dsh-codex-style-computer-use 2.3.4 → 2.3.5

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/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  [![开放插件市场](https://img.shields.io/endpoint?url=https%3A%2F%2Fdshopen.org%2Fbadge%2Fdsh-codex-style-computer-use.json)](https://dshopen.org/zh/plugins/dsh-codex-style-computer-use/)
4
4
 
5
- **Windows Computer Use 2.3.4 for DeepSeek Harness**
5
+ **Windows Computer Use 2.3.5 for DeepSeek Harness**
6
6
 
7
7
  Discover available actions per control, scroll to an exact percentage, switch views, and place the caret before or after matching text. Includes OCR and batch actions.
8
8
 
package/README.zh.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  [![开放插件市场](https://img.shields.io/endpoint?url=https%3A%2F%2Fdshopen.org%2Fbadge%2Fdsh-codex-style-computer-use.json)](https://dshopen.org/zh/plugins/dsh-codex-style-computer-use/)
4
4
 
5
- **Windows 桌面操控 2.3.4 · DeepSeek Harness 插件**
5
+ **Windows 桌面操控 2.3.5 · DeepSeek Harness 插件**
6
6
 
7
7
  先看控件支持哪些操作,再按百分比精确滚动、切换视图或显示离屏条目。编辑时可把光标准确放在匹配文字前后。支持 OCR 和批量操作。
8
8
 
package/client.js CHANGED
@@ -22,7 +22,7 @@ window.__ModuleLoader__.load({
22
22
  const module = { exports: {} }
23
23
  const exports = module.exports
24
24
  const React = require('react')
25
- const { createElement: h, useState, useEffect, useCallback } = React
25
+ const { createElement: h, useState, useEffect, useCallback, useRef, useSyncExternalStore } = React
26
26
 
27
27
  const API = '/api/computer-use/host-debug'
28
28
  const TEXT = {
@@ -55,35 +55,56 @@ window.__ModuleLoader__.load({
55
55
  h('b', { style: { color: ok ? 'inherit' : '#c0392b' } }, value))
56
56
  }
57
57
 
58
- function SettingsPage () {
58
+ const subscribeToNothing = () => () => {}
59
+ const selectedId = current => current?.getSnapshot().key ?? null
60
+
61
+ async function requestStatus (sessionId, options) {
62
+ const url = sessionId ? API + '?session=' + encodeURIComponent(sessionId) : API
63
+ const r = await fetch(url, options)
64
+ const status = await r.json()
65
+ if (!r.ok) throw new Error(status.error || ('HTTP ' + r.status))
66
+ return status
67
+ }
68
+
69
+ function SettingsPage ({ current }) {
70
+ const sessionId = useSyncExternalStore(current?.subscribe ?? subscribeToNothing, () => selectedId(current))
59
71
  const [state, setState] = useState(null)
60
72
  const [error, setError] = useState(null)
61
73
  const [busy, setBusy] = useState(false)
74
+ const lastRead = useRef(0)
62
75
 
63
76
  const load = useCallback(async () => {
77
+ const read = ++lastRead.current
64
78
  setError(null)
65
79
  try {
66
- const r = await fetch(API, { cache: 'no-store' })
67
- const j = await r.json()
68
- if (!r.ok) throw new Error(j.error || ('HTTP ' + r.status))
69
- setState(j)
70
- } catch (e) { setError(String(e?.message ?? e)) }
71
- }, [])
80
+ const status = await requestStatus(selectedId(current), { cache: 'no-store' })
81
+ if (read === lastRead.current) setState(status)
82
+ } catch (e) { if (read === lastRead.current) setError(String(e?.message ?? e)) }
83
+ }, [current])
72
84
 
73
- useEffect(() => { load() }, [load])
85
+ useEffect(() => {
86
+ load()
87
+ return () => { lastRead.current++ }
88
+ }, [load, sessionId])
74
89
 
75
- const save = useCallback(async (enabled) => {
90
+ async function save (enabled) {
76
91
  setBusy(true)
92
+ setError(null)
77
93
  try {
78
- const r = await fetch(API, { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ enabled }) })
79
- const j = await r.json()
80
- if (!r.ok) throw new Error(j.error || ('HTTP ' + r.status))
81
- setState(j)
94
+ const saved = await requestStatus(sessionId, { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ enabled }) })
95
+ if (saved.session.id === selectedId(current)) {
96
+ lastRead.current++
97
+ setState(saved)
98
+ } else {
99
+ // The switch is shared. Refresh the conversation selected during the save.
100
+ await load()
101
+ }
82
102
  } catch (e) { setError(String(e?.message ?? e)) } finally { setBusy(false) }
83
- }, [])
103
+ }
84
104
 
85
- const sandbox = state?.session?.sandbox ?? null
86
- const full = state?.session?.fullAccess === true
105
+ const permission = state?.session?.id === sessionId ? state.session : null
106
+ const sandbox = permission?.sandbox ?? null
107
+ const full = permission?.fullAccess === true
87
108
  const enabled = state?.enabled === true
88
109
 
89
110
  return h('div', { style: { padding: '18px 22px', lineHeight: 1.55, maxWidth: 760 } },
@@ -94,7 +115,7 @@ window.__ModuleLoader__.load({
94
115
  row(TEXT.gate1, full ? TEXT.fullYes : (sandbox ? (TEXT.fullNo + ':' + sandbox) : TEXT.fullUnknown), full),
95
116
  row(TEXT.gate2, enabled ? TEXT.on : TEXT.off, enabled),
96
117
  h('p', { style: { margin: '10px 0 0', opacity: .75, fontSize: 13 } }, TEXT.gateHint),
97
- !full ? h('p', { style: { margin: '6px 0 0', color: '#c0392b', fontSize: 13 } }, TEXT.warnGate1) : null,
118
+ sandbox && !full ? h('p', { style: { margin: '6px 0 0', color: '#c0392b', fontSize: 13 } }, TEXT.warnGate1) : null,
98
119
  !enabled ? h('p', { style: { margin: '6px 0 0', opacity: .75, fontSize: 13 } }, TEXT.warnOff) : null,
99
120
  state.lastBlockedAt ? h('p', { style: { margin: '6px 0 0', fontSize: 13 } }, TEXT.warnBlocked + '(' + TEXT.blockedAt + ':' + state.lastBlockedAt + ')') : null,
100
121
  h('p', { style: { margin: '6px 0 0', fontSize: 13, opacity: .6 } },
@@ -102,7 +123,7 @@ window.__ModuleLoader__.load({
102
123
  ) : h('p', { style: { opacity: .7 } }, TEXT.loading),
103
124
  h('div', { style: { display: 'flex', gap: 10, margin: '16px 0 14px' } },
104
125
  h('button', {
105
- disabled: busy,
126
+ disabled: busy || !state,
106
127
  onClick: () => save(!enabled),
107
128
  style: { padding: '7px 16px', borderRadius: 6, border: '1px solid rgba(127,127,127,.4)', cursor: 'pointer', fontWeight: 600, background: enabled ? 'transparent' : '#1f6feb', color: enabled ? 'inherit' : '#fff' },
108
129
  }, busy ? '…' : (enabled ? '关闭调试模式' : '开启调试模式')),
@@ -119,7 +140,7 @@ window.__ModuleLoader__.load({
119
140
  order: 52,
120
141
  label: () => TEXT.nav,
121
142
  locale: 'settings.computerUseDebug',
122
- }, () => h(SettingsPage)))
143
+ }, () => h(SettingsPage, { current: ctx.get('uiSession')?.adapter?.current })))
123
144
  }
124
145
 
125
146
  exports.apply = apply
package/lib/host-debug.js CHANGED
@@ -14,8 +14,9 @@
14
14
  // writes. Tools can read both; they cannot write either.
15
15
  //
16
16
  // SETTINGS PAGE CONTRACT (host side):
17
- // GET /api/computer-use/host-debug -> { enabled, since, session:{id,sandbox,fullAccess}, lastBlockedAt }
18
- // POST /api/computer-use/host-debug -> { enabled: boolean } (writes the file, returns the same shape)
17
+ // GET /api/computer-use/host-debug?session=<id> returns { enabled, since, session, lastBlockedAt, ready }.
18
+ // POST /api/computer-use/host-debug?session=<id> accepts { enabled: boolean } and returns the same status.
19
+ // The query identifies the displayed conversation. A missing or unknown id reports fullAccess: false.
19
20
  import { existsSync, mkdirSync, readFileSync, statSync, writeFileSync } from 'node:fs'
20
21
  import path from 'node:path'
21
22
 
package/lib/index.js CHANGED
@@ -450,7 +450,7 @@ function handleHostDebug (req, res, sctx) {
450
450
  const rejection = connection && typeof connection.requestRejection === 'function' ? connection.requestRejection(req) : null
451
451
  if (rejection) { send(403, { error: 'rejected by host', detail: String(rejection) }); return }
452
452
  const url = new URL(req.url, 'http://127.0.0.1')
453
- const sid = url.searchParams.get('session') || process.env.DSH_SESSION_ID || null
453
+ const sid = url.searchParams.get('session') || null
454
454
  const status = () => {
455
455
  const debug = readHostDebug()
456
456
  const perm = sessionPermission(sid)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-codex-style-computer-use",
3
- "version": "2.3.4",
3
+ "version": "2.3.5",
4
4
  "description": "Windows desktop automation for DeepSeek Harness. Discover actions per control, scroll to an exact percentage, switch views, and place the caret before or after matching text. Includes OCR and a prebuilt Windows worker.",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",