@aexol/spectral 0.9.68 → 0.9.70

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.
@@ -1 +1 @@
1
- {"version":3,"file":"spectral-vision-fallback.d.ts","sourceRoot":"","sources":["../../src/extensions/spectral-vision-fallback.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAsWjE,MAAM,CAAC,OAAO,UAAU,uBAAuB,CAAC,GAAG,EAAE,YAAY,GAAG,IAAI,CA6DvE"}
1
+ {"version":3,"file":"spectral-vision-fallback.d.ts","sourceRoot":"","sources":["../../src/extensions/spectral-vision-fallback.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AA2YjE,MAAM,CAAC,OAAO,UAAU,uBAAuB,CAAC,GAAG,EAAE,YAAY,GAAG,IAAI,CA6DvE"}
@@ -204,10 +204,43 @@ async function describeImages(visionModel, content, contextText, ctx) {
204
204
  headers: auth.headers,
205
205
  });
206
206
  let description = "";
207
+ let streamError;
208
+ let finalMessage;
207
209
  for await (const event of result) {
208
210
  if (event.type === "text_delta") {
209
211
  description += event.delta;
210
212
  }
213
+ else if (event.type === "error") {
214
+ streamError = event.error.errorMessage || "Unknown stream error";
215
+ finalMessage = event.error;
216
+ }
217
+ else if (event.type === "done") {
218
+ finalMessage = event.message;
219
+ }
220
+ }
221
+ // If no text_delta events were emitted, try extracting text from the final message
222
+ if (!description.trim() && finalMessage) {
223
+ const textBlocks = finalMessage.content
224
+ .filter((b) => b.type === "text")
225
+ .map((b) => b.text)
226
+ .join("");
227
+ if (textBlocks.trim()) {
228
+ description = textBlocks;
229
+ }
230
+ }
231
+ // If the stream errored, throw with the actual error so the caller can retry/fallback
232
+ if (streamError) {
233
+ throw new Error(`Vision model ${model.provider}/${model.id} stream error: ${streamError}`);
234
+ }
235
+ // If the final message has an error stop reason, throw
236
+ if (finalMessage && finalMessage.stopReason === "error" && finalMessage.errorMessage) {
237
+ throw new Error(`Vision model ${model.provider}/${model.id} error: ${finalMessage.errorMessage}`);
238
+ }
239
+ if (!description.trim()) {
240
+ process.stderr.write(`[${EXTENSION_NAME}] WARNING: Vision model ${model.provider}/${model.id} returned empty analysis. ` +
241
+ `stopReason=${finalMessage?.stopReason ?? "unknown"}, ` +
242
+ `contentBlocks=${finalMessage?.content?.length ?? 0}, ` +
243
+ `usage(input=${finalMessage?.usage?.input ?? 0}, output=${finalMessage?.usage?.output ?? 0}).\n`);
211
244
  }
212
245
  const textNote = description.trim()
213
246
  ? `[Image analysis from ${model.provider}/${model.id} (${imageCount} image(s)):\n${description.trim()}\n]`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aexol/spectral",
3
- "version": "0.9.68",
3
+ "version": "0.9.70",
4
4
  "description": "AI coding agent for Aexol with relay-based browser access.",
5
5
  "type": "module",
6
6
  "private": false,