@vercel/geistdocs 2.14.0 → 2.14.2

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 (73) hide show
  1. package/dist/assets/icons/icon-brain.d.ts +26 -0
  2. package/dist/assets/icons/icon-brain.d.ts.map +1 -0
  3. package/dist/assets/icons/icon-brain.js +25 -0
  4. package/dist/assets/icons/icon-buildings.d.ts +26 -0
  5. package/dist/assets/icons/icon-buildings.d.ts.map +1 -0
  6. package/dist/assets/icons/icon-buildings.js +25 -0
  7. package/dist/assets/icons/icon-chart-activity.d.ts +26 -0
  8. package/dist/assets/icons/icon-chart-activity.d.ts.map +1 -0
  9. package/dist/assets/icons/icon-chart-activity.js +25 -0
  10. package/dist/assets/icons/icon-code.d.ts +26 -0
  11. package/dist/assets/icons/icon-code.d.ts.map +1 -0
  12. package/dist/assets/icons/icon-code.js +25 -0
  13. package/dist/assets/icons/icon-git-merge.d.ts +26 -0
  14. package/dist/assets/icons/icon-git-merge.d.ts.map +1 -0
  15. package/dist/assets/icons/icon-git-merge.js +25 -0
  16. package/dist/assets/icons/icon-git-pull-request.d.ts +26 -0
  17. package/dist/assets/icons/icon-git-pull-request.d.ts.map +1 -0
  18. package/dist/assets/icons/icon-git-pull-request.js +25 -0
  19. package/dist/assets/icons/icon-headset.d.ts +26 -0
  20. package/dist/assets/icons/icon-headset.d.ts.map +1 -0
  21. package/dist/assets/icons/icon-headset.js +25 -0
  22. package/dist/assets/icons/icon-magnifying-glass.d.ts +26 -0
  23. package/dist/assets/icons/icon-magnifying-glass.d.ts.map +1 -0
  24. package/dist/assets/icons/icon-magnifying-glass.js +25 -0
  25. package/dist/assets/icons/icon-target.d.ts +26 -0
  26. package/dist/assets/icons/icon-target.d.ts.map +1 -0
  27. package/dist/assets/icons/icon-target.js +26 -0
  28. package/dist/assets/icons/icon-warning.d.ts +26 -0
  29. package/dist/assets/icons/icon-warning.d.ts.map +1 -0
  30. package/dist/assets/icons/icon-warning.js +25 -0
  31. package/dist/assets/icons/index.d.ts +10 -0
  32. package/dist/assets/icons/index.d.ts.map +1 -1
  33. package/dist/assets/icons/index.js +10 -0
  34. package/dist/cli/index.js +1 -1
  35. package/dist/components/code-block-tabs.d.ts.map +1 -1
  36. package/dist/components/code-block-tabs.js +4 -1
  37. package/dist/controls.d.ts.map +1 -1
  38. package/dist/controls.js +2 -2
  39. package/dist/internal/chat/dots-spinner.d.ts.map +1 -1
  40. package/dist/internal/chat/dots-spinner.js +4 -1
  41. package/dist/internal/chat/page-attachment.js +1 -1
  42. package/dist/internal/chat/shell.d.ts.map +1 -1
  43. package/dist/internal/chat/shell.js +65 -9
  44. package/dist/internal/eve-agent.d.ts +6 -1
  45. package/dist/internal/eve-agent.d.ts.map +1 -1
  46. package/dist/internal/eve-agent.js +356 -68
  47. package/dist/internal/navbar/desktop-menu.d.ts.map +1 -1
  48. package/dist/internal/navbar/desktop-menu.js +3 -1
  49. package/dist/internal/navbar/mobile-menu.d.ts.map +1 -1
  50. package/dist/internal/navbar/mobile-menu.js +28 -9
  51. package/dist/internal/navbar/navbar-logo.d.ts +3 -2
  52. package/dist/internal/navbar/navbar-logo.d.ts.map +1 -1
  53. package/dist/internal/navbar/navbar-logo.js +6 -3
  54. package/dist/internal/navbar/use-server-panel-mount.d.ts +9 -0
  55. package/dist/internal/navbar/use-server-panel-mount.d.ts.map +1 -0
  56. package/dist/internal/navbar/use-server-panel-mount.js +11 -0
  57. package/dist/internal/provider-client.d.ts.map +1 -1
  58. package/dist/internal/provider-client.js +24 -12
  59. package/dist/internal/search.d.ts.map +1 -1
  60. package/dist/internal/search.js +36 -4
  61. package/dist/source-config.d.ts +6 -0
  62. package/dist/source-config.d.ts.map +1 -1
  63. package/dist/source-config.js +13 -0
  64. package/docs/agents.md +1 -1
  65. package/docs/llms.txt +2 -2
  66. package/docs/manifest.json +1 -1
  67. package/docs/pages/ask-ai.md +1 -1
  68. package/package.json +3 -1
  69. package/rehype-task-list-labels.d.ts +9 -0
  70. package/rehype-task-list-labels.js +52 -0
  71. package/source-config.js +14 -0
  72. package/template/content/docs/ask-ai.mdx +1 -1
  73. package/template/package.json +1 -1
@@ -13,9 +13,16 @@
13
13
  * next to `message`; eve turns it into turn-scoped model context that is
14
14
  * not stored in session history.
15
15
  * - `GET {url}/eve/v1/session/:sessionId/stream?startIndex=N` streams
16
- * newline-delimited JSON events. The stream stays open after
17
- * `session.waiting`, so the client disconnects at turn boundaries and
18
- * counts consumed lines to resume from an absolute cursor.
16
+ * newline-delimited JSON. The stream stays open between turns, so the
17
+ * client disconnects at turn boundaries and counts stored lines to resume
18
+ * from an absolute cursor. Two stream versions are read:
19
+ * - v26 (eve 0.83 and older): one `{ type, data }` event per line; a turn
20
+ * ends with `session.waiting`, `session.completed`, or `session.failed`.
21
+ * - v27 (eve 0.84+): each stored line is a commit (`{ at, facts }`) or a
22
+ * progress record (`{ progress }`); `$eve` transport records are never
23
+ * counted. A turn ends with the `delivery.settled` of its message, or
24
+ * `session.ended`. A `stream.lease-ended` record ends one read, and the
25
+ * client reconnects from its cursor.
19
26
  * - `POST {url}/eve/v1/session/:sessionId/cancel` cancels the in-flight turn.
20
27
  * - In eve 0.83+, a bodyless `POST {url}/eve/v1/session/:sessionId` prepares
21
28
  * an existing session without starting a turn or replacing the session.
@@ -28,6 +35,8 @@ const SESSION_SEND_READY_TIMEOUT_MS = 20_000;
28
35
  const MAX_TRANSCRIPT_TURN_CHARS = 2000;
29
36
  const MAX_TRANSCRIPT_TOTAL_CHARS = 8000;
30
37
  const MAX_SOURCES_PER_ACTION = 5;
38
+ /** Bounds reconnects after v27 `stream.lease-ended` records within one turn. */
39
+ const MAX_STREAM_READS = 20;
31
40
  const TRAILING_SLASH_PATTERN = /\/+$/;
32
41
  const HTTP_URL_PATTERN = /^https?:\/\//;
33
42
  /** JSON body for eve's message routes; `clientContext` only when set. */
@@ -178,7 +187,10 @@ const parseSessionResponse = async (response) => {
178
187
  if (!isRecord(body) || typeof body.sessionId !== "string") {
179
188
  throw new Error("eve agent returned an invalid session response.");
180
189
  }
181
- return { sessionId: body.sessionId };
190
+ return {
191
+ deliveryId: typeof body.deliveryId === "string" ? body.deliveryId : undefined,
192
+ sessionId: body.sessionId,
193
+ };
182
194
  };
183
195
  /** Start an eve session without a turn so the first message can reuse it. */
184
196
  export const createEmptyEveAgentSession = async ({ agentUrl, fetchImpl = fetch, headers, signal, }) => {
@@ -191,7 +203,8 @@ export const createEmptyEveAgentSession = async ({ agentUrl, fetchImpl = fetch,
191
203
  if (!response.ok) {
192
204
  throw new Error(`eve agent session prewarm failed with status ${response.status}.`);
193
205
  }
194
- return await parseSessionResponse(response);
206
+ const { sessionId } = await parseSessionResponse(response);
207
+ return { sessionId };
195
208
  };
196
209
  /** Prepare an existing idle owner using eve 0.83's bodyless session POST. */
197
210
  export const prewarmExistingEveAgentSession = async ({ agentUrl, fetchImpl = fetch, headers, sessionId, signal, }) => {
@@ -206,16 +219,66 @@ export const prewarmExistingEveAgentSession = async ({ agentUrl, fetchImpl = fet
206
219
  throw new Error("eve agent returned an invalid preparation response.");
207
220
  }
208
221
  };
209
- const isTurnBoundaryEvent = (type) => type === "session.waiting" ||
210
- type === "session.completed" ||
211
- type === "session.failed";
212
- const createEveEventTranslator = (writer, { toolCitations, visibleTools }) => {
222
+ /**
223
+ * Track whether an event ends the turn. v26 ends at the session's status.
224
+ * v27 ends at the `delivery.settled` of the turn's message (any delivery
225
+ * when the agent returned no delivery ID) or at `session.ended`. A message
226
+ * that answers a paused turn's question settles `applied` while that turn
227
+ * resumes, so the boundary moves to the resumed turn settling or pausing.
228
+ */
229
+ const createTurnBoundary = (deliveryId) => {
230
+ let resumedTurn = false;
231
+ return (event) => {
232
+ switch (event.type) {
233
+ case "session.waiting":
234
+ case "session.completed":
235
+ case "session.failed":
236
+ case "session.ended":
237
+ return true;
238
+ case "delivery.settled":
239
+ if (deliveryId !== null && event.data?.deliveryId !== deliveryId) {
240
+ return false;
241
+ }
242
+ if (event.data?.outcome === "applied") {
243
+ resumedTurn = true;
244
+ return false;
245
+ }
246
+ return true;
247
+ case "turn.settled":
248
+ case "turn.paused":
249
+ return resumedTurn;
250
+ default:
251
+ return false;
252
+ }
253
+ };
254
+ };
255
+ /** Delivery outcomes after which the session can take the next message. */
256
+ const ACTIVE_DELIVERY_OUTCOMES = new Set([
257
+ "handled",
258
+ "awaiting-input",
259
+ "applied",
260
+ ]);
261
+ const getErrorMessage = (data) => {
262
+ if (typeof data?.message === "string") {
263
+ return data.message;
264
+ }
265
+ if (isRecord(data?.error) && typeof data.error.message === "string") {
266
+ return data.error.message;
267
+ }
268
+ return typeof data?.reason === "string" ? data.reason : undefined;
269
+ };
270
+ const createEveEventTranslator = (writer, { deliveryId, toolCitations, visibleTools }) => {
213
271
  let blockCounter = 0;
214
272
  let openTextId = null;
215
273
  let openReasoningId = null;
216
274
  let sessionWaiting = false;
275
+ let failureWritten = false;
217
276
  const knownToolCalls = new Map();
218
277
  const emittedSourceUrls = new Set();
278
+ /** v27 content kinds by part; only a part's first delta names its kind. */
279
+ const partKinds = new Map();
280
+ /** v27 parts whose text already streamed as deltas. */
281
+ const streamedParts = new Set();
219
282
  const closeTextBlock = () => {
220
283
  if (openTextId) {
221
284
  writer.write({ type: "text-end", id: openTextId });
@@ -255,6 +318,21 @@ const createEveEventTranslator = (writer, { toolCitations, visibleTools }) => {
255
318
  action.name ??
256
319
  action.kind ??
257
320
  "action";
321
+ const writeToolCall = (callId, toolName, input) => {
322
+ // Hidden tools never become known calls, so their results and any
323
+ // citations in them are dropped too.
324
+ if (visibleTools && !visibleTools.has(toolName)) {
325
+ return;
326
+ }
327
+ knownToolCalls.set(callId, toolName);
328
+ writer.write({
329
+ type: "tool-input-available",
330
+ toolCallId: callId,
331
+ toolName,
332
+ input: input ?? {},
333
+ dynamic: true,
334
+ });
335
+ };
258
336
  const handleActionsRequested = (data) => {
259
337
  if (!Array.isArray(data.actions)) {
260
338
  return;
@@ -265,20 +343,7 @@ const createEveEventTranslator = (writer, { toolCitations, visibleTools }) => {
265
343
  if (!isRecord(action) || typeof action.callId !== "string") {
266
344
  continue;
267
345
  }
268
- const toolName = getActionName(action);
269
- // Hidden tools never become known calls, so their results and any
270
- // citations in them are dropped too.
271
- if (visibleTools && !visibleTools.has(toolName)) {
272
- continue;
273
- }
274
- knownToolCalls.set(action.callId, toolName);
275
- writer.write({
276
- type: "tool-input-available",
277
- toolCallId: action.callId,
278
- toolName,
279
- input: action.input ?? {},
280
- dynamic: true,
281
- });
346
+ writeToolCall(action.callId, getActionName(action), action.input);
282
347
  }
283
348
  };
284
349
  const writeSourceChunks = (output) => {
@@ -295,25 +360,17 @@ const createEveEventTranslator = (writer, { toolCitations, visibleTools }) => {
295
360
  });
296
361
  }
297
362
  };
298
- const handleActionResult = (data) => {
299
- const result = data.result;
300
- if (!(isRecord(result) && typeof result.callId === "string")) {
363
+ const writeToolResult = ({ callId, error, failure, output, }) => {
364
+ if (!knownToolCalls.has(callId)) {
301
365
  return;
302
366
  }
303
- if (!knownToolCalls.has(result.callId)) {
304
- return;
305
- }
306
- const failed = data.status === "failed" ||
307
- data.status === "rejected" ||
308
- result.isError === true;
309
- if (failed) {
310
- const error = data.error;
311
- const fallbackErrorText = data.status === "rejected"
367
+ if (failure) {
368
+ const fallbackErrorText = failure === "rejected"
312
369
  ? "The action was rejected."
313
370
  : "The action failed.";
314
371
  writer.write({
315
372
  type: "tool-output-error",
316
- toolCallId: result.callId,
373
+ toolCallId: callId,
317
374
  errorText: isRecord(error) && typeof error.message === "string"
318
375
  ? error.message
319
376
  : fallbackErrorText,
@@ -323,12 +380,112 @@ const createEveEventTranslator = (writer, { toolCitations, visibleTools }) => {
323
380
  }
324
381
  writer.write({
325
382
  type: "tool-output-available",
326
- toolCallId: result.callId,
327
- output: toolCitations ? (result.output ?? null) : null,
383
+ toolCallId: callId,
384
+ output: toolCitations ? (output ?? null) : null,
328
385
  dynamic: true,
329
386
  });
330
387
  if (toolCitations) {
331
- writeSourceChunks(result.output);
388
+ writeSourceChunks(output);
389
+ }
390
+ };
391
+ const handleActionResult = (data) => {
392
+ const result = data.result;
393
+ if (!(isRecord(result) && typeof result.callId === "string")) {
394
+ return;
395
+ }
396
+ let failure = null;
397
+ if (data.status === "rejected") {
398
+ failure = "rejected";
399
+ }
400
+ else if (data.status === "failed" || result.isError === true) {
401
+ failure = "failed";
402
+ }
403
+ writeToolResult({
404
+ callId: result.callId,
405
+ error: data.error,
406
+ failure,
407
+ output: result.output,
408
+ });
409
+ };
410
+ /** v27 `call.requested`: one call, with its tool in `capability`. */
411
+ const handleCallRequested = (data) => {
412
+ const capability = data.capability;
413
+ if (typeof data.callId !== "string" ||
414
+ !isRecord(capability) ||
415
+ typeof capability.name !== "string" ||
416
+ // Task controls such as `eve__task_wait` are not user-facing tools.
417
+ capability.kind === "control") {
418
+ return;
419
+ }
420
+ closeTextBlock();
421
+ closeReasoningBlock();
422
+ writeToolCall(data.callId, capability.name, data.input);
423
+ };
424
+ /** v27 `call.settled`: `outcome` is `completed` or how the call stopped. */
425
+ const handleCallSettled = (data) => {
426
+ if (typeof data.callId !== "string") {
427
+ return;
428
+ }
429
+ let failure = null;
430
+ if (data.outcome === "rejected") {
431
+ failure = "rejected";
432
+ }
433
+ else if (data.outcome !== "completed") {
434
+ failure = "failed";
435
+ }
436
+ writeToolResult({
437
+ callId: data.callId,
438
+ error: data.error,
439
+ failure,
440
+ output: data.output,
441
+ });
442
+ };
443
+ /** v27 `content.delta` progress: text or reasoning for one part. */
444
+ const handleContentDelta = (data) => {
445
+ if (typeof data.partId !== "string" || typeof data.delta !== "string") {
446
+ return;
447
+ }
448
+ if (typeof data.kind === "string") {
449
+ partKinds.set(data.partId, data.kind);
450
+ }
451
+ const kind = partKinds.get(data.partId);
452
+ if (kind === "text") {
453
+ streamedParts.add(data.partId);
454
+ writeTextDelta(data.delta);
455
+ }
456
+ else if (kind === "reasoning") {
457
+ streamedParts.add(data.partId);
458
+ writeReasoningDelta(data.delta);
459
+ }
460
+ };
461
+ /**
462
+ * v27 `content.completed`: a finished part. Writes the whole value when
463
+ * its deltas were not read (they are optional), then closes the block.
464
+ */
465
+ const handleContentCompleted = (data) => {
466
+ if (typeof data.partId !== "string") {
467
+ return;
468
+ }
469
+ const unstreamedValue = !streamedParts.has(data.partId) && typeof data.value === "string"
470
+ ? data.value
471
+ : null;
472
+ if (data.kind === "text") {
473
+ if (unstreamedValue) {
474
+ writeTextDelta(unstreamedValue);
475
+ }
476
+ closeTextBlock();
477
+ }
478
+ else if (data.kind === "reasoning") {
479
+ if (unstreamedValue) {
480
+ writeReasoningDelta(unstreamedValue);
481
+ }
482
+ closeReasoningBlock();
483
+ }
484
+ };
485
+ /** v27 `interaction.opened`: render the question for the reader to answer. */
486
+ const handleInteractionOpened = (data) => {
487
+ if (isRecord(data.request) && typeof data.request.prompt === "string") {
488
+ writeTextDelta(`${data.request.prompt}\n`);
332
489
  }
333
490
  };
334
491
  const handleInputRequested = (data) => {
@@ -342,13 +499,16 @@ const createEveEventTranslator = (writer, { toolCitations, visibleTools }) => {
342
499
  }
343
500
  };
344
501
  const handleFailure = (data) => {
502
+ // One error per turn: v27 reports a failed session on several events.
503
+ if (failureWritten) {
504
+ return;
505
+ }
506
+ failureWritten = true;
345
507
  closeTextBlock();
346
508
  closeReasoningBlock();
347
509
  writer.write({
348
510
  type: "error",
349
- errorText: data && typeof data.message === "string"
350
- ? data.message
351
- : "The agent failed to answer.",
511
+ errorText: getErrorMessage(data) ?? "The agent failed to answer.",
352
512
  });
353
513
  };
354
514
  const eventHandlers = {
@@ -384,6 +544,54 @@ const createEveEventTranslator = (writer, { toolCitations, visibleTools }) => {
384
544
  },
385
545
  "turn.failed": handleFailure,
386
546
  "session.failed": handleFailure,
547
+ // v27 (eve 0.84+)
548
+ "content.delta": (data) => {
549
+ if (data) {
550
+ handleContentDelta(data);
551
+ }
552
+ },
553
+ "content.completed": (data) => {
554
+ if (data) {
555
+ handleContentCompleted(data);
556
+ }
557
+ },
558
+ "call.requested": (data) => {
559
+ if (data) {
560
+ handleCallRequested(data);
561
+ }
562
+ },
563
+ "call.settled": (data) => {
564
+ if (data) {
565
+ handleCallSettled(data);
566
+ }
567
+ },
568
+ "interaction.opened": (data) => {
569
+ if (data) {
570
+ handleInteractionOpened(data);
571
+ }
572
+ },
573
+ "turn.settled": (data) => {
574
+ if (data?.outcome === "failed") {
575
+ handleFailure(data);
576
+ }
577
+ },
578
+ "delivery.settled": (data) => {
579
+ if (deliveryId !== null && data?.deliveryId !== deliveryId) {
580
+ return;
581
+ }
582
+ if (ACTIVE_DELIVERY_OUTCOMES.has(data?.outcome)) {
583
+ sessionWaiting = true;
584
+ }
585
+ else if (data?.outcome === "failed" || data?.outcome === "refused") {
586
+ handleFailure(data);
587
+ }
588
+ },
589
+ "session.ended": (data) => {
590
+ sessionWaiting = false;
591
+ if (data?.outcome === "failed") {
592
+ handleFailure(data);
593
+ }
594
+ },
387
595
  };
388
596
  // Unknown event types (step.*, subagent.*, compaction.*, ...) are
389
597
  // intentionally ignored for forward compatibility.
@@ -462,7 +670,11 @@ export const startOrContinueEveAgentSession = async ({ agentUrl, clientContext,
462
670
  if (session.sessionId !== continuation.sessionId) {
463
671
  throw new Error("eve agent follow-up returned a different session id.");
464
672
  }
465
- return continuation;
673
+ return {
674
+ sessionId: continuation.sessionId,
675
+ startIndex: continuation.startIndex,
676
+ ...(session.deliveryId ? { deliveryId: session.deliveryId } : {}),
677
+ };
466
678
  }
467
679
  // Ask AI recovers from an inactive session by explicitly creating a new
468
680
  // one with the bounded transcript.
@@ -480,9 +692,61 @@ export const startOrContinueEveAgentSession = async ({ agentUrl, clientContext,
480
692
  throw new Error(`eve agent session create failed with status ${response.status}.`);
481
693
  }
482
694
  const session = await parseSessionResponse(response);
483
- return { sessionId: session.sessionId, startIndex: 0 };
695
+ return {
696
+ sessionId: session.sessionId,
697
+ startIndex: 0,
698
+ ...(session.deliveryId ? { deliveryId: session.deliveryId } : {}),
699
+ };
700
+ };
701
+ /**
702
+ * Apply a v27 `$eve` transport record. Transport records are never stored
703
+ * or counted; a position marker moves the cursor forward.
704
+ */
705
+ const readTransportRecord = (record, cursor) => {
706
+ switch (record.$eve) {
707
+ case "position":
708
+ return {
709
+ cursor: Number.isSafeInteger(record.next) && record.next > cursor
710
+ ? record.next
711
+ : cursor,
712
+ end: null,
713
+ };
714
+ case "stream.lease-ended":
715
+ return { cursor, end: { cursor, reconnect: true } };
716
+ case "stream.ended":
717
+ return { cursor, end: { cursor, reconnect: false } };
718
+ default:
719
+ return { cursor, end: null };
720
+ }
721
+ };
722
+ const handleStreamEvent = (value, onEvent) => isRecord(value) && typeof value.type === "string"
723
+ ? onEvent(value)
724
+ : false;
725
+ /**
726
+ * Hand a stored line's events to `onEvent`: every fact of a v27 commit (the
727
+ * whole line, even past a boundary), a v27 progress record, or a v26 event.
728
+ * Returns whether the line holds a turn boundary.
729
+ */
730
+ const handleStoredRecord = (record, onEvent) => {
731
+ if (isRecord(record) && Array.isArray(record.facts)) {
732
+ let boundary = false;
733
+ for (const fact of record.facts) {
734
+ if (handleStreamEvent(fact, onEvent)) {
735
+ boundary = true;
736
+ }
737
+ }
738
+ return boundary;
739
+ }
740
+ const event = isRecord(record) && isRecord(record.progress) ? record.progress : record;
741
+ return handleStreamEvent(event, onEvent);
484
742
  };
485
- const streamSessionEvents = async ({ agentUrl, fetchImpl, headers, onEvent, sessionId, signal, startIndex, }) => {
743
+ /**
744
+ * Read one stream response. v26 lines are events; v27 lines are commits
745
+ * (`facts`) or progress records, and `$eve` transport records are not
746
+ * counted. `onEvent` returns `true` at a turn boundary, which ends the read
747
+ * once the rest of its line is handled.
748
+ */
749
+ const readSessionStream = async ({ agentUrl, fetchImpl, headers, onEvent, sessionId, signal, startIndex, }) => {
486
750
  const query = startIndex > 0 ? `?startIndex=${startIndex}` : "";
487
751
  const response = await fetchImpl(`${agentUrl}${EVE_SESSION_PATH}/${encodeURIComponent(sessionId)}/stream${query}`, { headers, signal });
488
752
  if (!response.ok) {
@@ -494,25 +758,32 @@ const streamSessionEvents = async ({ agentUrl, fetchImpl, headers, onEvent, sess
494
758
  const reader = response.body.getReader();
495
759
  const decoder = new TextDecoder();
496
760
  let buffer = "";
497
- let consumed = 0;
761
+ let cursor = startIndex;
762
+ /** Returns how the read ends, or `null` to keep reading. */
498
763
  const processLine = (line) => {
499
764
  const trimmed = line.trim();
500
765
  if (!trimmed) {
501
- return false;
766
+ return null;
502
767
  }
503
- consumed += 1;
504
- let event;
768
+ let record;
505
769
  try {
506
- event = JSON.parse(trimmed);
770
+ record = JSON.parse(trimmed);
507
771
  }
508
772
  catch {
509
773
  // Skip malformed lines instead of failing the whole turn.
510
- return false;
511
- }
512
- if (!isRecord(event) || typeof event.type !== "string") {
513
- return false;
514
- }
515
- return onEvent(event);
774
+ cursor += 1;
775
+ return null;
776
+ }
777
+ // v27 transport records: never stored, never counted.
778
+ if (isRecord(record) && typeof record.$eve === "string") {
779
+ const transport = readTransportRecord(record, cursor);
780
+ cursor = transport.cursor;
781
+ return transport.end;
782
+ }
783
+ cursor += 1;
784
+ return handleStoredRecord(record, onEvent)
785
+ ? { cursor, reconnect: false }
786
+ : null;
516
787
  };
517
788
  try {
518
789
  while (true) {
@@ -522,8 +793,9 @@ const streamSessionEvents = async ({ agentUrl, fetchImpl, headers, onEvent, sess
522
793
  while (newlineIndex !== -1) {
523
794
  const line = buffer.slice(0, newlineIndex);
524
795
  buffer = buffer.slice(newlineIndex + 1);
525
- if (processLine(line)) {
526
- return consumed;
796
+ const result = processLine(line);
797
+ if (result) {
798
+ return result;
527
799
  }
528
800
  newlineIndex = buffer.indexOf("\n");
529
801
  }
@@ -531,19 +803,32 @@ const streamSessionEvents = async ({ agentUrl, fetchImpl, headers, onEvent, sess
531
803
  break;
532
804
  }
533
805
  }
534
- if (buffer.trim()) {
535
- processLine(buffer);
536
- }
537
- return consumed;
806
+ return ((buffer.trim() && processLine(buffer)) || { cursor, reconnect: false });
538
807
  }
539
808
  finally {
540
- // The eve stream stays open after `session.waiting`; release the
541
- // connection once the turn boundary is reached.
809
+ // The eve stream stays open after a turn boundary; release the
810
+ // connection once it is reached.
542
811
  await reader.cancel().catch(() => {
543
812
  // The reader may already be released or errored.
544
813
  });
545
814
  }
546
815
  };
816
+ /**
817
+ * Stream a turn's events until its boundary, reconnecting from the cursor
818
+ * when a v27 read lease ends. Resolves with the absolute position of the
819
+ * next stored line.
820
+ */
821
+ const streamSessionEvents = async (options) => {
822
+ let cursor = options.startIndex;
823
+ for (let read = 0; read < MAX_STREAM_READS; read++) {
824
+ const result = await readSessionStream({ ...options, startIndex: cursor });
825
+ cursor = result.cursor;
826
+ if (!result.reconnect) {
827
+ break;
828
+ }
829
+ }
830
+ return cursor;
831
+ };
547
832
  const cancelSession = ({ agentUrl, fetchImpl, headers, sessionId, }) => fetchImpl(`${agentUrl}${EVE_SESSION_PATH}/${encodeURIComponent(sessionId)}/cancel`, {
548
833
  method: "POST",
549
834
  body: JSON.stringify({}),
@@ -562,6 +847,7 @@ const cancelSession = ({ agentUrl, fetchImpl, headers, sessionId, }) => fetchImp
562
847
  export const streamEveAgentTurn = async ({ agentUrl, fetchImpl = fetch, headers, initialChunks = [], session, sessionTag = null, signal, toolCitations = true, visibleTools, writer, }) => {
563
848
  const normalizedUrl = normalizeAgentUrl(agentUrl);
564
849
  const { sessionId, startIndex } = session;
850
+ const deliveryId = session.deliveryId ?? null;
565
851
  // A bare `start` chunk does not flush client state; providing a message
566
852
  // id makes the assistant message render immediately, so the chat shows
567
853
  // the "Thinking..." indicator during model startup instead of a blank
@@ -571,12 +857,14 @@ export const streamEveAgentTurn = async ({ agentUrl, fetchImpl = fetch, headers,
571
857
  writer.write(chunk);
572
858
  }
573
859
  const translator = createEveEventTranslator(writer, {
860
+ deliveryId,
574
861
  toolCitations,
575
862
  visibleTools: visibleTools ? new Set(visibleTools) : null,
576
863
  });
577
- let consumed = 0;
864
+ const isTurnBoundary = createTurnBoundary(deliveryId);
865
+ let nextIndex = startIndex;
578
866
  try {
579
- consumed = await streamSessionEvents({
867
+ nextIndex = await streamSessionEvents({
580
868
  agentUrl: normalizedUrl,
581
869
  fetchImpl,
582
870
  headers,
@@ -585,7 +873,7 @@ export const streamEveAgentTurn = async ({ agentUrl, fetchImpl = fetch, headers,
585
873
  startIndex,
586
874
  onEvent: (event) => {
587
875
  translator.handleEvent(event);
588
- return isTurnBoundaryEvent(event.type);
876
+ return isTurnBoundary(event);
589
877
  },
590
878
  });
591
879
  }
@@ -608,7 +896,7 @@ export const streamEveAgentTurn = async ({ agentUrl, fetchImpl = fetch, headers,
608
896
  if (sessionTag && translator.isSessionWaiting()) {
609
897
  const eveAgent = {
610
898
  session: sessionTag,
611
- streamIndex: startIndex + consumed,
899
+ streamIndex: nextIndex,
612
900
  };
613
901
  writer.write({ type: "finish", messageMetadata: { eveAgent } });
614
902
  return;
@@ -1 +1 @@
1
- {"version":3,"file":"desktop-menu.d.ts","sourceRoot":"","sources":["../../../src/internal/navbar/desktop-menu.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EACV,oBAAoB,EACpB,wBAAwB,EACxB,gBAAgB,EACjB,MAAM,cAAc,CAAC;AAYtB,UAAU,gBAAgB;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,gBAAgB,EAAE,CAAC;CAC3B;AAiBD,UAAU,eAAe;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,wBAAwB,EAAE,CAAC;CACnC;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,oBAAoB,GAC7B,eAAe,EAAE,CAYnB;AA8DD,eAAO,MAAM,WAAW,GAAI,sBAAsB,gBAAgB,4CAuEjE,CAAC"}
1
+ {"version":3,"file":"desktop-menu.d.ts","sourceRoot":"","sources":["../../../src/internal/navbar/desktop-menu.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EACV,oBAAoB,EACpB,wBAAwB,EACxB,gBAAgB,EACjB,MAAM,cAAc,CAAC;AAatB,UAAU,gBAAgB;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,gBAAgB,EAAE,CAAC;CAC3B;AAiBD,UAAU,eAAe;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,wBAAwB,EAAE,CAAC;CACnC;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,oBAAoB,GAC7B,eAAe,EAAE,CAYnB;AA+DD,eAAO,MAAM,WAAW,GAAI,sBAAsB,gBAAgB,4CAuEjE,CAAC"}
@@ -8,6 +8,7 @@ import { LocalizedLink } from "../localized-link";
8
8
  import { NavigationMenu, NavigationMenuItem, NavigationMenuLink, NavigationMenuList, NavigationMenuTrigger, } from "../ui/navigation-menu";
9
9
  import { NAVBAR_PANEL_CLASSNAME, PanelLink } from "./navbar-logo";
10
10
  import { useNavActive } from "./use-nav-active";
11
+ import { useServerPanelMount } from "./use-server-panel-mount";
11
12
  /**
12
13
  * Shared styling for top-level nav triggers and links: full-height hit target
13
14
  * with a floating focus ring. The first item gets extra left padding to keep
@@ -44,7 +45,8 @@ const DropdownNavItem = ({ first, item, navItems, }) => {
44
45
  const isActive = useNavActive(navItems);
45
46
  const hasActiveChild = item.items.some((child) => !isExternal(child) && isActive(child.href));
46
47
  const sections = groupDropdownItems(item);
47
- return (_jsxs(NavigationMenuItem, { className: "flex", children: [_jsx(NavigationMenuTrigger, { className: topLevelItemClassName(first), "data-active": hasActiveChild ? "" : undefined, children: item.label }), _jsx(NavigationMenuPrimitive.Content, { className: NAVBAR_PANEL_CLASSNAME, forceMount: true, children: _jsx("div", { className: "mx-auto w-full max-w-[1448px] px-2", children: _jsx("div", { className: "flex flex-nowrap gap-x-10 pt-4 pb-6 pl-4", children: sections.map((section) => (_jsxs("div", { className: "min-w-[180px] shrink-0", children: [_jsx("p", { className: "text-gray-900 text-label-14", children: section.heading }), _jsx("ul", { className: "mt-[5px] flex list-none flex-col", children: section.items.map((child) => (_jsx("li", { className: "flex", children: _jsx(PanelLink, { active: !isExternal(child) && isActive(child.href), product: child }) }, child.href))) })] }, section.heading))) }) }) })] }));
48
+ const forceMount = useServerPanelMount();
49
+ return (_jsxs(NavigationMenuItem, { className: "flex", children: [_jsx(NavigationMenuTrigger, { className: topLevelItemClassName(first), "data-active": hasActiveChild ? "" : undefined, children: item.label }), _jsx(NavigationMenuPrimitive.Content, { className: NAVBAR_PANEL_CLASSNAME, forceMount: forceMount, children: _jsx("div", { className: "mx-auto w-full max-w-[1448px] px-2", children: _jsx("div", { className: "flex flex-nowrap gap-x-10 pt-4 pb-6 pl-4", children: sections.map((section) => (_jsxs("div", { className: "min-w-[180px] shrink-0", children: [_jsx("p", { className: "text-gray-900 text-label-14", children: section.heading }), _jsx("ul", { className: "mt-[5px] flex list-none flex-col", children: section.items.map((child) => (_jsx("li", { className: "flex", children: _jsx(PanelLink, { active: !isExternal(child) && isActive(child.href), product: child }) }, child.href))) })] }, section.heading))) }) }) })] }));
48
50
  };
49
51
  export const DesktopMenu = ({ items, className }) => {
50
52
  const isActive = useNavActive(items);
@@ -1 +1 @@
1
- {"version":3,"file":"mobile-menu.d.ts","sourceRoot":"","sources":["../../../src/internal/navbar/mobile-menu.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAK,EACV,yBAAyB,EAEzB,gBAAgB,EACjB,MAAM,cAAc,CAAC;AAQtB,UAAU,eAAe;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,GAAG,EAAE,gBAAgB,EAAE,CAAC;IACxB,WAAW,CAAC,EAAE,yBAAyB,EAAE,CAAC;IAC1C,4EAA4E;IAC5E,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AA+YD,eAAO,MAAM,UAAU,GAAI,OAAO,eAAe,4CAEhD,CAAC"}
1
+ {"version":3,"file":"mobile-menu.d.ts","sourceRoot":"","sources":["../../../src/internal/navbar/mobile-menu.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAK,EACV,yBAAyB,EAEzB,gBAAgB,EACjB,MAAM,cAAc,CAAC;AAQtB,UAAU,eAAe;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,GAAG,EAAE,gBAAgB,EAAE,CAAC;IACxB,WAAW,CAAC,EAAE,yBAAyB,EAAE,CAAC;IAC1C,4EAA4E;IAC5E,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAobD,eAAO,MAAM,UAAU,GAAI,OAAO,eAAe,4CAEhD,CAAC"}