TypeScript SDK
The frontend now consumes the reusable @infonchat/client package that lives in typescript-sdk/. You can import the SDK from any workspace project to call every REST endpoint and handle streaming responses from InfonChat.
Installation
From the repo root, install the package like any other pnpm workspace dependency:
pnpm install --filter frontend --workspace-root @infonchat/client
If you are developing a new workspace package, add the dependency to its package.json:
pnpm add @infonchat/client --filter my-new-app
Creating a client
import { InfonchatClient } from '@infonchat/client';
const client = new InfonchatClient({
baseUrl: import.meta.env.VITE_API_BASE_URL ?? 'http://localhost:8000',
getToken: () => authStore.getState().token,
onUnauthorized: () => authStore.getState().clearToken(),
});
const agents = await client.agents.list();
The SDK exposes resource-specific helpers on the client instance (e.g. client.memories, client.providers, client.mcpRegistry) that mirror the backend REST resources.
Streaming chat sessions
await client.streamChat({
chatId,
agentId,
message,
onEvent: (event) => {
if (event.type === 'text.delta') {
console.log(event.text);
}
},
});
There is also client.streamUserEvents for subscribing to the SSE event bus.
Regenerating OpenAPI types
When the backend schema changes, refresh the declarations that power the SDK:
pnpm --filter @infonchat/client run generate:api
pnpm --filter @infonchat/client run build
This overwrites typescript-sdk/src/types/api.d.ts and recompiles the package. Remember to commit both the generated types and the compiled output when releasing changes to the SDK.