@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/progress.d.ts
CHANGED
|
@@ -1,30 +1 @@
|
|
|
1
|
-
|
|
2
|
-
* @module progress
|
|
3
|
-
* @package @hop-top/kit
|
|
4
|
-
*
|
|
5
|
-
* Factor 9 — Observable Long-Running Operations.
|
|
6
|
-
*
|
|
7
|
-
* Emits structured progress events (JSON in non-TTY,
|
|
8
|
-
* human-readable in TTY).
|
|
9
|
-
*/
|
|
10
|
-
interface ProgressEvent {
|
|
11
|
-
phase: string;
|
|
12
|
-
step: string;
|
|
13
|
-
current: number;
|
|
14
|
-
total: number;
|
|
15
|
-
percent: number;
|
|
16
|
-
message?: string;
|
|
17
|
-
}
|
|
18
|
-
interface JobHandle {
|
|
19
|
-
id: string;
|
|
20
|
-
status: 'running' | 'completed' | 'failed' | 'cancelled';
|
|
21
|
-
}
|
|
22
|
-
declare class ProgressReporter {
|
|
23
|
-
private w;
|
|
24
|
-
private tty;
|
|
25
|
-
constructor(w: NodeJS.WritableStream, isTTY: boolean);
|
|
26
|
-
emit(event: ProgressEvent): void;
|
|
27
|
-
done(message: string): void;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export { type JobHandle, type ProgressEvent, ProgressReporter };
|
|
1
|
+
export { J as JobHandle, P as ProgressEvent, a as ProgressReporter } from './progress-CAzyxeWl.js';
|
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;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module provenance
|
|
3
|
+
* @package @hop-top/kit
|
|
4
|
+
*
|
|
5
|
+
* Factor 11 — Provenance.
|
|
6
|
+
*
|
|
7
|
+
* Attaches origin metadata to any data payload for JSON output,
|
|
8
|
+
* enabling consumers to verify source, timing, and method.
|
|
9
|
+
*/
|
|
10
|
+
interface Provenance {
|
|
11
|
+
source: string;
|
|
12
|
+
/** ISO 8601 timestamp */
|
|
13
|
+
timestamp: string;
|
|
14
|
+
method: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Wraps `data` with provenance metadata under `_meta`.
|
|
18
|
+
*/
|
|
19
|
+
declare function withProvenance<T>(data: T, p: Provenance): {
|
|
20
|
+
data: T;
|
|
21
|
+
_meta: Provenance;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
type provenance_Provenance = Provenance;
|
|
25
|
+
declare const provenance_withProvenance: typeof withProvenance;
|
|
26
|
+
declare namespace provenance {
|
|
27
|
+
export { type provenance_Provenance as Provenance, provenance_withProvenance as withProvenance };
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export { type Provenance as P, provenance as p, withProvenance as w };
|
package/dist/provenance.d.ts
CHANGED
|
@@ -1,24 +1 @@
|
|
|
1
|
-
|
|
2
|
-
* @module provenance
|
|
3
|
-
* @package @hop-top/kit
|
|
4
|
-
*
|
|
5
|
-
* Factor 11 — Provenance.
|
|
6
|
-
*
|
|
7
|
-
* Attaches origin metadata to any data payload for JSON output,
|
|
8
|
-
* enabling consumers to verify source, timing, and method.
|
|
9
|
-
*/
|
|
10
|
-
interface Provenance {
|
|
11
|
-
source: string;
|
|
12
|
-
/** ISO 8601 timestamp */
|
|
13
|
-
timestamp: string;
|
|
14
|
-
method: string;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Wraps `data` with provenance metadata under `_meta`.
|
|
18
|
-
*/
|
|
19
|
-
declare function withProvenance<T>(data: T, p: Provenance): {
|
|
20
|
-
data: T;
|
|
21
|
-
_meta: Provenance;
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
export { type Provenance, withProvenance };
|
|
1
|
+
export { P as Provenance, w as withProvenance } from './provenance-SMFHm5gx.js';
|
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,64 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @packageDocumentation
|
|
5
|
-
*
|
|
6
|
-
* RouteLLM adapter — registers the `routellm` URI scheme.
|
|
7
|
-
*
|
|
8
|
-
* URI format: `routellm://router_name:threshold` (e.g. `routellm://mf:0.7`).
|
|
9
|
-
*
|
|
10
|
-
* Delegates HTTP completions to an OpenAI-compatible endpoint on the
|
|
11
|
-
* RouteLLM server, translating the model field into the server's
|
|
12
|
-
* expected `router-[name]-[threshold]` format.
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
interface EvaConfig {
|
|
16
|
-
contracts: string[];
|
|
17
|
-
enforce: boolean;
|
|
18
|
-
}
|
|
19
|
-
interface RouterConfig {
|
|
20
|
-
baseUrl: string;
|
|
21
|
-
grpcPort: number;
|
|
22
|
-
strongModel: string;
|
|
23
|
-
weakModel: string;
|
|
24
|
-
routers: string[];
|
|
25
|
-
routerConfig: Record<string, unknown>;
|
|
26
|
-
eva: EvaConfig;
|
|
27
|
-
autostart: boolean;
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Extract and validate RouteLLM configuration from provider extras.
|
|
31
|
-
* Environment variables override all other sources.
|
|
32
|
-
*/
|
|
33
|
-
declare function parseRouterConfig(extras?: Record<string, unknown>): RouterConfig;
|
|
34
|
-
interface ParsedModel {
|
|
35
|
-
routerName: string;
|
|
36
|
-
threshold: number;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Split a model string of the form `router_name:threshold` into its
|
|
40
|
-
* components.
|
|
41
|
-
*/
|
|
42
|
-
declare function parseModelField(model: string): ParsedModel;
|
|
43
|
-
/**
|
|
44
|
-
* RouteLLM adapter implementing Completer and Streamer.
|
|
45
|
-
*
|
|
46
|
-
* Delegates to an OpenAI-compatible HTTP endpoint on the RouteLLM
|
|
47
|
-
* server using the standard fetch API.
|
|
48
|
-
*/
|
|
49
|
-
declare class RouteLLMAdapter implements Completer, Streamer {
|
|
50
|
-
readonly config: RouterConfig;
|
|
51
|
-
readonly routerName: string;
|
|
52
|
-
readonly threshold: number;
|
|
53
|
-
private readonly _baseUrl;
|
|
54
|
-
private readonly _serverModel;
|
|
55
|
-
private readonly _apiKey;
|
|
56
|
-
constructor(cfg: ResolvedConfig);
|
|
57
|
-
complete(req: Request): Promise<Response>;
|
|
58
|
-
stream(req: Request): AsyncGenerator<Token>;
|
|
59
|
-
close(): void;
|
|
60
|
-
private _buildBody;
|
|
61
|
-
private _post;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export { type EvaConfig, type ParsedModel, RouteLLMAdapter, type RouterConfig, parseModelField, parseRouterConfig };
|
|
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 _chunkVGOA5Y7Sjs = require('./chunk-VGOA5Y7S.js');
|
|
6
|
+
require('./chunk-VWGP4NVJ.js');
|
|
7
|
+
require('./chunk-BXJ2J27B.js');
|
|
8
|
+
require('./chunk-K7E34Q3A.js');
|
|
9
|
+
require('./chunk-KVG7YCTS.js');
|
|
10
|
+
require('./chunk-4UE5TCMQ.js');
|
|
11
|
+
require('./chunk-R5U7XKVJ.js');
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
exports.RouteLLMAdapter = _chunkVGOA5Y7Sjs.RouteLLMAdapter; exports.parseModelField = _chunkVGOA5Y7Sjs.parseModelField; exports.parseRouterConfig = _chunkVGOA5Y7Sjs.parseRouterConfig;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { E as Entity, Q as Query } from './api-DAexsu2H.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Typed ConnectRPC client for kit EntityService.
|
|
5
|
+
*
|
|
6
|
+
* Thin wrapper over generated Connect stubs, mapping between
|
|
7
|
+
* JS objects and protobuf Struct (JSON intermediate).
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
interface RPCClientOptions {
|
|
11
|
+
baseURL: string;
|
|
12
|
+
auth?: string;
|
|
13
|
+
}
|
|
14
|
+
declare class RPCClient<T extends Entity> {
|
|
15
|
+
private client;
|
|
16
|
+
private auth?;
|
|
17
|
+
constructor(opts: RPCClientOptions);
|
|
18
|
+
create(entity: Omit<T, "id"> | T): Promise<T>;
|
|
19
|
+
get(id: string): Promise<T>;
|
|
20
|
+
list(q?: Query): Promise<T[]>;
|
|
21
|
+
update(entity: T): Promise<T>;
|
|
22
|
+
delete(id: string): Promise<void>;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
type rpc_RPCClient<T extends Entity> = RPCClient<T>;
|
|
26
|
+
declare const rpc_RPCClient: typeof RPCClient;
|
|
27
|
+
type rpc_RPCClientOptions = RPCClientOptions;
|
|
28
|
+
declare namespace rpc {
|
|
29
|
+
export { rpc_RPCClient as RPCClient, type rpc_RPCClientOptions as RPCClientOptions };
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export { RPCClient as R, type RPCClientOptions as a, rpc as r };
|