@agentuity/core 2.0.7 → 2.0.8

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 (106) hide show
  1. package/dist/services/coder/api-reference.d.ts +4 -0
  2. package/dist/services/coder/api-reference.d.ts.map +1 -0
  3. package/dist/services/coder/api-reference.js +199 -0
  4. package/dist/services/coder/api-reference.js.map +1 -0
  5. package/dist/services/coder/client.d.ts +128 -0
  6. package/dist/services/coder/client.d.ts.map +1 -0
  7. package/dist/services/coder/client.js +265 -0
  8. package/dist/services/coder/client.js.map +1 -0
  9. package/dist/services/coder/discover.d.ts +13 -0
  10. package/dist/services/coder/discover.d.ts.map +1 -0
  11. package/dist/services/coder/discover.js +18 -0
  12. package/dist/services/coder/discover.js.map +1 -0
  13. package/dist/services/coder/github.d.ts +13 -0
  14. package/dist/services/coder/github.d.ts.map +1 -0
  15. package/dist/services/coder/github.js +15 -0
  16. package/dist/services/coder/github.js.map +1 -0
  17. package/dist/services/coder/index.d.ts +19 -0
  18. package/dist/services/coder/index.d.ts.map +1 -0
  19. package/dist/services/coder/index.js +13 -0
  20. package/dist/services/coder/index.js.map +1 -0
  21. package/dist/services/coder/loop-state.d.ts +10 -0
  22. package/dist/services/coder/loop-state.d.ts.map +1 -0
  23. package/dist/services/coder/loop-state.js +13 -0
  24. package/dist/services/coder/loop-state.js.map +1 -0
  25. package/dist/services/coder/session-data.d.ts +28 -0
  26. package/dist/services/coder/session-data.d.ts.map +1 -0
  27. package/dist/services/coder/session-data.js +28 -0
  28. package/dist/services/coder/session-data.js.map +1 -0
  29. package/dist/services/coder/sessions.d.ts +155 -0
  30. package/dist/services/coder/sessions.d.ts.map +1 -0
  31. package/dist/services/coder/sessions.js +125 -0
  32. package/dist/services/coder/sessions.js.map +1 -0
  33. package/dist/services/coder/skills.d.ts +17 -0
  34. package/dist/services/coder/skills.d.ts.map +1 -0
  35. package/dist/services/coder/skills.js +43 -0
  36. package/dist/services/coder/skills.js.map +1 -0
  37. package/dist/services/coder/types.d.ts +1066 -0
  38. package/dist/services/coder/types.d.ts.map +1 -0
  39. package/dist/services/coder/types.js +573 -0
  40. package/dist/services/coder/types.js.map +1 -0
  41. package/dist/services/coder/users.d.ts +12 -0
  42. package/dist/services/coder/users.d.ts.map +1 -0
  43. package/dist/services/coder/users.js +35 -0
  44. package/dist/services/coder/users.js.map +1 -0
  45. package/dist/services/coder/util.d.ts +82 -0
  46. package/dist/services/coder/util.d.ts.map +1 -0
  47. package/dist/services/coder/util.js +60 -0
  48. package/dist/services/coder/util.js.map +1 -0
  49. package/dist/services/coder/workspaces.d.ts +13 -0
  50. package/dist/services/coder/workspaces.d.ts.map +1 -0
  51. package/dist/services/coder/workspaces.js +37 -0
  52. package/dist/services/coder/workspaces.js.map +1 -0
  53. package/dist/services/index.d.ts +1 -0
  54. package/dist/services/index.d.ts.map +1 -1
  55. package/dist/services/index.js +1 -0
  56. package/dist/services/index.js.map +1 -1
  57. package/dist/services/oauth/types.d.ts +1 -0
  58. package/dist/services/oauth/types.d.ts.map +1 -1
  59. package/dist/services/oauth/types.js +1 -0
  60. package/dist/services/oauth/types.js.map +1 -1
  61. package/dist/services/project/deploy.d.ts +1 -1
  62. package/dist/services/queue/service.d.ts +28 -0
  63. package/dist/services/queue/service.d.ts.map +1 -1
  64. package/dist/services/queue/service.js +54 -9
  65. package/dist/services/queue/service.js.map +1 -1
  66. package/dist/services/sandbox/cli-list.d.ts +1 -1
  67. package/dist/services/sandbox/client.d.ts +10 -4
  68. package/dist/services/sandbox/client.d.ts.map +1 -1
  69. package/dist/services/sandbox/client.js +2 -2
  70. package/dist/services/sandbox/client.js.map +1 -1
  71. package/dist/services/sandbox/create.d.ts +2 -2
  72. package/dist/services/sandbox/execute.d.ts +2 -2
  73. package/dist/services/sandbox/execution.d.ts +4 -4
  74. package/dist/services/sandbox/files.d.ts +10 -2
  75. package/dist/services/sandbox/files.d.ts.map +1 -1
  76. package/dist/services/sandbox/files.js +14 -0
  77. package/dist/services/sandbox/files.js.map +1 -1
  78. package/dist/services/sandbox/get.d.ts +2 -2
  79. package/dist/services/sandbox/list.d.ts +4 -4
  80. package/dist/services/sandbox/run.d.ts +1 -1
  81. package/dist/services/sandbox/types.d.ts +18 -10
  82. package/dist/services/sandbox/types.d.ts.map +1 -1
  83. package/dist/services/sandbox/types.js +4 -4
  84. package/dist/services/sandbox/types.js.map +1 -1
  85. package/dist/services/session/events.d.ts +2 -2
  86. package/dist/services/workflow/types.d.ts +8 -8
  87. package/package.json +2 -2
  88. package/src/services/coder/api-reference.ts +207 -0
  89. package/src/services/coder/client.ts +378 -0
  90. package/src/services/coder/discover.ts +23 -0
  91. package/src/services/coder/github.ts +33 -0
  92. package/src/services/coder/index.ts +72 -0
  93. package/src/services/coder/loop-state.ts +19 -0
  94. package/src/services/coder/session-data.ts +63 -0
  95. package/src/services/coder/sessions.ts +237 -0
  96. package/src/services/coder/skills.ts +102 -0
  97. package/src/services/coder/types.ts +670 -0
  98. package/src/services/coder/users.ts +59 -0
  99. package/src/services/coder/util.ts +87 -0
  100. package/src/services/coder/workspaces.ts +77 -0
  101. package/src/services/index.ts +1 -0
  102. package/src/services/oauth/types.ts +1 -0
  103. package/src/services/queue/service.ts +56 -13
  104. package/src/services/sandbox/client.ts +10 -8
  105. package/src/services/sandbox/files.ts +28 -2
  106. package/src/services/sandbox/types.ts +8 -6
@@ -0,0 +1,670 @@
1
+ import { z } from 'zod/v4';
2
+
3
+ export const CoderSessionVisibilitySchema = z
4
+ .enum(['private', 'organization', 'collaborate'])
5
+ .describe('Visibility level for a coder session');
6
+ export type CoderSessionVisibility = z.infer<typeof CoderSessionVisibilitySchema>;
7
+
8
+ const VISIBILITY_ALIASES: Record<string, CoderSessionVisibility> = {
9
+ private: 'private',
10
+ org: 'organization',
11
+ organization: 'organization',
12
+ collab: 'collaborate',
13
+ collaborate: 'collaborate',
14
+ };
15
+
16
+ /**
17
+ * Normalize a visibility input string to the canonical server value.
18
+ * Accepts shortcuts like 'org' → 'organization', 'collab' → 'collaborate'.
19
+ */
20
+ export function normalizeVisibility(input: string): CoderSessionVisibility {
21
+ const result = VISIBILITY_ALIASES[input.toLowerCase().trim()];
22
+ if (!result) {
23
+ throw new Error(
24
+ `Invalid visibility "${input}". Valid values: private, org, organization, collaborate, collab`
25
+ );
26
+ }
27
+ return result;
28
+ }
29
+
30
+ export const CoderWorkflowModeSchema = z
31
+ .enum(['standard', 'loop'])
32
+ .describe('Workflow execution mode for a coder session');
33
+ export type CoderWorkflowMode = z.infer<typeof CoderWorkflowModeSchema>;
34
+
35
+ export const CoderSessionModeSchema = z
36
+ .enum(['sandbox', 'tui'])
37
+ .describe('Runtime mode used by the coder session');
38
+ export type CoderSessionMode = z.infer<typeof CoderSessionModeSchema>;
39
+
40
+ export const CoderSessionBucketSchema = z
41
+ .enum(['running', 'paused', 'provisioning', 'history'])
42
+ .describe('Derived bucket used for session listing and UI grouping');
43
+ export type CoderSessionBucket = z.infer<typeof CoderSessionBucketSchema>;
44
+
45
+ export const CoderSkillRefSchema = z
46
+ .object({
47
+ skillId: z.string().describe('Unique skill identifier'),
48
+ repo: z.string().describe('Repository slug for the skill source'),
49
+ name: z.string().optional().describe('Human-readable skill name'),
50
+ url: z.string().optional().describe('Canonical URL for the skill repository or page'),
51
+ })
52
+ .describe('Skill reference attached to a coder session');
53
+ export type CoderSkillRef = z.infer<typeof CoderSkillRefSchema>;
54
+
55
+ export const CoderSessionRepositoryRefSchema = z
56
+ .object({
57
+ repoId: z.string().optional().describe('Repository identifier when available'),
58
+ type: z.string().optional().describe('Repository type (e.g., github, gitlab)'),
59
+ provider: z.string().optional().describe('Git provider identifier'),
60
+ owner: z.string().optional().describe('Repository owner or organization'),
61
+ name: z.string().optional().describe('Repository name'),
62
+ fullName: z.string().optional().describe('Fully qualified repository name'),
63
+ url: z.string().optional().describe('Repository web URL'),
64
+ cloneUrl: z.string().optional().describe('Repository clone URL'),
65
+ defaultBranch: z.string().optional().describe('Default branch for the repository'),
66
+ branch: z.string().optional().describe('Selected branch for the session workspace'),
67
+ ref: z.string().optional().describe('Selected ref for the session workspace'),
68
+ commit: z.string().optional().describe('Pinned commit SHA for the session workspace'),
69
+ path: z.string().optional().describe('Subpath of the repository mounted in session'),
70
+ rootPath: z.string().optional().describe('Absolute workspace root path for the repository'),
71
+ })
72
+ .catchall(z.unknown())
73
+ .describe('Repository reference used by coder sessions');
74
+ export type CoderSessionRepositoryRef = z.infer<typeof CoderSessionRepositoryRefSchema>;
75
+
76
+ export const CoderSavedSkillSchema = z
77
+ .object({
78
+ id: z.string().describe('Saved skill record ID'),
79
+ source: z.string().describe('Skill source identifier (e.g. registry)'),
80
+ repo: z.string().describe('Repository identifier for the skill'),
81
+ skillId: z.string().describe('Skill identifier within the repository'),
82
+ name: z.string().describe('Human-readable skill name'),
83
+ description: z.string().optional().describe('Skill description'),
84
+ url: z.string().optional().describe('Skill URL'),
85
+ installs: z.number().optional().describe('Number of installs'),
86
+ createdAt: z.string().describe('Creation timestamp (ISO-8601)'),
87
+ updatedAt: z.string().describe('Last update timestamp (ISO-8601)'),
88
+ })
89
+ .passthrough()
90
+ .describe('Saved skill record returned by coder hub');
91
+ export type CoderSavedSkill = z.infer<typeof CoderSavedSkillSchema>;
92
+
93
+ export const CoderSkillBucketSchema = z
94
+ .object({
95
+ id: z.string().describe('Skill bucket record ID'),
96
+ name: z.string().describe('Skill bucket name'),
97
+ description: z.string().optional().describe('Skill bucket description'),
98
+ createdAt: z.string().describe('Creation timestamp (ISO-8601)'),
99
+ updatedAt: z.string().describe('Last update timestamp (ISO-8601)'),
100
+ skillCount: z.number().describe('Number of skills in the bucket'),
101
+ skills: z.array(CoderSavedSkillSchema).describe('Skills in this bucket'),
102
+ })
103
+ .passthrough()
104
+ .describe('Skill bucket returned by coder hub');
105
+ export type CoderSkillBucket = z.infer<typeof CoderSkillBucketSchema>;
106
+
107
+ export const CoderWorkspaceDetailSchema = z
108
+ .object({
109
+ id: z.string().describe('Workspace record ID'),
110
+ name: z.string().describe('Workspace name'),
111
+ description: z.string().optional().describe('Workspace description'),
112
+ scope: z.string().describe('Workspace scope: user or org'),
113
+ ownerUserId: z.string().describe('Owner user ID'),
114
+ repos: z.array(CoderSessionRepositoryRefSchema).describe('Repositories in workspace'),
115
+ repoCount: z.number().describe('Number of repositories'),
116
+ savedSkillIds: z.array(z.string()).describe('Saved skill IDs in workspace'),
117
+ skillBucketIds: z.array(z.string()).describe('Skill bucket IDs in workspace'),
118
+ selectionCount: z.number().describe('Total number of selections'),
119
+ createdAt: z.string().describe('Creation timestamp (ISO-8601)'),
120
+ updatedAt: z.string().describe('Last update timestamp (ISO-8601)'),
121
+ })
122
+ .passthrough()
123
+ .describe('Workspace detail returned by coder hub');
124
+ export type CoderWorkspaceDetail = z.infer<typeof CoderWorkspaceDetailSchema>;
125
+
126
+ export const CoderSavedSkillListResponseSchema = z
127
+ .object({
128
+ skills: z.array(CoderSavedSkillSchema).describe('Saved skills returned by coder hub'),
129
+ })
130
+ .passthrough()
131
+ .describe('Response payload for listing saved skills');
132
+ export type CoderSavedSkillListResponse = z.infer<typeof CoderSavedSkillListResponseSchema>;
133
+
134
+ export const CoderSkillBucketListResponseSchema = z
135
+ .object({
136
+ buckets: z.array(CoderSkillBucketSchema).describe('Skill buckets returned by coder hub'),
137
+ })
138
+ .passthrough()
139
+ .describe('Response payload for listing skill buckets');
140
+ export type CoderSkillBucketListResponse = z.infer<typeof CoderSkillBucketListResponseSchema>;
141
+
142
+ export const CoderWorkspaceListResponseSchema = z
143
+ .object({
144
+ workspaces: z.array(CoderWorkspaceDetailSchema).describe('Workspaces returned by coder hub'),
145
+ })
146
+ .passthrough()
147
+ .describe('Response payload for listing workspaces');
148
+ export type CoderWorkspaceListResponse = z.infer<typeof CoderWorkspaceListResponseSchema>;
149
+
150
+ export const CoderCreateWorkspaceRequestSchema = z
151
+ .object({
152
+ name: z.string().describe('Workspace name'),
153
+ description: z.string().optional().describe('Workspace description'),
154
+ scope: z.enum(['user', 'org']).optional().describe('Workspace scope'),
155
+ repos: z.array(CoderSessionRepositoryRefSchema).optional().describe('Repositories'),
156
+ savedSkillIds: z.array(z.string()).optional().describe('Saved skill IDs'),
157
+ skillBucketIds: z.array(z.string()).optional().describe('Skill bucket IDs'),
158
+ })
159
+ .describe('Request body for creating a workspace');
160
+ export type CoderCreateWorkspaceRequest = z.infer<typeof CoderCreateWorkspaceRequestSchema>;
161
+
162
+ export const CoderSaveSkillRequestSchema = z
163
+ .object({
164
+ repo: z.string().describe('Repository identifier'),
165
+ skillId: z.string().describe('Skill identifier'),
166
+ name: z.string().describe('Skill name'),
167
+ description: z.string().optional().describe('Skill description'),
168
+ url: z.string().optional().describe('Skill URL'),
169
+ source: z.string().optional().describe('Skill source (default: registry)'),
170
+ content: z.string().optional().describe('Skill content'),
171
+ })
172
+ .describe('Request body for saving a skill to the library');
173
+ export type CoderSaveSkillRequest = z.infer<typeof CoderSaveSkillRequestSchema>;
174
+
175
+ export const CoderCreateSkillBucketRequestSchema = z
176
+ .object({
177
+ name: z.string().describe('Skill bucket name'),
178
+ description: z.string().optional().describe('Skill bucket description'),
179
+ savedSkillIds: z
180
+ .array(z.string())
181
+ .optional()
182
+ .describe('Saved skill IDs to include in the bucket'),
183
+ })
184
+ .describe('Request body for creating a skill bucket');
185
+ export type CoderCreateSkillBucketRequest = z.infer<typeof CoderCreateSkillBucketRequestSchema>;
186
+
187
+ export const CoderSessionLoopConfigSchema = z
188
+ .object({
189
+ goal: z.string().optional().describe('High-level goal for loop mode execution'),
190
+ maxIterations: z
191
+ .number()
192
+ .int()
193
+ .optional()
194
+ .describe('Maximum loop iterations before completion'),
195
+ autoContinue: z
196
+ .boolean()
197
+ .optional()
198
+ .describe('Whether the loop auto-continues without manual approval'),
199
+ allowDetached: z
200
+ .boolean()
201
+ .optional()
202
+ .describe('Whether loop execution can continue when no client is actively attached'),
203
+ })
204
+ .describe('Loop mode configuration used when creating or updating a session');
205
+ export type CoderSessionLoopConfig = z.infer<typeof CoderSessionLoopConfigSchema>;
206
+
207
+ export const CoderCreateSessionRequestSchema = z
208
+ .object({
209
+ task: z.string().describe('Primary task prompt for the session'),
210
+ label: z.string().optional().describe('Human-readable session label'),
211
+ agent: z.string().optional().describe('Default agent identifier to use for execution'),
212
+ visibility: CoderSessionVisibilitySchema.optional().describe('Session visibility setting'),
213
+ workflowMode: CoderWorkflowModeSchema.optional().describe('Workflow execution mode'),
214
+ loop: CoderSessionLoopConfigSchema.optional().describe('Loop mode settings for the session'),
215
+ tags: z.array(z.string()).optional().describe('Tags applied to the session for filtering'),
216
+ savedSkillIds: z
217
+ .array(z.string())
218
+ .optional()
219
+ .describe('Saved skill IDs to attach to the session on creation'),
220
+ skillBucketIds: z
221
+ .array(z.string())
222
+ .optional()
223
+ .describe('Skill bucket IDs to attach to the session on creation'),
224
+ skills: z
225
+ .array(CoderSkillRefSchema)
226
+ .optional()
227
+ .describe('Skill definitions attached to the session'),
228
+ repo: CoderSessionRepositoryRefSchema.optional().describe(
229
+ 'Primary repository mounted for the session'
230
+ ),
231
+ repos: z
232
+ .array(CoderSessionRepositoryRefSchema)
233
+ .optional()
234
+ .describe('Multiple repositories mounted for the session'),
235
+ workspaceId: z
236
+ .string()
237
+ .optional()
238
+ .describe('Workspace identifier associated with the session'),
239
+ env: z
240
+ .record(z.string(), z.string())
241
+ .optional()
242
+ .describe('Environment variables injected into session runtime'),
243
+ metadata: z
244
+ .record(z.string(), z.string())
245
+ .optional()
246
+ .describe('Arbitrary metadata associated with the session'),
247
+ })
248
+ .describe('Request body for creating a coder session');
249
+ export type CoderCreateSessionRequest = z.infer<typeof CoderCreateSessionRequestSchema>;
250
+
251
+ export const CoderUpdateSessionRequestSchema = z
252
+ .object({
253
+ label: z.string().optional().describe('Updated session label'),
254
+ agent: z.string().optional().describe('Updated default agent identifier'),
255
+ visibility: CoderSessionVisibilitySchema.optional().describe('Updated visibility setting'),
256
+ workflowMode: CoderWorkflowModeSchema.optional().describe('Updated workflow mode'),
257
+ loop: CoderSessionLoopConfigSchema.optional().describe('Updated loop mode configuration'),
258
+ tags: z.array(z.string()).optional().describe('Updated set of tags for the session'),
259
+ skills: z
260
+ .array(CoderSkillRefSchema)
261
+ .optional()
262
+ .describe('Updated attached skills for the session'),
263
+ metadata: z
264
+ .record(z.string(), z.string())
265
+ .optional()
266
+ .describe('Updated arbitrary metadata associated with the session'),
267
+ })
268
+ .describe('Request body for updating a coder session');
269
+ export type CoderUpdateSessionRequest = z.infer<typeof CoderUpdateSessionRequestSchema>;
270
+
271
+ export const CoderSessionOwnerSchema = z
272
+ .object({
273
+ userId: z.string().describe('Owner user identifier'),
274
+ name: z.string().optional().describe('Owner display name'),
275
+ })
276
+ .describe('Owner identity for a session');
277
+ export type CoderSessionOwner = z.infer<typeof CoderSessionOwnerSchema>;
278
+
279
+ export const CoderSessionOriginSchema = z
280
+ .union([
281
+ z.string().describe('Origin type as a simple string identifier'),
282
+ z
283
+ .object({
284
+ type: z.string().describe('Origin type identifier for session creation source'),
285
+ })
286
+ .catchall(z.unknown()),
287
+ ])
288
+ .describe('Source metadata describing where a session originated');
289
+ export type CoderSessionOrigin = z.infer<typeof CoderSessionOriginSchema>;
290
+
291
+ export const CoderSessionWorkspaceSchema = z
292
+ .object({
293
+ id: z.string().describe('Workspace identifier'),
294
+ name: z.string().describe('Workspace display name'),
295
+ scope: z.enum(['user', 'org']).describe('Workspace ownership scope'),
296
+ })
297
+ .describe('Workspace associated with a coder session');
298
+ export type CoderSessionWorkspace = z.infer<typeof CoderSessionWorkspaceSchema>;
299
+
300
+ export const CoderSessionListItemSchema = z
301
+ .object({
302
+ sessionId: z.string().describe('Unique session identifier'),
303
+ label: z.string().describe('Human-readable session label'),
304
+ status: z.string().describe('Current session status'),
305
+ mode: CoderSessionModeSchema.describe('Runtime mode used by this session'),
306
+ visibility: z.string().describe('Visibility value assigned to the session'),
307
+ owner: CoderSessionOwnerSchema.optional().describe('Session owner identity'),
308
+ origin: CoderSessionOriginSchema.optional().describe('Session origin metadata'),
309
+ repo: CoderSessionRepositoryRefSchema.optional().describe('Primary repository reference'),
310
+ repos: z
311
+ .array(CoderSessionRepositoryRefSchema)
312
+ .optional()
313
+ .describe('Repository references mounted in session'),
314
+ workspace: CoderSessionWorkspaceSchema.optional().describe(
315
+ 'Associated workspace information'
316
+ ),
317
+ sessionKind: z.string().optional().describe('Session kind category emitted by backend'),
318
+ parentSessionId: z
319
+ .string()
320
+ .optional()
321
+ .describe('Parent session identifier when session is derived'),
322
+ coordinationJobId: z
323
+ .string()
324
+ .optional()
325
+ .describe('Coordination job identifier for orchestration'),
326
+ workflowMode: CoderWorkflowModeSchema.describe('Workflow mode currently active for session'),
327
+ loopStatus: z.string().optional().describe('Current loop status if workflow mode is loop'),
328
+ loopIteration: z
329
+ .number()
330
+ .optional()
331
+ .describe('Current loop iteration counter when applicable'),
332
+ createdAt: z.string().describe('Session creation timestamp (ISO-8601)'),
333
+ lastActivityAt: z.string().describe('Timestamp of most recent activity (ISO-8601)'),
334
+ taskCount: z.number().describe('Number of tasks associated with the session'),
335
+ subAgentCount: z.number().describe('Number of sub-agents associated with the session'),
336
+ observerCount: z.number().describe('Number of observer participants in the session'),
337
+ participantCount: z.number().describe('Total number of participants in the session'),
338
+ tags: z.array(z.string()).describe('Tag values attached to the session'),
339
+ skills: z.array(CoderSkillRefSchema).describe('Skills attached to the session'),
340
+ defaultAgent: z.string().optional().describe('Default agent assigned to session operations'),
341
+ bucket: CoderSessionBucketSchema.describe('Derived bucket for session listing'),
342
+ runtimeAvailable: z.boolean().describe('Whether runtime is currently reachable'),
343
+ controlAvailable: z.boolean().describe('Whether control operations are currently available'),
344
+ manageAvailable: z
345
+ .boolean()
346
+ .optional()
347
+ .describe('Whether management operations are currently available'),
348
+ wakeAvailable: z.boolean().describe('Whether wake operation is currently available'),
349
+ historyOnly: z
350
+ .boolean()
351
+ .describe('Whether session is history-only and no longer interactive'),
352
+ liveExpected: z.boolean().describe('Whether live connectivity is expected for the session'),
353
+ })
354
+ .describe('Session list item returned by coder hub list endpoints');
355
+ export type CoderSessionListItem = z.infer<typeof CoderSessionListItemSchema>;
356
+
357
+ export const CoderSessionSchema = CoderSessionListItemSchema.extend({
358
+ task: z.string().optional().describe('Primary task prompt associated with the session'),
359
+ env: z
360
+ .record(z.string(), z.string())
361
+ .optional()
362
+ .describe('Environment variables associated with the session'),
363
+ metadata: z
364
+ .record(z.string(), z.unknown())
365
+ .optional()
366
+ .describe('Additional metadata associated with the session'),
367
+ updatedAt: z
368
+ .string()
369
+ .optional()
370
+ .describe('Last update timestamp for session metadata (ISO-8601)'),
371
+ // These fields are present in list items but may be absent in detail responses
372
+ lastActivityAt: z.string().optional().describe('Timestamp of most recent activity (ISO-8601)'),
373
+ taskCount: z.number().optional().describe('Number of tasks associated with the session'),
374
+ subAgentCount: z
375
+ .number()
376
+ .optional()
377
+ .describe('Number of sub-agents associated with the session'),
378
+ observerCount: z.number().optional().describe('Number of observer participants in the session'),
379
+ participantCount: z.number().optional().describe('Total number of participants in the session'),
380
+ })
381
+ .passthrough()
382
+ .describe('Detailed coder session payload returned by session endpoints');
383
+ export type CoderSession = z.infer<typeof CoderSessionSchema>;
384
+
385
+ export const CoderListSessionsParamsSchema = z
386
+ .object({
387
+ search: z.string().optional().describe('Search query for session title, task, or metadata'),
388
+ includeArchived: z
389
+ .boolean()
390
+ .optional()
391
+ .describe('Whether archived sessions should be included'),
392
+ limit: z.number().int().optional().describe('Maximum number of sessions to return'),
393
+ offset: z.number().int().optional().describe('Number of sessions to skip for pagination'),
394
+ orgId: z.string().optional().describe('Optional org id for CLI auth context'),
395
+ })
396
+ .describe('Query parameters for listing sessions');
397
+ export type CoderListSessionsParams = z.infer<typeof CoderListSessionsParamsSchema>;
398
+
399
+ export const CoderSessionListResponseSchema = z
400
+ .object({
401
+ sessions: z.array(CoderSessionListItemSchema).describe('List of coder sessions'),
402
+ total: z.number().optional().describe('Total sessions matching the query'),
403
+ limit: z.number().optional().describe('Pagination limit used by the response'),
404
+ offset: z.number().optional().describe('Pagination offset used by the response'),
405
+ })
406
+ .describe('Normalized paginated session list response');
407
+ export type CoderSessionListResponse = z.infer<typeof CoderSessionListResponseSchema>;
408
+
409
+ export const CoderSessionListPayloadSchema = z
410
+ .union([
411
+ z.array(CoderSessionListItemSchema).describe('Array-only list payload from service'),
412
+ CoderSessionListResponseSchema.describe('Object list payload from service'),
413
+ ])
414
+ .describe('Raw session list payload shape returned by service');
415
+
416
+ export const CoderParticipantSchema = z
417
+ .object({
418
+ id: z.string().describe('Participant identifier'),
419
+ role: z.string().describe('Participant role in the session'),
420
+ transport: z.string().optional().describe('Transport protocol used by the participant'),
421
+ agentRole: z.string().optional().describe('Agent role when participant is an agent'),
422
+ connectedAt: z
423
+ .string()
424
+ .optional()
425
+ .describe('Timestamp when participant connected (ISO-8601)'),
426
+ disconnectedAt: z
427
+ .string()
428
+ .optional()
429
+ .describe('Timestamp when participant disconnected (ISO-8601)'),
430
+ lastActivityAt: z
431
+ .string()
432
+ .optional()
433
+ .describe('Timestamp of last participant activity (ISO-8601)'),
434
+ metadata: z
435
+ .record(z.string(), z.unknown())
436
+ .optional()
437
+ .describe('Additional participant metadata'),
438
+ })
439
+ .passthrough()
440
+ .describe('Participant entry associated with a session');
441
+ export type CoderParticipant = z.infer<typeof CoderParticipantSchema>;
442
+
443
+ export const CoderSessionParticipantsSchema = z
444
+ .object({
445
+ sessionId: z.string().describe('Session identifier for the participant list'),
446
+ participants: z
447
+ .array(CoderParticipantSchema)
448
+ .describe('Participant entries associated with session'),
449
+ })
450
+ .describe('Participants payload for a coder session');
451
+ export type CoderSessionParticipants = z.infer<typeof CoderSessionParticipantsSchema>;
452
+
453
+ export const CoderSessionReplaySchema = z
454
+ .object({
455
+ sessionId: z.string().describe('Session identifier for replay payload'),
456
+ replay: z.unknown().optional().describe('Replay payload emitted by coder hub'),
457
+ events: z
458
+ .array(z.unknown())
459
+ .optional()
460
+ .describe('Replay events if included in response payload'),
461
+ })
462
+ .passthrough()
463
+ .describe('Replay payload for a coder session');
464
+ export type CoderSessionReplay = z.infer<typeof CoderSessionReplaySchema>;
465
+
466
+ export const CoderSessionEventSchema = z
467
+ .object({
468
+ id: z.number().describe('Event sequence identifier'),
469
+ event: z.string().describe('Event name'),
470
+ category: z.string().optional().describe('Event category'),
471
+ agent: z.string().optional().describe('Agent identifier responsible for the event'),
472
+ taskId: z.string().optional().describe('Task identifier associated with the event'),
473
+ payload: z.unknown().optional().describe('Event payload data'),
474
+ occurredAt: z.string().describe('Timestamp when event occurred (ISO-8601)'),
475
+ ingestedAt: z.string().optional().describe('Timestamp when event was ingested (ISO-8601)'),
476
+ })
477
+ .passthrough()
478
+ .describe('Session history event entry');
479
+ export type CoderSessionEvent = z.infer<typeof CoderSessionEventSchema>;
480
+
481
+ export const CoderSessionEventHistorySchema = z
482
+ .object({
483
+ sessionId: z.string().describe('Session identifier for event history payload'),
484
+ events: z.array(CoderSessionEventSchema).describe('Event history items for the session'),
485
+ total: z.number().optional().describe('Total number of events when pagination is applied'),
486
+ limit: z.number().optional().describe('Pagination limit used by backend response'),
487
+ offset: z.number().optional().describe('Pagination offset used by backend response'),
488
+ })
489
+ .passthrough()
490
+ .describe('Event history payload for a coder session');
491
+ export type CoderSessionEventHistory = z.infer<typeof CoderSessionEventHistorySchema>;
492
+
493
+ export const CoderSessionDataQuerySchema = z
494
+ .object({
495
+ sessionId: z.string().describe('Session identifier'),
496
+ limit: z.number().int().optional().describe('Maximum number of records to return'),
497
+ offset: z.number().int().optional().describe('Number of records to skip for pagination'),
498
+ orgId: z.string().optional().describe('Optional org id for CLI auth context'),
499
+ })
500
+ .describe('Common query parameters for session data endpoints');
501
+ export type CoderSessionDataQuery = z.infer<typeof CoderSessionDataQuerySchema>;
502
+
503
+ export const CoderLoopStatusSchema = z
504
+ .enum([
505
+ 'idle',
506
+ 'starting',
507
+ 'running',
508
+ 'paused',
509
+ 'completed',
510
+ 'cancelled',
511
+ 'blocked',
512
+ 'awaiting_input',
513
+ ])
514
+ .describe('Current status of a loop-mode session');
515
+ export type CoderLoopStatus = z.infer<typeof CoderLoopStatusSchema>;
516
+
517
+ export const CoderSessionLoopStateSchema = z
518
+ .object({
519
+ status: CoderLoopStatusSchema.describe('Current loop status'),
520
+ iteration: z.number().describe('Current loop iteration number'),
521
+ maxIterations: z.number().optional().describe('Maximum configured loop iterations'),
522
+ goal: z.string().optional().describe('Loop execution goal statement'),
523
+ summary: z.string().optional().describe('Summary generated for current loop state'),
524
+ nextAction: z.string().optional().describe('Suggested next action for loop progression'),
525
+ loopId: z.string().optional().describe('Loop run identifier'),
526
+ startedAt: z.number().optional().describe('Unix timestamp in milliseconds when loop started'),
527
+ updatedAt: z
528
+ .number()
529
+ .optional()
530
+ .describe('Unix timestamp in milliseconds when loop was last updated'),
531
+ completedAt: z
532
+ .number()
533
+ .optional()
534
+ .describe('Unix timestamp in milliseconds when loop completed'),
535
+ lastCheckpointAt: z
536
+ .number()
537
+ .optional()
538
+ .describe('Unix timestamp in milliseconds for most recent loop checkpoint'),
539
+ autoContinue: z.boolean().optional().describe('Whether loop is configured to auto-continue'),
540
+ allowDetached: z
541
+ .boolean()
542
+ .optional()
543
+ .describe('Whether loop is allowed to continue while detached from active clients'),
544
+ activePrdKey: z.string().optional().describe('Active PRD key associated with loop execution'),
545
+ activePrdTaskId: z
546
+ .string()
547
+ .optional()
548
+ .describe('Active PRD task identifier associated with loop execution'),
549
+ })
550
+ .describe('Detailed state for loop-mode execution');
551
+ export type CoderSessionLoopState = z.infer<typeof CoderSessionLoopStateSchema>;
552
+
553
+ export const CoderLoopStateResponseSchema = z
554
+ .object({
555
+ sessionId: z.string().describe('Session identifier for the loop state payload'),
556
+ workflowMode: CoderWorkflowModeSchema.describe('Workflow mode for the target session'),
557
+ loop: CoderSessionLoopStateSchema.nullable().describe(
558
+ 'Loop state details, or null when not in loop mode'
559
+ ),
560
+ })
561
+ .describe('Loop state response for a coder session');
562
+ export type CoderLoopStateResponse = z.infer<typeof CoderLoopStateResponseSchema>;
563
+
564
+ // ────────────────────────────────────────────────────────────────────────────
565
+ // GitHub Account
566
+ // ────────────────────────────────────────────────────────────────────────────
567
+
568
+ export const CoderGitHubAccountSchema = z
569
+ .object({
570
+ installationId: z.string().describe('GitHub App installation ID'),
571
+ integrationId: z.string().describe('Integration record ID'),
572
+ accountId: z.string().describe('GitHub account numeric ID'),
573
+ accountName: z.string().describe('GitHub account login name'),
574
+ accountType: z.string().describe('Account type (User or Organization)'),
575
+ avatarUrl: z.string().optional().describe('GitHub account avatar URL'),
576
+ })
577
+ .passthrough()
578
+ .describe('GitHub account available via a GitHub App installation');
579
+ export type CoderGitHubAccount = z.infer<typeof CoderGitHubAccountSchema>;
580
+
581
+ export const CoderGitHubAccountListResponseSchema = z
582
+ .object({
583
+ connected: z.boolean().describe('Whether GitHub OAuth is connected'),
584
+ username: z.string().optional().describe('Connected GitHub username'),
585
+ avatarUrl: z.string().optional().describe('Connected GitHub avatar URL'),
586
+ accounts: z.array(CoderGitHubAccountSchema).describe('Available GitHub accounts'),
587
+ })
588
+ .passthrough()
589
+ .describe('Response payload for listing GitHub accounts');
590
+ export type CoderGitHubAccountListResponse = z.infer<typeof CoderGitHubAccountListResponseSchema>;
591
+
592
+ // ────────────────────────────────────────────────────────────────────────────
593
+ // GitHub Repository
594
+ // ────────────────────────────────────────────────────────────────────────────
595
+
596
+ export const CoderGitHubRepositorySchema = z
597
+ .object({
598
+ id: z.number().describe('GitHub repository numeric ID'),
599
+ name: z.string().describe('Repository name'),
600
+ fullName: z.string().describe('Full repository name (owner/repo)'),
601
+ private: z.boolean().describe('Whether repository is private'),
602
+ defaultBranch: z.string().optional().describe('Default branch name'),
603
+ cloneUrl: z.string().describe('Git clone URL'),
604
+ htmlUrl: z.string().describe('GitHub web URL'),
605
+ visibility: z.string().optional().describe('Repository visibility'),
606
+ archived: z.boolean().describe('Whether repository is archived'),
607
+ disabled: z.boolean().describe('Whether repository is disabled'),
608
+ owner: z
609
+ .object({
610
+ login: z.string().describe('Owner login name'),
611
+ avatarUrl: z.string().optional().describe('Owner avatar URL'),
612
+ })
613
+ .passthrough()
614
+ .describe('Repository owner'),
615
+ })
616
+ .passthrough()
617
+ .describe('GitHub repository returned by coder hub');
618
+ export type CoderGitHubRepository = z.infer<typeof CoderGitHubRepositorySchema>;
619
+
620
+ export const CoderGitHubRepositoryListResponseSchema = z
621
+ .object({
622
+ accountId: z.string().describe('GitHub account ID the repos belong to'),
623
+ totalCount: z.number().describe('Total number of repositories'),
624
+ repositories: z.array(CoderGitHubRepositorySchema).describe('Repository list'),
625
+ })
626
+ .passthrough()
627
+ .describe('Response payload for listing GitHub repositories');
628
+ export type CoderGitHubRepositoryListResponse = z.infer<
629
+ typeof CoderGitHubRepositoryListResponseSchema
630
+ >;
631
+
632
+ // ────────────────────────────────────────────────────────────────────────────
633
+ // Users
634
+ // ────────────────────────────────────────────────────────────────────────────
635
+
636
+ export const CoderUserSchema = z
637
+ .object({
638
+ userId: z.string().describe('User identifier'),
639
+ displayName: z.string().describe('Human-readable user display name'),
640
+ email: z.string().describe('User email address'),
641
+ provider: z.string().describe('Identity provider for this user'),
642
+ avatarUrl: z.string().optional().describe('Avatar URL for the user profile image'),
643
+ lastLoginAt: z.string().describe("Timestamp of the user's last login (ISO-8601)"),
644
+ lastSeenAt: z.string().describe("Timestamp of the user's most recent presence (ISO-8601)"),
645
+ createdAt: z
646
+ .string()
647
+ .describe('Timestamp when the user identity was first observed (ISO-8601)'),
648
+ })
649
+ .describe('Known user record from coder hub');
650
+ export type CoderUser = z.infer<typeof CoderUserSchema>;
651
+
652
+ export const CoderListUsersParamsSchema = z
653
+ .object({
654
+ search: z.string().optional().describe('Search query to filter users by display name'),
655
+ limit: z.number().int().optional().describe('Maximum number of users to return'),
656
+ offset: z.number().int().optional().describe('Number of users to skip for pagination'),
657
+ orgId: z.string().optional().describe('Optional org id for CLI auth context'),
658
+ })
659
+ .describe('Query parameters for listing known users');
660
+ export type CoderListUsersParams = z.infer<typeof CoderListUsersParamsSchema>;
661
+
662
+ export const CoderListUsersResponseSchema = z
663
+ .object({
664
+ users: z.array(CoderUserSchema).describe('List of known users'),
665
+ total: z.number().optional().describe('Total users matching the query'),
666
+ limit: z.number().optional().describe('Pagination limit used by backend response'),
667
+ offset: z.number().optional().describe('Pagination offset used by backend response'),
668
+ })
669
+ .describe('Normalized users list response');
670
+ export type CoderListUsersResponse = z.infer<typeof CoderListUsersResponseSchema>;