/** * src/errors.ts — Error factory + domain error code constants. * * All MCP tool handlers in this package return either * { ok: true, data, degraded? } * or * { ok: false, error: SkillFmToolError } * (shape defined in the vendored contract `beacon-mcp-tools-v1.ts`). * * This file owns the canonical list of error codes. Codes are domain-prefixed * `'SKILLFM..'` to make grep + log filtering reliable. * * TODO Week 5: * - Wire codes into the brain-client retry classifier (retryable=true vs false) * - Add i18n table for `userHint` (currently each handler ad-hoc fills en/zh) * - Add a structured `cause` field (preserving original Error) once we have * real network/io failures to surface — Phase 0 returns mocks, no real cause. */ import type { SkillFmToolError } from './_vendored-contracts/beacon-mcp-tools-v1.js'; export declare const SKILLFM_ERROR_CODES: { readonly AUTH_NOT_BOUND: "SKILLFM.AUTH.NOT_BOUND"; readonly AUTH_INVALID_TOKEN: "SKILLFM.AUTH.INVALID_TOKEN"; readonly AUTH_PRO_REQUIRED: "SKILLFM.AUTH.PRO_REQUIRED"; readonly NETWORK_UNREACHABLE: "SKILLFM.NETWORK.UNREACHABLE"; readonly NETWORK_TIMEOUT: "SKILLFM.NETWORK.TIMEOUT"; readonly BRAIN_RATE_LIMITED: "SKILLFM.BRAIN.RATE_LIMITED"; readonly BRAIN_INTERNAL: "SKILLFM.BRAIN.INTERNAL"; readonly BRAIN_CONTRACT_MISMATCH: "SKILLFM.BRAIN.CONTRACT_MISMATCH"; readonly TOOL_NOT_IMPLEMENTED: "SKILLFM.TOOL.NOT_IMPLEMENTED"; readonly TOOL_INVALID_INPUT: "SKILLFM.TOOL.INVALID_INPUT"; readonly CACHE_READ_FAILED: "SKILLFM.CACHE.READ_FAILED"; readonly CACHE_WRITE_FAILED: "SKILLFM.CACHE.WRITE_FAILED"; readonly DECISION_FREQUENCY_LIMITED: "SKILLFM.DECISION.FREQUENCY_LIMITED"; readonly DECISION_USER_OPTED_OUT: "SKILLFM.DECISION.USER_OPTED_OUT"; readonly DECISION_DUPLICATE_SUGGESTION: "SKILLFM.DECISION.DUPLICATE_SUGGESTION"; }; export type SkillFmErrorCode = (typeof SKILLFM_ERROR_CODES)[keyof typeof SKILLFM_ERROR_CODES]; /** * Throwable error class. Tool handlers can `throw new SkillFmError(...)` * and the MCP server boundary will convert into `SkillFmToolError` envelope. */ export declare class SkillFmError extends Error { readonly code: string; readonly userHint?: { en: string; zh: string; }; readonly retryable: boolean; constructor(opts: { code: string; message: string; userHint?: { en: string; zh: string; }; retryable?: boolean; }); /** Convert to the wire-shape error returned inside `SkillFmToolResult.error`. */ toToolError(): SkillFmToolError; } export declare function notImplemented(toolName: string): SkillFmError; export declare function authNotBound(): SkillFmError; export declare function networkUnreachable(detail: string): SkillFmError; export declare function proRequired(featureName: string): SkillFmError; export declare function invalidInput(reason: string): SkillFmError; //# sourceMappingURL=errors.d.ts.map