@crewx/sdk 0.9.0-rc.15 → 0.9.0-rc.151

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 (293) 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 +59 -6
  12. package/dist/agent/agent-list-view.d.ts +19 -0
  13. package/dist/app/app.d.ts +148 -0
  14. package/dist/app/backend-env.d.ts +3 -0
  15. package/dist/app/content-media-types.d.ts +2 -0
  16. package/dist/app/context.d.ts +2 -0
  17. package/dist/app/entry.d.ts +7 -0
  18. package/dist/app/frame.d.ts +56 -0
  19. package/dist/app/index.d.ts +10 -0
  20. package/dist/app/index.js +10 -0
  21. package/dist/app/protocol.d.ts +9 -0
  22. package/dist/app/runtime.d.ts +21 -0
  23. package/dist/app/tool-mode.d.ts +3 -0
  24. package/dist/boxing/box.types.d.ts +4 -0
  25. package/dist/config/canonicalize-agent-options.d.ts +18 -0
  26. package/dist/config/default-agent-models.d.ts +11 -0
  27. package/dist/config/global-settings.d.ts +33 -0
  28. package/dist/config/migrate-grok-mode.d.ts +6 -0
  29. package/dist/config/model-compat.d.ts +31 -0
  30. package/dist/config/models.generated.d.ts +37 -0
  31. package/dist/config/models.remote.d.ts +1 -0
  32. package/dist/config/overdrive.d.ts +7 -0
  33. package/dist/config/pricing.d.ts +6 -3
  34. package/dist/config/pricing.generated.d.ts +4 -0
  35. package/dist/config/pricing.types.d.ts +4 -0
  36. package/dist/config/timeout.config.d.ts +4 -0
  37. package/dist/config/wi-boards.d.ts +19 -0
  38. package/dist/context-budget/continuity.d.ts +61 -0
  39. package/dist/context-budget/index.d.ts +141 -0
  40. package/dist/conversation/index.d.ts +1 -1
  41. package/dist/conversation/sqlite-provider.d.ts +6 -3
  42. package/dist/conversation/to-template-messages.d.ts +9 -0
  43. package/dist/conversation/types.d.ts +48 -1
  44. package/dist/desktop/command-runner.d.ts +4 -0
  45. package/dist/desktop/default-adapters.d.ts +4 -0
  46. package/dist/desktop/global-install.d.ts +19 -0
  47. package/dist/desktop/index.d.ts +3 -0
  48. package/dist/desktop/index.js +3 -0
  49. package/dist/desktop/install.d.ts +5 -0
  50. package/dist/desktop/lnk.d.ts +22 -0
  51. package/dist/desktop/manifest.d.ts +21 -0
  52. package/dist/desktop/types.d.ts +67 -0
  53. package/dist/desktop/version.d.ts +1 -0
  54. package/dist/desktop/windows-paths.d.ts +21 -0
  55. package/dist/desktop/wrapper.d.ts +18 -0
  56. package/dist/esm/account/index.js +2 -0
  57. package/dist/esm/app/index.js +10 -0
  58. package/dist/esm/desktop/index.js +3 -0
  59. package/dist/esm/index.js +1137 -226
  60. package/dist/esm/node/index.js +2 -0
  61. package/dist/esm/plugins/index.js +498 -216
  62. package/dist/esm/process/index.js +1 -0
  63. package/dist/esm/publish/index.js +2 -0
  64. package/dist/esm/repository/index.js +606 -209
  65. package/dist/esm/skills/index.js +2 -0
  66. package/dist/esm/testing/index.js +1 -1
  67. package/dist/events/types.d.ts +9 -0
  68. package/dist/facade/Crewx.d.ts +60 -5
  69. package/dist/facade/task-ticket.d.ts +14 -0
  70. package/dist/highlight/thread-highlight-prompt.d.ts +2 -0
  71. package/dist/highlight/thread-highlighter.d.ts +326 -0
  72. package/dist/index.browser.d.ts +17 -1
  73. package/dist/index.browser.js +6 -2
  74. package/dist/index.d.ts +127 -17
  75. package/dist/index.js +1137 -226
  76. package/dist/internal/console-decoder.d.ts +38 -0
  77. package/dist/internal/windows-spawn.d.ts +10 -0
  78. package/dist/layout/types.d.ts +18 -1
  79. package/dist/lifecycle/process-lease.d.ts +80 -0
  80. package/dist/lifecycle/process-owner.d.ts +20 -0
  81. package/dist/lifecycle/task-heartbeat.d.ts +41 -0
  82. package/dist/lifecycle/task-stop.d.ts +82 -0
  83. package/dist/lifecycle/update-admission.d.ts +45 -0
  84. package/dist/local-server/base-url.d.ts +18 -0
  85. package/dist/local-server/index.d.ts +8 -0
  86. package/dist/local-server/opencode.d.ts +8 -0
  87. package/dist/local-server/probe.d.ts +3 -0
  88. package/dist/local-server/runtime.d.ts +26 -0
  89. package/dist/local-server/types.d.ts +43 -0
  90. package/dist/mcp-app/agent-access.d.ts +26 -0
  91. package/dist/mcp-app/apps-context.d.ts +20 -0
  92. package/dist/mcp-app/bundle-provenance.d.ts +3 -0
  93. package/dist/mcp-app/candidate-registration.d.ts +4 -0
  94. package/dist/mcp-app/catalog.d.ts +7 -0
  95. package/dist/mcp-app/content-channel.d.ts +86 -0
  96. package/dist/mcp-app/content-declarations.d.ts +31 -0
  97. package/dist/mcp-app/dev-checks.d.ts +29 -0
  98. package/dist/mcp-app/diagnostic-reason.d.ts +3 -0
  99. package/dist/mcp-app/discovery.d.ts +161 -0
  100. package/dist/mcp-app/errors.d.ts +7 -0
  101. package/dist/mcp-app/index.d.ts +33 -0
  102. package/dist/mcp-app/installed-app-ref.d.ts +25 -0
  103. package/dist/mcp-app/model-context.d.ts +29 -0
  104. package/dist/mcp-app/node-app-discovery-fs.d.ts +23 -0
  105. package/dist/mcp-app/product-bundle-assets.d.ts +27 -0
  106. package/dist/mcp-app/product-bundle-loader.d.ts +53 -0
  107. package/dist/mcp-app/projection.d.ts +14 -0
  108. package/dist/mcp-app/registry.d.ts +28 -0
  109. package/dist/mcp-app/skill-backend.d.ts +132 -0
  110. package/dist/mcp-app/state-set.d.ts +9 -0
  111. package/dist/mcp-app/types.d.ts +472 -0
  112. package/dist/mcp-app/workspace-app-assets.d.ts +42 -0
  113. package/dist/mcp-app/workspace-app-scan-cache.d.ts +24 -0
  114. package/dist/mcp-app/workspace-snapshot.d.ts +71 -0
  115. package/dist/migrations/0011_far_black_tarantula.sql +1 -0
  116. package/dist/migrations/0012_blue_turbo.sql +23 -0
  117. package/dist/migrations/0013_hesitant_adam_destine.sql +15 -0
  118. package/dist/migrations/0014_organic_mongu.sql +73 -0
  119. package/dist/migrations/0015_panoramic_gorilla_man.sql +71 -0
  120. package/dist/migrations/0016_fuzzy_hemingway.sql +14 -0
  121. package/dist/migrations/0017_project_stage_sdk_migration.sql +29 -0
  122. package/dist/migrations/0018_bored_jackal.sql +33 -0
  123. package/dist/migrations/0019_backfill_task_thread_ids.sql +74 -0
  124. package/dist/migrations/0020_useful_iron_lad.sql +55 -0
  125. package/dist/migrations/0021_dashing_peter_quill.sql +51 -0
  126. package/dist/migrations/0022_wandering_bucky.sql +1 -0
  127. package/dist/migrations/0023_red_payback.sql +1 -0
  128. package/dist/migrations/0024_storage_metadata.sql +262 -0
  129. package/dist/migrations/0025_task_heartbeat.sql +8 -0
  130. package/dist/migrations/0025_thread_app_instance_ledger.sql +2 -0
  131. package/dist/migrations/0026_mcp_action_source.sql +47 -0
  132. package/dist/migrations/0027_task_stop_scope_cleanup.sql +5 -0
  133. package/dist/migrations/0027_ui_instance_active_unique.sql +2 -0
  134. package/dist/migrations/0029_nice_rhino.sql +1 -0
  135. package/dist/migrations/0031_petite_arclight.sql +6 -0
  136. package/dist/migrations/0032_ui_instance_opened_by.sql +1 -0
  137. package/dist/migrations/0033_thread_creator_boundary_guard.sql +38 -0
  138. package/dist/migrations/0034_keen_fallen_one.sql +36 -0
  139. package/dist/migrations/0035_request_log_daily.sql +11 -0
  140. package/dist/migrations/0036_ui_definition_archive.sql +8 -0
  141. package/dist/migrations/0037_ui_instance_agent_open_request.sql +1 -0
  142. package/dist/migrations/0038_task_rating.sql +3 -0
  143. package/dist/migrations/meta/0011_snapshot.json +1342 -0
  144. package/dist/migrations/meta/0012_snapshot.json +1494 -0
  145. package/dist/migrations/meta/0013_snapshot.json +1592 -0
  146. package/dist/migrations/meta/0014_snapshot.json +1975 -0
  147. package/dist/migrations/meta/0015_snapshot.json +2315 -0
  148. package/dist/migrations/meta/0016_snapshot.json +2419 -0
  149. package/dist/migrations/meta/0017_snapshot.json +2419 -0
  150. package/dist/migrations/meta/0018_snapshot.json +2570 -0
  151. package/dist/migrations/meta/0020_snapshot.json +2895 -0
  152. package/dist/migrations/meta/0021_snapshot.json +3031 -0
  153. package/dist/migrations/meta/0022_snapshot.json +3039 -0
  154. package/dist/migrations/meta/0023_snapshot.json +3047 -0
  155. package/dist/migrations/meta/0029_snapshot.json +3206 -0
  156. package/dist/migrations/meta/0031_snapshot.json +3251 -0
  157. package/dist/migrations/meta/0034_snapshot.json +3473 -0
  158. package/dist/migrations/meta/0035_snapshot.json +3547 -0
  159. package/dist/migrations/meta/0036_snapshot.json +3591 -0
  160. package/dist/migrations/meta/0037_snapshot.json +3598 -0
  161. package/dist/migrations/meta/0038_snapshot.json +3626 -0
  162. package/dist/migrations/meta/_journal.json +196 -0
  163. package/dist/node/index.d.ts +1 -0
  164. package/dist/node/index.js +2 -0
  165. package/dist/paths.d.ts +1 -0
  166. package/dist/plugin/types.d.ts +1 -0
  167. package/dist/plugins/index.d.ts +1 -1
  168. package/dist/plugins/index.js +498 -216
  169. package/dist/plugins/sqlite-tracing.d.ts +46 -0
  170. package/dist/process/index.d.ts +2 -0
  171. package/dist/process/index.js +1 -0
  172. package/dist/process/process-control.d.ts +41 -0
  173. package/dist/prompt/tag-names.d.ts +22 -0
  174. package/dist/provider/acp/connection.d.ts +6 -0
  175. package/dist/provider/acp/meta.d.ts +11 -0
  176. package/dist/provider/bridge.d.ts +7 -1
  177. package/dist/provider/classify-task-error.d.ts +2 -0
  178. package/dist/provider/cli/adapter.types.d.ts +14 -2
  179. package/dist/provider/cli/adapters/agent-call.util.d.ts +1 -1
  180. package/dist/provider/cli/adapters/cli-knob.util.d.ts +7 -0
  181. package/dist/provider/cli/adapters/codex-item.d.ts +1 -0
  182. package/dist/provider/cli/adapters/event-timestamp.util.d.ts +1 -0
  183. package/dist/provider/cli/adapters/grok.d.ts +2 -0
  184. package/dist/provider/cli/adapters/index.d.ts +5 -0
  185. package/dist/provider/cli/index.d.ts +3 -2
  186. package/dist/provider/cli/meta.d.ts +5 -0
  187. package/dist/provider/cli/protocol-envelope.d.ts +3 -0
  188. package/dist/provider/errors.d.ts +5 -1
  189. package/dist/provider/idle-watchdog.d.ts +19 -0
  190. package/dist/provider/models.d.ts +17 -12
  191. package/dist/provider/order.d.ts +1 -1
  192. package/dist/provider/parse-usage.d.ts +6 -0
  193. package/dist/provider/provider-selection.d.ts +8 -0
  194. package/dist/provider/redact-technical-message.d.ts +1 -0
  195. package/dist/provider/task-error.types.d.ts +17 -0
  196. package/dist/publish/constants.d.ts +6 -0
  197. package/dist/publish/errors.d.ts +7 -0
  198. package/dist/publish/index.d.ts +50 -0
  199. package/dist/publish/index.js +2 -0
  200. package/dist/publish/manifest.d.ts +47 -0
  201. package/dist/publish/marketplace-api.constants.d.ts +1 -0
  202. package/dist/publish/pack.d.ts +6 -0
  203. package/dist/publish/scan.d.ts +10 -0
  204. package/dist/publish/secrets.d.ts +6 -0
  205. package/dist/publish/upload.d.ts +19 -0
  206. package/dist/remote/execution-profile.d.ts +9 -0
  207. package/dist/remote/index.d.ts +1 -0
  208. package/dist/remote/types.d.ts +28 -0
  209. package/dist/repository/agent-suggestion.repository.d.ts +34 -0
  210. package/dist/repository/base-sqlite-repository.d.ts +1 -0
  211. package/dist/repository/common-code.repository.d.ts +45 -0
  212. package/dist/repository/db.d.ts +12 -1
  213. package/dist/repository/index.d.ts +43 -5
  214. package/dist/repository/index.js +606 -209
  215. package/dist/repository/logs-db.d.ts +12 -0
  216. package/dist/repository/notification.repository.d.ts +58 -0
  217. package/dist/repository/project.repository.d.ts +90 -0
  218. package/dist/repository/request-log-mover.d.ts +70 -0
  219. package/dist/repository/request-log.repository.d.ts +7 -3
  220. package/dist/repository/storage-metadata.repository.d.ts +64 -0
  221. package/dist/repository/task-log-migration.d.ts +74 -0
  222. package/dist/repository/task-log.repository.d.ts +44 -0
  223. package/dist/repository/task-status.d.ts +21 -0
  224. package/dist/repository/task.repository.d.ts +275 -7
  225. package/dist/repository/thread-history.repository.d.ts +193 -0
  226. package/dist/repository/thread-origin-verdict.d.ts +27 -0
  227. package/dist/repository/thread-title.types.d.ts +29 -0
  228. package/dist/repository/thread.repository.d.ts +115 -7
  229. package/dist/repository/usage-backfill.d.ts +62 -0
  230. package/dist/repository/usage-from-logs.d.ts +21 -0
  231. package/dist/repository/workspace.repository.d.ts +3 -0
  232. package/dist/schema/agent-suggestions.d.ts +199 -0
  233. package/dist/schema/common-codes.d.ts +216 -0
  234. package/dist/schema/index.d.ts +13 -0
  235. package/dist/schema/notifications.d.ts +303 -0
  236. package/dist/schema/projects.d.ts +610 -0
  237. package/dist/schema/request-log-daily.d.ts +151 -0
  238. package/dist/schema/storage-metadata.d.ts +181 -0
  239. package/dist/schema/task-log-events.d.ts +119 -0
  240. package/dist/schema/tasks.d.ts +203 -0
  241. package/dist/schema/thread-creator-unverified.d.ts +45 -0
  242. package/dist/schema/thread-history.d.ts +734 -0
  243. package/dist/schema/threads.d.ts +59 -0
  244. package/dist/schema/ui-action-receipts.d.ts +358 -0
  245. package/dist/schema/ui-definition-archive.d.ts +63 -0
  246. package/dist/schema/ui-instance-repins.d.ts +222 -0
  247. package/dist/schema/ui-instances.d.ts +324 -0
  248. package/dist/schema/workspaces.d.ts +17 -0
  249. package/dist/skills/index.d.ts +15 -0
  250. package/dist/skills/index.js +2 -0
  251. package/dist/skills/types.d.ts +18 -0
  252. package/dist/task-log/anchor-child-tasks.d.ts +7 -0
  253. package/dist/task-log/delegation-trailer.d.ts +34 -0
  254. package/dist/template/engine.d.ts +2 -2
  255. package/dist/template/helpers/exec.browser.d.ts +4 -3
  256. package/dist/template/helpers/exec.d.ts +4 -3
  257. package/dist/template/types.d.ts +20 -0
  258. package/dist/testing/index.js +1 -1
  259. package/dist/types/index.d.ts +1574 -3
  260. package/dist/types/task-log.types.d.ts +3 -0
  261. package/dist/ui-card/index.d.ts +2 -0
  262. package/dist/ui-card/legacy-card-parser.d.ts +11 -0
  263. package/dist/ui-instance/definition.d.ts +6 -0
  264. package/dist/ui-instance/errors.d.ts +18 -0
  265. package/dist/ui-instance/index.d.ts +11 -0
  266. package/dist/ui-instance/json.d.ts +19 -0
  267. package/dist/ui-instance/lineage.d.ts +24 -0
  268. package/dist/ui-instance/runtime.d.ts +18 -0
  269. package/dist/ui-instance/store.d.ts +210 -0
  270. package/dist/ui-instance/types.d.ts +327 -0
  271. package/dist/ui-plugin/app-manifest.d.ts +64 -0
  272. package/dist/ui-plugin/csp.d.ts +28 -0
  273. package/dist/ui-plugin/index.d.ts +6 -0
  274. package/dist/ui-plugin/limits.d.ts +27 -0
  275. package/dist/ui-plugin/manifest.d.ts +3 -0
  276. package/dist/ui-plugin/types.d.ts +203 -0
  277. package/dist/ui-plugin/validator.d.ts +18 -0
  278. package/dist/utils/crewx-executable.d.ts +76 -0
  279. package/dist/utils/crewx-home.d.ts +1 -0
  280. package/dist/utils/env-defaults.d.ts +3 -0
  281. package/dist/utils/id.d.ts +1 -1
  282. package/dist/utils/local-identity.d.ts +2 -0
  283. package/dist/utils/runner-env.d.ts +3 -0
  284. package/dist/utils/timestamp.d.ts +1 -0
  285. package/dist/utils/workspace.d.ts +1 -0
  286. package/dist/wi/create.d.ts +48 -0
  287. package/dist/wi/select.d.ts +20 -0
  288. package/package.json +57 -3
  289. package/templates/agents/default.yaml +296 -128
  290. package/templates/documents/crewx-manual.md +138 -138
  291. package/templates/documents/crewx-quick-guide.md +8 -7
  292. package/templates/workflows/wi-default-flow.yaml +65 -0
  293. package/templates/workflows/wi-plan-flow.yaml +140 -0
@@ -1,20 +1,111 @@
1
1
  import { BaseSqliteRepository } from './base-sqlite-repository.js';
2
+ import type { DrizzleDb } from './db.js';
3
+ import { RepositoryError } from './errors.js';
2
4
  import { tasks } from '../schema/index.js';
3
- export type TaskRow = typeof tasks.$inferSelect;
5
+ import type { TaskLogEntry, TaskLogReadResult, TaskLogState } from './task-log.repository.js';
6
+ import { type TaskStatus, type TaskTerminalReason } from './task-status.js';
7
+ import { type StopTaskOptions, type StopTaskGenerationForInstructionOptions, type StopTaskResult } from '../lifecycle/task-stop.js';
8
+ export { TASK_HEARTBEAT_HARD_STALE_MS, TASK_HEARTBEAT_INTERVAL_MS, TASK_HEARTBEAT_STALE_MS, resolveTaskHeartbeatHardStaleMs, resolveTaskHeartbeatIntervalMs, resolveTaskHeartbeatStaleMs, } from '../lifecycle/task-heartbeat.js';
9
+ type RawTaskRow = typeof tasks.$inferSelect;
10
+ export type TaskRow = Omit<RawTaskRow, 'status'> & {
11
+ status: TaskStatus;
12
+ };
4
13
  export type NewTask = typeof tasks.$inferInsert;
14
+ type TaskActorKind = NonNullable<NewTask['actor_kind']>;
15
+ export type TaskKillStatus = 'terminated' | 'not_found' | 'failed' | 'not_running';
16
+ export interface TaskKillResult {
17
+ status: TaskKillStatus;
18
+ killed: boolean;
19
+ pid?: number;
20
+ error?: string;
21
+ }
22
+ export interface TaskStopRequestResult {
23
+ accepted: boolean;
24
+ status: string | null;
25
+ runEpoch: number;
26
+ alreadyRequestedAt?: string;
27
+ }
28
+ export type TaskStopOrigin = 'http' | 'cli' | 'instruction' | 'workflow' | 'internal';
29
+ export interface TaskStopRequestContext {
30
+ origin?: TaskStopOrigin;
31
+ at?: string;
32
+ callerPid?: number;
33
+ callerTaskId?: string;
34
+ }
35
+ export type TaskStopMethod = 'cooperative' | 'forced';
36
+ export interface FinalizeTaskStopOptions {
37
+ id: string;
38
+ runEpoch: number;
39
+ completedAt?: string;
40
+ method: TaskStopMethod;
41
+ error?: string;
42
+ terminalReason?: TaskTerminalReason;
43
+ durationMs?: number | null;
44
+ }
45
+ export interface FinalizeTaskForHostShutdownOptions {
46
+ id: string;
47
+ expectedRunEpoch: number;
48
+ workspaceId?: string | null;
49
+ completedAt?: string;
50
+ }
51
+ export type FinalizeTaskForHostShutdownOutcome = 'settled' | 'not_running' | 'epoch_mismatch' | 'workspace_mismatch';
52
+ 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' | 'rating' | 'rated_at'> & {
53
+ terminalReason: TaskTerminalReason | null;
54
+ };
55
+ export type TaskActivityLogRow = Pick<TaskRow, 'id' | 'thread_id' | 'agent_id' | 'parent_task_id' | 'started_at' | 'completed_at'>;
56
+ export type FindTasksByThreadOptions = {
57
+ projection: 'activity-log';
58
+ };
59
+ export interface WorkflowCardRow {
60
+ taskId: string;
61
+ workflowRunId?: string;
62
+ raw?: string;
63
+ }
64
+ export interface WorkflowParentTaskRow {
65
+ id: string;
66
+ agent_id: string;
67
+ thread_id: string | null;
68
+ workspace_id: string | null;
69
+ platform: string | null;
70
+ status: string;
71
+ error: string | null;
72
+ completed_at: string | null;
73
+ duration_ms: number | null;
74
+ started_at: string;
75
+ metadata: string | null;
76
+ }
77
+ export type WorkflowParentTaskKind = 'workflow_card' | 'workflow_ui_instance';
78
+ export interface WorkflowParentTaskLookup {
79
+ workspaceId: string;
80
+ workflowRunId: string;
81
+ kind: WorkflowParentTaskKind;
82
+ }
83
+ export interface AgentProviderUsageRow {
84
+ provider: string;
85
+ inputTokens: number;
86
+ outputTokens: number;
87
+ cachedInputTokens: number;
88
+ totalTokens: number;
89
+ costUsd: number;
90
+ totalTasks: number;
91
+ unavailableTaskCount: number;
92
+ }
5
93
  export interface AgentUsageRow {
6
94
  agentId: string;
7
95
  workspaceId: string | null;
8
96
  totalTasks: number;
97
+ unavailableTaskCount?: number;
9
98
  inputTokens: number;
10
99
  outputTokens: number;
11
100
  cachedInputTokens: number;
12
101
  costUsd: number;
13
102
  totalTokens: number;
103
+ providers: AgentProviderUsageRow[];
14
104
  }
15
105
  export interface TrendRow {
16
106
  date: string;
17
107
  agentId: string;
108
+ unavailableTaskCount?: number;
18
109
  inputTokens: number;
19
110
  outputTokens: number;
20
111
  cachedInputTokens: number;
@@ -24,6 +115,7 @@ export interface TrendRow {
24
115
  export interface ProviderUsageRow {
25
116
  provider: string;
26
117
  totalTasks: number;
118
+ unavailableTaskCount?: number;
27
119
  inputTokens: number;
28
120
  outputTokens: number;
29
121
  cachedInputTokens: number;
@@ -36,6 +128,7 @@ export interface ModelUsageRow {
36
128
  model: string;
37
129
  provider: string;
38
130
  totalTasks: number;
131
+ unavailableTaskCount?: number;
39
132
  inputTokens: number;
40
133
  outputTokens: number;
41
134
  cachedInputTokens: number;
@@ -51,20 +144,80 @@ export interface ReportTaskRow {
51
144
  status: string;
52
145
  error: string | null;
53
146
  exitCode: number | null;
147
+ terminalReason: TaskTerminalReason | null;
148
+ }
149
+ export interface DelegationEdge {
150
+ callerAgentId: string | null;
151
+ agentId: string;
152
+ taskCount: number;
153
+ totalTokens: number;
154
+ outputTokens: number;
155
+ }
156
+ export interface DelegationMatrixResult {
157
+ edges: DelegationEdge[];
158
+ truncated: boolean;
159
+ }
160
+ export type TaskEvidenceRow = Pick<TaskRow, 'id' | 'agent_id' | 'status' | 'prompt' | 'started_at' | 'completed_at' | 'thread_id'> & {
161
+ terminalReason: TaskTerminalReason | null;
162
+ };
163
+ export interface ThreadChainTurn {
164
+ id: string;
165
+ agentId: string;
166
+ status: string;
167
+ prompt: string;
168
+ startedAt: string;
169
+ completedAt: string | null;
54
170
  }
171
+ export interface ThreadChain {
172
+ threadId: string;
173
+ targetAgentTurnCount: number;
174
+ turns: ThreadChainTurn[];
175
+ }
176
+ export declare const HOST_SHUTDOWN_TERMINAL_ERROR = "Stopped by app shutdown";
177
+ type TaskUsageColumns = Pick<TaskRow, 'input_tokens' | 'output_tokens' | 'cached_input_tokens' | 'cost_usd'>;
178
+ export declare function mergeTerminalReason(metadataJson: string | null | undefined, reason: TaskTerminalReason): string;
179
+ export declare function hasRecordedUsage(task: TaskUsageColumns): boolean;
55
180
  export declare const PID_NULL_REAP_GRACE_MS: number;
181
+ export declare const PENDING_ADOPT_GRACE_MS: number;
182
+ export declare const DEFAULT_TASK_REAPER_TICK_INTERVAL_MS: number;
183
+ export interface ReapOrphanedTasksOptions {
184
+ tickIntervalMs?: number;
185
+ }
56
186
  export declare class TaskRepository extends BaseSqliteRepository {
57
187
  private readonly dbPath?;
188
+ private readonly clock;
189
+ private readonly taskLogRepository;
190
+ private lastReaperTickAt?;
58
191
  private readonly pidNullObservedSince;
59
192
  constructor(opts?: {
60
193
  dbPath?: string;
61
194
  dbRoot?: string;
195
+ clock?: () => number;
62
196
  });
63
197
  resolveDbPath(): string;
64
198
  private openHandle;
199
+ heartbeatTask(opts: {
200
+ id: string;
201
+ runEpoch: number;
202
+ }): boolean;
203
+ requestTaskStop(opts: {
204
+ id: string;
205
+ requestedAt: string;
206
+ origin?: TaskStopOrigin;
207
+ callerPid?: number;
208
+ callerTaskId?: string;
209
+ }): TaskStopRequestResult;
210
+ private requestTaskStopForInstruction;
211
+ finalizeTaskStop(opts: FinalizeTaskStopOptions): boolean;
212
+ finalizeTaskForHostShutdown(opts: FinalizeTaskForHostShutdownOptions): FinalizeTaskForHostShutdownOutcome;
213
+ stopTask(id: string, options?: StopTaskOptions): Promise<StopTaskResult>;
214
+ stopTaskGenerationForInstruction(options: StopTaskGenerationForInstructionOptions): Promise<StopTaskResult>;
65
215
  startTask(opts: {
66
216
  id: string;
67
217
  agentId: string;
218
+ actorKind?: TaskActorKind | null;
219
+ actorId?: string | null;
220
+ userId?: string | null;
68
221
  prompt: string;
69
222
  mode: string;
70
223
  status: string;
@@ -76,6 +229,8 @@ export declare class TaskRepository extends BaseSqliteRepository {
76
229
  command?: string | null;
77
230
  metadata?: string | null;
78
231
  workspaceId?: string | null;
232
+ cwd?: string | null;
233
+ projectId?: string | null;
79
234
  platform?: string | null;
80
235
  crewxVersion?: string | null;
81
236
  threadId?: string | null;
@@ -83,6 +238,22 @@ export declare class TaskRepository extends BaseSqliteRepository {
83
238
  renderedPrompt?: string | null;
84
239
  codingAgentCommand?: string | null;
85
240
  }): void;
241
+ updateTaskOwnership(opts: {
242
+ id: string;
243
+ runEpoch: number;
244
+ ownership: 'runner' | 'caller';
245
+ providerPid?: number | null;
246
+ runtime?: {
247
+ model?: string | null;
248
+ renderedPrompt?: string | null;
249
+ codingAgentCommand?: string | null;
250
+ metadata?: Record<string, unknown>;
251
+ };
252
+ }): boolean;
253
+ adoptPendingTask(id: string): boolean;
254
+ failPendingTask(id: string, error: string, completedAt?: string): boolean;
255
+ stopPendingTask(id: string, error?: string, completedAt?: string, stopRequest?: TaskStopRequestContext): boolean;
256
+ listTasksByProjectId(projectId: string): TaskRow[];
86
257
  finishTask(opts: {
87
258
  id: string;
88
259
  status: string;
@@ -97,20 +268,33 @@ export declare class TaskRepository extends BaseSqliteRepository {
97
268
  costUsd?: number;
98
269
  model?: string | null;
99
270
  runEpoch?: number | null;
271
+ partialResultRecovered?: boolean;
272
+ }): void;
273
+ updateTaskLifecycle(opts: {
274
+ id: string;
275
+ status: TaskStatus;
276
+ error: string | null;
277
+ completedAt: string | null;
278
+ durationMs: number | null;
279
+ workspaceId: string;
280
+ terminalReason?: TaskTerminalReason;
100
281
  }): void;
101
282
  appendLog(taskId: string, entry: {
102
283
  timestamp: string;
103
284
  level: string;
104
285
  message: string;
105
286
  }): void;
287
+ appendLogs(taskId: string, entries: readonly TaskLogEntry[]): void;
288
+ readLogs(taskId: string): TaskLogReadResult | undefined;
289
+ readLogsTail(taskId: string, limit: number): TaskLogReadResult | undefined;
290
+ getLogState(taskId: string): TaskLogState | undefined;
106
291
  getRunningTasks(): TaskRow[];
292
+ getActiveTasks(): TaskRow[];
107
293
  getAllTasks(): TaskRow[];
108
294
  getTask(id: string): TaskRow | undefined;
109
- killTask(id: string): {
110
- killed: boolean;
111
- pid?: number;
112
- };
113
- reapOrphanedTasks(): number;
295
+ killTask(id: string): Promise<TaskKillResult>;
296
+ reapOrphanedTasks(options?: ReapOrphanedTasksOptions): number;
297
+ reapRunningWorkflowTasks(graceMs?: number): number;
114
298
  findTaskStatus(taskId: string, workspaceId?: string): TaskRow | undefined;
115
299
  findChildTasks(parentTaskId: string, workspaceId?: string): TaskRow[];
116
300
  getWorkspaceUsageSummary(workspaceId?: string): Array<{
@@ -125,7 +309,14 @@ export declare class TaskRepository extends BaseSqliteRepository {
125
309
  outputTokens: number;
126
310
  costUsd: number;
127
311
  };
312
+ findTasksByThread(threadId: string, workspaceId: string | undefined, options: FindTasksByThreadOptions): TaskActivityLogRow[];
128
313
  findTasksByThread(threadId: string, workspaceId?: string): TaskRow[];
314
+ private parseWorkflowCardMetadata;
315
+ private extractThreadIdFromCommand;
316
+ findRunningWorkflowParentTasks(): WorkflowParentTaskRow[];
317
+ findWorkflowParentTasksByWorkspace(workspaceId: string): WorkflowParentTaskRow[];
318
+ findWorkflowParentTask(opts: WorkflowParentTaskLookup): WorkflowParentTaskRow | undefined;
319
+ batchFetchWorkflowCards(threadIds: string[], workspaceId?: string): Map<string, WorkflowCardRow>;
129
320
  findAllTasks(params: {
130
321
  workspaceId?: string;
131
322
  agentId?: string;
@@ -146,9 +337,86 @@ export declare class TaskRepository extends BaseSqliteRepository {
146
337
  getAgentUsage(from: string, to: string, workspace?: string): AgentUsageRow[];
147
338
  getAgentUsageTrendRaw(from: string, to: string, workspace?: string): TrendRow[];
148
339
  findTaskForStop(taskId: string, workspaceId: string): TaskRow | undefined;
149
- markTaskFailed(taskId: string, error: string, workspaceId?: string): void;
340
+ findLatestTaskByMetadata(opts: {
341
+ agentId: string;
342
+ workspaceId: string;
343
+ metaKey: string;
344
+ metaValue: string;
345
+ }): {
346
+ id: string;
347
+ thread_id: string | null;
348
+ status: string;
349
+ result: string | null;
350
+ error: string | null;
351
+ started_at: string;
352
+ completed_at: string | null;
353
+ metadata: string | null;
354
+ } | null;
355
+ markTaskFailed(taskId: string, error: string, workspaceId?: string, status?: TaskStatus, terminalReason?: TaskTerminalReason): void;
150
356
  findTasksByPromptHint(hint: string, workspaceId?: string): TaskRow[];
151
357
  getProviderUsage(from: string, to: string, workspace?: string): ProviderUsageRow[];
152
358
  getModelUsage(from: string, to: string, workspace?: string): ModelUsageRow[];
153
359
  getTasksForReport(from: string, to: string, workspace?: string): ReportTaskRow[];
360
+ getDelegationMatrix(from: string, to: string, workspace?: string): DelegationMatrixResult;
361
+ findTaskEvidence(params: {
362
+ workspaceId?: string;
363
+ agents?: string[];
364
+ statuses?: string[];
365
+ from?: string;
366
+ to?: string;
367
+ limit?: number;
368
+ order?: 'ASC' | 'DESC';
369
+ }): TaskEvidenceRow[];
370
+ findThreadChains(params: {
371
+ targetAgentId: string;
372
+ workspaceId?: string;
373
+ from?: string;
374
+ to?: string;
375
+ maxThreads?: number;
376
+ maxTurnsPerThread?: number;
377
+ }): ThreadChain[];
378
+ }
379
+ export declare const TASK_RATINGS: readonly ["up", "down"];
380
+ export type TaskRating = (typeof TASK_RATINGS)[number];
381
+ export declare const RATED_TASK_EXCERPT_MAX_CHARS = 1000;
382
+ export declare const RATED_TASK_LIST_MAX_LIMIT = 200;
383
+ export type TaskRatingErrorCode = 'TASK_NOT_FOUND' | 'TASK_RATING_NOT_TERMINAL';
384
+ export declare class TaskRatingError extends RepositoryError {
385
+ readonly stableCode: TaskRatingErrorCode;
386
+ readonly taskId: string;
387
+ constructor(stableCode: TaskRatingErrorCode, taskId: string);
388
+ }
389
+ export interface SetTaskRatingInput {
390
+ workspaceId: string;
391
+ taskId: string;
392
+ rating: TaskRating | null;
393
+ now?: string;
394
+ }
395
+ export interface SetTaskRatingResult {
396
+ taskId: string;
397
+ rating: TaskRating | null;
398
+ ratedAt: string | null;
399
+ changed: boolean;
400
+ }
401
+ export declare function setTaskRating(db: DrizzleDb, input: SetTaskRatingInput): SetTaskRatingResult;
402
+ export interface ListRatedTasksInput {
403
+ workspaceId: string;
404
+ agentId?: string;
405
+ sinceIso?: string;
406
+ limit: number;
407
+ }
408
+ export interface RatedTaskRow {
409
+ taskId: string;
410
+ agentId: string;
411
+ threadId: string | null;
412
+ status: TaskStatus;
413
+ rating: TaskRating;
414
+ ratedAt: string;
415
+ promptExcerpt: string | null;
416
+ resultExcerpt: string | null;
154
417
  }
418
+ export declare function buildRatedTasksQuery(input: ListRatedTasksInput): import("drizzle-orm").SQL<unknown>;
419
+ export declare function listRatedTasks(db: DrizzleDb, input: ListRatedTasksInput): RatedTaskRow[];
420
+ export type CountRatedTasksInput = Omit<ListRatedTasksInput, 'limit'>;
421
+ export declare function buildRatedTasksCountQuery(input: CountRatedTasksInput): import("drizzle-orm").SQL<unknown>;
422
+ export declare function countRatedTasks(db: DrizzleDb, input: CountRatedTasksInput): number;
@@ -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,27 @@
1
+ export type ThreadOriginKind = 'human' | 'agent' | 'system';
2
+ export interface ThreadOriginRow {
3
+ origin: 'direct' | 'delegated';
4
+ delegatedByAgentId: string | null;
5
+ }
6
+ export interface RawThreadOriginRow {
7
+ task_id: string;
8
+ thread_id: string;
9
+ caller_agent_id: string | null;
10
+ parent_task_id: string | null;
11
+ schedule_id: unknown;
12
+ platform: string | null;
13
+ parent_thread_id: string | null;
14
+ parent_agent_id: string | null;
15
+ }
16
+ export interface RawThreadCreatorPointerRow {
17
+ thread_id: string;
18
+ created_by_kind: string | null;
19
+ created_by_id: string | null;
20
+ created_by_task_id: string | null;
21
+ creator_task_id: string | null;
22
+ creator_actor_kind: string | null;
23
+ creator_actor_id: string | null;
24
+ creator_pointer_unverified: number;
25
+ }
26
+ export declare function lineageThreadOrigin(row: RawThreadOriginRow): ThreadOriginRow;
27
+ export declare function resolveThreadOrigin(row: RawThreadCreatorPointerRow, pointerLineage?: RawThreadOriginRow, fallbackLineage?: RawThreadOriginRow): ThreadOriginRow | undefined;
@@ -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;