@adecore/agent-contracts 0.20.0 → 0.21.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/agent.d.ts +37 -0
- package/dist/agent.js +10 -0
- package/dist/chat.d.ts +1446 -0
- package/dist/chat.js +88 -4
- package/dist/protocol.d.ts +980 -0
- package/dist/protocol.js +4 -1
- package/package.json +2 -1
- package/src/agent.ts +12 -0
- package/src/chat.ts +112 -4
- package/src/protocol.ts +8 -0
package/dist/chat.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { UiLinkResolutionSchema } from '@adecore/intelligent-ui/links';
|
|
1
2
|
import { z } from 'zod';
|
|
3
|
+
import { UiBlocksSchema } from '@adecore/intelligent-ui/protocol';
|
|
2
4
|
import { AgentKindSchema, AgentStatusSchema, SuggestedTitleSchema } from './agent.js';
|
|
3
5
|
import { WorktreeSchema } from './worktree.js';
|
|
4
6
|
import { ModelSelectionSchema, RuntimeModeSchema } from './model.js';
|
|
@@ -80,7 +82,24 @@ export const ChatAttachmentSchema = z.object({
|
|
|
80
82
|
mime: z.string(),
|
|
81
83
|
size: z.number().int().nonnegative(),
|
|
82
84
|
// Absolute, on the machine the daemon runs on.
|
|
83
|
-
path: z.string()
|
|
85
|
+
path: z.string(),
|
|
86
|
+
width: z.number().int().positive().optional(),
|
|
87
|
+
height: z.number().int().positive().optional()
|
|
88
|
+
});
|
|
89
|
+
export const ChatUiChoiceOriginSchema = z.object({
|
|
90
|
+
itemId: z.string().min(1),
|
|
91
|
+
blockId: z.string().min(1),
|
|
92
|
+
revision: z.string().min(1),
|
|
93
|
+
choiceId: z.string().min(1),
|
|
94
|
+
label: z.string().min(1),
|
|
95
|
+
sourceAt: z.number().nonnegative(),
|
|
96
|
+
older: z.boolean(),
|
|
97
|
+
values: z.record(z.string(), z.unknown()).optional(),
|
|
98
|
+
at: z.number().nonnegative()
|
|
99
|
+
});
|
|
100
|
+
export const ChatUiAnswerSchema = ChatUiChoiceOriginSchema.extend({
|
|
101
|
+
queued: z.boolean(),
|
|
102
|
+
turnId: z.string().min(1)
|
|
84
103
|
});
|
|
85
104
|
// A message typed while a turn was running; the daemon sends it when that turn settles.
|
|
86
105
|
export const ChatQueuedMessageSchema = z.object({
|
|
@@ -92,7 +111,8 @@ export const ChatQueuedMessageSchema = z.object({
|
|
|
92
111
|
skills: z.array(z.string()).optional(),
|
|
93
112
|
chats: z.array(z.string()).optional(),
|
|
94
113
|
attachments: z.array(ChatAttachmentSchema).optional(),
|
|
95
|
-
createdAt: z.number()
|
|
114
|
+
createdAt: z.number(),
|
|
115
|
+
uiChoice: ChatUiChoiceOriginSchema.optional()
|
|
96
116
|
});
|
|
97
117
|
// A command or a monitor the CLI keeps running beside its turns, until it ends or its process does.
|
|
98
118
|
export const ChatBackgroundTaskSchema = z.object({
|
|
@@ -236,11 +256,34 @@ export const ChatUserItemSchema = z.object({
|
|
|
236
256
|
skills: z.array(z.string()).optional(),
|
|
237
257
|
// Chats of the same project the person picked with `@`. Only their ids travel; the agent reads them itself.
|
|
238
258
|
chats: z.array(z.string()).optional(),
|
|
239
|
-
attachments: z.array(ChatAttachmentSchema).optional()
|
|
259
|
+
attachments: z.array(ChatAttachmentSchema).optional(),
|
|
260
|
+
uiChoice: ChatUiChoiceOriginSchema.optional()
|
|
261
|
+
});
|
|
262
|
+
export const ChatUiQueryReadingSchema = z.object({
|
|
263
|
+
state: z.enum(['fresh', 'failed', 'refused']),
|
|
264
|
+
value: z.unknown().optional(),
|
|
265
|
+
readId: z.string().optional(),
|
|
266
|
+
readAt: z.number().nonnegative(),
|
|
267
|
+
reason: z.string().optional()
|
|
268
|
+
});
|
|
269
|
+
export const ChatUiLinkReadingSchema = UiLinkResolutionSchema;
|
|
270
|
+
export const ChatUiQueryStateSchema = z.object({
|
|
271
|
+
authorChatId: z.string(),
|
|
272
|
+
access: z.unknown(),
|
|
273
|
+
blocks: z.record(z.string(), z.object({
|
|
274
|
+
revision: z.string(),
|
|
275
|
+
readings: z.record(z.string(), ChatUiQueryReadingSchema),
|
|
276
|
+
fallback: z.string(),
|
|
277
|
+
links: z.record(z.string(), ChatUiLinkReadingSchema).optional()
|
|
278
|
+
}))
|
|
240
279
|
});
|
|
241
280
|
export const ChatAssistantItemSchema = z.object({
|
|
242
281
|
...base,
|
|
243
282
|
kind: z.literal('assistant'),
|
|
283
|
+
ui: UiBlocksSchema.optional(),
|
|
284
|
+
uiAnswers: z.record(z.string(), ChatUiAnswerSchema).optional(),
|
|
285
|
+
uiQueries: ChatUiQueryStateSchema.optional(),
|
|
286
|
+
phase: z.string().optional(),
|
|
244
287
|
text: z.string(),
|
|
245
288
|
streaming: z.boolean(),
|
|
246
289
|
// Set for text a subagent wrote, with the id of the Agent call that spawned it.
|
|
@@ -486,7 +529,14 @@ export const ChatItemSchema = z.discriminatedUnion('kind', [
|
|
|
486
529
|
// Events apply after the `chat.attach` snapshot; item ids make upserts and streamed deltas replayable.
|
|
487
530
|
export const ChatEventSchema = z.discriminatedUnion('type', [
|
|
488
531
|
z.object({ type: z.literal('item'), item: ChatItemSchema, historyIndex: z.number().int().nonnegative().optional() }),
|
|
489
|
-
z.object({
|
|
532
|
+
z.object({
|
|
533
|
+
type: z.literal('delta'),
|
|
534
|
+
itemId: z.string(),
|
|
535
|
+
text: z.string(),
|
|
536
|
+
ui: UiBlocksSchema.optional(),
|
|
537
|
+
uiQueries: ChatUiQueryStateSchema.optional(),
|
|
538
|
+
textLength: z.number().int().nonnegative().optional()
|
|
539
|
+
}),
|
|
490
540
|
z.object({ type: z.literal('info'), info: ChatInfoSchema }),
|
|
491
541
|
z.object({ type: z.literal('reset'), info: ChatInfoSchema, items: z.array(ChatItemSchema) })
|
|
492
542
|
]);
|
|
@@ -571,6 +621,8 @@ export const ChatSubagentSourceSchema = z.enum(['claude-transcript', 'codex-thre
|
|
|
571
621
|
export const ChatSubagentResultSchema = z.object({
|
|
572
622
|
items: z.array(ChatItemSchema),
|
|
573
623
|
history: ChatSubagentPageSchema,
|
|
624
|
+
// A request still waiting must remain answerable after it leaves the newest page.
|
|
625
|
+
pending: z.array(z.union([ChatApprovalItemSchema, ChatQuestionItemSchema])).optional(),
|
|
574
626
|
source: ChatSubagentSourceSchema,
|
|
575
627
|
context: z.object({ provider: AgentKindSchema, cwd: z.string(), chatId: ChatIdSchema.optional() }).optional(),
|
|
576
628
|
// Whether the subagent is still writing, so a client knows to keep reading.
|
|
@@ -636,10 +688,12 @@ export const ChatAttachResultSchema = z.object({
|
|
|
636
688
|
// Absent from a host that keeps no visuals.
|
|
637
689
|
visuals: ChatVisualsSchema.optional()
|
|
638
690
|
});
|
|
691
|
+
export const ChatDeliverySchema = z.enum(['steer', 'queue']);
|
|
639
692
|
export const ChatSendPayloadSchema = z
|
|
640
693
|
.object({
|
|
641
694
|
chatId: ChatIdSchema,
|
|
642
695
|
text: z.string(),
|
|
696
|
+
delivery: ChatDeliverySchema.optional(),
|
|
643
697
|
mentions: z.array(z.string().min(1)).max(64).optional(),
|
|
644
698
|
skills: z.array(z.string().min(1)).max(16).optional(),
|
|
645
699
|
chats: z.array(ChatIdSchema).max(16).optional(),
|
|
@@ -648,6 +702,24 @@ export const ChatSendPayloadSchema = z
|
|
|
648
702
|
.refine((payload) => payload.text.trim() !== '' || (payload.attachments?.length ?? 0) > 0, { message: 'A message needs text or an attachment' });
|
|
649
703
|
// Daemons before completion follow-ups omit `turnId`; keeping it optional lets newer clients finish the send.
|
|
650
704
|
export const ChatSendResultSchema = z.object({ queued: z.boolean(), turnId: z.string().min(1).optional() });
|
|
705
|
+
export const ChatUiChoicePayloadSchema = z.object({
|
|
706
|
+
chatId: ChatIdSchema,
|
|
707
|
+
itemId: z.string().min(1).max(256),
|
|
708
|
+
blockId: z.string().min(1).max(256),
|
|
709
|
+
revision: z.string().min(1).max(128),
|
|
710
|
+
choiceId: z.string().min(1).max(256),
|
|
711
|
+
reads: z.record(z.string().max(128), z.string().max(128)).optional(),
|
|
712
|
+
values: z.record(z.string().max(128), z.unknown()).optional()
|
|
713
|
+
});
|
|
714
|
+
export const ChatUiQueryPayloadSchema = z.object({
|
|
715
|
+
chatId: ChatIdSchema,
|
|
716
|
+
itemId: z.string().min(1).max(256),
|
|
717
|
+
blockId: z.string().min(1).max(256),
|
|
718
|
+
revision: z.string().min(1).max(128),
|
|
719
|
+
query: z.string().min(1).max(128),
|
|
720
|
+
values: z.record(z.string().max(128), z.unknown()).optional()
|
|
721
|
+
});
|
|
722
|
+
export const ChatUiLinkPayloadSchema = ChatUiChoicePayloadSchema.omit({ choiceId: true }).extend({ nodeId: z.string().min(1).max(256) });
|
|
651
723
|
export const ChatQueuePayloadSchema = z.object({
|
|
652
724
|
chatId: ChatIdSchema,
|
|
653
725
|
messageId: z.string().min(1)
|
|
@@ -747,3 +819,15 @@ export const ChatForkInfoResultSchema = z.object({
|
|
|
747
819
|
export const ChatListResultSchema = z.object({
|
|
748
820
|
chats: z.array(ChatInfoSchema)
|
|
749
821
|
});
|
|
822
|
+
export const GeneratedImageInputSchema = z.object({
|
|
823
|
+
attachment: ChatAttachmentSchema.optional(),
|
|
824
|
+
revisedPrompt: z.string().optional(),
|
|
825
|
+
transparentBackground: z.boolean().optional()
|
|
826
|
+
});
|
|
827
|
+
export function generatedImageAttachment(item) {
|
|
828
|
+
if (item.kind !== 'tool' || item.name !== 'ImageGeneration') {
|
|
829
|
+
return null;
|
|
830
|
+
}
|
|
831
|
+
const parsed = GeneratedImageInputSchema.safeParse(item.input);
|
|
832
|
+
return parsed.success ? (parsed.data.attachment ?? null) : null;
|
|
833
|
+
}
|