@agentuity/core 2.0.11 → 2.0.13

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 (101) 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 +6 -4
  6. package/dist/services/coder/agents.d.ts.map +1 -1
  7. package/dist/services/coder/api-reference.d.ts.map +1 -1
  8. package/dist/services/coder/api-reference.js +78 -10
  9. package/dist/services/coder/api-reference.js.map +1 -1
  10. package/dist/services/coder/client.d.ts +17 -1
  11. package/dist/services/coder/client.d.ts.map +1 -1
  12. package/dist/services/coder/client.js +30 -2
  13. package/dist/services/coder/client.js.map +1 -1
  14. package/dist/services/coder/index.d.ts +2 -2
  15. package/dist/services/coder/index.d.ts.map +1 -1
  16. package/dist/services/coder/index.js +1 -1
  17. package/dist/services/coder/index.js.map +1 -1
  18. package/dist/services/coder/protocol.d.ts +385 -15
  19. package/dist/services/coder/protocol.d.ts.map +1 -1
  20. package/dist/services/coder/protocol.js +148 -2
  21. package/dist/services/coder/protocol.js.map +1 -1
  22. package/dist/services/coder/sessions.d.ts +24 -2
  23. package/dist/services/coder/sessions.d.ts.map +1 -1
  24. package/dist/services/coder/sessions.js +10 -1
  25. package/dist/services/coder/sessions.js.map +1 -1
  26. package/dist/services/coder/sse.d.ts +2 -2
  27. package/dist/services/coder/sse.d.ts.map +1 -1
  28. package/dist/services/coder/sse.js +290 -178
  29. package/dist/services/coder/sse.js.map +1 -1
  30. package/dist/services/coder/types.d.ts +680 -42
  31. package/dist/services/coder/types.d.ts.map +1 -1
  32. package/dist/services/coder/types.js +284 -40
  33. package/dist/services/coder/types.js.map +1 -1
  34. package/dist/services/coder/websocket.d.ts +13 -1
  35. package/dist/services/coder/websocket.d.ts.map +1 -1
  36. package/dist/services/coder/websocket.js +91 -19
  37. package/dist/services/coder/websocket.js.map +1 -1
  38. package/dist/services/coder/workspaces.d.ts +11 -1
  39. package/dist/services/coder/workspaces.d.ts.map +1 -1
  40. package/dist/services/coder/workspaces.js +34 -1
  41. package/dist/services/coder/workspaces.js.map +1 -1
  42. package/dist/services/sandbox/api-reference.js +8 -8
  43. package/dist/services/sandbox/api-reference.js.map +1 -1
  44. package/dist/services/sandbox/client.d.ts +3 -2
  45. package/dist/services/sandbox/client.d.ts.map +1 -1
  46. package/dist/services/sandbox/client.js.map +1 -1
  47. package/dist/services/sandbox/create.d.ts +5 -0
  48. package/dist/services/sandbox/create.d.ts.map +1 -1
  49. package/dist/services/sandbox/create.js +8 -0
  50. package/dist/services/sandbox/create.js.map +1 -1
  51. package/dist/services/sandbox/get.d.ts +8 -4
  52. package/dist/services/sandbox/get.d.ts.map +1 -1
  53. package/dist/services/sandbox/get.js +28 -3
  54. package/dist/services/sandbox/get.js.map +1 -1
  55. package/dist/services/sandbox/getStatus.d.ts +2 -0
  56. package/dist/services/sandbox/getStatus.d.ts.map +1 -1
  57. package/dist/services/sandbox/getStatus.js +17 -1
  58. package/dist/services/sandbox/getStatus.js.map +1 -1
  59. package/dist/services/sandbox/index.d.ts +1 -1
  60. package/dist/services/sandbox/index.d.ts.map +1 -1
  61. package/dist/services/sandbox/list.d.ts +3 -0
  62. package/dist/services/sandbox/list.d.ts.map +1 -1
  63. package/dist/services/sandbox/list.js +5 -0
  64. package/dist/services/sandbox/list.js.map +1 -1
  65. package/dist/services/sandbox/pause.d.ts +17 -1
  66. package/dist/services/sandbox/pause.d.ts.map +1 -1
  67. package/dist/services/sandbox/pause.js +21 -3
  68. package/dist/services/sandbox/pause.js.map +1 -1
  69. package/dist/services/sandbox/run.d.ts +3 -2
  70. package/dist/services/sandbox/run.d.ts.map +1 -1
  71. package/dist/services/sandbox/run.js +145 -85
  72. package/dist/services/sandbox/run.js.map +1 -1
  73. package/dist/services/sandbox/types.d.ts +11 -4
  74. package/dist/services/sandbox/types.d.ts.map +1 -1
  75. package/dist/services/sandbox/types.js +12 -0
  76. package/dist/services/sandbox/types.js.map +1 -1
  77. package/dist/services/stream/namespaces.d.ts +2 -2
  78. package/dist/services/stream/namespaces.js +2 -2
  79. package/dist/services/stream/namespaces.js.map +1 -1
  80. package/package.json +2 -2
  81. package/src/services/api.ts +6 -7
  82. package/src/services/coder/api-reference.ts +79 -9
  83. package/src/services/coder/client.ts +46 -0
  84. package/src/services/coder/index.ts +3 -0
  85. package/src/services/coder/protocol.ts +166 -2
  86. package/src/services/coder/sessions.ts +26 -0
  87. package/src/services/coder/sse.ts +343 -184
  88. package/src/services/coder/types.ts +350 -44
  89. package/src/services/coder/websocket.ts +120 -21
  90. package/src/services/coder/workspaces.ts +74 -0
  91. package/src/services/sandbox/api-reference.ts +8 -8
  92. package/src/services/sandbox/client.ts +4 -4
  93. package/src/services/sandbox/create.ts +10 -0
  94. package/src/services/sandbox/get.ts +32 -3
  95. package/src/services/sandbox/getStatus.ts +20 -1
  96. package/src/services/sandbox/index.ts +1 -1
  97. package/src/services/sandbox/list.ts +5 -0
  98. package/src/services/sandbox/pause.ts +38 -4
  99. package/src/services/sandbox/run.ts +202 -108
  100. package/src/services/sandbox/types.ts +17 -2
  101. package/src/services/stream/namespaces.ts +2 -2
@@ -113,13 +113,40 @@ export const CoderWorkspaceDetailSchema = z
113
113
  ownerUserId: z.string().describe('Owner user ID'),
114
114
  repos: z.array(CoderSessionRepositoryRefSchema).describe('Repositories in workspace'),
115
115
  repoCount: z.number().describe('Number of repositories'),
116
+ dependencies: z
117
+ .array(z.string())
118
+ .optional()
119
+ .default([])
120
+ .describe('APT package dependencies installed into workspace snapshots'),
121
+ setupScript: z
122
+ .string()
123
+ .optional()
124
+ .default('')
125
+ .describe('Shell script run while preparing workspace snapshots'),
126
+ snapshot: z
127
+ .object({
128
+ status: z.string().describe('Workspace snapshot build status'),
129
+ snapshotId: z.string().optional().describe('Created sandbox snapshot ID'),
130
+ snapshotRef: z.string().optional().describe('Snapshot reference used for sessions'),
131
+ baseSnapshotRef: z.string().optional().describe('Base session snapshot reference'),
132
+ baseDriverVersion: z.string().optional().describe('Base driver version stamp'),
133
+ configHash: z.string().optional().describe('Workspace snapshot input hash'),
134
+ buildId: z.string().optional().describe('Workspace snapshot build identifier'),
135
+ requestedAt: z.string().optional().describe('Snapshot build request timestamp'),
136
+ updatedAt: z.string().optional().describe('Snapshot build update timestamp'),
137
+ createdAt: z.string().optional().describe('Snapshot creation timestamp'),
138
+ error: z.string().optional().describe('Snapshot build error message'),
139
+ })
140
+ .passthrough()
141
+ .optional()
142
+ .describe('Workspace snapshot metadata'),
116
143
  savedSkillIds: z.array(z.string()).describe('Saved skill IDs in workspace'),
117
144
  skillBucketIds: z.array(z.string()).describe('Skill bucket IDs in workspace'),
118
- agentSlugs: z
145
+ enabledAgents: z
119
146
  .array(z.string())
120
147
  .optional()
121
148
  .default([])
122
- .describe('Published custom agent slugs in workspace'),
149
+ .describe('Effective agent roster stored on the workspace'),
123
150
  selectionCount: z.number().describe('Total number of selections'),
124
151
  createdAt: z.string().describe('Creation timestamp (ISO-8601)'),
125
152
  updatedAt: z.string().describe('Last update timestamp (ISO-8601)'),
@@ -133,7 +160,7 @@ export const CoderCustomAgentThinkingLevelSchema = z
133
160
  .describe('Thinking level override for a custom agent');
134
161
  export type CoderCustomAgentThinkingLevel = z.infer<typeof CoderCustomAgentThinkingLevelSchema>;
135
162
 
136
- export const CODER_CUSTOM_AGENT_PI_TOOLS = [
163
+ export const CODER_CUSTOM_AGENT_TOOLS = [
137
164
  'read',
138
165
  'ls',
139
166
  'find',
@@ -143,17 +170,17 @@ export const CODER_CUSTOM_AGENT_PI_TOOLS = [
143
170
  'edit',
144
171
  ] as const;
145
172
 
146
- export const CoderCustomAgentPiToolSchema = z
147
- .enum(CODER_CUSTOM_AGENT_PI_TOOLS)
173
+ export const CoderCustomAgentToolSchema = z
174
+ .enum(CODER_CUSTOM_AGENT_TOOLS)
148
175
  .describe('Workspace tool available to a standalone custom agent');
149
- export type CoderCustomAgentPiTool = z.infer<typeof CoderCustomAgentPiToolSchema>;
176
+ export type CoderCustomAgentTool = z.infer<typeof CoderCustomAgentToolSchema>;
150
177
 
151
- export const CoderCustomAgentPiToolResponseSchema = z
152
- .union([CoderCustomAgentPiToolSchema, z.string()])
153
- .describe('Pi workspace tool granted to a standalone custom agent');
154
- export type CoderCustomAgentPiToolResponse = z.infer<typeof CoderCustomAgentPiToolResponseSchema>;
178
+ export const CoderCustomAgentToolResponseSchema = z
179
+ .union([CoderCustomAgentToolSchema, z.string()])
180
+ .describe('Workspace tool granted to a standalone custom agent');
181
+ export type CoderCustomAgentToolResponse = z.infer<typeof CoderCustomAgentToolResponseSchema>;
155
182
 
156
- export const CODER_CUSTOM_AGENT_HUB_TOOLS = [
183
+ export const CODER_CUSTOM_AGENT_SERVICE_TOOLS = [
157
184
  'session_dashboard',
158
185
  'memory_service_search',
159
186
  'memory_service_store',
@@ -198,15 +225,17 @@ export const CODER_CUSTOM_AGENT_HUB_TOOLS = [
198
225
  'coord_spawn_workers',
199
226
  ] as const;
200
227
 
201
- export const CoderCustomAgentHubToolSchema = z
202
- .enum(CODER_CUSTOM_AGENT_HUB_TOOLS)
203
- .describe('Hub-managed tool available to a standalone custom agent');
204
- export type CoderCustomAgentHubTool = z.infer<typeof CoderCustomAgentHubToolSchema>;
228
+ export const CoderCustomAgentServiceToolSchema = z
229
+ .enum(CODER_CUSTOM_AGENT_SERVICE_TOOLS)
230
+ .describe('Service tool available to a standalone custom agent');
231
+ export type CoderCustomAgentServiceTool = z.infer<typeof CoderCustomAgentServiceToolSchema>;
205
232
 
206
- export const CoderCustomAgentHubToolResponseSchema = z
207
- .union([CoderCustomAgentHubToolSchema, z.string()])
208
- .describe('Hub-managed tool granted to a standalone custom agent');
209
- export type CoderCustomAgentHubToolResponse = z.infer<typeof CoderCustomAgentHubToolResponseSchema>;
233
+ export const CoderCustomAgentServiceToolResponseSchema = z
234
+ .union([CoderCustomAgentServiceToolSchema, z.string()])
235
+ .describe('Service tool granted to a standalone custom agent');
236
+ export type CoderCustomAgentServiceToolResponse = z.infer<
237
+ typeof CoderCustomAgentServiceToolResponseSchema
238
+ >;
210
239
 
211
240
  export const CoderCustomAgentSnapshotSchema = z
212
241
  .object({
@@ -221,15 +250,19 @@ export const CoderCustomAgentSnapshotSchema = z
221
250
  headlessCompatible: z
222
251
  .boolean()
223
252
  .describe('Whether the custom agent is safe for non-interactive callers'),
224
- piTools: z
225
- .array(CoderCustomAgentPiToolResponseSchema)
226
- .describe('Pi workspace tools granted to the custom agent'),
227
- hubToolNames: z
228
- .array(CoderCustomAgentHubToolResponseSchema)
229
- .describe('Hub-managed tools granted to the custom agent'),
253
+ tools: z
254
+ .array(CoderCustomAgentToolResponseSchema)
255
+ .describe('Workspace tools granted to the custom agent'),
256
+ serviceTools: z
257
+ .array(CoderCustomAgentServiceToolResponseSchema)
258
+ .describe('Service tools granted to the custom agent'),
230
259
  savedSkills: z
231
260
  .array(CoderSkillRefSchema)
232
261
  .describe('Frozen saved-skill refs attached to the custom agent snapshot'),
262
+ companionAgents: z
263
+ .array(z.string())
264
+ .default([])
265
+ .describe('Companion agents auto-included alongside this custom agent'),
233
266
  })
234
267
  .passthrough()
235
268
  .describe('Custom agent snapshot returned by coder hub');
@@ -316,19 +349,105 @@ export const CoderWorkspaceListResponseSchema = z
316
349
  .describe('Response payload for listing workspaces');
317
350
  export type CoderWorkspaceListResponse = z.infer<typeof CoderWorkspaceListResponseSchema>;
318
351
 
352
+ function hasWorkspaceSelections(input: {
353
+ repos?: unknown[];
354
+ dependencies?: unknown[];
355
+ setupScript?: string;
356
+ savedSkillIds?: unknown[];
357
+ skillBucketIds?: unknown[];
358
+ enabledAgents?: unknown[];
359
+ }): boolean {
360
+ return (
361
+ (input.repos?.length ?? 0) > 0 ||
362
+ (input.dependencies?.length ?? 0) > 0 ||
363
+ Boolean(input.setupScript?.trim()) ||
364
+ (input.savedSkillIds?.length ?? 0) > 0 ||
365
+ (input.skillBucketIds?.length ?? 0) > 0 ||
366
+ (input.enabledAgents?.length ?? 0) > 0
367
+ );
368
+ }
369
+
319
370
  export const CoderCreateWorkspaceRequestSchema = z
320
371
  .object({
321
372
  name: z.string().describe('Workspace name'),
322
373
  description: z.string().optional().describe('Workspace description'),
323
374
  scope: z.enum(['user', 'org']).optional().describe('Workspace scope'),
324
375
  repos: z.array(CoderSessionRepositoryRefSchema).optional().describe('Repositories'),
376
+ dependencies: z
377
+ .array(z.string())
378
+ .optional()
379
+ .describe('APT package dependencies installed into workspace snapshots'),
380
+ setupScript: z
381
+ .string()
382
+ .optional()
383
+ .describe('Shell script run while preparing workspace snapshots'),
325
384
  savedSkillIds: z.array(z.string()).optional().describe('Saved skill IDs'),
326
385
  skillBucketIds: z.array(z.string()).optional().describe('Skill bucket IDs'),
327
- agentSlugs: z.array(z.string()).optional().describe('Published custom agent slugs'),
386
+ enabledAgents: z
387
+ .array(z.string())
388
+ .optional()
389
+ .describe('Effective agent roster to store on the workspace'),
390
+ })
391
+ .refine(hasWorkspaceSelections, {
392
+ message:
393
+ 'A workspace needs at least one repo, dependency, setup script, saved skill, skill bucket, or agent',
328
394
  })
329
395
  .describe('Request body for creating a workspace');
330
396
  export type CoderCreateWorkspaceRequest = z.infer<typeof CoderCreateWorkspaceRequestSchema>;
331
397
 
398
+ export const CoderUpdateWorkspaceRequestSchema = z
399
+ .object({
400
+ name: z.string().optional().describe('Workspace name'),
401
+ description: z.string().optional().describe('Workspace description'),
402
+ scope: z.enum(['user', 'org']).optional().describe('Workspace scope'),
403
+ repos: z.array(CoderSessionRepositoryRefSchema).optional().describe('Repositories'),
404
+ dependencies: z
405
+ .array(z.string())
406
+ .optional()
407
+ .describe('APT package dependencies installed into workspace snapshots'),
408
+ setupScript: z
409
+ .string()
410
+ .optional()
411
+ .describe('Shell script run while preparing workspace snapshots'),
412
+ savedSkillIds: z.array(z.string()).optional().describe('Saved skill IDs'),
413
+ skillBucketIds: z.array(z.string()).optional().describe('Skill bucket IDs'),
414
+ enabledAgents: z
415
+ .array(z.string())
416
+ .optional()
417
+ .describe('Effective agent roster to store on the workspace'),
418
+ })
419
+ .refine((input) => Object.keys(input).length > 0, {
420
+ message: 'At least one workspace field must be provided',
421
+ })
422
+ .describe('Request body for updating a workspace');
423
+ export type CoderUpdateWorkspaceRequest = z.infer<typeof CoderUpdateWorkspaceRequestSchema>;
424
+
425
+ export const CoderWorkspaceDependencyValidationResponseSchema = z
426
+ .object({
427
+ valid: z.array(z.string()).describe('Valid dependency package specs'),
428
+ invalid: z
429
+ .array(
430
+ z
431
+ .object({
432
+ package: z.string().describe('Invalid dependency package spec'),
433
+ error: z.string().describe('Validation error'),
434
+ requestedVersion: z.string().optional().describe('Requested package version'),
435
+ availableVersions: z
436
+ .array(z.string())
437
+ .optional()
438
+ .describe('Available package versions returned by validation'),
439
+ searchUrl: z.string().describe('Package search URL'),
440
+ })
441
+ .passthrough()
442
+ )
443
+ .describe('Invalid dependency package specs'),
444
+ })
445
+ .passthrough()
446
+ .describe('Workspace dependency validation result');
447
+ export type CoderWorkspaceDependencyValidationResponse = z.infer<
448
+ typeof CoderWorkspaceDependencyValidationResponseSchema
449
+ >;
450
+
332
451
  export const CoderCreateCustomAgentRequestSchema = z
333
452
  .object({
334
453
  slug: z.string().describe('Stable custom agent slug'),
@@ -343,18 +462,22 @@ export const CoderCreateCustomAgentRequestSchema = z
343
462
  .boolean()
344
463
  .optional()
345
464
  .describe('Whether the custom agent is safe for non-interactive callers'),
346
- piTools: z
347
- .array(CoderCustomAgentPiToolSchema)
465
+ tools: z
466
+ .array(CoderCustomAgentToolSchema)
348
467
  .optional()
349
- .describe('Pi workspace tools to grant to the custom agent'),
350
- hubToolNames: z
351
- .array(CoderCustomAgentHubToolSchema)
468
+ .describe('Workspace tools to grant to the custom agent'),
469
+ serviceTools: z
470
+ .array(CoderCustomAgentServiceToolSchema)
352
471
  .optional()
353
- .describe('Hub-managed tools to grant to the custom agent'),
472
+ .describe('Service tools to grant to the custom agent'),
354
473
  savedSkillIds: z
355
474
  .array(z.string())
356
475
  .optional()
357
476
  .describe('Saved skill row ids to snapshot onto the custom agent'),
477
+ companionAgents: z
478
+ .array(z.string())
479
+ .optional()
480
+ .describe('Agent names to auto-include alongside this custom agent'),
358
481
  })
359
482
  .describe('Request body for creating a custom agent draft');
360
483
  export type CoderCreateCustomAgentRequest = z.infer<typeof CoderCreateCustomAgentRequestSchema>;
@@ -373,18 +496,22 @@ export const CoderUpdateCustomAgentRequestSchema = z
373
496
  .boolean()
374
497
  .optional()
375
498
  .describe('Whether the custom agent is safe for non-interactive callers'),
376
- piTools: z
377
- .array(CoderCustomAgentPiToolSchema)
499
+ tools: z
500
+ .array(CoderCustomAgentToolSchema)
378
501
  .optional()
379
- .describe('Pi workspace tools to grant to the custom agent'),
380
- hubToolNames: z
381
- .array(CoderCustomAgentHubToolSchema)
502
+ .describe('Workspace tools to grant to the custom agent'),
503
+ serviceTools: z
504
+ .array(CoderCustomAgentServiceToolSchema)
382
505
  .optional()
383
- .describe('Hub-managed tools to grant to the custom agent'),
506
+ .describe('Service tools to grant to the custom agent'),
384
507
  savedSkillIds: z
385
508
  .array(z.string())
386
509
  .optional()
387
510
  .describe('Saved skill row ids to snapshot onto the custom agent'),
511
+ companionAgents: z
512
+ .array(z.string())
513
+ .optional()
514
+ .describe('Agent names to auto-include alongside this custom agent'),
388
515
  })
389
516
  .describe('Request body for updating a custom agent draft');
390
517
  export type CoderUpdateCustomAgentRequest = z.infer<typeof CoderUpdateCustomAgentRequestSchema>;
@@ -447,10 +574,10 @@ export const CoderCreateSessionRequestSchema = z
447
574
  workflowMode: CoderWorkflowModeSchema.optional().describe('Workflow execution mode'),
448
575
  loop: CoderSessionLoopConfigSchema.optional().describe('Loop mode settings for the session'),
449
576
  tags: z.array(z.string()).optional().describe('Tags applied to the session for filtering'),
450
- agentSlugs: z
577
+ enabledAgents: z
451
578
  .array(z.string())
452
579
  .optional()
453
- .describe('Published custom agent slugs to include in the session'),
580
+ .describe('Enabled agent roster to include in the session'),
454
581
  savedSkillIds: z
455
582
  .array(z.string())
456
583
  .optional()
@@ -486,6 +613,59 @@ export const CoderCreateSessionRequestSchema = z
486
613
  .describe('Request body for creating a coder session');
487
614
  export type CoderCreateSessionRequest = z.infer<typeof CoderCreateSessionRequestSchema>;
488
615
 
616
+ function inferCoderAgentBuilderSessionMode(input: {
617
+ mode?: 'new' | 'edit' | 'from_session';
618
+ sourceSessionId?: string;
619
+ targetAgentId?: string;
620
+ targetAgentSlug?: string;
621
+ }): 'new' | 'edit' | 'from_session' {
622
+ if (input.mode) return input.mode;
623
+ if (input.sourceSessionId) return 'from_session';
624
+ if (input.targetAgentId || input.targetAgentSlug) return 'edit';
625
+ return 'new';
626
+ }
627
+
628
+ export const CoderCreateAgentBuilderSessionRequestSchema = z
629
+ .object({
630
+ label: z.string().optional().describe('Builder session label override'),
631
+ prompt: z.string().optional().describe('Optional user focus for the builder session kickoff'),
632
+ mode: z
633
+ .enum(['new', 'edit', 'from_session'])
634
+ .optional()
635
+ .describe('Builder launch mode override'),
636
+ visibility: CoderSessionVisibilitySchema.optional().describe('Builder session visibility'),
637
+ sourceSessionId: z
638
+ .string()
639
+ .optional()
640
+ .describe('Source session identifier for build-from-session launches'),
641
+ targetAgentId: z
642
+ .string()
643
+ .optional()
644
+ .describe('Target custom-agent identifier for edit launches'),
645
+ targetAgentSlug: z.string().optional().describe('Target custom-agent slug for edit launches'),
646
+ })
647
+ .superRefine((value, ctx) => {
648
+ const mode = inferCoderAgentBuilderSessionMode(value);
649
+ if (mode === 'from_session' && !value.sourceSessionId?.trim()) {
650
+ ctx.addIssue({
651
+ code: z.ZodIssueCode.custom,
652
+ path: ['sourceSessionId'],
653
+ message: 'sourceSessionId is required for from-session builder launches.',
654
+ });
655
+ }
656
+ if (mode === 'edit' && !value.targetAgentId?.trim() && !value.targetAgentSlug?.trim()) {
657
+ ctx.addIssue({
658
+ code: z.ZodIssueCode.custom,
659
+ path: ['targetAgentId'],
660
+ message: 'targetAgentId or targetAgentSlug is required for edit launches.',
661
+ });
662
+ }
663
+ })
664
+ .describe('Request body for creating an agent-builder session');
665
+ export type CoderCreateAgentBuilderSessionRequest = z.infer<
666
+ typeof CoderCreateAgentBuilderSessionRequestSchema
667
+ >;
668
+
489
669
  export const CoderUpdateSessionRequestSchema = z
490
670
  .object({
491
671
  label: z.string().optional().describe('Updated session label'),
@@ -495,10 +675,10 @@ export const CoderUpdateSessionRequestSchema = z
495
675
  workflowMode: CoderWorkflowModeSchema.optional().describe('Updated workflow mode'),
496
676
  loop: CoderSessionLoopConfigSchema.optional().describe('Updated loop mode configuration'),
497
677
  tags: z.array(z.string()).optional().describe('Updated set of tags for the session'),
498
- agentSlugs: z
678
+ enabledAgents: z
499
679
  .array(z.string())
500
680
  .optional()
501
- .describe('Updated published custom agent slugs included in the session'),
681
+ .describe('Updated enabled agent roster for the session'),
502
682
  skills: z
503
683
  .array(CoderSkillRefSchema)
504
684
  .optional()
@@ -540,6 +720,126 @@ export const CoderSessionWorkspaceSchema = z
540
720
  .describe('Workspace associated with a coder session');
541
721
  export type CoderSessionWorkspace = z.infer<typeof CoderSessionWorkspaceSchema>;
542
722
 
723
+ export const CoderAgentBuilderSessionModeSchema = z
724
+ .enum(['new', 'edit', 'from_session'])
725
+ .describe('Agent-builder launch mode for a builder session');
726
+ export type CoderAgentBuilderSessionMode = z.infer<typeof CoderAgentBuilderSessionModeSchema>;
727
+
728
+ export const CoderAgentBuilderActionKindSchema = z
729
+ .enum(['create_draft', 'update_draft', 'publish'])
730
+ .describe('Durable builder action emitted by an agent-builder session');
731
+ export type CoderAgentBuilderActionKind = z.infer<typeof CoderAgentBuilderActionKindSchema>;
732
+
733
+ export const CoderAgentBuilderSourceSessionSchema = z
734
+ .object({
735
+ sessionId: z.string().describe('Source session identifier linked to the builder session'),
736
+ label: z.string().optional().describe('Source session label when available'),
737
+ })
738
+ .describe('Source session reference used by agent-builder flows');
739
+ export type CoderAgentBuilderSourceSession = z.infer<typeof CoderAgentBuilderSourceSessionSchema>;
740
+
741
+ export const CoderAgentBuilderTargetAgentSchema = z
742
+ .object({
743
+ agentId: z.string().optional().describe('Target custom-agent identifier when editing'),
744
+ slug: z.string().describe('Target custom-agent slug'),
745
+ displayName: z.string().optional().describe('Target custom-agent display name'),
746
+ })
747
+ .describe('Target custom-agent reference for agent-builder edit flows');
748
+ export type CoderAgentBuilderTargetAgent = z.infer<typeof CoderAgentBuilderTargetAgentSchema>;
749
+
750
+ export const CoderAgentBuilderProposalSchema = z
751
+ .object({
752
+ slug: z.string().optional().describe('Proposed custom-agent slug'),
753
+ displayName: z.string().optional().describe('Proposed custom-agent name'),
754
+ description: z.string().optional().describe('Proposed custom-agent description'),
755
+ instructions: z.string().optional().describe('Proposed custom-agent system prompt'),
756
+ model: z.string().optional().describe('Proposed model override'),
757
+ thinkingLevel: CoderCustomAgentThinkingLevelSchema.optional().describe(
758
+ 'Proposed thinking level override'
759
+ ),
760
+ headlessCompatible: z
761
+ .boolean()
762
+ .optional()
763
+ .describe('Whether the proposed agent is safe for non-interactive callers'),
764
+ tools: z
765
+ .array(CoderCustomAgentToolResponseSchema)
766
+ .default([])
767
+ .describe('Proposed workspace tools for the agent'),
768
+ serviceTools: z
769
+ .array(CoderCustomAgentServiceToolResponseSchema)
770
+ .default([])
771
+ .describe('Proposed service tools for the agent'),
772
+ savedSkills: z
773
+ .array(CoderSkillRefSchema)
774
+ .default([])
775
+ .describe('Proposed frozen skill refs to attach'),
776
+ companionAgents: z
777
+ .array(z.string())
778
+ .default([])
779
+ .describe('Proposed companion agents to auto-include'),
780
+ })
781
+ .passthrough()
782
+ .describe('Session-scoped agent-builder proposal state');
783
+ export type CoderAgentBuilderProposal = z.infer<typeof CoderAgentBuilderProposalSchema>;
784
+
785
+ export const CoderAgentBuilderDurableStateSchema = z
786
+ .object({
787
+ draftAgentId: z.string().optional().describe('Linked draft custom-agent identifier'),
788
+ draftAgentSlug: z.string().optional().describe('Linked draft custom-agent slug'),
789
+ lastPublishedVersion: z
790
+ .number()
791
+ .int()
792
+ .optional()
793
+ .describe('Latest published version created through the builder flow'),
794
+ })
795
+ .describe('Durable agent-library state associated with a builder session');
796
+ export type CoderAgentBuilderDurableState = z.infer<typeof CoderAgentBuilderDurableStateSchema>;
797
+
798
+ export const CoderAgentBuilderActionStateSchema = z
799
+ .object({
800
+ kind: CoderAgentBuilderActionKindSchema.describe('Last durable builder action'),
801
+ status: z.enum(['completed', 'failed']).describe('Result of the last durable builder action'),
802
+ occurredAt: z.string().describe('Timestamp of the last durable builder action'),
803
+ message: z.string().optional().describe('Human-readable builder action result summary'),
804
+ agentId: z.string().optional().describe('Affected custom-agent identifier'),
805
+ agentSlug: z.string().optional().describe('Affected custom-agent slug'),
806
+ publishedVersion: z
807
+ .number()
808
+ .int()
809
+ .optional()
810
+ .describe('Published version number when publish succeeded'),
811
+ })
812
+ .describe('Latest durable action emitted by a builder session');
813
+ export type CoderAgentBuilderActionState = z.infer<typeof CoderAgentBuilderActionStateSchema>;
814
+
815
+ export const CoderAgentBuilderSessionSummarySchema = z
816
+ .object({
817
+ mode: CoderAgentBuilderSessionModeSchema.describe('Builder session mode'),
818
+ sourceSession: CoderAgentBuilderSourceSessionSchema.optional().describe(
819
+ 'Linked source session when the builder was launched from an existing session'
820
+ ),
821
+ targetAgent: CoderAgentBuilderTargetAgentSchema.optional().describe(
822
+ 'Target agent baseline when the builder is editing an existing custom agent'
823
+ ),
824
+ durable: CoderAgentBuilderDurableStateSchema.optional().describe(
825
+ 'Linked durable draft/publish state'
826
+ ),
827
+ lastAction: CoderAgentBuilderActionStateSchema.optional().describe(
828
+ 'Most recent durable builder action'
829
+ ),
830
+ })
831
+ .describe('Projected builder-session summary returned in session listings');
832
+ export type CoderAgentBuilderSessionSummary = z.infer<typeof CoderAgentBuilderSessionSummarySchema>;
833
+
834
+ export const CoderAgentBuilderSessionStateSchema = CoderAgentBuilderSessionSummarySchema.extend({
835
+ proposal: CoderAgentBuilderProposalSchema.optional().describe(
836
+ 'Full builder proposal state projected in session detail responses'
837
+ ),
838
+ })
839
+ .passthrough()
840
+ .describe('Full builder-session state returned in session details');
841
+ export type CoderAgentBuilderSessionState = z.infer<typeof CoderAgentBuilderSessionStateSchema>;
842
+
543
843
  export const CoderSessionListItemSchema = z
544
844
  .object({
545
845
  sessionId: z.string().describe('Unique session identifier'),
@@ -580,11 +880,14 @@ export const CoderSessionListItemSchema = z
580
880
  participantCount: z.number().describe('Total number of participants in the session'),
581
881
  tags: z.array(z.string()).describe('Tag values attached to the session'),
582
882
  skills: z.array(CoderSkillRefSchema).describe('Skills attached to the session'),
583
- agentSlugs: z
883
+ enabledAgents: z
584
884
  .array(z.string())
585
885
  .optional()
586
886
  .default([])
587
- .describe('Published custom agent slugs attached to the session'),
887
+ .describe('Enabled agent roster attached to the session'),
888
+ builder: CoderAgentBuilderSessionSummarySchema.optional().describe(
889
+ 'Projected builder-session summary when this session is an agent-builder flow'
890
+ ),
588
891
  defaultAgent: z.string().optional().describe('Default agent assigned to session operations'),
589
892
  bucket: CoderSessionBucketSchema.describe('Derived bucket for session listing'),
590
893
  runtimeAvailable: z.boolean().describe('Whether runtime is currently reachable'),
@@ -616,6 +919,9 @@ export const CoderSessionSchema = CoderSessionListItemSchema.extend({
616
919
  .string()
617
920
  .optional()
618
921
  .describe('Last update timestamp for session metadata (ISO-8601)'),
922
+ builder: CoderAgentBuilderSessionStateSchema.optional().describe(
923
+ 'Full builder-session state when this session is an agent-builder flow'
924
+ ),
619
925
  // These fields are present in list items but may be absent in detail responses
620
926
  lastActivityAt: z.string().optional().describe('Timestamp of most recent activity (ISO-8601)'),
621
927
  taskCount: z.number().optional().describe('Number of tasks associated with the session'),