/* THE REFUSALS THAT TURN A WHOLE TURN AWAY AT THE DOOR: refused before the model saw a word, so nothing ran and the message is still owed to somebody — the conversation's queue, held, for words a person sent, or the sandbox that started the turn itself. */ // A set rather than a run of case labels: what they share is a fact about the turn, not a shape. const TURNED_AWAY: ReadonlySet = new Set([ "claude-reauth", // An organisation turned the account's Claude Code access off, or no account of the provider can serve: the next // turn is routed off it (the daemon's blocked-account route), so the words wait for it rather than being spent. "claude-not-entitled", "unknown-command", "context-window-too-small", "model-helper-only", // The privacy shield refused an untrusted provider on a runtime it cannot read by content at all. "privacy-unshielded", // The turn carries a tool list its runtime cannot keep. "tools-unenforced", // The protected execution boundary refused admission, not an executed provider/runtime failure. "agent-domain-refused", // The privacy shield found personal data in instructions a runtime loads itself, where it could not mask them. "privacy-instructions", "sandbox-memory-low", // The conversation's own view of the workspace could not be set up in time: nothing was started in it. "workspace-setup", "sandbox-disk-low", "trial-unavailable", "trial-model-unavailable", "trial-exhausted", "model-unavailable", "engine-version-floor", ]); // The refusals about the model itself (its allowance, its account, its catalogue, its window), which another model // gets past: a turn one of these stops partway offers to carry on elsewhere rather than to wait. const ANOTHER_MODEL_CLEARS: ReadonlySet = new Set([ "claude-not-entitled", "context-window-too-small", "model-helper-only", "trial-unavailable", "trial-model-unavailable", "trial-exhausted", "model-unavailable", ]); /** Whether another model would get past a refusal: the trial's, the model's, or the account's on it. */ export const anotherModelClears = (code: string | undefined): boolean => code !== undefined && ANOTHER_MODEL_CLEARS.has(code); /** Whether a failure code refuses a turn before the model sees any of it. */ export const turnedAwayCode = (code: string | undefined): boolean => code !== undefined && TURNED_AWAY.has(code);