@ai-sdk-tool/parser 3.3.3 → 4.0.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/dist/index.d.cts CHANGED
@@ -8,6 +8,12 @@ export { ParseOptions, parse, stringify, transform } from './rjson.cjs';
8
8
  */
9
9
  interface ParserOptions {
10
10
  onError?: (message: string, metadata?: Record<string, unknown>) => void;
11
+ /**
12
+ * When true, stream parsers may emit malformed raw tool-call text as
13
+ * `text-delta` fallback on parse failure. Defaults to false to avoid leaking
14
+ * protocol/internal markup to end users.
15
+ */
16
+ emitRawToolCallTextOnError?: boolean;
11
17
  }
12
18
  interface TCMProtocol {
13
19
  formatTools({ tools, toolSystemPromptTemplate, }: {
@@ -18,15 +24,11 @@ interface TCMProtocol {
18
24
  parseGeneratedText({ text, tools, options, }: {
19
25
  text: string;
20
26
  tools: LanguageModelV3FunctionTool[];
21
- options?: {
22
- onError?: (message: string, metadata?: Record<string, unknown>) => void;
23
- };
27
+ options?: ParserOptions;
24
28
  }): LanguageModelV3Content[];
25
29
  createStreamParser({ tools, options, }: {
26
30
  tools: LanguageModelV3FunctionTool[];
27
- options?: {
28
- onError?: (message: string, metadata?: Record<string, unknown>) => void;
29
- };
31
+ options?: ParserOptions;
30
32
  }): TransformStream<LanguageModelV3StreamPart, LanguageModelV3StreamPart>;
31
33
  extractToolCallSegments?: ({ text, tools, }: {
32
34
  text: string;
package/dist/index.d.ts CHANGED
@@ -8,6 +8,12 @@ export { ParseOptions, parse, stringify, transform } from './rjson.js';
8
8
  */
9
9
  interface ParserOptions {
10
10
  onError?: (message: string, metadata?: Record<string, unknown>) => void;
11
+ /**
12
+ * When true, stream parsers may emit malformed raw tool-call text as
13
+ * `text-delta` fallback on parse failure. Defaults to false to avoid leaking
14
+ * protocol/internal markup to end users.
15
+ */
16
+ emitRawToolCallTextOnError?: boolean;
11
17
  }
12
18
  interface TCMProtocol {
13
19
  formatTools({ tools, toolSystemPromptTemplate, }: {
@@ -18,15 +24,11 @@ interface TCMProtocol {
18
24
  parseGeneratedText({ text, tools, options, }: {
19
25
  text: string;
20
26
  tools: LanguageModelV3FunctionTool[];
21
- options?: {
22
- onError?: (message: string, metadata?: Record<string, unknown>) => void;
23
- };
27
+ options?: ParserOptions;
24
28
  }): LanguageModelV3Content[];
25
29
  createStreamParser({ tools, options, }: {
26
30
  tools: LanguageModelV3FunctionTool[];
27
- options?: {
28
- onError?: (message: string, metadata?: Record<string, unknown>) => void;
29
- };
31
+ options?: ParserOptions;
30
32
  }): TransformStream<LanguageModelV3StreamPart, LanguageModelV3StreamPart>;
31
33
  extractToolCallSegments?: ({ text, tools, }: {
32
34
  text: string;
package/dist/index.js CHANGED
@@ -27,7 +27,7 @@ import {
27
27
  xmlToolMiddleware,
28
28
  yamlProtocol,
29
29
  yamlToolMiddleware
30
- } from "./chunk-NAQSTPDQ.js";
30
+ } from "./chunk-ERJKQKCR.js";
31
31
  import {
32
32
  escapeRegExp
33
33
  } from "./chunk-CXWS24JX.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-sdk-tool/parser",
3
- "version": "3.3.3",
3
+ "version": "4.0.0",
4
4
  "description": "AI SDK middleware for tool call parsing",
5
5
  "type": "module",
6
6
  "repository": {
@@ -44,19 +44,19 @@
44
44
  "access": "public"
45
45
  },
46
46
  "dependencies": {
47
- "@ai-sdk/openai": "^3.0.26",
47
+ "@ai-sdk/openai": "^3.0.28",
48
48
  "@ai-sdk/provider": "3.0.8",
49
- "@ai-sdk/provider-utils": "4.0.14",
49
+ "@ai-sdk/provider-utils": "4.0.15",
50
50
  "dedent": "^1.7.1",
51
51
  "yaml": "^2.8.2"
52
52
  },
53
53
  "devDependencies": {
54
- "@ai-sdk/openai-compatible": "2.0.28",
55
- "@biomejs/biome": "2.3.14",
54
+ "@ai-sdk/openai-compatible": "2.0.30",
55
+ "@biomejs/biome": "2.3.15",
56
56
  "@changesets/cli": "2.29.8",
57
- "@types/node": "^25.2.2",
57
+ "@types/node": "^25.2.3",
58
58
  "@vitest/coverage-v8": "^4.0.18",
59
- "ai": "6.0.77",
59
+ "ai": "6.0.84",
60
60
  "globals": "^17.3.0",
61
61
  "husky": "^9.1.7",
62
62
  "jiti": "^2.6.1",