@crewx/sdk 0.9.0-rc.12 → 0.9.0-rc.120

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 (252) hide show
  1. package/README.md +1 -1
  2. package/dist/account/auth-client.d.ts +61 -0
  3. package/dist/account/auth-json-v2.d.ts +1 -0
  4. package/dist/account/auth-json.d.ts +30 -0
  5. package/dist/account/config.d.ts +37 -0
  6. package/dist/account/env-bootstrap.d.ts +11 -0
  7. package/dist/account/errors.d.ts +24 -0
  8. package/dist/account/index.d.ts +12 -0
  9. package/dist/account/index.js +2 -0
  10. package/dist/account/session-manager.d.ts +47 -0
  11. package/dist/activity-log/builder.d.ts +56 -6
  12. package/dist/agent/agent-list-view.d.ts +19 -0
  13. package/dist/boxing/box.types.d.ts +4 -0
  14. package/dist/config/canonicalize-agent-options.d.ts +18 -0
  15. package/dist/config/default-agent-models.d.ts +11 -0
  16. package/dist/config/global-settings.d.ts +33 -0
  17. package/dist/config/migrate-grok-mode.d.ts +6 -0
  18. package/dist/config/model-compat.d.ts +31 -0
  19. package/dist/config/models.generated.d.ts +37 -0
  20. package/dist/config/models.remote.d.ts +1 -0
  21. package/dist/config/overdrive.d.ts +7 -0
  22. package/dist/config/pricing.d.ts +6 -3
  23. package/dist/config/pricing.generated.d.ts +4 -0
  24. package/dist/config/pricing.types.d.ts +4 -0
  25. package/dist/config/timeout.config.d.ts +4 -0
  26. package/dist/config/wi-boards.d.ts +19 -0
  27. package/dist/context-budget/continuity.d.ts +61 -0
  28. package/dist/context-budget/index.d.ts +141 -0
  29. package/dist/conversation/index.d.ts +1 -1
  30. package/dist/conversation/sqlite-provider.d.ts +6 -2
  31. package/dist/conversation/to-template-messages.d.ts +9 -0
  32. package/dist/conversation/types.d.ts +47 -1
  33. package/dist/desktop/command-runner.d.ts +4 -0
  34. package/dist/desktop/default-adapters.d.ts +4 -0
  35. package/dist/desktop/global-install.d.ts +19 -0
  36. package/dist/desktop/index.d.ts +3 -0
  37. package/dist/desktop/index.js +3 -0
  38. package/dist/desktop/install.d.ts +5 -0
  39. package/dist/desktop/lnk.d.ts +22 -0
  40. package/dist/desktop/manifest.d.ts +21 -0
  41. package/dist/desktop/types.d.ts +67 -0
  42. package/dist/desktop/version.d.ts +1 -0
  43. package/dist/desktop/windows-paths.d.ts +21 -0
  44. package/dist/desktop/wrapper.d.ts +18 -0
  45. package/dist/esm/account/index.js +2 -0
  46. package/dist/esm/desktop/index.js +3 -0
  47. package/dist/esm/index.js +700 -210
  48. package/dist/esm/plugins/index.js +292 -205
  49. package/dist/esm/process/index.js +1 -0
  50. package/dist/esm/publish/index.js +2 -0
  51. package/dist/esm/repository/index.js +363 -198
  52. package/dist/esm/skills/index.js +1 -0
  53. package/dist/esm/testing/index.js +1 -1
  54. package/dist/events/types.d.ts +9 -0
  55. package/dist/facade/Crewx.d.ts +56 -5
  56. package/dist/facade/task-ticket.d.ts +14 -0
  57. package/dist/highlight/thread-highlight-prompt.d.ts +2 -0
  58. package/dist/highlight/thread-highlighter.d.ts +326 -0
  59. package/dist/index.browser.d.ts +15 -1
  60. package/dist/index.browser.js +6 -2
  61. package/dist/index.d.ts +116 -17
  62. package/dist/index.js +700 -210
  63. package/dist/internal/console-decoder.d.ts +38 -0
  64. package/dist/internal/windows-spawn.d.ts +10 -0
  65. package/dist/layout/types.d.ts +18 -1
  66. package/dist/lifecycle/process-lease.d.ts +80 -0
  67. package/dist/lifecycle/process-owner.d.ts +20 -0
  68. package/dist/lifecycle/task-heartbeat.d.ts +41 -0
  69. package/dist/lifecycle/task-stop.d.ts +82 -0
  70. package/dist/lifecycle/update-admission.d.ts +45 -0
  71. package/dist/local-server/base-url.d.ts +18 -0
  72. package/dist/local-server/index.d.ts +8 -0
  73. package/dist/local-server/opencode.d.ts +8 -0
  74. package/dist/local-server/probe.d.ts +3 -0
  75. package/dist/local-server/runtime.d.ts +26 -0
  76. package/dist/local-server/types.d.ts +43 -0
  77. package/dist/mcp-app/apps-context.d.ts +5 -0
  78. package/dist/mcp-app/catalog.d.ts +7 -0
  79. package/dist/mcp-app/discovery.d.ts +108 -0
  80. package/dist/mcp-app/errors.d.ts +7 -0
  81. package/dist/mcp-app/index.d.ts +20 -0
  82. package/dist/mcp-app/installed-app-ref.d.ts +25 -0
  83. package/dist/mcp-app/node-app-discovery-fs.d.ts +20 -0
  84. package/dist/mcp-app/projection.d.ts +13 -0
  85. package/dist/mcp-app/registry.d.ts +19 -0
  86. package/dist/mcp-app/skill-backend.d.ts +48 -0
  87. package/dist/mcp-app/state-set.d.ts +9 -0
  88. package/dist/mcp-app/types.d.ts +370 -0
  89. package/dist/mcp-app/workspace-snapshot.d.ts +61 -0
  90. package/dist/migrations/0008_careful_black_bird.sql +17 -0
  91. package/dist/migrations/0009_hot_dark_phoenix.sql +1 -0
  92. package/dist/migrations/0010_analyze_stats.sql +6 -0
  93. package/dist/migrations/0011_far_black_tarantula.sql +1 -0
  94. package/dist/migrations/0012_blue_turbo.sql +23 -0
  95. package/dist/migrations/0013_hesitant_adam_destine.sql +15 -0
  96. package/dist/migrations/0014_organic_mongu.sql +73 -0
  97. package/dist/migrations/0015_panoramic_gorilla_man.sql +71 -0
  98. package/dist/migrations/0016_fuzzy_hemingway.sql +14 -0
  99. package/dist/migrations/0017_project_stage_sdk_migration.sql +29 -0
  100. package/dist/migrations/0018_bored_jackal.sql +33 -0
  101. package/dist/migrations/0019_backfill_task_thread_ids.sql +74 -0
  102. package/dist/migrations/0020_useful_iron_lad.sql +55 -0
  103. package/dist/migrations/0021_dashing_peter_quill.sql +51 -0
  104. package/dist/migrations/0022_wandering_bucky.sql +1 -0
  105. package/dist/migrations/0023_red_payback.sql +1 -0
  106. package/dist/migrations/0024_storage_metadata.sql +262 -0
  107. package/dist/migrations/0025_task_heartbeat.sql +8 -0
  108. package/dist/migrations/0025_thread_app_instance_ledger.sql +2 -0
  109. package/dist/migrations/0026_mcp_action_source.sql +47 -0
  110. package/dist/migrations/0027_task_stop_scope_cleanup.sql +5 -0
  111. package/dist/migrations/0027_ui_instance_active_unique.sql +2 -0
  112. package/dist/migrations/0029_nice_rhino.sql +1 -0
  113. package/dist/migrations/0031_petite_arclight.sql +6 -0
  114. package/dist/migrations/0032_ui_instance_opened_by.sql +1 -0
  115. package/dist/migrations/meta/0008_snapshot.json +1327 -0
  116. package/dist/migrations/meta/0009_snapshot.json +1335 -0
  117. package/dist/migrations/meta/0010_snapshot.json +1335 -0
  118. package/dist/migrations/meta/0011_snapshot.json +1342 -0
  119. package/dist/migrations/meta/0012_snapshot.json +1494 -0
  120. package/dist/migrations/meta/0013_snapshot.json +1592 -0
  121. package/dist/migrations/meta/0014_snapshot.json +1975 -0
  122. package/dist/migrations/meta/0015_snapshot.json +2315 -0
  123. package/dist/migrations/meta/0016_snapshot.json +2419 -0
  124. package/dist/migrations/meta/0017_snapshot.json +2419 -0
  125. package/dist/migrations/meta/0018_snapshot.json +2570 -0
  126. package/dist/migrations/meta/0020_snapshot.json +2895 -0
  127. package/dist/migrations/meta/0021_snapshot.json +3031 -0
  128. package/dist/migrations/meta/0022_snapshot.json +3039 -0
  129. package/dist/migrations/meta/0023_snapshot.json +3047 -0
  130. package/dist/migrations/meta/0029_snapshot.json +3206 -0
  131. package/dist/migrations/meta/0031_snapshot.json +3251 -0
  132. package/dist/migrations/meta/_journal.json +176 -1
  133. package/dist/paths.d.ts +1 -0
  134. package/dist/plugin/types.d.ts +1 -0
  135. package/dist/plugins/index.d.ts +1 -1
  136. package/dist/plugins/index.js +292 -205
  137. package/dist/plugins/sqlite-tracing.d.ts +46 -0
  138. package/dist/process/index.d.ts +2 -0
  139. package/dist/process/index.js +1 -0
  140. package/dist/process/process-control.d.ts +41 -0
  141. package/dist/prompt/tag-names.d.ts +20 -0
  142. package/dist/provider/acp/connection.d.ts +6 -0
  143. package/dist/provider/acp/meta.d.ts +11 -0
  144. package/dist/provider/bridge.d.ts +7 -1
  145. package/dist/provider/classify-task-error.d.ts +2 -0
  146. package/dist/provider/cli/adapter.types.d.ts +14 -2
  147. package/dist/provider/cli/adapters/agent-call.util.d.ts +1 -1
  148. package/dist/provider/cli/adapters/cli-knob.util.d.ts +7 -0
  149. package/dist/provider/cli/adapters/codex-item.d.ts +1 -0
  150. package/dist/provider/cli/adapters/event-timestamp.util.d.ts +1 -0
  151. package/dist/provider/cli/adapters/grok.d.ts +2 -0
  152. package/dist/provider/cli/adapters/index.d.ts +5 -0
  153. package/dist/provider/cli/index.d.ts +3 -2
  154. package/dist/provider/cli/meta.d.ts +5 -0
  155. package/dist/provider/cli/protocol-envelope.d.ts +3 -0
  156. package/dist/provider/errors.d.ts +5 -1
  157. package/dist/provider/idle-watchdog.d.ts +19 -0
  158. package/dist/provider/models.d.ts +17 -12
  159. package/dist/provider/order.d.ts +1 -1
  160. package/dist/provider/parse-usage.d.ts +6 -0
  161. package/dist/provider/provider-selection.d.ts +8 -0
  162. package/dist/provider/redact-technical-message.d.ts +1 -0
  163. package/dist/provider/task-error.types.d.ts +17 -0
  164. package/dist/publish/constants.d.ts +6 -0
  165. package/dist/publish/errors.d.ts +7 -0
  166. package/dist/publish/index.d.ts +50 -0
  167. package/dist/publish/index.js +2 -0
  168. package/dist/publish/manifest.d.ts +47 -0
  169. package/dist/publish/marketplace-api.constants.d.ts +1 -0
  170. package/dist/publish/pack.d.ts +6 -0
  171. package/dist/publish/scan.d.ts +9 -0
  172. package/dist/publish/secrets.d.ts +6 -0
  173. package/dist/publish/upload.d.ts +19 -0
  174. package/dist/remote/execution-profile.d.ts +9 -0
  175. package/dist/remote/index.d.ts +1 -0
  176. package/dist/remote/types.d.ts +28 -0
  177. package/dist/repository/agent-suggestion.repository.d.ts +34 -0
  178. package/dist/repository/base-sqlite-repository.d.ts +1 -0
  179. package/dist/repository/common-code.repository.d.ts +45 -0
  180. package/dist/repository/db.d.ts +12 -1
  181. package/dist/repository/index.d.ts +38 -5
  182. package/dist/repository/index.js +363 -198
  183. package/dist/repository/notification.repository.d.ts +58 -0
  184. package/dist/repository/project.repository.d.ts +90 -0
  185. package/dist/repository/request-log.repository.d.ts +1 -0
  186. package/dist/repository/storage-metadata.repository.d.ts +64 -0
  187. package/dist/repository/task-log-migration.d.ts +74 -0
  188. package/dist/repository/task-log.repository.d.ts +44 -0
  189. package/dist/repository/task-status.d.ts +14 -0
  190. package/dist/repository/task.repository.d.ts +233 -7
  191. package/dist/repository/thread-history.repository.d.ts +193 -0
  192. package/dist/repository/thread-title.types.d.ts +29 -0
  193. package/dist/repository/thread.repository.d.ts +47 -5
  194. package/dist/repository/usage-backfill.d.ts +62 -0
  195. package/dist/repository/usage-from-logs.d.ts +21 -0
  196. package/dist/repository/usage-report.repository.d.ts +27 -0
  197. package/dist/repository/workspace.repository.d.ts +3 -0
  198. package/dist/schema/agent-suggestions.d.ts +199 -0
  199. package/dist/schema/common-codes.d.ts +216 -0
  200. package/dist/schema/index.d.ts +10 -0
  201. package/dist/schema/notifications.d.ts +303 -0
  202. package/dist/schema/projects.d.ts +610 -0
  203. package/dist/schema/storage-metadata.d.ts +181 -0
  204. package/dist/schema/task-log-events.d.ts +119 -0
  205. package/dist/schema/tasks.d.ts +165 -0
  206. package/dist/schema/thread-history.d.ts +734 -0
  207. package/dist/schema/threads.d.ts +59 -0
  208. package/dist/schema/ui-action-receipts.d.ts +303 -0
  209. package/dist/schema/ui-instances.d.ts +305 -0
  210. package/dist/schema/usage-reports.d.ts +252 -0
  211. package/dist/schema/workspaces.d.ts +17 -0
  212. package/dist/skills/index.d.ts +8 -0
  213. package/dist/skills/index.js +1 -0
  214. package/dist/skills/types.d.ts +18 -0
  215. package/dist/task-log/anchor-child-tasks.d.ts +7 -0
  216. package/dist/task-log/delegation-trailer.d.ts +34 -0
  217. package/dist/template/engine.d.ts +2 -2
  218. package/dist/template/helpers/exec.browser.d.ts +4 -3
  219. package/dist/template/helpers/exec.d.ts +4 -3
  220. package/dist/template/types.d.ts +20 -0
  221. package/dist/testing/index.js +1 -1
  222. package/dist/types/index.d.ts +1570 -3
  223. package/dist/types/task-log.types.d.ts +2 -0
  224. package/dist/ui-card/index.d.ts +2 -0
  225. package/dist/ui-card/legacy-card-parser.d.ts +11 -0
  226. package/dist/ui-instance/definition.d.ts +6 -0
  227. package/dist/ui-instance/errors.d.ts +17 -0
  228. package/dist/ui-instance/index.d.ts +9 -0
  229. package/dist/ui-instance/json.d.ts +8 -0
  230. package/dist/ui-instance/runtime.d.ts +18 -0
  231. package/dist/ui-instance/store.d.ts +109 -0
  232. package/dist/ui-instance/types.d.ts +224 -0
  233. package/dist/ui-plugin/index.d.ts +4 -0
  234. package/dist/ui-plugin/limits.d.ts +27 -0
  235. package/dist/ui-plugin/manifest.d.ts +3 -0
  236. package/dist/ui-plugin/types.d.ts +178 -0
  237. package/dist/ui-plugin/validator.d.ts +15 -0
  238. package/dist/utils/crewx-executable.d.ts +76 -0
  239. package/dist/utils/crewx-home.d.ts +1 -0
  240. package/dist/utils/env-defaults.d.ts +2 -0
  241. package/dist/utils/id.d.ts +1 -1
  242. package/dist/utils/runner-env.d.ts +3 -0
  243. package/dist/utils/timestamp.d.ts +1 -0
  244. package/dist/utils/workspace.d.ts +1 -0
  245. package/dist/wi/create.d.ts +48 -0
  246. package/dist/wi/select.d.ts +20 -0
  247. package/package.json +40 -2
  248. package/templates/agents/default.yaml +279 -127
  249. package/templates/documents/crewx-manual.md +138 -138
  250. package/templates/documents/crewx-quick-guide.md +1 -1
  251. package/templates/workflows/wi-default-flow.yaml +65 -0
  252. package/templates/workflows/wi-plan-flow.yaml +140 -0
@@ -1,20 +1,107 @@
1
1
  import { BaseSqliteRepository } from './base-sqlite-repository.js';
2
2
  import { tasks } from '../schema/index.js';
3
- export type TaskRow = typeof tasks.$inferSelect;
3
+ import type { TaskLogEntry, TaskLogReadResult, TaskLogState } from './task-log.repository.js';
4
+ import { type TaskStatus, type TaskTerminalReason } from './task-status.js';
5
+ import { type StopTaskOptions, type StopTaskGenerationForInstructionOptions, type StopTaskResult } from '../lifecycle/task-stop.js';
6
+ export { TASK_HEARTBEAT_HARD_STALE_MS, TASK_HEARTBEAT_INTERVAL_MS, TASK_HEARTBEAT_STALE_MS, resolveTaskHeartbeatHardStaleMs, resolveTaskHeartbeatIntervalMs, resolveTaskHeartbeatStaleMs, } from '../lifecycle/task-heartbeat.js';
7
+ type RawTaskRow = typeof tasks.$inferSelect;
8
+ export type TaskRow = Omit<RawTaskRow, 'status'> & {
9
+ status: TaskStatus;
10
+ };
4
11
  export type NewTask = typeof tasks.$inferInsert;
12
+ type TaskActorKind = NonNullable<NewTask['actor_kind']>;
13
+ export type TaskKillStatus = 'terminated' | 'not_found' | 'failed' | 'not_running';
14
+ export interface TaskKillResult {
15
+ status: TaskKillStatus;
16
+ killed: boolean;
17
+ pid?: number;
18
+ error?: string;
19
+ }
20
+ export interface TaskStopRequestResult {
21
+ accepted: boolean;
22
+ status: string | null;
23
+ runEpoch: number;
24
+ alreadyRequestedAt?: string;
25
+ }
26
+ export type TaskStopOrigin = 'http' | 'cli' | 'instruction' | 'workflow' | 'internal';
27
+ export interface TaskStopRequestContext {
28
+ origin?: TaskStopOrigin;
29
+ at?: string;
30
+ callerPid?: number;
31
+ callerTaskId?: string;
32
+ }
33
+ export type TaskStopMethod = 'cooperative' | 'forced';
34
+ export interface FinalizeTaskStopOptions {
35
+ id: string;
36
+ runEpoch: number;
37
+ completedAt?: string;
38
+ method: TaskStopMethod;
39
+ error?: string;
40
+ terminalReason?: TaskTerminalReason;
41
+ durationMs?: number | null;
42
+ }
43
+ export interface FinalizeTaskForHostShutdownOptions {
44
+ id: string;
45
+ expectedRunEpoch: number;
46
+ workspaceId?: string | null;
47
+ completedAt?: string;
48
+ }
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'>;
51
+ export type TaskActivityLogRow = Pick<TaskRow, 'id' | 'thread_id' | 'agent_id' | 'parent_task_id' | 'started_at' | 'completed_at'>;
52
+ export type FindTasksByThreadOptions = {
53
+ projection: 'activity-log';
54
+ };
55
+ export interface WorkflowCardRow {
56
+ taskId: string;
57
+ workflowRunId?: string;
58
+ raw?: string;
59
+ }
60
+ export interface WorkflowParentTaskRow {
61
+ id: string;
62
+ agent_id: string;
63
+ thread_id: string | null;
64
+ workspace_id: string | null;
65
+ platform: string | null;
66
+ status: string;
67
+ error: string | null;
68
+ completed_at: string | null;
69
+ duration_ms: number | null;
70
+ started_at: string;
71
+ metadata: string | null;
72
+ }
73
+ export type WorkflowParentTaskKind = 'workflow_card' | 'workflow_ui_instance';
74
+ export interface WorkflowParentTaskLookup {
75
+ workspaceId: string;
76
+ workflowRunId: string;
77
+ kind: WorkflowParentTaskKind;
78
+ }
79
+ export interface AgentProviderUsageRow {
80
+ provider: string;
81
+ inputTokens: number;
82
+ outputTokens: number;
83
+ cachedInputTokens: number;
84
+ totalTokens: number;
85
+ costUsd: number;
86
+ totalTasks: number;
87
+ unavailableTaskCount: number;
88
+ }
5
89
  export interface AgentUsageRow {
6
90
  agentId: string;
7
91
  workspaceId: string | null;
8
92
  totalTasks: number;
93
+ unavailableTaskCount?: number;
9
94
  inputTokens: number;
10
95
  outputTokens: number;
11
96
  cachedInputTokens: number;
12
97
  costUsd: number;
13
98
  totalTokens: number;
99
+ providers: AgentProviderUsageRow[];
14
100
  }
15
101
  export interface TrendRow {
16
102
  date: string;
17
103
  agentId: string;
104
+ unavailableTaskCount?: number;
18
105
  inputTokens: number;
19
106
  outputTokens: number;
20
107
  cachedInputTokens: number;
@@ -24,6 +111,7 @@ export interface TrendRow {
24
111
  export interface ProviderUsageRow {
25
112
  provider: string;
26
113
  totalTasks: number;
114
+ unavailableTaskCount?: number;
27
115
  inputTokens: number;
28
116
  outputTokens: number;
29
117
  cachedInputTokens: number;
@@ -36,6 +124,7 @@ export interface ModelUsageRow {
36
124
  model: string;
37
125
  provider: string;
38
126
  totalTasks: number;
127
+ unavailableTaskCount?: number;
39
128
  inputTokens: number;
40
129
  outputTokens: number;
41
130
  cachedInputTokens: number;
@@ -44,19 +133,84 @@ export interface ModelUsageRow {
44
133
  activeDurationMs: number;
45
134
  lastActiveAt: string | null;
46
135
  }
136
+ export interface ReportTaskRow {
137
+ threadId: string | null;
138
+ agentId: string;
139
+ startedAt: string;
140
+ status: string;
141
+ error: string | null;
142
+ exitCode: number | null;
143
+ }
144
+ export interface DelegationEdge {
145
+ callerAgentId: string | null;
146
+ agentId: string;
147
+ taskCount: number;
148
+ totalTokens: number;
149
+ outputTokens: number;
150
+ }
151
+ export interface DelegationMatrixResult {
152
+ edges: DelegationEdge[];
153
+ truncated: boolean;
154
+ }
155
+ export type TaskEvidenceRow = Pick<TaskRow, 'id' | 'agent_id' | 'status' | 'prompt' | 'started_at' | 'completed_at' | 'thread_id'>;
156
+ export interface ThreadChainTurn {
157
+ id: string;
158
+ agentId: string;
159
+ status: string;
160
+ prompt: string;
161
+ startedAt: string;
162
+ completedAt: string | null;
163
+ }
164
+ export interface ThreadChain {
165
+ threadId: string;
166
+ targetAgentTurnCount: number;
167
+ turns: ThreadChainTurn[];
168
+ }
169
+ export declare const HOST_SHUTDOWN_TERMINAL_ERROR = "Stopped by app shutdown";
170
+ type TaskUsageColumns = Pick<TaskRow, 'input_tokens' | 'output_tokens' | 'cached_input_tokens' | 'cost_usd'>;
171
+ export declare function mergeTerminalReason(metadataJson: string | null | undefined, reason: TaskTerminalReason): string;
172
+ export declare function hasRecordedUsage(task: TaskUsageColumns): boolean;
47
173
  export declare const PID_NULL_REAP_GRACE_MS: number;
174
+ export declare const PENDING_ADOPT_GRACE_MS: number;
175
+ export declare const DEFAULT_TASK_REAPER_TICK_INTERVAL_MS: number;
176
+ export interface ReapOrphanedTasksOptions {
177
+ tickIntervalMs?: number;
178
+ }
48
179
  export declare class TaskRepository extends BaseSqliteRepository {
49
180
  private readonly dbPath?;
181
+ private readonly clock;
182
+ private readonly taskLogRepository;
183
+ private lastReaperTickAt?;
50
184
  private readonly pidNullObservedSince;
51
185
  constructor(opts?: {
52
186
  dbPath?: string;
53
187
  dbRoot?: string;
188
+ clock?: () => number;
54
189
  });
55
190
  resolveDbPath(): string;
56
191
  private openHandle;
192
+ heartbeatTask(opts: {
193
+ id: string;
194
+ runEpoch: number;
195
+ }): boolean;
196
+ requestTaskStop(opts: {
197
+ id: string;
198
+ requestedAt: string;
199
+ origin?: TaskStopOrigin;
200
+ callerPid?: number;
201
+ callerTaskId?: string;
202
+ }): TaskStopRequestResult;
203
+ private requestTaskStopForInstruction;
204
+ finalizeTaskStop(opts: FinalizeTaskStopOptions): boolean;
205
+ finalizeTaskForHostShutdown(opts: FinalizeTaskForHostShutdownOptions): FinalizeTaskForHostShutdownOutcome;
206
+ stopTask(id: string, options?: StopTaskOptions): Promise<StopTaskResult>;
207
+ stopTaskGenerationForInstruction(options: StopTaskGenerationForInstructionOptions): Promise<StopTaskResult>;
57
208
  startTask(opts: {
58
209
  id: string;
59
210
  agentId: string;
211
+ actorKind?: TaskActorKind | null;
212
+ actorId?: string | null;
213
+ userId?: string | null;
60
214
  prompt: string;
61
215
  mode: string;
62
216
  status: string;
@@ -68,6 +222,8 @@ export declare class TaskRepository extends BaseSqliteRepository {
68
222
  command?: string | null;
69
223
  metadata?: string | null;
70
224
  workspaceId?: string | null;
225
+ cwd?: string | null;
226
+ projectId?: string | null;
71
227
  platform?: string | null;
72
228
  crewxVersion?: string | null;
73
229
  threadId?: string | null;
@@ -75,6 +231,22 @@ export declare class TaskRepository extends BaseSqliteRepository {
75
231
  renderedPrompt?: string | null;
76
232
  codingAgentCommand?: string | null;
77
233
  }): void;
234
+ updateTaskOwnership(opts: {
235
+ id: string;
236
+ runEpoch: number;
237
+ ownership: 'runner' | 'caller';
238
+ providerPid?: number | null;
239
+ runtime?: {
240
+ model?: string | null;
241
+ renderedPrompt?: string | null;
242
+ codingAgentCommand?: string | null;
243
+ metadata?: Record<string, unknown>;
244
+ };
245
+ }): boolean;
246
+ adoptPendingTask(id: string): boolean;
247
+ failPendingTask(id: string, error: string, completedAt?: string): boolean;
248
+ stopPendingTask(id: string, error?: string, completedAt?: string, stopRequest?: TaskStopRequestContext): boolean;
249
+ listTasksByProjectId(projectId: string): TaskRow[];
78
250
  finishTask(opts: {
79
251
  id: string;
80
252
  status: string;
@@ -89,20 +261,33 @@ export declare class TaskRepository extends BaseSqliteRepository {
89
261
  costUsd?: number;
90
262
  model?: string | null;
91
263
  runEpoch?: number | null;
264
+ partialResultRecovered?: boolean;
265
+ }): void;
266
+ updateTaskLifecycle(opts: {
267
+ id: string;
268
+ status: TaskStatus;
269
+ error: string | null;
270
+ completedAt: string | null;
271
+ durationMs: number | null;
272
+ workspaceId: string;
273
+ terminalReason?: TaskTerminalReason;
92
274
  }): void;
93
275
  appendLog(taskId: string, entry: {
94
276
  timestamp: string;
95
277
  level: string;
96
278
  message: string;
97
279
  }): void;
280
+ appendLogs(taskId: string, entries: readonly TaskLogEntry[]): void;
281
+ readLogs(taskId: string): TaskLogReadResult | undefined;
282
+ readLogsTail(taskId: string, limit: number): TaskLogReadResult | undefined;
283
+ getLogState(taskId: string): TaskLogState | undefined;
98
284
  getRunningTasks(): TaskRow[];
285
+ getActiveTasks(): TaskRow[];
99
286
  getAllTasks(): TaskRow[];
100
287
  getTask(id: string): TaskRow | undefined;
101
- killTask(id: string): {
102
- killed: boolean;
103
- pid?: number;
104
- };
105
- reapOrphanedTasks(): number;
288
+ killTask(id: string): Promise<TaskKillResult>;
289
+ reapOrphanedTasks(options?: ReapOrphanedTasksOptions): number;
290
+ reapRunningWorkflowTasks(graceMs?: number): number;
106
291
  findTaskStatus(taskId: string, workspaceId?: string): TaskRow | undefined;
107
292
  findChildTasks(parentTaskId: string, workspaceId?: string): TaskRow[];
108
293
  getWorkspaceUsageSummary(workspaceId?: string): Array<{
@@ -117,7 +302,14 @@ export declare class TaskRepository extends BaseSqliteRepository {
117
302
  outputTokens: number;
118
303
  costUsd: number;
119
304
  };
305
+ findTasksByThread(threadId: string, workspaceId: string | undefined, options: FindTasksByThreadOptions): TaskActivityLogRow[];
120
306
  findTasksByThread(threadId: string, workspaceId?: string): TaskRow[];
307
+ private parseWorkflowCardMetadata;
308
+ private extractThreadIdFromCommand;
309
+ findRunningWorkflowParentTasks(): WorkflowParentTaskRow[];
310
+ findWorkflowParentTasksByWorkspace(workspaceId: string): WorkflowParentTaskRow[];
311
+ findWorkflowParentTask(opts: WorkflowParentTaskLookup): WorkflowParentTaskRow | undefined;
312
+ batchFetchWorkflowCards(threadIds: string[], workspaceId?: string): Map<string, WorkflowCardRow>;
121
313
  findAllTasks(params: {
122
314
  workspaceId?: string;
123
315
  agentId?: string;
@@ -138,8 +330,42 @@ export declare class TaskRepository extends BaseSqliteRepository {
138
330
  getAgentUsage(from: string, to: string, workspace?: string): AgentUsageRow[];
139
331
  getAgentUsageTrendRaw(from: string, to: string, workspace?: string): TrendRow[];
140
332
  findTaskForStop(taskId: string, workspaceId: string): TaskRow | undefined;
141
- markTaskFailed(taskId: string, error: string, workspaceId?: string): void;
333
+ findLatestTaskByMetadata(opts: {
334
+ agentId: string;
335
+ workspaceId: string;
336
+ metaKey: string;
337
+ metaValue: string;
338
+ }): {
339
+ id: string;
340
+ thread_id: string | null;
341
+ status: string;
342
+ result: string | null;
343
+ error: string | null;
344
+ started_at: string;
345
+ completed_at: string | null;
346
+ metadata: string | null;
347
+ } | null;
348
+ markTaskFailed(taskId: string, error: string, workspaceId?: string, status?: TaskStatus, terminalReason?: TaskTerminalReason): void;
142
349
  findTasksByPromptHint(hint: string, workspaceId?: string): TaskRow[];
143
350
  getProviderUsage(from: string, to: string, workspace?: string): ProviderUsageRow[];
144
351
  getModelUsage(from: string, to: string, workspace?: string): ModelUsageRow[];
352
+ getTasksForReport(from: string, to: string, workspace?: string): ReportTaskRow[];
353
+ getDelegationMatrix(from: string, to: string, workspace?: string): DelegationMatrixResult;
354
+ findTaskEvidence(params: {
355
+ workspaceId?: string;
356
+ agents?: string[];
357
+ statuses?: string[];
358
+ from?: string;
359
+ to?: string;
360
+ limit?: number;
361
+ order?: 'ASC' | 'DESC';
362
+ }): TaskEvidenceRow[];
363
+ findThreadChains(params: {
364
+ targetAgentId: string;
365
+ workspaceId?: string;
366
+ from?: string;
367
+ to?: string;
368
+ maxThreads?: number;
369
+ maxTurnsPerThread?: number;
370
+ }): ThreadChain[];
145
371
  }
@@ -0,0 +1,193 @@
1
+ import { BaseSqliteRepository } from './base-sqlite-repository.js';
2
+ import { RepositoryError } from './errors.js';
3
+ import type { ThreadActorType, ThreadEvent, ThreadHighlight, ThreadHighlightKind, ThreadHighlightRun, ThreadHighlightSource } from '../schema/index.js';
4
+ import type { ThreadPriority, ThreadState } from './thread-title.types.js';
5
+ export interface ThreadActorInput {
6
+ actorType?: ThreadActorType;
7
+ actorId?: string | null;
8
+ actor?: {
9
+ actorType?: ThreadActorType;
10
+ actorId?: string | null;
11
+ };
12
+ }
13
+ export interface ThreadSnapshotMutationInput extends ThreadActorInput {
14
+ threadId: string;
15
+ workspaceId?: string | null;
16
+ title?: string | null;
17
+ priority?: ThreadPriority | null;
18
+ state?: ThreadState | null;
19
+ taskId?: string | null;
20
+ }
21
+ export interface ThreadSnapshot {
22
+ threadId: string;
23
+ workspaceId: string | null;
24
+ title: string | null;
25
+ priority: ThreadPriority | null;
26
+ state: ThreadState | null;
27
+ metadata: string | null;
28
+ titleLocked: boolean;
29
+ updatedAt: string;
30
+ }
31
+ export interface ThreadTimelineOptions {
32
+ beforeSeq?: number;
33
+ afterSeq?: number;
34
+ limit?: number;
35
+ }
36
+ export interface ThreadTimelineQuery extends ThreadTimelineOptions {
37
+ threadId: string;
38
+ workspaceId: string;
39
+ }
40
+ export interface ThreadTimeline {
41
+ items: ThreadEvent[];
42
+ latestSeq: number;
43
+ hasMoreOlder: boolean;
44
+ }
45
+ export interface CreateThreadHighlightInput extends ThreadActorInput {
46
+ threadId: string;
47
+ workspaceId: string;
48
+ source?: ThreadHighlightSource;
49
+ kind: ThreadHighlightKind;
50
+ text: string;
51
+ taskId?: string;
52
+ coversFromTaskId?: string;
53
+ coversToTaskId?: string;
54
+ fromTaskId?: string;
55
+ toTaskId?: string;
56
+ agentId?: string | null;
57
+ sourceTaskId?: string | null;
58
+ detectorVersion?: string | null;
59
+ contentFingerprint?: string | null;
60
+ idempotencyKey?: string;
61
+ id?: string;
62
+ }
63
+ export interface UpdateThreadHighlightInput extends ThreadActorInput {
64
+ threadId: string;
65
+ workspaceId: string;
66
+ highlightId: string;
67
+ expectedRevision: number;
68
+ text?: string;
69
+ kind?: ThreadHighlightKind;
70
+ coversFromTaskId?: string;
71
+ coversToTaskId?: string;
72
+ }
73
+ export interface DismissThreadHighlightInput extends ThreadActorInput {
74
+ threadId: string;
75
+ workspaceId: string;
76
+ highlightId: string;
77
+ expectedRevision: number;
78
+ }
79
+ export interface ListActiveHighlightsOptions {
80
+ taskId?: string;
81
+ coversFromTaskId?: string;
82
+ coversToTaskId?: string;
83
+ }
84
+ export interface ThreadHighlightEligibleTurn {
85
+ taskId: string;
86
+ prompt: string;
87
+ result: string;
88
+ status: string;
89
+ startedAt: string;
90
+ completedAt: string | null;
91
+ }
92
+ export interface CreateThreadHighlightRegenerationRunInput extends ThreadActorInput {
93
+ threadId: string;
94
+ workspaceId: string;
95
+ requestId: string;
96
+ detectorVersion: string;
97
+ runId?: string;
98
+ }
99
+ export interface CreateThreadHighlightRegenerationRunResult {
100
+ run: ThreadHighlightRun;
101
+ created: boolean;
102
+ }
103
+ export interface FailThreadHighlightRegenerationRunInput extends ThreadActorInput {
104
+ runId: string;
105
+ workspaceId?: string;
106
+ errorCode: string;
107
+ }
108
+ export interface ThreadHighlightRegenerationCandidate {
109
+ kind: ThreadHighlightKind;
110
+ text: string;
111
+ anchorTaskId: string;
112
+ coversFromTaskId: string;
113
+ coversToTaskId: string;
114
+ contentFingerprint?: string;
115
+ }
116
+ export interface CompleteThreadHighlightRegenerationInput extends ThreadActorInput {
117
+ runId: string;
118
+ threadId: string;
119
+ workspaceId: string;
120
+ detectorVersion: string;
121
+ agentId?: string | null;
122
+ candidates: readonly ThreadHighlightRegenerationCandidate[];
123
+ }
124
+ export interface CompleteThreadHighlightRegenerationResult {
125
+ run: ThreadHighlightRun;
126
+ deletedCount: number;
127
+ createdCount: number;
128
+ previousAutoCount: number;
129
+ newAutoCount: number;
130
+ }
131
+ export declare const THREAD_HIGHLIGHT_DELETION_REASON_REGENERATION_REPLACED: "regeneration_replaced";
132
+ export type ThreadHighlightDeletionReason = typeof THREAD_HIGHLIGHT_DELETION_REASON_REGENERATION_REPLACED;
133
+ export declare const THREAD_HIGHLIGHT_REGENERATION_NO_ELIGIBLE_TURNS: "THREAD_HIGHLIGHT_REGENERATION_NO_ELIGIBLE_TURNS";
134
+ export declare const THREAD_HIGHLIGHT_REGENERATION_INTERRUPTED: "THREAD_HIGHLIGHT_REGENERATION_INTERRUPTED";
135
+ export declare const THREAD_HIGHLIGHT_REGENERATION_DETECTION_FAILED: "THREAD_HIGHLIGHT_REGENERATION_DETECTION_FAILED";
136
+ export declare const THREAD_HIGHLIGHT_REGENERATION_COMMIT_FAILED: "THREAD_HIGHLIGHT_REGENERATION_COMMIT_FAILED";
137
+ export type ThreadHighlightRegenerationErrorCode = typeof THREAD_HIGHLIGHT_REGENERATION_NO_ELIGIBLE_TURNS | typeof THREAD_HIGHLIGHT_REGENERATION_INTERRUPTED | typeof THREAD_HIGHLIGHT_REGENERATION_DETECTION_FAILED | typeof THREAD_HIGHLIGHT_REGENERATION_COMMIT_FAILED | string;
138
+ export declare class ThreadHistoryConflictError extends RepositoryError {
139
+ readonly threadId: string;
140
+ readonly highlightId: string;
141
+ readonly expectedRevision: number;
142
+ readonly currentRevision: number;
143
+ constructor(threadId: string, highlightId: string, expectedRevision: number, currentRevision: number);
144
+ }
145
+ export declare class ThreadHighlightConflictError extends ThreadHistoryConflictError {
146
+ }
147
+ export declare class ThreadHighlightRegenerationConflictError extends RepositoryError {
148
+ readonly stableCode: "THREAD_HIGHLIGHT_REGENERATION_IN_PROGRESS";
149
+ readonly run: ThreadHighlightRun;
150
+ constructor(run: ThreadHighlightRun);
151
+ }
152
+ export declare class ThreadHistoryRepository extends BaseSqliteRepository {
153
+ private readonly dbPath?;
154
+ constructor(opts?: {
155
+ dbPath?: string;
156
+ dbRoot?: string;
157
+ });
158
+ resolveDbPath(): string;
159
+ private openHandle;
160
+ private findThread;
161
+ private findRegenerationRun;
162
+ resolveWorkspaceId(threadId: string): string | null;
163
+ getSnapshot(threadId: string, workspaceId?: string | null): ThreadSnapshot | null;
164
+ updateSnapshot(input: ThreadSnapshotMutationInput): ThreadSnapshot;
165
+ mutateSnapshot(input: ThreadSnapshotMutationInput): ThreadSnapshot;
166
+ updateThreadSnapshot(input: ThreadSnapshotMutationInput): ThreadSnapshot;
167
+ getLatestSeq(threadId: string, workspaceId?: string | null): number | null;
168
+ listCompletedThreadHighlightTurns(threadId: string, workspaceId: string): ThreadHighlightEligibleTurn[] | null;
169
+ createHighlightRegenerationRun(input: CreateThreadHighlightRegenerationRunInput): CreateThreadHighlightRegenerationRunResult;
170
+ beginHighlightRegenerationRun(input: CreateThreadHighlightRegenerationRunInput): CreateThreadHighlightRegenerationRunResult;
171
+ queueHighlightRegenerationRun(input: CreateThreadHighlightRegenerationRunInput): CreateThreadHighlightRegenerationRunResult;
172
+ getHighlightRegenerationRun(runId: string, workspaceId?: string): ThreadHighlightRun | null;
173
+ getHighlightRegenerationRunByRequest(threadId: string, workspaceId: string, requestId: string): ThreadHighlightRun | null;
174
+ findHighlightRegenerationRun(threadId: string, workspaceId: string, requestId: string): ThreadHighlightRun | null;
175
+ startHighlightRegenerationRun(runId: string, workspaceId?: string): ThreadHighlightRun;
176
+ startHighlightRegeneration(runId: string, workspaceId?: string): ThreadHighlightRun;
177
+ failHighlightRegenerationRun(input: FailThreadHighlightRegenerationRunInput): ThreadHighlightRun;
178
+ failHighlightRegeneration(input: FailThreadHighlightRegenerationRunInput): ThreadHighlightRun;
179
+ recoverInterruptedHighlightRegenerationRuns(errorCode?: string): number;
180
+ completeHighlightRegenerationRun(input: CompleteThreadHighlightRegenerationInput): CompleteThreadHighlightRegenerationResult;
181
+ completeHighlightRegeneration(input: CompleteThreadHighlightRegenerationInput): CompleteThreadHighlightRegenerationResult;
182
+ replaceAutoHighlightsAtomically(input: CompleteThreadHighlightRegenerationInput): CompleteThreadHighlightRegenerationResult;
183
+ listTimeline(query: ThreadTimelineQuery): ThreadTimeline | null;
184
+ listTimeline(threadId: string, workspaceId: string, options?: ThreadTimelineOptions): ThreadTimeline | null;
185
+ listEvents(threadId: string, workspaceId: string, options?: ThreadTimelineOptions): ThreadTimeline | null;
186
+ getTimeline(threadId: string, workspaceId: string, options?: ThreadTimelineOptions): ThreadTimeline | null;
187
+ createHighlight(input: CreateThreadHighlightInput): ThreadHighlight;
188
+ updateHighlight(input: UpdateThreadHighlightInput): ThreadHighlight;
189
+ dismissHighlight(input: DismissThreadHighlightInput): ThreadHighlight;
190
+ listActiveHighlights(threadId: string, workspaceId: string, options?: ListActiveHighlightsOptions): ThreadHighlight[] | null;
191
+ listHighlights(threadId: string, workspaceId: string, options?: ListActiveHighlightsOptions): ThreadHighlight[] | null;
192
+ getActiveHighlights(threadId: string, workspaceId: string, options?: ListActiveHighlightsOptions): ThreadHighlight[] | null;
193
+ }
@@ -0,0 +1,29 @@
1
+ export declare const THREAD_PRIORITIES: readonly ["urgent", "high", "medium", "low"];
2
+ export type ThreadPriority = (typeof THREAD_PRIORITIES)[number];
3
+ export declare const BUILTIN_THREAD_STATES: readonly ["investigating", "in-progress", "in-review", "on-hold", "done"];
4
+ export type BuiltinThreadState = (typeof BUILTIN_THREAD_STATES)[number];
5
+ export type StableThreadState = BuiltinThreadState | `c_${string}`;
6
+ export type LegacyThreadState = `custom:${string}`;
7
+ export type ThreadState = StableThreadState | LegacyThreadState;
8
+ export interface ThreadTitleMeta {
9
+ priority?: ThreadPriority;
10
+ state?: ThreadState;
11
+ }
12
+ export interface ThreadTitlePatch {
13
+ priority?: ThreadPriority | null;
14
+ state?: ThreadState | null;
15
+ }
16
+ export declare function isThreadPriority(value: unknown): value is ThreadPriority;
17
+ export declare function isThreadState(value: unknown): value is ThreadState;
18
+ export declare function customStateLabel(state: ThreadState): string | undefined;
19
+ export declare function hasThreadTitleKey(metadataJson: string | null | undefined): boolean;
20
+ export declare function readThreadTitleMeta(metadataJson: string | null | undefined): ThreadTitleMeta;
21
+ export declare function mergeThreadTitleMeta(metadataJson: string | null | undefined, patch: ThreadTitlePatch): string | null;
22
+ export declare function threadTitleSearchHaystack(meta: ThreadTitleMeta, labelNames?: ReadonlyMap<string, string>): string;
23
+ export interface ThreadTitleFilter {
24
+ values: Set<string>;
25
+ includeNone: boolean;
26
+ }
27
+ export declare function parseThreadPriorityFilter(raw: string | undefined): ThreadTitleFilter | undefined;
28
+ export declare function parseThreadStateFilter(raw: string | undefined): ThreadTitleFilter | undefined;
29
+ export declare function matchesThreadTitleFilter(current: string | undefined, filter: ThreadTitleFilter | undefined): boolean;
@@ -1,8 +1,35 @@
1
1
  import { BaseSqliteRepository } from './base-sqlite-repository.js';
2
+ import { RepositoryError } from './errors.js';
2
3
  import { threads } from '../schema/index.js';
3
- import type { TaskRow } from './task.repository.js';
4
+ import type { TaskRow, TaskListRow } from './task.repository.js';
4
5
  export type ThreadRow = typeof threads.$inferSelect;
5
6
  export type NewThread = typeof threads.$inferInsert;
7
+ export type ThreadActorKind = NonNullable<NewThread['created_by_kind']>;
8
+ export interface ThreadCreationOptions {
9
+ createdByKind?: ThreadActorKind | null;
10
+ createdById?: string | null;
11
+ createdByTaskId?: string | null;
12
+ }
13
+ export type ThreadOriginFilter = 'direct' | 'delegated' | 'all';
14
+ type ThreadOriginScope = Exclude<ThreadOriginFilter, 'all'>;
15
+ export interface ThreadOriginRow {
16
+ origin: 'direct' | 'delegated';
17
+ delegatedByAgentId: string | null;
18
+ }
19
+ export interface ThreadTitleMetadataPatch {
20
+ priority?: string | null;
21
+ state?: string | null;
22
+ }
23
+ export interface ThreadTitleMetadataPatchResult {
24
+ threadId: string;
25
+ priority: string | null;
26
+ state: string | null;
27
+ }
28
+ export type ThreadTitleMetadataPatchErrorReason = 'THREAD_TITLE_PATCH_EMPTY' | 'THREAD_TITLE_PATCH_INVALID';
29
+ export declare class ThreadTitleMetadataPatchError extends RepositoryError {
30
+ readonly reason: ThreadTitleMetadataPatchErrorReason;
31
+ constructor(reason: ThreadTitleMetadataPatchErrorReason, message?: string);
32
+ }
6
33
  export declare class ThreadRepository extends BaseSqliteRepository {
7
34
  private readonly dbPath?;
8
35
  constructor(opts?: {
@@ -13,7 +40,10 @@ export declare class ThreadRepository extends BaseSqliteRepository {
13
40
  private openHandle;
14
41
  private validateWorkspaceId;
15
42
  private topLevelTaskPredicateSql;
16
- findAllThreads(workspaceId?: string): ThreadRow[];
43
+ private findAllThreadsQuery;
44
+ findAllThreads(workspaceId?: string, createdByKind?: ThreadActorKind): ThreadRow[];
45
+ explainFindAllThreadsPlan(workspaceId?: string, createdByKind?: ThreadActorKind): string[];
46
+ findThreadsByIdsOrTitles(ids: string[], workspaceId?: string): ThreadRow[];
17
47
  findThreadById(threadId: string, workspaceId?: string): ThreadRow | undefined;
18
48
  threadExists(threadId: string, workspaceId?: string): boolean;
19
49
  aggregateTaskStats(threadId: string, workspaceId?: string): {
@@ -30,15 +60,25 @@ export declare class ThreadRepository extends BaseSqliteRepository {
30
60
  task: TaskRow;
31
61
  children: TaskRow[];
32
62
  } | undefined;
33
- batchFetchTasks(threadIds: string[], workspaceId?: string): Map<string, TaskRow[]>;
63
+ private batchFetchTasksQuery;
64
+ batchFetchTasks(threadIds: string[], workspaceId?: string): Map<string, TaskListRow[]>;
65
+ private findThreadOriginsQuery;
66
+ private findRecordedThreadOriginsQuery;
67
+ private findThreadsByOriginQuery;
68
+ private findLegacyThreadsQuery;
69
+ findThreadOrigins(threadIds: string[], workspaceId?: string): Map<string, ThreadOriginRow>;
70
+ findThreadsByOrigin(origin: ThreadOriginScope, workspaceId?: string): ThreadRow[];
71
+ explainBatchFetchTasksPlan(threadIds: string[], workspaceId?: string): string[];
72
+ explainFindThreadOriginsPlan(threadIds: string[], workspaceId?: string): string[];
73
+ explainFindThreadsByOriginPlan(origin: ThreadOriginScope, workspaceId?: string): string[];
34
74
  updateThreadTitle(threadId: string, title: string, workspaceId?: string): void;
35
75
  upsertThread(threadId: string, opts: {
36
76
  platform: string;
37
77
  workspaceId?: string;
38
78
  title?: string;
39
79
  titleLocked?: boolean;
40
- }): void;
41
- ensureThread(threadId: string, platform: string, workspaceId?: string): void;
80
+ } & ThreadCreationOptions): void;
81
+ ensureThread(threadId: string, platform: string, workspaceId?: string, creator?: ThreadCreationOptions): void;
42
82
  saveUserMessage(threadId: string, text: string, opts?: {
43
83
  platform?: string;
44
84
  model?: string;
@@ -56,6 +96,7 @@ export declare class ThreadRepository extends BaseSqliteRepository {
56
96
  title?: string;
57
97
  titleLocked?: boolean;
58
98
  }): void;
99
+ patchThreadTitleMetadata(threadId: string, patch: ThreadTitleMetadataPatch, workspaceId?: string): ThreadTitleMetadataPatchResult | ThreadTitleMetadataPatchError | null;
59
100
  togglePin(threadId: string, workspaceId?: string): {
60
101
  pinned: boolean;
61
102
  } | null;
@@ -75,3 +116,4 @@ export declare class ThreadRepository extends BaseSqliteRepository {
75
116
  remaining: number;
76
117
  } | null;
77
118
  }
119
+ export {};