@vercel/geistdocs 2.7.10 → 2.9.0
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/assets/icons/icon-fullscreen-close.d.ts +26 -0
- package/dist/assets/icons/icon-fullscreen-close.d.ts.map +1 -0
- package/dist/assets/icons/icon-fullscreen-close.js +25 -0
- package/dist/assets/icons/icon-fullscreen.d.ts +26 -0
- package/dist/assets/icons/icon-fullscreen.d.ts.map +1 -0
- package/dist/assets/icons/icon-fullscreen.js +25 -0
- package/dist/assets/icons/icon-thumb-down.d.ts +26 -0
- package/dist/assets/icons/icon-thumb-down.d.ts.map +1 -0
- package/dist/assets/icons/icon-thumb-down.js +25 -0
- package/dist/assets/icons/index.d.ts +3 -0
- package/dist/assets/icons/index.d.ts.map +1 -1
- package/dist/assets/icons/index.js +3 -0
- package/dist/cli/index.js +1 -1
- package/dist/config.d.ts +67 -3
- package/dist/config.d.ts.map +1 -1
- package/dist/controls.d.ts +23 -1
- package/dist/controls.d.ts.map +1 -1
- package/dist/controls.js +44 -3
- package/dist/footer.js +1 -1
- package/dist/internal/chat/activity.d.ts +5 -1
- package/dist/internal/chat/activity.d.ts.map +1 -1
- package/dist/internal/chat/activity.js +11 -4
- package/dist/internal/chat/chat-user.d.ts +12 -0
- package/dist/internal/chat/chat-user.d.ts.map +1 -0
- package/dist/internal/chat/chat-user.js +27 -0
- package/dist/internal/chat/commands.d.ts +91 -0
- package/dist/internal/chat/commands.d.ts.map +1 -0
- package/dist/internal/chat/commands.js +165 -0
- package/dist/internal/chat/context.d.ts +49 -2
- package/dist/internal/chat/context.d.ts.map +1 -1
- package/dist/internal/chat/context.js +57 -4
- package/dist/internal/chat/message-actions.d.ts +15 -0
- package/dist/internal/chat/message-actions.d.ts.map +1 -0
- package/dist/internal/chat/message-actions.js +113 -0
- package/dist/internal/chat/message-feedback.d.ts +68 -0
- package/dist/internal/chat/message-feedback.d.ts.map +1 -0
- package/dist/internal/chat/message-feedback.js +188 -0
- package/dist/internal/chat/message-metadata.d.ts.map +1 -1
- package/dist/internal/chat/message-metadata.js +7 -1
- package/dist/internal/chat/message-text.d.ts +9 -0
- package/dist/internal/chat/message-text.d.ts.map +1 -0
- package/dist/internal/chat/message-text.js +15 -0
- package/dist/internal/chat/message.d.ts +4 -2
- package/dist/internal/chat/message.d.ts.map +1 -1
- package/dist/internal/chat/message.js +8 -1
- package/dist/internal/chat/options.d.ts +94 -0
- package/dist/internal/chat/options.d.ts.map +1 -0
- package/dist/internal/chat/options.js +171 -0
- package/dist/internal/chat/page-attachment.d.ts +12 -0
- package/dist/internal/chat/page-attachment.d.ts.map +1 -0
- package/dist/internal/chat/page-attachment.js +18 -0
- package/dist/internal/chat/session-provider.d.ts +33 -0
- package/dist/internal/chat/session-provider.d.ts.map +1 -0
- package/dist/internal/chat/session-provider.js +138 -0
- package/dist/internal/chat/session.d.ts +60 -0
- package/dist/internal/chat/session.d.ts.map +1 -0
- package/dist/internal/chat/session.js +85 -0
- package/dist/internal/chat/shell.d.ts.map +1 -1
- package/dist/internal/chat/shell.js +86 -157
- package/dist/internal/chat/use-chat-commands.d.ts +28 -0
- package/dist/internal/chat/use-chat-commands.d.ts.map +1 -0
- package/dist/internal/chat/use-chat-commands.js +62 -0
- package/dist/internal/chat/user-avatar.d.ts +7 -0
- package/dist/internal/chat/user-avatar.d.ts.map +1 -0
- package/dist/internal/chat/user-avatar.js +27 -0
- package/dist/internal/eve-agent-session-cookie.d.ts +68 -0
- package/dist/internal/eve-agent-session-cookie.d.ts.map +1 -0
- package/dist/internal/eve-agent-session-cookie.js +164 -0
- package/dist/internal/eve-agent-session.d.ts +9 -7
- package/dist/internal/eve-agent-session.d.ts.map +1 -1
- package/dist/internal/eve-agent-session.js +10 -13
- package/dist/internal/eve-agent.d.ts +96 -24
- package/dist/internal/eve-agent.d.ts.map +1 -1
- package/dist/internal/eve-agent.js +74 -51
- package/dist/internal/feedback-action.d.ts +14 -0
- package/dist/internal/feedback-action.d.ts.map +1 -1
- package/dist/internal/feedback-action.js +37 -5
- package/dist/internal/mdx-to-markdown.d.ts.map +1 -1
- package/dist/internal/mdx-to-markdown.js +226 -19
- package/dist/internal/page-actions-client.d.ts +9 -0
- package/dist/internal/page-actions-client.d.ts.map +1 -1
- package/dist/internal/page-actions-client.js +8 -4
- package/dist/internal/provider-client.d.ts.map +1 -1
- package/dist/internal/provider-client.js +10 -4
- package/dist/internal/use-mobile.d.ts +7 -0
- package/dist/internal/use-mobile.d.ts.map +1 -1
- package/dist/internal/use-mobile.js +17 -1
- package/dist/internal/webmcp-client.d.ts.map +1 -1
- package/dist/internal/webmcp-client.js +13 -3
- package/dist/internal/webmcp.d.ts +5 -1
- package/dist/internal/webmcp.d.ts.map +1 -1
- package/dist/internal/webmcp.js +31 -1
- package/dist/pages/changelog.d.ts.map +1 -1
- package/dist/pages/changelog.js +4 -0
- package/dist/pages/docs.d.ts.map +1 -1
- package/dist/pages/docs.js +2 -0
- package/dist/routes/chat.d.ts +83 -5
- package/dist/routes/chat.d.ts.map +1 -1
- package/dist/routes/chat.js +517 -80
- package/dist/routes/discovery.d.ts +1 -1
- package/dist/routes/discovery.d.ts.map +1 -1
- package/dist/routes/discovery.js +7 -11
- package/dist/routes/openapi.d.ts.map +1 -1
- package/dist/routes/openapi.js +47 -25
- package/docs/agents.md +3 -3
- package/docs/llms.txt +634 -37
- package/docs/manifest.json +3 -3
- package/docs/pages/agent-readiness.md +1 -1
- package/docs/pages/ask-ai.md +570 -26
- package/docs/pages/configuration.md +21 -1
- package/docs/pages/env.md +17 -3
- package/docs/pages/feedback.md +4 -0
- package/docs/pages/webmcp.md +18 -3
- package/docs/sitemap.md +1 -1
- package/package.json +1 -2
- package/template/.env.example +5 -0
- package/template/AGENTS.md +2 -0
- package/template/content/docs/agent-readiness.mdx +1 -1
- package/template/content/docs/ask-ai.cn.mdx +466 -15
- package/template/content/docs/ask-ai.mdx +570 -26
- package/template/content/docs/configuration.cn.mdx +39 -0
- package/template/content/docs/configuration.mdx +21 -1
- package/template/content/docs/env.cn.mdx +15 -1
- package/template/content/docs/env.mdx +18 -4
- package/template/content/docs/feedback.cn.mdx +4 -0
- package/template/content/docs/feedback.mdx +4 -0
- package/template/content/docs/webmcp.mdx +18 -3
- package/template/package.json +1 -2
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { isEveAgentSessionHandle, } from "./eve-agent-session.js";
|
|
2
1
|
/**
|
|
3
2
|
* Client for the eve framework's session HTTP API, translating eve's NDJSON
|
|
4
3
|
* event stream into AI SDK UI message chunks.
|
|
@@ -9,6 +8,10 @@ import { isEveAgentSessionHandle, } from "./eve-agent-session.js";
|
|
|
9
8
|
* - `POST {url}/eve/v1/session/:sessionId` sends a follow-up with `{ message }`
|
|
10
9
|
* to that fixed session. An inactive session responds with
|
|
11
10
|
* `{ code: "session_not_active" }` and status 409.
|
|
11
|
+
* - `message` is a string or an array of `{ type: "text", text }` parts. Both
|
|
12
|
+
* message routes accept an optional top-level `clientContext` JSON object
|
|
13
|
+
* next to `message`; eve turns it into turn-scoped model context that is
|
|
14
|
+
* not stored in session history.
|
|
12
15
|
* - `GET {url}/eve/v1/session/:sessionId/stream?startIndex=N` streams
|
|
13
16
|
* newline-delimited JSON events. The stream stays open after
|
|
14
17
|
* `session.waiting`, so the client disconnects at turn boundaries and
|
|
@@ -25,30 +28,43 @@ const MAX_TRANSCRIPT_TOTAL_CHARS = 8000;
|
|
|
25
28
|
const MAX_SOURCES_PER_ACTION = 5;
|
|
26
29
|
const TRAILING_SLASH_PATTERN = /\/+$/;
|
|
27
30
|
const HTTP_URL_PATTERN = /^https?:\/\//;
|
|
31
|
+
/** JSON body for eve's message routes; `clientContext` only when set. */
|
|
32
|
+
const createMessageBody = (message, clientContext) => JSON.stringify(clientContext ? { message, clientContext } : { message });
|
|
28
33
|
const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
29
|
-
const normalizeAgentUrl = (url) => url.replace(TRAILING_SLASH_PATTERN, "");
|
|
34
|
+
export const normalizeAgentUrl = (url) => url.replace(TRAILING_SLASH_PATTERN, "");
|
|
30
35
|
const getMessageText = (message) => message.parts
|
|
31
36
|
.filter((part) => part.type === "text")
|
|
32
37
|
.map((part) => part.text)
|
|
33
38
|
.join("\n");
|
|
39
|
+
const isEveAgentMessageMetadata = (value) => isRecord(value) &&
|
|
40
|
+
typeof value.session === "string" &&
|
|
41
|
+
value.session.length > 0 &&
|
|
42
|
+
Number.isSafeInteger(value.streamIndex) &&
|
|
43
|
+
value.streamIndex >= 0;
|
|
44
|
+
const readEveAgentMetadata = (message) => message?.metadata?.eveAgent;
|
|
34
45
|
/**
|
|
35
|
-
*
|
|
36
|
-
* message.
|
|
37
|
-
*
|
|
38
|
-
*
|
|
46
|
+
* Stream position on the most recent assistant message before the trailing
|
|
47
|
+
* user message. Only the most recent assistant message counts: a turn that
|
|
48
|
+
* failed or was stopped carries no position, and resuming from an older one
|
|
49
|
+
* would replay events. Legacy shapes (`{ sessionId, streamIndex }` objects
|
|
50
|
+
* and opaque string tokens) read as no position.
|
|
39
51
|
*/
|
|
40
|
-
export const
|
|
41
|
-
for (let index = messages.length -
|
|
52
|
+
export const getEveAgentMessageMetadata = (messages) => {
|
|
53
|
+
for (let index = messages.length - 2; index >= 0; index--) {
|
|
42
54
|
const message = messages[index];
|
|
43
55
|
if (message?.role !== "assistant") {
|
|
44
56
|
continue;
|
|
45
57
|
}
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
return isEveAgentSessionHandle(handle) ? handle : null;
|
|
58
|
+
const metadata = readEveAgentMetadata(message);
|
|
59
|
+
return isEveAgentMessageMetadata(metadata) ? metadata : null;
|
|
49
60
|
}
|
|
50
61
|
return null;
|
|
51
62
|
};
|
|
63
|
+
/** Whether any earlier assistant message records an eve turn. */
|
|
64
|
+
export const hasPriorEveAgentTurn = (messages) => messages
|
|
65
|
+
.slice(0, -1)
|
|
66
|
+
.some((message) => message.role === "assistant" &&
|
|
67
|
+
isEveAgentMessageMetadata(readEveAgentMetadata(message)));
|
|
52
68
|
const truncate = (value, limit) => value.length > limit ? `${value.slice(0, limit)}...` : value;
|
|
53
69
|
/**
|
|
54
70
|
* Resolve the eve agent URL from the route option and site config, and
|
|
@@ -86,8 +102,8 @@ export const capLastUserMessageText = (messages, limit) => {
|
|
|
86
102
|
};
|
|
87
103
|
/**
|
|
88
104
|
* Inline prior conversation turns into a single message for a fresh eve
|
|
89
|
-
* session. Used when history exists but
|
|
90
|
-
* for example after the
|
|
105
|
+
* session. Used when history exists but the browser holds no session for
|
|
106
|
+
* this conversation — for example after the session cookie expired.
|
|
91
107
|
*/
|
|
92
108
|
export const buildEveAgentTranscript = (messages, currentMessage) => {
|
|
93
109
|
const priorMessages = messages.slice(0, -1);
|
|
@@ -163,7 +179,7 @@ const parseSessionResponse = async (response) => {
|
|
|
163
179
|
return { sessionId: body.sessionId };
|
|
164
180
|
};
|
|
165
181
|
/** Start an eve session without a turn so the first message can reuse it. */
|
|
166
|
-
export const
|
|
182
|
+
export const createEmptyEveAgentSession = async ({ agentUrl, fetchImpl = fetch, headers, signal, }) => {
|
|
167
183
|
const response = await fetchImpl(`${normalizeAgentUrl(agentUrl)}${EVE_SESSION_PATH}`, {
|
|
168
184
|
method: "POST",
|
|
169
185
|
body: JSON.stringify({}),
|
|
@@ -173,13 +189,12 @@ export const prewarmEveAgentSession = async ({ agentUrl, fetchImpl = fetch, head
|
|
|
173
189
|
if (!response.ok) {
|
|
174
190
|
throw new Error(`eve agent session prewarm failed with status ${response.status}.`);
|
|
175
191
|
}
|
|
176
|
-
|
|
177
|
-
return { sessionId: session.sessionId, streamIndex: 0 };
|
|
192
|
+
return await parseSessionResponse(response);
|
|
178
193
|
};
|
|
179
194
|
const isTurnBoundaryEvent = (type) => type === "session.waiting" ||
|
|
180
195
|
type === "session.completed" ||
|
|
181
196
|
type === "session.failed";
|
|
182
|
-
const createEveEventTranslator = (writer) => {
|
|
197
|
+
const createEveEventTranslator = (writer, { toolCitations, visibleTools }) => {
|
|
183
198
|
let blockCounter = 0;
|
|
184
199
|
let openTextId = null;
|
|
185
200
|
let openReasoningId = null;
|
|
@@ -236,6 +251,11 @@ const createEveEventTranslator = (writer) => {
|
|
|
236
251
|
continue;
|
|
237
252
|
}
|
|
238
253
|
const toolName = getActionName(action);
|
|
254
|
+
// Hidden tools never become known calls, so their results and any
|
|
255
|
+
// citations in them are dropped too.
|
|
256
|
+
if (visibleTools && !visibleTools.has(toolName)) {
|
|
257
|
+
continue;
|
|
258
|
+
}
|
|
239
259
|
knownToolCalls.set(action.callId, toolName);
|
|
240
260
|
writer.write({
|
|
241
261
|
type: "tool-input-available",
|
|
@@ -289,10 +309,12 @@ const createEveEventTranslator = (writer) => {
|
|
|
289
309
|
writer.write({
|
|
290
310
|
type: "tool-output-available",
|
|
291
311
|
toolCallId: result.callId,
|
|
292
|
-
output: result.output ?? null,
|
|
312
|
+
output: toolCitations ? (result.output ?? null) : null,
|
|
293
313
|
dynamic: true,
|
|
294
314
|
});
|
|
295
|
-
|
|
315
|
+
if (toolCitations) {
|
|
316
|
+
writeSourceChunks(result.output);
|
|
317
|
+
}
|
|
296
318
|
};
|
|
297
319
|
const handleInputRequested = (data) => {
|
|
298
320
|
if (!Array.isArray(data.requests)) {
|
|
@@ -378,13 +400,13 @@ const waitForRetry = (delayMs, signal) => new Promise((resolve, reject) => {
|
|
|
378
400
|
}
|
|
379
401
|
signal?.addEventListener("abort", onAbort, { once: true });
|
|
380
402
|
});
|
|
381
|
-
const postSessionMessage = async ({ agentUrl,
|
|
403
|
+
const postSessionMessage = async ({ agentUrl, clientContext, fetchImpl, headers, message, sessionId, signal, }) => {
|
|
382
404
|
const readyDeadline = Date.now() + SESSION_SEND_READY_TIMEOUT_MS;
|
|
383
405
|
let retryDelayMs = SESSION_SEND_RETRY_BASE_DELAY_MS;
|
|
384
406
|
for (;;) {
|
|
385
|
-
const response = await fetchImpl(`${agentUrl}${EVE_SESSION_PATH}/${encodeURIComponent(
|
|
407
|
+
const response = await fetchImpl(`${agentUrl}${EVE_SESSION_PATH}/${encodeURIComponent(sessionId)}`, {
|
|
386
408
|
method: "POST",
|
|
387
|
-
body:
|
|
409
|
+
body: createMessageBody(message, clientContext),
|
|
388
410
|
headers,
|
|
389
411
|
signal,
|
|
390
412
|
});
|
|
@@ -401,22 +423,31 @@ const postSessionMessage = async ({ agentUrl, fetchImpl, handle, headers, messag
|
|
|
401
423
|
retryDelayMs = Math.min(retryDelayMs * 2, SESSION_SEND_RETRY_MAX_DELAY_MS);
|
|
402
424
|
}
|
|
403
425
|
};
|
|
404
|
-
|
|
405
|
-
|
|
426
|
+
/**
|
|
427
|
+
* Send the turn's message to the agent: as a follow-up to `continuation`
|
|
428
|
+
* when given, otherwise (or when that session is no longer active) as the
|
|
429
|
+
* first message of a new session. Resolves once the agent has accepted the
|
|
430
|
+
* message, before any event is streamed, so the caller can bind the
|
|
431
|
+
* resulting session to the response.
|
|
432
|
+
*/
|
|
433
|
+
export const startOrContinueEveAgentSession = async ({ agentUrl, clientContext, continuation = null, fallbackMessage, fetchImpl = fetch, headers, message, signal, }) => {
|
|
434
|
+
const normalizedUrl = normalizeAgentUrl(agentUrl);
|
|
435
|
+
if (continuation) {
|
|
406
436
|
const { code, response } = await postSessionMessage({
|
|
407
|
-
agentUrl,
|
|
437
|
+
agentUrl: normalizedUrl,
|
|
438
|
+
clientContext,
|
|
408
439
|
fetchImpl,
|
|
409
|
-
handle,
|
|
410
440
|
headers,
|
|
411
441
|
message,
|
|
442
|
+
sessionId: continuation.sessionId,
|
|
412
443
|
signal,
|
|
413
444
|
});
|
|
414
445
|
if (response.ok) {
|
|
415
446
|
const session = await parseSessionResponse(response);
|
|
416
|
-
if (session.sessionId !==
|
|
447
|
+
if (session.sessionId !== continuation.sessionId) {
|
|
417
448
|
throw new Error("eve agent follow-up returned a different session id.");
|
|
418
449
|
}
|
|
419
|
-
return
|
|
450
|
+
return continuation;
|
|
420
451
|
}
|
|
421
452
|
// Ask AI recovers from an inactive session by explicitly creating a new
|
|
422
453
|
// one with the bounded transcript.
|
|
@@ -424,9 +455,9 @@ const startOrContinueSession = async ({ agentUrl, fallbackMessage, fetchImpl, ha
|
|
|
424
455
|
throw new Error(`eve agent follow-up failed with status ${response.status}.`);
|
|
425
456
|
}
|
|
426
457
|
}
|
|
427
|
-
const response = await fetchImpl(`${
|
|
458
|
+
const response = await fetchImpl(`${normalizedUrl}${EVE_SESSION_PATH}`, {
|
|
428
459
|
method: "POST",
|
|
429
|
-
body:
|
|
460
|
+
body: createMessageBody(continuation ? (fallbackMessage ?? message) : message, clientContext),
|
|
430
461
|
headers,
|
|
431
462
|
signal,
|
|
432
463
|
});
|
|
@@ -510,29 +541,24 @@ const cancelSession = ({ agentUrl, fetchImpl, headers, sessionId, }) => fetchImp
|
|
|
510
541
|
// the cancel request fails.
|
|
511
542
|
});
|
|
512
543
|
/**
|
|
513
|
-
*
|
|
514
|
-
* message chunks to the provided writer.
|
|
544
|
+
* Stream one Ask AI turn from a session that already accepted the turn's
|
|
545
|
+
* message, writing AI SDK UI message chunks to the provided writer.
|
|
515
546
|
*/
|
|
516
|
-
export const
|
|
547
|
+
export const streamEveAgentTurn = async ({ agentUrl, fetchImpl = fetch, headers, initialChunks = [], session, sessionTag = null, signal, toolCitations = true, visibleTools, writer, }) => {
|
|
517
548
|
const normalizedUrl = normalizeAgentUrl(agentUrl);
|
|
549
|
+
const { sessionId, startIndex } = session;
|
|
518
550
|
// A bare `start` chunk does not flush client state; providing a message
|
|
519
551
|
// id makes the assistant message render immediately, so the chat shows
|
|
520
|
-
// the "Thinking..." indicator during
|
|
521
|
-
//
|
|
552
|
+
// the "Thinking..." indicator during model startup instead of a blank
|
|
553
|
+
// panel.
|
|
522
554
|
writer.write({ type: "start", messageId: `eve-${crypto.randomUUID()}` });
|
|
523
555
|
for (const chunk of initialChunks) {
|
|
524
556
|
writer.write(chunk);
|
|
525
557
|
}
|
|
526
|
-
const
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
fetchImpl,
|
|
530
|
-
handle,
|
|
531
|
-
headers,
|
|
532
|
-
message,
|
|
533
|
-
signal,
|
|
558
|
+
const translator = createEveEventTranslator(writer, {
|
|
559
|
+
toolCitations,
|
|
560
|
+
visibleTools: visibleTools ? new Set(visibleTools) : null,
|
|
534
561
|
});
|
|
535
|
-
const translator = createEveEventTranslator(writer);
|
|
536
562
|
let consumed = 0;
|
|
537
563
|
try {
|
|
538
564
|
consumed = await streamSessionEvents({
|
|
@@ -564,15 +590,12 @@ export const runEveAgentTurn = async ({ agentUrl, fallbackMessage, fetchImpl = f
|
|
|
564
590
|
throw error;
|
|
565
591
|
}
|
|
566
592
|
translator.finalize();
|
|
567
|
-
if (translator.isSessionWaiting()) {
|
|
568
|
-
const
|
|
569
|
-
|
|
593
|
+
if (sessionTag && translator.isSessionWaiting()) {
|
|
594
|
+
const eveAgent = {
|
|
595
|
+
session: sessionTag,
|
|
570
596
|
streamIndex: startIndex + consumed,
|
|
571
597
|
};
|
|
572
|
-
writer.write({
|
|
573
|
-
type: "finish",
|
|
574
|
-
messageMetadata: { eveAgent: nextHandle },
|
|
575
|
-
});
|
|
598
|
+
writer.write({ type: "finish", messageMetadata: { eveAgent } });
|
|
576
599
|
return;
|
|
577
600
|
}
|
|
578
601
|
writer.write({ type: "finish" });
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type ChatMessageFeedback } from "./chat/message-feedback";
|
|
1
2
|
export interface FeedbackPayload {
|
|
2
3
|
emotion: string;
|
|
3
4
|
message: string;
|
|
@@ -7,8 +8,21 @@ interface SendFeedbackOptions {
|
|
|
7
8
|
siteId?: string;
|
|
8
9
|
url: string;
|
|
9
10
|
}
|
|
11
|
+
interface SendChatMessageFeedbackOptions {
|
|
12
|
+
feedback: ChatMessageFeedback;
|
|
13
|
+
siteId?: string;
|
|
14
|
+
}
|
|
10
15
|
export declare const sendFeedback: ({ url, feedback, siteId, }: SendFeedbackOptions) => Promise<{
|
|
11
16
|
success: boolean;
|
|
12
17
|
}>;
|
|
18
|
+
/**
|
|
19
|
+
* Send a thumbs up or down on an Ask AI answer to the central feedback
|
|
20
|
+
* service. The note starts with `[Ask AI]` and carries the question,
|
|
21
|
+
* the sources shown, and the answer; `url` is the page the reader was on and
|
|
22
|
+
* `thumbs` is the vote.
|
|
23
|
+
*/
|
|
24
|
+
export declare const sendChatMessageFeedback: ({ feedback, siteId, }: SendChatMessageFeedbackOptions) => Promise<{
|
|
25
|
+
success: boolean;
|
|
26
|
+
}>;
|
|
13
27
|
export {};
|
|
14
28
|
//# sourceMappingURL=feedback-action.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"feedback-action.d.ts","sourceRoot":"","sources":["../../src/internal/feedback-action.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"feedback-action.d.ts","sourceRoot":"","sources":["../../src/internal/feedback-action.ts"],"names":[],"mappings":"AAGA,OAAO,EAEL,KAAK,mBAAmB,EAGzB,MAAM,yBAAyB,CAAC;AAEjC,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,UAAU,mBAAmB;IAC3B,QAAQ,EAAE,eAAe,CAAC;IAC1B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,GAAG,EAAE,MAAM,CAAC;CACb;AAED,UAAU,8BAA8B;IACtC,QAAQ,EAAE,mBAAmB,CAAC;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AA6DD,eAAO,MAAM,YAAY,GAAU,4BAIhC,mBAAmB,KAAG,OAAO,CAAC;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE,CAWpD,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB,GAAU,uBAG3C,8BAA8B,KAAG,OAAO,CAAC;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE,CAiB/D,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use server";
|
|
2
2
|
import { headers } from "next/headers";
|
|
3
|
+
import { CHAT_FEEDBACK_URL_LIMIT, formatChatMessageFeedbackNote, normalizeChatMessageFeedback, } from "./chat/message-feedback";
|
|
3
4
|
const emotions = [
|
|
4
5
|
{ name: "cry", emoji: "😭" },
|
|
5
6
|
{ name: "sad", emoji: "😕" },
|
|
@@ -8,8 +9,7 @@ const emotions = [
|
|
|
8
9
|
];
|
|
9
10
|
const protocol = process.env.NODE_ENV === "production" ? "https" : "http";
|
|
10
11
|
const baseUrl = `${protocol}://${process.env.NEXT_PUBLIC_VERCEL_PROJECT_PRODUCTION_URL}`;
|
|
11
|
-
|
|
12
|
-
const emoji = emotions.find((emotion) => emotion.name === feedback.emotion)?.emoji;
|
|
12
|
+
const postFeedback = async ({ emotion, maxUrlLength, note, siteId, thumbs, url, }) => {
|
|
13
13
|
const endpoint = new URL("/feedback", "https://geistdocs.com/feedback");
|
|
14
14
|
const headersList = await headers();
|
|
15
15
|
try {
|
|
@@ -19,9 +19,10 @@ export const sendFeedback = async ({ url, feedback, siteId, }) => {
|
|
|
19
19
|
"Content-Type": "application/json",
|
|
20
20
|
},
|
|
21
21
|
body: JSON.stringify({
|
|
22
|
-
note
|
|
23
|
-
url: new URL(url, baseUrl).toString(),
|
|
24
|
-
emotion
|
|
22
|
+
note,
|
|
23
|
+
url: new URL(url, baseUrl).toString().slice(0, maxUrlLength),
|
|
24
|
+
emotion,
|
|
25
|
+
thumbs,
|
|
25
26
|
ua: headersList.get("user-agent") ?? undefined,
|
|
26
27
|
ip: headersList.get("x-real-ip") || headersList.get("x-forwarded-for"),
|
|
27
28
|
label: siteId,
|
|
@@ -38,3 +39,34 @@ export const sendFeedback = async ({ url, feedback, siteId, }) => {
|
|
|
38
39
|
return { success: false };
|
|
39
40
|
}
|
|
40
41
|
};
|
|
42
|
+
export const sendFeedback = async ({ url, feedback, siteId, }) => {
|
|
43
|
+
const emoji = emotions.find((emotion) => emotion.name === feedback.emotion)?.emoji;
|
|
44
|
+
return await postFeedback({
|
|
45
|
+
emotion: emoji,
|
|
46
|
+
note: feedback.message,
|
|
47
|
+
siteId,
|
|
48
|
+
url,
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* Send a thumbs up or down on an Ask AI answer to the central feedback
|
|
53
|
+
* service. The note starts with `[Ask AI]` and carries the question,
|
|
54
|
+
* the sources shown, and the answer; `url` is the page the reader was on and
|
|
55
|
+
* `thumbs` is the vote.
|
|
56
|
+
*/
|
|
57
|
+
export const sendChatMessageFeedback = async ({ feedback, siteId, }) => {
|
|
58
|
+
// Server actions accept any input, so re-validate and re-cap here.
|
|
59
|
+
const normalized = normalizeChatMessageFeedback(feedback);
|
|
60
|
+
if (!normalized) {
|
|
61
|
+
return { success: false };
|
|
62
|
+
}
|
|
63
|
+
// The service labels `thumbs` votes; it only maps the four page-feedback
|
|
64
|
+
// emoji in `emotion`, so the vote emoji goes in the note instead.
|
|
65
|
+
return await postFeedback({
|
|
66
|
+
maxUrlLength: CHAT_FEEDBACK_URL_LIMIT,
|
|
67
|
+
note: formatChatMessageFeedbackNote(normalized),
|
|
68
|
+
siteId: typeof siteId === "string" ? siteId : undefined,
|
|
69
|
+
thumbs: normalized.vote,
|
|
70
|
+
url: normalized.pageUrl,
|
|
71
|
+
});
|
|
72
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mdx-to-markdown.d.ts","sourceRoot":"","sources":["../../src/internal/mdx-to-markdown.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,KAAK,aAAa,EAAW,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"mdx-to-markdown.d.ts","sourceRoot":"","sources":["../../src/internal/mdx-to-markdown.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,KAAK,aAAa,EAAW,MAAM,SAAS,CAAC;AA43CtD;;;GAGG;AACH,eAAO,MAAM,mBAAmB,GAAI,gBAAgB,aAAa,MAGjD,QAAQ,MAAM,oBAe7B,CAAC;AAEF,yEAAyE;AACzE,eAAO,MAAM,aAAa,WAlBF,MAAM,oBAkBoB,CAAC"}
|