@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
package/dist/api.js
CHANGED
|
@@ -1,165 +1,11 @@
|
|
|
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
|
-
constructor(err) {
|
|
30
|
-
super(err.message);
|
|
31
|
-
this.name = "APIRequestError";
|
|
32
|
-
this.status = err.status;
|
|
33
|
-
this.code = err.code;
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
var APIClient = class {
|
|
37
|
-
constructor(baseURL, opts) {
|
|
38
|
-
this.baseURL = baseURL.replace(/\/+$/, "");
|
|
39
|
-
this.auth = opts?.auth;
|
|
40
|
-
this.fetchFn = opts?.fetch ?? globalThis.fetch.bind(globalThis);
|
|
41
|
-
}
|
|
42
|
-
headers() {
|
|
43
|
-
const h = {
|
|
44
|
-
"Content-Type": "application/json"
|
|
45
|
-
};
|
|
46
|
-
if (this.auth) {
|
|
47
|
-
h["Authorization"] = `Bearer ${this.auth}`;
|
|
48
|
-
}
|
|
49
|
-
return h;
|
|
50
|
-
}
|
|
51
|
-
async request(method, path, body) {
|
|
52
|
-
const res = await this.fetchFn(`${this.baseURL}${path}`, {
|
|
53
|
-
method,
|
|
54
|
-
headers: this.headers(),
|
|
55
|
-
body: body !== void 0 ? JSON.stringify(body) : void 0
|
|
56
|
-
});
|
|
57
|
-
if (!res.ok) {
|
|
58
|
-
let err;
|
|
59
|
-
try {
|
|
60
|
-
err = await res.json();
|
|
61
|
-
} catch {
|
|
62
|
-
err = {
|
|
63
|
-
status: res.status,
|
|
64
|
-
code: "unknown",
|
|
65
|
-
message: res.statusText
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
throw new APIRequestError(err);
|
|
69
|
-
}
|
|
70
|
-
if (res.status === 204) return void 0;
|
|
71
|
-
return await res.json();
|
|
72
|
-
}
|
|
73
|
-
async create(entity) {
|
|
74
|
-
return this.request("POST", "/", entity);
|
|
75
|
-
}
|
|
76
|
-
async get(id) {
|
|
77
|
-
return this.request("GET", `/${encodeURIComponent(id)}`);
|
|
78
|
-
}
|
|
79
|
-
async list(q) {
|
|
80
|
-
const params = new URLSearchParams();
|
|
81
|
-
if (q?.limit !== void 0) params.set("limit", String(q.limit));
|
|
82
|
-
if (q?.offset !== void 0) params.set("offset", String(q.offset));
|
|
83
|
-
if (q?.sort) params.set("sort", q.sort);
|
|
84
|
-
if (q?.search) params.set("search", q.search);
|
|
85
|
-
const qs = params.toString();
|
|
86
|
-
return this.request("GET", `/${qs ? `?${qs}` : ""}`);
|
|
87
|
-
}
|
|
88
|
-
async update(entity) {
|
|
89
|
-
return this.request(
|
|
90
|
-
"PUT",
|
|
91
|
-
`/${encodeURIComponent(entity.id)}`,
|
|
92
|
-
entity
|
|
93
|
-
);
|
|
94
|
-
}
|
|
95
|
-
async delete(id) {
|
|
96
|
-
return this.request(
|
|
97
|
-
"DELETE",
|
|
98
|
-
`/${encodeURIComponent(id)}`
|
|
99
|
-
);
|
|
100
|
-
}
|
|
101
|
-
};
|
|
102
|
-
var WSClient = class _WSClient {
|
|
103
|
-
constructor(url) {
|
|
104
|
-
this.handlers = [];
|
|
105
|
-
this.url = url;
|
|
106
|
-
}
|
|
107
|
-
static async resolveWS() {
|
|
108
|
-
if (typeof globalThis.WebSocket !== "undefined") {
|
|
109
|
-
return globalThis.WebSocket;
|
|
110
|
-
}
|
|
111
|
-
try {
|
|
112
|
-
return require("ws");
|
|
113
|
-
} catch {
|
|
114
|
-
}
|
|
115
|
-
throw new Error("ws: no WebSocket implementation available");
|
|
116
|
-
}
|
|
117
|
-
async connect() {
|
|
118
|
-
const WS = await _WSClient.resolveWS();
|
|
119
|
-
return new Promise((resolve, reject) => {
|
|
120
|
-
const ws = new WS(this.url);
|
|
121
|
-
ws.onopen = () => {
|
|
122
|
-
this.ws = ws;
|
|
123
|
-
resolve();
|
|
124
|
-
};
|
|
125
|
-
ws.onerror = (e) => {
|
|
126
|
-
reject(e);
|
|
127
|
-
};
|
|
128
|
-
ws.onmessage = (ev) => {
|
|
129
|
-
try {
|
|
130
|
-
const msg = JSON.parse(
|
|
131
|
-
typeof ev.data === "string" ? ev.data : String(ev.data)
|
|
132
|
-
);
|
|
133
|
-
for (const fn of this.handlers) {
|
|
134
|
-
fn(msg);
|
|
135
|
-
}
|
|
136
|
-
} catch {
|
|
137
|
-
}
|
|
138
|
-
};
|
|
139
|
-
});
|
|
140
|
-
}
|
|
141
|
-
subscribe(topic) {
|
|
142
|
-
this.send({ type: "subscribe", topic, payload: null });
|
|
143
|
-
}
|
|
144
|
-
unsubscribe(topic) {
|
|
145
|
-
this.send({ type: "unsubscribe", topic, payload: null });
|
|
146
|
-
}
|
|
147
|
-
onMessage(fn) {
|
|
148
|
-
this.handlers.push(fn);
|
|
149
|
-
}
|
|
150
|
-
close() {
|
|
151
|
-
this.ws?.close();
|
|
152
|
-
this.ws = void 0;
|
|
153
|
-
this.handlers = [];
|
|
154
|
-
}
|
|
155
|
-
send(msg) {
|
|
156
|
-
if (!this.ws) throw new Error("ws: not connected");
|
|
157
|
-
this.ws.send(JSON.stringify(msg));
|
|
158
|
-
}
|
|
159
|
-
};
|
|
160
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
161
|
-
0 && (module.exports = {
|
|
162
|
-
APIClient,
|
|
163
|
-
APIRequestError,
|
|
164
|
-
WSClient
|
|
165
|
-
});
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
var _chunkCSJWB6D3js = require('./chunk-CSJWB6D3.js');
|
|
6
|
+
require('./chunk-R5U7XKVJ.js');
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
exports.APIClient = _chunkCSJWB6D3js.APIClient; exports.APIRequestError = _chunkCSJWB6D3js.APIRequestError; exports.WSClient = _chunkCSJWB6D3js.WSClient;
|
package/dist/auth.js
CHANGED
|
@@ -1,41 +1,7 @@
|
|
|
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
|
-
module.exports = __toCommonJS(auth_exports);
|
|
26
|
-
var NoAuth = class {
|
|
27
|
-
async inspect() {
|
|
28
|
-
return {
|
|
29
|
-
source: "none",
|
|
30
|
-
identity: "anonymous",
|
|
31
|
-
scopes: [],
|
|
32
|
-
renewable: false
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
async refresh() {
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
39
|
-
0 && (module.exports = {
|
|
40
|
-
NoAuth
|
|
41
|
-
});
|
|
3
|
+
var _chunkUKZIAQA7js = require('./chunk-UKZIAQA7.js');
|
|
4
|
+
require('./chunk-R5U7XKVJ.js');
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
exports.NoAuth = _chunkUKZIAQA7js.NoAuth;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
|
+
|
|
3
|
+
var _chunkR5U7XKVJjs = require('./chunk-R5U7XKVJ.js');
|
|
4
|
+
|
|
5
|
+
// src/errcorrect.ts
|
|
6
|
+
var errcorrect_exports = {};
|
|
7
|
+
_chunkR5U7XKVJjs.__export.call(void 0, errcorrect_exports, {
|
|
8
|
+
createCorrectedError: () => createCorrectedError,
|
|
9
|
+
formatError: () => formatError
|
|
10
|
+
});
|
|
11
|
+
function createCorrectedError(opts) {
|
|
12
|
+
const err = new Error(opts.message);
|
|
13
|
+
err.code = opts.code;
|
|
14
|
+
if (opts.cause !== void 0) err.cause = opts.cause;
|
|
15
|
+
if (opts.fix !== void 0) err.fix = opts.fix;
|
|
16
|
+
if (opts.alternatives !== void 0) err.alternatives = opts.alternatives;
|
|
17
|
+
if (opts.retryable !== void 0) err.retryable = opts.retryable;
|
|
18
|
+
err.toJSON = () => {
|
|
19
|
+
const o = {
|
|
20
|
+
code: err.code,
|
|
21
|
+
message: err.message
|
|
22
|
+
};
|
|
23
|
+
if (err.cause !== void 0) o.cause = err.cause;
|
|
24
|
+
if (err.fix !== void 0) o.fix = err.fix;
|
|
25
|
+
if (err.alternatives !== void 0) o.alternatives = err.alternatives;
|
|
26
|
+
if (err.retryable !== void 0) o.retryable = err.retryable;
|
|
27
|
+
return o;
|
|
28
|
+
};
|
|
29
|
+
return err;
|
|
30
|
+
}
|
|
31
|
+
function formatError(err, opts) {
|
|
32
|
+
const red = _optionalChain([opts, 'optionalAccess', _ => _.noColor]) ? (s) => s : (s) => `\x1B[31m${s}\x1B[0m`;
|
|
33
|
+
const bold = _optionalChain([opts, 'optionalAccess', _2 => _2.noColor]) ? (s) => s : (s) => `\x1B[1m${s}\x1B[0m`;
|
|
34
|
+
const lines = [];
|
|
35
|
+
lines.push(` ${red(bold("ERROR"))} ${err.message}`);
|
|
36
|
+
if (err.cause) {
|
|
37
|
+
lines.push(` Cause: ${err.cause}`);
|
|
38
|
+
}
|
|
39
|
+
if (err.fix) {
|
|
40
|
+
lines.push(` Fix: ${err.fix}`);
|
|
41
|
+
}
|
|
42
|
+
if (err.alternatives && err.alternatives.length > 0) {
|
|
43
|
+
for (const alt of err.alternatives) {
|
|
44
|
+
lines.push(` Try: ${alt}`);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return lines.join("\n");
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
exports.createCorrectedError = createCorrectedError; exports.formatError = formatError; exports.errcorrect_exports = errcorrect_exports;
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
|
|
2
|
+
|
|
3
|
+
var _chunkR5U7XKVJjs = require('./chunk-R5U7XKVJ.js');
|
|
4
|
+
|
|
5
|
+
// src/xdg.ts
|
|
6
|
+
var xdg_exports = {};
|
|
7
|
+
_chunkR5U7XKVJjs.__export.call(void 0, xdg_exports, {
|
|
8
|
+
cacheDir: () => cacheDir,
|
|
9
|
+
configDir: () => configDir,
|
|
10
|
+
dataDir: () => dataDir,
|
|
11
|
+
mustEnsure: () => mustEnsure,
|
|
12
|
+
stateDir: () => stateDir
|
|
13
|
+
});
|
|
14
|
+
var _os = require('os'); var os = _interopRequireWildcard(_os);
|
|
15
|
+
var _path = require('path'); var path = _interopRequireWildcard(_path);
|
|
16
|
+
var _fs = require('fs'); var fs = _interopRequireWildcard(_fs);
|
|
17
|
+
function platform(override) {
|
|
18
|
+
return _nullishCoalesce(override, () => ( process.platform));
|
|
19
|
+
}
|
|
20
|
+
function configDir(tool, plt) {
|
|
21
|
+
const xdg = process.env["XDG_CONFIG_HOME"];
|
|
22
|
+
if (xdg) return path.join(xdg, tool);
|
|
23
|
+
const p = platform(plt);
|
|
24
|
+
const home = os.homedir();
|
|
25
|
+
switch (p) {
|
|
26
|
+
case "darwin":
|
|
27
|
+
return path.join(home, "Library", "Preferences", tool);
|
|
28
|
+
case "win32": {
|
|
29
|
+
const appdata = process.env["APPDATA"];
|
|
30
|
+
if (!appdata) throw new Error("%APPDATA% is not set");
|
|
31
|
+
return path.join(appdata, tool);
|
|
32
|
+
}
|
|
33
|
+
default:
|
|
34
|
+
return path.join(home, ".config", tool);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
function dataDir(tool, plt) {
|
|
38
|
+
const xdg = process.env["XDG_DATA_HOME"];
|
|
39
|
+
if (xdg) return path.join(xdg, tool);
|
|
40
|
+
const p = platform(plt);
|
|
41
|
+
const home = os.homedir();
|
|
42
|
+
switch (p) {
|
|
43
|
+
case "darwin":
|
|
44
|
+
return path.join(home, "Library", "Application Support", tool);
|
|
45
|
+
case "win32": {
|
|
46
|
+
const local = process.env["LocalAppData"];
|
|
47
|
+
if (!local) throw new Error("%LocalAppData% is not set");
|
|
48
|
+
return path.win32.join(local, tool);
|
|
49
|
+
}
|
|
50
|
+
default:
|
|
51
|
+
return path.join(home, ".local", "share", tool);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
function cacheDir(tool, plt) {
|
|
55
|
+
const xdg = process.env["XDG_CACHE_HOME"];
|
|
56
|
+
if (xdg) return path.join(xdg, tool);
|
|
57
|
+
const p = platform(plt);
|
|
58
|
+
const home = os.homedir();
|
|
59
|
+
switch (p) {
|
|
60
|
+
case "darwin":
|
|
61
|
+
return path.join(home, "Library", "Caches", tool);
|
|
62
|
+
case "win32": {
|
|
63
|
+
const local = process.env["LocalAppData"];
|
|
64
|
+
if (!local) throw new Error("%LocalAppData% is not set");
|
|
65
|
+
return path.win32.join(local, tool, "cache");
|
|
66
|
+
}
|
|
67
|
+
default:
|
|
68
|
+
return path.join(home, ".cache", tool);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
function stateDir(tool, plt) {
|
|
72
|
+
const xdg = process.env["XDG_STATE_HOME"];
|
|
73
|
+
if (xdg) return path.join(xdg, tool);
|
|
74
|
+
const p = platform(plt);
|
|
75
|
+
const home = os.homedir();
|
|
76
|
+
switch (p) {
|
|
77
|
+
case "darwin":
|
|
78
|
+
return path.join(home, "Library", "Application Support", tool, "state");
|
|
79
|
+
case "win32": {
|
|
80
|
+
const local = process.env["LocalAppData"];
|
|
81
|
+
if (!local) throw new Error("%LocalAppData% is not set");
|
|
82
|
+
return path.win32.join(local, tool, "state");
|
|
83
|
+
}
|
|
84
|
+
default:
|
|
85
|
+
return path.join(home, ".local", "state", tool);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
function mustEnsure(dir) {
|
|
89
|
+
fs.mkdirSync(dir, { recursive: true, mode: 488 });
|
|
90
|
+
const stat = fs.statSync(dir);
|
|
91
|
+
if (!stat.isDirectory()) {
|
|
92
|
+
throw new Error(`mustEnsure: path exists but is not a directory: ${dir}`);
|
|
93
|
+
}
|
|
94
|
+
return dir;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
exports.configDir = configDir; exports.dataDir = dataDir; exports.cacheDir = cacheDir; exports.stateDir = stateDir; exports.mustEnsure = mustEnsure; exports.xdg_exports = xdg_exports;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
|
+
|
|
3
|
+
var _chunkR5U7XKVJjs = require('./chunk-R5U7XKVJ.js');
|
|
4
|
+
|
|
5
|
+
// src/safety.ts
|
|
6
|
+
var safety_exports = {};
|
|
7
|
+
_chunkR5U7XKVJjs.__export.call(void 0, safety_exports, {
|
|
8
|
+
safetyGuard: () => safetyGuard
|
|
9
|
+
});
|
|
10
|
+
function safetyGuard(level, opts) {
|
|
11
|
+
if (level === "read") return;
|
|
12
|
+
const force = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _ => _.force]), () => ( false));
|
|
13
|
+
const isTTY = !!process.stdout.isTTY;
|
|
14
|
+
if (level === "dangerous" && !force) {
|
|
15
|
+
throw new Error(
|
|
16
|
+
"dangerous operation requires --force"
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
if (level === "caution" && !isTTY && !force) {
|
|
20
|
+
throw new Error(
|
|
21
|
+
"caution-level operation in non-TTY requires --force"
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
exports.safetyGuard = safetyGuard; exports.safety_exports = safety_exports;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
var _chunkR5U7XKVJjs = require('./chunk-R5U7XKVJ.js');
|
|
4
|
+
|
|
5
|
+
// src/provenance.ts
|
|
6
|
+
var provenance_exports = {};
|
|
7
|
+
_chunkR5U7XKVJjs.__export.call(void 0, provenance_exports, {
|
|
8
|
+
withProvenance: () => withProvenance
|
|
9
|
+
});
|
|
10
|
+
function withProvenance(data, p) {
|
|
11
|
+
return { data, _meta: p };
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
exports.withProvenance = withProvenance; exports.provenance_exports = provenance_exports;
|