@meistrari/chat-nuxt 2.0.0 → 3.0.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.
Files changed (53) hide show
  1. package/README.md +7 -9
  2. package/dist/module.d.mts +1 -1
  3. package/dist/module.json +1 -1
  4. package/dist/module.mjs +0 -39
  5. package/dist/runtime/conversations/composables/conversations.d.ts +1 -4
  6. package/dist/runtime/conversations/composables/conversations.js +3 -6
  7. package/dist/runtime/embed/components/chat-embed-inner.vue +4 -35
  8. package/dist/runtime/embed/components/chat-embed.d.vue.ts +3 -0
  9. package/dist/runtime/embed/components/chat-embed.vue +10 -2
  10. package/dist/runtime/embed/components/chat-embed.vue.d.ts +3 -0
  11. package/dist/runtime/embed/components/configuration/chat-configuration-knowledge-sources-tab.d.vue.ts +2 -2
  12. package/dist/runtime/embed/components/configuration/chat-configuration-knowledge-sources-tab.vue.d.ts +2 -2
  13. package/dist/runtime/embed/components/meistrari-chat-embed.vue +9 -1
  14. package/dist/runtime/embed/components/mobile/chat-mobile-shell.d.vue.ts +2 -8
  15. package/dist/runtime/embed/components/mobile/chat-mobile-shell.vue +2 -12
  16. package/dist/runtime/embed/components/mobile/chat-mobile-shell.vue.d.ts +2 -8
  17. package/dist/runtime/embed/composables/embed-config.d.ts +6 -0
  18. package/dist/runtime/embed/composables/embed-config.js +11 -3
  19. package/dist/runtime/embed/feature-config.d.ts +0 -2
  20. package/dist/runtime/embed/feature-config.js +0 -1
  21. package/dist/runtime/embed/types.d.ts +14 -0
  22. package/dist/runtime/messages/components/chat-message-bubble.vue +8 -4
  23. package/dist/runtime/messages/components/chat-message-feedback.d.vue.ts +7 -0
  24. package/dist/runtime/messages/components/chat-message-feedback.vue +251 -0
  25. package/dist/runtime/messages/components/chat-message-feedback.vue.d.ts +7 -0
  26. package/dist/runtime/messages/components/chat-message-input.d.vue.ts +5 -15
  27. package/dist/runtime/messages/components/chat-message-input.vue +0 -7
  28. package/dist/runtime/messages/components/chat-message-input.vue.d.ts +5 -15
  29. package/dist/runtime/messages/composables/chat-feedback.d.ts +21 -0
  30. package/dist/runtime/messages/composables/chat-feedback.js +12 -0
  31. package/dist/runtime/messages/composables/chat.d.ts +1 -1
  32. package/dist/runtime/messages/composables/chat.js +34 -12
  33. package/dist/runtime/messages/message-state.d.ts +3 -0
  34. package/dist/runtime/messages/message-state.js +13 -0
  35. package/dist/runtime/types/embed.d.ts +1 -0
  36. package/dist/runtime/types/schemas/chat/conversations.d.ts +2 -3
  37. package/dist/runtime/types/schemas/chat/conversations.js +2 -3
  38. package/dist/runtime/types/schemas/chat/messages.d.ts +6 -48
  39. package/dist/runtime/types/schemas/chat/messages.js +5 -4
  40. package/dist/runtime/types/schemas/chat/workspace-settings.d.ts +0 -47
  41. package/dist/runtime/types/schemas/chat/workspace-settings.js +0 -1
  42. package/dist/runtime/types/schemas/integrations/tela-agent-api.d.ts +34 -0
  43. package/dist/runtime/types/schemas/integrations/tela-agent-api.js +3 -0
  44. package/dist/types.d.mts +1 -1
  45. package/package.json +1 -1
  46. package/dist/runtime/internal/agent-environment-resolver.stub.d.ts +0 -2
  47. package/dist/runtime/internal/agent-environment-resolver.stub.js +0 -1
  48. package/dist/runtime/messages/components/chat-model-selector.d.vue.ts +0 -15
  49. package/dist/runtime/messages/components/chat-model-selector.vue +0 -42
  50. package/dist/runtime/messages/components/chat-model-selector.vue.d.ts +0 -15
  51. package/dist/runtime/messages/composables/selected-model.d.ts +0 -4
  52. package/dist/runtime/messages/composables/selected-model.js +0 -48
  53. package/dist/runtime/types/chat-agent-environment-resolver.d.ts +0 -4
@@ -6,13 +6,16 @@ import {
6
6
  } from "../message-reasoning.js";
7
7
  import {
8
8
  beginAssistantMessageRetry,
9
+ markPendingAssistantMessagesFailed,
9
10
  markPendingAssistantMessagesInterrupted,
10
11
  restoreAssistantMessageAfterRetryFailure,
11
12
  selectTitleGenerationMessages,
12
- shouldTreatLoadedConversationTitleAsGenerated
13
+ shouldTreatLoadedConversationTitleAsGenerated,
14
+ CANCELLATION_FAILED_TEXT
13
15
  } from "../message-state.js";
14
16
  import { exportConversationToMarkdown } from "../../conversations/export.js";
15
17
  import { resolveChatStateScope } from "../../conversations/scope.js";
18
+ import { getChatApiErrorMessage } from "../../shared/chat-api-error.js";
16
19
  import { useChatApi } from "../../shared/composables/chat-api.js";
17
20
  import { useConversationFileActions } from "../../files/composables/conversation-files.js";
18
21
  import { useEmbedConfig } from "../../embed/composables/embed-config.js";
@@ -26,7 +29,6 @@ export function useChat() {
26
29
  const embedConfig = useEmbedConfig();
27
30
  const { user: authUser, activeOrganization } = useChatAuth();
28
31
  const { addFilesToConversation } = useConversationFileActions();
29
- const isTelaAgentMode = computed(() => !!embedConfig?.telaAgentId.value);
30
32
  const chatScope = computed(() => resolveChatStateScope(
31
33
  embedConfig?.workspaceId.value || activeOrganization.value?.id,
32
34
  embedConfig?.telaAgentId.value,
@@ -64,14 +66,18 @@ export function useChat() {
64
66
  const reasoningCache = createReasoningCache();
65
67
  const processedMessages = computed(() => resolveReasoningDisplayMessages(messages.value, reasoningCache));
66
68
  const stopCondition = computed(() => !hasPendingMessage.value);
69
+ let pollGeneration = 0;
67
70
  const pollMessages = async () => {
68
71
  if (!currentConversation.value)
69
72
  return;
73
+ const generation = pollGeneration;
70
74
  try {
71
75
  const response = await $fetch(
72
76
  chatApi.path(`/conversations/${currentConversation.value.id}/messages`),
73
77
  chatApi.withChatHeaders()
74
78
  );
79
+ if (generation !== pollGeneration)
80
+ return;
75
81
  messages.value = response.messages;
76
82
  if (response.newFiles && response.newFiles.length > 0) {
77
83
  const lastAssistantMessage = response.messages.findLast((m) => m.role === "assistant");
@@ -86,13 +92,30 @@ export function useChat() {
86
92
  }
87
93
  } catch (err) {
88
94
  Sentry.captureException(err);
95
+ if (generation !== pollGeneration)
96
+ return;
97
+ const errorRecord = err && typeof err === "object" ? err : null;
98
+ const statusCode = typeof errorRecord?.statusCode === "number" ? errorRecord.statusCode : typeof errorRecord?.status === "number" ? errorRecord.status : typeof errorRecord?.response?.status === "number" ? errorRecord.response.status : null;
99
+ if (statusCode && statusCode >= 400 && statusCode < 500 && statusCode !== 408 && statusCode !== 429) {
100
+ messages.value = markPendingAssistantMessagesFailed(messages.value);
101
+ error.value = getChatApiErrorMessage(err) ?? "Erro ao atualizar mensagens";
102
+ stopPolling();
103
+ }
89
104
  }
90
105
  };
91
- const { isPolling, start: startPolling, stop: stopPolling } = usePolling({
106
+ const { isPolling, start: beginPolling, stop: endPolling } = usePolling({
92
107
  callback: pollMessages,
93
108
  interval: 500,
94
109
  stopCondition
95
110
  });
111
+ function startPolling() {
112
+ pollGeneration++;
113
+ beginPolling();
114
+ }
115
+ function stopPolling() {
116
+ pollGeneration++;
117
+ endPolling();
118
+ }
96
119
  const setConversation = (conv) => {
97
120
  const conversationMessages = "messages" in conv ? conv.messages : [];
98
121
  currentConversation.value = { ...conv, messages: conversationMessages };
@@ -127,7 +150,7 @@ export function useChat() {
127
150
  loading.value = false;
128
151
  }
129
152
  };
130
- const sendMessage = async (content, files, model, agentInputs) => {
153
+ const sendMessage = async (content, files, agentInputs) => {
131
154
  if (!currentConversation.value)
132
155
  return null;
133
156
  sending.value = true;
@@ -163,17 +186,11 @@ export function useChat() {
163
186
  };
164
187
  messages.value = [...messages.value, optimisticUserMessage, optimisticAssistantMessage];
165
188
  try {
166
- const workspaceSettingsSnapshot = embedConfig?.workspaceSettings.value;
167
189
  const resolvedAgentInputs = resolveTelaAgentInputs(agentInputs, embedConfig?.telaAgentInputs?.value);
168
190
  const body = {
169
191
  content,
170
192
  files,
171
- ...isTelaAgentMode.value ? {
172
- ...resolvedAgentInputs ? { agentInputs: resolvedAgentInputs } : {}
173
- } : {
174
- model,
175
- ...workspaceSettingsSnapshot !== void 0 ? { workspaceSettingsSnapshot } : {}
176
- }
193
+ ...resolvedAgentInputs ? { agentInputs: resolvedAgentInputs } : {}
177
194
  };
178
195
  const response = await $fetch(
179
196
  chatApi.path(`/conversations/${currentConversation.value.id}/messages`),
@@ -225,10 +242,15 @@ export function useChat() {
225
242
  cancelling.value = true;
226
243
  error.value = null;
227
244
  try {
228
- await $fetch(
245
+ const result = await $fetch(
229
246
  chatApi.path(`/conversations/${currentConversation.value.id}/cancel`),
230
247
  chatApi.withChatHeaders({ method: "POST" })
231
248
  );
249
+ if (!result.cancelled) {
250
+ messages.value = markPendingAssistantMessagesFailed(messages.value, CANCELLATION_FAILED_TEXT);
251
+ stopPolling();
252
+ return false;
253
+ }
232
254
  messages.value = markPendingAssistantMessagesInterrupted(messages.value);
233
255
  stopPolling();
234
256
  return true;
@@ -1,6 +1,9 @@
1
1
  import type { Message } from '../types/schemas/chat/conversations.js';
2
2
  export declare const INTERRUPTED_GENERATION_TEXT = "_Gera\u00E7\u00E3o interrompida pelo usu\u00E1rio_";
3
+ export declare const GENERATION_FAILED_TEXT = "Erro: N\u00E3o foi poss\u00EDvel concluir a resposta";
4
+ export declare const CANCELLATION_FAILED_TEXT = "Erro: N\u00E3o foi poss\u00EDvel cancelar a mensagem";
3
5
  export declare function markPendingAssistantMessagesInterrupted(messages: Message[]): Message[];
6
+ export declare function markPendingAssistantMessagesFailed(messages: Message[], content?: string): Message[];
4
7
  export declare function beginAssistantMessageRetry(messages: Message[], messageId: string): {
5
8
  messages: Message[];
6
9
  originalMessage: Message;
@@ -1,4 +1,6 @@
1
1
  export const INTERRUPTED_GENERATION_TEXT = "_Gera\xE7\xE3o interrompida pelo usu\xE1rio_";
2
+ export const GENERATION_FAILED_TEXT = "Erro: N\xE3o foi poss\xEDvel concluir a resposta";
3
+ export const CANCELLATION_FAILED_TEXT = "Erro: N\xE3o foi poss\xEDvel cancelar a mensagem";
2
4
  export function markPendingAssistantMessagesInterrupted(messages) {
3
5
  return messages.map((message) => {
4
6
  if (message.role !== "assistant" || message.status !== "pending")
@@ -10,6 +12,17 @@ export function markPendingAssistantMessagesInterrupted(messages) {
10
12
  };
11
13
  });
12
14
  }
15
+ export function markPendingAssistantMessagesFailed(messages, content = GENERATION_FAILED_TEXT) {
16
+ return messages.map((message) => {
17
+ if (message.role !== "assistant" || message.status !== "pending")
18
+ return message;
19
+ return {
20
+ ...message,
21
+ content,
22
+ status: "failed"
23
+ };
24
+ });
25
+ }
13
26
  export function beginAssistantMessageRetry(messages, messageId) {
14
27
  const originalMessage = messages.find((message) => message.id === messageId);
15
28
  if (!originalMessage || originalMessage.role !== "assistant" || originalMessage.status !== "failed")
@@ -1,4 +1,5 @@
1
1
  export type { ChatFeatureConfig } from '../embed/feature-config.js';
2
2
  export type { ChatActor, ChatEmbedSharedProps, DefaultChatEmbedProps, MeistrariChatEmbedProps, TelaAgentChatEmbedProps, } from '../embed/types.js';
3
3
  export type { ChatActionPayload } from '../messages/composables/chat-action.js';
4
+ export type { MessageFeedbackConfig, MessageFeedbackPayload, MessageFeedbackRating, } from '../messages/composables/chat-feedback.js';
4
5
  export type { TelaAgentExecutionInput } from './schemas/integrations/tela-agent-api.js';
@@ -211,12 +211,11 @@ export declare const conversationWithMessagesSchema: z.ZodObject<{
211
211
  export type ConversationWithMessages = z.infer<typeof conversationWithMessagesSchema>;
212
212
  export declare const createConversationRequestSchema: z.ZodObject<{
213
213
  model: z.ZodOptional<z.ZodNullable<z.ZodString>>;
214
- }, z.core.$strip>;
214
+ }, z.core.$strict>;
215
215
  export type CreateConversationRequest = z.infer<typeof createConversationRequestSchema>;
216
216
  export declare const updateConversationRequestSchema: z.ZodObject<{
217
217
  title: z.ZodOptional<z.ZodString>;
218
- model: z.ZodOptional<z.ZodNullable<z.ZodString>>;
219
- }, z.core.$strip>;
218
+ }, z.core.$strict>;
220
219
  export type UpdateConversationRequest = z.infer<typeof updateConversationRequestSchema>;
221
220
  export declare const moveConversationRequestSchema: z.ZodObject<{
222
221
  groupId: z.ZodNullable<z.ZodString>;
@@ -49,12 +49,11 @@ export const conversationListMetadataSchema = z.object({
49
49
  export const conversationWithMessagesSchema = conversationSchema.extend({
50
50
  messages: z.array(messageSchema),
51
51
  });
52
- export const createConversationRequestSchema = z.object({
52
+ export const createConversationRequestSchema = z.strictObject({
53
53
  model: z.string().nullable().optional(),
54
54
  });
55
- export const updateConversationRequestSchema = z.object({
55
+ export const updateConversationRequestSchema = z.strictObject({
56
56
  title: z.string().optional(),
57
- model: z.string().nullable().optional(),
58
57
  });
59
58
  export const moveConversationRequestSchema = z.object({
60
59
  groupId: z.string().nullable(),
@@ -19,54 +19,7 @@ export declare const sendMessageBodySchema: z.ZodObject<{
19
19
  name: z.ZodString;
20
20
  content: z.ZodString;
21
21
  }, z.core.$strip>], "type">>>;
22
- model: z.ZodOptional<z.ZodString>;
23
- workspaceSettingsSnapshot: z.ZodOptional<z.ZodNullable<z.ZodObject<{
24
- systemMessage: z.ZodOptional<z.ZodNullable<z.ZodString>>;
25
- contextFiles: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
26
- url: z.ZodString;
27
- vaultReference: z.ZodOptional<z.ZodString>;
28
- name: z.ZodString;
29
- mimeType: z.ZodOptional<z.ZodString>;
30
- }, z.core.$strip>>>>;
31
- canvasTools: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
32
- canvasId: z.ZodString;
33
- name: z.ZodString;
34
- description: z.ZodString;
35
- variables: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
36
- name: z.ZodString;
37
- description: z.ZodString;
38
- type: z.ZodEnum<{
39
- file: "file";
40
- text: "text";
41
- }>;
42
- }, z.core.$strip>>>;
43
- }, z.core.$strip>>>>;
44
- knowledgeSources: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
45
- type: z.ZodEnum<{
46
- workstation: "workstation";
47
- }>;
48
- id: z.ZodString;
49
- name: z.ZodString;
50
- projectId: z.ZodString;
51
- description: z.ZodOptional<z.ZodString>;
52
- taskCount: z.ZodOptional<z.ZodNumber>;
53
- }, z.core.$strip>>>>;
54
- externalSkills: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
55
- ref: z.ZodString;
56
- name: z.ZodString;
57
- description: z.ZodString;
58
- runtime: z.ZodString;
59
- allowedTools: z.ZodArray<z.ZodString>;
60
- isPublic: z.ZodBoolean;
61
- addedBy: z.ZodObject<{
62
- userId: z.ZodString;
63
- username: z.ZodString;
64
- }, z.core.$strip>;
65
- addedAt: z.ZodString;
66
- }, z.core.$strip>>>>;
67
- updatedAt: z.ZodOptional<z.ZodUnion<readonly [z.ZodDate, z.ZodString]>>;
68
- }, z.core.$strip>>>;
69
- }, z.core.$strip>;
22
+ }, z.core.$strict>;
70
23
  export type SendMessageBody = z.infer<typeof sendMessageBodySchema>;
71
24
  export declare const sendMessageResponseSchema: z.ZodObject<{
72
25
  userMessage: z.ZodObject<{
@@ -178,3 +131,8 @@ export declare const messagePollResponseSchema: z.ZodObject<{
178
131
  }, z.core.$strip>>>;
179
132
  }, z.core.$strip>;
180
133
  export type MessagePollResponse = z.infer<typeof messagePollResponseSchema>;
134
+ export declare const cancelConversationResponseSchema: z.ZodObject<{
135
+ success: z.ZodLiteral<true>;
136
+ cancelled: z.ZodBoolean;
137
+ }, z.core.$strip>;
138
+ export type CancelConversationResponse = z.infer<typeof cancelConversationResponseSchema>;
@@ -2,13 +2,10 @@ import { z } from 'zod';
2
2
  import { telaAgentExecutionInputSchema } from '../integrations/tela-agent-api';
3
3
  import { messageSchema } from './conversations';
4
4
  import { fileUploadInputSchema, messageFileSchema } from './files';
5
- import { workspaceSettingsSnapshotSchema } from './workspace-settings';
6
- export const sendMessageBodySchema = z.object({
5
+ export const sendMessageBodySchema = z.strictObject({
7
6
  content: z.string(),
8
7
  files: z.array(fileUploadInputSchema).optional(),
9
8
  agentInputs: z.array(telaAgentExecutionInputSchema).optional(),
10
- model: z.string().optional(),
11
- workspaceSettingsSnapshot: workspaceSettingsSnapshotSchema.optional(),
12
9
  });
13
10
  export const sendMessageResponseSchema = z.object({
14
11
  userMessage: messageSchema,
@@ -18,3 +15,7 @@ export const messagePollResponseSchema = z.object({
18
15
  messages: z.array(messageSchema),
19
16
  newFiles: z.array(messageFileSchema).optional(),
20
17
  });
18
+ export const cancelConversationResponseSchema = z.object({
19
+ success: z.literal(true),
20
+ cancelled: z.boolean(),
21
+ });
@@ -125,53 +125,6 @@ export declare const resolvedWorkspaceSettingsPartialSchema: z.ZodObject<{
125
125
  updatedAt: z.ZodOptional<z.ZodUnion<readonly [z.ZodDate, z.ZodString]>>;
126
126
  }, z.core.$strip>;
127
127
  export type ResolvedWorkspaceSettingsPartial = z.infer<typeof resolvedWorkspaceSettingsPartialSchema>;
128
- export declare const workspaceSettingsSnapshotSchema: z.ZodNullable<z.ZodObject<{
129
- systemMessage: z.ZodOptional<z.ZodNullable<z.ZodString>>;
130
- contextFiles: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
131
- url: z.ZodString;
132
- vaultReference: z.ZodOptional<z.ZodString>;
133
- name: z.ZodString;
134
- mimeType: z.ZodOptional<z.ZodString>;
135
- }, z.core.$strip>>>>;
136
- canvasTools: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
137
- canvasId: z.ZodString;
138
- name: z.ZodString;
139
- description: z.ZodString;
140
- variables: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
141
- name: z.ZodString;
142
- description: z.ZodString;
143
- type: z.ZodEnum<{
144
- file: "file";
145
- text: "text";
146
- }>;
147
- }, z.core.$strip>>>;
148
- }, z.core.$strip>>>>;
149
- knowledgeSources: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
150
- type: z.ZodEnum<{
151
- workstation: "workstation";
152
- }>;
153
- id: z.ZodString;
154
- name: z.ZodString;
155
- projectId: z.ZodString;
156
- description: z.ZodOptional<z.ZodString>;
157
- taskCount: z.ZodOptional<z.ZodNumber>;
158
- }, z.core.$strip>>>>;
159
- externalSkills: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
160
- ref: z.ZodString;
161
- name: z.ZodString;
162
- description: z.ZodString;
163
- runtime: z.ZodString;
164
- allowedTools: z.ZodArray<z.ZodString>;
165
- isPublic: z.ZodBoolean;
166
- addedBy: z.ZodObject<{
167
- userId: z.ZodString;
168
- username: z.ZodString;
169
- }, z.core.$strip>;
170
- addedAt: z.ZodString;
171
- }, z.core.$strip>>>>;
172
- updatedAt: z.ZodOptional<z.ZodUnion<readonly [z.ZodDate, z.ZodString]>>;
173
- }, z.core.$strip>>;
174
- export type WorkspaceSettingsSnapshot = z.infer<typeof workspaceSettingsSnapshotSchema>;
175
128
  export declare const resolvedWorkspaceSettingsCanvasToolInputSchema: z.ZodObject<{
176
129
  canvasId: z.ZodString;
177
130
  }, z.core.$loose>;
@@ -33,7 +33,6 @@ export const resolvedWorkspaceSettingsSchema = z.object({
33
33
  updatedAt: z.union([z.date(), z.string()]),
34
34
  });
35
35
  export const resolvedWorkspaceSettingsPartialSchema = resolvedWorkspaceSettingsSchema.partial();
36
- export const workspaceSettingsSnapshotSchema = resolvedWorkspaceSettingsPartialSchema.nullable();
37
36
  export const resolvedWorkspaceSettingsCanvasToolInputSchema = canvasToolSchema
38
37
  .pick({ canvasId: true })
39
38
  .passthrough();
@@ -357,6 +357,40 @@ export declare const telaAgentApiResponseSchema: z.ZodObject<{
357
357
  isMultiturn: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
358
358
  }, z.core.$catchall<z.ZodUnknown>>;
359
359
  }, z.core.$catchall<z.ZodUnknown>>;
360
+ export declare const telaAgentResolveApiResponseSchema: z.ZodObject<{
361
+ agent: z.ZodObject<{
362
+ id: z.ZodString;
363
+ organizationName: z.ZodOptional<z.ZodString>;
364
+ repository: z.ZodOptional<z.ZodString>;
365
+ publishedId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
366
+ allowedCredentials: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
367
+ inputSchema: z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
368
+ id: z.ZodOptional<z.ZodString>;
369
+ name: z.ZodString;
370
+ type: z.ZodEnum<{
371
+ file: "file";
372
+ text: "text";
373
+ }>;
374
+ required: z.ZodOptional<z.ZodBoolean>;
375
+ description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
376
+ }, z.core.$catchall<z.ZodUnknown>>>>>, z.ZodTransform<{
377
+ [x: string]: unknown;
378
+ name: string;
379
+ type: "file" | "text";
380
+ id?: string | undefined;
381
+ required?: boolean | undefined;
382
+ description?: string | null | undefined;
383
+ }[], {
384
+ [x: string]: unknown;
385
+ name: string;
386
+ type: "file" | "text";
387
+ id?: string | undefined;
388
+ required?: boolean | undefined;
389
+ description?: string | null | undefined;
390
+ }[] | null | undefined>>;
391
+ isMultiturn: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
392
+ }, z.core.$catchall<z.ZodUnknown>>;
393
+ }, z.core.$catchall<z.ZodUnknown>>;
360
394
  export declare const telaAgentEndSessionApiResponseSchema: z.ZodObject<{
361
395
  data: z.ZodObject<{
362
396
  success: z.ZodBoolean;
@@ -134,6 +134,9 @@ export const telaAgentRunApiResponseSchema = z.object({
134
134
  export const telaAgentApiResponseSchema = z.object({
135
135
  data: telaAgentSchema,
136
136
  }).catchall(z.unknown());
137
+ export const telaAgentResolveApiResponseSchema = z.object({
138
+ agent: telaAgentSchema,
139
+ }).catchall(z.unknown());
137
140
  export const telaAgentEndSessionApiResponseSchema = z.object({
138
141
  data: z.object({
139
142
  success: z.boolean(),
package/dist/types.d.mts CHANGED
@@ -4,7 +4,7 @@ import type { default as Module } from './module.mjs'
4
4
 
5
5
  export type ModuleOptions = typeof Module extends NuxtModule<infer O> ? Partial<O> : Record<string, any>
6
6
 
7
- export { type ChatActionPayload, type ChatActor, type ChatEmbedSharedProps, type ChatFeatureConfig, type DefaultChatEmbedProps, type MeistrariChatEmbedProps, type TelaAgentChatEmbedProps, type TelaAgentExecutionInput } from '../dist/runtime/types/embed.js'
7
+ export { type ChatActionPayload, type ChatActor, type ChatEmbedSharedProps, type ChatFeatureConfig, type DefaultChatEmbedProps, type MeistrariChatEmbedProps, type MessageFeedbackConfig, type MessageFeedbackPayload, type MessageFeedbackRating, type TelaAgentChatEmbedProps, type TelaAgentExecutionInput } from '../dist/runtime/types/embed.js'
8
8
 
9
9
  export { default } from './module.mjs'
10
10
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meistrari/chat-nuxt",
3
- "version": "2.0.0",
3
+ "version": "3.0.0",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -1,2 +0,0 @@
1
- declare const _default: null;
2
- export default _default;
@@ -1 +0,0 @@
1
- export default null;
@@ -1,15 +0,0 @@
1
- import type { ChatModel } from '../../types/schemas/chat/models.js';
2
- type __VLS_Props = {
3
- disabled?: boolean;
4
- };
5
- type __VLS_ModelProps = {
6
- modelValue?: ChatModel;
7
- };
8
- type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
9
- declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
10
- "update:modelValue": (value: ChatModel) => any;
11
- }, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
12
- "onUpdate:modelValue"?: ((value: ChatModel) => any) | undefined;
13
- }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
14
- declare const _default: typeof __VLS_export;
15
- export default _default;
@@ -1,42 +0,0 @@
1
- <script setup>
2
- import { useBreakpoints } from "@vueuse/core";
3
- import { defaultChatModel } from "../../types/schemas/chat/models.js";
4
- import { chatModelOptions } from "../../types/schemas/chat/ui.js";
5
- import AnthropicLogo from "../../shared/components/icons/anthropic.vue";
6
- import { CHAT_MOBILE_BREAKPOINT } from "../../shared/breakpoints";
7
- defineProps({
8
- disabled: { type: Boolean, required: false }
9
- });
10
- const model = defineModel({ type: null, ...{ default: defaultChatModel } });
11
- const options = chatModelOptions.map((m) => ({
12
- value: m.value,
13
- label: m.label,
14
- description: m.description,
15
- icon: AnthropicLogo
16
- }));
17
- const breakpoints = useBreakpoints({ mobile: CHAT_MOBILE_BREAKPOINT });
18
- const isMobile = breakpoints.smaller("mobile");
19
- const contentClass = computed(() => isMobile.value ? "w-280px!" : "");
20
- </script>
21
-
22
- <template>
23
- <TelaCombobox
24
- v-model="model"
25
- :options="options"
26
- :disabled="disabled"
27
- :class="disabled && 'opacity-50 pointer-events-none'"
28
- placeholder="Modelo"
29
- input-placeholder="Buscar modelo..."
30
- :has-searchbar="false"
31
- :has-grouping-labels="false"
32
- :trigger-class="`border-none! ${disabled ? 'bg-[#F3F4F6]!' : ''}`"
33
- :content-class="contentClass"
34
- label-class="!text-14px !leading-18px !font-normal -tracking-0.01em! !text-gray-500"
35
- icon-class="w-16px h-16px scale-110 mr-1px !text-gray-500"
36
- label-item-class="!text-gray-500"
37
- />
38
- </template>
39
-
40
- <style scoped>
41
- :deep([role=option] svg){color:#6b7280}
42
- </style>
@@ -1,15 +0,0 @@
1
- import type { ChatModel } from '../../types/schemas/chat/models.js';
2
- type __VLS_Props = {
3
- disabled?: boolean;
4
- };
5
- type __VLS_ModelProps = {
6
- modelValue?: ChatModel;
7
- };
8
- type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
9
- declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
10
- "update:modelValue": (value: ChatModel) => any;
11
- }, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
12
- "onUpdate:modelValue"?: ((value: ChatModel) => any) | undefined;
13
- }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
14
- declare const _default: typeof __VLS_export;
15
- export default _default;
@@ -1,4 +0,0 @@
1
- import type { Conversation } from '../../types/schemas/chat/conversations.js';
2
- type ConversationModelTarget = Pick<Conversation, 'id' | 'model'>;
3
- export declare function useSelectedModel<T extends ConversationModelTarget>(conversation?: Readonly<Ref<T | null | undefined>>): any;
4
- export {};
@@ -1,48 +0,0 @@
1
- import { defaultChatModel } from "../../types/schemas/chat/models.js";
2
- import { useChatApi } from "../../shared/composables/chat-api.js";
3
- import { useStatusToast } from "../../shared/composables/status-toast.js";
4
- export function useSelectedModel(conversation) {
5
- const chatApi = useChatApi();
6
- const statusToast = useStatusToast();
7
- const override = ref(null);
8
- let requestSeq = 0;
9
- if (conversation) {
10
- watch(() => conversation.value?.id, () => {
11
- override.value = null;
12
- });
13
- }
14
- const model = computed({
15
- get() {
16
- if (override.value) {
17
- return override.value;
18
- }
19
- if (conversation?.value?.model) {
20
- return conversation.value.model;
21
- }
22
- return defaultChatModel;
23
- },
24
- set(value) {
25
- const previous = override.value;
26
- override.value = value;
27
- if (conversation?.value?.id) {
28
- const seq = ++requestSeq;
29
- $fetch(
30
- chatApi.path(`/conversations/${conversation.value.id}`),
31
- chatApi.withChatHeaders({
32
- method: "PATCH",
33
- body: { model: value }
34
- })
35
- ).catch(() => {
36
- if (seq !== requestSeq)
37
- return;
38
- override.value = previous;
39
- statusToast.update({
40
- text: "Erro ao salvar modelo selecionado",
41
- icon: "i-ph-warning"
42
- });
43
- });
44
- }
45
- }
46
- });
47
- return model;
48
- }
@@ -1,4 +0,0 @@
1
- declare module '#chat-agent-environment-resolver' {
2
- const resolver: unknown
3
- export default resolver
4
- }