@meistrari/chat-nuxt 4.13.0-rc.16 → 4.13.0-rc.18
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/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 +259 -2
- package/dist/runtime/types/schemas/chat/v3.js +139 -4
- package/dist/runtime/types/schemas/integrations/agent-events.d.ts +76 -9
- package/dist/runtime/types/schemas/integrations/agent-events.js +52 -7
- package/package.json +1 -1
package/dist/module.json
CHANGED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { ChatV3Mention, ChatV3Message } from './v3';
|
|
2
|
+
/**
|
|
3
|
+
* How the mentions of a message reach the agent. agent-api has no field for them: a message is
|
|
4
|
+
* text, which the harness hands to the model as it is (Claude Code still runs a leading `/skill`
|
|
5
|
+
* natively). So the text keeps the tokens the user picked (`/name`, `@name`) and ends with a block
|
|
6
|
+
* that says what each one is, where the agent finds the file, and that a skill is to be used.
|
|
7
|
+
* chat-api writes the block and takes it off again when it reads the message back.
|
|
8
|
+
*/
|
|
9
|
+
export type ChatV3MessageMention = ChatV3Message['mentions'][number];
|
|
10
|
+
/**
|
|
11
|
+
* The name agent-api gives a file sent with a message in `attachments/` (`safeName` of its
|
|
12
|
+
* sandbox-worker): the basename, NFC, anything but letters, digits, `_`, `.` and `-` as `_`, no
|
|
13
|
+
* leading dots, at most 200 characters.
|
|
14
|
+
*/
|
|
15
|
+
export declare function attachmentFileName(name: string): string;
|
|
16
|
+
/** Where the agent finds a mentioned file, relative to the root of its working tree. */
|
|
17
|
+
export declare function mentionPath(mention: ChatV3Mention): string | null;
|
|
18
|
+
/** Each mention once: the same skill, path or Vault file picked twice is said once. */
|
|
19
|
+
export declare function uniqueMentions(mentions: readonly ChatV3Mention[]): ChatV3Mention[];
|
|
20
|
+
/**
|
|
21
|
+
* The text the agent gets: the user's, then the block of its mentions. Without mentions, the text
|
|
22
|
+
* as it is, unless the user wrote what reads as such a block at its end: then it gets one more line
|
|
23
|
+
* break, which `splitChatV3MessageText` takes back, so the user's text survives the round trip.
|
|
24
|
+
*/
|
|
25
|
+
export declare function composeChatV3MessageText(text: string, mentions: readonly ChatV3Mention[]): string;
|
|
26
|
+
/**
|
|
27
|
+
* The user's text and its mentions, from the text the agent got. Only a block that closes the
|
|
28
|
+
* text and reads entry by entry is taken off: anything else is the user's own text.
|
|
29
|
+
*/
|
|
30
|
+
export declare function splitChatV3MessageText(text: string): {
|
|
31
|
+
text: string;
|
|
32
|
+
mentions: ChatV3MessageMention[];
|
|
33
|
+
};
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
const BLOCK_OPEN = '<chat-mentions>';
|
|
2
|
+
const BLOCK_CLOSE = '</chat-mentions>';
|
|
3
|
+
const SEPARATOR = '\n\n';
|
|
4
|
+
const INSTRUCTIONS = {
|
|
5
|
+
skill: (name) => `O usuário acionou a skill ${name} (/${name}). Use essa skill para atender a mensagem.`,
|
|
6
|
+
file: 'O usuário mencionou este arquivo do seu repositório de trabalho. Leia-o pelo caminho, relativo à raiz do repositório, e foque nele na resposta.',
|
|
7
|
+
attachment: 'O usuário mencionou este arquivo, anexado a esta mensagem. Leia-o e foque nele na resposta.',
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* The name agent-api gives a file sent with a message in `attachments/` (`safeName` of its
|
|
11
|
+
* sandbox-worker): the basename, NFC, anything but letters, digits, `_`, `.` and `-` as `_`, no
|
|
12
|
+
* leading dots, at most 200 characters.
|
|
13
|
+
*/
|
|
14
|
+
export function attachmentFileName(name) {
|
|
15
|
+
const base = name.split(/[/\\]/u).at(-1) ?? '';
|
|
16
|
+
const safe = base.normalize('NFC').replace(/[^\p{L}\p{N}_.-]/gu, '_').replace(/^\.+/u, '').slice(0, 200);
|
|
17
|
+
return safe || 'attachment';
|
|
18
|
+
}
|
|
19
|
+
/** Where the agent finds a mentioned file, relative to the root of its working tree. */
|
|
20
|
+
export function mentionPath(mention) {
|
|
21
|
+
if (mention.type === 'file')
|
|
22
|
+
return mention.path;
|
|
23
|
+
if (mention.type === 'attachment')
|
|
24
|
+
return `attachments/${attachmentFileName(mention.name)}`;
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
/** Each mention once: the same skill, path or Vault file picked twice is said once. */
|
|
28
|
+
export function uniqueMentions(mentions) {
|
|
29
|
+
const seen = new Set();
|
|
30
|
+
return mentions.filter((mention) => {
|
|
31
|
+
const key = mention.type === 'skill' ? `skill:${mention.name}` : mention.type === 'file' ? `file:${mention.path}` : `attachment:${mention.vaultReference}`;
|
|
32
|
+
if (seen.has(key))
|
|
33
|
+
return false;
|
|
34
|
+
seen.add(key);
|
|
35
|
+
return true;
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
/** Keeps a value on its entry's line: the block is read line by line, so line breaks are encoded too. */
|
|
39
|
+
function escapeAttribute(value) {
|
|
40
|
+
return value.replaceAll('&', '&').replaceAll('"', '"').replaceAll('<', '<').replaceAll('>', '>').replaceAll('\n', ' ').replaceAll('\r', ' ');
|
|
41
|
+
}
|
|
42
|
+
function unescapeAttribute(value) {
|
|
43
|
+
return value.replaceAll(' ', '\r').replaceAll(' ', '\n').replaceAll('"', '"').replaceAll('<', '<').replaceAll('>', '>').replaceAll('&', '&');
|
|
44
|
+
}
|
|
45
|
+
/** Whether the text, line breaks after it aside, closes with what reads as a block of mentions. */
|
|
46
|
+
function endsWithBlock(text) {
|
|
47
|
+
return splitChatV3MessageText(text.replace(/\n+$/u, '')).mentions.length > 0;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* The text the agent gets: the user's, then the block of its mentions. Without mentions, the text
|
|
51
|
+
* as it is, unless the user wrote what reads as such a block at its end: then it gets one more line
|
|
52
|
+
* break, which `splitChatV3MessageText` takes back, so the user's text survives the round trip.
|
|
53
|
+
*/
|
|
54
|
+
export function composeChatV3MessageText(text, mentions) {
|
|
55
|
+
const unique = uniqueMentions(mentions);
|
|
56
|
+
if (unique.length === 0)
|
|
57
|
+
return endsWithBlock(text) ? `${text}\n` : text;
|
|
58
|
+
const lines = unique.map((mention) => {
|
|
59
|
+
const name = `name="${escapeAttribute(mention.name)}"`;
|
|
60
|
+
if (mention.type === 'skill')
|
|
61
|
+
return `<skill ${name}>${INSTRUCTIONS.skill(escapeAttribute(mention.name))}</skill>`;
|
|
62
|
+
return `<${mention.type} ${name} path="${escapeAttribute(mentionPath(mention))}">${INSTRUCTIONS[mention.type]}</${mention.type}>`;
|
|
63
|
+
});
|
|
64
|
+
return `${text}${SEPARATOR}${BLOCK_OPEN}\n${lines.join('\n')}\n${BLOCK_CLOSE}`;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* One entry of the block. The closing tag is compared in code, not with a `\1` backreference:
|
|
68
|
+
* Bun 1.3.9 (what CI runs) fails that backreference under the `u` flag on text with accents.
|
|
69
|
+
*/
|
|
70
|
+
const ENTRY = /^<(skill|file|attachment) name="([^"]*)"(?: path="([^"]*)")?>[^<]*<\/(skill|file|attachment)>$/;
|
|
71
|
+
/**
|
|
72
|
+
* The user's text and its mentions, from the text the agent got. Only a block that closes the
|
|
73
|
+
* text and reads entry by entry is taken off: anything else is the user's own text.
|
|
74
|
+
*/
|
|
75
|
+
export function splitChatV3MessageText(text) {
|
|
76
|
+
// A block the user wrote went with one more line break (`composeChatV3MessageText`).
|
|
77
|
+
if (text.endsWith('\n') && endsWithBlock(text))
|
|
78
|
+
return { text: text.slice(0, -1), mentions: [] };
|
|
79
|
+
if (!text.endsWith(BLOCK_CLOSE))
|
|
80
|
+
return { text, mentions: [] };
|
|
81
|
+
const start = text.lastIndexOf(`${SEPARATOR}${BLOCK_OPEN}\n`);
|
|
82
|
+
if (start === -1)
|
|
83
|
+
return { text, mentions: [] };
|
|
84
|
+
const body = text.slice(start + SEPARATOR.length + BLOCK_OPEN.length + 1, -BLOCK_CLOSE.length - 1);
|
|
85
|
+
const mentions = [];
|
|
86
|
+
for (const line of body.split('\n')) {
|
|
87
|
+
const match = ENTRY.exec(line);
|
|
88
|
+
if (!match)
|
|
89
|
+
return { text, mentions: [] };
|
|
90
|
+
const [, type, name, path, closing] = match;
|
|
91
|
+
if (closing !== type || (type === 'skill') !== (path === undefined))
|
|
92
|
+
return { text, mentions: [] };
|
|
93
|
+
mentions.push({ type, name: unescapeAttribute(name), path: path === undefined ? null : unescapeAttribute(path) });
|
|
94
|
+
}
|
|
95
|
+
return { text: text.slice(0, start), mentions };
|
|
96
|
+
}
|
|
@@ -13,6 +13,54 @@ export declare const chatV3AgentStatusSchema: z.ZodEnum<{
|
|
|
13
13
|
not_published: "not_published";
|
|
14
14
|
}>;
|
|
15
15
|
export type ChatV3AgentStatus = z.infer<typeof chatV3AgentStatusSchema>;
|
|
16
|
+
/**
|
|
17
|
+
* An input the agent declares (its `input-schema.json`), at the commit a session runs. It has no
|
|
18
|
+
* default value: the host or the user gives it, and the session's first message has to carry
|
|
19
|
+
* every required one.
|
|
20
|
+
*/
|
|
21
|
+
export declare const chatV3AgentInputSchema: z.ZodObject<{
|
|
22
|
+
name: z.ZodString;
|
|
23
|
+
type: z.ZodEnum<{
|
|
24
|
+
file: "file";
|
|
25
|
+
text: "text";
|
|
26
|
+
}>;
|
|
27
|
+
required: z.ZodBoolean;
|
|
28
|
+
description: z.ZodNullable<z.ZodString>;
|
|
29
|
+
}, z.core.$strip>;
|
|
30
|
+
export type ChatV3AgentInput = z.infer<typeof chatV3AgentInputSchema>;
|
|
31
|
+
/** A skill the user can trigger with `/`: a `SKILL.md` of the agent's repository at its published commit. */
|
|
32
|
+
export declare const chatV3SkillSchema: z.ZodObject<{
|
|
33
|
+
name: z.ZodString;
|
|
34
|
+
description: z.ZodString;
|
|
35
|
+
path: z.ZodString;
|
|
36
|
+
}, z.core.$strip>;
|
|
37
|
+
export type ChatV3Skill = z.infer<typeof chatV3SkillSchema>;
|
|
38
|
+
/** A file under the agent's `references/`, which the agent reads from its working tree. */
|
|
39
|
+
export declare const chatV3ContextFileSchema: z.ZodObject<{
|
|
40
|
+
path: z.ZodString;
|
|
41
|
+
name: z.ZodString;
|
|
42
|
+
size: z.ZodNullable<z.ZodNumber>;
|
|
43
|
+
}, z.core.$strip>;
|
|
44
|
+
export type ChatV3ContextFile = z.infer<typeof chatV3ContextFileSchema>;
|
|
45
|
+
/**
|
|
46
|
+
* What `/` and `@` offer in a thread: the skills and context files of the commit its session runs,
|
|
47
|
+
* which an agent published again since does not change. Empty when the caller may not read the
|
|
48
|
+
* repository or agent-api fails to give it.
|
|
49
|
+
*/
|
|
50
|
+
export declare const chatV3ThreadCatalogSchema: z.ZodObject<{
|
|
51
|
+
commitSha: z.ZodNullable<z.ZodString>;
|
|
52
|
+
skills: z.ZodArray<z.ZodObject<{
|
|
53
|
+
name: z.ZodString;
|
|
54
|
+
description: z.ZodString;
|
|
55
|
+
path: z.ZodString;
|
|
56
|
+
}, z.core.$strip>>;
|
|
57
|
+
contextFiles: z.ZodArray<z.ZodObject<{
|
|
58
|
+
path: z.ZodString;
|
|
59
|
+
name: z.ZodString;
|
|
60
|
+
size: z.ZodNullable<z.ZodNumber>;
|
|
61
|
+
}, z.core.$strip>>;
|
|
62
|
+
}, z.core.$strip>;
|
|
63
|
+
export type ChatV3ThreadCatalog = z.infer<typeof chatV3ThreadCatalogSchema>;
|
|
16
64
|
/**
|
|
17
65
|
* How the agent of a request was chosen, in the order v1 chooses it: the one the request names,
|
|
18
66
|
* the workspace's own agent (its v1 agent, by id), or the environment's default.
|
|
@@ -34,6 +82,25 @@ export declare const chatV3AgentSchema: z.ZodObject<{
|
|
|
34
82
|
model: z.ZodNullable<z.ZodString>;
|
|
35
83
|
publishedSnapshotId: z.ZodNullable<z.ZodString>;
|
|
36
84
|
publishedCommitSha: z.ZodNullable<z.ZodString>;
|
|
85
|
+
inputs: z.ZodArray<z.ZodObject<{
|
|
86
|
+
name: z.ZodString;
|
|
87
|
+
type: z.ZodEnum<{
|
|
88
|
+
file: "file";
|
|
89
|
+
text: "text";
|
|
90
|
+
}>;
|
|
91
|
+
required: z.ZodBoolean;
|
|
92
|
+
description: z.ZodNullable<z.ZodString>;
|
|
93
|
+
}, z.core.$strip>>;
|
|
94
|
+
skills: z.ZodArray<z.ZodObject<{
|
|
95
|
+
name: z.ZodString;
|
|
96
|
+
description: z.ZodString;
|
|
97
|
+
path: z.ZodString;
|
|
98
|
+
}, z.core.$strip>>;
|
|
99
|
+
contextFiles: z.ZodArray<z.ZodObject<{
|
|
100
|
+
path: z.ZodString;
|
|
101
|
+
name: z.ZodString;
|
|
102
|
+
size: z.ZodNullable<z.ZodNumber>;
|
|
103
|
+
}, z.core.$strip>>;
|
|
37
104
|
}, z.core.$strip>;
|
|
38
105
|
export type ChatV3Agent = z.infer<typeof chatV3AgentSchema>;
|
|
39
106
|
export declare const chatV3ConfigurationSchema: z.ZodObject<{
|
|
@@ -61,6 +128,25 @@ export declare const chatV3ConfigurationSchema: z.ZodObject<{
|
|
|
61
128
|
model: z.ZodNullable<z.ZodString>;
|
|
62
129
|
publishedSnapshotId: z.ZodNullable<z.ZodString>;
|
|
63
130
|
publishedCommitSha: z.ZodNullable<z.ZodString>;
|
|
131
|
+
inputs: z.ZodArray<z.ZodObject<{
|
|
132
|
+
name: z.ZodString;
|
|
133
|
+
type: z.ZodEnum<{
|
|
134
|
+
file: "file";
|
|
135
|
+
text: "text";
|
|
136
|
+
}>;
|
|
137
|
+
required: z.ZodBoolean;
|
|
138
|
+
description: z.ZodNullable<z.ZodString>;
|
|
139
|
+
}, z.core.$strip>>;
|
|
140
|
+
skills: z.ZodArray<z.ZodObject<{
|
|
141
|
+
name: z.ZodString;
|
|
142
|
+
description: z.ZodString;
|
|
143
|
+
path: z.ZodString;
|
|
144
|
+
}, z.core.$strip>>;
|
|
145
|
+
contextFiles: z.ZodArray<z.ZodObject<{
|
|
146
|
+
path: z.ZodString;
|
|
147
|
+
name: z.ZodString;
|
|
148
|
+
size: z.ZodNullable<z.ZodNumber>;
|
|
149
|
+
}, z.core.$strip>>;
|
|
64
150
|
}, z.core.$strip>>;
|
|
65
151
|
limits: z.ZodObject<{
|
|
66
152
|
messageTextChars: z.ZodNumber;
|
|
@@ -111,6 +197,23 @@ export declare const chatV3ThreadSchema: z.ZodObject<{
|
|
|
111
197
|
updatedAt: z.ZodString;
|
|
112
198
|
}, z.core.$strip>;
|
|
113
199
|
export type ChatV3Thread = z.infer<typeof chatV3ThreadSchema>;
|
|
200
|
+
/**
|
|
201
|
+
* `GET /threads/{id}/inputs`: the inputs the commit the thread's session pinned declares. They stay
|
|
202
|
+
* those of that commit after the agent is published again.
|
|
203
|
+
*/
|
|
204
|
+
export declare const chatV3ThreadInputsSchema: z.ZodObject<{
|
|
205
|
+
commitSha: z.ZodString;
|
|
206
|
+
inputs: z.ZodArray<z.ZodObject<{
|
|
207
|
+
name: z.ZodString;
|
|
208
|
+
type: z.ZodEnum<{
|
|
209
|
+
file: "file";
|
|
210
|
+
text: "text";
|
|
211
|
+
}>;
|
|
212
|
+
required: z.ZodBoolean;
|
|
213
|
+
description: z.ZodNullable<z.ZodString>;
|
|
214
|
+
}, z.core.$strip>>;
|
|
215
|
+
}, z.core.$strip>;
|
|
216
|
+
export type ChatV3ThreadInputs = z.infer<typeof chatV3ThreadInputsSchema>;
|
|
114
217
|
/** The session behind a thread, read live from agent-api; `null` when agent-api no longer has it. */
|
|
115
218
|
export declare const chatV3SessionSummarySchema: z.ZodNullable<z.ZodObject<{
|
|
116
219
|
status: z.ZodString;
|
|
@@ -401,15 +504,93 @@ export declare const chatV3FileUploadSchema: z.ZodObject<{
|
|
|
401
504
|
expiresAt: z.ZodString;
|
|
402
505
|
}, z.core.$strip>;
|
|
403
506
|
export type ChatV3FileUpload = z.infer<typeof chatV3FileUploadSchema>;
|
|
507
|
+
/** How many agent inputs one message carries; with its files and itself they stay within agent-api's batch. */
|
|
508
|
+
export declare const CHAT_V3_INPUTS_PER_MESSAGE = 20;
|
|
404
509
|
/**
|
|
405
|
-
*
|
|
406
|
-
*
|
|
510
|
+
* The value of one agent input: text for a `text` input, a Vault reference (uploaded with
|
|
511
|
+
* `POST /files`) for a `file` one. agent-api checks the type against the declaration.
|
|
512
|
+
*/
|
|
513
|
+
export declare const chatV3SendInputSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
514
|
+
name: z.ZodString;
|
|
515
|
+
text: z.ZodString;
|
|
516
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
517
|
+
name: z.ZodString;
|
|
518
|
+
vaultReference: z.ZodString;
|
|
519
|
+
}, z.core.$strict>]>;
|
|
520
|
+
export type ChatV3SendInput = z.infer<typeof chatV3SendInputSchema>;
|
|
521
|
+
/**
|
|
522
|
+
* A file sent with a message, by its Vault reference. Its name, size and type are what `POST /files`
|
|
523
|
+
* answered: with them the thread lists the file, for `@` to mention it again.
|
|
524
|
+
*/
|
|
525
|
+
export declare const chatV3MessageFileSchema: z.ZodObject<{
|
|
526
|
+
vaultReference: z.ZodString;
|
|
527
|
+
name: z.ZodOptional<z.ZodString>;
|
|
528
|
+
size: z.ZodOptional<z.ZodNumber>;
|
|
529
|
+
contentType: z.ZodOptional<z.ZodString>;
|
|
530
|
+
}, z.core.$strict>;
|
|
531
|
+
export type ChatV3MessageFile = z.infer<typeof chatV3MessageFileSchema>;
|
|
532
|
+
export declare const CHAT_V3_MENTIONS_PER_MESSAGE = 20;
|
|
533
|
+
export declare const CHAT_V3_SKILL_NAME_CHARS = 128;
|
|
534
|
+
export declare const CHAT_V3_MENTION_PATH_CHARS = 1024;
|
|
535
|
+
/**
|
|
536
|
+
* Where a file mentioned by path sits in the agent's working tree: its context files
|
|
537
|
+
* (`references/`), the files the agent published (`output/`) and the ones sent to it
|
|
538
|
+
* (`attachments/`). Relative, without `..` or hidden segments.
|
|
539
|
+
*/
|
|
540
|
+
export declare const chatV3MentionPathSchema: z.ZodString;
|
|
541
|
+
/**
|
|
542
|
+
* What the user picked with `/` or `@`. The text keeps the token where it was picked (`/name`,
|
|
543
|
+
* `@name`); chat-api adds what each one means for the agent at the end of the message.
|
|
544
|
+
* - `skill`: a skill of the agent at the commit the thread runs.
|
|
545
|
+
* - `file`: a file of the agent's working tree, by path.
|
|
546
|
+
* - `attachment`: a file in Vault, sent with the message (again, if it went with an earlier one).
|
|
547
|
+
*/
|
|
548
|
+
export declare const chatV3MentionSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
549
|
+
type: z.ZodLiteral<"skill">;
|
|
550
|
+
name: z.ZodString;
|
|
551
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
552
|
+
type: z.ZodLiteral<"file">;
|
|
553
|
+
name: z.ZodString;
|
|
554
|
+
path: z.ZodString;
|
|
555
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
556
|
+
type: z.ZodLiteral<"attachment">;
|
|
557
|
+
name: z.ZodString;
|
|
558
|
+
vaultReference: z.ZodString;
|
|
559
|
+
}, z.core.$strict>], "type">;
|
|
560
|
+
export type ChatV3Mention = z.infer<typeof chatV3MentionSchema>;
|
|
561
|
+
/**
|
|
562
|
+
* A message's text, the files sent with it, what it mentions and the agent inputs it sets. Above
|
|
563
|
+
* the inline limit agent-api keeps the text in Vault and the event points at it; each file goes as
|
|
564
|
+
* an `input` the agent finds in `attachments/`, each agent input as a named `input` it finds in
|
|
565
|
+
* `input/<name>/`.
|
|
407
566
|
*/
|
|
408
567
|
export declare const chatV3SendMessageSchema: z.ZodObject<{
|
|
409
568
|
text: z.ZodString;
|
|
410
569
|
files: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
411
570
|
vaultReference: z.ZodString;
|
|
571
|
+
name: z.ZodOptional<z.ZodString>;
|
|
572
|
+
size: z.ZodOptional<z.ZodNumber>;
|
|
573
|
+
contentType: z.ZodOptional<z.ZodString>;
|
|
412
574
|
}, z.core.$strict>>>;
|
|
575
|
+
mentions: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
576
|
+
type: z.ZodLiteral<"skill">;
|
|
577
|
+
name: z.ZodString;
|
|
578
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
579
|
+
type: z.ZodLiteral<"file">;
|
|
580
|
+
name: z.ZodString;
|
|
581
|
+
path: z.ZodString;
|
|
582
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
583
|
+
type: z.ZodLiteral<"attachment">;
|
|
584
|
+
name: z.ZodString;
|
|
585
|
+
vaultReference: z.ZodString;
|
|
586
|
+
}, z.core.$strict>], "type">>>;
|
|
587
|
+
inputs: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
|
588
|
+
name: z.ZodString;
|
|
589
|
+
text: z.ZodString;
|
|
590
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
591
|
+
name: z.ZodString;
|
|
592
|
+
vaultReference: z.ZodString;
|
|
593
|
+
}, z.core.$strict>]>>>;
|
|
413
594
|
}, z.core.$strict>;
|
|
414
595
|
export type ChatV3SendMessage = z.infer<typeof chatV3SendMessageSchema>;
|
|
415
596
|
/** Text sent into a running turn; files go only with a queued message. */
|
|
@@ -536,6 +717,16 @@ export declare const chatV3MessageSchema: z.ZodObject<{
|
|
|
536
717
|
createdAt: z.ZodString;
|
|
537
718
|
completedAt: z.ZodNullable<z.ZodString>;
|
|
538
719
|
fileCount: z.ZodNumber;
|
|
720
|
+
inputNames: z.ZodArray<z.ZodString>;
|
|
721
|
+
mentions: z.ZodArray<z.ZodObject<{
|
|
722
|
+
type: z.ZodEnum<{
|
|
723
|
+
file: "file";
|
|
724
|
+
skill: "skill";
|
|
725
|
+
attachment: "attachment";
|
|
726
|
+
}>;
|
|
727
|
+
name: z.ZodString;
|
|
728
|
+
path: z.ZodNullable<z.ZodString>;
|
|
729
|
+
}, z.core.$strip>>;
|
|
539
730
|
question: z.ZodNullable<z.ZodObject<{
|
|
540
731
|
eventId: z.ZodString;
|
|
541
732
|
toolCallId: z.ZodString;
|
|
@@ -565,6 +756,7 @@ export declare const chatV3MessageSchema: z.ZodObject<{
|
|
|
565
756
|
author: z.ZodNullable<z.ZodObject<{
|
|
566
757
|
userId: z.ZodString;
|
|
567
758
|
}, z.core.$strip>>;
|
|
759
|
+
error: z.ZodNullable<z.ZodString>;
|
|
568
760
|
}, z.core.$strip>;
|
|
569
761
|
export type ChatV3Message = z.infer<typeof chatV3MessageSchema>;
|
|
570
762
|
export declare const chatV3MessageListQuerySchema: z.ZodObject<{
|
|
@@ -599,6 +791,16 @@ export declare const chatV3MessageListSchema: z.ZodObject<{
|
|
|
599
791
|
createdAt: z.ZodString;
|
|
600
792
|
completedAt: z.ZodNullable<z.ZodString>;
|
|
601
793
|
fileCount: z.ZodNumber;
|
|
794
|
+
inputNames: z.ZodArray<z.ZodString>;
|
|
795
|
+
mentions: z.ZodArray<z.ZodObject<{
|
|
796
|
+
type: z.ZodEnum<{
|
|
797
|
+
file: "file";
|
|
798
|
+
skill: "skill";
|
|
799
|
+
attachment: "attachment";
|
|
800
|
+
}>;
|
|
801
|
+
name: z.ZodString;
|
|
802
|
+
path: z.ZodNullable<z.ZodString>;
|
|
803
|
+
}, z.core.$strip>>;
|
|
602
804
|
question: z.ZodNullable<z.ZodObject<{
|
|
603
805
|
eventId: z.ZodString;
|
|
604
806
|
toolCallId: z.ZodString;
|
|
@@ -628,6 +830,7 @@ export declare const chatV3MessageListSchema: z.ZodObject<{
|
|
|
628
830
|
author: z.ZodNullable<z.ZodObject<{
|
|
629
831
|
userId: z.ZodString;
|
|
630
832
|
}, z.core.$strip>>;
|
|
833
|
+
error: z.ZodNullable<z.ZodString>;
|
|
631
834
|
}, z.core.$strip>>;
|
|
632
835
|
nextCursor: z.ZodNullable<z.ZodString>;
|
|
633
836
|
eventCursor: z.ZodNullable<z.ZodString>;
|
|
@@ -716,3 +919,57 @@ export declare const chatV3ArtifactListSchema: z.ZodObject<{
|
|
|
716
919
|
hasMore: z.ZodBoolean;
|
|
717
920
|
}, z.core.$loose>;
|
|
718
921
|
export type ChatV3ArtifactList = z.infer<typeof chatV3ArtifactListSchema>;
|
|
922
|
+
/**
|
|
923
|
+
* A file `@` can mention in a thread: one the user sent (`upload`, by its Vault reference, sent
|
|
924
|
+
* again with the message that mentions it) or one the agent published there (`artifact`, by its
|
|
925
|
+
* path in the agent's working tree).
|
|
926
|
+
*/
|
|
927
|
+
export declare const chatV3ThreadFileSchema: z.ZodObject<{
|
|
928
|
+
source: z.ZodEnum<{
|
|
929
|
+
upload: "upload";
|
|
930
|
+
artifact: "artifact";
|
|
931
|
+
}>;
|
|
932
|
+
name: z.ZodString;
|
|
933
|
+
vaultReference: z.ZodNullable<z.ZodString>;
|
|
934
|
+
path: z.ZodNullable<z.ZodString>;
|
|
935
|
+
size: z.ZodNullable<z.ZodNumber>;
|
|
936
|
+
contentType: z.ZodNullable<z.ZodString>;
|
|
937
|
+
createdAt: z.ZodNullable<z.ZodString>;
|
|
938
|
+
}, z.core.$strip>;
|
|
939
|
+
export type ChatV3ThreadFile = z.infer<typeof chatV3ThreadFileSchema>;
|
|
940
|
+
export declare const chatV3ThreadFileListSchema: z.ZodObject<{
|
|
941
|
+
files: z.ZodArray<z.ZodObject<{
|
|
942
|
+
source: z.ZodEnum<{
|
|
943
|
+
upload: "upload";
|
|
944
|
+
artifact: "artifact";
|
|
945
|
+
}>;
|
|
946
|
+
name: z.ZodString;
|
|
947
|
+
vaultReference: z.ZodNullable<z.ZodString>;
|
|
948
|
+
path: z.ZodNullable<z.ZodString>;
|
|
949
|
+
size: z.ZodNullable<z.ZodNumber>;
|
|
950
|
+
contentType: z.ZodNullable<z.ZodString>;
|
|
951
|
+
createdAt: z.ZodNullable<z.ZodString>;
|
|
952
|
+
}, z.core.$strip>>;
|
|
953
|
+
}, z.core.$strip>;
|
|
954
|
+
export type ChatV3ThreadFileList = z.infer<typeof chatV3ThreadFileListSchema>;
|
|
955
|
+
export declare const CHAT_V3_RECENT_FILES = 20;
|
|
956
|
+
export declare const chatV3RecentFileQuerySchema: z.ZodObject<{
|
|
957
|
+
agentId: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
958
|
+
}, z.core.$strict>;
|
|
959
|
+
export type ChatV3RecentFileQuery = z.infer<typeof chatV3RecentFileQuerySchema>;
|
|
960
|
+
/** The files the user sent lately in their threads with the agent, newest first, each once. */
|
|
961
|
+
export declare const chatV3RecentFileListSchema: z.ZodObject<{
|
|
962
|
+
files: z.ZodArray<z.ZodObject<{
|
|
963
|
+
source: z.ZodEnum<{
|
|
964
|
+
upload: "upload";
|
|
965
|
+
artifact: "artifact";
|
|
966
|
+
}>;
|
|
967
|
+
name: z.ZodString;
|
|
968
|
+
vaultReference: z.ZodNullable<z.ZodString>;
|
|
969
|
+
path: z.ZodNullable<z.ZodString>;
|
|
970
|
+
size: z.ZodNullable<z.ZodNumber>;
|
|
971
|
+
contentType: z.ZodNullable<z.ZodString>;
|
|
972
|
+
createdAt: z.ZodNullable<z.ZodString>;
|
|
973
|
+
}, z.core.$strip>>;
|
|
974
|
+
}, z.core.$strip>;
|
|
975
|
+
export type ChatV3RecentFileList = z.infer<typeof chatV3RecentFileListSchema>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { parseV5EventHint, v5ArtifactPageSchema, v5BranchNameSchema, v5EventIdSchema, v5HarnessSchema, v5Limits, v5ModelIdSchema, v5ReasoningEffortSchema, 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,40 @@ 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
|
+
});
|
|
19
53
|
/**
|
|
20
54
|
* How the agent of a request was chosen, in the order v1 chooses it: the one the request names,
|
|
21
55
|
* the workspace's own agent (its v1 agent, by id), or the environment's default.
|
|
@@ -28,6 +62,18 @@ export const chatV3AgentSchema = z.object({
|
|
|
28
62
|
model: z.string().nullable(),
|
|
29
63
|
publishedSnapshotId: z.string().uuid().nullable(),
|
|
30
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),
|
|
31
77
|
});
|
|
32
78
|
export const chatV3ConfigurationSchema = z.object({
|
|
33
79
|
apiVersion: z.literal(3),
|
|
@@ -83,6 +129,14 @@ export const chatV3ThreadSchema = z.object({
|
|
|
83
129
|
createdAt: z.string(),
|
|
84
130
|
updatedAt: z.string(),
|
|
85
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
|
+
});
|
|
86
140
|
/** The session behind a thread, read live from agent-api; `null` when agent-api no longer has it. */
|
|
87
141
|
export const chatV3SessionSummarySchema = z.object({
|
|
88
142
|
status: z.string(),
|
|
@@ -244,13 +298,62 @@ export const chatV3FileUploadSchema = chatV3FileSchema.extend({
|
|
|
244
298
|
uploadUrl: z.string().url(),
|
|
245
299
|
expiresAt: z.string(),
|
|
246
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;
|
|
247
303
|
/**
|
|
248
|
-
*
|
|
249
|
-
*
|
|
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
|
+
]);
|
|
311
|
+
/**
|
|
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>/`.
|
|
250
347
|
*/
|
|
251
348
|
export const chatV3SendMessageSchema = z.object({
|
|
252
349
|
text: z.string().min(1).max(v5Limits.messageTextChars),
|
|
253
|
-
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(),
|
|
254
357
|
}).strict();
|
|
255
358
|
/** Text sent into a running turn; files go only with a queued message. */
|
|
256
359
|
export const chatV3SteerMessageSchema = z.object({
|
|
@@ -354,6 +457,14 @@ export const chatV3MessageSchema = z.object({
|
|
|
354
457
|
completedAt: z.string().nullable(),
|
|
355
458
|
/** Files sent with the message. agent-api keeps no name for them, so only how many. */
|
|
356
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
|
+
})),
|
|
357
468
|
/** What the agent asked while answering, if it did: its turn ended waiting for the answer. */
|
|
358
469
|
question: chatV3QuestionSchema.nullable(),
|
|
359
470
|
/** The model and effort it ran with, as agent-api reported them when it started; null until it runs. */
|
|
@@ -364,6 +475,11 @@ export const chatV3MessageSchema = z.object({
|
|
|
364
475
|
* always null for now; it is never inferred from who created the thread.
|
|
365
476
|
*/
|
|
366
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(),
|
|
367
483
|
});
|
|
368
484
|
export const chatV3MessageListQuerySchema = z.object({
|
|
369
485
|
/** Exclusive cursor: the `nextCursor` of the previous page, which reads older messages. */
|
|
@@ -406,3 +522,22 @@ export const chatV3ArtifactListQuerySchema = z.object({
|
|
|
406
522
|
}).strict();
|
|
407
523
|
/** The files the agent published in the thread and agent-api verified, in the order they were published. */
|
|
408
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) });
|
|
@@ -38,6 +38,12 @@ export declare const v5ErrorStatus: {
|
|
|
38
38
|
readonly invalid_event_limit: 400;
|
|
39
39
|
readonly invalid_artifact_limit: 400;
|
|
40
40
|
readonly invalid_user_event_batch: 400;
|
|
41
|
+
/** A named input the session's commit does not declare (agent-api #858). */
|
|
42
|
+
readonly input_not_declared: 400;
|
|
43
|
+
/** A `file` input given text, or a `text` input given a Vault reference. */
|
|
44
|
+
readonly input_type_mismatch: 400;
|
|
45
|
+
/** The session's first message left out a required input. */
|
|
46
|
+
readonly input_required: 400;
|
|
41
47
|
readonly insufficient_role: 403;
|
|
42
48
|
readonly agent_publication_forbidden: 403;
|
|
43
49
|
readonly session_not_found: 404;
|
|
@@ -143,6 +149,8 @@ export declare const v5MessageSettingsSchema: z.ZodObject<{
|
|
|
143
149
|
}>;
|
|
144
150
|
}, z.core.$strict>;
|
|
145
151
|
export type V5MessageSettings = z.infer<typeof v5MessageSettingsSchema>;
|
|
152
|
+
/** The name of an agent input, as agent-api takes it; the agent reads its value in `input/<name>/`. */
|
|
153
|
+
export declare const v5InputNameSchema: z.ZodString;
|
|
146
154
|
/** A user event as the client sends it: a message, a steer, an input, a cancel or an answer. */
|
|
147
155
|
export declare const v5UserEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
148
156
|
type: z.ZodLiteral<"message-queue">;
|
|
@@ -678,6 +686,8 @@ export declare const v5SessionSchema: z.ZodObject<{
|
|
|
678
686
|
effort: z.ZodOptional<z.ZodString>;
|
|
679
687
|
commitSha: z.ZodString;
|
|
680
688
|
repository: z.ZodString;
|
|
689
|
+
/** The inputs the pinned commit declares (`v5InputContractSchema`), `{}` when it declares none. */
|
|
690
|
+
inputs: z.ZodOptional<z.ZodUnknown>;
|
|
681
691
|
}, z.core.$loose>;
|
|
682
692
|
effectiveModelSettings: z.ZodNullable<z.ZodObject<{
|
|
683
693
|
model: z.ZodString;
|
|
@@ -686,6 +696,41 @@ export declare const v5SessionSchema: z.ZodObject<{
|
|
|
686
696
|
createdAt: z.ZodString;
|
|
687
697
|
}, z.core.$loose>;
|
|
688
698
|
export type V5Session = z.infer<typeof v5SessionSchema>;
|
|
699
|
+
/**
|
|
700
|
+
* An input the agent declares in its `input-schema.json` (agent-api `declaredInputSchema`). It has
|
|
701
|
+
* no default value: the session is given it, by a named `input` event.
|
|
702
|
+
*/
|
|
703
|
+
export declare const v5DeclaredInputSchema: z.ZodObject<{
|
|
704
|
+
name: z.ZodString;
|
|
705
|
+
/** `text` or `file`; read as an open string so a new kind never breaks the chat. */
|
|
706
|
+
type: z.ZodString;
|
|
707
|
+
required: z.ZodBoolean;
|
|
708
|
+
description: z.ZodOptional<z.ZodString>;
|
|
709
|
+
}, z.core.$loose>;
|
|
710
|
+
export type V5DeclaredInput = z.infer<typeof v5DeclaredInputSchema>;
|
|
711
|
+
/** `GET /v5/agents/{agentId}/inputs`: the declarations at the branch or commit read. */
|
|
712
|
+
export declare const v5InputListSchema: z.ZodObject<{
|
|
713
|
+
branch: z.ZodString;
|
|
714
|
+
commitHash: z.ZodString;
|
|
715
|
+
inputs: z.ZodArray<z.ZodObject<{
|
|
716
|
+
name: z.ZodString;
|
|
717
|
+
/** `text` or `file`; read as an open string so a new kind never breaks the chat. */
|
|
718
|
+
type: z.ZodString;
|
|
719
|
+
required: z.ZodBoolean;
|
|
720
|
+
description: z.ZodOptional<z.ZodString>;
|
|
721
|
+
}, z.core.$loose>>;
|
|
722
|
+
}, z.core.$loose>;
|
|
723
|
+
export type V5InputList = z.infer<typeof v5InputListSchema>;
|
|
724
|
+
/** A session's `configuration.inputs` when its pinned commit declares inputs. */
|
|
725
|
+
export declare const v5InputContractSchema: z.ZodObject<{
|
|
726
|
+
inputs: z.ZodArray<z.ZodObject<{
|
|
727
|
+
name: z.ZodString;
|
|
728
|
+
/** `text` or `file`; read as an open string so a new kind never breaks the chat. */
|
|
729
|
+
type: z.ZodString;
|
|
730
|
+
required: z.ZodBoolean;
|
|
731
|
+
description: z.ZodOptional<z.ZodString>;
|
|
732
|
+
}, z.core.$loose>>;
|
|
733
|
+
}, z.core.$loose>;
|
|
689
734
|
/** Creation admits the session and its first queued messages and inputs in one idempotent request. */
|
|
690
735
|
export declare const v5SessionCreateSchema: z.ZodObject<{
|
|
691
736
|
agentId: z.ZodString;
|
|
@@ -875,15 +920,6 @@ export declare const v5RepositoryRefSchema: z.ZodObject<{
|
|
|
875
920
|
commitHash: z.ZodOptional<z.ZodString>;
|
|
876
921
|
}, z.core.$strict>;
|
|
877
922
|
export type V5RepositoryRef = z.infer<typeof v5RepositoryRefSchema>;
|
|
878
|
-
export declare const v5RepositorySchema: z.ZodObject<{
|
|
879
|
-
branch: z.ZodString;
|
|
880
|
-
commitHash: z.ZodString;
|
|
881
|
-
tree: z.ZodArray<z.ZodObject<{
|
|
882
|
-
path: z.ZodString;
|
|
883
|
-
type: z.ZodString;
|
|
884
|
-
}, z.core.$loose>>;
|
|
885
|
-
}, z.core.$loose>;
|
|
886
|
-
export type V5Repository = z.infer<typeof v5RepositorySchema>;
|
|
887
923
|
/**
|
|
888
924
|
* A model of agent-api's catalog (`GET /v5/agents/models`). `reasoningEfforts` are the ones the
|
|
889
925
|
* model runs with, `none` included; an alias (`aliasOf`) names another entry.
|
|
@@ -1048,3 +1084,34 @@ export declare const v5ArtifactQuerySchema: z.ZodObject<{
|
|
|
1048
1084
|
limit: z.ZodOptional<z.ZodNumber>;
|
|
1049
1085
|
}, z.core.$strict>;
|
|
1050
1086
|
export type V5ArtifactQuery = z.infer<typeof v5ArtifactQuerySchema>;
|
|
1087
|
+
/** A path of the agent's repository tree at one commit (`GET /v5/agents/{agentId}/repository`). */
|
|
1088
|
+
export declare const v5RepositoryTreeEntrySchema: z.ZodObject<{
|
|
1089
|
+
path: z.ZodString;
|
|
1090
|
+
/** `blob` or `tree`; read as an open string so a new kind never breaks the chat. */
|
|
1091
|
+
type: z.ZodString;
|
|
1092
|
+
sha: z.ZodString;
|
|
1093
|
+
size: z.ZodOptional<z.ZodNumber>;
|
|
1094
|
+
}, z.core.$loose>;
|
|
1095
|
+
export type V5RepositoryTreeEntry = z.infer<typeof v5RepositoryTreeEntrySchema>;
|
|
1096
|
+
export declare const v5RepositoryTreeSchema: z.ZodObject<{
|
|
1097
|
+
branch: z.ZodString;
|
|
1098
|
+
commitHash: z.ZodString;
|
|
1099
|
+
tree: z.ZodArray<z.ZodObject<{
|
|
1100
|
+
path: z.ZodString;
|
|
1101
|
+
/** `blob` or `tree`; read as an open string so a new kind never breaks the chat. */
|
|
1102
|
+
type: z.ZodString;
|
|
1103
|
+
sha: z.ZodString;
|
|
1104
|
+
size: z.ZodOptional<z.ZodNumber>;
|
|
1105
|
+
}, z.core.$loose>>;
|
|
1106
|
+
commitMessage: z.ZodNullable<z.ZodString>;
|
|
1107
|
+
}, z.core.$loose>;
|
|
1108
|
+
export type V5RepositoryTree = z.infer<typeof v5RepositoryTreeSchema>;
|
|
1109
|
+
/** One file of the agent's repository at a commit: text as it is, anything else in base64 (`encoding`). */
|
|
1110
|
+
export declare const v5RepositoryFileSchema: z.ZodObject<{
|
|
1111
|
+
branch: z.ZodString;
|
|
1112
|
+
commitHash: z.ZodString;
|
|
1113
|
+
filePath: z.ZodString;
|
|
1114
|
+
content: z.ZodString;
|
|
1115
|
+
encoding: z.ZodString;
|
|
1116
|
+
}, z.core.$loose>;
|
|
1117
|
+
export type V5RepositoryFile = z.infer<typeof v5RepositoryFileSchema>;
|
|
@@ -32,6 +32,12 @@ export const v5ErrorStatus = {
|
|
|
32
32
|
invalid_event_limit: 400,
|
|
33
33
|
invalid_artifact_limit: 400,
|
|
34
34
|
invalid_user_event_batch: 400,
|
|
35
|
+
/** A named input the session's commit does not declare (agent-api #858). */
|
|
36
|
+
input_not_declared: 400,
|
|
37
|
+
/** A `file` input given text, or a `text` input given a Vault reference. */
|
|
38
|
+
input_type_mismatch: 400,
|
|
39
|
+
/** The session's first message left out a required input. */
|
|
40
|
+
input_required: 400,
|
|
35
41
|
insufficient_role: 403,
|
|
36
42
|
agent_publication_forbidden: 403,
|
|
37
43
|
session_not_found: 404,
|
|
@@ -91,7 +97,8 @@ export const v5ModelIdSchema = z.string().min(1).max(256);
|
|
|
91
97
|
* agent-api checks the model against the session's harness and provider when it admits the message.
|
|
92
98
|
*/
|
|
93
99
|
export const v5MessageSettingsSchema = z.object({ model: v5ModelIdSchema, reasoningEffort: v5ReasoningEffortSchema }).strict();
|
|
94
|
-
|
|
100
|
+
/** The name of an agent input, as agent-api takes it; the agent reads its value in `input/<name>/`. */
|
|
101
|
+
export const v5InputNameSchema = z.string().min(1).max(128).regex(/^[a-z_][\w-]*$/iu);
|
|
95
102
|
const payloadSchema = z.string().min(1);
|
|
96
103
|
function isAnswers(payload) {
|
|
97
104
|
try {
|
|
@@ -106,7 +113,7 @@ function isAnswers(payload) {
|
|
|
106
113
|
export const v5UserEventSchema = z.discriminatedUnion('type', [
|
|
107
114
|
z.object({ type: z.literal('message-queue'), payload: payloadSchema, settings: v5MessageSettingsSchema.optional() }).strict(),
|
|
108
115
|
z.object({ type: z.literal('message-steer'), turnId: v5TurnIdSchema, payload: payloadSchema }).strict(),
|
|
109
|
-
z.object({ type: z.literal('input'), name:
|
|
116
|
+
z.object({ type: z.literal('input'), name: v5InputNameSchema.optional(), payload: payloadSchema.optional() }).strict(),
|
|
110
117
|
z.object({ type: z.literal('cancel'), turnId: v5TurnIdSchema }).strict(),
|
|
111
118
|
// An answer opens the next turn, so it takes settings too; a steer runs in the turn it joins.
|
|
112
119
|
z.object({ type: z.literal('tool-result'), toolCallId: z.string().min(1).max(v5Limits.turnIdChars), payload: payloadSchema, settings: v5MessageSettingsSchema.optional() }).strict(),
|
|
@@ -291,10 +298,31 @@ export const v5SessionSchema = z.looseObject({
|
|
|
291
298
|
effort: z.string().optional(),
|
|
292
299
|
commitSha: z.string(),
|
|
293
300
|
repository: z.string(),
|
|
301
|
+
/** The inputs the pinned commit declares (`v5InputContractSchema`), `{}` when it declares none. */
|
|
302
|
+
inputs: z.unknown().optional(),
|
|
294
303
|
}),
|
|
295
304
|
effectiveModelSettings: z.looseObject({ model: z.string(), reasoningEffort: z.string().nullable() }).nullable(),
|
|
296
305
|
createdAt: z.string(),
|
|
297
306
|
});
|
|
307
|
+
/**
|
|
308
|
+
* An input the agent declares in its `input-schema.json` (agent-api `declaredInputSchema`). It has
|
|
309
|
+
* no default value: the session is given it, by a named `input` event.
|
|
310
|
+
*/
|
|
311
|
+
export const v5DeclaredInputSchema = z.looseObject({
|
|
312
|
+
name: v5InputNameSchema,
|
|
313
|
+
/** `text` or `file`; read as an open string so a new kind never breaks the chat. */
|
|
314
|
+
type: z.string(),
|
|
315
|
+
required: z.boolean(),
|
|
316
|
+
description: z.string().optional(),
|
|
317
|
+
});
|
|
318
|
+
/** `GET /v5/agents/{agentId}/inputs`: the declarations at the branch or commit read. */
|
|
319
|
+
export const v5InputListSchema = z.looseObject({
|
|
320
|
+
branch: z.string(),
|
|
321
|
+
commitHash: z.string(),
|
|
322
|
+
inputs: z.array(v5DeclaredInputSchema),
|
|
323
|
+
});
|
|
324
|
+
/** A session's `configuration.inputs` when its pinned commit declares inputs. */
|
|
325
|
+
export const v5InputContractSchema = z.looseObject({ inputs: z.array(v5DeclaredInputSchema) });
|
|
298
326
|
/** Creation admits the session and its first queued messages and inputs in one idempotent request. */
|
|
299
327
|
export const v5SessionCreateSchema = z.object({
|
|
300
328
|
agentId: z.string().uuid(),
|
|
@@ -348,11 +376,6 @@ export const v5RepositoryRefSchema = z.object({
|
|
|
348
376
|
branch: v5BranchNameSchema.optional(),
|
|
349
377
|
commitHash: v5CommitHashSchema.optional(),
|
|
350
378
|
}).strict();
|
|
351
|
-
export const v5RepositorySchema = z.looseObject({
|
|
352
|
-
branch: z.string(),
|
|
353
|
-
commitHash: z.string(),
|
|
354
|
-
tree: z.array(z.looseObject({ path: z.string(), type: z.string() })),
|
|
355
|
-
});
|
|
356
379
|
/**
|
|
357
380
|
* A model of agent-api's catalog (`GET /v5/agents/models`). `reasoningEfforts` are the ones the
|
|
358
381
|
* model runs with, `none` included; an alias (`aliasOf`) names another entry.
|
|
@@ -413,3 +436,25 @@ export const v5ArtifactQuerySchema = z.object({
|
|
|
413
436
|
after: v5EventIdSchema.optional(),
|
|
414
437
|
limit: z.number().int().min(1).max(v5Limits.artifactPage.max).optional(),
|
|
415
438
|
}).strict();
|
|
439
|
+
/** A path of the agent's repository tree at one commit (`GET /v5/agents/{agentId}/repository`). */
|
|
440
|
+
export const v5RepositoryTreeEntrySchema = z.looseObject({
|
|
441
|
+
path: z.string().min(1),
|
|
442
|
+
/** `blob` or `tree`; read as an open string so a new kind never breaks the chat. */
|
|
443
|
+
type: z.string(),
|
|
444
|
+
sha: z.string(),
|
|
445
|
+
size: z.number().nonnegative().optional(),
|
|
446
|
+
});
|
|
447
|
+
export const v5RepositoryTreeSchema = z.looseObject({
|
|
448
|
+
branch: z.string(),
|
|
449
|
+
commitHash: z.string(),
|
|
450
|
+
tree: z.array(v5RepositoryTreeEntrySchema),
|
|
451
|
+
commitMessage: z.string().nullable(),
|
|
452
|
+
});
|
|
453
|
+
/** One file of the agent's repository at a commit: text as it is, anything else in base64 (`encoding`). */
|
|
454
|
+
export const v5RepositoryFileSchema = z.looseObject({
|
|
455
|
+
branch: z.string(),
|
|
456
|
+
commitHash: z.string(),
|
|
457
|
+
filePath: z.string(),
|
|
458
|
+
content: z.string(),
|
|
459
|
+
encoding: z.string(),
|
|
460
|
+
});
|