@meistrari/chat-nuxt 4.13.0-rc.8 → 4.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/embed/components/mobile/chat-mobile-shell.d.vue.ts +2 -2
- package/dist/runtime/embed/components/mobile/chat-mobile-shell.vue.d.ts +2 -2
- package/dist/runtime/files/components/chat-file-reference.vue +5 -2
- package/dist/runtime/files/components/chat-vault-link.vue +1 -1
- package/dist/runtime/files/file-reference.d.ts +7 -0
- package/dist/runtime/files/file-reference.js +8 -0
- package/dist/runtime/messages/components/chat-debug-widget-gallery.vue +13 -3
- package/dist/runtime/messages/tool-registry.js +7 -0
- package/dist/runtime/rendering/debug/widget-gallery.d.ts +2 -0
- package/dist/runtime/rendering/debug/widget-gallery.js +4 -0
- package/dist/runtime/types/schemas/chat/v3-mentions.d.ts +33 -0
- package/dist/runtime/types/schemas/chat/v3-mentions.js +96 -0
- package/dist/runtime/types/schemas/chat/v3.d.ts +494 -6
- package/dist/runtime/types/schemas/chat/v3.js +271 -13
- package/dist/runtime/types/schemas/integrations/agent-events.d.ts +246 -45
- package/dist/runtime/types/schemas/integrations/agent-events.js +101 -5
- package/package.json +2 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { parseV5EventHint, v5ArtifactPageSchema, v5EventIdSchema, v5HarnessSchema, v5Limits, v5SessionEventSchema, v5TurnIdSchema, v5UserInputRequestSchema, v5VaultReferenceSchema } from '../integrations/agent-events';
|
|
2
|
+
import { parseV5EventHint, v5ArtifactPageSchema, v5BranchNameSchema, v5EventIdSchema, v5HarnessSchema, v5InputNameSchema, v5Limits, v5ModelIdSchema, v5ReasoningEffortSchema, v5SessionEventSchema, v5TurnIdSchema, v5UserInputRequestSchema, v5VaultReferenceSchema } from '../integrations/agent-events';
|
|
3
3
|
/**
|
|
4
4
|
* Chat API v3 (`/v3/chat`): the conversational surface over agent-api v5 events-v1.
|
|
5
5
|
* The chat-api owns the thread; agent-api owns the session and its history.
|
|
@@ -16,6 +16,45 @@ export const chatV3AgentStatusSchema = z.enum([
|
|
|
16
16
|
/** Published: a session can start. */
|
|
17
17
|
'ready',
|
|
18
18
|
]);
|
|
19
|
+
/**
|
|
20
|
+
* An input the agent declares (its `input-schema.json`), at the commit a session runs. It has no
|
|
21
|
+
* default value: the host or the user gives it, and the session's first message has to carry
|
|
22
|
+
* every required one.
|
|
23
|
+
*/
|
|
24
|
+
export const chatV3AgentInputSchema = z.object({
|
|
25
|
+
name: z.string(),
|
|
26
|
+
type: z.enum(['text', 'file']),
|
|
27
|
+
required: z.boolean(),
|
|
28
|
+
description: z.string().nullable(),
|
|
29
|
+
});
|
|
30
|
+
/** A skill the user can trigger with `/`: a `SKILL.md` of the agent's repository at its published commit. */
|
|
31
|
+
export const chatV3SkillSchema = z.object({
|
|
32
|
+
name: z.string(),
|
|
33
|
+
description: z.string(),
|
|
34
|
+
/** Its `SKILL.md`, relative to the agent's repository. */
|
|
35
|
+
path: z.string(),
|
|
36
|
+
});
|
|
37
|
+
/** A file under the agent's `references/`, which the agent reads from its working tree. */
|
|
38
|
+
export const chatV3ContextFileSchema = z.object({
|
|
39
|
+
path: z.string(),
|
|
40
|
+
name: z.string(),
|
|
41
|
+
size: z.number().int().nonnegative().nullable(),
|
|
42
|
+
});
|
|
43
|
+
/**
|
|
44
|
+
* What `/` and `@` offer in a thread: the skills and context files of the commit its session runs,
|
|
45
|
+
* which an agent published again since does not change. Empty when the caller may not read the
|
|
46
|
+
* repository or agent-api fails to give it.
|
|
47
|
+
*/
|
|
48
|
+
export const chatV3ThreadCatalogSchema = z.object({
|
|
49
|
+
commitSha: z.string().nullable(),
|
|
50
|
+
skills: z.array(chatV3SkillSchema),
|
|
51
|
+
contextFiles: z.array(chatV3ContextFileSchema),
|
|
52
|
+
});
|
|
53
|
+
/**
|
|
54
|
+
* How the agent of a request was chosen, in the order v1 chooses it: the one the request names,
|
|
55
|
+
* the workspace's own agent (its v1 agent, by id), or the environment's default.
|
|
56
|
+
*/
|
|
57
|
+
export const chatV3AgentSourceSchema = z.enum(['request', 'workspace', 'default']);
|
|
19
58
|
export const chatV3AgentSchema = z.object({
|
|
20
59
|
agentId: z.string().uuid(),
|
|
21
60
|
repository: z.string(),
|
|
@@ -23,11 +62,25 @@ export const chatV3AgentSchema = z.object({
|
|
|
23
62
|
model: z.string().nullable(),
|
|
24
63
|
publishedSnapshotId: z.string().uuid().nullable(),
|
|
25
64
|
publishedCommitSha: z.string().nullable(),
|
|
65
|
+
/**
|
|
66
|
+
* The inputs the published commit declares, the ones a new thread's session will ask for.
|
|
67
|
+
* Empty when it declares none, and when they could not be read (a caller below the
|
|
68
|
+
* workspace's member role, or agent-api failing).
|
|
69
|
+
*/
|
|
70
|
+
inputs: z.array(chatV3AgentInputSchema),
|
|
71
|
+
/**
|
|
72
|
+
* What `/` and `@` offer, read from the published commit. Empty before a publication, and when
|
|
73
|
+
* the caller may not read the repository: they only add to the chat, so they never fail it.
|
|
74
|
+
*/
|
|
75
|
+
skills: z.array(chatV3SkillSchema),
|
|
76
|
+
contextFiles: z.array(chatV3ContextFileSchema),
|
|
26
77
|
});
|
|
27
78
|
export const chatV3ConfigurationSchema = z.object({
|
|
28
79
|
apiVersion: z.literal(3),
|
|
29
80
|
contractVersion: z.literal(CHAT_V3_CONTRACT_VERSION),
|
|
30
81
|
agentStatus: chatV3AgentStatusSchema,
|
|
82
|
+
/** `null` when no agent is named and there is neither a workspace agent nor a default one. */
|
|
83
|
+
agentSource: chatV3AgentSourceSchema.nullable(),
|
|
31
84
|
agent: chatV3AgentSchema.nullable(),
|
|
32
85
|
limits: z.object({
|
|
33
86
|
messageTextChars: z.number().int().positive(),
|
|
@@ -45,7 +98,19 @@ export const CHAT_V3_THREAD_PAGE = { default: 30, max: 100 };
|
|
|
45
98
|
const agentIdSchema = z.string().uuid().transform(id => id.toLowerCase());
|
|
46
99
|
/** A folder's id, lowercased like the agent's so the same folder always compares equal. */
|
|
47
100
|
const folderIdSchema = z.string().uuid().transform(id => id.toLowerCase());
|
|
48
|
-
/**
|
|
101
|
+
/** The effort a thread can choose, as agent-api takes it in a message's settings. */
|
|
102
|
+
export const chatV3ReasoningEffortSchema = v5ReasoningEffortSchema;
|
|
103
|
+
const SETTINGS_TOGETHER = 'Send model and reasoningEffort together, or neither.';
|
|
104
|
+
/** agent-api takes a message's model and effort as a pair: both given, both null, or both left out. */
|
|
105
|
+
function settingsTogether(body) {
|
|
106
|
+
return (body.model === undefined) === (body.reasoningEffort === undefined) && (body.model === null) === (body.reasoningEffort === null);
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* A thread as the chat owns it: access, title and the model chosen for it here, history in the
|
|
110
|
+
* agent-api session. `model` and `reasoningEffort` go as the settings of each message; both null
|
|
111
|
+
* runs the agent's own. Like a v1 conversation it belongs to the workspace, the agent and the
|
|
112
|
+
* host's scope: every member there sees it and can change it.
|
|
113
|
+
*/
|
|
49
114
|
export const chatV3ThreadSchema = z.object({
|
|
50
115
|
threadId: z.string().uuid(),
|
|
51
116
|
agentId: z.string().uuid(),
|
|
@@ -53,9 +118,25 @@ export const chatV3ThreadSchema = z.object({
|
|
|
53
118
|
title: z.string(),
|
|
54
119
|
/** The folder it is kept in; `null` outside any folder. */
|
|
55
120
|
folderId: z.string().uuid().nullable(),
|
|
121
|
+
model: z.string().nullable(),
|
|
122
|
+
reasoningEffort: chatV3ReasoningEffortSchema.nullable(),
|
|
123
|
+
/** The member who created it (user id), for the "mine" filter and the author in the list. */
|
|
124
|
+
createdBy: z.string(),
|
|
125
|
+
/** The host's scope it was created in (`x-chat-conversation-scope`); null outside a scoped host. */
|
|
126
|
+
scope: z.string().nullable(),
|
|
127
|
+
/** Moves when a message, a steer, an answer or a new title goes through the chat; lists are ordered by it. */
|
|
128
|
+
lastActivityAt: z.string(),
|
|
56
129
|
createdAt: z.string(),
|
|
57
130
|
updatedAt: z.string(),
|
|
58
131
|
});
|
|
132
|
+
/**
|
|
133
|
+
* `GET /threads/{id}/inputs`: the inputs the commit the thread's session pinned declares. They stay
|
|
134
|
+
* those of that commit after the agent is published again.
|
|
135
|
+
*/
|
|
136
|
+
export const chatV3ThreadInputsSchema = z.object({
|
|
137
|
+
commitSha: z.string(),
|
|
138
|
+
inputs: z.array(chatV3AgentInputSchema),
|
|
139
|
+
});
|
|
59
140
|
/** The session behind a thread, read live from agent-api; `null` when agent-api no longer has it. */
|
|
60
141
|
export const chatV3SessionSummarySchema = z.object({
|
|
61
142
|
status: z.string(),
|
|
@@ -64,31 +145,93 @@ export const chatV3SessionSummarySchema = z.object({
|
|
|
64
145
|
reasoningEffort: z.string().nullable(),
|
|
65
146
|
}).nullable();
|
|
66
147
|
export const chatV3ThreadDetailSchema = chatV3ThreadSchema.extend({ session: chatV3SessionSummarySchema });
|
|
67
|
-
/**
|
|
148
|
+
/**
|
|
149
|
+
* Creation also opens the agent-api session; send an `Idempotency-Key` header to retry safely.
|
|
150
|
+
* Without `agentId` the agent is chosen as v1 does: the workspace's own agent, else the default.
|
|
151
|
+
* `agentBranch` runs the head of that branch of the agent's repository instead of its publication;
|
|
152
|
+
* the session stays on that commit. The model and effort are optional, both or neither: agent-api
|
|
153
|
+
* checks them when a message goes.
|
|
154
|
+
*/
|
|
68
155
|
export const chatV3CreateThreadSchema = z.object({
|
|
69
|
-
agentId: agentIdSchema,
|
|
156
|
+
agentId: agentIdSchema.optional(),
|
|
157
|
+
agentBranch: v5BranchNameSchema.optional(),
|
|
70
158
|
title: z.string().trim().max(CHAT_V3_TITLE_CHARS).optional(),
|
|
71
159
|
/** Starts the thread inside this folder, which must be the agent's in the caller's scope. */
|
|
72
160
|
folderId: folderIdSchema.optional(),
|
|
73
|
-
|
|
74
|
-
|
|
161
|
+
model: v5ModelIdSchema.optional(),
|
|
162
|
+
reasoningEffort: chatV3ReasoningEffortSchema.optional(),
|
|
163
|
+
}).strict().refine(settingsTogether, { message: SETTINGS_TOGETHER, path: ['reasoningEffort'] });
|
|
164
|
+
/**
|
|
165
|
+
* Renames the thread, moves it into a folder (`folderId`) or out of one (`folderId: null`), changes
|
|
166
|
+
* its model and effort (both, or both null to go back to the agent's), or any of them; the last
|
|
167
|
+
* update wins. The next message runs with the new settings.
|
|
168
|
+
*/
|
|
75
169
|
export const chatV3UpdateThreadSchema = z.object({
|
|
76
170
|
title: z.string().trim().max(CHAT_V3_TITLE_CHARS).optional(),
|
|
77
171
|
folderId: folderIdSchema.nullable().optional(),
|
|
78
|
-
|
|
172
|
+
model: v5ModelIdSchema.nullable().optional(),
|
|
173
|
+
reasoningEffort: chatV3ReasoningEffortSchema.nullable().optional(),
|
|
174
|
+
}).strict().superRefine((body, ctx) => {
|
|
175
|
+
if (!settingsTogether(body))
|
|
176
|
+
ctx.addIssue({ code: 'custom', message: SETTINGS_TOGETHER, path: ['reasoningEffort'] });
|
|
177
|
+
else if (body.title === undefined && body.folderId === undefined && body.model === undefined)
|
|
178
|
+
ctx.addIssue({ code: 'custom', message: 'Send a title, a folderId, or a model and reasoningEffort.' });
|
|
179
|
+
});
|
|
180
|
+
/** Whose threads a list shows, as v1's `creator`: `all` (the default) or `me`, the caller's own. */
|
|
181
|
+
export const chatV3ThreadCreatorSchema = z.enum(['all', 'me']);
|
|
79
182
|
/** `folderId=none` lists the threads outside every folder. */
|
|
80
183
|
export const CHAT_V3_NO_FOLDER = 'none';
|
|
184
|
+
/**
|
|
185
|
+
* Whose catalog: an agent's, for a new thread, or a thread's, which runs the harness and model its
|
|
186
|
+
* session was pinned with even after the agent is published again. One of the two.
|
|
187
|
+
*/
|
|
188
|
+
export const chatV3ModelListQuerySchema = z.object({
|
|
189
|
+
agentId: agentIdSchema.optional(),
|
|
190
|
+
threadId: z.string().uuid().optional(),
|
|
191
|
+
}).strict().refine(query => (query.agentId === undefined) !== (query.threadId === undefined), { message: 'Send an agentId or a threadId.' });
|
|
192
|
+
/**
|
|
193
|
+
* A model a thread of the agent can choose, with the efforts it runs with, and what the chat's
|
|
194
|
+
* model picker shows of it: `cost` (1 to 5) is agent-api's tier, `description` the chat's own.
|
|
195
|
+
*/
|
|
196
|
+
export const chatV3ModelSchema = z.object({
|
|
197
|
+
id: z.string(),
|
|
198
|
+
name: z.string(),
|
|
199
|
+
vendor: z.string(),
|
|
200
|
+
description: z.string().nullable(),
|
|
201
|
+
cost: z.number().int().min(1).max(5),
|
|
202
|
+
maxInputTokens: z.number().int().positive(),
|
|
203
|
+
maxOutputTokens: z.number().int().positive().nullable(),
|
|
204
|
+
isMultiModal: z.boolean(),
|
|
205
|
+
reasoningEfforts: z.array(chatV3ReasoningEffortSchema),
|
|
206
|
+
defaultReasoningEffort: chatV3ReasoningEffortSchema.nullable(),
|
|
207
|
+
});
|
|
208
|
+
/**
|
|
209
|
+
* The models of agent-api's catalog for the harness, available ones only. `defaultModel` is what a
|
|
210
|
+
* thread without a choice runs: the agent's own model, or for a thread its session's. An agent
|
|
211
|
+
* agent-api does not have, or one without a harness yet, has no models.
|
|
212
|
+
*/
|
|
213
|
+
export const chatV3ModelListSchema = z.object({
|
|
214
|
+
agentStatus: chatV3AgentStatusSchema,
|
|
215
|
+
harness: v5HarnessSchema.nullable(),
|
|
216
|
+
defaultModel: z.string().nullable(),
|
|
217
|
+
models: z.array(chatV3ModelSchema),
|
|
218
|
+
});
|
|
219
|
+
/**
|
|
220
|
+
* A list is always of one agent, as a v1 conversation list always is. Without `agentId`, the agent
|
|
221
|
+
* is chosen as v1 does: the workspace's own agent, else the default.
|
|
222
|
+
*/
|
|
81
223
|
export const chatV3ThreadListQuerySchema = z.object({
|
|
82
224
|
agentId: agentIdSchema.optional(),
|
|
225
|
+
creator: chatV3ThreadCreatorSchema.optional(),
|
|
83
226
|
/** Only the threads of this folder, or with `none` only those outside every folder. */
|
|
84
227
|
folderId: z.union([z.literal(CHAT_V3_NO_FOLDER), folderIdSchema]).optional(),
|
|
85
|
-
/** Exclusive cursor: the
|
|
86
|
-
before: z.string().
|
|
228
|
+
/** Exclusive, opaque cursor: the `nextCursor` of the previous page. */
|
|
229
|
+
before: z.string().min(1).max(200).optional(),
|
|
87
230
|
limit: z.coerce.number().int().min(1).max(CHAT_V3_THREAD_PAGE.max).default(CHAT_V3_THREAD_PAGE.default),
|
|
88
231
|
}).strict();
|
|
89
232
|
export const chatV3ThreadListSchema = z.object({
|
|
90
233
|
threads: z.array(chatV3ThreadSchema),
|
|
91
|
-
nextCursor: z.string().
|
|
234
|
+
nextCursor: z.string().nullable(),
|
|
92
235
|
});
|
|
93
236
|
export const CHAT_V3_FOLDER_NAME_CHARS = 80;
|
|
94
237
|
const folderNameSchema = z.string().trim().min(1).max(CHAT_V3_FOLDER_NAME_CHARS);
|
|
@@ -119,6 +262,14 @@ export const chatV3CreateFolderSchema = z.object({
|
|
|
119
262
|
export const chatV3UpdateFolderSchema = z.object({
|
|
120
263
|
name: folderNameSchema,
|
|
121
264
|
}).strict();
|
|
265
|
+
export const chatV3ThreadCountQuerySchema = z.object({
|
|
266
|
+
agentId: agentIdSchema,
|
|
267
|
+
}).strict();
|
|
268
|
+
/** How many threads each filter of the list shows, as v1's conversation counts. */
|
|
269
|
+
export const chatV3ThreadCountSchema = z.object({
|
|
270
|
+
all: z.number().int().nonnegative(),
|
|
271
|
+
mine: z.number().int().nonnegative(),
|
|
272
|
+
});
|
|
122
273
|
export const CHAT_V3_MESSAGE_PAGE = { default: 30, max: 100 };
|
|
123
274
|
/** How many files one message carries; with the message they stay within agent-api's batch. */
|
|
124
275
|
export const CHAT_V3_FILES_PER_MESSAGE = 10;
|
|
@@ -147,13 +298,62 @@ export const chatV3FileUploadSchema = chatV3FileSchema.extend({
|
|
|
147
298
|
uploadUrl: z.string().url(),
|
|
148
299
|
expiresAt: z.string(),
|
|
149
300
|
});
|
|
301
|
+
/** How many agent inputs one message carries; with its files and itself they stay within agent-api's batch. */
|
|
302
|
+
export const CHAT_V3_INPUTS_PER_MESSAGE = 20;
|
|
303
|
+
/**
|
|
304
|
+
* The value of one agent input: text for a `text` input, a Vault reference (uploaded with
|
|
305
|
+
* `POST /files`) for a `file` one. agent-api checks the type against the declaration.
|
|
306
|
+
*/
|
|
307
|
+
export const chatV3SendInputSchema = z.union([
|
|
308
|
+
z.object({ name: v5InputNameSchema, text: z.string().min(1).max(v5Limits.inputTextChars) }).strict(),
|
|
309
|
+
z.object({ name: v5InputNameSchema, vaultReference: v5VaultReferenceSchema }).strict(),
|
|
310
|
+
]);
|
|
150
311
|
/**
|
|
151
|
-
* A
|
|
152
|
-
*
|
|
312
|
+
* A file sent with a message, by its Vault reference. Its name, size and type are what `POST /files`
|
|
313
|
+
* answered: with them the thread lists the file, for `@` to mention it again.
|
|
314
|
+
*/
|
|
315
|
+
export const chatV3MessageFileSchema = z.object({
|
|
316
|
+
vaultReference: v5VaultReferenceSchema,
|
|
317
|
+
name: z.string().trim().min(1).max(CHAT_V3_FILE_NAME_CHARS).optional(),
|
|
318
|
+
size: z.number().int().min(0).max(CHAT_V3_FILE_BYTES).optional(),
|
|
319
|
+
contentType: z.string().trim().min(1).max(255).optional(),
|
|
320
|
+
}).strict();
|
|
321
|
+
export const CHAT_V3_MENTIONS_PER_MESSAGE = 20;
|
|
322
|
+
export const CHAT_V3_SKILL_NAME_CHARS = 128;
|
|
323
|
+
export const CHAT_V3_MENTION_PATH_CHARS = 1024;
|
|
324
|
+
/**
|
|
325
|
+
* Where a file mentioned by path sits in the agent's working tree: its context files
|
|
326
|
+
* (`references/`), the files the agent published (`output/`) and the ones sent to it
|
|
327
|
+
* (`attachments/`). Relative, without `..` or hidden segments.
|
|
328
|
+
*/
|
|
329
|
+
export const chatV3MentionPathSchema = z.string().min(1).max(CHAT_V3_MENTION_PATH_CHARS).regex(/^(?:references|output|attachments)\/(?:[^/.\\][^/\\]*\/)*[^/.\\][^/\\]*$/u, 'A path under references/, output/ or attachments/, without hidden segments.').refine(path => !path.split('/').includes('..'), 'A path without `..`.');
|
|
330
|
+
/**
|
|
331
|
+
* What the user picked with `/` or `@`. The text keeps the token where it was picked (`/name`,
|
|
332
|
+
* `@name`); chat-api adds what each one means for the agent at the end of the message.
|
|
333
|
+
* - `skill`: a skill of the agent at the commit the thread runs.
|
|
334
|
+
* - `file`: a file of the agent's working tree, by path.
|
|
335
|
+
* - `attachment`: a file in Vault, sent with the message (again, if it went with an earlier one).
|
|
336
|
+
*/
|
|
337
|
+
export const chatV3MentionSchema = z.discriminatedUnion('type', [
|
|
338
|
+
z.object({ type: z.literal('skill'), name: z.string().trim().min(1).max(CHAT_V3_SKILL_NAME_CHARS) }).strict(),
|
|
339
|
+
z.object({ type: z.literal('file'), name: z.string().trim().min(1).max(CHAT_V3_FILE_NAME_CHARS), path: chatV3MentionPathSchema }).strict(),
|
|
340
|
+
z.object({ type: z.literal('attachment'), name: z.string().trim().min(1).max(CHAT_V3_FILE_NAME_CHARS), vaultReference: v5VaultReferenceSchema }).strict(),
|
|
341
|
+
]);
|
|
342
|
+
/**
|
|
343
|
+
* A message's text, the files sent with it, what it mentions and the agent inputs it sets. Above
|
|
344
|
+
* the inline limit agent-api keeps the text in Vault and the event points at it; each file goes as
|
|
345
|
+
* an `input` the agent finds in `attachments/`, each agent input as a named `input` it finds in
|
|
346
|
+
* `input/<name>/`.
|
|
153
347
|
*/
|
|
154
348
|
export const chatV3SendMessageSchema = z.object({
|
|
155
349
|
text: z.string().min(1).max(v5Limits.messageTextChars),
|
|
156
|
-
files: z.array(
|
|
350
|
+
files: z.array(chatV3MessageFileSchema).max(CHAT_V3_FILES_PER_MESSAGE).optional(),
|
|
351
|
+
mentions: z.array(chatV3MentionSchema).max(CHAT_V3_MENTIONS_PER_MESSAGE).optional(),
|
|
352
|
+
/**
|
|
353
|
+
* Values of the agent's declared inputs. The thread's first message has to carry every
|
|
354
|
+
* required one (agent-api answers `400 input_required`); a later one replaces the value it had.
|
|
355
|
+
*/
|
|
356
|
+
inputs: z.array(chatV3SendInputSchema).max(CHAT_V3_INPUTS_PER_MESSAGE).refine(inputs => new Set(inputs.map(input => input.name)).size === inputs.length, { message: 'Input names must be unique' }).optional(),
|
|
157
357
|
}).strict();
|
|
158
358
|
/** Text sent into a running turn; files go only with a queued message. */
|
|
159
359
|
export const chatV3SteerMessageSchema = z.object({
|
|
@@ -177,6 +377,23 @@ export const chatV3MessageReceiptSchema = z.object({
|
|
|
177
377
|
status: z.string(),
|
|
178
378
|
});
|
|
179
379
|
export const chatV3MessageStatusSchema = z.enum(['queued', 'running', 'completed', 'failed', 'cancelled', 'uncertain']);
|
|
380
|
+
/** The longest duration a timings report takes: one hour, in ms. */
|
|
381
|
+
export const CHAT_V3_TIMING_MAX_MS = 60 * 60 * 1000;
|
|
382
|
+
const timingMsSchema = z.number().int().min(0).max(CHAT_V3_TIMING_MAX_MS).optional();
|
|
383
|
+
/**
|
|
384
|
+
* How long a message took, as the browser that sent it and followed its turn measured it. Drafts
|
|
385
|
+
* are never stored, so the first output (TTFT) exists only there. Durations count from the
|
|
386
|
+
* runtime accepting the message, except the queue; each is left out when it was not seen.
|
|
387
|
+
* `errorCode` is the code agent-api gave a failed turn, never its text.
|
|
388
|
+
*/
|
|
389
|
+
export const chatV3MessageTimingsSchema = z.object({
|
|
390
|
+
queueMs: timingMsSchema,
|
|
391
|
+
ttftMs: timingMsSchema,
|
|
392
|
+
firstTextMs: timingMsSchema,
|
|
393
|
+
turnMs: timingMsSchema,
|
|
394
|
+
outcome: z.enum(['completed', 'failed', 'cancelled', 'uncertain']),
|
|
395
|
+
errorCode: z.string().min(1).max(100).regex(/^[\w.:-]+$/u).optional(),
|
|
396
|
+
}).strict();
|
|
180
397
|
/**
|
|
181
398
|
* A question the agent asked (`ask_user`), answered by its `toolCallId`. `answeredBy` is the
|
|
182
399
|
* message that answered it; nothing else tracks whether the agent still waits. One too long for
|
|
@@ -221,6 +438,7 @@ function parseQuestion(text) {
|
|
|
221
438
|
return null;
|
|
222
439
|
}
|
|
223
440
|
}
|
|
441
|
+
export const chatV3MessageAuthorSchema = z.object({ userId: z.string() });
|
|
224
442
|
/**
|
|
225
443
|
* One message of the user and the agent's reply to it, rebuilt from the session's events on
|
|
226
444
|
* every read. `text` is `null` while it is only in Vault (`textInVault`); `reply` is the
|
|
@@ -239,8 +457,29 @@ export const chatV3MessageSchema = z.object({
|
|
|
239
457
|
completedAt: z.string().nullable(),
|
|
240
458
|
/** Files sent with the message. agent-api keeps no name for them, so only how many. */
|
|
241
459
|
fileCount: z.number().int().nonnegative(),
|
|
460
|
+
/** The agent inputs set with the message, by name; their values are never listed. */
|
|
461
|
+
inputNames: z.array(z.string()),
|
|
462
|
+
/** What the message mentioned with `/` and `@`; `text` keeps their tokens, without what chat-api added for the agent. */
|
|
463
|
+
mentions: z.array(z.object({
|
|
464
|
+
type: z.enum(['skill', 'file', 'attachment']),
|
|
465
|
+
name: z.string(),
|
|
466
|
+
path: z.string().nullable(),
|
|
467
|
+
})),
|
|
242
468
|
/** What the agent asked while answering, if it did: its turn ended waiting for the answer. */
|
|
243
469
|
question: chatV3QuestionSchema.nullable(),
|
|
470
|
+
/** The model and effort it ran with, as agent-api reported them when it started; null until it runs. */
|
|
471
|
+
model: z.string().nullable(),
|
|
472
|
+
reasoningEffort: z.string().nullable(),
|
|
473
|
+
/**
|
|
474
|
+
* The member who sent it. agent-api v5 does not record it yet (`user_events.actor`), so it is
|
|
475
|
+
* always null for now; it is never inferred from who created the thread.
|
|
476
|
+
*/
|
|
477
|
+
author: chatV3MessageAuthorSchema.nullable(),
|
|
478
|
+
/**
|
|
479
|
+
* Why the message failed or ended uncertain, as agent-api said it: its error text, else its
|
|
480
|
+
* code. `null` for a message that did not fail, or whose failure came with no reason.
|
|
481
|
+
*/
|
|
482
|
+
error: z.string().nullable(),
|
|
244
483
|
});
|
|
245
484
|
export const chatV3MessageListQuerySchema = z.object({
|
|
246
485
|
/** Exclusive cursor: the `nextCursor` of the previous page, which reads older messages. */
|
|
@@ -283,3 +522,22 @@ export const chatV3ArtifactListQuerySchema = z.object({
|
|
|
283
522
|
}).strict();
|
|
284
523
|
/** The files the agent published in the thread and agent-api verified, in the order they were published. */
|
|
285
524
|
export const chatV3ArtifactListSchema = v5ArtifactPageSchema;
|
|
525
|
+
/**
|
|
526
|
+
* A file `@` can mention in a thread: one the user sent (`upload`, by its Vault reference, sent
|
|
527
|
+
* again with the message that mentions it) or one the agent published there (`artifact`, by its
|
|
528
|
+
* path in the agent's working tree).
|
|
529
|
+
*/
|
|
530
|
+
export const chatV3ThreadFileSchema = z.object({
|
|
531
|
+
source: z.enum(['upload', 'artifact']),
|
|
532
|
+
name: z.string(),
|
|
533
|
+
vaultReference: v5VaultReferenceSchema.nullable(),
|
|
534
|
+
path: z.string().nullable(),
|
|
535
|
+
size: z.number().int().nonnegative().nullable(),
|
|
536
|
+
contentType: z.string().nullable(),
|
|
537
|
+
createdAt: z.string().nullable(),
|
|
538
|
+
});
|
|
539
|
+
export const chatV3ThreadFileListSchema = z.object({ files: z.array(chatV3ThreadFileSchema) });
|
|
540
|
+
export const CHAT_V3_RECENT_FILES = 20;
|
|
541
|
+
export const chatV3RecentFileQuerySchema = z.object({ agentId: agentIdSchema }).strict();
|
|
542
|
+
/** The files the user sent lately in their threads with the agent, newest first, each once. */
|
|
543
|
+
export const chatV3RecentFileListSchema = z.object({ files: z.array(chatV3ThreadFileSchema) });
|