@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
@@ -1,10 +1,13 @@
1
- import type { ConversationSource } from "@capybara-hq/plugin-sdk";
1
+ import type { ConversationSource, TriggerSubject } from "@capybara-hq/plugin-sdk";
2
2
  import { AgentLookup } from "../agents/agent-lookup.js";
3
3
  import type { ModelRef } from "../agents/definition.js";
4
4
  import type { AgentAvatarView } from "../agents/profile.js";
5
- import type { TitleSource } from "../db/kernel-schema.js";
5
+ import type { AutomationEventMarker, ScheduleMarker } from "../automations/types.js";
6
+ import type { ConversationSubject, TitleSource } from "../db/kernel-schema.js";
6
7
  import { ConversationDevices, type NewConversationDevice } from "../devices/conversation-devices.js";
8
+ import { DeviceProjectFilesService } from "../devices/device-project-files.service.js";
7
9
  import { DeviceProjectsService } from "../devices/device-projects.service.js";
10
+ import { LibraryFilesService } from "../files/library-files.service.js";
8
11
  import { type PersonRef } from "../identity/account-avatar.js";
9
12
  import { KernelDb } from "../infra/database/kernel-db.js";
10
13
  import { TransactionHost } from "../infra/database/transaction-host.js";
@@ -13,16 +16,14 @@ import { OutboxService } from "../infra/outbox/outbox.service.js";
13
16
  import { ProviderRegistry } from "../runtime/providers.js";
14
17
  import { RunDeletion } from "../runtime/run-deletion.js";
15
18
  import { PermissionCeilingWrites } from "../sandbox/permission-ceiling-writes.js";
16
- import type { ScheduleMarker } from "../schedules/types.js";
17
19
  import { type RenderedInvocation, SkillInvoker } from "../skills/invoke.js";
18
20
  import { type ApprovalRecord, ApprovalsService } from "../tools/approvals.service.js";
19
21
  import { ConnectorContent } from "../tools/connector-content.js";
20
22
  import { type QuestionRecord, QuestionsService } from "../tools/questions.service.js";
21
23
  import { ConversationAccess } from "./access.js";
22
24
  import { type AgentTreeNode } from "./agent-tree.js";
23
- import { AttachmentsService } from "./attachments.service.js";
24
25
  import { EventLog } from "./event-log.js";
25
- import type { ConversationEvent, LogContentBlock } from "./events.js";
26
+ import { type ConversationEvent, type LogContentBlock } from "./events.js";
26
27
  import { type ImSenderContext } from "./message-context.js";
27
28
  import type { PermissionSelection } from "./permission-profiles.schemas.js";
28
29
  import { PermissionProfilesService } from "./permission-profiles.service.js";
@@ -54,8 +55,13 @@ export interface ConversationView {
54
55
  * sub-agent's is null: it works in its root conversation's.
55
56
  */
56
57
  deviceId: string | null;
57
- /** The scheduled task that created it (a `new`-mode task's run); null otherwise (spec §4). */
58
- scheduledTaskId: string | null;
58
+ /** The automation that created it (a `new`-mode task's run); null otherwise (spec §4). */
59
+ automationId: string | null;
60
+ /**
61
+ * The event subject it serves (a `subject`-mode automation's conversation, collaboration spec
62
+ * §4.5): the emitting extension and the subject; null for any other conversation.
63
+ */
64
+ subject: ConversationSubject | null;
59
65
  /**
60
66
  * The device project it is bound to (project root spec §4.3: chosen at creation, never
61
67
  * changed), as resolved then: its name and absolute path on the device; null in free mode (a
@@ -211,7 +217,10 @@ export interface AttachmentRef {
211
217
  connectorId: string;
212
218
  uri: string;
213
219
  }
214
- /** Resolved `@` resources: the blocks after the user text and their metadata. */
220
+ /**
221
+ * Resolved `@` resources and referenced project files: the blocks after the user text (the
222
+ * resources' bodies, then one text block per project file) and their metadata.
223
+ */
215
224
  export interface ResolvedExtra {
216
225
  blocks: {
217
226
  type: "text";
@@ -224,7 +233,29 @@ export interface ResolvedExtra {
224
233
  uri: string;
225
234
  name: string;
226
235
  }[];
236
+ /** The referenced project files (normalized paths), in block order; absent: none. */
237
+ projectFiles?: {
238
+ path: string;
239
+ }[];
240
+ /** The project root the project file blocks name (set with `projectFiles`). */
241
+ projectRoot?: string;
227
242
  }
243
+ export { MAX_PROJECT_FILES } from "../devices/device-project-files.service.js";
244
+ /** Where a message's project files are checked: the conversation's device and bound project. */
245
+ export interface ProjectFilesTarget {
246
+ deviceId: string | null;
247
+ project: {
248
+ name: string;
249
+ path: string;
250
+ } | null | undefined;
251
+ /** Stops the check on the device (the request's signal: the client hung up). */
252
+ signal?: AbortSignal | undefined;
253
+ }
254
+ /**
255
+ * The model-visible text of one referenced project file (composer menus §5): English, logged in
256
+ * the `user_message`, so replay rebuilds it from the log as it is.
257
+ */
258
+ export declare const projectFileText: (path: string, root: string) => string;
228
259
  export { userMessageIdemKey } from "./idem-keys.js";
229
260
  /** The longest conversation title (characters, after trimming). */
230
261
  export declare const CONVERSATION_TITLE_MAX_CHARS = 120;
@@ -239,6 +270,13 @@ export interface UserMessageInput {
239
270
  clientMessageId?: string;
240
271
  attachments?: AttachmentRef[];
241
272
  files?: string[];
273
+ /**
274
+ * Files of the conversation's device project, referenced by their paths relative to the
275
+ * project root (composer menus §5): checked with `stat`, never read or copied.
276
+ */
277
+ projectFiles?: {
278
+ path: string;
279
+ }[];
242
280
  /** Switch the conversation's model from the next run (the agent's own model = back to it). */
243
281
  model?: ModelRef;
244
282
  /** Switch the effort (one of the model's declared `effort` values). */
@@ -265,14 +303,18 @@ export interface UserMessageInput {
265
303
  im?: ImSenderContext;
266
304
  }
267
305
  /**
268
- * Message options only kernel callers pass (a scheduled task's fire, scheduled tasks spec §6), never
269
- * an HTTP body: the schedule marker the `user_message` carries and a zone that beats every other
270
- * source of the message's `timeZone` (`readMessageContext`).
306
+ * Message options only kernel callers pass (an automation's fire, scheduled tasks spec §6), never
307
+ * an HTTP body: the schedule marker or the event marker (collaboration spec §4.6) the
308
+ * `user_message` carries, and a zone that beats every other source of the message's `timeZone`
309
+ * (`readMessageContext`).
271
310
  */
272
311
  export interface InternalMessageOptions {
273
312
  initialPermission?: PermissionSelection;
313
+ /** The request's signal: the project file check on the device stops when the client hangs up. */
314
+ signal?: AbortSignal;
274
315
  createRequestHash?: string;
275
316
  schedule?: ScheduleMarker;
317
+ automationEvent?: AutomationEventMarker;
276
318
  timeZoneOverride?: string;
277
319
  }
278
320
  /** Options of a conversation created by a kernel caller (never an HTTP body). */
@@ -282,6 +324,14 @@ export interface NewConversationOptions {
282
324
  * conversation that fell back to `web` would be offered what only the web and DMs may see.
283
325
  */
284
326
  source: ConversationSource;
327
+ /**
328
+ * The event subject a `subject`-mode automation's conversation serves (collaboration spec §4.5):
329
+ * `subject` of the subject's trigger events and the emitting extension (`source`), fixed at
330
+ * creation (`conversations.subject`).
331
+ */
332
+ subject?: TriggerSubject & {
333
+ source: string;
334
+ };
285
335
  }
286
336
  /**
287
337
  * 会话:只有所有者可见;每次访问都实时复核 agent 对所有者仍可用(spec 3.6 R5),
@@ -299,8 +349,8 @@ export declare class ConversationsService {
299
349
  private readonly providers;
300
350
  /** Reads `@` resources with the sender's credentials. */
301
351
  private readonly content;
302
- /** Binds uploaded files to the conversation in the message's transaction. */
303
- private readonly attachments;
352
+ /** Attaches the sender's library files to the conversation in the message's transaction. */
353
+ private readonly libraryFiles;
304
354
  /** Renders a person's skill invocation (phase D). */
305
355
  private readonly invoker;
306
356
  /** Stops a deleted conversation's background tasks. */
@@ -309,6 +359,8 @@ export declare class ConversationsService {
309
359
  private readonly devices;
310
360
  /** The project of that device a new conversation is bound to (project root design §4.3). */
311
361
  private readonly projects;
362
+ /** Checks a message's referenced project files on the device (composer menus §5). */
363
+ private readonly projectFiles;
312
364
  /** A starter's message skips the run's pending questions (reply-while-question spec §8.1). */
313
365
  private readonly questions;
314
366
  /** ... and its pending network asks (network ask-to-allow spec §6.7). */
@@ -325,8 +377,8 @@ export declare class ConversationsService {
325
377
  providers: Pick<ProviderRegistry, "resolve">,
326
378
  /** Reads `@` resources with the sender's credentials. */
327
379
  content: Pick<ConnectorContent, "resolveAttachments">,
328
- /** Binds uploaded files to the conversation in the message's transaction. */
329
- attachments: Pick<AttachmentsService, "bindForMessage">,
380
+ /** Attaches the sender's library files to the conversation in the message's transaction. */
381
+ libraryFiles: Pick<LibraryFilesService, "attachForMessage">,
330
382
  /** Renders a person's skill invocation (phase D). */
331
383
  invoker: Pick<SkillInvoker, "prepare">,
332
384
  /** Stops a deleted conversation's background tasks. */
@@ -335,6 +387,8 @@ export declare class ConversationsService {
335
387
  devices: Pick<ConversationDevices, "forNew">,
336
388
  /** The project of that device a new conversation is bound to (project root design §4.3). */
337
389
  projects: Pick<DeviceProjectsService, "resolveForBinding">,
390
+ /** Checks a message's referenced project files on the device (composer menus §5). */
391
+ projectFiles: Pick<DeviceProjectFilesService, "statAll">,
338
392
  /** A starter's message skips the run's pending questions (reply-while-question spec §8.1). */
339
393
  questions: Pick<QuestionsService, "skipPendingIn">,
340
394
  /** ... and its pending network asks (network ask-to-allow spec §6.7). */
@@ -358,8 +412,8 @@ export declare class ConversationsService {
358
412
  * `agent.not_found` and nothing is written. Queues a run afterwards, like `postUserMessage`.
359
413
  * `events` are every event the create wrote, in seq order from seq 1 (a `model_switched` before
360
414
  * the message when the send switched), so a client can seed the new conversation's log whole.
361
- * `internal`: the conversation's source and, for kernel callers only, a scheduled task's marker,
362
- * which also sets `conversations.scheduled_task_id`, and its zone override. `pick.project` binds
415
+ * `internal`: the conversation's source and, for kernel callers only, an automation's marker,
416
+ * which also sets `conversations.automation_id`, and its zone override. `pick.project` binds
363
417
  * the conversation to one of its device's projects inside the write ({@link bindingFor}); a
364
418
  * retry answers with the conversation the first send created, its binding unchanged.
365
419
  */
@@ -529,20 +583,32 @@ export declare class ConversationsService {
529
583
  turnsBefore: number;
530
584
  }>;
531
585
  /**
532
- * 追加一条用户消息;带 `clientMessageId` 时重复提交返回同一事件。写入后调用 `ensureRun`:
533
- * 没有进行中的运行时投递一轮;运行中则由当前运行在步骤间隙吸收,或在它结束时再次 `ensureRun`。
534
- * A failed `ensureRun` is logged, not thrown: the message's transaction owes the ensure-run
586
+ * Appends a user message; a repeated send with the same `clientMessageId` returns the same
587
+ * event. After the write it calls `ensureRun`: with no run in progress it enqueues one; during
588
+ * a run the current run takes the message in between steps, or `ensureRun` runs again when it
589
+ * ends. A failed `ensureRun` is logged, not thrown: the message's transaction owes the ensure-run
535
590
  * backstop, which starts the run once the queue is reachable (transactional outbox spec §6).
536
591
  *
537
- * `attachments`(`@` 资源引用):内核以发送者的凭据读取资源(打码、限长),作为用户文本之后的额外文本块写入同一条
538
- * user_message,并在 `payload.attachments` 记录元数据(第 i 个附件对应 `content[i + 1]`)。读取失败整条不写。
539
- * 带 `clientMessageId` 的重复提交直接返回已写入的事件,不再读取。
592
+ * `attachments` (`@` resource references): the kernel reads each resource with the sender's
593
+ * credentials (redacted, length-capped) and writes it as an extra text block after the user's
594
+ * text in the same user_message, with its metadata in `payload.attachments` (attachment i is
595
+ * `content[i + 1]`). A failed read writes nothing. A repeated send with the same
596
+ * `clientMessageId` returns the written event without reading again.
597
+ *
598
+ * `files` (uploaded attachment ids): checked and bound to this conversation in the transaction
599
+ * that writes the event (see {@link BindFiles}) and appended last as image / document reference
600
+ * blocks (after the `@` resource blocks); any unavailable file writes nothing. The log holds
601
+ * only references, never bytes. With empty `text` (files only: the HTTP layer ensures `files`
602
+ * and no `@` resources then) no text block is written.
540
603
  *
541
- * `files`(上传的附件 id):在写事件的同一事务里校验并绑定到本会话(见 {@link BindFiles}),作为 image /
542
- * document 引用块追加在最后(`@` 资源块之后);任一附件不可用则整条不写。日志里只有引用,没有字节。
543
- * `text` 为空时(只发附件,HTTP 层保证此时有 `files` 且没有 `@` 资源)不写文本块。
604
+ * `projectFiles` (composer menus §5): checked in the conversation's stored project before the
605
+ * write ({@link resolveExtra}); one block each after the `@` resources' bodies, before the
606
+ * uploaded files' blocks, and `payload.projectFiles`. Any refusal writes nothing; a repeated
607
+ * send with the same `clientMessageId` returns the written event without checking again.
544
608
  */
545
- postUserMessage(orgId: string, conversationId: string, accountId: string, input: UserMessageInput): Promise<ConversationEvent>;
609
+ postUserMessage(orgId: string, conversationId: string, accountId: string, input: UserMessageInput,
610
+ /** The request's signal: the project file check on the device stops when the client hangs up. */
611
+ signal?: AbortSignal): Promise<ConversationEvent>;
546
612
  /**
547
613
  * Writes a message in one transaction: binds its files, reads its sender context and appends it
548
614
  * (after its `model_switched` when it switches).
@@ -610,14 +676,25 @@ export declare class ConversationsService {
610
676
  */
611
677
  prepareQueuedSkill(orgId: string, conv: ConversationView, accountId: string, input: Pick<UserMessageInput, "skill" | "text">): Promise<RenderedInvocation | undefined>;
612
678
  /**
613
- * Reads the `@` resources with the sender's credentials (nothing when there are none). Shared
614
- * with the queue, which reads them when a message is queued (decision 15).
615
- */
616
- resolveExtra(orgId: string, accountId: string, input: Pick<UserMessageInput, "attachments">): Promise<ResolvedExtra>;
617
- /**
618
- * Binds uploaded files inside the message's (or queue item's) transaction; none → no blocks.
619
- * The bound files join the conversation's files, so open pages read the list again after the
620
- * commit (`changed: files`, a hint).
679
+ * Reads the `@` resources with the sender's credentials and checks the referenced project files
680
+ * (nothing when there are none). Shared with the queue, which reads the resources when a
681
+ * message is queued (decision 15; a queued message carries no project files).
682
+ *
683
+ * Project files (composer menus §5) are checked in `target`'s project on its device as the
684
+ * sender (the conversation's owner, through `DeviceProjectFilesService.statAll`, outside any
685
+ * transaction): no bound project → `conversation.project_file_unavailable` with `reason:
686
+ * "no_project"`; a path leaving the project → `device.path_outside_project`; one that is not a
687
+ * file there → `conversation.project_file_unavailable` with its path; the device codes pass on.
688
+ * Each becomes a {@link projectFileText} block after the resources' bodies.
689
+ */
690
+ resolveExtra(orgId: string, accountId: string, input: Pick<UserMessageInput, "attachments" | "projectFiles">, target?: ProjectFilesTarget): Promise<ResolvedExtra>;
691
+ /** {@link resolveExtra}'s project file check: the normalized paths and the root, or none. */
692
+ private checkProjectFiles;
693
+ /**
694
+ * Attaches the sender's library files inside the message's (or queue item's) transaction
695
+ * (`LibraryFilesService.attachForMessage`: drafts become ready, the conversation refers to each);
696
+ * none → no blocks. The files join the conversation's files, so open pages read the list again
697
+ * after the commit (`changed: files`, a hint).
621
698
  */
622
699
  bindIn(orgId: string, conversationId: string, accountId: string, files: readonly string[]): Promise<LogContentBlock[]>;
623
700
  private userMessage;