@cleocode/contracts 2026.5.66 → 2026.5.67
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.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/llm/interfaces.d.ts +476 -0
- package/dist/llm/interfaces.d.ts.map +1 -0
- package/dist/llm/interfaces.js +24 -0
- package/dist/llm/interfaces.js.map +1 -0
- package/dist/llm/normalized-response.d.ts +130 -4
- package/dist/llm/normalized-response.d.ts.map +1 -1
- package/dist/llm/normalized-response.js +2 -0
- package/dist/llm/normalized-response.js.map +1 -1
- package/dist/llm/provider-id.d.ts +47 -0
- package/dist/llm/provider-id.d.ts.map +1 -0
- package/dist/llm/provider-id.js +13 -0
- package/dist/llm/provider-id.js.map +1 -0
- package/dist/llm/provider-profile.d.ts +52 -0
- package/dist/llm/provider-profile.d.ts.map +1 -1
- package/dist/llm/resolved-credential.d.ts +61 -0
- package/dist/llm/resolved-credential.d.ts.map +1 -0
- package/dist/llm/resolved-credential.js +14 -0
- package/dist/llm/resolved-credential.js.map +1 -0
- package/dist/operations/llm.d.ts +14 -2
- package/dist/operations/llm.d.ts.map +1 -1
- package/dist/operations/llm.js.map +1 -1
- package/package.json +2 -2
- package/src/index.ts +21 -0
- package/src/llm/interfaces.ts +538 -0
- package/src/llm/normalized-response.ts +132 -4
- package/src/llm/provider-id.ts +63 -0
- package/src/llm/provider-profile.ts +66 -0
- package/src/llm/resolved-credential.ts +62 -0
- package/src/operations/llm.ts +15 -2
|
@@ -11,10 +11,14 @@
|
|
|
11
11
|
*
|
|
12
12
|
* @module llm/normalized-response
|
|
13
13
|
* @task T9263
|
|
14
|
+
* @task T9282 (W0c — Phase 4 multimodal + stream extensions)
|
|
14
15
|
* @epic T-LLM-CRED-CENTRALIZATION
|
|
16
|
+
* @see ADR-072 §LlmTransport — pure wire level
|
|
15
17
|
*/
|
|
16
18
|
|
|
17
19
|
import type { ModelTransport } from '../operations/llm.js';
|
|
20
|
+
import type { NormalizedDelta, TransportContext } from './interfaces.js';
|
|
21
|
+
import type { ApiMode } from './provider-id.js';
|
|
18
22
|
|
|
19
23
|
/**
|
|
20
24
|
* Token usage reported by the provider for a single API call.
|
|
@@ -99,17 +103,71 @@ export interface NormalizedResponse {
|
|
|
99
103
|
raw: unknown;
|
|
100
104
|
}
|
|
101
105
|
|
|
106
|
+
/**
|
|
107
|
+
* An image content block for multimodal messages.
|
|
108
|
+
*
|
|
109
|
+
* `source.type` determines how the image data is provided:
|
|
110
|
+
* - `'base64'` — raw image bytes encoded as base64, with `mediaType` identifying
|
|
111
|
+
* the MIME type (e.g. `'image/png'`, `'image/jpeg'`).
|
|
112
|
+
* - `'url'` — a publicly accessible URL; `data` is the URL string and `mediaType`
|
|
113
|
+
* is still populated (sniffed by {@link image-routing.ts} when not supplied by
|
|
114
|
+
* the caller).
|
|
115
|
+
*
|
|
116
|
+
* @see ADR-072 §LlmTransport — pure wire level (W4d image routing)
|
|
117
|
+
*/
|
|
118
|
+
export interface TransportImageBlock {
|
|
119
|
+
/** Discriminant — always `'image'`. */
|
|
120
|
+
readonly type: 'image';
|
|
121
|
+
readonly source: {
|
|
122
|
+
/** How the image data is provided. */
|
|
123
|
+
readonly type: 'base64' | 'url';
|
|
124
|
+
/**
|
|
125
|
+
* Base64-encoded image bytes (when `type === 'base64'`) or a URL string
|
|
126
|
+
* (when `type === 'url'`).
|
|
127
|
+
*/
|
|
128
|
+
readonly data: string;
|
|
129
|
+
/** MIME type, e.g. `'image/png'`, `'image/jpeg'`, `'image/webp'`. */
|
|
130
|
+
readonly mediaType: string;
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* A text content block for multimodal messages.
|
|
136
|
+
*/
|
|
137
|
+
export interface TransportTextBlock {
|
|
138
|
+
/** Discriminant — always `'text'`. */
|
|
139
|
+
readonly type: 'text';
|
|
140
|
+
/** Plain text string. */
|
|
141
|
+
readonly text: string;
|
|
142
|
+
}
|
|
143
|
+
|
|
102
144
|
/**
|
|
103
145
|
* A single message in a provider-neutral conversation turn.
|
|
104
146
|
*
|
|
105
147
|
* `toolUseId` is required when `role` is `'tool'` — it identifies which
|
|
106
148
|
* tool call this result resolves, matching {@link NormalizedToolCall.id}.
|
|
149
|
+
*
|
|
150
|
+
* `content` supports both the legacy plain-string form and a multimodal block
|
|
151
|
+
* array. When `content` is a string, the transport treats it as a single text
|
|
152
|
+
* block. When it is an array, each element is either a {@link TransportTextBlock}
|
|
153
|
+
* or a {@link TransportImageBlock} — enabling image routing (W4d) without
|
|
154
|
+
* breaking existing transport consumers that only read the string form.
|
|
107
155
|
*/
|
|
108
156
|
export interface TransportMessage {
|
|
109
157
|
/** Conversation turn role. */
|
|
110
158
|
role: 'user' | 'assistant' | 'tool';
|
|
111
|
-
/**
|
|
112
|
-
|
|
159
|
+
/**
|
|
160
|
+
* Message content.
|
|
161
|
+
*
|
|
162
|
+
* - Plain `string` — backwards-compatible single-text-block form used by
|
|
163
|
+
* all existing transports. Transports that do not support images receive
|
|
164
|
+
* this form only.
|
|
165
|
+
* - `ReadonlyArray<TransportTextBlock | TransportImageBlock>` — multimodal
|
|
166
|
+
* block array enabling image routing (ADR-072 W4d). Transports that do not
|
|
167
|
+
* support images MUST stringify text blocks and drop image blocks (or throw
|
|
168
|
+
* if `imageMode` on the request is `'native'` — see {@link TransportRequest}).
|
|
169
|
+
*/
|
|
170
|
+
readonly content: string | ReadonlyArray<TransportTextBlock | TransportImageBlock>;
|
|
113
171
|
/** Tool-result messages: id of the call this resolves. */
|
|
114
172
|
toolUseId?: string;
|
|
115
173
|
}
|
|
@@ -131,13 +189,16 @@ export interface TransportTool {
|
|
|
131
189
|
}
|
|
132
190
|
|
|
133
191
|
/**
|
|
134
|
-
* Request parameters passed to {@link LlmTransport.complete}
|
|
192
|
+
* Request parameters passed to {@link LlmTransport.complete} and
|
|
193
|
+
* {@link LlmTransport.stream}.
|
|
135
194
|
*
|
|
136
195
|
* `temperature` is normalized to the 0.0–1.0 range; each transport clamps it
|
|
137
196
|
* to the provider's supported range before sending.
|
|
138
197
|
*
|
|
139
198
|
* `signal` may be used to abort in-flight requests (passed through to the
|
|
140
199
|
* underlying fetch / SDK call where supported).
|
|
200
|
+
*
|
|
201
|
+
* @see ADR-072 §LlmTransport — pure wire level
|
|
141
202
|
*/
|
|
142
203
|
export interface TransportRequest {
|
|
143
204
|
/** Model identifier — provider-specific (e.g. `'claude-sonnet-4-6'`). */
|
|
@@ -154,6 +215,36 @@ export interface TransportRequest {
|
|
|
154
215
|
temperature?: number;
|
|
155
216
|
/** AbortSignal for request cancellation. */
|
|
156
217
|
signal?: AbortSignal;
|
|
218
|
+
/**
|
|
219
|
+
* Prompt-cache breakpoint injection strategy.
|
|
220
|
+
*
|
|
221
|
+
* - `'system_and_3'` — inject cache breakpoints after the system prompt and
|
|
222
|
+
* after the last 3 user messages (Anthropic extended-caching strategy).
|
|
223
|
+
* - `'prefix_and_2'` — inject at the shared prefix boundary and after the 2
|
|
224
|
+
* most-recent turns (optimised for Gemini cached content).
|
|
225
|
+
* - `null` — no cache injection (default when not set).
|
|
226
|
+
*
|
|
227
|
+
* Transports apply the selected strategy before constructing the SDK request.
|
|
228
|
+
* Unsupported strategies on a given transport are silently ignored.
|
|
229
|
+
*
|
|
230
|
+
* @see ADR-072 §LlmTransport — pure wire level
|
|
231
|
+
*/
|
|
232
|
+
readonly cacheStrategy?: 'system_and_3' | 'prefix_and_2' | null;
|
|
233
|
+
/**
|
|
234
|
+
* Image handling mode for multimodal content blocks in {@link TransportMessage.content}.
|
|
235
|
+
*
|
|
236
|
+
* - `'native'` — send image blocks as-is to the provider's multimodal API.
|
|
237
|
+
* The transport MUST throw if the provider does not support native images.
|
|
238
|
+
* - `'text'` — strip all image blocks; only text blocks are sent. Useful for
|
|
239
|
+
* text-only providers or when images are redundant.
|
|
240
|
+
* - `'auto'` — the transport decides based on provider capability (default).
|
|
241
|
+
* Falls back to `'text'` for providers that do not support native images.
|
|
242
|
+
*
|
|
243
|
+
* Used by the image-routing layer (W4d) to select the per-turn input mode.
|
|
244
|
+
*
|
|
245
|
+
* @see ADR-072 §LlmTransport — pure wire level
|
|
246
|
+
*/
|
|
247
|
+
readonly imageMode?: 'native' | 'text' | 'auto';
|
|
157
248
|
}
|
|
158
249
|
|
|
159
250
|
/**
|
|
@@ -163,6 +254,15 @@ export interface TransportRequest {
|
|
|
163
254
|
* interface and maps provider-specific API shapes to/from
|
|
164
255
|
* {@link NormalizedResponse}. Role-resolver and executor code works
|
|
165
256
|
* exclusively against this interface so providers are swappable.
|
|
257
|
+
*
|
|
258
|
+
* As of Phase 4 (ADR-072) the interface gains two additional members:
|
|
259
|
+
* - {@link apiMode} — the wire protocol spoken by this transport.
|
|
260
|
+
* - {@link stream} — streaming completion returning {@link NormalizedDelta} chunks.
|
|
261
|
+
*
|
|
262
|
+
* Existing transport implementations MUST add stub implementations of both to
|
|
263
|
+
* maintain compile parity (W0c). Wave 1 migrations replace stubs with real impls.
|
|
264
|
+
*
|
|
265
|
+
* @see ADR-072 §LlmTransport — pure wire level
|
|
166
266
|
*/
|
|
167
267
|
export interface LlmTransport {
|
|
168
268
|
/**
|
|
@@ -170,6 +270,13 @@ export interface LlmTransport {
|
|
|
170
270
|
* can select the correct transport at runtime.
|
|
171
271
|
*/
|
|
172
272
|
readonly provider: ModelTransport;
|
|
273
|
+
/**
|
|
274
|
+
* Wire protocol this transport speaks. Used by the session and executor layers
|
|
275
|
+
* to select correct transports for providers that support multiple protocols.
|
|
276
|
+
*
|
|
277
|
+
* @see ADR-072 §Type lock-in — `ApiMode` closed 4-value union
|
|
278
|
+
*/
|
|
279
|
+
readonly apiMode: ApiMode;
|
|
173
280
|
/**
|
|
174
281
|
* Execute a single completion call and return a normalized response.
|
|
175
282
|
*
|
|
@@ -179,7 +286,28 @@ export interface LlmTransport {
|
|
|
179
286
|
* - Map provider-specific stop reasons to the canonical set where possible.
|
|
180
287
|
*
|
|
181
288
|
* @param request - Provider-neutral request parameters.
|
|
289
|
+
* @param ctx - Contextual metadata (request ID, abort signal, feature flags).
|
|
182
290
|
* @returns A promise that resolves to a {@link NormalizedResponse}.
|
|
183
291
|
*/
|
|
184
|
-
complete(request: TransportRequest): Promise<NormalizedResponse>;
|
|
292
|
+
complete(request: TransportRequest, ctx?: TransportContext): Promise<NormalizedResponse>;
|
|
293
|
+
/**
|
|
294
|
+
* Stream a completion. Each {@link NormalizedDelta} carries incremental text
|
|
295
|
+
* or reasoning content.
|
|
296
|
+
*
|
|
297
|
+
* Implementors MUST run streaming deltas through `StreamingThinkScrubber`
|
|
298
|
+
* before yielding them — reasoning content goes to `delta.reasoning`;
|
|
299
|
+
* visible text goes to `delta.text`. The final delta has a non-null
|
|
300
|
+
* `stopReason` and carries full usage stats in `delta.usage`.
|
|
301
|
+
*
|
|
302
|
+
* W0c transports carry a stub that throws until Wave 1 migration lands:
|
|
303
|
+
* ```ts
|
|
304
|
+
* throw new Error('STUB: W1 migration will implement stream() for <provider>');
|
|
305
|
+
* ```
|
|
306
|
+
*
|
|
307
|
+
* @param request - Provider-neutral request parameters.
|
|
308
|
+
* @param ctx - Contextual metadata (request ID, abort signal, feature flags).
|
|
309
|
+
* @returns An async iterable of normalized delta chunks.
|
|
310
|
+
* @see ADR-072 §LlmTransport — pure wire level
|
|
311
|
+
*/
|
|
312
|
+
stream(request: TransportRequest, ctx: TransportContext): AsyncIterable<NormalizedDelta>;
|
|
185
313
|
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Provider identity and API protocol types for the unified LLM provider architecture.
|
|
3
|
+
*
|
|
4
|
+
* These types anchor the Phase 4 contract layer (ADR-072). All downstream code
|
|
5
|
+
* that references a provider by name or by wire-protocol uses these types.
|
|
6
|
+
*
|
|
7
|
+
* @module llm/provider-id
|
|
8
|
+
* @task T9281
|
|
9
|
+
* @epic T9261 T-LLM-CRED-CENTRALIZATION
|
|
10
|
+
* @see ADR-072 §Type lock-in
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Canonical wire-level API protocol supported by a provider.
|
|
15
|
+
*
|
|
16
|
+
* Closed 4-value union. Providers that speak multiple protocols (e.g. OpenAI
|
|
17
|
+
* supports both chat_completions and codex_responses) declare separate
|
|
18
|
+
* ProviderProfiles, one per ApiMode.
|
|
19
|
+
*
|
|
20
|
+
* Adding a fifth value is a major breaking change — confirm in ADR-072 before doing so.
|
|
21
|
+
*
|
|
22
|
+
* @see ADR-072 §Type lock-in
|
|
23
|
+
*/
|
|
24
|
+
export type ApiMode =
|
|
25
|
+
| 'chat_completions' // OpenAI, OpenRouter, Groq, DeepSeek, Moonshot, xAI, Gemini-via-OR
|
|
26
|
+
| 'anthropic_messages' // Native Anthropic SDK — full prompt-cache + thinking
|
|
27
|
+
| 'codex_responses' // OpenAI Responses API (Codex CLI, xAI-responses)
|
|
28
|
+
| 'bedrock_converse'; // AWS Bedrock ConversationAPI
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Fixed set of builtin provider identifiers shipped with CLEO core.
|
|
32
|
+
*
|
|
33
|
+
* Plugin providers registered at runtime may use any non-empty string —
|
|
34
|
+
* see {@link ProviderId}.
|
|
35
|
+
*
|
|
36
|
+
* MIGRATION NOTE: The legacy `ModelTransport` ('anthropic'|'openai'|'gemini'|'moonshot')
|
|
37
|
+
* is re-typed as `Extract<ProviderId, BuiltinProviderId>` for one release cycle
|
|
38
|
+
* (deprecated, then removed).
|
|
39
|
+
*/
|
|
40
|
+
export type BuiltinProviderId =
|
|
41
|
+
| 'anthropic'
|
|
42
|
+
| 'openai'
|
|
43
|
+
| 'gemini'
|
|
44
|
+
| 'moonshot'
|
|
45
|
+
| 'openrouter'
|
|
46
|
+
| 'bedrock'
|
|
47
|
+
| 'deepseek'
|
|
48
|
+
| 'xai'
|
|
49
|
+
| 'groq'
|
|
50
|
+
| 'kimi-code';
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Provider identity string.
|
|
54
|
+
*
|
|
55
|
+
* Builtin providers use the fixed literals in {@link BuiltinProviderId}.
|
|
56
|
+
* Plugin providers registered at runtime via `ProviderRegistry` may use any
|
|
57
|
+
* non-empty string. The open string union allows plugins without forcing
|
|
58
|
+
* exhaustive switch checks in transport code (match arms should include a
|
|
59
|
+
* default/unknown branch).
|
|
60
|
+
*
|
|
61
|
+
* @see ADR-072 §Type lock-in
|
|
62
|
+
*/
|
|
63
|
+
export type ProviderId = BuiltinProviderId | (string & Record<never, never>);
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
import type { ModelTransport, StoredAuthTypeWire } from '../operations/llm.js';
|
|
14
|
+
import type { TransportMessage, TransportTool } from './normalized-response.js';
|
|
14
15
|
|
|
15
16
|
/**
|
|
16
17
|
* Describes a single LLM provider — its auth capabilities, base URL,
|
|
@@ -85,6 +86,71 @@ export interface ProviderProfile {
|
|
|
85
86
|
* @param signal - Optional abort signal for request cancellation.
|
|
86
87
|
*/
|
|
87
88
|
fetchModels?: (apiKey: string, signal?: AbortSignal) => Promise<ReadonlyArray<string> | null>;
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Hook: transform messages before they are passed to the SDK.
|
|
92
|
+
*
|
|
93
|
+
* Default behavior (when `undefined`): identity — messages are forwarded
|
|
94
|
+
* unchanged. Providers use this hook for shape conversions such as:
|
|
95
|
+
* - Gemini: hoisting the system message to `systemInstruction`.
|
|
96
|
+
* - Anthropic: injecting an assistant-prefill block for structured output.
|
|
97
|
+
* - OpenAI o-series: merging consecutive same-role messages.
|
|
98
|
+
*
|
|
99
|
+
* Port of Hermes `ProviderProfile.prepare_messages` (Hermes §3.1).
|
|
100
|
+
*
|
|
101
|
+
* @param messages - The transport-level messages prior to provider conversion.
|
|
102
|
+
* @param model - The resolved model identifier.
|
|
103
|
+
* @returns Possibly-modified messages array. Implementations MUST NOT mutate
|
|
104
|
+
* the input array; return a new array if changes are needed.
|
|
105
|
+
*/
|
|
106
|
+
readonly prepareMessages?: (
|
|
107
|
+
messages: readonly TransportMessage[],
|
|
108
|
+
model: string,
|
|
109
|
+
) => readonly TransportMessage[];
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Hook: contribute provider-specific extra body fields.
|
|
113
|
+
*
|
|
114
|
+
* The returned object is merged into the SDK request's `extra_body`
|
|
115
|
+
* (OpenAI-style) or equivalent provider field. Providers use this for:
|
|
116
|
+
* - Gemini: `thinkingConfig` for extended reasoning budget.
|
|
117
|
+
* - OpenRouter: Pareto router plugin parameters.
|
|
118
|
+
* - Anthropic-via-OpenRouter: fine-grained tool streaming control.
|
|
119
|
+
*
|
|
120
|
+
* Port of Hermes `ProviderProfile.build_extra_body`.
|
|
121
|
+
*
|
|
122
|
+
* @param model - The resolved model identifier.
|
|
123
|
+
* @param messages - The transport-level messages at call time.
|
|
124
|
+
* @param tools - The tool definitions at call time.
|
|
125
|
+
* @returns Object merged into the provider request's `extra_body` field.
|
|
126
|
+
*/
|
|
127
|
+
readonly buildExtraBody?: (
|
|
128
|
+
model: string,
|
|
129
|
+
messages: readonly TransportMessage[],
|
|
130
|
+
tools: readonly TransportTool[],
|
|
131
|
+
) => Readonly<Record<string, unknown>>;
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Hook: contribute provider-specific top-level API kwargs.
|
|
135
|
+
*
|
|
136
|
+
* The returned object is shallow-merged into the SDK call kwargs. Providers
|
|
137
|
+
* use this for top-level fields that do not fit into `extra_body`:
|
|
138
|
+
* - xAI Grok: `x-grok-conv-id` conversation pinning header.
|
|
139
|
+
* - Kimi: `reasoning_effort` top-level reasoning control.
|
|
140
|
+
* - Moonshot: JSON-schema sanitization applied at the request level.
|
|
141
|
+
*
|
|
142
|
+
* Port of Hermes `ProviderProfile.build_api_kwargs_extras`.
|
|
143
|
+
*
|
|
144
|
+
* @param model - The resolved model identifier.
|
|
145
|
+
* @param messages - The transport-level messages at call time.
|
|
146
|
+
* @param tools - The tool definitions at call time.
|
|
147
|
+
* @returns Object shallow-merged into the SDK call kwargs.
|
|
148
|
+
*/
|
|
149
|
+
readonly buildApiKwargsExtras?: (
|
|
150
|
+
model: string,
|
|
151
|
+
messages: readonly TransportMessage[],
|
|
152
|
+
tools: readonly TransportTool[],
|
|
153
|
+
) => Readonly<Record<string, unknown>>;
|
|
88
154
|
}
|
|
89
155
|
|
|
90
156
|
/**
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fully-resolved credential type for the unified LLM provider architecture.
|
|
3
|
+
*
|
|
4
|
+
* This type replaces the partial `CredentialResultWire` at the runtime level.
|
|
5
|
+
* `CredentialResultWire` is retained solely as a wire diagnostic type for
|
|
6
|
+
* `cleo llm whoami` CLI output.
|
|
7
|
+
*
|
|
8
|
+
* @module llm/resolved-credential
|
|
9
|
+
* @task T9281
|
|
10
|
+
* @epic T9261 T-LLM-CRED-CENTRALIZATION
|
|
11
|
+
* @see ADR-072 §Type lock-in
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import type { ProviderId } from './provider-id.js';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Fully-resolved credential ready for use in a transport constructor.
|
|
18
|
+
*
|
|
19
|
+
* The transport consumes this at construction time and MUST NOT store it
|
|
20
|
+
* beyond initialization. {@link extraHeaders} is merged into SDK
|
|
21
|
+
* defaultHeaders.
|
|
22
|
+
*
|
|
23
|
+
* Replaces the partial `CredentialResultWire` for runtime use.
|
|
24
|
+
* `CredentialResultWire` is retained as a wire diagnostic type for
|
|
25
|
+
* `cleo llm whoami` CLI output only.
|
|
26
|
+
*
|
|
27
|
+
* @see ADR-072 §Type lock-in
|
|
28
|
+
*/
|
|
29
|
+
export interface ResolvedCredential {
|
|
30
|
+
/** Provider this credential targets. */
|
|
31
|
+
readonly provider: ProviderId;
|
|
32
|
+
/** Human-readable store label (e.g. 'personal', 'work'). */
|
|
33
|
+
readonly label: string;
|
|
34
|
+
/**
|
|
35
|
+
* API key, OAuth bearer token, or empty string for aws_sdk auth.
|
|
36
|
+
* NEVER log this field. NEVER include in NormalizedResponse.providerData.
|
|
37
|
+
*/
|
|
38
|
+
readonly token: string;
|
|
39
|
+
/** How the token is presented to the provider. */
|
|
40
|
+
readonly authType: 'api_key' | 'oauth' | 'aws_sdk';
|
|
41
|
+
/**
|
|
42
|
+
* Unix epoch ms at which the token expires. null = never expires.
|
|
43
|
+
* LlmSession checks this before each send() and triggers OAuth refresh
|
|
44
|
+
* when less than 60 seconds remain.
|
|
45
|
+
*/
|
|
46
|
+
readonly expiresAt: number | null;
|
|
47
|
+
/**
|
|
48
|
+
* OAuth refresh token. null for api_key and aws_sdk credentials.
|
|
49
|
+
* LlmSession holds this; the transport never sees it.
|
|
50
|
+
*/
|
|
51
|
+
readonly refreshToken: string | null;
|
|
52
|
+
/**
|
|
53
|
+
* Extra HTTP headers merged into every SDK request from this credential.
|
|
54
|
+
* Typically carries 'Authorization: Bearer ...' for oauth authType,
|
|
55
|
+
* and 'anthropic-beta: ...' when needed.
|
|
56
|
+
*/
|
|
57
|
+
readonly extraHeaders: Readonly<Record<string, string>>;
|
|
58
|
+
/** Base URL override (proxy, on-prem deployment). null = use provider default. */
|
|
59
|
+
readonly baseUrl: string | null;
|
|
60
|
+
/** AWS profile name for Bedrock. null for all other providers. */
|
|
61
|
+
readonly awsProfile: string | null;
|
|
62
|
+
}
|
package/src/operations/llm.ts
CHANGED
|
@@ -9,8 +9,21 @@
|
|
|
9
9
|
* @epic T1386
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
import type { BuiltinProviderId, ProviderId } from '../llm/provider-id.js';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @deprecated since Phase 4 (ADR-072). Use {@link ProviderId} from
|
|
16
|
+
* `@cleocode/contracts/llm/provider-id.js` for new code. This alias remains
|
|
17
|
+
* for one release cycle to ease migration of legacy callers, then is removed.
|
|
18
|
+
*
|
|
19
|
+
* The alias resolves to {@link BuiltinProviderId} — a superset of the previous
|
|
20
|
+
* closed literal union (`'anthropic' | 'openai' | 'gemini' | 'moonshot'`).
|
|
21
|
+
* All existing consumers that pattern-match on the previous four values continue
|
|
22
|
+
* to compile without changes.
|
|
23
|
+
*
|
|
24
|
+
* @see ADR-072 §Type lock-in — ModelTransport deprecation cycle
|
|
25
|
+
*/
|
|
26
|
+
export type ModelTransport = Extract<ProviderId, BuiltinProviderId>;
|
|
14
27
|
|
|
15
28
|
/** Cache policy mode for prompt prefix caching. */
|
|
16
29
|
export type PromptCachePolicyMode = 'gemini_cached_content';
|