dsh-agent-sdk-bridge 1.1.4 → 1.1.6
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/DEVELOPMENT.md +12 -1
- package/FAQ.md +11 -0
- package/README.md +2 -1
- package/client.js +2522 -2437
- package/lib/index.js +34 -4
- package/lib/types/api.d.ts +7 -0
- package/lib/types/codebuddy-adapter.d.ts +13 -0
- package/lib/types/codebuddy.d.ts +16 -0
- package/package.json +1 -1
- package/src/api.ts +12 -1
- package/src/codebuddy-adapter.ts +25 -1
- package/src/codebuddy.ts +23 -1
package/lib/index.js
CHANGED
|
@@ -3488,7 +3488,6 @@ function priceFactorOf$1(model) {
|
|
|
3488
3488
|
function toCodeBuddyModel(model) {
|
|
3489
3489
|
const windows = new Set(model.contextWindow?.supportedLengths ?? []);
|
|
3490
3490
|
const declared = model.contextWindow?.defaultLength ?? model.maxInputTokens ?? model.maxAllowedSize ?? 2e5;
|
|
3491
|
-
windows.add(declared);
|
|
3492
3491
|
return {
|
|
3493
3492
|
id: model.id,
|
|
3494
3493
|
name: model.name ?? model.id,
|
|
@@ -3558,6 +3557,15 @@ var CodeBuddyCatalog = class {
|
|
|
3558
3557
|
this.ttlMs = ttlMs;
|
|
3559
3558
|
this.timeoutMs = timeoutMs;
|
|
3560
3559
|
}
|
|
3560
|
+
/**
|
|
3561
|
+
* The last catalog read for a region, without fetching.
|
|
3562
|
+
*
|
|
3563
|
+
* Callers that must answer synchronously (deciding whether a model exposes a
|
|
3564
|
+
* context-budget choice) use this instead of awaiting a refresh.
|
|
3565
|
+
*/
|
|
3566
|
+
snapshot(requested) {
|
|
3567
|
+
return this.snapshots.get(requested ?? readLive(this.region, "global"))?.models ?? [];
|
|
3568
|
+
}
|
|
3561
3569
|
/** Models for one region; a failed refresh keeps the last good list. */
|
|
3562
3570
|
async models(requested) {
|
|
3563
3571
|
const region = requested ?? readLive(this.region, "global");
|
|
@@ -4921,8 +4929,30 @@ var CodeBuddyAdapter = class extends LlmAdapter {
|
|
|
4921
4929
|
}
|
|
4922
4930
|
return content;
|
|
4923
4931
|
}
|
|
4932
|
+
/**
|
|
4933
|
+
* The window this model actually runs with.
|
|
4934
|
+
*
|
|
4935
|
+
* The user's override only applies where the provider accepts one. Every
|
|
4936
|
+
* model in the current catalog reports `supportedLengths: null`, so the CLI
|
|
4937
|
+
* answers a `set_config.contextWindow` with `Allowed: <none>`; a stored
|
|
4938
|
+
* override would then make DSH show a denominator the upstream never uses,
|
|
4939
|
+
* which is exactly how the context ring drifted.
|
|
4940
|
+
*/
|
|
4924
4941
|
contextWindowFor(id, region = this.region) {
|
|
4925
|
-
|
|
4942
|
+
const override = this.options.modelContextWindows?.(region)[id];
|
|
4943
|
+
if (override === void 0) return void 0;
|
|
4944
|
+
const live = this.models(region).find((entry) => entry.id === id);
|
|
4945
|
+
if (live === void 0) return override;
|
|
4946
|
+
return live.contextWindows.includes(override) ? override : void 0;
|
|
4947
|
+
}
|
|
4948
|
+
/** The catalog snapshot the adapter last read (empty before the first read). */
|
|
4949
|
+
models(region) {
|
|
4950
|
+
return this.catalog.snapshot(region);
|
|
4951
|
+
}
|
|
4952
|
+
/** Whether this model lets the user pick a context budget at all. */
|
|
4953
|
+
supportsContextWindowChoice(id, region = this.region) {
|
|
4954
|
+
const live = this.models(region).find((entry) => entry.id === id);
|
|
4955
|
+
return live !== void 0 && live.contextWindows.length > 0;
|
|
4926
4956
|
}
|
|
4927
4957
|
async listModels(provider) {
|
|
4928
4958
|
const region = this.region;
|
|
@@ -8018,7 +8048,6 @@ async function buildCodeBuddyRows(adapter, region) {
|
|
|
8018
8048
|
return (await adapter.describeCatalog(region)).map((entry) => {
|
|
8019
8049
|
const override = adapter.contextWindowFor(entry.id, region);
|
|
8020
8050
|
const choices = new Set(entry.contextWindows);
|
|
8021
|
-
choices.add(entry.defaultContextWindow);
|
|
8022
8051
|
if (override !== void 0) choices.add(override);
|
|
8023
8052
|
return {
|
|
8024
8053
|
id: entry.id,
|
|
@@ -8031,7 +8060,8 @@ async function buildCodeBuddyRows(adapter, region) {
|
|
|
8031
8060
|
defaultContextWindow: entry.defaultContextWindow,
|
|
8032
8061
|
...override === void 0 ? {} : { override },
|
|
8033
8062
|
...entry.priceFactor === void 0 ? {} : { priceFactor: entry.priceFactor },
|
|
8034
|
-
reasoning: (entry.reasoningEfforts?.length ?? 0) > 0
|
|
8063
|
+
reasoning: (entry.reasoningEfforts?.length ?? 0) > 0,
|
|
8064
|
+
contextWindowSelectable: entry.contextWindows.length > 0
|
|
8035
8065
|
};
|
|
8036
8066
|
});
|
|
8037
8067
|
}
|
package/lib/types/api.d.ts
CHANGED
|
@@ -38,6 +38,13 @@ export interface ModelRow {
|
|
|
38
38
|
override?: number;
|
|
39
39
|
priceFactor?: number;
|
|
40
40
|
reasoning: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Whether the provider accepts a context-budget choice for this model.
|
|
43
|
+
*
|
|
44
|
+
* Absent (Qoder, MiniMax) means the ordinary menu applies. `false` means the
|
|
45
|
+
* window is fixed upstream, so the page shows the value without a selector.
|
|
46
|
+
*/
|
|
47
|
+
contextWindowSelectable?: boolean;
|
|
41
48
|
}
|
|
42
49
|
/** The adapters the API can reach, one per provider route. */
|
|
43
50
|
export type AdapterMap = Readonly<Record<BrandId, QoderAdapter | CodeBuddyAdapter | MinimaxAdapter>>;
|
|
@@ -88,7 +88,20 @@ export declare class CodeBuddyAdapter extends LlmAdapter {
|
|
|
88
88
|
* only shape the CLI sends to the model as pixels.
|
|
89
89
|
*/
|
|
90
90
|
private buildFeed;
|
|
91
|
+
/**
|
|
92
|
+
* The window this model actually runs with.
|
|
93
|
+
*
|
|
94
|
+
* The user's override only applies where the provider accepts one. Every
|
|
95
|
+
* model in the current catalog reports `supportedLengths: null`, so the CLI
|
|
96
|
+
* answers a `set_config.contextWindow` with `Allowed: <none>`; a stored
|
|
97
|
+
* override would then make DSH show a denominator the upstream never uses,
|
|
98
|
+
* which is exactly how the context ring drifted.
|
|
99
|
+
*/
|
|
91
100
|
contextWindowFor(id: string, region?: CodeBuddyRegion): number | undefined;
|
|
101
|
+
/** The catalog snapshot the adapter last read (empty before the first read). */
|
|
102
|
+
private models;
|
|
103
|
+
/** Whether this model lets the user pick a context budget at all. */
|
|
104
|
+
supportsContextWindowChoice(id: string, region?: CodeBuddyRegion): boolean;
|
|
92
105
|
listModels(provider: string): Promise<readonly LlmModelInfo[]>;
|
|
93
106
|
resolveModel(provider: string, model: string): Promise<LlmResolvedModelInfo>;
|
|
94
107
|
prepareCall(provider: string, model: string, signal?: AbortSignal): Promise<PreparedAdapterCall>;
|
package/lib/types/codebuddy.d.ts
CHANGED
|
@@ -32,7 +32,16 @@ export interface CodeBuddyModel {
|
|
|
32
32
|
description?: string;
|
|
33
33
|
maxInputTokens?: number;
|
|
34
34
|
maxOutputTokens?: number;
|
|
35
|
+
/**
|
|
36
|
+
* Context budgets the provider actually accepts for this model.
|
|
37
|
+
*
|
|
38
|
+
* Empty means the model exposes no selectable window: CodeBuddy validates
|
|
39
|
+
* `set_config.contextWindow` against `contextWindow.supportedLengths` and
|
|
40
|
+
* rejects everything else with `Allowed: <none>`, so the settings page must
|
|
41
|
+
* not offer a choice the CLI will refuse.
|
|
42
|
+
*/
|
|
35
43
|
contextWindows: number[];
|
|
44
|
+
/** The window the model actually runs with (its physical input limit). */
|
|
36
45
|
defaultContextWindow: number;
|
|
37
46
|
vision: boolean;
|
|
38
47
|
reasoningEfforts?: string[];
|
|
@@ -111,6 +120,13 @@ export declare class CodeBuddyCatalog {
|
|
|
111
120
|
private readonly inflight;
|
|
112
121
|
private readonly failures;
|
|
113
122
|
constructor(region: Live<CodeBuddyRegion>, ttlMs?: Live<number>, timeoutMs?: Live<number>);
|
|
123
|
+
/**
|
|
124
|
+
* The last catalog read for a region, without fetching.
|
|
125
|
+
*
|
|
126
|
+
* Callers that must answer synchronously (deciding whether a model exposes a
|
|
127
|
+
* context-budget choice) use this instead of awaiting a refresh.
|
|
128
|
+
*/
|
|
129
|
+
snapshot(requested?: CodeBuddyRegion): readonly CodeBuddyModel[];
|
|
114
130
|
/** Models for one region; a failed refresh keeps the last good list. */
|
|
115
131
|
models(requested?: CodeBuddyRegion): Promise<readonly CodeBuddyModel[]>;
|
|
116
132
|
/** Why the last refresh failed, or undefined when it succeeded. */
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "dsh-agent-sdk-bridge",
|
|
3
3
|
"displayName": "Agent SDK Bridge",
|
|
4
4
|
"description": "DeepSeek Harness LLM adapter bridge for Qoder CN, Qoder International, Tencent CodeBuddy and MiniMax Code subscriptions. It reuses each provider's own SDK or official ACP server and CLI login, shows available quota, and exposes per-provider settings pages with independent international and mainland login regions.",
|
|
5
|
-
"version": "1.1.
|
|
5
|
+
"version": "1.1.6",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"author": "k1-h2",
|
package/src/api.ts
CHANGED
|
@@ -45,6 +45,13 @@ export interface ModelRow {
|
|
|
45
45
|
override?: number
|
|
46
46
|
priceFactor?: number
|
|
47
47
|
reasoning: boolean
|
|
48
|
+
/**
|
|
49
|
+
* Whether the provider accepts a context-budget choice for this model.
|
|
50
|
+
*
|
|
51
|
+
* Absent (Qoder, MiniMax) means the ordinary menu applies. `false` means the
|
|
52
|
+
* window is fixed upstream, so the page shows the value without a selector.
|
|
53
|
+
*/
|
|
54
|
+
contextWindowSelectable?: boolean
|
|
48
55
|
}
|
|
49
56
|
|
|
50
57
|
/** The adapters the API can reach, one per provider route. */
|
|
@@ -98,9 +105,12 @@ export async function buildCodeBuddyRows(
|
|
|
98
105
|
): Promise<ModelRow[]> {
|
|
99
106
|
const live = await adapter.describeCatalog(region)
|
|
100
107
|
return live.map(entry => {
|
|
108
|
+
// Only windows the provider accepts are offered. CodeBuddy validates
|
|
109
|
+
// `set_config.contextWindow` against `contextWindow.supportedLengths` and
|
|
110
|
+
// answers anything else with `Allowed: <none>`, so a menu entry the CLI
|
|
111
|
+
// refuses would be a switch that does nothing upstream.
|
|
101
112
|
const override = adapter.contextWindowFor(entry.id, region)
|
|
102
113
|
const choices = new Set<number>(entry.contextWindows)
|
|
103
|
-
choices.add(entry.defaultContextWindow)
|
|
104
114
|
if (override !== undefined) choices.add(override)
|
|
105
115
|
return {
|
|
106
116
|
id: entry.id,
|
|
@@ -114,6 +124,7 @@ export async function buildCodeBuddyRows(
|
|
|
114
124
|
...override === undefined ? {} : { override },
|
|
115
125
|
...entry.priceFactor === undefined ? {} : { priceFactor: entry.priceFactor },
|
|
116
126
|
reasoning: (entry.reasoningEfforts?.length ?? 0) > 0,
|
|
127
|
+
contextWindowSelectable: entry.contextWindows.length > 0,
|
|
117
128
|
}
|
|
118
129
|
})
|
|
119
130
|
}
|
package/src/codebuddy-adapter.ts
CHANGED
|
@@ -259,8 +259,32 @@ export class CodeBuddyAdapter extends LlmAdapter {
|
|
|
259
259
|
return content
|
|
260
260
|
}
|
|
261
261
|
|
|
262
|
+
/**
|
|
263
|
+
* The window this model actually runs with.
|
|
264
|
+
*
|
|
265
|
+
* The user's override only applies where the provider accepts one. Every
|
|
266
|
+
* model in the current catalog reports `supportedLengths: null`, so the CLI
|
|
267
|
+
* answers a `set_config.contextWindow` with `Allowed: <none>`; a stored
|
|
268
|
+
* override would then make DSH show a denominator the upstream never uses,
|
|
269
|
+
* which is exactly how the context ring drifted.
|
|
270
|
+
*/
|
|
262
271
|
contextWindowFor(id: string, region: CodeBuddyRegion = this.region): number | undefined {
|
|
263
|
-
|
|
272
|
+
const override = this.options.modelContextWindows?.(region)[id]
|
|
273
|
+
if (override === undefined) return undefined
|
|
274
|
+
const live = this.models(region).find(entry => entry.id === id)
|
|
275
|
+
if (live === undefined) return override
|
|
276
|
+
return live.contextWindows.includes(override) ? override : undefined
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
/** The catalog snapshot the adapter last read (empty before the first read). */
|
|
280
|
+
private models(region: CodeBuddyRegion): readonly CodeBuddyModel[] {
|
|
281
|
+
return this.catalog.snapshot(region)
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
/** Whether this model lets the user pick a context budget at all. */
|
|
285
|
+
supportsContextWindowChoice(id: string, region: CodeBuddyRegion = this.region): boolean {
|
|
286
|
+
const live = this.models(region).find(entry => entry.id === id)
|
|
287
|
+
return live !== undefined && live.contextWindows.length > 0
|
|
264
288
|
}
|
|
265
289
|
|
|
266
290
|
override async listModels(provider: string): Promise<readonly LlmModelInfo[]> {
|
package/src/codebuddy.ts
CHANGED
|
@@ -108,7 +108,16 @@ export interface CodeBuddyModel {
|
|
|
108
108
|
description?: string
|
|
109
109
|
maxInputTokens?: number
|
|
110
110
|
maxOutputTokens?: number
|
|
111
|
+
/**
|
|
112
|
+
* Context budgets the provider actually accepts for this model.
|
|
113
|
+
*
|
|
114
|
+
* Empty means the model exposes no selectable window: CodeBuddy validates
|
|
115
|
+
* `set_config.contextWindow` against `contextWindow.supportedLengths` and
|
|
116
|
+
* rejects everything else with `Allowed: <none>`, so the settings page must
|
|
117
|
+
* not offer a choice the CLI will refuse.
|
|
118
|
+
*/
|
|
111
119
|
contextWindows: number[]
|
|
120
|
+
/** The window the model actually runs with (its physical input limit). */
|
|
112
121
|
defaultContextWindow: number
|
|
113
122
|
vision: boolean
|
|
114
123
|
reasoningEfforts?: string[]
|
|
@@ -256,12 +265,15 @@ function priceFactorOf(model: RawLanguageModel): number | undefined {
|
|
|
256
265
|
|
|
257
266
|
/** Turn one raw catalog entry into the model row this plugin uses. */
|
|
258
267
|
export function toCodeBuddyModel(model: RawLanguageModel): CodeBuddyModel {
|
|
268
|
+
// Only what the provider declares as selectable is a choice. The physical
|
|
269
|
+
// `maxInputTokens` is the window the model runs with, not a menu entry:
|
|
270
|
+
// folding it into `contextWindows` offered 200K/1M switches that the CLI
|
|
271
|
+
// answered with `Invalid context_window value … Allowed: <none>`.
|
|
259
272
|
const windows = new Set<number>(model.contextWindow?.supportedLengths ?? [])
|
|
260
273
|
const declared = model.contextWindow?.defaultLength
|
|
261
274
|
?? model.maxInputTokens
|
|
262
275
|
?? model.maxAllowedSize
|
|
263
276
|
?? CODEBUDDY_DEFAULT_CONTEXT_WINDOW
|
|
264
|
-
windows.add(declared)
|
|
265
277
|
return {
|
|
266
278
|
id: model.id,
|
|
267
279
|
name: model.name ?? model.id,
|
|
@@ -334,6 +346,16 @@ export class CodeBuddyCatalog {
|
|
|
334
346
|
private readonly timeoutMs: Live<number> = CODEBUDDY_FETCH_TIMEOUT_MS,
|
|
335
347
|
) {}
|
|
336
348
|
|
|
349
|
+
/**
|
|
350
|
+
* The last catalog read for a region, without fetching.
|
|
351
|
+
*
|
|
352
|
+
* Callers that must answer synchronously (deciding whether a model exposes a
|
|
353
|
+
* context-budget choice) use this instead of awaiting a refresh.
|
|
354
|
+
*/
|
|
355
|
+
snapshot(requested?: CodeBuddyRegion): readonly CodeBuddyModel[] {
|
|
356
|
+
return this.snapshots.get(requested ?? readLive(this.region, 'global'))?.models ?? []
|
|
357
|
+
}
|
|
358
|
+
|
|
337
359
|
/** Models for one region; a failed refresh keeps the last good list. */
|
|
338
360
|
async models(requested?: CodeBuddyRegion): Promise<readonly CodeBuddyModel[]> {
|
|
339
361
|
const region = requested ?? readLive(this.region, 'global')
|