Max Avatar can now call Max API's /sessions endpoints: session.ts keeps the access token in memory after login (never persisted, cleared on logout, same lifecycle as the existing email/keys state), a new sessionsClient.ts wraps the 4 endpoints with the Bearer header, and index.ts exposes them as sessions:create/get/send-objective-message/ confirm-objective IPC handlers (input-validated, requireLoggedIn() gated) surfaced to the renderer as window.api.sessions.*. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
38 lines
1.5 KiB
TypeScript
38 lines
1.5 KiB
TypeScript
import { ElectronAPI } from '@electron-toolkit/preload'
|
|
import type { VoiceTurnResult } from '../shared/voice'
|
|
import type { AuthStatus, LoginResult } from '../shared/auth'
|
|
import type {
|
|
ObjectiveMessageResponse,
|
|
SessionObjectiveResponse,
|
|
SessionResponse
|
|
} from '../shared/session'
|
|
|
|
export interface SessionsApi {
|
|
create: () => Promise<SessionResponse>
|
|
get: (id: number) => Promise<SessionResponse>
|
|
sendObjectiveMessage: (id: number, message: string) => Promise<ObjectiveMessageResponse>
|
|
confirmObjective: (id: number) => Promise<SessionObjectiveResponse>
|
|
}
|
|
|
|
export interface ForgeAvatarApi {
|
|
setIgnoreMouseEvents: (ignore: boolean, options?: { forward: boolean }) => void
|
|
getWindowBounds: () => Promise<{ x: number; y: number; width: number; height: number }>
|
|
setWindowPosition: (x: number, y: number, width: number, height: number) => void
|
|
sendVoiceTurn: (audio: ArrayBuffer, mimeType: string) => Promise<VoiceTurnResult>
|
|
showContextMenu: (listening: boolean) => void
|
|
onToggleListening: (callback: (listening: boolean) => void) => () => void
|
|
onProactiveSpeech: (callback: (audio: ArrayBuffer) => void) => () => void
|
|
onUpdateAvailable: (callback: () => void) => () => void
|
|
onUpdateReady: (callback: () => void) => () => void
|
|
login: (email: string, password: string) => Promise<LoginResult>
|
|
getAuthStatus: () => Promise<AuthStatus>
|
|
sessions: SessionsApi
|
|
}
|
|
|
|
declare global {
|
|
interface Window {
|
|
electron: ElectronAPI
|
|
api: ForgeAvatarApi
|
|
}
|
|
}
|