mocode-ai 1.7.0 → 1.7.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/dist/tools/validation.js +5 -2
- package/package.json +1 -1
package/dist/tools/validation.js
CHANGED
|
@@ -3,7 +3,10 @@ import Ajv2020 from 'ajv/dist/2020.js';
|
|
|
3
3
|
const options = {
|
|
4
4
|
allErrors: true,
|
|
5
5
|
strict: false,
|
|
6
|
-
|
|
6
|
+
// 中转网关/弱模型常把 integer/number/boolean 序列化成字符串(如 "100"),
|
|
7
|
+
// 开启标量强转在校验前自动还原;类型完全不符("abc"→number)仍会被拦,
|
|
8
|
+
// minimum/maximum 等约束在转换后照常生效。
|
|
9
|
+
coerceTypes: true,
|
|
7
10
|
useDefaults: false,
|
|
8
11
|
removeAdditional: false,
|
|
9
12
|
validateFormats: false,
|
|
@@ -69,7 +72,7 @@ function formatErrors(errors, schema) {
|
|
|
69
72
|
}
|
|
70
73
|
return body + hint;
|
|
71
74
|
}
|
|
72
|
-
/** Validate after tool-local normalization; AJV
|
|
75
|
+
/** Validate after tool-local normalization; AJV coerces scalar strings to declared types. */
|
|
73
76
|
export function validateToolArguments(tool, args) {
|
|
74
77
|
if (!args || typeof args !== 'object' || Array.isArray(args)) {
|
|
75
78
|
return {
|