@vybestack/llxprt-code-core 0.5.0-nightly.251113.5cde5bb1 → 0.5.0-nightly.251115.a0f86309
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
|
@@ -1,108 +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
|
-
* ToolCallValidator - Validates tool call candidates
|
|
18
|
-
*
|
|
19
|
-
* Responsible for validating collected tool call candidates to ensure they are valid
|
|
20
|
-
* and meet execution requirements.
|
|
21
|
-
*/
|
|
22
|
-
import { DebugLogger } from '../../debug/index.js';
|
|
23
|
-
const logger = new DebugLogger('llxprt:providers:openai:toolCallValidator');
|
|
24
|
-
/**
|
|
25
|
-
* ToolCallValidator - The verification tool calls the candidates.
|
|
26
|
-
*/
|
|
27
|
-
export class ToolCallValidator {
|
|
28
|
-
allowedToolNames;
|
|
29
|
-
constructor(allowedToolNames = []) {
|
|
30
|
-
this.allowedToolNames = new Set(allowedToolNames);
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Validate tool call candidate
|
|
34
|
-
*/
|
|
35
|
-
validate(candidate) {
|
|
36
|
-
const result = {
|
|
37
|
-
index: candidate.index,
|
|
38
|
-
name: candidate.name || '',
|
|
39
|
-
args: candidate.args,
|
|
40
|
-
isValid: true,
|
|
41
|
-
validationErrors: [],
|
|
42
|
-
};
|
|
43
|
-
const errors = [];
|
|
44
|
-
// Check if name exists
|
|
45
|
-
if (!candidate.name || !candidate.name.trim()) {
|
|
46
|
-
errors.push('Tool call missing name');
|
|
47
|
-
result.isValid = false;
|
|
48
|
-
}
|
|
49
|
-
// Check if name is in allowed list
|
|
50
|
-
if (candidate.name &&
|
|
51
|
-
this.allowedToolNames.size > 0 &&
|
|
52
|
-
!this.allowedToolNames.has(candidate.name)) {
|
|
53
|
-
errors.push(`Tool name '${candidate.name}' is not in allowed list`);
|
|
54
|
-
result.isValid = false;
|
|
55
|
-
}
|
|
56
|
-
// Check name format
|
|
57
|
-
if (candidate.name && !this.isValidToolName(candidate.name)) {
|
|
58
|
-
errors.push(`Tool name '${candidate.name}' contains invalid characters`);
|
|
59
|
-
result.isValid = false;
|
|
60
|
-
}
|
|
61
|
-
// Check parameter format
|
|
62
|
-
if (candidate.args && !this.isValidArgs(candidate.args)) {
|
|
63
|
-
errors.push('Tool call arguments are not valid JSON');
|
|
64
|
-
result.isValid = false;
|
|
65
|
-
}
|
|
66
|
-
result.validationErrors = errors;
|
|
67
|
-
if (!result.isValid) {
|
|
68
|
-
logger.warn(`Tool call ${candidate.index} validation failed: ${errors.join(', ')}`);
|
|
69
|
-
}
|
|
70
|
-
else {
|
|
71
|
-
logger.debug(`Tool call ${candidate.index} validation passed`);
|
|
72
|
-
}
|
|
73
|
-
return result;
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Batch validate tool call candidates
|
|
77
|
-
*/
|
|
78
|
-
validateBatch(candidates) {
|
|
79
|
-
return candidates.map((candidate) => this.validate(candidate));
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* Check if tool name is valid
|
|
83
|
-
*/
|
|
84
|
-
isValidToolName(name) {
|
|
85
|
-
// Allow letters, numbers, underscores and hyphens
|
|
86
|
-
return /^[a-zA-Z0-9_-]+$/.test(name);
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Check if parameters are valid JSON
|
|
90
|
-
*/
|
|
91
|
-
isValidArgs(args) {
|
|
92
|
-
try {
|
|
93
|
-
JSON.parse(args);
|
|
94
|
-
return true;
|
|
95
|
-
}
|
|
96
|
-
catch {
|
|
97
|
-
return false;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
/**
|
|
101
|
-
* Update allowed tool names list
|
|
102
|
-
*/
|
|
103
|
-
updateAllowedTools(allowedToolNames) {
|
|
104
|
-
this.allowedToolNames = new Set(allowedToolNames);
|
|
105
|
-
logger.debug(`Updated allowed tool names: ${allowedToolNames.join(', ')}`);
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
//# sourceMappingURL=ToolCallValidator.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ToolCallValidator.js","sourceRoot":"","sources":["../../../../src/providers/openai/ToolCallValidator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH;;;;;GAKG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAEnD,MAAM,MAAM,GAAG,IAAI,WAAW,CAAC,2CAA2C,CAAC,CAAC;AAgB5E;;GAEG;AACH,MAAM,OAAO,iBAAiB;IACpB,gBAAgB,CAAc;IAEtC,YAAY,mBAA6B,EAAE;QACzC,IAAI,CAAC,gBAAgB,GAAG,IAAI,GAAG,CAAC,gBAAgB,CAAC,CAAC;IACpD,CAAC;IAED;;OAEG;IACH,QAAQ,CAAC,SAA4B;QACnC,MAAM,MAAM,GAAsB;YAChC,KAAK,EAAE,SAAS,CAAC,KAAK;YACtB,IAAI,EAAE,SAAS,CAAC,IAAI,IAAI,EAAE;YAC1B,IAAI,EAAE,SAAS,CAAC,IAAI;YACpB,OAAO,EAAE,IAAI;YACb,gBAAgB,EAAE,EAAE;SACrB,CAAC;QAEF,MAAM,MAAM,GAAa,EAAE,CAAC;QAE5B,uBAAuB;QACvB,IAAI,CAAC,SAAS,CAAC,IAAI,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC;YAC9C,MAAM,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAC;YACtC,MAAM,CAAC,OAAO,GAAG,KAAK,CAAC;QACzB,CAAC;QAED,mCAAmC;QACnC,IACE,SAAS,CAAC,IAAI;YACd,IAAI,CAAC,gBAAgB,CAAC,IAAI,GAAG,CAAC;YAC9B,CAAC,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,CAAC,EAC1C,CAAC;YACD,MAAM,CAAC,IAAI,CAAC,cAAc,SAAS,CAAC,IAAI,0BAA0B,CAAC,CAAC;YACpE,MAAM,C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