@everyai/cli 0.7.1 → 0.7.2
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 +2 -0
- package/dist/commands/tools.js +21 -0
- package/package.json +1 -1
- package/skills/use-every/SKILL.md +1 -1
package/README.md
CHANGED
|
@@ -91,6 +91,8 @@ Every command supports `--json`: exactly one JSON document on stdout, nothing el
|
|
|
91
91
|
|
|
92
92
|
Exit codes: `0` ok · `1` tool/generic error · `2` usage · `3` auth (run `every login`) · `4` permission/confirmation needed · `5` rate-limited · `6` not found · `7` network/timeout.
|
|
93
93
|
|
|
94
|
+
When a tool refuses (exit `1`) and the server attached a structured error, `error.code` is the server's stable, machine-readable code — e.g. `duplicate_deal`, `party_unresolved`, `contact_suppressed`, `deal_archived`, `person_has_references` — and `error.tool_error` carries the server's full error object (e.g. `existing_deal_id`). Branch on the code, never on the message. Servers that send no structured error still produce `error.code: "generic"`. Successful creates return the new record's id in `data.structured_content` (e.g. `structured_content.deal.id`).
|
|
95
|
+
|
|
94
96
|
Server-side human approvals never trigger an automatic destructive retry. If Every shows a pending approval after a destructive call returns or times out, approve it there and then re-run the identical command. The CLI sends one `tools/call` per invocation for a human-approval-gated action, and a still-valid approval can be consumed by that later invocation.
|
|
95
97
|
|
|
96
98
|
In `--json` mode, a server approval response uses exit `4` and includes a structured `error.mcp_gate` object. After local `--yes` or interactive consent, `type: "text_confirmation"` is retried once automatically; `type: "human_approval"` is returned to the caller without retrying.
|
package/dist/commands/tools.js
CHANGED
|
@@ -309,10 +309,31 @@ export async function invokeToolCall(name, opts = {}, argsFactory = async () =>
|
|
|
309
309
|
mcp_gate: marker,
|
|
310
310
|
});
|
|
311
311
|
}
|
|
312
|
+
// Servers that follow Every's write-result contract attach a stable,
|
|
313
|
+
// machine-readable code in structuredContent.error (e.g. duplicate_deal,
|
|
314
|
+
// party_unresolved). Surface it as error.code with the full server error
|
|
315
|
+
// under error.tool_error; older servers send none, so this falls back to
|
|
316
|
+
// 'generic' and behaves exactly as before.
|
|
317
|
+
const toolError = structuredToolError(result.structuredContent);
|
|
318
|
+
if (toolError) {
|
|
319
|
+
throw new CliError(rawMessage, ExitCode.GENERIC, toolError.code, { tool_error: toolError });
|
|
320
|
+
}
|
|
312
321
|
throw new CliError(rawMessage, ExitCode.GENERIC, 'generic');
|
|
313
322
|
}
|
|
314
323
|
return data;
|
|
315
324
|
}
|
|
325
|
+
/** The server's structured tool error, when it sent a well-formed one. */
|
|
326
|
+
function structuredToolError(structured) {
|
|
327
|
+
if (!structured || typeof structured !== 'object')
|
|
328
|
+
return undefined;
|
|
329
|
+
const error = structured.error;
|
|
330
|
+
if (!error || typeof error !== 'object')
|
|
331
|
+
return undefined;
|
|
332
|
+
const code = error.code;
|
|
333
|
+
if (typeof code !== 'string' || !/^[a-z][a-z0-9_]{0,63}$/.test(code))
|
|
334
|
+
return undefined;
|
|
335
|
+
return { ...error, code };
|
|
336
|
+
}
|
|
316
337
|
export async function executeToolCall(name, opts = {}, argsFactory = async () => ({}), augmentData = (data) => data) {
|
|
317
338
|
const data = await augmentData(await invokeToolCall(name, opts, argsFactory));
|
|
318
339
|
emitCommand(data, toolCallHuman(data), opts);
|
package/package.json
CHANGED
|
@@ -34,7 +34,7 @@ Always pass `--json`. Parse the envelope every time:
|
|
|
34
34
|
Check process exit codes:
|
|
35
35
|
|
|
36
36
|
- `0`: success.
|
|
37
|
-
- `1`: tool or generic error. Read the error message before deciding whether to retry.
|
|
37
|
+
- `1`: tool or generic error. If `error.code` is not `generic`, it is the server's stable refusal code (e.g. `duplicate_deal`, `party_unresolved`, `contact_suppressed`) and `error.tool_error` has the details — act on the code, not the wording. A refusal means nothing was created or changed unless the message says otherwise. Read the error message before deciding whether to retry.
|
|
38
38
|
- `2`: usage error. Fix the command or arguments.
|
|
39
39
|
- `3`: auth error. Tell the user to run `every login`.
|
|
40
40
|
- `4`: permission or confirmation needed. If present, inspect `error.mcp_gate`. A repeated `text_confirmation` means the CLI's one safe retry was still rejected; stop and report it. For `human_approval`, do not retry until the user approves in Every. Without `mcp_gate`, do not add confirmation flags unless the user authorized the action.
|