@nextclaw/channel-extension-feishu 0.1.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/LICENSE +21 -0
- package/README.md +17 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +5 -0
- package/dist/main.d.ts +1 -0
- package/dist/main.js +12 -0
- package/dist/services/feishu-auth-capability.service.d.ts +20 -0
- package/dist/services/feishu-auth-capability.service.js +32 -0
- package/dist/services/feishu-channel-adapter.service.d.ts +46 -0
- package/dist/services/feishu-channel-adapter.service.js +251 -0
- package/dist/services/feishu-extension-runtime.service.d.ts +19 -0
- package/dist/services/feishu-extension-runtime.service.js +66 -0
- package/dist/services/feishu-registration.service.d.ts +54 -0
- package/dist/services/feishu-registration.service.js +214 -0
- package/dist/services/feishu-reply-chat.service.js +92 -0
- package/dist/services/feishu-sdk.service.d.ts +75 -0
- package/dist/services/feishu-sdk.service.js +50 -0
- package/dist/stores/feishu-account.store.d.ts +21 -0
- package/dist/stores/feishu-account.store.js +40 -0
- package/dist/types/feishu-extension.types.d.ts +51 -0
- package/dist/utils/feishu-config.utils.js +79 -0
- package/dist/utils/feishu-message.utils.js +44 -0
- package/dist/utils/feishu-session-route.utils.js +38 -0
- package/nextclaw.extension.json +69 -0
- package/package.json +37 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
//#region src/utils/feishu-session-route.utils.ts
|
|
2
|
+
const PEER_KINDS = new Set([
|
|
3
|
+
"direct",
|
|
4
|
+
"group",
|
|
5
|
+
"channel"
|
|
6
|
+
]);
|
|
7
|
+
function readPayload(value) {
|
|
8
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return;
|
|
9
|
+
return value.payload;
|
|
10
|
+
}
|
|
11
|
+
function readNestedMessageSessionId(payload) {
|
|
12
|
+
const message = payload.message;
|
|
13
|
+
if (!message || typeof message !== "object" || Array.isArray(message)) return;
|
|
14
|
+
const sessionId = message.sessionId;
|
|
15
|
+
return typeof sessionId === "string" && sessionId.trim() ? sessionId.trim() : void 0;
|
|
16
|
+
}
|
|
17
|
+
function readFeishuEventSessionId(event) {
|
|
18
|
+
const payload = readPayload(event);
|
|
19
|
+
if (!payload || typeof payload !== "object" || Array.isArray(payload)) return;
|
|
20
|
+
const sessionId = payload.sessionId;
|
|
21
|
+
if (typeof sessionId === "string" && sessionId.trim()) return sessionId.trim();
|
|
22
|
+
return readNestedMessageSessionId(payload);
|
|
23
|
+
}
|
|
24
|
+
function resolveFeishuSessionRoute(event) {
|
|
25
|
+
const sessionId = readFeishuEventSessionId(event);
|
|
26
|
+
if (!sessionId) return null;
|
|
27
|
+
const parts = sessionId.split(":");
|
|
28
|
+
const normalizedParts = parts.map((part) => part.toLowerCase());
|
|
29
|
+
if (normalizedParts[0] !== "agent" || parts.length < 5) return null;
|
|
30
|
+
if (normalizedParts[2] === "feishu" && PEER_KINDS.has(normalizedParts[3] ?? "") && parts.length >= 5) return { conversationId: parts.slice(4).join(":") };
|
|
31
|
+
if (normalizedParts[2] === "feishu" && PEER_KINDS.has(normalizedParts[4] ?? "") && parts.length >= 6) return {
|
|
32
|
+
accountId: parts[3],
|
|
33
|
+
conversationId: parts.slice(5).join(":")
|
|
34
|
+
};
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
//#endregion
|
|
38
|
+
export { readFeishuEventSessionId, resolveFeishuSessionRoute };
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "nextclaw-channel-extension-feishu",
|
|
3
|
+
"name": "NextClaw Feishu Channel Extension",
|
|
4
|
+
"version": "0.1.0",
|
|
5
|
+
"server": {
|
|
6
|
+
"type": "stdio",
|
|
7
|
+
"command": "node",
|
|
8
|
+
"args": ["dist/main.js"]
|
|
9
|
+
},
|
|
10
|
+
"contributes": {
|
|
11
|
+
"channels": [
|
|
12
|
+
{
|
|
13
|
+
"id": "feishu",
|
|
14
|
+
"name": "Feishu/Lark",
|
|
15
|
+
"description": "Feishu/Lark QR scan-to-create bot with WebSocket messaging",
|
|
16
|
+
"auth": {
|
|
17
|
+
"type": "request-response"
|
|
18
|
+
},
|
|
19
|
+
"configUiHints": {
|
|
20
|
+
"enabled": { "label": "Enabled" },
|
|
21
|
+
"defaultAccountId": { "label": "Default Account ID" },
|
|
22
|
+
"domain": { "label": "Domain" },
|
|
23
|
+
"allowFrom": { "label": "Allow From" },
|
|
24
|
+
"groupPolicy": { "label": "Group Policy", "advanced": true },
|
|
25
|
+
"requireMention": { "label": "Require Mention", "advanced": true }
|
|
26
|
+
},
|
|
27
|
+
"configSchema": {
|
|
28
|
+
"type": "object",
|
|
29
|
+
"additionalProperties": true,
|
|
30
|
+
"properties": {
|
|
31
|
+
"enabled": { "type": "boolean" },
|
|
32
|
+
"defaultAccountId": { "type": "string" },
|
|
33
|
+
"domain": { "type": "string", "enum": ["feishu", "lark"] },
|
|
34
|
+
"allowFrom": {
|
|
35
|
+
"type": "array",
|
|
36
|
+
"items": { "type": "string" }
|
|
37
|
+
},
|
|
38
|
+
"groupPolicy": {
|
|
39
|
+
"type": "string",
|
|
40
|
+
"enum": ["open", "allowlist", "disabled"]
|
|
41
|
+
},
|
|
42
|
+
"requireMention": { "type": "boolean" },
|
|
43
|
+
"accounts": {
|
|
44
|
+
"type": "object",
|
|
45
|
+
"additionalProperties": {
|
|
46
|
+
"type": "object",
|
|
47
|
+
"additionalProperties": true,
|
|
48
|
+
"properties": {
|
|
49
|
+
"enabled": { "type": "boolean" },
|
|
50
|
+
"name": { "type": "string" },
|
|
51
|
+
"domain": { "type": "string", "enum": ["feishu", "lark"] },
|
|
52
|
+
"allowFrom": {
|
|
53
|
+
"type": "array",
|
|
54
|
+
"items": { "type": "string" }
|
|
55
|
+
},
|
|
56
|
+
"groupPolicy": {
|
|
57
|
+
"type": "string",
|
|
58
|
+
"enum": ["open", "allowlist", "disabled"]
|
|
59
|
+
},
|
|
60
|
+
"requireMention": { "type": "boolean" }
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
]
|
|
68
|
+
}
|
|
69
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@nextclaw/channel-extension-feishu",
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"private": false,
|
|
5
|
+
"description": "NextClaw Feishu/Lark lightweight channel extension process.",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"development": "./src/index.ts",
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js",
|
|
12
|
+
"default": "./dist/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist",
|
|
17
|
+
"nextclaw.extension.json",
|
|
18
|
+
"README.md"
|
|
19
|
+
],
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"@larksuiteoapi/node-sdk": "^1.59.0",
|
|
22
|
+
"@nextclaw/extension-sdk": "0.1.4",
|
|
23
|
+
"@nextclaw/ncp-toolkit": "0.5.15",
|
|
24
|
+
"@nextclaw/ncp": "0.5.10"
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"@types/node": "^20.17.6",
|
|
28
|
+
"typescript": "^5.6.3",
|
|
29
|
+
"vitest": "^4.1.2"
|
|
30
|
+
},
|
|
31
|
+
"scripts": {
|
|
32
|
+
"build": "tsdown src/index.ts src/main.ts --dts --clean --target es2022 --no-fixedExtension --unbundle",
|
|
33
|
+
"lint": "eslint src --max-warnings=0",
|
|
34
|
+
"test": "vitest run",
|
|
35
|
+
"tsc": "tsc -p tsconfig.json"
|
|
36
|
+
}
|
|
37
|
+
}
|