@capgo/cli
Version:
A CLI to upload to capgo servers
31 lines (30 loc) • 1.87 kB
TypeScript
/**
* Every local MCP error must leave the agent a way out: what to change and retry, which tool to
* call, what to ask the user, or, when the failure is not expected, how to reach support.
* Mirrors the hosted MCP server's error guidance (backend mcp/error_guidance.ts), with steps that
* use the local tools (capgo_login, capgo_set_project_dir, capgo_doctor).
*/
export declare const SUPPORT_EMAIL = "support@capgo.app";
/** Heading that marks an error text as already explained; the safety net skips those. */
export declare const GUIDANCE_HEADING = "How to fix";
export type ErrorKind = 'fix_input' | 'project' | 'not_found' | 'conflict' | 'authentication' | 'permission' | 'security_policy' | 'plan_limit' | 'rate_limited' | 'expired' | 'network' | 'unexpected';
export interface ErrorGuidance {
kind: ErrorKind;
nextSteps: string[];
}
/** Classify an error message from a local MCP tool and say what the agent should do next. */
export declare function guidanceForError(message: string, tool?: string): ErrorGuidance;
export declare function formatGuidance(guidance: ErrorGuidance): string;
/** Append guidance to an error text unless the tool already explained the way out. */
export declare function explainError(message: string, tool?: string): string;
/**
* Safety net for every registered tool: error results get guidance appended, and a thrown error
* becomes an error result with guidance instead of a bare protocol error.
*/
export declare function withErrorGuidance<H extends (...args: any[]) => Promise<unknown>>(tool: string, handler: H): H;
/**
* Last safety net on the transport: a JSON-RPC error (unknown tool, invalid request) or an error tool
* result that no handler explained (e.g. the SDK rejected the arguments) gets guidance. Other
* messages pass through.
*/
export declare function withGuidedErrorResults<M>(message: M): M;