dsh-watch-together 0.2.2 → 0.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1317 -1229
- package/README.md +21 -1
- package/docs/INTERFACES.zh.md +17 -0
- package/docs/images/reward-qr.png +0 -0
- package/dsh.plugin.json +12 -12
- package/examples/floating-chat/glass_window.py +9 -1
- package/examples/floating-chat/glass_window_gpu.py +16 -7
- package/examples/floating-chat/window.py +447 -74
- package/package.json +115 -111
- package/src/chat-store.js +17 -10
- package/src/handler.js +11 -1
- package/src/index.js +5 -5
- package/src/input-surface.js +13 -12
- package/src/interfaces.js +8 -2
- package/src/public-api.js +6 -0
- package/src/runtime-ports.js +45 -0
- package/src/watch-actions.js +177 -173
- package/src/watch-loop.js +13 -10
- package/src/watch-run.js +5 -5
- package/src/window-interface.js +21 -13
package/README.md
CHANGED
|
@@ -417,7 +417,7 @@ pythonw examples/floating-chat/window.py # 无控制台
|
|
|
417
417
|
```
|
|
418
418
|
|
|
419
419
|
它长这样:三块分开的液态玻璃(标题 / 主体 / 输入栏),气泡圆角、半透明,
|
|
420
|
-
|
|
420
|
+
你说的话靠右;标题栏可拖动、双击标题改名、▾ 折叠、✕ 关闭,底部有麦克风图标和发送。
|
|
421
421
|
窗口底稿就是 PR #15 的 `glass_window.py`(现在叫 `window.py`),没有另写一套
|
|
422
422
|
近似样式;GPU 伴生 `glass_window_gpu.py` 只把每帧合成搬到 moderngl,UI 和交互
|
|
423
423
|
仍是同一份,所以 CPU/GPU 形式一致。
|
|
@@ -594,6 +594,26 @@ node scripts/install-dev.mjs # 把本包同步进 DSH profile(副本
|
|
|
594
594
|
|
|
595
595
|
改完代码要重启 DSH Desktop 才生效(插件树在进程启动时组合)。
|
|
596
596
|
|
|
597
|
+
## 致谢
|
|
598
|
+
|
|
599
|
+
社区提的改动按 PR 记在这里(storyboard 那边的完整名单在 `dsh-video-storyboard/CREDITS.md`):
|
|
600
|
+
|
|
601
|
+
- [@ggfgfgf-on](https://github.com/ggfgfgf-on) —— 插件设置页([PR #11](https://github.com/SAOS-3624/dsh-watch-together/pull/11),设置直接渲染在插件详情页);
|
|
602
|
+
核心改走 runtime-ports、悬浮窗气泡与折叠重做([PR #22](https://github.com/SAOS-3624/dsh-watch-together/pull/22))
|
|
603
|
+
- [@DreamDLYY](https://github.com/DreamDLYY) —— 悬浮窗拖出屏幕后抓屏越界、日志每帧刷错、背景永久花屏的复现与修复([PR #23](https://github.com/SAOS-3624/dsh-watch-together/pull/23))
|
|
604
|
+
|
|
597
605
|
## 许可
|
|
598
606
|
|
|
599
607
|
Apache License 2.0 —— 见 [LICENSE](LICENSE)(全文)与 [NOTICE](NOTICE)(这个项目**不做什么**:不托管视频、不上传位置、不绕过 DRM、不内置 TTS 引擎)。
|
|
608
|
+
|
|
609
|
+
## 赞赏
|
|
610
|
+
|
|
611
|
+
免费、不锁功能、不需要授权 —— 就是 Apache-2.0,拿去用就行。
|
|
612
|
+
|
|
613
|
+
如果它替你省了时间,欢迎扫码:
|
|
614
|
+
|
|
615
|
+
<p align="center">
|
|
616
|
+
<img src="./docs/images/reward-qr.png" alt="赞赏码(微信 / 支付宝)" width="240">
|
|
617
|
+
</p>
|
|
618
|
+
|
|
619
|
+
打赏不解锁任何东西,也不影响这个项目以后的授权方式。
|
package/docs/INTERFACES.zh.md
CHANGED
|
@@ -30,6 +30,23 @@ api.tts.due({ at, segment, ... }); // 声音事件
|
|
|
30
30
|
每个接口都是 frozen 对象;缺少依赖时在**创建时**报错(`recognition` 缺
|
|
31
31
|
`runStoryboard` 等),而不是陪看跑到一半才炸。
|
|
32
32
|
|
|
33
|
+
### 运行时端口
|
|
34
|
+
|
|
35
|
+
`src/runtime-ports.js` 是核心模块取接口的唯一入口:
|
|
36
|
+
|
|
37
|
+
```js
|
|
38
|
+
import { installPorts, getTtsPort, getWindowPort } from 'dsh-watch-together/public-api';
|
|
39
|
+
|
|
40
|
+
installPorts({ tts: api.tts, window: api.window }); // 组合根注入
|
|
41
|
+
getTtsPort().due({ at: 12, text: '...' });
|
|
42
|
+
getWindowPort().message({ role: 'assistant', text: '...' });
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
`chat-store.js` / `watch-loop.js` / `watch-actions.js` / `input-surface.js`
|
|
46
|
+
只 import 这个端口模块,不再 import `voice.js`、`floating-window.js` 或
|
|
47
|
+
`window-protocol.js`。没有注入时端口提供历史默认实现(speech-bus + 自带
|
|
48
|
+
Python 窗口),所以 CLI 和既有测试行为不变。
|
|
49
|
+
|
|
33
50
|
## 2. 窗口线协议
|
|
34
51
|
|
|
35
52
|
窗口实现不需要 import 插件代码,只读写两个 JSONL 文件(默认在
|
|
Binary file
|
package/dsh.plugin.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "dsh-watch-together",
|
|
3
|
-
"description": "Watch a video together with a text-only agent: follow the user's real playback position and hand over one segment at a time, just before the segment ends.",
|
|
4
|
-
"version": "0.2.
|
|
5
|
-
"entry": {
|
|
6
|
-
"name": "dsh-watch-together",
|
|
7
|
-
"inject": [
|
|
8
|
-
"tools",
|
|
9
|
-
"attachments"
|
|
10
|
-
]
|
|
11
|
-
}
|
|
12
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "dsh-watch-together",
|
|
3
|
+
"description": "Watch a video together with a text-only agent: follow the user's real playback position and hand over one segment at a time, just before the segment ends.",
|
|
4
|
+
"version": "0.2.4",
|
|
5
|
+
"entry": {
|
|
6
|
+
"name": "dsh-watch-together",
|
|
7
|
+
"inject": [
|
|
8
|
+
"tools",
|
|
9
|
+
"attachments"
|
|
10
|
+
]
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -2,6 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
GPU 伴生文件按原始 PR 的布局 `import glass_window as G`;这里的窗口已经改名为
|
|
4
4
|
`window.py`(交互补全都在里面),所以用这个别名保持 GPU 路径可直接运行。
|
|
5
|
+
|
|
6
|
+
不再 `from window import *`:那样会在导入时复制一份全局量(W/H/SHAPES/
|
|
7
|
+
OVERLAY/BOX_MAPS),窗口缩放或气泡按文字改宽后,GPU 仍拿旧坐标合成,
|
|
8
|
+
表现就会和 CPU 不一致。这里改成动态代理,每次访问都回到 window.py。
|
|
5
9
|
"""
|
|
6
10
|
|
|
7
|
-
|
|
11
|
+
import window as _window
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def __getattr__(name):
|
|
15
|
+
return getattr(_window, name)
|
|
@@ -108,6 +108,7 @@ void main() {
|
|
|
108
108
|
float e = texelFetch(edge, p, 0).r;
|
|
109
109
|
vec2 ec = texelFetch(coord, p, 0).rg + offset;
|
|
110
110
|
ivec2 ep = clamp(ivec2(floor(ec + 0.5)), ivec2(0), ivec2(src_size) - 1);
|
|
111
|
+
// 边缘从小框自己的原始帧取,避免 warped 在贴边小框上采到黑边。
|
|
111
112
|
vec3 edgep = texelFetch(raw, ep, 0).rgb;
|
|
112
113
|
vec3 patch = mix(strong, edgep, e);
|
|
113
114
|
frag = vec4(mix(base, patch, a), 1.0);
|
|
@@ -213,6 +214,7 @@ class GPULens:
|
|
|
213
214
|
self._motion = 0.0
|
|
214
215
|
self.src = None
|
|
215
216
|
self.geo = None
|
|
217
|
+
self.geo_version = -1
|
|
216
218
|
self.fbos = {}
|
|
217
219
|
self.texs = {}
|
|
218
220
|
|
|
@@ -292,6 +294,7 @@ class GPULens:
|
|
|
292
294
|
t = self._tex("union", (HW, HH), 1, "f1", union.tobytes())
|
|
293
295
|
t.filter = (moderngl.LINEAR, moderngl.LINEAR)
|
|
294
296
|
self.geo = (W, H, hw, hh, HW, HH)
|
|
297
|
+
self.geo_version = G.SHAPES_VERSION
|
|
295
298
|
self.fbos.clear()
|
|
296
299
|
self.texs = {k: v for k, v in self.texs.items()
|
|
297
300
|
if k in ("alpha", "edge", "coord", "warpcoord", "overlay", "union")}
|
|
@@ -306,8 +309,9 @@ class GPULens:
|
|
|
306
309
|
self.src.repeat_y = False
|
|
307
310
|
self.src.write(data)
|
|
308
311
|
|
|
309
|
-
def render(self, bgra, size, px, py, motion=0.0):
|
|
310
|
-
if self.geo is None or self.geo[:2] != (G.W, G.H)
|
|
312
|
+
def render(self, bgra, size, px, py, motion=0.0, moved=False):
|
|
313
|
+
if (self.geo is None or self.geo[:2] != (G.W, G.H)
|
|
314
|
+
or getattr(self, "geo_version", -1) != G.SHAPES_VERSION):
|
|
311
315
|
self._build_geo()
|
|
312
316
|
W, H, hw, hh, HW, HH = self.geo
|
|
313
317
|
gw, gh = size
|
|
@@ -407,8 +411,11 @@ class GPULens:
|
|
|
407
411
|
prev.color_attachments[0].use(1)
|
|
408
412
|
p = self.progs["post"]
|
|
409
413
|
p["texel"] = (1.0 / W, 1.0 / H)
|
|
410
|
-
|
|
411
|
-
|
|
414
|
+
# 和 CPU 一致:只在“本帧检测到移动”时混上一帧,停下立刻干净;
|
|
415
|
+
# 移动帧跳过色散,先把拖动/滚动响应保住。
|
|
416
|
+
p["blend"] = float(0.35 * max(0.0, min(1.0, motion))
|
|
417
|
+
if moved and getattr(self, "_prev_valid", False) else 0.0)
|
|
418
|
+
p["chroma"] = 0.0 if moved else 3.6 * (W / 900.0)
|
|
412
419
|
self._set(p, curr=0, prev=1)
|
|
413
420
|
p.vao.render(moderngl.TRIANGLES)
|
|
414
421
|
self.ctx.copy_framebuffer(prev, out)
|
|
@@ -450,18 +457,20 @@ def capture_gpu(self, sct):
|
|
|
450
457
|
moved = bool(float(d.mean()) > 0.01 or float(d.max()) > 0.5)
|
|
451
458
|
if moved:
|
|
452
459
|
self._last_motion = now
|
|
453
|
-
_gpu._motion = min(1.0, _gpu._motion * 0.
|
|
460
|
+
_gpu._motion = min(1.0, _gpu._motion * 0.50 + 0.50)
|
|
454
461
|
else:
|
|
455
|
-
_gpu._motion *= 0.
|
|
462
|
+
_gpu._motion *= 0.55
|
|
456
463
|
if (not G.FORCE and not moved and box == self._sig_bbox
|
|
457
464
|
and now - getattr(self, "_last_motion", 0.0) > 0.30):
|
|
458
465
|
self._sig = sig
|
|
459
466
|
_gpu._motion = 0.0
|
|
467
|
+
_gpu._prev_valid = False
|
|
460
468
|
return None
|
|
461
469
|
self._sig = sig
|
|
462
470
|
self._sig_bbox = box
|
|
463
471
|
|
|
464
|
-
panel = _gpu.render(shot.bgra, shot.size, px, py,
|
|
472
|
+
panel = _gpu.render(shot.bgra, shot.size, px, py,
|
|
473
|
+
motion=_gpu._motion, moved=moved)
|
|
465
474
|
out = panel.copy()
|
|
466
475
|
mic_box = out.crop((G.MIC_POS[0], G.MIC_POS[1],
|
|
467
476
|
G.MIC_POS[0] + 28, G.MIC_POS[1] + 28)).convert("L")
|