@deepseek-ai/dsh-llm 0.1.1-rc.2 → 0.1.2-alpha.2
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/README.i18n.yaml +2 -2
- package/README.md +123 -62
- package/README.zh.md +123 -66
- package/lib/index.js +780 -680
- package/lib/typert.host.d.ts +3 -0
- package/lib/typert.host.js +528 -0
- package/lib/typert.remote-client.d.ts +26 -0
- package/lib/typert.remote-client.js +102 -0
- package/lib/types/assembler.js +3 -3
- package/lib/types/brand.d.ts +10 -10
- package/lib/types/brand.js +13 -12
- package/lib/types/call-config.d.ts +0 -9
- package/lib/types/call-config.js +0 -40
- package/lib/types/content.d.ts +50 -16
- package/lib/types/content.js +99 -41
- package/lib/types/index.d.ts +38 -8
- package/lib/types/index.js +668 -570
- package/lib/types/message.d.ts +4 -13
- package/lib/types/message.js +4 -22
- package/lib/types/types.d.ts +53 -5
- package/package.json +25 -13
- package/lib/types/never.d.ts +0 -16
- package/lib/types/never.js +0 -21
package/lib/types/message.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** Message value types, identity, and immutable construction helpers. */
|
|
2
|
-
import { MessageId,
|
|
3
|
-
import type { ContentBlock,
|
|
2
|
+
import type { MessageId, ToolCallId } from './brand.ts';
|
|
3
|
+
import type { ContentBlock, ToolResultBlock } from './types.ts';
|
|
4
4
|
/** Provider/model identity and adapter-private replay data for an assistant message. */
|
|
5
5
|
export interface AssistantProvenance {
|
|
6
6
|
/** Provider route that produced the message. */
|
|
@@ -21,7 +21,7 @@ export interface ModelMessageSource extends AssistantProvenance {
|
|
|
21
21
|
/** Required source of a user-role message carrying one tool result. */
|
|
22
22
|
export interface ToolMessageSource {
|
|
23
23
|
kind: 'tool';
|
|
24
|
-
callId:
|
|
24
|
+
callId: ToolCallId;
|
|
25
25
|
}
|
|
26
26
|
/**
|
|
27
27
|
* The kind of information in producer-supplied context, declared by the
|
|
@@ -183,7 +183,7 @@ export declare function createAssistantMessage(input: NewAssistantMessage & {
|
|
|
183
183
|
}): AssistantMessage;
|
|
184
184
|
/** Input whose acceptance creates one tool-result message. */
|
|
185
185
|
export interface ToolResultMessageInput {
|
|
186
|
-
readonly callId:
|
|
186
|
+
readonly callId: ToolCallId;
|
|
187
187
|
readonly content: ContentBlock[];
|
|
188
188
|
readonly isError: boolean;
|
|
189
189
|
}
|
|
@@ -193,14 +193,5 @@ export interface ToolResultMessageInput {
|
|
|
193
193
|
* @returns an immutable user-role tool-result message.
|
|
194
194
|
*/
|
|
195
195
|
export declare function createToolResultMessage(input: ToolResultMessageInput): ToolResultMessage;
|
|
196
|
-
/**
|
|
197
|
-
* Whether a stream chunk carries visible model output (the first-token
|
|
198
|
-
* boundary shared by client step timing and the whole-log sessionStats
|
|
199
|
-
* projection). Empty deltas (heartbeats, empty tool-call frames) do not count
|
|
200
|
-
* as a first token.
|
|
201
|
-
* @param chunk - the stream chunk to test.
|
|
202
|
-
* @returns true when the chunk contains a non-empty text/reasoning/tool delta.
|
|
203
|
-
*/
|
|
204
|
-
export declare function isTokenDelta(chunk: StreamChunk): boolean;
|
|
205
196
|
export {};
|
|
206
197
|
//# sourceMappingURL=message.d.ts.map
|
package/lib/types/message.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/** Message value types, identity, and immutable construction helpers. */
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { randomUUID } from '@deepseek-ai/dsh-util-crypto';
|
|
3
|
+
import { brandString } from '@deepseek-ai/dsh-brand';
|
|
4
|
+
import { deepFreeze } from '@deepseek-ai/dsh-util-values';
|
|
4
5
|
/**
|
|
5
6
|
* Bound for a `notice` summary. The account rides a collapsed transcript row
|
|
6
7
|
* and is committed to the durable log, while its inputs — task labels, goal
|
|
@@ -33,7 +34,7 @@ export function freezeMessage(message) {
|
|
|
33
34
|
export function createMessage(input) {
|
|
34
35
|
return freezeMessage({
|
|
35
36
|
...input,
|
|
36
|
-
id:
|
|
37
|
+
id: brandString(randomUUID()),
|
|
37
38
|
});
|
|
38
39
|
}
|
|
39
40
|
/**
|
|
@@ -78,23 +79,4 @@ export function createToolResultMessage(input) {
|
|
|
78
79
|
}],
|
|
79
80
|
});
|
|
80
81
|
}
|
|
81
|
-
/**
|
|
82
|
-
* Whether a stream chunk carries visible model output (the first-token
|
|
83
|
-
* boundary shared by client step timing and the whole-log sessionStats
|
|
84
|
-
* projection). Empty deltas (heartbeats, empty tool-call frames) do not count
|
|
85
|
-
* as a first token.
|
|
86
|
-
* @param chunk - the stream chunk to test.
|
|
87
|
-
* @returns true when the chunk contains a non-empty text/reasoning/tool delta.
|
|
88
|
-
*/
|
|
89
|
-
export function isTokenDelta(chunk) {
|
|
90
|
-
switch (chunk.type) {
|
|
91
|
-
case 'text-delta':
|
|
92
|
-
case 'reasoning-delta':
|
|
93
|
-
return chunk.text !== '';
|
|
94
|
-
case 'tool-call-delta':
|
|
95
|
-
return chunk.argumentsDelta !== '' || chunk.name !== undefined;
|
|
96
|
-
default:
|
|
97
|
-
return false;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
82
|
//# sourceMappingURL=message.js.map
|
package/lib/types/types.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import type { Branded } from '@deepseek-ai/dsh-brand';
|
|
7
7
|
import type { ImageAttachmentRef } from '@deepseek-ai/dsh-attachment';
|
|
8
|
-
import type {
|
|
8
|
+
import type { ToolCallId, ProviderRequestId, ReasoningEffortId } from './brand.ts';
|
|
9
9
|
import type { Message } from './message.ts';
|
|
10
10
|
declare module '@deepseek-ai/cordis' {
|
|
11
11
|
interface Events {
|
|
@@ -49,7 +49,7 @@ export interface ReasoningBlock {
|
|
|
49
49
|
* A durable raster image reference, valid in user or assistant content. The
|
|
50
50
|
* block is deliberately role-neutral; assistant-side rendering is forward
|
|
51
51
|
* compatibility — the current production adapters declare text-only output,
|
|
52
|
-
* so only user
|
|
52
|
+
* so only user messages may carry images.
|
|
53
53
|
*/
|
|
54
54
|
export interface ImageBlock {
|
|
55
55
|
type: 'image';
|
|
@@ -60,7 +60,7 @@ export interface ImageBlock {
|
|
|
60
60
|
export interface ToolCallBlock {
|
|
61
61
|
type: 'tool-call';
|
|
62
62
|
/** Provider-issued call id; correlates with the matching tool result. */
|
|
63
|
-
id:
|
|
63
|
+
id: ToolCallId;
|
|
64
64
|
name: string;
|
|
65
65
|
/** Raw JSON string as produced by the model. */
|
|
66
66
|
arguments: string;
|
|
@@ -68,7 +68,7 @@ export interface ToolCallBlock {
|
|
|
68
68
|
/** The result of a tool invocation, sent back to the model. */
|
|
69
69
|
export interface ToolResultBlock {
|
|
70
70
|
type: 'tool-result';
|
|
71
|
-
toolCallId:
|
|
71
|
+
toolCallId: ToolCallId;
|
|
72
72
|
content: ContentBlock[];
|
|
73
73
|
isError?: boolean;
|
|
74
74
|
}
|
|
@@ -123,10 +123,46 @@ export type FinishReason = FinishReasonMap[keyof FinishReasonMap];
|
|
|
123
123
|
export interface TokenUsage {
|
|
124
124
|
inputTokens: number;
|
|
125
125
|
outputTokens: number;
|
|
126
|
+
/**
|
|
127
|
+
* Exact full-call total including aggregate prompt and output tokens.
|
|
128
|
+
*
|
|
129
|
+
* Adapters preserve a provider total or derive it from authoritative
|
|
130
|
+
* aggregate prompt/output counters; they omit it when unavailable or
|
|
131
|
+
* inconsistent.
|
|
132
|
+
*/
|
|
133
|
+
totalTokens?: number;
|
|
126
134
|
cacheReadTokens?: number;
|
|
127
135
|
cacheWriteTokens?: number;
|
|
128
136
|
reasoningTokens?: number;
|
|
129
137
|
}
|
|
138
|
+
/**
|
|
139
|
+
* Request price of one ordered image occurrence under one exact model route's
|
|
140
|
+
* request projection. Every occurrence resolves to the pair the wire actually
|
|
141
|
+
* carries: provider visual tokens for a retained image, plus the model-visible
|
|
142
|
+
* text sent with or instead of it (request-preview handle, offload placeholder,
|
|
143
|
+
* or text-only substitution). The caller prices `text` with its own text
|
|
144
|
+
* estimator so provider pricing never fixes a text tokenization.
|
|
145
|
+
*/
|
|
146
|
+
export interface LlmImageRequestPrice {
|
|
147
|
+
/** Provider visual tokens for the retained request image; 0 when only text represents this occurrence. */
|
|
148
|
+
visualTokens: number;
|
|
149
|
+
/** Model-visible text sent for this occurrence, to be priced by the caller's text estimator. */
|
|
150
|
+
text: string;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Provider-side request-image pricing for one exact model route. Implemented
|
|
154
|
+
* by adapters whose provider charges visual tokens; consumers (the token
|
|
155
|
+
* meter) resolve it synchronously per measurement, so implementations must not
|
|
156
|
+
* perform I/O.
|
|
157
|
+
*/
|
|
158
|
+
export interface LlmImageRequestPricing {
|
|
159
|
+
/**
|
|
160
|
+
* Price every image occurrence of one request projection.
|
|
161
|
+
* @param images - durable image references in request order, one entry per occurrence.
|
|
162
|
+
* @returns one price per occurrence, aligned by index with `images`.
|
|
163
|
+
*/
|
|
164
|
+
priceImages(images: readonly ImageAttachmentRef[]): readonly LlmImageRequestPrice[];
|
|
165
|
+
}
|
|
130
166
|
/** Display metadata for one registered provider route. */
|
|
131
167
|
export interface LlmProviderInfo {
|
|
132
168
|
/** Provider route key used by {@link GenerateOptions.provider}. */
|
|
@@ -192,9 +228,21 @@ export interface LlmModelDiscoveryRequest {
|
|
|
192
228
|
api?: string;
|
|
193
229
|
/** Credential for this interrogation alone; the harness never stores it. */
|
|
194
230
|
apiKey?: string;
|
|
231
|
+
}
|
|
232
|
+
/** Provider-side discovery request with operation-local cancellation attached. */
|
|
233
|
+
export interface LlmModelDiscoveryOperation extends LlmModelDiscoveryRequest {
|
|
195
234
|
/** Caller cancellation; implementations must settle promptly after it aborts. */
|
|
196
235
|
signal?: AbortSignal;
|
|
197
236
|
}
|
|
237
|
+
declare module '@deepseek-ai/dsh-typert-protocol' {
|
|
238
|
+
interface RemoteErrorDetailsMap {
|
|
239
|
+
/** A draft provider interrogation refused or failed. */
|
|
240
|
+
'llm/model-discovery-rejected': {
|
|
241
|
+
readonly settingsNs: string;
|
|
242
|
+
readonly baseURL?: string;
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
}
|
|
198
246
|
/**
|
|
199
247
|
* One model an endpoint reports about itself. Every field but the id is
|
|
200
248
|
* optional because most provider listings disclose an id and nothing else;
|
|
@@ -299,7 +347,7 @@ export type StreamChunk = {
|
|
|
299
347
|
} | {
|
|
300
348
|
type: 'tool-call-delta';
|
|
301
349
|
index: number;
|
|
302
|
-
id:
|
|
350
|
+
id: ToolCallId;
|
|
303
351
|
name?: string;
|
|
304
352
|
argumentsDelta: string;
|
|
305
353
|
} | {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@deepseek-ai/dsh-llm",
|
|
3
3
|
"description": "Provider-neutral LLM service interface for the DeepSeek Harness",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.2-alpha.2",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -34,6 +34,14 @@
|
|
|
34
34
|
"types": "./lib/types/message.d.ts",
|
|
35
35
|
"default": "./lib/types/message.js"
|
|
36
36
|
},
|
|
37
|
+
"./typert": {
|
|
38
|
+
"types": "./lib/typert.host.d.ts",
|
|
39
|
+
"default": "./lib/typert.host.js"
|
|
40
|
+
},
|
|
41
|
+
"./remote": {
|
|
42
|
+
"types": "./lib/typert.remote-client.d.ts",
|
|
43
|
+
"default": "./lib/typert.remote-client.js"
|
|
44
|
+
},
|
|
37
45
|
"./src/*": "./src/*",
|
|
38
46
|
"./package.json": "./package.json"
|
|
39
47
|
},
|
|
@@ -41,24 +49,28 @@
|
|
|
41
49
|
"lib/index.js",
|
|
42
50
|
"lib/invariant.js",
|
|
43
51
|
"lib/types/**/*.js",
|
|
44
|
-
"lib/types/**/*.d.ts"
|
|
52
|
+
"lib/types/**/*.d.ts",
|
|
53
|
+
"lib/typert.host.js",
|
|
54
|
+
"lib/typert.host.d.ts",
|
|
55
|
+
"lib/typert.remote-client.js",
|
|
56
|
+
"lib/typert.remote-client.d.ts"
|
|
45
57
|
],
|
|
46
58
|
"license": "MIT",
|
|
47
59
|
"peerDependencies": {
|
|
48
|
-
"@deepseek-ai/
|
|
49
|
-
"@deepseek-ai/dsh-attachment": "^0.1.1-rc.2",
|
|
50
|
-
"@deepseek-ai/dsh-invariants": "^0.1.1-rc.2",
|
|
51
|
-
"@deepseek-ai/dsh-timeout": "^0.1.1-rc.2",
|
|
52
|
-
"@deepseek-ai/cordis": "^4.0.1"
|
|
60
|
+
"@deepseek-ai/cordis": "^4.0.2"
|
|
53
61
|
},
|
|
54
62
|
"dependencies": {
|
|
55
|
-
"
|
|
63
|
+
"zod": "^4.4.3",
|
|
64
|
+
"@deepseek-ai/dsh-util-crypto": "^0.1.2-alpha.2",
|
|
65
|
+
"@deepseek-ai/schemastery": "^3.18.2",
|
|
66
|
+
"@deepseek-ai/dsh-timeout": "^0.1.2-alpha.2",
|
|
67
|
+
"@deepseek-ai/dsh-brand": "^0.1.2-alpha.2",
|
|
68
|
+
"@deepseek-ai/dsh-util-values": "^0.1.2-alpha.2",
|
|
69
|
+
"@deepseek-ai/dsh-typert-protocol": "^0.1.2-alpha.2"
|
|
56
70
|
},
|
|
57
71
|
"devDependencies": {
|
|
58
|
-
"@deepseek-ai/dsh-
|
|
59
|
-
"@deepseek-ai/dsh-
|
|
60
|
-
"@deepseek-ai/cordis": "^4.0.
|
|
61
|
-
"@deepseek-ai/dsh-attachment": "^0.1.1-rc.2",
|
|
62
|
-
"@deepseek-ai/dsh-invariants": "^0.1.1-rc.2"
|
|
72
|
+
"@deepseek-ai/dsh-attachment": "^0.1.2-alpha.2",
|
|
73
|
+
"@deepseek-ai/dsh-invariants": "^0.1.2-alpha.2",
|
|
74
|
+
"@deepseek-ai/cordis": "^4.0.2"
|
|
63
75
|
}
|
|
64
76
|
}
|
package/lib/types/never.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Exhaustiveness helper for closed core unions. Use {@link assertNever} at the default branch so a
|
|
3
|
-
* new variant fails compilation at every required handler. Do not use it for declaration-merged
|
|
4
|
-
* unions such as session events or content blocks: handle known variants and explicitly fall
|
|
5
|
-
* through because plugins may add valid unknown cases.
|
|
6
|
-
* @module @deepseek-ai/dsh-llm/never
|
|
7
|
-
*/
|
|
8
|
-
/**
|
|
9
|
-
* Mark an unreachable closed-union branch. A newly unhandled typed variant fails at the call site;
|
|
10
|
-
* a value that escaped its type throws with diagnostics at runtime.
|
|
11
|
-
* @param value - the impossible value; typed `never` so an unhandled variant fails compilation at the call site.
|
|
12
|
-
* @param context - optional label (e.g. the switch site) prefixed into the throw message.
|
|
13
|
-
* @returns never — it always throws, with the offending value JSON-rendered in the message.
|
|
14
|
-
*/
|
|
15
|
-
export declare function assertNever(value: never, context?: string): never;
|
|
16
|
-
//# sourceMappingURL=never.d.ts.map
|
package/lib/types/never.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Exhaustiveness helper for closed core unions. Use {@link assertNever} at the default branch so a
|
|
3
|
-
* new variant fails compilation at every required handler. Do not use it for declaration-merged
|
|
4
|
-
* unions such as session events or content blocks: handle known variants and explicitly fall
|
|
5
|
-
* through because plugins may add valid unknown cases.
|
|
6
|
-
* @module @deepseek-ai/dsh-llm/never
|
|
7
|
-
*/
|
|
8
|
-
/**
|
|
9
|
-
* Mark an unreachable closed-union branch. A newly unhandled typed variant fails at the call site;
|
|
10
|
-
* a value that escaped its type throws with diagnostics at runtime.
|
|
11
|
-
* @param value - the impossible value; typed `never` so an unhandled variant fails compilation at the call site.
|
|
12
|
-
* @param context - optional label (e.g. the switch site) prefixed into the throw message.
|
|
13
|
-
* @returns never — it always throws, with the offending value JSON-rendered in the message.
|
|
14
|
-
*/
|
|
15
|
-
export function assertNever(value, context) {
|
|
16
|
-
// JSON.stringify is typed string but returns undefined for undefined input;
|
|
17
|
-
// String() covers that and other non-serializable escapes.
|
|
18
|
-
const rendered = JSON.stringify(value) ?? String(value);
|
|
19
|
-
throw new Error(`unreachable variant${context ? ` in ${context}` : ''}: ${rendered}`);
|
|
20
|
-
}
|
|
21
|
-
//# sourceMappingURL=never.js.map
|