dsh-vertex-argon 1.2.0 → 1.2.1
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 +2 -2
- package/adapter.js +56 -7
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
|
|
15
15
|
`dsh-vertex-argon` 为 [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness) (DSH) 提供完整的 **Gemini 4 Argon** 接入支持,自动聚合 **Google Vertex AI**(服务账号 / ADC)与 **Google Gemini Developer API**(AI Studio API Key)双通道,修复内置 `pi-ai` 适配器误传 `thinkingBudget` 导致的 `HTTP 400` 报错,完整打通原生三档思考、思维链(Thought Summaries)、`v1beta1` **Long Decode 跨段长生成自动续传**与带签名的多轮工具调用。
|
|
16
16
|
|
|
17
|
-
Current release: **[1.2.
|
|
17
|
+
Current release: **[1.2.1](https://github.com/higekibaka/dsh-vertex-argon)** · [npm](https://www.npmjs.com/package/dsh-vertex-argon)
|
|
18
18
|
|
|
19
19
|
---
|
|
20
20
|
|
|
@@ -25,7 +25,7 @@ Current release: **[1.2.0](https://github.com/higekibaka/dsh-vertex-argon)** ·
|
|
|
25
25
|
| **思考控制参数** | 误判为旧模型并发送 `thinkingBudget: -1`,触发云端 `HTTP 400` | 原生发送 `thinkingLevel: "LOW" \| "MEDIUM" \| "HIGH"`,绝不传 `thinkingBudget` |
|
|
26
26
|
| **思维链(思考摘要)** | 手动新增模型默认无 `reasoning` 标记,不请求摘要 | 固定开启 `includeThoughts: true`,流式解析 `thought: true` 实时展示思维链 |
|
|
27
27
|
| **多轮工具调用回传** | 路由切换或签名不对齐时易丢失上下文 | 保持 `provider` / `model` 与 `thoughtSignature` 签名全链路一致 |
|
|
28
|
-
| **Long Decode 长生成** | Vertex 硬编码 `v1` 且锁死 64K,遇 `CONTINUATION` 直接抛错断流 | 自动切换 `v1beta1` 跨 64K
|
|
28
|
+
| **Long Decode 长生成** | Vertex 硬编码 `v1` 且锁死 64K,遇 `CONTINUATION` 直接抛错断流 | 自动切换 `v1beta1` 跨 64K 分段零延迟续传(最高 512K)、断流检查点指数退避恢复,按首跳输入上报水位防误压缩 |
|
|
29
29
|
| **采样参数净化** | 可能携带被 Argon 拒绝或忽略的采样字段 | 自动剥离 `temperature`、`topP`、`topK` 等无效采样参数 |
|
|
30
30
|
| **通道管理与设置** | 需手改 `cordis.patch.yml` 并反复排查校验报错 | 自动检测双通道 + 内置 **设置 → Vertex Argon** 图形化实时调节页面 |
|
|
31
31
|
|
package/adapter.js
CHANGED
|
@@ -17,6 +17,9 @@ export const LEVELS = ['low', 'medium', 'high']
|
|
|
17
17
|
export const MAX_SINGLE_CALL_TOKENS = 65536
|
|
18
18
|
export const MAX_LONG_DECODE_TOKENS = 524288
|
|
19
19
|
export const MAX_CONTINUATION_HOPS = 32
|
|
20
|
+
export const RECONNECT_INITIAL_DELAY_MS = 500
|
|
21
|
+
export const RECONNECT_MAX_DELAY_MS = 10000
|
|
22
|
+
export const RECONNECT_JITTER_RATIO = 0.1
|
|
20
23
|
const MAX_STREAM_RECONNECTS_WITHOUT_PROGRESS = 3
|
|
21
24
|
const COMPACTION_HEADROOM_FLOOR = 131072
|
|
22
25
|
const ENV_KEYS = ['GOOGLE_APPLICATION_CREDENTIALS', 'GOOGLE_CLOUD_PROJECT', 'GCLOUD_PROJECT', 'GOOGLE_CLOUD_LOCATION', 'GOOGLE_CLOUD_API_KEY']
|
|
@@ -91,12 +94,49 @@ function isAbortedError(err, signal) {
|
|
|
91
94
|
return Boolean(signal?.aborted) || (err instanceof Error && err.name === 'AbortError')
|
|
92
95
|
}
|
|
93
96
|
|
|
94
|
-
function
|
|
95
|
-
return
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
)
|
|
97
|
+
function isNonRetryableApiRejection(err, receivedAnyChunk, hopCount, hasCheckpointToken) {
|
|
98
|
+
if (receivedAnyChunk) return false
|
|
99
|
+
if (!(err instanceof Error && (err.name === 'ApiError' || ('status' in err && typeof err.status === 'number')))) {
|
|
100
|
+
return false
|
|
101
|
+
}
|
|
102
|
+
if (!hasCheckpointToken || hopCount <= 1) return true
|
|
103
|
+
const status = typeof err.status === 'number' ? err.status : 0
|
|
104
|
+
if (status === 408 || status === 429 || (status >= 500 && status < 600)) return false
|
|
105
|
+
return true
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export function computeReconnectDelayMs(attempt, options = {}) {
|
|
109
|
+
const initialDelayMs = options?.initialDelayMs ?? RECONNECT_INITIAL_DELAY_MS
|
|
110
|
+
if (!(initialDelayMs > 0)) return 0
|
|
111
|
+
const maxDelayMs = options?.maxDelayMs ?? RECONNECT_MAX_DELAY_MS
|
|
112
|
+
const jitterRatio = options?.jitterRatio ?? RECONNECT_JITTER_RATIO
|
|
113
|
+
const random = options?.random ?? Math.random
|
|
114
|
+
const exponent = Math.min(Math.max(0, attempt - 1), 10)
|
|
115
|
+
const exponential = Math.min(initialDelayMs * (2 ** exponent), maxDelayMs)
|
|
116
|
+
const jitter = 1 - jitterRatio + 2 * jitterRatio * random()
|
|
117
|
+
return Math.round(Math.min(exponential * jitter, maxDelayMs))
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function waitWithAbort(delayMs, signal) {
|
|
121
|
+
if (!(delayMs > 0)) return Promise.resolve()
|
|
122
|
+
if (signal?.aborted) {
|
|
123
|
+
const err = new Error('The operation was aborted')
|
|
124
|
+
err.name = 'AbortError'
|
|
125
|
+
return Promise.reject(err)
|
|
126
|
+
}
|
|
127
|
+
return new Promise((resolve, reject) => {
|
|
128
|
+
const timer = setTimeout(() => {
|
|
129
|
+
signal?.removeEventListener?.('abort', onAbort)
|
|
130
|
+
resolve()
|
|
131
|
+
}, delayMs)
|
|
132
|
+
function onAbort() {
|
|
133
|
+
clearTimeout(timer)
|
|
134
|
+
const err = new Error('The operation was aborted')
|
|
135
|
+
err.name = 'AbortError'
|
|
136
|
+
reject(err)
|
|
137
|
+
}
|
|
138
|
+
signal?.addEventListener?.('abort', onAbort, { once: true })
|
|
139
|
+
})
|
|
100
140
|
}
|
|
101
141
|
|
|
102
142
|
async function continueArgonRequestStream(apiClient, origRequestStream, request, meta) {
|
|
@@ -120,6 +160,7 @@ async function continueArgonRequestStream(apiClient, origRequestStream, request,
|
|
|
120
160
|
let baseBodyObj
|
|
121
161
|
let resumeToken
|
|
122
162
|
let reconnectsWithoutProgress = 0
|
|
163
|
+
let consecutiveReconnectFailures = 0
|
|
123
164
|
let lastError
|
|
124
165
|
let hopCount = 0
|
|
125
166
|
let initialPromptTokens
|
|
@@ -250,7 +291,7 @@ async function continueArgonRequestStream(apiClient, origRequestStream, request,
|
|
|
250
291
|
if (
|
|
251
292
|
hopError &&
|
|
252
293
|
(isAbortedError(hopError.error, request?.abortSignal) ||
|
|
253
|
-
|
|
294
|
+
isNonRetryableApiRejection(hopError.error, hopReceivedAnyChunk, hopCount, Boolean(hopToken || hopStartToken)))
|
|
254
295
|
) {
|
|
255
296
|
throw hopError.error
|
|
256
297
|
}
|
|
@@ -266,16 +307,20 @@ async function continueArgonRequestStream(apiClient, origRequestStream, request,
|
|
|
266
307
|
if (hopFinishReason === 'CONTINUATION' && hasNewToken) {
|
|
267
308
|
resumeToken = hopToken
|
|
268
309
|
reconnectsWithoutProgress = 0
|
|
310
|
+
consecutiveReconnectFailures = hopError ? 1 : 0
|
|
269
311
|
} else {
|
|
270
312
|
resumeToken = undefined
|
|
271
313
|
reconnectsWithoutProgress = 0
|
|
314
|
+
consecutiveReconnectFailures = 0
|
|
272
315
|
}
|
|
273
316
|
} else if (hasNewToken) {
|
|
274
317
|
resumeToken = hopToken
|
|
275
318
|
reconnectsWithoutProgress = 0
|
|
319
|
+
consecutiveReconnectFailures = 1
|
|
276
320
|
} else if (!hopHasYieldedContent && hopStartToken && reconnectsWithoutProgress < MAX_STREAM_RECONNECTS_WITHOUT_PROGRESS) {
|
|
277
321
|
resumeToken = hopStartToken
|
|
278
322
|
reconnectsWithoutProgress += 1
|
|
323
|
+
consecutiveReconnectFailures += 1
|
|
279
324
|
} else {
|
|
280
325
|
resumeToken = undefined
|
|
281
326
|
}
|
|
@@ -286,6 +331,10 @@ async function continueArgonRequestStream(apiClient, origRequestStream, request,
|
|
|
286
331
|
(hopFinishReason === 'CONTINUATION' || hopFinishReason === undefined)
|
|
287
332
|
|
|
288
333
|
if (canResume) {
|
|
334
|
+
if (consecutiveReconnectFailures > 0) {
|
|
335
|
+
const delayMs = computeReconnectDelayMs(consecutiveReconnectFailures, meta?.reconnectBackoff)
|
|
336
|
+
await waitWithAbort(delayMs, request?.abortSignal)
|
|
337
|
+
}
|
|
289
338
|
if (!baseBodyObj) baseBodyObj = JSON.parse(request.body)
|
|
290
339
|
const nextReq = {
|
|
291
340
|
...request,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-vertex-argon",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.1",
|
|
4
4
|
"description": "Google Vertex AI & Gemini API Argon plugin for DeepSeek Harness — native Low/Medium/High thinking levels, v1beta1 Long Decode continuation, thought summaries, signed tool-call replay, and dedicated Settings UI.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|