@emotion-machine/claw-messenger 0.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.
- package/README.md +68 -0
- package/dist/channel.d.ts +22 -0
- package/dist/channel.js +505 -0
- package/dist/config.d.ts +24 -0
- package/dist/config.js +17 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +109 -0
- package/dist/outbound/send.d.ts +15 -0
- package/dist/outbound/send.js +70 -0
- package/dist/runtime.d.ts +3 -0
- package/dist/runtime.js +10 -0
- package/dist/ws/client.d.ts +48 -0
- package/dist/ws/client.js +208 -0
- package/openclaw.plugin.json +23 -0
- package/package.json +63 -0
- package/src/types/openclaw.d.ts +311 -0
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type declarations for openclaw/plugin-sdk.
|
|
3
|
+
*
|
|
4
|
+
* These are derived from the runtime shapes in openclaw's compiled JS.
|
|
5
|
+
* Since openclaw doesn't ship .d.ts files, we declare the subset we need.
|
|
6
|
+
*/
|
|
7
|
+
declare module "openclaw/plugin-sdk" {
|
|
8
|
+
import { z } from "zod";
|
|
9
|
+
|
|
10
|
+
// ── Config ──
|
|
11
|
+
|
|
12
|
+
export interface OpenclawConfig {
|
|
13
|
+
channels?: Record<string, any>;
|
|
14
|
+
session?: { store?: any };
|
|
15
|
+
[key: string]: any;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// ── Channel Plugin ──
|
|
19
|
+
|
|
20
|
+
export interface ChannelPlugin<T = any> {
|
|
21
|
+
id: string;
|
|
22
|
+
meta: {
|
|
23
|
+
label: string;
|
|
24
|
+
blurb: string;
|
|
25
|
+
docsPath: string;
|
|
26
|
+
docsLabel?: string;
|
|
27
|
+
systemImage?: string;
|
|
28
|
+
quickstartAllowFrom?: boolean;
|
|
29
|
+
aliases?: string[];
|
|
30
|
+
showConfigured?: boolean;
|
|
31
|
+
order?: number;
|
|
32
|
+
selectionLabel?: string;
|
|
33
|
+
detailLabel?: string;
|
|
34
|
+
selectionDocsPrefix?: string;
|
|
35
|
+
selectionDocsOmitLabel?: boolean;
|
|
36
|
+
selectionExtras?: string[];
|
|
37
|
+
};
|
|
38
|
+
pairing?: {
|
|
39
|
+
idLabel: string;
|
|
40
|
+
normalizeAllowEntry?: (entry: string) => string;
|
|
41
|
+
notifyApproval?: (ctx: { cfg: OpenclawConfig; id: string }) => Promise<void>;
|
|
42
|
+
};
|
|
43
|
+
onboarding?: any;
|
|
44
|
+
capabilities: {
|
|
45
|
+
chatTypes: ("direct" | "group" | "channel" | "thread")[];
|
|
46
|
+
reactions?: boolean;
|
|
47
|
+
threads?: boolean;
|
|
48
|
+
media?: boolean;
|
|
49
|
+
nativeCommands?: boolean;
|
|
50
|
+
blockStreaming?: boolean;
|
|
51
|
+
polls?: boolean;
|
|
52
|
+
};
|
|
53
|
+
reload?: { configPrefixes: string[] };
|
|
54
|
+
configSchema?: any;
|
|
55
|
+
config: {
|
|
56
|
+
listAccountIds: (cfg: OpenclawConfig) => string[];
|
|
57
|
+
resolveAccount: (cfg: OpenclawConfig, accountId: string) => T;
|
|
58
|
+
defaultAccountId: (cfg: OpenclawConfig) => string;
|
|
59
|
+
setAccountEnabled: (ctx: { cfg: OpenclawConfig; accountId: string; enabled: boolean }) => OpenclawConfig;
|
|
60
|
+
deleteAccount: (ctx: { cfg: OpenclawConfig; accountId: string }) => OpenclawConfig;
|
|
61
|
+
isConfigured: (account: T) => boolean;
|
|
62
|
+
describeAccount: (account: T) => Record<string, any>;
|
|
63
|
+
resolveAllowFrom: (ctx: { cfg: OpenclawConfig; accountId: string }) => string[];
|
|
64
|
+
formatAllowFrom: (ctx: { allowFrom: string[] }) => string[];
|
|
65
|
+
};
|
|
66
|
+
security?: {
|
|
67
|
+
resolveDmPolicy?: (ctx: { cfg: OpenclawConfig; accountId?: string; account: T }) => {
|
|
68
|
+
policy: string;
|
|
69
|
+
allowFrom: string[];
|
|
70
|
+
policyPath?: string;
|
|
71
|
+
allowFromPath?: string;
|
|
72
|
+
approveHint?: string;
|
|
73
|
+
normalizeEntry?: (raw: string) => string;
|
|
74
|
+
};
|
|
75
|
+
collectWarnings?: (ctx: { account: T; cfg: OpenclawConfig }) => string[];
|
|
76
|
+
};
|
|
77
|
+
groups?: {
|
|
78
|
+
resolveRequireMention?: (ctx: any) => boolean;
|
|
79
|
+
resolveToolPolicy?: (cfg: OpenclawConfig, accountId: string, groupId: string) => string | undefined;
|
|
80
|
+
};
|
|
81
|
+
threading?: any;
|
|
82
|
+
messaging: {
|
|
83
|
+
normalizeTarget: (target: string) => string | null;
|
|
84
|
+
targetResolver: {
|
|
85
|
+
looksLikeId: (raw: string) => boolean;
|
|
86
|
+
hint: string;
|
|
87
|
+
};
|
|
88
|
+
};
|
|
89
|
+
directory?: any;
|
|
90
|
+
resolver?: any;
|
|
91
|
+
actions?: any;
|
|
92
|
+
setup?: {
|
|
93
|
+
resolveAccountId?: (ctx: { accountId?: string }) => string;
|
|
94
|
+
applyAccountName?: (ctx: { cfg: OpenclawConfig; accountId: string; name?: string }) => OpenclawConfig;
|
|
95
|
+
validateInput?: (ctx: { accountId: string; input: any }) => string | null;
|
|
96
|
+
applyAccountConfig?: (ctx: { cfg: OpenclawConfig; accountId: string; input: any }) => OpenclawConfig;
|
|
97
|
+
};
|
|
98
|
+
outbound?: {
|
|
99
|
+
deliveryMode: "direct" | "buffered" | "coalesced";
|
|
100
|
+
chunker?: ((text: string, limit: number) => string[]) | null;
|
|
101
|
+
chunkerMode?: "plain" | "markdown" | "text";
|
|
102
|
+
textChunkLimit?: number;
|
|
103
|
+
sendText?: (ctx: {
|
|
104
|
+
to: string;
|
|
105
|
+
text: string;
|
|
106
|
+
accountId?: string;
|
|
107
|
+
cfg?: OpenclawConfig;
|
|
108
|
+
deps?: any;
|
|
109
|
+
replyToId?: string;
|
|
110
|
+
threadId?: string;
|
|
111
|
+
}) => Promise<{ channel: string; [key: string]: any }>;
|
|
112
|
+
sendMedia?: (ctx: {
|
|
113
|
+
to: string;
|
|
114
|
+
text: string;
|
|
115
|
+
mediaUrl: string;
|
|
116
|
+
accountId?: string;
|
|
117
|
+
cfg?: OpenclawConfig;
|
|
118
|
+
deps?: any;
|
|
119
|
+
replyToId?: string;
|
|
120
|
+
threadId?: string;
|
|
121
|
+
}) => Promise<{ channel: string; [key: string]: any }>;
|
|
122
|
+
sendPayload?: (ctx: any) => Promise<{ channel: string; [key: string]: any }>;
|
|
123
|
+
};
|
|
124
|
+
status?: {
|
|
125
|
+
defaultRuntime?: any;
|
|
126
|
+
collectStatusIssues?: (ctx: any) => any;
|
|
127
|
+
buildChannelSummary?: (ctx: any) => any;
|
|
128
|
+
probeAccount?: (ctx: { account: T; timeoutMs: number }) => Promise<any>;
|
|
129
|
+
auditAccount?: (ctx: any) => Promise<any>;
|
|
130
|
+
buildAccountSnapshot?: (ctx: { account: T; cfg?: OpenclawConfig; runtime?: any; probe?: any }) => any;
|
|
131
|
+
resolveAccountState?: (ctx: any) => string;
|
|
132
|
+
};
|
|
133
|
+
gateway?: {
|
|
134
|
+
startAccount?: (ctx: {
|
|
135
|
+
account: T;
|
|
136
|
+
cfg: OpenclawConfig;
|
|
137
|
+
runtime: PluginRuntime;
|
|
138
|
+
abortSignal: AbortSignal;
|
|
139
|
+
log?: any;
|
|
140
|
+
setStatus?: (state: any) => void;
|
|
141
|
+
}) => Promise<any>;
|
|
142
|
+
logoutAccount?: (ctx: { accountId: string; cfg: OpenclawConfig }) => Promise<any>;
|
|
143
|
+
};
|
|
144
|
+
streaming?: any;
|
|
145
|
+
agentPrompt?: any;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
// ── Plugin Runtime ──
|
|
149
|
+
|
|
150
|
+
export interface PluginRuntime {
|
|
151
|
+
version: string;
|
|
152
|
+
config: {
|
|
153
|
+
loadConfig(): OpenclawConfig;
|
|
154
|
+
writeConfigFile(cfg: OpenclawConfig): Promise<void>;
|
|
155
|
+
};
|
|
156
|
+
system: {
|
|
157
|
+
enqueueSystemEvent(event: any): void;
|
|
158
|
+
[key: string]: any;
|
|
159
|
+
};
|
|
160
|
+
media: {
|
|
161
|
+
loadWebMedia(url: string): Promise<any>;
|
|
162
|
+
detectMime(buffer: Buffer): string | undefined;
|
|
163
|
+
[key: string]: any;
|
|
164
|
+
};
|
|
165
|
+
channel: {
|
|
166
|
+
text: {
|
|
167
|
+
chunkText(text: string, limit: number): string[];
|
|
168
|
+
chunkMarkdownText(text: string, limit: number): string[];
|
|
169
|
+
chunkMarkdownTextWithMode(text: string, limit: number, mode: string): string[];
|
|
170
|
+
resolveChunkMode(cfg: OpenclawConfig, channel: string): string;
|
|
171
|
+
resolveTextChunkLimit?(cfg: OpenclawConfig, channel: string, accountId?: string, opts?: any): number;
|
|
172
|
+
hasControlCommand(text: string, cfg: OpenclawConfig): boolean;
|
|
173
|
+
[key: string]: any;
|
|
174
|
+
};
|
|
175
|
+
reply: {
|
|
176
|
+
dispatchReplyWithBufferedBlockDispatcher(ctx: any): Promise<any>;
|
|
177
|
+
resolveEffectiveMessagesConfig(cfg: OpenclawConfig, agentId?: string): any;
|
|
178
|
+
formatInboundEnvelope(ctx: any): string;
|
|
179
|
+
finalizeInboundContext(ctx: any): any;
|
|
180
|
+
resolveEnvelopeFormatOptions(cfg: OpenclawConfig): any;
|
|
181
|
+
[key: string]: any;
|
|
182
|
+
};
|
|
183
|
+
routing: {
|
|
184
|
+
resolveAgentRoute(ctx: {
|
|
185
|
+
cfg: OpenclawConfig;
|
|
186
|
+
channel: string;
|
|
187
|
+
accountId: string;
|
|
188
|
+
peer: { kind: "dm" | "group" | "channel"; id: string };
|
|
189
|
+
}): { sessionKey: string; accountId: string; agentId?: string; mainSessionKey?: string; [key: string]: any };
|
|
190
|
+
};
|
|
191
|
+
pairing: {
|
|
192
|
+
buildPairingReply(ctx: { channel: string; idLine: string; code: string }): string;
|
|
193
|
+
readAllowFromStore(channel: string): Promise<string[]>;
|
|
194
|
+
upsertPairingRequest(ctx: { channel: string; id: string; meta?: { name?: string } }): Promise<{ code: string; created: boolean }>;
|
|
195
|
+
};
|
|
196
|
+
media: {
|
|
197
|
+
fetchRemoteMedia(ctx: { url: string }): Promise<{ buffer: Buffer; contentType?: string }>;
|
|
198
|
+
saveMediaBuffer(buffer: Uint8Array, contentType: string | undefined, direction: "inbound" | "outbound", maxBytes: number): Promise<{ path: string; contentType?: string }>;
|
|
199
|
+
};
|
|
200
|
+
session: {
|
|
201
|
+
resolveStorePath(store: any, opts?: { agentId?: string }): string;
|
|
202
|
+
readSessionUpdatedAt(path: string, sessionKey: string): number | null;
|
|
203
|
+
recordSessionMetaFromInbound(ctx: any): Promise<void>;
|
|
204
|
+
recordInboundSession(ctx: any): void;
|
|
205
|
+
updateLastRoute(ctx: any): void;
|
|
206
|
+
};
|
|
207
|
+
activity: {
|
|
208
|
+
record(ctx: any): void;
|
|
209
|
+
get(ctx: any): any;
|
|
210
|
+
};
|
|
211
|
+
[key: string]: any;
|
|
212
|
+
};
|
|
213
|
+
logging: {
|
|
214
|
+
shouldLogVerbose(): boolean;
|
|
215
|
+
getChildLogger(bindings: string, opts?: any): any;
|
|
216
|
+
};
|
|
217
|
+
state: {
|
|
218
|
+
resolveStateDir(cfg: OpenclawConfig): string;
|
|
219
|
+
};
|
|
220
|
+
[key: string]: any;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
// ── Plugin API ──
|
|
224
|
+
|
|
225
|
+
export interface OpenclawPluginApi {
|
|
226
|
+
id: string;
|
|
227
|
+
name: string;
|
|
228
|
+
version: string;
|
|
229
|
+
description: string;
|
|
230
|
+
source: string;
|
|
231
|
+
config: OpenclawConfig;
|
|
232
|
+
pluginConfig: any;
|
|
233
|
+
runtime: PluginRuntime;
|
|
234
|
+
logger: any;
|
|
235
|
+
registerChannel(registration: { plugin: ChannelPlugin }): void;
|
|
236
|
+
registerProvider(provider: any): void;
|
|
237
|
+
registerTool(tool: any, opts?: any): void;
|
|
238
|
+
registerHook(events: string | string[], handler: any, opts?: any): void;
|
|
239
|
+
registerHttpHandler(handler: any): void;
|
|
240
|
+
registerHttpRoute(params: { path: string; handler: any }): void;
|
|
241
|
+
registerGatewayMethod(method: string, handler: any): void;
|
|
242
|
+
registerCli(registrar: any, opts?: any): void;
|
|
243
|
+
registerService(service: any): void;
|
|
244
|
+
registerCommand(command: any): void;
|
|
245
|
+
resolvePath(input: string): string;
|
|
246
|
+
on(hookName: string, handler: any, opts?: any): void;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
// ── Helpers ──
|
|
250
|
+
|
|
251
|
+
export const DEFAULT_ACCOUNT_ID: string;
|
|
252
|
+
export const PAIRING_APPROVED_MESSAGE: string;
|
|
253
|
+
|
|
254
|
+
export function normalizeAccountId(accountId?: string | null): string;
|
|
255
|
+
export function normalizeE164(input: string): string | null;
|
|
256
|
+
export function buildChannelConfigSchema(schema: any): any;
|
|
257
|
+
export function emptyPluginConfigSchema(): any;
|
|
258
|
+
export function getChatChannelMeta(channel: string): any;
|
|
259
|
+
export function formatPairingApproveHint(channel: string): string;
|
|
260
|
+
|
|
261
|
+
export function setAccountEnabledInConfigSection(ctx: {
|
|
262
|
+
cfg: OpenclawConfig;
|
|
263
|
+
sectionKey: string;
|
|
264
|
+
accountId: string;
|
|
265
|
+
enabled: boolean;
|
|
266
|
+
allowTopLevel?: boolean;
|
|
267
|
+
}): OpenclawConfig;
|
|
268
|
+
|
|
269
|
+
export function deleteAccountFromConfigSection(ctx: {
|
|
270
|
+
cfg: OpenclawConfig;
|
|
271
|
+
sectionKey: string;
|
|
272
|
+
accountId: string;
|
|
273
|
+
clearBaseFields?: string[];
|
|
274
|
+
}): OpenclawConfig;
|
|
275
|
+
|
|
276
|
+
export function registerPluginHttpRoute(params: {
|
|
277
|
+
path: string;
|
|
278
|
+
pluginId?: string;
|
|
279
|
+
accountId?: string;
|
|
280
|
+
source?: string;
|
|
281
|
+
log?: (msg: string) => void;
|
|
282
|
+
handler: (req: any, res: any) => Promise<void> | void;
|
|
283
|
+
registry?: any;
|
|
284
|
+
fallbackPath?: string;
|
|
285
|
+
}): () => void;
|
|
286
|
+
|
|
287
|
+
export function normalizePluginHttpPath(path?: string, fallback?: string): string | null;
|
|
288
|
+
|
|
289
|
+
// ── Ack Reactions ──
|
|
290
|
+
|
|
291
|
+
export function resolveAckReaction(cfg: OpenclawConfig, agentId?: string): string | undefined;
|
|
292
|
+
|
|
293
|
+
export function shouldAckReaction(params: {
|
|
294
|
+
scope: string;
|
|
295
|
+
isDirect: boolean;
|
|
296
|
+
isGroup: boolean;
|
|
297
|
+
isMentionableGroup?: boolean;
|
|
298
|
+
requireMention?: boolean;
|
|
299
|
+
canDetectMention?: boolean;
|
|
300
|
+
effectiveWasMentioned?: boolean;
|
|
301
|
+
shouldBypassMention?: boolean;
|
|
302
|
+
}): boolean;
|
|
303
|
+
|
|
304
|
+
// Config schemas
|
|
305
|
+
export const IMessageConfigSchema: any;
|
|
306
|
+
export const TelegramConfigSchema: any;
|
|
307
|
+
export const DiscordConfigSchema: any;
|
|
308
|
+
export const SlackConfigSchema: any;
|
|
309
|
+
export const SignalConfigSchema: any;
|
|
310
|
+
export const WhatsAppConfigSchema: any;
|
|
311
|
+
}
|