fastagent-sh/fastagent
소개
Ship durable, production-grade AI agents in TypeScript. Built-in human-in-the-loop approvals, isolated sandboxes, agent skills & MCP, and resumable streams — embed it in your app, self-host over HTTP for any stack, or scale to zero on any cloud.
AI 및 머신러닝측정된 스타 증가
- in 24h
- 0
- in 7 days
- +1
- in 15 days
- +1
- in 1 month
- 기록 수집 중
서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.
README.md
OriginalShip durable, production-grade AI agents in TypeScript.
English · 简体中文
Built-in human-in-the-loop approvals, isolated sandboxes, agent skills & MCP, and resumable streams.
Embed it in your app, self-host over HTTP for any stack, or scale to zero on any cloud.
Quickstart · Coding-Agent Guide · Human-in-the-Loop · Sandboxes · AG-UI / A2A · Embed · Deploy · Docs
Quickstart (5 minutes)
Requires Node ≥ 22.22 (Node 24/26 LTS recommended) or Bun ≥ 1.4.4. Remote UIs and Edge Workers install only npm i @fastagent-sh/client (~57 kB gzipped, zero Node.js dependencies).
npm create fastagent@latest my-agent # or: pnpm create fastagent@latest / bun create fastagent
cd my-agent
npx @fastagent-sh/fastagent login # sign in once (or set an API key in .env / local Ollama)
npm run dev # local Agent API server (:8787) with live reload
Building with Claude Code, Codex, Cursor, or Pi? Copy this prompt so your coding agent builds, tests, and gates the project end-to-end:
Read https://raw.githubusercontent.com/fastagent-sh/fastagent/main/docs/ai-start.md and build a FastAgent in this directory.
Why FastAgent?
FastAgent is server-grade agent infrastructure for shipping real backend and cloud services — not weekend toy loops, laptop CLI coding agents, or desktop chat clients. Turn plain SYSTEM.md, AGENTS.md, AAIF skills/, .mcp.json, and typed TypeScript tools into durable services for any model, any stack, and any cloud:
| Production requirement | How FastAgent solves it |
|---|---|
| Define & scale tools without graph boilerplate | Plain SYSTEM.md, AGENTS.md, AAIF skills/, .mcp.json, and typed defineTool() + QuickJS-WASM codemode to batch dozens of tools in one turn across any LLM |
| Survive timeouts, deploys & duplicate webhooks | Durable sessions (SQLite or PostgreSQL) with single-writer lease fencing, idempotencyKey deduplication, mid-run steer, and rewind forks |
| Gate risky actions without burning idle compute | $0-idle human-in-the-loop approvals (requiresApproval), structured mid-run api.requestInput(), and wake-time RBAC verifyApproval |
Run code, bash & file tools safely |
Unified SandboxProvider across local OS sandboxes (Seatbelt / Bubblewrap / Landlock) and 5 cloud MicroVMs (E2B, Vercel, Modal, OpenSandbox, Cloudflare) + needs() secret isolation |
| Connect any frontend or polyglot backend | Open HTTP/SSE Agent API with gapless ?after= stream replay, plus zero-dep useChat(), AG-UI 1.0 (with HITL resume), and A2A 1.0 |
| Deploy anywhere without vendor lock-in | Embed in-process (openAgent()), self-host privately (Docker / on-prem), or scale to zero on any cloud (Fly.io, Railway, Cloud Run, AWS Bedrock AgentCore) with zero-content OpenTelemetry |
By the numbers (verified in CI)
- ~57 kB gzipped edge client:
@fastagent-sh/clientdepends solely oneffectwith zero Node.js or cloud SDKs. - ~0.5 MB RSS per additional tenant: ~290 ms cold
openAgent()open in hermetic benchmarks (npm run bench -- --budget), coalescing up to 500 active tenant leases per PostgreSQL heartbeat query. - Mechanically enforced security: 7 targeted mutation checks (
npm run test:mutations) continuously falsify lease fencing,.env*sandbox exclusion, child-env isolation, wake-timeverifyApproval, andcodemodeHITL/allowlist guards. - 100% dual-harness parity: Both default
pi-durableand optional@fastagent-sh/harness-dshpass the same conformance suite (test/harnesses/agent-api-conformance.ts).
Author in Markdown & TypeScript — ship as a SemVer npm package
my-agent/
├── fastagent.config.ts # model, sandbox, codemode, custom providers, MCP servers
├── SYSTEM.md # system prompt (hot-reloaded on every turn)
├── AGENTS.md # standing operating rules
├── skills/ # AAIF Agent Skills (skills/<name>/SKILL.md)
└── src/tools/ # typed tools (defineTool, requiresApproval, api.requestInput, needs())
// src/tools/issue-refund.ts
import { defineTool, needs } from "@fastagent-sh/fastagent";
export default needs(["STRIPE_SECRET_KEY"], ({ STRIPE_SECRET_KEY }) =>
defineTool({
name: "issue_refund",
description: "Refund a customer charge in cents.",
parameters: {
type: "object",
properties: { chargeId: { type: "string" }, amountCents: { type: "integer", minimum: 1 } },
required: ["chargeId", "amountCents"],
additionalProperties: false,
} as const,
requiresApproval: ({ chargeId, amountCents }) =>
amountCents > 2_500
? {
summary: `Approve $${(amountCents / 100).toFixed(2)} refund on ${chargeId}`,
includeArgs: true,
policy: { ruleId: "high-refund", ruleVersion: "v1", requiredRole: "billing-lead" },
}
: false,
async execute({ chargeId, amountCents }) {
return `Refunded ${amountCents}c on ${chargeId} (key loaded: ${STRIPE_SECRET_KEY.length > 0})`;
},
}),
);
Compile into an immutable SemVer ESM package (dist/) with deterministic CI gates:
npm exec -- fastagent info --json
npm exec -- fastagent build --json # runs tsc, emits dist/ with SHA-256 build.json & peerDependencies
npm exec -- fastagent deploy check --json # blocks builds if .env*, .fastagent/, or .state/ could leak
Two ways teams adopt FastAgent
1. Embed in your Node/Bun & PostgreSQL backend (openAgent)
Keep your existing authentication, tenancy, and pg pool—coalescing up to 500 tenant leases per query with live secret rotation and Workspace context layers:
import { baseEnv, openAgent, openPostgresDatabase } from "@fastagent-sh/fastagent";
import billingAgent from "@acme/billing-agent"; // built via `fastagent build`
const db = openPostgresDatabase({ url: process.env.DATABASE_URL! }, { max: 20 });
const agent = await openAgent(billingAgent, {
name: "tenant-acme", // rootless PostgreSQL when codingTools: false or remote cloud sandbox
database: db,
secrets: { ANTHROPIC_API_KEY: process.env.ANTHROPIC_API_KEY!, STRIPE_SECRET_KEY: vault.read("stripe") },
env: baseEnv(process.env),
codemode: true, // batch & filter read-only tools in QuickJS-WASM
layers: [{ id: "workspace:acme-vip", instructions: "VIP SLA: escalate refunds > $500." }],
verifyApproval: ({ responder, policy }) =>
responder === "user:billing-lead" || !policy?.requiredRole
? { ok: true }
: { ok: false, reason: "Requires billing-lead role", mode: "reject" },
});
2. Run as stateless PG containers, scale-to-zero services, or isolated MicroVMs
# Stateless Kubernetes / Cloud Run / ECS container (FASTAGENT_DATABASE_URL, zero /data volume!)
fastagent deploy init docker && fastagent deploy check
# Scale-to-zero Fly.io / Railway container woken on demand via POST /v1/invoke
fastagent deploy init fly
# Local OS kernel sandbox (Seatbelt / bwrap / Landlock) or Cloud MicroVMs (e2b, vercel, modal, opensandbox, cloudflare)
fastagent dev --sandbox read-only
fastagent dev --sandbox e2b
Need regulated AWS isolation (HIPAA / SOC 2 / FedRAMP)? Serve the exact same dist/ package inside per-session Amazon Bedrock AgentCore MicroVMs via @fastagent-sh/fastagent/agentcore and call over IAM SigV4 with @fastagent-sh/client/agentcore (Deploy — Track 3).
Connect any UI, Edge BFF, or multi-agent inbox (@fastagent-sh/client)
import { connectAgent } from "@fastagent-sh/client";
import { uiMessageStreamHandler } from "@fastagent-sh/client/ui-stream"; // @ai-sdk/react useChat()
import { agUiHandler } from "@fastagent-sh/client/ag-ui"; // AG-UI 1.0 (CopilotKit & approval inboxes, with HITL resume!)
import { a2aHandler } from "@fastagent-sh/client/a2a"; // AAIF A2A 1.0 JSON-RPC + Agent Card
const agent = connectAgent(process.env.AGENT_URL!, { apiKey: process.env.AGENT_API_KEY! });
// Expose directly from a Next.js / Hono / Cloudflare Worker route (or pass `--protocols all` on standalone servers)
export const POST = agUiHandler(agent);
Architecture at a glance
Every caller speaks one contract—the Agent API—while the shared serving layer enforces HITL governance, codemode, layers, OTLP zero-content tracing, and SandboxProvider confinement identically across both harnesses:
Callers (@fastagent-sh/client · openAgent · CLI · ui-stream · AG-UI 1.0 · A2A 1.0 · AgentCore SigV4)
│ Agent API (/v1)
┌──────────────────────────────────────────▼──────────────────────────────────────────┐
│ Shared Serving Layer (@fastagent-sh/fastagent) │
│ Build & Layers · needs() & Live updateSecrets() · HITL (verifyApproval) · codemode │
│ Orthogonal SandboxProvider (off | OS Seatbelt/bwrap/Landlock | 5 Cloud MicroVMs) │
└─────────────────────┬─────────────────────────────────────────┬─────────────────────┘
│ (lazy) │ (optional, lazy)
┌───────────▼───────────┐ ┌───────────▼───────────┐
│ pi-durable (default) │ │ @fastagent-sh/ │
│ SQLite / PostgreSQL │ │ harness-dsh │
│ (fenced leases) │ │ SQLite / PostgreSQL │
└───────────────────────┘ └───────────────────────┘
How FastAgent compares
FastAgent complements UI libraries like @ai-sdk/react and focuses strictly on the durable server runtime layer (full comparison):
| If you are evaluating… | Where FastAgent fits |
|---|---|
Vercel AI SDK (ai / useChat) |
Works together. Use @ai-sdk/react useChat() on the frontend and @fastagent-sh/client/ui-stream on your BFF route to get durable Postgres sessions, crash recovery, $0-idle HITL approvals, and sandboxes without building a custom persistence layer. |
| Workflow graphs (LangGraph, etc.) | Zero graph DSL. Author plain Markdown (SYSTEM.md, skills/) + typed defineTool() modules instead of wiring state-graph nodes and checkpointers by hand. |
| Closed vendor agent clouds | Open & portable. Same artifact embeds in-process, runs on your own Docker/K8s/Fly.io/Railway, or deploys to AWS Bedrock AgentCore across any LLM provider or self-hosted vLLM/Ollama. |
| Local CLI coding agents | Server-grade multi-caller runtime. Built for HTTP/SSE APIs, multi-tenant Postgres pools, webhook idempotency, and CI gates rather than interactive laptop terminals. |
Production examples
Clone a complete working agent from examples/:
| Example | Topology | Highlights |
|---|---|---|
| Multi-Tenant SaaS Copilot | Embedded (Hono + PostgreSQL) | Shared openPostgresDatabase(), verifyApproval, useChat() (ui-stream) & AG-UI 1.0, resumable SSE |
| Sleep-When-Idle AI SRE | Fly.io + Alert Webhooks | codemode diagnostic fan-out, $0-idle requiresApproval rollback gate, mid-run steer |
| Sandboxed PR Review Agent | Self-hosted + GitHub Actions | read-only OS sandbox, per-PR conversation, idempotent webhook retries |
| Deep Research & Daily Brief | Self-hosted + External Cron | codemode multi-source fan-out & filtering, /daily-brief prompt template, durable crash recovery |
Packages & documentation
| Package | Role | Runtime baseline |
|---|---|---|
create-fastagent |
One-command project scaffolder (npm create fastagent@latest) |
Node ≥ 22.22 or Bun ≥ 1.4.4 |
@fastagent-sh/fastagent |
Runtime, openAgent, defineTool, defineOpenAICompatibleProvider, openPostgresDatabase, CLI, ./harness, ./agentcore, and ./sandboxes/{e2b,vercel,modal,opensandbox,cloudflare} |
Node ≥ 22.22 (24/26 LTS recommended) or Bun ≥ 1.4.4 |
@fastagent-sh/client |
Zero-Node-dep Agent API client (connectAgent, ./auth, ./agentcore) & stateless protocol projections (./ui-stream, ./ag-ui, ./a2a) |
Node 22+, Browsers, Edge, Deno, Bun (ES2024) |
@fastagent-sh/harness-dsh |
Optional DeepSeek Harness (@deepseek-ai/dsh) server adapter with 100% Agent API, HITL, codemode, and SandboxProvider parity |
Node ≥ 22.22 (24/26 LTS recommended) or Bun ≥ 1.4.4 |
Documentation (docs/):
Overview · Quickstart · Coding-Agent Guide · Human-in-the-Loop · Sandboxes · Configuration · MCP · Packaging & CI · Embedding · Protocols (useChat / AG-UI / A2A) · Deploy · Remotes · Architecture · Agent API · CLI · API Reference · Troubleshooting
Contributing & license
Contributions welcome—see CONTRIBUTING.md and SECURITY.md. Licensed under MIT.
관련 프로젝트 살펴보기
불러오는 중…
