dsh-session-superagent 0.9.264 → 0.9.266

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/docs/README.md CHANGED
@@ -13,7 +13,7 @@
13
13
  | [为什么做这个产品](为什么做这个产品.md) | **动任何功能之前先读**:谁在痛、三条不变量(不打断 / 不留手尾 / 不失控)、明确不做什么 |
14
14
  | [对比-官方原型](对比-官方原型.md) | 想知道和官方 `dsh-superagent-prototype` 的功能差距、哪些该抄哪些不该 |
15
15
  | [official-decomp/](official-decomp/01-structure-tree.md) | **完整官方结构树**:运行时/事件源/面板/提示词运维逐文件解构,以及已落地与待吸收清单 |
16
- | [ui-decomp/](ui-decomp/03-gap-map.md) | **UI 复用主任务**:DSH 主库素材、superagent 控件、主理鱼逐页差距与已实施回写 |
16
+ | [ui-decomp/](ui-decomp/03-gap-map.md) | **UI 复用主任务**:DSH 主库素材、superagent 控件、逐页差距、宿主原语 smoke 与实施回写 |
17
17
  | [competitive-analysis](competitive-analysis.md) | 想知道和 Sweep / CodeRabbit 这类工具的差别 |
18
18
  | [deepseek-papers](deepseek-papers.md) | 想知道设计取舍背后的研究依据 |
19
19
  | [真机验证清单](真机验证清单.md) | 重启后三条命令 + 三个动作,5 分钟确认新代码在跑 |
package/lib/index.js CHANGED
@@ -47,7 +47,7 @@ import {
47
47
 
48
48
  export const name = 'dsh-session-superagent'
49
49
  /** 服务端版本:随 package.json 同步(meta 测试守着)。客户端据此挑「最新的那个实例」。 */
50
- export const SERVER_VERSION = '0.9.264'
50
+ export const SERVER_VERSION = '0.9.266'
51
51
  export const inject = ['tools', 'agents', 'webServer']
52
52
  /** 一条会话每小时最多被唤醒几次(跨所有守累计)。单守上限挡不住多守叠加。 */
53
53
  // 本进程启动时刻:用来区分「刚重启还没轮到」与「定时器真的丢了」
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-session-superagent",
3
- "version": "0.9.264",
3
+ "version": "0.9.266",
4
4
  "description": "Session-level superagent for DeepSeek Harness: watch a GitHub repository and wake a session when something needs doing. Credentials never reach the model.",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
@@ -9,7 +9,8 @@
9
9
  "./watch": "./lib/watch.js",
10
10
  "./redact": "./lib/redact.js",
11
11
  "./package.json": "./package.json",
12
- "./client": "./client.js"
12
+ "./client": "./client.js",
13
+ "./host-primitives": "./ui-host-primitives.js"
13
14
  },
14
15
  "files": [
15
16
  "lib/index.js",
@@ -25,6 +26,7 @@
25
26
  "CHANGELOG.md",
26
27
  "LICENSE",
27
28
  "client.js",
29
+ "ui-host-primitives.js",
28
30
  "bin/check.mjs",
29
31
  "assets/icon-180.png",
30
32
  "docs/whats-new-0.9.md",
@@ -0,0 +1,111 @@
1
+ // L84d:DSH 宿主原语的薄适配层。
2
+ // 这里只转换调用面,不实现焦点圈、portal、定位、计时或第二套弹层。
3
+
4
+ const TOOLTIP_ICONS = Object.freeze({
5
+ question: 'IconQuestionOutlineMedium',
6
+ info: 'IconInfoOutlineMedium',
7
+ warn: 'IconWarningOutlineMedium',
8
+ warning: 'IconWarningOutlineMedium',
9
+ alert: 'IconWarningOutlineMedium',
10
+ })
11
+
12
+ /** 只清除 id 仍相同的 Toast;旧 Toast 的完成回调不能清除新通知。 */
13
+ export function dismissToast(current, id) {
14
+ return current && current.id === id ? null : current
15
+ }
16
+
17
+ /**
18
+ * 用宿主注入的 React 与 @deepseek-ai/dsh-client-ui-primitives 创建适配器。
19
+ * 原语必须由调用方通过 factory require 取得;本模块不做文件系统包解析。
20
+ */
21
+ export function createHostUi({ React, primitives } = {}) {
22
+ if (!React || typeof React.createElement !== 'function' || typeof React.isValidElement !== 'function') {
23
+ throw new TypeError('createHostUi 需要宿主 React.createElement 与 React.isValidElement')
24
+ }
25
+ if (!primitives || (typeof primitives !== 'object' && typeof primitives !== 'function')) {
26
+ throw new TypeError('createHostUi 需要 DSH primitives')
27
+ }
28
+
29
+ const h = React.createElement
30
+ const primitive = (name) => {
31
+ const value = primitives[name]
32
+ if (!value) {
33
+ throw new Error(`DSH primitives.${name} 不可用;适配层不会创建替代弹层`)
34
+ }
35
+ return value
36
+ }
37
+
38
+ function Modal({ open, title, description, footer, onClose, className, children } = {}) {
39
+ if (!open) return null
40
+ return h(primitive('Modal'), {
41
+ open,
42
+ title,
43
+ description,
44
+ footer,
45
+ onClose,
46
+ className,
47
+ closeLabel: '关闭',
48
+ }, children)
49
+ }
50
+
51
+ function Toast({ item, onDone } = {}) {
52
+ if (item === null || item === undefined) return null
53
+ return h(primitive('Toast'), {
54
+ key: item.id,
55
+ text: item.text,
56
+ tone: item.tone,
57
+ holdMs: 3000,
58
+ // success 由宿主生成内建勾;error 必须显式使用官方 warning icon。
59
+ icon: item.tone === 'error' ? h(primitive('IconWarningOutlineMedium')) : undefined,
60
+ // 宿主 onDone 不带参数;这里只把完成项 id 交回调用方做 id guard。
61
+ onDone: () => onDone(item.id),
62
+ })
63
+ }
64
+
65
+ const defaultTooltipIcon = (icon) => {
66
+ if (React.isValidElement(icon)) return icon
67
+ // 与现有 InfoTip 一样,未识别的字符串回退到 question,但不自绘 SVG。
68
+ const exportName = TOOLTIP_ICONS[icon] || TOOLTIP_ICONS.question
69
+ return h(primitive(exportName))
70
+ }
71
+
72
+ function Tooltip({ text, icon = 'question', warn = false, children } = {}) {
73
+ const HostTooltip = primitive('Tooltip')
74
+ // children 可替换 trigger;省略时保留 InfoTip 的 button / dt-info 调用面。
75
+ const trigger = children === undefined
76
+ ? h('button', {
77
+ type: 'button',
78
+ className: ['dt-info', warn && 'dt-info-warn'].filter(Boolean).join(' '),
79
+ 'aria-label': text,
80
+ }, defaultTooltipIcon(icon))
81
+ : children
82
+ if (!React.isValidElement(trigger)) {
83
+ throw new TypeError('Tooltip children 必须是单个 React element')
84
+ }
85
+ return h(HostTooltip, {
86
+ label: text,
87
+ side: 'top',
88
+ portal: true,
89
+ openOnClick: true,
90
+ gap: 8,
91
+ }, trigger)
92
+ }
93
+
94
+ // 无第二套 timer:notify 只替换当前项,dismiss 交给 Toast.onDone(id) 调用。
95
+ function createToastState() {
96
+ const [item, setItem] = React.useState(null)
97
+ const sequence = React.useRef(0)
98
+ const notify = React.useCallback((text, tone = 'info') => {
99
+ sequence.current += 1
100
+ const id = sequence.current
101
+ setItem({ id, text, tone })
102
+ return id
103
+ }, [])
104
+ const dismiss = React.useCallback((id) => {
105
+ setItem((current) => dismissToast(current, id))
106
+ }, [])
107
+ return { item, notify, dismiss }
108
+ }
109
+
110
+ return { Modal, Toast, Tooltip, createToastState, dismissToast }
111
+ }