@lansenger-pm/openclaw-lansenger-channel 2.2.0 → 2.2.2
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/openclaw.plugin.json +50 -18
- package/package.json +1 -1
- package/dist/src/send-file-tool.js +0 -68
- package/dist/src/send-file-tool.js.map +0 -1
package/openclaw.plugin.json
CHANGED
|
@@ -1,31 +1,63 @@
|
|
|
1
1
|
{
|
|
2
2
|
"id": "lansenger",
|
|
3
|
-
"kind": "channel",
|
|
4
3
|
"channels": ["lansenger"],
|
|
5
4
|
"name": "Lansenger (蓝信)",
|
|
6
5
|
"description": "Lansenger enterprise messaging channel plugin for OpenClaw / 蓝信企业即时通讯频道插件",
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
"markdownCapable": true,
|
|
15
|
-
"exposure": {
|
|
16
|
-
"configured": true,
|
|
17
|
-
"setup": true,
|
|
18
|
-
"docs": true
|
|
19
|
-
}
|
|
6
|
+
"channelEnvVars": {
|
|
7
|
+
"lansenger": ["LANSENGER_APP_ID", "LANSENGER_APP_SECRET", "LANSENGER_API_GATEWAY_URL"]
|
|
8
|
+
},
|
|
9
|
+
"activation": {
|
|
10
|
+
"onStartup": true,
|
|
11
|
+
"onChannels": ["lansenger"],
|
|
12
|
+
"onConfigPaths": ["channels.lansenger"]
|
|
20
13
|
},
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
|
|
24
|
-
|
|
14
|
+
"contracts": {
|
|
15
|
+
"tools": [
|
|
16
|
+
"lansenger_send_file",
|
|
17
|
+
"lansenger_send_text",
|
|
18
|
+
"lansenger_send_image_url",
|
|
19
|
+
"lansenger_revoke_message",
|
|
20
|
+
"lansenger_send_link_card",
|
|
21
|
+
"lansenger_send_app_articles",
|
|
22
|
+
"lansenger_send_app_card",
|
|
23
|
+
"lansenger_update_dynamic_card",
|
|
24
|
+
"lansenger_query_groups"
|
|
25
|
+
]
|
|
26
|
+
},
|
|
27
|
+
"toolMetadata": {
|
|
28
|
+
"lansenger_send_file": {
|
|
29
|
+
"configSignals": [{ "rootPath": "channels.lansenger", "required": ["appId", "appSecret"] }]
|
|
30
|
+
},
|
|
31
|
+
"lansenger_send_text": {
|
|
32
|
+
"configSignals": [{ "rootPath": "channels.lansenger", "required": ["appId", "appSecret"] }]
|
|
33
|
+
},
|
|
34
|
+
"lansenger_send_image_url": {
|
|
35
|
+
"configSignals": [{ "rootPath": "channels.lansenger", "required": ["appId", "appSecret"] }]
|
|
36
|
+
},
|
|
37
|
+
"lansenger_revoke_message": {
|
|
38
|
+
"configSignals": [{ "rootPath": "channels.lansenger", "required": ["appId", "appSecret"] }]
|
|
39
|
+
},
|
|
40
|
+
"lansenger_send_link_card": {
|
|
41
|
+
"configSignals": [{ "rootPath": "channels.lansenger", "required": ["appId", "appSecret"] }]
|
|
42
|
+
},
|
|
43
|
+
"lansenger_send_app_articles": {
|
|
44
|
+
"configSignals": [{ "rootPath": "channels.lansenger", "required": ["appId", "appSecret"] }]
|
|
45
|
+
},
|
|
46
|
+
"lansenger_send_app_card": {
|
|
47
|
+
"configSignals": [{ "rootPath": "channels.lansenger", "required": ["appId", "appSecret"] }]
|
|
48
|
+
},
|
|
49
|
+
"lansenger_update_dynamic_card": {
|
|
50
|
+
"configSignals": [{ "rootPath": "channels.lansenger", "required": ["appId", "appSecret"] }]
|
|
51
|
+
},
|
|
52
|
+
"lansenger_query_groups": {
|
|
53
|
+
"configSignals": [{ "rootPath": "channels.lansenger", "required": ["appId", "appSecret"] }]
|
|
54
|
+
}
|
|
25
55
|
},
|
|
26
56
|
"skills": ["./skills"],
|
|
27
57
|
"channelConfigs": {
|
|
28
58
|
"lansenger": {
|
|
59
|
+
"label": "Lansenger (蓝信)",
|
|
60
|
+
"description": "Lansenger enterprise messaging channel / 蓝信企业即时通讯频道",
|
|
29
61
|
"schema": {
|
|
30
62
|
"type": "object",
|
|
31
63
|
"additionalProperties": false,
|
package/package.json
CHANGED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import { resolveAccount, makeClient } from "./channel.js";
|
|
2
|
-
import * as path from "node:path";
|
|
3
|
-
import * as fs from "node:fs/promises";
|
|
4
|
-
const SendFileSchema = {
|
|
5
|
-
type: "object",
|
|
6
|
-
properties: {
|
|
7
|
-
filePath: { type: "string", description: "Absolute local path to the file to send. Any path works — Documents, Desktop, workspace, /tmp, etc." },
|
|
8
|
-
caption: { type: "string", description: "Plain-text caption for the file (Markdown will NOT render on Lansenger). Optional." },
|
|
9
|
-
to: { type: "string", description: "Lansenger target chat ID. Optional — if omitted, the file is sent to the current conversation automatically." },
|
|
10
|
-
},
|
|
11
|
-
required: ["filePath"],
|
|
12
|
-
};
|
|
13
|
-
function resolveSessionTarget(ctx) {
|
|
14
|
-
if (ctx.to)
|
|
15
|
-
return ctx.to;
|
|
16
|
-
if (ctx.sessionKey) {
|
|
17
|
-
const parts = String(ctx.sessionKey).split(":");
|
|
18
|
-
if (parts.length >= 3 && parts[2])
|
|
19
|
-
return parts[2];
|
|
20
|
-
}
|
|
21
|
-
return String(ctx.requesterSenderId ?? "");
|
|
22
|
-
}
|
|
23
|
-
export function registerLansengerSendFileTool(api) {
|
|
24
|
-
if (!api.config)
|
|
25
|
-
return;
|
|
26
|
-
const section = api.config.channels?.["lansenger"];
|
|
27
|
-
if (!section)
|
|
28
|
-
return;
|
|
29
|
-
const accounts = section.accounts;
|
|
30
|
-
let account;
|
|
31
|
-
if (accounts && Object.keys(accounts).length > 0) {
|
|
32
|
-
const firstKey = Object.keys(accounts)[0];
|
|
33
|
-
account = resolveAccount(api.config, firstKey);
|
|
34
|
-
}
|
|
35
|
-
else {
|
|
36
|
-
account = resolveAccount(api.config, undefined);
|
|
37
|
-
}
|
|
38
|
-
if (!account.enabled || !account.appId)
|
|
39
|
-
return;
|
|
40
|
-
api.registerTool((ctx) => ({
|
|
41
|
-
name: "lansenger_send_file",
|
|
42
|
-
label: "Lansenger Send File",
|
|
43
|
-
description: "Send a local file as an attachment to the user on Lansenger (蓝信). Use this tool to deliver any file — PDF, image, document, video, etc. The file can be anywhere on the local disk. Do NOT use MEDIA: tags to send files on Lansenger — they silently fail for files outside the workspace; always use this tool instead.",
|
|
44
|
-
parameters: SendFileSchema,
|
|
45
|
-
async execute(_toolCallId, params) {
|
|
46
|
-
const filePath = params.filePath;
|
|
47
|
-
const caption = params.caption ?? "";
|
|
48
|
-
const to = resolveSessionTarget({ ...ctx, to: params.to });
|
|
49
|
-
if (!filePath)
|
|
50
|
-
return { content: [{ type: "text", text: JSON.stringify({ error: "filePath is required" }) }] };
|
|
51
|
-
if (!to)
|
|
52
|
-
return { content: [{ type: "text", text: JSON.stringify({ error: "No target specified and no active session context. Provide a 'to' parameter." }) }] };
|
|
53
|
-
const resolved = path.resolve(filePath);
|
|
54
|
-
try {
|
|
55
|
-
const stat = await fs.stat(resolved);
|
|
56
|
-
if (!stat.isFile())
|
|
57
|
-
return { content: [{ type: "text", text: JSON.stringify({ error: `Not a file: ${filePath}` }) }] };
|
|
58
|
-
}
|
|
59
|
-
catch {
|
|
60
|
-
return { content: [{ type: "text", text: JSON.stringify({ error: `File not found: ${filePath}` }) }] };
|
|
61
|
-
}
|
|
62
|
-
const client = makeClient(account);
|
|
63
|
-
const result = await client.sendFile(to, resolved, caption);
|
|
64
|
-
return { content: [{ type: "text", text: JSON.stringify({ success: result.success, messageId: result.messageId ?? null }) }] };
|
|
65
|
-
},
|
|
66
|
-
}), { name: "lansenger_send_file" });
|
|
67
|
-
}
|
|
68
|
-
//# sourceMappingURL=send-file-tool.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"send-file-tool.js","sourceRoot":"","sources":["../../src/send-file-tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1D,OAAO,KAAK,IAAI,MAAM,W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