@stackstackstack/dsh-llm-pi-ai 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.i18n.yaml +6 -0
- package/README.md +204 -0
- package/README.zh.md +205 -0
- package/lib/index.js +1868 -0
- package/lib/invariant.js +23 -0
- package/lib/types/adapter.d.ts +69 -0
- package/lib/types/catalog.d.ts +183 -0
- package/lib/types/config.d.ts +176 -0
- package/lib/types/context.d.ts +24 -0
- package/lib/types/discovery.d.ts +38 -0
- package/lib/types/index.d.ts +68 -0
- package/lib/types/invariant.d.ts +16 -0
- package/lib/types/provider.d.ts +59 -0
- package/lib/types/replay.d.ts +48 -0
- package/lib/types/stream.d.ts +38 -0
- package/package.json +59 -0
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Durable pi-ai replay metadata and assistant-history reconstruction.
|
|
3
|
+
*
|
|
4
|
+
* Harness content remains the durable source for text and tool calls. This
|
|
5
|
+
* module stores only the provider-native metadata needed to reconstruct a
|
|
6
|
+
* pi-ai assistant message on a later request.
|
|
7
|
+
*
|
|
8
|
+
* @module dsh-llm-pi-ai/replay
|
|
9
|
+
*/
|
|
10
|
+
import type { Message } from '@stackstackstack/dsh-llm';
|
|
11
|
+
import type { Api, AssistantMessage } from '@earendil-works/pi-ai';
|
|
12
|
+
type PiAiReplayBlock = {
|
|
13
|
+
type: 'text';
|
|
14
|
+
textSignature?: string;
|
|
15
|
+
} | {
|
|
16
|
+
type: 'reasoning';
|
|
17
|
+
thinkingSignature?: string;
|
|
18
|
+
redacted?: boolean;
|
|
19
|
+
} | {
|
|
20
|
+
type: 'tool-call';
|
|
21
|
+
thoughtSignature?: string;
|
|
22
|
+
};
|
|
23
|
+
/** Versioned adapter-private projection required to replay a pi-ai response. */
|
|
24
|
+
export interface PiAiReplayState {
|
|
25
|
+
kind: 'pi-ai';
|
|
26
|
+
version: 1;
|
|
27
|
+
api: Api;
|
|
28
|
+
provider: string;
|
|
29
|
+
model: string;
|
|
30
|
+
responseModel?: string;
|
|
31
|
+
responseId?: string;
|
|
32
|
+
stopReason: AssistantMessage['stopReason'];
|
|
33
|
+
blocks: PiAiReplayBlock[];
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Project a successful pi-ai response into the minimal durable replay state.
|
|
37
|
+
* @param message - completed native pi-ai assistant response.
|
|
38
|
+
* @returns the versioned lossless-JSON replay projection.
|
|
39
|
+
*/
|
|
40
|
+
export declare function toPiReplayState(message: AssistantMessage): PiAiReplayState;
|
|
41
|
+
/**
|
|
42
|
+
* Convert one durable Harness assistant message into pi-ai history.
|
|
43
|
+
* @param message - assistant content with required source and optional adapter-owned replay metadata.
|
|
44
|
+
* @returns a native pi-ai assistant message reconstructed from durable content.
|
|
45
|
+
*/
|
|
46
|
+
export declare function toPiAssistant(message: Message): AssistantMessage;
|
|
47
|
+
export {};
|
|
48
|
+
//# sourceMappingURL=replay.d.ts.map
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* pi-ai assistant event translation into the Harness streaming protocol.
|
|
3
|
+
*
|
|
4
|
+
* pi-ai tool-call arguments are parsed objects while the Harness keeps their
|
|
5
|
+
* raw JSON representation. pi-ai also reports failures as terminal stream
|
|
6
|
+
* events, which this module maps into Harness finish chunks.
|
|
7
|
+
*
|
|
8
|
+
* @module dsh-llm-pi-ai/stream
|
|
9
|
+
*/
|
|
10
|
+
import type { FinishReason, StreamChunk, TokenUsage } from '@stackstackstack/dsh-llm';
|
|
11
|
+
import type { AssistantMessage, AssistantMessageEvent, Usage as PiUsage } from '@earendil-works/pi-ai';
|
|
12
|
+
/**
|
|
13
|
+
* Map pi-ai usage (reasoning folded into output by pi-ai).
|
|
14
|
+
* @param usage - cumulative usage from the terminal pi-ai event.
|
|
15
|
+
* @returns harness counts; cache fields appear only when non-zero (pi-ai reports zeros, not absence).
|
|
16
|
+
*/
|
|
17
|
+
export declare function mapUsage(usage: PiUsage): TokenUsage;
|
|
18
|
+
/**
|
|
19
|
+
* Map a terminal pi-ai event to the harness finish reason.
|
|
20
|
+
* @param message - the assistant message carried by the `done` or `error` event.
|
|
21
|
+
* @param contextWindow - resolved catalog capacity for usage-based overflow detection.
|
|
22
|
+
* @returns the mapped harness reason. Recognized error text, `stop` usage above
|
|
23
|
+
* `contextWindow`, and zero-output `length` usage that fills the window map
|
|
24
|
+
* to `CONTEXT_WINDOW_EXCEEDED`; a `stop` with no content blocks maps to an
|
|
25
|
+
* `EMPTY_RESPONSE` error.
|
|
26
|
+
*/
|
|
27
|
+
export declare function mapStopReason(message: AssistantMessage, contextWindow?: number): FinishReason;
|
|
28
|
+
/**
|
|
29
|
+
* Translate the pi-ai event stream into StreamChunks. pi-ai never throws
|
|
30
|
+
* mid-stream — failures arrive as `error` events, which become error/aborted
|
|
31
|
+
* `finish` chunks (the harness protocol's other error-delivery style).
|
|
32
|
+
* @param events - one assistant turn's pi-ai event stream.
|
|
33
|
+
* @param contextWindow - resolved catalog capacity for usage-based overflow detection.
|
|
34
|
+
* @returns the harness chunks, ending with `usage` then `finish`; throws
|
|
35
|
+
* `LlmError` (`STREAM_CLOSED`) if the source ends without a terminal event.
|
|
36
|
+
*/
|
|
37
|
+
export declare function toStreamChunks(events: AsyncIterable<AssistantMessageEvent>, contextWindow?: number): AsyncGenerator<StreamChunk>;
|
|
38
|
+
//# sourceMappingURL=stream.d.ts.map
|
package/package.json
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@stackstackstack/dsh-llm-pi-ai",
|
|
3
|
+
"description": "pi-ai-backed DeepSeek adapter for the DeepSeek Harness LLM seam (design-verification twin of dsh-llm-deepseek)",
|
|
4
|
+
"version": "0.1.5",
|
|
5
|
+
"publishConfig": {
|
|
6
|
+
"access": "public"
|
|
7
|
+
},
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/deepseek-ai/deepseek-harness.git",
|
|
11
|
+
"directory": "packages/llm/llm-pi-ai"
|
|
12
|
+
},
|
|
13
|
+
"type": "module",
|
|
14
|
+
"main": "lib/index.js",
|
|
15
|
+
"types": "lib/types/index.d.ts",
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"types": "./lib/types/index.d.ts",
|
|
19
|
+
"default": "./lib/index.js"
|
|
20
|
+
},
|
|
21
|
+
"./invariant": {
|
|
22
|
+
"types": "./lib/types/invariant.d.ts",
|
|
23
|
+
"default": "./lib/invariant.js"
|
|
24
|
+
},
|
|
25
|
+
"./src/*": "./src/*",
|
|
26
|
+
"./package.json": "./package.json"
|
|
27
|
+
},
|
|
28
|
+
"files": [
|
|
29
|
+
"lib/index.js",
|
|
30
|
+
"lib/invariant.js",
|
|
31
|
+
"lib/types/**/*.d.ts"
|
|
32
|
+
],
|
|
33
|
+
"license": "MIT",
|
|
34
|
+
"peerDependencies": {
|
|
35
|
+
"@stackstackstack/dsh-credentials": "^0.1.5",
|
|
36
|
+
"@stackstackstack/dsh-attachment": "^0.1.5",
|
|
37
|
+
"@stackstackstack/dsh-launch-environment": "^0.1.5",
|
|
38
|
+
"@stackstackstack/dsh-invariants": "^0.1.5",
|
|
39
|
+
"@stackstackstack/dsh-llm": "^0.1.5",
|
|
40
|
+
"@stackstackstack/dsh-timeout": "^0.1.5",
|
|
41
|
+
"@deepseek-ai/cordis": "^4.0.1",
|
|
42
|
+
"@stackstackstack/dsh-settings": "^0.1.5"
|
|
43
|
+
},
|
|
44
|
+
"dependencies": {
|
|
45
|
+
"@earendil-works/pi-ai": "^0.82.1",
|
|
46
|
+
"@deepseek-ai/schemastery": "^3.18.1"
|
|
47
|
+
},
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"@stackstackstack/dsh-attachment": "^0.1.5",
|
|
50
|
+
"@stackstackstack/dsh-launch-environment": "^0.1.5",
|
|
51
|
+
"@stackstackstack/dsh-invariants": "^0.1.5",
|
|
52
|
+
"@stackstackstack/dsh-llm": "^0.1.5",
|
|
53
|
+
"@stackstackstack/dsh-credentials": "^0.1.5",
|
|
54
|
+
"@stackstackstack/dsh-llm-deepseek": "^0.1.5",
|
|
55
|
+
"@stackstackstack/dsh-settings": "^0.1.5",
|
|
56
|
+
"@stackstackstack/dsh-timeout": "^0.1.5",
|
|
57
|
+
"@deepseek-ai/cordis": "^4.0.1"
|
|
58
|
+
}
|
|
59
|
+
}
|