@agent-os-sdk/client 0.9.9 → 0.9.11
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 +2 -0
- package/dist/client/AgentOsClient.d.ts.map +1 -1
- package/dist/client/AgentOsClient.js +4 -0
- package/dist/client/HttpRequestBuilder.d.ts +1 -0
- package/dist/client/HttpRequestBuilder.d.ts.map +1 -1
- package/dist/client/HttpRequestBuilder.js +6 -2
- package/dist/client/auth.d.ts +4 -0
- package/dist/client/auth.d.ts.map +1 -1
- package/dist/client/raw.d.ts +13 -0
- package/dist/client/raw.d.ts.map +1 -1
- package/dist/client/raw.js +68 -4
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/modules/agents.d.ts +29 -0
- package/dist/modules/agents.d.ts.map +1 -1
- package/dist/modules/agents.js +23 -0
- package/dist/modules/builder.d.ts +0 -4
- package/dist/modules/builder.d.ts.map +1 -1
- package/dist/modules/files.d.ts +34 -13
- package/dist/modules/files.d.ts.map +1 -1
- package/dist/modules/files.js +86 -19
- package/dist/modules/graphs.d.ts +1 -1
- package/dist/modules/graphs.d.ts.map +1 -1
- package/dist/modules/members.d.ts +0 -6
- package/dist/modules/members.d.ts.map +1 -1
- package/dist/modules/members.js +0 -6
- 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/runs.d.ts +2 -0
- package/dist/modules/runs.d.ts.map +1 -1
- package/dist/modules/runs.js +2 -2
- package/dist/modules/threads.js +2 -2
- package/dist/modules/vectorStores.d.ts +6 -3
- package/dist/modules/vectorStores.d.ts.map +1 -1
- package/dist/modules/vectorStores.js +86 -14
- package/dist/modules/workspaces.d.ts +35 -0
- package/dist/modules/workspaces.d.ts.map +1 -1
- package/dist/modules/workspaces.js +41 -0
- package/package.json +50 -51
- package/src/client/AgentOsClient.ts +4 -0
- package/src/client/HttpRequestBuilder.ts +7 -2
- package/src/client/auth.ts +4 -0
- package/src/client/raw.ts +93 -5
- package/src/index.ts +1 -0
- package/src/modules/agents.ts +52 -0
- package/src/modules/builder.ts +0 -7
- package/src/modules/files.ts +125 -29
- package/src/modules/graphs.ts +1 -1
- package/src/modules/members.ts +0 -7
- package/src/modules/observability.ts +28 -0
- package/src/modules/runs.ts +4 -2
- package/src/modules/threads.ts +2 -2
- package/src/modules/vectorStores.ts +115 -18
- package/src/modules/workspaces.ts +64 -0
- package/dist/modules/dlq.d.ts +0 -81
- package/dist/modules/dlq.d.ts.map +0 -1
- package/dist/modules/dlq.js +0 -66
- package/dist/modules/mcp.d.ts +0 -39
- package/dist/modules/mcp.d.ts.map +0 -1
- package/dist/modules/mcp.js +0 -38
package/src/modules/files.ts
CHANGED
|
@@ -4,21 +4,23 @@
|
|
|
4
4
|
|
|
5
5
|
import type { RawClient, APIResponse, components } from "../client/raw.js";
|
|
6
6
|
|
|
7
|
+
type FileListItem = components["schemas"]["FileListItem"];
|
|
8
|
+
type FileDetail = components["schemas"]["FileDetail"];
|
|
7
9
|
type CreatePresignedUploadRequest = components["schemas"]["CreatePresignedUploadRequest"];
|
|
8
10
|
type PresignedUploadResponse = components["schemas"]["PresignedUploadResponse"];
|
|
9
11
|
type ConfirmUploadRequest = components["schemas"]["ConfirmUploadRequest"];
|
|
12
|
+
type FileConfirmResponse = components["schemas"]["FileConfirmResponse"];
|
|
13
|
+
type PresignedDownloadResponse = components["schemas"]["PresignedDownloadResponse"];
|
|
10
14
|
|
|
11
15
|
export interface StoredFile {
|
|
12
16
|
id: string;
|
|
13
17
|
filename: string;
|
|
14
18
|
content_type: string;
|
|
15
19
|
size_bytes: number;
|
|
16
|
-
sha256
|
|
17
|
-
storage_uri: string;
|
|
18
|
-
workspace_id: string;
|
|
19
|
-
uploaded_by?: string;
|
|
20
|
+
sha256?: string;
|
|
20
21
|
status: "pending" | "confirmed" | "deleted";
|
|
21
22
|
created_at: string;
|
|
23
|
+
updated_at?: string;
|
|
22
24
|
}
|
|
23
25
|
|
|
24
26
|
export interface FileListResponse {
|
|
@@ -29,39 +31,109 @@ export interface FileListResponse {
|
|
|
29
31
|
export interface PresignedUpload {
|
|
30
32
|
file_id: string;
|
|
31
33
|
upload_url: string;
|
|
32
|
-
|
|
34
|
+
expires_in: number;
|
|
35
|
+
object_key: string;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface ConfirmedUpload {
|
|
39
|
+
file_id: string;
|
|
40
|
+
status: string;
|
|
41
|
+
size_bytes: number;
|
|
42
|
+
sha256?: string;
|
|
33
43
|
}
|
|
34
44
|
|
|
35
45
|
export interface PresignedDownload {
|
|
46
|
+
file_id: string;
|
|
36
47
|
download_url: string;
|
|
37
|
-
|
|
48
|
+
filename: string;
|
|
49
|
+
content_type: string;
|
|
50
|
+
size_bytes: number;
|
|
51
|
+
expires_in: number;
|
|
38
52
|
}
|
|
39
53
|
|
|
40
54
|
export class FilesModule {
|
|
41
55
|
constructor(private client: RawClient, private headers: () => Record<string, string>) { }
|
|
42
56
|
|
|
57
|
+
private resolveWorkspaceId(workspaceId?: string): string {
|
|
58
|
+
if (workspaceId && workspaceId.trim().length > 0) {
|
|
59
|
+
return workspaceId.trim();
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const headers = this.headers();
|
|
63
|
+
const fromHeader = headers["X-Workspace-Id"] ?? headers["x-workspace-id"];
|
|
64
|
+
if (fromHeader && fromHeader.trim().length > 0) {
|
|
65
|
+
return fromHeader.trim();
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
throw new Error("workspace_id is required (pass workspaceId or set X-Workspace-Id in client headers)");
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
private static toStoredFile(item: FileListItem | FileDetail): StoredFile {
|
|
72
|
+
return {
|
|
73
|
+
id: item.id ?? "",
|
|
74
|
+
filename: item.filename ?? "",
|
|
75
|
+
content_type: item.content_type ?? "application/octet-stream",
|
|
76
|
+
size_bytes: item.size_bytes ?? 0,
|
|
77
|
+
sha256: "sha256" in item ? item.sha256 ?? undefined : undefined,
|
|
78
|
+
status: (item.status ?? "pending") as StoredFile["status"],
|
|
79
|
+
created_at: item.created_at ?? "",
|
|
80
|
+
updated_at: "updated_at" in item ? item.updated_at ?? undefined : undefined,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
|
|
43
84
|
/**
|
|
44
|
-
* List
|
|
85
|
+
* List files in a workspace.
|
|
45
86
|
*/
|
|
46
87
|
async list(params?: {
|
|
47
88
|
workspace_id?: string;
|
|
89
|
+
status?: string;
|
|
48
90
|
limit?: number;
|
|
49
91
|
offset?: number;
|
|
50
92
|
}): Promise<APIResponse<FileListResponse>> {
|
|
51
|
-
|
|
52
|
-
|
|
93
|
+
const workspaceId = this.resolveWorkspaceId(params?.workspace_id);
|
|
94
|
+
const response = await this.client.GET<FileListItem[]>("/v1/api/workspaces/{workspaceId}/files", {
|
|
95
|
+
params: {
|
|
96
|
+
path: { workspaceId },
|
|
97
|
+
query: {
|
|
98
|
+
status: params?.status,
|
|
99
|
+
limit: params?.limit,
|
|
100
|
+
offset: params?.offset,
|
|
101
|
+
},
|
|
102
|
+
},
|
|
53
103
|
headers: this.headers(),
|
|
54
104
|
});
|
|
105
|
+
|
|
106
|
+
const items = Array.isArray(response.data)
|
|
107
|
+
? response.data.map((item) => FilesModule.toStoredFile(item))
|
|
108
|
+
: [];
|
|
109
|
+
|
|
110
|
+
return {
|
|
111
|
+
...response,
|
|
112
|
+
data: {
|
|
113
|
+
items,
|
|
114
|
+
total: items.length,
|
|
115
|
+
},
|
|
116
|
+
};
|
|
55
117
|
}
|
|
56
118
|
|
|
57
119
|
/**
|
|
58
120
|
* Get a file by ID.
|
|
59
121
|
*/
|
|
60
|
-
async get(fileId: string): Promise<APIResponse<StoredFile>> {
|
|
61
|
-
|
|
62
|
-
|
|
122
|
+
async get(fileId: string, workspaceId?: string): Promise<APIResponse<StoredFile>> {
|
|
123
|
+
const resolvedWorkspaceId = this.resolveWorkspaceId(workspaceId);
|
|
124
|
+
const response = await this.client.GET<FileDetail>("/v1/api/workspaces/{workspaceId}/files/{fileId}", {
|
|
125
|
+
params: { path: { workspaceId: resolvedWorkspaceId, fileId } },
|
|
63
126
|
headers: this.headers(),
|
|
64
127
|
});
|
|
128
|
+
|
|
129
|
+
if (!response.data) {
|
|
130
|
+
return response as APIResponse<StoredFile>;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
return {
|
|
134
|
+
...response,
|
|
135
|
+
data: FilesModule.toStoredFile(response.data),
|
|
136
|
+
};
|
|
65
137
|
}
|
|
66
138
|
|
|
67
139
|
/**
|
|
@@ -69,44 +141,68 @@ export class FilesModule {
|
|
|
69
141
|
*/
|
|
70
142
|
async createUpload(body: {
|
|
71
143
|
filename: string;
|
|
72
|
-
content_type
|
|
144
|
+
content_type?: string;
|
|
73
145
|
size_bytes?: number;
|
|
74
146
|
expected_sha256?: string;
|
|
75
|
-
}): Promise<APIResponse<PresignedUpload>> {
|
|
76
|
-
|
|
77
|
-
|
|
147
|
+
}, workspaceId?: string): Promise<APIResponse<PresignedUpload>> {
|
|
148
|
+
const resolvedWorkspaceId = this.resolveWorkspaceId(workspaceId);
|
|
149
|
+
const requestBody: CreatePresignedUploadRequest = {
|
|
150
|
+
filename: body.filename,
|
|
151
|
+
content_type: body.content_type,
|
|
152
|
+
size_bytes: body.size_bytes,
|
|
153
|
+
expected_sha256: body.expected_sha256,
|
|
154
|
+
};
|
|
155
|
+
return this.client.POST<PresignedUploadResponse>("/v1/api/workspaces/{workspaceId}/files/presign", {
|
|
156
|
+
params: { path: { workspaceId: resolvedWorkspaceId } },
|
|
157
|
+
body: requestBody,
|
|
78
158
|
headers: this.headers(),
|
|
79
|
-
})
|
|
159
|
+
}) as Promise<APIResponse<PresignedUpload>>;
|
|
80
160
|
}
|
|
81
161
|
|
|
82
162
|
/**
|
|
83
163
|
* Confirm an upload.
|
|
84
164
|
*/
|
|
85
|
-
async confirmUpload(fileId: string, sha256
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
165
|
+
async confirmUpload(fileId: string, sha256?: string, workspaceId?: string): Promise<APIResponse<ConfirmedUpload>> {
|
|
166
|
+
const resolvedWorkspaceId = this.resolveWorkspaceId(workspaceId);
|
|
167
|
+
const requestBody: ConfirmUploadRequest = { sha256 };
|
|
168
|
+
return this.client.POST<FileConfirmResponse>("/v1/api/workspaces/{workspaceId}/files/{fileId}/confirm", {
|
|
169
|
+
params: { path: { workspaceId: resolvedWorkspaceId, fileId } },
|
|
170
|
+
body: requestBody,
|
|
89
171
|
headers: this.headers(),
|
|
90
|
-
})
|
|
172
|
+
}) as Promise<APIResponse<ConfirmedUpload>>;
|
|
91
173
|
}
|
|
92
174
|
|
|
93
175
|
/**
|
|
94
176
|
* Get a presigned download URL.
|
|
95
177
|
*/
|
|
96
|
-
async getDownloadUrl(fileId: string): Promise<APIResponse<PresignedDownload>> {
|
|
97
|
-
|
|
98
|
-
|
|
178
|
+
async getDownloadUrl(fileId: string, workspaceId?: string): Promise<APIResponse<PresignedDownload>> {
|
|
179
|
+
const resolvedWorkspaceId = this.resolveWorkspaceId(workspaceId);
|
|
180
|
+
return this.client.GET<PresignedDownloadResponse>("/v1/api/workspaces/{workspaceId}/files/{fileId}/download", {
|
|
181
|
+
params: { path: { workspaceId: resolvedWorkspaceId, fileId } },
|
|
99
182
|
headers: this.headers(),
|
|
100
|
-
})
|
|
183
|
+
}) as Promise<APIResponse<PresignedDownload>>;
|
|
101
184
|
}
|
|
102
185
|
|
|
103
186
|
/**
|
|
104
187
|
* Delete a file.
|
|
105
188
|
*/
|
|
106
|
-
async delete(fileId: string): Promise<APIResponse<void>> {
|
|
107
|
-
|
|
108
|
-
|
|
189
|
+
async delete(fileId: string, workspaceId?: string): Promise<APIResponse<void>> {
|
|
190
|
+
const resolvedWorkspaceId = this.resolveWorkspaceId(workspaceId);
|
|
191
|
+
return this.client.DELETE<void>("/v1/api/workspaces/{workspaceId}/files/{fileId}", {
|
|
192
|
+
params: { path: { workspaceId: resolvedWorkspaceId, fileId } },
|
|
109
193
|
headers: this.headers(),
|
|
110
194
|
});
|
|
111
195
|
}
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* Alias for createUpload with explicit semantic name.
|
|
199
|
+
*/
|
|
200
|
+
async createPresignedUpload(body: {
|
|
201
|
+
filename: string;
|
|
202
|
+
content_type?: string;
|
|
203
|
+
size_bytes?: number;
|
|
204
|
+
expected_sha256?: string;
|
|
205
|
+
}, workspaceId?: string): Promise<APIResponse<PresignedUpload>> {
|
|
206
|
+
return this.createUpload(body, workspaceId);
|
|
207
|
+
}
|
|
112
208
|
}
|
package/src/modules/graphs.ts
CHANGED
package/src/modules/members.ts
CHANGED
|
@@ -159,7 +159,6 @@ export class MembersModule {
|
|
|
159
159
|
|
|
160
160
|
/**
|
|
161
161
|
* Remove a member from the tenant.
|
|
162
|
-
* Note: Use delete() - remove() is provided as alias for backwards compatibility.
|
|
163
162
|
*/
|
|
164
163
|
async delete(memberId: string): Promise<APIResponse<void>> {
|
|
165
164
|
return this.client.DELETE<void>("/v1/api/members/{id}", {
|
|
@@ -168,12 +167,6 @@ export class MembersModule {
|
|
|
168
167
|
});
|
|
169
168
|
}
|
|
170
169
|
|
|
171
|
-
/**
|
|
172
|
-
* Alias for delete() (backwards compatibility)
|
|
173
|
-
* @deprecated Use delete() instead
|
|
174
|
-
*/
|
|
175
|
-
remove = (memberId: string) => this.delete(memberId);
|
|
176
|
-
|
|
177
170
|
/**
|
|
178
171
|
* Resend invitation email.
|
|
179
172
|
*/
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { APIResponse, RawClient } from "../client/raw.js";
|
|
2
|
+
|
|
3
|
+
export type FrontendLogLevel = "DEBUG" | "INFO" | "WARN" | "ERROR";
|
|
4
|
+
|
|
5
|
+
export interface FrontendLogPayload {
|
|
6
|
+
level: FrontendLogLevel;
|
|
7
|
+
message: string;
|
|
8
|
+
stack?: string;
|
|
9
|
+
route?: string;
|
|
10
|
+
url?: string;
|
|
11
|
+
user_agent?: string;
|
|
12
|
+
session_id?: string;
|
|
13
|
+
context?: Record<string, unknown>;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export class ObservabilityModule {
|
|
17
|
+
constructor(
|
|
18
|
+
private client: RawClient,
|
|
19
|
+
private headers: () => Record<string, string>
|
|
20
|
+
) { }
|
|
21
|
+
|
|
22
|
+
async logFrontend(payload: FrontendLogPayload): Promise<APIResponse<Record<string, unknown>>> {
|
|
23
|
+
return this.client.POST<Record<string, unknown>>("/v1/api/observability/frontend-log", {
|
|
24
|
+
body: payload,
|
|
25
|
+
headers: this.headers(),
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
}
|
package/src/modules/runs.ts
CHANGED
|
@@ -110,13 +110,15 @@ export class RunsModule {
|
|
|
110
110
|
agent_id: string;
|
|
111
111
|
thread?: { thread_id?: string } | { new_thread: true };
|
|
112
112
|
input?: unknown;
|
|
113
|
+
/** Optional bundle pinning (draft/published). When omitted, backend resolves live bundle. */
|
|
114
|
+
bundle_id?: string;
|
|
113
115
|
/** Idempotency key for safe retries. When set, duplicate requests with the same key return the original response. */
|
|
114
116
|
idempotency_key?: string;
|
|
115
117
|
}): Promise<APIResponse<CreateRunResponse>> {
|
|
116
|
-
// Send Idempotency-Key
|
|
118
|
+
// Send canonical X-Idempotency-Key header + body idempotency_key for backend contract parity.
|
|
117
119
|
const headers: Record<string, string> = {};
|
|
118
120
|
if (body.idempotency_key) {
|
|
119
|
-
headers["Idempotency-Key"] = body.idempotency_key;
|
|
121
|
+
headers["X-Idempotency-Key"] = body.idempotency_key;
|
|
120
122
|
}
|
|
121
123
|
|
|
122
124
|
return this.client.POST<CreateRunResponse>("/v1/api/runs", {
|
package/src/modules/threads.ts
CHANGED
|
@@ -93,10 +93,10 @@ export class ThreadsModule {
|
|
|
93
93
|
/** Idempotency key for safe retries. When set, duplicate requests with the same key return the original response. */
|
|
94
94
|
idempotency_key?: string;
|
|
95
95
|
}): Promise<APIResponse<Thread>> {
|
|
96
|
-
// Send Idempotency-Key
|
|
96
|
+
// Send canonical X-Idempotency-Key header + body idempotency_key for backend contract parity.
|
|
97
97
|
const headers: Record<string, string> = { ...this.headers() };
|
|
98
98
|
if (body?.idempotency_key) {
|
|
99
|
-
headers["Idempotency-Key"] = body.idempotency_key;
|
|
99
|
+
headers["X-Idempotency-Key"] = body.idempotency_key;
|
|
100
100
|
}
|
|
101
101
|
|
|
102
102
|
return this.client.POST<Thread>("/v1/api/threads", {
|
|
@@ -11,7 +11,6 @@ type VectorStoreFileResponse = components["schemas"]["VectorStoreFileResponse"];
|
|
|
11
11
|
export interface VectorStore {
|
|
12
12
|
id: string;
|
|
13
13
|
name: string;
|
|
14
|
-
workspace_id: string;
|
|
15
14
|
embedding_provider: string;
|
|
16
15
|
embedding_model: string;
|
|
17
16
|
dimension: number;
|
|
@@ -52,6 +51,42 @@ export interface VectorStoreFilesResponse {
|
|
|
52
51
|
total: number;
|
|
53
52
|
}
|
|
54
53
|
|
|
54
|
+
type VectorStoreLike = VectorStoreResponse & {
|
|
55
|
+
embeddingProvider?: string;
|
|
56
|
+
embeddingModel?: string;
|
|
57
|
+
credentialBindingAlias?: 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_alias: item.credential_binding_alias ?? item.credentialBindingAlias ?? 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
|
+
|
|
55
90
|
export class VectorStoresModule {
|
|
56
91
|
constructor(private client: RawClient, private headers: () => Record<string, string>) { }
|
|
57
92
|
|
|
@@ -63,20 +98,41 @@ export class VectorStoresModule {
|
|
|
63
98
|
limit?: number;
|
|
64
99
|
offset?: number;
|
|
65
100
|
}): Promise<APIResponse<VectorStoreListResponse>> {
|
|
66
|
-
|
|
101
|
+
const response = await this.client.GET<VectorStoreResponse[]>("/v1/api/vector-stores", {
|
|
67
102
|
params: { query: params },
|
|
68
103
|
headers: this.headers(),
|
|
69
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
|
+
};
|
|
70
117
|
}
|
|
71
118
|
|
|
72
119
|
/**
|
|
73
120
|
* Get a vector store by ID.
|
|
74
121
|
*/
|
|
75
122
|
async get(storeId: string): Promise<APIResponse<VectorStore>> {
|
|
76
|
-
|
|
77
|
-
params: { path: {
|
|
123
|
+
const response = await this.client.GET<VectorStoreResponse>("/v1/api/vector-stores/{vectorStoreId}", {
|
|
124
|
+
params: { path: { vectorStoreId: storeId } },
|
|
78
125
|
headers: this.headers(),
|
|
79
126
|
});
|
|
127
|
+
|
|
128
|
+
if (!response.data) {
|
|
129
|
+
return response as APIResponse<VectorStore>;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
return {
|
|
133
|
+
...response,
|
|
134
|
+
data: toVectorStore(response.data),
|
|
135
|
+
};
|
|
80
136
|
}
|
|
81
137
|
|
|
82
138
|
/**
|
|
@@ -89,18 +145,27 @@ export class VectorStoresModule {
|
|
|
89
145
|
dimension?: number;
|
|
90
146
|
credential_binding_alias?: string;
|
|
91
147
|
}): Promise<APIResponse<VectorStore>> {
|
|
92
|
-
|
|
148
|
+
const response = await this.client.POST<VectorStoreResponse>("/v1/api/vector-stores", {
|
|
93
149
|
body,
|
|
94
150
|
headers: this.headers(),
|
|
95
151
|
});
|
|
152
|
+
|
|
153
|
+
if (!response.data) {
|
|
154
|
+
return response as APIResponse<VectorStore>;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
return {
|
|
158
|
+
...response,
|
|
159
|
+
data: toVectorStore(response.data),
|
|
160
|
+
};
|
|
96
161
|
}
|
|
97
162
|
|
|
98
163
|
/**
|
|
99
164
|
* Delete a vector store.
|
|
100
165
|
*/
|
|
101
166
|
async delete(storeId: string): Promise<APIResponse<void>> {
|
|
102
|
-
return this.client.DELETE<void>("/v1/api/vector-stores/{
|
|
103
|
-
params: { path: {
|
|
167
|
+
return this.client.DELETE<void>("/v1/api/vector-stores/{vectorStoreId}", {
|
|
168
|
+
params: { path: { vectorStoreId: storeId } },
|
|
104
169
|
headers: this.headers(),
|
|
105
170
|
});
|
|
106
171
|
}
|
|
@@ -115,11 +180,11 @@ export class VectorStoresModule {
|
|
|
115
180
|
top_k?: number;
|
|
116
181
|
min_score?: number;
|
|
117
182
|
}): Promise<APIResponse<VectorQueryResult>> {
|
|
118
|
-
return this.client.POST<
|
|
119
|
-
params: { path: {
|
|
183
|
+
return this.client.POST<VectorQueryResponse>("/v1/api/vector-stores/{vectorStoreId}/query", {
|
|
184
|
+
params: { path: { vectorStoreId: storeId } },
|
|
120
185
|
body,
|
|
121
186
|
headers: this.headers(),
|
|
122
|
-
})
|
|
187
|
+
}) as Promise<APIResponse<VectorQueryResult>>;
|
|
123
188
|
}
|
|
124
189
|
|
|
125
190
|
// ======================== Files ========================
|
|
@@ -128,32 +193,64 @@ export class VectorStoresModule {
|
|
|
128
193
|
* List files in a vector store.
|
|
129
194
|
*/
|
|
130
195
|
async listFiles(storeId: string, params?: {
|
|
131
|
-
|
|
132
|
-
|
|
196
|
+
skip?: number;
|
|
197
|
+
take?: number;
|
|
133
198
|
}): Promise<APIResponse<VectorStoreFilesResponse>> {
|
|
134
|
-
|
|
135
|
-
params: { path: {
|
|
199
|
+
const response = await this.client.GET<VectorStoreFileResponse[]>("/v1/api/vector-stores/{vectorStoreId}/files", {
|
|
200
|
+
params: { path: { vectorStoreId: storeId }, query: params },
|
|
136
201
|
headers: this.headers(),
|
|
137
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
|
+
};
|
|
138
215
|
}
|
|
139
216
|
|
|
140
217
|
/**
|
|
141
218
|
* Attach a file to a vector store.
|
|
142
219
|
*/
|
|
143
220
|
async attachFile(storeId: string, fileId: string): Promise<APIResponse<VectorStoreFile>> {
|
|
144
|
-
|
|
145
|
-
params: { path: {
|
|
221
|
+
const response = await this.client.POST<VectorStoreFileResponse>("/v1/api/vector-stores/{vectorStoreId}/files", {
|
|
222
|
+
params: { path: { vectorStoreId: storeId } },
|
|
146
223
|
body: { file_id: fileId },
|
|
147
224
|
headers: this.headers(),
|
|
148
225
|
});
|
|
226
|
+
|
|
227
|
+
if (!response.data) {
|
|
228
|
+
return response as APIResponse<VectorStoreFile>;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
return {
|
|
232
|
+
...response,
|
|
233
|
+
data: toVectorStoreFile(response.data),
|
|
234
|
+
};
|
|
149
235
|
}
|
|
150
236
|
|
|
151
237
|
/**
|
|
152
238
|
* Remove a file from a vector store.
|
|
153
239
|
*/
|
|
154
240
|
async removeFile(storeId: string, fileId: string): Promise<APIResponse<void>> {
|
|
155
|
-
return this.client.DELETE<void>("/v1/api/vector-stores/{
|
|
156
|
-
params: { path: {
|
|
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 },
|
|
157
254
|
headers: this.headers(),
|
|
158
255
|
});
|
|
159
256
|
}
|
|
@@ -3,9 +3,29 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
import type { RawClient, APIResponse, components } from "../client/raw.js";
|
|
6
|
+
import { parseSSE } from "../sse/client.js";
|
|
6
7
|
|
|
7
8
|
type UpdateWorkspaceRequest = components["schemas"]["UpdateWorkspaceRequest"];
|
|
8
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
|
+
|
|
9
29
|
export interface Workspace {
|
|
10
30
|
id: string;
|
|
11
31
|
tenant_id: string;
|
|
@@ -106,6 +126,50 @@ export class WorkspacesModule {
|
|
|
106
126
|
headers: this.headers(),
|
|
107
127
|
});
|
|
108
128
|
}
|
|
129
|
+
|
|
130
|
+
// ======================== FOLLOW (Workspace SSE) ========================
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Stream events for a specific workspace via SSE.
|
|
134
|
+
* Server validates ACL: caller must have access to the workspace.
|
|
135
|
+
*
|
|
136
|
+
* @param workspaceId - Workspace to stream events for
|
|
137
|
+
* @param options - AbortSignal for cleanup (MUST be used to avoid leaking connections)
|
|
138
|
+
*
|
|
139
|
+
* @example
|
|
140
|
+
* ```ts
|
|
141
|
+
* const controller = new AbortController();
|
|
142
|
+
* for await (const event of client.workspaces.followEvents(workspaceId, { signal: controller.signal })) {
|
|
143
|
+
* if (event.type === 'run_status_changed') {
|
|
144
|
+
* console.log(`Run ${event.run_id} → ${event.new_status}`);
|
|
145
|
+
* }
|
|
146
|
+
* }
|
|
147
|
+
* // On cleanup:
|
|
148
|
+
* controller.abort();
|
|
149
|
+
* ```
|
|
150
|
+
*/
|
|
151
|
+
async *followEvents(workspaceId: string, options?: WorkspaceFollowOptions): AsyncGenerator<WorkspaceEvent, void, unknown> {
|
|
152
|
+
const response = await this.client.streamGet(
|
|
153
|
+
"/v1/api/workspaces/{workspaceId}/events/stream",
|
|
154
|
+
{
|
|
155
|
+
params: { path: { workspaceId } },
|
|
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
|
+
if (options?.signal?.aborted) return;
|
|
170
|
+
throw err;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
109
173
|
}
|
|
110
174
|
|
|
111
175
|
export interface WorkspaceQuotaResponse {
|