Repository navigation
LBA REQ 106
Planned
Capture / agentic infrastructure (ADR-0095)
The system shall run one local-model loop without an editor: record a desktop or test-source capture in the extension's format with CPU/RAM and GPU samples, send a prompt to a local Ollama model through the MCP bridge, mark prompt sent, first token, response done and the GPU edges, export a clip around them, and print one metadata-only receipt.
The correlated capture of LBA-REQ-105 needs VS Code to start and stop. A local model on the machine that holds the screen (first a Windows 11 laptop with an NVIDIA GPU) is measured end to end only when one command starts the capture, prompts the model, cues the GPU rise and clips it (#134 slice 4).
-
node out/mcp/localModelLoop.jsneeds no VS Code. It writesrun-<uuid>/under--captures-dir(default: the extension's globalStoragecapturesfolder for the platform) with the extension'scapture-meta.json,active-capture-session.json,capture-status.json, frame PNGs,resources.jsonl,gpu.json/gpu.jsonlandcapture.json(frames[] index/tMs/image, samples, markers[] with imageGrab). - Frames come from the extension's ffmpeg arguments (gdigrab on Windows, x11grab on Xorg) or from
--source test(lavfi testsrc in real time) at--fps(default 4); the CPU/RAM and GPU samplers run alongside. - After
--lead-ms(default 2000) the prompt (and an optional--imagePNG) goes to--modelat--ollamathrough the MCP bridge with a streamed/api/chat; tools are offered only from the bridge's default allow-list plus--allow-tool, and only when the model reports thetoolscapability. "prompt sent", "first token" and "response done" are agent cues on the shared nearest-frame grab. - After
--tail-ms(default 3000) everything stops, the automatic GPU cues are added, all markers are in time order, and the clip covers the earliest of prompt sent and the first GPU cue minus 1 s to response done plus 1 s insideclips/. - One JSON receipt goes to stdout and next to the clip: capture id, model name, digest and capabilities, per-cue instantMs, offset from prompt sent and imageGrab, GPU edges, first-token latency, clip SHA-256, size and duration, frame count, and GPU availability or the reason. It holds no pixels and at most 200 characters of the answer.
- Unreachable Ollama, a missing model, missing ffmpeg or a refused desktop are reported before a capture starts (exit 3); a capture without frames is marked failed (exit 4); a failed chat (exit 5) or clip (exit 6) still writes the receipt; missing nvidia-smi marks the GPU unavailable and the loop completes.
- Reference mode (#139 slice 2):
--reference openwebui --endpoint <https url> --token-file <path> --reference-model <id>first streams the same prompt through the Open WebUI chat-completions API (OpenAI-compatible SSE), with the cues "reference sent", "reference first token" and "reference done" on the same axis while the GPU sampler runs as the idle control, then runs the local phase. Both sides use temperature 0,--seed(default 42) and--max-tokens(default 256). The receipt adds onecomparisonblock: first-token latency, total time, output count (tokens, or labelled chunks) and tokens/s per side, the GPU utilization and VRAM during the reference window, the local VRAM peak and the GPU edges. The token is read once from an owner-only, non-empty file and sent only as theAuthorization: Bearerheader. It never appears in argv, output, logs, the receipt orcapture.json. The endpoint must be https (plain http only for 127.0.0.1 or localhost). Exit 7 is a failed reference run and 8 a reference timeout. Without these flags the loop is unchanged. - Like-for-like reference (#143): the reference preflight records
alias(the/api/modelsentry has a non-emptyinfo.base_model_id),baseModelId,hasToolsandhasDefaultFeatures(booleans only, never tool or feature names) in the receipt andcomparison.referenceModel; an alias prints one stderr warning naming the base id and--reference-model <base>, without changing the exit code.--no-toolssends the local model notoolskey and recordstoolsOffered: []; with--allow-toolit is a usage error (exit 2); without it the Ollama request is byte-for-byte unchanged. Both sides ofcomparisonholdpromptTokens(referenceusage.promptTokens; localprompt_eval_countof the final turn),firstTokenMs(first token of any kind, thinking or reasoning included),firstAnswerMs(first content or tool-call token) and tokens/s over first token to done; the local side holdsthinkingChars, the reference sidereasoningChars. The cue "first token" means the first token of any kind; "answer started" and "reference answer started" mark the first answer token.
node test/local-model-loop.mjs and node test/local-model-loop-reference.mjs (T-106,
including a sentinel token grepped in every output and artifact of a full loop against a fake SSE server); a real loop with a local Ollama, nvidia-smi and
ffmpeg on a LINUX workstation is recorded on the pull request. The Windows laptop run is to be proven.
src/mcp/localModelLoop.ts; src/mcp/ollamaMcpBridge.ts; src/capturePlatform.ts; src/captureAssemble.ts; src/captureHost.ts; src/extension.ts; package.json; test/local-model-loop.mjs; src/mcp/openWebUiReference.ts; test/local-model-loop-reference.mjs; test/extension-activation.mjs; test/ollama-mcp-bridge.mjs; docs/information-for-users/command-reference.md; docs/architecture/adr/ADR-0095-correlated-capture-local-clips.md
Planned