-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathindex.ts
More file actions
57 lines (50 loc) · 1.95 KB
/
index.ts
File metadata and controls
57 lines (50 loc) · 1.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import type { OpenClawPluginApi } from "openclaw/plugin-sdk/core";
import { createCozeWebFetchTool } from "./src/tools/web-fetch.js";
import { createCozeWebSearchTool } from "./src/tools/web-search.js";
import { registerUpgradeModule } from "./src/upgrade/index.js";
import { registerSessionRecovery } from "./src/session-recovery.js";
import { registerWechatLogin } from "./src/wechat-login/index.js";
function hasApiKey(pluginConfig: OpenClawPluginApi["pluginConfig"]): boolean {
return typeof pluginConfig?.apiKey === "string" && pluginConfig.apiKey.trim().length > 0;
}
const plugin = {
id: "coze-openclaw-plugin",
name: "Coze OpenClaw Plugin",
description: "Coze web tools and bundled generation skills for OpenClaw.",
async register(api: OpenClawPluginApi) {
// ========================================
// Coze tools registration (requires apiKey)
// ========================================
if (!hasApiKey(api.pluginConfig)) {
api.logger.info?.(
"Skipping Coze tool registration because plugins.entries.coze-openclaw-plugin.config.apiKey is missing.",
);
} else {
api.registerTool(
createCozeWebSearchTool({
pluginConfig: api.pluginConfig,
logger: api.logger,
}),
);
api.registerTool(
createCozeWebFetchTool({
pluginConfig: api.pluginConfig,
logger: api.logger,
}),
);
}
// ========================================
// Upgrade module (CLI commands + HTTP routes + chat command)
// ========================================
registerUpgradeModule(api);
// ========================================
// Boot notification / session recovery
// ========================================
registerSessionRecovery(api);
// ========================================
// WeChat login command + hook
// ========================================
registerWechatLogin(api);
},
};
export default plugin;