Make your computer a home for your AI partner. Avibe is the local-first Agent OS: Vibey, its built-in AI partner, works out of the box, and Claude Code, Codex & OpenCode run unchanged beside it — reach them from your browser, phone, or any chat app.
Python agentagent-osaiai-agentsai-partnerchatopsclaudeclaude-codecodexdevtoolsdiscord-botlark-botllmlocal-firstlong-term-memoryopencodeslack-botvibe-codingvibeywechat
fix(computer): clarify destructive quit and structured output (#2604)
Max2a1a44a1d799
diff --git a/core/computer_cli.py b/core/computer_cli.pyindex d1bb80623..70efa0df6 100644--- a/core/computer_cli.py+++ b/core/computer_cli.py@@ -24,7 +24,7 @@ COMPUTER_CLI_TOOLS: dict[tuple[str, ...], str] = {("clipboard", "read"): "clipboard_read",("clipboard", "write"): "clipboard_write",("launch",): "launch_app",- ("quit",): "kill_app",+ ("force-quit",): "kill_app",}OBSERVATION_TOOLS = frozenset(@@ -124,6 +124,10 @@ def tool_for_command(path: tuple[str, ...]) -> str:def _structured_payloads(result: Mapping[str, Any]) -> list[dict[str, Any]]:+ structured = result.get("structuredContent")+ if isinstance(structured, dict):+ return [structured]+payloads: list[dict[str, Any]] = []content = result.get("content")if not isinstance(content, list):diff --git a/core/computer_server.py b/core/computer_server.pyindex cd511eb19..970c8285d 100644--- a/core/computer_server.py+++ b/core/computer_server.py@@ -743,6 +743,7 @@ def _error_result("text": json.dumps(payload, ensure_ascii=False, sort_keys=True),}],+ "structuredContent": payload,"isError": True,}@@ -789,6 +790,8 @@ def _fold_tool_result(tool=tool_name or "",)if structured is not None:+ if isinstance(structured, dict):+ result["structuredContent"] = structuredcontent = result.get("content")if not isinstance(content, list):content = []diff --git a/docs/CLI.md b/docs/CLI.mdindex 8c69ced1e..688f9a51f 100644--- a/docs/CLI.md+++ b/docs/CLI.md@@ -225,7 +225,7 @@ vibe computer set-value --arg pid=123 --arg value=enabled --arg element_token=elvibe computer clipboard readvibe computer clipboard write --arg text="copied text"vibe computer launch --arg bundle_id=com.example.App-vibe computer quit --arg pid=123+vibe computer force-quit --arg pid=123```Every leaf also accepts `--args-json OBJECT` or `--args-json @FILE`,@@ -234,6 +234,10 @@ repeatable `--arg NAME=VALUE`, and `--json`. `--output PATH` is supported byprints the resulting path. Human output for observations includes theaccessibility state and element tokens when the driver returns them.+Machine-readable output keeps the structured driver object in+`result.structuredContent` and retains the legacy text content. `force-quit`+uses the driver's SIGKILL operation; unsaved application state can be lost.+The command reaches the running Controller over local control IPC, so theexisting `require_bind`, observe-first, exact-window, focus-shortcut,single-holder lease, desktop state, and driver admission checks remain in thediff --git a/docs/COMMANDS.md b/docs/COMMANDS.mdindex ff40a8d01..4073d69ef 100644--- a/docs/COMMANDS.md+++ b/docs/COMMANDS.md@@ -714,7 +714,7 @@ vibe computer set-value --arg pid=123 --arg value=enabled --arg element_token=elvibe computer clipboard readvibe computer clipboard write --arg text="copied text"vibe computer launch --arg bundle_id=com.example.App-vibe computer quit --arg pid=123+vibe computer force-quit --arg pid=123```Each leaf accepts `--args-json`, repeatable `--arg`, and `--json`. `observe@@ -722,6 +722,10 @@ window` and `zoom` accept `--output PATH` for a caller-selected screenshotfile. The CLI has no `--session-id` or Turn-ID option and rejects a manuallysupplied driver `session` argument.+The `--json` result exposes the structured driver object at+`result.structuredContent` and retains the legacy text content for compatibility.+`force-quit` sends SIGKILL through the driver and can lose unsaved work.+Computer Use guidance is a built-in managed Skill named `computer-use`, loadedon demand. It tells Agents to treat screen and clipboard data as untrusted,observe the exact target before input, avoid focus and pointer movement, anddiff --git a/skills/computer-use/SKILL.md b/skills/computer-use/SKILL.mdindex 725c71091..f1f1817b3 100644--- a/skills/computer-use/SKILL.md+++ b/skills/computer-use/SKILL.md@@ -24,7 +24,7 @@ vibe computer set-value --arg pid=123 --arg value=enabled --arg element_token=elvibe computer clipboard read --arg include_text=truevibe computer clipboard write --arg text="copied text"vibe computer launch --arg bundle_id=com.example.App-vibe computer quit --arg pid=123+vibe computer force-quit --arg pid=123```Every leaf accepts `--args-json OBJECT`, `--args-json @FILE`, repeatable@@ -33,6 +33,37 @@ Every leaf accepts `--args-json OBJECT`, `--args-json @FILE`, repeatablethe resulting path. `observe window` and `zoom` are the observation operationsthat establish the exact window state required before input.+`--json` keeps the structured driver object at `result.structuredContent`.+The legacy `content` text block remains available for existing callers.++During one Agent Turn, consecutive `vibe computer` calls in the same Avibe+Session share the driver session. Element tokens from one observation stay+valid for following calls until a newer observation replaces that snapshot, so+a short script can observe once, click several times, and observe once at the+end:++```text+vibe computer observe window --arg pid=123 --arg window_id=456+vibe computer click --arg pid=123 --arg window_id=456 --arg element_token=el_1+vibe computer click --arg pid=123 --arg window_id=456 --arg element_token=el_2+vibe computer observe window --arg pid=123 --arg window_id=456+```++Each call still passes the Controller's safety checks. A later observation+replaces the earlier element tokens. At the start of every later Agent Turn,+observe the target again before input and do not reuse tokens from the prior+Turn.++QQ, WeChat, and similar Electron applications may return only window chrome and+menus on the first observation after launch. The driver enables the+accessibility tree and waits up to 4 seconds; after a timeout it backs off for+30 seconds. Wait about 30 seconds and observe again before concluding that the+application text is unreadable.++`force-quit` maps to the driver's `kill_app` operation and sends SIGKILL. It+can lose unsaved work; use the application's cooperative close flow first and+reserve this command for an explicit forced termination.+Argument contract:- Window-targeted operations use `pid` and `window_id` for the exact target.@@ -40,9 +71,10 @@ Argument contract:operation's documented `x`/`y` or drag fields.- `observe window` and `zoom` accept the exact window fields; `zoom` alsoaccepts its rectangle fields such as `x1`, `y1`, `x2`, and `y2`.-- `type`, `key`, `hotkey`, `scroll`, `set-value`, `launch`, `quit`, and- clipboard write use their named driver fields, for example `text`, `key`,- `keys`, `direction`, `value`, `bundle_id` or `urls`, `pid`, and `text`.+- `type`, `key`, `hotkey`, `scroll`, `set-value`, `launch`, and clipboard+ write use their named driver fields, for example `text`, `key`, `keys`,+ `direction`, `value`, `bundle_id` or `urls`, and `text`.+ `vibe computer force-quit --arg pid=123` uses the target `pid`.- Use `--args-json` for nested values such as `keys` arrays or `urls`; repeated`--arg` values are parsed as JSON when valid. The exact allowlisted fieldvalidation remains in the Controller-owned driver boundary.diff --git a/tests/test_computer_cli.py b/tests/test_computer_cli.pyindex f70453879..02c71e7a1 100644--- a/tests/test_computer_cli.py+++ b/tests/test_computer_cli.py@@ -17,6 +17,7 @@ import pytestfrom core import internal_server, session_turnsfrom core.computer_cli import (+ _COMPUTER_ERROR_I18N_KEYS,COMPUTER_CLI_TOOLS,build_driver_arguments,format_human_result,@@ -33,6 +34,7 @@ from vibe.i18n import t as i18n_tdef _structured(payload: dict) -> dict:return {"isError": False,+ "structuredContent": payload,"content": [{"type": "text",@@ -70,7 +72,7 @@ def test_parser_covers_the_allowlisted_driver_operations_without_session_id() ->(["computer", "clipboard", "read"], ("clipboard", "read")),(["computer", "clipboard", "write"], ("clipboard", "write")),(["computer", "launch"], ("launch",)),- (["computer", "quit"], ("quit",)),+ (["computer", "force-quit"], ("force-quit",)),]parser = cli.build_parser()@@ -87,6 +89,8 @@ def test_parser_covers_the_allowlisted_driver_operations_without_session_id() ->with pytest.raises(SystemExit):parser.parse_args(["computer", "click", "--session-id", "manual"])+ with pytest.raises(SystemExit):+ parser.parse_args(["computer", "quit"])def test_packaged_skill_examples_parse_and_match_the_pinned_driver_schema() -> None:@@ -96,6 +100,8 @@ def test_packaged_skill_examples_parse_and_match_the_pinned_driver_schema() -> Nfor line in skill.splitlines()if line.strip().startswith("vibe computer ")]+ commands.extend(re.findall(r"`(vibe computer [^`]+)`", skill))+ commands = list(dict.fromkeys(commands))snapshot = json.loads(Path("desktop/cua-driver/tools-v0.31.0.json").read_text(encoding="utf-8"))@@ -128,7 +134,6 @@ def test_packaged_skill_examples_parse_and_match_the_pinned_driver_schema() -> Ncovered_tools.add(tool)assert covered_tools == set(COMPUTER_CLI_TOOLS.values())- assert len(commands) == len(COMPUTER_CLI_TOOLS)assert re.findall(r"vibe computer clipboard read[^\n]*",skill,@@ -249,9 +254,76 @@ def test_cmd_computer_binds_the_caller_session_and_prints_structured_result(}payload = json.loads(capsys.readouterr().out)assert payload["session_id"] == "ses-cli"+ assert payload["result"]["structuredContent"]["apps"][0]["name"] == "Fixture"assert payload["result"]["content"][0]["type"] == "text"+def test_computer_cli_error_translations_exist_in_all_supported_languages() -> None:+ keys = {*_COMPUTER_ERROR_I18N_KEYS.values(), "computer.cli.error.screenshotMissing"}+ for catalog_path in sorted(Path("vibe/i18n").glob("*.json")):+ catalog = json.loads(catalog_path.read_text(encoding="utf-8"))+ for key in keys:+ value: object = catalog+ for part in key.split("."):+ assert isinstance(value, dict) and part in value, (+ f"{catalog_path.stem} is missing {key}"+ )+ value = value[part]+ assert isinstance(value, str) and value.strip(), (+ f"{catalog_path.stem} has an empty translation for {key}"+ )+++ ("language", "expected"),+ [+ (+ "en",+ "No screenshot is available for this result. The window may be hidden or "+ "minimized, or capture may be unavailable.",+ ),+ (+ "zh",+ "此结果没有可用的截图。窗口可能已隐藏或最小化,也可能是截图不可用。",+ ),+ ],+)+def test_cmd_computer_localizes_missing_screenshot_error(+ monkeypatch: pytest.MonkeyPatch,+ tmp_path: Path,+ language: str,+ expected: str,+) -> None:+ monkeypatch.setenv("AVIBE_SESSION_ID", "ses-cli")+ monkeypatch.setattr(cli, "_configured_cli_language", lambda: language)++ with patch(+ "vibe.internal_client.computer_use_sync",+ return_value={+ "status_code": 200,+ "body": {+ "ok": True,+ "tool": "get_window_state",+ "result": _structured({"pid": 7, "window_id": 9}),+ },+ },+ ):+ args = cli.build_parser().parse_args(+ [+ "computer",+ "observe",+ "window",+ "--output",+ str(tmp_path / "window.png"),+ ]+ )+ with pytest.raises(cli.TaskCliError) as exc_info:+ cli.cmd_computer(args)++ assert str(exc_info.value) == expected+ assert "computer.cli.error.screenshotMissing" not in str(exc_info.value)++@pytest.mark.parametrize(("argv", "expected_tool", "expected_arguments"),[@@ -312,6 +384,10 @@ def test_cmd_computer_reports_driver_error_before_writing_screenshot("tool": expected_tool,"result": {"isError": True,+ "structuredContent": {+ "code": "desktop_busy",+ "params": {},+ },"content": [{"type": "text",@@ -398,6 +474,13 @@ def test_json_unavailable_error_keeps_code_and_params("tool": "list_apps","result": {"isError": True,+ "structuredContent": {+ "code": "computer_use_unavailable",+ "params": {+ "status": "needs_permission",+ "reason": "screen_recording",+ },+ },"content": [{"type": "text",@@ -424,7 +507,11 @@ def test_json_unavailable_error_keeps_code_and_params()assert cli.cmd_computer(args) == 1- assert json.loads(capsys.readouterr().out) == body+ payload = json.loads(capsys.readouterr().out)+ assert payload["result"]["structuredContent"]["params"]["reason"] == (+ "screen_recording"+ )+ assert payload == bodydef test_cmd_computer_localizes_controller_error_in_zh(diff --git a/tests/test_computer_server.py b/tests/test_computer_server.pyindex ef1a3c9e0..2731c4e7d 100644--- a/tests/test_computer_server.py+++ b/tests/test_computer_server.py@@ -523,7 +523,7 @@ def test_result_folding_preserves_images_and_moves_structured_content() -> None:assert result["content"][0]["type"] == "image"assert result["content"][-1]["type"] == "text"assert '"answer":42' in result["content"][-1]["text"]- assert "structuredContent" not in result+ assert result["structuredContent"] == {"answer": 42}assert "outputSchema" not in result@@ -548,6 +548,7 @@ def test_result_folding_preserves_driver_error_code_params_and_detail() -> None:"detail": "ScreenCaptureKit window was unavailable","params": {"scope": "window"},}+ assert result["structuredContent"] == payloaddef test_result_folding_preserves_bounded_detail_inside_driver_params() -> None:@@ -577,6 +578,7 @@ def test_result_folding_preserves_bounded_detail_inside_driver_params() -> None:},}assert "supersecretvalue123456" not in result["content"][0]["text"]+ assert result["structuredContent"] == payloaddef test_result_folding_preserves_real_driver_exit_code_and_content_detail() -> None:@@ -604,6 +606,7 @@ def test_result_folding_preserves_real_driver_exit_code_and_content_detail() ->"detail": "window ownership lookup failed in the driver","params": {"exit_code": 1},}+ assert result["structuredContent"] == payloaddef test_result_folding_uses_bounded_content_text_for_unstructured_driver_errors() -> None:@@ -625,6 +628,7 @@ def test_result_folding_uses_bounded_content_text_for_unstructured_driver_errors"detail": "driver detail with controls","params": {"tool": "get_window_state"},}+ assert result["structuredContent"] == payloaddef test_result_folding_preserves_json_rpc_error_code_and_detail() -> None:@@ -644,6 +648,7 @@ def test_result_folding_preserves_json_rpc_error_code_and_detail() -> None:"detail": "driver rejected request","params": {"rpc_code": -32001},}+ assert result["structuredContent"] == payloaddef test_diagnostic_text_is_bounded_and_single_line() -> None:@@ -691,6 +696,7 @@ def test_driver_error_detail_redacts_credential_material() -> None:"detail": "capture failed with api_key=[redacted]","params": {"scope": "window"},}+ assert result["structuredContent"] == payloadassert "supersecretvalue123456" not in result["content"][0]["text"]@@ -866,13 +872,7 @@ async def test_real_stdio_proxy_preserves_large_window_state_response(assert result.get("isError") is not Trueimage = next(item for item in result["content"] if item.get("type") == "image")assert len(image["data"]) == 1_200_000- structured_text = next(- item["text"]- for item in result["content"]- if item.get("type") == "text"- and item.get("text", "").startswith("Structured content:\n")- )- payload = json.loads(structured_text.split("\n", 1)[1])+ payload = result["structuredContent"]assert payload["pid"] == 97470assert payload["window_id"] == 6286assert payload["element_count"] == 330diff --git a/vibe/cli.py b/vibe/cli.pyindex 034e212df..73a604336 100644--- a/vibe/cli.py+++ b/vibe/cli.py@@ -826,7 +826,14 @@ def cmd_computer(args) -> int:print(format_human_result(tool, result, translate=translate))return 1- screenshot_path = write_screenshot(tool, result, args.output)+ try:+ screenshot_path = write_screenshot(tool, result, args.output)+ except ComputerCliError as exc:+ raise TaskCliError(+ i18n_t(exc.key, language, **exc.params),+ code="computer_use_screenshot_missing",+ help_command="vibe computer --help",+ ) from excif screenshot_path:body["screenshot_path"] = screenshot_pathif args.json:@@ -17349,7 +17356,7 @@ def build_parser():)computer_subparsers = computer_parser.add_subparsers(dest="computer_command",- metavar="{observe,zoom,click,type,key,hotkey,scroll,drag,set-value,clipboard,launch,quit}",+ metavar="{observe,zoom,click,type,key,hotkey,scroll,drag,set-value,clipboard,launch,force-quit}",)computer_subparsers.required = True@@ -17432,7 +17439,7 @@ def build_parser():("drag", "drag"),("set-value", "setValue"),("launch", "launch"),- ("quit", "quit"),+ ("force-quit", "forceQuit"),):leaf = computer_subparsers.add_parser(name,@@ -19355,7 +19362,7 @@ _CLI_COMMAND_FLOORS: dict[tuple[str, ...], Optional[str]] = {("computer", "clipboard", "read"): "member",("computer", "clipboard", "write"): "member",("computer", "launch"): "member",- ("computer", "quit"): "member",+ ("computer", "force-quit"): "member",# Host scope, not instance scope: these act on this machine's screen and on# authored files, and have no role contract to repair here.("screenshot",): None,diff --git a/vibe/i18n/en.json b/vibe/i18n/en.jsonindex 64ed10bd5..2e58b801c 100644--- a/vibe/i18n/en.json+++ b/vibe/i18n/en.json@@ -874,7 +874,7 @@"drag": "Drag an observed target","setValue": "Set an observed control value","launch": "Launch an application or URL",- "quit": "Quit an application",+ "forceQuit": "Force-terminate an application; unsaved state is lost.","clipboard": "Read or write the system clipboard","clipboardRead": "Read the system clipboard","clipboardWrite": "Write the system clipboard"@@ -887,7 +887,7 @@"sessionArgumentForbidden": "The Computer Use session is bound to the caller's Avibe Session and cannot be supplied through --args-json or --arg.","outputArgumentConflict": "Use --output or screenshot_out_file in --args-json, not both.","unsupportedCommand": "Unsupported Computer Use command: {command}",- "screenshotMissing": "{tool} did not return an image that could be written to --output.",+ "screenshotMissing": "No screenshot is available for this result. The window may be hidden or minimized, or capture may be unavailable.","outputUnsupported": "--output is supported only by observe window or zoom.","missingCallerSession": "Computer Use requires an Avibe Agent caller Session.","missingCallerTurn": "Computer Use requires the caller's Avibe Session to have an active Turn.",diff --git a/vibe/i18n/zh.json b/vibe/i18n/zh.jsonindex 5fb8e1e90..99732205c 100644--- a/vibe/i18n/zh.json+++ b/vibe/i18n/zh.json@@ -874,7 +874,7 @@"drag": "拖动已观察的目标","setValue": "设置已观察控件的值","launch": "启动应用或 URL",- "quit": "退出应用",+ "forceQuit": "强制终止应用;未保存的数据会丢失。","clipboard": "读取或写入系统剪贴板","clipboardRead": "读取系统剪贴板","clipboardWrite": "写入系统剪贴板"@@ -887,7 +887,7 @@"sessionArgumentForbidden": "Computer Use session 已绑定调用方 Avibe Session,不能通过 --args-json 或 --arg 提供。","outputArgumentConflict": "请在 --output 和 --args-json 中的 screenshot_out_file 之间二选一,不能同时提供。","unsupportedCommand": "不支持的 Computer Use 命令:{command}",- "screenshotMissing": "{tool} 没有返回可写入 --output 的图像。",+ "screenshotMissing": "此结果没有可用的截图。窗口可能已隐藏或最小化,也可能是截图不可用。","outputUnsupported": "--output 只支持 observe window 或 zoom。","missingCallerSession": "Computer Use 需要 Avibe Agent 调用方 Session。","missingCallerTurn": "Computer Use 要求调用方 Avibe Session 当前有活动 Turn。",