dsh-vertex-argon 1.6.4 → 2.0.0

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/adapter.js CHANGED
@@ -23,29 +23,16 @@ export const PROVIDER = 'google-vertex-argon'
23
23
  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
- 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)
26
+ export const CARBON_MODEL = 'gemini-4-carbon'
27
+ export const GOOGLE_API_CARBON_MODEL = 'gemini-4-carbon-google'
28
+ /** Gemini API 官方直连模型判定(Argon 与 Carbon)。 */
29
+ export function isGoogleApiModel(modelId) {
30
+ return modelId === GOOGLE_API_MODEL || modelId === GOOGLE_API_CARBON_MODEL
38
31
  }
39
- /** 反代模型对应的上游基础 ID;档位后缀由 resolveProxyUpstreamModel 追加。 */
40
- export function proxyUpstreamBaseModel(modelId) {
41
- return modelId === PROXY_FLASH_MODEL ? FLASH_UPSTREAM_MODEL : MODEL
32
+ /** 官方直连(Vertex AI / Gemini API)对应的上游模型 ID。 */
33
+ export function officialUpstreamModel(modelId) {
34
+ return modelId === CARBON_MODEL || modelId === GOOGLE_API_CARBON_MODEL ? CARBON_MODEL : MODEL
42
35
  }
43
- /** 反代上游模型 ID:`<基础 ID>-<low|medium|high>`,与反代暴露的档位模型一一对应。 */
44
- export function resolveProxyUpstreamModel(modelId, level) {
45
- return `${proxyUpstreamBaseModel(modelId)}-${level}`
46
- }
47
- export const PROXY_API_KEY_ENV = 'ANTIGRAVITY_API_KEY'
48
- export const DEFAULT_PROXY_BASE_URL = 'http://127.0.0.1:8045/v1beta'
49
36
  export const LEVELS = ['low', 'medium', 'high']
50
37
  export const MAX_SINGLE_CALL_TOKENS = 65536
51
38
  export const MAX_LONG_DECODE_TOKENS = 1048576
@@ -53,18 +40,18 @@ const COMPACTION_HEADROOM_FLOOR = 131072
53
40
  const ENV_KEYS = ['GOOGLE_APPLICATION_CREDENTIALS', 'GOOGLE_CLOUD_PROJECT', 'GCLOUD_PROJECT', 'GOOGLE_CLOUD_LOCATION', 'GOOGLE_CLOUD_API_KEY']
54
41
  const DEFAULT_THINKING_MAP = { off: null, minimal: null, low: 'low', medium: 'medium', high: 'high', xhigh: null, max: null }
55
42
 
56
- const readVal = v => (v && typeof v === 'object' && typeof v.get === 'function') ? v.get() : v
57
-
58
- export function normalizeProxyBaseUrl(raw) {
59
- const value = typeof raw === 'string' ? raw.trim() : raw
60
- if (value != null && typeof value !== 'string') throw new LlmError('Antigravity proxy base URL must be a string.', 'INVALID_CONFIG')
61
- let url
62
- try { url = new URL(value || DEFAULT_PROXY_BASE_URL) } catch { throw new LlmError('Antigravity proxy base URL must be a valid HTTP(S) URL.', 'INVALID_CONFIG') }
63
- if (!['http:', 'https:'].includes(url.protocol)) throw new LlmError('Antigravity proxy base URL must use HTTP or HTTPS.', 'INVALID_CONFIG')
64
- url.pathname = (!url.pathname || url.pathname === '/') ? '/v1beta' : url.pathname.replace(/[/]+$/, '')
65
- return url.href
43
+ // The host's agent/request hook already narrows 'max' to 'high'. Direct adapter
44
+ // callers (advisor tools calling adapter.stream / prepareCall().stream) bypass
45
+ // that hook, so the same narrowing has to happen at this boundary too.
46
+ export function narrowMaxReasoning(options) {
47
+ if (!options || typeof options !== 'object') return options
48
+ const requested = [options.reasoning, options.reasoningEffort]
49
+ if (!requested.some(value => typeof value === 'string' && value.toLowerCase() === 'max')) return options
50
+ return { ...options, reasoning: 'high', reasoningEffort: 'high' }
66
51
  }
67
52
 
53
+ const readVal = v => (v && typeof v === 'object' && typeof v.get === 'function') ? v.get() : v
54
+
68
55
  export function isGemini4Model(model) {
69
56
  return Boolean(
70
57
  model &&
@@ -76,16 +63,26 @@ export function isGemini4Model(model) {
76
63
 
77
64
  function googleKeyEnvironment(value) {
78
65
  const name = typeof value === 'string' ? value.trim() : ''
79
- // The proxy credential namespace is reserved, including Windows case aliases.
80
- return !name || name.toUpperCase() === PROXY_API_KEY_ENV ? 'GOOGLE_API_KEY' : name
66
+ return name || 'GOOGLE_API_KEY'
81
67
  }
82
68
 
83
69
  export function detectPiAiArgonRoutes(ctx, explicitRoutes) {
84
70
  if (explicitRoutes && typeof explicitRoutes === 'object') {
71
+ const hasVertexCarbon = Boolean(explicitRoutes.hasVertexCarbon)
72
+ const hasGoogleCarbon = Boolean(explicitRoutes.hasGoogleCarbon)
73
+ const hasVertexArgon = explicitRoutes.hasVertexArgon !== undefined
74
+ ? Boolean(explicitRoutes.hasVertexArgon)
75
+ : explicitRoutes.hasVertex !== false
76
+ const hasGoogleArgon = explicitRoutes.hasGoogleArgon !== undefined
77
+ ? Boolean(explicitRoutes.hasGoogleArgon)
78
+ : Boolean(explicitRoutes.hasGoogle)
85
79
  return {
86
- hasVertex: explicitRoutes.hasVertex !== false,
87
- hasGoogle: Boolean(explicitRoutes.hasGoogle),
88
- hasProxy: explicitRoutes.hasProxy === true,
80
+ hasVertex: hasVertexArgon || hasVertexCarbon,
81
+ hasGoogle: hasGoogleArgon || hasGoogleCarbon,
82
+ hasVertexArgon,
83
+ hasGoogleArgon,
84
+ hasVertexCarbon,
85
+ hasGoogleCarbon,
89
86
  googleApiKeyEnv: googleKeyEnvironment(explicitRoutes.googleApiKeyEnv),
90
87
  googleBaseUrl: explicitRoutes.googleBaseUrl,
91
88
  vertexBaseUrl: explicitRoutes.vertexBaseUrl,
@@ -98,19 +95,37 @@ export function detectPiAiArgonRoutes(ctx, explicitRoutes) {
98
95
  const providers = readVal(entry?.fiber?.config?.providers) ?? readVal(entry?.options?.config?.providers) ?? {}
99
96
  const googleCfg = providers?.google
100
97
  const vertexCfg = providers?.['google-vertex']
101
- const hasModel = list => Array.isArray(list) && list.some(m => /^(?:models\/)?gemini-4-argon\b/i.test(String(readVal(m?.id) ?? '')))
102
- const hasGoogle = hasModel(readVal(googleCfg?.models))
103
- const hasVertex = hasModel(readVal(vertexCfg?.models))
98
+ const hasModel = (list, re) => Array.isArray(list) && list.some(m => re.test(String(readVal(m?.id) ?? '')))
99
+ const googleModels = readVal(googleCfg?.models)
100
+ const vertexModels = readVal(vertexCfg?.models)
101
+ const hasGoogleArgon = hasModel(googleModels, /^(?:models\/)?gemini-4-argon\b/i)
102
+ const hasVertexArgon = hasModel(vertexModels, /^(?:models\/)?gemini-4-argon\b/i)
103
+ const hasGoogleCarbon = hasModel(googleModels, /^(?:models\/)?gemini-4-carbon\b/i)
104
+ const hasVertexCarbon = hasModel(vertexModels, /^(?:models\/)?gemini-4-carbon\b/i)
105
+ const hasGoogle = hasGoogleArgon || hasGoogleCarbon
106
+ const hasVertex = hasVertexArgon || hasVertexCarbon || !hasGoogle
104
107
  return {
105
- hasVertex: hasVertex || !hasGoogle,
108
+ hasVertex,
106
109
  hasGoogle,
110
+ hasVertexArgon: hasVertexArgon || (!hasGoogle && !hasVertexCarbon),
111
+ hasGoogleArgon,
112
+ hasVertexCarbon,
113
+ hasGoogleCarbon,
107
114
  googleApiKeyEnv: googleKeyEnvironment(readVal(googleCfg?.apiKeyEnv)),
108
115
  googleBaseUrl: readVal(googleCfg?.baseURL),
109
116
  vertexBaseUrl: readVal(vertexCfg?.baseURL),
110
117
  }
111
118
  }
112
119
  } catch {}
113
- return { hasVertex: true, hasGoogle: false, googleApiKeyEnv: 'GOOGLE_API_KEY' }
120
+ return {
121
+ hasVertex: true,
122
+ hasGoogle: false,
123
+ hasVertexArgon: true,
124
+ hasGoogleArgon: false,
125
+ hasVertexCarbon: false,
126
+ hasGoogleCarbon: false,
127
+ googleApiKeyEnv: 'GOOGLE_API_KEY',
128
+ }
114
129
  }
115
130
 
116
131
  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
@@ -251,11 +266,11 @@ export function gemini4StreamSimple(
251
266
  assertPreparedStructuredOutput(structuredOutput)
252
267
  ensureGemini4ApiClientPatch()
253
268
  const fallback = defaultLevel ?? (/cyber-permissive/i.test(requestModel?.id ?? '') ? 'high' : 'medium')
254
- const rawLevel = options.reasoning ?? fallback
269
+ const requestedLevel = options.reasoning ?? fallback
270
+ const rawLevel = typeof requestedLevel === 'string' && requestedLevel.toLowerCase() === 'max' ? 'high' : requestedLevel
255
271
  const mapped = requestModel?.thinkingLevelMap?.[rawLevel] ?? rawLevel
256
272
  const level = typeof mapped === 'string' ? mapped.toLowerCase() : fallback
257
- if (!LEVELS.includes(level)) throw new LlmError('Gemini 4 Argon requires low, medium or high.', 'UNSUPPORTED_REASONING_EFFORT')
258
- const resolvedUpstreamModelId = isProxyModel(requestModel?.id) ? resolveProxyUpstreamModel(requestModel.id, level) : upstreamModelId
273
+ if (!LEVELS.includes(level)) throw new LlmError('Gemini 4 (Argon / Carbon) requires low, medium or high.', 'UNSUPPORTED_REASONING_EFFORT')
259
274
  const { reasoning, thinking, thinkingBudgets, temperature, onPayload: prior, onProviderStreamEvent: priorEvent, ...rest } = options
260
275
  const requestedMaxTokens = options.maxTokens ?? requestModel.maxTokens
261
276
  const effectiveMaxTokens =
@@ -287,10 +302,10 @@ export function gemini4StreamSimple(
287
302
  const replacement = await prior?.(payload, payloadModel)
288
303
  let body = replacement === undefined ? payload : replacement
289
304
  if (!body || typeof body !== 'object' || Array.isArray(body) || !Array.isArray(body.contents) || !body.config || typeof body.config !== 'object' || Array.isArray(body.config)) {
290
- throw new LlmError('Gemini 4 Argon received an incompatible native payload.', 'INVALID_REQUEST')
305
+ throw new LlmError('Gemini 4 received an incompatible native payload.', 'INVALID_REQUEST')
291
306
  }
292
- if (body.model !== requestModel.id && body.model !== upstreamModelId && body.model !== resolvedUpstreamModelId) {
293
- throw new LlmError('Gemini 4 Argon received an incompatible model payload.', 'INVALID_REQUEST')
307
+ if (body.model !== requestModel.id && body.model !== upstreamModelId) {
308
+ throw new LlmError('Gemini 4 received an incompatible model payload.', 'INVALID_REQUEST')
294
309
  }
295
310
  body = signatures.restorePayload(body)
296
311
  if (structuredOutput) body = structuredOutput.generateContent(body)
@@ -302,7 +317,7 @@ export function gemini4StreamSimple(
302
317
  const toolMode = shouldFallbackToAutoToolMode(retryKey) ? 'AUTO' : 'VALIDATED'
303
318
  return {
304
319
  ...body,
305
- model: resolvedUpstreamModelId,
320
+ model: upstreamModelId,
306
321
  config: {
307
322
  ...cleanConfig,
308
323
  ...(cleanConfig.tools?.some(tool => tool.functionDeclarations?.length) ? {
@@ -404,10 +419,6 @@ export function resolveConfigValues(raw = {}) {
404
419
  const googleServiceTier = readVal(source?.googleServiceTier) ?? 'standard'
405
420
  const vertexServiceTier = readVal(source?.vertexServiceTier) ?? 'standard'
406
421
  const vertexPaygoOnly = readVal(source?.vertexPaygoOnly) ?? false
407
- const proxyEnabled = readVal(source?.proxyEnabled) ?? false
408
- const proxyBaseUrl = normalizeProxyBaseUrl(readVal(source?.proxyBaseUrl))
409
- const proxyApiKey = readVal(source?.proxyApiKey) ?? ''
410
- if (typeof proxyEnabled !== 'boolean' || typeof proxyApiKey !== 'string') throw new LlmError('Invalid Antigravity proxy configuration.', 'INVALID_CONFIG')
411
422
  const retainRawResponses = readVal(source?.retainRawResponses) ?? false
412
423
  if (typeof retainRawResponses !== 'boolean') throw new LlmError('Raw response retention consent must be an explicit boolean.', 'INVALID_CONFIG')
413
424
  if (![googleServiceTier, vertexServiceTier].every(tier => SERVICE_TIERS.includes(tier))) throw new LlmError('Invalid Argon service tier.', 'INVALID_CONFIG')
@@ -437,9 +448,6 @@ export function resolveConfigValues(raw = {}) {
437
448
  googleServiceTier,
438
449
  vertexServiceTier,
439
450
  vertexPaygoOnly,
440
- proxyEnabled,
441
- proxyBaseUrl,
442
- proxyApiKey: proxyApiKey.trim(),
443
451
  retainRawResponses,
444
452
  interactionsBackground,
445
453
  allowInteractionStorage,
@@ -447,44 +455,43 @@ export function resolveConfigValues(raw = {}) {
447
455
  }
448
456
  }
449
457
 
450
- /** Serve Vertex AI, Gemini API and isolated Antigravity proxy models in one plugin group. */
458
+ /** Serve the official Vertex AI and Gemini API models in one plugin group. */
451
459
  export function argonProvider(nativeVertex, models, defaultLevel = 'medium', nativeGoogle = googleProvider(), longDecode = true, recordDiagnostic, serviceConfig = {}, responseHub, structuredOutput) {
452
460
  const modelMap = new Map((Array.isArray(models) ? models : [models]).map(m => [m.id, m]))
453
461
  return {
454
462
  id: PROVIDER,
455
- name: 'Vertex Argon',
463
+ name: 'Gemini 4 Adapter',
456
464
  auth: nativeVertex.auth,
457
465
  getModels: () => [...modelMap.values()],
458
466
  streamSimple(requestModel, context, options = {}) {
459
467
  const configured = modelMap.get(requestModel?.id)
460
468
  if (!configured || requestModel.provider !== PROVIDER) {
461
- throw new LlmError('Vertex Argon only serves configured Gemini 4 Argon routes.', 'UNSUPPORTED_OPTION')
469
+ throw new LlmError('Gemini 4 Adapter only serves configured Gemini 4 routes.', 'UNSUPPORTED_OPTION')
462
470
  }
463
471
  const { env: rawEnv, apiKey: vertexApiKey, ...restOptions } = options
464
472
  const cleanEnv = rawEnv ? { ...rawEnv } : undefined
465
473
  if (cleanEnv) {
466
474
  delete cleanEnv.__GOOGLE_API_KEY__
467
- delete cleanEnv.__ANTIGRAVITY_API_KEY__
468
475
  }
469
476
  if (configured.api === 'google-generative-ai') {
470
- const proxy = isProxyModel(configured.id)
471
- const apiKey = proxy ? rawEnv?.__ANTIGRAVITY_API_KEY__ : rawEnv?.__GOOGLE_API_KEY__
472
- if (!apiKey) throw new LlmError(proxy ? 'Antigravity proxy requires its dedicated API key.' : 'Gemini API credentials are not configured.', 'MISSING_CREDENTIAL')
477
+ const apiKey = rawEnv?.__GOOGLE_API_KEY__
478
+ if (!apiKey) throw new LlmError('Gemini API credentials are not configured.', 'MISSING_CREDENTIAL')
479
+ const policy = resolveServicePolicy(serviceConfig, 'google-generative-ai', 'generate-content')
473
480
  return gemini4StreamSimple(
474
481
  (m, c, o) => nativeGoogle.stream(m, c, o),
475
482
  requestModel,
476
483
  context,
477
484
  { ...restOptions, ...(cleanEnv ? { env: cleanEnv } : {}), ...(apiKey ? { apiKey } : {}), maxTokens: options.maxTokens ?? configured.maxTokens },
478
485
  defaultLevel,
479
- proxy ? proxyUpstreamBaseModel(configured.id) : MODEL,
486
+ officialUpstreamModel(configured.id),
480
487
  longDecode,
481
488
  recordDiagnostic,
482
- resolveServicePolicy(serviceConfig, 'google-generative-ai', 'generate-content'),
489
+ policy,
483
490
  { responseHub, retainRawResponses: serviceConfig.retainRawResponses }, structuredOutput,
484
491
  )
485
492
  }
486
493
  if (requestModel.api !== 'google-vertex') {
487
- throw new LlmError('Vertex Argon only serves google-vertex or google-generative-ai.', 'UNSUPPORTED_OPTION')
494
+ throw new LlmError('Gemini 4 Adapter only serves google-vertex or google-generative-ai.', 'UNSUPPORTED_OPTION')
488
495
  }
489
496
  return gemini4StreamSimple(
490
497
  (m, c, o) => nativeVertex.stream(m, c, o),
@@ -492,7 +499,7 @@ export function argonProvider(nativeVertex, models, defaultLevel = 'medium', nat
492
499
  context,
493
500
  { ...restOptions, ...(cleanEnv ? { env: cleanEnv } : {}), ...(vertexApiKey ? { apiKey: vertexApiKey } : {}), maxTokens: options.maxTokens ?? configured.maxTokens },
494
501
  defaultLevel,
495
- MODEL,
502
+ officialUpstreamModel(configured.id),
496
503
  longDecode,
497
504
  recordDiagnostic,
498
505
  resolveServicePolicy(serviceConfig, 'google-vertex', 'generate-content'),
@@ -515,7 +522,7 @@ export class ArgonAdapter extends LlmAdapter {
515
522
  imageRequestPricing(provider, model) { return this.inner.imageRequestPricing?.(provider, model) }
516
523
  imageRequestTarget(provider, model, image) {
517
524
  const cfg = this.configSnapshot?.()
518
- const protocol = (model === GOOGLE_API_MODEL || isProxyModel(model)) ? cfg?.googleProtocol : cfg?.vertexProtocol
525
+ const protocol = isGoogleApiModel(model) ? cfg?.googleProtocol : cfg?.vertexProtocol
519
526
  if (provider === PROVIDER && protocol === 'interactions' && this.interactionHandler) return interactionImageRequestTarget(image)
520
527
  return this.inner.imageRequestTarget(provider, model, image)
521
528
  }
@@ -526,13 +533,14 @@ export class ArgonAdapter extends LlmAdapter {
526
533
  resolveModel(provider, model, signal) { return this.inner.resolveModel(provider, model, signal) }
527
534
  async prepareCall(provider, model, signal) {
528
535
  const cfg = this.configSnapshot?.()
529
- 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)
536
+ const googleApi = isGoogleApiModel(model)
537
+ const protocol = googleApi ? cfg?.googleProtocol : cfg?.vertexProtocol
538
+ if (provider === PROVIDER && cfg) resolveServicePolicy(cfg, googleApi ? 'google-generative-ai' : 'google-vertex', protocol)
530
539
  const prepared = await this.inner.prepareCall(provider, model, signal)
531
- const protocol = (model === GOOGLE_API_MODEL || isProxyModel(model)) ? cfg?.googleProtocol : cfg?.vertexProtocol
532
540
  if (provider === PROVIDER && protocol === 'interactions' && this.interactionHandler) {
533
- return { model: prepared.model, stream: options => this.interactionHandler(options, cfg) }
541
+ return { model: prepared.model, stream: options => this.interactionHandler(narrowMaxReasoning(options), cfg) }
534
542
  }
535
- return { ...prepared, stream: options => prepared.stream(generateContentHistory(options, model)) }
543
+ return { ...prepared, stream: options => prepared.stream(generateContentHistory(narrowMaxReasoning(options), model)) }
536
544
  }
537
545
  async *stream(options) {
538
546
  const prepared = await this.prepareCall(options.provider, options.model, options.signal)
@@ -592,12 +600,12 @@ export function createArgonAdapter(ctx, configInput, nativeVertex = googleVertex
592
600
  vt: cfg.vertexServiceTier,
593
601
  paygo: cfg.vertexPaygoOnly,
594
602
  raw: cfg.retainRawResponses,
595
- pe: cfg.proxyEnabled,
596
- pb: cfg.proxyBaseUrl,
597
- pk: cfg.proxyApiKey,
598
- p: detected.hasProxy,
599
603
  v: detected.hasVertex,
600
604
  g: detected.hasGoogle,
605
+ va: detected.hasVertexArgon,
606
+ ga: detected.hasGoogleArgon,
607
+ vc: detected.hasVertexCarbon,
608
+ gc: detected.hasGoogleCarbon,
601
609
  ge: detected.googleApiKeyEnv,
602
610
  gb: detected.googleBaseUrl,
603
611
  vb: detected.vertexBaseUrl,
@@ -617,21 +625,19 @@ export function createArgonAdapter(ctx, configInput, nativeVertex = googleVertex
617
625
  (await input.ctx.env(detected.googleApiKeyEnv || 'GOOGLE_API_KEY')) ??
618
626
  (await input.ctx.env('GOOGLE_API_KEY')) ??
619
627
  (await input.ctx.env('GEMINI_API_KEY'))
620
- const proxyKey = cfg.proxyApiKey || await input.ctx.env(PROXY_API_KEY_ENV)
621
628
  if (googleKey) env.__GOOGLE_API_KEY__ = googleKey
622
- if (proxyKey) env.__ANTIGRAVITY_API_KEY__ = proxyKey
623
629
  if (vertexRes) {
624
630
  return { ...vertexRes, env: { ...env, ...vertexRes.env } }
625
631
  }
626
- if (googleKey || proxyKey) {
627
- return { auth: {}, env, source: googleKey ? (detected.googleApiKeyEnv || 'GOOGLE_API_KEY') : PROXY_API_KEY_ENV }
632
+ if (googleKey) {
633
+ return { auth: {}, env, source: detected.googleApiKeyEnv || 'GOOGLE_API_KEY' }
628
634
  }
629
635
  return undefined
630
636
  },
631
637
  },
632
638
  }
633
639
  const models = []
634
- if (detected.hasVertex) {
640
+ if (detected.hasVertexArgon ?? detected.hasVertex) {
635
641
  models.push({
636
642
  id: MODEL,
637
643
  name: detected.hasGoogle ? 'Gemini 4 Argon (Vertex AI)' : 'Gemini 4 Argon',
@@ -646,13 +652,13 @@ export function createArgonAdapter(ctx, configInput, nativeVertex = googleVertex
646
652
  cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
647
653
  })
648
654
  }
649
- if (detected.hasGoogle) {
655
+ if (detected.hasVertexCarbon) {
650
656
  models.push({
651
- id: GOOGLE_API_MODEL,
652
- name: 'Gemini 4 Argon (Gemini API)',
657
+ id: CARBON_MODEL,
658
+ name: detected.hasGoogle ? 'Gemini 4 Carbon (Vertex AI)' : 'Gemini 4 Carbon',
653
659
  provider: PROVIDER,
654
- api: 'google-generative-ai',
655
- baseUrl: detected.googleBaseUrl || 'https://generativelanguage.googleapis.com/v1beta',
660
+ api: 'google-vertex',
661
+ baseUrl: detected.vertexBaseUrl || 'https://{location}-aiplatform.googleapis.com',
656
662
  reasoning: true,
657
663
  input: ['text', 'image'],
658
664
  contextWindow: cfg.contextWindow,
@@ -661,13 +667,13 @@ export function createArgonAdapter(ctx, configInput, nativeVertex = googleVertex
661
667
  cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
662
668
  })
663
669
  }
664
- if (cfg.proxyEnabled || detected.hasProxy) {
670
+ if (detected.hasGoogleArgon ?? detected.hasGoogle) {
665
671
  models.push({
666
- id: PROXY_MODEL,
667
- name: PROXY_MODEL_NAMES[PROXY_MODEL],
672
+ id: GOOGLE_API_MODEL,
673
+ name: 'Gemini 4 Argon (Gemini API)',
668
674
  provider: PROVIDER,
669
675
  api: 'google-generative-ai',
670
- baseUrl: cfg.proxyBaseUrl,
676
+ baseUrl: detected.googleBaseUrl || 'https://generativelanguage.googleapis.com/v1beta',
671
677
  reasoning: true,
672
678
  input: ['text', 'image'],
673
679
  contextWindow: cfg.contextWindow,
@@ -675,12 +681,14 @@ export function createArgonAdapter(ctx, configInput, nativeVertex = googleVertex
675
681
  thinkingLevelMap: { ...DEFAULT_THINKING_MAP },
676
682
  cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
677
683
  })
684
+ }
685
+ if (detected.hasGoogleCarbon) {
678
686
  models.push({
679
- id: PROXY_FLASH_MODEL,
680
- name: PROXY_MODEL_NAMES[PROXY_FLASH_MODEL],
687
+ id: GOOGLE_API_CARBON_MODEL,
688
+ name: 'Gemini 4 Carbon (Gemini API)',
681
689
  provider: PROVIDER,
682
690
  api: 'google-generative-ai',
683
- baseUrl: cfg.proxyBaseUrl,
691
+ baseUrl: detected.googleBaseUrl || 'https://generativelanguage.googleapis.com/v1beta',
684
692
  reasoning: true,
685
693
  input: ['text', 'image'],
686
694
  contextWindow: cfg.contextWindow,
@@ -694,10 +702,10 @@ export function createArgonAdapter(ctx, configInput, nativeVertex = googleVertex
694
702
  cachedKey = key
695
703
  cachedProfiles = new Map([[PROVIDER, {
696
704
  provider: PROVIDER,
697
- displayName: 'Vertex Argon',
705
+ displayName: 'Gemini 4 Adapter',
698
706
  piProvider: provider,
699
707
  reasoning: cfg.reasoning,
700
- streamIdleTimeoutMs: cfg.longDecode ? STREAM_READ_TIMEOUT_MS + 60000 : 300000,
708
+ streamIdleTimeoutMs: cfg.longDecode ? STREAM_READ_TIMEOUT_MS + 60000 : STREAM_READ_TIMEOUT_MS,
701
709
  maxRequestImageBytes: 20 * 1024 * 1024,
702
710
  requestImagePixelBudget: 2048 * 2048,
703
711
  requestImageMaxBytes: 1024 * 1024,