dsh-vertex-argon 1.1.3 → 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.
Files changed (2) hide show
  1. package/adapter.js +25 -2
  2. package/package.json +1 -1
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",
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": {