Skip to main content
Alpha

AI & agents

The AI capability is NetScript's stack for agentic chat and tool-calling: a provider-agnostic engine at the design center, a durable-chat runtime that makes a chat survive reload and reconnect, and an app-owned chat UI you copy into your workspace.

alpha

It is layered so each piece stands alone. Two layers ship and install today — the durable-chat runtime (@netscript/fresh/ai) and the chat UI (@netscript/fresh-ui ai copy registry). The provider-agnostic engine (@netscript/ai) and the AI plugin (@netscript/plugin-ai + @netscript/plugin-ai-core) arrive in the next cut.

The two planes

NetScript models live state in two distinct planes, and the headline rule of this capability is never build chat on the wrong primitive. A StreamDB shape is the right tool for live lists, boards, and tables — CRUD rows reconciled last-writer-wins. A durable chat session is an append-only, replayable chunk log keyed by sessionId, because a tool call is a multi-chunk mid-stream event that cannot collapse into a single row without losing its pending → streaming → complete states. Reach for durable streams for data; reach for durable chat for conversation.

Minimal taste — a durable chat proxy

Every durable chat needs one route that proxies the browser's chat-stream request to the session's durable-stream URL. That route is a single call:

// routes/api/chat/[sessionId].ts
import { createNetScriptChatStreamProxy } from "@netscript/fresh/ai";

const proxy = createNetScriptChatStreamProxy({
  target: (req) => ({
    sessionId: new URL(req.url).pathname.split("/").pop()!,
  }),
});

export const handler = { POST: proxy, GET: proxy };

Authorization lives where you produce the session response (toNetScriptChatResponse with an authorize hook — required in production), and the transcript is rendered by the copy-registry chat UI. The durable chat page walks the full recipe.

The section

Reference

The section pages orient; the generated reference enumerates every symbol. The shipping layers live under @netscript/fresh (the /ai and /ai/sandbox subpaths) and @netscript/fresh-ui (the copy-registry manifest). The engine and the AI plugin have their own generated reference pages:

ai

plugin-ai

plugin-ai-core