@agent-os-sdk/client 0.9.26 → 0.9.27

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 (209) hide show
  1. package/dist/client/AgentOsClient.d.ts +141 -0
  2. package/dist/client/AgentOsClient.d.ts.map +1 -0
  3. package/{src/client/AgentOsClient.ts → dist/client/AgentOsClient.js} +61 -105
  4. package/dist/client/HttpRequestBuilder.d.ts +50 -0
  5. package/dist/client/HttpRequestBuilder.d.ts.map +1 -0
  6. package/{src/client/HttpRequestBuilder.ts → dist/client/HttpRequestBuilder.js} +9 -41
  7. package/{src/client/OperationContext.ts → dist/client/OperationContext.d.ts} +6 -9
  8. package/dist/client/OperationContext.d.ts.map +1 -0
  9. package/dist/client/OperationContext.js +13 -0
  10. package/dist/client/OperationContextProvider.d.ts +54 -0
  11. package/dist/client/OperationContextProvider.d.ts.map +1 -0
  12. package/{src/client/OperationContextProvider.ts → dist/client/OperationContextProvider.js} +17 -35
  13. package/{src/client/auth.ts → dist/client/auth.d.ts} +29 -65
  14. package/dist/client/auth.d.ts.map +1 -0
  15. package/dist/client/auth.js +38 -0
  16. package/dist/client/config.d.ts +49 -0
  17. package/dist/client/config.d.ts.map +1 -0
  18. package/{src/client/config.ts → dist/client/config.js} +5 -43
  19. package/dist/client/helpers.d.ts +63 -0
  20. package/dist/client/helpers.d.ts.map +1 -0
  21. package/{src/client/helpers.ts → dist/client/helpers.js} +9 -52
  22. package/dist/client/pagination.d.ts +105 -0
  23. package/dist/client/pagination.d.ts.map +1 -0
  24. package/{src/client/pagination.ts → dist/client/pagination.js} +15 -116
  25. package/dist/client/raw.d.ts +277 -0
  26. package/dist/client/raw.d.ts.map +1 -0
  27. package/dist/client/raw.js +337 -0
  28. package/dist/client/retry.d.ts +37 -0
  29. package/dist/client/retry.d.ts.map +1 -0
  30. package/{src/client/retry.ts → dist/client/retry.js} +13 -55
  31. package/dist/client/sanitize.d.ts +19 -0
  32. package/dist/client/sanitize.d.ts.map +1 -0
  33. package/{src/client/sanitize.ts → dist/client/sanitize.js} +4 -7
  34. package/dist/client/timeout.d.ts +26 -0
  35. package/dist/client/timeout.d.ts.map +1 -0
  36. package/{src/client/timeout.ts → dist/client/timeout.js} +10 -18
  37. package/dist/errors/factory.d.ts +22 -0
  38. package/dist/errors/factory.d.ts.map +1 -0
  39. package/{src/errors/factory.ts → dist/errors/factory.js} +18 -57
  40. package/dist/errors/index.d.ts +210 -0
  41. package/dist/errors/index.d.ts.map +1 -0
  42. package/{src/errors/index.ts → dist/errors/index.js} +74 -156
  43. package/{src/generated/client.ts → dist/generated/client.d.ts} +5 -17
  44. package/dist/generated/client.d.ts.map +1 -0
  45. package/dist/generated/client.js +15 -0
  46. package/{src/generated/index.ts → dist/generated/index.d.ts} +1 -1
  47. package/dist/generated/index.d.ts.map +1 -0
  48. package/dist/generated/index.js +1 -0
  49. package/{src/generated/openapi.ts → dist/generated/openapi.d.ts} +1 -1
  50. package/dist/generated/openapi.d.ts.map +1 -0
  51. package/dist/generated/openapi.js +5 -0
  52. package/dist/index.d.ts +69 -0
  53. package/dist/index.d.ts.map +1 -0
  54. package/{src/index.ts → dist/index.js} +13 -63
  55. package/dist/modules/a2a.d.ts +48 -0
  56. package/dist/modules/a2a.d.ts.map +1 -0
  57. package/dist/modules/a2a.js +37 -0
  58. package/dist/modules/agents.d.ts +346 -0
  59. package/dist/modules/agents.d.ts.map +1 -0
  60. package/dist/modules/agents.js +296 -0
  61. package/dist/modules/apiTokens.d.ts +62 -0
  62. package/dist/modules/apiTokens.d.ts.map +1 -0
  63. package/dist/modules/apiTokens.js +56 -0
  64. package/dist/modules/approvals.d.ts +75 -0
  65. package/dist/modules/approvals.d.ts.map +1 -0
  66. package/dist/modules/approvals.js +91 -0
  67. package/dist/modules/audit.d.ts +78 -0
  68. package/dist/modules/audit.d.ts.map +1 -0
  69. package/{src/modules/audit.ts → dist/modules/audit.js} +23 -74
  70. package/{src/modules/auth.ts → dist/modules/auth.d.ts} +6 -11
  71. package/dist/modules/auth.d.ts.map +1 -0
  72. package/dist/modules/auth.js +22 -0
  73. package/dist/modules/builder.d.ts +242 -0
  74. package/dist/modules/builder.d.ts.map +1 -0
  75. package/dist/modules/builder.js +248 -0
  76. package/dist/modules/catalog.d.ts +142 -0
  77. package/dist/modules/catalog.d.ts.map +1 -0
  78. package/dist/modules/catalog.js +136 -0
  79. package/dist/modules/chatwoot.d.ts +59 -0
  80. package/dist/modules/chatwoot.d.ts.map +1 -0
  81. package/dist/modules/chatwoot.js +200 -0
  82. package/dist/modules/checkpoints.d.ts +62 -0
  83. package/dist/modules/checkpoints.d.ts.map +1 -0
  84. package/dist/modules/checkpoints.js +48 -0
  85. package/dist/modules/contracts.d.ts +48 -0
  86. package/dist/modules/contracts.d.ts.map +1 -0
  87. package/dist/modules/contracts.js +25 -0
  88. package/dist/modules/credentials.d.ts +105 -0
  89. package/dist/modules/credentials.d.ts.map +1 -0
  90. package/dist/modules/credentials.js +135 -0
  91. package/dist/modules/crons.d.ts +73 -0
  92. package/dist/modules/crons.d.ts.map +1 -0
  93. package/dist/modules/crons.js +67 -0
  94. package/dist/modules/datasets.d.ts +80 -0
  95. package/dist/modules/datasets.d.ts.map +1 -0
  96. package/dist/modules/datasets.js +91 -0
  97. package/{src/modules/evaluation.ts → dist/modules/evaluation.d.ts} +23 -109
  98. package/dist/modules/evaluation.d.ts.map +1 -0
  99. package/dist/modules/evaluation.js +108 -0
  100. package/dist/modules/files.d.ts +89 -0
  101. package/dist/modules/files.d.ts.map +1 -0
  102. package/dist/modules/files.js +133 -0
  103. package/dist/modules/graphs.d.ts +120 -0
  104. package/dist/modules/graphs.d.ts.map +1 -0
  105. package/dist/modules/graphs.js +69 -0
  106. package/{src/modules/improvements.ts → dist/modules/improvements.d.ts} +8 -27
  107. package/dist/modules/improvements.d.ts.map +1 -0
  108. package/dist/modules/improvements.js +27 -0
  109. package/dist/modules/info.d.ts +76 -0
  110. package/dist/modules/info.d.ts.map +1 -0
  111. package/{src/modules/info.ts → dist/modules/info.js} +16 -66
  112. package/dist/modules/knowledge.d.ts +91 -0
  113. package/dist/modules/knowledge.d.ts.map +1 -0
  114. package/dist/modules/knowledge.js +80 -0
  115. package/{src/modules/me.ts → dist/modules/me.d.ts} +7 -23
  116. package/dist/modules/me.d.ts.map +1 -0
  117. package/dist/modules/me.js +28 -0
  118. package/dist/modules/members.d.ts +124 -0
  119. package/dist/modules/members.d.ts.map +1 -0
  120. package/dist/modules/members.js +142 -0
  121. package/dist/modules/memberships.d.ts +25 -0
  122. package/dist/modules/memberships.d.ts.map +1 -0
  123. package/dist/modules/memberships.js +20 -0
  124. package/{src/modules/metaAgent.ts → dist/modules/metaAgent.d.ts} +8 -44
  125. package/dist/modules/metaAgent.d.ts.map +1 -0
  126. package/dist/modules/metaAgent.js +32 -0
  127. package/dist/modules/metrics.d.ts +20 -0
  128. package/dist/modules/metrics.d.ts.map +1 -0
  129. package/{src/modules/metrics.ts → dist/modules/metrics.js} +7 -14
  130. package/dist/modules/observability.d.ts +19 -0
  131. package/dist/modules/observability.d.ts.map +1 -0
  132. package/dist/modules/observability.js +14 -0
  133. package/dist/modules/playground.d.ts +42 -0
  134. package/dist/modules/playground.d.ts.map +1 -0
  135. package/dist/modules/playground.js +48 -0
  136. package/dist/modules/presets.d.ts +32 -0
  137. package/dist/modules/presets.d.ts.map +1 -0
  138. package/dist/modules/presets.js +199 -0
  139. package/dist/modules/prompts.d.ts +87 -0
  140. package/dist/modules/prompts.d.ts.map +1 -0
  141. package/dist/modules/prompts.js +87 -0
  142. package/dist/modules/roles.d.ts +64 -0
  143. package/dist/modules/roles.d.ts.map +1 -0
  144. package/dist/modules/roles.js +79 -0
  145. package/dist/modules/runs.d.ts +451 -0
  146. package/dist/modules/runs.d.ts.map +1 -0
  147. package/{src/modules/runs.ts → dist/modules/runs.js} +96 -438
  148. package/dist/modules/store.d.ts +37 -0
  149. package/dist/modules/store.d.ts.map +1 -0
  150. package/dist/modules/store.js +48 -0
  151. package/{src/modules/templates.ts → dist/modules/templates.d.ts} +8 -32
  152. package/dist/modules/templates.d.ts.map +1 -0
  153. package/dist/modules/templates.js +26 -0
  154. package/dist/modules/tenants.d.ts +49 -0
  155. package/dist/modules/tenants.d.ts.map +1 -0
  156. package/dist/modules/tenants.js +56 -0
  157. package/dist/modules/threads.d.ts +205 -0
  158. package/dist/modules/threads.d.ts.map +1 -0
  159. package/dist/modules/threads.js +225 -0
  160. package/dist/modules/tools.d.ts +62 -0
  161. package/dist/modules/tools.d.ts.map +1 -0
  162. package/dist/modules/tools.js +45 -0
  163. package/dist/modules/traces.d.ts +89 -0
  164. package/dist/modules/traces.d.ts.map +1 -0
  165. package/dist/modules/traces.js +65 -0
  166. package/{src/modules/triggers.ts → dist/modules/triggers.d.ts} +24 -153
  167. package/dist/modules/triggers.d.ts.map +1 -0
  168. package/dist/modules/triggers.js +176 -0
  169. package/{src/modules/usage.ts → dist/modules/usage.d.ts} +14 -46
  170. package/dist/modules/usage.d.ts.map +1 -0
  171. package/dist/modules/usage.js +43 -0
  172. package/dist/modules/vectorStores.d.ts +100 -0
  173. package/dist/modules/vectorStores.d.ts.map +1 -0
  174. package/dist/modules/vectorStores.js +159 -0
  175. package/dist/modules/workspaces.d.ts +138 -0
  176. package/dist/modules/workspaces.d.ts.map +1 -0
  177. package/dist/modules/workspaces.js +121 -0
  178. package/dist/sse/client.d.ts +140 -0
  179. package/dist/sse/client.d.ts.map +1 -0
  180. package/{src/sse/client.ts → dist/sse/client.js} +24 -100
  181. package/package.json +8 -15
  182. package/src/client/raw.ts +0 -609
  183. package/src/generated/swagger.json +0 -17014
  184. package/src/modules/a2a.ts +0 -64
  185. package/src/modules/agents.ts +0 -604
  186. package/src/modules/apiTokens.ts +0 -101
  187. package/src/modules/approvals.ts +0 -151
  188. package/src/modules/catalog.ts +0 -241
  189. package/src/modules/chatwoot.ts +0 -242
  190. package/src/modules/checkpoints.ts +0 -87
  191. package/src/modules/contracts.ts +0 -80
  192. package/src/modules/credentials.ts +0 -216
  193. package/src/modules/crons.ts +0 -115
  194. package/src/modules/datasets.ts +0 -142
  195. package/src/modules/files.ts +0 -208
  196. package/src/modules/members.ts +0 -199
  197. package/src/modules/memberships.ts +0 -42
  198. package/src/modules/observability.ts +0 -28
  199. package/src/modules/playground.ts +0 -68
  200. package/src/modules/presets.ts +0 -246
  201. package/src/modules/prompts.ts +0 -147
  202. package/src/modules/roles.ts +0 -112
  203. package/src/modules/store.ts +0 -65
  204. package/src/modules/tenants.ts +0 -79
  205. package/src/modules/threads.ts +0 -343
  206. package/src/modules/tools.ts +0 -91
  207. package/src/modules/traces.ts +0 -133
  208. package/src/modules/vectorStores.ts +0 -257
  209. package/src/modules/workspaces.ts +0 -216
@@ -1,257 +0,0 @@
1
- /**
2
- * Vector Stores Module - Fully Typed
3
- */
4
-
5
- import type { RawClient, APIResponse, components } from "../client/raw.js";
6
-
7
- type VectorStoreResponse = components["schemas"]["VectorStoreResponse"];
8
- type VectorQueryResponse = components["schemas"]["VectorQueryResponse"];
9
- type VectorStoreFileResponse = components["schemas"]["VectorStoreFileResponse"];
10
-
11
- export interface VectorStore {
12
- id: string;
13
- name: string;
14
- embedding_provider: string;
15
- embedding_model: string;
16
- dimension: number;
17
- credential_binding_key?: string;
18
- file_count: number;
19
- created_at: string;
20
- }
21
-
22
- export interface VectorStoreListResponse {
23
- items: VectorStore[];
24
- total: number;
25
- }
26
-
27
- export interface VectorSearchResult {
28
- id: string;
29
- chunk_index: number;
30
- content_text: string;
31
- score: number;
32
- file_id?: string;
33
- }
34
-
35
- export interface VectorQueryResult {
36
- query: string;
37
- results: VectorSearchResult[];
38
- total_results: number;
39
- }
40
-
41
- export interface VectorStoreFile {
42
- id: string;
43
- file_id: string;
44
- filename: string;
45
- status: "pending" | "processing" | "completed" | "failed";
46
- created_at: string;
47
- }
48
-
49
- export interface VectorStoreFilesResponse {
50
- items: VectorStoreFile[];
51
- total: number;
52
- }
53
-
54
- type VectorStoreLike = VectorStoreResponse & {
55
- embeddingProvider?: string;
56
- embeddingModel?: string;
57
- credentialBindingKey?: string;
58
- fileCount?: number;
59
- createdAt?: string;
60
- };
61
-
62
- type VectorStoreFileLike = VectorStoreFileResponse & {
63
- fileId?: string;
64
- createdAt?: string;
65
- };
66
-
67
- function toVectorStore(item: VectorStoreLike): VectorStore {
68
- return {
69
- id: item.id ?? "",
70
- name: item.name ?? "",
71
- embedding_provider: item.embedding_provider ?? item.embeddingProvider ?? "",
72
- embedding_model: item.embedding_model ?? item.embeddingModel ?? "",
73
- dimension: item.dimension ?? 0,
74
- credential_binding_key: item.credential_binding_key ?? item.credentialBindingKey ?? undefined,
75
- file_count: item.file_count ?? item.fileCount ?? 0,
76
- created_at: item.created_at ?? item.createdAt ?? "",
77
- };
78
- }
79
-
80
- function toVectorStoreFile(item: VectorStoreFileLike): VectorStoreFile {
81
- return {
82
- id: item.id ?? "",
83
- file_id: item.file_id ?? item.fileId ?? "",
84
- filename: item.filename ?? "",
85
- status: (item.status ?? "pending") as VectorStoreFile["status"],
86
- created_at: item.created_at ?? item.createdAt ?? "",
87
- };
88
- }
89
-
90
- export class VectorStoresModule {
91
- constructor(private client: RawClient, private headers: () => Record<string, string>) { }
92
-
93
- /**
94
- * List all vector stores.
95
- */
96
- async list(params?: {
97
- workspace_id?: string;
98
- limit?: number;
99
- offset?: number;
100
- }): Promise<APIResponse<VectorStoreListResponse>> {
101
- const response = await this.client.GET<VectorStoreResponse[]>("/v1/api/vector-stores", {
102
- params: { query: params },
103
- headers: this.headers(),
104
- });
105
-
106
- const items = Array.isArray(response.data)
107
- ? response.data.map((item) => toVectorStore(item))
108
- : [];
109
-
110
- return {
111
- ...response,
112
- data: {
113
- items,
114
- total: items.length,
115
- },
116
- };
117
- }
118
-
119
- /**
120
- * Get a vector store by ID.
121
- */
122
- async get(storeId: string): Promise<APIResponse<VectorStore>> {
123
- const response = await this.client.GET<VectorStoreResponse>("/v1/api/vector-stores/{vectorStoreId}", {
124
- params: { path: { vectorStoreId: storeId } },
125
- headers: this.headers(),
126
- });
127
-
128
- if (!response.data) {
129
- return response as APIResponse<VectorStore>;
130
- }
131
-
132
- return {
133
- ...response,
134
- data: toVectorStore(response.data),
135
- };
136
- }
137
-
138
- /**
139
- * Create a new vector store.
140
- */
141
- async create(body: {
142
- name: string;
143
- embedding_provider?: string;
144
- embedding_model?: string;
145
- dimension?: number;
146
- credential_binding_key?: string;
147
- }): Promise<APIResponse<VectorStore>> {
148
- const response = await this.client.POST<VectorStoreResponse>("/v1/api/vector-stores", {
149
- body,
150
- headers: this.headers(),
151
- });
152
-
153
- if (!response.data) {
154
- return response as APIResponse<VectorStore>;
155
- }
156
-
157
- return {
158
- ...response,
159
- data: toVectorStore(response.data),
160
- };
161
- }
162
-
163
- /**
164
- * Delete a vector store.
165
- */
166
- async delete(storeId: string): Promise<APIResponse<void>> {
167
- return this.client.DELETE<void>("/v1/api/vector-stores/{vectorStoreId}", {
168
- params: { path: { vectorStoreId: storeId } },
169
- headers: this.headers(),
170
- });
171
- }
172
-
173
- // ======================== Query ========================
174
-
175
- /**
176
- * Query a vector store for similar content.
177
- */
178
- async query(storeId: string, body: {
179
- query: string;
180
- top_k?: number;
181
- min_score?: number;
182
- }): Promise<APIResponse<VectorQueryResult>> {
183
- return this.client.POST<VectorQueryResponse>("/v1/api/vector-stores/{vectorStoreId}/query", {
184
- params: { path: { vectorStoreId: storeId } },
185
- body,
186
- headers: this.headers(),
187
- }) as Promise<APIResponse<VectorQueryResult>>;
188
- }
189
-
190
- // ======================== Files ========================
191
-
192
- /**
193
- * List files in a vector store.
194
- */
195
- async listFiles(storeId: string, params?: {
196
- skip?: number;
197
- take?: number;
198
- }): Promise<APIResponse<VectorStoreFilesResponse>> {
199
- const response = await this.client.GET<VectorStoreFileResponse[]>("/v1/api/vector-stores/{vectorStoreId}/files", {
200
- params: { path: { vectorStoreId: storeId }, query: params },
201
- headers: this.headers(),
202
- });
203
-
204
- const items = Array.isArray(response.data)
205
- ? response.data.map((item) => toVectorStoreFile(item))
206
- : [];
207
-
208
- return {
209
- ...response,
210
- data: {
211
- items,
212
- total: items.length,
213
- },
214
- };
215
- }
216
-
217
- /**
218
- * Attach a file to a vector store.
219
- */
220
- async attachFile(storeId: string, fileId: string): Promise<APIResponse<VectorStoreFile>> {
221
- const response = await this.client.POST<VectorStoreFileResponse>("/v1/api/vector-stores/{vectorStoreId}/files", {
222
- params: { path: { vectorStoreId: storeId } },
223
- body: { file_id: fileId },
224
- headers: this.headers(),
225
- });
226
-
227
- if (!response.data) {
228
- return response as APIResponse<VectorStoreFile>;
229
- }
230
-
231
- return {
232
- ...response,
233
- data: toVectorStoreFile(response.data),
234
- };
235
- }
236
-
237
- /**
238
- * Remove a file from a vector store.
239
- */
240
- async removeFile(storeId: string, fileId: string): Promise<APIResponse<void>> {
241
- return this.client.DELETE<void>("/v1/api/vector-stores/{vectorStoreId}/files/{fileId}", {
242
- params: { path: { vectorStoreId: storeId, fileId } },
243
- headers: this.headers(),
244
- });
245
- }
246
-
247
- /**
248
- * Bind a vector store to an agent.
249
- */
250
- async bindAgent(storeId: string, agentId: string): Promise<APIResponse<void>> {
251
- return this.client.POST<void>("/v1/api/vector-stores/{vectorStoreId}/bind-agent", {
252
- params: { path: { vectorStoreId: storeId } },
253
- body: { agent_id: agentId },
254
- headers: this.headers(),
255
- });
256
- }
257
- }
@@ -1,216 +0,0 @@
1
- /**
2
- * Workspaces Module - Fully Typed
3
- */
4
-
5
- import type { RawClient, APIResponse, components } from "../client/raw.js";
6
- import { parseSSE } from "../sse/client.js";
7
-
8
- type UpdateWorkspaceRequest = components["schemas"]["UpdateWorkspaceRequest"];
9
-
10
- // ─── Workspace Event Types ─────────────────────────────────────
11
-
12
- /** Event emitted by workspace-level SSE stream. */
13
- export interface WorkspaceEvent {
14
- type: string;
15
- workspace_id: string;
16
- run_id?: string;
17
- agent_id?: string;
18
- old_status?: string;
19
- new_status?: string;
20
- ts: number;
21
- }
22
-
23
- /** Options for followEvents(). */
24
- export interface WorkspaceFollowOptions {
25
- /** AbortSignal to kill the SSE connection. Required for cleanup. */
26
- signal?: AbortSignal;
27
- }
28
-
29
- export interface Workspace {
30
- id: string;
31
- tenant_id: string;
32
- name: string;
33
- is_default: boolean;
34
- settings?: Record<string, unknown>;
35
- created_at: string;
36
- updated_at: string;
37
- }
38
-
39
- export interface WorkspaceListResponse {
40
- items: Workspace[];
41
- total: number;
42
- }
43
-
44
- export class WorkspacesModule {
45
- constructor(
46
- private client: RawClient,
47
- private getTenantId: () => string,
48
- private headers: () => Record<string, string>
49
- ) { }
50
-
51
- /**
52
- * List all workspaces.
53
- */
54
- async list(params?: {
55
- limit?: number;
56
- offset?: number;
57
- }): Promise<APIResponse<WorkspaceListResponse>> {
58
- return this.client.GET<WorkspaceListResponse>("/v1/api/workspaces", {
59
- params: { query: params },
60
- headers: this.headers(),
61
- });
62
- }
63
-
64
- /**
65
- * Get a workspace by ID.
66
- */
67
- async get(workspaceId: string): Promise<APIResponse<Workspace>> {
68
- return this.client.GET<Workspace>("/v1/api/workspaces/{id}", {
69
- params: { path: { id: workspaceId } },
70
- headers: this.headers(),
71
- });
72
- }
73
-
74
- /**
75
- * Create a new workspace.
76
- */
77
- async create(body: {
78
- name: string;
79
- is_default?: boolean;
80
- }): Promise<APIResponse<Workspace>> {
81
- return this.client.POST<Workspace>("/v1/api/workspaces", {
82
- body,
83
- headers: this.headers(),
84
- });
85
- }
86
-
87
- /**
88
- * Update a workspace.
89
- */
90
- async update(workspaceId: string, body: {
91
- name?: string;
92
- }): Promise<APIResponse<Workspace>> {
93
- return this.client.PUT<Workspace>("/v1/api/workspaces/{id}", {
94
- params: { path: { id: workspaceId } },
95
- body,
96
- headers: this.headers(),
97
- });
98
- }
99
-
100
- /**
101
- * Delete a workspace.
102
- */
103
- async delete(workspaceId: string): Promise<APIResponse<void>> {
104
- return this.client.DELETE<void>("/v1/api/workspaces/{id}", {
105
- params: { path: { id: workspaceId } },
106
- headers: this.headers(),
107
- });
108
- }
109
-
110
- /**
111
- * Get workspace quotas.
112
- */
113
- async getQuotas(workspaceId: string): Promise<APIResponse<WorkspaceQuotaResponse>> {
114
- return this.client.GET<WorkspaceQuotaResponse>("/v1/api/workspaces/{workspaceId}/quotas", {
115
- params: { path: { workspaceId } },
116
- headers: this.headers(),
117
- });
118
- }
119
-
120
- /**
121
- * Get workspace usage.
122
- */
123
- async getUsage(workspaceId: string, params?: { from?: string; to?: string }): Promise<APIResponse<WorkspaceUsageResponse>> {
124
- return this.client.GET<WorkspaceUsageResponse>("/v1/api/workspaces/{workspaceId}/usage", {
125
- params: { path: { workspaceId }, query: params },
126
- headers: this.headers(),
127
- });
128
- }
129
-
130
- // ======================== FOLLOW (Workspace SSE) ========================
131
-
132
- /**
133
- * Stream workspace events via SSE.
134
- * Workspace identity flows via X-Workspace-Id header (same as all SDK methods).
135
- *
136
- * @param options - AbortSignal for cleanup (MUST be used to avoid leaking connections)
137
- *
138
- * @example
139
- * ```ts
140
- * const controller = new AbortController();
141
- * for await (const event of client.workspaces.followEvents({ signal: controller.signal })) {
142
- * if (event.type === 'run_status_changed') {
143
- * console.log(`Run ${event.run_id} → ${event.new_status}`);
144
- * }
145
- * }
146
- * // On cleanup:
147
- * controller.abort();
148
- * ```
149
- */
150
- async *followEvents(options?: WorkspaceFollowOptions): AsyncGenerator<WorkspaceEvent, void, unknown> {
151
- // Workspace identity flows via X-Workspace-Id header (set by this.headers()),
152
- // consistent with all other SDK endpoints. No path param needed.
153
- const response = await this.client.streamGet(
154
- "/v1/api/workspaces/events/stream",
155
- {
156
- headers: this.headers(),
157
- signal: options?.signal,
158
- }
159
- );
160
-
161
- try {
162
- for await (const rawEvent of parseSSE<WorkspaceEvent>(response)) {
163
- if (rawEvent.data != null) {
164
- yield rawEvent.data;
165
- }
166
- }
167
- } catch (err) {
168
- // Abort is normal cleanup — not an error worth surfacing.
169
- // Check both signal state and error name (covers proxy/wrapper edge cases).
170
- if (options?.signal?.aborted) return;
171
- if (err instanceof Error && err.name === "AbortError") return;
172
- throw err;
173
- }
174
- }
175
- }
176
-
177
- export interface WorkspaceQuotaResponse {
178
- workspace_id: string;
179
- quotas: {
180
- runs_per_month: Quota;
181
- tokens_per_month: Quota;
182
- agents_max: Quota;
183
- storage_mb: Quota;
184
- };
185
- reset_at: string;
186
- source: string;
187
- }
188
-
189
- export interface Quota {
190
- limit: number;
191
- used: number;
192
- remaining: number;
193
- }
194
-
195
- export interface WorkspaceUsageResponse {
196
- workspace_id: string;
197
- period: { from: string; to: string };
198
- usage: {
199
- total_runs: number;
200
- completed_runs: number;
201
- failed_runs: number;
202
- total_tokens: number;
203
- input_tokens: number;
204
- output_tokens: number;
205
- total_duration_ms: number;
206
- estimated_count: number;
207
- };
208
- daily_breakdown: Array<{
209
- date: string;
210
- runs: number;
211
- tokens_in: number;
212
- tokens_out: number;
213
- duration_ms: number;
214
- }>;
215
- source: string;
216
- }