@namzu/anthropic 3.4.0 → 4.0.1
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 +181 -0
- package/README.md +9 -3
- package/dist/client.d.ts +3 -2
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +219 -44
- package/dist/client.js.map +1 -1
- package/dist/thinking-capability.d.ts +4 -5
- package/dist/thinking-capability.d.ts.map +1 -1
- package/dist/thinking-capability.js +9 -6
- package/dist/thinking-capability.js.map +1 -1
- package/package.json +2 -2
- package/src/client.ts +275 -51
- package/src/thinking-capability.ts +15 -6
|
@@ -194,7 +194,11 @@ export function resolveThinkingCapability(model: string): ThinkingCapability {
|
|
|
194
194
|
/** The `thinking` body value, or `undefined` to send no thinking field. */
|
|
195
195
|
export type ResolvedThinkingBody =
|
|
196
196
|
| { type: 'adaptive'; display?: 'summarized' | 'omitted' }
|
|
197
|
-
| {
|
|
197
|
+
| {
|
|
198
|
+
type: 'enabled'
|
|
199
|
+
budget_tokens?: number
|
|
200
|
+
display?: 'summarized' | 'omitted'
|
|
201
|
+
}
|
|
198
202
|
| { type: 'disabled' }
|
|
199
203
|
| undefined
|
|
200
204
|
|
|
@@ -253,10 +257,9 @@ export function resolveThinkingBody(
|
|
|
253
257
|
* arrived with 4.7, and `max` does not exist below 4.6 — so `capability.effort`
|
|
254
258
|
* is a set rather than a flag. It was a flag, which meant `xhigh` on a 4.6 and
|
|
255
259
|
* `max` on a 4.5 were forwarded to a vendor that rejects an unknown level
|
|
256
|
-
* rather than clamping it.
|
|
257
|
-
*
|
|
258
|
-
*
|
|
259
|
-
* refusing would fail a call that has a correct answer.
|
|
260
|
+
* rather than clamping it. Refusing before transport is the only truthful
|
|
261
|
+
* outcome: silently dropping a caller's effort changes the request to the
|
|
262
|
+
* model default while reporting that the requested control was honoured.
|
|
260
263
|
*
|
|
261
264
|
* The COMBINATION has to be legal, and the legal set is per model rather than
|
|
262
265
|
* universal. Opus 5 accepts `thinking: {type: "disabled"}` at `high` or below
|
|
@@ -274,9 +277,15 @@ export function resolveEffort(
|
|
|
274
277
|
effort: ReasoningEffort | undefined,
|
|
275
278
|
thinkingBody: ResolvedThinkingBody,
|
|
276
279
|
capability: ThinkingCapability,
|
|
280
|
+
model?: string,
|
|
277
281
|
): ReasoningEffort | undefined {
|
|
278
282
|
if (effort === undefined) return undefined
|
|
279
283
|
const allowed =
|
|
280
284
|
thinkingBody?.type === 'disabled' ? capability.effortWhenDisabled : capability.effort
|
|
281
|
-
|
|
285
|
+
if (allowed.includes(effort)) return effort
|
|
286
|
+
const target = model ? ` by model "${model}"` : ' by this model/thinking combination'
|
|
287
|
+
const offered = allowed.length > 0 ? allowed.join(', ') : 'none'
|
|
288
|
+
throw new Error(
|
|
289
|
+
`AnthropicProvider: effort "${effort}" is not supported${target}. Supported levels: ${offered}. Choose one of those levels or omit \`effort\`.`,
|
|
290
|
+
)
|
|
282
291
|
}
|