@ai-sdk-tool/parser 3.3.1 → 3.3.2

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
@@ -3,6 +3,12 @@ import { LanguageModelV3FunctionTool, LanguageModelV3ToolCall, LanguageModelV3Co
3
3
  import { ToolResultPart } from '@ai-sdk/provider-utils';
4
4
  export { ParseOptions, parse, stringify, transform } from './rjson.cjs';
5
5
 
6
+ /**
7
+ * Options for parsing tool calls and handling errors
8
+ */
9
+ interface ParserOptions {
10
+ onError?: (message: string, metadata?: Record<string, unknown>) => void;
11
+ }
6
12
  interface TCMProtocol {
7
13
  formatTools({ tools, toolSystemPromptTemplate, }: {
8
14
  tools: LanguageModelV3FunctionTool[];
@@ -261,4 +267,4 @@ declare function transformParams({ params, protocol, toolSystemPromptTemplate, t
261
267
  toolChoice: undefined;
262
268
  };
263
269
 
264
- export { type DebugLevel, type OnErrorFn, type TCMCoreProtocol, type TCMProtocol, type ToolCallMiddlewareProviderOptions, type XmlProtocolOptions, type YamlProtocolOptions, createDynamicIfThenElseSchema, createToolMiddleware, decodeOriginalTools, encodeOriginalTools, escapeRegExp, extractOnErrorOption, extractToolNamesFromOriginalTools, getDebugLevel, getPotentialStartIndex, hasInputProperty, hermesToolMiddleware, isProtocolFactory, isTCMProtocolFactory, isToolChoiceActive, isToolResultPart, jsonProtocol, logParseFailure, logParsedChunk, logParsedSummary, logRawChunk, originalToolsSchema, toolChoiceStream, transformParams, wrapGenerate, wrapStream, xmlProtocol, xmlToolMiddleware, yamlProtocol, yamlToolMiddleware };
270
+ export { type DebugLevel, type OnErrorFn, type ParserOptions, type TCMCoreProtocol, type TCMProtocol, type ToolCallMiddlewareProviderOptions, type XmlProtocolOptions, type YamlProtocolOptions, createDynamicIfThenElseSchema, createToolMiddleware, decodeOriginalTools, encodeOriginalTools, escapeRegExp, extractOnErrorOption, extractToolNamesFromOriginalTools, getDebugLevel, getPotentialStartIndex, hasInputProperty, hermesToolMiddleware, isProtocolFactory, isTCMProtocolFactory, isToolChoiceActive, isToolResultPart, jsonProtocol, logParseFailure, logParsedChunk, logParsedSummary, logRawChunk, originalToolsSchema, toolChoiceStream, transformParams, wrapGenerate, wrapStream, xmlProtocol, xmlToolMiddleware, yamlProtocol, yamlToolMiddleware };
package/dist/index.d.ts CHANGED
@@ -3,6 +3,12 @@ import { LanguageModelV3FunctionTool, LanguageModelV3ToolCall, LanguageModelV3Co
3
3
  import { ToolResultPart } from '@ai-sdk/provider-utils';
4
4
  export { ParseOptions, parse, stringify, transform } from './rjson.js';
5
5
 
6
+ /**
7
+ * Options for parsing tool calls and handling errors
8
+ */
9
+ interface ParserOptions {
10
+ onError?: (message: string, metadata?: Record<string, unknown>) => void;
11
+ }
6
12
  interface TCMProtocol {
7
13
  formatTools({ tools, toolSystemPromptTemplate, }: {
8
14
  tools: LanguageModelV3FunctionTool[];
@@ -261,4 +267,4 @@ declare function transformParams({ params, protocol, toolSystemPromptTemplate, t
261
267
  toolChoice: undefined;
262
268
  };
263
269
 
264
- export { type DebugLevel, type OnErrorFn, type TCMCoreProtocol, type TCMProtocol, type ToolCallMiddlewareProviderOptions, type XmlProtocolOptions, type YamlProtocolOptions, createDynamicIfThenElseSchema, createToolMiddleware, decodeOriginalTools, encodeOriginalTools, escapeRegExp, extractOnErrorOption, extractToolNamesFromOriginalTools, getDebugLevel, getPotentialStartIndex, hasInputProperty, hermesToolMiddleware, isProtocolFactory, isTCMProtocolFactory, isToolChoiceActive, isToolResultPart, jsonProtocol, logParseFailure, logParsedChunk, logParsedSummary, logRawChunk, originalToolsSchema, toolChoiceStream, transformParams, wrapGenerate, wrapStream, xmlProtocol, xmlToolMiddleware, yamlProtocol, yamlToolMiddleware };
270
+ export { type DebugLevel, type OnErrorFn, type ParserOptions, type TCMCoreProtocol, type TCMProtocol, type ToolCallMiddlewareProviderOptions, type XmlProtocolOptions, type YamlProtocolOptions, createDynamicIfThenElseSchema, createToolMiddleware, decodeOriginalTools, encodeOriginalTools, escapeRegExp, extractOnErrorOption, extractToolNamesFromOriginalTools, getDebugLevel, getPotentialStartIndex, hasInputProperty, hermesToolMiddleware, isProtocolFactory, isTCMProtocolFactory, isToolChoiceActive, isToolResultPart, jsonProtocol, logParseFailure, logParsedChunk, logParsedSummary, logRawChunk, originalToolsSchema, toolChoiceStream, transformParams, wrapGenerate, wrapStream, xmlProtocol, xmlToolMiddleware, yamlProtocol, yamlToolMiddleware };
package/dist/index.js CHANGED
@@ -3,7 +3,6 @@ import {
3
3
  createToolMiddleware,
4
4
  decodeOriginalTools,
5
5
  encodeOriginalTools,
6
- escapeRegExp,
7
6
  extractOnErrorOption,
8
7
  extractToolNamesFromOriginalTools,
9
8
  getDebugLevel,
@@ -28,8 +27,10 @@ import {
28
27
  xmlToolMiddleware,
29
28
  yamlProtocol,
30
29
  yamlToolMiddleware
31
- } from "./chunk-7E6UFDFQ.js";
32
- import "./chunk-EW3A6Y7O.js";
30
+ } from "./chunk-5WKXBBCU.js";
31
+ import {
32
+ escapeRegExp
33
+ } from "./chunk-ZDBNJWLY.js";
33
34
  import {
34
35
  parse,
35
36
  stringify,
package/dist/rxml.cjs CHANGED
@@ -2250,6 +2250,11 @@ function createIntermediateCall(toolName, rawSegment, schema) {
2250
2250
  };
2251
2251
  }
2252
2252
 
2253
+ // src/core/utils/regex.ts
2254
+ function escapeRegExp(literal) {
2255
+ return literal.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
2256
+ }
2257
+
2253
2258
  // src/rxml/heuristics/xml-defaults.ts
2254
2259
  var MALFORMED_CLOSE_RE_G = /<\/\s+([A-Za-z0-9_:-]+)\s*>/g;
2255
2260
  var MALFORMED_CLOSE_RE = /<\/\s+([A-Za-z0-9_:-]+)\s*>/;
@@ -2491,9 +2496,6 @@ function getStringPropertyNames(schema) {
2491
2496
  }
2492
2497
  return names;
2493
2498
  }
2494
- function escapeRegExp(s) {
2495
- return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
2496
- }
2497
2499
  function dedupeSingleTag(xml, key) {
2498
2500
  var _a, _b;
2499
2501
  const escaped = escapeRegExp(key);