dsh-session-superagent 0.9.265 → 0.9.267
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 +75 -0
- package/README.md +3 -3
- package/client.js +458 -154
- package/lib/index.js +1 -1
- package/package.json +4 -2
- package/ui-host-primitives.js +122 -0
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.
|
|
50
|
+
export const SERVER_VERSION = '0.9.267'
|
|
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.
|
|
3
|
+
"version": "0.9.267",
|
|
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,122 @@
|
|
|
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
|
+
const [remountKey, setRemountKey] = React.useState(0)
|
|
75
|
+
React.useEffect(() => {
|
|
76
|
+
if (typeof window === 'undefined') return undefined
|
|
77
|
+
const target = window
|
|
78
|
+
const closeOnScroll = () => setRemountKey((current) => current + 1)
|
|
79
|
+
// DSH Tooltip 没有受控 open 或 scroll listener;capture 可同时覆盖嵌套滚动容器。
|
|
80
|
+
target.addEventListener('scroll', closeOnScroll, true)
|
|
81
|
+
return () => target.removeEventListener('scroll', closeOnScroll, true)
|
|
82
|
+
}, [])
|
|
83
|
+
// children 可替换 trigger;省略时保留 InfoTip 的 button / dt-info 调用面。
|
|
84
|
+
const trigger = children === undefined
|
|
85
|
+
? h('button', {
|
|
86
|
+
type: 'button',
|
|
87
|
+
className: ['dt-info', warn && 'dt-info-warn'].filter(Boolean).join(' '),
|
|
88
|
+
'aria-label': text,
|
|
89
|
+
}, defaultTooltipIcon(icon))
|
|
90
|
+
: children
|
|
91
|
+
if (!React.isValidElement(trigger)) {
|
|
92
|
+
throw new TypeError('Tooltip children 必须是单个 React element')
|
|
93
|
+
}
|
|
94
|
+
// 只以 key 重挂载宿主 Tooltip 来清掉内部 pinned 状态;不克隆 trigger、不增加 DOM 或事件层。
|
|
95
|
+
return h(HostTooltip, {
|
|
96
|
+
key: remountKey,
|
|
97
|
+
label: text,
|
|
98
|
+
side: 'top',
|
|
99
|
+
portal: true,
|
|
100
|
+
openOnClick: true,
|
|
101
|
+
gap: 8,
|
|
102
|
+
}, trigger)
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// 无第二套 timer:notify 只替换当前项,dismiss 交给 Toast.onDone(id) 调用。
|
|
106
|
+
function createToastState() {
|
|
107
|
+
const [item, setItem] = React.useState(null)
|
|
108
|
+
const sequence = React.useRef(0)
|
|
109
|
+
const notify = React.useCallback((text, tone = 'info') => {
|
|
110
|
+
sequence.current += 1
|
|
111
|
+
const id = sequence.current
|
|
112
|
+
setItem({ id, text, tone })
|
|
113
|
+
return id
|
|
114
|
+
}, [])
|
|
115
|
+
const dismiss = React.useCallback((id) => {
|
|
116
|
+
setItem((current) => dismissToast(current, id))
|
|
117
|
+
}, [])
|
|
118
|
+
return { item, notify, dismiss }
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
return { Modal, Toast, Tooltip, createToastState, dismissToast }
|
|
122
|
+
}
|