@vercel/geistdocs 2.7.10 → 2.8.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.
Files changed (120) hide show
  1. package/dist/assets/icons/icon-thumb-down.d.ts +26 -0
  2. package/dist/assets/icons/icon-thumb-down.d.ts.map +1 -0
  3. package/dist/assets/icons/icon-thumb-down.js +25 -0
  4. package/dist/assets/icons/index.d.ts +1 -0
  5. package/dist/assets/icons/index.d.ts.map +1 -1
  6. package/dist/assets/icons/index.js +1 -0
  7. package/dist/cli/index.js +1 -1
  8. package/dist/config.d.ts +67 -3
  9. package/dist/config.d.ts.map +1 -1
  10. package/dist/controls.d.ts +23 -1
  11. package/dist/controls.d.ts.map +1 -1
  12. package/dist/controls.js +44 -3
  13. package/dist/footer.js +1 -1
  14. package/dist/internal/chat/activity.d.ts +5 -1
  15. package/dist/internal/chat/activity.d.ts.map +1 -1
  16. package/dist/internal/chat/activity.js +11 -4
  17. package/dist/internal/chat/chat-user.d.ts +12 -0
  18. package/dist/internal/chat/chat-user.d.ts.map +1 -0
  19. package/dist/internal/chat/chat-user.js +27 -0
  20. package/dist/internal/chat/commands.d.ts +91 -0
  21. package/dist/internal/chat/commands.d.ts.map +1 -0
  22. package/dist/internal/chat/commands.js +165 -0
  23. package/dist/internal/chat/context.d.ts +46 -2
  24. package/dist/internal/chat/context.d.ts.map +1 -1
  25. package/dist/internal/chat/context.js +50 -4
  26. package/dist/internal/chat/message-actions.d.ts +15 -0
  27. package/dist/internal/chat/message-actions.d.ts.map +1 -0
  28. package/dist/internal/chat/message-actions.js +113 -0
  29. package/dist/internal/chat/message-feedback.d.ts +68 -0
  30. package/dist/internal/chat/message-feedback.d.ts.map +1 -0
  31. package/dist/internal/chat/message-feedback.js +188 -0
  32. package/dist/internal/chat/message-metadata.d.ts.map +1 -1
  33. package/dist/internal/chat/message-metadata.js +7 -1
  34. package/dist/internal/chat/message-text.d.ts +9 -0
  35. package/dist/internal/chat/message-text.d.ts.map +1 -0
  36. package/dist/internal/chat/message-text.js +15 -0
  37. package/dist/internal/chat/message.d.ts +4 -2
  38. package/dist/internal/chat/message.d.ts.map +1 -1
  39. package/dist/internal/chat/message.js +8 -1
  40. package/dist/internal/chat/options.d.ts +94 -0
  41. package/dist/internal/chat/options.d.ts.map +1 -0
  42. package/dist/internal/chat/options.js +171 -0
  43. package/dist/internal/chat/page-attachment.d.ts +12 -0
  44. package/dist/internal/chat/page-attachment.d.ts.map +1 -0
  45. package/dist/internal/chat/page-attachment.js +18 -0
  46. package/dist/internal/chat/session-provider.d.ts +33 -0
  47. package/dist/internal/chat/session-provider.d.ts.map +1 -0
  48. package/dist/internal/chat/session-provider.js +138 -0
  49. package/dist/internal/chat/session.d.ts +60 -0
  50. package/dist/internal/chat/session.d.ts.map +1 -0
  51. package/dist/internal/chat/session.js +85 -0
  52. package/dist/internal/chat/shell.d.ts.map +1 -1
  53. package/dist/internal/chat/shell.js +81 -157
  54. package/dist/internal/chat/use-chat-commands.d.ts +28 -0
  55. package/dist/internal/chat/use-chat-commands.d.ts.map +1 -0
  56. package/dist/internal/chat/use-chat-commands.js +62 -0
  57. package/dist/internal/chat/user-avatar.d.ts +7 -0
  58. package/dist/internal/chat/user-avatar.d.ts.map +1 -0
  59. package/dist/internal/chat/user-avatar.js +27 -0
  60. package/dist/internal/eve-agent-session-cookie.d.ts +68 -0
  61. package/dist/internal/eve-agent-session-cookie.d.ts.map +1 -0
  62. package/dist/internal/eve-agent-session-cookie.js +164 -0
  63. package/dist/internal/eve-agent-session.d.ts +9 -7
  64. package/dist/internal/eve-agent-session.d.ts.map +1 -1
  65. package/dist/internal/eve-agent-session.js +10 -13
  66. package/dist/internal/eve-agent.d.ts +96 -24
  67. package/dist/internal/eve-agent.d.ts.map +1 -1
  68. package/dist/internal/eve-agent.js +74 -51
  69. package/dist/internal/feedback-action.d.ts +14 -0
  70. package/dist/internal/feedback-action.d.ts.map +1 -1
  71. package/dist/internal/feedback-action.js +37 -5
  72. package/dist/internal/page-actions-client.d.ts +9 -0
  73. package/dist/internal/page-actions-client.d.ts.map +1 -1
  74. package/dist/internal/page-actions-client.js +8 -4
  75. package/dist/internal/provider-client.d.ts.map +1 -1
  76. package/dist/internal/provider-client.js +2 -2
  77. package/dist/internal/use-mobile.d.ts +7 -0
  78. package/dist/internal/use-mobile.d.ts.map +1 -1
  79. package/dist/internal/use-mobile.js +17 -1
  80. package/dist/internal/webmcp-client.d.ts.map +1 -1
  81. package/dist/internal/webmcp-client.js +13 -3
  82. package/dist/internal/webmcp.d.ts +5 -1
  83. package/dist/internal/webmcp.d.ts.map +1 -1
  84. package/dist/internal/webmcp.js +31 -1
  85. package/dist/pages/changelog.d.ts.map +1 -1
  86. package/dist/pages/changelog.js +4 -0
  87. package/dist/pages/docs.d.ts.map +1 -1
  88. package/dist/pages/docs.js +2 -0
  89. package/dist/routes/chat.d.ts +83 -5
  90. package/dist/routes/chat.d.ts.map +1 -1
  91. package/dist/routes/chat.js +517 -80
  92. package/dist/routes/discovery.d.ts +1 -1
  93. package/dist/routes/discovery.d.ts.map +1 -1
  94. package/dist/routes/discovery.js +7 -11
  95. package/dist/routes/openapi.d.ts.map +1 -1
  96. package/dist/routes/openapi.js +47 -25
  97. package/docs/agents.md +3 -3
  98. package/docs/llms.txt +631 -35
  99. package/docs/manifest.json +3 -3
  100. package/docs/pages/agent-readiness.md +1 -1
  101. package/docs/pages/ask-ai.md +567 -24
  102. package/docs/pages/configuration.md +21 -1
  103. package/docs/pages/env.md +17 -3
  104. package/docs/pages/feedback.md +4 -0
  105. package/docs/pages/webmcp.md +18 -3
  106. package/docs/sitemap.md +1 -1
  107. package/package.json +1 -2
  108. package/template/.env.example +5 -0
  109. package/template/AGENTS.md +2 -0
  110. package/template/content/docs/agent-readiness.mdx +1 -1
  111. package/template/content/docs/ask-ai.cn.mdx +466 -15
  112. package/template/content/docs/ask-ai.mdx +567 -24
  113. package/template/content/docs/configuration.cn.mdx +39 -0
  114. package/template/content/docs/configuration.mdx +21 -1
  115. package/template/content/docs/env.cn.mdx +15 -1
  116. package/template/content/docs/env.mdx +18 -4
  117. package/template/content/docs/feedback.cn.mdx +4 -0
  118. package/template/content/docs/feedback.mdx +4 -0
  119. package/template/content/docs/webmcp.mdx +18 -3
  120. package/template/package.json +1 -2
@@ -0,0 +1,188 @@
1
+ import { getMessageSources } from "./message-sources";
2
+ import { getMessageMarkdown } from "./message-text";
3
+ /** Longest question or answer text sent with Ask AI feedback. */
4
+ export const CHAT_FEEDBACK_TEXT_LIMIT = 4000;
5
+ /** Most source URLs sent with Ask AI feedback. */
6
+ export const CHAT_FEEDBACK_SOURCE_LIMIT = 10;
7
+ /** The feedback service rejects `url` values over 1,024 characters. */
8
+ export const CHAT_FEEDBACK_URL_LIMIT = 1024;
9
+ /** The feedback service rejects `note` values over 16,384 characters. */
10
+ export const CHAT_FEEDBACK_NOTE_LIMIT = 16_384;
11
+ /** First line of every Ask AI feedback note, for feedback triage. */
12
+ export const CHAT_FEEDBACK_NOTE_PREFIX = "[Ask AI]";
13
+ export const CHAT_FEEDBACK_EMOJI = {
14
+ up: "👍",
15
+ down: "👎",
16
+ };
17
+ const ELLIPSIS = "…";
18
+ const BACKTICK_RUN_PATTERN = /`+/g;
19
+ const WHITESPACE_PATTERN = /\s+/g;
20
+ /** Characters that could start Markdown, mentions, or HTML in the summary. */
21
+ const SUMMARY_MARKUP_PATTERN = /[`*_~[\]()!<>@#|\\]/g;
22
+ /** A source rendered in an inline code span must not be able to leave it. */
23
+ const UNSAFE_SOURCE_PATTERN = /[\s`<>]/;
24
+ /**
25
+ * Longest question summary in the note's first line. The feedback service
26
+ * titles the issue with the note's first ten words.
27
+ */
28
+ const CHAT_FEEDBACK_SUMMARY_LIMIT = 80;
29
+ const isHighSurrogate = (code) => code >= 0xd8_00 && code <= 0xdb_ff;
30
+ /**
31
+ * Shorten `value` to at most `limit` characters, ending with an ellipsis
32
+ * when shortened. Never splits a surrogate pair.
33
+ */
34
+ export const capText = (value, limit) => {
35
+ if (value.length <= limit) {
36
+ return value;
37
+ }
38
+ let end = Math.max(0, limit - ELLIPSIS.length);
39
+ if (end > 0 && isHighSurrogate(value.charCodeAt(end - 1))) {
40
+ end -= 1;
41
+ }
42
+ return `${value.slice(0, end)}${ELLIPSIS}`;
43
+ };
44
+ export const isChatMessageFeedbackVote = (value) => value === "up" || value === "down";
45
+ const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
46
+ /** The vote stored on a message by `withMessageFeedbackVote`, if any. */
47
+ export const readMessageFeedbackVote = (message) => {
48
+ const vote = isRecord(message.metadata)
49
+ ? message.metadata.feedback
50
+ : undefined;
51
+ return isChatMessageFeedbackVote(vote) ? vote : undefined;
52
+ };
53
+ /**
54
+ * Record `vote` in the metadata of the message with `messageId`, keeping
55
+ * every other metadata key (such as the eve stream position) so the vote
56
+ * persists with stored chat history without changing later chat requests.
57
+ */
58
+ export const withMessageFeedbackVote = (messages, messageId, vote) => messages.map((message) => message.id === messageId
59
+ ? {
60
+ ...message,
61
+ metadata: {
62
+ ...(isRecord(message.metadata) ? message.metadata : {}),
63
+ feedback: vote,
64
+ },
65
+ }
66
+ : message);
67
+ const isPageContextMessage = (message) => isRecord(message.metadata) && message.metadata.isPageContext === true;
68
+ /**
69
+ * The question an assistant message answers: the closest earlier user
70
+ * message, skipping page-context messages the chat route also ignores.
71
+ */
72
+ const getAnsweredQuestion = (messages, answerIndex) => {
73
+ for (let index = answerIndex - 1; index >= 0; index--) {
74
+ const message = messages[index];
75
+ if (message?.role === "user" && !isPageContextMessage(message)) {
76
+ return getMessageMarkdown(message);
77
+ }
78
+ }
79
+ return "";
80
+ };
81
+ const isRootRelativePath = (value) => typeof value === "string" &&
82
+ value.startsWith("/") &&
83
+ !value.startsWith("//") &&
84
+ !value.includes("\\");
85
+ /** Sources are HTTP(S) URLs or site paths with no whitespace or markup. */
86
+ const isFeedbackSource = (value) => {
87
+ if (typeof value !== "string" || UNSAFE_SOURCE_PATTERN.test(value)) {
88
+ return false;
89
+ }
90
+ if (isRootRelativePath(value)) {
91
+ return true;
92
+ }
93
+ try {
94
+ const { protocol } = new URL(value);
95
+ return protocol === "http:" || protocol === "https:";
96
+ }
97
+ catch {
98
+ return false;
99
+ }
100
+ };
101
+ /**
102
+ * Validate and cap feedback before it crosses a trust boundary. Server
103
+ * actions accept arbitrary input, so the server re-runs this on whatever the
104
+ * browser sent. Returns `null` for input that is not answer feedback.
105
+ */
106
+ export const normalizeChatMessageFeedback = (input) => {
107
+ if (!isRecord(input)) {
108
+ return null;
109
+ }
110
+ const { answer, pageUrl, question, sources, vote } = input;
111
+ if (!isChatMessageFeedbackVote(vote) ||
112
+ typeof answer !== "string" ||
113
+ !answer.trim() ||
114
+ !isRootRelativePath(pageUrl)) {
115
+ return null;
116
+ }
117
+ return {
118
+ answer: capText(answer.trim(), CHAT_FEEDBACK_TEXT_LIMIT),
119
+ // A truncated path still names the page; an ellipsis would not.
120
+ pageUrl: pageUrl.slice(0, CHAT_FEEDBACK_URL_LIMIT),
121
+ question: typeof question === "string"
122
+ ? capText(question.trim(), CHAT_FEEDBACK_TEXT_LIMIT)
123
+ : "",
124
+ sources: Array.isArray(sources)
125
+ ? Array.from(new Set(sources
126
+ .map((source) => typeof source === "string" ? source.trim() : source)
127
+ .filter(isFeedbackSource)))
128
+ .slice(0, CHAT_FEEDBACK_SOURCE_LIMIT)
129
+ .map((source) => capText(source, CHAT_FEEDBACK_URL_LIMIT))
130
+ : [],
131
+ vote,
132
+ };
133
+ };
134
+ /**
135
+ * Collect feedback for the assistant message with `messageId`. Returns
136
+ * `null` when the message is missing, is not an assistant message, or has no
137
+ * text to rate.
138
+ */
139
+ export const buildChatMessageFeedback = ({ messageId, messages, pageUrl, vote, }) => {
140
+ const index = messages.findIndex((message) => message.id === messageId);
141
+ const message = messages[index];
142
+ if (message?.role !== "assistant") {
143
+ return null;
144
+ }
145
+ return normalizeChatMessageFeedback({
146
+ answer: getMessageMarkdown(message),
147
+ pageUrl,
148
+ question: getAnsweredQuestion(messages, index),
149
+ sources: getMessageSources(message.parts).map((source) => source.url),
150
+ vote,
151
+ });
152
+ };
153
+ /**
154
+ * Fence `text` as a code block whose fence is longer than any backtick run
155
+ * inside it, so the text renders verbatim: Markdown, @-mentions, and images
156
+ * in a question or answer stay inert in the triage issue. The summary line
157
+ * drops markup characters and sources render as inline code instead.
158
+ */
159
+ const fence = (text, language) => {
160
+ const longestRun = Math.max(0, ...Array.from(text.matchAll(BACKTICK_RUN_PATTERN), ([run]) => run.length));
161
+ const marker = "`".repeat(Math.max(3, longestRun + 1));
162
+ return `${marker}${language}\n${text}\n${marker}`;
163
+ };
164
+ /**
165
+ * The `note` sent to the feedback service. Its first line starts with
166
+ * `CHAT_FEEDBACK_NOTE_PREFIX` and the vote emoji, so triage can tell Ask AI
167
+ * feedback from page feedback, then summarizes the question on one line
168
+ * because the service titles the issue with the note's first words. The
169
+ * answer comes last so the note limit can only ever shorten the answer.
170
+ */
171
+ export const formatChatMessageFeedbackNote = (feedback) => {
172
+ const emoji = CHAT_FEEDBACK_EMOJI[feedback.vote];
173
+ const verdict = feedback.vote === "up" ? "Helpful" : "Not helpful";
174
+ const summary = capText(feedback.question
175
+ .replace(SUMMARY_MARKUP_PATTERN, "")
176
+ .replace(WHITESPACE_PATTERN, " ")
177
+ .trim(), CHAT_FEEDBACK_SUMMARY_LIMIT);
178
+ const sections = [
179
+ `${CHAT_FEEDBACK_NOTE_PREFIX} ${emoji} ${summary || `${verdict} answer`}`,
180
+ `**Vote:** ${verdict}`,
181
+ `**Question**\n\n${feedback.question ? fence(feedback.question, "text") : "_No question found._"}`,
182
+ `**Sources**\n\n${feedback.sources.length > 0
183
+ ? feedback.sources.map((source) => `- \`${source}\``).join("\n")
184
+ : "_No sources shown._"}`,
185
+ `**Answer**\n\n${fence(feedback.answer, "md")}`,
186
+ ];
187
+ return capText(sections.join("\n\n"), CHAT_FEEDBACK_NOTE_LIMIT);
188
+ };
@@ -1 +1 @@
1
- {"version":3,"file":"message-metadata.d.ts","sourceRoot":"","sources":["../../../src/internal/chat/message-metadata.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAgB,KAAK,SAAS,EAAE,MAAM,IAAI,CAAC;AAOlD,UAAU,oBAAoB;IAC5B,UAAU,EAAE,OAAO,CAAC;IACpB,KAAK,EAAE,SAAS,CAAC,OAAO,CAAC,CAAC;CAC3B;AAQD,eAAO,MAAM,eAAe,GAAI,wBAG7B,oBAAoB,mDA0DtB,CAAC"}
1
+ {"version":3,"file":"message-metadata.d.ts","sourceRoot":"","sources":["../../../src/internal/chat/message-metadata.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAgB,KAAK,SAAS,EAAE,MAAM,IAAI,CAAC;AAQlD,UAAU,oBAAoB;IAC5B,UAAU,EAAE,OAAO,CAAC;IACpB,KAAK,EAAE,SAAS,CAAC,OAAO,CAAC,CAAC;CAC3B;AAQD,eAAO,MAAM,eAAe,GAAI,wBAG7B,oBAAoB,mDA+DtB,CAAC"}
@@ -2,13 +2,19 @@
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { isToolUIPart } from "ai";
4
4
  import { IconBookmark, IconChevronDown } from "#geistdocs-assets/icons";
5
+ import { useGeistdocsConfig } from "../config-context";
5
6
  import { getMessageActivity } from "./activity";
6
7
  import { DotsSpinner } from "./dots-spinner";
7
8
  import { getMessageSources } from "./message-sources";
8
9
  import { Source, Sources, SourcesContent, SourcesTrigger } from "./sources";
9
10
  const LoadingContainer = ({ children }) => (_jsx("div", { className: "h-12 animate-pulse pt-2 text-gray-900 text-sm", children: children }));
10
11
  export const MessageMetadata = ({ parts, inProgress, }) => {
11
- const activity = getMessageActivity({ inProgress, parts });
12
+ const { ai } = useGeistdocsConfig();
13
+ const activity = getMessageActivity({
14
+ inProgress,
15
+ parts,
16
+ toolLabels: ai?.toolLabels,
17
+ });
12
18
  if (activity) {
13
19
  return (_jsxs(LoadingContainer, { children: [_jsx(DotsSpinner, {}), " ", activity.label] }));
14
20
  }
@@ -0,0 +1,9 @@
1
+ import type { UIMessage } from "ai";
2
+ /**
3
+ * The Markdown a reader sees for a message: its non-blank text parts, in
4
+ * order, separated by blank lines. Reasoning, tool, and source parts are
5
+ * excluded. Text parts split by tool calls render as separate blocks, so
6
+ * they are joined as separate paragraphs.
7
+ */
8
+ export declare const getMessageMarkdown: (message: Pick<UIMessage, "parts">) => string;
9
+ //# sourceMappingURL=message-text.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"message-text.d.ts","sourceRoot":"","sources":["../../../src/internal/chat/message-text.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AAEpC;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,GAAI,SAAS,IAAI,CAAC,SAAS,EAAE,OAAO,CAAC,KAAG,MAUtD,CAAC"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * The Markdown a reader sees for a message: its non-blank text parts, in
3
+ * order, separated by blank lines. Reasoning, tool, and source parts are
4
+ * excluded. Text parts split by tool calls render as separate blocks, so
5
+ * they are joined as separate paragraphs.
6
+ */
7
+ export const getMessageMarkdown = (message) => message.parts
8
+ .flatMap((part) => {
9
+ if (part.type !== "text") {
10
+ return [];
11
+ }
12
+ const text = part.text.trim();
13
+ return text ? [text] : [];
14
+ })
15
+ .join("\n\n");
@@ -1,9 +1,11 @@
1
- import type { ComponentProps, HTMLAttributes } from "react";
1
+ import type { ComponentProps, HTMLAttributes, ReactNode } from "react";
2
2
  import { Streamdown } from "streamdown";
3
3
  export type MessageProps = HTMLAttributes<HTMLDivElement> & {
4
+ /** Rendered beside the message, aligned to its last line. */
5
+ avatar?: ReactNode;
4
6
  from: "system" | "user" | "assistant" | "data";
5
7
  };
6
- export declare const Message: ({ className, from, ...props }: MessageProps) => import("react/jsx-runtime").JSX.Element;
8
+ export declare const Message: ({ avatar, children, className, from, ...props }: MessageProps) => import("react/jsx-runtime").JSX.Element;
7
9
  export type MessageContentProps = HTMLAttributes<HTMLDivElement>;
8
10
  export declare const MessageContent: ({ children, className, ...props }: MessageContentProps) => import("react/jsx-runtime").JSX.Element;
9
11
  export type MessageResponseProps = ComponentProps<typeof Streamdown>;
@@ -1 +1 @@
1
- {"version":3,"file":"message.d.ts","sourceRoot":"","sources":["../../../src/internal/chat/message.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAE5D,OAAO,EAEL,UAAU,EAEX,MAAM,YAAY,CAAC;AAmMpB,MAAM,MAAM,YAAY,GAAG,cAAc,CAAC,cAAc,CAAC,GAAG;IAC1D,IAAI,EAAE,QAAQ,GAAG,MAAM,GAAG,WAAW,GAAG,MAAM,CAAC;CAChD,CAAC;AAEF,eAAO,MAAM,OAAO,GAAI,+BAA+B,YAAY,4CASlE,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG,cAAc,CAAC,cAAc,CAAC,CAAC;AAEjE,eAAO,MAAM,cAAc,GAAI,mCAI5B,mBAAmB,4CAqBrB,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG,cAAc,CAAC,OAAO,UAAU,CAAC,CAAC;AAErE,eAAO,MAAM,eAAe,gEACA,oBAAoB,6CAa/C,CAAC"}
1
+ {"version":3,"file":"message.d.ts","sourceRoot":"","sources":["../../../src/internal/chat/message.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvE,OAAO,EAEL,UAAU,EAEX,MAAM,YAAY,CAAC;AAmMpB,MAAM,MAAM,YAAY,GAAG,cAAc,CAAC,cAAc,CAAC,GAAG;IAC1D,6DAA6D;IAC7D,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,IAAI,EAAE,QAAQ,GAAG,MAAM,GAAG,WAAW,GAAG,MAAM,CAAC;CAChD,CAAC;AAEF,eAAO,MAAM,OAAO,GAAI,iDAMrB,YAAY,4CAsCd,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG,cAAc,CAAC,cAAc,CAAC,CAAC;AAEjE,eAAO,MAAM,cAAc,GAAI,mCAI5B,mBAAmB,4CAqBrB,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG,cAAc,CAAC,OAAO,UAAU,CAAC,CAAC;AAErE,eAAO,MAAM,eAAe,gEACA,oBAAoB,6CAa/C,CAAC"}
@@ -56,7 +56,14 @@ const CHAT_RESPONSE_COMPONENTS = {
56
56
  h6: ({ children, className, node: _node, ...props }) => (_jsx("h6", { className: cn("font-semibold text-sm", className), ...props, children: children })),
57
57
  pre: ({ children, className }) => _jsx("pre", { className: className, children: children }),
58
58
  };
59
- export const Message = ({ className, from, ...props }) => (_jsx("div", { className: cn("group flex w-full flex-col gap-2 py-4 [&>div]:max-w-[80%]", from === "user" ? "is-user items-end" : "is-assistant items-start", className), ...props }));
59
+ export const Message = ({ avatar, children, className, from, ...props }) => {
60
+ if (!avatar) {
61
+ return (_jsx("div", { className: cn("group flex w-full flex-col gap-2 py-4 [&>div]:max-w-[80%]", from === "user" ? "is-user items-end" : "is-assistant items-start", className), ...props, children: children }));
62
+ }
63
+ return (_jsxs("div", { className: cn("group flex w-full items-end gap-3 py-4", from === "user"
64
+ ? "is-user flex-row justify-end"
65
+ : "is-assistant flex-row-reverse justify-end", className), ...props, children: [_jsx("div", { className: cn("flex min-w-0 max-w-[80%] flex-col gap-2", from === "user" ? "items-end" : "items-start"), children: children }), avatar] }));
66
+ };
60
67
  export const MessageContent = ({ children, className, ...props }) => (_jsxs("div", { className: cn("relative flex min-h-10 w-fit min-w-0 max-w-full flex-col gap-2 whitespace-normal rounded-[12px] px-4 py-2 text-left text-sm leading-relaxed", "group-[.is-user]:bg-gray-1000 group-[.is-user]:text-white group-[.is-user]:dark:bg-gray-100 group-[.is-user]:dark:text-gray-1000", "group-[.is-assistant]:min-h-0 group-[.is-assistant]:px-0 group-[.is-assistant]:py-0 group-[.is-assistant]:text-gray-1000", className), ...props, children: [_jsx("div", { className: "is-user:dark", children: children }), _jsx("svg", { "aria-hidden": "true", className: "absolute right-[2.5px] -bottom-[0.5px] hidden translate-x-1/2 group-[.is-user]:block group-[.is-user]:fill-gray-1000 group-[.is-user]:dark:fill-gray-100", height: "14", viewBox: "0 0 18 14", width: "18", children: _jsx("path", { d: "M0.866025 8.80383L11.2583 0.803833C11.2583 0.803833 12.0621 9.5 17.2583 13.1961C12.0621 13.1961 0.866025 8.80383 0.866025 8.80383Z" }) })] }));
61
68
  export const MessageResponse = memo(({ className, ...props }) => (_jsx(Streamdown, { className: cn("size-full whitespace-normal text-left text-sm leading-relaxed [&>*:first-child]:mt-0 [&>*:last-child]:mb-0", className), components: CHAT_RESPONSE_COMPONENTS, linkSafety: { enabled: true, renderModal: LinkSafetyModal }, plugins: { cjk }, ...props })), (prevProps, nextProps) => prevProps.children === nextProps.children);
62
69
  MessageResponse.displayName = "MessageResponse";
@@ -0,0 +1,94 @@
1
+ import type { ReactNode } from "react";
2
+ import type { GeistdocsAISuggestionInput } from "../../config.js";
3
+ export declare const DEFAULT_CHAT_ENDPOINT = "/api/chat";
4
+ export declare const DEFAULT_CHAT_TITLE = "Ask AI";
5
+ export declare const DEFAULT_CHAT_HISTORY_RETENTION_DAYS = 30;
6
+ export declare const MAX_CHAT_SUGGESTIONS = 4;
7
+ /**
8
+ * Package routes with fixed paths that the site OpenAPI document describes.
9
+ * Neither the chat route nor the document itself may live at one of them.
10
+ */
11
+ export declare const RESERVED_SITE_PATHS: readonly string[];
12
+ /**
13
+ * Resolve `ai.endpoint` to the app-local chat route path. Invalid values
14
+ * throw: a chat client pointed at the wrong origin, a malformed path, or a
15
+ * path another package route already serves cannot work, and the OpenAPI
16
+ * document would describe a route that does not exist.
17
+ */
18
+ export declare const resolveChatEndpoint: (endpoint: string | undefined) => string;
19
+ /** Resolve `ai.title`, falling back to "Ask AI" when unset or blank. */
20
+ export declare const resolveChatTitle: (title: string | undefined) => string;
21
+ export interface ChatSuggestion {
22
+ icon?: ReactNode;
23
+ /** Stable React key, unique within the returned list. */
24
+ key: string;
25
+ text: string;
26
+ }
27
+ /**
28
+ * Normalize `ai.suggestions` into at most four renderable suggestions.
29
+ * Blank entries are dropped and repeated texts keep their first occurrence,
30
+ * so the text doubles as a unique, stable key.
31
+ */
32
+ export declare const normalizeChatSuggestions: (suggestions: readonly GeistdocsAISuggestionInput[] | undefined) => ChatSuggestion[];
33
+ /**
34
+ * Resolve `ai.history.retentionDays` to milliseconds.
35
+ *
36
+ * - `undefined`, negative, `NaN`, and `-Infinity` use the 30-day default.
37
+ * - `0` keeps no history: stored conversations are cleared on load and new
38
+ * messages are not saved.
39
+ * - `Infinity` never expires stored conversations.
40
+ * - Fractional days are allowed (`0.5` is 12 hours).
41
+ */
42
+ export declare const resolveChatHistoryRetentionMs: (retentionDays: number | undefined) => number;
43
+ export declare const isValidChatHistoryRetentionDays: (retentionDays: number | undefined) => boolean;
44
+ interface TimestampedRow {
45
+ timestamp?: unknown;
46
+ }
47
+ /**
48
+ * The most recent activity in a stored conversation, or `undefined` when no
49
+ * row carries a usable timestamp.
50
+ */
51
+ export declare const getChatLastActivityAt: (rows: readonly TimestampedRow[]) => number | undefined;
52
+ /**
53
+ * Whether a stored conversation should be cleared. A conversation survives
54
+ * while its most recent message is younger than the retention window; at
55
+ * exactly the boundary it expires. An empty store never expires, and a store
56
+ * whose rows carry no usable timestamp is treated as expired.
57
+ */
58
+ export declare const isChatHistoryExpired: ({ now, retentionMs, rows, }: {
59
+ now: number;
60
+ retentionMs: number;
61
+ rows: readonly TimestampedRow[];
62
+ }) => boolean;
63
+ /**
64
+ * Turn the stored rows of a conversation, in `sequence` order, into the
65
+ * messages to restore. An expired conversation restores nothing and reports
66
+ * `expired` so the caller clears the store.
67
+ */
68
+ export declare const restoreStoredChat: <T extends {
69
+ sequence?: unknown;
70
+ timestamp?: unknown;
71
+ }>({ now, retentionMs, rows, }: {
72
+ now: number;
73
+ retentionMs: number;
74
+ rows: readonly T[];
75
+ }) => {
76
+ expired: boolean;
77
+ messages: Omit<T, "sequence" | "timestamp">[];
78
+ };
79
+ /**
80
+ * Build the rows to store for a conversation. Messages already stored keep
81
+ * their original timestamp, so saving (which happens on every load as well as
82
+ * after each message) never refreshes the age of old messages; messages seen
83
+ * for the first time are stamped with `now`.
84
+ */
85
+ export declare const stampChatMessages: <T extends {
86
+ id: string;
87
+ }>(messages: readonly T[], storedRows: readonly ({
88
+ id: string;
89
+ } & TimestampedRow)[], now: number) => (T & {
90
+ sequence: number;
91
+ timestamp: number;
92
+ })[];
93
+ export {};
94
+ //# sourceMappingURL=options.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../../src/internal/chat/options.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,iBAAiB,CAAC;AAKlE,eAAO,MAAM,qBAAqB,cAAc,CAAC;AACjD,eAAO,MAAM,kBAAkB,WAAW,CAAC;AAC3C,eAAO,MAAM,mCAAmC,KAAK,CAAC;AACtD,eAAO,MAAM,oBAAoB,IAAI,CAAC;AAEtC;;;GAGG;AACH,eAAO,MAAM,mBAAmB,EAAE,SAAS,MAAM,EAMhD,CAAC;AAKF;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,GAAI,UAAU,MAAM,GAAG,SAAS,KAAG,MAqClE,CAAC;AAEF,wEAAwE;AACxE,eAAO,MAAM,gBAAgB,GAAI,OAAO,MAAM,GAAG,SAAS,KAAG,MAG5D,CAAC;AAEF,MAAM,WAAW,cAAc;IAC7B,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,yDAAyD;IACzD,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,GACnC,aAAa,SAAS,0BAA0B,EAAE,GAAG,SAAS,KAC7D,cAAc,EA0BhB,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,6BAA6B,GACxC,eAAe,MAAM,GAAG,SAAS,KAChC,MAcF,CAAC;AAEF,eAAO,MAAM,+BAA+B,GAC1C,eAAe,MAAM,GAAG,SAAS,YAMZ,CAAC;AAExB,UAAU,cAAc;IACtB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAKD;;;GAGG;AACH,eAAO,MAAM,qBAAqB,GAChC,MAAM,SAAS,cAAc,EAAE,KAC9B,MAAM,GAAG,SAaX,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,GAAI,6BAIlC;IACD,GAAG,EAAE,MAAM,CAAC;IACZ,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,SAAS,cAAc,EAAE,CAAC;CACjC,KAAG,OAgBH,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,GAC5B,CAAC,SAAS;IAAE,QAAQ,CAAC,EAAE,OAAO,CAAC;IAAC,SAAS,CAAC,EAAE,OAAO,CAAA;CAAE,EACrD,6BAIC;IACD,GAAG,EAAE,MAAM,CAAC;IACZ,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,SAAS,CAAC,EAAE,CAAC;CACpB,KAAG;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,QAAQ,EAAE,IAAI,CAAC,CAAC,EAAE,UAAU,GAAG,WAAW,CAAC,EAAE,CAAA;CASpE,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,GAAI,CAAC,SAAS;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,EACxD,UAAU,SAAS,CAAC,EAAE,EACtB,YAAY,SAAS,CAAC;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,GAAG,cAAc,CAAC,EAAE,EACxD,KAAK,MAAM,KACV,CAAC,CAAC,GAAG;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAAC,EAa/C,CAAC"}
@@ -0,0 +1,171 @@
1
+ // Pure Ask AI option resolution shared by the chat client and server routes.
2
+ // Keep this module free of runtime imports so routes and tests can load it.
3
+ export const DEFAULT_CHAT_ENDPOINT = "/api/chat";
4
+ export const DEFAULT_CHAT_TITLE = "Ask AI";
5
+ export const DEFAULT_CHAT_HISTORY_RETENTION_DAYS = 30;
6
+ export const MAX_CHAT_SUGGESTIONS = 4;
7
+ /**
8
+ * Package routes with fixed paths that the site OpenAPI document describes.
9
+ * Neither the chat route nor the document itself may live at one of them.
10
+ */
11
+ export const RESERVED_SITE_PATHS = [
12
+ "/.well-known/mcp.json",
13
+ "/agents.md",
14
+ "/api/search",
15
+ "/llms.txt",
16
+ "/sitemap.md",
17
+ ];
18
+ const DAY_MS = 24 * 60 * 60 * 1000;
19
+ const INVALID_ENDPOINT_CHARACTERS = /[\s?#\\]/;
20
+ /**
21
+ * Resolve `ai.endpoint` to the app-local chat route path. Invalid values
22
+ * throw: a chat client pointed at the wrong origin, a malformed path, or a
23
+ * path another package route already serves cannot work, and the OpenAPI
24
+ * document would describe a route that does not exist.
25
+ */
26
+ export const resolveChatEndpoint = (endpoint) => {
27
+ if (endpoint === undefined) {
28
+ return DEFAULT_CHAT_ENDPOINT;
29
+ }
30
+ if (typeof endpoint !== "string" ||
31
+ !endpoint.startsWith("/") ||
32
+ endpoint.startsWith("//") ||
33
+ endpoint === "/" ||
34
+ INVALID_ENDPOINT_CHARACTERS.test(endpoint)) {
35
+ throw new Error(`ai.endpoint must be a root-relative path such as "/api/chat", without a query string, fragment, whitespace, or backslashes. Received ${JSON.stringify(endpoint)}.`);
36
+ }
37
+ // Browsers normalize the path before sending the request, so a path the
38
+ // URL parser would rewrite (dot segments, including percent-encoded ones,
39
+ // or characters it percent-encodes) could reach a different route than the
40
+ // one validated here. A trailing slash would redirect to another route.
41
+ if (new URL(endpoint, "https://geistdocs.local").pathname !== endpoint ||
42
+ endpoint.endsWith("/")) {
43
+ throw new Error(`ai.endpoint must be a normalized path without "." or ".." segments, characters that need percent-encoding, or a trailing slash. Received ${JSON.stringify(endpoint)}.`);
44
+ }
45
+ if (RESERVED_SITE_PATHS.includes(endpoint)) {
46
+ throw new Error(`ai.endpoint must not be a path another Geistdocs route serves. Received ${JSON.stringify(endpoint)}.`);
47
+ }
48
+ return endpoint;
49
+ };
50
+ /** Resolve `ai.title`, falling back to "Ask AI" when unset or blank. */
51
+ export const resolveChatTitle = (title) => {
52
+ const trimmed = typeof title === "string" ? title.trim() : "";
53
+ return trimmed || DEFAULT_CHAT_TITLE;
54
+ };
55
+ /**
56
+ * Normalize `ai.suggestions` into at most four renderable suggestions.
57
+ * Blank entries are dropped and repeated texts keep their first occurrence,
58
+ * so the text doubles as a unique, stable key.
59
+ */
60
+ export const normalizeChatSuggestions = (suggestions) => {
61
+ const normalized = [];
62
+ const seen = new Set();
63
+ for (const suggestion of suggestions ?? []) {
64
+ const rawText = typeof suggestion === "string" ? suggestion : suggestion?.text;
65
+ const text = typeof rawText === "string" ? rawText.trim() : "";
66
+ if (!text || seen.has(text)) {
67
+ continue;
68
+ }
69
+ seen.add(text);
70
+ normalized.push(typeof suggestion === "object" && suggestion.icon !== undefined
71
+ ? { icon: suggestion.icon, key: text, text }
72
+ : { key: text, text });
73
+ if (normalized.length === MAX_CHAT_SUGGESTIONS) {
74
+ break;
75
+ }
76
+ }
77
+ return normalized;
78
+ };
79
+ /**
80
+ * Resolve `ai.history.retentionDays` to milliseconds.
81
+ *
82
+ * - `undefined`, negative, `NaN`, and `-Infinity` use the 30-day default.
83
+ * - `0` keeps no history: stored conversations are cleared on load and new
84
+ * messages are not saved.
85
+ * - `Infinity` never expires stored conversations.
86
+ * - Fractional days are allowed (`0.5` is 12 hours).
87
+ */
88
+ export const resolveChatHistoryRetentionMs = (retentionDays) => {
89
+ if (retentionDays === Number.POSITIVE_INFINITY) {
90
+ return Number.POSITIVE_INFINITY;
91
+ }
92
+ if (typeof retentionDays !== "number" ||
93
+ !Number.isFinite(retentionDays) ||
94
+ retentionDays < 0) {
95
+ return DEFAULT_CHAT_HISTORY_RETENTION_DAYS * DAY_MS;
96
+ }
97
+ return retentionDays * DAY_MS;
98
+ };
99
+ export const isValidChatHistoryRetentionDays = (retentionDays) => retentionDays === undefined ||
100
+ retentionDays === Number.POSITIVE_INFINITY ||
101
+ (typeof retentionDays === "number" &&
102
+ Number.isFinite(retentionDays) &&
103
+ retentionDays >= 0);
104
+ const isValidTimestamp = (value) => typeof value === "number" && Number.isFinite(value);
105
+ /**
106
+ * The most recent activity in a stored conversation, or `undefined` when no
107
+ * row carries a usable timestamp.
108
+ */
109
+ export const getChatLastActivityAt = (rows) => {
110
+ let latest;
111
+ for (const row of rows) {
112
+ if (isValidTimestamp(row.timestamp) &&
113
+ (latest === undefined || row.timestamp > latest)) {
114
+ latest = row.timestamp;
115
+ }
116
+ }
117
+ return latest;
118
+ };
119
+ /**
120
+ * Whether a stored conversation should be cleared. A conversation survives
121
+ * while its most recent message is younger than the retention window; at
122
+ * exactly the boundary it expires. An empty store never expires, and a store
123
+ * whose rows carry no usable timestamp is treated as expired.
124
+ */
125
+ export const isChatHistoryExpired = ({ now, retentionMs, rows, }) => {
126
+ if (rows.length === 0) {
127
+ return false;
128
+ }
129
+ // A zero window keeps nothing, even rows stamped slightly in the future.
130
+ if (retentionMs <= 0) {
131
+ return true;
132
+ }
133
+ const lastActivityAt = getChatLastActivityAt(rows);
134
+ if (lastActivityAt === undefined) {
135
+ return true;
136
+ }
137
+ return now - lastActivityAt >= retentionMs;
138
+ };
139
+ /**
140
+ * Turn the stored rows of a conversation, in `sequence` order, into the
141
+ * messages to restore. An expired conversation restores nothing and reports
142
+ * `expired` so the caller clears the store.
143
+ */
144
+ export const restoreStoredChat = ({ now, retentionMs, rows, }) => {
145
+ if (isChatHistoryExpired({ now, retentionMs, rows })) {
146
+ return { expired: true, messages: [] };
147
+ }
148
+ return {
149
+ expired: false,
150
+ messages: rows.map(({ sequence, timestamp, ...message }) => message),
151
+ };
152
+ };
153
+ /**
154
+ * Build the rows to store for a conversation. Messages already stored keep
155
+ * their original timestamp, so saving (which happens on every load as well as
156
+ * after each message) never refreshes the age of old messages; messages seen
157
+ * for the first time are stamped with `now`.
158
+ */
159
+ export const stampChatMessages = (messages, storedRows, now) => {
160
+ const storedTimestamps = new Map();
161
+ for (const row of storedRows) {
162
+ if (isValidTimestamp(row.timestamp)) {
163
+ storedTimestamps.set(row.id, row.timestamp);
164
+ }
165
+ }
166
+ return messages.map((message, index) => ({
167
+ ...message,
168
+ sequence: index,
169
+ timestamp: storedTimestamps.get(message.id) ?? now,
170
+ }));
171
+ };
@@ -0,0 +1,12 @@
1
+ import { type ChatPageAttachment } from "./commands";
2
+ /** Removable card above the prompt input naming the page the next message carries. */
3
+ export declare const ChatPageAttachmentCard: ({ onRemove, page, }: {
4
+ onRemove: () => void;
5
+ page: ChatPageAttachment;
6
+ }) => import("react/jsx-runtime").JSX.Element;
7
+ /** Chip on a sent user message naming the page it was asked about. */
8
+ export declare const ChatMessagePageChip: ({ className, metadata, }: {
9
+ className?: string;
10
+ metadata: unknown;
11
+ }) => import("react/jsx-runtime").JSX.Element | null;
12
+ //# sourceMappingURL=page-attachment.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"page-attachment.d.ts","sourceRoot":"","sources":["../../../src/internal/chat/page-attachment.tsx"],"names":[],"mappings":"AAIA,OAAO,EACL,KAAK,kBAAkB,EAGxB,MAAM,YAAY,CAAC;AAEpB,sFAAsF;AACtF,eAAO,MAAM,sBAAsB,GAAI,qBAGpC;IACD,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,IAAI,EAAE,kBAAkB,CAAC;CAC1B,4CAuBA,CAAC;AAEF,sEAAsE;AACtE,eAAO,MAAM,mBAAmB,GAAI,0BAGjC;IACD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,OAAO,CAAC;CACnB,mDAuBA,CAAC"}
@@ -0,0 +1,18 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { IconCross, IconFileText } from "#geistdocs-assets/icons";
4
+ import { cn } from "#geistdocs-ui/utils";
5
+ import { getChatPageLabel, getMessagePageAttachment, } from "./commands";
6
+ /** Removable card above the prompt input naming the page the next message carries. */
7
+ export const ChatPageAttachmentCard = ({ onRemove, page, }) => {
8
+ const label = getChatPageLabel(page);
9
+ return (_jsxs("div", { className: "flex min-w-0 items-center gap-2 rounded-md border border-gray-alpha-400 bg-background-200 py-1.5 pr-1 pl-2.5 text-gray-1000 text-label-13", "data-geistdocs-chat-page-attachment": true, children: [_jsx(IconFileText, { className: "shrink-0 text-gray-900", size: 14 }), _jsxs("span", { className: "min-w-0 flex-1 truncate", title: page.url, children: [_jsx("span", { className: "sr-only", children: "Asking about " }), label] }), _jsx("button", { "aria-label": `Remove ${label}`, className: "flex size-6 shrink-0 cursor-pointer items-center justify-center rounded text-gray-900 hover:bg-gray-alpha-100 hover:text-gray-1000 focus-visible:shadow-focus-ring focus-visible:outline-none", onClick: onRemove, type: "button", children: _jsx(IconCross, { size: 12 }) })] }));
10
+ };
11
+ /** Chip on a sent user message naming the page it was asked about. */
12
+ export const ChatMessagePageChip = ({ className, metadata, }) => {
13
+ const page = getMessagePageAttachment(metadata);
14
+ if (!page) {
15
+ return null;
16
+ }
17
+ return (_jsxs("span", { className: cn("inline-flex max-w-[80%] items-center gap-1 rounded-full border border-gray-alpha-400 px-2 py-0.5 text-gray-900 text-label-12", className), "data-geistdocs-chat-message-page": true, title: page.url, children: [_jsx(IconFileText, { className: "shrink-0", size: 12 }), _jsxs("span", { className: "truncate", children: [_jsx("span", { className: "sr-only", children: "Asked about " }), getChatPageLabel(page)] })] }));
18
+ };
@@ -0,0 +1,33 @@
1
+ import { type ReactNode } from "react";
2
+ import { type GeistdocsChatSession } from "./session";
3
+ type ChatSessionState = {
4
+ status: "loading";
5
+ } | {
6
+ error: Error;
7
+ /**
8
+ * Try again after a transient failure, such as an unreadable history
9
+ * store. Absent for configuration errors, which retrying can't fix.
10
+ */
11
+ retry?: () => void;
12
+ status: "error";
13
+ } | {
14
+ /** Clear the stored and displayed conversation. */
15
+ clearConversation: () => Promise<void>;
16
+ session: GeistdocsChatSession;
17
+ status: "ready";
18
+ };
19
+ /**
20
+ * The shared chat session. `"error"` must be thrown by the consumer so it
21
+ * fails inside that shell's chat error boundary instead of the page.
22
+ */
23
+ export declare const useChatSession: () => ChatSessionState;
24
+ /**
25
+ * Provides the single chat shared by the desktop panel and the mobile
26
+ * drawer. An invalid `ai.endpoint` is caught here and handed to the shells
27
+ * as an `"error"` state, so it fails inside their error boundaries.
28
+ */
29
+ export declare const GeistdocsChatSessionProvider: ({ children, }: {
30
+ children: ReactNode;
31
+ }) => import("react/jsx-runtime").JSX.Element;
32
+ export {};
33
+ //# sourceMappingURL=session-provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session-provider.d.ts","sourceRoot":"","sources":["../../../src/internal/chat/session-provider.tsx"],"names":[],"mappings":"AAIA,OAAO,EAEL,KAAK,SAAS,EAQf,MAAM,OAAO,CAAC;AAMf,OAAO,EAEL,KAAK,oBAAoB,EAE1B,MAAM,WAAW,CAAC;AAInB,KAAK,gBAAgB,GACjB;IAAE,MAAM,EAAE,SAAS,CAAA;CAAE,GACrB;IACE,KAAK,EAAE,KAAK,CAAC;IACb;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,IAAI,CAAC;IACnB,MAAM,EAAE,OAAO,CAAC;CACjB,GACD;IACE,mDAAmD;IACnD,iBAAiB,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IACvC,OAAO,EAAE,oBAAoB,CAAC;IAC9B,MAAM,EAAE,OAAO,CAAC;CACjB,CAAC;AAIN;;;GAGG;AACH,eAAO,MAAM,cAAc,wBAU1B,CAAC;AA8HF;;;;GAIG;AACH,eAAO,MAAM,4BAA4B,GAAI,eAE1C;IACD,QAAQ,EAAE,SAAS,CAAC;CACrB,4CAmCA,CAAC"}