@adecore/agent-contracts 0.0.1 → 0.17.0-beta.2

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.
@@ -0,0 +1,72 @@
1
+ import { z } from 'zod';
2
+ export declare const ErrorSchema: z.ZodObject<{
3
+ code: z.ZodString;
4
+ message: z.ZodString;
5
+ }, z.core.$strip>;
6
+ export type WireError = z.infer<typeof ErrorSchema>;
7
+ export declare const RequestSchema: z.ZodObject<{
8
+ id: z.ZodString;
9
+ type: z.ZodString;
10
+ payload: z.ZodUnknown;
11
+ }, z.core.$strip>;
12
+ export type Request = z.infer<typeof RequestSchema>;
13
+ export declare const ReplyOkSchema: z.ZodObject<{
14
+ id: z.ZodString;
15
+ ok: z.ZodLiteral<true>;
16
+ result: z.ZodUnknown;
17
+ }, z.core.$strip>;
18
+ export type ReplyOk = z.infer<typeof ReplyOkSchema>;
19
+ export declare const ReplyErrorSchema: z.ZodObject<{
20
+ id: z.ZodNullable<z.ZodString>;
21
+ ok: z.ZodLiteral<false>;
22
+ error: z.ZodObject<{
23
+ code: z.ZodString;
24
+ message: z.ZodString;
25
+ }, z.core.$strip>;
26
+ }, z.core.$strip>;
27
+ export type ReplyError = z.infer<typeof ReplyErrorSchema>;
28
+ export declare const ReplySchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
29
+ id: z.ZodString;
30
+ ok: z.ZodLiteral<true>;
31
+ result: z.ZodUnknown;
32
+ }, z.core.$strip>, z.ZodObject<{
33
+ id: z.ZodNullable<z.ZodString>;
34
+ ok: z.ZodLiteral<false>;
35
+ error: z.ZodObject<{
36
+ code: z.ZodString;
37
+ message: z.ZodString;
38
+ }, z.core.$strip>;
39
+ }, z.core.$strip>], "ok">;
40
+ export type Reply = z.infer<typeof ReplySchema>;
41
+ export declare const EventSchema: z.ZodObject<{
42
+ type: z.ZodLiteral<"event">;
43
+ event: z.ZodString;
44
+ payload: z.ZodUnknown;
45
+ }, z.core.$strip>;
46
+ export type Event = z.infer<typeof EventSchema>;
47
+ export declare const ServerFrameSchema: z.ZodUnion<readonly [z.ZodDiscriminatedUnion<[z.ZodObject<{
48
+ id: z.ZodString;
49
+ ok: z.ZodLiteral<true>;
50
+ result: z.ZodUnknown;
51
+ }, z.core.$strip>, z.ZodObject<{
52
+ id: z.ZodNullable<z.ZodString>;
53
+ ok: z.ZodLiteral<false>;
54
+ error: z.ZodObject<{
55
+ code: z.ZodString;
56
+ message: z.ZodString;
57
+ }, z.core.$strip>;
58
+ }, z.core.$strip>], "ok">, z.ZodObject<{
59
+ type: z.ZodLiteral<"event">;
60
+ event: z.ZodString;
61
+ payload: z.ZodUnknown;
62
+ }, z.core.$strip>]>;
63
+ export type ServerFrame = z.infer<typeof ServerFrameSchema>;
64
+ export type ParseResult<T> = {
65
+ ok: true;
66
+ value: T;
67
+ } | {
68
+ ok: false;
69
+ message: string;
70
+ };
71
+ export declare function parseRequest(input: unknown): ParseResult<Request>;
72
+ export declare function parseServerFrame(input: unknown): ParseResult<ServerFrame>;
@@ -0,0 +1,40 @@
1
+ import { z } from 'zod';
2
+ export const ErrorSchema = z.object({
3
+ code: z.string().min(1),
4
+ message: z.string()
5
+ });
6
+ export const RequestSchema = z.object({
7
+ id: z.string().min(1),
8
+ type: z.string().min(1),
9
+ payload: z.unknown()
10
+ });
11
+ export const ReplyOkSchema = z.object({
12
+ id: z.string().min(1),
13
+ ok: z.literal(true),
14
+ result: z.unknown()
15
+ });
16
+ // The id is nullable so the server can still answer a frame it could not parse at all.
17
+ export const ReplyErrorSchema = z.object({
18
+ id: z.string().min(1).nullable(),
19
+ ok: z.literal(false),
20
+ error: ErrorSchema
21
+ });
22
+ export const ReplySchema = z.discriminatedUnion('ok', [ReplyOkSchema, ReplyErrorSchema]);
23
+ export const EventSchema = z.object({
24
+ type: z.literal('event'),
25
+ event: z.string().min(1),
26
+ payload: z.unknown()
27
+ });
28
+ export const ServerFrameSchema = z.union([ReplySchema, EventSchema]);
29
+ function toResult(parsed) {
30
+ if (parsed.success) {
31
+ return { ok: true, value: parsed.data };
32
+ }
33
+ return { ok: false, message: z.prettifyError(parsed.error) };
34
+ }
35
+ export function parseRequest(input) {
36
+ return toResult(RequestSchema.safeParse(input));
37
+ }
38
+ export function parseServerFrame(input) {
39
+ return toResult(ServerFrameSchema.safeParse(input));
40
+ }
package/dist/ids.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ import { z } from 'zod';
2
+ export declare const SessionIdSchema: z.ZodString;
3
+ export type SessionId = z.infer<typeof SessionIdSchema>;
package/dist/ids.js ADDED
@@ -0,0 +1,3 @@
1
+ import { z } from 'zod';
2
+ // The client picks the id (its node id), so the only rule is that it is not empty.
3
+ export const SessionIdSchema = z.string().min(1);
@@ -0,0 +1,12 @@
1
+ export * from './agent.ts';
2
+ export * from './chat.ts';
3
+ export * from './envelope.ts';
4
+ export * from './ids.ts';
5
+ export * from './model.ts';
6
+ export * from './protocol.ts';
7
+ export * from './provider-accounts.ts';
8
+ export * from './task.ts';
9
+ export * from './text.ts';
10
+ export * from './usage.ts';
11
+ export * from './worktree.ts';
12
+ export type * from './port.ts';
package/dist/index.js ADDED
@@ -0,0 +1,11 @@
1
+ export * from './agent.js';
2
+ export * from './chat.js';
3
+ export * from './envelope.js';
4
+ export * from './ids.js';
5
+ export * from './model.js';
6
+ export * from './protocol.js';
7
+ export * from './provider-accounts.js';
8
+ export * from './task.js';
9
+ export * from './text.js';
10
+ export * from './usage.js';
11
+ export * from './worktree.js';
@@ -0,0 +1,282 @@
1
+ import { z } from 'zod';
2
+ export declare const ModelOptionChoiceSchema: z.ZodObject<{
3
+ id: z.ZodString;
4
+ label: z.ZodString;
5
+ description: z.ZodOptional<z.ZodString>;
6
+ }, z.core.$strip>;
7
+ export type ModelOptionChoice = z.infer<typeof ModelOptionChoiceSchema>;
8
+ export declare const ModelOptionDescriptorSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
9
+ id: z.ZodString;
10
+ label: z.ZodString;
11
+ type: z.ZodLiteral<"select">;
12
+ choices: z.ZodArray<z.ZodObject<{
13
+ id: z.ZodString;
14
+ label: z.ZodString;
15
+ description: z.ZodOptional<z.ZodString>;
16
+ }, z.core.$strip>>;
17
+ defaultChoice: z.ZodString;
18
+ }, z.core.$strip>, z.ZodObject<{
19
+ id: z.ZodString;
20
+ label: z.ZodString;
21
+ type: z.ZodLiteral<"boolean">;
22
+ defaultValue: z.ZodBoolean;
23
+ description: z.ZodOptional<z.ZodString>;
24
+ }, z.core.$strip>], "type">;
25
+ export type ModelOptionDescriptor = z.infer<typeof ModelOptionDescriptorSchema>;
26
+ export declare const ModelInfoSchema: z.ZodObject<{
27
+ slug: z.ZodString;
28
+ name: z.ZodString;
29
+ badge: z.ZodOptional<z.ZodString>;
30
+ legacy: z.ZodBoolean;
31
+ isDefault: z.ZodBoolean;
32
+ options: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
33
+ id: z.ZodString;
34
+ label: z.ZodString;
35
+ type: z.ZodLiteral<"select">;
36
+ choices: z.ZodArray<z.ZodObject<{
37
+ id: z.ZodString;
38
+ label: z.ZodString;
39
+ description: z.ZodOptional<z.ZodString>;
40
+ }, z.core.$strip>>;
41
+ defaultChoice: z.ZodString;
42
+ }, z.core.$strip>, z.ZodObject<{
43
+ id: z.ZodString;
44
+ label: z.ZodString;
45
+ type: z.ZodLiteral<"boolean">;
46
+ defaultValue: z.ZodBoolean;
47
+ description: z.ZodOptional<z.ZodString>;
48
+ }, z.core.$strip>], "type">>;
49
+ }, z.core.$strip>;
50
+ export type ModelInfo = z.infer<typeof ModelInfoSchema>;
51
+ export declare const ModelSelectionSchema: z.ZodObject<{
52
+ model: z.ZodString;
53
+ options: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodBoolean]>>;
54
+ }, z.core.$strip>;
55
+ export type ModelSelection = z.infer<typeof ModelSelectionSchema>;
56
+ export declare const ModelCatalogProfileSchema: z.ZodObject<{
57
+ options: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
58
+ id: z.ZodString;
59
+ label: z.ZodString;
60
+ type: z.ZodLiteral<"select">;
61
+ choices: z.ZodArray<z.ZodObject<{
62
+ id: z.ZodString;
63
+ label: z.ZodString;
64
+ description: z.ZodOptional<z.ZodString>;
65
+ }, z.core.$strip>>;
66
+ defaultChoice: z.ZodString;
67
+ }, z.core.$strip>, z.ZodObject<{
68
+ id: z.ZodString;
69
+ label: z.ZodString;
70
+ type: z.ZodLiteral<"boolean">;
71
+ defaultValue: z.ZodBoolean;
72
+ description: z.ZodOptional<z.ZodString>;
73
+ }, z.core.$strip>], "type">>;
74
+ contextWindowTokens: z.ZodRecord<z.ZodString, z.ZodNumber>;
75
+ }, z.core.$strip>;
76
+ export type ModelCatalogProfile = z.infer<typeof ModelCatalogProfileSchema>;
77
+ export declare const ModelCatalogEntrySchema: z.ZodObject<{
78
+ slug: z.ZodString;
79
+ name: z.ZodString;
80
+ badge: z.ZodOptional<z.ZodString>;
81
+ profile: z.ZodString;
82
+ aliases: z.ZodOptional<z.ZodArray<z.ZodString>>;
83
+ legacy: z.ZodOptional<z.ZodBoolean>;
84
+ }, z.core.$strip>;
85
+ export type ModelCatalogEntry = z.infer<typeof ModelCatalogEntrySchema>;
86
+ export declare const ModelCatalogDataSchema: z.ZodObject<{
87
+ updatedAt: z.ZodISODateTime;
88
+ defaultModel: z.ZodString;
89
+ profiles: z.ZodRecord<z.ZodString, z.ZodObject<{
90
+ options: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
91
+ id: z.ZodString;
92
+ label: z.ZodString;
93
+ type: z.ZodLiteral<"select">;
94
+ choices: z.ZodArray<z.ZodObject<{
95
+ id: z.ZodString;
96
+ label: z.ZodString;
97
+ description: z.ZodOptional<z.ZodString>;
98
+ }, z.core.$strip>>;
99
+ defaultChoice: z.ZodString;
100
+ }, z.core.$strip>, z.ZodObject<{
101
+ id: z.ZodString;
102
+ label: z.ZodString;
103
+ type: z.ZodLiteral<"boolean">;
104
+ defaultValue: z.ZodBoolean;
105
+ description: z.ZodOptional<z.ZodString>;
106
+ }, z.core.$strip>], "type">>;
107
+ contextWindowTokens: z.ZodRecord<z.ZodString, z.ZodNumber>;
108
+ }, z.core.$strip>>;
109
+ models: z.ZodArray<z.ZodObject<{
110
+ slug: z.ZodString;
111
+ name: z.ZodString;
112
+ badge: z.ZodOptional<z.ZodString>;
113
+ profile: z.ZodString;
114
+ aliases: z.ZodOptional<z.ZodArray<z.ZodString>>;
115
+ legacy: z.ZodOptional<z.ZodBoolean>;
116
+ }, z.core.$strip>>;
117
+ }, z.core.$strip>;
118
+ export type ModelCatalogData = z.infer<typeof ModelCatalogDataSchema>;
119
+ export declare const RuntimeModeSchema: z.ZodEnum<{
120
+ auto: "auto";
121
+ "auto-accept-edits": "auto-accept-edits";
122
+ "full-access": "full-access";
123
+ supervised: "supervised";
124
+ }>;
125
+ export type RuntimeMode = z.infer<typeof RuntimeModeSchema>;
126
+ export declare const ProviderCapabilitiesSchema: z.ZodObject<{
127
+ chat: z.ZodBoolean;
128
+ terminal: z.ZodBoolean;
129
+ hooks: z.ZodBoolean;
130
+ streamsToolOutput: z.ZodBoolean;
131
+ diffs: z.ZodEnum<{
132
+ "before-after": "before-after";
133
+ none: "none";
134
+ unified: "unified";
135
+ }>;
136
+ attachments: z.ZodBoolean;
137
+ mentions: z.ZodBoolean;
138
+ denyReason: z.ZodBoolean;
139
+ allowAlways: z.ZodBoolean;
140
+ asyncQuestions: z.ZodBoolean;
141
+ compaction: z.ZodEnum<{
142
+ native: "native";
143
+ none: "none";
144
+ prompt: "prompt";
145
+ }>;
146
+ reportsCost: z.ZodBoolean;
147
+ reportsContextWindow: z.ZodBoolean;
148
+ reportsThinking: z.ZodBoolean;
149
+ slashCommands: z.ZodBoolean;
150
+ }, z.core.$strip>;
151
+ export type ProviderCapabilities = z.infer<typeof ProviderCapabilitiesSchema>;
152
+ export declare const ProviderInfoSchema: z.ZodObject<{
153
+ kind: z.ZodEnum<{
154
+ apple: "apple";
155
+ claude: "claude";
156
+ codex: "codex";
157
+ copilot: "copilot";
158
+ gemini: "gemini";
159
+ }>;
160
+ name: z.ZodString;
161
+ installed: z.ZodBoolean;
162
+ version: z.ZodNullable<z.ZodString>;
163
+ models: z.ZodArray<z.ZodObject<{
164
+ slug: z.ZodString;
165
+ name: z.ZodString;
166
+ badge: z.ZodOptional<z.ZodString>;
167
+ legacy: z.ZodBoolean;
168
+ isDefault: z.ZodBoolean;
169
+ options: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
170
+ id: z.ZodString;
171
+ label: z.ZodString;
172
+ type: z.ZodLiteral<"select">;
173
+ choices: z.ZodArray<z.ZodObject<{
174
+ id: z.ZodString;
175
+ label: z.ZodString;
176
+ description: z.ZodOptional<z.ZodString>;
177
+ }, z.core.$strip>>;
178
+ defaultChoice: z.ZodString;
179
+ }, z.core.$strip>, z.ZodObject<{
180
+ id: z.ZodString;
181
+ label: z.ZodString;
182
+ type: z.ZodLiteral<"boolean">;
183
+ defaultValue: z.ZodBoolean;
184
+ description: z.ZodOptional<z.ZodString>;
185
+ }, z.core.$strip>], "type">>;
186
+ }, z.core.$strip>>;
187
+ defaultModel: z.ZodNullable<z.ZodString>;
188
+ capabilities: z.ZodObject<{
189
+ chat: z.ZodBoolean;
190
+ terminal: z.ZodBoolean;
191
+ hooks: z.ZodBoolean;
192
+ streamsToolOutput: z.ZodBoolean;
193
+ diffs: z.ZodEnum<{
194
+ "before-after": "before-after";
195
+ none: "none";
196
+ unified: "unified";
197
+ }>;
198
+ attachments: z.ZodBoolean;
199
+ mentions: z.ZodBoolean;
200
+ denyReason: z.ZodBoolean;
201
+ allowAlways: z.ZodBoolean;
202
+ asyncQuestions: z.ZodBoolean;
203
+ compaction: z.ZodEnum<{
204
+ native: "native";
205
+ none: "none";
206
+ prompt: "prompt";
207
+ }>;
208
+ reportsCost: z.ZodBoolean;
209
+ reportsContextWindow: z.ZodBoolean;
210
+ reportsThinking: z.ZodBoolean;
211
+ slashCommands: z.ZodBoolean;
212
+ }, z.core.$strip>;
213
+ resumeCommand: z.ZodString;
214
+ }, z.core.$strip>;
215
+ export type ProviderInfo = z.infer<typeof ProviderInfoSchema>;
216
+ export declare const ProviderListResultSchema: z.ZodObject<{
217
+ providers: z.ZodArray<z.ZodObject<{
218
+ kind: z.ZodEnum<{
219
+ apple: "apple";
220
+ claude: "claude";
221
+ codex: "codex";
222
+ copilot: "copilot";
223
+ gemini: "gemini";
224
+ }>;
225
+ name: z.ZodString;
226
+ installed: z.ZodBoolean;
227
+ version: z.ZodNullable<z.ZodString>;
228
+ models: z.ZodArray<z.ZodObject<{
229
+ slug: z.ZodString;
230
+ name: z.ZodString;
231
+ badge: z.ZodOptional<z.ZodString>;
232
+ legacy: z.ZodBoolean;
233
+ isDefault: z.ZodBoolean;
234
+ options: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
235
+ id: z.ZodString;
236
+ label: z.ZodString;
237
+ type: z.ZodLiteral<"select">;
238
+ choices: z.ZodArray<z.ZodObject<{
239
+ id: z.ZodString;
240
+ label: z.ZodString;
241
+ description: z.ZodOptional<z.ZodString>;
242
+ }, z.core.$strip>>;
243
+ defaultChoice: z.ZodString;
244
+ }, z.core.$strip>, z.ZodObject<{
245
+ id: z.ZodString;
246
+ label: z.ZodString;
247
+ type: z.ZodLiteral<"boolean">;
248
+ defaultValue: z.ZodBoolean;
249
+ description: z.ZodOptional<z.ZodString>;
250
+ }, z.core.$strip>], "type">>;
251
+ }, z.core.$strip>>;
252
+ defaultModel: z.ZodNullable<z.ZodString>;
253
+ capabilities: z.ZodObject<{
254
+ chat: z.ZodBoolean;
255
+ terminal: z.ZodBoolean;
256
+ hooks: z.ZodBoolean;
257
+ streamsToolOutput: z.ZodBoolean;
258
+ diffs: z.ZodEnum<{
259
+ "before-after": "before-after";
260
+ none: "none";
261
+ unified: "unified";
262
+ }>;
263
+ attachments: z.ZodBoolean;
264
+ mentions: z.ZodBoolean;
265
+ denyReason: z.ZodBoolean;
266
+ allowAlways: z.ZodBoolean;
267
+ asyncQuestions: z.ZodBoolean;
268
+ compaction: z.ZodEnum<{
269
+ native: "native";
270
+ none: "none";
271
+ prompt: "prompt";
272
+ }>;
273
+ reportsCost: z.ZodBoolean;
274
+ reportsContextWindow: z.ZodBoolean;
275
+ reportsThinking: z.ZodBoolean;
276
+ slashCommands: z.ZodBoolean;
277
+ }, z.core.$strip>;
278
+ resumeCommand: z.ZodString;
279
+ }, z.core.$strip>>;
280
+ }, z.core.$strip>;
281
+ export type ProviderListResult = z.infer<typeof ProviderListResultSchema>;
282
+ export declare function resumeCommandFor(template: string, agentSessionId: string, flags?: string[]): string;
package/dist/model.js ADDED
@@ -0,0 +1,123 @@
1
+ import { z } from 'zod';
2
+ import { AgentKindSchema } from './agent.js';
3
+ // Options a model exposes (effort, context window, thinking). Generic descriptors instead of
4
+ // per-provider enums: a new model is a catalog entry, not a code change.
5
+ export const ModelOptionChoiceSchema = z.object({
6
+ id: z.string().min(1),
7
+ label: z.string(),
8
+ description: z.string().optional()
9
+ });
10
+ export const ModelOptionDescriptorSchema = z.discriminatedUnion('type', [
11
+ z.object({
12
+ id: z.string().min(1),
13
+ label: z.string(),
14
+ type: z.literal('select'),
15
+ choices: z.array(ModelOptionChoiceSchema).min(1),
16
+ defaultChoice: z.string()
17
+ }),
18
+ z.object({
19
+ id: z.string().min(1),
20
+ label: z.string(),
21
+ type: z.literal('boolean'),
22
+ defaultValue: z.boolean(),
23
+ // The line under the label in the picker: what turning it on costs or asks for.
24
+ description: z.string().optional()
25
+ })
26
+ ]);
27
+ export const ModelInfoSchema = z.object({
28
+ slug: z.string().min(1),
29
+ name: z.string(),
30
+ badge: z.string().optional(),
31
+ legacy: z.boolean(),
32
+ isDefault: z.boolean(),
33
+ options: z.array(ModelOptionDescriptorSchema)
34
+ });
35
+ export const ModelSelectionSchema = z.object({
36
+ model: z.string().min(1),
37
+ options: z.record(z.string(), z.union([z.string(), z.boolean()]))
38
+ });
39
+ // A slug ends up on a CLI's command line, so it never starts with a dash and carries no brackets.
40
+ const ModelSlugSchema = z.string().regex(/^[a-z0-9][a-z0-9._-]*$/, 'Expected a model slug');
41
+ export const ModelCatalogProfileSchema = z.object({
42
+ options: z.array(ModelOptionDescriptorSchema),
43
+ // Context size per value of the `contextWindow` option, or `*` when the model has one size.
44
+ contextWindowTokens: z.record(z.string(), z.number().int().positive())
45
+ });
46
+ export const ModelCatalogEntrySchema = z.object({
47
+ slug: ModelSlugSchema,
48
+ name: z.string().min(1),
49
+ badge: z.string().optional(),
50
+ profile: z.string().min(1),
51
+ aliases: z.array(z.string().min(1)).optional(),
52
+ legacy: z.boolean().optional()
53
+ });
54
+ /*
55
+ * The models one provider offers, as a host ships them and as a catalog service hands out a newer
56
+ * copy. `updatedAt` orders the two, so a copy older than the one a host shipped with is never taken.
57
+ */
58
+ export const ModelCatalogDataSchema = z
59
+ .object({
60
+ updatedAt: z.iso.datetime(),
61
+ defaultModel: ModelSlugSchema,
62
+ profiles: z.record(z.string(), ModelCatalogProfileSchema),
63
+ models: z.array(ModelCatalogEntrySchema).min(1)
64
+ })
65
+ .refine((data) => data.models.every((model) => data.profiles[model.profile] !== undefined), 'Every model needs a profile the catalog has')
66
+ .refine((data) => data.models.some((model) => model.slug === data.defaultModel), 'The default model has to be one of the models');
67
+ // The thread's permission policy, one vocabulary for every provider; each adapter maps it.
68
+ export const RuntimeModeSchema = z.enum(['supervised', 'auto-accept-edits', 'auto', 'full-access']);
69
+ // What a provider's CLI can do, so a client never offers what it would drop and the daemon
70
+ // never asks for what the protocol has no room for. Read by the composer and the thread rows.
71
+ export const ProviderCapabilitiesSchema = z.object({
72
+ // Where this CLI can be opened: as a chat node, as a terminal node, or both.
73
+ chat: z.boolean(),
74
+ terminal: z.boolean(),
75
+ // Whether the daemon understands this CLI's hooks; without them a node shows the session status only.
76
+ hooks: z.boolean(),
77
+ // Partial output while a tool call runs, for the live row under it.
78
+ streamsToolOutput: z.boolean(),
79
+ // How a file change reaches the thread: as a unified diff, as the text before and after, or not at all.
80
+ diffs: z.enum(['unified', 'before-after', 'none']),
81
+ attachments: z.boolean(),
82
+ mentions: z.boolean(),
83
+ // Whether a decline carries a reason for the agent.
84
+ denyReason: z.boolean(),
85
+ allowAlways: z.boolean(),
86
+ // A question the person may leave alone while the turn goes on.
87
+ asyncQuestions: z.boolean(),
88
+ // Folding the context: a call of its own, a slash command sent as a turn, or nothing.
89
+ compaction: z.enum(['native', 'prompt', 'none']),
90
+ reportsCost: z.boolean(),
91
+ reportsContextWindow: z.boolean(),
92
+ // Whether the CLI hands over what the model thought before it answered.
93
+ reportsThinking: z.boolean(),
94
+ slashCommands: z.boolean()
95
+ });
96
+ export const ProviderInfoSchema = z.object({
97
+ kind: AgentKindSchema,
98
+ name: z.string(),
99
+ installed: z.boolean(),
100
+ version: z.string().nullable(),
101
+ // Empty while the CLI is not installed or has no chat backend yet.
102
+ models: z.array(ModelInfoSchema),
103
+ defaultModel: z.string().nullable(),
104
+ capabilities: ProviderCapabilitiesSchema,
105
+ // What a terminal runs to continue one of this CLI's sessions. `{id}` stands for the session id
106
+ // and `{flags}` for the flags the launch carries, which is where in the line each CLI takes them.
107
+ resumeCommand: z.string()
108
+ });
109
+ export const ProviderListResultSchema = z.object({
110
+ providers: z.array(ProviderInfoSchema)
111
+ });
112
+ /*
113
+ * Fills a provider's resume template; the id is quoted so a shell takes it as one word. `{flags}` is
114
+ * a word of its own rather than a substring, since it stands for none, one or several words and a
115
+ * substitution would leave a double space behind where a launch carries no flags at all.
116
+ */
117
+ export function resumeCommandFor(template, agentSessionId, flags = []) {
118
+ const id = `'${agentSessionId.replaceAll("'", `'\\''`)}'`;
119
+ return template
120
+ .split(' ')
121
+ .flatMap((word) => (word === '{flags}' ? flags : [word.replace('{id}', id)]))
122
+ .join(' ');
123
+ }
package/dist/port.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ import type { Request, ServerFrame } from './envelope.ts';
2
+ export interface FramePort {
3
+ send(frame: Request | ServerFrame): void;
4
+ onFrame(listener: (frame: unknown) => void): () => void;
5
+ }
package/dist/port.js ADDED
@@ -0,0 +1 @@
1
+ export {};