ai-sdk-provider-claude-code 2.2.4 → 3.0.0-beta.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/dist/index.cjs CHANGED
@@ -238,7 +238,22 @@ function convertToClaudeCodeMessages(prompt) {
238
238
  }
239
239
  case "tool":
240
240
  for (const tool3 of message.content) {
241
- const resultText = tool3.output.type === "text" ? tool3.output.value : JSON.stringify(tool3.output.value);
241
+ if (tool3.type === "tool-approval-response") {
242
+ continue;
243
+ }
244
+ let resultText;
245
+ const output = tool3.output;
246
+ if (output.type === "text" || output.type === "error-text") {
247
+ resultText = output.value;
248
+ } else if (output.type === "json" || output.type === "error-json") {
249
+ resultText = JSON.stringify(output.value);
250
+ } else if (output.type === "execution-denied") {
251
+ resultText = `[Execution denied${output.reason ? `: ${output.reason}` : ""}]`;
252
+ } else if (output.type === "content") {
253
+ resultText = output.value.filter((part) => part.type === "text").map((part) => part.text).join("\n");
254
+ } else {
255
+ resultText = "[Unknown output type]";
256
+ }
242
257
  const formattedToolResult = `Tool Result (${tool3.toolName}): ${resultText}`;
243
258
  messages.push(formattedToolResult);
244
259
  addSegment(formattedToolResult);
@@ -698,7 +713,7 @@ var modelMap = {
698
713
  haiku: "haiku"
699
714
  };
700
715
  var ClaudeCodeLanguageModel = class _ClaudeCodeLanguageModel {
701
- specificationVersion = "v2";
716
+ specificationVersion = "v3";
702
717
  defaultObjectGenerationMode = "json";
703
718
  supportsImageUrls = false;
704
719
  supportedUrls = {};
@@ -841,8 +856,8 @@ var ClaudeCodeLanguageModel = class _ClaudeCodeLanguageModel {
841
856
  if (unsupportedParams.length > 0) {
842
857
  for (const param of unsupportedParams) {
843
858
  warnings.push({
844
- type: "unsupported-setting",
845
- setting: param,
859
+ type: "unsupported",
860
+ feature: param,
846
861
  details: `Claude Code SDK does not support the ${param} parameter. It will be ignored.`
847
862
  });
848
863
  }
@@ -861,8 +876,8 @@ var ClaudeCodeLanguageModel = class _ClaudeCodeLanguageModel {
861
876
  });
862
877
  if (options.responseFormat?.type === "json" && !options.responseFormat.schema) {
863
878
  warnings.push({
864
- type: "unsupported-setting",
865
- setting: "responseFormat",
879
+ type: "unsupported",
880
+ feature: "responseFormat",
866
881
  details: "JSON response format requires a schema for the Claude Code provider. The JSON responseFormat is ignored and the call is treated as plain text."
867
882
  });
868
883
  }
@@ -1748,9 +1763,9 @@ var ClaudeCodeLanguageModel = class _ClaudeCodeLanguageModel {
1748
1763
  const m = w.message;
1749
1764
  if (m !== void 0) base.message = String(m);
1750
1765
  }
1751
- if (w.type === "unsupported-setting") {
1752
- const setting = w.setting;
1753
- if (setting !== void 0) base.setting = String(setting);
1766
+ if (w.type === "unsupported" || w.type === "compatibility") {
1767
+ const feature = w.feature;
1768
+ if (feature !== void 0) base.feature = String(feature);
1754
1769
  if ("details" in w) {
1755
1770
  const d = w.details;
1756
1771
  if (d !== void 0) base.details = String(d);
@@ -1797,10 +1812,11 @@ function createClaudeCode(options = {}) {
1797
1812
  };
1798
1813
  provider.languageModel = createModel;
1799
1814
  provider.chat = createModel;
1800
- provider.textEmbeddingModel = (modelId) => {
1815
+ provider.specificationVersion = "v3";
1816
+ provider.embeddingModel = (modelId) => {
1801
1817
  throw new import_provider3.NoSuchModelError({
1802
1818
  modelId,
1803
- modelType: "textEmbeddingModel"
1819
+ modelType: "embeddingModel"
1804
1820
  });
1805
1821
  };
1806
1822
  provider.imageModel = (modelId) => {