@meistrari/chat-nuxt 3.12.0 → 3.12.1-rc.0
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/module.json +1 -1
- package/dist/runtime/embed/components/chat-embed-inner.vue +26 -15
- package/dist/runtime/embed/composables/use-agent-wake.d.ts +1 -0
- package/dist/runtime/embed/composables/use-agent-wake.js +34 -19
- package/dist/runtime/types/schemas/integrations/tela-agent-api.d.ts +1 -0
- package/dist/runtime/types/schemas/integrations/tela-agent-api.js +1 -0
- package/package.json +1 -1
package/dist/module.json
CHANGED
|
@@ -202,7 +202,10 @@ const selectedModel = computed({
|
|
|
202
202
|
if (!updated && currentConversation.value?.id === conversation.id && currentConversation.value.model === value) {
|
|
203
203
|
setConversationModel(previousModel);
|
|
204
204
|
} else if (updated && value) {
|
|
205
|
-
|
|
205
|
+
if (conversation.threadSessionId)
|
|
206
|
+
await agentWake.ensureReady(conversation.threadSessionId, value);
|
|
207
|
+
else
|
|
208
|
+
await agentWake.wake(void 0, value);
|
|
206
209
|
}
|
|
207
210
|
return updated;
|
|
208
211
|
});
|
|
@@ -252,10 +255,10 @@ function updateConversationId(nextConversationId) {
|
|
|
252
255
|
}
|
|
253
256
|
async function ensureConversationLoaded(conversationId) {
|
|
254
257
|
if (currentConversation.value?.id === conversationId) {
|
|
255
|
-
|
|
256
|
-
currentConversation.value.threadSessionId
|
|
257
|
-
|
|
258
|
-
|
|
258
|
+
if (currentConversation.value.threadSessionId)
|
|
259
|
+
void agentWake.ensureReady(currentConversation.value.threadSessionId, selectedModel.value);
|
|
260
|
+
else
|
|
261
|
+
void agentWake.wake(void 0, selectedModel.value);
|
|
259
262
|
startPolling();
|
|
260
263
|
return;
|
|
261
264
|
}
|
|
@@ -273,10 +276,10 @@ async function ensureConversationLoaded(conversationId) {
|
|
|
273
276
|
});
|
|
274
277
|
return;
|
|
275
278
|
}
|
|
276
|
-
|
|
277
|
-
currentConversation.value.threadSessionId
|
|
278
|
-
|
|
279
|
-
|
|
279
|
+
if (currentConversation.value.threadSessionId)
|
|
280
|
+
void agentWake.ensureReady(currentConversation.value.threadSessionId, selectedModel.value);
|
|
281
|
+
else
|
|
282
|
+
void agentWake.wake(void 0, selectedModel.value);
|
|
280
283
|
startPolling();
|
|
281
284
|
} finally {
|
|
282
285
|
if (loadingConversationId.value === conversationId) {
|
|
@@ -470,12 +473,13 @@ async function handleSend(content, files, agentInputs) {
|
|
|
470
473
|
const conversation = currentConversation.value;
|
|
471
474
|
if (!conversation)
|
|
472
475
|
throw new Error("Erro ao preparar conversa");
|
|
473
|
-
if (conversation.threadSessionId && resolvedFeatures.value.chatOutboundQueue
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
476
|
+
if (conversation.threadSessionId && resolvedFeatures.value.chatOutboundQueue) {
|
|
477
|
+
const wake = await agentWake.ensureReady(conversation.threadSessionId, selectedModel.value);
|
|
478
|
+
if (wake.status !== "ready") {
|
|
479
|
+
if (wake.wokenSandbox && !wake.wokenSandbox.rewakeable)
|
|
480
|
+
return { defer: true };
|
|
478
481
|
throw new Error("N\xE3o foi poss\xEDvel acordar o agente. Tente novamente.");
|
|
482
|
+
}
|
|
479
483
|
return {};
|
|
480
484
|
}
|
|
481
485
|
if (!conversation.threadSessionId) {
|
|
@@ -520,8 +524,15 @@ async function handleCancel() {
|
|
|
520
524
|
await cancelConversation();
|
|
521
525
|
}
|
|
522
526
|
async function handleRetry(messageId) {
|
|
523
|
-
if (
|
|
527
|
+
if (currentConversation.value?.threadSessionId) {
|
|
528
|
+
const wake = await agentWake.ensureReady(currentConversation.value.threadSessionId, selectedModel.value);
|
|
529
|
+
if (wake.status !== "ready") {
|
|
530
|
+
statusToast.update({ text: "N\xE3o foi poss\xEDvel acordar o agente. Tente novamente.", icon: "i-ph-warning" });
|
|
531
|
+
return;
|
|
532
|
+
}
|
|
533
|
+
} else {
|
|
524
534
|
await agentWake.waitUntilSettled();
|
|
535
|
+
}
|
|
525
536
|
await retryMessage(messageId, claimableWakeSessionId());
|
|
526
537
|
}
|
|
527
538
|
async function handleNewConversation(groupId) {
|
|
@@ -17,6 +17,7 @@ export declare function useAgentWake(): {
|
|
|
17
17
|
state: any;
|
|
18
18
|
sessionId: any;
|
|
19
19
|
wake: (requestedSessionId?: string, model?: string | null) => Promise<TelaAgentWakeResponse>;
|
|
20
|
+
ensureReady: (sessionId: string, model?: string | null) => Promise<TelaAgentWakeResponse>;
|
|
20
21
|
skip: () => void;
|
|
21
22
|
consume: () => void;
|
|
22
23
|
waitUntilSettled: (signal?: AbortSignal) => Promise<AgentWakeSnapshot>;
|
|
@@ -78,7 +78,7 @@ export function useAgentWake() {
|
|
|
78
78
|
activeWake = null;
|
|
79
79
|
setSnapshot({ state: "idle" });
|
|
80
80
|
}
|
|
81
|
-
async function
|
|
81
|
+
async function runWake(requestedSessionId, model, probeExistingSession) {
|
|
82
82
|
generation++;
|
|
83
83
|
const currentGeneration = generation;
|
|
84
84
|
abortController?.abort();
|
|
@@ -96,26 +96,34 @@ export function useAgentWake() {
|
|
|
96
96
|
}
|
|
97
97
|
const run = async () => {
|
|
98
98
|
try {
|
|
99
|
+
const requestWake = () => $fetch(
|
|
100
|
+
chatApi.path("/agent/wake"),
|
|
101
|
+
chatApi.withChatHeaders({
|
|
102
|
+
method: "POST",
|
|
103
|
+
signal: controller.signal,
|
|
104
|
+
body: {
|
|
105
|
+
...wakeSessionId ? { sessionId: wakeSessionId } : {},
|
|
106
|
+
...model ? { model } : {}
|
|
107
|
+
}
|
|
108
|
+
})
|
|
109
|
+
);
|
|
110
|
+
const requestStatus = (sessionId2) => $fetch(
|
|
111
|
+
chatApi.path(`/agent/wake/${encodeURIComponent(sessionId2)}/status`),
|
|
112
|
+
chatApi.withChatHeaders({
|
|
113
|
+
method: "GET",
|
|
114
|
+
signal: controller.signal
|
|
115
|
+
})
|
|
116
|
+
);
|
|
99
117
|
const result = await pollAgentWake({
|
|
100
118
|
signal: controller.signal,
|
|
101
|
-
request: () =>
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
}
|
|
110
|
-
})
|
|
111
|
-
),
|
|
112
|
-
requestStatus: (sessionId2) => $fetch(
|
|
113
|
-
chatApi.path(`/agent/wake/${encodeURIComponent(sessionId2)}/status`),
|
|
114
|
-
chatApi.withChatHeaders({
|
|
115
|
-
method: "GET",
|
|
116
|
-
signal: controller.signal
|
|
117
|
-
})
|
|
118
|
-
),
|
|
119
|
+
request: async () => {
|
|
120
|
+
if (!probeExistingSession || !wakeSessionId)
|
|
121
|
+
return await requestWake();
|
|
122
|
+
const status = await requestStatus(wakeSessionId);
|
|
123
|
+
const shouldWake = status.status === "unavailable" && (!status.wokenSandbox || status.wokenSandbox.rewakeable);
|
|
124
|
+
return shouldWake ? await requestWake() : status;
|
|
125
|
+
},
|
|
126
|
+
requestStatus,
|
|
119
127
|
onResponse: (response) => {
|
|
120
128
|
if (currentGeneration !== generation)
|
|
121
129
|
return;
|
|
@@ -151,6 +159,12 @@ export function useAgentWake() {
|
|
|
151
159
|
activeWake = null;
|
|
152
160
|
}
|
|
153
161
|
}
|
|
162
|
+
function wake(requestedSessionId, model) {
|
|
163
|
+
return runWake(requestedSessionId, model, false);
|
|
164
|
+
}
|
|
165
|
+
function ensureReady(sessionId2, model) {
|
|
166
|
+
return runWake(sessionId2, model, true);
|
|
167
|
+
}
|
|
154
168
|
async function waitUntilSettled(signal) {
|
|
155
169
|
if (snapshot.value.state !== "waking" || !activeWake)
|
|
156
170
|
return snapshot.value;
|
|
@@ -190,6 +204,7 @@ export function useAgentWake() {
|
|
|
190
204
|
state,
|
|
191
205
|
sessionId,
|
|
192
206
|
wake,
|
|
207
|
+
ensureReady,
|
|
193
208
|
skip,
|
|
194
209
|
consume,
|
|
195
210
|
waitUntilSettled
|
|
@@ -302,6 +302,7 @@ export declare const telaAgentWakeResponseSchema: z.ZodObject<{
|
|
|
302
302
|
}>;
|
|
303
303
|
leaseGeneration: z.ZodNumber;
|
|
304
304
|
executable: z.ZodBoolean;
|
|
305
|
+
rewakeable: z.ZodBoolean;
|
|
305
306
|
}, z.core.$strip>>;
|
|
306
307
|
}, z.core.$strip>;
|
|
307
308
|
export type TelaAgentWakeResponse = z.infer<typeof telaAgentWakeResponseSchema>;
|
|
@@ -150,6 +150,7 @@ export const telaAgentWakeResponseSchema = z.object({
|
|
|
150
150
|
status: wokenSandboxStatusSchema,
|
|
151
151
|
leaseGeneration: z.number().int().positive(),
|
|
152
152
|
executable: z.boolean(),
|
|
153
|
+
rewakeable: z.boolean(),
|
|
153
154
|
}).optional(),
|
|
154
155
|
});
|
|
155
156
|
export const telaAgentV4SessionStatusEventSchema = z.object({
|