feat(ai): make unrecognized shell prompts an actionable unknown state instead of a terminal block (#4198)

* feat(ai): make unrecognized shell prompts an actionable unknown state instead of a terminal block

Composes #3935 (advisory semantics), #4110 (OSC 133 marker authority + pending-input guards) and #4195 (asymmetric harm / state-model proposal). An unrecognized prompt on a live shell now yields a non-terminal SHELL_READINESS_UNKNOWN result with a read-only/confirm viable path; PROVEN-busy states keep the exact hard SHELL_NOT_READY block. Never blind-types into unknown; never claims ready without evidence.

* fix(ai): propagate unknown readiness code through the active Catty SDK path

---------

Co-authored-by: 陈大猫 <16399091+binaricat@users.noreply.github.com>
This commit is contained in:
GOUKI9999and陈大猫 authored and GitHub committed 2026-11-15 01:27:43 +08:00
1 parent 8433302959
commit 0a4ff8875f
20 files changed
+778 -17

No files matched your search

@@ -81,6 +81,11 @@ function formatTerminalExecuteResult(result) {
// Align with Catty executor wording when a command ran but produced no text.
const TERMINAL_EXECUTE_NO_OUTPUT_TEXT = "Command completed (no output)";
// Matches READINESS_UNKNOWN in electron/bridges/ai/shellReadinessState.cjs.
// Kept as a literal to avoid a capabilities -> bridges dependency; a test
// asserts the two stay in sync.
const SHELL_READINESS_UNKNOWN_CODE = "SHELL_READINESS_UNKNOWN";
/**
* Format terminal_execute for MCP clients.
* Match Catty semantics: when the command actually ran, always surface
@@ -97,6 +102,18 @@ function formatTerminalExecuteMcpResponse(result) {
return { content: [{ type: "text", text: formatRpcError(result) }], isError: true };
}
// #4195: an unrecognized prompt on a live shell is an actionable,
// non-terminal state, not a fatal tool error. The exec gate already refused
// to send the command; surface the honest + viable-path hint as a NORMAL
// tool result (no isError) so the agent inspects / re-checks / confirms
// instead of treating the session as permanently bricked (cf. #3935, where
// shellReady became advisory). Never claim the command ran.
if (result.code === SHELL_READINESS_UNKNOWN_CODE) {
return {
content: [{ type: "text", text: result.error || "Shell readiness unknown; no command was sent." }],
};
}
// Operational failure with no command evidence (session not found, busy, blocked…).
if (result.ok === false && !hasTerminalExecuteEvidence(result)) {
return { content: [{ type: "text", text: formatRpcError(result) }], isError: true };