@meistrari/chat-nuxt 1.3.0 → 1.5.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 (98) hide show
  1. package/README.md +51 -16
  2. package/dist/module.json +1 -1
  3. package/dist/module.mjs +12 -8
  4. package/dist/runtime/components/MeistrariChatEmbed.d.vue.ts +5 -16
  5. package/dist/runtime/components/MeistrariChatEmbed.vue +28 -5
  6. package/dist/runtime/components/MeistrariChatEmbed.vue.d.ts +5 -16
  7. package/dist/runtime/components/app-markdown-render.d.vue.ts +3 -1
  8. package/dist/runtime/components/app-markdown-render.vue +15 -4
  9. package/dist/runtime/components/app-markdown-render.vue.d.ts +3 -1
  10. package/dist/runtime/components/chat/message-bubble.vue +10 -2
  11. package/dist/runtime/components/chat/message-input.d.vue.ts +30 -4
  12. package/dist/runtime/components/chat/message-input.vue +268 -24
  13. package/dist/runtime/components/chat/message-input.vue.d.ts +30 -4
  14. package/dist/runtime/composables/useChat.d.ts +3 -5
  15. package/dist/runtime/composables/useChat.js +24 -3
  16. package/dist/runtime/composables/useChatAction.d.ts +10 -0
  17. package/dist/runtime/composables/useChatAction.js +12 -0
  18. package/dist/runtime/composables/useChatApi.js +4 -0
  19. package/dist/runtime/composables/useConversations.js +8 -2
  20. package/dist/runtime/composables/useEmbedConfig.d.ts +12 -2
  21. package/dist/runtime/composables/useEmbedConfig.js +24 -3
  22. package/dist/runtime/composables/useFeatureFlags.d.ts +1 -2
  23. package/dist/runtime/composables/useTelaAgentMetadata.d.ts +8 -0
  24. package/dist/runtime/composables/useTelaAgentMetadata.js +65 -0
  25. package/dist/runtime/composables/useWorkspaceSettings.d.ts +1 -19
  26. package/dist/runtime/embed/components/ChatConfigurationModal.d.vue.ts +1 -1
  27. package/dist/runtime/embed/components/ChatConfigurationModal.vue.d.ts +1 -1
  28. package/dist/runtime/embed/components/ChatEmbed.d.vue.ts +6 -21
  29. package/dist/runtime/embed/components/ChatEmbed.vue +44 -11
  30. package/dist/runtime/embed/components/ChatEmbed.vue.d.ts +6 -21
  31. package/dist/runtime/embed/components/ChatEmbedInner.vue +36 -12
  32. package/dist/runtime/plugins/markstream.d.ts +1 -1
  33. package/dist/runtime/plugins/markstream.js +1 -1
  34. package/dist/runtime/server/api/conversations/[id]/cancel.post.d.ts +1 -1
  35. package/dist/runtime/server/api/conversations/[id]/cancel.post.js +37 -17
  36. package/dist/runtime/server/api/conversations/[id]/clear.post.js +28 -13
  37. package/dist/runtime/server/api/conversations/[id]/duplicate.post.js +11 -13
  38. package/dist/runtime/server/api/conversations/[id]/files.get.js +5 -7
  39. package/dist/runtime/server/api/conversations/[id]/index.delete.js +13 -12
  40. package/dist/runtime/server/api/conversations/[id]/index.get.js +6 -13
  41. package/dist/runtime/server/api/conversations/[id]/index.patch.js +11 -10
  42. package/dist/runtime/server/api/conversations/[id]/messages/[messageId]/retry.post.js +46 -80
  43. package/dist/runtime/server/api/conversations/[id]/messages/index.get.d.ts +1 -14
  44. package/dist/runtime/server/api/conversations/[id]/messages/index.get.js +81 -187
  45. package/dist/runtime/server/api/conversations/[id]/messages/index.post.js +68 -83
  46. package/dist/runtime/server/api/conversations/[id]/usage.get.js +4 -8
  47. package/dist/runtime/server/api/conversations/generate-title.post.js +4 -3
  48. package/dist/runtime/server/api/conversations/index.get.js +5 -4
  49. package/dist/runtime/server/api/conversations/index.post.js +5 -4
  50. package/dist/runtime/server/api/tela/agents/[id].get.d.ts +6 -0
  51. package/dist/runtime/server/api/tela/agents/[id].get.js +25 -0
  52. package/dist/runtime/server/api/workspace/settings.patch.js +1 -1
  53. package/dist/runtime/server/db/index.js +62 -0
  54. package/dist/runtime/server/db/schema/conversations.d.ts +17 -0
  55. package/dist/runtime/server/db/schema/conversations.js +3 -1
  56. package/dist/runtime/server/db/schema/workspace-settings.d.ts +1 -1
  57. package/dist/runtime/server/utils/agent-api.d.ts +1 -1
  58. package/dist/runtime/server/utils/agent-api.js +2 -5
  59. package/dist/runtime/server/utils/chat-context.d.ts +5 -0
  60. package/dist/runtime/server/utils/chat-context.js +20 -0
  61. package/dist/runtime/server/utils/chat-workspace-settings.d.ts +2 -1
  62. package/dist/runtime/server/utils/chat-workspace-settings.js +10 -1
  63. package/dist/runtime/server/utils/conversation-agent-turn.d.ts +39 -0
  64. package/dist/runtime/server/utils/conversation-agent-turn.js +170 -0
  65. package/dist/runtime/server/utils/conversation-message-files.d.ts +10 -0
  66. package/dist/runtime/server/utils/conversation-message-files.js +77 -0
  67. package/dist/runtime/server/utils/conversation-message-sync.d.ts +31 -0
  68. package/dist/runtime/server/utils/conversation-message-sync.js +132 -0
  69. package/dist/runtime/server/utils/conversation-scope.d.ts +2 -0
  70. package/dist/runtime/server/utils/conversation-scope.js +12 -0
  71. package/dist/runtime/server/utils/tela-agent-api.d.ts +29 -0
  72. package/dist/runtime/server/utils/tela-agent-api.js +107 -0
  73. package/dist/runtime/server/utils/tela-agent-session.d.ts +48 -0
  74. package/dist/runtime/server/utils/tela-agent-session.js +350 -0
  75. package/dist/runtime/types/embed.d.ts +29 -0
  76. package/dist/runtime/types/embed.js +0 -0
  77. package/dist/runtime/types/tela-agent.d.ts +243 -0
  78. package/dist/runtime/types/tela-agent.js +98 -0
  79. package/dist/runtime/types/workspace-settings-data.d.ts +19 -0
  80. package/dist/runtime/types/workspace-settings-data.js +0 -0
  81. package/dist/runtime/types/workspace-settings.d.ts +1 -1
  82. package/dist/runtime/utils/agent-input-readiness.d.ts +14 -0
  83. package/dist/runtime/utils/agent-input-readiness.js +15 -0
  84. package/dist/runtime/utils/custom-markdown-components.d.ts +9 -0
  85. package/dist/runtime/utils/custom-markdown-components.js +54 -0
  86. package/dist/runtime/utils/features.d.ts +9 -0
  87. package/dist/runtime/utils/features.js +5 -4
  88. package/dist/runtime/utils/file.js +46 -7
  89. package/dist/runtime/utils/markdown-nodes.d.ts +1 -0
  90. package/dist/runtime/utils/markdown-nodes.js +6 -0
  91. package/dist/runtime/utils/tela-chat.d.ts +6 -0
  92. package/dist/runtime/utils/tela-chat.js +12 -1
  93. package/drizzle/0014_faulty_lake.sql +2 -0
  94. package/drizzle/meta/0014_snapshot.json +732 -0
  95. package/drizzle/meta/_journal.json +7 -0
  96. package/package.json +1 -1
  97. package/dist/runtime/types/feature-flags.d.ts +0 -7
  98. package/dist/runtime/types/feature-flags.js +0 -6
@@ -0,0 +1,29 @@
1
+ import type { Component, DeepReadonly } from 'vue';
2
+ import type { WorkspaceSettings } from './workspace-settings-data.js';
3
+ import type { TelaAgentExecutionInput } from './tela-agent.js';
4
+ import type { ChatLoadingMessageMode } from '../utils/chat-loading-messages.js';
5
+ import type { ChatActor, ChatFeatureConfig } from '../utils/tela-chat.js';
6
+ export type ChatEmbedSharedProps = {
7
+ conversationId?: string | null;
8
+ initialConversationId?: string | null;
9
+ hideSidebar?: boolean;
10
+ loadingMessages?: readonly string[] | null;
11
+ loadingMessagesMode?: ChatLoadingMessageMode | null;
12
+ customComponents?: Record<string, Component>;
13
+ customHtmlTags?: readonly string[];
14
+ };
15
+ export type DefaultChatEmbedProps = ChatEmbedSharedProps & {
16
+ telaAgentId?: undefined;
17
+ telaAgentInputs?: undefined;
18
+ workspaceSettings?: DeepReadonly<WorkspaceSettings> | WorkspaceSettings | null;
19
+ user?: ChatActor | null;
20
+ features?: Partial<ChatFeatureConfig>;
21
+ };
22
+ export type TelaAgentChatEmbedProps = ChatEmbedSharedProps & {
23
+ telaAgentId: string;
24
+ telaAgentInputs?: DeepReadonly<TelaAgentExecutionInput[]> | null;
25
+ workspaceSettings?: never;
26
+ user?: never;
27
+ features?: Partial<ChatFeatureConfig>;
28
+ };
29
+ export type MeistrariChatEmbedProps = DefaultChatEmbedProps | TelaAgentChatEmbedProps;
File without changes
@@ -0,0 +1,243 @@
1
+ import { z } from 'zod';
2
+ export declare const telaAgentAttachmentSchema: z.ZodObject<{
3
+ vaultRef: z.ZodString;
4
+ filename: z.ZodString;
5
+ }, z.core.$strip>;
6
+ export declare const telaAgentInputVariableSchema: z.ZodObject<{
7
+ id: z.ZodOptional<z.ZodString>;
8
+ name: z.ZodString;
9
+ type: z.ZodEnum<{
10
+ text: "text";
11
+ file: "file";
12
+ }>;
13
+ required: z.ZodOptional<z.ZodBoolean>;
14
+ description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
15
+ }, z.core.$catchall<z.ZodUnknown>>;
16
+ export type TelaAgentInputVariable = z.infer<typeof telaAgentInputVariableSchema>;
17
+ export declare const telaAgentFileInputSchema: z.ZodObject<{
18
+ type: z.ZodLiteral<"file">;
19
+ name: z.ZodString;
20
+ vaultRef: z.ZodString;
21
+ filename: z.ZodString;
22
+ metadata: z.ZodOptional<z.ZodString>;
23
+ }, z.core.$strip>;
24
+ export declare const telaAgentTextInputSchema: z.ZodObject<{
25
+ type: z.ZodLiteral<"text">;
26
+ name: z.ZodString;
27
+ content: z.ZodString;
28
+ }, z.core.$strip>;
29
+ export declare const telaAgentExecutionInputSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
30
+ type: z.ZodLiteral<"file">;
31
+ name: z.ZodString;
32
+ vaultRef: z.ZodString;
33
+ filename: z.ZodString;
34
+ metadata: z.ZodOptional<z.ZodString>;
35
+ }, z.core.$strip>, z.ZodObject<{
36
+ type: z.ZodLiteral<"text">;
37
+ name: z.ZodString;
38
+ content: z.ZodString;
39
+ }, z.core.$strip>], "type">;
40
+ export type TelaAgentExecutionInput = z.infer<typeof telaAgentExecutionInputSchema>;
41
+ export declare const telaAgentRunPayloadSchema: z.ZodObject<{
42
+ message: z.ZodString;
43
+ sessionId: z.ZodOptional<z.ZodString>;
44
+ inputSchema: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
45
+ type: z.ZodLiteral<"file">;
46
+ name: z.ZodString;
47
+ vaultRef: z.ZodString;
48
+ filename: z.ZodString;
49
+ metadata: z.ZodOptional<z.ZodString>;
50
+ }, z.core.$strip>, z.ZodObject<{
51
+ type: z.ZodLiteral<"text">;
52
+ name: z.ZodString;
53
+ content: z.ZodString;
54
+ }, z.core.$strip>], "type">>>;
55
+ attachments: z.ZodOptional<z.ZodArray<z.ZodObject<{
56
+ vaultRef: z.ZodString;
57
+ filename: z.ZodString;
58
+ }, z.core.$strip>>>;
59
+ }, z.core.$catchall<z.ZodUnknown>>;
60
+ export type TelaAgentRunPayload = z.infer<typeof telaAgentRunPayloadSchema>;
61
+ export declare const telaAgentSchema: z.ZodObject<{
62
+ id: z.ZodString;
63
+ inputSchema: z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
64
+ id: z.ZodOptional<z.ZodString>;
65
+ name: z.ZodString;
66
+ type: z.ZodEnum<{
67
+ text: "text";
68
+ file: "file";
69
+ }>;
70
+ required: z.ZodOptional<z.ZodBoolean>;
71
+ description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
72
+ }, z.core.$catchall<z.ZodUnknown>>>>>, z.ZodTransform<{
73
+ [x: string]: unknown;
74
+ name: string;
75
+ type: "text" | "file";
76
+ id?: string | undefined;
77
+ required?: boolean | undefined;
78
+ description?: string | null | undefined;
79
+ }[], {
80
+ [x: string]: unknown;
81
+ name: string;
82
+ type: "text" | "file";
83
+ id?: string | undefined;
84
+ required?: boolean | undefined;
85
+ description?: string | null | undefined;
86
+ }[] | null | undefined>>;
87
+ isMultiturn: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
88
+ }, z.core.$catchall<z.ZodUnknown>>;
89
+ export type TelaAgent = z.infer<typeof telaAgentSchema>;
90
+ export declare const telaAgentRunResponseSchema: z.ZodObject<{
91
+ sessionId: z.ZodString;
92
+ }, z.core.$catchall<z.ZodUnknown>>;
93
+ export type TelaAgentRunResponse = z.infer<typeof telaAgentRunResponseSchema>;
94
+ export declare const telaAgentSessionStatusSchema: z.ZodEnum<{
95
+ pending: "pending";
96
+ running: "running";
97
+ completed: "completed";
98
+ failed: "failed";
99
+ waiting_messages: "waiting_messages";
100
+ cancelled: "cancelled";
101
+ }>;
102
+ export type TelaAgentSessionStatus = z.infer<typeof telaAgentSessionStatusSchema>;
103
+ export declare const telaAgentStepSchema: z.ZodObject<{
104
+ id: z.ZodString;
105
+ eventId: z.ZodOptional<z.ZodString>;
106
+ inputTokens: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
107
+ outputTokens: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
108
+ cacheReadInputTokens: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
109
+ cacheCreationInputTokens: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
110
+ calculatedCostUsd: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
111
+ }, z.core.$catchall<z.ZodUnknown>>;
112
+ export type TelaAgentStep = z.infer<typeof telaAgentStepSchema>;
113
+ export declare const telaAgentUsageSchema: z.ZodObject<{
114
+ duration: z.ZodOptional<z.ZodNumber>;
115
+ turns: z.ZodOptional<z.ZodNumber>;
116
+ completionTokens: z.ZodOptional<z.ZodNumber>;
117
+ promptTokens: z.ZodOptional<z.ZodNumber>;
118
+ totalTokens: z.ZodOptional<z.ZodNumber>;
119
+ completionCost: z.ZodOptional<z.ZodNumber>;
120
+ promptCost: z.ZodOptional<z.ZodNumber>;
121
+ totalCost: z.ZodOptional<z.ZodNumber>;
122
+ }, z.core.$catchall<z.ZodUnknown>>;
123
+ export declare const telaAgentSessionSchema: z.ZodObject<{
124
+ sessionId: z.ZodString;
125
+ status: z.ZodEnum<{
126
+ pending: "pending";
127
+ running: "running";
128
+ completed: "completed";
129
+ failed: "failed";
130
+ waiting_messages: "waiting_messages";
131
+ cancelled: "cancelled";
132
+ }>;
133
+ steps: z.ZodArray<z.ZodObject<{
134
+ id: z.ZodString;
135
+ eventId: z.ZodOptional<z.ZodString>;
136
+ inputTokens: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
137
+ outputTokens: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
138
+ cacheReadInputTokens: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
139
+ cacheCreationInputTokens: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
140
+ calculatedCostUsd: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
141
+ }, z.core.$catchall<z.ZodUnknown>>>;
142
+ nextCursor: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
143
+ result: z.ZodOptional<z.ZodObject<{
144
+ usage: z.ZodOptional<z.ZodObject<{
145
+ duration: z.ZodOptional<z.ZodNumber>;
146
+ turns: z.ZodOptional<z.ZodNumber>;
147
+ completionTokens: z.ZodOptional<z.ZodNumber>;
148
+ promptTokens: z.ZodOptional<z.ZodNumber>;
149
+ totalTokens: z.ZodOptional<z.ZodNumber>;
150
+ completionCost: z.ZodOptional<z.ZodNumber>;
151
+ promptCost: z.ZodOptional<z.ZodNumber>;
152
+ totalCost: z.ZodOptional<z.ZodNumber>;
153
+ }, z.core.$catchall<z.ZodUnknown>>>;
154
+ content: z.ZodOptional<z.ZodString>;
155
+ structuredContent: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
156
+ childEventIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
157
+ }, z.core.$catchall<z.ZodUnknown>>>;
158
+ error: z.ZodOptional<z.ZodString>;
159
+ createdAt: z.ZodOptional<z.ZodNumber>;
160
+ updatedAt: z.ZodOptional<z.ZodNumber>;
161
+ }, z.core.$catchall<z.ZodUnknown>>;
162
+ export type TelaAgentSession = z.infer<typeof telaAgentSessionSchema>;
163
+ export declare const telaAgentRunApiResponseSchema: z.ZodObject<{
164
+ data: z.ZodObject<{
165
+ sessionId: z.ZodString;
166
+ }, z.core.$catchall<z.ZodUnknown>>;
167
+ }, z.core.$catchall<z.ZodUnknown>>;
168
+ export declare const telaAgentApiResponseSchema: z.ZodObject<{
169
+ data: z.ZodObject<{
170
+ id: z.ZodString;
171
+ inputSchema: z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
172
+ id: z.ZodOptional<z.ZodString>;
173
+ name: z.ZodString;
174
+ type: z.ZodEnum<{
175
+ text: "text";
176
+ file: "file";
177
+ }>;
178
+ required: z.ZodOptional<z.ZodBoolean>;
179
+ description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
180
+ }, z.core.$catchall<z.ZodUnknown>>>>>, z.ZodTransform<{
181
+ [x: string]: unknown;
182
+ name: string;
183
+ type: "text" | "file";
184
+ id?: string | undefined;
185
+ required?: boolean | undefined;
186
+ description?: string | null | undefined;
187
+ }[], {
188
+ [x: string]: unknown;
189
+ name: string;
190
+ type: "text" | "file";
191
+ id?: string | undefined;
192
+ required?: boolean | undefined;
193
+ description?: string | null | undefined;
194
+ }[] | null | undefined>>;
195
+ isMultiturn: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
196
+ }, z.core.$catchall<z.ZodUnknown>>;
197
+ }, z.core.$catchall<z.ZodUnknown>>;
198
+ export declare const telaAgentSessionApiResponseSchema: z.ZodObject<{
199
+ data: z.ZodObject<{
200
+ sessionId: z.ZodString;
201
+ status: z.ZodEnum<{
202
+ pending: "pending";
203
+ running: "running";
204
+ completed: "completed";
205
+ failed: "failed";
206
+ waiting_messages: "waiting_messages";
207
+ cancelled: "cancelled";
208
+ }>;
209
+ steps: z.ZodArray<z.ZodObject<{
210
+ id: z.ZodString;
211
+ eventId: z.ZodOptional<z.ZodString>;
212
+ inputTokens: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
213
+ outputTokens: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
214
+ cacheReadInputTokens: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
215
+ cacheCreationInputTokens: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
216
+ calculatedCostUsd: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
217
+ }, z.core.$catchall<z.ZodUnknown>>>;
218
+ nextCursor: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
219
+ result: z.ZodOptional<z.ZodObject<{
220
+ usage: z.ZodOptional<z.ZodObject<{
221
+ duration: z.ZodOptional<z.ZodNumber>;
222
+ turns: z.ZodOptional<z.ZodNumber>;
223
+ completionTokens: z.ZodOptional<z.ZodNumber>;
224
+ promptTokens: z.ZodOptional<z.ZodNumber>;
225
+ totalTokens: z.ZodOptional<z.ZodNumber>;
226
+ completionCost: z.ZodOptional<z.ZodNumber>;
227
+ promptCost: z.ZodOptional<z.ZodNumber>;
228
+ totalCost: z.ZodOptional<z.ZodNumber>;
229
+ }, z.core.$catchall<z.ZodUnknown>>>;
230
+ content: z.ZodOptional<z.ZodString>;
231
+ structuredContent: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
232
+ childEventIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
233
+ }, z.core.$catchall<z.ZodUnknown>>>;
234
+ error: z.ZodOptional<z.ZodString>;
235
+ createdAt: z.ZodOptional<z.ZodNumber>;
236
+ updatedAt: z.ZodOptional<z.ZodNumber>;
237
+ }, z.core.$catchall<z.ZodUnknown>>;
238
+ }, z.core.$catchall<z.ZodUnknown>>;
239
+ export declare const telaAgentEndSessionApiResponseSchema: z.ZodObject<{
240
+ data: z.ZodObject<{
241
+ success: z.ZodBoolean;
242
+ }, z.core.$catchall<z.ZodUnknown>>;
243
+ }, z.core.$catchall<z.ZodUnknown>>;
@@ -0,0 +1,98 @@
1
+ import { z } from "zod";
2
+ export const telaAgentAttachmentSchema = z.object({
3
+ vaultRef: z.string().startsWith("vault://"),
4
+ filename: z.string().min(1).max(255)
5
+ });
6
+ export const telaAgentInputVariableSchema = z.object({
7
+ id: z.string().optional(),
8
+ name: z.string().min(1),
9
+ type: z.enum(["file", "text"]),
10
+ required: z.boolean().optional(),
11
+ description: z.string().nullable().optional()
12
+ }).catchall(z.unknown());
13
+ export const telaAgentFileInputSchema = z.object({
14
+ type: z.literal("file"),
15
+ name: z.string().min(1),
16
+ vaultRef: z.string().startsWith("vault://"),
17
+ filename: z.string().min(1).max(255),
18
+ metadata: z.string().optional()
19
+ });
20
+ export const telaAgentTextInputSchema = z.object({
21
+ type: z.literal("text"),
22
+ name: z.string().min(1),
23
+ content: z.string()
24
+ });
25
+ export const telaAgentExecutionInputSchema = z.discriminatedUnion("type", [
26
+ telaAgentFileInputSchema,
27
+ telaAgentTextInputSchema
28
+ ]);
29
+ export const telaAgentRunPayloadSchema = z.object({
30
+ message: z.string().min(1),
31
+ sessionId: z.string().optional(),
32
+ inputSchema: z.array(telaAgentExecutionInputSchema).optional(),
33
+ attachments: z.array(telaAgentAttachmentSchema).optional()
34
+ }).catchall(z.unknown());
35
+ export const telaAgentSchema = z.object({
36
+ id: z.string(),
37
+ inputSchema: z.array(telaAgentInputVariableSchema).nullable().optional().transform((value) => value ?? []),
38
+ isMultiturn: z.boolean().nullable().optional()
39
+ }).catchall(z.unknown());
40
+ export const telaAgentRunResponseSchema = z.object({
41
+ sessionId: z.string()
42
+ }).catchall(z.unknown());
43
+ export const telaAgentSessionStatusSchema = z.enum([
44
+ "pending",
45
+ "running",
46
+ "completed",
47
+ "failed",
48
+ "waiting_messages",
49
+ "cancelled"
50
+ ]);
51
+ export const telaAgentStepSchema = z.object({
52
+ id: z.string(),
53
+ eventId: z.string().optional(),
54
+ inputTokens: z.number().nullable().optional(),
55
+ outputTokens: z.number().nullable().optional(),
56
+ cacheReadInputTokens: z.number().nullable().optional(),
57
+ cacheCreationInputTokens: z.number().nullable().optional(),
58
+ calculatedCostUsd: z.number().nullable().optional()
59
+ }).catchall(z.unknown());
60
+ export const telaAgentUsageSchema = z.object({
61
+ duration: z.number().optional(),
62
+ turns: z.number().optional(),
63
+ completionTokens: z.number().optional(),
64
+ promptTokens: z.number().optional(),
65
+ totalTokens: z.number().optional(),
66
+ completionCost: z.number().optional(),
67
+ promptCost: z.number().optional(),
68
+ totalCost: z.number().optional()
69
+ }).catchall(z.unknown());
70
+ export const telaAgentSessionSchema = z.object({
71
+ sessionId: z.string(),
72
+ status: telaAgentSessionStatusSchema,
73
+ steps: z.array(telaAgentStepSchema),
74
+ nextCursor: z.number().nullable().optional(),
75
+ result: z.object({
76
+ usage: telaAgentUsageSchema.optional(),
77
+ content: z.string().optional(),
78
+ structuredContent: z.record(z.string(), z.unknown()).optional(),
79
+ childEventIds: z.array(z.string()).optional()
80
+ }).catchall(z.unknown()).optional(),
81
+ error: z.string().optional(),
82
+ createdAt: z.number().optional(),
83
+ updatedAt: z.number().optional()
84
+ }).catchall(z.unknown());
85
+ export const telaAgentRunApiResponseSchema = z.object({
86
+ data: telaAgentRunResponseSchema
87
+ }).catchall(z.unknown());
88
+ export const telaAgentApiResponseSchema = z.object({
89
+ data: telaAgentSchema
90
+ }).catchall(z.unknown());
91
+ export const telaAgentSessionApiResponseSchema = z.object({
92
+ data: telaAgentSessionSchema
93
+ }).catchall(z.unknown());
94
+ export const telaAgentEndSessionApiResponseSchema = z.object({
95
+ data: z.object({
96
+ success: z.boolean()
97
+ }).catchall(z.unknown())
98
+ }).catchall(z.unknown());
@@ -0,0 +1,19 @@
1
+ import type { ContextFile, ExternalSkill } from '../server/db/schema/workspace-settings.js';
2
+ import type { CanvasTool } from './agent.js';
3
+ import type { KnowledgeSource } from './chat.js';
4
+ export type WorkspaceSettings = {
5
+ workspaceId: string;
6
+ systemMessage: string | null;
7
+ contextFiles: ContextFile[] | null;
8
+ canvasTools: CanvasTool[] | null;
9
+ knowledgeSources: KnowledgeSource[] | null;
10
+ externalSkills: ExternalSkill[] | null;
11
+ updatedAt: Date;
12
+ };
13
+ export type WorkspaceSettingsUpdate = {
14
+ systemMessage?: string | null;
15
+ contextFiles?: ContextFile[] | null;
16
+ canvasTools?: CanvasTool[] | null;
17
+ knowledgeSources?: KnowledgeSource[] | null;
18
+ externalSkills?: ExternalSkill[] | null;
19
+ };
File without changes
@@ -1,3 +1,3 @@
1
1
  import type { ChatConfigurationSavePayload, ChatConfigurationTab } from '../embed/components/ChatConfigurationModal.vue.js';
2
- import type { WorkspaceSettings, WorkspaceSettingsUpdate } from '../composables/useWorkspaceSettings.js';
2
+ import type { WorkspaceSettings, WorkspaceSettingsUpdate } from './workspace-settings-data.js';
3
3
  export type { ChatConfigurationSavePayload, ChatConfigurationTab, WorkspaceSettings, WorkspaceSettingsUpdate, };
@@ -0,0 +1,14 @@
1
+ import type { TelaAgentInputVariable } from '../types/tela-agent.js';
2
+ export type AgentInputPendingFile = {
3
+ inputName?: string | null;
4
+ };
5
+ export type AgentInputReadiness = {
6
+ ready: boolean;
7
+ missingRequiredInputs: boolean;
8
+ hasUnmappedFiles: boolean;
9
+ };
10
+ export declare function getAgentInputReadiness(options: {
11
+ inputVariables: readonly TelaAgentInputVariable[];
12
+ inputTexts: Record<string, string | undefined>;
13
+ files: readonly AgentInputPendingFile[];
14
+ }): AgentInputReadiness;
@@ -0,0 +1,15 @@
1
+ export function getAgentInputReadiness(options) {
2
+ const inputVariables = options.inputVariables.filter((input) => input.name.trim());
3
+ const fileInputs = inputVariables.filter((input) => input.type === "file");
4
+ const textInputs = inputVariables.filter((input) => input.type === "text");
5
+ const fileInputNames = new Set(fileInputs.map((input) => input.name));
6
+ const missingRequiredFileInput = fileInputs.filter((input) => input.required).some((input) => !options.files.some((file) => file.inputName === input.name));
7
+ const missingRequiredTextInput = textInputs.filter((input) => input.required).some((input) => (options.inputTexts[input.name] ?? "").trim().length === 0);
8
+ const hasUnmappedFiles = fileInputs.length > 0 && options.files.some((file) => !file.inputName || !fileInputNames.has(file.inputName));
9
+ const missingRequiredInputs = missingRequiredFileInput || missingRequiredTextInput;
10
+ return {
11
+ ready: !missingRequiredInputs && !hasUnmappedFiles,
12
+ missingRequiredInputs,
13
+ hasUnmappedFiles
14
+ };
15
+ }
@@ -0,0 +1,9 @@
1
+ import { type Component } from 'vue';
2
+ import type { BaseNode } from 'markstream-vue';
3
+ export type CustomMarkdownNode = BaseNode & {
4
+ attrs?: [string, unknown][];
5
+ content?: string;
6
+ };
7
+ export declare function customMarkdownNodeProps(node: CustomMarkdownNode): Record<string, unknown>;
8
+ export declare function wrapCustomMarkdownComponent(component: Component, tagName?: string): Component;
9
+ export declare function wrapCustomMarkdownComponents(components: Record<string, Component>): Record<string, Component>;
@@ -0,0 +1,54 @@
1
+ import { defineComponent, h } from "vue";
2
+ function camelizeAttributeName(name) {
3
+ return name.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase());
4
+ }
5
+ export function customMarkdownNodeProps(node) {
6
+ const attrProps = {};
7
+ for (const attr of node.attrs ?? []) {
8
+ const [name, value] = attr;
9
+ if (!name)
10
+ continue;
11
+ const propName = camelizeAttributeName(name);
12
+ if (propName === "node")
13
+ continue;
14
+ attrProps[propName] = value;
15
+ }
16
+ return { node, ...attrProps };
17
+ }
18
+ function customMarkdownComponentAdapterName(tagName, component) {
19
+ if (typeof component === "function" && component.name)
20
+ return component.name;
21
+ if (typeof component === "object" && component) {
22
+ const namedComponent = component;
23
+ return namedComponent.displayName ?? namedComponent.name ?? tagName;
24
+ }
25
+ return tagName;
26
+ }
27
+ export function wrapCustomMarkdownComponent(component, tagName = "unknown") {
28
+ return defineComponent({
29
+ name: `CustomMarkdownComponentAdapter(${customMarkdownComponentAdapterName(tagName, component)})`,
30
+ props: {
31
+ node: {
32
+ type: Object,
33
+ required: true
34
+ }
35
+ },
36
+ setup(props, { attrs }) {
37
+ return () => h(
38
+ component,
39
+ {
40
+ ...attrs,
41
+ ...customMarkdownNodeProps(props.node)
42
+ },
43
+ {
44
+ default: () => props.node.content ?? ""
45
+ }
46
+ );
47
+ }
48
+ });
49
+ }
50
+ export function wrapCustomMarkdownComponents(components) {
51
+ return Object.fromEntries(
52
+ Object.entries(components).map(([name, component]) => [name, wrapCustomMarkdownComponent(component, name)])
53
+ );
54
+ }
@@ -3,4 +3,13 @@ export interface ResolvedChatNuxtFeatures {
3
3
  generateTitle: boolean;
4
4
  credentials: boolean;
5
5
  }
6
+ export interface ChatNuxtFeatureRuntimeConfig {
7
+ public?: {
8
+ chatNuxtFeatures?: Partial<ResolvedChatNuxtFeatures>;
9
+ };
10
+ chatNuxt?: {
11
+ features?: Partial<ResolvedChatNuxtFeatures>;
12
+ };
13
+ }
14
+ export declare function resolveChatNuxtFeatures(config?: ChatNuxtFeatureRuntimeConfig): ResolvedChatNuxtFeatures;
6
15
  export declare function useChatNuxtFeatures(): ResolvedChatNuxtFeatures;
@@ -1,15 +1,16 @@
1
- import { useRuntimeConfig } from "#imports";
2
1
  const DEFAULTS = {
3
2
  usage: true,
4
3
  generateTitle: false,
5
4
  credentials: false
6
5
  };
7
- export function useChatNuxtFeatures() {
8
- const config = useRuntimeConfig();
9
- const features = config.public.chatNuxtFeatures;
6
+ export function resolveChatNuxtFeatures(config = {}) {
7
+ const features = config.chatNuxt?.features ?? config.public?.chatNuxtFeatures;
10
8
  return {
11
9
  usage: features?.usage ?? DEFAULTS.usage,
12
10
  generateTitle: features?.generateTitle ?? DEFAULTS.generateTitle,
13
11
  credentials: features?.credentials ?? DEFAULTS.credentials
14
12
  };
15
13
  }
14
+ export function useChatNuxtFeatures() {
15
+ return resolveChatNuxtFeatures(useRuntimeConfig());
16
+ }
@@ -3,6 +3,7 @@ const VAULT_REGEX = /(?<!\]\()vault:\/\/[^\s"'<>`\[\]()*_~]+/gi;
3
3
  const URL_REGEX = /https?:\/\/[^\s"'<>`\[\]()*_~]+/gi;
4
4
  const VAULT_PATTERN = new RegExp(`vault://${URL_CHAR_CLASS}`, "gi");
5
5
  const VAULT_PERMALINK_PATTERN = new RegExp(`https://(?:[a-z0-9-]+\\.)*(?:vault|api)\\.tela(?:staging)?\\.com/(?:[a-z0-9_-]+/)*permalinks/${URL_CHAR_CLASS}`, "gi");
6
+ const MARKDOWN_LINK_PATTERN = /\[([^\]\n]*)\]\(([^)\s]+)(?:\s+["'][^)]*["'])?\)/g;
6
7
  const FILE_EXTENSIONS = {
7
8
  pdf: "application/pdf",
8
9
  doc: "application/msword",
@@ -257,12 +258,44 @@ function getPermalinkId(url) {
257
258
  const match = url.match(/permalinks\/([a-f0-9-]+)/);
258
259
  return match?.[1] ?? "Arquivo";
259
260
  }
261
+ function overlapsFileMatch(start, end, fileMatches) {
262
+ return fileMatches.some((fileMatch) => start < fileMatch.end && end > fileMatch.start);
263
+ }
264
+ function collectMarkdownFileLinkMatches(text) {
265
+ const matches = [];
266
+ for (const match of text.matchAll(MARKDOWN_LINK_PATTERN)) {
267
+ const start = match.index;
268
+ if (text[start - 1] === "!")
269
+ continue;
270
+ const href = match[2];
271
+ if (!href)
272
+ continue;
273
+ const file = detectFileFromUrl(href);
274
+ if (!file)
275
+ continue;
276
+ matches.push({
277
+ start,
278
+ end: start + match[0].length,
279
+ file
280
+ });
281
+ }
282
+ return matches;
283
+ }
260
284
  function detectFilesInText(text) {
261
285
  const files = [];
262
286
  const seen = /* @__PURE__ */ new Set();
263
- const vaultMatches = text.match(VAULT_REGEX) ?? [];
264
- for (const rawMatch of vaultMatches) {
265
- const match = stripTrailingPunctuation(rawMatch);
287
+ const markdownFileLinkMatches = collectMarkdownFileLinkMatches(text);
288
+ for (const { file } of markdownFileLinkMatches) {
289
+ if (seen.has(file.reference))
290
+ continue;
291
+ seen.add(file.reference);
292
+ files.push(file);
293
+ }
294
+ for (const rawMatch of text.matchAll(VAULT_REGEX)) {
295
+ const match = stripTrailingPunctuation(rawMatch[0]);
296
+ const start = rawMatch.index;
297
+ if (overlapsFileMatch(start, start + match.length, markdownFileLinkMatches))
298
+ continue;
266
299
  if (seen.has(match))
267
300
  continue;
268
301
  seen.add(match);
@@ -278,9 +311,11 @@ function detectFilesInText(text) {
278
311
  hashParams
279
312
  });
280
313
  }
281
- const urlMatches = text.match(URL_REGEX) ?? [];
282
- for (const rawMatch of urlMatches) {
283
- const match = stripTrailingPunctuation(rawMatch);
314
+ for (const rawMatch of text.matchAll(URL_REGEX)) {
315
+ const match = stripTrailingPunctuation(rawMatch[0]);
316
+ const start = rawMatch.index;
317
+ if (overlapsFileMatch(start, start + match.length, markdownFileLinkMatches))
318
+ continue;
284
319
  if (seen.has(match))
285
320
  continue;
286
321
  if (isVaultS3Url(match)) {
@@ -320,10 +355,12 @@ function detectFilesInText(text) {
320
355
  }
321
356
  function parseContentWithFiles(text) {
322
357
  const segments = [];
323
- const fileMatches = [];
358
+ const fileMatches = collectMarkdownFileLinkMatches(text);
324
359
  for (const match of text.matchAll(VAULT_REGEX)) {
325
360
  const rawUrl = match[0];
326
361
  const url = stripTrailingPunctuation(rawUrl);
362
+ if (overlapsFileMatch(match.index, match.index + url.length, fileMatches))
363
+ continue;
327
364
  const hashParams = parseVaultHashParams(url);
328
365
  const filenameExt = hashParams?.filename?.split(".").pop()?.toLowerCase();
329
366
  const urlExt = getExtensionFromUrl(url);
@@ -343,6 +380,8 @@ function parseContentWithFiles(text) {
343
380
  for (const match of text.matchAll(URL_REGEX)) {
344
381
  const rawUrl = match[0];
345
382
  const url = stripTrailingPunctuation(rawUrl);
383
+ if (overlapsFileMatch(match.index, match.index + url.length, fileMatches))
384
+ continue;
346
385
  if (isVaultS3Url(url)) {
347
386
  const { name, mimeType } = getFileInfoFromVaultS3Url(url);
348
387
  fileMatches.push({
@@ -20,3 +20,4 @@ export interface MarkdownGenericNode {
20
20
  export type MarkdownNode = MarkdownCodeBlockNode | MarkdownMermaidNode | MarkdownGenericNode;
21
21
  export declare function transformMarkdownNodes<T>(value: T): T;
22
22
  export declare function extractMermaidSource(node: MarkdownNode | null | undefined): string | undefined;
23
+ export declare function jsonMarkdown(value: unknown): string;
@@ -38,3 +38,9 @@ export function extractMermaidSource(node) {
38
38
  }
39
39
  return normalizeMermaidSource(node);
40
40
  }
41
+ export function jsonMarkdown(value) {
42
+ const json = JSON.stringify(value, null, 2);
43
+ return json ? `\`\`\`json
44
+ ${json}
45
+ \`\`\`` : "";
46
+ }
@@ -1,10 +1,14 @@
1
1
  export type ChatFeatureConfig = {
2
2
  showUsageTab?: boolean;
3
3
  showDebugOption?: boolean;
4
+ showModelSelector?: boolean;
5
+ showCancelButton?: boolean;
4
6
  };
5
7
  export type ResolvedChatFeatureConfig = {
6
8
  showUsageTab: boolean;
7
9
  showDebugOption: boolean;
10
+ showModelSelector: boolean;
11
+ showCancelButton: boolean;
8
12
  };
9
13
  export type ChatActor = {
10
14
  name?: string | null;
@@ -12,6 +16,8 @@ export type ChatActor = {
12
16
  image?: string | null;
13
17
  };
14
18
  export declare function normalizeConversationId(value: string | null | undefined): string | null;
19
+ export declare function normalizeTelaAgentId(value: string | null | undefined): string | null;
20
+ export declare function resolveChatStateScope(workspaceId: string | null | undefined, telaAgentId: string | null | undefined): string;
15
21
  export declare function resolveChatFeatures(features?: Partial<ChatFeatureConfig>): ResolvedChatFeatureConfig;
16
22
  export declare function resolveConversationCreator(conversationUserId: string | null | undefined, options: {
17
23
  currentUser?: ChatActor | null;