@nexface/chat 0.1.20 → 0.1.21-alpha.1

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 (44) hide show
  1. package/dist/assistant-components.d.ts +2 -1
  2. package/dist/assistant-components.js +22 -10
  3. package/dist/assistant-runtime.js +15 -4
  4. package/dist/client.d.ts +3 -1
  5. package/dist/client.js +136 -42
  6. package/dist/config.d.ts +1 -1
  7. package/dist/default-chat.d.ts +1 -1
  8. package/dist/default-chat.js +26411 -26047
  9. package/dist/fonts/Inter-OFL.txt +93 -0
  10. package/dist/fonts/inter-medium.ttf +0 -0
  11. package/dist/protocol-messages.js +15 -16
  12. package/dist/protocol-response.js +10 -3
  13. package/dist/react.d.ts +13 -1
  14. package/dist/react.js +609 -99
  15. package/dist/session-coordinator.d.ts +23 -0
  16. package/dist/session-coordinator.js +139 -0
  17. package/dist/session-history.d.ts +29 -0
  18. package/dist/session-history.js +282 -0
  19. package/dist/shared/errors.d.ts +1 -1
  20. package/dist/shared/errors.js +2 -0
  21. package/dist/shared/tool-presentation.d.ts +17 -0
  22. package/dist/shared/tool-presentation.js +5 -0
  23. package/dist/shared/tool-proxy.d.ts +6 -0
  24. package/dist/shared/tool-proxy.js +25 -0
  25. package/dist/storage.d.ts +4 -6
  26. package/dist/storage.js +52 -43
  27. package/dist/styles.css +1491 -676
  28. package/dist/tool-confirmation-card.d.ts +5 -0
  29. package/dist/tool-confirmation-card.js +33 -0
  30. package/dist/tool-confirmation.d.ts +23 -0
  31. package/dist/tool-confirmation.js +25 -0
  32. package/dist/tool-presentation.d.ts +6 -0
  33. package/dist/tool-presentation.js +132 -0
  34. package/dist/tool-result.d.ts +5 -0
  35. package/dist/tool-result.js +31 -0
  36. package/dist/types.d.ts +3 -1
  37. package/dist/ui/home-demo/greeting.d.ts +3 -1
  38. package/dist/ui/home-demo/greeting.js +2 -2
  39. package/dist/ui/home-demo/suggestions.d.ts +2 -4
  40. package/dist/ui/home-demo/suggestions.js +5 -4
  41. package/dist/ui/home-demo/trace.js +2 -3
  42. package/dist/ui/thread-list.aui.d.ts +2 -1
  43. package/dist/ui/thread-list.aui.js +2 -2
  44. package/package.json +3 -3
package/dist/storage.js CHANGED
@@ -146,6 +146,21 @@ 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
+ : {}),
149
164
  parts,
150
165
  ...(unfinished ? { state: "error" } : {}),
151
166
  ...(error ? { error } : {}),
@@ -159,16 +174,10 @@ function withoutReasoning(messages) {
159
174
  return [{ ...message, parts }];
160
175
  });
161
176
  }
162
- export function readChatStorage(key, version) {
177
+ export function decodeChatStorage(raw) {
163
178
  try {
164
- const raw = localStorage.getItem(key);
165
- if (version)
166
- version.value = raw;
167
179
  const value = JSON.parse(raw ?? "null");
168
- if (!record(value) ||
169
- value.version !== 3 ||
170
- !Array.isArray(value.sessions) ||
171
- !value.sessions.length)
180
+ if (!record(value) || value.version !== 3 || !Array.isArray(value.sessions))
172
181
  return;
173
182
  const sessions = [];
174
183
  for (const session of value.sessions) {
@@ -176,6 +185,7 @@ export function readChatStorage(key, version) {
176
185
  typeof session.id !== "string" ||
177
186
  !session.id ||
178
187
  (session.title !== undefined && typeof session.title !== "string") ||
188
+ (session.appendOnly !== undefined && typeof session.appendOnly !== "boolean") ||
179
189
  !Array.isArray(session.messages) ||
180
190
  !session.messages.every(isMessage) ||
181
191
  sessions.some((existing) => existing.id === session.id))
@@ -183,50 +193,49 @@ export function readChatStorage(key, version) {
183
193
  sessions.push({
184
194
  id: session.id,
185
195
  ...(session.title ? { title: session.title } : {}),
196
+ ...(session.appendOnly ? { appendOnly: true } : {}),
186
197
  messages: migratePageTaskResults(withoutReasoning(session.messages)).map(restoreMessage),
187
198
  });
188
199
  }
189
- const activeSessionId = sessions.find((session) => session.id === value.activeSessionId)?.id ?? sessions[0].id;
200
+ const activeSessionId = sessions.find((session) => session.id === value.activeSessionId)?.id ?? sessions[0]?.id ?? "";
190
201
  return { sessions, activeSessionId };
191
202
  }
192
203
  catch {
193
204
  return undefined;
194
205
  }
195
206
  }
196
- export function writeChatStorage(key, state, version) {
197
- try {
198
- const next = JSON.stringify({
199
- version: 3,
200
- activeSessionId: state.activeSessionId,
201
- sessions: state.sessions.map(({ id, title, messages }) => ({
202
- id,
203
- title,
204
- messages: withoutReasoning(messages).map((message) => ({
205
- ...message,
206
- parts: message.parts.map((part) => part.type === "tool" && part.error
207
- ? {
208
- ...part,
209
- errorMessage: part.error.userMessage,
210
- result: JSON.stringify({
211
- error: { code: part.error.code, message: part.error.userMessage },
212
- }),
213
- }
214
- : part),
215
- })),
216
- })),
217
- });
218
- if (next === version.value)
219
- return "unchanged";
220
- if (localStorage.getItem(key) !== version.value)
221
- return "conflict";
222
- localStorage.setItem(key, next);
223
- version.value = next;
224
- return "saved";
225
- }
226
- catch {
227
- // Storage restrictions or quota exhaustion must not break the active chat.
228
- return "unavailable";
229
- }
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
+ };
230
239
  }
231
240
  export function conversationFromMessages(messages) {
232
241
  const legacy = new Set([