@ai-sdk-tool/parser 2.1.7 → 3.0.0-canary.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
@@ -1,5 +1,5 @@
1
1
  import * as _ai_sdk_provider from '@ai-sdk/provider';
2
- import { LanguageModelV2FunctionTool, LanguageModelV2ToolCall, LanguageModelV2ToolResultPart, LanguageModelV2Content, LanguageModelV2StreamPart, LanguageModelV2Middleware, LanguageModelV2ProviderDefinedTool, JSONSchema7 } from '@ai-sdk/provider';
2
+ import { LanguageModelV3FunctionTool, LanguageModelV3ToolCall, LanguageModelV3ToolResultPart, LanguageModelV3Content, LanguageModelV3StreamPart, LanguageModelV3Middleware, LanguageModelV3ProviderDefinedTool, JSONSchema7 } from '@ai-sdk/provider';
3
3
 
4
4
  /**
5
5
  * ToolCallProtocol
@@ -13,10 +13,10 @@ import { LanguageModelV2FunctionTool, LanguageModelV2ToolCall, LanguageModelV2To
13
13
  * - Static formatting helpers (`formatTools`, `formatToolCall`, `formatToolResponse`)
14
14
  * are used to construct strings that the model will read.
15
15
  * - Parsing helpers (`parseGeneratedText`, `createStreamParser`) must convert
16
- * model output back into structured `LanguageModelV2Content` parts, emitting
16
+ * model output back into structured `LanguageModelV3Content` parts, emitting
17
17
  * `text` for regular content and `tool-call` for detected tool invocations.
18
18
  */
19
- interface ToolCallProtocol {
19
+ type ToolCallProtocol = {
20
20
  /**
21
21
  * Produces a provider-facing string that describes all available tools.
22
22
  *
@@ -32,7 +32,7 @@ interface ToolCallProtocol {
32
32
  * @returns A string to be embedded into the model's system prompt.
33
33
  */
34
34
  formatTools({ tools, toolSystemPromptTemplate, }: {
35
- tools: LanguageModelV2FunctionTool[];
35
+ tools: LanguageModelV3FunctionTool[];
36
36
  toolSystemPromptTemplate: (tools: string) => string;
37
37
  }): string;
38
38
  /**
@@ -46,7 +46,7 @@ interface ToolCallProtocol {
46
46
  * @param toolCall The tool call to format for the model.
47
47
  * @returns A textual representation of the tool call (e.g., an XML element).
48
48
  */
49
- formatToolCall(toolCall: LanguageModelV2ToolCall): string;
49
+ formatToolCall(toolCall: LanguageModelV3ToolCall): string;
50
50
  /**
51
51
  * Formats a tool result payload so the model can consume it as plain text.
52
52
  *
@@ -56,10 +56,10 @@ interface ToolCallProtocol {
56
56
  * @param toolResult The result part produced after executing a tool.
57
57
  * @returns Textual representation of the tool result for the model.
58
58
  */
59
- formatToolResponse(toolResult: LanguageModelV2ToolResultPart): string;
59
+ formatToolResponse(toolResult: LanguageModelV3ToolResultPart): string;
60
60
  /**
61
61
  * Parses a fully generated text (non-streaming) response from the model and
62
- * converts it into a sequence of `LanguageModelV2Content` parts.
62
+ * converts it into a sequence of `LanguageModelV3Content` parts.
63
63
  *
64
64
  * Implementations should:
65
65
  * - Detect tool-call segments addressed to known `tools` and emit
@@ -75,14 +75,14 @@ interface ToolCallProtocol {
75
75
  */
76
76
  parseGeneratedText({ text, tools, options, }: {
77
77
  text: string;
78
- tools: LanguageModelV2FunctionTool[];
78
+ tools: LanguageModelV3FunctionTool[];
79
79
  options?: {
80
80
  onError?: (message: string, metadata?: Record<string, unknown>) => void;
81
81
  };
82
- }): LanguageModelV2Content[];
82
+ }): LanguageModelV3Content[];
83
83
  /**
84
84
  * Creates a TransformStream that converts streaming model deltas
85
- * (`LanguageModelV2StreamPart`) into a normalized sequence of stream parts,
85
+ * (`LanguageModelV3StreamPart`) into a normalized sequence of stream parts,
86
86
  * including `text-start`/`text-delta`/`text-end` and `tool-call` events.
87
87
  *
88
88
  * The stream parser should:
@@ -94,14 +94,14 @@ interface ToolCallProtocol {
94
94
  *
95
95
  * @param tools The list of tools that may be invoked by the model.
96
96
  * @param options Optional error callback for non-fatal streaming issues.
97
- * @returns A TransformStream that accepts and emits `LanguageModelV2StreamPart`s.
97
+ * @returns A TransformStream that accepts and emits `LanguageModelV3StreamPart`s.
98
98
  */
99
99
  createStreamParser({ tools, options, }: {
100
- tools: LanguageModelV2FunctionTool[];
100
+ tools: LanguageModelV3FunctionTool[];
101
101
  options?: {
102
102
  onError?: (message: string, metadata?: Record<string, unknown>) => void;
103
103
  };
104
- }): TransformStream<LanguageModelV2StreamPart, LanguageModelV2StreamPart>;
104
+ }): TransformStream<LanguageModelV3StreamPart, LanguageModelV3StreamPart>;
105
105
  /**
106
106
  * Optionally returns the exact substrings that would be parsed as tool-calls
107
107
  * from the provided text for this protocol.
@@ -109,9 +109,9 @@ interface ToolCallProtocol {
109
109
  */
110
110
  extractToolCallSegments?: ({ text, tools, }: {
111
111
  text: string;
112
- tools: LanguageModelV2FunctionTool[];
112
+ tools: LanguageModelV3FunctionTool[];
113
113
  }) => string[];
114
- }
114
+ };
115
115
 
116
116
  type JsonMixOptions = {
117
117
  toolCallStart?: string;
@@ -126,7 +126,16 @@ declare const morphXmlProtocol: () => ToolCallProtocol;
126
126
  declare function createToolMiddleware({ protocol, toolSystemPromptTemplate, }: {
127
127
  protocol: ToolCallProtocol | (() => ToolCallProtocol);
128
128
  toolSystemPromptTemplate: (tools: string) => string;
129
- }): LanguageModelV2Middleware;
129
+ }): LanguageModelV3Middleware;
130
+
131
+ type DebugLevel = "off" | "stream" | "parse";
132
+ declare function getDebugLevel(): DebugLevel;
133
+ declare function logRawChunk(part: unknown): void;
134
+ declare function logParsedChunk(part: unknown): void;
135
+ declare function logParsedSummary({ toolCalls, originalText, }: {
136
+ toolCalls: unknown[];
137
+ originalText: string;
138
+ }): void;
130
139
 
131
140
  /**
132
141
  * Dynamically generates a JSON Schema using 'if/then/else' to simulate 'oneOf' behavior
@@ -136,12 +145,12 @@ declare function createToolMiddleware({ protocol, toolSystemPromptTemplate, }: {
136
145
  * matches exactly one of the provided tools based on its 'name' property,
137
146
  * and then applies the corresponding tool's 'parameters' schema to its 'arguments' property.
138
147
  *
139
- * @param tools An array of tool definitions (LanguageModelV2FunctionTool or LanguageModelV2ProviderDefinedTool).
148
+ * @param tools An array of tool definitions (LanguageModelV3FunctionTool or LanguageModelV3ProviderDefinedTool).
140
149
  * Each tool must have a unique 'name' and its 'parameters' must be a valid JSON Schema.
141
150
  * @returns A JSONSchema7 object representing the dynamic validation logic.
142
151
  * @throws Error if a 'provider-defined' tool is encountered, as they are not supported by this middleware.
143
152
  */
144
- declare function createDynamicIfThenElseSchema(tools: (LanguageModelV2FunctionTool | LanguageModelV2ProviderDefinedTool)[]): JSONSchema7;
153
+ declare function createDynamicIfThenElseSchema(tools: (LanguageModelV3FunctionTool | LanguageModelV3ProviderDefinedTool)[]): JSONSchema7;
145
154
 
146
155
  /**
147
156
  * Returns the index of the start of the searchedText in the text, or null if it
@@ -150,6 +159,53 @@ declare function createDynamicIfThenElseSchema(tools: (LanguageModelV2FunctionTo
150
159
  */
151
160
  declare function getPotentialStartIndex(text: string, searchedText: string): number | null;
152
161
 
162
+ type OnErrorFn = (message: string, metadata?: Record<string, unknown>) => void;
163
+ declare function extractOnErrorOption(providerOptions?: unknown): {
164
+ onError?: OnErrorFn;
165
+ } | undefined;
166
+
167
+ type ToolCallMiddlewareProviderOptions = {
168
+ toolCallMiddleware?: {
169
+ debugSummary?: {
170
+ originalText?: string;
171
+ toolCalls?: string;
172
+ };
173
+ toolChoice?: {
174
+ type: string;
175
+ toolName?: string;
176
+ };
177
+ originalTools?: Array<{
178
+ name: string;
179
+ inputSchema: string;
180
+ }>;
181
+ };
182
+ };
183
+ declare const originalToolsSchema: {
184
+ encode: typeof encodeOriginalTools;
185
+ decode: typeof decodeOriginalTools;
186
+ };
187
+ declare function encodeOriginalTools(tools: LanguageModelV3FunctionTool[] | undefined): Array<{
188
+ name: string;
189
+ inputSchema: string;
190
+ }>;
191
+ declare function decodeOriginalTools(originalTools: Array<{
192
+ name: string;
193
+ inputSchema: string;
194
+ }> | undefined): LanguageModelV3FunctionTool[];
195
+ declare function extractToolNamesFromOriginalTools(originalTools: Array<{
196
+ name: string;
197
+ inputSchema: string;
198
+ }> | undefined): string[];
199
+ declare function isToolChoiceActive(params: {
200
+ providerOptions?: {
201
+ toolCallMiddleware?: {
202
+ toolChoice?: {
203
+ type: string;
204
+ };
205
+ };
206
+ };
207
+ }): boolean;
208
+
153
209
  declare function escapeRegExp(literal: string): string;
154
210
 
155
211
  /**
@@ -267,69 +323,14 @@ declare namespace robustJson {
267
323
  export { type robustJson_ParseOptions as ParseOptions, robustJson_parse as parse, robustJson_stringify as stringify, robustJson_transform as transform };
268
324
  }
269
325
 
270
- type DebugLevel = "off" | "stream" | "parse";
271
- declare function getDebugLevel(): DebugLevel;
272
- declare function logRawChunk(part: unknown): void;
273
- declare function logParsedChunk(part: unknown): void;
274
- declare function logParsedSummary({ toolCalls, originalText, }: {
275
- toolCalls: unknown[];
276
- originalText: string;
277
- }): void;
278
-
279
- type OnErrorFn = (message: string, metadata?: Record<string, unknown>) => void;
280
- declare function extractOnErrorOption(providerOptions?: unknown): {
281
- onError?: OnErrorFn;
282
- } | undefined;
283
-
284
- type ToolCallMiddlewareProviderOptions = {
285
- toolCallMiddleware?: {
286
- debugSummary?: {
287
- originalText?: string;
288
- toolCalls?: string;
289
- };
290
- toolChoice?: {
291
- type: string;
292
- };
293
- originalTools?: Array<{
294
- name: string;
295
- inputSchema: string;
296
- }>;
297
- };
298
- };
299
- declare const originalToolsSchema: {
300
- encode: typeof encodeOriginalTools;
301
- decode: typeof decodeOriginalTools;
302
- };
303
- declare function encodeOriginalTools(tools: LanguageModelV2FunctionTool[] | undefined): Array<{
304
- name: string;
305
- inputSchema: string;
306
- }>;
307
- declare function decodeOriginalTools(originalTools: Array<{
308
- name: string;
309
- inputSchema: string;
310
- }> | undefined): LanguageModelV2FunctionTool[];
311
- declare function extractToolNamesFromOriginalTools(originalTools: Array<{
312
- name: string;
313
- inputSchema: string;
314
- }> | undefined): string[];
315
- declare function isToolChoiceActive(params: {
316
- providerOptions?: {
317
- toolCallMiddleware?: {
318
- toolChoice?: {
319
- type: string;
320
- };
321
- };
322
- };
323
- }): boolean;
324
-
325
- declare function isToolCallContent(content: unknown): content is LanguageModelV2ToolCall;
326
- declare function isToolResultPart(content: unknown): content is LanguageModelV2ToolResultPart;
326
+ declare function isToolCallContent(content: unknown): content is LanguageModelV3ToolCall;
327
+ declare function isToolResultPart(content: unknown): content is LanguageModelV3ToolResultPart;
327
328
  declare function hasInputProperty(obj: unknown): obj is {
328
329
  input?: unknown;
329
330
  };
330
331
 
331
- declare const gemmaToolMiddleware: _ai_sdk_provider.LanguageModelV2Middleware;
332
- declare const hermesToolMiddleware: _ai_sdk_provider.LanguageModelV2Middleware;
333
- declare const morphXmlToolMiddleware: _ai_sdk_provider.LanguageModelV2Middleware;
332
+ declare const gemmaToolMiddleware: _ai_sdk_provider.LanguageModelV3Middleware;
333
+ declare const hermesToolMiddleware: _ai_sdk_provider.LanguageModelV3Middleware;
334
+ declare const morphXmlToolMiddleware: _ai_sdk_provider.LanguageModelV3Middleware;
334
335
 
335
- export { type DebugLevel, type OnErrorFn, robustJson as RJSON, type ToolCallMiddlewareProviderOptions, createDynamicIfThenElseSchema, createToolMiddleware, decodeOriginalTools, encodeOriginalTools, escapeRegExp, extractOnErrorOption, extractToolNamesFromOriginalTools, gemmaToolMiddleware, getDebugLevel, getPotentialStartIndex, hasInputProperty, hermesToolMiddleware, isToolCallContent, isToolChoiceActive, isToolResultPart, jsonMixProtocol, logParsedChunk, logParsedSummary, logRawChunk, morphXmlProtocol, morphXmlToolMiddleware, originalToolsSchema };
336
+ export { type DebugLevel, type OnErrorFn, robustJson as RJSON, type ParseOptions as RJSONParseOptions, type ToolCallMiddlewareProviderOptions, createDynamicIfThenElseSchema, createToolMiddleware, decodeOriginalTools, encodeOriginalTools, escapeRegExp, extractOnErrorOption, extractToolNamesFromOriginalTools, gemmaToolMiddleware, getDebugLevel, getPotentialStartIndex, hasInputProperty, hermesToolMiddleware, isToolCallContent, isToolChoiceActive, isToolResultPart, jsonMixProtocol, logParsedChunk, logParsedSummary, logRawChunk, morphXmlProtocol, morphXmlToolMiddleware, originalToolsSchema, parse as parseRJSON, stringify as stringifyRJSON, transform as transformRJSON };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as _ai_sdk_provider from '@ai-sdk/provider';
2
- import { LanguageModelV2FunctionTool, LanguageModelV2ToolCall, LanguageModelV2ToolResultPart, LanguageModelV2Content, LanguageModelV2StreamPart, LanguageModelV2Middleware, LanguageModelV2ProviderDefinedTool, JSONSchema7 } from '@ai-sdk/provider';
2
+ import { LanguageModelV3FunctionTool, LanguageModelV3ToolCall, LanguageModelV3ToolResultPart, LanguageModelV3Content, LanguageModelV3StreamPart, LanguageModelV3Middleware, LanguageModelV3ProviderDefinedTool, JSONSchema7 } from '@ai-sdk/provider';
3
3
 
4
4
  /**
5
5
  * ToolCallProtocol
@@ -13,10 +13,10 @@ import { LanguageModelV2FunctionTool, LanguageModelV2ToolCall, LanguageModelV2To
13
13
  * - Static formatting helpers (`formatTools`, `formatToolCall`, `formatToolResponse`)
14
14
  * are used to construct strings that the model will read.
15
15
  * - Parsing helpers (`parseGeneratedText`, `createStreamParser`) must convert
16
- * model output back into structured `LanguageModelV2Content` parts, emitting
16
+ * model output back into structured `LanguageModelV3Content` parts, emitting
17
17
  * `text` for regular content and `tool-call` for detected tool invocations.
18
18
  */
19
- interface ToolCallProtocol {
19
+ type ToolCallProtocol = {
20
20
  /**
21
21
  * Produces a provider-facing string that describes all available tools.
22
22
  *
@@ -32,7 +32,7 @@ interface ToolCallProtocol {
32
32
  * @returns A string to be embedded into the model's system prompt.
33
33
  */
34
34
  formatTools({ tools, toolSystemPromptTemplate, }: {
35
- tools: LanguageModelV2FunctionTool[];
35
+ tools: LanguageModelV3FunctionTool[];
36
36
  toolSystemPromptTemplate: (tools: string) => string;
37
37
  }): string;
38
38
  /**
@@ -46,7 +46,7 @@ interface ToolCallProtocol {
46
46
  * @param toolCall The tool call to format for the model.
47
47
  * @returns A textual representation of the tool call (e.g., an XML element).
48
48
  */
49
- formatToolCall(toolCall: LanguageModelV2ToolCall): string;
49
+ formatToolCall(toolCall: LanguageModelV3ToolCall): string;
50
50
  /**
51
51
  * Formats a tool result payload so the model can consume it as plain text.
52
52
  *
@@ -56,10 +56,10 @@ interface ToolCallProtocol {
56
56
  * @param toolResult The result part produced after executing a tool.
57
57
  * @returns Textual representation of the tool result for the model.
58
58
  */
59
- formatToolResponse(toolResult: LanguageModelV2ToolResultPart): string;
59
+ formatToolResponse(toolResult: LanguageModelV3ToolResultPart): string;
60
60
  /**
61
61
  * Parses a fully generated text (non-streaming) response from the model and
62
- * converts it into a sequence of `LanguageModelV2Content` parts.
62
+ * converts it into a sequence of `LanguageModelV3Content` parts.
63
63
  *
64
64
  * Implementations should:
65
65
  * - Detect tool-call segments addressed to known `tools` and emit
@@ -75,14 +75,14 @@ interface ToolCallProtocol {
75
75
  */
76
76
  parseGeneratedText({ text, tools, options, }: {
77
77
  text: string;
78
- tools: LanguageModelV2FunctionTool[];
78
+ tools: LanguageModelV3FunctionTool[];
79
79
  options?: {
80
80
  onError?: (message: string, metadata?: Record<string, unknown>) => void;
81
81
  };
82
- }): LanguageModelV2Content[];
82
+ }): LanguageModelV3Content[];
83
83
  /**
84
84
  * Creates a TransformStream that converts streaming model deltas
85
- * (`LanguageModelV2StreamPart`) into a normalized sequence of stream parts,
85
+ * (`LanguageModelV3StreamPart`) into a normalized sequence of stream parts,
86
86
  * including `text-start`/`text-delta`/`text-end` and `tool-call` events.
87
87
  *
88
88
  * The stream parser should:
@@ -94,14 +94,14 @@ interface ToolCallProtocol {
94
94
  *
95
95
  * @param tools The list of tools that may be invoked by the model.
96
96
  * @param options Optional error callback for non-fatal streaming issues.
97
- * @returns A TransformStream that accepts and emits `LanguageModelV2StreamPart`s.
97
+ * @returns A TransformStream that accepts and emits `LanguageModelV3StreamPart`s.
98
98
  */
99
99
  createStreamParser({ tools, options, }: {
100
- tools: LanguageModelV2FunctionTool[];
100
+ tools: LanguageModelV3FunctionTool[];
101
101
  options?: {
102
102
  onError?: (message: string, metadata?: Record<string, unknown>) => void;
103
103
  };
104
- }): TransformStream<LanguageModelV2StreamPart, LanguageModelV2StreamPart>;
104
+ }): TransformStream<LanguageModelV3StreamPart, LanguageModelV3StreamPart>;
105
105
  /**
106
106
  * Optionally returns the exact substrings that would be parsed as tool-calls
107
107
  * from the provided text for this protocol.
@@ -109,9 +109,9 @@ interface ToolCallProtocol {
109
109
  */
110
110
  extractToolCallSegments?: ({ text, tools, }: {
111
111
  text: string;
112
- tools: LanguageModelV2FunctionTool[];
112
+ tools: LanguageModelV3FunctionTool[];
113
113
  }) => string[];
114
- }
114
+ };
115
115
 
116
116
  type JsonMixOptions = {
117
117
  toolCallStart?: string;
@@ -126,7 +126,16 @@ declare const morphXmlProtocol: () => ToolCallProtocol;
126
126
  declare function createToolMiddleware({ protocol, toolSystemPromptTemplate, }: {
127
127
  protocol: ToolCallProtocol | (() => ToolCallProtocol);
128
128
  toolSystemPromptTemplate: (tools: string) => string;
129
- }): LanguageModelV2Middleware;
129
+ }): LanguageModelV3Middleware;
130
+
131
+ type DebugLevel = "off" | "stream" | "parse";
132
+ declare function getDebugLevel(): DebugLevel;
133
+ declare function logRawChunk(part: unknown): void;
134
+ declare function logParsedChunk(part: unknown): void;
135
+ declare function logParsedSummary({ toolCalls, originalText, }: {
136
+ toolCalls: unknown[];
137
+ originalText: string;
138
+ }): void;
130
139
 
131
140
  /**
132
141
  * Dynamically generates a JSON Schema using 'if/then/else' to simulate 'oneOf' behavior
@@ -136,12 +145,12 @@ declare function createToolMiddleware({ protocol, toolSystemPromptTemplate, }: {
136
145
  * matches exactly one of the provided tools based on its 'name' property,
137
146
  * and then applies the corresponding tool's 'parameters' schema to its 'arguments' property.
138
147
  *
139
- * @param tools An array of tool definitions (LanguageModelV2FunctionTool or LanguageModelV2ProviderDefinedTool).
148
+ * @param tools An array of tool definitions (LanguageModelV3FunctionTool or LanguageModelV3ProviderDefinedTool).
140
149
  * Each tool must have a unique 'name' and its 'parameters' must be a valid JSON Schema.
141
150
  * @returns A JSONSchema7 object representing the dynamic validation logic.
142
151
  * @throws Error if a 'provider-defined' tool is encountered, as they are not supported by this middleware.
143
152
  */
144
- declare function createDynamicIfThenElseSchema(tools: (LanguageModelV2FunctionTool | LanguageModelV2ProviderDefinedTool)[]): JSONSchema7;
153
+ declare function createDynamicIfThenElseSchema(tools: (LanguageModelV3FunctionTool | LanguageModelV3ProviderDefinedTool)[]): JSONSchema7;
145
154
 
146
155
  /**
147
156
  * Returns the index of the start of the searchedText in the text, or null if it
@@ -150,6 +159,53 @@ declare function createDynamicIfThenElseSchema(tools: (LanguageModelV2FunctionTo
150
159
  */
151
160
  declare function getPotentialStartIndex(text: string, searchedText: string): number | null;
152
161
 
162
+ type OnErrorFn = (message: string, metadata?: Record<string, unknown>) => void;
163
+ declare function extractOnErrorOption(providerOptions?: unknown): {
164
+ onError?: OnErrorFn;
165
+ } | undefined;
166
+
167
+ type ToolCallMiddlewareProviderOptions = {
168
+ toolCallMiddleware?: {
169
+ debugSummary?: {
170
+ originalText?: string;
171
+ toolCalls?: string;
172
+ };
173
+ toolChoice?: {
174
+ type: string;
175
+ toolName?: string;
176
+ };
177
+ originalTools?: Array<{
178
+ name: string;
179
+ inputSchema: string;
180
+ }>;
181
+ };
182
+ };
183
+ declare const originalToolsSchema: {
184
+ encode: typeof encodeOriginalTools;
185
+ decode: typeof decodeOriginalTools;
186
+ };
187
+ declare function encodeOriginalTools(tools: LanguageModelV3FunctionTool[] | undefined): Array<{
188
+ name: string;
189
+ inputSchema: string;
190
+ }>;
191
+ declare function decodeOriginalTools(originalTools: Array<{
192
+ name: string;
193
+ inputSchema: string;
194
+ }> | undefined): LanguageModelV3FunctionTool[];
195
+ declare function extractToolNamesFromOriginalTools(originalTools: Array<{
196
+ name: string;
197
+ inputSchema: string;
198
+ }> | undefined): string[];
199
+ declare function isToolChoiceActive(params: {
200
+ providerOptions?: {
201
+ toolCallMiddleware?: {
202
+ toolChoice?: {
203
+ type: string;
204
+ };
205
+ };
206
+ };
207
+ }): boolean;
208
+
153
209
  declare function escapeRegExp(literal: string): string;
154
210
 
155
211
  /**
@@ -267,69 +323,14 @@ declare namespace robustJson {
267
323
  export { type robustJson_ParseOptions as ParseOptions, robustJson_parse as parse, robustJson_stringify as stringify, robustJson_transform as transform };
268
324
  }
269
325
 
270
- type DebugLevel = "off" | "stream" | "parse";
271
- declare function getDebugLevel(): DebugLevel;
272
- declare function logRawChunk(part: unknown): void;
273
- declare function logParsedChunk(part: unknown): void;
274
- declare function logParsedSummary({ toolCalls, originalText, }: {
275
- toolCalls: unknown[];
276
- originalText: string;
277
- }): void;
278
-
279
- type OnErrorFn = (message: string, metadata?: Record<string, unknown>) => void;
280
- declare function extractOnErrorOption(providerOptions?: unknown): {
281
- onError?: OnErrorFn;
282
- } | undefined;
283
-
284
- type ToolCallMiddlewareProviderOptions = {
285
- toolCallMiddleware?: {
286
- debugSummary?: {
287
- originalText?: string;
288
- toolCalls?: string;
289
- };
290
- toolChoice?: {
291
- type: string;
292
- };
293
- originalTools?: Array<{
294
- name: string;
295
- inputSchema: string;
296
- }>;
297
- };
298
- };
299
- declare const originalToolsSchema: {
300
- encode: typeof encodeOriginalTools;
301
- decode: typeof decodeOriginalTools;
302
- };
303
- declare function encodeOriginalTools(tools: LanguageModelV2FunctionTool[] | undefined): Array<{
304
- name: string;
305
- inputSchema: string;
306
- }>;
307
- declare function decodeOriginalTools(originalTools: Array<{
308
- name: string;
309
- inputSchema: string;
310
- }> | undefined): LanguageModelV2FunctionTool[];
311
- declare function extractToolNamesFromOriginalTools(originalTools: Array<{
312
- name: string;
313
- inputSchema: string;
314
- }> | undefined): string[];
315
- declare function isToolChoiceActive(params: {
316
- providerOptions?: {
317
- toolCallMiddleware?: {
318
- toolChoice?: {
319
- type: string;
320
- };
321
- };
322
- };
323
- }): boolean;
324
-
325
- declare function isToolCallContent(content: unknown): content is LanguageModelV2ToolCall;
326
- declare function isToolResultPart(content: unknown): content is LanguageModelV2ToolResultPart;
326
+ declare function isToolCallContent(content: unknown): content is LanguageModelV3ToolCall;
327
+ declare function isToolResultPart(content: unknown): content is LanguageModelV3ToolResultPart;
327
328
  declare function hasInputProperty(obj: unknown): obj is {
328
329
  input?: unknown;
329
330
  };
330
331
 
331
- declare const gemmaToolMiddleware: _ai_sdk_provider.LanguageModelV2Middleware;
332
- declare const hermesToolMiddleware: _ai_sdk_provider.LanguageModelV2Middleware;
333
- declare const morphXmlToolMiddleware: _ai_sdk_provider.LanguageModelV2Middleware;
332
+ declare const gemmaToolMiddleware: _ai_sdk_provider.LanguageModelV3Middleware;
333
+ declare const hermesToolMiddleware: _ai_sdk_provider.LanguageModelV3Middleware;
334
+ declare const morphXmlToolMiddleware: _ai_sdk_provider.LanguageModelV3Middleware;
334
335
 
335
- export { type DebugLevel, type OnErrorFn, robustJson as RJSON, type ToolCallMiddlewareProviderOptions, createDynamicIfThenElseSchema, createToolMiddleware, decodeOriginalTools, encodeOriginalTools, escapeRegExp, extractOnErrorOption, extractToolNamesFromOriginalTools, gemmaToolMiddleware, getDebugLevel, getPotentialStartIndex, hasInputProperty, hermesToolMiddleware, isToolCallContent, isToolChoiceActive, isToolResultPart, jsonMixProtocol, logParsedChunk, logParsedSummary, logRawChunk, morphXmlProtocol, morphXmlToolMiddleware, originalToolsSchema };
336
+ export { type DebugLevel, type OnErrorFn, robustJson as RJSON, type ParseOptions as RJSONParseOptions, type ToolCallMiddlewareProviderOptions, createDynamicIfThenElseSchema, createToolMiddleware, decodeOriginalTools, encodeOriginalTools, escapeRegExp, extractOnErrorOption, extractToolNamesFromOriginalTools, gemmaToolMiddleware, getDebugLevel, getPotentialStartIndex, hasInputProperty, hermesToolMiddleware, isToolCallContent, isToolChoiceActive, isToolResultPart, jsonMixProtocol, logParsedChunk, logParsedSummary, logRawChunk, morphXmlProtocol, morphXmlToolMiddleware, originalToolsSchema, parse as parseRJSON, stringify as stringifyRJSON, transform as transformRJSON };
package/dist/index.js CHANGED
@@ -21,8 +21,11 @@ import {
21
21
  morphXmlProtocol,
22
22
  morphXmlToolMiddleware,
23
23
  originalToolsSchema,
24
- robust_json_exports
25
- } from "./chunk-GSD5HDOQ.js";
24
+ parse,
25
+ robust_json_exports,
26
+ stringify,
27
+ transform
28
+ } from "./chunk-FOANBZRH.js";
26
29
  export {
27
30
  robust_json_exports as RJSON,
28
31
  createDynamicIfThenElseSchema,
@@ -46,6 +49,9 @@ export {
46
49
  logRawChunk,
47
50
  morphXmlProtocol,
48
51
  morphXmlToolMiddleware,
49
- originalToolsSchema
52
+ originalToolsSchema,
53
+ parse as parseRJSON,
54
+ stringify as stringifyRJSON,
55
+ transform as transformRJSON
50
56
  };
51
57
  //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-sdk-tool/parser",
3
- "version": "2.1.7",
3
+ "version": "3.0.0-canary.0",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -28,27 +28,21 @@
28
28
  "author": "",
29
29
  "license": "Apache-2.0",
30
30
  "dependencies": {
31
- "@ai-sdk/provider": "2.0.0",
32
- "@ai-sdk/provider-utils": "3.0.7",
31
+ "@ai-sdk/provider": "3.0.0-beta.14",
32
+ "@ai-sdk/provider-utils": "4.0.0-beta.30",
33
33
  "@ai-sdk-tool/rxml": "0.1.1"
34
34
  },
35
35
  "devDependencies": {
36
- "@ai-sdk/openai-compatible": "1.0.13",
37
- "@types/node": "^24.3.0",
38
- "@vitest/coverage-istanbul": "^3.2.4",
39
- "ai": "5.0.28",
36
+ "@ai-sdk/openai-compatible": "2.0.0-beta.31",
37
+ "@types/node": "^24.10.0",
38
+ "ai": "6.0.0-beta.92",
40
39
  "tsup": "^8.5.0",
41
- "vite": "^7.1.3",
42
- "vitest": "^3.2.4",
43
- "zod": "^4.1.5"
40
+ "zod": "^4.1.12"
44
41
  },
45
42
  "scripts": {
46
43
  "build": "tsup",
47
44
  "dev": "tsup --watch",
48
45
  "test": "vitest run",
49
- "test:watch": "vitest --watch",
50
- "check-types": "tsc --noEmit",
51
- "lint": "eslint src tests --ext .ts,.tsx",
52
- "lint:fix": "eslint src tests --ext .ts,.tsx --fix"
46
+ "typecheck": "tsc --noEmit"
53
47
  }
54
48
  }