@agent-os-sdk/client 0.9.26 → 0.9.28
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.
- package/dist/client/AgentOsClient.d.ts +141 -0
- package/dist/client/AgentOsClient.d.ts.map +1 -0
- package/{src/client/AgentOsClient.ts → dist/client/AgentOsClient.js} +61 -105
- package/dist/client/HttpRequestBuilder.d.ts +50 -0
- package/dist/client/HttpRequestBuilder.d.ts.map +1 -0
- package/{src/client/HttpRequestBuilder.ts → dist/client/HttpRequestBuilder.js} +9 -41
- package/{src/client/OperationContext.ts → dist/client/OperationContext.d.ts} +6 -9
- package/dist/client/OperationContext.d.ts.map +1 -0
- package/dist/client/OperationContext.js +13 -0
- package/dist/client/OperationContextProvider.d.ts +54 -0
- package/dist/client/OperationContextProvider.d.ts.map +1 -0
- package/{src/client/OperationContextProvider.ts → dist/client/OperationContextProvider.js} +17 -35
- package/{src/client/auth.ts → dist/client/auth.d.ts} +29 -65
- package/dist/client/auth.d.ts.map +1 -0
- package/dist/client/auth.js +38 -0
- package/dist/client/config.d.ts +49 -0
- package/dist/client/config.d.ts.map +1 -0
- package/{src/client/config.ts → dist/client/config.js} +5 -43
- package/dist/client/helpers.d.ts +63 -0
- package/dist/client/helpers.d.ts.map +1 -0
- package/{src/client/helpers.ts → dist/client/helpers.js} +9 -52
- package/dist/client/pagination.d.ts +105 -0
- package/dist/client/pagination.d.ts.map +1 -0
- package/{src/client/pagination.ts → dist/client/pagination.js} +15 -116
- package/dist/client/raw.d.ts +277 -0
- package/dist/client/raw.d.ts.map +1 -0
- package/dist/client/raw.js +337 -0
- package/dist/client/retry.d.ts +37 -0
- package/dist/client/retry.d.ts.map +1 -0
- package/{src/client/retry.ts → dist/client/retry.js} +13 -55
- package/dist/client/sanitize.d.ts +19 -0
- package/dist/client/sanitize.d.ts.map +1 -0
- package/{src/client/sanitize.ts → dist/client/sanitize.js} +4 -7
- package/dist/client/timeout.d.ts +26 -0
- package/dist/client/timeout.d.ts.map +1 -0
- package/{src/client/timeout.ts → dist/client/timeout.js} +10 -18
- package/dist/errors/factory.d.ts +22 -0
- package/dist/errors/factory.d.ts.map +1 -0
- package/{src/errors/factory.ts → dist/errors/factory.js} +18 -57
- package/dist/errors/index.d.ts +210 -0
- package/dist/errors/index.d.ts.map +1 -0
- package/{src/errors/index.ts → dist/errors/index.js} +74 -156
- package/{src/generated/client.ts → dist/generated/client.d.ts} +5 -17
- package/dist/generated/client.d.ts.map +1 -0
- package/dist/generated/client.js +15 -0
- package/{src/generated/index.ts → dist/generated/index.d.ts} +1 -1
- package/dist/generated/index.d.ts.map +1 -0
- package/dist/generated/index.js +1 -0
- package/{src/generated/openapi.ts → dist/generated/openapi.d.ts} +1 -1
- package/dist/generated/openapi.d.ts.map +1 -0
- package/dist/generated/openapi.js +5 -0
- package/dist/index.d.ts +69 -0
- package/dist/index.d.ts.map +1 -0
- package/{src/index.ts → dist/index.js} +13 -63
- package/dist/modules/a2a.d.ts +48 -0
- package/dist/modules/a2a.d.ts.map +1 -0
- package/dist/modules/a2a.js +37 -0
- package/dist/modules/agents.d.ts +346 -0
- package/dist/modules/agents.d.ts.map +1 -0
- package/dist/modules/agents.js +296 -0
- package/dist/modules/apiTokens.d.ts +62 -0
- package/dist/modules/apiTokens.d.ts.map +1 -0
- package/dist/modules/apiTokens.js +56 -0
- package/dist/modules/approvals.d.ts +77 -0
- package/dist/modules/approvals.d.ts.map +1 -0
- package/dist/modules/approvals.js +91 -0
- package/dist/modules/audit.d.ts +78 -0
- package/dist/modules/audit.d.ts.map +1 -0
- package/{src/modules/audit.ts → dist/modules/audit.js} +23 -74
- package/{src/modules/auth.ts → dist/modules/auth.d.ts} +6 -11
- package/dist/modules/auth.d.ts.map +1 -0
- package/dist/modules/auth.js +22 -0
- package/dist/modules/builder.d.ts +242 -0
- package/dist/modules/builder.d.ts.map +1 -0
- package/dist/modules/builder.js +248 -0
- package/dist/modules/catalog.d.ts +142 -0
- package/dist/modules/catalog.d.ts.map +1 -0
- package/dist/modules/catalog.js +136 -0
- package/dist/modules/chatwoot.d.ts +59 -0
- package/dist/modules/chatwoot.d.ts.map +1 -0
- package/dist/modules/chatwoot.js +200 -0
- package/dist/modules/checkpoints.d.ts +62 -0
- package/dist/modules/checkpoints.d.ts.map +1 -0
- package/dist/modules/checkpoints.js +48 -0
- package/dist/modules/contracts.d.ts +48 -0
- package/dist/modules/contracts.d.ts.map +1 -0
- package/dist/modules/contracts.js +25 -0
- package/dist/modules/credentials.d.ts +105 -0
- package/dist/modules/credentials.d.ts.map +1 -0
- package/dist/modules/credentials.js +135 -0
- package/dist/modules/crons.d.ts +73 -0
- package/dist/modules/crons.d.ts.map +1 -0
- package/dist/modules/crons.js +67 -0
- package/dist/modules/datasets.d.ts +80 -0
- package/dist/modules/datasets.d.ts.map +1 -0
- package/dist/modules/datasets.js +91 -0
- package/{src/modules/evaluation.ts → dist/modules/evaluation.d.ts} +23 -109
- package/dist/modules/evaluation.d.ts.map +1 -0
- package/dist/modules/evaluation.js +108 -0
- package/dist/modules/files.d.ts +89 -0
- package/dist/modules/files.d.ts.map +1 -0
- package/dist/modules/files.js +133 -0
- package/dist/modules/graphs.d.ts +120 -0
- package/dist/modules/graphs.d.ts.map +1 -0
- package/dist/modules/graphs.js +69 -0
- package/{src/modules/improvements.ts → dist/modules/improvements.d.ts} +8 -27
- package/dist/modules/improvements.d.ts.map +1 -0
- package/dist/modules/improvements.js +27 -0
- package/dist/modules/info.d.ts +76 -0
- package/dist/modules/info.d.ts.map +1 -0
- package/{src/modules/info.ts → dist/modules/info.js} +16 -66
- package/dist/modules/knowledge.d.ts +91 -0
- package/dist/modules/knowledge.d.ts.map +1 -0
- package/dist/modules/knowledge.js +80 -0
- package/{src/modules/me.ts → dist/modules/me.d.ts} +7 -23
- package/dist/modules/me.d.ts.map +1 -0
- package/dist/modules/me.js +28 -0
- package/dist/modules/members.d.ts +124 -0
- package/dist/modules/members.d.ts.map +1 -0
- package/dist/modules/members.js +142 -0
- package/dist/modules/memberships.d.ts +25 -0
- package/dist/modules/memberships.d.ts.map +1 -0
- package/dist/modules/memberships.js +20 -0
- package/{src/modules/metaAgent.ts → dist/modules/metaAgent.d.ts} +8 -44
- package/dist/modules/metaAgent.d.ts.map +1 -0
- package/dist/modules/metaAgent.js +32 -0
- package/dist/modules/metrics.d.ts +20 -0
- package/dist/modules/metrics.d.ts.map +1 -0
- package/{src/modules/metrics.ts → dist/modules/metrics.js} +7 -14
- package/dist/modules/observability.d.ts +19 -0
- package/dist/modules/observability.d.ts.map +1 -0
- package/dist/modules/observability.js +14 -0
- package/dist/modules/playground.d.ts +42 -0
- package/dist/modules/playground.d.ts.map +1 -0
- package/dist/modules/playground.js +48 -0
- package/dist/modules/presets.d.ts +32 -0
- package/dist/modules/presets.d.ts.map +1 -0
- package/dist/modules/presets.js +199 -0
- package/dist/modules/prompts.d.ts +87 -0
- package/dist/modules/prompts.d.ts.map +1 -0
- package/dist/modules/prompts.js +87 -0
- package/dist/modules/roles.d.ts +64 -0
- package/dist/modules/roles.d.ts.map +1 -0
- package/dist/modules/roles.js +79 -0
- package/dist/modules/runs.d.ts +451 -0
- package/dist/modules/runs.d.ts.map +1 -0
- package/{src/modules/runs.ts → dist/modules/runs.js} +96 -438
- package/dist/modules/store.d.ts +37 -0
- package/dist/modules/store.d.ts.map +1 -0
- package/dist/modules/store.js +48 -0
- package/{src/modules/templates.ts → dist/modules/templates.d.ts} +8 -32
- package/dist/modules/templates.d.ts.map +1 -0
- package/dist/modules/templates.js +26 -0
- package/dist/modules/tenants.d.ts +49 -0
- package/dist/modules/tenants.d.ts.map +1 -0
- package/dist/modules/tenants.js +56 -0
- package/dist/modules/threads.d.ts +205 -0
- package/dist/modules/threads.d.ts.map +1 -0
- package/dist/modules/threads.js +225 -0
- package/dist/modules/tools.d.ts +62 -0
- package/dist/modules/tools.d.ts.map +1 -0
- package/dist/modules/tools.js +45 -0
- package/dist/modules/traces.d.ts +89 -0
- package/dist/modules/traces.d.ts.map +1 -0
- package/dist/modules/traces.js +65 -0
- package/{src/modules/triggers.ts → dist/modules/triggers.d.ts} +24 -153
- package/dist/modules/triggers.d.ts.map +1 -0
- package/dist/modules/triggers.js +176 -0
- package/{src/modules/usage.ts → dist/modules/usage.d.ts} +14 -46
- package/dist/modules/usage.d.ts.map +1 -0
- package/dist/modules/usage.js +43 -0
- package/dist/modules/vectorStores.d.ts +100 -0
- package/dist/modules/vectorStores.d.ts.map +1 -0
- package/dist/modules/vectorStores.js +159 -0
- package/dist/modules/workspaces.d.ts +138 -0
- package/dist/modules/workspaces.d.ts.map +1 -0
- package/dist/modules/workspaces.js +121 -0
- package/dist/sse/client.d.ts +140 -0
- package/dist/sse/client.d.ts.map +1 -0
- package/{src/sse/client.ts → dist/sse/client.js} +24 -100
- package/package.json +8 -15
- package/src/client/raw.ts +0 -609
- package/src/generated/swagger.json +0 -17014
- package/src/modules/a2a.ts +0 -64
- package/src/modules/agents.ts +0 -604
- package/src/modules/apiTokens.ts +0 -101
- package/src/modules/approvals.ts +0 -151
- package/src/modules/catalog.ts +0 -241
- package/src/modules/chatwoot.ts +0 -242
- package/src/modules/checkpoints.ts +0 -87
- package/src/modules/contracts.ts +0 -80
- package/src/modules/credentials.ts +0 -216
- package/src/modules/crons.ts +0 -115
- package/src/modules/datasets.ts +0 -142
- package/src/modules/files.ts +0 -208
- package/src/modules/members.ts +0 -199
- package/src/modules/memberships.ts +0 -42
- package/src/modules/observability.ts +0 -28
- package/src/modules/playground.ts +0 -68
- package/src/modules/presets.ts +0 -246
- package/src/modules/prompts.ts +0 -147
- package/src/modules/roles.ts +0 -112
- package/src/modules/store.ts +0 -65
- package/src/modules/tenants.ts +0 -79
- package/src/modules/threads.ts +0 -343
- package/src/modules/tools.ts +0 -91
- package/src/modules/traces.ts +0 -133
- package/src/modules/vectorStores.ts +0 -257
- 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
|
-
}
|