agent-web-os 0.1.19 → 0.2.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
@@ -2,79 +2,66 @@
2
2
 
3
3
  **[English](./README.md)** | **[中文](./README.zh-CN.md)**
4
4
 
5
- Browser-based operating system for your agents. Bash + Node.js + Python runtime with an observable in-memory filesystem. Install NPM or PIP packages, run shell commands, execute Node.js scripts, and manage files entirely in the browser — no server required. Supports Claude Code, Codex CLI, and OpenCode.
5
+ A browser-based operating system for AI agents. Full Bash shell, Node.js runtime, and Python 3.11 execution. Observable in-memory filesystem. No server required.
6
6
 
7
7
  ## Install
8
8
 
9
9
  ```bash
10
10
  npm install agent-web-os
11
+ bun add agent-web-os
12
+ pnpm add agent-web-os
13
+ yarn add agent-web-os
11
14
  ```
12
15
 
13
- ## Usage
16
+ ## Vite Integration
14
17
 
15
- ### Bash Session
16
-
17
- Create a full bash session with a virtual filesystem, shell, and Node.js runtime:
18
+ Install `agent-web-os`, create a session in the browser, and execute commands from your component or hook.
18
19
 
19
20
  ```ts
20
- import { createBrowserBashSession } from "agent-web-os"
21
-
22
- const session = createBrowserBashSession({
23
- rootPath: "/workspace",
24
- })
21
+ import { createBrowserBashSession, executeBrowserBash } from "agent-web-os"
25
22
 
26
- // Run shell commands
27
- const result = await executeBrowserBash(session, "echo hello world")
28
- console.log(result.stdout) // "hello world\n"
23
+ const session = createBrowserBashSession({ rootPath: "/workspace" })
29
24
 
30
- // Read/write files through the observable filesystem
31
- session.fs.writeFileSync("/workspace/index.js", 'console.log("hi")')
32
- await executeBrowserBash(session, "node index.js")
33
-
34
- // Clean up
35
- session.dispose()
25
+ export async function runAgentWebOsDemo() {
26
+ const result = await executeBrowserBash(session, "node --version")
27
+ console.log(result.stdout)
28
+ }
36
29
  ```
37
30
 
38
- ### Observable Filesystem
39
-
40
- A reactive in-memory filesystem that emits change events:
31
+ ## xterm Integration
41
32
 
42
- ```ts
43
- import { ObservableInMemoryFs } from "agent-web-os"
44
-
45
- const fs = new ObservableInMemoryFs()
46
-
47
- fs.subscribe((event) => {
48
- console.log(event.event, event.path) // "add", "/hello.txt"
49
- })
33
+ Install xterm separately, attach it to your DOM node, mirror stdout into the terminal, and send keystrokes into `writeStdin` for interactive tools.
50
34
 
51
- fs.writeFileSync("/hello.txt", "world")
35
+ ```bash
36
+ npm install @xterm/xterm @xterm/addon-fit
37
+ bun add @xterm/xterm @xterm/addon-fit
38
+ pnpm add @xterm/xterm @xterm/addon-fit
39
+ yarn add @xterm/xterm @xterm/addon-fit
52
40
  ```
53
41
 
54
- ### Node.js Runtime
55
-
56
- Run Node.js scripts and npm commands in the browser via [almostnode](https://www.npmjs.com/package/almostnode):
57
-
58
42
  ```ts
59
- import { createAlmostNodeSession } from "agent-web-os"
60
-
61
- const nodeSession = createAlmostNodeSession(fs)
62
- // Provides node, npm install, npm run, and Vite dev server support
63
- ```
43
+ import { Terminal } from "@xterm/xterm"
44
+ import { FitAddon } from "@xterm/addon-fit"
45
+ import "@xterm/xterm/css/xterm.css"
46
+ import { createBrowserBashSession, executeBrowserBash } from "agent-web-os"
64
47
 
65
- ### Service Worker Bridge
48
+ const session = createBrowserBashSession({ rootPath: "/workspace" })
49
+ const terminal = new Terminal({ convertEol: true, cursorBlink: true })
50
+ const fitAddon = new FitAddon()
66
51
 
67
- For HTTP server support within the browser, register the service worker:
52
+ terminal.loadAddon(fitAddon)
53
+ terminal.open(container)
54
+ fitAddon.fit()
68
55
 
69
- ```ts
70
- import { getServerBridge } from "agent-web-os"
56
+ void executeBrowserBash(session, "python --version")
57
+ session.setStdoutWriter((data) => terminal.write(data))
58
+ session.setTerminalSize(terminal.cols, terminal.rows)
71
59
 
72
- const bridge = getServerBridge()
73
- await bridge.initServiceWorker()
60
+ terminal.onData((data) => {
61
+ session.writeStdin(data)
62
+ })
74
63
  ```
75
64
 
76
- Copy `node_modules/agent-web-os/dist/__sw__.js` to your public directory so the service worker can be registered.
77
-
78
65
  ## License
79
66
 
80
67
  MIT
package/README.zh-CN.md CHANGED
@@ -2,79 +2,66 @@
2
2
 
3
3
  **[English](./README.md)** | **[中文](./README.zh-CN.md)**
4
4
 
5
- 基于浏览器的 Agent 操作系统。集成 Bash + Node.js + Python 运行时,内置可观测的内存文件系统。支持安装 NPM 或 PIP 包、执行 Shell 命令、运行 Node.js 脚本,并在浏览器中管理文件——无需服务器。兼容 Claude Code、Codex CLI 和 OpenCode。
5
+ 基于浏览器的 AI Agent 操作系统。完整的 Bash Shell、Node.js 运行时和 Python 3.11 执行环境。可观测的内存文件系统。无需服务器。
6
6
 
7
7
  ## 安装
8
8
 
9
9
  ```bash
10
10
  npm install agent-web-os
11
+ bun add agent-web-os
12
+ pnpm add agent-web-os
13
+ yarn add agent-web-os
11
14
  ```
12
15
 
13
- ## 使用方法
16
+ ## Vite 集成
14
17
 
15
- ### Bash 会话
16
-
17
- 创建一个完整的 Bash 会话,包含虚拟文件系统、Shell 和 Node.js 运行时:
18
+ 安装 `agent-web-os`,在浏览器中创建会话,然后从组件或 Hook 中执行命令。
18
19
 
19
20
  ```ts
20
- import { createBrowserBashSession } from "agent-web-os"
21
-
22
- const session = createBrowserBashSession({
23
- rootPath: "/workspace",
24
- })
21
+ import { createBrowserBashSession, executeBrowserBash } from "agent-web-os"
25
22
 
26
- // 执行 Shell 命令
27
- const result = await executeBrowserBash(session, "echo hello world")
28
- console.log(result.stdout) // "hello world\n"
23
+ const session = createBrowserBashSession({ rootPath: "/workspace" })
29
24
 
30
- // 通过可观测文件系统读写文件
31
- session.fs.writeFileSync("/workspace/index.js", 'console.log("hi")')
32
- await executeBrowserBash(session, "node index.js")
33
-
34
- // 清理资源
35
- session.dispose()
25
+ export async function runAgentWebOsDemo() {
26
+ const result = await executeBrowserBash(session, "node --version")
27
+ console.log(result.stdout)
28
+ }
36
29
  ```
37
30
 
38
- ### 可观测文件系统
39
-
40
- 响应式的内存文件系统,支持变更事件监听:
31
+ ## xterm 集成
41
32
 
42
- ```ts
43
- import { ObservableInMemoryFs } from "agent-web-os"
44
-
45
- const fs = new ObservableInMemoryFs()
46
-
47
- fs.subscribe((event) => {
48
- console.log(event.event, event.path) // "add", "/hello.txt"
49
- })
33
+ 单独安装 xterm,将其挂载到 DOM 节点,将 stdout 映射到终端,并将按键输入发送到 `writeStdin` 以支持交互式工具。
50
34
 
51
- fs.writeFileSync("/hello.txt", "world")
35
+ ```bash
36
+ npm install @xterm/xterm @xterm/addon-fit
37
+ bun add @xterm/xterm @xterm/addon-fit
38
+ pnpm add @xterm/xterm @xterm/addon-fit
39
+ yarn add @xterm/xterm @xterm/addon-fit
52
40
  ```
53
41
 
54
- ### Node.js 运行时
55
-
56
- 通过 [almostnode](https://www.npmjs.com/package/almostnode) 在浏览器中运行 Node.js 脚本和 npm 命令:
57
-
58
42
  ```ts
59
- import { createAlmostNodeSession } from "agent-web-os"
60
-
61
- const nodeSession = createAlmostNodeSession(fs)
62
- // 支持 node、npm install、npm run Vite 开发服务器
63
- ```
43
+ import { Terminal } from "@xterm/xterm"
44
+ import { FitAddon } from "@xterm/addon-fit"
45
+ import "@xterm/xterm/css/xterm.css"
46
+ import { createBrowserBashSession, executeBrowserBash } from "agent-web-os"
64
47
 
65
- ### Service Worker 桥接
48
+ const session = createBrowserBashSession({ rootPath: "/workspace" })
49
+ const terminal = new Terminal({ convertEol: true, cursorBlink: true })
50
+ const fitAddon = new FitAddon()
66
51
 
67
- 如需在浏览器中支持 HTTP 服务器,注册 Service Worker:
52
+ terminal.loadAddon(fitAddon)
53
+ terminal.open(container)
54
+ fitAddon.fit()
68
55
 
69
- ```ts
70
- import { getServerBridge } from "agent-web-os"
56
+ void executeBrowserBash(session, "python --version")
57
+ session.setStdoutWriter((data) => terminal.write(data))
58
+ session.setTerminalSize(terminal.cols, terminal.rows)
71
59
 
72
- const bridge = getServerBridge()
73
- await bridge.initServiceWorker()
60
+ terminal.onData((data) => {
61
+ session.writeStdin(data)
62
+ })
74
63
  ```
75
64
 
76
- 将 `node_modules/agent-web-os/dist/__sw__.js` 复制到你的 public 目录,以便注册 Service Worker。
77
-
78
65
  ## 许可证
79
66
 
80
67
  MIT