@adminforth/agent 2.5.8 → 2.5.10

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.
@@ -50,7 +50,7 @@
50
50
  <div class="flex items-center justify-center">
51
51
  <Button
52
52
  @click="agentStore.createPreSession(); agentStore.setSessionHistoryOpen(false); agentStore.focusTextInput();"
53
- class="!py-1 !px-2 rounded-3xl text-gray-800 dark:text-gray-200 max-w-64 mr-2"
53
+ class="!py-1 !px-2 max-w-64 mr-2"
54
54
  >
55
55
  <IconPlusOutline class="w-5 h-5" />
56
56
  {{ $t('New chat') }}
@@ -28,8 +28,11 @@
28
28
  </span>
29
29
  <button
30
30
  type="button"
31
- class="shrink-0 rounded-md px-2 py-1 text-xs font-medium text-lightPrimary transition-colors hover:bg-lightPrimary/10 dark:text-darkPrimary dark:hover:bg-darkPrimary/10"
32
- :title="$t('Steer into the current response')"
31
+ class="shrink-0 rounded-md px-2 py-1 text-xs font-medium text-lightPrimary transition-colors hover:bg-lightPrimary/10 disabled:cursor-not-allowed disabled:opacity-40 disabled:hover:bg-transparent dark:text-darkPrimary dark:hover:bg-darkPrimary/10 dark:disabled:hover:bg-transparent"
32
+ :disabled="agentStore.isFinalResponseStreaming"
33
+ :title="agentStore.isFinalResponseStreaming
34
+ ? $t('The final response is streaming; this message will be sent after it finishes')
35
+ : $t('Steer into the current response')"
33
36
  @click="agentStore.steerQueuedMessage(item.id)"
34
37
  >
35
38
  {{ $t('Steer') }}
@@ -13,12 +13,14 @@ export type QueuedMessage = {
13
13
  type CreateAgentSteerQueueOptions = {
14
14
  activeSessionId: Ref<string | null>;
15
15
  currentChat: ShallowRef<Chat<any> | null | undefined>;
16
+ isFinalResponseStreaming: Ref<boolean>;
16
17
  sendMessage: (text: string) => void | Promise<void>;
17
18
  };
18
19
 
19
20
  export function createAgentSteerQueue({
20
21
  activeSessionId,
21
22
  currentChat,
23
+ isFinalResponseStreaming,
22
24
  sendMessage,
23
25
  }: CreateAgentSteerQueueOptions) {
24
26
  const queue = ref<QueuedMessage[]>([]);
@@ -146,7 +148,10 @@ export function createAgentSteerQueue({
146
148
  async function steerQueuedMessage(id: string) {
147
149
  const item = queue.value.find((candidate: QueuedMessage) => candidate.id === id);
148
150
  const sessionId = activeSessionId.value;
149
- if (!item || !sessionId || sessionId === PRE_SESSION_ID) {
151
+ // A steer is only consumed before a subsequent model call. Once the assistant is
152
+ // streaming its final text there is no such call left, so retain this item for the
153
+ // normal FIFO follow-up instead of silently losing the instruction server-side.
154
+ if (!item || !sessionId || sessionId === PRE_SESSION_ID || isFinalResponseStreaming.value) {
150
155
  return;
151
156
  }
152
157
  removeQueuedMessage(id);
@@ -238,9 +238,22 @@ export const useAgentStore = defineStore('agent', () => {
238
238
  return status === 'submitted' || status === 'streaming' || hasPendingToolApproval.value;
239
239
  });
240
240
 
241
+ // During an assistant text stream, a newly submitted steer cannot be consumed: the
242
+ // steer middleware only runs before another model call. Keep it in the queue so it
243
+ // becomes a normal follow-up when the current turn ends.
244
+ const isFinalResponseStreaming = computed(() => {
245
+ const chat = currentChat.value as any;
246
+ const lastMessage = chat?.lastMessage;
247
+
248
+ return chat?.status === 'streaming'
249
+ && lastMessage?.role === 'assistant'
250
+ && lastMessage.parts?.some((part: any) => part.type === 'text' && part.state === 'streaming');
251
+ });
252
+
241
253
  const steerBuffer = createAgentSteerQueue({
242
254
  activeSessionId,
243
255
  currentChat,
256
+ isFinalResponseStreaming,
244
257
  sendMessage,
245
258
  });
246
259
 
@@ -646,6 +659,7 @@ export const useAgentStore = defineStore('agent', () => {
646
659
  //_________-Steer queue-_____________
647
660
  submitUserMessage,
648
661
  isTurnActive,
662
+ isFinalResponseStreaming,
649
663
  steerQueue: steerBuffer.queue,
650
664
  steerQueuedMessage: steerBuffer.steerQueuedMessage,
651
665
  removeQueuedMessage: steerBuffer.removeQueuedMessage,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adminforth/agent",
3
- "version": "2.5.8",
3
+ "version": "2.5.10",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "type": "module",