@nextclaw/channel-plugin-feishu 0.2.29-beta.0 → 0.2.29-beta.1
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 +23 -0
- package/dist/index.js +45 -0
- package/dist/src/accounts.js +141 -0
- package/dist/src/app-scope-checker.js +36 -0
- package/dist/src/async.js +34 -0
- package/dist/src/auth-errors.js +72 -0
- package/dist/src/bitable.js +495 -0
- package/dist/src/bot.d.ts +35 -0
- package/dist/src/bot.js +941 -0
- package/dist/src/calendar-calendar.js +54 -0
- package/dist/src/calendar-event-attendee.js +98 -0
- package/dist/src/calendar-event.js +193 -0
- package/dist/src/calendar-freebusy.js +40 -0
- package/dist/src/calendar-shared.js +23 -0
- package/dist/src/calendar.js +16 -0
- package/dist/src/card-action.js +49 -0
- package/dist/src/channel.d.ts +7 -0
- package/dist/src/channel.js +413 -0
- package/dist/src/chat-schema.js +25 -0
- package/dist/src/chat.js +87 -0
- package/dist/src/client.d.ts +16 -0
- package/dist/src/client.js +112 -0
- package/dist/src/config-schema.d.ts +357 -0
- package/dist/src/dedup.js +126 -0
- package/dist/src/device-flow.js +109 -0
- package/dist/src/directory.js +101 -0
- package/dist/src/doc-schema.js +148 -0
- package/dist/src/docx-batch-insert.js +104 -0
- package/dist/src/docx-color-text.js +80 -0
- package/dist/src/docx-table-ops.js +197 -0
- package/dist/src/docx.js +858 -0
- package/dist/src/domains.js +14 -0
- package/dist/src/drive-schema.js +41 -0
- package/dist/src/drive.js +126 -0
- package/dist/src/dynamic-agent.js +93 -0
- package/dist/src/external-keys.js +13 -0
- package/dist/src/feishu-fetch.js +12 -0
- package/dist/src/identity.js +92 -0
- package/dist/src/lark-ticket.js +11 -0
- package/dist/src/media.d.ts +75 -0
- package/dist/src/media.js +304 -0
- package/dist/src/mention.d.ts +52 -0
- package/dist/src/mention.js +82 -0
- package/dist/src/monitor.account.d.ts +1 -0
- package/dist/src/monitor.account.js +393 -0
- package/dist/src/monitor.d.ts +11 -0
- package/dist/src/monitor.js +58 -0
- package/dist/src/monitor.startup.js +24 -0
- package/dist/src/monitor.state.d.ts +1 -0
- package/dist/src/monitor.state.js +80 -0
- package/dist/src/monitor.transport.js +167 -0
- package/dist/src/nextclaw-sdk/account-id.js +15 -0
- package/dist/src/nextclaw-sdk/core-channel.js +150 -0
- package/dist/src/nextclaw-sdk/core-pairing.js +151 -0
- package/dist/src/nextclaw-sdk/dedupe.js +164 -0
- package/dist/src/nextclaw-sdk/feishu.d.ts +1 -0
- package/dist/src/nextclaw-sdk/feishu.js +14 -0
- package/dist/src/nextclaw-sdk/history.js +69 -0
- package/dist/src/nextclaw-sdk/network-body.js +180 -0
- package/dist/src/nextclaw-sdk/network-fetch.js +63 -0
- package/dist/src/nextclaw-sdk/network-webhook.js +126 -0
- package/dist/src/nextclaw-sdk/network.js +4 -0
- package/dist/src/nextclaw-sdk/runtime-store.js +21 -0
- package/dist/src/nextclaw-sdk/secrets-config.js +65 -0
- package/dist/src/nextclaw-sdk/secrets-core.d.ts +1 -0
- package/dist/src/nextclaw-sdk/secrets-core.js +68 -0
- package/dist/src/nextclaw-sdk/secrets-prompt.js +193 -0
- package/dist/src/nextclaw-sdk/secrets.d.ts +1 -0
- package/dist/src/nextclaw-sdk/secrets.js +4 -0
- package/dist/src/nextclaw-sdk/types.d.ts +242 -0
- package/dist/src/oauth.js +171 -0
- package/dist/src/onboarding.js +381 -0
- package/dist/src/outbound.js +150 -0
- package/dist/src/perm-schema.js +49 -0
- package/dist/src/perm.js +90 -0
- package/dist/src/policy.js +61 -0
- package/dist/src/post.js +160 -0
- package/dist/src/probe.d.ts +11 -0
- package/dist/src/probe.js +85 -0
- package/dist/src/raw-request.js +24 -0
- package/dist/src/reactions.d.ts +67 -0
- package/dist/src/reactions.js +91 -0
- package/dist/src/reply-dispatcher.js +250 -0
- package/dist/src/runtime.js +5 -0
- package/dist/src/secret-input.js +3 -0
- package/dist/src/send-result.js +12 -0
- package/dist/src/send-target.js +22 -0
- package/dist/src/send.d.ts +51 -0
- package/dist/src/send.js +265 -0
- package/dist/src/sheets-shared.js +193 -0
- package/dist/src/sheets.js +95 -0
- package/dist/src/streaming-card.js +263 -0
- package/dist/src/targets.js +39 -0
- package/dist/src/task-comment.js +76 -0
- package/dist/src/task-shared.js +13 -0
- package/dist/src/task-subtask.js +79 -0
- package/dist/src/task-task.js +144 -0
- package/dist/src/task-tasklist.js +136 -0
- package/dist/src/task.js +16 -0
- package/dist/src/token-store.js +154 -0
- package/dist/src/tool-account.js +65 -0
- package/dist/src/tool-result.js +18 -0
- package/dist/src/tool-scopes.js +62 -0
- package/dist/src/tools-config.js +30 -0
- package/dist/src/types.d.ts +43 -0
- package/dist/src/typing.js +145 -0
- package/dist/src/uat-client.js +102 -0
- package/dist/src/user-tool-client.js +132 -0
- package/dist/src/user-tool-helpers.js +110 -0
- package/dist/src/user-tool-result.js +10 -0
- package/dist/src/wiki-schema.js +45 -0
- package/dist/src/wiki.js +144 -0
- package/package.json +8 -4
- package/index.ts +0 -75
package/dist/src/wiki.js
ADDED
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { jsonToolResult, toolExecutionErrorResult, unknownToolActionResult } from "./tool-result.js";
|
|
2
|
+
import { createFeishuToolClient, resolveRegisteredFeishuToolsConfig } from "./tool-account.js";
|
|
3
|
+
import { FeishuWikiSchema } from "./wiki-schema.js";
|
|
4
|
+
//#region src/wiki.ts
|
|
5
|
+
const WIKI_ACCESS_HINT = "To grant wiki access: Open wiki space → Settings → Members → Add the bot. See: https://open.feishu.cn/document/server-docs/docs/wiki-v2/wiki-qa#a40ad4ca";
|
|
6
|
+
async function listSpaces(client) {
|
|
7
|
+
const res = await client.wiki.space.list({});
|
|
8
|
+
if (res.code !== 0) throw new Error(res.msg);
|
|
9
|
+
const spaces = res.data?.items?.map((s) => ({
|
|
10
|
+
space_id: s.space_id,
|
|
11
|
+
name: s.name,
|
|
12
|
+
description: s.description,
|
|
13
|
+
visibility: s.visibility
|
|
14
|
+
})) ?? [];
|
|
15
|
+
return {
|
|
16
|
+
spaces,
|
|
17
|
+
...spaces.length === 0 && { hint: WIKI_ACCESS_HINT }
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
async function listNodes(client, spaceId, parentNodeToken) {
|
|
21
|
+
const res = await client.wiki.spaceNode.list({
|
|
22
|
+
path: { space_id: spaceId },
|
|
23
|
+
params: { parent_node_token: parentNodeToken }
|
|
24
|
+
});
|
|
25
|
+
if (res.code !== 0) throw new Error(res.msg);
|
|
26
|
+
return { nodes: res.data?.items?.map((n) => ({
|
|
27
|
+
node_token: n.node_token,
|
|
28
|
+
obj_token: n.obj_token,
|
|
29
|
+
obj_type: n.obj_type,
|
|
30
|
+
title: n.title,
|
|
31
|
+
has_child: n.has_child
|
|
32
|
+
})) ?? [] };
|
|
33
|
+
}
|
|
34
|
+
async function getNode(client, token) {
|
|
35
|
+
const res = await client.wiki.space.getNode({ params: { token } });
|
|
36
|
+
if (res.code !== 0) throw new Error(res.msg);
|
|
37
|
+
const node = res.data?.node;
|
|
38
|
+
return {
|
|
39
|
+
node_token: node?.node_token,
|
|
40
|
+
space_id: node?.space_id,
|
|
41
|
+
obj_token: node?.obj_token,
|
|
42
|
+
obj_type: node?.obj_type,
|
|
43
|
+
title: node?.title,
|
|
44
|
+
parent_node_token: node?.parent_node_token,
|
|
45
|
+
has_child: node?.has_child,
|
|
46
|
+
creator: node?.creator,
|
|
47
|
+
create_time: node?.node_create_time
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
async function createNode(client, spaceId, title, objType, parentNodeToken) {
|
|
51
|
+
const res = await client.wiki.spaceNode.create({
|
|
52
|
+
path: { space_id: spaceId },
|
|
53
|
+
data: {
|
|
54
|
+
obj_type: objType || "docx",
|
|
55
|
+
node_type: "origin",
|
|
56
|
+
title,
|
|
57
|
+
parent_node_token: parentNodeToken
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
if (res.code !== 0) throw new Error(res.msg);
|
|
61
|
+
const node = res.data?.node;
|
|
62
|
+
return {
|
|
63
|
+
node_token: node?.node_token,
|
|
64
|
+
obj_token: node?.obj_token,
|
|
65
|
+
obj_type: node?.obj_type,
|
|
66
|
+
title: node?.title
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
async function moveNode(client, spaceId, nodeToken, targetSpaceId, targetParentToken) {
|
|
70
|
+
const res = await client.wiki.spaceNode.move({
|
|
71
|
+
path: {
|
|
72
|
+
space_id: spaceId,
|
|
73
|
+
node_token: nodeToken
|
|
74
|
+
},
|
|
75
|
+
data: {
|
|
76
|
+
target_space_id: targetSpaceId || spaceId,
|
|
77
|
+
target_parent_token: targetParentToken
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
if (res.code !== 0) throw new Error(res.msg);
|
|
81
|
+
return {
|
|
82
|
+
success: true,
|
|
83
|
+
node_token: res.data?.node?.node_token
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
async function renameNode(client, spaceId, nodeToken, title) {
|
|
87
|
+
const res = await client.wiki.spaceNode.updateTitle({
|
|
88
|
+
path: {
|
|
89
|
+
space_id: spaceId,
|
|
90
|
+
node_token: nodeToken
|
|
91
|
+
},
|
|
92
|
+
data: { title }
|
|
93
|
+
});
|
|
94
|
+
if (res.code !== 0) throw new Error(res.msg);
|
|
95
|
+
return {
|
|
96
|
+
success: true,
|
|
97
|
+
node_token: nodeToken,
|
|
98
|
+
title
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
function registerFeishuWikiTools(api) {
|
|
102
|
+
if (!api.config) {
|
|
103
|
+
api.logger.debug?.("feishu_wiki: No config available, skipping wiki tools");
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
if (!resolveRegisteredFeishuToolsConfig(api.config).wiki) {
|
|
107
|
+
api.logger.debug?.("feishu_wiki: wiki tool disabled in config");
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
api.registerTool((ctx) => {
|
|
111
|
+
const defaultAccountId = ctx.agentAccountId;
|
|
112
|
+
return {
|
|
113
|
+
name: "feishu_wiki",
|
|
114
|
+
label: "Feishu Wiki",
|
|
115
|
+
description: "Feishu knowledge base operations. Actions: spaces, nodes, get, create, move, rename",
|
|
116
|
+
parameters: FeishuWikiSchema,
|
|
117
|
+
async execute(_toolCallId, params) {
|
|
118
|
+
const p = params;
|
|
119
|
+
try {
|
|
120
|
+
const client = createFeishuToolClient({
|
|
121
|
+
api,
|
|
122
|
+
executeParams: p,
|
|
123
|
+
defaultAccountId
|
|
124
|
+
});
|
|
125
|
+
switch (p.action) {
|
|
126
|
+
case "spaces": return jsonToolResult(await listSpaces(client));
|
|
127
|
+
case "nodes": return jsonToolResult(await listNodes(client, p.space_id, p.parent_node_token));
|
|
128
|
+
case "get": return jsonToolResult(await getNode(client, p.token));
|
|
129
|
+
case "search": return jsonToolResult({ error: "Search is not available. Use feishu_wiki with action: 'nodes' to browse or action: 'get' to lookup by token." });
|
|
130
|
+
case "create": return jsonToolResult(await createNode(client, p.space_id, p.title, p.obj_type, p.parent_node_token));
|
|
131
|
+
case "move": return jsonToolResult(await moveNode(client, p.space_id, p.node_token, p.target_space_id, p.target_parent_token));
|
|
132
|
+
case "rename": return jsonToolResult(await renameNode(client, p.space_id, p.node_token, p.title));
|
|
133
|
+
default: return unknownToolActionResult(p.action);
|
|
134
|
+
}
|
|
135
|
+
} catch (err) {
|
|
136
|
+
return toolExecutionErrorResult(err);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
}, { name: "feishu_wiki" });
|
|
141
|
+
api.logger.info?.(`feishu_wiki: Registered feishu_wiki tool`);
|
|
142
|
+
}
|
|
143
|
+
//#endregion
|
|
144
|
+
export { registerFeishuWikiTools };
|
package/package.json
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nextclaw/channel-plugin-feishu",
|
|
3
|
-
"version": "0.2.29-beta.
|
|
3
|
+
"version": "0.2.29-beta.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "NextClaw Feishu/Lark channel plugin with doc/wiki/drive tools.",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"exports": {
|
|
8
8
|
".": {
|
|
9
|
-
"
|
|
9
|
+
"development": "./index.ts",
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"default": "./dist/index.js"
|
|
10
12
|
}
|
|
11
13
|
},
|
|
12
14
|
"files": [
|
|
13
|
-
"
|
|
15
|
+
"dist",
|
|
14
16
|
"openclaw.plugin.json",
|
|
15
17
|
"README.md",
|
|
16
18
|
"skills",
|
|
@@ -18,7 +20,7 @@
|
|
|
18
20
|
],
|
|
19
21
|
"openclaw": {
|
|
20
22
|
"extensions": [
|
|
21
|
-
"./index.
|
|
23
|
+
"./dist/index.js"
|
|
22
24
|
],
|
|
23
25
|
"development": {
|
|
24
26
|
"extensions": [
|
|
@@ -51,6 +53,8 @@
|
|
|
51
53
|
"zod": "^4.3.6"
|
|
52
54
|
},
|
|
53
55
|
"scripts": {
|
|
56
|
+
"build": "tsdown index.ts --dts --clean --target es2022 --no-fixedExtension --unbundle",
|
|
57
|
+
"dev:build": "tsdown index.ts --dts --target es2022 --no-fixedExtension --unbundle --no-clean --watch",
|
|
54
58
|
"lint": "eslint index.ts"
|
|
55
59
|
}
|
|
56
60
|
}
|
package/index.ts
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import type { OpenClawPluginApi } from "./src/nextclaw-sdk/feishu.js";
|
|
2
|
-
import { registerFeishuCalendarTools } from "./src/calendar.js";
|
|
3
|
-
import { emptyPluginConfigSchema } from "./src/nextclaw-sdk/feishu.js";
|
|
4
|
-
import { registerFeishuBitableTools } from "./src/bitable.js";
|
|
5
|
-
import { feishuPlugin } from "./src/channel.js";
|
|
6
|
-
import { registerFeishuChatTools } from "./src/chat.js";
|
|
7
|
-
import { registerFeishuDocTools } from "./src/docx.js";
|
|
8
|
-
import { registerFeishuDriveTools } from "./src/drive.js";
|
|
9
|
-
import { registerFeishuIdentityTools } from "./src/identity.js";
|
|
10
|
-
import { registerFeishuOAuthTool } from "./src/oauth.js";
|
|
11
|
-
import { registerFeishuPermTools } from "./src/perm.js";
|
|
12
|
-
import { setFeishuRuntime } from "./src/runtime.js";
|
|
13
|
-
import { registerFeishuSheetsTools } from "./src/sheets.js";
|
|
14
|
-
import { registerFeishuTaskTools } from "./src/task.js";
|
|
15
|
-
import { registerFeishuWikiTools } from "./src/wiki.js";
|
|
16
|
-
|
|
17
|
-
export { monitorFeishuProvider } from "./src/monitor.js";
|
|
18
|
-
export {
|
|
19
|
-
sendMessageFeishu,
|
|
20
|
-
sendCardFeishu,
|
|
21
|
-
updateCardFeishu,
|
|
22
|
-
editMessageFeishu,
|
|
23
|
-
getMessageFeishu,
|
|
24
|
-
} from "./src/send.js";
|
|
25
|
-
export {
|
|
26
|
-
uploadImageFeishu,
|
|
27
|
-
uploadFileFeishu,
|
|
28
|
-
sendImageFeishu,
|
|
29
|
-
sendFileFeishu,
|
|
30
|
-
sendMediaFeishu,
|
|
31
|
-
} from "./src/media.js";
|
|
32
|
-
export { probeFeishu } from "./src/probe.js";
|
|
33
|
-
export {
|
|
34
|
-
addReactionFeishu,
|
|
35
|
-
removeReactionFeishu,
|
|
36
|
-
listReactionsFeishu,
|
|
37
|
-
FeishuEmoji,
|
|
38
|
-
} from "./src/reactions.js";
|
|
39
|
-
export {
|
|
40
|
-
extractMentionTargets,
|
|
41
|
-
extractMessageBody,
|
|
42
|
-
isMentionForwardRequest,
|
|
43
|
-
formatMentionForText,
|
|
44
|
-
formatMentionForCard,
|
|
45
|
-
formatMentionAllForText,
|
|
46
|
-
formatMentionAllForCard,
|
|
47
|
-
buildMentionedMessage,
|
|
48
|
-
buildMentionedCardContent,
|
|
49
|
-
type MentionTarget,
|
|
50
|
-
} from "./src/mention.js";
|
|
51
|
-
export { feishuPlugin } from "./src/channel.js";
|
|
52
|
-
|
|
53
|
-
const plugin = {
|
|
54
|
-
id: "feishu",
|
|
55
|
-
name: "Feishu",
|
|
56
|
-
description: "Feishu/Lark channel plugin",
|
|
57
|
-
configSchema: emptyPluginConfigSchema(),
|
|
58
|
-
register(api: OpenClawPluginApi) {
|
|
59
|
-
setFeishuRuntime(api.runtime);
|
|
60
|
-
api.registerChannel({ plugin: feishuPlugin });
|
|
61
|
-
registerFeishuDocTools(api);
|
|
62
|
-
registerFeishuChatTools(api);
|
|
63
|
-
registerFeishuWikiTools(api);
|
|
64
|
-
registerFeishuDriveTools(api);
|
|
65
|
-
registerFeishuPermTools(api);
|
|
66
|
-
registerFeishuBitableTools(api);
|
|
67
|
-
registerFeishuCalendarTools(api);
|
|
68
|
-
registerFeishuTaskTools(api);
|
|
69
|
-
registerFeishuSheetsTools(api);
|
|
70
|
-
registerFeishuIdentityTools(api);
|
|
71
|
-
registerFeishuOAuthTool(api);
|
|
72
|
-
},
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
export default plugin;
|