@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
@@ -295,6 +295,104 @@
295
295
  "when": 1793462415359,
296
296
  "tag": "0041_broker_log_client",
297
297
  "breakpoints": true
298
+ },
299
+ {
300
+ "idx": 42,
301
+ "version": "6",
302
+ "when": 1793483673049,
303
+ "tag": "0042_client_spaces",
304
+ "breakpoints": true
305
+ },
306
+ {
307
+ "idx": 43,
308
+ "version": "6",
309
+ "when": 1793484500603,
310
+ "tag": "0043_space_member_invite",
311
+ "breakpoints": true
312
+ },
313
+ {
314
+ "idx": 44,
315
+ "version": "6",
316
+ "when": 1793522503369,
317
+ "tag": "0044_client_portal",
318
+ "breakpoints": true
319
+ },
320
+ {
321
+ "idx": 45,
322
+ "version": "6",
323
+ "when": 1793524595925,
324
+ "tag": "0045_client_portal_no_slug",
325
+ "breakpoints": true
326
+ },
327
+ {
328
+ "idx": 46,
329
+ "version": "6",
330
+ "when": 1793528832589,
331
+ "tag": "0046_space_file_hash",
332
+ "breakpoints": true
333
+ },
334
+ {
335
+ "idx": 47,
336
+ "version": "6",
337
+ "when": 1793530627348,
338
+ "tag": "0047_knowledge_folders",
339
+ "breakpoints": true
340
+ },
341
+ {
342
+ "idx": 48,
343
+ "version": "6",
344
+ "when": 1793530918731,
345
+ "tag": "0048_space_chunk_kind",
346
+ "breakpoints": true
347
+ },
348
+ {
349
+ "idx": 49,
350
+ "version": "6",
351
+ "when": 1793531418985,
352
+ "tag": "0049_knowledge_sources",
353
+ "breakpoints": true
354
+ },
355
+ {
356
+ "idx": 50,
357
+ "version": "6",
358
+ "when": 1793532546956,
359
+ "tag": "0050_dateien",
360
+ "breakpoints": true
361
+ },
362
+ {
363
+ "idx": 51,
364
+ "version": "6",
365
+ "when": 1793533776814,
366
+ "tag": "0051_dateien_drafts",
367
+ "breakpoints": true
368
+ },
369
+ {
370
+ "idx": 52,
371
+ "version": "6",
372
+ "when": 1793534570691,
373
+ "tag": "0052_dateien_plugin_kinds",
374
+ "breakpoints": true
375
+ },
376
+ {
377
+ "idx": 53,
378
+ "version": "6",
379
+ "when": 1793547992117,
380
+ "tag": "0053_dateien_file_title",
381
+ "breakpoints": true
382
+ },
383
+ {
384
+ "idx": 54,
385
+ "version": "6",
386
+ "when": 1793554001311,
387
+ "tag": "0054_dateien_ocr",
388
+ "breakpoints": true
389
+ },
390
+ {
391
+ "idx": 55,
392
+ "version": "6",
393
+ "when": 1793556126014,
394
+ "tag": "0055_dateien_doc_reread",
395
+ "breakpoints": true
298
396
  }
299
397
  ]
300
398
  }
@@ -43,9 +43,43 @@ export const space = sqliteTable("space", {
43
43
  */
44
44
  origin: text("origin", { enum: ["local"] }),
45
45
  syncedAt: integer("synced_at", { mode: "timestamp_ms" }),
46
+ /**
47
+ * `client`: a client space under `parentId` (docs/plans/client-spaces.md): one client's data,
48
+ * results and chats, reading the parent's setup. `space`: a space of the organization.
49
+ */
50
+ kind: text("kind", { enum: ["space", "client"] })
51
+ .notNull()
52
+ .default("space"),
53
+ /** The space a client space belongs to; null for a space. Two levels, never more. */
54
+ parentId: text("parent_id").references(() => space.id, {
55
+ onDelete: "cascade",
56
+ }),
46
57
  createdAt: createdAt(),
47
58
  updatedAt: updatedAt(),
48
- }, (t) => [index("space_tenant").on(t.tenantId)]);
59
+ }, (t) => [index("space_tenant").on(t.tenantId), index("space_parent").on(t.parentId)]);
60
+ /**
61
+ * Who of the organization is in a client space (docs/plans/client-spaces.md): `client`, the
62
+ * client's own people, who see only the client spaces they are in; `member`, the firm's people
63
+ * assigned to it. The firm's members see every client space of their space all the same until a
64
+ * space turns "assigned only" on.
65
+ */
66
+ export const spaceMember = sqliteTable("space_member", {
67
+ id: text("id").primaryKey(),
68
+ tenantId: text("tenant_id").notNull(),
69
+ spaceId: text("space_id")
70
+ .notNull()
71
+ .references(() => space.id, { onDelete: "cascade" }),
72
+ /** Null while the person is invited and has not signed in yet. */
73
+ userId: text("user_id"),
74
+ /** The address an invitation went to: the person is found by it on their first sign-in. */
75
+ email: text("email"),
76
+ role: text("role", { enum: ["member", "client"] }).notNull(),
77
+ addedBy: text("added_by").notNull(),
78
+ createdAt: createdAt(),
79
+ }, (t) => [
80
+ uniqueIndex("space_member_key").on(t.spaceId, t.userId),
81
+ index("space_member_user").on(t.userId),
82
+ ]);
49
83
  export const wizard = sqliteTable("wizard", {
50
84
  id: text("id").primaryKey(),
51
85
  spaceId: text("space_id")
@@ -177,6 +211,19 @@ export const run = sqliteTable("run", {
177
211
  */
178
212
  deviceOffer: text("device_offer", { mode: "json" }).$type(),
179
213
  costMicros: integer("cost_micros").notNull().default(0),
214
+ /**
215
+ * The client space a run was started in (docs/plans/client-portal.md): the wizard is its
216
+ * parent's, the run's data and results belong to the client space. Null: a run of its
217
+ * wizard's space.
218
+ */
219
+ clientSpaceId: text("client_space_id").references(() => space.id, {
220
+ onDelete: "cascade",
221
+ }),
222
+ /**
223
+ * When the firm shared the run with the client space's clients, on purpose; null: it stays
224
+ * the firm's. A client's own runs need none.
225
+ */
226
+ clientSharedAt: integer("client_shared_at", { mode: "timestamp_ms" }),
180
227
  /** Set once the result is shared: `/s/<token>` shows it read-only. */
181
228
  shareToken: text("share_token"),
182
229
  sharedAt: integer("shared_at", { mode: "timestamp_ms" }),
@@ -190,6 +237,7 @@ export const run = sqliteTable("run", {
190
237
  index("run_wizard").on(t.wizardId, t.createdAt),
191
238
  index("run_visitor").on(t.visitorId, t.createdAt),
192
239
  index("run_status").on(t.status),
240
+ index("run_client_space").on(t.clientSpaceId, t.createdAt),
193
241
  ]);
194
242
  export const runEvent = sqliteTable("run_event", {
195
243
  id: integer("id").primaryKey({ autoIncrement: true }),
@@ -273,21 +321,31 @@ export const spaceConnector = sqliteTable("space_connector", {
273
321
  }, (t) => [primaryKey({ columns: [t.spaceId, t.id] })]);
274
322
  /**
275
323
  * What a space holds for all its wizards: logos, assets (images, graphics, videos) and
276
- * documents. `id` is the asset the content lives in. The first logo is the one end users see.
324
+ * documents. Its bytes are a blob, by `hash` (files/blobs.ts): the same bytes in Marke and in
325
+ * Wissen are stored once. The first logo is the one end users see.
277
326
  */
278
327
  export const spaceFile = sqliteTable("space_file", {
279
328
  id: text("id").primaryKey(),
280
329
  spaceId: text("space_id")
281
330
  .notNull()
282
331
  .references(() => space.id, { onDelete: "cascade" }),
283
- kind: text("kind", { enum: ["logo", "asset", "document", "pattern"] }).notNull(),
332
+ kind: text("kind", { enum: ["logo", "asset", "document", "pattern", "picture"] }).notNull(),
284
333
  name: text("name").notNull(),
285
334
  mime: text("mime").notNull(),
286
335
  size: integer("size").notNull(),
336
+ /** sha256 of its bytes. Null on a file from before 0.16 until `wizards move-files` moved it. */
337
+ hash: text("hash"),
287
338
  description: text("description").notNull().default(""),
288
339
  /** A web address the file was fetched from, when it was not uploaded. */
289
340
  source: text("source"),
290
341
  position: integer("position").notNull().default(0),
342
+ /**
343
+ * A document's folder in Knowledge: the page it sits in, null at the top. Its path
344
+ * (`files/<name>`) does not follow it. Its folder deleted, it goes to the top.
345
+ */
346
+ parentId: text("parent_id").references(() => spacePage.id, {
347
+ onDelete: "set null",
348
+ }),
291
349
  /** `pending` while it is read, described and indexed. */
292
350
  status: text("status", { enum: ["pending", "ready", "failed"] })
293
351
  .notNull()
@@ -308,6 +366,7 @@ export const spaceFile = sqliteTable("space_file", {
308
366
  }, (t) => [
309
367
  index("space_file_space").on(t.spaceId, t.kind, t.position),
310
368
  uniqueIndex("space_file_origin").on(t.spaceId, t.origin, t.originKey),
369
+ index("space_file_hash").on(t.hash),
311
370
  ]);
312
371
  /**
313
372
  * The index of Knowledge: one unit per section of a page, row of a table, file, summary of a
@@ -351,6 +410,11 @@ export const spaceChunk = sqliteTable("space_chunk", {
351
410
  embedding: blob("embedding", { mode: "buffer" }),
352
411
  /** The model the vector was made with; only vectors of one model are compared. */
353
412
  model: text("model"),
413
+ /**
414
+ * Null: the vector is of the text. `image`: of a picture file, `page`: of a picture of a PDF
415
+ * page (`sheet`); the text is what the words find them by.
416
+ */
417
+ kind: text("kind").$type(),
354
418
  }, (t) => [
355
419
  index("space_chunk_space").on(t.spaceId, t.model),
356
420
  index("space_chunk_file").on(t.fileId),
@@ -360,6 +424,156 @@ export const spaceChunk = sqliteTable("space_chunk", {
360
424
  index("space_chunk_table").on(t.tableId),
361
425
  index("space_chunk_value").on(t.valueId),
362
426
  ]);
427
+ export const spaceMount = sqliteTable("space_mount", {
428
+ id: text("id").primaryKey(),
429
+ tenantId: text("tenant_id").notNull(),
430
+ spaceId: text("space_id")
431
+ .notNull()
432
+ .references(() => space.id, { onDelete: "cascade" }),
433
+ name: text("name").notNull(),
434
+ /** Its name in a wizard's path (`dateien/<slug>/…`), unique in the space. */
435
+ slug: text("slug").notNull(),
436
+ /** Where it lives: `folder` on this computer, else a kind of the plugin (`s3`). */
437
+ kind: text("kind").notNull(),
438
+ /** The plugin that brings the kind; null for a folder of this computer. */
439
+ plugin: text("plugin"),
440
+ /** What the kind needs to reach it: a folder's `path`, or what the plugin's kind kept. */
441
+ source: text("source", { mode: "json" }).$type().notNull(),
442
+ /** Where it lives, in one line for the studio: a path, `s3://bucket/prefix/`. */
443
+ location: text("location"),
444
+ /** Where the source's changes go on from, as its reader said it last. */
445
+ cursor: text("cursor"),
446
+ /** `scanning` while it is listed and read, `away` while its source can't be reached. */
447
+ status: text("status", { enum: ["scanning", "ready", "away"] })
448
+ .notNull()
449
+ .default("scanning"),
450
+ error: text("error"),
451
+ /** When the whole tree was last listed against the rows. */
452
+ scannedAt: integer("scanned_at", { mode: "timestamp_ms" }),
453
+ /**
454
+ * Whether its files may be changed: drafts written back with „Veröffentlichen“. Off unless
455
+ * allowed when mounting or in its settings; who may then is the broker's `w` on the mount.
456
+ */
457
+ writable: integer("writable", { mode: "boolean" }).notNull().default(false),
458
+ /** A category whose value for a file is the folder of the first level it lies in. */
459
+ folderCategoryId: text("folder_category_id").references(() => spaceCategory.id, { onDelete: "set null" }),
460
+ createdBy: text("created_by"),
461
+ createdAt: createdAt(),
462
+ updatedAt: updatedAt(),
463
+ }, (t) => [uniqueIndex("space_mount_slug").on(t.spaceId, t.slug)]);
464
+ /**
465
+ * A file of a mount: where it is, its fingerprint (size and time, its hash), how far it is
466
+ * indexed. Its row stays when it moves or is renamed (found again by its hash), so its
467
+ * categories do.
468
+ */
469
+ export const spaceMountFile = sqliteTable("space_mount_file", {
470
+ id: text("id").primaryKey(),
471
+ mountId: text("mount_id")
472
+ .notNull()
473
+ .references(() => spaceMount.id, { onDelete: "cascade" }),
474
+ spaceId: text("space_id")
475
+ .notNull()
476
+ .references(() => space.id, { onDelete: "cascade" }),
477
+ /** Its path in the mount, with `/`: `Kunden/A1/angebot.pdf`. */
478
+ path: text("path").notNull(),
479
+ /** The source's own id of it, where it keeps one across a move (a drive's): the row follows it. */
480
+ sourceId: text("source_id"),
481
+ name: text("name").notNull(),
482
+ mime: text("mime").notNull(),
483
+ size: integer("size").notNull(),
484
+ /** The source's time of its last change, in milliseconds. */
485
+ modified: integer("modified").notNull(),
486
+ /** sha256 of its bytes, once read. */
487
+ hash: text("hash"),
488
+ /** `pending` until read; `ready` indexed; `skipped` kept out of the index (too large, no text). */
489
+ status: text("status", { enum: ["pending", "ready", "skipped", "failed"] })
490
+ .notNull()
491
+ .default("pending"),
492
+ error: text("error"),
493
+ pages: integer("pages"),
494
+ /** What its text calls itself: a front matter's `title:` or its first heading. */
495
+ title: text("title"),
496
+ /** Whether a thumbnail stands at `derived/m/<mount>/<id>.jpg`. */
497
+ thumb: integer("thumb", { mode: "boolean" }).notNull().default(false),
498
+ createdAt: createdAt(),
499
+ updatedAt: updatedAt(),
500
+ }, (t) => [
501
+ uniqueIndex("space_mount_file_path").on(t.mountId, t.path),
502
+ index("space_mount_file_hash").on(t.mountId, t.hash),
503
+ index("space_mount_file_source").on(t.mountId, t.sourceId),
504
+ index("space_mount_file_status").on(t.mountId, t.status),
505
+ ]);
506
+ /**
507
+ * A unit of a mounted file's index, without its text: where it stands in the file's text
508
+ * (`start`, `end`) or which page it shows, and its vector. Its words are in two contentless FTS5
509
+ * tables (`space_mount_unit_fts`, `space_mount_unit_tri`, rowid = id), written when the file is
510
+ * read; a snippet reads the original again.
511
+ */
512
+ export const spaceMountUnit = sqliteTable("space_mount_unit", {
513
+ id: integer("id").primaryKey({ autoIncrement: true }),
514
+ spaceId: text("space_id")
515
+ .notNull()
516
+ .references(() => space.id, { onDelete: "cascade" }),
517
+ mountId: text("mount_id")
518
+ .notNull()
519
+ .references(() => spaceMount.id, { onDelete: "cascade" }),
520
+ fileId: text("file_id")
521
+ .notNull()
522
+ .references(() => spaceMountFile.id, { onDelete: "cascade" }),
523
+ idx: integer("idx").notNull(),
524
+ /** The section's headings, joined by " › ". */
525
+ heading: text("heading"),
526
+ /** The page of the original it starts on, or the page a `page` unit shows. */
527
+ sheet: integer("sheet"),
528
+ /** Where its passage stands in the file's text, in characters; null for a picture. */
529
+ start: integer("start"),
530
+ end: integer("end"),
531
+ embedding: blob("embedding", { mode: "buffer" }),
532
+ model: text("model"),
533
+ /** Null: the vector is of the text. `image`: of the picture file, `page`: of a PDF page. */
534
+ kind: text("kind").$type(),
535
+ }, (t) => [
536
+ index("space_mount_unit_file").on(t.fileId),
537
+ index("space_mount_unit_space").on(t.spaceId, t.model),
538
+ ]);
539
+ /**
540
+ * A draft of a mounted file: an edit kept in engenty until „Veröffentlichen“ writes it to the
541
+ * source. `base` is the file as it was read when the edit began; the source changed since, the
542
+ * write is refused and `conflict` holds what stands there now. A text file's draft keeps its
543
+ * text and the text it was read as (for the merge); a replaced file keeps its bytes by hash.
544
+ */
545
+ export const spaceMountDraft = sqliteTable("space_mount_draft", {
546
+ id: text("id").primaryKey(),
547
+ spaceId: text("space_id")
548
+ .notNull()
549
+ .references(() => space.id, { onDelete: "cascade" }),
550
+ mountId: text("mount_id")
551
+ .notNull()
552
+ .references(() => spaceMount.id, { onDelete: "cascade" }),
553
+ fileId: text("file_id")
554
+ .notNull()
555
+ .references(() => spaceMountFile.id, { onDelete: "cascade" }),
556
+ /** The file as it was read: its entry at the source and the sha256 of its bytes. */
557
+ base: text("base", { mode: "json" })
558
+ .$type()
559
+ .notNull(),
560
+ /** The draft's text, for a text file. */
561
+ text: text("text"),
562
+ /** The text the file had when it was read, for the merge with a change at the source. */
563
+ baseText: text("base_text"),
564
+ /** The draft's bytes by hash (blobs/), for a file replaced by an upload. */
565
+ blob: text("blob"),
566
+ mime: text("mime"),
567
+ /** What stands at the source now, where it changed since `base`; its text for a text file. */
568
+ conflict: text("conflict", { mode: "json" }).$type(),
569
+ createdBy: text("created_by"),
570
+ updatedBy: text("updated_by"),
571
+ createdAt: createdAt(),
572
+ updatedAt: updatedAt(),
573
+ }, (t) => [
574
+ uniqueIndex("space_mount_draft_file").on(t.fileId),
575
+ index("space_mount_draft_mount").on(t.mountId),
576
+ ]);
363
577
  // --- The space's data -------------------------------------------------------
364
578
  // Tables and pages a space keeps, its own or one of its wizards'. Shared by everyone who works
365
579
  // in the space, unlike the wizard's store below, which belongs to one person.
@@ -382,6 +596,15 @@ export const spaceTable = sqliteTable("space_table", {
382
596
  title: text("title").notNull(),
383
597
  /** Its name in a path (`tables/<slug>`), unique among the space's tables. */
384
598
  slug: text("slug"),
599
+ /**
600
+ * Its folder in Knowledge: the page it sits in, null at the top. Its path does not follow it.
601
+ * Its folder deleted, it goes to the top.
602
+ */
603
+ parentId: text("parent_id").references(() => spacePage.id, {
604
+ onDelete: "set null",
605
+ }),
606
+ /** Its place among its folder's contents, pages and files among them. */
607
+ position: integer("position").notNull().default(0),
385
608
  /** `faq`: a question and its answer per row. */
386
609
  format: text("format", { enum: ["faq"] }),
387
610
  columns: text("columns", { mode: "json" }).$type().notNull(),
@@ -402,7 +625,7 @@ export const spaceTable = sqliteTable("space_table", {
402
625
  updatedAt: updatedAt(),
403
626
  }, (t) => [
404
627
  index("space_table_space").on(t.spaceId, t.wizardId),
405
- uniqueIndex("space_table_list").on(t.wizardId, t.list),
628
+ uniqueIndex("space_table_list").on(t.spaceId, t.wizardId, t.list),
406
629
  uniqueIndex("space_table_origin").on(t.spaceId, t.origin, t.originKey),
407
630
  ]);
408
631
  /** A row of a table: cells by column id. Rows stand in the order they were added. */
@@ -460,6 +683,67 @@ export const spacePage = sqliteTable("space_page", {
460
683
  index("space_page_parent").on(t.parentId, t.position),
461
684
  uniqueIndex("space_page_origin").on(t.spaceId, t.origin, t.originKey),
462
685
  ]);
686
+ export const spaceSource = sqliteTable("space_source", {
687
+ id: text("id").primaryKey(),
688
+ tenantId: text("tenant_id").notNull(),
689
+ spaceId: text("space_id")
690
+ .notNull()
691
+ .references(() => space.id, { onDelete: "cascade" }),
692
+ /** The kind a plugin registered: `website`, `sitemap`, `urls`. */
693
+ kind: text("kind").notNull(),
694
+ /** The plugin that brings the kind; its reader reads the source. */
695
+ plugin: text("plugin").notNull(),
696
+ address: text("address").notNull(),
697
+ label: text("label").notNull(),
698
+ state: text("state", { enum: ["proposed", "taken"] }).notNull(),
699
+ rules: text("rules", { mode: "json" }).$type().notNull(),
700
+ categories: text("categories", { mode: "json" }).$type().notNull(),
701
+ /** Read again every so many hours; null: only when asked. */
702
+ everyHours: integer("every_hours"),
703
+ /** What a signal address of the kind names the source by. */
704
+ token: text("token").notNull(),
705
+ status: text("status", { enum: ["idle", "running", "failed"] }).notNull(),
706
+ error: text("error"),
707
+ lastRunAt: integer("last_run_at", { mode: "timestamp_ms" }),
708
+ createdAt: createdAt(),
709
+ updatedAt: updatedAt(),
710
+ }, (t) => [index("space_source_space").on(t.spaceId), uniqueIndex("space_source_token").on(t.token)]);
711
+ /** One entry a source holds: an address, whether it is in, and what it became. */
712
+ export const spaceSourceEntry = sqliteTable("space_source_entry", {
713
+ id: text("id").primaryKey(),
714
+ sourceId: text("source_id")
715
+ .notNull()
716
+ .references(() => spaceSource.id, { onDelete: "cascade" }),
717
+ address: text("address").notNull(),
718
+ title: text("title"),
719
+ /** Where it stands below the source's folder: the folders' names, outermost first. */
720
+ path: text("path", { mode: "json" }).$type().notNull(),
721
+ included: integer("included", { mode: "boolean" }).notNull(),
722
+ reason: text("reason"),
723
+ decidedBy: text("decided_by", { enum: ["rule", "model", "person"] }),
724
+ status: text("status", { enum: ["new", "done", "check", "failed", "kept"] }).notNull(),
725
+ /** The key it was written under: `e:<id>`, or `dir:<path>` for the text of a folder. */
726
+ itemKey: text("item_key"),
727
+ result: text("result", { mode: "json" }).$type(),
728
+ note: text("note"),
729
+ fingerprint: text("fingerprint"),
730
+ updatedAt: updatedAt(),
731
+ }, (t) => [uniqueIndex("space_source_entry_address").on(t.sourceId, t.address)]);
732
+ /** A run of a source: what it wrote, kept unchanged, failed on and left out, and its log. */
733
+ export const spaceSourceRun = sqliteTable("space_source_run", {
734
+ id: text("id").primaryKey(),
735
+ sourceId: text("source_id")
736
+ .notNull()
737
+ .references(() => spaceSource.id, { onDelete: "cascade" }),
738
+ startedAt: integer("started_at", { mode: "timestamp_ms" }).notNull(),
739
+ endedAt: integer("ended_at", { mode: "timestamp_ms" }),
740
+ status: text("status", { enum: ["running", "done", "failed", "stopped"] }).notNull(),
741
+ written: integer("written").notNull(),
742
+ unchanged: integer("unchanged").notNull(),
743
+ failed: integer("failed").notNull(),
744
+ leftOut: integer("left_out").notNull(),
745
+ log: text("log", { mode: "json" }).$type().notNull(),
746
+ }, (t) => [index("space_source_run_source").on(t.sourceId, t.startedAt)]);
463
747
  // --- Categories -----------------------------------------------------------------
464
748
  // Typed properties that run across Knowledge: set on pages, rows, tables and files, any number of
465
749
  // each, so a step filters before it searches.
@@ -505,7 +789,7 @@ export const spaceCategoryValue = sqliteTable("space_category_value", {
505
789
  createdAt: createdAt(),
506
790
  }, (t) => [uniqueIndex("space_category_value_value").on(t.categoryId, t.value)]);
507
791
  /**
508
- * A category set on an item: exactly one of page, row, table and file. A choice points to its
792
+ * A category set on an item: exactly one of page, row, table, file and mounted file. A choice points to its
509
793
  * value; the other types keep theirs typed: a date as milliseconds, a number, a short text, yes
510
794
  * or no. A choice with several values has a row per value.
511
795
  */
@@ -521,6 +805,10 @@ export const spaceItemCategory = sqliteTable("space_item_category", {
521
805
  rowId: text("row_id").references(() => spaceTableRow.id, { onDelete: "cascade" }),
522
806
  tableId: text("table_id").references(() => spaceTable.id, { onDelete: "cascade" }),
523
807
  fileId: text("file_id").references(() => spaceFile.id, { onDelete: "cascade" }),
808
+ /** A file of a mount in Dateien: the space's categories hold for those too. */
809
+ mountFileId: text("mount_file_id").references(() => spaceMountFile.id, {
810
+ onDelete: "cascade",
811
+ }),
524
812
  valueId: text("value_id").references(() => spaceCategoryValue.id, { onDelete: "cascade" }),
525
813
  text: text("text"),
526
814
  num: real("num"),
@@ -536,6 +824,7 @@ export const spaceItemCategory = sqliteTable("space_item_category", {
536
824
  index("space_item_category_row").on(t.rowId),
537
825
  index("space_item_category_table").on(t.tableId),
538
826
  index("space_item_category_file").on(t.fileId),
827
+ index("space_item_category_mount_file").on(t.mountFileId),
539
828
  ]);
540
829
  // --- Skills -------------------------------------------------------------------------
541
830
  // Instructions in the Agent Skills format the space's wizards follow (docs/plans/skills.md):
@@ -13,6 +13,7 @@ and change with notice. Everything else is the studio’s own and changes withou
13
13
  |---|---|---|
14
14
  | `/api/v1/…` | programs that build and publish wizards: the spaces of a local install, importing a wizard | an access token of the account, with scopes (`wizards:read`, `wizards:write`, `wizards:publish`, `runs:test`); see [the Manage-App contract](https://github.com/engenty/engenty-wizards/blob/main/docs/manage-contract.md) |
15
15
  | `/api/v1/spaces/:spaceId/elements` | programs that use a space: search its knowledge, read its skills, call its connections, run its wizards (see below) | the same tokens, with `data:read`, `elements:read`, `elements:run` |
16
+ | `/api/v1/client/…` | apps for a firm’s clients, like the client portal: their client spaces, what waits for them, chats, files, results, the wizards opened to them (see below) | a token of a person with the role `client`, with `data:read`, `elements:read`, `elements:run` |
16
17
  | `/api/mcp` | AI apps: every tool of [the MCP server](../user-guide/ai-apps.md), the space’s elements among them | the same tokens, or the local ticket `wizards mcp` carries |
17
18
  | The public run API: `/api/public/wizards/:token`, `/api/public/wizards/:token/runs`, `/api/public/codes/:code`, `/api/runs/:id/…` | running a published wizard by its link: what the runner in a browser does | nobody; a visitor cookie, or the `x-wizards-visitor` header where a cookie does not survive |
18
19
 
@@ -37,6 +38,30 @@ name (`x-wizards-client`, or the MCP client’s). A space outside the token’s
37
38
  refused. A write, a send or a delete on a connection runs only where the space allows it without a
38
39
  person’s yes.
39
40
 
41
+ ## A client’s client spaces
42
+
43
+ A firm works for its clients in client spaces under its space. A client of the organization signs
44
+ in with an account of their own and reaches only the client spaces they are in. The client
45
+ portal (`<team>.wizards.page/portal`) is built on these calls alone, so another app can offer the
46
+ same. `GET /api/v1/client` lists them with their inputs as JSON Schema. A call is
47
+ `POST /api/v1/client/:name`, or `POST /api/v1/client/spaces/:spaceId/:name` for one client space,
48
+ with `{ "input": { … } }`; it answers `{ "result": … }`, or an error with why.
49
+
50
+ | Call | Scope | Gives |
51
+ |---|---|---|
52
+ | `me`, `spaces` | `data:read` | Who you are, your organization, your client spaces with their address (`slug`) and the firm’s brand |
53
+ | `for_you` | `data:read` | Your runs waiting on a page or an answer, the results the firm shared, the wizards you can start |
54
+ | `wizards`, `wizard_start` | `elements:read`, `elements:run` | The firm’s wizards opened to clients, each with its engenty (`avatar`) and its number of steps; a start runs it in your client space |
55
+ | `results`, `run_open` | `data:read` | Your finished runs and those the firm shared; a ticket for one run’s own routes (`/api/runs/:id/…?rt=…`) |
56
+ | `chats`, `chat_messages` | `data:read` | Your chats in the client space and their messages: each message’s `parts` in the order they were written, its text and the views and runs of the firm’s AI as cards |
57
+ | `chat_post` | `elements:run` | Writes in one of your chats, or starts one. The firm’s AI answers every message as you, with the client space’s Knowledge, the wizards opened to you and views; the firm’s people read the chat too |
58
+ | `files` | `data:read` | The client space’s files. One file’s bytes: `GET /api/v1/client/spaces/:spaceId/files/:fileId` |
59
+
60
+ Only a person with the role `client` gets an answer (`403 clients_only` otherwise). A space that is
61
+ not one of yours answers `404`. The firm’s Knowledge and wizards reach you only where the firm
62
+ opened them to clients, and a run the firm makes in your client space only once it is shared with
63
+ you. The calls need the organization’s `clientSpaces` switch.
64
+
40
65
  ## Private
41
66
 
42
67
  `/api/studio/…`, `/api/auth/…` and `/api/internal/…` belong to the studio, the sign-in and the
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  title: Accounts
3
3
  description: Accounts a plugin connects for a space, such as a calendar or a mailbox, through the runtime's built-in connectors.
4
- version: 0.13.0
4
+ version: 0.15.0
5
5
  ---
6
6
 
7
7
  A wizard’s connections belong to the person who runs it. A plugin that works for the whole
@@ -30,10 +30,12 @@ const { events } = await server.connections.call<{ events: unknown[] }>(account.
30
30
  | `server.connections.` | Does |
31
31
  |---|---|
32
32
  | `available(ids)` | Returns the connectors of these ids that a person can connect here now: `{ id, name, auth }`, and for `auth: "api_key"` the `fields` to ask for (`key`, `label`, `placeholder`, `required`, `secret`). An OAuth connector is offered once its client is set up (`GOOGLE_OAUTH_CLIENT_ID` …) or when it registers a client itself. On a local install Google is also offered through the linked engenty account. A connector that takes keys (HubSpot, S3) is always offered |
33
- | `start({ space, connector, actions, lang? })` | Returns the provider’s sign-in page of an OAuth connector. The provider asks only for the rights that `actions` need. `lang` (`"en"` or `"de"`) is the language of the page the person comes back to; without it, the page follows their browser |
33
+ | `start({ space, connector, actions, scopes?, lang? })` | Returns the provider’s sign-in page of an OAuth connector. The provider asks only for the rights that `actions` need, and for `scopes`, rights at the provider for `request` (Drive’s `https://www.googleapis.com/auth/drive` to write, Microsoft’s `Files.Read.All` for SharePoint). `lang` (`"en"` or `"de"`) is the language of the page the person comes back to; without it, the page follows their browser |
34
34
  | `connect({ space, connector, actions, credentials })` | Connects a connector that takes keys. `credentials` holds the keys by field key. The runtime tries them once at the provider and then keeps them sealed. Keys the provider refuses throw an error with the status `400` and the code `credentials`, whose message says what was wrong. Returns the connection |
35
35
  | `list(space)`, `get(id)` | Return what is connected: `{ id, space, connector, label, actions, createdAt }`, the newest first. `label` is the account as the provider names it, often an email address |
36
36
  | `call(id, action, input)` | Runs one of the connector’s actions with the account, through the runtime’s broker. When the token has run out, the runtime fetches a fresh one first. The call carries the run or chat it is made in, and the connection’s rules decide: who may use it, and per kind of action whether it runs, waits for the space’s admins or never runs. From a guest’s run (a wizard at its link, nobody signed in) only actions that read go through; a write or delete throws, and the refusal is logged. A plugin’s own job (a sync, a timer) runs every action the connection was made for |
37
+ | `request(id, { url, method?, headers?, body?, kind?, signal? })` | Sends a request of the plugin’s own to the connector’s service as the account, for what no action does (a drive’s changes, a file’s bytes). See [Requests of the plugin’s own](#requests-of-the-plugins-own) |
38
+ | `scopes(id)` | The rights the provider granted the connection, as it answered the sign-in |
37
39
  | `remove(id)` | Forgets the connection and its tokens |
38
40
 
39
41
  ## Signing in
@@ -67,6 +69,32 @@ window.addEventListener("message", (event) => {
67
69
  words of its answer. If the person removed the connection at the provider, the next call
68
70
  fails this way.
69
71
 
72
+ ## Requests of the plugin’s own
73
+
74
+ A connector’s actions are made for wizards: a search, a file’s text cut at 50 KB. Where a plugin
75
+ needs the service itself, such as a mount of [Dateien](./space.md#a-kind-of-mount) reading a drive’s
76
+ changes and a file’s bytes, `request` sends its own request as the account:
77
+
78
+ ```ts
79
+ const res = await server.connections.request(account.id, {
80
+ url: `https://www.googleapis.com/drive/v3/files/${id}?alt=media`,
81
+ });
82
+ const bytes = new Uint8Array(await res.arrayBuffer());
83
+ ```
84
+
85
+ - Only connectors that take requests do: Google Drive (`https://www.googleapis.com`), OneDrive
86
+ and SharePoint (`https://graph.microsoft.com`), S3 (the endpoint its keys name). A request to
87
+ another address throws.
88
+ - The runtime signs it: a bearer token for a sign-in, renewed where it ran out; a bucket’s keys
89
+ sign it as S3 does (Signature V4).
90
+ - It goes through the broker as `request`, with `kind` (`read` by default, `write`,
91
+ `destructive`) for the connection’s rules and its log. A plugin’s own job runs it.
92
+ - The answer comes back as it is, whatever its status. A `401` is heard as a sign-in that ran
93
+ out.
94
+ - In the cloud it reaches the public internet only. On a local install it reaches the local
95
+ network too, where a person’s own bucket is (a NAS, a MinIO); `connect` checks keys there as
96
+ well. A wizard’s connections stay on the public internet everywhere.
97
+
70
98
  ## Where it is kept
71
99
 
72
100
  A connection a plugin makes is a connection of the space (the table `space_connection` of the
@@ -28,7 +28,7 @@ loads them from their files and loads a plugin again when its files change.
28
28
  | A page of the studio | Behind an icon in the app bar, or at its address | [The studio half](./studio.md) |
29
29
  | A section of the settings | In the settings’ list | [The studio half](./studio.md) |
30
30
  | A section of the space page | In one of its parts, below the part’s own sections | [The studio half](./studio.md#the-space) |
31
- | A part of the space page | In the space’s menu, beside Info, Brand, Knowledge, Data and Results | [The studio half](./studio.md#a-part-of-the-plugins-own) |
31
+ | A part of the space page | In the space’s menu, beside Info, Brand, Knowledge, Memory and Results | [The studio half](./studio.md#a-part-of-the-plugins-own) |
32
32
 
33
33
  ## Two halves
34
34