@agentuity/core 2.0.7 → 2.0.9

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,378 @@
1
+ import type { Logger } from '../../logger.ts';
2
+ import { z } from 'zod/v4';
3
+ import { APIClient } from '../api.ts';
4
+ import { getServiceUrls } from '../config.ts';
5
+ import { getEnv } from '../env.ts';
6
+ import { createMinimalLogger } from '../logger.ts';
7
+ import { discoverUrl } from './discover.ts';
8
+ import {
9
+ coderArchiveSession,
10
+ type CoderCreateSessionResponse,
11
+ type CoderLifecycleResponse,
12
+ coderCreateSession,
13
+ coderDeleteSession,
14
+ coderGetSession,
15
+ coderListConnectableSessions,
16
+ coderListSessions,
17
+ coderUpdateSession,
18
+ type CoderCreateSessionParams,
19
+ type CoderUpdateSessionResponse,
20
+ type CoderListConnectableSessionsParams,
21
+ type CoderListSessionsParamsWithOrg,
22
+ } from './sessions.ts';
23
+ import {
24
+ coderCreateSkillBucket,
25
+ coderDeleteSavedSkill,
26
+ coderDeleteSkillBucket,
27
+ coderListSavedSkills,
28
+ coderListSkillBuckets,
29
+ coderSaveSkill,
30
+ } from './skills.ts';
31
+ import {
32
+ coderCreateWorkspace,
33
+ coderDeleteWorkspace,
34
+ coderGetWorkspace,
35
+ coderListWorkspaces,
36
+ } from './workspaces.ts';
37
+ import { coderListGitHubAccounts, coderListGitHubRepos } from './github.ts';
38
+ import { coderGetLoopState, type CoderGetLoopStateParams } from './loop-state.ts';
39
+ import {
40
+ coderGetReplay,
41
+ coderListEventHistory,
42
+ coderListParticipants,
43
+ type CoderGetSessionReplayParams,
44
+ type CoderListEventHistoryParams,
45
+ type CoderListParticipantsParams,
46
+ } from './session-data.ts';
47
+ import { coderListUsers, type CoderListUsersParamsWithOrg } from './users.ts';
48
+ import type {
49
+ CoderGitHubAccountListResponse,
50
+ CoderGitHubRepositoryListResponse,
51
+ CoderListUsersResponse,
52
+ CoderSavedSkill,
53
+ CoderSavedSkillListResponse,
54
+ CoderLoopStateResponse,
55
+ CoderSession,
56
+ CoderSessionEventHistory,
57
+ CoderSessionListResponse,
58
+ CoderSessionParticipants,
59
+ CoderSessionReplay,
60
+ CoderSkillBucket,
61
+ CoderSkillBucketListResponse,
62
+ CoderCreateSkillBucketRequest,
63
+ CoderCreateWorkspaceRequest,
64
+ CoderWorkspaceDetail,
65
+ CoderWorkspaceListResponse,
66
+ CoderSaveSkillRequest,
67
+ CoderUpdateSessionRequest,
68
+ } from './types.ts';
69
+ import { normalizeCoderUrl } from './util.ts';
70
+
71
+ export const CoderClientOptionsSchema = z
72
+ .object({
73
+ apiKey: z.string().optional().describe('API key for authentication'),
74
+ url: z.string().optional().describe('Base URL for the Coder Hub HTTP API'),
75
+ region: z.string().optional().describe('Region used for Catalyst URL resolution'),
76
+ orgId: z.string().optional().describe('Organization ID for multi-tenant operations'),
77
+ logger: z.custom<Logger>().optional().describe('Custom logger implementation'),
78
+ })
79
+ .describe('Configuration options for constructing a CoderClient');
80
+ export type CoderClientOptions = z.infer<typeof CoderClientOptionsSchema>;
81
+
82
+ /**
83
+ * Ergonomic client for Coder Hub session management APIs.
84
+ *
85
+ * URL resolution strategy:
86
+ * 1) options.url
87
+ * 2) AGENTUITY_CODER_URL
88
+ * 3) discover via Catalyst GET /coder
89
+ */
90
+ export class CoderClient {
91
+ readonly #apiKey?: string;
92
+ readonly #orgId?: string;
93
+ readonly #region: string;
94
+ readonly #logger: Logger;
95
+ readonly #explicitUrl?: string;
96
+ #resolvedUrl?: string;
97
+ #client?: APIClient;
98
+ #clientPromise?: Promise<APIClient>;
99
+
100
+ constructor(options: CoderClientOptions = {}) {
101
+ this.#apiKey = options.apiKey ?? getEnv('AGENTUITY_SDK_KEY') ?? getEnv('AGENTUITY_CLI_KEY');
102
+ this.#orgId = options.orgId;
103
+ this.#region = options.region ?? getEnv('AGENTUITY_REGION') ?? 'usc';
104
+ this.#logger = options.logger ?? createMinimalLogger();
105
+ this.#explicitUrl = options.url;
106
+ }
107
+
108
+ /**
109
+ * Gets the active coder base URL, discovering it from Catalyst if needed.
110
+ */
111
+ async getUrl(): Promise<string> {
112
+ if (this.#resolvedUrl) {
113
+ return this.#resolvedUrl;
114
+ }
115
+
116
+ if (this.#explicitUrl) {
117
+ this.#resolvedUrl = normalizeCoderUrl(this.#explicitUrl);
118
+ return this.#resolvedUrl;
119
+ }
120
+
121
+ const envUrl = getEnv('AGENTUITY_CODER_URL');
122
+ if (envUrl) {
123
+ this.#resolvedUrl = normalizeCoderUrl(envUrl);
124
+ return this.#resolvedUrl;
125
+ }
126
+
127
+ const catalystUrl = getServiceUrls(this.#region).catalyst;
128
+ const headers: Record<string, string> = {};
129
+ if (this.#orgId) {
130
+ headers['x-agentuity-orgid'] = this.#orgId;
131
+ }
132
+ const catalystClient = new APIClient(catalystUrl, this.#logger, this.#apiKey ?? '', {
133
+ headers,
134
+ });
135
+ this.#resolvedUrl = await discoverUrl(catalystClient);
136
+ return this.#resolvedUrl;
137
+ }
138
+
139
+ async #getClient(): Promise<APIClient> {
140
+ if (this.#client) {
141
+ return this.#client;
142
+ }
143
+
144
+ if (!this.#clientPromise) {
145
+ this.#clientPromise = (async () => {
146
+ const baseUrl = await this.getUrl();
147
+ // Hub API routes live under /api (e.g., /api/hub/sessions)
148
+ const url = `${baseUrl}/api`;
149
+ const headers: Record<string, string> = {};
150
+ if (this.#orgId) {
151
+ headers['x-agentuity-orgid'] = this.#orgId;
152
+ }
153
+ const apiClient = new APIClient(url, this.#logger, this.#apiKey ?? '', { headers });
154
+ this.#client = apiClient;
155
+ return apiClient;
156
+ })();
157
+ }
158
+
159
+ return this.#clientPromise;
160
+ }
161
+
162
+ /**
163
+ * Creates a new coder session.
164
+ */
165
+ async createSession(
166
+ body: CoderCreateSessionParams['body']
167
+ ): Promise<CoderCreateSessionResponse> {
168
+ const client = await this.#getClient();
169
+ return coderCreateSession(client, { body, orgId: this.#orgId });
170
+ }
171
+
172
+ /**
173
+ * Retrieves a coder session by id.
174
+ */
175
+ async getSession(sessionId: string): Promise<CoderSession> {
176
+ const client = await this.#getClient();
177
+ return coderGetSession(client, { sessionId, orgId: this.#orgId });
178
+ }
179
+
180
+ /**
181
+ * Updates an existing coder session.
182
+ */
183
+ async updateSession(
184
+ sessionId: string,
185
+ body: CoderUpdateSessionRequest
186
+ ): Promise<CoderUpdateSessionResponse> {
187
+ const client = await this.#getClient();
188
+ return coderUpdateSession(client, { sessionId, body, orgId: this.#orgId });
189
+ }
190
+
191
+ /**
192
+ * Lists coder sessions with optional filtering.
193
+ */
194
+ async listSessions(
195
+ params?: Omit<CoderListSessionsParamsWithOrg, 'orgId'>
196
+ ): Promise<CoderSessionListResponse> {
197
+ const client = await this.#getClient();
198
+ return coderListSessions(client, { ...params, orgId: this.#orgId });
199
+ }
200
+
201
+ /**
202
+ * Permanently deletes a coder session.
203
+ */
204
+ async deleteSession(sessionId: string): Promise<void> {
205
+ const client = await this.#getClient();
206
+ return coderDeleteSession(client, { sessionId, orgId: this.#orgId });
207
+ }
208
+
209
+ /**
210
+ * Archives an active coder session.
211
+ */
212
+ async archiveSession(sessionId: string): Promise<CoderLifecycleResponse> {
213
+ const client = await this.#getClient();
214
+ return coderArchiveSession(client, { sessionId, orgId: this.#orgId });
215
+ }
216
+
217
+ /**
218
+ * Lists sessions the caller can connect to.
219
+ */
220
+ async listConnectableSessions(
221
+ params?: Omit<CoderListConnectableSessionsParams, 'orgId'>
222
+ ): Promise<CoderSessionListResponse> {
223
+ const client = await this.#getClient();
224
+ return coderListConnectableSessions(client, { ...params, orgId: this.#orgId });
225
+ }
226
+
227
+ /**
228
+ * Lists available workspaces.
229
+ */
230
+ async listWorkspaces(): Promise<CoderWorkspaceListResponse> {
231
+ const client = await this.#getClient();
232
+ return coderListWorkspaces(client);
233
+ }
234
+
235
+ /**
236
+ * Retrieves a workspace by id.
237
+ */
238
+ async getWorkspace(workspaceId: string): Promise<CoderWorkspaceDetail> {
239
+ const client = await this.#getClient();
240
+ return coderGetWorkspace(client, { workspaceId });
241
+ }
242
+
243
+ /**
244
+ * Creates a new workspace.
245
+ */
246
+ async createWorkspace(body: CoderCreateWorkspaceRequest): Promise<CoderWorkspaceDetail> {
247
+ const client = await this.#getClient();
248
+ return coderCreateWorkspace(client, { body });
249
+ }
250
+
251
+ /**
252
+ * Deletes a workspace.
253
+ */
254
+ async deleteWorkspace(workspaceId: string): Promise<void> {
255
+ const client = await this.#getClient();
256
+ return coderDeleteWorkspace(client, { workspaceId });
257
+ }
258
+
259
+ /**
260
+ * Lists saved skills in the caller's library.
261
+ */
262
+ async listSavedSkills(): Promise<CoderSavedSkillListResponse> {
263
+ const client = await this.#getClient();
264
+ return coderListSavedSkills(client);
265
+ }
266
+
267
+ /**
268
+ * Saves a skill to the caller's library.
269
+ */
270
+ async saveSkill(body: CoderSaveSkillRequest): Promise<CoderSavedSkill> {
271
+ const client = await this.#getClient();
272
+ return coderSaveSkill(client, { body });
273
+ }
274
+
275
+ /**
276
+ * Deletes a saved skill from the caller's library.
277
+ */
278
+ async deleteSavedSkill(skillId: string): Promise<void> {
279
+ const client = await this.#getClient();
280
+ return coderDeleteSavedSkill(client, { skillId });
281
+ }
282
+
283
+ /**
284
+ * Lists skill buckets.
285
+ */
286
+ async listSkillBuckets(): Promise<CoderSkillBucketListResponse> {
287
+ const client = await this.#getClient();
288
+ return coderListSkillBuckets(client);
289
+ }
290
+
291
+ /**
292
+ * Creates a skill bucket.
293
+ */
294
+ async createSkillBucket(body: CoderCreateSkillBucketRequest): Promise<CoderSkillBucket> {
295
+ const client = await this.#getClient();
296
+ return coderCreateSkillBucket(client, { body });
297
+ }
298
+
299
+ /**
300
+ * Deletes a skill bucket.
301
+ */
302
+ async deleteSkillBucket(bucketId: string): Promise<void> {
303
+ const client = await this.#getClient();
304
+ return coderDeleteSkillBucket(client, { bucketId });
305
+ }
306
+
307
+ /**
308
+ * Retrieves replay data for a session.
309
+ */
310
+ async getReplay(
311
+ sessionId: string,
312
+ params?: Omit<CoderGetSessionReplayParams, 'sessionId' | 'orgId'>
313
+ ): Promise<CoderSessionReplay> {
314
+ const client = await this.#getClient();
315
+ return coderGetReplay(client, { sessionId, ...params, orgId: this.#orgId });
316
+ }
317
+
318
+ /**
319
+ * Lists participants for a session.
320
+ */
321
+ async listParticipants(
322
+ sessionId: string,
323
+ params?: Omit<CoderListParticipantsParams, 'sessionId' | 'orgId'>
324
+ ): Promise<CoderSessionParticipants> {
325
+ const client = await this.#getClient();
326
+ return coderListParticipants(client, { sessionId, ...params, orgId: this.#orgId });
327
+ }
328
+
329
+ /**
330
+ * Lists historical events for a session.
331
+ */
332
+ async listEventHistory(
333
+ sessionId: string,
334
+ params?: Omit<CoderListEventHistoryParams, 'sessionId' | 'orgId'>
335
+ ): Promise<CoderSessionEventHistory> {
336
+ const client = await this.#getClient();
337
+ return coderListEventHistory(client, { sessionId, ...params, orgId: this.#orgId });
338
+ }
339
+
340
+ /**
341
+ * Gets loop-mode state for a session.
342
+ */
343
+ async getLoopState(
344
+ sessionId: string,
345
+ params?: Omit<CoderGetLoopStateParams, 'sessionId' | 'orgId'>
346
+ ): Promise<CoderLoopStateResponse> {
347
+ const client = await this.#getClient();
348
+ return coderGetLoopState(client, { sessionId, ...params, orgId: this.#orgId });
349
+ }
350
+
351
+ /**
352
+ * Lists known users in the coder hub.
353
+ */
354
+ async listUsers(
355
+ params?: Omit<CoderListUsersParamsWithOrg, 'orgId'>
356
+ ): Promise<CoderListUsersResponse> {
357
+ const client = await this.#getClient();
358
+ return coderListUsers(client, { ...params, orgId: this.#orgId });
359
+ }
360
+
361
+ // ── GitHub ────────────────────────────────────────────────────────────
362
+
363
+ /**
364
+ * Lists GitHub accounts available via the caller's GitHub App installations.
365
+ */
366
+ async listGitHubAccounts(): Promise<CoderGitHubAccountListResponse> {
367
+ const client = await this.#getClient();
368
+ return coderListGitHubAccounts(client);
369
+ }
370
+
371
+ /**
372
+ * Lists repositories accessible under a specific GitHub account.
373
+ */
374
+ async listGitHubRepos(accountId: string): Promise<CoderGitHubRepositoryListResponse> {
375
+ const client = await this.#getClient();
376
+ return coderListGitHubRepos(client, { accountId });
377
+ }
378
+ }
@@ -0,0 +1,23 @@
1
+ import { z } from 'zod/v4';
2
+ import { type APIClient } from '../api.ts';
3
+ import { normalizeCoderUrl } from './util.ts';
4
+
5
+ export const DiscoverCoderUrlDataSchema = z
6
+ .object({
7
+ url: z.string().describe('Discovered base URL for the organization coder hub API'),
8
+ })
9
+ .describe('Response payload for coder URL discovery');
10
+
11
+ /**
12
+ * Discovers the org-specific Coder Hub URL through Catalyst.
13
+ *
14
+ * Calls `GET /coder` on the Catalyst API. The org is resolved server-side
15
+ * from the API key's auth context (not via query parameters).
16
+ */
17
+ export async function discoverUrl(client: APIClient): Promise<string> {
18
+ const resp = await client.get<z.infer<typeof DiscoverCoderUrlDataSchema>>(
19
+ '/coder',
20
+ DiscoverCoderUrlDataSchema
21
+ );
22
+ return normalizeCoderUrl(resp.url);
23
+ }
@@ -0,0 +1,33 @@
1
+ import { type APIClient } from '../api.ts';
2
+ import {
3
+ CoderGitHubAccountListResponseSchema,
4
+ type CoderGitHubAccountListResponse,
5
+ CoderGitHubRepositoryListResponseSchema,
6
+ type CoderGitHubRepositoryListResponse,
7
+ } from './types.ts';
8
+
9
+ /**
10
+ * Lists GitHub accounts available via the caller's GitHub App installations.
11
+ */
12
+ export async function coderListGitHubAccounts(
13
+ client: APIClient
14
+ ): Promise<CoderGitHubAccountListResponse> {
15
+ return client.get<CoderGitHubAccountListResponse>(
16
+ '/hub/github/accounts',
17
+ CoderGitHubAccountListResponseSchema
18
+ );
19
+ }
20
+
21
+ /**
22
+ * Lists repositories accessible under a specific GitHub account.
23
+ */
24
+ export async function coderListGitHubRepos(
25
+ client: APIClient,
26
+ params: { accountId: string }
27
+ ): Promise<CoderGitHubRepositoryListResponse> {
28
+ const path = `/hub/github/repos?accountId=${encodeURIComponent(params.accountId)}`;
29
+ return client.get<CoderGitHubRepositoryListResponse>(
30
+ path,
31
+ CoderGitHubRepositoryListResponseSchema
32
+ );
33
+ }
@@ -0,0 +1,72 @@
1
+ export * from './types.ts';
2
+
3
+ export { discoverUrl, DiscoverCoderUrlDataSchema } from './discover.ts';
4
+
5
+ export type {
6
+ CoderCreateSessionParams,
7
+ CoderCreateSessionResponse,
8
+ CoderGetSessionParams,
9
+ CoderLifecycleResponse,
10
+ CoderListConnectableSessionsParams,
11
+ CoderListSessionsParamsWithOrg,
12
+ CoderSessionIdParams,
13
+ CoderUpdateSessionParams,
14
+ CoderUpdateSessionResponse,
15
+ } from './sessions.ts';
16
+ export {
17
+ coderArchiveSession,
18
+ coderCreateSession,
19
+ coderDeleteSession,
20
+ coderGetSession,
21
+ coderListConnectableSessions,
22
+ coderListSessions,
23
+ coderUpdateSession,
24
+ CoderCreateSessionParamsSchema,
25
+ CoderGetSessionParamsSchema,
26
+ CoderListConnectableSessionsParamsSchema,
27
+ CoderListSessionsParamsWithOrgSchema,
28
+ CoderSessionIdParamsSchema,
29
+ CoderUpdateSessionParamsSchema,
30
+ } from './sessions.ts';
31
+
32
+ export * from './skills.ts';
33
+ export * from './workspaces.ts';
34
+ export * from './github.ts';
35
+
36
+ export type {
37
+ CoderGetSessionReplayParams,
38
+ CoderListEventHistoryParams,
39
+ CoderListParticipantsParams,
40
+ } from './session-data.ts';
41
+ export {
42
+ coderGetReplay,
43
+ coderListEventHistory,
44
+ coderListParticipants,
45
+ CoderGetSessionReplayParamsSchema,
46
+ CoderListEventHistoryParamsSchema,
47
+ CoderListParticipantsParamsSchema,
48
+ } from './session-data.ts';
49
+
50
+ export type { CoderGetLoopStateParams } from './loop-state.ts';
51
+ export { coderGetLoopState, CoderGetLoopStateParamsSchema } from './loop-state.ts';
52
+
53
+ export type { CoderListUsersParamsWithOrg } from './users.ts';
54
+ export { coderListUsers, CoderListUsersParamsWithOrgSchema } from './users.ts';
55
+
56
+ export type { CoderClientOptions } from './client.ts';
57
+ export { CoderClient, CoderClientOptionsSchema } from './client.ts';
58
+
59
+ export type { CoderErrorCode, CoderErrorContext } from './util.ts';
60
+ export {
61
+ CoderErrorCodeSchema,
62
+ CoderErrorContextSchema,
63
+ CoderResponseError,
64
+ CoderSessionArchivedError,
65
+ CoderSessionConflictError,
66
+ CoderSessionNotFoundError,
67
+ normalizeCoderUrl,
68
+ throwCoderError,
69
+ withOrgId,
70
+ } from './util.ts';
71
+
72
+ export { default as CoderAPIReference } from './api-reference.ts';
@@ -0,0 +1,19 @@
1
+ import { z } from 'zod/v4';
2
+ import { type APIClient } from '../api.ts';
3
+ import { CoderLoopStateResponseSchema, type CoderLoopStateResponse } from './types.ts';
4
+
5
+ export const CoderGetLoopStateParamsSchema = z
6
+ .object({
7
+ sessionId: z.string().describe('Coder session identifier'),
8
+ orgId: z.string().optional().describe('Optional org id for CLI auth context'),
9
+ })
10
+ .describe('Parameters for retrieving loop state');
11
+ export type CoderGetLoopStateParams = z.infer<typeof CoderGetLoopStateParamsSchema>;
12
+
13
+ export async function coderGetLoopState(
14
+ client: APIClient,
15
+ params: CoderGetLoopStateParams
16
+ ): Promise<CoderLoopStateResponse> {
17
+ const path = `/hub/session/${encodeURIComponent(params.sessionId)}/loop`;
18
+ return client.get<CoderLoopStateResponse>(path, CoderLoopStateResponseSchema);
19
+ }
@@ -0,0 +1,63 @@
1
+ import { z } from 'zod/v4';
2
+ import { type APIClient } from '../api.ts';
3
+ import {
4
+ CoderSessionDataQuerySchema,
5
+ CoderSessionEventHistorySchema,
6
+ CoderSessionParticipantsSchema,
7
+ CoderSessionReplaySchema,
8
+ type CoderSessionDataQuery,
9
+ type CoderSessionEventHistory,
10
+ type CoderSessionParticipants,
11
+ type CoderSessionReplay,
12
+ } from './types.ts';
13
+
14
+ export const CoderGetSessionReplayParamsSchema = CoderSessionDataQuerySchema.describe(
15
+ 'Parameters for retrieving session replay data'
16
+ );
17
+ export type CoderGetSessionReplayParams = z.infer<typeof CoderGetSessionReplayParamsSchema>;
18
+
19
+ export const CoderListParticipantsParamsSchema = CoderSessionDataQuerySchema.describe(
20
+ 'Parameters for listing session participants'
21
+ );
22
+ export type CoderListParticipantsParams = z.infer<typeof CoderListParticipantsParamsSchema>;
23
+
24
+ export const CoderListEventHistoryParamsSchema = CoderSessionDataQuerySchema.describe(
25
+ 'Parameters for listing session event history'
26
+ );
27
+ export type CoderListEventHistoryParams = z.infer<typeof CoderListEventHistoryParamsSchema>;
28
+
29
+ function buildSessionDataQuery(params: CoderSessionDataQuery): string {
30
+ const query = new URLSearchParams();
31
+ if (params.limit !== undefined) {
32
+ query.set('limit', String(params.limit));
33
+ }
34
+ if (params.offset !== undefined) {
35
+ query.set('offset', String(params.offset));
36
+ }
37
+ const queryString = query.toString();
38
+ return queryString ? `?${queryString}` : '';
39
+ }
40
+
41
+ export async function coderGetReplay(
42
+ client: APIClient,
43
+ params: CoderGetSessionReplayParams
44
+ ): Promise<CoderSessionReplay> {
45
+ const path = `/hub/session/${encodeURIComponent(params.sessionId)}/replay${buildSessionDataQuery(params)}`;
46
+ return client.get<CoderSessionReplay>(path, CoderSessionReplaySchema);
47
+ }
48
+
49
+ export async function coderListParticipants(
50
+ client: APIClient,
51
+ params: CoderListParticipantsParams
52
+ ): Promise<CoderSessionParticipants> {
53
+ const path = `/hub/session/${encodeURIComponent(params.sessionId)}/participants${buildSessionDataQuery(params)}`;
54
+ return client.get<CoderSessionParticipants>(path, CoderSessionParticipantsSchema);
55
+ }
56
+
57
+ export async function coderListEventHistory(
58
+ client: APIClient,
59
+ params: CoderListEventHistoryParams
60
+ ): Promise<CoderSessionEventHistory> {
61
+ const path = `/hub/session/${encodeURIComponent(params.sessionId)}/events/history${buildSessionDataQuery(params)}`;
62
+ return client.get<CoderSessionEventHistory>(path, CoderSessionEventHistorySchema);
63
+ }