@nexface/chat 0.1.13-alpha.4 → 0.1.13-alpha.5

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 (58) hide show
  1. package/dist/assistant-attachments.js +60 -16
  2. package/dist/assistant-components.d.ts +3 -3
  3. package/dist/assistant-components.js +77 -28
  4. package/dist/assistant-runtime.d.ts +1 -1
  5. package/dist/assistant-runtime.js +100 -42
  6. package/dist/attachments.js +36 -14
  7. package/dist/client.js +312 -72
  8. package/dist/config.js +4 -4
  9. package/dist/default-chat.d.ts +1 -1
  10. package/dist/default-chat.js +2102 -727
  11. package/dist/errors.js +55 -17
  12. package/dist/page-confirmation.js +3 -3
  13. package/dist/protocol-messages.js +290 -65
  14. package/dist/protocol-response.js +38 -17
  15. package/dist/react.js +146 -49
  16. package/dist/shared/errors.d.ts +1 -1
  17. package/dist/shared/schema.js +45 -18
  18. package/dist/storage.js +130 -52
  19. package/dist/styles.css +99 -20
  20. package/dist/tool-result.js +7 -2
  21. package/dist/ui/attachment.aui.d.ts +1 -1
  22. package/dist/ui/attachment.aui.js +16 -19
  23. package/dist/ui/code-block.js +2 -2
  24. package/dist/ui/collapsible.js +2 -2
  25. package/dist/ui/composer-voice.js +3 -1
  26. package/dist/ui/dialog.d.ts +1 -1
  27. package/dist/ui/dialog.js +9 -3
  28. package/dist/ui/dropdown-menu.js +2 -2
  29. package/dist/ui/home-demo/composer.js +7 -3
  30. package/dist/ui/home-demo/greeting.d.ts +1 -1
  31. package/dist/ui/home-demo/greeting.js +1 -1
  32. package/dist/ui/home-demo/messages.d.ts +1 -1
  33. package/dist/ui/home-demo/messages.js +4 -4
  34. package/dist/ui/home-demo/suggestions.d.ts +1 -1
  35. package/dist/ui/home-demo/suggestions.js +5 -2
  36. package/dist/ui/home-demo/surfaces.js +3 -1
  37. package/dist/ui/home-demo/thread.d.ts +1 -1
  38. package/dist/ui/home-demo/thread.js +1 -1
  39. package/dist/ui/home-demo/trace-line.d.ts +1 -1
  40. package/dist/ui/home-demo/trace-line.js +2 -2
  41. package/dist/ui/home-demo/trace.d.ts +1 -1
  42. package/dist/ui/home-demo/trace.js +28 -8
  43. package/dist/ui/markdown-text.js +2 -2
  44. package/dist/ui/reasoning.aui.js +2 -2
  45. package/dist/ui/reasoning.d.ts +1 -1
  46. package/dist/ui/reasoning.js +6 -8
  47. package/dist/ui/surface.js +27 -7
  48. package/dist/ui/thread-list.aui.d.ts +2 -2
  49. package/dist/ui/thread-list.aui.js +18 -11
  50. package/dist/ui/tool-group.aui.js +2 -2
  51. package/dist/ui/tooltip-icon-button.js +1 -1
  52. package/dist/ui/use-attachment-src.js +1 -1
  53. package/dist/ui/use-copy-to-clipboard.d.ts +1 -1
  54. package/dist/ui/use-copy-to-clipboard.js +1 -1
  55. package/dist/ui/utils.js +9 -2
  56. package/dist/use-next-message.js +7 -3
  57. package/dist/voice/use-voice.js +35 -12
  58. package/package.json +3 -3
@@ -7,7 +7,10 @@ export function useVoiceInput(options) {
7
7
  const [status, setStatus] = useState("idle");
8
8
  const owner = useRef(undefined);
9
9
  const generation = useRef(0);
10
- const cancel = () => { owner.current?.(); generation.current++; };
10
+ const cancel = () => {
11
+ owner.current?.();
12
+ generation.current++;
13
+ };
11
14
  const dictation = useMemo(() => ({
12
15
  disableInputDuringDictation: true,
13
16
  listen() {
@@ -32,10 +35,14 @@ export function useVoiceInput(options) {
32
35
  callback(value);
33
36
  };
34
37
  const valid = () => !ended && generation.current === token;
35
- const restore = () => { try {
36
- composer.setText(original);
37
- }
38
- catch { /* A disposed Session no longer owns a composer. */ } };
38
+ const restore = () => {
39
+ try {
40
+ composer.setText(original);
41
+ }
42
+ catch {
43
+ /* A disposed Session no longer owns a composer. */
44
+ }
45
+ };
39
46
  const finish = (reason) => {
40
47
  if (!valid())
41
48
  return;
@@ -63,14 +70,16 @@ export function useVoiceInput(options) {
63
70
  try {
64
71
  input?.cancel();
65
72
  }
66
- catch { /* Cancellation still restores the draft. */ }
73
+ catch {
74
+ /* Cancellation still restores the draft. */
75
+ }
67
76
  };
68
77
  const session = {
69
78
  get status() {
70
79
  // Reuse assistant-ui's status polling, including sources that emit no end event.
71
80
  if (!ended && input?.status.type === "ended")
72
81
  queueMicrotask(complete);
73
- return ended ? status : input?.status ?? status;
82
+ return ended ? status : (input?.status ?? status);
74
83
  },
75
84
  stop: async () => {
76
85
  if (!valid())
@@ -86,9 +95,18 @@ export function useVoiceInput(options) {
86
95
  }
87
96
  },
88
97
  cancel: terminate,
89
- onSpeechStart(callback) { starts.add(callback); return () => starts.delete(callback); },
90
- onSpeech(callback) { speeches.add(callback); return () => speeches.delete(callback); },
91
- onSpeechEnd(callback) { ends.add(callback); return () => ends.delete(callback); },
98
+ onSpeechStart(callback) {
99
+ starts.add(callback);
100
+ return () => starts.delete(callback);
101
+ },
102
+ onSpeech(callback) {
103
+ speeches.add(callback);
104
+ return () => speeches.delete(callback);
105
+ },
106
+ onSpeechEnd(callback) {
107
+ ends.add(callback);
108
+ return () => ends.delete(callback);
109
+ },
92
110
  };
93
111
  owner.current = terminate;
94
112
  config.notice("");
@@ -101,7 +119,9 @@ export function useVoiceInput(options) {
101
119
  try {
102
120
  input?.cancel();
103
121
  }
104
- catch { /* The source already failed. */ }
122
+ catch {
123
+ /* The source already failed. */
124
+ }
105
125
  if (!cancelled)
106
126
  latest.current.notice(error instanceof Error ? error.message : "语音输入失败,请重试。");
107
127
  };
@@ -152,5 +172,8 @@ export function useVoiceInput(options) {
152
172
  cancel();
153
173
  }, [options.active, options.open, options.blocked, enabled]);
154
174
  useLayoutEffect(() => () => cancel(), [source, options.sessionId]);
155
- return { dictation: enabled ? dictation : undefined, state: { status, supported: enabled, cancel } };
175
+ return {
176
+ dictation: enabled ? dictation : undefined,
177
+ state: { status, supported: enabled, cancel },
178
+ };
156
179
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nexface/chat",
3
- "version": "0.1.13-alpha.4",
3
+ "version": "0.1.13-alpha.5",
4
4
  "type": "module",
5
5
  "sideEffects": [
6
6
  "./dist/index.js",
@@ -18,7 +18,7 @@
18
18
  },
19
19
  "dependencies": {
20
20
  "@ag-ui/core": "0.0.59",
21
- "@nexface/agent": "0.1.13-alpha.4",
21
+ "@nexface/agent": "0.1.13-alpha.5",
22
22
  "class-variance-authority": "0.7.1",
23
23
  "clsx": "2.1.1",
24
24
  "fast-json-patch": "3.1.1",
@@ -27,7 +27,7 @@
27
27
  "use-sync-external-store": "1.7.0"
28
28
  },
29
29
  "peerDependencies": {
30
- "@nexface/tools": "0.1.13-alpha.4",
30
+ "@nexface/tools": "0.1.13-alpha.5",
31
31
  "react": ">=17",
32
32
  "react-dom": ">=17"
33
33
  },