cli-wechat-bridge 1.0.5

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.
Files changed (54) hide show
  1. package/LICENSE.txt +21 -0
  2. package/README.md +637 -0
  3. package/bin/_run-entry.mjs +35 -0
  4. package/bin/wechat-bridge-claude.mjs +5 -0
  5. package/bin/wechat-bridge-codex.mjs +5 -0
  6. package/bin/wechat-bridge-opencode.mjs +5 -0
  7. package/bin/wechat-bridge-shell.mjs +5 -0
  8. package/bin/wechat-bridge.mjs +5 -0
  9. package/bin/wechat-check-update.mjs +5 -0
  10. package/bin/wechat-claude-start.mjs +5 -0
  11. package/bin/wechat-claude.mjs +5 -0
  12. package/bin/wechat-codex-start.mjs +5 -0
  13. package/bin/wechat-codex.mjs +5 -0
  14. package/bin/wechat-daemon.mjs +5 -0
  15. package/bin/wechat-opencode-start.mjs +5 -0
  16. package/bin/wechat-opencode.mjs +5 -0
  17. package/bin/wechat-setup.mjs +5 -0
  18. package/dist/bridge/bridge-adapter-common.js +95 -0
  19. package/dist/bridge/bridge-adapters.claude.js +829 -0
  20. package/dist/bridge/bridge-adapters.codex.js +2228 -0
  21. package/dist/bridge/bridge-adapters.core.js +717 -0
  22. package/dist/bridge/bridge-adapters.js +26 -0
  23. package/dist/bridge/bridge-adapters.opencode.js +2129 -0
  24. package/dist/bridge/bridge-adapters.shared.js +1005 -0
  25. package/dist/bridge/bridge-adapters.shell.js +363 -0
  26. package/dist/bridge/bridge-controller.js +48 -0
  27. package/dist/bridge/bridge-final-reply.js +46 -0
  28. package/dist/bridge/bridge-process-reaper.js +348 -0
  29. package/dist/bridge/bridge-state.js +362 -0
  30. package/dist/bridge/bridge-types.js +1 -0
  31. package/dist/bridge/bridge-utils.js +1240 -0
  32. package/dist/bridge/claude-hook.js +82 -0
  33. package/dist/bridge/claude-hooks.js +267 -0
  34. package/dist/bridge/wechat-bridge.js +1026 -0
  35. package/dist/commands/check-update.js +30 -0
  36. package/dist/companion/codex-panel-link.js +72 -0
  37. package/dist/companion/codex-panel.js +179 -0
  38. package/dist/companion/codex-remote-client.js +124 -0
  39. package/dist/companion/local-companion-link.js +240 -0
  40. package/dist/companion/local-companion-start.js +420 -0
  41. package/dist/companion/local-companion.js +424 -0
  42. package/dist/daemon/daemon-link.js +175 -0
  43. package/dist/daemon/wechat-daemon.js +1202 -0
  44. package/dist/media/media-types.js +1 -0
  45. package/dist/runtime/create-runtime-host.js +12 -0
  46. package/dist/runtime/legacy-adapter-runtime.js +46 -0
  47. package/dist/runtime/runtime-types.js +5 -0
  48. package/dist/utils/version-checker.js +161 -0
  49. package/dist/wechat/channel-config.js +196 -0
  50. package/dist/wechat/setup.js +283 -0
  51. package/dist/wechat/standalone-bot.js +355 -0
  52. package/dist/wechat/wechat-channel.js +492 -0
  53. package/dist/wechat/wechat-transport.js +1213 -0
  54. package/package.json +101 -0
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { runJsEntry } from "./_run-entry.mjs";
4
+
5
+ runJsEntry("dist/bridge/wechat-bridge.js", ["--adapter", "claude"]);
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { runJsEntry } from "./_run-entry.mjs";
4
+
5
+ runJsEntry("dist/bridge/wechat-bridge.js", ["--adapter", "codex"]);
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { runJsEntry } from "./_run-entry.mjs";
4
+
5
+ runJsEntry("dist/bridge/wechat-bridge.js", ["--adapter", "opencode"]);
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { runJsEntry } from "./_run-entry.mjs";
4
+
5
+ runJsEntry("dist/bridge/wechat-bridge.js", ["--adapter", "shell"]);
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { runJsEntry } from "./_run-entry.mjs";
4
+
5
+ runJsEntry("dist/bridge/wechat-bridge.js");
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { runJsEntry } from "./_run-entry.mjs";
4
+
5
+ runJsEntry("dist/commands/check-update.js", []);
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { runJsEntry } from "./_run-entry.mjs";
4
+
5
+ runJsEntry("dist/companion/local-companion-start.js", ["--adapter", "claude"]);
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { runJsEntry } from "./_run-entry.mjs";
4
+
5
+ runJsEntry("dist/companion/local-companion.js", ["--adapter", "claude"]);
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { runJsEntry } from "./_run-entry.mjs";
4
+
5
+ runJsEntry("dist/companion/local-companion-start.js");
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { runJsEntry } from "./_run-entry.mjs";
4
+
5
+ runJsEntry("dist/companion/codex-remote-client.js");
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { runJsEntry } from "./_run-entry.mjs";
4
+
5
+ runJsEntry("dist/daemon/wechat-daemon.js");
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { runJsEntry } from "./_run-entry.mjs";
4
+
5
+ runJsEntry("dist/companion/local-companion-start.js", ["--adapter", "opencode"]);
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { runJsEntry } from "./_run-entry.mjs";
4
+
5
+ runJsEntry("dist/companion/local-companion.js", ["--adapter", "opencode"]);
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { runJsEntry } from "./_run-entry.mjs";
4
+
5
+ runJsEntry("dist/wechat/setup.js");
@@ -0,0 +1,95 @@
1
+ export function isRecord(value) {
2
+ return typeof value === "object" && value !== null && !Array.isArray(value);
3
+ }
4
+ export function getCodexRpcRequestId(value) {
5
+ return typeof value === "string" || typeof value === "number" ? value : null;
6
+ }
7
+ export function getNotificationThreadId(params) {
8
+ if (!isRecord(params)) {
9
+ return null;
10
+ }
11
+ if (typeof params.threadId === "string") {
12
+ return params.threadId;
13
+ }
14
+ if (isRecord(params.thread) && typeof params.thread.id === "string") {
15
+ return params.thread.id;
16
+ }
17
+ return null;
18
+ }
19
+ export function getNotificationTurnId(params) {
20
+ if (!isRecord(params)) {
21
+ return null;
22
+ }
23
+ if (typeof params.turnId === "string") {
24
+ return params.turnId;
25
+ }
26
+ if (isRecord(params.turn) && typeof params.turn.id === "string") {
27
+ return params.turn.id;
28
+ }
29
+ return null;
30
+ }
31
+ export function describeUnknownError(error) {
32
+ if (error instanceof Error && error.message) {
33
+ return error.message;
34
+ }
35
+ return String(error);
36
+ }
37
+ export function normalizeCodexRpcError(error) {
38
+ if (isRecord(error)) {
39
+ const message = typeof error.message === "string"
40
+ ? error.message
41
+ : typeof error.code === "number"
42
+ ? `RPC error ${error.code}`
43
+ : "";
44
+ const data = typeof error.data === "string"
45
+ ? error.data
46
+ : typeof error.details === "string"
47
+ ? error.details
48
+ : "";
49
+ const combined = [message, data].filter(Boolean).join(": ");
50
+ if (combined) {
51
+ return combined;
52
+ }
53
+ }
54
+ return describeUnknownError(error);
55
+ }
56
+ export function getLocalCompanionCommandName(kind) {
57
+ switch (kind) {
58
+ case "codex":
59
+ return "wechat-codex";
60
+ case "claude":
61
+ return "wechat-claude";
62
+ case "opencode":
63
+ return "wechat-opencode";
64
+ default:
65
+ return "local companion";
66
+ }
67
+ }
68
+ export function getSharedSessionIdFromAdapterState(state) {
69
+ return state.sharedSessionId ?? state.sharedThreadId;
70
+ }
71
+ export function quoteWindowsCommandArg(value) {
72
+ return `"${value.replace(/"/g, '""')}"`;
73
+ }
74
+ export function quotePosixCommandArg(value) {
75
+ return `'${value.replace(/'/g, `'\\''`)}'`;
76
+ }
77
+ export function isRecentIsoTimestamp(timestamp, maxAgeMs) {
78
+ const parsedMs = Date.parse(timestamp);
79
+ if (!Number.isFinite(parsedMs)) {
80
+ return false;
81
+ }
82
+ return parsedMs >= Date.now() - maxAgeMs;
83
+ }
84
+ export function coerceWebSocketMessageData(data) {
85
+ if (typeof data === "string") {
86
+ return data;
87
+ }
88
+ if (data instanceof ArrayBuffer) {
89
+ return Buffer.from(data).toString("utf8");
90
+ }
91
+ if (ArrayBuffer.isView(data)) {
92
+ return Buffer.from(data.buffer, data.byteOffset, data.byteLength).toString("utf8");
93
+ }
94
+ return null;
95
+ }