@codeproxy/core 0.1.8 → 0.1.11

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/index.d.cts CHANGED
@@ -1,51 +1,3 @@
1
- type UpstreamFormat = 'anthropic' | 'openai-chat';
2
- interface CacheStats {
3
- cachedTokens: number;
4
- cacheCreationTokens: number;
5
- inputTokens: number;
6
- outputTokens: number;
7
- totalTokens: number;
8
- }
9
- interface CreateResponsesFetchOptions {
10
- /** Upstream API format. If omitted, inferred from `baseUrl`. */
11
- upstreamFormat?: UpstreamFormat;
12
- /** Upstream endpoint URL. Required. */
13
- baseUrl: string;
14
- /** Override upstream API version header (Anthropic only). */
15
- apiVersion?: string;
16
- /** Replace the caller-provided `model` field before translation. */
17
- model?: string;
18
- /** Extra headers merged into every upstream call. */
19
- defaultHeaders?: Record<string, string>;
20
- /** Underlying fetch. Defaults to `globalThis.fetch`. */
21
- fetch?: typeof fetch;
22
- /** Non-/responses traffic forward target. Defaults to `options.fetch`. */
23
- passthroughFetch?: typeof fetch;
24
- /** Drop image/file parts from user messages (e.g. DeepSeek text-only models). */
25
- dropImages?: boolean;
26
- /** Fallback thought signature for Gemini OpenAI-compatible tool histories. */
27
- fallbackThoughtSignature?: string;
28
- /** Optional callback to receive cache statistics. */
29
- onCacheStats?: (stats: CacheStats) => void;
30
- /** Override reasoning_effort sent to the upstream model (OpenAI Chat / Anthropic). */
31
- reasoning_effort?: string;
32
- /** Override thinking configuration sent to the upstream model. */
33
- thinking?: unknown;
34
- /** Timeout in milliseconds for upstream requests. Defaults to no timeout. */
35
- timeoutMs?: number;
36
- /** Fallback upstream for requests where the last user message contains images. */
37
- fallbackUpstream?: {
38
- baseUrl: string;
39
- upstreamFormat?: UpstreamFormat;
40
- model?: string;
41
- defaultHeaders?: Record<string, string>;
42
- apiVersion?: string;
43
- reasoning_effort?: string;
44
- thinking?: unknown;
45
- };
46
- }
47
- declare function createResponsesFetch(options: CreateResponsesFetchOptions): typeof fetch;
48
-
49
1
  /**
50
2
  * OpenAI Responses API type definitions (subset used by this library).
51
3
  * Only the fields relevant to request translation and event emission are typed.
@@ -240,6 +192,7 @@ interface ResponsesOutputFunctionCall {
240
192
  type: 'function_call' | 'local_shell_call' | string;
241
193
  status: 'completed' | 'in_progress';
242
194
  name?: string;
195
+ namespace?: string;
243
196
  arguments?: string;
244
197
  call_id?: string;
245
198
  thought_signature?: string;
@@ -295,6 +248,58 @@ interface ResponsesStreamEvent {
295
248
  [key: string]: unknown;
296
249
  }
297
250
 
251
+ type UpstreamFormat = 'anthropic' | 'openai-chat';
252
+ interface CacheStats {
253
+ cachedTokens: number;
254
+ cacheCreationTokens: number;
255
+ inputTokens: number;
256
+ outputTokens: number;
257
+ totalTokens: number;
258
+ }
259
+ interface CreateResponsesFetchOptions {
260
+ /** Upstream API format. If omitted, inferred from `baseUrl`. */
261
+ upstreamFormat?: UpstreamFormat;
262
+ /** Upstream endpoint URL. Required. */
263
+ baseUrl: string;
264
+ /** Override upstream API version header (Anthropic only). */
265
+ apiVersion?: string;
266
+ /** Replace the caller-provided `model` field before translation. */
267
+ model?: string;
268
+ /** Extra headers merged into every upstream call. */
269
+ defaultHeaders?: Record<string, string>;
270
+ /** Underlying fetch. Defaults to `globalThis.fetch`. */
271
+ fetch?: typeof fetch;
272
+ /** Non-/responses traffic forward target. Defaults to `options.fetch`. */
273
+ passthroughFetch?: typeof fetch;
274
+ /** Drop image/file parts from user messages (e.g. DeepSeek text-only models). */
275
+ dropImages?: boolean;
276
+ /** Drop tools from the request before translation. Return true to drop a tool.
277
+ * Use to reduce payload size when the upstream has a limit (e.g. DeepSeek ECONNRESET
278
+ * on 252 KB requests with 143 tools). Applied before namespace flattening. */
279
+ dropTools?: (tool: ResponsesTool) => boolean;
280
+ /** Fallback thought signature for Gemini OpenAI-compatible tool histories. */
281
+ fallbackThoughtSignature?: string;
282
+ /** Optional callback to receive cache statistics. */
283
+ onCacheStats?: (stats: CacheStats) => void;
284
+ /** Override reasoning_effort sent to the upstream model (OpenAI Chat / Anthropic). */
285
+ reasoning_effort?: string;
286
+ /** Override thinking configuration sent to the upstream model. */
287
+ thinking?: unknown;
288
+ /** Timeout in milliseconds for upstream requests. Defaults to no timeout. */
289
+ timeoutMs?: number;
290
+ /** Fallback upstream for requests where the last user message contains images. */
291
+ fallbackUpstream?: {
292
+ baseUrl: string;
293
+ upstreamFormat?: UpstreamFormat;
294
+ model?: string;
295
+ defaultHeaders?: Record<string, string>;
296
+ apiVersion?: string;
297
+ reasoning_effort?: string;
298
+ thinking?: unknown;
299
+ };
300
+ }
301
+ declare function createResponsesFetch(options: CreateResponsesFetchOptions): typeof fetch;
302
+
298
303
  /** Anthropic Messages API type definitions (subset). */
299
304
  interface AnthropicTextBlock {
300
305
  type: 'text';
@@ -640,6 +645,9 @@ interface TranslateResponseOptions {
640
645
  responseId?: string;
641
646
  createdAt?: number;
642
647
  model?: string;
648
+ /** Chat Completions tool list from the translated request — used to recover
649
+ * namespace when the upstream omits the "namespace." prefix in a tool call. */
650
+ requestTools?: unknown[];
643
651
  }
644
652
  /** Convert an OpenAI Chat response into a Responses-API response. */
645
653
  declare function translateResponse(body: OpenAiChatResponse, options?: TranslateResponseOptions): ResponsesResponse;
package/dist/index.d.ts CHANGED
@@ -1,51 +1,3 @@
1
- type UpstreamFormat = 'anthropic' | 'openai-chat';
2
- interface CacheStats {
3
- cachedTokens: number;
4
- cacheCreationTokens: number;
5
- inputTokens: number;
6
- outputTokens: number;
7
- totalTokens: number;
8
- }
9
- interface CreateResponsesFetchOptions {
10
- /** Upstream API format. If omitted, inferred from `baseUrl`. */
11
- upstreamFormat?: UpstreamFormat;
12
- /** Upstream endpoint URL. Required. */
13
- baseUrl: string;
14
- /** Override upstream API version header (Anthropic only). */
15
- apiVersion?: string;
16
- /** Replace the caller-provided `model` field before translation. */
17
- model?: string;
18
- /** Extra headers merged into every upstream call. */
19
- defaultHeaders?: Record<string, string>;
20
- /** Underlying fetch. Defaults to `globalThis.fetch`. */
21
- fetch?: typeof fetch;
22
- /** Non-/responses traffic forward target. Defaults to `options.fetch`. */
23
- passthroughFetch?: typeof fetch;
24
- /** Drop image/file parts from user messages (e.g. DeepSeek text-only models). */
25
- dropImages?: boolean;
26
- /** Fallback thought signature for Gemini OpenAI-compatible tool histories. */
27
- fallbackThoughtSignature?: string;
28
- /** Optional callback to receive cache statistics. */
29
- onCacheStats?: (stats: CacheStats) => void;
30
- /** Override reasoning_effort sent to the upstream model (OpenAI Chat / Anthropic). */
31
- reasoning_effort?: string;
32
- /** Override thinking configuration sent to the upstream model. */
33
- thinking?: unknown;
34
- /** Timeout in milliseconds for upstream requests. Defaults to no timeout. */
35
- timeoutMs?: number;
36
- /** Fallback upstream for requests where the last user message contains images. */
37
- fallbackUpstream?: {
38
- baseUrl: string;
39
- upstreamFormat?: UpstreamFormat;
40
- model?: string;
41
- defaultHeaders?: Record<string, string>;
42
- apiVersion?: string;
43
- reasoning_effort?: string;
44
- thinking?: unknown;
45
- };
46
- }
47
- declare function createResponsesFetch(options: CreateResponsesFetchOptions): typeof fetch;
48
-
49
1
  /**
50
2
  * OpenAI Responses API type definitions (subset used by this library).
51
3
  * Only the fields relevant to request translation and event emission are typed.
@@ -240,6 +192,7 @@ interface ResponsesOutputFunctionCall {
240
192
  type: 'function_call' | 'local_shell_call' | string;
241
193
  status: 'completed' | 'in_progress';
242
194
  name?: string;
195
+ namespace?: string;
243
196
  arguments?: string;
244
197
  call_id?: string;
245
198
  thought_signature?: string;
@@ -295,6 +248,58 @@ interface ResponsesStreamEvent {
295
248
  [key: string]: unknown;
296
249
  }
297
250
 
251
+ type UpstreamFormat = 'anthropic' | 'openai-chat';
252
+ interface CacheStats {
253
+ cachedTokens: number;
254
+ cacheCreationTokens: number;
255
+ inputTokens: number;
256
+ outputTokens: number;
257
+ totalTokens: number;
258
+ }
259
+ interface CreateResponsesFetchOptions {
260
+ /** Upstream API format. If omitted, inferred from `baseUrl`. */
261
+ upstreamFormat?: UpstreamFormat;
262
+ /** Upstream endpoint URL. Required. */
263
+ baseUrl: string;
264
+ /** Override upstream API version header (Anthropic only). */
265
+ apiVersion?: string;
266
+ /** Replace the caller-provided `model` field before translation. */
267
+ model?: string;
268
+ /** Extra headers merged into every upstream call. */
269
+ defaultHeaders?: Record<string, string>;
270
+ /** Underlying fetch. Defaults to `globalThis.fetch`. */
271
+ fetch?: typeof fetch;
272
+ /** Non-/responses traffic forward target. Defaults to `options.fetch`. */
273
+ passthroughFetch?: typeof fetch;
274
+ /** Drop image/file parts from user messages (e.g. DeepSeek text-only models). */
275
+ dropImages?: boolean;
276
+ /** Drop tools from the request before translation. Return true to drop a tool.
277
+ * Use to reduce payload size when the upstream has a limit (e.g. DeepSeek ECONNRESET
278
+ * on 252 KB requests with 143 tools). Applied before namespace flattening. */
279
+ dropTools?: (tool: ResponsesTool) => boolean;
280
+ /** Fallback thought signature for Gemini OpenAI-compatible tool histories. */
281
+ fallbackThoughtSignature?: string;
282
+ /** Optional callback to receive cache statistics. */
283
+ onCacheStats?: (stats: CacheStats) => void;
284
+ /** Override reasoning_effort sent to the upstream model (OpenAI Chat / Anthropic). */
285
+ reasoning_effort?: string;
286
+ /** Override thinking configuration sent to the upstream model. */
287
+ thinking?: unknown;
288
+ /** Timeout in milliseconds for upstream requests. Defaults to no timeout. */
289
+ timeoutMs?: number;
290
+ /** Fallback upstream for requests where the last user message contains images. */
291
+ fallbackUpstream?: {
292
+ baseUrl: string;
293
+ upstreamFormat?: UpstreamFormat;
294
+ model?: string;
295
+ defaultHeaders?: Record<string, string>;
296
+ apiVersion?: string;
297
+ reasoning_effort?: string;
298
+ thinking?: unknown;
299
+ };
300
+ }
301
+ declare function createResponsesFetch(options: CreateResponsesFetchOptions): typeof fetch;
302
+
298
303
  /** Anthropic Messages API type definitions (subset). */
299
304
  interface AnthropicTextBlock {
300
305
  type: 'text';
@@ -640,6 +645,9 @@ interface TranslateResponseOptions {
640
645
  responseId?: string;
641
646
  createdAt?: number;
642
647
  model?: string;
648
+ /** Chat Completions tool list from the translated request — used to recover
649
+ * namespace when the upstream omits the "namespace." prefix in a tool call. */
650
+ requestTools?: unknown[];
643
651
  }
644
652
  /** Convert an OpenAI Chat response into a Responses-API response. */
645
653
  declare function translateResponse(body: OpenAiChatResponse, options?: TranslateResponseOptions): ResponsesResponse;