Cosmo Realtime SDK
ReleasesMigration guidesTypeScript

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.

  • RealtimeClient no 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 the RealtimeSession that agent.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) or session.close() (abrupt)
    • client.getSessionId() → session.sessionId
    • client.getConnectTimings() → session.connectTimings
    • client.getLifecycleState() → session.state
    • client.isActive() → read session.state
    • client.isScreenSharing() → session.getScreenShareState().kind === 'active'
    • client.setError(error) → removed; there is no session equivalent
  • RealtimeProvider is fed a session, not a client: the client, getAuthHeaders, and transportFactory props are replaced by session?: 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's session — or your own agent.start() result — and null between runs.

  • useRealtimeClient and the RealtimeClientLike type are removed. Components that need imperative calls from context use useRealtimeSessionContext(), which returns the provider's RealtimeSession | null.