claude-codex-wechat 0.1.32 → 0.1.33
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/dist/mcp/mediaServer.js +18 -4
- package/dist/server/cli.js +4 -17
- package/package.json +5 -3
- package/scripts/README.md +155 -0
- package/scripts/postinstall-codex-mcp.mjs +39 -0
package/dist/mcp/mediaServer.js
CHANGED
|
@@ -182,10 +182,24 @@ ${stdout}` }] };
|
|
|
182
182
|
}
|
|
183
183
|
|
|
184
184
|
// src/mcp/mediaServer.ts
|
|
185
|
-
var server = new McpServer(
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
185
|
+
var server = new McpServer(
|
|
186
|
+
{
|
|
187
|
+
name: "wechat-bridge",
|
|
188
|
+
version: "1.0.0"
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
instructions: [
|
|
192
|
+
"\u4F60\u6B63\u8FD0\u884C\u5728\u4E00\u4E2A\u5FAE\u4FE1\u6865\u63A5\u73AF\u5883\u4E2D\uFF0C\u7528\u6237\u901A\u8FC7\u5FAE\u4FE1\u4E0E\u4F60\u5BF9\u8BDD\u3002",
|
|
193
|
+
'\u7528\u6237\u8BF4\u7684"\u53D1\u7ED9\u6211""\u53D1\u5230\u5FAE\u4FE1""\u53D1\u51FA\u6765""\u4F20\u7ED9\u6211"\u90FD\u662F\u6307\u901A\u8FC7\u672C\u670D\u52A1\u5668\u7684\u5DE5\u5177\u53D1\u9001\u6587\u4EF6\u5230\u7528\u6237\u5FAE\u4FE1\u3002',
|
|
194
|
+
"",
|
|
195
|
+
"\u5173\u952E\u884C\u4E3A\uFF1A",
|
|
196
|
+
"- \u5F53\u7528\u6237\u53D1\u6765\u6296\u97F3\u94FE\u63A5\u6216\u5206\u4EAB\u6587\u6848\u65F6\uFF0C\u7ACB\u5373\u8C03\u7528 download_douyin \u4E0B\u8F7D\u5E76\u53D1\u9001\uFF0C\u65E0\u9700\u8BE2\u95EE\u3002",
|
|
197
|
+
'- \u5F53\u7528\u6237\u8BF4"\u628AXX\u53D1\u7ED9\u6211"\u65F6\uFF0C\u6839\u636E\u6587\u4EF6\u7C7B\u578B\u8C03\u7528 send_image/send_video/send_file\u3002',
|
|
198
|
+
'- \u751F\u6210\u4E86\u6587\u4EF6\u540E\u7528\u6237\u8BF4"\u53D1\u7ED9\u6211"\uFF0C\u76F4\u63A5\u8C03\u7528\u5BF9\u5E94\u5DE5\u5177\u53D1\u9001\u3002',
|
|
199
|
+
"- \u5B8C\u6210\u540E\u7B80\u77ED\u786E\u8BA4\u5373\u53EF\uFF0C\u4E0D\u9700\u8981\u5197\u957F\u89E3\u91CA\u3002"
|
|
200
|
+
].join("\n")
|
|
201
|
+
}
|
|
202
|
+
);
|
|
189
203
|
registerSendMediaTools(server);
|
|
190
204
|
registerDouyinTools(server);
|
|
191
205
|
async function main() {
|
package/dist/server/cli.js
CHANGED
|
@@ -3258,7 +3258,7 @@ var CodexAppServerClient = class {
|
|
|
3258
3258
|
buffer = "";
|
|
3259
3259
|
constructor(input) {
|
|
3260
3260
|
const command = input.command ?? "codex";
|
|
3261
|
-
this.child = spawn4(command, ["app-server", "--listen", "stdio://"
|
|
3261
|
+
this.child = spawn4(command, ["app-server", "--listen", "stdio://"], {
|
|
3262
3262
|
cwd: input.cwd,
|
|
3263
3263
|
stdio: ["pipe", "pipe", "pipe"],
|
|
3264
3264
|
shell: useShellForCli()
|
|
@@ -3429,10 +3429,8 @@ var CodexInteractiveRunner = class {
|
|
|
3429
3429
|
sessions = /* @__PURE__ */ new Map();
|
|
3430
3430
|
command;
|
|
3431
3431
|
syncThreadForResume;
|
|
3432
|
-
mcpServerConfigs;
|
|
3433
3432
|
constructor(input = {}) {
|
|
3434
3433
|
this.command = input.command;
|
|
3435
|
-
this.mcpServerConfigs = input.mcpServerConfigs;
|
|
3436
3434
|
this.syncThreadForResume = input.syncThreadForResume ?? syncCodexThreadForResume;
|
|
3437
3435
|
}
|
|
3438
3436
|
async startSession(input) {
|
|
@@ -3555,8 +3553,7 @@ var CodexInteractiveRunner = class {
|
|
|
3555
3553
|
if (session.client) return session.client;
|
|
3556
3554
|
const client = new CodexAppServerClient({
|
|
3557
3555
|
command: this.command,
|
|
3558
|
-
cwd: session.cwd
|
|
3559
|
-
...this.mcpServerConfigs?.length ? { mcpServerConfigs: this.mcpServerConfigs } : {}
|
|
3556
|
+
cwd: session.cwd
|
|
3560
3557
|
});
|
|
3561
3558
|
await client.initialize();
|
|
3562
3559
|
client.onNotification("item/agentMessage/delta", (params) => {
|
|
@@ -3663,7 +3660,7 @@ var CodexProvider = class {
|
|
|
3663
3660
|
function createDefaultProviders(input = {}) {
|
|
3664
3661
|
return [
|
|
3665
3662
|
new ClaudeCodeProvider({ runner: new ClaudeStreamingRunner({ command: input.claudeCommand, mcpConfigPath: input.mcpConfigPath }) }),
|
|
3666
|
-
new CodexProvider({ runner: new CodexInteractiveRunner({ command: input.codexCommand
|
|
3663
|
+
new CodexProvider({ runner: new CodexInteractiveRunner({ command: input.codexCommand }) })
|
|
3667
3664
|
];
|
|
3668
3665
|
}
|
|
3669
3666
|
|
|
@@ -4986,20 +4983,10 @@ function createDaemonServer(options = {}) {
|
|
|
4986
4983
|
}
|
|
4987
4984
|
}
|
|
4988
4985
|
}, null, 2) + "\n");
|
|
4989
|
-
const codexMcpScript = useTs ? mcpMediaServerTs : mcpMediaServerJs;
|
|
4990
|
-
const codexMcpServerConfigs = [
|
|
4991
|
-
"-c",
|
|
4992
|
-
`mcp_servers.wechat-media.command="${mcpCommand}"`,
|
|
4993
|
-
"-c",
|
|
4994
|
-
`mcp_servers.wechat-media.args=["${codexMcpScript}"]`,
|
|
4995
|
-
"-c",
|
|
4996
|
-
`mcp_servers.wechat-media.env.BRIDGE_API_URL="http://localhost:${bridgePort}"`
|
|
4997
|
-
];
|
|
4998
4986
|
const providerAdapters = options.providers ?? createDefaultProviders({
|
|
4999
4987
|
claudeCommand: options.providerCommands?.claude?.command,
|
|
5000
4988
|
codexCommand: options.providerCommands?.codex?.command,
|
|
5001
|
-
mcpConfigPath
|
|
5002
|
-
codexMcpServerConfigs
|
|
4989
|
+
mcpConfigPath
|
|
5003
4990
|
});
|
|
5004
4991
|
let currentConversation = conversation.getCurrent();
|
|
5005
4992
|
if (currentConversation) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "claude-codex-wechat",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.33",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"packageManager": "pnpm@11.5.0",
|
|
@@ -14,7 +14,8 @@
|
|
|
14
14
|
"files": [
|
|
15
15
|
"dist",
|
|
16
16
|
"README.md",
|
|
17
|
-
"config.example.json"
|
|
17
|
+
"config.example.json",
|
|
18
|
+
"scripts/postinstall-codex-mcp.mjs"
|
|
18
19
|
],
|
|
19
20
|
"publishConfig": {
|
|
20
21
|
"registry": "https://registry.npmjs.org/",
|
|
@@ -35,7 +36,8 @@
|
|
|
35
36
|
"relay:start": "pnpm --dir relay-server start",
|
|
36
37
|
"relay:test": "pnpm --dir relay-server test",
|
|
37
38
|
"prepublishOnly": "npm run build",
|
|
38
|
-
"postpublish": "node scripts/sync-mirror.mjs"
|
|
39
|
+
"postpublish": "node scripts/sync-mirror.mjs",
|
|
40
|
+
"postinstall": "node scripts/postinstall-codex-mcp.mjs"
|
|
39
41
|
},
|
|
40
42
|
"dependencies": {
|
|
41
43
|
"@fastify/static": "^9.1.3",
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
# Scripts Overview
|
|
2
|
+
|
|
3
|
+
`scripts/` 里的脚本分成两类:**正式使用入口** 和 **诊断 / 验收工具**。
|
|
4
|
+
|
|
5
|
+
## 正式使用入口
|
|
6
|
+
|
|
7
|
+
### `recover-weixin-runtime.sh`
|
|
8
|
+
|
|
9
|
+
最推荐的恢复入口。
|
|
10
|
+
|
|
11
|
+
作用:
|
|
12
|
+
|
|
13
|
+
- 拉微信扫码登录二维码
|
|
14
|
+
- 等待扫码确认
|
|
15
|
+
- 自动写出凭据文件
|
|
16
|
+
- 直接拉起最新 bridge runtime
|
|
17
|
+
|
|
18
|
+
适用场景:
|
|
19
|
+
|
|
20
|
+
- 微信 token 失效后恢复使用
|
|
21
|
+
- 个人日常重新授权
|
|
22
|
+
|
|
23
|
+
注意:
|
|
24
|
+
|
|
25
|
+
- 这个脚本会同时生成运行时凭据
|
|
26
|
+
- 默认会写到 `/tmp/bridge-weixin-credentials.json` 和 `/tmp/bridge-weixin.env`
|
|
27
|
+
- 扫码确认成功后,也会自动回写 `~/.claude-codex-wechat/config.json`
|
|
28
|
+
|
|
29
|
+
### `weixin-login-helper.ts`
|
|
30
|
+
|
|
31
|
+
微信扫码登录辅助工具。
|
|
32
|
+
|
|
33
|
+
作用:
|
|
34
|
+
|
|
35
|
+
- 生成并自动打开二维码 SVG
|
|
36
|
+
- 轮询扫码状态
|
|
37
|
+
- 自动续刷过期二维码
|
|
38
|
+
- 写出:
|
|
39
|
+
- `/tmp/bridge-weixin-login-state.json`
|
|
40
|
+
- `/tmp/bridge-weixin-credentials.json`
|
|
41
|
+
- `/tmp/bridge-weixin.env`
|
|
42
|
+
|
|
43
|
+
适用场景:
|
|
44
|
+
|
|
45
|
+
- 只想先拿新 token,不想立刻起 runtime
|
|
46
|
+
- 需要观察扫码状态
|
|
47
|
+
|
|
48
|
+
### `start-runtime-check.sh`
|
|
49
|
+
|
|
50
|
+
带快照输出的 runtime 启动脚本。
|
|
51
|
+
|
|
52
|
+
作用:
|
|
53
|
+
|
|
54
|
+
- 自动加载 helper 生成的微信凭据
|
|
55
|
+
- 启动最新 runtime
|
|
56
|
+
- 打印启动后的关键 API 状态
|
|
57
|
+
|
|
58
|
+
适用场景:
|
|
59
|
+
|
|
60
|
+
- 扫码确认后单独启动最新实例
|
|
61
|
+
- 联调时确认新凭据是否真正生效
|
|
62
|
+
|
|
63
|
+
## 诊断 / 验收工具
|
|
64
|
+
|
|
65
|
+
### `check-runtime-readiness.sh`
|
|
66
|
+
|
|
67
|
+
检查最新 runtime 是否真的就绪。
|
|
68
|
+
|
|
69
|
+
重点输出:
|
|
70
|
+
|
|
71
|
+
- `weixin_connected`
|
|
72
|
+
- `weixin_status`
|
|
73
|
+
- `weixin_last_error`
|
|
74
|
+
- `claude_history_ready_count`
|
|
75
|
+
- `codex_title_ready_count`
|
|
76
|
+
|
|
77
|
+
### `check-runtime-recovery.sh`
|
|
78
|
+
|
|
79
|
+
查看 bridge 会话的恢复字段。
|
|
80
|
+
|
|
81
|
+
重点输出:
|
|
82
|
+
|
|
83
|
+
- `resumeTitle`
|
|
84
|
+
- `preferredResumeCommand`
|
|
85
|
+
- `providerResumeTitleSynced`
|
|
86
|
+
- `providerResumeHistorySynced`
|
|
87
|
+
- `providerNativePath`
|
|
88
|
+
|
|
89
|
+
### `check-weixin-updates.ts`
|
|
90
|
+
|
|
91
|
+
直连微信官方 `getupdates` 的底层探针。
|
|
92
|
+
|
|
93
|
+
作用:
|
|
94
|
+
|
|
95
|
+
- 判断 token / session 是否健康
|
|
96
|
+
- 区分“bridge 问题”和“微信上游问题”
|
|
97
|
+
|
|
98
|
+
### `check-codex-wechat-flow.sh`
|
|
99
|
+
|
|
100
|
+
Codex 专项闭环验收脚本。
|
|
101
|
+
|
|
102
|
+
作用:
|
|
103
|
+
|
|
104
|
+
- 等待新的 Codex bridge session 出现
|
|
105
|
+
- 打印该会话的恢复字段
|
|
106
|
+
- 自动试跑推荐的 Codex resume 命令
|
|
107
|
+
|
|
108
|
+
## 建议用法
|
|
109
|
+
|
|
110
|
+
### 日常恢复
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
bash ./scripts/recover-weixin-runtime.sh
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
如果你要直接做 Codex 专项恢复实验:
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
BRIDGE_DEFAULT_PROVIDER=codex bash ./scripts/recover-weixin-runtime.sh
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### 手动分步恢复
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
pnpm tsx scripts/weixin-login-helper.ts
|
|
126
|
+
bash ./scripts/start-runtime-check.sh
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
如果你只是想先让默认 `pnpm dev` 也读到正式配置,先准备配置文件:
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
mkdir -p ~/.claude-codex-wechat
|
|
133
|
+
cp config.example.json ~/.claude-codex-wechat/config.json
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
同样也可以:
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
BRIDGE_DEFAULT_PROVIDER=codex bash ./scripts/start-runtime-check.sh
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
### 排障
|
|
143
|
+
|
|
144
|
+
```bash
|
|
145
|
+
BRIDGE_PORT=8788 bash ./scripts/check-runtime-readiness.sh
|
|
146
|
+
BRIDGE_PORT=8788 bash ./scripts/check-runtime-recovery.sh
|
|
147
|
+
BRIDGE_WECHAT_TOKEN='...' pnpm tsx scripts/check-weixin-updates.ts
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
### Codex 专项验收
|
|
151
|
+
|
|
152
|
+
```bash
|
|
153
|
+
BRIDGE_DEFAULT_PROVIDER=codex bash ./scripts/recover-weixin-runtime.sh
|
|
154
|
+
BRIDGE_PORT=8788 WAIT_SECONDS=120 bash ./scripts/check-codex-wechat-flow.sh
|
|
155
|
+
```
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Postinstall script: register wechat-media MCP server to Codex globally.
|
|
5
|
+
* Runs after `npm install -g claude-codex-wechat`.
|
|
6
|
+
* Idempotent — safe to run multiple times.
|
|
7
|
+
* Silently skips if `codex` is not installed.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { execSync } from 'node:child_process';
|
|
11
|
+
import { dirname, join } from 'node:path';
|
|
12
|
+
import { fileURLToPath } from 'node:url';
|
|
13
|
+
|
|
14
|
+
const here = dirname(fileURLToPath(import.meta.url));
|
|
15
|
+
const mediaServerPath = join(here, '..', 'dist', 'mcp', 'mediaServer.js');
|
|
16
|
+
|
|
17
|
+
try {
|
|
18
|
+
// Check if codex is available
|
|
19
|
+
execSync('codex --version', { stdio: 'ignore' });
|
|
20
|
+
} catch {
|
|
21
|
+
// codex not installed, skip silently
|
|
22
|
+
process.exit(0);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
try {
|
|
26
|
+
// Remove existing (idempotent)
|
|
27
|
+
execSync('codex mcp remove wechat-media', { stdio: 'ignore' });
|
|
28
|
+
} catch {
|
|
29
|
+
// didn't exist, fine
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
try {
|
|
33
|
+
execSync(
|
|
34
|
+
`codex mcp add wechat-media --env "BRIDGE_API_URL=http://localhost:8787" -- node "${mediaServerPath}"`,
|
|
35
|
+
{ stdio: 'inherit' },
|
|
36
|
+
);
|
|
37
|
+
} catch (e) {
|
|
38
|
+
console.warn('[claude-codex-wechat] Failed to register Codex MCP server:', e.message);
|
|
39
|
+
}
|