claude-codex-wechat 0.1.32 → 0.1.34

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.
@@ -182,10 +182,24 @@ ${stdout}` }] };
182
182
  }
183
183
 
184
184
  // src/mcp/mediaServer.ts
185
- var server = new McpServer({
186
- name: "wechat-bridge",
187
- version: "1.0.0"
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() {
@@ -11,6 +11,7 @@ import { networkInterfaces } from "node:os";
11
11
 
12
12
  // src/daemon/server.ts
13
13
  import { mkdtempSync, existsSync as existsSync9, writeFileSync as writeFileSync2 } from "node:fs";
14
+ import { execSync } from "node:child_process";
14
15
  import { tmpdir as tmpdir2 } from "node:os";
15
16
  import { dirname as dirname7, join as join11 } from "node:path";
16
17
  import { fileURLToPath as fileURLToPath2 } from "node:url";
@@ -3258,7 +3259,7 @@ var CodexAppServerClient = class {
3258
3259
  buffer = "";
3259
3260
  constructor(input) {
3260
3261
  const command = input.command ?? "codex";
3261
- this.child = spawn4(command, ["app-server", "--listen", "stdio://", ...input.mcpServerConfigs ?? []], {
3262
+ this.child = spawn4(command, ["app-server", "--listen", "stdio://"], {
3262
3263
  cwd: input.cwd,
3263
3264
  stdio: ["pipe", "pipe", "pipe"],
3264
3265
  shell: useShellForCli()
@@ -3429,10 +3430,8 @@ var CodexInteractiveRunner = class {
3429
3430
  sessions = /* @__PURE__ */ new Map();
3430
3431
  command;
3431
3432
  syncThreadForResume;
3432
- mcpServerConfigs;
3433
3433
  constructor(input = {}) {
3434
3434
  this.command = input.command;
3435
- this.mcpServerConfigs = input.mcpServerConfigs;
3436
3435
  this.syncThreadForResume = input.syncThreadForResume ?? syncCodexThreadForResume;
3437
3436
  }
3438
3437
  async startSession(input) {
@@ -3555,8 +3554,7 @@ var CodexInteractiveRunner = class {
3555
3554
  if (session.client) return session.client;
3556
3555
  const client = new CodexAppServerClient({
3557
3556
  command: this.command,
3558
- cwd: session.cwd,
3559
- ...this.mcpServerConfigs?.length ? { mcpServerConfigs: this.mcpServerConfigs } : {}
3557
+ cwd: session.cwd
3560
3558
  });
3561
3559
  await client.initialize();
3562
3560
  client.onNotification("item/agentMessage/delta", (params) => {
@@ -3663,7 +3661,7 @@ var CodexProvider = class {
3663
3661
  function createDefaultProviders(input = {}) {
3664
3662
  return [
3665
3663
  new ClaudeCodeProvider({ runner: new ClaudeStreamingRunner({ command: input.claudeCommand, mcpConfigPath: input.mcpConfigPath }) }),
3666
- new CodexProvider({ runner: new CodexInteractiveRunner({ command: input.codexCommand, mcpServerConfigs: input.codexMcpServerConfigs }) })
3664
+ new CodexProvider({ runner: new CodexInteractiveRunner({ command: input.codexCommand }) })
3667
3665
  ];
3668
3666
  }
3669
3667
 
@@ -4930,6 +4928,18 @@ function readUpdateStatusBestEffort(configPath) {
4930
4928
  return { ok: false };
4931
4929
  }
4932
4930
  }
4931
+ function ensureCodexMcpRegistered(mediaServerPath, bridgePort) {
4932
+ try {
4933
+ execSync("codex --version", { stdio: "ignore" });
4934
+ const list = execSync("codex mcp list", { encoding: "utf8", stdio: ["pipe", "pipe", "ignore"] });
4935
+ if (list.includes("wechat-media")) return;
4936
+ execSync(
4937
+ `codex mcp add wechat-media --env "BRIDGE_API_URL=http://localhost:${bridgePort}" -- node "${mediaServerPath}"`,
4938
+ { stdio: "ignore" }
4939
+ );
4940
+ } catch {
4941
+ }
4942
+ }
4933
4943
  function createDaemonServer(options = {}) {
4934
4944
  const app = Fastify({ logger: true });
4935
4945
  const events = new BridgeEventHub();
@@ -4986,20 +4996,11 @@ function createDaemonServer(options = {}) {
4986
4996
  }
4987
4997
  }
4988
4998
  }, 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
- ];
4999
+ ensureCodexMcpRegistered(useTs ? mcpMediaServerTs : mcpMediaServerJs, bridgePort);
4998
5000
  const providerAdapters = options.providers ?? createDefaultProviders({
4999
5001
  claudeCommand: options.providerCommands?.claude?.command,
5000
5002
  codexCommand: options.providerCommands?.codex?.command,
5001
- mcpConfigPath,
5002
- codexMcpServerConfigs
5003
+ mcpConfigPath
5003
5004
  });
5004
5005
  let currentConversation = conversation.getCurrent();
5005
5006
  if (currentConversation) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-codex-wechat",
3
- "version": "0.1.32",
3
+ "version": "0.1.34",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "packageManager": "pnpm@11.5.0",