@ai-sdk/anthropic 4.0.93 → 4.0.95

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.
@@ -2128,6 +2128,18 @@ export declare function prepareTools({ tools, toolChoice, disableParallelToolUse
2128
2128
  */
2129
2129
  export declare function sanitizeJsonSchema(schema: JSONSchema7): JSONSchema7;
2130
2130
  //#endregion
2131
+ //#region src/supports-native-structured-output-schema.d.ts
2132
+ /**
2133
+ * Whether Anthropic's native structured outputs (`output_config.format`) can
2134
+ * represent a schema without rejecting it or losing data.
2135
+ *
2136
+ * Rejected: self-referencing schemas, and schemas with too many optional
2137
+ * properties. Lossy: open objects (maps, free-form objects), which native
2138
+ * structured outputs close with `additionalProperties: false`, so the model
2139
+ * can only return `{}` for them.
2140
+ */
2141
+ export declare function supportsNativeStructuredOutputSchema(schema: JSONSchema7): boolean;
2142
+ //#endregion
2131
2143
  //#region src/skills/anthropic-skills.d.ts
2132
2144
  interface AnthropicSkillsConfig {
2133
2145
  provider: string;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":["_$__anthropic_api0.AnthropicToolChoice","_$__anthropic_api0.AnthropicTextContent","_$__anthropic_api0.AnthropicMessage","SandboxSession","SandboxSession","_$__tool_computer_toolset_202608010.ComputerToolset_20260801Member"],"sources":["../../src/anthropic-files.ts","../../src/anthropic-api.ts","../../src/anthropic-language-model-options.ts","../../src/get-cache-control.ts","../../src/convert-to-anthropic-prompt.ts","../../src/anthropic-model-catalog.ts","../../src/anthropic-language-model.ts","../../src/tool/computer-toolset_20260801.ts","../../src/tool/bash_20241022.ts","../../src/tool/bash_20250124.ts","../../src/anthropic-tools.ts","../../src/anthropic-prepare-tools.ts","../../src/sanitize-json-schema.ts","../../src/skills/anthropic-skills.ts"],"mappings":";;;;UAiCU;EACR;EACA;EACA,SAAS,WAAW;EACpB,QAAQ;;qBAGG,0BAA0B;mBAOR;WANpB;MAEL;EAIyB,YAAA,QAAQ;EAE/B,aACJ,MACA,WACA,UACA,aACA,WACC,+BAA+B,QAAQ;;;;KC1ChC,mBACR,uBACA,4BACA;KAEQ;EACV;EACA;;UAGe;EACf;EACA,SAAS,MAAM,uBAAuB;EACtC;EACA;IACE;;;;;;;;;;UAWa;EACf;EACA;IAAQ;IAAwB;;EAChC;;UAGe;EACf;EACA,SAAS,MACL,uBACA,wBACA,wBACA,2BACA,kCACA;;UAIW;EACf;EACA,SAAS,MACL,uBACA,2BACA,mCACA,2BACA,2BACA,gCACA,0CACA,qCACA,sCACA,uCACA,8CACA,oDACA,oCACA,6BACA,gCACA;;cAIO,sCAA8B,EAAA;;;;;;;;GAKvC,EAAA,KAAA;KAKQ,2BAA2B,YACrC,kBAAkB;EAElB;;UAGe;EACf;EACA;EACA;EACA,gBAAgB;;UAGD;EACf;EACA;EACA,YAAY;EACZ,eAAe;;UAGA;EACf;EACA;EACA;EAGA;;UAGe;EACf;EACA;EAGA;;KAGG;EAEC;EACA;EACA;;EAGA;EACA;;EAGA;EACA;EACA;;EAGA;EACA;;UAGW;EACf;EACA,QAAQ;EACR,eAAe;;;UAIA;EACf;EACA,QAAQ;EACR,eAAe;;UAGA;EACf;EACA,QAAQ;EACR;EACA;EACA;IAAc;;EACd,eAAe;;UAGA;EACf;EACA;EACA;;;;;;KAOU;EAEN;EACA;;EAGA;EACA;;EAGA;;UAGW;EACf;EACA;EACA;EACA;;;;;EAKA,SAAS;;;;;EAKT;EACA,eAAe;;UAGA;EACf;EACA;EACA;EAaA;EACA,SAAS;EACT,eAAe;;KAKZ,6BAA6B,KAChC;EAGA;;KAGG,8BAA8B,KACjC;EAGA;;KAGG,iCAAiC,KACpC;EAGA;;UAGe;EACf;EACA;;UAGe;EACf;EACA;;;;EAIA;EACA,kBAEI,MACI,6BACA,8BACA,iCACA;EAER;EACA,eAAe;;UAGA;EACf;EACA;EACA,SACI;IACE;IACA;IACA;IACA;IACA;;IAGA;IACA;;EAEN,SAAS;EACT,eAAe;;UAGA;EACf;EACA;EACA;IAEM;IACA,iBAAiB;MACf;MACA;;;IAIF;IACA;;EAEN,eAAe;;UAIA;EACf;EACA;EACA;IAEM;IACA;IACA;IACA;IACA,SAAS;MAAQ;MAA+B;;;IAGhD;IACA;IACA;IACA;IACA,SAAS;MAAQ;MAA+B;;;IAGhD;IACA;;EAEN,eAAe;;UAIA;EACf;EACA;EACA;IAEM;IACA;;IAGA;IACA;;IAGA;IACA;IACA;IACA;IACA;IACA;;IAGA;IACA;IACA;IACA;IACA;IACA;;EAEN,eAAe;;UAIA;EACf;EACA;EACA;IAEM;IACA;IACA;IACA;IACA;MACE;MACA;;;IAIF;IACA;;EAEN,eAAe;;UAGA;EACf;EACA;EACA;IAEM;IACA;IACA;;IAGA;IACA;IACA;;IAGA;;;;;;IAMA;;EAEN,eAAe;;UAGA;EACf;EACA;EACA;IAEM;IACA;IACA;IACA;MACE;MACA;MACA;QAAc;;MACd;QACM;QAAgB;QAA+B;;QAC/C;QAAc;QAA0B;;;;IAIhD;IACA;;EAEN,SAAS;EACT,eAAe;;UAEA;EACf;EACA;EACA;EACA;EACA;EACA,eAAe;;UAGA;EACf;EACA;EACA;EACA,kBAEI;IACE;IACA;IACA,YAAY;;EAElB,eAAe;;KAGL;EAEN;EACA;EACA,cAAc;EACd,eAAe;EACf;EACA;;;;;EAKA;;;;;;;;EAQA,kBAAkB;;EAKlB;EACA;EACA,eAAe;;EAGf;EACA;;EAGA;EACA;;EAGA;EACA;EACA;EACA;EACA;EACA,eAAe;;EAGf;EACA;EACA;EACA;EACA;EACA;EACA,eAAe;;;;;;EAOf;EACA,UAAU;IAAiB;IAAmB;;EAC9C,eAAe;;EAGf;EACA;EAIA,eAAe;;EAGf;EACA;EACA;EACA,eAAe;;EAGf;EACA;EACA,eAAe;;EAGf;EACA;;EAGA;EACA;EACA;EACA;EACA;EACA;IAAc;;EACd;EACA;EACA;EACA,eAAe;;EAGf;EAIA;EACA;EACA;EACA;EACA;IACE;IACA;IACA;IACA;IACA;;EAEF;E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P;MACF;MACJ;MAEwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAJlB;MACF;MACJ;MAEwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAHxB;MACA;MAEa;MACK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBCnBC,eACpB,OACA,YACA,wBACA,uBACA,0BACA,qBACA,4BACA;EAEA,OAAO;EACP,YAAY;EACZ;EACA,wBAAwB;;;;EAKxB;;;;EAKA;;;;;EAMA;;;;;;EAOA;IACE;EACF,OAAO,MAAM;EACb,YAAY;EACZ,cAAc;EACd,OAAO;;;;;;;;;;;wBC3BO,mBAAmB,QAAQ,cAAc;;;UCtB/C;EACR;EACA;EACA,SAAS,WAAW;EACpB,QAAQ;;qBAGG,2BAA2B;mBAOT;WANpB;MAEL;EAIyB,YAAA,QAAQ;UAEvB;UAMA;EA0BR,YACJ,QAAQ,WAAW,8BAClB,QAAQ,QAAQ,WAAW"}
1
+ {"version":3,"file":"index.d.ts","names":["_$__anthropic_api0.AnthropicToolChoice","_$__anthropic_api0.AnthropicTextContent","_$__anthropic_api0.AnthropicMessage","SandboxSession","SandboxSession","_$__tool_computer_toolset_202608010.ComputerToolset_20260801Member"],"sources":["../../src/anthropic-files.ts","../../src/anthropic-api.ts","../../src/anthropic-language-model-options.ts","../../src/get-cache-control.ts","../../src/convert-to-anthropic-prompt.ts","../../src/anthropic-model-catalog.ts","../../src/anthropic-language-model.ts","../../src/tool/computer-toolset_20260801.ts","../../src/tool/bash_20241022.ts","../../src/tool/bash_20250124.ts","../../src/anthropic-tools.ts","../../src/anthropic-prepare-tools.ts","../../src/sanitize-json-schema.ts","../../src/supports-native-structured-output-schema.ts","../../src/skills/anthropic-skills.ts"],"mappings":";;;;UAiCU;EACR;EACA;EACA,SAAS,WAAW;EACpB,QAAQ;;qBAGG,0BAA0B;mBAOR;WANpB;MAEL;EAIyB,YAAA,QAAQ;EAE/B,aACJ,MACA,WACA,UACA,aACA,WACC,+BAA+B,QAAQ;;;;KC1ChC,mBACR,uBACA,4BACA;KAEQ;EACV;EACA;;UAGe;EACf;EACA,SAAS,MAAM,uBAAuB;EACtC;EACA;IACE;;;;;;;;;;UAWa;EACf;EACA;IAAQ;IAAwB;;EAChC;;UAGe;EACf;EACA,SAAS,MACL,uBACA,wBACA,wBACA,2BACA,kCACA;;UAIW;EACf;EACA,SAAS,MACL,uBACA,2BACA,mCACA,2BACA,2BACA,gCACA,0CACA,qCACA,sCACA,uCACA,8CACA,oDACA,oCACA,6BACA,gCACA;;cAIO,sCAA8B,EAAA;;;;;;;;GAKvC,EAAA,KAAA;KAKQ,2BAA2B,YACrC,kBAAkB;EAElB;;UAGe;EACf;EACA;EACA;EACA,gBAAgB;;UAGD;EACf;EACA;EACA,YAAY;EACZ,eAAe;;UAGA;EACf;EACA;EACA;EAGA;;UAGe;EACf;EACA;EAGA;;KAGG;EAEC;EACA;EACA;;EAGA;EACA;;EAGA;EACA;EACA;;EAGA;EACA;;UAGW;EACf;EACA,QAAQ;EACR,eAAe;;;UAIA;EACf;EACA,QAAQ;EACR,eAAe;;UAGA;EACf;EACA,QAAQ;EACR;EACA;EACA;IAAc;;EACd,eAAe;;UAGA;EACf;EACA;EACA;;;;;;KAOU;EAEN;EACA;;EAGA;EACA;;EAGA;;UAGW;EACf;EACA;EACA;EACA;;;;;EAKA,SAAS;;;;;EAKT;EACA,eAAe;;UAGA;EACf;EACA;EACA;EAaA;EACA,SAAS;EACT,eAAe;;KAKZ,6BAA6B,KAChC;EAGA;;KAGG,8BAA8B,KACjC;EAGA;;KAGG,iCAAiC,KACpC;EAGA;;UAGe;EACf;EACA;;UAGe;EACf;EACA;;;;EAIA;EACA,kBAEI,MACI,6BACA,8BACA,iCACA;EAER;EACA,eAAe;;UAGA;EACf;EACA;EACA,SACI;IACE;IACA;IACA;IACA;IACA;;IAGA;IACA;;EAEN,SAAS;EACT,eAAe;;UAGA;EACf;EACA;EACA;IAEM;IACA,iBAAiB;MACf;MACA;;;IAIF;IACA;;EAEN,eAAe;;UAIA;EACf;EACA;EACA;IAEM;IACA;IACA;IACA;IACA,SAAS;MAAQ;MAA+B;;;IAGhD;IACA;IACA;IACA;IACA,SAAS;MAAQ;MAA+B;;;IAGhD;IACA;;EAEN,eAAe;;UAIA;EACf;EACA;EACA;IAEM;IACA;;IAGA;IACA;;IAGA;IACA;IACA;IACA;IACA;IACA;;IAGA;IACA;IACA;IACA;IACA;IACA;;EAEN,eAAe;;UAIA;EACf;EACA;EACA;IAEM;IACA;IACA;IACA;IACA;MACE;MACA;;;IAIF;IACA;;EAEN,eAAe;;UAGA;EACf;EACA;EACA;IAEM;IACA;IACA;;IAGA;IACA;IACA;;IAGA;;;;;;IAMA;;EAEN,eAAe;;UAGA;EACf;EACA;EACA;IAEM;IACA;IACA;IACA;MACE;MACA;MACA;QAAc;;MACd;QACM;QAAgB;QAA+B;;QAC/C;QAAc;QAA0B;;;;IAIhD;IACA;;EAEN,SAAS;EACT,eAAe;;UAEA;EACf;EACA;EACA;EACA;EACA;EACA,eAAe;;UAGA;EACf;EACA;EACA;EACA,kBAEI;IACE;IACA;IACA,YAAY;;EAElB,eAAe;;KAGL;EAEN;EACA;EACA,cAAc;EACd,eAAe;EACf;EACA;;;;;EAKA;;;;;;;;EAQA,kBAAkB;;EAKlB;EACA;EACA,eAAe;;EAGf;EACA;;EAGA;EACA;;EAGA;EACA;EACA;EACA;EACA;EACA,eAAe;;EAGf;EACA;EACA;EACA;EACA;EACA;EACA,eAAe;;;;;;EAOf;EACA,UAAU;IAAiB;IAAmB;;EAC9C,eAAe;;EAGf;EACA;EAIA,eAAe;;EAGf;EACA;EACA;EACA,eAAe;;EAGf;EACA;EACA,eAAe;;EAGf;EACA;;EAGA;EACA;EACA;EACA;EACA;EACA;IAAc;;EACd;EACA;EACA;EACA,eAAe;;EAGf;EAIA;EACA;EACA;EACA;EACA;IACE;IACA;IACA;IACA;IACA;;E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;;MAQP;MACF;MACJ;MAEwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAJlB;MACF;MACJ;MAEwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAHxB;MACA;MAEa;MACK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBCnBC,eACpB,OACA,YACA,wBACA,uBACA,0BACA,qBACA,4BACA;EAEA,OAAO;EACP,YAAY;EACZ;EACA,wBAAwB;;;;EAKxB;;;;EAKA;;;;;EAMA;;;;;;EAOA;IACE;EACF,OAAO,MAAM;EACb,YAAY;EACZ,cAAc;EACd,OAAO;;;;;;;;;;;wBC3BO,mBAAmB,QAAQ,cAAc;;;;;;;;;;;;wBCDzC,qCACd,QAAQ;;;UCtBA;EACR;EACA;EACA,SAAS,WAAW;EACpB,QAAQ;;qBAGG,2BAA2B;mBAOT;WANpB;MAEL;EAIyB,YAAA,QAAQ;UAEvB;UAMA;EA0BR,YACJ,QAAQ,WAAW,8BAClB,QAAQ,QAAQ,WAAW"}
@@ -1,4 +1,4 @@
1
- import { WORKFLOW_DESERIALIZE, WORKFLOW_SERIALIZE, combineHeaders, convertBase64ToUint8Array, convertInlineFileDataToUint8Array, convertToBase64, createEventSourceResponseHandler, createJsonErrorResponseHandler, createJsonResponseHandler, createProviderDefinedToolFactory, createProviderExecutedToolFactory, createProviderStreamError, createToolNameMapping, encodePathSegment, experimental_toolCaller, generateId, getFromApi, getTopLevelMediaType, isCustomReasoning, isNonNullable, isProviderStreamError, isRecord, lazySchema, mapReasoningToProviderBudget, mapReasoningToProviderEffort, parseProviderOptions, postFormDataToApi, postJsonToApi, resolve, resolveFullMediaType, resolveProviderReference, safeValidateTypes, secureJsonParse, serializeModelOptions, validateTypes, zodSchema } from "@ai-sdk/provider-utils";
1
+ import { WORKFLOW_DESERIALIZE, WORKFLOW_SERIALIZE, combineHeaders, convertBase64ToUint8Array, convertInlineFileDataToUint8Array, convertToBase64, createEventSourceResponseHandler, createJsonErrorResponseHandler, createJsonResponseHandler, createProviderDefinedToolFactory, createProviderExecutedToolFactory, createProviderStreamError, createToolNameMapping, encodePathSegment, experimental_toolCaller, generateId, getFromApi, getTopLevelMediaType, isCustomReasoning, isNonNullable, isProviderStreamError, isRecord, lazySchema, mapReasoningToProviderBudget, mapReasoningToProviderEffort, parseProviderOptions, postFormDataToApi, postJsonToApi, resolve, resolveFullMediaType, resolveProviderReference, safeValidateTypes, secureJsonParse, serializeModelOptions, stringifyWithBigIntAndCycles, validateTypes, zodSchema } from "@ai-sdk/provider-utils";
2
2
  import { z } from "zod/v4";
3
3
  import { APICallError, InvalidArgumentError, InvalidResponseDataError, UnsupportedFunctionalityError } from "@ai-sdk/provider";
4
4
  //#region src/anthropic-error.ts
@@ -2962,7 +2962,7 @@ async function convertToAnthropicPrompt({ prompt, sendReasoning, warnings, cache
2962
2962
  case "execution-denied":
2963
2963
  contentValue = output.reason ?? "Tool call execution denied.";
2964
2964
  break;
2965
- default: contentValue = JSON.stringify(output.value);
2965
+ default: contentValue = stringifyWithBigIntAndCycles(output.value);
2966
2966
  }
2967
2967
  const toolsetName = getAnthropicToolsetName({
2968
2968
  toolName: part.toolName,
@@ -3633,6 +3633,10 @@ function getAnthropicCaller(providerOptions) {
3633
3633
  return caller?.type === "direct" ? { type: "direct" } : void 0;
3634
3634
  }
3635
3635
  function toAnthropicToolInput(input) {
3636
+ if (typeof input === "string") try {
3637
+ const parsed = secureJsonParse(input);
3638
+ if (typeof parsed === "object" && parsed !== null && !Array.isArray(parsed)) return parsed;
3639
+ } catch {}
3636
3640
  return typeof input === "object" && input !== null && !Array.isArray(input) ? input : { rawInvalidInput: input };
3637
3641
  }
3638
3642
  //#endregion
@@ -3699,8 +3703,10 @@ function sanitizeDefinition(definition) {
3699
3703
  }
3700
3704
  function sanitizeSchema(schema) {
3701
3705
  const result = {};
3702
- const schemaWithDefs = schema;
3703
- if (schema.$ref != null) return { $ref: schema.$ref };
3706
+ if (schema.$ref != null) return {
3707
+ $ref: schema.$ref,
3708
+ ...sanitizeSchemaDefinitions(schema)
3709
+ };
3704
3710
  if (schema.$schema != null) result.$schema = schema.$schema;
3705
3711
  if (schema.$id != null) result.$id = schema.$id;
3706
3712
  if (schema.title != null) result.title = schema.title;
@@ -3712,11 +3718,7 @@ function sanitizeSchema(schema) {
3712
3718
  if (schema.anyOf != null) result.anyOf = schema.anyOf.map(sanitizeDefinition);
3713
3719
  else if (schema.oneOf != null) result.anyOf = schema.oneOf.map(sanitizeDefinition);
3714
3720
  if (schema.allOf != null) result.allOf = schema.allOf.map(sanitizeDefinition);
3715
- if (schema.definitions != null) result.definitions = Object.fromEntries(Object.entries(schema.definitions).map(([name, definition]) => [name, sanitizeDefinition(definition)]));
3716
- if (schemaWithDefs.$defs != null) {
3717
- const resultWithDefs = result;
3718
- resultWithDefs.$defs = Object.fromEntries(Object.entries(schemaWithDefs.$defs).map(([name, definition]) => [name, sanitizeDefinition(definition)]));
3719
- }
3721
+ Object.assign(result, sanitizeSchemaDefinitions(schema));
3720
3722
  if (schema.type === "object" || schema.properties != null) {
3721
3723
  if (schema.properties != null) result.properties = Object.fromEntries(Object.entries(schema.properties).map(([name, definition]) => [name, sanitizeDefinition(definition)]));
3722
3724
  result.additionalProperties = false;
@@ -3728,6 +3730,14 @@ function sanitizeSchema(schema) {
3728
3730
  if (constraintDescription != null) result.description = result.description == null ? constraintDescription : `${result.description}\n${constraintDescription}`;
3729
3731
  return result;
3730
3732
  }
3733
+ function sanitizeSchemaDefinitions(schema) {
3734
+ const { $defs } = schema;
3735
+ const sanitizeAll = (definitions) => Object.fromEntries(Object.entries(definitions).map(([name, definition]) => [name, sanitizeDefinition(definition)]));
3736
+ return {
3737
+ ...schema.definitions != null && { definitions: sanitizeAll(schema.definitions) },
3738
+ ...$defs != null && { $defs: sanitizeAll($defs) }
3739
+ };
3740
+ }
3731
3741
  function getConstraintDescription(schema) {
3732
3742
  const descriptions = DESCRIPTION_CONSTRAINT_KEYS.flatMap((key) => {
3733
3743
  const value = schema[key];
@@ -3745,6 +3755,155 @@ function formatConstraintValue(value) {
3745
3755
  return JSON.stringify(value);
3746
3756
  }
3747
3757
  //#endregion
3758
+ //#region src/has-circular-schema-reference.ts
3759
+ const SCHEMA_MAP_KEYWORDS = /* @__PURE__ */ new Set([
3760
+ "dependentSchemas",
3761
+ "patternProperties",
3762
+ "properties"
3763
+ ]);
3764
+ const DATA_KEYWORDS = /* @__PURE__ */ new Set([
3765
+ "const",
3766
+ "default",
3767
+ "enum",
3768
+ "examples"
3769
+ ]);
3770
+ /**
3771
+ * Whether a JSON schema contains a cycle of local `$ref`s, e.g. a tree node
3772
+ * whose children reference the node itself.
3773
+ *
3774
+ * Anthropic's native structured outputs reject such schemas, while the JSON
3775
+ * response tool accepts them.
3776
+ */
3777
+ function hasCircularSchemaReference(schema) {
3778
+ const visiting = /* @__PURE__ */ new Set();
3779
+ const visited = /* @__PURE__ */ new Set();
3780
+ const visit = (pointer) => {
3781
+ if (visiting.has(pointer)) return true;
3782
+ if (visited.has(pointer)) return false;
3783
+ const target = resolveSchemaPointer(schema, pointer);
3784
+ if (target === void 0) return false;
3785
+ visiting.add(pointer);
3786
+ const isCircular = collectLocalRefs(target).some(visit);
3787
+ visiting.delete(pointer);
3788
+ visited.add(pointer);
3789
+ return isCircular;
3790
+ };
3791
+ return visit("#");
3792
+ }
3793
+ function collectLocalRefs(node, refs = []) {
3794
+ if (Array.isArray(node)) {
3795
+ for (const item of node) collectLocalRefs(item, refs);
3796
+ return refs;
3797
+ }
3798
+ if (!isRecord(node)) return refs;
3799
+ for (const [key, value] of Object.entries(node)) if (key === "$ref") {
3800
+ if (typeof value === "string" && value.startsWith("#")) refs.push(value);
3801
+ } else if (SCHEMA_MAP_KEYWORDS.has(key) && isRecord(value)) for (const subschema of Object.values(value)) collectLocalRefs(subschema, refs);
3802
+ else if (key !== "$defs" && key !== "definitions" && !DATA_KEYWORDS.has(key)) collectLocalRefs(value, refs);
3803
+ return refs;
3804
+ }
3805
+ function resolveSchemaPointer(schema, pointer) {
3806
+ if (pointer === "#") return schema;
3807
+ if (!pointer.startsWith("#/")) return;
3808
+ let decodedPointer;
3809
+ try {
3810
+ decodedPointer = decodeURIComponent(pointer.slice(2));
3811
+ } catch {
3812
+ return;
3813
+ }
3814
+ let current = schema;
3815
+ for (const rawSegment of decodedPointer.split("/")) {
3816
+ const segment = rawSegment.replace(/~1/g, "/").replace(/~0/g, "~");
3817
+ if (Array.isArray(current)) current = current[Number(segment)];
3818
+ else if (isRecord(current)) current = current[segment];
3819
+ else return;
3820
+ }
3821
+ return current;
3822
+ }
3823
+ //#endregion
3824
+ //#region src/supports-native-structured-output-schema.ts
3825
+ const MAX_OPTIONAL_PROPERTIES = 10;
3826
+ const SUBSCHEMA_KEYWORDS = [
3827
+ "additionalProperties",
3828
+ "contains",
3829
+ "else",
3830
+ "if",
3831
+ "items",
3832
+ "not",
3833
+ "then"
3834
+ ];
3835
+ const SUBSCHEMA_LIST_KEYWORDS = [
3836
+ "allOf",
3837
+ "anyOf",
3838
+ "oneOf",
3839
+ "prefixItems"
3840
+ ];
3841
+ const SUBSCHEMA_MAP_KEYWORDS = [
3842
+ "dependentSchemas",
3843
+ "patternProperties",
3844
+ "properties"
3845
+ ];
3846
+ /**
3847
+ * Whether Anthropic's native structured outputs (`output_config.format`) can
3848
+ * represent a schema without rejecting it or losing data.
3849
+ *
3850
+ * Rejected: self-referencing schemas, and schemas with too many optional
3851
+ * properties. Lossy: open objects (maps, free-form objects), which native
3852
+ * structured outputs close with `additionalProperties: false`, so the model
3853
+ * can only return `{}` for them.
3854
+ */
3855
+ function supportsNativeStructuredOutputSchema(schema) {
3856
+ if (hasCircularSchemaReference(schema)) return false;
3857
+ const { optionalProperties, hasOpenObject } = getSchemaStats(schema, schema, /* @__PURE__ */ new Map());
3858
+ return !hasOpenObject && optionalProperties <= MAX_OPTIONAL_PROPERTIES;
3859
+ }
3860
+ function getSchemaStats(node, root, refStats) {
3861
+ const stats = {
3862
+ optionalProperties: 0,
3863
+ hasOpenObject: false
3864
+ };
3865
+ if (!isRecord(node)) return stats;
3866
+ const add = (child) => {
3867
+ const childStats = getSchemaStats(child, root, refStats);
3868
+ stats.optionalProperties += childStats.optionalProperties;
3869
+ stats.hasOpenObject ||= childStats.hasOpenObject;
3870
+ };
3871
+ if (typeof node.$ref === "string" && node.$ref.startsWith("#")) {
3872
+ let resolved = refStats.get(node.$ref);
3873
+ if (resolved == null) {
3874
+ resolved = getSchemaStats(resolveSchemaPointer(root, node.$ref), root, refStats);
3875
+ refStats.set(node.$ref, resolved);
3876
+ }
3877
+ stats.optionalProperties += resolved.optionalProperties;
3878
+ stats.hasOpenObject ||= resolved.hasOpenObject;
3879
+ }
3880
+ if (isOpenObject(node)) stats.hasOpenObject = true;
3881
+ if (isRecord(node.properties)) {
3882
+ const required = new Set(Array.isArray(node.required) ? node.required : []);
3883
+ stats.optionalProperties += Object.keys(node.properties).filter((name) => !required.has(name)).length;
3884
+ }
3885
+ for (const keyword of SUBSCHEMA_KEYWORDS) {
3886
+ const value = node[keyword];
3887
+ if (Array.isArray(value)) value.forEach(add);
3888
+ else add(value);
3889
+ }
3890
+ for (const keyword of SUBSCHEMA_LIST_KEYWORDS) {
3891
+ const value = node[keyword];
3892
+ if (Array.isArray(value)) value.forEach(add);
3893
+ }
3894
+ for (const keyword of SUBSCHEMA_MAP_KEYWORDS) {
3895
+ const value = node[keyword];
3896
+ if (isRecord(value)) Object.values(value).forEach(add);
3897
+ }
3898
+ return stats;
3899
+ }
3900
+ function isOpenObject(node) {
3901
+ const { additionalProperties, patternProperties, properties, type } = node;
3902
+ if (additionalProperties === true || isRecord(additionalProperties)) return true;
3903
+ if (isRecord(patternProperties) && Object.keys(patternProperties).length > 0) return true;
3904
+ return (type === "object" || Array.isArray(type) && type.includes("object")) && properties == null && additionalProperties !== false;
3905
+ }
3906
+ //#endregion
3748
3907
  //#region src/anthropic-language-model.ts
3749
3908
  function createAnthropicStreamError(error) {
3750
3909
  const inferredMetadata = getAnthropicStreamErrorMetadata(error.type);
@@ -3863,6 +4022,28 @@ function getProviderOptionsName(provider) {
3863
4022
  const dotIndex = provider.indexOf(".");
3864
4023
  return dotIndex === -1 ? provider : provider.substring(0, dotIndex);
3865
4024
  }
4025
+ const TEXT_OR_THINKING_BLOCK_TYPES = /* @__PURE__ */ new Set([
4026
+ "redacted_thinking",
4027
+ "text",
4028
+ "thinking"
4029
+ ]);
4030
+ function isContinuationStopReason(stopReason) {
4031
+ return stopReason === "pause_turn" || stopReason === "tool_use";
4032
+ }
4033
+ /**
4034
+ * Text parts to return when the JSON response tool is in use: the text after
4035
+ * the last tool call or result, and only if the tool was never called.
4036
+ */
4037
+ function getJsonResponseToolFallbackText(content, stopReason) {
4038
+ const text = /* @__PURE__ */ new Set();
4039
+ if (isContinuationStopReason(stopReason)) return text;
4040
+ for (const part of content) {
4041
+ if (part.type === "tool_use" && part.name === "json") return /* @__PURE__ */ new Set();
4042
+ if (part.type === "text") text.add(part);
4043
+ else if (!TEXT_OR_THINKING_BLOCK_TYPES.has(part.type)) text.clear();
4044
+ }
4045
+ return text;
4046
+ }
3866
4047
  var AnthropicLanguageModel = class AnthropicLanguageModel {
3867
4048
  static [WORKFLOW_SERIALIZE](model) {
3868
4049
  return serializeModelOptions({
@@ -3973,10 +4154,11 @@ var AnthropicLanguageModel = class AnthropicLanguageModel {
3973
4154
  }
3974
4155
  const isAnthropicModel = isKnownModel || modelId.includes("claude-");
3975
4156
  const supportsStructuredOutput = (config.supportsNativeStructuredOutput ?? true) && modelSupportsStructuredOutput;
4157
+ const supportsResponseSchema = responseFormat?.type !== "json" || responseFormat.schema == null || supportsNativeStructuredOutputSchema(responseFormat.schema);
3976
4158
  const supportsStrictTools = (config.supportsStrictTools ?? true) && modelSupportsStructuredOutput;
3977
4159
  const structureOutputMode = anthropicOptions?.structuredOutputMode ?? "auto";
3978
- let useStructuredOutput = structureOutputMode === "outputFormat" || structureOutputMode === "auto" && supportsStructuredOutput;
3979
- if (!useStructuredOutput && rejectsForcedToolUse && supportsStructuredOutput && responseFormat?.type === "json" && responseFormat.schema != null) {
4160
+ let useStructuredOutput = structureOutputMode === "outputFormat" || structureOutputMode === "auto" && supportsStructuredOutput && supportsResponseSchema;
4161
+ if (!useStructuredOutput && rejectsForcedToolUse && modelSupportsStructuredOutput && responseFormat?.type === "json" && responseFormat.schema != null && supportsNativeStructuredOutputSchema(responseFormat.schema)) {
3980
4162
  warnings.push({
3981
4163
  type: "unsupported",
3982
4164
  feature: "providerOptions.anthropic.structuredOutputMode",
@@ -4275,7 +4457,7 @@ var AnthropicLanguageModel = class AnthropicLanguageModel {
4275
4457
  else if (anthropicOptions?.fallbacks && anthropicOptions.fallbacks.length > 0) betas.add("server-side-fallback-2026-06-01");
4276
4458
  const defaultEagerInputStreaming = stream && (anthropicOptions?.toolStreaming ?? true);
4277
4459
  const { tools: anthropicTools, toolChoice: anthropicToolChoice, toolWarnings, betas: toolsBetas } = await prepareTools(jsonResponseTool != null ? {
4278
- tools: [...tools ?? [], jsonResponseTool],
4460
+ tools: [...(tools ?? []).filter((tool) => toolChoice?.type !== "none" && (toolChoice?.type !== "tool" || tool.name === toolChoice.toolName)), jsonResponseTool],
4279
4461
  toolChoice: { type: "required" },
4280
4462
  disableParallelToolUse: true,
4281
4463
  cacheControlValidator,
@@ -4383,9 +4565,10 @@ var AnthropicLanguageModel = class AnthropicLanguageModel {
4383
4565
  const serverToolCalls = {};
4384
4566
  let isJsonResponseFromTool = false;
4385
4567
  const hasWebSearchResults = response.content.some((part) => part.type === "web_search_tool_result" && Array.isArray(part.content) && part.content.length > 0);
4568
+ const jsonResponseToolFallbackText = usesJsonResponseTool ? getJsonResponseToolFallbackText(response.content, response.stop_reason) : void 0;
4386
4569
  for (const part of response.content) switch (part.type) {
4387
4570
  case "text":
4388
- if (!usesJsonResponseTool) {
4571
+ if (jsonResponseToolFallbackText == null || jsonResponseToolFallbackText.has(part)) {
4389
4572
  const citations = part.citations ?? [];
4390
4573
  content.push({
4391
4574
  type: "text",
@@ -4823,6 +5006,16 @@ var AnthropicLanguageModel = class AnthropicLanguageModel {
4823
5006
  let safeguardResults;
4824
5007
  let container = null;
4825
5008
  let isJsonResponseFromTool = false;
5009
+ const heldBackText = [];
5010
+ const heldBackTextByIndex = /* @__PURE__ */ new Map();
5011
+ const createTextEnd = (id, citations) => ({
5012
+ type: "text-end",
5013
+ id,
5014
+ ...citations.length > 0 && {
5015
+ citations: citations.map((citation) => mapAnthropicCitation(citation, citationDocuments)),
5016
+ providerMetadata: { anthropic: { citations } }
5017
+ }
5018
+ });
4826
5019
  let hasWebSearchResults = false;
4827
5020
  const fallbackWebCitations = [];
4828
5021
  let isMessageOpen = false;
@@ -4869,9 +5062,19 @@ var AnthropicLanguageModel = class AnthropicLanguageModel {
4869
5062
  return;
4870
5063
  }
4871
5064
  blockType = contentBlockType;
5065
+ if (!TEXT_OR_THINKING_BLOCK_TYPES.has(contentBlockType)) heldBackText.length = 0;
4872
5066
  switch (contentBlockType) {
4873
5067
  case "text":
4874
- if (usesJsonResponseTool) return;
5068
+ if (usesJsonResponseTool) {
5069
+ const entry = {
5070
+ id: String(value.index),
5071
+ text: "",
5072
+ citations: []
5073
+ };
5074
+ heldBackText.push(entry);
5075
+ heldBackTextByIndex.set(value.index, entry);
5076
+ return;
5077
+ }
4875
5078
  contentBlocks[value.index] = {
4876
5079
  type: "text",
4877
5080
  citations: []
@@ -5257,14 +5460,7 @@ var AnthropicLanguageModel = class AnthropicLanguageModel {
5257
5460
  const contentBlock = contentBlocks[value.index];
5258
5461
  switch (contentBlock.type) {
5259
5462
  case "text":
5260
- controller.enqueue({
5261
- type: "text-end",
5262
- id: String(value.index),
5263
- ...contentBlock.citations.length > 0 && {
5264
- citations: contentBlock.citations.map((citation) => mapAnthropicCitation(citation, citationDocuments)),
5265
- providerMetadata: { anthropic: { citations: contentBlock.citations } }
5266
- }
5267
- });
5463
+ controller.enqueue(createTextEnd(String(value.index), contentBlock.citations));
5268
5464
  break;
5269
5465
  case "reasoning":
5270
5466
  controller.enqueue({
@@ -5324,7 +5520,11 @@ var AnthropicLanguageModel = class AnthropicLanguageModel {
5324
5520
  const deltaType = value.delta.type;
5325
5521
  switch (deltaType) {
5326
5522
  case "text_delta":
5327
- if (usesJsonResponseTool) return;
5523
+ if (usesJsonResponseTool) {
5524
+ const entry = heldBackTextByIndex.get(value.index);
5525
+ if (entry != null) entry.text += value.delta.text;
5526
+ return;
5527
+ }
5328
5528
  controller.enqueue({
5329
5529
  type: "text-delta",
5330
5530
  id: String(value.index),
@@ -5385,6 +5585,7 @@ var AnthropicLanguageModel = class AnthropicLanguageModel {
5385
5585
  const citation = value.delta.citation;
5386
5586
  const contentBlock = contentBlocks[value.index];
5387
5587
  if (contentBlock?.type === "text") contentBlock.citations.push(citation);
5588
+ heldBackTextByIndex.get(value.index)?.citations.push(citation);
5388
5589
  if (citation.type === "web_search_result_location") fallbackWebCitations.push(citation);
5389
5590
  else {
5390
5591
  const source = createCitationSource(citation, citationDocuments, generateId);
@@ -5410,6 +5611,7 @@ var AnthropicLanguageModel = class AnthropicLanguageModel {
5410
5611
  }
5411
5612
  isMessageOpen = true;
5412
5613
  activeMessageId = value.message.id;
5614
+ heldBackTextByIndex.clear();
5413
5615
  usage.input_tokens = value.message.usage.input_tokens;
5414
5616
  usage.cache_read_input_tokens = value.message.usage.cache_read_input_tokens ?? 0;
5415
5617
  usage.cache_creation_input_tokens = value.message.usage.cache_creation_input_tokens ?? 0;
@@ -5530,6 +5732,20 @@ var AnthropicLanguageModel = class AnthropicLanguageModel {
5530
5732
  if (source) controller.enqueue(source);
5531
5733
  }
5532
5734
  fallbackWebCitations.length = 0;
5735
+ if (!isJsonResponseFromTool && !isContinuationStopReason(finishReason.raw)) for (const { id, text, citations } of heldBackText) {
5736
+ if (text.length === 0) continue;
5737
+ controller.enqueue({
5738
+ type: "text-start",
5739
+ id
5740
+ });
5741
+ controller.enqueue({
5742
+ type: "text-delta",
5743
+ id,
5744
+ delta: text
5745
+ });
5746
+ controller.enqueue(createTextEnd(id, citations));
5747
+ }
5748
+ heldBackText.length = 0;
5533
5749
  controller.enqueue({
5534
5750
  type: "finish",
5535
5751
  finishReason,
@@ -6401,6 +6617,6 @@ var AnthropicSkills = class {
6401
6617
  }
6402
6618
  };
6403
6619
  //#endregion
6404
- export { AnthropicFiles, AnthropicLanguageModel, AnthropicLanguageModel as AnthropicMessagesLanguageModel, AnthropicSkills, anthropicTools, getAnthropicModelCapabilities as getModelCapabilities, prepareTools, sanitizeJsonSchema };
6620
+ export { AnthropicFiles, AnthropicLanguageModel, AnthropicLanguageModel as AnthropicMessagesLanguageModel, AnthropicSkills, anthropicTools, getAnthropicModelCapabilities as getModelCapabilities, prepareTools, sanitizeJsonSchema, supportsNativeStructuredOutputSchema };
6405
6621
 
6406
6622
  //# sourceMappingURL=index.js.map