openclaw-cph-provider 1.0.0 → 1.2.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.
Files changed (2) hide show
  1. package/index.js +76 -55
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -1,64 +1,85 @@
1
- import { defineSingleProviderPluginEntry } from "openclaw/plugin-sdk/provider-entry";
1
+ import { definePluginEntry } from "openclaw/plugin-sdk/core";
2
+ import { createProviderApiKeyAuthMethod } from "openclaw/plugin-sdk/provider-auth-api-key";
2
3
 
3
- const CPH_BASE_URL = "https://codingplanhub.com/v1";
4
+ const CPH_BASE_URL = "http://43.248.139.31:8080/v1";
4
5
 
5
- export default defineSingleProviderPluginEntry({
6
+ // Static model catalog
7
+ const CPH_MODELS = [
8
+ { id: "deepseek-v3.2", name: "DeepSeek V3.2", reasoning: false, input: ["text"], contextWindow: 65536, maxTokens: 8192 },
9
+ { id: "deepseek-v3", name: "DeepSeek V3", reasoning: false, input: ["text"], contextWindow: 65536, maxTokens: 8192 },
10
+ { id: "glm-5.1", name: "GLM 5.1", reasoning: false, input: ["text"], contextWindow: 200000, maxTokens: 8192 },
11
+ { id: "glm-5", name: "GLM 5", reasoning: false, input: ["text"], contextWindow: 200000, maxTokens: 8192 },
12
+ { id: "glm-5-turbo", name: "GLM 5 Turbo", reasoning: false, input: ["text"], contextWindow: 200000, maxTokens: 8192 },
13
+ { id: "glm-4.7", name: "GLM 4.7", reasoning: false, input: ["text"], contextWindow: 200000, maxTokens: 8192 },
14
+ { id: "glm-4.6", name: "GLM 4.6", reasoning: false, input: ["text"], contextWindow: 200000, maxTokens: 8192 },
15
+ { id: "glm-4.5", name: "GLM 4.5", reasoning: false, input: ["text"], contextWindow: 128000, maxTokens: 8192 },
16
+ { id: "glm-4.5-air", name: "GLM 4.5 Air", reasoning: false, input: ["text"], contextWindow: 128000, maxTokens: 8192 },
17
+ { id: "qwen3.5-plus", name: "Qwen 3.5 Plus", reasoning: false, input: ["text"], contextWindow: 1000000, maxTokens: 8192 },
18
+ { id: "qwen3-coder-plus", name: "Qwen 3 Coder Plus", reasoning: false, input: ["text"], contextWindow: 1000000, maxTokens: 8192 },
19
+ { id: "qwen3-coder-next", name: "Qwen 3 Coder Next", reasoning: false, input: ["text"], contextWindow: 256000, maxTokens: 8192 },
20
+ { id: "qwen3-max-2026-01-23", name: "Qwen 3 Max", reasoning: false, input: ["text"], contextWindow: 256000, maxTokens: 8192 },
21
+ { id: "kimi-k2.5", name: "Kimi K2.5", reasoning: false, input: ["text"], contextWindow: 256000, maxTokens: 8192 },
22
+ { id: "doubao-seed-2.0-pro", name: "Doubao Seed 2.0 Pro", reasoning: false, input: ["text"], contextWindow: 128000, maxTokens: 8192 },
23
+ { id: "doubao-seed-2.0-code", name: "Doubao Seed 2.0 Code", reasoning: false, input: ["text"], contextWindow: 128000, maxTokens: 8192 },
24
+ { id: "doubao-seed-code", name: "Doubao Seed Code", reasoning: false, input: ["text"], contextWindow: 128000, maxTokens: 8192 },
25
+ { id: "hunyuan-turbo", name: "Hunyuan Turbo", reasoning: false, input: ["text"], contextWindow: 256000, maxTokens: 8192 },
26
+ { id: "hunyuan-pro", name: "Hunyuan Pro", reasoning: false, input: ["text"], contextWindow: 256000, maxTokens: 8192 },
27
+ { id: "hunyuan-a13b", name: "Hunyuan A13B", reasoning: false, input: ["text"], contextWindow: 230000, maxTokens: 8192 },
28
+ { id: "mimo-v2-pro", name: "MiMo V2 Pro", reasoning: false, input: ["text"], contextWindow: 1000000, maxTokens: 8192 },
29
+ { id: "mimo-v2-omni", name: "MiMo V2 Omni", reasoning: false, input: ["text"], contextWindow: 256000, maxTokens: 8192 },
30
+ { id: "MiniMax-M2.7", name: "MiniMax M2.7", reasoning: false, input: ["text"], contextWindow: 200000, maxTokens: 8192 },
31
+ { id: "MiniMax-M2.5", name: "MiniMax M2.5", reasoning: false, input: ["text"], contextWindow: 200000, maxTokens: 8192 },
32
+ { id: "minimax-m2.5", name: "MiniMax M2.5", reasoning: false, input: ["text"], contextWindow: 200000, maxTokens: 8192 },
33
+ ];
34
+
35
+ export default definePluginEntry({
6
36
  id: "cph",
7
37
  name: "Coding Plan Hub",
8
38
  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,
39
+ register(api) {
40
+ api.registerProvider({
41
+ id: "cph",
42
+ label: "Coding Plan Hub",
43
+ docsPath: "/providers/cph",
44
+ envVars: ["CPH_API_KEY"],
45
+ auth: [
46
+ createProviderApiKeyAuthMethod({
47
+ providerId: "cph",
48
+ methodId: "api-key",
49
+ label: "CPH API key",
50
+ hint: "Get your key from the Coding Plan Hub portal",
51
+ optionKey: "cphApiKey",
52
+ flagName: "--cph-api-key",
53
+ envVar: "CPH_API_KEY",
54
+ promptMessage: "Enter your Coding Plan Hub API key",
55
+ expectedProviders: ["cph"],
56
+ defaultModel: "cph/deepseek-v3.2",
57
+ wizard: {
58
+ choiceId: "cph-api-key",
59
+ choiceLabel: "Coding Plan Hub API key",
60
+ groupId: "cph",
61
+ groupLabel: "Coding Plan Hub",
62
+ groupHint: "API key",
63
+ methodId: "api-key",
59
64
  },
60
- };
65
+ }),
66
+ ],
67
+ catalog: {
68
+ order: "simple",
69
+ run: async (ctx) => {
70
+ const apiKey = ctx.resolveProviderApiKey("cph").apiKey
71
+ || ctx.env.CPH_API_KEY;
72
+ if (!apiKey) return null;
73
+ return {
74
+ provider: {
75
+ baseUrl: CPH_BASE_URL,
76
+ api: "openai-completions",
77
+ models: CPH_MODELS,
78
+ apiKey,
79
+ },
80
+ };
81
+ },
61
82
  },
62
- },
83
+ });
63
84
  },
64
85
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openclaw-cph-provider",
3
- "version": "1.0.0",
3
+ "version": "1.2.0",
4
4
  "description": "OpenClaw provider plugin for Coding Plan Hub API gateway",
5
5
  "type": "module",
6
6
  "openclaw": {