@crewx/sdk 0.9.0-rc.7 → 0.9.0-rc.71

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.
Files changed (143) hide show
  1. package/README.md +1 -1
  2. package/dist/activity-log/builder.d.ts +55 -6
  3. package/dist/config/canonicalize-agent-options.d.ts +17 -0
  4. package/dist/config/global-settings.d.ts +33 -0
  5. package/dist/config/migrate-grok-mode.d.ts +6 -0
  6. package/dist/config/model-compat.d.ts +31 -0
  7. package/dist/config/models.generated.d.ts +33 -0
  8. package/dist/config/models.remote.d.ts +1 -0
  9. package/dist/config/overdrive.d.ts +7 -0
  10. package/dist/config/pricing.d.ts +8 -5
  11. package/dist/config/pricing.generated.d.ts +4 -0
  12. package/dist/config/pricing.types.d.ts +4 -10
  13. package/dist/config/timeout.config.d.ts +3 -0
  14. package/dist/config/wi-boards.d.ts +19 -0
  15. package/dist/context-budget/index.d.ts +105 -0
  16. package/dist/conversation/index.d.ts +1 -1
  17. package/dist/conversation/to-template-messages.d.ts +7 -0
  18. package/dist/conversation/types.d.ts +1 -0
  19. package/dist/desktop/command-runner.d.ts +4 -0
  20. package/dist/desktop/default-adapters.d.ts +4 -0
  21. package/dist/desktop/global-install.d.ts +19 -0
  22. package/dist/desktop/index.d.ts +2 -0
  23. package/dist/desktop/index.js +3 -0
  24. package/dist/desktop/install.d.ts +5 -0
  25. package/dist/desktop/lnk.d.ts +22 -0
  26. package/dist/desktop/manifest.d.ts +21 -0
  27. package/dist/desktop/types.d.ts +67 -0
  28. package/dist/desktop/version.d.ts +1 -0
  29. package/dist/desktop/windows-paths.d.ts +21 -0
  30. package/dist/desktop/wrapper.d.ts +18 -0
  31. package/dist/esm/desktop/index.js +3 -0
  32. package/dist/esm/index.js +271 -102
  33. package/dist/esm/plugins/index.js +166 -75
  34. package/dist/esm/publish/index.js +1 -0
  35. package/dist/esm/repository/index.js +184 -78
  36. package/dist/esm/testing/index.js +1 -1
  37. package/dist/events/types.d.ts +4 -0
  38. package/dist/facade/Crewx.d.ts +30 -0
  39. package/dist/index.browser.d.ts +7 -1
  40. package/dist/index.browser.js +6 -2
  41. package/dist/index.d.ts +36 -8
  42. package/dist/index.js +271 -102
  43. package/dist/internal/windows-spawn.d.ts +10 -0
  44. package/dist/local-server/base-url.d.ts +18 -0
  45. package/dist/local-server/index.d.ts +8 -0
  46. package/dist/local-server/opencode.d.ts +8 -0
  47. package/dist/local-server/probe.d.ts +3 -0
  48. package/dist/local-server/runtime.d.ts +26 -0
  49. package/dist/local-server/types.d.ts +43 -0
  50. package/dist/migrations/0008_careful_black_bird.sql +17 -0
  51. package/dist/migrations/0009_hot_dark_phoenix.sql +1 -0
  52. package/dist/migrations/0010_analyze_stats.sql +6 -0
  53. package/dist/migrations/0011_far_black_tarantula.sql +1 -0
  54. package/dist/migrations/0012_blue_turbo.sql +23 -0
  55. package/dist/migrations/0013_hesitant_adam_destine.sql +15 -0
  56. package/dist/migrations/0014_organic_mongu.sql +73 -0
  57. package/dist/migrations/0015_panoramic_gorilla_man.sql +71 -0
  58. package/dist/migrations/0016_fuzzy_hemingway.sql +14 -0
  59. package/dist/migrations/0017_project_stage_sdk_migration.sql +29 -0
  60. package/dist/migrations/meta/0008_snapshot.json +1327 -0
  61. package/dist/migrations/meta/0009_snapshot.json +1335 -0
  62. package/dist/migrations/meta/0010_snapshot.json +1335 -0
  63. package/dist/migrations/meta/0011_snapshot.json +1342 -0
  64. package/dist/migrations/meta/0012_snapshot.json +1494 -0
  65. package/dist/migrations/meta/0013_snapshot.json +1592 -0
  66. package/dist/migrations/meta/0014_snapshot.json +1975 -0
  67. package/dist/migrations/meta/0015_snapshot.json +2315 -0
  68. package/dist/migrations/meta/0016_snapshot.json +2419 -0
  69. package/dist/migrations/meta/0017_snapshot.json +2419 -0
  70. package/dist/migrations/meta/_journal.json +71 -1
  71. package/dist/paths.d.ts +1 -0
  72. package/dist/plugin/types.d.ts +1 -0
  73. package/dist/plugins/index.js +166 -75
  74. package/dist/provider/acp/connection.d.ts +4 -0
  75. package/dist/provider/acp/meta.d.ts +11 -0
  76. package/dist/provider/bridge.d.ts +16 -1
  77. package/dist/provider/classify-task-error.d.ts +2 -0
  78. package/dist/provider/cli/adapter.types.d.ts +6 -0
  79. package/dist/provider/cli/adapters/cli-knob.util.d.ts +8 -0
  80. package/dist/provider/cli/adapters/grok.d.ts +2 -0
  81. package/dist/provider/cli/adapters/index.d.ts +1 -0
  82. package/dist/provider/cli/index.d.ts +1 -1
  83. package/dist/provider/cli/meta.d.ts +5 -0
  84. package/dist/provider/errors.d.ts +1 -0
  85. package/dist/provider/idle-watchdog.d.ts +19 -0
  86. package/dist/provider/models.d.ts +17 -12
  87. package/dist/provider/order.d.ts +1 -1
  88. package/dist/provider/parse-usage.d.ts +6 -0
  89. package/dist/provider/provider-selection.d.ts +8 -0
  90. package/dist/provider/redact-technical-message.d.ts +1 -0
  91. package/dist/provider/task-error.types.d.ts +16 -0
  92. package/dist/publish/auth-boundary.d.ts +22 -0
  93. package/dist/publish/auth-json.d.ts +11 -0
  94. package/dist/publish/constants.d.ts +6 -0
  95. package/dist/publish/index.d.ts +30 -0
  96. package/dist/publish/index.js +1 -0
  97. package/dist/publish/manifest.d.ts +17 -0
  98. package/dist/publish/marketplace-api.constants.d.ts +1 -0
  99. package/dist/publish/pack.d.ts +2 -0
  100. package/dist/publish/scan.d.ts +9 -0
  101. package/dist/publish/secrets.d.ts +6 -0
  102. package/dist/publish/upload.d.ts +18 -0
  103. package/dist/repository/agent-suggestion.repository.d.ts +34 -0
  104. package/dist/repository/db.d.ts +8 -0
  105. package/dist/repository/index.d.ts +16 -3
  106. package/dist/repository/index.js +184 -78
  107. package/dist/repository/notification.repository.d.ts +58 -0
  108. package/dist/repository/project.repository.d.ts +90 -0
  109. package/dist/repository/task-log-migration.d.ts +74 -0
  110. package/dist/repository/task-log.repository.d.ts +44 -0
  111. package/dist/repository/task.repository.d.ts +114 -0
  112. package/dist/repository/thread.repository.d.ts +5 -2
  113. package/dist/repository/usage-report.repository.d.ts +27 -0
  114. package/dist/schema/agent-suggestions.d.ts +199 -0
  115. package/dist/schema/index.d.ts +7 -0
  116. package/dist/schema/notifications.d.ts +303 -0
  117. package/dist/schema/projects.d.ts +610 -0
  118. package/dist/schema/task-log-events.d.ts +119 -0
  119. package/dist/schema/tasks.d.ts +53 -0
  120. package/dist/schema/ui-action-receipts.d.ts +303 -0
  121. package/dist/schema/ui-instances.d.ts +267 -0
  122. package/dist/schema/usage-reports.d.ts +252 -0
  123. package/dist/testing/index.js +1 -1
  124. package/dist/types/index.d.ts +445 -3
  125. package/dist/ui-card/index.d.ts +2 -0
  126. package/dist/ui-card/legacy-card-parser.d.ts +11 -0
  127. package/dist/ui-instance/definition.d.ts +6 -0
  128. package/dist/ui-instance/errors.d.ts +17 -0
  129. package/dist/ui-instance/index.d.ts +6 -0
  130. package/dist/ui-instance/json.d.ts +5 -0
  131. package/dist/ui-instance/runtime.d.ts +13 -0
  132. package/dist/ui-instance/store.d.ts +65 -0
  133. package/dist/ui-instance/types.d.ts +200 -0
  134. package/dist/utils/crewx-home.d.ts +1 -0
  135. package/dist/utils/id.d.ts +1 -1
  136. package/dist/utils/timestamp.d.ts +1 -0
  137. package/dist/wi/create.d.ts +48 -0
  138. package/dist/wi/select.d.ts +20 -0
  139. package/package.json +18 -2
  140. package/templates/agents/default.yaml +175 -117
  141. package/templates/documents/crewx-manual.md +138 -138
  142. package/templates/workflows/wi-default-flow.yaml +65 -0
  143. package/templates/workflows/wi-plan-flow.yaml +140 -0
@@ -0,0 +1,58 @@
1
+ import { BaseSqliteRepository } from './base-sqlite-repository.js';
2
+ import { notifications, notification_reads } from '../schema/index.js';
3
+ export declare const DEFAULT_NOTIFICATION_CAP = 500;
4
+ export type NotificationRow = typeof notifications.$inferSelect;
5
+ export type NewNotification = typeof notifications.$inferInsert;
6
+ export type NotificationReadRow = typeof notification_reads.$inferSelect;
7
+ export type NotificationLevel = 'info' | 'warning' | 'critical';
8
+ export type NotificationSource = 'agent' | 'system';
9
+ export interface CreateNotificationInput {
10
+ workspaceId: string;
11
+ agentId?: string | null;
12
+ taskId?: string | null;
13
+ threadId?: string | null;
14
+ source?: NotificationSource;
15
+ level?: NotificationLevel;
16
+ title: string;
17
+ body?: string | null;
18
+ targetUserId?: string | null;
19
+ metadata?: string | null;
20
+ }
21
+ export interface NotificationListItem extends NotificationRow {
22
+ read: boolean;
23
+ read_at: string | null;
24
+ }
25
+ export interface ListNotificationsParams {
26
+ workspaceId: string;
27
+ userId: string;
28
+ limit?: number;
29
+ }
30
+ export interface UserScope {
31
+ workspaceId: string;
32
+ userId: string;
33
+ }
34
+ export interface MarkReadParams {
35
+ notificationId: string;
36
+ workspaceId: string;
37
+ userId: string;
38
+ }
39
+ export declare const DEFAULT_LIST_LIMIT = 50;
40
+ export declare class NotificationRepository extends BaseSqliteRepository {
41
+ private readonly dbPath?;
42
+ private readonly cap;
43
+ constructor(opts?: {
44
+ dbPath?: string;
45
+ dbRoot?: string;
46
+ cap?: number;
47
+ });
48
+ resolveDbPath(): string;
49
+ private openHandle;
50
+ create(input: CreateNotificationInput): {
51
+ id: string;
52
+ };
53
+ private enforceCap;
54
+ list(params: ListNotificationsParams): NotificationListItem[];
55
+ unreadCount(params: UserScope): number;
56
+ markRead(params: MarkReadParams): boolean;
57
+ markAllRead(params: UserScope): number;
58
+ }
@@ -0,0 +1,90 @@
1
+ import { BaseSqliteRepository } from './base-sqlite-repository.js';
2
+ import type { Project as ProjectLedgerRow, ProjectCriterion as ProjectCriterionRow, ProjectEvent as ProjectEventRow } from '../schema/index.js';
3
+ export type ProjectScene = 'planning' | 'plan_review' | 'running' | 'human_wait' | 'limit_wait' | 'failed_stop' | 'analyzing_feedback' | 'replanned' | 'awaiting_review' | 'accepted';
4
+ export type CriterionVerifyStatus = 'pending' | 'verifying' | 'passed' | 'failed';
5
+ export type ProjectActorType = 'user' | 'project_manager' | 'system';
6
+ export type ProjectEventType = 'created' | 'plan_proposed' | 'plan_approved' | 'decision_requested' | 'decision_answered' | 'replanned' | 'stage_advanced' | 'criterion_verified' | 'scene_changed' | 'result_submitted' | 'accepted';
7
+ export type ProjectEvidenceKind = 'task' | 'wi' | 'url';
8
+ export interface ProjectStage {
9
+ key: string;
10
+ labelOverride: string | null;
11
+ }
12
+ export declare const DEFAULT_PROJECT_STAGE_KEYS: readonly ["outcome_plan", "contract_check", "feature_link", "use_verify", "result_review"];
13
+ export declare const DEFAULT_PROJECT_STAGES: readonly ProjectStage[];
14
+ export interface ProjectEvidence {
15
+ kind: ProjectEvidenceKind;
16
+ ref: string;
17
+ label?: string;
18
+ }
19
+ export interface ProjectActorInput {
20
+ actorType?: ProjectActorType;
21
+ actorId?: string | null;
22
+ }
23
+ export interface CreateProjectInput {
24
+ workspaceId: string;
25
+ name: string;
26
+ outcome: string;
27
+ dueDate?: string | null;
28
+ stages?: readonly ProjectStage[];
29
+ criteria: readonly string[];
30
+ }
31
+ export interface ListProjectsOptions {
32
+ includeArchived?: boolean;
33
+ }
34
+ export interface ListProjectEventsOptions {
35
+ afterSeq?: number;
36
+ limit?: number;
37
+ }
38
+ export interface AppendProjectEventInput extends ProjectActorInput {
39
+ projectId: string;
40
+ type: ProjectEventType;
41
+ title: string;
42
+ summary?: string | null;
43
+ payload?: Record<string, unknown>;
44
+ }
45
+ export interface SetCriterionVerifyInput extends ProjectActorInput {
46
+ projectId?: string;
47
+ criterionId: string;
48
+ verifyStatus?: CriterionVerifyStatus;
49
+ status?: CriterionVerifyStatus;
50
+ }
51
+ export interface SetCriterionEvidenceInput extends ProjectActorInput {
52
+ projectId?: string;
53
+ criterionId: string;
54
+ evidence: readonly ProjectEvidence[];
55
+ }
56
+ export interface AcceptProjectInput extends ProjectActorInput {
57
+ remainingRisks: unknown;
58
+ nextPlan: unknown;
59
+ lessons: unknown;
60
+ evidenceRefs: unknown;
61
+ }
62
+ export interface ProjectDetail extends ProjectLedgerRow {
63
+ stages: ProjectStage[];
64
+ criteria: ProjectCriterionRow[];
65
+ }
66
+ export declare class ProjectRepository extends BaseSqliteRepository {
67
+ private readonly dbPath?;
68
+ constructor(opts?: {
69
+ dbPath?: string;
70
+ dbRoot?: string;
71
+ });
72
+ resolveDbPath(): string;
73
+ private openHandle;
74
+ private getDetailFromHandle;
75
+ private getDetailOrThrow;
76
+ createProject(input: CreateProjectInput): ProjectDetail;
77
+ getProject(id: string): ProjectDetail | undefined;
78
+ listProjectsByWorkspace(workspaceId: string, options?: ListProjectsOptions): ProjectDetail[];
79
+ archiveProject(id: string): ProjectDetail;
80
+ setScene(id: string, scene: ProjectScene, actor?: ProjectActorInput): ProjectDetail;
81
+ setStageIndex(id: string, index: number, actor?: ProjectActorInput): ProjectDetail;
82
+ setCriterionVerify(input: SetCriterionVerifyInput): ProjectCriterionRow;
83
+ setCriterionVerify(projectId: string, criterionId: string, status: CriterionVerifyStatus, actor?: ProjectActorInput): ProjectCriterionRow;
84
+ setCriterionEvidence(input: SetCriterionEvidenceInput): ProjectCriterionRow;
85
+ setCriterionEvidence(projectId: string, criterionId: string, evidence: readonly ProjectEvidence[], actor?: ProjectActorInput): ProjectCriterionRow;
86
+ appendEvent(input: AppendProjectEventInput): ProjectEventRow;
87
+ appendEvent(projectId: string, input: Omit<AppendProjectEventInput, 'projectId'>): ProjectEventRow;
88
+ listEvents(projectId: string, options?: ListProjectEventsOptions): ProjectEventRow[];
89
+ acceptProject(id: string, input: AcceptProjectInput): ProjectDetail;
90
+ }
@@ -0,0 +1,74 @@
1
+ export type TaskLogMigrationMode = 'dry-run' | 'apply' | 'verify';
2
+ export declare const TASK_LOG_MIGRATION_TERMINAL_STATUSES: readonly ["success", "failed", "completed"];
3
+ export declare const TASK_LOG_MIGRATION_MIN_FREE_SPACE_BYTES: number;
4
+ export declare const TASK_LOG_MIGRATION_EVENT_ROW_BYTES = 256;
5
+ export type TaskLogVerificationIssueKind = 'malformed-blob' | 'mixed-source' | 'seq-gap' | 'duplicate-seq' | 'orphan-event' | 'count-mismatch' | 'source-invariant' | 'invalid-event';
6
+ export type TaskLogMigrationFailureKind = 'malformed' | 'mixed-source' | 'metadata' | 'invalid-source';
7
+ export interface TaskLogMigrationOptions {
8
+ mode: TaskLogMigrationMode;
9
+ dbPath?: string;
10
+ batchTasks?: number;
11
+ backupPath?: string;
12
+ }
13
+ export interface TaskLogMigrationFailure {
14
+ taskId: string;
15
+ reason: string;
16
+ kind?: TaskLogMigrationFailureKind;
17
+ }
18
+ export interface TaskLogVerificationIssue {
19
+ taskId: string | null;
20
+ kind: TaskLogVerificationIssueKind;
21
+ reason: string;
22
+ expected?: number;
23
+ actual?: number;
24
+ seq?: number;
25
+ }
26
+ export interface TaskLogVerificationReport {
27
+ checkedTasks: number;
28
+ eventSourceTasks: number;
29
+ blobSourceTasks: number;
30
+ eventCount: number;
31
+ orphanEventCount: number;
32
+ failedTasks: number;
33
+ issues: TaskLogVerificationIssue[];
34
+ }
35
+ export interface TaskLogMigrationReport {
36
+ mode: TaskLogMigrationMode;
37
+ ok: boolean;
38
+ dbPath: string;
39
+ backupPath?: string;
40
+ backupMethod?: 'sqlite-online-backup';
41
+ blockedReason?: string;
42
+ activeTaskCount: number;
43
+ taskCount: number;
44
+ candidateTaskCount: number;
45
+ eligibleTaskCount: number;
46
+ statusCounts: Record<string, number>;
47
+ deferredTaskCount: number;
48
+ deferredStatusCounts: Record<string, number>;
49
+ entryCount: number;
50
+ sourceBytes: number;
51
+ estimatedFreeSpaceBytes: number;
52
+ requiredFreeSpaceBytes: number;
53
+ availableFreeSpaceBytes: number;
54
+ minimumFreeSpaceReserveBytes: number;
55
+ freeSpaceGatePassed: boolean;
56
+ migratedTasks: number;
57
+ migratedEntries: number;
58
+ skippedTasks: number;
59
+ failedTasks: number;
60
+ malformedRows: TaskLogMigrationFailure[];
61
+ failures: TaskLogMigrationFailure[];
62
+ logicalSourceBytesRemoved: number;
63
+ warnings: string[];
64
+ remainingTaskCount: number;
65
+ verification?: TaskLogVerificationReport;
66
+ }
67
+ export declare function resolveTaskLogMigrationDbPath(dbPath?: string): string;
68
+ export declare function hasSufficientTaskLogMigrationFreeSpace(availableFreeSpaceBytes: number, estimatedFreeSpaceBytes: number): boolean;
69
+ export interface TaskLogWalCheckpointConnection {
70
+ pragma(pragma: string): unknown;
71
+ }
72
+ export declare function tryCheckpointTaskLogWal(db: TaskLogWalCheckpointConnection): string | undefined;
73
+ export declare function runTaskLogMigration(options: TaskLogMigrationOptions): Promise<TaskLogMigrationReport>;
74
+ export declare function taskLogBackupName(backupPath: string): string;
@@ -0,0 +1,44 @@
1
+ import { BaseSqliteRepository } from './base-sqlite-repository.js';
2
+ export type TaskLogStorage = 'blob' | 'events';
3
+ export interface TaskLogEntry {
4
+ timestamp: string;
5
+ level: string;
6
+ message: string;
7
+ }
8
+ export type RawTaskLogEntry = TaskLogEntry;
9
+ export type TaskLogRawEntry = TaskLogEntry;
10
+ export interface TaskLogState {
11
+ taskId: string;
12
+ source: TaskLogStorage;
13
+ revision: number;
14
+ lastSeq: number;
15
+ }
16
+ export interface TaskLogReadResult extends TaskLogState {
17
+ entries: TaskLogEntry[];
18
+ }
19
+ export interface TaskLogRepositoryContract {
20
+ appendLog(taskId: string, entry: TaskLogEntry): TaskLogState;
21
+ appendLogs(taskId: string, entries: readonly TaskLogEntry[]): TaskLogState;
22
+ readLogs(taskId: string): TaskLogReadResult | undefined;
23
+ readLogsTail(taskId: string, limit: number): TaskLogReadResult | undefined;
24
+ getLogState(taskId: string): TaskLogState | undefined;
25
+ }
26
+ export declare class TaskLogRepository extends BaseSqliteRepository implements TaskLogRepositoryContract {
27
+ private readonly dbPath?;
28
+ constructor(opts?: {
29
+ dbPath?: string;
30
+ dbRoot?: string;
31
+ });
32
+ resolveDbPath(): string;
33
+ private openHandle;
34
+ private findStateRow;
35
+ private findStateRowInTransaction;
36
+ private requireStateRowInTransaction;
37
+ appendLog(taskId: string, entry: TaskLogEntry): TaskLogState;
38
+ appendLogs(taskId: string, entries: readonly TaskLogEntry[]): TaskLogState;
39
+ getLogState(taskId: string): TaskLogState | undefined;
40
+ readLogs(taskId: string): TaskLogReadResult | undefined;
41
+ readLogsTail(taskId: string, limit: number): TaskLogReadResult | undefined;
42
+ readTail(taskId: string, limit: number): TaskLogReadResult | undefined;
43
+ private readLogsInternal;
44
+ }
@@ -1,7 +1,27 @@
1
1
  import { BaseSqliteRepository } from './base-sqlite-repository.js';
2
2
  import { tasks } from '../schema/index.js';
3
+ import type { TaskLogEntry, TaskLogReadResult, TaskLogState } from './task-log.repository.js';
3
4
  export type TaskRow = typeof tasks.$inferSelect;
4
5
  export type NewTask = typeof tasks.$inferInsert;
6
+ 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'>;
7
+ export interface WorkflowCardRow {
8
+ taskId: string;
9
+ workflowRunId?: string;
10
+ raw?: string;
11
+ }
12
+ export interface WorkflowParentTaskRow {
13
+ id: string;
14
+ agent_id: string;
15
+ thread_id: string | null;
16
+ workspace_id: string | null;
17
+ platform: string | null;
18
+ status: string;
19
+ error: string | null;
20
+ completed_at: string | null;
21
+ duration_ms: number | null;
22
+ started_at: string;
23
+ metadata: string | null;
24
+ }
5
25
  export interface AgentUsageRow {
6
26
  agentId: string;
7
27
  workspaceId: string | null;
@@ -32,8 +52,56 @@ export interface ProviderUsageRow {
32
52
  activeDurationMs: number;
33
53
  lastActiveAt: string | null;
34
54
  }
55
+ export interface ModelUsageRow {
56
+ model: string;
57
+ provider: string;
58
+ totalTasks: number;
59
+ inputTokens: number;
60
+ outputTokens: number;
61
+ cachedInputTokens: number;
62
+ costUsd: number;
63
+ totalTokens: number;
64
+ activeDurationMs: number;
65
+ lastActiveAt: string | null;
66
+ }
67
+ export interface ReportTaskRow {
68
+ threadId: string | null;
69
+ agentId: string;
70
+ startedAt: string;
71
+ status: string;
72
+ error: string | null;
73
+ exitCode: number | null;
74
+ }
75
+ export interface DelegationEdge {
76
+ callerAgentId: string | null;
77
+ agentId: string;
78
+ taskCount: number;
79
+ totalTokens: number;
80
+ outputTokens: number;
81
+ }
82
+ export interface DelegationMatrixResult {
83
+ edges: DelegationEdge[];
84
+ truncated: boolean;
85
+ }
86
+ export type TaskEvidenceRow = Pick<TaskRow, 'id' | 'agent_id' | 'status' | 'prompt' | 'started_at' | 'completed_at' | 'thread_id'>;
87
+ export interface ThreadChainTurn {
88
+ id: string;
89
+ agentId: string;
90
+ status: string;
91
+ prompt: string;
92
+ startedAt: string;
93
+ completedAt: string | null;
94
+ }
95
+ export interface ThreadChain {
96
+ threadId: string;
97
+ targetAgentTurnCount: number;
98
+ turns: ThreadChainTurn[];
99
+ }
100
+ export declare const PID_NULL_REAP_GRACE_MS: number;
35
101
  export declare class TaskRepository extends BaseSqliteRepository {
36
102
  private readonly dbPath?;
103
+ private readonly taskLogRepository;
104
+ private readonly pidNullObservedSince;
37
105
  constructor(opts?: {
38
106
  dbPath?: string;
39
107
  dbRoot?: string;
@@ -54,6 +122,7 @@ export declare class TaskRepository extends BaseSqliteRepository {
54
122
  command?: string | null;
55
123
  metadata?: string | null;
56
124
  workspaceId?: string | null;
125
+ projectId?: string | null;
57
126
  platform?: string | null;
58
127
  crewxVersion?: string | null;
59
128
  threadId?: string | null;
@@ -61,6 +130,7 @@ export declare class TaskRepository extends BaseSqliteRepository {
61
130
  renderedPrompt?: string | null;
62
131
  codingAgentCommand?: string | null;
63
132
  }): void;
133
+ listTasksByProjectId(projectId: string): TaskRow[];
64
134
  finishTask(opts: {
65
135
  id: string;
66
136
  status: string;
@@ -81,6 +151,10 @@ export declare class TaskRepository extends BaseSqliteRepository {
81
151
  level: string;
82
152
  message: string;
83
153
  }): void;
154
+ appendLogs(taskId: string, entries: readonly TaskLogEntry[]): void;
155
+ readLogs(taskId: string): TaskLogReadResult | undefined;
156
+ readLogsTail(taskId: string, limit: number): TaskLogReadResult | undefined;
157
+ getLogState(taskId: string): TaskLogState | undefined;
84
158
  getRunningTasks(): TaskRow[];
85
159
  getAllTasks(): TaskRow[];
86
160
  getTask(id: string): TaskRow | undefined;
@@ -89,6 +163,7 @@ export declare class TaskRepository extends BaseSqliteRepository {
89
163
  pid?: number;
90
164
  };
91
165
  reapOrphanedTasks(): number;
166
+ reapRunningWorkflowTasks(graceMs?: number): number;
92
167
  findTaskStatus(taskId: string, workspaceId?: string): TaskRow | undefined;
93
168
  findChildTasks(parentTaskId: string, workspaceId?: string): TaskRow[];
94
169
  getWorkspaceUsageSummary(workspaceId?: string): Array<{
@@ -104,6 +179,10 @@ export declare class TaskRepository extends BaseSqliteRepository {
104
179
  costUsd: number;
105
180
  };
106
181
  findTasksByThread(threadId: string, workspaceId?: string): TaskRow[];
182
+ private parseWorkflowCardMetadata;
183
+ private extractThreadIdFromCommand;
184
+ findRunningWorkflowParentTasks(): WorkflowParentTaskRow[];
185
+ batchFetchWorkflowCards(threadIds: string[], workspaceId?: string): Map<string, WorkflowCardRow>;
107
186
  findAllTasks(params: {
108
187
  workspaceId?: string;
109
188
  agentId?: string;
@@ -124,7 +203,42 @@ export declare class TaskRepository extends BaseSqliteRepository {
124
203
  getAgentUsage(from: string, to: string, workspace?: string): AgentUsageRow[];
125
204
  getAgentUsageTrendRaw(from: string, to: string, workspace?: string): TrendRow[];
126
205
  findTaskForStop(taskId: string, workspaceId: string): TaskRow | undefined;
206
+ findLatestTaskByMetadata(opts: {
207
+ agentId: string;
208
+ workspaceId: string;
209
+ metaKey: string;
210
+ metaValue: string;
211
+ }): {
212
+ id: string;
213
+ thread_id: string | null;
214
+ status: string;
215
+ result: string | null;
216
+ error: string | null;
217
+ started_at: string;
218
+ completed_at: string | null;
219
+ metadata: string | null;
220
+ } | null;
127
221
  markTaskFailed(taskId: string, error: string, workspaceId?: string): void;
128
222
  findTasksByPromptHint(hint: string, workspaceId?: string): TaskRow[];
129
223
  getProviderUsage(from: string, to: string, workspace?: string): ProviderUsageRow[];
224
+ getModelUsage(from: string, to: string, workspace?: string): ModelUsageRow[];
225
+ getTasksForReport(from: string, to: string, workspace?: string): ReportTaskRow[];
226
+ getDelegationMatrix(from: string, to: string, workspace?: string): DelegationMatrixResult;
227
+ findTaskEvidence(params: {
228
+ workspaceId?: string;
229
+ agents?: string[];
230
+ statuses?: string[];
231
+ from?: string;
232
+ to?: string;
233
+ limit?: number;
234
+ order?: 'ASC' | 'DESC';
235
+ }): TaskEvidenceRow[];
236
+ findThreadChains(params: {
237
+ targetAgentId: string;
238
+ workspaceId?: string;
239
+ from?: string;
240
+ to?: string;
241
+ maxThreads?: number;
242
+ maxTurnsPerThread?: number;
243
+ }): ThreadChain[];
130
244
  }
@@ -1,6 +1,6 @@
1
1
  import { BaseSqliteRepository } from './base-sqlite-repository.js';
2
2
  import { threads } from '../schema/index.js';
3
- import type { TaskRow } from './task.repository.js';
3
+ import type { TaskRow, TaskListRow } from './task.repository.js';
4
4
  export type ThreadRow = typeof threads.$inferSelect;
5
5
  export type NewThread = typeof threads.$inferInsert;
6
6
  export declare class ThreadRepository extends BaseSqliteRepository {
@@ -14,6 +14,7 @@ export declare class ThreadRepository extends BaseSqliteRepository {
14
14
  private validateWorkspaceId;
15
15
  private topLevelTaskPredicateSql;
16
16
  findAllThreads(workspaceId?: string): ThreadRow[];
17
+ findThreadsByIdsOrTitles(ids: string[], workspaceId?: string): ThreadRow[];
17
18
  findThreadById(threadId: string, workspaceId?: string): ThreadRow | undefined;
18
19
  threadExists(threadId: string, workspaceId?: string): boolean;
19
20
  aggregateTaskStats(threadId: string, workspaceId?: string): {
@@ -30,7 +31,9 @@ export declare class ThreadRepository extends BaseSqliteRepository {
30
31
  task: TaskRow;
31
32
  children: TaskRow[];
32
33
  } | undefined;
33
- batchFetchTasks(threadIds: string[], workspaceId?: string): Map<string, TaskRow[]>;
34
+ private batchFetchTasksQuery;
35
+ batchFetchTasks(threadIds: string[], workspaceId?: string): Map<string, TaskListRow[]>;
36
+ explainBatchFetchTasksPlan(threadIds: string[], workspaceId?: string): string[];
34
37
  updateThreadTitle(threadId: string, title: string, workspaceId?: string): void;
35
38
  upsertThread(threadId: string, opts: {
36
39
  platform: string;
@@ -0,0 +1,27 @@
1
+ import { BaseSqliteRepository } from './base-sqlite-repository.js';
2
+ import { usage_reports } from '../schema/index.js';
3
+ export type UsageReportRow = typeof usage_reports.$inferSelect;
4
+ export type NewUsageReport = typeof usage_reports.$inferInsert;
5
+ export interface PublishReportInput {
6
+ id: string;
7
+ workspaceId: string;
8
+ month: string;
9
+ generatedAt: string;
10
+ sourceRange: string;
11
+ tier: string;
12
+ totalTokens: number;
13
+ totalCostUsd: number;
14
+ payload: string;
15
+ }
16
+ export declare class UsageReportRepository extends BaseSqliteRepository {
17
+ private readonly dbPath?;
18
+ constructor(opts?: {
19
+ dbPath?: string;
20
+ dbRoot?: string;
21
+ });
22
+ resolveDbPath(): string;
23
+ private openHandle;
24
+ publish(input: PublishReportInput): UsageReportRow;
25
+ findByMonth(workspaceId: string, month: string): UsageReportRow | undefined;
26
+ listByWorkspace(workspaceId: string): UsageReportRow[];
27
+ }
@@ -0,0 +1,199 @@
1
+ export declare const agent_suggestions: import("drizzle-orm/sqlite-core").SQLiteTableWithColumns<{
2
+ name: "agent_suggestions";
3
+ schema: undefined;
4
+ columns: {
5
+ id: import("drizzle-orm/sqlite-core").SQLiteColumn<{
6
+ name: "id";
7
+ tableName: "agent_suggestions";
8
+ dataType: "string";
9
+ columnType: "SQLiteText";
10
+ data: string;
11
+ driverParam: string;
12
+ notNull: true;
13
+ hasDefault: false;
14
+ isPrimaryKey: true;
15
+ isAutoincrement: false;
16
+ hasRuntimeDefault: false;
17
+ enumValues: [string, ...string[]];
18
+ baseColumn: never;
19
+ identity: undefined;
20
+ generated: undefined;
21
+ }, {}, {
22
+ length: number | undefined;
23
+ }>;
24
+ workspace_id: import("drizzle-orm/sqlite-core").SQLiteColumn<{
25
+ name: "workspace_id";
26
+ tableName: "agent_suggestions";
27
+ dataType: "string";
28
+ columnType: "SQLiteText";
29
+ data: string;
30
+ driverParam: string;
31
+ notNull: true;
32
+ hasDefault: false;
33
+ isPrimaryKey: false;
34
+ isAutoincrement: false;
35
+ hasRuntimeDefault: false;
36
+ enumValues: [string, ...string[]];
37
+ baseColumn: never;
38
+ identity: undefined;
39
+ generated: undefined;
40
+ }, {}, {
41
+ length: number | undefined;
42
+ }>;
43
+ agent_id: import("drizzle-orm/sqlite-core").SQLiteColumn<{
44
+ name: "agent_id";
45
+ tableName: "agent_suggestions";
46
+ dataType: "string";
47
+ columnType: "SQLiteText";
48
+ data: string;
49
+ driverParam: string;
50
+ notNull: true;
51
+ hasDefault: false;
52
+ isPrimaryKey: false;
53
+ isAutoincrement: false;
54
+ hasRuntimeDefault: false;
55
+ enumValues: [string, ...string[]];
56
+ baseColumn: never;
57
+ identity: undefined;
58
+ generated: undefined;
59
+ }, {}, {
60
+ length: number | undefined;
61
+ }>;
62
+ task_id: import("drizzle-orm/sqlite-core").SQLiteColumn<{
63
+ name: "task_id";
64
+ tableName: "agent_suggestions";
65
+ dataType: "string";
66
+ columnType: "SQLiteText";
67
+ data: string;
68
+ driverParam: string;
69
+ notNull: false;
70
+ hasDefault: false;
71
+ isPrimaryKey: false;
72
+ isAutoincrement: false;
73
+ hasRuntimeDefault: false;
74
+ enumValues: [string, ...string[]];
75
+ baseColumn: never;
76
+ identity: undefined;
77
+ generated: undefined;
78
+ }, {}, {
79
+ length: number | undefined;
80
+ }>;
81
+ type: import("drizzle-orm/sqlite-core").SQLiteColumn<{
82
+ name: "type";
83
+ tableName: "agent_suggestions";
84
+ dataType: "string";
85
+ columnType: "SQLiteText";
86
+ data: string;
87
+ driverParam: string;
88
+ notNull: true;
89
+ hasDefault: false;
90
+ isPrimaryKey: false;
91
+ isAutoincrement: false;
92
+ hasRuntimeDefault: false;
93
+ enumValues: [string, ...string[]];
94
+ baseColumn: never;
95
+ identity: undefined;
96
+ generated: undefined;
97
+ }, {}, {
98
+ length: number | undefined;
99
+ }>;
100
+ status: import("drizzle-orm/sqlite-core").SQLiteColumn<{
101
+ name: "status";
102
+ tableName: "agent_suggestions";
103
+ dataType: "string";
104
+ columnType: "SQLiteText";
105
+ data: string;
106
+ driverParam: string;
107
+ notNull: true;
108
+ hasDefault: true;
109
+ isPrimaryKey: false;
110
+ isAutoincrement: false;
111
+ hasRuntimeDefault: false;
112
+ enumValues: [string, ...string[]];
113
+ baseColumn: never;
114
+ identity: undefined;
115
+ generated: undefined;
116
+ }, {}, {
117
+ length: number | undefined;
118
+ }>;
119
+ payload: import("drizzle-orm/sqlite-core").SQLiteColumn<{
120
+ name: "payload";
121
+ tableName: "agent_suggestions";
122
+ dataType: "string";
123
+ columnType: "SQLiteText";
124
+ data: string;
125
+ driverParam: string;
126
+ notNull: true;
127
+ hasDefault: false;
128
+ isPrimaryKey: false;
129
+ isAutoincrement: false;
130
+ hasRuntimeDefault: false;
131
+ enumValues: [string, ...string[]];
132
+ baseColumn: never;
133
+ identity: undefined;
134
+ generated: undefined;
135
+ }, {}, {
136
+ length: number | undefined;
137
+ }>;
138
+ applied_commit_sha: import("drizzle-orm/sqlite-core").SQLiteColumn<{
139
+ name: "applied_commit_sha";
140
+ tableName: "agent_suggestions";
141
+ dataType: "string";
142
+ columnType: "SQLiteText";
143
+ data: string;
144
+ driverParam: string;
145
+ notNull: false;
146
+ hasDefault: false;
147
+ isPrimaryKey: false;
148
+ isAutoincrement: false;
149
+ hasRuntimeDefault: false;
150
+ enumValues: [string, ...string[]];
151
+ baseColumn: never;
152
+ identity: undefined;
153
+ generated: undefined;
154
+ }, {}, {
155
+ length: number | undefined;
156
+ }>;
157
+ created_at: import("drizzle-orm/sqlite-core").SQLiteColumn<{
158
+ name: "created_at";
159
+ tableName: "agent_suggestions";
160
+ dataType: "string";
161
+ columnType: "SQLiteText";
162
+ data: string;
163
+ driverParam: string;
164
+ notNull: true;
165
+ hasDefault: false;
166
+ isPrimaryKey: false;
167
+ isAutoincrement: false;
168
+ hasRuntimeDefault: false;
169
+ enumValues: [string, ...string[]];
170
+ baseColumn: never;
171
+ identity: undefined;
172
+ generated: undefined;
173
+ }, {}, {
174
+ length: number | undefined;
175
+ }>;
176
+ updated_at: import("drizzle-orm/sqlite-core").SQLiteColumn<{
177
+ name: "updated_at";
178
+ tableName: "agent_suggestions";
179
+ dataType: "string";
180
+ columnType: "SQLiteText";
181
+ data: string;
182
+ driverParam: string;
183
+ notNull: true;
184
+ hasDefault: false;
185
+ isPrimaryKey: false;
186
+ isAutoincrement: false;
187
+ hasRuntimeDefault: false;
188
+ enumValues: [string, ...string[]];
189
+ baseColumn: never;
190
+ identity: undefined;
191
+ generated: undefined;
192
+ }, {}, {
193
+ length: number | undefined;
194
+ }>;
195
+ };
196
+ dialect: "sqlite";
197
+ }>;
198
+ export type AgentSuggestion = typeof agent_suggestions.$inferSelect;
199
+ export type NewAgentSuggestion = typeof agent_suggestions.$inferInsert;