@meistrari/chat-nuxt 4.8.0-rc.2 → 4.8.0-rc.4
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/messages/components/chat-message-list.vue +3 -1
- package/dist/runtime/messages/conversation-timeline.d.ts +2 -1
- package/dist/runtime/messages/conversation-timeline.js +30 -1
- package/dist/runtime/types/schemas/chat/conversation-runtime.d.ts +2 -0
- package/dist/runtime/types/schemas/chat/conversations.d.ts +2 -0
- package/dist/runtime/types/schemas/chat/conversations.js +1 -0
- package/dist/runtime/types/schemas/chat/message-audit.d.ts +92 -0
- package/dist/runtime/types/schemas/chat/message-audit.js +55 -0
- package/dist/runtime/types/schemas/chat/messages.d.ts +4 -0
- package/dist/runtime/types/schemas/chat/messages.js +1 -0
- package/package.json +1 -1
package/dist/module.json
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
<script setup>
|
|
2
|
+
import { useEmbedConfig } from "../../embed/composables/embed-config";
|
|
2
3
|
import ChatMessageBubble from "./chat-message-bubble.vue";
|
|
3
4
|
import { useStickToBottom } from "../composables/use-stick-to-bottom";
|
|
4
5
|
import { mergeConversationTimeline } from "../conversation-timeline";
|
|
@@ -46,7 +47,8 @@ const skeletonMessages = [
|
|
|
46
47
|
{ id: "user-2", align: "end", width: "46%", height: "44px" },
|
|
47
48
|
{ id: "assistant-2", align: "start", width: "84%", height: "92px" }
|
|
48
49
|
];
|
|
49
|
-
const
|
|
50
|
+
const executionControls = useEmbedConfig()?.executionControls;
|
|
51
|
+
const timelineItems = computed(() => mergeConversationTimeline(props.messages, props.events, executionControls?.value));
|
|
50
52
|
const today = useCurrentDay();
|
|
51
53
|
const timestampSeparators = computed(() => getTimestampSeparatorLabels(props.messages, today.value));
|
|
52
54
|
const latestMessageId = computed(() => props.messages.at(-1)?.id ?? null);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ConversationEvent, Message } from '../types/schemas/chat/conversations.js';
|
|
2
|
+
import { type ChatExecutionControls } from '../embed/execution-controls.js';
|
|
2
3
|
export declare function getConversationForkSource(event: ConversationEvent): {
|
|
3
4
|
sourceConversationId: string;
|
|
4
5
|
sourceTitle: string;
|
|
@@ -15,4 +16,4 @@ export type ConversationTimelineItem = {
|
|
|
15
16
|
createdAt: Date;
|
|
16
17
|
value: Message;
|
|
17
18
|
};
|
|
18
|
-
export declare function mergeConversationTimeline(messages: readonly Message[], events?: readonly ConversationEvent[] | null): ConversationTimelineItem[];
|
|
19
|
+
export declare function mergeConversationTimeline(messages: readonly Message[], events?: readonly ConversationEvent[] | null, controls?: ChatExecutionControls): ConversationTimelineItem[];
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
+
import { chatReasoningEffortSchema } from "../types/schemas/chat/models.js";
|
|
3
|
+
import { resolveChatExecutionMode } from "../embed/execution-controls.js";
|
|
2
4
|
const forkSourceSchema = z.object({
|
|
3
5
|
sourceConversationId: z.string().uuid(),
|
|
4
6
|
sourceTitle: z.string(),
|
|
@@ -10,7 +12,14 @@ export function getConversationForkSource(event) {
|
|
|
10
12
|
const parsed = forkSourceSchema.safeParse(event.payload);
|
|
11
13
|
return parsed.success ? parsed.data : null;
|
|
12
14
|
}
|
|
13
|
-
|
|
15
|
+
const executionChangeSchema = z.object({
|
|
16
|
+
messageId: z.string(),
|
|
17
|
+
previousModel: z.string().nullable(),
|
|
18
|
+
model: z.string().nullable(),
|
|
19
|
+
previousReasoningEffort: chatReasoningEffortSchema.nullable(),
|
|
20
|
+
reasoningEffort: chatReasoningEffortSchema.nullable()
|
|
21
|
+
});
|
|
22
|
+
export function mergeConversationTimeline(messages, events = [], controls) {
|
|
14
23
|
const items = [
|
|
15
24
|
...(events ?? []).filter((event) => event.type !== "conversation_forked").map((event) => ({ kind: "event", id: event.id, createdAt: event.createdAt, value: event })),
|
|
16
25
|
...messages.map((message) => ({ kind: "message", id: message.id, createdAt: message.createdAt, value: message }))
|
|
@@ -40,5 +49,25 @@ export function mergeConversationTimeline(messages, events = []) {
|
|
|
40
49
|
if (index !== -1)
|
|
41
50
|
items.splice(index + 1, 0, { kind: "event", id: event.id, createdAt: event.createdAt, value: event });
|
|
42
51
|
}
|
|
52
|
+
if (controls?.mode === "simple") {
|
|
53
|
+
const seen = /* @__PURE__ */ new Set();
|
|
54
|
+
const labels = { default: "Padr\xE3o", deep: "Aprofundar", custom: "Personalizado" };
|
|
55
|
+
return items.flatMap((item) => {
|
|
56
|
+
if (item.kind !== "event" || !["model_changed", "reasoning_effort_changed"].includes(item.value.type))
|
|
57
|
+
return [item];
|
|
58
|
+
const parsed = executionChangeSchema.safeParse(item.value.payload);
|
|
59
|
+
if (!parsed.success)
|
|
60
|
+
return [{ ...item, value: { ...item.value, description: "alterou o modo de resposta" } }];
|
|
61
|
+
const change = parsed.data;
|
|
62
|
+
const key = JSON.stringify([item.value.conversationId, change.messageId, item.createdAt, item.value.actorLabel, change.previousModel, change.previousReasoningEffort, change.model, change.reasoningEffort]);
|
|
63
|
+
if (seen.has(key))
|
|
64
|
+
return [];
|
|
65
|
+
seen.add(key);
|
|
66
|
+
const before = resolveChatExecutionMode(controls.profiles, { model: change.previousModel, reasoningEffort: change.previousReasoningEffort });
|
|
67
|
+
const after = resolveChatExecutionMode(controls.profiles, change);
|
|
68
|
+
const description = before === after ? "alterou o modo de resposta" : `mudou de ${labels[before]} para ${labels[after]}`;
|
|
69
|
+
return [{ ...item, value: { ...item.value, description } }];
|
|
70
|
+
});
|
|
71
|
+
}
|
|
43
72
|
return items;
|
|
44
73
|
}
|
|
@@ -96,6 +96,7 @@ export declare const sendMessageV2BodySchema: z.ZodObject<{
|
|
|
96
96
|
export type SendMessageV2Body = z.infer<typeof sendMessageV2BodySchema>;
|
|
97
97
|
export declare const sendMessageV2ResponseSchema: z.ZodObject<{
|
|
98
98
|
userMessage: z.ZodObject<{
|
|
99
|
+
auditEventId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
99
100
|
id: z.ZodString;
|
|
100
101
|
conversationId: z.ZodString;
|
|
101
102
|
role: z.ZodEnum<{
|
|
@@ -130,6 +131,7 @@ export declare const sendMessageV2ResponseSchema: z.ZodObject<{
|
|
|
130
131
|
generationEndedAt: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
|
|
131
132
|
}, z.core.$strip>;
|
|
132
133
|
assistantMessage: z.ZodObject<{
|
|
134
|
+
auditEventId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
133
135
|
id: z.ZodString;
|
|
134
136
|
conversationId: z.ZodString;
|
|
135
137
|
role: z.ZodEnum<{
|
|
@@ -80,6 +80,7 @@ export declare const conversationGroupSchema: z.ZodObject<{
|
|
|
80
80
|
}, z.core.$strip>;
|
|
81
81
|
export type ConversationGroup = z.infer<typeof conversationGroupSchema>;
|
|
82
82
|
export declare const messageSchema: z.ZodObject<{
|
|
83
|
+
auditEventId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
83
84
|
id: z.ZodString;
|
|
84
85
|
conversationId: z.ZodString;
|
|
85
86
|
role: z.ZodEnum<{
|
|
@@ -194,6 +195,7 @@ export declare const conversationWithMessagesSchema: z.ZodObject<{
|
|
|
194
195
|
createdAt: z.ZodDate;
|
|
195
196
|
updatedAt: z.ZodDate;
|
|
196
197
|
messages: z.ZodArray<z.ZodObject<{
|
|
198
|
+
auditEventId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
197
199
|
id: z.ZodString;
|
|
198
200
|
conversationId: z.ZodString;
|
|
199
201
|
role: z.ZodEnum<{
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const messageAuditTraceSchema: z.ZodObject<{
|
|
3
|
+
metrics: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
4
|
+
durationMs: z.ZodNumber;
|
|
5
|
+
toolCalls: z.ZodNumber;
|
|
6
|
+
apiCalls: z.ZodNumber;
|
|
7
|
+
tokensIn: z.ZodNumber;
|
|
8
|
+
tokensOut: z.ZodNumber;
|
|
9
|
+
cachedTokens: z.ZodNumber;
|
|
10
|
+
totalCostUsd: z.ZodNumber;
|
|
11
|
+
cacheSavingsUsd: z.ZodNumber;
|
|
12
|
+
}, z.core.$strip>>>;
|
|
13
|
+
prompt: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
14
|
+
model: z.ZodNullable<z.ZodString>;
|
|
15
|
+
timestamp: z.ZodNullable<z.ZodNumber>;
|
|
16
|
+
}, z.core.$strip>>>;
|
|
17
|
+
spans: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
|
|
18
|
+
type: z.ZodString;
|
|
19
|
+
id: z.ZodString;
|
|
20
|
+
parentId: z.ZodNullable<z.ZodString>;
|
|
21
|
+
startMs: z.ZodNumber;
|
|
22
|
+
endMs: z.ZodNumber;
|
|
23
|
+
metrics: z.ZodOptional<z.ZodObject<{
|
|
24
|
+
tokensIn: z.ZodNumber;
|
|
25
|
+
tokensOut: z.ZodNumber;
|
|
26
|
+
cachedTokens: z.ZodNumber;
|
|
27
|
+
costUsd: z.ZodNumber;
|
|
28
|
+
toolCallCount: z.ZodNumber;
|
|
29
|
+
apiCallCount: z.ZodNumber;
|
|
30
|
+
}, z.core.$strip>>;
|
|
31
|
+
}, z.core.$strip>>>>;
|
|
32
|
+
events: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
|
|
33
|
+
type: z.ZodString;
|
|
34
|
+
relativeTimeMs: z.ZodNumber;
|
|
35
|
+
timestamp: z.ZodNumber;
|
|
36
|
+
sequenceIndex: z.ZodNumber;
|
|
37
|
+
runTurnId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
38
|
+
callId: z.ZodOptional<z.ZodString>;
|
|
39
|
+
toolName: z.ZodOptional<z.ZodString>;
|
|
40
|
+
category: z.ZodOptional<z.ZodString>;
|
|
41
|
+
status: z.ZodOptional<z.ZodString>;
|
|
42
|
+
text: z.ZodOptional<z.ZodString>;
|
|
43
|
+
tokensIn: z.ZodOptional<z.ZodNumber>;
|
|
44
|
+
tokensOut: z.ZodOptional<z.ZodNumber>;
|
|
45
|
+
cachedTokens: z.ZodOptional<z.ZodNumber>;
|
|
46
|
+
costUsd: z.ZodOptional<z.ZodNumber>;
|
|
47
|
+
result: z.ZodOptional<z.ZodObject<{
|
|
48
|
+
isError: z.ZodBoolean;
|
|
49
|
+
durationMs: z.ZodNumber;
|
|
50
|
+
}, z.core.$strip>>;
|
|
51
|
+
}, z.core.$strip>>>>;
|
|
52
|
+
}, z.core.$strip>;
|
|
53
|
+
export type MessageAuditTrace = z.infer<typeof messageAuditTraceSchema>;
|
|
54
|
+
export declare const messageAuditEventSchema: z.ZodObject<{
|
|
55
|
+
id: z.ZodUUID;
|
|
56
|
+
sequence: z.ZodString;
|
|
57
|
+
attemptId: z.ZodUUID;
|
|
58
|
+
messageId: z.ZodUUID;
|
|
59
|
+
conversationId: z.ZodUUID;
|
|
60
|
+
workspaceId: z.ZodString;
|
|
61
|
+
userId: z.ZodString;
|
|
62
|
+
telaAgentId: z.ZodNullable<z.ZodString>;
|
|
63
|
+
conversationScope: z.ZodNullable<z.ZodString>;
|
|
64
|
+
status: z.ZodEnum<{
|
|
65
|
+
pending: "pending";
|
|
66
|
+
completed: "completed";
|
|
67
|
+
failed: "failed";
|
|
68
|
+
}>;
|
|
69
|
+
occurredAt: z.ZodISODateTime;
|
|
70
|
+
snapshot: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
71
|
+
}, z.core.$strip>;
|
|
72
|
+
export declare const messageAuditPageSchema: z.ZodObject<{
|
|
73
|
+
events: z.ZodArray<z.ZodObject<{
|
|
74
|
+
id: z.ZodUUID;
|
|
75
|
+
sequence: z.ZodString;
|
|
76
|
+
attemptId: z.ZodUUID;
|
|
77
|
+
messageId: z.ZodUUID;
|
|
78
|
+
conversationId: z.ZodUUID;
|
|
79
|
+
workspaceId: z.ZodString;
|
|
80
|
+
userId: z.ZodString;
|
|
81
|
+
telaAgentId: z.ZodNullable<z.ZodString>;
|
|
82
|
+
conversationScope: z.ZodNullable<z.ZodString>;
|
|
83
|
+
status: z.ZodEnum<{
|
|
84
|
+
pending: "pending";
|
|
85
|
+
completed: "completed";
|
|
86
|
+
failed: "failed";
|
|
87
|
+
}>;
|
|
88
|
+
occurredAt: z.ZodISODateTime;
|
|
89
|
+
snapshot: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
90
|
+
}, z.core.$strip>>;
|
|
91
|
+
nextCursor: z.ZodNullable<z.ZodString>;
|
|
92
|
+
}, z.core.$strip>;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
const metricsSchema = z.object({
|
|
3
|
+
durationMs: z.number(),
|
|
4
|
+
toolCalls: z.number(),
|
|
5
|
+
apiCalls: z.number(),
|
|
6
|
+
tokensIn: z.number(),
|
|
7
|
+
tokensOut: z.number(),
|
|
8
|
+
cachedTokens: z.number(),
|
|
9
|
+
totalCostUsd: z.number(),
|
|
10
|
+
cacheSavingsUsd: z.number(),
|
|
11
|
+
});
|
|
12
|
+
export const messageAuditTraceSchema = z.object({
|
|
13
|
+
metrics: metricsSchema.nullable().optional(),
|
|
14
|
+
prompt: z.object({ model: z.string().nullable(), timestamp: z.number().nullable() }).nullable().optional(),
|
|
15
|
+
spans: z.array(z.object({
|
|
16
|
+
type: z.string(),
|
|
17
|
+
id: z.string(),
|
|
18
|
+
parentId: z.string().nullable(),
|
|
19
|
+
startMs: z.number(),
|
|
20
|
+
endMs: z.number(),
|
|
21
|
+
metrics: z.object({ tokensIn: z.number(), tokensOut: z.number(), cachedTokens: z.number(), costUsd: z.number(), toolCallCount: z.number(), apiCallCount: z.number() }).optional(),
|
|
22
|
+
})).nullable().optional(),
|
|
23
|
+
events: z.array(z.object({
|
|
24
|
+
type: z.string(),
|
|
25
|
+
relativeTimeMs: z.number(),
|
|
26
|
+
timestamp: z.number(),
|
|
27
|
+
sequenceIndex: z.number(),
|
|
28
|
+
runTurnId: z.string().nullable().optional(),
|
|
29
|
+
callId: z.string().optional(),
|
|
30
|
+
toolName: z.string().optional(),
|
|
31
|
+
category: z.string().optional(),
|
|
32
|
+
status: z.string().optional(),
|
|
33
|
+
text: z.string().optional(),
|
|
34
|
+
tokensIn: z.number().optional(),
|
|
35
|
+
tokensOut: z.number().optional(),
|
|
36
|
+
cachedTokens: z.number().optional(),
|
|
37
|
+
costUsd: z.number().optional(),
|
|
38
|
+
result: z.object({ isError: z.boolean(), durationMs: z.number() }).optional(),
|
|
39
|
+
})).nullable().optional(),
|
|
40
|
+
});
|
|
41
|
+
export const messageAuditEventSchema = z.object({
|
|
42
|
+
id: z.uuid(),
|
|
43
|
+
sequence: z.string(),
|
|
44
|
+
attemptId: z.uuid(),
|
|
45
|
+
messageId: z.uuid(),
|
|
46
|
+
conversationId: z.uuid(),
|
|
47
|
+
workspaceId: z.string(),
|
|
48
|
+
userId: z.string(),
|
|
49
|
+
telaAgentId: z.string().nullable(),
|
|
50
|
+
conversationScope: z.string().nullable(),
|
|
51
|
+
status: z.enum(['pending', 'completed', 'failed']),
|
|
52
|
+
occurredAt: z.iso.datetime(),
|
|
53
|
+
snapshot: z.record(z.string(), z.unknown()),
|
|
54
|
+
});
|
|
55
|
+
export const messageAuditPageSchema = z.object({ events: z.array(messageAuditEventSchema), nextCursor: z.string().nullable() });
|
|
@@ -19,6 +19,7 @@ export declare const messageOverviewResponseSchema: z.ZodObject<{
|
|
|
19
19
|
}>>;
|
|
20
20
|
content: z.ZodString;
|
|
21
21
|
agentSessionId: z.ZodNullable<z.ZodString>;
|
|
22
|
+
auditEventId: z.ZodNullable<z.ZodString>;
|
|
22
23
|
agentSessionCursor: z.ZodNullable<z.ZodNumber>;
|
|
23
24
|
createdAt: z.ZodDate;
|
|
24
25
|
updatedAt: z.ZodNullable<z.ZodDate>;
|
|
@@ -122,6 +123,7 @@ export declare const sendMessageBodySchema: z.ZodObject<{
|
|
|
122
123
|
export type SendMessageBody = z.infer<typeof sendMessageBodySchema>;
|
|
123
124
|
export declare const sendMessageResponseSchema: z.ZodObject<{
|
|
124
125
|
userMessage: z.ZodObject<{
|
|
126
|
+
auditEventId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
125
127
|
id: z.ZodString;
|
|
126
128
|
conversationId: z.ZodString;
|
|
127
129
|
role: z.ZodEnum<{
|
|
@@ -156,6 +158,7 @@ export declare const sendMessageResponseSchema: z.ZodObject<{
|
|
|
156
158
|
generationEndedAt: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
|
|
157
159
|
}, z.core.$strip>;
|
|
158
160
|
assistantMessage: z.ZodObject<{
|
|
161
|
+
auditEventId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
159
162
|
id: z.ZodString;
|
|
160
163
|
conversationId: z.ZodString;
|
|
161
164
|
role: z.ZodEnum<{
|
|
@@ -193,6 +196,7 @@ export declare const sendMessageResponseSchema: z.ZodObject<{
|
|
|
193
196
|
export type SendMessageResponse = z.infer<typeof sendMessageResponseSchema>;
|
|
194
197
|
export declare const messagePollResponseSchema: z.ZodObject<{
|
|
195
198
|
messages: z.ZodArray<z.ZodObject<{
|
|
199
|
+
auditEventId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
196
200
|
id: z.ZodString;
|
|
197
201
|
conversationId: z.ZodString;
|
|
198
202
|
role: z.ZodEnum<{
|
|
@@ -17,6 +17,7 @@ export const messageOverviewResponseSchema = z.strictObject({
|
|
|
17
17
|
status: messageStatusSchema.nullable(),
|
|
18
18
|
content: z.string(),
|
|
19
19
|
agentSessionId: z.string().nullable(),
|
|
20
|
+
auditEventId: z.string().uuid().nullable(),
|
|
20
21
|
agentSessionCursor: z.number().int().nullable(),
|
|
21
22
|
createdAt: z.date(),
|
|
22
23
|
updatedAt: z.date().nullable(),
|