@saas-pro-lib/ai
v0.0.1
Published
React provider, hooks, and minimal <AgentChat /> component for the ai/go agentcore GraphQL surface.
Readme
@saas-pro-lib/ai
React hooks and a minimal <AgentChat /> component for the GraphQL surface
backed by saas-pro-lib/sdk/ai/go/agentcore/chat.
The library is a thin client — it consumes whatever Apollo Client you already have in scope and provides three things:
<AgentChatProvider>— Context for lib-wide config (initialMessageLimit)useAgentChat({ agentId, sessionId })— headless hook (messages, send, approve/reject, status)<AgentChat />— opinion-light default UI built on top of the hook
Quick start
import { ApolloProvider } from "@apollo/client";
import { AgentChatProvider, AgentChat } from "@saas-pro-lib/ai";
function App() {
return (
<ApolloProvider client={apolloClient}>
<AgentChatProvider initialMessageLimit={50}>
<AgentChat agentKey="banner-advisor" sessionKey={bannerId} />
</AgentChatProvider>
</ApolloProvider>
);
}The Apollo Client must be configured to talk to the app GraphQL endpoint that
delegates agent operations to agentcore/chat, and have a subscription link
(graphql-sse for HTTP, graphql-ws for WebSocket) wired up — runEvents is a
live subscription.
Headless usage
For custom UIs, drop the component and use useAgentChat directly:
const chat = useAgentChat({ agentKey: "banner-advisor", sessionKey: bannerId });
chat.messages; // ReadonlyArray<Message>
chat.status; // 'idle' | 'running' | 'awaiting_approval' | 'error'
chat.pendingApprovals; // ReadonlyArray<PendingApproval>
chat.send("hello");
chat.send({
text: "このバナーを改善して",
attachments: [{ kind: "image_url", url: bannerImageUrl }],
context: { format: "WIDE" },
});
chat.approve(toolCallId);
chat.reject(toolCallId, "no thanks");What's included (v0.0.1)
- Message list (USER / ASSISTANT / TOOL)
- Input box with Cmd/Ctrl+Enter to submit
- Approval panel for
requiresApprovaltool calls - Live updates via
runEventssubscription - Optimistic local user message until server confirms
What's NOT in this version
- Markdown / code-block rendering (caller can swap in their own renderer once the Response Catalog lands)
- Virtual scrolling for >1000 messages
- ConnectionBanner / JumpToLatest / ThinkingBlock
- Sessions sidebar
- Slash commands /
@mentionautocomplete - Themes / CSS-variable theming
- i18n / a11y shortcuts modal
- Drafts / offline queue
- Voice / TTS / image-gen plugins
These are deliberately out of scope for the MVP and tracked against docs/features/agent-core/requirements.md FR-10..FR-29 for follow-up sessions.
Auth
The library does not own authentication. Configure your Apollo Client links to attach whatever credentials your agent-core-server middleware expects.
