@crewx/sdk 0.9.0-rc.17 → 0.9.0-rc.171

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 (343) 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/agent-interceptor/chain.d.ts +25 -0
  14. package/dist/agent-interceptor/index.d.ts +6 -0
  15. package/dist/agent-interceptor/model-runner.d.ts +19 -0
  16. package/dist/agent-interceptor/program-runner.d.ts +13 -0
  17. package/dist/agent-interceptor/protocol.d.ts +68 -0
  18. package/dist/agent-interceptor/run-stop.d.ts +3 -0
  19. package/dist/agent-interceptor/schema.d.ts +267 -0
  20. package/dist/agent-interceptor/types.d.ts +88 -0
  21. package/dist/app/app.d.ts +167 -0
  22. package/dist/app/backend-env.d.ts +3 -0
  23. package/dist/app/content-media-types.d.ts +2 -0
  24. package/dist/app/context.d.ts +2 -0
  25. package/dist/app/entry.d.ts +9 -0
  26. package/dist/app/frame.d.ts +55 -0
  27. package/dist/app/index.d.ts +18 -0
  28. package/dist/app/index.js +12 -0
  29. package/dist/app/job-bridge.child.d.ts +1 -0
  30. package/dist/app/job-bridge.d.ts +67 -0
  31. package/dist/app/job-bridge.drain.child.d.ts +1 -0
  32. package/dist/app/job-bridge.example.d.ts +11 -0
  33. package/dist/app/job-contract.d.ts +40 -0
  34. package/dist/app/job-wire.d.ts +149 -0
  35. package/dist/app/protocol.d.ts +9 -0
  36. package/dist/app/runtime.d.ts +23 -0
  37. package/dist/app/schedule-contract.d.ts +59 -0
  38. package/dist/app/tool-mode.d.ts +3 -0
  39. package/dist/app-artifact-policy/check.d.ts +2 -0
  40. package/dist/app-artifact-policy/contract.d.ts +54 -0
  41. package/dist/app-artifact-policy/helper.d.ts +15 -0
  42. package/dist/app-artifact-policy/index.d.ts +3 -0
  43. package/dist/app-artifact-policy/index.js +18 -0
  44. package/dist/app-artifact-policy/paths.d.ts +24 -0
  45. package/dist/app-artifact-policy/scan.d.ts +47 -0
  46. package/dist/boxing/box.types.d.ts +4 -0
  47. package/dist/config/canonicalize-agent-options.d.ts +18 -0
  48. package/dist/config/default-agent-models.d.ts +11 -0
  49. package/dist/config/global-settings.d.ts +33 -0
  50. package/dist/config/migrate-grok-mode.d.ts +6 -0
  51. package/dist/config/model-compat.d.ts +31 -0
  52. package/dist/config/models.generated.d.ts +37 -0
  53. package/dist/config/models.remote.d.ts +1 -0
  54. package/dist/config/overdrive.d.ts +7 -0
  55. package/dist/config/pricing.d.ts +6 -3
  56. package/dist/config/pricing.generated.d.ts +4 -0
  57. package/dist/config/pricing.types.d.ts +4 -0
  58. package/dist/config/timeout.config.d.ts +4 -0
  59. package/dist/config/wi-boards.d.ts +19 -0
  60. package/dist/context-budget/continuity.d.ts +63 -0
  61. package/dist/context-budget/index.d.ts +142 -0
  62. package/dist/conversation/index.d.ts +1 -1
  63. package/dist/conversation/sqlite-provider.d.ts +6 -3
  64. package/dist/conversation/to-template-messages.d.ts +9 -0
  65. package/dist/conversation/types.d.ts +58 -1
  66. package/dist/desktop/command-runner.d.ts +4 -0
  67. package/dist/desktop/default-adapters.d.ts +4 -0
  68. package/dist/desktop/global-install.d.ts +19 -0
  69. package/dist/desktop/index.d.ts +3 -0
  70. package/dist/desktop/index.js +3 -0
  71. package/dist/desktop/install.d.ts +5 -0
  72. package/dist/desktop/lnk.d.ts +22 -0
  73. package/dist/desktop/manifest.d.ts +21 -0
  74. package/dist/desktop/types.d.ts +67 -0
  75. package/dist/desktop/version.d.ts +1 -0
  76. package/dist/desktop/windows-paths.d.ts +21 -0
  77. package/dist/desktop/wrapper.d.ts +18 -0
  78. package/dist/esm/account/index.js +2 -0
  79. package/dist/esm/app/index.js +12 -0
  80. package/dist/esm/app-artifact-policy/index.js +18 -0
  81. package/dist/esm/desktop/index.js +3 -0
  82. package/dist/esm/index.js +1175 -224
  83. package/dist/esm/node/index.js +2 -0
  84. package/dist/esm/plugins/index.js +527 -214
  85. package/dist/esm/process/index.js +1 -0
  86. package/dist/esm/publish/index.js +2 -0
  87. package/dist/esm/repository/index.js +648 -211
  88. package/dist/esm/skills/index.js +2 -0
  89. package/dist/esm/testing/index.js +1 -1
  90. package/dist/events/types.d.ts +28 -0
  91. package/dist/facade/Crewx.d.ts +70 -5
  92. package/dist/facade/task-ticket.d.ts +14 -0
  93. package/dist/highlight/thread-highlight-prompt.d.ts +2 -0
  94. package/dist/highlight/thread-highlighter.d.ts +326 -0
  95. package/dist/index.browser.d.ts +25 -1
  96. package/dist/index.browser.js +6 -2
  97. package/dist/index.d.ts +157 -17
  98. package/dist/index.js +1175 -224
  99. package/dist/internal/console-decoder.d.ts +38 -0
  100. package/dist/internal/windows-spawn.d.ts +10 -0
  101. package/dist/layout/types.d.ts +18 -1
  102. package/dist/lifecycle/process-lease.d.ts +80 -0
  103. package/dist/lifecycle/process-owner.d.ts +20 -0
  104. package/dist/lifecycle/task-heartbeat.d.ts +41 -0
  105. package/dist/lifecycle/task-stop.d.ts +82 -0
  106. package/dist/lifecycle/update-admission.d.ts +45 -0
  107. package/dist/local-server/base-url.d.ts +18 -0
  108. package/dist/local-server/index.d.ts +8 -0
  109. package/dist/local-server/opencode.d.ts +8 -0
  110. package/dist/local-server/probe.d.ts +3 -0
  111. package/dist/local-server/runtime.d.ts +26 -0
  112. package/dist/local-server/types.d.ts +43 -0
  113. package/dist/mcp-app/agent-access.d.ts +26 -0
  114. package/dist/mcp-app/app-handoff.d.ts +109 -0
  115. package/dist/mcp-app/app-icon-read.d.ts +7 -0
  116. package/dist/mcp-app/app-job-bridge.d.ts +30 -0
  117. package/dist/mcp-app/app-job-bridge.example.d.ts +36 -0
  118. package/dist/mcp-app/app-job.d.ts +168 -0
  119. package/dist/mcp-app/app-schedule.d.ts +85 -0
  120. package/dist/mcp-app/apps-context.d.ts +32 -0
  121. package/dist/mcp-app/bundle-provenance.d.ts +3 -0
  122. package/dist/mcp-app/candidate-registration.d.ts +4 -0
  123. package/dist/mcp-app/card-handler.d.ts +7 -0
  124. package/dist/mcp-app/catalog.d.ts +7 -0
  125. package/dist/mcp-app/content-channel.d.ts +86 -0
  126. package/dist/mcp-app/content-declarations.d.ts +31 -0
  127. package/dist/mcp-app/dev-checks.d.ts +31 -0
  128. package/dist/mcp-app/diagnostic-reason.d.ts +3 -0
  129. package/dist/mcp-app/discovery.d.ts +164 -0
  130. package/dist/mcp-app/errors.d.ts +7 -0
  131. package/dist/mcp-app/index.d.ts +45 -0
  132. package/dist/mcp-app/installed-app-ref.d.ts +25 -0
  133. package/dist/mcp-app/model-context.d.ts +29 -0
  134. package/dist/mcp-app/node-app-discovery-fs.d.ts +23 -0
  135. package/dist/mcp-app/product-bundle-assets.d.ts +27 -0
  136. package/dist/mcp-app/product-bundle-loader.d.ts +53 -0
  137. package/dist/mcp-app/projection.d.ts +14 -0
  138. package/dist/mcp-app/prompt-cards.d.ts +28 -0
  139. package/dist/mcp-app/registry.d.ts +28 -0
  140. package/dist/mcp-app/skill-backend.d.ts +141 -0
  141. package/dist/mcp-app/state-set.d.ts +9 -0
  142. package/dist/mcp-app/types.d.ts +490 -0
  143. package/dist/mcp-app/workspace-app-assets.d.ts +42 -0
  144. package/dist/mcp-app/workspace-app-scan-cache.d.ts +27 -0
  145. package/dist/mcp-app/workspace-snapshot.d.ts +76 -0
  146. package/dist/migrations/0011_far_black_tarantula.sql +1 -0
  147. package/dist/migrations/0012_blue_turbo.sql +23 -0
  148. package/dist/migrations/0013_hesitant_adam_destine.sql +15 -0
  149. package/dist/migrations/0014_organic_mongu.sql +73 -0
  150. package/dist/migrations/0015_panoramic_gorilla_man.sql +71 -0
  151. package/dist/migrations/0016_fuzzy_hemingway.sql +14 -0
  152. package/dist/migrations/0017_project_stage_sdk_migration.sql +29 -0
  153. package/dist/migrations/0018_bored_jackal.sql +33 -0
  154. package/dist/migrations/0019_backfill_task_thread_ids.sql +74 -0
  155. package/dist/migrations/0020_useful_iron_lad.sql +55 -0
  156. package/dist/migrations/0021_dashing_peter_quill.sql +51 -0
  157. package/dist/migrations/0022_wandering_bucky.sql +1 -0
  158. package/dist/migrations/0023_red_payback.sql +1 -0
  159. package/dist/migrations/0024_storage_metadata.sql +262 -0
  160. package/dist/migrations/0025_task_heartbeat.sql +8 -0
  161. package/dist/migrations/0025_thread_app_instance_ledger.sql +2 -0
  162. package/dist/migrations/0026_mcp_action_source.sql +47 -0
  163. package/dist/migrations/0027_task_stop_scope_cleanup.sql +5 -0
  164. package/dist/migrations/0027_ui_instance_active_unique.sql +2 -0
  165. package/dist/migrations/0029_nice_rhino.sql +1 -0
  166. package/dist/migrations/0031_petite_arclight.sql +6 -0
  167. package/dist/migrations/0032_ui_instance_opened_by.sql +1 -0
  168. package/dist/migrations/0033_thread_creator_boundary_guard.sql +38 -0
  169. package/dist/migrations/0034_keen_fallen_one.sql +36 -0
  170. package/dist/migrations/0035_request_log_daily.sql +11 -0
  171. package/dist/migrations/0036_ui_definition_archive.sql +8 -0
  172. package/dist/migrations/0037_ui_instance_agent_open_request.sql +1 -0
  173. package/dist/migrations/0038_task_rating.sql +3 -0
  174. package/dist/migrations/0039_aspiring_purifiers.sql +9 -0
  175. package/dist/migrations/0040_task_provider_inputs.sql +53 -0
  176. package/dist/migrations/0041_tranquil_vivisector.sql +54 -0
  177. package/dist/migrations/meta/0011_snapshot.json +1342 -0
  178. package/dist/migrations/meta/0012_snapshot.json +1494 -0
  179. package/dist/migrations/meta/0013_snapshot.json +1592 -0
  180. package/dist/migrations/meta/0014_snapshot.json +1975 -0
  181. package/dist/migrations/meta/0015_snapshot.json +2315 -0
  182. package/dist/migrations/meta/0016_snapshot.json +2419 -0
  183. package/dist/migrations/meta/0017_snapshot.json +2419 -0
  184. package/dist/migrations/meta/0018_snapshot.json +2570 -0
  185. package/dist/migrations/meta/0020_snapshot.json +2895 -0
  186. package/dist/migrations/meta/0021_snapshot.json +3031 -0
  187. package/dist/migrations/meta/0022_snapshot.json +3039 -0
  188. package/dist/migrations/meta/0023_snapshot.json +3047 -0
  189. package/dist/migrations/meta/0029_snapshot.json +3206 -0
  190. package/dist/migrations/meta/0031_snapshot.json +3251 -0
  191. package/dist/migrations/meta/0034_snapshot.json +3473 -0
  192. package/dist/migrations/meta/0035_snapshot.json +3547 -0
  193. package/dist/migrations/meta/0036_snapshot.json +3591 -0
  194. package/dist/migrations/meta/0037_snapshot.json +3598 -0
  195. package/dist/migrations/meta/0038_snapshot.json +3626 -0
  196. package/dist/migrations/meta/0039_snapshot.json +3684 -0
  197. package/dist/migrations/meta/0040_snapshot.json +3759 -0
  198. package/dist/migrations/meta/0041_snapshot.json +4156 -0
  199. package/dist/migrations/meta/_journal.json +217 -0
  200. package/dist/node/index.d.ts +1 -0
  201. package/dist/node/index.js +2 -0
  202. package/dist/paths.d.ts +1 -0
  203. package/dist/plugin/types.d.ts +1 -0
  204. package/dist/plugins/index.d.ts +1 -1
  205. package/dist/plugins/index.js +527 -214
  206. package/dist/plugins/sqlite-tracing.d.ts +46 -0
  207. package/dist/process/index.d.ts +2 -0
  208. package/dist/process/index.js +1 -0
  209. package/dist/process/process-control.d.ts +60 -0
  210. package/dist/prompt/tag-names.d.ts +22 -0
  211. package/dist/provider/acp/connection.d.ts +6 -0
  212. package/dist/provider/acp/meta.d.ts +11 -0
  213. package/dist/provider/bridge.d.ts +12 -2
  214. package/dist/provider/classify-task-error.d.ts +2 -0
  215. package/dist/provider/claude-agent-env.d.ts +1 -0
  216. package/dist/provider/cli/adapter.types.d.ts +23 -2
  217. package/dist/provider/cli/adapters/agent-call.util.d.ts +1 -1
  218. package/dist/provider/cli/adapters/cli-knob.util.d.ts +7 -0
  219. package/dist/provider/cli/adapters/codex-item.d.ts +1 -0
  220. package/dist/provider/cli/adapters/event-timestamp.util.d.ts +1 -0
  221. package/dist/provider/cli/adapters/grok.d.ts +2 -0
  222. package/dist/provider/cli/adapters/index.d.ts +5 -0
  223. package/dist/provider/cli/index.d.ts +3 -2
  224. package/dist/provider/cli/meta.d.ts +5 -0
  225. package/dist/provider/cli/protocol-envelope.d.ts +3 -0
  226. package/dist/provider/errors.d.ts +5 -1
  227. package/dist/provider/idle-watchdog.d.ts +19 -0
  228. package/dist/provider/models.d.ts +17 -12
  229. package/dist/provider/order.d.ts +1 -1
  230. package/dist/provider/parse-usage.d.ts +6 -0
  231. package/dist/provider/provider-selection.d.ts +8 -0
  232. package/dist/provider/redact-technical-message.d.ts +1 -0
  233. package/dist/provider/task-error.types.d.ts +17 -0
  234. package/dist/provider-account/accounts.d.ts +15 -0
  235. package/dist/provider-account/index.d.ts +5 -0
  236. package/dist/provider-account/registry.d.ts +30 -0
  237. package/dist/provider-account/types.d.ts +40 -0
  238. package/dist/publish/constants.d.ts +6 -0
  239. package/dist/publish/errors.d.ts +7 -0
  240. package/dist/publish/index.d.ts +55 -0
  241. package/dist/publish/index.js +2 -0
  242. package/dist/publish/manifest.d.ts +47 -0
  243. package/dist/publish/marketplace-api.constants.d.ts +1 -0
  244. package/dist/publish/pack.d.ts +6 -0
  245. package/dist/publish/scan.d.ts +10 -0
  246. package/dist/publish/secrets.d.ts +6 -0
  247. package/dist/publish/upload.d.ts +19 -0
  248. package/dist/remote/execution-profile.d.ts +9 -0
  249. package/dist/remote/index.d.ts +1 -0
  250. package/dist/remote/types.d.ts +28 -0
  251. package/dist/repository/agent-send-history.repository.d.ts +23 -0
  252. package/dist/repository/agent-suggestion.repository.d.ts +34 -0
  253. package/dist/repository/base-sqlite-repository.d.ts +1 -0
  254. package/dist/repository/common-code.repository.d.ts +45 -0
  255. package/dist/repository/db.d.ts +12 -1
  256. package/dist/repository/index.d.ts +53 -6
  257. package/dist/repository/index.js +648 -211
  258. package/dist/repository/logs-db.d.ts +12 -0
  259. package/dist/repository/notification.repository.d.ts +58 -0
  260. package/dist/repository/project.repository.d.ts +90 -0
  261. package/dist/repository/public-task-answer.d.ts +24 -0
  262. package/dist/repository/request-log-mover.d.ts +70 -0
  263. package/dist/repository/request-log.repository.d.ts +7 -3
  264. package/dist/repository/sidebar-tab.repository.d.ts +86 -0
  265. package/dist/repository/storage-metadata.repository.d.ts +64 -0
  266. package/dist/repository/task-log-migration.d.ts +74 -0
  267. package/dist/repository/task-log.repository.d.ts +44 -0
  268. package/dist/repository/task-status.d.ts +21 -0
  269. package/dist/repository/task.repository.d.ts +307 -8
  270. package/dist/repository/thread-history.repository.d.ts +193 -0
  271. package/dist/repository/thread-origin-verdict.d.ts +27 -0
  272. package/dist/repository/thread-title.types.d.ts +29 -0
  273. package/dist/repository/thread.repository.d.ts +134 -5
  274. package/dist/repository/usage-backfill.d.ts +62 -0
  275. package/dist/repository/usage-from-logs.d.ts +21 -0
  276. package/dist/repository/workspace.repository.d.ts +3 -0
  277. package/dist/schema/agent-send-history.d.ts +85 -0
  278. package/dist/schema/agent-suggestions.d.ts +199 -0
  279. package/dist/schema/common-codes.d.ts +216 -0
  280. package/dist/schema/index.d.ts +16 -0
  281. package/dist/schema/notifications.d.ts +303 -0
  282. package/dist/schema/projects.d.ts +610 -0
  283. package/dist/schema/request-log-daily.d.ts +151 -0
  284. package/dist/schema/sidebar-tabs.d.ts +466 -0
  285. package/dist/schema/storage-metadata.d.ts +181 -0
  286. package/dist/schema/task-log-events.d.ts +119 -0
  287. package/dist/schema/task-provider-inputs.d.ts +100 -0
  288. package/dist/schema/tasks.d.ts +1058 -1
  289. package/dist/schema/thread-creator-unverified.d.ts +45 -0
  290. package/dist/schema/thread-history.d.ts +734 -0
  291. package/dist/schema/threads.d.ts +59 -0
  292. package/dist/schema/ui-action-receipts.d.ts +358 -0
  293. package/dist/schema/ui-definition-archive.d.ts +63 -0
  294. package/dist/schema/ui-instance-repins.d.ts +222 -0
  295. package/dist/schema/ui-instances.d.ts +324 -0
  296. package/dist/schema/workspaces.d.ts +17 -0
  297. package/dist/skills/index.d.ts +15 -0
  298. package/dist/skills/index.js +2 -0
  299. package/dist/skills/types.d.ts +18 -0
  300. package/dist/task-log/anchor-child-tasks.d.ts +7 -0
  301. package/dist/task-log/delegation-trailer.d.ts +34 -0
  302. package/dist/template/engine.d.ts +2 -2
  303. package/dist/template/helpers/exec.browser.d.ts +4 -3
  304. package/dist/template/helpers/exec.d.ts +4 -3
  305. package/dist/template/helpers/format-conversation.d.ts +1 -0
  306. package/dist/template/types.d.ts +20 -0
  307. package/dist/testing/index.js +1 -1
  308. package/dist/types/index.d.ts +1611 -3
  309. package/dist/types/task-log.types.d.ts +6 -1
  310. package/dist/ui-card/index.d.ts +2 -0
  311. package/dist/ui-card/legacy-card-parser.d.ts +11 -0
  312. package/dist/ui-instance/definition.d.ts +6 -0
  313. package/dist/ui-instance/errors.d.ts +18 -0
  314. package/dist/ui-instance/index.d.ts +11 -0
  315. package/dist/ui-instance/json.d.ts +19 -0
  316. package/dist/ui-instance/lineage.d.ts +24 -0
  317. package/dist/ui-instance/runtime.d.ts +19 -0
  318. package/dist/ui-instance/store.d.ts +213 -0
  319. package/dist/ui-instance/types.d.ts +343 -0
  320. package/dist/ui-plugin/app-icon.d.ts +50 -0
  321. package/dist/ui-plugin/app-manifest.d.ts +64 -0
  322. package/dist/ui-plugin/csp.d.ts +28 -0
  323. package/dist/ui-plugin/index.d.ts +8 -0
  324. package/dist/ui-plugin/limits.d.ts +27 -0
  325. package/dist/ui-plugin/manifest.d.ts +3 -0
  326. package/dist/ui-plugin/types.d.ts +208 -0
  327. package/dist/ui-plugin/validator.d.ts +18 -0
  328. package/dist/utils/crewx-executable.d.ts +76 -0
  329. package/dist/utils/crewx-home.d.ts +1 -0
  330. package/dist/utils/env-defaults.d.ts +3 -0
  331. package/dist/utils/id.d.ts +1 -1
  332. package/dist/utils/local-identity.d.ts +2 -0
  333. package/dist/utils/runner-env.d.ts +3 -0
  334. package/dist/utils/timestamp.d.ts +1 -0
  335. package/dist/utils/workspace.d.ts +1 -0
  336. package/dist/wi/create.d.ts +48 -0
  337. package/dist/wi/select.d.ts +20 -0
  338. package/package.json +63 -3
  339. package/templates/agents/default.yaml +303 -128
  340. package/templates/documents/crewx-manual.md +138 -138
  341. package/templates/documents/crewx-quick-guide.md +8 -7
  342. package/templates/workflows/wi-default-flow.yaml +65 -0
  343. package/templates/workflows/wi-plan-flow.yaml +140 -0
@@ -1,8 +1,96 @@
1
1
  import { BaseSqliteRepository } from './base-sqlite-repository.js';
2
+ import type { DrizzleHandle } from './db.js';
3
+ import { RepositoryError } from './errors.js';
2
4
  import { threads } from '../schema/index.js';
5
+ import { type TaskStatus } from './task-status.js';
6
+ import type { UnreadReplyCandidate } from './public-task-answer.js';
7
+ import type { ThreadOriginRow } from './thread-origin-verdict.js';
3
8
  import type { TaskRow, TaskListRow } from './task.repository.js';
9
+ export type { ThreadOriginRow } from './thread-origin-verdict.js';
4
10
  export type ThreadRow = typeof threads.$inferSelect;
5
11
  export type NewThread = typeof threads.$inferInsert;
12
+ export type ThreadActorKind = NonNullable<NewThread['created_by_kind']>;
13
+ export interface ThreadCreationOptions {
14
+ createdByKind?: ThreadActorKind | null;
15
+ createdById?: string | null;
16
+ createdByTaskId?: string | null;
17
+ }
18
+ export interface CreateAppLaunchThreadInput {
19
+ threadId: string;
20
+ workspaceId: string;
21
+ platform: string;
22
+ title: string;
23
+ appId: string;
24
+ createdById: string | null;
25
+ initialAgentId?: string;
26
+ }
27
+ export type CreateAppLaunchThreadResult = {
28
+ status: 'created';
29
+ thread: ThreadRow;
30
+ } | {
31
+ status: 'existing';
32
+ thread: ThreadRow;
33
+ } | {
34
+ status: 'conflict';
35
+ };
36
+ export interface UnreadReplyWatermark {
37
+ threadId: string;
38
+ readThroughAt: string | null;
39
+ }
40
+ export interface TaskDescendantSummary {
41
+ total: number;
42
+ running: number;
43
+ pending: number;
44
+ paused: number;
45
+ success: number;
46
+ failed: number;
47
+ stopped: number;
48
+ runnerLost: number;
49
+ checkedAt: string;
50
+ }
51
+ export interface RespondedAgent {
52
+ agentId: string;
53
+ lastRepliedAt: string;
54
+ }
55
+ export interface TaskDescendantRow {
56
+ task: TaskRow;
57
+ parentTaskId: string;
58
+ parentAgentId: string | null;
59
+ depth: number;
60
+ }
61
+ export interface TaskDescendantListOptions {
62
+ states?: readonly TaskStatus[];
63
+ limit?: number;
64
+ cursor?: string | null;
65
+ maxDepth?: number;
66
+ }
67
+ export interface TaskDescendantList {
68
+ rows: TaskDescendantRow[];
69
+ summary: TaskDescendantSummary;
70
+ nextCursor: string | null;
71
+ traversalTruncated: boolean;
72
+ }
73
+ export type ThreadOriginFilter = 'direct' | 'delegated' | 'all';
74
+ type ThreadOriginScope = Exclude<ThreadOriginFilter, 'all'>;
75
+ export interface ThreadTitleMetadataPatch {
76
+ priority?: string | null;
77
+ state?: string | null;
78
+ }
79
+ export interface ThreadTitleMetadataPatchResult {
80
+ threadId: string;
81
+ priority: string | null;
82
+ state: string | null;
83
+ }
84
+ export type ThreadTitleMetadataPatchErrorReason = 'THREAD_TITLE_PATCH_EMPTY' | 'THREAD_TITLE_PATCH_INVALID';
85
+ export declare class ThreadTitleMetadataPatchError extends RepositoryError {
86
+ readonly reason: ThreadTitleMetadataPatchErrorReason;
87
+ constructor(reason: ThreadTitleMetadataPatchErrorReason, message?: string);
88
+ }
89
+ export type ThreadTransaction = Parameters<Parameters<DrizzleHandle['db']['transaction']>[0]>[0];
90
+ export declare function toggleThreadPinInTx(tx: ThreadTransaction, threadId: string, workspaceId?: string): {
91
+ pinned: boolean;
92
+ } | null;
93
+ export declare function reorderPinsInTx(tx: ThreadTransaction, threadIds: string[], workspaceId?: string): void;
6
94
  export declare class ThreadRepository extends BaseSqliteRepository {
7
95
  private readonly dbPath?;
8
96
  constructor(opts?: {
@@ -11,10 +99,22 @@ export declare class ThreadRepository extends BaseSqliteRepository {
11
99
  });
12
100
  resolveDbPath(): string;
13
101
  private openHandle;
14
- private validateWorkspaceId;
15
102
  private topLevelTaskPredicateSql;
16
- findAllThreads(workspaceId?: string): ThreadRow[];
103
+ private workflowAnchorPredicateSql;
104
+ private descendantTraversalSql;
105
+ private descendantSkippedSql;
106
+ private findAllThreadsQuery;
107
+ private findThreadIdsQuery;
108
+ private readThreadIds;
109
+ private findThreadSortKeysQuery;
110
+ private readThreadSortKeys;
111
+ private readThreadRowsByIds;
112
+ private readThreadRows;
113
+ findAllThreads(workspaceId?: string, createdByKind?: ThreadActorKind): ThreadRow[];
114
+ explainFindAllThreadsPlan(workspaceId?: string, createdByKind?: ThreadActorKind): string[];
115
+ findThreadsByIdsOrTitles(ids: string[], workspaceId?: string): ThreadRow[];
17
116
  findThreadById(threadId: string, workspaceId?: string): ThreadRow | undefined;
117
+ createAppLaunchThread(input: CreateAppLaunchThreadInput): CreateAppLaunchThreadResult;
18
118
  threadExists(threadId: string, workspaceId?: string): boolean;
19
119
  aggregateTaskStats(threadId: string, workspaceId?: string): {
20
120
  taskCount: number;
@@ -23,24 +123,52 @@ export declare class ThreadRepository extends BaseSqliteRepository {
23
123
  cachedInputTokens: number;
24
124
  costUsd: number;
25
125
  agentIds: string[];
126
+ delegated: {
127
+ taskCount: number;
128
+ inputTokens: number;
129
+ outputTokens: number;
130
+ cachedInputTokens: number;
131
+ costUsd: number;
132
+ };
26
133
  };
27
- findTopLevelTasks(threadId: string, workspaceId?: string, limit?: number): TaskRow[];
134
+ getDescendantSummaryByTaskId(threadId: string, workspaceId?: string): Record<string, TaskDescendantSummary>;
135
+ listUnreadReplyCandidates(watermarks: readonly UnreadReplyWatermark[], workspaceId?: string): Map<string, UnreadReplyCandidate[]>;
136
+ private unreadReplyCandidatesQuery;
137
+ getThreadTaskStatusBatch(threadIds: string[], workspaceId?: string): {
138
+ tasksByThread: Map<string, TaskListRow[]>;
139
+ descendantSummaryByTaskId: Record<string, TaskDescendantSummary>;
140
+ };
141
+ listDescendantsByTaskId(taskId: string, workspaceId: string, options?: TaskDescendantListOptions): TaskDescendantList | undefined;
142
+ findInterceptedRequests(taskIds: readonly string[]): Map<string, string>;
143
+ findTopLevelTasks(threadId: string, workspaceId?: string, limit?: number, ownAgentId?: string): TaskRow[];
28
144
  findAllTasks(threadId: string, workspaceId?: string): TaskRow[];
145
+ findRespondedAgents(threadId: string, workspaceId?: string): RespondedAgent[];
29
146
  findTaskById(threadId: string, taskId: string, workspaceId?: string): {
30
147
  task: TaskRow;
31
148
  children: TaskRow[];
32
149
  } | undefined;
33
150
  private batchFetchTasksQuery;
34
151
  batchFetchTasks(threadIds: string[], workspaceId?: string): Map<string, TaskListRow[]>;
152
+ private findThreadOriginsQuery;
153
+ private findCreatorPointersQuery;
154
+ private findTaskOriginLineageQuery;
155
+ findThreadOrigins(threadIds: string[], workspaceId?: string): Map<string, ThreadOriginRow>;
156
+ findThreadsByOrigin(origin: ThreadOriginScope, workspaceId?: string): ThreadRow[];
157
+ findRecentDirectThreads(workspaceId: string, limit?: number): {
158
+ threads: ThreadRow[];
159
+ originsByThread: Map<string, ThreadOriginRow>;
160
+ };
35
161
  explainBatchFetchTasksPlan(threadIds: string[], workspaceId?: string): string[];
162
+ explainFindThreadOriginsPlan(threadIds: string[], workspaceId?: string): string[];
163
+ explainFindThreadsByOriginPlan(origin: ThreadOriginScope, workspaceId?: string): string[];
36
164
  updateThreadTitle(threadId: string, title: string, workspaceId?: string): void;
37
165
  upsertThread(threadId: string, opts: {
38
166
  platform: string;
39
167
  workspaceId?: string;
40
168
  title?: string;
41
169
  titleLocked?: boolean;
42
- }): void;
43
- ensureThread(threadId: string, platform: string, workspaceId?: string): void;
170
+ } & ThreadCreationOptions): void;
171
+ ensureThread(threadId: string, platform: string, workspaceId?: string, creator?: ThreadCreationOptions): void;
44
172
  saveUserMessage(threadId: string, text: string, opts?: {
45
173
  platform?: string;
46
174
  model?: string;
@@ -58,6 +186,7 @@ export declare class ThreadRepository extends BaseSqliteRepository {
58
186
  title?: string;
59
187
  titleLocked?: boolean;
60
188
  }): void;
189
+ patchThreadTitleMetadata(threadId: string, patch: ThreadTitleMetadataPatch, workspaceId?: string): ThreadTitleMetadataPatchResult | ThreadTitleMetadataPatchError | null;
61
190
  togglePin(threadId: string, workspaceId?: string): {
62
191
  pinned: boolean;
63
192
  } | null;
@@ -0,0 +1,62 @@
1
+ export type UsageBackfillMode = 'dry-run' | 'apply' | 'verify' | 'restore';
2
+ export declare const USAGE_BACKFILL_TERMINAL_STATUSES: readonly ["success", "failed", "completed"];
3
+ export declare const USAGE_BACKFILL_MAX_LATE_USAGE_AGE_MS: number;
4
+ export declare const USAGE_BACKFILL_UNDO_SCHEMA_VERSION = 1;
5
+ export declare const USAGE_BACKFILL_SNAPSHOT_ROW_BYTES = 2048;
6
+ export declare const USAGE_BACKFILL_MIN_FREE_SPACE_RESERVE_BYTES: number;
7
+ export type UsageAccountingReason = 'pre-instrumentation' | 'provider-no-usage' | 'suppressed-by-adapter' | 'not-captured';
8
+ export interface UsageBackfillOptions {
9
+ mode: UsageBackfillMode;
10
+ dbPath?: string;
11
+ backupPath?: string;
12
+ restorePath?: string;
13
+ now?: Date | string | number;
14
+ }
15
+ export interface UsageBackfillProviderStats {
16
+ candidates: number;
17
+ recovered: number;
18
+ unavailable: number;
19
+ deferred: number;
20
+ }
21
+ export interface UsageBackfillFailure {
22
+ taskId: string;
23
+ reason: string;
24
+ }
25
+ export interface UsageBackfillReport {
26
+ mode: UsageBackfillMode;
27
+ ok: boolean;
28
+ dbPath: string;
29
+ scannedTasks: number;
30
+ terminalTasks: number;
31
+ rawTargetTasks: number;
32
+ candidateTasks: number;
33
+ recoveredTasks: number;
34
+ unavailableTasks: number;
35
+ deferredTasks: number;
36
+ changedTasks: number;
37
+ wouldChangeTasks: number;
38
+ accountingTasks: number;
39
+ remainingTargetTasks: number;
40
+ providerDistribution: Record<string, UsageBackfillProviderStats>;
41
+ reasonCounts: Record<UsageAccountingReason, number>;
42
+ estimatedFreeSpaceBytes: number;
43
+ requiredFreeSpaceBytes: number;
44
+ availableFreeSpaceBytes: number;
45
+ minimumFreeSpaceReserveBytes: number;
46
+ freeSpaceGatePassed: boolean;
47
+ backupPath?: string;
48
+ snapshotPath?: string;
49
+ backupMethod?: 'row-undo-snapshot';
50
+ restored: number;
51
+ skippedConflict: number;
52
+ conflictSamples: UsageBackfillConflict[];
53
+ blockedReason?: string;
54
+ failures: UsageBackfillFailure[];
55
+ warnings: string[];
56
+ }
57
+ export interface UsageBackfillConflict {
58
+ taskId: string;
59
+ fields: string[];
60
+ }
61
+ export declare function classifyUsageAccountingReason(provider: string | undefined): UsageAccountingReason;
62
+ export declare function runUsageBackfill(options: UsageBackfillOptions): Promise<UsageBackfillReport>;
@@ -0,0 +1,21 @@
1
+ import type { CliProviderAdapter } from '../provider/cli/adapter.types.js';
2
+ import type { TaskLogRepositoryContract } from './task-log.repository.js';
3
+ export interface RecoveredTaskUsage {
4
+ inputTokens: number;
5
+ outputTokens: number;
6
+ cachedInputTokens: number;
7
+ costUsd: number;
8
+ model: string | null;
9
+ }
10
+ export interface TaskLogUsageRecovery {
11
+ stdout: string;
12
+ adapter: CliProviderAdapter;
13
+ usage?: RecoveredTaskUsage;
14
+ }
15
+ export interface RecoverUsageFromTaskLogsOptions {
16
+ taskLogRepository: Pick<TaskLogRepositoryContract, 'readLogs'>;
17
+ taskId: string;
18
+ provider?: string | null;
19
+ model?: string | null;
20
+ }
21
+ export declare function recoverUsageFromTaskLogs(options: RecoverUsageFromTaskLogsOptions): TaskLogUsageRecovery | undefined;
@@ -48,6 +48,9 @@ export declare class WorkspaceRepository extends BaseSqliteRepository {
48
48
  total: number;
49
49
  };
50
50
  findById(id: string): ProjectRow | undefined;
51
+ toggleStar(id: string): {
52
+ starred: boolean;
53
+ } | null;
51
54
  findAgentsByProject(id: string): string[];
52
55
  findThreadsByProject(id: string, params: {
53
56
  limit: number;
@@ -0,0 +1,85 @@
1
+ export declare const agent_send_history: import("drizzle-orm/sqlite-core").SQLiteTableWithColumns<{
2
+ name: "agent_send_history";
3
+ schema: undefined;
4
+ columns: {
5
+ workspace_id: import("drizzle-orm/sqlite-core").SQLiteColumn<{
6
+ name: "workspace_id";
7
+ tableName: "agent_send_history";
8
+ dataType: "string";
9
+ columnType: "SQLiteText";
10
+ data: string;
11
+ driverParam: string;
12
+ notNull: true;
13
+ hasDefault: false;
14
+ isPrimaryKey: false;
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
+ actor_id: import("drizzle-orm/sqlite-core").SQLiteColumn<{
25
+ name: "actor_id";
26
+ tableName: "agent_send_history";
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_send_history";
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
+ last_accepted_at: import("drizzle-orm/sqlite-core").SQLiteColumn<{
63
+ name: "last_accepted_at";
64
+ tableName: "agent_send_history";
65
+ dataType: "string";
66
+ columnType: "SQLiteText";
67
+ data: string;
68
+ driverParam: string;
69
+ notNull: true;
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
+ };
82
+ dialect: "sqlite";
83
+ }>;
84
+ export type AgentSendHistory = typeof agent_send_history.$inferSelect;
85
+ export type NewAgentSendHistory = typeof agent_send_history.$inferInsert;
@@ -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;