@inbrief/agent-sdk
v0.2.1
Published
Embed an InBrief Agent widget in any web application.
Readme
@inbrief/agent-sdk
Use the InBrief Agent widget from a web application without managing script tags or global APIs.
import { mountInBriefAgent } from "@inbrief/agent-sdk";
const widget = await mountInBriefAgent({
baseUrl: "https://agent.inbrief.sh",
version: "v1",
agentId: "agent-id",
authorization: {
getAccessToken: async () => {
const response = await fetch("/api/auth/access-token", { credentials: "same-origin" });
if (!response.ok) throw new Error("Authentication required");
return (await response.json()).accessToken;
},
getClientIdentity: () => ({
headerName: "organization-domain",
headerValue: window.location.hostname.split(".")[0],
}),
getUserIdentity: () => ({
id: authenticatedUser.sub,
email: authenticatedUser.email,
}),
},
});
widget.destroy();baseUrl and version are the only InBrief runtime location settings. For example, move a customer from staging to production by changing baseUrl; adopt a future API-compatible widget by changing version from v1 to v2.
The authorization callbacks are the only host-specific integration. The SDK uses them to check the agent assignment before mounting and for each chat turn. getUserIdentity lets InBrief attribute and isolate conversations by the host application's authenticated user. Unassigned clients receive no launcher. Tokens and external user IDs are not persisted by the SDK. Conversation content is retained only in tab-scoped browser session storage for the active host origin and agent.
