Upgrade TypeScript to 0.6
Every breaking change in `cosmo-ai` 0.6.0, with the replacement for each.
Breaking changes when moving cosmo-ai from v0.5.1 to v0.6.0. The changelog has the full release notes; more than one version behind, chain the pages.
-
RealtimeClientno longer carries the session surface — the client is credentials, base URL, and the agent factories (agent,catalogAgent,verify,mintToken,getSessionUsage). Everything scoped to one run lives on theRealtimeSessionthatagent.start()returns: the events, the state getters, the sends, and the media controls.Before:
const agent = client.agent({ instructions: 'You are a helpful assistant.' }); await agent.start(); client.on('transcript', onTranscript); await client.sendText('hello'); await client.disconnect();After:
const agent = client.agent({ instructions: 'You are a helpful assistant.' }); const session = await agent.start(); session.on('transcript', onTranscript); await session.sendText('hello'); await session.end();Most calls keep their name on the session; the ones that don't:
client.sendPing()→session.ping()client.setMicMuted(muted)→session.setMuted(muted)client.disconnect()/client.close()→session.end()(graceful) orsession.close()(abrupt)client.getSessionId()→session.sessionIdclient.getConnectTimings()→session.connectTimingsclient.getLifecycleState()→session.stateclient.isActive()→ readsession.stateclient.isScreenSharing()→session.getScreenShareState().kind === 'active'client.setError(error)→ removed; there is no session equivalent
-
RealtimeProvideris fed a session, not a client: theclient,getAuthHeaders, andtransportFactoryprops are replaced bysession?: RealtimeSession | null. The provider no longer constructs or disconnects a client of its own.Before:
<RealtimeProvider client={client}> <App /> </RealtimeProvider>After:
const { session, start, end } = useRealtimeSession({ makeAgent: (client) => client.agent({ instructions: 'You are a helpful assistant.' }), }); <RealtimeProvider session={session}> <App /> </RealtimeProvider>Pass
useRealtimeSession'ssession— or your ownagent.start()result — andnullbetween runs. -
useRealtimeClientand theRealtimeClientLiketype are removed. Components that need imperative calls from context useuseRealtimeSessionContext(), which returns the provider'sRealtimeSession | null.