tdsk-backend

Documents the Express Core API backend architecture, endpoints, and services for Threaded Stack.

Updated Jan 4, 2026
One-click install
npx skills add https://github.com/threadedstack/threadedstack --skill tdsk-backend-threadedstack
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: tdsk-backend
Source: https://github.com/threadedstack/threadedstack/tree/main/.claude/skills/tdsk-backend
Command: npx skills add https://github.com/threadedstack/threadedstack --skill tdsk-backend-threadedstack

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Navigating a large Express backend codebase with dozens of endpoints, middleware layers, and services is slow and error-prone. This Skill provides a structured knowledge base of the Threaded Stack Core API so you can quickly locate routes, understand middleware order, and modify services correctly. ## Core Features & Use Cases - Endpoint Reference: Covers admin CRUD routes, agent run/SSE streaming, OpenAI-compatible chat completions, sandbox lifecycle, shell sessions, and Stripe payment webhooks. - Architecture Guidance: Documents middleware setup order, service layer (SecretResolver, ProxyService, EgressProxy, Scheduler, SandboxService), and WebSocket server dispatch. - Use Case: When adding a new quota-limited POST route, consult the Skill to see how enforceQuota maps routes to quota keys and where auth middleware is applied in accounts.ts. ## Quick Start Ask the AI to explain how the sandbox shell session flow works in the backend, including authentication and reconnection handling.

Frequently Asked Questions about tdsk-backend

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I add a new API endpoint to an Express backend?▼

Define a TEndpointConfig object or TEndpointBuilder function in the endpoints directory and register it in endpoints.ts. The setupEndpoints middleware auto-injects param validation for routes with :id params and applies auth, subscription, and quota middleware to accounts routes.

How does JWT authentication middleware work in Express?▼

The authenticate function in setupAuth.ts validates JWT tokens on all /_/* routes except those in the AuthIgnore list. Auth, subscription creation, and quota enforcement are applied in accounts.ts rather than globally in main.ts.

How do I implement OpenAI-compatible chat completions for a custom agent?▼

Use the POST /_/agents/:id/v1/chat/completions route, which accepts standard OpenAI request bodies and supports both SSE streaming and non-streaming responses. Request and response adapters convert between OpenAI message types and internal thread types.

Does the backend support WebSocket connections for shell sessions?▼

Yes, the WebSocket server uses noServer mode with multi-path dispatch, routing /ai/ws, sandbox tunnel, shell, and monitor upgrades to separate handlers. Shell sessions support PTY allocation, reconnection via ring buffers, and multi-user joining.

Why would secrets leak through an egress proxy and how to prevent it?▼

Placeholder tokens can leak if swapped without domain scoping. The EgressProxy uses fail-closed replacement: a placeholder is only swapped to its real secret when it carries a non-empty allowedDomains scope matching the destination host.

What are the limitations of in-memory session stores?▼

The SessionStore keeps LLM sessions in memory with a 1-hour TTL and 5-minute cleanup interval, so sessions do not survive server restarts. Rate limiters and sandbox session maps are also in-memory and not shared across instances.