@agentuity/core 2.0.10 → 2.0.12

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.
Files changed (110) hide show
  1. package/dist/services/api.d.ts +1 -1
  2. package/dist/services/api.d.ts.map +1 -1
  3. package/dist/services/api.js +4 -6
  4. package/dist/services/api.js.map +1 -1
  5. package/dist/services/coder/agents.d.ts +172 -0
  6. package/dist/services/coder/agents.d.ts.map +1 -0
  7. package/dist/services/coder/agents.js +77 -0
  8. package/dist/services/coder/agents.js.map +1 -0
  9. package/dist/services/coder/api-reference.d.ts.map +1 -1
  10. package/dist/services/coder/api-reference.js +459 -39
  11. package/dist/services/coder/api-reference.js.map +1 -1
  12. package/dist/services/coder/client.d.ts +47 -1
  13. package/dist/services/coder/client.d.ts.map +1 -1
  14. package/dist/services/coder/client.js +94 -1
  15. package/dist/services/coder/client.js.map +1 -1
  16. package/dist/services/coder/close-codes.d.ts +76 -0
  17. package/dist/services/coder/close-codes.d.ts.map +1 -0
  18. package/dist/services/coder/close-codes.js +77 -0
  19. package/dist/services/coder/close-codes.js.map +1 -0
  20. package/dist/services/coder/index.d.ts +10 -3
  21. package/dist/services/coder/index.d.ts.map +1 -1
  22. package/dist/services/coder/index.js +6 -1
  23. package/dist/services/coder/index.js.map +1 -1
  24. package/dist/services/coder/protocol.d.ts +2225 -0
  25. package/dist/services/coder/protocol.d.ts.map +1 -0
  26. package/dist/services/coder/protocol.js +1122 -0
  27. package/dist/services/coder/protocol.js.map +1 -0
  28. package/dist/services/coder/sessions.d.ts +31 -0
  29. package/dist/services/coder/sessions.d.ts.map +1 -1
  30. package/dist/services/coder/sessions.js +40 -7
  31. package/dist/services/coder/sessions.js.map +1 -1
  32. package/dist/services/coder/sse.d.ts +255 -0
  33. package/dist/services/coder/sse.d.ts.map +1 -0
  34. package/dist/services/coder/sse.js +788 -0
  35. package/dist/services/coder/sse.js.map +1 -0
  36. package/dist/services/coder/types.d.ts +1578 -0
  37. package/dist/services/coder/types.d.ts.map +1 -1
  38. package/dist/services/coder/types.js +377 -1
  39. package/dist/services/coder/types.js.map +1 -1
  40. package/dist/services/coder/websocket.d.ts +358 -0
  41. package/dist/services/coder/websocket.d.ts.map +1 -0
  42. package/dist/services/coder/websocket.js +863 -0
  43. package/dist/services/coder/websocket.js.map +1 -0
  44. package/dist/services/oauth/types.d.ts +10 -0
  45. package/dist/services/oauth/types.d.ts.map +1 -1
  46. package/dist/services/oauth/types.js +3 -0
  47. package/dist/services/oauth/types.js.map +1 -1
  48. package/dist/services/project/deploy.d.ts +1 -1
  49. package/dist/services/sandbox/api-reference.js +7 -7
  50. package/dist/services/sandbox/api-reference.js.map +1 -1
  51. package/dist/services/sandbox/client.d.ts +3 -2
  52. package/dist/services/sandbox/client.d.ts.map +1 -1
  53. package/dist/services/sandbox/client.js.map +1 -1
  54. package/dist/services/sandbox/create.d.ts +5 -0
  55. package/dist/services/sandbox/create.d.ts.map +1 -1
  56. package/dist/services/sandbox/create.js +8 -0
  57. package/dist/services/sandbox/create.js.map +1 -1
  58. package/dist/services/sandbox/get.d.ts +8 -4
  59. package/dist/services/sandbox/get.d.ts.map +1 -1
  60. package/dist/services/sandbox/get.js +28 -3
  61. package/dist/services/sandbox/get.js.map +1 -1
  62. package/dist/services/sandbox/getStatus.d.ts +2 -0
  63. package/dist/services/sandbox/getStatus.d.ts.map +1 -1
  64. package/dist/services/sandbox/getStatus.js +17 -1
  65. package/dist/services/sandbox/getStatus.js.map +1 -1
  66. package/dist/services/sandbox/index.d.ts +1 -1
  67. package/dist/services/sandbox/index.d.ts.map +1 -1
  68. package/dist/services/sandbox/list.d.ts +3 -0
  69. package/dist/services/sandbox/list.d.ts.map +1 -1
  70. package/dist/services/sandbox/list.js +5 -0
  71. package/dist/services/sandbox/list.js.map +1 -1
  72. package/dist/services/sandbox/pause.d.ts +17 -1
  73. package/dist/services/sandbox/pause.d.ts.map +1 -1
  74. package/dist/services/sandbox/pause.js +21 -3
  75. package/dist/services/sandbox/pause.js.map +1 -1
  76. package/dist/services/sandbox/run.d.ts +3 -2
  77. package/dist/services/sandbox/run.d.ts.map +1 -1
  78. package/dist/services/sandbox/run.js +145 -85
  79. package/dist/services/sandbox/run.js.map +1 -1
  80. package/dist/services/sandbox/types.d.ts +10 -4
  81. package/dist/services/sandbox/types.d.ts.map +1 -1
  82. package/dist/services/sandbox/types.js +10 -0
  83. package/dist/services/sandbox/types.js.map +1 -1
  84. package/dist/services/stream/namespaces.d.ts +2 -2
  85. package/dist/services/stream/namespaces.js +2 -2
  86. package/dist/services/stream/namespaces.js.map +1 -1
  87. package/package.json +2 -2
  88. package/src/services/api.ts +6 -7
  89. package/src/services/coder/agents.ts +148 -0
  90. package/src/services/coder/api-reference.ts +479 -43
  91. package/src/services/coder/client.ts +143 -0
  92. package/src/services/coder/close-codes.ts +83 -0
  93. package/src/services/coder/index.ts +32 -1
  94. package/src/services/coder/protocol.ts +1364 -0
  95. package/src/services/coder/sessions.ts +66 -10
  96. package/src/services/coder/sse.ts +955 -0
  97. package/src/services/coder/types.ts +462 -1
  98. package/src/services/coder/websocket.ts +1042 -0
  99. package/src/services/oauth/types.ts +3 -0
  100. package/src/services/sandbox/api-reference.ts +7 -7
  101. package/src/services/sandbox/client.ts +4 -4
  102. package/src/services/sandbox/create.ts +10 -0
  103. package/src/services/sandbox/get.ts +32 -3
  104. package/src/services/sandbox/getStatus.ts +20 -1
  105. package/src/services/sandbox/index.ts +1 -1
  106. package/src/services/sandbox/list.ts +5 -0
  107. package/src/services/sandbox/pause.ts +38 -4
  108. package/src/services/sandbox/run.ts +202 -108
  109. package/src/services/sandbox/types.ts +15 -2
  110. package/src/services/stream/namespaces.ts +2 -2
@@ -55,7 +55,7 @@ export type CoderSkillRef = z.infer<typeof CoderSkillRefSchema>;
55
55
  export const CoderSessionRepositoryRefSchema = z
56
56
  .object({
57
57
  repoId: z.string().optional().describe('Repository identifier when available'),
58
- type: z.string().optional().describe('Repository type (e.g., github, gitlab)'),
58
+ type: z.string().optional().describe('Repository type (e.g., GitHub, GitLab)'),
59
59
  provider: z.string().optional().describe('Git provider identifier'),
60
60
  owner: z.string().optional().describe('Repository owner or organization'),
61
61
  name: z.string().optional().describe('Repository name'),
@@ -115,6 +115,11 @@ export const CoderWorkspaceDetailSchema = z
115
115
  repoCount: z.number().describe('Number of repositories'),
116
116
  savedSkillIds: z.array(z.string()).describe('Saved skill IDs in workspace'),
117
117
  skillBucketIds: z.array(z.string()).describe('Skill bucket IDs in workspace'),
118
+ enabledAgents: z
119
+ .array(z.string())
120
+ .optional()
121
+ .default([])
122
+ .describe('Effective agent roster stored on the workspace'),
118
123
  selectionCount: z.number().describe('Total number of selections'),
119
124
  createdAt: z.string().describe('Creation timestamp (ISO-8601)'),
120
125
  updatedAt: z.string().describe('Last update timestamp (ISO-8601)'),
@@ -123,6 +128,176 @@ export const CoderWorkspaceDetailSchema = z
123
128
  .describe('Workspace detail returned by coder hub');
124
129
  export type CoderWorkspaceDetail = z.infer<typeof CoderWorkspaceDetailSchema>;
125
130
 
131
+ export const CoderCustomAgentThinkingLevelSchema = z
132
+ .enum(['off', 'minimal', 'low', 'medium', 'high', 'xhigh'])
133
+ .describe('Thinking level override for a custom agent');
134
+ export type CoderCustomAgentThinkingLevel = z.infer<typeof CoderCustomAgentThinkingLevelSchema>;
135
+
136
+ export const CODER_CUSTOM_AGENT_TOOLS = [
137
+ 'read',
138
+ 'ls',
139
+ 'find',
140
+ 'grep',
141
+ 'bash',
142
+ 'write',
143
+ 'edit',
144
+ ] as const;
145
+
146
+ export const CoderCustomAgentToolSchema = z
147
+ .enum(CODER_CUSTOM_AGENT_TOOLS)
148
+ .describe('Workspace tool available to a standalone custom agent');
149
+ export type CoderCustomAgentTool = z.infer<typeof CoderCustomAgentToolSchema>;
150
+
151
+ export const CoderCustomAgentToolResponseSchema = z
152
+ .union([CoderCustomAgentToolSchema, z.string()])
153
+ .describe('Workspace tool granted to a standalone custom agent');
154
+ export type CoderCustomAgentToolResponse = z.infer<typeof CoderCustomAgentToolResponseSchema>;
155
+
156
+ export const CODER_CUSTOM_AGENT_SERVICE_TOOLS = [
157
+ 'session_dashboard',
158
+ 'memory_service_search',
159
+ 'memory_service_store',
160
+ 'memory_service_get',
161
+ 'memory_service_update',
162
+ 'memory_service_delete',
163
+ 'memory_service_list',
164
+ 'memory_service_schema',
165
+ 'memory_service_facets',
166
+ 'context7_search',
167
+ 'grep_app_search',
168
+ 'web_search',
169
+ 'fetch_content',
170
+ 'product_prd_create',
171
+ 'product_prd_get',
172
+ 'product_prd_update',
173
+ 'product_prd_list',
174
+ 'product_task_comment',
175
+ 'session_todo_create',
176
+ 'session_todo_update',
177
+ 'session_todo_list',
178
+ 'session_todo_comment',
179
+ 'session_todo_attach',
180
+ 'product_generate_deck',
181
+ 'sandbox_exec',
182
+ 'loop_get_state',
183
+ 'loop_update_state',
184
+ 'coord_create_job',
185
+ 'coord_add_task',
186
+ 'coord_claim_task',
187
+ 'coord_complete_task',
188
+ 'coord_fail_task',
189
+ 'coord_list_tasks',
190
+ 'coord_job_status',
191
+ 'coord_reserve_file',
192
+ 'coord_release_file',
193
+ 'coord_provide_contract',
194
+ 'coord_check_contract',
195
+ 'coord_send_message',
196
+ 'coord_read_messages',
197
+ 'coord_heartbeat',
198
+ 'coord_spawn_workers',
199
+ ] as const;
200
+
201
+ export const CoderCustomAgentServiceToolSchema = z
202
+ .enum(CODER_CUSTOM_AGENT_SERVICE_TOOLS)
203
+ .describe('Service tool available to a standalone custom agent');
204
+ export type CoderCustomAgentServiceTool = z.infer<typeof CoderCustomAgentServiceToolSchema>;
205
+
206
+ export const CoderCustomAgentServiceToolResponseSchema = z
207
+ .union([CoderCustomAgentServiceToolSchema, z.string()])
208
+ .describe('Service tool granted to a standalone custom agent');
209
+ export type CoderCustomAgentServiceToolResponse = z.infer<
210
+ typeof CoderCustomAgentServiceToolResponseSchema
211
+ >;
212
+
213
+ export const CoderCustomAgentSnapshotSchema = z
214
+ .object({
215
+ slug: z.string().describe('Stable custom agent slug'),
216
+ displayName: z.string().describe('Human-readable custom agent name'),
217
+ description: z.string().optional().describe('Optional custom agent description'),
218
+ instructions: z.string().describe('Standalone custom-agent system prompt'),
219
+ model: z.string().optional().describe('Optional model override'),
220
+ thinkingLevel: CoderCustomAgentThinkingLevelSchema.optional().describe(
221
+ 'Optional thinking level override'
222
+ ),
223
+ headlessCompatible: z
224
+ .boolean()
225
+ .describe('Whether the custom agent is safe for non-interactive callers'),
226
+ tools: z
227
+ .array(CoderCustomAgentToolResponseSchema)
228
+ .describe('Workspace tools granted to the custom agent'),
229
+ serviceTools: z
230
+ .array(CoderCustomAgentServiceToolResponseSchema)
231
+ .describe('Service tools granted to the custom agent'),
232
+ savedSkills: z
233
+ .array(CoderSkillRefSchema)
234
+ .describe('Frozen saved-skill refs attached to the custom agent snapshot'),
235
+ companionAgents: z
236
+ .array(z.string())
237
+ .default([])
238
+ .describe('Companion agents auto-included alongside this custom agent'),
239
+ })
240
+ .passthrough()
241
+ .describe('Custom agent snapshot returned by coder hub');
242
+ export type CoderCustomAgentSnapshot = z.infer<typeof CoderCustomAgentSnapshotSchema>;
243
+
244
+ export const CoderCustomAgentVersionSchema = CoderCustomAgentSnapshotSchema.extend({
245
+ id: z.string().describe('Published custom agent version identifier'),
246
+ agentId: z.string().describe('Parent custom agent identifier'),
247
+ version: z.number().int().describe('Published version number'),
248
+ createdByUserId: z.string().describe('User who published the version'),
249
+ createdAt: z.string().describe('Version creation timestamp (ISO-8601)'),
250
+ })
251
+ .passthrough()
252
+ .describe('Published custom agent version returned by coder hub');
253
+ export type CoderCustomAgentVersion = z.infer<typeof CoderCustomAgentVersionSchema>;
254
+
255
+ export const CoderCustomAgentSchema = CoderCustomAgentSnapshotSchema.extend({
256
+ id: z.string().describe('Custom agent record identifier'),
257
+ ownerUserId: z.string().describe('Owner user identifier'),
258
+ lifecycle: z
259
+ .enum(['draft', 'published', 'archived'])
260
+ .describe('Current lifecycle state for the custom agent'),
261
+ visibility: z.enum(['org', 'private_draft']).describe('Visibility tier for the custom agent'),
262
+ createdAt: z.string().describe('Creation timestamp (ISO-8601)'),
263
+ updatedAt: z.string().describe('Last update timestamp (ISO-8601)'),
264
+ hasPublishedVersion: z
265
+ .boolean()
266
+ .describe('Whether the agent has at least one published version'),
267
+ hasUnpublishedChanges: z
268
+ .boolean()
269
+ .describe('Whether the current draft differs from the latest published version'),
270
+ latestPublishedVersion: z.number().int().optional().describe('Latest published version number'),
271
+ latestPublishedAt: z.string().optional().describe('Latest published timestamp (ISO-8601)'),
272
+ published: CoderCustomAgentVersionSchema.optional().describe(
273
+ 'Latest published version snapshot'
274
+ ),
275
+ draft: CoderCustomAgentSnapshotSchema.optional().describe('Owner-visible draft snapshot'),
276
+ })
277
+ .passthrough()
278
+ .describe('Custom agent record returned by coder hub');
279
+ export type CoderCustomAgent = z.infer<typeof CoderCustomAgentSchema>;
280
+
281
+ export const CoderCustomAgentListResponseSchema = z
282
+ .object({
283
+ agents: z.array(CoderCustomAgentSchema).describe('Custom agents returned by coder hub'),
284
+ })
285
+ .passthrough()
286
+ .describe('Response payload for listing custom agents');
287
+ export type CoderCustomAgentListResponse = z.infer<typeof CoderCustomAgentListResponseSchema>;
288
+
289
+ export const CoderCustomAgentVersionListResponseSchema = z
290
+ .object({
291
+ versions: z
292
+ .array(CoderCustomAgentVersionSchema)
293
+ .describe('Published custom agent versions returned by coder hub'),
294
+ })
295
+ .passthrough()
296
+ .describe('Response payload for listing custom agent versions');
297
+ export type CoderCustomAgentVersionListResponse = z.infer<
298
+ typeof CoderCustomAgentVersionListResponseSchema
299
+ >;
300
+
126
301
  export const CoderSavedSkillListResponseSchema = z
127
302
  .object({
128
303
  skills: z.array(CoderSavedSkillSchema).describe('Saved skills returned by coder hub'),
@@ -147,6 +322,20 @@ export const CoderWorkspaceListResponseSchema = z
147
322
  .describe('Response payload for listing workspaces');
148
323
  export type CoderWorkspaceListResponse = z.infer<typeof CoderWorkspaceListResponseSchema>;
149
324
 
325
+ function hasWorkspaceSelections(input: {
326
+ repos?: unknown[];
327
+ savedSkillIds?: unknown[];
328
+ skillBucketIds?: unknown[];
329
+ enabledAgents?: unknown[];
330
+ }): boolean {
331
+ return (
332
+ (input.repos?.length ?? 0) > 0 ||
333
+ (input.savedSkillIds?.length ?? 0) > 0 ||
334
+ (input.skillBucketIds?.length ?? 0) > 0 ||
335
+ (input.enabledAgents?.length ?? 0) > 0
336
+ );
337
+ }
338
+
150
339
  export const CoderCreateWorkspaceRequestSchema = z
151
340
  .object({
152
341
  name: z.string().describe('Workspace name'),
@@ -155,10 +344,85 @@ export const CoderCreateWorkspaceRequestSchema = z
155
344
  repos: z.array(CoderSessionRepositoryRefSchema).optional().describe('Repositories'),
156
345
  savedSkillIds: z.array(z.string()).optional().describe('Saved skill IDs'),
157
346
  skillBucketIds: z.array(z.string()).optional().describe('Skill bucket IDs'),
347
+ enabledAgents: z
348
+ .array(z.string())
349
+ .optional()
350
+ .describe('Effective agent roster to store on the workspace'),
351
+ })
352
+ .refine(hasWorkspaceSelections, {
353
+ message: 'A workspace needs at least one repo, saved skill, skill bucket, or agent',
158
354
  })
159
355
  .describe('Request body for creating a workspace');
160
356
  export type CoderCreateWorkspaceRequest = z.infer<typeof CoderCreateWorkspaceRequestSchema>;
161
357
 
358
+ export const CoderCreateCustomAgentRequestSchema = z
359
+ .object({
360
+ slug: z.string().describe('Stable custom agent slug'),
361
+ displayName: z.string().describe('Human-readable custom agent name'),
362
+ description: z.string().optional().describe('Optional custom agent description'),
363
+ instructions: z.string().describe('Standalone custom-agent system prompt'),
364
+ model: z.string().optional().describe('Optional model override'),
365
+ thinkingLevel: CoderCustomAgentThinkingLevelSchema.optional().describe(
366
+ 'Optional thinking level override'
367
+ ),
368
+ headlessCompatible: z
369
+ .boolean()
370
+ .optional()
371
+ .describe('Whether the custom agent is safe for non-interactive callers'),
372
+ tools: z
373
+ .array(CoderCustomAgentToolSchema)
374
+ .optional()
375
+ .describe('Workspace tools to grant to the custom agent'),
376
+ serviceTools: z
377
+ .array(CoderCustomAgentServiceToolSchema)
378
+ .optional()
379
+ .describe('Service tools to grant to the custom agent'),
380
+ savedSkillIds: z
381
+ .array(z.string())
382
+ .optional()
383
+ .describe('Saved skill row ids to snapshot onto the custom agent'),
384
+ companionAgents: z
385
+ .array(z.string())
386
+ .optional()
387
+ .describe('Agent names to auto-include alongside this custom agent'),
388
+ })
389
+ .describe('Request body for creating a custom agent draft');
390
+ export type CoderCreateCustomAgentRequest = z.infer<typeof CoderCreateCustomAgentRequestSchema>;
391
+
392
+ export const CoderUpdateCustomAgentRequestSchema = z
393
+ .object({
394
+ slug: z.string().optional().describe('Stable custom agent slug'),
395
+ displayName: z.string().optional().describe('Human-readable custom agent name'),
396
+ description: z.string().nullable().optional().describe('Optional custom agent description'),
397
+ instructions: z.string().optional().describe('Standalone custom-agent system prompt'),
398
+ model: z.string().nullable().optional().describe('Optional model override'),
399
+ thinkingLevel: CoderCustomAgentThinkingLevelSchema.nullable()
400
+ .optional()
401
+ .describe('Optional thinking level override'),
402
+ headlessCompatible: z
403
+ .boolean()
404
+ .optional()
405
+ .describe('Whether the custom agent is safe for non-interactive callers'),
406
+ tools: z
407
+ .array(CoderCustomAgentToolSchema)
408
+ .optional()
409
+ .describe('Workspace tools to grant to the custom agent'),
410
+ serviceTools: z
411
+ .array(CoderCustomAgentServiceToolSchema)
412
+ .optional()
413
+ .describe('Service tools to grant to the custom agent'),
414
+ savedSkillIds: z
415
+ .array(z.string())
416
+ .optional()
417
+ .describe('Saved skill row ids to snapshot onto the custom agent'),
418
+ companionAgents: z
419
+ .array(z.string())
420
+ .optional()
421
+ .describe('Agent names to auto-include alongside this custom agent'),
422
+ })
423
+ .describe('Request body for updating a custom agent draft');
424
+ export type CoderUpdateCustomAgentRequest = z.infer<typeof CoderUpdateCustomAgentRequestSchema>;
425
+
162
426
  export const CoderSaveSkillRequestSchema = z
163
427
  .object({
164
428
  repo: z.string().describe('Repository identifier'),
@@ -209,10 +473,18 @@ export const CoderCreateSessionRequestSchema = z
209
473
  task: z.string().describe('Primary task prompt for the session'),
210
474
  label: z.string().optional().describe('Human-readable session label'),
211
475
  agent: z.string().optional().describe('Default agent identifier to use for execution'),
476
+ defaultAgent: z
477
+ .string()
478
+ .optional()
479
+ .describe('Preferred default agent identifier for routing session prompts'),
212
480
  visibility: CoderSessionVisibilitySchema.optional().describe('Session visibility setting'),
213
481
  workflowMode: CoderWorkflowModeSchema.optional().describe('Workflow execution mode'),
214
482
  loop: CoderSessionLoopConfigSchema.optional().describe('Loop mode settings for the session'),
215
483
  tags: z.array(z.string()).optional().describe('Tags applied to the session for filtering'),
484
+ enabledAgents: z
485
+ .array(z.string())
486
+ .optional()
487
+ .describe('Enabled agent roster to include in the session'),
216
488
  savedSkillIds: z
217
489
  .array(z.string())
218
490
  .optional()
@@ -248,14 +520,72 @@ export const CoderCreateSessionRequestSchema = z
248
520
  .describe('Request body for creating a coder session');
249
521
  export type CoderCreateSessionRequest = z.infer<typeof CoderCreateSessionRequestSchema>;
250
522
 
523
+ function inferCoderAgentBuilderSessionMode(input: {
524
+ mode?: 'new' | 'edit' | 'from_session';
525
+ sourceSessionId?: string;
526
+ targetAgentId?: string;
527
+ targetAgentSlug?: string;
528
+ }): 'new' | 'edit' | 'from_session' {
529
+ if (input.mode) return input.mode;
530
+ if (input.sourceSessionId) return 'from_session';
531
+ if (input.targetAgentId || input.targetAgentSlug) return 'edit';
532
+ return 'new';
533
+ }
534
+
535
+ export const CoderCreateAgentBuilderSessionRequestSchema = z
536
+ .object({
537
+ label: z.string().optional().describe('Builder session label override'),
538
+ prompt: z.string().optional().describe('Optional user focus for the builder session kickoff'),
539
+ mode: z
540
+ .enum(['new', 'edit', 'from_session'])
541
+ .optional()
542
+ .describe('Builder launch mode override'),
543
+ visibility: CoderSessionVisibilitySchema.optional().describe('Builder session visibility'),
544
+ sourceSessionId: z
545
+ .string()
546
+ .optional()
547
+ .describe('Source session identifier for build-from-session launches'),
548
+ targetAgentId: z
549
+ .string()
550
+ .optional()
551
+ .describe('Target custom-agent identifier for edit launches'),
552
+ targetAgentSlug: z.string().optional().describe('Target custom-agent slug for edit launches'),
553
+ })
554
+ .superRefine((value, ctx) => {
555
+ const mode = inferCoderAgentBuilderSessionMode(value);
556
+ if (mode === 'from_session' && !value.sourceSessionId?.trim()) {
557
+ ctx.addIssue({
558
+ code: z.ZodIssueCode.custom,
559
+ path: ['sourceSessionId'],
560
+ message: 'sourceSessionId is required for from-session builder launches.',
561
+ });
562
+ }
563
+ if (mode === 'edit' && !value.targetAgentId?.trim() && !value.targetAgentSlug?.trim()) {
564
+ ctx.addIssue({
565
+ code: z.ZodIssueCode.custom,
566
+ path: ['targetAgentId'],
567
+ message: 'targetAgentId or targetAgentSlug is required for edit launches.',
568
+ });
569
+ }
570
+ })
571
+ .describe('Request body for creating an agent-builder session');
572
+ export type CoderCreateAgentBuilderSessionRequest = z.infer<
573
+ typeof CoderCreateAgentBuilderSessionRequestSchema
574
+ >;
575
+
251
576
  export const CoderUpdateSessionRequestSchema = z
252
577
  .object({
253
578
  label: z.string().optional().describe('Updated session label'),
254
579
  agent: z.string().optional().describe('Updated default agent identifier'),
580
+ defaultAgent: z.string().optional().describe('Updated preferred default agent identifier'),
255
581
  visibility: CoderSessionVisibilitySchema.optional().describe('Updated visibility setting'),
256
582
  workflowMode: CoderWorkflowModeSchema.optional().describe('Updated workflow mode'),
257
583
  loop: CoderSessionLoopConfigSchema.optional().describe('Updated loop mode configuration'),
258
584
  tags: z.array(z.string()).optional().describe('Updated set of tags for the session'),
585
+ enabledAgents: z
586
+ .array(z.string())
587
+ .optional()
588
+ .describe('Updated enabled agent roster for the session'),
259
589
  skills: z
260
590
  .array(CoderSkillRefSchema)
261
591
  .optional()
@@ -297,6 +627,126 @@ export const CoderSessionWorkspaceSchema = z
297
627
  .describe('Workspace associated with a coder session');
298
628
  export type CoderSessionWorkspace = z.infer<typeof CoderSessionWorkspaceSchema>;
299
629
 
630
+ export const CoderAgentBuilderSessionModeSchema = z
631
+ .enum(['new', 'edit', 'from_session'])
632
+ .describe('Agent-builder launch mode for a builder session');
633
+ export type CoderAgentBuilderSessionMode = z.infer<typeof CoderAgentBuilderSessionModeSchema>;
634
+
635
+ export const CoderAgentBuilderActionKindSchema = z
636
+ .enum(['create_draft', 'update_draft', 'publish'])
637
+ .describe('Durable builder action emitted by an agent-builder session');
638
+ export type CoderAgentBuilderActionKind = z.infer<typeof CoderAgentBuilderActionKindSchema>;
639
+
640
+ export const CoderAgentBuilderSourceSessionSchema = z
641
+ .object({
642
+ sessionId: z.string().describe('Source session identifier linked to the builder session'),
643
+ label: z.string().optional().describe('Source session label when available'),
644
+ })
645
+ .describe('Source session reference used by agent-builder flows');
646
+ export type CoderAgentBuilderSourceSession = z.infer<typeof CoderAgentBuilderSourceSessionSchema>;
647
+
648
+ export const CoderAgentBuilderTargetAgentSchema = z
649
+ .object({
650
+ agentId: z.string().optional().describe('Target custom-agent identifier when editing'),
651
+ slug: z.string().describe('Target custom-agent slug'),
652
+ displayName: z.string().optional().describe('Target custom-agent display name'),
653
+ })
654
+ .describe('Target custom-agent reference for agent-builder edit flows');
655
+ export type CoderAgentBuilderTargetAgent = z.infer<typeof CoderAgentBuilderTargetAgentSchema>;
656
+
657
+ export const CoderAgentBuilderProposalSchema = z
658
+ .object({
659
+ slug: z.string().optional().describe('Proposed custom-agent slug'),
660
+ displayName: z.string().optional().describe('Proposed custom-agent name'),
661
+ description: z.string().optional().describe('Proposed custom-agent description'),
662
+ instructions: z.string().optional().describe('Proposed custom-agent system prompt'),
663
+ model: z.string().optional().describe('Proposed model override'),
664
+ thinkingLevel: CoderCustomAgentThinkingLevelSchema.optional().describe(
665
+ 'Proposed thinking level override'
666
+ ),
667
+ headlessCompatible: z
668
+ .boolean()
669
+ .optional()
670
+ .describe('Whether the proposed agent is safe for non-interactive callers'),
671
+ tools: z
672
+ .array(CoderCustomAgentToolResponseSchema)
673
+ .default([])
674
+ .describe('Proposed workspace tools for the agent'),
675
+ serviceTools: z
676
+ .array(CoderCustomAgentServiceToolResponseSchema)
677
+ .default([])
678
+ .describe('Proposed service tools for the agent'),
679
+ savedSkills: z
680
+ .array(CoderSkillRefSchema)
681
+ .default([])
682
+ .describe('Proposed frozen skill refs to attach'),
683
+ companionAgents: z
684
+ .array(z.string())
685
+ .default([])
686
+ .describe('Proposed companion agents to auto-include'),
687
+ })
688
+ .passthrough()
689
+ .describe('Session-scoped agent-builder proposal state');
690
+ export type CoderAgentBuilderProposal = z.infer<typeof CoderAgentBuilderProposalSchema>;
691
+
692
+ export const CoderAgentBuilderDurableStateSchema = z
693
+ .object({
694
+ draftAgentId: z.string().optional().describe('Linked draft custom-agent identifier'),
695
+ draftAgentSlug: z.string().optional().describe('Linked draft custom-agent slug'),
696
+ lastPublishedVersion: z
697
+ .number()
698
+ .int()
699
+ .optional()
700
+ .describe('Latest published version created through the builder flow'),
701
+ })
702
+ .describe('Durable agent-library state associated with a builder session');
703
+ export type CoderAgentBuilderDurableState = z.infer<typeof CoderAgentBuilderDurableStateSchema>;
704
+
705
+ export const CoderAgentBuilderActionStateSchema = z
706
+ .object({
707
+ kind: CoderAgentBuilderActionKindSchema.describe('Last durable builder action'),
708
+ status: z.enum(['completed', 'failed']).describe('Result of the last durable builder action'),
709
+ occurredAt: z.string().describe('Timestamp of the last durable builder action'),
710
+ message: z.string().optional().describe('Human-readable builder action result summary'),
711
+ agentId: z.string().optional().describe('Affected custom-agent identifier'),
712
+ agentSlug: z.string().optional().describe('Affected custom-agent slug'),
713
+ publishedVersion: z
714
+ .number()
715
+ .int()
716
+ .optional()
717
+ .describe('Published version number when publish succeeded'),
718
+ })
719
+ .describe('Latest durable action emitted by a builder session');
720
+ export type CoderAgentBuilderActionState = z.infer<typeof CoderAgentBuilderActionStateSchema>;
721
+
722
+ export const CoderAgentBuilderSessionSummarySchema = z
723
+ .object({
724
+ mode: CoderAgentBuilderSessionModeSchema.describe('Builder session mode'),
725
+ sourceSession: CoderAgentBuilderSourceSessionSchema.optional().describe(
726
+ 'Linked source session when the builder was launched from an existing session'
727
+ ),
728
+ targetAgent: CoderAgentBuilderTargetAgentSchema.optional().describe(
729
+ 'Target agent baseline when the builder is editing an existing custom agent'
730
+ ),
731
+ durable: CoderAgentBuilderDurableStateSchema.optional().describe(
732
+ 'Linked durable draft/publish state'
733
+ ),
734
+ lastAction: CoderAgentBuilderActionStateSchema.optional().describe(
735
+ 'Most recent durable builder action'
736
+ ),
737
+ })
738
+ .describe('Projected builder-session summary returned in session listings');
739
+ export type CoderAgentBuilderSessionSummary = z.infer<typeof CoderAgentBuilderSessionSummarySchema>;
740
+
741
+ export const CoderAgentBuilderSessionStateSchema = CoderAgentBuilderSessionSummarySchema.extend({
742
+ proposal: CoderAgentBuilderProposalSchema.optional().describe(
743
+ 'Full builder proposal state projected in session detail responses'
744
+ ),
745
+ })
746
+ .passthrough()
747
+ .describe('Full builder-session state returned in session details');
748
+ export type CoderAgentBuilderSessionState = z.infer<typeof CoderAgentBuilderSessionStateSchema>;
749
+
300
750
  export const CoderSessionListItemSchema = z
301
751
  .object({
302
752
  sessionId: z.string().describe('Unique session identifier'),
@@ -337,6 +787,14 @@ export const CoderSessionListItemSchema = z
337
787
  participantCount: z.number().describe('Total number of participants in the session'),
338
788
  tags: z.array(z.string()).describe('Tag values attached to the session'),
339
789
  skills: z.array(CoderSkillRefSchema).describe('Skills attached to the session'),
790
+ enabledAgents: z
791
+ .array(z.string())
792
+ .optional()
793
+ .default([])
794
+ .describe('Enabled agent roster attached to the session'),
795
+ builder: CoderAgentBuilderSessionSummarySchema.optional().describe(
796
+ 'Projected builder-session summary when this session is an agent-builder flow'
797
+ ),
340
798
  defaultAgent: z.string().optional().describe('Default agent assigned to session operations'),
341
799
  bucket: CoderSessionBucketSchema.describe('Derived bucket for session listing'),
342
800
  runtimeAvailable: z.boolean().describe('Whether runtime is currently reachable'),
@@ -368,6 +826,9 @@ export const CoderSessionSchema = CoderSessionListItemSchema.extend({
368
826
  .string()
369
827
  .optional()
370
828
  .describe('Last update timestamp for session metadata (ISO-8601)'),
829
+ builder: CoderAgentBuilderSessionStateSchema.optional().describe(
830
+ 'Full builder-session state when this session is an agent-builder flow'
831
+ ),
371
832
  // These fields are present in list items but may be absent in detail responses
372
833
  lastActivityAt: z.string().optional().describe('Timestamp of most recent activity (ISO-8601)'),
373
834
  taskCount: z.number().optional().describe('Number of tasks associated with the session'),