{
  "schema": "leumas.docs.page/1",
  "id": "pkg:@leumas/flow-recorder",
  "slug": "engines/flow-recorder",
  "kind": "capabilities",
  "bucket": "package",
  "title": "@leumas/flow-recorder",
  "name": "@leumas/flow-recorder",
  "eyebrow": null,
  "chip": null,
  "summary": "Record & replay real runtime hook flows into replayable timelines. Part of the Leviathan runtime; mounted by leumas-api at /api/flows. Captured flows feed perception→rules→action.",
  "keywords": [
    "flow-recorder",
    "replayable",
    "timelines",
    "perception",
    "captured",
    "flow recorder api",
    "leumas flow recorder",
    "flows"
  ],
  "audience": "both",
  "funnel": {
    "product": null,
    "cta": null
  },
  "body": "# @leumas/flow-recorder\n\nRecord real runtime hook flows into **replayable timelines**, and expose them over the API.\nPart of the **Leviathan runtime** — captured flows feed the perception→rules→action loop (P5), so\napps stop being black boxes and become **observable, replayable, trainable organisms**.\n\nWorks with any hook emitter that supports `onAny`/`offAny` or `on('*')`/`off('*')`, plus `emit()`.\n\n## Record & replay\n\n```js\nimport { createFlowRecorder } from '@leumas/flow-recorder';\n\nconst recorder = createFlowRecorder({ hooks }); // hooks = your live-hooks emitter\nrecorder.start();\nhooks.emit('server:start');\nhooks.emit('music:loaded', { track: 'dreamscape.mp3' });\nrecorder.stop();\n\nconst flow = recorder.export();           // { meta:{source,started,ended}, events:[{name,ts,payload}] }\nawait recorder.replay({ hooks, speed: 1 }); // re-emit in order; delay = original delta * speed\n```\n\nPass `filter` as an array of event names or `({ name, payload }) => boolean` to limit capture. `ts` is\nrelative to `started` in ms.\n\n## API (mounted in leumas-api at `/api/flows`)\n\n```js\nimport { createFlowRouter } from '@leumas/flow-recorder';\napp.use('/api/flows', createFlowRouter({ store, gate: requirePassNode(), getHooks }));\n```\n\n- `GET  /api/flows` → list saved flows (summaries)\n- `GET  /api/flows/:id` → one full flow (meta + events)\n- `POST /api/flows` → save a flow `{ meta, events }` *(gate meters writes)*\n- `POST /api/flows/:id/replay` → replay onto a host-provided emitter (`getHooks(id, body)`)\n- `DELETE /api/flows/:id` → delete\n\n`store` defaults to an in-memory store (`createMemoryFlowStore`). Back it with the leumas.db `flows`\ncollection by passing a `{ list, get, save, remove }` adapter.\n",
  "source": {
    "path": "shared/engines/leviathan/flow-recorder/README.md",
    "blobSha": "",
    "commit": "",
    "committedAt": "",
    "provenance": "no-git",
    "bytes": 1938,
    "hash": "7919110768feb13a0f709ea0fa04b4dc7fb48274"
  },
  "urls": {
    "html": "/p/engines/flow-recorder",
    "json": "/docs/engines/flow-recorder.json",
    "md": "/docs/engines/flow-recorder.md"
  },
  "links": {
    "composes": [],
    "usedBy": [],
    "product": [],
    "howTo": [],
    "skills": []
  },
  "exports": null
}
