@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.
@@ -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
- | { type: 'enabled'; budget_tokens?: number; display?: 'summarized' | 'omitted' }
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. Dropping the field is right where the level does
257
- * not exist: `effort` shapes an answer the model will still produce, so a
258
- * request without it is the same request at the model's own default, whereas
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
- return allowed.includes(effort) ? effort : undefined
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
  }