Cloudflare Workers에서 실행되는 터미널 스타일 AI 코딩 에이전트

hackernews | | 📦 오픈소스
#ai 코딩 에이전트 #cloudflare workers #sqlite #웹 에이전트 #터미널 ui
원문 출처: hackernews · Genesis Park에서 요약 및 분석

요약

Cloudflare Workers 환경에서 작동하는 이 실험적 터미널형 AI 코딩 에이전트는 SQLite 기반 Durable Object를 통해 파일 시스템과 세션을 유지하며, 브라우저 기반 UI를 제공합니다. 에이전트는 격리된 샌드박스 내에서 자바스크립트를 실행하고, 사용자가 작성한 파일을 실제 워커 엔드포인트로 게시하거나 크론 작업으로 예약할 수 있는 기능을 지원합니다. 배포 시에는 Cloudflare AI Gateway 토큰 설정 등 사후 구성이 필요하지만, 세션 간 데이터가 지속되는 실제 구동 가능한 환경을 특징으로 합니다.

본문

A terminal-style AI coding agent running fully on Cloudflare Workers. It combines: - a browser terminal UI ( ghostty-web ) - a SQLite-backed Durable Object for persistent sessions and files - pi's worker-friendly coding-agent runtime - Dynamic Worker Loader sandboxes for code execution - session-scoped published Workers - Durable Object alarm-powered cron jobs Live deployment in this repo currently targets: Note: this example requires a CF_GATEWAY_TOKEN secret, so you may still need to finish a small amount of post-deploy setup in Cloudflare/Wrangler. Inside a session, the agent can: - read, write, edit, and list files in a persistent filesystem - execute JavaScript in an isolated worker sandbox - import local files and many packages through esm.sh - publish a file as a Worker endpoint at /w// - create recurring cron jobs that send prompts back into the session examples/terminal-agent/ ├── src/ │ ├── index.ts # main Worker + Durable Object + loopback outbound entrypoint │ ├── tui-session.ts # pi agent session wiring │ ├── frontend.ts # browser terminal UI │ ├── sqlite-tools.ts # SQLite-backed file tools │ ├── published-workers.ts # publish file-backed Workers │ ├── cron-tools.ts # cron job tools + schedule parsing │ └── pi-fork/ # worker-specific terminal/runtime shims ├── wrangler.jsonc ├── vitest.config.ts └── wrangler.test.jsonc Routes: / → creates a new session and redirects to/s/ /s/ → serves the terminal web UI/ws/ → websocket for terminal I/O/w// → published session Worker endpoint Each session lives in a SQLite-backed Durable Object. It stores: - message history - pi session state - persistent files - published Worker metadata - cron job metadata The execute tool uses Cloudflare's Dynamic Worker Loader to run user code in isolated workers. Supports: - local relative imports from the session filesystem - package imports resolved through esm.sh - outbound fetch() through a loopback outbound entrypoint in the same Worker The agent can expose a file as a real HTTP Worker endpoint. Example route: /w// Published Workers are cached by dependency version, so they are not rebuilt on every request. Cron jobs are stored in the Durable Object and scheduled with alarms. Each run: - sends the stored prompt back into the same session - computes the next matching run time - re-arms the next earliest alarm Current minimum interval: - every 10 minutes From the repo root: npm install Create: examples/terminal-agent/.dev.vars With at least: CF_GATEWAY_TOKEN=your_cloudflare_ai_gateway_token From examples/terminal-agent : npm run dev The predev script builds the local worker packages first. From examples/terminal-agent : npm run deploy Main config file: examples/terminal-agent/wrangler.jsonc Important values: CF_ACCOUNT_ID CF_GATEWAY_NAME AI_GATEWAY_MODEL - custom domain / routes - Durable Object migrations - worker loader binding From examples/terminal-agent : npm test There is worker-pool coverage for published Workers and dynamic loader behavior. Note: depending on local environment, the Cloudflare Vitest worker pool may emit an upstream node:os warning even when assertions pass. Ask the agent to run a file like: examples/import-test.js Create a file that exports either: export default async function(request, env, ctx) { return new Response("hello"); } or: export default { async fetch(request, env, ctx) { return new Response("hello"); }, }; Then publish it with the worker publishing tool. Example schedule: */10 * * * * This runs every 10 minutes in UTC. - Sessions are persistent across reconnects. - Published Workers are session-scoped. - Cron jobs are session-scoped. bash is intentionally not exposed in this environment.- The frontend branding and Open Graph metadata live in src/frontend.ts . This example is actively experimental, but it is real and deployable.

Genesis Park 편집팀이 AI를 활용하여 작성한 분석입니다. 원문은 출처 링크를 통해 확인할 수 있습니다.

공유

관련 저널 읽기

전체 보기 →