{
  "schema": "leumas.docs.page/1",
  "id": "how-to:dreamer",
  "slug": "how-to/dreamer",
  "kind": "pages",
  "bucket": "how-to",
  "title": "Dreamer (@leumas/dreamer)",
  "name": "Dreamer",
  "eyebrow": null,
  "chip": "@leumas/dreamer",
  "summary": "The ecosystem's multi-stage ideation pipeline: a data-defined chain of LLM stages — the default is idea → expansion → feasibility → selection → scaffold → notes — where each stage can read earlier...",
  "keywords": [
    "dreamer",
    "feasibility",
    "critically",
    "data-defined",
    "hardwired",
    "leumas dreamer",
    "how to dreamer",
    "multi-stage"
  ],
  "audience": "both",
  "funnel": {
    "product": null,
    "cta": null
  },
  "body": "# Dreamer (@leumas/dreamer)\n\nThe ecosystem's **multi-stage ideation pipeline**: a data-defined chain of LLM stages — the default\nis `idea → expansion → feasibility → selection → scaffold → notes` — where each stage can read\nearlier stages' outputs and, critically, **run on any configured model** (ported from the legacy\n`Dreamer` tool, which was hardwired to a single local Ollama model in five places).\n\n## How agents call it\n\n| Surface | How |\n|---|---|\n| Chatbot / Leviathan | attach the `dream` functioncall (stored doc, executor `action:dream`) |\n| Automation rule | action `dream` (e.g. cron trigger → \"ideate on X weekly\") |\n| MCP client | `functioncalls` server → `dream` tool |\n| 3D-programming grid | an `action:dream` cell, chainable with other cells |\n| HTTP | `POST /api/dreamer/run` (JSON) or `POST /api/dreamer/run/stream` (SSE) |\n| Studio | Intelligence → Dreamer |\n| Code | `runDreamer({ topic, depth, mode, definition, provider, model, stageModels, onEvent, signal, providerRegistry, connector })` from `@leumas/dreamer` |\n\nArgs: `topic` (required) · `depth` `standard`|`deep` (default standard) · `mode` `standard`|`wild`\n(wild favors unconventional-but-plausible ideas) · `provider`/`model` (any @leumas/providers brain,\ndefault `auto`) · `pipeline` (a custom definition; defaults to the 6-stage pipeline) · `stageModels`\n(per-stage model overrides) · `inputValues` (values for a pipeline's declared `{{input.*}}` tokens).\n\n## Any model — and mixable per stage (the whole point)\n\nThis is the headline capability. `provider`/`model` set the run default, but **`stageModels` overrides\nthe model per stage by key**, so a single run can brainstorm cheaply and decide expensively:\n\n```jsonc\nPOST /api/dreamer/run\n{\n  \"topic\": \"carbon-negative concrete\",\n  \"depth\": \"deep\",\n  \"provider\": \"auto\",\n  \"stageModels\": { \"idea\": \"llama3.1\", \"selection\": \"claude-opus-4-8\" }\n}\n```\n\nResolution per stage: `stageModels[key] → stage.provider/stage.model → the run's provider/model →\n'auto'`. `'auto'` always resolves to whatever provider is available, so a call with no model set\nstill runs. Never call a raw provider — always go through the injected registry.\n\n## The pipeline is DATA (add a stage with no code change)\n\nA pipeline is portable JSON: `{ name, version, stages: [{ key, label, task, outputFormat,\npriorOutputs }] }`. Studio can edit it, an action/HTTP caller can pass one in, and a tenant can store\ntheir own. Validate any custom definition first — `GET /api/dreamer/pipeline` returns the default;\n`POST /api/dreamer/pipeline/validate` returns `{ ok, errors }`. The one validator rejects duplicate\nkeys, self-references, unknown `priorOutputs`, and **forward references** (a stage consuming a later\nstage's output).\n\n## SSE vocabulary\n\n`start · stage_start · stage_done · done · error` (+ `: ping` heartbeat every 15s; client disconnect\naborts the run; read POST-SSE with the shared `admin/_shared/sse.js` `streamPostSse` — EventSource is\nGET-only). Every stage checkpoints to `/db/dreamer_runs`, so a dropped stream loses nothing and a\npartial/failed run is still readable (the legacy tool left orphan folders with no status).\n\n## Persistence\n\n`dreamer_runs` dynamic collection (auto-written when a connector is injected): the doc is created\n`running` up-front and updated after each stage with `steps`, `outputs`, `usage`, then finalized\n`done`/`aborted`/`error`. No separate list route — query `/db/dreamer_runs`.\n\n## Gating\n\n`requireAuth` + `requireMembership('intelligence')` (admins bypass) + PassNode guard\n`feature:dreamer.run` — author a `passnode_rules` doc with that resource id to meter/charge runs; no\nrule = free pass. LLM calls cost real tokens, so meter before white-labeling.\n",
  "source": {
    "path": "shared/services/knowledge/build-knowledge/dreamer.md",
    "blobSha": "",
    "commit": "",
    "committedAt": "",
    "provenance": "no-git",
    "bytes": 3924,
    "hash": "4249baba39bf06782f9d1ff0c7b462b859d0201e"
  },
  "urls": {
    "html": "/p/how-to/dreamer",
    "json": "/docs/how-to/dreamer.json",
    "md": "/docs/how-to/dreamer.md"
  },
  "links": {
    "composes": [],
    "usedBy": [],
    "product": [],
    "howTo": [],
    "skills": []
  }
}
