@adecore/agent-contracts 0.23.1 → 0.24.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/src/index.ts CHANGED
@@ -1,13 +1,413 @@
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 './visual.ts';
12
- export * from './worktree.ts';
13
- export type * from './port.ts';
1
+ // Public API: exports.test.ts snapshots this list, so a name added or dropped here is an API change.
2
+ export {
3
+ AgentKindSchema,
4
+ type AgentKind,
5
+ AgentStatusSchema,
6
+ type AgentStatus,
7
+ SUGGESTED_TITLE_LIMIT,
8
+ SuggestedTitleSchema,
9
+ AgentRequestSchema,
10
+ type AgentRequest,
11
+ AgentInfoSchema,
12
+ type AgentInfo,
13
+ SessionStatusEventSchema,
14
+ type SessionStatusEvent,
15
+ AgentResumePayloadSchema,
16
+ type AgentResumePayload,
17
+ ApprovalChoiceSchema,
18
+ type ApprovalChoice,
19
+ ApprovalRequestSchema,
20
+ type ApprovalRequest,
21
+ SessionApprovalsEventSchema,
22
+ type SessionApprovalsEvent,
23
+ ApprovalAnswerPayloadSchema,
24
+ type ApprovalAnswerPayload,
25
+ ApprovalAnswerResultSchema,
26
+ type ApprovalAnswerResult,
27
+ ApprovalPreferencePayloadSchema,
28
+ type ApprovalPreferencePayload
29
+ } from './agent.ts';
30
+ export {
31
+ ChatIdSchema,
32
+ type ChatId,
33
+ ChatContextBreakdownSchema,
34
+ type ChatContextBreakdown,
35
+ ChatUsageSchema,
36
+ type ChatUsage,
37
+ CHAT_ATTACHMENTS_MAX_BYTES,
38
+ CHAT_ATTACHMENT_MAX_BYTES,
39
+ CHAT_ATTACHMENTS_MAX_COUNT,
40
+ attachmentBytes,
41
+ attachmentImageMime,
42
+ ChatAttachmentUploadSchema,
43
+ type ChatAttachmentUpload,
44
+ ChatAttachmentUploadsSchema,
45
+ ChatAttachmentSchema,
46
+ type ChatAttachment,
47
+ ChatUiChoiceOriginSchema,
48
+ type ChatUiChoiceOrigin,
49
+ ChatUiAnswerSchema,
50
+ type ChatUiAnswer,
51
+ ChatQuoteSourceSchema,
52
+ type ChatQuoteSource,
53
+ ChatQueuedMessageSchema,
54
+ type ChatQueuedMessage,
55
+ ChatBackgroundTaskSchema,
56
+ type ChatBackgroundTask,
57
+ ChatTurnLimitSchema,
58
+ type ChatTurnLimit,
59
+ ChatGoalStatusSchema,
60
+ type ChatGoalStatus,
61
+ ChatGoalSchema,
62
+ type ChatGoal,
63
+ ChatQuestionSchema,
64
+ type ChatQuestion,
65
+ ChatRequestKindSchema,
66
+ type ChatRequestKind,
67
+ CHAT_REQUEST_LIMITS,
68
+ ChatRequestApprovalSchema,
69
+ type ChatRequestApproval,
70
+ ChatRequestSummarySchema,
71
+ type ChatRequestSummary,
72
+ ChatInfoSchema,
73
+ type ChatInfo,
74
+ ChatSkillSourceSchema,
75
+ type ChatSkillSource,
76
+ ChatSkillSchema,
77
+ type ChatSkill,
78
+ SkillsListPayloadSchema,
79
+ type SkillsListPayload,
80
+ SkillsListResultSchema,
81
+ type SkillsListResult,
82
+ ChatUserItemSchema,
83
+ ChatUiQueryReadingSchema,
84
+ type ChatUiQueryReading,
85
+ ChatUiLinkReadingSchema,
86
+ type ChatUiLinkReading,
87
+ ChatUiQueryStateSchema,
88
+ type ChatUiQueryState,
89
+ ChatAssistantItemSchema,
90
+ ChatThinkingItemSchema,
91
+ ChatToolStateSchema,
92
+ type ChatToolState,
93
+ ChatToolProgressSchema,
94
+ type ChatToolProgress,
95
+ ChatFileChangeSchema,
96
+ type ChatFileChange,
97
+ ChatSubagentStatusSchema,
98
+ type ChatSubagentStatus,
99
+ ChatWorkflowPhaseSchema,
100
+ type ChatWorkflowPhase,
101
+ ChatWorkflowAgentSchema,
102
+ type ChatWorkflowAgent,
103
+ ChatWorkflowSchema,
104
+ type ChatWorkflow,
105
+ workflowAgentRef,
106
+ workflowAgentIdOf,
107
+ ChatToolItemSchema,
108
+ ChatSubagentUsageSchema,
109
+ type ChatSubagentUsage,
110
+ HOST_TASK_ORIGIN,
111
+ ChatSubagentItemSchema,
112
+ ChatApprovalDecisionSchema,
113
+ type ChatApprovalDecision,
114
+ ChatApprovalItemSchema,
115
+ ChatQuestionItemSchema,
116
+ ChatCheckpointFileSchema,
117
+ type ChatCheckpointFile,
118
+ ChatCheckpointDiffSchema,
119
+ type ChatCheckpointDiff,
120
+ ChatTurnItemSchema,
121
+ notResumedNote,
122
+ abortedByMachine,
123
+ WAITING_NOTE_PREFIX,
124
+ ChatNoteItemSchema,
125
+ ChatCompactionItemSchema,
126
+ ChatItemSchema,
127
+ type ChatItem,
128
+ type ChatUserItem,
129
+ type ChatAssistantItem,
130
+ type ChatThinkingItem,
131
+ type ChatToolItem,
132
+ type ChatSubagentItem,
133
+ type ChatApprovalItem,
134
+ type ChatQuestionItem,
135
+ type ChatTurnItem,
136
+ type ChatNoteItem,
137
+ type ChatCompactionItem,
138
+ ChatEventSchema,
139
+ type ChatEvent,
140
+ ChatEventEnvelopeSchema,
141
+ type ChatEventEnvelope,
142
+ ChatCreatePayloadSchema,
143
+ type ChatCreatePayload,
144
+ ChatConfigurePayloadSchema,
145
+ type ChatConfigurePayload,
146
+ ChatPreferencesPayloadSchema,
147
+ type ChatPreferencesPayload,
148
+ ChatTargetPayloadSchema,
149
+ type ChatTargetPayload,
150
+ ChatClearPayloadSchema,
151
+ type ChatClearPayload,
152
+ ChatCancelPayloadSchema,
153
+ type ChatCancelPayload,
154
+ ChatAttachPayloadSchema,
155
+ ChatHistoryPayloadSchema,
156
+ ChatHistoryPageSchema,
157
+ ChatHistoryResultSchema,
158
+ type ChatHistoryResult,
159
+ ChatSubagentPayloadSchema,
160
+ type ChatSubagentPayload,
161
+ ChatStopSubagentPayloadSchema,
162
+ type ChatStopSubagentPayload,
163
+ ChatGoalActionSchema,
164
+ type ChatGoalAction,
165
+ ChatGoalPayloadSchema,
166
+ type ChatGoalPayload,
167
+ ChatStopTaskPayloadSchema,
168
+ type ChatStopTaskPayload,
169
+ ChatSubagentPageSchema,
170
+ ChatSubagentSourceSchema,
171
+ type ChatSubagentSource,
172
+ ChatSubagentResultSchema,
173
+ type ChatSubagentResult,
174
+ ChatStatusEventSchema,
175
+ type ChatStatusEvent,
176
+ ChatSubagentChangedEventSchema,
177
+ type ChatSubagentChangedEvent,
178
+ CHAT_BOOKMARK_LIMITS,
179
+ ChatBookmarkSchema,
180
+ type ChatBookmark,
181
+ ChatBookmarksSchema,
182
+ ChatAddBookmarkPayloadSchema,
183
+ type ChatAddBookmarkPayload,
184
+ ChatRenameBookmarkPayloadSchema,
185
+ type ChatRenameBookmarkPayload,
186
+ ChatRemoveBookmarkPayloadSchema,
187
+ type ChatRemoveBookmarkPayload,
188
+ ChatBookmarksResultSchema,
189
+ type ChatBookmarksResult,
190
+ ChatBookmarksEventSchema,
191
+ type ChatBookmarksEvent,
192
+ ChatRemoveVisualPayloadSchema,
193
+ type ChatRemoveVisualPayload,
194
+ ChatVisualsResultSchema,
195
+ type ChatVisualsResult,
196
+ ChatVisualsEventSchema,
197
+ type ChatVisualsEvent,
198
+ ChatAttachResultSchema,
199
+ type ChatAttachResult,
200
+ ChatDeliverySchema,
201
+ type ChatDelivery,
202
+ ChatSendPayloadSchema,
203
+ type ChatSendPayload,
204
+ ChatSendResultSchema,
205
+ type ChatSendResult,
206
+ ChatUiChoicePayloadSchema,
207
+ type ChatUiChoicePayload,
208
+ ChatUiQueryPayloadSchema,
209
+ type ChatUiQueryPayload,
210
+ ChatUiLinkPayloadSchema,
211
+ type ChatUiLinkPayload,
212
+ ChatQueuePayloadSchema,
213
+ type ChatQueuePayload,
214
+ ChatUnqueueResultSchema,
215
+ type ChatUnqueueResult,
216
+ ChatApprovePayloadSchema,
217
+ type ChatApprovePayload,
218
+ ChatDismissPayloadSchema,
219
+ type ChatDismissPayload,
220
+ ChatAnswerPayloadSchema,
221
+ type ChatAnswerPayload,
222
+ ChatTurnDiffPayloadSchema,
223
+ type ChatTurnDiffPayload,
224
+ ChatTurnDiffResultSchema,
225
+ type ChatTurnDiffResult,
226
+ CHAT_FORK_TITLE_MAX,
227
+ ChatForkPayloadSchema,
228
+ type ChatForkPayload,
229
+ ChatForkResultSchema,
230
+ type ChatForkResult,
231
+ ChatContinueOnPayloadSchema,
232
+ type ChatContinueOnPayload,
233
+ ChatContinueOnResultSchema,
234
+ type ChatContinueOnResult,
235
+ ChatSummarizePayloadSchema,
236
+ type ChatSummarizePayload,
237
+ ChatSummarizeResultSchema,
238
+ type ChatSummarizeResult,
239
+ ChatForkInfoPayloadSchema,
240
+ type ChatForkInfoPayload,
241
+ ChatForkInfoResultSchema,
242
+ type ChatForkInfoResult,
243
+ ChatListResultSchema,
244
+ type ChatListResult,
245
+ GeneratedImageInputSchema,
246
+ type GeneratedImageInput,
247
+ generatedImageAttachment
248
+ } from './chat.ts';
249
+ export {
250
+ ErrorSchema,
251
+ type WireError,
252
+ RequestSchema,
253
+ type Request,
254
+ ReplyOkSchema,
255
+ type ReplyOk,
256
+ ReplyErrorSchema,
257
+ type ReplyError,
258
+ ReplySchema,
259
+ type Reply,
260
+ EventSchema,
261
+ type Event,
262
+ ServerFrameSchema,
263
+ type ServerFrame,
264
+ type ParseResult,
265
+ parseRequest,
266
+ parseServerFrame
267
+ } from './envelope.ts';
268
+ export { SessionIdSchema, type SessionId } from './ids.ts';
269
+ export {
270
+ ModelOptionChoiceSchema,
271
+ type ModelOptionChoice,
272
+ ModelOptionDescriptorSchema,
273
+ type ModelOptionDescriptor,
274
+ ModelInfoSchema,
275
+ type ModelInfo,
276
+ ModelSelectionSchema,
277
+ type ModelSelection,
278
+ ModelCatalogProfileSchema,
279
+ type ModelCatalogProfile,
280
+ ModelCatalogEntrySchema,
281
+ type ModelCatalogEntry,
282
+ ModelCatalogDataSchema,
283
+ type ModelCatalogData,
284
+ RuntimeModeSchema,
285
+ type RuntimeMode,
286
+ ProviderCapabilitiesSchema,
287
+ type ProviderCapabilities,
288
+ ProviderInfoSchema,
289
+ type ProviderInfo,
290
+ ProviderListResultSchema,
291
+ type ProviderListResult,
292
+ resumeCommandFor
293
+ } from './model.ts';
294
+ export type { FramePort } from './port.ts';
295
+ export { EmptySchema, AGENT_REQUEST_SCHEMAS, AGENT_EVENT_SCHEMAS, type AgentRequestType, type AgentEventType } from './protocol.ts';
296
+ export {
297
+ ProviderAccountIdSchema,
298
+ type ProviderAccountId,
299
+ ProviderAccountVariableSchema,
300
+ type ProviderAccountVariable,
301
+ ProviderAccountSchema,
302
+ type ProviderAccount,
303
+ ProviderAccountStateSchema,
304
+ type ProviderAccountState,
305
+ ProviderAccountStatusSchema,
306
+ type ProviderAccountStatus,
307
+ ProviderAccountMapSchema,
308
+ type ProviderAccountMap,
309
+ ProviderAccountsSchema,
310
+ type ProviderAccounts,
311
+ ProviderAccountsSavePayloadSchema,
312
+ type ProviderAccountsSavePayload,
313
+ ProviderAccountCreatePayloadSchema,
314
+ type ProviderAccountCreatePayload,
315
+ ProviderAccountCreateResultSchema,
316
+ type ProviderAccountCreateResult,
317
+ ProviderAccountWatchLoginPayloadSchema,
318
+ type ProviderAccountWatchLoginPayload
319
+ } from './provider-accounts.ts';
320
+ export { isRecord } from './record.ts';
321
+ export {
322
+ TaskStatusSchema,
323
+ type TaskStatus,
324
+ TaskResultSchema,
325
+ type TaskResult,
326
+ TaskSchema,
327
+ type Task,
328
+ TaskChangedEventSchema,
329
+ type TaskChangedEvent
330
+ } from './task.ts';
331
+ export { clipText, TOOL_OUTPUT_TAIL, appendToolOutput } from './text.ts';
332
+ export {
333
+ UsageProviderSchema,
334
+ type UsageProvider,
335
+ USAGE_PROVIDERS,
336
+ UsageResolutionSchema,
337
+ type UsageResolution,
338
+ UsageTotalsSchema,
339
+ type UsageTotals,
340
+ EMPTY_TOTALS,
341
+ totalTokensOf,
342
+ addTotals,
343
+ UsageAccountSchema,
344
+ type UsageAccount,
345
+ UsageBucketSchema,
346
+ type UsageBucket,
347
+ UsagePriceBasisSchema,
348
+ type UsagePriceBasis,
349
+ UsageModelSchema,
350
+ type UsageModel,
351
+ UsageProjectSchema,
352
+ type UsageProject,
353
+ UsageSummaryPayloadSchema,
354
+ type UsageSummaryPayload,
355
+ UsageScanSchema,
356
+ type UsageScan,
357
+ UsagePricingSchema,
358
+ type UsagePricing,
359
+ UsageRootSchema,
360
+ type UsageRoot,
361
+ UsageRateSchema,
362
+ type UsageRate,
363
+ UsageSummaryResultSchema,
364
+ type UsageSummaryResult,
365
+ UsageChangedEventSchema,
366
+ type UsageChangedEvent,
367
+ UsageWindowSchema,
368
+ type UsageWindow,
369
+ UsageLimitsProviderSchema,
370
+ type UsageLimitsProvider,
371
+ UsageLimitsSnapshotSchema,
372
+ type UsageLimitsSnapshot
373
+ } from './usage.ts';
374
+ export {
375
+ VISUAL_LIMITS,
376
+ VISUAL_MEASURE_WIDTHS,
377
+ VisualHeightSchema,
378
+ type VisualHeight,
379
+ VisualLayoutSchema,
380
+ type VisualLayout,
381
+ ChatVisualSchema,
382
+ type ChatVisual,
383
+ ChatVisualsSchema,
384
+ visualFrameHeight,
385
+ VISUAL_BRIDGE_METHODS,
386
+ type VisualAppearance,
387
+ type VisualTheme,
388
+ type VisualRequestId,
389
+ type VisualViewport,
390
+ type VisualScrollRequest,
391
+ visualViewportMessage,
392
+ visualScrollMessage,
393
+ type VisualMessage,
394
+ visualProxyReadyMessage,
395
+ visualResourceReadyMessage,
396
+ visualHostContextMessage,
397
+ visualSizeChangedMessage,
398
+ visualOpenLinkRequest,
399
+ visualOpenLinkResult,
400
+ parseVisualMessage,
401
+ VISUAL_THEME_VARIABLES,
402
+ type VisualThemeVariable,
403
+ VISUAL_LIGHT_THEME,
404
+ VISUAL_DARK_THEME,
405
+ cleanVisualVariables,
406
+ visualThemeFragment,
407
+ VISUAL_PAGE_RULES,
408
+ VISUAL_LAYOUT_GUIDE,
409
+ VISUAL_THEME_GUIDE,
410
+ injectVisualBootstrap,
411
+ VISUAL_HOST_PAGE
412
+ } from './visual.ts';
413
+ export { WorktreeWorkSchema, type WorktreeWork, WorktreeSchema, type Worktree } from './worktree.ts';
package/src/model.ts CHANGED
@@ -109,13 +109,19 @@ export const ProviderCapabilitiesSchema = z.object({
109
109
  allowAlways: z.boolean(),
110
110
  // A question the person may leave alone while the turn goes on.
111
111
  asyncQuestions: z.boolean(),
112
+ // Whether a message sent while a turn runs can join that turn rather than wait for the next;
113
+ // absent where it cannot, which is also what a host from before this field reports.
114
+ steer: z.boolean().optional(),
112
115
  // Folding the context: a call of its own, a slash command sent as a turn, or nothing.
113
116
  compaction: z.enum(['native', 'prompt', 'none']),
114
117
  reportsCost: z.boolean(),
115
118
  reportsContextWindow: z.boolean(),
116
119
  // Whether the CLI hands over what the model thought before it answered.
117
120
  reportsThinking: z.boolean(),
118
- slashCommands: z.boolean()
121
+ slashCommands: z.boolean(),
122
+ // How `/goal` reaches the CLI: through a protocol of its own that pauses, resumes and clears (`native`),
123
+ // or as the slash command alone (`command`); absent where the CLI has no goals.
124
+ goals: z.enum(['native', 'command']).optional()
119
125
  });
120
126
  export type ProviderCapabilities = z.infer<typeof ProviderCapabilitiesSchema>;
121
127
 
package/src/protocol.ts CHANGED
@@ -19,6 +19,7 @@ import {
19
19
  ChatForkInfoResultSchema,
20
20
  ChatForkPayloadSchema,
21
21
  ChatForkResultSchema,
22
+ ChatGoalPayloadSchema,
22
23
  ChatHistoryPayloadSchema,
23
24
  ChatHistoryResultSchema,
24
25
  ChatInfoSchema,
@@ -96,6 +97,7 @@ export const AGENT_REQUEST_SCHEMAS = {
96
97
  'chat.subagent': { payload: ChatSubagentPayloadSchema, result: ChatSubagentResultSchema },
97
98
  'chat.stopSubagent': { payload: ChatStopSubagentPayloadSchema, result: EmptySchema },
98
99
  'chat.stopTask': { payload: ChatStopTaskPayloadSchema, result: EmptySchema },
100
+ 'chat.goal': { payload: ChatGoalPayloadSchema, result: EmptySchema },
99
101
  'chat.addBookmark': { payload: ChatAddBookmarkPayloadSchema, result: ChatBookmarksResultSchema },
100
102
  'chat.renameBookmark': { payload: ChatRenameBookmarkPayloadSchema, result: ChatBookmarksResultSchema },
101
103
  'chat.removeBookmark': { payload: ChatRemoveBookmarkPayloadSchema, result: ChatBookmarksResultSchema },
@@ -115,6 +117,8 @@ export const AGENT_REQUEST_SCHEMAS = {
115
117
  'usage.limits': { payload: EmptySchema, result: UsageLimitsSnapshotSchema },
116
118
  'usage.refreshLimits': { payload: EmptySchema, result: UsageLimitsSnapshotSchema },
117
119
  'chat.kill': { payload: ChatTargetPayloadSchema, result: EmptySchema },
120
+ // Ends the chat's CLI and keeps the conversation, which the next message resumes in a fresh process.
121
+ 'chat.restart': { payload: ChatTargetPayloadSchema, result: EmptySchema },
118
122
  'chat.list': { payload: EmptySchema, result: ChatListResultSchema }
119
123
  } as const;
120
124
 
package/src/record.ts ADDED
@@ -0,0 +1,4 @@
1
+ /* A plain object read off the wire or a file, whose fields are still unchecked; an array is not one. */
2
+ export function isRecord(value: unknown): value is Record<string, unknown> {
3
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
4
+ }
package/src/text.ts CHANGED
@@ -18,3 +18,20 @@ export function clipText(text: string, max: number): string {
18
18
  }
19
19
  return text.slice(0, end);
20
20
  }
21
+
22
+ // What a running tool call keeps of the output it streams; the host and every client cut it alike, so a delta grows both the same way.
23
+ export const TOOL_OUTPUT_TAIL = 64 * 1024;
24
+
25
+ /* `output` with `text` after it, cut to its last `TOOL_OUTPUT_TAIL` UTF-16 units, never between the halves of a surrogate pair. */
26
+ export function appendToolOutput(output: string | null, text: string): string {
27
+ const whole = (output ?? '') + text;
28
+ let start = whole.length - TOOL_OUTPUT_TAIL;
29
+ if (start <= 0) {
30
+ return whole;
31
+ }
32
+ const unit = whole.charCodeAt(start);
33
+ if (unit >= 0xdc00 && unit <= 0xdfff) {
34
+ start += 1;
35
+ }
36
+ return whole.slice(start);
37
+ }
package/src/visual.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { z } from 'zod';
2
+ import { isRecord } from './record.ts';
2
3
  import { visualViewportScript } from './visual-viewport.ts';
3
4
 
4
5
  /*
@@ -162,10 +163,6 @@ export function visualOpenLinkResult(id: VisualRequestId) {
162
163
  return { jsonrpc: '2.0', id, result: {} } as const;
163
164
  }
164
165
 
165
- function isRecord(value: unknown): value is Record<string, unknown> {
166
- return typeof value === 'object' && value !== null && !Array.isArray(value);
167
- }
168
-
169
166
  function sizeOf(value: unknown): number | undefined {
170
167
  return typeof value === 'number' && Number.isFinite(value) && value >= 0 ? value : undefined;
171
168
  }