@unlinearity/cli-wechat-bridge 1.0.0
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/LICENSE.txt +21 -0
- package/README.md +531 -0
- package/bin/_run-entry.mjs +41 -0
- package/bin/wechat-bridge-claude.mjs +5 -0
- package/bin/wechat-bridge-codex.mjs +5 -0
- package/bin/wechat-bridge-opencode.mjs +5 -0
- package/bin/wechat-bridge-shell.mjs +5 -0
- package/bin/wechat-bridge.mjs +5 -0
- package/bin/wechat-check-update.mjs +5 -0
- package/bin/wechat-claude-start.mjs +5 -0
- package/bin/wechat-claude.mjs +5 -0
- package/bin/wechat-codex-start.mjs +5 -0
- package/bin/wechat-codex.mjs +5 -0
- package/bin/wechat-opencode-start.mjs +5 -0
- package/bin/wechat-opencode.mjs +5 -0
- package/package.json +86 -0
- package/src/bridge/bridge-adapters.claude.ts +1047 -0
- package/src/bridge/bridge-adapters.codex.ts +2733 -0
- package/src/bridge/bridge-adapters.core.ts +877 -0
- package/src/bridge/bridge-adapters.opencode.ts +2390 -0
- package/src/bridge/bridge-adapters.shared.ts +1647 -0
- package/src/bridge/bridge-adapters.shell.ts +456 -0
- package/src/bridge/bridge-adapters.ts +30 -0
- package/src/bridge/bridge-controller.ts +58 -0
- package/src/bridge/bridge-final-reply.ts +56 -0
- package/src/bridge/bridge-process-reaper.ts +417 -0
- package/src/bridge/bridge-state.ts +520 -0
- package/src/bridge/bridge-types.ts +218 -0
- package/src/bridge/bridge-utils.ts +1524 -0
- package/src/bridge/claude-hook.ts +92 -0
- package/src/bridge/claude-hooks.ts +376 -0
- package/src/bridge/wechat-bridge.ts +1305 -0
- package/src/commands/check-update.ts +46 -0
- package/src/companion/codex-panel-link.ts +151 -0
- package/src/companion/codex-panel.ts +225 -0
- package/src/companion/codex-remote-client.ts +178 -0
- package/src/companion/local-companion-link.ts +338 -0
- package/src/companion/local-companion-start.ts +520 -0
- package/src/companion/local-companion.ts +532 -0
- package/src/media/media-types.ts +11 -0
- package/src/runtime/create-runtime-host.ts +16 -0
- package/src/runtime/legacy-adapter-runtime.ts +55 -0
- package/src/runtime/runtime-types.ts +51 -0
- package/src/utils/version-checker.ts +197 -0
- package/src/wechat/channel-config.ts +141 -0
- package/src/wechat/setup.ts +232 -0
- package/src/wechat/standalone-bot.ts +483 -0
- package/src/wechat/wechat-channel.ts +608 -0
- package/src/wechat/wechat-transport.ts +1290 -0
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
export type BridgeAdapterKind = "codex" | "claude" | "opencode" | "shell";
|
|
2
|
+
export type BridgeLifecycleMode = "persistent" | "companion_bound";
|
|
3
|
+
export type BridgeTurnOrigin = "wechat" | "local";
|
|
4
|
+
export type BridgeSessionSwitchSource = BridgeTurnOrigin | "restore";
|
|
5
|
+
export type BridgeSessionSwitchReason =
|
|
6
|
+
| "local_follow"
|
|
7
|
+
| "local_session_fallback"
|
|
8
|
+
| "local_turn"
|
|
9
|
+
| "wechat_resume"
|
|
10
|
+
| "startup_restore";
|
|
11
|
+
export type BridgeThreadSwitchSource = BridgeSessionSwitchSource;
|
|
12
|
+
export type BridgeThreadSwitchReason = BridgeSessionSwitchReason;
|
|
13
|
+
|
|
14
|
+
export type BridgeWorkerStatus =
|
|
15
|
+
| "starting"
|
|
16
|
+
| "idle"
|
|
17
|
+
| "busy"
|
|
18
|
+
| "awaiting_approval"
|
|
19
|
+
| "awaiting_input"
|
|
20
|
+
| "stopped"
|
|
21
|
+
| "error";
|
|
22
|
+
|
|
23
|
+
export type BridgeNoticeLevel = "info" | "warning";
|
|
24
|
+
|
|
25
|
+
export type ApprovalSource = "shell" | "cli";
|
|
26
|
+
|
|
27
|
+
export type ApprovalRequest = {
|
|
28
|
+
source: ApprovalSource;
|
|
29
|
+
summary: string;
|
|
30
|
+
commandPreview: string;
|
|
31
|
+
toolName?: string;
|
|
32
|
+
detailLabel?: string;
|
|
33
|
+
detailPreview?: string;
|
|
34
|
+
requestId?: string;
|
|
35
|
+
confirmInput?: string;
|
|
36
|
+
denyInput?: string;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export type PendingApproval = ApprovalRequest & {
|
|
40
|
+
code: string;
|
|
41
|
+
createdAt: string;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export type UserInputRequestOption = {
|
|
45
|
+
label: string;
|
|
46
|
+
description: string;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export type UserInputRequestQuestion = {
|
|
50
|
+
id: string;
|
|
51
|
+
header: string;
|
|
52
|
+
question: string;
|
|
53
|
+
isOther: boolean;
|
|
54
|
+
isSecret: boolean;
|
|
55
|
+
options?: UserInputRequestOption[] | null;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
export type UserInputRequest = {
|
|
59
|
+
summary: string;
|
|
60
|
+
questions: UserInputRequestQuestion[];
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
export type PendingUserInputRequest = UserInputRequest & {
|
|
64
|
+
createdAt: string;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
export type BridgeResumeSessionCandidate = {
|
|
68
|
+
sessionId: string;
|
|
69
|
+
title: string;
|
|
70
|
+
lastUpdatedAt: string;
|
|
71
|
+
source?: string;
|
|
72
|
+
threadId?: string;
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
export type BridgeResumeThreadCandidate = BridgeResumeSessionCandidate;
|
|
76
|
+
|
|
77
|
+
export type BridgeState = {
|
|
78
|
+
instanceId: string;
|
|
79
|
+
adapter: BridgeAdapterKind;
|
|
80
|
+
command: string;
|
|
81
|
+
cwd: string;
|
|
82
|
+
profile?: string;
|
|
83
|
+
bridgeStartedAtMs: number;
|
|
84
|
+
authorizedUserId: string;
|
|
85
|
+
ignoredBacklogCount: number;
|
|
86
|
+
sharedSessionId?: string;
|
|
87
|
+
sharedThreadId?: string;
|
|
88
|
+
resumeConversationId?: string;
|
|
89
|
+
transcriptPath?: string;
|
|
90
|
+
pendingConfirmation?: PendingApproval | null;
|
|
91
|
+
pendingUserInput?: PendingUserInputRequest | null;
|
|
92
|
+
lastActivityAt?: string;
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
export type BridgeAdapterState = {
|
|
96
|
+
kind: BridgeAdapterKind;
|
|
97
|
+
status: BridgeWorkerStatus;
|
|
98
|
+
pid?: number;
|
|
99
|
+
cwd: string;
|
|
100
|
+
command: string;
|
|
101
|
+
profile?: string;
|
|
102
|
+
startedAt?: string;
|
|
103
|
+
lastInputAt?: string;
|
|
104
|
+
lastOutputAt?: string;
|
|
105
|
+
pendingApproval?: ApprovalRequest | null;
|
|
106
|
+
sharedSessionId?: string;
|
|
107
|
+
sharedThreadId?: string;
|
|
108
|
+
activeRuntimeSessionId?: string;
|
|
109
|
+
resumeConversationId?: string;
|
|
110
|
+
transcriptPath?: string;
|
|
111
|
+
lastSessionSwitchAt?: string;
|
|
112
|
+
lastSessionSwitchSource?: BridgeSessionSwitchSource;
|
|
113
|
+
lastSessionSwitchReason?: BridgeSessionSwitchReason;
|
|
114
|
+
lastThreadSwitchAt?: string;
|
|
115
|
+
lastThreadSwitchSource?: BridgeThreadSwitchSource;
|
|
116
|
+
lastThreadSwitchReason?: BridgeThreadSwitchReason;
|
|
117
|
+
activeTurnId?: string;
|
|
118
|
+
activeTurnOrigin?: BridgeTurnOrigin;
|
|
119
|
+
pendingApprovalOrigin?: BridgeTurnOrigin;
|
|
120
|
+
pendingUserInput?: UserInputRequest | null;
|
|
121
|
+
pendingUserInputOrigin?: BridgeTurnOrigin;
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
export type BridgeEvent =
|
|
125
|
+
| {
|
|
126
|
+
type: "stdout";
|
|
127
|
+
text: string;
|
|
128
|
+
timestamp: string;
|
|
129
|
+
}
|
|
130
|
+
| {
|
|
131
|
+
type: "stderr";
|
|
132
|
+
text: string;
|
|
133
|
+
timestamp: string;
|
|
134
|
+
}
|
|
135
|
+
| {
|
|
136
|
+
type: "final_reply";
|
|
137
|
+
text: string;
|
|
138
|
+
timestamp: string;
|
|
139
|
+
}
|
|
140
|
+
| {
|
|
141
|
+
type: "status";
|
|
142
|
+
status: BridgeWorkerStatus;
|
|
143
|
+
message?: string;
|
|
144
|
+
timestamp: string;
|
|
145
|
+
}
|
|
146
|
+
| {
|
|
147
|
+
type: "notice";
|
|
148
|
+
text: string;
|
|
149
|
+
level: BridgeNoticeLevel;
|
|
150
|
+
timestamp: string;
|
|
151
|
+
}
|
|
152
|
+
| {
|
|
153
|
+
type: "approval_required";
|
|
154
|
+
request: ApprovalRequest | PendingApproval;
|
|
155
|
+
timestamp: string;
|
|
156
|
+
}
|
|
157
|
+
| {
|
|
158
|
+
type: "user_input_required";
|
|
159
|
+
request: UserInputRequest | PendingUserInputRequest;
|
|
160
|
+
timestamp: string;
|
|
161
|
+
}
|
|
162
|
+
| {
|
|
163
|
+
type: "mirrored_user_input";
|
|
164
|
+
text: string;
|
|
165
|
+
timestamp: string;
|
|
166
|
+
origin: "local";
|
|
167
|
+
}
|
|
168
|
+
| {
|
|
169
|
+
type: "session_switched";
|
|
170
|
+
sessionId: string;
|
|
171
|
+
source: BridgeSessionSwitchSource;
|
|
172
|
+
reason: BridgeSessionSwitchReason;
|
|
173
|
+
timestamp: string;
|
|
174
|
+
}
|
|
175
|
+
| {
|
|
176
|
+
type: "thread_switched";
|
|
177
|
+
threadId: string;
|
|
178
|
+
source: BridgeThreadSwitchSource;
|
|
179
|
+
reason: BridgeThreadSwitchReason;
|
|
180
|
+
timestamp: string;
|
|
181
|
+
}
|
|
182
|
+
| {
|
|
183
|
+
type: "task_complete";
|
|
184
|
+
exitCode?: number;
|
|
185
|
+
summary?: string;
|
|
186
|
+
timestamp: string;
|
|
187
|
+
}
|
|
188
|
+
| {
|
|
189
|
+
type: "task_failed";
|
|
190
|
+
message: string;
|
|
191
|
+
timestamp: string;
|
|
192
|
+
}
|
|
193
|
+
| {
|
|
194
|
+
type: "fatal_error";
|
|
195
|
+
message: string;
|
|
196
|
+
timestamp: string;
|
|
197
|
+
}
|
|
198
|
+
| {
|
|
199
|
+
type: "shutdown_requested";
|
|
200
|
+
reason: "companion_closed" | "companion_reconnect_timeout";
|
|
201
|
+
message: string;
|
|
202
|
+
exitCode?: number;
|
|
203
|
+
timestamp: string;
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
export interface BridgeAdapter {
|
|
207
|
+
setEventSink(sink: (event: BridgeEvent) => void): void;
|
|
208
|
+
start(): Promise<void>;
|
|
209
|
+
sendInput(text: string): Promise<void>;
|
|
210
|
+
listResumeSessions(limit?: number): Promise<BridgeResumeSessionCandidate[]>;
|
|
211
|
+
resumeSession(sessionId: string): Promise<void>;
|
|
212
|
+
interrupt(): Promise<boolean>;
|
|
213
|
+
reset(): Promise<void>;
|
|
214
|
+
resolveApproval(action: "confirm" | "deny"): Promise<boolean>;
|
|
215
|
+
submitUserInput(answers: Record<string, string[]>): Promise<boolean>;
|
|
216
|
+
dispose(): Promise<void>;
|
|
217
|
+
getState(): BridgeAdapterState;
|
|
218
|
+
}
|