@link-assistant/agent 0.12.1 → 0.12.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@link-assistant/agent",
3
- "version": "0.12.1",
3
+ "version": "0.12.3",
4
4
  "description": "A minimal, public domain AI CLI agent compatible with OpenCode's JSON interface. Bun-only runtime.",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -1,6 +1,11 @@
1
1
  import type { ModelsDev } from '../provider/models';
2
2
  import { MessageV2 } from './message-v2';
3
- import { type StreamTextResult, type Tool as AITool, APICallError } from 'ai';
3
+ import {
4
+ type StreamTextResult,
5
+ type Tool as AITool,
6
+ APICallError,
7
+ JSONParseError,
8
+ } from 'ai';
4
9
  import { Log } from '../util/log';
5
10
  import { Identifier } from '../id/id';
6
11
  import { Session } from '.';
@@ -205,6 +210,22 @@ export namespace SessionProcessor {
205
210
  break;
206
211
  }
207
212
  case 'error':
213
+ // Skip stream parse errors (malformed SSE from gateway/provider)
214
+ // The AI SDK emits these as error events but continues the stream.
215
+ // Following OpenAI Codex pattern: log and skip bad events.
216
+ // See: https://github.com/link-assistant/agent/issues/169
217
+ if (JSONParseError.isInstance(value.error)) {
218
+ log.warn(() => ({
219
+ message:
220
+ 'skipping malformed SSE event (stream parse error)',
221
+ errorName: (value.error as Error)?.name,
222
+ errorMessage: (value.error as Error)?.message?.substring(
223
+ 0,
224
+ 200
225
+ ),
226
+ }));
227
+ continue;
228
+ }
208
229
  throw value.error;
209
230
 
210
231
  case 'start-step':
@@ -364,7 +385,7 @@ export namespace SessionProcessor {
364
385
  providerID: input.providerID,
365
386
  });
366
387
 
367
- // Check if error is retryable (APIError, SocketConnectionError, or TimeoutError)
388
+ // Check if error is retryable (APIError, SocketConnectionError, TimeoutError)
368
389
  const isRetryableAPIError =
369
390
  error?.name === 'APIError' && error.data.isRetryable;
370
391
  const isRetryableSocketError =