@meistrari/chat-nuxt 4.8.0-rc.3 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@meistrari/chat-nuxt",
3
3
  "configKey": "chatNuxt",
4
- "version": "4.8.0-rc.3",
4
+ "version": "4.8.0-rc.4",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "unknown"
@@ -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 timelineItems = computed(() => mergeConversationTimeline(props.messages, props.events));
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
- export function mergeConversationTimeline(messages, events = []) {
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
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meistrari/chat-nuxt",
3
- "version": "4.8.0-rc.3",
3
+ "version": "4.8.0-rc.4",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {