@crewx/sdk 0.9.0-rc.138 → 0.9.0-rc.139

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.
@@ -1,5 +1,7 @@
1
- export type TaskStatus = 'pending' | 'running' | 'paused' | 'success' | 'failed' | 'stopped' | 'runner_lost';
2
- export declare const TASK_TERMINAL_STATUSES: readonly ["success", "failed", "stopped", "runner_lost"];
1
+ export type TaskStatus = 'pending' | 'running' | 'paused' | 'success' | 'failed' | 'stopped';
2
+ export declare const TASK_TERMINAL_STATUSES: readonly ["success", "failed", "stopped"];
3
+ export declare const TASK_TERMINAL_STORED_STATUSES: readonly ["success", "completed", "done", "failed", "error", "stopped", "runner_lost"];
4
+ export declare function storedTaskStatusesFor(statuses: readonly string[]): string[];
3
5
  export type TaskTerminalStatus = (typeof TASK_TERMINAL_STATUSES)[number];
4
6
  export type TaskTerminalReason = 'user_stop' | 'runner_lost' | 'launch_failed';
5
7
  export declare const LEGACY_TASK_TERMINAL_ERROR_PATTERNS: {
@@ -11,4 +13,9 @@ export interface TaskStatusInput {
11
13
  error?: string | null;
12
14
  metadata?: string | null;
13
15
  }
16
+ export declare function readTaskTerminalReason(row: TaskStatusInput): TaskTerminalReason | undefined;
14
17
  export declare function normalizeTaskStatus(row: TaskStatusInput): TaskStatus;
18
+ export declare function normalizeTaskRow<T extends TaskStatusInput>(row: T): Omit<T, 'status'> & {
19
+ status: TaskStatus;
20
+ };
21
+ export declare function isTaskRetryableByDefault(row: TaskStatusInput): boolean;
@@ -47,7 +47,9 @@ export interface FinalizeTaskForHostShutdownOptions {
47
47
  completedAt?: string;
48
48
  }
49
49
  export type FinalizeTaskForHostShutdownOutcome = 'settled' | 'not_running' | 'epoch_mismatch' | 'workspace_mismatch';
50
- export type TaskListRow = Pick<TaskRow, 'id' | 'thread_id' | 'agent_id' | 'status' | 'parent_task_id' | 'started_at' | 'completed_at' | 'duration_ms' | 'input_tokens' | 'output_tokens' | 'cost_usd' | 'error'>;
50
+ export type TaskListRow = Pick<TaskRow, 'id' | 'thread_id' | 'agent_id' | 'status' | 'parent_task_id' | 'started_at' | 'completed_at' | 'duration_ms' | 'input_tokens' | 'output_tokens' | 'cost_usd' | 'error'> & {
51
+ terminalReason: TaskTerminalReason | null;
52
+ };
51
53
  export type TaskActivityLogRow = Pick<TaskRow, 'id' | 'thread_id' | 'agent_id' | 'parent_task_id' | 'started_at' | 'completed_at'>;
52
54
  export type FindTasksByThreadOptions = {
53
55
  projection: 'activity-log';
@@ -140,6 +142,7 @@ export interface ReportTaskRow {
140
142
  status: string;
141
143
  error: string | null;
142
144
  exitCode: number | null;
145
+ terminalReason: TaskTerminalReason | null;
143
146
  }
144
147
  export interface DelegationEdge {
145
148
  callerAgentId: string | null;
@@ -152,7 +155,9 @@ export interface DelegationMatrixResult {
152
155
  edges: DelegationEdge[];
153
156
  truncated: boolean;
154
157
  }
155
- export type TaskEvidenceRow = Pick<TaskRow, 'id' | 'agent_id' | 'status' | 'prompt' | 'started_at' | 'completed_at' | 'thread_id'>;
158
+ export type TaskEvidenceRow = Pick<TaskRow, 'id' | 'agent_id' | 'status' | 'prompt' | 'started_at' | 'completed_at' | 'thread_id'> & {
159
+ terminalReason: TaskTerminalReason | null;
160
+ };
156
161
  export interface ThreadChainTurn {
157
162
  id: string;
158
163
  agentId: string;
@@ -1,6 +1,7 @@
1
1
  import { BaseSqliteRepository } from './base-sqlite-repository.js';
2
2
  import { RepositoryError } from './errors.js';
3
3
  import { threads } from '../schema/index.js';
4
+ import { type TaskStatus } from './task-status.js';
4
5
  import type { ThreadOriginRow } from './thread-origin-verdict.js';
5
6
  import type { TaskRow, TaskListRow } from './task.repository.js';
6
7
  export type { ThreadOriginRow } from './thread-origin-verdict.js';
@@ -41,6 +42,24 @@ export interface TaskDescendantSummary {
41
42
  runnerLost: number;
42
43
  checkedAt: string;
43
44
  }
45
+ export interface TaskDescendantRow {
46
+ task: TaskRow;
47
+ parentTaskId: string;
48
+ parentAgentId: string | null;
49
+ depth: number;
50
+ }
51
+ export interface TaskDescendantListOptions {
52
+ states?: readonly TaskStatus[];
53
+ limit?: number;
54
+ cursor?: string | null;
55
+ maxDepth?: number;
56
+ }
57
+ export interface TaskDescendantList {
58
+ rows: TaskDescendantRow[];
59
+ summary: TaskDescendantSummary;
60
+ nextCursor: string | null;
61
+ traversalTruncated: boolean;
62
+ }
44
63
  export type ThreadOriginFilter = 'direct' | 'delegated' | 'all';
45
64
  type ThreadOriginScope = Exclude<ThreadOriginFilter, 'all'>;
46
65
  export interface ThreadTitleMetadataPatch {
@@ -67,6 +86,8 @@ export declare class ThreadRepository extends BaseSqliteRepository {
67
86
  private openHandle;
68
87
  private topLevelTaskPredicateSql;
69
88
  private workflowAnchorPredicateSql;
89
+ private descendantTraversalSql;
90
+ private descendantSkippedSql;
70
91
  private findAllThreadsQuery;
71
92
  private findThreadIdsQuery;
72
93
  private readThreadIds;
@@ -96,7 +117,8 @@ export declare class ThreadRepository extends BaseSqliteRepository {
96
117
  };
97
118
  };
98
119
  getDescendantSummaryByTaskId(threadId: string, workspaceId?: string): Record<string, TaskDescendantSummary>;
99
- findTopLevelTasks(threadId: string, workspaceId?: string, limit?: number): TaskRow[];
120
+ listDescendantsByTaskId(taskId: string, workspaceId: string, options?: TaskDescendantListOptions): TaskDescendantList | undefined;
121
+ findTopLevelTasks(threadId: string, workspaceId?: string, limit?: number, ownAgentId?: string): TaskRow[];
100
122
  findAllTasks(threadId: string, workspaceId?: string): TaskRow[];
101
123
  findTaskById(threadId: string, taskId: string, workspaceId?: string): {
102
124
  task: TaskRow;