@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.
- package/dist/assistant-attachments.js +60 -16
- package/dist/assistant-components.d.ts +3 -3
- package/dist/assistant-components.js +77 -28
- package/dist/assistant-runtime.d.ts +1 -1
- package/dist/assistant-runtime.js +100 -42
- package/dist/attachments.js +36 -14
- package/dist/client.js +312 -72
- package/dist/config.js +4 -4
- package/dist/default-chat.d.ts +1 -1
- package/dist/default-chat.js +2102 -727
- package/dist/errors.js +55 -17
- package/dist/page-confirmation.js +3 -3
- package/dist/protocol-messages.js +290 -65
- package/dist/protocol-response.js +38 -17
- package/dist/react.js +146 -49
- package/dist/shared/errors.d.ts +1 -1
- package/dist/shared/schema.js +45 -18
- package/dist/storage.js +130 -52
- package/dist/styles.css +99 -20
- package/dist/tool-result.js +7 -2
- package/dist/ui/attachment.aui.d.ts +1 -1
- package/dist/ui/attachment.aui.js +16 -19
- package/dist/ui/code-block.js +2 -2
- package/dist/ui/collapsible.js +2 -2
- package/dist/ui/composer-voice.js +3 -1
- package/dist/ui/dialog.d.ts +1 -1
- package/dist/ui/dialog.js +9 -3
- package/dist/ui/dropdown-menu.js +2 -2
- package/dist/ui/home-demo/composer.js +7 -3
- package/dist/ui/home-demo/greeting.d.ts +1 -1
- package/dist/ui/home-demo/greeting.js +1 -1
- package/dist/ui/home-demo/messages.d.ts +1 -1
- package/dist/ui/home-demo/messages.js +4 -4
- package/dist/ui/home-demo/suggestions.d.ts +1 -1
- package/dist/ui/home-demo/suggestions.js +5 -2
- package/dist/ui/home-demo/surfaces.js +3 -1
- package/dist/ui/home-demo/thread.d.ts +1 -1
- package/dist/ui/home-demo/thread.js +1 -1
- package/dist/ui/home-demo/trace-line.d.ts +1 -1
- package/dist/ui/home-demo/trace-line.js +2 -2
- package/dist/ui/home-demo/trace.d.ts +1 -1
- package/dist/ui/home-demo/trace.js +28 -8
- package/dist/ui/markdown-text.js +2 -2
- package/dist/ui/reasoning.aui.js +2 -2
- package/dist/ui/reasoning.d.ts +1 -1
- package/dist/ui/reasoning.js +6 -8
- package/dist/ui/surface.js +27 -7
- package/dist/ui/thread-list.aui.d.ts +2 -2
- package/dist/ui/thread-list.aui.js +18 -11
- package/dist/ui/tool-group.aui.js +2 -2
- package/dist/ui/tooltip-icon-button.js +1 -1
- package/dist/ui/use-attachment-src.js +1 -1
- package/dist/ui/use-copy-to-clipboard.d.ts +1 -1
- package/dist/ui/use-copy-to-clipboard.js +1 -1
- package/dist/ui/utils.js +9 -2
- package/dist/use-next-message.js +7 -3
- package/dist/voice/use-voice.js +35 -12
- package/package.json +3 -3
package/dist/voice/use-voice.js
CHANGED
|
@@ -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 = () => {
|
|
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 = () => {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
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 {
|
|
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) {
|
|
90
|
-
|
|
91
|
-
|
|
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 {
|
|
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 {
|
|
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.
|
|
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.
|
|
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.
|
|
30
|
+
"@nexface/tools": "0.1.13-alpha.5",
|
|
31
31
|
"react": ">=17",
|
|
32
32
|
"react-dom": ">=17"
|
|
33
33
|
},
|