Cosmo Docs
Desktop App

IPC API (Preload Bridge)

Full reference for the CosmoDesktopAPI exposed to the renderer

packages/desktop/src/preload/index.ts exposes a typed CosmoDesktopAPI to the renderer via Electron's contextBridge:

contextBridge.exposeInMainWorld('cosmoDesktop', api)

The renderer accesses it as window.cosmoDesktop.

All methods return Promises (or void for event subscriptions that return an unsubscribe function).

window.cosmoDesktop.window

Window control methods for the custom frameless titlebar.

MethodReturnsDescription
minimize()voidMinimise the window
maximize()voidToggle maximised state
close()voidClose the window
isMaximized()Promise<boolean>Current maximised state
onMaximizedChanged(cb)Unsubscribe fnListen for resize events

window.cosmoDesktop.auth

MethodReturnsDescription
get()Promise<StoredAuth | null>Load stored auth
login()Promise<void>Open web sign-in in browser
logout()Promise<void>Wipe data and relaunch
onChanged(cb)Unsubscribe fnListen for auth:changed

StoredAuth fields: token, userId, orgId, userName, userEmail, orgName, orgSlug, role, plan?, onboardingCompleted?.

window.cosmoDesktop.onboarding

MethodReturnsDescription
getUserProfile(userId)Promise<unknown>Load user profile
saveUserProfile(userId, data)Promise<unknown>Save + cloud push
getOrgStatus(orgId)Promise<unknown>Load org onboarding
saveOrg(orgId, data)Promise<unknown>Save org data + cloud push
reset(orgId, userId)Promise<void>Wipe all onboarding data
saveAsset(orgId, fileName, buffer, contentType)Promise<unknown>Store brand asset
resolveAssetUrl(ref)Promise<string>Resolve asset:// to file:// URL
seedOnboarding(data)Promise<{ seeded: boolean }>Seed sample org data
getSampleTasks(orgId)Promise<unknown[]>Get onboarding sample tasks

seedOnboarding takes { companyName?: string; useCase?: string }, not an orgId string.

window.cosmoDesktop.chat

MethodReturnsDescription
listSessions()Promise<SessionInfo[]>All chat sessions
createSession(opts?)Promise<SessionInfo>Create a new session
getMessages(sessionId)Promise<DisplayMessage[]>Messages for a session
deleteSession(sessionId)Promise<void>Delete session + history
sendMessage(sessionId, content, context?, model?)voidStart streaming (events via onEvent)
stop(sessionId)voidAbort in-flight stream
getAvailableModels()Promise<ModelInfo[]>Models list from server
confirmTool(confirmId, approved)voidResolve a pending tool confirmation
extractOnboarding(sessionId)Promise<unknown>Extract memory from onboarding session
onEvent(cb)Unsubscribe fnListen for chat:event

SessionInfo fields: id, title, createdAt, lastUsedAt, messageCount, hidden?, workspaceId?.

ModelInfo fields: id, displayName, provider, tier, contextWindow.

createSession options:

{
  systemPrompt?: string;
  title?: string;
  userId?: string;
  orgId?: string;
  hidden?: boolean;
  onboarding?: boolean;
}

window.cosmoDesktop.connectors

MethodReturnsDescription
getAvailable()Promise<ConnectorType[]>Provider catalog from server
list(token, orgId)Promise<ConnectorInfo[]>Installed instances
add(token, orgId, serverId, label)Promise<ConnectorInfo>Start auth flow + create instance
remove(token, orgId, instanceId)Promise<void>Delete instance + tokens

window.cosmoDesktop.updates

MethodReturnsDescription
getStatus()Promise<UpdateStatus>Current update state
check()Promise<UpdateStatus>Trigger immediate check
download()Promise<void>Start download
install()voidQuit and install
onStatus(cb)Unsubscribe fnListen for updates:status events

window.cosmoDesktop.tasks

The tasks namespace exposes only an event listener — there is no list method here. Fetching tasks goes through the server API directly.

MethodReturnsDescription
onChanged(cb)Unsubscribe fnListen for tasks:changed events

window.cosmoDesktop.workspaces

MethodReturnsDescription
list(orgId)Promise<WorkspaceInfo[]>All user workspaces
get(orgId, workspaceId)Promise<WorkspaceInfo | null>Single workspace
create(orgId, name, teamId?, description?)Promise<WorkspaceInfo>Create a new workspace under the given team
update(orgId, workspaceId, name?, description?)Promise<WorkspaceInfo>Rename or update description
delete(orgId, workspaceId)Promise<void>Delete workspace + local HTML artifacts
onChanged(cb)Unsubscribe fnListen for workspace mutations

window.cosmoDesktop.teams

MethodReturnsDescription
list(orgId)Promise<Team[]>All user teams
get(orgId, teamId)Promise<Record<string, unknown> | null>Single team
listMembers(orgId, teamId)Promise<Record<string, unknown>[]>Team members
onChanged(cb)Unsubscribe fnListen for team mutations

window.cosmoDesktop.artifacts

MethodReturnsDescription
list(orgId, workspaceId)Promise<unknown[]>Artifacts in workspace
get(orgId, artifactId)Promise<unknown>Full artifact with HTML
softDelete(orgId, artifactId, workspaceId?)Promise<{ deleted: boolean; workspaceId?: string; deletedAt?: string }>Soft-delete — moves to Trash; optional workspaceId skips full-org scan
restore(orgId, artifactId, workspaceId?)Promise<{ restored: boolean; workspaceId?: string }>Restore from Trash; optional workspaceId skips full-org scan
purge(orgId, artifactId, workspaceId?)Promise<{ deleted: boolean; workspaceId?: string }>Permanently delete a trashed artifact (no-op on a live one); optional workspaceId skips full-org scan
listTrashed(orgId)Promise<unknown[]>All soft-deleted artifacts across every workspace in the org
onChanged(cb)Unsubscribe fnListen for artifact mutations
onCreated(cb)Unsubscribe fnListen for new artifacts created by AI

window.cosmoDesktop.billing

MethodReturnsDescription
openManage()voidOpen web billing page
getUsage()Promise<UsageSummary | null>User token usage today
getSubscription()Promise<SubscriptionDetails | null>Subscription info
openPortal()Promise<void>Open Stripe portal in browser

window.cosmoDesktop.feedback

MethodReturnsDescription
onCapture(cb)Unsubscribe fnReceive PostHog survey data from AI

Utility

Property / MethodTypeDescription
platformstringdarwin / win32 / linux (direct property, not async)
getAppVersion()Promise<string>Electron app version
openExternal(url)Promise<void>Open URL in system browser
openWebPage(path)Promise<void>Open Cosmo web URL