dsh-vertex-argon 2.2.3 → 2.2.5
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/CHANGELOG.md +23 -0
- package/README.md +1 -1
- package/adapter.js +90 -26
- package/google-signatures.js +9 -3
- package/index.js +18 -5
- package/interaction-adapter.js +4 -3
- package/interactions-input.js +5 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,29 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to **Gemini 4 Adapter** (`dsh-vertex-argon`) are documented in this file.
|
|
4
4
|
|
|
5
|
+
## [2.2.5] - 2026-11-19
|
|
6
|
+
|
|
7
|
+
### Fixed
|
|
8
|
+
- **Same-Chunk Unsigned-to-Signed Part Boundaries (`google-signatures.js`)**:
|
|
9
|
+
- Tracked `currentFromThisChunk` inside `observe(chunk)` so an unsigned part followed immediately by a signed part (`text` or `thinking`) within the same `candidates[0].content.parts` array always splits 1:1 into separate blocks while preserving cross-chunk delta merging.
|
|
10
|
+
- **Strict `extraBody` Effort/Null Hardening & Direct-Provider Origin Pinning (`adapter.js`)**:
|
|
11
|
+
- Added `'reasoningEffort'`, `'reasoning_effort'`, `'thinkingLevel'`, and `'thinking_level'` to `EXTRA_BODY_STRIPPED_KEYS` (and stripped `reasoningEffort` / `reasoning_effort` on `body` & `cleanConfig` in `gemini4StreamSimple`), and rejected explicit `null` / non-plain-object values for `httpOptions.extraBody`, `extraBody.generationConfig`, and `extraBody.generation_config` with `INVALID_REQUEST`.
|
|
12
|
+
- Pinned `baseUrl` and `contextWindow` on `effectiveModel` in `argonProvider.streamSimple` from `configured` alongside `id`, `provider`, `api`, `maxTokens`, `thinkingLevelMap`, and `[MAX_TOKENS_CEILING]`.
|
|
13
|
+
- **Two-Stage `apply()` Cleanup Rollback (`index.js`)**:
|
|
14
|
+
- Rolled back both `registration?.()` and `unpatchPiAi()` in `try/finally` inside both the `ctx.effect` disposer and `catch` handler if `ctx.effect(...)` throws after `ctx.llm.registerAdapter()` has succeeded.
|
|
15
|
+
|
|
16
|
+
## [2.2.4] - 2026-11-19
|
|
17
|
+
|
|
18
|
+
### Fixed
|
|
19
|
+
- **Google Background Interactions `longDecode: false` Clamp & `maxTokens: null` Guard (`interaction-adapter.js`, `interactions-input.js`)**:
|
|
20
|
+
- Clamped outbound `maxTokens` / `generation_config.max_output_tokens` to `65,536` when `longDecode === false` (including Google background Interactions where `explicitMaxTokensCap > 65536`), and rejected explicit `maxTokens: null` in both `buildInteractionRequest` and `argonProvider.streamSimple`.
|
|
21
|
+
- **GenerateContent `onPayload` `extraBody` Thinking Sanitization, Mandatory Output Cap & Cloned Model Ceiling Retention (`adapter.js`)**:
|
|
22
|
+
- Sanitized `httpOptions.extraBody` and `extraBody.generationConfig` / `generation_config` (`thinkingConfig`, `thinkingBudget`, `includeThoughts`, sampling keys) for all Gemini 4 models (plus explicit cache fields on Hydrogen/Neon), and ensured omitted `config.maxOutputTokens` after upstream `onPayload` hooks is restored to the resolved output budget.
|
|
23
|
+
- Preserved trusted `configured` model properties and `MAX_TOKENS_CEILING` symbols in `argonProvider.streamSimple` so JSON-cloned model descriptors cannot bypass configured caps.
|
|
24
|
+
- **Signed Thinking Part Boundaries & Startup Registration Rollback (`google-signatures.js`, `index.js`)**:
|
|
25
|
+
- Split subsequent unsigned thinking parts away from preceding signed thinking parts in `observe()` so empty signed thinking parts preserve 1:1 boundaries.
|
|
26
|
+
- Registered `installGemini4PiAiPatch()` disposal immediately and rolled back the lease if `ctx.llm.registerAdapter()` throws.
|
|
27
|
+
|
|
5
28
|
## [2.2.3] - 2026-11-19
|
|
6
29
|
|
|
7
30
|
### Fixed
|
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
**面向 [DeepSeek Harness](<https://github.com/deepseek-ai/deepseek-harness>) 的 Google 官方双通道(Vertex AI + Gemini Developer API)Gemini 4 适配器,原生支持 Argon、Carbon、Hydrogen 与 Neon 八模型路由、GenerateContent / Interactions 双协议、65K+ 多跳长解码与请求级诊断。**
|
|
6
6
|
|
|
7
|
-
- **当前版本**:`2.2.
|
|
7
|
+
- **当前版本**:`2.2.5`([CHANGELOG.md](<CHANGELOG.md>))
|
|
8
8
|
- **npm 包名**:`dsh-vertex-argon`(保留既有包名、官方通道路由与本地存储域 ID,官方通道用户可直接原地升级;`2.0.0` 已移除 `1.6.x` 非官方反代通道)
|
|
9
9
|
- **运行要求**:DSH `>=0.2.0-rc.2`,Node.js `^22.19.0 || >=24.0.0`(见 [package.json](<package.json>))
|
|
10
10
|
|
package/adapter.js
CHANGED
|
@@ -412,6 +412,63 @@ function routeCeilingFor(requestModel, longDecode = true) {
|
|
|
412
412
|
: (longDecode === false ? MAX_SINGLE_CALL_TOKENS : MAX_LONG_DECODE_TOKENS))
|
|
413
413
|
}
|
|
414
414
|
|
|
415
|
+
function isPlainObjectRecord(value) {
|
|
416
|
+
if (!value || typeof value !== 'object' || Array.isArray(value)) return false
|
|
417
|
+
const proto = Object.getPrototypeOf(value)
|
|
418
|
+
return proto === null || proto === Object.prototype
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
const EXTRA_BODY_STRIPPED_KEYS = [
|
|
422
|
+
'thinkingConfig',
|
|
423
|
+
'thinking_config',
|
|
424
|
+
'thinkingBudget',
|
|
425
|
+
'thinking_budget',
|
|
426
|
+
'thinkingLevel',
|
|
427
|
+
'thinking_level',
|
|
428
|
+
'reasoningEffort',
|
|
429
|
+
'reasoning_effort',
|
|
430
|
+
'includeThoughts',
|
|
431
|
+
'include_thoughts',
|
|
432
|
+
'temperature',
|
|
433
|
+
'topP',
|
|
434
|
+
'top_p',
|
|
435
|
+
'topK',
|
|
436
|
+
'top_k',
|
|
437
|
+
'candidateCount',
|
|
438
|
+
'candidate_count',
|
|
439
|
+
'frequencyPenalty',
|
|
440
|
+
'frequency_penalty',
|
|
441
|
+
'presencePenalty',
|
|
442
|
+
'presence_penalty',
|
|
443
|
+
]
|
|
444
|
+
|
|
445
|
+
function sanitizeGemini4ExtraBody(extraBody, stripExplicitCache) {
|
|
446
|
+
if (extraBody === undefined) return extraBody
|
|
447
|
+
if (!isPlainObjectRecord(extraBody)) {
|
|
448
|
+
throw new LlmError('Gemini 4 httpOptions.extraBody must be a plain object.', 'INVALID_REQUEST')
|
|
449
|
+
}
|
|
450
|
+
const cleanExtraBody = { ...extraBody }
|
|
451
|
+
for (const key of EXTRA_BODY_STRIPPED_KEYS) delete cleanExtraBody[key]
|
|
452
|
+
if (stripExplicitCache) {
|
|
453
|
+
delete cleanExtraBody.cachedContent
|
|
454
|
+
delete cleanExtraBody.cached_content
|
|
455
|
+
}
|
|
456
|
+
for (const cfgKey of ['generationConfig', 'generation_config']) {
|
|
457
|
+
if (!Object.hasOwn(cleanExtraBody, cfgKey) || cleanExtraBody[cfgKey] === undefined) continue
|
|
458
|
+
if (!isPlainObjectRecord(cleanExtraBody[cfgKey])) {
|
|
459
|
+
throw new LlmError(`Gemini 4 httpOptions.extraBody.${cfgKey} must be a plain object.`, 'INVALID_REQUEST')
|
|
460
|
+
}
|
|
461
|
+
const sub = { ...cleanExtraBody[cfgKey] }
|
|
462
|
+
for (const key of EXTRA_BODY_STRIPPED_KEYS) delete sub[key]
|
|
463
|
+
if (stripExplicitCache) {
|
|
464
|
+
delete sub.cachedContent
|
|
465
|
+
delete sub.cached_content
|
|
466
|
+
}
|
|
467
|
+
cleanExtraBody[cfgKey] = sub
|
|
468
|
+
}
|
|
469
|
+
return cleanExtraBody
|
|
470
|
+
}
|
|
471
|
+
|
|
415
472
|
function assertOutboundMaxOutputTokens(body, cleanConfig, extraBody, ceiling) {
|
|
416
473
|
const locations = [
|
|
417
474
|
cleanConfig?.maxOutputTokens,
|
|
@@ -482,7 +539,7 @@ export function gemini4StreamSimple(
|
|
|
482
539
|
assertGemini4MaxTokens(options, requestModel, longDecode)
|
|
483
540
|
const routeCeiling = routeCeilingFor(requestModel, longDecode)
|
|
484
541
|
const outboundCeiling = longDecode === false ? Math.min(routeCeiling, MAX_SINGLE_CALL_TOKENS) : routeCeiling
|
|
485
|
-
const requestedMaxTokens = options.maxTokens
|
|
542
|
+
const requestedMaxTokens = options.maxTokens === undefined ? requestModel.maxTokens : options.maxTokens
|
|
486
543
|
if (requestedMaxTokens !== undefined && (!Number.isSafeInteger(requestedMaxTokens) || requestedMaxTokens < 1 || requestedMaxTokens > MAX_LONG_DECODE_TOKENS)) {
|
|
487
544
|
throw new LlmError('Invalid Gemini 4 maxTokens budget.', 'INVALID_REQUEST')
|
|
488
545
|
}
|
|
@@ -527,7 +584,9 @@ export function gemini4StreamSimple(
|
|
|
527
584
|
delete body.cachedContent
|
|
528
585
|
delete body.cached_content
|
|
529
586
|
}
|
|
530
|
-
|
|
587
|
+
delete body.reasoningEffort
|
|
588
|
+
delete body.reasoning_effort
|
|
589
|
+
const { temperature: _t, topP: _tp, topK: _tk, candidateCount: _cc, frequencyPenalty: _fp, presencePenalty: _pp, reasoningEffort: _reBody, reasoning_effort: _reSnake, ...cleanConfig } = body.config
|
|
531
590
|
if (supportsXhigh) {
|
|
532
591
|
delete cleanConfig.cachedContent
|
|
533
592
|
delete cleanConfig.cached_content
|
|
@@ -537,32 +596,21 @@ export function gemini4StreamSimple(
|
|
|
537
596
|
? cleanConfig.httpOptions
|
|
538
597
|
: {}
|
|
539
598
|
const sanitizedHttpOptions = { ...prevHttpOptions }
|
|
540
|
-
if (
|
|
541
|
-
supportsXhigh
|
|
542
|
-
prevHttpOptions.extraBody &&
|
|
543
|
-
typeof prevHttpOptions.extraBody === 'object' &&
|
|
544
|
-
!Array.isArray(prevHttpOptions.extraBody)
|
|
545
|
-
) {
|
|
546
|
-
const cleanExtraBody = { ...prevHttpOptions.extraBody }
|
|
547
|
-
delete cleanExtraBody.cachedContent
|
|
548
|
-
delete cleanExtraBody.cached_content
|
|
549
|
-
for (const cfgKey of ['generationConfig', 'generation_config']) {
|
|
550
|
-
if (cleanExtraBody[cfgKey] && typeof cleanExtraBody[cfgKey] === 'object' && !Array.isArray(cleanExtraBody[cfgKey])) {
|
|
551
|
-
const sub = { ...cleanExtraBody[cfgKey] }
|
|
552
|
-
delete sub.cachedContent
|
|
553
|
-
delete sub.cached_content
|
|
554
|
-
cleanExtraBody[cfgKey] = sub
|
|
555
|
-
}
|
|
556
|
-
}
|
|
557
|
-
sanitizedHttpOptions.extraBody = cleanExtraBody
|
|
599
|
+
if (Object.hasOwn(prevHttpOptions, 'extraBody') && prevHttpOptions.extraBody !== undefined) {
|
|
600
|
+
sanitizedHttpOptions.extraBody = sanitizeGemini4ExtraBody(prevHttpOptions.extraBody, supportsXhigh)
|
|
558
601
|
}
|
|
559
602
|
assertOutboundMaxOutputTokens(body, cleanConfig, sanitizedHttpOptions.extraBody, outboundCeiling)
|
|
603
|
+
const resolvedPayloadMax = cleanConfig.maxOutputTokens !== undefined
|
|
604
|
+
? cleanConfig.maxOutputTokens
|
|
605
|
+
: (cleanConfig.max_output_tokens !== undefined ? cleanConfig.max_output_tokens : (effectiveMaxTokens ?? outboundCeiling))
|
|
606
|
+
delete cleanConfig.max_output_tokens
|
|
560
607
|
const toolMode = shouldFallbackToAutoToolMode(retryKey) ? 'AUTO' : 'VALIDATED'
|
|
561
608
|
return {
|
|
562
609
|
...body,
|
|
563
610
|
model: upstreamModelId,
|
|
564
611
|
config: {
|
|
565
612
|
...cleanConfig,
|
|
613
|
+
maxOutputTokens: resolvedPayloadMax,
|
|
566
614
|
...(cleanConfig.tools?.some(tool => tool.functionDeclarations?.length) ? {
|
|
567
615
|
toolConfig: {
|
|
568
616
|
...cleanConfig.toolConfig,
|
|
@@ -814,9 +862,25 @@ export function argonProvider(nativeVertex, models, defaultLevel = undefined, na
|
|
|
814
862
|
getModels: () => [...modelMap.values()],
|
|
815
863
|
streamSimple(requestModel, context, options = {}) {
|
|
816
864
|
const configured = modelMap.get(requestModel?.id)
|
|
817
|
-
if (!configured || requestModel
|
|
865
|
+
if (!configured || requestModel?.provider !== PROVIDER) {
|
|
818
866
|
throw new LlmError('Gemini 4 Adapter only serves configured Gemini 4 routes.', 'UNSUPPORTED_OPTION')
|
|
819
867
|
}
|
|
868
|
+
if (requestModel.api !== undefined && requestModel.api !== configured.api) {
|
|
869
|
+
throw new LlmError('Gemini 4 Adapter only serves google-vertex or google-generative-ai.', 'UNSUPPORTED_OPTION')
|
|
870
|
+
}
|
|
871
|
+
const effectiveModel = {
|
|
872
|
+
...configured,
|
|
873
|
+
...requestModel,
|
|
874
|
+
id: configured.id,
|
|
875
|
+
provider: PROVIDER,
|
|
876
|
+
api: configured.api,
|
|
877
|
+
baseUrl: configured.baseUrl,
|
|
878
|
+
contextWindow: configured.contextWindow,
|
|
879
|
+
maxTokens: configured.maxTokens,
|
|
880
|
+
thinkingLevelMap: configured.thinkingLevelMap,
|
|
881
|
+
[MAX_TOKENS_CEILING]: configured[MAX_TOKENS_CEILING] ?? (Number.isSafeInteger(configured.maxTokens) ? configured.maxTokens : undefined),
|
|
882
|
+
}
|
|
883
|
+
const requestedMaxTokens = options.maxTokens === undefined ? configured.maxTokens : options.maxTokens
|
|
820
884
|
const { env: rawEnv, apiKey: vertexApiKey, ...restOptions } = options
|
|
821
885
|
const cleanEnv = rawEnv ? { ...rawEnv } : undefined
|
|
822
886
|
if (cleanEnv) {
|
|
@@ -828,9 +892,9 @@ export function argonProvider(nativeVertex, models, defaultLevel = undefined, na
|
|
|
828
892
|
const policy = resolveServicePolicy(serviceConfig, 'google-generative-ai', 'generate-content')
|
|
829
893
|
return gemini4StreamSimple(
|
|
830
894
|
(m, c, o) => nativeGoogle.stream(m, c, o),
|
|
831
|
-
|
|
895
|
+
effectiveModel,
|
|
832
896
|
context,
|
|
833
|
-
{ ...restOptions, ...(cleanEnv ? { env: cleanEnv } : {}), ...(apiKey ? { apiKey } : {}), maxTokens:
|
|
897
|
+
{ ...restOptions, ...(cleanEnv ? { env: cleanEnv } : {}), ...(apiKey ? { apiKey } : {}), maxTokens: requestedMaxTokens },
|
|
834
898
|
defaultLevel,
|
|
835
899
|
officialUpstreamModel(configured.id),
|
|
836
900
|
longDecode,
|
|
@@ -839,14 +903,14 @@ export function argonProvider(nativeVertex, models, defaultLevel = undefined, na
|
|
|
839
903
|
{ responseHub, retainRawResponses: serviceConfig.retainRawResponses }, structuredOutput,
|
|
840
904
|
)
|
|
841
905
|
}
|
|
842
|
-
if (
|
|
906
|
+
if (effectiveModel.api !== 'google-vertex') {
|
|
843
907
|
throw new LlmError('Gemini 4 Adapter only serves google-vertex or google-generative-ai.', 'UNSUPPORTED_OPTION')
|
|
844
908
|
}
|
|
845
909
|
return gemini4StreamSimple(
|
|
846
910
|
(m, c, o) => nativeVertex.stream(m, c, o),
|
|
847
|
-
|
|
911
|
+
effectiveModel,
|
|
848
912
|
context,
|
|
849
|
-
{ ...restOptions, ...(cleanEnv ? { env: cleanEnv } : {}), ...(vertexApiKey ? { apiKey: vertexApiKey } : {}), maxTokens:
|
|
913
|
+
{ ...restOptions, ...(cleanEnv ? { env: cleanEnv } : {}), ...(vertexApiKey ? { apiKey: vertexApiKey } : {}), maxTokens: requestedMaxTokens },
|
|
850
914
|
defaultLevel,
|
|
851
915
|
officialUpstreamModel(configured.id),
|
|
852
916
|
longDecode,
|
package/google-signatures.js
CHANGED
|
@@ -115,7 +115,7 @@ export function createGoogleSignatureBridge(context, model) {
|
|
|
115
115
|
const historyDigest = history.digest('hex')
|
|
116
116
|
const content = [], pending = [], standalone = new Map(), usedToolIds = new Set()
|
|
117
117
|
const partial = { role: 'assistant', api: model.api, provider: model.provider, model: model.id, content }
|
|
118
|
-
let current, seen = false, bytes = 0
|
|
118
|
+
let current, currentFromThisChunk = false, seen = false, bytes = 0
|
|
119
119
|
const emit = event => {
|
|
120
120
|
if (pending.length >= 32768) throw failure('Google response exceeded the bounded pending event count.')
|
|
121
121
|
pending.push({ ...event, partial })
|
|
@@ -136,6 +136,7 @@ export function createGoogleSignatureBridge(context, model) {
|
|
|
136
136
|
...(sig ? { contentSignature: sig } : {}),
|
|
137
137
|
})
|
|
138
138
|
current = undefined
|
|
139
|
+
currentFromThisChunk = false
|
|
139
140
|
}
|
|
140
141
|
const finishMessage = message => {
|
|
141
142
|
close()
|
|
@@ -159,6 +160,7 @@ export function createGoogleSignatureBridge(context, model) {
|
|
|
159
160
|
},
|
|
160
161
|
observe(chunk) {
|
|
161
162
|
seen = true
|
|
163
|
+
currentFromThisChunk = false
|
|
162
164
|
for (const part of chunk.candidates?.[0]?.content?.parts ?? []) {
|
|
163
165
|
bytes += Buffer.byteLength(JSON.stringify(part))
|
|
164
166
|
if (bytes > 64 * 1024 * 1024) throw failure('Google response exceeded the bounded signature replay buffer.')
|
|
@@ -178,9 +180,12 @@ export function createGoogleSignatureBridge(context, model) {
|
|
|
178
180
|
if (part.text !== undefined) {
|
|
179
181
|
const type = part.thought === true ? 'thinking' : 'text'
|
|
180
182
|
const sigKey = type === 'text' ? 'textSignature' : 'thinkingSignature'
|
|
183
|
+
const sameChunkSigBoundary = currentFromThisChunk && (Boolean(current?.[sigKey]) || Boolean(sig))
|
|
181
184
|
const splitSigned = type === 'text'
|
|
182
|
-
? (Boolean(current?.textSignature) || (Boolean(sig) && part.text === ''))
|
|
183
|
-
: (
|
|
185
|
+
? (Boolean(current?.textSignature) || sameChunkSigBoundary || (Boolean(sig) && part.text === ''))
|
|
186
|
+
: (sameChunkSigBoundary ||
|
|
187
|
+
(Boolean(sig) && (Boolean(current?.thinkingSignature) || part.text === '')) ||
|
|
188
|
+
(Boolean(current?.thinkingSignature) && current.thinking === ''))
|
|
184
189
|
if (!current || current.type !== type || splitSigned) {
|
|
185
190
|
close(); current = type === 'text' ? { type, text: '' } : { type, thinking: '' }
|
|
186
191
|
const index = start(current)
|
|
@@ -188,6 +193,7 @@ export function createGoogleSignatureBridge(context, model) {
|
|
|
188
193
|
}
|
|
189
194
|
const key = type === 'text' ? 'text' : 'thinking'
|
|
190
195
|
current[key] += part.text
|
|
196
|
+
currentFromThisChunk = true
|
|
191
197
|
if (sig) current[sigKey] = sig
|
|
192
198
|
emit({ type: type === 'text' ? 'text_delta' : 'thinking_delta', contentIndex: content.length - 1, delta: part.text })
|
|
193
199
|
}
|
package/index.js
CHANGED
|
@@ -119,11 +119,24 @@ export function apply(ctx, config) {
|
|
|
119
119
|
const recordDiagnostic = record => hub.record(record)
|
|
120
120
|
const adapter = createArgonAdapter(ctx, () => config, undefined, undefined, recordDiagnostic, taskHub, responseHub)
|
|
121
121
|
const unpatchPiAi = installGemini4PiAiPatch(recordDiagnostic, () => config, responseHub)
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
122
|
+
let registration
|
|
123
|
+
try {
|
|
124
|
+
registration = ctx.llm.registerAdapter([PROVIDER], adapter)
|
|
125
|
+
ctx.effect(() => () => {
|
|
126
|
+
try {
|
|
127
|
+
registration?.()
|
|
128
|
+
} finally {
|
|
129
|
+
unpatchPiAi()
|
|
130
|
+
}
|
|
131
|
+
})
|
|
132
|
+
} catch (error) {
|
|
133
|
+
try {
|
|
134
|
+
registration?.()
|
|
135
|
+
} finally {
|
|
136
|
+
unpatchPiAi()
|
|
137
|
+
}
|
|
138
|
+
throw error
|
|
139
|
+
}
|
|
127
140
|
if (typeof ctx.on === 'function') {
|
|
128
141
|
ctx.on('llm/stream', (options, next) => associations.stream(options, next))
|
|
129
142
|
ctx.on('agent/assistant-stream', payload => associations.frame(payload))
|
package/interaction-adapter.js
CHANGED
|
@@ -10,9 +10,10 @@ import { isGoogleApiModel, officialUpstreamModel } from './adapter.js'
|
|
|
10
10
|
|
|
11
11
|
const terminalStates = new Set(['completed', 'requires_action', 'incomplete', 'failed', 'cancelled', 'budget_exceeded'])
|
|
12
12
|
export function assertInteractionOptions(options, cfg, route) {
|
|
13
|
-
const
|
|
13
|
+
const requestedMax = options.maxTokens === undefined ? cfg.maxTokens : options.maxTokens
|
|
14
14
|
const maxCeiling = cfg.explicitMaxTokensCap ?? cfg.maxTokens
|
|
15
|
-
if (!Number.isSafeInteger(
|
|
15
|
+
if (!Number.isSafeInteger(requestedMax) || requestedMax <= 0 || requestedMax > maxCeiling) throw new Error('Interactions output budget must be a positive integer within the configured effective cap.')
|
|
16
|
+
const max = cfg.longDecode === false ? Math.min(requestedMax, 65536) : requestedMax
|
|
16
17
|
const defaultReasoning = cfg?.hasExplicitReasoning === false ? defaultReasoningForModel(options.model) : cfg.reasoning
|
|
17
18
|
const resolvedReasoning = resolveGemini4ReasoningLevel(options, options.model, defaultReasoning)
|
|
18
19
|
if (!resolvedReasoning.ok) {
|
|
@@ -164,7 +165,7 @@ export function createInteractionsHandler({ ctx, GoogleGenAI, resolveSecret, get
|
|
|
164
165
|
return block
|
|
165
166
|
}) }))
|
|
166
167
|
const { streamInteractions } = await import('./interactions.js')
|
|
167
|
-
for await (const chunk of streamInteractions({ ...options, messages, signal }, { route, upstreamModel, ...controls, serviceTier: route === 'google-generative-ai' ? servicePolicy.tier : undefined, background: cfg.interactionsBackground, store: cfg.allowInteractionStorage, transport, resolveImage, structuredOutput, onEvent: observed, onReconnectDelay: ms => { pendingBackoffMs = ms }, onTerminal: () => { complete = true }, onExit: reason => { exitReason = reason } })) {
|
|
168
|
+
for await (const chunk of streamInteractions({ ...options, maxTokens: controls.maxTokens, messages, signal }, { route, upstreamModel, ...controls, longDecode: cfg.longDecode, serviceTier: route === 'google-generative-ai' ? servicePolicy.tier : undefined, background: cfg.interactionsBackground, store: cfg.allowInteractionStorage, transport, resolveImage, structuredOutput, onEvent: observed, onReconnectDelay: ms => { pendingBackoffMs = ms }, onTerminal: () => { complete = true }, onExit: reason => { exitReason = reason } })) {
|
|
168
169
|
if (chunk.type === 'usage') {
|
|
169
170
|
recordUsage()
|
|
170
171
|
// Only an observed first-hop input watermark can be normalized for the
|
package/interactions-input.js
CHANGED
|
@@ -128,7 +128,9 @@ function findUnclaimedToolResultIndex(messages, startIndex, toolCallId, claimedT
|
|
|
128
128
|
// Completed foreign-protocol tool rounds become a textual transcript, never
|
|
129
129
|
// forged function calls or fake thought signatures.
|
|
130
130
|
export async function buildInteractionRequest(options, settings = {}) {
|
|
131
|
-
const
|
|
131
|
+
const rawMax = options.maxTokens !== undefined
|
|
132
|
+
? options.maxTokens
|
|
133
|
+
: (settings.maxTokens !== undefined ? settings.maxTokens : 65536)
|
|
132
134
|
const hasExplicitUpstream = !isOmittedModel(settings.upstreamModel)
|
|
133
135
|
const hasExplicitOption = !isOmittedModel(options.model)
|
|
134
136
|
const resolvedUpstream = hasExplicitUpstream ? resolveOfficialGemini4Model(settings.upstreamModel) : null
|
|
@@ -145,7 +147,8 @@ export async function buildInteractionRequest(options, settings = {}) {
|
|
|
145
147
|
const upstreamModel = resolvedUpstream?.upstreamModel ?? resolvedOption?.upstreamModel ?? 'gemini-4-argon'
|
|
146
148
|
const resolvedReasoning = resolveGemini4ReasoningLevel(options, upstreamModel, settings.reasoning ?? defaultReasoningForModel(upstreamModel))
|
|
147
149
|
for (const flag of [settings.background, settings.store]) if (flag !== undefined && typeof flag !== 'boolean') throw new Error('Interactions background and storage consent must be booleans.')
|
|
148
|
-
if (!Number.isSafeInteger(
|
|
150
|
+
if (!Number.isSafeInteger(rawMax) || rawMax<1 || rawMax>1048576) throw new Error('Invalid Interactions output token budget.')
|
|
151
|
+
const max = settings.longDecode === false ? Math.min(rawMax, 65536) : rawMax
|
|
149
152
|
if (!resolvedReasoning.ok) {
|
|
150
153
|
if (resolvedReasoning.errorType === 'conflict') {
|
|
151
154
|
throw new Error('Conflicting reasoning and reasoningEffort options in Interactions request.')
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-vertex-argon",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.5",
|
|
4
4
|
"description": "Gemini 4 Adapter for DSH: official Vertex AI & Gemini API channels (Argon, Carbon, Hydrogen & Neon), resilient long decode, explicit service tiers, and request diagnostics.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|