@adminforth/agent 2.5.6 → 2.5.8
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.
|
@@ -89,9 +89,9 @@ export function createAgentSessionManager({
|
|
|
89
89
|
method: 'POST',
|
|
90
90
|
path: '/agent/get-session-info',
|
|
91
91
|
body: { sessionId },
|
|
92
|
+
silentError: true,
|
|
92
93
|
});
|
|
93
94
|
if (res.error) {
|
|
94
|
-
console.error('Error fetching session:', res.error);
|
|
95
95
|
return;
|
|
96
96
|
}
|
|
97
97
|
sessions.value[sessionId] = res.session;
|
|
@@ -109,8 +109,10 @@ export function createAgentSessionManager({
|
|
|
109
109
|
}
|
|
110
110
|
currentSession.value = sessions.value[sessionId];
|
|
111
111
|
setCurrentChat(sessionId);
|
|
112
|
-
if (currentChat.value.messages.length === 0) {
|
|
113
|
-
|
|
112
|
+
if (currentChat.value && currentChat.value.messages.length === 0) {
|
|
113
|
+
// The session fetch can bail out (deleted/expired session), leaving no stored
|
|
114
|
+
// messages — keep `messages` an array so consumers can iterate it safely.
|
|
115
|
+
currentChat.value.messages = (currentSession.value?.messages ?? []).flatMap(mapStoredMessage);
|
|
114
116
|
}
|
|
115
117
|
}
|
|
116
118
|
|
|
@@ -147,13 +147,13 @@ export const useAgentStore = defineStore('agent', () => {
|
|
|
147
147
|
}
|
|
148
148
|
|
|
149
149
|
async function submitToolApproval(sessionId: string, decision: 'approve' | 'reject') {
|
|
150
|
-
const message = currentChat.value?.messages
|
|
151
|
-
.findLast(candidate => candidate.role === 'assistant' && candidate.parts.some(part => {
|
|
150
|
+
const message = (currentChat.value?.messages ?? [])
|
|
151
|
+
.findLast(candidate => candidate.role === 'assistant' && (candidate.parts ?? []).some((part: any) => {
|
|
152
152
|
return part.type === 'data-tool-approval'
|
|
153
153
|
&& part.data?.sessionId === sessionId
|
|
154
154
|
&& part.data?.status === 'pending';
|
|
155
155
|
}));
|
|
156
|
-
const approvalPart = message?.parts.find(part => {
|
|
156
|
+
const approvalPart = (message?.parts ?? []).find((part: any) => {
|
|
157
157
|
return part.type === 'data-tool-approval'
|
|
158
158
|
&& part.data?.sessionId === sessionId
|
|
159
159
|
&& part.data?.status === 'pending';
|
|
@@ -190,13 +190,13 @@ export const useAgentStore = defineStore('agent', () => {
|
|
|
190
190
|
return currentChat.value?.status === 'streaming';
|
|
191
191
|
});
|
|
192
192
|
const hasPendingToolApproval = computed(() => (
|
|
193
|
-
currentChat.value?.messages.some((message: any) => (
|
|
193
|
+
(currentChat.value?.messages ?? []).some((message: any) => (
|
|
194
194
|
message.role === 'assistant'
|
|
195
|
-
&& message.parts.some((part: any) => (
|
|
195
|
+
&& (message.parts ?? []).some((part: any) => (
|
|
196
196
|
part.type === 'data-tool-approval'
|
|
197
197
|
&& (part.data?.status === 'pending' || part.data?.status === 'processing')
|
|
198
198
|
))
|
|
199
|
-
))
|
|
199
|
+
))
|
|
200
200
|
));
|
|
201
201
|
const isMessageInputBlocked = computed(() => (
|
|
202
202
|
isResponseInProgress.value || hasPendingToolApproval.value
|
|
@@ -468,7 +468,7 @@ export const useAgentStore = defineStore('agent', () => {
|
|
|
468
468
|
|
|
469
469
|
|
|
470
470
|
function getCompiledMessageTextWithSteeredParts(message: any): string {
|
|
471
|
-
const currentTurnUserMessages = currentChat.value?.messages.filter((msg: any) => msg.metadata?.turnId === message?.metadata?.turnId && msg.role === 'user');
|
|
471
|
+
const currentTurnUserMessages = (currentChat.value?.messages ?? []).filter((msg: any) => msg.metadata?.turnId === message?.metadata?.turnId && msg.role === 'user');
|
|
472
472
|
let messageToCompile = '';
|
|
473
473
|
for(const msg of currentTurnUserMessages) {
|
|
474
474
|
const text = (msg.parts ?? [])
|