# tress ## Authentication & revocation URL: /docs/authentication Reuse session access. Add custom authorization and revocation when needed. # Authentication & revocation **`createTressAccess` is optional.** You do not need an external authentication service to connect a terminal. Keep the host's existing access flow, whether that is the Tress demo's shared session or your application's login and thread permissions. ## Choose the app's access method The source-preview CLI supports three app-selected policies: | App policy | User connection | | --- | --- | | API key or bearer token | `tress attach https://app.example --api-key-env MY_APP_API_KEY` | | Explicit anonymous access | `tress attach https://app.example` | | Custom request headers | `tress attach https://app.example --headers-file app-headers.json` | The environment variable holds an **app-issued user credential**, not a model key or project-wide Harness key. The app validates it and decides which conversations are visible. Anonymous access exposes exactly the conversations the app intentionally makes available without a credential. With the [discovery endpoint](/docs/existing-app#4-make-the-app-discoverable-and-connect), normal attachment automatically lists all permitted conversations. The same credentials accompany discovery, list, and thread requests. Thread endpoints remain on the app's origin; credentials are not forwarded through redirects. No new login provider or header file is required for the first two policies. API-key environment flags currently apply to app-origin attachment and `tress threads`; direct thread attachment and `tress ask` use header files. ## Session access and shared commands The Tress demo creates a secret session token and includes it in the copied connection command: ```sh tress attach https://your-demo.example -s YOUR_SESSION_TOKEN ``` That token grants access to the shared conversation. The server looks up its hash and checks the session before accepting the thread's WebSocket. It is different from the thread's public ID. Anyone holding the command can join that session, so share it only with its intended participants. No additional `createTressAccess` setup is needed for this demo flow. For an existing Harness app, reuse its session/access implementation. Tress does not automatically add the demo's token issuance and routes to arbitrary apps. A browser cookie stays in the browser; the app must provide a credential or session-sharing mechanism the terminal can present too. The wrapper is optional; the server's access check still matters. ## Use Harness's existing authorization hook The `statewireHost` used by Harness already accepts `authorize`. If your host uses it, keep it. For example, inside your server's host configuration: ```ts import { statewireHost } from "statewire-node"; const host = statewireHost({ ...existingHostOptions, // transport, protocol, key, storage, onError authorize: async ({ headers }) => { // Application functions: resolve a browser session or terminal credential. const session = await app.authenticateHeaders(headers); if (!session) throw new Response("Sign in", { status: 401 }); if (!await app.canAccessThread(session.userId, threadId)) { throw new Response("Forbidden", { status: 403 }); } // Stable principal: avoid putting a rotating access token in this value. return { subject: session.userId, threadId }; }, }); ``` `existingHostOptions`, `app`, and `threadId` are application code. In the pinned version, this hook gates each attachment and binds its client ID to the returned principal. Commands travel on that authorized WebSocket. Clients attach over a WebSocket at the thread URL plus `/ws`. Browsers can't set headers on a WebSocket, so `headers` is the union of the upgrade request's headers (same-origin cookies, `Origin`) and the headers the client sends in the socket's first message (an `Authorization` token, for example). Upgrade headers win when both carry a name. Credentials never go in the URL or the subprotocol, so they stay out of access logs. The hook does **not** re-run on every command or automatically close an open socket when an application session expires. Keep your existing upgrade checks (including `Origin` for cookie sessions) and connection-lifetime policy. If you want the helper to handle those checks and closure, use the optional adapter below. ## Handle an unauthorized browser connection The pinned `useHarness` API has no option named `onUnauthorized`. Its `StatewireWebsocket` transport provides a `headers({ staleAuth })` resolver and an `onChange` callback. These work with either `useHarness` or assistant-ui's `HarnessThread`. For an app that uses bearer tokens in the browser: ```tsx import { useHarness } from "harness-sdk"; import { StatewireWebsocket } from "statewire"; function useAppThread(threadId: string) { return useHarness({ transport: StatewireWebsocket({ url: `/api/threads/${encodeURIComponent(threadId)}`, headers: async ({ staleAuth }) => { const token = await appAuth.getAccessToken({ refresh: staleAuth }); return { Authorization: `Bearer ${token}` }; }, onChange(connection) { if (connection.status !== "stopped") return; if (connection.reason === "unauthorized") appAuth.showSignIn(); if (connection.reason === "forbidden") appAuth.showAccessDenied(); }, }), }); } ``` `appAuth` represents your own login/refresh/UI functions, not Harness exports. The resolver runs on every attach and reconnect, and its headers travel in the socket's first message, never in the URL. Statewire gives a 401 rejection one recovery attempt with `staleAuth: true`; another rejection stops the connection. A 403 stops it as forbidden. For same-origin cookie sessions, omit `headers`: the browser sends the cookie on the WebSocket upgrade. After signing in again, call `harness.transport.connection.reconnect()` on the value returned by `useHarness`. These callbacks recover or display an access failure; server-side checks decide who can connect. They do not add credential refresh to the native Tress CLI. ## Optional: application header credentials An app can issue a separate terminal credential for independent expiry and revocation. Store its hash, owner, allowed thread or workspace, expiration, and revocation status. Keep provider and project-wide keys on the server. The preview CLI reads HTTP headers from a private JSON file: ```json { "Authorization": "Bearer APP_ISSUED_TERMINAL_TOKEN" } ``` Replace the placeholder through your application's credential issuance flow. Custom application headers also work. On Unix, the file must have private permissions. HTTPS is required except on loopback for local development or SSH forwarding. ```sh chmod 600 app-headers.json tress attach https://chat.example.com/api/threads/main \ --headers-file app-headers.json --ui ``` This works with your existing authorized host; `@tress/access` is not required. The client sends the headers with discovery, list, and thread connections, refuses redirects, and does not forward them when switching to a different origin. Obtain a fresh file and reattach after expiry; the CLI does not implement OAuth or automatic token refresh. ## Optional: extra checks and live revocation Use `createTressAccess` if you want a reusable adapter for authorizing each WebSocket, same-origin checks for cookie sessions, and closing expired or revoked connections. It works with your own session store or identity provider; it does not require an external auth service. ```ts import { createTressAccess } from "@tress/access"; const access = createTressAccess({ host: existingThreadHost, origin: appOrigin, authorize: async ({ request, action }) => { // Your app validates the session/credential and this thread's permissions. const grant = await app.authorizeThread(request, threadId, action); if (!grant) throw new Response("Forbidden", { status: 403 }); return { subject: grant.userId, connectionId: grant.id, expiresAt: grant.expiresAt, // milliseconds since Unix epoch }; }, }); // Hand each `/api/threads/:id/ws` upgrade to this same long-lived instance. // `existingThreadHost.upgrade` comes from statewire-node. await listenFetch({ fetch: (request) => access.fetch(request), upgrade: (request) => access.upgrade(request), }, { port: 3000 }); ``` `listenFetch` comes from `@assistant-ui/pinboard/node`; `access.upgrade` returns a refusal Response or a Pinboard `Accept`, which it completes. With another server, accept the `statewire.v1` subprotocol and call `accepted.attach(socket)`. The [reference app](https://github.com/assistant-ui/tress/blob/main/examples/existing-app/server.mjs) shows a full server. `authorize` receives a `request` whose headers combine the upgrade's headers with the socket's first-message headers, and the adapter authorizes the socket before the host sees any frame. `access.fetch` still serves `/stream` and `/frames` for older Tress CLI releases. `@tress/access` is a private source-preview package in `packages/access`, not a published npm dependency. Use a TypeScript-aware build or Node 24. Your app supplies the host, canonical origin, thread, and authorization function. The [reference app](/docs/local) demonstrates this optional setup. To revoke a connection, persist the decision in an authenticated application action, then notify the adapter: ```ts await app.terminalGrants.revoke(connectionId, currentUser.id); access.revoke(connectionId); ``` Your app checks ownership and stores the revocation durably. `access.revoke` closes that grant's open sockets and denies subsequent attachments on this adapter. After restart, `authorize` must still reject revoked credentials. Give the browser and terminal separate grant IDs if they need independent revocation. Disconnecting a client does not undo admitted commands or stop the agent's run. For multiple workers, broadcast revocation to every worker holding an affected socket. A database update alone cannot close a socket on another process. The adapter also closes sockets at expiry, even when the thread is quiet. A managed access service remains future, optional work. Neither it nor this adapter is required to reuse an application's existing authorized host. --- ## Embedding and runtimes URL: /docs/embedding The engine is portable; the host supplies storage and tools, and clients control its thread. # Embedding and runtimes Embedding Tress means using its engine or connection layer in your own application. A browser can load the Rust/WASM engine with browser-compatible tools, or act as a client of a machine host. Loading WASM alone does not give a browser native filesystem access or durable background execution. ## Choose the boundary | Component | Use it for | Current runtime | | --- | --- | --- | | Rust engine and `tress-wasm` | Run the agent with tools supplied by your application | Native Rust, or WASM with JavaScript bindings | | `@tress/workspaces` | Supply filesystem/tool adapters and checkpointable engine context | JavaScript host; Node for native disk adapters | | `@tress/harness-host` | Give the engine a shared Harness thread and persistence | Node 22+; standalone host wraps it with disk storage and HTTP access | | `@tress/client` | Connect an interface to a Harness thread; optionally reuse Tress UI | JavaScript; the standalone browser uses this internal package | | Native Tress CLI | Control a machine host or an application's Harness threads | Native Rust executable | These JavaScript packages are repository-local source previews, not published public npm packages. Existing assistant-ui applications do not need to add the Tress UI package to [enable terminal access](/docs/existing-app). ## What runs in WASM? The standalone host loads the **Rust agent engine** as WASM in Node's V8 runtime. Its browser uses the JavaScript Harness client; its terminal uses a native Rust protocol client. They share the host's thread, rather than running independent copies of the agent. The complete terminal UI is not compiled to browser WASM. The native executable embeds the host's assets but still launches an installed Node runtime. A self-contained V8 executable and a stable public embedding API remain future work. ## Keep storage on the host Supply a workspace adapter for files and tools, and Harness storage for the conversation. Saving an engine checkpoint alone does not start a shared host. Clients send commands to the host and observe its state; closing a client should not own the lifetime of the agent. For machine-backed artifacts, the host writes ordinary project files and serves authorized reads to interfaces. Managed conversation storage does not automatically sync those files. File versioning, artifact metadata, and remote backup policy remain application responsibilities. The [workspace adapter examples](https://github.com/assistant-ui/tress/blob/main/packages/workspaces/README.md) show engine embedding. The [machine host source](https://github.com/assistant-ui/tress/tree/main/packages/harness-host) shows the Harness and storage composition. Start with [Run on your machine](/docs/workspace) to use the assembled product. --- ## Connect an existing app URL: /docs/existing-app Keep your assistant-ui UI and agent. Expose its server-owned thread. # Connect an existing app The integration adds **the native Tress terminal as another client**. Keep your assistant-ui interface, existing agent, tools, and login. There is no Tress React component, browser client package, or stylesheet to install. This source preview needs a Statewire host using Harness protocol `2026-09-13`. The browser and terminal must connect to that **same thread host**. An ordinary AI SDK `/api/chat` route does not, by itself, own a shared conversation. If you already have an authorized server-owned Harness endpoint and an app-issued terminal credential, add discovery and [connect the terminal](#4-make-the-app-discoverable-and-connect). No new Tress server or browser dependency is required. Otherwise, the [runnable example](/docs/local) demonstrates the host and credential boundary. ## 1. Reuse the thread host If your app already has a server-owned Harness thread, keep it and its existing session/access checks. Its WebSocket upgrade handler is the integration point. **`createTressAccess` is optional.** Tress does not require another auth provider or a wrapper around an already authorized host. ```ts // Your upgrade handler for GET /api/threads/:id/ws. It returns a refusal // Response or the host's accept; Pinboard's `listenFetch({ fetch, upgrade })` // (or `appFetch` inside a Hono route) completes the handshake. Another // WebSocket server accepts `statewire.v1` and calls `accepted.attach(socket)`. const upgrade = async (request: Request) => { // Application code: check Origin for cookie sessions, then this thread's // permissions. Credentials sent in the first frame reach the host's // `authorize({ headers })` (see the access guide). await app.requireThreadAccess(request, threadId); return existingThreadHost.upgrade(request); }; ``` Keep serving `existingThreadHost.fetch` at `/stream` and `/frames` while older Tress CLI releases may still connect over HTTP. Current clients attach over the WebSocket only. `existingThreadHost`, `app`, and `threadId` come from your app. Resolve the thread and its owner before selecting the host. Do not create a fresh host on every HTTP request. A public thread ID alone does not authorize a connection. The terminal needs a credential your host understands; the browser's cookie is not automatically transferred to the CLI. The [access guide](/docs/authentication) covers the demo's built-in session sharing, Harness's native `authorize` hook, and the optional access adapter. ## 2. If the browser currently owns the transport Move that transport to a server-owned host first. The upstream source packages provide this composition: ```ts import { statewireHost } from "statewire-node"; import { AISDKTransport } from "@harness-sdk/ai-sdk"; import { HARNESS_HOST_PROTOCOL } from "harness-sdk/host"; import { DirectChatTransport } from "ai"; const existingThreadHost = statewireHost({ protocol: HARNESS_HOST_PROTOCOL, key: [threadId], transport: (restored) => AISDKTransport({ threadId, transport: new DirectChatTransport({ agent: existingAgent }), ...(restored ? { initialState: restored as AISDKTransport.State } : {}), }), storage: { load: () => app.threadSnapshots.load(threadId), save: (snapshot) => app.threadSnapshots.save(threadId, snapshot), }, onError: (error) => app.reportStorageError(error), }); ``` This is a composition example: supply your existing AI SDK agent, snapshot store, and error reporting. These Harness adapters are currently upstream source packages; see [versions](/docs/reference). There is **no required `CHAT_BACKEND_URL`**. A transport can call the existing agent in-process. If your app already uses HTTP between services, keep its own configured transport. ## 3. Only if needed: point assistant-ui at the shared thread Skip this step if your browser already uses that server-owned Harness thread. Keep its existing components and provider. If you moved a browser-owned transport to the server in step 2, update only the runtime/provider wiring: ```tsx import { AuiConfig, AuiProvider } from "@assistant-ui/react"; import { HarnessThread } from "@assistant-ui/react-harness-sdk"; import { StatewireWebsocket } from "statewire"; const config = AuiConfig({ thread: HarnessThread({ transport: StatewireWebsocket({ url: "/api/threads/main" }), }), }); export function Assistant() { return ; } ``` For dynamic conversations, scope the provider and endpoint to the selected thread. The browser dials `/api/threads/main/ws` and sends its same-origin session cookie on the upgrade. ## 4. Make the app discoverable and connect Publish `GET /.well-known/tress.json` as `application/json`: ```json { "version": 1, "threads": "/api/thread-list", "thread": "/api/threads/{id}" } ``` Point `threads` at the app's authorized Harness thread-list transport (`harness-sdk-threads`, version `2026-09-13`). Return all conversations this credential permits, including archived ones. Reuse your existing index and storage. Point `thread` at the corresponding server-owned Harness hosts. Both endpoints serve Statewire's WebSocket at `/ws` on the same app origin. Filter the list by the authenticated user and check each thread independently. The [source integration guide](https://github.com/assistant-ui/tress/blob/main/docs/terminal-integration.md) specifies the manifest and ID constraints; the example server demonstrates it. The user connects once, then chooses from the app's accessible threads: ```sh # MY_APP_API_KEY contains the user's app-issued API key / bearer token. tress attach https://chat.example.com --api-key-env MY_APP_API_KEY # If the application explicitly permits anonymous access: tress attach https://chat.example.com ``` No header file is required for either flow. For custom header authentication, use `--headers-file app-headers.json` with a private JSON object of headers; see the [access guide](/docs/authentication). The app chooses its auth policy. Managed Harness keys remain on the application's backend, which can proxy both the list and threads using the same authorization. Attachment automatically lists every accessible thread, including those never visited in this terminal. Choose a number to load existing history. Add `--ui` for the terminal interface. `/threads` or Ctrl-T refreshes the list; plain mode also supports `/thread ID`. The CLI refreshes on connection and picker opening, not continuously in the background. Direct thread URLs still work when a specific conversation is known: ```sh chmod 600 app-headers.json tress attach https://chat.example.com/api/threads/main \ --headers-file app-headers.json ``` The [Tress demo](/docs/try) uses its separate secret-session command. It grants access to that one session, not the visitor's entire account history. Discovery does not change the existing demo's access policy. Verify messages from each client, reconnect, and your app's expiry policy before following the [production walkthrough](/docs/production). These commands are a source preview; build this checkout. Published v0.3.0 does not include app discovery. Generic CLI browser login, automatic token refresh, and thread creation remain future work. --- ## One workspace, any interface. URL: /docs Keep the agent and files on a machine. Use the same workspace from a browser or terminal. # One workspace, any interface. Tress is a coding agent with a workspace that lives on your laptop, VM, or server. Use the terminal or open its browser interface to work with the same conversation and files. You do not need an existing assistant-ui application to start a Tress workspace. ```text Browser interface ──┐ ├── Machine host: agent + tools + workspace files Terminal client ────┘ └── Harness conversation persistence ``` The host performs the work. Clients send requests and display the results. For example, ask the terminal to create a file, preview that file in the browser, and continue the conversation there. The file stays on the host's disk; the browser does not need native filesystem or process access. ## Choose where to start | You want to… | Start here | | --- | --- | | Work on your own project | [Run on your machine](/docs/workspace). Start the host in a folder, then use its terminal or browser interface. | | Try Tress before running a host | [Try the hosted demo](/docs/try). The website supplies the agent and conversation host. | | Continue conversations from an existing assistant-ui app | [Connect an existing app](/docs/existing-app). Keep its UI, agent, and identity; Tress becomes another client. | | Embed the engine or connect your own interface | [Embedding and runtimes](/docs/embedding). Choose the engine, host, or client boundary you need. | **Release status:** the durable machine host and existing-app discovery are source previews. Build this checkout to use them. The installer currently provides v0.3.0, whose local conversation is not saved after exit. See [versions and limits](/docs/reference) before choosing an installation path. ## What survives closing a client? Closing the browser or terminal disconnects that interface. The machine host keeps running. Reconnect to continue the same conversation; restart the host to restore saved completed turns. The standalone preview has one saved thread per project. Recovery of a tool interrupted by a host crash is still unfinished. Local mode saves Harness conversation snapshots on the machine. Optional managed Harness stores the conversation remotely while execution and files stay on the machine. Conversation persistence does not back up project files. Use persistent disks and backups for those files. ## Connect an existing application An existing assistant-ui app is another way to use Tress. Its backend already supplies the agent and tools. Expose its authorized Harness threads and let users attach from a terminal. They see the conversations their credential may access without installing Tress browser components or moving execution to their terminal machine. The app chooses API-key, anonymous, or custom access. Built with [Farming Labs Docs](https://docs.farming-labs.dev). --- ## App development URL: /docs/local Develop terminal access for an existing assistant-ui application. # App development This guide is for developers integrating an existing application. To work on your own project with Tress's agent, start with [Run on your machine](/docs/workspace). ## Run the complete reference app Use Node 26 LTS (24+ works) and stable Rust. From this repository's root: ```sh cargo build --locked -p tress npm --prefix examples/existing-app ci npm --prefix examples/existing-app run build cd examples/existing-app APP_PASSWORD=local-example-password PUBLIC_ORIGIN=http://localhost:3000 npm start ``` Open `http://localhost:3000` and sign in with `local-example-password`. The sample agent echoes messages without a model key. Download a terminal credential, then follow the browser-first steps below using the built binary and the file's actual download path. The reference app demonstrates one owner and one thread, including the **optional** `createTressAccess` adapter and separate terminal grants. Existing apps can keep their own session/access implementation. Replace this example's password login with your application's identity provider for production. Its `AGENT_MODULE` option accepts a module exporting your existing AI SDK agent; no separate chat-backend URL is required. ## Use your existing application Build the preview CLI from this checkout: ```sh cargo build --locked -p tress ./target/debug/tress --help ``` Start your existing application with its normal development command after adding [the integration](/docs/existing-app). Keep its thread host alive outside the lifetime of an individual browser tab. ## Browser first 1. Open `http://localhost:3000`, sign in, and select a conversation. 2. Use the app's terminal-sharing action. The reference app issues a separate grant; save its header file privately. The [website demo](/docs/try) instead supplies a command containing its secret session token. 3. Copy the thread endpoint and connect. For the reference app: ```sh chmod 600 app-headers.json ./target/debug/tress attach http://localhost:3000/api/threads/main \ --headers-file app-headers.json ``` 4. Send a message in either client. Both should show one reply. 5. Close the terminal mid-run and reconnect. The host keeps working. ## Terminal first Obtain the endpoint and any required credential through your app's access flow, then run the same command. The preview discovers existing threads when the app publishes its manifest: ```sh tress attach http://localhost:3000 --api-key-env MY_APP_API_KEY ``` The variable holds an app-issued bearer credential. Omit the flag only when the app allows anonymous access; use `--headers-file` for its custom headers. The reference app above uses a downloaded grant file. Thread creation and a generic browser login flow remain separate work. Have the app provide the browser URL for that thread alongside its endpoint: ```ts const connection = { endpoint: new URL(`/api/threads/${encodeURIComponent(threadId)}`, appOrigin).href, browserUrl: new URL(`/chat/${encodeURIComponent(threadId)}`, appOrigin).href, }; ``` These routes are examples; use your application's actual routing. The browser URL selects the thread and still requires the app's normal login. ## Remote development machine Run the app on the remote machine, then forward its local port: ```sh ssh -L 3000:127.0.0.1:3000 user@your-server ``` Open `http://localhost:3000` and use the same local attach command on your laptop. Here, SSH carries traffic to the remote host. No public domain is required. The remote host still runs the agent and owns its workspace. --- ## Production URL: /docs/production Run a private machine workspace or deploy an existing application with a durable thread owner. # Production ## Private machine workspace For a personal laptop or VM workspace, follow [Run on your machine](/docs/workspace). The standalone host binds to `127.0.0.1`. On a VM, keep its project disk and state directory persistent, then forward the actual port printed by Tress: ```sh # Replace 5311 with the printed port on both sides. ssh -L 5311:127.0.0.1:5311 user@your-server ``` Open the printed private browser URL on your laptop with the forwarded port. Preserve `127.0.0.1` and the port because this host validates Host and Origin. The host remains on the VM; closing a browser does not move its files or agent. The preview is single-owner and has no public multi-user deployment flow. Managed Harness stores conversations, not a backup of the VM disk. ## Existing application deployment The rest of this guide applies to your application's authorized Harness host, not to exposing the standalone loopback listener directly on the internet. The initial self-hosting topology is one long-running thread owner behind an HTTPS reverse proxy. Reuse an existing durable Harness deployment when your application already has one. ```text browser ──┐ ┌─ durable conversation storage ├─ HTTPS app address ── thread owner ── existing agent terminal ─┘ └─ workspace / tools ``` ## Configure the owner Use your application's canonical public origin when creating connection commands and browser links. The deployment platform or DNS points that domain to the app. Tress learns the address from the connection command; it does not guess where you deployed the server. ```ts const appOrigin = "https://chat.example.com"; const endpoint = new URL(`/api/threads/${encodeURIComponent(threadId)}`, appOrigin).href; const browserUrl = new URL(`/chat/${encodeURIComponent(threadId)}`, appOrigin).href; ``` Use your application's actual route paths. Keep its session/access checks on the host. `createTressAccess` is optional; if you use it, pass this same `appOrigin` as its `origin`. [Access options](/docs/authentication) explains native Harness authorization and the additional connection-lifetime checks. Provide durable snapshots and storage for the access records your app uses, a process supervisor, and a shutdown path that flushes the thread host. Snapshot persistence can restore completed conversations; it does not make an in-flight external side effect exactly once. Surface interruptions and use your agent's recovery policy. ## Forward streaming requests For an Nginx reverse proxy in front of a host listening on port 3000, the thread route needs streaming and a long enough idle timeout: ```nginx location /api/threads/ { proxy_pass http://127.0.0.1:3000; proxy_http_version 1.1; proxy_buffering off; proxy_cache off; proxy_read_timeout 3600s; proxy_set_header Host $host; proxy_set_header X-Forwarded-Proto $scheme; } ``` This location belongs in your existing HTTPS server configuration. TLS, certificates, and the app's remaining routes still come from your deployment. Keep the host's heartbeat shorter than the proxy's idle timeout. ## Connect from any terminal Build the compatible source-preview client and expose the app's discovery manifest, authorized thread list, and per-thread endpoints. For bearer access: ```sh tress attach https://chat.example.com --api-key-env MY_APP_API_KEY ``` Tress lists all conversations that credential may access. An explicitly anonymous app can omit the flag. Custom authentication can use a private `--headers-file`; see [access options](/docs/authentication). There is no software to install on every user's browser. The app serves its existing assistant-ui interface. The integration runs on the thread host. ## Verify before rollout 1. Join the same private thread from a browser and another machine's terminal. 2. Send from each. Check shared history, streaming, and one execution per prompt. 3. Disconnect during a run. Reconnect without replaying the prompt. 4. Try a different user's credential. Deny both reads and commands. 5. Verify your session expiry/revocation policy on open connections and later commands. With separate grants and the optional adapter, revoking the terminal closes its connection while the browser continues. 6. Restart after a completed turn. Restore history and keep revoked credentials denied. 7. Repeat through the actual HTTPS proxy (it must forward WebSocket upgrades) and test an expired credential. ## Scaling and serverless Multiple hosts do not become a shared thread owner merely by sharing a database. Route a thread's WebSockets to one owner, or use the existing Harness routing infrastructure. If your access policy supports live revocation, broadcast it to every owner holding an affected connection. A request-limited frontend can serve the UI, but it needs a durable worker or thread service for long-running agents. Do not assume an in-memory host inside a request handler will survive after the request or deployment ends. --- ## Versions & limits URL: /docs/reference What this preview supports, and what still needs upstream release work. # Versions & limits | Component | Preview source | | --- | --- | | Tress | Build the native client from this checkout. Published v0.3.0 supports Tress-specific hosts. | | Rust Statewire client | Git revision `684168fd5ed6eb87e1ff90b166446311d9837aeb`, adding `http::connect_with_headers`; no new crates.io release is implied. | | Harness thread and thread-list protocols | `2026-09-13` | | JavaScript Statewire | `0.19.4` | | assistant-ui | `@assistant-ui/react` `0.15.28`, `@assistant-ui/tap` `0.9.23` in the reference app | | AI SDK | `7.0.114` in the reference app | | Optional access adapter | `packages/access`, source package; Node 24 or a TypeScript-aware build. Existing host auth can be used directly. | | Harness adapters | Upstream source at `c07dab9b1eb32a3800d2bad25e807efa0cfeedef`; several are not published on npm. | | Managed Harness client (hosted sessions) | `harness-sdk` `0.6.0` from upstream `b49366450c98baa83bc94238f57393ba114894be`: protocol `2026-11-04` (minimum `2026-09-30`) on JavaScript Statewire `0.28.4`. | The installer currently provides v0.3.0. Its `attach` joins chat; use the separate `connect` command for paired folders. Combined `attach` file sharing and the Harness commands below require a source build. See the [release and source-preview steps](/docs/try#build-the-source-preview). The CLI can negotiate the existing Tress host or a Harness host, display the active branch's text and tool activity, and submit text to a known thread. App-origin attachment discovers all permitted threads through the app's manifest and authorized list endpoint. It refreshes the list when connecting and opening the picker. Harness preloads its recent message window; full message-history pagination, thread creation, and OAuth credential refresh remain follow-up work. For an existing app, use its browser interface for approvals and history management when that app supports them. The standalone machine host does not provide per-command approval dialogs. Adding the client does not add cancellation, branching, or approval capabilities to your existing agent. ## Machine host and embedding The [machine workspace](/docs/workspace) source preview starts or resumes one Harness conversation per project. Local snapshots survive completed-turn restarts; managed mode uses HarnessCloud while files and execution stay on the machine. Live managed deployment and the native release matrix remain to be validated. No new CLI release has been published. The host requires Node 22+, binds to loopback, and grants tool permissions at startup. It has no per-command approval dialog or automatic interrupted-tool recovery. Conversation persistence does not back up or version project files. The Rust engine runs natively or as WASM. The terminal remains a native client, and the browser uses the JavaScript Harness client. Public embedding packages and a self-contained V8 runtime remain future work; see [embedding and runtimes](/docs/embedding). ## Commands ```sh # Automatically browse all permitted threads (app publishes discovery). tress attach https://chat.example.com --api-key-env MY_APP_API_KEY # Explicitly anonymous app; no credential file. tress attach https://public-app.example.com # Script the same list, or directly select a listed ID. tress threads https://chat.example.com --api-key-env MY_APP_API_KEY --json tress threads https://chat.example.com --api-key-env MY_APP_API_KEY --open main # Known Harness thread endpoint; preserve your app's routing. tress attach https://chat.example.com/api/threads/main --headers-file app-headers.json # Full terminal UI. tress attach https://chat.example.com/api/threads/main --headers-file app-headers.json --ui # One prompt, then exit when the host's reply finishes. tress ask --host https://chat.example.com/api/threads/main --headers-file app-headers.json "Explain this project" # Existing Tress demo session. tress attach https://your-demo.example -s YOUR_SESSION_ID ``` `--api-key-env` reads a bearer credential from the named variable for app-origin attachment or `tress threads`. `--headers-file` accepts a private JSON object of header names and values for custom auth, direct attachment, and one-shot use. Choose one method. Statewire and HTTP framing headers are reserved. `/attach` includes the variable name or file path, never the credential value. The demo's `-s` value is a secret session token; its copied command grants session access. ## Common connection failures | Symptom | Check | | --- | --- | | Cannot connect | Is the app origin or complete thread endpoint reachable from this machine? | | No discovery | Serve `/.well-known/tress.json` as JSON and expose the authorized Harness list. Direct thread URLs still work. | | Access ended | Reauthenticate through the app and obtain a new grant. Do not blindly resend an in-flight prompt. | | Empty history | Are both clients using one server-owned Harness host and the same thread? | | Works directly, fails behind proxy | Check buffering, idle timeout, routing to the correct owner, and the canonical origin. | | Browser works, terminal denied | Check the terminal grant's subject, thread permissions, expiry, and private file permissions. | Managed authentication and new-project scaffolding remain planned. Existing applications retain control over their auth provider and deployment. --- ## Try the browser demo URL: /docs/try Start on the website, then join from a terminal. # Try the browser demo 1. Open [the demo](/#demo) and start a conversation. 2. Choose its terminal connection action. It supplies the host address and secret session token for that conversation. 3. Install Tress with the command shown on the website, or build from source. 4. Run the copied connection command. For example: ```sh tress attach https://your-demo.example -s YOUR_SESSION_ID ``` The URL and ID above are placeholders. Use the values from your own demo session. The `-s` value is an access token, not just a public thread ID. Anyone holding that command can join the session. The demo validates it internally; no external auth service or `createTressAccess` setup is required. A bare host address selects its default thread; `-s` selects a Tress demo session. Send a prompt from the terminal. Its response appears in both clients. Add `--ui` to use the full terminal interface. ## A fresh session on refresh Every page refresh starts a new demo session, even when the URL contains the previous session ID. The header, browser URL, and copied terminal command all use the new ID. Earlier threads remain available in the sidebar. Opening a session link or selecting a sidebar thread resumes that conversation. Reconnecting within the page keeps the current session. Terminals and connected folders stay attached to their original session; copy the new command if you want them to join the refreshed session. Refreshes count toward the demo's session-creation limits. Hosts using `TRESS_DEMO_SHARED=1` keep a single shared thread instead. ## Connect your computer or VM The installer currently provides **v0.3.0**. Its `attach` command joins the conversation; it does not share your machine's files. To connect files and chat in one terminal, [build the source preview](#build-the-source-preview), open **connect folder**, and run the command shown there on your computer or VM: ```sh tress attach https://your-demo.example -s YOUR_SESSION_ID --ui ``` The default demo connects automatically. It has no pairing form or code-entry step. The browser shows the connected machine, its permissions, and its files. The same terminal opens the chat. Keep it running while using the files. Access is read-only by default; add `--allow-write` for edits. Add `--root /path/to/project` to restrict sharing to a folder, or `--chat-only` to join without sharing files. Closing the connector stops file access while the conversation remains available. Run the same command to reconnect. ## Build the source preview Combined chat and file sharing through `attach`, including `--root`, `--allow-write`, and `--chat-only`, requires the current source build. These options are not in the published v0.3.0 binary. With Rust installed: ```sh git clone https://github.com/assistant-ui/tress.git cd tress cargo install --locked --path crates/tress ``` If you already have the repository, use its current checkout. Run the binary installed by Cargo (`~/.cargo/bin/tress` on macOS/Linux), or put that directory before `~/.local/bin` on PATH. Both builds currently report `0.3.0`, so the version string alone does not identify the source preview. With that source build, run the copied `attach` command again. By default, it offers the terminal machine's whole filesystem, read-only. The session command connects directly in the default demo. Use `--root /path/to/project` to restrict the scope, or `--chat-only` to join without offering files. Whole-filesystem access includes personal files your terminal can read, subject to OS permissions; symlinks and special files remain unavailable. Close the terminal to stop sharing. Run the command again to resume access. ```text /status show connection and host details /disconnect stop sharing and exit (chat-only mode can /reconnect) /exit leave the terminal client ``` Add `--ui` to use the full terminal interface: ```sh tress attach https://your-demo.example -s YOUR_SESSION_ID --ui ``` To restrict sharing to a real project folder from your computer or VM, use: ```sh tress attach https://your-demo.example -s YOUR_SESSION_ID --root . --allow-write --ui ``` Run it in the project folder. Once the terminal UI opens, both clients can then ask the agent to read and edit that folder. Omit `--allow-write` for read-only access. `/exit` or `/disconnect` stops sharing. No shell execution is exposed, and switching chats requires exiting first. The site must be reachable from the machine running the command; `localhost` always means that machine. ## Optional pairing and browser approval Pairing remains available behind host environment flags: | Host settings | Behavior | | --- | --- | | Both flags unset or `0` | Default demo: direct connection, no pairing controls | | `TRESS_SHOW_PAIRING=1` | Adds **Have a pairing code?** under **connect folder**; modern `attach` still connects directly | | `TRESS_REQUIRE_PAIRING=1` | Requires browser-owner approval and always shows the code form, even with `TRESS_SHOW_PAIRING=0` | Both flags accept `1` or `true`. Change them on the server and restart or redeploy it. Showing optional pairing does not change access permissions. When pairing is required, enter the terminal's code in the browser before it connects. Older hosts may also require this step. On those hosts, the released v0.3.0 CLI can share a folder from a separate terminal with `tress connect --site --root .`. With optional pairing, choose **Have a pairing code?** to enter its code. That legacy code-based flow is hidden in the default demo; use the source-preview `attach` command for its direct connection. The public demo has its own access model. To connect an application you own, follow [existing apps](/docs/existing-app); adding a URL alone does not make an arbitrary chat website compatible. --- ## Run on your machine URL: /docs/workspace Start a persistent Tress workspace on your laptop, VM, or server. # Run on your machine Start Tress in a project folder. It runs a background Harness host, connects the terminal, and prints a private URL for the same workspace in your browser. The host uses Tress's agent and existing browser UI; no application scaffold is needed. **Source preview:** the published v0.3.0 installer does not include this host. For now, build and install it from source. The host machine needs Node 22+ even after installation; the executable bundles JavaScript, WASM, and browser assets, but does not bundle Node or V8. ## Build and install Install stable Rust, Node 26 LTS (22+ works) with npm, and Python 3.11+. Clone this repository or update your existing checkout, then run from its root: ```sh git clone https://github.com/assistant-ui/tress.git cd tress rustup target add wasm32-unknown-unknown tress_bindgen_version=$(python3 -c 'import tomllib; print(next(p["version"] for p in tomllib.load(open("Cargo.lock", "rb"))["package"] if p["name"] == "wasm-bindgen"))') cargo install wasm-bindgen-cli --version "$tress_bindgen_version" --locked npm --prefix packages/workspaces ci npm --prefix packages/workspaces run build npm --prefix site run wasm:node npm --prefix packages/client ci npm --prefix packages/client run build npm --prefix packages/harness-host ci npm --prefix packages/harness-host run build TRESS_EMBED_RUNTIME=1 cargo install --locked --path crates/tress ``` Use the Cargo-installed `tress` (normally `~/.cargo/bin/tress`). If you used the website installer before, place `~/.cargo/bin` before `~/.local/bin` on PATH. Both builds currently report `0.3.0`, so the version alone cannot tell them apart. A plain Cargo installation without the host build above is enough for existing-app attachment, but does not bundle this machine runtime. ## Start your workspace ```sh tress setup --local cd /path/to/your-project tress ``` Setup saves your model credential and selects local mode. Running `tress` starts or rejoins the project host. Ask a question in the terminal, then open the private `Browser:` URL it prints. Both clients show the same thread. The browser can list, preview, and download files from that project. An exported `ANTHROPIC_API_KEY` can supply the model credential instead. For an Anthropic key that requires a workspace, also set `ANTHROPIC_WORKSPACE_ID` on the host before starting it. This is the Anthropic workspace, separate from the Harness workspace used in managed mode. Provider and managed service keys stay on the host. The default local host allows project file reads and edits; native shell execution is disabled. Closing the terminal leaves the host running. ## Return later or stop the host ```sh cd /path/to/your-project tress # reconnect to this project's saved thread tress ask "summarize the changes" tress serve --stop # stop the host; retain conversation and files tress # restart the host and restore completed turns ``` The preview keeps one conversation per canonical project path. Conversation snapshots and private connection metadata live under `~/.local/state/tress/harness/` by default, outside the project; workspace files stay inside the project. `XDG_STATE_HOME` changes the state directory. Moving to another machine does not automatically move either store. ## Choose tool permissions Stop the current host before changing permissions or model settings: ```sh tress serve --stop tress serve --open # read-only project tools ``` To allow edits and native commands instead: ```sh tress serve --stop tress serve --allow-write --allow-exec ``` Native commands run with the host process's permissions. This preview has no per-command approval dialog, and the shell is not sandboxed to the project. An interrupted tool is reported as interrupted; it is not automatically replayed. ## Use a VM or managed conversation storage Run the same setup on your VM with a persistent project disk. The listener is private to `127.0.0.1`; forward the printed port with SSH, preserving the port, then open its private URL. See [deployment options](/docs/production). Optional managed mode uses HarnessCloud for conversation storage and a tunnel to the machine's agent. The machine must remain available to execute tools. It does not upload project files or migrate an existing local conversation. See the [managed host configuration](https://github.com/assistant-ui/tress/blob/main/docs/local-harness.md#managed-harness). Automated tunnel tests pass; live managed deployment validation remains a release requirement. ---