@framers/agentos 0.10.22 → 0.10.24
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 +1 -1
- package/dist/api/AgentOS.d.ts.map +1 -1
- package/dist/api/AgentOS.js +3 -2
- package/dist/api/AgentOS.js.map +1 -1
- package/dist/api/agent.d.ts.map +1 -1
- package/dist/api/agent.js +25 -10
- package/dist/api/agent.js.map +1 -1
- package/dist/api/embedText.d.ts.map +1 -1
- package/dist/api/embedText.js +53 -17
- package/dist/api/embedText.js.map +1 -1
- package/dist/api/generateImage.d.ts.map +1 -1
- package/dist/api/generateImage.js +51 -7
- package/dist/api/generateImage.js.map +1 -1
- package/dist/api/generateText.d.ts +50 -7
- package/dist/api/generateText.d.ts.map +1 -1
- package/dist/api/generateText.js +265 -35
- package/dist/api/generateText.js.map +1 -1
- package/dist/api/model.d.ts +25 -1
- package/dist/api/model.d.ts.map +1 -1
- package/dist/api/model.js +108 -3
- package/dist/api/model.js.map +1 -1
- package/dist/api/runtime/SelfImprovementSessionManager.d.ts +34 -2
- package/dist/api/runtime/SelfImprovementSessionManager.d.ts.map +1 -1
- package/dist/api/runtime/SelfImprovementSessionManager.js +119 -33
- package/dist/api/runtime/SelfImprovementSessionManager.js.map +1 -1
- package/dist/api/runtime/global-default.d.ts +9 -1
- package/dist/api/runtime/global-default.d.ts.map +1 -1
- package/dist/api/runtime/global-default.js.map +1 -1
- package/dist/api/runtime/provider-defaults.d.ts.map +1 -1
- package/dist/api/runtime/provider-defaults.js +10 -4
- package/dist/api/runtime/provider-defaults.js.map +1 -1
- package/dist/api/runtime/tool-emulation/history.d.ts +16 -0
- package/dist/api/runtime/tool-emulation/history.d.ts.map +1 -0
- package/dist/api/runtime/tool-emulation/history.js +89 -0
- package/dist/api/runtime/tool-emulation/history.js.map +1 -0
- package/dist/api/runtime/tool-emulation/index.d.ts +1 -0
- package/dist/api/runtime/tool-emulation/index.d.ts.map +1 -1
- package/dist/api/runtime/tool-emulation/index.js +1 -0
- package/dist/api/runtime/tool-emulation/index.js.map +1 -1
- package/dist/api/runtime/tool-emulation/loop.d.ts +6 -0
- package/dist/api/runtime/tool-emulation/loop.d.ts.map +1 -1
- package/dist/api/runtime/tool-emulation/loop.js +1 -0
- package/dist/api/runtime/tool-emulation/loop.js.map +1 -1
- package/dist/api/sessionTranscript.d.ts +34 -0
- package/dist/api/sessionTranscript.d.ts.map +1 -1
- package/dist/api/sessionTranscript.js +61 -1
- package/dist/api/sessionTranscript.js.map +1 -1
- package/dist/api/streamText.d.ts.map +1 -1
- package/dist/api/streamText.js +120 -24
- package/dist/api/streamText.js.map +1 -1
- package/dist/api/types/AgentOSInput.d.ts +11 -0
- package/dist/api/types/AgentOSInput.d.ts.map +1 -1
- package/dist/api/types.d.ts +14 -6
- package/dist/api/types.d.ts.map +1 -1
- package/dist/api/types.js.map +1 -1
- package/dist/cognition/emergent/AdaptPersonalityTool.d.ts +13 -4
- package/dist/cognition/emergent/AdaptPersonalityTool.d.ts.map +1 -1
- package/dist/cognition/emergent/AdaptPersonalityTool.js +32 -23
- package/dist/cognition/emergent/AdaptPersonalityTool.js.map +1 -1
- package/dist/cognition/emergent/EmergentCapabilityEngine.d.ts +18 -6
- package/dist/cognition/emergent/EmergentCapabilityEngine.d.ts.map +1 -1
- package/dist/cognition/emergent/EmergentCapabilityEngine.js.map +1 -1
- package/dist/cognition/emergent/SelfEvaluateTool.d.ts +10 -3
- package/dist/cognition/emergent/SelfEvaluateTool.d.ts.map +1 -1
- package/dist/cognition/emergent/SelfEvaluateTool.js +3 -2
- package/dist/cognition/emergent/SelfEvaluateTool.js.map +1 -1
- package/dist/cognition/substrate/CognitiveMemoryBridge.d.ts +51 -2
- package/dist/cognition/substrate/CognitiveMemoryBridge.d.ts.map +1 -1
- package/dist/cognition/substrate/CognitiveMemoryBridge.js +84 -2
- package/dist/cognition/substrate/CognitiveMemoryBridge.js.map +1 -1
- package/dist/cognition/substrate/ConversationHistoryManager.d.ts +8 -4
- package/dist/cognition/substrate/ConversationHistoryManager.d.ts.map +1 -1
- package/dist/cognition/substrate/ConversationHistoryManager.js +17 -5
- package/dist/cognition/substrate/ConversationHistoryManager.js.map +1 -1
- package/dist/cognition/substrate/GMI.d.ts +92 -5
- package/dist/cognition/substrate/GMI.d.ts.map +1 -1
- package/dist/cognition/substrate/GMI.js +291 -65
- package/dist/cognition/substrate/GMI.js.map +1 -1
- package/dist/cognition/substrate/GMIManager.d.ts +12 -0
- package/dist/cognition/substrate/GMIManager.d.ts.map +1 -1
- package/dist/cognition/substrate/GMIManager.js +22 -16
- package/dist/cognition/substrate/GMIManager.js.map +1 -1
- package/dist/cognition/substrate/IGMI.d.ts +23 -0
- package/dist/cognition/substrate/IGMI.d.ts.map +1 -1
- package/dist/cognition/substrate/IGMI.js.map +1 -1
- package/dist/cognition/substrate/MetapromptExecutor.d.ts +183 -28
- package/dist/cognition/substrate/MetapromptExecutor.d.ts.map +1 -1
- package/dist/cognition/substrate/MetapromptExecutor.js +431 -108
- package/dist/cognition/substrate/MetapromptExecutor.js.map +1 -1
- package/dist/cognition/substrate/personas/IPersonaDefinition.d.ts +5 -0
- package/dist/cognition/substrate/personas/IPersonaDefinition.d.ts.map +1 -1
- package/dist/cognition/substrate/personas/PersonaValidation.d.ts.map +1 -1
- package/dist/cognition/substrate/personas/PersonaValidation.js +30 -0
- package/dist/cognition/substrate/personas/PersonaValidation.js.map +1 -1
- package/dist/cognition/substrate/personas/SoulLoader.d.ts +14 -1
- package/dist/cognition/substrate/personas/SoulLoader.d.ts.map +1 -1
- package/dist/cognition/substrate/personas/SoulLoader.js +45 -12
- package/dist/cognition/substrate/personas/SoulLoader.js.map +1 -1
- package/dist/cognition/substrate/personas/definitions/default_assistant_persona.json +3 -35
- package/dist/cognition/substrate/personas/hexaco.d.ts +34 -0
- package/dist/cognition/substrate/personas/hexaco.d.ts.map +1 -0
- package/dist/cognition/substrate/personas/hexaco.js +66 -0
- package/dist/cognition/substrate/personas/hexaco.js.map +1 -0
- package/dist/cognition/substrate/userFeedback.d.ts +69 -0
- package/dist/cognition/substrate/userFeedback.d.ts.map +1 -0
- package/dist/cognition/substrate/userFeedback.js +107 -0
- package/dist/cognition/substrate/userFeedback.js.map +1 -0
- package/dist/core/conversation/ConversationMessage.d.ts +9 -0
- package/dist/core/conversation/ConversationMessage.d.ts.map +1 -1
- package/dist/core/conversation/ConversationMessage.js.map +1 -1
- package/dist/core/llm/IPromptEngine.d.ts +9 -0
- package/dist/core/llm/IPromptEngine.d.ts.map +1 -1
- package/dist/core/llm/IPromptEngine.js.map +1 -1
- package/dist/core/llm/PromptEngine.d.ts +30 -1
- package/dist/core/llm/PromptEngine.d.ts.map +1 -1
- package/dist/core/llm/PromptEngine.js +229 -92
- package/dist/core/llm/PromptEngine.js.map +1 -1
- package/dist/core/llm/providers/AIModelProviderManager.d.ts +20 -0
- package/dist/core/llm/providers/AIModelProviderManager.d.ts.map +1 -1
- package/dist/core/llm/providers/AIModelProviderManager.js +35 -5
- package/dist/core/llm/providers/AIModelProviderManager.js.map +1 -1
- package/dist/core/llm/providers/IProvider.d.ts +28 -8
- package/dist/core/llm/providers/IProvider.d.ts.map +1 -1
- package/dist/core/llm/providers/implementations/AnthropicProvider.d.ts +135 -49
- package/dist/core/llm/providers/implementations/AnthropicProvider.d.ts.map +1 -1
- package/dist/core/llm/providers/implementations/AnthropicProvider.js +323 -114
- package/dist/core/llm/providers/implementations/AnthropicProvider.js.map +1 -1
- package/dist/core/llm/providers/implementations/ClaudeCodeProvider.d.ts.map +1 -1
- package/dist/core/llm/providers/implementations/ClaudeCodeProvider.js +15 -1
- package/dist/core/llm/providers/implementations/ClaudeCodeProvider.js.map +1 -1
- package/dist/core/llm/providers/implementations/GeminiCLIProvider.d.ts +1 -1
- package/dist/core/llm/providers/implementations/GeminiCLIProvider.d.ts.map +1 -1
- package/dist/core/llm/providers/implementations/GeminiCLIProvider.js +51 -24
- package/dist/core/llm/providers/implementations/GeminiCLIProvider.js.map +1 -1
- package/dist/core/llm/providers/implementations/GeminiProvider.d.ts +25 -6
- package/dist/core/llm/providers/implementations/GeminiProvider.d.ts.map +1 -1
- package/dist/core/llm/providers/implementations/GeminiProvider.js +108 -90
- package/dist/core/llm/providers/implementations/GeminiProvider.js.map +1 -1
- package/dist/core/llm/providers/implementations/MistralProvider.d.ts +11 -0
- package/dist/core/llm/providers/implementations/MistralProvider.d.ts.map +1 -1
- package/dist/core/llm/providers/implementations/MistralProvider.js +32 -2
- package/dist/core/llm/providers/implementations/MistralProvider.js.map +1 -1
- package/dist/core/llm/providers/implementations/OllamaProvider.js +7 -7
- package/dist/core/llm/providers/implementations/OllamaProvider.js.map +1 -1
- package/dist/core/llm/providers/implementations/OpenAIProvider.d.ts +53 -2
- package/dist/core/llm/providers/implementations/OpenAIProvider.d.ts.map +1 -1
- package/dist/core/llm/providers/implementations/OpenAIProvider.js +84 -17
- package/dist/core/llm/providers/implementations/OpenAIProvider.js.map +1 -1
- package/dist/core/llm/providers/implementations/OpenRouterProvider.d.ts.map +1 -1
- package/dist/core/llm/providers/implementations/OpenRouterProvider.js +8 -3
- package/dist/core/llm/providers/implementations/OpenRouterProvider.js.map +1 -1
- package/dist/core/llm/providers/implementations/TogetherProvider.d.ts +3 -3
- package/dist/core/llm/providers/implementations/TogetherProvider.d.ts.map +1 -1
- package/dist/core/llm/providers/implementations/TogetherProvider.js +25 -13
- package/dist/core/llm/providers/implementations/TogetherProvider.js.map +1 -1
- package/dist/core/llm/providers/implementations/cacheLeakDetector.d.ts +15 -7
- package/dist/core/llm/providers/implementations/cacheLeakDetector.d.ts.map +1 -1
- package/dist/core/llm/providers/implementations/cacheLeakDetector.js +12 -7
- package/dist/core/llm/providers/implementations/cacheLeakDetector.js.map +1 -1
- package/dist/core/llm/providers/model-cache-capabilities.d.ts +24 -9
- package/dist/core/llm/providers/model-cache-capabilities.d.ts.map +1 -1
- package/dist/core/llm/providers/model-cache-capabilities.js +59 -44
- package/dist/core/llm/providers/model-cache-capabilities.js.map +1 -1
- package/dist/core/llm/providers/model-effort.d.ts +14 -0
- package/dist/core/llm/providers/model-effort.d.ts.map +1 -1
- package/dist/core/llm/providers/model-effort.js +22 -0
- package/dist/core/llm/providers/model-effort.js.map +1 -1
- package/dist/core/llm/providers/model-forced-tool-choice.d.ts +13 -6
- package/dist/core/llm/providers/model-forced-tool-choice.d.ts.map +1 -1
- package/dist/core/llm/providers/model-forced-tool-choice.js +14 -7
- package/dist/core/llm/providers/model-forced-tool-choice.js.map +1 -1
- package/dist/core/llm/providers/model-thinking.d.ts +64 -13
- package/dist/core/llm/providers/model-thinking.d.ts.map +1 -1
- package/dist/core/llm/providers/model-thinking.js +52 -12
- package/dist/core/llm/providers/model-thinking.js.map +1 -1
- package/dist/core/llm/providers/openrouter-only-params.d.ts +26 -7
- package/dist/core/llm/providers/openrouter-only-params.d.ts.map +1 -1
- package/dist/core/llm/providers/openrouter-only-params.js +58 -9
- package/dist/core/llm/providers/openrouter-only-params.js.map +1 -1
- package/dist/core/llm/providers/url-secrets.d.ts +42 -0
- package/dist/core/llm/providers/url-secrets.d.ts.map +1 -0
- package/dist/core/llm/providers/url-secrets.js +64 -0
- package/dist/core/llm/providers/url-secrets.js.map +1 -0
- package/dist/core/llm/streaming/StreamingBatcher.d.ts +4 -3
- package/dist/core/llm/streaming/StreamingBatcher.d.ts.map +1 -1
- package/dist/core/llm/streaming/StreamingBatcher.js +8 -3
- package/dist/core/llm/streaming/StreamingBatcher.js.map +1 -1
- package/dist/core/safety/LLMProviderHealthRegistry.d.ts +4 -0
- package/dist/core/safety/LLMProviderHealthRegistry.d.ts.map +1 -1
- package/dist/core/safety/LLMProviderHealthRegistry.js +26 -0
- package/dist/core/safety/LLMProviderHealthRegistry.js.map +1 -1
- package/dist/core/utils/sha256.d.ts +19 -0
- package/dist/core/utils/sha256.d.ts.map +1 -0
- package/dist/core/utils/sha256.js +101 -0
- package/dist/core/utils/sha256.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/orchestration/pipeline/query/types.js +3 -3
- package/dist/orchestration/pipeline/query/types.js.map +1 -1
- package/dist/orchestration/planning/ProviderAssignmentEngine.js +2 -2
- package/dist/orchestration/planning/ProviderAssignmentEngine.js.map +1 -1
- package/package.json +1 -1
|
@@ -88,11 +88,13 @@ export interface AnthropicProviderConfig {
|
|
|
88
88
|
* Whether the given Claude model id accepts the `temperature` parameter.
|
|
89
89
|
*
|
|
90
90
|
* Anthropic deprecated `temperature` on reasoning-default models. Opus 4.7,
|
|
91
|
-
* Opus 4.8, Opus 5, Opus 5.5, Sonnet 5, Fable 5 and Fable 5.1
|
|
92
|
-
* that include it with HTTP 400 "`temperature` is deprecated
|
|
93
|
-
* Opus 5, Opus 5.5 and Fable 5.1 were live-probed on
|
|
94
|
-
*
|
|
95
|
-
*
|
|
91
|
+
* Opus 4.8, Opus 5, Opus 5.5, Sonnet 5, Sonnet 5.5, Fable 5 and Fable 5.1
|
|
92
|
+
* reject requests that include it with HTTP 400 "`temperature` is deprecated
|
|
93
|
+
* for this model." Opus 5, Opus 5.5 and Fable 5.1 were live-probed on
|
|
94
|
+
* 2026-09-29 and Sonnet 5.5 on 2026-09-30. Opus 5.5, Sonnet 5.5 and Fable 5.1
|
|
95
|
+
* match the existing `opus-5`, `sonnet-5` and `fable-5` alternatives on
|
|
96
|
+
* purpose, because `\b` matches at the hyphen before their trailing version
|
|
97
|
+
* digit.
|
|
96
98
|
* Every earlier Claude model (Opus ≤ 4.6, Sonnet 4.6 and earlier, Haiku) still accepts it.
|
|
97
99
|
* The same family also rejects `top_p` / `top_k`, so {@link buildRequestPayload}
|
|
98
100
|
* gates `top_p` on this predicate too.
|
|
@@ -138,6 +140,27 @@ interface AnthropicContentBlock {
|
|
|
138
140
|
data: string;
|
|
139
141
|
};
|
|
140
142
|
}
|
|
143
|
+
/**
|
|
144
|
+
* Prompt-cache writes on one response, split by cache TTL: the
|
|
145
|
+
* `usage.cache_creation` object of the Messages API. The two counts add up to
|
|
146
|
+
* `cache_creation_input_tokens`.
|
|
147
|
+
*/
|
|
148
|
+
export interface AnthropicCacheCreationBreakdown {
|
|
149
|
+
/** Tokens written with the default 5-minute TTL. */
|
|
150
|
+
ephemeral_5m_input_tokens?: number;
|
|
151
|
+
/** Tokens written with the 1-hour TTL (`cache_control.ttl: '1h'`). */
|
|
152
|
+
ephemeral_1h_input_tokens?: number;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Why the model declined, sent beside `stop_reason: 'refusal'`. Kept verbatim
|
|
156
|
+
* on the content-policy error the provider raises.
|
|
157
|
+
*/
|
|
158
|
+
interface AnthropicStopDetails {
|
|
159
|
+
type?: string;
|
|
160
|
+
/** The policy area the request fell under, such as `cyber`. */
|
|
161
|
+
category?: string | null;
|
|
162
|
+
explanation?: string | null;
|
|
163
|
+
}
|
|
141
164
|
/** The Anthropic Messages API response shape. */
|
|
142
165
|
interface AnthropicMessagesResponse {
|
|
143
166
|
id: string;
|
|
@@ -145,13 +168,20 @@ interface AnthropicMessagesResponse {
|
|
|
145
168
|
role: 'assistant';
|
|
146
169
|
content: AnthropicContentBlock[];
|
|
147
170
|
model: string;
|
|
148
|
-
stop_reason: 'end_turn' | 'max_tokens' | 'stop_sequence' | 'tool_use' | null;
|
|
171
|
+
stop_reason: 'end_turn' | 'max_tokens' | 'stop_sequence' | 'tool_use' | 'pause_turn' | 'refusal' | 'model_context_window_exceeded' | null;
|
|
149
172
|
stop_sequence: string | null;
|
|
173
|
+
/** Present with `stop_reason: 'refusal'`. */
|
|
174
|
+
stop_details?: AnthropicStopDetails | null;
|
|
150
175
|
usage: {
|
|
151
176
|
input_tokens: number;
|
|
152
177
|
output_tokens: number;
|
|
153
178
|
cache_creation_input_tokens?: number;
|
|
154
179
|
cache_read_input_tokens?: number;
|
|
180
|
+
/**
|
|
181
|
+
* Split of `cache_creation_input_tokens` by cache TTL. 5-minute writes
|
|
182
|
+
* bill at 1.25x the input price and 1-hour writes at 2x.
|
|
183
|
+
*/
|
|
184
|
+
cache_creation?: AnthropicCacheCreationBreakdown | null;
|
|
155
185
|
};
|
|
156
186
|
/**
|
|
157
187
|
* Cache-diagnostics verdict (beta `cache-diagnosis-2026-04-07`). Returned
|
|
@@ -190,9 +220,10 @@ export declare function clampAnthropicMaxTokens(modelId: string, requested: numb
|
|
|
190
220
|
* Resolves a caller-supplied model id to its ANTHROPIC_MODELS catalog row.
|
|
191
221
|
* Exact id match wins; otherwise a dated snapshot (`claude-sonnet-5-20260101`)
|
|
192
222
|
* or bare alias is matched by prefix — the SAME resolution the max-tokens
|
|
193
|
-
* clamp uses, shared so pricing
|
|
194
|
-
* row a model id means (
|
|
195
|
-
* snapshot id as costUSD undefined:
|
|
223
|
+
* clamp uses, shared so pricing ({@link estimateAnthropicCostUSD}) and
|
|
224
|
+
* clamping can never disagree about which row a model id means (an
|
|
225
|
+
* exact-only match prices every dated snapshot id as costUSD undefined:
|
|
226
|
+
* unmetered spend).
|
|
196
227
|
*
|
|
197
228
|
* The longest catalog id that prefixes `modelId` wins. Catalog ids nest:
|
|
198
229
|
* `claude-opus-5` is a prefix of `claude-opus-5-5`. A first-match scan makes
|
|
@@ -210,9 +241,51 @@ export declare function resolveAnthropicModelEntry(modelId: string): ModelInfo |
|
|
|
210
241
|
* @param catalog Model rows to search, in any order.
|
|
211
242
|
* @param modelId Caller-supplied model id, bare or dated.
|
|
212
243
|
* @returns The exact row, else the row with the longest id that prefixes
|
|
213
|
-
* `modelId`, else the first row whose id starts with `modelId`.
|
|
244
|
+
* `modelId`, else the first row whose id starts with `modelId`. An empty id
|
|
245
|
+
* resolves to nothing: every catalog id starts with `''`, so the last rule
|
|
246
|
+
* would otherwise price a response with no model echo as the first row.
|
|
214
247
|
*/
|
|
215
248
|
export declare function resolveModelCatalogEntry(catalog: readonly ModelInfo[], modelId: string): ModelInfo | undefined;
|
|
249
|
+
/**
|
|
250
|
+
* Token counts that decide what one Messages API call costs, under the API's
|
|
251
|
+
* own `usage` field names.
|
|
252
|
+
*/
|
|
253
|
+
export interface AnthropicUsageForCost {
|
|
254
|
+
/** Input tokens billed at the full input price (cache reads and writes excluded). */
|
|
255
|
+
input_tokens: number;
|
|
256
|
+
/** Output tokens, thinking included. */
|
|
257
|
+
output_tokens: number;
|
|
258
|
+
/** Tokens read from the prompt cache. */
|
|
259
|
+
cache_read_input_tokens?: number;
|
|
260
|
+
/** Tokens written to the prompt cache, both TTLs together. */
|
|
261
|
+
cache_creation_input_tokens?: number;
|
|
262
|
+
/** The same writes split by TTL, when the response reports the split. */
|
|
263
|
+
cache_creation?: AnthropicCacheCreationBreakdown | null;
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* Estimates the USD cost of one Anthropic Messages API call from its usage.
|
|
267
|
+
*
|
|
268
|
+
* | Tokens | Price |
|
|
269
|
+
* | --- | --- |
|
|
270
|
+
* | `input_tokens` | the input price |
|
|
271
|
+
* | `cache_read_input_tokens` | the row's `pricePer1MTokensCacheRead`, else 0.1x the input price |
|
|
272
|
+
* | 5-minute cache writes | 1.25x the input price |
|
|
273
|
+
* | 1-hour cache writes | 2x the input price |
|
|
274
|
+
* | `output_tokens` | the output price |
|
|
275
|
+
*
|
|
276
|
+
* `input_tokens` excludes cached tokens, so the input components add up
|
|
277
|
+
* without double counting. The 1-hour share of the writes comes from
|
|
278
|
+
* `cache_creation.ephemeral_1h_input_tokens`: a response without that split
|
|
279
|
+
* is priced as 5-minute writes only, and a 1-hour count above the write total
|
|
280
|
+
* is capped at the total.
|
|
281
|
+
*
|
|
282
|
+
* @param modelId Model id, bare or dated, resolved with
|
|
283
|
+
* {@link resolveAnthropicModelEntry}.
|
|
284
|
+
* @param usage Token counts from the response.
|
|
285
|
+
* @returns The cost in USD, or `undefined` when the catalog has no price for
|
|
286
|
+
* the model (unknown, empty or unpriced id).
|
|
287
|
+
*/
|
|
288
|
+
export declare function estimateAnthropicCostUSD(modelId: string, usage: AnthropicUsageForCost): number | undefined;
|
|
216
289
|
/**
|
|
217
290
|
* @class AnthropicProvider
|
|
218
291
|
* @implements {IProvider}
|
|
@@ -268,7 +341,10 @@ export declare class AnthropicProvider implements IProvider {
|
|
|
268
341
|
* @param {ModelCompletionOptions} options - Completion options. `maxTokens` is strongly
|
|
269
342
|
* recommended; defaults to {@link AnthropicProviderConfig.defaultMaxTokens} if omitted.
|
|
270
343
|
* @returns {Promise<ModelCompletionResponse>} A normalized completion response.
|
|
271
|
-
* @throws {AnthropicProviderError} On authentication, validation, or network
|
|
344
|
+
* @throws {AnthropicProviderError} On authentication, validation, or network
|
|
345
|
+
* errors, and with code `content_filter` when the model refuses
|
|
346
|
+
* (`stop_reason: 'refusal'`); partial output from a refused turn is
|
|
347
|
+
* discarded.
|
|
272
348
|
*/
|
|
273
349
|
generateCompletion(modelId: string, messages: ChatMessage[], options: ModelCompletionOptions): Promise<ModelCompletionResponse>;
|
|
274
350
|
/**
|
|
@@ -278,6 +354,9 @@ export declare class AnthropicProvider implements IProvider {
|
|
|
278
354
|
* 256 chars of the system prompt, read from the just-built payload so it
|
|
279
355
|
* reflects what actually went to the wire. Fail-open by construction.
|
|
280
356
|
*
|
|
357
|
+
* @param cacheOptOut True when the caller turned caching off for this
|
|
358
|
+
* request (`options.cache === false`). Its uncached input is deliberate,
|
|
359
|
+
* so the detector does not count it toward the `unmarked` warning.
|
|
281
360
|
* @private
|
|
282
361
|
*/
|
|
283
362
|
private recordCacheLeakSample;
|
|
@@ -311,6 +390,11 @@ export declare class AnthropicProvider implements IProvider {
|
|
|
311
390
|
* {@link mapResponseToCompletion} stays the single mapping path
|
|
312
391
|
* (structured output, stop reasons, cost, thinking blocks).
|
|
313
392
|
*
|
|
393
|
+
* A refusal returns normally with `stop_reason: 'refusal'` and its
|
|
394
|
+
* `stop_details`, even when it cut a tool_use input off mid-JSON:
|
|
395
|
+
* {@link mapResponseToCompletion} raises it as a content-policy error, and
|
|
396
|
+
* a transport error here would be retried instead.
|
|
397
|
+
*
|
|
314
398
|
* @throws {AnthropicProviderError} `STREAM_ERROR_EVENT` on an SSE error
|
|
315
399
|
* event, `STREAM_INCOMPLETE` when the stream ends before `message_delta`
|
|
316
400
|
* or a tool_use input JSON is truncated, plus whatever
|
|
@@ -336,7 +420,10 @@ export declare class AnthropicProvider implements IProvider {
|
|
|
336
420
|
* @param {ChatMessage[]} messages - Conversation messages.
|
|
337
421
|
* @param {ModelCompletionOptions} options - Completion options.
|
|
338
422
|
* @returns {AsyncGenerator<ModelCompletionResponse>} Incremental response chunks.
|
|
339
|
-
* @throws {AnthropicProviderError} On connection
|
|
423
|
+
* @throws {AnthropicProviderError} On connection errors, and with code
|
|
424
|
+
* `content_filter` when the model refuses (`stop_reason: 'refusal'`),
|
|
425
|
+
* before or after text has streamed. Other stream errors end the stream
|
|
426
|
+
* with an error chunk.
|
|
340
427
|
*/
|
|
341
428
|
generateCompletionStream(modelId: string, messages: ChatMessage[], options: ModelCompletionOptions): AsyncGenerator<ModelCompletionResponse, void, undefined>;
|
|
342
429
|
/**
|
|
@@ -479,7 +566,14 @@ export declare class AnthropicProvider implements IProvider {
|
|
|
479
566
|
* the stop reason from Anthropic's vocabulary to IProvider conventions.
|
|
480
567
|
*
|
|
481
568
|
* @param {AnthropicMessagesResponse} apiResponse - Raw Anthropic response.
|
|
569
|
+
* @param structuredOutputName - Name of the forced structured-output tool,
|
|
570
|
+
* whose input becomes the message content.
|
|
571
|
+
* @param requestedModelId - The model the request named. Prices the call
|
|
572
|
+
* when the response carries no model echo.
|
|
482
573
|
* @returns {ModelCompletionResponse} Normalized completion response.
|
|
574
|
+
* @throws {AnthropicProviderError} With code `content_filter` when the model
|
|
575
|
+
* refused (`stop_reason: 'refusal'`), whether or not it wrote any output
|
|
576
|
+
* first.
|
|
483
577
|
* @private
|
|
484
578
|
*/
|
|
485
579
|
private mapResponseToCompletion;
|
|
@@ -489,13 +583,37 @@ export declare class AnthropicProvider implements IProvider {
|
|
|
489
583
|
* - `end_turn` → `"stop"` (natural completion)
|
|
490
584
|
* - `tool_use` → `"tool_calls"` (model wants to invoke tools)
|
|
491
585
|
* - `max_tokens` → `"length"` (hit token limit)
|
|
586
|
+
* - `model_context_window_exceeded` → `"length"` (output cut off at the
|
|
587
|
+
* context window)
|
|
492
588
|
* - `stop_sequence` → `"stop"` (hit a caller-specified stop sequence)
|
|
589
|
+
* - `refusal` → `"content_filter"`, the name GeminiProvider and
|
|
590
|
+
* OpenAIProvider use. Both response paths raise a refusal as an error
|
|
591
|
+
* before a finish reason is reported; the mapping keeps the vocabulary
|
|
592
|
+
* complete.
|
|
593
|
+
* - anything else (such as `pause_turn`) passes through unchanged.
|
|
493
594
|
*
|
|
494
595
|
* @param {string | null} stopReason - Anthropic's stop_reason value.
|
|
495
596
|
* @returns {string} Normalized finish reason.
|
|
496
597
|
* @private
|
|
497
598
|
*/
|
|
498
599
|
private mapStopReason;
|
|
600
|
+
/**
|
|
601
|
+
* The error a refused turn raises. Code `content_filter` is what
|
|
602
|
+
* `isContentPolicyRefusal` recognizes, so the generateText and streamText
|
|
603
|
+
* fallback chains act on it, and the provider-health registry does not
|
|
604
|
+
* count it as a provider failure. The message carries no HTTP status or
|
|
605
|
+
* rate-limit wording, which retry classifiers grep for.
|
|
606
|
+
*
|
|
607
|
+
* @param modelId Model that refused.
|
|
608
|
+
* @param stopDetails The response's `stop_details`, kept verbatim.
|
|
609
|
+
* @param partialText Text the model wrote before refusing, discarded as an
|
|
610
|
+
* answer but kept for diagnostics.
|
|
611
|
+
* @param usage Tokens the refused call consumed.
|
|
612
|
+
* @returns An error with code `content_filter` and Anthropic error type
|
|
613
|
+
* `refusal`.
|
|
614
|
+
* @private
|
|
615
|
+
*/
|
|
616
|
+
private refusalError;
|
|
499
617
|
/**
|
|
500
618
|
* Assembles completed tool calls from the streaming accumulator.
|
|
501
619
|
*
|
|
@@ -504,42 +622,6 @@ export declare class AnthropicProvider implements IProvider {
|
|
|
504
622
|
* @private
|
|
505
623
|
*/
|
|
506
624
|
private assembleToolCalls;
|
|
507
|
-
/**
|
|
508
|
-
* Estimates USD cost for a given model and token counts.
|
|
509
|
-
*
|
|
510
|
-
* Looks up pricing from the static model catalog. Returns undefined
|
|
511
|
-
* if the model is not found in the catalog.
|
|
512
|
-
*
|
|
513
|
-
* @param {number} inputTokens - Number of input tokens.
|
|
514
|
-
* @param {number} outputTokens - Number of output tokens.
|
|
515
|
-
* @param {string} modelId - Model identifier for pricing lookup.
|
|
516
|
-
* @returns {number | undefined} Estimated cost in USD.
|
|
517
|
-
* @private
|
|
518
|
-
*/
|
|
519
|
-
/**
|
|
520
|
-
* Estimate cost in USD for a completion, including Anthropic's prompt-
|
|
521
|
-
* caching tier pricing.
|
|
522
|
-
*
|
|
523
|
-
* Anthropic billing tiers (as of 2025):
|
|
524
|
-
* input_tokens × 1.00 × base input rate (non-cached input)
|
|
525
|
-
* cache_read_input_tokens × 0.10 × base input rate (cache hit)
|
|
526
|
-
* cache_creation_input_tokens × 1.25 × base input rate (5-min TTL write)
|
|
527
|
-
* output_tokens × 1.00 × base output rate
|
|
528
|
-
*
|
|
529
|
-
* The API's `input_tokens` field already EXCLUDES cached tokens, so we
|
|
530
|
-
* sum three separate components for total input cost. Previous
|
|
531
|
-
* implementation used only `input_tokens` × rate, which happened to
|
|
532
|
-
* be correct for the non-cached portion but hid cache creation cost
|
|
533
|
-
* and ignored cache read cost entirely — meaning reported costUSD
|
|
534
|
-
* was always BELOW true billed amount whenever caching was active.
|
|
535
|
-
*
|
|
536
|
-
* 1-hour TTL cache-creation rate is 2× the base input rate, not 1.25×.
|
|
537
|
-
* We can't tell which TTL was used from the response, so we assume
|
|
538
|
-
* the default 5-minute tier. For long-lived cached contexts the
|
|
539
|
-
* reported cost will under-estimate by the 0.75× difference on
|
|
540
|
-
* creation tokens (minor; mostly one-shot at run start).
|
|
541
|
-
*/
|
|
542
|
-
private estimateCost;
|
|
543
625
|
/**
|
|
544
626
|
* Builds an abort chunk for early stream termination.
|
|
545
627
|
*
|
|
@@ -623,7 +705,11 @@ export declare class AnthropicProvider implements IProvider {
|
|
|
623
705
|
* Tool schemas are not secret; user message content never appears here.
|
|
624
706
|
*/
|
|
625
707
|
private logStrictSchemaRejection;
|
|
626
|
-
/**
|
|
708
|
+
/**
|
|
709
|
+
* True when the request enables extended thinking or replays thinking
|
|
710
|
+
* blocks. `{ type: 'disabled' }` turns thinking off; `between_tools` still
|
|
711
|
+
* returns thinking blocks between tool calls, so it counts.
|
|
712
|
+
*/
|
|
627
713
|
private payloadUsesThinking;
|
|
628
714
|
/**
|
|
629
715
|
* Parses an SSE (Server-Sent Events) stream from Anthropic.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AnthropicProvider.d.ts","sourceRoot":"","sources":["../../../../../src/core/llm/providers/implementations/AnthropicProvider.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EACL,SAAS,EACT,WAAW,EAGX,sBAAsB,EACtB,uBAAuB,EAEvB,SAAS,EAET,wBAAwB,EACxB,yBAAyB,EACzB,gBAAgB,EACjB,MAAM,cAAc,CAAC;AAKtB,OAAO,EAAE,6BAA6B,EAAE,MAAM,gCAAgC,CAAC;
|
|
1
|
+
{"version":3,"file":"AnthropicProvider.d.ts","sourceRoot":"","sources":["../../../../../src/core/llm/providers/implementations/AnthropicProvider.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EACL,SAAS,EACT,WAAW,EAGX,sBAAsB,EACtB,uBAAuB,EAEvB,SAAS,EAET,wBAAwB,EACxB,yBAAyB,EACzB,gBAAgB,EACjB,MAAM,cAAc,CAAC;AAKtB,OAAO,EAAE,6BAA6B,EAAE,MAAM,gCAAgC,CAAC;AAgB/E,OAAO,EAAE,6BAA6B,EAAE,CAAC;AAMzC;;;;;;;;;GASG;AACH,MAAM,WAAW,uBAAuB;IACtC;;;OAGG;IACH,MAAM,EAAE,MAAM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