@engenty/wizards-runtime 0.15.0 → 0.16.0

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 (243) hide show
  1. package/apps/runtime/dist/agents/studio-assistant.js +138 -9
  2. package/apps/runtime/dist/agents/website.js +10 -5
  3. package/apps/runtime/dist/app.js +18 -0
  4. package/apps/runtime/dist/auth/index.js +5 -0
  5. package/apps/runtime/dist/broker/account.js +5 -0
  6. package/apps/runtime/dist/broker/index.js +5 -0
  7. package/apps/runtime/dist/broker/rwx.js +255 -7
  8. package/apps/runtime/dist/cli/main.js +7 -0
  9. package/apps/runtime/dist/cli/move-files.js +68 -0
  10. package/apps/runtime/dist/cli/move-folder-sources.js +120 -0
  11. package/apps/runtime/dist/connectors/plugin-connections.js +74 -4
  12. package/apps/runtime/dist/db/migrations/tenant/0042_client_spaces.sql +16 -0
  13. package/apps/runtime/dist/db/migrations/tenant/0043_space_member_invite.sql +19 -0
  14. package/apps/runtime/dist/db/migrations/tenant/0044_client_portal.sql +8 -0
  15. package/apps/runtime/dist/db/migrations/tenant/0045_client_portal_no_slug.sql +2 -0
  16. package/apps/runtime/dist/db/migrations/tenant/0046_space_file_hash.sql +2 -0
  17. package/apps/runtime/dist/db/migrations/tenant/0047_knowledge_folders.sql +3 -0
  18. package/apps/runtime/dist/db/migrations/tenant/0048_space_chunk_kind.sql +1 -0
  19. package/apps/runtime/dist/db/migrations/tenant/0049_knowledge_sources.sql +57 -0
  20. package/apps/runtime/dist/db/migrations/tenant/0050_dateien.sql +71 -0
  21. package/apps/runtime/dist/db/migrations/tenant/0051_dateien_drafts.sql +23 -0
  22. package/apps/runtime/dist/db/migrations/tenant/0052_dateien_plugin_kinds.sql +5 -0
  23. package/apps/runtime/dist/db/migrations/tenant/0053_dateien_file_title.sql +3 -0
  24. package/apps/runtime/dist/db/migrations/tenant/0054_dateien_ocr.sql +14 -0
  25. package/apps/runtime/dist/db/migrations/tenant/0055_dateien_doc_reread.sql +3 -0
  26. package/apps/runtime/dist/db/migrations/tenant/meta/0042_snapshot.json +5286 -0
  27. package/apps/runtime/dist/db/migrations/tenant/meta/0043_snapshot.json +5293 -0
  28. package/apps/runtime/dist/db/migrations/tenant/meta/0044_snapshot.json +5344 -0
  29. package/apps/runtime/dist/db/migrations/tenant/meta/0045_snapshot.json +5329 -0
  30. package/apps/runtime/dist/db/migrations/tenant/meta/0046_snapshot.json +5343 -0
  31. package/apps/runtime/dist/db/migrations/tenant/meta/0047_snapshot.json +5391 -0
  32. package/apps/runtime/dist/db/migrations/tenant/meta/0048_snapshot.json +5398 -0
  33. package/apps/runtime/dist/db/migrations/tenant/meta/0049_snapshot.json +5793 -0
  34. package/apps/runtime/dist/db/migrations/tenant/meta/0050_snapshot.json +6288 -0
  35. package/apps/runtime/dist/db/migrations/tenant/meta/0051_snapshot.json +6461 -0
  36. package/apps/runtime/dist/db/migrations/tenant/meta/0052_snapshot.json +6497 -0
  37. package/apps/runtime/dist/db/migrations/tenant/meta/0053_snapshot.json +6504 -0
  38. package/apps/runtime/dist/db/migrations/tenant/meta/0054_snapshot.json +6504 -0
  39. package/apps/runtime/dist/db/migrations/tenant/meta/0055_snapshot.json +6504 -0
  40. package/apps/runtime/dist/db/migrations/tenant/meta/_journal.json +98 -0
  41. package/apps/runtime/dist/db/schema.js +294 -5
  42. package/apps/runtime/dist/docs/dev/api.md +25 -0
  43. package/apps/runtime/dist/docs/dev/plugins/connections.md +30 -2
  44. package/apps/runtime/dist/docs/dev/plugins/index.md +1 -1
  45. package/apps/runtime/dist/docs/dev/plugins/reference.md +7 -4
  46. package/apps/runtime/dist/docs/dev/plugins/server.md +11 -5
  47. package/apps/runtime/dist/docs/dev/plugins/space.md +130 -4
  48. package/apps/runtime/dist/docs/dev/plugins/studio.md +13 -3
  49. package/apps/runtime/dist/docs/user-guide/command-line.md +2 -0
  50. package/apps/runtime/dist/docs/user-guide/plugins.md +1 -1
  51. package/apps/runtime/dist/docs/user-guide/space.md +6 -6
  52. package/apps/runtime/dist/docs/user-guide/steps.md +1 -1
  53. package/apps/runtime/dist/documents/ocr.js +72 -0
  54. package/apps/runtime/dist/documents/parse.js +81 -12
  55. package/apps/runtime/dist/elements/caller.js +5 -3
  56. package/apps/runtime/dist/elements/gate.js +1 -1
  57. package/apps/runtime/dist/elements/knowledge.js +181 -12
  58. package/apps/runtime/dist/elements/specs.js +1 -1
  59. package/apps/runtime/dist/elements/wizards.js +15 -2
  60. package/apps/runtime/dist/engenty/connections-google/connectors/drive.js +3 -0
  61. package/apps/runtime/dist/engenty/connections-microsoft/onedrive.js +3 -0
  62. package/apps/runtime/dist/engenty/connections-s3/s3.js +6 -0
  63. package/apps/runtime/dist/engine/runner.js +19 -2
  64. package/apps/runtime/dist/engine/steps.js +1 -1
  65. package/apps/runtime/dist/env.js +6 -0
  66. package/apps/runtime/dist/files/blobs.js +57 -1
  67. package/apps/runtime/dist/files/objects.js +1 -0
  68. package/apps/runtime/dist/files/pictures.js +41 -0
  69. package/apps/runtime/dist/files/storage.js +14 -26
  70. package/apps/runtime/dist/files/thumbs.js +77 -0
  71. package/apps/runtime/dist/files/upload-check.js +2 -2
  72. package/apps/runtime/dist/index.js +22 -0
  73. package/apps/runtime/dist/live/views.js +2 -1
  74. package/apps/runtime/dist/manage.js +4 -1
  75. package/apps/runtime/dist/mcp/tools.js +5 -0
  76. package/apps/runtime/dist/models.js +82 -13
  77. package/apps/runtime/dist/mounts/cache.js +71 -0
  78. package/apps/runtime/dist/mounts/drafts.js +367 -0
  79. package/apps/runtime/dist/mounts/folder.js +148 -0
  80. package/apps/runtime/dist/mounts/mounts.js +1315 -0
  81. package/apps/runtime/dist/mounts/source.js +179 -0
  82. package/apps/runtime/dist/mounts/units.js +97 -0
  83. package/apps/runtime/dist/move-files.js +4 -0
  84. package/apps/runtime/dist/plugins/loader.js +73 -1
  85. package/apps/runtime/dist/plugins/registry.js +2 -0
  86. package/apps/runtime/dist/prompts/goose.md +13 -1
  87. package/apps/runtime/dist/prompts/tools.md +5 -2
  88. package/apps/runtime/dist/render/convert.js +188 -1
  89. package/apps/runtime/dist/routes/api.js +6 -1
  90. package/apps/runtime/dist/routes/client-contract.js +164 -0
  91. package/apps/runtime/dist/routes/client-spaces.js +58 -0
  92. package/apps/runtime/dist/routes/dateien.js +173 -0
  93. package/apps/runtime/dist/routes/elements.js +2 -2
  94. package/apps/runtime/dist/routes/plugins.js +2 -1
  95. package/apps/runtime/dist/routes/runs.js +24 -10
  96. package/apps/runtime/dist/routes/studio.js +168 -8
  97. package/apps/runtime/dist/secrets/signing.js +16 -0
  98. package/apps/runtime/dist/services/client-portal.js +439 -0
  99. package/apps/runtime/dist/services/client-spaces.js +228 -0
  100. package/apps/runtime/dist/services/cloud.js +2 -0
  101. package/apps/runtime/dist/services/knowledge-model.js +24 -8
  102. package/apps/runtime/dist/services/knowledge.js +72 -42
  103. package/apps/runtime/dist/services/links.js +17 -0
  104. package/apps/runtime/dist/services/members-studio.js +5 -1
  105. package/apps/runtime/dist/services/page-pictures.js +162 -0
  106. package/apps/runtime/dist/services/runs.js +22 -6
  107. package/apps/runtime/dist/services/space-categories.js +41 -5
  108. package/apps/runtime/dist/services/space-data.js +165 -8
  109. package/apps/runtime/dist/services/space-files.js +102 -19
  110. package/apps/runtime/dist/services/space-index.js +384 -41
  111. package/apps/runtime/dist/services/space-origin.js +25 -1
  112. package/apps/runtime/dist/services/space-sources.js +937 -0
  113. package/apps/runtime/dist/services/spaces.js +60 -12
  114. package/apps/runtime/dist/services/synced-spaces.js +10 -1
  115. package/apps/runtime/dist/services/work-ai.js +29 -8
  116. package/apps/runtime/dist/services/work-chats.js +3 -2
  117. package/apps/runtime/dist/sharing/index.js +2 -0
  118. package/apps/runtime/dist/store/index.js +29 -8
  119. package/apps/runtime/dist/store/shared-lists.js +30 -17
  120. package/apps/runtime/dist/sync/records.js +22 -27
  121. package/apps/runtime/dist/texts.js +4 -0
  122. package/apps/runtime/dist/tools/pages.js +1 -1
  123. package/apps/runtime/dist/widgets/step.js +2 -1
  124. package/apps/web/dist/assets/AboutDialog-0q4P80yv.js +1 -0
  125. package/apps/web/dist/assets/BlockEditor-CUYFH_CU.js +173 -0
  126. package/apps/web/dist/assets/BlockEditor-CtW6lw0y.css +1 -0
  127. package/apps/web/dist/assets/CapabilitiesPage-BlZP8DYb.js +2 -0
  128. package/apps/web/dist/assets/{ChangelogDialog-Do7pwmFv.js → ChangelogDialog-CDN7kMs1.js} +1 -1
  129. package/apps/web/dist/assets/{CodeEditor-Cdox-51M.js → CodeEditor-D-Y16fdk.js} +1 -1
  130. package/apps/web/dist/assets/EditorPage-CrMVsgUt.js +3 -0
  131. package/apps/web/dist/assets/{FlowPreview-BPS86xzA.js → FlowPreview-DXnk7m9P.js} +1 -1
  132. package/apps/web/dist/assets/{LangSwitch-BRHbi_Sd.js → LangSwitch-Dkd0FBIH.js} +1 -1
  133. package/apps/web/dist/assets/Marketplace-Cty40VwG.js +2 -0
  134. package/apps/web/dist/assets/NewWizardChannels-Czool7s1.js +1 -0
  135. package/apps/web/dist/assets/NewWizardPage-CfVe_4a2.js +7 -0
  136. package/apps/web/dist/assets/OnboardingPage-D3SEpTmt.js +1 -0
  137. package/apps/web/dist/assets/PreviewPane-CQDKQO6z.js +7 -0
  138. package/apps/web/dist/assets/PublicRunner-BDZNnlQw.js +1 -0
  139. package/apps/web/dist/assets/ReadOnly-B7MUySpC.js +1 -0
  140. package/apps/web/dist/assets/SettingsPage-Bgurv3l2.js +2 -0
  141. package/apps/web/dist/assets/SetupPage-C3km8vqv.js +1 -0
  142. package/apps/web/dist/assets/{SharePage-PKHX8a8a.js → SharePage-UwEJBIzq.js} +1 -1
  143. package/apps/web/dist/assets/SkillEditor-BaEiqqXl.js +1 -0
  144. package/apps/web/dist/assets/Skills-Bv6XbKxc.js +9 -0
  145. package/apps/web/dist/assets/SpacePage-D9PXLSU_.js +2 -0
  146. package/apps/web/dist/assets/UpdateCheck-C7I43zFZ.js +2 -0
  147. package/apps/web/dist/assets/changelog-DwgWiSZb.js +1 -0
  148. package/apps/web/dist/assets/circle-check-DDLzlcXP.js +1 -0
  149. package/apps/web/dist/assets/code-DsnwzN1x.js +1 -0
  150. package/apps/web/dist/assets/code-editor-Ca5EAxmd.js +2 -0
  151. package/apps/web/dist/assets/code-xml-S4IFi5Jc.js +1 -0
  152. package/apps/web/dist/assets/connection-sign-in-hI3HXhq4.js +1 -0
  153. package/apps/web/dist/assets/{dist-H1UN89OA.js → dist-B3Ray2U5.js} +1 -1
  154. package/apps/web/dist/assets/dist-CQpLJoQZ.js +10 -0
  155. package/apps/web/dist/assets/{dist-GlRRx9Xl.js → dist-D1uGQ_tB.js} +1 -1
  156. package/apps/web/dist/assets/{dist-BdDd1FxP.js → dist-DFI-tsfx.js} +1 -1
  157. package/apps/web/dist/assets/eye-TJSuiHHO.js +1 -0
  158. package/apps/web/dist/assets/floating-ui.dom-pwdNGv4b.js +1 -0
  159. package/apps/web/dist/assets/host-D5hNHbhF.js +125 -0
  160. package/apps/web/dist/assets/i18n-BBzMbGoo.js +55 -0
  161. package/apps/web/dist/assets/index-CyBrvupM.js +10 -0
  162. package/apps/web/dist/assets/index-w-3J3ZJ9.css +1 -0
  163. package/apps/web/dist/assets/{json-CEsfHdlZ.js → json-Ce3iHrtf.js} +1 -1
  164. package/apps/web/dist/assets/link-CPL8pB1P.js +1 -0
  165. package/apps/web/dist/assets/list-checks-DaxmUPqK.js +1 -0
  166. package/apps/web/dist/assets/{markdown-5-I9_izp.js → markdown-hqKQy2pp.js} +1 -1
  167. package/apps/web/dist/assets/marked.esm-DQ7XA7AC.js +67 -0
  168. package/apps/web/dist/assets/oss-credits-BrwV0a4F.js +1 -0
  169. package/apps/web/dist/assets/pdf-Dg-raaUo.js +54 -0
  170. package/apps/web/dist/assets/pdf.worker.min-68CMzziE.js +1 -0
  171. package/apps/web/dist/assets/pdf.worker.min-CjEcRF4W.mjs +28 -0
  172. package/apps/web/dist/assets/phone-B4uKDBFq.js +1 -0
  173. package/apps/web/dist/assets/read-aloud-Bfp9_bUY.js +1 -0
  174. package/apps/web/dist/assets/{runners-BoPaPsjN.js → runners-CUpBpSji.js} +1 -1
  175. package/apps/web/dist/assets/scroll-text-BEnPzQEi.js +1 -0
  176. package/apps/web/dist/assets/session-CMQo8P-G.js +2 -0
  177. package/apps/web/dist/assets/table-5B9G3oA6.js +1 -0
  178. package/apps/web/dist/assets/theme-CdX0marK.js +11 -0
  179. package/apps/web/dist/assets/ui-BCfu5sia.js +16 -0
  180. package/apps/web/dist/assets/upload-CAlHC232.js +1 -0
  181. package/apps/web/dist/assets/{useMutation-7_FOHoEl.js → useMutation-1fV4Nnxq.js} +1 -1
  182. package/apps/web/dist/assets/viewers-ChriFcRy.js +2 -0
  183. package/apps/web/dist/assets/volume-2-BqlBtCIJ.js +1 -0
  184. package/apps/web/dist/assets/w3c-keyname-BOAvb0qz.js +1 -0
  185. package/apps/web/dist/assets/xlsx-CuSbHU4R.js +141 -0
  186. package/apps/web/dist/index.html +19 -14
  187. package/apps/web/dist/mcp/flow.html +2 -2
  188. package/node_modules/@engenty/wizards/dist/plugin/index.d.ts +223 -4
  189. package/node_modules/@engenty/wizards/dist/plugin/mount.d.ts +123 -0
  190. package/node_modules/@engenty/wizards/dist/plugin/mount.js +7 -0
  191. package/node_modules/@engenty/wizards/dist/plugin/studio.d.ts +110 -1
  192. package/node_modules/@engenty/wizards-shared/dist/connectors.d.ts +1 -1
  193. package/node_modules/@engenty/wizards-shared/dist/feature-flags.d.ts +24 -0
  194. package/node_modules/@engenty/wizards-shared/dist/feature-flags.js +24 -0
  195. package/node_modules/@engenty/wizards-shared/dist/knowledge.d.ts +33 -4
  196. package/node_modules/@engenty/wizards-shared/dist/run.d.ts +3 -0
  197. package/node_modules/@engenty/wizards-shared/dist/run.js +6 -0
  198. package/node_modules/@engenty/wizards-shared/dist/rwx.d.ts +21 -4
  199. package/node_modules/@engenty/wizards-shared/dist/rwx.js +27 -3
  200. package/node_modules/@engenty/wizards-shared/dist/spaces.d.ts +11 -1
  201. package/node_modules/@engenty/wizards-shared/dist/spaces.js +9 -2
  202. package/node_modules/@engenty/wizards-shared/dist/text-merge.d.ts +6 -0
  203. package/node_modules/@engenty/wizards-shared/dist/text-merge.js +25 -0
  204. package/package.json +3 -1
  205. package/plugin/.claude-plugin/plugin.json +1 -1
  206. package/plugin/plugin.json +1 -1
  207. package/apps/web/dist/assets/AboutDialog-DaWEIHFN.js +0 -1
  208. package/apps/web/dist/assets/CapabilitiesPage-Dt91U_sK.js +0 -2
  209. package/apps/web/dist/assets/EditorPage-DS_a5K3s.js +0 -3
  210. package/apps/web/dist/assets/Marketplace-CS7JTgiv.js +0 -2
  211. package/apps/web/dist/assets/NewWizardChannels-D-OLsex6.js +0 -1
  212. package/apps/web/dist/assets/NewWizardPage-BM_pkk41.js +0 -7
  213. package/apps/web/dist/assets/OnboardingPage-Cpn5pubC.js +0 -1
  214. package/apps/web/dist/assets/PreviewPane-BOk1-yO4.js +0 -9
  215. package/apps/web/dist/assets/PublicRunner-CgzMZb0r.js +0 -1
  216. package/apps/web/dist/assets/ReadOnly-8DEx-ly3.js +0 -1
  217. package/apps/web/dist/assets/SettingsPage-CcrknFcI.js +0 -2
  218. package/apps/web/dist/assets/SetupPage-D5nzjgPU.js +0 -1
  219. package/apps/web/dist/assets/SkillEditor-BsXTqNli.js +0 -1
  220. package/apps/web/dist/assets/Skills-C_X1ZsKg.js +0 -9
  221. package/apps/web/dist/assets/SpacePage-wZGqUoSQ.js +0 -2
  222. package/apps/web/dist/assets/UpdateCheck-D6x7MqEl.js +0 -2
  223. package/apps/web/dist/assets/changelog-M-eOBqgu.js +0 -1
  224. package/apps/web/dist/assets/circle-alert-DJbCyxcg.js +0 -1
  225. package/apps/web/dist/assets/circle-check-jqtsKi_b.js +0 -1
  226. package/apps/web/dist/assets/code-editor-BpCEnf8H.js +0 -2
  227. package/apps/web/dist/assets/code-xml-q88cSTV8.js +0 -1
  228. package/apps/web/dist/assets/connection-sign-in-UJ6xk-TD.js +0 -1
  229. package/apps/web/dist/assets/dist-EBVTpvRr.js +0 -10
  230. package/apps/web/dist/assets/eye-CgkvVlba.js +0 -1
  231. package/apps/web/dist/assets/host-Bd_bon_c.js +0 -118
  232. package/apps/web/dist/assets/i18n-0fUKyVRE.js +0 -55
  233. package/apps/web/dist/assets/index-D18DvnxX.css +0 -1
  234. package/apps/web/dist/assets/index-DOgwxnto.js +0 -10
  235. package/apps/web/dist/assets/oss-credits-IdX5bc71.js +0 -1
  236. package/apps/web/dist/assets/phone-CjPvZ0nk.js +0 -1
  237. package/apps/web/dist/assets/read-aloud-CLXo_asN.js +0 -1
  238. package/apps/web/dist/assets/scroll-text-2BhJO_W7.js +0 -1
  239. package/apps/web/dist/assets/session-CpYa5hwd.js +0 -2
  240. package/apps/web/dist/assets/theme-Bj3wNQR0.js +0 -11
  241. package/apps/web/dist/assets/ui-CktezodE.js +0 -82
  242. package/apps/web/dist/assets/upload-CHGCFVZK.js +0 -1
  243. package/apps/web/dist/assets/volume-2-Bw5KASy8.js +0 -1
@@ -73,12 +73,17 @@ const tooLarge = bodyLimit({
73
73
  * The caller of an API call, signed in like an MCP client (access token or API key), with the
74
74
  * scopes the call needs; or the answer that turns it away.
75
75
  */
76
- export async function caller(c, scopes) {
76
+ export async function caller(c, scopes, { clients = false } = {}) {
77
77
  const authInfo = await authenticate(c.req.raw);
78
78
  if (authInfo instanceof Response) {
79
79
  return authInfo;
80
80
  }
81
81
  const who = principalOf(authInfo);
82
+ // A client of the organization uses its client spaces' elements, nothing else of the API
83
+ // (docs/plans/client-spaces.md).
84
+ if (who.role === "client" && !clients) {
85
+ return c.json({ error: "This isn’t open to clients.", code: "forbidden" }, 403);
86
+ }
82
87
  if (scopes.some((scope) => !who.scopes.includes(scope))) {
83
88
  return c.json({ error: "This token isn’t allowed to do that.", code: "insufficient_scope" }, 403);
84
89
  }
@@ -0,0 +1,164 @@
1
+ import { Hono } from "hono";
2
+ import { z } from "zod";
3
+ import { clientOf } from "../clients.js";
4
+ import { clientChatMessages, clientChatPost, clientChats, clientFile, clientFileInfo, clientFiles, clientForYou, clientMe, clientOpenRun, clientResults, clientSpaces, clientStartWizard, clientWizards, } from "../services/client-portal.js";
5
+ import { caller, inTenantAs } from "./api.js";
6
+ import { notFoundAnswer } from "./lang.js";
7
+ const none = z.object({});
8
+ export const CLIENT_CALLS = {
9
+ me: {
10
+ scope: "data:read",
11
+ space: false,
12
+ description: "Who you are, and the organization you are a client of.",
13
+ input: none,
14
+ run: (who) => clientMe(who),
15
+ },
16
+ spaces: {
17
+ scope: "data:read",
18
+ space: false,
19
+ description: "Your client spaces, each with the firm's space and its brand.",
20
+ input: none,
21
+ run: (who) => clientSpaces(who),
22
+ },
23
+ for_you: {
24
+ scope: "data:read",
25
+ space: true,
26
+ description: "What waits for you in a client space: your runs waiting on a page or an answer, results the firm shared, the wizards you can start.",
27
+ input: none,
28
+ run: (who, spaceId) => clientForYou(who, spaceId),
29
+ },
30
+ wizards: {
31
+ scope: "elements:read",
32
+ space: true,
33
+ description: "The firm's wizards you can start in a client space, each with its engenty (`avatar`) and its number of steps.",
34
+ input: none,
35
+ run: (who, spaceId) => clientWizards(who, spaceId),
36
+ },
37
+ wizard_start: {
38
+ scope: "elements:run",
39
+ space: true,
40
+ description: "Starts one of those wizards in the client space. Gives the run and its ticket for the run's own routes.",
41
+ input: z.object({ wizardId: z.string().min(1).max(64) }),
42
+ run: (who, spaceId, input) => clientStartWizard(who, spaceId, input.wizardId),
43
+ },
44
+ results: {
45
+ scope: "data:read",
46
+ space: true,
47
+ description: "The finished runs of a client space you see: yours, and those the firm shared.",
48
+ input: none,
49
+ run: (who, spaceId) => clientResults(who, spaceId),
50
+ },
51
+ run_open: {
52
+ scope: "data:read",
53
+ space: false,
54
+ description: "One run you see, by its id: a ticket its own routes open with (`?rt=`), and its client space.",
55
+ input: z.object({ runId: z.string().min(1).max(64) }),
56
+ run: (who, _spaceId, input) => clientOpenRun(who, input.runId),
57
+ },
58
+ chats: {
59
+ scope: "data:read",
60
+ space: true,
61
+ description: "The chats of a client space you are a member of.",
62
+ input: none,
63
+ run: (who, spaceId) => clientChats(who, spaceId),
64
+ },
65
+ chat_messages: {
66
+ scope: "data:read",
67
+ space: false,
68
+ description: "One of your chats, by its id: who wrote what, its text and the AI's views and runs as parts in order, and its client space.",
69
+ input: z.object({ chatId: z.string().min(1).max(64) }),
70
+ run: (who, _spaceId, input) => clientChatMessages(who, input.chatId),
71
+ },
72
+ chat_post: {
73
+ scope: "elements:run",
74
+ space: true,
75
+ description: "Writes in one of your chats, or starts a new one. The firm's AI answers every message; the firm's people read the chat too.",
76
+ input: z.object({
77
+ chatId: z.string().min(1).max(64).optional(),
78
+ text: z.string().trim().min(1).max(20_000),
79
+ }),
80
+ run: (who, spaceId, input) => clientChatPost(who, spaceId, input),
81
+ },
82
+ files: {
83
+ scope: "data:read",
84
+ space: true,
85
+ description: "The files of a client space. One file's bytes: GET /client/files/:fileId.",
86
+ input: none,
87
+ run: (who, spaceId) => clientFiles(who, spaceId),
88
+ },
89
+ file: {
90
+ scope: "data:read",
91
+ space: false,
92
+ description: "One file you see, by its id: what it is, and its client space.",
93
+ input: z.object({ fileId: z.string().min(1).max(64) }),
94
+ run: (who, _spaceId, input) => clientFileInfo(who, input.fileId),
95
+ },
96
+ };
97
+ const CALLS = CLIENT_CALLS;
98
+ const callBody = z.object({ input: z.record(z.string(), z.unknown()).default({}) });
99
+ /** The token's person as the services know a client, or the answer that turns the call away. */
100
+ async function clientWho(c, scope) {
101
+ const who = await caller(c, [scope], { clients: true });
102
+ if (who instanceof Response) {
103
+ return who;
104
+ }
105
+ if (who.role !== "client") {
106
+ return c.json({ error: "This is for clients of the organization.", code: "clients_only" }, 403);
107
+ }
108
+ return {
109
+ who: {
110
+ id: who.userId,
111
+ tenantId: who.tenantId,
112
+ role: who.role,
113
+ name: who.name ?? "",
114
+ email: who.email ?? "",
115
+ client: clientOf(c) ?? who.client,
116
+ },
117
+ principal: who,
118
+ };
119
+ }
120
+ async function callClient(c, name, spaceId) {
121
+ const call = CALLS[name];
122
+ if (!call || call.space !== (spaceId !== null)) {
123
+ return c.json(notFoundAnswer(c), 404);
124
+ }
125
+ const signedIn = await clientWho(c, call.scope);
126
+ if (signedIn instanceof Response) {
127
+ return signedIn;
128
+ }
129
+ const { who, principal } = signedIn;
130
+ const body = callBody.safeParse(await c.req.json().catch(() => ({})));
131
+ const input = body.success ? call.input.safeParse(body.data.input) : null;
132
+ if (!input?.success) {
133
+ return c.json({ error: "Invalid input", code: "invalid", issues: input?.error.issues ?? [] }, 400);
134
+ }
135
+ const result = await inTenantAs(principal, () => call.run(who, spaceId ?? "", input.data));
136
+ return c.json({ result });
137
+ }
138
+ export const clientContractRoutes = new Hono()
139
+ .get("/client", (c) => c.json({
140
+ calls: Object.entries(CALLS).map(([name, call]) => ({
141
+ name,
142
+ path: call.space ? `/api/v1/client/spaces/{spaceId}/${name}` : `/api/v1/client/${name}`,
143
+ scope: call.scope,
144
+ description: call.description,
145
+ input: z.toJSONSchema(call.input, { unrepresentable: "any" }),
146
+ })),
147
+ }))
148
+ .get("/client/files/:fileId", async (c) => {
149
+ const signedIn = await clientWho(c, "data:read");
150
+ if (signedIn instanceof Response) {
151
+ return signedIn;
152
+ }
153
+ const { who, principal } = signedIn;
154
+ const file = await inTenantAs(principal, () => clientFile(who, c.req.param("fileId")));
155
+ return new Response(new Uint8Array(file.data), {
156
+ headers: {
157
+ "content-type": file.mime,
158
+ "content-disposition": `attachment; filename*=UTF-8''${encodeURIComponent(file.name)}`,
159
+ "cache-control": "private, no-store",
160
+ },
161
+ });
162
+ })
163
+ .post("/client/spaces/:spaceId/:name", (c) => callClient(c, c.req.param("name"), c.req.param("spaceId")))
164
+ .post("/client/:name", (c) => callClient(c, c.req.param("name"), null));
@@ -0,0 +1,58 @@
1
+ import { Hono } from "hono";
2
+ import { z } from "zod";
3
+ import { setOpenToClients } from "../broker/rwx.js";
4
+ import { addSpaceMember, clientOpenOf, createClientSpace, deleteClientSpace, inviteClient, listClientSpaces, listSpaceMembers, removeSpaceMember, renameClientSpace, requireClientSpaces, shareWithClient, } from "../services/client-spaces.js";
5
+ const OPEN_KINDS = ["document", "table", "page", "wizard"];
6
+ export const clientSpaceRoutes = new Hono()
7
+ .get("/spaces/:id/clients", async (c) => c.json({ clients: await listClientSpaces(c.get("user").id, c.req.param("id")) }))
8
+ .post("/spaces/:id/clients", async (c) => {
9
+ const { name } = z.object({ name: z.string().min(1).max(200) }).parse(await c.req.json());
10
+ return c.json(await createClientSpace(c.get("user").id, c.req.param("id"), name));
11
+ })
12
+ .patch("/spaces/:id/client", async (c) => {
13
+ const { name } = z
14
+ .object({ name: z.string().trim().min(1).max(200) })
15
+ .parse(await c.req.json());
16
+ return c.json(await renameClientSpace(c.get("user").id, c.req.param("id"), name));
17
+ })
18
+ // A run of a client space shared with its clients on purpose, or taken back.
19
+ .put("/runs/:id/client-share", async (c) => {
20
+ const { shared } = z.object({ shared: z.boolean() }).parse(await c.req.json());
21
+ return c.json(await shareWithClient(c.get("user").id, c.req.param("id"), shared));
22
+ })
23
+ .delete("/spaces/:id/client", async (c) => {
24
+ await deleteClientSpace(c.get("user").id, c.req.param("id"));
25
+ return c.json({ ok: true });
26
+ })
27
+ .get("/spaces/:id/members", async (c) => c.json({ members: await listSpaceMembers(c.get("user").id, c.req.param("id")) }))
28
+ .put("/spaces/:id/members/:userId", async (c) => {
29
+ const { role } = z.object({ role: z.enum(["member", "client"]) }).parse(await c.req.json());
30
+ await addSpaceMember(c.get("user").id, c.req.param("id"), {
31
+ userId: c.req.param("userId"),
32
+ role,
33
+ });
34
+ return c.json({ ok: true });
35
+ })
36
+ .post("/spaces/:id/invite", async (c) => {
37
+ const { email, lang } = z
38
+ .object({
39
+ email: z.string().trim().email().max(254),
40
+ lang: z.enum(["de", "en"]).default("de"),
41
+ })
42
+ .parse(await c.req.json());
43
+ await inviteClient(c.get("user").id, c.req.param("id"), { email, lang });
44
+ return c.json({ ok: true });
45
+ })
46
+ .delete("/spaces/:id/members/:userId", async (c) => {
47
+ await removeSpaceMember(c.get("user").id, c.req.param("id"), c.req.param("userId"));
48
+ return c.json({ ok: true });
49
+ })
50
+ .get("/spaces/:id/open-to-clients", async (c) => c.json({ open: await clientOpenOf(c.get("user").id, c.req.param("id")) }))
51
+ .put("/spaces/:id/open-to-clients", async (c) => {
52
+ await requireClientSpaces();
53
+ const body = z
54
+ .object({ kind: z.enum(OPEN_KINDS), id: z.string().min(1).max(64), open: z.boolean() })
55
+ .parse(await c.req.json());
56
+ await setOpenToClients(c.get("user").id, c.req.param("id"), { kind: body.kind, id: body.id }, body.open);
57
+ return c.json({ ok: true });
58
+ });
@@ -0,0 +1,173 @@
1
+ import { note } from "@engenty/wizards-shared/run";
2
+ import { AGENT_ACCESS, AUDIENCES } from "@engenty/wizards-shared/rwx";
3
+ import { Hono } from "hono";
4
+ import { z } from "zod";
5
+ import { subjectsOfPerson } from "../broker/rwx.js";
6
+ import { discardDraft, keepMine, mountDrafts, openDraft, publishDraft, publishMount, replaceDraft, saveDraft, } from "../mounts/drafts.js";
7
+ import { completeFolder, createMount, deleteMount, listMounts, mountAccess, mountCanWrite, mountFileContent, mountFiles, mountFileThumb, mountFileView, mountRow, mountView, pickFolder, previewFolder, rescanMount, updateMount, } from "../mounts/mounts.js";
8
+ import { copyToKnowledge } from "../mounts/source.js";
9
+ import { ServiceError } from "../services/errors.js";
10
+ import { ownedSpace } from "../services/spaces.js";
11
+ import { spaceFileResponse } from "./delivery.js";
12
+ const whoOf = (c) => subjectsOfPerson(c.get("user").id, c.get("user").role);
13
+ const access = {
14
+ see: z.array(z.enum(AUDIENCES)).max(AUDIENCES.length),
15
+ wizards: z.union([z.enum(["all", "none"]), z.array(z.string().max(60)).max(200)]),
16
+ // A Work chat reads a folder unless it is told otherwise.
17
+ agents: z.enum(AGENT_ACCESS).default("read"),
18
+ };
19
+ export const dateienRoutes = new Hono()
20
+ .get("/spaces/:id/mounts", async (c) => {
21
+ const space = await ownedSpace(c.get("user").id, c.req.param("id"));
22
+ return c.json({ mounts: await listMounts(space.id, whoOf(c)) });
23
+ })
24
+ // The system's folder dialog on this computer; `{ path: false }` where there is none.
25
+ .post("/spaces/:id/mounts/pick", async (c) => {
26
+ await ownedSpace(c.get("user").id, c.req.param("id"));
27
+ const { prompt } = z.object({ prompt: z.string().max(200) }).parse(await c.req.json());
28
+ return c.json({ path: await pickFolder(prompt) });
29
+ })
30
+ .get("/spaces/:id/mounts/folders", async (c) => {
31
+ await ownedSpace(c.get("user").id, c.req.param("id"));
32
+ return c.json({ folders: await completeFolder(c.req.query("path") ?? "") });
33
+ })
34
+ // What a folder holds, for the review before it is mounted.
35
+ .post("/spaces/:id/mounts/preview", async (c) => {
36
+ await ownedSpace(c.get("user").id, c.req.param("id"));
37
+ const { path } = z.object({ path: z.string().min(1).max(1000) }).parse(await c.req.json());
38
+ return c.json(await previewFolder(path));
39
+ })
40
+ .post("/spaces/:id/mounts", async (c) => {
41
+ const space = await ownedSpace(c.get("user").id, c.req.param("id"));
42
+ const body = z
43
+ .object({
44
+ path: z.string().min(1).max(1000).optional(),
45
+ kind: z.string().max(24).optional(),
46
+ source: z.record(z.string(), z.unknown()).optional(),
47
+ name: z.string().max(120).optional(),
48
+ folderCategory: z.string().max(60).nullable().optional(),
49
+ writable: z.boolean().optional(),
50
+ ...access,
51
+ })
52
+ .parse(await c.req.json());
53
+ return c.json(await createMount(c.get("user").id, space.id, body));
54
+ })
55
+ .get("/spaces/:id/mounts/:mountId", async (c) => {
56
+ const space = await ownedSpace(c.get("user").id, c.req.param("id"));
57
+ const row = await mountRow(space.id, c.req.param("mountId"), whoOf(c));
58
+ const mount = await mountView(space.id, row.id, whoOf(c));
59
+ return c.json({
60
+ ...mount,
61
+ ...(await mountAccess(space.id, mount.id)),
62
+ canWrite: await mountCanWrite(row),
63
+ ...(row.kind === "folder" ? {} : { source: row.source }),
64
+ });
65
+ })
66
+ .patch("/spaces/:id/mounts/:mountId", async (c) => {
67
+ const space = await ownedSpace(c.get("user").id, c.req.param("id"));
68
+ const body = z
69
+ .object({
70
+ name: z.string().max(120).optional(),
71
+ see: access.see.optional(),
72
+ wizards: access.wizards.optional(),
73
+ agents: access.agents.optional(),
74
+ writable: z.boolean().optional(),
75
+ })
76
+ .parse(await c.req.json());
77
+ return c.json(await updateMount(c.get("user").id, space.id, c.req.param("mountId"), whoOf(c), body));
78
+ })
79
+ .post("/spaces/:id/mounts/:mountId/rescan", async (c) => {
80
+ const space = await ownedSpace(c.get("user").id, c.req.param("id"));
81
+ await rescanMount(space.id, c.req.param("mountId"), whoOf(c));
82
+ return c.json({ ok: true });
83
+ })
84
+ .delete("/spaces/:id/mounts/:mountId", async (c) => {
85
+ const space = await ownedSpace(c.get("user").id, c.req.param("id"));
86
+ await deleteMount(space.id, c.req.param("mountId"));
87
+ return c.json({ ok: true });
88
+ })
89
+ .get("/spaces/:id/mounts/:mountId/files", async (c) => {
90
+ const space = await ownedSpace(c.get("user").id, c.req.param("id"));
91
+ return c.json({ files: await mountFiles(space.id, c.req.param("mountId"), whoOf(c)) });
92
+ })
93
+ .get("/spaces/:id/mount-files/:fileId", async (c) => {
94
+ const space = await ownedSpace(c.get("user").id, c.req.param("id"));
95
+ return c.json(await mountFileView(space.id, c.req.param("fileId"), whoOf(c)));
96
+ })
97
+ // A mounted file's bytes, read where it lives.
98
+ .get("/spaces/:id/mount-files/:fileId/content", async (c) => {
99
+ const space = await ownedSpace(c.get("user").id, c.req.param("id"));
100
+ const { file, data } = await mountFileContent(space.id, c.req.param("fileId"), whoOf(c));
101
+ return spaceFileResponse(c, file.mime, data);
102
+ })
103
+ // „In Wissen übernehmen“: a copy of the file in Knowledge, read as an upload is.
104
+ .post("/spaces/:id/mount-files/:fileId/knowledge", async (c) => {
105
+ const space = await ownedSpace(c.get("user").id, c.req.param("id"));
106
+ const { parentId } = z
107
+ .object({ parentId: z.string().max(40).nullish() })
108
+ .parse(await c.req.json().catch(() => ({})));
109
+ const row = await copyToKnowledge(c.get("user").id, space.id, c.req.param("fileId"), whoOf(c), parentId ?? null);
110
+ return c.json({ id: row.id, name: row.name });
111
+ })
112
+ .get("/spaces/:id/mount-files/:fileId/thumb", async (c) => {
113
+ const space = await ownedSpace(c.get("user").id, c.req.param("id"));
114
+ const thumb = await mountFileThumb(space.id, c.req.param("fileId"), whoOf(c));
115
+ return thumb ? spaceFileResponse(c, "image/jpeg", thumb) : c.notFound();
116
+ })
117
+ .get("/spaces/:id/mounts/:mountId/drafts", async (c) => {
118
+ const space = await ownedSpace(c.get("user").id, c.req.param("id"));
119
+ return c.json({ drafts: await mountDrafts(space.id, c.req.param("mountId"), whoOf(c)) });
120
+ })
121
+ // „Veröffentlichen“ for every draft of the mount without a conflict.
122
+ .post("/spaces/:id/mounts/:mountId/publish", async (c) => {
123
+ const space = await ownedSpace(c.get("user").id, c.req.param("id"));
124
+ return c.json(await publishMount(space.id, c.req.param("mountId"), whoOf(c)));
125
+ })
126
+ // The file's draft, else the file as it stands, to edit.
127
+ .get("/spaces/:id/mount-files/:fileId/draft", async (c) => {
128
+ const space = await ownedSpace(c.get("user").id, c.req.param("id"));
129
+ return c.json(await openDraft(space.id, c.req.param("fileId"), whoOf(c)));
130
+ })
131
+ .put("/spaces/:id/mount-files/:fileId/draft", async (c) => {
132
+ const space = await ownedSpace(c.get("user").id, c.req.param("id"));
133
+ const body = z
134
+ .object({
135
+ text: z.string().max(4_000_000),
136
+ base: z
137
+ .object({
138
+ size: z.number().int().min(0),
139
+ modified: z.number(),
140
+ version: z.string().nullable(),
141
+ hash: z.string().max(64),
142
+ })
143
+ .optional(),
144
+ baseText: z.string().max(4_000_000).optional(),
145
+ })
146
+ .parse(await c.req.json());
147
+ const draft = await saveDraft(c.get("user").id, space.id, c.req.param("fileId"), whoOf(c), body);
148
+ return c.json({ draft });
149
+ })
150
+ // A file replaced by an upload (the form's `file`), as a draft.
151
+ .post("/spaces/:id/mount-files/:fileId/draft/replace", async (c) => {
152
+ const space = await ownedSpace(c.get("user").id, c.req.param("id"));
153
+ const file = (await c.req.formData()).get("file");
154
+ if (!(file instanceof File)) {
155
+ throw new ServiceError("invalid", note("chooseFile"));
156
+ }
157
+ const data = new Uint8Array(await file.arrayBuffer());
158
+ return c.json(await replaceDraft(c.get("user").id, space.id, c.req.param("fileId"), whoOf(c), data, file.type || "application/octet-stream"));
159
+ })
160
+ .delete("/spaces/:id/mount-files/:fileId/draft", async (c) => {
161
+ const space = await ownedSpace(c.get("user").id, c.req.param("id"));
162
+ await discardDraft(space.id, c.req.param("fileId"), whoOf(c));
163
+ return c.json({ ok: true });
164
+ })
165
+ .post("/spaces/:id/mount-files/:fileId/publish", async (c) => {
166
+ const space = await ownedSpace(c.get("user").id, c.req.param("id"));
167
+ return c.json(await publishDraft(space.id, c.req.param("fileId"), whoOf(c)));
168
+ })
169
+ // „Meine behalten“: the draft over what stands at the source now.
170
+ .post("/spaces/:id/mount-files/:fileId/keep-mine", async (c) => {
171
+ const space = await ownedSpace(c.get("user").id, c.req.param("id"));
172
+ return c.json(await keepMine(space.id, c.req.param("fileId"), whoOf(c)));
173
+ });
@@ -27,7 +27,7 @@ const calls = () => [
27
27
  const callBody = z.object({ input: z.record(z.string(), z.unknown()).default({}) });
28
28
  export const elementRoutes = new Hono()
29
29
  .get("/spaces/:spaceId/elements", async (c) => {
30
- const who = await caller(c, []);
30
+ const who = await caller(c, [], { clients: true });
31
31
  if (who instanceof Response) {
32
32
  return who;
33
33
  }
@@ -41,7 +41,7 @@ export const elementRoutes = new Hono()
41
41
  });
42
42
  })
43
43
  .post("/spaces/:spaceId/elements/:name", async (c) => {
44
- const who = await caller(c, []);
44
+ const who = await caller(c, [], { clients: true });
45
45
  if (who instanceof Response) {
46
46
  return who;
47
47
  }
@@ -54,7 +54,8 @@ export function answerOf(err) {
54
54
  export async function dispatchAs(c, user) {
55
55
  const id = c.req.param("id") ?? "";
56
56
  const plugin = (await pluginIdsOf(user.tenantId)).has(id) ? loadedPlugin(id) : undefined;
57
- if (!plugin) {
57
+ // A client of the organization reaches no plugin's studio routes (docs/plans/client-spaces.md).
58
+ if (!plugin || user.role === "client") {
58
59
  return c.json(notFoundAnswer(c), 404);
59
60
  }
60
61
  const url = new URL(c.req.url);
@@ -37,12 +37,14 @@ import { transcribeAudio } from "../media/transcribe.js";
37
37
  import { errorText, ModelUnavailableError, noteOf } from "../model-errors.js";
38
38
  import { listDownload, renderDownload, stepHtml } from "../render/downloads.js";
39
39
  import { HTML_RESPONSE_CSP } from "../render/guard.js";
40
- import { runTicketValid, verifySignedUrl } from "../secrets/signing.js";
40
+ import { runTicketValid, runViewTicketValid, verifySignedUrl } from "../secrets/signing.js";
41
41
  import { brandView } from "../services/brand.js";
42
+ import { clientMayOpen } from "../services/client-portal.js";
42
43
  import { ServiceError } from "../services/errors.js";
43
44
  import { publicRunners, servePageRunner } from "../services/runners.js";
44
45
  import { sharedRun, sharedStepIds, shareImage, shareRun, shareView, unshareRun, } from "../services/shares.js";
45
46
  import { shippedFontCss, shippedFontFile } from "../services/shipped-fonts.js";
47
+ import { spaceFileBytes } from "../services/space-files.js";
46
48
  import { isLangCode, storedTranslation, translateResult, translationFor, uiTexts, } from "../services/translations.js";
47
49
  import { isIconFile, wizardAvatarSvg, wizardIcon } from "../services/wizard-icon.js";
48
50
  import { shareOverview } from "../sharing/index.js";
@@ -132,12 +134,21 @@ async function accessibleRun(c, runId, opts = {}) {
132
134
  if (runTicketValid(run.id, c.req.query("rt"))) {
133
135
  return run;
134
136
  }
137
+ // A ticket that only reads: a run the firm shared with a client (services/client-portal.ts).
138
+ if (c.req.method === "GET" && runViewTicketValid(run.id, c.req.query("rt"))) {
139
+ return run;
140
+ }
135
141
  const vid = visitorId(c, false);
136
142
  if (vid && run.visitorId === vid) {
137
143
  return run;
138
144
  }
139
145
  const user = await principalOf(c);
140
146
  if (user && user.tenantId === run.tenantId) {
147
+ // A client of the organization opens only the runs of their client spaces that are theirs
148
+ // or shared with them (docs/plans/client-portal.md); the firm opens every run.
149
+ if (user.role === "client" && !(await clientMayOpen(user.id, run))) {
150
+ return null;
151
+ }
141
152
  return run;
142
153
  }
143
154
  return null;
@@ -145,7 +156,7 @@ async function accessibleRun(c, runId, opts = {}) {
145
156
  /** Whether a signed-in member of the run's organization is looking, not the guest who ran it. */
146
157
  async function memberViewing(c, run) {
147
158
  const user = await principalOf(c);
148
- return !!user && user.tenantId === run.tenantId;
159
+ return !!user && user.tenantId === run.tenantId && user.role !== "client";
149
160
  }
150
161
  /**
151
162
  * What a step of a guest's run made from a connection the space keeps for its members stays in
@@ -508,12 +519,15 @@ export const publicRoutes = new Hono()
508
519
  });
509
520
  })
510
521
  .get("/logos/:id", async (c) => {
511
- const found = await loadAsset(c.req.param("id"));
512
- if (found?.row.kind !== "logo") {
522
+ const row = await db.query.spaceFile.findFirst({
523
+ where: eq(schema.spaceFile.id, c.req.param("id")),
524
+ });
525
+ const data = row?.kind === "logo" ? await spaceFileBytes(row) : null;
526
+ if (!row || !data) {
513
527
  return c.notFound();
514
528
  }
515
- return c.body(new Uint8Array(found.data), 200, {
516
- "content-type": bareMime(found.row.mime) ?? "application/octet-stream",
529
+ return c.body(new Uint8Array(data), 200, {
530
+ "content-type": bareMime(row.mime) ?? "application/octet-stream",
517
531
  "cache-control": "public, max-age=86400",
518
532
  "x-content-type-options": "nosniff",
519
533
  // An SVG logo is shown, never run.
@@ -554,12 +568,12 @@ export const publicRoutes = new Hono()
554
568
  ? await db.query.space.findFirst({ where: eq(schema.space.id, row.spaceId) })
555
569
  : null;
556
570
  const named = p?.brand.fonts?.some((f) => f.source && "file" in f.source && f.source.file === id);
557
- const found = named && row?.mime.startsWith("font/") ? await loadAsset(id) : null;
558
- if (!found) {
571
+ const data = named && row?.mime.startsWith("font/") ? await spaceFileBytes(row) : null;
572
+ if (!row || !data) {
559
573
  return c.notFound();
560
574
  }
561
- return c.body(new Uint8Array(found.data), 200, {
562
- "content-type": bareMime(found.row.mime) ?? "application/octet-stream",
575
+ return c.body(new Uint8Array(data), 200, {
576
+ "content-type": bareMime(row.mime) ?? "application/octet-stream",
563
577
  "cache-control": "public, max-age=86400",
564
578
  "x-content-type-options": "nosniff",
565
579
  "access-control-allow-origin": "*",