Skip to main content

Overview

The @standardagents/vue package provides Vue 3 composables and a plugin for building UIs that connect to Standard Agents Builder threads. It handles real-time message streaming, custom event listening, and workblock transformation for tool visualization.

Key Features

  • Real-time WebSocket updates for live message streaming
  • Vue plugin with provide/inject architecture
  • Workblock transformation for UI-friendly tool displays
  • Custom event system for backend-to-frontend communication
  • File uploads and attachments for sending images to the LLM
  • TypeScript support with full type definitions
  • Works with any Vue 3 framework (Nuxt, Vite, etc.)

Installation

npm
pnpm
yarn
Requirements: Vue 3.3+

Quick Start

Plugin Setup

StandardAgentsPlugin

Install the plugin when creating your Vue application to configure the API endpoint.
Options:

Components

ThreadProvider

Component that establishes a WebSocket connection to a thread and provides context to child components.
Props:

Composables

useStandardAgents

Access the Standard Agents client directly for advanced operations.
Returns:

useThread

Composable to access the full thread context. Must be used within a ThreadProvider.

Method Reference

sendMessage

Send a message to the thread. Automatically includes any pending attachments and clears them after sending.
Signature:
Optimistic UI: When you call sendMessage(), an optimistic message with attachment previews is shown immediately. The real message replaces it when confirmed by the server via WebSocket.

addAttachment

Queue file(s) to be sent with the next message. Files are NOT uploaded immediately - they’re held locally with preview URLs and sent inline (base64) when sendMessage() is called. Use this for images/files that should be sent directly to the LLM.
Signature:
PendingAttachment Type:

removeAttachment

Remove a pending attachment before sending.
Signature:

clearAttachments

Remove all pending attachments.
Signature:

addFiles

Upload files to the thread’s filesystem. Files are uploaded immediately and stored persistently. Use this for documents/files that should be stored on the thread but NOT sent directly to the LLM.
Signature:
ThreadFile Type:

removeFile

Remove a pending file upload (cannot remove already committed files).

File URL Helpers


stopExecution

Stop the current agent execution.

deleteMessage

Delete a message from the thread. The message is optimistically removed from the UI immediately. If the server request fails, the message is restored.
Signature:
Note: Server-side attachment files are automatically cleaned up when a message is deleted.

onEvent / subscribeToEvent

Subscribe to custom events emitted by the agent.

addFiles vs addAttachment

Real-time File Synchronization

The files computed ref from useThread() automatically stays synchronized with the server. When files are added, modified, or deleted on the thread (by the agent, tools, or other clients), the files array updates in real-time via WebSocket.

File Events

The SDK listens for three file-related events:

Custom File Event Handling

You can also subscribe to these events directly for custom handling:

How It Works

  1. Initial load: When ThreadProvider mounts, it fetches the current file list from the server
  2. Live updates: WebSocket events update the files array as changes occur
  3. Optimistic UI: Local uploads via addFiles() appear immediately as “uploading” then transition to “committed”
  4. Deduplication: Server files take priority over local pending files with the same path

useThread Return Value

Full ThreadContext: ConnectionStatus:

Custom Events

Listen for custom events emitted by the backend using onEvent from useThread():
Backend Integration: Events are emitted from the backend using emitThreadEvent():

Workblocks

Workblocks are a UI-friendly transformation of tool calls. When useWorkblocks: true, consecutive assistant messages with tool calls are grouped into workblocks.

WorkMessage Type

Rendering Workblocks

Use ThreadProvider with :useWorkblocks="true" and access via useThread():

TypeScript Support

The package is written in TypeScript and includes full type definitions.

Message Type

Complete Example

Next Steps

Core Concepts

Learn about agents, prompts, and tools

React SDK

React hooks and components

Architecture

How the backend framework works

API Reference

REST and WebSocket APIs

Reconnect recovery

A thread provider reads the newest message page after a socket reconnect. preload controls the initial history reads. When preload is enabled, a snapshot after the first socket open closes the initial subscription gap. Recovery also reads history when preload is false. Recovery runs in the background. Snapshot results preserve in-flight events and optimistic mutations. Thread switches invalidate pending history responses. Deletions reconcile within the newest page window. Older cached rows outside that window remain until history is read again.

Shared HTTP transport

Pass a fetch-compatible function as fetch in StandardAgentsPlugin options. Thread requests and endpoint overrides will inherit this transport.
An empty thread ID keeps a provider idle. Its children keep their component instances when the selection changes. canReconnect checks an application auth halt before each retry. onAuthorized runs after an authorized socket opens. Both options are available on ThreadProvider and useThreadSetup. Thread providers adapt a framework-free ThreadSessionStore from @standardagents/client. The store owns message history, live reducers, run status, committed files, and optimistic commands. Reconnect recovery runs once in that shared store. Upload queues and display grouping stay in the framework adapter. Socket frame types are available from @standardagents/client/protocol. Store-owned thread state uses read-only computed refs. This includes messages, pagination flags, connection status, run status, loading and errors. Assignments to these refs fail typechecking. Thread commands update the shared session state. Pending attachment queues retain writable refs.