@vybestack/llxprt-code 0.1.12 → 0.1.13-nightly.250727.2261021c
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.js +0 -0
- package/dist/package.json +5 -5
- package/dist/src/acp/acp.d.ts +208 -0
- package/dist/src/acp/acp.js +193 -0
- package/dist/src/acp/acp.js.map +1 -0
- package/dist/src/acp/acpPeer.d.ts +8 -0
- package/dist/src/acp/acpPeer.js +537 -0
- package/dist/src/acp/acpPeer.js.map +1 -0
- package/dist/src/config/config.d.ts +2 -0
- package/dist/src/config/config.js +73 -19
- package/dist/src/config/config.js.map +1 -1
- package/dist/src/config/extension.d.ts +2 -2
- package/dist/src/config/extension.js +21 -16
- package/dist/src/config/extension.js.map +1 -1
- package/dist/src/config/settings.d.ts +7 -0
- package/dist/src/config/settings.js +15 -0
- package/dist/src/config/settings.js.map +1 -1
- package/dist/src/gemini.js +33 -34
- package/dist/src/gemini.js.map +1 -1
- package/dist/src/generated/git-commit.d.ts +1 -1
- package/dist/src/generated/git-commit.js +1 -1
- package/dist/src/nonInteractiveCli.js +36 -3
- package/dist/src/nonInteractiveCli.js.map +1 -1
- package/dist/src/providers/index.d.ts +1 -7
- package/dist/src/providers/index.js +2 -10
- package/dist/src/providers/index.js.map +1 -1
- package/dist/src/providers/providerConfigUtils.d.ts +1 -2
- package/dist/src/providers/providerConfigUtils.js +1 -1
- package/dist/src/providers/providerConfigUtils.js.map +1 -1
- package/dist/src/providers/providerManagerInstance.d.ts +2 -2
- package/dist/src/providers/providerManagerInstance.js +21 -19
- package/dist/src/providers/providerManagerInstance.js.map +1 -1
- package/dist/src/providers/types.d.ts +1 -9
- package/dist/src/providers/types.js +2 -10
- package/dist/src/providers/types.js.map +1 -1
- package/dist/src/services/CommandService.d.ts +3 -1
- package/dist/src/services/CommandService.js +50 -11
- package/dist/src/services/CommandService.js.map +1 -1
- package/dist/src/ui/App.js +24 -25
- package/dist/src/ui/App.js.map +1 -1
- package/dist/src/ui/commands/aboutCommand.js +21 -0
- package/dist/src/ui/commands/aboutCommand.js.map +1 -1
- package/dist/src/ui/commands/baseurlCommand.d.ts +7 -0
- package/dist/src/ui/commands/baseurlCommand.js +22 -0
- package/dist/src/ui/commands/baseurlCommand.js.map +1 -0
- package/dist/src/ui/commands/bugCommand.d.ts +7 -0
- package/dist/src/ui/commands/bugCommand.js +61 -0
- package/dist/src/ui/commands/bugCommand.js.map +1 -0
- package/dist/src/ui/commands/chatCommand.d.ts +7 -0
- package/dist/src/ui/commands/chatCommand.js +170 -0
- package/dist/src/ui/commands/chatCommand.js.map +1 -0
- package/dist/src/ui/commands/clearCommand.js +12 -2
- package/dist/src/ui/commands/clearCommand.js.map +1 -1
- package/dist/src/ui/commands/compressCommand.d.ts +7 -0
- package/dist/src/ui/commands/compressCommand.js +62 -0
- package/dist/src/ui/commands/compressCommand.js.map +1 -0
- package/dist/src/ui/commands/docsCommand.d.ts +7 -0
- package/dist/src/ui/commands/docsCommand.js +29 -0
- package/dist/src/ui/commands/docsCommand.js.map +1 -0
- package/dist/src/ui/commands/editorCommand.d.ts +7 -0
- package/dist/src/ui/commands/editorCommand.js +14 -0
- package/dist/src/ui/commands/editorCommand.js.map +1 -0
- package/dist/src/ui/commands/extensionsCommand.d.ts +7 -0
- package/dist/src/ui/commands/extensionsCommand.js +29 -0
- package/dist/src/ui/commands/extensionsCommand.js.map +1 -0
- package/dist/src/ui/commands/ideCommand.d.ts +8 -0
- package/dist/src/ui/commands/ideCommand.js +123 -0
- package/dist/src/ui/commands/ideCommand.js.map +1 -0
- package/dist/src/{providers/ProviderAwareContentGenerator.d.ts → ui/commands/keyCommand.d.ts} +2 -1
- package/dist/src/ui/commands/keyCommand.js +29 -0
- package/dist/src/ui/commands/keyCommand.js.map +1 -0
- package/dist/src/ui/commands/keyfileCommand.d.ts +7 -0
- package/dist/src/ui/commands/keyfileCommand.js +104 -0
- package/dist/src/ui/commands/keyfileCommand.js.map +1 -0
- package/dist/src/ui/commands/mcpCommand.d.ts +7 -0
- package/dist/src/ui/commands/mcpCommand.js +204 -0
- package/dist/src/ui/commands/mcpCommand.js.map +1 -0
- package/dist/src/ui/commands/modelCommand.d.ts +7 -0
- package/dist/src/ui/commands/modelCommand.js +60 -0
- package/dist/src/ui/commands/modelCommand.js.map +1 -0
- package/dist/src/ui/commands/providerCommand.d.ts +7 -0
- package/dist/src/ui/commands/providerCommand.js +86 -0
- package/dist/src/ui/commands/providerCommand.js.map +1 -0
- package/dist/src/ui/commands/quitCommand.d.ts +7 -0
- package/dist/src/ui/commands/quitCommand.js +32 -0
- package/dist/src/ui/commands/quitCommand.js.map +1 -0
- package/dist/src/ui/commands/restoreCommand.d.ts +8 -0
- package/dist/src/ui/commands/restoreCommand.js +126 -0
- package/dist/src/ui/commands/restoreCommand.js.map +1 -0
- package/dist/src/ui/commands/statsCommand.d.ts +7 -0
- package/dist/src/ui/commands/statsCommand.js +50 -0
- package/dist/src/ui/commands/statsCommand.js.map +1 -0
- package/dist/src/ui/commands/toolsCommand.d.ts +7 -0
- package/dist/src/ui/commands/toolsCommand.js +54 -0
- package/dist/src/ui/commands/toolsCommand.js.map +1 -0
- package/dist/src/ui/commands/types.d.ts +34 -2
- package/dist/src/ui/components/ContextSummaryDisplay.d.ts +6 -1
- package/dist/src/ui/components/ContextSummaryDisplay.js +46 -19
- package/dist/src/ui/components/ContextSummaryDisplay.js.map +1 -1
- package/dist/src/ui/components/Footer.d.ts +0 -1
- package/dist/src/ui/components/Footer.js +3 -21
- package/dist/src/ui/components/Footer.js.map +1 -1
- package/dist/src/ui/components/InputPrompt.js +110 -61
- package/dist/src/ui/components/InputPrompt.js.map +1 -1
- package/dist/src/ui/components/ProviderModelDialog.d.ts +1 -1
- package/dist/src/ui/components/ThemeDialog.js +25 -24
- package/dist/src/ui/components/ThemeDialog.js.map +1 -1
- package/dist/src/ui/components/messages/ToolGroupMessage.js +3 -1
- package/dist/src/ui/components/messages/ToolGroupMessage.js.map +1 -1
- package/dist/src/ui/components/shared/MaxSizedBox.js +69 -2
- package/dist/src/ui/components/shared/MaxSizedBox.js.map +1 -1
- package/dist/src/ui/components/shared/RadioButtonSelect.d.ts +3 -1
- package/dist/src/ui/components/shared/RadioButtonSelect.js +60 -10
- package/dist/src/ui/components/shared/RadioButtonSelect.js.map +1 -1
- package/dist/src/ui/components/shared/text-buffer.js +1 -1
- package/dist/src/ui/components/shared/text-buffer.js.map +1 -1
- package/dist/src/ui/constants.d.ts +1 -0
- package/dist/src/ui/constants.js +1 -0
- package/dist/src/ui/constants.js.map +1 -1
- package/dist/src/ui/containers/SessionController.js +1 -1
- package/dist/src/ui/containers/SessionController.js.map +1 -1
- package/dist/src/ui/contexts/OpenAIProviderContext.d.ts +1 -2
- package/dist/src/ui/contexts/OpenAIProviderContext.js.map +1 -1
- package/dist/src/ui/hooks/shellCommandProcessor.d.ts +1 -1
- package/dist/src/ui/hooks/shellCommandProcessor.js +35 -11
- package/dist/src/ui/hooks/shellCommandProcessor.js.map +1 -1
- package/dist/src/ui/hooks/slashCommandProcessor.d.ts +2 -9
- package/dist/src/ui/hooks/slashCommandProcessor.js +83 -622
- package/dist/src/ui/hooks/slashCommandProcessor.js.map +1 -1
- package/dist/src/ui/hooks/useAuthCommand.js +16 -2
- package/dist/src/ui/hooks/useAuthCommand.js.map +1 -1
- package/dist/src/ui/hooks/useCompletion.d.ts +1 -0
- package/dist/src/ui/hooks/useCompletion.js +21 -2
- package/dist/src/ui/hooks/useCompletion.js.map +1 -1
- package/dist/src/ui/hooks/useFocus.d.ts +6 -0
- package/dist/src/ui/hooks/useFocus.js +41 -0
- package/dist/src/ui/hooks/useFocus.js.map +1 -0
- package/dist/src/ui/hooks/useGeminiStream.js +34 -2
- package/dist/src/ui/hooks/useGeminiStream.js.map +1 -1
- package/dist/src/ui/hooks/useOpenAIProviderInfo.d.ts +3 -2
- package/dist/src/ui/hooks/useOpenAIProviderInfo.js +5 -4
- package/dist/src/ui/hooks/useOpenAIProviderInfo.js.map +1 -1
- package/dist/src/ui/hooks/usePrivacySettings.js +5 -5
- package/dist/src/ui/hooks/usePrivacySettings.js.map +1 -1
- package/dist/src/ui/hooks/useProviderDialog.d.ts +5 -2
- package/dist/src/ui/hooks/useProviderDialog.js +55 -3
- package/dist/src/ui/hooks/useProviderDialog.js.map +1 -1
- package/dist/src/ui/hooks/useProviderModelDialog.d.ts +1 -1
- package/dist/src/ui/themes/ansi-light.js +1 -1
- package/dist/src/ui/themes/ansi-light.js.map +1 -1
- package/dist/src/ui/themes/googlecode.js +1 -1
- package/dist/src/ui/themes/googlecode.js.map +1 -1
- package/dist/src/ui/themes/xcode.js +1 -1
- package/dist/src/ui/themes/xcode.js.map +1 -1
- package/dist/src/ui/types.d.ts +10 -0
- package/dist/src/ui/types.js.map +1 -1
- package/dist/src/ui/utils/updateCheck.js +10 -6
- package/dist/src/ui/utils/updateCheck.js.map +1 -1
- package/dist/src/utils/userStartupWarnings.js +1 -16
- package/dist/src/utils/userStartupWarnings.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -5
- package/dist/src/providers/IMessage.d.ts +0 -38
- package/dist/src/providers/IMessage.js +0 -17
- package/dist/src/providers/IMessage.js.map +0 -1
- package/dist/src/providers/IModel.d.ts +0 -23
- package/dist/src/providers/IModel.js +0 -17
- package/dist/src/providers/IModel.js.map +0 -1
- package/dist/src/providers/IProvider.d.ts +0 -32
- package/dist/src/providers/IProvider.js +0 -17
- package/dist/src/providers/IProvider.js.map +0 -1
- package/dist/src/providers/ITool.d.ts +0 -23
- package/dist/src/providers/ITool.js +0 -17
- package/dist/src/providers/ITool.js.map +0 -1
- package/dist/src/providers/ProviderAwareContentGenerator.js +0 -9
- package/dist/src/providers/ProviderAwareContentGenerator.js.map +0 -1
- package/dist/src/providers/ProviderManager.d.ts +0 -19
- package/dist/src/providers/ProviderManager.js +0 -63
- package/dist/src/providers/ProviderManager.js.map +0 -1
- package/dist/src/providers/ProviderManagerAdapter.d.ts +0 -17
- package/dist/src/providers/ProviderManagerAdapter.js +0 -113
- package/dist/src/providers/ProviderManagerAdapter.js.map +0 -1
- package/dist/src/providers/README-qwen3.md +0 -60
- package/dist/src/providers/adapters/IStreamAdapter.d.ts +0 -18
- package/dist/src/providers/adapters/IStreamAdapter.js +0 -7
- package/dist/src/providers/adapters/IStreamAdapter.js.map +0 -1
- package/dist/src/providers/anthropic/AnthropicProvider.d.ts +0 -46
- package/dist/src/providers/anthropic/AnthropicProvider.js +0 -478
- package/dist/src/providers/anthropic/AnthropicProvider.js.map +0 -1
- package/dist/src/providers/contentGeneratorProvider.d.ts +0 -13
- package/dist/src/providers/contentGeneratorProvider.js +0 -17
- package/dist/src/providers/contentGeneratorProvider.js.map +0 -1
- package/dist/src/providers/gemini/GeminiProvider.d.ts +0 -72
- package/dist/src/providers/gemini/GeminiProvider.js +0 -454
- package/dist/src/providers/gemini/GeminiProvider.js.map +0 -1
- package/dist/src/providers/integration/TEST_INSTRUCTIONS.md +0 -197
- package/dist/src/providers/openai/ConversationCache.d.ts +0 -20
- package/dist/src/providers/openai/ConversationCache.js +0 -109
- package/dist/src/providers/openai/ConversationCache.js.map +0 -1
- package/dist/src/providers/openai/IChatGenerateParams.d.ts +0 -11
- package/dist/src/providers/openai/IChatGenerateParams.js +0 -2
- package/dist/src/providers/openai/IChatGenerateParams.js.map +0 -1
- package/dist/src/providers/openai/OpenAIProvider.d.ts +0 -71
- package/dist/src/providers/openai/OpenAIProvider.js +0 -486
- package/dist/src/providers/openai/OpenAIProvider.js.map +0 -1
- package/dist/src/providers/openai/Qwen3FireworksProvider.d.ts +0 -39
- package/dist/src/providers/openai/Qwen3FireworksProvider.js +0 -209
- package/dist/src/providers/openai/Qwen3FireworksProvider.js.map +0 -1
- package/dist/src/providers/openai/RESPONSES_API_MODELS.d.ts +0 -2
- package/dist/src/providers/openai/RESPONSES_API_MODELS.js +0 -14
- package/dist/src/providers/openai/RESPONSES_API_MODELS.js.map +0 -1
- package/dist/src/providers/openai/buildResponsesRequest.d.ts +0 -67
- package/dist/src/providers/openai/buildResponsesRequest.js +0 -144
- package/dist/src/providers/openai/buildResponsesRequest.js.map +0 -1
- package/dist/src/providers/openai/docs/accessing-provider-info.md +0 -172
- package/dist/src/providers/openai/docs/params-mapping.md +0 -91
- package/dist/src/providers/openai/docs/qwen3-fireworks.md +0 -47
- package/dist/src/providers/openai/docs/responses-api-tool-calls.md +0 -96
- package/dist/src/providers/openai/estimateRemoteTokens.d.ts +0 -26
- package/dist/src/providers/openai/estimateRemoteTokens.js +0 -75
- package/dist/src/providers/openai/estimateRemoteTokens.js.map +0 -1
- package/dist/src/providers/openai/getOpenAIProviderInfo.d.ts +0 -46
- package/dist/src/providers/openai/getOpenAIProviderInfo.js +0 -74
- package/dist/src/providers/openai/getOpenAIProviderInfo.js.map +0 -1
- package/dist/src/providers/openai/parseResponsesStream.d.ts +0 -3
- package/dist/src/providers/openai/parseResponsesStream.js +0 -444
- package/dist/src/providers/openai/parseResponsesStream.js.map +0 -1
- package/dist/src/providers/parsers/TextToolCallParser.d.ts +0 -35
- package/dist/src/providers/parsers/TextToolCallParser.js +0 -248
- package/dist/src/providers/parsers/TextToolCallParser.js.map +0 -1
- package/dist/src/providers/tokenizers/AnthropicTokenizer.d.ts +0 -19
- package/dist/src/providers/tokenizers/AnthropicTokenizer.js +0 -37
- package/dist/src/providers/tokenizers/AnthropicTokenizer.js.map +0 -1
- package/dist/src/providers/tokenizers/ITokenizer.d.ts +0 -18
- package/dist/src/providers/tokenizers/ITokenizer.js +0 -17
- package/dist/src/providers/tokenizers/ITokenizer.js.map +0 -1
- package/dist/src/providers/tokenizers/OpenAITokenizer.d.ts +0 -24
- package/dist/src/providers/tokenizers/OpenAITokenizer.js +0 -56
- package/dist/src/providers/tokenizers/OpenAITokenizer.js.map +0 -1
- package/dist/src/tools/IToolFormatter.d.ts +0 -40
- package/dist/src/tools/IToolFormatter.js +0 -17
- package/dist/src/tools/IToolFormatter.js.map +0 -1
- package/dist/src/tools/ToolFormatter.d.ts +0 -45
- package/dist/src/tools/ToolFormatter.js +0 -216
- package/dist/src/tools/ToolFormatter.js.map +0 -1
- package/dist/vybestack-llxprt-code-0.1.12.tgz +0 -0
@@ -1,248 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* Copyright 2025 Vybestack LLC
|
3
|
-
*
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
-
* you may not use this file except in compliance with the License.
|
6
|
-
* You may obtain a copy of the License at
|
7
|
-
*
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
9
|
-
*
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
-
* See the License for the specific language governing permissions and
|
14
|
-
* limitations under the License.
|
15
|
-
*/
|
16
|
-
export class GemmaToolCallParser {
|
17
|
-
// Support multiple tool call formats
|
18
|
-
patterns = [
|
19
|
-
// Format 1: [TOOL_REQUEST] toolName {args} [TOOL_REQUEST_END]
|
20
|
-
/\[TOOL_REQUEST\]\s*(\w+)\s+({.*?})\s*\[TOOL_REQUEST_END\]/gs,
|
21
|
-
// Format 2: ✦ tool_call: toolName for key value pairs (more specific to avoid false positives)
|
22
|
-
/✦\s*tool_call:\s*(\w+)\s+for\s+(.+?)(?=\n|✦|$)/gs,
|
23
|
-
// Format 3: JSON object with name/arguments followed by [END_TOOL_REQUEST]
|
24
|
-
/(\d+\s+)?{"name":\s*"(\w+)",\s*"arguments":\s*({.*?})}\s*(?:\n\s*\d+\s+)?\[END_TOOL_REQUEST\]/gs,
|
25
|
-
// Format 4: Hermes format with <tool_call> tags
|
26
|
-
/<tool_call>\s*({.*?"name":\s*"(\w+)".*?})\s*<\/tool_call>/gs,
|
27
|
-
// Format 5: XML with <invoke> tags (Claude-style)
|
28
|
-
/<invoke\s+name="(\w+)">(.*?)<\/invoke>/gs,
|
29
|
-
// Format 6: Generic XML tool format
|
30
|
-
/<tool>\s*<name>(\w+)<\/name>\s*<arguments>(.*?)<\/arguments>\s*<\/tool>/gs,
|
31
|
-
];
|
32
|
-
parse(content) {
|
33
|
-
const toolCalls = [];
|
34
|
-
let cleanedContent = content;
|
35
|
-
const matches = [];
|
36
|
-
// Quick check: if content doesn't contain any tool call markers, return early
|
37
|
-
if (!content.includes('[TOOL_REQUEST') &&
|
38
|
-
!content.includes('tool_call:') &&
|
39
|
-
!content.includes('[END_TOOL_REQUEST]') &&
|
40
|
-
!content.includes('{"name":') &&
|
41
|
-
!content.includes('<tool_call>') &&
|
42
|
-
!content.includes('<invoke') &&
|
43
|
-
!content.includes('<tool>')) {
|
44
|
-
return { cleanedContent: content, toolCalls: [] };
|
45
|
-
}
|
46
|
-
// Try each pattern
|
47
|
-
for (const pattern of this.patterns) {
|
48
|
-
let match;
|
49
|
-
while ((match = pattern.exec(content)) !== null) {
|
50
|
-
if (pattern === this.patterns[1]) {
|
51
|
-
// Format 2: Parse key-value pairs from "for key value key2 value2" format
|
52
|
-
const [fullMatch, toolName, argsStr] = match;
|
53
|
-
const args = this.parseKeyValuePairs(argsStr);
|
54
|
-
matches.push({ fullMatch, toolName, args });
|
55
|
-
}
|
56
|
-
else if (pattern === this.patterns[2]) {
|
57
|
-
// Format 3: JSON object format {"name": "tool", "arguments": {...}}
|
58
|
-
const [fullMatch, , toolName, jsonArgs] = match;
|
59
|
-
matches.push({ fullMatch, toolName, args: jsonArgs });
|
60
|
-
}
|
61
|
-
else if (pattern === this.patterns[3]) {
|
62
|
-
// Format 4: Hermes format <tool_call>{"arguments": {...}, "name": "tool"}</tool_call>
|
63
|
-
const [fullMatch, hermesJson, toolName] = match;
|
64
|
-
try {
|
65
|
-
const parsed = JSON.parse(hermesJson);
|
66
|
-
matches.push({
|
67
|
-
fullMatch,
|
68
|
-
toolName,
|
69
|
-
args: JSON.stringify(parsed.arguments || {}),
|
70
|
-
});
|
71
|
-
}
|
72
|
-
catch (error) {
|
73
|
-
console.error(`[GemmaToolCallParser] Failed to parse Hermes format: ${error}`);
|
74
|
-
// Still need to track the match to remove it from content
|
75
|
-
matches.push({ fullMatch, toolName: '', args: '' });
|
76
|
-
}
|
77
|
-
}
|
78
|
-
else if (pattern === this.patterns[4]) {
|
79
|
-
// Format 5: XML with <invoke> tags (Claude-style)
|
80
|
-
const [fullMatch, toolName, xmlContent] = match;
|
81
|
-
matches.push({ fullMatch, toolName, args: xmlContent });
|
82
|
-
}
|
83
|
-
else if (pattern === this.patterns[5]) {
|
84
|
-
// Format 6: Generic XML tool format
|
85
|
-
const [fullMatch, toolName, xmlArgs] = match;
|
86
|
-
matches.push({ fullMatch, toolName, args: xmlArgs });
|
87
|
-
}
|
88
|
-
else {
|
89
|
-
// Format 1: tool name followed by JSON arguments
|
90
|
-
const [fullMatch, toolName, jsonArgs] = match;
|
91
|
-
matches.push({ fullMatch, toolName, args: jsonArgs });
|
92
|
-
}
|
93
|
-
}
|
94
|
-
// Reset the regex state for next use
|
95
|
-
pattern.lastIndex = 0;
|
96
|
-
}
|
97
|
-
// Process each match
|
98
|
-
for (const { fullMatch, toolName, args } of matches) {
|
99
|
-
// Remove the tool call pattern from the content regardless of parsing success so markers are always stripped
|
100
|
-
cleanedContent = cleanedContent.replace(fullMatch, '');
|
101
|
-
// Skip if toolName is empty (failed parsing)
|
102
|
-
if (!toolName) {
|
103
|
-
continue;
|
104
|
-
}
|
105
|
-
try {
|
106
|
-
let parsedArgs;
|
107
|
-
if (typeof args === 'string') {
|
108
|
-
// Check if it's XML content (Claude-style or generic)
|
109
|
-
if (args.includes('<parameter') ||
|
110
|
-
(args.includes('<') && args.includes('>'))) {
|
111
|
-
parsedArgs = this.parseXMLParameters(args);
|
112
|
-
}
|
113
|
-
else {
|
114
|
-
// Handle JSON string arguments
|
115
|
-
parsedArgs = JSON.parse(args);
|
116
|
-
}
|
117
|
-
}
|
118
|
-
else {
|
119
|
-
// Already parsed (from key-value format)
|
120
|
-
parsedArgs = args;
|
121
|
-
}
|
122
|
-
toolCalls.push({
|
123
|
-
name: toolName,
|
124
|
-
arguments: parsedArgs,
|
125
|
-
});
|
126
|
-
}
|
127
|
-
catch (error) {
|
128
|
-
if (typeof args === 'string') {
|
129
|
-
// Try to extract a simpler JSON pattern if the full match fails
|
130
|
-
const simpleJsonMatch = args.match(/^{[^{]*}$/);
|
131
|
-
if (simpleJsonMatch) {
|
132
|
-
try {
|
133
|
-
const parsedArgs = JSON.parse(simpleJsonMatch[0]);
|
134
|
-
toolCalls.push({
|
135
|
-
name: toolName,
|
136
|
-
arguments: parsedArgs,
|
137
|
-
});
|
138
|
-
cleanedContent = cleanedContent.replace(fullMatch, '');
|
139
|
-
}
|
140
|
-
catch (_secondError) {
|
141
|
-
console.error(`[GemmaToolCallParser] Failed to parse tool arguments for ${toolName}:`, error);
|
142
|
-
console.error(`[GemmaToolCallParser] Raw arguments: ${args}`);
|
143
|
-
// Keep the original text if we can't parse it
|
144
|
-
}
|
145
|
-
}
|
146
|
-
else {
|
147
|
-
console.error(`[GemmaToolCallParser] Failed to parse tool arguments for ${toolName}:`, error);
|
148
|
-
console.error(`[GemmaToolCallParser] Raw arguments: ${args}`);
|
149
|
-
}
|
150
|
-
}
|
151
|
-
}
|
152
|
-
}
|
153
|
-
// Clean up any extra whitespace and stray markers that were not matched (best effort)
|
154
|
-
cleanedContent = cleanedContent
|
155
|
-
.replace(/\[TOOL_REQUEST(?:_END)?]/g, '')
|
156
|
-
.replace(/<\|im_start\|>assistant/g, '')
|
157
|
-
.replace(/<\|im_end\|>/g, '')
|
158
|
-
.replace(/<tool_call>[\s\S]*?<\/tool_call>/g, '') // Remove any remaining tool_call tags
|
159
|
-
.replace(/<function_calls>[\s\S]*?<\/function_calls>/g, '') // Remove function_calls wrapper
|
160
|
-
.replace(/<invoke[\s\S]*?<\/invoke>/g, '') // Remove any remaining invoke tags
|
161
|
-
.replace(/<tool>[\s\S]*?<\/tool>/g, '') // Remove any remaining tool tags
|
162
|
-
// .replace(/<think>[\s\S]*?<\/think>/g, '') // Keep think tags visible by default
|
163
|
-
.replace(/<tool_call>\s*\{[^}]*$/gm, '') // Remove incomplete tool calls
|
164
|
-
.replace(/\{"name"\s*:\s*"[^"]*"\s*,?\s*"arguments"\s*:\s*\{[^}]*$/gm, '') // Remove incomplete JSON tool calls
|
165
|
-
.replace(/✦\s*<think>/g, '') // Remove ✦ symbol followed by think tag
|
166
|
-
.replace(/\s+/g, ' ')
|
167
|
-
.trim();
|
168
|
-
return {
|
169
|
-
cleanedContent,
|
170
|
-
toolCalls,
|
171
|
-
};
|
172
|
-
}
|
173
|
-
parseKeyValuePairs(str) {
|
174
|
-
const args = {};
|
175
|
-
// Parse "key value key2 value2" format
|
176
|
-
// Example: "path /Users/acoliver/projects/gemini-code/gemini-cli/docs"
|
177
|
-
const parts = str.trim().split(/\s+/);
|
178
|
-
for (let i = 0; i < parts.length; i += 2) {
|
179
|
-
if (i + 1 < parts.length) {
|
180
|
-
const key = parts[i];
|
181
|
-
let value = parts[i + 1];
|
182
|
-
// Handle quoted strings that might contain spaces
|
183
|
-
if (value.startsWith('"') || value.startsWith("'")) {
|
184
|
-
const quote = value[0];
|
185
|
-
let endIndex = i + 1;
|
186
|
-
// Find the closing quote
|
187
|
-
while (endIndex < parts.length && !parts[endIndex].endsWith(quote)) {
|
188
|
-
endIndex++;
|
189
|
-
}
|
190
|
-
if (endIndex < parts.length) {
|
191
|
-
value = parts.slice(i + 1, endIndex + 1).join(' ');
|
192
|
-
value = value.slice(1, -1); // Remove quotes
|
193
|
-
i = endIndex - 1; // Adjust loop counter
|
194
|
-
}
|
195
|
-
}
|
196
|
-
// Try to parse as number or boolean
|
197
|
-
if (!isNaN(Number(value))) {
|
198
|
-
args[key] = Number(value);
|
199
|
-
}
|
200
|
-
else if (value === 'true' || value === 'false') {
|
201
|
-
args[key] = value === 'true';
|
202
|
-
}
|
203
|
-
else {
|
204
|
-
args[key] = value;
|
205
|
-
}
|
206
|
-
}
|
207
|
-
}
|
208
|
-
return args;
|
209
|
-
}
|
210
|
-
parseXMLParameters(xmlContent) {
|
211
|
-
const args = {};
|
212
|
-
// Parse Claude-style <parameter name="key">value</parameter>
|
213
|
-
const parameterPattern = /<parameter\s+name="([^"]+)">([^<]*)<\/parameter>/g;
|
214
|
-
let match;
|
215
|
-
while ((match = parameterPattern.exec(xmlContent)) !== null) {
|
216
|
-
const [, key, value] = match;
|
217
|
-
args[key] = this.parseValue(value.trim());
|
218
|
-
}
|
219
|
-
// If no parameter tags found, try generic XML <key>value</key>
|
220
|
-
if (Object.keys(args).length === 0) {
|
221
|
-
// Match any XML tag pair
|
222
|
-
const genericPattern = /<(\w+)>([^<]*)<\/\1>/g;
|
223
|
-
while ((match = genericPattern.exec(xmlContent)) !== null) {
|
224
|
-
const [, key, value] = match;
|
225
|
-
args[key] = this.parseValue(value.trim());
|
226
|
-
}
|
227
|
-
}
|
228
|
-
return args;
|
229
|
-
}
|
230
|
-
parseValue(value) {
|
231
|
-
// Try to parse as number
|
232
|
-
if (!isNaN(Number(value)) && value !== '') {
|
233
|
-
return Number(value);
|
234
|
-
}
|
235
|
-
// Try to parse as boolean
|
236
|
-
if (value === 'true' || value === 'false') {
|
237
|
-
return value === 'true';
|
238
|
-
}
|
239
|
-
// Handle HTML entities
|
240
|
-
return value
|
241
|
-
.replace(/</g, '<')
|
242
|
-
.replace(/>/g, '>')
|
243
|
-
.replace(/&/g, '&')
|
244
|
-
.replace(/"/g, '"')
|
245
|
-
.replace(/'/g, "'");
|
246
|
-
}
|
247
|
-
}
|
248
|
-
//# sourceMappingURL=TextToolCallParser.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"TextToolCallParser.js","sourceRoot":"","sources":["../../../../src/providers/parsers/TextToolCallParser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAcH,MAAM,OAAO,mBAAmB;IAC9B,qCAAqC;IACpB,QAAQ,GAAG;QAC1B,8D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AG,CAAC;aACrB,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC;aACrB,OAAO,CAAC,QAAQ,EAAE,GAAG,CAAC;aACtB,OAAO,CAAC,SAAS,EAAE,GAAG,CAAC;aACvB,OAAO,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;IAC5B,CAAC;CACF"}
|
@@ -1,19 +0,0 @@
|
|
1
|
-
import { ITokenizer } from './ITokenizer.js';
|
2
|
-
export declare class AnthropicTokenizer implements ITokenizer {
|
3
|
-
/**
|
4
|
-
* Count tokens for Anthropic models
|
5
|
-
*
|
6
|
-
* Anthropic uses a tokenizer similar to Claude's tiktoken-based tokenizer.
|
7
|
-
* Since there's no official @anthropic-ai/tokenizer package available,
|
8
|
-
* we use a character-based estimation that aligns with typical Claude tokenization:
|
9
|
-
* - Average ~3.5-4 characters per token for English text
|
10
|
-
* - More conservative estimate for code and special characters
|
11
|
-
*
|
12
|
-
* This estimation should be within 10-15% of actual token counts for most content.
|
13
|
-
*
|
14
|
-
* @param text The text to tokenize
|
15
|
-
* @param model The model name (for model-specific tokenization if needed)
|
16
|
-
* @returns Estimated token count
|
17
|
-
*/
|
18
|
-
countTokens(text: string, _model: string): Promise<number>;
|
19
|
-
}
|
@@ -1,37 +0,0 @@
|
|
1
|
-
export class AnthropicTokenizer {
|
2
|
-
/**
|
3
|
-
* Count tokens for Anthropic models
|
4
|
-
*
|
5
|
-
* Anthropic uses a tokenizer similar to Claude's tiktoken-based tokenizer.
|
6
|
-
* Since there's no official @anthropic-ai/tokenizer package available,
|
7
|
-
* we use a character-based estimation that aligns with typical Claude tokenization:
|
8
|
-
* - Average ~3.5-4 characters per token for English text
|
9
|
-
* - More conservative estimate for code and special characters
|
10
|
-
*
|
11
|
-
* This estimation should be within 10-15% of actual token counts for most content.
|
12
|
-
*
|
13
|
-
* @param text The text to tokenize
|
14
|
-
* @param model The model name (for model-specific tokenization if needed)
|
15
|
-
* @returns Estimated token count
|
16
|
-
*/
|
17
|
-
async countTokens(text, _model) {
|
18
|
-
// Base estimation: ~4 characters per token
|
19
|
-
let baseEstimate = text.length / 4;
|
20
|
-
// Adjust for code content (more tokens due to special characters)
|
21
|
-
const codeIndicators = /[{}[\]()<>:;=,\n\t]/g;
|
22
|
-
const codeMatches = text.match(codeIndicators);
|
23
|
-
if (codeMatches && codeMatches.length > text.length * 0.1) {
|
24
|
-
// If more than 10% special characters, it's likely code
|
25
|
-
baseEstimate = text.length / 3.5;
|
26
|
-
}
|
27
|
-
// Adjust for whitespace (multiple spaces/newlines count as fewer tokens)
|
28
|
-
const whitespaceRuns = text.match(/\s{2,}/g);
|
29
|
-
if (whitespaceRuns) {
|
30
|
-
const extraWhitespace = whitespaceRuns.reduce((sum, run) => sum + run.length - 1, 0);
|
31
|
-
baseEstimate -= extraWhitespace / 4;
|
32
|
-
}
|
33
|
-
// Round up to be conservative (better to overestimate than underestimate)
|
34
|
-
return Math.ceil(baseEstimate);
|
35
|
-
}
|
36
|
-
}
|
37
|
-
//# sourceMappingURL=AnthropicTokenizer.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"AnthropicTokenizer.js","sourceRoot":"","sources":["../../../../src/providers/tokenizers/AnthropicTokenizer.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,kBAAkB;IAC7B;;;;;;;;;;;;;;OAcG;IACH,KAAK,CAAC,WAAW,CAAC,IAAY,EAAE,MAAc;QAC5C,2CAA2C;QAC3C,IAAI,YAAY,GAAG,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;QAEnC,kEAAkE;QAClE,MAAM,cAAc,GAAG,sBAAsB,CAAC;QAC9C,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;QAC/C,IAAI,WAAW,IAAI,WAAW,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,GAAG,GAAG,EAAE,CAAC;YAC1D,wDAAwD;YACxD,YAAY,GAAG,IAAI,CAAC,MAAM,GAAG,GAAG,CAAC;QACnC,CAAC;QAED,yEAAyE;QACzE,MAAM,cAAc,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;QAC7C,IAAI,cAAc,EAAE,CAAC;YACnB,MAAM,eAAe,GAAG,cAAc,CAAC,MAAM,CAC3C,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC,GAAG,GAAG,GAAG,CAAC,MAAM,GAAG,CAAC,EAClC,CAAC,CACF,CAAC;YACF,YAAY,IAAI,eAAe,GAAG,CAAC,CAAC;QACtC,CAAC;QAED,0EAA0E;QAC1E,OAAO,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IACjC,CAAC;CACF"}
|
@@ -1,18 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* Copyright 2025 Vybestack LLC
|
3
|
-
*
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
-
* you may not use this file except in compliance with the License.
|
6
|
-
* You may obtain a copy of the License at
|
7
|
-
*
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
9
|
-
*
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
-
* See the License for the specific language governing permissions and
|
14
|
-
* limitations under the License.
|
15
|
-
*/
|
16
|
-
export interface ITokenizer {
|
17
|
-
countTokens(text: string, model: string): Promise<number>;
|
18
|
-
}
|
@@ -1,17 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* Copyright 2025 Vybestack LLC
|
3
|
-
*
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
-
* you may not use this file except in compliance with the License.
|
6
|
-
* You may obtain a copy of the License at
|
7
|
-
*
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
9
|
-
*
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
-
* See the License for the specific language governing permissions and
|
14
|
-
* limitations under the License.
|
15
|
-
*/
|
16
|
-
export {};
|
17
|
-
//# sourceMappingURL=ITokenizer.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"ITokenizer.js","sourceRoot":"","sources":["../../../../src/providers/tokenizers/ITokenizer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG"}
|
@@ -1,24 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* Copyright 2025 Vybestack LLC
|
3
|
-
*
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
-
* you may not use this file except in compliance with the License.
|
6
|
-
* You may obtain a copy of the License at
|
7
|
-
*
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
9
|
-
*
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
-
* See the License for the specific language governing permissions and
|
14
|
-
* limitations under the License.
|
15
|
-
*/
|
16
|
-
import { ITokenizer } from './ITokenizer.js';
|
17
|
-
export declare class OpenAITokenizer implements ITokenizer {
|
18
|
-
private encoderCache;
|
19
|
-
countTokens(text: string, model: string): Promise<number>;
|
20
|
-
/**
|
21
|
-
* Clean up encoder resources
|
22
|
-
*/
|
23
|
-
dispose(): void;
|
24
|
-
}
|
@@ -1,56 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* Copyright 2025 Vybestack LLC
|
3
|
-
*
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
-
* you may not use this file except in compliance with the License.
|
6
|
-
* You may obtain a copy of the License at
|
7
|
-
*
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
9
|
-
*
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
-
* See the License for the specific language governing permissions and
|
14
|
-
* limitations under the License.
|
15
|
-
*/
|
16
|
-
import { encoding_for_model } from '@dqbd/tiktoken';
|
17
|
-
export class OpenAITokenizer {
|
18
|
-
encoderCache = new Map();
|
19
|
-
async countTokens(text, model) {
|
20
|
-
try {
|
21
|
-
// Get or create encoder for the model
|
22
|
-
let encoder = this.encoderCache.get(model);
|
23
|
-
if (!encoder) {
|
24
|
-
// Try to get encoder for the specific model
|
25
|
-
try {
|
26
|
-
encoder = encoding_for_model(model);
|
27
|
-
this.encoderCache.set(model, encoder);
|
28
|
-
}
|
29
|
-
catch (_error) {
|
30
|
-
// Fall back to cl100k_base encoding for newer models
|
31
|
-
console.warn(`No specific encoding for model ${model}, using cl100k_base`);
|
32
|
-
encoder = encoding_for_model('gpt-4');
|
33
|
-
this.encoderCache.set(model, encoder);
|
34
|
-
}
|
35
|
-
}
|
36
|
-
// Count tokens
|
37
|
-
const tokens = encoder.encode(text);
|
38
|
-
return tokens.length;
|
39
|
-
}
|
40
|
-
catch (error) {
|
41
|
-
console.error('Error counting tokens:', error);
|
42
|
-
// Fallback: rough estimate based on characters
|
43
|
-
return Math.ceil(text.length / 4);
|
44
|
-
}
|
45
|
-
}
|
46
|
-
/**
|
47
|
-
* Clean up encoder resources
|
48
|
-
*/
|
49
|
-
dispose() {
|
50
|
-
for (const encoder of this.encoderCache.values()) {
|
51
|
-
encoder.free();
|
52
|
-
}
|
53
|
-
this.encoderCache.clear();
|
54
|
-
}
|
55
|
-
}
|
56
|
-
//# sourceMappingURL=OpenAITokenizer.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"OpenAITokenizer.js","sourceRoot":"","sources":["../../../../src/providers/tokenizers/OpenAITokenizer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAA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AAI,CAAC,YAAY,CAAC,KAAK,EAAE,CAAC;IAC5B,CAAC;CACF"}
|
@@ -1,40 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* Copyright 2025 Vybestack LLC
|
3
|
-
*
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
-
* you may not use this file except in compliance with the License.
|
6
|
-
* You may obtain a copy of the License at
|
7
|
-
*
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
9
|
-
*
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
-
* See the License for the specific language governing permissions and
|
14
|
-
* limitations under the License.
|
15
|
-
*/
|
16
|
-
import { ITool } from '../providers/ITool.js';
|
17
|
-
import { IMessage } from '../providers/IMessage.js';
|
18
|
-
export type ToolFormat = 'openai' | 'anthropic' | 'deepseek' | 'qwen' | 'hermes' | 'xml' | 'llama' | 'gemma';
|
19
|
-
export interface OpenAIFunction {
|
20
|
-
name: string;
|
21
|
-
description?: string;
|
22
|
-
parameters: object;
|
23
|
-
}
|
24
|
-
export interface OpenAITool {
|
25
|
-
type: 'function';
|
26
|
-
function: OpenAIFunction;
|
27
|
-
}
|
28
|
-
export interface ResponsesTool {
|
29
|
-
type: 'function';
|
30
|
-
name: string;
|
31
|
-
description?: string | null;
|
32
|
-
parameters: Record<string, unknown> | null;
|
33
|
-
strict: boolean | null;
|
34
|
-
}
|
35
|
-
export interface IToolFormatter {
|
36
|
-
toProviderFormat(tools: ITool[], format: 'openai'): OpenAITool[];
|
37
|
-
toProviderFormat(tools: ITool[], format: ToolFormat): unknown;
|
38
|
-
fromProviderFormat(rawToolCall: unknown, format: ToolFormat): IMessage['tool_calls'];
|
39
|
-
toResponsesTool(tools: ITool[]): ResponsesTool[];
|
40
|
-
}
|
@@ -1,17 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* Copyright 2025 Vybestack LLC
|
3
|
-
*
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
-
* you may not use this file except in compliance with the License.
|
6
|
-
* You may obtain a copy of the License at
|
7
|
-
*
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
9
|
-
*
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
-
* See the License for the specific language governing permissions and
|
14
|
-
* limitations under the License.
|
15
|
-
*/
|
16
|
-
export {};
|
17
|
-
//# sourceMappingURL=IToolFormatter.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"IToolFormatter.js","sourceRoot":"","sources":["../../../src/tools/IToolFormatter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG"}
|
@@ -1,45 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* Copyright 2025 Vybestack LLC
|
3
|
-
*
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
-
* you may not use this file except in compliance with the License.
|
6
|
-
* You may obtain a copy of the License at
|
7
|
-
*
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
9
|
-
*
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
-
* See the License for the specific language governing permissions and
|
14
|
-
* limitations under the License.
|
15
|
-
*/
|
16
|
-
import { IToolFormatter, ToolFormat, OpenAITool, ResponsesTool } from './IToolFormatter.js';
|
17
|
-
import { ITool } from '../providers/ITool.js';
|
18
|
-
import { IMessage } from '../providers/IMessage.js';
|
19
|
-
export declare class ToolFormatter implements IToolFormatter {
|
20
|
-
/**
|
21
|
-
* Converts Gemini schema format (with uppercase Type enums) to standard JSON Schema format
|
22
|
-
*/
|
23
|
-
private convertGeminiSchemaToStandard;
|
24
|
-
toProviderFormat(tools: ITool[], format: 'openai'): OpenAITool[];
|
25
|
-
toProviderFormat(tools: ITool[], format: ToolFormat): unknown;
|
26
|
-
fromProviderFormat(rawToolCall: unknown, format: ToolFormat): IMessage['tool_calls'];
|
27
|
-
/**
|
28
|
-
* Handles streaming tool call accumulation for OpenAI-compatible providers
|
29
|
-
* This accumulates partial tool calls from streaming responses
|
30
|
-
*/
|
31
|
-
accumulateStreamingToolCall(deltaToolCall: {
|
32
|
-
index?: number;
|
33
|
-
id?: string;
|
34
|
-
type?: string;
|
35
|
-
function?: {
|
36
|
-
name?: string;
|
37
|
-
arguments?: string;
|
38
|
-
};
|
39
|
-
}, accumulatedToolCalls: NonNullable<IMessage['tool_calls']>, format: ToolFormat): void;
|
40
|
-
/**
|
41
|
-
* Formats tools specifically for the OpenAI Responses API
|
42
|
-
* The Responses API expects a flatter format than the regular OpenAI API
|
43
|
-
*/
|
44
|
-
toResponsesTool(tools: ITool[]): ResponsesTool[];
|
45
|
-
}
|