@adelie/server

中文文档
0.6.5发布于 2026/11/07Apache-2.0TypeScriptES Module近 30 天下载 2529

Adelie web server: multi-user authentication and authorization, Session execution with SSE streaming, and usage accounting, built on @adelie/core.

原始使用文档
文档目录4 节
  1. Architecture
  2. Environment
  3. Running
  4. Security notes (known MVP limits)

@adelie/server

The Adelie Web backend — the Web implementation of the SDK's Human boundary. HTTP carries Prompt input, approvals and interrupts; Server-Sent Events stream the OmniMessage output. Adds multi-user auth, Project authorization, Session runtime, scheduling and usage accounting on top of @adelie/core.

Architecture

  • HTTP: Hono + @hono/node-server; the http module (src/http/app.ts) assembles the business surface from every module's HttpModule.routes contributions and binds no port (tests drive it via app.request()); index.ts is the startup entry (dotenv, graceful shutdown).
  • Storage: SQLite via Node's built-in node:sqlite (WAL) holds only indexes and aggregates (users, auth sessions, Project authorization, Agent/Session indexes, usage, UI prefs, error records). Agent State, Traces and Workspaces stay as files under ~/.adelie/data/<project>/agents/<agent>/, fully shared with the SDK and CLI.
  • Runtime: a session manager keeps active Sessions (get-or-resume-or-heal, per-Session mutex, run/compact driving); approvals surface over SSE as approval_request and decisions re-read the stored approval mode each time; interrupts converge pending approvals to deny before aborting; a scheduler fires agent_state/schedule/*.toml tasks while the service runs.
  • SSE: per-channel monotonic event ids with a bounded replay buffer (1000 events / 2MB); reconnects replay from Last-Event-ID or receive resync_required; heartbeat comment every 20s.
  • Usage: token_usage events are persisted row by row; costs are computed at query time from current per-model pricing.
  • Terminals: src/terminal/ runs pty sessions server-side (node-pty) and feeds every byte into a headless xterm, so the daemon — not the browser — owns the screen. Control is JSON over HTTP (/api/terminals: list / create / capture / keys / kill; create accepts cwd, name, cols/rows and a shell override); the byte stream is a binary WebSocket at /api/terminals/:id/stream ([opcode, slot, payload], output coalesced into ~5ms windows with an immediate leading flush). On attach the server renders the current grid back into an ANSI restore stream, so a reload or a second device rebuilds the exact screen — scrollback, colours, cursor and DEC input modes — while the shell keeps running the whole time. The web app surfaces this twice: an in-app dock (Ctrl+, Codex-style) and the standalone/terminal page (?id=attaches an existing terminal — the dock's detach handoff —?cwd=/?name=` parameterize a new one). Sessions run in-process (no forked terminal worker); this module is the only thing touching node-pty, which is where that split would go if load ever demands it.

The full route tables and the SSE protocol are documented in the Server API reference. DTO types are exported for type-only import via @adelie/server/api.

Environment

VariableMeaningDefault
PORT / HOSTListen port / address4000 / 127.0.0.1
ADELIE_HOME (was PENGUIN_HOME)Data root (shared with SDK/CLI)~/.adelie/data
ADELIE_WEB_DB (was PENGUIN_WEB_DB)SQLite file path<root>/web.db
ADELIE_WEB_DIST (was PENGUIN_WEB_DIST)Front-end build dir (static hosting + SPA fallback when present)../web/dist, or the bundled web-dist/ in the npm package
ADELIE_TRUST_PROXYTrust x-forwarded-proto (1 to enable): it opens the hot-update network gate over proxied HTTPS and marks session cookies Secure — only behind a reverse proxy that sets/strips the header itselfunset (untrusted)
ADELIE_CLI_ENTRY (was PENGUIN_CLI_ENTRY)CLI entry script offered to the Agents this server runs: it is written into <root>/bin/penguin and put at the front of every command's PATHpenguin server|web sets it under that name, the desktop shell passes the pre-rename one; otherwise the entry of the checkout this server was started from, when it has one

Every deployment variable above keeps reading the spelling in parentheses: its writer is outside this repository (the desktop shell's launch environment, an existing deployment's unit file, an older launcher script), so both names are accepted while those writers move over — see packages/core/src/state/boundary-env.ts.

.env in the process cwd is loaded automatically.

Running

pnpm --filter @adelie/server dev     # tsx watch (front end via the Vite dev proxy)
pnpm --filter @adelie/server build   # tsup → dist/
pnpm --filter @adelie/server start   # node dist/index.js

pnpm typecheck / test run tsc and vitest (tests use a temp root + in-memory DB; no ports, no live LLM calls).

Security notes (known MVP limits)

  • CSRF: session cookie is SameSite=Lax and writes accept only Content-Type: application/json; no CSRF token yet.
  • Login throttling: per-username exponential backoff after 5 consecutive failures (1s doubling to a 60s cap, 429 too_many_attempts inside the window, reset on success; in-memory, so a restart clears it). Unknown usernames are throttled identically, so it is not an account-existence oracle. A reverse proxy can still add IP-level limits for public deployments.
  • Built-in admin admin is seeded with a random password that is hashed and discarded unseen (ADELIE_SEED_ADMIN_PASSWORD pins it for tests/e2e). Until a password is set, every start prints a first-login link that signs the browser in to choose one; a banner keeps reminding until the initial flag clears.
  • Passwords use node:crypto scrypt (scrypt$N$r$p$salt$hash, timingSafeEqual). A session is a row in auth_sessions (the cookie holds a random token, the row its sha256); it survives a restart, renews the expiry in place, and logout deletes the row. Sessions run 30 days with sliding renewal.
  • Model credentials live in the Project's hidden 0600 config file; the API always masks them.
  • Terminals are a shell as the OS account running the server, i.e. the most privileged thing the API hands out — they are not Project-scoped. A terminal is only visible to the account that created it (someone else's id answers 404, not 403), and the stream WebSocket checks Origin on top of the session cookie because a WebSocket handshake is not subject to CORS. Do not expose a deployment with terminals enabled to accounts you would not give SSH.
  • Behind a reverse proxy, disable response buffering for SSE paths (the server already sends X-Accel-Buffering: no), and set ADELIE_TRUST_PROXY=1 with x-forwarded-proto forwarded so session cookies are marked Secure — the header alone is not trusted, so without the opt-in an HTTPS deployment issues its cookies without the flag.

Part of Adelie · Apache-2.0

版本与发布记录

@adelie/server 共发布 19 个版本,首次发布于 2026/10/17;过去 12 个月发布了 19 个版本。

版本发布日期距今
0.6.5latest2026/11/07今天
0.6.42026/11/052 天前
0.6.32026/11/043 天前
0.6.22026/11/025 天前
0.6.12026/11/016 天前
0.6.02026/10/308 天前

关于 @adelie/server 的常见问题

@adelie/server 是什么?

Adelie web server: multi-user authentication and authorization, Session execution with SSE streaming, and usage accounting, built on @adelie/core.

如何安装 @adelie/server?

在项目目录运行 npm install @adelie/server,或使用 pnpm add / yarn add / bun add。

@adelie/server 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@adelie/server 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@adelie/server 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=24。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@adelie/server 可以商用吗?

@adelie/server 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@adelie/server 的下载量有多少?

根据 npm 官方下载统计,@adelie/server 在 2026/10/05 – 2026/11/03 这 30 天内被下载 2,529 次,日均约 84 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@adelie/server 还在维护吗?

最新版本 0.6.5 发布于 2026/11/07(今天);至今共发布 19 个版本,其中过去 12 个月发布了 19 个;首次发布于 2026/10/17。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。