UNPKG

@essentialai/cogent-bridge

Version:

Cogent Bridge — cross-agent comms for Claude Code, OpenAI Codex and Slack. Codex users: install with `curl -fsSL https://cogent.tools/install.sh | sh`, then start with `cogent-codex` for real-time peer wake.

55 lines • 2.03 kB
export var BridgeErrorCode; (function (BridgeErrorCode) { BridgeErrorCode["CLI_NOT_FOUND"] = "CLI_NOT_FOUND"; BridgeErrorCode["CLI_TIMEOUT"] = "CLI_TIMEOUT"; BridgeErrorCode["CLI_EXEC_FAILED"] = "CLI_EXEC_FAILED"; BridgeErrorCode["STATE_CORRUPT"] = "STATE_CORRUPT"; BridgeErrorCode["STATE_WRITE_FAILED"] = "STATE_WRITE_FAILED"; BridgeErrorCode["LOCK_TIMEOUT"] = "LOCK_TIMEOUT"; BridgeErrorCode["LOCK_STALE"] = "LOCK_STALE"; BridgeErrorCode["PEER_NOT_FOUND"] = "PEER_NOT_FOUND"; BridgeErrorCode["INVALID_INPUT"] = "INVALID_INPUT"; BridgeErrorCode["STARTUP_FAILED"] = "STARTUP_FAILED"; BridgeErrorCode["DIR_NOT_WRITABLE"] = "DIR_NOT_WRITABLE"; BridgeErrorCode["NETWORK_TIMEOUT"] = "NETWORK_TIMEOUT"; BridgeErrorCode["JOIN_NOT_CONFIRMED"] = "JOIN_NOT_CONFIRMED"; })(BridgeErrorCode || (BridgeErrorCode = {})); export class BridgeError extends Error { code; suggestion; constructor(code, message, suggestion) { const fullMessage = suggestion ? `${code}: ${message}. ${suggestion}` : `${code}: ${message}`; super(fullMessage); this.name = "BridgeError"; this.code = code; this.suggestion = suggestion; } } export function toolResult(text, isError) { return { content: [{ type: "text", text }], ...(isError ? { isError: true } : {}), }; } export function errorResult(error) { if (error instanceof BridgeError) { return toolResult(JSON.stringify({ success: false, error: error.code, message: error.message, suggestion: error.suggestion, }, null, 2), true); } const message = error instanceof Error ? error.message : String(error); return toolResult(JSON.stringify({ success: false, error: "INTERNAL_ERROR", message, }, null, 2), true); } export function successResult(data) { return toolResult(JSON.stringify(data, null, 2), false); } //# sourceMappingURL=errors.js.map