@chbo297/infoflow 2026.2.23
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 +21 -0
- package/README.md +74 -0
- package/index.ts +18 -0
- package/openclaw.plugin.json +9 -0
- package/package.json +41 -0
- package/src/accounts.ts +131 -0
- package/src/bot.ts +338 -0
- package/src/channel.ts +307 -0
- package/src/infoflow-req-parse.ts +451 -0
- package/src/logging.ts +141 -0
- package/src/monitor.ts +177 -0
- package/src/reply-dispatcher.ts +88 -0
- package/src/runtime.ts +14 -0
- package/src/send.ts +527 -0
- package/src/targets.ts +130 -0
- package/src/types.ts +127 -0
package/src/types.ts
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Infoflow channel type definitions.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
// ---------------------------------------------------------------------------
|
|
6
|
+
// Policy types
|
|
7
|
+
// ---------------------------------------------------------------------------
|
|
8
|
+
|
|
9
|
+
export type InfoflowDmPolicy = "open" | "pairing" | "allowlist";
|
|
10
|
+
export type InfoflowGroupPolicy = "open" | "allowlist" | "disabled";
|
|
11
|
+
export type InfoflowChatType = "direct" | "group";
|
|
12
|
+
|
|
13
|
+
// ---------------------------------------------------------------------------
|
|
14
|
+
// AT mention types
|
|
15
|
+
// ---------------------------------------------------------------------------
|
|
16
|
+
|
|
17
|
+
/** AT mention options for @mentioning members in group messages */
|
|
18
|
+
export type InfoflowAtOptions = {
|
|
19
|
+
/** @all members; when true, atUserIds is ignored */
|
|
20
|
+
atAll?: boolean;
|
|
21
|
+
/** List of user IDs (uuapName) to @mention */
|
|
22
|
+
atUserIds?: string[];
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
/** Group message body item type */
|
|
26
|
+
export type InfoflowGroupMessageBodyItem =
|
|
27
|
+
| { type: "TEXT"; content: string }
|
|
28
|
+
| { type: "MD"; content: string }
|
|
29
|
+
| { type: "AT"; atall?: boolean; atuserids: string[] }
|
|
30
|
+
| { type: "LINK"; href: string };
|
|
31
|
+
|
|
32
|
+
/** Content item for sendInfoflowMessage */
|
|
33
|
+
export type InfoflowMessageContentItem = {
|
|
34
|
+
type: "text" | "markdown" | "at" | "link";
|
|
35
|
+
content: string;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
// ---------------------------------------------------------------------------
|
|
39
|
+
// Account configuration
|
|
40
|
+
// ---------------------------------------------------------------------------
|
|
41
|
+
|
|
42
|
+
export type InfoflowAccountConfig = {
|
|
43
|
+
enabled?: boolean;
|
|
44
|
+
name?: string;
|
|
45
|
+
apiHost?: string;
|
|
46
|
+
checkToken?: string;
|
|
47
|
+
encodingAESKey?: string;
|
|
48
|
+
appKey?: string;
|
|
49
|
+
appSecret?: string;
|
|
50
|
+
dmPolicy?: InfoflowDmPolicy;
|
|
51
|
+
allowFrom?: string[];
|
|
52
|
+
groupPolicy?: InfoflowGroupPolicy;
|
|
53
|
+
groupAllowFrom?: string[];
|
|
54
|
+
requireMention?: boolean;
|
|
55
|
+
/** Robot name for matching @mentions in group messages */
|
|
56
|
+
robotName?: string;
|
|
57
|
+
accounts?: Record<string, InfoflowAccountConfig>;
|
|
58
|
+
defaultAccount?: string;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export type ResolvedInfoflowAccount = {
|
|
62
|
+
accountId: string;
|
|
63
|
+
name?: string;
|
|
64
|
+
enabled: boolean;
|
|
65
|
+
configured: boolean;
|
|
66
|
+
config: {
|
|
67
|
+
enabled?: boolean;
|
|
68
|
+
name?: string;
|
|
69
|
+
apiHost: string;
|
|
70
|
+
checkToken: string;
|
|
71
|
+
encodingAESKey: string;
|
|
72
|
+
appKey: string;
|
|
73
|
+
appSecret: string;
|
|
74
|
+
dmPolicy?: InfoflowDmPolicy;
|
|
75
|
+
allowFrom?: string[];
|
|
76
|
+
groupPolicy?: InfoflowGroupPolicy;
|
|
77
|
+
groupAllowFrom?: string[];
|
|
78
|
+
requireMention?: boolean;
|
|
79
|
+
/** Robot name for matching @mentions in group messages */
|
|
80
|
+
robotName?: string;
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
// ---------------------------------------------------------------------------
|
|
85
|
+
// Message types
|
|
86
|
+
// ---------------------------------------------------------------------------
|
|
87
|
+
|
|
88
|
+
export type InfoflowMessageEvent = {
|
|
89
|
+
fromuser: string;
|
|
90
|
+
mes: string;
|
|
91
|
+
chatType: InfoflowChatType;
|
|
92
|
+
groupId?: number;
|
|
93
|
+
senderName?: string;
|
|
94
|
+
/** Whether the bot was @mentioned in the message */
|
|
95
|
+
wasMentioned?: boolean;
|
|
96
|
+
/** Original message ID from Infoflow */
|
|
97
|
+
messageId?: string;
|
|
98
|
+
/** Unix millisecond timestamp of the message */
|
|
99
|
+
timestamp?: number;
|
|
100
|
+
/** Raw message text preserving @mentions (for RawBody) */
|
|
101
|
+
rawMes?: string;
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
// ---------------------------------------------------------------------------
|
|
105
|
+
// Handler parameter types
|
|
106
|
+
// ---------------------------------------------------------------------------
|
|
107
|
+
|
|
108
|
+
export type HandleInfoflowMessageParams = {
|
|
109
|
+
cfg: import("openclaw/plugin-sdk").OpenClawConfig;
|
|
110
|
+
event: InfoflowMessageEvent;
|
|
111
|
+
accountId: string;
|
|
112
|
+
statusSink?: (patch: { lastInboundAt?: number; lastOutboundAt?: number }) => void;
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
export type HandlePrivateChatParams = {
|
|
116
|
+
cfg: import("openclaw/plugin-sdk").OpenClawConfig;
|
|
117
|
+
msgData: Record<string, unknown>;
|
|
118
|
+
accountId: string;
|
|
119
|
+
statusSink?: (patch: { lastInboundAt?: number; lastOutboundAt?: number }) => void;
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
export type HandleGroupChatParams = {
|
|
123
|
+
cfg: import("openclaw/plugin-sdk").OpenClawConfig;
|
|
124
|
+
msgData: Record<string, unknown>;
|
|
125
|
+
accountId: string;
|
|
126
|
+
statusSink?: (patch: { lastInboundAt?: number; lastOutboundAt?: number }) => void;
|
|
127
|
+
};
|