@agentuity/core 1.0.37 → 1.0.39
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/services/keyvalue/service.d.ts +2 -0
- package/dist/services/keyvalue/service.d.ts.map +1 -1
- package/dist/services/keyvalue/service.js +4 -0
- package/dist/services/keyvalue/service.js.map +1 -1
- package/dist/services/sandbox/client.d.ts +56 -5
- package/dist/services/sandbox/client.d.ts.map +1 -1
- package/dist/services/sandbox/client.js +120 -51
- package/dist/services/sandbox/client.js.map +1 -1
- package/dist/services/sandbox/pause.js +1 -1
- package/dist/services/sandbox/pause.js.map +1 -1
- package/dist/services/sandbox/types.d.ts +30 -0
- package/dist/services/sandbox/types.d.ts.map +1 -1
- package/dist/services/sandbox/types.js +28 -0
- package/dist/services/sandbox/types.js.map +1 -1
- package/dist/services/stream/delete.d.ts +27 -0
- package/dist/services/stream/delete.d.ts.map +1 -0
- package/dist/services/stream/delete.js +58 -0
- package/dist/services/stream/delete.js.map +1 -0
- package/dist/services/stream/index.d.ts +3 -0
- package/dist/services/stream/index.d.ts.map +1 -1
- package/dist/services/stream/index.js +3 -0
- package/dist/services/stream/index.js.map +1 -1
- package/dist/services/stream/namespaces.d.ts +75 -0
- package/dist/services/stream/namespaces.d.ts.map +1 -0
- package/dist/services/stream/namespaces.js +99 -0
- package/dist/services/stream/namespaces.js.map +1 -0
- package/dist/services/stream/search.d.ts +34 -0
- package/dist/services/stream/search.d.ts.map +1 -0
- package/dist/services/stream/search.js +49 -0
- package/dist/services/stream/search.js.map +1 -0
- package/dist/services/task/service.d.ts +154 -18
- package/dist/services/task/service.d.ts.map +1 -1
- package/dist/services/task/service.js +255 -10
- package/dist/services/task/service.js.map +1 -1
- package/dist/services/vector/service.d.ts +3 -0
- package/dist/services/vector/service.d.ts.map +1 -1
- package/dist/services/vector/service.js +7 -0
- package/dist/services/vector/service.js.map +1 -1
- package/package.json +2 -2
- package/src/services/keyvalue/service.ts +4 -0
- package/src/services/sandbox/client.ts +215 -84
- package/src/services/sandbox/pause.ts +1 -1
- package/src/services/sandbox/types.ts +52 -0
- package/src/services/stream/delete.ts +87 -0
- package/src/services/stream/index.ts +3 -0
- package/src/services/stream/namespaces.ts +160 -0
- package/src/services/stream/search.ts +80 -0
- package/src/services/task/service.ts +375 -13
- package/src/services/vector/service.ts +8 -0
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { type APIClient } from '../api.ts';
|
|
3
|
+
import { StreamNamespaceEntrySchema, type StreamNamespaceEntry } from './namespaces.ts';
|
|
4
|
+
import { StreamResponseError } from './util.ts';
|
|
5
|
+
|
|
6
|
+
// --- Response schema matching Pulse format ---
|
|
7
|
+
|
|
8
|
+
const SearchStreamsResponseSchema = z.discriminatedUnion('success', [
|
|
9
|
+
z.object({
|
|
10
|
+
success: z.literal<false>(false),
|
|
11
|
+
message: z.string().optional(),
|
|
12
|
+
}),
|
|
13
|
+
z.object({
|
|
14
|
+
success: z.literal<true>(true),
|
|
15
|
+
entries: z.array(StreamNamespaceEntrySchema),
|
|
16
|
+
total: z.number(),
|
|
17
|
+
}),
|
|
18
|
+
]);
|
|
19
|
+
|
|
20
|
+
type SearchStreamsResponse = z.infer<typeof SearchStreamsResponseSchema>;
|
|
21
|
+
|
|
22
|
+
// --- Options ---
|
|
23
|
+
|
|
24
|
+
export interface StreamSearchOptions {
|
|
25
|
+
keyword: string;
|
|
26
|
+
namespace?: string;
|
|
27
|
+
limit?: number;
|
|
28
|
+
offset?: number;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// --- Return types ---
|
|
32
|
+
|
|
33
|
+
export interface StreamSearchResult {
|
|
34
|
+
entries: StreamNamespaceEntry[];
|
|
35
|
+
total: number;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// --- Function ---
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Search streams by keyword across name, metadata, and headers.
|
|
42
|
+
* Optionally filter by a specific namespace.
|
|
43
|
+
*
|
|
44
|
+
* @param client - The API client configured for Pulse
|
|
45
|
+
* @param options - Search keyword, optional namespace filter, and pagination
|
|
46
|
+
* @returns Matching stream entries with total count
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* const result = await streamSearch(client, { keyword: 'agent-logs' });
|
|
50
|
+
* console.log(`Found ${result.total} matching streams`);
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* // Search within a specific namespace
|
|
54
|
+
* const result = await streamSearch(client, {
|
|
55
|
+
* keyword: 'error',
|
|
56
|
+
* namespace: 'agent-logs',
|
|
57
|
+
* limit: 50,
|
|
58
|
+
* });
|
|
59
|
+
*/
|
|
60
|
+
export async function streamSearch(
|
|
61
|
+
client: APIClient,
|
|
62
|
+
options: StreamSearchOptions
|
|
63
|
+
): Promise<StreamSearchResult> {
|
|
64
|
+
const resp = await client.post<SearchStreamsResponse>(
|
|
65
|
+
'/search',
|
|
66
|
+
{
|
|
67
|
+
keyword: options.keyword,
|
|
68
|
+
namespace: options.namespace,
|
|
69
|
+
limit: options.limit,
|
|
70
|
+
offset: options.offset,
|
|
71
|
+
},
|
|
72
|
+
SearchStreamsResponseSchema
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
if (resp.success) {
|
|
76
|
+
return { entries: resp.entries, total: resp.total };
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
throw new StreamResponseError({ message: resp.message });
|
|
80
|
+
}
|
|
@@ -30,10 +30,9 @@ export type TaskType = z.infer<typeof TaskTypeSchema>;
|
|
|
30
30
|
* - `'open'` — Created, not yet started.
|
|
31
31
|
* - `'in_progress'` — Actively being worked on.
|
|
32
32
|
* - `'done'` — Work completed.
|
|
33
|
-
* - `'closed'` — Resolved and closed.
|
|
34
33
|
* - `'cancelled'` — Abandoned.
|
|
35
34
|
*/
|
|
36
|
-
export const TaskStatusSchema = z.enum(['open', 'in_progress', '
|
|
35
|
+
export const TaskStatusSchema = z.enum(['open', 'in_progress', 'done', 'cancelled']);
|
|
37
36
|
|
|
38
37
|
export type TaskStatus = z.infer<typeof TaskStatusSchema>;
|
|
39
38
|
|
|
@@ -137,6 +136,10 @@ export const TaskSchema = z.object({
|
|
|
137
136
|
.lazy(() => z.array(CommentSchema))
|
|
138
137
|
.optional()
|
|
139
138
|
.describe('Array of comments on this task.'),
|
|
139
|
+
subtask_count: z
|
|
140
|
+
.number()
|
|
141
|
+
.optional()
|
|
142
|
+
.describe('Number of direct child tasks (subtasks). Only included in list responses.'),
|
|
140
143
|
});
|
|
141
144
|
|
|
142
145
|
export type Task = z.infer<typeof TaskSchema>;
|
|
@@ -451,6 +454,24 @@ export const BatchDeleteTasksParamsSchema = z.object({
|
|
|
451
454
|
|
|
452
455
|
export type BatchDeleteTasksParams = z.infer<typeof BatchDeleteTasksParamsSchema>;
|
|
453
456
|
|
|
457
|
+
/**
|
|
458
|
+
* Parameters for creating a new user entity.
|
|
459
|
+
*/
|
|
460
|
+
export interface CreateUserParams {
|
|
461
|
+
/** The user's display name. */
|
|
462
|
+
name: string;
|
|
463
|
+
/** The user type — defaults to 'human'. */
|
|
464
|
+
type?: 'human' | 'agent';
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
/**
|
|
468
|
+
* Parameters for creating a new project entity.
|
|
469
|
+
*/
|
|
470
|
+
export interface CreateProjectParams {
|
|
471
|
+
/** The project name. */
|
|
472
|
+
name: string;
|
|
473
|
+
}
|
|
474
|
+
|
|
454
475
|
/**
|
|
455
476
|
* A single task that was deleted in a batch operation.
|
|
456
477
|
*/
|
|
@@ -639,9 +660,6 @@ export const TaskActivityDataPointSchema = z.object({
|
|
|
639
660
|
/** Number of tasks in `'done'` status on this date. */
|
|
640
661
|
done: z.number().describe("Number of tasks in `'done'` status on this date."),
|
|
641
662
|
|
|
642
|
-
/** Number of tasks in `'closed'` status on this date. */
|
|
643
|
-
closed: z.number().describe("Number of tasks in `'closed'` status on this date."),
|
|
644
|
-
|
|
645
663
|
/** Number of tasks in `'cancelled'` status on this date. */
|
|
646
664
|
cancelled: z.number().describe("Number of tasks in `'cancelled'` status on this date."),
|
|
647
665
|
});
|
|
@@ -700,10 +718,10 @@ export interface TaskStorage {
|
|
|
700
718
|
update(id: string, params: UpdateTaskParams): Promise<Task>;
|
|
701
719
|
|
|
702
720
|
/**
|
|
703
|
-
* Close a task by setting its status to
|
|
721
|
+
* Close a task by setting its status to done.
|
|
704
722
|
*
|
|
705
723
|
* @param id - The unique task identifier
|
|
706
|
-
* @returns The
|
|
724
|
+
* @returns The task with updated closed_date and status set to done
|
|
707
725
|
*/
|
|
708
726
|
close(id: string): Promise<Task>;
|
|
709
727
|
|
|
@@ -907,6 +925,52 @@ export interface TaskStorage {
|
|
|
907
925
|
*/
|
|
908
926
|
listProjects(): Promise<ListProjectsResult>;
|
|
909
927
|
|
|
928
|
+
/**
|
|
929
|
+
* Create a new user entity.
|
|
930
|
+
*
|
|
931
|
+
* @param params - The user creation parameters
|
|
932
|
+
* @returns The created user entity reference
|
|
933
|
+
*/
|
|
934
|
+
createUser(params: CreateUserParams): Promise<UserEntityRef>;
|
|
935
|
+
|
|
936
|
+
/**
|
|
937
|
+
* Get a user entity by ID.
|
|
938
|
+
*
|
|
939
|
+
* @param userId - The unique user identifier
|
|
940
|
+
* @returns The user entity reference
|
|
941
|
+
*/
|
|
942
|
+
getUser(userId: string): Promise<UserEntityRef>;
|
|
943
|
+
|
|
944
|
+
/**
|
|
945
|
+
* Delete a user entity.
|
|
946
|
+
*
|
|
947
|
+
* @param userId - The unique user identifier
|
|
948
|
+
*/
|
|
949
|
+
deleteUser(userId: string): Promise<void>;
|
|
950
|
+
|
|
951
|
+
/**
|
|
952
|
+
* Create a new project entity.
|
|
953
|
+
*
|
|
954
|
+
* @param params - The project creation parameters
|
|
955
|
+
* @returns The created project entity reference
|
|
956
|
+
*/
|
|
957
|
+
createProject(params: CreateProjectParams): Promise<EntityRef>;
|
|
958
|
+
|
|
959
|
+
/**
|
|
960
|
+
* Get a project entity by ID.
|
|
961
|
+
*
|
|
962
|
+
* @param projectId - The unique project identifier
|
|
963
|
+
* @returns The project entity reference
|
|
964
|
+
*/
|
|
965
|
+
getProject(projectId: string): Promise<EntityRef>;
|
|
966
|
+
|
|
967
|
+
/**
|
|
968
|
+
* Delete a project entity.
|
|
969
|
+
*
|
|
970
|
+
* @param projectId - The unique project identifier
|
|
971
|
+
*/
|
|
972
|
+
deleteProject(projectId: string): Promise<void>;
|
|
973
|
+
|
|
910
974
|
/**
|
|
911
975
|
* Get task activity time-series data showing daily status counts.
|
|
912
976
|
*
|
|
@@ -973,6 +1037,24 @@ const UserIdRequiredError = StructuredError(
|
|
|
973
1037
|
'User ID is required and must be a non-empty string'
|
|
974
1038
|
);
|
|
975
1039
|
|
|
1040
|
+
/** Thrown when a user name parameter is empty or not a string. */
|
|
1041
|
+
const UserNameRequiredError = StructuredError(
|
|
1042
|
+
'UserNameRequiredError',
|
|
1043
|
+
'A non-empty user name is required.'
|
|
1044
|
+
);
|
|
1045
|
+
|
|
1046
|
+
/** Thrown when a project name parameter is empty or not a string. */
|
|
1047
|
+
const ProjectNameRequiredError = StructuredError(
|
|
1048
|
+
'ProjectNameRequiredError',
|
|
1049
|
+
'A non-empty project name is required.'
|
|
1050
|
+
);
|
|
1051
|
+
|
|
1052
|
+
/** Thrown when a project ID parameter is empty or not a string. */
|
|
1053
|
+
const ProjectIdRequiredError = StructuredError(
|
|
1054
|
+
'ProjectIdRequiredError',
|
|
1055
|
+
'A non-empty project ID is required.'
|
|
1056
|
+
);
|
|
1057
|
+
|
|
976
1058
|
/**
|
|
977
1059
|
* Thrown when the API returns a success HTTP status but the response body indicates failure.
|
|
978
1060
|
*/
|
|
@@ -1009,7 +1091,7 @@ type TaskResponse<T> = TaskSuccessResponse<T> | TaskErrorResponse;
|
|
|
1009
1091
|
* presigned S3 URLs, changelog tracking, and activity analytics.
|
|
1010
1092
|
*
|
|
1011
1093
|
* Tasks support lifecycle management through status transitions (`open` → `in_progress`
|
|
1012
|
-
* → `done`/`
|
|
1094
|
+
* → `done`/`cancelled`) with automatic date tracking for each transition.
|
|
1013
1095
|
*
|
|
1014
1096
|
* All methods validate inputs client-side and throw structured errors for invalid
|
|
1015
1097
|
* parameters. API errors throw {@link ServiceException}.
|
|
@@ -1286,17 +1368,17 @@ export class TaskStorageService implements TaskStorage {
|
|
|
1286
1368
|
}
|
|
1287
1369
|
|
|
1288
1370
|
/**
|
|
1289
|
-
* Close a task by setting its status to
|
|
1371
|
+
* Close a task by setting its status to done.
|
|
1290
1372
|
*
|
|
1291
1373
|
* @param id - The unique task identifier
|
|
1292
|
-
* @returns The
|
|
1374
|
+
* @returns The task with status set to done and updated closed_date
|
|
1293
1375
|
* @throws {@link TaskIdRequiredError} if the ID is empty or not a string
|
|
1294
1376
|
* @throws {@link ServiceException} if the API request fails
|
|
1295
1377
|
*
|
|
1296
1378
|
* @example
|
|
1297
1379
|
* ```typescript
|
|
1298
|
-
* const
|
|
1299
|
-
* console.log('
|
|
1380
|
+
* const task = await tasks.close('task_abc123');
|
|
1381
|
+
* console.log('Done at:', task.closed_date);
|
|
1300
1382
|
* ```
|
|
1301
1383
|
*/
|
|
1302
1384
|
async close(id: string): Promise<Task> {
|
|
@@ -1449,7 +1531,7 @@ export class TaskStorageService implements TaskStorage {
|
|
|
1449
1531
|
*
|
|
1450
1532
|
* @example
|
|
1451
1533
|
* ```typescript
|
|
1452
|
-
* const result = await tasks.batchDelete({ status: '
|
|
1534
|
+
* const result = await tasks.batchDelete({ status: 'done', older_than: '7d', limit: 50 });
|
|
1453
1535
|
* console.log(`Deleted ${result.count} tasks`);
|
|
1454
1536
|
* ```
|
|
1455
1537
|
*/
|
|
@@ -2524,6 +2606,286 @@ export class TaskStorageService implements TaskStorage {
|
|
|
2524
2606
|
throw await toServiceException('GET', url, res.response);
|
|
2525
2607
|
}
|
|
2526
2608
|
|
|
2609
|
+
/**
|
|
2610
|
+
* Create a new user entity.
|
|
2611
|
+
*
|
|
2612
|
+
* @param params - The user creation parameters including name and optional type
|
|
2613
|
+
* @returns The created user entity reference
|
|
2614
|
+
* @throws {@link UserNameRequiredError} if the name is empty or not a string
|
|
2615
|
+
* @throws {@link ServiceException} if the API request fails
|
|
2616
|
+
*
|
|
2617
|
+
* @example
|
|
2618
|
+
* ```typescript
|
|
2619
|
+
* const user = await tasks.createUser({ name: 'Jane Doe', type: 'human' });
|
|
2620
|
+
* console.log('Created user:', user.id, user.name);
|
|
2621
|
+
* ```
|
|
2622
|
+
*/
|
|
2623
|
+
async createUser(params: CreateUserParams): Promise<UserEntityRef> {
|
|
2624
|
+
if (!params?.name || typeof params.name !== 'string' || params.name.trim().length === 0) {
|
|
2625
|
+
throw new UserNameRequiredError();
|
|
2626
|
+
}
|
|
2627
|
+
|
|
2628
|
+
const normalizedName = params.name.trim();
|
|
2629
|
+
const url = buildUrl(this.#baseUrl, `/task/users/create/${TASK_API_VERSION}`);
|
|
2630
|
+
const signal = AbortSignal.timeout(30_000);
|
|
2631
|
+
|
|
2632
|
+
const res = await this.#adapter.invoke<TaskResponse<UserEntityRef>>(url, {
|
|
2633
|
+
method: 'POST',
|
|
2634
|
+
body: safeStringify({ ...params, name: normalizedName }),
|
|
2635
|
+
contentType: 'application/json',
|
|
2636
|
+
signal,
|
|
2637
|
+
telemetry: {
|
|
2638
|
+
name: 'agentuity.task.createUser',
|
|
2639
|
+
attributes: { userName: normalizedName },
|
|
2640
|
+
},
|
|
2641
|
+
});
|
|
2642
|
+
|
|
2643
|
+
if (res.ok) {
|
|
2644
|
+
if (res.data.success) {
|
|
2645
|
+
return res.data.data;
|
|
2646
|
+
}
|
|
2647
|
+
throw new TaskStorageResponseError({
|
|
2648
|
+
status: res.response.status,
|
|
2649
|
+
message: res.data.message,
|
|
2650
|
+
});
|
|
2651
|
+
}
|
|
2652
|
+
|
|
2653
|
+
throw await toServiceException('POST', url, res.response);
|
|
2654
|
+
}
|
|
2655
|
+
|
|
2656
|
+
/**
|
|
2657
|
+
* Get a user entity by ID.
|
|
2658
|
+
*
|
|
2659
|
+
* @param userId - The unique user identifier
|
|
2660
|
+
* @returns The user entity reference
|
|
2661
|
+
* @throws {@link UserIdRequiredError} if the user ID is empty or not a string
|
|
2662
|
+
* @throws {@link ServiceException} if the API request fails
|
|
2663
|
+
*
|
|
2664
|
+
* @example
|
|
2665
|
+
* ```typescript
|
|
2666
|
+
* const user = await tasks.getUser('usr_abc123');
|
|
2667
|
+
* console.log(`${user.name} (${user.type})`);
|
|
2668
|
+
* ```
|
|
2669
|
+
*/
|
|
2670
|
+
async getUser(userId: string): Promise<UserEntityRef> {
|
|
2671
|
+
if (!userId || typeof userId !== 'string' || userId.trim().length === 0) {
|
|
2672
|
+
throw new UserIdRequiredError();
|
|
2673
|
+
}
|
|
2674
|
+
|
|
2675
|
+
const url = buildUrl(
|
|
2676
|
+
this.#baseUrl,
|
|
2677
|
+
`/task/users/get/${TASK_API_VERSION}/${encodeURIComponent(userId)}`
|
|
2678
|
+
);
|
|
2679
|
+
const signal = AbortSignal.timeout(30_000);
|
|
2680
|
+
|
|
2681
|
+
const res = await this.#adapter.invoke<TaskResponse<UserEntityRef>>(url, {
|
|
2682
|
+
method: 'GET',
|
|
2683
|
+
signal,
|
|
2684
|
+
telemetry: {
|
|
2685
|
+
name: 'agentuity.task.getUser',
|
|
2686
|
+
attributes: { userId },
|
|
2687
|
+
},
|
|
2688
|
+
});
|
|
2689
|
+
|
|
2690
|
+
if (res.ok) {
|
|
2691
|
+
if (res.data.success) {
|
|
2692
|
+
return res.data.data;
|
|
2693
|
+
}
|
|
2694
|
+
throw new TaskStorageResponseError({
|
|
2695
|
+
status: res.response.status,
|
|
2696
|
+
message: res.data.message,
|
|
2697
|
+
});
|
|
2698
|
+
}
|
|
2699
|
+
|
|
2700
|
+
throw await toServiceException('GET', url, res.response);
|
|
2701
|
+
}
|
|
2702
|
+
|
|
2703
|
+
/**
|
|
2704
|
+
* Delete a user entity.
|
|
2705
|
+
*
|
|
2706
|
+
* @param userId - The unique user identifier
|
|
2707
|
+
* @throws {@link UserIdRequiredError} if the user ID is empty or not a string
|
|
2708
|
+
* @throws {@link ServiceException} if the API request fails
|
|
2709
|
+
*
|
|
2710
|
+
* @example
|
|
2711
|
+
* ```typescript
|
|
2712
|
+
* await tasks.deleteUser('usr_abc123');
|
|
2713
|
+
* console.log('User deleted');
|
|
2714
|
+
* ```
|
|
2715
|
+
*/
|
|
2716
|
+
async deleteUser(userId: string): Promise<void> {
|
|
2717
|
+
if (!userId || typeof userId !== 'string' || userId.trim().length === 0) {
|
|
2718
|
+
throw new UserIdRequiredError();
|
|
2719
|
+
}
|
|
2720
|
+
|
|
2721
|
+
const url = buildUrl(
|
|
2722
|
+
this.#baseUrl,
|
|
2723
|
+
`/task/users/delete/${TASK_API_VERSION}/${encodeURIComponent(userId)}`
|
|
2724
|
+
);
|
|
2725
|
+
const signal = AbortSignal.timeout(30_000);
|
|
2726
|
+
|
|
2727
|
+
const res = await this.#adapter.invoke<TaskResponse<void>>(url, {
|
|
2728
|
+
method: 'DELETE',
|
|
2729
|
+
signal,
|
|
2730
|
+
telemetry: {
|
|
2731
|
+
name: 'agentuity.task.deleteUser',
|
|
2732
|
+
attributes: { userId },
|
|
2733
|
+
},
|
|
2734
|
+
});
|
|
2735
|
+
|
|
2736
|
+
if (res.ok) {
|
|
2737
|
+
if (res.data?.success === false) {
|
|
2738
|
+
throw new TaskStorageResponseError({
|
|
2739
|
+
status: res.response.status,
|
|
2740
|
+
message: res.data.message ?? 'Operation failed',
|
|
2741
|
+
});
|
|
2742
|
+
}
|
|
2743
|
+
return;
|
|
2744
|
+
}
|
|
2745
|
+
|
|
2746
|
+
throw await toServiceException('DELETE', url, res.response);
|
|
2747
|
+
}
|
|
2748
|
+
|
|
2749
|
+
/**
|
|
2750
|
+
* Create a new project entity.
|
|
2751
|
+
*
|
|
2752
|
+
* @param params - The project creation parameters including name
|
|
2753
|
+
* @returns The created project entity reference
|
|
2754
|
+
* @throws {@link ProjectNameRequiredError} if the name is empty or not a string
|
|
2755
|
+
* @throws {@link ServiceException} if the API request fails
|
|
2756
|
+
*
|
|
2757
|
+
* @example
|
|
2758
|
+
* ```typescript
|
|
2759
|
+
* const project = await tasks.createProject({ name: 'My Project' });
|
|
2760
|
+
* console.log('Created project:', project.id, project.name);
|
|
2761
|
+
* ```
|
|
2762
|
+
*/
|
|
2763
|
+
async createProject(params: CreateProjectParams): Promise<EntityRef> {
|
|
2764
|
+
if (!params?.name || typeof params.name !== 'string' || params.name.trim().length === 0) {
|
|
2765
|
+
throw new ProjectNameRequiredError();
|
|
2766
|
+
}
|
|
2767
|
+
|
|
2768
|
+
const normalizedName = params.name.trim();
|
|
2769
|
+
const url = buildUrl(this.#baseUrl, `/task/projects/create/${TASK_API_VERSION}`);
|
|
2770
|
+
const signal = AbortSignal.timeout(30_000);
|
|
2771
|
+
|
|
2772
|
+
const res = await this.#adapter.invoke<TaskResponse<EntityRef>>(url, {
|
|
2773
|
+
method: 'POST',
|
|
2774
|
+
body: safeStringify({ ...params, name: normalizedName }),
|
|
2775
|
+
contentType: 'application/json',
|
|
2776
|
+
signal,
|
|
2777
|
+
telemetry: {
|
|
2778
|
+
name: 'agentuity.task.createProject',
|
|
2779
|
+
attributes: { projectName: normalizedName },
|
|
2780
|
+
},
|
|
2781
|
+
});
|
|
2782
|
+
|
|
2783
|
+
if (res.ok) {
|
|
2784
|
+
if (res.data.success) {
|
|
2785
|
+
return res.data.data;
|
|
2786
|
+
}
|
|
2787
|
+
throw new TaskStorageResponseError({
|
|
2788
|
+
status: res.response.status,
|
|
2789
|
+
message: res.data.message,
|
|
2790
|
+
});
|
|
2791
|
+
}
|
|
2792
|
+
|
|
2793
|
+
throw await toServiceException('POST', url, res.response);
|
|
2794
|
+
}
|
|
2795
|
+
|
|
2796
|
+
/**
|
|
2797
|
+
* Get a project entity by ID.
|
|
2798
|
+
*
|
|
2799
|
+
* @param projectId - The unique project identifier
|
|
2800
|
+
* @returns The project entity reference
|
|
2801
|
+
* @throws {@link ProjectIdRequiredError} if the project ID is empty or not a string
|
|
2802
|
+
* @throws {@link ServiceException} if the API request fails
|
|
2803
|
+
*
|
|
2804
|
+
* @example
|
|
2805
|
+
* ```typescript
|
|
2806
|
+
* const project = await tasks.getProject('prj_abc123');
|
|
2807
|
+
* console.log(`${project.name} (${project.id})`);
|
|
2808
|
+
* ```
|
|
2809
|
+
*/
|
|
2810
|
+
async getProject(projectId: string): Promise<EntityRef> {
|
|
2811
|
+
if (!projectId || typeof projectId !== 'string' || projectId.trim().length === 0) {
|
|
2812
|
+
throw new ProjectIdRequiredError();
|
|
2813
|
+
}
|
|
2814
|
+
|
|
2815
|
+
const url = buildUrl(
|
|
2816
|
+
this.#baseUrl,
|
|
2817
|
+
`/task/projects/get/${TASK_API_VERSION}/${encodeURIComponent(projectId)}`
|
|
2818
|
+
);
|
|
2819
|
+
const signal = AbortSignal.timeout(30_000);
|
|
2820
|
+
|
|
2821
|
+
const res = await this.#adapter.invoke<TaskResponse<EntityRef>>(url, {
|
|
2822
|
+
method: 'GET',
|
|
2823
|
+
signal,
|
|
2824
|
+
telemetry: {
|
|
2825
|
+
name: 'agentuity.task.getProject',
|
|
2826
|
+
attributes: { projectId },
|
|
2827
|
+
},
|
|
2828
|
+
});
|
|
2829
|
+
|
|
2830
|
+
if (res.ok) {
|
|
2831
|
+
if (res.data.success) {
|
|
2832
|
+
return res.data.data;
|
|
2833
|
+
}
|
|
2834
|
+
throw new TaskStorageResponseError({
|
|
2835
|
+
status: res.response.status,
|
|
2836
|
+
message: res.data.message,
|
|
2837
|
+
});
|
|
2838
|
+
}
|
|
2839
|
+
|
|
2840
|
+
throw await toServiceException('GET', url, res.response);
|
|
2841
|
+
}
|
|
2842
|
+
|
|
2843
|
+
/**
|
|
2844
|
+
* Delete a project entity.
|
|
2845
|
+
*
|
|
2846
|
+
* @param projectId - The unique project identifier
|
|
2847
|
+
* @throws {@link ProjectIdRequiredError} if the project ID is empty or not a string
|
|
2848
|
+
* @throws {@link ServiceException} if the API request fails
|
|
2849
|
+
*
|
|
2850
|
+
* @example
|
|
2851
|
+
* ```typescript
|
|
2852
|
+
* await tasks.deleteProject('prj_abc123');
|
|
2853
|
+
* console.log('Project deleted');
|
|
2854
|
+
* ```
|
|
2855
|
+
*/
|
|
2856
|
+
async deleteProject(projectId: string): Promise<void> {
|
|
2857
|
+
if (!projectId || typeof projectId !== 'string' || projectId.trim().length === 0) {
|
|
2858
|
+
throw new ProjectIdRequiredError();
|
|
2859
|
+
}
|
|
2860
|
+
|
|
2861
|
+
const url = buildUrl(
|
|
2862
|
+
this.#baseUrl,
|
|
2863
|
+
`/task/projects/delete/${TASK_API_VERSION}/${encodeURIComponent(projectId)}`
|
|
2864
|
+
);
|
|
2865
|
+
const signal = AbortSignal.timeout(30_000);
|
|
2866
|
+
|
|
2867
|
+
const res = await this.#adapter.invoke<TaskResponse<void>>(url, {
|
|
2868
|
+
method: 'DELETE',
|
|
2869
|
+
signal,
|
|
2870
|
+
telemetry: {
|
|
2871
|
+
name: 'agentuity.task.deleteProject',
|
|
2872
|
+
attributes: { projectId },
|
|
2873
|
+
},
|
|
2874
|
+
});
|
|
2875
|
+
|
|
2876
|
+
if (res.ok) {
|
|
2877
|
+
if (res.data?.success === false) {
|
|
2878
|
+
throw new TaskStorageResponseError({
|
|
2879
|
+
status: res.response.status,
|
|
2880
|
+
message: res.data.message ?? 'Operation failed',
|
|
2881
|
+
});
|
|
2882
|
+
}
|
|
2883
|
+
return;
|
|
2884
|
+
}
|
|
2885
|
+
|
|
2886
|
+
throw await toServiceException('DELETE', url, res.response);
|
|
2887
|
+
}
|
|
2888
|
+
|
|
2527
2889
|
/**
|
|
2528
2890
|
* Get task activity time-series data showing daily task counts by status.
|
|
2529
2891
|
*
|
|
@@ -341,6 +341,14 @@ export const VectorNamespaceStatsSchema = z.object({
|
|
|
341
341
|
.number()
|
|
342
342
|
.optional()
|
|
343
343
|
.describe('Unix timestamp (milliseconds) when the namespace was last used'),
|
|
344
|
+
|
|
345
|
+
/**
|
|
346
|
+
* Whether this namespace is system-managed (internal)
|
|
347
|
+
*/
|
|
348
|
+
internal: z
|
|
349
|
+
.boolean()
|
|
350
|
+
.optional()
|
|
351
|
+
.describe('Whether this namespace is system-managed (internal).'),
|
|
344
352
|
});
|
|
345
353
|
|
|
346
354
|
export type VectorNamespaceStats = z.infer<typeof VectorNamespaceStatsSchema>;
|