@hyprnos/dsh-remote-plugin 0.0.0-stage → 0.8.8

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.
Files changed (210) hide show
  1. package/README.en.md +61 -0
  2. package/README.md +60 -2
  3. package/apk/dsh-remote.apk +0 -0
  4. package/approval-summary.mjs +115 -0
  5. package/client.js +197 -0
  6. package/cordis.patch.yml +5 -0
  7. package/doctor-skill.mjs +99 -0
  8. package/doctor-target.mjs +24 -0
  9. package/file-delivery.mjs +84 -0
  10. package/gateway-stats.cjs +501 -0
  11. package/gateway.cjs +8451 -0
  12. package/index.mjs +1784 -0
  13. package/insights.mjs +111 -0
  14. package/market.mjs +86 -0
  15. package/package.json +71 -4
  16. package/peak-reminders.mjs +50 -0
  17. package/plugin-center.mjs +777 -0
  18. package/plugin-transaction.mjs +300 -0
  19. package/public/activity.js +188 -0
  20. package/public/admin.html +820 -0
  21. package/public/admin.js +1167 -0
  22. package/public/announcement-forms.js +89 -0
  23. package/public/announcements.json +464 -0
  24. package/public/app.js +8826 -0
  25. package/public/approval-records.js +301 -0
  26. package/public/approval-summary.js +78 -0
  27. package/public/build.json +5 -0
  28. package/public/cache-upgrade.js +51 -0
  29. package/public/chat-copy.js +59 -0
  30. package/public/chat-files.js +87 -0
  31. package/public/desktop/desktop.css +816 -0
  32. package/public/desktop/desktop.html +871 -0
  33. package/public/desktop/desktop.js +4548 -0
  34. package/public/desktop/i18n.js +85 -0
  35. package/public/diagnostics.js +203 -0
  36. package/public/doctor-entry.js +94 -0
  37. package/public/doctor.css +205 -0
  38. package/public/doctor.js +769 -0
  39. package/public/donate.png +0 -0
  40. package/public/e2ee-transport.js +219 -0
  41. package/public/extensions.css +109 -0
  42. package/public/extensions.js +215 -0
  43. package/public/file-inbox.css +66 -0
  44. package/public/file-inbox.js +289 -0
  45. package/public/genui.css +8 -0
  46. package/public/genui.js +254 -0
  47. package/public/history.js +304 -0
  48. package/public/i18n.js +57 -0
  49. package/public/icon.svg +12 -0
  50. package/public/image-cache.js +141 -0
  51. package/public/image-preview.js +290 -0
  52. package/public/index.html +1548 -0
  53. package/public/insights.css +28 -0
  54. package/public/insights.js +290 -0
  55. package/public/jsqr.min.js +10104 -0
  56. package/public/lan-discovery.js +94 -0
  57. package/public/link-check.js +109 -0
  58. package/public/manifest.webmanifest +16 -0
  59. package/public/md.js +333 -0
  60. package/public/morphicons-init.js +41 -0
  61. package/public/motion.js +557 -0
  62. package/public/network.js +100 -0
  63. package/public/onboarding.css +36 -0
  64. package/public/onboarding.js +253 -0
  65. package/public/operations.js +141 -0
  66. package/public/permission-presets.js +159 -0
  67. package/public/plugin-center.css +120 -0
  68. package/public/plugin-center.js +666 -0
  69. package/public/plugin-icon.svg +5 -0
  70. package/public/plugin.html +68 -0
  71. package/public/plugin.js +211 -0
  72. package/public/qrcode.min.js +2297 -0
  73. package/public/relay-autopair.js +251 -0
  74. package/public/relay-devices.js +80 -0
  75. package/public/relay-settings.css +24 -0
  76. package/public/relay-settings.js +194 -0
  77. package/public/remote-state.js +27 -0
  78. package/public/remote-ui.css +148 -0
  79. package/public/remote-ui.js +243 -0
  80. package/public/session-deck.css +79 -0
  81. package/public/session-deck.js +180 -0
  82. package/public/session-presets.js +47 -0
  83. package/public/setup.css +18 -0
  84. package/public/setup.js +213 -0
  85. package/public/sha256.js +119 -0
  86. package/public/skills.css +81 -0
  87. package/public/skills.js +202 -0
  88. package/public/skins/blue-fish/DESIGN.md +24 -0
  89. package/public/skins/blue-fish/face.png +0 -0
  90. package/public/skins/blue-fish/icon-blush.png +0 -0
  91. package/public/skins/blue-fish/icon-sleep.png +0 -0
  92. package/public/skins/blue-fish/icon-smile.png +0 -0
  93. package/public/skins/blue-fish/icon-star.png +0 -0
  94. package/public/skins/blue-fish/icon-wink.png +0 -0
  95. package/public/skins/blue-fish/icon.png +0 -0
  96. package/public/skins/blue-fish/mascot.png +0 -0
  97. package/public/skins/blue-fish/pattern.png +0 -0
  98. package/public/skins/blue-fish/preview.html +12 -0
  99. package/public/skins/blue-fish/skin.css +122 -0
  100. package/public/skins/blue-fish/sparkles.svg +18 -0
  101. package/public/skins/bocchi/DESIGN.md +99 -0
  102. package/public/skins/bocchi/face.png +0 -0
  103. package/public/skins/bocchi/grain.png +0 -0
  104. package/public/skins/bocchi/icon-blush.png +0 -0
  105. package/public/skins/bocchi/icon-sleep.png +0 -0
  106. package/public/skins/bocchi/icon-smile.png +0 -0
  107. package/public/skins/bocchi/icon-star.png +0 -0
  108. package/public/skins/bocchi/icon-wink.png +0 -0
  109. package/public/skins/bocchi/icon.png +0 -0
  110. package/public/skins/bocchi/pattern-soft.png +0 -0
  111. package/public/skins/bocchi/pattern.png +0 -0
  112. package/public/skins/bocchi/preview.html +55 -0
  113. package/public/skins/bocchi/skin.css +233 -0
  114. package/public/skins/bocchi/stage-bg.png +0 -0
  115. package/public/skins/bocchi/stage-soft.png +0 -0
  116. package/public/skins/bocchi/stand.png +0 -0
  117. package/public/skins/bocchi/sticker-guitar.png +0 -0
  118. package/public/skins/kessoku/DESIGN.md +38 -0
  119. package/public/skins/kessoku/grain.png +0 -0
  120. package/public/skins/kessoku/skin.css +212 -0
  121. package/public/skins/kita/SOURCES.json +51 -0
  122. package/public/skins/kita/face.png +0 -0
  123. package/public/skins/kita/icon-live.png +0 -0
  124. package/public/skins/kita/icon-reddress.png +0 -0
  125. package/public/skins/kita/icon-seifuku.png +0 -0
  126. package/public/skins/kita/pattern.png +0 -0
  127. package/public/skins/kita/preview.html +56 -0
  128. package/public/skins/kita/skin.css +26 -0
  129. package/public/skins/kita/stand.png +0 -0
  130. package/public/skins/kita/sticker-live.png +0 -0
  131. package/public/skins/nijika/SOURCES.json +51 -0
  132. package/public/skins/nijika/face.png +0 -0
  133. package/public/skins/nijika/icon-live.png +0 -0
  134. package/public/skins/nijika/icon-reddress.png +0 -0
  135. package/public/skins/nijika/icon-seifuku.png +0 -0
  136. package/public/skins/nijika/pattern.png +0 -0
  137. package/public/skins/nijika/preview.html +56 -0
  138. package/public/skins/nijika/skin.css +25 -0
  139. package/public/skins/nijika/stand.png +0 -0
  140. package/public/skins/nijika/sticker-live.png +0 -0
  141. package/public/skins/penguin/DESIGN.md +33 -0
  142. package/public/skins/penguin/SOURCES.json +22 -0
  143. package/public/skins/penguin/aic-blueprint.svg +24 -0
  144. package/public/skins/penguin/endfield-triangles.svg +4 -0
  145. package/public/skins/penguin/face.png +0 -0
  146. package/public/skins/penguin/icon-blush.png +0 -0
  147. package/public/skins/penguin/icon-dizzy.png +0 -0
  148. package/public/skins/penguin/icon-laugh.png +0 -0
  149. package/public/skins/penguin/icon-sleep.png +0 -0
  150. package/public/skins/penguin/icon-smile.png +0 -0
  151. package/public/skins/penguin/icon-star.png +0 -0
  152. package/public/skins/penguin/icon-wink.png +0 -0
  153. package/public/skins/penguin/icon.png +0 -0
  154. package/public/skins/penguin/mascot.png +0 -0
  155. package/public/skins/penguin/pattern-night.png +0 -0
  156. package/public/skins/penguin/pattern.png +0 -0
  157. package/public/skins/penguin/preview.html +12 -0
  158. package/public/skins/penguin/skin.css +212 -0
  159. package/public/skins/ryo/SOURCES.json +51 -0
  160. package/public/skins/ryo/face.png +0 -0
  161. package/public/skins/ryo/icon-live.png +0 -0
  162. package/public/skins/ryo/icon-reddress.png +0 -0
  163. package/public/skins/ryo/icon-seifuku.png +0 -0
  164. package/public/skins/ryo/pattern.png +0 -0
  165. package/public/skins/ryo/preview.html +56 -0
  166. package/public/skins/ryo/skin.css +25 -0
  167. package/public/skins/ryo/stand.png +0 -0
  168. package/public/skins/ryo/sticker-live.png +0 -0
  169. package/public/sponsor-entry.js +21 -0
  170. package/public/styles.css +1494 -0
  171. package/public/subagents.css +61 -0
  172. package/public/subagents.js +275 -0
  173. package/public/task-board.js +109 -0
  174. package/public/teams.js +98 -0
  175. package/public/theme-picker.css +58 -0
  176. package/public/theme-vars.css +1044 -0
  177. package/public/theme.js +166 -0
  178. package/public/transcribe-core.js +74 -0
  179. package/public/turn-results.js +121 -0
  180. package/public/update.json +49 -0
  181. package/public/vendor/gsap/NOTICE.md +10 -0
  182. package/public/vendor/gsap/gsap.min.js +11 -0
  183. package/public/vendor/morphicons/LICENSE +21 -0
  184. package/public/vendor/morphicons/README.md +10 -0
  185. package/public/vendor/morphicons/controller-CXZuwJ_M.js +152 -0
  186. package/public/vendor/morphicons/dom.js +206 -0
  187. package/public/vendor/morphicons/element.js +261 -0
  188. package/public/vendor/morphicons/normalize-CYnN3Npw.js +540 -0
  189. package/public/vendor/morphicons/spring-CFHloqPP.js +623 -0
  190. package/public/version.json +3 -0
  191. package/public/voice-input.js +739 -0
  192. package/public/workflow.css +365 -0
  193. package/public/workflow.js +409 -0
  194. package/session-file.mjs +39 -0
  195. package/skills/dsh-remote-doctor/SKILL.md +186 -0
  196. package/skills/dsh-remote-doctor/references/wiki/README.md +40 -0
  197. package/skills/dsh-remote-doctor/references/wiki/ai-guide.md +61 -0
  198. package/skills/dsh-remote-doctor/references/wiki/connection.md +76 -0
  199. package/skills/dsh-remote-doctor/references/wiki/errors.md +26 -0
  200. package/skills/dsh-remote-doctor/references/wiki/evidence.md +44 -0
  201. package/skills/dsh-remote-doctor/references/wiki/files.md +31 -0
  202. package/skills/dsh-remote-doctor/references/wiki/maintenance.md +30 -0
  203. package/skills/dsh-remote-doctor/references/wiki/notifications.md +33 -0
  204. package/skills/dsh-remote-doctor/references/wiki/operations.md +32 -0
  205. package/skills/dsh-remote-doctor/references/wiki/plugins.md +90 -0
  206. package/skills/dsh-remote-doctor/references/wiki/sessions.md +45 -0
  207. package/skills/dsh-remote-doctor/references/wiki/sources.md +27 -0
  208. package/skills.mjs +53 -0
  209. package/task-board.mjs +57 -0
  210. package/teams.mjs +58 -0
@@ -0,0 +1,300 @@
1
+ /* Bounded pnpm policy inspection and recoverable profile snapshots. Built-ins only. */
2
+ import { readFileSync, existsSync, writeFileSync, renameSync, unlinkSync, readdirSync, lstatSync, readlinkSync, realpathSync } from 'node:fs'
3
+ import { cp } from 'node:fs/promises'
4
+ import { join, resolve, relative, isAbsolute, dirname } from 'node:path'
5
+ import { createHash } from 'node:crypto'
6
+ const pkgName = /^(?:@[a-z0-9][a-z0-9._-]*\/)?[a-z0-9][a-z0-9._-]*$/
7
+ const semver = /^\d+\.\d+\.\d+(?:-[a-zA-Z0-9.-]+)?(?:\+[a-zA-Z0-9.-]+)?$/
8
+ export const controlFiles = ['package.json', 'pnpm-lock.yaml', 'pnpm-workspace.yaml', 'cordis.patch.yml', 'cordis.yml', '.npmrc', '.remote-plugin-center/disabled.json']
9
+ const error = message => Object.assign(new Error(message), { status: 409 })
10
+ // Windows can temporarily refuse replacement while a reader holds the target.
11
+ // The manager polls these ledger files, so a short bounded retry is
12
+ // safe: only the metadata rename is repeated, never an install command or any
13
+ // other result-uncertain write.
14
+ const retryCell = new Int32Array(new SharedArrayBuffer(4))
15
+ export function replaceFile(tmp, file) {
16
+ for (let attempt = 0; ; attempt++) {
17
+ try { return renameSync(tmp, file) }
18
+ catch (failure) {
19
+ if (!['EPERM', 'EACCES', 'EBUSY'].includes(failure.code) || attempt >= 20) throw failure
20
+ Atomics.wait(retryCell, 0, 0, 10)
21
+ }
22
+ }
23
+ }
24
+ const text = file => existsSync(file) ? readFileSync(file, 'utf8') : null
25
+ const hash = value => createHash('sha256').update(value).digest('hex')
26
+ export function profileRevision(dir) { return hash(JSON.stringify(controlFiles.map(name => [name, text(join(dir, name))]))) }
27
+ function scalar(raw) {
28
+ const value = raw.trim()
29
+ if (value.startsWith('"')) { try { return JSON.parse(value) } catch { throw error('无法安全解析配置,请在主机检查 YAML 引号。') } }
30
+ if (value.startsWith("'")) {
31
+ if (!value.endsWith("'")) throw error('无法安全解析 YAML 字符串。')
32
+ return value.slice(1, -1).replaceAll("''", "'")
33
+ }
34
+ if (/[\[\]{}&*!>]/.test(value) || /(^|\s)\|(?!\|)/.test(value)) throw error('此配置使用复杂 YAML 语法,请在主机处理后重试。')
35
+ return value.replace(/\s+#.*$/, '').trim()
36
+ }
37
+ function section(raw, key) {
38
+ const lines = (raw || '').split(/\r?\n/), indexes = []
39
+ if (lines.some(line => line.startsWith("'" + key + "':") || line.startsWith('"' + key + '":') || /^<<:/.test(line))) throw error('暂不支持带引号的策略字段或 YAML 合并键,请在主机统一配置后重试。')
40
+ for (let i = 0; i < lines.length; i++) if (lines[i].startsWith(key + ':')) indexes.push(i)
41
+ if (indexes.length > 1) throw error('配置存在重复字段 ' + key + ',请在主机检查。')
42
+ const start = indexes[0] ?? -1
43
+ let end = start + 1
44
+ if (start >= 0) while (end < lines.length && (!lines[end].trim() || /^\s|^#/.test(lines[end]))) end++
45
+ return { lines, start, end, inline: start < 0 ? '' : lines[start].slice(key.length + 1).replace(/\s+#.*$/, '').trim() }
46
+ }
47
+ export function releasePolicy(raw, env = process.env, npmrc = '') {
48
+ const age = section(raw, 'minimumReleaseAge'), excluded = section(raw, 'minimumReleaseAgeExclude')
49
+ if (/^\s*(?:minimum-release-age|minimumReleaseAge)(?:-exclude|Exclude)?(?:\[\])?\s*=/mi.test(npmrc) || Object.keys(env).some(key => /^npm_config_minimum_release_age/i.test(key))) {
50
+ throw error('发布年龄策略由 .npmrc 或环境变量设置,请在主机统一到当前 profile 的 pnpm-workspace.yaml 后重试。')
51
+ }
52
+ const minutes = age.start < 0 ? 1440 : Number(age.inline)
53
+ if (!Number.isSafeInteger(minutes) || minutes < 0 || age.start >= 0 && !/^\d+$/.test(age.inline)) throw error('minimumReleaseAge 必须为非负整数分钟。')
54
+ let rules = []
55
+ if (excluded.start >= 0) {
56
+ if (excluded.inline) {
57
+ try { rules = JSON.parse(excluded.inline) } catch { throw error('请将 minimumReleaseAgeExclude 改为标准 YAML 列表后重试。') }
58
+ if (!Array.isArray(rules)) throw error('发布年龄豁免必须为列表。')
59
+ } else {
60
+ for (const line of excluded.lines.slice(excluded.start + 1, excluded.end)) {
61
+ if (!line.trim() || /^\s*#/.test(line)) continue
62
+ const match = /^\s+-\s+(.+)$/.exec(line)
63
+ if (!match) throw error('无法安全解析发布年龄豁免列表。')
64
+ rules.push(scalar(match[1]))
65
+ }
66
+ }
67
+ }
68
+ const entries = rules.map(rule => {
69
+ if (typeof rule !== 'string') throw error('发布年龄豁免必须为包名字符串。')
70
+ const at = rule.lastIndexOf('@'), name = at > 0 ? rule.slice(0, at) : rule
71
+ const versions = at > 0 ? rule.slice(at + 1).split(/\s*\|\|\s*/) : []
72
+ if (!pkgName.test(name) || versions.some(version => !semver.test(version))) throw error('存在通配或复杂豁免规则,请先在主机核对;Remote 只合并精确版本。')
73
+ return { name, versions }
74
+ })
75
+ return { minutes, entries }
76
+ }
77
+ export function mergeReleaseRules(raw, additions = []) {
78
+ const { entries } = releasePolicy(raw, {}, ''), grouped = new Map()
79
+ for (const entry of [...entries, ...additions.map(({ name, version }) => ({ name, versions: [version] }))]) {
80
+ if (!pkgName.test(entry.name) || entry.versions.some(version => !semver.test(version))) throw error('无效的精确版本豁免。')
81
+ const previous = grouped.get(entry.name)
82
+ if (previous && (!previous.length || !entry.versions.length)) {
83
+ if (previous.length !== entry.versions.length) throw error('同名包混用了全版本与精确版本豁免,请在主机核对。')
84
+ } else grouped.set(entry.name, [...new Set([...(previous || []), ...entry.versions])])
85
+ }
86
+ const rules = [...grouped].map(([name, versions]) => name + (versions.length ? '@' + versions.join(' || ') : ''))
87
+ const previous = entries.map(entry => entry.name + (entry.versions.length ? '@' + entry.versions.join(' || ') : ''))
88
+ if (JSON.stringify(rules) === JSON.stringify(previous)) return { raw, changes: [] }
89
+ const block = section(raw, 'minimumReleaseAgeExclude'), newline = raw?.includes('\r\n') ? '\r\n' : '\n'
90
+ const replacement = ['minimumReleaseAgeExclude:', ...rules.map(rule => ' - ' + JSON.stringify(rule))]
91
+ const lines = block.start < 0 ? [...block.lines.filter((line, i) => line || i < block.lines.length - 1), ...replacement] : [...block.lines.slice(0, block.start), ...replacement, ...block.lines.slice(block.end)]
92
+ return { raw: lines.join(newline).replace(/(?:\r?\n)*$/, newline), changes: rules.filter(rule => !previous.includes(rule)) }
93
+ }
94
+ function lockEntries(raw) {
95
+ if (!raw) return []
96
+ const block = section(raw, 'packages'), result = []
97
+ if (block.inline === '{}') return result
98
+ if (block.start < 0) throw error('锁文件缺少 packages 区段,请先在主机修复锁文件。')
99
+ const lines = block.lines.slice(block.start + 1, block.end)
100
+ for (let i = 0; i < lines.length; i++) {
101
+ const line = lines[i]
102
+ if (!/^ \S/.test(line)) continue
103
+ const match = /^ (.+):\s*(?:\{\})?\s*$/.exec(line)
104
+ if (!match) throw error('暂不支持此锁文件格式。')
105
+ const key = scalar(match[1]), identity = /^(\/?(?:@[^/]+\/)?[^/@]+)@([^()]+)(?:\(.*\))?$/.exec(key)
106
+ if (!identity || !pkgName.test(identity[1].replace(/^\//, ''))) throw error('锁文件包含不支持的包标识,请在主机检查:' + key.slice(0, 120))
107
+ const name = identity[1].replace(/^\//, ''), reference = identity[2]
108
+ if (reference.startsWith('file:')) {
109
+ let version = ''
110
+ for (let j = i + 1; j < lines.length && !/^ \S/.test(lines[j]); j++) {
111
+ const found = /^ version:\s*(.+)$/.exec(lines[j]); if (found) version = scalar(found[1])
112
+ }
113
+ if (!semver.test(version)) throw error('本地包的锁文件缺少可核验版本:' + name)
114
+ result.push({ name, version, reference })
115
+ } else {
116
+ if (!semver.test(reference)) throw error('锁文件包含非 registry 或旧格式条目,请在主机检查:' + key.slice(0, 120))
117
+ result.push({ name, version: reference })
118
+ }
119
+ }
120
+ if (result.length > 1200) throw error('锁文件超过自动预检范围,请在主机维护。')
121
+ return result
122
+ }
123
+ // Local tarballs have no registry release age, but retain their pinned version
124
+ // for the manifest/lockfile/installed-package consistency check below.
125
+ export function lockPackages(raw) { return lockEntries(raw).filter(row => !row.reference) }
126
+ export async function prepareReleasePlan(dir, operation, publishedTimes, env = process.env) {
127
+ const before = profileRevision(dir), workspace = text(join(dir, 'pnpm-workspace.yaml'))
128
+ let baselineWarning = ''
129
+ try { verifyInstalled(dir, operation) } catch (failure) { baselineWarning = failure.message }
130
+ const policy = releasePolicy(workspace, env, text(join(dir, '.npmrc')) || '')
131
+ const packages = lockPackages(text(join(dir, 'pnpm-lock.yaml')))
132
+ if (operation.version) packages.push({ name: operation.name, version: operation.version })
133
+ if (operation.action === 'update-all') packages.push(...operation.targets.map(({ name, version }) => ({ name, version })))
134
+ const pairs = [...new Map(packages.map(row => [row.name + '@' + row.version, row])).values()]
135
+ const blockers = [], now = Date.now(), names = [...new Set(pairs.map(row => row.name))]
136
+ let cursor = 0
137
+ // Give large lockfiles multiple request batches, within the client/proxy budget.
138
+ const budget = Math.min(120000, Math.max(20000, Math.ceil(names.length / 6) * 20000))
139
+ const controller = new AbortController(), timeout = setTimeout(() => controller.abort(), budget)
140
+ try { if (policy.minutes > 0) await Promise.all(Array.from({ length: Math.min(6, names.length) }, async () => {
141
+ while (cursor < names.length) {
142
+ if (controller.signal.aborted) throw error('发布时间预检超时,请重试;不会执行安装。')
143
+ const name = names[cursor++]
144
+ // Matching is deliberately first-name-wins, like pnpm, including dormant duplicates.
145
+ const first = policy.entries.find(rule => rule.name === name)
146
+ const checked = pairs.filter(row => row.name === name && !(first && (!first.versions.length || first.versions.includes(row.version))))
147
+ if (!checked.length) continue
148
+ const times = await publishedTimes(name, controller.signal, checked.map(row => row.version))
149
+ for (const row of checked) {
150
+ const at = Date.parse(times[row.version])
151
+ if (!Number.isFinite(at) || at > now + 60000) throw error('无法核实 ' + name + '@' + row.version + ' 的发布时间,未放行;请稍后重试。')
152
+ if (at + policy.minutes * 60000 > now) blockers.push({ ...row, publishedAt: new Date(at).toISOString(), eligibleAt: new Date(at + policy.minutes * 60000).toISOString() })
153
+ }
154
+ }
155
+ })) } catch (failure) {
156
+ const timedOut = controller.signal.aborted
157
+ controller.abort()
158
+ if (timedOut) throw error('发布时间预检超时(' + budget / 1000 + ' 秒,' + names.length + ' 个包),不会执行安装;请重试。')
159
+ throw failure
160
+ } finally { clearTimeout(timeout) }
161
+ blockers.sort((a, b) => (a.name + '@' + a.version).localeCompare(b.name + '@' + b.version))
162
+ const merged = mergeReleaseRules(workspace, blockers)
163
+ if (profileRevision(dir) !== before) throw error('预检期间主机配置已变化,请重新预检。')
164
+ return { revision: before, minutes: policy.minutes, blockers, ruleChanges: merged.changes, workspace: merged.raw, baselineWarning,
165
+ action: operation.action, name: operation.name, version: operation.version || '',
166
+ ...(operation.action === 'update-all' ? { targets: operation.targets } : {}), expiresAt: Date.now() + 10 * 60000 }
167
+ }
168
+ export function canonicalPath(value) {
169
+ let current = resolve(value)
170
+ const suffix = []
171
+ while (true) {
172
+ try { return join(realpathSync(current), ...suffix) }
173
+ catch (err) {
174
+ const parent = dirname(current)
175
+ if (!['ENOENT', 'ENOTDIR'].includes(err.code) || parent === current) throw err
176
+ suffix.unshift(current.slice(parent.length).replace(/^[\\/]+/, '')); current = parent
177
+ }
178
+ }
179
+ }
180
+ function inside(root, path) { const rel = relative(canonicalPath(root), canonicalPath(path)); if (isAbsolute(rel) || rel === '..' || rel.startsWith('..\\') || rel.startsWith('../')) throw error('快照路径越界。') }
181
+ export function treeDigest(root, { localRoot = join(dirname(root), 'local-plugins'), localSnapshotRoot = localRoot, linkIdentityRoot = root, linkedPaths } = {}) {
182
+ if (!existsSync(root)) return null
183
+ root = canonicalPath(root)
184
+ localRoot = localRoot && canonicalPath(localRoot)
185
+ localSnapshotRoot = localSnapshotRoot && canonicalPath(localSnapshotRoot)
186
+ linkIdentityRoot = canonicalPath(linkIdentityRoot)
187
+ const digest = createHash('sha256')
188
+ function walk(dir) {
189
+ for (const entry of readdirSync(dir).sort()) {
190
+ const file = join(dir, entry), info = lstatSync(file)
191
+ digest.update(relative(root, file).replaceAll('\\', '/') + '\0')
192
+ if (info.isSymbolicLink()) {
193
+ const target = canonicalPath(resolve(dirname(join(linkIdentityRoot, relative(root, file))), readlinkSync(file))), rel = relative(linkIdentityRoot, target)
194
+ if (isAbsolute(rel) || rel === '..' || rel.startsWith('..\\') || rel.startsWith('../')) {
195
+ // Desktop's bundled local plugins use junctions outside node_modules.
196
+ // Only the same profile's local-plugins is an allowed second root.
197
+ if (!localRoot || !localSnapshotRoot) throw error('快照路径越界:' + relative(root, file))
198
+ inside(localRoot, target)
199
+ const localPath = relative(resolve(localRoot), target), saved = join(localSnapshotRoot, localPath)
200
+ inside(localSnapshotRoot, realpathSync(saved))
201
+ if (!lstatSync(saved).isDirectory()) throw error('本地插件链接必须指向普通目录。')
202
+ linkedPaths?.add(localPath)
203
+ digest.update('local:' + localPath.replaceAll('\\', '/') + ':' + treeDigest(saved, { localRoot: null }))
204
+ } else inside(root, realpathSync(file))
205
+ digest.update('link:' + readlinkSync(file))
206
+ } else if (info.isDirectory()) { digest.update('dir'); walk(file) }
207
+ else if (info.isFile()) digest.update(readFileSync(file))
208
+ else throw error('插件目录包含不支持的文件类型。')
209
+ digest.update('\0')
210
+ }
211
+ }
212
+ walk(root); return digest.digest('hex')
213
+ }
214
+ export async function backupTransaction(dir, backup) {
215
+ inside(join(dir, '.remote-plugin-center'), backup)
216
+ const localRoot = join(dir, 'local-plugins'), localSnapshotRoot = join(backup, 'local-plugins'), linkedPaths = new Set()
217
+ const before = profileRevision(dir), modules = join(dir, 'node_modules'), installed = treeDigest(modules, { localRoot, linkedPaths })
218
+ const localInstalled = linkedPaths.size ? treeDigest(localRoot, { localRoot: null }) : null
219
+ if (localInstalled !== null) {
220
+ inside(dir, realpathSync(localRoot))
221
+ await cp(localRoot, localSnapshotRoot, { recursive: true, verbatimSymlinks: true, force: false, errorOnExist: true })
222
+ if (treeDigest(localSnapshotRoot, { localRoot: null }) !== localInstalled) throw error('本地插件备份校验失败,未执行安装。')
223
+ }
224
+ if (installed !== null) await cp(modules, join(backup, 'node_modules'), { recursive: true, verbatimSymlinks: true, force: false, errorOnExist: true })
225
+ if (installed !== null && treeDigest(join(backup, 'node_modules'), { localRoot, localSnapshotRoot, linkIdentityRoot: modules }) !== installed) throw error('备份包含不能独立恢复的链接,未执行安装。')
226
+ // Other control files were already copied by the worker; add absent-file facts.
227
+ const record = { files: Object.fromEntries(controlFiles.map(name => [name, text(join(dir, name))])), revision: before, installed, localInstalled }
228
+ if (profileRevision(dir) !== before || treeDigest(modules) !== installed || localInstalled !== null && treeDigest(localRoot, { localRoot: null }) !== localInstalled) throw error('备份期间插件文件或配置发生变化,尚未执行安装。')
229
+ writeFileSync(join(backup, 'transaction.json'), JSON.stringify(record), { mode: 0o600 })
230
+ return record
231
+ }
232
+ export function writeWorkspace(dir, raw) {
233
+ if (raw === null) return
234
+ const file = join(dir, 'pnpm-workspace.yaml'), tmp = file + '.remote-' + process.pid
235
+ writeFileSync(tmp, raw, { mode: 0o600 }); replaceFile(tmp, file)
236
+ }
237
+ export function verifyInstalled(dir, job) {
238
+ const manifest = JSON.parse(text(join(dir, 'package.json'))), raw = text(join(dir, 'pnpm-lock.yaml'))
239
+ if (!raw) throw error('安装后未生成锁文件,无法确认安装一致性。')
240
+ const importers = section(raw, 'importers'), root = importers.lines.slice(importers.start + 1, importers.end)
241
+ const refs = new Map(); let group = false, name = '', specifier = '', version = '', inRoot = false
242
+ const flush = () => { if (name) refs.set(name, { specifier, version: version.split('(')[0] }); name = ''; specifier = ''; version = '' }
243
+ for (const line of root) {
244
+ if (/^ \S/.test(line)) { flush(); inRoot = /^ (?:\.|'\.'|"\."):\s*$/.test(line); group = false; continue }
245
+ if (!inRoot) continue
246
+ if (/^ \S/.test(line)) { flush(); group = /^ (?:dependencies|devDependencies|optionalDependencies):\s*$/.test(line); continue }
247
+ if (!group) continue
248
+ const key = /^ (.+):\s*$/.exec(line)
249
+ if (key) { flush(); name = scalar(key[1]); continue }
250
+ const value = /^ (specifier|version):\s*(.+)$/.exec(line)
251
+ if (value?.[1] === 'specifier') specifier = scalar(value[2])
252
+ if (value?.[1] === 'version') version = scalar(value[2])
253
+ }
254
+ flush()
255
+ const all = { ...manifest.dependencies, ...manifest.devDependencies, ...manifest.optionalDependencies }
256
+ const localVersions = new Map(lockEntries(raw).filter(row => row.reference).map(row => [row.name + '@' + row.reference, row.version]))
257
+ for (const [name, requested] of Object.entries(all)) {
258
+ if (!pkgName.test(name)) throw error('配置存在无效的依赖包名。')
259
+ const ref = refs.get(name), file = join(dir, 'node_modules', ...name.split('/'), 'package.json')
260
+ const resolvedVersion = ref && (ref.version.startsWith('file:') ? localVersions.get(name + '@' + ref.version) : ref.version)
261
+ if (!ref || ref.specifier !== requested || !semver.test(resolvedVersion || '') || !existsSync(file) || JSON.parse(text(file)).version !== resolvedVersion) throw error('安装后配置、锁文件与插件文件不一致:' + name)
262
+ }
263
+ if ([...refs.keys()].some(name => !Object.hasOwn(all, name))) throw error('锁文件中仍有已移除的直接依赖。')
264
+ }
265
+ export async function restoreTransaction(dir, sourceBackup, failed, destination) {
266
+ inside(join(dir, '.remote-plugin-center'), sourceBackup); inside(join(dir, '.remote-plugin-center'), destination)
267
+ const record = JSON.parse(text(join(sourceBackup, 'transaction.json')))
268
+ const localRoot = join(dir, 'local-plugins'), localSnapshotRoot = join(sourceBackup, 'local-plugins')
269
+ const checkLocal = () => {
270
+ // Preserve the user's linked source directories. Never silently overwrite
271
+ // them, even if the package manager changed them during a failed install.
272
+ if (record.localInstalled != null && (treeDigest(localRoot, { localRoot: null }) !== record.localInstalled || treeDigest(localSnapshotRoot, { localRoot: null }) !== record.localInstalled)) throw error('本地插件源码或其备份已变化,不能自动恢复;请在主机核对 local-plugins 备份。')
273
+ }
274
+ checkLocal()
275
+ if (profileRevision(dir) !== failed.revision || treeDigest(join(dir, 'node_modules')) !== failed.installed) throw error('失败后插件文件或配置已有新改动,不能覆盖;请在主机核对备份。')
276
+ const source = join(sourceBackup, 'node_modules'), staged = join(destination, 'staged-node_modules'), current = join(dir, 'node_modules'), displaced = join(destination, 'failed-node_modules')
277
+ if (record.installed !== null) {
278
+ await cp(source, staged, { recursive: true, verbatimSymlinks: true, force: false, errorOnExist: true })
279
+ // Validate source links relative to source instead of accidentally following a new active tree.
280
+ if (treeDigest(source, { localRoot, localSnapshotRoot, linkIdentityRoot: current }) !== record.installed || treeDigest(staged, { localRoot, linkIdentityRoot: current }) !== record.installed) throw error('恢复备份校验失败,未替换插件。')
281
+ }
282
+ checkLocal()
283
+ if (profileRevision(dir) !== failed.revision || treeDigest(current) !== failed.installed) throw error('准备恢复时主机状态发生变化,已停止。')
284
+ const previousFiles = Object.fromEntries(controlFiles.map(name => [name, text(join(dir, name))]))
285
+ let moved = false, installed = false
286
+ const put = (name, value) => { const file = join(dir, name); if (value === null) { if (existsSync(file)) unlinkSync(file) } else { writeFileSync(file + '.remote-' + process.pid, value, { mode: 0o600 }); replaceFile(file + '.remote-' + process.pid, file) } }
287
+ try {
288
+ if (existsSync(current)) { renameSync(current, displaced); moved = true }
289
+ if (record.installed !== null) { renameSync(staged, current); installed = true }
290
+ for (const name of controlFiles) put(name, record.files[name])
291
+ if (profileRevision(dir) !== record.revision || treeDigest(current) !== record.installed) throw error('恢复后的文件校验未通过。')
292
+ } catch (failure) {
293
+ try {
294
+ if (installed) renameSync(current, join(destination, 'restore-attempt'))
295
+ if (moved) renameSync(displaced, current)
296
+ for (const name of controlFiles) put(name, previousFiles[name])
297
+ } catch { throw error('恢复过程中存在文件占用或写入失败,请退出 DSH 后在主机使用备份恢复;所有副本已保留。') }
298
+ throw failure
299
+ }
300
+ }
@@ -0,0 +1,188 @@
1
+ /* Compact, shared conversation activity. Durable events remain untouched. */
2
+ 'use strict';
3
+ ;(function(root){
4
+ const esc=value=>String(value??'').replace(/[&<>"']/g,char=>({'&':'&amp;','<':'&lt;','>':'&gt;','"':'&quot;',"'":'&#39;'}[char]))
5
+ const text=(zh,en)=>root.I18N?.lang==='en'?en:zh
6
+ // Test a copy only: joiners remain significant inside real words and emoji.
7
+ const hasVisibleText=value=>String(value??'').replace(/[\u200b-\u200d\u2060\ufeff]/g,'').trim().length>0
8
+ const json=value=>{try{return typeof value==='string'?value:JSON.stringify(value,null,2)??''}catch{return String(value)}}
9
+ const cut=(value,length)=>{const source=String(value??'');return source.length>length?source.slice(0,length)+'…':source}
10
+ const brief=value=>cut(String(value??'').replace(/\s+/g,' ').trim(),100)
11
+ const icon=kind=>`<svg class="activity-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="${kind==='reasoning'?'m12 3 2.4 6.6L21 12l-6.6 2.4L12 21l-2.4-6.6L3 12l6.6-2.4Z':'m8 7-5 5 5 5m8-10 5 5-5 5m-3-14-2 18'}"/></svg>`
12
+ function argumentHint(value){
13
+ if(typeof value==='string'){try{value=JSON.parse(value)}catch{return brief(value)}}
14
+ if(!value||typeof value!=='object')return ''
15
+ for(const key of ['description','command','cmd','path','file_path','pattern','query','url','line'])if(typeof value[key]==='string')return brief(value[key])
16
+ return ''
17
+ }
18
+ function shell(kind,key,title,hint,state,body,live=false,error=false){
19
+ return `<details class="chat-activity activity-${kind}${live?' is-live':''}${error?' is-error':''}" data-activity-key="${esc(key)}"><summary>${icon(kind)}<span class="activity-copy"><span class="activity-title">${esc(title)}</span>${hint?`<span class="activity-hint">${esc(hint)}</span>`:''}</span><span class="activity-state">${live?'<i aria-hidden="true"></i>':''}${esc(state)}</span><span class="activity-chevron" aria-hidden="true"></span></summary><div class="activity-body">${body}</div></details>`
20
+ }
21
+ function reasoning(value={}){
22
+ const source=String(value.text??'')
23
+ const hint=brief(source.split('\n').filter(line=>line.trim()).at(-1)||'')
24
+ return shell('reasoning',value.key,text(value.live?'思考中':'思考过程',value.live?'Thinking':'Reasoning'),hint,value.live?text('进行中','Live'):'',`<div class="activity-reasoning-text">${esc(cut(source,12000))}</div>`,!!value.live)
25
+ }
26
+ const errorOf=data=>!!(data?.error||data?.ok===false||data?.isError===true)
27
+ function tool(value={}){
28
+ const args=value.args,returned=Object.hasOwn(value,'result'),error=!!value.error
29
+ const section=(title,content)=>`<section><h4>${esc(title)}</h4><pre>${esc(cut(json(content),12000))}</pre></section>`
30
+ const translated=returned?root.DshApprovalRecords?.feedbackHtml(value.result):''
31
+ const body=(args===undefined?'':section(text('参数','Arguments'),args))+(returned?(translated||section(text('结果','Result'),value.result)):`<p class="activity-note">${esc(text('当前记录中尚无对应结果。','No matching result in the loaded history.'))}</p>`)
32
+ return shell('tool',value.key,value.name||text(returned?'工具结果':'工具调用',returned?'Tool result':'Tool call'),argumentHint(args),text(error?'返回错误':returned?'已返回':'已调用',error?'Error':returned?'Returned':'Called'),body,false,error)
33
+ }
34
+ const dataOf=entry=>entry.event?.data||{}
35
+ const callId=data=>data.callId||data.message?.source?.callId
36
+ const resultOf=data=>data.error??data.result??data.output??data.message??data.text??data.content??data
37
+ const pairs=new WeakMap()
38
+ function prepare(entries){
39
+ const pending=new Map(),matched=new Map(),consumed=new Set()
40
+ for(const entry of entries){
41
+ const data=dataOf(entry),id=callId(data)
42
+ if(!id)continue
43
+ if(entry.event?.type==='tool/call'){const queue=pending.get(id)||[];queue.push(entry);pending.set(id,queue)}
44
+ else if(entry.event?.type==='tool/result'){
45
+ const queue=pending.get(id)||[]
46
+ const index=queue.findLastIndex(call=>data.turn==null||dataOf(call).turn==null||data.turn===dataOf(call).turn)
47
+ if(index>=0){const [call]=queue.splice(index,1);matched.set(call,entry);consumed.add(entry)}
48
+ }
49
+ }
50
+ return entries.filter(entry=>!consumed.has(entry)).map(entry=>{
51
+ if(entry.event?.type!=='tool/call')return entry
52
+ const result=matched.get(entry)
53
+ if(!result)return entry
54
+ const cached=pairs.get(entry)
55
+ if(cached?.result===result)return cached.entry
56
+ const data=dataOf(entry),output=dataOf(result)
57
+ const next={...entry,view:{...entry.view,toolActivity:{key:'tool:'+entry.seq,name:data.name||data.toolName,args:data.arguments??data.args??data.input,result:resultOf(output),error:errorOf(output)}}}
58
+ pairs.set(entry,{result,entry:next});return next
59
+ })
60
+ }
61
+ function toolEvent(entry){
62
+ if(entry.view?.toolActivity)return tool(entry.view.toolActivity)
63
+ const data=dataOf(entry),isResult=entry.event?.type==='tool/result'
64
+ return tool({key:'tool:'+entry.seq,name:data.name||data.toolName||(isResult?text('工具结果','Tool result'):undefined),...(isResult?{result:resultOf(data),error:errorOf(data)}:{args:data.arguments??data.args??data.input})})
65
+ }
66
+ function reasoningKind(block){return block&&typeof block==='object'&&(block.type==='thinking'||block.type==='reasoning')}
67
+ function messageBlocks(entry){
68
+ const data=entry?.event?.data||{},message=data.message||{}
69
+ const blocks=Array.isArray(message.content)?message.content:(Array.isArray(data.content)?data.content:null)
70
+ return blocks?{data,message,blocks}:null
71
+ }
72
+ function stripReasoning(entry,rest){
73
+ const parts=messageBlocks(entry)
74
+ const data={...parts.data}
75
+ if(Array.isArray(parts.message.content))data.message={...parts.message,content:rest}
76
+ else data.content=rest
77
+ return {...entry,event:{...entry.event,data}}
78
+ }
79
+ /**
80
+ * Collapse a turn's process — every tool activity plus the reasoning blocks that would
81
+ * otherwise occupy a row inside each assistant message — into one disclosure.
82
+ * A user message starts a new turn; a turn without enough items keeps its original rows.
83
+ */
84
+ function group(entries){
85
+ const isTool=entry=>{const type=entry?.event?.type;return type==='tool/call'||type==='tool/result'}
86
+ // Only a human message starts a new turn; injected system-reminder user events do not.
87
+ const isTurnStart=entry=>{
88
+ if(entry?.event?.type!=='user/message')return false
89
+ const data=entry.event.data||{},source=data.source??data.message?.source
90
+ return !source||source.kind==='user'
91
+ }
92
+ const out=[]
93
+ const emit=segment=>{
94
+ const items=[],stripped=new Map()
95
+ for(const entry of segment){
96
+ if(isTool(entry)){items.push({kind:'tool',seq:entry.seq,entry});continue}
97
+ const parts=messageBlocks(entry)
98
+ if(!parts)continue
99
+ const reasoning=parts.blocks.filter(reasoningKind)
100
+ if(!reasoning.length)continue
101
+ const rest=parts.blocks.filter(block=>!reasoningKind(block))
102
+ const copy=stripReasoning(entry,rest)
103
+ // Tools and other block types can still carry content. Only text-only blanks
104
+ // are removed here; the block renderer decides whether tools are suppressed.
105
+ stripped.set(entry,{copy,empty:!rest.some(block=>block?.type!=='text'||hasVisibleText(block.text))})
106
+ reasoning.forEach((block,index)=>items.push({kind:'reasoning',seq:Number(entry.seq)+(index+1)/1000,text:String(block.text??block.content??''),key:'reasoning:'+entry.seq+':'+index}))
107
+ }
108
+ if(items.length>1){
109
+ let emitted=false
110
+ for(const entry of segment){
111
+ const decorated=stripped.get(entry)
112
+ if((isTool(entry)||decorated)&&!emitted){out.push({seq:items[0].seq,event:{type:'activity/group'},view:{activityGroup:{items}}});emitted=true}
113
+ if(isTool(entry))continue
114
+ if(decorated){if(!decorated.empty)out.push(decorated.copy);continue}
115
+ out.push(entry)
116
+ }
117
+ }else out.push(...segment)
118
+ }
119
+ let segment=[]
120
+ for(const entry of entries){
121
+ if(isTurnStart(entry)){emit(segment);segment=[];out.push(entry)}
122
+ else segment.push(entry)
123
+ }
124
+ emit(segment)
125
+ return out
126
+ }
127
+ function reasoningKey(data,index,fallback){return data?.turn!=null&&data?.step!=null?'reasoning:'+JSON.stringify([data.turn,data.step,index]):fallback}
128
+ function failure(event) {
129
+ if(event?.type==='turn/end' && event.data?.reason?.kind==='error')return event.data.reason.error
130
+ if(event?.type==='assistant/attempt') {
131
+ const stream=Array.isArray(event.data?.stream)?event.data.stream:[]
132
+ const finish=stream.findLast(record=>record.type==='chunk'&&record.chunk?.type==='finish')?.chunk
133
+ if(finish?.reason?.kind==='error')return finish.reason.failure
134
+ }
135
+ return null
136
+ }
137
+ function failureHtml(value,attempt=false) {
138
+ if(!value)return ''
139
+ const message=typeof value==='string'?value:value.message
140
+ const facts=[value.code,value.status?`HTTP ${value.status}`:''].filter(item=>typeof item==='string'&&item)
141
+ return `<div class="chat-runtime-error" role="status"><strong>${esc(text(attempt?'模型请求失败':'运行出错',attempt?'Model request failed':'Run failed'))}</strong><div>${esc(cut(message||text('主机未提供错误详情','The host did not provide error details'),4000))}</div>${facts.length?`<small>${esc(facts.join(' · '))}</small>`:''}</div>`
142
+ }
143
+ const failureGroups=new WeakMap()
144
+ function groupFailures(entries) {
145
+ const out=[]
146
+ let pending=[],count=0,last=-1
147
+ const emit=()=>{
148
+ if(count>1){
149
+ const items=pending.slice(0,last+1),first=items[0],cached=failureGroups.get(first)
150
+ let grouped=cached
151
+ if(!cached||cached.view.failureGroup.items.length!==items.length||!items.every((entry,index)=>entry===cached.view.failureGroup.items[index])){
152
+ grouped={seq:first.seq,event:{type:'failure/group'},view:{failureGroup:{items,count}}}
153
+ failureGroups.set(first,grouped)
154
+ }
155
+ out.push(grouped,...pending.slice(last+1))
156
+ }else out.push(...pending)
157
+ pending=[];count=0;last=-1
158
+ }
159
+ for(const entry of entries){
160
+ if(failure(entry.event)){pending.push(entry);count++;last=pending.length-1}
161
+ // Retry lifecycle markers may sit between failures; messages/tools/success end a run.
162
+ else if(pending.length&&['turn/start','agent/status'].includes(entry.event?.type))pending.push(entry)
163
+ else{emit();out.push(entry)}
164
+ }
165
+ emit()
166
+ return out
167
+ }
168
+ function failureGroupHtml(group,renderEntry) {
169
+ const latest=failure(group.items.at(-1)?.event)
170
+ const hint=typeof latest==='string'?latest:latest?.message
171
+ return shell('error','failure-group:'+group.items[0].seq,text(`连续报错 · ${group.count} 条`,`${group.count} consecutive errors`),brief(hint),text('详情','Details'),group.items.map(renderEntry).join(''),false,true)
172
+ }
173
+ function attemptHtml(event) {
174
+ const blocks=new Map(),data=event?.data||{}
175
+ for(const record of Array.isArray(data.stream)?data.stream:[]) {
176
+ const chunk=record.type==='chunk'?record.chunk:null,index=chunk?.index??record.index
177
+ if(!Number.isSafeInteger(index)||index<0||index>=64)continue
178
+ if(record.type==='reasoning-chunks')blocks.set(index,cut((blocks.get(index)||'')+(record.texts||[]).join(''),12000))
179
+ else if(chunk?.type==='reasoning-delta')blocks.set(index,cut((blocks.get(index)||'')+String(chunk.text||''),12000))
180
+ else if(chunk?.type==='block-end'&&chunk.block?.type==='reasoning')blocks.set(index,cut(chunk.block.text??chunk.block.content??'',12000))
181
+ }
182
+ return [...blocks].filter(([,value])=>value).map(([index,value])=>reasoning({text:value,key:`attempt:${event.seq}:${index}`})).join('')+failureHtml(failure(event),true)
183
+ }
184
+ const streamNotice=()=>`<div class="activity-note" role="status">${esc(text('弱网精简已隐藏实时思考,完成后可查看;可在网络设置中关闭精简。','Live reasoning is hidden in weak-network mode. View it after completion or disable trimming in network settings.'))}</div>`
185
+ const api={hasVisibleText,prepare,tool,toolEvent,reasoning,reasoningKey,group,failure,failureHtml,groupFailures,failureGroupHtml,attemptHtml,streamNotice}
186
+ if(typeof module!=='undefined'&&module.exports)module.exports=api
187
+ else root.DshActivity=api
188
+ })(typeof window==='undefined'?globalThis:window)