How-to Guides
FluxyChat SDK — AI Agent Skill
You are coding with the FluxyChat SDK (`@fluxy-chat/sdk`). Factory functions (`createXyz()`) return interfaces with per-instance state.
FluxyChat SDK — AI Agent Skill
Identity
You are coding with the FluxyChat SDK (@fluxy-chat/sdk). All imports from @fluxy-chat/sdk (subpath entries: ./react, ./room, ./chat, ./testing, ./core, ./markdown, and more). Core pattern: factory functions (createXyz()) returning interfaces with per-instance state.
Modules
Core
- ThreadState —
createThreadState(): thread management with state merging - Outbox —
createMessageOutbox(),createOutboxProcessor(): dedup and flush for outbound messages - Transport —
createWebSocketTransport(),createAdaptiveTransport(),createDurableTransport(): WebSocket transport with backpressure - Sync —
delta-sync.ts: CRDT-like state sync with patches
Media & Voice
- Voice pipeline —
createVoicePipeline(): mic→ASR→LLM→TTS→speaker 5-stage orchestrator with per-stage metrics - Voice quality —
createSloTracker()(TTFA percentiles),createNoiseProcessor()(AEC/noise/gain),createQualityCollector()(snapshot breakdown) - Turn detection —
createTurnDetector(): VAD energy gate + semantic EOT, dynamic endpointing - Voice controls —
createProsodyController()(style/rate/pitch),createDiarizer()(speaker ID/overlap/correction) - Call QA —
createQaAnalyzer(): topic/outcome/sentiment/compliance scoring with evidence spans - Huddles —
createHuddle(): WebRTC join/leave, mute/unmute, screen share, captions, recording consent - Video generation —
createVideoGenerator(): polling progress, cancel, multi-job tracking
AI Tools
- Tool system —
getPresetTools(),buildToolList(),createChatTools(): preset tools with approval configs, tool overrides - Dynamic tools —
dynamicTool(),createDynamicToolRegistry(): runtime tool registration - Call options —
callOptionsSchema(),prepareCall(),createAgentWithCallOptions(): type-safe runtime config - Workflow agent —
createWorkflowAgent(): LLM-powered multi-step agent - Agent delegation —
delegateToAgent(): hand a task off to another agent - Slash commands —
createSlashCommandRegistry(): /command parser - Gamification —
createGamification(): XP/levels/badges/streaks - Moderation —
createModerationEngine(),evaluateModerationRules(): profanity/spam/PII/content policies - Rendering —
ComponentRenderer,renderParts(): pluggable component/message rendering
Real-time Infrastructure
- Relay —
createDecentralizedRelay(): peer-to-peer relay - Failover —
createRegionalFailover(): multi-region fallback - Room —
createFluxyRoomSession(),acquireFluxyRoomSession(),createRoomSequencer(),createBroadcastApi() - Delivery —
createDeliverySemantics(): at-most-once/at-least-once/exactly-once - Streaming —
createFluxyStream(),createResumableAgentStream() - Ephemeral —
postEphemeral(): post an ephemeral message (optional DM fallback)
Enterprise/Security
- Group cipher —
createGroupCipher({ keyMaterial }): AES-256-GCM with HKDF-SHA256 per-epoch keys and AAD binding. (createMlsManager()throws with migration text; it never performed the cryptography it claimed.) - AI governance —
createAiGovernance(): model/prompt/tool registry, risk tiering, approvals - eDiscovery —
createEdiscoveryManager(): legal hold, export, SHA-256 audit log - DLP —
createDlpDetector(): PHI/PCI pattern scan, redact/block/flag - CMK —
createCmkManager(): envelope encryption, key rotation/revocation, tenant-isolated audit - Data residency —
createResidencyValidator(): region pinning, subprocessors, 8 region codes - Policy engine (OPA) —
createPolicyEngine(): enforcing/shadow/disabled, rego-like matching - MCP identity —
createMcpIdentityManager(): server registration, instructions, tool provenance - Bot protection —
createBotProtection(): rate limits, raid mode, trust scoring - Session replay —
createSessionReplayManager(): redacted timeline, consent, deterministic protocol - Federation —
createFederationBridge(): Matrix/ActivityPub/DM bridges - Feature flags —
createFeatureFlagManager(): tenant rollout, kill switch, metric guardrails - Sandbox —
createSandboxExecutor(): isolated runs, quotas, timeouts, multi-runtime - GUI sandbox —
createGuiSandboxManager(): iframe sandbox, CSP, capability grants
Developer Experience
- Testing utils —
createMockAdapter(),matchers(Vitest custom) - Telemetry —
createTelemetryManager(),OpenTelemetryIntegration(),DevToolsTelemetryIntegration() - DevTools —
createDevToolsStore(),createDevToolsInspector() - Deterministic models —
createDeterministicLanguageModel(): scripted output/chunks/errors - Stream fixtures —
streamFixtures,simulateStream(): edge case stream patterns - Error hierarchy —
ChatError,RateLimitError,LockError,NotImplementedError
Patterns
- Factory functions only (no class exports, no module-level state)
- Each factory returns typed interface with per-instance mutable state
- In-memory implementations — deployer wires real infrastructure (LiveKit, Redis, your provider, etc.)
- Tests use
vi.fn()mocks, no external services - Guide docs in
docs/guides/*.mdwith usage examples
Test Command
cd packages/sdk && npx vitest run1,300+ tests across 200+ files.
Adapter Lifecycle & Operations
FluxyChat adapter lifecycle methods provide hooks for cleanup, ephemeral messaging, attachment rehydration, and portable background task tracking.
AI Tool Presets
`createChatTools()` generates a set of AI SDK-compatible tools for chat operations (fetching messages, posting, reactions, etc.) with preset-based filtering and