@adminforth/agent 1.48.0 → 1.48.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
|
@@ -62,5 +62,5 @@ custom/speech_recognition_frontend/voiceActivityDetection.ts
|
|
|
62
62
|
custom/speech_recognition_frontend/types/
|
|
63
63
|
custom/speech_recognition_frontend/types/voice-activity-detection.d.ts
|
|
64
64
|
|
|
65
|
-
sent 1,
|
|
66
|
-
total size is 1,
|
|
65
|
+
sent 1,668,700 bytes received 905 bytes 3,339,210.00 bytes/sec
|
|
66
|
+
total size is 1,664,547 speedup is 1.00
|
|
@@ -118,10 +118,13 @@ const THRESHOLD_TO_SHOW_BUTTON = 10;
|
|
|
118
118
|
let messageResizeObserver: ResizeObserver | null = null;
|
|
119
119
|
let observedLastUserMessageElement: HTMLElement | null = null;
|
|
120
120
|
let observedLastAgentMessageElement: HTMLElement | null = null;
|
|
121
|
+
let updateSpacerFrameId: number | null = null;
|
|
122
|
+
let pendingSpacerUpdate: Promise<void> | null = null;
|
|
123
|
+
let spacerUpdateQueued = false;
|
|
121
124
|
|
|
122
125
|
onMounted(async () => {
|
|
123
126
|
messageResizeObserver = new ResizeObserver(() => {
|
|
124
|
-
|
|
127
|
+
scheduleSpacerHeightUpdate();
|
|
125
128
|
});
|
|
126
129
|
|
|
127
130
|
await import('@incremark/theme/styles.css')
|
|
@@ -136,6 +139,10 @@ onUnmounted(() => {
|
|
|
136
139
|
|
|
137
140
|
stopObservingLastMessages();
|
|
138
141
|
messageResizeObserver?.disconnect();
|
|
142
|
+
if (updateSpacerFrameId !== null) {
|
|
143
|
+
cancelAnimationFrame(updateSpacerFrameId);
|
|
144
|
+
updateSpacerFrameId = null;
|
|
145
|
+
}
|
|
139
146
|
agentStore.stopPlaceholderAnimation();
|
|
140
147
|
});
|
|
141
148
|
|
|
@@ -221,6 +228,30 @@ async function updateSpacerHeight() {
|
|
|
221
228
|
spacerHeight.value = Math.max(0, clientHeight - (lastUserMessageHeight + MASK_HEIGHT + lastAgentMessageHeight));
|
|
222
229
|
}
|
|
223
230
|
|
|
231
|
+
function scheduleSpacerHeightUpdate() {
|
|
232
|
+
spacerUpdateQueued = true;
|
|
233
|
+
|
|
234
|
+
if (updateSpacerFrameId !== null) {
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
updateSpacerFrameId = requestAnimationFrame(() => {
|
|
239
|
+
updateSpacerFrameId = null;
|
|
240
|
+
|
|
241
|
+
if (pendingSpacerUpdate) {
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
spacerUpdateQueued = false;
|
|
246
|
+
pendingSpacerUpdate = updateSpacerHeight().finally(() => {
|
|
247
|
+
pendingSpacerUpdate = null;
|
|
248
|
+
if (spacerUpdateQueued) {
|
|
249
|
+
scheduleSpacerHeightUpdate();
|
|
250
|
+
}
|
|
251
|
+
});
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
|
|
224
255
|
function stopObservingLastMessages() {
|
|
225
256
|
if (!messageResizeObserver) {
|
|
226
257
|
return;
|
|
@@ -285,4 +316,4 @@ function recalculateScroll() {
|
|
|
285
316
|
}
|
|
286
317
|
}
|
|
287
318
|
|
|
288
|
-
</script>
|
|
319
|
+
</script>
|
|
@@ -118,10 +118,13 @@ const THRESHOLD_TO_SHOW_BUTTON = 10;
|
|
|
118
118
|
let messageResizeObserver: ResizeObserver | null = null;
|
|
119
119
|
let observedLastUserMessageElement: HTMLElement | null = null;
|
|
120
120
|
let observedLastAgentMessageElement: HTMLElement | null = null;
|
|
121
|
+
let updateSpacerFrameId: number | null = null;
|
|
122
|
+
let pendingSpacerUpdate: Promise<void> | null = null;
|
|
123
|
+
let spacerUpdateQueued = false;
|
|
121
124
|
|
|
122
125
|
onMounted(async () => {
|
|
123
126
|
messageResizeObserver = new ResizeObserver(() => {
|
|
124
|
-
|
|
127
|
+
scheduleSpacerHeightUpdate();
|
|
125
128
|
});
|
|
126
129
|
|
|
127
130
|
await import('@incremark/theme/styles.css')
|
|
@@ -136,6 +139,10 @@ onUnmounted(() => {
|
|
|
136
139
|
|
|
137
140
|
stopObservingLastMessages();
|
|
138
141
|
messageResizeObserver?.disconnect();
|
|
142
|
+
if (updateSpacerFrameId !== null) {
|
|
143
|
+
cancelAnimationFrame(updateSpacerFrameId);
|
|
144
|
+
updateSpacerFrameId = null;
|
|
145
|
+
}
|
|
139
146
|
agentStore.stopPlaceholderAnimation();
|
|
140
147
|
});
|
|
141
148
|
|
|
@@ -221,6 +228,30 @@ async function updateSpacerHeight() {
|
|
|
221
228
|
spacerHeight.value = Math.max(0, clientHeight - (lastUserMessageHeight + MASK_HEIGHT + lastAgentMessageHeight));
|
|
222
229
|
}
|
|
223
230
|
|
|
231
|
+
function scheduleSpacerHeightUpdate() {
|
|
232
|
+
spacerUpdateQueued = true;
|
|
233
|
+
|
|
234
|
+
if (updateSpacerFrameId !== null) {
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
updateSpacerFrameId = requestAnimationFrame(() => {
|
|
239
|
+
updateSpacerFrameId = null;
|
|
240
|
+
|
|
241
|
+
if (pendingSpacerUpdate) {
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
spacerUpdateQueued = false;
|
|
246
|
+
pendingSpacerUpdate = updateSpacerHeight().finally(() => {
|
|
247
|
+
pendingSpacerUpdate = null;
|
|
248
|
+
if (spacerUpdateQueued) {
|
|
249
|
+
scheduleSpacerHeightUpdate();
|
|
250
|
+
}
|
|
251
|
+
});
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
|
|
224
255
|
function stopObservingLastMessages() {
|
|
225
256
|
if (!messageResizeObserver) {
|
|
226
257
|
return;
|
|
@@ -285,4 +316,4 @@ function recalculateScroll() {
|
|
|
285
316
|
}
|
|
286
317
|
}
|
|
287
318
|
|
|
288
|
-
</script>
|
|
319
|
+
</script>
|
|
@@ -11,6 +11,7 @@ import { randomUUID } from "crypto";
|
|
|
11
11
|
function createAgentEventStream(res, options = {}) {
|
|
12
12
|
let isStreamClosed = false;
|
|
13
13
|
let activeBlock = null;
|
|
14
|
+
const isAiUiMessageStream = options.vercelAiUiMessageStream === true;
|
|
14
15
|
res.writeHead(200, Object.assign({ "Content-Type": "text/event-stream", "Cache-Control": "no-cache", "Connection": "keep-alive" }, (options.vercelAiUiMessageStream
|
|
15
16
|
? { "x-vercel-ai-ui-message-stream": "v1" }
|
|
16
17
|
: {})));
|
|
@@ -89,7 +90,7 @@ function createAgentEventStream(res, options = {}) {
|
|
|
89
90
|
},
|
|
90
91
|
transcript(text, language) {
|
|
91
92
|
stream.send({
|
|
92
|
-
type: "transcript",
|
|
93
|
+
type: isAiUiMessageStream ? "data-transcript" : "transcript",
|
|
93
94
|
data: {
|
|
94
95
|
text,
|
|
95
96
|
language,
|
|
@@ -98,7 +99,7 @@ function createAgentEventStream(res, options = {}) {
|
|
|
98
99
|
},
|
|
99
100
|
response(text, sessionId, turnId) {
|
|
100
101
|
stream.send({
|
|
101
|
-
type: "response",
|
|
102
|
+
type: isAiUiMessageStream ? "data-response" : "response",
|
|
102
103
|
data: {
|
|
103
104
|
text,
|
|
104
105
|
sessionId,
|
|
@@ -108,7 +109,7 @@ function createAgentEventStream(res, options = {}) {
|
|
|
108
109
|
},
|
|
109
110
|
speechResponse(transcript, response, sessionId, turnId) {
|
|
110
111
|
stream.send({
|
|
111
|
-
type: "speech-response",
|
|
112
|
+
type: isAiUiMessageStream ? "data-speech-response" : "speech-response",
|
|
112
113
|
data: {
|
|
113
114
|
transcript,
|
|
114
115
|
response,
|
|
@@ -119,7 +120,7 @@ function createAgentEventStream(res, options = {}) {
|
|
|
119
120
|
},
|
|
120
121
|
audioStart(mimeType, format, sampleRate, channelCount, bitsPerSample) {
|
|
121
122
|
stream.send({
|
|
122
|
-
type: "audio-start",
|
|
123
|
+
type: isAiUiMessageStream ? "data-audio-start" : "audio-start",
|
|
123
124
|
data: {
|
|
124
125
|
mimeType,
|
|
125
126
|
format,
|
|
@@ -131,22 +132,25 @@ function createAgentEventStream(res, options = {}) {
|
|
|
131
132
|
},
|
|
132
133
|
audioDelta(value) {
|
|
133
134
|
stream.send({
|
|
134
|
-
type: "audio-delta",
|
|
135
|
+
type: isAiUiMessageStream ? "data-audio-delta" : "audio-delta",
|
|
135
136
|
data: {
|
|
136
137
|
base64: Buffer.from(value).toString("base64"),
|
|
137
138
|
},
|
|
138
139
|
});
|
|
139
140
|
},
|
|
140
141
|
audioDone() {
|
|
141
|
-
stream.send({
|
|
142
|
-
type: "audio-done",
|
|
143
|
-
});
|
|
142
|
+
stream.send(Object.assign({ type: isAiUiMessageStream ? "data-audio-done" : "audio-done" }, (isAiUiMessageStream ? { data: {} } : {})));
|
|
144
143
|
},
|
|
145
144
|
error(error) {
|
|
146
|
-
stream.send(
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
145
|
+
stream.send(isAiUiMessageStream
|
|
146
|
+
? {
|
|
147
|
+
type: "error",
|
|
148
|
+
errorText: error,
|
|
149
|
+
}
|
|
150
|
+
: {
|
|
151
|
+
type: "error",
|
|
152
|
+
error,
|
|
153
|
+
});
|
|
150
154
|
},
|
|
151
155
|
end() {
|
|
152
156
|
if (isStreamClosed || res.writableEnded || res.destroyed) {
|
package/package.json
CHANGED
|
@@ -22,6 +22,7 @@ function createAgentEventStream(
|
|
|
22
22
|
) {
|
|
23
23
|
let isStreamClosed = false;
|
|
24
24
|
let activeBlock: { type: "text" | "reasoning"; id: string } | null = null;
|
|
25
|
+
const isAiUiMessageStream = options.vercelAiUiMessageStream === true;
|
|
25
26
|
|
|
26
27
|
res.writeHead(200, {
|
|
27
28
|
"Content-Type": "text/event-stream",
|
|
@@ -124,7 +125,7 @@ function createAgentEventStream(
|
|
|
124
125
|
|
|
125
126
|
transcript(text: string, language?: string) {
|
|
126
127
|
stream.send({
|
|
127
|
-
type: "transcript",
|
|
128
|
+
type: isAiUiMessageStream ? "data-transcript" : "transcript",
|
|
128
129
|
data: {
|
|
129
130
|
text,
|
|
130
131
|
language,
|
|
@@ -134,7 +135,7 @@ function createAgentEventStream(
|
|
|
134
135
|
|
|
135
136
|
response(text: string, sessionId: string, turnId: string) {
|
|
136
137
|
stream.send({
|
|
137
|
-
type: "response",
|
|
138
|
+
type: isAiUiMessageStream ? "data-response" : "response",
|
|
138
139
|
data: {
|
|
139
140
|
text,
|
|
140
141
|
sessionId,
|
|
@@ -150,7 +151,7 @@ function createAgentEventStream(
|
|
|
150
151
|
turnId: string,
|
|
151
152
|
) {
|
|
152
153
|
stream.send({
|
|
153
|
-
type: "speech-response",
|
|
154
|
+
type: isAiUiMessageStream ? "data-speech-response" : "speech-response",
|
|
154
155
|
data: {
|
|
155
156
|
transcript,
|
|
156
157
|
response,
|
|
@@ -168,7 +169,7 @@ function createAgentEventStream(
|
|
|
168
169
|
bitsPerSample: number,
|
|
169
170
|
) {
|
|
170
171
|
stream.send({
|
|
171
|
-
type: "audio-start",
|
|
172
|
+
type: isAiUiMessageStream ? "data-audio-start" : "audio-start",
|
|
172
173
|
data: {
|
|
173
174
|
mimeType,
|
|
174
175
|
format,
|
|
@@ -181,7 +182,7 @@ function createAgentEventStream(
|
|
|
181
182
|
|
|
182
183
|
audioDelta(value: Uint8Array) {
|
|
183
184
|
stream.send({
|
|
184
|
-
type: "audio-delta",
|
|
185
|
+
type: isAiUiMessageStream ? "data-audio-delta" : "audio-delta",
|
|
185
186
|
data: {
|
|
186
187
|
base64: Buffer.from(value).toString("base64"),
|
|
187
188
|
},
|
|
@@ -190,15 +191,21 @@ function createAgentEventStream(
|
|
|
190
191
|
|
|
191
192
|
audioDone() {
|
|
192
193
|
stream.send({
|
|
193
|
-
type: "audio-done",
|
|
194
|
+
type: isAiUiMessageStream ? "data-audio-done" : "audio-done",
|
|
195
|
+
...(isAiUiMessageStream ? { data: {} } : {}),
|
|
194
196
|
});
|
|
195
197
|
},
|
|
196
198
|
|
|
197
199
|
error(error: string) {
|
|
198
|
-
stream.send(
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
200
|
+
stream.send(isAiUiMessageStream
|
|
201
|
+
? {
|
|
202
|
+
type: "error",
|
|
203
|
+
errorText: error,
|
|
204
|
+
}
|
|
205
|
+
: {
|
|
206
|
+
type: "error",
|
|
207
|
+
error,
|
|
208
|
+
});
|
|
202
209
|
},
|
|
203
210
|
|
|
204
211
|
end() {
|