@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
@@ -15,6 +15,7 @@ import { sql } from "kysely";
15
15
  import { isInlineArtifactType, isTextArtifactType } from "../conversations/artifacts.js";
16
16
  import { FILE_CONTENT_MAX_BYTES, previewKind, readPrefix, trimUtf8, } from "../conversations/files.js";
17
17
  import { ApiError } from "../errors.js";
18
+ import { BlobsService } from "../files/blobs.service.js";
18
19
  import { PreviewerRegistry } from "../files/previewers.js";
19
20
  import { HTML_TOKEN_TTL_SECONDS, HtmlTokens } from "../html/html-token.js";
20
21
  import { isHtmlType } from "../html/html-type.js";
@@ -24,7 +25,6 @@ import { TransactionHost } from "../infra/database/transaction-host.js";
24
25
  import { Transactional } from "../infra/database/transactional.decorator.js";
25
26
  import { LockService } from "../infra/lock/lock.service.js";
26
27
  import { CredentialThrottler } from "../infra/throttler/credential-throttler.js";
27
- import { StorageService } from "../storage/storage.service.js";
28
28
  import { ShareLiveness } from "./liveness.js";
29
29
  /** The share-open throttler (`NAMED_THROTTLERS`): per client address, misses count. */
30
30
  const THROTTLER = ["share-open"];
@@ -66,23 +66,26 @@ export function attachmentDisposition(name) {
66
66
  * share needs a web session of an active member of the share's own org (not the session's current
67
67
  * org): without one 401 `share.sign_in_required`, a signed-in non-member 404. `ShareLiveness`
68
68
  * checks the share and its creator; this service checks the viewer. The bytes are always streamed
69
- * by the kernel from the snapshot, never a presigned URL; nothing lives in process memory (the
69
+ * by the kernel from the share's blob (`BlobsService.open`: size and etag checked), never a
70
+ * presigned URL; nothing lives in process memory (the
70
71
  * throttler and the open dedupe are Redis keys with a TTL).
71
72
  */
72
73
  let ShareOpenService = class ShareOpenService {
73
74
  db;
74
75
  txHost;
75
76
  liveness;
76
- storage;
77
+ blobs;
77
78
  tokens;
78
79
  locks;
79
80
  previewers;
80
81
  throttler;
81
- constructor(db, txHost, liveness, storage, tokens, locks, previewers, throttler) {
82
+ constructor(db, txHost, liveness,
83
+ /** The share's blob, size and etag checked (a replaced object is not the snapshot). */
84
+ blobs, tokens, locks, previewers, throttler) {
82
85
  this.db = db;
83
86
  this.txHost = txHost;
84
87
  this.liveness = liveness;
85
- this.storage = storage;
88
+ this.blobs = blobs;
86
89
  this.tokens = tokens;
87
90
  this.locks = locks;
88
91
  this.previewers = previewers;
@@ -146,7 +149,7 @@ let ShareOpenService = class ShareOpenService {
146
149
  }
147
150
  /** Streams the snapshot as `application/octet-stream` (spec §3); `download` adds the attachment name. */
148
151
  async content(share, download, reply) {
149
- const got = await this.storage.kernel(share.orgId).get(share.objectKey);
152
+ const got = await this.blobs.open(share.orgId, share.blob);
150
153
  if (!got)
151
154
  throw shareNotFound();
152
155
  sandboxedBytes(reply)
@@ -166,9 +169,9 @@ let ShareOpenService = class ShareOpenService {
166
169
  throw notPreviewable("Only text files have content");
167
170
  }
168
171
  const max = Math.min(limit, FILE_CONTENT_MAX_BYTES);
169
- const got = await this.storage
170
- .kernel(share.orgId)
171
- .get(share.objectKey, { range: { start: 0, end: max - 1 } });
172
+ const got = await this.blobs.open(share.orgId, share.blob, {
173
+ range: { start: 0, end: max - 1 },
174
+ });
172
175
  if (!got)
173
176
  throw shareNotFound();
174
177
  let body = await readPrefix(got.body, max);
@@ -190,7 +193,7 @@ let ShareOpenService = class ShareOpenService {
190
193
  async inline(share, reply) {
191
194
  if (!isInlineArtifactType(share.contentType))
192
195
  throw shareNotFound();
193
- const got = await this.storage.kernel(share.orgId).get(share.objectKey);
196
+ const got = await this.blobs.open(share.orgId, share.blob);
194
197
  if (!got)
195
198
  throw shareNotFound();
196
199
  const type = (share.contentType.split(";")[0] ?? "").trim().toLowerCase();
@@ -279,7 +282,7 @@ ShareOpenService = __decorate([
279
282
  __param(0, Inject(KernelDb)),
280
283
  __param(1, Inject(TransactionHost)),
281
284
  __param(2, Inject(ShareLiveness)),
282
- __param(3, Inject(StorageService)),
285
+ __param(3, Inject(BlobsService)),
283
286
  __param(4, Inject(HtmlTokens)),
284
287
  __param(5, Inject(LockService)),
285
288
  __param(6, Inject(PreviewerRegistry)),
@@ -1,13 +1,15 @@
1
1
  import type { z } from "zod";
2
2
  import { type Principal } from "../identity/principal.js";
3
3
  import { type OrgContext } from "../orgs/org.guard.js";
4
- import { CreateShareBody, ListSharesQuery, ShareFileParams, ShareIdParams } from "./shares.schemas.js";
4
+ import { CreateShareBody, LibraryShareParams, ListSharesQuery, ShareFileParams, ShareIdParams } from "./shares.schemas.js";
5
5
  import { type SharePolicy, SharesService, type ShareView } from "./shares.service.js";
6
6
  /**
7
- * Shares of conversation files (file sharing spec §2): `agents.use`, a person only (a service
8
- * token is refused by `requireUser`). Creating and listing a file's shares need the conversation's
9
- * owner (`ConversationAccess.isAccessible`, else `conversation.not_found`); refreshing needs the
10
- * creator, revoking the creator or an org admin (else `share.not_found`).
7
+ * Shares of files (file sharing spec §2, file library spec §6): `agents.use`, a person only (a
8
+ * service token is refused by `requireUser`). Creating and listing a conversation file's shares
9
+ * need the conversation's owner (`ConversationAccess.isAccessible`, else `conversation.not_found`);
10
+ * a library file's, the file's owner (else `file.not_found`); the anonymous guest creates none
11
+ * (`member.anonymous_guest`). Refreshing needs the creator, revoking the creator or an org admin
12
+ * (else `share.not_found`).
11
13
  */
12
14
  export declare class SharesController {
13
15
  private readonly shares;
@@ -21,6 +23,15 @@ export declare class SharesController {
21
23
  shares: ShareView[];
22
24
  policy: SharePolicy;
23
25
  }>;
26
+ /** Shares one of the caller's library files (no conversation): 201 `{ share }`. */
27
+ createForFile(principal: Principal, org: OrgContext, params: z.infer<typeof LibraryShareParams>, body: z.infer<typeof CreateShareBody>): Promise<{
28
+ share: ShareView;
29
+ }>;
30
+ /** The live and recent shares the caller made of one library file (any version of it). */
31
+ forLibraryFile(principal: Principal, org: OrgContext, params: z.infer<typeof LibraryShareParams>): Promise<{
32
+ shares: ShareView[];
33
+ policy: SharePolicy;
34
+ }>;
24
35
  /** "Update to latest": the newest available version as the next generation (creator only). */
25
36
  refresh(principal: Principal, org: OrgContext, params: z.infer<typeof ShareIdParams>): Promise<{
26
37
  share: ShareView;
@@ -12,10 +12,12 @@ import { CurrentPrincipal, patTokenId, requireUser, } from "../identity/principa
12
12
  import { createZodDto } from "../infra/validation/create-zod-dto.js";
13
13
  import { ZBody, ZParam, ZQuery } from "../infra/validation/zod-params.js";
14
14
  import { CurrentOrg, OrgAction } from "../orgs/org.guard.js";
15
- import { CreateShareBody, ListSharesQuery, ShareFileParams, ShareIdParams, } from "./shares.schemas.js";
15
+ import { CreateShareBody, LibraryShareParams, ListSharesQuery, ShareFileParams, ShareIdParams, } from "./shares.schemas.js";
16
16
  import { SharesService } from "./shares.service.js";
17
17
  class ShareFileParamsDto extends createZodDto(ShareFileParams, "ShareFileParams") {
18
18
  }
19
+ class LibraryShareParamsDto extends createZodDto(LibraryShareParams, "LibraryShareParams") {
20
+ }
19
21
  class CreateShareBodyDto extends createZodDto(CreateShareBody, "CreateShareBody") {
20
22
  }
21
23
  class ShareIdParamsDto extends createZodDto(ShareIdParams, "ShareIdParams") {
@@ -23,10 +25,12 @@ class ShareIdParamsDto extends createZodDto(ShareIdParams, "ShareIdParams") {
23
25
  class ListSharesQueryDto extends createZodDto(ListSharesQuery, "ListSharesQuery") {
24
26
  }
25
27
  /**
26
- * Shares of conversation files (file sharing spec §2): `agents.use`, a person only (a service
27
- * token is refused by `requireUser`). Creating and listing a file's shares need the conversation's
28
- * owner (`ConversationAccess.isAccessible`, else `conversation.not_found`); refreshing needs the
29
- * creator, revoking the creator or an org admin (else `share.not_found`).
28
+ * Shares of files (file sharing spec §2, file library spec §6): `agents.use`, a person only (a
29
+ * service token is refused by `requireUser`). Creating and listing a conversation file's shares
30
+ * need the conversation's owner (`ConversationAccess.isAccessible`, else `conversation.not_found`);
31
+ * a library file's, the file's owner (else `file.not_found`); the anonymous guest creates none
32
+ * (`member.anonymous_guest`). Refreshing needs the creator, revoking the creator or an org admin
33
+ * (else `share.not_found`).
30
34
  */
31
35
  let SharesController = class SharesController {
32
36
  shares;
@@ -47,6 +51,20 @@ let SharesController = class SharesController {
47
51
  const p = requireUser(principal);
48
52
  return this.shares.forFile(org.orgId, p.account.id, params.id, params.fileId);
49
53
  }
54
+ /** Shares one of the caller's library files (no conversation): 201 `{ share }`. */
55
+ async createForFile(principal, org, params, body) {
56
+ const p = requireUser(principal);
57
+ return {
58
+ share: await this.shares.createForFile(org.orgId, p.account.id, params.fileId, body, {
59
+ tokenId: patTokenId(p),
60
+ }),
61
+ };
62
+ }
63
+ /** The live and recent shares the caller made of one library file (any version of it). */
64
+ async forLibraryFile(principal, org, params) {
65
+ const p = requireUser(principal);
66
+ return this.shares.forLibraryFile(org.orgId, p.account.id, params.fileId);
67
+ }
50
68
  /** "Update to latest": the newest available version as the next generation (creator only). */
51
69
  async refresh(principal, org, params) {
52
70
  const p = requireUser(principal);
@@ -83,6 +101,22 @@ __decorate([
83
101
  __param(1, CurrentOrg()),
84
102
  __param(2, ZParam(ShareFileParamsDto))
85
103
  ], SharesController.prototype, "forFile", null);
104
+ __decorate([
105
+ Post("files/:fileId/shares"),
106
+ OrgAction("agents.use"),
107
+ __param(0, CurrentPrincipal()),
108
+ __param(1, CurrentOrg()),
109
+ __param(2, ZParam(LibraryShareParamsDto)),
110
+ __param(3, ZBody(CreateShareBodyDto))
111
+ ], SharesController.prototype, "createForFile", null);
112
+ __decorate([
113
+ Get("files/:fileId/shares"),
114
+ Header("cache-control", "private, no-store"),
115
+ OrgAction("agents.use"),
116
+ __param(0, CurrentPrincipal()),
117
+ __param(1, CurrentOrg()),
118
+ __param(2, ZParam(LibraryShareParamsDto))
119
+ ], SharesController.prototype, "forLibraryFile", null);
86
120
  __decorate([
87
121
  Post("shares/:shareId/refresh"),
88
122
  HttpCode(200),
@@ -1,8 +1,8 @@
1
1
  /**
2
- * File sharing (file sharing spec): creating, refreshing, revoking and listing shares
3
- * ({@link SharesService}), the live check the open routes use (`ShareLiveness`), the public open
4
- * routes' service (`ShareOpenService`) and the snapshot deletion the maintenance worker runs
5
- * (`ShareObjects`).
2
+ * File sharing (file sharing spec, file library spec §6): creating, refreshing, revoking and listing
3
+ * shares ({@link SharesService}), the live check the open routes use (`ShareLiveness`), the public
4
+ * open routes' service (`ShareOpenService`, streaming the share's blob) and the legacy snapshot
5
+ * deletion the maintenance worker runs (`ShareObjects`).
6
6
  */
7
7
  export declare class SharesModule {
8
8
  }
@@ -7,18 +7,18 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
7
7
  import { Module } from "@nestjs/common";
8
8
  import { ConversationsModule } from "../conversations/conversations.module.js";
9
9
  import { FilesModule } from "../files/files.module.js";
10
+ import { LibraryReadModule } from "../files/library-read.module.js";
10
11
  import { HtmlTokensModule } from "../html/html-token.js";
11
12
  import { OrgLockModule } from "../orgs/org-lock.js";
12
- import { StorageModule } from "../storage/storage.module.js";
13
13
  import { ShareLivenessModule } from "./liveness.js";
14
14
  import { ShareObjectsModule } from "./share-objects.js";
15
15
  import { ShareOpenService } from "./share-open.service.js";
16
16
  import { SharesService } from "./shares.service.js";
17
17
  /**
18
- * File sharing (file sharing spec): creating, refreshing, revoking and listing shares
19
- * ({@link SharesService}), the live check the open routes use (`ShareLiveness`), the public open
20
- * routes' service (`ShareOpenService`) and the snapshot deletion the maintenance worker runs
21
- * (`ShareObjects`).
18
+ * File sharing (file sharing spec, file library spec §6): creating, refreshing, revoking and listing
19
+ * shares ({@link SharesService}), the live check the open routes use (`ShareLiveness`), the public
20
+ * open routes' service (`ShareOpenService`, streaming the share's blob) and the legacy snapshot
21
+ * deletion the maintenance worker runs (`ShareObjects`).
22
22
  */
23
23
  let SharesModule = class SharesModule {
24
24
  };
@@ -26,7 +26,8 @@ SharesModule = __decorate([
26
26
  Module({
27
27
  imports: [
28
28
  ConversationsModule,
29
- StorageModule,
29
+ // the library files shares are made from and the blobs they point at
30
+ LibraryReadModule,
30
31
  OrgLockModule,
31
32
  ShareLivenessModule,
32
33
  ShareObjectsModule,
@@ -5,6 +5,10 @@ export declare const ShareFileParams: z.ZodObject<{
5
5
  id: z.ZodString;
6
6
  fileId: z.ZodString;
7
7
  }, z.core.$strip>;
8
+ /** `POST …/files/:fileId/shares` (a library file) and its per-file list. */
9
+ export declare const LibraryShareParams: z.ZodObject<{
10
+ fileId: z.ZodString;
11
+ }, z.core.$strip>;
8
12
  /**
9
13
  * A new share: who may open it and when it expires (days; null = never, internal only). An
10
14
  * external share needs a non-null expiry within the platform maximum (`share.expiry_too_long`).
@@ -4,6 +4,8 @@ export const ShareFileParams = z.object({
4
4
  id: z.string().min(1).max(100),
5
5
  fileId: z.string().min(1).max(100),
6
6
  });
7
+ /** `POST …/files/:fileId/shares` (a library file) and its per-file list. */
8
+ export const LibraryShareParams = z.object({ fileId: z.string().min(1).max(100) });
7
9
  /**
8
10
  * A new share: who may open it and when it expires (days; null = never, internal only). An
9
11
  * external share needs a non-null expiry within the platform maximum (`share.expiry_too_long`).
@@ -1,20 +1,22 @@
1
1
  import { ConversationAccess } from "../conversations/access.js";
2
2
  import { ConversationFiles } from "../conversations/files.js";
3
+ import { type BlobRef, BlobsService } from "../files/blobs.service.js";
4
+ import { ReferencedFiles } from "../files/referenced-files.js";
3
5
  import { KernelConfigService } from "../infra/config/kernel-config.service.js";
4
6
  import { KernelDb } from "../infra/database/kernel-db.js";
5
7
  import { TransactionHost } from "../infra/database/transaction-host.js";
6
8
  import { LockService } from "../infra/lock/lock.service.js";
7
- import { OutboxService } from "../infra/outbox/outbox.service.js";
8
9
  import type { KernelLogger } from "../log.js";
9
10
  import { OrgLock } from "../orgs/org-lock.js";
10
- import { StorageService } from "../storage/storage.service.js";
11
11
  import { type ExternalSharingState } from "./settings.js";
12
12
  /**
13
- * Shares of conversation files (file sharing spec §1, §2): a share is a frozen snapshot of one
14
- * file, copied under `shares/<id>/<generation>` of the org's kernel prefix **before** the row that
15
- * names it is written (intent first: a crash leaves an orphan object the daily sweep frees, never a
16
- * row without its object). Freeing a snapshot is owed through the outbox by the transaction that
17
- * stops using it (a refresh, a revoke). Nothing is held in process memory; every read is live.
13
+ * Shares of files (file sharing spec §1, §2; file library spec §6): a share is a frozen snapshot of
14
+ * one file, which is the file's blob: the row points at it (`blob_id`, locked `ready` by
15
+ * `BlobsService.lockReady` in the transaction that writes the pointer), so nothing is copied and
16
+ * nothing is owed when the share stops (the blob sweep frees a blob no file or share needs). A share
17
+ * is made from a conversation (its file, `conversation_id` set) or from the library (`conversation_id`
18
+ * null); either names the library file it came from (`source_file_id`). Nothing is held in process
19
+ * memory; every read is live.
18
20
  */
19
21
  /**
20
22
  * `live`: opens now. `suspended`: not revoked or expired, but it does not open now: an external
@@ -30,7 +32,7 @@ export interface ShareView {
30
32
  */
31
33
  url: string | null;
32
34
  audience: "internal" | "external";
33
- conversationId: string;
35
+ conversationId: string | null;
34
36
  fileId: string;
35
37
  sourcePath: string | null;
36
38
  name: string;
@@ -49,9 +51,9 @@ export interface ShareView {
49
51
  revokedAt: string | null;
50
52
  revokeReason: string | null;
51
53
  /**
52
- * A newer version of `sourcePath` was delivered after the snapshot's (refresh offered). In the
53
- * per-file list ({@link SharesService.forFile}) only a version whose object is still stored
54
- * counts; in the org and personal lists the event log alone decides (no storage reads).
54
+ * The creator has a newer ready version of the snapshot's file (same source conversation and
55
+ * `sourcePath`; refresh offered). In the per-file lists only a version whose bytes are still
56
+ * stored counts; in the org and personal lists the file rows alone decide (no storage reads).
55
57
  */
56
58
  newerVersion: boolean;
57
59
  }
@@ -69,80 +71,93 @@ export interface ShareActor {
69
71
  export declare const SHARE_RECENT_DAYS = 7;
70
72
  /** The most shares one list returns (newest first). */
71
73
  export declare const SHARES_LIST_MAX = 500;
74
+ /** The file a share snapshots: its row and its blob (read after the viewer's checks). */
75
+ interface ShareSource {
76
+ id: string;
77
+ name: string;
78
+ contentType: string;
79
+ /** The version group of a delivered file; null for an upload. */
80
+ sourcePath: string | null;
81
+ blob: BlobRef;
82
+ }
72
83
  export declare class SharesService {
73
84
  private readonly db;
74
85
  readonly txHost: TransactionHost;
75
86
  private readonly files;
87
+ private readonly library;
88
+ private readonly blobs;
76
89
  private readonly access;
77
- private readonly storage;
78
- private readonly outbox;
79
90
  private readonly orgLock;
80
91
  private readonly locks;
81
92
  private readonly config;
82
93
  private readonly log?;
83
- constructor(db: KernelDb, txHost: TransactionHost, files: Pick<ConversationFiles, "file" | "identify" | "latestAvailable">, access: Pick<ConversationAccess, "isAccessible">, storage: Pick<StorageService, "kernel">, outbox: Pick<OutboxService, "add">, orgLock: Pick<OrgLock, "lockAndAuthorize">, locks: Pick<LockService, "run">, config: Pick<KernelConfigService, "get" | "fieldSource">, log?: KernelLogger | undefined);
94
+ constructor(db: KernelDb, txHost: TransactionHost, files: Pick<ConversationFiles, "file" | "identify">, library: Pick<ReferencedFiles, "owned">, blobs: Pick<BlobsService, "lockReady" | "head">, access: Pick<ConversationAccess, "isAccessible">, orgLock: Pick<OrgLock, "lockAndAuthorize">, locks: Pick<LockService, "run">, config: Pick<KernelConfigService, "get" | "fieldSource">, log?: KernelLogger | undefined);
84
95
  /** The effective external switch for the org and the platform's expiry maximum, read live. */
85
96
  policy(orgId: string): Promise<SharePolicy>;
86
97
  /**
87
98
  * Shares one file of the viewer's conversation (any version shown in the panel, or an
88
- * attachment sent in it). The snapshot is streamed into its object first, outside any
89
- * transaction; then {@link insertShare} writes the row and the `share.created` audit. A code
90
- * collision retries the insert with a new code (the object is keyed by the id, not the code).
99
+ * attachment sent in it): {@link insertShare} points the row at the file's blob. The anonymous
100
+ * guest cannot share (`member.anonymous_guest`).
91
101
  */
92
102
  create(orgId: string, accountId: string, conversationId: string, fileId: string, body: {
93
103
  audience: "internal" | "external";
94
104
  expiresInDays: 1 | 7 | 30 | null;
95
105
  }, actor?: ShareActor): Promise<ShareView>;
96
106
  /**
97
- * The row and audit of a new share. The row's org is read from the conversation here (locked
98
- * `FOR SHARE`, so a concurrent delete waits and then revokes this share too), never taken from
99
- * the caller; the viewer's access is checked again inside the transaction, since the copy ran
100
- * without one. Internal: called by {@link create} only.
107
+ * Shares one of the viewer's library files (file library spec §6): the file must be the
108
+ * viewer's and `ready` (else `file.not_found`) with its bytes still stored (else
109
+ * `share.file_unavailable`). The share has no conversation. The anonymous guest cannot share.
110
+ */
111
+ createForFile(orgId: string, accountId: string, fileId: string, body: {
112
+ audience: "internal" | "external";
113
+ expiresInDays: 1 | 7 | 30 | null;
114
+ }, actor?: ShareActor): Promise<ShareView>;
115
+ /** The policy checks of a new share, then its insert (a code collision retries with a new code). */
116
+ private insertWithCode;
117
+ /**
118
+ * The row and audit of a new share. A conversation's share locks the conversation `FOR SHARE`
119
+ * (a concurrent delete waits and then revokes this share too) and checks the viewer's access
120
+ * again. Either kind locks the file row `FOR SHARE` while it is the creator's and `ready` (a
121
+ * concurrent delete waits and then revokes this share too) and the blob through
122
+ * `BlobsService.lockReady` (a blob a deletion claimed is never pointed at again); a file deleted
123
+ * or bytes claimed meanwhile → `share.file_unavailable`. Internal: called by {@link create} and
124
+ * {@link createForFile} only.
101
125
  */
102
126
  insertShare(s: {
103
127
  id: string;
104
128
  orgId: string;
105
129
  code: string;
106
- conversationId: string;
107
- fileId: string;
108
- sourcePath: string | null;
130
+ conversationId: string | null;
131
+ file: ShareSource;
109
132
  accountId: string;
110
133
  audience: "internal" | "external";
111
- name: string;
112
- contentType: string;
113
- size: number;
114
- objectKey: string;
115
134
  expiresInDays: number | null;
116
135
  }, actor: ShareActor): Promise<void>;
117
136
  /**
118
- * "Update to latest" (creator only): copies the newest available version of the share's source
119
- * path delivered after its current snapshot as the next generation under the same code, then
120
- * {@link commitRefresh} moves the row and owes the previous snapshot's deletion. Refreshes of one
121
- * share are serialized by a lock (taken outside any transaction), so two never write the same
122
- * generation's object.
137
+ * "Update to latest" (creator only): points the share at the creator's newest ready version of
138
+ * the same file (same source conversation and source path) made after the current one whose
139
+ * bytes are still stored ({@link nextVersion}), as the next generation under the same code; nothing
140
+ * is copied or deleted. A share of an upload has no versions (`validation_failed`). A
141
+ * conversation's share also needs the creator to still own the conversation. Refreshes of one
142
+ * share are serialized by a lock (taken outside any transaction).
123
143
  */
124
144
  refresh(orgId: string, accountId: string, shareId: string, actor?: ShareActor): Promise<ShareView>;
125
145
  /**
126
- * The row move of a refresh: generation `from` → `from + 1` with the new snapshot, the previous
127
- * snapshot's deletion owed, `share.refreshed` audited. If the share was revoked or expired (or
128
- * moved) since the copy began, nothing moves and the new snapshot's deletion is owed instead;
129
- * returns whether it moved. Internal: called by {@link refresh} only.
146
+ * The row move of a refresh: generation `from` → `from + 1` pointing at `next`'s file and blob
147
+ * (the file locked while it is the creator's and `ready`, the blob through `lockReady`; either
148
+ * gone meanwhile → `share.file_unavailable`), `share.refreshed` audited. If the share was revoked
149
+ * or expired (or moved) meanwhile, nothing moves; returns whether it moved. Internal: called by
150
+ * {@link refresh} only.
130
151
  */
131
152
  commitRefresh(at: {
132
153
  orgId: string;
133
154
  accountId: string;
134
155
  shareId: string;
135
156
  from: number;
136
- }, snap: {
137
- fileId: string;
138
- name: string;
139
- contentType: string;
140
- size: number;
141
- objectKey: string;
142
- }, actor: ShareActor): Promise<boolean>;
157
+ }, next: ShareSource, actor: ShareActor): Promise<boolean>;
143
158
  /**
144
- * Revokes a share (its creator, or an org admin with `org.update`; anyone else: `share.not_found`)
145
- * and owes its snapshot's deletion. Idempotent: an already revoked share is left as it is, with
159
+ * Revokes a share (its creator, or an org admin with `org.update`; anyone else: `share.not_found`).
160
+ * Nothing is owed: the blob sweep frees the blob once nothing needs it. Idempotent: an already revoked share is left as it is, with
146
161
  * no second audit. An admin's role is re-read under the org row lock (taken before the share row).
147
162
  */
148
163
  revoke(orgId: string, accountId: string, shareId: string, actor?: ShareActor): Promise<void>;
@@ -154,6 +169,18 @@ export declare class SharesService {
154
169
  shares: ShareView[];
155
170
  policy: SharePolicy;
156
171
  }>;
172
+ /**
173
+ * The live and recent shares the viewer made of one of their library files (file library spec
174
+ * §6): of any version of it (the same source conversation and source path) or, for an upload, of
175
+ * the file itself, from a conversation or from the library; newest first, with the share policy.
176
+ * Not the viewer's ready file → `file.not_found`.
177
+ */
178
+ forLibraryFile(orgId: string, accountId: string, fileId: string): Promise<{
179
+ shares: ShareView[];
180
+ policy: SharePolicy;
181
+ }>;
182
+ /** The views of a per-file list: a newer version counts only while its bytes are stored. */
183
+ private confirmed;
157
184
  /**
158
185
  * The org's live and recent shares: the actor's own (`mine`), or every member's (`all`, org
159
186
  * admins with `org.update`, re-read live; anyone else `forbidden`). Newest first, at most
@@ -168,16 +195,28 @@ export declare class SharesService {
168
195
  private views;
169
196
  private toView;
170
197
  /**
171
- * The file to share, after the viewer's access check: a delivered version, or an attachment whose
172
- * stored object is still the one finalize checked (else `share.file_unavailable`).
198
+ * The file to share, after the viewer's access check: a delivered version, or an attachment,
199
+ * whose stored bytes are still its blob's (else `share.file_unavailable`).
173
200
  */
174
201
  private fileToShare;
202
+ /** One of the account's library files while it is `ready`; else `file.not_found`. */
203
+ private ownedReady;
204
+ /**
205
+ * In the caller's transaction: locks the file row `FOR SHARE` while it is the account's, `ready`
206
+ * and still on `blobId` (the blob the caller then locks; a hashing merge that moved the file
207
+ * meanwhile refuses), so a delete waits for the caller, then revokes what it wrote; false
208
+ * otherwise.
209
+ */
210
+ private lockFile;
175
211
  /**
176
- * Streams the file's object into `objectKey` (never buffered whole); returns the snapshot's size.
177
- * The object is gone, or an upload's object is no longer the one finalize checked →
178
- * `share.file_unavailable`. Runs with no transaction open.
212
+ * The creator's newest ready version of a share's file made after the current one (the same
213
+ * source conversation and source path; file library spec §6) whose bytes are still stored, or
214
+ * null. The current file is the share's `source_file_id` (else `file_id`); when it no longer
215
+ * exists, the group is the share's conversation and versions made after the share last moved.
216
+ * At most {@link FILE_VERSIONS_MAX} candidates are looked at. Reads storage: no transaction open.
179
217
  */
180
- private copy;
181
- /** Owes the deletion of one share generation's snapshot (in the caller's transaction). */
182
- private oweDelete;
218
+ private nextVersion;
219
+ /** The anonymous guest (channel guests, no sign-in) cannot share (file library spec §2). */
220
+ private rejectGuest;
183
221
  }
222
+ export {};