@cavelon/cli 0.2.5 → 0.2.6

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.
@@ -278,7 +278,7 @@ export const api = {
278
278
  const secrets = secretsIn(doc, op, args);
279
279
  if (secrets.length)
280
280
  throw secretRefusal(op, secrets);
281
- if (driven && !op.readOnly) {
281
+ if (driven && (!op.readOnly || op.method === "POST")) {
282
282
  const words = [
283
283
  "api",
284
284
  name,
@@ -1,5 +1,4 @@
1
1
  import { createHash } from "node:crypto";
2
- import { PERSON_WAIT_MS } from "./approval-policy.js";
3
2
  import { actingTarget, targetLine } from "./acting.js";
4
3
  import { drivenByAgent } from "./agent-env.js";
5
4
  import { CavelonError, ExitCode } from "./errors.js";
@@ -119,11 +118,19 @@ export async function personApproves(ctx, driven, change, target = {}) {
119
118
  ctx.approved = { guarded: change.guarded ?? true };
120
119
  return;
121
120
  }
121
+ if (answer === "unavailable" || answer === "unanswered") {
122
+ throw new CavelonError(ExitCode.needsAction, {
123
+ code: "confirm_needs_person",
124
+ message: answer === "unavailable"
125
+ ? "The MCP client could not obtain a usable approval answer; nothing was changed. The person confirms in their own terminal."
126
+ : "The dialog was cancelled or returned no approval answer; nothing was changed. The person can confirm in their own terminal.",
127
+ hint: `Show the person the preview and this command to run themselves: ${change.command}`,
128
+ details: { answer, needs_person: "terminal", person_command: change.command },
129
+ });
130
+ }
122
131
  throw new CavelonError(ExitCode.needsAction, {
123
132
  code: "confirm_declined",
124
- message: answer === "declined"
125
- ? "The person did not approve the change; nothing was changed."
126
- : `The person did not answer within ${PERSON_WAIT_MS / 60_000} minutes, or the client could not ask; nothing was changed.`,
133
+ message: "The MCP client returned an explicit decline; nothing was changed.",
127
134
  hint: `Ask the person whether they want it. With their yes, call ${change.tool} again with the same confirm token, or they run ${change.command} in their own terminal.`,
128
135
  details: { answer, person_command: change.command },
129
136
  });
@@ -133,7 +140,7 @@ export function needsPerson(command) {
133
140
  code: "confirm_needs_person",
134
141
  message: `A coding agent cannot confirm this change; nothing was changed. The person confirms it in their own terminal: ${command}`,
135
142
  hint: "Show the person the preview and the command; they run it themselves, outside the agent.",
136
- details: { person_command: command },
143
+ details: { needs_person: "terminal", person_command: command },
137
144
  });
138
145
  }
139
146
  export function confirmThroughClient(tool, token) {
package/dist/kit-codes.js CHANGED
@@ -67,7 +67,7 @@ export const KIT_ERROR_CODES = [
67
67
  { code: "confirm_token_required", area: "cli", message: "Over MCP, or run by a coding agent in its shell, a changing command confirms only with the token its preview returned, never with true or a bare --confirm.", hint: "Call the tool (or run the command) without confirm, show the person the preview, then call it again with the same arguments and confirm set to its confirm_token (--confirm <token> in a shell)." },
68
68
  { code: "confirm_needs_person", area: "cli", message: "A coding agent cannot confirm this change, even with its preview's token: it reaches live traffic or the whole tenant, or cannot be taken back, and the agent's MCP client cannot ask the person (or the agent runs cavelon in its shell). Nothing was changed.", hint: "Show the person the preview; they run the command the refusal names in their own terminal, outside the agent." },
69
69
  { code: "native_ui_disconnected", area: "cli", message: "The native person UI call failed after routing. Its outcome may be unknown, so the adapter never retries through another connection.", hint: "Inspect the instance's current state before repeating the change. Reconnect the client; a new guarded attempt needs a fresh preview and person answer." },
70
- { code: "confirm_declined", area: "cli", message: "The MCP client asked the person to approve the change, and they declined or did not answer in time. Nothing was changed.", hint: "Ask the person whether they want the change; with their yes, confirm again with the same token, or they run the command in their own terminal." },
70
+ { code: "confirm_declined", area: "cli", message: "The MCP client returned an explicit decline to the change. Nothing was changed.", hint: "Do not retry automatically. A new attempt needs the person's request and a fresh dialog answer, or they run the exact command in their own terminal." },
71
71
  { code: "token_mismatch", area: "cli", message: "The confirm token is not the one for this change: it belongs to another preview, or the change differs from what its preview showed; nothing was changed (exit code 4).", hint: "Show the person the new preview this answer carries, and confirm only with its confirm_token after their yes; a token confirms exactly the change its preview showed." },
72
72
  { code: "unknown_argument", area: "cli", message: "An MCP tool was called with an argument its schema does not list; nothing was done.", hint: "Call it again with the argument the error names (the tool's schema lists them all), spelled in snake_case." },
73
73
  { code: "solution_not_active", area: "cli", message: "Only an active solution can be the tenant's default route; this one is not (a draft, or inactive after a deactivate), so nothing was changed.", hint: "Activate it through the readiness gate and preview the default route in one step: `cavelon activate --harness <slug> --make-default`." },
package/dist/mcp.js CHANGED
@@ -230,10 +230,14 @@ function clientAsks(server) {
230
230
  async function askThroughClient(server, message, relatedRequestId) {
231
231
  try {
232
232
  const result = await server.elicitInput({ mode: "form", message, requestedSchema: APPROVAL_SCHEMA }, { timeout: PERSON_WAIT_MS, relatedRequestId });
233
- return result.action === "accept" && result.content?.approve === true ? "approved" : "declined";
233
+ if (result.action === "accept" && result.content?.approve === true)
234
+ return "approved";
235
+ if (result.action === "decline" || result.action === "accept" && result.content?.approve === false)
236
+ return "declined";
237
+ return result.action === "cancel" ? "unanswered" : "unavailable";
234
238
  }
235
239
  catch {
236
- return "unanswered";
240
+ return "unavailable";
237
241
  }
238
242
  }
239
243
  function mcpIo(io) {
@@ -245,6 +249,7 @@ export function createMcpServer(io, commands, updates = {}, startup = {}) {
245
249
  const server = new Server({ name: "cavelon", version: KIT_VERSION }, { capabilities: { tools: { listChanged: true } }, instructions: mcpInstructions(commands) });
246
250
  const notice = startSessionUpdateCheck(io, updates);
247
251
  const sessionTenants = new Map();
252
+ let clientUiUnavailable = false;
248
253
  const launch = createContext(mcpIo(io), { ...startup, json: true }, "mcp").globals;
249
254
  async function credentialAccess() {
250
255
  const read = (async () => {
@@ -297,8 +302,13 @@ export function createMcpServer(io, commands, updates = {}, startup = {}) {
297
302
  return fail(error);
298
303
  }
299
304
  const ctx = createContext(mcpIo(folder.io), { ...launch, json: true, tenant: tenant ?? launch.tenant, solutionEnv: solutionEnv ?? launch.solutionEnv, sessionTenants }, "mcp");
300
- if (clientAsks(server))
301
- ctx.askPerson = (message) => askThroughClient(server, message, requestId);
305
+ if (!clientUiUnavailable && clientAsks(server))
306
+ ctx.askPerson = async (message) => {
307
+ const answer = await askThroughClient(server, message, requestId);
308
+ if (answer === "unavailable")
309
+ clientUiUnavailable = true;
310
+ return answer;
311
+ };
302
312
  for (const message of renamed)
303
313
  ctx.warn(message);
304
314
  try {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "format": 1,
3
- "version": "0.2.5",
3
+ "version": "0.2.6",
4
4
  "entries": {
5
5
  "omp": [
6
6
  "omp-extension.mjs"
package/dist/openapi.js CHANGED
@@ -26,6 +26,10 @@ export function operations(doc) {
26
26
  const byKey = new Map();
27
27
  for (const p of [...shared, ...own])
28
28
  byKey.set(`${p.in}:${p.name}`, p);
29
+ const personOnly = personOnlyOf(raw);
30
+ const confirmation = confirmationOf(raw);
31
+ const readPost = method === "post" && raw["x-cavelon-read-only"] === true &&
32
+ !personOnly?.marked && !confirmation.confirmation;
29
33
  out.push({
30
34
  operationId,
31
35
  alias: aliasOf(operationId, path, method),
@@ -38,9 +42,9 @@ export function operations(doc) {
38
42
  parameters: [...byKey.values()],
39
43
  requestBody: raw.requestBody ? deref(doc, raw.requestBody) : undefined,
40
44
  responses: raw.responses ?? {},
41
- readOnly: method === "get" || method === "head" || method === "options",
42
- personOnly: personOnlyOf(raw),
43
- ...confirmationOf(raw),
45
+ readOnly: method === "get" || method === "head" || method === "options" || readPost,
46
+ personOnly,
47
+ ...confirmation,
44
48
  });
45
49
  }
46
50
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cavelon/cli",
3
- "version": "0.2.5",
3
+ "version": "0.2.6",
4
4
  "description": "The cavelon binary: CLI and local MCP server for building Cavelon solutions with a coding agent.",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://github.com/goodguys-gmbh/cavelon-dev-kit",