@dsh-enhanced/llm-route-capabilities 0.1.3
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/LICENSE +21 -0
- package/README.md +5 -0
- package/lib/index.d.ts +19 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +97 -0
- package/lib/index.js.map +1 -0
- package/lib/version.d.ts +2 -0
- package/lib/version.d.ts.map +1 -0
- package/lib/version.js +2 -0
- package/lib/version.js.map +1 -0
- package/package.json +53 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 dsh-enhanced contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
# @dsh-enhanced/llm-route-capabilities
|
|
2
|
+
|
|
3
|
+
普通、非激活型 TypeScript 库,用于把 provider/model 的工具调用能力声明附着到一个精确的 DSH `LlmRuntime` 实例。它不声明 `dsh.bundle`,也不会向 profile 注入任何 Cordis patch。
|
|
4
|
+
|
|
5
|
+
能力分为 `none`(不能接收 DSH tools)、`native`(原生 tool-call stream)和 `bridge`(由 provider 的受约束协议桥接为 DSH tool calls)。精确 model 声明覆盖 provider 声明;重复 selector 会失败,卸载 disposer 只撤回自己注册的声明。
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { LlmRuntime } from '@deepseek-ai/dsh-llm';
|
|
2
|
+
import { version } from './version.js';
|
|
3
|
+
export type ToolCallMode = 'none' | 'native' | 'bridge';
|
|
4
|
+
export interface LlmRouteCapabilityDeclaration {
|
|
5
|
+
readonly provider: string;
|
|
6
|
+
readonly model?: string;
|
|
7
|
+
readonly toolCalls: ToolCallMode;
|
|
8
|
+
}
|
|
9
|
+
export type LlmRouteCapabilityDisposer = () => void;
|
|
10
|
+
/**
|
|
11
|
+
* Attach one audited capability declaration to exactly one live LLM runtime.
|
|
12
|
+
* A selector has a single owner; even an identical duplicate is rejected so
|
|
13
|
+
* plugin unload cannot make another plugin's declaration disappear.
|
|
14
|
+
*/
|
|
15
|
+
export declare function registerLlmRouteCapability(runtime: LlmRuntime, input: LlmRouteCapabilityDeclaration): LlmRouteCapabilityDisposer;
|
|
16
|
+
/** Resolve the exact-model declaration first, then the provider-wide fallback. */
|
|
17
|
+
export declare function resolveLlmRouteCapability(runtime: LlmRuntime, provider: string, model: string): Readonly<LlmRouteCapabilityDeclaration> | undefined;
|
|
18
|
+
export { version };
|
|
19
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AACtD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAEtC,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,QAAQ,GAAG,QAAQ,CAAA;AAEvD,MAAM,WAAW,6BAA6B;IAC5C,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,SAAS,EAAE,YAAY,CAAA;CACjC;AAED,MAAM,MAAM,0BAA0B,GAAG,MAAM,IAAI,CAAA;AA2EnD;;;;GAIG;AACH,wBAAgB,0BAA0B,CACxC,OAAO,EAAE,UAAU,EACnB,KAAK,EAAE,6BAA6B,GACnC,0BAA0B,CAsB5B;AAED,kFAAkF;AAClF,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,UAAU,EACnB,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,MAAM,GACZ,QAAQ,CAAC,6BAA6B,CAAC,GAAG,SAAS,CAIrD;AAED,OAAO,EAAE,OAAO,EAAE,CAAA"}
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { version } from './version.js';
|
|
2
|
+
const registrySymbol = Symbol.for('@dsh-enhanced/llm-route-capabilities/runtime-registry/v1');
|
|
3
|
+
const providerPattern = /^[A-Za-z0-9][A-Za-z0-9._-]{0,255}$/u;
|
|
4
|
+
const modes = new Set(['none', 'native', 'bridge']);
|
|
5
|
+
function registryTarget(runtime) {
|
|
6
|
+
return runtime;
|
|
7
|
+
}
|
|
8
|
+
function validState(value) {
|
|
9
|
+
if (value === null || typeof value !== 'object')
|
|
10
|
+
return false;
|
|
11
|
+
const candidate = value;
|
|
12
|
+
return candidate.schemaVersion === 1
|
|
13
|
+
&& candidate.providers instanceof Map
|
|
14
|
+
&& candidate.models instanceof Map;
|
|
15
|
+
}
|
|
16
|
+
function registry(runtime, create) {
|
|
17
|
+
const target = registryTarget(runtime);
|
|
18
|
+
const existing = target[registrySymbol];
|
|
19
|
+
if (existing !== undefined) {
|
|
20
|
+
if (!validState(existing)) {
|
|
21
|
+
throw new Error('llm-route-capabilities: incompatible registry is already attached to this LlmRuntime');
|
|
22
|
+
}
|
|
23
|
+
return existing;
|
|
24
|
+
}
|
|
25
|
+
if (!create)
|
|
26
|
+
return undefined;
|
|
27
|
+
const state = {
|
|
28
|
+
schemaVersion: 1,
|
|
29
|
+
providers: new Map(),
|
|
30
|
+
models: new Map(),
|
|
31
|
+
};
|
|
32
|
+
Object.defineProperty(target, registrySymbol, {
|
|
33
|
+
value: state,
|
|
34
|
+
enumerable: false,
|
|
35
|
+
configurable: false,
|
|
36
|
+
writable: false,
|
|
37
|
+
});
|
|
38
|
+
return state;
|
|
39
|
+
}
|
|
40
|
+
function normalize(input) {
|
|
41
|
+
if (!providerPattern.test(input.provider)) {
|
|
42
|
+
throw new Error('llm-route-capabilities: provider must be an exact non-empty provider id');
|
|
43
|
+
}
|
|
44
|
+
if (input.model !== undefined
|
|
45
|
+
&& (input.model.length === 0 || input.model.length > 512 || /[\s\p{Cc}]/u.test(input.model))) {
|
|
46
|
+
throw new Error('llm-route-capabilities: model must be an exact non-empty model id');
|
|
47
|
+
}
|
|
48
|
+
if (!modes.has(input.toolCalls)) {
|
|
49
|
+
throw new Error('llm-route-capabilities: invalid tool-call mode');
|
|
50
|
+
}
|
|
51
|
+
return Object.freeze({
|
|
52
|
+
provider: input.provider,
|
|
53
|
+
...(input.model === undefined ? {} : { model: input.model }),
|
|
54
|
+
toolCalls: input.toolCalls,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
function modelKey(provider, model) {
|
|
58
|
+
return JSON.stringify([provider, model]);
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Attach one audited capability declaration to exactly one live LLM runtime.
|
|
62
|
+
* A selector has a single owner; even an identical duplicate is rejected so
|
|
63
|
+
* plugin unload cannot make another plugin's declaration disappear.
|
|
64
|
+
*/
|
|
65
|
+
export function registerLlmRouteCapability(runtime, input) {
|
|
66
|
+
const declaration = normalize(input);
|
|
67
|
+
const state = registry(runtime, true);
|
|
68
|
+
const entries = declaration.model === undefined ? state.providers : state.models;
|
|
69
|
+
const key = declaration.model === undefined
|
|
70
|
+
? declaration.provider
|
|
71
|
+
: modelKey(declaration.provider, declaration.model);
|
|
72
|
+
if (entries.has(key)) {
|
|
73
|
+
const selector = declaration.model === undefined
|
|
74
|
+
? declaration.provider
|
|
75
|
+
: `${declaration.provider}/${declaration.model}`;
|
|
76
|
+
throw new Error(`llm-route-capabilities: duplicate route capability selector: ${selector}`);
|
|
77
|
+
}
|
|
78
|
+
const token = Symbol('llm-route-capability-registration');
|
|
79
|
+
entries.set(key, { declaration, token });
|
|
80
|
+
let disposed = false;
|
|
81
|
+
return () => {
|
|
82
|
+
if (disposed)
|
|
83
|
+
return;
|
|
84
|
+
disposed = true;
|
|
85
|
+
const current = entries.get(key);
|
|
86
|
+
if (current?.token === token)
|
|
87
|
+
entries.delete(key);
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
/** Resolve the exact-model declaration first, then the provider-wide fallback. */
|
|
91
|
+
export function resolveLlmRouteCapability(runtime, provider, model) {
|
|
92
|
+
const state = registry(runtime, false);
|
|
93
|
+
return state?.models.get(modelKey(provider, model))?.declaration
|
|
94
|
+
?? state?.providers.get(provider)?.declaration;
|
|
95
|
+
}
|
|
96
|
+
export { version };
|
|
97
|
+
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAuBtC,MAAM,cAAc,GAAG,MAAM,CAAC,GAAG,CAAC,0DAA0D,CAAC,CAAA;AAC7F,MAAM,eAAe,GAAG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E,KAAK,CAAC,CAAC,EAAE,WAAW;WAC3D,KAAK,EAAE,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,WAAW,CAAA;AAClD,CAAC;AAED,OAAO,EAAE,OAAO,EAAE,CAAA"}
|
package/lib/version.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO,UAAU,CAAA"}
|
package/lib/version.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,OAAO,GAAG,OAAO,CAAA"}
|
package/package.json
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@dsh-enhanced/llm-route-capabilities",
|
|
3
|
+
"version": "0.1.3",
|
|
4
|
+
"description": "Runtime-local LLM route capability declarations for DeepSeek Harness integrations.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "./lib/index.js",
|
|
8
|
+
"types": "./lib/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./lib/index.d.ts",
|
|
12
|
+
"default": "./lib/index.js"
|
|
13
|
+
},
|
|
14
|
+
"./package.json": "./package.json"
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"lib",
|
|
18
|
+
"README.md",
|
|
19
|
+
"LICENSE"
|
|
20
|
+
],
|
|
21
|
+
"engines": {
|
|
22
|
+
"node": "^22.19.0 || >=24.0.0"
|
|
23
|
+
},
|
|
24
|
+
"publishConfig": {
|
|
25
|
+
"access": "public"
|
|
26
|
+
},
|
|
27
|
+
"repository": {
|
|
28
|
+
"type": "git",
|
|
29
|
+
"url": "git+https://github.com/22-ai-00/dsh-enhanced.git",
|
|
30
|
+
"directory": "packages/llm-route-capabilities"
|
|
31
|
+
},
|
|
32
|
+
"keywords": [
|
|
33
|
+
"deepseek",
|
|
34
|
+
"deepseek-harness",
|
|
35
|
+
"llm",
|
|
36
|
+
"tool-calls"
|
|
37
|
+
],
|
|
38
|
+
"peerDependencies": {
|
|
39
|
+
"@deepseek-ai/dsh-llm": ">=0.1.0-rc.8 <0.2.0"
|
|
40
|
+
},
|
|
41
|
+
"devDependencies": {
|
|
42
|
+
"@deepseek-ai/cordis": "4.0.1",
|
|
43
|
+
"@deepseek-ai/dsh-llm": "0.1.0-rc.8",
|
|
44
|
+
"@types/node": "22.20.0",
|
|
45
|
+
"typescript": "6.0.3",
|
|
46
|
+
"vitest": "4.1.8"
|
|
47
|
+
},
|
|
48
|
+
"scripts": {
|
|
49
|
+
"build": "tsc -p tsconfig.build.json",
|
|
50
|
+
"test": "vitest run",
|
|
51
|
+
"typecheck": "tsc -p tsconfig.json --noEmit"
|
|
52
|
+
}
|
|
53
|
+
}
|