mirror of
https://github.com/AgentSeal/codeburn.git
synced 2026-10-29 18:44:34 +00:00
For a bundled CLI the not-found panel now tells desktop users to reopen or reinstall the app instead of installing from npm. Strings in all six locales.
23 lines
972 B
TypeScript
23 lines
972 B
TypeScript
import type { CliError, CodeburnBridge } from './types'
|
|
|
|
// The preload script (app/electron/preload.ts) exposes `window.codeburn` as the
|
|
// typed CodeburnBridge (methods resolve to CLI JSON or reject with a plain
|
|
// CliError).
|
|
declare global {
|
|
interface Window {
|
|
codeburn: CodeburnBridge
|
|
}
|
|
}
|
|
|
|
/** The typed bridge. Import this instead of touching `window` directly. */
|
|
export const codeburn: CodeburnBridge = window.codeburn
|
|
|
|
/** Coerce anything thrown across the IPC boundary into a CliError shape. */
|
|
export function normalizeCliError(err: unknown): CliError {
|
|
if (err && typeof err === 'object' && 'kind' in err && typeof (err as CliError).kind === 'string') {
|
|
const e = err as CliError
|
|
return { kind: e.kind, message: e.message ?? 'codeburn CLI error', ...(e.cold ? { cold: true as const } : {}), ...(e.stage ? { stage: e.stage } : {}) }
|
|
}
|
|
const message = err instanceof Error ? err.message : String(err)
|
|
return { kind: 'nonzero', message }
|
|
}
|