@ai-sdk-tool/parser 4.1.6 → 4.1.8
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/{chunk-ZIOUCBCX.js → chunk-7EDEAFRX.js} +42 -42
- package/dist/{chunk-ZIOUCBCX.js.map → chunk-7EDEAFRX.js.map} +1 -1
- package/dist/{chunk-QBZNMO5C.js → chunk-A3DLFT2S.js} +2 -2
- package/dist/{chunk-QBZNMO5C.js.map → chunk-A3DLFT2S.js.map} +1 -1
- package/dist/{chunk-D4YULTAO.js → chunk-IATDQDRY.js} +2 -2
- package/dist/{chunk-D4YULTAO.js.map → chunk-IATDQDRY.js.map} +1 -1
- package/dist/community.cjs +41 -41
- package/dist/community.cjs.map +1 -1
- package/dist/community.js +3 -3
- package/dist/index.cjs +41 -41
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +3 -3
- package/dist/rjson.cjs +1 -1
- package/dist/rjson.cjs.map +1 -1
- package/dist/rjson.js +1 -1
- package/dist/rxml.cjs +1 -1
- package/dist/rxml.cjs.map +1 -1
- package/dist/rxml.js +1 -1
- package/package.json +3 -3
|
@@ -5,10 +5,10 @@ import {
|
|
|
5
5
|
parse as parse2,
|
|
6
6
|
stringify,
|
|
7
7
|
unescapeXml
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-IATDQDRY.js";
|
|
9
9
|
import {
|
|
10
10
|
parse
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-A3DLFT2S.js";
|
|
12
12
|
import {
|
|
13
13
|
coerceBySchema,
|
|
14
14
|
getSchemaType,
|
|
@@ -4794,19 +4794,19 @@ function processToolCallMatch(text, tc, currentIndex, processedElements, options
|
|
|
4794
4794
|
processedElements
|
|
4795
4795
|
);
|
|
4796
4796
|
const parsedArgs = parseYamlContent(tc.content, options);
|
|
4797
|
-
if (parsedArgs
|
|
4797
|
+
if (parsedArgs === null) {
|
|
4798
|
+
const originalText = text.substring(tc.startIndex, tc.endIndex);
|
|
4799
|
+
(_a = options == null ? void 0 : options.onError) == null ? void 0 : _a.call(options, "Could not parse YAML tool call", {
|
|
4800
|
+
toolCall: originalText
|
|
4801
|
+
});
|
|
4802
|
+
processedElements.push({ type: "text", text: originalText });
|
|
4803
|
+
} else {
|
|
4798
4804
|
processedElements.push({
|
|
4799
4805
|
type: "tool-call",
|
|
4800
4806
|
toolCallId: generateToolCallId(),
|
|
4801
4807
|
toolName: tc.toolName,
|
|
4802
4808
|
input: JSON.stringify(parsedArgs)
|
|
4803
4809
|
});
|
|
4804
|
-
} else {
|
|
4805
|
-
const originalText = text.substring(tc.startIndex, tc.endIndex);
|
|
4806
|
-
(_a = options == null ? void 0 : options.onError) == null ? void 0 : _a.call(options, "Could not parse YAML tool call", {
|
|
4807
|
-
toolCall: originalText
|
|
4808
|
-
});
|
|
4809
|
-
processedElements.push({ type: "text", text: originalText });
|
|
4810
4810
|
}
|
|
4811
4811
|
return tc.endIndex;
|
|
4812
4812
|
}
|
|
@@ -4930,7 +4930,22 @@ ${yamlContent}</${toolCall.toolName}>`;
|
|
|
4930
4930
|
var _a;
|
|
4931
4931
|
const parsedArgs = parseYamlContent(toolContent, options);
|
|
4932
4932
|
flushText(controller);
|
|
4933
|
-
if (parsedArgs
|
|
4933
|
+
if (parsedArgs === null) {
|
|
4934
|
+
const original = `<${toolName}>${toolContent}</${toolName}>`;
|
|
4935
|
+
const emitRawFallback = shouldEmitRawToolCallTextOnError(options);
|
|
4936
|
+
emitFailedToolInputLifecycle({
|
|
4937
|
+
controller,
|
|
4938
|
+
id: toolCallId,
|
|
4939
|
+
emitRawToolCallTextOnError: emitRawFallback,
|
|
4940
|
+
rawToolCallText: original,
|
|
4941
|
+
emitRawText: (rawText) => {
|
|
4942
|
+
flushText(controller, rawText);
|
|
4943
|
+
}
|
|
4944
|
+
});
|
|
4945
|
+
(_a = options == null ? void 0 : options.onError) == null ? void 0 : _a.call(options, "Could not parse streaming YAML tool call", {
|
|
4946
|
+
toolCall: original
|
|
4947
|
+
});
|
|
4948
|
+
} else {
|
|
4934
4949
|
const finalInput = stringifyToolInputWithSchema({
|
|
4935
4950
|
toolName,
|
|
4936
4951
|
args: parsedArgs,
|
|
@@ -4953,21 +4968,6 @@ ${yamlContent}</${toolCall.toolName}>`;
|
|
|
4953
4968
|
input: finalInput
|
|
4954
4969
|
});
|
|
4955
4970
|
}
|
|
4956
|
-
} else {
|
|
4957
|
-
const original = `<${toolName}>${toolContent}</${toolName}>`;
|
|
4958
|
-
const emitRawFallback = shouldEmitRawToolCallTextOnError(options);
|
|
4959
|
-
emitFailedToolInputLifecycle({
|
|
4960
|
-
controller,
|
|
4961
|
-
id: toolCallId,
|
|
4962
|
-
emitRawToolCallTextOnError: emitRawFallback,
|
|
4963
|
-
rawToolCallText: original,
|
|
4964
|
-
emitRawText: (rawText) => {
|
|
4965
|
-
flushText(controller, rawText);
|
|
4966
|
-
}
|
|
4967
|
-
});
|
|
4968
|
-
(_a = options == null ? void 0 : options.onError) == null ? void 0 : _a.call(options, "Could not parse streaming YAML tool call", {
|
|
4969
|
-
toolCall: original
|
|
4970
|
-
});
|
|
4971
4971
|
}
|
|
4972
4972
|
};
|
|
4973
4973
|
const finalizeUnclosedToolCall = (controller) => {
|
|
@@ -4980,21 +4980,7 @@ ${yamlContent}</${toolCall.toolName}>`;
|
|
|
4980
4980
|
const reconciledBuffer = stripTrailingPartialCloseTag(buffer, toolName);
|
|
4981
4981
|
const parsedArgs = parseYamlContent(reconciledBuffer, options);
|
|
4982
4982
|
flushText(controller);
|
|
4983
|
-
if (parsedArgs
|
|
4984
|
-
const finalInput = stringifyToolInputWithSchema({
|
|
4985
|
-
toolName,
|
|
4986
|
-
args: parsedArgs,
|
|
4987
|
-
tools
|
|
4988
|
-
});
|
|
4989
|
-
emitFinalizedToolInputLifecycle({
|
|
4990
|
-
controller,
|
|
4991
|
-
id: toolCallId,
|
|
4992
|
-
state: currentToolCall,
|
|
4993
|
-
toolName,
|
|
4994
|
-
finalInput,
|
|
4995
|
-
onMismatch: options == null ? void 0 : options.onError
|
|
4996
|
-
});
|
|
4997
|
-
} else {
|
|
4983
|
+
if (parsedArgs === null) {
|
|
4998
4984
|
const unfinishedContent = `<${toolName}>${buffer}`;
|
|
4999
4985
|
const emitRawFallback = shouldEmitRawToolCallTextOnError(options);
|
|
5000
4986
|
emitFailedToolInputLifecycle({
|
|
@@ -5011,6 +4997,20 @@ ${yamlContent}</${toolCall.toolName}>`;
|
|
|
5011
4997
|
"Could not complete streaming YAML tool call at finish.",
|
|
5012
4998
|
{ toolCall: unfinishedContent }
|
|
5013
4999
|
);
|
|
5000
|
+
} else {
|
|
5001
|
+
const finalInput = stringifyToolInputWithSchema({
|
|
5002
|
+
toolName,
|
|
5003
|
+
args: parsedArgs,
|
|
5004
|
+
tools
|
|
5005
|
+
});
|
|
5006
|
+
emitFinalizedToolInputLifecycle({
|
|
5007
|
+
controller,
|
|
5008
|
+
id: toolCallId,
|
|
5009
|
+
state: currentToolCall,
|
|
5010
|
+
toolName,
|
|
5011
|
+
finalInput,
|
|
5012
|
+
onMismatch: options == null ? void 0 : options.onError
|
|
5013
|
+
});
|
|
5014
5014
|
}
|
|
5015
5015
|
buffer = "";
|
|
5016
5016
|
currentToolCall = null;
|
|
@@ -5466,7 +5466,7 @@ function extractJsonLikeCandidates(rawText) {
|
|
|
5466
5466
|
}
|
|
5467
5467
|
function mergeJsonCandidatesByStart(tagged, codeBlocks, balanced) {
|
|
5468
5468
|
return [...tagged, ...codeBlocks, ...balanced].sort(
|
|
5469
|
-
(a, b) => a.startIndex
|
|
5469
|
+
(a, b) => a.startIndex === b.startIndex ? b.endIndex - a.endIndex : a.startIndex - b.startIndex
|
|
5470
5470
|
);
|
|
5471
5471
|
}
|
|
5472
5472
|
function toToolCallPart(candidate) {
|
|
@@ -7333,4 +7333,4 @@ export {
|
|
|
7333
7333
|
morphXmlToolMiddleware,
|
|
7334
7334
|
yamlXmlToolMiddleware
|
|
7335
7335
|
};
|
|
7336
|
-
//# sourceMappingURL=chunk-
|
|
7336
|
+
//# sourceMappingURL=chunk-7EDEAFRX.js.map
|