openclaw-cph-provider 1.0.0
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.js +64 -0
- package/openclaw.plugin.json +28 -0
- package/package.json +14 -0
package/index.js
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { defineSingleProviderPluginEntry } from "openclaw/plugin-sdk/provider-entry";
|
|
2
|
+
|
|
3
|
+
const CPH_BASE_URL = "https://codingplanhub.com/v1";
|
|
4
|
+
|
|
5
|
+
export default defineSingleProviderPluginEntry({
|
|
6
|
+
id: "cph",
|
|
7
|
+
name: "Coding Plan Hub",
|
|
8
|
+
description: "Coding Plan Hub — OpenAI-compatible API gateway for Chinese AI platforms",
|
|
9
|
+
provider: {
|
|
10
|
+
label: "Coding Plan Hub",
|
|
11
|
+
auth: [
|
|
12
|
+
{
|
|
13
|
+
methodId: "api-key",
|
|
14
|
+
label: "CPH API key",
|
|
15
|
+
hint: "API key from your Coding Plan Hub portal",
|
|
16
|
+
optionKey: "cphApiKey",
|
|
17
|
+
flagName: "--cph-api-key",
|
|
18
|
+
envVar: "CPH_API_KEY",
|
|
19
|
+
promptMessage: "Enter your Coding Plan Hub API key",
|
|
20
|
+
defaultModel: "cph/deepseek-v3.2",
|
|
21
|
+
},
|
|
22
|
+
],
|
|
23
|
+
catalog: {
|
|
24
|
+
order: "simple",
|
|
25
|
+
run: async (ctx) => {
|
|
26
|
+
const apiKey = ctx.resolveProviderApiKey("cph").apiKey;
|
|
27
|
+
if (!apiKey) return null;
|
|
28
|
+
|
|
29
|
+
let models;
|
|
30
|
+
try {
|
|
31
|
+
const res = await fetch(`${CPH_BASE_URL}/models`, {
|
|
32
|
+
headers: { Authorization: `Bearer ${apiKey}` },
|
|
33
|
+
});
|
|
34
|
+
if (!res.ok) throw new Error(`HTTP ${res.status}`);
|
|
35
|
+
const data = await res.json();
|
|
36
|
+
models = (data.data || []).map((m) => ({
|
|
37
|
+
id: m.id,
|
|
38
|
+
name: m.id,
|
|
39
|
+
reasoning: false,
|
|
40
|
+
input: ["text"],
|
|
41
|
+
contextWindow: 128000,
|
|
42
|
+
maxTokens: 8192,
|
|
43
|
+
}));
|
|
44
|
+
} catch {
|
|
45
|
+
// Fallback to static list if API is unreachable
|
|
46
|
+
models = [
|
|
47
|
+
{ id: "deepseek-v3.2", name: "DeepSeek V3.2", reasoning: false, input: ["text"], contextWindow: 65536, maxTokens: 8192 },
|
|
48
|
+
{ id: "glm-5", name: "GLM 5", reasoning: false, input: ["text"], contextWindow: 128000, maxTokens: 8192 },
|
|
49
|
+
{ id: "qwen3.5-plus", name: "Qwen 3.5 Plus", reasoning: false, input: ["text"], contextWindow: 128000, maxTokens: 8192 },
|
|
50
|
+
];
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return {
|
|
54
|
+
provider: {
|
|
55
|
+
baseUrl: CPH_BASE_URL,
|
|
56
|
+
apiKey,
|
|
57
|
+
api: "openai-completions",
|
|
58
|
+
models,
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "cph",
|
|
3
|
+
"enabledByDefault": true,
|
|
4
|
+
"providers": ["cph"],
|
|
5
|
+
"providerAuthEnvVars": {
|
|
6
|
+
"cph": ["CPH_API_KEY"]
|
|
7
|
+
},
|
|
8
|
+
"providerAuthChoices": [
|
|
9
|
+
{
|
|
10
|
+
"provider": "cph",
|
|
11
|
+
"method": "api-key",
|
|
12
|
+
"choiceId": "cph-api-key",
|
|
13
|
+
"choiceLabel": "Coding Plan Hub API key",
|
|
14
|
+
"groupId": "cph",
|
|
15
|
+
"groupLabel": "Coding Plan Hub",
|
|
16
|
+
"groupHint": "API key",
|
|
17
|
+
"optionKey": "cphApiKey",
|
|
18
|
+
"cliFlag": "--cph-api-key",
|
|
19
|
+
"cliOption": "--cph-api-key <key>",
|
|
20
|
+
"cliDescription": "Coding Plan Hub API key"
|
|
21
|
+
}
|
|
22
|
+
],
|
|
23
|
+
"configSchema": {
|
|
24
|
+
"type": "object",
|
|
25
|
+
"additionalProperties": false,
|
|
26
|
+
"properties": {}
|
|
27
|
+
}
|
|
28
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "openclaw-cph-provider",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "OpenClaw provider plugin for Coding Plan Hub API gateway",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"openclaw": {
|
|
7
|
+
"extensions": ["./index.js"],
|
|
8
|
+
"providers": ["cph"],
|
|
9
|
+
"compat": {
|
|
10
|
+
"pluginApi": ">=2026.3.24-beta.2"
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"license": "MIT"
|
|
14
|
+
}
|