@warlock.js/ai-anthropic 5.29.0 → 5.31.0
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/CHANGELOG.md +63 -0
- package/cjs/index.cjs +1124 -147
- package/cjs/index.cjs.map +1 -1
- package/esm/config.type.d.mts +170 -3
- package/esm/config.type.d.mts.map +1 -1
- package/esm/index.d.mts +9 -3
- package/esm/index.mjs +8 -1
- package/esm/known-output-limits.mjs +46 -0
- package/esm/known-output-limits.mjs.map +1 -0
- package/esm/known-pricing.d.mts +58 -0
- package/esm/known-pricing.d.mts.map +1 -0
- package/esm/known-pricing.mjs +165 -0
- package/esm/known-pricing.mjs.map +1 -0
- package/esm/known-vision-models.mjs +1 -1
- package/esm/known-vision-models.mjs.map +1 -1
- package/esm/model.d.mts +322 -0
- package/esm/model.d.mts.map +1 -0
- package/esm/model.mjs +523 -73
- package/esm/model.mjs.map +1 -1
- package/esm/request.type.d.mts +25 -0
- package/esm/request.type.d.mts.map +1 -0
- package/esm/sdk.d.mts +7 -6
- package/esm/sdk.d.mts.map +1 -1
- package/esm/sdk.mjs +4 -4
- package/esm/sdk.mjs.map +1 -1
- package/esm/thinking-mode.d.mts +15 -2
- package/esm/thinking-mode.d.mts.map +1 -1
- package/esm/thinking-mode.mjs +128 -2
- package/esm/thinking-mode.mjs.map +1 -1
- package/esm/utils/cache-usage.mjs +62 -0
- package/esm/utils/cache-usage.mjs.map +1 -0
- package/esm/utils/index.d.mts +3 -0
- package/esm/utils/index.mjs +1 -0
- package/esm/utils/map-stop-reason.d.mts +1 -0
- package/esm/utils/map-stop-reason.mjs +17 -13
- package/esm/utils/map-stop-reason.mjs.map +1 -1
- package/esm/utils/provider-blocks.d.mts +39 -0
- package/esm/utils/provider-blocks.d.mts.map +1 -0
- package/esm/utils/provider-blocks.mjs +83 -0
- package/esm/utils/provider-blocks.mjs.map +1 -0
- package/esm/utils/to-anthropic-messages.d.mts +71 -0
- package/esm/utils/to-anthropic-messages.d.mts.map +1 -0
- package/esm/utils/to-anthropic-messages.mjs +53 -13
- package/esm/utils/to-anthropic-messages.mjs.map +1 -1
- package/esm/utils/to-anthropic-tools.d.mts +19 -0
- package/esm/utils/to-anthropic-tools.d.mts.map +1 -0
- package/esm/utils/to-anthropic-tools.mjs +1 -1
- package/esm/utils/to-anthropic-tools.mjs.map +1 -1
- package/esm/utils/wrap-anthropic-error.d.mts +1 -0
- package/esm/utils/wrap-anthropic-error.mjs +7 -2
- package/esm/utils/wrap-anthropic-error.mjs.map +1 -1
- package/llms-full.txt +273 -27
- package/llms.txt +1 -1
- package/package.json +5 -4
- package/skills/README.md +1 -1
- package/skills/setup-anthropic/SKILL.md +273 -27
package/esm/model.d.mts
ADDED
|
@@ -0,0 +1,322 @@
|
|
|
1
|
+
import { AnthropicModelConfig } from "./config.type.mjs";
|
|
2
|
+
import { AnthropicNonStreamingRequest, AnthropicRequest, AnthropicRequestOptions, AnthropicStreamingRequest } from "./request.type.mjs";
|
|
3
|
+
import Anthropic from "@anthropic-ai/sdk";
|
|
4
|
+
import { Message, ModelCallOptions, ModelCapabilities, ModelContract, ModelPricing, ModelResponse, ModelStreamChunk } from "@warlock.js/ai";
|
|
5
|
+
|
|
6
|
+
//#region ../../packages/ai-anthropic/src/model.d.ts
|
|
7
|
+
/**
|
|
8
|
+
* Anthropic-backed implementation of `ModelContract`.
|
|
9
|
+
*
|
|
10
|
+
* **Role.** The provider-facing bridge between the vendor-neutral
|
|
11
|
+
* `@warlock.js/ai` agent runtime and the official `@anthropic-ai/sdk`
|
|
12
|
+
* Messages API. Agents, workflows, and supervisors never talk to
|
|
13
|
+
* Anthropic directly — they hold a `ModelContract`, and this class is
|
|
14
|
+
* what makes that contract concrete for Claude models.
|
|
15
|
+
*
|
|
16
|
+
* **Responsibility.**
|
|
17
|
+
* - Owns: a long-lived `Anthropic` client + frozen `ModelConfig`
|
|
18
|
+
* (name, temperature, maxTokens) used as defaults for every call.
|
|
19
|
+
* - Owns: translating vendor-neutral `Message[]` / `ToolConfig[]` into
|
|
20
|
+
* Anthropic wire shapes (system hoisting, `tool_use` / `tool_result`
|
|
21
|
+
* blocks) on the way out, and translating Anthropic's content-block
|
|
22
|
+
* response (text, tool calls, stop reason, usage) back into the
|
|
23
|
+
* neutral shapes on the way in.
|
|
24
|
+
* - Does NOT own: dispatching tools, deciding whether to loop, tracking
|
|
25
|
+
* conversation history, or retrying on failure — those are agent
|
|
26
|
+
* concerns. The model is a stateless (per-call) protocol adapter.
|
|
27
|
+
*
|
|
28
|
+
* Because it holds a live client and shared defaults, it is modeled as
|
|
29
|
+
* a class (see §4.2 of code-style.md — "long-lived state across
|
|
30
|
+
* calls").
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* import Anthropic from "@anthropic-ai/sdk";
|
|
34
|
+
* const client = new Anthropic({ apiKey: process.env.ANTHROPIC_API_KEY });
|
|
35
|
+
* const model = new AnthropicModel(client, { name: "claude-sonnet-4-6" });
|
|
36
|
+
*
|
|
37
|
+
* const myAgent = agent({
|
|
38
|
+
* model,
|
|
39
|
+
* systemPrompt: "You are a helpful assistant.",
|
|
40
|
+
* tools: [searchTool],
|
|
41
|
+
* });
|
|
42
|
+
*
|
|
43
|
+
* const result = await myAgent.execute("Summarize today's news.");
|
|
44
|
+
*/
|
|
45
|
+
declare class AnthropicModel implements ModelContract {
|
|
46
|
+
readonly name: string;
|
|
47
|
+
readonly provider: string;
|
|
48
|
+
readonly capabilities: ModelCapabilities;
|
|
49
|
+
readonly pricing?: ModelPricing;
|
|
50
|
+
private readonly client;
|
|
51
|
+
private readonly config;
|
|
52
|
+
private readonly thinkingMode;
|
|
53
|
+
/** Documented max output tokens of this model, when known. Sizes the default `max_tokens`. */
|
|
54
|
+
private readonly maxOutputTokens?;
|
|
55
|
+
private readonly preservedThinking;
|
|
56
|
+
private readonly logger;
|
|
57
|
+
constructor(client: Anthropic, config: AnthropicModelConfig, provider?: string);
|
|
58
|
+
/**
|
|
59
|
+
* Single-shot completion. Sends the full message list to the Messages
|
|
60
|
+
* endpoint, waits for the terminal response, and reshapes it into a
|
|
61
|
+
* vendor-neutral `ModelResponse`. Per-call `options` override the
|
|
62
|
+
* instance's `ModelConfig` defaults for this call only.
|
|
63
|
+
*/
|
|
64
|
+
complete(messages: Message[], options?: ModelCallOptions): Promise<ModelResponse>;
|
|
65
|
+
/** Build a detached request snapshot without sending it to Anthropic. */
|
|
66
|
+
buildRequest(messages: Message[], options: ModelCallOptions & {
|
|
67
|
+
stream: true;
|
|
68
|
+
}): AnthropicStreamingRequest;
|
|
69
|
+
buildRequest(messages: Message[], options?: ModelCallOptions & {
|
|
70
|
+
stream?: false;
|
|
71
|
+
}): AnthropicNonStreamingRequest;
|
|
72
|
+
buildRequest(messages: Message[], options?: ModelCallOptions & {
|
|
73
|
+
stream?: boolean;
|
|
74
|
+
}): AnthropicRequest;
|
|
75
|
+
/**
|
|
76
|
+
* `buildRequest()` for the adapter's own calls: a build failure (a reserved
|
|
77
|
+
* body key, a `providerOptions.anthropic.body` value `structuredClone`
|
|
78
|
+
* cannot copy) is logged like a send failure and rejects as an `AIError`.
|
|
79
|
+
* Errors that are not already an `AIError` become an `InvalidRequestError`,
|
|
80
|
+
* since nothing reached Anthropic and retrying cannot help.
|
|
81
|
+
*/
|
|
82
|
+
private buildLoggedRequest;
|
|
83
|
+
/** Send a built request without rebuilding its body or applying model defaults. */
|
|
84
|
+
send(request: AnthropicNonStreamingRequest, options?: AnthropicRequestOptions): Promise<ModelResponse>;
|
|
85
|
+
send(request: AnthropicStreamingRequest, options?: AnthropicRequestOptions): AsyncIterable<ModelStreamChunk>;
|
|
86
|
+
send(request: AnthropicRequest, options?: AnthropicRequestOptions): Promise<ModelResponse> | AsyncIterable<ModelStreamChunk>;
|
|
87
|
+
private completeRequest;
|
|
88
|
+
/**
|
|
89
|
+
* Count the input tokens a request would use, through Anthropic's
|
|
90
|
+
* `messages.countTokens` endpoint (a network call; no tokens are
|
|
91
|
+
* generated or billed as output). Takes the same messages and options
|
|
92
|
+
* as `complete()` — system prompt, tools, thinking and
|
|
93
|
+
* `providerOptions.anthropic.betas` are counted exactly as they would be
|
|
94
|
+
* sent. For an offline estimate use `AnthropicSDK.count()`.
|
|
95
|
+
*
|
|
96
|
+
* @example
|
|
97
|
+
* const tokens = await model.countTokens(messages, { tools });
|
|
98
|
+
*/
|
|
99
|
+
countTokens(messages: Message[], options?: ModelCallOptions): Promise<number>;
|
|
100
|
+
/**
|
|
101
|
+
* Incremental streaming completion. Yields neutral `ModelStreamChunk`s
|
|
102
|
+
* — `delta` for text tokens, `tool-call` once a `tool_use` block's
|
|
103
|
+
* arguments have fully accumulated, and a terminal `done` carrying the
|
|
104
|
+
* final finish reason + usage totals. Callers consume it with
|
|
105
|
+
* `for await`.
|
|
106
|
+
*
|
|
107
|
+
* With `options.streamChunks` it also yields `reasoning` for every
|
|
108
|
+
* non-empty `thinking_delta`, `tool-args` for every `input_json_delta`
|
|
109
|
+
* of a client `tool_use` block, and `usage` after `message_start` and
|
|
110
|
+
* each `message_delta` (whose counts are cumulative).
|
|
111
|
+
*/
|
|
112
|
+
stream(messages: Message[], options?: ModelCallOptions): AsyncIterable<ModelStreamChunk>;
|
|
113
|
+
private streamRequest;
|
|
114
|
+
/**
|
|
115
|
+
* Fold one stream event into the per-index block accumulator. Unknown
|
|
116
|
+
* block and delta types (beta `compaction`, future additions) are kept
|
|
117
|
+
* as their start payload plus whatever their delta carries, so they
|
|
118
|
+
* round-trip without the adapter knowing their shape.
|
|
119
|
+
*/
|
|
120
|
+
private trackStreamedBlock;
|
|
121
|
+
/** Close the accumulated stream blocks into an ordered content array. */
|
|
122
|
+
private finishStreamedBlocks;
|
|
123
|
+
/**
|
|
124
|
+
* Send a request through the SDK. With `providerOptions.anthropic.betas`
|
|
125
|
+
* the call goes to `client.beta.messages` (which takes the `betas` list
|
|
126
|
+
* and the beta-only body fields); otherwise to `client.messages`. The
|
|
127
|
+
* cancellation signal rides in the request options, as before.
|
|
128
|
+
*/
|
|
129
|
+
private dispatch;
|
|
130
|
+
/**
|
|
131
|
+
* The full request body and the beta flags it needs: the adapter-built
|
|
132
|
+
* params, then `thinking.display` when thinking is sent on an adaptive
|
|
133
|
+
* model, the typed `thinkingBlockBinding`, `contextManagement` and
|
|
134
|
+
* `serverCompaction` options, then `providerOptions.anthropic.body`
|
|
135
|
+
* merged last (caller fields win). The body may add fields the adapter
|
|
136
|
+
* does not build (`fallbacks`, …) but may not replace the conversation or
|
|
137
|
+
* the model — see {@link RESERVED_BODY_FIELDS}.
|
|
138
|
+
*/
|
|
139
|
+
private buildBody;
|
|
140
|
+
/**
|
|
141
|
+
* Set `thinking.block_binding.prefix_mismatch_behavior`. It rides on
|
|
142
|
+
* adaptive or budget (`enabled`) thinking. A model that runs adaptive
|
|
143
|
+
* thinking when `thinking` is omitted (every preserved-thinking model) gets
|
|
144
|
+
* an explicit `{ type: "adaptive" }`, which is the same request. Any other
|
|
145
|
+
* shape (`between_tools`, `disabled`) takes no extra field, so the option
|
|
146
|
+
* is skipped with a debug log.
|
|
147
|
+
*/
|
|
148
|
+
private applyBlockBinding;
|
|
149
|
+
/**
|
|
150
|
+
* Assemble the Anthropic request body shared by `complete()` and
|
|
151
|
+
* `stream()` (each adds its own `stream` literal so the SDK's create
|
|
152
|
+
* overload resolves to the right return type). Hoists the system
|
|
153
|
+
* prompt out of `messages`, resolves `max_tokens` (required by
|
|
154
|
+
* Anthropic) with the documented default, and conditionally attaches
|
|
155
|
+
* temperature, tools, native structured output, extended thinking
|
|
156
|
+
* (`reasoning`), and automatic or explicit prompt-cache control.
|
|
157
|
+
* Temperature is dropped when thinking is enabled, since Anthropic
|
|
158
|
+
* rejects the two together, and always for adaptive-mode models, which
|
|
159
|
+
* reject any explicit temperature (see `acceptsTemperature`).
|
|
160
|
+
*/
|
|
161
|
+
private buildParams;
|
|
162
|
+
/**
|
|
163
|
+
* The `max_tokens` sent when neither the call nor the model config sets
|
|
164
|
+
* `maxTokens`:
|
|
165
|
+
*
|
|
166
|
+
* - streaming: the model's documented max output, or
|
|
167
|
+
* `DEFAULT_MAX_TOKENS` (16384) for an unknown id;
|
|
168
|
+
* - non-streaming: `DEFAULT_MAX_TOKENS`, capped by the model's max output
|
|
169
|
+
* (the SDK requires streaming for larger non-streaming requests unless
|
|
170
|
+
* the client sets a `timeout`; see `DEFAULT_MAX_TOKENS`).
|
|
171
|
+
*
|
|
172
|
+
* With thinking on, the value is raised to at least the thinking budget
|
|
173
|
+
* plus `MIN_ANSWER_TOKENS`, and never exceeds the model's max output.
|
|
174
|
+
*/
|
|
175
|
+
private resolveDefaultMaxTokens;
|
|
176
|
+
/**
|
|
177
|
+
* Spread-friendly `system` fragment. Returns an empty object when no
|
|
178
|
+
* system prompt was hoisted out of the messages.
|
|
179
|
+
*
|
|
180
|
+
* When a per-call `cacheControl.breakpoints` hint is present (≥ 1),
|
|
181
|
+
* the system prompt is emitted as a single `TextBlockParam` carrying
|
|
182
|
+
* `cache_control: ephemeral` — the system prompt is the longest stable
|
|
183
|
+
* prefix on a turn, so one breakpoint there lets multi-turn agents
|
|
184
|
+
* read it back at the ~0.1x cache-read rate. Without the hint the
|
|
185
|
+
* system prompt stays a plain string (left uncached) so a one-shot
|
|
186
|
+
* call never pays the ~1.25x cache-write surcharge.
|
|
187
|
+
*/
|
|
188
|
+
private buildSystem;
|
|
189
|
+
/**
|
|
190
|
+
* Let Anthropic select the last cacheable block when caching is enabled
|
|
191
|
+
* without a caller-selected breakpoint. An explicit breakpoint remains
|
|
192
|
+
* authoritative, so the request-level form is deliberately omitted then.
|
|
193
|
+
*/
|
|
194
|
+
private buildAutomaticCacheControl;
|
|
195
|
+
/**
|
|
196
|
+
* Build a typed cache-control marker. The per-call
|
|
197
|
+
* `cacheControl.ttl` wins over the model's `promptCacheTtl`; with
|
|
198
|
+
* neither, TTL is omitted for Anthropic's 5-minute default.
|
|
199
|
+
*/
|
|
200
|
+
private cacheControl;
|
|
201
|
+
/**
|
|
202
|
+
* Translate the neutral `reasoning` option into Anthropic's thinking
|
|
203
|
+
* settings, in the shape this model accepts (`thinkingMode`). Emitted
|
|
204
|
+
* only when the model declares the `reasoning` capability AND a
|
|
205
|
+
* reasoning option is supplied; otherwise returns an empty object.
|
|
206
|
+
*
|
|
207
|
+
* - Adaptive mode (Opus 4.7+, Sonnet 5+, Fable 5+, unknown ids):
|
|
208
|
+
* `thinking: { type: "adaptive" }` (installed SDK
|
|
209
|
+
* `ThinkingConfigAdaptive`, `messages.d.ts:1065`) plus
|
|
210
|
+
* `output_config.effort` from the neutral effort, defaulting to
|
|
211
|
+
* `"medium"`. `budget_tokens` is never sent — these models 400 on it
|
|
212
|
+
* (claude-api ref). `reasoning.maxTokens` only sizes the default
|
|
213
|
+
* `max_tokens` headroom.
|
|
214
|
+
* - Budget mode (Haiku 4.5, Opus/Sonnet 4.6, older):
|
|
215
|
+
* `thinking: { type: "enabled", budget_tokens }`. An explicit
|
|
216
|
+
* `reasoning.maxTokens` wins; otherwise the effort maps to a tiered
|
|
217
|
+
* budget. `budget_tokens` must be ≥ 1024 (`ThinkingConfigEnabled`,
|
|
218
|
+
* `messages.d.ts:1084`), so the budget is floored at that minimum.
|
|
219
|
+
*
|
|
220
|
+
* The neutral `effort: "none"` ("run without reasoning") is mapped per
|
|
221
|
+
* model by `noReasoningForm` (see `thinking-mode.ts` for the sources):
|
|
222
|
+
* - Claude Sonnet 5.5: `thinking: { type: "between_tools" }`, its only
|
|
223
|
+
* thinking-off form. It is sent alone — no `output_config.effort` (the
|
|
224
|
+
* model default, `high`, is within the `high`-or-below range it
|
|
225
|
+
* requires) and no `display`, both of which the API rejects alongside it.
|
|
226
|
+
* - Claude Sonnet 5 and Claude Haiku 5.5: `thinking: { type: "disabled" }`
|
|
227
|
+
* with no effort and no `display`. Haiku 5.5 accepts `disabled` only at
|
|
228
|
+
* effort `high` or below; its default (`medium`) applies.
|
|
229
|
+
* - Claude Opus 5: adaptive thinking at `output_config.effort: "low"`.
|
|
230
|
+
* Opus 5 accepts `disabled`, but with it the model can write a tool call
|
|
231
|
+
* as plain text (the call never runs) and leak thinking tags; the lowest
|
|
232
|
+
* effort is the documented alternative.
|
|
233
|
+
* - Opus 5.5 and Fable 5/5.1: no `thinking` field. These models have no
|
|
234
|
+
* thinking-off form (`disabled` and `budget_tokens` are a 400 at every
|
|
235
|
+
* effort), so thinking still runs at the model's default effort. Pass
|
|
236
|
+
* `effort: "low"` to spend less.
|
|
237
|
+
* - Every other model: no `thinking` field, as before.
|
|
238
|
+
*/
|
|
239
|
+
private buildThinking;
|
|
240
|
+
/**
|
|
241
|
+
* The thinking settings for `reasoning: { effort: "none" }`, per
|
|
242
|
+
* `noReasoningForm(this.name)` (documented on `buildThinking`).
|
|
243
|
+
*/
|
|
244
|
+
private buildNoReasoning;
|
|
245
|
+
/**
|
|
246
|
+
* Spread-friendly tools fragment. Returns an empty object when no
|
|
247
|
+
* tools were supplied so the caller can unconditionally spread it.
|
|
248
|
+
*
|
|
249
|
+
* When `config.promptCaching` is on, marks the LAST tool with
|
|
250
|
+
* `cache_control: ephemeral` — Anthropic caches the whole prefix up
|
|
251
|
+
* to a breakpoint, and tools sit before `system` in that prefix, so
|
|
252
|
+
* one breakpoint on the final tool caches every tool definition.
|
|
253
|
+
* Reads bill at ~0.1x after the first write. The system prompt is
|
|
254
|
+
* deliberately left uncached: it carries per-turn placeholders, so a
|
|
255
|
+
* breakpoint there would pay the ~1.25x write surcharge every turn
|
|
256
|
+
* with no reads.
|
|
257
|
+
*/
|
|
258
|
+
private buildTools;
|
|
259
|
+
/**
|
|
260
|
+
* Spread-friendly `output_config` fragment carrying both the native
|
|
261
|
+
* structured-output `format` and the adaptive-thinking `effort`, merged
|
|
262
|
+
* into one object (both live under `OutputConfig`, installed SDK
|
|
263
|
+
* `messages.d.ts:796-806`). Returns an empty object when neither applies,
|
|
264
|
+
* so budget-mode requests carry `output_config` only when a schema asks
|
|
265
|
+
* for it.
|
|
266
|
+
*/
|
|
267
|
+
private buildOutputConfig;
|
|
268
|
+
/**
|
|
269
|
+
* Translate the neutral `responseSchema` option into Anthropic's
|
|
270
|
+
* native `output_config.format` (JSON-schema structured outputs).
|
|
271
|
+
*
|
|
272
|
+
* Only returned when the model declares the `structuredOutput`
|
|
273
|
+
* capability AND the schema is a proper root-object JSON Schema —
|
|
274
|
+
* Anthropic rejects non-object roots. When the capability is off
|
|
275
|
+
* (config override) or the schema is non-object, returns `undefined`:
|
|
276
|
+
* the agent has already injected a soft schema hint into the system
|
|
277
|
+
* prompt as the fallback, and client-side `validate()` still enforces
|
|
278
|
+
* shape.
|
|
279
|
+
*/
|
|
280
|
+
private buildStructuredOutputFormat;
|
|
281
|
+
/**
|
|
282
|
+
* Concatenate every `text` content block into the single neutral
|
|
283
|
+
* `content` string. `tool_use` and other block types are ignored
|
|
284
|
+
* here — tool calls are surfaced separately via `extractToolCalls`.
|
|
285
|
+
*/
|
|
286
|
+
private extractText;
|
|
287
|
+
/**
|
|
288
|
+
* Reshape Anthropic's `tool_use` content blocks into the neutral
|
|
289
|
+
* `ModelToolCallRequest[]`. Returns `undefined` when the model
|
|
290
|
+
* requested no tools so callers can branch on presence.
|
|
291
|
+
*/
|
|
292
|
+
private extractToolCalls;
|
|
293
|
+
/**
|
|
294
|
+
* Preserve Anthropic's opaque extended-thinking blocks beside a tool
|
|
295
|
+
* request so the next assistant turn can replay their signatures exactly.
|
|
296
|
+
*/
|
|
297
|
+
private buildThinkingMetadata;
|
|
298
|
+
/**
|
|
299
|
+
* Normalize Anthropic's `usage` block into the neutral `Usage` shape.
|
|
300
|
+
* Anthropic reports `input_tokens` / `output_tokens` separately with
|
|
301
|
+
* no pre-summed total, so `total` is computed. `input_tokens` is the
|
|
302
|
+
* uncached remainder only — cache reads (`cachedTokens`) and writes
|
|
303
|
+
* (`cacheWriteTokens`, with the 1-hour share in `cacheWrite1hTokens`)
|
|
304
|
+
* come on top of it — so the usage is marked
|
|
305
|
+
* `inputIncludesCache: false`. Anthropic also reports
|
|
306
|
+
* `output_tokens_details.thinking_tokens` as the reasoning subset of
|
|
307
|
+
* its inclusive `output_tokens`; it is surfaced as `reasoningTokens`
|
|
308
|
+
* when present, without changing the billing total. Server-side
|
|
309
|
+
* compaction iterations are added in (see {@link compactionIterationUsage}).
|
|
310
|
+
* `cost` is attached when the model is priced.
|
|
311
|
+
*/
|
|
312
|
+
private extractUsage;
|
|
313
|
+
/**
|
|
314
|
+
* Wrap a thrown provider error into the typed `AIError` hierarchy and
|
|
315
|
+
* emit the standard error log line before it propagates. Shared by
|
|
316
|
+
* every catch site so the log shape stays identical.
|
|
317
|
+
*/
|
|
318
|
+
private logAndWrap;
|
|
319
|
+
}
|
|
320
|
+
//#endregion
|
|
321
|
+
export { AnthropicModel };
|
|
322
|
+
//# sourceMappingURL=model.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model.d.mts","names":[],"sources":["../../../../../../../packages/ai-anthropic/src/model.ts"],"mappings":";;;;;;;;AAmNA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAAa,cAAA,YAA0B,aAAA;EAAA,SACrB,IAAA;EAAA,SACA,QAAA;EAAA,SACA,YAAA,EAAc,iBAAA;EAAA,SACd,OAAA,GAAU,YAAA;EAAA,iBAET,MAAA;EAAA,iBACA,MAAA;EAAA,iBACA,YAAA;EARoB;EAAA,iBAUpB,eAAA;EAAA,iBACA,iBAAA;EAAA,iBACA,MAAA;cAGf,MAAA,EAAQ,SAAA,EACR,MAAA,EAAQ,oBAAA,EACR,QAAA;EAbc;;;;;;EA6DH,QAAA,CAAS,QAAA,EAAU,OAAA,IAAW,OAAA,GAAU,gBAAA,GAAmB,OAAA,CAAQ,aAAA;EArD/D;EA4DV,YAAA,CACL,QAAA,EAAU,OAAA,IACV,OAAA,EAAS,gBAAA;IAAqB,MAAA;EAAA,IAC7B,yBAAA;EACI,YAAA,CACL,QAAA,EAAU,OAAA,IACV,OAAA,GAAU,gBAAA;IAAqB,MAAA;EAAA,IAC9B,4BAAA;EACI,YAAA,CACL,QAAA,EAAU,OAAA,IACV,OAAA,GAAU,gBAAA;IAAqB,MAAA;EAAA,IAC9B,gBAAA;EAlBkD;;;;;;;EAAA,QAqC7C,kBAAA;EA5BwB;EA2DzB,IAAA,CACL,OAAA,EAAS,4BAAA,EACT,OAAA,GAAU,uBAAA,GACT,OAAA,CAAQ,aAAA;EACJ,IAAA,CACL,OAAA,EAAS,yBAAA,EACT,OAAA,GAAU,uBAAA,GACT,aAAA,CAAc,gBAAA;EACV,IAAA,CACL,OAAA,EAAS,gBAAA,EACT,OAAA,GAAU,uBAAA,GACT,OAAA,CAAQ,aAAA,IAAiB,aAAA,CAAc,gBAAA;EAAA,QAqB5B,eAAA;EAxFZ;;;;;;;;;;;EAkIW,WAAA,CAAY,QAAA,EAAU,OAAA,IAAW,OAAA,GAAU,gBAAA,GAAmB,OAAA;EAzGnE;;;;;;;;;;;;EAkJM,MAAA,CACZ,QAAA,EAAU,OAAA,IACV,OAAA,GAAU,gBAAA,GACT,aAAA,CAAc,gBAAA;EAAA,QAOF,aAAA;EAtHE;;;;;;EAAA,QA4TT,kBAAA;EAxTG;EAAA,QA4WH,oBAAA;EA5WkC;;;;;;EAAA,QA8XlC,QAAA;EA/TmE;;;;;;;;;EAAA,QA+VnE,SAAA;EAlDA;;;;;;;;EAAA,QAiIA,iBAAA;EA+MA;;;;;;;;;;;AAgQU;EAhQV,QAzKA,WAAA;;;;;;;;;;;;;;UA2DA,uBAAA;;;;;;;;;;;;;UAsBA,WAAA;;;;;;UA0BA,0BAAA;;;;;;UAeA,YAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UA+CA,aAAA;;;;;UAwCA,gBAAA;;;;;;;;;;;;;;UA8BA,UAAA;;;;;;;;;UAyCA,iBAAA;;;;;;;;;;;;;UA8BA,2BAAA;;;;;;UAmBA,WAAA;;;;;;UAYA,gBAAA;;;;;UAuBA,qBAAA;;;;;;;;;;;;;;;UA6BA,YAAA;;;;;;UAgCA,UAAA;AAAA"}
|