dsh-codex-style-computer-use 2.3.0 → 2.3.1

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
@@ -23,6 +23,7 @@ English | [中文](README.zh.md) | [Français](README.fr.md) | [Deutsch](README.
23
23
 
24
24
  ## Why it costs less
25
25
 
26
+ - **Find a window without reading its controls.** Start with `computer_state {windows:true}`. When you need a control, pass that window's handle to `computer_uia`.
26
27
  - **One round trip for a known sequence.** One `computer_batch` call runs a list of actions serially, stops at the first failure, and costs one model round trip instead of one per action.
27
28
  - **Only the delta comes back.** Pass the previous observation ID as `since` and receive additions, changes, removals and ordering — not the whole tree again.
28
29
  - **Compact receipts by default in 2.0.0.** Post-action text normally adds at most 6 KiB to the action receipt; `feedback: full` is still there when detail matters more.
package/README.zh.md CHANGED
@@ -23,6 +23,7 @@
23
23
 
24
24
  ## 为什么它更省
25
25
 
26
+ - **找窗口时只读窗口列表。** 先用 `computer_state {windows:true}` 拿到目标窗口的句柄,需要定位控件时再把句柄传给 `computer_uia`。
26
27
  - **一段已知流程只花一轮往返。** 一次 `computer_batch` 串行执行整串动作、遇错即停,只花一轮模型往返,而不是每个动作各花一轮。
27
28
  - **只回增量。** 把上一次观察 ID 作为 `since` 传回,只拿到新增、变化、删除与顺序,而不是整棵树重发。
28
29
  - **2.0.0 默认精简回执。** 动作后的文字回执通常最多再加 6 KiB;需要细节时仍可用 `feedback: full`。
@@ -21,39 +21,32 @@ function setCoordinates (value, size) {
21
21
  const validImageSize = size => Array.isArray(size) && size.length === 2 && size.every(n => Number.isFinite(n) && n > 0)
22
22
  const validPoint = point => Number.isFinite(point?.x) && Number.isFinite(point?.y)
23
23
 
24
- function restoreFileGeometry (value) {
25
- if (!value.sourceImageSize) return
26
- value.imageSize = value.sourceImageSize
27
- if (value.sourceCursorInImage) value.cursorInImage = value.sourceCursorInImage
28
- else delete value.cursorInImage
29
- delete value.sourceImageSize
30
- delete value.sourceCursorInImage
24
+ export function screenshotPathOnly (value, reason) {
25
+ value.imageStatus = 'path-only'
26
+ value.imageReason = reason
31
27
  setCoordinates(value, value.imageSize)
28
+ const notes = {
29
+ 'model-text-only': 'Image not attached: this model does not declare image input. Use UIA/text or switch to an image-capable model.',
30
+ 'delivery-path': 'Path delivery requested: no image block was attached. The file is on path; call read_image only if visual inspection is actually needed.',
31
+ 'earlier-batch-image': 'This earlier capture is available at its path.',
32
+ }
33
+ value.view = notes[reason] || 'Image not attached. Use read_image on path if visual inspection is needed.'
34
+ if (value.settled === false) value.view = 'NOT settled — re-shoot. ' + value.view
35
+ return value
32
36
  }
33
37
 
34
38
  // DSH image blocks reference the host's durable attachment store. Paths and raw
35
39
  // base64 are not image blocks. Keep a usable file when a route cannot accept one.
36
40
  export async function attachScreenshot (ctx, exec, value, data, options = {}) {
37
- // The local file has geometry even when the model route cannot accept images.
38
- setCoordinates(value, value.imageSize)
39
- const fallback = (reason) => {
40
- delete value.image
41
- restoreFileGeometry(value)
42
- value.imageStatus = 'path-only'
43
- value.imageReason = reason
44
- value.view = reason === 'model-text-only'
45
- ? 'Image not attached: this model does not declare image input. Use UIA/text or switch to an image-capable model.'
46
- : reason === 'delivery-path'
47
- ? 'Path delivery requested: no image block was attached. The file is on path; call read_image only if visual inspection is actually needed.'
48
- : 'Image not attached. Use read_image on path if visual inspection is needed.'
49
- if (value.settled === false) value.view = 'NOT settled — re-shoot. ' + value.view
50
- return value
51
- }
41
+ const fallback = reason => screenshotPathOnly(value, reason)
52
42
  // delivery:"path" — the caller has another way to verify (UIA/OCR/window text), so the pixels
53
43
  // are not evidence it will read. The file is still written and the path still returned; only
54
44
  // the image block is withheld, which is what keeps it out of the re-sent conversation history.
55
45
  if (options.delivery === 'path') return fallback('delivery-path')
46
+ const blocked = () => exec?.signal?.aborted || options.blocked?.()
56
47
  try {
48
+ const interrupted = () => fallback(exec?.signal?.aborted ? 'cancelled' : 'cancelled-or-paused')
49
+ if (blocked()) return interrupted()
57
50
  if (!validImageSize(value.imageSize)) return fallback('invalid-source-image-size')
58
51
  const sourceSize = [...value.imageSize]
59
52
  const attachments = ctx.get?.('attachments')
@@ -65,10 +58,10 @@ export async function attachScreenshot (ctx, exec, value, data, options = {}) {
65
58
  if (!llm?.resolveModelInfo || !provider || !model) return fallback('route-unavailable')
66
59
  const active = await llm.resolveModelInfo(provider, model, exec?.signal)
67
60
  if (!active.inputModalities?.includes('image')) return fallback('model-text-only')
68
- if (exec?.signal?.aborted) return fallback('cancelled')
61
+ if (blocked()) return interrupted()
69
62
  if (!attachments.imageLimits?.mediaTypes?.includes(value.mime)) return fallback('media-type-unavailable')
70
63
  const image = await attachments.saveImage({ data, mediaType: value.mime, name: basename(value.path) })
71
- if (exec?.signal?.aborted) return fallback('cancelled')
64
+ if (blocked()) return interrupted()
72
65
  const attachedSize = [image?.width, image?.height]
73
66
  if (!validImageSize(attachedSize)) return fallback('invalid-attachment-image-size')
74
67
  const evidence = visionEvidence(exec, { ...options, adapterVersion: active.adapterVersion || 'unversioned' })
@@ -84,6 +77,7 @@ export async function attachScreenshot (ctx, exec, value, data, options = {}) {
84
77
  }
85
78
  value.image = image
86
79
  value.imageStatus = 'attached'
80
+ delete value.imageReason
87
81
  setCoordinates(value, attachedSize)
88
82
  if (resized && value.coordinateRule) value.coordinateRule += ' imageSize, cursorInImage and coordinates describe the attached image. path retains the original capture: use sourceImageSize and sourceCursorInImage for that file; map its pixels using region.width/sourceImageSize[0] and region.height/sourceImageSize[1].'
89
83
  value.view = value.settled === false
@@ -111,48 +105,12 @@ export function renderScreenshot (value) {
111
105
  ]
112
106
  }
113
107
 
114
- // A batch exposes one latest image as its checkpoint. Earlier explicit captures
115
- // keep their paths for deliberate later reads, without multiplying vision input.
116
- //
117
- // `delivery` is the batch-level request, and it has to reach further than the checkpoint: when
118
- // no checkpoint happens (shot:"never", a readback tail, or a later failure) the observation
119
- // falls back to the last explicit step image. A batch that asked for paths must not hand one
120
- // back as a picture just because the checkpoint was skipped — same pixels, quieter route.
121
- export function selectBatchScreenshot (result, automatic, kind = 'image', delivery = 'auto') {
122
- let latest = automatic
123
- let index
124
- if (!latest) {
125
- for (const [i, action] of result.actions.entries()) {
126
- if (action.tool === 'computer_shot' && action.result?.path) {
127
- latest = action.result
128
- index = i
129
- }
130
- }
131
- }
132
- const pathDelivery = delivery === 'path'
133
- const pathNote = 'Path delivery requested: no image block was attached. Use read_image on this path only if these pixels are the evidence.'
134
- for (const action of result.actions) {
135
- const shot = action.result
136
- if (shot?.image && shot !== latest) {
137
- delete shot.image
138
- restoreFileGeometry(shot)
139
- shot.imageStatus = 'path-only'
140
- shot.imageReason = pathDelivery ? 'delivery-path' : 'earlier-batch-image'
141
- shot.view = pathDelivery
142
- ? pathNote
143
- : kind === 'state'
144
- ? 'A newer UIA state is returned. This earlier image remains at its path.'
145
- : 'Only the latest batch screenshot is attached. Use read_image on this path if this earlier frame is needed.'
146
- }
147
- }
108
+ // If no automatic checkpoint exists (including after a failed step), identify the
109
+ // last successful explicit capture by its actual step, not the end of the batch.
110
+ export function selectBatchScreenshot (result, automatic, kind = 'image') {
111
+ const index = automatic ? -1 : result.actions.findLastIndex(a => a.tool === 'computer_shot' && a.result?.path)
112
+ const latest = automatic ?? result.actions[index]?.result
148
113
  if (latest) {
149
- if (pathDelivery && latest.image) {
150
- delete latest.image
151
- restoreFileGeometry(latest)
152
- latest.imageStatus = 'path-only'
153
- latest.imageReason = 'delivery-path'
154
- latest.view = pathNote
155
- }
156
114
  result.observation = latest
157
115
  if (kind === 'state') result.observationSource = 'automatic final UIA state'
158
116
  else result.imageSource = automatic ? 'automatic final screenshot' : `action ${index + 1}; captured before any later actions`
package/lib/tools.js CHANGED
@@ -17,7 +17,7 @@
17
17
 
18
18
  import { runBatch, actionRefusal } from './batch.js'
19
19
  import { saveOwnedShot } from './artifacts.js'
20
- import { attachScreenshot, renderScreenshot, selectBatchScreenshot, screenshotMetadata } from './image-output.js'
20
+ import { attachScreenshot, renderScreenshot, selectBatchScreenshot, screenshotMetadata, screenshotPathOnly } from './image-output.js'
21
21
  import { ObservationStore } from './observations.js'
22
22
  import { feedbackPolicy, feedbackActions, feedbackVerification, selectFeedbackDetail } from './feedback.js'
23
23
  import { collectCompactState, limitCompactFeedback, feedbackViewport } from './compact-feedback.js'
@@ -86,10 +86,7 @@ export function registerTools ({ ctx, cu, config, dataDir, log, snapshotPath, de
86
86
  }
87
87
 
88
88
  // Shared by direct calls, explicit batch steps, and the batch checkpoint.
89
- const takeScreenshot = async (args, exec) => {
90
- // Refuse a bad value BEFORE the capture: a refused request that already wrote a file and
91
- // reports outcome:"not-dispatched" is a false receipt.
92
- const delivery = deliveryMode(args.delivery)
89
+ const captureFile = async (args) => {
93
90
  const r = rect(args.region)
94
91
  const shot = await cu.screenshot({
95
92
  x: r && r.x, y: r && r.y, width: r && r.width, height: r && r.height,
@@ -97,8 +94,12 @@ export function registerTools ({ ctx, cu, config, dataDir, log, snapshotPath, de
97
94
  maxWidth: r && r.width <= 900 ? r.width : 1280,
98
95
  })
99
96
  const path = saveShot(shot.image, shot.mime === 'image/png' ? 'png' : 'jpg')
100
- const res = { path, mime: shot.mime, region: shot.region, ...screenshotMetadata(shot) }
101
- return attachScreenshot(ctx, exec, res, shot.image, { rules: config.feedbackRules, delivery })
97
+ return { value: { path, mime: shot.mime, region: shot.region, ...screenshotMetadata(shot) }, bytes: shot.image }
98
+ }
99
+ const takeScreenshot = async (args, exec) => {
100
+ const delivery = deliveryMode(args.delivery)
101
+ const { value, bytes } = await captureFile(args)
102
+ return attachScreenshot(ctx, exec, value, bytes, { rules: config.feedbackRules, delivery })
102
103
  }
103
104
 
104
105
  const clickTarget = async (args) => {
@@ -766,9 +767,19 @@ export function registerTools ({ ctx, cu, config, dataDir, log, snapshotPath, de
766
767
  let automatic, feedback, lastContext = {}
767
768
  const detail = selectFeedbackDetail(args.feedback,
768
769
  config.actionFeedback === false ? 'none' : config.actionFeedbackDetail ?? 'compact')
770
+ // Keep only the latest eligible frame's bytes until we know whether a checkpoint
771
+ // supersedes it. All completed explicit captures have their own local file.
772
+ let pendingFrame
773
+ const captureStep = async input => {
774
+ const stepDelivery = deliveryMode(input.delivery)
775
+ const frame = await captureFile(input)
776
+ const pathOnly = delivery === 'path' || stepDelivery === 'path'
777
+ pendingFrame = pathOnly ? undefined : frame
778
+ return screenshotPathOnly(frame.value, pathOnly ? 'delivery-path' : 'earlier-batch-image')
779
+ }
769
780
  // Batch still observes once at its final checkpoint. Capture the actual
770
781
  // result coordinates without re-resolving potentially stale mark ids.
771
- const feedbackHandlers = Object.fromEntries(Object.entries(HANDLERS).map(([name, handler]) => [name,
782
+ const feedbackHandlers = Object.fromEntries(Object.entries({ ...HANDLERS, computer_shot: captureStep }).map(([name, handler]) => [name,
772
783
  async (input, context) => {
773
784
  const receipt = await handler(input, context)
774
785
  lastContext = { args: input, receipt, tool: name }
@@ -791,7 +802,13 @@ export function registerTools ({ ctx, cu, config, dataDir, log, snapshotPath, de
791
802
  if (!automatic) return null
792
803
  return automatic.path
793
804
  } })
794
- return { ...selectBatchScreenshot(result, feedback?.observation ?? automatic, feedback?.feedback?.kind, delivery), ...feedback }
805
+ const checkpoint = feedback?.observation ?? automatic
806
+ if (!checkpoint && pendingFrame) {
807
+ await attachScreenshot(ctx, exec, pendingFrame.value, pendingFrame.bytes, {
808
+ rules: config.feedbackRules, blocked: () => feedbackBlocked(exec),
809
+ })
810
+ }
811
+ return { ...selectBatchScreenshot(result, checkpoint, feedback?.feedback?.kind), ...feedback }
795
812
  },
796
813
  })
797
814
 
@@ -871,7 +888,6 @@ export function registerTools ({ ctx, cu, config, dataDir, log, snapshotPath, de
871
888
  // The observation tools and the meta tool were missing from this map, so a batch could not
872
889
  // take a screenshot: "unknown tool computer_shot" (reported 2026-09-12). The map must cover
873
890
  // the WHOLE surface — a caller should never have to know which subset happens to be wired.
874
- computer_shot: takeScreenshot,
875
891
  computer_ocr: async (a) => {
876
892
  let region
877
893
  if (a.region) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-codex-style-computer-use",
3
- "version": "2.3.0",
3
+ "version": "2.3.1",
4
4
  "description": "Codex-style Computer Use for DeepSeek Harness: Windows desktop control, screenshots, UI Automation, human input handoff, approval gates and prebuilt native workers. Install and update from dsh-market without PowerShell 7 or build steps.",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
@@ -99,4 +99,4 @@
99
99
  "url": "https://github.com/ltmroberthk915/dsh-computer-use/issues"
100
100
  },
101
101
  "icon": "./icon.svg"
102
- }
102
+ }
@@ -48,7 +48,7 @@ The plugin also has a deterministic backstop: after a non-desktop top-level tool
48
48
 
49
49
  `computer_shot` returns a native image on routes declaring image input. `imageStatus:"attached"`: follow `view` and inspect it directly — no extra read_image. `imageStatus:"path-only"`: follow `view`; the path is not visual evidence. A text-only route needs UIA/text or an image-capable model, and `settled:false` needs a fresh capture. A batch attaches only its latest image and labels its step; an earlier image does not verify later actions. `computer_marks {shot:true}` returns an annotated path whose ids match the text map.
50
50
 
51
- `delivery:"path"` on `computer_shot`/`computer_batch` writes the file and returns its path with NO image block — for work verified from UIA/OCR/window text. Not free: read_image re-adds the image, so use it only when verification is textual. Default `auto`.
51
+ `delivery:"path"` on `computer_shot`/`computer_batch` saves the local files without creating image attachments. Set it once on the batch when verifying from UIA/OCR/window text. With default `auto`, only the selected frame can become an attachment; earlier files remain available. A later read_image still adds the pixels to the conversation.
52
52
 
53
53
  Reuse `observation` from direct click/type/key/move/drag/scroll/select; do not call shot/read_image again without a reason. Image-capable routes (provider aliases included) get image feedback when the attachment channel exists, otherwise UIA/text with the reason in `feedback`. Image transport does not certify grounding — inspect `visionEvidence`. `feedbackRules` match provider/model/adapter version and expire; a current failed-grounding record selects text feedback (the GLM 5.3 record has a limited window) while explicit screenshots keep their image/path. If UIA is absent or truncated, narrow or report the gap. `actionFeedback:false` restores manual feedback.
54
54
 
@@ -131,4 +131,4 @@ The plugin's own window is refused by default: the host holds the human's approv
131
131
  1. this conversation is 完全权限 (`danger-full-access`); and
132
132
  2. debug mode is switched on in 设置 → 电脑操控(调试).
133
133
 
134
- Neither gate can be opened from a tool call — do not try: the switch lives host-side and the permission is the composer pill. When a refusal happens the human gets one notice card (at most once per 10 minutes) naming both gates. With both open, driving the Harness window is allowed and every action is audited as `HOST-CONTROL`; `close`, `minimize` and `hide` of the Harness remain refused even then, and observation never needs the gates. A worker launched without host identity (CLI, MCP) also refuses those three on a Harness window unless the caller passes `confirmHost:true`.
134
+ Neither gate can be opened from a tool call — do not try: the switch lives host-side and the permission is the composer pill. When a refusal happens the human gets one notice card (at most once per 10 minutes) naming both gates. With both open, driving the Harness window is allowed and every action is audited as `HOST-CONTROL`; `close`, `minimize` and `hide` of the Harness remain refused even then, and observation never needs the gates. A worker launched without host identity (CLI, MCP) also refuses those three on a Harness window unless the caller passes `confirmHost:true`.