@cavelon/cli 0.1.17 → 0.2.0
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/commands/db-connections.js +13 -3
- package/dist/commands/db.js +39 -7
- package/dist/commands/init.js +2 -2
- package/dist/commands/setup.js +1 -1
- package/dist/database-queries.js +178 -8
- package/dist/mcp-command.js +13 -3
- package/dist/mcp-entry.js +8 -2
- package/dist/native-assets/manifest.json +1 -1
- package/dist/setup-agents.js +2 -4
- package/dist/skills/cavelon-authoring/SKILL.md +25 -3
- package/dist/skills/cavelon-loop/SKILL.md +3 -2
- package/dist/skills/cavelon-testing/SKILL.md +7 -1
- package/dist/workflow-queries.js +23 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -213,10 +213,12 @@ export const dbLoginScript = {
|
|
|
213
213
|
name: "db login-script", summary: "Print the instance's published read-only login SQL for a dialect or saved connection; no database is contacted.",
|
|
214
214
|
description: "Needs database_connectors.view. The DBA replaces the script's password placeholder locally, outside the kit.\n" +
|
|
215
215
|
"Only variants this instance publishes are offered; this build publishes read_only. Omitted inputs use its defaults.\n" +
|
|
216
|
-
"For SQL Server, connection_limit_enforced is false; --schema scopes SELECT instead of granting db_datareader
|
|
216
|
+
"For SQL Server, connection_limit_enforced is false; --schema scopes SELECT instead of granting db_datareader.\n" +
|
|
217
|
+
"For Oracle, --schema names the one schema READ covers (omitted: the placeholder YOUR_SCHEMA); a profile sets the limit.",
|
|
217
218
|
readOnly: true, idempotent: true, mcpTool: "db_login_script", operations: ["GET /api/v1/database-connectors/login-script", `GET ${CONNECTION}/login-script`],
|
|
218
219
|
positionals: [{ name: "dialect", description: "Database dialect; omit only with --connection." }],
|
|
219
220
|
options: {
|
|
221
|
+
dialect: { ...textOption("Database dialect, as the dialect argument; give one of the two.", "<dialect>"), cliOnly: true },
|
|
220
222
|
connection: textOption("Use dialect, database, user and TLS from this saved connection (name or id).", "<connection>"),
|
|
221
223
|
"database-name": textOption("Database the login may read (without --connection).", "<name>"),
|
|
222
224
|
username: textOption("Database login name (without --connection).", "<name>"),
|
|
@@ -225,9 +227,17 @@ export const dbLoginScript = {
|
|
|
225
227
|
"connection-limit": textOption("Connections to allow; omitted uses the instance's pool size times four.", "<n>"),
|
|
226
228
|
"require-tls": textOption("MySQL REQUIRE SSL (true or false, without --connection).", "<true|false>"),
|
|
227
229
|
},
|
|
228
|
-
examples: [
|
|
230
|
+
examples: [
|
|
231
|
+
"cavelon db login-script postgresql --database-name shop --username cavelon_reader",
|
|
232
|
+
"cavelon db login-script --dialect oracle --database-name SHOPPDB --username cavelon_ro --schema SHOP",
|
|
233
|
+
"cavelon db login-script --connection shop-db --schema public",
|
|
234
|
+
],
|
|
229
235
|
async run(ctx, input) {
|
|
230
|
-
const
|
|
236
|
+
const argument = positional(input, "dialect");
|
|
237
|
+
const option = stringOption(input, "dialect");
|
|
238
|
+
if (argument !== undefined && option !== undefined)
|
|
239
|
+
throw usageError("Give the dialect once: as the argument or with --dialect, not both.");
|
|
240
|
+
const dialect = argument ?? option;
|
|
231
241
|
const connectionRef = stringOption(input, "connection");
|
|
232
242
|
if (Boolean(dialect) === Boolean(connectionRef))
|
|
233
243
|
throw usageError("Give a dialect or --connection, exactly one.");
|
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/commands/init.js
CHANGED
|
@@ -6,7 +6,7 @@ import { AGENTS, bundledSkills, generatedCopy, parseAgents, KNOWN_SKILL_ROOTS, s
|
|
|
6
6
|
import { nativeClient, resolveNativeMcp, hasNativeApprovalAdapter } from "../native-clients.js";
|
|
7
7
|
import { applyNativeInstallation, planNativeInstallation } from "../native-install.js";
|
|
8
8
|
import { serverCommand } from "../setup-agents.js";
|
|
9
|
-
import { encodeMcpEntry, isKitMcpEntry } from "../mcp-entry.js";
|
|
9
|
+
import { encodeMcpEntry, isCurrentMcpEntry, isKitMcpEntry } from "../mcp-entry.js";
|
|
10
10
|
import { upsertJsoncEntry } from "../jsonc-config.js";
|
|
11
11
|
import { CavelonError, ExitCode, usageError } from "../errors.js";
|
|
12
12
|
import { confinedPath, realPath, within } from "../paths.js";
|
|
@@ -204,7 +204,7 @@ async function writeMcp(root, target, onlyExisting, env) {
|
|
|
204
204
|
const selected = await resolveNativeMcp(config, root);
|
|
205
205
|
if ("error" in selected)
|
|
206
206
|
return { file: rel(root, selected.file), action: "skipped", reason: selected.error };
|
|
207
|
-
if (selected.current !== undefined &&
|
|
207
|
+
if (selected.current !== undefined && isCurrentMcpEntry(selected.current, config.entryFormat, config.extra))
|
|
208
208
|
return { file: rel(root, selected.file), action: "unchanged" };
|
|
209
209
|
const value = encodeMcpEntry(await serverCommand(env), config.entryFormat, config.extra);
|
|
210
210
|
return applyBlock(root, selected.file, upsertJsoncEntry(selected.text, config.keys, value, { onlyExisting, matches: current => isKitMcpEntry(current, config.entryFormat, config.extra) }));
|
package/dist/commands/setup.js
CHANGED
|
@@ -431,7 +431,7 @@ export const setup = {
|
|
|
431
431
|
type: "string",
|
|
432
432
|
value: "<list>",
|
|
433
433
|
multiple: true,
|
|
434
|
-
description: "Only these agents: claude, codex, cursor, copilot, gemini, kiro, opencode, pi, qwen, cline, kilo, or all (comma-separated). Default: every agent found.",
|
|
434
|
+
description: "Only these agents: claude, codex, cursor, copilot, gemini, kiro, opencode, pi, qwen, cline, kilo, goose, omp, or all (comma-separated). Default: every agent found.",
|
|
435
435
|
},
|
|
436
436
|
yes: { type: "boolean", short: "y", description: "Make the changes without asking." },
|
|
437
437
|
check: { type: "boolean", description: "Report what is set up and working; change nothing." },
|
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,53 @@ 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
|
+
const ORACLE_DIALECT = "oracle";
|
|
233
|
+
const ORACLE_Q_CLOSERS = { "[": "]", "{": "}", "(": ")", "<": ">" };
|
|
234
|
+
function oracleQuoteAt(sql, i) {
|
|
235
|
+
const prefix = /[nN]?[qQ]'/y;
|
|
236
|
+
prefix.lastIndex = i;
|
|
237
|
+
const match = prefix.exec(sql);
|
|
238
|
+
if (!match || (i > 0 && /[\p{L}\p{N}_$#]/u.test(sql[i - 1])))
|
|
239
|
+
return 0;
|
|
240
|
+
return match[0].length;
|
|
241
|
+
}
|
|
242
|
+
function oracleQuoteEnd(sql, start) {
|
|
243
|
+
if (start >= sql.length || /\s/.test(sql[start]))
|
|
244
|
+
return undefined;
|
|
245
|
+
const closer = `${ORACLE_Q_CLOSERS[sql[start]] ?? sql[start]}'`;
|
|
246
|
+
const end = sql.indexOf(closer, start + 1);
|
|
247
|
+
return end === -1 ? undefined : end + closer.length;
|
|
248
|
+
}
|
|
249
|
+
function dollarTagAt(sql, i) {
|
|
250
|
+
const tag = /\$(?:[A-Za-z_][A-Za-z0-9_]*)?\$/y;
|
|
251
|
+
tag.lastIndex = i;
|
|
252
|
+
return tag.exec(sql)?.[0];
|
|
253
|
+
}
|
|
169
254
|
function sqlTokens(sql, dialect) {
|
|
170
255
|
const tokens = [];
|
|
171
256
|
let i = 0;
|
|
@@ -177,20 +262,22 @@ function sqlTokens(sql, dialect) {
|
|
|
177
262
|
}
|
|
178
263
|
let end;
|
|
179
264
|
let kind;
|
|
180
|
-
if (sql
|
|
265
|
+
if (startsLineComment(sql, i, dialect)) {
|
|
181
266
|
const newline = sql.indexOf("\n", i);
|
|
182
267
|
end = newline === -1 ? sql.length : newline;
|
|
183
268
|
kind = "comment";
|
|
184
269
|
}
|
|
185
270
|
else if (sql.startsWith("/*", i)) {
|
|
186
|
-
|
|
187
|
-
if (close === -1)
|
|
188
|
-
return undefined;
|
|
189
|
-
end = close + 2;
|
|
271
|
+
end = blockCommentEnd(sql, i, dialect === "postgresql");
|
|
190
272
|
kind = "comment";
|
|
191
273
|
}
|
|
274
|
+
else if (dialect === ORACLE_DIALECT && oracleQuoteAt(sql, i)) {
|
|
275
|
+
end = oracleQuoteEnd(sql, i + oracleQuoteAt(sql, i));
|
|
276
|
+
kind = "string";
|
|
277
|
+
}
|
|
192
278
|
else if (char === "'") {
|
|
193
|
-
|
|
279
|
+
const escapePrefix = i > 0 && /[eE]/.test(sql[i - 1]) && (i < 2 || !/[\p{L}\p{N}]/u.test(sql[i - 2]));
|
|
280
|
+
end = closing(sql, i, "'", dialect === "mysql" || (dialect === "postgresql" && escapePrefix));
|
|
194
281
|
kind = "string";
|
|
195
282
|
}
|
|
196
283
|
else if (char === '"') {
|
|
@@ -205,6 +292,12 @@ function sqlTokens(sql, dialect) {
|
|
|
205
292
|
end = closing(sql, i, "]", false);
|
|
206
293
|
kind = "identifier";
|
|
207
294
|
}
|
|
295
|
+
else if (char === "$" && dialect === "postgresql" && dollarTagAt(sql, i)) {
|
|
296
|
+
const tag = dollarTagAt(sql, i);
|
|
297
|
+
const close = sql.indexOf(tag, i + tag.length);
|
|
298
|
+
end = close === -1 ? undefined : close + tag.length;
|
|
299
|
+
kind = "string";
|
|
300
|
+
}
|
|
208
301
|
else if (WORD_START.test(char)) {
|
|
209
302
|
end = i + 1;
|
|
210
303
|
while (end < sql.length && WORD_PART.test(sql[end]))
|
|
@@ -304,6 +397,74 @@ export function isProcedureCall(sql, dialect) {
|
|
|
304
397
|
const code = sqlTokens(sql, dialect)?.filter((t) => t.kind !== "comment");
|
|
305
398
|
return isWord(code?.find((t) => !isSymbol(t, "(")), "EXEC", "EXECUTE");
|
|
306
399
|
}
|
|
400
|
+
const READ_FORBIDDEN_WORDS = [
|
|
401
|
+
"INSERT", "UPDATE", "DELETE", "MERGE", "UPSERT", "INTO", "TRUNCATE", "DROP", "ALTER", "CREATE", "GRANT", "REVOKE", "COPY", "CALL", "EXEC", "EXECUTE",
|
|
402
|
+
"UPDLOCK", "XLOCK", "HOLDLOCK", "TABLOCKX",
|
|
403
|
+
];
|
|
404
|
+
const LOCKING_AFTER_FOR = ["SHARE", "KEY", "NO", "UPDATE"];
|
|
405
|
+
const ORACLE_FORBIDDEN_WORDS = ["BEGIN", "DECLARE", "FUNCTION", "PROCEDURE", "PACKAGE", "PRAGMA", "COMMIT", "ROLLBACK", "SAVEPOINT", "HTTPURITYPE", "DBURITYPE", "XDBURITYPE"];
|
|
406
|
+
const ORACLE_FORBIDDEN_PREFIXES = ["DBMS_", "UTL_"];
|
|
407
|
+
function commonReadRefusal(code) {
|
|
408
|
+
return code.some((token, i) => {
|
|
409
|
+
if (token.kind !== "word")
|
|
410
|
+
return false;
|
|
411
|
+
const word = token.text.toUpperCase();
|
|
412
|
+
const next = code[i + 1];
|
|
413
|
+
return READ_FORBIDDEN_WORDS.includes(word) || (word === "FOR" && next?.kind === "word" && LOCKING_AFTER_FOR.includes(next.text.toUpperCase())) || (word === "LOCK" && isWord(next, "IN"));
|
|
414
|
+
});
|
|
415
|
+
}
|
|
416
|
+
export function oracleQueryProblem(sql, dialect, write) {
|
|
417
|
+
if (dialect !== ORACLE_DIALECT)
|
|
418
|
+
return undefined;
|
|
419
|
+
const tokens = sqlTokens(sql, dialect);
|
|
420
|
+
if (!tokens || tokens.some((t) => t.kind === "comment" && /^\/\*M?!/.test(t.text)))
|
|
421
|
+
return undefined;
|
|
422
|
+
const code = tokens.filter((t) => t.kind !== "comment");
|
|
423
|
+
if (code.some((t, i) => t.kind === "semicolon" && i !== code.length - 1))
|
|
424
|
+
return undefined;
|
|
425
|
+
if (write ? !isWord(code[0], "INSERT", "UPDATE", "DELETE") : !isWord(code.find((t) => !isSymbol(t, "(")), "SELECT", "WITH") || commonReadRefusal(code))
|
|
426
|
+
return undefined;
|
|
427
|
+
const refused = (message) => problem(write ? "write_statement_refused" : "forbidden_keyword", message, "sql_text");
|
|
428
|
+
for (const token of code) {
|
|
429
|
+
if (isSymbol(token, "@"))
|
|
430
|
+
return refused("The SQL may not reach another database: a database link (table@link) is not allowed.");
|
|
431
|
+
const name = token.kind === "word" ? token.text.toUpperCase() : token.kind === "identifier" ? token.text.slice(1, -1).replaceAll('""', '"').toUpperCase() : undefined;
|
|
432
|
+
if (name === undefined)
|
|
433
|
+
continue;
|
|
434
|
+
if (ORACLE_FORBIDDEN_WORDS.includes(name))
|
|
435
|
+
return refused(write ? `A write query may not hold ${name}.` : `The SQL may only read: ${name} is not allowed on Oracle.`);
|
|
436
|
+
if (ORACLE_FORBIDDEN_PREFIXES.some((prefix) => name.startsWith(prefix))) {
|
|
437
|
+
return refused(write
|
|
438
|
+
? `A write query may not call ${token.text}: Oracle's supplied packages are refused.`
|
|
439
|
+
: `The SQL may not call ${token.text}: Oracle's DBMS_* and UTL_* packages reach the network, files or dynamic SQL.`);
|
|
440
|
+
}
|
|
441
|
+
if (write && (name === "RETURNING" || name === "RETURN")) {
|
|
442
|
+
return refused("On Oracle a write query may not hold RETURNING: its INTO needs output binds, which a write query does not have. Read the changed rows with a separate read query.");
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
return undefined;
|
|
446
|
+
}
|
|
447
|
+
export function listOutsideIn(sql, dialect, listNames) {
|
|
448
|
+
if (!listNames.length)
|
|
449
|
+
return undefined;
|
|
450
|
+
const tokens = sqlTokens(sql, dialect);
|
|
451
|
+
if (!tokens)
|
|
452
|
+
return undefined;
|
|
453
|
+
const code = tokens.filter((t) => t.kind !== "comment");
|
|
454
|
+
const byStart = new Map(code.map((token, index) => [token.start, index]));
|
|
455
|
+
for (const match of sql.matchAll(BIND)) {
|
|
456
|
+
const name = match[1];
|
|
457
|
+
if (!listNames.includes(name))
|
|
458
|
+
continue;
|
|
459
|
+
const index = byStart.get(match.index);
|
|
460
|
+
if (index === undefined)
|
|
461
|
+
continue;
|
|
462
|
+
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], ")");
|
|
463
|
+
if (!placed)
|
|
464
|
+
return name;
|
|
465
|
+
}
|
|
466
|
+
return undefined;
|
|
467
|
+
}
|
|
307
468
|
function settledTool(schema, tool) {
|
|
308
469
|
const settled = settledForm(schema, schema.properties?.[TOOLS_SECTION], [tool]);
|
|
309
470
|
return Array.isArray(settled) && isObject(settled[0]) ? settled[0] : tool;
|
|
@@ -384,6 +545,15 @@ export function checkQueryTools(disk, schema, baseline, connections) {
|
|
|
384
545
|
message: `Query tool "${slug}": ${call.message}`,
|
|
385
546
|
});
|
|
386
547
|
}
|
|
548
|
+
const oracle = typeof query.sql_text === "string" ? oracleQueryProblem(query.sql_text, dialect, write) : undefined;
|
|
549
|
+
if (oracle) {
|
|
550
|
+
findings.push({
|
|
551
|
+
code: oracle.code,
|
|
552
|
+
severity: "warning",
|
|
553
|
+
...locate(disk, `/${TOOLS_SECTION}/${index}/${QUERY_FIELD}/${oracle.at}`),
|
|
554
|
+
message: `Query tool "${slug}": ${oracle.message} The instance refuses it when the query is saved (${oracle.code}).`,
|
|
555
|
+
});
|
|
556
|
+
}
|
|
387
557
|
const connection = isObject(query.connection) ? query.connection : undefined;
|
|
388
558
|
if (write && connections?.some(c => c.name === connection?.name && c.dialect === dialect && c.allows_writes === false)) {
|
|
389
559
|
findings.push({
|
package/dist/mcp-command.js
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
|
-
|
|
1
|
+
const RELEASE_LINE = "0.2";
|
|
2
|
+
export const EARLIER_RELEASE_LINES = ["0.1"];
|
|
3
|
+
const npx = (line) => ({ command: "npx", args: ["-y", `@cavelon/cli@${line}`, "mcp"] });
|
|
4
|
+
export const MCP_COMMAND = npx(RELEASE_LINE);
|
|
2
5
|
export const INSTALLED_MCP_COMMAND = { command: "cavelon", args: ["mcp"] };
|
|
3
|
-
export function mcpCommand(platform = process.platform) {
|
|
4
|
-
|
|
6
|
+
export function mcpCommand(platform = process.platform, line = RELEASE_LINE) {
|
|
7
|
+
const command = line === RELEASE_LINE ? MCP_COMMAND : npx(line);
|
|
8
|
+
return platform === "win32" ? { command: "cmd", args: ["/c", command.command, ...command.args] } : command;
|
|
9
|
+
}
|
|
10
|
+
export function currentMcpCommands() {
|
|
11
|
+
return [INSTALLED_MCP_COMMAND, mcpCommand("linux"), mcpCommand("win32")];
|
|
12
|
+
}
|
|
13
|
+
export function kitMcpCommands() {
|
|
14
|
+
return [...currentMcpCommands(), ...EARLIER_RELEASE_LINES.flatMap(line => [mcpCommand("linux", line), mcpCommand("win32", line)])];
|
|
5
15
|
}
|
package/dist/mcp-entry.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { isDeepStrictEqual } from "node:util";
|
|
2
|
-
import {
|
|
2
|
+
import { currentMcpCommands, kitMcpCommands } from "./mcp-command.js";
|
|
3
3
|
export function encodeMcpEntry(command, format, extra = {}) {
|
|
4
4
|
return format === "command-array" ? { ...extra, command: [command.command, ...command.args] } : { ...extra, [format === "goose-stdio" ? "cmd" : "command"]: command.command, args: command.args };
|
|
5
5
|
}
|
|
@@ -15,7 +15,13 @@ export function decodeMcpEntry(value, format) {
|
|
|
15
15
|
return { command: words[0], args: words.slice(1) };
|
|
16
16
|
}
|
|
17
17
|
export function isKitMcpEntry(value, format, extra = {}) {
|
|
18
|
+
return matchesAny(kitMcpCommands(), value, format, extra);
|
|
19
|
+
}
|
|
20
|
+
export function isCurrentMcpEntry(value, format, extra = {}) {
|
|
21
|
+
return matchesAny(currentMcpCommands(), value, format, extra);
|
|
22
|
+
}
|
|
23
|
+
function matchesAny(commands, value, format, extra) {
|
|
18
24
|
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
19
25
|
return false;
|
|
20
|
-
return
|
|
26
|
+
return commands.some(command => isDeepStrictEqual(encodeMcpEntry(command, format, extra), value));
|
|
21
27
|
}
|
package/dist/setup-agents.js
CHANGED
|
@@ -9,6 +9,7 @@ import { runProgram } from "./run-program.js";
|
|
|
9
9
|
import { KIT_VERSION } from "./version.js";
|
|
10
10
|
import { NATIVE_CLIENTS, nativeClient, hasNativeApprovalAdapter, readNativeMcp, resolveNativeMcp } from "./native-clients.js";
|
|
11
11
|
import { decodeMcpEntry, encodeMcpEntry, isKitMcpEntry } from "./mcp-entry.js";
|
|
12
|
+
import { kitMcpCommands } from "./mcp-command.js";
|
|
12
13
|
import { removeJsoncEntry, upsertJsoncEntry } from "./jsonc-config.js";
|
|
13
14
|
import { removeYamlEntry, upsertYamlEntry } from "./yaml-config.js";
|
|
14
15
|
import { applyNativeInstallation, checkNativeInstallation, planNativeInstallation, removeNativeInstallation } from "./native-install.js";
|
|
@@ -117,14 +118,11 @@ async function isDirectory(dir) {
|
|
|
117
118
|
export async function serverCommand(env, platform = process.platform) {
|
|
118
119
|
return (await findProgram("cavelon", env, platform, [".exe"])) ? INSTALLED_MCP_COMMAND : mcpCommand(platform);
|
|
119
120
|
}
|
|
120
|
-
function knownCommands() {
|
|
121
|
-
return [INSTALLED_MCP_COMMAND, mcpCommand("linux"), mcpCommand("win32")];
|
|
122
|
-
}
|
|
123
121
|
function jsonEntry(mcp, command) {
|
|
124
122
|
return { ...mcp.extra, command: command.command, args: command.args };
|
|
125
123
|
}
|
|
126
124
|
function isOwnJsonEntry(mcp, value) {
|
|
127
|
-
return
|
|
125
|
+
return kitMcpCommands().some((c) => JSON.stringify(jsonEntry(mcp, c)) === JSON.stringify(value));
|
|
128
126
|
}
|
|
129
127
|
function tomlBlock(command) {
|
|
130
128
|
return ["[mcp_servers.cavelon]", `command = ${JSON.stringify(command.command)}`, `args = [${command.args.map((a) => JSON.stringify(a)).join(", ")}]`].join("\n");
|
|
@@ -340,7 +340,7 @@ says who does what on the instance.
|
|
|
340
340
|
tool_type: database_query
|
|
341
341
|
scope: tenant_local
|
|
342
342
|
database_query:
|
|
343
|
-
connection: { name: shop-db, dialect: postgresql } # by name only: never a host, user or password; postgresql, mysql or
|
|
343
|
+
connection: { name: shop-db, dialect: postgresql } # by name only: never a host, user or password; postgresql, mysql, mssql or oracle
|
|
344
344
|
sql_text: SELECT number, status, shipped_at FROM orders WHERE number = :order_no AND email = :email LIMIT 5
|
|
345
345
|
parameters:
|
|
346
346
|
- name: order_no
|
|
@@ -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,
|
|
@@ -410,6 +419,16 @@ says who does what on the instance.
|
|
|
410
419
|
reads (`procedure_definition_unreadable`, `procedure_definition_writes`):
|
|
411
420
|
ask the person for a read-only login with `EXECUTE` and `VIEW DEFINITION`
|
|
412
421
|
on procedures that read. Where a procedure is not needed, write a `SELECT`.
|
|
422
|
+
- **Oracle.** On an `oracle` connection the instance also refuses PL/SQL
|
|
423
|
+
(`BEGIN`, `DECLARE`, `WITH FUNCTION`), transaction control, `DBMS_*` and
|
|
424
|
+
`UTL_*` packages, `HTTPURITYPE` and database links (`table@link`):
|
|
425
|
+
`forbidden_keyword` in a read, `write_statement_refused` in a write, which
|
|
426
|
+
also may not hold `RETURNING`. Text in `q'[…]'` literals, strings and
|
|
427
|
+
comments is not SQL, and one trailing semicolon is accepted. Bound rows with
|
|
428
|
+
`FETCH FIRST n ROWS ONLY`. `cavelon validate` warns of these in one
|
|
429
|
+
`SELECT`/`WITH` read or `INSERT`/`UPDATE`/`DELETE` write; a PL/SQL block,
|
|
430
|
+
another first keyword or several statements get no local warning, and the
|
|
431
|
+
instance refuses them when it saves the query.
|
|
413
432
|
- `cavelon explain <code>` explains every code the connector uses: what
|
|
414
433
|
`validate` and the preview name, the codes of a failed call (`timeout`,
|
|
415
434
|
`identity_required`, …) and of a connection test.
|
|
@@ -432,7 +451,8 @@ parameters and replace the SQL and write settings with:
|
|
|
432
451
|
```
|
|
433
452
|
|
|
434
453
|
One `INSERT`, `UPDATE` or `DELETE`; `UPDATE`/`DELETE` need a parameterized
|
|
435
|
-
`WHERE`. Upserts and `RETURNING`/`OUTPUT` are allowed
|
|
454
|
+
`WHERE`. Upserts and `RETURNING`/`OUTPUT` are allowed (not `RETURNING` on
|
|
455
|
+
Oracle), a leading `WITH` and
|
|
436
456
|
multiple statements are not (`write_statement_refused`). On SQL Server one
|
|
437
457
|
`EXEC` of a writing procedure is allowed, subject to the instance's
|
|
438
458
|
`write_procedure_definition_refused` checks, including no transaction
|
|
@@ -464,7 +484,9 @@ payload is the query's arguments: only the model-sourced parameter names.
|
|
|
464
484
|
Map workflow data with a Transform before the node; there is no per-node
|
|
465
485
|
JSONPath argument mapping. Never include an identity parameter (such as
|
|
466
486
|
`email`) or an unknown name: the call answers `invalid_arguments` and runs
|
|
467
|
-
nothing.
|
|
487
|
+
nothing. A list parameter takes a JSON array; declare it in `input_schema` as
|
|
488
|
+
`type: array`, which `cavelon validate` checks. `config_overrides` do not
|
|
489
|
+
apply to a query node.
|
|
468
490
|
|
|
469
491
|
For `order_status` above, add this fragment to
|
|
470
492
|
`package/registry_entities.yaml`, connect the workflow's entry to
|
|
@@ -132,8 +132,9 @@ use it when you parse the result.
|
|
|
132
132
|
in the Admin; preserve `credential_required_for_target_change`.
|
|
133
133
|
Older instances may lack these routes or keep management person-only;
|
|
134
134
|
follow their published gate and direct a person to their dashboard.
|
|
135
|
-
The dialects are `postgresql`, `mysql
|
|
136
|
-
`mssql` (SQL Server)
|
|
135
|
+
The dialects are `postgresql`, `mysql`,
|
|
136
|
+
`mssql` (SQL Server) and `oracle`; an instance accepts those its OpenAPI
|
|
137
|
+
publishes. A SQL Server login that can write keeps the
|
|
137
138
|
connection's queries from running (`write_privileges_unacknowledged`) until
|
|
138
139
|
it may only read or the Owner acknowledges it in the Admin, so ask for a
|
|
139
140
|
read-only login. A stored-procedure query (`EXEC`, SQL Server only) needs
|
|
@@ -177,8 +177,14 @@ 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.
|
|
183
|
+
- An Oracle query is test-run the same way. Save-time refusals of PL/SQL,
|
|
184
|
+
`DBMS_*`/`UTL_*` packages, database links or a write's `RETURNING`
|
|
185
|
+
(`forbidden_keyword`, `write_statement_refused`) come before any test run.
|
|
186
|
+
`cavelon validate` warns of them in one recognizable read or write; a PL/SQL
|
|
187
|
+
block or several statements are refused only by the instance, on save.
|
|
182
188
|
- A read stored-procedure query (SQL Server) is test-run the same way; the
|
|
183
189
|
instance refuses the run while the connection's login can write or the
|
|
184
190
|
procedure's definition writes or cannot be read, with a code
|
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.
|
|
3
|
+
"version": "0.2.0",
|
|
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",
|