fix: revert cross-boundary TS imports, add .d.ts for shared modules
The Electron TS backend can't import from app/lib/ at runtime (compiled
to dist/ which doesn't include app/). Restore original TS implementations
and add .d.ts declaration files for the shared JS modules.