claude-codex-wechat 0.1.15 → 0.1.16
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/server/cli.js
CHANGED
|
@@ -106,16 +106,13 @@ function normalizeBridgeDefaultsConfig(raw) {
|
|
|
106
106
|
}
|
|
107
107
|
function normalizeTunnelConfig(raw) {
|
|
108
108
|
const record = raw && typeof raw === "object" ? raw : {};
|
|
109
|
-
const enabled = record.enabled === true;
|
|
110
109
|
const relayRecord = record.relay && typeof record.relay === "object" ? record.relay : void 0;
|
|
111
|
-
const relay =
|
|
112
|
-
|
|
113
|
-
...typeof relayRecord
|
|
114
|
-
}
|
|
115
|
-
if (!enabled && !relay) return void 0;
|
|
110
|
+
const relay = {
|
|
111
|
+
serverUrl: typeof relayRecord?.serverUrl === "string" && relayRecord.serverUrl.trim() ? relayRecord.serverUrl : "wss://wechat.style520.com/agent",
|
|
112
|
+
...typeof relayRecord?.authToken === "string" && relayRecord.authToken.trim() ? { authToken: relayRecord.authToken } : {}
|
|
113
|
+
};
|
|
116
114
|
return {
|
|
117
|
-
|
|
118
|
-
...relay ? { relay } : {}
|
|
115
|
+
relay
|
|
119
116
|
};
|
|
120
117
|
}
|
|
121
118
|
function normalizeProviderCommand(raw, envFallback) {
|
|
@@ -179,7 +176,6 @@ async function persistBridgeDefaultsToConfigFile(input) {
|
|
|
179
176
|
},
|
|
180
177
|
...input.tunnel ? {
|
|
181
178
|
tunnel: {
|
|
182
|
-
enabled: input.tunnel.enabled === true,
|
|
183
179
|
...input.tunnel.relay ? {
|
|
184
180
|
relay: {
|
|
185
181
|
...input.tunnel.relay.serverUrl ? { serverUrl: input.tunnel.relay.serverUrl } : {},
|
|
@@ -1472,7 +1468,6 @@ function registerTunnelRoutes(input) {
|
|
|
1472
1468
|
const getStatus = async () => await input.tunnelManager.getStatus();
|
|
1473
1469
|
input.app.get("/api/tunnel/status", getStatus);
|
|
1474
1470
|
const start = async () => {
|
|
1475
|
-
input.defaults.tunnel.enabled = true;
|
|
1476
1471
|
await persistBridgeDefaultsToConfigFile({
|
|
1477
1472
|
configPath: input.configPath,
|
|
1478
1473
|
tunnel: input.defaults.tunnel
|
|
@@ -1481,24 +1476,9 @@ function registerTunnelRoutes(input) {
|
|
|
1481
1476
|
};
|
|
1482
1477
|
input.app.post("/api/tunnel/start", start);
|
|
1483
1478
|
const stop = async () => {
|
|
1484
|
-
input.defaults.tunnel.enabled = false;
|
|
1485
|
-
await persistBridgeDefaultsToConfigFile({
|
|
1486
|
-
configPath: input.configPath,
|
|
1487
|
-
tunnel: input.defaults.tunnel
|
|
1488
|
-
});
|
|
1489
1479
|
return await input.tunnelManager.stop();
|
|
1490
1480
|
};
|
|
1491
1481
|
input.app.post("/api/tunnel/stop", stop);
|
|
1492
|
-
const setEnabled = async (request) => {
|
|
1493
|
-
const enabled = request.body?.enabled === true;
|
|
1494
|
-
input.defaults.tunnel.enabled = enabled;
|
|
1495
|
-
await persistBridgeDefaultsToConfigFile({
|
|
1496
|
-
configPath: input.configPath,
|
|
1497
|
-
tunnel: input.defaults.tunnel
|
|
1498
|
-
});
|
|
1499
|
-
return await input.tunnelManager.setEnabled(enabled);
|
|
1500
|
-
};
|
|
1501
|
-
input.app.post("/api/tunnel/settings", setEnabled);
|
|
1502
1482
|
}
|
|
1503
1483
|
|
|
1504
1484
|
// src/admin/settingsRoutes.ts
|
|
@@ -1547,10 +1527,9 @@ function normalizeSettings(input, defaultWorkspace) {
|
|
|
1547
1527
|
defaultProvider: input.defaultProvider === "codex" ? "codex" : "claude-code",
|
|
1548
1528
|
defaultWorkspace: typeof input.defaultWorkspace === "string" && input.defaultWorkspace.trim() ? input.defaultWorkspace : defaultWorkspace,
|
|
1549
1529
|
tunnel: {
|
|
1550
|
-
|
|
1551
|
-
...typeof relay.serverUrl === "string" && relay.serverUrl.trim() || typeof relay.authToken === "string" && relay.authToken.trim() ? {
|
|
1530
|
+
...typeof relay.serverUrl === "string" && relay.serverUrl.trim() || typeof relay.authToken === "string" && relay.authToken.trim() || !("relay" in tunnel) ? {
|
|
1552
1531
|
relay: {
|
|
1553
|
-
|
|
1532
|
+
serverUrl: typeof relay.serverUrl === "string" && relay.serverUrl.trim() ? relay.serverUrl : "wss://wechat.style520.com/agent",
|
|
1554
1533
|
...typeof relay.authToken === "string" && relay.authToken.trim() ? { authToken: relay.authToken } : {}
|
|
1555
1534
|
}
|
|
1556
1535
|
} : {}
|
|
@@ -3241,9 +3220,9 @@ var BRIDGE_COMMAND_HELP_GROUPS = [
|
|
|
3241
3220
|
entries: [
|
|
3242
3221
|
{ command: "/help", desc: "\u663E\u793A\u672C\u5E2E\u52A9" },
|
|
3243
3222
|
{ command: "/status", desc: "\u67E5\u770B\u5F53\u524D\u4F1A\u8BDD\uFF08provider\u3001\u5DE5\u4F5C\u76EE\u5F55\u3001\u72B6\u6001\uFF09" },
|
|
3244
|
-
{ command: "/new", desc: "\
|
|
3223
|
+
{ command: "/new", desc: "\u6309\u5F53\u524D provider \u65B0\u5EFA\u4F1A\u8BDD" },
|
|
3245
3224
|
{ command: "/new claude|codex", desc: "\u65B0\u5EFA\u6307\u5B9A provider \u4F1A\u8BDD" },
|
|
3246
|
-
{ command: "/new <\u76EE\u5F55>", desc: "\u5728\u6307\u5B9A\u76EE\u5F55\
|
|
3225
|
+
{ command: "/new <\u76EE\u5F55>", desc: "\u5728\u6307\u5B9A\u76EE\u5F55\u6309\u5F53\u524D provider \u65B0\u5EFA\u4F1A\u8BDD" },
|
|
3247
3226
|
{ command: "/new claude:<\u76EE\u5F55>", desc: "\u65B0\u5EFA\u6307\u5B9A provider + \u6307\u5B9A\u76EE\u5F55\u4F1A\u8BDD" },
|
|
3248
3227
|
{ command: "/stop", desc: "\u4E2D\u65AD\u5F53\u524D\u6B63\u5728\u751F\u6210\u7684\u56DE\u590D\uFF08\u4F1A\u8BDD\u4FDD\u7559\uFF09" }
|
|
3249
3228
|
]
|
|
@@ -3673,7 +3652,7 @@ var MessageRouter = class _MessageRouter {
|
|
|
3673
3652
|
}
|
|
3674
3653
|
if (command.kind === "new_session") {
|
|
3675
3654
|
await this.preemptActiveGeneration(chatId);
|
|
3676
|
-
const providerId = command.providerId ?? this.options.defaults?.defaultProvider ?? "claude-code";
|
|
3655
|
+
const providerId = command.providerId ?? this.conversation.getCurrent()?.providerId ?? this.options.defaults?.defaultProvider ?? "claude-code";
|
|
3677
3656
|
const cwd = command.cwd ?? this.conversation.getCurrent()?.cwd ?? this.options.defaults?.defaultWorkspace ?? defaultWorkspaceDir();
|
|
3678
3657
|
const session = this.conversation.create({
|
|
3679
3658
|
chatId,
|
|
@@ -4008,7 +3987,6 @@ var RelayTunnelProvider = class {
|
|
|
4008
3987
|
socket = null;
|
|
4009
3988
|
status = {
|
|
4010
3989
|
installed: true,
|
|
4011
|
-
enabled: false,
|
|
4012
3990
|
running: false,
|
|
4013
3991
|
status: "stopped"
|
|
4014
3992
|
};
|
|
@@ -4035,7 +4013,6 @@ var RelayTunnelProvider = class {
|
|
|
4035
4013
|
async start() {
|
|
4036
4014
|
this.status = {
|
|
4037
4015
|
...this.status,
|
|
4038
|
-
enabled: true,
|
|
4039
4016
|
status: "starting"
|
|
4040
4017
|
};
|
|
4041
4018
|
const socket = this.options.createSocket(this.options.serverUrl);
|
|
@@ -4074,10 +4051,9 @@ var RelayTunnelProvider = class {
|
|
|
4074
4051
|
return;
|
|
4075
4052
|
}
|
|
4076
4053
|
if (payload?.type === "registered") {
|
|
4077
|
-
const publicUrl = typeof payload?.token === "string" ? `${derivePublicBaseUrl(this.options.serverUrl)}/${payload.token}` : void 0;
|
|
4054
|
+
const publicUrl = typeof payload?.publicUrl === "string" && payload.publicUrl ? payload.publicUrl : typeof payload?.token === "string" ? `${derivePublicBaseUrl(this.options.serverUrl)}/${payload.token}` : void 0;
|
|
4078
4055
|
this.status = {
|
|
4079
4056
|
installed: true,
|
|
4080
|
-
enabled: true,
|
|
4081
4057
|
running: true,
|
|
4082
4058
|
status: "running",
|
|
4083
4059
|
...publicUrl ? { publicUrl } : {}
|
|
@@ -4115,15 +4091,11 @@ var RelayTunnelProvider = class {
|
|
|
4115
4091
|
this.socket = null;
|
|
4116
4092
|
this.status = {
|
|
4117
4093
|
installed: true,
|
|
4118
|
-
enabled: false,
|
|
4119
4094
|
running: false,
|
|
4120
4095
|
status: "stopped"
|
|
4121
4096
|
};
|
|
4122
4097
|
return { ...this.status };
|
|
4123
4098
|
}
|
|
4124
|
-
async setEnabled(enabled) {
|
|
4125
|
-
return enabled ? await this.start() : await this.stop();
|
|
4126
|
-
}
|
|
4127
4099
|
async handleRequest(payload) {
|
|
4128
4100
|
const fetchImpl = this.options.fetchImpl ?? fetch;
|
|
4129
4101
|
const response = await fetchImpl(`${this.options.targetBaseUrl}${payload.path}`, {
|
|
@@ -4168,11 +4140,6 @@ var RelayTunnelRouter = class {
|
|
|
4168
4140
|
if (!provider) return this.notConfiguredStatus();
|
|
4169
4141
|
return await provider.stop();
|
|
4170
4142
|
}
|
|
4171
|
-
async setEnabled(enabled) {
|
|
4172
|
-
const provider = this.getOrCreateRelayProvider();
|
|
4173
|
-
if (!provider) return this.notConfiguredStatus();
|
|
4174
|
-
return await provider.setEnabled(enabled);
|
|
4175
|
-
}
|
|
4176
4143
|
getOrCreateRelayProvider() {
|
|
4177
4144
|
const relay = this.options.defaults.tunnel.relay;
|
|
4178
4145
|
if (!relay?.serverUrl || !relay.authToken) return null;
|
|
@@ -4190,7 +4157,6 @@ var RelayTunnelRouter = class {
|
|
|
4190
4157
|
notConfiguredStatus() {
|
|
4191
4158
|
return {
|
|
4192
4159
|
installed: false,
|
|
4193
|
-
enabled: false,
|
|
4194
4160
|
running: false,
|
|
4195
4161
|
status: "error",
|
|
4196
4162
|
error: "relay_not_configured"
|
|
@@ -4208,8 +4174,10 @@ function createDaemonServer(options = {}) {
|
|
|
4208
4174
|
defaultProvider: options.bridgeDefaults?.defaultProvider ?? persistedConfig.bridge?.defaultProvider ?? "claude-code",
|
|
4209
4175
|
defaultWorkspace: options.bridgeDefaults?.defaultWorkspace ?? persistedConfig.bridge?.defaultWorkspace ?? process.cwd(),
|
|
4210
4176
|
tunnel: options.bridgeDefaults?.tunnel ?? {
|
|
4211
|
-
|
|
4212
|
-
|
|
4177
|
+
relay: {
|
|
4178
|
+
serverUrl: persistedConfig.tunnel?.relay?.serverUrl ?? "wss://wechat.style520.com/agent",
|
|
4179
|
+
...persistedConfig.tunnel?.relay?.authToken ? { authToken: persistedConfig.tunnel.relay.authToken } : {}
|
|
4180
|
+
}
|
|
4213
4181
|
}
|
|
4214
4182
|
};
|
|
4215
4183
|
const existingRelayAuthToken = bridgeDefaults.tunnel.relay?.authToken?.trim();
|
|
@@ -4427,7 +4395,7 @@ async function startDaemon(options) {
|
|
|
4427
4395
|
defaultProvider: config.bridge?.defaultProvider ?? "claude-code",
|
|
4428
4396
|
defaultWorkspace: config.bridge?.defaultWorkspace ?? process.cwd(),
|
|
4429
4397
|
tunnel: {
|
|
4430
|
-
enabled:
|
|
4398
|
+
enabled: true,
|
|
4431
4399
|
...config.tunnel?.relay ? { relay: config.tunnel.relay } : {}
|
|
4432
4400
|
}
|
|
4433
4401
|
};
|
|
@@ -4442,7 +4410,7 @@ async function startDaemon(options) {
|
|
|
4442
4410
|
await app.listen({ host, port });
|
|
4443
4411
|
const address = app.server.address();
|
|
4444
4412
|
const actualPort = typeof address === "object" && address ? address.port : port;
|
|
4445
|
-
if (config.tunnel?.
|
|
4413
|
+
if (config.tunnel?.relay?.serverUrl && config.tunnel?.relay?.authToken) {
|
|
4446
4414
|
await resolvedTunnelProvider?.start().catch(() => void 0);
|
|
4447
4415
|
}
|
|
4448
4416
|
console.log("claude-codex-wechat listening:");
|