Skip to content

An open-source, faster Devin alternative

TypeScript

feat: simplify CLI session prompt (#591)

Mohamed Habib00c446c32827
diff --git a/cli/README.md b/cli/README.md
index 35f3fba7..c66f57c5 100644
--- a/cli/README.md
+++ b/cli/README.md
@@ -4,8 +4,7 @@ The OpenComputer CLI treats every agent as a normal source repository. A
template creates editable instructions, TypeScript tools, connection
declarations, a sandbox workspace, and committed agent identity.
-[Bun](https://bun.sh/) 1.2 or newer is required. The CLI is still installed
-and published through npm:
+Node.js 22 or newer is required. Install the CLI through npm:
```bash
npm install --global @opencomputer/cli
@@ -69,13 +68,20 @@ opencomputer dev
```
For a terminal-only workflow, `opencomputer session` automatically starts a
-temporary local service when one is not already running and opens an OpenTUI
-multi-turn interface. The service is stopped when the interface exits:
+temporary local service when one is not already running and opens a simple
+multi-turn `User:` / `Agent:` prompt. Type `/exit`, `/quit`, or press Ctrl+C to
+leave. The service is stopped when the prompt exits:
```bash
opencomputer session
```
+Add `--verbose` to retain reasoning, tool, and lifecycle events in the terminal:
+
+```bash
+opencomputer session --verbose
+```
+
Pass a prompt for a single turn. This also starts and stops the service
automatically when needed:
diff --git a/cli/package-lock.json b/cli/package-lock.json
index 6173e58a..5d782c87 100644
--- a/cli/package-lock.json
+++ b/cli/package-lock.json
@@ -1,16 +1,14 @@
{
"name": "@opencomputer/cli",
- "version": "0.3.11",
+ "version": "0.3.12",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "@opencomputer/cli",
- "version": "0.3.11",
+ "version": "0.3.12",
"dependencies": {
"@opencode-ai/sdk": "1.18.4",
- "@opentui/core": "^0.4.5",
- "@opentui/react": "^0.4.5",
"ai": "^7.0.45",
"opencode-ai": "1.18.4",
"react": "^19.2.8"
@@ -31,7 +29,7 @@
"vite": "^8.2.0"
},
"engines": {
- "bun": ">=1.2.0"
+ "node": ">=22.0.0"
}
},
"node_modules/@ai-sdk/gateway": {
@@ -186,157 +184,6 @@
"cross-spawn": "7.0.6"
}
},
- "node_modules/@opentui/core": {
- "version": "0.4.5",
- "resolved": "https://registry.npmjs.org/@opentui/core/-/core-0.4.5.tgz",
- "integrity": "sha512-JsgRTPkA6e+Vxmumxai6SElOSlRQkbzNKHlCfemlArRiLhfC1IZ9RXJo2QH4xSu+uBOWAM90uss73/pPlkdEig==",
- "license": "MIT",
- "dependencies": {
- "bun-ffi-structs": "0.2.4",
- "diff": "9.0.0",
- "marked": "17.0.1",
- "string-width": "7.2.0",
- "strip-ansi": "7.1.2"
- },
- "optionalDependencies": {
- "@opentui/core-darwin-arm64": "0.4.5",
- "@opentui/core-darwin-x64": "0.4.5",
- "@opentui/core-linux-arm64": "0.4.5",
- "@opentui/core-linux-arm64-musl": "0.4.5",
- "@opentui/core-linux-x64": "0.4.5",
- "@opentui/core-linux-x64-musl": "0.4.5",
- "@opentui/core-win32-arm64": "0.4.5",
- "@opentui/core-win32-x64": "0.4.5"
- },
- "peerDependencies": {
- "web-tree-sitter": "0.25.10"
- }
- },
- "node_modules/@opentui/core-darwin-arm64": {
- "version": "0.4.5",
- "resolved": "https://registry.npmjs.org/@opentui/core-darwin-arm64/-/core-darwin-arm64-0.4.5.tgz",
- "integrity": "sha512-8KUG0oRidnR+oW1RSZJ72/PhZLl+qRRMk5U/mieF4c0SJ5V3tYACpBZAKzQfHNd1f7QzD8FHZct1lPpQgtmkWg==",
- "cpu": [
- "arm64"
- ],
- "license": "MIT",
- "optional": true,
- "os": [
- "darwin"
- ]
- },
- "node_modules/@opentui/core-darwin-x64": {
- "version": "0.4.5",
- "resolved": "https://registry.npmjs.org/@opentui/core-darwin-x64/-/core-darwin-x64-0.4.5.tgz",
- "integrity": "sha512-R2bocsg55gwjOqCp/MWFgFYzRmsduKegB6nzgFAPCvAD/L5Jf30xpWJWFlSg3x8vxe1L9WJ84dfqa4M7mZZ3wA==",
- "cpu": [
- "x64"
- ],
- "license": "MIT",
- "optional": true,
- "os": [
- "darwin"
- ]
- },
- "node_modules/@opentui/core-linux-arm64": {
- "version": "0.4.5",
- "resolved": "https://registry.npmjs.org/@opentui/core-linux-arm64/-/core-linux-arm64-0.4.5.tgz",
- "integrity": "sha512-R4MZ25a4CzOAGVjW9aj1hUfzQGVfCJwrwBDbNs2SXaIvzcZqkxCVtU4FoQ5LsaD0j/BdNQVg2CIfFkFsm1fDuQ==",
- "cpu": [
- "arm64"
- ],
- "license": "MIT",
- "optional": true,
- "os": [
- "linux"
- ]
- },
- "node_modules/@opentui/core-linux-arm64-musl": {
- "version": "0.4.5",
- "resolved": "https://registry.npmjs.org/@opentui/core-linux-arm64-musl/-/core-linux-arm64-musl-0.4.5.tgz",
- "integrity": "sha512-ieqdyKI6EIYPalYAETB2wsdP83hr5Ifi+dFnBFUmdEEFHsoKwBmn2S7bsTOYlX7Bg03F4/YPIg+IvRpeC+cUJw==",
- "cpu": [
- "arm64"
- ],
- "libc": [
- "musl"
- ],
- "license": "MIT",
- "optional": true,
- "os": [
- "linux"
- ]
- },
- "node_modules/@opentui/core-linux-x64": {
- "version": "0.4.5",
- "resolved": "https://registry.npmjs.org/@opentui/core-linux-x64/-/core-linux-x64-0.4.5.tgz",
- "integrity": "sha512-SNyuQoxMKI1vuJhgxSSW96adWM6LqFl2SoS3GM4tGeneGOanVVG2Y06PvlytXvF4cKik97t0rqkVMRetmOs93w==",
- "cpu": [
- "x64"
- ],
- "license": "MIT",
- "optional": true,
- "os": [
- "linux"
- ]
- },
- "node_modules/@opentui/core-linux-x64-musl": {
- "version": "0.4.5",
- "resolved": "https://registry.npmjs.org/@opentui/core-linux-x64-musl/-/core-linux-x64-musl-0.4.5.tgz",
- "integrity": "sha512-mKVKcIcPiSVVZZsdPSBoWwoa2/TCeQAaMDeHF7PFw2kt5bTXZPP7xxWfRQLCNIcA1eaGl59UuwUWHDR2Ve548Q==",
- "cpu": [
- "x64"
- ],
- "libc": [
- "musl"
- ],
- "license": "MIT",
- "optional": true,
- "os": [
- "linux"
- ]
- },
- "node_modules/@opentui/core-win32-arm64": {
- "version": "0.4.5",
- "resolved": "https://registry.npmjs.org/@opentui/core-win32-arm64/-/core-win32-arm64-0.4.5.tgz",
- "integrity": "sha512-GHTTsqeR45q2Iek9Rb7ty+x/hAKn2jZ1ujlCgPR8LBKyF7h0E1dNFryoZ7ehMc3kJndP1sKn836IemKFqxuDdQ==",
- "cpu": [
- "arm64"
- ],
- "license": "MIT",
- "optional": true,
- "os": [
- "win32"
- ]
- },
- "node_modules/@opentui/core-win32-x64": {
- "version": "0.4.5",
- "resolved": "https://registry.npmjs.org/@opentui/core-win32-x64/-/core-win32-x64-0.4.5.tgz",
- "integrity": "sha512-Y8T/yXCDGagRGiQrtmuB6AhRcPucKFs/Dre3v8kJwNYqDccI4FzUPKclZ7djfmRZNjl7JUqPhZZP/PwDpQocMg==",
- "cpu": [
- "x64"
- ],
- "license": "MIT",
- "optional": true,
- "os": [
- "win32"
- ]
- },
- "node_modules/@opentui/react": {
- "version": "0.4.5",
- "resolved": "https://registry.npmjs.org/@opentui/react/-/react-0.4.5.tgz",
- "integrity": "sha512-n88Vx0cMmAu++/S14WscjvdcT46IDcxve02jMtcfHQ9j6cySRHfILfGEpOB7xxc8RpCwQceEyOjkKkfzPzm6Jg==",
- "license": "MIT",
- "dependencies": {
- "@opentui/core": "0.4.5",
- "react-reconciler": "^0.33.0"
- },
- "peerDependencies": {
- "react": ">=19.2.0",
- "react-devtools-core": "^7.0.1",
- "ws": "^8.18.0"
- }
- },
"node_modules/@oxc-project/types": {
"version": "0.142.0",
"resolved": "https://registry.npmjs.org/@oxc-project/types/-/types-0.142.0.tgz",
@@ -799,18 +646,6 @@
"zod": "^3.25.76 || ^4.1.8"
}
},
- "node_modules/ansi-regex": {
- "version": "6.2.2",
- "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.2.2.tgz",
- "integrity": "sha512-Bq3SmSpyFHaWjPk8If9yc6svM8c56dB5BAtW4Qbw5jHTwwXXcTLoRMkpDJp6VL0XzlWaCHTXrkFURMYmD0sLqg==",
- "license": "MIT",
- "engines": {
- "node": ">=12"
- },
- "funding": {
- "url": "https://github.com/chalk/ansi-regex?sponsor=1"
- }
- },
"node_modules/bail": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/bail/-/bail-2.0.2.tgz",
@@ -822,15 +657,6 @@
"url": "https://github.com/sponsors/wooorm"
}
},
- "node_modules/bun-ffi-structs": {
- "version": "0.2.4",
- "resolved": "https://registry.npmjs.org/bun-ffi-structs/-/bun-ffi-structs-0.2.4.tgz",
- "integrity": "sha512-AJzsqoVFs1KBbJbWHIYrVZLDC3NhTqqh25awRXqzoLzmBAKr5oqk6+CwuYHAekKx+VBCYVohBoKuRq40dV+TYg==",
- "license": "MIT",
- "peerDependencies": {
- "typescript": "^5"
- }
- },
"node_modules/ccount": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/ccount/-/ccount-2.0.1.tgz",
@@ -984,21 +810,6 @@
"url": "https://github.com/sponsors/wooorm"
}
},
- "node_modules/diff": {
- "version": "9.0.0",
- "resolved": "https://registry.npmjs.org/diff/-/diff-9.0.0.tgz",
- "integrity": "sha512-svtcdpS8CgJyqAjEQIXdb3OjhFVVYjzGAPO8WGCmRbrml64SPw/jJD4GoE98aR7r25A0XcgrK3F02yw9R/vhQw==",
- "license": "BSD-3-Clause",
- "engines": {
- "node": ">=0.3.1"
- }
- },
- "node_modules/emoji-regex": {
- "version": "10.6.0",
- "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-10.6.0.tgz",
- "integrity": "sha512-toUI84YS5YmxW219erniWD0CIVOo46xGKColeNQRgOzDorgBi1v4D71/OFzgD9GO2UGKIv1C3Sp8DAn0+j5w7A==",
- "license": "MIT"
- },
"node_modules/estree-util-is-identifier-name": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/estree-util-is-identifier-name/-/estree-util-is-identifier-name-3.0.0.tgz",
@@ -1059,18 +870,6 @@
"node": "^8.16.0 || ^10.6.0 || >=11.0.0"
}
},
- "node_modules/get-east-asian-width": {
- "version": "1.6.0",
- "resolved": "https://registry.npmjs.org/get-east-asian-width/-/get-east-asian-width-1.6.0.tgz",
- "integrity": "sha512-QRbvDIbx6YklUe6RxeTeleMR0yv3cYH6PsPZHcnVn7xv7zO1BHN8r0XETu8n6Ye3Q+ahtSarc3WgtNWmehIBfA==",
- "license": "MIT",
- "engines": {
- "node": ">=18"
- },
- "funding": {
- "url": "https://github.com/sponsors/sindresorhus"
- }
- },
"node_modules/hast-util-to-jsx-runtime": {
"version": "2.3.6",
"resolved": "https://registry.npmjs.org/hast-util-to-jsx-runtime/-/hast-util-to-jsx-runtime-2.3.6.tgz",
@@ -1499,18 +1298,6 @@
"url": "https://github.com/sponsors/wooorm"
}
},
- "node_modules/marked": {
- "version": "17.0.1",
- "resolved": "https://registry.npmjs.org/marked/-/marked-17.0.1.tgz",
- "integrity": "sha512-boeBdiS0ghpWcSwoNm/jJBwdpFaMnZWRzjA6SkUMYb40SVaN1x7mmfGKp0jvexGcx+7y2La5zRZsYFZI6Qpypg==",
- "license": "MIT",
- "bin": {
- "marked": "bin/marked.js"
- },
- "engines": {
- "node": ">= 20"
- }
- },
"node_modules/mdast-util-find-and-replace": {
"version": "3.0.2",
"resolved": "https://registry.npmjs.org/mdast-util-find-and-replace/-/mdast-util-find-and-replace-3.0.2.tgz",
@@ -2727,39 +2514,6 @@
"node": ">=0.10.0"
}
},
- "node_modules/react-devtools-core": {
- "version": "7.0.1",
- "resolved": "https://registry.npmjs.org/react-devtools-core/-/react-devtools-core-7.0.1.tgz",
- "integrity": "sha512-C3yNvRHaizlpiASzy7b9vbnBGLrhvdhl1CbdU6EnZgxPNbai60szdLtl+VL76UNOt5bOoVTOz5rNWZxgGt+Gsw==",
- "license": "MIT",
- "peer": true,
- "dependencies": {
- "shell-quote": "^1.6.1",
- "ws": "^7"
- }
- },
- "node_modules/react-devtools-core/node_modules/ws": {
- "version": "7.5.13",
- "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.13.tgz",
- "integrity": "sha512-rsKI6xDBFVf4r/x8XyChGK04QR/XHroxs/jUcoWvtEZM8TPU/X/uIY9B1CsSzYws9ZJb/6bbBu7dPhFW00CAoA==",
- "license": "MIT",
- "peer": true,
- "engines": {
- "node": ">=8.3.0"
- },
- "peerDependencies": {
- "bufferutil": "^4.0.1",
- "utf-8-validate": "^5.0.2"
- },
- "peerDependenciesMeta": {
- "bufferutil": {
- "optional": true
- },
- "utf-8-validate": {
- "optional": true
- }
- }
- },
"node_modules/react-dom": {
"version": "19.2.8",
"resolved": "https://registry.npmjs.org/react-dom/-/react-dom-19.2.8.tgz",
@@ -2801,21 +2555,6 @@
"react": ">=18"
}
},
- "node_modules/react-reconciler": {
- "version": "0.33.0",
- "resolved": "https://registry.npmjs.org/react-reconciler/-/react-reconciler-0.33.0.tgz",
- "integrity": "sha512-KetWRytFv1epdpJc3J4G75I4WrplZE5jOL7Yq0p34+OVOKF4Se7WrdIdVC45XsSSmUTlht2FM/fM1FZb1mfQeA==",
- "license": "MIT",
- "dependencies": {
- "scheduler": "^0.27.0"
- },
- "engines": {
- "node": ">=0.10.0"
- },
- "peerDependencies": {
- "react": "^19.2.0"
- }
- },
"node_modules/remark-gfm": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/remark-gfm/-/remark-gfm-4.0.1.tgz",
@@ -2924,6 +2663,7 @@
"version": "0.27.0",
"resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.27.0.tgz",
"integrity": "sha512-eNv+WrVbKu1f3vbYJT/xtiF5syA5HPIMtf9IgY/nKg0sWqzAUEvqY/xm7OcZc/qafLx/iO9FgOmeSAp4v5ti/Q==",
+ "dev": true,
"license": "MIT"
},
"node_modules/shebang-command": {
@@ -2947,19 +2687,6 @@
"node": ">=8"
}
},
- "node_modules/shell-quote": {
- "version": "1.10.0",
- "resolved": "https://registry.npmjs.org/shell-quote/-/shell-quote-1.10.0.tgz",
- "integrity": "sha512-w1aiOKwKuRgtwAReIIj89puqg+I7GvX4IbLrvmhXbzQsj1+Zwi4VO3+fa6ZF91TWSjIxoEkKnMeHcLEODK5ZXA==",
- "license": "MIT",
- "peer": true,
- "engines": {
- "node": ">= 0.4"
- },
- "funding": {
- "url": "https://github.com/sponsors/ljharb"
- }
- },
"node_modules/source-map-js": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz",
@@ -2981,23 +2708,6 @@
"url": "https://github.com/sponsors/wooorm"
}
},
- "node_modules/string-width": {
- "version": "7.2.0",
- "resolved": "https://registry.npmjs.org/string-width/-/string-width-7.2.0.tgz",
- "integrity": "sha512-tsaTIkKW9b4N+AEj+SVA+WhJzV7/zMhcSu78mLKWSk7cXMOSHsBKFWUs0fWwq8QyK3MgJBQRX6Gbi4kYbdvGkQ==",
- "license": "MIT",
- "dependencies": {
- "emoji-regex": "^10.3.0",
- "get-east-asian-width": "^1.0.0",
- "strip-ansi": "^7.1.0"
- },
- "engines": {
- "node": ">=18"
- },
- "funding": {
- "url": "https://github.com/sponsors/sindresorhus"
- }
- },
"node_modules/stringify-entities": {
"version": "4.0.4",
"resolved": "https://registry.npmjs.org/stringify-entities/-/stringify-entities-4.0.4.tgz",
@@ -3013,21 +2723,6 @@
"url": "https://github.com/sponsors/wooorm"
}
},
- "node_modules/strip-ansi": {
- "version": "7.1.2",
- "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.1.2.tgz",
- "integrity": "sha512-gmBGslpoQJtgnMAvOVqGZpEz9dyoKTCzy2nfz/n8aIFhN/jCE/rCmcxabB6jOOHV+0WNnylOxaxBQPSvcWklhA==",
- "license": "MIT",
- "dependencies": {
- "ansi-regex": "^6.0.1"
- },
- "engines": {
- "node": ">=12"
- },
- "funding": {
- "url": "https://github.com/chalk/strip-ansi?sponsor=1"
- }
- },
"node_modules/style-to-js": {
"version": "1.1.21",
"resolved": "https://registry.npmjs.org/style-to-js/-/style-to-js-1.1.21.tgz",
@@ -3126,6 +2821,7 @@
"version": "5.9.3",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz",
"integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==",
+ "dev": true,
"license": "Apache-2.0",
"bin": {
"tsc": "bin/tsc",
@@ -3362,21 +3058,6 @@
}
}
},
- "node_modules/web-tree-sitter": {
- "version": "0.25.10",
- "resolved": "https://registry.npmjs.org/web-tree-sitter/-/web-tree-sitter-0.25.10.tgz",
- "integrity": "sha512-Y09sF44/13XvgVKgO2cNDw5rGk6s26MgoZPXLESvMXeefBf7i6/73eFurre0IsTW6E14Y0ArIzhUMmjoc7xyzA==",
- "license": "MIT",
- "peer": true,
- "peerDependencies": {
- "@types/emscripten": "^1.40.0"
- },
- "peerDependenciesMeta": {
- "@types/emscripten": {
- "optional": true
- }
- }
- },
"node_modules/which": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",
@@ -3392,28 +3073,6 @@
"node": ">= 8"
}
},
- "node_modules/ws": {
- "version": "8.21.1",
- "resolved": "https://registry.npmjs.org/ws/-/ws-8.21.1.tgz",
- "integrity": "sha512-+0NTnW77fFN/DjQi6k/Sq/Yvk4Sgajw7urW8V+asjXnRgDs9gyGkdb7EzgfhA4goXsRIZKE28fzIXBHEzhuiWw==",
- "license": "MIT",
- "peer": true,
- "engines": {
- "node": ">=10.0.0"
- },
- "peerDependencies": {
- "bufferutil": "^4.0.1",
- "utf-8-validate": ">=5.0.2"
- },
- "peerDependenciesMeta": {
- "bufferutil": {
- "optional": true
- },
- "utf-8-validate": {
- "optional": true
- }
- }
- },
"node_modules/zod": {
"version": "4.4.3",
"resolved": "https://registry.npmjs.org/zod/-/zod-4.4.3.tgz",
diff --git a/cli/package.json b/cli/package.json
index 1247aee6..3fd6f699 100644
--- a/cli/package.json
+++ b/cli/package.json
@@ -1,6 +1,6 @@
{
"name": "@opencomputer/cli",
- "version": "0.3.11",
+ "version": "0.3.12",
"description": "Build, test, connect, deploy, and share OpenComputer agents as code.",
"type": "module",
"bin": {
@@ -11,14 +11,15 @@
"README.md"
],
"scripts": {
+ "clean": "node -e \"require('node:fs').rmSync('dist',{recursive:true,force:true})\"",
"build:server": "tsc -p tsconfig.json",
"build:ui": "tsc -p tsconfig.ui.json --noEmit && vite build",
- "build": "npm run build:server && npm run build:ui",
+ "build": "npm run clean && npm run build:server && npm run build:ui",
"test": "npm run build && node --test dist/*.test.js",
"prepack": "npm test"
},
"engines": {
- "bun": ">=1.2.0"
+ "node": ">=22.0.0"
},
"publishConfig": {
"access": "public"
@@ -35,8 +36,6 @@
],
"dependencies": {
"@opencode-ai/sdk": "1.18.4",
- "@opentui/core": "^0.4.5",
- "@opentui/react": "^0.4.5",
"ai": "^7.0.45",
"opencode-ai": "1.18.4",
"react": "^19.2.8"
diff --git a/cli/src/commands.ts b/cli/src/commands.ts
index e2f90f3d..4dcf61e2 100644
--- a/cli/src/commands.ts
+++ b/cli/src/commands.ts
@@ -33,6 +33,7 @@ export interface GlobalOptions {
apiUrl?: string;
apiKey?: string;
json: boolean;
+ verbose?: boolean;
}
function printJSON(value: unknown): void {
@@ -542,7 +543,9 @@ export async function runCommand(
const useRemote = remote || Boolean(agentOption) || action !== "create";
if (!useRemote) {
const prompt = args.join(" ").trim();
- await runLocalAgent(prompt ? ["run", prompt] : ["shell"], config);
+ await runLocalAgent(prompt ? ["run", prompt] : ["shell"], config, {
+ verbose: globals.verbose,
+ });
return;
}
if (action === "list") {
diff --git a/cli/src/index.ts b/cli/src/index.ts
index 854ce7d7..1b5bb38f 100644
--- a/cli/src/index.ts
+++ b/cli/src/index.ts
@@ -1,8 +1,8 @@
-#!/usr/bin/env bun
+#!/usr/bin/env node
import { runCommand, type GlobalOptions } from "./commands.js";
-const VERSION = "0.3.11";
+const VERSION = "0.3.12";
const BANNER = String.raw` ____ ______ __
/ __ \____ ___ ____ / ____/___ ____ ___ ____ __ / /____ _____
@@ -63,6 +63,7 @@ Global options:
--api-url <url> OpenComputer API (default: https://app.opencomputer.dev)
--api-key <key> API key (or OPENCOMPUTER_API_KEY)
--json Print machine-readable output
+ --verbose Print session events
--help Show this help
--version Show the CLI version
`);
@@ -82,6 +83,7 @@ async function main(): Promise<void> {
apiUrl: takeOption(args, "--api-url"),
apiKey: takeOption(args, "--api-key"),
json: takeFlag(args, "--json"),
+ verbose: takeFlag(args, "--verbose"),
};
const command = args.shift();
if (!command) {
diff --git a/cli/src/local.ts b/cli/src/local.ts
index fdaa1fe5..ecbc2d19 100644
--- a/cli/src/local.ts
+++ b/cli/src/local.ts
@@ -22,6 +22,10 @@ import { fileURLToPath } from "node:url";
import type { ResolvedConfig } from "./config.js";
import { renderDevUI } from "./dev-ui.js";
import { findAgentRoot, prepareAgent, readManifest } from "./project.js";
+import {
+ formatSessionEvent,
+ runSessionPrompt,
+} from "./session-prompt.js";
interface DevState {
version: 3;
@@ -891,13 +895,16 @@ async function ensureDevService(
throw new Error("Timed out starting the local development service");
}
-async function runSessionShell(config: ResolvedConfig): Promise<void> {
+async function runSessionShell(
+ config: ResolvedConfig,
+ verbose: boolean,
+): Promise<void> {
const target = await ensureDevService(config);
try {
const manifest = await readManifest(target.state.agentRoot);
- const { runSessionTUI } = await import("./tui.js");
- await runSessionTUI({
+ await runSessionPrompt({
agentName: manifest.name,
+ verbose,
send: (prompt, sessionId, emit) =>
runLocalSession(prompt, target.state, sessionId, emit),
});
@@ -909,10 +916,23 @@ async function runSessionShell(config: ResolvedConfig): Promise<void> {
async function runOneShotSession(
prompt: string,
config: ResolvedConfig,
+ verbose: boolean,
): Promise<void> {
const target = await ensureDevService(config);
try {
- await runLocalSession(prompt, target.state);
+ let streamedText = false;
+ await runLocalSession(prompt, target.state, undefined, (event) => {
+ if (event.type === "message.delta") {
+ streamedText = true;
+ process.stdout.write(String(event.data.text ?? ""));
+ } else if (event.type === "message.completed") {
+ if (!streamedText) process.stdout.write(String(event.data.text ?? ""));
+ } else if (verbose) {
+ const formatted = formatSessionEvent(event);
+ if (formatted) process.stderr.write(`${formatted}\n`);
+ }
+ });
+ process.stdout.write("\n");
} finally {
await stopOwnedDev(target.owned);
}
@@ -921,6 +941,7 @@ async function runOneShotSession(
export async function runLocalAgent(
args: string[],
config: ResolvedConfig,
+ options: { verbose?: boolean } = {},
): Promise<void> {
if (args[0] === "dev") {
if (args.length > 1) throw new Error(`Unexpected local argument: ${args[1]}`);
@@ -930,12 +951,12 @@ export async function runLocalAgent(
if (args[0] === "run") {
const prompt = args.slice(1).join(" ").trim();
if (!prompt) throw new Error("A prompt is required");
- await runOneShotSession(prompt, config);
+ await runOneShotSession(prompt, config, options.verbose === true);
return;
}
if (args[0] === "shell") {
if (args.length > 1) throw new Error(`Unexpected local argument: ${args[1]}`);
- await runSessionShell(config);
+ await runSessionShell(config, options.verbose === true);
return;
}
throw new Error(`Unexpected local argument: ${args[0] ?? "none"}`);
diff --git a/cli/src/session-prompt.test.ts b/cli/src/session-prompt.test.ts
new file mode 100644
index 00000000..408533a1
--- /dev/null
+++ b/cli/src/session-prompt.test.ts
@@ -0,0 +1,119 @@
+import assert from "node:assert/strict";
+import { Readable, PassThrough } from "node:stream";
+import test from "node:test";
+
+import { runSessionPrompt } from "./session-prompt.js";
+
+test("session prompt renders a simple multi-turn transcript", async () => {
+ const input = Readable.from(["hello\nagain\n/exit\n"]);
+ const output = new PassThrough();
+ output.setEncoding("utf8");
+ let rendered = "";
+ output.on("data", (chunk: string) => {
+ rendered += chunk;
+ });
+ const sessions: Array<string | undefined> = [];
+
+ await runSessionPrompt({
+ agentName: "Email triage",
+ input,
+ output,
+ send: async (prompt, sessionId, emit) => {
+ sessions.push(sessionId);
+ if (prompt === "hello") {
+ emit({ type: "message.delta", data: { text: "Hi" } });
+ emit({ type: "message.delta", data: { text: " there" } });
+ return "session-1";
+ }
+ emit({ type: "message.completed", data: { text: "Welcome back" } });
+ return "session-1";
+ },
+ });
+
+ assert.deepEqual(sessions, [undefined, "session-1"]);
+ assert.equal(
+ rendered,
+ "OpenComputer session — Email triage\n" +
+ "Type /exit or /quit to leave.\n\n" +
+ "User: hello\n" +
+ "Agent: Hi there\n\n" +
+ "User: again\n" +
+ "Agent: Welcome back\n\n" +
+ "User: /exit\n\n",
+ );
+});
+
+test("session prompt reports a failed turn and keeps reading", async () => {
+ const input = Readable.from(["fail\n/quit\n"]);
+ const output = new PassThrough();
+ output.setEncoding("utf8");
+ let rendered = "";
+ output.on("data", (chunk: string) => {
+ rendered += chunk;
+ });
+
+ await runSessionPrompt({
+ agentName: "Test agent",
+ input,
+ output,
+ send: async () => {
+ throw new Error("request failed");
+ },
+ });
+
+ assert.match(rendered, /Agent: Error: request failed\n\nUser:/);
+});
+
+test("session prompt shows a lightweight spinner on interactive output", async () => {
+ const input = Readable.from(["hello\n/exit\n"]);
+ const output = Object.assign(new PassThrough(), { isTTY: true });
+ output.setEncoding("utf8");
+ let rendered = "";
+ output.on("data", (chunk: string) => {
+ rendered += chunk;
+ });
+
+ await runSessionPrompt({
+ agentName: "Test agent",
+ input,
+ output,
+ send: async (_prompt, _sessionId, emit) => {
+ emit({ type: "message.completed", data: { text: "Hello" } });
+ return "session-1";
+ },
+ });
+
+ assert.ok(rendered.includes("Agent: ⠋\b \bHello"));
+});
+
+test("session prompt prints non-message events only in verbose mode", async () => {
+ const input = Readable.from(["hello\n/exit\n"]);
+ const output = new PassThrough();
+ output.setEncoding("utf8");
+ let rendered = "";
+ output.on("data", (chunk: string) => {
+ rendered += chunk;
+ });
+
+ await runSessionPrompt({
+ agentName: "Test agent",
+ verbose: true,
+ input,
+ output,
+ send: async (_prompt, _sessionId, emit) => {
+ emit({ type: "session.created", data: { sessionId: "session-1" } });
+ emit({
+ type: "tool.started",
+ data: { tool: "gmail_search", input: { query: "unread" } },
+ });
+ emit({ type: "tool.completed", data: { tool: "gmail_search" } });
+ emit({ type: "message.completed", data: { text: "Found two emails" } });
+ return "session-1";
+ },
+ });
+
+ assert.match(rendered, /Event: session\.created/);
+ assert.match(rendered, /Event: tool\.started/);
+ assert.match(rendered, /Event: tool\.completed/);
+ assert.match(rendered, /Agent: Found two emails/);
+});
diff --git a/cli/src/session-prompt.ts b/cli/src/session-prompt.ts
new file mode 100644
index 00000000..86dd03d8
--- /dev/null
+++ b/cli/src/session-prompt.ts
@@ -0,0 +1,117 @@
+import { createInterface } from "node:readline";
+import type { Readable, Writable } from "node:stream";
+
+export interface SessionPromptEvent {
+ type: string;
+ data: Record<string, unknown>;
+}
+
+interface SessionPromptOptions {
+ agentName: string;
+ verbose?: boolean;
+ input?: Readable;
+ output?: Writable;
+ send(
+ prompt: string,
+ sessionId: string | undefined,
+ emit: (event: SessionPromptEvent) => void,
+ ): Promise<string>;
+}
+
+export function formatSessionEvent(
+ event: SessionPromptEvent,
+): string | undefined {
+ if (event.type === "message.delta" || event.type === "message.completed") {
+ return undefined;
+ }
+ return `Event: ${event.type} ${JSON.stringify(event.data)}`;
+}
+
+const spinnerFrames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"];
+
+function startSpinner(output: Writable, enabled: boolean): () => void {
+ if (!enabled) return () => undefined;
+ let frame = 0;
+ let stopped = false;
+ output.write(spinnerFrames[frame]);
+ const timer = setInterval(() => {
+ frame = (frame + 1) % spinnerFrames.length;
+ output.write(`\b${spinnerFrames[frame]}`);
+ }, 80);
+ timer.unref();
+
+ return () => {
+ if (stopped) return;
+ stopped = true;
+ clearInterval(timer);
+ output.write("\b \b");
+ };
+}
+
+export async function runSessionPrompt(
+ options: SessionPromptOptions,
+): Promise<void> {
+ const input = options.input ?? process.stdin;
+ const output = options.output ?? process.stdout;
+ const terminal = "isTTY" in input && input.isTTY === true;
+ const lines = createInterface({ input, output, terminal, crlfDelay: Infinity });
+ lines.on("SIGINT", () => lines.close());
+
+ output.write(
+ `OpenComputer session — ${options.agentName}\n` +
+ "Type /exit or /quit to leave.\n\n" +
+ "User: ",
+ );
+
+ let sessionId: string | undefined;
+ try {
+ for await (const line of lines) {
+ if (!terminal) output.write(`${line}\n`);
+ const prompt = line.trim();
+ if (prompt === "/exit" || prompt === "/quit") break;
+ if (!prompt) {
+ output.write("User: ");
+ continue;
+ }
+
+ output.write("Agent: ");
+ const stopSpinner = startSpinner(
+ output,
+ "isTTY" in output && output.isTTY === true,
+ );
+ let streamedText = false;
+ let printedEvents = false;
+ try {
+ sessionId = await options.send(prompt, sessionId, (event) => {
+ if (event.type === "message.delta") {
+ stopSpinner();
+ if (printedEvents && !streamedText) output.write("Agent: ");
+ streamedText = true;
+ output.write(String(event.data.text ?? ""));
+ } else if (event.type === "message.completed" && !streamedText) {
+ stopSpinner();
+ if (printedEvents) output.write("Agent: ");
+ output.write(String(event.data.text ?? ""));
+ } else if (options.verbose) {
+ const formatted = formatSessionEvent(event);
+ if (!formatted) return;
+ stopSpinner();
+ if (!printedEvents) output.write("\n");
+ printedEvents = true;
+ output.write(`${formatted}\n`);
+ }
+ });
+ } catch (error: unknown) {
+ stopSpinner();
+ output.write(
+ `Error: ${error instanceof Error ? error.message : String(error)}`,
+ );
+ }
+ stopSpinner();
+ output.write("\n\nUser: ");
+ }
+ } finally {
+ lines.close();
+ output.write("\n");
+ }
+}
diff --git a/cli/src/tui.tsx b/cli/src/tui.tsx
deleted file mode 100644
index eabfa6d3..00000000
--- a/cli/src/tui.tsx
+++ /dev/null
@@ -1,280 +0,0 @@
-/** @jsxImportSource @opentui/react */
-
-import { createCliRenderer, SyntaxStyle } from "@opentui/core";
-import { createRoot, useKeyboard } from "@opentui/react";
-import { useCallback, useEffect, useState } from "react";
-
-export interface TuiEvent {
- type: string;
- data: Record<string, unknown>;
-}
-
-interface ToolState {
- id: string;
- name: string;
- title?: string;
- status: "running" | "completed" | "failed";
-}
-
-interface Turn {
- id: string;
- role: "user" | "assistant";
- text: string;
- reasoning: string;
- tools: ToolState[];
- active: boolean;
- error?: string;
-}
-
-interface AppProps {
- agentName: string;
- send(
- prompt: string,
- sessionId: string | undefined,
- emit: (event: TuiEvent) => void,
- ): Promise<string>;
- exit(): void;
-}
-
-const markdownStyle = SyntaxStyle.fromStyles({
- default: { fg: "#e5e5df" },
- "markup.heading": { fg: "#f1f1ea", bold: true },
- "markup.strong": { fg: "#f1f1ea", bold: true },
- "markup.italic": { fg: "#c8c8c0", italic: true },
- "markup.list": { fg: "#8fb99a" },
- "markup.raw": { fg: "#d5b87a" },
- "markup.raw.block": { fg: "#d5b87a", bg: "#1b1b19" },
- "markup.link": { fg: "#8fb99a" },
- "markup.link.label": { fg: "#8fb99a", underline: true },
- "markup.link.url": { fg: "#77776f", dim: true },
- "markup.quote": { fg: "#a8a8a0", italic: true },
-});
-
-function SessionApp({ agentName, send, exit }: AppProps) {
- const [turns, setTurns] = useState<Turn[]>([]);
- const [sessionId, setSessionId] = useState<string>();
- const [input, setInput] = useState("");
- const [busy, setBusy] = useState(false);
- const [spinnerIndex, setSpinnerIndex] = useState(0);
- const spinner = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"];
-
- useEffect(() => {
- if (!busy) {
- setSpinnerIndex(0);
- return;
- }
- const timer = setInterval(
- () => setSpinnerIndex((current) => (current + 1) % spinner.length),
- 90,
- );
- return () => clearInterval(timer);
- }, [busy, spinner.length]);
-
- useKeyboard((key) => {
- if (key.ctrl && !key.shift && key.name === "c") exit();
- });
-
- const updateAssistant = useCallback(
- (id: string, update: (turn: Turn) => Turn) => {
- setTurns((current) =>
- current.map((turn) => (turn.id === id ? update(turn) : turn)),
- );
- },
- [],
- );
-
- const submit = (value: string): void => {
- const prompt = value.trim();
- if (!prompt || busy) return;
- if (prompt === "/exit" || prompt === "/quit") {
- exit();
- return;
- }
- setInput("");
- setBusy(true);
- const userId = crypto.randomUUID();
- const assistantId = crypto.randomUUID();
- setTurns((current) => [
- ...current,
- {
- id: userId,
- role: "user",
- text: prompt,
- reasoning: "",
- tools: [],
- active: false,
- },
- {
- id: assistantId,
- role: "assistant",
- text: "",
- reasoning: "",
- tools: [],
- active: true,
- },
- ]);
-
- const emit = (event: TuiEvent): void => {
- updateAssistant(assistantId, (turn) => {
- if (event.type === "message.delta") {
- return { ...turn, text: turn.text + String(event.data.text ?? "") };
- }
- if (event.type === "message.completed") {
- return { ...turn, text: String(event.data.text ?? turn.text) };
- }
- if (event.type === "reasoning.delta") {
- return {
- ...turn,
- reasoning: turn.reasoning + String(event.data.text ?? ""),
- };
- }
- if (event.type.startsWith("tool.")) {
- const id = String(event.data.callId ?? event.data.tool ?? "tool");
- const previous = turn.tools.find((item) => item.id === id);
- const eventName =
- typeof event.data.tool === "string" ? event.data.tool.trim() : "";
- const eventTitle =
- typeof event.data.title === "string" ? event.data.title.trim() : "";
- const status =
- event.type === "tool.completed"
- ? "completed"
- : event.type === "tool.failed"
- ? "failed"
- : "running";
- const tool: ToolState = {
- id,
- name: eventName || previous?.name || "tool",
- title: eventTitle || previous?.title,
- status,
- };
- const existing = turn.tools.findIndex((item) => item.id === id);
- const tools = [...turn.tools];
- if (existing === -1) tools.push(tool);
- else tools[existing] = { ...tools[existing]!, ...tool };
- return { ...turn, tools };
- }
- return turn;
- });
- };
-
- void send(prompt, sessionId, emit)
- .then((nextSessionId) => setSessionId(nextSessionId))
- .catch((error: unknown) => {
- updateAssistant(assistantId, (turn) => ({
- ...turn,
- error: error instanceof Error ? error.message : String(error),
- }));
- })
- .finally(() => {
- updateAssistant(assistantId, (turn) => ({ ...turn, active: false }));
- setBusy(false);
- });
- };
-
- return (
- <box style={{ width: "100%", height: "100%", flexDirection: "column", backgroundColor: "#11110f" }}>
- <box style={{ height: 3, paddingX: 2, flexDirection: "row", alignItems: "center", border: ["bottom"], borderColor: "#34342f" }}>
- <text fg="#f0f0e9"><strong>OpenComputer</strong></text>
- <text fg="#787870"> / {agentName}</text>
- <box style={{ flexGrow: 1 }} />
- <text fg={busy ? "#d2aa62" : "#69aa7c"}>
- {busy ? spinner[spinnerIndex] : "●"}
- </text>
- <text fg="#85857d"> {busy ? "working" : "local"}</text>
- </box>
-
- <scrollbox
- style={{ flexGrow: 1, paddingX: 2, paddingY: 1 }}
- stickyScroll
- stickyStart="bottom"
- >
- {!turns.length && (
- <box style={{ flexDirection: "column", paddingTop: 2 }}>
- <ascii-font
- text="opencomputer"
- font="tiny"
- color={["#f1f1ea", "#8fb99a"]}
- selectable={false}
- style={{ marginBottom: 1 }}
- />
- <text fg="#e6e6df"><strong>Test your agent locally</strong></text>
- <text fg="#77776f">Send a message below. Connected tools are proxied through OpenComputer.</text>
- </box>
- )}
- {turns.map((turn) => (
- <box key={turn.id} style={{ flexDirection: "column", marginBottom: 1 }}>
- <text fg={turn.role === "user" ? "#999991" : "#6fa981"}>
- <strong>{turn.role === "user" ? "YOU" : agentName.toUpperCase()}</strong>
- </text>
- {turn.role === "assistant" && (turn.reasoning || turn.tools.length > 0) && (
- <box style={{ flexDirection: "column", marginTop: 1, marginBottom: turn.text ? 0 : 1 }}>
- {turn.active && !turn.text ? (
- <>
- {turn.reasoning && <text fg="#6f6f68">{turn.reasoning}</text>}
- {turn.tools.map((tool) => (
- <text key={tool.id} fg={tool.status === "failed" ? "#b66b6b" : "#77776f"}>
- {tool.status === "completed" ? "✓" : tool.status === "failed" ? "×" : "○"} {tool.title || tool.name}
- </text>
- ))}
- </>
- ) : (
- <text fg="#66665f">✓ {turn.tools.length ? `${turn.tools.length} tool ${turn.tools.length === 1 ? "call" : "calls"}` : "thought process"}</text>
- )}
- </box>
- )}
- {turn.role === "assistant" &&
- turn.active &&
- !turn.text &&
- !turn.reasoning &&
- turn.tools.length === 0 && (
- <text fg="#77776f">{spinner[spinnerIndex]} Agent is working…</text>
- )}
- {turn.text && (
- <markdown
- content={turn.text}
- syntaxStyle={markdownStyle}
- conceal
- concealCode
- streaming={turn.active}
- internalBlockMode="top-level"
- style={{ width: "100%" }}
- />
- )}
- {turn.error && <text fg="#d27777">Error: {turn.error}</text>}
- </box>
- ))}
- </scrollbox>
-
- <box style={{ height: 3, marginX: 2, marginBottom: 1, paddingX: 1, flexDirection: "row", border: true, borderColor: busy ? "#3b3b36" : "#62625b", alignItems: "center" }}>
- <text fg="#77776f">› </text>
- <input
- style={{ flexGrow: 1, width: "100%" }}
- value={input}
- placeholder={busy ? "Agent is working…" : `Message ${agentName}`}
- focused={!busy}
- onInput={setInput}
- onSubmit={submit as never}
- />
- </box>
- <box style={{ height: 1, paddingX: 2 }}>
- <text fg="#575751">Enter send · Drag select · Ctrl+Shift+C copy · Ctrl+C quit</text>
- </box>
- </box>
- );
-}
-
-export async function runSessionTUI(options: Omit<AppProps, "exit">): Promise<void> {
- const renderer = await createCliRenderer({ exitOnCtrlC: false });
- const root = createRoot(renderer);
- await new Promise<void>((done) => {
- let finished = false;
- const exit = (): void => {
- if (finished) return;
- finished = true;
- done();
- };
- root.render(<SessionApp {...options} exit={exit} />);
- });
- root.unmount();
- renderer.destroy();
-}