@vibedev-si/dsh-vibedev 0.7.1 → 0.7.2
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/README.md +10 -6
- package/THIRD-PARTY-NOTICES.txt +1 -1
- package/lib/index.js +55 -43
- package/lib/llm/context-budget.d.ts +52 -20
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -10,11 +10,13 @@
|
|
|
10
10
|
|
|
11
11
|
本插件由 `dsh-media` 改名而来,见下面的「从 dsh-media 升级」。
|
|
12
12
|
|
|
13
|
-
## 0.7.
|
|
13
|
+
## 0.7.2 用户可见更新
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
上下文窗口现在就是网关下发的输入上限(`max_input_tokens`):1M 的模型显示 1M,不再显示 1.34M。宿主的自动压缩仍然落在窗口的 80%(宿主自己的 0.8 阈值),所以看到 80% 就是该压缩的时候,不会再出现「表上还剩四分之一、请求却被网关拒掉」的情况。
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
阈值之所以能落在 80%,是因为插件现在把每次请求的输出预留也交给宿主了:网关按「消息 + 输出预留」计算同一个窗口(一次 655K 消息配 393K 预留就被判超窗),而之前宿主不知道这份预留,按消息独占全窗来算。现在预留收在窗口的 20% 以内(1M 窗口是 128K):压缩点是窗口的 80%,也就是 800K 消息,加上预留一共约 930K,仍在模型 1.05M 的合并上限之内;之前预留 393K,同一个压缩点合起来要 1.19M,根本发不出去。
|
|
18
|
+
|
|
19
|
+
供应商返回「prompt is too long: N tokens > M maximum」这类超窗错误时,仍然会被识别成上下文超限:宿主会先压缩再重试一次这次请求,而不是把它判成不可重试的错误。
|
|
18
20
|
|
|
19
21
|
## 0.7.0 用户可见更新
|
|
20
22
|
|
|
@@ -340,11 +342,13 @@ npm run build
|
|
|
340
342
|
|
|
341
343
|
## English
|
|
342
344
|
|
|
343
|
-
### What changes in 0.7.
|
|
345
|
+
### What changes in 0.7.2
|
|
346
|
+
|
|
347
|
+
The context window is now exactly the input cap the gateway states (`max_input_tokens`): a 1M model reads 1M, not 1.34M. The host still compacts at 80% of that window — its own 0.8 ratio — so 80% on the meter is where compaction happens, and a request no longer gets refused while the meter still shows a third of the window free.
|
|
344
348
|
|
|
345
|
-
|
|
349
|
+
That ratio only lands at 80% because the plugin now reports each request's completion reserve to the host as well: the gateway prices `messages + completion` against one window (655K of messages with a 393K reserve was refused), while the host, not knowing that reserve, priced the whole window as input. The reserve is now kept under 20% of the window (128K for a 1M window): the trigger is 80% of the window, 800K of messages, and the request released there is about 930K including the reserve — still inside the model's 1.05M combined limit. The old 393K reserve would have made the same trigger cost 1.19M, which could never be sent.
|
|
346
350
|
|
|
347
|
-
A provider overflow such as "prompt is too long: N tokens > M maximum" is
|
|
351
|
+
A provider overflow such as "prompt is too long: N tokens > M maximum" is still classified as a context-window failure, so the host compacts once and retries that request instead of treating the turn as a non-retryable error.
|
|
348
352
|
|
|
349
353
|
### What changes in 0.7.0
|
|
350
354
|
|
package/THIRD-PARTY-NOTICES.txt
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
THIRD-PARTY NOTICES · @vibedev-si/dsh-vibedev 0.7.
|
|
1
|
+
THIRD-PARTY NOTICES · @vibedev-si/dsh-vibedev 0.7.2
|
|
2
2
|
|
|
3
3
|
This package bundles code from the projects below. Each is used under the licence that
|
|
4
4
|
follows its name; the licence texts are reproduced as the projects ship them.
|
package/lib/index.js
CHANGED
|
@@ -5880,51 +5880,61 @@ const openAICompletionsApi = () => lazyApi(() => import("./openai-completions-Dq
|
|
|
5880
5880
|
const openAIResponsesApi = () => lazyApi(() => import("./openai-responses-DygWnsye.js"));
|
|
5881
5881
|
//#endregion
|
|
5882
5882
|
//#region src/llm/context-budget.ts
|
|
5883
|
-
/**
|
|
5884
|
-
* What a catalog model's returned `contextWindow` should be.
|
|
5885
|
-
*
|
|
5886
|
-
* The host compacts from the window it is told: `basic-compaction` starts at
|
|
5887
|
-
* `min(thresholdRatio × window, window − maxTokens − headroomTokens)` (defaults 0.8, 65,536) and
|
|
5888
|
-
* measures against provider usage plus a heuristic delta. Declaring the provider's *input cap* as the
|
|
5889
|
-
* window therefore compacts at 80% of that cap at best, and earlier whenever the output reserve is
|
|
5890
|
-
* large — but declaring more than the cap lets a request outgrow it before compaction fires.
|
|
5891
|
-
*
|
|
5892
|
-
* The gateway states both numbers: `context_window` (capacity) and `max_input_tokens` (the cap its
|
|
5893
|
-
* provider enforces; the value a `context_length_exceeded` error quotes). Where the two agree, the
|
|
5894
|
-
* input cap is the real limit and the provider bills output outside it, so the host's total capacity
|
|
5895
|
-
* is `input + maxTokens`: the reserve the host subtracts then cancels out and the trigger lands in
|
|
5896
|
-
* the 80–90% band of the real input budget. Where `context_window` is larger than the input cap it
|
|
5897
|
-
* is a real total, and the window never claims past it.
|
|
5898
|
-
*
|
|
5899
|
-
* @module dsh-vibedev/llm/context-budget
|
|
5900
|
-
*/
|
|
5901
|
-
/** Share of the provider's input budget compaction should start around. */
|
|
5902
|
-
const CONTEXT_COMPACT_TARGET = .88;
|
|
5903
|
-
/** The host compaction default this arithmetic is written against (`thresholdRatio`). */
|
|
5904
|
-
const HOST_THRESHOLD_RATIO = .8;
|
|
5905
5883
|
/** The host compaction default reserve below the message budget (`headroomTokens`). */
|
|
5906
5884
|
const HOST_HEADROOM_TOKENS = 65536;
|
|
5907
|
-
/**
|
|
5908
|
-
|
|
5885
|
+
/** A completion below this trades too much of the model's own output for compaction timing. */
|
|
5886
|
+
const MIN_COMPLETION_TOKENS = 32768;
|
|
5887
|
+
/** The trigger never falls below this share of the window, however tight the headroom gets. */
|
|
5888
|
+
const MIN_THRESHOLD_SHARE = .1;
|
|
5889
|
+
/** A derived completion is stated in whole blocks, so the reserve reads like a limit. */
|
|
5890
|
+
const COMPLETION_STEP = 4096;
|
|
5891
|
+
/**
|
|
5892
|
+
* The window to report to the host: the input the provider will actually take.
|
|
5909
5893
|
*
|
|
5910
|
-
*
|
|
5911
|
-
*
|
|
5912
|
-
*
|
|
5913
|
-
* catalog states one.
|
|
5914
|
-
* @param budget - the catalog's capacity, input cap and output reserve.
|
|
5894
|
+
* This is deliberately *not* sized to move the host's trigger; the trigger is moved by the
|
|
5895
|
+
* completion reserve instead, so the number on screen keeps meaning "input left".
|
|
5896
|
+
* @param budget - the catalog's capacity and input cap.
|
|
5915
5897
|
* @param fallback - window for a catalog that states no capacity at all.
|
|
5916
5898
|
* @returns a positive token count to declare as the model's context window.
|
|
5917
5899
|
*/
|
|
5918
5900
|
function declaredContextWindow(budget, fallback) {
|
|
5919
5901
|
const window = budget.contextWindow;
|
|
5920
|
-
const
|
|
5921
|
-
if (
|
|
5922
|
-
|
|
5923
|
-
|
|
5924
|
-
|
|
5925
|
-
|
|
5926
|
-
|
|
5927
|
-
|
|
5902
|
+
const cap = budget.maxInputTokens;
|
|
5903
|
+
if (window === void 0) return Math.max(1, cap ?? fallback);
|
|
5904
|
+
if (cap === void 0) return Math.max(1, window);
|
|
5905
|
+
return Math.max(1, Math.min(window, cap));
|
|
5906
|
+
}
|
|
5907
|
+
/**
|
|
5908
|
+
* The completion to report and to request per call.
|
|
5909
|
+
*
|
|
5910
|
+
* An output the catalog already keeps under the reserve is left alone. A larger one is capped at
|
|
5911
|
+
* the reserve, so the host's ratio decides the trigger and `messages + completion` stays inside
|
|
5912
|
+
* the provider's combined limit. A window too small for the ratio keeps a workable floor and lets
|
|
5913
|
+
* the trigger fall earlier, and never reports a completion that would leave no pressure budget.
|
|
5914
|
+
* @param budget - the catalog's output and capacity.
|
|
5915
|
+
* @param contextWindow - the window declared by {@link declaredContextWindow}.
|
|
5916
|
+
* @returns the completion tokens one request may reserve.
|
|
5917
|
+
*/
|
|
5918
|
+
function declaredCompletionTokens(budget, contextWindow) {
|
|
5919
|
+
const room = Math.floor(contextWindow * .19999999999999996) - HOST_HEADROOM_TOKENS;
|
|
5920
|
+
const safe = contextWindow - HOST_HEADROOM_TOKENS - Math.max(1, Math.floor(contextWindow * MIN_THRESHOLD_SHARE));
|
|
5921
|
+
const limit = Math.max(1, Math.min(Math.max(room, MIN_COMPLETION_TOKENS), safe));
|
|
5922
|
+
if (budget.maxTokens <= limit) return Math.max(1, budget.maxTokens);
|
|
5923
|
+
return Math.max(1, Math.floor(limit / COMPLETION_STEP) * COMPLETION_STEP);
|
|
5924
|
+
}
|
|
5925
|
+
/**
|
|
5926
|
+
* Both numbers an adapter model reports, kept together so the window and its reserve never
|
|
5927
|
+
* disagree.
|
|
5928
|
+
* @param budget - the catalog's capacity, input cap and output.
|
|
5929
|
+
* @param fallback - window for a catalog that states no capacity at all.
|
|
5930
|
+
* @returns the window and the completion to declare.
|
|
5931
|
+
*/
|
|
5932
|
+
function declaredBudget(budget, fallback) {
|
|
5933
|
+
const contextWindow = declaredContextWindow(budget, fallback);
|
|
5934
|
+
return {
|
|
5935
|
+
contextWindow,
|
|
5936
|
+
maxTokens: declaredCompletionTokens(budget, contextWindow)
|
|
5937
|
+
};
|
|
5928
5938
|
}
|
|
5929
5939
|
//#endregion
|
|
5930
5940
|
//#region src/llm/models.ts
|
|
@@ -6021,6 +6031,11 @@ function toPiModel(model, provider, origin) {
|
|
|
6021
6031
|
const levels = model.reasoningLevels ?? [];
|
|
6022
6032
|
const reasoning = levels.length > 0;
|
|
6023
6033
|
const compat = compatOf(model);
|
|
6034
|
+
const budget = declaredBudget({
|
|
6035
|
+
contextWindow: model.contextWindow,
|
|
6036
|
+
...model.maxInputTokens === void 0 ? {} : { maxInputTokens: model.maxInputTokens },
|
|
6037
|
+
maxTokens: model.maxTokens
|
|
6038
|
+
}, model.contextWindow);
|
|
6024
6039
|
return {
|
|
6025
6040
|
id: model.id,
|
|
6026
6041
|
name: model.name,
|
|
@@ -6031,12 +6046,8 @@ function toPiModel(model, provider, origin) {
|
|
|
6031
6046
|
...reasoning ? { thinkingLevelMap: thinkingLevelMap(levels) } : {},
|
|
6032
6047
|
input: [...model.input],
|
|
6033
6048
|
cost: { ...model.cost },
|
|
6034
|
-
contextWindow:
|
|
6035
|
-
|
|
6036
|
-
...model.maxInputTokens === void 0 ? {} : { maxInputTokens: model.maxInputTokens },
|
|
6037
|
-
maxTokens: model.maxTokens
|
|
6038
|
-
}, model.contextWindow),
|
|
6039
|
-
maxTokens: model.maxTokens,
|
|
6049
|
+
contextWindow: budget.contextWindow,
|
|
6050
|
+
maxTokens: budget.maxTokens,
|
|
6040
6051
|
...compat === void 0 ? {} : { compat }
|
|
6041
6052
|
};
|
|
6042
6053
|
}
|
|
@@ -6608,6 +6619,7 @@ var GatewayAdapter = class extends LlmAdapter {
|
|
|
6608
6619
|
name: model.name,
|
|
6609
6620
|
inputModalities: [...model.input],
|
|
6610
6621
|
context: { contextWindow: model.contextWindow },
|
|
6622
|
+
defaultMaxTokens: model.maxTokens,
|
|
6611
6623
|
...reasoningInfo(model, catalog)
|
|
6612
6624
|
};
|
|
6613
6625
|
}
|
|
@@ -1,27 +1,34 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* The capacity and completion budget one catalog model reports to the host.
|
|
3
3
|
*
|
|
4
|
-
* The host
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* window
|
|
8
|
-
*
|
|
4
|
+
* The host's `basic-compaction` reads two numbers from the adapter model and charges both to the
|
|
5
|
+
* same window: the window itself, and the completion the route reserves per request (the request
|
|
6
|
+
* header's `maxTokens`, else the adapter's `defaultMaxTokens`). It compacts at
|
|
7
|
+
* `min(thresholdRatio × window, window − completion − headroomTokens)`, defaulting to `0.8` and
|
|
8
|
+
* `65,536`. The gateway prices a request the same way: `messages + completion` against the
|
|
9
|
+
* provider's own combined limit.
|
|
9
10
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* the
|
|
15
|
-
*
|
|
11
|
+
* Two rules follow:
|
|
12
|
+
*
|
|
13
|
+
* - The window is the input the provider really takes (`max_input_tokens`), because the context
|
|
14
|
+
* meter divides pressure by it. Declaring more — the previous `input + completion` sizing that
|
|
15
|
+
* moved the ratio alone — made a request already at the real input budget read as two thirds of
|
|
16
|
+
* the way through, and pushed the host's trigger above the cap it was meant to respect.
|
|
17
|
+
* - The completion must fit under `window × (1 − thresholdRatio) − headroomTokens`, or the host
|
|
18
|
+
* subtracts it from the pressure budget and compacts early, while a request near the trigger
|
|
19
|
+
* overshoots the provider's combined limit by the completion it asked for.
|
|
20
|
+
*
|
|
21
|
+
* Both cannot always hold: a small window with the fixed 65,536 headroom cannot reach the ratio.
|
|
22
|
+
* There the completion wins a floor and the trigger lands lower, which is safe but earlier.
|
|
16
23
|
*
|
|
17
24
|
* @module dsh-vibedev/llm/context-budget
|
|
18
25
|
*/
|
|
19
|
-
/** Share of the provider's input budget compaction should start around. */
|
|
20
|
-
export declare const CONTEXT_COMPACT_TARGET = 0.88;
|
|
21
26
|
/** The host compaction default this arithmetic is written against (`thresholdRatio`). */
|
|
22
27
|
export declare const HOST_THRESHOLD_RATIO = 0.8;
|
|
23
28
|
/** The host compaction default reserve below the message budget (`headroomTokens`). */
|
|
24
29
|
export declare const HOST_HEADROOM_TOKENS = 65536;
|
|
30
|
+
/** A completion below this trades too much of the model's own output for compaction timing. */
|
|
31
|
+
export declare const MIN_COMPLETION_TOKENS = 32768;
|
|
25
32
|
/** What the catalog says about one model's capacity. */
|
|
26
33
|
export interface CatalogBudget {
|
|
27
34
|
/** Catalog capacity, when it states one. */
|
|
@@ -31,15 +38,40 @@ export interface CatalogBudget {
|
|
|
31
38
|
/** Output the catalog reserves per request. */
|
|
32
39
|
readonly maxTokens: number;
|
|
33
40
|
}
|
|
41
|
+
/** The two numbers one adapter model hands the host. */
|
|
42
|
+
export interface DeclaredBudget {
|
|
43
|
+
/** The window the context meter divides by and compaction starts from. */
|
|
44
|
+
readonly contextWindow: number;
|
|
45
|
+
/** The completion every request reserves inside that window. */
|
|
46
|
+
readonly maxTokens: number;
|
|
47
|
+
}
|
|
34
48
|
/**
|
|
35
|
-
* The window to report to the host.
|
|
49
|
+
* The window to report to the host: the input the provider will actually take.
|
|
36
50
|
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
* catalog states one.
|
|
41
|
-
* @param budget - the catalog's capacity, input cap and output reserve.
|
|
51
|
+
* This is deliberately *not* sized to move the host's trigger; the trigger is moved by the
|
|
52
|
+
* completion reserve instead, so the number on screen keeps meaning "input left".
|
|
53
|
+
* @param budget - the catalog's capacity and input cap.
|
|
42
54
|
* @param fallback - window for a catalog that states no capacity at all.
|
|
43
55
|
* @returns a positive token count to declare as the model's context window.
|
|
44
56
|
*/
|
|
45
57
|
export declare function declaredContextWindow(budget: CatalogBudget, fallback: number): number;
|
|
58
|
+
/**
|
|
59
|
+
* The completion to report and to request per call.
|
|
60
|
+
*
|
|
61
|
+
* An output the catalog already keeps under the reserve is left alone. A larger one is capped at
|
|
62
|
+
* the reserve, so the host's ratio decides the trigger and `messages + completion` stays inside
|
|
63
|
+
* the provider's combined limit. A window too small for the ratio keeps a workable floor and lets
|
|
64
|
+
* the trigger fall earlier, and never reports a completion that would leave no pressure budget.
|
|
65
|
+
* @param budget - the catalog's output and capacity.
|
|
66
|
+
* @param contextWindow - the window declared by {@link declaredContextWindow}.
|
|
67
|
+
* @returns the completion tokens one request may reserve.
|
|
68
|
+
*/
|
|
69
|
+
export declare function declaredCompletionTokens(budget: CatalogBudget, contextWindow: number): number;
|
|
70
|
+
/**
|
|
71
|
+
* Both numbers an adapter model reports, kept together so the window and its reserve never
|
|
72
|
+
* disagree.
|
|
73
|
+
* @param budget - the catalog's capacity, input cap and output.
|
|
74
|
+
* @param fallback - window for a catalog that states no capacity at all.
|
|
75
|
+
* @returns the window and the completion to declare.
|
|
76
|
+
*/
|
|
77
|
+
export declare function declaredBudget(budget: CatalogBudget, fallback: number): DeclaredBudget;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vibedev-si/dsh-vibedev",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.2",
|
|
4
4
|
"description": "VibeDev 账号与模型:在 DeepSeek Harness 里登录 VibeDev,与 DeepSeek 账号并存,使用 VibeDev 网关的模型(Claude、GPT 等),并生成图片、视频、音乐和播客 · VibeDev account and models for DeepSeek Harness: sign in to VibeDev next to the DeepSeek account and use the VibeDev gateway's models (Claude, GPT and more), plus image, video, music and podcast generation",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|