- Inicio
- Plugins
- Visión, voz y multimodal
- dsh-streamvision
dsh-streamvision
shet114513/dsh-streamvision
Samples the screen, converts frames to SVG and writes readable change events, plus a band-split OCR text stream.
Instalar
dsh plugin --profile web add github:shet114513/dsh-streamvisionREADME
dsh-streamvision
Continuous screen vision for an agent that otherwise only sees single screenshots.
The main path never puts pixels into the conversation:
sample → SVG conversion → event writing → injected information
Every sample writes two timestamped files at once — the raw frame (data/samples/s_<ts>.png) and its
vector conversion (data/vectors/s_<ts>.svg + .json) — then differences it against the previous frame
on a coarse block grid and turns the change into events an agent can read: how strong, where, what the
screen looks like now, whether it looks crowded, and what the previous event was. Text has its own parallel
channel (band-split OCR, no subtitle-band selection).
Small and dependency-light: Win32 GDI through koffi, a hand-written PNG encoder, and the OCR engine shipped with Windows. No Python, no model weights, no network.
What's new in 0.2.9
sv_framewas silently shooting at 1/4 size (blocking, #3) —capture()only honouredmaxHeightwhen it was smaller than the frame; otherwise it fell into aw / 4fallback, somaxHeight: 1440on a 2560×1440 screen returned 640×360 (and a 1554×1205 window returned 389×302). Sizing now is:outW→outH/maxHeight→ native, always clamped to the source, never upscaled. Small regions are no longer downscaled to a quarter either.sv_framereturns the realsize, and it now matchessv_watchfor the same screen.sv_textnever admitted a line on a live screen (blocking, #3) — stability used to be judged on the whole band concatenation: one changed character anywhere (blinking caret, clock, one scrolling log line, a streaming reply) replaced the pending entry and reset the 1.2 s timer, sowrittenstayed at 0 forever. Admission is now per line: each line is matched against the previous scan independently, so one moving line no longer blocks the rest of its band. Lines that disappear are kept for a short TTL (so a missed OCR beat doesn't restart the clock), the same line recognised in two overlapping bands is written once, and duplicates only bumplastSeen/hitsas before.sv_text({action:'scan', force:true})— skip the stability gate and flush every recognised line immediately: one-shot snapshots and "is the text path alive at all" debugging.scannow also reportssize, per-bandlines,scannedChars/scannedLinesandforced, so a zero result is distinguishable from a zero scan.- Fresh install could not write at all —
scanText/scanFullwrote their temp PNG before the data directory was ever created, so a fresh install (nodata/) failed withENOENTon the very first scan. The directory is now created before any write. SV_DATA_DIR— all data (samples/,vectors/,text.jsonl,events.jsonl,ocr.json,frames/) can live outside the package, e.g. in a host state directory, so upgrades and reinstalls don't wipe it. Default unchanged (<package>/data).
What's new in 0.2.8
- Non-ASCII install paths fixed (blocking) —
lib/pipeline.jscomputedROOTfromnew URL(import.meta.url).pathname, which keeps percent-encoding: with a Chinese (or any non-ASCII) Windows user name,data/samplescould not be created andsv_armreportedarmed: truewhileevents.jsonlnever appeared. It now usesfileURLToPath, like the other three modules. - Failures are no longer silent — sampling and event-append exceptions are recorded in
ARMED.lastErrorand exposed bysv_info/sv_arm({action:'status'}); 10 consecutive failures stop the watcher withstopReason: "error".sv_eventsnow tells the three empty cases apart: not armed / armed but nothing changed / last arm failed. - Local-change detector — besides the whole-frame HSV score (diluted on chat/document screens) and
the busiest 8×6 block, an area criterion counts the share of pixels that changed noticeably.
Default
areaCut: 0.004(0.4%): a one-line document edit is ~0.4%–1%, a static screen is <0.1%, a full-screen animation is tens of percent. Events now carrylocalandarea.
What's new in 0.2.7
- Event stream — each event now carries
edgeDensity(share of blocks with a strong neighbour contrast: <10 empty, 10–25 normal, >25 busy) next tostrength,where,sceneandsample. 32×18 grid,svgcapped at 2400 chars with the sample path kept for the full text. - Reading is lossless —
sv_eventsreturns the oldest unread events, reportspending/truncatedand the nextid; a high-water mark indata/events.seqsurvives daemon restarts, so a stalesinceIdis clamped and flagged (staleSince) instead of silently skipping events. - Text stream — three overlapping bands (0–38% / 32–72% / 66–100%), 2× / 2× / 3×, three parallel OCR passes (1.2 s for a full pass). A line only enters the stream after being recognised twice ≥1.2 s apart with bigram similarity ≥0.85; the earlier version is kept. Unstable text never pollutes the stream.
- Pluggable OCR —
lib/ocr.jsresolves an engine in this order:data/ocr.json({cmd,args,timeoutMs}, placeholders{file}/{scale}/{top}/{bottom}) →SV_OCR_CMDenv →registerOcrHook()→ Windows OCR fallback. Anything that prints{"text": ...}or plain text works. - Bounded disk — the sample pool keeps the last 3 minutes by age (
SV_KEEP_MS, default 180000, hard cap 3000), pruning the png/svg/json of a timestamp as one unit.
What it does
- Continuous capture — BitBlt + nearest-neighbour downscale, ~45–65 ms per 720p frame.
- Block differencing — 32×18 blocks, mean absolute difference; reports which blocks moved and how much.
- Gated events — a still screen produces no events at all.
- Scene segmentation / peaks — activity runs split into scenes;
peakskeeps the N most-changed moments. - Working memory — three capacity-limited layers (
sink/ring/text).
Motion events land in data/events.jsonl, recognised text in data/text.jsonl; the two loops are
independent, so captioning never blocks the motion channel.
Tools
| tool | purpose |
|---|---|
sv_watch | sample for N seconds, return a change timeline (optionally dump frames) |
sv_frame | export a raw frame (the SVG conversion loses detail) |
sv_scenes | sample for N seconds, cut activity into scenes or peaks, update working memory |
sv_memory | read / append / clear the working-memory layers |
sv_events | read the motion event queue; wait long-polls and returns the moment a new event lands |
sv_text | text stream: scan runs one band-split OCR pass (force:true skips the 2-scan gate); a line enters only after being seen twice; read long-polls |
sv_arm | arm an in-process watcher that appends events to data/events.jsonl |
sv_blocks | read the newest SVG conversion (or sample one more with mode:"live") |
sv_info | screen size, armed state, frame-file accounting |
Watching without being woken up
sv_arm does not push messages into the conversation. It samples at fps and appends one compact
event per meaningful change; you read the stream with a long-poll:
sv_arm({ action: 'on', window: 'Game', fps: 2, cutAbs: 12, cooldownMs: 3000, idleExit: 900 })
sv_events({ wait: 60, sinceId: lastId }) // returns as soon as something lands
// → handle it, then loop again; sv_arm({ action: 'off' }) when done
Long-poll instead of injecting a message per event: an injected message starts a new turn, and a new turn means re-reading the context — slower and far more expensive than staying in the same turn.
Detector sensitivity
Three criteria are OR-ed; an event fires if any of them passes:
| parameter | default | catches |
|---|---|---|
cutAbs | 12 | whole-frame change — scene cuts, scrolling, video motion |
localCut | 12 | one 8×6 block changing a lot (a small dialog, a HUD element) |
areaCut | 0.004 | share of pixels changed noticeably — a one-line edit in a document or chat |
Tuning: static screens that never fire → lower areaCut to 0.002. Too many events on a busy screen →
raise areaCut toward 0.02.
Noisy video that fires constantly → areaCut: 0.03, cutAbs: 20, and a longer cooldownMs. If you want
the old block-mean behaviour instead, pass score: 'blocks', threshold: 4.
Events echo all three numbers (score, local, area in percent), so you can tune from the stream
itself instead of guessing.
Daemon
sv_daemon.mjs runs the same pipeline outside the agent loop:
node sv_daemon.mjs --window "<window title>" --seconds 60 --fps 8 --captions --captionMs 1500
Install
# inside your DSH profile directory
npm install link:/path/to/dsh-streamvision
Add dsh-streamvision to your profile's dsh.profile.bundles, then restart DSH (plugins are not
hot-reloaded).
Notes
- Windows only (Win32 GDI + Windows.Media.Ocr).
- Text stream accuracy: the bundled Windows OCR is stable but not accurate for Chinese — a line is
only admitted after being seen twice, so a consistently misread line still enters the stream
("安装" → "女装", "目录" → "d i rectO"). Treat
sv_textas a hint, not as the source of truth, and prefer picture reads (sv_frame/sv_blocks) when the exact wording matters. For better Chinese, plug a real engine throughSV_OCR_CMD/data/ocr.json(PaddleOCR, RapidOCR, PP-OCR). - The process must be DPI-aware; the plugin calls
SetProcessDpiAwarenessContext(PER_MONITOR_AWARE_V2)on load. - Capture reads screen pixels: a window that is not in front gets whatever covers it.
- Sampling only. Input and window control deliberately live elsewhere.
License
MIT
Plugins relacionados
dsh-web-ui (dsh-tool-describe-image)
zhu1090093659/dsh-web-ui
modlens
liustack/modlens
ipollowork
devin-axis/ipollowork
dsh-image-gen
shanliuling/dsh-image-gen