@capybara-hq/kernel 0.1.0-rc.105 → 0.1.0-rc.107

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 (359) hide show
  1. package/dist/admin/admin.schemas.d.ts +3 -0
  2. package/dist/agents/agents.schemas.d.ts +9 -9
  3. package/dist/{schedules/schedules.controller.d.ts → automations/automations.controller.d.ts} +37 -32
  4. package/dist/{schedules/schedules.controller.js → automations/automations.controller.js} +68 -57
  5. package/dist/automations/automations.module.d.ts +16 -0
  6. package/dist/{schedules/schedules.module.js → automations/automations.module.js} +18 -15
  7. package/dist/{schedules/schedules.schemas.d.ts → automations/automations.schemas.d.ts} +151 -50
  8. package/dist/automations/automations.schemas.js +253 -0
  9. package/dist/{schedules/scheduled-tasks.service.d.ts → automations/automations.service.d.ts} +99 -52
  10. package/dist/{schedules/scheduled-tasks.service.js → automations/automations.service.js} +303 -134
  11. package/dist/{schedules → automations}/calendar.d.ts +8 -8
  12. package/dist/{schedules → automations}/calendar.js +2 -2
  13. package/dist/automations/effective-settings.d.ts +28 -0
  14. package/dist/automations/effective-settings.js +25 -0
  15. package/dist/automations/errors.d.ts +19 -0
  16. package/dist/automations/errors.js +19 -0
  17. package/dist/automations/events/coalesce.d.ts +28 -0
  18. package/dist/automations/events/coalesce.js +131 -0
  19. package/dist/automations/events/deadline.d.ts +10 -0
  20. package/dist/automations/events/deadline.js +24 -0
  21. package/dist/automations/events/dispatcher.d.ts +74 -0
  22. package/dist/automations/events/dispatcher.js +353 -0
  23. package/dist/automations/events/events.module.d.ts +7 -0
  24. package/dist/automations/events/events.module.js +26 -0
  25. package/dist/automations/events/guards.d.ts +32 -0
  26. package/dist/automations/events/guards.js +87 -0
  27. package/dist/automations/events/sweep.job.d.ts +49 -0
  28. package/dist/automations/events/sweep.job.js +202 -0
  29. package/dist/automations/events/token.d.ts +5 -0
  30. package/dist/automations/events/token.js +5 -0
  31. package/dist/automations/events/trigger-events.service.d.ts +47 -0
  32. package/dist/automations/events/trigger-events.service.js +254 -0
  33. package/dist/{schedules → automations}/fire.d.ts +57 -17
  34. package/dist/{schedules → automations}/fire.js +311 -79
  35. package/dist/{schedules → automations}/grant-rules.d.ts +1 -1
  36. package/dist/{schedules → automations}/grant-rules.js +5 -5
  37. package/dist/automations/job-ids.d.ts +113 -0
  38. package/dist/automations/job-ids.js +117 -0
  39. package/dist/{schedules → automations}/pause.d.ts +3 -3
  40. package/dist/{schedules → automations}/pause.js +3 -3
  41. package/dist/{schedules → automations}/run-tracker.d.ts +21 -10
  42. package/dist/{schedules → automations}/run-tracker.js +68 -56
  43. package/dist/{schedules → automations}/scan.job.d.ts +12 -8
  44. package/dist/{schedules → automations}/scan.job.js +39 -23
  45. package/dist/{schedules → automations}/schedule-math.d.ts +19 -12
  46. package/dist/{schedules → automations}/schedule-math.js +17 -7
  47. package/dist/{schedules → automations}/store.d.ts +57 -27
  48. package/dist/{schedules → automations}/store.js +102 -52
  49. package/dist/automations/store.module.d.ts +6 -0
  50. package/dist/{schedules → automations}/store.module.js +9 -9
  51. package/dist/automations/types.d.ts +178 -0
  52. package/dist/{schedules → automations}/unattended.d.ts +22 -11
  53. package/dist/{schedules → automations}/unattended.js +53 -30
  54. package/dist/catalog/marketplaces.service.d.ts +1 -1
  55. package/dist/channels/channels.module.js +7 -6
  56. package/dist/channels/file-delivery.d.ts +26 -11
  57. package/dist/channels/file-delivery.js +32 -11
  58. package/dist/channels/outbound.d.ts +8 -8
  59. package/dist/channels/outbound.js +32 -30
  60. package/dist/channels/threads.d.ts +1 -1
  61. package/dist/channels/threads.js +1 -1
  62. package/dist/config/schema.d.ts +8 -1
  63. package/dist/config/schema.js +56 -6
  64. package/dist/conversations/approval-profile.d.ts +2 -2
  65. package/dist/conversations/approval-profile.js +3 -3
  66. package/dist/conversations/artifacts.d.ts +20 -17
  67. package/dist/conversations/artifacts.js +30 -37
  68. package/dist/conversations/attachments.controller.d.ts +6 -19
  69. package/dist/conversations/attachments.controller.js +8 -59
  70. package/dist/conversations/attachments.service.d.ts +30 -74
  71. package/dist/conversations/attachments.service.js +51 -193
  72. package/dist/conversations/conversations.controller.d.ts +7 -1
  73. package/dist/conversations/conversations.controller.js +26 -10
  74. package/dist/conversations/conversations.module.js +4 -0
  75. package/dist/conversations/conversations.service.d.ts +112 -35
  76. package/dist/conversations/conversations.service.js +160 -43
  77. package/dist/conversations/event-log.d.ts +1 -0
  78. package/dist/conversations/events.d.ts +95 -27
  79. package/dist/conversations/events.js +108 -10
  80. package/dist/conversations/files.d.ts +66 -64
  81. package/dist/conversations/files.js +127 -147
  82. package/dist/conversations/message-context.d.ts +2 -2
  83. package/dist/conversations/message-context.js +1 -1
  84. package/dist/conversations/permission-profile-store.d.ts +2 -1
  85. package/dist/conversations/permission-profiles.controller.d.ts +3 -0
  86. package/dist/conversations/permission-profiles.service.js +1 -1
  87. package/dist/conversations/prompt-suggestion-request.d.ts +1 -1
  88. package/dist/conversations/prompt-suggestion-request.js +4 -2
  89. package/dist/conversations/prompt-suggestions.d.ts +3 -3
  90. package/dist/conversations/prompt-suggestions.js +11 -10
  91. package/dist/conversations/queue.d.ts +7 -4
  92. package/dist/conversations/queue.js +6 -2
  93. package/dist/conversations/queue.service.d.ts +5 -5
  94. package/dist/conversations/queue.service.js +27 -16
  95. package/dist/ctx/create-ctx.d.ts +23 -2
  96. package/dist/ctx/create-ctx.js +78 -3
  97. package/dist/db/kernel-schema.d.ts +184 -27
  98. package/dist/devices/device-project-files.service.d.ts +88 -0
  99. package/dist/devices/device-project-files.service.js +249 -0
  100. package/dist/devices/device-projects.service.d.ts +40 -0
  101. package/dist/devices/device-projects.service.js +16 -13
  102. package/dist/devices/devices.controller.d.ts +9 -3
  103. package/dist/devices/devices.controller.js +27 -5
  104. package/dist/devices/devices.module.js +9 -1
  105. package/dist/devices/devices.schemas.js +6 -1
  106. package/dist/devices/dto.d.ts +15 -0
  107. package/dist/devices/dto.js +11 -0
  108. package/dist/devices/project-paths.d.ts +29 -0
  109. package/dist/devices/project-paths.js +66 -0
  110. package/dist/devices/project-rules.d.ts +5 -1
  111. package/dist/devices/project-rules.js +5 -1
  112. package/dist/errors.d.ts +53 -13
  113. package/dist/errors.js +53 -13
  114. package/dist/evals/canonical-json.d.ts +7 -0
  115. package/dist/evals/canonical-json.js +21 -0
  116. package/dist/evals/reconstruct.d.ts +10 -1
  117. package/dist/evals/reconstruct.js +20 -1
  118. package/dist/evals/recorded-tools.d.ts +0 -2
  119. package/dist/evals/recorded-tools.js +1 -16
  120. package/dist/evals/snapshot.d.ts +26 -3
  121. package/dist/evals/snapshot.js +110 -57
  122. package/dist/evals/worker.d.ts +4 -3
  123. package/dist/evals/worker.js +8 -4
  124. package/dist/extensions/host.d.ts +9 -2
  125. package/dist/extensions/host.js +12 -0
  126. package/dist/extensions/instance.d.ts +3 -1
  127. package/dist/extensions/instance.js +4 -0
  128. package/dist/extensions/ledger.d.ts +1 -1
  129. package/dist/extensions/permission-set.d.ts +17 -1
  130. package/dist/extensions/permission-set.js +13 -1
  131. package/dist/extensions/permission-view.d.ts +1 -1
  132. package/dist/extensions/permission-view.js +4 -1
  133. package/dist/files/blob-objects.d.ts +124 -0
  134. package/dist/files/blob-objects.js +341 -0
  135. package/dist/files/blob-sweep.job.d.ts +122 -0
  136. package/dist/files/blob-sweep.job.js +389 -0
  137. package/dist/files/blobs.service.d.ts +135 -0
  138. package/dist/files/blobs.service.js +300 -0
  139. package/dist/files/conversation-media.d.ts +41 -0
  140. package/dist/files/conversation-media.js +124 -0
  141. package/dist/files/deliveries.d.ts +64 -0
  142. package/dist/files/deliveries.js +156 -0
  143. package/dist/files/deliveries.module.d.ts +6 -0
  144. package/dist/files/deliveries.module.js +24 -0
  145. package/dist/files/draft-cleanup.job.d.ts +26 -0
  146. package/dist/files/draft-cleanup.job.js +93 -0
  147. package/dist/files/files.module.d.ts +1 -1
  148. package/dist/files/files.module.js +3 -2
  149. package/dist/files/hash-job.d.ts +127 -0
  150. package/dist/files/hash-job.js +447 -0
  151. package/dist/files/library-backfill.d.ts +63 -0
  152. package/dist/files/library-backfill.js +143 -0
  153. package/dist/files/library-files.service.d.ts +255 -0
  154. package/dist/files/library-files.service.js +883 -0
  155. package/dist/files/library-jobs.module.d.ts +8 -0
  156. package/dist/files/library-jobs.module.js +27 -0
  157. package/dist/files/library-query.d.ts +127 -0
  158. package/dist/files/library-query.js +322 -0
  159. package/dist/files/library-read.module.d.ts +9 -0
  160. package/dist/files/library-read.module.js +30 -0
  161. package/dist/files/library.controller.d.ts +77 -0
  162. package/dist/files/library.controller.js +235 -0
  163. package/dist/files/library.module.d.ts +9 -0
  164. package/dist/files/library.module.js +29 -0
  165. package/dist/files/library.schemas.d.ts +46 -0
  166. package/dist/files/library.schemas.js +49 -0
  167. package/dist/files/previewers.controller.d.ts +20 -0
  168. package/dist/files/previewers.controller.js +47 -0
  169. package/dist/files/previewers.d.ts +25 -11
  170. package/dist/files/previewers.js +43 -27
  171. package/dist/files/referenced-files.d.ts +150 -0
  172. package/dist/files/referenced-files.js +234 -0
  173. package/dist/git/gateway.js +2 -2
  174. package/dist/html/html-document.controller.d.ts +8 -1
  175. package/dist/html/html-document.controller.js +19 -1
  176. package/dist/html/html-document.service.d.ts +19 -4
  177. package/dist/html/html-document.service.js +43 -22
  178. package/dist/html/html-token.d.ts +10 -1
  179. package/dist/html/html-token.js +14 -0
  180. package/dist/html/html.module.js +8 -1
  181. package/dist/http/api.module.js +10 -5
  182. package/dist/http/request-signal.d.ts +8 -0
  183. package/dist/http/request-signal.js +14 -0
  184. package/dist/identity/settings.d.ts +26 -0
  185. package/dist/identity/settings.js +33 -2
  186. package/dist/inbox/inbox.module.js +2 -2
  187. package/dist/inbox/inbox.service.d.ts +8 -8
  188. package/dist/inbox/inbox.service.js +7 -7
  189. package/dist/infra/config/kernel-config.service.js +10 -5
  190. package/dist/infra/outbox/registry.d.ts +111 -2
  191. package/dist/infra/outbox/registry.js +104 -9
  192. package/dist/infra/throttler/named-throttlers.d.ts +2 -0
  193. package/dist/infra/throttler/named-throttlers.js +14 -0
  194. package/dist/kernel.module.js +3 -0
  195. package/dist/lifecycle/kernel-lifecycle.js +6 -0
  196. package/dist/models/purposes.js +1 -1
  197. package/dist/orgs/offboarding.js +1 -1
  198. package/dist/orgs/roles.d.ts +1 -1
  199. package/dist/orgs/roles.js +3 -3
  200. package/dist/orgs/settings.controller.d.ts +1 -1
  201. package/dist/orgs/settings.service.d.ts +75 -13
  202. package/dist/orgs/settings.service.js +104 -26
  203. package/dist/platform/exclusions.js +45 -8
  204. package/dist/platform/file-ref.d.ts +18 -3
  205. package/dist/platform/file-ref.js +22 -11
  206. package/dist/platform/operation.js +6 -2
  207. package/dist/platform/ops/admin.ops.js +5 -2
  208. package/dist/platform/ops/{schedules.ops.d.ts → automations.ops.d.ts} +4 -4
  209. package/dist/platform/ops/automations.ops.js +560 -0
  210. package/dist/platform/ops/devices.ops.d.ts +3 -1
  211. package/dist/platform/ops/devices.ops.js +77 -3
  212. package/dist/platform/ops/files.ops.d.ts +18 -0
  213. package/dist/platform/ops/files.ops.js +267 -0
  214. package/dist/platform/ops/inbox.ops.js +4 -4
  215. package/dist/platform/ops/org-settings.ops.js +6 -2
  216. package/dist/platform/ops/orgs.ops.js +2 -1
  217. package/dist/platform/ops/platform.ops.js +4 -4
  218. package/dist/platform/ops/shares.ops.js +2 -2
  219. package/dist/platform/platform-ops.module.d.ts +3 -2
  220. package/dist/platform/platform-ops.module.js +10 -5
  221. package/dist/platform/route-schemas.js +6 -3
  222. package/dist/push/jobs.d.ts +3 -3
  223. package/dist/push/jobs.js +2 -2
  224. package/dist/push/preferences.service.js +1 -1
  225. package/dist/push/push-owed.d.ts +3 -3
  226. package/dist/push/push-owed.js +6 -6
  227. package/dist/push/push.schemas.d.ts +4 -4
  228. package/dist/push/push.schemas.js +3 -3
  229. package/dist/push/recipients.d.ts +4 -4
  230. package/dist/push/recipients.js +23 -23
  231. package/dist/push/texts.d.ts +3 -3
  232. package/dist/push/texts.js +2 -2
  233. package/dist/push/triggers.d.ts +1 -1
  234. package/dist/roles/worker.module.js +18 -4
  235. package/dist/runtime/compaction-settings.service.d.ts +13 -1
  236. package/dist/runtime/compaction-settings.service.js +16 -1
  237. package/dist/runtime/compaction.service.d.ts +3 -1
  238. package/dist/runtime/compaction.service.js +3 -1
  239. package/dist/runtime/context/build.d.ts +24 -1
  240. package/dist/runtime/context/build.js +33 -11
  241. package/dist/runtime/context/cache-expiry.d.ts +31 -0
  242. package/dist/runtime/context/cache-expiry.js +60 -0
  243. package/dist/runtime/context/cache-ttl.d.ts +18 -0
  244. package/dist/runtime/context/cache-ttl.js +30 -0
  245. package/dist/runtime/context/compaction.d.ts +9 -2
  246. package/dist/runtime/context/compaction.js +64 -21
  247. package/dist/runtime/context/in-context-compaction.d.ts +156 -0
  248. package/dist/runtime/context/in-context-compaction.js +310 -0
  249. package/dist/runtime/context/run-context.d.ts +38 -0
  250. package/dist/runtime/context/run-context.js +54 -0
  251. package/dist/runtime/hook-calls.d.ts +2 -1
  252. package/dist/runtime/hook-calls.js +5 -2
  253. package/dist/runtime/maintenance.d.ts +16 -4
  254. package/dist/runtime/maintenance.js +79 -18
  255. package/dist/runtime/model-call.d.ts +34 -5
  256. package/dist/runtime/model-call.js +207 -22
  257. package/dist/runtime/providers.js +11 -1
  258. package/dist/runtime/run-finish.d.ts +4 -4
  259. package/dist/runtime/run-finish.js +3 -3
  260. package/dist/runtime/run-queue.js +12 -7
  261. package/dist/runtime/run-steps.d.ts +4 -2
  262. package/dist/runtime/run-steps.js +10 -5
  263. package/dist/runtime/run-worker.js +7 -1
  264. package/dist/runtime/runtime.module.js +6 -3
  265. package/dist/runtime/subagents/dispatch.js +11 -3
  266. package/dist/sandbox/browse-roots.d.ts +8 -0
  267. package/dist/sandbox/browse-roots.js +22 -0
  268. package/dist/sandbox/network-grants.d.ts +4 -4
  269. package/dist/sandbox/network-grants.js +7 -7
  270. package/dist/sandbox/operation-authority.d.ts +10 -3
  271. package/dist/sandbox/operation-authority.js +20 -10
  272. package/dist/sandbox/operation-intents.d.ts +3 -1
  273. package/dist/sandbox/operation-intents.js +11 -4
  274. package/dist/sandbox/permission-call-grants.js +2 -2
  275. package/dist/sandbox/permission-facts.js +1 -1
  276. package/dist/sandbox/review/classifier.d.ts +2 -2
  277. package/dist/sandbox/review/classifier.js +22 -11
  278. package/dist/sandbox/review/permission-candidate.d.ts +1 -1
  279. package/dist/sandbox/review/permission-candidate.js +1 -1
  280. package/dist/sandbox/sandbox.service.d.ts +15 -5
  281. package/dist/sandbox/sandbox.service.js +14 -8
  282. package/dist/shares/liveness.d.ts +26 -12
  283. package/dist/shares/liveness.js +79 -20
  284. package/dist/shares/revoke.d.ts +16 -11
  285. package/dist/shares/revoke.js +18 -14
  286. package/dist/shares/share-objects.d.ts +16 -21
  287. package/dist/shares/share-objects.js +25 -55
  288. package/dist/shares/share-open.service.d.ts +8 -4
  289. package/dist/shares/share-open.service.js +14 -11
  290. package/dist/shares/shares.controller.d.ts +16 -5
  291. package/dist/shares/shares.controller.js +39 -5
  292. package/dist/shares/shares.module.d.ts +4 -4
  293. package/dist/shares/shares.module.js +7 -6
  294. package/dist/shares/shares.schemas.d.ts +4 -0
  295. package/dist/shares/shares.schemas.js +2 -0
  296. package/dist/shares/shares.service.d.ts +93 -54
  297. package/dist/shares/shares.service.js +292 -131
  298. package/dist/shares/sweep.job.d.ts +18 -39
  299. package/dist/shares/sweep.job.js +47 -206
  300. package/dist/storage/purge.d.ts +1 -1
  301. package/dist/storage/purge.js +2 -2
  302. package/dist/tools/approvals.service.d.ts +6 -6
  303. package/dist/tools/approvals.service.js +19 -19
  304. package/dist/tools/builtin-names.d.ts +12 -12
  305. package/dist/tools/builtin-names.js +29 -29
  306. package/dist/tools/builtins/artifacts.d.ts +21 -13
  307. package/dist/tools/builtins/artifacts.js +81 -51
  308. package/dist/tools/builtins/{schedules.d.ts → automations.d.ts} +35 -33
  309. package/dist/tools/builtins/{schedules.js → automations.js} +236 -105
  310. package/dist/tools/builtins/builtin-tools.d.ts +15 -9
  311. package/dist/tools/builtins/builtin-tools.js +33 -22
  312. package/dist/tools/builtins/conversation-files.d.ts +23 -13
  313. package/dist/tools/builtins/conversation-files.js +62 -83
  314. package/dist/tools/builtins/image/generate.d.ts +7 -1
  315. package/dist/tools/builtins/image/generate.js +1 -1
  316. package/dist/tools/builtins/platform.js +1 -0
  317. package/dist/tools/builtins/sandbox/common.d.ts +6 -2
  318. package/dist/tools/builtins/sandbox/deliver.js +6 -7
  319. package/dist/tools/builtins/sandbox/fetch-attachment.d.ts +6 -5
  320. package/dist/tools/builtins/sandbox/fetch-attachment.js +19 -12
  321. package/dist/tools/call-scope.d.ts +1 -1
  322. package/dist/tools/git-asks.js +1 -1
  323. package/dist/tools/git-push-policy.d.ts +3 -3
  324. package/dist/tools/git-push-policy.js +6 -6
  325. package/dist/tools/network-asks.d.ts +3 -3
  326. package/dist/tools/network-asks.js +3 -3
  327. package/dist/tools/pipeline.d.ts +4 -4
  328. package/dist/tools/pipeline.js +2 -2
  329. package/dist/tools/policy.d.ts +3 -3
  330. package/dist/tools/policy.js +3 -3
  331. package/dist/tools/tools.module.js +15 -9
  332. package/dist/ui/call-extension.d.ts +6 -4
  333. package/dist/ui/call-extension.js +5 -4
  334. package/dist/ui/embed-token.js +6 -3
  335. package/dist/ui/registry.d.ts +21 -5
  336. package/dist/ui/registry.js +24 -6
  337. package/dist/ui/ui.schemas.d.ts +22 -0
  338. package/dist/ui/ui.schemas.js +22 -4
  339. package/dist/ui/views.controller.d.ts +13 -3
  340. package/dist/ui/views.controller.js +33 -2
  341. package/dist/ui/views.d.ts +29 -1
  342. package/dist/ui/views.js +131 -7
  343. package/package.json +3 -3
  344. package/src/migrations/0188_automations_rename.sql +309 -0
  345. package/src/migrations/0189_event_automations.sql +136 -0
  346. package/src/migrations/0190_file_library.sql +285 -0
  347. package/src/migrations/0191_file_library_copy.sql +4 -0
  348. package/dist/platform/ops/schedules.ops.js +0 -509
  349. package/dist/schedules/effective-settings.d.ts +0 -22
  350. package/dist/schedules/effective-settings.js +0 -18
  351. package/dist/schedules/errors.d.ts +0 -8
  352. package/dist/schedules/errors.js +0 -8
  353. package/dist/schedules/job-ids.d.ts +0 -81
  354. package/dist/schedules/job-ids.js +0 -95
  355. package/dist/schedules/schedules.module.d.ts +0 -16
  356. package/dist/schedules/schedules.schemas.js +0 -213
  357. package/dist/schedules/store.module.d.ts +0 -6
  358. package/dist/schedules/types.d.ts +0 -110
  359. /package/dist/{schedules → automations}/types.js +0 -0
@@ -59,7 +59,7 @@ export type MessageContext = Pick<EventPayload<"user_message">, "sender" | "time
59
59
  * - `sender`: the account's display name and org role at send time; the org's anonymous guest
60
60
  * account (`org_anonymous_accounts`) is `{ name: <senderName, else "Anonymous guest">, role:
61
61
  * "guest", anonymous: true }`. Names are sanitised; an empty one leaves `sender` out.
62
- * - `timeZone`: the override (`timeZoneOverride`, when valid: a scheduled task's zone, scheduled
62
+ * - `timeZone`: the override (`timeZoneOverride`, when valid: an automation's zone, scheduled
63
63
  * tasks spec §6), else what the IM platform gave for the sender (`im`, when valid), else the
64
64
  * account's setting, else the browser's (when valid), else the org default, else UTC. The
65
65
  * anonymous guest account has no setting of its own, so it gets the IM value or the org default.
@@ -77,6 +77,6 @@ export declare function readMessageContext(t: KernelSchemaDb, input: {
77
77
  browser?: BrowserContext | undefined;
78
78
  /** An IM message: what the platform gave for the sender (maintainer decision 2026-11-08). */
79
79
  im?: ImSenderContext | undefined;
80
- /** A zone that beats every other source (a scheduled task's zone); internal callers only. */
80
+ /** A zone that beats every other source (an automation's zone); internal callers only. */
81
81
  timeZoneOverride?: string | undefined;
82
82
  }): Promise<MessageContext>;
@@ -84,7 +84,7 @@ export async function recipientLocale(t, input) {
84
84
  * - `sender`: the account's display name and org role at send time; the org's anonymous guest
85
85
  * account (`org_anonymous_accounts`) is `{ name: <senderName, else "Anonymous guest">, role:
86
86
  * "guest", anonymous: true }`. Names are sanitised; an empty one leaves `sender` out.
87
- * - `timeZone`: the override (`timeZoneOverride`, when valid: a scheduled task's zone, scheduled
87
+ * - `timeZone`: the override (`timeZoneOverride`, when valid: an automation's zone, scheduled
88
88
  * tasks spec §6), else what the IM platform gave for the sender (`im`, when valid), else the
89
89
  * account's setting, else the browser's (when valid), else the org default, else UTC. The
90
90
  * anonymous guest account has no setting of its own, so it gets the IM value or the org default.
@@ -12,6 +12,7 @@ export declare class PermissionProfileStore {
12
12
  account_id: string;
13
13
  agent_id: string;
14
14
  archived_at: Date | null;
15
+ automation_id: string | null;
15
16
  consumed_seq: string;
16
17
  create_request_hash: string | null;
17
18
  create_request_id: string | null;
@@ -31,11 +32,11 @@ export declare class PermissionProfileStore {
31
32
  project_path: string | null;
32
33
  queue_pause_reason: string | null;
33
34
  queue_paused: boolean;
34
- scheduled_task_id: string | null;
35
35
  selection: unknown;
36
36
  source: "channel_dm" | "channel_group" | "subagent" | "web";
37
37
  subagent_depth: number;
38
38
  subagent_type: string | null;
39
+ subject: import("../db/kernel-schema.js").ConversationSubject | null;
39
40
  title: string | null;
40
41
  title_attempts: number;
41
42
  title_source: import("../db/kernel-schema.js").TitleSource | null;
@@ -16,6 +16,9 @@ export declare const FirstMessageBody: z.ZodObject<{
16
16
  uri: z.ZodString;
17
17
  }, z.core.$strict>>>;
18
18
  files: z.ZodOptional<z.ZodArray<z.ZodUUID>>;
19
+ projectFiles: z.ZodOptional<z.ZodArray<z.ZodObject<{
20
+ path: z.ZodString;
21
+ }, z.core.$strict>>>;
19
22
  model: z.ZodOptional<z.ZodObject<{
20
23
  provider: z.ZodString;
21
24
  model: z.ZodString;
@@ -123,7 +123,7 @@ let PermissionProfilesService = class PermissionProfilesService {
123
123
  }
124
124
  async setLocked(orgId, id, accountId, body, binding) {
125
125
  let row = await this.store.own(orgId, id, accountId);
126
- if (row.parent_conversation_id || row.kind !== "chat" || row.scheduled_task_id)
126
+ if (row.parent_conversation_id || row.kind !== "chat" || row.automation_id)
127
127
  throw new ApiError("forbidden", "Only interactive root conversations have editable permissions");
128
128
  const subject = {
129
129
  orgId,
@@ -78,7 +78,7 @@ export interface SuggestionEligibilityInput {
78
78
  }
79
79
  /**
80
80
  * Whether a finished run may get a suggestion by its outcome, conversation and trigger (spec §2):
81
- * `completed` or `max_steps`, a `chat` conversation from `web`, not a scheduled or compact run.
81
+ * `completed` or `max_steps`, a `chat` conversation from `web`, not an automation's or compact run.
82
82
  * The final reply, freshness and the switches are checked elsewhere.
83
83
  */
84
84
  export declare function suggestionEligible(i: SuggestionEligibilityInput): boolean;
@@ -107,7 +107,8 @@ export function buildSuggestionRequest(input) {
107
107
  reference = ref.request;
108
108
  // every event of the snapshot (it ends at the run's terminal event): absorbable events past
109
109
  // the recorded absorbedUpToSeq stay out, anything else model-visible after the final reply
110
- // breaks the check below
110
+ // breaks the check below. It keeps the baseline's recorded cacheTtl: the same tier as the
111
+ // last call keeps its cache entry whole (idle compaction spec §9.4)
111
112
  extended = assembleModelRequest({ ...gathered.input, events });
112
113
  }
113
114
  catch (err) {
@@ -147,7 +148,7 @@ export function buildSuggestionRequest(input) {
147
148
  }
148
149
  /**
149
150
  * Whether a finished run may get a suggestion by its outcome, conversation and trigger (spec §2):
150
- * `completed` or `max_steps`, a `chat` conversation from `web`, not a scheduled or compact run.
151
+ * `completed` or `max_steps`, a `chat` conversation from `web`, not an automation's or compact run.
151
152
  * The final reply, freshness and the switches are checked elsewhere.
152
153
  */
153
154
  export function suggestionEligible(i) {
@@ -155,6 +156,7 @@ export function suggestionEligible(i) {
155
156
  i.kind === "chat" &&
156
157
  i.source === "web" &&
157
158
  i.trigger !== "schedule" &&
159
+ i.trigger !== "automation_event" &&
158
160
  i.trigger !== "compact");
159
161
  }
160
162
  // C0 and C1 controls (newlines are split on first; a tab becomes a space)
@@ -1,5 +1,6 @@
1
1
  import { type ModelUsage } from "@capybara-hq/plugin-sdk";
2
2
  import type { Job, Queue, Worker } from "bullmq";
3
+ import { ConversationMedia } from "../files/conversation-media.js";
3
4
  import { SettingsService } from "../identity/settings.js";
4
5
  import { KernelConfigService } from "../infra/config/kernel-config.service.js";
5
6
  import { KernelDb } from "../infra/database/kernel-db.js";
@@ -9,7 +10,6 @@ import { OrgSettingsService } from "../orgs/settings.service.js";
9
10
  import { type AuditEntry, type HookRunner } from "../runtime/hook-calls.js";
10
11
  import { ProviderRegistry } from "../runtime/providers.js";
11
12
  import { UsageReportJobs } from "../runtime/usage-report-jobs.js";
12
- import { AttachmentsService } from "./attachments.service.js";
13
13
  import { EventLog } from "./event-log.js";
14
14
  import type { ConversationEvent, EventPayload } from "./events.js";
15
15
  import { PromptSuggestionStore } from "./prompt-suggestion-store.js";
@@ -58,7 +58,7 @@ export declare class PromptSuggestionGenerator {
58
58
  /** The platform's compaction settings (the org's reserve for the fit guard). */
59
59
  private readonly settings;
60
60
  /** The run's media, as the run's steps load it. */
61
- private readonly attachments;
61
+ private readonly media;
62
62
  private readonly store;
63
63
  private readonly config;
64
64
  private readonly log;
@@ -74,7 +74,7 @@ export declare class PromptSuggestionGenerator {
74
74
  /** The platform's compaction settings (the org's reserve for the fit guard). */
75
75
  settings: Pick<SettingsService, "get">,
76
76
  /** The run's media, as the run's steps load it. */
77
- attachments: Pick<AttachmentsService, "mediaInfo" | "fetchMedia">, store: Pick<PromptSuggestionStore, "isFresh" | "put">, config: KernelConfigService, log: Pick<KernelLogger, "debug" | "warn">, txHost: TransactionHost, timeoutMs?: () => number);
77
+ media: Pick<ConversationMedia, "mediaInfo" | "fetchMedia">, store: Pick<PromptSuggestionStore, "isFresh" | "put">, config: KernelConfigService, log: Pick<KernelLogger, "debug" | "warn">, txHost: TransactionHost, timeoutMs?: () => number);
78
78
  private get db();
79
79
  /**
80
80
  * One suggestion for the run (spec §1–§4); `shutdown` aborts the call (the worker stopping).
@@ -16,6 +16,8 @@ import { loadSnapshotMedia } from "../evals/reconstruct.js";
16
16
  import { takeSnapshot, toEvents } from "../evals/snapshot.js";
17
17
  import { ExtensionsModule } from "../extensions/extensions.module.js";
18
18
  import { ExtensionHost } from "../extensions/host.js";
19
+ import { ConversationMedia } from "../files/conversation-media.js";
20
+ import { LibraryReadModule } from "../files/library-read.module.js";
19
21
  import { audit } from "../identity/audit.js";
20
22
  import { IdentityModule } from "../identity/identity.module.js";
21
23
  import { SettingsService } from "../identity/settings.js";
@@ -31,8 +33,6 @@ import { fireObserve, hookDeniedAudit, hookDeniedEvent, hookRequestOf, } from ".
31
33
  import { consumeModelStream, deltaChars } from "../runtime/model-call.js";
32
34
  import { ProviderRegistry, ProvidersModule } from "../runtime/providers.js";
33
35
  import { UsageReportJobs, UsageReportJobsModule } from "../runtime/usage-report-jobs.js";
34
- import { AttachmentsModule } from "./attachments.module.js";
35
- import { AttachmentsService } from "./attachments.service.js";
36
36
  import { EventLog, EventLogModule } from "./event-log.js";
37
37
  import { buildSuggestionRequest, cleanSuggestion, lastModelCallOf, PROMPT_SUGGESTION_TIMEOUT_MS, suggestionEligible, suggestionStale, } from "./prompt-suggestion-request.js";
38
38
  import { PromptSuggestionStore } from "./prompt-suggestion-store.js";
@@ -98,7 +98,7 @@ let PromptSuggestionGenerator = class PromptSuggestionGenerator {
98
98
  usage;
99
99
  orgSettings;
100
100
  settings;
101
- attachments;
101
+ media;
102
102
  store;
103
103
  config;
104
104
  log;
@@ -112,7 +112,7 @@ let PromptSuggestionGenerator = class PromptSuggestionGenerator {
112
112
  /** The platform's compaction settings (the org's reserve for the fit guard). */
113
113
  settings,
114
114
  /** The run's media, as the run's steps load it. */
115
- attachments, store, config, log, txHost, timeoutMs = () => PROMPT_SUGGESTION_TIMEOUT_MS) {
115
+ media, store, config, log, txHost, timeoutMs = () => PROMPT_SUGGESTION_TIMEOUT_MS) {
116
116
  this.kdb = kdb;
117
117
  this.eventLog = eventLog;
118
118
  this.registry = registry;
@@ -120,7 +120,7 @@ let PromptSuggestionGenerator = class PromptSuggestionGenerator {
120
120
  this.usage = usage;
121
121
  this.orgSettings = orgSettings;
122
122
  this.settings = settings;
123
- this.attachments = attachments;
123
+ this.media = media;
124
124
  this.store = store;
125
125
  this.config = config;
126
126
  this.log = log;
@@ -177,8 +177,8 @@ let PromptSuggestionGenerator = class PromptSuggestionGenerator {
177
177
  let media;
178
178
  try {
179
179
  media = await loadSnapshotMedia(snapshot, last.seq, info, {
180
- info: (orgId, convId, ids) => this.attachments.mediaInfo(orgId, convId, ids),
181
- fetch: (orgId, convId, ids, caps) => this.attachments.fetchMedia(orgId, convId, ids, caps),
180
+ info: (orgId, convId, ids) => this.media.mediaInfo(orgId, convId, ids),
181
+ fetch: (orgId, convId, ids, caps) => this.media.fetchMedia(orgId, convId, ids, caps),
182
182
  });
183
183
  }
184
184
  catch {
@@ -214,7 +214,7 @@ let PromptSuggestionGenerator = class PromptSuggestionGenerator {
214
214
  try {
215
215
  out = await consumeModelStream(provider, request, info.streamIdleTimeoutMs ?? this.config.get().runtime.streamIdleMs, signal, (ev) => {
216
216
  streamedChars += deltaChars(ev);
217
- });
217
+ }, this.log);
218
218
  }
219
219
  catch (err) {
220
220
  if (shutdown.aborted) {
@@ -447,7 +447,7 @@ PromptSuggestionGenerator = __decorate([
447
447
  __param(4, Inject(UsageReportJobs)),
448
448
  __param(5, Inject(OrgSettingsService)),
449
449
  __param(6, Inject(SettingsService)),
450
- __param(7, Inject(AttachmentsService)),
450
+ __param(7, Inject(ConversationMedia)),
451
451
  __param(8, Inject(PromptSuggestionStore)),
452
452
  __param(9, Inject(KernelConfigService)),
453
453
  __param(10, Inject(KERNEL_LOGGER)),
@@ -555,7 +555,8 @@ PromptSuggestionsModule = __decorate([
555
555
  UsageReportJobsModule,
556
556
  OrgSettingsModule,
557
557
  IdentityModule,
558
- AttachmentsModule,
558
+ // the run's media: library files the conversation refers to, and `read` copies
559
+ LibraryReadModule,
559
560
  PROMPT_SUGGESTION_QUEUE_MODULE,
560
561
  ],
561
562
  providers: [PromptSuggestionStore, PromptSuggestionGenerator, PromptSuggestionQueue],
@@ -1,7 +1,7 @@
1
1
  import { type ModelRef } from "../agents/definition.js";
2
+ import type { ScheduleMarker } from "../automations/types.js";
2
3
  import type { KernelSchemaDb } from "../db/kernel-schema.js";
3
4
  import { ApiError } from "../errors.js";
4
- import type { ScheduleMarker } from "../schedules/types.js";
5
5
  import { type InvocationRecord, type RenderedInvocation } from "../skills/invoke.js";
6
6
  import type { AttachmentRef } from "./conversations.service.js";
7
7
  import { type AppendEvent, type EventLog } from "./event-log.js";
@@ -30,7 +30,7 @@ export interface QueuedSkill {
30
30
  record: InvocationRecord;
31
31
  }
32
32
  /**
33
- * A scheduled task's queued message (scheduled tasks spec §6), stored in
33
+ * An automation's queued message (scheduled tasks spec §6), stored in
34
34
  * `conversation_queue.schedule`: the marker the `user_message` carries and the task's zone, which
35
35
  * becomes the message's `timeZone` (the top-priority override of `readMessageContext`).
36
36
  */
@@ -104,9 +104,11 @@ export interface QueueRow {
104
104
  effort: string | null;
105
105
  skill: unknown;
106
106
  schedule: unknown;
107
+ /** An event automation's marker (collaboration spec §4.6); null for any other message. */
108
+ automation_event: unknown;
107
109
  created_at: Date;
108
110
  }
109
- export declare const COLUMNS: readonly ["id", "conversation_id", "account_id", "position", "text", "content", "attachments", "files", "client_message_id", "model", "effort", "skill", "schedule", "created_at"];
111
+ export declare const COLUMNS: readonly ["id", "conversation_id", "account_id", "position", "text", "content", "attachments", "files", "client_message_id", "model", "effort", "skill", "schedule", "automation_event", "created_at"];
110
112
  /**
111
113
  * Queued text as the event log will store it: NUL becomes U+FFFD (PG rejects NUL in text and
112
114
  * jsonb), the mapping `payloadJson` applies to a direct send (final review m1).
@@ -127,7 +129,8 @@ export declare function storedSkill(invokedAs: string, invoked: RenderedInvocati
127
129
  };
128
130
  /**
129
131
  * The `user_message` a queued item becomes, as `postUserMessage` would have written it; a scheduled
130
- * task's item carries its marker (without the stored zone, which is in `context`).
132
+ * task's item carries its marker (without the stored zone, which is in `context`), an event
133
+ * automation's item its event marker.
131
134
  */
132
135
  export declare function queuedUserMessage(r: QueueRow, context?: MessageContext): AppendEvent;
133
136
  /**
@@ -29,6 +29,7 @@ export const COLUMNS = [
29
29
  "effort",
30
30
  "skill",
31
31
  "schedule",
32
+ "automation_event",
32
33
  "created_at",
33
34
  ];
34
35
  /**
@@ -80,12 +81,14 @@ export function storedSkill(invokedAs, invoked) {
80
81
  }
81
82
  /**
82
83
  * The `user_message` a queued item becomes, as `postUserMessage` would have written it; a scheduled
83
- * task's item carries its marker (without the stored zone, which is in `context`).
84
+ * task's item carries its marker (without the stored zone, which is in `context`), an event
85
+ * automation's item its event marker.
84
86
  */
85
87
  export function queuedUserMessage(r, context = {}) {
86
88
  const attachments = r.attachments;
87
89
  const skill = r.skill;
88
90
  const marker = queuedMarker(r);
91
+ const event = r.automation_event;
89
92
  return {
90
93
  type: "user_message",
91
94
  idemKey: userMessageIdemKey(r.client_message_id),
@@ -101,6 +104,7 @@ export function queuedUserMessage(r, context = {}) {
101
104
  clientMessageId: r.client_message_id,
102
105
  ...(skill !== null && { skill: skill.record }),
103
106
  ...(marker !== undefined && { schedule: marker }),
107
+ ...(event !== null && event !== undefined && { automationEvent: event }),
104
108
  },
105
109
  };
106
110
  }
@@ -136,7 +140,7 @@ export async function appendQueuedIn(t, eventLog, conversationId, r) {
136
140
  payload: { ...next, byAccountId: r.account_id, reason: "user" },
137
141
  });
138
142
  }
139
- // run context spec §3.4: no browser values were stored with a leftover row; a scheduled task's
143
+ // run context spec §3.4: no browser values were stored with a leftover row; an automation's
140
144
  // item stored its task's zone, which wins (scheduled tasks spec §6)
141
145
  // org-filter: reads the org of the conversation the caller holds the row lock of
142
146
  const org = await t
@@ -30,7 +30,7 @@ export declare class ConversationQueue {
30
30
  * credentials. The same `clientMessageId` again returns the queued item (`created: false`), or,
31
31
  * when it was already sent, the sent `user_message` with `item: null`. Then `ensureRun`: on an
32
32
  * idle conversation the item goes out at once. `internal` (kernel callers only, never HTTP): a
33
- * scheduled task's marker and zone, stored with the item and written with its `user_message`
33
+ * automation's marker and zone, stored with the item and written with its `user_message`
34
34
  * (scheduled tasks spec §6).
35
35
  */
36
36
  add(orgId: string, conversationId: string, accountId: string, input: QueueInput, internal?: InternalMessageOptions): Promise<{
@@ -41,9 +41,9 @@ export declare class ConversationQueue {
41
41
  private addIn;
42
42
  /**
43
43
  * Changes a queued item's text (its resources and files stay as queued). A skill invocation's
44
- * text is its arguments: the skill is rendered again with them now. A scheduled task's item
45
- * becomes the person's message: its schedule marker (and the task's zone) is dropped, so the run
46
- * it triggers is attended (scheduled tasks spec §7).
44
+ * text is its arguments: the skill is rendered again with them now. An automation's item
45
+ * becomes the person's message: its schedule or event marker (and the task's zone) is dropped,
46
+ * so the run it triggers is attended (scheduled tasks spec §7).
47
47
  */
48
48
  edit(orgId: string, conversationId: string, accountId: string, itemId: string, text: string): Promise<QueueItem>;
49
49
  private editIn;
@@ -53,7 +53,7 @@ export declare class ConversationQueue {
53
53
  * Sends a queued item now: it leaves the queue and is posted as a user message in the same
54
54
  * transaction (an interjection when a run is active; the items before it keep their place).
55
55
  * Racing the dispatcher, exactly one of them takes the item; the loser sees it gone (404). A
56
- * scheduled task's item is sent as the person's message, without its schedule marker
56
+ * automation's item is sent as the person's message, without its schedule marker
57
57
  * (scheduled tasks spec §7).
58
58
  */
59
59
  sendNow(orgId: string, conversationId: string, accountId: string, itemId: string): Promise<ConversationEvent>;
@@ -10,11 +10,12 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
10
10
  import { randomUUID } from "node:crypto";
11
11
  import { Inject, Injectable } from "@nestjs/common";
12
12
  import { sql } from "kysely";
13
+ import { releaseQueuedTaskRunIn } from "../automations/run-tracker.js";
14
+ import { ApiError } from "../errors.js";
13
15
  import { KernelDb } from "../infra/database/kernel-db.js";
14
16
  import { TransactionHost } from "../infra/database/transaction-host.js";
15
17
  import { Transactional } from "../infra/database/transactional.decorator.js";
16
18
  import { RunControl as RunControlService } from "../runtime/run-control.js";
17
- import { releaseQueuedTaskRunIn } from "../schedules/run-tracker.js";
18
19
  import { notInvocable } from "../skills/invoke.js";
19
20
  import { ConversationsService, NO_REPLY_SKIPS, } from "./conversations.service.js";
20
21
  import { EventLog, payloadJson } from "./event-log.js";
@@ -70,7 +71,7 @@ let ConversationQueue = class ConversationQueue {
70
71
  * credentials. The same `clientMessageId` again returns the queued item (`created: false`), or,
71
72
  * when it was already sent, the sent `user_message` with `item: null`. Then `ensureRun`: on an
72
73
  * idle conversation the item goes out at once. `internal` (kernel callers only, never HTTP): a
73
- * scheduled task's marker and zone, stored with the item and written with its `user_message`
74
+ * automation's marker and zone, stored with the item and written with its `user_message`
74
75
  * (scheduled tasks spec §6).
75
76
  */
76
77
  async add(orgId, conversationId, accountId, input, internal = {}) {
@@ -114,8 +115,12 @@ let ConversationQueue = class ConversationQueue {
114
115
  .select("last_seq")
115
116
  .where("id", "=", conversationId)
116
117
  .where("org_id", "=", orgId)
118
+ // deleted after the caller's check: no files are attached to it
119
+ .where("deleted_at", "is", null)
117
120
  .forUpdate()
118
- .executeTakeFirstOrThrow();
121
+ .executeTakeFirst();
122
+ if (!conv)
123
+ throw new ApiError("conversation.not_found", "Conversation not found");
119
124
  const existing = await t
120
125
  .selectFrom("conversation_queue")
121
126
  .select(COLUMNS)
@@ -140,7 +145,7 @@ let ConversationQueue = class ConversationQueue {
140
145
  const fileMeta = blocks.flatMap((b) => (b.type === "image" || b.type === "document" || b.type === "file") && b.source.kind === "ref"
141
146
  ? [
142
147
  {
143
- attachmentId: b.source.attachmentId,
148
+ attachmentId: b.source.fileId,
144
149
  name: b.name ?? "",
145
150
  mediaType: b.mediaType,
146
151
  ...(b.size !== undefined && { size: b.size }),
@@ -174,6 +179,7 @@ let ConversationQueue = class ConversationQueue {
174
179
  timeZone: internal.timeZoneOverride,
175
180
  }),
176
181
  }),
182
+ automation_event: internal.automationEvent === undefined ? null : JSON.stringify(internal.automationEvent),
177
183
  })
178
184
  .returning(COLUMNS)
179
185
  .executeTakeFirstOrThrow();
@@ -184,9 +190,9 @@ let ConversationQueue = class ConversationQueue {
184
190
  }
185
191
  /**
186
192
  * Changes a queued item's text (its resources and files stay as queued). A skill invocation's
187
- * text is its arguments: the skill is rendered again with them now. A scheduled task's item
188
- * becomes the person's message: its schedule marker (and the task's zone) is dropped, so the run
189
- * it triggers is attended (scheduled tasks spec §7).
193
+ * text is its arguments: the skill is rendered again with them now. An automation's item
194
+ * becomes the person's message: its schedule or event marker (and the task's zone) is dropped,
195
+ * so the run it triggers is attended (scheduled tasks spec §7).
190
196
  */
191
197
  async edit(orgId, conversationId, accountId, itemId, text) {
192
198
  const conv = await this.conversations.writable(orgId, conversationId, accountId);
@@ -214,15 +220,15 @@ let ConversationQueue = class ConversationQueue {
214
220
  const t = this.db.db;
215
221
  const cur = await t
216
222
  .selectFrom("conversation_queue")
217
- .select(["attachments", "files", "content", "skill", "schedule"])
223
+ .select(["attachments", "files", "content", "skill", "schedule", "automation_event"])
218
224
  .where("id", "=", itemId)
219
225
  .where("conversation_id", "=", conversationId)
220
226
  .forUpdate()
221
227
  .executeTakeFirst();
222
228
  if (!cur)
223
229
  throw itemNotFound();
224
- // a person's words now: the task's run for this item will not happen (scheduled tasks §6)
225
- await releaseQueuedTaskRunIn(t, cur.schedule);
230
+ // a person's words now: the task's run for this item will not happen (automations §6)
231
+ await releaseQueuedTaskRunIn(t, cur);
226
232
  const skill = cur.skill;
227
233
  checkText(text, cur.files.length, cur.attachments.length, skill !== null);
228
234
  // an invocation's first block is its rendered text: replace it and the record
@@ -233,6 +239,7 @@ let ConversationQueue = class ConversationQueue {
233
239
  text: noNul(text),
234
240
  // edited by a person: no longer the task's message
235
241
  schedule: null,
242
+ automation_event: null,
236
243
  updated_at: sql `now()`,
237
244
  ...(stored !== undefined && {
238
245
  skill: stored.skill,
@@ -258,12 +265,12 @@ let ConversationQueue = class ConversationQueue {
258
265
  .deleteFrom("conversation_queue")
259
266
  .where("id", "=", itemId)
260
267
  .where("conversation_id", "=", conversationId)
261
- .returning(["id", "schedule"])
268
+ .returning(["id", "schedule", "automation_event"])
262
269
  .executeTakeFirst();
263
270
  if (!gone)
264
271
  throw itemNotFound();
265
- // a task's queued message deleted by a person: its run is skipped (scheduled tasks §6)
266
- await releaseQueuedTaskRunIn(t, gone.schedule);
272
+ // a task's queued message deleted by a person: its run is skipped (automations §6)
273
+ await releaseQueuedTaskRunIn(t, gone);
267
274
  await unpauseIfEmpty(t, conversationId);
268
275
  // the wakes an unpause releases for the tree are owed with it (transactional outbox spec §6)
269
276
  await this.runs.oweHeldTreeIn(conversationId);
@@ -272,7 +279,7 @@ let ConversationQueue = class ConversationQueue {
272
279
  * Sends a queued item now: it leaves the queue and is posted as a user message in the same
273
280
  * transaction (an interjection when a run is active; the items before it keep their place).
274
281
  * Racing the dispatcher, exactly one of them takes the item; the loser sees it gone (404). A
275
- * scheduled task's item is sent as the person's message, without its schedule marker
282
+ * automation's item is sent as the person's message, without its schedule marker
276
283
  * (scheduled tasks spec §7).
277
284
  */
278
285
  async sendNow(orgId, conversationId, accountId, itemId) {
@@ -319,8 +326,12 @@ let ConversationQueue = class ConversationQueue {
319
326
  throw itemNotFound();
320
327
  const sent = await alreadySent(t, conversationId, row.client_message_id);
321
328
  // sent by a person: their message, not the task's, whose run is skipped
322
- await releaseQueuedTaskRunIn(t, row.schedule);
323
- const out = await appendQueuedIn(t, this.eventLog, conversationId, { ...row, schedule: null });
329
+ await releaseQueuedTaskRunIn(t, row);
330
+ const out = await appendQueuedIn(t, this.eventLog, conversationId, {
331
+ ...row,
332
+ schedule: null,
333
+ automation_event: null,
334
+ });
324
335
  await unpauseIfEmpty(t, conversationId);
325
336
  // sent during the run, the item is the author's message like a direct send: it skips the
326
337
  // pending questions they may answer (reply-while-question spec §4.2)
@@ -1,6 +1,7 @@
1
- import { type EmbedClaims, type ExtensionContext, type ExtensionManifest, type ExtensionPointRef, type HttpAccess, type Logger, type RouteCaller, resolveUiSlots, type SetupCheckArgs, type SetupGuidePlace, type ToolHandler, type ToolSpec, type ToolWatcher } from "@capybara-hq/plugin-sdk";
1
+ import { type EmbedClaims, type ExtensionContext, type ExtensionManifest, type ExtensionPointRef, type HttpAccess, type Logger, type RouteCaller, resolveUiSlots, type SetupCheckArgs, type SetupGuidePlace, type ToolHandler, type ToolSpec, type ToolWatcher, type TriggerEvent } from "@capybara-hq/plugin-sdk";
2
2
  import type { Redis } from "ioredis";
3
3
  import { Kysely } from "kysely";
4
+ import type { TriggerEventsService } from "../automations/events/trigger-events.service.js";
4
5
  import type { DeviceAccessService } from "../device-access/device-access.service.js";
5
6
  import type { DialInAccess } from "../dial-in/access.js";
6
7
  import { type RegisteredHook } from "../extensions/hooks.js";
@@ -13,7 +14,7 @@ import type { HookRunner } from "../runtime/hook-calls.js";
13
14
  import type { DeviceReports } from "../sandbox/device-reports.js";
14
15
  import type { ShareLiveness } from "../shares/liveness.js";
15
16
  import type { EmbedTokens } from "../ui/embed-token.js";
16
- import { type UiActionHandler, type UiRender } from "../ui/registry.js";
17
+ import { type UiActionHandler, type UiQueryHandler, type UiRender } from "../ui/registry.js";
17
18
  import { type BusSubscriber } from "./bus.js";
18
19
  import { type ExtensionNetServices } from "./net.js";
19
20
  import { type Keyring } from "./secrets.js";
@@ -76,6 +77,12 @@ export interface KernelDeps {
76
77
  * a test, the CLI): `ctx.deviceAccess` calls are refused.
77
78
  */
78
79
  deviceAccess?: () => DeviceAccessBackend | undefined;
80
+ /**
81
+ * What `ctx.triggers` calls through (`TriggerEventsService`), found at the time of use like
82
+ * `deviceAccess`. Absent, or resolving to undefined (a ctx built alone in a test, the CLI):
83
+ * `ctx.triggers.emit` rejects.
84
+ */
85
+ triggers?: () => TriggersBackend | undefined;
79
86
  runWorkers: boolean;
80
87
  /** 内核 logger(`debug` 可选:插件 Logger 没有它,测试可不给)。 */
81
88
  log: Logger & {
@@ -84,6 +91,16 @@ export interface KernelDeps {
84
91
  }
85
92
  /** What `ctx.deviceAccess` calls through (`DeviceAccessService`). */
86
93
  export type DeviceAccessBackend = Pick<DeviceAccessService, "ensureService" | "request" | "reportBlockedHosts" | "streamTicket" | "addNetworkHosts" | "answerHandoff">;
94
+ /** What `ctx.triggers` calls through (`TriggerEventsService`). */
95
+ export type TriggersBackend = Pick<TriggerEventsService, "emit">;
96
+ /**
97
+ * A plain-data copy of an emitted event, taken once at the ctx boundary (check-then-use): every
98
+ * own enumerable field is read once (a getter cannot change a value after it was validated),
99
+ * prototypes and accessors are dropped. `cause.call` keeps its original reference, since the
100
+ * pipeline's call scope is a symbol-keyed field and the context holds an `AbortSignal`, neither of
101
+ * which a clone keeps; only its scope is read. Data that cannot be cloned is `invalid_event`.
102
+ */
103
+ export declare function snapshotTriggerEvent(event: TriggerEvent): TriggerEvent;
87
104
  /**
88
105
  * What `ctx.ui.verifyEmbedToken` returns for a valid token: the signed claims, with an org
89
106
  * token's `role` replaced by the caller's role at verification time.
@@ -178,6 +195,8 @@ export type KernelExtensionContext = ExtensionContext & {
178
195
  uiViews: ReadonlyMap<string, UiRender>;
179
196
  /** 经 `ctx.ui.action` 注册的动作处理函数(按贡献 id)。 */
180
197
  uiActions: ReadonlyMap<string, UiActionHandler>;
198
+ /** Query handlers registered through `ctx.ui.query`, by component id. */
199
+ uiQueries: ReadonlyMap<string, UiQueryHandler>;
181
200
  /** Setup checks registered through `ctx.setup.check`, by id. */
182
201
  setupChecks: ReadonlyMap<string, RegisteredSetupCheck>;
183
202
  /**
@@ -209,6 +228,8 @@ export declare class LiveConfig {
209
228
  * (through `deps.dialIn`; another device throws `ExtensionPermissionError`); `devices` only for
210
229
  * an extension that provides `device-provider@1`, `reportChanged` only for a live device bound to
211
230
  * this extension (through `deps.devices`; another device throws `ExtensionPermissionError`);
231
+ * `triggers` only with `permissions.triggers`, each emit only of a declared event type, stored
232
+ * in the event's org scope (through `deps.triggers`);
212
233
  * `http.route`
213
234
  * only the method + path declared in `permissions.http` (the record carries the declared access and
214
235
  * its mount, see {@link Route}); `tools.register` only names declared in