dsh-ta 0.0.0-stage → 0.1.0
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 +18 -0
- package/LICENSE +21 -0
- package/README.md +387 -2
- package/client.js +545 -0
- package/cordis.patch.yml +101 -0
- package/docs/RELEASE.md +88 -0
- package/docs/presets.example.yml +95 -0
- package/docs/reme/.env.example +11 -0
- package/docs/reme/docker-compose.yml +25 -0
- package/icon.svg +8 -0
- package/index.js +1675 -0
- package/locale/en.json +6 -0
- package/locale/zh.json +6 -0
- package/memory/capture.js +113 -0
- package/memory/messages.js +76 -0
- package/memory/outbox.js +130 -0
- package/package.json +60 -4
package/client.js
ADDED
|
@@ -0,0 +1,545 @@
|
|
|
1
|
+
window.__ModuleLoader__.load({
|
|
2
|
+
id: 'dsh-ta',
|
|
3
|
+
factory(require) {
|
|
4
|
+
const React = require('react')
|
|
5
|
+
const h = React.createElement
|
|
6
|
+
|
|
7
|
+
const DEFAULTS = {
|
|
8
|
+
taHome: '~/TATA/home',
|
|
9
|
+
remeEndpoint: 'http://127.0.0.1:2333',
|
|
10
|
+
jurisdictions: ['~/dsh'],
|
|
11
|
+
captureEnabled: true,
|
|
12
|
+
captureInterval: 5,
|
|
13
|
+
heartbeatEnabled: false,
|
|
14
|
+
heartbeatActiveStart: '08:00',
|
|
15
|
+
heartbeatActiveEnd: '23:00',
|
|
16
|
+
dreamEnabled: true,
|
|
17
|
+
outingCleanupEnabled: true,
|
|
18
|
+
jurisdictionOutingEnabled: true,
|
|
19
|
+
jurisdictionOutingTime: '22:45',
|
|
20
|
+
timezone: 'Asia/Shanghai',
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const FIELD_KEYS = [
|
|
24
|
+
'taHome',
|
|
25
|
+
'remeEndpoint',
|
|
26
|
+
'jurisdictions',
|
|
27
|
+
'captureEnabled',
|
|
28
|
+
'captureInterval',
|
|
29
|
+
'heartbeatEnabled',
|
|
30
|
+
'heartbeatActiveStart',
|
|
31
|
+
'heartbeatActiveEnd',
|
|
32
|
+
'dreamEnabled',
|
|
33
|
+
'outingCleanupEnabled',
|
|
34
|
+
'jurisdictionOutingEnabled',
|
|
35
|
+
'jurisdictionOutingTime',
|
|
36
|
+
'timezone',
|
|
37
|
+
]
|
|
38
|
+
|
|
39
|
+
const inputStyle = {
|
|
40
|
+
width: '100%',
|
|
41
|
+
boxSizing: 'border-box',
|
|
42
|
+
padding: '7px 9px',
|
|
43
|
+
border: '1px solid var(--dsw-alias-border-l4, var(--dsw-alias-border-l1, rgba(127,127,127,.28)))',
|
|
44
|
+
borderRadius: 7,
|
|
45
|
+
background: 'var(--dsw-alias-bg-layer-1, rgba(127,127,127,.06))',
|
|
46
|
+
color: 'inherit',
|
|
47
|
+
font: 'inherit',
|
|
48
|
+
fontSize: 13,
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function parseJurisdictions(text) {
|
|
52
|
+
return String(text ?? '').split(/\r?\n/).map(item => item.trim()).filter(Boolean)
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return {
|
|
56
|
+
inject: ['slots', 'uiWorkspace', 'workspaces', 'configForms'],
|
|
57
|
+
apply(ctx) {
|
|
58
|
+
const uiWorkspace = ctx.uiWorkspace || ctx.get('uiWorkspace')
|
|
59
|
+
const workspaces = ctx.workspaces || ctx.get('workspaces')
|
|
60
|
+
const configForms = ctx.configForms || ctx.get('configForms')
|
|
61
|
+
|
|
62
|
+
function configuredHome() {
|
|
63
|
+
try {
|
|
64
|
+
const value = configForms?.get('dsh-ta')?.getSnapshot?.().value
|
|
65
|
+
return typeof value?.taHome === 'string' && value.taHome ? value.taHome : DEFAULTS.taHome
|
|
66
|
+
} catch {
|
|
67
|
+
return DEFAULTS.taHome
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function TaEntry({ wide }) {
|
|
72
|
+
const [busy, setBusy] = React.useState(false)
|
|
73
|
+
const [error, setError] = React.useState('')
|
|
74
|
+
|
|
75
|
+
async function openTa() {
|
|
76
|
+
if (busy) return
|
|
77
|
+
if (!uiWorkspace || !workspaces) {
|
|
78
|
+
setError('会话服务未就绪')
|
|
79
|
+
return
|
|
80
|
+
}
|
|
81
|
+
setBusy(true)
|
|
82
|
+
setError('')
|
|
83
|
+
try {
|
|
84
|
+
const home = configuredHome()
|
|
85
|
+
const suffix = home.replace(/^~\/?/, '').replace(/\/+$/, '')
|
|
86
|
+
const workspace = workspaces?.list?.getSnapshot?.().items
|
|
87
|
+
?.find(item => item.path === home
|
|
88
|
+
|| (suffix && item.path?.endsWith(`/${suffix}`)))
|
|
89
|
+
if (!workspace) {
|
|
90
|
+
setError(`没有找到 ${home} 工作区`)
|
|
91
|
+
return
|
|
92
|
+
}
|
|
93
|
+
await uiWorkspace.openWorkspace(workspace.workspaceId, undefined, { agentPreset: 'ta' })
|
|
94
|
+
} catch (cause) {
|
|
95
|
+
setError(cause instanceof Error ? cause.message : String(cause))
|
|
96
|
+
} finally {
|
|
97
|
+
setBusy(false)
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
return h('button', {
|
|
102
|
+
type: 'button',
|
|
103
|
+
title: error || '去找Ta',
|
|
104
|
+
'aria-label': '去找Ta',
|
|
105
|
+
disabled: busy,
|
|
106
|
+
onClick: openTa,
|
|
107
|
+
style: {
|
|
108
|
+
display: 'inline-flex',
|
|
109
|
+
alignItems: 'center',
|
|
110
|
+
justifyContent: 'center',
|
|
111
|
+
gap: 6,
|
|
112
|
+
height: 30,
|
|
113
|
+
width: wide ? 'auto' : 30,
|
|
114
|
+
padding: wide ? '0 9px' : 0,
|
|
115
|
+
border: '1px solid var(--dsw-alias-border-l2, var(--dsw-alias-border-l1, rgba(127,127,127,.28)))',
|
|
116
|
+
borderRadius: 8,
|
|
117
|
+
background: 'transparent',
|
|
118
|
+
color: 'inherit',
|
|
119
|
+
font: 'inherit',
|
|
120
|
+
fontSize: 12,
|
|
121
|
+
cursor: busy ? 'default' : 'pointer',
|
|
122
|
+
opacity: busy ? 0.6 : 1,
|
|
123
|
+
},
|
|
124
|
+
},
|
|
125
|
+
h('span', { 'aria-hidden': true, style: { fontSize: 14, lineHeight: 1 } }, '✦'),
|
|
126
|
+
wide ? h('span', null, error || '去找Ta') : null)
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function Field({ label, hint, children }) {
|
|
130
|
+
return h('label', {
|
|
131
|
+
style: { display: 'grid', gap: 5, marginBottom: 15 },
|
|
132
|
+
},
|
|
133
|
+
h('span', { style: { fontSize: 13, fontWeight: 600 } }, label),
|
|
134
|
+
children,
|
|
135
|
+
hint ? h('span', {
|
|
136
|
+
style: { fontSize: 11, lineHeight: 1.45, opacity: 0.62 },
|
|
137
|
+
}, hint) : null)
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
function Toggle({ label, hint, checked, disabled, onChange }) {
|
|
141
|
+
return h('label', {
|
|
142
|
+
style: {
|
|
143
|
+
display: 'flex',
|
|
144
|
+
alignItems: 'flex-start',
|
|
145
|
+
gap: 9,
|
|
146
|
+
marginBottom: 12,
|
|
147
|
+
cursor: disabled ? 'default' : 'pointer',
|
|
148
|
+
opacity: disabled ? 0.55 : 1,
|
|
149
|
+
},
|
|
150
|
+
},
|
|
151
|
+
h('input', {
|
|
152
|
+
type: 'checkbox',
|
|
153
|
+
checked: Boolean(checked),
|
|
154
|
+
disabled,
|
|
155
|
+
onChange: event => onChange(event.target.checked),
|
|
156
|
+
style: { marginTop: 2, accentColor: 'var(--dsw-alias-brand-primary, #4d6bfe)' },
|
|
157
|
+
}),
|
|
158
|
+
h('span', null,
|
|
159
|
+
h('span', { style: { display: 'block', fontSize: 13, fontWeight: 600 } }, label),
|
|
160
|
+
hint ? h('span', {
|
|
161
|
+
style: { display: 'block', marginTop: 2, fontSize: 11, lineHeight: 1.45, opacity: 0.62 },
|
|
162
|
+
}, hint) : null))
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
function Section({ title, children }) {
|
|
166
|
+
return h('section', {
|
|
167
|
+
style: {
|
|
168
|
+
padding: '15px 16px 2px',
|
|
169
|
+
marginBottom: 14,
|
|
170
|
+
border: '1px solid var(--dsw-alias-border-l2, var(--dsw-alias-border-l1, rgba(127,127,127,.2)))',
|
|
171
|
+
borderRadius: 10,
|
|
172
|
+
background: 'var(--dsw-alias-bg-layer-1, rgba(127,127,127,.035))',
|
|
173
|
+
},
|
|
174
|
+
},
|
|
175
|
+
h('h3', {
|
|
176
|
+
style: { margin: '0 0 13px', fontSize: 13, letterSpacing: '.02em', opacity: 0.82 },
|
|
177
|
+
}, title),
|
|
178
|
+
children)
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
function TaSettings() {
|
|
182
|
+
const [form, setForm] = React.useState(null)
|
|
183
|
+
const [draft, setDraft] = React.useState({ ...DEFAULTS })
|
|
184
|
+
const [baseline, setBaseline] = React.useState({ ...DEFAULTS })
|
|
185
|
+
const [jurisdictionText, setJurisdictionText] = React.useState(DEFAULTS.jurisdictions.join('\n'))
|
|
186
|
+
const [state, setState] = React.useState('loading')
|
|
187
|
+
const [message, setMessage] = React.useState('')
|
|
188
|
+
const saving = React.useRef(false)
|
|
189
|
+
const editing = React.useRef(false)
|
|
190
|
+
|
|
191
|
+
React.useEffect(() => {
|
|
192
|
+
if (!configForms) {
|
|
193
|
+
setState('unavailable')
|
|
194
|
+
setMessage('配置服务不可用')
|
|
195
|
+
return undefined
|
|
196
|
+
}
|
|
197
|
+
let bound
|
|
198
|
+
let ready = false
|
|
199
|
+
const timeout = setTimeout(() => {
|
|
200
|
+
if (!ready) {
|
|
201
|
+
setState('unavailable')
|
|
202
|
+
setMessage('读取配置超时,请刷新页面重试')
|
|
203
|
+
}
|
|
204
|
+
}, 10000)
|
|
205
|
+
try {
|
|
206
|
+
bound = configForms.get('dsh-ta')
|
|
207
|
+
setForm(bound)
|
|
208
|
+
} catch (cause) {
|
|
209
|
+
ready = true
|
|
210
|
+
setState('unavailable')
|
|
211
|
+
setMessage(cause instanceof Error ? cause.message : String(cause))
|
|
212
|
+
return undefined
|
|
213
|
+
}
|
|
214
|
+
const read = () => {
|
|
215
|
+
const snapshot = bound.getSnapshot()
|
|
216
|
+
if (snapshot.status === 'unavailable') {
|
|
217
|
+
ready = true
|
|
218
|
+
setState('unavailable')
|
|
219
|
+
setMessage('当前 profile 没有提供 dsh-ta 配置')
|
|
220
|
+
return
|
|
221
|
+
}
|
|
222
|
+
if (snapshot.status === 'loading' && !snapshot.value) return
|
|
223
|
+
if (snapshot.value && !saving.current && !editing.current) {
|
|
224
|
+
const next = { ...DEFAULTS, ...snapshot.value }
|
|
225
|
+
setDraft(next)
|
|
226
|
+
setBaseline(next)
|
|
227
|
+
setJurisdictionText((next.jurisdictions ?? DEFAULTS.jurisdictions).join('\n'))
|
|
228
|
+
ready = true
|
|
229
|
+
setState('ready')
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
read()
|
|
233
|
+
const unsubscribe = bound.subscribe(read)
|
|
234
|
+
return () => {
|
|
235
|
+
clearTimeout(timeout)
|
|
236
|
+
unsubscribe()
|
|
237
|
+
}
|
|
238
|
+
}, [])
|
|
239
|
+
|
|
240
|
+
const update = (field, value) => {
|
|
241
|
+
if (saving.current) return
|
|
242
|
+
editing.current = true
|
|
243
|
+
setDraft(previous => ({ ...previous, [field]: value }))
|
|
244
|
+
setMessage('')
|
|
245
|
+
setState(previous => previous === 'error' ? 'ready' : previous)
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
const save = async () => {
|
|
249
|
+
if (!form || saving.current) return
|
|
250
|
+
const target = {
|
|
251
|
+
...draft,
|
|
252
|
+
jurisdictions: parseJurisdictions(jurisdictionText),
|
|
253
|
+
}
|
|
254
|
+
target.taHome = String(target.taHome ?? '').trim()
|
|
255
|
+
if (!target.taHome) {
|
|
256
|
+
setState('error')
|
|
257
|
+
setMessage('Ta 的家目录不能为空')
|
|
258
|
+
return
|
|
259
|
+
}
|
|
260
|
+
if (target.taHome === '/' || target.taHome === '~') {
|
|
261
|
+
setState('error')
|
|
262
|
+
setMessage('Ta 的家目录不能是 / 或 ~')
|
|
263
|
+
return
|
|
264
|
+
}
|
|
265
|
+
if (target.jurisdictions.length === 0) {
|
|
266
|
+
setState('error')
|
|
267
|
+
setMessage('至少保留一个只读辖区')
|
|
268
|
+
return
|
|
269
|
+
}
|
|
270
|
+
if (target.jurisdictions.some(root => root === '/' || root === '~')) {
|
|
271
|
+
setState('error')
|
|
272
|
+
setMessage('辖区不能是 / 或 ~')
|
|
273
|
+
return
|
|
274
|
+
}
|
|
275
|
+
if (!Number.isInteger(target.captureInterval) || target.captureInterval < 1 || target.captureInterval > 60) {
|
|
276
|
+
setState('error')
|
|
277
|
+
setMessage('捕获间隔必须是 1–60 的整数')
|
|
278
|
+
return
|
|
279
|
+
}
|
|
280
|
+
try {
|
|
281
|
+
const endpoint = new URL(target.remeEndpoint)
|
|
282
|
+
if (endpoint.protocol !== 'http:' && endpoint.protocol !== 'https:') throw new Error('协议')
|
|
283
|
+
} catch {
|
|
284
|
+
setState('error')
|
|
285
|
+
setMessage('ReMe 地址必须是 http(s) URL')
|
|
286
|
+
return
|
|
287
|
+
}
|
|
288
|
+
for (const clock of [target.heartbeatActiveStart, target.heartbeatActiveEnd, target.jurisdictionOutingTime]) {
|
|
289
|
+
if (!/^([01]\d|2[0-3]):[0-5]\d$/.test(clock)) {
|
|
290
|
+
setState('error')
|
|
291
|
+
setMessage(`时间格式应为 HH:MM,当前是 ${clock}`)
|
|
292
|
+
return
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
try {
|
|
296
|
+
new Intl.DateTimeFormat('en-US', { timeZone: target.timezone })
|
|
297
|
+
} catch {
|
|
298
|
+
setState('error')
|
|
299
|
+
setMessage(`无效时区:${target.timezone}`)
|
|
300
|
+
return
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
const snapshot = form.getSnapshot()
|
|
304
|
+
if (snapshot.writable === false) {
|
|
305
|
+
setState('error')
|
|
306
|
+
setMessage('当前 profile 不允许写入配置')
|
|
307
|
+
return
|
|
308
|
+
}
|
|
309
|
+
const changed = FIELD_KEYS.filter(field => JSON.stringify(target[field]) !== JSON.stringify(baseline[field]))
|
|
310
|
+
if (changed.length === 0) {
|
|
311
|
+
setState('ready')
|
|
312
|
+
setMessage('没有修改')
|
|
313
|
+
return
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
saving.current = true
|
|
317
|
+
setState('saving')
|
|
318
|
+
setMessage('')
|
|
319
|
+
try {
|
|
320
|
+
const ops = changed.map(field => ({ op: 'set', path: [field], value: target[field] }))
|
|
321
|
+
const accepted = await form.mutate(ops, snapshot.revision)
|
|
322
|
+
if (!accepted) throw new Error('宿主拒绝了这次配置写入')
|
|
323
|
+
editing.current = false
|
|
324
|
+
setDraft(target)
|
|
325
|
+
setBaseline(target)
|
|
326
|
+
setJurisdictionText(target.jurisdictions.join('\n'))
|
|
327
|
+
setState('ready')
|
|
328
|
+
setMessage('已保存。配置已即时生效。')
|
|
329
|
+
} catch (cause) {
|
|
330
|
+
setState('error')
|
|
331
|
+
setMessage(cause instanceof Error ? cause.message : String(cause))
|
|
332
|
+
} finally {
|
|
333
|
+
saving.current = false
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
const reset = () => {
|
|
338
|
+
editing.current = false
|
|
339
|
+
setDraft({ ...baseline })
|
|
340
|
+
setJurisdictionText((baseline.jurisdictions ?? DEFAULTS.jurisdictions).join('\n'))
|
|
341
|
+
setState('ready')
|
|
342
|
+
setMessage('')
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
if (state === 'loading') {
|
|
346
|
+
return h('div', { style: { padding: 24, fontSize: 13, opacity: 0.68 } }, '正在读取 Ta 配置…')
|
|
347
|
+
}
|
|
348
|
+
if (state === 'unavailable' || !form) {
|
|
349
|
+
return h('div', { style: { maxWidth: 760, padding: '8px 4px' } },
|
|
350
|
+
h('h2', { style: { margin: '0 0 8px', fontSize: 18 } }, 'TA 的家'),
|
|
351
|
+
h('p', { style: { margin: 0, fontSize: 13, lineHeight: 1.6, opacity: 0.68 } },
|
|
352
|
+
message || '当前 profile 没有提供 dsh-ta 配置,无法编辑。'),
|
|
353
|
+
h('p', { style: { margin: '12px 0 0', fontSize: 12, lineHeight: 1.55, opacity: 0.56 } },
|
|
354
|
+
'请先在 profile 中启用 dsh-ta 配置,然后刷新设置页。'))
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
const disabled = state === 'saving'
|
|
358
|
+
const dirty = FIELD_KEYS.some(field => JSON.stringify(draft[field]) !== JSON.stringify(baseline[field]))
|
|
359
|
+
|| JSON.stringify(parseJurisdictions(jurisdictionText)) !== JSON.stringify(baseline.jurisdictions)
|
|
360
|
+
const text = (field, placeholder) => h('input', {
|
|
361
|
+
style: inputStyle,
|
|
362
|
+
value: draft[field] ?? '',
|
|
363
|
+
placeholder,
|
|
364
|
+
disabled,
|
|
365
|
+
onChange: event => update(field, event.target.value),
|
|
366
|
+
})
|
|
367
|
+
const number = (field, min, max) => h('input', {
|
|
368
|
+
type: 'number',
|
|
369
|
+
min,
|
|
370
|
+
max,
|
|
371
|
+
style: inputStyle,
|
|
372
|
+
value: draft[field] ?? '',
|
|
373
|
+
disabled,
|
|
374
|
+
onChange: event => update(field, Number(event.target.value)),
|
|
375
|
+
})
|
|
376
|
+
|
|
377
|
+
return h('div', {
|
|
378
|
+
style: { maxWidth: 760, padding: '8px 4px 28px', color: 'inherit' },
|
|
379
|
+
},
|
|
380
|
+
h('div', { style: { marginBottom: 18 } },
|
|
381
|
+
h('h2', { style: { margin: '0 0 5px', fontSize: 18 } }, 'TA 的家'),
|
|
382
|
+
h('p', {
|
|
383
|
+
style: { margin: 0, fontSize: 12, lineHeight: 1.55, opacity: 0.64 },
|
|
384
|
+
}, '身份、记忆、辖区与夜间回顾。保存会写入当前 profile;配置字段即时生效。')),
|
|
385
|
+
|
|
386
|
+
state === 'error' ? h('div', {
|
|
387
|
+
role: 'alert',
|
|
388
|
+
style: {
|
|
389
|
+
marginBottom: 14,
|
|
390
|
+
padding: '9px 11px',
|
|
391
|
+
border: '1px solid var(--dsw-alias-state-error-primary, rgba(220,80,80,.35))',
|
|
392
|
+
borderRadius: 8,
|
|
393
|
+
color: 'var(--dsw-alias-state-error-primary, #c44)',
|
|
394
|
+
fontSize: 12,
|
|
395
|
+
lineHeight: 1.45,
|
|
396
|
+
},
|
|
397
|
+
}, message || '配置不可用') : null,
|
|
398
|
+
|
|
399
|
+
h(Section, { title: '位置' },
|
|
400
|
+
h(Field, { label: 'Ta 的家', hint: '必须与 ta / ta-review 会话的工作目录一致。' },
|
|
401
|
+
text('taHome', '~/TATA/home')),
|
|
402
|
+
h(Field, { label: 'ReMe 地址', hint: '建议只指向本机回环地址;capture 会把对话写入这里。' },
|
|
403
|
+
text('remeEndpoint', 'http://127.0.0.1:2333'))),
|
|
404
|
+
|
|
405
|
+
h(Section, { title: '记忆与辖区' },
|
|
406
|
+
h(Field, { label: '只读辖区', hint: '每行一个根目录;不能填 / 或 ~。' },
|
|
407
|
+
h('textarea', {
|
|
408
|
+
style: { ...inputStyle, minHeight: 64, resize: 'vertical', lineHeight: 1.5 },
|
|
409
|
+
value: jurisdictionText,
|
|
410
|
+
disabled,
|
|
411
|
+
onChange: event => {
|
|
412
|
+
editing.current = true
|
|
413
|
+
setJurisdictionText(event.target.value)
|
|
414
|
+
setMessage('')
|
|
415
|
+
setState(previous => previous === 'error' ? 'ready' : previous)
|
|
416
|
+
},
|
|
417
|
+
})),
|
|
418
|
+
h(Toggle, {
|
|
419
|
+
label: '捕获完成的聊天',
|
|
420
|
+
hint: '关闭后不把日常对话送入长期记忆。',
|
|
421
|
+
checked: draft.captureEnabled,
|
|
422
|
+
disabled,
|
|
423
|
+
onChange: value => update('captureEnabled', value),
|
|
424
|
+
}),
|
|
425
|
+
h(Field, { label: '每几轮封一批', hint: '1–60。' },
|
|
426
|
+
number('captureInterval', 1, 60))),
|
|
427
|
+
|
|
428
|
+
h(Section, { title: '夜间回顾' },
|
|
429
|
+
h(Toggle, {
|
|
430
|
+
label: '22:30 ReMe 整理',
|
|
431
|
+
checked: draft.dreamEnabled,
|
|
432
|
+
disabled,
|
|
433
|
+
onChange: value => update('dreamEnabled', value),
|
|
434
|
+
}),
|
|
435
|
+
h(Toggle, {
|
|
436
|
+
label: '02:00 清理旧出门记录',
|
|
437
|
+
checked: draft.outingCleanupEnabled,
|
|
438
|
+
disabled,
|
|
439
|
+
onChange: value => update('outingCleanupEnabled', value),
|
|
440
|
+
}),
|
|
441
|
+
h(Toggle, {
|
|
442
|
+
label: '22:45 辖区人格化查看',
|
|
443
|
+
hint: '由 Ta 自己读当天文件和对话,写一份辖区出门记录,供回顾使用。',
|
|
444
|
+
checked: draft.jurisdictionOutingEnabled,
|
|
445
|
+
disabled,
|
|
446
|
+
onChange: value => update('jurisdictionOutingEnabled', value),
|
|
447
|
+
}),
|
|
448
|
+
h(Field, { label: '辖区查看时间', hint: '24 小时制,例如 22:45。' },
|
|
449
|
+
text('jurisdictionOutingTime', '22:45')),
|
|
450
|
+
h(Field, { label: '时区' },
|
|
451
|
+
text('timezone', 'Asia/Shanghai'))),
|
|
452
|
+
|
|
453
|
+
h(Section, { title: '主动消息' },
|
|
454
|
+
h(Toggle, {
|
|
455
|
+
label: '启用心跳',
|
|
456
|
+
hint: '默认关闭。开启后只在活跃时段、inbox 非空时创建 life 会话。',
|
|
457
|
+
checked: draft.heartbeatEnabled,
|
|
458
|
+
disabled,
|
|
459
|
+
onChange: value => update('heartbeatEnabled', value),
|
|
460
|
+
}),
|
|
461
|
+
h(Field, { label: '活跃开始' }, text('heartbeatActiveStart', '08:00')),
|
|
462
|
+
h(Field, { label: '活跃结束' }, text('heartbeatActiveEnd', '23:00'))),
|
|
463
|
+
|
|
464
|
+
h('div', { style: { display: 'flex', alignItems: 'center', gap: 9, marginTop: 18 } },
|
|
465
|
+
h('button', {
|
|
466
|
+
type: 'button',
|
|
467
|
+
onClick: save,
|
|
468
|
+
disabled: disabled,
|
|
469
|
+
style: {
|
|
470
|
+
padding: '7px 14px',
|
|
471
|
+
border: 0,
|
|
472
|
+
borderRadius: 7,
|
|
473
|
+
background: 'var(--dsw-alias-button-primary-fill, var(--dsw-alias-brand-primary, #4d6bfe))',
|
|
474
|
+
color: 'var(--dsw-alias-label-primary-foreground, #fff)',
|
|
475
|
+
font: 'inherit',
|
|
476
|
+
fontSize: 12,
|
|
477
|
+
fontWeight: 600,
|
|
478
|
+
cursor: disabled ? 'default' : 'pointer',
|
|
479
|
+
opacity: disabled ? 0.55 : 1,
|
|
480
|
+
},
|
|
481
|
+
}, state === 'saving' ? '保存中…' : '保存'),
|
|
482
|
+
h('button', {
|
|
483
|
+
type: 'button',
|
|
484
|
+
onClick: reset,
|
|
485
|
+
disabled,
|
|
486
|
+
style: {
|
|
487
|
+
padding: '7px 12px',
|
|
488
|
+
border: '1px solid var(--dsw-alias-border-l1, rgba(127,127,127,.28))',
|
|
489
|
+
borderRadius: 7,
|
|
490
|
+
background: 'transparent',
|
|
491
|
+
color: 'inherit',
|
|
492
|
+
font: 'inherit',
|
|
493
|
+
fontSize: 12,
|
|
494
|
+
cursor: disabled ? 'default' : 'pointer',
|
|
495
|
+
},
|
|
496
|
+
}, '还原修改'),
|
|
497
|
+
(message || dirty) ? h('span', {
|
|
498
|
+
role: 'status',
|
|
499
|
+
'aria-live': 'polite',
|
|
500
|
+
style: { fontSize: 11, opacity: 0.65 },
|
|
501
|
+
}, message || '有未保存修改') : null))
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
function TaIcon({ size, active }) {
|
|
505
|
+
return h('svg', {
|
|
506
|
+
'aria-hidden': true,
|
|
507
|
+
viewBox: '0 0 24 24',
|
|
508
|
+
width: size,
|
|
509
|
+
height: size,
|
|
510
|
+
fill: 'none',
|
|
511
|
+
stroke: 'currentColor',
|
|
512
|
+
strokeWidth: 1.9,
|
|
513
|
+
strokeLinecap: 'round',
|
|
514
|
+
strokeLinejoin: 'round',
|
|
515
|
+
style: { opacity: active ? 1 : 0.82, display: 'block' },
|
|
516
|
+
},
|
|
517
|
+
h('path', { d: 'M4.5 20.5h15' }),
|
|
518
|
+
h('path', { d: 'M6 20.5V9.5L12 4.5l6 5v11' }),
|
|
519
|
+
h('path', { d: 'M12 9.2l.65 1.8 1.8.65-1.8.65-.65 1.8-.65-1.8-1.8-.65 1.8-.65z', strokeWidth: 1.4 }))
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
ctx.slots.inject('sidebar.footer.action', () => ctx.slots.register({
|
|
523
|
+
name: 'sidebar.footer.action',
|
|
524
|
+
id: 'dsh-ta-entry',
|
|
525
|
+
order: 20,
|
|
526
|
+
label: '去找Ta',
|
|
527
|
+
}, TaEntry))
|
|
528
|
+
|
|
529
|
+
ctx.slots.inject('settings.section', () => ctx.slots.register({
|
|
530
|
+
name: 'settings.section',
|
|
531
|
+
id: 'dsh-ta',
|
|
532
|
+
order: 30,
|
|
533
|
+
label: () => 'TA 的家',
|
|
534
|
+
}, TaSettings))
|
|
535
|
+
|
|
536
|
+
ctx.slots.inject('settings.section.icon', () => ctx.slots.register({
|
|
537
|
+
name: 'settings.section.icon',
|
|
538
|
+
id: 'dsh-ta',
|
|
539
|
+
order: 30,
|
|
540
|
+
label: () => 'TA 的家',
|
|
541
|
+
}, TaIcon))
|
|
542
|
+
},
|
|
543
|
+
}
|
|
544
|
+
},
|
|
545
|
+
})
|
package/cordis.patch.yml
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
- insert:
|
|
2
|
+
- id: dsh-ta
|
|
3
|
+
name: dsh-ta
|
|
4
|
+
config:
|
|
5
|
+
taHome: "~/TATA/home"
|
|
6
|
+
remeEndpoint: http://127.0.0.1:2333
|
|
7
|
+
presets:
|
|
8
|
+
- ta
|
|
9
|
+
- ta-review
|
|
10
|
+
permissionPreset: read-only
|
|
11
|
+
captureEnabled: true
|
|
12
|
+
captureInterval: 5
|
|
13
|
+
timezone: Asia/Shanghai
|
|
14
|
+
heartbeatEnabled: false
|
|
15
|
+
jurisdictions:
|
|
16
|
+
- "~/dsh"
|
|
17
|
+
- id: preset-ta
|
|
18
|
+
name: "@deepseek-ai/dsh-agent-preset"
|
|
19
|
+
config:
|
|
20
|
+
id: ta
|
|
21
|
+
name: "TA"
|
|
22
|
+
description: "Persistent personal assistant preset. Read-only tools and no shell."
|
|
23
|
+
order: 9
|
|
24
|
+
plugins:
|
|
25
|
+
- id: time-context
|
|
26
|
+
name: "@deepseek-ai/dsh-time-context"
|
|
27
|
+
- id: agent-instructions
|
|
28
|
+
name: "@deepseek-ai/dsh-agent-instructions"
|
|
29
|
+
config:
|
|
30
|
+
maxBytes: 65536
|
|
31
|
+
- id: tool-fs
|
|
32
|
+
name: "@deepseek-ai/dsh-tool-fs"
|
|
33
|
+
config:
|
|
34
|
+
read: true
|
|
35
|
+
readImage: true
|
|
36
|
+
write: false
|
|
37
|
+
edit: false
|
|
38
|
+
- id: tool-fs-search
|
|
39
|
+
name: "@deepseek-ai/dsh-tool-fs-search"
|
|
40
|
+
config:
|
|
41
|
+
sampleOverCapGlobResults: false
|
|
42
|
+
- id: tool-web
|
|
43
|
+
name: "@deepseek-ai/dsh-tool-web"
|
|
44
|
+
- id: tool-ask-user
|
|
45
|
+
name: "@deepseek-ai/dsh-tool-ask-user"
|
|
46
|
+
- id: tool-todo
|
|
47
|
+
name: "@deepseek-ai/dsh-tool-todo"
|
|
48
|
+
config:
|
|
49
|
+
allowParallelInProgress: false
|
|
50
|
+
- id: compaction
|
|
51
|
+
name: cordis:group
|
|
52
|
+
group: true
|
|
53
|
+
isolate:
|
|
54
|
+
compaction: true
|
|
55
|
+
toolResultPruner: true
|
|
56
|
+
config:
|
|
57
|
+
- id: compaction-basic
|
|
58
|
+
name: "@deepseek-ai/dsh-compaction-basic"
|
|
59
|
+
- id: command-compact
|
|
60
|
+
name: "@deepseek-ai/dsh-command-compact"
|
|
61
|
+
- id: tool-result-pruner
|
|
62
|
+
name: "@deepseek-ai/dsh-compaction-tool-result-pruner"
|
|
63
|
+
|
|
64
|
+
- id: preset-ta-review
|
|
65
|
+
name: "@deepseek-ai/dsh-agent-preset"
|
|
66
|
+
config:
|
|
67
|
+
id: ta-review
|
|
68
|
+
name: "TA Review"
|
|
69
|
+
description: "Nightly review preset. Read-only files and controlled review write tools."
|
|
70
|
+
order: 10
|
|
71
|
+
plugins:
|
|
72
|
+
- id: time-context
|
|
73
|
+
name: "@deepseek-ai/dsh-time-context"
|
|
74
|
+
- id: agent-instructions
|
|
75
|
+
name: "@deepseek-ai/dsh-agent-instructions"
|
|
76
|
+
config:
|
|
77
|
+
maxBytes: 65536
|
|
78
|
+
- id: tool-fs
|
|
79
|
+
name: "@deepseek-ai/dsh-tool-fs"
|
|
80
|
+
config:
|
|
81
|
+
read: true
|
|
82
|
+
readImage: true
|
|
83
|
+
write: false
|
|
84
|
+
edit: false
|
|
85
|
+
- id: tool-fs-search
|
|
86
|
+
name: "@deepseek-ai/dsh-tool-fs-search"
|
|
87
|
+
config:
|
|
88
|
+
sampleOverCapGlobResults: false
|
|
89
|
+
- id: compaction
|
|
90
|
+
name: cordis:group
|
|
91
|
+
group: true
|
|
92
|
+
isolate:
|
|
93
|
+
compaction: true
|
|
94
|
+
toolResultPruner: true
|
|
95
|
+
config:
|
|
96
|
+
- id: compaction-basic
|
|
97
|
+
name: "@deepseek-ai/dsh-compaction-basic"
|
|
98
|
+
- id: command-compact
|
|
99
|
+
name: "@deepseek-ai/dsh-command-compact"
|
|
100
|
+
- id: tool-result-pruner
|
|
101
|
+
name: "@deepseek-ai/dsh-compaction-tool-result-pruner"
|