neeter

API Reference

All exports and types for @neeter/server, @neeter/core, @neeter/react, and @neeter/types

For usage examples, see the Server Guide and Client Guide.

@neeter/server

ExportDescription
SessionManager<TCtx>Manages agent sessions — create, resume, list history, optional persistence
SessionManagerOptionsConstructor options — idleTimeoutMs, store
Session<TCtx>A single session — id, sdkSessionId, context, pushMessage(), permissionGate, abort()
SessionInit<TCtx>Factory return type — model, systemPrompt, permissionMode, mcpServers, extraArgs, env, etc.
ResumeOptionsOptions for SessionManager.resume()sdkSessionId, forkSession, resumeSessionAt
sessionMeta(session)Extract a SessionHistoryEntry from a Session
extractText(content)Pull the text portion from a UserMessageContent value
createJsonSessionStore(dataDir)File-based SessionStore using append-only JSONL + JSON metadata
MessageTranslator<TCtx>Converts SDK messages to SSE events
TranslatorConfig<TCtx>Translator options — onToolResult hook
createAgentRouter<TCtx>(config)Returns a Hono app with session, SSE, resume, and permission routes
PermissionGatePer-session deferred-promise map for tool approval and user questions
PushChannel<T>Async iterable queue for feeding messages to the SDK
sseEncode(event)Formats an SSEEvent as an SSE string
createSandboxHook(dir, resolve)PreToolUse hook that blocks file operations outside a sandbox directory
streamSession(session, translator, onEvent?)Async generator yielding SSEEvents, with optional persistence callback

@neeter/core

Framework-agnostic state management, agent lifecycle, and utilities. Use standalone for vanilla JS apps or as the foundation for @neeter/react.

ExportDescription
AgentClientFramework-agnostic client managing EventSource lifecycle, session creation, resumption, and message sending
AgentClientConfigConstructor options — endpoint, onCustomEvent
ResumeOptionsOptions for resuming a session — sdkSessionId, fork, resumeSessionAt
RewindOptionsOptions for rewinding file checkpoints — dryRun
createChatStore()Creates a vanilla Zustand store
replayEvents(store, events, options?)Reconstruct chat store state from persisted SSEEvent[]. Pass stopAtCheckpoint to truncate at a checkpoint
registerWidget(registration)Register a component for a tool name
getWidget(toolName)Look up a registered widget
stripMcpPrefix(name)"mcp__server__tool""tool"
findMatchingApproval(request, toolCall)Find approval request matching a tool call
isApprovalClaimedByToolCall(request, messages)Check if approval is claimed by any non-terminal tool call in a ChatMessage[]
cn(...inputs)clsx + tailwind-merge utility for class merging

@neeter/react

React-specific hooks, components, and widgets. Re-exports all @neeter/core utilities for convenience.

ExportDescription
AgentProviderContext provider — wraps store + SSE connection. Props: endpoint, resumeSessionId, onCustomEvent
useAgentContext()Returns { sessionId, sdkSessionId, sessionHistory, sendMessage, stopSession, respondToPermission, resumeSession, rewindSession, newSession, refreshHistory, store }
useChatStore(selector)Zustand selector hook into chat state
useAgent(store, config?)SSE connection hook (used internally by AgentProvider). Config: endpoint, resumeSessionId, onCustomEvent
MessageListAuto-scrolling message list with pending permissions and thinking indicator
TextMessageMarkdown-rendered message bubble
ChatInputTextarea + send/stop button (accepts onStop, isStreaming)
ToolCallCardLifecycle-aware tool call display with inline approval
PendingPermissionsRenders pending tool approval and user question cards
RollbackButtonButton that triggers file checkpoint rollback for a given message
ToolApprovalCardTool approval card with Allow/Deny buttons
UserQuestionCardStructured question card with option selection
ThinkingBlockCollapsible card displaying extended thinking text
ThinkingIndicatorAnimated dots shown while agent is generating
CollapsibleCardExpandable card wrapper
StatusDotPhase-colored status indicator
cn(...inputs)clsx + tailwind-merge utility for class merging
registerWidget(registration)Register a component for a tool name
getWidget(toolName)Look up a registered widget
stripMcpPrefix(name)"mcp__server__tool""tool"

Types

Re-exported from @neeter/server, @neeter/core, and @neeter/react:

TypeDescription
SSEEvent{ event: string, data: string }
ChatMessage{ id, role, content, thinking?, toolCalls? }
ToolCallInfo{ id, name, input, partialInput?, result?, error?, status }
ToolCallPhase"pending" | "streaming_input" | "running" | "complete" | "error"
WidgetProps<TResult>Props passed to widget components
WidgetRegistration<TResult>Widget registration — toolName, label, richLabel?, inputRenderer?, component
ChatStoreStoreApi<ChatStoreShape> — vanilla Zustand store
ChatStoreShapeFull state + actions interface (includes totalCost, totalTurns, totalInputTokens, totalOutputTokens, modelUsage, lastStopReason)
TextBlock{ type: "text", text: string } — text content block
Base64ImageSource{ type: "base64", media_type, data } — base64-encoded image source
ImageBlock{ type: "image", source: Base64ImageSource } — image content block
ContentBlockTextBlock | ImageBlock — single content block
UserMessageContentstring | ContentBlock[] — content for a user message
CustomEvent<T>{ name: string, value: T } — structured app-level event
SessionInitEvent{ sdkSessionId, model, tools } — session initialization payload
SessionHistoryEntry{ sdkSessionId, description, createdAt, lastActivityAt } — session metadata
SessionRecord{ meta: SessionHistoryEntry, events: SSEEvent[] } — persistable session data
SessionStorePluggable persistence backend — save, load, list, delete
PermissionRequestToolApprovalRequest | UserQuestionRequest — pending permission
PermissionResponseToolApprovalResponse | UserQuestionResponse — user's answer
ToolApprovalRequest{ kind, requestId, toolName, toolUseId?, input, description? }
ToolApprovalResponse{ kind, requestId, behavior: "allow" | "deny", message? }
UserQuestion{ question, header?, options?, multiSelect? }
UserQuestionOption{ label, description, markdown? } — single option in a UserQuestion
UserQuestionRequest{ kind, requestId, questions: UserQuestion[] }
UserQuestionResponse{ kind, requestId, answers: Record<string, string> }
TokenUsage{ inputTokens, outputTokens, cacheCreationInputTokens, cacheReadInputTokens }
ModelUsageTokenUsage + { webSearchRequests, costUSD, contextWindow } — per-model breakdown
StopReason"end_turn" | "max_tokens" | "stop_sequence" | "refusal" | "tool_use" | null
TurnCompleteData{ numTurns, cost, stopReason: StopReason, usage: TokenUsage | null, modelUsage: Record<string, ModelUsage> | null }

On this page