@adminforth/agent 1.38.0 → 1.39.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/build.log CHANGED
@@ -18,8 +18,6 @@ custom/composables/
18
18
  custom/composables/useAgentAudio.ts
19
19
  custom/composables/useAgentStore.ts
20
20
  custom/composables/useAgentTransitions.ts
21
- custom/composables/agentAudio/
22
- custom/composables/agentAudio/agent-processing.mp3
23
21
  custom/composables/agentStore/
24
22
  custom/composables/agentStore/constants.ts
25
23
  custom/composables/agentStore/pageContext.ts
@@ -41,6 +39,9 @@ custom/incremark_code_renderers/IncremarkShikiCodeBlock.vue
41
39
  custom/incremark_code_renderers/incremarkCodeHighlight.ts
42
40
  custom/incremark_code_renderers/incremarkRenderer.ts
43
41
  custom/incremark_code_renderers/renderIncremarkMarkdown.ts
42
+ custom/public/
43
+ custom/public/agentAudio/
44
+ custom/public/agentAudio/agent-processing.mp3
44
45
  custom/skills/
45
46
  custom/skills/analyze_data/
46
47
  custom/skills/analyze_data/SKILL.md
@@ -57,5 +58,5 @@ custom/speech_recognition_frontend/voiceActivityDetection.ts
57
58
  custom/speech_recognition_frontend/types/
58
59
  custom/speech_recognition_frontend/types/voice-activity-detection.d.ts
59
60
 
60
- sent 1,655,972 bytes received 856 bytes 3,313,656.00 bytes/sec
61
- total size is 1,652,100 speedup is 1.00
61
+ sent 1,656,214 bytes received 860 bytes 3,314,148.00 bytes/sec
62
+ total size is 1,652,352 speedup is 1.00
@@ -119,8 +119,8 @@
119
119
  }"
120
120
  >
121
121
  <div
122
- class="w-full border rounded-lg pb-8 dark:bg-gray-700"
123
- :class="agentStore.isAudioChatMode ? 'border-none mt-8' : 'border'"
122
+ class="w-full border rounded-lg pb-8"
123
+ :class="agentStore.isAudioChatMode ? 'border-none mt-8' : 'border dark:bg-gray-700'"
124
124
  >
125
125
  <textarea
126
126
  v-if="!agentStore.isAudioChatMode"
@@ -14,28 +14,36 @@ type StreamingAudioState = {
14
14
  isDone: boolean;
15
15
  };
16
16
 
17
- const standByAudio = new Audio('./agentAudio/agent-processing.mp3');
17
+ let standByAudio: HTMLAudioElement | null = null;
18
18
 
19
19
  function playStandByAudio() {
20
+ if (!standByAudio) {
21
+ standByAudio = new Audio(`/plugins/AdminForthAgentPlugin/agentAudio/agent-processing.mp3`);
22
+ standByAudio.addEventListener('ended', () => {
23
+ if (!standByAudio.paused) {
24
+ restartStandByAudio();
25
+ }
26
+ });
27
+ }
20
28
  standByAudio.currentTime = 0;
21
29
  standByAudio.play()
22
30
  }
23
31
 
24
32
  function stopStandByAudio() {
33
+ if (!standByAudio) {
34
+ return;
35
+ }
25
36
  standByAudio.pause();
26
37
  standByAudio.currentTime = 0;
27
38
  }
28
39
 
29
40
  function restartStandByAudio() {
30
- standByAudio.currentTime = 0;
41
+ if (standByAudio) {
42
+ standByAudio.currentTime = 0;
43
+ }
31
44
  playStandByAudio();
32
45
  }
33
46
 
34
- standByAudio.addEventListener('ended', () => {
35
- if (!standByAudio.paused) {
36
- restartStandByAudio();
37
- }
38
- });
39
47
 
40
48
  export const useAgentAudio = defineStore('agentAudio', () => {
41
49
  const agentStore = useAgentStore();
@@ -164,7 +172,7 @@ export const useAgentAudio = defineStore('agentAudio', () => {
164
172
  }
165
173
 
166
174
  if (event.type === 'speech-response') {
167
- // stopStandByAudio();
175
+ stopStandByAudio();
168
176
  agentStore.setCurrentChatStatus('ready');
169
177
  agentStore.addAgentMessage(event.data.response.text);
170
178
  agentAudioMode.value = 'playingAgentResponse';
@@ -189,7 +197,7 @@ export const useAgentAudio = defineStore('agentAudio', () => {
189
197
  }
190
198
 
191
199
  if (event.type === 'data-tool-call') {
192
- // playStandByAudio();
200
+ playStandByAudio();
193
201
  agentStore.addDataToolCallMessage(event.data);
194
202
  }
195
203
  }
@@ -330,6 +338,7 @@ export const useAgentAudio = defineStore('agentAudio', () => {
330
338
  }
331
339
 
332
340
  function stopCurrentAudioPlayback(dontResetMode = false) {
341
+ stopStandByAudio();
333
342
  bufferedAudioChunks = [];
334
343
  bufferedAudioMimeType = 'audio/mpeg';
335
344
  detachStreamingAudio();
@@ -91,8 +91,10 @@ async function onStartRecording() {
91
91
  microphoneButtonMode.value = 'calibrating';
92
92
  await requestMicAndStartVAD(saidSomething, stopRecording, onAnySound);
93
93
  setTimeout(() => {
94
- microphoneButtonMode.value = 'listen';
95
- agentAudio.playBeep(1000);
94
+ if (isAudioChatMode.value) {
95
+ microphoneButtonMode.value = 'listen';
96
+ agentAudio.playBeep(1000);
97
+ }
96
98
  }, CALIBRATION_DURATION);
97
99
  }
98
100
 
@@ -119,8 +119,8 @@
119
119
  }"
120
120
  >
121
121
  <div
122
- class="w-full border rounded-lg pb-8 dark:bg-gray-700"
123
- :class="agentStore.isAudioChatMode ? 'border-none mt-8' : 'border'"
122
+ class="w-full border rounded-lg pb-8"
123
+ :class="agentStore.isAudioChatMode ? 'border-none mt-8' : 'border dark:bg-gray-700'"
124
124
  >
125
125
  <textarea
126
126
  v-if="!agentStore.isAudioChatMode"
@@ -14,28 +14,36 @@ type StreamingAudioState = {
14
14
  isDone: boolean;
15
15
  };
16
16
 
17
- const standByAudio = new Audio('./agentAudio/agent-processing.mp3');
17
+ let standByAudio: HTMLAudioElement | null = null;
18
18
 
19
19
  function playStandByAudio() {
20
+ if (!standByAudio) {
21
+ standByAudio = new Audio(`/plugins/AdminForthAgentPlugin/agentAudio/agent-processing.mp3`);
22
+ standByAudio.addEventListener('ended', () => {
23
+ if (!standByAudio.paused) {
24
+ restartStandByAudio();
25
+ }
26
+ });
27
+ }
20
28
  standByAudio.currentTime = 0;
21
29
  standByAudio.play()
22
30
  }
23
31
 
24
32
  function stopStandByAudio() {
33
+ if (!standByAudio) {
34
+ return;
35
+ }
25
36
  standByAudio.pause();
26
37
  standByAudio.currentTime = 0;
27
38
  }
28
39
 
29
40
  function restartStandByAudio() {
30
- standByAudio.currentTime = 0;
41
+ if (standByAudio) {
42
+ standByAudio.currentTime = 0;
43
+ }
31
44
  playStandByAudio();
32
45
  }
33
46
 
34
- standByAudio.addEventListener('ended', () => {
35
- if (!standByAudio.paused) {
36
- restartStandByAudio();
37
- }
38
- });
39
47
 
40
48
  export const useAgentAudio = defineStore('agentAudio', () => {
41
49
  const agentStore = useAgentStore();
@@ -164,7 +172,7 @@ export const useAgentAudio = defineStore('agentAudio', () => {
164
172
  }
165
173
 
166
174
  if (event.type === 'speech-response') {
167
- // stopStandByAudio();
175
+ stopStandByAudio();
168
176
  agentStore.setCurrentChatStatus('ready');
169
177
  agentStore.addAgentMessage(event.data.response.text);
170
178
  agentAudioMode.value = 'playingAgentResponse';
@@ -189,7 +197,7 @@ export const useAgentAudio = defineStore('agentAudio', () => {
189
197
  }
190
198
 
191
199
  if (event.type === 'data-tool-call') {
192
- // playStandByAudio();
200
+ playStandByAudio();
193
201
  agentStore.addDataToolCallMessage(event.data);
194
202
  }
195
203
  }
@@ -330,6 +338,7 @@ export const useAgentAudio = defineStore('agentAudio', () => {
330
338
  }
331
339
 
332
340
  function stopCurrentAudioPlayback(dontResetMode = false) {
341
+ stopStandByAudio();
333
342
  bufferedAudioChunks = [];
334
343
  bufferedAudioMimeType = 'audio/mpeg';
335
344
  detachStreamingAudio();
@@ -91,8 +91,10 @@ async function onStartRecording() {
91
91
  microphoneButtonMode.value = 'calibrating';
92
92
  await requestMicAndStartVAD(saidSomething, stopRecording, onAnySound);
93
93
  setTimeout(() => {
94
- microphoneButtonMode.value = 'listen';
95
- agentAudio.playBeep(1000);
94
+ if (isAudioChatMode.value) {
95
+ microphoneButtonMode.value = 'listen';
96
+ agentAudio.playBeep(1000);
97
+ }
96
98
  }, CALIBRATION_DURATION);
97
99
  }
98
100
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adminforth/agent",
3
- "version": "1.38.0",
3
+ "version": "1.39.1",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "type": "module",