@cavelon/cli 0.2.2 → 0.2.4
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 +12 -1
- package/dist/access.js +1 -0
- package/dist/automation-settings.js +35 -0
- package/dist/citus-functions.js +120 -0
- package/dist/command.js +1 -0
- package/dist/commands/api.js +10 -9
- package/dist/commands/db-connections.js +79 -9
- package/dist/commands/db-query-management.js +66 -0
- package/dist/commands/db.js +66 -20
- package/dist/commands/index.js +5 -0
- package/dist/commands/setup.js +112 -8
- package/dist/commands/solution.js +5 -3
- package/dist/database-queries.js +46 -1
- package/dist/database-write-paths.js +98 -0
- package/dist/kit-codes.js +1 -0
- package/dist/main.js +13 -1
- package/dist/mcp.js +3 -1
- package/dist/native-assets/manifest.json +1 -1
- package/dist/package-check.js +8 -0
- package/dist/setup-agents.js +91 -12
- package/dist/skills/cavelon-authoring/SKILL.md +24 -2
- package/dist/skills/cavelon-loop/SKILL.md +13 -3
- package/dist/skills/cavelon-testing/SKILL.md +18 -3
- package/dist/workflow-queries.js +1 -1
- package/package.json +1 -1
package/dist/commands/db.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { CURSOR_OPTION, intOption, LIMIT_OPTION, listOption, pageOf, positional, stringOption } from "../command.js";
|
|
2
|
-
import { CavelonError, ExitCode, usageError } from "../errors.js";
|
|
3
|
-
import { connectorOffer, isProcedureCall } from "../database-queries.js";
|
|
1
|
+
import { boolOption, CURSOR_OPTION, intOption, LIMIT_OPTION, listOption, pageOf, positional, stringOption } from "../command.js";
|
|
2
|
+
import { CavelonError, ExitCode, usageError, validationError } from "../errors.js";
|
|
3
|
+
import { connectorOffer, isProcedureCall, queryTools } from "../database-queries.js";
|
|
4
|
+
import { requireSolution, validatePackage } from "./solution.js";
|
|
4
5
|
import { requireFeature } from "../features.js";
|
|
5
6
|
import { clip, keyValues, moreHint, table } from "../format.js";
|
|
6
7
|
import { callStable } from "../invoke.js";
|
|
@@ -17,7 +18,7 @@ function reported(value) {
|
|
|
17
18
|
return value ? "yes" : "no";
|
|
18
19
|
return typeof value === "string" || typeof value === "number" ? value : undefined;
|
|
19
20
|
}
|
|
20
|
-
const WRITE_EVIDENCE = ["kind", "dry_run", "rolled_back", "affected_rows", "committed"];
|
|
21
|
+
const WRITE_EVIDENCE = ["kind", "dry_run", "rolled_back", "affected_rows", "committed", "surface", "redirect_hops", "redirect_target_class"];
|
|
21
22
|
const NO_WRITE_RETRY = "Do not retry an ambiguous write outcome. Check the database for the change before anyone repeats it.";
|
|
22
23
|
const FEATURE = "database_connector_enabled";
|
|
23
24
|
const DOCS_PAGE = "administration/database-connectors";
|
|
@@ -58,7 +59,7 @@ export async function resolveConnection(ctx, ref) {
|
|
|
58
59
|
hint: `\`${cavelonCommand("db", "connections")}\` lists them${all.length ? ` (${all.map((c) => c.name).slice(0, 10).join(", ")})` : "; the tenant Owner creates one with db connections create or in the Admin"}.`,
|
|
59
60
|
});
|
|
60
61
|
}
|
|
61
|
-
async function resolveQuery(ctx, ref) {
|
|
62
|
+
export async function resolveQuery(ctx, ref) {
|
|
62
63
|
await connectorOn(ctx);
|
|
63
64
|
if (isUuid(ref)) {
|
|
64
65
|
try {
|
|
@@ -100,7 +101,7 @@ function expiryWarnings(connections, now) {
|
|
|
100
101
|
? `expired on ${day(cert.not_after)}`
|
|
101
102
|
: `expires on ${day(cert.not_after)} (in ${days === 0 ? "less than a day" : `${days} day${days === 1 ? "" : "s"}`})`;
|
|
102
103
|
warnings.push(`The CA certificate "${cert.subject}" of the database connection "${c.name}" ${when}: from then its TLS check fails, and with it the connection's queries. ` +
|
|
103
|
-
`
|
|
104
|
+
`A person replaces the CA certificate in the Admin under Settings › Security & access › Databases, then tests the connection again: ${cavelonCommand("db", "test", c.name)}`);
|
|
104
105
|
}
|
|
105
106
|
}
|
|
106
107
|
return warnings;
|
|
@@ -194,10 +195,13 @@ export const dbInstance = {
|
|
|
194
195
|
["connections_per_process", offer.network.connections_per_process],
|
|
195
196
|
["write_queries", reported(offer.write_queries)],
|
|
196
197
|
["max_affected_rows_limit", reported(offer.max_affected_rows_limit)],
|
|
198
|
+
["kerberos_dialects", offer.kerberos_dialects?.join(", ")],
|
|
199
|
+
["ssh_tunnels", reported(offer.ssh_tunnels)],
|
|
197
200
|
]),
|
|
198
201
|
"",
|
|
199
202
|
firewall,
|
|
200
203
|
...(counts.length ? ["", databaseLimitsText(counts)] : []),
|
|
204
|
+
...(offer.network.private_targets ? ["", "Private targets (managed by a platform operator in the Admin):", table(offer.network.private_targets, ["cidr", "ports", "source", "usable"]) || "none"] : []),
|
|
201
205
|
...(offer.runnable_dialects.length ? [] : ["", "This instance runs no database dialect: a connection can be saved, but its test and queries answer unavailable."]),
|
|
202
206
|
].join("\n"),
|
|
203
207
|
};
|
|
@@ -244,6 +248,7 @@ export const dbConnections = {
|
|
|
244
248
|
data: page,
|
|
245
249
|
text: (table(rows, ["name", "dialect", "target", "tls", "enabled", ...(rows.some(c => "allows_writes" in c) ? ["allows_writes"] : []), "last_test", "queries", "id"]) ||
|
|
246
250
|
`No database connections. The tenant Owner creates one with db connections create or in the Admin (\`${cavelonCommand("docs", "get", DOCS_PAGE)}\` says who does what).`) +
|
|
251
|
+
connections.filter(c => c.ssh_tunnel).map(c => `\n\n${c.name}: SSH bastion ${c.ssh_tunnel.username}@${c.ssh_tunnel.host}:${c.ssh_tunnel.port}${c.ssh_tunnel.authorized_keys_entry ? `\nInstall this exact authorized_keys entry on the bastion:\n${c.ssh_tunnel.authorized_keys_entry}` : "\nA person sets its SSH key in the Admin."}`).join("") +
|
|
247
252
|
caLines(connections).join("\n") +
|
|
248
253
|
moreHint(page.next_cursor, cavelonCommand("db", "connections")) +
|
|
249
254
|
(untested.length ? `\n\nNot tested successfully: ${untested.join(", ")}; its queries are not ready for agents. The Owner tests one with: ${cavelonCommand("db", "test", fill("connection"))}` : "") +
|
|
@@ -417,7 +422,10 @@ export const dbTest = {
|
|
|
417
422
|
throw ownerOnly(error, "A connection test");
|
|
418
423
|
}
|
|
419
424
|
const ok = result.outcome === "ok";
|
|
420
|
-
const steps = (result.steps ?? []).map((s) => ({ step: s.name, status: s.status, code: s.code ?? null,
|
|
425
|
+
const steps = (result.steps ?? []).map((s) => ({ step: s.name, status: s.status, code: s.code ?? null,
|
|
426
|
+
engine: s.detail?.engine ?? null, private_target_id: s.detail?.private_target_id ?? null,
|
|
427
|
+
redirects: s.detail?.redirects === undefined ? null : clip(JSON.stringify(s.detail.redirects), 300),
|
|
428
|
+
message: s.driver_message ? clip(s.driver_message, 160) : null }));
|
|
421
429
|
const findings = (Array.isArray(result.procedure_findings) ? result.procedure_findings : []).map((f) => ({
|
|
422
430
|
query: f.slug ?? f.query_id ?? "?",
|
|
423
431
|
code: f.code ?? null,
|
|
@@ -430,7 +438,7 @@ export const dbTest = {
|
|
|
430
438
|
}
|
|
431
439
|
const text = [
|
|
432
440
|
`Connection "${connection.name}" (${connection.dialect}): ${ok ? "test passed" : `test failed (${result.outcome})`}, ${result.duration_ms} ms.`,
|
|
433
|
-
table(steps, ["step", "status", "code", ...(steps.some((s) => s.message) ? ["message"] : [])], 80),
|
|
441
|
+
table(steps, ["step", "status", "code", ...["engine", "private_target_id", "redirects"].filter(k => steps.some(s => s[k] !== null)), ...(steps.some((s) => s.message) ? ["message"] : [])], 80),
|
|
434
442
|
...(result.server_version ? [`server: ${result.server_version}`] : []),
|
|
435
443
|
...(result.write_privileges ? [`write privileges: ${clip(JSON.stringify(result.write_privileges), 300)}`] : []),
|
|
436
444
|
...(findings.length
|
|
@@ -522,8 +530,10 @@ function runValues(query, given) {
|
|
|
522
530
|
const ROWS_SHOWN = 20;
|
|
523
531
|
export const dbTestRun = {
|
|
524
532
|
name: "db test-run",
|
|
525
|
-
summary: "
|
|
526
|
-
description: "
|
|
533
|
+
summary: "Test a saved query, or validate and test unsaved package SQL with --draft; show model output and rows.",
|
|
534
|
+
description: "With --draft, reads the tool slug from package/, validates first and tests without saving or applying. Needs\n" +
|
|
535
|
+
"database_connectors.manage with the Owner's personal access token or the Admin; an API key cannot run a draft.\n" +
|
|
536
|
+
"Needs the tenant Owner's permission (database_connectors.test); it reads the customer's own data. Give each parameter\n" +
|
|
527
537
|
"with --value name=value, those the platform fills from the signed-in visitor (end_user.*) too: that is how an\n" +
|
|
528
538
|
"identity-scoped query is checked for one customer. A list parameter takes a JSON array (--value 'skus=[\"X-1\",\"X-2\"]'),\n" +
|
|
529
539
|
"one to max_items items of its type; the instance checks each item and names a refused one by position, never its value.\n" +
|
|
@@ -540,31 +550,37 @@ export const dbTestRun = {
|
|
|
540
550
|
"switched off.",
|
|
541
551
|
readOnly: false,
|
|
542
552
|
idempotent: true,
|
|
543
|
-
mcpEffect: "Tests
|
|
553
|
+
mcpEffect: "Tests a saved query or unsaved package definition once on the instance; writes are dry runs that roll back. The instance keeps audit evidence and changes no setting or saved query. Never retry an ambiguous write outcome.",
|
|
544
554
|
mcpTool: "db_test_run",
|
|
545
|
-
operations: ["POST /api/v1/database-connectors/queries/{query_id}/test-run"],
|
|
555
|
+
operations: ["POST /api/v1/database-connectors/queries/{query_id}/test-run", "POST /api/v1/database-connectors/queries/test-run"],
|
|
556
|
+
operationsAreAlternatives: true,
|
|
546
557
|
positionals: [{ name: "query", description: "The query's tool slug or id.", required: true }],
|
|
547
558
|
options: {
|
|
559
|
+
draft: { type: "boolean", description: "Validate package/ and test its unsaved query definition before apply (database_connectors.manage)." },
|
|
548
560
|
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." },
|
|
549
561
|
rows: { type: "string", value: "<n>", description: `Show at most n rows in the text (default ${ROWS_SHOWN}); --json carries what the instance returned.` },
|
|
550
562
|
},
|
|
551
563
|
examples: [
|
|
564
|
+
"cavelon db test-run order_status --draft --value order_no=A-10023 --value email=ada@example.com",
|
|
552
565
|
"cavelon db test-run order_status --value order_no=A-10023 --value email=ada@example.com",
|
|
553
566
|
"cavelon db test-run stock --value sku=4711 --json",
|
|
554
567
|
`cavelon db test-run stock_of_skus --value 'skus=["X-1","X-2"]'`,
|
|
555
568
|
],
|
|
556
569
|
async run(ctx, input) {
|
|
557
|
-
const
|
|
558
|
-
|
|
570
|
+
const draft = boolOption(input, "draft");
|
|
571
|
+
const ref = positional(input, "query");
|
|
572
|
+
const local = draft ? await draftQuery(ctx, ref) : undefined;
|
|
573
|
+
const query = local?.query ?? await resolveQuery(ctx, ref);
|
|
574
|
+
if (!draft && query.parameters.some(p => p.source?.startsWith("end_user."))) {
|
|
559
575
|
requirePersonForIdentityChoice(await accessFor(await ctx.client()), "POST /api/v1/database-connectors/queries/{query_id}/test-run", "test a query with end_user.* parameters");
|
|
560
576
|
}
|
|
561
577
|
const values = runValues(query, listOption(input, "value"));
|
|
562
578
|
const shown = intOption(input, "rows", { min: 0, max: 500, fallback: ROWS_SHOWN });
|
|
563
579
|
let result;
|
|
564
580
|
try {
|
|
565
|
-
result = await callStable(ctx, "POST", "/api/v1/database-connectors/queries/{query_id}/test-run", "test runs of database queries", {
|
|
566
|
-
params: { query_id: [query.id] },
|
|
567
|
-
body: { values },
|
|
581
|
+
result = await callStable(ctx, "POST", draft ? "/api/v1/database-connectors/queries/test-run" : "/api/v1/database-connectors/queries/{query_id}/test-run", "test runs of database queries", {
|
|
582
|
+
params: draft ? undefined : { query_id: [query.id] },
|
|
583
|
+
body: { ...local?.body, values },
|
|
568
584
|
timeoutMs: 90_000,
|
|
569
585
|
});
|
|
570
586
|
}
|
|
@@ -572,7 +588,7 @@ export const dbTestRun = {
|
|
|
572
588
|
if (query.kind === "write" && error instanceof CavelonError && (error.code === "network_error" || error.code === "request_timeout")) {
|
|
573
589
|
throw new CavelonError(error.exitCode, { code: error.code, status: error.status, message: error.message, hint: NO_WRITE_RETRY, docs: error.docs, details: error.details });
|
|
574
590
|
}
|
|
575
|
-
throw refusedRun(ownerOnly(error, "A test run"), query);
|
|
591
|
+
throw refusedRun(draft ? withPermissionHint(error, "A draft query test needs database_connectors.manage with the tenant Owner's personal access token or the Admin; an API key cannot run it.") : ownerOnly(error, "A test run"), query);
|
|
576
592
|
}
|
|
577
593
|
const ok = result.outcome === "ok" && !result.error_code;
|
|
578
594
|
const columns = result.columns ?? [];
|
|
@@ -580,7 +596,7 @@ export const dbTestRun = {
|
|
|
580
596
|
const more = (result.rows?.length ?? 0) - rows.length;
|
|
581
597
|
const text = [
|
|
582
598
|
keyValues([
|
|
583
|
-
["query", `${query.slug} (version ${query.version})`],
|
|
599
|
+
["query", `${query.slug} (${draft ? "unsaved draft" : `version ${query.version}`})`],
|
|
584
600
|
["outcome", result.error_code ? `${result.outcome} (${result.error_code}${result.sqlstate ? `, SQLSTATE ${result.sqlstate}` : ""})` : result.outcome],
|
|
585
601
|
["rows", ok ? `${result.returned_rows ?? rows.length} returned of ${result.row_count ?? "?"}${result.truncated ? ", truncated for the model" : ""}` : undefined],
|
|
586
602
|
["duration_ms", result.duration_ms],
|
|
@@ -594,9 +610,39 @@ export const dbTestRun = {
|
|
|
594
610
|
...(more > 0 ? [`… ${more} more rows (--rows, or --json).`] : []),
|
|
595
611
|
].join("\n");
|
|
596
612
|
return {
|
|
597
|
-
data: { query: { id: query.id,
|
|
613
|
+
data: { query: { ...(draft ? { draft: true } : { id: query.id, version: query.version }), slug: query.slug }, ...result },
|
|
598
614
|
text: text + explainLine([result.error_code]) + (result.error_code === "write_outcome_unknown" ? `\n\n${NO_WRITE_RETRY}` : ""),
|
|
599
615
|
exitCode: ok ? ExitCode.ok : ExitCode.validation,
|
|
600
616
|
};
|
|
601
617
|
},
|
|
602
618
|
};
|
|
619
|
+
async function draftQuery(ctx, ref) {
|
|
620
|
+
await connectorOn(ctx);
|
|
621
|
+
const access = await accessFor(await ctx.client());
|
|
622
|
+
if (access?.kind === "api_key")
|
|
623
|
+
throw new CavelonError(ExitCode.needsAction, {
|
|
624
|
+
code: "key_needs_a_person", message: "An API key cannot test an unsaved database query. Nothing was sent.",
|
|
625
|
+
hint: "Use the tenant Owner's personal access token with database_connectors.manage, or test the draft in the Admin.",
|
|
626
|
+
});
|
|
627
|
+
const project = requireSolution(await ctx.session());
|
|
628
|
+
const { disk, findings } = await validatePackage(ctx, project, false);
|
|
629
|
+
const errors = findings.filter(f => f.severity === "error");
|
|
630
|
+
if (errors.length)
|
|
631
|
+
throw validationError("The package has validation errors; the draft was not run.", { findings: errors }, "Run cavelon validate and fix the named fields first.");
|
|
632
|
+
for (const finding of findings.filter(f => f.severity === "warning"))
|
|
633
|
+
ctx.warn(`${finding.code}: ${finding.message}`);
|
|
634
|
+
const tool = queryTools(disk.package).find(t => t.slug === ref);
|
|
635
|
+
if (!tool)
|
|
636
|
+
throw usageError(`No database query tool "${ref}" in package/.`, "--draft takes the package tool's slug, not a saved query id.");
|
|
637
|
+
const definition = tool.tool.database_query;
|
|
638
|
+
const target = definition.connection;
|
|
639
|
+
const connection = await resolveConnection(ctx, target.name);
|
|
640
|
+
if (connection.dialect !== target.dialect)
|
|
641
|
+
throw validationError(`Connection "${target.name}" uses ${connection.dialect}, but the draft names ${target.dialect}.`);
|
|
642
|
+
const body = { connection_id: connection.id, slug: tool.slug };
|
|
643
|
+
for (const field of ["sql_text", "parameters", "max_rows", "max_result_chars", "kind", "max_affected_rows"]) {
|
|
644
|
+
if (definition[field] !== undefined)
|
|
645
|
+
body[field] = definition[field];
|
|
646
|
+
}
|
|
647
|
+
return { query: { slug: tool.slug, connection_name: connection.name, parameters: (definition.parameters ?? []), kind: definition.kind }, body };
|
|
648
|
+
}
|
package/dist/commands/index.js
CHANGED
|
@@ -16,6 +16,7 @@ import { harnessClone, harnessDefault, harnessList, harnessNew, tenantCreate, te
|
|
|
16
16
|
import { kbUpload, testRun, trace } from "./work.js";
|
|
17
17
|
import { dbConnections, dbInstance, dbQueries, dbRuns, dbTest, dbTestRun } from "./db.js";
|
|
18
18
|
import { dbConnectionCa, dbConnectionCreate, dbConnectionDelete, dbConnectionUpdate, dbLoginScript, dbSchema } from "./db-connections.js";
|
|
19
|
+
import { dbQueryDelete, dbQueryEnable, dbQueryDisable, dbQueryRename } from "./db-query-management.js";
|
|
19
20
|
import { secretsDelete, secretsList, secretsSet, variablesDelete, variablesGet, variablesList, variablesSet } from "./values.js";
|
|
20
21
|
import { loopCancel, loopIterations, loopPause, loopResume, loopStart, loopWatch, triggerIdentity } from "./loops.js";
|
|
21
22
|
import { artifactsExport, sandboxActivity, sandboxCat, sandboxFiles, sandboxList, sandboxLogs, sandboxReceipt, sandboxRefresh, sandboxSeed, sandboxValidate, } from "./sandboxes.js";
|
|
@@ -116,6 +117,10 @@ export const COMMANDS = [
|
|
|
116
117
|
dbLoginScript,
|
|
117
118
|
dbSchema,
|
|
118
119
|
dbQueries,
|
|
120
|
+
dbQueryDelete,
|
|
121
|
+
dbQueryEnable,
|
|
122
|
+
dbQueryDisable,
|
|
123
|
+
dbQueryRename,
|
|
119
124
|
dbRuns,
|
|
120
125
|
dbTest,
|
|
121
126
|
dbTestRun,
|
package/dist/commands/setup.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { promises as fs } from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
|
-
import { boolOption, listOption } from "../command.js";
|
|
3
|
+
import { boolOption, listOption, stringOption } from "../command.js";
|
|
4
|
+
import { agentVariable } from "../agent-env.js";
|
|
5
|
+
import { readMcpMode, saveMcpMode } from "../automation-settings.js";
|
|
6
|
+
import { findProject } from "../project.js";
|
|
7
|
+
import { init } from "./init.js";
|
|
4
8
|
import { createContext } from "../context.js";
|
|
5
9
|
import { asCavelonError, CavelonError, ExitCode, usageError } from "../errors.js";
|
|
6
10
|
import { readJsonFile, writeFileAtomic } from "../fsutil.js";
|
|
@@ -123,11 +127,11 @@ function normalizeAddress(raw) {
|
|
|
123
127
|
return undefined;
|
|
124
128
|
}
|
|
125
129
|
}
|
|
126
|
-
async function loginStep(ctx) {
|
|
130
|
+
async function loginStep(ctx, nonInteractive = false) {
|
|
127
131
|
const session = await ctx.session();
|
|
128
132
|
if (session.url && session.token)
|
|
129
133
|
return { status: "already", instance: session.url, text: `Already logged in to ${session.url}.` };
|
|
130
|
-
if (!canAsk(ctx)) {
|
|
134
|
+
if (!canAsk(ctx) || nonInteractive) {
|
|
131
135
|
return {
|
|
132
136
|
status: "not_logged_in",
|
|
133
137
|
instance: session.url ?? null,
|
|
@@ -189,13 +193,13 @@ async function runSetup(ctx, input) {
|
|
|
189
193
|
const state = await loadState(env);
|
|
190
194
|
const plans = [];
|
|
191
195
|
for (const { agent, found: where } of chosen)
|
|
192
|
-
plans.push(await planAgent(agent, where, env, command, skills, process.platform, state.agents[agent.name]));
|
|
196
|
+
plans.push(await planAgent(agent, where, env, command, skills, process.platform, state.agents[agent.name], boolOption(input, "update")));
|
|
193
197
|
const pending = plans.some((p) => p.changes.some((c) => c.outcome === "planned"));
|
|
194
198
|
let results = plans.map((plan) => ({ plan, changes: plan.changes }));
|
|
195
199
|
let declined = false;
|
|
196
200
|
if (pending) {
|
|
197
201
|
if (!boolOption(input, "yes")) {
|
|
198
|
-
if (!canAsk(ctx)) {
|
|
202
|
+
if (!canAsk(ctx) || boolOption(input, "non-interactive")) {
|
|
199
203
|
if (!ctx.json)
|
|
200
204
|
ctx.io.stderr.write(`cavelon setup would change this:\n${planText(plans, notFound)}\n`);
|
|
201
205
|
throw confirmationRequired("setup changes your coding agents' settings only when you agree", { agents: plans.map((p) => planJson(p)), server: command });
|
|
@@ -222,7 +226,7 @@ async function runSetup(ctx, input) {
|
|
|
222
226
|
}
|
|
223
227
|
if (recovered)
|
|
224
228
|
await saveState(env, state);
|
|
225
|
-
const loginReport = declined ? undefined : await loginStep(ctx);
|
|
229
|
+
const loginReport = declined || boolOption(input, "update") ? undefined : await loginStep(ctx, boolOption(input, "non-interactive"));
|
|
226
230
|
const failed = results.some((r) => r.changes.some((c) => c.outcome === "failed"));
|
|
227
231
|
const ready = results.filter((r) => r.changes.length && r.changes.every((c) => c.outcome === "done" || c.outcome === "unchanged"));
|
|
228
232
|
const changed = results.filter((r) => r.changes.some((c) => c.outcome === "done"));
|
|
@@ -269,6 +273,85 @@ async function runSetup(ctx, input) {
|
|
|
269
273
|
exitCode,
|
|
270
274
|
};
|
|
271
275
|
}
|
|
276
|
+
async function runUpdate(ctx, input) {
|
|
277
|
+
const project = await findProject(ctx.io.cwd);
|
|
278
|
+
if (project && !boolOption(input, "yes")) {
|
|
279
|
+
if (!canAsk(ctx) || boolOption(input, "non-interactive"))
|
|
280
|
+
throw confirmationRequired("updating also refreshes the current solution's generated setup", { solution: project.root });
|
|
281
|
+
if (!(await confirm(ctx, `Update Cavelon plugins, owned skills and generated setup in ${project.root}?`, true))) {
|
|
282
|
+
return { data: { agents: [], not_found: [], server: await serverCommand(ctx.io.env), declined: true, login: null, next: [] }, text: "Nothing was changed.", exitCode: ExitCode.ok };
|
|
283
|
+
}
|
|
284
|
+
input = { ...input, options: { ...input.options, yes: true } };
|
|
285
|
+
}
|
|
286
|
+
const result = await runSetup(ctx, input);
|
|
287
|
+
if (result.data.declined || !project)
|
|
288
|
+
return result;
|
|
289
|
+
try {
|
|
290
|
+
const project = await init.run(ctx, { positionals: {}, options: { update: true } });
|
|
291
|
+
return { ...result, data: { ...result.data, project: project.data }, text: `${result.text}\n\nCurrent solution:\n${project.text}` };
|
|
292
|
+
}
|
|
293
|
+
catch (error) {
|
|
294
|
+
const err = asCavelonError(error);
|
|
295
|
+
return { ...result, data: { ...result.data, project_error: err.toJSON() }, text: `${result.text}\n\nCurrent solution update failed: ${err.message}`, exitCode: err.exitCode };
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
function interactiveSetup(ctx, input) {
|
|
299
|
+
return canAsk(ctx) && !boolOption(input, "non-interactive") && !agentVariable(ctx.io.env) && !/^(1|true|yes)$/i.test(ctx.io.env.CI ?? "");
|
|
300
|
+
}
|
|
301
|
+
async function chooseMcpMode(ctx, current) {
|
|
302
|
+
ctx.io.stderr.write(`\nMCP YOLO is currently ${current === "yolo" ? "enabled" : "disabled"}. It combines preview and execution for eligible routine changes in the session's selected target. Critical changes still ask for approval.\n`);
|
|
303
|
+
for (;;) {
|
|
304
|
+
const answer = (await readLine(ctx.io, "YOLO for new agent sessions: [y] enable, [n] disable, [Enter] keep current: ")).toLowerCase();
|
|
305
|
+
if (!answer)
|
|
306
|
+
return undefined;
|
|
307
|
+
if (["y", "yes", "j", "ja"].includes(answer))
|
|
308
|
+
return "yolo";
|
|
309
|
+
if (["n", "no", "nein"].includes(answer))
|
|
310
|
+
return "standard";
|
|
311
|
+
ctx.io.stderr.write("Please choose y, n, or Enter.\n");
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
async function offerMcpMode(ctx, input, result) {
|
|
315
|
+
if (!interactiveSetup(ctx, input) || boolOption(input, "yes") || result.data.declined)
|
|
316
|
+
return result;
|
|
317
|
+
try {
|
|
318
|
+
const current = await readMcpMode(ctx.io.env);
|
|
319
|
+
const mode = await chooseMcpMode(ctx, current);
|
|
320
|
+
const changed = mode ? await saveMcpMode(ctx.io.env, mode) : false;
|
|
321
|
+
return { ...result, data: { ...result.data, mcp_mode: mode ?? current, mode_changed: changed }, text: `${result.text}\n\nMCP startup mode: ${mode ?? current}. Restart your coding agent to apply the installed CLI, skills and startup mode.` };
|
|
322
|
+
}
|
|
323
|
+
catch (error) {
|
|
324
|
+
const err = asCavelonError(error);
|
|
325
|
+
return { ...result, data: { ...result.data, mode_error: err.toJSON() }, text: `${result.text}\n\nMCP mode selection incomplete: ${err.message}`, exitCode: err.exitCode };
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
async function runFollowUp(ctx, input) {
|
|
329
|
+
const installer = boolOption(input, "installer");
|
|
330
|
+
let update = boolOption(input, "update");
|
|
331
|
+
let mode = stringOption(input, "mcp-mode");
|
|
332
|
+
const current = await readMcpMode(ctx.io.env);
|
|
333
|
+
const interactive = interactiveSetup(ctx, input);
|
|
334
|
+
if (installer && interactive) {
|
|
335
|
+
if (!update && !boolOption(input, "skip-update"))
|
|
336
|
+
update = await confirm(ctx, "Set up or update Cavelon plugins and skills in your coding agents (and this solution, if present)?", true);
|
|
337
|
+
if (!mode)
|
|
338
|
+
mode = await chooseMcpMode(ctx, current);
|
|
339
|
+
}
|
|
340
|
+
if (!installer && mode && mode !== current && !boolOption(input, "yes")) {
|
|
341
|
+
if (!interactive)
|
|
342
|
+
throw confirmationRequired("the personal MCP startup mode changes only when you agree", { mcp_mode: mode });
|
|
343
|
+
if (!(await confirm(ctx, `Set the MCP startup mode to ${mode}? Critical changes still ask for approval.`, false)))
|
|
344
|
+
mode = undefined;
|
|
345
|
+
}
|
|
346
|
+
const changed = mode ? await saveMcpMode(ctx.io.env, mode) : false;
|
|
347
|
+
const selected = mode ?? current;
|
|
348
|
+
const report = update ? await runUpdate(ctx, { ...input, options: { ...input.options, update: true, ...(installer ? { yes: true } : {}) } }) : undefined;
|
|
349
|
+
return {
|
|
350
|
+
data: { updated_agents: Boolean(report && !report.data.declined && report.exitCode === ExitCode.ok), mcp_mode: selected, mode_changed: changed, ...(report ? { update: report.data } : {}) },
|
|
351
|
+
text: [report?.text, `MCP startup mode: ${selected}.`, "Next: restart your coding agent or reconnect its Cavelon tools to use the installed CLI, skills and startup mode.", ...(!update ? ["Run cavelon setup --update to refresh plugins and skills later; cavelon setup also guides first-time login."] : [])].filter(Boolean).join("\n\n"),
|
|
352
|
+
exitCode: report?.exitCode ?? ExitCode.ok,
|
|
353
|
+
};
|
|
354
|
+
}
|
|
272
355
|
function joinLabels(labels, word = "and") {
|
|
273
356
|
if (labels.length <= 1)
|
|
274
357
|
return labels.join("");
|
|
@@ -421,12 +504,20 @@ export const setup = {
|
|
|
421
504
|
"The server starts as `cavelon mcp` when cavelon is installed, otherwise through npx. --check reports what is set up and\n" +
|
|
422
505
|
"working: each agent's entry, the MCP server starting, and the login. An agent found but never set up for Cavelon is\n" +
|
|
423
506
|
"reported and skipped (exit 0 when the rest works); --strict, or naming it with --agents, counts it.\n" +
|
|
424
|
-
"
|
|
507
|
+
"--update refreshes plugins and owned skills, including the current solution's generated setup, and keeps your login.\n" +
|
|
508
|
+
"--mcp-mode saves a personal startup choice; restart your coding agent to apply it. Critical changes still need approval.\n" +
|
|
509
|
+
"Interactive setup and --update also offer the YOLO choice; Enter preserves it. --yes keeps it unless --mcp-mode is given.\n" +
|
|
510
|
+
"Without a terminal it changes nothing unless --yes, or explicit --installer update/mode choices are given.",
|
|
425
511
|
readOnly: false,
|
|
426
512
|
destructive: true,
|
|
427
513
|
idempotent: true,
|
|
428
514
|
mcpTool: false,
|
|
429
515
|
options: {
|
|
516
|
+
update: { type: "boolean", description: "Refresh agent plugins, owned skills and the current solution's generated setup; keep your login." },
|
|
517
|
+
"mcp-mode": { type: "string", value: "<standard|yolo>", description: "Save the personal mode for new MCP sessions, without editing agent launch commands. Critical changes still need approval." },
|
|
518
|
+
installer: { type: "boolean", description: "Installer follow-up: ask separately about agent updates and YOLO. Without a terminal, keep both unless explicitly selected." },
|
|
519
|
+
"skip-update": { type: "boolean", description: "With --installer: skip the agent update question and leave plugins and skills unchanged." },
|
|
520
|
+
"non-interactive": { type: "boolean", description: "Never ask questions. Installer choices must be passed explicitly; other changes still require --yes." },
|
|
430
521
|
agents: {
|
|
431
522
|
type: "string",
|
|
432
523
|
value: "<list>",
|
|
@@ -442,6 +533,8 @@ export const setup = {
|
|
|
442
533
|
"cavelon setup",
|
|
443
534
|
"cavelon setup --agents claude,codex --instance https://cavelon.example.com --yes",
|
|
444
535
|
"cavelon setup --check",
|
|
536
|
+
"cavelon setup --update",
|
|
537
|
+
"cavelon setup --mcp-mode yolo --yes",
|
|
445
538
|
"cavelon setup --remove",
|
|
446
539
|
],
|
|
447
540
|
async run(ctx, input) {
|
|
@@ -449,10 +542,21 @@ export const setup = {
|
|
|
449
542
|
throw usageError("--check and --remove do not go together.");
|
|
450
543
|
if (boolOption(input, "strict") && !boolOption(input, "check"))
|
|
451
544
|
throw usageError("--strict goes with --check.");
|
|
545
|
+
const followUp = boolOption(input, "installer") || stringOption(input, "mcp-mode") !== undefined;
|
|
546
|
+
if ((followUp || boolOption(input, "update")) && (boolOption(input, "check") || boolOption(input, "remove")))
|
|
547
|
+
throw usageError("Update and MCP mode options do not go with --check or --remove.");
|
|
548
|
+
if (boolOption(input, "skip-update") && (!boolOption(input, "installer") || boolOption(input, "update")))
|
|
549
|
+
throw usageError("--skip-update requires --installer and cannot be combined with --update.");
|
|
550
|
+
if (stringOption(input, "mcp-mode") !== undefined && !["standard", "yolo"].includes(stringOption(input, "mcp-mode")))
|
|
551
|
+
throw usageError("--mcp-mode must be standard or yolo.");
|
|
452
552
|
if (boolOption(input, "check"))
|
|
453
553
|
return runCheck(ctx, input);
|
|
454
554
|
if (boolOption(input, "remove"))
|
|
455
555
|
return runRemove(ctx, input);
|
|
456
|
-
|
|
556
|
+
if (followUp)
|
|
557
|
+
return runFollowUp(ctx, input);
|
|
558
|
+
if (boolOption(input, "update"))
|
|
559
|
+
return offerMcpMode(ctx, input, await runUpdate(ctx, input));
|
|
560
|
+
return offerMcpMode(ctx, input, await runSetup(ctx, input));
|
|
457
561
|
},
|
|
458
562
|
};
|
|
@@ -17,6 +17,7 @@ import { defaultChangeLine, defaultCommands, named, readDefaultRoute, setDefault
|
|
|
17
17
|
import { ceilingHint, LIMIT_ABOVE_CEILING, parseLimits, readLimits } from "../limits.js";
|
|
18
18
|
import { digest, fileDigest, fileDigests, listPreviews, loadPreview, previewExpiry, readItemFiles, readPulledFiles, rememberAppliedFiles, retiredPreview, retirePreviews, savePreview, writePulledFiles, writeState, } from "../local-state.js";
|
|
19
19
|
import { catalogEntry, checkPackage, KIT_CODES, packageVersionOf } from "../package-check.js";
|
|
20
|
+
import { WRITE_PATH_HINT } from "../database-write-paths.js";
|
|
20
21
|
import { applyQueryNotes, connectorOffer, importWritesQueries, NEEDS_SUPERADMIN_CODE, queryBlockedHint, queryChanges, queryTools, readQueryBaseline, rememberQueries, schemaKnowsWrites } from "../database-queries.js";
|
|
21
22
|
import { yoloAllows } from "../automation-policy.js";
|
|
22
23
|
import { cliFix, similarCodes } from "../code-hints.js";
|
|
@@ -330,7 +331,7 @@ async function inventoryFor(ctx, project, disk, offline, schema) {
|
|
|
330
331
|
}));
|
|
331
332
|
return { inventory, skipped };
|
|
332
333
|
}
|
|
333
|
-
async function validatePackage(ctx, project, offline) {
|
|
334
|
+
export async function validatePackage(ctx, project, offline) {
|
|
334
335
|
const disk = await readPackage(project.root, project.layout);
|
|
335
336
|
const version = packageVersionOf(disk.package) ?? project.packageVersion;
|
|
336
337
|
const { schema, used } = await schemaFor(ctx, version, offline);
|
|
@@ -1362,8 +1363,9 @@ export const explain = {
|
|
|
1362
1363
|
const read = capacity ? (await listedPages(ctx, pages)).map((page) => ({ page, command: cavelonCommand("docs", "get", page) })) : [];
|
|
1363
1364
|
const fix = cliFix(entry);
|
|
1364
1365
|
const cli = entry.kind === "cli" || !fix ? undefined : spoken(fix);
|
|
1365
|
-
const
|
|
1366
|
-
const
|
|
1366
|
+
const writeAdvice = entry.code === "confirmation_unavailable" && catalog?.api_error_codes?.some(e => e.code === "write_needs_confirmation");
|
|
1367
|
+
const hint = writeAdvice ? WRITE_PATH_HINT : entry.hint ? spoken(entry.hint) : entry.hint;
|
|
1368
|
+
const data = { ...entry, hint, ...(writeAdvice ? { instance_hint: entry.hint } : {}), ...(entry.area === KNOWLEDGE_OUTCOME_AREA ? { kind: "knowledge_outcome" } : {}), docs, ...(cli ? { cli_fix: cli } : {}), ...(kitHint ? { kit_hint: kitHint } : {}), ...(read.length ? { read } : {}) };
|
|
1367
1369
|
return {
|
|
1368
1370
|
data,
|
|
1369
1371
|
text: keyValues([
|
package/dist/database-queries.js
CHANGED
|
@@ -2,6 +2,7 @@ import { readJsonFile } from "./fsutil.js";
|
|
|
2
2
|
import { statePath, writeState } from "./local-state.js";
|
|
3
3
|
import { locate } from "./package-files.js";
|
|
4
4
|
import { canonical, settledForm } from "./package-format.js";
|
|
5
|
+
import { CITUS_ADMIN_FUNCTIONS } from "./citus-functions.js";
|
|
5
6
|
export const QUERY_TOOL_TYPE = "database_query";
|
|
6
7
|
const QUERY_FIELD = "database_query";
|
|
7
8
|
const TOOLS_SECTION = "tools";
|
|
@@ -443,6 +444,50 @@ export function oracleQueryProblem(sql, dialect, write) {
|
|
|
443
444
|
}
|
|
444
445
|
return undefined;
|
|
445
446
|
}
|
|
447
|
+
export function citusQueryProblem(sql, dialect, write) {
|
|
448
|
+
if (dialect !== "postgresql")
|
|
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
|
+
if (code.some((t, i) => t.kind === "semicolon" && i !== code.length - 1))
|
|
455
|
+
return undefined;
|
|
456
|
+
if (write ? !isWord(code[0], "INSERT", "UPDATE", "DELETE") : !isWord(code.find(t => !isSymbol(t, "(")), "SELECT", "WITH") || commonReadRefusal(code))
|
|
457
|
+
return undefined;
|
|
458
|
+
const nameOf = (t) => t?.kind === "word" ? t.text.toLowerCase() : t?.kind === "identifier" && t.text.startsWith('"') ? t.text.slice(1, -1).replaceAll('""', '"').toLowerCase() : undefined;
|
|
459
|
+
for (let i = 0; i < code.length - 1; i++) {
|
|
460
|
+
const name = nameOf(code[i]);
|
|
461
|
+
if (!name || !isSymbol(code[i + 1], "("))
|
|
462
|
+
continue;
|
|
463
|
+
let before = i - 1;
|
|
464
|
+
let schema;
|
|
465
|
+
if (isSymbol(code[before], ".")) {
|
|
466
|
+
schema = nameOf(code[before - 1]);
|
|
467
|
+
before -= 2;
|
|
468
|
+
}
|
|
469
|
+
if (schema !== undefined && schema !== "pg_catalog" && schema !== "citus_internal")
|
|
470
|
+
continue;
|
|
471
|
+
if (isWord(code[before], "INTO", "AS"))
|
|
472
|
+
continue;
|
|
473
|
+
let depth = 0;
|
|
474
|
+
let after = i + 1;
|
|
475
|
+
for (; after < code.length; after++) {
|
|
476
|
+
if (isSymbol(code[after], "("))
|
|
477
|
+
depth++;
|
|
478
|
+
if (isSymbol(code[after], ")") && --depth === 0) {
|
|
479
|
+
after++;
|
|
480
|
+
break;
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
if (isWord(code[after], "AS") && (isSymbol(code[after + 1], "(") || isWord(code[after + 1], "MATERIALIZED", "NOT")))
|
|
484
|
+
continue;
|
|
485
|
+
if (schema === "citus_internal" || name.startsWith("run_command_on_") || name.startsWith("citus_internal_") || CITUS_ADMIN_FUNCTIONS.has(name)) {
|
|
486
|
+
return problem(write ? "write_statement_refused" : "forbidden_keyword", `The SQL may not call ${name}: Citus' administrative functions run commands on other nodes or change the cluster.`, "sql_text");
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
return undefined;
|
|
490
|
+
}
|
|
446
491
|
export function listOutsideIn(sql, dialect, listNames) {
|
|
447
492
|
if (!listNames.length)
|
|
448
493
|
return undefined;
|
|
@@ -544,7 +589,7 @@ export function checkQueryTools(disk, schema, baseline, connections) {
|
|
|
544
589
|
message: `Query tool "${slug}": ${call.message}`,
|
|
545
590
|
});
|
|
546
591
|
}
|
|
547
|
-
const oracle = typeof query.sql_text === "string" ? oracleQueryProblem(query.sql_text, dialect, write) : undefined;
|
|
592
|
+
const oracle = typeof query.sql_text === "string" ? oracleQueryProblem(query.sql_text, dialect, write) ?? citusQueryProblem(query.sql_text, dialect, write) : undefined;
|
|
548
593
|
if (oracle) {
|
|
549
594
|
findings.push({
|
|
550
595
|
code: oracle.code,
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { queryTools, schemaKnowsWrites } from "./database-queries.js";
|
|
2
|
+
import { locate } from "./package-files.js";
|
|
3
|
+
const object = (v) => v && typeof v === "object" && !Array.isArray(v) ? v : undefined;
|
|
4
|
+
const rows = (v) => Array.isArray(v) ? v.filter(x => object(x)) : [];
|
|
5
|
+
const active = (v) => v.is_active !== false;
|
|
6
|
+
const scope = (v, harness) => v.harness_slug === undefined || v.harness_slug === harness;
|
|
7
|
+
const CODE = "write_needs_confirmation";
|
|
8
|
+
export const WRITE_PATH_HINT = "Keep requires_confirmation on for chat. A direct Tool Call without it needs the latest Approval decision to be approved and no later agent stage; alternatively use a schedule, a webhook whose secret header is checked, or Run now. The instance checks the actual run and decision.";
|
|
9
|
+
export function checkWritePaths(disk, schema, catalog, baseline) {
|
|
10
|
+
if (!schemaKnowsWrites(schema) || !catalog?.api_error_codes?.some(e => e.code === CODE))
|
|
11
|
+
return [];
|
|
12
|
+
const queries = new Map();
|
|
13
|
+
for (const [slug, tool] of Object.entries(baseline?.tools ?? {})) {
|
|
14
|
+
const query = object(tool.database_query);
|
|
15
|
+
if (query)
|
|
16
|
+
queries.set(slug, query);
|
|
17
|
+
}
|
|
18
|
+
for (const { slug, tool } of queryTools(disk.package)) {
|
|
19
|
+
const query = object(tool.database_query);
|
|
20
|
+
if (query)
|
|
21
|
+
queries.set(slug, query);
|
|
22
|
+
}
|
|
23
|
+
for (const tool of rows(disk.package.tools))
|
|
24
|
+
if (tool.tool_type !== "database_query" && typeof tool.slug === "string")
|
|
25
|
+
queries.delete(tool.slug);
|
|
26
|
+
const unconfirmed = (slug) => typeof slug === "string" && queries.get(slug)?.kind === "write" && queries.get(slug)?.requires_confirmation === false;
|
|
27
|
+
const registry = object(disk.package.registry_entities);
|
|
28
|
+
const nodes = rows(registry?.orchestration_nodes);
|
|
29
|
+
const agents = rows(disk.package.agents);
|
|
30
|
+
const edges = rows(registry?.graph_edges);
|
|
31
|
+
const triggers = rows(registry?.triggers);
|
|
32
|
+
const skills = rows(disk.package.skills);
|
|
33
|
+
const findings = new Map();
|
|
34
|
+
const warn = (pointer, message) => findings.set(pointer, { code: CODE, severity: "warning", ...locate(disk, pointer), message, hint: WRITE_PATH_HINT });
|
|
35
|
+
const outsider = (trigger) => trigger.trigger_type !== "schedule" && !(trigger.trigger_type === "webhook" && object(trigger.config)?.auth_mode === "secret_header");
|
|
36
|
+
const harnesses = new Set([...nodes, ...agents, ...triggers].map(x => x.harness_slug));
|
|
37
|
+
for (const harness of harnesses) {
|
|
38
|
+
const localNodes = nodes.filter(n => active(n) && scope(n, harness));
|
|
39
|
+
const localAgents = agents.filter(a => active(a) && scope(a, harness));
|
|
40
|
+
const localEdges = edges.filter(e => active(e) && scope(e, harness));
|
|
41
|
+
const localTriggers = triggers.filter(t => active(t) && scope(t, harness));
|
|
42
|
+
const pending = [];
|
|
43
|
+
const add = (kind, slug, approved = false) => { if (typeof slug === "string")
|
|
44
|
+
pending.push({ kind, slug, approved }); };
|
|
45
|
+
for (const node of localNodes) {
|
|
46
|
+
if (node.node_type === "chat_start")
|
|
47
|
+
add("orchestration", node.slug);
|
|
48
|
+
if (node.node_type === "trigger_start") {
|
|
49
|
+
const trigger = localTriggers.find(t => t.slug === object(node.config)?.trigger_slug);
|
|
50
|
+
if (trigger && outsider(trigger))
|
|
51
|
+
add("orchestration", node.slug);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
for (const trigger of localTriggers.filter(outsider))
|
|
55
|
+
add("agent", trigger.entrypoint_agent_slug);
|
|
56
|
+
if (!localNodes.some(n => n.node_type === "chat_start")) {
|
|
57
|
+
for (const agent of localAgents.filter(a => a.is_entrypoint === true))
|
|
58
|
+
add("agent", agent.slug);
|
|
59
|
+
}
|
|
60
|
+
const seen = new Set();
|
|
61
|
+
while (pending.length) {
|
|
62
|
+
const current = pending.pop();
|
|
63
|
+
const key = JSON.stringify(current);
|
|
64
|
+
if (seen.has(key))
|
|
65
|
+
continue;
|
|
66
|
+
seen.add(key);
|
|
67
|
+
const node = current.kind === "orchestration" ? localNodes.find(n => n.slug === current.slug) : undefined;
|
|
68
|
+
const agent = current.kind === "agent" ? localAgents.find(a => a.slug === current.slug) : undefined;
|
|
69
|
+
if (current.kind === "orchestration" && !node || current.kind === "agent" && !agent)
|
|
70
|
+
continue;
|
|
71
|
+
let approved = current.approved;
|
|
72
|
+
if (agent) {
|
|
73
|
+
approved = false;
|
|
74
|
+
const assignments = [...rows(agent.tool_assignments), ...rows(agent.skill_assignments).filter(active).flatMap(a => rows(skills.find(s => s.slug === a.skill_slug)?.tool_assignments))].filter(active);
|
|
75
|
+
for (const assignment of assignments.filter(a => unconfirmed(a.tool_slug))) {
|
|
76
|
+
warn(`/agents/${agents.indexOf(agent)}/tool_assignments`, `Agent "${current.slug}" can call write query "${String(assignment.tool_slug)}" without confirmation on an outsider-started path; an agent cannot use the Approval-node exception, so the instance refuses it with ${CODE}.`);
|
|
77
|
+
}
|
|
78
|
+
for (const handoff of rows(agent.handoffs).filter(active))
|
|
79
|
+
add("agent", handoff.to_agent_slug, false);
|
|
80
|
+
}
|
|
81
|
+
if (node?.node_type === "approval")
|
|
82
|
+
approved = true;
|
|
83
|
+
if (node?.node_type === "tool_call" && unconfirmed(object(node.config)?.tool_slug) && !approved) {
|
|
84
|
+
warn(`/registry_entities/orchestration_nodes/${nodes.indexOf(node)}/config/tool_slug`, `Tool Call node "${current.slug}" calls write query "${String(object(node.config)?.tool_slug)}" on an outsider-started path without an Approval node after the last agent stage; the instance refuses it with ${CODE}.`);
|
|
85
|
+
}
|
|
86
|
+
for (const edge of localEdges) {
|
|
87
|
+
const from = object(edge.from_node_ref);
|
|
88
|
+
const to = object(edge.to_node_ref);
|
|
89
|
+
if (from?.kind !== current.kind || from.slug !== current.slug || typeof to?.kind !== "string")
|
|
90
|
+
continue;
|
|
91
|
+
const condition = object(object(edge.config)?.condition);
|
|
92
|
+
const rejected = node?.node_type === "approval" && (object(edge.config)?.default === true || condition?.path === "approval.approved" && condition.operator === "equals" && condition.value === false);
|
|
93
|
+
add(to.kind, to.slug, rejected ? false : approved);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return [...findings.values()];
|
|
98
|
+
}
|
package/dist/kit-codes.js
CHANGED
|
@@ -33,6 +33,7 @@ export const KIT_ERROR_CODES = [
|
|
|
33
33
|
{ code: "operation_for_a_person", area: "cli", message: "The operation stays with a person (the instance marks it, or it changes a secret, a credential or an approval), so an agent does not send it.", hint: "A person runs it in their own terminal, or in the Admin." },
|
|
34
34
|
{ code: "secret_field_for_a_person", area: "cli", message: "The request sets a field the instance marks as a secret value, so an agent does not send it.", hint: "Leave the field out; a person enters the value with `cavelon secrets set <name>` or in the Admin." },
|
|
35
35
|
{ code: "yes_required", area: "cli", message: "setup changes something and there is no terminal to ask.", hint: "Read the plan it printed, then run it again with --yes." },
|
|
36
|
+
{ code: "automation_settings_invalid", area: "cli", message: "The personal MCP startup settings are unreadable or have an unrecognized format; setup leaves them unchanged and MCP starts in standard mode.", hint: "Restore automation.json in the personal Cavelon config directory with format: 1 and mcp_mode: standard or yolo, or move it aside and run cavelon setup again." },
|
|
36
37
|
{ code: "operations_unavailable", area: "cli", message: "The instance does not offer the operations API.", hint: "Its operator turns it on with OPERATIONS_API_ENABLED." },
|
|
37
38
|
{ code: "not_an_operation_id", area: "cli", message: "That is not an operation id; they start with op_.", hint: "Commands that start work print the operation id; `cavelon status` lists running ones." },
|
|
38
39
|
{ code: "operation_gone", area: "cli", message: "The operation no longer exists on the instance.", hint: "Start the work again; `cavelon status` lists the running operations." },
|