Open History to see the last commit
1import type { ProviderId } from '@tanstack/ai/byok'
2
3export type Keyring = Partial<Record<ProviderId, string>>
4export type KeyPreview = Partial<Record<ProviderId, string>>
5
6export interface KeyringStorage {
7 readonly id: string
8 readonly label: string
9 readonly persistent: boolean
10 readonly unlockable?: boolean
11 readonly warning?: string
12 peek?: () => KeyPreview | Promise<KeyPreview>
13 load: () => Keyring | Promise<Keyring>
14 save: (keys: Keyring) => void | Promise<void>
15 clear: () => void | Promise<void>
16}
17
18export function memoryStorage(): KeyringStorage {
19 return {
20 id: 'memory',
21 label: 'Session only (not saved)',
22 persistent: false,
23 warning:
24 'Keys stay in memory for this tab only. They are not saved across reloads.',
25 load: () => ({}),
26 save: () => {},
27 clear: () => {},
28 }
29}