dsh-codex-style-computer-use 2.3.1 → 2.3.2
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/lib/argument-recovery.js +50 -0
- package/lib/core/bin/dsh-computer-use-worker.exe +0 -0
- package/lib/core/bin/dsh-computer-use-worker.exe.json +2 -2
- package/lib/core/index.js +18 -2
- package/lib/core/worker.cs +972 -121
- package/lib/image-output.js +1 -1
- package/lib/index.js +3 -0
- package/lib/key-command.js +3 -3
- package/lib/tools.js +233 -78
- package/mcp/src/tools.js +5 -2
- package/package.json +1 -1
- package/scripts/check-behavior.mjs +2 -1
- package/skills/computer-use/SKILL.md +28 -0
- package/skills/computer-use/scripts/inspect-borrow.py +113 -0
|
@@ -11,6 +11,14 @@ Read this entry before driving. The skill gate requires this receipt once per se
|
|
|
11
11
|
|
|
12
12
|
Tools load for the current Agent after a successful `skill` load or this receipt; if invisible, call `computer_use_activate` (opens no cycle, releases no brake). Stop/exit and computer_ask work before activation. Issue real tool calls: a target handle is a string argument to computer_uia_act — tags, examples and prose do not execute; in a run_code-only host, call tools through run_code. Observation and the safety direction (ask, stop, exit) are not gated; a human brake still refuses observation. Read a referenced file only when its condition applies.
|
|
13
13
|
|
|
14
|
+
## BrowserSkill confirmation on Windows
|
|
15
|
+
|
|
16
|
+
When using BrowserSkill, identify which component is asking. For an existing user tab, `bsk_tabs` with `action:"borrow"` waits for the extension's decision. If the profile requires confirmation, tell the user before issuing the call where to look for “允许借用标签页?” in their browser. Send the borrow once and continue on its success receipt. Preserve the extension's confirmation setting. For a page JavaScript `dialog_pending`, decide the dialog within the task's authorization and await the original operation.
|
|
17
|
+
|
|
18
|
+
For an ordinary Windows prompt that continues an authorized operation, use the existing task authorization. Locate the dialog in its owning window, read its requested effect, click the matching control once and verify the resulting application state. A full-access conversation running in autonomous mode can do this unattended. The host reads `sandboxPolicy.resolve({session}).mode` and `approval.effectivePolicy(session)` for that call. BrowserSkill separately owns its tab-borrow preference.
|
|
19
|
+
|
|
20
|
+
When explaining a missed prompt, compare the request and its result with screenshot times and intervening tool calls. An earlier frame or a later empty `dialog-status` cannot establish what was visible while borrowing. Use a frame from the waiting interval to identify the visible prompt. If that frame is missing, report the gap. The success receipt names the borrowed tab and windows. It omits the approver. To inspect a named DSH v4 session locally, run `python scripts/inspect-borrow.py <session-file>` from this skill's directory. It reads direct tool records. Compressed sessions require Python's Zstandard support (standard in 3.14, or the `zstandard` module).
|
|
21
|
+
|
|
14
22
|
## Cycle boundary (one rule)
|
|
15
23
|
|
|
16
24
|
A desktop cycle covers **one continuous desktop block**, not the user's task and not the turn.
|
|
@@ -32,6 +40,16 @@ The plugin also has a deterministic backstop: after a non-desktop top-level tool
|
|
|
32
40
|
|
|
33
41
|
## Start, act, verify
|
|
34
42
|
|
|
43
|
+
On a multi-display desktop, keep the task in its existing work window. Inspect `computer_state {hwnd}` for the work area, owned popups and nine sampled pixel receivers. If a required popup opens on another screen, identify its owner and use `computer_window {op:"move", hwnd:popup, workHwnd:parent}`. Check `contained:true`, then activate the popup and observe it again. The same call leaves an already contained window in place. For a covered window, query its controls by hwnd. Pixel samples describe only the sampled positions.
|
|
44
|
+
|
|
45
|
+
For a screenshot-bound click, the worker rechecks a known accessible control or the local pixels before pressing. On STALE_SCREENSHOT, observe again and select the current target. Window OCR accepts `hwnd` with an optional absolute crop inside the surface. Window-scoped pixel waits and OCR read the same surface as the screenshot, including behind other windows. For a targeted action, automatic feedback follows its window and active owned popup. Inspect the returned title and controls before choosing the next action.
|
|
46
|
+
|
|
47
|
+
On Windows, `computer_shot {hwnd}` reads the selected window surface even under an opaque window. A background capture can be inspected. For input, bring the intended window forward and take a fresh shot with a screenshotId. Minimized or unavailable surfaces can return a capture error. Default screenshots wait for the observed area to go quiet. Repeated static views return sooner. If `settled:false` is returned, observe again before acting.
|
|
48
|
+
|
|
49
|
+
For a visual action inside one window, use `computer_shot {hwnd}` and pass its `screenshotId` with the observed image coordinates to click, drag or scroll. Click and wheel accept integer `x` and `y`; drag takes `from` and `to` as coordinate pairs. Use the dimensions returned with that ID, including after attachment resizing. On `STALE_SCREENSHOT`, take a fresh window capture. A change of page, zoom or scroll inside the same window also calls for fresh visual evidence. If the route cannot inspect the image, use a UIA field, mark, or OCR result.
|
|
50
|
+
|
|
51
|
+
For keyboard or text input, pass the observed `hwnd` to require that exact foreground window. `computer_uia {hwnd,focused:true}` reads the focused control and its current selections. Check the returned text and selection status. To scroll an inner pane, query its Scroll pattern and use `computer_uia_act {target,action:"scroll",value:"down"}`; compare the returned percentages. To find an app by name or AppID, `computer_state {appQuery:"..."}` returns Start registrations and visible matching windows. Check each window's `matchBy` and title before choosing between windows sharing an executable.
|
|
52
|
+
|
|
35
53
|
1. Identify the app with `computer_state {windows:true}`, reusing a known window; activate its hwnd with `computer_window` and require `activated:true` before capturing or driving; bind the intended record/field/document too. Minimized: restore, then activate. An occlusion error means inspect what covers it.
|
|
36
54
|
2. Cheapest sufficient observation first: returned readback → focused UIA query → reusable mark map → image only when visual evidence is needed. Do not re-read state to satisfy a checklist.
|
|
37
55
|
3. Prefer `computer_uia {hwnd, role, name, id}` + `computer_uia_act` for pattern controls (`name` substring, `id` exact AutomationId, scoped by hwnd). Prefer the returned `target`; after replacement `rebind:true` recovers only with native identity or complete unique semantic evidence in the same window — changed context, ambiguity and incomplete searches refuse. Use target OR name/id/role, never both; narrow the query instead of taking the first same-name button. Tabs use `action:"select"`; fields may `setValue` with readback.
|
|
@@ -44,6 +62,16 @@ The plugin also has a deterministic backstop: after a non-desktop top-level tool
|
|
|
44
62
|
|
|
45
63
|
**`computer_launch {target}`** opens an app/URL/folder/document in one call instead of the 4+ step Win+R route; the launcher resolves aliases (`calc`), `shell:` folders, URLs, paths and associations. Pass `args` (one array entry per argument value, never a pre-built command line) to start an executable with arguments — e.g. a dedicated browser profile: target `…\msedge.exe`, args `["--user-data-dir=D:\profiles\job", "--new-window", "<url>"]`. It is an actuation (same approval/brake/audit funnel, lights the border), and `launched:true` means it reached the launcher, not that the app is ready — verify with `computer_state` before driving. For code, give the full path.
|
|
46
64
|
|
|
65
|
+
## Window and control actions
|
|
66
|
+
|
|
67
|
+
Check the current tool schemas for these Windows actions and options. Older plugin versions can share this manual.
|
|
68
|
+
|
|
69
|
+
Use `computer_window {hwnd, observe:true}` to activate a known window and read its UIA controls in one call. The observation covers the window that received activation, including an owned modal. Use `computer_type {expectTarget, text}` with an observed field when entering text in that exact field matters. If focus changes, inspect its contents before continuing a partial write.
|
|
70
|
+
|
|
71
|
+
Use `computer_uia_act {target, action:"selectText", value}` to select an exact passage. Add immediately adjacent `prefix` or `suffix` if the passage occurs more than once. Check `selectionVerified`. On a slider, `setValue` accepts a numeric string and returns `rangeValue`. For list items, `addToSelection` and `removeFromSelection` preserve other selected items when supported.
|
|
72
|
+
|
|
73
|
+
Use `computer_click {mark, ctrl:true}` for Ctrl-click. Click and key accept `durationMs` from 20 to 2000. `computer_key` accepts `Control_L`, `Shift_L`, `Alt_L` and numeric keypad digits such as `KP_9` and `Numpad_0`. Num Lock determines how an app interprets keypad digits.
|
|
74
|
+
|
|
47
75
|
## Screenshots and coordinates
|
|
48
76
|
|
|
49
77
|
`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.
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
"""Read one DSH v4 session. Report direct tool receipts without page or screenshot content."""
|
|
2
|
+
import argparse
|
|
3
|
+
import contextlib
|
|
4
|
+
import io
|
|
5
|
+
import json
|
|
6
|
+
import pathlib
|
|
7
|
+
import re
|
|
8
|
+
import sys
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
@contextlib.contextmanager
|
|
12
|
+
def open_session(path):
|
|
13
|
+
with contextlib.ExitStack() as stack:
|
|
14
|
+
raw = stack.enter_context(path.open("rb"))
|
|
15
|
+
if path.suffix == ".zstd":
|
|
16
|
+
try:
|
|
17
|
+
from compression import zstd
|
|
18
|
+
raw = stack.enter_context(zstd.open(raw, "rb"))
|
|
19
|
+
except ImportError:
|
|
20
|
+
import zstandard
|
|
21
|
+
raw = stack.enter_context(zstandard.ZstdDecompressor().stream_reader(raw))
|
|
22
|
+
yield stack.enter_context(io.TextIOWrapper(raw, encoding="utf-8"))
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def inspect(lines):
|
|
26
|
+
header = json.loads(next(lines))
|
|
27
|
+
if header.get("type") != "session" or header.get("version") != 4 or not header.get("id"):
|
|
28
|
+
raise ValueError("Expected a DSH v4 session header")
|
|
29
|
+
records, waiting, shots, latest, checks = [], {}, {}, {}, {}
|
|
30
|
+
last_shot = None
|
|
31
|
+
last_seq = -1
|
|
32
|
+
for line in lines:
|
|
33
|
+
event = json.loads(line)
|
|
34
|
+
seq, kind, data = event["seq"], event["type"], event["data"]
|
|
35
|
+
if seq != last_seq + 1:
|
|
36
|
+
raise ValueError("Incomplete or unordered session history")
|
|
37
|
+
last_seq = seq
|
|
38
|
+
if kind == "step/start":
|
|
39
|
+
for item in waiting.values():
|
|
40
|
+
item["newStepsDuringWait"] += 1
|
|
41
|
+
elif kind == "tool/call":
|
|
42
|
+
name, call = data["name"], data["callId"]
|
|
43
|
+
for item in waiting.values():
|
|
44
|
+
item["directCallsDuringWait"].append(name)
|
|
45
|
+
if name == "computer_shot":
|
|
46
|
+
shots[call] = seq
|
|
47
|
+
if name not in ("bsk_tabs", "bsk_assist"):
|
|
48
|
+
continue
|
|
49
|
+
args = data["arguments"]
|
|
50
|
+
if isinstance(args, str):
|
|
51
|
+
args = json.loads(args)
|
|
52
|
+
session = args.get("session")
|
|
53
|
+
if name == "bsk_tabs" and args.get("action") == "borrow":
|
|
54
|
+
item = dict(browserSkillSession=session, tabId=args.get("tabId"), callSeq=seq,
|
|
55
|
+
startedAtMs=event["time"], outcome="result-unobserved", lastDirectShot=last_shot,
|
|
56
|
+
newStepsDuringWait=0, directCallsDuringWait=[])
|
|
57
|
+
records.append(item)
|
|
58
|
+
waiting[call] = item
|
|
59
|
+
if session:
|
|
60
|
+
latest[session] = item
|
|
61
|
+
if name == "bsk_assist" and args.get("action") == "dialog-status" and session in latest:
|
|
62
|
+
checks[call] = latest[session]
|
|
63
|
+
elif kind == "tool/result":
|
|
64
|
+
message = data["message"]
|
|
65
|
+
call = message["toolCallId"]
|
|
66
|
+
if call in shots:
|
|
67
|
+
start = shots.pop(call)
|
|
68
|
+
parts = message.get("content", [])
|
|
69
|
+
has_image = any(p.get("type") == "image" for p in parts)
|
|
70
|
+
for part in parts:
|
|
71
|
+
if part.get("type") != "text":
|
|
72
|
+
continue
|
|
73
|
+
try:
|
|
74
|
+
artifact = json.loads(part.get("text", ""))
|
|
75
|
+
except ValueError:
|
|
76
|
+
continue
|
|
77
|
+
if isinstance(artifact, dict) and isinstance(artifact.get("path"), str) and artifact["path"]:
|
|
78
|
+
has_image = True
|
|
79
|
+
if not message.get("isError") and has_image:
|
|
80
|
+
last_shot = dict(callSeq=start, resultSeq=seq, returnedAtMs=event["time"])
|
|
81
|
+
item, check = waiting.pop(call, None), checks.pop(call, None)
|
|
82
|
+
if item is None and check is None:
|
|
83
|
+
continue
|
|
84
|
+
receipt = "\n".join(c["text"] for c in message["content"] if c.get("type") == "text")
|
|
85
|
+
if item is not None:
|
|
86
|
+
item.update(resultSeq=seq, returnedAtMs=event["time"], elapsedMs=event["time"]-item["startedAtMs"])
|
|
87
|
+
match = re.fullmatch(r"\[session ([^\]\s]+)\] borrowed tab (\d+) from window \d+ into Agent Window \d+", receipt)
|
|
88
|
+
if message.get("isError"):
|
|
89
|
+
item["outcome"] = "error"
|
|
90
|
+
elif match and item["browserSkillSession"] in (None, match[1]) and int(match[2]) == item["tabId"]:
|
|
91
|
+
item.update(outcome="borrowed", approver="absent-from-receipt")
|
|
92
|
+
else:
|
|
93
|
+
item["outcome"] = "unrecognized-receipt"
|
|
94
|
+
if check and check.get("resultSeq", seq) < seq and not message.get("isError") and "firstLaterJsDialogStatus" not in check:
|
|
95
|
+
try:
|
|
96
|
+
status = json.loads(receipt)
|
|
97
|
+
except ValueError:
|
|
98
|
+
continue
|
|
99
|
+
if isinstance(status, dict) and status.get("session_id") == check["browserSkillSession"] and isinstance(status.get("dialogs"), list):
|
|
100
|
+
check["firstLaterJsDialogStatus"] = dict(seq=seq, afterResultMs=event["time"]-check["returnedAtMs"],
|
|
101
|
+
count=len(status["dialogs"]), scope="page-js-dialogs")
|
|
102
|
+
return dict(sessionId=header["id"], throughSeq=last_seq, borrows=records)
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
if __name__ == "__main__":
|
|
106
|
+
parser = argparse.ArgumentParser(description=__doc__)
|
|
107
|
+
parser.add_argument("session", type=pathlib.Path)
|
|
108
|
+
args = parser.parse_args()
|
|
109
|
+
try:
|
|
110
|
+
with open_session(args.session) as lines:
|
|
111
|
+
print(json.dumps(inspect(iter(lines)), indent=2))
|
|
112
|
+
except (ValueError, KeyError, OSError, ImportError, StopIteration) as error:
|
|
113
|
+
sys.exit(f"Could not read the session: {error}")
|