@cavelon/cli 0.1.13 → 0.1.15
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/access.js +32 -0
- package/dist/change-confirmation.js +3 -2
- package/dist/chat-reader.js +68 -0
- package/dist/commands/api.js +13 -5
- package/dist/commands/chat.js +12 -5
- package/dist/commands/db-connections.js +284 -0
- package/dist/commands/db.js +63 -26
- package/dist/commands/index.js +7 -0
- package/dist/commands/session.js +11 -0
- package/dist/commands/solution.js +119 -25
- package/dist/commands/work.js +16 -6
- package/dist/database-queries.js +30 -11
- package/dist/http.js +15 -0
- package/dist/kit-codes.js +2 -0
- package/dist/mcp.js +17 -8
- package/dist/package-check.js +6 -3
- package/dist/package-references.js +5 -1
- package/dist/principal.js +11 -1
- package/dist/skills/cavelon-authoring/SKILL.md +155 -10
- package/dist/skills/cavelon-loop/SKILL.md +79 -22
- package/dist/skills/cavelon-testing/SKILL.md +62 -8
- package/dist/workflow-queries.js +160 -0
- package/package.json +1 -1
package/dist/mcp.js
CHANGED
|
@@ -15,7 +15,7 @@ const INSTRUCTIONS = "Tools for one Cavelon instance, acting with the token a pe
|
|
|
15
15
|
"loop_start, sandbox_seed, artifacts_export) return operation ids at once; read them with operation_status, which returns " +
|
|
16
16
|
`the state at once, or waits up to its timeout (at most ${MCP_MAX_WAIT_MS / 1000} s) when given one, and reports waited_ms, ` +
|
|
17
17
|
"and follow a loop with loop_iterations. What needs confirmation: apply imports only with confirm set to a preview's id; " +
|
|
18
|
-
"tenant_create, variables_set where it replaces another value, loop_start, limits_set, models_set_limit, loop_cancel, sandbox_seed, " +
|
|
18
|
+
"tenant_create, variables_set where it replaces another value, variables_delete, loop_start, limits_set, models_set_limit, loop_cancel, sandbox_seed, " +
|
|
19
19
|
"trigger_identity, harness_default, activate of a solution a channel or trigger reaches or with make_default, deactivate, " +
|
|
20
20
|
"and api for an operation that is not read-only, " +
|
|
21
21
|
"return what they would do and a confirm_token, and change nothing until called again with the same arguments and " +
|
|
@@ -24,14 +24,16 @@ const INSTRUCTIONS = "Tools for one Cavelon instance, acting with the token a pe
|
|
|
24
24
|
"or that cannot be taken back, is the person's to confirm, and the token alone does not make it: its preview says " +
|
|
25
25
|
"needs_person. With needs_person \"client\", call again with the token and the client asks the person to approve exactly that " +
|
|
26
26
|
"change; their no, or no answer, changes nothing (confirm_declined). Only after their yes does cavelon ask the instance for " +
|
|
27
|
-
"the
|
|
27
|
+
"confirmation bound to the token, tenant and exact request. The instance does not verify the person's answer: asking them " +
|
|
28
|
+
"is the kit's responsibility alone. Ask before every guarded change; never answer on the person's behalf or reuse an earlier yes for another change. " +
|
|
29
|
+
"confirmation_required or confirmation_invalid changed nothing: preview again, never retry " +
|
|
28
30
|
"on your own. With needs_person \"terminal\" this client cannot ask " +
|
|
29
31
|
"them: give the person the preview's confirm command, which they run in their own terminal, never in yours. These are " +
|
|
30
32
|
"harness_default and activate (the default route and a solution something reaches: live traffic), deactivate, tenant_create, " +
|
|
31
|
-
"variables_set replacing a value (every solution of the tenant reads it), limits_set, models_set_limit, trigger_identity, " +
|
|
33
|
+
"variables_set replacing a value (every solution of the tenant reads it), variables_delete, limits_set, models_set_limit, trigger_identity, " +
|
|
32
34
|
"api for an operation that is not read-only, loop_start unless the trigger's solution is a draft (a run acts as the person " +
|
|
33
35
|
"and spends budget), and apply where its preview says show_to_person (tenant-wide sections, an active solution, deletions, " +
|
|
34
|
-
"env/prod). A draft's apply, a draft's loop_start, loop_cancel, sandbox_seed and kb_upload's replace you confirm with the " +
|
|
36
|
+
"env/prod, or database_queries.would_write). A draft's apply with no query writes or other person requirement, a draft's loop_start, loop_cancel, sandbox_seed and kb_upload's replace you confirm with the " +
|
|
35
37
|
"token once the person saw the preview. " +
|
|
36
38
|
"chat sends one message to a solution and returns its answer: the way to try one that is not the default route. " +
|
|
37
39
|
"kb_upload names files that match an active document of the knowledge base; with replace it replaces them, and where the " +
|
|
@@ -52,9 +54,12 @@ const INSTRUCTIONS = "Tools for one Cavelon instance, acting with the token a pe
|
|
|
52
54
|
"instance allows this tenant (upload sizes and types, run and tool limits, timeouts, quotas) and who changes each. " +
|
|
53
55
|
"Never change a limit on your own: propose the old and new value (limits_set for a limit a tenant admin changes, " +
|
|
54
56
|
"models_set_limit for an endpoint's max_concurrent_requests) and let the person decide; an operator's limit goes to the operator. " +
|
|
55
|
-
"db_connections, db_queries and db_runs read
|
|
56
|
-
"
|
|
57
|
-
"
|
|
57
|
+
"db_connections, db_queries and db_runs read database connections, saved queries and their runs. Connection commands " +
|
|
58
|
+
"and query-writing apply follow the permissions and needs_a_person the instance publishes: use whoami, including " +
|
|
59
|
+
"database_connectors.manage, instead of assuming every token is blocked. An authorized personal access token may " +
|
|
60
|
+
"manage definitions. Creating, changing or deleting a query, including imports that create or change one, needs the person's approval even on a draft; after approval cavelon sends the " +
|
|
61
|
+
"instance's confirmation for the exact change where required. Passwords, privilege acknowledgment and enabling writes " +
|
|
62
|
+
"stay with a person in the Admin; never accept or pass the database password or set allows_writes through a tool. " +
|
|
58
63
|
"variables_list/variables_get/variables_set handle plain-text {{var:…}} values; setting one needs a role that may manage " +
|
|
59
64
|
"the tenant's settings, as a secret does (a Builder's may not): where whoami says the credential may not, tell the person " +
|
|
60
65
|
"who sets it instead of calling variables_set. secrets_list shows which {{secret:…}} " +
|
|
@@ -134,9 +139,13 @@ export function notForThisCredential(spec, access) {
|
|
|
134
139
|
export function toolFor(spec, commands = [], access) {
|
|
135
140
|
const marked = spec.mcpEffect ?? (spec.readOnly ? "Read-only." : spec.destructive ? "Changes the instance; may delete or overwrite." : "Changes the instance.");
|
|
136
141
|
const refused = notForThisCredential(spec, access);
|
|
142
|
+
const conditional = (spec.operations ?? []).flatMap(operation => {
|
|
143
|
+
const reason = operationAccess(access, operation).personWhen;
|
|
144
|
+
return reason === undefined ? [] : [`Needs a person only when (${operation}): ${reason}. Ordinary requests remain usable; the instance decides every request.`];
|
|
145
|
+
});
|
|
137
146
|
return {
|
|
138
147
|
name: toolName(spec),
|
|
139
|
-
description: mcpSpelling([refused, spec.summary, spec.description, marked].filter(Boolean).join("\n"), spec, commands),
|
|
148
|
+
description: mcpSpelling([refused, spec.summary, spec.description, ...conditional, marked].filter(Boolean).join("\n"), spec, commands),
|
|
140
149
|
inputSchema: inputSchema(spec, commands),
|
|
141
150
|
annotations: {
|
|
142
151
|
title: spec.summary,
|
package/dist/package-check.js
CHANGED
|
@@ -4,6 +4,7 @@ import { checkQueryTools, QUERY_CHANGED_CODE, QUERY_FIELDS_IGNORED_CODE } from "
|
|
|
4
4
|
import { locate, schemaSections, tenantWideSections } from "./package-files.js";
|
|
5
5
|
import { MANIFEST_SECTION, PERSONA_SECTION, sectionFields } from "./package-format.js";
|
|
6
6
|
import { kitErrorEntry } from "./kit-codes.js";
|
|
7
|
+
import { checkWorkflowQueries } from "./workflow-queries.js";
|
|
7
8
|
import { cavelonCommand, fill, folderCommand } from "./printed.js";
|
|
8
9
|
import { branches, checkModels, checkReferences, checkUnknownFields, closest, DUPLICATE_CODE, FIELD_UNKNOWN_CODE, MODEL_UNKNOWN_CODE, REFERENCE_MISSING_CODE, REFERENCE_UNKNOWN_CODE, KNOWLEDGE_TOOL_KEYS, } from "./package-references.js";
|
|
9
10
|
export const SCHEMA_CODE = "package_schema_invalid";
|
|
@@ -163,8 +164,9 @@ export const KIT_CODES = [
|
|
|
163
164
|
{
|
|
164
165
|
code: QUERY_CHANGED_CODE,
|
|
165
166
|
area: "package",
|
|
166
|
-
message: "A database query tool's query (database_query), name or description differs from the last pull or apply, or the tool is new.
|
|
167
|
-
hint: "
|
|
167
|
+
message: "A database query tool's query (database_query), name or description differs from the last pull or apply, or the tool is new. Creating or changing it needs database_connectors.manage and the person's approval.",
|
|
168
|
+
hint: "Preview with `cavelon apply`: a personal access token holding database_connectors.manage (the tenant Owner or a superadmin in Tenant mode) may import it after the person approves. " +
|
|
169
|
+
"Over MCP the client asks the person; from an agent's shell the person runs the preview's confirm command in their own terminal. A credential without that permission gets database_query_needs_superadmin; its published hint names who this instance permits. " +
|
|
168
170
|
"To apply the rest first, leave the query as the instance holds it: restore the tool's entry as the last pull wrote it, or remove its database_query block (a query tool without one keeps the instance's query, name and description). " +
|
|
169
171
|
"Rename the tool for one agent with the assignment's config_overrides instead: an override of name, description or max_calls is no query change.",
|
|
170
172
|
docs: DATABASE_DOCS,
|
|
@@ -338,7 +340,8 @@ export function checkPackage(disk, options) {
|
|
|
338
340
|
findings.push(...checkUncheckedAssertions(disk, options.schema));
|
|
339
341
|
findings.push(...checkSolutionSlug(disk, options.solution));
|
|
340
342
|
findings.push(...checkTenantWide(disk, options.schema, options.solution));
|
|
341
|
-
findings.push(...checkQueryTools(disk, options.schema, options.queryBaseline));
|
|
343
|
+
findings.push(...checkQueryTools(disk, options.schema, options.queryBaseline, options.queryConnections));
|
|
344
|
+
findings.push(...checkWorkflowQueries(disk, options.schema, options.inventory, options.queryBaseline));
|
|
342
345
|
noteTenantWide(findings, options.schema, options.solution);
|
|
343
346
|
for (const finding of findings) {
|
|
344
347
|
const entry = findingEntry(options.catalog, finding.code);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { locate } from "./package-files.js";
|
|
2
|
+
import { schemaRunsQueryNodes, workflowQueryNodes } from "./workflow-queries.js";
|
|
2
3
|
export const DUPLICATE_CODE = "package_duplicate_key";
|
|
3
4
|
export const REFERENCE_MISSING_CODE = "package_reference_missing";
|
|
4
5
|
export const REFERENCE_UNKNOWN_CODE = "package_reference_unknown";
|
|
@@ -282,9 +283,12 @@ const CHECKED_BY = {
|
|
|
282
283
|
models: "the agents' models",
|
|
283
284
|
};
|
|
284
285
|
export const checkedBy = (kind) => CHECKED_BY[kind];
|
|
285
|
-
export function missingInventory(disk, inventory) {
|
|
286
|
+
export function missingInventory(disk, inventory, schema) {
|
|
286
287
|
const needed = new Set();
|
|
287
288
|
const pkg = disk.package;
|
|
289
|
+
const ownTools = new Set(keysIn(pkg, TOOL));
|
|
290
|
+
if ((!schema || schemaRunsQueryNodes(schema)) && workflowQueryNodes(pkg).some((node) => !ownTools.has(node.slug)))
|
|
291
|
+
needed.add("tools");
|
|
288
292
|
for (const ref of references(pkg)) {
|
|
289
293
|
const kind = ref.target.inventory;
|
|
290
294
|
if (!kind || keysIn(pkg, ref.target).includes(ref.name) || ref.target.builtin?.has(ref.name))
|
package/dist/principal.js
CHANGED
|
@@ -2,12 +2,14 @@ export async function readPrincipal(client, options = {}) {
|
|
|
2
2
|
const response = await client.get("/api/v1/meta/principal", { allow: [400, 403, 404, 405], sendTenant: options.sendTenant });
|
|
3
3
|
if (response.status !== 200 || !response.data?.kind)
|
|
4
4
|
return undefined;
|
|
5
|
-
const { permissions, needs_a_person: needsAPerson, tenant, ...rest } = response.data;
|
|
5
|
+
const { permissions, needs_a_person: needsAPerson, needs_a_person_when: needsAPersonWhen, tenant, ...rest } = response.data;
|
|
6
6
|
const principal = rest;
|
|
7
7
|
if (Array.isArray(permissions))
|
|
8
8
|
principal.permissions = permissions.filter((p) => typeof p === "string");
|
|
9
9
|
if (Array.isArray(needsAPerson))
|
|
10
10
|
principal.needs_a_person = operationsNeedingAPerson(needsAPerson);
|
|
11
|
+
if (Array.isArray(needsAPersonWhen))
|
|
12
|
+
principal.needs_a_person_when = conditionalOperations(needsAPersonWhen);
|
|
11
13
|
if (tenant === null)
|
|
12
14
|
principal.tenant = null;
|
|
13
15
|
else if (tenant && typeof tenant === "object" && typeof tenant.id === "string") {
|
|
@@ -16,6 +18,14 @@ export async function readPrincipal(client, options = {}) {
|
|
|
16
18
|
}
|
|
17
19
|
return principal;
|
|
18
20
|
}
|
|
21
|
+
function conditionalOperations(value) {
|
|
22
|
+
return value
|
|
23
|
+
.filter((o) => Boolean(o) && typeof o === "object" && !Array.isArray(o))
|
|
24
|
+
.filter((o) => typeof o.method === "string" && ["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS", "TRACE"].includes(o.method.toUpperCase())
|
|
25
|
+
&& typeof o.path === "string" && o.path.startsWith("/") && !/[\s?#]/.test(o.path)
|
|
26
|
+
&& (o.operation === null || typeof o.operation === "string") && typeof o.reason === "string")
|
|
27
|
+
.map((o) => ({ operation: o.operation, method: o.method.toUpperCase(), path: o.path, reason: o.reason }));
|
|
28
|
+
}
|
|
19
29
|
function operationsNeedingAPerson(value) {
|
|
20
30
|
return value
|
|
21
31
|
.filter((o) => Boolean(o) && typeof o === "object")
|
|
@@ -327,7 +327,7 @@ schema has them: `cavelon validate` reports an unknown section):
|
|
|
327
327
|
## Database query tools
|
|
328
328
|
|
|
329
329
|
A database query tool lets an agent answer from a customer's live database. A
|
|
330
|
-
saved
|
|
330
|
+
saved query of explicit `kind: read` or `kind: write` is one tool (`tool_type: database_query` in
|
|
331
331
|
`package/tools.yaml`); the model only calls it and fills the parameters it is
|
|
332
332
|
given, and never writes SQL. `cavelon schema tools.database_query` lists the
|
|
333
333
|
fields this instance takes; `cavelon docs get administration/database-connectors`
|
|
@@ -355,15 +355,25 @@ says who does what on the instance.
|
|
|
355
355
|
allows_anonymous: false
|
|
356
356
|
```
|
|
357
357
|
|
|
358
|
-
- **Who writes a query.**
|
|
359
|
-
|
|
360
|
-
|
|
358
|
+
- **Who writes a query.** A personal access token whose principal holds
|
|
359
|
+
`database_connectors.manage` may create or change a query with `cavelon
|
|
360
|
+
apply`: the tenant Owner (or Admin) and a superadmin in Tenant mode hold
|
|
361
|
+
that permission. Read `cavelon whoami` and the instance's
|
|
362
|
+
`database_connector.may_write_queries`; the instance decides. The query's
|
|
363
|
+
SQL, parameters, limits and `allows_anonymous`, and the tool's own `slug`, `name` and
|
|
361
364
|
`description`, are all part of the query. `cavelon validate` warns
|
|
362
365
|
(`database_query_changed`) for each query tool that differs from the last
|
|
363
|
-
pull or apply
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
366
|
+
pull or apply. Edit the definition in `package/tools.yaml`, validate it and
|
|
367
|
+
preview with `cavelon apply`. If the preview's
|
|
368
|
+
`database_queries.would_write` is nonempty, the person approves even for a
|
|
369
|
+
draft: over MCP the client asks them when you confirm the preview id; from
|
|
370
|
+
an agent's shell they run the printed confirm in their own terminal. Only
|
|
371
|
+
after their yes does cavelon request the instance's confirmation id and
|
|
372
|
+
send it with that exact import. An unchanged definition needs no query
|
|
373
|
+
confirmation. A credential without manage is blocked with
|
|
374
|
+
`database_query_needs_superadmin`, stopping the whole import; its hint
|
|
375
|
+
names who this instance permits (older instances can still require a
|
|
376
|
+
superadmin in the Admin). What you may change
|
|
367
377
|
freely is how agents and skills use the tool: the assignment
|
|
368
378
|
(`tool_assignments` with `config_overrides` `name`, `description` or
|
|
369
379
|
`max_calls`) is no query change. `params_json_schema` and `default_config`
|
|
@@ -379,7 +389,7 @@ says who does what on the instance.
|
|
|
379
389
|
- **`allows_anonymous`.** Set it to true only for public data (stock, prices,
|
|
380
390
|
opening hours) and only on a query without an identity parameter; the
|
|
381
391
|
instance refuses it otherwise (`anonymous_with_context_parameter`).
|
|
382
|
-
- **
|
|
392
|
+
- **Read query design.** One `SELECT` or `WITH` statement; select only the
|
|
383
393
|
columns the answer needs (never `SELECT *`); always bound the rows (`LIMIT`,
|
|
384
394
|
`TOP`, `FETCH FIRST`) and keep `max_rows` small; constrain every model
|
|
385
395
|
parameter (`pattern`, `max_length`, `enum`, `minimum`/`maximum`) and
|
|
@@ -388,7 +398,7 @@ says who does what on the instance.
|
|
|
388
398
|
postal code) rather than one guessable key. Each `:name` in the SQL needs
|
|
389
399
|
exactly one parameter of that name (a literal colon is `\:`); validate checks
|
|
390
400
|
this (`bind_mismatch`) and each parameter's type and constraints.
|
|
391
|
-
- **
|
|
401
|
+
- **Read stored procedures (SQL Server only).** On an `mssql` connection the SQL
|
|
392
402
|
may instead be exactly one call, `EXEC [schema].[procedure] @p1 = :p1, @p2 =
|
|
393
403
|
:p2`: every argument a placeholder with a declared parameter, no literal,
|
|
394
404
|
`OUTPUT`, option or dynamic SQL (`procedure_call_form`; on another dialect
|
|
@@ -404,6 +414,141 @@ says who does what on the instance.
|
|
|
404
414
|
`validate` and the preview name, the codes of a failed call (`timeout`,
|
|
405
415
|
`identity_required`, …) and of a connection test.
|
|
406
416
|
|
|
417
|
+
### Authoring a write query
|
|
418
|
+
|
|
419
|
+
Read the instance's schema before using these fields. Set `kind: write`
|
|
420
|
+
explicitly, keep `max_affected_rows` small (default 1, at most 100), and keep
|
|
421
|
+
`requires_confirmation: true` (the default) so the signed-in person confirms
|
|
422
|
+
in chat before execution. `max_calls` takes 1–1000; omitted, the instance
|
|
423
|
+
uses 1 for a write and 5 for a read. For the example above, keep its
|
|
424
|
+
parameters and replace the SQL and write settings with:
|
|
425
|
+
|
|
426
|
+
```yaml
|
|
427
|
+
kind: write
|
|
428
|
+
sql_text: UPDATE orders SET status = 'cancelled' WHERE number = :order_no AND email = :email
|
|
429
|
+
max_affected_rows: 1
|
|
430
|
+
requires_confirmation: true
|
|
431
|
+
max_calls: 1
|
|
432
|
+
```
|
|
433
|
+
|
|
434
|
+
One `INSERT`, `UPDATE` or `DELETE`; `UPDATE`/`DELETE` need a parameterized
|
|
435
|
+
`WHERE`. Upserts and `RETURNING`/`OUTPUT` are allowed, a leading `WITH` and
|
|
436
|
+
multiple statements are not (`write_statement_refused`). On SQL Server one
|
|
437
|
+
`EXEC` of a writing procedure is allowed, subject to the instance's
|
|
438
|
+
`write_procedure_definition_refused` checks, including no transaction
|
|
439
|
+
control or `SET NOCOUNT ON`. Local validation cannot prove a procedure's
|
|
440
|
+
behavior; read the server's preview and test results.
|
|
441
|
+
|
|
442
|
+
Use a dedicated least-privilege write login. A tenant Owner or Admin enables
|
|
443
|
+
writes in the Admin with `database_connectors.allow_writes` from a tenant
|
|
444
|
+
membership; a global role alone does not grant it. `allows_writes`,
|
|
445
|
+
passwords and privilege acknowledgment remain person-only Admin actions,
|
|
446
|
+
never query or connection package fields. `db connections` displays the
|
|
447
|
+
published flag; validation warns on explicit false (`writes_not_allowed`)
|
|
448
|
+
and treats omission or an unreadable/offline list as unknown. Tokens get
|
|
449
|
+
`person_only_operation` and tenant API keys get `key_needs_a_person` on
|
|
450
|
+
the password and write-enable routes; follow `needs_a_person`.
|
|
451
|
+
|
|
452
|
+
The import/API approval of a query definition is separate from its
|
|
453
|
+
`requires_confirmation` chat execution prompt. Test writes against a test
|
|
454
|
+
database: `db test-run` is a dry run that rolls back and prints only the
|
|
455
|
+
returned evidence. Never retry `write_outcome_unknown`; ask a person to
|
|
456
|
+
check the database before any repetition. `cavelon explain <code>` reads
|
|
457
|
+
the instance's published catalog.
|
|
458
|
+
|
|
459
|
+
### Calling a query from a workflow
|
|
460
|
+
|
|
461
|
+
Where the instance's package schema supports it, a `tool_call` node names a
|
|
462
|
+
saved query with `tool_slug` and `tool_type: database_query`. Its incoming
|
|
463
|
+
payload is the query's arguments: only the model-sourced parameter names.
|
|
464
|
+
Map workflow data with a Transform before the node; there is no per-node
|
|
465
|
+
JSONPath argument mapping. Never include an identity parameter (such as
|
|
466
|
+
`email`) or an unknown name: the call answers `invalid_arguments` and runs
|
|
467
|
+
nothing. `config_overrides` do not apply to a query node.
|
|
468
|
+
|
|
469
|
+
For `order_status` above, add this fragment to
|
|
470
|
+
`package/registry_entities.yaml`, connect the workflow's entry to
|
|
471
|
+
`query_arguments`, and provide the `query_failed` and `show_order` agents.
|
|
472
|
+
Keep these nodes and edges in the same solution.
|
|
473
|
+
|
|
474
|
+
```yaml
|
|
475
|
+
orchestration_nodes:
|
|
476
|
+
- slug: query_arguments
|
|
477
|
+
node_type: transform
|
|
478
|
+
config:
|
|
479
|
+
mode: json_mapping
|
|
480
|
+
mapping: { order_no: $.previous_output.order_number }
|
|
481
|
+
- slug: lookup_order
|
|
482
|
+
node_type: tool_call
|
|
483
|
+
config:
|
|
484
|
+
tool_slug: order_status
|
|
485
|
+
tool_type: database_query
|
|
486
|
+
input_schema:
|
|
487
|
+
type: object
|
|
488
|
+
properties: { order_no: { type: string, maxLength: 20 } }
|
|
489
|
+
required: [order_no]
|
|
490
|
+
additionalProperties: false
|
|
491
|
+
output_format: auto
|
|
492
|
+
- slug: query_result
|
|
493
|
+
node_type: router
|
|
494
|
+
config: { strategy: condition }
|
|
495
|
+
graph_edges:
|
|
496
|
+
- from_node_ref: { kind: orchestration, slug: query_arguments }
|
|
497
|
+
to_node_ref: { kind: orchestration, slug: lookup_order }
|
|
498
|
+
edge_type: pipeline
|
|
499
|
+
- from_node_ref: { kind: orchestration, slug: lookup_order }
|
|
500
|
+
to_node_ref: { kind: orchestration, slug: query_result }
|
|
501
|
+
edge_type: pipeline
|
|
502
|
+
- from_node_ref: { kind: orchestration, slug: query_result }
|
|
503
|
+
to_node_ref: { kind: agent, slug: query_failed }
|
|
504
|
+
edge_type: condition
|
|
505
|
+
config:
|
|
506
|
+
branch_key: failed
|
|
507
|
+
priority: 0
|
|
508
|
+
condition: { source: previous_output, path: error, operator: exists }
|
|
509
|
+
- from_node_ref: { kind: orchestration, slug: query_result }
|
|
510
|
+
to_node_ref: { kind: agent, slug: show_order }
|
|
511
|
+
edge_type: condition
|
|
512
|
+
config: { branch_key: answered, default: true }
|
|
513
|
+
```
|
|
514
|
+
|
|
515
|
+
- **Output.** Success is `columns`, `rows` (each row an array in column
|
|
516
|
+
order), `returned_rows`, `truncated`, an optional `note`, and the query's
|
|
517
|
+
`source`. Read cells by position, e.g. `$.previous_output.rows[0][1]` for
|
|
518
|
+
the second column. Failure is `{error, message}` with a fixed message,
|
|
519
|
+
never database driver text; the node records the code as its failure and
|
|
520
|
+
keeps this output, so the Router branches on `error`. Read the published
|
|
521
|
+
output under `x-cavelon-output.database_query` on the Tool Call config.
|
|
522
|
+
- **Identity.** A conversation-bound run fills identity parameters from its
|
|
523
|
+
signed-in Chat User. A trigger, schedule or inbound-email run has none:
|
|
524
|
+
an identity-bound query, or one without `allows_anonymous: true`, answers
|
|
525
|
+
`identity_required`. `validate` warns on trigger paths that reach these
|
|
526
|
+
queries. A trigger execution identity is not a Chat User; use only a
|
|
527
|
+
public-data query with no identity parameters and `allows_anonymous: true`
|
|
528
|
+
in such a run.
|
|
529
|
+
- **Write confirmation and budget.** Every direct Tool Call node refuses a
|
|
530
|
+
write with `requires_confirmation: true` (`confirmation_unavailable`),
|
|
531
|
+
because it cannot wait for the person's click; `validate` warns. Turn it
|
|
532
|
+
off only for an intended unattended write. The shared workflow cap
|
|
533
|
+
counts the query's saved `max_calls` across a workflow run's Tool Call
|
|
534
|
+
nodes, Agent stages, `for_each` iterations and concurrent branches, and
|
|
535
|
+
persists on resume. The next call is refused with `tool_call_limit_reached`
|
|
536
|
+
and evidence records `refused`. A direct node fails with that code; an Agent
|
|
537
|
+
receives the tool's refusal. Read queries have no
|
|
538
|
+
run cap. Agent per-turn limits apply in addition to the shared run cap.
|
|
539
|
+
Ordinary chat per-turn limits stay as they are. Do not infer runtime acceptance
|
|
540
|
+
from kit fixtures, or raise a query's saved run cap with assignment `config_overrides`.
|
|
541
|
+
- **Validation.** `validate` checks argument names in `input_schema` and a
|
|
542
|
+
directly preceding Transform's flat JSON mapping, using the query's
|
|
543
|
+
parameters (or the remembered query when its definition is left out).
|
|
544
|
+
Dynamic arguments still need a test. If neither the package nor the
|
|
545
|
+
tenant's last tools list names the query, it warns with
|
|
546
|
+
`tool_call_database_query_missing`; `--strict` fails. The server's import
|
|
547
|
+
preview checks the reference again. `cavelon explain
|
|
548
|
+
tool_call_database_query_missing` explains the published code. On an
|
|
549
|
+
older instance the kit keeps the schema's rules and skips checks for query
|
|
550
|
+
nodes it does not publish.
|
|
551
|
+
|
|
407
552
|
## After each edit
|
|
408
553
|
|
|
409
554
|
1. `cavelon validate` until it reports no errors (`--strict` before an apply
|
|
@@ -21,6 +21,10 @@ use it when you parse the result.
|
|
|
21
21
|
enter Platform mode, which tenants it reaches, and what it may do there: its
|
|
22
22
|
permissions (an API key's scopes too), whether it may activate and set
|
|
23
23
|
variables, and the operations a person runs instead.
|
|
24
|
+
Its optional `needs_a_person_when` lists conditional identity choices
|
|
25
|
+
separately; `api list` and `api describe` show their reasons, and
|
|
26
|
+
`api list --usable` keeps these operations for ordinary requests. Never
|
|
27
|
+
read a reason as authority or treat the conditional list as unconditional.
|
|
24
28
|
- **Offer only what the credential may do.** Over MCP, a tool whose
|
|
25
29
|
description starts with "Not for this credential" is one the instance says
|
|
26
30
|
this token or key may not use in this tenant; `api_list` marks such
|
|
@@ -92,20 +96,39 @@ use it when you parse the result.
|
|
|
92
96
|
In their own terminal, a plain `cavelon init` asks them. Ask for the instance
|
|
93
97
|
URL if you do not know it.
|
|
94
98
|
|
|
95
|
-
- **
|
|
99
|
+
- **Connect a database, leaving the password with a person.** A database query tool
|
|
96
100
|
needs a connection of the name and dialect its package names, tested
|
|
97
|
-
successfully, in every tenant it is applied to. A
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
+
successfully, in every tenant it is applied to. A personal access token
|
|
102
|
+
holding `database_connectors.manage` (the tenant Owner, legacy Admin, or a
|
|
103
|
+
superadmin in Tenant mode) may run `cavelon db connections create|update|delete`
|
|
104
|
+
and upload a public CA with `cavelon db connections ca <connection> <file>`.
|
|
105
|
+
Create sends no password and prints the Admin step from `needs_a_person`;
|
|
106
|
+
a person enters it in Settings › Security & access › Databases. Never take
|
|
107
|
+
a password as an argument, environment value, stdin, file or tool input.
|
|
108
|
+
Private keys are refused by CA upload. Test with `cavelon db test <connection>`.
|
|
109
|
+
Use the same connection name in every tenant and environment
|
|
101
110
|
(`env/test.yaml`, `env/prod.yaml`), each pointing at that environment's
|
|
102
111
|
database, so one package serves them all. `cavelon db instance` says which
|
|
103
112
|
dialects this instance runs and the addresses it connects from, which the
|
|
104
113
|
customer allows through their database's firewall; tell the person both
|
|
105
|
-
before
|
|
114
|
+
before setting up a connection. `cavelon db login-script <dialect>` or
|
|
115
|
+
`cavelon db login-script --connection <connection>` returns the script this
|
|
116
|
+
build actually publishes (currently `read_only`), never an invented write
|
|
117
|
+
script. The DBA replaces its password placeholder locally. Explore only
|
|
118
|
+
the catalog with `cavelon db schema <connection> [schema]`, a read-only
|
|
119
|
+
operation requiring `database_connectors.manage`. The instance tutorial is
|
|
120
|
+
`cavelon docs get administration/database-connector-setup`.
|
|
121
|
+
Keep connection settings outside packages: the query names only name and
|
|
122
|
+
dialect. `allows_writes`, when published, is read-only kit output;
|
|
123
|
+
enabling it and acknowledging write privileges stay in the dashboard.
|
|
124
|
+
A password-bearing target's host, port or dialect change needs a person
|
|
125
|
+
in the Admin; preserve `credential_required_for_target_change`.
|
|
126
|
+
Older instances may lack these routes or keep management person-only;
|
|
127
|
+
follow their published gate and direct a person to their dashboard.
|
|
128
|
+
The dialects are `postgresql`, `mysql` and
|
|
106
129
|
`mssql` (SQL Server). A SQL Server login that can write keeps the
|
|
107
130
|
connection's queries from running (`write_privileges_unacknowledged`) until
|
|
108
|
-
it may only read or
|
|
131
|
+
it may only read or the Owner acknowledges it in the Admin, so ask for a
|
|
109
132
|
read-only login. A stored-procedure query (`EXEC`, SQL Server only) needs
|
|
110
133
|
one without any write privileges, acknowledged or not
|
|
111
134
|
(`write_privileges_block_procedure`), and a procedure that only reads.
|
|
@@ -162,13 +185,18 @@ use it when you parse the result.
|
|
|
162
185
|
code, package file and path, and hint; `cavelon explain <code>` says more.
|
|
163
186
|
A preview that changes nothing says "Nothing to import" and stores no
|
|
164
187
|
preview: there is nothing to confirm.
|
|
165
|
-
**
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
188
|
+
**Database query changes need manage permission and the person's yes.**
|
|
189
|
+
A PAT holding `database_connectors.manage` (the tenant Owner or a
|
|
190
|
+
superadmin in Tenant mode) may apply them. A nonempty
|
|
191
|
+
`database_queries.would_write` in the instance's preview needs person
|
|
192
|
+
approval even on a draft: over MCP the client asks; from an agent's shell
|
|
193
|
+
the person runs the printed confirm. A credential without that permission
|
|
194
|
+
gets `database_query_needs_superadmin`, which stops the whole import;
|
|
195
|
+
the blocker's hint names who this instance permits. To apply the other
|
|
196
|
+
changes now, leave the query as the instance holds it
|
|
169
197
|
(restore the tool's entry as the last pull wrote it, or remove its
|
|
170
|
-
`database_query` block) and preview again.
|
|
171
|
-
|
|
198
|
+
`database_query` block) and preview again. Matching definitions need no
|
|
199
|
+
query confirmation, and a no-op preview stores nothing.
|
|
172
200
|
5. **Confirm** exactly that preview: `cavelon apply --confirm <preview-id>`
|
|
173
201
|
(the line `apply` printed, with the same `--env` and `--tenant`). Exit 4
|
|
174
202
|
means the preview is stale and nothing was imported: the target changed on
|
|
@@ -228,6 +256,17 @@ with one solution: its **default route**. A fresh tenant's default is an empty
|
|
|
228
256
|
`cavelon harness list` marks the default (DEFAULT), and `cavelon activate`
|
|
229
257
|
says when the solution it activated is not the default.
|
|
230
258
|
|
|
259
|
+
Activation can also take this route without `--make-default`. Read its
|
|
260
|
+
published preview: `takes_default_route: true` needs the person's yes,
|
|
261
|
+
including when `takes_default_route_from` and `_from_name` are both null
|
|
262
|
+
(assigning an unassigned route). False with null/null means no takeover.
|
|
263
|
+
An omitted flag is unknown, even if the schema declares a false default,
|
|
264
|
+
and still needs the person. Never infer the effect from instructions, a
|
|
265
|
+
default slug or other configuration. The preview reserves no state; the
|
|
266
|
+
successful activation's `took_default_route` and corresponding from/name
|
|
267
|
+
fields report the actual effect, which may differ. `status` shows the
|
|
268
|
+
preview too.
|
|
269
|
+
|
|
231
270
|
- **Ask the person** whether the new solution should become the default. It
|
|
232
271
|
changes live traffic; never decide it yourself.
|
|
233
272
|
- With their yes: `cavelon activate --make-default` (or `cavelon harness
|
|
@@ -255,8 +294,8 @@ says when the solution it activated is not the default.
|
|
|
255
294
|
## Show the person before confirming
|
|
256
295
|
|
|
257
296
|
Show every preview to the person. Confirm on your own only a preview that
|
|
258
|
-
needs no person: `apply` to a draft solution in a test environment (
|
|
259
|
-
|
|
297
|
+
needs no person: `apply` to a draft solution in a test environment (no query
|
|
298
|
+
writes or other reason to show it to a person), `loop start` of a trigger
|
|
260
299
|
of a draft solution, `loop cancel` and `sandbox seed` of a test run or Sandbox
|
|
261
300
|
you started, and `kb upload --replace`. Stop, show the preview, and wait for
|
|
262
301
|
the person when:
|
|
@@ -269,6 +308,9 @@ the person when:
|
|
|
269
308
|
solution of the tenant, reaching the active solutions …`, after
|
|
270
309
|
`--include-tenant-wide` or on an instance that imports them anyway): every
|
|
271
310
|
solution of the tenant sees the change;
|
|
311
|
+
- the instance's preview lists query writes under
|
|
312
|
+
`database_queries.would_write`: its SQL changes what agents may read from
|
|
313
|
+
the tenant's database, even on a draft;
|
|
272
314
|
- the preview lists target needs (secrets, grants, identities): only a person
|
|
273
315
|
can provide them, with `cavelon secrets set <name>` or in the Admin, as the
|
|
274
316
|
preview names it.
|
|
@@ -280,6 +322,7 @@ trigger whose solution is not a draft (a run acts as the person and spends
|
|
|
280
322
|
budget), `limits set`, `models set-limit`, `trigger identity` (standing
|
|
281
323
|
authority for a trigger), `harness default`, `activate --make-default`,
|
|
282
324
|
`activate` of a solution its preview says a channel or trigger reaches,
|
|
325
|
+
whose activation takes the default route, or whose reach or route effect is unknown,
|
|
283
326
|
`deactivate` (they move live traffic), and `api` for any operation that is
|
|
284
327
|
not read-only, `cavelon` does not take your confirm as theirs. Their preview
|
|
285
328
|
says how in `needs_person`:
|
|
@@ -295,12 +338,25 @@ says how in `needs_person`:
|
|
|
295
338
|
in your session. Give them that command and wait; never run it yourself. A
|
|
296
339
|
token is refused (`confirm_needs_person`, exit code 5).
|
|
297
340
|
|
|
298
|
-
A new variable
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
341
|
+
A new variable needs no confirm. A solution needs none only when no channel
|
|
342
|
+
or active trigger reaches it and readiness explicitly publishes
|
|
343
|
+
`takes_default_route: false`. If the single read leaves `channel_count`
|
|
344
|
+
null, the kit reads the matching list row; an unreadable list, missing row
|
|
345
|
+
or missing count keeps reach unknown and needs the person.
|
|
346
|
+
|
|
347
|
+
Asking the person is the kit's responsibility alone. Keep asking before every
|
|
348
|
+
guarded change; never answer on their behalf or reuse a previous yes for a
|
|
349
|
+
different change. This includes creating, changing or deleting a database
|
|
350
|
+
query and imports that create or change one, even on a draft.
|
|
351
|
+
|
|
352
|
+
Where the instance publishes `confirmations.enforced`, after the person's
|
|
353
|
+
yes `cavelon` asks it for an id bound to the token, tenant and exact request
|
|
354
|
+
(method, path and canonical body) and sends it along; you never handle it.
|
|
355
|
+
It is audited, usable once and lasts 10 minutes. The same personal access
|
|
356
|
+
token can issue it and send the change, so the instance cannot verify that
|
|
357
|
+
the person answered. After their yes, make the change directly: there is no
|
|
358
|
+
extra Admin approval step. Database passwords and **Allow write queries**
|
|
359
|
+
remain person-only, set in the Admin. `confirmation_required`
|
|
304
360
|
or `confirmation_invalid` (exit code 5) means the instance changed nothing:
|
|
305
361
|
show the person the preview again and let them confirm it (in the client's
|
|
306
362
|
dialog or their own terminal), never retry on your own.
|
|
@@ -309,7 +365,8 @@ dialog or their own terminal), never retry on your own.
|
|
|
309
365
|
`variables_set` where it replaces a value, `loop_start`, `limits_set`,
|
|
310
366
|
`models_set_limit`, `loop_cancel`, `sandbox_seed`, `trigger_identity`,
|
|
311
367
|
`harness_default`, `deactivate`, `activate` of a solution a channel or
|
|
312
|
-
trigger reaches or
|
|
368
|
+
trigger reaches, whose activation takes the default route or whose reach or
|
|
369
|
+
route effect is unknown, or with `make_default`, and
|
|
313
370
|
`kb_upload` where it would deactivate documents return a `confirm_token` with
|
|
314
371
|
their preview. Show
|
|
315
372
|
the preview, then call the tool again with the same arguments and `confirm`
|
|
@@ -142,23 +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
|
-
-
|
|
146
|
-
|
|
147
|
-
`
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
`
|
|
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.
|
|
155
|
-
- A stored-procedure query (SQL Server) is test-run the same way; the
|
|
182
|
+
- A read stored-procedure query (SQL Server) is test-run the same way; the
|
|
156
183
|
instance refuses the run while the connection's login can write or the
|
|
157
184
|
procedure's definition writes or cannot be read, with a code
|
|
158
185
|
`cavelon explain` explains. A run whose procedure committed or rolled back
|
|
159
186
|
fails with `query_failed` and a `notice`: the query is switched off, and a
|
|
160
187
|
person fixes the procedure. `cavelon db test <connection>` lists the
|
|
161
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.
|
|
162
210
|
- `cavelon db runs <query>` lists each run's outcome and error code (never a
|
|
163
211
|
value or a row), and `cavelon trace` shows the code a failed call answered
|
|
164
212
|
the model with on the tool's span (`error_code`); `cavelon explain <code>`
|
|
@@ -262,6 +310,12 @@ the confirm command in their own terminal. When every suite passes,
|
|
|
262
310
|
`cavelon activate --harness <name or slug>` goes through the readiness gate; if the
|
|
263
311
|
token may not activate, a person activates in the Admin. A solution that a
|
|
264
312
|
channel or an active trigger reaches goes live for them at once, so its
|
|
265
|
-
activation previews first and needs the person's yes
|
|
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
|
|
266
320
|
client asks them when you confirm with its token, and from your shell they run
|
|
267
321
|
the confirm command in their own terminal.
|