dsh-remote-plugin 0.8.0-rc.3 → 0.8.0-rc.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 (65) hide show
  1. package/apk/dsh-remote.apk +0 -0
  2. package/client.js +21 -4
  3. package/doctor-skill.mjs +99 -0
  4. package/doctor-target.mjs +24 -0
  5. package/gateway.cjs +565 -47
  6. package/index.mjs +82 -6
  7. package/insights.mjs +11 -6
  8. package/market.mjs +83 -0
  9. package/package.json +8 -1
  10. package/peak-reminders.mjs +50 -0
  11. package/plugin-center.mjs +162 -32
  12. package/plugin-transaction.mjs +261 -0
  13. package/public/activity.js +58 -1
  14. package/public/admin.html +51 -16
  15. package/public/admin.js +158 -117
  16. package/public/announcement-forms.js +89 -0
  17. package/public/app.js +543 -177
  18. package/public/build.json +5 -0
  19. package/public/desktop/desktop.html +36 -8
  20. package/public/desktop/desktop.js +326 -80
  21. package/public/diagnostics.js +109 -0
  22. package/public/doctor-entry.js +65 -0
  23. package/public/doctor.css +205 -0
  24. package/public/doctor.js +741 -0
  25. package/public/extensions.js +8 -6
  26. package/public/history.js +21 -9
  27. package/public/image-preview.js +22 -6
  28. package/public/index.html +46 -11
  29. package/public/insights.css +7 -0
  30. package/public/insights.js +11 -5
  31. package/public/md.js +91 -34
  32. package/public/network.js +16 -2
  33. package/public/operations.js +1 -1
  34. package/public/plugin-center.css +12 -0
  35. package/public/plugin-center.js +161 -26
  36. package/public/plugin.html +36 -130
  37. package/public/plugin.js +62 -66
  38. package/public/remote-state.js +27 -0
  39. package/public/remote-ui.css +148 -0
  40. package/public/remote-ui.js +243 -0
  41. package/public/session-presets.js +47 -0
  42. package/public/setup.css +18 -0
  43. package/public/setup.js +213 -0
  44. package/public/skins/blue-fish/face.png +0 -0
  45. package/public/skins/blue-fish/icon-blush.png +0 -0
  46. package/public/skins/blue-fish/icon-sleep.png +0 -0
  47. package/public/skins/blue-fish/icon-smile.png +0 -0
  48. package/public/skins/blue-fish/icon-star.png +0 -0
  49. package/public/skins/blue-fish/icon-wink.png +0 -0
  50. package/public/skins/blue-fish/icon.png +0 -0
  51. package/public/skins/blue-fish/mascot.png +0 -0
  52. package/public/skins/blue-fish/pattern.png +0 -0
  53. package/public/skins/blue-fish/preview.html +289 -0
  54. package/public/skins/blue-fish/skin.css +561 -0
  55. package/public/styles.css +5 -1
  56. package/public/teams.js +76 -0
  57. package/public/theme-vars.css +79 -4
  58. package/public/theme.js +2 -2
  59. package/public/turn-results.js +119 -0
  60. package/public/update.json +4 -4
  61. package/public/version.json +1 -1
  62. package/public/workflow.css +42 -0
  63. package/public/workflow.js +4 -1
  64. package/skills/dsh-remote-doctor/SKILL.md +170 -0
  65. package/teams.mjs +53 -0
Binary file
package/client.js CHANGED
@@ -25,9 +25,9 @@ window.__ModuleLoader__.load({
25
25
  // keep a safe fallback for Desktop hosts without that value.
26
26
  position: 'fixed', top: window.location && window.location.protocol === 'dsh-app:' ? 'calc(12px + env(titlebar-area-height, 40px))' : 12,
27
27
  right: 12, bottom: 12, zIndex: 2147483000,
28
- width: 'min(520px, calc(100vw - 24px))', background: '#0b0e1a',
29
- border: '1px solid rgba(125, 207, 255, .22)', borderRadius: 24, overflow: 'hidden',
30
- boxShadow: '-16px 18px 48px rgba(0,0,0,.46), 0 0 0 1px rgba(91,140,255,.08)',
28
+ width: 'min(520px, calc(100vw - 24px))', background: 'transparent',
29
+ border: '1px solid rgba(128,128,128,.25)', borderRadius: 16, overflow: 'hidden',
30
+ boxShadow: '-12px 16px 42px rgba(0,0,0,.24)',
31
31
  transform: 'translateX(102%)', transition: 'transform .22s ease',
32
32
  display: 'flex', flexDirection: 'column',
33
33
  }
@@ -35,12 +35,14 @@ window.__ModuleLoader__.load({
35
35
  // 动态注入列布局, 让各 footer action 上下堆叠。
36
36
  var FOOTER_FIX_ID = 'dsh-remote-footer-stack'
37
37
  var FOOTER_FIX_CSS = '.kIs9zW_footerActions{flex-direction:column!important;align-items:stretch!important}'
38
- var PLUGIN_THEMES = ['default', 'dark', 'light', 'neutral']
38
+ var PLUGIN_THEMES = ['default', 'dark', 'light', 'neutral', 'mono', 'fish']
39
39
  var ICON_PALETTES = {
40
40
  default: { bg: '#F6F9FF', upper: '#4F7FEF', lower: '#8A64D8' },
41
41
  dark: { bg: '#FFF4E3', upper: '#C66A00', lower: '#8A5A24' },
42
42
  light: { bg: '#FFF9EF', upper: '#9B6A20', lower: '#66517F' },
43
43
  neutral: { bg: '#F4F0DF', upper: '#585818', lower: '#832D15' },
44
+ mono: { bg: '#F5F5F5', upper: '#222222', lower: '#555555' },
45
+ fish: { bg: '#EAF6FF', upper: '#2F52D0', lower: '#537CC4' },
44
46
  }
45
47
 
46
48
  function currentPluginTheme() {
@@ -132,12 +134,18 @@ window.__ModuleLoader__.load({
132
134
  function Drawer(props) {
133
135
  var open = props.useStore(function (s) { return s.open })
134
136
  var loaded = React.useRef(false)
137
+ var frame = React.useRef(null)
135
138
  if (open) loaded.current = true
136
139
  // 管理页里的「收起面板」通过 postMessage 请求父窗口关闭抽屉
137
140
  React.useEffect(function () {
138
141
  function onMsg(e) {
139
142
  if (e.origin !== location.origin) return
140
143
  var d = e.data
144
+ if (d && d.source === 'dsh-remote-admin' && d.type === 'open-session' && e.source === frame.current?.contentWindow && typeof d.sessionId === 'string' && /^[a-zA-Z0-9_-]{1,200}$/.test(d.sessionId) && typeof d.requestId === 'string') {
145
+ var opened = props.openSession(d.sessionId)
146
+ e.source.postMessage({source:'dsh-remote-host',requestId:d.requestId,opened:opened},e.origin)
147
+ if(opened) props.actions.close()
148
+ }
141
149
  if (d && (d.source === 'dsh-remote-admin' || d.source === 'dsh-remote-plugin') && d.type === 'close') props.actions.close()
142
150
  }
143
151
  window.addEventListener('message', onMsg)
@@ -154,6 +162,7 @@ window.__ModuleLoader__.load({
154
162
  }),
155
163
  },
156
164
  loaded.current ? React.createElement('iframe', {
165
+ ref: frame,
157
166
  src: '/remote/plugin.html',
158
167
  title: 'DSH Remote 快速状态面板',
159
168
  sandbox: 'allow-scripts allow-same-origin allow-forms allow-modals allow-popups',
@@ -163,6 +172,13 @@ window.__ModuleLoader__.load({
163
172
 
164
173
  var inject = ['slots']
165
174
  function apply(ctx) {
175
+ var navigation = null
176
+ // Declare optional service access, including hosts that start navigation
177
+ // after plugins. The panel remains usable without native navigation.
178
+ if (typeof ctx.inject === 'function') ctx.inject(['uiWorkspace'], function (child) {
179
+ navigation = child.get('uiWorkspace')
180
+ child.effect(function () { return function () { navigation = null } }, 'dsh-remote: native diagnosis navigation')
181
+ })
166
182
  var store = storeRuntime.defineStore({
167
183
  init: function () { return { open: false } },
168
184
  actions: {
@@ -187,6 +203,7 @@ window.__ModuleLoader__.load({
187
203
  name: 'shell.overlay',
188
204
  id: 'dsh-remote-drawer',
189
205
  store,
206
+ inject: function () { return {openSession:function(id){try{if(typeof navigation?.openSession!=='function')return false;navigation.openSession(id);return true}catch(_){return false}}} },
190
207
  }, Drawer)
191
208
  })
192
209
  }, 'dsh-remote: overlay drawer')
@@ -0,0 +1,99 @@
1
+ // Bundled read-only diagnosis skill for DSH Remote.
2
+ // Registration is best-effort: an older DSH without the skill registry must
3
+ // still load the Remote plugin, and the client keeps a prompt-only fallback.
4
+ import { readFileSync } from 'node:fs'
5
+ import { join } from 'node:path'
6
+ import { fileURLToPath } from 'node:url'
7
+
8
+ export const DOCTOR_SKILL_NAME = 'dsh-remote-doctor'
9
+ const SKILL_DIR = fileURLToPath(new URL('./skills/dsh-remote-doctor/', import.meta.url))
10
+ const SKILL_PATH = join(SKILL_DIR, 'SKILL.md')
11
+ const DESCRIPTION = 'Diagnose DSH Remote plugin and client problems with read-only evidence. Use when the user reports a DSH Remote connection, gateway, plugin update, mobile/desktop UI, notification, file-transfer, or model/session problem and asks for a cause analysis, troubleshooting steps, or an issue-ready feedback draft.'
12
+ const WHEN_TO_USE = 'The user is troubleshooting DSH Remote itself, wants evidence collected on their own machine, or asks whether a problem is a plugin defect.'
13
+ const PROVIDER = 'dsh-remote-doctor'
14
+ const BUNDLED_SKILL_RANK = 600
15
+
16
+ let body
17
+ const registrations = new WeakMap()
18
+ export const doctorSkillStatus = ctx => registrations.get(ctx) || 'unconfirmed'
19
+
20
+ function skillBody() {
21
+ if (body !== undefined) return body
22
+ const raw = readFileSync(SKILL_PATH, 'utf8').replace(/^\uFEFF/, '')
23
+ body = raw.replace(/^---\r?\n[\s\S]*?\r?\n---\r?\n?/, '').trim()
24
+ if (!body) throw new Error('dsh-remote-doctor skill body is empty')
25
+ return body
26
+ }
27
+
28
+ /**
29
+ * Register the packaged doctor skill with the optional DSH skill registry.
30
+ * Returns false instead of failing plugin startup when this DSH build has no
31
+ * skill service or the packaged asset is unavailable.
32
+ */
33
+ function registerProvider(ctx) {
34
+ let skills
35
+ try {
36
+ // Cordis may reject access to an optional service before a method can be
37
+ // tested. A missing/undeclared skill registry must not abort Remote.apply.
38
+ skills = ctx?.get?.('skills') ?? ctx?.skills
39
+ if (typeof skills?.registerProvider !== 'function' || typeof ctx?.effect !== 'function') return false
40
+ } catch { return false }
41
+ let content
42
+ try {
43
+ content = skillBody()
44
+ } catch (error) {
45
+ try { ctx.logger?.warn?.('dsh-remote: doctor skill unavailable: ' + (error?.message || String(error))) } catch {}
46
+ return false
47
+ }
48
+ const candidate = {
49
+ name: DOCTOR_SKILL_NAME,
50
+ description: DESCRIPTION,
51
+ whenToUse: WHEN_TO_USE,
52
+ invocation: { modelInvocable: true, userInvocable: true },
53
+ provider: PROVIDER,
54
+ source: 'bundled',
55
+ path: SKILL_PATH,
56
+ resourceBase: { kind: 'directory', path: SKILL_DIR },
57
+ rank: BUNDLED_SKILL_RANK,
58
+ locator: SKILL_PATH,
59
+ }
60
+ const provider = {
61
+ name: PROVIDER,
62
+ list: () => Promise.resolve([candidate]),
63
+ get: () => Promise.resolve({
64
+ name: DOCTOR_SKILL_NAME,
65
+ description: DESCRIPTION,
66
+ whenToUse: WHEN_TO_USE,
67
+ invocation: { modelInvocable: true, userInvocable: true },
68
+ provider: PROVIDER,
69
+ source: 'bundled',
70
+ path: SKILL_PATH,
71
+ resourceBase: { kind: 'directory', path: SKILL_DIR },
72
+ content,
73
+ }),
74
+ }
75
+ try {
76
+ ctx.effect(() => skills.registerProvider(() => provider), 'dsh-remote: doctor skill')
77
+ return true
78
+ } catch (error) {
79
+ try { ctx.logger?.warn?.('dsh-remote: doctor skill registration failed: ' + (error?.message || String(error))) } catch {}
80
+ return false
81
+ }
82
+ }
83
+
84
+ export function registerDoctorSkill(ctx) {
85
+ // Optional injection declares service access and waits for the registry to
86
+ // become available. True here means the watcher was installed; only the
87
+ // observed registration status proves a provider was registered.
88
+ if (typeof ctx?.inject === 'function') {
89
+ registrations.set(ctx, 'waiting')
90
+ ctx.inject(['skills'], child => {
91
+ registrations.set(ctx, registerProvider(child) ? 'registered' : 'unavailable')
92
+ child.effect(() => () => { registrations.set(ctx, 'waiting') }, 'dsh-remote: doctor registration state')
93
+ })
94
+ return true
95
+ }
96
+ const registered = registerProvider(ctx)
97
+ registrations.set(ctx, registered ? 'registered' : 'unavailable')
98
+ return registered
99
+ }
@@ -0,0 +1,24 @@
1
+ // The loaded module determines the diagnosis target. No client path input.
2
+ import {readFileSync,realpathSync} from 'node:fs'
3
+ import {join} from 'node:path'
4
+ import {fileURLToPath} from 'node:url'
5
+ import {doctorSkillStatus} from './doctor-skill.mjs'
6
+ export const DOCTOR_PLUGIN_ROOT = realpathSync(fileURLToPath(new URL('./',import.meta.url)))
7
+ const registries = new WeakMap()
8
+ export function watchDoctorWorkspaces(ctx) {
9
+ if(typeof ctx?.inject!=='function')return
10
+ ctx.inject(['workspaceRegistry'],child=>{
11
+ registries.set(ctx,child.get('workspaceRegistry'))
12
+ child.effect(()=>()=>registries.delete(ctx),'dsh-remote: doctor workspace targets')
13
+ })
14
+ }
15
+ export function readDoctorTarget(ctx) {
16
+ let version=''
17
+ try { const pkg=JSON.parse(readFileSync(join(DOCTOR_PLUGIN_ROOT,'package.json'),'utf8'));if(pkg.name==='dsh-remote-plugin')version=pkg.version } catch {}
18
+ let workspaces=[]
19
+ try {
20
+ const registry=registries.get(ctx) ?? ctx.get?.('workspaceRegistry') ?? ctx.get?.('workspace'),rows=registry?.list?.()
21
+ if(Array.isArray(rows))workspaces=rows.slice(0,100).filter(row=>typeof row?.id==='string'&&typeof row?.path==='string').map(row=>({workspaceId:row.id.slice(0,200),title:String(row.title||row.name||'').slice(0,200),path:row.path.slice(0,4096)}))
22
+ } catch {}
23
+ return {ok:true,schema:1,plugin:{path:DOCTOR_PLUGIN_ROOT,version,kind:'loaded-plugin'},skill:{name:'dsh-remote-doctor',status:doctorSkillStatus(ctx)},workspaces}
24
+ }