@vercel/geistdocs 2.14.1 → 2.14.3-canary.9417d69
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/dist/cli/index.js +1 -1
- package/dist/components/video.d.ts +2 -2
- package/dist/components/video.d.ts.map +1 -1
- package/dist/components/video.js +1 -1
- package/dist/config.d.ts +15 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/controls.d.ts +6 -1
- package/dist/controls.d.ts.map +1 -1
- package/dist/controls.js +8 -2
- package/dist/internal/chat/prompt-input.d.ts.map +1 -1
- package/dist/internal/chat/prompt-input.js +3 -2
- package/dist/internal/chat/shell.d.ts.map +1 -1
- package/dist/internal/chat/shell.js +4 -2
- package/dist/internal/config-context.d.ts +2 -0
- package/dist/internal/config-context.d.ts.map +1 -1
- package/dist/internal/config-context.js +2 -0
- package/dist/internal/eve-agent.d.ts +6 -1
- package/dist/internal/eve-agent.d.ts.map +1 -1
- package/dist/internal/eve-agent.js +356 -68
- package/dist/internal/lazy-mdx-components.d.ts +21 -0
- package/dist/internal/lazy-mdx-components.d.ts.map +1 -0
- package/dist/internal/lazy-mdx-components.js +13 -0
- package/dist/internal/localized-link.d.ts +3 -1
- package/dist/internal/localized-link.d.ts.map +1 -1
- package/dist/internal/localized-link.js +2 -2
- package/dist/internal/navbar/desktop-menu.d.ts.map +1 -1
- package/dist/internal/navbar/desktop-menu.js +1 -1
- package/dist/internal/navbar/mobile-menu.d.ts.map +1 -1
- package/dist/internal/navbar/mobile-menu.js +3 -3
- package/dist/internal/navbar/navbar-logo.d.ts +7 -3
- package/dist/internal/navbar/navbar-logo.d.ts.map +1 -1
- package/dist/internal/navbar/navbar-logo.js +2 -3
- package/dist/mdx.d.ts.map +1 -1
- package/dist/mdx.js +1 -5
- package/dist/navbar.d.ts.map +1 -1
- package/dist/navbar.js +3 -1
- package/docs/agents.md +1 -1
- package/docs/llms.txt +28 -2
- package/docs/manifest.json +1 -1
- package/docs/pages/ask-ai.md +1 -1
- package/docs/pages/configuration.md +26 -0
- package/package.json +6 -6
- package/template/content/docs/ask-ai.mdx +1 -1
- package/template/content/docs/configuration.mdx +26 -0
- 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
|
|
17
|
-
*
|
|
18
|
-
*
|
|
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 {
|
|
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
|
-
|
|
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
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
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
|
-
|
|
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
|
|
299
|
-
|
|
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 (
|
|
304
|
-
|
|
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:
|
|
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:
|
|
327
|
-
output: toolCitations ? (
|
|
383
|
+
toolCallId: callId,
|
|
384
|
+
output: toolCitations ? (output ?? null) : null,
|
|
328
385
|
dynamic: true,
|
|
329
386
|
});
|
|
330
387
|
if (toolCitations) {
|
|
331
|
-
writeSourceChunks(
|
|
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
|
|
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
|
|
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 {
|
|
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
|
-
|
|
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
|
|
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
|
|
766
|
+
return null;
|
|
502
767
|
}
|
|
503
|
-
|
|
504
|
-
let event;
|
|
768
|
+
let record;
|
|
505
769
|
try {
|
|
506
|
-
|
|
770
|
+
record = JSON.parse(trimmed);
|
|
507
771
|
}
|
|
508
772
|
catch {
|
|
509
773
|
// Skip malformed lines instead of failing the whole turn.
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
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
|
-
|
|
526
|
-
|
|
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
|
-
|
|
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
|
|
541
|
-
// connection once
|
|
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
|
-
|
|
864
|
+
const isTurnBoundary = createTurnBoundary(deliveryId);
|
|
865
|
+
let nextIndex = startIndex;
|
|
578
866
|
try {
|
|
579
|
-
|
|
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
|
|
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:
|
|
899
|
+
streamIndex: nextIndex,
|
|
612
900
|
};
|
|
613
901
|
writer.write({ type: "finish", messageMetadata: { eveAgent } });
|
|
614
902
|
return;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { ComponentProps, ComponentType } from "react";
|
|
2
|
+
import type ReactPlayerComponent from "react-player";
|
|
3
|
+
import type * as TabsModule from "#geistdocs-ui/components/tabs";
|
|
4
|
+
import type * as CodeBlockTabsModule from "../components/code-block-tabs";
|
|
5
|
+
import type * as CopyPromptModule from "../components/copy-prompt";
|
|
6
|
+
import type * as MermaidModule from "../components/mermaid";
|
|
7
|
+
import type * as TabsWithChildrenModule from "../components/tabs-with-children";
|
|
8
|
+
type Lazy<T extends ComponentType<any>> = ComponentType<ComponentProps<T>>;
|
|
9
|
+
export declare const CopyPrompt: Lazy<typeof CopyPromptModule.CopyPrompt>;
|
|
10
|
+
export declare const Mermaid: Lazy<typeof MermaidModule.Mermaid>;
|
|
11
|
+
export declare const TabsWithChildren: Lazy<typeof TabsWithChildrenModule.TabsWithChildren>;
|
|
12
|
+
export declare const TabContent: Lazy<typeof TabsWithChildrenModule.TabContent>;
|
|
13
|
+
export declare const CodeBlockTabs: Lazy<typeof CodeBlockTabsModule.CodeBlockTabs>;
|
|
14
|
+
export declare const CompactCodeBlockTabs: Lazy<typeof CodeBlockTabsModule.CompactCodeBlockTabs>;
|
|
15
|
+
export declare const CodeBlockTabsList: Lazy<typeof CodeBlockTabsModule.CodeBlockTabsList>;
|
|
16
|
+
export declare const CodeBlockTabsTrigger: Lazy<typeof CodeBlockTabsModule.CodeBlockTabsTrigger>;
|
|
17
|
+
export declare const CodeBlockTab: Lazy<typeof CodeBlockTabsModule.CodeBlockTab>;
|
|
18
|
+
export declare const Tabs: Lazy<typeof TabsModule.Tabs>;
|
|
19
|
+
export declare const ReactPlayer: Lazy<typeof ReactPlayerComponent>;
|
|
20
|
+
export {};
|
|
21
|
+
//# sourceMappingURL=lazy-mdx-components.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lazy-mdx-components.d.ts","sourceRoot":"","sources":["../../src/internal/lazy-mdx-components.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAC3D,OAAO,KAAK,oBAAoB,MAAM,cAAc,CAAC;AACrD,OAAO,KAAK,KAAK,UAAU,MAAM,+BAA+B,CAAC;AACjE,OAAO,KAAK,KAAK,mBAAmB,MAAM,+BAA+B,CAAC;AAC1E,OAAO,KAAK,KAAK,gBAAgB,MAAM,2BAA2B,CAAC;AACnE,OAAO,KAAK,KAAK,aAAa,MAAM,uBAAuB,CAAC;AAC5D,OAAO,KAAK,KAAK,sBAAsB,MAAM,kCAAkC,CAAC;AAShF,KAAK,IAAI,CAAC,CAAC,SAAS,aAAa,CAAC,GAAG,CAAC,IAAI,aAAa,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC;AAE3E,eAAO,MAAM,UAAU,EAAE,IAAI,CAAC,OAAO,gBAAgB,CAAC,UAAU,CAE/D,CAAC;AAEF,eAAO,MAAM,OAAO,EAAE,IAAI,CAAC,OAAO,aAAa,CAAC,OAAO,CAEtD,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,IAAI,CACjC,OAAO,sBAAsB,CAAC,gBAAgB,CAG/C,CAAC;AAEF,eAAO,MAAM,UAAU,EAAE,IAAI,CAAC,OAAO,sBAAsB,CAAC,UAAU,CAGnE,CAAC;AAEJ,eAAO,MAAM,aAAa,EAAE,IAAI,CAAC,OAAO,mBAAmB,CAAC,aAAa,CAGtE,CAAC;AAEJ,eAAO,MAAM,oBAAoB,EAAE,IAAI,CACrC,OAAO,mBAAmB,CAAC,oBAAoB,CAKhD,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,IAAI,CAClC,OAAO,mBAAmB,CAAC,iBAAiB,CAG7C,CAAC;AAEF,eAAO,MAAM,oBAAoB,EAAE,IAAI,CACrC,OAAO,mBAAmB,CAAC,oBAAoB,CAKhD,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,IAAI,CAAC,OAAO,mBAAmB,CAAC,YAAY,CAGpE,CAAC;AAEJ,eAAO,MAAM,IAAI,EAAE,IAAI,CAAC,OAAO,UAAU,CAAC,IAAI,CAE7C,CAAC;AAEF,eAAO,MAAM,WAAW,EAAE,IAAI,CAAC,OAAO,oBAAoB,CAEzD,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import dynamic from "next/dynamic";
|
|
3
|
+
export const CopyPrompt = dynamic(() => import("../components/copy-prompt").then((mod) => mod.CopyPrompt));
|
|
4
|
+
export const Mermaid = dynamic(() => import("../components/mermaid").then((mod) => mod.Mermaid));
|
|
5
|
+
export const TabsWithChildren = dynamic(() => import("../components/tabs-with-children").then((mod) => mod.TabsWithChildren));
|
|
6
|
+
export const TabContent = dynamic(() => import("../components/tabs-with-children").then((mod) => mod.TabContent));
|
|
7
|
+
export const CodeBlockTabs = dynamic(() => import("../components/code-block-tabs").then((mod) => mod.CodeBlockTabs));
|
|
8
|
+
export const CompactCodeBlockTabs = dynamic(() => import("../components/code-block-tabs").then((mod) => mod.CompactCodeBlockTabs));
|
|
9
|
+
export const CodeBlockTabsList = dynamic(() => import("../components/code-block-tabs").then((mod) => mod.CodeBlockTabsList));
|
|
10
|
+
export const CodeBlockTabsTrigger = dynamic(() => import("../components/code-block-tabs").then((mod) => mod.CodeBlockTabsTrigger));
|
|
11
|
+
export const CodeBlockTab = dynamic(() => import("../components/code-block-tabs").then((mod) => mod.CodeBlockTab));
|
|
12
|
+
export const Tabs = dynamic(() => import("#geistdocs-ui/components/tabs").then((mod) => mod.Tabs));
|
|
13
|
+
export const ReactPlayer = dynamic(() => import("react-player"));
|
|
@@ -2,12 +2,14 @@ import type { AnchorHTMLAttributes, ReactNode } from "react";
|
|
|
2
2
|
interface LocalizedLinkProps extends AnchorHTMLAttributes<HTMLAnchorElement> {
|
|
3
3
|
children: ReactNode;
|
|
4
4
|
href: string;
|
|
5
|
+
/** Defaults to `true`; `false` skips viewport prefetching. */
|
|
6
|
+
prefetch?: boolean;
|
|
5
7
|
}
|
|
6
8
|
/**
|
|
7
9
|
* Resolve an app-local href against the active language segment. See
|
|
8
10
|
* `localizeHref` for the prefixing rules.
|
|
9
11
|
*/
|
|
10
12
|
export declare const useLocalizedHref: (href: string) => string;
|
|
11
|
-
export declare const LocalizedLink: ({ href, ...props }: LocalizedLinkProps) => import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
export declare const LocalizedLink: ({ href, prefetch, ...props }: LocalizedLinkProps) => import("react/jsx-runtime").JSX.Element;
|
|
12
14
|
export {};
|
|
13
15
|
//# sourceMappingURL=localized-link.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"localized-link.d.ts","sourceRoot":"","sources":["../../src/internal/localized-link.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,oBAAoB,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAI7D,UAAU,kBAAmB,SAAQ,oBAAoB,CAAC,iBAAiB,CAAC;IAC1E,QAAQ,EAAE,SAAS,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"localized-link.d.ts","sourceRoot":"","sources":["../../src/internal/localized-link.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,oBAAoB,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAI7D,UAAU,kBAAmB,SAAQ,oBAAoB,CAAC,iBAAiB,CAAC;IAC1E,QAAQ,EAAE,SAAS,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,8DAA8D;IAC9D,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED;;;GAGG;AACH,eAAO,MAAM,gBAAgB,GAAI,MAAM,MAAM,KAAG,MAQ/C,CAAC;AAEF,eAAO,MAAM,aAAa,GAAI,8BAI3B,kBAAkB,4CAIpB,CAAC"}
|
|
@@ -16,7 +16,7 @@ export const useLocalizedHref = (href) => {
|
|
|
16
16
|
const language = typeof params?.lang === "string" ? params.lang : undefined;
|
|
17
17
|
return localizeHref(href, language, defaultLanguage);
|
|
18
18
|
};
|
|
19
|
-
export const LocalizedLink = ({ href, ...props }) => {
|
|
19
|
+
export const LocalizedLink = ({ href, prefetch = true, ...props }) => {
|
|
20
20
|
const localizedHref = useLocalizedHref(href);
|
|
21
|
-
return _jsx(Link, { href: localizedHref, prefetch:
|
|
21
|
+
return _jsx(Link, { href: localizedHref, prefetch: prefetch, ...props });
|
|
22
22
|
};
|