@cavelon/cli 0.1.17 → 0.1.18
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/commands/db.js
CHANGED
|
@@ -125,13 +125,14 @@ function lastTest(c) {
|
|
|
125
125
|
return `${c.last_test_outcome ?? "?"} (${c.last_test_at})`;
|
|
126
126
|
}
|
|
127
127
|
const filledBy = (p) => (!p.source || p.source === "model" ? "model" : p.source);
|
|
128
|
+
const typeOf = (p) => (p.list === true ? `list of ${p.type ?? "string"}` : (p.type ?? "string"));
|
|
128
129
|
function parameterRows(parameters) {
|
|
129
130
|
return parameters.map((p) => ({
|
|
130
131
|
name: p.name,
|
|
131
132
|
filled_by: filledBy(p),
|
|
132
|
-
type: p
|
|
133
|
+
type: typeOf(p),
|
|
133
134
|
required: p.required === false ? "no" : "yes",
|
|
134
|
-
constraints: ["max_length", "pattern", "enum", "minimum", "maximum"]
|
|
135
|
+
constraints: ["max_items", "max_length", "pattern", "enum", "minimum", "maximum"]
|
|
135
136
|
.filter((k) => p[k] !== undefined && p[k] !== null)
|
|
136
137
|
.map((k) => `${k} ${JSON.stringify(p[k])}`)
|
|
137
138
|
.join(", ") || null,
|
|
@@ -478,6 +479,31 @@ function typed(parameter, raw) {
|
|
|
478
479
|
}
|
|
479
480
|
return raw;
|
|
480
481
|
}
|
|
482
|
+
function listValue(parameter, raw) {
|
|
483
|
+
const type = parameter.type ?? "string";
|
|
484
|
+
const at = `--value ${parameter.name}`;
|
|
485
|
+
let items;
|
|
486
|
+
try {
|
|
487
|
+
items = JSON.parse(raw);
|
|
488
|
+
}
|
|
489
|
+
catch {
|
|
490
|
+
items = undefined;
|
|
491
|
+
}
|
|
492
|
+
if (!Array.isArray(items)) {
|
|
493
|
+
const example = type === "integer" || type === "number" ? "[4711,4712]" : type === "date" ? '["2026-10-01","2026-10-02"]' : '["A-10023","A-10024"]';
|
|
494
|
+
throw usageError(`${at}: a list parameter takes a JSON array of ${type} values.`, `Give it as ${parameter.name}=${example}, quoted for your shell.`);
|
|
495
|
+
}
|
|
496
|
+
if (!items.length)
|
|
497
|
+
throw usageError(`${at}: must hold at least 1 item.`);
|
|
498
|
+
if (typeof parameter.max_items === "number" && items.length > parameter.max_items)
|
|
499
|
+
throw usageError(`${at}: must hold at most ${parameter.max_items} items.`);
|
|
500
|
+
items.forEach((item, index) => {
|
|
501
|
+
const fits = type === "integer" ? Number.isInteger(item) : type === "number" ? typeof item === "number" && Number.isFinite(item) : typeof item === "string";
|
|
502
|
+
if (!fits)
|
|
503
|
+
throw usageError(`${at}: item ${index + 1} ${item === null ? "is empty" : `is not ${type === "integer" ? "an integer" : type === "number" ? "a number" : type === "date" ? "a date (YYYY-MM-DD) string" : "a string"}`}.`);
|
|
504
|
+
});
|
|
505
|
+
return items;
|
|
506
|
+
}
|
|
481
507
|
function runValues(query, given) {
|
|
482
508
|
const values = {};
|
|
483
509
|
for (const pair of given) {
|
|
@@ -487,9 +513,9 @@ function runValues(query, given) {
|
|
|
487
513
|
const name = pair.slice(0, at);
|
|
488
514
|
const parameter = query.parameters.find((p) => p.name === name);
|
|
489
515
|
if (!parameter) {
|
|
490
|
-
throw usageError(`${query.slug} has no parameter "${name}".`, `Its parameters: ${query.parameters.map((p) => `${p.name} (${filledBy(p)}, ${p
|
|
516
|
+
throw usageError(`${query.slug} has no parameter "${name}".`, `Its parameters: ${query.parameters.map((p) => `${p.name} (${filledBy(p)}, ${typeOf(p)})`).join(", ") || "none"}.`);
|
|
491
517
|
}
|
|
492
|
-
values[name] = typed(parameter, pair.slice(at + 1));
|
|
518
|
+
values[name] = parameter.list === true ? listValue(parameter, pair.slice(at + 1)) : typed(parameter, pair.slice(at + 1));
|
|
493
519
|
}
|
|
494
520
|
return values;
|
|
495
521
|
}
|
|
@@ -499,7 +525,9 @@ export const dbTestRun = {
|
|
|
499
525
|
summary: "Run a saved query once with the values given, identity parameters included; show what the model would see and the rows.",
|
|
500
526
|
description: "Needs the tenant Owner's permission (database_connectors.test); it reads the customer's own data. Give each parameter\n" +
|
|
501
527
|
"with --value name=value, those the platform fills from the signed-in visitor (end_user.*) too: that is how an\n" +
|
|
502
|
-
"identity-scoped query is checked for one customer.
|
|
528
|
+
"identity-scoped query is checked for one customer. A list parameter takes a JSON array (--value 'skus=[\"X-1\",\"X-2\"]'),\n" +
|
|
529
|
+
"one to max_items items of its type; the instance checks each item and names a refused one by position, never its value.\n" +
|
|
530
|
+
"The instance records the run (counts only; a list by its item count) and audits it with your\n" +
|
|
503
531
|
"name. Where the instance publishes the matching needs_a_person_when restriction, the kit refuses an API key on an\n" +
|
|
504
532
|
"end_user.* query before sending (exit 5): a person tests it in the Admin or with their personal access token. Ordinary queries\n" +
|
|
505
533
|
"remain usable with an API key. On an older instance that omits the restriction, the server decides.\n" +
|
|
@@ -517,10 +545,14 @@ export const dbTestRun = {
|
|
|
517
545
|
operations: ["POST /api/v1/database-connectors/queries/{query_id}/test-run"],
|
|
518
546
|
positionals: [{ name: "query", description: "The query's tool slug or id.", required: true }],
|
|
519
547
|
options: {
|
|
520
|
-
value: { type: "string", multiple: true, value: "<name=value>", description: "One parameter's value, typed as the parameter's type." },
|
|
548
|
+
value: { type: "string", multiple: true, value: "<name=value>", description: "One parameter's value, typed as the parameter's type; a list parameter's is a JSON array." },
|
|
521
549
|
rows: { type: "string", value: "<n>", description: `Show at most n rows in the text (default ${ROWS_SHOWN}); --json carries what the instance returned.` },
|
|
522
550
|
},
|
|
523
|
-
examples: [
|
|
551
|
+
examples: [
|
|
552
|
+
"cavelon db test-run order_status --value order_no=A-10023 --value email=ada@example.com",
|
|
553
|
+
"cavelon db test-run stock --value sku=4711 --json",
|
|
554
|
+
`cavelon db test-run stock_of_skus --value 'skus=["X-1","X-2"]'`,
|
|
555
|
+
],
|
|
524
556
|
async run(ctx, input) {
|
|
525
557
|
const query = await resolveQuery(ctx, positional(input, "query"));
|
|
526
558
|
if (query.parameters.some(p => p.source?.startsWith("end_user."))) {
|
package/dist/database-queries.js
CHANGED
|
@@ -47,6 +47,13 @@ export function parameterSchema(schema) {
|
|
|
47
47
|
const parameters = querySchema(schema)?.properties?.parameters;
|
|
48
48
|
return isObject(parameters) ? resolveRef(schema, parameters.items) : undefined;
|
|
49
49
|
}
|
|
50
|
+
export function schemaKnowsLists(schema) {
|
|
51
|
+
const properties = parameterSchema(schema)?.properties;
|
|
52
|
+
return isObject(properties) && "list" in properties;
|
|
53
|
+
}
|
|
54
|
+
export const LIST_ITEM_TYPES = ["string", "integer", "number", "date"];
|
|
55
|
+
export const LIST_MAX_ITEMS_DEFAULT = 20;
|
|
56
|
+
export const CONFIRMATION_LIST_LIMIT = 20;
|
|
50
57
|
export function schemaKnowsWrites(schema) {
|
|
51
58
|
const kind = querySchema(schema)?.properties?.kind;
|
|
52
59
|
return Array.isArray(kind?.enum) && kind.enum.includes("write");
|
|
@@ -73,7 +80,7 @@ const CONSTRAINTS_BY_TYPE = {
|
|
|
73
80
|
const CONSTRAINTS = ["max_length", "pattern", "enum", "minimum", "maximum"];
|
|
74
81
|
const problem = (code, message, at) => ({ code, message, ...(at ? { at } : {}) });
|
|
75
82
|
const isNumber = (v) => typeof v === "number" && Number.isFinite(v);
|
|
76
|
-
function parameterProblems(p, index, defaults) {
|
|
83
|
+
function parameterProblems(p, index, defaults, lists) {
|
|
77
84
|
const name = typeof p.name === "string" ? p.name : `#${index + 1}`;
|
|
78
85
|
const source = p.source ?? defaults.source;
|
|
79
86
|
const type = typeof (p.type ?? defaults.type) === "string" ? String(p.type ?? defaults.type) : "string";
|
|
@@ -81,7 +88,10 @@ function parameterProblems(p, index, defaults) {
|
|
|
81
88
|
const at = `parameters/${index}`;
|
|
82
89
|
const said = (what) => `parameter '${name}': ${what}`;
|
|
83
90
|
const set = CONSTRAINTS.filter((key) => p[key] !== undefined && p[key] !== null);
|
|
91
|
+
const maxItems = p.max_items !== undefined && p.max_items !== null;
|
|
84
92
|
if (typeof source === "string" && source !== defaults.source) {
|
|
93
|
+
if (lists && (p.list === true || maxItems))
|
|
94
|
+
return [problem("parameter_context_list", said(`a context parameter (${source}) binds one value, never a list`), `${at}/${p.list === true ? "list" : "max_items"}`)];
|
|
85
95
|
if (type !== "string")
|
|
86
96
|
return [problem("parameter_context_not_string", said(`a context parameter (${source}) has type string`), `${at}/type`)];
|
|
87
97
|
if (required === false)
|
|
@@ -94,6 +104,20 @@ function parameterProblems(p, index, defaults) {
|
|
|
94
104
|
if (typeof p.description !== "string" || !p.description.trim()) {
|
|
95
105
|
problems.push(problem("parameter_description_missing", said("the model needs a description of what to fill in"), at));
|
|
96
106
|
}
|
|
107
|
+
if (lists && p.list !== true && maxItems) {
|
|
108
|
+
problems.push(problem("parameter_constraint_not_applicable", said("max_items applies to a list only"), `${at}/max_items`));
|
|
109
|
+
return problems;
|
|
110
|
+
}
|
|
111
|
+
if (lists && p.list === true) {
|
|
112
|
+
if (!LIST_ITEM_TYPES.includes(type)) {
|
|
113
|
+
problems.push(problem("parameter_list_type", said(`a list's items are a string, integer, number or date, not ${type}`), `${at}/type`));
|
|
114
|
+
return problems;
|
|
115
|
+
}
|
|
116
|
+
if (required === false) {
|
|
117
|
+
problems.push(problem("parameter_list_optional", said("a list parameter is always required"), `${at}/required`));
|
|
118
|
+
return problems;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
97
121
|
const misplaced = set.filter((key) => !(CONSTRAINTS_BY_TYPE[type] ?? []).includes(key));
|
|
98
122
|
if (misplaced.length) {
|
|
99
123
|
problems.push(problem("parameter_constraint_not_applicable", said(`${misplaced.join(", ")} does not apply to type ${type}`), `${at}/${misplaced[0]}`));
|
|
@@ -127,7 +151,8 @@ export function queryProblems(query, schema) {
|
|
|
127
151
|
const repeated = [...new Set(names.filter((n, i) => names.indexOf(n) !== i))].sort((a, b) => a.localeCompare(b, "en"));
|
|
128
152
|
if (repeated.length)
|
|
129
153
|
problems.push(problem("parameter_names_repeat", `parameter names repeat: ${repeated.join(", ")}`, "parameters"));
|
|
130
|
-
|
|
154
|
+
const lists = schemaKnowsLists(schema);
|
|
155
|
+
parameters.forEach((p, index) => problems.push(...parameterProblems(p, index, defaults, lists)));
|
|
131
156
|
if (typeof query.sql_text === "string" && query.sql_text.trim()) {
|
|
132
157
|
const found = bindNames(query.sql_text);
|
|
133
158
|
const missing = found.filter((n) => !names.includes(n)).sort((a, b) => a.localeCompare(b, "en"));
|
|
@@ -139,6 +164,19 @@ export function queryProblems(query, schema) {
|
|
|
139
164
|
];
|
|
140
165
|
problems.push(problem("bind_mismatch", `The SQL and its parameters disagree; ${parts.join("; ")}.`, "sql_text"));
|
|
141
166
|
}
|
|
167
|
+
const listed = lists ? parameters.filter((p) => p.list === true && (p.source ?? defaults.source) === defaults.source && typeof p.name === "string").map((p) => p.name) : [];
|
|
168
|
+
const dialect = isObject(query.connection) && typeof query.connection.dialect === "string" ? query.connection.dialect : undefined;
|
|
169
|
+
const outside = dialect ? listOutsideIn(query.sql_text, dialect, listed) : undefined;
|
|
170
|
+
if (outside)
|
|
171
|
+
problems.push(problem("list_parameter_outside_in", `The list parameter :${outside} may stand only as IN (:${outside}) or NOT IN (:${outside}).`, "sql_text"));
|
|
172
|
+
}
|
|
173
|
+
const confirmation = querySchema(schema)?.properties?.requires_confirmation;
|
|
174
|
+
if (lists && schemaKnowsWrites(schema) && query.kind === "write" && confirmation && (query.requires_confirmation ?? confirmation.default) === true) {
|
|
175
|
+
parameters.forEach((p, index) => {
|
|
176
|
+
if (p.list !== true || (isNumber(p.max_items) ? p.max_items : LIST_MAX_ITEMS_DEFAULT) <= CONFIRMATION_LIST_LIMIT)
|
|
177
|
+
return;
|
|
178
|
+
problems.push(problem("list_too_long_to_confirm", `The confirmation card shows at most ${CONFIRMATION_LIST_LIMIT} values of a list, so a write that asks the person first takes max_items of at most ${CONFIRMATION_LIST_LIMIT}: ${String(p.name)}.`, `parameters/${index}/max_items`));
|
|
179
|
+
});
|
|
142
180
|
}
|
|
143
181
|
const context = parameters.some((p) => typeof p.source === "string" && p.source !== defaults.source);
|
|
144
182
|
if (query.allows_anonymous === true && context) {
|
|
@@ -166,6 +204,36 @@ function closing(sql, start, quote, backslash) {
|
|
|
166
204
|
}
|
|
167
205
|
return undefined;
|
|
168
206
|
}
|
|
207
|
+
function blockCommentEnd(sql, start, nested) {
|
|
208
|
+
let depth = 0;
|
|
209
|
+
for (let i = start; i < sql.length - 1;) {
|
|
210
|
+
const pair = sql.slice(i, i + 2);
|
|
211
|
+
if (pair === "/*") {
|
|
212
|
+
if (nested || depth === 0)
|
|
213
|
+
depth++;
|
|
214
|
+
i += 2;
|
|
215
|
+
}
|
|
216
|
+
else if (pair === "*/") {
|
|
217
|
+
depth--;
|
|
218
|
+
i += 2;
|
|
219
|
+
if (depth === 0)
|
|
220
|
+
return i;
|
|
221
|
+
}
|
|
222
|
+
else
|
|
223
|
+
i++;
|
|
224
|
+
}
|
|
225
|
+
return undefined;
|
|
226
|
+
}
|
|
227
|
+
function startsLineComment(sql, i, dialect) {
|
|
228
|
+
if (sql.startsWith("--", i))
|
|
229
|
+
return dialect !== "mysql" || i + 2 >= sql.length || /\s/.test(sql[i + 2]);
|
|
230
|
+
return dialect === "mysql" && sql[i] === "#";
|
|
231
|
+
}
|
|
232
|
+
function dollarTagAt(sql, i) {
|
|
233
|
+
const tag = /\$(?:[A-Za-z_][A-Za-z0-9_]*)?\$/y;
|
|
234
|
+
tag.lastIndex = i;
|
|
235
|
+
return tag.exec(sql)?.[0];
|
|
236
|
+
}
|
|
169
237
|
function sqlTokens(sql, dialect) {
|
|
170
238
|
const tokens = [];
|
|
171
239
|
let i = 0;
|
|
@@ -177,20 +245,18 @@ function sqlTokens(sql, dialect) {
|
|
|
177
245
|
}
|
|
178
246
|
let end;
|
|
179
247
|
let kind;
|
|
180
|
-
if (sql
|
|
248
|
+
if (startsLineComment(sql, i, dialect)) {
|
|
181
249
|
const newline = sql.indexOf("\n", i);
|
|
182
250
|
end = newline === -1 ? sql.length : newline;
|
|
183
251
|
kind = "comment";
|
|
184
252
|
}
|
|
185
253
|
else if (sql.startsWith("/*", i)) {
|
|
186
|
-
|
|
187
|
-
if (close === -1)
|
|
188
|
-
return undefined;
|
|
189
|
-
end = close + 2;
|
|
254
|
+
end = blockCommentEnd(sql, i, dialect === "postgresql");
|
|
190
255
|
kind = "comment";
|
|
191
256
|
}
|
|
192
257
|
else if (char === "'") {
|
|
193
|
-
|
|
258
|
+
const escapePrefix = i > 0 && /[eE]/.test(sql[i - 1]) && (i < 2 || !/[\p{L}\p{N}]/u.test(sql[i - 2]));
|
|
259
|
+
end = closing(sql, i, "'", dialect === "mysql" || (dialect === "postgresql" && escapePrefix));
|
|
194
260
|
kind = "string";
|
|
195
261
|
}
|
|
196
262
|
else if (char === '"') {
|
|
@@ -205,6 +271,12 @@ function sqlTokens(sql, dialect) {
|
|
|
205
271
|
end = closing(sql, i, "]", false);
|
|
206
272
|
kind = "identifier";
|
|
207
273
|
}
|
|
274
|
+
else if (char === "$" && dialect === "postgresql" && dollarTagAt(sql, i)) {
|
|
275
|
+
const tag = dollarTagAt(sql, i);
|
|
276
|
+
const close = sql.indexOf(tag, i + tag.length);
|
|
277
|
+
end = close === -1 ? undefined : close + tag.length;
|
|
278
|
+
kind = "string";
|
|
279
|
+
}
|
|
208
280
|
else if (WORD_START.test(char)) {
|
|
209
281
|
end = i + 1;
|
|
210
282
|
while (end < sql.length && WORD_PART.test(sql[end]))
|
|
@@ -304,6 +376,27 @@ export function isProcedureCall(sql, dialect) {
|
|
|
304
376
|
const code = sqlTokens(sql, dialect)?.filter((t) => t.kind !== "comment");
|
|
305
377
|
return isWord(code?.find((t) => !isSymbol(t, "(")), "EXEC", "EXECUTE");
|
|
306
378
|
}
|
|
379
|
+
export function listOutsideIn(sql, dialect, listNames) {
|
|
380
|
+
if (!listNames.length)
|
|
381
|
+
return undefined;
|
|
382
|
+
const tokens = sqlTokens(sql, dialect);
|
|
383
|
+
if (!tokens)
|
|
384
|
+
return undefined;
|
|
385
|
+
const code = tokens.filter((t) => t.kind !== "comment");
|
|
386
|
+
const byStart = new Map(code.map((token, index) => [token.start, index]));
|
|
387
|
+
for (const match of sql.matchAll(BIND)) {
|
|
388
|
+
const name = match[1];
|
|
389
|
+
if (!listNames.includes(name))
|
|
390
|
+
continue;
|
|
391
|
+
const index = byStart.get(match.index);
|
|
392
|
+
if (index === undefined)
|
|
393
|
+
continue;
|
|
394
|
+
const placed = index >= 2 && isWord(code[index - 2], "IN") && isSymbol(code[index - 1], "(") && code[index + 1]?.kind === "word" && code[index + 1].text === name && isSymbol(code[index + 2], ")");
|
|
395
|
+
if (!placed)
|
|
396
|
+
return name;
|
|
397
|
+
}
|
|
398
|
+
return undefined;
|
|
399
|
+
}
|
|
307
400
|
function settledTool(schema, tool) {
|
|
308
401
|
const settled = settledForm(schema, schema.properties?.[TOOLS_SECTION], [tool]);
|
|
309
402
|
return Array.isArray(settled) && isObject(settled[0]) ? settled[0] : tool;
|
|
@@ -398,6 +398,15 @@ says who does what on the instance.
|
|
|
398
398
|
postal code) rather than one guessable key. Each `:name` in the SQL needs
|
|
399
399
|
exactly one parameter of that name (a literal colon is `\:`); validate checks
|
|
400
400
|
this (`bind_mismatch`) and each parameter's type and constraints.
|
|
401
|
+
- **List parameters.** Where the instance's schema publishes `list` on a
|
|
402
|
+
parameter, `list: true` lets the model give one to `max_items` values
|
|
403
|
+
(20 when left out, at most 100) for `IN (:name)` or `NOT IN (:name)`, and
|
|
404
|
+
nowhere else in the SQL (`list_parameter_outside_in`). Only a required,
|
|
405
|
+
model-filled string, integer, number or date may be a list
|
|
406
|
+
(`parameter_list_optional`, `parameter_list_type`, `parameter_context_list`);
|
|
407
|
+
its constraints apply to each item. A write query that asks the person
|
|
408
|
+
first takes `max_items` of at most 20, what the confirmation card shows
|
|
409
|
+
(`list_too_long_to_confirm`). `cavelon validate` checks all of these.
|
|
401
410
|
- **Read stored procedures (SQL Server only).** On an `mssql` connection the SQL
|
|
402
411
|
may instead be exactly one call, `EXEC [schema].[procedure] @p1 = :p1, @p2 =
|
|
403
412
|
:p2`: every argument a placeholder with a declared parameter, no literal,
|
|
@@ -464,7 +473,9 @@ payload is the query's arguments: only the model-sourced parameter names.
|
|
|
464
473
|
Map workflow data with a Transform before the node; there is no per-node
|
|
465
474
|
JSONPath argument mapping. Never include an identity parameter (such as
|
|
466
475
|
`email`) or an unknown name: the call answers `invalid_arguments` and runs
|
|
467
|
-
nothing.
|
|
476
|
+
nothing. A list parameter takes a JSON array; declare it in `input_schema` as
|
|
477
|
+
`type: array`, which `cavelon validate` checks. `config_overrides` do not
|
|
478
|
+
apply to a query node.
|
|
468
479
|
|
|
469
480
|
For `order_status` above, add this fragment to
|
|
470
481
|
`package/registry_entities.yaml`, connect the workflow's entry to
|
|
@@ -177,7 +177,8 @@ the Admin. Then:
|
|
|
177
177
|
follow the command's actionable refusal and ask its operator for support.
|
|
178
178
|
- To check what an identity-scoped query returns for one customer, the tenant
|
|
179
179
|
Owner runs it once with `cavelon db test-run <query> --value <name>=<value>`,
|
|
180
|
-
identity parameters included; it shows what the model would see.
|
|
180
|
+
identity parameters included; it shows what the model would see. A list
|
|
181
|
+
parameter's value is a JSON array: `--value 'skus=["X-1","X-2"]'`. Never put
|
|
181
182
|
a real customer's data into a test file.
|
|
182
183
|
- A read stored-procedure query (SQL Server) is test-run the same way; the
|
|
183
184
|
instance refuses the run while the connection's login can write or the
|
package/dist/workflow-queries.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { parameterSchema, QUERY_TOOL_TYPE, querySchema, queryTools, schemaKnowsQueries, schemaKnowsWrites } from "./database-queries.js";
|
|
1
|
+
import { parameterSchema, QUERY_TOOL_TYPE, querySchema, queryTools, schemaKnowsLists, schemaKnowsQueries, schemaKnowsWrites } from "./database-queries.js";
|
|
2
2
|
import { locate } from "./package-files.js";
|
|
3
3
|
export const WORKFLOW_QUERY_MISSING_CODE = "tool_call_database_query_missing";
|
|
4
4
|
const object = (value) => value && typeof value === "object" && !Array.isArray(value) ? value : undefined;
|
|
@@ -116,6 +116,21 @@ function argumentNames(pkg, query) {
|
|
|
116
116
|
});
|
|
117
117
|
return found;
|
|
118
118
|
}
|
|
119
|
+
function shapeMismatch(query, parameters, source) {
|
|
120
|
+
const properties = object(object(query.config.input_schema)?.properties) ?? {};
|
|
121
|
+
const at = `/registry_entities/orchestration_nodes/${query.index}/config/input_schema/properties`;
|
|
122
|
+
return parameters.flatMap((parameter) => {
|
|
123
|
+
if ((parameter.source ?? source) !== source || typeof parameter.name !== "string" || !Object.hasOwn(properties, parameter.name))
|
|
124
|
+
return [];
|
|
125
|
+
const type = object(properties[parameter.name])?.type;
|
|
126
|
+
const declared = typeof type === "string" ? [type] : Array.isArray(type) ? type.filter((t) => typeof t === "string") : [];
|
|
127
|
+
if (!declared.length)
|
|
128
|
+
return [];
|
|
129
|
+
const list = parameter.list === true;
|
|
130
|
+
const carries = list ? declared.includes("array") : declared.some((t) => t !== "array");
|
|
131
|
+
return carries ? [] : [{ name: parameter.name, list, declared, pointer: `${at}/${pointerKey(parameter.name)}/type` }];
|
|
132
|
+
});
|
|
133
|
+
}
|
|
119
134
|
export function checkWorkflowQueries(disk, schema, inventory, baseline) {
|
|
120
135
|
if (!schemaRunsQueryNodes(schema) || disk.unreadable?.includes("tools"))
|
|
121
136
|
return [];
|
|
@@ -152,6 +167,13 @@ export function checkWorkflowQueries(disk, schema, inventory, baseline) {
|
|
|
152
167
|
hint: "Use a Transform before the query node to emit only its model-sourced parameter names. Identity parameters come from the signed-in Chat User, never workflow data; the query's parameters decide the accepted arguments, not input_schema.",
|
|
153
168
|
});
|
|
154
169
|
}
|
|
170
|
+
for (const mismatch of schemaKnowsLists(schema) ? shapeMismatch(queryNode, parameters, source) : []) {
|
|
171
|
+
findings.push({
|
|
172
|
+
code: "invalid_arguments", severity: "error", ...locate(disk, mismatch.pointer),
|
|
173
|
+
message: `Tool Call node "${String(node.slug ?? index)}" declares "${mismatch.name}" in its input_schema as ${mismatch.declared.join(" or ")}, but query "${slug}" takes ${mismatch.list ? "a list there: a JSON array" : "a single value there, never an array"}; the payload cannot satisfy both, so the call answers invalid_arguments or fails the input_schema and runs nothing.`,
|
|
174
|
+
hint: mismatch.list ? `Declare it as {"type": "array", "items": {…}} and pass the values as a JSON array of one to max_items items.` : "Declare the property with the parameter's own type, or make the query's parameter a list (list: true) used as IN (:name).",
|
|
175
|
+
});
|
|
176
|
+
}
|
|
155
177
|
if ((identity.size || query.allows_anonymous !== true) && triggerReaches(disk.package, queryNode)) {
|
|
156
178
|
findings.push({ code: "identity_required", severity: "warning", ...locate(disk, at), message: `Tool Call node "${String(node.slug ?? index)}" runs query "${slug}" in a workflow a trigger starts: the run has no signed-in Chat User, so ${identity.size ? "its identity parameters cannot be filled" : "the query does not allow anonymous calls"} and the call answers identity_required.`, hint: "Use this query in a conversation-bound run with a signed-in Chat User. A trigger can run a public-data query only when it has no identity parameters and allows_anonymous is true; a trigger execution identity is not a Chat User." });
|
|
157
179
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cavelon/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.18",
|
|
4
4
|
"description": "The cavelon binary: CLI and local MCP server for building Cavelon solutions with a coding agent.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"homepage": "https://github.com/goodguys-gmbh/cavelon-dev-kit",
|