@helpai/elements 0.8.0 → 0.8.1

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/index.mjs CHANGED
@@ -1390,10 +1390,19 @@ var AgentTransport = class {
1390
1390
  * parallel with start-session, so a reply that was streaming when the
1391
1391
  * user reloaded keeps flowing).
1392
1392
  *
1393
- * Returns (no throw) on 204 / non-OK nothing in flight (or a backend
1394
- * without the endpoint graceful no-op) or once a terminal chunk is
1395
- * drained. Throws only when every attempt produced a 200 that dropped before
1396
- * finishing: a genuinely incomplete reply the UI should flag with a retry.
1393
+ * The endpoint ALWAYS opens a 200 SSE stream (mirrors the AI SDK
1394
+ * resumable-stream lib): it replays the in-flight reply from the buffer, or
1395
+ * when nothing is in flight (reply finished + the buffer was flushed, or
1396
+ * nothing ever started) closes an EMPTY stream. So "nothing to resume" is
1397
+ * signalled by a segment that ends without a terminal chunk AND surfaced no
1398
+ * NEW events — not by a status code. We stop gracefully there; the completed
1399
+ * turn comes from the DB via start-session / list-messages.
1400
+ *
1401
+ * Returns (no throw) on a terminal chunk, an empty/no-new-events segment, or
1402
+ * a 204 / non-OK (a backend that signals "nothing" by status, or lacks the
1403
+ * endpoint). Retries only a segment that yielded new events but no finish — a
1404
+ * real mid-reply drop. Throws only if every attempt kept yielding new events
1405
+ * yet never finished: a genuinely stuck, incomplete reply.
1397
1406
  */
1398
1407
  async *resumeStreamGen(ctrl, seenIds, immediate) {
1399
1408
  for (let attempt = 1; attempt <= MAX_RESUME_ATTEMPTS && !ctrl.signal.aborted; attempt++) {
@@ -1418,7 +1427,12 @@ var AgentTransport = class {
1418
1427
  log4.debug("resume \u2192 no in-flight stream", { status: res.status });
1419
1428
  return;
1420
1429
  }
1430
+ const before = seenIds.size;
1421
1431
  if (yield* this.drain(parseChatStream(res, ctrl.signal), seenIds, ctrl)) return;
1432
+ if (seenIds.size === before) {
1433
+ log4.debug("resume \u2192 stream closed with no new events; nothing to resume");
1434
+ return;
1435
+ }
1422
1436
  }
1423
1437
  if (ctrl.signal.aborted) return;
1424
1438
  throw new StreamError("stream incomplete after resume attempts", "server");
package/package.json CHANGED
@@ -80,5 +80,5 @@
80
80
  ],
81
81
  "type": "module",
82
82
  "types": "./index.d.ts",
83
- "version": "0.8.0"
83
+ "version": "0.8.1"
84
84
  }
package/web-component.mjs CHANGED
@@ -1454,10 +1454,19 @@ var AgentTransport = class {
1454
1454
  * parallel with start-session, so a reply that was streaming when the
1455
1455
  * user reloaded keeps flowing).
1456
1456
  *
1457
- * Returns (no throw) on 204 / non-OK nothing in flight (or a backend
1458
- * without the endpoint graceful no-op) or once a terminal chunk is
1459
- * drained. Throws only when every attempt produced a 200 that dropped before
1460
- * finishing: a genuinely incomplete reply the UI should flag with a retry.
1457
+ * The endpoint ALWAYS opens a 200 SSE stream (mirrors the AI SDK
1458
+ * resumable-stream lib): it replays the in-flight reply from the buffer, or
1459
+ * when nothing is in flight (reply finished + the buffer was flushed, or
1460
+ * nothing ever started) closes an EMPTY stream. So "nothing to resume" is
1461
+ * signalled by a segment that ends without a terminal chunk AND surfaced no
1462
+ * NEW events — not by a status code. We stop gracefully there; the completed
1463
+ * turn comes from the DB via start-session / list-messages.
1464
+ *
1465
+ * Returns (no throw) on a terminal chunk, an empty/no-new-events segment, or
1466
+ * a 204 / non-OK (a backend that signals "nothing" by status, or lacks the
1467
+ * endpoint). Retries only a segment that yielded new events but no finish — a
1468
+ * real mid-reply drop. Throws only if every attempt kept yielding new events
1469
+ * yet never finished: a genuinely stuck, incomplete reply.
1461
1470
  */
1462
1471
  async *resumeStreamGen(ctrl, seenIds, immediate) {
1463
1472
  for (let attempt = 1; attempt <= MAX_RESUME_ATTEMPTS && !ctrl.signal.aborted; attempt++) {
@@ -1482,7 +1491,12 @@ var AgentTransport = class {
1482
1491
  log4.debug("resume \u2192 no in-flight stream", { status: res.status });
1483
1492
  return;
1484
1493
  }
1494
+ const before = seenIds.size;
1485
1495
  if (yield* this.drain(parseChatStream(res, ctrl.signal), seenIds, ctrl)) return;
1496
+ if (seenIds.size === before) {
1497
+ log4.debug("resume \u2192 stream closed with no new events; nothing to resume");
1498
+ return;
1499
+ }
1486
1500
  }
1487
1501
  if (ctrl.signal.aborted) return;
1488
1502
  throw new StreamError("stream incomplete after resume attempts", "server");