@agentuity/core 1.0.30 → 1.0.31

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.
@@ -42,6 +42,28 @@ export interface EntityRef {
42
42
  name: string;
43
43
  }
44
44
 
45
+ /**
46
+ * The type of user entity.
47
+ *
48
+ * - `'human'` — A human user.
49
+ * - `'agent'` — An AI agent.
50
+ */
51
+ export type UserType = 'human' | 'agent';
52
+
53
+ /**
54
+ * A reference to a user entity with type discrimination.
55
+ * Extends {@link EntityRef} with a {@link UserEntityRef.type | type} field
56
+ * to distinguish between human users and AI agents.
57
+ */
58
+ export interface UserEntityRef extends EntityRef {
59
+ /**
60
+ * The type of user. Defaults to `'human'` if not specified.
61
+ *
62
+ * @default 'human'
63
+ */
64
+ type?: UserType;
65
+ }
66
+
45
67
  /**
46
68
  * A work item in the task management system.
47
69
  *
@@ -130,13 +152,13 @@ export interface Task {
130
152
  closed_id?: string;
131
153
 
132
154
  /** Reference to the user who created the task. */
133
- creator?: EntityRef;
155
+ creator?: UserEntityRef;
134
156
 
135
157
  /** Reference to the user the task is assigned to. */
136
- assignee?: EntityRef;
158
+ assignee?: UserEntityRef;
137
159
 
138
160
  /** Reference to the user who closed the task. */
139
- closer?: EntityRef;
161
+ closer?: UserEntityRef;
140
162
 
141
163
  /** Reference to the project this task belongs to. */
142
164
  project?: EntityRef;
@@ -171,7 +193,7 @@ export interface Comment {
171
193
  user_id: string;
172
194
 
173
195
  /** Reference to the comment author with display name. */
174
- author?: EntityRef;
196
+ author?: UserEntityRef;
175
197
 
176
198
  /**
177
199
  * The comment text content.
@@ -286,11 +308,11 @@ export interface CreateTaskParams {
286
308
  */
287
309
  assigned_id?: string;
288
310
 
289
- /** Reference to the user creating the task (id and name). */
290
- creator?: EntityRef;
311
+ /** Reference to the user creating the task (id, name, and optional type). */
312
+ creator?: UserEntityRef;
291
313
 
292
314
  /** Reference to the user being assigned the task. */
293
- assignee?: EntityRef;
315
+ assignee?: UserEntityRef;
294
316
 
295
317
  /** Reference to the project this task belongs to. */
296
318
  project?: EntityRef;
@@ -349,10 +371,10 @@ export interface UpdateTaskParams {
349
371
  closed_id?: string;
350
372
 
351
373
  /** Reference to the user being assigned the task. */
352
- assignee?: EntityRef;
374
+ assignee?: UserEntityRef;
353
375
 
354
376
  /** Reference to the user closing the task. */
355
- closer?: EntityRef;
377
+ closer?: UserEntityRef;
356
378
 
357
379
  /** Reference to the project this task belongs to. */
358
380
  project?: EntityRef;
@@ -425,6 +447,62 @@ export interface ListTasksResult {
425
447
  offset: number;
426
448
  }
427
449
 
450
+ /**
451
+ * Parameters for batch-deleting tasks by filter.
452
+ * At least one filter must be provided.
453
+ */
454
+ export interface BatchDeleteTasksParams {
455
+ /** Filter by task status. */
456
+ status?: TaskStatus;
457
+
458
+ /** Filter by task type. */
459
+ type?: TaskType;
460
+
461
+ /** Filter by priority level. */
462
+ priority?: TaskPriority;
463
+
464
+ /** Filter by parent task ID (delete subtasks). */
465
+ parent_id?: string;
466
+
467
+ /** Filter by creator ID. */
468
+ created_id?: string;
469
+
470
+ /**
471
+ * Delete tasks older than this duration.
472
+ * Accepts Go-style duration strings: `'30m'`, `'24h'`, `'7d'`, `'2w'`.
473
+ */
474
+ older_than?: string;
475
+
476
+ /**
477
+ * Maximum number of tasks to delete.
478
+ * @default 50
479
+ * @maximum 200
480
+ */
481
+ limit?: number;
482
+ }
483
+
484
+ /**
485
+ * A single task that was deleted in a batch operation.
486
+ */
487
+ export interface BatchDeletedTask {
488
+ /** The ID of the deleted task. */
489
+ id: string;
490
+
491
+ /** The title of the deleted task. */
492
+ title: string;
493
+ }
494
+
495
+ /**
496
+ * Result of a batch delete operation.
497
+ */
498
+ export interface BatchDeleteTasksResult {
499
+ /** Array of tasks that were deleted. */
500
+ deleted: BatchDeletedTask[];
501
+
502
+ /** Total number of tasks deleted. */
503
+ count: number;
504
+ }
505
+
428
506
  /**
429
507
  * Paginated list of changelog entries for a task.
430
508
  */
@@ -484,7 +562,7 @@ export interface Attachment {
484
562
  user_id: string;
485
563
 
486
564
  /** Reference to the uploader with display name. */
487
- author?: EntityRef;
565
+ author?: UserEntityRef;
488
566
 
489
567
  /** Original filename of the uploaded file. */
490
568
  filename: string;
@@ -554,8 +632,8 @@ export interface ListAttachmentsResult {
554
632
  * List of all users who have been referenced in tasks (as creators, assignees, or closers).
555
633
  */
556
634
  export interface ListUsersResult {
557
- /** Array of user entity references. */
558
- users: EntityRef[];
635
+ /** Array of user entity references with type information. */
636
+ users: UserEntityRef[];
559
637
  }
560
638
 
561
639
  /**
@@ -672,6 +750,15 @@ export interface TaskStorage {
672
750
  */
673
751
  softDelete(id: string): Promise<Task>;
674
752
 
753
+ /**
754
+ * Batch soft-delete tasks matching the given filters.
755
+ * At least one filter must be provided.
756
+ *
757
+ * @param params - Filters to select which tasks to delete
758
+ * @returns The list of deleted tasks and count
759
+ */
760
+ batchDelete(params: BatchDeleteTasksParams): Promise<BatchDeleteTasksResult>;
761
+
675
762
  /**
676
763
  * Get the changelog (audit trail) for a task.
677
764
  *
@@ -867,6 +954,9 @@ export interface TaskStorage {
867
954
  /** API version string used for task CRUD, comment, tag, and attachment endpoints. */
868
955
  const TASK_API_VERSION = '2026-02-24';
869
956
 
957
+ /** Maximum number of tasks that can be deleted in a single batch request. */
958
+ const MAX_BATCH_DELETE_LIMIT = 200;
959
+
870
960
  /** API version string used for the task activity analytics endpoint. */
871
961
  const TASK_ACTIVITY_API_VERSION = '2026-02-28';
872
962
 
@@ -1383,6 +1473,77 @@ export class TaskStorageService implements TaskStorage {
1383
1473
  throw await toServiceException('POST', url, res.response);
1384
1474
  }
1385
1475
 
1476
+ /**
1477
+ * Batch soft-delete tasks matching the given filters.
1478
+ * At least one filter must be provided. The server caps the limit at 200.
1479
+ *
1480
+ * @param params - Filters to select which tasks to delete
1481
+ * @returns The list of deleted tasks and count
1482
+ * @throws {@link ServiceException} if the API request fails
1483
+ *
1484
+ * @example
1485
+ * ```typescript
1486
+ * const result = await tasks.batchDelete({ status: 'closed', older_than: '7d', limit: 50 });
1487
+ * console.log(`Deleted ${result.count} tasks`);
1488
+ * ```
1489
+ */
1490
+ async batchDelete(params: BatchDeleteTasksParams): Promise<BatchDeleteTasksResult> {
1491
+ const hasFilter =
1492
+ params.status ||
1493
+ params.type ||
1494
+ params.priority ||
1495
+ params.parent_id ||
1496
+ params.created_id ||
1497
+ params.older_than;
1498
+ if (!hasFilter) {
1499
+ throw new Error('At least one filter is required for batch delete');
1500
+ }
1501
+ if (params.limit !== undefined && params.limit > MAX_BATCH_DELETE_LIMIT) {
1502
+ throw new Error(
1503
+ `Batch delete limit must not exceed ${MAX_BATCH_DELETE_LIMIT} (got ${params.limit})`
1504
+ );
1505
+ }
1506
+
1507
+ const url = buildUrl(this.#baseUrl, `/task/delete/batch/${TASK_API_VERSION}`);
1508
+ const signal = AbortSignal.timeout(60_000);
1509
+
1510
+ const body: Record<string, unknown> = {};
1511
+ if (params.status) body.status = params.status;
1512
+ if (params.type) body.type = params.type;
1513
+ if (params.priority) body.priority = params.priority;
1514
+ if (params.parent_id) body.parent_id = params.parent_id;
1515
+ if (params.created_id) body.created_id = params.created_id;
1516
+ if (params.older_than) body.older_than = params.older_than;
1517
+ if (params.limit !== undefined) body.limit = params.limit;
1518
+
1519
+ const res = await this.#adapter.invoke<TaskResponse<BatchDeleteTasksResult>>(url, {
1520
+ method: 'POST',
1521
+ body: safeStringify(body),
1522
+ headers: { 'Content-Type': 'application/json' },
1523
+ signal,
1524
+ telemetry: {
1525
+ name: 'agentuity.task.batchDelete',
1526
+ attributes: {
1527
+ ...(params.status ? { status: params.status } : {}),
1528
+ ...(params.type ? { type: params.type } : {}),
1529
+ ...(params.older_than ? { older_than: params.older_than } : {}),
1530
+ },
1531
+ },
1532
+ });
1533
+
1534
+ if (res.ok) {
1535
+ if (res.data.success) {
1536
+ return res.data.data;
1537
+ }
1538
+ throw new TaskStorageResponseError({
1539
+ status: res.response.status,
1540
+ message: res.data.message,
1541
+ });
1542
+ }
1543
+
1544
+ throw await toServiceException('POST', url, res.response);
1545
+ }
1546
+
1386
1547
  /**
1387
1548
  * Create a comment on a task.
1388
1549
  *