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 +35 -48
- package/README.zh-CN.md +35 -48
- package/dist/index.cjs +48512 -32777
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -147
- package/dist/index.d.ts +6 -147
- package/dist/index.js +37183 -16116
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-QV36H6BY.js +0 -5325
- package/dist/chunk-QV36H6BY.js.map +0 -1
- package/dist/npm-C6N7BGOG.js +0 -14
- package/dist/npm-C6N7BGOG.js.map +0 -1
package/README.md
CHANGED
|
@@ -2,79 +2,66 @@
|
|
|
2
2
|
|
|
3
3
|
**[English](./README.md)** | **[中文](./README.zh-CN.md)**
|
|
4
4
|
|
|
5
|
-
|
|
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
|
-
##
|
|
16
|
+
## Vite Integration
|
|
14
17
|
|
|
15
|
-
|
|
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
|
-
|
|
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
|
|
32
|
-
|
|
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
|
-
|
|
39
|
-
|
|
40
|
-
A reactive in-memory filesystem that emits change events:
|
|
31
|
+
## xterm Integration
|
|
41
32
|
|
|
42
|
-
|
|
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
|
-
|
|
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 {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
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
|
-
|
|
48
|
+
const session = createBrowserBashSession({ rootPath: "/workspace" })
|
|
49
|
+
const terminal = new Terminal({ convertEol: true, cursorBlink: true })
|
|
50
|
+
const fitAddon = new FitAddon()
|
|
66
51
|
|
|
67
|
-
|
|
52
|
+
terminal.loadAddon(fitAddon)
|
|
53
|
+
terminal.open(container)
|
|
54
|
+
fitAddon.fit()
|
|
68
55
|
|
|
69
|
-
|
|
70
|
-
|
|
56
|
+
void executeBrowserBash(session, "python --version")
|
|
57
|
+
session.setStdoutWriter((data) => terminal.write(data))
|
|
58
|
+
session.setTerminalSize(terminal.cols, terminal.rows)
|
|
71
59
|
|
|
72
|
-
|
|
73
|
-
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
32
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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 {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
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
|
-
|
|
48
|
+
const session = createBrowserBashSession({ rootPath: "/workspace" })
|
|
49
|
+
const terminal = new Terminal({ convertEol: true, cursorBlink: true })
|
|
50
|
+
const fitAddon = new FitAddon()
|
|
66
51
|
|
|
67
|
-
|
|
52
|
+
terminal.loadAddon(fitAddon)
|
|
53
|
+
terminal.open(container)
|
|
54
|
+
fitAddon.fit()
|
|
68
55
|
|
|
69
|
-
|
|
70
|
-
|
|
56
|
+
void executeBrowserBash(session, "python --version")
|
|
57
|
+
session.setStdoutWriter((data) => terminal.write(data))
|
|
58
|
+
session.setTerminalSize(terminal.cols, terminal.rows)
|
|
71
59
|
|
|
72
|
-
|
|
73
|
-
|
|
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
|