/** * FrameSource dispatcher. * * The public API lets customers choose what the agent sees via * `vision: { frameSource: { type: "wireframe" | "fn", ... } }`. This module * hides the strategy behind one entrypoint — `startFrameSource` — which * returns a stop function. The target canvas is passed in so the caller * (vision/index.ts) can hand the same canvas to `canvas.captureStream()`. * * Two built-in sources: * * 1. `{ type: "wireframe", rate, features: { includeImages } }` * — Runs the Wireframe library against `document.body` at `rate` Hz. * This is the default, tuned for low bandwidth + agent-readable * structure. `includeImages: true` fetches cover photos/avatars/ * thumbnails via CORS and draws real pixels; otherwise the agent * gets labelled placeholder boxes. * * 2. `{ type: "fn", rate, captureFn }` * — The user supplies a function that returns a canvas or ImageBitmap * on each tick. Useful for custom sources the DOM walker can't * introspect: `