@openclaw-china/wecom 2026.3.22 → 2026.3.29
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/dist/index.d.ts +26 -0
- package/dist/index.js +89 -0
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/skills/wecom-doc/SKILL.md +120 -120
package/dist/index.d.ts
CHANGED
|
@@ -103,6 +103,13 @@ interface PluginConfig {
|
|
|
103
103
|
};
|
|
104
104
|
}
|
|
105
105
|
|
|
106
|
+
type WecomMessageActionName = "send" | "sendAttachment";
|
|
107
|
+
interface WecomMessageToolResult {
|
|
108
|
+
ok: boolean;
|
|
109
|
+
messageId?: string;
|
|
110
|
+
error?: string;
|
|
111
|
+
[key: string]: unknown;
|
|
112
|
+
}
|
|
106
113
|
declare const wecomPlugin: {
|
|
107
114
|
id: string;
|
|
108
115
|
meta: {
|
|
@@ -463,6 +470,25 @@ declare const wecomPlugin: {
|
|
|
463
470
|
setStatus?: (status: Record<string, unknown>) => void;
|
|
464
471
|
}) => Promise<void>;
|
|
465
472
|
};
|
|
473
|
+
actions: {
|
|
474
|
+
describeMessageTool: () => {
|
|
475
|
+
actions: WecomMessageActionName[];
|
|
476
|
+
capabilities: string[];
|
|
477
|
+
schema?: {
|
|
478
|
+
properties: Record<string, unknown>;
|
|
479
|
+
visibility?: "current-channel" | "all-configured";
|
|
480
|
+
};
|
|
481
|
+
};
|
|
482
|
+
handleAction: (ctx: {
|
|
483
|
+
channel: string;
|
|
484
|
+
action: string;
|
|
485
|
+
params: Record<string, unknown>;
|
|
486
|
+
cfg: PluginConfig;
|
|
487
|
+
accountId?: string | null;
|
|
488
|
+
sessionKey?: string | null;
|
|
489
|
+
sessionId?: string | null;
|
|
490
|
+
}) => Promise<WecomMessageToolResult>;
|
|
491
|
+
};
|
|
466
492
|
};
|
|
467
493
|
|
|
468
494
|
/**
|
package/dist/index.js
CHANGED
|
@@ -10178,6 +10178,91 @@ function stopWecomWsGatewayForAccount(accountId) {
|
|
|
10178
10178
|
}
|
|
10179
10179
|
|
|
10180
10180
|
// src/channel.ts
|
|
10181
|
+
function readStringParam(params, name, opts) {
|
|
10182
|
+
const value = params[name];
|
|
10183
|
+
if (value === void 0 || value === null) {
|
|
10184
|
+
if (opts?.required) {
|
|
10185
|
+
throw new Error(`wecom ${name} param is required`);
|
|
10186
|
+
}
|
|
10187
|
+
return void 0;
|
|
10188
|
+
}
|
|
10189
|
+
const str = String(value);
|
|
10190
|
+
return opts?.trim ? str.trim() : str;
|
|
10191
|
+
}
|
|
10192
|
+
async function handleWecomMessageAction(ctx, outbound) {
|
|
10193
|
+
const { action, params, cfg, accountId, sessionKey, sessionId } = ctx;
|
|
10194
|
+
const commonParams = {
|
|
10195
|
+
cfg,
|
|
10196
|
+
accountId: accountId ?? void 0,
|
|
10197
|
+
sessionKey: sessionKey ?? void 0,
|
|
10198
|
+
runId: sessionId ?? void 0
|
|
10199
|
+
};
|
|
10200
|
+
if (action === "send") {
|
|
10201
|
+
const to = readStringParam(params, "to", { required: true });
|
|
10202
|
+
const message = readStringParam(params, "message", { required: false, trim: true }) ?? "";
|
|
10203
|
+
const media = readStringParam(params, "media", { trim: false });
|
|
10204
|
+
if (!to) {
|
|
10205
|
+
return { ok: false, error: "wecom send requires 'to' param" };
|
|
10206
|
+
}
|
|
10207
|
+
if (media) {
|
|
10208
|
+
const result = await outbound.sendMedia({
|
|
10209
|
+
...commonParams,
|
|
10210
|
+
to,
|
|
10211
|
+
mediaUrl: media,
|
|
10212
|
+
text: message || void 0
|
|
10213
|
+
});
|
|
10214
|
+
if (!result.ok) {
|
|
10215
|
+
return { ok: false, error: result.error?.message ?? "sendMedia failed" };
|
|
10216
|
+
}
|
|
10217
|
+
return { ok: true, messageId: result.messageId };
|
|
10218
|
+
} else {
|
|
10219
|
+
const result = await outbound.sendText({
|
|
10220
|
+
...commonParams,
|
|
10221
|
+
to,
|
|
10222
|
+
text: message
|
|
10223
|
+
});
|
|
10224
|
+
if (!result.ok) {
|
|
10225
|
+
return { ok: false, error: result.error?.message ?? "sendText failed" };
|
|
10226
|
+
}
|
|
10227
|
+
return { ok: true, messageId: result.messageId };
|
|
10228
|
+
}
|
|
10229
|
+
}
|
|
10230
|
+
if (action === "sendAttachment") {
|
|
10231
|
+
const to = readStringParam(params, "to", { required: true });
|
|
10232
|
+
const media = readStringParam(params, "media", { trim: false });
|
|
10233
|
+
const caption = readStringParam(params, "caption", { required: false, trim: true });
|
|
10234
|
+
if (!to) {
|
|
10235
|
+
return { ok: false, error: "wecom sendAttachment requires 'to' param" };
|
|
10236
|
+
}
|
|
10237
|
+
if (!media) {
|
|
10238
|
+
return { ok: false, error: "wecom sendAttachment requires 'media' param" };
|
|
10239
|
+
}
|
|
10240
|
+
const result = await outbound.sendMedia({
|
|
10241
|
+
...commonParams,
|
|
10242
|
+
to,
|
|
10243
|
+
mediaUrl: media,
|
|
10244
|
+
text: caption
|
|
10245
|
+
});
|
|
10246
|
+
if (!result.ok) {
|
|
10247
|
+
return { ok: false, error: result.error?.message ?? "sendMedia failed" };
|
|
10248
|
+
}
|
|
10249
|
+
return { ok: true, messageId: result.messageId };
|
|
10250
|
+
}
|
|
10251
|
+
return { ok: false, error: `Unsupported wecom action: ${action}` };
|
|
10252
|
+
}
|
|
10253
|
+
function describeWecomMessageTool() {
|
|
10254
|
+
return {
|
|
10255
|
+
actions: ["send", "sendAttachment"],
|
|
10256
|
+
capabilities: ["media"],
|
|
10257
|
+
schema: {
|
|
10258
|
+
properties: {
|
|
10259
|
+
media: { type: "string", description: "Media file URL or local file path (for file/image/audio/video attachments)" },
|
|
10260
|
+
caption: { type: "string", description: "Optional caption text for the media" }
|
|
10261
|
+
},
|
|
10262
|
+
visibility: "current-channel"
|
|
10263
|
+
}
|
|
10264
|
+
};
|
|
10265
|
+
}
|
|
10181
10266
|
var BARE_USER_ID_RE = /^[a-z0-9][a-z0-9._@-]{0,63}$/;
|
|
10182
10267
|
var EXPLICIT_USER_ID_RE = /^[A-Za-z0-9][A-Za-z0-9._@-]{0,63}$/;
|
|
10183
10268
|
var GROUP_ID_RE = /^[A-Za-z0-9][A-Za-z0-9._:@-]{0,127}$/;
|
|
@@ -10932,6 +11017,10 @@ var wecomPlugin = {
|
|
|
10932
11017
|
stopWecomWsGatewayForAccount(ctx.accountId);
|
|
10933
11018
|
ctx.setStatus?.({ accountId: ctx.accountId, running: false, lastStopAt: Date.now() });
|
|
10934
11019
|
}
|
|
11020
|
+
},
|
|
11021
|
+
actions: {
|
|
11022
|
+
describeMessageTool: () => describeWecomMessageTool(),
|
|
11023
|
+
handleAction: async (ctx) => handleWecomMessageAction(ctx, wecomPlugin.outbound)
|
|
10935
11024
|
}
|
|
10936
11025
|
};
|
|
10937
11026
|
|