@opencow-ai/opencow-agent-sdk 0.4.12 → 0.4.14
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/cli.mjs +427 -148
- package/dist/client.js +417 -119
- package/dist/controller/compact/autoCompact.d.ts +4 -0
- package/dist/controller/loop.d.ts +1 -0
- package/dist/entrypoints/sdk/logTypes.d.ts +33 -2
- package/dist/entrypoints/sdk/runtimeTypes.d.ts +39 -14
- package/dist/providers/codex/shim.d.ts +3 -3
- package/dist/providers/openai/shim.d.ts +12 -20
- package/dist/providers/provider.d.ts +1 -1
- package/dist/providers/shared/config.d.ts +10 -7
- package/dist/providers/shared/httpObservability.d.ts +5 -0
- package/dist/providers/shared/model/maxTokens.d.ts +1 -0
- package/dist/providers/shared/requestSideChannels.d.ts +1 -0
- package/dist/providers/shared/routing.d.ts +9 -10
- package/dist/query.d.ts +1 -0
- package/dist/sdk.js +417 -119
- package/dist/session/sideQuery.d.ts +1 -1
- package/dist/types/toolRuntime.d.ts +1 -0
- package/package.json +1 -1
|
@@ -7,6 +7,7 @@ import { trySessionMemoryCompaction } from './sessionMemoryCompact.js';
|
|
|
7
7
|
export declare function getEffectiveContextWindowSize(model: string, opts?: {
|
|
8
8
|
contextWindow?: number;
|
|
9
9
|
maxOutputTokens?: number;
|
|
10
|
+
maxOutputTokensLimit?: number;
|
|
10
11
|
}): number;
|
|
11
12
|
export type AutoCompactTrackingState = {
|
|
12
13
|
compacted: boolean;
|
|
@@ -21,10 +22,12 @@ export declare const MANUAL_COMPACT_BUFFER_TOKENS = 3000;
|
|
|
21
22
|
export declare function getAutoCompactThreshold(model: string, opts?: {
|
|
22
23
|
contextWindow?: number;
|
|
23
24
|
maxOutputTokens?: number;
|
|
25
|
+
maxOutputTokensLimit?: number;
|
|
24
26
|
}): number;
|
|
25
27
|
export declare function calculateTokenWarningState(tokenUsage: number, model: string, opts?: {
|
|
26
28
|
contextWindow?: number;
|
|
27
29
|
maxOutputTokens?: number;
|
|
30
|
+
maxOutputTokensLimit?: number;
|
|
28
31
|
}): {
|
|
29
32
|
percentLeft: number;
|
|
30
33
|
isAboveWarningThreshold: boolean;
|
|
@@ -36,6 +39,7 @@ export declare function isAutoCompactEnabled(): boolean;
|
|
|
36
39
|
export declare function shouldAutoCompact(messages: Message[], model: string, querySource?: QuerySource, snipTokensFreed?: number, opts?: {
|
|
37
40
|
contextWindow?: number;
|
|
38
41
|
maxOutputTokens?: number;
|
|
42
|
+
maxOutputTokensLimit?: number;
|
|
39
43
|
}): Promise<boolean>;
|
|
40
44
|
export declare function autoCompactIfNeeded(messages: Message[], toolUseContext: ToolRuntimeContext, cacheSafeParams: CacheSafeParams, querySource?: QuerySource, tracking?: AutoCompactTrackingState, snipTokensFreed?: number): Promise<{
|
|
41
45
|
wasCompacted: boolean;
|
|
@@ -32,6 +32,7 @@ export type Options = {
|
|
|
32
32
|
isNonInteractiveSession: boolean;
|
|
33
33
|
extraToolSchemas?: BetaToolUnion[];
|
|
34
34
|
maxOutputTokensOverride?: number;
|
|
35
|
+
maxOutputTokensLimitOverride?: number;
|
|
35
36
|
fallbackModel?: string;
|
|
36
37
|
onStreamingFallback?: () => void;
|
|
37
38
|
querySource: QuerySource;
|
|
@@ -112,8 +112,10 @@ export interface SdkDiagnosticEvent {
|
|
|
112
112
|
* across all providers).
|
|
113
113
|
*
|
|
114
114
|
* `source` mirrors the `source` argument that `buildFetch` already
|
|
115
|
-
* accepts (e.g. `'main_loop'`, `'
|
|
116
|
-
* distinguish main-loop API calls from auxiliary
|
|
115
|
+
* accepts (e.g. `'main_loop'`, `'count_tokens'`, `'agent:custom'`) —
|
|
116
|
+
* lets the host distinguish main-loop API calls from auxiliary and
|
|
117
|
+
* subagent ones. `endpoint` is a normalized route family such as
|
|
118
|
+
* `'messages'`, `'count_tokens'`, or `'responses'`.
|
|
117
119
|
*
|
|
118
120
|
* @stable
|
|
119
121
|
*/
|
|
@@ -123,18 +125,47 @@ export type SdkHttpEvent = {
|
|
|
123
125
|
readonly method: string;
|
|
124
126
|
readonly url: string;
|
|
125
127
|
readonly source: string | undefined;
|
|
128
|
+
readonly endpoint?: string;
|
|
129
|
+
readonly attempt?: number;
|
|
130
|
+
readonly maxAttempts?: number;
|
|
126
131
|
readonly timestamp: number;
|
|
127
132
|
} | {
|
|
128
133
|
readonly type: 'response_start';
|
|
129
134
|
readonly requestId: string;
|
|
130
135
|
readonly status: number;
|
|
131
136
|
readonly durationMs: number;
|
|
137
|
+
readonly source?: string;
|
|
138
|
+
readonly endpoint?: string;
|
|
139
|
+
readonly attempt?: number;
|
|
140
|
+
readonly maxAttempts?: number;
|
|
141
|
+
readonly willRetry?: boolean;
|
|
142
|
+
readonly retryDelayMs?: number;
|
|
143
|
+
readonly failureReason?: string;
|
|
132
144
|
readonly timestamp: number;
|
|
133
145
|
} | {
|
|
134
146
|
readonly type: 'error';
|
|
135
147
|
readonly requestId: string;
|
|
136
148
|
readonly error: Error;
|
|
137
149
|
readonly durationMs: number;
|
|
150
|
+
readonly source?: string;
|
|
151
|
+
readonly endpoint?: string;
|
|
152
|
+
readonly attempt?: number;
|
|
153
|
+
readonly maxAttempts?: number;
|
|
154
|
+
readonly willRetry?: boolean;
|
|
155
|
+
readonly retryDelayMs?: number;
|
|
156
|
+
readonly failureReason?: string;
|
|
157
|
+
readonly status?: number;
|
|
158
|
+
readonly timestamp: number;
|
|
159
|
+
} | {
|
|
160
|
+
readonly type: 'retry';
|
|
161
|
+
readonly requestId?: string;
|
|
162
|
+
readonly source?: string;
|
|
163
|
+
readonly endpoint?: string;
|
|
164
|
+
readonly attempt: number;
|
|
165
|
+
readonly maxAttempts?: number;
|
|
166
|
+
readonly retryDelayMs: number;
|
|
167
|
+
readonly status?: number;
|
|
168
|
+
readonly failureReason: string;
|
|
138
169
|
readonly timestamp: number;
|
|
139
170
|
};
|
|
140
171
|
/**
|
|
@@ -6,6 +6,7 @@ import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
|
6
6
|
import type { CallToolResult, ToolAnnotations } from '@modelcontextprotocol/sdk/types.js';
|
|
7
7
|
import type { z } from 'zod/v4';
|
|
8
8
|
import type { ExitReason, HookEvent, HookInput, SDKMessage, SDKResultMessage, SDKSessionInfo, SDKUserMessage, SyncHookJSONOutput } from './coreTypes.js';
|
|
9
|
+
export type { SDKMessage, SDKUserMessage } from './coreTypes.js';
|
|
9
10
|
export type EffortLevel = 'low' | 'medium' | 'high' | 'xhigh' | 'max';
|
|
10
11
|
export type AnyZodRawShape = z.ZodRawShape;
|
|
11
12
|
export type InferShape<Shape extends AnyZodRawShape = AnyZodRawShape> = z.infer<z.ZodObject<Shape>>;
|
|
@@ -125,7 +126,7 @@ export type SettingSource = 'user' | 'project' | 'local';
|
|
|
125
126
|
import type { SdkTool } from '../../capabilities/SdkTool.js';
|
|
126
127
|
import type { LayoutProfile } from '../../session/layout/LayoutProfile.js';
|
|
127
128
|
import type { SdkRule } from '../../session/rules/SdkRule.js';
|
|
128
|
-
import type { ProviderTransport, DeprecatedProviderTransportName } from '../../providers/shared/config.js';
|
|
129
|
+
import type { ProviderTransport, DeprecatedProviderTransportName, ReasoningEffort } from '../../providers/shared/config.js';
|
|
129
130
|
import type { FileHistoryChangeListener, FileHistoryState } from '../../session/fileHistory.js';
|
|
130
131
|
export type Options = {
|
|
131
132
|
cwd?: string;
|
|
@@ -148,6 +149,13 @@ export type Options = {
|
|
|
148
149
|
* values are clamped + warn-logged, never thrown.
|
|
149
150
|
*/
|
|
150
151
|
maxOutputTokens?: number;
|
|
152
|
+
/**
|
|
153
|
+
* Optional host-authoritative upper bound for `maxOutputTokens`. Use this
|
|
154
|
+
* when the selected model is a custom gateway/deployment id whose native
|
|
155
|
+
* output cap is known by the host model catalog but not by the SDK's built-in
|
|
156
|
+
* model table. When unset, SDK built-in per-model limits are used.
|
|
157
|
+
*/
|
|
158
|
+
maxOutputTokensLimit?: number;
|
|
151
159
|
/**
|
|
152
160
|
* Per-session context window override (input tokens). Used by autoCompact
|
|
153
161
|
* threshold computation and any other code path that calls
|
|
@@ -161,6 +169,26 @@ export type Options = {
|
|
|
161
169
|
* Values < 10_000 or > 5_000_000 are dropped + warn-logged (table fallback).
|
|
162
170
|
*/
|
|
163
171
|
contextWindow?: number;
|
|
172
|
+
/**
|
|
173
|
+
* Host-provided default reasoning effort for the selected model. This is
|
|
174
|
+
* protocol-neutral: providers serialize it into their native request shape,
|
|
175
|
+
* such as OpenAI Chat Completions `reasoning_effort` or OpenAI Responses
|
|
176
|
+
* `reasoning.effort`.
|
|
177
|
+
*
|
|
178
|
+
* Leave unset to preserve SDK/model defaults. Pass `null` on a per-turn
|
|
179
|
+
* override to clear inherited or descriptor defaults. Hosts with an
|
|
180
|
+
* authoritative model catalog should pass that model's default here, and
|
|
181
|
+
* user-selected effort can override the catalog default before it reaches
|
|
182
|
+
* the SDK.
|
|
183
|
+
*/
|
|
184
|
+
reasoningEffort?: ReasoningEffort | null;
|
|
185
|
+
/**
|
|
186
|
+
* Low-level request-body extension. Snake-case mirrors OpenAI-style clients
|
|
187
|
+
* that expose an `extra_body` escape hatch. Provider shims decide how to
|
|
188
|
+
* merge it into their wire body; the SDK does not validate provider-specific
|
|
189
|
+
* nested schemas here.
|
|
190
|
+
*/
|
|
191
|
+
extra_body?: ExtraBody;
|
|
164
192
|
/**
|
|
165
193
|
* 本回合手动压缩上下文(对应 host 的 /compact)。设置后 SDK 复用 auto-compact
|
|
166
194
|
* 机制(isAutoCompact=false + 这些指令)压缩当前消息、发出 system/compact_boundary,
|
|
@@ -302,10 +330,9 @@ export type Options = {
|
|
|
302
330
|
* Explicit wire-level transport selection. When provided, overrides the
|
|
303
331
|
* default base-URL / model-alias sniff in `resolveProviderTransport`.
|
|
304
332
|
*
|
|
305
|
-
* Hosts that proxy upstream providers through their own backend
|
|
306
|
-
*
|
|
307
|
-
*
|
|
308
|
-
* SDK's built-in Codex base URL detector.
|
|
333
|
+
* Hosts that proxy upstream providers through their own backend MUST set
|
|
334
|
+
* this explicitly because the proxy URL usually does not match the SDK's
|
|
335
|
+
* built-in provider detectors.
|
|
309
336
|
*
|
|
310
337
|
* - `'auto'` (default) — sniff baseUrl then model alias (legacy behavior)
|
|
311
338
|
* - `'chat_completions'` — POST {baseUrl}/chat/completions (OpenAI Chat
|
|
@@ -320,12 +347,9 @@ export type Options = {
|
|
|
320
347
|
/**
|
|
321
348
|
* Host model → provider-route catalog, keyed by model id. Consulted AFTER
|
|
322
349
|
* subagent model resolution (tier aliases / Agent tool `model` param), so
|
|
323
|
-
* a
|
|
324
|
-
*
|
|
325
|
-
*
|
|
326
|
-
* Models absent from the catalog use the session provider config as
|
|
327
|
-
* before. Entries may carry `providerSpecific.openaiResponses` extras
|
|
328
|
-
* applied when that model's request uses the openai_responses wire.
|
|
350
|
+
* a host can override a subagent model's baseURL/key/transport/reasoning
|
|
351
|
+
* defaults without changing the main session provider. Models absent from
|
|
352
|
+
* the catalog use the session provider config as before.
|
|
329
353
|
*/
|
|
330
354
|
modelProviders?: ModelProviders;
|
|
331
355
|
/**
|
|
@@ -341,8 +365,8 @@ export type Options = {
|
|
|
341
365
|
* - `metadata` — string-keyed map attached to the request
|
|
342
366
|
* - `responseFormat` — JSON schema enforcement
|
|
343
367
|
* - `reasoning` — reasoning configuration override. `effort` controls
|
|
344
|
-
* how hard the model thinks (minimal/low/medium/high;
|
|
345
|
-
* specific). `summary` controls whether human-readable reasoning
|
|
368
|
+
* how hard the model thinks (none/minimal/low/medium/high/xhigh;
|
|
369
|
+
* default model-specific). `summary` controls whether human-readable reasoning
|
|
346
370
|
* summary is returned in the SSE stream ('auto'/'concise'/'detailed';
|
|
347
371
|
* when unset, upstream returns only encrypted reasoning items —
|
|
348
372
|
* useful for state preservation but invisible in UI). Merges with
|
|
@@ -357,7 +381,7 @@ export type Options = {
|
|
|
357
381
|
metadata?: Record<string, string>;
|
|
358
382
|
responseFormat?: unknown;
|
|
359
383
|
reasoning?: {
|
|
360
|
-
effort?:
|
|
384
|
+
effort?: ReasoningEffort;
|
|
361
385
|
summary?: 'auto' | 'concise' | 'detailed' | null;
|
|
362
386
|
};
|
|
363
387
|
};
|
|
@@ -453,6 +477,7 @@ export type InternalOptions = Options;
|
|
|
453
477
|
export type SessionMutationOptions = {
|
|
454
478
|
dir?: string;
|
|
455
479
|
};
|
|
480
|
+
export type ExtraBody = Record<string, unknown>;
|
|
456
481
|
export type GetSessionInfoOptions = SessionMutationOptions;
|
|
457
482
|
export type ListSessionsOptions = SessionMutationOptions & {
|
|
458
483
|
limit?: number;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ResolvedCodexCredentials, ResolvedProviderRequest } from '../../providers/shared/config.js';
|
|
1
|
+
import type { ResolvedCodexCredentials, ResolvedProviderRequest, ReasoningEffort } from '../../providers/shared/config.js';
|
|
2
2
|
export interface AnthropicUsage {
|
|
3
3
|
input_tokens: number;
|
|
4
4
|
output_tokens: number;
|
|
@@ -53,7 +53,7 @@ export interface ResponsesProviderSpecific {
|
|
|
53
53
|
* reasoning (Codex aliases or `?reasoning=high` model suffix) per-key.
|
|
54
54
|
*
|
|
55
55
|
* - `effort`: how hard the model thinks. Without it, model-specific
|
|
56
|
-
* default applies
|
|
56
|
+
* default applies.
|
|
57
57
|
* - `summary`: whether human-readable reasoning summary is streamed via
|
|
58
58
|
* `response.reasoning_summary_text.delta` events. WITHOUT this set,
|
|
59
59
|
* the upstream returns only encrypted_content reasoning items —
|
|
@@ -62,7 +62,7 @@ export interface ResponsesProviderSpecific {
|
|
|
62
62
|
* chain-of-thought text.
|
|
63
63
|
*/
|
|
64
64
|
reasoning?: {
|
|
65
|
-
effort?:
|
|
65
|
+
effort?: ReasoningEffort;
|
|
66
66
|
summary?: 'auto' | 'concise' | 'detailed' | null;
|
|
67
67
|
};
|
|
68
68
|
}
|
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
*/
|
|
23
23
|
import type { ProviderOverride } from '../shared/routing.js';
|
|
24
24
|
import { type AnthropicStreamEvent, type AnthropicUsage, type ShimCreateParams } from '../../providers/codex/shim.js';
|
|
25
|
+
import { type ReasoningEffort } from '../../providers/shared/config.js';
|
|
25
26
|
interface OpenAIMessage {
|
|
26
27
|
role: 'system' | 'user' | 'assistant' | 'tool';
|
|
27
28
|
content?: string | null | Array<{
|
|
@@ -61,7 +62,9 @@ export declare function convertMessages(messages: Array<{
|
|
|
61
62
|
content?: unknown;
|
|
62
63
|
};
|
|
63
64
|
content?: unknown;
|
|
64
|
-
}>, system: unknown
|
|
65
|
+
}>, system: unknown, options?: {
|
|
66
|
+
replayReasoningContent?: boolean;
|
|
67
|
+
}): OpenAIMessage[];
|
|
65
68
|
export declare function convertTools(tools: Array<{
|
|
66
69
|
name: string;
|
|
67
70
|
description?: string;
|
|
@@ -98,24 +101,12 @@ export declare function openaiUsageToAnthropicUsage(usage: {
|
|
|
98
101
|
* responsibilities.
|
|
99
102
|
*/
|
|
100
103
|
/**
|
|
101
|
-
* Convert an SDK
|
|
102
|
-
*
|
|
103
|
-
*
|
|
104
|
-
*
|
|
105
|
-
* - SDK vocab: `'low' | 'medium' | 'high' | 'xhigh'`
|
|
106
|
-
* (`'xhigh'` is the SDK-internal "Max" tier,
|
|
107
|
-
* surfaced as "max" in the CLI — see
|
|
108
|
-
* `lib/effort.ts`.)
|
|
109
|
-
* - OpenAI chat wire vocab: `'low' | 'medium' | 'high'`
|
|
110
|
-
* (Spec: platform.openai.com/docs/api-reference/chat/create)
|
|
111
|
-
*
|
|
112
|
-
* `'xhigh'` is clamped down to `'high'` rather than rejected: the SDK
|
|
113
|
-
* semantic is "as much reasoning as the provider will give" and `'high'`
|
|
114
|
-
* is the upper bound on this wire. Sending `'xhigh'` raw would 400 on
|
|
115
|
-
* strict proxies. The Responses API (codex) has its own serialisation
|
|
116
|
-
* and does NOT go through this function — see `codex/shim.ts`.
|
|
104
|
+
* Convert an SDK reasoning-effort tier to the value accepted by OpenAI Chat
|
|
105
|
+
* Completions `reasoning_effort`. The current OpenAI wire accepts the same
|
|
106
|
+
* vocabulary as the SDK; model-specific legality is enforced by the host
|
|
107
|
+
* catalog / upstream provider, not by this transport boundary.
|
|
117
108
|
*/
|
|
118
|
-
export declare function toOpenAIChatReasoningEffort(effort:
|
|
109
|
+
export declare function toOpenAIChatReasoningEffort(effort: ReasoningEffort): ReasoningEffort;
|
|
119
110
|
export declare function buildOpenAIRequestBody(params: ShimCreateParams, ctx: {
|
|
120
111
|
resolvedModel: string;
|
|
121
112
|
baseUrl: string;
|
|
@@ -133,7 +124,7 @@ export declare function buildOpenAIRequestBody(params: ShimCreateParams, ctx: {
|
|
|
133
124
|
* transports serialise differently on the wire.
|
|
134
125
|
*/
|
|
135
126
|
reasoning?: {
|
|
136
|
-
effort:
|
|
127
|
+
effort: ReasoningEffort;
|
|
137
128
|
};
|
|
138
129
|
}): Record<string, unknown>;
|
|
139
130
|
export declare function openaiStreamToAnthropic(response: Response, model: string): AsyncGenerator<AnthropicStreamEvent>;
|
|
@@ -209,7 +200,8 @@ export declare function createOpenAIShimClient(options: {
|
|
|
209
200
|
defaultHeaders?: Record<string, string>;
|
|
210
201
|
maxRetries?: number;
|
|
211
202
|
timeout?: number;
|
|
212
|
-
reasoningEffort?:
|
|
203
|
+
reasoningEffort?: ReasoningEffort;
|
|
213
204
|
providerOverride?: ProviderOverride;
|
|
205
|
+
source?: string;
|
|
214
206
|
}): unknown;
|
|
215
207
|
export {};
|
|
@@ -86,7 +86,7 @@ export interface Provider {
|
|
|
86
86
|
/**
|
|
87
87
|
* Construct the HTTP-level client that `services/api/claude.ts`
|
|
88
88
|
* drives in its request pipeline. The returned object exposes the
|
|
89
|
-
* Anthropic SDK's `
|
|
89
|
+
* Anthropic SDK's `messages.create(...)` surface so
|
|
90
90
|
* `withRetry` and the main agent loop consume a uniform shape
|
|
91
91
|
* regardless of Provider family.
|
|
92
92
|
*
|
|
@@ -2,7 +2,7 @@ export declare const DEFAULT_OPENAI_BASE_URL = "https://api.openai.com/v1";
|
|
|
2
2
|
export declare const DEFAULT_CODEX_BASE_URL = "https://chatgpt.com/backend-api/codex";
|
|
3
3
|
/** Default GitHub Models API model when user selects copilot / github:copilot */
|
|
4
4
|
export declare const DEFAULT_GITHUB_MODELS_API_MODEL = "openai/gpt-4.1";
|
|
5
|
-
type ReasoningEffort = 'low' | 'medium' | 'high' | 'xhigh';
|
|
5
|
+
export type ReasoningEffort = 'none' | 'minimal' | 'low' | 'medium' | 'high' | 'xhigh';
|
|
6
6
|
/**
|
|
7
7
|
* Wire-level transport selected by `resolveProviderTransport`.
|
|
8
8
|
*
|
|
@@ -16,6 +16,7 @@ type ReasoningEffort = 'low' | 'medium' | 'high' | 'xhigh';
|
|
|
16
16
|
* wire format. Renamed from `'codex_responses'` in 0.2.0 (alias retained
|
|
17
17
|
* one version). ChatGPT-Codex vendor identity (isCodexBaseUrl /
|
|
18
18
|
* CODEX_ALIAS_MODELS / DEFAULT_CODEX_BASE_URL) is orthogonal and preserved.
|
|
19
|
+
*
|
|
19
20
|
*/
|
|
20
21
|
export type ProviderTransport = 'chat_completions' | 'openai_responses';
|
|
21
22
|
/**
|
|
@@ -25,15 +26,15 @@ export type ProviderTransport = 'chat_completions' | 'openai_responses';
|
|
|
25
26
|
export type DeprecatedProviderTransportName = 'codex_responses';
|
|
26
27
|
/**
|
|
27
28
|
* ALS-scoped env-var keys used to forward public `Options.transport` /
|
|
28
|
-
* `Options.providerSpecific.openaiResponses`
|
|
29
|
-
* provider-side resolvers
|
|
30
|
-
*
|
|
29
|
+
* `Options.providerSpecific.openaiResponses` / `Options.extra_body` from
|
|
30
|
+
* `runSdkQueryRuntime` to provider-side resolvers/shims without threading new
|
|
31
|
+
* parameters through the deep call chain.
|
|
31
32
|
*
|
|
32
33
|
* Pattern: identical to how `OPENAI_BASE_URL` is consumed via
|
|
33
34
|
* `getQueryEnvVar` from inside `resolveProviderTransport`. The double
|
|
34
35
|
* underscore prefix marks them as SDK-internal — hosts MUST NOT set these
|
|
35
36
|
* directly in `Options.env`; use the typed `Options.transport` /
|
|
36
|
-
* `Options.providerSpecific` fields instead.
|
|
37
|
+
* `Options.providerSpecific` / `Options.extra_body` fields instead.
|
|
37
38
|
*
|
|
38
39
|
* Why env-injection (vs signature plumbing): the call chain
|
|
39
40
|
* `runSdkQueryRuntime` → `QueryEngine.ask` → `getNormalizedClient` →
|
|
@@ -45,7 +46,10 @@ export type DeprecatedProviderTransportName = 'codex_responses';
|
|
|
45
46
|
* CLAUDE_CODE_USE_GITHUB, OPENCOW_DEBUG_REASONING).
|
|
46
47
|
*/
|
|
47
48
|
export declare const QUERY_ENV_KEY_TRANSPORT_OVERRIDE = "__OPENCOW_TRANSPORT_OVERRIDE";
|
|
49
|
+
export declare const QUERY_ENV_KEY_REASONING_EFFORT_OVERRIDE = "__OPENCOW_REASONING_EFFORT_OVERRIDE";
|
|
50
|
+
export declare const QUERY_ENV_VALUE_REASONING_EFFORT_CLEAR = "__OPENCOW_CLEAR_REASONING_EFFORT__";
|
|
48
51
|
export declare const QUERY_ENV_KEY_PROVIDER_SPECIFIC_OPENAI_RESPONSES = "__OPENCOW_PROVIDER_SPECIFIC_OPENAI_RESPONSES";
|
|
52
|
+
export declare const QUERY_ENV_KEY_EXTRA_BODY = "__OPENCOW_EXTRA_BODY";
|
|
49
53
|
export type ResolvedProviderRequest = {
|
|
50
54
|
transport: ProviderTransport;
|
|
51
55
|
requestedModel: string;
|
|
@@ -139,7 +143,7 @@ export declare function resolveProviderRequest(options?: {
|
|
|
139
143
|
model?: string;
|
|
140
144
|
baseUrl?: string;
|
|
141
145
|
fallbackModel?: string;
|
|
142
|
-
reasoningEffortOverride?: ReasoningEffort;
|
|
146
|
+
reasoningEffortOverride?: ReasoningEffort | null;
|
|
143
147
|
/**
|
|
144
148
|
* Optional explicit transport override forwarded to
|
|
145
149
|
* `resolveProviderTransport`. When unset, callers can still rely on the
|
|
@@ -181,4 +185,3 @@ export declare function parseChatgptAccountId(token: string | undefined): string
|
|
|
181
185
|
export declare function resolveOpenAIResponsesCredentials(): ResolvedCodexCredentials;
|
|
182
186
|
export declare function resolveCodexApiCredentials(env?: NodeJS.ProcessEnv): ResolvedCodexCredentials;
|
|
183
187
|
export declare function getReasoningEffortForModel(model: string): ReasoningEffort | undefined;
|
|
184
|
-
export {};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { SdkHttpEvent } from '../../entrypoints/sdk/logTypes.js';
|
|
2
|
+
export declare function classifyModelHttpEndpoint(url: string): string;
|
|
3
|
+
export declare function errorToFailureReason(error: unknown): string;
|
|
4
|
+
export declare function responseBodyToFailureReason(status: number, body: string): string;
|
|
5
|
+
export declare function emitSdkHttp(event: SdkHttpEvent): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function mergeOpenAICompatibleExtraBodyParams(body: Record<string, unknown>, params: Record<string, unknown>): void;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { SettingsJson } from '../../session/settings/types.js';
|
|
2
|
-
import type { ProviderTransport } from './config.js';
|
|
2
|
+
import type { ProviderTransport, ReasoningEffort } from './config.js';
|
|
3
3
|
/**
|
|
4
4
|
* Provider override resolved for a specific agent/model.
|
|
5
5
|
* When present, the API client uses these instead of the session-global
|
|
@@ -8,19 +8,18 @@ import type { ProviderTransport } from './config.js';
|
|
|
8
8
|
export interface ProviderOverride {
|
|
9
9
|
/** Model name to send to the API (e.g. "deepseek-chat", "gpt-4o") */
|
|
10
10
|
model: string;
|
|
11
|
-
/** Base URL. Optional — falls back to the session's
|
|
11
|
+
/** Base URL. Optional — falls back to the session's provider env. */
|
|
12
12
|
baseURL?: string;
|
|
13
13
|
/** API key. Optional — falls back to the session's env credential chain. */
|
|
14
14
|
apiKey?: string;
|
|
15
15
|
/**
|
|
16
16
|
* Wire transport for this override. Without it the session-level
|
|
17
|
-
* transport/sniff applies
|
|
18
|
-
*
|
|
19
|
-
* than the main session (chat_completions) hits the wrong endpoint and
|
|
20
|
-
* 404s. 'anthropic' routes to the native Anthropic client instead of the
|
|
21
|
-
* OpenAI shim.
|
|
17
|
+
* transport/sniff applies. 'anthropic' routes to the native Anthropic
|
|
18
|
+
* client; other values route to their matching shim.
|
|
22
19
|
*/
|
|
23
20
|
transport?: ProviderTransport | 'anthropic';
|
|
21
|
+
/** Default reasoning effort for this model route; null clears session default. */
|
|
22
|
+
reasoningEffort?: ReasoningEffort | null;
|
|
24
23
|
/** Per-wire extras (e.g. openai-responses reasoning summary config). */
|
|
25
24
|
providerSpecific?: {
|
|
26
25
|
openaiResponses?: Record<string, unknown>;
|
|
@@ -30,9 +29,9 @@ export interface ProviderOverride {
|
|
|
30
29
|
* Host-supplied model → provider-route catalog (`Options.modelProviders`).
|
|
31
30
|
* Key is the model id as it appears after subagent model resolution (tier
|
|
32
31
|
* env values / Agent tool `model` param). The host owns the model catalog
|
|
33
|
-
* (which
|
|
34
|
-
* resolving a subagent's model so any resolution path — tier alias,
|
|
35
|
-
* model param, inherit —
|
|
32
|
+
* (which endpoint/defaults each model should use); the SDK consults this
|
|
33
|
+
* AFTER resolving a subagent's model so any resolution path — tier alias,
|
|
34
|
+
* explicit model param, inherit — can land on the right provider config.
|
|
36
35
|
*/
|
|
37
36
|
export type ModelProviderConfig = Omit<ProviderOverride, 'model'>;
|
|
38
37
|
export type ModelProviders = Record<string, ModelProviderConfig>;
|
package/dist/query.d.ts
CHANGED