@cavelon/cli 0.1.12 → 0.1.14

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.
@@ -142,16 +142,71 @@ the Admin. Then:
142
142
 
143
143
  - A step can assert the agent calls the query (`tool_called` with the tool's
144
144
  slug), and the judge checks the answer against the known rows.
145
- - A test run has no signed-in visitor. A query with an identity parameter
146
- (`end_user.*`), or one without `allows_anonymous`, answers
147
- `identity_required` there and runs nothing: such a step checks that the
148
- agent asks the visitor to sign in, not the rows. The instance does not yet
149
- let a suite name a test Chat User whose identity its queries use (a suite's
150
- `as_chat_user` reader reads knowledge as that person, nothing more).
145
+ - For identity-scoped queries (`end_user.*`), choose a test Chat User of the
146
+ acting tenant: `cavelon whoami` shows the tenant;
147
+ `cavelon api list_chat_users -p tenant_id=<tenant_id> --json` lists its
148
+ identities (`chat_users.view` is needed). Use
149
+ `cavelon test run --suite <suite> --as-chat-user <id> --wait --timeout 5m`
150
+ or `cavelon chat "<message>" --harness <solution> --as-chat-user <id>`.
151
+ A personal access token needs `knowledge_bases.view` and `end_users.read`,
152
+ besides permission to run the suite. Knowledge reads use that person's
153
+ groups, and queries bind their identity. The override is on each run
154
+ request: never edit a saved suite just to choose a test reader.
155
+ - A person chooses the test identity in the Admin or with their personal
156
+ access token. With the matching published `needs_a_person_when`, the kit
157
+ refuses an API key on `test run --as-chat-user` and on `db test-run` for
158
+ a query with `end_user.*` parameters before execution (`key_needs_a_person`,
159
+ exit 5). Ordinary key query tests, unrestricted readers and a suite's
160
+ reader already saved by a person remain usable in CI. `whoami` and
161
+ `api describe` show the instance's condition. Do not parse its reason or
162
+ refuse an unknown conditional operation; generic API calls and instances
163
+ that omit the list leave authority to the server.
164
+ - For an `end_user.email` parameter, check the published `email_verified`
165
+ flag. A manually created, unverified Chat User cannot prove the address:
166
+ its query answers `identity_required` and asks for sign-in. Verification
167
+ comes from the widget's email code or SSO. An older instance may omit the
168
+ flag; do not infer verification from an email being present.
169
+ - Check one identity's known rows, another identity's different rows, and
170
+ an audience run that asks for sign-in. Omit the option to use the suite's
171
+ saved reader (audience by default); an audience run has no identity, so a
172
+ query with an identity parameter or without `allows_anonymous` runs
173
+ nothing. Assert the query tool was called and the answer contains only
174
+ the chosen identity's rows. A deleted or cross-tenant reader must be
175
+ refused, not fall back to audience. An older instance may not support a
176
+ reader override, or may refuse a PAT on it even with reader fields:
177
+ follow the command's actionable refusal and ask its operator for support.
151
178
  - To check what an identity-scoped query returns for one customer, the tenant
152
179
  Owner runs it once with `cavelon db test-run <query> --value <name>=<value>`,
153
180
  identity parameters included; it shows what the model would see. Never put
154
181
  a real customer's data into a test file.
182
+ - A read stored-procedure query (SQL Server) is test-run the same way; the
183
+ instance refuses the run while the connection's login can write or the
184
+ procedure's definition writes or cannot be read, with a code
185
+ `cavelon explain` explains. A run whose procedure committed or rolled back
186
+ fails with `query_failed` and a `notice`: the query is switched off, and a
187
+ person fixes the procedure. `cavelon db test <connection>` lists the
188
+ procedure queries whose procedure no longer passes (`procedure_findings`).
189
+ - For a write query, `cavelon db test-run` is a dry run that rolls back,
190
+ provided the connection permits writes. Check the returned `kind`,
191
+ `dry_run`, `rolled_back`, `affected_rows` and `committed`; missing fields
192
+ on older instances and null commit evidence are unknown, never proof of
193
+ rollback. Check `writes_not_allowed`, `too_many_rows_affected` and
194
+ save-time `write_statement_refused`/`write_procedure_definition_refused`
195
+ with `cavelon explain`. Never retry `write_outcome_unknown`; a person
196
+ checks the database before any repetition. Query-definition approval and
197
+ `requires_confirmation` before executing a chat write are separate.
198
+ - A direct workflow Tool Call write with confirmation enabled answers
199
+ `confirmation_unavailable`. For an intended unattended write only, turn
200
+ that query setting off and retain model-only arguments and trigger
201
+ identity checks. The shared `max_calls` budget counts across direct nodes,
202
+ Agent stages, `for_each`, concurrent branches and resume; expect
203
+ `tool_call_limit_reached` on the next call and `refused` run evidence.
204
+ A direct node fails with that code; an Agent receives the tool's refusal.
205
+ Test both mixed-call orders, repeated Agent stages, a fresh
206
+ run's reset and a resumed run's restored count. Agent per-turn limits also
207
+ apply. Read queries have no run cap, and ordinary chat limits are unchanged.
208
+ Fake kit tests prove response handling, not this shared runtime budget or
209
+ workflow acceptance.
155
210
  - `cavelon db runs <query>` lists each run's outcome and error code (never a
156
211
  value or a row), and `cavelon trace` shows the code a failed call answered
157
212
  the model with on the tool's span (`error_code`); `cavelon explain <code>`
@@ -255,6 +310,12 @@ the confirm command in their own terminal. When every suite passes,
255
310
  `cavelon activate --harness <name or slug>` goes through the readiness gate; if the
256
311
  token may not activate, a person activates in the Admin. A solution that a
257
312
  channel or an active trigger reaches goes live for them at once, so its
258
- activation previews first and needs the person's yes: show it; over MCP the
313
+ activation previews first and needs the person's yes. So does activation
314
+ that takes the default route (including assigning an unassigned route), or
315
+ whose reach or route effect is unknown. It needs no confirm only when no
316
+ channel or active trigger reaches it and readiness explicitly says
317
+ `takes_default_route: false`. The preview reserves no route state; the
318
+ successful result's `took_default_route` fields report the actual effect.
319
+ Show it; over MCP the
259
320
  client asks them when you confirm with its token, and from your shell they run
260
321
  the confirm command in their own terminal.
@@ -224,12 +224,23 @@ const PLUGIN_UPDATE = {
224
224
  claude: "`claude plugin marketplace update cavelon-dev-kit` and `claude plugin update cavelon@cavelon-dev-kit`",
225
225
  codex: "`codex plugin marketplace upgrade cavelon-dev-kit` and `codex plugin add cavelon@cavelon-dev-kit`",
226
226
  };
227
+ const INSTALL_DOCS = `https://github.com/${REPOSITORY}/blob/main/docs/install`;
227
228
  function pluginUpdate(client) {
228
229
  const name = client?.toLowerCase() ?? "";
229
230
  if (name.includes("claude"))
230
- return PLUGIN_UPDATE.claude;
231
+ return `with ${PLUGIN_UPDATE.claude}`;
231
232
  if (name.includes("codex"))
232
- return PLUGIN_UPDATE.codex;
233
+ return `with ${PLUGIN_UPDATE.codex}`;
234
+ if (name.includes("gemini"))
235
+ return "with `gemini extensions update cavelon`";
236
+ if (name.includes("cursor"))
237
+ return `as ${INSTALL_DOCS}/cursor.md#update says`;
238
+ if (name.includes("kiro"))
239
+ return `as ${INSTALL_DOCS}/kiro.md#update says`;
240
+ if (name.includes("copilot"))
241
+ return "with `copilot plugin update cavelon`";
242
+ if (name.includes("visual studio code") || name.includes("vscode"))
243
+ return `as ${INSTALL_DOCS}/vscode-copilot.md#update says`;
233
244
  return undefined;
234
245
  }
235
246
  export function sessionWarning(facts) {
@@ -249,10 +260,12 @@ export function sessionWarning(facts) {
249
260
  if (pluginBehind) {
250
261
  said.push(`The Cavelon plugin is ${plugin}${latest ? "" : `, older than cavelon ${newest}`}.`);
251
262
  const commands = pluginUpdate(facts.client);
252
- asks.push(commands ? `Update the plugin with ${commands}.` : `Update the plugin: in Claude Code with ${PLUGIN_UPDATE.claude}; in Codex with ${PLUGIN_UPDATE.codex}.`);
263
+ asks.push(commands
264
+ ? `Update the plugin ${commands}.`
265
+ : `Update the plugin: in Claude Code with ${PLUGIN_UPDATE.claude}; in Codex with ${PLUGIN_UPDATE.codex}; in another agent as its page in ${INSTALL_DOCS}/ says.`);
253
266
  }
254
267
  else if (latest && plugin === undefined && pluginUpdate(facts.client)) {
255
- asks.push(`If they use the Cavelon plugin, also update it with ${pluginUpdate(facts.client)}.`);
268
+ asks.push(`If they use the Cavelon plugin, also update it ${pluginUpdate(facts.client)}.`);
256
269
  }
257
270
  if (skillsBehind) {
258
271
  said.push(`The skills \`cavelon init --agents\` wrote in this solution folder are from cavelon ${skills}.`);
@@ -0,0 +1,160 @@
1
+ import { parameterSchema, QUERY_TOOL_TYPE, querySchema, queryTools, schemaKnowsQueries, schemaKnowsWrites } from "./database-queries.js";
2
+ import { locate } from "./package-files.js";
3
+ export const WORKFLOW_QUERY_MISSING_CODE = "tool_call_database_query_missing";
4
+ const object = (value) => value && typeof value === "object" && !Array.isArray(value) ? value : undefined;
5
+ const rows = (value) => Array.isArray(value) ? value.filter((row) => object(row) !== undefined) : [];
6
+ const pointerKey = (key) => key.replaceAll("~", "~0").replaceAll("/", "~1");
7
+ const scopeMatches = (row, scope) => row.harness_slug === undefined || row.harness_slug === scope;
8
+ const active = (row) => row.is_active !== false;
9
+ export function workflowQueryNodes(pkg) {
10
+ const queries = new Set(queryTools(pkg).map((tool) => tool.slug));
11
+ const nodes = object(pkg.registry_entities)?.orchestration_nodes;
12
+ if (!Array.isArray(nodes))
13
+ return [];
14
+ return nodes.flatMap((raw, index) => {
15
+ const node = object(raw);
16
+ const config = object(node?.config);
17
+ const slug = typeof config?.tool_slug === "string" ? config.tool_slug.trim() : undefined;
18
+ return node?.node_type === "tool_call" && config && slug && (config.tool_type === QUERY_TOOL_TYPE || queries.has(slug))
19
+ ? [{ node, index, config, slug }] : [];
20
+ });
21
+ }
22
+ function resolve(schema, raw) {
23
+ let value = object(raw);
24
+ for (let hops = 0; value && typeof value.$ref === "string" && hops < 10; hops++) {
25
+ if (!value.$ref.startsWith("#/$defs/"))
26
+ return undefined;
27
+ value = object(schema.$defs?.[value.$ref.slice("#/$defs/".length)]);
28
+ }
29
+ return value;
30
+ }
31
+ export function schemaRunsQueryNodes(schema) {
32
+ if (!schemaKnowsQueries(schema))
33
+ return false;
34
+ const registry = resolve(schema, schema.properties?.registry_entities);
35
+ const nodes = resolve(schema, object(registry?.properties)?.orchestration_nodes);
36
+ const entry = resolve(schema, nodes?.items);
37
+ for (const branch of rows(entry?.allOf)) {
38
+ const types = object(object(object(branch.if)?.properties)?.node_type)?.enum;
39
+ if (!Array.isArray(types) || !types.includes("tool_call"))
40
+ continue;
41
+ const config = resolve(schema, object(object(branch.then)?.properties)?.config);
42
+ const allowed = object(object(config?.properties)?.tool_type)?.enum;
43
+ return Array.isArray(allowed) && allowed.includes(QUERY_TOOL_TYPE);
44
+ }
45
+ return false;
46
+ }
47
+ function triggerReaches(pkg, query) {
48
+ if (!active(query.node))
49
+ return false;
50
+ const registry = object(pkg.registry_entities);
51
+ const scope = query.node.harness_slug;
52
+ const nodes = rows(registry?.orchestration_nodes).filter((node) => scopeMatches(node, scope));
53
+ const edges = rows(registry?.graph_edges).filter((edge) => active(edge) && scopeMatches(edge, scope));
54
+ const triggers = rows(registry?.triggers).filter((trigger) => active(trigger) && scopeMatches(trigger, scope));
55
+ const pending = [{ kind: "orchestration", slug: query.node.slug }];
56
+ const seen = new Set();
57
+ while (pending.length) {
58
+ const ref = pending.pop();
59
+ const key = JSON.stringify([ref.kind, ref.slug]);
60
+ if (seen.has(key))
61
+ continue;
62
+ seen.add(key);
63
+ if (ref.kind === "orchestration") {
64
+ const node = nodes.find((node) => node.slug === ref.slug);
65
+ if (node && !active(node))
66
+ continue;
67
+ if (node?.node_type === "trigger_start") {
68
+ const bound = object(node.config)?.trigger_slug;
69
+ const trigger = rows(registry?.triggers).find((trigger) => trigger.slug === bound && scopeMatches(trigger, scope));
70
+ if (!trigger || active(trigger))
71
+ return true;
72
+ }
73
+ }
74
+ else if (ref.kind === "agent" && triggers.some((trigger) => trigger.entrypoint_agent_slug === ref.slug)) {
75
+ return true;
76
+ }
77
+ for (const edge of edges) {
78
+ const to = object(edge.to_node_ref);
79
+ const from = object(edge.from_node_ref);
80
+ if (to?.kind === ref.kind && to.slug === ref.slug && typeof from?.kind === "string" && typeof from.slug === "string")
81
+ pending.push({ kind: from.kind, slug: from.slug });
82
+ }
83
+ }
84
+ return false;
85
+ }
86
+ function argumentNames(pkg, query) {
87
+ const found = [];
88
+ const input = object(query.config.input_schema);
89
+ const properties = object(input?.properties) ?? {};
90
+ const at = `/registry_entities/orchestration_nodes/${query.index}/config/input_schema`;
91
+ for (const name of Object.keys(properties))
92
+ found.push({ name, pointer: `${at}/properties/${pointerKey(name)}` });
93
+ if (Array.isArray(input?.required))
94
+ input.required.forEach((name, index) => {
95
+ if (typeof name === "string" && !Object.hasOwn(properties, name))
96
+ found.push({ name, pointer: `${at}/required/${index}` });
97
+ });
98
+ const registry = object(pkg.registry_entities);
99
+ const edges = rows(registry?.graph_edges).filter((edge) => active(edge) && scopeMatches(edge, query.node.harness_slug) && !object(edge.config)?.input_template);
100
+ const nodes = Array.isArray(registry?.orchestration_nodes) ? registry.orchestration_nodes : [];
101
+ nodes.forEach((raw, index) => {
102
+ const node = object(raw);
103
+ const config = object(node?.config);
104
+ if (!node || !active(node) || !scopeMatches(node, query.node.harness_slug) || node.node_type !== "transform" || !config)
105
+ return;
106
+ if ((config.mode ?? "json_mapping") !== "json_mapping" || (config.target_mode ?? "flat") !== "flat")
107
+ return;
108
+ if (!edges.some((edge) => {
109
+ const from = object(edge.from_node_ref);
110
+ const to = object(edge.to_node_ref);
111
+ return from?.kind === "orchestration" && from.slug === node.slug && to?.kind === "orchestration" && to.slug === query.node.slug;
112
+ }))
113
+ return;
114
+ for (const name of Object.keys(object(config.mapping) ?? {}))
115
+ found.push({ name, pointer: `/registry_entities/orchestration_nodes/${index}/config/mapping/${pointerKey(name)}` });
116
+ });
117
+ return found;
118
+ }
119
+ export function checkWorkflowQueries(disk, schema, inventory, baseline) {
120
+ if (!schemaRunsQueryNodes(schema) || disk.unreadable?.includes("tools"))
121
+ return [];
122
+ const findings = [];
123
+ const tools = queryTools(disk.package);
124
+ const defaults = object(parameterSchema(schema)?.properties);
125
+ const source = object(defaults?.source)?.default ?? "model";
126
+ for (const queryNode of workflowQueryNodes(disk.package)) {
127
+ const { node, index, slug } = queryNode;
128
+ const at = `/registry_entities/orchestration_nodes/${index}/config/tool_slug`;
129
+ const namedTool = rows(disk.package.tools).find((tool) => tool.slug === slug);
130
+ if (namedTool && namedTool.tool_type !== QUERY_TOOL_TYPE)
131
+ continue;
132
+ const tool = tools.find((tool) => tool.slug === slug)?.tool;
133
+ const query = object(tool?.database_query) ?? object(baseline?.tools[slug]?.database_query);
134
+ if (!tool && !inventory?.names.tools?.includes(slug) && Array.isArray(inventory?.names.tools)) {
135
+ findings.push({ code: WORKFLOW_QUERY_MISSING_CODE, severity: "warning", ...locate(disk, at), message: `Tool Call node "${String(node.slug ?? index)}" names database query "${slug}", which is neither in the package nor among the tenant's tools at the last pull (${inventory.written_at}); the import preview blocks it unless it exists by then.` });
136
+ }
137
+ if (!query)
138
+ continue;
139
+ const confirmation = object(object(querySchema(schema)?.properties)?.requires_confirmation);
140
+ if (schemaKnowsWrites(schema) && query.kind === "write" && confirmation && (query.requires_confirmation ?? confirmation.default) === true) {
141
+ findings.push({ code: "confirmation_unavailable", severity: "warning", ...locate(disk, at), message: `Tool Call node "${String(node.slug ?? index)}" calls write query "${slug}" with requires_confirmation: the node cannot wait for a person's click, so the instance refuses it with confirmation_unavailable.`, hint: "Call the query from an agent in a signed-in person's chat, or have the tenant's query manager turn confirmation off for an intended unattended write." });
142
+ }
143
+ const parameters = rows(query.parameters);
144
+ const model = new Set(parameters.filter((parameter) => (parameter.source ?? source) === source).map((parameter) => parameter.name));
145
+ const identity = new Set(parameters.filter((parameter) => (parameter.source ?? source) !== source).map((parameter) => parameter.name));
146
+ for (const argument of argumentNames(disk.package, queryNode)) {
147
+ if (model.has(argument.name))
148
+ continue;
149
+ findings.push({
150
+ code: "invalid_arguments", severity: "error", ...locate(disk, argument.pointer),
151
+ message: `Tool Call node "${String(node.slug ?? index)}" passes "${argument.name}" to query "${slug}": ${identity.has(argument.name) ? "an identity parameter is filled by the instance from the signed-in Chat User" : "the query has no model-sourced parameter of that name"}; the call answers invalid_arguments and runs nothing.`,
152
+ 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
+ });
154
+ }
155
+ if ((identity.size || query.allows_anonymous !== true) && triggerReaches(disk.package, queryNode)) {
156
+ 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
+ }
158
+ }
159
+ return findings;
160
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cavelon/cli",
3
- "version": "0.1.12",
3
+ "version": "0.1.14",
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",