@nexface/chat 0.1.9-alpha.0 → 0.1.9-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/BUNDLED_DEPENDENCIES.json +1007 -0
- package/dist/BUNDLED_LICENSES.txt +4164 -0
- package/dist/assistant-attachments.d.ts +0 -2
- package/dist/assistant-attachments.js +1 -10
- package/dist/assistant-attachments.js.map +1 -1
- package/dist/assistant-components.js +2 -1
- package/dist/assistant-components.js.map +1 -1
- package/dist/client.d.ts +2 -2
- package/dist/client.js +5 -2
- package/dist/client.js.map +1 -1
- package/dist/default-chat.js +52062 -173
- package/dist/default-chat.js.map +7 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/messages.d.ts +0 -4
- package/dist/messages.js +1 -120
- package/dist/messages.js.map +1 -1
- package/dist/protocol-messages.d.ts +2 -2
- package/dist/protocol-messages.js +2 -3
- package/dist/protocol-messages.js.map +1 -1
- package/dist/react.d.ts +0 -1
- package/dist/react.js +2 -3
- package/dist/react.js.map +1 -1
- package/dist/storage.js +11 -3
- package/dist/storage.js.map +1 -1
- package/dist/styles.css +0 -6
- package/dist/ui/attachment.aui.js +2 -2
- package/dist/ui/attachment.aui.js.map +1 -1
- package/dist/ui/home-demo/action-bar.d.ts +1 -2
- package/dist/ui/home-demo/action-bar.js.map +1 -1
- package/dist/ui/home-demo/composer.d.ts +1 -1
- package/dist/ui/home-demo/composer.js.map +1 -1
- package/dist/ui/home-demo/greeting.d.ts +1 -2
- package/dist/ui/home-demo/greeting.js.map +1 -1
- package/dist/ui/home-demo/messages.d.ts +2 -2
- package/dist/ui/home-demo/messages.js.map +1 -1
- package/dist/ui/home-demo/suggestions.d.ts +1 -6
- package/dist/ui/home-demo/suggestions.js +1 -7
- package/dist/ui/home-demo/suggestions.js.map +1 -1
- package/dist/ui/home-demo/trace-line.d.ts +2 -3
- package/dist/ui/home-demo/trace-line.js.map +1 -1
- package/dist/ui/home-demo/trace.d.ts +2 -3
- package/dist/ui/home-demo/trace.js.map +1 -1
- package/dist/ui/markdown-text.d.ts +1 -7
- package/dist/ui/markdown-text.js +2 -26
- package/dist/ui/markdown-text.js.map +1 -1
- package/dist/ui/reasoning.aui.js.map +1 -1
- package/package.json +12 -12
package/dist/storage.js
CHANGED
|
@@ -76,7 +76,7 @@ function isAttachment(value) {
|
|
|
76
76
|
function isPart(value) {
|
|
77
77
|
if (!record(value))
|
|
78
78
|
return false;
|
|
79
|
-
if (value.type === "text")
|
|
79
|
+
if (value.type === "text" || value.type === "reasoning")
|
|
80
80
|
return typeof value.text === "string";
|
|
81
81
|
return value.type === "tool" && typeof value.toolCallId === "string"
|
|
82
82
|
&& typeof value.name === "string" && typeof value.arguments === "string"
|
|
@@ -111,6 +111,14 @@ function restoreMessage(message) {
|
|
|
111
111
|
});
|
|
112
112
|
return { ...message, parts, ...(unfinished ? { state: "error" } : {}), ...(error ? { error } : {}) };
|
|
113
113
|
}
|
|
114
|
+
function withoutReasoning(messages) {
|
|
115
|
+
return messages.flatMap((message) => {
|
|
116
|
+
const parts = message.parts.filter((part) => part.type !== "reasoning");
|
|
117
|
+
if (!parts.length && message.parts.length)
|
|
118
|
+
return [];
|
|
119
|
+
return [{ ...message, parts }];
|
|
120
|
+
});
|
|
121
|
+
}
|
|
114
122
|
export function readChatStorage(key, version) {
|
|
115
123
|
try {
|
|
116
124
|
const raw = localStorage.getItem(key);
|
|
@@ -126,7 +134,7 @@ export function readChatStorage(key, version) {
|
|
|
126
134
|
|| !Array.isArray(session.messages) || !session.messages.every(isMessage)
|
|
127
135
|
|| sessions.some((existing) => existing.id === session.id))
|
|
128
136
|
return;
|
|
129
|
-
sessions.push({ id: session.id, ...(session.title ? { title: session.title } : {}), messages: migratePageTaskResults(session.messages).map(restoreMessage) });
|
|
137
|
+
sessions.push({ id: session.id, ...(session.title ? { title: session.title } : {}), messages: migratePageTaskResults(withoutReasoning(session.messages)).map(restoreMessage) });
|
|
130
138
|
}
|
|
131
139
|
const activeSessionId = sessions.find((session) => session.id === value.activeSessionId)?.id ?? sessions[0].id;
|
|
132
140
|
return { sessions, activeSessionId };
|
|
@@ -140,7 +148,7 @@ export function writeChatStorage(key, state, version) {
|
|
|
140
148
|
const next = JSON.stringify({
|
|
141
149
|
version: 3,
|
|
142
150
|
activeSessionId: state.activeSessionId,
|
|
143
|
-
sessions: state.sessions.map(({ id, title, messages }) => ({ id, title, messages: messages.map((message) => ({
|
|
151
|
+
sessions: state.sessions.map(({ id, title, messages }) => ({ id, title, messages: withoutReasoning(messages).map((message) => ({
|
|
144
152
|
...message, parts: message.parts.map((part) => part.type === "tool" && part.error ? {
|
|
145
153
|
...part, errorMessage: part.error.userMessage,
|
|
146
154
|
result: JSON.stringify({ error: { code: part.error.code, message: part.error.userMessage } }),
|
package/dist/storage.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage.js","sourceRoot":"","sources":["../src/storage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAGlE,OAAO,EAAE,iBAAiB,EAAmB,MAAM,kBAAkB,CAAC;AAEtE,MAAM,CAAC,MAAM,cAAc,GAAG,0BAA0B,CAAC;AAWzD,MAAM,kBAAkB,GAAG,2BAA2B,CAAC;AACvD,MAAM,MAAM,GAAG,CAAC,KAAc,EAAoC,EAAE,CAClE,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAEvE,SAAS,oBAAoB,CAAC,OAAkB;IAC9C,IAAI,OAAO,CAAC,IAAI,KAAK,WAAW,IAAI,OAAO,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC,IAAI,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,IAAI,KAAK,MAAM;QAAE,OAAO;IAC5G,IAAI,CAAC;QACH,M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BAAE,SAAS;YACxC,IAAI,IAAI,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;gBACzB,+DAA+D;gBAC/D,IAAI,GAAG,CAAC,IAAI,IAAI,EAAE,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC;gBAChC,SAAS;YACX,CAAC;YACD,IAAI,IAAI,KAAK,SAAS;gBAAE,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAC5C,IAAI,GAAG,SAAS,CAAC;YACjB,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,iBAAiB,IAAI,IAAI,CAAC,IAAI,KAAK,mBAAmB,IAAI,IAAI,CAAC,IAAI,KAAK,iBAAiB;gBACnH,CAAC,CAAC,8BAA8B;gBAChC,CAAC,CAAC,UAAU,IAAI,CAAC,IAAI,QAAQ,IAAI,CAAC,SAAS,QAAQ,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,YAAY,IAAI,kBAAkB,EAAE,CAAC,CAAC;QACjH,CAAC;QACD,IAAI,IAAI,KAAK,SAAS;YAAE,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC5C,MAAM,OAAO,GAAG,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACpC,OAAO,EAAE,EAAE,EAAE,OAAO,CAAC,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC;IACvE,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { isNexfaceError, runError, toolError } from \"./errors.js\";\nimport type { AgentInputContent, AgentMessage } from \"@nexface/agent\";\nimport type { UIMessage, UIMessagePart } from \"./react.js\";\nimport { attachmentContent, type Attachment } from \"./attachments.js\";\n\nexport const chatStorageKey = \"nexface:chat:sessions:v3\";\n\ninterface StoredSession {\n id: string;\n title?: string;\n messages: UIMessage[];\n}\ninterface StoredChat {\n sessions: StoredSession[];\n activeSessionId: string;\n}\nconst interruptedMessage = \"页面已刷新,之前的操作未恢复,执行结果请重新核实。\";\nconst record = (value: unknown): value is Record<string, unknown> =>\n value !== null && typeof value === \"object\" && !Array.isArray(value);\n\nfunction legacyPageTaskResult(message: UIMessage): Record<string, unknown> | undefined {\n if (message.role !== \"assistant\" || message.parts.length !== 1 || message.parts[0]?.type !== \"text\") return;\n try {\n const parsed: unknown = JSON.parse(message.parts[0].text);\n if (!record(parsed) || Object.keys(parsed).length !== 1 || !record(parsed.pageTaskResult)) return;\n const result = parsed.pageTaskResult;\n if ((result.status === \"done\" || result.status === \"blocked\")\n && result.businessOutcome === \"unverified\"\n && record(result.task)\n && typeof result.task.goal === \"string\"\n && typeof result.task.completion === \"string\") return result;\n } catch { /* Non-JSON assistant text remains unchanged. */ }\n return;\n}\n\nfunction migratePageTaskResults(messages: readonly UIMessage[]): UIMessage[] {\n const migrated: UIMessage[] = [];\n for (const message of messages) {\n const result = legacyPageTaskResult(message);\n let updated = false;\n if (result) for (let index = migrated.length - 1; index >= 0 && !updated; index -= 1) {\n const owner = migrated[index]!;\n if (owner.role === \"user\") break;\n const partIndex = owner.parts.findIndex((part) => part.type === \"tool\" && part.name === \"nxf_delegatePageTask\");\n if (partIndex < 0) continue;\n const part = owner.parts[partIndex];\n if (part?.type !== \"tool\" || part.result === undefined) break;\n try {\n const accepted: unknown = JSON.parse(part.result!);\n const task = result.task as Record<string, unknown>;\n if (!record(accepted) || !record(accepted.result) || accepted.result.status !== \"accepted\"\n || accepted.result.goal !== task.goal || accepted.result.completion !== task.completion) break;\n } catch { break; }\n const parts = [...owner.parts];\n parts[partIndex] = { ...part, result: JSON.stringify({ result: { pageTaskResult: result } }) };\n migrated[index] = { ...owner, parts };\n updated = true;\n }\n if (!updated) migrated.push(message);\n }\n return migrated;\n}\n\nfunction isContent(value: unknown): value is AgentInputContent {\n if (!record(value)) return false;\n if (value.type === \"text\") return typeof value.text === \"string\";\n if (value.type !== \"image\" || !record(value.source)) return false;\n return (value.source.type === \"data\" || value.source.type === \"url\")\n && typeof value.source.value === \"string\"\n && (value.source.mimeType === undefined || typeof value.source.mimeType === \"string\");\n}\nfunction isAttachment(value: unknown): value is Attachment {\n return record(value) && typeof value.id === \"string\" && typeof value.name === \"string\"\n && (isContent(value.content) || Array.isArray(value.content) && value.content.length > 0 && value.content.every(isContent))\n && (value.preview === undefined || typeof value.preview === \"string\");\n}\nfunction isPart(value: unknown): value is UIMessagePart {\n if (!record(value)) return false;\n if (value.type === \"text\") return typeof value.text === \"string\";\n return value.type === \"tool\" && typeof value.toolCallId === \"string\"\n && typeof value.name === \"string\" && typeof value.arguments === \"string\"\n && [\"result\", \"parseError\", \"errorMessage\"].every((key) => value[key] === undefined || typeof value[key] === \"string\")\n && (value.isError === undefined || typeof value.isError === \"boolean\")\n && (value.error === undefined || isNexfaceError(value.error))\n && (value.toolState === undefined || [\"failed\", \"unknown\", \"not_started\", \"cancelled\", \"rejected\"].includes(String(value.toolState)));\n}\nfunction isMessage(value: unknown): value is UIMessage {\n return record(value) && typeof value.id === \"string\" && (value.role === \"user\" || value.role === \"assistant\")\n && Array.isArray(value.parts) && value.parts.every(isPart)\n && (value.attachments === undefined || Array.isArray(value.attachments) && value.attachments.every(isAttachment))\n && (value.error === undefined || isNexfaceError(value.error))\n && (value.revisionOf === undefined || typeof value.revisionOf === \"string\")\n && (value.state === undefined || [\"running\", \"success\", \"error\", \"cancelled\"].includes(String(value.state)));\n}\nfunction restoreMessage(message: UIMessage): UIMessage {\n const unfinished = message.state === \"running\" || message.parts.some((part) => part.type === \"tool\" && part.result === undefined && !part.isError);\n const error = unfinished ? runError(`restored:${message.id}`, { code: \"CHAT_STREAM_INCOMPLETE\" }, message.parts.some((part) => part.type === \"tool\" && part.result === undefined)) : message.error;\n const parts = message.parts.map((part): UIMessagePart => {\n if (part.type !== \"tool\") return part;\n const missing = part.result === undefined && !part.isError;\n const result = missing ? JSON.stringify({ error: { code: \"EXECUTION_OUTCOME_UNKNOWN\", message: interruptedMessage } }) : part.result;\n let presentation = toolError(part.error?.id ?? `${message.id}:${part.toolCallId}`, part.toolCallId,\n result ?? JSON.stringify({ error: { code: \"TOOL_ERROR\" } }), missing ? error?.id : part.error?.parentErrorId, false, part.name);\n if (!presentation.toolState && part.isError) presentation = toolError(part.error?.id ?? `${message.id}:${part.toolCallId}`, part.toolCallId, JSON.stringify({ error: { code: \"TOOL_ERROR\" } }));\n return { ...part, ...(result === undefined ? {} : { result }), isError: Boolean(presentation.error),\n ...(presentation.error ? { error: presentation.error, errorMessage: presentation.error.userMessage } : {}),\n ...(presentation.toolState ? { toolState: presentation.toolState } : {}),\n };\n });\n return { ...message, parts, ...(unfinished ? { state: \"error\" as const } : {}), ...(error ? { error } : {}) };\n}\n\nexport interface ChatStorageVersion { value: string | null }\n\nexport function readChatStorage(key: string, version?: ChatStorageVersion): StoredChat | undefined {\n try {\n const raw = localStorage.getItem(key);\n if (version) version.value = raw;\n const value: unknown = JSON.parse(raw ?? \"null\");\n if (!record(value) || value.version !== 3 || !Array.isArray(value.sessions) || !value.sessions.length) return;\n const sessions: StoredSession[] = [];\n for (const session of value.sessions) {\n if (!record(session) || typeof session.id !== \"string\" || !session.id\n || (session.title !== undefined && typeof session.title !== \"string\")\n || !Array.isArray(session.messages) || !session.messages.every(isMessage)\n || sessions.some((existing) => existing.id === session.id)) return;\n sessions.push({ id: session.id, ...(session.title ? { title: session.title } : {}), messages: migratePageTaskResults(session.messages).map(restoreMessage) });\n }\n const activeSessionId = sessions.find((session) => session.id === value.activeSessionId)?.id ?? sessions[0]!.id;\n return { sessions, activeSessionId };\n } catch {\n return undefined;\n }\n}\n\nexport function writeChatStorage(key: string, state: StoredChat, version: ChatStorageVersion): \"saved\" | \"unchanged\" | \"conflict\" | \"unavailable\" {\n try {\n const next = JSON.stringify({\n version: 3,\n activeSessionId: state.activeSessionId,\n sessions: state.sessions.map(({ id, title, messages }) => ({ id, title, messages: messages.map((message) => ({\n ...message, parts: message.parts.map((part) => part.type === \"tool\" && part.error ? {\n ...part, errorMessage: part.error.userMessage,\n result: JSON.stringify({ error: { code: part.error.code, message: part.error.userMessage } }),\n } : part),\n })) })),\n });\n if (next === version.value) return \"unchanged\";\n if (localStorage.getItem(key) !== version.value) return \"conflict\";\n localStorage.setItem(key, next);\n version.value = next;\n return \"saved\";\n } catch {\n // Storage restrictions or quota exhaustion must not break the active chat.\n return \"unavailable\";\n }\n}\n\nexport function conversationFromMessages(messages: readonly UIMessage[]): AgentMessage[] {\n const legacy = new Set([\"callAppTool\", \"getSnapshot\", \"executeCode\", \"loadSkill\", \"finish\", \"nxf_executeCode\"]);\n if (messages.some((message) => message.parts.some((part) => part.type === \"tool\" && legacy.has(part.name)))) throw new Error(\"旧版本会话无法恢复,请升级后新建会话。\");\n // Restore conversation content only. Runtime catalogs, snapshots, approvals and Skills belong to the new page.\n return messages.filter((message) => message.role !== \"assistant\" || message.parts.length > 0).map((message): AgentMessage => {\n if (message.role === \"user\") {\n const text = message.parts.flatMap((part) => part.type === \"text\" ? [part.text] : []).join(\"\\n\");\n return { id: message.id, role: \"user\", content: message.attachments?.length\n ? [{ type: \"text\", text }, ...message.attachments.flatMap(attachmentContent)] : text };\n }\n const sections: string[] = [];\n let text: string | undefined;\n for (const part of message.parts) {\n if (part.type === \"reasoning\") continue;\n if (part.type === \"text\") {\n // Reasoning splits display parts, not the original model text.\n text = (text ?? \"\") + part.text;\n continue;\n }\n if (text !== undefined) sections.push(text);\n text = undefined;\n sections.push(part.name === \"nxf_getSnapshot\" || part.name === \"nxf_executeAction\" || part.name === \"nxf_applyAction\"\n ? \"之前调用了页面自动化工具;页面已刷新,需要重新观察页面。\"\n : `历史工具记录 ${part.name}\\n输入:${part.arguments}\\n结果:${part.result ?? part.errorMessage ?? interruptedMessage}`);\n }\n if (text !== undefined) sections.push(text);\n const content = sections.join(\"\\n\");\n return { id: message.id, role: \"assistant\", content, toolCalls: [] };\n });\n}\n"]}
|
|
1
|
+
{"version":3,"file":"storage.js","sourceRoot":"","sources":["../src/storage.ts"],"names":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AAI,IAAI,EAAE,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC;gBAChC,SAAS;YACX,CAAC;YACD,IAAI,IAAI,KAAK,SAAS;gBAAE,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAC5C,IAAI,GAAG,SAAS,CAAC;YACjB,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,iBAAiB,IAAI,IAAI,CAAC,IAAI,KAAK,mBAAmB,IAAI,IAAI,CAAC,IAAI,KAAK,iBAAiB;gBACnH,CAAC,CAAC,8BAA8B;gBAChC,CAAC,CAAC,UAAU,IAAI,CAAC,IAAI,QAAQ,IAAI,CAAC,SAAS,QAAQ,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,YAAY,IAAI,kBAAkB,EAAE,CAAC,CAAC;QACjH,CAAC;QACD,IAAI,IAAI,KAAK,SAAS;YAAE,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC5C,MAAM,OAAO,GAAG,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACpC,OAAO,EAAE,EAAE,EAAE,OAAO,CAAC,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC;IACvE,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { isNexfaceError, runError, toolError } from \"./errors.js\";\nimport type { AgentInputContent, AgentMessage } from \"@nexface/agent\";\nimport type { UIMessage, UIMessagePart } from \"./react.js\";\nimport { attachmentContent, type Attachment } from \"./attachments.js\";\n\nexport const chatStorageKey = \"nexface:chat:sessions:v3\";\n\ninterface StoredSession {\n id: string;\n title?: string;\n messages: UIMessage[];\n}\ninterface StoredChat {\n sessions: StoredSession[];\n activeSessionId: string;\n}\nconst interruptedMessage = \"页面已刷新,之前的操作未恢复,执行结果请重新核实。\";\nconst record = (value: unknown): value is Record<string, unknown> =>\n value !== null && typeof value === \"object\" && !Array.isArray(value);\n\nfunction legacyPageTaskResult(message: UIMessage): Record<string, unknown> | undefined {\n if (message.role !== \"assistant\" || message.parts.length !== 1 || message.parts[0]?.type !== \"text\") return;\n try {\n const parsed: unknown = JSON.parse(message.parts[0].text);\n if (!record(parsed) || Object.keys(parsed).length !== 1 || !record(parsed.pageTaskResult)) return;\n const result = parsed.pageTaskResult;\n if ((result.status === \"done\" || result.status === \"blocked\")\n && result.businessOutcome === \"unverified\"\n && record(result.task)\n && typeof result.task.goal === \"string\"\n && typeof result.task.completion === \"string\") return result;\n } catch { /* Non-JSON assistant text remains unchanged. */ }\n return;\n}\n\nfunction migratePageTaskResults(messages: readonly UIMessage[]): UIMessage[] {\n const migrated: UIMessage[] = [];\n for (const message of messages) {\n const result = legacyPageTaskResult(message);\n let updated = false;\n if (result) for (let index = migrated.length - 1; index >= 0 && !updated; index -= 1) {\n const owner = migrated[index]!;\n if (owner.role === \"user\") break;\n const partIndex = owner.parts.findIndex((part) => part.type === \"tool\" && part.name === \"nxf_delegatePageTask\");\n if (partIndex < 0) continue;\n const part = owner.parts[partIndex];\n if (part?.type !== \"tool\" || part.result === undefined) break;\n try {\n const accepted: unknown = JSON.parse(part.result!);\n const task = result.task as Record<string, unknown>;\n if (!record(accepted) || !record(accepted.result) || accepted.result.status !== \"accepted\"\n || accepted.result.goal !== task.goal || accepted.result.completion !== task.completion) break;\n } catch { break; }\n const parts = [...owner.parts];\n parts[partIndex] = { ...part, result: JSON.stringify({ result: { pageTaskResult: result } }) };\n migrated[index] = { ...owner, parts };\n updated = true;\n }\n if (!updated) migrated.push(message);\n }\n return migrated;\n}\n\nfunction isContent(value: unknown): value is AgentInputContent {\n if (!record(value)) return false;\n if (value.type === \"text\") return typeof value.text === \"string\";\n if (value.type !== \"image\" || !record(value.source)) return false;\n return (value.source.type === \"data\" || value.source.type === \"url\")\n && typeof value.source.value === \"string\"\n && (value.source.mimeType === undefined || typeof value.source.mimeType === \"string\");\n}\nfunction isAttachment(value: unknown): value is Attachment {\n return record(value) && typeof value.id === \"string\" && typeof value.name === \"string\"\n && (isContent(value.content) || Array.isArray(value.content) && value.content.length > 0 && value.content.every(isContent))\n && (value.preview === undefined || typeof value.preview === \"string\");\n}\nfunction isPart(value: unknown): value is UIMessagePart {\n if (!record(value)) return false;\n if (value.type === \"text\" || value.type === \"reasoning\") return typeof value.text === \"string\";\n return value.type === \"tool\" && typeof value.toolCallId === \"string\"\n && typeof value.name === \"string\" && typeof value.arguments === \"string\"\n && [\"result\", \"parseError\", \"errorMessage\"].every((key) => value[key] === undefined || typeof value[key] === \"string\")\n && (value.isError === undefined || typeof value.isError === \"boolean\")\n && (value.error === undefined || isNexfaceError(value.error))\n && (value.toolState === undefined || [\"failed\", \"unknown\", \"not_started\", \"cancelled\", \"rejected\"].includes(String(value.toolState)));\n}\nfunction isMessage(value: unknown): value is UIMessage {\n return record(value) && typeof value.id === \"string\" && (value.role === \"user\" || value.role === \"assistant\")\n && Array.isArray(value.parts) && value.parts.every(isPart)\n && (value.attachments === undefined || Array.isArray(value.attachments) && value.attachments.every(isAttachment))\n && (value.error === undefined || isNexfaceError(value.error))\n && (value.revisionOf === undefined || typeof value.revisionOf === \"string\")\n && (value.state === undefined || [\"running\", \"success\", \"error\", \"cancelled\"].includes(String(value.state)));\n}\nfunction restoreMessage(message: UIMessage): UIMessage {\n const unfinished = message.state === \"running\" || message.parts.some((part) => part.type === \"tool\" && part.result === undefined && !part.isError);\n const error = unfinished ? runError(`restored:${message.id}`, { code: \"CHAT_STREAM_INCOMPLETE\" }, message.parts.some((part) => part.type === \"tool\" && part.result === undefined)) : message.error;\n const parts = message.parts.map((part): UIMessagePart => {\n if (part.type !== \"tool\") return part;\n const missing = part.result === undefined && !part.isError;\n const result = missing ? JSON.stringify({ error: { code: \"EXECUTION_OUTCOME_UNKNOWN\", message: interruptedMessage } }) : part.result;\n let presentation = toolError(part.error?.id ?? `${message.id}:${part.toolCallId}`, part.toolCallId,\n result ?? JSON.stringify({ error: { code: \"TOOL_ERROR\" } }), missing ? error?.id : part.error?.parentErrorId, false, part.name);\n if (!presentation.toolState && part.isError) presentation = toolError(part.error?.id ?? `${message.id}:${part.toolCallId}`, part.toolCallId, JSON.stringify({ error: { code: \"TOOL_ERROR\" } }));\n return { ...part, ...(result === undefined ? {} : { result }), isError: Boolean(presentation.error),\n ...(presentation.error ? { error: presentation.error, errorMessage: presentation.error.userMessage } : {}),\n ...(presentation.toolState ? { toolState: presentation.toolState } : {}),\n };\n });\n return { ...message, parts, ...(unfinished ? { state: \"error\" as const } : {}), ...(error ? { error } : {}) };\n}\n\nfunction withoutReasoning(messages: readonly UIMessage[]): UIMessage[] {\n return messages.flatMap((message) => {\n const parts = message.parts.filter((part) => part.type !== \"reasoning\");\n if (!parts.length && message.parts.length) return [];\n return [{ ...message, parts }];\n });\n}\n\nexport interface ChatStorageVersion { value: string | null }\n\nexport function readChatStorage(key: string, version?: ChatStorageVersion): StoredChat | undefined {\n try {\n const raw = localStorage.getItem(key);\n if (version) version.value = raw;\n const value: unknown = JSON.parse(raw ?? \"null\");\n if (!record(value) || value.version !== 3 || !Array.isArray(value.sessions) || !value.sessions.length) return;\n const sessions: StoredSession[] = [];\n for (const session of value.sessions) {\n if (!record(session) || typeof session.id !== \"string\" || !session.id\n || (session.title !== undefined && typeof session.title !== \"string\")\n || !Array.isArray(session.messages) || !session.messages.every(isMessage)\n || sessions.some((existing) => existing.id === session.id)) return;\n sessions.push({ id: session.id, ...(session.title ? { title: session.title } : {}), messages: migratePageTaskResults(withoutReasoning(session.messages)).map(restoreMessage) });\n }\n const activeSessionId = sessions.find((session) => session.id === value.activeSessionId)?.id ?? sessions[0]!.id;\n return { sessions, activeSessionId };\n } catch {\n return undefined;\n }\n}\n\nexport function writeChatStorage(key: string, state: StoredChat, version: ChatStorageVersion): \"saved\" | \"unchanged\" | \"conflict\" | \"unavailable\" {\n try {\n const next = JSON.stringify({\n version: 3,\n activeSessionId: state.activeSessionId,\n sessions: state.sessions.map(({ id, title, messages }) => ({ id, title, messages: withoutReasoning(messages).map((message) => ({\n ...message, parts: message.parts.map((part) => part.type === \"tool\" && part.error ? {\n ...part, errorMessage: part.error.userMessage,\n result: JSON.stringify({ error: { code: part.error.code, message: part.error.userMessage } }),\n } : part),\n })) })),\n });\n if (next === version.value) return \"unchanged\";\n if (localStorage.getItem(key) !== version.value) return \"conflict\";\n localStorage.setItem(key, next);\n version.value = next;\n return \"saved\";\n } catch {\n // Storage restrictions or quota exhaustion must not break the active chat.\n return \"unavailable\";\n }\n}\n\nexport function conversationFromMessages(messages: readonly UIMessage[]): AgentMessage[] {\n const legacy = new Set([\"callAppTool\", \"getSnapshot\", \"executeCode\", \"loadSkill\", \"finish\", \"nxf_executeCode\"]);\n if (messages.some((message) => message.parts.some((part) => part.type === \"tool\" && legacy.has(part.name)))) throw new Error(\"旧版本会话无法恢复,请升级后新建会话。\");\n // Restore conversation content only. Runtime catalogs, snapshots, approvals and Skills belong to the new page.\n return messages.filter((message) => message.role !== \"assistant\" || message.parts.length > 0).map((message): AgentMessage => {\n if (message.role === \"user\") {\n const text = message.parts.flatMap((part) => part.type === \"text\" ? [part.text] : []).join(\"\\n\");\n return { id: message.id, role: \"user\", content: message.attachments?.length\n ? [{ type: \"text\", text }, ...message.attachments.flatMap(attachmentContent)] : text };\n }\n const sections: string[] = [];\n let text: string | undefined;\n for (const part of message.parts) {\n if (part.type === \"reasoning\") continue;\n if (part.type === \"text\") {\n // Reasoning splits display parts, not the original model text.\n text = (text ?? \"\") + part.text;\n continue;\n }\n if (text !== undefined) sections.push(text);\n text = undefined;\n sections.push(part.name === \"nxf_getSnapshot\" || part.name === \"nxf_executeAction\" || part.name === \"nxf_applyAction\"\n ? \"之前调用了页面自动化工具;页面已刷新,需要重新观察页面。\"\n : `历史工具记录 ${part.name}\\n输入:${part.arguments}\\n结果:${part.result ?? part.errorMessage ?? interruptedMessage}`);\n }\n if (text !== undefined) sections.push(text);\n const content = sections.join(\"\\n\");\n return { id: message.id, role: \"assistant\", content, toolCalls: [] };\n });\n}\n"]}
|
package/dist/styles.css
CHANGED
|
@@ -810,9 +810,6 @@
|
|
|
810
810
|
.nexface-ui .nxf-scroll-m-20 {
|
|
811
811
|
scroll-margin: calc(var(--nxf-spacing) * 20);
|
|
812
812
|
}
|
|
813
|
-
.nexface-ui .nxf-\[scrollbar-width\:none\] {
|
|
814
|
-
scrollbar-width: none;
|
|
815
|
-
}
|
|
816
813
|
.nexface-ui .nxf-\[scrollbar-gutter\:stable_both-edges\] {
|
|
817
814
|
scrollbar-gutter: stable both-edges;
|
|
818
815
|
}
|
|
@@ -2391,9 +2388,6 @@
|
|
|
2391
2388
|
width: calc(var(--nxf-spacing) * 4);
|
|
2392
2389
|
height: calc(var(--nxf-spacing) * 4);
|
|
2393
2390
|
}
|
|
2394
|
-
.nexface-ui .nxf-\[\&\:\:-webkit-scrollbar\]\:hidden::-webkit-scrollbar {
|
|
2395
|
-
display: none;
|
|
2396
|
-
}
|
|
2397
2391
|
.nexface-ui .nxf-\[\[align\=center\]\]\:text-center[align="center"] {
|
|
2398
2392
|
text-align: center;
|
|
2399
2393
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { useState, isValidElement, createContext, useContext, } from "react";
|
|
4
4
|
import { XIcon, PlusIcon, FileText, Loader2Icon, AlertCircleIcon, } from "lucide-react";
|
|
5
5
|
import { AttachmentPrimitive, ComposerPrimitive, MessagePrimitive, useAuiState, useAui, } from "@assistant-ui/react";
|
|
@@ -20,7 +20,7 @@ const AttachmentPreview = ({ src }) => {
|
|
|
20
20
|
const AttachmentPreviewDialog = ({ children }) => {
|
|
21
21
|
const src = usePreview();
|
|
22
22
|
if (!src)
|
|
23
|
-
return children;
|
|
23
|
+
return _jsx(_Fragment, { children: children });
|
|
24
24
|
return (_jsxs(Dialog, { children: [_jsx(DialogTrigger, { className: cn("aui-attachment-preview-trigger cursor-zoom-in"), asChild: true, children: isValidElement(children) ? (children) : (_jsx("button", { type: "button", children: children })) }), _jsxs(DialogContent, { className: cn("aui-attachment-preview-dialog-content [&>button]:bg-foreground/60 [&>button]:hover:bg-foreground/80 [&_svg]:text-background p-2 sm:max-w-3xl [&>button]:rounded-full [&>button]:p-1 [&>button]:opacity-100 [&>button]:ring-0!"), children: [_jsx(DialogTitle, { className: cn("aui-sr-only sr-only"), children: "\u56FE\u7247\u9644\u4EF6\u9884\u89C8" }), _jsx("div", { className: cn("aui-attachment-preview bg-background relative mx-auto flex max-h-[80dvh] w-full items-center justify-center overflow-hidden rounded-sm"), children: _jsx(AttachmentPreview, { src: src }) })] })] }));
|
|
25
25
|
};
|
|
26
26
|
const AttachmentThumb = () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attachment.aui.js","sourceRoot":"","sources":["../../src/ui/attachment.aui.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AACb,OAAO,EAA0B,QAAQ,EAAW,cAAc,EAAE,aAAa,EAAE,UAAU,GAAG,MAAM,OAAO,CAAC;AAC9G,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,WAAW,EAAE,eAAe,GAAG,MAAM,cAAc,CAAC;AACxF,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,qBAAqB,CAAC;AACrH,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,cAAc,GAAG,MAAM,cAAc,CAAC;AACzF,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,aAAa,EAAE,aAAa,GAAG,MAAM,aAAa,CAAC;AACjF,OAAO,EAAE,MAAM,EAAe,cAAc,GAAG,MAAM,aAAa,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,O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AC,iBAAiB,IAAC,OAAO,EAAC,0BAAM,EAAC,IAAI,EAAC,QAAQ,EAAC,OAAO,EAAC,OAAO,EAAC,IAAI,EAAC,MAAM,EAAC,SAAS,EAAE,EAAE,CAAC,8OAA8O,CAAC,gBAAa,0BAAM,YAC3V,KAAC,QAAQ,IAAC,SAAS,EAAE,EAAE,CAAC,gCAAgC,CAAC,GAAG,GACzC,GACa,CAAC,CAAC;AACtC,CAAC,CAAC","sourcesContent":["\"use client\";\nimport { type PropsWithChildren, useState, type FC, isValidElement, createContext, useContext, } from \"react\";\nimport { XIcon, PlusIcon, FileText, Loader2Icon, AlertCircleIcon, } from \"lucide-react\";\nimport { AttachmentPrimitive, ComposerPrimitive, MessagePrimitive, useAuiState, useAui, } from \"@assistant-ui/react\";\nimport { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, } from \"./tooltip.js\";\nimport { Dialog, DialogTitle, DialogContent, DialogTrigger, } from \"./dialog.js\";\nimport { Avatar, AvatarImage, AvatarFallback, } from \"./avatar.js\";\nimport { TooltipIconButton } from \"./tooltip-icon-button.js\";\nimport { useAttachmentSrc } from \"./use-attachment-src.js\";\nimport { cn } from \"./utils.js\";\nconst PreviewContext = createContext<string | undefined>(undefined);\nconst usePreview = () => { const fallback = useAttachmentSrc(); return useContext(PreviewContext) ?? fallback; };\ntype AttachmentPreviewProps = {\n src: string;\n};\nconst AttachmentPreview: FC<AttachmentPreviewProps> = ({ src }) => {\n const [isLoaded, setIsLoaded] = useState(false);\n return (<img src={src} alt=\"附件预览\" className={cn(\"block h-auto max-h-[80vh] w-auto max-w-full rounded-sm object-contain transition-opacity duration-300 motion-reduce:transition-none\", isLoaded\n ? \"aui-attachment-preview-image-loaded opacity-100\"\n : \"aui-attachment-preview-image-loading opacity-0\")} onLoad={() => setIsLoaded(true)}/>);\n};\nconst AttachmentPreviewDialog: FC<PropsWithChildren> = ({ children }) => {\n const src = usePreview();\n if (!src)\n return children;\n return (<Dialog>\n <DialogTrigger className={cn(\"aui-attachment-preview-trigger cursor-zoom-in\")} asChild>\n {isValidElement(children) ? (children) : (<button type=\"button\">{children}</button>)}\n </DialogTrigger>\n <DialogContent className={cn(\"aui-attachment-preview-dialog-content [&>button]:bg-foreground/60 [&>button]:hover:bg-foreground/80 [&_svg]:text-background p-2 sm:max-w-3xl [&>button]:rounded-full [&>button]:p-1 [&>button]:opacity-100 [&>button]:ring-0!\")}>\n <DialogTitle className={cn(\"aui-sr-only sr-only\")}>\n 图片附件预览\n </DialogTitle>\n <div className={cn(\"aui-attachment-preview bg-background relative mx-auto flex max-h-[80dvh] w-full items-center justify-center overflow-hidden rounded-sm\")}>\n <AttachmentPreview src={src}/>\n </div>\n </DialogContent>\n </Dialog>);\n};\nconst AttachmentThumb: FC = () => {\n const src = usePreview();\n const name = useAuiState((s) => s.attachment.name);\n return <Avatar className={cn(\"aui-attachment-tile-avatar h-full w-full rounded-none\")}>\n {src ? <img src={src} alt={name} className={cn(\"aui-attachment-tile-image h-full w-full rounded-none object-cover\")}/> : <AvatarFallback><FileText className={cn(\"aui-attachment-tile-fallback-icon text-muted-foreground/80 size-6 stroke-[1.5]\")}/></AvatarFallback>}\n </Avatar>;\n};\nexport function AttachmentUI({ preview, children }: PropsWithChildren<{\n preview?: string | undefined;\n}>) {\n return <PreviewContext.Provider value={preview}><AttachmentContent>{children}</AttachmentContent></PreviewContext.Provider>;\n}\nconst AttachmentContent: FC<PropsWithChildren> = ({ children }) => {\n const aui = useAui();\n const isComposer = aui.attachment.source !== \"message\";\n const isImage = useAuiState((s) => s.attachment.type === \"image\");\n const typeLabel = useAuiState((s) => {\n const type = s.attachment.type;\n switch (type) {\n case \"image\":\n return \"图片\";\n case \"document\":\n return \"文档\";\n case \"file\":\n return \"文件\";\n default:\n return type;\n }\n });\n const uploadState = useAuiState((s) => s.attachment.status.type === \"running\"\n ? \"uploading\"\n : s.attachment.status.type === \"incomplete\" &&\n s.attachment.status.reason === \"error\"\n ? \"error\"\n : undefined);\n const isUploading = uploadState === \"uploading\";\n const isError = uploadState === \"error\";\n const errorMessage = useAuiState((s) => s.attachment.status.type === \"incomplete\" &&\n s.attachment.status.reason === \"error\"\n ? (s.attachment.status.message ?? \"附件处理失败\")\n : undefined);\n return (<TooltipProvider>\n <Tooltip>\n <AttachmentPrimitive.Root className={cn(\"aui-attachment-root relative\", isComposer &&\n \"animate-in fade-in-0 zoom-in-95 duration-200 motion-reduce:animate-none\", isImage &&\n !isComposer &&\n \"aui-attachment-root-message only:*:first:size-24\")}>\n <AttachmentPreviewDialog>\n <TooltipTrigger asChild>\n <div className={cn(\"aui-attachment-tile bg-muted hover:after:bg-foreground/10 focus-visible:ring-ring/50 relative size-14 cursor-pointer overflow-hidden rounded-[calc(var(--nxf-composer-radius,1rem)-var(--nxf-composer-padding,8px))] transition-transform outline-none after:pointer-events-none after:absolute after:inset-0 after:rounded-[inherit] after:ring-1 after:ring-black/10 after:transition-colors after:ring-inset focus-visible:ring-1 active:scale-[0.96] motion-reduce:transition-none dark:after:ring-white/10\", isError &&\n \"after:ring-destructive/60 dark:after:ring-destructive/60\")} role=\"button\" tabIndex={0} onKeyDown={(e) => {\n if (e.key === \"Enter\") {\n e.preventDefault();\n e.currentTarget.click();\n }\n else if (e.key === \" \") {\n e.preventDefault();\n }\n }} onKeyUp={(e) => {\n if (e.key === \" \")\n e.currentTarget.click();\n }} aria-label={`${typeLabel}附件${isError ? \",处理失败\" : isUploading ? \",正在处理\" : \"\"}`}>\n <AttachmentThumb />\n {isUploading && (<div aria-hidden=\"true\" className={cn(\"aui-attachment-tile-uploading bg-background/60 animate-in fade-in-0 absolute inset-0 flex items-center justify-center backdrop-blur-[2px] motion-reduce:animate-none\")}>\n <Loader2Icon className={cn(\"text-muted-foreground size-4 animate-spin\")}/>\n </div>)}\n {isError && (<div aria-hidden=\"true\" className={cn(\"aui-attachment-tile-error bg-background/70 animate-in fade-in-0 absolute inset-0 flex items-center justify-center backdrop-blur-[2px] motion-reduce:animate-none\")}>\n <AlertCircleIcon className={cn(\"text-destructive size-4\")}/>\n </div>)}\n </div>\n </TooltipTrigger>\n </AttachmentPreviewDialog>\n {isComposer && <AttachmentRemove />}\n {children}\n </AttachmentPrimitive.Root>\n <TooltipContent side=\"top\">\n <AttachmentPrimitive.Name />\n {errorMessage && (<p className={cn(\"aui-attachment-error-message\")}>{errorMessage}</p>)}\n </TooltipContent>\n </Tooltip>\n </TooltipProvider>);\n};\nconst AttachmentRemove: FC = () => {\n const name = useAuiState((s) => s.attachment.name);\n return (<AttachmentPrimitive.Remove asChild>\n <TooltipIconButton tooltip=\"移除附件\" aria-label={`移除 ${name}`} className={cn(\"aui-attachment-tile-remove absolute end-1 top-1 size-5 rounded-full bg-black/50! text-white after:absolute after:-inset-1.5 hover:bg-black/70! hover:text-white! active:scale-[0.96] motion-reduce:transition-none\")} side=\"top\">\n <XIcon className={cn(\"aui-attachment-remove-icon size-3 stroke-[2.5]\")}/>\n </TooltipIconButton>\n </AttachmentPrimitive.Remove>);\n};\nexport const UserMessageAttachments: FC = () => {\n return (<div className={cn(\"aui-user-message-attachments-end col-span-full col-start-1 row-start-1 flex w-full flex-row justify-end gap-2\")}>\n <MessagePrimitive.Attachments>\n {() => <AttachmentUI />}\n </MessagePrimitive.Attachments>\n </div>);\n};\nexport const ComposerAttachments: FC = () => {\n return (<div className={cn(\"aui-composer-attachments flex w-full flex-row items-center gap-2 overflow-x-auto empty:hidden\")}>\n <ComposerPrimitive.Attachments>\n {() => <AttachmentUI />}\n </ComposerPrimitive.Attachments>\n </div>);\n};\nexport const ComposerAddAttachment: FC = () => {\n return (<ComposerPrimitive.AddAttachment asChild>\n <TooltipIconButton tooltip=\"添加附件\" side=\"bottom\" variant=\"ghost\" size=\"icon\" className={cn(\"aui-composer-add-attachment text-muted-foreground hover:text-foreground hover:bg-muted-foreground/15 dark:border-muted-foreground/15 dark:hover:bg-muted-foreground/30 size-7 rounded-full active:scale-[0.96] motion-reduce:transition-none\")} aria-label=\"添加附件\">\n <PlusIcon className={cn(\"aui-attachment-add-icon size-4\")}/>\n </TooltipIconButton>\n </ComposerPrimitive.AddAttachment>);\n};\n"]}
|
|
1
|
+
{"version":3,"file":"attachment.aui.js","sourceRoot":"","sources":["../../src/ui/attachment.aui.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AACb,OAAO,EAA0B,QAAQ,EAAW,cAAc,EAAE,aAAa,EAAE,UAAU,GAAG,MAAM,OAAO,CAAC;AAC9G,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,WAAW,EAAE,eAAe,GAAG,MAAM,cAAc,CAAC;AACxF,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,qBAAqB,CAAC;AACrH,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,cAAc,GAAG,MAAM,cAAc,CAAC;AACzF,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,aAAa,EAAE,aAAa,GAAG,MAAM,aAAa,CAAC;AACjF,OAAO,EAAE,MAAM,EAAE,cAAc,GAAG,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,EAAE,EAAE,MAAM,YAAY,CAAC;AAChC,MAAM,cAAc,GAAG,aAAa,CAAqB,SAAS,CAAC,CAAC;AACpE,MAAM,UAAU,GAAG,GAAG,EAAE,GAAG,MAAM,QAAQ,GAAG,gBAAgB,EAAE,CAAC,CAAC,OAAO,UAAU,CAAC,cAAc,CAAC,IAAI,QAAQ,CAAC,CAAC,CAAC,CAAC;AAIjH,MAAM,iBAAiB,GAA+B,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE;IAChE,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAChD,OAAO,CAAC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AAM,IAAI,EAAE,EAAE,SAAS,EAAE,EAAE,CAAC,oNAAoN,CAAC,EAAE,IAAI,EAAC,KAAK,YAC1S,KAAC,KAAK,IAAC,SAAS,EAAE,EAAE,CAAC,gDAAgD,CAAC,GAAG,GACtD,GACQ,CAAC,CAAC;AACjC,CAAC,CAAC;AACF,MAAM,CAAC,MAAM,sBAAsB,GAAO,GAAG,EAAE;IAC7C,OAAO,CAAC,cAAK,SAAS,EAAE,EAAE,CAAC,+GAA+G,CAAC,YAC1I,KAAC,gBAAgB,CAAC,WAAW,cAC3B,GAAG,EAAE,CAAC,KAAC,YAAY,KAAG,GACO,GAC1B,CAAC,CAAC;AACV,CAAC,CAAC;AACF,MAAM,CAAC,MAAM,mBAAmB,GAAO,GAAG,EAAE;IAC1C,OAAO,CAAC,cAAK,SAAS,EAAE,EAAE,CAAC,+FAA+F,CAAC,YAC1H,KAAC,iBAAiB,CAAC,WAAW,cAC5B,GAAG,EAAE,CAAC,KAAC,YAAY,KAAG,GACQ,GAC3B,CAAC,CAAC;AACV,CAAC,CAAC;AACF,MAAM,CAAC,MAAM,qBAAqB,GAAO,GAAG,EAAE;IAC5C,OAAO,CAAC,KAAC,iBAAiB,CAAC,aAAa,IAAC,OAAO,kBAC/C,KAAC,iBAAiB,IAAC,OAAO,EAAC,0BAAM,EAAC,IAAI,EAAC,QAAQ,EAAC,OAAO,EAAC,OAAO,EAAC,IAAI,EAAC,MAAM,EAAC,SAAS,EAAE,EAAE,CAAC,8OAA8O,CAAC,gBAAa,0BAAM,YAC3V,KAAC,QAAQ,IAAC,SAAS,EAAE,EAAE,CAAC,gCAAgC,CAAC,GAAG,GACzC,GACa,CAAC,CAAC;AACtC,CAAC,CAAC","sourcesContent":["\"use client\";\nimport { type PropsWithChildren, useState, type FC, isValidElement, createContext, useContext, } from \"react\";\nimport { XIcon, PlusIcon, FileText, Loader2Icon, AlertCircleIcon, } from \"lucide-react\";\nimport { AttachmentPrimitive, ComposerPrimitive, MessagePrimitive, useAuiState, useAui, } from \"@assistant-ui/react\";\nimport { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, } from \"./tooltip.js\";\nimport { Dialog, DialogTitle, DialogContent, DialogTrigger, } from \"./dialog.js\";\nimport { Avatar, AvatarFallback, } from \"./avatar.js\";\nimport { TooltipIconButton } from \"./tooltip-icon-button.js\";\nimport { useAttachmentSrc } from \"./use-attachment-src.js\";\nimport { cn } from \"./utils.js\";\nconst PreviewContext = createContext<string | undefined>(undefined);\nconst usePreview = () => { const fallback = useAttachmentSrc(); return useContext(PreviewContext) ?? fallback; };\ntype AttachmentPreviewProps = {\n src: string;\n};\nconst AttachmentPreview: FC<AttachmentPreviewProps> = ({ src }) => {\n const [isLoaded, setIsLoaded] = useState(false);\n return (<img src={src} alt=\"附件预览\" className={cn(\"block h-auto max-h-[80vh] w-auto max-w-full rounded-sm object-contain transition-opacity duration-300 motion-reduce:transition-none\", isLoaded\n ? \"aui-attachment-preview-image-loaded opacity-100\"\n : \"aui-attachment-preview-image-loading opacity-0\")} onLoad={() => setIsLoaded(true)}/>);\n};\nconst AttachmentPreviewDialog: FC<PropsWithChildren<unknown>> = ({ children }) => {\n const src = usePreview();\n if (!src)\n return <>{children}</>;\n return (<Dialog>\n <DialogTrigger className={cn(\"aui-attachment-preview-trigger cursor-zoom-in\")} asChild>\n {isValidElement(children) ? (children) : (<button type=\"button\">{children}</button>)}\n </DialogTrigger>\n <DialogContent className={cn(\"aui-attachment-preview-dialog-content [&>button]:bg-foreground/60 [&>button]:hover:bg-foreground/80 [&_svg]:text-background p-2 sm:max-w-3xl [&>button]:rounded-full [&>button]:p-1 [&>button]:opacity-100 [&>button]:ring-0!\")}>\n <DialogTitle className={cn(\"aui-sr-only sr-only\")}>\n 图片附件预览\n </DialogTitle>\n <div className={cn(\"aui-attachment-preview bg-background relative mx-auto flex max-h-[80dvh] w-full items-center justify-center overflow-hidden rounded-sm\")}>\n <AttachmentPreview src={src}/>\n </div>\n </DialogContent>\n </Dialog>);\n};\nconst AttachmentThumb: FC = () => {\n const src = usePreview();\n const name = useAuiState((s) => s.attachment.name);\n return <Avatar className={cn(\"aui-attachment-tile-avatar h-full w-full rounded-none\")}>\n {src ? <img src={src} alt={name} className={cn(\"aui-attachment-tile-image h-full w-full rounded-none object-cover\")}/> : <AvatarFallback><FileText className={cn(\"aui-attachment-tile-fallback-icon text-muted-foreground/80 size-6 stroke-[1.5]\")}/></AvatarFallback>}\n </Avatar>;\n};\nexport function AttachmentUI({ preview, children }: PropsWithChildren<{\n preview?: string | undefined;\n}>) {\n return <PreviewContext.Provider value={preview}><AttachmentContent>{children}</AttachmentContent></PreviewContext.Provider>;\n}\nconst AttachmentContent: FC<PropsWithChildren<unknown>> = ({ children }) => {\n const aui = useAui();\n const isComposer = aui.attachment.source !== \"message\";\n const isImage = useAuiState((s) => s.attachment.type === \"image\");\n const typeLabel = useAuiState((s) => {\n const type = s.attachment.type;\n switch (type) {\n case \"image\":\n return \"图片\";\n case \"document\":\n return \"文档\";\n case \"file\":\n return \"文件\";\n default:\n return type;\n }\n });\n const uploadState = useAuiState((s) => s.attachment.status.type === \"running\"\n ? \"uploading\"\n : s.attachment.status.type === \"incomplete\" &&\n s.attachment.status.reason === \"error\"\n ? \"error\"\n : undefined);\n const isUploading = uploadState === \"uploading\";\n const isError = uploadState === \"error\";\n const errorMessage = useAuiState((s) => s.attachment.status.type === \"incomplete\" &&\n s.attachment.status.reason === \"error\"\n ? (s.attachment.status.message ?? \"附件处理失败\")\n : undefined);\n return (<TooltipProvider>\n <Tooltip>\n <AttachmentPrimitive.Root className={cn(\"aui-attachment-root relative\", isComposer &&\n \"animate-in fade-in-0 zoom-in-95 duration-200 motion-reduce:animate-none\", isImage &&\n !isComposer &&\n \"aui-attachment-root-message only:*:first:size-24\")}>\n <AttachmentPreviewDialog>\n <TooltipTrigger asChild>\n <div className={cn(\"aui-attachment-tile bg-muted hover:after:bg-foreground/10 focus-visible:ring-ring/50 relative size-14 cursor-pointer overflow-hidden rounded-[calc(var(--nxf-composer-radius,1rem)-var(--nxf-composer-padding,8px))] transition-transform outline-none after:pointer-events-none after:absolute after:inset-0 after:rounded-[inherit] after:ring-1 after:ring-black/10 after:transition-colors after:ring-inset focus-visible:ring-1 active:scale-[0.96] motion-reduce:transition-none dark:after:ring-white/10\", isError &&\n \"after:ring-destructive/60 dark:after:ring-destructive/60\")} role=\"button\" tabIndex={0} onKeyDown={(e) => {\n if (e.key === \"Enter\") {\n e.preventDefault();\n e.currentTarget.click();\n }\n else if (e.key === \" \") {\n e.preventDefault();\n }\n }} onKeyUp={(e) => {\n if (e.key === \" \")\n e.currentTarget.click();\n }} aria-label={`${typeLabel}附件${isError ? \",处理失败\" : isUploading ? \",正在处理\" : \"\"}`}>\n <AttachmentThumb />\n {isUploading && (<div aria-hidden=\"true\" className={cn(\"aui-attachment-tile-uploading bg-background/60 animate-in fade-in-0 absolute inset-0 flex items-center justify-center backdrop-blur-[2px] motion-reduce:animate-none\")}>\n <Loader2Icon className={cn(\"text-muted-foreground size-4 animate-spin\")}/>\n </div>)}\n {isError && (<div aria-hidden=\"true\" className={cn(\"aui-attachment-tile-error bg-background/70 animate-in fade-in-0 absolute inset-0 flex items-center justify-center backdrop-blur-[2px] motion-reduce:animate-none\")}>\n <AlertCircleIcon className={cn(\"text-destructive size-4\")}/>\n </div>)}\n </div>\n </TooltipTrigger>\n </AttachmentPreviewDialog>\n {isComposer && <AttachmentRemove />}\n {children}\n </AttachmentPrimitive.Root>\n <TooltipContent side=\"top\">\n <AttachmentPrimitive.Name />\n {errorMessage && (<p className={cn(\"aui-attachment-error-message\")}>{errorMessage}</p>)}\n </TooltipContent>\n </Tooltip>\n </TooltipProvider>);\n};\nconst AttachmentRemove: FC = () => {\n const name = useAuiState((s) => s.attachment.name);\n return (<AttachmentPrimitive.Remove asChild>\n <TooltipIconButton tooltip=\"移除附件\" aria-label={`移除 ${name}`} className={cn(\"aui-attachment-tile-remove absolute end-1 top-1 size-5 rounded-full bg-black/50! text-white after:absolute after:-inset-1.5 hover:bg-black/70! hover:text-white! active:scale-[0.96] motion-reduce:transition-none\")} side=\"top\">\n <XIcon className={cn(\"aui-attachment-remove-icon size-3 stroke-[2.5]\")}/>\n </TooltipIconButton>\n </AttachmentPrimitive.Remove>);\n};\nexport const UserMessageAttachments: FC = () => {\n return (<div className={cn(\"aui-user-message-attachments-end col-span-full col-start-1 row-start-1 flex w-full flex-row justify-end gap-2\")}>\n <MessagePrimitive.Attachments>\n {() => <AttachmentUI />}\n </MessagePrimitive.Attachments>\n </div>);\n};\nexport const ComposerAttachments: FC = () => {\n return (<div className={cn(\"aui-composer-attachments flex w-full flex-row items-center gap-2 overflow-x-auto empty:hidden\")}>\n <ComposerPrimitive.Attachments>\n {() => <AttachmentUI />}\n </ComposerPrimitive.Attachments>\n </div>);\n};\nexport const ComposerAddAttachment: FC = () => {\n return (<ComposerPrimitive.AddAttachment asChild>\n <TooltipIconButton tooltip=\"添加附件\" side=\"bottom\" variant=\"ghost\" size=\"icon\" className={cn(\"aui-composer-add-attachment text-muted-foreground hover:text-foreground hover:bg-muted-foreground/15 dark:border-muted-foreground/15 dark:hover:bg-muted-foreground/30 size-7 rounded-full active:scale-[0.96] motion-reduce:transition-none\")} aria-label=\"添加附件\">\n <PlusIcon className={cn(\"aui-attachment-add-icon size-4\")}/>\n </TooltipIconButton>\n </ComposerPrimitive.AddAttachment>);\n};\n"]}
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export declare function AssistantActionBar(): ReactNode;
|
|
1
|
+
export declare function AssistantActionBar(): import("react").JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"action-bar.js","sourceRoot":"","sources":["../../../src/ui/home-demo/action-bar.tsx"],"names":[],"mappings":";AAAA,oGAAoG;AACpG,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"action-bar.js","sourceRoot":"","sources":["../../../src/ui/home-demo/action-bar.tsx"],"names":[],"mappings":";AAAA,oGAAoG;AACpG,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,kBAAkB,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,MAAM,UAAU,kBAAkB;IAEhC,OAAO,CACL,KAAC,kBAAkB,CAAC,IAAI,IACtB,QAAQ,EAAC,OAAO,EAChB,SAAS,EAAE,EAAE,CAAC,2BAA2B,CAAC,YAE1C,MAAC,kBAAkB,CAAC,IAAI,kBACX,0BAAM,EACjB,SAAS,EAAE,EAAE,CAAC,iBAAiB,CAAC,aAEhC,KAAC,KAAK,IAAC,SAAS,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,YACzC,KAAC,SAAS,IAAC,SAAS,EAAE,EAAE,CAAC,QAAQ,CAAC,GAAK,GACjC,EACR,KAAC,KAAK,IAAC,SAAS,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,YAC1C,KAAC,QAAQ,IAAC,SAAS,EAAE,EAAE,CAAC,QAAQ,CAAC,GAAK,GAChC,IACgB,GACF,CAC3B,CAAC;AACJ,CAAC","sourcesContent":["// Adapted from the pinned official homepage Demo; see vendor/assistant-ui/home-demo/ADAPTATIONS.md.\nimport { cn } from \"../utils.js\";\nimport { ActionBarPrimitive, AuiIf } from \"@assistant-ui/react\";\nimport { CheckIcon, CopyIcon } from \"lucide-react\";\nimport { actionButtonClass } from \"./styles.js\";\nexport function AssistantActionBar() {\n\n return (\n <ActionBarPrimitive.Root\n autohide=\"never\"\n className={cn(\"flex items-center gap-1.5\")}\n >\n <ActionBarPrimitive.Copy\n aria-label=\"复制回复\"\n className={cn(actionButtonClass)}\n >\n <AuiIf condition={(s) => s.message.isCopied}>\n <CheckIcon className={cn(\"size-4\")} />\n </AuiIf>\n <AuiIf condition={(s) => !s.message.isCopied}>\n <CopyIcon className={cn(\"size-4\")} />\n </AuiIf>\n </ActionBarPrimitive.Copy>\n </ActionBarPrimitive.Root>\n );\n}\n"]}
|
|
@@ -8,4 +8,4 @@ export declare function EditComposer({ children, inputProps, cancelProps, sendPr
|
|
|
8
8
|
inputProps: ComponentProps<typeof ComposerPrimitive.Input>;
|
|
9
9
|
cancelProps: ComponentProps<"button">;
|
|
10
10
|
sendProps: ComponentProps<"button">;
|
|
11
|
-
}):
|
|
11
|
+
}): import("react").JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"composer.js","sourceRoot":"","sources":["../../../src/ui/home-demo/composer.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAC1E,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AACjC,MAAM,UAAU,QAAQ,CAAC,EAAE,QAAQ,EAAE,UAAU,EAAE,OAAO,EAAE,GAAG,KAAK,EAEjE;IACC,OAAO,CACL,KAAC,iBAAiB,CAAC,IAAI,IAAC,SAAS,EAAE,EAAE,CAAC,iBAAiB,CAAC,KAAO,KAAK,YAClE,KAAC,iBAAiB,CAAC,kBAAkB,IAAC,OAAO,QAAC,QAAQ,EAAE,UAAU,CAAC,QAAQ,EACzE,aAAa,EAAE,CAAC,KAAK,EAAE,EAAE,GAAG,IAAI,UAAU,CAAC,QAAQ;gBAAE,KAAK,CAAC,cAAc,EAAE,CAAC,CAAC,CAAC,EAC9E,iBAAiB,EAAE,CAAC,KAAK,EAAE,EAAE,GAAG,IAAI,UAAU,CAAC,QAAQ;gBAAE,KAAK,CAAC,cAAc,EAAE,CAAC,CAAC,CAAC,YAClF,4BAAe,oBAAoB,EAAC,SAAS,EAAE,EAAE,CAAC,uMAAuM,CAAC,aACxP,cAAK,SAAS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PTATIONS.md.\nimport type { ComponentProps, ReactNode } from \"react\";\nimport { ComposerPrimitive, MessagePrimitive } from \"@assistant-ui/react\";\nimport { cn } from \"../utils.js\";\nexport function Composer({ children, inputProps, actions, ...props }: ComponentProps<typeof ComposerPrimitive.Root> & {\n inputProps: ComponentProps<typeof ComposerPrimitive.Input>; actions: ReactNode;\n}) {\n return (\n <ComposerPrimitive.Root className={cn(\"relative w-full\")} {...props}>\n <ComposerPrimitive.AttachmentDropzone asChild disabled={inputProps.disabled}\n onDropCapture={(event) => { if (inputProps.disabled) event.preventDefault(); }}\n onDragOverCapture={(event) => { if (inputProps.disabled) event.preventDefault(); }}>\n <div data-slot=\"aui_composer-shell\" className={cn(\"border-foreground/10 bg-muted/30 focus-within:border-foreground/25 data-[dragging=true]:border-foreground/40 rounded-thread flex flex-col border transition-colors data-[dragging=true]:border-dashed\")} >\n <div className={cn(\"has-[.aui-attachment-root]:px-3 has-[.aui-attachment-root]:pt-3\")} >{children}</div>\n <ComposerPrimitive.Input asChild {...inputProps}>\n <textarea data-composer-input rows={1} className={cn(\"placeholder:text-muted-foreground field-sizing-content max-h-48 w-full resize-none bg-transparent px-4 pt-3 pb-2 text-base leading-6 focus:outline-none\")} />\n </ComposerPrimitive.Input>\n <div className={cn(\"flex items-center justify-between gap-2 px-2 pb-2\")} >{actions}</div>\n </div>\n </ComposerPrimitive.AttachmentDropzone>\n </ComposerPrimitive.Root>\n );\n}\n\nexport function EditComposer({ children, inputProps, cancelProps, sendProps, ...props }: ComponentProps<typeof ComposerPrimitive.Root> & {\n inputProps: ComponentProps<typeof ComposerPrimitive.Input>;\n cancelProps: ComponentProps<\"button\">; sendProps: ComponentProps<\"button\">;\n})
|
|
1
|
+
{"version":3,"file":"composer.js","sourceRoot":"","sources":["../../../src/ui/home-demo/composer.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAC1E,OAAO,EAAE,EAAE,EAA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6I,CAAC,KAAO,KAAK,aAC9L,KAAC,iBAAiB,CAAC,KAAK,IAAC,OAAO,WAAK,UAAU,YAC7C,mBACE,SAAS,QAET,IAAI,EAAE,CAAC,EACP,SAAS,EAAE,EAAE,CAAC,oIAAoI,CAAC,GACnJ,GACsB,EACzB,QAAQ,EACT,eAAK,SAAS,EAAE,EAAE,CAAC,qDAAqD,CAAC,aACvE,KAAC,iBAAiB,CAAC,MAAM,IAAC,OAAO,kBAC/B,iBACE,IAAI,EAAC,QAAQ,KACT,WAAW,EACf,SAAS,EAAE,EAAE,CAAC,oGAAoG,CAAC,6BAG5G,GACgB,EAC3B,KAAC,iBAAiB,CAAC,IAAI,IAAC,OAAO,kBAC7B,iBACE,IAAI,EAAC,QAAQ,KACT,SAAS,EACb,SAAS,EAAE,EAAE,CAAC,4HAA4H,CAAC,2DAGpI,GACc,IACrB,IACiB,GACH,CACzB,CAAC;AACJ,CAAC","sourcesContent":["// Adapted from the pinned official homepage Demo; see vendor/assistant-ui/home-demo/ADAPTATIONS.md.\nimport type { ComponentProps, ReactNode } from \"react\";\nimport { ComposerPrimitive, MessagePrimitive } from \"@assistant-ui/react\";\nimport { cn } from \"../utils.js\";\nexport function Composer({ children, inputProps, actions, ...props }: ComponentProps<typeof ComposerPrimitive.Root> & {\n inputProps: ComponentProps<typeof ComposerPrimitive.Input>; actions: ReactNode;\n}) {\n return (\n <ComposerPrimitive.Root className={cn(\"relative w-full\")} {...props}>\n <ComposerPrimitive.AttachmentDropzone asChild disabled={inputProps.disabled}\n onDropCapture={(event) => { if (inputProps.disabled) event.preventDefault(); }}\n onDragOverCapture={(event) => { if (inputProps.disabled) event.preventDefault(); }}>\n <div data-slot=\"aui_composer-shell\" className={cn(\"border-foreground/10 bg-muted/30 focus-within:border-foreground/25 data-[dragging=true]:border-foreground/40 rounded-thread flex flex-col border transition-colors data-[dragging=true]:border-dashed\")} >\n <div className={cn(\"has-[.aui-attachment-root]:px-3 has-[.aui-attachment-root]:pt-3\")} >{children}</div>\n <ComposerPrimitive.Input asChild {...inputProps}>\n <textarea data-composer-input rows={1} className={cn(\"placeholder:text-muted-foreground field-sizing-content max-h-48 w-full resize-none bg-transparent px-4 pt-3 pb-2 text-base leading-6 focus:outline-none\")} />\n </ComposerPrimitive.Input>\n <div className={cn(\"flex items-center justify-between gap-2 px-2 pb-2\")} >{actions}</div>\n </div>\n </ComposerPrimitive.AttachmentDropzone>\n </ComposerPrimitive.Root>\n );\n}\n\nexport function EditComposer({ children, inputProps, cancelProps, sendProps, ...props }: ComponentProps<typeof ComposerPrimitive.Root> & {\n inputProps: ComponentProps<typeof ComposerPrimitive.Input>;\n cancelProps: ComponentProps<\"button\">; sendProps: ComponentProps<\"button\">;\n}) {\n return (\n <MessagePrimitive.Root\n data-role=\"user\" data-slot=\"aui_edit-composer-wrapper\"\n className={cn(\"mx-auto flex w-full max-w-(--nxf-thread-max-width) flex-col items-end\")}\n >\n <ComposerPrimitive.Root className={cn(\"border-foreground/10 bg-muted/30 focus-within:border-foreground/25 rounded-thread flex w-full max-w-[85%] flex-col border transition-colors\")} {...props}>\n <ComposerPrimitive.Input asChild {...inputProps}>\n <textarea\n autoFocus\n\n rows={1}\n className={cn(\"field-sizing-content max-h-48 min-h-12 w-full resize-none bg-transparent px-4 pt-3.5 pb-1 text-[15px] leading-6 focus:outline-none\")}\n />\n </ComposerPrimitive.Input>\n {children}\n <div className={cn(\"flex items-center justify-end gap-1.5 px-2.5 pb-2.5\")} >\n <ComposerPrimitive.Cancel asChild>\n <button\n type=\"button\"\n {...cancelProps}\n className={cn(\"text-muted-foreground hover:text-foreground rounded-control h-8 px-3 text-[13px] transition-colors\")}\n >\n 取消\n </button>\n </ComposerPrimitive.Cancel>\n <ComposerPrimitive.Send asChild>\n <button\n type=\"button\"\n {...sendProps}\n className={cn(\"bg-primary text-primary-foreground rounded-control h-8 px-3 text-[13px] font-medium transition-opacity disabled:opacity-40\")}\n >\n 保存并重新发送\n </button>\n </ComposerPrimitive.Send>\n </div>\n </ComposerPrimitive.Root>\n </MessagePrimitive.Root>\n );\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"greeting.js","sourceRoot":"","sources":["../../../src/ui/home-demo/greeting.tsx"],"names":[],"mappings":";AAAA,oGAAoG;AACpG,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"greeting.js","sourceRoot":"","sources":["../../../src/ui/home-demo/greeting.tsx"],"names":[],"mappings":";AAAA,oGAAoG;AACpG,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAClD,MAAM,UAAU,QAAQ,CAAC,EAAE,KAAK,EAAE,WAAW,EAAuD;IAElG,OAAO,CACL,eAAK,SAAS,EAAE,EAAE,CAAC,kJAAkJ,CAAC,aACpK,YAAG,SAAS,EAAE,EAAE,CAAC,WAAW,CAAC,YAC1B,KAAK,GACJ,EACH,WAAW,CAAC,CAAC,CAAC,YAAG,SAAS,EAAE,EAAE,CAAC,QAAQ,CAAC,YAAG,WAAW,GAAK,CAAC,CAAC,CAAC,IAAI,IAC/D,CACP,CAAC;AACJ,CAAC","sourcesContent":["// Adapted from the pinned official homepage Demo; see vendor/assistant-ui/home-demo/ADAPTATIONS.md.\nimport { cn } from \"../utils.js\";\nimport { typeSection, typeDeck } from \"./type.js\";\nexport function Greeting({ title, description }: { title: string; description?: string | undefined }) {\n\n return (\n <div className={cn(\"animate-in fade-in slide-in-from-bottom-1 mx-auto mb-8 flex w-full max-w-(--nxf-thread-max-width) flex-col items-center text-center duration-200\")} >\n <p className={cn(typeSection)}>\n {title}\n </p>\n {description ? <p className={cn(typeDeck)}>{description}</p> : null}\n </div>\n );\n}\n"]}
|
|
@@ -3,7 +3,7 @@ export declare function UserMessage({ children, attachments, actions }: {
|
|
|
3
3
|
children: ReactNode;
|
|
4
4
|
attachments: ReactNode;
|
|
5
5
|
actions: ReactNode;
|
|
6
|
-
}):
|
|
6
|
+
}): import("react").JSX.Element;
|
|
7
7
|
export declare function AssistantMessage({ children }: {
|
|
8
8
|
children: ReactNode;
|
|
9
|
-
}):
|
|
9
|
+
}): import("react").JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messages.js","sourceRoot":"","sources":["../../../src/ui/home-demo/messages.tsx"],"names":[],"mappings":";AAAA,oGAAoG;AACpG,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AAEjC,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACxG,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACrD,MAAM,UAAU,WAAW,CAAC,EAAE,QAAQ,EAAE,WAAW,EAAE,OAAO,EAAuE;IACjI,OAAO,CACL,MAAC,gBAAgB,CAAC,IAAI,iBACV,MAAM,eAAW,uBAAuB,EAClD,SAAS,EAAE,EAAE,CAAC,8HAA8H,CAAC,aAE7I,cAAK,SAAS,EAAE,EAAE,CAAC,wCAAwC,CAAC,YACzD,WAAW,GACR,EACN,eAAK,SAAS,EAAE,EAAE,CAAC,sBAAsB,CAAC,aACxC,cAAK,SAAS,EAAE,EAAE,CAAC,iFAAiF,CAAC,YAClG,QAAQ,GACL,EACN,KAAC,kBAAkB,CAAC,IAAI,IACtB,eAAe,QACf,QAAQ,EAAC,UAAU,EACnB,SAAS,EAAE,EAAE,CAAC,sFAAsF,CAAC,YAEpG,OAAO,GACgB,IACtB,IACgB,CACzB,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,EAAE,QAAQ,EAA2B;IACpE,OAAO,CACL,MAAC,gBAAgB,CAAC,IAAI,iBACV,WAAW,eAAW,4BAA4B,EAC5D,SAAS,EAAE,EAAE,CAAC,sGAAsG,CAAC,aAErH,4BAAe,+BAA+B,EAAC,SAAS,EAAE,EAAE,CAAC,6CAA6C,CAAC,aACxG,QAAQ,EACT,KAAC,YAAY,KAAG,IACZ,EACN,cAAK,SAAS,EAAE,EAAE,CAAC,6CAA6C,CAAC,YAC/D,KAAC,kBAAkB,KAAG,GAClB,IACgB,CACzB,CAAC;AACJ,CAAC;AAED,SAAS,YAAY;IACnB,MAAM,SAAS,GAAG,WAAW,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,IAAI,KAAK,YAAY,IAAI,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,KAAK,WAAW,CAAC,CAAC;IACzH,IAAI,SAAS;QAAE,OAAO,YAAG,IAAI,EAAC,QAAQ,EAAC,SAAS,EAAE,EAAE,CAAC,wCAAwC,CAAC,wBAAa,CAAC;IAC5G,OAAO,KAAC,gBAAgB,CAAC,KAAK,cAAC,KAAC,cAAc,CAAC,IAAI,IAAC,IAAI,EAAC,OAAO,EAAC,SAAS,EAAE,EAAE,CAAC,yEAAyE,CAAC,YAAE,KAAC,cAAc,CAAC,OAAO,IAAC,SAAS,EAAE,EAAE,CAAC,cAAc,CAAC,GAAI,GAAsB,GAAyB,CAAC;AACtQ,CAAC","sourcesContent":["// Adapted from the pinned official homepage Demo; see vendor/assistant-ui/home-demo/ADAPTATIONS.md.\nimport { cn } from \"../utils.js\";\nimport type { ReactNode } from \"react\";\nimport { ActionBarPrimitive, ErrorPrimitive, MessagePrimitive, useAuiState } from \"@assistant-ui/react\";\nimport { AssistantActionBar } from \"./action-bar.js\";\nexport function UserMessage({ children, attachments, actions }: { children: ReactNode; attachments: ReactNode; actions: ReactNode })
|
|
1
|
+
{"version":3,"file":"messages.js","sourceRoot":"","sources":["../../../src/ui/home-demo/messages.tsx"],"names":[],"mappings":";AAAA,oGAAoG;AACpG,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AAEjC,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,gBAAgB,EAAE,WAAW,E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AAS;QAAE,OAAO,YAAG,IAAI,EAAC,QAAQ,EAAC,SAAS,EAAE,EAAE,CAAC,wCAAwC,CAAC,wBAAa,CAAC;IAC5G,OAAO,KAAC,gBAAgB,CAAC,KAAK,cAAC,KAAC,cAAc,CAAC,IAAI,IAAC,IAAI,EAAC,OAAO,EAAC,SAAS,EAAE,EAAE,CAAC,yEAAyE,CAAC,YAAE,KAAC,cAAc,CAAC,OAAO,IAAC,SAAS,EAAE,EAAE,CAAC,cAAc,CAAC,GAAI,GAAsB,GAAyB,CAAC;AACtQ,CAAC","sourcesContent":["// Adapted from the pinned official homepage Demo; see vendor/assistant-ui/home-demo/ADAPTATIONS.md.\nimport { cn } from \"../utils.js\";\nimport type { ReactNode } from \"react\";\nimport { ActionBarPrimitive, ErrorPrimitive, MessagePrimitive, useAuiState } from \"@assistant-ui/react\";\nimport { AssistantActionBar } from \"./action-bar.js\";\nexport function UserMessage({ children, attachments, actions }: { children: ReactNode; attachments: ReactNode; actions: ReactNode }) {\n return (\n <MessagePrimitive.Root\n data-role=\"user\" data-slot=\"aui_user-message-root\"\n className={cn(\"animate-in fade-in slide-in-from-bottom-1 mx-auto flex w-full max-w-(--nxf-thread-max-width) flex-col items-end duration-150\")}\n >\n <div className={cn(\"w-full has-[.aui-attachment-root]:mb-2\")} >\n {attachments}\n </div>\n <div className={cn(\"relative max-w-[80%]\")} >\n <div className={cn(\"peer bg-muted rounded-thread px-4 py-2 text-[15px] wrap-break-word empty:hidden\")} >\n {children}\n </div>\n <ActionBarPrimitive.Root\n hideWhenRunning\n autohide=\"not-last\"\n className={cn(\"absolute start-0 top-1/2 -translate-x-full -translate-y-1/2 pe-1.5 peer-empty:hidden\")}\n >\n {actions}\n </ActionBarPrimitive.Root>\n </div>\n </MessagePrimitive.Root>\n );\n}\n\nexport function AssistantMessage({ children }: { children: ReactNode }) {\n return (\n <MessagePrimitive.Root\n data-role=\"assistant\" data-slot=\"aui_assistant-message-root\"\n className={cn(\"animate-in fade-in slide-in-from-bottom-1 mx-auto w-full max-w-(--nxf-thread-max-width) duration-150\")}\n >\n <div data-slot=\"aui_assistant-message-content\" className={cn(\"text-[15px] leading-relaxed wrap-break-word\")} >\n {children}\n <MessageError />\n </div>\n <div className={cn(\"mt-2 flex items-center gap-1.5 empty:hidden\")} >\n <AssistantActionBar />\n </div>\n </MessagePrimitive.Root>\n );\n}\n\nfunction MessageError() {\n const cancelled = useAuiState((s) => s.message.status?.type === \"incomplete\" && s.message.status.reason === \"cancelled\");\n if (cancelled) return <p role=\"status\" className={cn(\"mt-2 text-[13px] text-muted-foreground\")}>Stopped</p>;\n return <MessagePrimitive.Error><ErrorPrimitive.Root role=\"alert\" className={cn(\"mt-2 border-l-2 pl-3 text-[13px] border-destructive/60 text-destructive\")}><ErrorPrimitive.Message className={cn(\"line-clamp-2\")} /></ErrorPrimitive.Root></MessagePrimitive.Error>;\n}\n"]}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { ReactNode } from "react";
|
|
2
1
|
export declare function Suggestions({ suggestions, disabled, onSend }: {
|
|
3
2
|
suggestions: readonly {
|
|
4
3
|
label: string;
|
|
@@ -6,8 +5,4 @@ export declare function Suggestions({ suggestions, disabled, onSend }: {
|
|
|
6
5
|
}[];
|
|
7
6
|
disabled: boolean;
|
|
8
7
|
onSend(prompt: string): void;
|
|
9
|
-
}):
|
|
10
|
-
export declare function FollowUps({ disabled, onSend }: {
|
|
11
|
-
disabled: boolean;
|
|
12
|
-
onSend(prompt: string): void;
|
|
13
|
-
}): ReactNode;
|
|
8
|
+
}): import("react").JSX.Element;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Adapted from the pinned official homepage Demo; see vendor/assistant-ui/home-demo/ADAPTATIONS.md.
|
|
2
2
|
"use client";
|
|
3
3
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
|
-
import {
|
|
4
|
+
import { ThreadPrimitive, useAuiState } from "@assistant-ui/react";
|
|
5
5
|
import { cn } from "../utils.js";
|
|
6
6
|
const suggestionChipClass = "border-foreground/10 bg-background text-muted-foreground hover:border-foreground/25 hover:text-foreground rounded-control h-8 border px-3 text-[13px] transition-colors";
|
|
7
7
|
export function Suggestions({ suggestions, disabled, onSend }) {
|
|
@@ -13,10 +13,4 @@ export function Suggestions({ suggestions, disabled, onSend }) {
|
|
|
13
13
|
// under the cursor. Disabled buttons also stay out of the tab order in React 18.
|
|
14
14
|
_jsx("div", { "aria-hidden": hidden, className: cn("animate-in fade-in mx-auto flex max-w-[34rem] flex-wrap items-center justify-center gap-2 transition-opacity duration-200 motion-reduce:animate-none", hidden && "opacity-0"), children: suggestions.map((suggestion) => (_jsx(ThreadPrimitive.Suggestion, { prompt: suggestion.prompt, send: true, disabled: hidden, onClick: (event) => { event.preventDefault(); onSend(suggestion.prompt); }, className: cn(suggestionChipClass), children: suggestion.label }, suggestion.prompt))) }));
|
|
15
15
|
}
|
|
16
|
-
export function FollowUps({ disabled, onSend }) {
|
|
17
|
-
const suggestions = useAuiState((s) => s.thread.suggestions);
|
|
18
|
-
return (_jsx(AuiIf, { condition: (s) => !s.thread.isEmpty &&
|
|
19
|
-
!s.thread.isRunning &&
|
|
20
|
-
s.thread.suggestions.length > 0, children: _jsx("div", { className: cn("animate-in fade-in flex [scrollbar-width:none] gap-2 overflow-x-auto duration-200 motion-reduce:animate-none [&::-webkit-scrollbar]:hidden"), children: suggestions.map((suggestion) => (_jsx(ThreadPrimitive.Suggestion, { prompt: suggestion.prompt, send: true, disabled: disabled, onClick: (event) => { event.preventDefault(); onSend(suggestion.prompt); }, className: cn(suggestionChipClass, "shrink-0 whitespace-nowrap"), children: suggestion.prompt }, suggestion.prompt))) }) }));
|
|
21
|
-
}
|
|
22
16
|
//# sourceMappingURL=suggestions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"suggestions.js","sourceRoot":"","sources":["../../../src/ui/home-demo/suggestions.tsx"],"names":[],"mappings":"AAAA,oGAAoG;AACpG,YAAY,CAAC;;AAEb,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"suggestions.js","sourceRoot":"","sources":["../../../src/ui/home-demo/suggestions.tsx"],"names":[],"mappings":"AAAA,oGAAoG;AACpG,YAAY,CAAC;;AAEb,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACnE,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AAEjC,MAAM,mBAAmB,GACvB,yKAAyK,CAAC;AAE5K,MAAM,UAAU,WAAW,CAAC,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,EAG1D;IACC,MAAM,eAAe,GAAG,WAAW,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IAC/D,MAAM,MAAM,GAAG,CAAC,eAAe,IAAI,QAAQ,CAAC;IAE5C,OAAO;IACL,0EAA0E;IAC1E,uEAAuE;IACvE,iFAAiF;IACjF,6BACe,MAAM,EACnB,SAAS,EAAE,EAAE,CACX,sJAAsJ,EACtJ,MAAM,IAAI,WAAW,CACtB,YAEA,WAAW,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,CAC/B,KAAC,eAAe,CAAC,UAAU,IAEzB,MAAM,EAAE,UAAU,CAAC,MAAM,EACzB,IAAI,QACJ,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE,GAAG,KAAK,CAAC,cAAc,EAAE,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAC1E,SAAS,EAAE,EAAE,CAAC,mBAAmB,CAAC,YAEjC,UAAU,CAAC,KAAK,IAPZ,UAAU,CAAC,MAAM,CAQK,CAC9B,CAAC,GACE,CACP,CAAC;AACJ,CAAC","sourcesContent":["// Adapted from the pinned official homepage Demo; see vendor/assistant-ui/home-demo/ADAPTATIONS.md.\n\"use client\";\n\nimport { ThreadPrimitive, useAuiState } from \"@assistant-ui/react\";\nimport { cn } from \"../utils.js\";\n\nconst suggestionChipClass =\n \"border-foreground/10 bg-background text-muted-foreground hover:border-foreground/25 hover:text-foreground rounded-control h-8 border px-3 text-[13px] transition-colors\";\n\nexport function Suggestions({ suggestions, disabled, onSend }: {\n suggestions: readonly { label: string; prompt: string }[];\n disabled: boolean; onSend(prompt: string): void;\n}) {\n const isComposerEmpty = useAuiState((s) => s.composer.isEmpty);\n const hidden = !isComposerEmpty || disabled;\n\n return (\n // Typing hides the suggestions without unmounting them: the empty view is\n // centred, so collapsing a block this tall moves the composer out from\n // under the cursor. Disabled buttons also stay out of the tab order in React 18.\n <div\n aria-hidden={hidden}\n className={cn(\n \"animate-in fade-in mx-auto flex max-w-[34rem] flex-wrap items-center justify-center gap-2 transition-opacity duration-200 motion-reduce:animate-none\",\n hidden && \"opacity-0\",\n )}\n >\n {suggestions.map((suggestion) => (\n <ThreadPrimitive.Suggestion\n key={suggestion.prompt}\n prompt={suggestion.prompt}\n send\n disabled={hidden}\n onClick={(event) => { event.preventDefault(); onSend(suggestion.prompt); }}\n className={cn(suggestionChipClass)}\n >\n {suggestion.label}\n </ThreadPrimitive.Suggestion>\n ))}\n </div>\n );\n}\n"]}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { type ReactNode } from "react";
|
|
2
1
|
/**
|
|
3
2
|
* The mark every trace line carries. A disclosure rotates it and a plain line
|
|
4
3
|
* does not, so the two read as the same grammar rather than two symbols; it
|
|
@@ -8,7 +7,7 @@ import { type ReactNode } from "react";
|
|
|
8
7
|
export declare function TraceMarker({ live, className, }: {
|
|
9
8
|
live: boolean;
|
|
10
9
|
className?: string;
|
|
11
|
-
}):
|
|
10
|
+
}): import("react").JSX.Element;
|
|
12
11
|
export declare function useToolDuration(isRunning: boolean): number | null;
|
|
13
12
|
export declare function formatDuration(ms: number): string;
|
|
14
13
|
export declare function TraceLine({ live, label, detail, meta, }: {
|
|
@@ -16,4 +15,4 @@ export declare function TraceLine({ live, label, detail, meta, }: {
|
|
|
16
15
|
label: string;
|
|
17
16
|
detail?: string;
|
|
18
17
|
meta?: string;
|
|
19
|
-
}):
|
|
18
|
+
}): import("react").JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trace-line.js","sourceRoot":"","sources":["../../../src/ui/home-demo/trace-line.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,
|
|
1
|
+
{"version":3,"file":"trace-line.js","sourceRoot":"","sources":["../../../src/ui/home-demo/trace-line.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AAEjC;;;;;GAKG;AACH,MAAM,UAAU,WAAW,CAAC,EAC1B,IAAI,EACJ,SAAS,GAIV;IACC,OAAO,CACL,oCAEE,SAAS,EAAE,EAAE,CACX,4CAA4C,EAC5C,IAAI,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,0BAA0B,EACnD,SAAS,CACV,YAEA,GAAG,GACC,CACR,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,SAAkB;IAChD,MAAM,YAAY,GAAG,MAAM,CAAgB,IAAI,CAAC,CAAC;IACjD,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,QAAQ,CAAgB,IAAI,CAAC,CAAC;IAE9D,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,SAAS,IAAI,YAAY,CAAC,OAAO,KAAK,IAAI,EAAE,CAAC;YAC/C,YAAY,CAAC,OAAO,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;YAClC,WAAW,CAAC,IAAI,CAAC,CAAC;QACpB,CAAC;aAAM,IAAI,CAAC,SAAS,IAAI,YAAY,CAAC,OAAO,KAAK,IAAI,EAAE,CAAC;YACvD,WAAW,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,YAAY,CAAC,OAAO,CAAC,CAAC;YAC/C,YAAY,CAAC,OAAO,GAAG,IAAI,CAAC;QAC9B,CAAC;IACH,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC;IAEhB,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,EAAU;IACvC,IAAI,EAAE,GAAG,IAAI;QAAE,OAAO,GAAG,EAAE,IAAI,CAAC;IAChC,OAAO,GAAG,CAAC,EAAE,GAAG,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC;AACtC,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,EACxB,IAAI,EACJ,KAAK,EACL,MAAM,EACN,IAAI,GAML;IACC,OAAO,CACL,eAAK,SAAS,EAAE,EAAE,CAAC,oFAAoF,CAAC,aACtG,KAAC,WAAW,IAAC,IAAI,EAAE,IAAI,GAAI,EAC3B,eAAM,SAAS,EAAE,EAAE,CAAC,+CAA+C,CAAC,YACjE,IAAI,CAAC,CAAC,CAAC,CACN,MAAC,YAAY,eACV,KAAK,EACL,MAAM,CAAC,CAAC,CAAC,IAAI,MAAM,EAAE,CAAC,CAAC,CAAC,IAAI,IAChB,CAChB,CAAC,CAAC,CAAC,CACF,8BACG,KAAK,EACL,MAAM,CAAC,CAAC,CAAC,IAAI,MAAM,EAAE,CAAC,CAAC,CAAC,IAAI,IAC5B,CACJ,GACI,EACN,IAAI,CAAC,CAAC,CAAC,CACN,eAAM,SAAS,EAAE,EAAE,CAAC,mCAAmC,CAAC,YAAG,IAAI,GAAQ,CACxE,CAAC,CAAC,CAAC,IAAI,IACJ,CACP,CAAC;AACJ,CAAC","sourcesContent":["\"use client\";\n\nimport { useEffect, useRef, useState } from \"react\";\nimport { ShimmerLabel } from \"./surfaces.js\";\nimport { cn } from \"../utils.js\";\n\n/**\n * The mark every trace line carries. A disclosure rotates it and a plain line\n * does not, so the two read as the same grammar rather than two symbols; it\n * stays a glyph rather than an icon because an icon on a line that cannot open\n * reads as an affordance.\n */\nexport function TraceMarker({\n live,\n className,\n}: {\n live: boolean;\n className?: string;\n}) {\n return (\n <span\n aria-hidden\n className={cn(\n \"inline-block shrink-0 transition-transform\",\n live ? \"text-blue-500\" : \"text-muted-foreground/50\",\n className,\n )}\n >\n {\">\"}\n </span>\n );\n}\n\nexport function useToolDuration(isRunning: boolean): number | null {\n const startTimeRef = useRef<number | null>(null);\n const [duration, setDuration] = useState<number | null>(null);\n\n useEffect(() => {\n if (isRunning && startTimeRef.current === null) {\n startTimeRef.current = Date.now();\n setDuration(null);\n } else if (!isRunning && startTimeRef.current !== null) {\n setDuration(Date.now() - startTimeRef.current);\n startTimeRef.current = null;\n }\n }, [isRunning]);\n\n return duration;\n}\n\nexport function formatDuration(ms: number): string {\n if (ms < 1000) return `${ms}ms`;\n return `${(ms / 1000).toFixed(1)}s`;\n}\n\nexport function TraceLine({\n live,\n label,\n detail,\n meta,\n}: {\n live: boolean;\n label: string;\n detail?: string;\n meta?: string;\n}) {\n return (\n <div className={cn(\"my-1 flex items-baseline gap-2 font-mono text-[12px] [font-variant-ligatures:none]\")}>\n <TraceMarker live={live} />\n <span className={cn(\"text-muted-foreground min-w-0 flex-1 truncate\")}>\n {live ? (\n <ShimmerLabel>\n {label}\n {detail ? ` ${detail}` : null}\n </ShimmerLabel>\n ) : (\n <>\n {label}\n {detail ? ` ${detail}` : null}\n </>\n )}\n </span>\n {meta ? (\n <span className={cn(\"text-muted-foreground/50 shrink-0\")}>{meta}</span>\n ) : null}\n </div>\n );\n}\n"]}
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import type { UIMessagePart } from "../../messages.js";
|
|
2
2
|
import type { ToolCallMessagePartProps } from "@assistant-ui/react";
|
|
3
|
-
import type { ReactNode } from "react";
|
|
4
3
|
export declare const disclosureContentClass = "border-foreground/10 ms-[5px] border-s ps-4";
|
|
5
4
|
export declare function DisclosureTrigger({ live, label, detail, }: {
|
|
6
5
|
live: boolean;
|
|
7
6
|
label: string;
|
|
8
7
|
detail?: string;
|
|
9
|
-
}):
|
|
8
|
+
}): import("react").JSX.Element;
|
|
10
9
|
export declare function ToolCall({ toolName, args, argsText, result, status, isError, showDetails, presentation }: ToolCallMessagePartProps & {
|
|
11
10
|
showDetails: boolean;
|
|
12
11
|
presentation?: UIMessagePart | undefined;
|
|
13
|
-
}):
|
|
12
|
+
}): import("react").JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trace.js","sourceRoot":"","sources":["../../../src/ui/home-demo/trace.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACpE,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"trace.js","sourceRoot":"","sources":["../../../src/ui/home-demo/trace.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACpE,YAAY,CAAC;AAGb,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EACL,SAAS,EACT,WAAW,EACX,eAAe,EACf,cAAc,GACf,MAAM,iBAAiB,CAAC;AAEzB,MAAM,CAAC,MAAM,sBAAsB,GACjC,6CAA6C,CAAC;AAEhD,MAAM,UAAU,iBAAiB,CAAC,EAChC,IAAI,EACJ,KAAK,EACL,MAAM,GAKP;IACC,OAAO,CACL,MAAC,kBAAkB,iBAAW,oBAAoB,EAAC,SAAS,EAAE,EAAE,CAAC,4JAA4J,CAAC,aAC5N,KAAC,WAAW,IACV,I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K,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,EAAE,SAAS,KAAK,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,EAAE,SAAS,KAAK,aAAa,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,OAAO,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,GAAO,CAAC,CAAC,CAAC,IAAI,IACtU,IAAc,IAAG,CAAC;AACzC,CAAC","sourcesContent":["import type { UIMessagePart } from \"../../messages.js\";\nimport { cn } from \"../utils.js\";\nimport { Collapsible, CollapsibleContent } from \"../collapsible.js\";\n\"use client\";\n\nimport type { ToolCallMessagePartProps } from \"@assistant-ui/react\";\nimport { ShimmerLabel } from \"./surfaces.js\";\nimport { CollapsibleTrigger } from \"../collapsible.js\";\nimport {\n TraceLine,\n TraceMarker,\n useToolDuration,\n formatDuration,\n} from \"./trace-line.js\";\n\nexport const disclosureContentClass =\n \"border-foreground/10 ms-[5px] border-s ps-4\";\n\nexport function DisclosureTrigger({\n live,\n label,\n detail,\n}: {\n live: boolean;\n label: string;\n detail?: string;\n}) {\n return (\n <CollapsibleTrigger data-slot=\"tool-group-trigger\" className={cn(\"group/trigger my-1 flex max-w-full items-baseline gap-2 text-left font-mono text-[12px] outline-none [font-variant-ligatures:none] focus-visible:underline\")}>\n <TraceMarker\n live={live}\n className={cn(\"group-data-open/trigger:rotate-90 group-data-panel-open/trigger:rotate-90\")}\n />\n <span className={cn(\"text-muted-foreground group-hover/trigger:text-foreground min-w-0 truncate transition-colors\")}>\n {live ? (\n <ShimmerLabel>\n {label}\n {detail ? ` ${detail}` : null}\n </ShimmerLabel>\n ) : (\n <>\n {label}\n {detail ? ` ${detail}` : null}\n </>\n )}\n </span>\n </CollapsibleTrigger>\n );\n}\n\nexport function ToolCall({ toolName, args, argsText, result, status, isError, showDetails, presentation }: ToolCallMessagePartProps & { showDetails: boolean; presentation?: UIMessagePart | undefined }) {\n const tool = presentation?.type === \"tool\" ? presentation : undefined;\n const error = tool?.error;\n const label = tool?.toolState === \"unknown\" ? \"Result unknown\" : tool?.toolState === \"rejected\" ? \"Rejected\" : tool?.toolState === \"cancelled\" ? \"Stopped\" : tool?.toolState === \"not_started\" ? \"Not started\" : tool?.toolState === \"failed\" || isError ? \"Failed\" : undefined;\n const live = !label && status?.type === \"running\";\n const duration = useToolDuration(live);\n const line = <TraceLine live={live} label={label ?? (live ? \"running\" : \"ran\")} detail={toolName} {...(duration === null ? {} : { meta: formatDuration(duration) })} />;\n const reason = error && !error.parentErrorId && error.scope === \"tool\" && error.execution !== \"unknown\" ? <p role=\"alert\" className={cn(\"mt-2 border-l-2 pl-3 text-[13px] border-destructive/60 text-destructive\")}>{error.userMessage}</p> : null;\n if (!showDetails) return <>{line}{reason}</>;\n return <>{line}{reason}<Collapsible><DisclosureTrigger live={false} label=\"操作明细\" /><CollapsibleContent className={cn(disclosureContentClass)}>\n <pre className={cn(\"overflow-x-auto text-xs\")} aria-label=\"操作输入\">{argsText || JSON.stringify(args, null, 2)}</pre>\n {result !== undefined ? <pre className={cn(\"overflow-x-auto text-xs\")} aria-label=\"操作输出\">{error ? error.userMessage : tool?.toolState === \"cancelled\" ? \"Stopped\" : tool?.toolState === \"rejected\" ? \"Rejected\" : tool?.toolState === \"not_started\" ? \"Not started\" : typeof result === \"string\" ? result : JSON.stringify(result, null, 2)}</pre> : null}\n </CollapsibleContent></Collapsible></>;\n}\n"]}
|
|
@@ -1,7 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import type { TextMessagePartProps } from "@assistant-ui/react";
|
|
3
|
-
type MarkdownTextProps = Partial<TextMessagePartProps> & {
|
|
4
|
-
components?: Parameters<typeof memoizeMarkdownComponents>[0];
|
|
5
|
-
};
|
|
6
|
-
export declare const MarkdownText: import("react").NamedExoticComponent<MarkdownTextProps>;
|
|
7
|
-
export {};
|
|
1
|
+
export declare const MarkdownText: import("react").NamedExoticComponent<{}>;
|
package/dist/ui/markdown-text.js
CHANGED
|
@@ -2,36 +2,12 @@
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { MarkdownTextPrimitive, unstable_memoizeMarkdownComponents as memoizeMarkdownComponents, useIsMarkdownCodeBlock, } from "@assistant-ui/react-markdown";
|
|
4
4
|
import remarkGfm from "remark-gfm";
|
|
5
|
-
import { memo,
|
|
5
|
+
import { memo, useRef } from "react";
|
|
6
6
|
import { CheckIcon, CopyIcon } from "lucide-react";
|
|
7
7
|
import { CodeBlock } from "./code-block.js";
|
|
8
8
|
import { useCopyToClipboard } from "./use-copy-to-clipboard.js";
|
|
9
9
|
import { cn } from "./utils.js";
|
|
10
|
-
const
|
|
11
|
-
const ref = useRef(value);
|
|
12
|
-
if (value !== ref.current) {
|
|
13
|
-
const prev = ref.current;
|
|
14
|
-
const stable = value !== undefined &&
|
|
15
|
-
prev !== undefined &&
|
|
16
|
-
Object.keys(prev).length === Object.keys(value).length &&
|
|
17
|
-
Object.keys(value).every((key) => prev[key] === value[key]);
|
|
18
|
-
if (!stable)
|
|
19
|
-
ref.current = value;
|
|
20
|
-
}
|
|
21
|
-
return ref.current;
|
|
22
|
-
};
|
|
23
|
-
const MarkdownTextImpl = ({ components }) => {
|
|
24
|
-
const stableComponents = useShallowStable(components);
|
|
25
|
-
const markdownComponents = useMemo(() => {
|
|
26
|
-
if (!stableComponents)
|
|
27
|
-
return defaultComponents;
|
|
28
|
-
return {
|
|
29
|
-
...defaultComponents,
|
|
30
|
-
...memoizeMarkdownComponents(stableComponents),
|
|
31
|
-
};
|
|
32
|
-
}, [stableComponents]);
|
|
33
|
-
return (_jsx(MarkdownTextPrimitive, { remarkPlugins: [remarkGfm], skipHtml: true, className: cn("aui-md"), components: markdownComponents, defer: true }));
|
|
34
|
-
};
|
|
10
|
+
const MarkdownTextImpl = () => (_jsx(MarkdownTextPrimitive, { remarkPlugins: [remarkGfm], skipHtml: true, className: cn("aui-md"), components: defaultComponents, defer: true }));
|
|
35
11
|
export const MarkdownText = memo(MarkdownTextImpl);
|
|
36
12
|
function MarkdownTable({ className, children, ...props }) {
|
|
37
13
|
const ref = useRef(null);
|