@cozeclaw/coze-openclaw-plugin 0.1.1 → 0.1.3
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/index.ts +10 -0
- package/openclaw.plugin.json +0 -1
- package/package.json +2 -2
- package/skills/coze-asr/SKILL.md +3 -2
- package/skills/coze-image-gen/SKILL.md +4 -3
- package/skills/coze-tts/SKILL.md +4 -3
- package/src/plugin.test.ts +62 -0
package/index.ts
CHANGED
|
@@ -2,11 +2,21 @@ import type { OpenClawPluginApi } from "openclaw/plugin-sdk/core";
|
|
|
2
2
|
import { createCozeWebFetchTool } from "./src/tools/web-fetch.js";
|
|
3
3
|
import { createCozeWebSearchTool } from "./src/tools/web-search.js";
|
|
4
4
|
|
|
5
|
+
function hasApiKey(pluginConfig: OpenClawPluginApi["pluginConfig"]): boolean {
|
|
6
|
+
return typeof pluginConfig?.apiKey === "string" && pluginConfig.apiKey.trim().length > 0;
|
|
7
|
+
}
|
|
8
|
+
|
|
5
9
|
const plugin = {
|
|
6
10
|
id: "coze-openclaw-plugin",
|
|
7
11
|
name: "Coze OpenClaw Plugin",
|
|
8
12
|
description: "Coze web tools and bundled generation skills for OpenClaw.",
|
|
9
13
|
register(api: OpenClawPluginApi) {
|
|
14
|
+
if (!hasApiKey(api.pluginConfig)) {
|
|
15
|
+
api.logger.info?.(
|
|
16
|
+
"Skipping Coze tool registration because plugins.entries.coze-openclaw-plugin.config.apiKey is missing.",
|
|
17
|
+
);
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
10
20
|
api.registerTool(
|
|
11
21
|
createCozeWebSearchTool({
|
|
12
22
|
pluginConfig: api.pluginConfig,
|
package/openclaw.plugin.json
CHANGED
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cozeclaw/coze-openclaw-plugin",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "OpenClaw Coze tools and bundled skills",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"test": "vitest run src/config.test.ts src/skill-cli.test.ts src/tools/web-search.test.ts src/tools/web-fetch.test.ts"
|
|
7
|
+
"test": "vitest run src/config.test.ts src/plugin.test.ts src/skill-cli.test.ts src/tools/web-search.test.ts src/tools/web-fetch.test.ts"
|
|
8
8
|
},
|
|
9
9
|
"devDependencies": {
|
|
10
10
|
"openclaw": "v2026.2.6",
|
package/skills/coze-asr/SKILL.md
CHANGED
|
@@ -12,8 +12,8 @@ Transcribe audio from a URL or local file using Coze ASR.
|
|
|
12
12
|
## Quick start
|
|
13
13
|
|
|
14
14
|
```bash
|
|
15
|
-
node {
|
|
16
|
-
node {
|
|
15
|
+
node {skillDir}/scripts/asr.mjs --url "https://example.com/audio.mp3"
|
|
16
|
+
node {skillDir}/scripts/asr.mjs --file ./recording.mp3
|
|
17
17
|
```
|
|
18
18
|
|
|
19
19
|
## Options
|
|
@@ -24,4 +24,5 @@ node {baseDir}/scripts/asr.mjs --file ./recording.mp3
|
|
|
24
24
|
## Notes
|
|
25
25
|
|
|
26
26
|
- The skill runtime requires `plugins.entries.coze-openclaw-plugin.config.apiKey`.
|
|
27
|
+
- `{skillDir}` means the directory containing this `SKILL.md`.
|
|
27
28
|
- Local files are read and uploaded as base64 audio content.
|
|
@@ -12,9 +12,9 @@ Generate one or more images from a prompt using Coze.
|
|
|
12
12
|
## Quick start
|
|
13
13
|
|
|
14
14
|
```bash
|
|
15
|
-
node {
|
|
16
|
-
node {
|
|
17
|
-
node {
|
|
15
|
+
node {skillDir}/scripts/gen.mjs --prompt "A futuristic city at sunset"
|
|
16
|
+
node {skillDir}/scripts/gen.mjs --prompt "A serene mountain landscape" --count 2 --size 4K
|
|
17
|
+
node {skillDir}/scripts/gen.mjs --prompt "A hero's journey through magical lands" --sequential --max-sequential 5
|
|
18
18
|
```
|
|
19
19
|
|
|
20
20
|
## Options
|
|
@@ -28,4 +28,5 @@ node {baseDir}/scripts/gen.mjs --prompt "A hero's journey through magical lands"
|
|
|
28
28
|
## Notes
|
|
29
29
|
|
|
30
30
|
- The skill runtime requires `plugins.entries.coze-openclaw-plugin.config.apiKey`.
|
|
31
|
+
- `{skillDir}` means the directory containing this `SKILL.md`.
|
|
31
32
|
- URLs are printed directly and are suitable for immediate use.
|
package/skills/coze-tts/SKILL.md
CHANGED
|
@@ -12,9 +12,9 @@ Generate speech audio URLs from text using Coze TTS.
|
|
|
12
12
|
## Quick start
|
|
13
13
|
|
|
14
14
|
```bash
|
|
15
|
-
node {
|
|
16
|
-
node {
|
|
17
|
-
node {
|
|
15
|
+
node {skillDir}/scripts/tts.mjs --text "Hello, welcome to our service"
|
|
16
|
+
node {skillDir}/scripts/tts.mjs --texts "Chapter 1" "Chapter 2" --speaker zh_male_m191_uranus_bigtts
|
|
17
|
+
node {skillDir}/scripts/tts.mjs --text "Fast announcement" --speech-rate 30 --format mp3 --sample-rate 48000
|
|
18
18
|
```
|
|
19
19
|
|
|
20
20
|
## Options
|
|
@@ -30,4 +30,5 @@ node {baseDir}/scripts/tts.mjs --text "Fast announcement" --speech-rate 30 --for
|
|
|
30
30
|
## Notes
|
|
31
31
|
|
|
32
32
|
- The skill runtime requires `plugins.entries.coze-openclaw-plugin.config.apiKey`.
|
|
33
|
+
- `{skillDir}` means the directory containing this `SKILL.md`.
|
|
33
34
|
- The script prints one audio URL per generated segment.
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { describe, expect, it, vi } from "vitest";
|
|
2
|
+
import plugin from "../index.js";
|
|
3
|
+
|
|
4
|
+
function createApi(pluginConfig: Record<string, unknown>) {
|
|
5
|
+
return {
|
|
6
|
+
id: "coze-openclaw-plugin",
|
|
7
|
+
name: "Coze OpenClaw Plugin",
|
|
8
|
+
description: "Coze OpenClaw",
|
|
9
|
+
source: "test",
|
|
10
|
+
config: {},
|
|
11
|
+
pluginConfig,
|
|
12
|
+
runtime: {} as never,
|
|
13
|
+
logger: {
|
|
14
|
+
debug() {},
|
|
15
|
+
info: vi.fn(),
|
|
16
|
+
warn() {},
|
|
17
|
+
error() {},
|
|
18
|
+
},
|
|
19
|
+
registerTool: vi.fn(),
|
|
20
|
+
registerHook() {},
|
|
21
|
+
registerHttpRoute() {},
|
|
22
|
+
registerChannel() {},
|
|
23
|
+
registerGatewayMethod() {},
|
|
24
|
+
registerCli() {},
|
|
25
|
+
registerService() {},
|
|
26
|
+
registerProvider() {},
|
|
27
|
+
registerCommand() {},
|
|
28
|
+
registerContextEngine() {},
|
|
29
|
+
resolvePath(input: string) {
|
|
30
|
+
return input;
|
|
31
|
+
},
|
|
32
|
+
on() {},
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
describe("plugin registration", () => {
|
|
37
|
+
it("skips tool registration when apiKey is missing", () => {
|
|
38
|
+
const api = createApi({});
|
|
39
|
+
|
|
40
|
+
plugin.register?.(api);
|
|
41
|
+
|
|
42
|
+
expect(api.registerTool).not.toHaveBeenCalled();
|
|
43
|
+
expect(api.logger.info).toHaveBeenCalledWith(
|
|
44
|
+
"Skipping Coze tool registration because plugins.entries.coze-openclaw-plugin.config.apiKey is missing.",
|
|
45
|
+
);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it("registers coze web tools when apiKey exists", () => {
|
|
49
|
+
const api = createApi({ apiKey: "test-key" });
|
|
50
|
+
|
|
51
|
+
plugin.register?.(api);
|
|
52
|
+
|
|
53
|
+
expect(api.registerTool).toHaveBeenCalledTimes(2);
|
|
54
|
+
const toolNames = api.registerTool.mock.calls
|
|
55
|
+
.map((call) => {
|
|
56
|
+
const tool = call[0];
|
|
57
|
+
return typeof tool === "function" ? undefined : tool.name;
|
|
58
|
+
})
|
|
59
|
+
.filter(Boolean);
|
|
60
|
+
expect(toolNames).toEqual(["coze_web_search", "coze_web_fetch"]);
|
|
61
|
+
});
|
|
62
|
+
});
|