@trikhub/cli 0.3.4 → 0.3.6
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validator.d.ts","sourceRoot":"","sources":["../../src/lib/validator.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;
|
|
1
|
+
{"version":3,"file":"validator.d.ts","sourceRoot":"","sources":["../../src/lib/validator.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAMH;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB;AAkCD;;GAEG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,gBAAgB,CAsG/D;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,gBAAgB,GAAG,MAAM,CAkBvE"}
|
package/dist/lib/validator.js
CHANGED
|
@@ -7,58 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import { readFileSync, existsSync } from 'node:fs';
|
|
9
9
|
import { join } from 'node:path';
|
|
10
|
-
|
|
11
|
-
* Allowed string formats in agentDataSchema
|
|
12
|
-
* Free-form strings without these constraints are security risks
|
|
13
|
-
*/
|
|
14
|
-
const ALLOWED_STRING_FORMATS = ['date', 'date-time', 'time', 'email', 'uri', 'uuid', 'id'];
|
|
15
|
-
/**
|
|
16
|
-
* Check if a JSON Schema allows unconstrained strings
|
|
17
|
-
*
|
|
18
|
-
* Unconstrained strings in agentData can lead to prompt injection
|
|
19
|
-
* because the agent's output would flow directly to the user.
|
|
20
|
-
*/
|
|
21
|
-
function hasUnconstrainedStrings(schema, path = '') {
|
|
22
|
-
const issues = [];
|
|
23
|
-
if (!schema || typeof schema !== 'object') {
|
|
24
|
-
return issues;
|
|
25
|
-
}
|
|
26
|
-
const s = schema;
|
|
27
|
-
// Check if this is a string type
|
|
28
|
-
if (s.type === 'string') {
|
|
29
|
-
const hasEnum = Array.isArray(s.enum) && s.enum.length > 0;
|
|
30
|
-
const hasConst = s.const !== undefined;
|
|
31
|
-
const hasPattern = typeof s.pattern === 'string';
|
|
32
|
-
const hasAllowedFormat = ALLOWED_STRING_FORMATS.includes(s.format);
|
|
33
|
-
if (!hasEnum && !hasConst && !hasPattern && !hasAllowedFormat) {
|
|
34
|
-
issues.push(`${path || 'root'}: Unconstrained string type. ` +
|
|
35
|
-
`Use enum, const, pattern, or format (${ALLOWED_STRING_FORMATS.join(', ')}) to constrain.`);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
// Recurse into object properties
|
|
39
|
-
if (s.properties && typeof s.properties === 'object') {
|
|
40
|
-
for (const [key, value] of Object.entries(s.properties)) {
|
|
41
|
-
issues.push(...hasUnconstrainedStrings(value, `${path}.${key}`));
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
// Recurse into array items
|
|
45
|
-
if (s.items) {
|
|
46
|
-
issues.push(...hasUnconstrainedStrings(s.items, `${path}[]`));
|
|
47
|
-
}
|
|
48
|
-
// Check additionalProperties
|
|
49
|
-
if (s.additionalProperties && typeof s.additionalProperties === 'object') {
|
|
50
|
-
issues.push(...hasUnconstrainedStrings(s.additionalProperties, `${path}[*]`));
|
|
51
|
-
}
|
|
52
|
-
// Check anyOf, oneOf, allOf
|
|
53
|
-
for (const combinator of ['anyOf', 'oneOf', 'allOf']) {
|
|
54
|
-
if (Array.isArray(s[combinator])) {
|
|
55
|
-
s[combinator].forEach((subSchema, i) => {
|
|
56
|
-
issues.push(...hasUnconstrainedStrings(subSchema, `${path}(${combinator}[${i}])`));
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
return issues;
|
|
61
|
-
}
|
|
10
|
+
import { findUnconstrainedStrings } from '@trikhub/manifest';
|
|
62
11
|
/**
|
|
63
12
|
* Validate a trik at the given path
|
|
64
13
|
*/
|
|
@@ -88,7 +37,7 @@ export function validateTrik(trikPath) {
|
|
|
88
37
|
};
|
|
89
38
|
}
|
|
90
39
|
// 3. Validate required fields
|
|
91
|
-
const requiredFields = ['id', 'name', 'version', 'description', 'entry', 'actions', 'capabilities', 'limits'];
|
|
40
|
+
const requiredFields = ['schemaVersion', 'id', 'name', 'version', 'description', 'entry', 'actions', 'capabilities', 'limits'];
|
|
92
41
|
for (const field of requiredFields) {
|
|
93
42
|
if (!(field in manifest)) {
|
|
94
43
|
errors.push(`Missing required field: ${field}`);
|
|
@@ -124,10 +73,10 @@ export function validateTrik(trikPath) {
|
|
|
124
73
|
errors.push(`Action "${actionName}": Template mode requires agentDataSchema`);
|
|
125
74
|
}
|
|
126
75
|
else {
|
|
127
|
-
// Check for unconstrained strings in agentDataSchema
|
|
128
|
-
const
|
|
129
|
-
for (const
|
|
130
|
-
errors.push(`Action "${actionName}": ${
|
|
76
|
+
// Check for unconstrained strings in agentDataSchema (security check)
|
|
77
|
+
const unconstrained = findUnconstrainedStrings(action.agentDataSchema, `actions.${actionName}.agentDataSchema`);
|
|
78
|
+
for (const path of unconstrained) {
|
|
79
|
+
errors.push(`Action "${actionName}": Unconstrained string at ${path}`);
|
|
131
80
|
}
|
|
132
81
|
}
|
|
133
82
|
if (!action.responseTemplates || Object.keys(action.responseTemplates).length === 0) {
|
|
@@ -146,12 +95,6 @@ export function validateTrik(trikPath) {
|
|
|
146
95
|
if (manifest.limits.maxExecutionTimeMs > 120000) {
|
|
147
96
|
warnings.push('maxExecutionTimeMs is very high (>2min)');
|
|
148
97
|
}
|
|
149
|
-
if (manifest.limits.maxLlmCalls > 50) {
|
|
150
|
-
warnings.push('maxLlmCalls is very high (>50)');
|
|
151
|
-
}
|
|
152
|
-
if (manifest.limits.maxToolCalls > 100) {
|
|
153
|
-
warnings.push('maxToolCalls is very high (>100)');
|
|
154
|
-
}
|
|
155
98
|
}
|
|
156
99
|
return {
|
|
157
100
|
valid: errors.length === 0,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validator.js","sourceRoot":"","sources":["../../src/lib/validator.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"validator.js","sourceRoot":"","sources":["../../src/lib/validator.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,wBAAwB,EAAmB,MAAM,mBAAmB,CAAC;AA2C9E;;GAEG;AACH,MAAM,UAAU,YAAY,CAAC,QAAgB;IAC3C,MAAM,MAAM,GAAa,EAAE,CAAC;IAC5B,MAAM,QAAQ,GAAa,EAAE,CAAC;IAE9B,gCAAgC;IAChC,MAAM,YAAY,GAAG,IAAI,CAAC,QAAQ,EAAE,eAAe,CAAC,CAAC;IACrD,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC,EAAE,CAAC;QAC9B,OAAO;YACL,KAAK,EAAE,KAAK;YACZ,MAAM,EAAE,CAAC,uBAAuB,CAAC;YACjC,QAAQ,EAAE,EAAE;SACb,CAAC;IACJ,CAAC;IAED,oBAAoB;IACpB,IAAI,QAAsB,CAAC;IAC3B,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,YAAY,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;QACpD,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IACjC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO;YACL,KAAK,EAAE,KAAK;YACZ,MAAM,EAAE,CAAC,0BAA0B,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC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C,CAAC;YACrF,CAAC;QACH,CAAC;IACH,CAAC;IAED,qBAAqB;IACrB,IAAI,QAAQ,CAAC,MAAM,EAAE,CAAC;QACpB,IAAI,QAAQ,CAAC,MAAM,CAAC,kBAAkB,GAAG,MAAM,EAAE,CAAC;YAChD,QAAQ,CAAC,IAAI,CAAC,yCAAyC,CAAC,CAAC;QAC3D,CAAC;IACH,CAAC;IAED,OAAO;QACL,KAAK,EAAE,MAAM,CAAC,MAAM,KAAK,CAAC;QAC1B,MAAM;QACN,QAAQ;KACT,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,sBAAsB,CAAC,MAAwB;IAC7D,MAAM,KAAK,GAAa,EAAE,CAAC;IAE3B,IAAI,MAAM,CAAC,KAAK,EAAE,CAAC;QACjB,KAAK,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;IAClC,CAAC;SAAM,CAAC;QACN,KAAK,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;IAClC,CAAC;IAED,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;QAClC,KAAK,CAAC,IAAI,CAAC,aAAa,KAAK,EAAE,CAAC,CAAC;IACnC,CAAC;IAED,KAAK,MAAM,OAAO,IAAI,MAAM,CAAC,QAAQ,EAAE,CAAC;QACtC,KAAK,CAAC,IAAI,CAAC,YAAY,OAAO,EAAE,CAAC,CAAC;IACpC,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trikhub/cli",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.6",
|
|
4
4
|
"description": "CLI for TrikHub - Teaching AI new triks",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"ora": "^8.0.1",
|
|
27
27
|
"semver": "^7.6.3",
|
|
28
28
|
"tar": "^7.4.0",
|
|
29
|
-
"@trikhub/manifest": "0.
|
|
29
|
+
"@trikhub/manifest": "0.9.0"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@types/node": "^20.14.0",
|