agent-web-os 0.1.2 → 0.1.4

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 ADDED
@@ -0,0 +1,80 @@
1
+ # agent-web-os
2
+
3
+ **[English](./README.md)** | **[中文](./README.zh-CN.md)**
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.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ npm install agent-web-os
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ ### Bash Session
16
+
17
+ Create a full bash session with a virtual filesystem, shell, and Node.js runtime:
18
+
19
+ ```ts
20
+ import { createBrowserBashSession } from "agent-web-os"
21
+
22
+ const session = createBrowserBashSession({
23
+ rootPath: "/workspace",
24
+ })
25
+
26
+ // Run shell commands
27
+ const result = await executeBrowserBash(session, "echo hello world")
28
+ console.log(result.stdout) // "hello world\n"
29
+
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()
36
+ ```
37
+
38
+ ### Observable Filesystem
39
+
40
+ A reactive in-memory filesystem that emits change events:
41
+
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
+ })
50
+
51
+ fs.writeFileSync("/hello.txt", "world")
52
+ ```
53
+
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
+ ```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
+ ```
64
+
65
+ ### Service Worker Bridge
66
+
67
+ For HTTP server support within the browser, register the service worker:
68
+
69
+ ```ts
70
+ import { getServerBridge } from "agent-web-os"
71
+
72
+ const bridge = getServerBridge()
73
+ await bridge.initServiceWorker()
74
+ ```
75
+
76
+ Copy `node_modules/agent-web-os/dist/__sw__.js` to your public directory so the service worker can be registered.
77
+
78
+ ## License
79
+
80
+ MIT
@@ -0,0 +1,80 @@
1
+ # agent-web-os
2
+
3
+ **[English](./README.md)** | **[中文](./README.zh-CN.md)**
4
+
5
+ 基于浏览器的 Agent 操作系统。集成 Bash + Node.js + Python 运行时,内置可观测的内存文件系统。支持安装 NPM 或 PIP 包、执行 Shell 命令、运行 Node.js 脚本,并在浏览器中管理文件——无需服务器。兼容 Claude Code、Codex CLI 和 OpenCode。
6
+
7
+ ## 安装
8
+
9
+ ```bash
10
+ npm install agent-web-os
11
+ ```
12
+
13
+ ## 使用方法
14
+
15
+ ### Bash 会话
16
+
17
+ 创建一个完整的 Bash 会话,包含虚拟文件系统、Shell 和 Node.js 运行时:
18
+
19
+ ```ts
20
+ import { createBrowserBashSession } from "agent-web-os"
21
+
22
+ const session = createBrowserBashSession({
23
+ rootPath: "/workspace",
24
+ })
25
+
26
+ // 执行 Shell 命令
27
+ const result = await executeBrowserBash(session, "echo hello world")
28
+ console.log(result.stdout) // "hello world\n"
29
+
30
+ // 通过可观测文件系统读写文件
31
+ session.fs.writeFileSync("/workspace/index.js", 'console.log("hi")')
32
+ await executeBrowserBash(session, "node index.js")
33
+
34
+ // 清理资源
35
+ session.dispose()
36
+ ```
37
+
38
+ ### 可观测文件系统
39
+
40
+ 响应式的内存文件系统,支持变更事件监听:
41
+
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
+ })
50
+
51
+ fs.writeFileSync("/hello.txt", "world")
52
+ ```
53
+
54
+ ### Node.js 运行时
55
+
56
+ 通过 [almostnode](https://www.npmjs.com/package/almostnode) 在浏览器中运行 Node.js 脚本和 npm 命令:
57
+
58
+ ```ts
59
+ import { createAlmostNodeSession } from "agent-web-os"
60
+
61
+ const nodeSession = createAlmostNodeSession(fs)
62
+ // 支持 node、npm install、npm run 和 Vite 开发服务器
63
+ ```
64
+
65
+ ### Service Worker 桥接
66
+
67
+ 如需在浏览器中支持 HTTP 服务器,注册 Service Worker:
68
+
69
+ ```ts
70
+ import { getServerBridge } from "agent-web-os"
71
+
72
+ const bridge = getServerBridge()
73
+ await bridge.initServiceWorker()
74
+ ```
75
+
76
+ 将 `node_modules/agent-web-os/dist/__sw__.js` 复制到你的 public 目录,以便注册 Service Worker。
77
+
78
+ ## 许可证
79
+
80
+ MIT