@vybestack/llxprt-code-core 0.5.0-nightly.251112.9f39f506 → 0.5.0-nightly.251114.cf6b109c
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 +1 -1
- package/dist/src/providers/openai/OpenAIProvider.js +5 -5
- package/dist/src/providers/openai/OpenAIProvider.js.map +1 -1
- package/dist/src/providers/openai/ToolCallCollector.js +7 -8
- package/dist/src/providers/openai/ToolCallCollector.js.map +1 -1
- package/dist/src/providers/openai/ToolCallNormalizer.d.ts +8 -2
- package/dist/src/providers/openai/ToolCallNormalizer.js +13 -15
- package/dist/src/providers/openai/ToolCallNormalizer.js.map +1 -1
- package/dist/src/providers/openai/ToolCallPipeline.d.ts +13 -26
- package/dist/src/providers/openai/ToolCallPipeline.js +57 -60
- package/dist/src/providers/openai/ToolCallPipeline.js.map +1 -1
- package/dist/src/tools/doubleEscapeUtils.d.ts +2 -2
- package/dist/src/tools/doubleEscapeUtils.js +49 -33
- package/dist/src/tools/doubleEscapeUtils.js.map +1 -1
- package/package.json +1 -1
- package/dist/src/providers/openai/ToolCallExecutor.d.ts +0 -65
- package/dist/src/providers/openai/ToolCallExecutor.js +0 -120
- package/dist/src/providers/openai/ToolCallExecutor.js.map +0 -1
- package/dist/src/providers/openai/ToolCallValidator.d.ts +0 -55
- package/dist/src/providers/openai/ToolCallValidator.js +0 -108
- package/dist/src/providers/openai/ToolCallValidator.js.map +0 -1
|
@@ -14,30 +14,24 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
/**
|
|
17
|
-
* ToolCallPipeline -
|
|
17
|
+
* ToolCallPipeline - Simplified tool call processing pipeline
|
|
18
18
|
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
19
|
+
* Focused on collection and normalization phases only.
|
|
20
|
+
* Tool execution is handled by the Core layer, not Provider layer.
|
|
21
21
|
*/
|
|
22
22
|
import { DebugLogger } from '../../debug/index.js';
|
|
23
23
|
import { ToolCallCollector } from './ToolCallCollector.js';
|
|
24
|
-
import { ToolCallValidator } from './ToolCallValidator.js';
|
|
25
24
|
import { ToolCallNormalizer, } from './ToolCallNormalizer.js';
|
|
26
|
-
import { ToolCallExecutor, } from './ToolCallExecutor.js';
|
|
27
25
|
const logger = new DebugLogger('llxprt:providers:openai:toolCallPipeline');
|
|
28
26
|
/**
|
|
29
|
-
* ToolCallPipeline -
|
|
27
|
+
* Simplified ToolCallPipeline - Collection and normalization only
|
|
30
28
|
*/
|
|
31
29
|
export class ToolCallPipeline {
|
|
32
30
|
collector;
|
|
33
|
-
validator;
|
|
34
31
|
normalizer;
|
|
35
|
-
|
|
36
|
-
constructor(allowedToolNames = []) {
|
|
32
|
+
constructor() {
|
|
37
33
|
this.collector = new ToolCallCollector();
|
|
38
|
-
this.validator = new ToolCallValidator(allowedToolNames);
|
|
39
34
|
this.normalizer = new ToolCallNormalizer();
|
|
40
|
-
this.executor = new ToolCallExecutor();
|
|
41
35
|
}
|
|
42
36
|
/**
|
|
43
37
|
* Add tool call fragment
|
|
@@ -46,72 +40,67 @@ export class ToolCallPipeline {
|
|
|
46
40
|
this.collector.addFragment(index, fragment);
|
|
47
41
|
}
|
|
48
42
|
/**
|
|
49
|
-
* Process all collected tool calls
|
|
43
|
+
* Process all collected tool calls (collection + normalization only)
|
|
50
44
|
*/
|
|
51
45
|
async process() {
|
|
52
|
-
logger.debug('Starting tool call pipeline processing');
|
|
46
|
+
logger.debug('Starting simplified tool call pipeline processing');
|
|
53
47
|
// Phase 1: Collect complete calls
|
|
54
48
|
const candidates = this.collector.getCompleteCalls();
|
|
55
49
|
logger.debug(`Collected ${candidates.length} complete tool calls`);
|
|
56
|
-
// Phase 2:
|
|
57
|
-
const
|
|
58
|
-
const
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
50
|
+
// Phase 2: Normalize calls directly (no separate validation needed)
|
|
51
|
+
const normalizedCalls = [];
|
|
52
|
+
const failedCalls = [];
|
|
53
|
+
for (const candidate of candidates) {
|
|
54
|
+
try {
|
|
55
|
+
// Create a mock validated call for normalization
|
|
56
|
+
const mockValidatedCall = {
|
|
57
|
+
index: candidate.index,
|
|
58
|
+
name: candidate.name || '',
|
|
59
|
+
args: candidate.args || '',
|
|
60
|
+
isValid: true,
|
|
61
|
+
validationErrors: [],
|
|
62
|
+
};
|
|
63
|
+
const normalized = this.normalizer.normalize(mockValidatedCall);
|
|
64
|
+
if (normalized) {
|
|
65
|
+
normalizedCalls.push(normalized);
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
failedCalls.push({
|
|
69
|
+
index: candidate.index,
|
|
70
|
+
name: candidate.name,
|
|
71
|
+
args: candidate.args,
|
|
72
|
+
isValid: false,
|
|
73
|
+
validationErrors: ['Normalization failed'],
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
catch (error) {
|
|
78
|
+
failedCalls.push({
|
|
79
|
+
index: candidate.index,
|
|
80
|
+
name: candidate.name,
|
|
81
|
+
args: candidate.args,
|
|
82
|
+
isValid: false,
|
|
83
|
+
validationErrors: [
|
|
84
|
+
error instanceof Error ? error.message : 'Unknown error',
|
|
85
|
+
],
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
logger.debug(`Normalized ${normalizedCalls.length} tool calls, ${failedCalls.length} failed`);
|
|
69
90
|
// Reset collector for next batch
|
|
70
91
|
this.collector.reset();
|
|
71
92
|
const result = {
|
|
72
|
-
executed: executionResults,
|
|
73
93
|
normalized: normalizedCalls,
|
|
74
|
-
failed:
|
|
94
|
+
failed: failedCalls,
|
|
75
95
|
stats: {
|
|
76
96
|
collected: candidates.length,
|
|
77
|
-
validated: validCalls.length,
|
|
78
97
|
normalized: normalizedCalls.length,
|
|
79
|
-
|
|
80
|
-
failed: invalidCalls.length + failedResults.length,
|
|
98
|
+
failed: failedCalls.length,
|
|
81
99
|
},
|
|
82
100
|
};
|
|
83
101
|
logger.debug(`Pipeline processing completed: ${JSON.stringify(result.stats)}`);
|
|
84
102
|
return result;
|
|
85
103
|
}
|
|
86
|
-
/**
|
|
87
|
-
* Register tool function
|
|
88
|
-
*/
|
|
89
|
-
registerTool(name, fn) {
|
|
90
|
-
this.executor.registerTool(name, fn);
|
|
91
|
-
this.validator.updateAllowedTools(this.executor.getRegisteredTools());
|
|
92
|
-
}
|
|
93
|
-
/**
|
|
94
|
-
* Register tool functions in batch
|
|
95
|
-
*/
|
|
96
|
-
registerTools(tools) {
|
|
97
|
-
this.executor.registerTools(tools);
|
|
98
|
-
this.validator.updateAllowedTools(this.executor.getRegisteredTools());
|
|
99
|
-
}
|
|
100
|
-
/**
|
|
101
|
-
* Check if tool is registered
|
|
102
|
-
*/
|
|
103
|
-
isToolRegistered(name) {
|
|
104
|
-
return this.executor.isToolRegistered(name);
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* Get pipeline statistics
|
|
108
|
-
*/
|
|
109
|
-
getStats() {
|
|
110
|
-
return {
|
|
111
|
-
collector: this.collector.getStats(),
|
|
112
|
-
registeredTools: this.executor.getRegisteredTools().length,
|
|
113
|
-
};
|
|
114
|
-
}
|
|
115
104
|
/**
|
|
116
105
|
* Normalize single tool name (for non-streaming path)
|
|
117
106
|
*/
|
|
@@ -126,6 +115,14 @@ export class ToolCallPipeline {
|
|
|
126
115
|
const normalized = this.normalizer.normalize(mockValidatedCall);
|
|
127
116
|
return normalized?.name || name || '';
|
|
128
117
|
}
|
|
118
|
+
/**
|
|
119
|
+
* Get pipeline statistics
|
|
120
|
+
*/
|
|
121
|
+
getStats() {
|
|
122
|
+
return {
|
|
123
|
+
collector: this.collector.getStats(),
|
|
124
|
+
};
|
|
125
|
+
}
|
|
129
126
|
/**
|
|
130
127
|
* Reset pipeline state
|
|
131
128
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ToolCallPipeline.js","sourceRoot":"","sources":["../../../../src/providers/openai/ToolCallPipeline.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH;;;;;GAKG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,
|
|
1
|
+
{"version":3,"file":"ToolCallPipeline.js","sourceRoot":"","sources":["../../../../src/providers/openai/ToolCallPipeline.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH;;;;;GAKG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EACL,kBAAkB,GAEnB,MAAM,yBAAyB,CAAC;AAEjC,MAAM,MAAM,GAAG,IAAI,WAAW,CAAC,0CAA0C,CAAC,CAAC;AAoB3E;;GAEG;AACH,MAAM,OAAO,gBAAgB;IACnB,SAAS,CAAoB;IAC7B,UAAU,CAAqB;IAEvC;QACE,IAAI,CAAC,SAAS,GAAG,IAAI,iBAAiB,EAAE,CAAC;QACzC,IAAI,CAAC,UAAU,GAAG,IAAI,kBAAkB,EAAE,CAAC;IAC7C,CAAC;IAED;;OAEG;IACH,WAAW,CAAC,KAAa,EAAE,QAAmC;QAC5D,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IAC9C,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,OAAO;QACX,MAAM,CAAC,KAAK,CAAC,mDAAmD,CAAC,CAAC;QAElE,kCAAkC;QAClC,MAAM,UAAU,GAAG,IAAI,CAAC,SAAS,CAAC,gBAAgB,EAAE,CAAC;QACrD,MAAM,CAAC,KAAK,CAAC,aAAa,UAAU,CAAC,MAAM,sBAAsB,CAAC,CAAC;QAEnE,oEAAoE;QAC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WAAW,CAAC,MAAM,SAAS,CAChF,CAAC;QAEF,iCAAiC;QACjC,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;QAEvB,MAAM,MAAM,GAAmB;YAC7B,UAAU,EAAE,eAAe;YAC3B,MAAM,EAAE,WAAW;YACnB,KAAK,EAAE;gBACL,SAAS,EAAE,UAAU,CAAC,MAAM;gBAC5B,UAAU,EAAE,eAAe,CAAC,MAAM;gBAClC,MAAM,EAAE,WAAW,CAAC,MAAM;aAC3B;SACF,CAAC;QAEF,MAAM,CAAC,KAAK,CACV,kCAAkC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CACjE,CAAC;QACF,OAAO,MAAM,CAAC;IAChB,CAAC;IAED;;OAEG;IACH,iBAAiB,CAAC,IAAY,EAAE,IAAa;QAC3C,MAAM,iBAAiB,GAAG;YACxB,KAAK,EAAE,CAAC;YACR,IAAI,EAAE,IAAI,IAAI,EAAE;YAChB,IAAI,EAAE,IAAI,IAAI,EAAE;YAChB,OAAO,EAAE,IAAI;YACb,gBAAgB,EAAE,EAAE;SACrB,CAAC;QAEF,MAAM,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,iBAAiB,CAAC,CAAC;QAChE,OAAO,UAAU,EAAE,IAAI,IAAI,IAAI,IAAI,EAAE,CAAC;IACxC,CAAC;IAED;;OAEG;IACH,QAAQ;QACN,OAAO;YACL,SAAS,EAAE,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE;SACrC,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,KAAK;QACH,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;QACvB,MAAM,CAAC,KAAK,CAAC,wBAAwB,CAAC,CAAC;IACzC,CAAC;CACF"}
|
|
@@ -34,10 +34,10 @@ export declare function detectDoubleEscapingInChunk(chunk: string): boolean;
|
|
|
34
34
|
* Processes tool call parameters, fixing double-escaping if detected
|
|
35
35
|
* @param parametersString - The JSON string containing tool parameters
|
|
36
36
|
* @param toolName - Name of the tool (for logging)
|
|
37
|
-
* @param format - The tool format being used (for context)
|
|
37
|
+
* @param format - The tool format being used (for context, optional)
|
|
38
38
|
* @returns Processed parameters object
|
|
39
39
|
*/
|
|
40
|
-
export declare function processToolParameters(parametersString: string, toolName: string, format
|
|
40
|
+
export declare function processToolParameters(parametersString: string, toolName: string, format?: string): unknown;
|
|
41
41
|
/**
|
|
42
42
|
* Logs double-escaping detection in streaming chunks (for debugging)
|
|
43
43
|
* @param chunk - The chunk that contains potential double-escaping
|
|
@@ -145,54 +145,70 @@ export function detectDoubleEscapingInChunk(chunk) {
|
|
|
145
145
|
* Processes tool call parameters, fixing double-escaping if detected
|
|
146
146
|
* @param parametersString - The JSON string containing tool parameters
|
|
147
147
|
* @param toolName - Name of the tool (for logging)
|
|
148
|
-
* @param format - The tool format being used (for context)
|
|
148
|
+
* @param format - The tool format being used (for context, optional)
|
|
149
149
|
* @returns Processed parameters object
|
|
150
150
|
*/
|
|
151
151
|
export function processToolParameters(parametersString, toolName, format) {
|
|
152
152
|
if (!parametersString.trim()) {
|
|
153
153
|
return {};
|
|
154
154
|
}
|
|
155
|
-
//
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
155
|
+
// Try multiple parsing strategies without format dependency
|
|
156
|
+
return tryMultipleParsingStrategies(parametersString, toolName, format);
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Try multiple parsing strategies to handle tool parameters
|
|
160
|
+
* @param parametersString - The JSON string containing tool parameters
|
|
161
|
+
* @param toolName - Name of the tool (for logging)
|
|
162
|
+
* @param format - The tool format being used (for context, optional)
|
|
163
|
+
* @returns Processed parameters object
|
|
164
|
+
*/
|
|
165
|
+
function tryMultipleParsingStrategies(parametersString, toolName, format) {
|
|
166
|
+
// Strategy 1: Direct JSON parsing
|
|
167
|
+
try {
|
|
168
|
+
const parsed = JSON.parse(parametersString);
|
|
169
|
+
// Handle empty string case
|
|
170
|
+
if (typeof parsed === 'string' && parsed.trim() === '') {
|
|
171
|
+
return {};
|
|
172
|
+
}
|
|
173
|
+
// If the parsed result is a string that looks like JSON,
|
|
174
|
+
// it might be double-escaped, so continue to strategy 2
|
|
175
|
+
if (typeof parsed === 'string' && parsed.trim().startsWith('{')) {
|
|
176
|
+
// Don't return yet, let strategy 2 handle the double-escaping
|
|
160
177
|
}
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
return parametersString; // Return as-is if not valid JSON
|
|
178
|
+
else {
|
|
179
|
+
return parsed;
|
|
164
180
|
}
|
|
165
181
|
}
|
|
166
|
-
|
|
182
|
+
catch {
|
|
183
|
+
// Continue to next strategy
|
|
184
|
+
}
|
|
185
|
+
// Strategy 2: Detect and repair double escaping (existing logic, no format dependency)
|
|
167
186
|
const detection = detectDoubleEscaping(parametersString);
|
|
168
|
-
if (detection.
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
187
|
+
if (detection.correctedValue !== undefined) {
|
|
188
|
+
if (detection.isDoubleEscaped) {
|
|
189
|
+
logger.error(() => `[${format || 'auto'}] Fixed double-escaped parameters for ${toolName}`, {
|
|
190
|
+
tool: toolName,
|
|
191
|
+
format: format || 'auto',
|
|
192
|
+
originalLength: parametersString.length,
|
|
193
|
+
fixed: true,
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
const result = convertStringNumbersToNumbers(detection.correctedValue);
|
|
197
|
+
// Handle empty string case for double-escaped results
|
|
198
|
+
if (typeof result === 'string' && result.trim() === '') {
|
|
199
|
+
return {};
|
|
200
|
+
}
|
|
201
|
+
return result;
|
|
177
202
|
}
|
|
178
|
-
|
|
179
|
-
|
|
203
|
+
// Strategy 3: Return original string (last resort)
|
|
204
|
+
if (detection.detectionDetails.error) {
|
|
205
|
+
logger.error(() => `[${format || 'auto'}] Failed to parse parameters for ${toolName}`, {
|
|
180
206
|
tool: toolName,
|
|
181
|
-
format,
|
|
207
|
+
format: format || 'auto',
|
|
182
208
|
error: detection.detectionDetails.error,
|
|
183
209
|
});
|
|
184
|
-
// Return the string as-is if parsing fails
|
|
185
|
-
return parametersString;
|
|
186
|
-
}
|
|
187
|
-
// Convert string numbers to actual numbers for qwen format
|
|
188
|
-
const normalized = detection.correctedValue;
|
|
189
|
-
if (typeof normalized === 'string') {
|
|
190
|
-
const trimmed = normalized.trim();
|
|
191
|
-
if (trimmed.length === 0) {
|
|
192
|
-
return {};
|
|
193
|
-
}
|
|
194
210
|
}
|
|
195
|
-
return
|
|
211
|
+
return parametersString;
|
|
196
212
|
}
|
|
197
213
|
/**
|
|
198
214
|
* Converts string numbers to actual numbers in an object
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"doubleEscapeUtils.js","sourceRoot":"","sources":["../../../src/tools/doubleEscapeUtils.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;;;;;;;;GAcG;AAEH;;;;GAIG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,MAAM,MAAM,GAAG,IAAI,WAAW,CAAC,2BAA2B,CAAC,CAAC;AAE5D;;;;GAIG;AACH,MAAM,UAAU,6BAA6B,CAAC,UAAkB;IAC9D,qFAAqF;IACrF,OAAO,UAAU,KAAK,MAAM,CAAC;AAC/B,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAAC,UAAkB;IAUrD,MAAM,MAAM,GASR;QACF,eAAe,EAAE,KAAK;QACtB,cAAc,EAAE,SAAS;QACzB,aAAa,EAAE,UAAU;QACzB,gBAAgB,EAAE,EAAE;KACrB,CAAC;IAEF,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;QAEtC,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;YAC/B,MAAM,CAAC,gBAAgB,CAAC,UAAU,GAAG,MAA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CACV,GAAG,EAAE,CACH,IAAI,MAAM,+DAA+D,QAAQ,EAAE,EACrF;YACE,KAAK;YACL,IAAI,EAAE,QAAQ;YACd,MAAM;YACN,OAAO,EAAE,6DAA6D;SACvE,CACF,CAAC;IACJ,CAAC;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,65 +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 ToolExecutionResult {
|
|
17
|
-
index: number;
|
|
18
|
-
name: string;
|
|
19
|
-
success: boolean;
|
|
20
|
-
result?: unknown;
|
|
21
|
-
error?: string;
|
|
22
|
-
executionTime: number;
|
|
23
|
-
}
|
|
24
|
-
export interface ToolFunction {
|
|
25
|
-
(args: Record<string, unknown>): Promise<unknown> | unknown;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* ToolCallExecutor - Responsible for executing tool calls
|
|
29
|
-
*/
|
|
30
|
-
export declare class ToolCallExecutor {
|
|
31
|
-
private toolRegistry;
|
|
32
|
-
/**
|
|
33
|
-
* Register tool function
|
|
34
|
-
*/
|
|
35
|
-
registerTool(name: string, fn: ToolFunction): void;
|
|
36
|
-
/**
|
|
37
|
-
* Batch register tool functions
|
|
38
|
-
*/
|
|
39
|
-
registerTools(tools: Record<string, ToolFunction>): void;
|
|
40
|
-
/**
|
|
41
|
-
* Execute single tool call
|
|
42
|
-
*/
|
|
43
|
-
execute(normalizedCall: NormalizedToolCall): Promise<ToolExecutionResult>;
|
|
44
|
-
/**
|
|
45
|
-
* Batch execute tool calls
|
|
46
|
-
*/
|
|
47
|
-
executeBatch(normalizedCalls: NormalizedToolCall[]): Promise<ToolExecutionResult[]>;
|
|
48
|
-
/**
|
|
49
|
-
* Check if tool is registered
|
|
50
|
-
*/
|
|
51
|
-
isToolRegistered(name: string): boolean;
|
|
52
|
-
/**
|
|
53
|
-
* Get list of registered tool names
|
|
54
|
-
*/
|
|
55
|
-
getRegisteredTools(): string[];
|
|
56
|
-
/**
|
|
57
|
-
* Remove registered tool
|
|
58
|
-
*/
|
|
59
|
-
unregisterTool(name: string): boolean;
|
|
60
|
-
/**
|
|
61
|
-
* Clear all registered tools
|
|
62
|
-
*/
|
|
63
|
-
clearTools(): void;
|
|
64
|
-
}
|
|
65
|
-
import { NormalizedToolCall } from './ToolCallNormalizer.js';
|
|
@@ -1,120 +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
|
-
/**
|
|
17
|
-
* ToolCallExecutor - Execute tool calls
|
|
18
|
-
*
|
|
19
|
-
* Responsible for executing normalized tool calls and handling execution results.
|
|
20
|
-
*/
|
|
21
|
-
import { DebugLogger } from '../../debug/index.js';
|
|
22
|
-
const logger = new DebugLogger('llxprt:providers:openai:toolCallExecutor');
|
|
23
|
-
/**
|
|
24
|
-
* ToolCallExecutor - Responsible for executing tool calls
|
|
25
|
-
*/
|
|
26
|
-
export class ToolCallExecutor {
|
|
27
|
-
toolRegistry = new Map();
|
|
28
|
-
/**
|
|
29
|
-
* Register tool function
|
|
30
|
-
*/
|
|
31
|
-
registerTool(name, fn) {
|
|
32
|
-
this.toolRegistry.set(name, fn);
|
|
33
|
-
logger.debug(`Registered tool: ${name}`);
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Batch register tool functions
|
|
37
|
-
*/
|
|
38
|
-
registerTools(tools) {
|
|
39
|
-
for (const [name, fn] of Object.entries(tools)) {
|
|
40
|
-
this.registerTool(name, fn);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Execute single tool call
|
|
45
|
-
*/
|
|
46
|
-
async execute(normalizedCall) {
|
|
47
|
-
const startTime = Date.now();
|
|
48
|
-
try {
|
|
49
|
-
const toolFn = this.toolRegistry.get(normalizedCall.name);
|
|
50
|
-
if (!toolFn) {
|
|
51
|
-
throw new Error(`Tool '${normalizedCall.name}' is not registered`);
|
|
52
|
-
}
|
|
53
|
-
logger.debug(`Executing tool call ${normalizedCall.index}: ${normalizedCall.name}`);
|
|
54
|
-
const result = await toolFn(normalizedCall.args);
|
|
55
|
-
const executionTime = Date.now() - startTime;
|
|
56
|
-
logger.debug(`Tool call ${normalizedCall.index} completed in ${executionTime}ms`);
|
|
57
|
-
return {
|
|
58
|
-
index: normalizedCall.index,
|
|
59
|
-
name: normalizedCall.name,
|
|
60
|
-
success: true,
|
|
61
|
-
result,
|
|
62
|
-
executionTime,
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
catch (error) {
|
|
66
|
-
const executionTime = Date.now() - startTime;
|
|
67
|
-
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
68
|
-
logger.error(`Tool call ${normalizedCall.index} failed: ${errorMessage}`);
|
|
69
|
-
return {
|
|
70
|
-
index: normalizedCall.index,
|
|
71
|
-
name: normalizedCall.name,
|
|
72
|
-
success: false,
|
|
73
|
-
error: errorMessage,
|
|
74
|
-
executionTime,
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* Batch execute tool calls
|
|
80
|
-
*/
|
|
81
|
-
async executeBatch(normalizedCalls) {
|
|
82
|
-
// Execute sequentially to avoid resource conflicts
|
|
83
|
-
const results = [];
|
|
84
|
-
for (const call of normalizedCalls) {
|
|
85
|
-
const result = await this.execute(call);
|
|
86
|
-
results.push(result);
|
|
87
|
-
}
|
|
88
|
-
return results;
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* Check if tool is registered
|
|
92
|
-
*/
|
|
93
|
-
isToolRegistered(name) {
|
|
94
|
-
return this.toolRegistry.has(name);
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
* Get list of registered tool names
|
|
98
|
-
*/
|
|
99
|
-
getRegisteredTools() {
|
|
100
|
-
return Array.from(this.toolRegistry.keys());
|
|
101
|
-
}
|
|
102
|
-
/**
|
|
103
|
-
* Remove registered tool
|
|
104
|
-
*/
|
|
105
|
-
unregisterTool(name) {
|
|
106
|
-
const removed = this.toolRegistry.delete(name);
|
|
107
|
-
if (removed) {
|
|
108
|
-
logger.debug(`Unregistered tool: ${name}`);
|
|
109
|
-
}
|
|
110
|
-
return removed;
|
|
111
|
-
}
|
|
112
|
-
/**
|
|
113
|
-
* Clear all registered tools
|
|
114
|
-
*/
|
|
115
|
-
clearTools() {
|
|
116
|
-
this.toolRegistry.clear();
|
|
117
|
-
logger.debug('Cleared all registered tools');
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
//# sourceMappingURL=ToolCallExecutor.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ToolCallExecutor.js","sourceRoot":"","sources":["../../../../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AAkB;QAChB,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,IAAI,EAAE,CAAC,CAAC;IAC9C,CAAC;IAED;;OAEG;IACH,cAAc,CAAC,IAAY;QACzB,MAAM,OAAO,GAAG,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAC/C,IAAI,OAAO,EAAE,CAAC;YACZ,MAAM,CAAC,KAAK,CAAC,sBAAsB,IAAI,EAAE,CAAC,CAAC;QAC7C,CAAC;QACD,OAAO,OAAO,CAAC;IACjB,CAAC;IAED;;OAEG;IACH,UAAU;QACR,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,CAAC;QAC1B,MAAM,CAAC,KAAK,CAAC,8BAA8B,CAAC,CAAC;IAC/C,CAAC;CACF"}
|
|
@@ -1,55 +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 ValidationResult {
|
|
17
|
-
isValid: boolean;
|
|
18
|
-
errors: string[];
|
|
19
|
-
warnings: string[];
|
|
20
|
-
}
|
|
21
|
-
export interface ValidatedToolCall {
|
|
22
|
-
index: number;
|
|
23
|
-
name: string;
|
|
24
|
-
args?: string;
|
|
25
|
-
isValid: boolean;
|
|
26
|
-
validationErrors: string[];
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* ToolCallValidator - The verification tool calls the candidates.
|
|
30
|
-
*/
|
|
31
|
-
export declare class ToolCallValidator {
|
|
32
|
-
private allowedToolNames;
|
|
33
|
-
constructor(allowedToolNames?: string[]);
|
|
34
|
-
/**
|
|
35
|
-
* Validate tool call candidate
|
|
36
|
-
*/
|
|
37
|
-
validate(candidate: ToolCallCandidate): ValidatedToolCall;
|
|
38
|
-
/**
|
|
39
|
-
* Batch validate tool call candidates
|
|
40
|
-
*/
|
|
41
|
-
validateBatch(candidates: ToolCallCandidate[]): ValidatedToolCall[];
|
|
42
|
-
/**
|
|
43
|
-
* Check if tool name is valid
|
|
44
|
-
*/
|
|
45
|
-
private isValidToolName;
|
|
46
|
-
/**
|
|
47
|
-
* Check if parameters are valid JSON
|
|
48
|
-
*/
|
|
49
|
-
private isValidArgs;
|
|
50
|
-
/**
|
|
51
|
-
* Update allowed tool names list
|
|
52
|
-
*/
|
|
53
|
-
updateAllowedTools(allowedToolNames: string[]): void;
|
|
54
|
-
}
|
|
55
|
-
import { ToolCallCandidate } from './ToolCallCollector.js';
|