attention-plugins · 轻量级 DSH Web 插件:智能任务通知,主线/支线管理
Lightweight DSH Web plugin — smart session notifications with main-line / side-line orchestration
- ✅ 4 种事件通知:完成、失败、提问、权限请求
- ⭐ 主线/支线管理:主线任务立即响,支线全部完成才响一次
- 🎯 ⭐ 一键标记:会话标题栏 + 输入框工具行两处标记主线,新会话发消息前即可标记
- 🔊 3 种内置音效:Chime / Success / Subtle(Web Audio 实时合成)
- 🔔 浏览器通知:离开标签页时弹出系统通知
- 🎛️ 灵活配置:独立的设置面板,音量可调,事件独立开关
- ✨ 动效面板:设置面板标题「Attention is all you need」衬线排版 + 图纸式自注意力连线图(浅色图版深色墨线、query 轮换、印刷品级对比、零辉光),主线标记直接内嵌原神原石官方贴图(尊重
prefers-reduced-motion) - 🧪 测试覆盖:62 个单元测试,100% 通过
要求:DeepSeek Harness ≥ 0.1.6-alpha.1
# 从本地安装
cd /path/to/attention-plugins
pnpm install && pnpm run build
dsh plugin --profile web add file:$(pwd)
# 重启 DSH Web
dsh web安装后:
- 打开 Settings → Attention 配置插件
- 打开任意会话,标题栏右侧看到 ☆ 设为主线 按钮;或在新会话(尚未发送第一条消息时)输入框工具行左侧找到 ☆ 小图标
- 点击
☆→ 变成⭐ 主线(橙色高亮);新会话可在发出第一条消息之前就标记为主线
启动 4 个任务:A(主线)、B、C、D
- A 完成 → 🔔 立即通知
- B、C、D 依次完成 → 静默
- 所有支线完成 → 🔔 "All side-line tasks completed"
启动 3 个任务:A、B、C(都不标记主线)
- A 完成 → 静默
- B 完成 → 静默
- C 完成 → 🔔 "All tasks completed"
会话运行中需要回答问题
→ 🔔 通知 + 🎵 Chime(question 事件)
→ 用户返回查看并回答
设置面板(Settings → Attention):
| 配置项 | 说明 | 默认值 |
|---|---|---|
| 🔊 声音通知 | 总开关 | ✅ 开启 |
| 🎵 音效选择 | Chime / Success / Subtle | Chime |
| 🔉 音量 | 0-100% | 70% |
| 🔔 浏览器通知 | 系统通知 | ❌ 关闭 |
| 👁️ 为当前会话也通知 | 正在查看的会话也响 | ❌ 关闭 |
事件独立配置:
| 事件 | 默认音效 | 说明 |
|---|---|---|
| ✅ Completed | Chime | 任务成功完成 |
| Subtle | 任务执行失败 | |
| ❓ Question | Success | 需要用户回答 |
| 🔒 Permission | Success | 需要用户授权 |
⭐ 主线标记:
- 位置 1:会话标题栏右侧(带文字按钮)
- 位置 2:输入框工具行左侧(紧凑小图标,新会话发消息前即可用)
- 未标记:
☆(灰色) - 已标记:
⭐(橙色高亮)
- 事件检测:监听
api-session/status远程事件 - 边沿检测:跟踪
running状态(true → false = 完成) - 失败检测:监听
api-session/error(agent loop 的真实失败;用户主动中止不会触发),按「本轮运行期间是否新增错误」归属 - 提问 / 权限检测:这两类没有对应的
api-session/*远程事件,唯一来源是 UI 状态源ctx.uiSession.sessionStatus里的pendingInteraction(kind: 'question' | 'plan-review' | 'approval');通过ctx.inject(['uiSession'])订阅,首帧静默只记录基线 - 音效合成:Web Audio API(OscillatorNode + GainNode);响度按系统提示音量级校准(70% 音量下峰值约 −7~−9 dBFS,含起振包络防爆音;低频
subtle按等响曲线补偿);AudioContext 冷启动预热 +devicechange后重建,避免蓝牙切换后首次提示音被吞或路由失效 - 通知:Notification API(需用户授权)
- 存储:localStorage(
attention-plugins:config) - Slot 注入:
conversation.session.header.utilities(⭐ 按钮)+conversation.input.left(输入框工具行 ⭐ 小图标)
# 安装依赖
pnpm install
# 构建
pnpm run build
# 监听模式
pnpm run watch
# 运行测试
pnpm test
# 清理
pnpm run clean测试覆盖:
✓ tests/engine.test.ts (21 tests)
✓ tests/mainline-sideline-advanced.test.ts (16 tests)
✓ tests/pending.test.ts (10 tests)
✓ tests/sound-params.test.ts (15 tests)
Test Files 4 passed (4)
Tests 62 passed (62)
- 4 种事件类型(completed / failed / question / permission)
- 主线/支线逻辑
- ⭐ 主线标记按钮(header slot)
- ⭐ 主线标记小图标(composer 工具行,发消息前可用)
- 声音提示(3 种内置音效)
- 浏览器系统通知
- 设置面板 UI
- 设置面板动效(衬线标题 + 图纸式连线图 / 官方原石贴图标记 / 卡片入场)
- 中英文本地化
- 47 个单元测试
- npm 发布
- 社区插件目录收录
- 更多音效选择
- 自定义音频上传
未来展望:详见 docs/vision.md
基于 @dingyi222666/dsh-session-notification 的架构设计(MIT License),完全重写并扩展为支持主线/支线逻辑的版本。
MIT License - 详见 LICENSE
- ✅ 4 Event Types: completed, failed, question, permission
- ⭐ Main/Side-line Management: Main-line alerts immediately, side-line alerts when ALL finish
- 🎯 ⭐ One-click Marker: Mark main-line from the conversation header or the composer tool row — available before the first message of a new session
- 🔊 3 Built-in Sounds: Chime / Success / Subtle (Web Audio synthesis)
- 🔔 Browser Notifications: System notifications when away
- 🎛️ Flexible Config: Dedicated settings panel, volume control, per-event switches
- ✨ Animated Panel: serif-typeset "Attention is all you need" title over a printed-plate self-attention figure (dark ink lines on a near-white plate, rotating query, zero glow); the mainline marker embeds the official Genshin Primogem texture (honours
prefers-reduced-motion) - 🧪 Test Coverage: 62 unit tests, 100% passed
Requirements: DeepSeek Harness ≥ 0.1.6-alpha.1
# Install from local
cd /path/to/attention-plugins
pnpm install && pnpm run build
dsh plugin --profile web add file:$(pwd)
# Restart DSH Web
dsh webAfter installation:
- Open Settings → Attention to configure
- Open any session, see ☆ Set as Main button in header
- Click
☆→ becomes⭐ Main(orange highlight)
Start 4 tasks: A (main), B, C, D
- A completes → 🔔 Alert immediately
- B, C, D complete → Silent
- All side-line done → 🔔 "All side-line tasks completed"
Start 3 tasks: A, B, C (no main-line marked)
- A completes → Silent
- B completes → Silent
- C completes → 🔔 "All tasks completed"
Session asks a question
→ 🔔 Notification + 🎵 Chime (question event)
→ User returns to answer
Settings Panel (Settings → Attention):
| Option | Description | Default |
|---|---|---|
| 🔊 Sound Notifications | Master switch | ✅ On |
| 🎵 Sound Effect | Chime / Success / Subtle | Chime |
| 🔉 Volume | 0-100% | 70% |
| 🔔 Browser Notifications | System notifications | ❌ Off |
| 👁️ Alert for Current Session | Also notify when viewing | ❌ Off |
Per-event Configuration:
| Event | Default Sound | Description |
|---|---|---|
| ✅ Completed | Chime | Task finished successfully |
| Subtle | Task execution failed | |
| ❓ Question | Success | User answer required |
| 🔒 Permission | Success | User authorization needed |
⭐ Main-line Marker:
- Location: Conversation header right side
- Unmarked:
☆ Set as Main(gray) - Marked:
⭐ Main(orange highlight)
- Event Detection: Listens to
api-session/statusremote events - Edge Detection: Tracks
runningstate (true → false = completed) - Failure Detection: Listens to
api-session/error(a genuine agent-loop failure; a user-initiated abort does not raise it), attributed to the run that was active - Question / Permission Detection: neither has an
api-session/*remote event — the only source ispendingInteractionon the UI status sourcectx.uiSession.sessionStatus(kind: 'question' | 'plan-review' | 'approval'), subscribed viactx.inject(['uiSession']); the first frame only records a baseline - Sound Synthesis: Web Audio API (OscillatorNode + GainNode); loudness calibrated to system-alert ballpark (≈ −7~−9 dBFS peaks at 70% volume, with attack ramps against clicks; the low-frequency
subtleis equal-loudness compensated); AudioContext cold-start priming +devicechangerecreation, so the first alert after a Bluetooth switch is neither swallowed nor left on a dead route - Notifications: Notification API (requires user permission)
- Storage: localStorage (
attention-plugins:config) - Slot Injection:
conversation.session.header.utilities(⭐ button)
# Install dependencies
pnpm install
# Build
pnpm run build
# Watch mode
pnpm run watch
# Run tests
pnpm test
# Clean
pnpm run cleanTest Coverage:
✓ tests/engine.test.ts (21 tests)
✓ tests/mainline-sideline-advanced.test.ts (16 tests)
✓ tests/pending.test.ts (10 tests)
✓ tests/sound-params.test.ts (15 tests)
Test Files 4 passed (4)
Tests 62 passed (62)
- 4 event types (completed / failed / question / permission)
- Main-line/side-line logic
- ⭐ Main-line marker button (header slot)
- Sound notifications (3 built-in effects)
- Browser notifications
- Settings panel UI
- Settings panel motion (serif title + printed-plate figure / official Primogem texture marker / card entrance)
- English/Chinese localization
- 47 unit tests
- npm publish
- Community plugin directory listing
- More sound effects
- Custom audio upload
Future Vision: See docs/vision.md
Based on the architecture of @dingyi222666/dsh-session-notification (MIT License), completely rewritten and extended with main-line/side-line logic.
MIT License - see LICENSE