Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/private-files.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'lyra': patch
---

On macOS and Linux, Lyra's own files (session audio and documents, saved voices, the search index and API keys, and notes in the default `~/.lyra` folder) are now readable only by your account, and folders from earlier versions are tightened at startup; on a shared computer other accounts could read them before. Saved voices and API keys are now written durably, so a power cut right after saving can't empty them. Settings now says the built-in summary model is for non-commercial use only, with a link to its licence, and the README says when Lyra goes online (model downloads and the update check).
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,17 @@ Grant microphone access when prompted. Models download on first use:

- **Whisper `large-v3-turbo`** (~575 MB), on the first recording
- **Speaker models** (~46 MB), on the first meeting
- **Local notes model** (~2 GB), only if you turn on local meeting notes
- **Local notes model** (~2 GB), only if you turn on local meeting notes. It's Qwen2.5 3B, licensed
for non-commercial use only (see [THIRD_PARTY.md](THIRD_PARTY.md))
- **Search model** (~146 MB), only if you turn on search by meaning

On macOS, capturing a call's audio needs Screen Recording permission.

## Privacy

Everything runs on this computer by default. The only exception is meeting notes **with a cloud model**, which you have to switch on yourself. It sends the meeting transcript (never audio or voiceprints) to the provider you pick, using your own key, which is stored in the system keychain. Recording other people usually requires their consent.
Everything runs on this computer by default. Your notes, transcripts and audio go to a cloud service only for meeting notes **with a cloud model**, which you have to switch on yourself. It sends the meeting transcript (never audio or voiceprints) to the provider you pick, using your own key, which is stored in the system keychain. Recording other people usually requires their consent.

Lyra also goes online, without sending any of your content, to download the models above on first use (from Hugging Face and GitHub), and to check GitHub for a new release when it starts and every four hours after. The update check can't be turned off yet. On macOS and Linux, Lyra's own files (session audio and documents, voiceprints, the search index, keys, and notes in its default folder) can be read only by your account.

## Build

Expand Down
18 changes: 17 additions & 1 deletion THIRD_PARTY.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,28 @@ upstream revision and checked against its sha256 before it is loaded (`src/main/
| Silero VAD v5.1.2, ggml build (`ggml-silero-v5.1.2.bin`) | Dropping non-speech inside each chunk, in whisper.cpp | MIT ([snakers4/silero-vad](https://github.com/snakers4/silero-vad)) | [ggml-org/whisper-vad @ 9ffd54a](https://huggingface.co/ggml-org/whisper-vad/tree/9ffd54a1e1ee413ddf265af9913beaf518d1639b) |
| Silero VAD v5, ONNX (`silero_vad_v5.onnx`) | Where a recording's chunks start and end | MIT ([snakers4/silero-vad](https://github.com/snakers4/silero-vad)) | [k2-fsa/sherpa-onnx release `asr-models`](https://github.com/k2-fsa/sherpa-onnx/releases/tag/asr-models), pinned by sha256 |
| NVIDIA Parakeet TDT 0.6B v3, int8 ONNX | Evals only (`--asr parakeet`); not downloaded by the app | CC BY 4.0 ([model card](https://huggingface.co/nvidia/parakeet-tdt-0.6b-v3)); attribution: NVIDIA | [csukuangfj/sherpa-onnx-nemo-parakeet-tdt-0.6b-v3-int8 @ ed5d745](https://huggingface.co/csukuangfj/sherpa-onnx-nemo-parakeet-tdt-0.6b-v3-int8/tree/ed5d745623472f97cfc2e6c2916ee248798fc5a8) |
| nomic-embed-text-v1.5, Q8_0 GGUF (`nomic-embed-text-v1.5.Q8_0.gguf`) | Search by meaning (opt-in); downloaded only when it's turned on | Apache-2.0 ([model card](https://huggingface.co/nomic-ai/nomic-embed-text-v1.5)) | [nomic-ai/nomic-embed-text-v1.5-GGUF @ 0188c9b](https://huggingface.co/nomic-ai/nomic-embed-text-v1.5-GGUF/tree/0188c9bf409793f810680a5a431e7b899c46104c) |
| Qwen2.5-3B-Instruct, Q4_K_M GGUF | Local meeting notes and titles (opt-in) | **Qwen Research License: non-commercial use only**; commercial use needs a licence from Alibaba Cloud | [Qwen/Qwen2.5-3B-Instruct-GGUF @ 7dabda4](https://huggingface.co/Qwen/Qwen2.5-3B-Instruct-GGUF/tree/7dabda4d13d513e3e842b20f0d435c732f172cbe) |

"Qwen is licensed under the Qwen RESEARCH LICENSE AGREEMENT, Copyright (c) Alibaba Cloud. All
Rights Reserved." Lyra is a non-commercial project, which the licence allows. Lyra's own code is
MIT, but the model's terms bind whoever runs it: anyone using Lyra commercially must leave local
summaries off or get a licence from Alibaba Cloud.
summaries off or get a licence from Alibaba Cloud. Settings says so where local summaries are
offered.

Each model's sha256 and size are in the source file that downloads it (`src/main/models.ts`,
`src/main/meeting/speakerModel.ts`, `src/main/meeting/notesLocal.ts`,
`src/main/searchIndex/service.ts`).

## Fonts

Bundled into the window from the `@fontsource` packages, under the
[SIL Open Font License 1.1](https://openfontlicense.org), which travels with each package's files.

| Font | Licence |
| --- | --- |
| IBM Plex Sans, IBM Plex Mono (`@fontsource/ibm-plex-sans`, `@fontsource/ibm-plex-mono`) | SIL OFL 1.1, Copyright IBM Corp. |
| Literata (`@fontsource-variable/literata`) | SIL OFL 1.1, Copyright The Literata Project Authors |

## Word lists

Expand Down
12 changes: 11 additions & 1 deletion apps/lyra/src/main/atomicFile.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { mkdtempSync, readdirSync, readFileSync, writeFileSync } from 'node:fs'
import { mkdtempSync, readdirSync, readFileSync, statSync, writeFileSync } from 'node:fs'
import { tmpdir } from 'node:os'
import { basename, join } from 'node:path'
import { describe, expect, it } from 'vitest'
Expand All @@ -18,6 +18,16 @@ describe('atomic writes', () => {
expect(readdirSync(root).sort()).toEqual(['doc.json', 'note.txt'])
})

it.skipIf(process.platform === 'win32')('writes files only their owner can read', async () => {
const root = dir()
const path = join(root, 'voices.json')
writeFileSync(path, 'old', { mode: 0o644 })
await writeFileAtomic(path, 'new')
writeFileAtomicSync(join(root, 'doc.json'), 'doc')
expect(statSync(path).mode & 0o777).toBe(0o600)
expect(statSync(join(root, 'doc.json')).mode & 0o777).toBe(0o600)
})

it('never interleaves overlapping writes of one file', async () => {
const root = dir()
const path = join(root, 'settings.json')
Expand Down
6 changes: 4 additions & 2 deletions apps/lyra/src/main/atomicFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { closeSync, fsyncSync, openSync, renameSync, unlinkSync, writeSync } fro
import { open, rename, unlink } from 'node:fs/promises'
import { basename, dirname, join } from 'node:path'
import { setTimeout as sleep } from 'node:timers/promises'
import { PRIVATE_FILE_MODE } from './privateFiles'

/**
* Durable file replacement: write a temp file beside the target, fsync it, then rename it over
Expand Down Expand Up @@ -67,7 +68,8 @@ function renameOverSync(temp: string, path: string): void {
export async function writeFileAtomic(path: string, data: string | Uint8Array): Promise<void> {
const temp = tempPathFor(path)
try {
const handle = await open(temp, 'wx')
// Owner-only (privateFiles.ts); the rename carries the mode over to the target.
const handle = await open(temp, 'wx', PRIVATE_FILE_MODE)
try {
await handle.writeFile(data)
await handle.sync()
Expand All @@ -84,7 +86,7 @@ export async function writeFileAtomic(path: string, data: string | Uint8Array):
export function writeFileAtomicSync(path: string, data: string | Uint8Array): void {
const temp = tempPathFor(path)
try {
const fd = openSync(temp, 'wx')
const fd = openSync(temp, 'wx', PRIVATE_FILE_MODE)
try {
const bytes = typeof data === 'string' ? Buffer.from(data, 'utf8') : data
let written = 0
Expand Down
3 changes: 2 additions & 1 deletion apps/lyra/src/main/checkpoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { join } from 'node:path'
import type { z } from 'zod'
import { writeFileAtomic } from './atomicFile'
import { log } from './log'
import { PRIVATE_DIR_MODE } from './privateFiles'
import { sessionCheckpointDir } from './sessionStore'

/**
Expand Down Expand Up @@ -46,7 +47,7 @@ export async function readCheckpoint<T>(
/** Replaces the checkpoint atomically; a failure is logged, never thrown (it only costs a redo). */
export async function writeCheckpoint(id: string, name: CheckpointName, value: unknown): Promise<void> {
try {
await mkdir(sessionCheckpointDir(id), { recursive: true })
await mkdir(sessionCheckpointDir(id), { recursive: true, mode: PRIVATE_DIR_MODE })
await writeFileAtomic(pathOf(id, name), JSON.stringify(value))
} catch (error) {
log('checkpoint', 'could not save a checkpoint', { id, name, error: errorMessage(error) })
Expand Down
56 changes: 40 additions & 16 deletions apps/lyra/src/main/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,9 @@ import {
powerMonitor,
session,
shell,
type IpcMainEvent,
type IpcMainInvokeEvent,
type WebContents
} from 'electron'
import { release } from 'node:os'
import { homedir, release } from 'node:os'
import { join } from 'node:path'
import { electronApp, optimizer, is } from '@electron-toolkit/utils'
import { systemAudioSource } from './systemAudioSource'
Expand Down Expand Up @@ -52,21 +50,23 @@ import {
reexportDirtySessions,
restoreSession,
flushAllSessions,
sessionsRoot,
getSessionPage as getPage,
listSessions as listPages,
openSessionFor,
saveSessionPage as savePage
} from './sessionStore'
import { registerHotkeys, unregisterHotkeys } from './hotkey'
import { tightenDir } from './privateFiles'
import { registerMicPrompt, stopMicPrompt } from './micprompt'
import { exportIgnoredApps, importIgnoredApps } from './ignoredAppsFile'
import { registerOverlay, watchMainWindow } from './overlay'
import { registerPowerHandling, watchSessionEnd } from './power'
import { startResourceLog } from './resources'
import {
getMainWindow,
isFromMainWindow,
registerSessionIpc,
requireMainWindow,
onSessionState,
resetSessionState,
setMainWindow,
Expand Down Expand Up @@ -209,14 +209,6 @@ function isMainContents(contents: WebContents): boolean {
return contents === getMainWindow()?.webContents
}

/**
* Settings, keys and the notes folder are changed only from the main window. The overlay shares
* its preload, and its page has no use for them.
*/
function requireMainWindow(event: IpcMainEvent | IpcMainInvokeEvent): void {
if (!isFromMainWindow(event)) throw new Error('Not allowed from this window')
}

/** The app's top band (`--band` in styles.css), which the window controls share. */
const BAND_HEIGHT = 56

Expand Down Expand Up @@ -377,10 +369,20 @@ function registerIpc(): void {
requireMainWindow(event)
return revealNotesFolder()
})
ipcMain.handle('pages:save', (_event, page: unknown) => savePage(SavePageArg.parse(page)))
ipcMain.handle('pages:delete', (_event, id: unknown) => deletePage(PageIdArg.parse(id)))
ipcMain.handle('pages:restore', (_event, id: unknown) => restoreSession(PageIdArg.parse(id)))
ipcMain.handle('pages:reveal', (_event, id: unknown) => {
ipcMain.handle('pages:save', (event, page: unknown) => {
requireMainWindow(event)
return savePage(SavePageArg.parse(page))
})
ipcMain.handle('pages:delete', (event, id: unknown) => {
requireMainWindow(event)
return deletePage(PageIdArg.parse(id))
})
ipcMain.handle('pages:restore', (event, id: unknown) => {
requireMainWindow(event)
return restoreSession(PageIdArg.parse(id))
})
ipcMain.handle('pages:reveal', (event, id: unknown) => {
requireMainWindow(event)
shell.showItemInFolder(resolveInNotes(PageIdArg.parse(id)))
})
ipcMain.handle('sessions:open', (event, id: unknown) =>
Expand Down Expand Up @@ -654,6 +656,7 @@ void app.whenReady().then(() => {
await repairInterruptedAudio().catch((error: unknown) => {
log('app', 'could not repair interrupted audio', error instanceof Error ? error.message : String(error))
})
await tightenFolders()
// Sessions deleted before a crash were never emptied into the system trash.
void emptySessionTrash()
// A crash mid-export leaves a note file behind its document.
Expand Down Expand Up @@ -688,6 +691,27 @@ void app.whenReady().then(() => {
})
})

/**
* Folders written before Lyra kept its files owner-only (privateFiles.ts): its data folder
* (voices, keys, the search index, settings), every session's audio and documents, and the notes
* folder only when it's Lyra's own default, never one the person chose.
*/
async function tightenFolders(): Promise<void> {
const notes = getSettings().notesDir
const folders = {
userData: app.getPath('userData'),
sessions: sessionsRoot(),
...(notes === join(homedir(), '.lyra') ? { notes } : {})
}
for (const [name, folder] of Object.entries(folders)) {
const changed = await tightenDir(folder).catch((error: unknown) => {
log('app', 'could not make a folder owner-only', { folder: name, error: errorMessage(error) })
return false
})
if (changed) log('app', 'made a folder owner-only', { folder: name })
}
}

/** Longest the app waits on all its own shutdown work before quitting anyway. */
const QUIT_FLUSH_MS = 12_000
/** Each step's own bound, so one slow step can't use up the others' time. */
Expand Down
3 changes: 2 additions & 1 deletion apps/lyra/src/main/livePass.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { join } from 'node:path'
import { z } from 'zod'
import type { AudioTrack } from '../shared/types'
import type { TranscribedChunk } from './transcriber'
import { PRIVATE_DIR_MODE } from './privateFiles'

/**
* `raw/live.json`: every word transcribed while recording, across all of a session's takes. Each
Expand Down Expand Up @@ -124,7 +125,7 @@ export async function readLiveFile(dir: string, now = new Date()): Promise<LiveR

/** Writes `<dir>/live.json` through a temporary file, so a crash mid-write leaves the old one. */
export async function writeLiveFile(dir: string, pass: Record<string, unknown>): Promise<void> {
await mkdir(dir, { recursive: true })
await mkdir(dir, { recursive: true, mode: PRIVATE_DIR_MODE })
const path = join(dir, LIVE_FILE)
const temp = `${path}.tmp`
await writeFile(temp, JSON.stringify(pass), 'utf8')
Expand Down
12 changes: 10 additions & 2 deletions apps/lyra/src/main/meeting/notes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import type {
} from '../../shared/types'
import { clearCheckpoint, readCheckpoint, writeCheckpoint } from '../checkpoints'
import { log } from '../log'
import { requireMainWindow } from '../session'
import { settle } from '../pendingWork'
import { changeSession, editSession, listSessions } from '../sessionStore'
import { notesLinesOf } from './notesChunks'
Expand Down Expand Up @@ -364,11 +365,18 @@ export function createMeetingNotes(deps: {
onMeetingLabeled((pageId) => {
void writeOwed(pageId)
})
ipcMain.handle('notes:generate', (_event, pageId: unknown) => generateNotes(z.string().parse(pageId), 'manual'))
// These two can send transcripts to a cloud model: the main window only.
ipcMain.handle('notes:generate', (event, pageId: unknown) => {
requireMainWindow(event)
return generateNotes(z.string().parse(pageId), 'manual')
})
ipcMain.handle('notes:summaryEdited', (_event, pageId: unknown) => edited(z.string().parse(pageId)))
ipcMain.handle('notes:state', (_event, pageId: unknown) => stateOf(z.string().parse(pageId)))
ipcMain.handle('notes:backfillStatus', () => backfillStatus())
ipcMain.handle('notes:backfill', (_event, kind: unknown) => backfill(z.enum(['outdated', 'missing']).parse(kind)))
ipcMain.handle('notes:backfill', (event, kind: unknown) => {
requireMainWindow(event)
return backfill(z.enum(['outdated', 'missing']).parse(kind))
})
ipcMain.handle('notes:stopBackfill', () => stopBackfill())
ipcMain.handle('notes:cancel', (_event, pageId: unknown) => jobs.cancel(z.string().parse(pageId), new Error(SUMMARY_STOPPED)))
}
Expand Down
19 changes: 13 additions & 6 deletions apps/lyra/src/main/meeting/pipeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
type SpeakerMatch
} from '../../shared/sessionDoc'
import { log } from '../log'
import { requireMainWindow } from '../session'
import { resolveInNotes } from '../pages'
import { deleteSessionAudio, trackPath } from '../recorder'
import {
Expand Down Expand Up @@ -672,25 +673,30 @@ export async function similarLines(pageId: string, moved: readonly string[], fro
*/
export function registerMeetingPipeline(): void {
ipcMain.handle('people:list', () => listPeople())
ipcMain.handle('people:enroll', async (_event, name: unknown, pcm: unknown, self: unknown) => {
ipcMain.handle('people:enroll', async (event, name: unknown, pcm: unknown, self: unknown) => {
requireMainWindow(event)
if (typeof name !== 'string') throw new Error('Invalid name')
const models = await ensureSpeakerModels()
const embedding = await embedVoice(pcmFrom(pcm), models)
return addPerson(name, embedding, self === true)
})
ipcMain.handle('people:rename', (_event, id: unknown, name: unknown) => {
ipcMain.handle('people:rename', (event, id: unknown, name: unknown) => {
requireMainWindow(event)
if (typeof id !== 'string' || typeof name !== 'string') throw new Error('Invalid input')
return renamePerson(id, name)
})
ipcMain.handle('people:setSelf', (_event, id: unknown) => {
ipcMain.handle('people:setSelf', (event, id: unknown) => {
requireMainWindow(event)
if (typeof id !== 'string' && id !== null) throw new Error('Invalid input')
return setSelf(id)
})
ipcMain.handle('people:delete', (_event, id: unknown) => {
ipcMain.handle('people:delete', (event, id: unknown) => {
requireMainWindow(event)
if (typeof id !== 'string') throw new Error('Invalid input')
return deletePerson(id)
})
ipcMain.handle('people:restore', (_event, id: unknown) => {
ipcMain.handle('people:restore', (event, id: unknown) => {
requireMainWindow(event)
if (typeof id !== 'string') throw new Error('Invalid input')
return restorePerson(id)
})
Expand All @@ -713,7 +719,8 @@ export function registerMeetingPipeline(): void {
resolveInNotes(pageId)
return similarLines(pageId, moved, from)
})
ipcMain.handle('sessions:audio', (_event, pageId: unknown, start: unknown, end: unknown) => {
ipcMain.handle('sessions:audio', (event, pageId: unknown, start: unknown, end: unknown) => {
requireMainWindow(event)
if (typeof pageId !== 'string' || typeof start !== 'number' || typeof end !== 'number') {
throw new Error('Invalid input')
}
Expand Down
4 changes: 3 additions & 1 deletion apps/lyra/src/main/pages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { extname, join, resolve } from 'node:path'
import type { MoveNotesResult, NoteFormat, Page } from '../shared/types'
import { log } from './log'
import { checkSessionsDir, isNoteName, noteInRoot } from './notePath'
import { PRIVATE_DIR_MODE } from './privateFiles'
import { moveSessionFiles } from './sessionStore'
import { getSettings, onSettingsChanged } from './settings'

Expand Down Expand Up @@ -108,7 +109,8 @@ export function parsePage(raw: string, id: string, mtime = new Date().toISOStrin
}

export async function ensurePagesDir(): Promise<void> {
await mkdir(notesDir(), { recursive: true })
// Owner-only when Lyra creates it; a folder the person chose keeps the modes they gave it.
await mkdir(notesDir(), { recursive: true, mode: PRIVATE_DIR_MODE })
}

const pad = (value: number): string => String(value).padStart(2, '0')
Expand Down
Loading
Loading