@hop-top/kit 0.5.0-alpha.3 → 0.5.0-alpha.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +40 -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-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-UIOOOK6M.js +334 -0
- package/dist/chunk-UKZIAQA7.js +26 -0
- package/dist/chunk-WBVO43HU.js +355 -0
- package/dist/chunk-WTYDHXPW.js +574 -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/{cli-DLygZLi9.d.ts → cli-8rfITnv4.d.ts} +13 -4
- package/dist/cli.d.ts +4 -4
- package/dist/cli.js +50 -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.test.ts +56 -1
- package/src/cli.ts +24 -4
- 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/progress.js
CHANGED
|
@@ -1,56 +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(progress_exports);
|
|
26
|
-
var ProgressReporter = class {
|
|
27
|
-
constructor(w, isTTY) {
|
|
28
|
-
this.w = w;
|
|
29
|
-
this.tty = isTTY;
|
|
30
|
-
}
|
|
31
|
-
emit(event) {
|
|
32
|
-
if (this.tty) {
|
|
33
|
-
const msg = event.message ? ` ${event.message}` : "";
|
|
34
|
-
this.w.write(
|
|
35
|
-
`[${event.phase}] ${event.step} ${event.current}/${event.total} (${event.percent}%)${msg}
|
|
36
|
-
`
|
|
37
|
-
);
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
this.w.write(JSON.stringify(event) + "\n");
|
|
41
|
-
}
|
|
42
|
-
done(message) {
|
|
43
|
-
if (this.tty) {
|
|
44
|
-
this.w.write(`done: ${message}
|
|
45
|
-
`);
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
this.w.write(
|
|
49
|
-
JSON.stringify({ done: true, message }) + "\n"
|
|
50
|
-
);
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
54
|
-
0 && (module.exports = {
|
|
55
|
-
ProgressReporter
|
|
56
|
-
});
|
|
3
|
+
var _chunkBDNNPRX6js = require('./chunk-BDNNPRX6.js');
|
|
4
|
+
require('./chunk-R5U7XKVJ.js');
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
exports.ProgressReporter = _chunkBDNNPRX6js.ProgressReporter;
|
package/dist/provenance.js
CHANGED
|
@@ -1,32 +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(provenance_exports);
|
|
26
|
-
function withProvenance(data, p) {
|
|
27
|
-
return { data, _meta: p };
|
|
28
|
-
}
|
|
29
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
30
|
-
0 && (module.exports = {
|
|
31
|
-
withProvenance
|
|
32
|
-
});
|
|
3
|
+
var _chunk6SVOHNICjs = require('./chunk-6SVOHNIC.js');
|
|
4
|
+
require('./chunk-R5U7XKVJ.js');
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
exports.withProvenance = _chunk6SVOHNICjs.withProvenance;
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { C as Completer, S as Streamer, T as ToolCaller, a as ToolStreamer, R as ResolvedConfig, b as Request, c as Response, f as ToolStream, d as ToolDef, e as ToolResponse } from './llm-DYuR7_uX.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @packageDocumentation
|
|
5
|
+
*
|
|
6
|
+
* RouteLLM adapter — registers the `routellm` URI scheme.
|
|
7
|
+
*
|
|
8
|
+
* The model field takes either shape a RouteLLM server advertises on
|
|
9
|
+
* `/v1/models`, as in Go:
|
|
10
|
+
*
|
|
11
|
+
* - `router_name:threshold` — `routellm://mf:0.7`, sent as the server's
|
|
12
|
+
* `router-[name]-[threshold]` model. The client picks both.
|
|
13
|
+
* - tier name — `routellm://private`, sent verbatim. The server resolves
|
|
14
|
+
* router and threshold from its own tier config.
|
|
15
|
+
*
|
|
16
|
+
* Delegates to the openai adapter (`@hop-top/kit/openai`) pointed
|
|
17
|
+
* at the RouteLLM server's OpenAI-compatible endpoint.
|
|
18
|
+
* Importing this module registers the openai schemes too.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
interface EvaConfig {
|
|
22
|
+
contracts: string[];
|
|
23
|
+
enforce: boolean;
|
|
24
|
+
}
|
|
25
|
+
interface RouterConfig {
|
|
26
|
+
baseUrl: string;
|
|
27
|
+
grpcPort: number;
|
|
28
|
+
strongModel: string;
|
|
29
|
+
weakModel: string;
|
|
30
|
+
routers: string[];
|
|
31
|
+
routerConfig: Record<string, unknown>;
|
|
32
|
+
eva: EvaConfig;
|
|
33
|
+
autostart: boolean;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Extract and validate RouteLLM configuration from provider extras.
|
|
37
|
+
* Environment variables (`ROUTELLM_BASE_URL`, `ROUTELLM_STRONG_MODEL`,
|
|
38
|
+
* `ROUTELLM_WEAK_MODEL`, `ROUTELLM_ROUTERS`) override all other
|
|
39
|
+
* sources; with `opts.hermetic` none is read.
|
|
40
|
+
*/
|
|
41
|
+
declare function parseRouterConfig(extras?: Record<string, unknown>, opts?: {
|
|
42
|
+
hermetic?: boolean;
|
|
43
|
+
}): RouterConfig;
|
|
44
|
+
/**
|
|
45
|
+
* The model field classified. `isTier` selects `tier`; otherwise
|
|
46
|
+
* `routerName` and `threshold` hold the client-selected pair. The
|
|
47
|
+
* unused shape stays at `""` / `0`.
|
|
48
|
+
*/
|
|
49
|
+
interface ParsedModel {
|
|
50
|
+
isTier: boolean;
|
|
51
|
+
tier: string;
|
|
52
|
+
routerName: string;
|
|
53
|
+
threshold: number;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Classify the model field as a `router_name:threshold` pair or a tier
|
|
57
|
+
* name, exactly as Go does.
|
|
58
|
+
*
|
|
59
|
+
* The shapes are told apart by the text after the last colon: when it
|
|
60
|
+
* parses as a finite float (Go `ParseFloat` syntax) the model is a
|
|
61
|
+
* router pair, else a tier sent verbatim — so a tier name may contain
|
|
62
|
+
* colons and `mf:abc` is a tier. A leading or trailing colon leaves a
|
|
63
|
+
* tier. The threshold range is checked by the adapter, not here; an
|
|
64
|
+
* unknown tier fails at the server.
|
|
65
|
+
*/
|
|
66
|
+
declare function parseModelField(model: string): ParsedModel;
|
|
67
|
+
/**
|
|
68
|
+
* RouteLLM adapter: complete, stream, callWithTools and streamWithTools.
|
|
69
|
+
*
|
|
70
|
+
* Delegates to an inner {@link OpenAIAdapter} pointed at the RouteLLM
|
|
71
|
+
* server's OpenAI-compatible `/v1` API, so tool calling, tool names
|
|
72
|
+
* (openai rule, `?tool_names=`), size limits, retries and the
|
|
73
|
+
* credential guard are the openai adapter's.
|
|
74
|
+
*/
|
|
75
|
+
declare class RouteLLMAdapter implements Completer, Streamer, ToolCaller, ToolStreamer {
|
|
76
|
+
readonly config: RouterConfig;
|
|
77
|
+
/** Client-selected router; `""` for a tier. */
|
|
78
|
+
readonly routerName: string;
|
|
79
|
+
/** Client-selected threshold; `0` for a tier (see {@link isTier}). */
|
|
80
|
+
readonly threshold: number;
|
|
81
|
+
/** Server-resolved tier name; `""` for a router pair. */
|
|
82
|
+
readonly tier: string;
|
|
83
|
+
/** The API root requests go to: the resolved base URL plus `/v1`. */
|
|
84
|
+
readonly baseURL: string;
|
|
85
|
+
private readonly inner;
|
|
86
|
+
constructor(cfg: ResolvedConfig);
|
|
87
|
+
/**
|
|
88
|
+
* Whether the adapter targets a server-resolved tier rather than a
|
|
89
|
+
* client-selected pair; use it instead of `threshold === 0`, which is
|
|
90
|
+
* also a valid client threshold.
|
|
91
|
+
*/
|
|
92
|
+
isTier(): boolean;
|
|
93
|
+
complete(req: Request): Promise<Response>;
|
|
94
|
+
stream(req: Request): ToolStream;
|
|
95
|
+
callWithTools(req: Request, tools: ToolDef[]): Promise<ToolResponse>;
|
|
96
|
+
streamWithTools(req: Request, tools: ToolDef[]): ToolStream;
|
|
97
|
+
close(): void;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
type routellm_EvaConfig = EvaConfig;
|
|
101
|
+
type routellm_ParsedModel = ParsedModel;
|
|
102
|
+
type routellm_RouteLLMAdapter = RouteLLMAdapter;
|
|
103
|
+
declare const routellm_RouteLLMAdapter: typeof RouteLLMAdapter;
|
|
104
|
+
type routellm_RouterConfig = RouterConfig;
|
|
105
|
+
declare const routellm_parseModelField: typeof parseModelField;
|
|
106
|
+
declare const routellm_parseRouterConfig: typeof parseRouterConfig;
|
|
107
|
+
declare namespace routellm {
|
|
108
|
+
export { type routellm_EvaConfig as EvaConfig, type routellm_ParsedModel as ParsedModel, routellm_RouteLLMAdapter as RouteLLMAdapter, type routellm_RouterConfig as RouterConfig, routellm_parseModelField as parseModelField, routellm_parseRouterConfig as parseRouterConfig };
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export { type EvaConfig as E, type ParsedModel as P, RouteLLMAdapter as R, type RouterConfig as a, parseRouterConfig as b, parseModelField as p, routellm as r };
|
package/dist/routellm.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import './llm-
|
|
2
|
-
export { E as EvaConfig, P as ParsedModel, R as RouteLLMAdapter, a as RouterConfig, p as parseModelField, b as parseRouterConfig } from './routellm-
|
|
1
|
+
import './llm-DYuR7_uX.js';
|
|
2
|
+
export { E as EvaConfig, P as ParsedModel, R as RouteLLMAdapter, a as RouterConfig, p as parseModelField, b as parseRouterConfig } from './routellm-B0nv59mH.js';
|
package/dist/routellm.js
CHANGED
|
@@ -1,258 +1,16 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
19
2
|
|
|
20
|
-
// src/routellm.ts
|
|
21
|
-
var routellm_exports = {};
|
|
22
|
-
__export(routellm_exports, {
|
|
23
|
-
RouteLLMAdapter: () => RouteLLMAdapter,
|
|
24
|
-
parseModelField: () => parseModelField,
|
|
25
|
-
parseRouterConfig: () => parseRouterConfig
|
|
26
|
-
});
|
|
27
|
-
module.exports = __toCommonJS(routellm_exports);
|
|
28
3
|
|
|
29
|
-
// src/llm.ts
|
|
30
|
-
var LLMError = class extends Error {
|
|
31
|
-
constructor(message) {
|
|
32
|
-
super(message);
|
|
33
|
-
this.name = "LLMError";
|
|
34
|
-
Object.setPrototypeOf(this, new.target.prototype);
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
var registry = /* @__PURE__ */ new Map();
|
|
38
|
-
function register(scheme, factory) {
|
|
39
|
-
if (registry.has(scheme)) {
|
|
40
|
-
throw new LLMError(`provider already registered for scheme: ${scheme}`);
|
|
41
|
-
}
|
|
42
|
-
registry.set(scheme, factory);
|
|
43
|
-
}
|
|
44
4
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
function parseRouterConfig(extras) {
|
|
59
|
-
const cfg = defaultRouterConfig();
|
|
60
|
-
if (extras) {
|
|
61
|
-
const raw = extras["routellm"];
|
|
62
|
-
if (raw !== void 0) {
|
|
63
|
-
if (typeof raw !== "object" || raw === null || Array.isArray(raw)) {
|
|
64
|
-
throw new LLMError(
|
|
65
|
-
`routellm: expected map, got ${typeof raw}`
|
|
66
|
-
);
|
|
67
|
-
}
|
|
68
|
-
const sub = raw;
|
|
69
|
-
if (typeof sub["base_url"] === "string") cfg.baseUrl = sub["base_url"];
|
|
70
|
-
if (typeof sub["grpc_port"] === "number") cfg.grpcPort = sub["grpc_port"];
|
|
71
|
-
if (typeof sub["strong_model"] === "string") {
|
|
72
|
-
cfg.strongModel = sub["strong_model"];
|
|
73
|
-
}
|
|
74
|
-
if (typeof sub["weak_model"] === "string") {
|
|
75
|
-
cfg.weakModel = sub["weak_model"];
|
|
76
|
-
}
|
|
77
|
-
if (Array.isArray(sub["routers"])) {
|
|
78
|
-
cfg.routers = sub["routers"].filter(
|
|
79
|
-
(r) => typeof r === "string"
|
|
80
|
-
);
|
|
81
|
-
}
|
|
82
|
-
if (typeof sub["router_config"] === "object" && sub["router_config"] !== null && !Array.isArray(sub["router_config"])) {
|
|
83
|
-
cfg.routerConfig = sub["router_config"];
|
|
84
|
-
}
|
|
85
|
-
if (typeof sub["eva"] === "object" && sub["eva"] !== null) {
|
|
86
|
-
const e = sub["eva"];
|
|
87
|
-
if (Array.isArray(e["contracts"])) {
|
|
88
|
-
cfg.eva.contracts = e["contracts"].filter(
|
|
89
|
-
(c) => typeof c === "string"
|
|
90
|
-
);
|
|
91
|
-
}
|
|
92
|
-
if (typeof e["enforce"] === "boolean") cfg.eva.enforce = e["enforce"];
|
|
93
|
-
}
|
|
94
|
-
if (typeof sub["autostart"] === "boolean") {
|
|
95
|
-
cfg.autostart = sub["autostart"];
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
const envBaseUrl = process.env["ROUTELLM_BASE_URL"];
|
|
100
|
-
if (envBaseUrl) cfg.baseUrl = envBaseUrl;
|
|
101
|
-
const envStrong = process.env["ROUTELLM_STRONG_MODEL"];
|
|
102
|
-
if (envStrong) cfg.strongModel = envStrong;
|
|
103
|
-
const envWeak = process.env["ROUTELLM_WEAK_MODEL"];
|
|
104
|
-
if (envWeak) cfg.weakModel = envWeak;
|
|
105
|
-
const envRouters = process.env["ROUTELLM_ROUTERS"];
|
|
106
|
-
if (envRouters) {
|
|
107
|
-
cfg.routers = envRouters.split(",").map((r) => r.trim()).filter(Boolean);
|
|
108
|
-
}
|
|
109
|
-
return cfg;
|
|
110
|
-
}
|
|
111
|
-
function parseModelField(model) {
|
|
112
|
-
if (!model) {
|
|
113
|
-
throw new LLMError(
|
|
114
|
-
"model field is required (format: router_name:threshold)"
|
|
115
|
-
);
|
|
116
|
-
}
|
|
117
|
-
const idx = model.indexOf(":");
|
|
118
|
-
if (idx < 0) {
|
|
119
|
-
throw new LLMError(
|
|
120
|
-
`invalid model "${model}": expected format router_name:threshold (e.g. mf:0.7)`
|
|
121
|
-
);
|
|
122
|
-
}
|
|
123
|
-
const routerName = model.slice(0, idx);
|
|
124
|
-
const rawThreshold = model.slice(idx + 1);
|
|
125
|
-
if (!routerName || !rawThreshold) {
|
|
126
|
-
throw new LLMError(
|
|
127
|
-
`invalid model "${model}": expected format router_name:threshold (e.g. mf:0.7)`
|
|
128
|
-
);
|
|
129
|
-
}
|
|
130
|
-
const threshold = Number(rawThreshold);
|
|
131
|
-
if (Number.isNaN(threshold)) {
|
|
132
|
-
throw new LLMError(`invalid threshold "${rawThreshold}": not a number`);
|
|
133
|
-
}
|
|
134
|
-
return { routerName, threshold };
|
|
135
|
-
}
|
|
136
|
-
var RouteLLMAdapter = class {
|
|
137
|
-
constructor(cfg) {
|
|
138
|
-
this.config = parseRouterConfig(cfg.provider.extras);
|
|
139
|
-
const model = cfg.provider.model || cfg.uri.model;
|
|
140
|
-
const parsed = parseModelField(model);
|
|
141
|
-
this.routerName = parsed.routerName;
|
|
142
|
-
this.threshold = parsed.threshold;
|
|
143
|
-
if (this.threshold < 0 || this.threshold > 1) {
|
|
144
|
-
throw new LLMError(
|
|
145
|
-
`routellm: threshold ${this.threshold} out of range [0, 1]`
|
|
146
|
-
);
|
|
147
|
-
}
|
|
148
|
-
this._serverModel = `router-${this.routerName}-${this.threshold}`;
|
|
149
|
-
let baseUrl = this.config.baseUrl;
|
|
150
|
-
if (baseUrl === "http://localhost:6060" && cfg.provider.baseURL) {
|
|
151
|
-
baseUrl = cfg.provider.baseURL;
|
|
152
|
-
}
|
|
153
|
-
this._baseUrl = baseUrl;
|
|
154
|
-
this._apiKey = cfg.provider.apiKey ?? "";
|
|
155
|
-
}
|
|
156
|
-
async complete(req) {
|
|
157
|
-
const body = this._buildBody(req, false);
|
|
158
|
-
const resp = await this._post("/v1/chat/completions", body);
|
|
159
|
-
const data = await resp.json();
|
|
160
|
-
const choice = data.choices?.[0];
|
|
161
|
-
const content = choice?.message?.content ?? "";
|
|
162
|
-
const finishReason = choice?.finish_reason ?? "";
|
|
163
|
-
const usage = data.usage ? {
|
|
164
|
-
promptTokens: data.usage.prompt_tokens ?? 0,
|
|
165
|
-
completionTokens: data.usage.completion_tokens ?? 0,
|
|
166
|
-
totalTokens: data.usage.total_tokens ?? 0
|
|
167
|
-
} : void 0;
|
|
168
|
-
return { content, role: "assistant", usage, finishReason };
|
|
169
|
-
}
|
|
170
|
-
async *stream(req) {
|
|
171
|
-
const body = this._buildBody(req, true);
|
|
172
|
-
const resp = await this._post("/v1/chat/completions", body);
|
|
173
|
-
if (!resp.body) {
|
|
174
|
-
throw new LLMError("routellm: streaming response has no body");
|
|
175
|
-
}
|
|
176
|
-
const reader = resp.body.getReader();
|
|
177
|
-
const decoder = new TextDecoder();
|
|
178
|
-
let buf = "";
|
|
179
|
-
try {
|
|
180
|
-
for (; ; ) {
|
|
181
|
-
const { done, value } = await reader.read();
|
|
182
|
-
if (done) break;
|
|
183
|
-
buf += decoder.decode(value, { stream: true });
|
|
184
|
-
const lines = buf.split("\n");
|
|
185
|
-
buf = lines.pop() ?? "";
|
|
186
|
-
for (const line of lines) {
|
|
187
|
-
const trimmed = line.trim();
|
|
188
|
-
if (!trimmed || !trimmed.startsWith("data: ")) continue;
|
|
189
|
-
const payload = trimmed.slice(6);
|
|
190
|
-
if (payload === "[DONE]") {
|
|
191
|
-
yield { content: "", done: true };
|
|
192
|
-
return;
|
|
193
|
-
}
|
|
194
|
-
const chunk = JSON.parse(payload);
|
|
195
|
-
const delta = chunk.choices?.[0]?.delta;
|
|
196
|
-
const content = delta?.content ?? "";
|
|
197
|
-
const isDone = chunk.choices?.[0]?.finish_reason != null;
|
|
198
|
-
yield { content, done: isDone };
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
} finally {
|
|
202
|
-
reader.releaseLock();
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
close() {
|
|
206
|
-
}
|
|
207
|
-
// ── private ────────────────────────────────────────────────────
|
|
208
|
-
_buildBody(req, stream) {
|
|
209
|
-
const body = {
|
|
210
|
-
model: this._serverModel,
|
|
211
|
-
messages: req.messages.map((m) => ({
|
|
212
|
-
role: m.role,
|
|
213
|
-
content: m.content
|
|
214
|
-
})),
|
|
215
|
-
stream
|
|
216
|
-
};
|
|
217
|
-
if (req.temperature !== void 0) body["temperature"] = req.temperature;
|
|
218
|
-
if (req.maxTokens !== void 0) body["max_tokens"] = req.maxTokens;
|
|
219
|
-
if (req.stopSequences?.length) body["stop"] = req.stopSequences;
|
|
220
|
-
return body;
|
|
221
|
-
}
|
|
222
|
-
async _post(path, body) {
|
|
223
|
-
const url = `${this._baseUrl}${path}`;
|
|
224
|
-
const headers = {
|
|
225
|
-
"Content-Type": "application/json"
|
|
226
|
-
};
|
|
227
|
-
if (this._apiKey) {
|
|
228
|
-
headers["Authorization"] = `Bearer ${this._apiKey}`;
|
|
229
|
-
}
|
|
230
|
-
const resp = await fetch(url, {
|
|
231
|
-
method: "POST",
|
|
232
|
-
headers,
|
|
233
|
-
body: JSON.stringify(body)
|
|
234
|
-
});
|
|
235
|
-
if (!resp.ok) {
|
|
236
|
-
const text = await resp.text().catch(() => "");
|
|
237
|
-
throw new LLMError(
|
|
238
|
-
`routellm: HTTP ${resp.status} from ${url}: ${text}`
|
|
239
|
-
);
|
|
240
|
-
}
|
|
241
|
-
return resp;
|
|
242
|
-
}
|
|
243
|
-
};
|
|
244
|
-
function routellmFactory(cfg) {
|
|
245
|
-
const adapter = new RouteLLMAdapter(cfg);
|
|
246
|
-
return {
|
|
247
|
-
complete: (req) => adapter.complete(req),
|
|
248
|
-
stream: (req) => adapter.stream(req),
|
|
249
|
-
close: () => adapter.close()
|
|
250
|
-
};
|
|
251
|
-
}
|
|
252
|
-
register("routellm", routellmFactory);
|
|
253
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
254
|
-
0 && (module.exports = {
|
|
255
|
-
RouteLLMAdapter,
|
|
256
|
-
parseModelField,
|
|
257
|
-
parseRouterConfig
|
|
258
|
-
});
|
|
5
|
+
var _chunkMUIQVU6Ejs = require('./chunk-MUIQVU6E.js');
|
|
6
|
+
require('./chunk-ABQSE7AI.js');
|
|
7
|
+
require('./chunk-YGYQUFGY.js');
|
|
8
|
+
require('./chunk-PSFYJGDG.js');
|
|
9
|
+
require('./chunk-4UE5TCMQ.js');
|
|
10
|
+
require('./chunk-KVG7YCTS.js');
|
|
11
|
+
require('./chunk-R5U7XKVJ.js');
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
exports.RouteLLMAdapter = _chunkMUIQVU6Ejs.RouteLLMAdapter; exports.parseModelField = _chunkMUIQVU6Ejs.parseModelField; exports.parseRouterConfig = _chunkMUIQVU6Ejs.parseRouterConfig;
|
package/dist/rpc.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import './api-
|
|
2
|
-
export { R as RPCClient, a as RPCClientOptions } from './rpc-
|
|
1
|
+
import './api-DAexsu2H.js';
|
|
2
|
+
export { R as RPCClient, a as RPCClientOptions } from './rpc-D31Lg0Kc.js';
|
package/dist/rpc.js
CHANGED
|
@@ -1,101 +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
|
-
__export(rpc_exports, {
|
|
23
|
-
RPCClient: () => RPCClient
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(rpc_exports);
|
|
26
|
-
var import_connect = require("@connectrpc/connect");
|
|
27
|
-
var import_connect_web = require("@connectrpc/connect-web");
|
|
28
|
-
var import_protobuf = require("@bufbuild/protobuf");
|
|
3
|
+
var _chunkWUOAQVOAjs = require('./chunk-WUOAQVOA.js');
|
|
4
|
+
require('./chunk-R5U7XKVJ.js');
|
|
29
5
|
|
|
30
|
-
// src/gen/crud_pb.ts
|
|
31
|
-
var import_codegenv2 = require("@bufbuild/protobuf/codegenv2");
|
|
32
|
-
var import_wkt = require("@bufbuild/protobuf/wkt");
|
|
33
|
-
var file_crud = /* @__PURE__ */ (0, import_codegenv2.fileDesc)("CgpjcnVkLnByb3RvEgdjcnVkLnYxIjgKDUNyZWF0ZVJlcXVlc3QSJwoGZW50aXR5GAEgASgLMhcuZ29vZ2xlLnByb3RvYnVmLlN0cnVjdCI5Cg5DcmVhdGVSZXNwb25zZRInCgZlbnRpdHkYASABKAsyFy5nb29nbGUucHJvdG9idWYuU3RydWN0IhgKCkdldFJlcXVlc3QSCgoCaWQYASABKAkiNgoLR2V0UmVzcG9uc2USJwoGZW50aXR5GAEgASgLMhcuZ29vZ2xlLnByb3RvYnVmLlN0cnVjdCJKCgtMaXN0UmVxdWVzdBINCgVsaW1pdBgBIAEoBRIOCgZvZmZzZXQYAiABKAUSDAoEc29ydBgDIAEoCRIOCgZzZWFyY2gYBCABKAkiOQoMTGlzdFJlc3BvbnNlEikKCGVudGl0aWVzGAEgAygLMhcuZ29vZ2xlLnByb3RvYnVmLlN0cnVjdCI4Cg1VcGRhdGVSZXF1ZXN0EicKBmVudGl0eRgBIAEoCzIXLmdvb2dsZS5wcm90b2J1Zi5TdHJ1Y3QiOQoOVXBkYXRlUmVzcG9uc2USJwoGZW50aXR5GAEgASgLMhcuZ29vZ2xlLnByb3RvYnVmLlN0cnVjdCIbCg1EZWxldGVSZXF1ZXN0EgoKAmlkGAEgASgJIhAKDkRlbGV0ZVJlc3BvbnNlMqcCCg1FbnRpdHlTZXJ2aWNlEjkKBkNyZWF0ZRIWLmNydWQudjEuQ3JlYXRlUmVxdWVzdBoXLmNydWQudjEuQ3JlYXRlUmVzcG9uc2USMAoDR2V0EhMuY3J1ZC52MS5HZXRSZXF1ZXN0GhQuY3J1ZC52MS5HZXRSZXNwb25zZRIzCgRMaXN0EhQuY3J1ZC52MS5MaXN0UmVxdWVzdBoVLmNydWQudjEuTGlzdFJlc3BvbnNlEjkKBlVwZGF0ZRIWLmNydWQudjEuVXBkYXRlUmVxdWVzdBoXLmNydWQudjEuVXBkYXRlUmVzcG9uc2USOQoGRGVsZXRlEhYuY3J1ZC52MS5EZWxldGVSZXF1ZXN0GhcuY3J1ZC52MS5EZWxldGVSZXNwb25zZUJ3Cgtjb20uY3J1ZC52MUIJQ3J1ZFByb3RvUAFaIGhvcC50b3Ava2l0L3Byb3RvL2NydWQvdjE7Y3J1ZHYxogIDQ1hYqgIHQ3J1ZC5WMcoCB0NydWRcVjHiAhNDcnVkXFYxXEdQQk1ldGFkYXRh6gIIQ3J1ZDo6VjFiBnByb3RvMw", [import_wkt.file_google_protobuf_struct]);
|
|
34
|
-
var CreateRequestSchema = /* @__PURE__ */ (0, import_codegenv2.messageDesc)(file_crud, 0);
|
|
35
|
-
var GetRequestSchema = /* @__PURE__ */ (0, import_codegenv2.messageDesc)(file_crud, 2);
|
|
36
|
-
var ListRequestSchema = /* @__PURE__ */ (0, import_codegenv2.messageDesc)(file_crud, 4);
|
|
37
|
-
var UpdateRequestSchema = /* @__PURE__ */ (0, import_codegenv2.messageDesc)(file_crud, 6);
|
|
38
|
-
var DeleteRequestSchema = /* @__PURE__ */ (0, import_codegenv2.messageDesc)(file_crud, 8);
|
|
39
|
-
var EntityService = /* @__PURE__ */ (0, import_codegenv2.serviceDesc)(file_crud, 0);
|
|
40
6
|
|
|
41
|
-
|
|
42
|
-
var RPCClient = class {
|
|
43
|
-
constructor(opts) {
|
|
44
|
-
this.auth = opts.auth;
|
|
45
|
-
const transport = (0, import_connect_web.createConnectTransport)({
|
|
46
|
-
baseUrl: opts.baseURL,
|
|
47
|
-
interceptors: this.auth ? [
|
|
48
|
-
(next) => async (req) => {
|
|
49
|
-
req.header.set(
|
|
50
|
-
"Authorization",
|
|
51
|
-
`Bearer ${this.auth}`
|
|
52
|
-
);
|
|
53
|
-
return next(req);
|
|
54
|
-
}
|
|
55
|
-
] : []
|
|
56
|
-
});
|
|
57
|
-
this.client = (0, import_connect.createClient)(EntityService, transport);
|
|
58
|
-
}
|
|
59
|
-
async create(entity) {
|
|
60
|
-
const res = await this.client.create(
|
|
61
|
-
(0, import_protobuf.create)(CreateRequestSchema, {
|
|
62
|
-
entity
|
|
63
|
-
})
|
|
64
|
-
);
|
|
65
|
-
return res.entity ?? {};
|
|
66
|
-
}
|
|
67
|
-
async get(id) {
|
|
68
|
-
const res = await this.client.get(
|
|
69
|
-
(0, import_protobuf.create)(GetRequestSchema, { id })
|
|
70
|
-
);
|
|
71
|
-
return res.entity ?? {};
|
|
72
|
-
}
|
|
73
|
-
async list(q) {
|
|
74
|
-
const res = await this.client.list(
|
|
75
|
-
(0, import_protobuf.create)(ListRequestSchema, {
|
|
76
|
-
limit: q?.limit ?? 0,
|
|
77
|
-
offset: q?.offset ?? 0,
|
|
78
|
-
sort: q?.sort ?? "",
|
|
79
|
-
search: q?.search ?? ""
|
|
80
|
-
})
|
|
81
|
-
);
|
|
82
|
-
return res.entities ?? [];
|
|
83
|
-
}
|
|
84
|
-
async update(entity) {
|
|
85
|
-
const res = await this.client.update(
|
|
86
|
-
(0, import_protobuf.create)(UpdateRequestSchema, {
|
|
87
|
-
entity
|
|
88
|
-
})
|
|
89
|
-
);
|
|
90
|
-
return res.entity ?? {};
|
|
91
|
-
}
|
|
92
|
-
async delete(id) {
|
|
93
|
-
await this.client.delete(
|
|
94
|
-
(0, import_protobuf.create)(DeleteRequestSchema, { id })
|
|
95
|
-
);
|
|
96
|
-
}
|
|
97
|
-
};
|
|
98
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
99
|
-
0 && (module.exports = {
|
|
100
|
-
RPCClient
|
|
101
|
-
});
|
|
7
|
+
exports.RPCClient = _chunkWUOAQVOAjs.RPCClient;
|
package/dist/safety.js
CHANGED
|
@@ -1,44 +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(safety_exports);
|
|
26
|
-
function safetyGuard(level, opts) {
|
|
27
|
-
if (level === "read") return;
|
|
28
|
-
const force = opts?.force ?? false;
|
|
29
|
-
const isTTY = !!process.stdout.isTTY;
|
|
30
|
-
if (level === "dangerous" && !force) {
|
|
31
|
-
throw new Error(
|
|
32
|
-
"dangerous operation requires --force"
|
|
33
|
-
);
|
|
34
|
-
}
|
|
35
|
-
if (level === "caution" && !isTTY && !force) {
|
|
36
|
-
throw new Error(
|
|
37
|
-
"caution-level operation in non-TTY requires --force"
|
|
38
|
-
);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
42
|
-
0 && (module.exports = {
|
|
43
|
-
safetyGuard
|
|
44
|
-
});
|
|
3
|
+
var _chunk6HFAEZ52js = require('./chunk-6HFAEZ52.js');
|
|
4
|
+
require('./chunk-R5U7XKVJ.js');
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
exports.safetyGuard = _chunk6HFAEZ52js.safetyGuard;
|