Skip to main content

System Components

X21’s behaviour is defined by three primary subsystems and several supporting services. Understanding what each part is responsible for makes it easier to troubleshoot issues and extend the platform.

Excel VSTO Add-in

  • Task Pane HostingTaskPaneManager and WebView2TaskPaneHost load the compiled React app and bridge messages using chrome.webview.postMessage.
  • Excel API LayerExcelApiService exposes /api/actions/execute which fans out to handlers such as HandleWriteValues, HandleReadFormat, HandleCreateChart, and VBA operations. It uses ExcelSelection to gather workbook metadata and supports staging/undo via the FormatManager.
  • Port & Backend DiscoveryExcelApiConfigService and BackendConfigService keep track of which localhost ports the API and Deno services are using by reading and writing files like excel-api-port-*.txt and deno-websocket-port-*.txt.
  • Telemetry Clients – The add-in integrates with NLog for local diagnostics and PostHogService for behaviour analytics tied to the user email.

Deno Orchestrator

  • Router & WebSocket ManagerRouter upgrades connections, routes events (stream:start, tool:permission:response, etc.), and stores sockets per workbook via WebSocketManager.
  • Tool Executionsrc/tools defines concrete tool classes (WriteValuesTool, AddSheetsTool, VBAUpdateTool, …). Execution flows through toolExecutionFlow, which calls Excel, captures revert data, and updates conversation history.
  • State ManagementstateManager maintains per-workbook conversation history, tool changes, request metadata, and abort controllers. It also records attachments and ensures pending tools are tracked.
  • LLM Clientllm-client/anthropic.ts builds parameter sets for Claude Sonnet 4.5, handles token counting, and performs summarisation during compacting.
  • Observabilitytracing.ts wraps Langfuse, logging each prompt, tool call, auto-approval, rejection, or cancellation as structured traces and spans.

Task Pane UI

  • Authentication ContextAuthContext wraps Supabase’s PKCE flow, persists sessions, and exposes the current user to the rest of the app.
  • Chat Surface – The main chat component streams Claude deltas, renders Markdown, and displays structured tool cards with actions for approve/reject/view/revert.
  • Tool PermissionswebSocketChatService auto-approves whitelisted tools, batches approvals into tool:permission:response, and surfaces errors with actionable messages.
  • Attachments & Metadata – The UI collects workbook metadata via webViewBridge, uploads file attachments (PDFs, PNGs, JPEGs) as base64 payloads, and exposes toggles for auto-approve.
  • Analyticsposthog.ts initialises the PostHog client with the same API key used by the VSTO layer so front-end events align with backend traces.

Shared Contracts

  • Typesdeno-server/src/types/index.ts defines shared TypeScript interfaces for tool requests, WebSocket messages, and Excel API payloads.
  • Port Files%LOCALAPPDATA%\X21 holds deno-server-port-*.txt, deno-websocket-port-*.txt, and excel-api-port-*.txt so each component can discover the others even after a restart.
  • VersioningPublish.ps1 increments the ClickOnce manifest version and renames setup.exe to include x21-setup-v<version>.exe, ensuring clear audit trails.
Together, these components deliver the end-to-end workflow: the UI orchestrates user intent, the Deno server coordinates with Claude and Excel, and the VSTO add-in performs deterministic Excel operations.