@hop-top/kit 0.5.0-alpha.1 → 0.5.0-alpha.11
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.
- package/CHANGELOG.md +275 -0
- package/LICENSE +1 -1
- package/LICENSE-cobra.txt +174 -0
- package/NOTICE +15 -0
- package/README.md +55 -259
- package/dist/aim-DZHwwiIc.d.ts +139 -0
- package/dist/aim.d.ts +1 -116
- package/dist/aim.js +13 -414
- package/dist/alias-D9_qFlyP.d.ts +174 -0
- package/dist/alias.d.ts +2 -73
- package/dist/alias.js +27 -207
- package/dist/api-DAexsu2H.d.ts +77 -0
- package/dist/api.d.ts +1 -62
- package/dist/api.js +10 -164
- package/dist/auth-2-jfgiHn.d.ts +34 -0
- package/dist/auth.d.ts +1 -26
- package/dist/auth.js +6 -40
- package/dist/chunk-3FIKGFKI.js +54 -0
- package/dist/chunk-4FMALWYB.js +669 -0
- package/dist/chunk-4GPCWBBA.js +143 -0
- package/dist/chunk-4UE5TCMQ.js +104 -0
- package/dist/chunk-65VPWMPV.js +1134 -0
- package/dist/chunk-6HFAEZ52.js +29 -0
- package/dist/chunk-6SVOHNIC.js +17 -0
- package/dist/chunk-BDNNPRX6.js +41 -0
- package/dist/chunk-BRNEKPWX.js +37 -0
- package/dist/chunk-BXJ2J27B.js +219 -0
- package/dist/chunk-CSJWB6D3.js +151 -0
- package/dist/chunk-CXBZTONY.js +65 -0
- package/dist/chunk-EE4M2UOF.js +818 -0
- package/dist/chunk-GFRAYYRD.js +817 -0
- package/dist/chunk-IVQHLI56.js +1890 -0
- package/dist/chunk-IZ6Q4SE3.js +178 -0
- package/dist/chunk-JKMQSAJP.js +174 -0
- package/dist/chunk-K7E34Q3A.js +1445 -0
- package/dist/chunk-KVG7YCTS.js +115 -0
- package/dist/chunk-L23O2FFE.js +51 -0
- package/dist/chunk-MFVUENZR.js +1549 -0
- package/dist/chunk-ML7D5DWY.js +263 -0
- package/dist/chunk-MQXYDYRD.js +968 -0
- package/dist/chunk-POR5L2DG.js +247 -0
- package/dist/chunk-QJVSKKRQ.js +369 -0
- package/dist/chunk-QQQYCWSC.js +240 -0
- package/dist/chunk-R5U7XKVJ.js +16 -0
- package/dist/chunk-RYKLVOVK.js +309 -0
- package/dist/chunk-SNVGDYX7.js +187 -0
- package/dist/chunk-T6OZMPPV.js +68 -0
- package/dist/chunk-UKZIAQA7.js +26 -0
- package/dist/chunk-VGOA5Y7S.js +251 -0
- package/dist/chunk-VWGP4NVJ.js +513 -0
- package/dist/chunk-WBVO43HU.js +355 -0
- package/dist/chunk-WUOAQVOA.js +86 -0
- package/dist/chunk-XJTRY453.js +868 -0
- package/dist/chunk-YOBAUCVN.js +583 -0
- package/dist/cli-RSRk1M36.d.ts +707 -0
- package/dist/cli.d.ts +7 -309
- package/dist/cli.js +125 -945
- package/dist/completion-csVun6SP.d.ts +112 -0
- package/dist/completion-values-By-mnjNt.d.ts +142 -0
- package/dist/completion-values.d.ts +1 -0
- package/dist/completion-values.js +29 -0
- package/dist/completion.d.ts +3 -0
- package/dist/completion.js +34 -0
- package/dist/compliance-AxFf-uMy.d.ts +60 -0
- package/dist/compliance.d.ts +1 -0
- package/dist/compliance.js +17 -0
- package/dist/config-CaK60ByQ.d.ts +241 -0
- package/dist/config.d.ts +1 -97
- package/dist/config.js +8 -78
- package/dist/errcorrect-BcX1Ft0K.d.ts +44 -0
- package/dist/errcorrect.d.ts +1 -37
- package/dist/errcorrect.js +8 -68
- package/dist/error-Do8Qji43.d.ts +231 -0
- package/dist/id/index.d.ts +2 -83
- package/dist/id/index.js +14 -65
- package/dist/index-BKJZClJx.d.ts +1486 -0
- package/dist/index-C3Zw4wDJ.d.ts +359 -0
- package/dist/index-CGE5yLBj.d.ts +328 -0
- package/dist/index-VLDcI5NF.d.ts +95 -0
- package/dist/index.d.ts +37 -0
- package/dist/index.js +132 -0
- package/dist/llm-DYuR7_uX.d.ts +1069 -0
- package/dist/llm-anthropic-Cd_I2xXB.d.ts +67 -0
- package/dist/llm-anthropic.d.ts +2 -0
- package/dist/llm-anthropic.js +13 -0
- package/dist/llm-openai-DyFrucmV.d.ts +87 -0
- package/dist/llm-openai.d.ts +2 -0
- package/dist/llm-openai.js +19 -0
- package/dist/llm.d.ts +1 -188
- package/dist/llm.js +101 -356
- package/dist/log-CkaxMX3U.d.ts +115 -0
- package/dist/log.d.ts +2 -0
- package/dist/log.js +14 -0
- package/dist/mcp/index.d.ts +4 -0
- package/dist/mcp/index.js +185 -0
- package/dist/netpolicy-Brx5XZUB.d.ts +151 -0
- package/dist/netpolicy.d.ts +1 -0
- package/dist/netpolicy.js +25 -0
- package/dist/output-CjZWmL8s.d.ts +420 -0
- package/dist/output.d.ts +3 -213
- package/dist/output.js +135 -447
- package/dist/parity-CvMuYcVI.d.ts +61 -0
- package/dist/progress-CAzyxeWl.d.ts +38 -0
- package/dist/progress.d.ts +1 -30
- package/dist/progress.js +6 -55
- package/dist/provenance-SMFHm5gx.d.ts +30 -0
- package/dist/provenance.d.ts +1 -24
- package/dist/provenance.js +6 -31
- package/dist/routellm-B0nv59mH.d.ts +111 -0
- package/dist/routellm.d.ts +2 -64
- package/dist/routellm.js +13 -255
- package/dist/rpc-D31Lg0Kc.d.ts +32 -0
- package/dist/rpc.d.ts +2 -25
- package/dist/rpc.js +4 -98
- package/dist/safety-CUaYEjZc.d.ts +30 -0
- package/dist/safety.d.ts +1 -24
- package/dist/safety.js +6 -43
- package/dist/scope-BrhYB4ij.d.ts +141 -0
- package/dist/scope.d.ts +1 -121
- package/dist/scope.js +20 -377
- package/dist/serve-D8yWMrTc.d.ts +646 -0
- package/dist/serve.d.ts +3 -0
- package/dist/serve.js +75 -0
- package/dist/sqlstore.js +6 -39
- package/dist/stream-CrjeCp0M.d.ts +44 -0
- package/dist/stream.d.ts +1 -35
- package/dist/stream.js +8 -51
- package/dist/telemetry/index.d.ts +1 -315
- package/dist/telemetry/index.js +26 -599
- package/dist/toolspec-DcPwwoAZ.d.ts +368 -0
- package/dist/toolspec.d.ts +2 -0
- package/dist/toolspec.js +37 -0
- package/dist/tui/index.d.ts +6 -298
- package/dist/tui/index.js +17 -381
- package/dist/upgrade-C3RWGwRi.d.ts +125 -0
- package/dist/upgrade.d.ts +1 -95
- package/dist/upgrade.js +6 -114
- package/dist/xdg-DB7Shoib.d.ts +179 -0
- package/dist/xdg.d.ts +1 -169
- package/dist/xdg.js +14 -128
- package/package.json +192 -24
- package/src/README.md +15 -0
- package/src/alias.conformance.test.ts +250 -0
- package/src/alias.test.ts +206 -2
- package/src/alias.ts +196 -21
- package/src/cli.help-command.test.ts +105 -0
- package/src/cli.offline.test.ts +93 -0
- package/src/cli.parity.test.ts +192 -0
- package/src/cli.root.conformance.test.ts +166 -0
- package/src/cli.test.ts +95 -1
- package/src/cli.ts +234 -25
- package/src/completion-scripts.ts +16 -0
- package/src/completion-values.test.ts +76 -16
- package/src/completion-values.ts +170 -66
- package/src/completion.conformance.test.ts +298 -0
- package/src/completion.test.ts +268 -145
- package/src/completion.ts +772 -121
- package/src/compliance.test.ts +196 -2
- package/src/compliance.ts +440 -20
- package/src/config-merge.test.ts +425 -0
- package/src/config.test.ts +228 -1
- package/src/config.ts +429 -16
- package/src/delegation.test.ts +299 -0
- package/src/delegation.ts +807 -0
- package/src/gen/crud_pb.ts +7 -7
- package/src/id/README.md +38 -0
- package/src/id/contract.test.ts +1 -1
- package/src/id/index.test.ts +1 -1
- package/src/id/index.ts +3 -2
- package/src/index.test.ts +71 -0
- package/src/index.ts +46 -0
- package/src/llm-anthropic.conformance.test.ts +1135 -0
- package/src/llm-anthropic.test.ts +152 -0
- package/src/llm-anthropic.ts +940 -0
- package/src/llm-choice-hermetic.test.ts +335 -0
- package/src/llm-config.test.ts +232 -0
- package/src/llm-config.ts +106 -0
- package/src/llm-endpoint.ts +254 -0
- package/src/llm-error.ts +17 -0
- package/src/llm-errors.ts +152 -0
- package/src/llm-file.ts +126 -0
- package/src/llm-http.ts +317 -0
- package/src/llm-keys.ts +167 -0
- package/src/llm-media.conformance.test.ts +87 -0
- package/src/llm-media.test.ts +279 -0
- package/src/llm-media.ts +322 -0
- package/src/llm-openai.conformance.test.ts +407 -0
- package/src/llm-openai.test.ts +510 -0
- package/src/llm-openai.ts +708 -0
- package/src/llm-payload.ts +155 -0
- package/src/llm-quote.ts +46 -0
- package/src/llm-routellm.conformance.test.ts +44 -0
- package/src/llm-toolnames.conformance.test.ts +112 -0
- package/src/llm-toolnames.test.ts +132 -0
- package/src/llm-toolnames.ts +298 -0
- package/src/llm-uri.ts +99 -0
- package/src/llm.test.ts +43 -15
- package/src/llm.toolcall.test.ts +175 -0
- package/src/llm.ts +602 -190
- package/src/log.parity.test.ts +105 -0
- package/src/log.test.ts +270 -1
- package/src/log.ts +228 -49
- package/src/mcp/README.md +63 -0
- package/src/mcp/args-separator.test.ts +164 -0
- package/src/mcp/args.test.ts +223 -0
- package/src/mcp/args.ts +160 -0
- package/src/mcp/audit.test.ts +520 -0
- package/src/mcp/audit.ts +70 -0
- package/src/mcp/bridge.test.ts +250 -0
- package/src/mcp/bridge.ts +286 -0
- package/src/mcp/conformance.test.ts +357 -0
- package/src/mcp/dispatch.ts +359 -0
- package/src/mcp/identity.test.ts +166 -0
- package/src/mcp/identity.ts +72 -0
- package/src/mcp/index.ts +176 -0
- package/src/mcp/legacy-notify.test.ts +59 -0
- package/src/mcp/legacy.ts +367 -0
- package/src/mcp/mcp.test.ts +707 -0
- package/src/mcp/modern-confirm.test.ts +520 -0
- package/src/mcp/modern-confirm.ts +484 -0
- package/src/mcp/modern.ts +788 -0
- package/src/mcp/stdio.test.ts +313 -0
- package/src/mcp/stdio.ts +254 -0
- package/src/mcp/tasks.ts +82 -0
- package/src/mcp/testtree.ts +250 -0
- package/src/mcp/toolname.test.ts +147 -0
- package/src/mcp/types.ts +689 -0
- package/src/netpolicy.test.ts +280 -0
- package/src/netpolicy.ts +256 -0
- package/src/output/README.md +46 -0
- package/src/output/builtins.ts +5 -5
- package/src/output/dispatch.ts +10 -2
- package/src/output/error.ts +459 -0
- package/src/output/formatter.ts +29 -5
- package/src/output/formatters/README.md +50 -0
- package/src/output/formatters/csv.ts +48 -12
- package/src/output/formatters/json.ts +4 -25
- package/src/output/formatters/project.ts +34 -0
- package/src/output/formatters/table.ts +8 -6
- package/src/output/formatters/text.ts +7 -3
- package/src/output/formatters/yaml.ts +5 -22
- package/src/output/projection.test.ts +298 -0
- package/src/output/projection.ts +33 -59
- package/src/output/template.ts +11 -21
- package/src/output.surface.test.ts +41 -0
- package/src/output.ts +64 -3
- package/src/plan.ts +89 -0
- package/src/policy.ts +472 -0
- package/src/published-types.test.ts +133 -0
- package/src/routellm.test.ts +209 -28
- package/src/routellm.toolcall.test.ts +521 -0
- package/src/routellm.ts +213 -177
- package/src/router/README.md +44 -0
- package/src/router/server.test.ts +41 -0
- package/src/router/server.ts +11 -0
- package/src/safety.test.ts +19 -9
- package/src/scope-defaults.json +29 -29
- package/src/serve.test.ts +1257 -0
- package/src/serve.ts +1665 -0
- package/src/sideeffect.ts +105 -0
- package/src/telemetry/README.md +48 -0
- package/src/telemetry/client.test.ts +31 -0
- package/src/telemetry/client.ts +12 -6
- package/src/telemetry/offline.test.ts +64 -0
- package/src/toolspec-internal.ts +279 -0
- package/src/toolspec-manifest.test.ts +167 -0
- package/src/toolspec-manifest.ts +415 -0
- package/src/toolspec-spec-schemas.ts +12 -0
- package/src/toolspec-spec.test.ts +273 -0
- package/src/toolspec-spec.ts +458 -0
- package/src/toolspec.from-command.test.ts +350 -0
- package/src/toolspec.test.ts +2 -2
- package/src/toolspec.ts +222 -0
- package/src/triton/README.md +34 -0
- package/src/tui/README.md +42 -0
- package/src/tui/parity.test.ts +120 -31
- package/src/tui/parity.ts +58 -7
- package/src/upgrade.test.ts +291 -0
- package/src/upgrade.ts +116 -7
- package/src/wizard.test.ts +7 -7
- package/test/llm/conformance-helpers.ts +100 -0
- package/test/output/csv.test.ts +164 -0
- package/test/output/dispatch.test.ts +1 -2
- package/test/output/error.test.ts +277 -0
- package/test/output/smoke-capture.ts +2 -2
- package/test/output/smoke.test.ts +2 -2
- package/test/output/taxonomy-contract.test.ts +148 -0
- package/test/setup-env.ts +16 -0
- package/test/toolspec/fixture.ts +79 -0
- package/tsconfig.json +3 -1
- package/tsconfig.test.json +10 -0
- package/vitest.config.ts +9 -0
- package/src/tui/parity.json +0 -74
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
|
-
|
|
31
|
-
var
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
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 };
|
package/dist/errcorrect.d.ts
CHANGED
|
@@ -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';
|
package/dist/errcorrect.js
CHANGED
|
@@ -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
|
-
|
|
21
|
-
var
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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 };
|
package/dist/id/index.d.ts
CHANGED
|
@@ -1,83 +1,2 @@
|
|
|
1
|
-
import
|
|
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';
|