dsh-vertex-argon 1.6.2 → 1.6.3
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 +12 -0
- package/README.md +7 -5
- package/adapter.js +41 -8
- package/client.js +3 -3
- package/interaction-adapter.js +4 -2
- package/interactions-input.js +27 -14
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,18 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to `dsh-vertex-argon` are documented in this file.
|
|
4
4
|
|
|
5
|
+
## [1.6.3] - 2026-10-28
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
- **Gemini 3.8 Flash on the Antigravity Proxy (`adapter.js`, `interaction-adapter.js`, `client.js`)**:
|
|
9
|
+
- Added `PROXY_FLASH_MODEL = 'gemini-3.8-flash-proxy'` (`Gemini 3.8 Flash (Antigravity)`) next to `PROXY_MODEL`; both register only when `proxyEnabled || explicitRoutes.hasProxy`, share the proxy base URL and the dedicated `ANTIGRAVITY_API_KEY` / `proxyApiKey` credential, and never touch Google / Vertex credentials.
|
|
10
|
+
- Added `isProxyModel` / `proxyUpstreamBaseModel` / `resolveProxyUpstreamModel` as the single proxy-map; `gemini-3.8-flash-proxy` maps `low` / `medium` / `high` 1:1 to `gemini-3.8-flash-low` / `gemini-3.8-flash-medium` / `gemini-3.8-flash-high` across both GenerateContent and Interactions, while official Vertex AI and Gemini API routes keep `gemini-4-argon`.
|
|
11
|
+
- Inspector shows **Antigravity Proxy** for both proxy model IDs. The 16 volatile settings are unchanged.
|
|
12
|
+
|
|
13
|
+
### Fixed
|
|
14
|
+
- **Cross-Model GenerateContent History Downgrade (`interactions-input.js`, `adapter.js`)**:
|
|
15
|
+
- `generateContentHistory(options, model)` now also downgrades history when switching between `gemini-4-argon-proxy` and `gemini-3.8-flash-proxy` (or across providers) and the message carries `reasoning` / `tool-call` blocks: thought blocks are dropped, completed tool round-trips become explicit text, unfinished calls throw, and `replayState` is stripped. pi-ai no longer emits a signature-stripped native `functionCall` or an orphan `functionResponse` after a proxy-model switch, and old reasoning is no longer replayed as public prose. Same-model history keeps native signature replay; pure-text cross-model messages still fall through to the signature bridge.
|
|
16
|
+
|
|
5
17
|
## [1.6.2] - 2026-10-26
|
|
6
18
|
|
|
7
19
|
### Fixed
|
package/README.md
CHANGED
|
@@ -4,13 +4,13 @@
|
|
|
4
4
|
|
|
5
5
|
**为 [DeepSeek Harness](<https://github.com/deepseek-ai/deepseek-harness>) 提供 Vertex AI、Gemini API、Antigravity 三路由,以及 GenerateContent / Interactions 双协议接入。**
|
|
6
6
|
|
|
7
|
-
工程版本 **1.6.
|
|
7
|
+
工程版本 **1.6.3**;兼容 **DSH 0.2.1-rc.2 / 0.2.1-rc.3**,Node.js `^22.19.0 || >=24.0.0`。版本与依赖以 [package.json](<package.json>) 为准;历史变更见 [CHANGELOG.md](<CHANGELOG.md>)。本文说明本地工程,不代表已安装、已发布或已完成本轮云端实测。
|
|
8
8
|
|
|
9
9
|
[三路由与凭据](<#三路由与凭据>) · [完整配置](<#完整配置16-项>) · [流式恢复](<#generatecontent四项韧性机制>) · [Inspector](<#argon-inspectordebug-与-operations>) · [历史实测](<#历史实测奥德赛七号全年舰长日志>)
|
|
10
10
|
|
|
11
11
|
## 核心能力
|
|
12
12
|
|
|
13
|
-
-
|
|
13
|
+
- **独立代理模型**:Antigravity 路由下有 `gemini-4-argon-proxy` 与 `gemini-3.8-flash-proxy` 两个独立模型,共用独立地址与专属密钥,不覆盖 Gemini API 模型。
|
|
14
14
|
- **GenerateContent 长解码**:单跳输出上限 `65,536`,输出预算配置最高 `1,048,576`,所有尝试共用 32 跳上限;支持检查点恢复、阶段超时、安全首包重试和仅思考结束自愈。
|
|
15
15
|
- **Interactions 后台恢复与状态对账**:显式启用后台与存储后,用 `creating` 预写锁防止未知创建被自动重发,以 `last_event_id` 续读已知任务;兼容 `2026-05-20` 独立生命周期事件,并在同会话发起新提示词时自动以有界非流式探针对账历史任务(清理已 `failed` / `cancelled` / `404` 死锁,保留未回放终态句柄的同时放行新提示词)。
|
|
16
16
|
- **签名保真**:保留并回放仅含 `thoughtSignature` / `thought_signature` 的空 `Part`;思考档位为 `low` / `medium` / `high`,宿主传入 `max` 时收敛为 `high`。
|
|
@@ -25,8 +25,9 @@ Provider ID 保持 `google-vertex-argon`,模型位于 **Vertex Argon** 分组
|
|
|
25
25
|
| Vertex AI | `gemini-4-argon` | `google-vertex` | `vertexProtocol` / `vertexServiceTier` |
|
|
26
26
|
| Gemini Developer API | `gemini-4-argon-google` | `google-generative-ai` | `googleProtocol` / `googleServiceTier` |
|
|
27
27
|
| Antigravity Proxy | `gemini-4-argon-proxy` | `google-generative-ai` | 复用 `googleProtocol` / `googleServiceTier` |
|
|
28
|
+
| Antigravity Proxy | `gemini-3.8-flash-proxy` | `google-generative-ai` | 同上;与 Argon 共用代理地址与专属密钥 |
|
|
28
29
|
|
|
29
|
-
|
|
30
|
+
这里的“三路由”指三个连接目标、四个独立模型 ID,**并未新增第三种诊断 `route` 值**。Inspector 根据独立 `model` 显示 **Antigravity Proxy**。代理启用条件为 `proxyEnabled === true || explicitRoutes.hasProxy === true`;默认关闭,仅配置密钥不会自动开启。
|
|
30
31
|
|
|
31
32
|
### Vertex AI
|
|
32
33
|
|
|
@@ -46,7 +47,8 @@ Provider ID 保持 `google-vertex-argon`,模型位于 **Vertex Argon** 分组
|
|
|
46
47
|
- `proxyApiKey` 先去除首尾空白;有值时使用设置值,否则只读取 `ANTIGRAVITY_API_KEY`。
|
|
47
48
|
- **绝不回退到 Google/Vertex 密钥,也不把代理密钥送往 Google/Vertex。** 缺少专属密钥时应明确失败。
|
|
48
49
|
- 地址和密钥使用草稿输入,失焦或点击保存后提交,重置恢复默认值。填写的 Key 保存在插件配置中,密码框仅遮挡显示;也可留空并使用 DSH 凭据中的 `ANTIGRAVITY_API_KEY`,避免直接填写配置。设置实时更新时,模型列表缓存随之失效。
|
|
49
|
-
-
|
|
50
|
+
- 选中代理模型时,插件按推理档位(`low` / `medium` / `high`)把上游模型 ID 1:1 映射:`gemini-4-argon-proxy` → `gemini-4-argon-low`、`gemini-4-argon-medium`、`gemini-4-argon-high`;`gemini-3.8-flash-proxy` → `gemini-3.8-flash-low`、`gemini-3.8-flash-medium`、`gemini-3.8-flash-high`(官方 Vertex AI 与 Gemini API 路由保持 `gemini-4-argon`)。GenerateContent 与 Interactions 走同一份映射。代理沿用 Google 协议与服务层级配置;具体端点是否支持所选能力仍取决于代理实现,不是新增的云端验证结论。
|
|
51
|
+
- **两个代理模型之间切换**时,旧模型的 GenerateContent 工具历史会在出站前降级成文本记录、旧思考一并剔除;未完成的工具调用直接报错。只有与当前代理模型完全一致的历史才保留原生签名回放,避免底层按 provider/model 摘掉签名后仍发出裸 `functionCall` 或孤立 `functionResponse`。
|
|
50
52
|
|
|
51
53
|
## 完整配置:16 项
|
|
52
54
|
|
|
@@ -148,7 +150,7 @@ billedPromptTokens, billedCachedTokens, billedTotalTokens
|
|
|
148
150
|
|
|
149
151
|
## 历史实测:奥德赛七号全年舰长日志
|
|
150
152
|
|
|
151
|
-
> 以下是 **v1.5.0 历史云端实测**,保留用于说明长解码已有依据;**不是 v1.6.
|
|
153
|
+
> 以下是 **v1.5.0 历史云端实测**,保留用于说明长解码已有依据;**不是 v1.6.3 本轮新增 live 验证,也不能证明 Antigravity 或新增恢复分支已在云端验证**。本轮验证状态见 [验证账本](<docs/implementation/STATUS.md>)。
|
|
152
154
|
|
|
153
155
|
历史任务要求单回合连续输出 `DAY 001` 至 `DAY 365` 的全年日志,保持每日状态、每周维护、月末报告以及第 100/200/215/300/365 天的长期事件。原记录记载全年日志与状态台账完成;本文未重新运行或逐篇复核内容。
|
|
154
156
|
|
package/adapter.js
CHANGED
|
@@ -24,6 +24,26 @@ export const NATIVE_PROVIDER = 'google-vertex'
|
|
|
24
24
|
export const MODEL = 'gemini-4-argon'
|
|
25
25
|
export const GOOGLE_API_MODEL = 'gemini-4-argon-google'
|
|
26
26
|
export const PROXY_MODEL = 'gemini-4-argon-proxy'
|
|
27
|
+
/** Antigravity 反代暴露的 Gemini 3.8 Flash;与 Argon 共用同一份反代地址与专属密钥。 */
|
|
28
|
+
export const PROXY_FLASH_MODEL = 'gemini-3.8-flash-proxy'
|
|
29
|
+
export const FLASH_UPSTREAM_MODEL = 'gemini-3.8-flash'
|
|
30
|
+
export const PROXY_MODELS = Object.freeze([PROXY_MODEL, PROXY_FLASH_MODEL])
|
|
31
|
+
export const PROXY_MODEL_NAMES = Object.freeze({
|
|
32
|
+
[PROXY_MODEL]: 'Gemini 4 Argon (Antigravity)',
|
|
33
|
+
[PROXY_FLASH_MODEL]: 'Gemini 3.8 Flash (Antigravity)',
|
|
34
|
+
})
|
|
35
|
+
/** 反代模型判定:Argon 与 Flash 都走同一条 Antigravity 通道。 */
|
|
36
|
+
export function isProxyModel(modelId) {
|
|
37
|
+
return typeof modelId === 'string' && PROXY_MODELS.includes(modelId)
|
|
38
|
+
}
|
|
39
|
+
/** 反代模型对应的上游基础 ID;档位后缀由 resolveProxyUpstreamModel 追加。 */
|
|
40
|
+
export function proxyUpstreamBaseModel(modelId) {
|
|
41
|
+
return modelId === PROXY_FLASH_MODEL ? FLASH_UPSTREAM_MODEL : MODEL
|
|
42
|
+
}
|
|
43
|
+
/** 反代上游模型 ID:`<基础 ID>-<low|medium|high>`,与反代暴露的档位模型一一对应。 */
|
|
44
|
+
export function resolveProxyUpstreamModel(modelId, level) {
|
|
45
|
+
return `${proxyUpstreamBaseModel(modelId)}-${level}`
|
|
46
|
+
}
|
|
27
47
|
export const PROXY_API_KEY_ENV = 'ANTIGRAVITY_API_KEY'
|
|
28
48
|
export const DEFAULT_PROXY_BASE_URL = 'http://127.0.0.1:8045/v1beta'
|
|
29
49
|
export const LEVELS = ['low', 'medium', 'high']
|
|
@@ -200,7 +220,7 @@ export function gemini4StreamSimple(
|
|
|
200
220
|
const mapped = requestModel?.thinkingLevelMap?.[rawLevel] ?? rawLevel
|
|
201
221
|
const level = typeof mapped === 'string' ? mapped.toLowerCase() : fallback
|
|
202
222
|
if (!LEVELS.includes(level)) throw new LlmError('Gemini 4 Argon requires low, medium or high.', 'UNSUPPORTED_REASONING_EFFORT')
|
|
203
|
-
const resolvedUpstreamModelId = requestModel?.id
|
|
223
|
+
const resolvedUpstreamModelId = isProxyModel(requestModel?.id) ? resolveProxyUpstreamModel(requestModel.id, level) : upstreamModelId
|
|
204
224
|
const { reasoning, thinking, thinkingBudgets, temperature, onPayload: prior, onProviderStreamEvent: priorEvent, ...rest } = options
|
|
205
225
|
const requestedMaxTokens = options.maxTokens ?? requestModel.maxTokens
|
|
206
226
|
const effectiveMaxTokens =
|
|
@@ -409,7 +429,7 @@ export function argonProvider(nativeVertex, models, defaultLevel = 'medium', nat
|
|
|
409
429
|
delete cleanEnv.__ANTIGRAVITY_API_KEY__
|
|
410
430
|
}
|
|
411
431
|
if (configured.api === 'google-generative-ai') {
|
|
412
|
-
const proxy = configured.id
|
|
432
|
+
const proxy = isProxyModel(configured.id)
|
|
413
433
|
const apiKey = proxy ? rawEnv?.__ANTIGRAVITY_API_KEY__ : rawEnv?.__GOOGLE_API_KEY__
|
|
414
434
|
if (!apiKey) throw new LlmError(proxy ? 'Antigravity proxy requires its dedicated API key.' : 'Gemini API credentials are not configured.', 'MISSING_CREDENTIAL')
|
|
415
435
|
return gemini4StreamSimple(
|
|
@@ -418,7 +438,7 @@ export function argonProvider(nativeVertex, models, defaultLevel = 'medium', nat
|
|
|
418
438
|
context,
|
|
419
439
|
{ ...restOptions, ...(cleanEnv ? { env: cleanEnv } : {}), ...(apiKey ? { apiKey } : {}), maxTokens: options.maxTokens ?? configured.maxTokens },
|
|
420
440
|
defaultLevel,
|
|
421
|
-
MODEL,
|
|
441
|
+
proxy ? proxyUpstreamBaseModel(configured.id) : MODEL,
|
|
422
442
|
longDecode,
|
|
423
443
|
recordDiagnostic,
|
|
424
444
|
resolveServicePolicy(serviceConfig, 'google-generative-ai', 'generate-content'),
|
|
@@ -457,7 +477,7 @@ export class ArgonAdapter extends LlmAdapter {
|
|
|
457
477
|
imageRequestPricing(provider, model) { return this.inner.imageRequestPricing?.(provider, model) }
|
|
458
478
|
imageRequestTarget(provider, model, image) {
|
|
459
479
|
const cfg = this.configSnapshot?.()
|
|
460
|
-
const protocol = (model === GOOGLE_API_MODEL || model
|
|
480
|
+
const protocol = (model === GOOGLE_API_MODEL || isProxyModel(model)) ? cfg?.googleProtocol : cfg?.vertexProtocol
|
|
461
481
|
if (provider === PROVIDER && protocol === 'interactions' && this.interactionHandler) return interactionImageRequestTarget(image)
|
|
462
482
|
return this.inner.imageRequestTarget(provider, model, image)
|
|
463
483
|
}
|
|
@@ -468,13 +488,13 @@ export class ArgonAdapter extends LlmAdapter {
|
|
|
468
488
|
resolveModel(provider, model, signal) { return this.inner.resolveModel(provider, model, signal) }
|
|
469
489
|
async prepareCall(provider, model, signal) {
|
|
470
490
|
const cfg = this.configSnapshot?.()
|
|
471
|
-
if (provider === PROVIDER && cfg) resolveServicePolicy(cfg, (model === GOOGLE_API_MODEL || model
|
|
491
|
+
if (provider === PROVIDER && cfg) resolveServicePolicy(cfg, (model === GOOGLE_API_MODEL || isProxyModel(model)) ? 'google-generative-ai' : 'google-vertex', (model === GOOGLE_API_MODEL || isProxyModel(model)) ? cfg.googleProtocol : cfg.vertexProtocol)
|
|
472
492
|
const prepared = await this.inner.prepareCall(provider, model, signal)
|
|
473
|
-
const protocol = (model === GOOGLE_API_MODEL || model
|
|
493
|
+
const protocol = (model === GOOGLE_API_MODEL || isProxyModel(model)) ? cfg?.googleProtocol : cfg?.vertexProtocol
|
|
474
494
|
if (provider === PROVIDER && protocol === 'interactions' && this.interactionHandler) {
|
|
475
495
|
return { model: prepared.model, stream: options => this.interactionHandler(options, cfg) }
|
|
476
496
|
}
|
|
477
|
-
return { ...prepared, stream: options => prepared.stream(generateContentHistory(options)) }
|
|
497
|
+
return { ...prepared, stream: options => prepared.stream(generateContentHistory(options, model)) }
|
|
478
498
|
}
|
|
479
499
|
async *stream(options) {
|
|
480
500
|
const prepared = await this.prepareCall(options.provider, options.model, options.signal)
|
|
@@ -606,7 +626,20 @@ export function createArgonAdapter(ctx, configInput, nativeVertex = googleVertex
|
|
|
606
626
|
if (cfg.proxyEnabled || detected.hasProxy) {
|
|
607
627
|
models.push({
|
|
608
628
|
id: PROXY_MODEL,
|
|
609
|
-
name:
|
|
629
|
+
name: PROXY_MODEL_NAMES[PROXY_MODEL],
|
|
630
|
+
provider: PROVIDER,
|
|
631
|
+
api: 'google-generative-ai',
|
|
632
|
+
baseUrl: cfg.proxyBaseUrl,
|
|
633
|
+
reasoning: true,
|
|
634
|
+
input: ['text', 'image'],
|
|
635
|
+
contextWindow: cfg.contextWindow,
|
|
636
|
+
maxTokens: cfg.maxTokens,
|
|
637
|
+
thinkingLevelMap: { ...DEFAULT_THINKING_MAP },
|
|
638
|
+
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
|
|
639
|
+
})
|
|
640
|
+
models.push({
|
|
641
|
+
id: PROXY_FLASH_MODEL,
|
|
642
|
+
name: PROXY_MODEL_NAMES[PROXY_FLASH_MODEL],
|
|
610
643
|
provider: PROVIDER,
|
|
611
644
|
api: 'google-generative-ai',
|
|
612
645
|
baseUrl: cfg.proxyBaseUrl,
|
package/client.js
CHANGED
|
@@ -531,7 +531,7 @@ window.__ModuleLoader__.load({
|
|
|
531
531
|
inspectorTimeline: '请求列表', inspectorThinking: '思考等级', inspectorFailure: '失败类别', inspectorDuration: '耗时',
|
|
532
532
|
inspectorAssociation: '关联状态', inspectorTokenWatermark: 'Token 水位', inspectorEyebrow: 'ARGON / DEBUG',
|
|
533
533
|
proxyTitle: 'Antigravity 反代通道 (Antigravity Proxy)', proxyEnabled: '启用独立代理模型', proxyBaseUrl: '代理 Base URL', proxyApiKey: '代理 API Key',
|
|
534
|
-
proxyHint: '独立模型 gemini-4-argon-proxy;共用 Gemini API 的协议与服务等级。密钥只使用此处配置或 ANTIGRAVITY_API_KEY,不复用 Google / Vertex 凭据。',
|
|
534
|
+
proxyHint: '独立模型 gemini-4-argon-proxy 与 gemini-3.8-flash-proxy;共用 Gemini API 的协议与服务等级。密钥只使用此处配置或 ANTIGRAVITY_API_KEY,不复用 Google / Vertex 凭据。',
|
|
535
535
|
proxySaveHint: '开关点击即保存;地址和密钥在离开输入框或点击对应保存按钮时保存,不逐字提交。恢复默认值会关闭代理、恢复默认地址并清空专属密钥。',
|
|
536
536
|
proxySaveBaseUrl: '保存代理地址', proxySaveApiKey: '保存代理密钥',
|
|
537
537
|
})
|
|
@@ -539,7 +539,7 @@ window.__ModuleLoader__.load({
|
|
|
539
539
|
inspectorTimeline: 'Requests', inspectorThinking: 'Thinking level', inspectorFailure: 'Failure category', inspectorDuration: 'Duration',
|
|
540
540
|
inspectorAssociation: 'Association status', inspectorTokenWatermark: 'Token watermark', inspectorEyebrow: 'ARGON / DEBUG',
|
|
541
541
|
proxyTitle: 'Antigravity Proxy', proxyEnabled: 'Enable the independent proxy model', proxyBaseUrl: 'Proxy Base URL', proxyApiKey: 'Proxy API Key',
|
|
542
|
-
proxyHint: 'Independent gemini-4-argon-proxy
|
|
542
|
+
proxyHint: 'Independent gemini-4-argon-proxy and gemini-3.8-flash-proxy models; they share Gemini API protocol and service tier settings. Uses only this key or ANTIGRAVITY_API_KEY, never Google / Vertex credentials.',
|
|
543
543
|
proxySaveHint: 'The switch saves immediately. URL and key save on blur or with their Save buttons, never on each keystroke. Reset disables the proxy, restores the default URL and clears its dedicated key.',
|
|
544
544
|
proxySaveBaseUrl: 'Save proxy URL', proxySaveApiKey: 'Save proxy key',
|
|
545
545
|
})
|
|
@@ -1047,7 +1047,7 @@ window.__ModuleLoader__.load({
|
|
|
1047
1047
|
navigate()
|
|
1048
1048
|
}
|
|
1049
1049
|
const association = row => t(row?.association === 'linked' ? 'inspectorAssociated' : row?.association === 'unverified' ? 'inspectorUnverified' : 'inspectorUnassociated')
|
|
1050
|
-
const routeName = record => record?.model === 'gemini-4-argon-proxy' || record?.route === 'antigravity-proxy' ? 'Antigravity Proxy' : record?.route === 'google-generative-ai' ? 'Gemini API' : record?.route === 'google-vertex' ? 'Vertex AI' : (record?.route ?? t('inspectorUnknown'))
|
|
1050
|
+
const routeName = record => record?.model === 'gemini-4-argon-proxy' || record?.model === 'gemini-3.8-flash-proxy' || record?.route === 'antigravity-proxy' ? 'Antigravity Proxy' : record?.route === 'google-generative-ai' ? 'Gemini API' : record?.route === 'google-vertex' ? 'Vertex AI' : (record?.route ?? t('inspectorUnknown'))
|
|
1051
1051
|
const outcome = value => t(({ done: 'diagOutcome_done', 'tool-calls': 'diagOutcome_tool', 'max-tokens': 'diagOutcome_max', error: 'diagOutcome_error', aborted: 'diagOutcome_aborted' })[value] ?? 'diagOutcome_incomplete')
|
|
1052
1052
|
const tone = value => value === 'done' || value === 'tool-calls' ? 'success' : value === 'error' ? 'error' : value === 'max-tokens' ? 'warn' : 'idle'
|
|
1053
1053
|
const activeDetail = detail?.status === 'available' ? detail : null
|
package/interaction-adapter.js
CHANGED
|
@@ -4,6 +4,8 @@ import { durableInteractionTransport } from './interaction-state.js'
|
|
|
4
4
|
import { createArgonDiagnosticTracker } from './diagnostics.js'
|
|
5
5
|
import { interactionExitReason } from './interaction-lifecycle.js'
|
|
6
6
|
import { resolveServicePolicy } from './service-level.js'
|
|
7
|
+
// 循环导入:adapter.js 只在本模块的函数被调用时才读取这些绑定,函数声明本身已提升。
|
|
8
|
+
import { isProxyModel, resolveProxyUpstreamModel } from './adapter.js'
|
|
7
9
|
|
|
8
10
|
const terminalStates = new Set(['completed', 'requires_action', 'incomplete', 'failed', 'cancelled', 'budget_exceeded'])
|
|
9
11
|
export function assertInteractionOptions(options, cfg, route) {
|
|
@@ -19,7 +21,7 @@ export function assertInteractionOptions(options, cfg, route) {
|
|
|
19
21
|
|
|
20
22
|
export function createInteractionsHandler({ ctx, GoogleGenAI, resolveSecret, getRoutes, taskHub, recordDiagnostic, responseHub, structuredOutput }) {
|
|
21
23
|
return async function* interactions(options, cfg) {
|
|
22
|
-
const proxy = options.model
|
|
24
|
+
const proxy = isProxyModel(options.model)
|
|
23
25
|
const route = proxy || options.model === 'gemini-4-argon-google' ? 'google-generative-ai' : 'google-vertex'
|
|
24
26
|
const requestController = new AbortController()
|
|
25
27
|
const signal = options.signal ? AbortSignal.any([options.signal, requestController.signal]) : requestController.signal
|
|
@@ -153,7 +155,7 @@ export function createInteractionsHandler({ ctx, GoogleGenAI, resolveSecret, get
|
|
|
153
155
|
return block
|
|
154
156
|
}) }))
|
|
155
157
|
const { streamInteractions } = await import('./interactions.js')
|
|
156
|
-
for await (const chunk of streamInteractions({ ...options, messages, signal }, { route, upstreamModel: proxy ?
|
|
158
|
+
for await (const chunk of streamInteractions({ ...options, messages, signal }, { route, upstreamModel: proxy ? resolveProxyUpstreamModel(options.model, controls.reasoning) : 'gemini-4-argon', ...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 } })) {
|
|
157
159
|
if (chunk.type === 'usage') {
|
|
158
160
|
recordUsage()
|
|
159
161
|
// Only an observed first-hop input watermark can be normalized for the
|
package/interactions-input.js
CHANGED
|
@@ -91,27 +91,40 @@ export async function buildInteractionRequest(options, settings) {
|
|
|
91
91
|
|
|
92
92
|
// Switching back to GenerateContent must not feed its SDK Interactions replay
|
|
93
93
|
// envelopes or unsigned function calls under the same DSH provider/model alias.
|
|
94
|
-
|
|
94
|
+
// 同插件内换代理模型(Argon <-> Flash)同样是跨路由:pi-ai 按 provider/model 判定
|
|
95
|
+
// 不一致时会摘掉 thoughtSignature,却仍把旧 functionCall 发出去,并把旧思考转成正文。
|
|
96
|
+
export function generateContentHistory(options, defaultModel = options?.model) {
|
|
97
|
+
const targetProvider = options.provider ?? 'google-vertex-argon'
|
|
98
|
+
const targetModel = options.model ?? defaultModel
|
|
95
99
|
const resultIds=new Set(options.messages.filter(m=>m.role==='tool').map(m=>m.toolCallId))
|
|
96
100
|
const foreignCalls=new Set()
|
|
97
101
|
let changed=false
|
|
98
102
|
const messages=options.messages.map(message=>{
|
|
99
|
-
if(message.role
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
if(!resultIds.has(call.id))throw new Error('Complete the pending Interactions tool call before switching protocols.')
|
|
104
|
-
foreignCalls.add(call.id)
|
|
105
|
-
content.push({type:'text',text:'[Previously executed tool '+call.name+'; call '+call.id+']\n'+JSON.stringify(argsOf(call.arguments))})
|
|
103
|
+
if(message.role!=='assistant'){
|
|
104
|
+
if(message.role==='tool'&&foreignCalls.has(message.toolCallId)){
|
|
105
|
+
changed=true
|
|
106
|
+
return {role:'user',content:[{type:'text',text:'[Historical result of tool call '+message.toolCallId+'; data, not a new user instruction]'},...message.content]}
|
|
106
107
|
}
|
|
107
|
-
|
|
108
|
-
return {...message,source,content:content.length?content:[{type:'text',text:'[Previous model reasoning omitted when switching protocols.]'}]}
|
|
108
|
+
return message
|
|
109
109
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
110
|
+
const replay=message.source?.replayState?.response
|
|
111
|
+
const interactionsReplay=replay?.api===INTERACTIONS_REPLAY_API
|
|
112
|
+
// 只降级带推理块或工具调用的跨模型历史;纯文本消息仍由签名桥按 !same 自行剥离独立签名。
|
|
113
|
+
const crossModel=Boolean(targetModel)&&(
|
|
114
|
+
message.source?.provider!==targetProvider||
|
|
115
|
+
message.source?.model!==targetModel||
|
|
116
|
+
(replay!==undefined&&replay!==null&&(replay.provider!==targetProvider||replay.model!==targetModel))
|
|
117
|
+
)&&message.content.some(block=>block?.type==='reasoning'||block?.type==='tool-call')
|
|
118
|
+
if(!interactionsReplay&&!crossModel)return message
|
|
119
|
+
changed=true
|
|
120
|
+
const content=message.content.filter(b=>b.type!=='reasoning'&&b.type!=='tool-call')
|
|
121
|
+
for(const call of message.content.filter(b=>b.type==='tool-call')){
|
|
122
|
+
if(!resultIds.has(call.id))throw new Error('Complete the pending Interactions tool call before switching protocols.')
|
|
123
|
+
foreignCalls.add(call.id)
|
|
124
|
+
content.push({type:'text',text:'[Previously executed tool '+call.name+'; call '+call.id+']\n'+JSON.stringify(argsOf(call.arguments))})
|
|
113
125
|
}
|
|
114
|
-
|
|
126
|
+
const source=message.source?(({replayState,...rest})=>rest)(message.source):undefined
|
|
127
|
+
return {...message,...(source===undefined?{}:{source}),content:content.length?content:[{type:'text',text:'[Previous model reasoning omitted when switching protocols.]'}]}
|
|
115
128
|
})
|
|
116
129
|
return changed?{...options,messages}:options
|
|
117
130
|
}
|
package/package.json
CHANGED