@meistrari/chat-nuxt 1.12.0 → 1.13.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/components/chat/reasoning-message.vue +4 -1
- package/dist/runtime/composables/useVerbConjugation.d.ts +1 -0
- package/dist/runtime/composables/useVerbConjugation.js +14 -1
- package/dist/runtime/server/api/conversations/[id]/messages/[messageId]/retry.post.js +2 -0
- package/dist/runtime/server/api/conversations/[id]/messages/index.get.js +26 -4
- package/dist/runtime/server/db/schema/messages.d.ts +34 -0
- package/dist/runtime/server/db/schema/messages.js +3 -1
- package/dist/runtime/server/utils/conversation-message-sync.d.ts +1 -1
- package/dist/runtime/server/utils/conversation-message-sync.js +2 -2
- package/dist/runtime/server/utils/tela-agent-api.d.ts +3 -1
- package/dist/runtime/server/utils/tela-agent-api.js +285 -26
- package/dist/runtime/server/utils/tela-agent-session.d.ts +14 -4
- package/dist/runtime/server/utils/tela-agent-session.js +57 -22
- package/dist/runtime/types/tela-agent.d.ts +155 -43
- package/dist/runtime/types/tela-agent.js +49 -11
- package/drizzle/0017_typical_dexter_bennett.sql +2 -0
- package/drizzle/meta/0017_snapshot.json +899 -0
- package/drizzle/meta/_journal.json +7 -0
- package/package.json +1 -1
|
@@ -43,7 +43,7 @@ export function toTelaAgentAttachments(files) {
|
|
|
43
43
|
}));
|
|
44
44
|
}
|
|
45
45
|
export function getTelaAgentStepSyncId(step) {
|
|
46
|
-
return step.eventId ?? step.id;
|
|
46
|
+
return step.eventId ?? step.id ?? null;
|
|
47
47
|
}
|
|
48
48
|
function isRecord(value) {
|
|
49
49
|
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
@@ -251,6 +251,9 @@ function getStepText(step) {
|
|
|
251
251
|
return null;
|
|
252
252
|
}
|
|
253
253
|
export function normalizeTelaAgentReasoningStep(sessionId, step) {
|
|
254
|
+
const syncId = getTelaAgentStepSyncId(step);
|
|
255
|
+
if (!syncId)
|
|
256
|
+
return null;
|
|
254
257
|
const content = normalizeStepMessageContent(step);
|
|
255
258
|
if (content.length === 0)
|
|
256
259
|
return null;
|
|
@@ -264,7 +267,7 @@ export function normalizeTelaAgentReasoningStep(sessionId, step) {
|
|
|
264
267
|
const parentToolUseId = getStringProperty(record, "parent_tool_use_id");
|
|
265
268
|
return {
|
|
266
269
|
type,
|
|
267
|
-
uuid:
|
|
270
|
+
uuid: syncId,
|
|
268
271
|
message: {
|
|
269
272
|
role: role ?? (type === "user" ? "user" : "assistant"),
|
|
270
273
|
content
|
|
@@ -275,40 +278,70 @@ export function normalizeTelaAgentReasoningStep(sessionId, step) {
|
|
|
275
278
|
parent_tool_use_id: parentToolUseId
|
|
276
279
|
};
|
|
277
280
|
}
|
|
278
|
-
export function
|
|
279
|
-
if (!lastSyncedStepId)
|
|
280
|
-
return session.steps;
|
|
281
|
-
const lastSyncedIndex = session.steps.findIndex((step) => getTelaAgentStepSyncId(step) === lastSyncedStepId);
|
|
282
|
-
return session.steps.slice(lastSyncedIndex + 1);
|
|
283
|
-
}
|
|
284
|
-
export function extractTelaAgentAssistantContent(session, steps = session.steps) {
|
|
281
|
+
export function extractTelaAgentAssistantContent(session) {
|
|
285
282
|
const structuredContent = session.result?.structuredContent;
|
|
286
283
|
if (structuredContent)
|
|
287
284
|
return sanitizeText(jsonMarkdown(structuredContent));
|
|
288
285
|
if (session.result?.content)
|
|
289
286
|
return normalizeTelaAgentResultContent(session.result.content);
|
|
290
|
-
for (let i = steps.length - 1; i >= 0; i--) {
|
|
291
|
-
const text = getStepText(steps[i]);
|
|
287
|
+
for (let i = session.steps.length - 1; i >= 0; i--) {
|
|
288
|
+
const text = getStepText(session.steps[i]);
|
|
292
289
|
if (text)
|
|
293
290
|
return text;
|
|
294
291
|
}
|
|
295
292
|
return "";
|
|
296
293
|
}
|
|
294
|
+
export function resolveTelaAgentRequestCursor(options) {
|
|
295
|
+
if (typeof options.pendingMessage.agentSessionCursor === "number")
|
|
296
|
+
return options.pendingMessage.agentSessionCursor;
|
|
297
|
+
const lastTerminalMessage = options.lastTerminalMessage;
|
|
298
|
+
if (lastTerminalMessage && lastTerminalMessage.agentSessionId === options.threadSessionId && typeof lastTerminalMessage.agentSessionCursor === "number") {
|
|
299
|
+
return lastTerminalMessage.agentSessionCursor;
|
|
300
|
+
}
|
|
301
|
+
return void 0;
|
|
302
|
+
}
|
|
297
303
|
export function mapTelaAgentSessionToMessageUpdate(session, options = {}) {
|
|
298
304
|
const now = options.now ?? /* @__PURE__ */ new Date();
|
|
299
|
-
const
|
|
300
|
-
const
|
|
301
|
-
const
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
305
|
+
const reasoningData = session.steps.map((step) => normalizeTelaAgentReasoningStep(session.sessionId, step)).filter((step) => Boolean(step));
|
|
306
|
+
const accumulatedReasoningData = [...options.existingReasoningData ?? []];
|
|
307
|
+
const reasoningIndexes = new Map(accumulatedReasoningData.map((item, index) => [item.uuid, index]));
|
|
308
|
+
const changedReasoningData = [];
|
|
309
|
+
for (const item of reasoningData) {
|
|
310
|
+
const existingIndex = reasoningIndexes.get(item.uuid);
|
|
311
|
+
if (existingIndex === void 0) {
|
|
312
|
+
reasoningIndexes.set(item.uuid, accumulatedReasoningData.length);
|
|
313
|
+
accumulatedReasoningData.push(item);
|
|
314
|
+
changedReasoningData.push(item);
|
|
315
|
+
continue;
|
|
316
|
+
}
|
|
317
|
+
const existingItem = accumulatedReasoningData[existingIndex];
|
|
318
|
+
const existingContent = JSON.stringify({
|
|
319
|
+
type: existingItem.type,
|
|
320
|
+
message: existingItem.message,
|
|
321
|
+
parent_tool_use_id: existingItem.parent_tool_use_id
|
|
322
|
+
});
|
|
323
|
+
const nextContent = JSON.stringify({
|
|
324
|
+
type: item.type,
|
|
325
|
+
message: item.message,
|
|
326
|
+
parent_tool_use_id: item.parent_tool_use_id
|
|
327
|
+
});
|
|
328
|
+
if (existingContent !== nextContent) {
|
|
329
|
+
accumulatedReasoningData[existingIndex] = item;
|
|
330
|
+
changedReasoningData.push(item);
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
const lastChangedReasoning = changedReasoningData.at(-1);
|
|
306
334
|
const update = {};
|
|
307
|
-
|
|
335
|
+
const nextCursor = typeof session.nextCursor === "number" ? session.nextCursor : void 0;
|
|
336
|
+
if (nextCursor !== void 0) {
|
|
337
|
+
update.agentSessionCursor = nextCursor;
|
|
338
|
+
update.agentSessionId = session.sessionId;
|
|
339
|
+
}
|
|
340
|
+
if (changedReasoningData.length > 0)
|
|
308
341
|
update.reasoningData = accumulatedReasoningData;
|
|
309
|
-
if (
|
|
310
|
-
update.externalUuid =
|
|
311
|
-
if (!options.pendingMessageTtft && options.userMessageCreatedAt &&
|
|
342
|
+
if (lastChangedReasoning)
|
|
343
|
+
update.externalUuid = lastChangedReasoning.uuid;
|
|
344
|
+
if (!options.pendingMessageTtft && options.userMessageCreatedAt && changedReasoningData.length > 0) {
|
|
312
345
|
update.ttft = String(now.getTime() - options.userMessageCreatedAt.getTime());
|
|
313
346
|
}
|
|
314
347
|
if (session.status === "completed" || session.status === "waiting_messages") {
|
|
@@ -323,6 +356,8 @@ export function mapTelaAgentSessionToMessageUpdate(session, options = {}) {
|
|
|
323
356
|
update.content = INTERRUPTED_GENERATION_TEXT;
|
|
324
357
|
update.status = "completed";
|
|
325
358
|
update.updatedAt = now;
|
|
359
|
+
} else if (changedReasoningData.length > 0 || nextCursor !== void 0) {
|
|
360
|
+
update.updatedAt = now;
|
|
326
361
|
}
|
|
327
362
|
return update;
|
|
328
363
|
}
|
|
@@ -101,7 +101,7 @@ export declare const telaAgentSessionStatusSchema: z.ZodEnum<{
|
|
|
101
101
|
}>;
|
|
102
102
|
export type TelaAgentSessionStatus = z.infer<typeof telaAgentSessionStatusSchema>;
|
|
103
103
|
export declare const telaAgentStepSchema: z.ZodObject<{
|
|
104
|
-
id: z.ZodString
|
|
104
|
+
id: z.ZodOptional<z.ZodString>;
|
|
105
105
|
eventId: z.ZodOptional<z.ZodString>;
|
|
106
106
|
inputTokens: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
107
107
|
outputTokens: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
@@ -120,6 +120,22 @@ export declare const telaAgentUsageSchema: z.ZodObject<{
|
|
|
120
120
|
promptCost: z.ZodOptional<z.ZodNumber>;
|
|
121
121
|
totalCost: z.ZodOptional<z.ZodNumber>;
|
|
122
122
|
}, z.core.$catchall<z.ZodUnknown>>;
|
|
123
|
+
export declare const telaAgentSessionResultSchema: z.ZodObject<{
|
|
124
|
+
usage: z.ZodOptional<z.ZodObject<{
|
|
125
|
+
duration: z.ZodOptional<z.ZodNumber>;
|
|
126
|
+
turns: z.ZodOptional<z.ZodNumber>;
|
|
127
|
+
completionTokens: z.ZodOptional<z.ZodNumber>;
|
|
128
|
+
promptTokens: z.ZodOptional<z.ZodNumber>;
|
|
129
|
+
totalTokens: z.ZodOptional<z.ZodNumber>;
|
|
130
|
+
completionCost: z.ZodOptional<z.ZodNumber>;
|
|
131
|
+
promptCost: z.ZodOptional<z.ZodNumber>;
|
|
132
|
+
totalCost: z.ZodOptional<z.ZodNumber>;
|
|
133
|
+
}, z.core.$catchall<z.ZodUnknown>>>;
|
|
134
|
+
usageBreakdown: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
135
|
+
content: z.ZodOptional<z.ZodString>;
|
|
136
|
+
structuredContent: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
137
|
+
childEventIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
138
|
+
}, z.core.$catchall<z.ZodUnknown>>;
|
|
123
139
|
export declare const telaAgentSessionSchema: z.ZodObject<{
|
|
124
140
|
sessionId: z.ZodString;
|
|
125
141
|
status: z.ZodEnum<{
|
|
@@ -131,7 +147,7 @@ export declare const telaAgentSessionSchema: z.ZodObject<{
|
|
|
131
147
|
cancelled: "cancelled";
|
|
132
148
|
}>;
|
|
133
149
|
steps: z.ZodArray<z.ZodObject<{
|
|
134
|
-
id: z.ZodString
|
|
150
|
+
id: z.ZodOptional<z.ZodString>;
|
|
135
151
|
eventId: z.ZodOptional<z.ZodString>;
|
|
136
152
|
inputTokens: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
137
153
|
outputTokens: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
@@ -151,6 +167,7 @@ export declare const telaAgentSessionSchema: z.ZodObject<{
|
|
|
151
167
|
promptCost: z.ZodOptional<z.ZodNumber>;
|
|
152
168
|
totalCost: z.ZodOptional<z.ZodNumber>;
|
|
153
169
|
}, z.core.$catchall<z.ZodUnknown>>>;
|
|
170
|
+
usageBreakdown: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
154
171
|
content: z.ZodOptional<z.ZodString>;
|
|
155
172
|
structuredContent: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
156
173
|
childEventIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
@@ -160,6 +177,142 @@ export declare const telaAgentSessionSchema: z.ZodObject<{
|
|
|
160
177
|
updatedAt: z.ZodOptional<z.ZodNumber>;
|
|
161
178
|
}, z.core.$catchall<z.ZodUnknown>>;
|
|
162
179
|
export type TelaAgentSession = z.infer<typeof telaAgentSessionSchema>;
|
|
180
|
+
export declare const telaAgentV4SessionStatusEventSchema: z.ZodObject<{
|
|
181
|
+
kind: z.ZodLiteral<"status">;
|
|
182
|
+
sessionId: z.ZodString;
|
|
183
|
+
status: z.ZodEnum<{
|
|
184
|
+
pending: "pending";
|
|
185
|
+
running: "running";
|
|
186
|
+
failed: "failed";
|
|
187
|
+
cancelled: "cancelled";
|
|
188
|
+
}>;
|
|
189
|
+
error: z.ZodOptional<z.ZodString>;
|
|
190
|
+
createdAt: z.ZodNumber;
|
|
191
|
+
updatedAt: z.ZodNumber;
|
|
192
|
+
}, z.core.$catchall<z.ZodUnknown>>;
|
|
193
|
+
export declare const telaAgentV4SessionStepsEventSchema: z.ZodObject<{
|
|
194
|
+
kind: z.ZodLiteral<"steps">;
|
|
195
|
+
sessionId: z.ZodString;
|
|
196
|
+
status: z.ZodEnum<{
|
|
197
|
+
pending: "pending";
|
|
198
|
+
running: "running";
|
|
199
|
+
completed: "completed";
|
|
200
|
+
failed: "failed";
|
|
201
|
+
waiting_messages: "waiting_messages";
|
|
202
|
+
cancelled: "cancelled";
|
|
203
|
+
}>;
|
|
204
|
+
steps: z.ZodArray<z.ZodObject<{
|
|
205
|
+
id: z.ZodOptional<z.ZodString>;
|
|
206
|
+
eventId: z.ZodOptional<z.ZodString>;
|
|
207
|
+
inputTokens: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
208
|
+
outputTokens: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
209
|
+
cacheReadInputTokens: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
210
|
+
cacheCreationInputTokens: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
211
|
+
calculatedCostUsd: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
212
|
+
}, z.core.$catchall<z.ZodUnknown>>>;
|
|
213
|
+
nextCursor: z.ZodNullable<z.ZodNumber>;
|
|
214
|
+
createdAt: z.ZodNumber;
|
|
215
|
+
updatedAt: z.ZodNumber;
|
|
216
|
+
}, z.core.$catchall<z.ZodUnknown>>;
|
|
217
|
+
export declare const telaAgentV4SessionResultEventSchema: z.ZodObject<{
|
|
218
|
+
kind: z.ZodLiteral<"result">;
|
|
219
|
+
sessionId: z.ZodString;
|
|
220
|
+
status: z.ZodEnum<{
|
|
221
|
+
completed: "completed";
|
|
222
|
+
waiting_messages: "waiting_messages";
|
|
223
|
+
}>;
|
|
224
|
+
result: z.ZodObject<{
|
|
225
|
+
usage: z.ZodOptional<z.ZodObject<{
|
|
226
|
+
duration: z.ZodOptional<z.ZodNumber>;
|
|
227
|
+
turns: z.ZodOptional<z.ZodNumber>;
|
|
228
|
+
completionTokens: z.ZodOptional<z.ZodNumber>;
|
|
229
|
+
promptTokens: z.ZodOptional<z.ZodNumber>;
|
|
230
|
+
totalTokens: z.ZodOptional<z.ZodNumber>;
|
|
231
|
+
completionCost: z.ZodOptional<z.ZodNumber>;
|
|
232
|
+
promptCost: z.ZodOptional<z.ZodNumber>;
|
|
233
|
+
totalCost: z.ZodOptional<z.ZodNumber>;
|
|
234
|
+
}, z.core.$catchall<z.ZodUnknown>>>;
|
|
235
|
+
usageBreakdown: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
236
|
+
content: z.ZodOptional<z.ZodString>;
|
|
237
|
+
structuredContent: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
238
|
+
childEventIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
239
|
+
}, z.core.$catchall<z.ZodUnknown>>;
|
|
240
|
+
nextCursor: z.ZodNullable<z.ZodNumber>;
|
|
241
|
+
createdAt: z.ZodNumber;
|
|
242
|
+
updatedAt: z.ZodNumber;
|
|
243
|
+
}, z.core.$catchall<z.ZodUnknown>>;
|
|
244
|
+
export declare const telaAgentV4SessionErrorEventSchema: z.ZodObject<{
|
|
245
|
+
kind: z.ZodLiteral<"error">;
|
|
246
|
+
sessionId: z.ZodString;
|
|
247
|
+
error: z.ZodString;
|
|
248
|
+
}, z.core.$catchall<z.ZodUnknown>>;
|
|
249
|
+
export declare const telaAgentV4SessionStreamEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
250
|
+
kind: z.ZodLiteral<"status">;
|
|
251
|
+
sessionId: z.ZodString;
|
|
252
|
+
status: z.ZodEnum<{
|
|
253
|
+
pending: "pending";
|
|
254
|
+
running: "running";
|
|
255
|
+
failed: "failed";
|
|
256
|
+
cancelled: "cancelled";
|
|
257
|
+
}>;
|
|
258
|
+
error: z.ZodOptional<z.ZodString>;
|
|
259
|
+
createdAt: z.ZodNumber;
|
|
260
|
+
updatedAt: z.ZodNumber;
|
|
261
|
+
}, z.core.$catchall<z.ZodUnknown>>, z.ZodObject<{
|
|
262
|
+
kind: z.ZodLiteral<"steps">;
|
|
263
|
+
sessionId: z.ZodString;
|
|
264
|
+
status: z.ZodEnum<{
|
|
265
|
+
pending: "pending";
|
|
266
|
+
running: "running";
|
|
267
|
+
completed: "completed";
|
|
268
|
+
failed: "failed";
|
|
269
|
+
waiting_messages: "waiting_messages";
|
|
270
|
+
cancelled: "cancelled";
|
|
271
|
+
}>;
|
|
272
|
+
steps: z.ZodArray<z.ZodObject<{
|
|
273
|
+
id: z.ZodOptional<z.ZodString>;
|
|
274
|
+
eventId: z.ZodOptional<z.ZodString>;
|
|
275
|
+
inputTokens: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
276
|
+
outputTokens: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
277
|
+
cacheReadInputTokens: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
278
|
+
cacheCreationInputTokens: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
279
|
+
calculatedCostUsd: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
280
|
+
}, z.core.$catchall<z.ZodUnknown>>>;
|
|
281
|
+
nextCursor: z.ZodNullable<z.ZodNumber>;
|
|
282
|
+
createdAt: z.ZodNumber;
|
|
283
|
+
updatedAt: z.ZodNumber;
|
|
284
|
+
}, z.core.$catchall<z.ZodUnknown>>, z.ZodObject<{
|
|
285
|
+
kind: z.ZodLiteral<"result">;
|
|
286
|
+
sessionId: z.ZodString;
|
|
287
|
+
status: z.ZodEnum<{
|
|
288
|
+
completed: "completed";
|
|
289
|
+
waiting_messages: "waiting_messages";
|
|
290
|
+
}>;
|
|
291
|
+
result: z.ZodObject<{
|
|
292
|
+
usage: z.ZodOptional<z.ZodObject<{
|
|
293
|
+
duration: z.ZodOptional<z.ZodNumber>;
|
|
294
|
+
turns: z.ZodOptional<z.ZodNumber>;
|
|
295
|
+
completionTokens: z.ZodOptional<z.ZodNumber>;
|
|
296
|
+
promptTokens: z.ZodOptional<z.ZodNumber>;
|
|
297
|
+
totalTokens: z.ZodOptional<z.ZodNumber>;
|
|
298
|
+
completionCost: z.ZodOptional<z.ZodNumber>;
|
|
299
|
+
promptCost: z.ZodOptional<z.ZodNumber>;
|
|
300
|
+
totalCost: z.ZodOptional<z.ZodNumber>;
|
|
301
|
+
}, z.core.$catchall<z.ZodUnknown>>>;
|
|
302
|
+
usageBreakdown: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
303
|
+
content: z.ZodOptional<z.ZodString>;
|
|
304
|
+
structuredContent: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
305
|
+
childEventIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
306
|
+
}, z.core.$catchall<z.ZodUnknown>>;
|
|
307
|
+
nextCursor: z.ZodNullable<z.ZodNumber>;
|
|
308
|
+
createdAt: z.ZodNumber;
|
|
309
|
+
updatedAt: z.ZodNumber;
|
|
310
|
+
}, z.core.$catchall<z.ZodUnknown>>, z.ZodObject<{
|
|
311
|
+
kind: z.ZodLiteral<"error">;
|
|
312
|
+
sessionId: z.ZodString;
|
|
313
|
+
error: z.ZodString;
|
|
314
|
+
}, z.core.$catchall<z.ZodUnknown>>], "kind">;
|
|
315
|
+
export type TelaAgentV4SessionStreamEvent = z.infer<typeof telaAgentV4SessionStreamEventSchema>;
|
|
163
316
|
export declare const telaAgentRunApiResponseSchema: z.ZodObject<{
|
|
164
317
|
data: z.ZodObject<{
|
|
165
318
|
sessionId: z.ZodString;
|
|
@@ -195,47 +348,6 @@ export declare const telaAgentApiResponseSchema: z.ZodObject<{
|
|
|
195
348
|
isMultiturn: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
196
349
|
}, z.core.$catchall<z.ZodUnknown>>;
|
|
197
350
|
}, 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
351
|
export declare const telaAgentEndSessionApiResponseSchema: z.ZodObject<{
|
|
240
352
|
data: z.ZodObject<{
|
|
241
353
|
success: z.ZodBoolean;
|
|
@@ -49,14 +49,16 @@ export const telaAgentSessionStatusSchema = z.enum([
|
|
|
49
49
|
"cancelled"
|
|
50
50
|
]);
|
|
51
51
|
export const telaAgentStepSchema = z.object({
|
|
52
|
-
id: z.string(),
|
|
52
|
+
id: z.string().optional(),
|
|
53
53
|
eventId: z.string().optional(),
|
|
54
54
|
inputTokens: z.number().nullable().optional(),
|
|
55
55
|
outputTokens: z.number().nullable().optional(),
|
|
56
56
|
cacheReadInputTokens: z.number().nullable().optional(),
|
|
57
57
|
cacheCreationInputTokens: z.number().nullable().optional(),
|
|
58
58
|
calculatedCostUsd: z.number().nullable().optional()
|
|
59
|
-
}).catchall(z.unknown())
|
|
59
|
+
}).catchall(z.unknown()).refine((step) => Boolean(step.id || step.eventId), {
|
|
60
|
+
message: "Tela agent step must include id or eventId"
|
|
61
|
+
});
|
|
60
62
|
export const telaAgentUsageSchema = z.object({
|
|
61
63
|
duration: z.number().optional(),
|
|
62
64
|
turns: z.number().optional(),
|
|
@@ -67,30 +69,66 @@ export const telaAgentUsageSchema = z.object({
|
|
|
67
69
|
promptCost: z.number().optional(),
|
|
68
70
|
totalCost: z.number().optional()
|
|
69
71
|
}).catchall(z.unknown());
|
|
72
|
+
export const telaAgentSessionResultSchema = z.object({
|
|
73
|
+
usage: telaAgentUsageSchema.optional(),
|
|
74
|
+
usageBreakdown: z.record(z.string(), z.unknown()).optional(),
|
|
75
|
+
content: z.string().optional(),
|
|
76
|
+
structuredContent: z.record(z.string(), z.unknown()).optional(),
|
|
77
|
+
childEventIds: z.array(z.string()).optional()
|
|
78
|
+
}).catchall(z.unknown());
|
|
70
79
|
export const telaAgentSessionSchema = z.object({
|
|
71
80
|
sessionId: z.string(),
|
|
72
81
|
status: telaAgentSessionStatusSchema,
|
|
73
82
|
steps: z.array(telaAgentStepSchema),
|
|
74
83
|
nextCursor: z.number().nullable().optional(),
|
|
75
|
-
result:
|
|
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(),
|
|
84
|
+
result: telaAgentSessionResultSchema.optional(),
|
|
81
85
|
error: z.string().optional(),
|
|
82
86
|
createdAt: z.number().optional(),
|
|
83
87
|
updatedAt: z.number().optional()
|
|
84
88
|
}).catchall(z.unknown());
|
|
89
|
+
export const telaAgentV4SessionStatusEventSchema = z.object({
|
|
90
|
+
kind: z.literal("status"),
|
|
91
|
+
sessionId: z.string(),
|
|
92
|
+
status: z.enum(["pending", "running", "failed", "cancelled"]),
|
|
93
|
+
error: z.string().optional(),
|
|
94
|
+
createdAt: z.number(),
|
|
95
|
+
updatedAt: z.number()
|
|
96
|
+
}).catchall(z.unknown());
|
|
97
|
+
export const telaAgentV4SessionStepsEventSchema = z.object({
|
|
98
|
+
kind: z.literal("steps"),
|
|
99
|
+
sessionId: z.string(),
|
|
100
|
+
status: telaAgentSessionStatusSchema,
|
|
101
|
+
steps: z.array(telaAgentStepSchema),
|
|
102
|
+
nextCursor: z.number().nullable(),
|
|
103
|
+
createdAt: z.number(),
|
|
104
|
+
updatedAt: z.number()
|
|
105
|
+
}).catchall(z.unknown());
|
|
106
|
+
export const telaAgentV4SessionResultEventSchema = z.object({
|
|
107
|
+
kind: z.literal("result"),
|
|
108
|
+
sessionId: z.string(),
|
|
109
|
+
status: z.enum(["completed", "waiting_messages"]),
|
|
110
|
+
result: telaAgentSessionResultSchema,
|
|
111
|
+
nextCursor: z.number().nullable(),
|
|
112
|
+
createdAt: z.number(),
|
|
113
|
+
updatedAt: z.number()
|
|
114
|
+
}).catchall(z.unknown());
|
|
115
|
+
export const telaAgentV4SessionErrorEventSchema = z.object({
|
|
116
|
+
kind: z.literal("error"),
|
|
117
|
+
sessionId: z.string(),
|
|
118
|
+
error: z.string()
|
|
119
|
+
}).catchall(z.unknown());
|
|
120
|
+
export const telaAgentV4SessionStreamEventSchema = z.discriminatedUnion("kind", [
|
|
121
|
+
telaAgentV4SessionStatusEventSchema,
|
|
122
|
+
telaAgentV4SessionStepsEventSchema,
|
|
123
|
+
telaAgentV4SessionResultEventSchema,
|
|
124
|
+
telaAgentV4SessionErrorEventSchema
|
|
125
|
+
]);
|
|
85
126
|
export const telaAgentRunApiResponseSchema = z.object({
|
|
86
127
|
data: telaAgentRunResponseSchema
|
|
87
128
|
}).catchall(z.unknown());
|
|
88
129
|
export const telaAgentApiResponseSchema = z.object({
|
|
89
130
|
data: telaAgentSchema
|
|
90
131
|
}).catchall(z.unknown());
|
|
91
|
-
export const telaAgentSessionApiResponseSchema = z.object({
|
|
92
|
-
data: telaAgentSessionSchema
|
|
93
|
-
}).catchall(z.unknown());
|
|
94
132
|
export const telaAgentEndSessionApiResponseSchema = z.object({
|
|
95
133
|
data: z.object({
|
|
96
134
|
success: z.boolean()
|