pi-codebuddy-sdk 0.1.16 → 0.1.18
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/package.json +1 -1
- package/src/index.ts +44 -16
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -16,32 +16,60 @@ import { streamCodebuddy } from "./provider.js";
|
|
|
16
16
|
// ── provider registration ──
|
|
17
17
|
|
|
18
18
|
export default function activate(api: ExtensionAPI) {
|
|
19
|
+
// Register synchronously with hardcoded models first.
|
|
20
|
+
// Lazy discovery runs after startup — if it succeeds, re-registers with full list.
|
|
19
21
|
api.registerProvider("codebuddy", {
|
|
20
22
|
name: "CodeBuddy",
|
|
21
23
|
baseUrl: "codebuddy-local",
|
|
22
24
|
apiKey: "codebuddy-local-auth",
|
|
23
25
|
api: "codebuddy-sdk",
|
|
24
|
-
models:
|
|
26
|
+
models: FALLBACK_MODELS,
|
|
25
27
|
streamSimple: streamCodebuddy,
|
|
26
28
|
});
|
|
27
29
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
30
|
+
// Async model discovery — updates provider with live model list
|
|
31
|
+
discoverAndUpdate(api);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
async function discoverAndUpdate(api: ExtensionAPI) {
|
|
35
|
+
try {
|
|
36
|
+
const models = await discoverModels();
|
|
37
|
+
api.registerProvider("codebuddy", {
|
|
38
|
+
name: "CodeBuddy",
|
|
39
|
+
baseUrl: "codebuddy-local",
|
|
40
|
+
apiKey: "codebuddy-local-auth",
|
|
41
|
+
api: "codebuddy-sdk",
|
|
42
|
+
models,
|
|
43
|
+
streamSimple: streamCodebuddy,
|
|
44
|
+
});
|
|
45
|
+
} catch {
|
|
46
|
+
// Fallback models already registered
|
|
47
|
+
}
|
|
43
48
|
}
|
|
44
49
|
|
|
50
|
+
// ── hardcoded fallback models (used before async discovery completes) ──
|
|
51
|
+
|
|
52
|
+
const FALLBACK_MODELS: ProviderApi["models"] = [
|
|
53
|
+
{
|
|
54
|
+
id: "hy3-preview-agent-ioa", name: "Hunyuan 3", api: "codebuddy-sdk", provider: "codebuddy",
|
|
55
|
+
baseUrl: "https://codebuddy.tencent.com", reasoning: false, input: ["text"],
|
|
56
|
+
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
|
|
57
|
+
contextWindow: 131072, maxTokens: 8192,
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
id: "claude-sonnet-4.6", name: "Claude Sonnet 4.6", api: "codebuddy-sdk", provider: "codebuddy",
|
|
61
|
+
baseUrl: "https://codebuddy.tencent.com", reasoning: true, input: ["text", "image"],
|
|
62
|
+
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
|
|
63
|
+
contextWindow: 200000, maxTokens: 8192,
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
id: "deepseek-v4-pro-ioa", name: "DeepSeek V4 Pro", api: "codebuddy-sdk", provider: "codebuddy",
|
|
67
|
+
baseUrl: "https://codebuddy.tencent.com", reasoning: false, input: ["text"],
|
|
68
|
+
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
|
|
69
|
+
contextWindow: 131072, maxTokens: 8192,
|
|
70
|
+
},
|
|
71
|
+
];
|
|
72
|
+
|
|
45
73
|
// ── model discovery ──
|
|
46
74
|
|
|
47
75
|
let _sdk: typeof import("@tencent-ai/agent-sdk") | undefined;
|