ohmyvibe 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/.env.example CHANGED
@@ -1,2 +1,2 @@
1
- MANAGEMENT_SERVER_URL=http://localhost:3310
2
- DAEMON_NAME=ohmyvibe-local
1
+ MANAGEMENT_SERVER_URL=http://localhost:3310
2
+ DAEMON_NAME=ohmyvibe-local
package/README.md CHANGED
@@ -1,249 +1,249 @@
1
- # OhMyVibe
2
-
3
- 这是一个 `VibeCoding` 控制台:
4
-
5
- - `daemon -> control server <- browser` 架构(daemon 主动连接管理端)
6
- - 每个会话独立启动一个 `codex app-server` 子进程
7
- - daemon 统一管理多会话、消息发送、中断、状态同步
8
- - 额外提供一个标准 `ACP` bridge 入口,方便后续给编辑器或其他 ACP client 接入
9
- - 应用侧 session 本地持久化到 `data/sessions.json`
10
- - 支持从 Codex 历史 `~/.codex/sessions` 恢复会话,并绑定到原始 Codex thread
11
- - Web 控制台为独立 React + shadcn 风格项目,浏览器只连接管理端
12
-
13
- ## 为什么这样做
14
-
15
- 当前官方能力里,`Codex CLI` 暴露的是 `app-server` 自动化接口,而不是原生 `ACP agent`。因此这个 MVP 采用两层桥接:
16
-
17
- 1. 南向:daemon 通过 `codex app-server --listen stdio://` 控制 Codex
18
- 2. 北向:daemon 自己暴露 `ACP` 兼容 agent,供外部 ACP client 使用
19
-
20
- 这能保证现在就能正确接入 Codex,同时不把上层协议绑死在 Codex 私有接口上。
21
-
22
- ## 运行
23
-
24
- 要求:
25
-
26
- - Node.js 22+
27
- - 本机已安装并可运行 `codex`
28
- - `codex` 已完成登录
29
-
30
- 1. 启动 Web 管理端(API + 页面):
31
-
32
- ```bash
33
- npm install
34
- npm --prefix web install
35
- npm --prefix web run build
36
- npm run web:server
37
- ```
38
-
39
- 默认监听 `http://localhost:3310`
40
- 默认读取 `web/.env`
41
-
42
- 2. 在被控机器启动 daemon,并主动连接管理端:
43
-
44
- ```bash
45
- npm run daemon
46
- ```
47
-
48
- daemon 不再暴露本地 HTTP API,浏览器也不应直接连接 daemon。
49
- 默认读取根目录 `.env`
50
-
51
- 可选环境变量:
52
-
53
- - `DAEMON_ID`:固定 daemon 标识
54
- - `DAEMON_NAME`:展示名称
55
-
56
- 3. 浏览器访问管理端页面:
57
-
58
- ```bash
59
- http://your-control-host:3310
60
- ```
61
-
62
- 开发模式(前端热更新):
63
-
64
- ```bash
65
- npm run web:dev
66
- ```
67
-
68
- 启动 ACP bridge:
69
-
70
- ```bash
71
- npm run acp
72
- ```
73
-
74
- ## 使用示例
75
-
76
- ### 示例 1:本机快速跑通
77
-
78
- 先启动控制端:
79
-
80
- ```bash
81
- git clone https://github.com/gaoyu06/OhMyVibe.git
82
- cd OhMyVibe
83
- npm install
84
- npm --prefix web install
85
- npm --prefix web run build
86
- npm run web:server
87
- ```
88
-
89
- 再在另一台机器或另一个终端启动 daemon:
90
-
91
- ```bash
92
- cp .env.example .env
93
- ```
94
-
95
- `.env`:
96
-
97
- ```env
98
- MANAGEMENT_SERVER_URL=http://localhost:3310
99
- DAEMON_NAME=ohmyvibe-local
100
- ```
101
-
102
- 启动:
103
-
104
- ```bash
105
- npm run daemon
106
- ```
107
-
108
- 浏览器访问:
109
-
110
- ```text
111
- http://localhost:3310
112
- ```
113
-
114
- ### 示例 2:通过 npm 全局安装 daemon
115
-
116
- 如果你只想安装被控端 daemon,可以直接安装 npm 包:
117
-
118
- ```bash
119
- npm install -g ohmyvibe
120
- ```
121
-
122
- 然后直接连接到你的控制端:
123
-
124
- ```bash
125
- ohmyvibe --management-server-url http://your-control-host:3310
126
- ```
127
-
128
- 也可以显式指定 daemon 名称或 id:
129
-
130
- ```bash
131
- ohmyvibe daemon ^
132
- --management-server-url http://your-control-host:3310 ^
133
- --daemon-name office-win ^
134
- --daemon-id office-win-01
135
- ```
136
-
137
- 说明:
138
-
139
- - 当前 npm 包主要提供 `daemon` / `acp` CLI
140
- - Web 控制服务端目前仍建议直接从仓库部署
141
-
142
- ## 服务端部署示例
143
-
144
- ### 示例 1:在 Linux 服务器部署控制端
145
-
146
- ```bash
147
- git clone https://github.com/gaoyu06/OhMyVibe.git
148
- cd OhMyVibe
149
- npm install
150
- npm --prefix web install
151
- cp web/.env.example web/.env
152
- npm --prefix web run build
153
- npm run web:server
154
- ```
155
-
156
- `web/.env`:
157
-
158
- ```env
159
- PORT=3310
160
- VITE_CONTROL_SERVER_URL=https://your-domain.example.com
161
- ```
162
-
163
- 反向代理到 `3310` 端口后,浏览器即可访问控制台,远端 daemon 使用:
164
-
165
- ```env
166
- MANAGEMENT_SERVER_URL=https://your-domain.example.com
167
- ```
168
-
169
- ### 示例 2:用 PM2 托管控制端
170
-
171
- ```bash
172
- pm2 start "npm run web:server" --name ohmyvibe-control
173
- pm2 save
174
- ```
175
-
176
- ### 示例 3:发布前验证 npm 包
177
-
178
- ```bash
179
- npm run build:daemon
180
- npm run pack:dry-run
181
- ```
182
-
183
- ## 全局安装 daemon
184
-
185
- 如果你要把 daemon 作为全局命令安装,当前包已经支持:
186
-
187
- ```bash
188
- npm install -g ohmyvibe
189
- ```
190
-
191
- 然后直接启动:
192
-
193
- ```bash
194
- ohmyvibe --management-server-url http://localhost:3310
195
- ```
196
-
197
- 也可以显式指定 daemon 名称或 id:
198
-
199
- ```bash
200
- ohmyvibe daemon \
201
- --management-server-url http://localhost:3310 \
202
- --daemon-name ohmyvibe-local \
203
- --daemon-id local-1
204
- ```
205
-
206
- 如果仍然想走环境变量,也支持:
207
-
208
- - `MANAGEMENT_SERVER_URL`
209
- - `DAEMON_ID`
210
- - `DAEMON_NAME`
211
-
212
- 发布前可先验证打包内容:
213
-
214
- ```bash
215
- npm run build:daemon
216
- npm run pack:dry-run
217
- ```
218
-
219
- 正式发布:
220
-
221
- ```bash
222
- npm publish --access public
223
- ```
224
-
225
- ## 现在支持的能力
226
-
227
- - 创建多个独立 Codex 会话
228
- - daemon 重启后恢复应用内 session 列表与 transcript
229
- - 给指定会话发送消息
230
- - 流式接收 assistant 文本增量
231
- - 用 `item/*` 与 `turn/*` 事件维护实时 transcript
232
- - 中断运行中的 turn
233
- - 关闭会话
234
- - 从 Codex 历史会话列表恢复,并继续在同一 `threadId` 上对话
235
- - 使用独立前端从其他设备远程管理 daemon
236
- - daemon 主动连接管理端,浏览器不需要直连 daemon
237
-
238
- ## 后续建议
239
-
240
- - 把 `turn/interrupt`、审批、文件 diff、命令执行输出做成更细粒度 UI
241
- - 将 ACP session 和 web session 统一到同一后端存储
242
- - 为 `codex app-server` 请求/通知补完整类型约束
243
-
244
- ## 参考文档
245
-
246
- - OpenAI Codex App Server: https://developers.openai.com/codex/app-server
247
- - OpenAI Codex CLI repo: https://github.com/openai/codex
248
- - ACP 协议主页: https://agentclientprotocol.com
249
- - ACP TypeScript SDK: https://www.npmjs.com/package/@agentclientprotocol/sdk
1
+ # OhMyVibe
2
+
3
+ 这是一个 `VibeCoding` 控制台:
4
+
5
+ - `daemon -> control server <- browser` 架构(daemon 主动连接管理端)
6
+ - 每个会话独立启动一个 `codex app-server` 子进程
7
+ - daemon 统一管理多会话、消息发送、中断、状态同步
8
+ - 额外提供一个标准 `ACP` bridge 入口,方便后续给编辑器或其他 ACP client 接入
9
+ - 应用侧 session 本地持久化到 `data/sessions.json`
10
+ - 支持从 Codex 历史 `~/.codex/sessions` 恢复会话,并绑定到原始 Codex thread
11
+ - Web 控制台为独立 React + shadcn 风格项目,浏览器只连接管理端
12
+
13
+ ## 为什么这样做
14
+
15
+ 当前官方能力里,`Codex CLI` 暴露的是 `app-server` 自动化接口,而不是原生 `ACP agent`。因此这个 MVP 采用两层桥接:
16
+
17
+ 1. 南向:daemon 通过 `codex app-server --listen stdio://` 控制 Codex
18
+ 2. 北向:daemon 自己暴露 `ACP` 兼容 agent,供外部 ACP client 使用
19
+
20
+ 这能保证现在就能正确接入 Codex,同时不把上层协议绑死在 Codex 私有接口上。
21
+
22
+ ## 运行
23
+
24
+ 要求:
25
+
26
+ - Node.js 22+
27
+ - 本机已安装并可运行 `codex`
28
+ - `codex` 已完成登录
29
+
30
+ 1. 启动 Web 管理端(API + 页面):
31
+
32
+ ```bash
33
+ npm install
34
+ npm --prefix web install
35
+ npm --prefix web run build
36
+ npm run web:server
37
+ ```
38
+
39
+ 默认监听 `http://localhost:3310`
40
+ 默认读取 `web/.env`
41
+
42
+ 2. 在被控机器启动 daemon,并主动连接管理端:
43
+
44
+ ```bash
45
+ npm run daemon
46
+ ```
47
+
48
+ daemon 不再暴露本地 HTTP API,浏览器也不应直接连接 daemon。
49
+ 默认读取根目录 `.env`
50
+
51
+ 可选环境变量:
52
+
53
+ - `DAEMON_ID`:固定 daemon 标识
54
+ - `DAEMON_NAME`:展示名称
55
+
56
+ 3. 浏览器访问管理端页面:
57
+
58
+ ```bash
59
+ http://your-control-host:3310
60
+ ```
61
+
62
+ 开发模式(前端热更新):
63
+
64
+ ```bash
65
+ npm run web:dev
66
+ ```
67
+
68
+ 启动 ACP bridge:
69
+
70
+ ```bash
71
+ npm run acp
72
+ ```
73
+
74
+ ## 使用示例
75
+
76
+ ### 示例 1:本机快速跑通
77
+
78
+ 先启动控制端:
79
+
80
+ ```bash
81
+ git clone https://github.com/gaoyu06/OhMyVibe.git
82
+ cd OhMyVibe
83
+ npm install
84
+ npm --prefix web install
85
+ npm --prefix web run build
86
+ npm run web:server
87
+ ```
88
+
89
+ 再在另一台机器或另一个终端启动 daemon:
90
+
91
+ ```bash
92
+ cp .env.example .env
93
+ ```
94
+
95
+ `.env`:
96
+
97
+ ```env
98
+ MANAGEMENT_SERVER_URL=http://localhost:3310
99
+ DAEMON_NAME=ohmyvibe-local
100
+ ```
101
+
102
+ 启动:
103
+
104
+ ```bash
105
+ npm run daemon
106
+ ```
107
+
108
+ 浏览器访问:
109
+
110
+ ```text
111
+ http://localhost:3310
112
+ ```
113
+
114
+ ### 示例 2:通过 npm 全局安装 daemon
115
+
116
+ 如果你只想安装被控端 daemon,可以直接安装 npm 包:
117
+
118
+ ```bash
119
+ npm install -g ohmyvibe
120
+ ```
121
+
122
+ 然后直接连接到你的控制端:
123
+
124
+ ```bash
125
+ ohmyvibe --management-server-url http://your-control-host:3310
126
+ ```
127
+
128
+ 也可以显式指定 daemon 名称或 id:
129
+
130
+ ```bash
131
+ ohmyvibe daemon ^
132
+ --management-server-url http://your-control-host:3310 ^
133
+ --daemon-name office-win ^
134
+ --daemon-id office-win-01
135
+ ```
136
+
137
+ 说明:
138
+
139
+ - 当前 npm 包主要提供 `daemon` / `acp` CLI
140
+ - Web 控制服务端目前仍建议直接从仓库部署
141
+
142
+ ## 服务端部署示例
143
+
144
+ ### 示例 1:在 Linux 服务器部署控制端
145
+
146
+ ```bash
147
+ git clone https://github.com/gaoyu06/OhMyVibe.git
148
+ cd OhMyVibe
149
+ npm install
150
+ npm --prefix web install
151
+ cp web/.env.example web/.env
152
+ npm --prefix web run build
153
+ npm run web:server
154
+ ```
155
+
156
+ `web/.env`:
157
+
158
+ ```env
159
+ PORT=3310
160
+ VITE_CONTROL_SERVER_URL=https://your-domain.example.com
161
+ ```
162
+
163
+ 反向代理到 `3310` 端口后,浏览器即可访问控制台,远端 daemon 使用:
164
+
165
+ ```env
166
+ MANAGEMENT_SERVER_URL=https://your-domain.example.com
167
+ ```
168
+
169
+ ### 示例 2:用 PM2 托管控制端
170
+
171
+ ```bash
172
+ pm2 start "npm run web:server" --name ohmyvibe-control
173
+ pm2 save
174
+ ```
175
+
176
+ ### 示例 3:发布前验证 npm 包
177
+
178
+ ```bash
179
+ npm run build:daemon
180
+ npm run pack:dry-run
181
+ ```
182
+
183
+ ## 全局安装 daemon
184
+
185
+ 如果你要把 daemon 作为全局命令安装,当前包已经支持:
186
+
187
+ ```bash
188
+ npm install -g ohmyvibe
189
+ ```
190
+
191
+ 然后直接启动:
192
+
193
+ ```bash
194
+ ohmyvibe --management-server-url http://localhost:3310
195
+ ```
196
+
197
+ 也可以显式指定 daemon 名称或 id:
198
+
199
+ ```bash
200
+ ohmyvibe daemon \
201
+ --management-server-url http://localhost:3310 \
202
+ --daemon-name ohmyvibe-local \
203
+ --daemon-id local-1
204
+ ```
205
+
206
+ 如果仍然想走环境变量,也支持:
207
+
208
+ - `MANAGEMENT_SERVER_URL`
209
+ - `DAEMON_ID`
210
+ - `DAEMON_NAME`
211
+
212
+ 发布前可先验证打包内容:
213
+
214
+ ```bash
215
+ npm run build:daemon
216
+ npm run pack:dry-run
217
+ ```
218
+
219
+ 正式发布:
220
+
221
+ ```bash
222
+ npm publish --access public
223
+ ```
224
+
225
+ ## 现在支持的能力
226
+
227
+ - 创建多个独立 Codex 会话
228
+ - daemon 重启后恢复应用内 session 列表与 transcript
229
+ - 给指定会话发送消息
230
+ - 流式接收 assistant 文本增量
231
+ - 用 `item/*` 与 `turn/*` 事件维护实时 transcript
232
+ - 中断运行中的 turn
233
+ - 关闭会话
234
+ - 从 Codex 历史会话列表恢复,并继续在同一 `threadId` 上对话
235
+ - 使用独立前端从其他设备远程管理 daemon
236
+ - daemon 主动连接管理端,浏览器不需要直连 daemon
237
+
238
+ ## 后续建议
239
+
240
+ - 把 `turn/interrupt`、审批、文件 diff、命令执行输出做成更细粒度 UI
241
+ - 将 ACP session 和 web session 统一到同一后端存储
242
+ - 为 `codex app-server` 请求/通知补完整类型约束
243
+
244
+ ## 参考文档
245
+
246
+ - OpenAI Codex App Server: https://developers.openai.com/codex/app-server
247
+ - OpenAI Codex CLI repo: https://github.com/openai/codex
248
+ - ACP 协议主页: https://agentclientprotocol.com
249
+ - ACP TypeScript SDK: https://www.npmjs.com/package/@agentclientprotocol/sdk
package/dist/cli.js CHANGED
@@ -1,26 +1,26 @@
1
1
  #!/usr/bin/env node
2
2
  import "dotenv/config";
3
3
  function printHelp() {
4
- console.log(`OhMyVibe CLI
5
-
6
- Usage:
7
- ohmyvibe [command] [options]
8
-
9
- Commands:
10
- daemon Start the managed daemon (default)
11
- acp Start the ACP bridge
12
-
13
- Options:
14
- -u, --management-server-url <url> Control server URL
15
- --daemon-id <id> Override daemon id
16
- -n, --daemon-name <name> Override daemon display name
17
- -h, --help Show help
18
- -v, --version Show version
19
-
20
- Examples:
21
- ohmyvibe --management-server-url http://localhost:3310
22
- ohmyvibe daemon -u http://localhost:3310 -n my-daemon
23
- ohmyvibe acp
4
+ console.log(`OhMyVibe CLI
5
+
6
+ Usage:
7
+ ohmyvibe [command] [options]
8
+
9
+ Commands:
10
+ daemon Start the managed daemon (default)
11
+ acp Start the ACP bridge
12
+
13
+ Options:
14
+ -u, --management-server-url <url> Control server URL
15
+ --daemon-id <id> Override daemon id
16
+ -n, --daemon-name <name> Override daemon display name
17
+ -h, --help Show help
18
+ -v, --version Show version
19
+
20
+ Examples:
21
+ ohmyvibe --management-server-url http://localhost:3310
22
+ ohmyvibe daemon -u http://localhost:3310 -n my-daemon
23
+ ohmyvibe acp
24
24
  `);
25
25
  }
26
26
  function printVersion() {
@@ -1,6 +1,7 @@
1
1
  import os from "node:os";
2
2
  import { randomUUID } from "node:crypto";
3
3
  import { WebSocket } from "ws";
4
+ import packageJson from "../../package.json" with { type: "json" };
4
5
  export class ManagementBridge {
5
6
  serverUrl;
6
7
  daemonId;
@@ -8,6 +9,8 @@ export class ManagementBridge {
8
9
  sessionManager;
9
10
  socket;
10
11
  reconnectTimer;
12
+ eventFlushTimer;
13
+ pendingEvents = [];
11
14
  constructor(sessionManager, options) {
12
15
  this.sessionManager = sessionManager;
13
16
  this.serverUrl = options.serverUrl;
@@ -17,11 +20,7 @@ export class ManagementBridge {
17
20
  start() {
18
21
  this.connect();
19
22
  this.sessionManager.on("event", (event) => {
20
- this.send({
21
- type: "daemon-event",
22
- daemonId: this.daemonId,
23
- event,
24
- });
23
+ this.enqueueEvent(event);
25
24
  });
26
25
  }
27
26
  connect() {
@@ -83,11 +82,13 @@ export class ManagementBridge {
83
82
  }, 3000);
84
83
  }
85
84
  sendHello() {
85
+ this.flushPendingEvents();
86
86
  this.send({
87
87
  type: "daemon-hello",
88
88
  daemon: {
89
89
  id: this.daemonId,
90
90
  name: this.daemonName,
91
+ version: packageJson.version,
91
92
  platform: process.platform,
92
93
  cwd: process.cwd(),
93
94
  connectedAt: new Date().toISOString(),
@@ -98,6 +99,27 @@ export class ManagementBridge {
98
99
  sessions: this.sessionManager.list(),
99
100
  });
100
101
  }
102
+ enqueueEvent(event) {
103
+ this.pendingEvents.push(event);
104
+ if (this.eventFlushTimer) {
105
+ return;
106
+ }
107
+ this.eventFlushTimer = setTimeout(() => {
108
+ this.eventFlushTimer = undefined;
109
+ this.flushPendingEvents();
110
+ }, 16);
111
+ }
112
+ flushPendingEvents() {
113
+ if (!this.pendingEvents.length) {
114
+ return;
115
+ }
116
+ const events = this.pendingEvents.splice(0, this.pendingEvents.length);
117
+ this.send({
118
+ type: "daemon-events",
119
+ daemonId: this.daemonId,
120
+ events,
121
+ });
122
+ }
101
123
  async handleRequest(method, params) {
102
124
  switch (method) {
103
125
  case "getConfig":