@nexface/chat 0.1.21-alpha.5 → 0.1.21-alpha.7

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 (48) hide show
  1. package/dist/BUNDLED_DEPENDENCIES.json +12 -0
  2. package/dist/BUNDLED_LICENSES.txt +50 -0
  3. package/dist/assistant-components.d.ts +1 -2
  4. package/dist/assistant-components.js +6 -8
  5. package/dist/assistant-runtime.d.ts +1 -4
  6. package/dist/assistant-runtime.js +5 -19
  7. package/dist/client.js +12 -24
  8. package/dist/default-chat.d.ts +1 -1
  9. package/dist/default-chat.js +7864 -1553
  10. package/dist/messages.d.ts +0 -3
  11. package/dist/protocol-messages.d.ts +2 -3
  12. package/dist/protocol-messages.js +27 -145
  13. package/dist/protocol-response.js +2 -2
  14. package/dist/react.d.ts +1 -11
  15. package/dist/react.js +100 -515
  16. package/dist/storage.d.ts +6 -3
  17. package/dist/storage.js +44 -50
  18. package/dist/styles.css +676 -1503
  19. package/dist/tool-result.d.ts +0 -5
  20. package/dist/tool-result.js +0 -31
  21. package/dist/types.d.ts +1 -3
  22. package/dist/ui/home-demo/action-bar.js +2 -13
  23. package/dist/ui/home-demo/greeting.d.ts +1 -3
  24. package/dist/ui/home-demo/greeting.js +2 -2
  25. package/dist/ui/home-demo/suggestions.d.ts +4 -2
  26. package/dist/ui/home-demo/suggestions.js +4 -5
  27. package/dist/ui/home-demo/trace.js +3 -2
  28. package/dist/ui/markdown-text.d.ts +1 -6
  29. package/dist/ui/markdown-text.js +2 -39
  30. package/dist/ui/thread-list.aui.d.ts +1 -2
  31. package/dist/ui/thread-list.aui.js +2 -6
  32. package/package.json +3 -4
  33. package/dist/fonts/Inter-OFL.txt +0 -93
  34. package/dist/fonts/inter-medium.ttf +0 -0
  35. package/dist/session-coordinator.d.ts +0 -23
  36. package/dist/session-coordinator.js +0 -139
  37. package/dist/session-history.d.ts +0 -29
  38. package/dist/session-history.js +0 -282
  39. package/dist/shared/text-only-reply.d.ts +0 -6
  40. package/dist/shared/text-only-reply.js +0 -10
  41. package/dist/shared/tool-presentation.d.ts +0 -18
  42. package/dist/shared/tool-presentation.js +0 -5
  43. package/dist/shared/tool-result-markdown.d.ts +0 -15
  44. package/dist/shared/tool-result-markdown.js +0 -55
  45. package/dist/shared/tool-result-reference.d.ts +0 -2
  46. package/dist/shared/tool-result-reference.js +0 -5
  47. package/dist/tool-presentation.d.ts +0 -6
  48. package/dist/tool-presentation.js +0 -113
package/dist/storage.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import type { AgentMessage } from "@nexface/agent";
2
2
  import type { UIMessage } from "./react.js";
3
3
  export declare const chatStorageKey = "nexface:chat:sessions:v3";
4
- export interface StoredSession {
4
+ interface StoredSession {
5
5
  id: string;
6
6
  title?: string;
7
7
  appendOnly?: boolean;
@@ -11,7 +11,10 @@ interface StoredChat {
11
11
  sessions: StoredSession[];
12
12
  activeSessionId: string;
13
13
  }
14
- export declare function decodeChatStorage(raw: string | null): StoredChat | undefined;
15
- export declare function encodeSession(session: StoredSession): StoredSession;
14
+ export interface ChatStorageVersion {
15
+ value: string | null;
16
+ }
17
+ export declare function readChatStorage(key: string, version?: ChatStorageVersion): StoredChat | undefined;
18
+ export declare function writeChatStorage(key: string, state: StoredChat, version: ChatStorageVersion): "saved" | "unchanged" | "conflict" | "unavailable";
16
19
  export declare function conversationFromMessages(messages: readonly UIMessage[]): AgentMessage[];
17
20
  export {};
package/dist/storage.js CHANGED
@@ -146,21 +146,6 @@ function restoreMessage(message) {
146
146
  });
147
147
  return {
148
148
  ...message,
149
- ...(message.attachments
150
- ? {
151
- attachments: message.attachments.map((attachment) => {
152
- const image = attachmentContent(attachment).find((content) => content.type === "image" && content.source.type === "data");
153
- return attachment.preview === undefined &&
154
- image?.type === "image" &&
155
- image.source.type === "data"
156
- ? {
157
- ...attachment,
158
- preview: `data:${image.source.mimeType ?? "image/png"};base64,${image.source.value}`,
159
- }
160
- : attachment;
161
- }),
162
- }
163
- : {}),
164
149
  parts,
165
150
  ...(unfinished ? { state: "error" } : {}),
166
151
  ...(error ? { error } : {}),
@@ -174,10 +159,16 @@ function withoutReasoning(messages) {
174
159
  return [{ ...message, parts }];
175
160
  });
176
161
  }
177
- export function decodeChatStorage(raw) {
162
+ export function readChatStorage(key, version) {
178
163
  try {
164
+ const raw = localStorage.getItem(key);
165
+ if (version)
166
+ version.value = raw;
179
167
  const value = JSON.parse(raw ?? "null");
180
- if (!record(value) || value.version !== 3 || !Array.isArray(value.sessions))
168
+ if (!record(value) ||
169
+ value.version !== 3 ||
170
+ !Array.isArray(value.sessions) ||
171
+ !value.sessions.length)
181
172
  return;
182
173
  const sessions = [];
183
174
  for (const session of value.sessions) {
@@ -197,45 +188,48 @@ export function decodeChatStorage(raw) {
197
188
  messages: migratePageTaskResults(withoutReasoning(session.messages)).map(restoreMessage),
198
189
  });
199
190
  }
200
- const activeSessionId = sessions.find((session) => session.id === value.activeSessionId)?.id ?? sessions[0]?.id ?? "";
191
+ const activeSessionId = sessions.find((session) => session.id === value.activeSessionId)?.id ?? sessions[0].id;
201
192
  return { sessions, activeSessionId };
202
193
  }
203
194
  catch {
204
195
  return undefined;
205
196
  }
206
197
  }
207
- export function encodeSession(session) {
208
- return {
209
- id: session.id,
210
- ...(session.title ? { title: session.title } : {}),
211
- ...(session.appendOnly ? { appendOnly: true } : {}),
212
- messages: withoutReasoning(session.messages).map((message) => ({
213
- ...message,
214
- ...(message.attachments
215
- ? {
216
- attachments: message.attachments.map((attachment) => {
217
- const contents = attachmentContent(attachment);
218
- if (!contents.some((content) => content.type === "image" &&
219
- content.source.type === "data" &&
220
- attachment.preview ===
221
- `data:${content.source.mimeType ?? "image/png"};base64,${content.source.value}`))
222
- return attachment;
223
- const { preview: _preview, ...saved } = attachment;
224
- return saved;
225
- }),
226
- }
227
- : {}),
228
- parts: message.parts.map((part) => part.type === "tool" && part.error
229
- ? {
230
- ...part,
231
- errorMessage: part.error.userMessage,
232
- result: JSON.stringify({
233
- error: { code: part.error.code, message: part.error.userMessage },
234
- }),
235
- }
236
- : part),
237
- })),
238
- };
198
+ export function writeChatStorage(key, state, version) {
199
+ try {
200
+ const next = JSON.stringify({
201
+ version: 3,
202
+ activeSessionId: state.activeSessionId,
203
+ sessions: state.sessions.map(({ id, title, appendOnly, messages }) => ({
204
+ id,
205
+ title,
206
+ ...(appendOnly ? { appendOnly } : {}),
207
+ messages: withoutReasoning(messages).map((message) => ({
208
+ ...message,
209
+ parts: message.parts.map((part) => part.type === "tool" && part.error
210
+ ? {
211
+ ...part,
212
+ errorMessage: part.error.userMessage,
213
+ result: JSON.stringify({
214
+ error: { code: part.error.code, message: part.error.userMessage },
215
+ }),
216
+ }
217
+ : part),
218
+ })),
219
+ })),
220
+ });
221
+ if (next === version.value)
222
+ return "unchanged";
223
+ if (localStorage.getItem(key) !== version.value)
224
+ return "conflict";
225
+ localStorage.setItem(key, next);
226
+ version.value = next;
227
+ return "saved";
228
+ }
229
+ catch {
230
+ // Storage restrictions or quota exhaustion must not break the active chat.
231
+ return "unavailable";
232
+ }
239
233
  }
240
234
  export function conversationFromMessages(messages) {
241
235
  const legacy = new Set([