@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.
- package/dist/assistant-components.d.ts +2 -1
- package/dist/assistant-components.js +22 -10
- package/dist/assistant-runtime.js +15 -4
- package/dist/client.d.ts +3 -1
- package/dist/client.js +136 -42
- package/dist/config.d.ts +1 -1
- package/dist/default-chat.d.ts +1 -1
- package/dist/default-chat.js +26411 -26047
- package/dist/fonts/Inter-OFL.txt +93 -0
- package/dist/fonts/inter-medium.ttf +0 -0
- package/dist/protocol-messages.js +15 -16
- package/dist/protocol-response.js +10 -3
- package/dist/react.d.ts +13 -1
- package/dist/react.js +609 -99
- package/dist/session-coordinator.d.ts +23 -0
- package/dist/session-coordinator.js +139 -0
- package/dist/session-history.d.ts +29 -0
- package/dist/session-history.js +282 -0
- package/dist/shared/errors.d.ts +1 -1
- package/dist/shared/errors.js +2 -0
- package/dist/shared/tool-presentation.d.ts +17 -0
- package/dist/shared/tool-presentation.js +5 -0
- package/dist/shared/tool-proxy.d.ts +6 -0
- package/dist/shared/tool-proxy.js +25 -0
- package/dist/storage.d.ts +4 -6
- package/dist/storage.js +52 -43
- package/dist/styles.css +1491 -676
- package/dist/tool-confirmation-card.d.ts +5 -0
- package/dist/tool-confirmation-card.js +33 -0
- package/dist/tool-confirmation.d.ts +23 -0
- package/dist/tool-confirmation.js +25 -0
- package/dist/tool-presentation.d.ts +6 -0
- package/dist/tool-presentation.js +132 -0
- package/dist/tool-result.d.ts +5 -0
- package/dist/tool-result.js +31 -0
- package/dist/types.d.ts +3 -1
- package/dist/ui/home-demo/greeting.d.ts +3 -1
- package/dist/ui/home-demo/greeting.js +2 -2
- package/dist/ui/home-demo/suggestions.d.ts +2 -4
- package/dist/ui/home-demo/suggestions.js +5 -4
- package/dist/ui/home-demo/trace.js +2 -3
- package/dist/ui/thread-list.aui.d.ts +2 -1
- package/dist/ui/thread-list.aui.js +2 -2
- 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
|
|
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]
|
|
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
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
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([
|