← All Labs Lab 21 / 28 Eject a habitat agent as a standalone repo
Lab 21 · Code & ship · Proposed

Eject a habitat agent as a standalone repo

An agent configured in this monorepo ejects into a directory outside it that installs, typechecks and serves its A2A card and a turn on its own, with no imports back into the monorepo.

Proposed Needs: tool-calling Source: examples/21-eject-standalone-agent

Not built yet. PROMPT.md is the prompt to build it from.

A prototype that only runs inside umwelten's workspace isn't shippable. This lab takes one declarative agent config (id, instructions, Owned and Mounted dirs, A2A bearer auth, one ui:// tool), generates a project into a temp directory outside the repo, and checks that project stands on its own.

The checks the build should end with:

CheckWhat it shows
no-monorepo-pathsNo file in the ejected project refers to the monorepo (workspace:, ../../packages, absolute repo paths)
installs-and-typecheckspnpm install and tsc --noEmit succeed in the ejected directory
serves-on-its-ownStarted from the ejected directory with a faux model, it answers /health, refuses /a2a without the token, and completes one A2A task with it

Known going in

  • The packages are private. @umwelten/habitat, @umwelten/pi and @umwelten/protocols are private: true at 0.6.0, so an ejected project can't install them from npm. The build must pick one: pack them as tarballs into the ejected repo, bundle the agent with esbuild, or depend on the published umwelten package if it exports enough. Record the choice in FINDINGS.
  • The ejected project must reach models through Mycel only (D-28); its .env.example lists MYCEL_API_KEY, never a vendor key.

Split out

  • Distilling specs from the prototype session is Lab 24.
  • verify-deploy as a gate is Lab 25.
  • The hot-reload builder UI was a workbench, not a claim; it can come back on top of these.

Prompt

Coding-Agent Prompt · Ready to Paste
Build `examples/21-eject-standalone-agent/`: `eject.ts` turns one declarative agent config into a standalone project directory, and `run.ts --smoke` checks that project runs with no tie to this monorepo.

Read first: `packages/habitat/src/durable/durable-habitat.ts` (`DurableHabitat.open`, `createA2ASurface`), `packages/habitat/Dockerfile`, `examples/23-a2a-view-artifacts/run.ts` (a minimal habitat served over A2A with a bearer token) and `examples/21-eject-standalone-agent/README.md` (known facts: the packages are private). Don't import from another lab.

1. The config (a zod schema): id, instructions, Owned dir, Mounted read-only dir, A2A bearer token env var name, model spec (`mycel:<id>` only, D-28), and one tool that returns withUIResources(summary, view).
2. `eject(config, outDir)` writes package.json, tsconfig.json, src/agent.ts, src/server.ts (/health, A2A card and /a2a behind the bearer token), Dockerfile and .env.example (MYCEL_API_KEY only). Decide how the ejected project gets @umwelten/habitat given the packages are private (pack tarballs, bundle, or the published `umwelten` package) and record why in FINDINGS.md.
3. `run.ts --smoke` ejects into a mkdtemp directory outside the repo, then prints one PASS/FAIL line per check and exits 1 on any failure: no-monorepo-paths (no `workspace:`, `../../packages` or repo-absolute path in any ejected file); installs-and-typechecks (`pnpm install` and `tsc --noEmit` exit 0 there); serves-on-its-own (started from there with a faux model injected by an env flag, `/health` is 200, `/a2a` without the token is 401, one SendMessage with the token completes).
4. Strict TypeScript, no `any`; clean up processes and temp dirs in `finally`. README frontmatter (status built) and FINDINGS.md.
Works in Pi, Claude Code, Codex & Antigravity Offline mock first → --live opt-in