@nexface/chat 0.1.15-alpha.0 → 0.1.15-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (131) hide show
  1. package/dist/assistant-attachments.js +60 -17
  2. package/dist/assistant-components.d.ts +3 -3
  3. package/dist/assistant-components.js +77 -29
  4. package/dist/assistant-runtime.d.ts +1 -1
  5. package/dist/assistant-runtime.js +100 -43
  6. package/dist/attachments.js +36 -15
  7. package/dist/client.js +309 -77
  8. package/dist/config.d.ts +1 -1
  9. package/dist/config.js +4 -5
  10. package/dist/default-chat.d.ts +1 -1
  11. package/dist/default-chat.js +2102 -728
  12. package/dist/errors.d.ts +1 -0
  13. package/dist/errors.js +69 -18
  14. package/dist/index.js +0 -1
  15. package/dist/messages.js +0 -1
  16. package/dist/page-confirmation.js +3 -4
  17. package/dist/protocol-messages.js +290 -66
  18. package/dist/protocol-response.js +38 -18
  19. package/dist/react.d.ts +1 -1
  20. package/dist/react.js +147 -50
  21. package/dist/shared/errors.d.ts +1 -1
  22. package/dist/shared/errors.js +0 -1
  23. package/dist/shared/runtime-controller.d.ts +1 -0
  24. package/dist/shared/runtime-controller.js +0 -1
  25. package/dist/shared/runtime-execution.js +0 -1
  26. package/dist/shared/schema.js +45 -19
  27. package/dist/storage.js +130 -53
  28. package/dist/styles.css +99 -20
  29. package/dist/tool-result.js +7 -3
  30. package/dist/types.js +0 -1
  31. package/dist/ui/attachment.aui.d.ts +1 -1
  32. package/dist/ui/attachment.aui.js +16 -20
  33. package/dist/ui/avatar.js +0 -1
  34. package/dist/ui/button.js +0 -1
  35. package/dist/ui/code-block.js +2 -3
  36. package/dist/ui/collapsible.js +2 -3
  37. package/dist/ui/composer-voice.js +3 -2
  38. package/dist/ui/dialog.d.ts +1 -1
  39. package/dist/ui/dialog.js +9 -4
  40. package/dist/ui/dropdown-menu.js +2 -3
  41. package/dist/ui/home-demo/action-bar.js +0 -1
  42. package/dist/ui/home-demo/composer.js +7 -4
  43. package/dist/ui/home-demo/greeting.d.ts +1 -1
  44. package/dist/ui/home-demo/greeting.js +1 -2
  45. package/dist/ui/home-demo/messages.d.ts +1 -1
  46. package/dist/ui/home-demo/messages.js +4 -5
  47. package/dist/ui/home-demo/styles.js +0 -1
  48. package/dist/ui/home-demo/suggestions.d.ts +1 -1
  49. package/dist/ui/home-demo/suggestions.js +5 -3
  50. package/dist/ui/home-demo/surfaces.js +3 -2
  51. package/dist/ui/home-demo/thread.d.ts +1 -1
  52. package/dist/ui/home-demo/thread.js +1 -2
  53. package/dist/ui/home-demo/trace-line.d.ts +1 -1
  54. package/dist/ui/home-demo/trace-line.js +2 -3
  55. package/dist/ui/home-demo/trace.d.ts +1 -1
  56. package/dist/ui/home-demo/trace.js +28 -9
  57. package/dist/ui/home-demo/type.js +0 -1
  58. package/dist/ui/input.js +0 -1
  59. package/dist/ui/markdown-text.js +2 -3
  60. package/dist/ui/reasoning.aui.js +2 -3
  61. package/dist/ui/reasoning.d.ts +1 -1
  62. package/dist/ui/reasoning.js +6 -9
  63. package/dist/ui/surface.js +27 -8
  64. package/dist/ui/thread-list.aui.d.ts +2 -2
  65. package/dist/ui/thread-list.aui.js +18 -12
  66. package/dist/ui/tool-group.aui.js +2 -3
  67. package/dist/ui/tooltip-icon-button.js +1 -2
  68. package/dist/ui/tooltip.js +0 -1
  69. package/dist/ui/use-attachment-src.js +1 -2
  70. package/dist/ui/use-copy-to-clipboard.d.ts +1 -1
  71. package/dist/ui/use-copy-to-clipboard.js +1 -2
  72. package/dist/ui/utils.js +9 -3
  73. package/dist/use-next-message.js +7 -4
  74. package/dist/voice/types.js +0 -1
  75. package/dist/voice/use-voice.js +35 -13
  76. package/package.json +8 -4
  77. package/dist/assistant-attachments.js.map +0 -1
  78. package/dist/assistant-components.js.map +0 -1
  79. package/dist/assistant-runtime.js.map +0 -1
  80. package/dist/attachments.js.map +0 -1
  81. package/dist/client.js.map +0 -1
  82. package/dist/config.js.map +0 -1
  83. package/dist/default-chat.js.map +0 -7
  84. package/dist/errors.js.map +0 -1
  85. package/dist/index.js.map +0 -1
  86. package/dist/messages.js.map +0 -1
  87. package/dist/page-confirmation.js.map +0 -1
  88. package/dist/protocol-messages.js.map +0 -1
  89. package/dist/protocol-response.js.map +0 -1
  90. package/dist/react.js.map +0 -1
  91. package/dist/shared/errors.js.map +0 -1
  92. package/dist/shared/runtime-controller.js.map +0 -1
  93. package/dist/shared/runtime-execution.js.map +0 -1
  94. package/dist/shared/schema.js.map +0 -1
  95. package/dist/storage.js.map +0 -1
  96. package/dist/tool-result.js.map +0 -1
  97. package/dist/types.js.map +0 -1
  98. package/dist/ui/attachment.aui.js.map +0 -1
  99. package/dist/ui/avatar.js.map +0 -1
  100. package/dist/ui/button.js.map +0 -1
  101. package/dist/ui/code-block.js.map +0 -1
  102. package/dist/ui/collapsible.js.map +0 -1
  103. package/dist/ui/composer-voice.js.map +0 -1
  104. package/dist/ui/dialog.js.map +0 -1
  105. package/dist/ui/dropdown-menu.js.map +0 -1
  106. package/dist/ui/home-demo/action-bar.js.map +0 -1
  107. package/dist/ui/home-demo/composer.js.map +0 -1
  108. package/dist/ui/home-demo/greeting.js.map +0 -1
  109. package/dist/ui/home-demo/messages.js.map +0 -1
  110. package/dist/ui/home-demo/styles.js.map +0 -1
  111. package/dist/ui/home-demo/suggestions.js.map +0 -1
  112. package/dist/ui/home-demo/surfaces.js.map +0 -1
  113. package/dist/ui/home-demo/thread.js.map +0 -1
  114. package/dist/ui/home-demo/trace-line.js.map +0 -1
  115. package/dist/ui/home-demo/trace.js.map +0 -1
  116. package/dist/ui/home-demo/type.js.map +0 -1
  117. package/dist/ui/input.js.map +0 -1
  118. package/dist/ui/markdown-text.js.map +0 -1
  119. package/dist/ui/reasoning.aui.js.map +0 -1
  120. package/dist/ui/reasoning.js.map +0 -1
  121. package/dist/ui/surface.js.map +0 -1
  122. package/dist/ui/thread-list.aui.js.map +0 -1
  123. package/dist/ui/tool-group.aui.js.map +0 -1
  124. package/dist/ui/tooltip-icon-button.js.map +0 -1
  125. package/dist/ui/tooltip.js.map +0 -1
  126. package/dist/ui/use-attachment-src.js.map +0 -1
  127. package/dist/ui/use-copy-to-clipboard.js.map +0 -1
  128. package/dist/ui/utils.js.map +0 -1
  129. package/dist/use-next-message.js.map +0 -1
  130. package/dist/voice/types.js.map +0 -1
  131. package/dist/voice/use-voice.js.map +0 -1
@@ -1,32 +1,48 @@
1
1
  const types = {
2
- txt: "text/plain", md: "text/markdown", csv: "text/csv", json: "application/json",
3
- png: "image/png", jpg: "image/jpeg", jpeg: "image/jpeg", webp: "image/webp",
2
+ txt: "text/plain",
3
+ md: "text/markdown",
4
+ csv: "text/csv",
5
+ json: "application/json",
6
+ png: "image/png",
7
+ jpg: "image/jpeg",
8
+ jpeg: "image/jpeg",
9
+ webp: "image/webp",
4
10
  };
5
11
  export const attachmentAccept = ".txt,.md,.csv,.json,.png,.jpg,.jpeg,.webp";
6
12
  export const attachmentContent = (attachment) => Array.isArray(attachment.content) ? attachment.content : [attachment.content];
7
13
  export function validateAttachment(file, options) {
8
- if (options.maxSizeBytes !== undefined && (!Number.isFinite(options.maxSizeBytes) || options.maxSizeBytes <= 0))
14
+ if (options.maxSizeBytes !== undefined &&
15
+ (!Number.isFinite(options.maxSizeBytes) || options.maxSizeBytes <= 0))
9
16
  throw new Error("附件大小限制必须是正数。");
10
17
  if (file.size > (options.maxSizeBytes ?? 5 * 1024 * 1024))
11
18
  throw new Error(`文件过大:${file.name}`);
12
19
  const extension = file.name.split(".").at(-1)?.toLowerCase() ?? "";
13
20
  const mime = file.type || types[extension] || "";
14
- const accepted = (options.accept ?? attachmentAccept).split(",").map((part) => part.trim().toLowerCase());
15
- if (!accepted.some((part) => part === "*" || part === `.${extension}` || part === mime
16
- || part.endsWith("/*") && mime.startsWith(part.slice(0, -1))))
21
+ const accepted = (options.accept ?? attachmentAccept)
22
+ .split(",")
23
+ .map((part) => part.trim().toLowerCase());
24
+ if (!accepted.some((part) => part === "*" ||
25
+ part === `.${extension}` ||
26
+ part === mime ||
27
+ (part.endsWith("/*") && mime.startsWith(part.slice(0, -1)))))
17
28
  throw new Error(`不接受此文件:${file.name}`);
18
29
  }
19
30
  export async function readAttachment(file, options) {
20
- if (options.maxSizeBytes !== undefined && (!Number.isFinite(options.maxSizeBytes) || options.maxSizeBytes <= 0))
31
+ if (options.maxSizeBytes !== undefined &&
32
+ (!Number.isFinite(options.maxSizeBytes) || options.maxSizeBytes <= 0))
21
33
  throw new Error("附件大小限制必须是正数。");
22
34
  const extension = file.name.split(".").at(-1)?.toLowerCase() ?? "";
23
35
  const mime = types[extension];
24
- if (!mime || (file.type && file.type !== mime && !(extension === "md" && file.type === "text/plain"))) {
36
+ if (!mime ||
37
+ (file.type && file.type !== mime && !(extension === "md" && file.type === "text/plain"))) {
25
38
  throw new Error(`不支持文件类型:${file.name}`);
26
39
  }
27
- const accepted = (options.accept ?? attachmentAccept).split(",").map((part) => part.trim().toLowerCase());
28
- if (!accepted.some((part) => part === `.${extension}` || part === mime
29
- || part.endsWith("/*") && mime.startsWith(part.slice(0, -1)))) {
40
+ const accepted = (options.accept ?? attachmentAccept)
41
+ .split(",")
42
+ .map((part) => part.trim().toLowerCase());
43
+ if (!accepted.some((part) => part === `.${extension}` ||
44
+ part === mime ||
45
+ (part.endsWith("/*") && mime.startsWith(part.slice(0, -1))))) {
30
46
  throw new Error(`不接受此文件:${file.name}`);
31
47
  }
32
48
  if (file.size > (options.maxSizeBytes ?? 5 * 1024 * 1024))
@@ -37,9 +53,15 @@ export async function readAttachment(file, options) {
37
53
  return { id, name: file.name, content: { type: "text", text: `附件 ${file.name}\n${value}` } };
38
54
  }
39
55
  const preview = await read(file, true);
40
- return { id, name: file.name, preview, content: {
41
- type: "image", source: { type: "data", value: preview.slice(preview.indexOf(",") + 1), mimeType: mime },
42
- } };
56
+ return {
57
+ id,
58
+ name: file.name,
59
+ preview,
60
+ content: {
61
+ type: "image",
62
+ source: { type: "data", value: preview.slice(preview.indexOf(",") + 1), mimeType: mime },
63
+ },
64
+ };
43
65
  }
44
66
  function read(file, image) {
45
67
  return new Promise((resolve, reject) => {
@@ -52,4 +74,3 @@ function read(file, image) {
52
74
  reader.readAsText(file);
53
75
  });
54
76
  }
55
- //# sourceMappingURL=attachments.js.map