dsh-lcx-codex 0.4.3-pre.3 → 0.4.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/README.md +68 -99
- package/THIRD_PARTY_NOTICES.md +64 -0
- package/lib/auxiliary-usage.js +63 -0
- package/lib/client.js +1363 -295
- package/lib/dsh-compat.js +80 -18
- package/lib/dsh-responses.js +75 -8
- package/lib/grok-native-search.js +153 -79
- package/lib/index.js +159 -101
- package/lib/invocation-policy-scope.js +261 -0
- package/lib/json-store.js +11 -4
- package/lib/pi-responses-runtime.js +1571 -0
- package/lib/responses-request.js +1 -1
- package/lib/responses-stream.js +163 -92
- package/lib/route.js +17 -3
- package/lib/search-accounting.js +86 -0
- package/lib/search-usage.js +86 -0
- package/lib/transport.js +38 -10
- package/lib/types/client/index.d.ts +12 -0
- package/lib/types/client/search-media.d.ts +16 -0
- package/lib/web-run-output.js +22 -0
- package/lib/web-search-alpha.js +230 -28
- package/lib/web-search-capability.js +26 -1
- package/lib/web-search-hosted.js +119 -9
- package/lib/web-search-ref-store.js +88 -7
- package/package.json +50 -26
- package/lib/types/compact-v2.d.ts +0 -104
- package/lib/types/dsh-compat.d.ts +0 -78
- package/lib/types/dsh-responses.d.ts +0 -82
- package/lib/types/grok-native-search.d.ts +0 -39
- package/lib/types/json-store.d.ts +0 -10
- package/lib/types/native-checkpoint.d.ts +0 -213
- package/lib/types/responses-request.d.ts +0 -59
- package/lib/types/responses-stream.d.ts +0 -64
- package/lib/types/route.d.ts +0 -153
- package/lib/types/service-mutex.d.ts +0 -14
- package/lib/types/token-budget.d.ts +0 -50
- package/lib/types/transport.d.ts +0 -21
- package/lib/types/web-run-output.d.ts +0 -29
- package/lib/types/web-search-alpha.d.ts +0 -286
- package/lib/types/web-search-capability.d.ts +0 -26
- package/lib/types/web-search-hosted.d.ts +0 -246
- package/lib/types/web-search-ref-store.d.ts +0 -22
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import { requestImageHandleText, type Message } from "@deepseek-ai/dsh-llm";
|
|
2
|
-
import type { Context } from "@deepseek-ai/cordis";
|
|
3
|
-
import type { ResponseInputItem } from "openai/resources/responses/responses.js";
|
|
4
|
-
type ImageAttachmentRef = Parameters<typeof requestImageHandleText>[0];
|
|
5
|
-
import type { Model as PiModel, Tool as PiToolValue } from "@earendil-works/pi-ai";
|
|
6
|
-
declare const DEFAULT_MAX_REQUEST_IMAGE_BYTES: number;
|
|
7
|
-
declare const DEFAULT_REQUEST_IMAGE_PIXEL_BUDGET: number;
|
|
8
|
-
declare const DEFAULT_REQUEST_IMAGE_MAX_BYTES: number;
|
|
9
|
-
export { DEFAULT_MAX_REQUEST_IMAGE_BYTES, DEFAULT_REQUEST_IMAGE_PIXEL_BUDGET, DEFAULT_REQUEST_IMAGE_MAX_BYTES, };
|
|
10
|
-
type WireRecord = Record<string, unknown>;
|
|
11
|
-
type ImageSupport = "supported" | "unsupported" | "unknown";
|
|
12
|
-
type PiTool = PiToolValue;
|
|
13
|
-
type DshContext = Pick<Context, "attachments" | "llm" | "fs">;
|
|
14
|
-
type ImageOptions = {
|
|
15
|
-
imageSupport: ImageSupport;
|
|
16
|
-
signal?: AbortSignal;
|
|
17
|
-
maxRequestImageBytes: number;
|
|
18
|
-
requestImagePixelBudget: number;
|
|
19
|
-
requestImageMaxBytes: number;
|
|
20
|
-
};
|
|
21
|
-
type SerializeOptions = Partial<ImageOptions> & {
|
|
22
|
-
route?: unknown;
|
|
23
|
-
model?: unknown;
|
|
24
|
-
responsesCompat?: unknown;
|
|
25
|
-
systemPrompt?: unknown;
|
|
26
|
-
includeSystemPrompt?: boolean;
|
|
27
|
-
onReplayDegrade?: unknown;
|
|
28
|
-
tools?: PiTool[];
|
|
29
|
-
};
|
|
30
|
-
type ReplayBlock = WireRecord & {
|
|
31
|
-
type: "text" | "reasoning" | "tool-call";
|
|
32
|
-
};
|
|
33
|
-
type ReplayResponse = WireRecord & {
|
|
34
|
-
kind: "pi-ai";
|
|
35
|
-
version: 2;
|
|
36
|
-
api: string;
|
|
37
|
-
provider: string;
|
|
38
|
-
model: string;
|
|
39
|
-
stopReason: "stop" | "length" | "toolUse" | "error" | "aborted";
|
|
40
|
-
};
|
|
41
|
-
export declare function responseInputItems(value: unknown): ResponseInputItem[];
|
|
42
|
-
export declare function resolveModelImageSupport(ctx: DshContext | undefined, route: {
|
|
43
|
-
provider?: unknown;
|
|
44
|
-
model?: unknown;
|
|
45
|
-
}, signal?: AbortSignal): Promise<ImageSupport>;
|
|
46
|
-
export declare function readDshPiReplayState(value: unknown): {
|
|
47
|
-
response: ReplayResponse;
|
|
48
|
-
blocks: ReplayBlock[];
|
|
49
|
-
};
|
|
50
|
-
export declare function resolvePiResponsesModel(options: {
|
|
51
|
-
imageSupport: unknown;
|
|
52
|
-
route?: unknown;
|
|
53
|
-
model?: unknown;
|
|
54
|
-
responsesCompat?: unknown;
|
|
55
|
-
}): {
|
|
56
|
-
id: string;
|
|
57
|
-
name: string;
|
|
58
|
-
api: string;
|
|
59
|
-
provider: string;
|
|
60
|
-
baseUrl: string;
|
|
61
|
-
reasoning: boolean;
|
|
62
|
-
input: any[];
|
|
63
|
-
cost: {};
|
|
64
|
-
contextWindow: number;
|
|
65
|
-
maxTokens: number;
|
|
66
|
-
compat?: {
|
|
67
|
-
[x: string]: unknown;
|
|
68
|
-
} | undefined;
|
|
69
|
-
};
|
|
70
|
-
export declare function serializeDshMessages(messages: readonly Message[], ctx: DshContext | undefined, options?: SerializeOptions): Promise<{
|
|
71
|
-
input: import("openai/resources/responses/responses.js").ResponseInput;
|
|
72
|
-
imageMap: Map<string, import("@deepseek-ai/dsh-attachment").ImageAttachmentRef>;
|
|
73
|
-
tools: import("openai/resources/responses/responses.js").Tool[] | undefined;
|
|
74
|
-
model: PiModel<"openai-responses">;
|
|
75
|
-
grammarToolInputProperties: ReadonlyMap<string, string>;
|
|
76
|
-
deferredToolsMode: string | undefined;
|
|
77
|
-
}>;
|
|
78
|
-
export declare function responsesTools(tools: readonly PiTool[] | undefined): any[] | undefined;
|
|
79
|
-
export declare function persistNativeImageReferences(output: readonly unknown[], imageMap: ReadonlyMap<string, ImageAttachmentRef>): unknown[];
|
|
80
|
-
export declare function hydrateNativeImageReferences(output: unknown, ctx: DshContext | undefined, options?: Partial<ImageOptions> & {
|
|
81
|
-
imageMap?: unknown;
|
|
82
|
-
}): Promise<unknown[]>;
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import type { Message, ToolSchema } from "@deepseek-ai/dsh-llm";
|
|
2
|
-
export declare const GROK_NATIVE_SERVER_TOOL_TYPES: Set<string>;
|
|
3
|
-
export type GrokNativeSearchState = {
|
|
4
|
-
web: boolean;
|
|
5
|
-
x: boolean;
|
|
6
|
-
};
|
|
7
|
-
export type GrokNativeReplayRoute = {
|
|
8
|
-
provider: string;
|
|
9
|
-
model: string;
|
|
10
|
-
sessionId: string;
|
|
11
|
-
baseURL: string;
|
|
12
|
-
apiKeyEnv: string;
|
|
13
|
-
headers?: Record<string, string>;
|
|
14
|
-
};
|
|
15
|
-
type WireTool = Record<string, unknown>;
|
|
16
|
-
type WireItem = Record<string, unknown> & {
|
|
17
|
-
type: string;
|
|
18
|
-
};
|
|
19
|
-
type GrokNativeVisibleAddition = {
|
|
20
|
-
kind: "citation-sources";
|
|
21
|
-
textSha256: string;
|
|
22
|
-
};
|
|
23
|
-
type GrokNativeReplayEnvelope = {
|
|
24
|
-
kind: "xai-responses-native-search";
|
|
25
|
-
version: 2;
|
|
26
|
-
provider: string;
|
|
27
|
-
model: string;
|
|
28
|
-
sourceSessionId: string;
|
|
29
|
-
routeAuthorityFingerprint: string;
|
|
30
|
-
output: WireItem[];
|
|
31
|
-
visibleAdditions: GrokNativeVisibleAddition[];
|
|
32
|
-
};
|
|
33
|
-
export declare function grokNativeReplayRouteFingerprint(route: GrokNativeReplayRoute): string;
|
|
34
|
-
export declare function grokNativeSearchEnabled(state: GrokNativeSearchState): boolean;
|
|
35
|
-
export declare function grokVisibleFunctionTools(tools: readonly ToolSchema[] | undefined, state?: GrokNativeSearchState): ToolSchema[] | undefined;
|
|
36
|
-
export declare function grokWireTools(tools: readonly unknown[] | undefined, state: GrokNativeSearchState): WireTool[];
|
|
37
|
-
export declare function createGrokNativeReplayEnvelope(output: readonly unknown[] | undefined, route: GrokNativeReplayRoute | undefined, visibleAdditions?: readonly unknown[]): GrokNativeReplayEnvelope | undefined;
|
|
38
|
-
export declare function restoreGrokNativeReplay(input: readonly unknown[], messages: readonly Message[], route: GrokNativeReplayRoute | undefined): unknown[];
|
|
39
|
-
export {};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export declare class JsonStore<T> {
|
|
2
|
-
readonly file: string;
|
|
3
|
-
readonly empty: () => T;
|
|
4
|
-
readonly validate: (data: unknown) => data is T;
|
|
5
|
-
readonly corruptCode: string;
|
|
6
|
-
data: T;
|
|
7
|
-
constructor(file: string, empty: () => T, validate: (data: unknown) => data is T, corruptCode?: string);
|
|
8
|
-
refresh(): void;
|
|
9
|
-
update(mutator: (current: T) => T): void;
|
|
10
|
-
}
|
|
@@ -1,213 +0,0 @@
|
|
|
1
|
-
import type { ResponseInputItem } from "openai/resources/responses/responses.js";
|
|
2
|
-
import { Session, type SessionEvent } from "@deepseek-ai/dsh-session";
|
|
3
|
-
import { requestImageHandleText, type Message, type StreamChunk, type TokenUsage } from "@deepseek-ai/dsh-llm";
|
|
4
|
-
type CompactionItem = {
|
|
5
|
-
type: "compaction";
|
|
6
|
-
encrypted_content: string;
|
|
7
|
-
};
|
|
8
|
-
export type NativeOutputItem = ResponseInputItem;
|
|
9
|
-
type RouteIdentity = {
|
|
10
|
-
provider: string;
|
|
11
|
-
model: string;
|
|
12
|
-
baseURL: string;
|
|
13
|
-
sessionId: string;
|
|
14
|
-
};
|
|
15
|
-
type CompactionSummaryEvent = SessionEvent<"compaction/summary">;
|
|
16
|
-
type RetentionOptions = {
|
|
17
|
-
tokenBudget?: number;
|
|
18
|
-
assistantTokenReserve?: number;
|
|
19
|
-
assistantPerMessageTokenCap?: number;
|
|
20
|
-
};
|
|
21
|
-
type RetentionPlan = {
|
|
22
|
-
items: unknown[];
|
|
23
|
-
clientCount: number;
|
|
24
|
-
assistantCount: number;
|
|
25
|
-
estimatedTokens: number;
|
|
26
|
-
clientEstimatedTokens: number;
|
|
27
|
-
assistantEstimatedTokens: number;
|
|
28
|
-
};
|
|
29
|
-
type NativeCheckpointBase = {
|
|
30
|
-
compactionId: string;
|
|
31
|
-
provider: string;
|
|
32
|
-
model: string;
|
|
33
|
-
baseURLFingerprint: string;
|
|
34
|
-
sourceSessionId: string;
|
|
35
|
-
nativeOutput: NativeOutputItem[];
|
|
36
|
-
nativeCompaction?: CompactionItem;
|
|
37
|
-
retainedInputCount?: number;
|
|
38
|
-
retainedClientCount?: number;
|
|
39
|
-
retainedAssistantCount?: number;
|
|
40
|
-
retainedEstimatedTokens?: number;
|
|
41
|
-
createdAt?: number;
|
|
42
|
-
};
|
|
43
|
-
export type NativeCheckpointV5 = NativeCheckpointBase & {
|
|
44
|
-
type: "lcx-native-compaction-v5";
|
|
45
|
-
version: 5;
|
|
46
|
-
retentionPolicy?: "conversation-fidelity-v1";
|
|
47
|
-
};
|
|
48
|
-
export type NativeCheckpointBlock = NativeCheckpointV5;
|
|
49
|
-
declare module "@deepseek-ai/dsh-llm" {
|
|
50
|
-
interface ContentBlockMap {
|
|
51
|
-
"lcx-native-compaction-v5": NativeCheckpointV5;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
type NativeCompactionResult = {
|
|
55
|
-
compaction: CompactionItem;
|
|
56
|
-
};
|
|
57
|
-
type ImageAttachmentRef = Parameters<typeof requestImageHandleText>[0];
|
|
58
|
-
type CheckpointRouteRecord = {
|
|
59
|
-
version: number;
|
|
60
|
-
provider: unknown;
|
|
61
|
-
model: unknown;
|
|
62
|
-
baseURLFingerprint: unknown;
|
|
63
|
-
sourceSessionId: unknown;
|
|
64
|
-
};
|
|
65
|
-
type CreateCheckpointOptions = {
|
|
66
|
-
session: Session;
|
|
67
|
-
route: RouteIdentity;
|
|
68
|
-
result: NativeCompactionResult;
|
|
69
|
-
input?: unknown[];
|
|
70
|
-
ephemeralPreludeItemCount?: number;
|
|
71
|
-
imageMap?: ReadonlyMap<string, ImageAttachmentRef>;
|
|
72
|
-
retentionOptions?: RetentionOptions;
|
|
73
|
-
};
|
|
74
|
-
/**
|
|
75
|
-
* @typedef {object} NativeCheckpointBase
|
|
76
|
-
* @property {string} compactionId
|
|
77
|
-
* @property {string} provider
|
|
78
|
-
* @property {string} model
|
|
79
|
-
* @property {string} baseURLFingerprint
|
|
80
|
-
* @property {string} sourceSessionId
|
|
81
|
-
* @property {NativeOutputItem[]} nativeOutput
|
|
82
|
-
* @property {CompactionItem} [nativeCompaction]
|
|
83
|
-
* @property {number} [retainedInputCount]
|
|
84
|
-
* @property {number} [retainedClientCount]
|
|
85
|
-
* @property {number} [retainedAssistantCount]
|
|
86
|
-
* @property {number} [retainedEstimatedTokens]
|
|
87
|
-
* @property {number} [createdAt]
|
|
88
|
-
*/
|
|
89
|
-
/** @typedef {NativeCheckpointBase & { type: 'lcx-native-compaction-v5', version: 5, retentionPolicy?: 'conversation-fidelity-v1' }} NativeCheckpointV5 */
|
|
90
|
-
/** @typedef {NativeCheckpointV5} NativeCheckpointBlock */
|
|
91
|
-
/**
|
|
92
|
-
* Minimal validated candidate shape. DSH rawOutput is unknown until the existing
|
|
93
|
-
* version, field, count, and compaction validation below has completed.
|
|
94
|
-
* @typedef {object} NativeCheckpointCandidate
|
|
95
|
-
* @property {typeof NATIVE_BLOCK_TYPE} type
|
|
96
|
-
* @property {typeof NATIVE_BLOCK_VERSION} version
|
|
97
|
-
* @property {unknown} [compactionId]
|
|
98
|
-
* @property {unknown} [nativeOutput]
|
|
99
|
-
* @property {unknown} [provider]
|
|
100
|
-
* @property {unknown} [model]
|
|
101
|
-
* @property {unknown} [baseURLFingerprint]
|
|
102
|
-
* @property {unknown} [sourceSessionId]
|
|
103
|
-
* @property {unknown} [retainedInputCount]
|
|
104
|
-
* @property {unknown} [retainedClientCount]
|
|
105
|
-
* @property {unknown} [retainedAssistantCount]
|
|
106
|
-
*/
|
|
107
|
-
/** @typedef {{ compaction: CompactionItem }} NativeCompactionResult */
|
|
108
|
-
/** @typedef {{ session: Session, route: RouteIdentity, result: NativeCompactionResult, input?: unknown[], ephemeralPreludeItemCount?: number, imageMap?: unknown, retentionOptions?: RetentionOptions }} CreateCheckpointOptions */
|
|
109
|
-
/** @typedef {Error & { code?: string }} LcxError */
|
|
110
|
-
export declare const NATIVE_BLOCK_TYPE = "lcx-native-compaction-v5";
|
|
111
|
-
export declare const NATIVE_BLOCK_VERSION = 5;
|
|
112
|
-
export declare const RETAINED_MESSAGE_TOKEN_BUDGET = 64000;
|
|
113
|
-
export declare const ASSISTANT_RETENTION_TOKEN_RESERVE = 24000;
|
|
114
|
-
export declare const ASSISTANT_RETENTION_PER_MESSAGE_TOKEN_CAP = 3000;
|
|
115
|
-
/**
|
|
116
|
-
* @param {unknown[] | null | undefined} input
|
|
117
|
-
* @param {RetentionOptions} [options]
|
|
118
|
-
* @returns {unknown[]}
|
|
119
|
-
*/
|
|
120
|
-
export declare function retainedCompactionInput(input: readonly unknown[] | null | undefined, options?: RetentionOptions): unknown[];
|
|
121
|
-
/**
|
|
122
|
-
* @param {unknown[] | null | undefined} input
|
|
123
|
-
* @param {RetentionOptions} [options]
|
|
124
|
-
* @returns {RetentionPlan}
|
|
125
|
-
*/
|
|
126
|
-
export declare function retainedConversationPlan(input: readonly unknown[] | null | undefined, options?: RetentionOptions): RetentionPlan;
|
|
127
|
-
/**
|
|
128
|
-
* @param {unknown[] | null | undefined} input
|
|
129
|
-
* @param {RetentionOptions} [options]
|
|
130
|
-
*/
|
|
131
|
-
export declare function retainedConversationInput<T>(input: readonly T[] | null | undefined, options?: RetentionOptions): T[];
|
|
132
|
-
/** @param {unknown[] | null | undefined} items */
|
|
133
|
-
export declare function hasRetainedCompactionInput(items: readonly unknown[] | null | undefined): boolean;
|
|
134
|
-
export declare function compactCheckpointId(message: Message | null | undefined): string | undefined;
|
|
135
|
-
/** Reject reserved checkpoint markers without interpreting unsupported formats or opening sidecars. */
|
|
136
|
-
export declare function assertSupportedCheckpointMessage(message: Message): void;
|
|
137
|
-
/** @param {Session | null | undefined} session */
|
|
138
|
-
export declare function activeCompactionId(session: Session | null | undefined): string | undefined;
|
|
139
|
-
/**
|
|
140
|
-
* @param {CreateCheckpointOptions} options
|
|
141
|
-
* @returns {NativeCheckpointV5}
|
|
142
|
-
*/
|
|
143
|
-
export declare function createNativeCheckpointBlock({ session, route, result, input, ephemeralPreludeItemCount, imageMap, retentionOptions, }: CreateCheckpointOptions): NativeCheckpointV5;
|
|
144
|
-
/**
|
|
145
|
-
* @param {NativeCheckpointBlock} block
|
|
146
|
-
* @param {unknown} usage
|
|
147
|
-
* @returns {UnknownRecord[]}
|
|
148
|
-
*/
|
|
149
|
-
export declare function nativeCheckpointChunks(block: NativeCheckpointBlock, usage: TokenUsage | undefined): StreamChunk[];
|
|
150
|
-
/**
|
|
151
|
-
* @param {Session | null | undefined} session
|
|
152
|
-
* @param {string | null | undefined} compactionId
|
|
153
|
-
* @returns {CompactionSummaryEvent | undefined}
|
|
154
|
-
*/
|
|
155
|
-
export declare function compactionSummaryEvent(session: Session | null | undefined, compactionId: string | null | undefined): CompactionSummaryEvent | undefined;
|
|
156
|
-
/**
|
|
157
|
-
* @param {CompactionSummaryEvent | null | undefined} event
|
|
158
|
-
* @returns {NativeCheckpointBlock | undefined}
|
|
159
|
-
*/
|
|
160
|
-
export declare function stateFromSummaryEvent(event: CompactionSummaryEvent | null | undefined): {
|
|
161
|
-
compactionId: string;
|
|
162
|
-
provider: string;
|
|
163
|
-
model: string;
|
|
164
|
-
baseURLFingerprint: string;
|
|
165
|
-
sourceSessionId: string;
|
|
166
|
-
nativeOutput: NativeOutputItem[];
|
|
167
|
-
nativeCompaction: CompactionItem;
|
|
168
|
-
retainedInputCount?: number | undefined;
|
|
169
|
-
retainedClientCount?: number | undefined;
|
|
170
|
-
retainedAssistantCount?: number | undefined;
|
|
171
|
-
type: string;
|
|
172
|
-
version: number;
|
|
173
|
-
} | undefined;
|
|
174
|
-
/**
|
|
175
|
-
* @param {Session} session
|
|
176
|
-
* @param {Message} message
|
|
177
|
-
*/
|
|
178
|
-
export declare function checkpointStateForMessage(session: Session, message: Message): {
|
|
179
|
-
compactionId: string;
|
|
180
|
-
provider: string;
|
|
181
|
-
model: string;
|
|
182
|
-
baseURLFingerprint: string;
|
|
183
|
-
sourceSessionId: string;
|
|
184
|
-
nativeOutput: NativeOutputItem[];
|
|
185
|
-
nativeCompaction: CompactionItem;
|
|
186
|
-
retainedInputCount?: number | undefined;
|
|
187
|
-
retainedClientCount?: number | undefined;
|
|
188
|
-
retainedAssistantCount?: number | undefined;
|
|
189
|
-
type: string;
|
|
190
|
-
version: number;
|
|
191
|
-
} | undefined;
|
|
192
|
-
/**
|
|
193
|
-
* @param {NativeCheckpointBlock} state
|
|
194
|
-
* @param {RouteIdentity} route
|
|
195
|
-
* @param {unknown} ctx
|
|
196
|
-
*/
|
|
197
|
-
export declare function stateRouteCompatible(state: CheckpointRouteRecord | null | undefined, route: RouteIdentity, ctx: unknown): boolean;
|
|
198
|
-
/**
|
|
199
|
-
* @param {Session} session
|
|
200
|
-
* @param {string} compactionId
|
|
201
|
-
* @returns {Message[]}
|
|
202
|
-
*/
|
|
203
|
-
export declare function shadowedMessagesForCheckpoint(session: Session, compactionId: string): Message[];
|
|
204
|
-
/**
|
|
205
|
-
* @param {Session} session
|
|
206
|
-
* @param {string} compactionId
|
|
207
|
-
* @param {{ maxChars?: number }} [options]
|
|
208
|
-
* @returns {Message[]}
|
|
209
|
-
*/
|
|
210
|
-
export declare function portableMessagesForCheckpoint(session: Session, compactionId: string, options?: {
|
|
211
|
-
maxChars?: number;
|
|
212
|
-
}): Message[];
|
|
213
|
-
export {};
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
/** @typedef {'none' | 'short' | 'long'} CacheRetention */
|
|
2
|
-
type UnknownRecord = Record<string, unknown>;
|
|
3
|
-
type CacheRetention = "none" | "short" | "long";
|
|
4
|
-
type ResponsesCompat = {
|
|
5
|
-
supportsLongCacheRetention?: boolean;
|
|
6
|
-
supportsExplicitPromptCacheMode?: boolean;
|
|
7
|
-
supportsMaxOutputTokens?: boolean;
|
|
8
|
-
};
|
|
9
|
-
type PiResponsesModel = {
|
|
10
|
-
id: string;
|
|
11
|
-
provider: string;
|
|
12
|
-
reasoning?: boolean;
|
|
13
|
-
thinkingLevelMap?: Record<string, string | null>;
|
|
14
|
-
includeEncryptedReasoning?: boolean;
|
|
15
|
-
compat?: ResponsesCompat;
|
|
16
|
-
};
|
|
17
|
-
type GenerationControls = {
|
|
18
|
-
reasoningEffort?: unknown;
|
|
19
|
-
temperature?: unknown;
|
|
20
|
-
maxTokens?: unknown;
|
|
21
|
-
};
|
|
22
|
-
type BuildResponsesBodyOptions = GenerationControls & {
|
|
23
|
-
model: PiResponsesModel | string;
|
|
24
|
-
input: unknown[];
|
|
25
|
-
tools?: unknown;
|
|
26
|
-
sessionId?: string;
|
|
27
|
-
promptCacheKey?: string;
|
|
28
|
-
promptCacheRetention?: string;
|
|
29
|
-
cacheRetention?: CacheRetention;
|
|
30
|
-
samplingParams?: UnknownRecord;
|
|
31
|
-
};
|
|
32
|
-
type ResponsesWireBody = UnknownRecord & {
|
|
33
|
-
model: string;
|
|
34
|
-
input: unknown[];
|
|
35
|
-
stream: boolean;
|
|
36
|
-
store: boolean;
|
|
37
|
-
tool_choice?: string;
|
|
38
|
-
parallel_tool_calls?: boolean;
|
|
39
|
-
};
|
|
40
|
-
/**
|
|
41
|
-
* Pi-parity generation controls for OpenAI Responses.
|
|
42
|
-
* @param {GenerationControls & { model?: PiResponsesModel | string, includeDefaultReasoning?: boolean }} [controls]
|
|
43
|
-
*/
|
|
44
|
-
export declare function responsesGenerationEnvelope({ model, reasoningEffort, temperature, maxTokens, includeDefaultReasoning, }?: GenerationControls & {
|
|
45
|
-
model?: PiResponsesModel | string;
|
|
46
|
-
includeDefaultReasoning?: boolean;
|
|
47
|
-
}): UnknownRecord;
|
|
48
|
-
/**
|
|
49
|
-
* Build the shared LCX-owned request envelope while retaining Pi 0.85.1 Responses semantics.
|
|
50
|
-
* Production LCX ordinary/compact/replay construction places the DSH system prompt in canonical input.
|
|
51
|
-
* @param {BuildResponsesBodyOptions} options
|
|
52
|
-
*/
|
|
53
|
-
export declare function buildResponsesBody({ model, input, tools, sessionId, promptCacheKey, promptCacheRetention, cacheRetention, reasoningEffort, temperature, maxTokens, samplingParams, }: BuildResponsesBodyOptions): ResponsesWireBody;
|
|
54
|
-
/**
|
|
55
|
-
* Compact is the standard request plus the one opaque-history transition patch.
|
|
56
|
-
* @param {BuildResponsesBodyOptions} options
|
|
57
|
-
*/
|
|
58
|
-
export declare function buildCompactionResponsesBody(options: BuildResponsesBodyOptions): ResponsesWireBody;
|
|
59
|
-
export {};
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { type Model as PiModel } from "@earendil-works/pi-ai";
|
|
2
|
-
import type { StreamChunk } from "@deepseek-ai/dsh-llm";
|
|
3
|
-
import { type GrokNativeReplayRoute } from "./grok-native-search.js";
|
|
4
|
-
type UnknownRecord = Record<string, unknown>;
|
|
5
|
-
type PiResponsesModel = PiModel<"openai-responses">;
|
|
6
|
-
type ManagedFailure = {
|
|
7
|
-
message: string;
|
|
8
|
-
code: string;
|
|
9
|
-
status?: number;
|
|
10
|
-
requestId?: string;
|
|
11
|
-
providerRetryAfterMs?: number;
|
|
12
|
-
};
|
|
13
|
-
type AbortLike = Pick<AbortSignal, "aborted" | "reason">;
|
|
14
|
-
export type ServerToolUsage = {
|
|
15
|
-
webSearchCalls: number;
|
|
16
|
-
xSearchCalls: number;
|
|
17
|
-
total: number;
|
|
18
|
-
};
|
|
19
|
-
type StreamRequestOptions = {
|
|
20
|
-
baseURL: string;
|
|
21
|
-
provider: string;
|
|
22
|
-
model: string;
|
|
23
|
-
piModel: PiResponsesModel;
|
|
24
|
-
body: UnknownRecord;
|
|
25
|
-
grammarToolInputProperties?: ReadonlyMap<string, string>;
|
|
26
|
-
headers?: Record<string, string>;
|
|
27
|
-
signal?: AbortSignal;
|
|
28
|
-
timeoutMs?: number;
|
|
29
|
-
applyDefaultTimeout?: boolean;
|
|
30
|
-
streamIdleTimeoutMs?: number;
|
|
31
|
-
maxAttempts?: number;
|
|
32
|
-
maxResponseBytes?: number;
|
|
33
|
-
serverToolTypes?: ReadonlySet<string>;
|
|
34
|
-
nativeReplayRoute?: GrokNativeReplayRoute;
|
|
35
|
-
onServerToolUsage?: (usage: ServerToolUsage) => void;
|
|
36
|
-
};
|
|
37
|
-
/**
|
|
38
|
-
* Provider bodies/messages are deliberately not surfaced. Only a stable class and safe facts leave the wire boundary.
|
|
39
|
-
* @param {unknown} error
|
|
40
|
-
* @param {AbortSignal} [signal]
|
|
41
|
-
*/
|
|
42
|
-
export declare function managedFailure(error: unknown, signal: AbortLike | undefined): ManagedFailure;
|
|
43
|
-
/** @param {unknown} error @param {AbortSignal} [signal] */
|
|
44
|
-
export declare function managedFailureChunk(error: unknown, signal?: AbortLike): StreamChunk;
|
|
45
|
-
/**
|
|
46
|
-
* Send one LCX-owned OpenAI Responses request. Ordinary and replay use one provider attempt;
|
|
47
|
-
* the DSH agent recovery layer remains the visible retry owner.
|
|
48
|
-
* @param {object} options
|
|
49
|
-
* @param {string} options.baseURL
|
|
50
|
-
* @param {string} options.provider
|
|
51
|
-
* @param {string} options.model
|
|
52
|
-
* @param {UnknownRecord} options.piModel
|
|
53
|
-
* @param {UnknownRecord} options.body
|
|
54
|
-
* @param {Map<string, string>} [options.grammarToolInputProperties]
|
|
55
|
-
* @param {Record<string, string>} [options.headers]
|
|
56
|
-
* @param {AbortSignal} [options.signal]
|
|
57
|
-
* @param {number} [options.timeoutMs]
|
|
58
|
-
* @param {number} [options.maxAttempts]
|
|
59
|
-
* @param {number} [options.maxResponseBytes]
|
|
60
|
-
* @param {ReadonlySet<string>} [options.serverToolTypes]
|
|
61
|
-
* @param {(usage: ServerToolUsage) => void} [options.onServerToolUsage]
|
|
62
|
-
*/
|
|
63
|
-
export declare function streamResponsesRequest({ baseURL, provider, model, piModel, body, grammarToolInputProperties, headers, signal, timeoutMs, applyDefaultTimeout, streamIdleTimeoutMs, maxAttempts, maxResponseBytes, serverToolTypes, nativeReplayRoute, onServerToolUsage, }: StreamRequestOptions): AsyncGenerator<StreamChunk, void, unknown>;
|
|
64
|
-
export {};
|
package/lib/types/route.d.ts
DELETED
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
import type { Context } from "@deepseek-ai/cordis";
|
|
2
|
-
import { type Session } from "@deepseek-ai/dsh-session";
|
|
3
|
-
import "@deepseek-ai/dsh-settings";
|
|
4
|
-
import { resolveRetryPolicy } from "@deepseek-ai/dsh-llm";
|
|
5
|
-
import type { Model, ModelThinkingLevel } from "@earendil-works/pi-ai";
|
|
6
|
-
type HeaderMap = Record<string, string>;
|
|
7
|
-
type RetryPolicyConfig = Parameters<typeof resolveRetryPolicy>[0];
|
|
8
|
-
type CacheRetention = "none" | "short" | "long";
|
|
9
|
-
type ResponsesCompat = {
|
|
10
|
-
supportsDeveloperRole?: boolean;
|
|
11
|
-
sessionAffinityFormat?: "openai" | "openai-nosession" | "openrouter";
|
|
12
|
-
supportsStrictMode?: boolean;
|
|
13
|
-
supportsLongCacheRetention?: boolean;
|
|
14
|
-
supportsOpenAIGrammarTools?: boolean;
|
|
15
|
-
supportsAdditionalTools?: boolean;
|
|
16
|
-
supportsToolSearch?: boolean;
|
|
17
|
-
supportsExplicitPromptCacheMode?: boolean;
|
|
18
|
-
supportsMaxOutputTokens?: boolean;
|
|
19
|
-
};
|
|
20
|
-
type RouteIdentity = {
|
|
21
|
-
provider: string;
|
|
22
|
-
model: string;
|
|
23
|
-
baseURL: string;
|
|
24
|
-
sessionId: string;
|
|
25
|
-
};
|
|
26
|
-
type RouteOptions = {
|
|
27
|
-
provider?: unknown;
|
|
28
|
-
model?: unknown;
|
|
29
|
-
sessionId?: unknown;
|
|
30
|
-
};
|
|
31
|
-
type ProviderModelProfile = {
|
|
32
|
-
id?: unknown;
|
|
33
|
-
compat?: unknown;
|
|
34
|
-
reasoningEfforts?: unknown;
|
|
35
|
-
};
|
|
36
|
-
type ProviderProfile = {
|
|
37
|
-
api?: string;
|
|
38
|
-
baseURL?: string;
|
|
39
|
-
apiKeyEnv?: string;
|
|
40
|
-
headers?: HeaderMap;
|
|
41
|
-
reasoning?: unknown;
|
|
42
|
-
cacheRetention?: unknown;
|
|
43
|
-
timeoutMs?: unknown;
|
|
44
|
-
streamIdleTimeoutMs?: unknown;
|
|
45
|
-
maxRequestImageBytes?: unknown;
|
|
46
|
-
requestImagePixelBudget?: unknown;
|
|
47
|
-
requestImageMaxBytes?: unknown;
|
|
48
|
-
retryPolicy?: RetryPolicyConfig;
|
|
49
|
-
compat?: unknown;
|
|
50
|
-
models?: ProviderModelProfile[];
|
|
51
|
-
modelOverrides?: Record<string, ProviderModelProfile>;
|
|
52
|
-
};
|
|
53
|
-
type LlmSettingsSection = {
|
|
54
|
-
providers?: Record<string, ProviderProfile>;
|
|
55
|
-
};
|
|
56
|
-
type RequestHeaderConfig = {
|
|
57
|
-
provider?: unknown;
|
|
58
|
-
model?: unknown;
|
|
59
|
-
reasoningEffort?: unknown;
|
|
60
|
-
temperature?: unknown;
|
|
61
|
-
maxTokens?: unknown;
|
|
62
|
-
};
|
|
63
|
-
type RequestHeader = {
|
|
64
|
-
config?: RequestHeaderConfig;
|
|
65
|
-
};
|
|
66
|
-
type RouteSession = Pick<Session, "requestHeader">;
|
|
67
|
-
export type RouteContext = Pick<Context, "credentials" | "llm" | "logger" | "sessions" | "settings">;
|
|
68
|
-
type RoutePolicy = {
|
|
69
|
-
cacheRetention?: unknown;
|
|
70
|
-
supportsLongCacheRetention?: unknown;
|
|
71
|
-
supportsExplicitPromptCacheMode?: unknown;
|
|
72
|
-
responsesCompat?: unknown;
|
|
73
|
-
timeoutMs?: number;
|
|
74
|
-
maxAttempts?: number;
|
|
75
|
-
maxRequestImageBytes?: number;
|
|
76
|
-
requestImagePixelBudget?: number;
|
|
77
|
-
requestImageMaxBytes?: number;
|
|
78
|
-
};
|
|
79
|
-
type PiResponsesModel = Model<"openai-responses">;
|
|
80
|
-
type ModelControlProjection = {
|
|
81
|
-
reasoning?: boolean;
|
|
82
|
-
thinkingLevelMap?: Partial<Record<ModelThinkingLevel, string | null>>;
|
|
83
|
-
includeEncryptedReasoning?: boolean;
|
|
84
|
-
};
|
|
85
|
-
type ModelDescriptorDefaults = Partial<Pick<PiResponsesModel, "reasoning" | "thinkingLevelMap">>;
|
|
86
|
-
type UnresolvedRouteConfig = RoutePolicy & {
|
|
87
|
-
provider: string;
|
|
88
|
-
model: string;
|
|
89
|
-
baseURL: string;
|
|
90
|
-
apiKeyEnv: string;
|
|
91
|
-
headers?: HeaderMap;
|
|
92
|
-
};
|
|
93
|
-
export type ResolvedResponsesRoute = UnresolvedRouteConfig & {
|
|
94
|
-
api: "openai-responses";
|
|
95
|
-
cacheRetention: CacheRetention;
|
|
96
|
-
supportsLongCacheRetention: boolean;
|
|
97
|
-
responsesCompat?: ResponsesCompat;
|
|
98
|
-
modelControls?: ModelControlProjection;
|
|
99
|
-
modelDefaults?: ModelDescriptorDefaults;
|
|
100
|
-
profileReasoning?: ModelThinkingLevel;
|
|
101
|
-
streamIdleTimeoutMs?: number;
|
|
102
|
-
};
|
|
103
|
-
type GenerationControls = {
|
|
104
|
-
reasoningEffort?: unknown;
|
|
105
|
-
temperature?: unknown;
|
|
106
|
-
maxTokens?: unknown;
|
|
107
|
-
};
|
|
108
|
-
type CheckpointRouteRecord = {
|
|
109
|
-
version: number;
|
|
110
|
-
provider: unknown;
|
|
111
|
-
model: unknown;
|
|
112
|
-
baseURLFingerprint: unknown;
|
|
113
|
-
sourceSessionId: unknown;
|
|
114
|
-
};
|
|
115
|
-
/** @param {unknown} value */
|
|
116
|
-
export declare function normalizeBaseURL(value: unknown): string;
|
|
117
|
-
/** @param {unknown} baseURL */
|
|
118
|
-
export declare function baseURLFingerprint(baseURL: unknown): string;
|
|
119
|
-
/** @param {Partial<RouteIdentity> | null | undefined} route @param {{ includeSession?: boolean }} [options] */
|
|
120
|
-
export declare function routeFingerprint(route: Partial<RouteIdentity> | null | undefined, options?: {
|
|
121
|
-
includeSession?: boolean;
|
|
122
|
-
}): string;
|
|
123
|
-
/** @param {Partial<RouteIdentity> | null | undefined} route @param {Partial<Pick<ResolvedResponsesRoute, 'cacheRetention'>>} [config] @param {RouteContext | null | undefined} [ctx] */
|
|
124
|
-
export declare function promptCacheSessionId(route: Partial<RouteIdentity> | null | undefined, config?: Partial<Pick<ResolvedResponsesRoute, "cacheRetention">>, ctx?: RouteContext | null | undefined): string | undefined;
|
|
125
|
-
/** @param {Partial<RouteIdentity> | null | undefined} route @param {Partial<Pick<ResolvedResponsesRoute, 'cacheRetention'>>} [config] @param {RouteContext | null | undefined} [ctx] */
|
|
126
|
-
export declare function promptCacheKey(route: Partial<RouteIdentity> | null | undefined, config?: Partial<Pick<ResolvedResponsesRoute, "cacheRetention">>, ctx?: RouteContext | null | undefined): string | undefined;
|
|
127
|
-
/** Grok follows Pi directly: cache/affinity belongs to the selected child session. */
|
|
128
|
-
export declare function grokPromptCacheSessionId(route: Partial<RouteIdentity> | null | undefined, config?: Partial<Pick<ResolvedResponsesRoute, "cacheRetention">>): string | undefined;
|
|
129
|
-
/** @param {Partial<Pick<ResolvedResponsesRoute, 'cacheRetention' | 'supportsLongCacheRetention' | 'responsesCompat'>>} [config] */
|
|
130
|
-
export declare function promptCacheRetention(config?: Partial<Pick<ResolvedResponsesRoute, "cacheRetention" | "supportsLongCacheRetention" | "responsesCompat">>): "24h" | undefined;
|
|
131
|
-
/** @param {RouteContext | null | undefined} ctx @param {string} namespace */
|
|
132
|
-
export declare function settingsValue(ctx: RouteContext | null | undefined, namespace: string): LlmSettingsSection | undefined;
|
|
133
|
-
/** Resolve only the selected DSH profile; policy cannot supply route identity or credentials. */
|
|
134
|
-
export declare function resolveResponsesRouteConfig(ctx: RouteContext | null | undefined, options: RouteOptions & {
|
|
135
|
-
purpose?: string;
|
|
136
|
-
}, policy: RoutePolicy): ResolvedResponsesRoute | undefined;
|
|
137
|
-
/** Resolve a Grok-prefixed model through its selected DSH Responses profile. */
|
|
138
|
-
export declare function resolveGrokResponsesRouteConfig(ctx: RouteContext | null | undefined, options: RouteOptions, policy: RoutePolicy): ResolvedResponsesRoute | undefined;
|
|
139
|
-
/** @param {RouteContext | null | undefined} ctx @param {Pick<ResolvedResponsesRoute, 'apiKeyEnv'>} config */
|
|
140
|
-
export declare function resolveApiKey(ctx: RouteContext | null | undefined, config: Pick<ResolvedResponsesRoute, "apiKeyEnv">): Promise<string>;
|
|
141
|
-
/** @param {RouteContext | null | undefined} ctx @param {ResolvedResponsesRoute} config @param {unknown} sessionId @param {string | null | undefined} requestId @returns {Promise<HeaderMap>} */
|
|
142
|
-
export declare function authenticatedHeaders(ctx: RouteContext | null | undefined, config: ResolvedResponsesRoute, sessionId: unknown, requestId: string | null | undefined): Promise<HeaderMap>;
|
|
143
|
-
/** Grok mirrors Pi createClient ordering without changing accepted GPT headers. */
|
|
144
|
-
export declare function authenticatedGrokHeaders(ctx: RouteContext | null | undefined, config: ResolvedResponsesRoute, sessionId: unknown): Promise<HeaderMap>;
|
|
145
|
-
/** @param {RouteOptions | null | undefined} options @param {Pick<UnresolvedRouteConfig, 'provider' | 'model' | 'baseURL'>} config @returns {RouteIdentity} */
|
|
146
|
-
export declare function currentRoute(options: RouteOptions | null | undefined, config: Pick<UnresolvedRouteConfig, "provider" | "model" | "baseURL">): RouteIdentity;
|
|
147
|
-
/** @param {RequestHeader | null | undefined} header @param {Partial<RouteIdentity> | null | undefined} route @returns {GenerationControls} */
|
|
148
|
-
export declare function generationControlsFromHeader(header: RequestHeader | null | undefined, route: Partial<RouteIdentity> | null | undefined): GenerationControls;
|
|
149
|
-
/** @param {RouteSession | null | undefined} session @param {Partial<RouteIdentity> | null | undefined} route @returns {GenerationControls} */
|
|
150
|
-
export declare function generationControlsFromSession(session: RouteSession | null | undefined, route: Partial<RouteIdentity> | null | undefined): GenerationControls;
|
|
151
|
-
/** @param {CheckpointRouteRecord | null | undefined} record @param {RouteIdentity} route @param {unknown} ctx */
|
|
152
|
-
export declare function routeCompatible(record: CheckpointRouteRecord | null | undefined, route: RouteIdentity, ctx: unknown): boolean;
|
|
153
|
-
export {};
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
type Release = () => void;
|
|
2
|
-
export declare class ServiceMutex {
|
|
3
|
-
private locked;
|
|
4
|
-
private closed;
|
|
5
|
-
private closeReason?;
|
|
6
|
-
private readonly queue;
|
|
7
|
-
private readonly idleWaiters;
|
|
8
|
-
constructor();
|
|
9
|
-
acquire(signal?: AbortSignal): Promise<Release>;
|
|
10
|
-
release(): void;
|
|
11
|
-
run<T>(signal: AbortSignal | undefined, task: () => T | Promise<T>): Promise<T>;
|
|
12
|
-
close(reason?: Error): Promise<void>;
|
|
13
|
-
}
|
|
14
|
-
export {};
|