dsh-vertex-argon 1.1.2 → 1.1.4
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 +108 -31
- package/adapter.js +25 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,44 +1,121 @@
|
|
|
1
|
-
|
|
1
|
+
<div align="center">
|
|
2
|
+
<img src="./icon.svg" width="76" height="76" alt="Vertex Argon Icon" />
|
|
3
|
+
<h1>dsh-vertex-argon</h1>
|
|
4
|
+
<p><strong>Google Vertex AI & Gemini API Dual-Route Gemini 4 Argon Plugin for <a href="https://github.com/deepseek-ai/deepseek-harness">DeepSeek Harness</a> (DSH)</strong></p>
|
|
5
|
+
<p>
|
|
6
|
+
<a href="https://www.npmjs.com/package/dsh-vertex-argon"><img src="https://img.shields.io/npm/v/dsh-vertex-argon?style=flat-square&color=2563eb" alt="npm version" /></a>
|
|
7
|
+
<a href="https://github.com/deepseek-ai/deepseek-harness"><img src="https://img.shields.io/badge/DSH-0.1.7--rc.2%20%7C%200.2.0--rc.2-4f46e5?style=flat-square" alt="DSH compatibility" /></a>
|
|
8
|
+
<a href="https://docs.cloud.google.com/gemini-enterprise-agent-platform/models/gemini/4-argon"><img src="https://img.shields.io/badge/Thinking%20Levels-LOW%20%7C%20MEDIUM%20%7C%20HIGH-0ea5e9?style=flat-square" alt="Thinking Levels" /></a>
|
|
9
|
+
<a href="./LICENSE"><img src="https://img.shields.io/badge/License-MIT-10b981?style=flat-square" alt="License" /></a>
|
|
10
|
+
</p>
|
|
11
|
+
</div>
|
|
2
12
|
|
|
3
|
-
|
|
13
|
+
---
|
|
4
14
|
|
|
5
|
-
|
|
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)与带签名的多轮工具调用。
|
|
6
16
|
|
|
7
|
-
|
|
17
|
+
Current release: **[1.1.3](https://github.com/higekibaka/dsh-vertex-argon)** · [npm](https://www.npmjs.com/package/dsh-vertex-argon)
|
|
8
18
|
|
|
9
|
-
|
|
10
|
-
- 检测到 `google-vertex` 配置了 `gemini-4-argon`(或默认状态)时,在 **Vertex Argon** 分组下显示 **`Gemini 4 Argon (Vertex AI)`**(模型 ID:`gemini-4-argon`)。
|
|
11
|
-
- 检测到 `google`(Gemini Developer API)配置了 `gemini-4-argon` 时,自动在同一个 **Vertex Argon** 分组下多显示一项 **`Gemini 4 Argon (Gemini API)`**(模型 ID:`gemini-4-argon-google`),自动复用已配置的 `GOOGLE_API_KEY`。
|
|
12
|
-
2. **原生三档思考控制(`LOW / MEDIUM / HIGH`)**
|
|
13
|
-
- 严格对齐 [Google Cloud Gemini 4 Argon 官方文档](https://docs.cloud.google.com/gemini-enterprise-agent-platform/models/gemini/4-argon),发送离散 `thinkingLevel`(默认 `MEDIUM`),彻底不发送 `thinkingBudget`,并自动剔除被 Argon 忽略的采样参数(`temperature`、`topP`、`topK`)。
|
|
14
|
-
3. **思维链(思考摘要)与多轮工具调用签名回传**
|
|
15
|
-
- 固定开启 `includeThoughts: true`,解析 `thought: true` 内容块并在界面展示思考过程。
|
|
16
|
-
- 完整保留 `functionCall` 的 `thoughtSignature` 签名,确保多步工具调用(`run_code` 等)回传不丢上下文。
|
|
17
|
-
4. **原生分组兜底保护**
|
|
18
|
-
- 同时为原生的 `Google` 与 `Google Vertex AI` 路由注入 `Gemini 4` `thinkingLevel` 兼容补丁,即使误选原分组下的 `gemini-4-argon` 也不会报 400 错误。
|
|
19
|
-
5. **专属设置页面(设置 → Vertex Argon)**
|
|
20
|
-
- 实时控制模型选择器显隐、切换默认思考档位(`Low / Medium / High`)、调整单次流式最大输出上限(默认 `65,536`)与共享上下文窗口(默认 `1,048,576`)。
|
|
19
|
+
---
|
|
21
20
|
|
|
22
|
-
##
|
|
21
|
+
## ✨ 为什么需要这个插件?
|
|
23
22
|
|
|
24
|
-
|
|
23
|
+
| 能力维度 | DSH 内置 `google` / `google-vertex` 旧适配器 | `dsh-vertex-argon` 插件通道 |
|
|
24
|
+
|---|---|---|
|
|
25
|
+
| **思考控制参数** | 误判为旧模型并发送 `thinkingBudget: -1`,触发云端 `HTTP 400` | 原生发送 `thinkingLevel: "LOW" \| "MEDIUM" \| "HIGH"`,绝不传 `thinkingBudget` |
|
|
26
|
+
| **思维链(思考摘要)** | 手动新增模型默认无 `reasoning` 标记,不请求摘要 | 固定开启 `includeThoughts: true`,流式解析 `thought: true` 实时展示思维链 |
|
|
27
|
+
| **多轮工具调用回传** | 路由切换或签名不对齐时易丢失上下文 | 保持 `provider` / `model` 与 `thoughtSignature` 签名全链路一致 |
|
|
28
|
+
| **采样参数净化** | 可能携带被 Argon 拒绝或忽略的采样字段 | 自动剥离 `temperature`、`topP`、`topK` 等无效采样参数 |
|
|
29
|
+
| **通道管理与设置** | 需手改 `cordis.patch.yml` 并反复排查校验报错 | 自动检测双通道 + 内置 **设置 → Vertex Argon** 图形化实时调节页面 |
|
|
25
30
|
|
|
26
|
-
|
|
31
|
+
---
|
|
27
32
|
|
|
28
|
-
|
|
33
|
+
## 🔄 工作原理与架构流向
|
|
29
34
|
|
|
30
|
-
|
|
35
|
+
```mermaid
|
|
36
|
+
flowchart TD
|
|
37
|
+
U["DSH 模型配置扫描"] --> D{"自动检测 gemini-4-argon"}
|
|
38
|
+
D -->|"检测到 google-vertex 或默认"| V["Vertex Argon → Gemini 4 Argon (Vertex AI)<br/>复用 GOOGLE_APPLICATION_CREDENTIALS"]
|
|
39
|
+
D -->|"检测到 google (Gemini API)"| G["Vertex Argon → Gemini 4 Argon (Gemini API)<br/>复用 GOOGLE_API_KEY"]
|
|
40
|
+
V --> P["onPayload 请求级净化与注入"]
|
|
41
|
+
G --> P
|
|
42
|
+
P --> T["注入 thinkingLevel: LOW / MEDIUM / HIGH 与 includeThoughts: true<br/>剔除 thinkingBudget 与 temperature / topP / topK"]
|
|
43
|
+
T --> S["Google GenAI Stream 响应"]
|
|
44
|
+
S --> R1["thought: true → DSH 思维链面板"]
|
|
45
|
+
S --> R2["functionCall + thoughtSignature → 原生工具卡片与多轮签名回放"]
|
|
46
|
+
```
|
|
31
47
|
|
|
32
|
-
|
|
48
|
+
除提供独立的 **Vertex Argon** 分组外,插件在启动时还会为内置 `PiAiAdapter` 注入 `installGemini4PiAiPatch` 运行时兜底——即便用户在模型选择器中误点了原 `Google` 或 `Google Vertex AI` 分组下的 `gemini-4-argon`,也会被自动改写为合法的 `thinkingLevel` 请求。
|
|
33
49
|
|
|
34
|
-
|
|
35
|
-
在系统用户环境变量中设置以下 3 项,设置后**完全退出 DSH(含系统托盘)并重开**:
|
|
36
|
-
- `GOOGLE_APPLICATION_CREDENTIALS`:本地服务账号 JSON 密钥文件的完整路径(不加引号)
|
|
37
|
-
- `GOOGLE_CLOUD_PROJECT`:Google Cloud 项目 ID
|
|
38
|
-
- `GOOGLE_CLOUD_LOCATION`:`global`(或 `us` / `eu`)
|
|
39
|
-
- **方式 B:Google Gemini API(AI Studio API Key)**
|
|
40
|
-
在 DSH **设置 → 模型 → Google** 中配置 `GOOGLE_API_KEY`,并添加模型 ID `gemini-4-argon`。插件会自动检测并在 **Vertex Argon** 分组下展示 `Gemini 4 Argon (Gemini API)`。
|
|
50
|
+
---
|
|
41
51
|
|
|
42
|
-
##
|
|
52
|
+
## 🚀 安装方法
|
|
43
53
|
|
|
44
|
-
|
|
54
|
+
### 方式 1:在 DSH 对话框中一键安装(推荐)
|
|
55
|
+
|
|
56
|
+
直接向当前 DSH 会话发送:
|
|
57
|
+
|
|
58
|
+
```text
|
|
59
|
+
请用 plugin_manager 的 install_bundle 安装 dsh-vertex-argon
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
> 若本机默认配置了尚未同步新包的镜像源,可发送:
|
|
63
|
+
> `请用 plugin_manager 的 install_bundle 从 https://registry.npmjs.org/ 安装 dsh-vertex-argon`
|
|
64
|
+
|
|
65
|
+
### 方式 2:使用 DSH CLI 安装
|
|
66
|
+
|
|
67
|
+
```sh
|
|
68
|
+
dsh plugin --profile web add dsh-vertex-argon
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
---
|
|
72
|
+
|
|
73
|
+
## 🔑 双通道凭据配置(二选一或同时配置)
|
|
74
|
+
|
|
75
|
+
### 通道 A:Google Vertex AI(服务账号 JSON / ADC)
|
|
76
|
+
|
|
77
|
+
1. 在 [Google Cloud 控制台](https://console.cloud.google.com/) 确认项目已绑定结算账户、已启用 **Vertex AI API**(`aiplatform.googleapis.com`),并为服务账号授予 **Vertex AI User**(`roles/aiplatform.user`)角色,下载 JSON 密钥文件。
|
|
78
|
+
2. 在系统用户环境变量中设置以下 3 项(Windows 打开「编辑账户的环境变量 → 用户变量」新建,**变量值不要加引号**):
|
|
79
|
+
|
|
80
|
+
| 环境变量名 | 填写示例 | 说明 |
|
|
81
|
+
|---|---|---|
|
|
82
|
+
| `GOOGLE_APPLICATION_CREDENTIALS` | `C:\Keys\vertex-sa.json` | 服务账号 JSON 密钥文件的完整本地路径 |
|
|
83
|
+
| `GOOGLE_CLOUD_PROJECT` | `my-gcp-project-id` | Google Cloud **项目 ID**(注意不是项目名称) |
|
|
84
|
+
| `GOOGLE_CLOUD_LOCATION` | `global` | 调用区域,推荐 `global`(或 `us` / `eu`) |
|
|
85
|
+
|
|
86
|
+
3. **完全退出 DSH(含右下角系统托盘图标)并重新启动**,使进程继承新的环境变量。
|
|
87
|
+
4. 在会话模型选择器中选择 **`Vertex Argon → Gemini 4 Argon (Vertex AI)`**。
|
|
88
|
+
|
|
89
|
+
### 通道 B:Google Gemini API(AI Studio API Key)
|
|
90
|
+
|
|
91
|
+
1. 打开 DSH **设置 → 模型 → Google**,配置你的 `GOOGLE_API_KEY`。
|
|
92
|
+
2. 在 `Google` 提供商下添加模型 ID:`gemini-4-argon`。
|
|
93
|
+
3. 插件会自动检测到该配置,并在模型选择器的 **`Vertex Argon`** 分组下多显示一项 **`Gemini 4 Argon (Gemini API)`**,点击即可直接调用。
|
|
94
|
+
|
|
95
|
+
---
|
|
96
|
+
|
|
97
|
+
## ⚙️ 设置页面与配置项(Configuration)
|
|
98
|
+
|
|
99
|
+
打开左下角 **设置 → Vertex Argon**,无需修改 YAML 或重启应用,即可实时调整以下配置(对应 `local-vertex-argon` Profile 条目):
|
|
100
|
+
|
|
101
|
+
| 配置字段 | 默认值 | 可选范围 / 预设 | 说明 |
|
|
102
|
+
|---|---|---|---|
|
|
103
|
+
| `showInModelPicker` | `true` | `true` / `false` | 是否在会话模型选择器中显示 `Vertex Argon` 分组(隐藏不影响已打开会话) |
|
|
104
|
+
| `reasoning` | `medium` | `low` / `medium` / `high` | 默认思考档位,分别映射为原生 `LOW` / `MEDIUM` / `HIGH` |
|
|
105
|
+
| `maxTokens` | `65536` | `1` – `65536` | 单次流式请求最大输出上限(含思考与正文 token,官方单次流式上限为 `65,536`) |
|
|
106
|
+
| `contextWindow` | `1048576` | `1` – `1048576` | 输入、思考与输出共享的总上下文窗口(官方上限为 `1,048,576`) |
|
|
107
|
+
|
|
108
|
+
---
|
|
109
|
+
|
|
110
|
+
## ❓ 常见问题
|
|
111
|
+
|
|
112
|
+
- **为什么极简问题有时候不显示思维链文本?**
|
|
113
|
+
插件已固定发送 `includeThoughts: true`,但 Google 云端会根据问题复杂度动态决定是否吐出可读摘要:遇到推理或工具调用任务时会返回思考摘要文本,极简问答可能仅返回 `thoughtSignature` 签名而不产出摘要文本,属官方正常机制。
|
|
114
|
+
- **Gemini 网页版订阅(Gemini Advanced)包含这里的费用吗?**
|
|
115
|
+
不包含。无论是 Vertex AI 还是 Gemini Developer API,均按对应平台的 API 用量计费。
|
|
116
|
+
|
|
117
|
+
---
|
|
118
|
+
|
|
119
|
+
## 📄 License
|
|
120
|
+
|
|
121
|
+
[MIT](./LICENSE) © [hgk](https://github.com/higekibaka)
|
package/adapter.js
CHANGED
|
@@ -59,6 +59,29 @@ export function detectPiAiArgonRoutes(ctx, explicitRoutes) {
|
|
|
59
59
|
return { hasVertex: true, hasGoogle: false, googleApiKeyEnv: 'GOOGLE_API_KEY' }
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
+
const TRANSIENT_GEMINI_STOP_RE = /(?:Unhandled stop reason:\s*(?:MALFORMED_RESPONSE|MALFORMED_FUNCTION_CALL|UNEXPECTED_TOOL_CALL|TOO_MANY_TOOL_CALLS)|Provider stopped with:\s*(?:MALFORMED_RESPONSE|MALFORMED_FUNCTION_CALL|UNEXPECTED_TOOL_CALL|OTHER|FINISH_REASON_UNSPECIFIED))/i
|
|
63
|
+
|
|
64
|
+
function wrapGemini4Stream(rawStream) {
|
|
65
|
+
if (!rawStream || typeof rawStream[Symbol.asyncIterator] !== 'function') return rawStream
|
|
66
|
+
return {
|
|
67
|
+
[Symbol.asyncIterator]: async function* () {
|
|
68
|
+
for await (const event of rawStream) {
|
|
69
|
+
if (event?.type === 'error' && typeof event?.error?.errorMessage === 'string' && TRANSIENT_GEMINI_STOP_RE.test(event.error.errorMessage)) {
|
|
70
|
+
yield {
|
|
71
|
+
...event,
|
|
72
|
+
error: {
|
|
73
|
+
...event.error,
|
|
74
|
+
errorMessage: `${event.error.errorMessage} (502 upstream transient finishReason)`,
|
|
75
|
+
},
|
|
76
|
+
}
|
|
77
|
+
continue
|
|
78
|
+
}
|
|
79
|
+
yield event
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
62
85
|
export function gemini4StreamSimple(nativeStream, requestModel, context, options = {}, defaultLevel = 'medium', upstreamModelId = requestModel.id) {
|
|
63
86
|
const fallback = defaultLevel ?? (/cyber-permissive/i.test(requestModel?.id ?? '') ? 'high' : 'medium')
|
|
64
87
|
const rawLevel = options.reasoning ?? fallback
|
|
@@ -66,7 +89,7 @@ export function gemini4StreamSimple(nativeStream, requestModel, context, options
|
|
|
66
89
|
const level = typeof mapped === 'string' ? mapped.toLowerCase() : fallback
|
|
67
90
|
if (!LEVELS.includes(level)) throw new LlmError('Gemini 4 Argon requires low, medium or high.', 'UNSUPPORTED_REASONING_EFFORT')
|
|
68
91
|
const { reasoning, thinking, thinkingBudgets, temperature, onPayload: prior, ...rest } = options
|
|
69
|
-
return nativeStream(requestModel, context, {
|
|
92
|
+
return wrapGemini4Stream(nativeStream(requestModel, context, {
|
|
70
93
|
...rest,
|
|
71
94
|
maxTokens: options.maxTokens ?? requestModel.maxTokens,
|
|
72
95
|
async onPayload(payload, payloadModel) {
|
|
@@ -85,7 +108,7 @@ export function gemini4StreamSimple(nativeStream, requestModel, context, options
|
|
|
85
108
|
config: { ...cleanConfig, thinkingConfig: { thinkingLevel: level.toUpperCase(), includeThoughts: true } },
|
|
86
109
|
}
|
|
87
110
|
},
|
|
88
|
-
})
|
|
111
|
+
}))
|
|
89
112
|
}
|
|
90
113
|
|
|
91
114
|
export function installGemini4PiAiPatch() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-vertex-argon",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.4",
|
|
4
4
|
"description": "Google Vertex AI & Gemini API Argon plugin for DeepSeek Harness — native Low/Medium/High thinking levels, thought summaries, signed tool-call replay, and dedicated Settings UI.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|