@vertesia/client 0.80.0-dev.20251121 → 0.80.0
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/README.md +110 -0
- package/lib/cjs/InteractionsApi.js +12 -0
- package/lib/cjs/InteractionsApi.js.map +1 -1
- package/lib/cjs/SkillsApi.js +39 -0
- package/lib/cjs/SkillsApi.js.map +1 -0
- package/lib/cjs/client.js +5 -6
- package/lib/cjs/client.js.map +1 -1
- package/lib/cjs/store/FilesApi.js +78 -1
- package/lib/cjs/store/FilesApi.js.map +1 -1
- package/lib/cjs/store/ObjectsApi.js +1 -0
- package/lib/cjs/store/ObjectsApi.js.map +1 -1
- package/lib/cjs/store/index.js +1 -0
- package/lib/cjs/store/index.js.map +1 -1
- package/lib/esm/InteractionsApi.js +12 -0
- package/lib/esm/InteractionsApi.js.map +1 -1
- package/lib/esm/SkillsApi.js +36 -0
- package/lib/esm/SkillsApi.js.map +1 -0
- package/lib/esm/client.js +5 -6
- package/lib/esm/client.js.map +1 -1
- package/lib/esm/store/FilesApi.js +76 -0
- package/lib/esm/store/FilesApi.js.map +1 -1
- package/lib/esm/store/ObjectsApi.js +1 -0
- package/lib/esm/store/ObjectsApi.js.map +1 -1
- package/lib/esm/store/index.js +1 -0
- package/lib/esm/store/index.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/types/InteractionsApi.d.ts +7 -1
- package/lib/types/InteractionsApi.d.ts.map +1 -1
- package/lib/types/SkillsApi.d.ts +26 -0
- package/lib/types/SkillsApi.d.ts.map +1 -0
- package/lib/types/client.d.ts +3 -1
- package/lib/types/client.d.ts.map +1 -1
- package/lib/types/store/FilesApi.d.ts +55 -0
- package/lib/types/store/FilesApi.d.ts.map +1 -1
- package/lib/types/store/ObjectsApi.d.ts.map +1 -1
- package/lib/types/store/index.d.ts +1 -0
- package/lib/types/store/index.d.ts.map +1 -1
- package/lib/vertesia-client.js +1 -1
- package/lib/vertesia-client.js.map +1 -1
- package/package.json +13 -4
- package/src/InteractionsApi.ts +14 -1
- package/src/SkillsApi.ts +46 -0
- package/src/client.ts +5 -6
- package/src/store/FilesApi.ts +93 -0
- package/src/store/ObjectsApi.ts +1 -0
- package/src/store/index.ts +1 -0
package/src/store/FilesApi.ts
CHANGED
|
@@ -3,16 +3,27 @@ import {
|
|
|
3
3
|
GetFileUrlPayload,
|
|
4
4
|
GetFileUrlResponse,
|
|
5
5
|
GetUploadUrlPayload,
|
|
6
|
+
SetFileMetadataPayload,
|
|
6
7
|
} from "@vertesia/common";
|
|
7
8
|
import { StreamSource } from "../StreamSource.js";
|
|
8
9
|
|
|
9
10
|
export const MEMORIES_PREFIX = "memories";
|
|
11
|
+
export const ARTIFACTS_PREFIX = "agents";
|
|
10
12
|
|
|
11
13
|
export function getMemoryFilePath(name: string) {
|
|
12
14
|
const nameWithExt = name.endsWith(".tar.gz") ? name : name + ".tar.gz";
|
|
13
15
|
return `${MEMORIES_PREFIX}/${nameWithExt}`;
|
|
14
16
|
}
|
|
15
17
|
|
|
18
|
+
/**
|
|
19
|
+
* Build the storage path for an agent artifact
|
|
20
|
+
* @param runId - The workflow run ID
|
|
21
|
+
* @param name - The artifact filename
|
|
22
|
+
*/
|
|
23
|
+
export function getAgentArtifactPath(runId: string, name: string): string {
|
|
24
|
+
return `${ARTIFACTS_PREFIX}/${runId}/${name}`;
|
|
25
|
+
}
|
|
26
|
+
|
|
16
27
|
export class FilesApi extends ApiTopic {
|
|
17
28
|
constructor(parent: ClientBase) {
|
|
18
29
|
super(parent, "/api/v1/files");
|
|
@@ -36,6 +47,7 @@ export class FilesApi extends ApiTopic {
|
|
|
36
47
|
contentType: string;
|
|
37
48
|
contentDisposition?: string;
|
|
38
49
|
etag?: string;
|
|
50
|
+
customMetadata?: Record<string, string>;
|
|
39
51
|
}> {
|
|
40
52
|
return this.get("/metadata", {
|
|
41
53
|
query: {
|
|
@@ -44,6 +56,17 @@ export class FilesApi extends ApiTopic {
|
|
|
44
56
|
});
|
|
45
57
|
}
|
|
46
58
|
|
|
59
|
+
/**
|
|
60
|
+
* Set custom metadata on a file
|
|
61
|
+
* @param file - The file path or URI
|
|
62
|
+
* @param metadata - Custom metadata key-value pairs
|
|
63
|
+
* @returns Success status
|
|
64
|
+
*/
|
|
65
|
+
setFileMetadata(file: string, metadata: Record<string, string>): Promise<{ success: boolean; file: string }> {
|
|
66
|
+
const payload: SetFileMetadataPayload = { file, metadata };
|
|
67
|
+
return this.put("/metadata", { payload });
|
|
68
|
+
}
|
|
69
|
+
|
|
47
70
|
/**
|
|
48
71
|
* Get or create a bucket for the project. If the bucket already exists, it does nothing.
|
|
49
72
|
* The bucket URI is returned.
|
|
@@ -179,4 +202,74 @@ export class FilesApi extends ApiTopic {
|
|
|
179
202
|
}
|
|
180
203
|
return stream;
|
|
181
204
|
}
|
|
205
|
+
|
|
206
|
+
// ==================== Agent Artifact Methods ====================
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* List files by prefix
|
|
210
|
+
* @param prefix - Path prefix to filter files
|
|
211
|
+
* @returns Array of file paths matching the prefix
|
|
212
|
+
*/
|
|
213
|
+
listByPrefix(prefix: string): Promise<{ files: string[] }> {
|
|
214
|
+
return this.get("/list", { query: { prefix } });
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Upload an artifact for an agent run
|
|
219
|
+
* @param runId - The workflow run ID
|
|
220
|
+
* @param name - Artifact name (e.g., "output.json")
|
|
221
|
+
* @param source - File content source
|
|
222
|
+
* @returns The full path of the uploaded artifact
|
|
223
|
+
*/
|
|
224
|
+
async uploadArtifact(runId: string, name: string, source: StreamSource | File): Promise<string> {
|
|
225
|
+
const artifactPath = getAgentArtifactPath(runId, name);
|
|
226
|
+
if (source instanceof File) {
|
|
227
|
+
const file = source as File;
|
|
228
|
+
return this.uploadFile(
|
|
229
|
+
new StreamSource(file.stream(), name, file.type, artifactPath)
|
|
230
|
+
);
|
|
231
|
+
} else {
|
|
232
|
+
return this.uploadFile(
|
|
233
|
+
new StreamSource(source.stream, name, source.type, artifactPath)
|
|
234
|
+
);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* Download an artifact from an agent run
|
|
240
|
+
* @param runId - The workflow run ID
|
|
241
|
+
* @param name - Artifact name
|
|
242
|
+
* @returns ReadableStream of the artifact content
|
|
243
|
+
*/
|
|
244
|
+
async downloadArtifact(runId: string, name: string): Promise<ReadableStream<Uint8Array>> {
|
|
245
|
+
const artifactPath = getAgentArtifactPath(runId, name);
|
|
246
|
+
return this.downloadFile(artifactPath);
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* Get download URL for an artifact
|
|
251
|
+
* @param runId - The workflow run ID
|
|
252
|
+
* @param name - Artifact name
|
|
253
|
+
* @param disposition - Content disposition (inline or attachment)
|
|
254
|
+
* @returns Signed URL response
|
|
255
|
+
*/
|
|
256
|
+
getArtifactDownloadUrl(
|
|
257
|
+
runId: string,
|
|
258
|
+
name: string,
|
|
259
|
+
disposition?: "inline" | "attachment"
|
|
260
|
+
): Promise<GetFileUrlResponse> {
|
|
261
|
+
const artifactPath = getAgentArtifactPath(runId, name);
|
|
262
|
+
return this.getDownloadUrl(artifactPath, name, disposition);
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* List artifacts for an agent run
|
|
267
|
+
* @param runId - The workflow run ID
|
|
268
|
+
* @returns Array of artifact file paths
|
|
269
|
+
*/
|
|
270
|
+
async listArtifacts(runId: string): Promise<string[]> {
|
|
271
|
+
const prefix = `${ARTIFACTS_PREFIX}/${runId}/`;
|
|
272
|
+
const result = await this.listByPrefix(prefix);
|
|
273
|
+
return result.files;
|
|
274
|
+
}
|
|
182
275
|
}
|
package/src/store/ObjectsApi.ts
CHANGED
|
@@ -364,6 +364,7 @@ export class ObjectsApi extends ApiTopic {
|
|
|
364
364
|
max_hw: options.max_hw,
|
|
365
365
|
generate_if_missing: options.generate_if_missing,
|
|
366
366
|
sign_url: options.sign_url,
|
|
367
|
+
block_on_generation: options.block_on_generation,
|
|
367
368
|
};
|
|
368
369
|
|
|
369
370
|
return this.get(`/${documentId}/renditions/${options.format}`, {
|