@hop-top/kit 0.5.0-alpha.3 → 0.5.0-alpha.5
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 +52 -0
- package/LICENSE +1 -1
- package/README.md +47 -575
- package/dist/{aim-CTp-kJW2.d.ts → aim-DZHwwiIc.d.ts} +1 -1
- package/dist/aim.d.ts +1 -1
- package/dist/aim.js +13 -414
- package/dist/{alias-dhhr08Ei.d.ts → alias-BOj0-VAr.d.ts} +1 -1
- package/dist/alias.d.ts +1 -1
- package/dist/alias.js +18 -206
- package/dist/{api-miiso81x.d.ts → api-DAexsu2H.d.ts} +1 -1
- package/dist/api.d.ts +1 -1
- package/dist/api.js +10 -164
- package/dist/auth.js +6 -40
- package/dist/chunk-3FIKGFKI.js +54 -0
- package/dist/chunk-4UE5TCMQ.js +104 -0
- package/dist/chunk-6HFAEZ52.js +29 -0
- package/dist/chunk-6SVOHNIC.js +17 -0
- package/dist/chunk-72XZWQX7.js +504 -0
- package/dist/chunk-ABQSE7AI.js +513 -0
- package/dist/chunk-BDNNPRX6.js +41 -0
- package/dist/chunk-BRNEKPWX.js +37 -0
- package/dist/chunk-CSJWB6D3.js +151 -0
- package/dist/chunk-GGWJRWWA.js +309 -0
- package/dist/chunk-IQXEISMC.js +142 -0
- package/dist/chunk-IXVQ62NZ.js +334 -0
- package/dist/chunk-JTMPNXVQ.js +1491 -0
- package/dist/chunk-KVG7YCTS.js +115 -0
- package/dist/chunk-L23O2FFE.js +51 -0
- package/dist/chunk-MQXYDYRD.js +968 -0
- package/dist/chunk-MUIQVU6E.js +251 -0
- package/dist/chunk-POR5L2DG.js +247 -0
- package/dist/chunk-PSFYJGDG.js +1445 -0
- package/dist/chunk-QJVSKKRQ.js +369 -0
- package/dist/chunk-QPUCXQXT.js +67 -0
- package/dist/chunk-R5U7XKVJ.js +16 -0
- package/dist/chunk-S45UHXQF.js +182 -0
- package/dist/chunk-T46YPHKN.js +669 -0
- package/dist/chunk-UKZIAQA7.js +26 -0
- package/dist/chunk-WBVO43HU.js +355 -0
- package/dist/chunk-WUOAQVOA.js +86 -0
- package/dist/chunk-WWUKGJB5.js +90 -0
- package/dist/chunk-YGYQUFGY.js +219 -0
- package/dist/chunk-YOBAUCVN.js +583 -0
- package/dist/chunk-ZC5TZYZJ.js +609 -0
- package/dist/{cli-DLygZLi9.d.ts → cli-8rfITnv4.d.ts} +13 -4
- package/dist/cli.d.ts +4 -4
- package/dist/cli.js +51 -1057
- package/dist/{config-BUY7_W2n.d.ts → config-Bm9fBXch.d.ts} +35 -4
- package/dist/config.d.ts +1 -1
- package/dist/config.js +6 -78
- package/dist/errcorrect.js +8 -68
- package/dist/{error-DISJKeDu.d.ts → error-Do8Qji43.d.ts} +88 -1
- package/dist/id/index.d.ts +1 -1
- package/dist/id/index.js +14 -65
- package/dist/{index-MLrRDvEG.d.ts → index-B-pqGHhU.d.ts} +113 -19
- package/dist/{index-Bc5c7Ty5.d.ts → index-DEyjGoo2.d.ts} +1 -1
- package/dist/{index-QSffbLnj.d.ts → index-VLDcI5NF.d.ts} +3 -2
- package/dist/index.d.ts +18 -15
- package/dist/index.js +39 -6722
- 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 -1
- package/dist/llm.js +101 -356
- package/dist/mcp/index.d.ts +2 -1
- package/dist/mcp/index.js +155 -1453
- package/dist/{netpolicy-asvCfwi8.d.ts → netpolicy-Brx5XZUB.d.ts} +16 -3
- package/dist/netpolicy.d.ts +1 -1
- package/dist/netpolicy.js +25 -118
- package/dist/{output-4aXs91GY.d.ts → output-CjZWmL8s.d.ts} +28 -4
- package/dist/output.d.ts +2 -2
- package/dist/output.js +137 -971
- package/dist/progress.js +6 -55
- package/dist/provenance.js +6 -31
- package/dist/routellm-B0nv59mH.d.ts +111 -0
- package/dist/routellm.d.ts +2 -2
- package/dist/routellm.js +13 -255
- package/dist/{rpc-D5xLEf8V.d.ts → rpc-D31Lg0Kc.d.ts} +1 -1
- package/dist/rpc.d.ts +2 -2
- package/dist/rpc.js +4 -98
- package/dist/safety.js +6 -43
- package/dist/scope.js +20 -377
- package/dist/{serve-DE-jscpb.d.ts → serve-D8yWMrTc.d.ts} +2 -2
- package/dist/serve.d.ts +2 -2
- package/dist/serve.js +75 -1019
- package/dist/sqlstore.js +6 -39
- package/dist/stream.js +8 -51
- package/dist/telemetry/index.js +24 -608
- package/dist/tui/index.d.ts +5 -5
- package/dist/tui/index.js +17 -374
- package/dist/upgrade.js +6 -114
- package/dist/xdg.js +14 -128
- package/package.json +130 -25
- package/src/README.md +15 -0
- package/src/cli.help-command.test.ts +105 -0
- package/src/cli.test.ts +95 -1
- package/src/cli.ts +78 -13
- package/src/completion-values.test.ts +10 -10
- package/src/compliance.test.ts +196 -2
- package/src/compliance.ts +440 -20
- package/src/config.test.ts +187 -1
- package/src/config.ts +173 -7
- 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 +12 -0
- package/src/index.ts +2 -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/mcp/README.md +57 -0
- package/src/mcp/conformance.test.ts +24 -3
- package/src/mcp/dispatch.ts +4 -4
- package/src/mcp/identity.test.ts +166 -0
- package/src/mcp/identity.ts +72 -0
- package/src/mcp/index.ts +6 -0
- package/src/mcp/legacy.ts +21 -8
- package/src/mcp/mcp.test.ts +14 -4
- package/src/mcp/modern-confirm.ts +1 -1
- package/src/mcp/modern.ts +12 -11
- package/src/mcp/tasks.ts +1 -1
- package/src/mcp/types.ts +80 -8
- package/src/netpolicy.test.ts +78 -0
- package/src/netpolicy.ts +28 -3
- package/src/output/README.md +46 -0
- package/src/output/builtins.ts +5 -5
- package/src/output/error.ts +144 -1
- package/src/output/formatters/README.md +50 -0
- package/src/output.ts +24 -1
- package/src/published-types.test.ts +115 -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.ts +1 -1
- package/src/telemetry/README.md +48 -0
- package/src/telemetry/client.ts +5 -5
- package/src/toolspec.test.ts +2 -2
- package/src/triton/README.md +34 -0
- package/src/tui/README.md +42 -0
- package/src/wizard.test.ts +7 -7
- package/test/llm/conformance-helpers.ts +100 -0
- package/test/output/dispatch.test.ts +1 -2
- package/test/output/error.test.ts +33 -2
- 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/tsconfig.json +3 -1
- package/tsconfig.test.json +10 -0
- package/vitest.config.ts +9 -0
- package/dist/llm-B5XUWH8T.d.ts +0 -231
- package/dist/routellm-PGSt2D1y.d.ts +0 -75
|
@@ -6,9 +6,38 @@
|
|
|
6
6
|
* Merges configuration from up to three file layers in priority order:
|
|
7
7
|
* system → user → project → envOverride
|
|
8
8
|
*
|
|
9
|
-
* Each
|
|
9
|
+
* Each layer merges into `dst` with these rules:
|
|
10
|
+
*
|
|
11
|
+
* - Plain objects merge recursively, key by key, so a later layer only
|
|
12
|
+
* overrides the keys it sets (`db: {port: 2}` keeps an earlier `db.host`).
|
|
13
|
+
* - Arrays and scalars are replaced wholesale.
|
|
14
|
+
* - `null` clears an object or array; it leaves a scalar untouched.
|
|
15
|
+
* - On a type conflict (object vs non-object) the later value replaces the
|
|
16
|
+
* earlier one.
|
|
17
|
+
* - Non-plain objects (`Date`, `Map`, class instances) are never merged
|
|
18
|
+
* into; a later value replaces them.
|
|
19
|
+
*
|
|
20
|
+
* This matches Go's `kit/core/config` for struct fields. Go differs where its
|
|
21
|
+
* target type differs: a `map[...]` value or an `any` field is replaced
|
|
22
|
+
* whole rather than merged, and a type conflict on a typed field is a decode
|
|
23
|
+
* error rather than a replacement.
|
|
24
|
+
*
|
|
10
25
|
* Missing files are silently skipped. A file that exists but contains invalid
|
|
11
|
-
* YAML causes {@link load} to throw.
|
|
26
|
+
* YAML causes {@link load} to throw. A document whose root is not a mapping
|
|
27
|
+
* is ignored.
|
|
28
|
+
*
|
|
29
|
+
* Each file is checked before it merges, with aliases expanded, and
|
|
30
|
+
* {@link load} throws `config: failed to parse <path>: <reason>` when:
|
|
31
|
+
*
|
|
32
|
+
* - its aliases expand past Go yaml.v3's budget: more than 100 nodes inside
|
|
33
|
+
* alias expansions and more than 1000 in total, with the share inside
|
|
34
|
+
* aliases above 0.99 (up to 400k nodes), falling linearly to 0.10 at 4M
|
|
35
|
+
* (`document contains excessive aliasing`). Go counts only the keys its
|
|
36
|
+
* target struct reads; TS has no target, so it counts every key, and a
|
|
37
|
+
* file Go accepts because the aliases sit under ignored keys fails here.
|
|
38
|
+
* - collections nest deeper than 100, counted through aliases
|
|
39
|
+
* (`nesting exceeded maxDepth (100)`). Go allows 10000 levels of text
|
|
40
|
+
* nesting and caps alias chains only through the budget above.
|
|
12
41
|
*
|
|
13
42
|
* @example
|
|
14
43
|
* ```ts
|
|
@@ -50,12 +79,12 @@ interface Options<T extends object = object> {
|
|
|
50
79
|
systemConfigPath?: string;
|
|
51
80
|
/**
|
|
52
81
|
* Path to the per-user config file, e.g. `~/.config/mytool/config.yaml`.
|
|
53
|
-
* Applied second;
|
|
82
|
+
* Applied second; merges over system values (see the module merge rules).
|
|
54
83
|
*/
|
|
55
84
|
userConfigPath?: string;
|
|
56
85
|
/**
|
|
57
86
|
* Path to the project-level config file, e.g. `.mytool.yaml`.
|
|
58
|
-
* Applied third;
|
|
87
|
+
* Applied third; merges over system and user values.
|
|
59
88
|
*/
|
|
60
89
|
projectConfigPath?: string;
|
|
61
90
|
/**
|
|
@@ -73,6 +102,8 @@ interface Options<T extends object = object> {
|
|
|
73
102
|
* Merge order: `systemConfigPath` → `userConfigPath` → `projectConfigPath` →
|
|
74
103
|
* `envOverride`.
|
|
75
104
|
*
|
|
105
|
+
* - Objects merge recursively; arrays and scalars replace; `null` clears
|
|
106
|
+
* objects and arrays but not scalars (see the module docs for details).
|
|
76
107
|
* - Missing files (ENOENT) are silently skipped.
|
|
77
108
|
* - A file that exists but is not valid YAML causes this function to throw
|
|
78
109
|
* a descriptive error wrapping the parse failure.
|
package/dist/config.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { O as Options, l as load } from './config-
|
|
1
|
+
export { O as Options, l as load } from './config-Bm9fBXch.js';
|
package/dist/config.js
CHANGED
|
@@ -1,79 +1,7 @@
|
|
|
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
|
-
|
|
32
|
-
|
|
33
|
-
|
|
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
|
+
var _chunkIQXEISMCjs = require('./chunk-IQXEISMC.js');
|
|
4
|
+
require('./chunk-R5U7XKVJ.js');
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
exports.load = _chunkIQXEISMCjs.load;
|
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;
|
|
@@ -30,8 +30,15 @@ declare const CODE_NOT_FOUND = "NOT_FOUND";
|
|
|
30
30
|
declare const CODE_CONFLICT = "CONFLICT";
|
|
31
31
|
declare const CODE_UNAUTHORIZED = "UNAUTHORIZED";
|
|
32
32
|
declare const CODE_TRANSIENT = "TRANSIENT";
|
|
33
|
+
declare const CODE_CONSENT_REFUSED = "CONSENT_REFUSED";
|
|
33
34
|
declare const CODE_PROVENANCE_MISSING = "PROVENANCE_MISSING";
|
|
34
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;
|
|
35
42
|
/**
|
|
36
43
|
* Spec-assigned exit code for the generic failure class: the command
|
|
37
44
|
* failed and no narrower code applies. Pair it with {@link genericError}
|
|
@@ -39,12 +46,41 @@ declare const CODE_RATE_LIMITED = "RATE_LIMITED";
|
|
|
39
46
|
* class.
|
|
40
47
|
*/
|
|
41
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;
|
|
42
69
|
/**
|
|
43
70
|
* Spec-assigned exit code for transient/retryable failures (Factor 11).
|
|
44
71
|
* Agents branch on it before parsing stderr: exit 6 means a retry may
|
|
45
72
|
* clear the failure.
|
|
46
73
|
*/
|
|
47
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;
|
|
48
84
|
/** Conventional exit code for Factor-10 rate-limit refusals. */
|
|
49
85
|
declare const EXIT_RATE_LIMITED = 64;
|
|
50
86
|
/**
|
|
@@ -54,6 +90,16 @@ declare const EXIT_RATE_LIMITED = 64;
|
|
|
54
90
|
* codes, and kit as a library stays out of the low per-tool range.
|
|
55
91
|
*/
|
|
56
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;
|
|
57
103
|
/**
|
|
58
104
|
* Structured-error envelope rendered to stderr when `--format json|yaml`
|
|
59
105
|
* is set. Keys are the on-wire snake_case names.
|
|
@@ -79,6 +125,24 @@ interface CliError {
|
|
|
79
125
|
* (or use {@link withTransience}) to classify their own codes.
|
|
80
126
|
*/
|
|
81
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[];
|
|
82
146
|
/**
|
|
83
147
|
* Builds an envelope from `err`, retaining it for {@link unwrapError}
|
|
84
148
|
* while rendering as `code` and message. Transience defaults from the
|
|
@@ -121,6 +185,29 @@ declare function usageError(message: string): CliError;
|
|
|
121
185
|
* service-unavailable responses.
|
|
122
186
|
*/
|
|
123
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;
|
|
124
211
|
/** CODE_RATE_LIMITED envelope with exit code 64 (Factor 10). */
|
|
125
212
|
declare function rateLimitedError(message: string): CliError;
|
|
126
213
|
/**
|
|
@@ -141,4 +228,4 @@ declare function renderError(w: {
|
|
|
141
228
|
write(chunk: string): unknown;
|
|
142
229
|
}, format: string, err: CliError | null | undefined): void;
|
|
143
230
|
|
|
144
|
-
export {
|
|
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,2 +1,2 @@
|
|
|
1
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-
|
|
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';
|
package/dist/id/index.js
CHANGED
|
@@ -1,66 +1,15 @@
|
|
|
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
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
return (0, import_typeid_js.typeid)(prefix).toString();
|
|
34
|
-
}
|
|
35
|
-
function parse(s) {
|
|
36
|
-
const tid = import_typeid_js.TypeID.fromString(s);
|
|
37
|
-
return {
|
|
38
|
-
prefix: tid.getType(),
|
|
39
|
-
uuid: tid.toUUID()
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
function newTyped(prefix) {
|
|
43
|
-
return (0, import_typeid_js.typeid)(prefix).toString();
|
|
44
|
-
}
|
|
45
|
-
function parseTyped(prefix, s) {
|
|
46
|
-
const tid = import_typeid_js.TypeID.fromString(s, prefix);
|
|
47
|
-
return tid.toString();
|
|
48
|
-
}
|
|
49
|
-
var SUFFIX_RE = /^[0-7][0-9a-hjkmnp-tv-z]{25}$/;
|
|
50
|
-
function typeIdSchema(prefix) {
|
|
51
|
-
const pattern = new RegExp(
|
|
52
|
-
`^${escapeRegExp(prefix)}_${SUFFIX_RE.source.slice(1, -1)}$`
|
|
53
|
-
);
|
|
54
|
-
return import_zod.z.string().regex(pattern, `invalid typeid for prefix '${prefix}'`);
|
|
55
|
-
}
|
|
56
|
-
function escapeRegExp(s) {
|
|
57
|
-
return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
58
|
-
}
|
|
59
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
60
|
-
0 && (module.exports = {
|
|
61
|
-
newId,
|
|
62
|
-
newTyped,
|
|
63
|
-
parse,
|
|
64
|
-
parseTyped,
|
|
65
|
-
typeIdSchema
|
|
66
|
-
});
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
var _chunkL23O2FFEjs = require('../chunk-L23O2FFE.js');
|
|
8
|
+
require('../chunk-R5U7XKVJ.js');
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
exports.newId = _chunkL23O2FFEjs.newId; exports.newTyped = _chunkL23O2FFEjs.newTyped; exports.parse = _chunkL23O2FFEjs.parse; exports.parseTyped = _chunkL23O2FFEjs.parseTyped; exports.typeIdSchema = _chunkL23O2FFEjs.typeIdSchema;
|