@wu529778790/open-im 1.0.3 → 1.1.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.
@@ -0,0 +1,156 @@
1
+ /**
2
+ * WeWork (企业微信/WeCom) Type Definitions
3
+ * 基于企业微信官方 AI_BOT WebSocket 协议
4
+ * 参考: @wecom/wecom-openclaw-plugin
5
+ */
6
+ export type WeWorkConnectionState = 'disconnected' | 'connecting' | 'connected' | 'error';
7
+ export declare const enum WeWorkCommand {
8
+ /** 认证订阅 */
9
+ SUBSCRIBE = "aibot_subscribe",
10
+ /** 心跳 */
11
+ PING = "ping",
12
+ /** 企业微信推送消息(官方协议) */
13
+ AIBOT_CALLBACK = "aibot_msg_callback",
14
+ /** 回复消息(长连接模式必须用此命令,不能用 HTTP response_url) */
15
+ AIBOT_RESPOND_MSG = "aibot_respond_msg",
16
+ /** 主动推送消息(无需回调,用于启动/关闭通知等) */
17
+ AIBOT_SEND_MSG = "aibot_send_msg",
18
+ /** AI bot 响应消息(旧) */
19
+ AIBOT_RESPONSE = "aibot_response"
20
+ }
21
+ export interface WeWorkRequest {
22
+ cmd: string;
23
+ headers: {
24
+ req_id: string;
25
+ };
26
+ body: unknown;
27
+ }
28
+ export interface WeWorkResponse {
29
+ headers: {
30
+ req_id: string;
31
+ };
32
+ errcode: number;
33
+ errmsg: string;
34
+ }
35
+ export interface WeWorkSubscribeRequest extends WeWorkRequest {
36
+ cmd: WeWorkCommand.SUBSCRIBE;
37
+ body: {
38
+ secret: string;
39
+ bot_id: string;
40
+ };
41
+ }
42
+ export interface WeWorkCallbackMessage {
43
+ cmd: WeWorkCommand.AIBOT_CALLBACK;
44
+ headers: {
45
+ req_id: string;
46
+ };
47
+ body: {
48
+ msgid: string;
49
+ aibotid: string;
50
+ chatid: string;
51
+ chattype: 'single' | 'group';
52
+ from: {
53
+ userid: string;
54
+ };
55
+ response_url: string;
56
+ msgtype: 'text' | 'image' | 'voice' | 'video' | 'file' | 'stream' | 'mixed';
57
+ text?: {
58
+ content: string;
59
+ };
60
+ image?: {
61
+ /** 图片 URL(通过 URL 方式接收图片时) */
62
+ url?: string;
63
+ /** 图片 base64 数据(直接传输时) */
64
+ base64?: string;
65
+ md5?: string;
66
+ };
67
+ /** 图文混排消息 */
68
+ mixed?: {
69
+ msg_item: Array<{
70
+ msgtype: 'text' | 'image';
71
+ text?: {
72
+ content: string;
73
+ };
74
+ image?: {
75
+ url?: string;
76
+ base64?: string;
77
+ md5?: string;
78
+ };
79
+ }>;
80
+ };
81
+ quote?: {
82
+ msgtype: string;
83
+ text?: {
84
+ content: string;
85
+ };
86
+ image?: {
87
+ url?: string;
88
+ aeskey?: string;
89
+ };
90
+ file?: {
91
+ url?: string;
92
+ aeskey?: string;
93
+ };
94
+ };
95
+ stream?: {
96
+ id: string;
97
+ };
98
+ };
99
+ }
100
+ export interface WeWorkResponseMessage extends WeWorkRequest {
101
+ cmd: WeWorkCommand.AIBOT_RESPONSE;
102
+ body: {
103
+ msgtype: 'stream' | 'text' | 'markdown';
104
+ stream?: {
105
+ id: string;
106
+ finish: boolean;
107
+ content: string;
108
+ msg_item?: Array<{
109
+ msgtype: 'image' | 'file';
110
+ image?: {
111
+ base64: string;
112
+ md5: string;
113
+ };
114
+ }>;
115
+ feedback?: {
116
+ id: string;
117
+ };
118
+ };
119
+ text?: {
120
+ content: string;
121
+ };
122
+ markdown?: {
123
+ content: string;
124
+ };
125
+ };
126
+ }
127
+ export interface MessageState {
128
+ accumulatedText: string;
129
+ /** 流式回复的 streamId,用于保持同一个流式回复使用相同的 streamId */
130
+ streamId?: string;
131
+ }
132
+ export interface WeWorkResponse {
133
+ headers: {
134
+ req_id: string;
135
+ };
136
+ errcode: number;
137
+ errmsg: string;
138
+ }
139
+ export interface WeWorkHttpResponseBody {
140
+ msgtype: 'text' | 'markdown' | 'stream';
141
+ text?: {
142
+ content: string;
143
+ };
144
+ markdown?: {
145
+ content: string;
146
+ };
147
+ stream?: {
148
+ id: string;
149
+ finish: boolean;
150
+ content: string;
151
+ };
152
+ }
153
+ export interface WeWorkHttpResponse {
154
+ msgtype: 'text' | 'markdown' | 'stream';
155
+ [key: string]: unknown;
156
+ }
@@ -0,0 +1,6 @@
1
+ /**
2
+ * WeWork (企业微信/WeCom) Type Definitions
3
+ * 基于企业微信官方 AI_BOT WebSocket 协议
4
+ * 参考: @wecom/wecom-openclaw-plugin
5
+ */
6
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wu529778790/open-im",
3
- "version": "1.0.3",
3
+ "version": "1.1.0",
4
4
  "description": "Multi-platform IM bridge for AI CLI tools (Claude, Codex, Cursor)",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -43,13 +43,16 @@
43
43
  },
44
44
  "dependencies": {
45
45
  "@larksuiteoapi/node-sdk": "^1.59.0",
46
+ "@wecom/wecom-openclaw-plugin": "^1.0.6",
46
47
  "prompts": "^2.4.2",
48
+ "qrcode-terminal": "^0.12.0",
47
49
  "telegraf": "^4.16.3",
48
50
  "ws": "^8.18.0"
49
51
  },
50
52
  "devDependencies": {
51
53
  "@types/node": "^20.0.0",
52
54
  "@types/prompts": "^2.4.9",
55
+ "@types/qrcode-terminal": "^0.12.2",
53
56
  "@types/ws": "^8.5.13",
54
57
  "dotenv": "^16.0.0",
55
58
  "tsx": "^4.0.0",