s-m-r-t
Open the s-m-r-t source on GitHub Switch to dark color scheme
← All packages
Agents & runtime v0.57.40 New

@happyvertical/smrt-chat

Rooms, direct messages, threads, persona-bound conversations, tool loops, the AssistantDock, helper preferences, and voice gateway turns.

Source ↗

What it gives you

Rooms, direct messages, threads, persona-bound conversations, tool loops, the AssistantDock, helper preferences, and voice gateway turns.

  1. 01AssistantDock with its own mounted SvelteKit routes
  2. 02Assistant turns that suspend for browser tools and resume with their results
  3. 03Runtime report, overview, and data-surface tools for the persona extraTools seam
  4. 04Two recipes: chat.assistant places the dock in the shell header; chat.rooms brings the room models

Chat is a closed service facade

ChatService keeps its collections and agent-reply bridge private, so callers use the supported conversation operations instead of bypassing membership or lifecycle checks. All seven models expose only generated list and get. allowedTools is fail-closed: an absent or empty allowlist grants no agent tool access. The agent authors as its resolved bot Profile, recorded on the session as agentProfileId, never as the agentId slug.

The tool loop and streams have bounded entry points

runToolLoop and runPersonaConversationTurn use the manifest tool catalog with DEFAULT_MAX_STEPS. Non-manifest extraTools pass the same allow-list; createDataSurfaceTools supplies principal-bound discovery and reads. runChatConversationStream and createChatStreamHandler provide token SSE through SmrtChatBackend. Voice sessions use createVoiceChatSession and handleVoiceGatewayTurn; validate their tenant, actor, persona, and conversation binding because a gateway bearer token is not user authentication. captureChatFeedback records thumbs and can feed learning reinforcement.

The AssistantDock and its routes

AssistantDock reads the mounted descriptors of a host data-surface registry; with none it is plain chat. mountAssistantRoutes from the /sveltekit subpath serves the dock from one catch-all route. The principal comes from event.locals, and threads only from the actor keyed session room. runAssistantTurn runs one turn over the tool loop with server tools and declared browser tools. A browser tool call suspends the turn; the browser resumes it with results, which reach the model marked untrusted. Destructive browser calls always wait for the person.

Report and overview tools for the assistant

createRuntimeReportTools returns reports.runtime.sources, define, list, and run for the persona extraTools seam. The model supplies only a declarative RuntimeReportSpec from smrt-reports, and sources are a server-owned allow-list. A report is saved only after a person confirms the exact spec; without a confirmation host, apply returns an awaiting_confirmation proposal and stores nothing. createOverviewTools returns overviews.describe, apply, and undo over a host-opened overview page.

Questions the assistant asks are data

An assistant turn that asks the person to choose attaches an assistant-question object to its message. Its options come from code that knows the domain, never from model text. AssistantDock renders it as AssistantQuestionForm: a radio group, a select, or checkboxes, with the default preselected. On submit, the transport's optional answerQuestion continues the turn in code with no model round-trip. A transport without it receives the answer as an ordinary message, and a typed reply is matched against the options. parseAssistantQuestion and matchAssistantQuestionText come from the /svelte subpath.

Helper preferences are presentation policy

HelperPreferencesService on the package root loads, saves, and resets a per-profile helper choice under a host-supplied authorize and policy. It is never an identity, persona, or tool authority. Browser code imports the DTO, parser, and field list from the /helper-preferences subpath, which ships no server adapter. HelperControlPanel keeps a local draft apart from the applied snapshot, and FloatingAssistant accepts the saved bottom-corner placement.