Skip to content

Repository files navigation

invincible

In-browser agent harness — a Zig/dvui Wasm workspace hosted by Next.js, with inference via Vercel AI Gateway.

License:MIT

What it is

Invincible is a browser-based agent workspace. You open /harness, and the canvas is the product: type prompts, run multi-turn chat, smoke the Gateway path, and (when configured) drive a jailed sandbox for agent tools.

The Next.js host is a thin shell — load the Wasm module, bridge messages, and keep server-only secrets off the client. Clone it, point it at your Vercel project and keys, and run the same harness on your work.

Features

FeatureNotes
CoreWasm harness chatTranscript, composer, and turn UX live in the canvas (/harness)
CoreAI Gateway inferencePOST /api/chatAI_GATEWAY_API_KEY stays on the server
RequiredMulti-tenant login + adminAlways on: credentials auth, grants, /login + /admin on every deploy (see docs/bring-your-own.md)
OptionalAgent tools + sandboxPOST /api/agent — DB grants + per-row backend (byo
OptionalBuiltin HTTPS fetchhttp_get via a durable HTTP instance a user creates under Settings → Sandbox when BUILTIN_HTTP_FETCH=sandboxdocs/builtin-http.md
OptionalTenant BYOK inferenceAdmin Inference keys (/admin/inference), harness model cycle (canvas Next), request-scoped Gateway BYOK
OptionalPer-user MCP toolsSettings → MCP servers; tools on agent turns (docs/mcp.md)
OptionalUser GitHub PATSettings → GitHub token; sandbox exec injects GH_TOKEN/GITHUB_TOKEN (docs/sandbox.md)
OptionalPreferred sandbox + instancesSettings → Sandbox (catalog preference + Workspace/HTTP instance lifecycle) (docs/sandbox.md)
OptionalOIDC SSO + SCIMCode on main; enable with env (docs/bring-your-own.md §4b)
OptionalAgent personasPer-user AGENTS.md-style standing orders bound to a session and injected server-side (docs/personas.md)

Try it

Local (best for new visitors)

For a full product path, configure the tenancy triple in .env.local (DATABASE_URL, AUTH_SECRET, CREDENTIALS_ENCRYPTION_KEY) and sign in. See Run locally and docs/bring-your-own.md for the required setup.

  1. Set AI_GATEWAY_API_KEY (see Run locally).
  2. npm run dev → open http://localhost:3000/harness.
  3. Type in the canvas composer → Enter or Send.
  4. Send a short prompt to smoke the host Gateway path (reply appears in the canvas).
  5. Refresh restores session into Wasm (and cloud when signed in); nav Clear resets local + cloud row.

Reference deploy

Maintainer sample (not required for BYO success):

Productionhttps://invincible-dun-ten.vercel.app
Harnesshttps://invincible-dun-ten.vercel.app/harness

That host runs multi-tenant-only. Unauthenticated visits to /harness redirect to /login. Use an account you control on that deploy — this README does not publish seed passwords. A fresh fork or npm run dev without the tenancy triple shows the login wall and fails closed until tenancy is configured (docs/bring-your-own.md).

IDs and pointers: docs/project-ids.md.

Run locally

npm install
cp .env.example .env.local # set AI_GATEWAY_API_KEY# optional: HARNESS_ARTIFACT_TOKEN=… npm run fetch-harness# or: HARNESS_SKIP_FETCH=1 if public/harness is already populated
npm run dev

Everything is multi-tenant-only: configure the tenancy triple (DATABASE_URL, AUTH_SECRET, CREDENTIALS_ENCRYPTION_KEY), migrate + seed, and sign in with a user that has an inference grant and (for tool turns) a sandbox grant — otherwise requests fail closed (401/403) and /harness redirects to /login. Tool paths: docs/sandbox.md · Builtin HTTP.

npm test&& npm run typecheck

Deploy your own

docs/bring-your-own.md — clone → env → your Vercel → secrets → Wasm supply → verify /harness.

TopicDoc
Agent tools workspacedocs/sandbox.md
Multi-tenant setupdocs/bring-your-own.md §4a
Tenant BYOK inferencedocs/bring-your-own.md §4a Inference keys
OIDC + SCIMdocs/bring-your-own.md §4b
Per-user MCPdocs/mcp.md
User GitHub PAT (Settings)docs/sandbox.md (GitHub token section)
Self-hosted Zig runnerdocs/runner.md

Anyone can connect this repo to their Vercel project and keys — no single-host hardcoding required.

Architecture

  • Wasm harness — primary product surface: transcript, composer, busy/error UI.
  • DOM host — Next.js shell: route /harness, load web.js + harness.wasm, bridge poll/submit, thin nav/status chips (not a second chat).
  • Vercel backendPOST /api/chat and POST /api/agent; Gateway key and sandbox tokens never enter the client or Wasm.
  • Session — local-first SessionStore (memory + localStorage) restored into Wasm; optional cloud multi-device sync (id-shaped /api/sessions*, Redis-backed, server-minted ids) when the user is signed in.

Full ownership table: docs/feature-divide.md.

Stack

LayerTech
App (DOM host)Next.js 15 (App Router) + React 19 — shell only
InferenceVercel AI Gateway (ai SDK) · POST /api/chat · POST /api/agent
Agent sandbox (optional)Protocol v1 daemon (sandbox/)
Harness UIZig 0.16 + dvui Wasm (primary product surface)
Auth (optional)Auth.js credentials + optional OIDC; SCIM Users API
PaletteAsteronica TEAL / WARM / EMBER
Sessionlib/sessionStore.ts + lib/sessionRepository.ts (cloud hybrid)
BridgeProtocol v9 (lib/harnessBridge.ts)
TestsVitest

Docs

Living guides only (process / phase history lives in closed GitHub issues).

DocAudience
bring-your-own.mdOperator — your Vercel + keys + Wasm paths
sandbox.mdOperator — agent tools workspace
dev/README.mdDogfood sandbox image (dev/Dockerfile + GHA→VCR)
builtin-http.mdOperator — builtin HTTPS fetch (http_get)
mcp.mdOperator — per-user MCP servers + Exa smoke
feature-divide.mdProduct — DOM shell vs Wasm harness
agent-stream.mdProduct — agent SSE events, thinking collapse, caps
runner.mdOperator — self-hosted Zig runner + workflows
session-model.mdProduct — session restore behavior
personas.mdProduct — agent personas + how New session binds/injects
harness-limits.mdProduct — browser / mobile / density limits
harness-deploy-race.mdOperator — artifact vs Vercel race
project-ids.mdMaintainer sample IDs / URLs
SECURITY.mdSecrets + self-hosted public policy
AGENTS.mdAgent / contributor operating rules

Secrets

Server-only names — never commit values or put them in client/Wasm.

Set what you need via .env.example locally and your Vercel project env in production. Full cutover tables and order-of-operations: docs/bring-your-own.md. Policy: SECURITY.md.

Minimum to chat: a signed-in user with an inference grant (BYOK), plus the host AI_GATEWAY_API_KEY. Tool turns additionally need a sandbox grant. Optional: harness artifact token, tenancy triple, OIDC/SCIM tokens — see .env.example for names only.

About

In-browser agent harness: Zig/dvui Wasm UI + Next.js host, inference via Vercel AI Gateway

Topics

Resources

Security policy

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages