dsh-vertex-argon 0.0.0-stage → 1.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 hgk
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,44 @@
1
- # Temporary Holding Version
1
+ # dsh-vertex-argon
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ DeepSeek Harness (DSH) 专用的 **Gemini 4 Argon(Vertex AI & Gemini API 双通道)** 插件。
4
+
5
+ 解决 DSH 内置 `pi-ai` 适配器对 `gemini-4-argon` 发送 `thinkingBudget` 导致 `HTTP 400`、无法切换思考档位、无法显示思维链(思考摘要)的问题。
6
+
7
+ ## 核心特性
8
+
9
+ 1. **双通道自动检测与聚合**
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`)。
21
+
22
+ ## 安装方法
23
+
24
+ ### 从 npm 安装
25
+
26
+ 在 DSH 会话中直接对 Agent 发送:
27
+
28
+ > `请用 plugin_manager 的 install_bundle 安装 dsh-vertex-argon`
29
+
30
+ 或在 DSH **设置 → 插件** 中搜索/输入 `dsh-vertex-argon` 安装。
31
+
32
+ ### 前置凭据配置(二选一或同时使用)
33
+
34
+ - **方式 A:Google Vertex AI(服务账号 JSON / ADC)**
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)`。
41
+
42
+ ## License
43
+
44
+ MIT © hgk
package/adapter.js ADDED
@@ -0,0 +1,334 @@
1
+ import { access } from 'node:fs/promises'
2
+ import { homedir } from 'node:os'
3
+ import { resolve } from 'node:path'
4
+ import { shared } from './runtime.js'
5
+ const { LlmAdapter, LlmError, resolveRetryPolicy, resolveImageAttachmentAccess } = await shared('@deepseek-ai/dsh-llm')
6
+ const { PiAiAdapter } = await shared('@deepseek-ai/dsh-llm-pi-ai')
7
+ const { launchEnvironmentOf } = await shared('@deepseek-ai/dsh-launch-environment')
8
+ const { googleVertexProvider } = await shared('@earendil-works/pi-ai/providers/google-vertex')
9
+ const { googleProvider } = await shared('@earendil-works/pi-ai/providers/google')
10
+
11
+ export const PROVIDER = 'google-vertex-argon'
12
+ export const NATIVE_PROVIDER = 'google-vertex'
13
+ export const MODEL = 'gemini-4-argon'
14
+ export const GOOGLE_API_MODEL = 'gemini-4-argon-google'
15
+ export const LEVELS = ['low', 'medium', 'high']
16
+ const ENV_KEYS = ['GOOGLE_APPLICATION_CREDENTIALS', 'GOOGLE_CLOUD_PROJECT', 'GCLOUD_PROJECT', 'GOOGLE_CLOUD_LOCATION', 'GOOGLE_CLOUD_API_KEY']
17
+ const DEFAULT_THINKING_MAP = { off: null, minimal: null, low: 'low', medium: 'medium', high: 'high', xhigh: null, max: null }
18
+
19
+ const readVal = v => (v && typeof v === 'object' && typeof v.get === 'function') ? v.get() : v
20
+
21
+ export function isGemini4Model(model) {
22
+ return Boolean(
23
+ model &&
24
+ typeof model.id === 'string' &&
25
+ /^(?:models\/)?gemini-4\b/i.test(model.id) &&
26
+ (model.api === 'google-vertex' || model.api === 'google-generative-ai'),
27
+ )
28
+ }
29
+
30
+ export function detectPiAiArgonRoutes(ctx, explicitRoutes) {
31
+ if (explicitRoutes && typeof explicitRoutes === 'object') {
32
+ return {
33
+ hasVertex: explicitRoutes.hasVertex !== false,
34
+ hasGoogle: Boolean(explicitRoutes.hasGoogle),
35
+ googleApiKeyEnv: explicitRoutes.googleApiKeyEnv || 'GOOGLE_API_KEY',
36
+ googleBaseUrl: explicitRoutes.googleBaseUrl,
37
+ vertexBaseUrl: explicitRoutes.vertexBaseUrl,
38
+ }
39
+ }
40
+ try {
41
+ const entries = ctx?.get?.('configEditor')?.entries?.() ?? ctx?.root?.loader?.entries?.() ?? []
42
+ for (const entry of entries) {
43
+ if (entry?.options?.id !== 'llm-pi-ai' && entry?.options?.name !== '@deepseek-ai/dsh-llm-pi-ai') continue
44
+ const providers = readVal(entry?.fiber?.config?.providers) ?? readVal(entry?.options?.config?.providers) ?? {}
45
+ const googleCfg = providers?.google
46
+ const vertexCfg = providers?.['google-vertex']
47
+ const hasModel = list => Array.isArray(list) && list.some(m => /^(?:models\/)?gemini-4-argon\b/i.test(String(readVal(m?.id) ?? '')))
48
+ const hasGoogle = hasModel(readVal(googleCfg?.models))
49
+ const hasVertex = hasModel(readVal(vertexCfg?.models))
50
+ return {
51
+ hasVertex: hasVertex || !hasGoogle,
52
+ hasGoogle,
53
+ googleApiKeyEnv: readVal(googleCfg?.apiKeyEnv) || 'GOOGLE_API_KEY',
54
+ googleBaseUrl: readVal(googleCfg?.baseURL),
55
+ vertexBaseUrl: readVal(vertexCfg?.baseURL),
56
+ }
57
+ }
58
+ } catch {}
59
+ return { hasVertex: true, hasGoogle: false, googleApiKeyEnv: 'GOOGLE_API_KEY' }
60
+ }
61
+
62
+ export function gemini4StreamSimple(nativeStream, requestModel, context, options = {}, defaultLevel = 'medium', upstreamModelId = requestModel.id) {
63
+ const fallback = defaultLevel ?? (/cyber-permissive/i.test(requestModel?.id ?? '') ? 'high' : 'medium')
64
+ const rawLevel = options.reasoning ?? fallback
65
+ const mapped = requestModel?.thinkingLevelMap?.[rawLevel] ?? rawLevel
66
+ const level = typeof mapped === 'string' ? mapped.toLowerCase() : fallback
67
+ if (!LEVELS.includes(level)) throw new LlmError('Gemini 4 Argon requires low, medium or high.', 'UNSUPPORTED_REASONING_EFFORT')
68
+ const { reasoning, thinking, thinkingBudgets, temperature, onPayload: prior, ...rest } = options
69
+ return nativeStream(requestModel, context, {
70
+ ...rest,
71
+ maxTokens: options.maxTokens ?? requestModel.maxTokens,
72
+ async onPayload(payload, payloadModel) {
73
+ const replacement = await prior?.(payload, payloadModel)
74
+ const body = replacement === undefined ? payload : replacement
75
+ if (!body || typeof body !== 'object' || Array.isArray(body) || !Array.isArray(body.contents) || !body.config || typeof body.config !== 'object' || Array.isArray(body.config)) {
76
+ throw new LlmError('Gemini 4 Argon received an incompatible native payload.', 'INVALID_REQUEST')
77
+ }
78
+ if (body.model !== requestModel.id && body.model !== upstreamModelId) {
79
+ throw new LlmError('Gemini 4 Argon received an incompatible model payload.', 'INVALID_REQUEST')
80
+ }
81
+ const { temperature: _t, topP: _tp, topK: _tk, candidateCount: _cc, frequencyPenalty: _fp, presencePenalty: _pp, ...cleanConfig } = body.config
82
+ return {
83
+ ...body,
84
+ model: upstreamModelId,
85
+ config: { ...cleanConfig, thinkingConfig: { thinkingLevel: level.toUpperCase(), includeThoughts: true } },
86
+ }
87
+ },
88
+ })
89
+ }
90
+
91
+ export function installGemini4PiAiPatch() {
92
+ const proto = PiAiAdapter?.prototype
93
+ if (!proto || typeof proto.current !== 'function') return () => {}
94
+ const origCurrent = proto.current
95
+ const patchedProviders = new Map()
96
+ const ensureGemini4Capabilities = piProvider => {
97
+ if (typeof piProvider?.getModels !== 'function') return
98
+ try {
99
+ for (const m of piProvider.getModels()) {
100
+ if (isGemini4Model(m) && !m.reasoning) {
101
+ m.reasoning = true
102
+ m.thinkingLevelMap = { ...DEFAULT_THINKING_MAP }
103
+ }
104
+ }
105
+ } catch {}
106
+ }
107
+ const wrapProvider = (piProvider, defaultReasoning) => {
108
+ if (!piProvider || typeof piProvider.streamSimple !== 'function' || typeof piProvider.stream !== 'function') return
109
+ ensureGemini4Capabilities(piProvider)
110
+ if (piProvider.id === PROVIDER || patchedProviders.has(piProvider)) return
111
+ const origStreamSimple = piProvider.streamSimple
112
+ patchedProviders.set(piProvider, origStreamSimple)
113
+ piProvider.streamSimple = function (requestModel, context, options = {}) {
114
+ if (isGemini4Model(requestModel)) {
115
+ return gemini4StreamSimple((m, c, o) => piProvider.stream(m, c, o), requestModel, context, options, defaultReasoning, requestModel.id)
116
+ }
117
+ return origStreamSimple.call(this, requestModel, context, options)
118
+ }
119
+ }
120
+ function patchedCurrent() {
121
+ const snapshot = origCurrent.call(this)
122
+ if (snapshot?.profiles instanceof Map) {
123
+ for (const profile of snapshot.profiles.values()) {
124
+ if (profile?.piProvider) wrapProvider(profile.piProvider, profile.reasoning)
125
+ }
126
+ }
127
+ return snapshot
128
+ }
129
+ proto.current = patchedCurrent
130
+ return () => {
131
+ if (proto.current === patchedCurrent) proto.current = origCurrent
132
+ for (const [piProvider, origStreamSimple] of patchedProviders.entries()) {
133
+ piProvider.streamSimple = origStreamSimple
134
+ }
135
+ patchedProviders.clear()
136
+ }
137
+ }
138
+
139
+ export function resolveConfigValues(raw = {}) {
140
+ const source = typeof raw === 'function' ? raw() : raw
141
+ const showInModelPicker = readVal(source?.showInModelPicker) ?? true
142
+ const reasoning = readVal(source?.reasoning) ?? 'medium'
143
+ const contextWindow = readVal(source?.contextWindow) ?? 1048576
144
+ const maxTokens = readVal(source?.maxTokens) ?? 65536
145
+ if (!LEVELS.includes(reasoning)) throw new LlmError('Invalid default Argon effort.', 'INVALID_CONFIG')
146
+ for (const [key, val] of [['contextWindow', contextWindow], ['maxTokens', maxTokens]]) {
147
+ if (!Number.isSafeInteger(val) || val <= 0) throw new LlmError('Invalid Argon ' + key, 'INVALID_CONFIG')
148
+ }
149
+ return {
150
+ showInModelPicker: Boolean(showInModelPicker),
151
+ reasoning,
152
+ contextWindow,
153
+ maxTokens,
154
+ routes: source?.routes,
155
+ }
156
+ }
157
+
158
+ /** Serve both Vertex AI Argon and Gemini API (google) Argon under the unified plugin group. */
159
+ export function argonProvider(nativeVertex, models, defaultLevel = 'medium', nativeGoogle = googleProvider()) {
160
+ const modelMap = new Map((Array.isArray(models) ? models : [models]).map(m => [m.id, m]))
161
+ return {
162
+ id: PROVIDER,
163
+ name: 'Vertex Argon',
164
+ auth: nativeVertex.auth,
165
+ getModels: () => [...modelMap.values()],
166
+ streamSimple(requestModel, context, options = {}) {
167
+ const configured = modelMap.get(requestModel?.id)
168
+ if (!configured || requestModel.provider !== PROVIDER) {
169
+ throw new LlmError('Vertex Argon only serves configured Gemini 4 Argon routes.', 'UNSUPPORTED_OPTION')
170
+ }
171
+ const { env: rawEnv, ...restOptions } = options
172
+ const googleApiKey = rawEnv?.__GOOGLE_API_KEY__
173
+ const cleanEnv = rawEnv ? { ...rawEnv } : undefined
174
+ if (cleanEnv) delete cleanEnv.__GOOGLE_API_KEY__
175
+ if (requestModel.id === GOOGLE_API_MODEL || requestModel.api === 'google-generative-ai') {
176
+ const apiKey = googleApiKey || options.apiKey
177
+ return gemini4StreamSimple(
178
+ (m, c, o) => nativeGoogle.stream(m, c, o),
179
+ requestModel,
180
+ context,
181
+ { ...restOptions, ...(cleanEnv ? { env: cleanEnv } : {}), ...(apiKey ? { apiKey } : {}), maxTokens: options.maxTokens ?? configured.maxTokens },
182
+ defaultLevel,
183
+ MODEL,
184
+ )
185
+ }
186
+ if (requestModel.api !== 'google-vertex') {
187
+ throw new LlmError('Vertex Argon only serves google-vertex or google-generative-ai.', 'UNSUPPORTED_OPTION')
188
+ }
189
+ return gemini4StreamSimple(
190
+ (m, c, o) => nativeVertex.stream(m, c, o),
191
+ requestModel,
192
+ context,
193
+ { ...restOptions, ...(cleanEnv ? { env: cleanEnv } : {}), maxTokens: options.maxTokens ?? configured.maxTokens },
194
+ defaultLevel,
195
+ MODEL,
196
+ )
197
+ },
198
+ }
199
+ }
200
+
201
+ export class ArgonAdapter extends LlmAdapter {
202
+ constructor(inner, isVisible = () => true) {
203
+ super()
204
+ this.inner = inner
205
+ this.isVisible = isVisible
206
+ }
207
+ providerInfo(provider) { return this.inner.providerInfo(provider) }
208
+ providerRetryPolicy(provider) { return this.inner.providerRetryPolicy(provider) }
209
+ imageRequestPricing(provider, model) { return this.inner.imageRequestPricing(provider, model) }
210
+ async listModels(provider) {
211
+ if (!this.isVisible()) return []
212
+ return this.inner.listModels(provider)
213
+ }
214
+ resolveModel(provider, model, signal) { return this.inner.resolveModel(provider, model, signal) }
215
+ prepareCall(provider, model, signal) { return this.inner.prepareCall(provider, model, signal) }
216
+ stream(options) { return this.inner.stream(options) }
217
+ }
218
+
219
+ export function createArgonAdapter(ctx, configInput, nativeVertex = googleVertexProvider(), nativeGoogle = googleProvider()) {
220
+ resolveConfigValues(configInput)
221
+ const environment = launchEnvironmentOf(ctx)
222
+ const resolveSecret = async name => {
223
+ try {
224
+ const cred = await ctx?.get?.('credentials')?.resolve?.(name)
225
+ if (cred?.value) return cred.value
226
+ } catch {}
227
+ return environment.get(name)?.value
228
+ }
229
+ const authContext = {
230
+ env: async key => resolveSecret(key),
231
+ async fileExists(file) {
232
+ const expanded = file.startsWith('~/') || file === '~' ? resolve(homedir(), file === '~' ? '' : file.slice(2)) : file
233
+ try { await access(expanded); return true } catch { return false }
234
+ },
235
+ }
236
+ let cachedKey = ''
237
+ let cachedProfiles = null
238
+ const getProfiles = () => {
239
+ const cfg = resolveConfigValues(configInput)
240
+ const detected = detectPiAiArgonRoutes(ctx, cfg.routes)
241
+ const key = JSON.stringify({
242
+ r: cfg.reasoning,
243
+ cw: cfg.contextWindow,
244
+ mt: cfg.maxTokens,
245
+ v: detected.hasVertex,
246
+ g: detected.hasGoogle,
247
+ ge: detected.googleApiKeyEnv,
248
+ gb: detected.googleBaseUrl,
249
+ vb: detected.vertexBaseUrl,
250
+ })
251
+ if (key === cachedKey && cachedProfiles) return cachedProfiles
252
+ const auth = {
253
+ apiKey: {
254
+ ...nativeVertex.auth.apiKey,
255
+ async resolve(input) {
256
+ const vertexRes = await nativeVertex.auth.apiKey.resolve(input)
257
+ const env = {}
258
+ for (const k of ENV_KEYS) {
259
+ const val = await input.ctx.env(k)
260
+ if (val !== undefined) env[k] = val
261
+ }
262
+ const googleKey =
263
+ (await input.ctx.env(detected.googleApiKeyEnv || 'GOOGLE_API_KEY')) ??
264
+ (await input.ctx.env('GOOGLE_API_KEY')) ??
265
+ (await input.ctx.env('GEMINI_API_KEY'))
266
+ if (googleKey) env.__GOOGLE_API_KEY__ = googleKey
267
+ if (vertexRes) {
268
+ return { ...vertexRes, env: { ...env, ...vertexRes.env } }
269
+ }
270
+ if (googleKey) {
271
+ return { auth: {}, env, source: detected.googleApiKeyEnv || 'GOOGLE_API_KEY' }
272
+ }
273
+ return undefined
274
+ },
275
+ },
276
+ }
277
+ const models = []
278
+ if (detected.hasVertex) {
279
+ models.push({
280
+ id: MODEL,
281
+ name: detected.hasGoogle ? 'Gemini 4 Argon (Vertex AI)' : 'Gemini 4 Argon',
282
+ provider: PROVIDER,
283
+ api: 'google-vertex',
284
+ baseUrl: detected.vertexBaseUrl || 'https://{location}-aiplatform.googleapis.com',
285
+ reasoning: true,
286
+ input: ['text', 'image'],
287
+ contextWindow: cfg.contextWindow,
288
+ maxTokens: cfg.maxTokens,
289
+ thinkingLevelMap: { ...DEFAULT_THINKING_MAP },
290
+ cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
291
+ })
292
+ }
293
+ if (detected.hasGoogle) {
294
+ models.push({
295
+ id: GOOGLE_API_MODEL,
296
+ name: 'Gemini 4 Argon (Gemini API)',
297
+ provider: PROVIDER,
298
+ api: 'google-generative-ai',
299
+ baseUrl: detected.googleBaseUrl || 'https://generativelanguage.googleapis.com/v1beta',
300
+ reasoning: true,
301
+ input: ['text', 'image'],
302
+ contextWindow: cfg.contextWindow,
303
+ maxTokens: cfg.maxTokens,
304
+ thinkingLevelMap: { ...DEFAULT_THINKING_MAP },
305
+ cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
306
+ })
307
+ }
308
+ const configuredMaxTokens = new Map(models.map(m => [m.id, cfg.maxTokens]))
309
+ const provider = argonProvider({ ...nativeVertex, auth }, models, cfg.reasoning, nativeGoogle)
310
+ cachedKey = key
311
+ cachedProfiles = new Map([[PROVIDER, {
312
+ provider: PROVIDER,
313
+ displayName: 'Vertex Argon',
314
+ piProvider: provider,
315
+ reasoning: cfg.reasoning,
316
+ streamIdleTimeoutMs: 300000,
317
+ maxRequestImageBytes: 20 * 1024 * 1024,
318
+ requestImagePixelBudget: 2048 * 2048,
319
+ requestImageMaxBytes: 1024 * 1024,
320
+ retryPolicy: resolveRetryPolicy(undefined, 'local-vertex-argon'),
321
+ modelErrors: new Map(),
322
+ configuredMaxTokens,
323
+ }]])
324
+ return cachedProfiles
325
+ }
326
+ const inner = new PiAiAdapter({
327
+ profiles: getProfiles,
328
+ resolveApiKey: async () => undefined,
329
+ auth: { authContext },
330
+ resolveAttachments: () => ctx.get('attachments'),
331
+ resolveImageAccess: (attachments, ref) => resolveImageAttachmentAccess(attachments, path => ctx.get('fs')?.processPathFromHostPath(path), ref),
332
+ })
333
+ return new ArgonAdapter(inner, () => resolveConfigValues(configInput).showInModelPicker)
334
+ }
package/client.js ADDED
@@ -0,0 +1,264 @@
1
+ window.__ModuleLoader__.load({
2
+ id: 'dsh-vertex-argon',
3
+ factory(require) {
4
+ const React = require('react')
5
+ const h = React.createElement
6
+ const ns = 'settings.localVertexArgon'
7
+ const dictionaries = {
8
+ zh: {
9
+ title: 'Vertex Argon',
10
+ subtitle: '自动聚合 Vertex AI 与 Gemini API 的 Argon 通道 · 原生三档思考与工具签名回传',
11
+ show: '在模型选择器中显示 Vertex Argon 分组',
12
+ showHint: '控制是否在会话模型选择器中列出 Vertex Argon 分组下的模型。正在使用该模型的会话不受隐藏影响。',
13
+ visible: '已显示',
14
+ hidden: '已隐藏',
15
+ reasoningLabel: '默认思考档位(Thinking Level)',
16
+ reasoningHint: '仅支持官方 LOW / MEDIUM(默认)/ HIGH 三档,直接发送原生 thinkingLevel 并开启 includeThoughts: true,彻底不传 thinkingBudget。',
17
+ level_low: 'Low(低)',
18
+ level_medium: 'Medium(默认)',
19
+ level_high: 'High(高)',
20
+ maxTokensLabel: '单次流式最大输出(Max Output Tokens)',
21
+ maxTokensHint: '官方单次流式请求上限为 65,536 tokens(含思考与正文输出),这是上限而非固定消耗。',
22
+ contextWindowLabel: '共享上下文窗口(Context Window)',
23
+ contextWindowHint: '官方总窗口为 1,048,576 tokens,由输入、思考和输出共同共享。',
24
+ resetDefaults: '恢复官方默认配置',
25
+ saving: '保存中…',
26
+ saved: '已保存并实时生效',
27
+ error: '保存失败,请重试。',
28
+ loading: '正在读取配置…',
29
+ unavailable: '当前连接无法修改宿主设置。',
30
+ how: '自动检测与使用方法',
31
+ step1: '自动检测:只要在 DSH「设置 → 模型」的 Google(Gemini API)或 Google Vertex AI 中添加了 gemini-4-argon,本插件分组下就会自动出现对应的「Gemini 4 Argon (Vertex AI)」与「Gemini 4 Argon (Gemini API)」。',
32
+ step2: '凭据复用:Vertex AI 通道自动读取 Windows 环境变量(GOOGLE_APPLICATION_CREDENTIALS / GOOGLE_CLOUD_PROJECT / GOOGLE_CLOUD_LOCATION);Gemini API 通道自动复用 Google 提供商配置的 GOOGLE_API_KEY。',
33
+ step3: '在会话模型选择器中选择 Vertex Argon 分组下的对应模型,即可正常切换 Low / Medium / High 三档并查看思维链与工具调用卡片。',
34
+ scope: '通道特性与双保险',
35
+ detail: '本插件不仅在 Vertex Argon 分组下提供完整支持 thought: true 思考摘要与 thoughtSignature 签名回传的模型入口,还同时为原生的 google 与 google-vertex 路由注入了 Gemini 4 thinkingLevel 兼容补丁,即使误选原分组条目也不会再报 thinkingBudget 400 错误。',
36
+ route: '提供方路由:google-vertex-argon · 模型 ID:gemini-4-argon (Vertex AI) / gemini-4-argon-google (Gemini API)',
37
+ },
38
+ en: {
39
+ title: 'Vertex Argon',
40
+ subtitle: 'Auto-detected Vertex AI & Gemini API Argon routes · native thinking levels & signed tool replay',
41
+ show: 'Show Vertex Argon group in the model picker',
42
+ showHint: 'Controls whether Vertex Argon models appear in the model picker. Active conversations are unaffected.',
43
+ visible: 'Visible',
44
+ hidden: 'Hidden',
45
+ reasoningLabel: 'Default Thinking Level',
46
+ reasoningHint: 'Supports official LOW, MEDIUM (default), and HIGH levels via native thinkingLevel with includeThoughts: true. Never sends thinkingBudget.',
47
+ level_low: 'Low',
48
+ level_medium: 'Medium (Default)',
49
+ level_high: 'High',
50
+ maxTokensLabel: 'Single-Request Max Output Tokens',
51
+ maxTokensHint: 'Official per-request streaming cap is 65,536 tokens (thinking + response combined).',
52
+ contextWindowLabel: 'Shared Context Window',
53
+ contextWindowHint: 'Official 1,048,576-token window shared across input, thinking, and output tokens.',
54
+ resetDefaults: 'Restore Official Defaults',
55
+ saving: 'Saving…',
56
+ saved: 'Saved and applied live',
57
+ error: 'Could not save. Please retry.',
58
+ loading: 'Loading configuration…',
59
+ unavailable: 'This connection cannot edit Host settings.',
60
+ how: 'Auto-detection & usage',
61
+ step1: 'Auto-detection: When gemini-4-argon is configured under Google (Gemini API) or Google Vertex AI in Models settings, this plugin automatically lists "Gemini 4 Argon (Vertex AI)" and/or "Gemini 4 Argon (Gemini API)".',
62
+ step2: 'Credential reuse: Vertex AI uses GOOGLE_APPLICATION_CREDENTIALS / GOOGLE_CLOUD_PROJECT / GOOGLE_CLOUD_LOCATION; Gemini API reuses your configured GOOGLE_API_KEY.',
63
+ step3: 'Select either model under Vertex Argon in the model picker for full Low / Medium / High thinking summaries and tool calls.',
64
+ scope: 'Scope & fallback protection',
65
+ detail: 'In addition to the dedicated Vertex Argon group, this plugin patches native google and google-vertex Gemini 4 requests so selecting the original entries also sends thinkingLevel instead of thinkingBudget.',
66
+ route: 'Provider route: google-vertex-argon · Models: gemini-4-argon (Vertex AI) / gemini-4-argon-google (Gemini API)',
67
+ },
68
+ }
69
+
70
+ function installAdjacentPicker(ctx) {
71
+ const slot = 'conversation.input.model'
72
+ const lenses = new WeakMap()
73
+ function lens(source) {
74
+ if (lenses.has(source)) return lenses.get(source)
75
+ let previous; let projected
76
+ const view = {
77
+ subscribe: listener => source.subscribe(listener),
78
+ getSnapshot() {
79
+ const state = source.getSnapshot()
80
+ if (state === previous) return projected
81
+ previous = state; projected = state
82
+ const groups = state?.groups
83
+ if (!Array.isArray(groups)) return projected
84
+ const native = groups.findIndex(group => group.id === 'google-vertex')
85
+ const argon = groups.findIndex(group => group.id === 'google-vertex-argon')
86
+ if (native < 0 || argon < 0 || argon === native + 1) return projected
87
+ const rest = groups.filter(group => group.id !== 'google-vertex-argon')
88
+ const at = rest.findIndex(group => group.id === 'google-vertex') + 1
89
+ projected = { ...state, groups: [...rest.slice(0, at), groups[argon], ...rest.slice(at)] }
90
+ return projected
91
+ },
92
+ }
93
+ lenses.set(source, view)
94
+ return view
95
+ }
96
+ function OrderedPicker({ originalComponent, ...props }) { return h(originalComponent, props) }
97
+ return ctx.slots.inject(slot, () => {
98
+ let original; let stop = () => {}; let updating = false; let disposed = false
99
+ const sync = () => {
100
+ if (updating || disposed) return
101
+ const others = ctx.slots.entries(slot).filter(entry => entry.component !== OrderedPicker)
102
+ const candidate = others.length === 1 ? others[0] : undefined
103
+ const next = candidate?.locale === 'model' && typeof candidate.inject === 'function' &&
104
+ (candidate.options.priority ?? 0) === 0 && !candidate.children && !candidate.store ? candidate : undefined
105
+ if (next === original) return
106
+ updating = true
107
+ try {
108
+ stop(); stop = () => {}; original = next
109
+ if (next) stop = ctx.slots.register({
110
+ name: slot, priority: -10, locale: next.locale,
111
+ inject: (...args) => {
112
+ const props = next.inject(...args)
113
+ const source = props.directory
114
+ const directory = source && typeof source.getSnapshot === 'function' && typeof source.subscribe === 'function' ? lens(source) : source
115
+ return { ...props, directory, originalComponent: next.component }
116
+ },
117
+ }, OrderedPicker)
118
+ } finally { updating = false }
119
+ }
120
+ const unsubscribe = ctx.slots.subscribe(slot, sync)
121
+ sync()
122
+ return () => { disposed = true; unsubscribe(); stop() }
123
+ })
124
+ }
125
+
126
+ function Settings({ form, t }) {
127
+ const state = React.useSyncExternalStore(listener => form.subscribe(listener), () => form.getSnapshot(), () => form.getSnapshot())
128
+ const [pending, setPending] = React.useState(false)
129
+ const [notice, setNotice] = React.useState('')
130
+ const val = state.value || {}
131
+ const visible = val.showInModelPicker !== false
132
+ const reasoning = val.reasoning || 'medium'
133
+ const maxTokens = val.maxTokens || 65536
134
+ const contextWindow = val.contextWindow || 1048576
135
+ const disabled = pending || state.status !== 'ready' || !state.writable
136
+
137
+ const updateField = async (key, nextVal) => {
138
+ if (disabled) return
139
+ setPending(true); setNotice('')
140
+ try { setNotice(await form.set(key, nextVal) ? 'saved' : 'error') }
141
+ catch { setNotice('error') }
142
+ finally { setPending(false) }
143
+ }
144
+
145
+ const resetAll = async () => {
146
+ if (disabled) return
147
+ setPending(true); setNotice('')
148
+ try {
149
+ const ok1 = await form.set('showInModelPicker', true)
150
+ const ok2 = await form.set('reasoning', 'medium')
151
+ const ok3 = await form.set('maxTokens', 65536)
152
+ const ok4 = await form.set('contextWindow', 1048576)
153
+ setNotice(ok1 && ok2 && ok3 && ok4 ? 'saved' : 'error')
154
+ } catch { setNotice('error') }
155
+ finally { setPending(false) }
156
+ }
157
+
158
+ const fmt = n => Number(n).toLocaleString()
159
+
160
+ return h('section', { className: 'local-vertex-argon', 'aria-label': t('title') },
161
+ h('style', null,
162
+ '.local-vertex-argon{max-width:720px;color:var(--dsw-alias-label-primary);font-size:14px;line-height:1.6}' +
163
+ '.local-vertex-argon h2{font-size:20px;line-height:1.35;margin:0 0 8px;font-weight:600}' +
164
+ '.local-vertex-argon h3{font-size:14px;margin:0 0 8px;font-weight:600}' +
165
+ '.local-vertex-argon p{margin:0 0 12px}.local-vertex-argon .muted{color:var(--dsw-alias-label-secondary)}' +
166
+ '.local-vertex-argon .card{padding:18px 0;border-top:1px solid var(--dsw-alias-border-l1);margin-top:16px}' +
167
+ '.local-vertex-argon .row{display:flex;gap:16px;align-items:center;justify-content:space-between;margin-bottom:8px;flex-wrap:wrap}' +
168
+ '.local-vertex-argon .group{display:flex;gap:8px;flex-wrap:wrap;align-items:center}' +
169
+ '.local-vertex-argon button{font:inherit;flex:none;min-width:72px;padding:6px 14px;border:1px solid var(--dsw-alias-border-l2);border-radius:8px;background:var(--dsw-alias-bg-layer-1);color:var(--dsw-alias-label-primary);cursor:pointer;transition:background .15s,border-color .15s}' +
170
+ '.local-vertex-argon button:hover:not(:disabled){background:var(--dsw-alias-bg-layer-2)}' +
171
+ '.local-vertex-argon button[aria-pressed="true"],.local-vertex-argon button[aria-checked="true"]{border-color:var(--dsw-alias-brand-primary);font-weight:600;background:var(--dsw-alias-bg-layer-2)}' +
172
+ '.local-vertex-argon button:focus-visible{outline:2px solid var(--dsw-alias-label-primary);outline-offset:2px}' +
173
+ '.local-vertex-argon button:disabled{opacity:.55;cursor:default}' +
174
+ '.local-vertex-argon .status{min-height:22px;font-size:13px;color:var(--dsw-alias-label-secondary);margin-top:6px}' +
175
+ '.local-vertex-argon .status.error{color:var(--dsw-alias-state-error-primary)}' +
176
+ '.local-vertex-argon ol{padding-left:22px;margin:8px 0}.local-vertex-argon li{margin:8px 0}'
177
+ ),
178
+ h('h2', null, t('title')),
179
+ h('p', { className: 'muted' }, t('subtitle')),
180
+ h('div', { className: 'card' },
181
+ h('div', { className: 'row' },
182
+ h('strong', { id: 'vertex-argon-visibility-label' }, t('show')),
183
+ h('button', {
184
+ type: 'button', role: 'switch', 'aria-checked': visible,
185
+ 'aria-labelledby': 'vertex-argon-visibility-label',
186
+ 'aria-describedby': 'vertex-argon-visibility-hint',
187
+ disabled, onClick: () => updateField('showInModelPicker', !visible),
188
+ }, t(pending ? 'saving' : visible ? 'visible' : 'hidden')),
189
+ ),
190
+ h('p', { className: 'muted', id: 'vertex-argon-visibility-hint' }, t('showHint')),
191
+ h('div', { className: 'row', style: { marginTop: '16px' } },
192
+ h('strong', null, t('reasoningLabel')),
193
+ h('div', { className: 'group', role: 'group', 'aria-label': t('reasoningLabel') },
194
+ ...['low', 'medium', 'high'].map(level =>
195
+ h('button', {
196
+ key: level, type: 'button', 'aria-pressed': reasoning === level,
197
+ disabled, onClick: () => updateField('reasoning', level),
198
+ }, t('level_' + level))
199
+ ),
200
+ ),
201
+ ),
202
+ h('p', { className: 'muted' }, t('reasoningHint')),
203
+ ),
204
+ h('div', { className: 'card' },
205
+ h('div', { className: 'row' },
206
+ h('strong', null, t('maxTokensLabel') + ' (' + fmt(maxTokens) + ')'),
207
+ h('div', { className: 'group', role: 'group', 'aria-label': t('maxTokensLabel') },
208
+ ...[8192, 16384, 32768, 65536].map(cap =>
209
+ h('button', {
210
+ key: cap, type: 'button', 'aria-pressed': maxTokens === cap,
211
+ disabled, onClick: () => updateField('maxTokens', cap),
212
+ }, fmt(cap))
213
+ ),
214
+ ),
215
+ ),
216
+ h('p', { className: 'muted' }, t('maxTokensHint')),
217
+ h('div', { className: 'row', style: { marginTop: '16px' } },
218
+ h('strong', null, t('contextWindowLabel') + ' (' + fmt(contextWindow) + ')'),
219
+ h('div', { className: 'group', role: 'group', 'aria-label': t('contextWindowLabel') },
220
+ ...[262144, 524288, 1048576].map(win =>
221
+ h('button', {
222
+ key: win, type: 'button', 'aria-pressed': contextWindow === win,
223
+ disabled, onClick: () => updateField('contextWindow', win),
224
+ }, fmt(win))
225
+ ),
226
+ ),
227
+ ),
228
+ h('p', { className: 'muted' }, t('contextWindowHint')),
229
+ h('div', { className: 'row', style: { marginTop: '12px' } },
230
+ h('span', {
231
+ className: 'status' + (notice === 'error' ? ' error' : ''),
232
+ role: notice === 'error' ? 'alert' : 'status', 'aria-live': 'polite',
233
+ }, state.status === 'loading' ? t('loading') : state.status === 'unavailable' ? t('unavailable') : notice ? t(notice) : ''),
234
+ h('button', { type: 'button', disabled, onClick: resetAll }, t('resetDefaults')),
235
+ ),
236
+ ),
237
+ h('div', { className: 'card' },
238
+ h('h3', null, t('how')),
239
+ h('ol', null, ...['step1', 'step2', 'step3'].map(key => h('li', { key }, t(key)))),
240
+ ),
241
+ h('div', { className: 'card' },
242
+ h('h3', null, t('scope')),
243
+ h('p', null, t('detail')),
244
+ h('p', { className: 'muted' }, t('route')),
245
+ ),
246
+ )
247
+ }
248
+
249
+ return {
250
+ inject: ['slots', 'locale', 'configForms'],
251
+ apply(ctx) {
252
+ ctx.effect(() => ctx.locale.register(ns, dictionaries), 'vertex-argon: locale')
253
+ const form = ctx.configForms.get('local-vertex-argon')
254
+ ctx.effect(() => installAdjacentPicker(ctx), 'vertex-argon: adjacent model picker')
255
+ ctx.effect(() => ctx.configForms.whileServed(['local-vertex-argon'], () =>
256
+ ctx.slots.inject('settings.section', () => ctx.slots.register({
257
+ name: 'settings.section', id: 'local-vertex-argon', order: 36,
258
+ label: () => ctx.locale.bind(ns)('title'), locale: ns, inject: () => ({ form }),
259
+ }, Settings)),
260
+ ), 'vertex-argon: settings section')
261
+ },
262
+ }
263
+ },
264
+ })
@@ -0,0 +1,3 @@
1
+ - insert:
2
+ - id: local-vertex-argon
3
+ name: './index.js'
package/icon.svg ADDED
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64"><rect width="64" height="64" rx="16" fill="#182232"/><polygon points="32,10 51,21 51,43 32,54 13,43 13,21" fill="none" stroke="#4da3ff" stroke-width="3.5" stroke-linejoin="round"/><path d="M32 17 C33.8 25.5 38.5 30.2 47 32 C38.5 33.8 33.8 38.5 32 47 C30.2 38.5 25.5 33.8 17 32 C25.5 30.2 30.2 25.5 32 17 Z" fill="#8ab4f8"/></svg>
package/index.js ADDED
@@ -0,0 +1,69 @@
1
+ import { shared } from './runtime.js'
2
+ const { default: z } = await shared('@deepseek-ai/schemastery')
3
+ import { createArgonAdapter, installGemini4PiAiPatch, resolveConfigValues, detectPiAiArgonRoutes, PROVIDER, NATIVE_PROVIDER, LEVELS } from './adapter.js'
4
+
5
+ export const name = 'local-vertex-argon'
6
+ export const inject = ['llm']
7
+ export const Config = z.object({
8
+ showInModelPicker: z.boolean().default(true).volatile(),
9
+ reasoning: z.union(LEVELS).default('medium').volatile(),
10
+ contextWindow: z.number().step(1).min(1).max(1048576).default(1048576).volatile(),
11
+ maxTokens: z.number().step(1).min(1).max(65536).default(65536).volatile(),
12
+ })
13
+
14
+ export function apply(ctx, config) {
15
+ const adapter = createArgonAdapter(ctx, () => config)
16
+ const unpatchPiAi = installGemini4PiAiPatch()
17
+ const registration = ctx.llm.registerAdapter([PROVIDER], adapter)
18
+ ctx.effect(() => () => {
19
+ unpatchPiAi()
20
+ registration?.()
21
+ })
22
+ if (typeof ctx.on === 'function') {
23
+ ctx.on('agent/request', async (_payload, next) => {
24
+ const proposed = await next()
25
+ if (
26
+ (proposed?.provider === PROVIDER ||
27
+ ((proposed?.provider === 'google' || proposed?.provider === 'google-vertex') &&
28
+ /^(?:models\/)?gemini-4\b/i.test(proposed?.model ?? ''))) &&
29
+ proposed.reasoningEffort === 'max'
30
+ ) {
31
+ return { ...proposed, reasoningEffort: 'high' }
32
+ }
33
+ return proposed
34
+ })
35
+ let moving = false
36
+ let lastRoutesSnap = JSON.stringify(detectPiAiArgonRoutes(ctx))
37
+ const followNativeAndSync = () => {
38
+ if (moving || typeof ctx.llm.listProviders !== 'function') return
39
+ const nextRoutesSnap = JSON.stringify(detectPiAiArgonRoutes(ctx))
40
+ const routesChanged = nextRoutesSnap !== lastRoutesSnap
41
+ lastRoutesSnap = nextRoutesSnap
42
+ const ids = ctx.llm.listProviders().map(p => p.id)
43
+ const nativeIdx = ids.indexOf(NATIVE_PROVIDER)
44
+ const argonIdx = ids.indexOf(PROVIDER)
45
+ const needsMove = nativeIdx >= 0 && argonIdx >= 0 && argonIdx < nativeIdx
46
+ if (!needsMove && !routesChanged) return
47
+ moving = true
48
+ try {
49
+ registration?.replace?.([PROVIDER])
50
+ } finally {
51
+ moving = false
52
+ }
53
+ }
54
+ ctx.on('llm/adapters-updated', followNativeAndSync)
55
+ ctx.on('settings/document-updated', followNativeAndSync)
56
+ followNativeAndSync()
57
+ let lastSnap = JSON.stringify(resolveConfigValues(config))
58
+ ctx.on('loader/volatile-update', () => {
59
+ const nextSnap = JSON.stringify(resolveConfigValues(config))
60
+ if (nextSnap === lastSnap) return
61
+ lastSnap = nextSnap
62
+ if (typeof registration?.replace === 'function') registration.replace([PROVIDER])
63
+ else ctx.emit?.('llm/adapters-updated')
64
+ })
65
+ }
66
+ ctx.inject?.(['settings'], settingsCtx => {
67
+ settingsCtx.effect(() => settingsCtx.settings.configure({ auto: false }, ctx.fiber), 'vertex-argon: dedicated settings page')
68
+ })
69
+ }
package/locale/en.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "meta": {
3
+ "title": "Vertex Argon",
4
+ "description": "Native Low / Medium / High thinking levels, thought summaries, signed tool replay, and dedicated settings page."
5
+ }
6
+ }
package/locale/zh.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "meta": {
3
+ "title": "Vertex Argon",
4
+ "description": "原生 Low / Medium / High 三档思考、思考摘要与工具调用签名回传;含专属设置页。"
5
+ }
6
+ }
package/package.json CHANGED
@@ -1,6 +1,90 @@
1
1
  {
2
2
  "name": "dsh-vertex-argon",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "1.1.2",
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
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/higekibaka/dsh-vertex-argon.git"
9
+ },
10
+ "bugs": "https://github.com/higekibaka/dsh-vertex-argon/issues",
11
+ "homepage": "https://github.com/higekibaka/dsh-vertex-argon#readme",
12
+ "type": "module",
13
+ "main": "index.js",
14
+ "icon": "./icon.svg",
15
+ "exports": {
16
+ ".": "./index.js",
17
+ "./client": "./client.js",
18
+ "./cordis.patch.yml": "./cordis.patch.yml",
19
+ "./package.json": "./package.json",
20
+ "./locale/*.json": "./locale/*.json"
21
+ },
22
+ "files": [
23
+ "LICENSE",
24
+ "README.md",
25
+ "runtime.js",
26
+ "index.js",
27
+ "adapter.js",
28
+ "client.js",
29
+ "icon.svg",
30
+ "cordis.patch.yml",
31
+ "locale"
32
+ ],
33
+ "engines": {
34
+ "node": "^22.19.0 || >=24.0.0"
35
+ },
36
+ "keywords": [
37
+ "deepseek-harness",
38
+ "dsh",
39
+ "dsh-plugin",
40
+ "vertex-ai",
41
+ "gemini",
42
+ "gemini-4-argon",
43
+ "plugin"
44
+ ],
45
+ "dsh": {
46
+ "engines": {
47
+ "dsh": "0.1.7-rc.2 || 0.2.0-rc.1 || 0.2.0-rc.2"
48
+ },
49
+ "bundle": {
50
+ "patch": "./cordis.patch.yml"
51
+ },
52
+ "client": {
53
+ "platform": "web",
54
+ "immediately": true,
55
+ "inject": [
56
+ "@deepseek-ai/dsh-client-ui-settings",
57
+ "@deepseek-ai/dsh-client-locale",
58
+ "@deepseek-ai/dsh-client-ui-model-selection"
59
+ ]
60
+ }
61
+ },
62
+ "peerDependencies": {
63
+ "@deepseek-ai/dsh-llm": ">=0.1.7-rc.2",
64
+ "@deepseek-ai/dsh-llm-pi-ai": ">=0.1.7-rc.2",
65
+ "@deepseek-ai/dsh-launch-environment": ">=0.1.7-rc.2",
66
+ "@deepseek-ai/schemastery": "^3.18.4",
67
+ "@earendil-works/pi-ai": "0.85.1 || 0.87.1"
68
+ },
69
+ "peerDependenciesMeta": {
70
+ "@deepseek-ai/dsh-llm": {
71
+ "optional": true
72
+ },
73
+ "@deepseek-ai/dsh-llm-pi-ai": {
74
+ "optional": true
75
+ },
76
+ "@deepseek-ai/dsh-launch-environment": {
77
+ "optional": true
78
+ },
79
+ "@deepseek-ai/schemastery": {
80
+ "optional": true
81
+ },
82
+ "@earendil-works/pi-ai": {
83
+ "optional": true
84
+ }
85
+ },
86
+ "publishConfig": {
87
+ "access": "public",
88
+ "registry": "https://registry.npmjs.org/"
89
+ }
90
+ }
package/runtime.js ADDED
@@ -0,0 +1,22 @@
1
+ import { createRequire, findPackageJSON } from 'node:module'
2
+ import { pathToFileURL } from 'node:url'
3
+ import { dirname, resolve } from 'node:path'
4
+
5
+ // DSH desktop hosts plugins outside its ASAR dependency tree. Resolve shared
6
+ // services from the running host entry, never install a second service copy.
7
+ export async function shared(specifier) {
8
+ try { return await import(specifier) }
9
+ catch (error) {
10
+ if (error.code !== 'ERR_MODULE_NOT_FOUND' || !process.argv[1]) throw error
11
+ const host = pathToFileURL(process.argv[1])
12
+ const require = createRequire(host)
13
+ let target
14
+ if (specifier.startsWith('@earendil-works/pi-ai/providers/')) {
15
+ const sub = specifier.slice('@earendil-works/pi-ai/providers/'.length)
16
+ const manifest = findPackageJSON('@earendil-works/pi-ai', host)
17
+ if (!manifest) throw error
18
+ target = resolve(dirname(manifest), 'dist/providers/' + sub + '.js')
19
+ } else target = require.resolve(specifier)
20
+ return import(pathToFileURL(target).href)
21
+ }
22
+ }