Local Agent
Example: Embed a Local Agent in a Node Service
A typical embedding pattern for using a local Agent inside a Node service, and when Federation AIService belongs in the picture
Example: Embed a Local Agent in a Node Service
One very common pattern looks like this:
- Your Node service process creates an
Agent. - The service creates or loads a session at startup.
- An HTTP handler receives a request and turns it into
session.prompt().
Minimal embedding mode
import { Agent } from "@downcity/agent";
import { Workspace } from "@downcity/workspace";
const agent = new Agent({ id: "repo-helper", model });
const workspace = new Workspace({
id: "project",
path: process.cwd(),
});
const session = await agent.sessions.create({ workspace });