offrouter-core 0.2.1 → 0.2.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/dist/audit.d.ts +137 -0
- package/dist/audit.d.ts.map +1 -0
- package/dist/audit.js +320 -0
- package/dist/audit.js.map +1 -0
- package/dist/auth/credential-chain.d.ts +84 -0
- package/dist/auth/credential-chain.d.ts.map +1 -0
- package/dist/auth/credential-chain.js +150 -0
- package/dist/auth/credential-chain.js.map +1 -0
- package/dist/auth/index.d.ts +10 -0
- package/dist/auth/index.d.ts.map +1 -0
- package/dist/auth/index.js +7 -0
- package/dist/auth/index.js.map +1 -0
- package/dist/auth/keychain.d.ts +60 -0
- package/dist/auth/keychain.d.ts.map +1 -0
- package/dist/auth/keychain.js +104 -0
- package/dist/auth/keychain.js.map +1 -0
- package/dist/auth/oauth-pkce.d.ts +138 -0
- package/dist/auth/oauth-pkce.d.ts.map +1 -0
- package/dist/auth/oauth-pkce.js +375 -0
- package/dist/auth/oauth-pkce.js.map +1 -0
- package/dist/auth/oauth-server.d.ts +36 -0
- package/dist/auth/oauth-server.d.ts.map +1 -0
- package/dist/auth/oauth-server.js +210 -0
- package/dist/auth/oauth-server.js.map +1 -0
- package/dist/config.d.ts +76 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +355 -0
- package/dist/config.js.map +1 -0
- package/dist/delegation.d.ts +123 -0
- package/dist/delegation.d.ts.map +1 -0
- package/dist/delegation.js +455 -0
- package/dist/delegation.js.map +1 -0
- package/dist/index.d.ts +41 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +26 -0
- package/dist/index.js.map +1 -0
- package/dist/policy.d.ts +45 -0
- package/dist/policy.d.ts.map +1 -0
- package/dist/policy.js +318 -0
- package/dist/policy.js.map +1 -0
- package/{src/protocol.ts → dist/protocol.d.ts} +2 -2
- package/dist/protocol.d.ts.map +1 -0
- package/dist/protocol.js +6 -0
- package/dist/protocol.js.map +1 -0
- package/dist/providers/adapter.d.ts +137 -0
- package/dist/providers/adapter.d.ts.map +1 -0
- package/dist/providers/adapter.js +163 -0
- package/dist/providers/adapter.js.map +1 -0
- package/dist/providers/catalog-data.d.ts +128 -0
- package/dist/providers/catalog-data.d.ts.map +1 -0
- package/dist/providers/catalog-data.js +397 -0
- package/dist/providers/catalog-data.js.map +1 -0
- package/dist/providers/catalog.d.ts +63 -0
- package/dist/providers/catalog.d.ts.map +1 -0
- package/dist/providers/catalog.js +394 -0
- package/dist/providers/catalog.js.map +1 -0
- package/dist/providers/fake.d.ts +46 -0
- package/dist/providers/fake.d.ts.map +1 -0
- package/dist/providers/fake.js +234 -0
- package/dist/providers/fake.js.map +1 -0
- package/dist/providers/openai-compatible.d.ts +65 -0
- package/dist/providers/openai-compatible.d.ts.map +1 -0
- package/dist/providers/openai-compatible.js +434 -0
- package/dist/providers/openai-compatible.js.map +1 -0
- package/dist/proxy/responses-mapper.d.ts +366 -0
- package/dist/proxy/responses-mapper.d.ts.map +1 -0
- package/dist/proxy/responses-mapper.js +517 -0
- package/dist/proxy/responses-mapper.js.map +1 -0
- package/dist/proxy/responses-server.d.ts +29 -0
- package/dist/proxy/responses-server.d.ts.map +1 -0
- package/dist/proxy/responses-server.js +360 -0
- package/dist/proxy/responses-server.js.map +1 -0
- package/dist/router.d.ts +18 -0
- package/dist/router.d.ts.map +1 -0
- package/dist/router.js +296 -0
- package/dist/router.js.map +1 -0
- package/dist/schemas.d.ts +560 -0
- package/dist/schemas.d.ts.map +1 -0
- package/{src/schemas.ts → dist/schemas.js} +83 -103
- package/dist/schemas.js.map +1 -0
- package/dist/secrets.d.ts +112 -0
- package/dist/secrets.d.ts.map +1 -0
- package/dist/secrets.js +326 -0
- package/dist/secrets.js.map +1 -0
- package/dist/types.d.ts +117 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +6 -0
- package/dist/types.js.map +1 -0
- package/dist/usage-file.d.ts +59 -0
- package/dist/usage-file.d.ts.map +1 -0
- package/dist/usage-file.js +316 -0
- package/dist/usage-file.js.map +1 -0
- package/dist/usage.d.ts +235 -0
- package/dist/usage.d.ts.map +1 -0
- package/dist/usage.js +517 -0
- package/dist/usage.js.map +1 -0
- package/package.json +7 -2
- package/src/audit.test.ts +0 -302
- package/src/audit.ts +0 -553
- package/src/auth/credential-chain.test.ts +0 -326
- package/src/auth/credential-chain.ts +0 -235
- package/src/auth/index.ts +0 -45
- package/src/auth/keychain.test.ts +0 -265
- package/src/auth/keychain.ts +0 -168
- package/src/auth/oauth-pkce.test.ts +0 -329
- package/src/auth/oauth-pkce.ts +0 -571
- package/src/auth/oauth-server.test.ts +0 -83
- package/src/auth/oauth-server.ts +0 -296
- package/src/config.test.ts +0 -479
- package/src/config.ts +0 -505
- package/src/delegation.test.ts +0 -368
- package/src/delegation.ts +0 -605
- package/src/index.ts +0 -280
- package/src/policy.test.ts +0 -634
- package/src/policy.ts +0 -420
- package/src/providers/adapter.test.ts +0 -293
- package/src/providers/adapter.ts +0 -328
- package/src/providers/catalog-data.test.ts +0 -258
- package/src/providers/catalog-data.ts +0 -498
- package/src/providers/catalog.test.ts +0 -84
- package/src/providers/catalog.ts +0 -483
- package/src/providers/fake.ts +0 -312
- package/src/providers/openai-compatible.test.ts +0 -366
- package/src/providers/openai-compatible.ts +0 -554
- package/src/proxy/responses-mapper.test.ts +0 -290
- package/src/proxy/responses-mapper.ts +0 -736
- package/src/proxy/responses-server.test.ts +0 -322
- package/src/proxy/responses-server.ts +0 -469
- package/src/router.test.ts +0 -699
- package/src/router.ts +0 -352
- package/src/schemas.test.ts +0 -291
- package/src/secrets.test.ts +0 -271
- package/src/secrets.ts +0 -461
- package/src/types.ts +0 -173
- package/src/usage-file.test.ts +0 -243
- package/src/usage-file.ts +0 -435
- package/src/usage.test.ts +0 -335
- package/src/usage.ts +0 -859
- package/tsconfig.json +0 -9
|
@@ -0,0 +1,366 @@
|
|
|
1
|
+
import { DelegationRuntime, type DelegationRuntimeOptions } from "../delegation.js";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import type { PolicyConfig } from "../policy.js";
|
|
4
|
+
import type { ProviderAdapter } from "../providers/adapter.js";
|
|
5
|
+
import type { ProviderErrorCode } from "../providers/adapter.js";
|
|
6
|
+
import type { HarnessRef, ProviderCandidate, RouteDecision, RouteRequest, WorkspaceRef } from "../types.js";
|
|
7
|
+
import type { DelegationRequest } from "../delegation.js";
|
|
8
|
+
/** Max chars kept for the routing-only prompt preview. */
|
|
9
|
+
export declare const RESPONSES_PROMPT_PREVIEW_CHARS = 120;
|
|
10
|
+
export interface ParsedResponsesInput {
|
|
11
|
+
/** Full prompt text for delegation only (never used for routing). */
|
|
12
|
+
prompt: string;
|
|
13
|
+
/** Requested model id; informational, routing overrides it. */
|
|
14
|
+
model?: string;
|
|
15
|
+
maxOutputTokens?: number;
|
|
16
|
+
temperature?: number;
|
|
17
|
+
stream?: boolean;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Thrown when an inbound request body fails schema validation. The proxy maps
|
|
21
|
+
* this to a 400 OpenAI-style error response.
|
|
22
|
+
*/
|
|
23
|
+
export declare class InvalidProxyRequestError extends Error {
|
|
24
|
+
readonly issues: readonly z.ZodIssue[];
|
|
25
|
+
constructor(issues: readonly z.ZodIssue[]);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Strict Zod schema for an OpenAI Responses inbound request body. Unknown
|
|
29
|
+
* top-level keys are rejected so malformed requests surface as a 400 rather
|
|
30
|
+
* than silently ignoring fields.
|
|
31
|
+
*/
|
|
32
|
+
export declare const ResponsesRequestSchema: z.ZodObject<{
|
|
33
|
+
model: z.ZodOptional<z.ZodString>;
|
|
34
|
+
instructions: z.ZodOptional<z.ZodString>;
|
|
35
|
+
input: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodObject<{
|
|
36
|
+
role: z.ZodOptional<z.ZodString>;
|
|
37
|
+
content: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodObject<{
|
|
38
|
+
type: z.ZodOptional<z.ZodString>;
|
|
39
|
+
text: z.ZodOptional<z.ZodString>;
|
|
40
|
+
input_text: z.ZodOptional<z.ZodString>;
|
|
41
|
+
output_text: z.ZodOptional<z.ZodString>;
|
|
42
|
+
}, "strip", z.ZodTypeAny, {
|
|
43
|
+
type?: string | undefined;
|
|
44
|
+
text?: string | undefined;
|
|
45
|
+
input_text?: string | undefined;
|
|
46
|
+
output_text?: string | undefined;
|
|
47
|
+
}, {
|
|
48
|
+
type?: string | undefined;
|
|
49
|
+
text?: string | undefined;
|
|
50
|
+
input_text?: string | undefined;
|
|
51
|
+
output_text?: string | undefined;
|
|
52
|
+
}>]>, "many">]>>;
|
|
53
|
+
}, "strip", z.ZodTypeAny, {
|
|
54
|
+
role?: string | undefined;
|
|
55
|
+
content?: string | (string | {
|
|
56
|
+
type?: string | undefined;
|
|
57
|
+
text?: string | undefined;
|
|
58
|
+
input_text?: string | undefined;
|
|
59
|
+
output_text?: string | undefined;
|
|
60
|
+
})[] | undefined;
|
|
61
|
+
}, {
|
|
62
|
+
role?: string | undefined;
|
|
63
|
+
content?: string | (string | {
|
|
64
|
+
type?: string | undefined;
|
|
65
|
+
text?: string | undefined;
|
|
66
|
+
input_text?: string | undefined;
|
|
67
|
+
output_text?: string | undefined;
|
|
68
|
+
})[] | undefined;
|
|
69
|
+
}>]>, "many">]>>;
|
|
70
|
+
stream: z.ZodOptional<z.ZodBoolean>;
|
|
71
|
+
max_output_tokens: z.ZodOptional<z.ZodNumber>;
|
|
72
|
+
temperature: z.ZodOptional<z.ZodNumber>;
|
|
73
|
+
}, "strip", z.ZodTypeAny, {
|
|
74
|
+
model?: string | undefined;
|
|
75
|
+
stream?: boolean | undefined;
|
|
76
|
+
temperature?: number | undefined;
|
|
77
|
+
instructions?: string | undefined;
|
|
78
|
+
input?: string | (string | {
|
|
79
|
+
role?: string | undefined;
|
|
80
|
+
content?: string | (string | {
|
|
81
|
+
type?: string | undefined;
|
|
82
|
+
text?: string | undefined;
|
|
83
|
+
input_text?: string | undefined;
|
|
84
|
+
output_text?: string | undefined;
|
|
85
|
+
})[] | undefined;
|
|
86
|
+
})[] | undefined;
|
|
87
|
+
max_output_tokens?: number | undefined;
|
|
88
|
+
}, {
|
|
89
|
+
model?: string | undefined;
|
|
90
|
+
stream?: boolean | undefined;
|
|
91
|
+
temperature?: number | undefined;
|
|
92
|
+
instructions?: string | undefined;
|
|
93
|
+
input?: string | (string | {
|
|
94
|
+
role?: string | undefined;
|
|
95
|
+
content?: string | (string | {
|
|
96
|
+
type?: string | undefined;
|
|
97
|
+
text?: string | undefined;
|
|
98
|
+
input_text?: string | undefined;
|
|
99
|
+
output_text?: string | undefined;
|
|
100
|
+
})[] | undefined;
|
|
101
|
+
})[] | undefined;
|
|
102
|
+
max_output_tokens?: number | undefined;
|
|
103
|
+
}>;
|
|
104
|
+
/**
|
|
105
|
+
* Extract prompt text and tuning options from an OpenAI Responses request body.
|
|
106
|
+
* Validates the body and throws {@link InvalidProxyRequestError} on any
|
|
107
|
+
* schema violation. Accepts both string and structured `input` shapes.
|
|
108
|
+
*/
|
|
109
|
+
export declare function extractPromptFromResponsesInput(body: unknown): ParsedResponsesInput;
|
|
110
|
+
/** Stable sha256 digest of the full prompt text. */
|
|
111
|
+
export declare function promptDigest(text: string): string;
|
|
112
|
+
/** Short single-line preview; collapses whitespace and truncates. */
|
|
113
|
+
export declare function promptPreview(text: string, max?: number): string;
|
|
114
|
+
export interface BuildRouteInput {
|
|
115
|
+
prompt: string;
|
|
116
|
+
harness: HarnessRef;
|
|
117
|
+
workspace: WorkspaceRef;
|
|
118
|
+
requestId?: string;
|
|
119
|
+
kind?: RouteRequest["task"]["kind"];
|
|
120
|
+
risk?: RouteRequest["task"]["risk"];
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Build a RouteRequest from the full prompt. The raw prompt is reduced to a
|
|
124
|
+
* redacted preview and digest; the full text never appears on the route.
|
|
125
|
+
*/
|
|
126
|
+
export declare function buildRouteRequest(input: BuildRouteInput): RouteRequest;
|
|
127
|
+
export interface BuildDelegationInput {
|
|
128
|
+
prompt: string;
|
|
129
|
+
route: RouteRequest;
|
|
130
|
+
taskId?: string;
|
|
131
|
+
maxOutputTokens?: number;
|
|
132
|
+
temperature?: number;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Build a DelegationRequest carrying the full prompt. Routing has already
|
|
136
|
+
* cleared the selected provider; the full text reaches the adapter only here.
|
|
137
|
+
*/
|
|
138
|
+
export declare function buildDelegationRequest(input: BuildDelegationInput): DelegationRequest;
|
|
139
|
+
export interface ResponsesOutputTextPart {
|
|
140
|
+
type: "output_text";
|
|
141
|
+
text: string;
|
|
142
|
+
annotations: unknown[];
|
|
143
|
+
}
|
|
144
|
+
export interface ResponsesMessageItem {
|
|
145
|
+
id: string;
|
|
146
|
+
type: "message";
|
|
147
|
+
status: "completed";
|
|
148
|
+
role: "assistant";
|
|
149
|
+
content: ResponsesOutputTextPart[];
|
|
150
|
+
}
|
|
151
|
+
export interface ResponsesObject {
|
|
152
|
+
id: string;
|
|
153
|
+
object: "response";
|
|
154
|
+
created_at: number;
|
|
155
|
+
status: "in_progress" | "completed" | "failed";
|
|
156
|
+
model: string;
|
|
157
|
+
output: ResponsesMessageItem[];
|
|
158
|
+
output_text?: string;
|
|
159
|
+
usage?: {
|
|
160
|
+
input_tokens: number;
|
|
161
|
+
output_tokens: number;
|
|
162
|
+
total_tokens: number;
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
export interface ResponsesUsageInput {
|
|
166
|
+
inputTokens?: number;
|
|
167
|
+
outputTokens?: number;
|
|
168
|
+
totalTokens?: number;
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Stateful builder that accumulates output text and produces the three
|
|
172
|
+
* OpenAI Responses SSE event payloads the proxy emits.
|
|
173
|
+
*/
|
|
174
|
+
export declare class ResponsesSseBuilder {
|
|
175
|
+
readonly responseId: string;
|
|
176
|
+
readonly messageId: string;
|
|
177
|
+
readonly createdAtMs: number;
|
|
178
|
+
private readonly now;
|
|
179
|
+
private model;
|
|
180
|
+
private text;
|
|
181
|
+
private usage;
|
|
182
|
+
constructor(model: string, now?: () => Date);
|
|
183
|
+
setModel(model: string): void;
|
|
184
|
+
addText(delta: string): void;
|
|
185
|
+
setUsage(usage: ResponsesUsageInput): void;
|
|
186
|
+
get fullText(): string;
|
|
187
|
+
createdEvent(): {
|
|
188
|
+
type: "response.created";
|
|
189
|
+
response: ResponsesObject;
|
|
190
|
+
};
|
|
191
|
+
deltaEvent(delta: string): {
|
|
192
|
+
type: "response.output_text.delta";
|
|
193
|
+
item_id: string;
|
|
194
|
+
output_index: number;
|
|
195
|
+
content_index: number;
|
|
196
|
+
delta: string;
|
|
197
|
+
};
|
|
198
|
+
completedEvent(): {
|
|
199
|
+
type: "response.completed";
|
|
200
|
+
response: ResponsesObject;
|
|
201
|
+
};
|
|
202
|
+
/**
|
|
203
|
+
* Final non-streaming Responses object: merges created + completed into a
|
|
204
|
+
* single JSON body (status "completed" with output_text).
|
|
205
|
+
*/
|
|
206
|
+
responseObject(): ResponsesObject;
|
|
207
|
+
private baseObject;
|
|
208
|
+
}
|
|
209
|
+
/** Wrap any JSON-serializable payload as an SSE `data:` line. */
|
|
210
|
+
export declare function responsesSseData(payload: unknown): string;
|
|
211
|
+
/**
|
|
212
|
+
* Strict Zod schema for an OpenAI Chat Completions inbound request body.
|
|
213
|
+
* Unknown top-level keys are rejected.
|
|
214
|
+
*/
|
|
215
|
+
export declare const ChatCompletionsRequestSchema: z.ZodObject<{
|
|
216
|
+
model: z.ZodOptional<z.ZodString>;
|
|
217
|
+
messages: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
218
|
+
role: z.ZodOptional<z.ZodString>;
|
|
219
|
+
content: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodObject<{
|
|
220
|
+
type: z.ZodOptional<z.ZodString>;
|
|
221
|
+
text: z.ZodOptional<z.ZodString>;
|
|
222
|
+
}, "strip", z.ZodTypeAny, {
|
|
223
|
+
type?: string | undefined;
|
|
224
|
+
text?: string | undefined;
|
|
225
|
+
}, {
|
|
226
|
+
type?: string | undefined;
|
|
227
|
+
text?: string | undefined;
|
|
228
|
+
}>]>, "many">]>>;
|
|
229
|
+
}, "strip", z.ZodTypeAny, {
|
|
230
|
+
role?: string | undefined;
|
|
231
|
+
content?: string | (string | {
|
|
232
|
+
type?: string | undefined;
|
|
233
|
+
text?: string | undefined;
|
|
234
|
+
})[] | undefined;
|
|
235
|
+
}, {
|
|
236
|
+
role?: string | undefined;
|
|
237
|
+
content?: string | (string | {
|
|
238
|
+
type?: string | undefined;
|
|
239
|
+
text?: string | undefined;
|
|
240
|
+
})[] | undefined;
|
|
241
|
+
}>, "many">>;
|
|
242
|
+
stream: z.ZodOptional<z.ZodBoolean>;
|
|
243
|
+
max_tokens: z.ZodOptional<z.ZodNumber>;
|
|
244
|
+
temperature: z.ZodOptional<z.ZodNumber>;
|
|
245
|
+
}, "strip", z.ZodTypeAny, {
|
|
246
|
+
model?: string | undefined;
|
|
247
|
+
stream?: boolean | undefined;
|
|
248
|
+
max_tokens?: number | undefined;
|
|
249
|
+
temperature?: number | undefined;
|
|
250
|
+
messages?: {
|
|
251
|
+
role?: string | undefined;
|
|
252
|
+
content?: string | (string | {
|
|
253
|
+
type?: string | undefined;
|
|
254
|
+
text?: string | undefined;
|
|
255
|
+
})[] | undefined;
|
|
256
|
+
}[] | undefined;
|
|
257
|
+
}, {
|
|
258
|
+
model?: string | undefined;
|
|
259
|
+
stream?: boolean | undefined;
|
|
260
|
+
max_tokens?: number | undefined;
|
|
261
|
+
temperature?: number | undefined;
|
|
262
|
+
messages?: {
|
|
263
|
+
role?: string | undefined;
|
|
264
|
+
content?: string | (string | {
|
|
265
|
+
type?: string | undefined;
|
|
266
|
+
text?: string | undefined;
|
|
267
|
+
})[] | undefined;
|
|
268
|
+
}[] | undefined;
|
|
269
|
+
}>;
|
|
270
|
+
/**
|
|
271
|
+
* Extract prompt text and options from an OpenAI Chat Completions body.
|
|
272
|
+
* Validates the body strictly and throws {@link InvalidProxyRequestError} on any
|
|
273
|
+
* schema violation. Used by the optional /v1/chat/completions alias.
|
|
274
|
+
*/
|
|
275
|
+
export declare function extractPromptFromChatCompletions(body: unknown): ParsedResponsesInput;
|
|
276
|
+
export interface ChatCompletionDeltaEvent {
|
|
277
|
+
id: string;
|
|
278
|
+
object: "chat.completion.chunk";
|
|
279
|
+
created: number;
|
|
280
|
+
model: string;
|
|
281
|
+
choices: Array<{
|
|
282
|
+
index: number;
|
|
283
|
+
delta: {
|
|
284
|
+
role?: "assistant";
|
|
285
|
+
content?: string;
|
|
286
|
+
};
|
|
287
|
+
finish_reason: string | null;
|
|
288
|
+
}>;
|
|
289
|
+
}
|
|
290
|
+
export interface ChatUsageInput {
|
|
291
|
+
promptTokens?: number;
|
|
292
|
+
completionTokens?: number;
|
|
293
|
+
totalTokens?: number;
|
|
294
|
+
}
|
|
295
|
+
export interface ChatCompletionObject {
|
|
296
|
+
id: string;
|
|
297
|
+
object: "chat.completion";
|
|
298
|
+
created: number;
|
|
299
|
+
model: string;
|
|
300
|
+
choices: Array<{
|
|
301
|
+
index: number;
|
|
302
|
+
message: {
|
|
303
|
+
role: "assistant";
|
|
304
|
+
content: string;
|
|
305
|
+
};
|
|
306
|
+
finish_reason: string;
|
|
307
|
+
}>;
|
|
308
|
+
usage?: {
|
|
309
|
+
prompt_tokens: number;
|
|
310
|
+
completion_tokens: number;
|
|
311
|
+
total_tokens: number;
|
|
312
|
+
};
|
|
313
|
+
}
|
|
314
|
+
/** Stateful builder for Chat Completions streaming chunks. */
|
|
315
|
+
export declare class ChatCompletionsSseBuilder {
|
|
316
|
+
readonly completionId: string;
|
|
317
|
+
readonly createdAtMs: number;
|
|
318
|
+
private model;
|
|
319
|
+
private text;
|
|
320
|
+
private usage;
|
|
321
|
+
constructor(model: string, now?: () => Date);
|
|
322
|
+
setModel(model: string): void;
|
|
323
|
+
addText(delta: string): void;
|
|
324
|
+
get fullText(): string;
|
|
325
|
+
setUsage(usage: ChatUsageInput): void;
|
|
326
|
+
firstEvent(): ChatCompletionDeltaEvent;
|
|
327
|
+
deltaEvent(content: string): ChatCompletionDeltaEvent;
|
|
328
|
+
doneEvent(): ChatCompletionDeltaEvent;
|
|
329
|
+
/**
|
|
330
|
+
* Final non-streaming Chat Completions object: a single JSON body with the
|
|
331
|
+
* merged assistant message and (optional) usage.
|
|
332
|
+
*/
|
|
333
|
+
completionObject(): ChatCompletionObject;
|
|
334
|
+
private chunk;
|
|
335
|
+
}
|
|
336
|
+
/** Terminal SSE marker for Chat Completions streams. */
|
|
337
|
+
export declare const CHAT_COMPLETIONS_DONE = "data: [DONE]\n\n";
|
|
338
|
+
/** Map a canonical provider error code to an HTTP status. */
|
|
339
|
+
export declare function providerErrorCodeToHttpStatus(code: ProviderErrorCode): number;
|
|
340
|
+
/**
|
|
341
|
+
* Map a routing decision at the gate to an HTTP status.
|
|
342
|
+
* needsConfiguration -> 503; otherwise blocked -> 403.
|
|
343
|
+
*/
|
|
344
|
+
export declare function policyDecisionToHttpStatus(decision: RouteDecision): number;
|
|
345
|
+
export interface OpenAiErrorPayload {
|
|
346
|
+
error: {
|
|
347
|
+
message: string;
|
|
348
|
+
type: string;
|
|
349
|
+
code?: string;
|
|
350
|
+
};
|
|
351
|
+
}
|
|
352
|
+
/** Build an OpenAI-style error JSON payload. */
|
|
353
|
+
export declare function openAiErrorPayload(status: number, message: string, code?: string): OpenAiErrorPayload;
|
|
354
|
+
export interface ResponsesProxyContext {
|
|
355
|
+
policy: PolicyConfig;
|
|
356
|
+
candidates: ProviderCandidate[];
|
|
357
|
+
adapters: Record<string, ProviderAdapter>;
|
|
358
|
+
runtime: DelegationRuntime;
|
|
359
|
+
}
|
|
360
|
+
export declare function createResponsesProxyContext(options: {
|
|
361
|
+
policy: PolicyConfig;
|
|
362
|
+
candidates: ProviderCandidate[];
|
|
363
|
+
adapters: Record<string, ProviderAdapter>;
|
|
364
|
+
delegation?: Pick<DelegationRuntimeOptions, "audit" | "now" | "includePromptPreview">;
|
|
365
|
+
}): ResponsesProxyContext;
|
|
366
|
+
//# sourceMappingURL=responses-mapper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"responses-mapper.d.ts","sourceRoot":"","sources":["../../src/proxy/responses-mapper.ts"],"names":[],"mappings":"AAeA,OAAO,EACL,iBAAiB,EACjB,KAAK,wBAAwB,EAC9B,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,KAAK,EACV,UAAU,EACV,iBAAiB,EACjB,aAAa,EACb,YAAY,EACZ,YAAY,EACb,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAGV,iBAAiB,EAClB,MAAM,kBAAkB,CAAC;AAE1B,0DAA0D;AAC1D,eAAO,MAAM,8BAA8B,MAAM,CAAC;AAMlD,MAAM,WAAW,oBAAoB;IACnC,qEAAqE;IACrE,MAAM,EAAE,MAAM,CAAC;IACf,+DAA+D;IAC/D,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAMD;;;GAGG;AACH,qBAAa,wBAAyB,SAAQ,KAAK;IACjD,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,QAAQ,EAAE,CAAC;gBAC3B,MAAM,EAAE,SAAS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