@ai-sdk-tool/parser 4.0.1 → 4.1.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/README.md +109 -20
- package/dist/{chunk-DPGORNPB.js → chunk-722D5BGD.js} +3339 -826
- package/dist/chunk-722D5BGD.js.map +1 -0
- package/dist/{chunk-76E6H46R.js → chunk-D4YULTAO.js} +11 -8
- package/dist/chunk-D4YULTAO.js.map +1 -0
- package/dist/{chunk-DJB4DAZO.js → chunk-GMTE7BY5.js} +1 -1
- package/dist/{chunk-DJB4DAZO.js.map → chunk-GMTE7BY5.js.map} +1 -1
- package/dist/{chunk-IX4FJELL.js → chunk-QBZNMO5C.js} +1 -1
- package/dist/chunk-QBZNMO5C.js.map +1 -0
- package/dist/community.cjs +7868 -5243
- package/dist/community.cjs.map +1 -1
- package/dist/community.d.cts +7 -1
- package/dist/community.d.ts +7 -1
- package/dist/community.js +128 -8
- package/dist/community.js.map +1 -1
- package/dist/index.cjs +7199 -4683
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +40 -62
- package/dist/index.d.ts +40 -62
- package/dist/index.js +28 -14
- package/dist/rjson.cjs.map +1 -1
- package/dist/rjson.d.cts +15 -15
- package/dist/rjson.d.ts +15 -15
- package/dist/rjson.js +1 -1
- package/dist/rxml.cjs +6 -6
- package/dist/rxml.cjs.map +1 -1
- package/dist/rxml.d.cts +23 -23
- package/dist/rxml.d.ts +23 -23
- package/dist/rxml.js +2 -2
- package/dist/schema-coerce.cjs.map +1 -1
- package/dist/schema-coerce.js +1 -1
- package/package.json +7 -7
- package/dist/chunk-76E6H46R.js.map +0 -1
- package/dist/chunk-DPGORNPB.js.map +0 -1
- package/dist/chunk-IX4FJELL.js.map +0 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _ai_sdk_provider from '@ai-sdk/provider';
|
|
2
|
-
import { LanguageModelV3FunctionTool, LanguageModelV3ToolCall, LanguageModelV3Content,
|
|
2
|
+
import { LanguageModelV3FunctionTool, LanguageModelV3StreamPart, LanguageModelV3ToolCall, LanguageModelV3Content, LanguageModelV3ProviderTool, JSONSchema7, SharedV3ProviderOptions, LanguageModelV3, LanguageModelV3TextPart, LanguageModelV3FilePart, LanguageModelV3Middleware, LanguageModelV3Prompt } from '@ai-sdk/provider';
|
|
3
3
|
import { ToolResultPart } from '@ai-sdk/provider-utils';
|
|
4
4
|
export { ParseOptions, parse, stringify, transform } from './rjson.cjs';
|
|
5
5
|
|
|
@@ -7,45 +7,45 @@ export { ParseOptions, parse, stringify, transform } from './rjson.cjs';
|
|
|
7
7
|
* Options for parsing tool calls and handling errors
|
|
8
8
|
*/
|
|
9
9
|
interface ParserOptions {
|
|
10
|
-
onError?: (message: string, metadata?: Record<string, unknown>) => void;
|
|
11
10
|
/**
|
|
12
11
|
* When true, stream parsers may emit malformed raw tool-call text as
|
|
13
12
|
* `text-delta` fallback on parse failure. Defaults to false to avoid leaking
|
|
14
13
|
* protocol/internal markup to end users.
|
|
15
14
|
*/
|
|
16
15
|
emitRawToolCallTextOnError?: boolean;
|
|
16
|
+
onError?: (message: string, metadata?: Record<string, unknown>) => void;
|
|
17
17
|
}
|
|
18
18
|
interface TCMProtocol {
|
|
19
|
+
createStreamParser({ tools, options, }: {
|
|
20
|
+
tools: LanguageModelV3FunctionTool[];
|
|
21
|
+
options?: ParserOptions;
|
|
22
|
+
}): TransformStream<LanguageModelV3StreamPart, LanguageModelV3StreamPart>;
|
|
23
|
+
extractToolCallSegments?: ({ text, tools, }: {
|
|
24
|
+
text: string;
|
|
25
|
+
tools: LanguageModelV3FunctionTool[];
|
|
26
|
+
}) => string[];
|
|
27
|
+
formatToolCall(toolCall: LanguageModelV3ToolCall): string;
|
|
19
28
|
formatTools({ tools, toolSystemPromptTemplate, }: {
|
|
20
29
|
tools: LanguageModelV3FunctionTool[];
|
|
21
30
|
toolSystemPromptTemplate: (tools: LanguageModelV3FunctionTool[]) => string;
|
|
22
31
|
}): string;
|
|
23
|
-
formatToolCall(toolCall: LanguageModelV3ToolCall): string;
|
|
24
32
|
parseGeneratedText({ text, tools, options, }: {
|
|
25
33
|
text: string;
|
|
26
34
|
tools: LanguageModelV3FunctionTool[];
|
|
27
35
|
options?: ParserOptions;
|
|
28
36
|
}): LanguageModelV3Content[];
|
|
29
|
-
createStreamParser({ tools, options, }: {
|
|
30
|
-
tools: LanguageModelV3FunctionTool[];
|
|
31
|
-
options?: ParserOptions;
|
|
32
|
-
}): TransformStream<LanguageModelV3StreamPart, LanguageModelV3StreamPart>;
|
|
33
|
-
extractToolCallSegments?: ({ text, tools, }: {
|
|
34
|
-
text: string;
|
|
35
|
-
tools: LanguageModelV3FunctionTool[];
|
|
36
|
-
}) => string[];
|
|
37
37
|
}
|
|
38
38
|
type TCMCoreProtocol = TCMProtocol;
|
|
39
39
|
declare function isProtocolFactory(protocol: TCMProtocol | (() => TCMProtocol)): protocol is () => TCMProtocol;
|
|
40
|
-
declare
|
|
40
|
+
declare const isTCMProtocolFactory: typeof isProtocolFactory;
|
|
41
41
|
|
|
42
|
-
interface
|
|
43
|
-
toolCallStart?: string;
|
|
42
|
+
interface HermesProtocolOptions {
|
|
44
43
|
toolCallEnd?: string;
|
|
44
|
+
toolCallStart?: string;
|
|
45
45
|
}
|
|
46
|
-
declare const
|
|
46
|
+
declare const hermesProtocol: ({ toolCallStart, toolCallEnd, }?: HermesProtocolOptions) => TCMProtocol;
|
|
47
47
|
|
|
48
|
-
interface
|
|
48
|
+
interface MorphXmlProtocolOptions {
|
|
49
49
|
parseOptions?: {
|
|
50
50
|
repair?: boolean;
|
|
51
51
|
maxReparses?: number;
|
|
@@ -54,16 +54,20 @@ interface XmlProtocolOptions {
|
|
|
54
54
|
[key: string]: unknown;
|
|
55
55
|
};
|
|
56
56
|
}
|
|
57
|
-
declare const
|
|
57
|
+
declare const morphXmlProtocol: (protocolOptions?: MorphXmlProtocolOptions) => TCMCoreProtocol;
|
|
58
|
+
|
|
59
|
+
declare const qwen3CoderProtocol: () => TCMProtocol;
|
|
60
|
+
declare const uiTarsXmlProtocol: () => TCMProtocol;
|
|
61
|
+
declare const Qwen3CoderToolParser: () => TCMProtocol;
|
|
58
62
|
|
|
59
|
-
interface
|
|
63
|
+
interface YamlXmlProtocolOptions {
|
|
60
64
|
/**
|
|
61
65
|
* Whether to include a system prompt example showing YAML multiline syntax.
|
|
62
66
|
* @default true
|
|
63
67
|
*/
|
|
64
68
|
includeMultilineExample?: boolean;
|
|
65
69
|
}
|
|
66
|
-
declare const
|
|
70
|
+
declare const yamlXmlProtocol: (_protocolOptions?: YamlXmlProtocolOptions) => TCMCoreProtocol;
|
|
67
71
|
|
|
68
72
|
type DebugLevel = "off" | "stream" | "parse";
|
|
69
73
|
declare function getDebugLevel(): DebugLevel;
|
|
@@ -102,12 +106,11 @@ declare function createDynamicIfThenElseSchema(tools: (LanguageModelV3FunctionTo
|
|
|
102
106
|
*/
|
|
103
107
|
declare function getPotentialStartIndex(text: string, searchedText: string): number | null;
|
|
104
108
|
|
|
105
|
-
type OnErrorFn
|
|
109
|
+
type OnErrorFn = (message: string, metadata?: Record<string, unknown>) => void;
|
|
106
110
|
declare function extractOnErrorOption(providerOptions?: unknown): {
|
|
107
|
-
onError?: OnErrorFn
|
|
111
|
+
onError?: OnErrorFn;
|
|
108
112
|
} | undefined;
|
|
109
113
|
|
|
110
|
-
type OnErrorFn = (message: string, metadata?: Record<string, unknown>) => void;
|
|
111
114
|
interface ToolCallMiddlewareProviderOptions {
|
|
112
115
|
toolCallMiddleware?: {
|
|
113
116
|
debugSummary?: {
|
|
@@ -129,8 +132,8 @@ declare const originalToolsSchema: {
|
|
|
129
132
|
decode: typeof decodeOriginalTools;
|
|
130
133
|
};
|
|
131
134
|
interface EncodedOriginalTool {
|
|
132
|
-
name: string;
|
|
133
135
|
inputSchema: string;
|
|
136
|
+
name: string;
|
|
134
137
|
}
|
|
135
138
|
interface DecodeOriginalToolsOptions {
|
|
136
139
|
onError?: OnErrorFn;
|
|
@@ -140,10 +143,13 @@ declare function encodeOriginalTools(tools: LanguageModelV3FunctionTool[] | unde
|
|
|
140
143
|
inputSchema: string;
|
|
141
144
|
}>;
|
|
142
145
|
declare function decodeOriginalTools(originalTools: EncodedOriginalTool[] | undefined, options?: DecodeOriginalToolsOptions): LanguageModelV3FunctionTool[];
|
|
146
|
+
declare function decodeOriginalToolsFromProviderOptions(providerOptions: ToolCallMiddlewareProviderOptions | undefined, options?: DecodeOriginalToolsOptions): LanguageModelV3FunctionTool[];
|
|
143
147
|
declare function extractToolNamesFromOriginalTools(originalTools: Array<{
|
|
144
148
|
name: string;
|
|
145
149
|
inputSchema: string;
|
|
146
150
|
}> | undefined): string[];
|
|
151
|
+
declare function getToolCallMiddlewareOptions(providerOptions?: unknown): Record<string, unknown>;
|
|
152
|
+
declare function mergeToolCallMiddlewareOptions(providerOptions: unknown, overrides: Record<string, unknown>): SharedV3ProviderOptions;
|
|
147
153
|
declare function isToolChoiceActive(params: {
|
|
148
154
|
providerOptions?: {
|
|
149
155
|
toolCallMiddleware?: {
|
|
@@ -170,8 +176,9 @@ declare function wrapGenerate({ protocol, doGenerate, params, }: {
|
|
|
170
176
|
}): Promise<_ai_sdk_provider.LanguageModelV3GenerateResult>;
|
|
171
177
|
|
|
172
178
|
declare const hermesToolMiddleware: _ai_sdk_provider.LanguageModelV3Middleware;
|
|
173
|
-
declare const
|
|
174
|
-
declare const
|
|
179
|
+
declare const qwen3CoderToolMiddleware: _ai_sdk_provider.LanguageModelV3Middleware;
|
|
180
|
+
declare const morphXmlToolMiddleware: _ai_sdk_provider.LanguageModelV3Middleware;
|
|
181
|
+
declare const yamlXmlToolMiddleware: _ai_sdk_provider.LanguageModelV3Middleware;
|
|
175
182
|
|
|
176
183
|
declare function wrapStream({ protocol, doStream, doGenerate, params, }: {
|
|
177
184
|
protocol: TCMCoreProtocol;
|
|
@@ -206,10 +213,14 @@ declare function toolChoiceStream({ doGenerate, tools, options, }: {
|
|
|
206
213
|
stream: ReadableStream<LanguageModelV3StreamPart>;
|
|
207
214
|
}>;
|
|
208
215
|
|
|
216
|
+
type ToolResponseUserContentPart = LanguageModelV3TextPart | LanguageModelV3FilePart;
|
|
217
|
+
|
|
218
|
+
type ToolResponsePromptTemplateResult = string | ToolResponseUserContentPart[];
|
|
219
|
+
|
|
209
220
|
declare function createToolMiddleware({ protocol, toolSystemPromptTemplate, toolResponsePromptTemplate, placement, }: {
|
|
210
221
|
protocol: TCMCoreProtocol | (() => TCMCoreProtocol);
|
|
211
222
|
toolSystemPromptTemplate: (tools: LanguageModelV3FunctionTool[]) => string;
|
|
212
|
-
toolResponsePromptTemplate?: (toolResult: ToolResultPart) =>
|
|
223
|
+
toolResponsePromptTemplate?: (toolResult: ToolResultPart) => ToolResponsePromptTemplateResult;
|
|
213
224
|
placement?: "first" | "last";
|
|
214
225
|
}): LanguageModelV3Middleware;
|
|
215
226
|
|
|
@@ -233,46 +244,13 @@ declare function transformParams({ params, protocol, toolSystemPromptTemplate, t
|
|
|
233
244
|
};
|
|
234
245
|
protocol: TCMCoreProtocol | (() => TCMCoreProtocol);
|
|
235
246
|
toolSystemPromptTemplate: (tools: LanguageModelV3FunctionTool[]) => string;
|
|
236
|
-
toolResponsePromptTemplate?: (toolResult: ToolResultPart) =>
|
|
247
|
+
toolResponsePromptTemplate?: (toolResult: ToolResultPart) => ToolResponsePromptTemplateResult;
|
|
237
248
|
placement?: "first" | "last";
|
|
238
249
|
}): {
|
|
239
250
|
prompt: LanguageModelV3Prompt;
|
|
240
251
|
tools: never[];
|
|
241
252
|
toolChoice: undefined;
|
|
242
|
-
providerOptions: SharedV3ProviderOptions;
|
|
243
|
-
} | {
|
|
244
|
-
responseFormat: {
|
|
245
|
-
type: "json";
|
|
246
|
-
schema: JSONSchema7;
|
|
247
|
-
name: string;
|
|
248
|
-
description: string | undefined;
|
|
249
|
-
};
|
|
250
|
-
providerOptions: {
|
|
251
|
-
toolCallMiddleware: {
|
|
252
|
-
toolChoice?: {
|
|
253
|
-
type: string;
|
|
254
|
-
toolName?: string;
|
|
255
|
-
} | undefined;
|
|
256
|
-
};
|
|
257
|
-
};
|
|
258
|
-
prompt: LanguageModelV3Prompt;
|
|
259
|
-
tools: never[];
|
|
260
|
-
toolChoice: undefined;
|
|
261
|
-
} | {
|
|
262
|
-
responseFormat: {
|
|
263
|
-
type: "json";
|
|
264
|
-
schema: JSONSchema7;
|
|
265
|
-
};
|
|
266
|
-
providerOptions: {
|
|
267
|
-
toolCallMiddleware: {
|
|
268
|
-
toolChoice: {
|
|
269
|
-
type: "required";
|
|
270
|
-
};
|
|
271
|
-
};
|
|
272
|
-
};
|
|
273
|
-
prompt: LanguageModelV3Prompt;
|
|
274
|
-
tools: never[];
|
|
275
|
-
toolChoice: undefined;
|
|
253
|
+
providerOptions: _ai_sdk_provider.SharedV3ProviderOptions;
|
|
276
254
|
};
|
|
277
255
|
|
|
278
|
-
export { type DebugLevel, type
|
|
256
|
+
export { type DebugLevel, type MorphXmlProtocolOptions, type OnErrorFn, type ParserOptions, Qwen3CoderToolParser, type TCMCoreProtocol, type TCMProtocol, type ToolCallMiddlewareProviderOptions, type YamlXmlProtocolOptions, createDynamicIfThenElseSchema, createToolMiddleware, decodeOriginalTools, decodeOriginalToolsFromProviderOptions, encodeOriginalTools, escapeRegExp, extractOnErrorOption, extractToolNamesFromOriginalTools, getDebugLevel, getPotentialStartIndex, getToolCallMiddlewareOptions, hasInputProperty, hermesProtocol, hermesToolMiddleware, isProtocolFactory, isTCMProtocolFactory, isToolChoiceActive, isToolResultPart, logParseFailure, logParsedChunk, logParsedSummary, logRawChunk, mergeToolCallMiddlewareOptions, morphXmlProtocol, morphXmlToolMiddleware, originalToolsSchema, qwen3CoderProtocol, qwen3CoderToolMiddleware, toolChoiceStream, transformParams, uiTarsXmlProtocol, wrapGenerate, wrapStream, yamlXmlProtocol, yamlXmlToolMiddleware };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _ai_sdk_provider from '@ai-sdk/provider';
|
|
2
|
-
import { LanguageModelV3FunctionTool, LanguageModelV3ToolCall, LanguageModelV3Content,
|
|
2
|
+
import { LanguageModelV3FunctionTool, LanguageModelV3StreamPart, LanguageModelV3ToolCall, LanguageModelV3Content, LanguageModelV3ProviderTool, JSONSchema7, SharedV3ProviderOptions, LanguageModelV3, LanguageModelV3TextPart, LanguageModelV3FilePart, LanguageModelV3Middleware, LanguageModelV3Prompt } from '@ai-sdk/provider';
|
|
3
3
|
import { ToolResultPart } from '@ai-sdk/provider-utils';
|
|
4
4
|
export { ParseOptions, parse, stringify, transform } from './rjson.js';
|
|
5
5
|
|
|
@@ -7,45 +7,45 @@ export { ParseOptions, parse, stringify, transform } from './rjson.js';
|
|
|
7
7
|
* Options for parsing tool calls and handling errors
|
|
8
8
|
*/
|
|
9
9
|
interface ParserOptions {
|
|
10
|
-
onError?: (message: string, metadata?: Record<string, unknown>) => void;
|
|
11
10
|
/**
|
|
12
11
|
* When true, stream parsers may emit malformed raw tool-call text as
|
|
13
12
|
* `text-delta` fallback on parse failure. Defaults to false to avoid leaking
|
|
14
13
|
* protocol/internal markup to end users.
|
|
15
14
|
*/
|
|
16
15
|
emitRawToolCallTextOnError?: boolean;
|
|
16
|
+
onError?: (message: string, metadata?: Record<string, unknown>) => void;
|
|
17
17
|
}
|
|
18
18
|
interface TCMProtocol {
|
|
19
|
+
createStreamParser({ tools, options, }: {
|
|
20
|
+
tools: LanguageModelV3FunctionTool[];
|
|
21
|
+
options?: ParserOptions;
|
|
22
|
+
}): TransformStream<LanguageModelV3StreamPart, LanguageModelV3StreamPart>;
|
|
23
|
+
extractToolCallSegments?: ({ text, tools, }: {
|
|
24
|
+
text: string;
|
|
25
|
+
tools: LanguageModelV3FunctionTool[];
|
|
26
|
+
}) => string[];
|
|
27
|
+
formatToolCall(toolCall: LanguageModelV3ToolCall): string;
|
|
19
28
|
formatTools({ tools, toolSystemPromptTemplate, }: {
|
|
20
29
|
tools: LanguageModelV3FunctionTool[];
|
|
21
30
|
toolSystemPromptTemplate: (tools: LanguageModelV3FunctionTool[]) => string;
|
|
22
31
|
}): string;
|
|
23
|
-
formatToolCall(toolCall: LanguageModelV3ToolCall): string;
|
|
24
32
|
parseGeneratedText({ text, tools, options, }: {
|
|
25
33
|
text: string;
|
|
26
34
|
tools: LanguageModelV3FunctionTool[];
|
|
27
35
|
options?: ParserOptions;
|
|
28
36
|
}): LanguageModelV3Content[];
|
|
29
|
-
createStreamParser({ tools, options, }: {
|
|
30
|
-
tools: LanguageModelV3FunctionTool[];
|
|
31
|
-
options?: ParserOptions;
|
|
32
|
-
}): TransformStream<LanguageModelV3StreamPart, LanguageModelV3StreamPart>;
|
|
33
|
-
extractToolCallSegments?: ({ text, tools, }: {
|
|
34
|
-
text: string;
|
|
35
|
-
tools: LanguageModelV3FunctionTool[];
|
|
36
|
-
}) => string[];
|
|
37
37
|
}
|
|
38
38
|
type TCMCoreProtocol = TCMProtocol;
|
|
39
39
|
declare function isProtocolFactory(protocol: TCMProtocol | (() => TCMProtocol)): protocol is () => TCMProtocol;
|
|
40
|
-
declare
|
|
40
|
+
declare const isTCMProtocolFactory: typeof isProtocolFactory;
|
|
41
41
|
|
|
42
|
-
interface
|
|
43
|
-
toolCallStart?: string;
|
|
42
|
+
interface HermesProtocolOptions {
|
|
44
43
|
toolCallEnd?: string;
|
|
44
|
+
toolCallStart?: string;
|
|
45
45
|
}
|
|
46
|
-
declare const
|
|
46
|
+
declare const hermesProtocol: ({ toolCallStart, toolCallEnd, }?: HermesProtocolOptions) => TCMProtocol;
|
|
47
47
|
|
|
48
|
-
interface
|
|
48
|
+
interface MorphXmlProtocolOptions {
|
|
49
49
|
parseOptions?: {
|
|
50
50
|
repair?: boolean;
|
|
51
51
|
maxReparses?: number;
|
|
@@ -54,16 +54,20 @@ interface XmlProtocolOptions {
|
|
|
54
54
|
[key: string]: unknown;
|
|
55
55
|
};
|
|
56
56
|
}
|
|
57
|
-
declare const
|
|
57
|
+
declare const morphXmlProtocol: (protocolOptions?: MorphXmlProtocolOptions) => TCMCoreProtocol;
|
|
58
|
+
|
|
59
|
+
declare const qwen3CoderProtocol: () => TCMProtocol;
|
|
60
|
+
declare const uiTarsXmlProtocol: () => TCMProtocol;
|
|
61
|
+
declare const Qwen3CoderToolParser: () => TCMProtocol;
|
|
58
62
|
|
|
59
|
-
interface
|
|
63
|
+
interface YamlXmlProtocolOptions {
|
|
60
64
|
/**
|
|
61
65
|
* Whether to include a system prompt example showing YAML multiline syntax.
|
|
62
66
|
* @default true
|
|
63
67
|
*/
|
|
64
68
|
includeMultilineExample?: boolean;
|
|
65
69
|
}
|
|
66
|
-
declare const
|
|
70
|
+
declare const yamlXmlProtocol: (_protocolOptions?: YamlXmlProtocolOptions) => TCMCoreProtocol;
|
|
67
71
|
|
|
68
72
|
type DebugLevel = "off" | "stream" | "parse";
|
|
69
73
|
declare function getDebugLevel(): DebugLevel;
|
|
@@ -102,12 +106,11 @@ declare function createDynamicIfThenElseSchema(tools: (LanguageModelV3FunctionTo
|
|
|
102
106
|
*/
|
|
103
107
|
declare function getPotentialStartIndex(text: string, searchedText: string): number | null;
|
|
104
108
|
|
|
105
|
-
type OnErrorFn
|
|
109
|
+
type OnErrorFn = (message: string, metadata?: Record<string, unknown>) => void;
|
|
106
110
|
declare function extractOnErrorOption(providerOptions?: unknown): {
|
|
107
|
-
onError?: OnErrorFn
|
|
111
|
+
onError?: OnErrorFn;
|
|
108
112
|
} | undefined;
|
|
109
113
|
|
|
110
|
-
type OnErrorFn = (message: string, metadata?: Record<string, unknown>) => void;
|
|
111
114
|
interface ToolCallMiddlewareProviderOptions {
|
|
112
115
|
toolCallMiddleware?: {
|
|
113
116
|
debugSummary?: {
|
|
@@ -129,8 +132,8 @@ declare const originalToolsSchema: {
|
|
|
129
132
|
decode: typeof decodeOriginalTools;
|
|
130
133
|
};
|
|
131
134
|
interface EncodedOriginalTool {
|
|
132
|
-
name: string;
|
|
133
135
|
inputSchema: string;
|
|
136
|
+
name: string;
|
|
134
137
|
}
|
|
135
138
|
interface DecodeOriginalToolsOptions {
|
|
136
139
|
onError?: OnErrorFn;
|
|
@@ -140,10 +143,13 @@ declare function encodeOriginalTools(tools: LanguageModelV3FunctionTool[] | unde
|
|
|
140
143
|
inputSchema: string;
|
|
141
144
|
}>;
|
|
142
145
|
declare function decodeOriginalTools(originalTools: EncodedOriginalTool[] | undefined, options?: DecodeOriginalToolsOptions): LanguageModelV3FunctionTool[];
|
|
146
|
+
declare function decodeOriginalToolsFromProviderOptions(providerOptions: ToolCallMiddlewareProviderOptions | undefined, options?: DecodeOriginalToolsOptions): LanguageModelV3FunctionTool[];
|
|
143
147
|
declare function extractToolNamesFromOriginalTools(originalTools: Array<{
|
|
144
148
|
name: string;
|
|
145
149
|
inputSchema: string;
|
|
146
150
|
}> | undefined): string[];
|
|
151
|
+
declare function getToolCallMiddlewareOptions(providerOptions?: unknown): Record<string, unknown>;
|
|
152
|
+
declare function mergeToolCallMiddlewareOptions(providerOptions: unknown, overrides: Record<string, unknown>): SharedV3ProviderOptions;
|
|
147
153
|
declare function isToolChoiceActive(params: {
|
|
148
154
|
providerOptions?: {
|
|
149
155
|
toolCallMiddleware?: {
|
|
@@ -170,8 +176,9 @@ declare function wrapGenerate({ protocol, doGenerate, params, }: {
|
|
|
170
176
|
}): Promise<_ai_sdk_provider.LanguageModelV3GenerateResult>;
|
|
171
177
|
|
|
172
178
|
declare const hermesToolMiddleware: _ai_sdk_provider.LanguageModelV3Middleware;
|
|
173
|
-
declare const
|
|
174
|
-
declare const
|
|
179
|
+
declare const qwen3CoderToolMiddleware: _ai_sdk_provider.LanguageModelV3Middleware;
|
|
180
|
+
declare const morphXmlToolMiddleware: _ai_sdk_provider.LanguageModelV3Middleware;
|
|
181
|
+
declare const yamlXmlToolMiddleware: _ai_sdk_provider.LanguageModelV3Middleware;
|
|
175
182
|
|
|
176
183
|
declare function wrapStream({ protocol, doStream, doGenerate, params, }: {
|
|
177
184
|
protocol: TCMCoreProtocol;
|
|
@@ -206,10 +213,14 @@ declare function toolChoiceStream({ doGenerate, tools, options, }: {
|
|
|
206
213
|
stream: ReadableStream<LanguageModelV3StreamPart>;
|
|
207
214
|
}>;
|
|
208
215
|
|
|
216
|
+
type ToolResponseUserContentPart = LanguageModelV3TextPart | LanguageModelV3FilePart;
|
|
217
|
+
|
|
218
|
+
type ToolResponsePromptTemplateResult = string | ToolResponseUserContentPart[];
|
|
219
|
+
|
|
209
220
|
declare function createToolMiddleware({ protocol, toolSystemPromptTemplate, toolResponsePromptTemplate, placement, }: {
|
|
210
221
|
protocol: TCMCoreProtocol | (() => TCMCoreProtocol);
|
|
211
222
|
toolSystemPromptTemplate: (tools: LanguageModelV3FunctionTool[]) => string;
|
|
212
|
-
toolResponsePromptTemplate?: (toolResult: ToolResultPart) =>
|
|
223
|
+
toolResponsePromptTemplate?: (toolResult: ToolResultPart) => ToolResponsePromptTemplateResult;
|
|
213
224
|
placement?: "first" | "last";
|
|
214
225
|
}): LanguageModelV3Middleware;
|
|
215
226
|
|
|
@@ -233,46 +244,13 @@ declare function transformParams({ params, protocol, toolSystemPromptTemplate, t
|
|
|
233
244
|
};
|
|
234
245
|
protocol: TCMCoreProtocol | (() => TCMCoreProtocol);
|
|
235
246
|
toolSystemPromptTemplate: (tools: LanguageModelV3FunctionTool[]) => string;
|
|
236
|
-
toolResponsePromptTemplate?: (toolResult: ToolResultPart) =>
|
|
247
|
+
toolResponsePromptTemplate?: (toolResult: ToolResultPart) => ToolResponsePromptTemplateResult;
|
|
237
248
|
placement?: "first" | "last";
|
|
238
249
|
}): {
|
|
239
250
|
prompt: LanguageModelV3Prompt;
|
|
240
251
|
tools: never[];
|
|
241
252
|
toolChoice: undefined;
|
|
242
|
-
providerOptions: SharedV3ProviderOptions;
|
|
243
|
-
} | {
|
|
244
|
-
responseFormat: {
|
|
245
|
-
type: "json";
|
|
246
|
-
schema: JSONSchema7;
|
|
247
|
-
name: string;
|
|
248
|
-
description: string | undefined;
|
|
249
|
-
};
|
|
250
|
-
providerOptions: {
|
|
251
|
-
toolCallMiddleware: {
|
|
252
|
-
toolChoice?: {
|
|
253
|
-
type: string;
|
|
254
|
-
toolName?: string;
|
|
255
|
-
} | undefined;
|
|
256
|
-
};
|
|
257
|
-
};
|
|
258
|
-
prompt: LanguageModelV3Prompt;
|
|
259
|
-
tools: never[];
|
|
260
|
-
toolChoice: undefined;
|
|
261
|
-
} | {
|
|
262
|
-
responseFormat: {
|
|
263
|
-
type: "json";
|
|
264
|
-
schema: JSONSchema7;
|
|
265
|
-
};
|
|
266
|
-
providerOptions: {
|
|
267
|
-
toolCallMiddleware: {
|
|
268
|
-
toolChoice: {
|
|
269
|
-
type: "required";
|
|
270
|
-
};
|
|
271
|
-
};
|
|
272
|
-
};
|
|
273
|
-
prompt: LanguageModelV3Prompt;
|
|
274
|
-
tools: never[];
|
|
275
|
-
toolChoice: undefined;
|
|
253
|
+
providerOptions: _ai_sdk_provider.SharedV3ProviderOptions;
|
|
276
254
|
};
|
|
277
255
|
|
|
278
|
-
export { type DebugLevel, type
|
|
256
|
+
export { type DebugLevel, type MorphXmlProtocolOptions, type OnErrorFn, type ParserOptions, Qwen3CoderToolParser, type TCMCoreProtocol, type TCMProtocol, type ToolCallMiddlewareProviderOptions, type YamlXmlProtocolOptions, createDynamicIfThenElseSchema, createToolMiddleware, decodeOriginalTools, decodeOriginalToolsFromProviderOptions, encodeOriginalTools, escapeRegExp, extractOnErrorOption, extractToolNamesFromOriginalTools, getDebugLevel, getPotentialStartIndex, getToolCallMiddlewareOptions, hasInputProperty, hermesProtocol, hermesToolMiddleware, isProtocolFactory, isTCMProtocolFactory, isToolChoiceActive, isToolResultPart, logParseFailure, logParsedChunk, logParsedSummary, logRawChunk, mergeToolCallMiddlewareOptions, morphXmlProtocol, morphXmlToolMiddleware, originalToolsSchema, qwen3CoderProtocol, qwen3CoderToolMiddleware, toolChoiceStream, transformParams, uiTarsXmlProtocol, wrapGenerate, wrapStream, yamlXmlProtocol, yamlXmlToolMiddleware };
|
package/dist/index.js
CHANGED
|
@@ -1,74 +1,88 @@
|
|
|
1
1
|
import {
|
|
2
|
+
Qwen3CoderToolParser,
|
|
2
3
|
createDynamicIfThenElseSchema,
|
|
3
4
|
createToolMiddleware,
|
|
4
5
|
decodeOriginalTools,
|
|
6
|
+
decodeOriginalToolsFromProviderOptions,
|
|
5
7
|
encodeOriginalTools,
|
|
6
8
|
extractOnErrorOption,
|
|
7
9
|
extractToolNamesFromOriginalTools,
|
|
8
10
|
getDebugLevel,
|
|
9
11
|
getPotentialStartIndex,
|
|
12
|
+
getToolCallMiddlewareOptions,
|
|
10
13
|
hasInputProperty,
|
|
14
|
+
hermesProtocol,
|
|
11
15
|
hermesToolMiddleware,
|
|
12
16
|
isProtocolFactory,
|
|
13
17
|
isTCMProtocolFactory,
|
|
14
18
|
isToolChoiceActive,
|
|
15
19
|
isToolResultPart,
|
|
16
|
-
jsonProtocol,
|
|
17
20
|
logParseFailure,
|
|
18
21
|
logParsedChunk,
|
|
19
22
|
logParsedSummary,
|
|
20
23
|
logRawChunk,
|
|
24
|
+
mergeToolCallMiddlewareOptions,
|
|
25
|
+
morphXmlProtocol,
|
|
26
|
+
morphXmlToolMiddleware,
|
|
21
27
|
originalToolsSchema,
|
|
28
|
+
qwen3CoderProtocol,
|
|
29
|
+
qwen3CoderToolMiddleware,
|
|
22
30
|
toolChoiceStream,
|
|
23
31
|
transformParams,
|
|
32
|
+
uiTarsXmlProtocol,
|
|
24
33
|
wrapGenerate,
|
|
25
34
|
wrapStream,
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
yamlToolMiddleware
|
|
30
|
-
} from "./chunk-DPGORNPB.js";
|
|
35
|
+
yamlXmlProtocol,
|
|
36
|
+
yamlXmlToolMiddleware
|
|
37
|
+
} from "./chunk-722D5BGD.js";
|
|
31
38
|
import {
|
|
32
39
|
escapeRegExp
|
|
33
|
-
} from "./chunk-
|
|
40
|
+
} from "./chunk-D4YULTAO.js";
|
|
34
41
|
import {
|
|
35
42
|
parse,
|
|
36
43
|
stringify,
|
|
37
44
|
transform
|
|
38
|
-
} from "./chunk-
|
|
39
|
-
import "./chunk-
|
|
45
|
+
} from "./chunk-QBZNMO5C.js";
|
|
46
|
+
import "./chunk-GMTE7BY5.js";
|
|
40
47
|
export {
|
|
48
|
+
Qwen3CoderToolParser,
|
|
41
49
|
createDynamicIfThenElseSchema,
|
|
42
50
|
createToolMiddleware,
|
|
43
51
|
decodeOriginalTools,
|
|
52
|
+
decodeOriginalToolsFromProviderOptions,
|
|
44
53
|
encodeOriginalTools,
|
|
45
54
|
escapeRegExp,
|
|
46
55
|
extractOnErrorOption,
|
|
47
56
|
extractToolNamesFromOriginalTools,
|
|
48
57
|
getDebugLevel,
|
|
49
58
|
getPotentialStartIndex,
|
|
59
|
+
getToolCallMiddlewareOptions,
|
|
50
60
|
hasInputProperty,
|
|
61
|
+
hermesProtocol,
|
|
51
62
|
hermesToolMiddleware,
|
|
52
63
|
isProtocolFactory,
|
|
53
64
|
isTCMProtocolFactory,
|
|
54
65
|
isToolChoiceActive,
|
|
55
66
|
isToolResultPart,
|
|
56
|
-
jsonProtocol,
|
|
57
67
|
logParseFailure,
|
|
58
68
|
logParsedChunk,
|
|
59
69
|
logParsedSummary,
|
|
60
70
|
logRawChunk,
|
|
71
|
+
mergeToolCallMiddlewareOptions,
|
|
72
|
+
morphXmlProtocol,
|
|
73
|
+
morphXmlToolMiddleware,
|
|
61
74
|
originalToolsSchema,
|
|
62
75
|
parse,
|
|
76
|
+
qwen3CoderProtocol,
|
|
77
|
+
qwen3CoderToolMiddleware,
|
|
63
78
|
stringify,
|
|
64
79
|
toolChoiceStream,
|
|
65
80
|
transform,
|
|
66
81
|
transformParams,
|
|
82
|
+
uiTarsXmlProtocol,
|
|
67
83
|
wrapGenerate,
|
|
68
84
|
wrapStream,
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
yamlProtocol,
|
|
72
|
-
yamlToolMiddleware
|
|
85
|
+
yamlXmlProtocol,
|
|
86
|
+
yamlXmlToolMiddleware
|
|
73
87
|
};
|
|
74
88
|
//# sourceMappingURL=index.js.map
|