@engenty/wizards-runtime 0.0.0-stage → 0.7.5

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 (518) hide show
  1. package/LICENSE +110 -0
  2. package/README.md +214 -2
  3. package/apps/runtime/dist/agents/architect.js +444 -0
  4. package/apps/runtime/dist/agents/studio-assistant.js +883 -0
  5. package/apps/runtime/dist/agents/subscription.js +207 -0
  6. package/apps/runtime/dist/agents/thought.js +21 -0
  7. package/apps/runtime/dist/agents/website.js +480 -0
  8. package/apps/runtime/dist/app.js +359 -0
  9. package/apps/runtime/dist/apple/wizards-apple +0 -0
  10. package/apps/runtime/dist/assistant/browser.js +26 -0
  11. package/apps/runtime/dist/assistant/docs.js +158 -0
  12. package/apps/runtime/dist/assistant/knows.js +353 -0
  13. package/apps/runtime/dist/assistant/primer.js +26 -0
  14. package/apps/runtime/dist/assistant/runs.js +24 -0
  15. package/apps/runtime/dist/auth/account.js +175 -0
  16. package/apps/runtime/dist/auth/device.js +112 -0
  17. package/apps/runtime/dist/auth/index.js +358 -0
  18. package/apps/runtime/dist/auth/keys.js +55 -0
  19. package/apps/runtime/dist/auth/local-ticket.js +26 -0
  20. package/apps/runtime/dist/authoring/example.js +74 -0
  21. package/apps/runtime/dist/authoring/guide.js +433 -0
  22. package/apps/runtime/dist/authoring/ops.js +117 -0
  23. package/apps/runtime/dist/browser/fast/action-space.js +160 -0
  24. package/apps/runtime/dist/browser/fast/classifier.js +91 -0
  25. package/apps/runtime/dist/browser/fast/decide.js +171 -0
  26. package/apps/runtime/dist/browser/fast/driver.js +141 -0
  27. package/apps/runtime/dist/browser/fast/instructions.js +33 -0
  28. package/apps/runtime/dist/browser/fast/run.js +249 -0
  29. package/apps/runtime/dist/browser/fast/span-picker.js +153 -0
  30. package/apps/runtime/dist/browser/fast/text-helper.js +178 -0
  31. package/apps/runtime/dist/browser/snapshot.js +335 -0
  32. package/apps/runtime/dist/cli/account.js +385 -0
  33. package/apps/runtime/dist/cli/autostart.js +182 -0
  34. package/apps/runtime/dist/cli/autoupdate.js +221 -0
  35. package/apps/runtime/dist/cli/clients.js +44 -0
  36. package/apps/runtime/dist/cli/connect.js +540 -0
  37. package/apps/runtime/dist/cli/environment.js +93 -0
  38. package/apps/runtime/dist/cli/exec.js +45 -0
  39. package/apps/runtime/dist/cli/features.js +50 -0
  40. package/apps/runtime/dist/cli/home.js +88 -0
  41. package/apps/runtime/dist/cli/install-env.js +33 -0
  42. package/apps/runtime/dist/cli/machine.js +107 -0
  43. package/apps/runtime/dist/cli/main.js +222 -0
  44. package/apps/runtime/dist/cli/mcp.js +136 -0
  45. package/apps/runtime/dist/cli/menu.js +202 -0
  46. package/apps/runtime/dist/cli/processes.js +72 -0
  47. package/apps/runtime/dist/cli/report.js +66 -0
  48. package/apps/runtime/dist/cli/setup.js +335 -0
  49. package/apps/runtime/dist/cli/start.js +276 -0
  50. package/apps/runtime/dist/cli/status.js +203 -0
  51. package/apps/runtime/dist/cli/ui.js +59 -0
  52. package/apps/runtime/dist/cli/uninstall-main.js +20 -0
  53. package/apps/runtime/dist/cli/uninstall.js +231 -0
  54. package/apps/runtime/dist/cli/update.js +86 -0
  55. package/apps/runtime/dist/cli/validate.js +75 -0
  56. package/apps/runtime/dist/cli/versions.js +123 -0
  57. package/apps/runtime/dist/connectors/builtin.js +86 -0
  58. package/apps/runtime/dist/connectors/external.js +409 -0
  59. package/apps/runtime/dist/connectors/gmail.js +107 -0
  60. package/apps/runtime/dist/connectors/imap.js +261 -0
  61. package/apps/runtime/dist/connectors/index.js +325 -0
  62. package/apps/runtime/dist/connectors/mail.js +72 -0
  63. package/apps/runtime/dist/connectors/outlook.js +90 -0
  64. package/apps/runtime/dist/connectors/plugin-connections.js +343 -0
  65. package/apps/runtime/dist/connectors/via-account.js +65 -0
  66. package/apps/runtime/dist/credits/credits.js +100 -0
  67. package/apps/runtime/dist/credits/estimate.js +152 -0
  68. package/apps/runtime/dist/db/adopt.js +149 -0
  69. package/apps/runtime/dist/db/client.js +173 -0
  70. package/apps/runtime/dist/db/control-schema.js +133 -0
  71. package/apps/runtime/dist/db/migrations/control/0000_last_absorbing_man.sql +47 -0
  72. package/apps/runtime/dist/db/migrations/control/0001_gorgeous_nicolaos.sql +41 -0
  73. package/apps/runtime/dist/db/migrations/control/0002_secret_penance.sql +1 -0
  74. package/apps/runtime/dist/db/migrations/control/0003_nasty_mordo.sql +3 -0
  75. package/apps/runtime/dist/db/migrations/control/0004_breezy_eddie_brock.sql +6 -0
  76. package/apps/runtime/dist/db/migrations/control/0005_chilly_oracle.sql +1 -0
  77. package/apps/runtime/dist/db/migrations/control/0006_sleepy_mojo.sql +1 -0
  78. package/apps/runtime/dist/db/migrations/control/0007_common_the_hand.sql +15 -0
  79. package/apps/runtime/dist/db/migrations/control/0008_runner.sql +8 -0
  80. package/apps/runtime/dist/db/migrations/control/0009_plugin_claim.sql +9 -0
  81. package/apps/runtime/dist/db/migrations/control/0010_tan_snowbird.sql +6 -0
  82. package/apps/runtime/dist/db/migrations/control/meta/0000_snapshot.json +311 -0
  83. package/apps/runtime/dist/db/migrations/control/meta/0001_snapshot.json +599 -0
  84. package/apps/runtime/dist/db/migrations/control/meta/0002_snapshot.json +607 -0
  85. package/apps/runtime/dist/db/migrations/control/meta/0003_snapshot.json +311 -0
  86. package/apps/runtime/dist/db/migrations/control/meta/0004_snapshot.json +350 -0
  87. package/apps/runtime/dist/db/migrations/control/meta/0005_snapshot.json +358 -0
  88. package/apps/runtime/dist/db/migrations/control/meta/0006_snapshot.json +365 -0
  89. package/apps/runtime/dist/db/migrations/control/meta/0007_snapshot.json +460 -0
  90. package/apps/runtime/dist/db/migrations/control/meta/0008_snapshot.json +505 -0
  91. package/apps/runtime/dist/db/migrations/control/meta/0009_snapshot.json +561 -0
  92. package/apps/runtime/dist/db/migrations/control/meta/0010_snapshot.json +600 -0
  93. package/apps/runtime/dist/db/migrations/control/meta/_journal.json +83 -0
  94. package/apps/runtime/dist/db/migrations/tenant/0000_eminent_freak.sql +188 -0
  95. package/apps/runtime/dist/db/migrations/tenant/0001_salty_master_chief.sql +1 -0
  96. package/apps/runtime/dist/db/migrations/tenant/0002_cloudy_firebird.sql +1 -0
  97. package/apps/runtime/dist/db/migrations/tenant/0003_brown_warbound.sql +52 -0
  98. package/apps/runtime/dist/db/migrations/tenant/0004_romantic_nocturne.sql +6 -0
  99. package/apps/runtime/dist/db/migrations/tenant/0005_reflective_forgotten_one.sql +2 -0
  100. package/apps/runtime/dist/db/migrations/tenant/0006_hard_war_machine.sql +30 -0
  101. package/apps/runtime/dist/db/migrations/tenant/0007_space_data.sql +43 -0
  102. package/apps/runtime/dist/db/migrations/tenant/0008_run_event_note.sql +1 -0
  103. package/apps/runtime/dist/db/migrations/tenant/0009_knowledge.sql +104 -0
  104. package/apps/runtime/dist/db/migrations/tenant/0010_plugin_connection.sql +15 -0
  105. package/apps/runtime/dist/db/migrations/tenant/0011_runners.sql +2 -0
  106. package/apps/runtime/dist/db/migrations/tenant/0012_assistant_chat.sql +40 -0
  107. package/apps/runtime/dist/db/migrations/tenant/0013_run_origin.sql +1 -0
  108. package/apps/runtime/dist/db/migrations/tenant/0014_run_answer.sql +2 -0
  109. package/apps/runtime/dist/db/migrations/tenant/0015_device_calls.sql +13 -0
  110. package/apps/runtime/dist/db/migrations/tenant/0016_even_trish_tilby.sql +12 -0
  111. package/apps/runtime/dist/db/migrations/tenant/meta/0000_snapshot.json +1323 -0
  112. package/apps/runtime/dist/db/migrations/tenant/meta/0001_snapshot.json +1330 -0
  113. package/apps/runtime/dist/db/migrations/tenant/meta/0002_snapshot.json +1337 -0
  114. package/apps/runtime/dist/db/migrations/tenant/meta/0003_snapshot.json +1605 -0
  115. package/apps/runtime/dist/db/migrations/tenant/meta/0004_snapshot.json +1645 -0
  116. package/apps/runtime/dist/db/migrations/tenant/meta/0005_snapshot.json +1659 -0
  117. package/apps/runtime/dist/db/migrations/tenant/meta/0006_snapshot.json +1696 -0
  118. package/apps/runtime/dist/db/migrations/tenant/meta/0007_snapshot.json +2012 -0
  119. package/apps/runtime/dist/db/migrations/tenant/meta/0008_snapshot.json +2019 -0
  120. package/apps/runtime/dist/db/migrations/tenant/meta/0009_snapshot.json +2837 -0
  121. package/apps/runtime/dist/db/migrations/tenant/meta/0010_snapshot.json +2942 -0
  122. package/apps/runtime/dist/db/migrations/tenant/meta/0011_snapshot.json +2956 -0
  123. package/apps/runtime/dist/db/migrations/tenant/meta/0012_snapshot.json +3132 -0
  124. package/apps/runtime/dist/db/migrations/tenant/meta/0013_snapshot.json +3139 -0
  125. package/apps/runtime/dist/db/migrations/tenant/meta/0014_snapshot.json +3154 -0
  126. package/apps/runtime/dist/db/migrations/tenant/meta/0015_snapshot.json +3243 -0
  127. package/apps/runtime/dist/db/migrations/tenant/meta/0016_snapshot.json +3326 -0
  128. package/apps/runtime/dist/db/migrations/tenant/meta/_journal.json +125 -0
  129. package/apps/runtime/dist/db/schema.js +602 -0
  130. package/apps/runtime/dist/debug.js +196 -0
  131. package/apps/runtime/dist/docs/dev/index.md +41 -0
  132. package/apps/runtime/dist/docs/dev/meta.json +7 -0
  133. package/apps/runtime/dist/docs/dev/plugins/connections.md +74 -0
  134. package/apps/runtime/dist/docs/dev/plugins/events.md +89 -0
  135. package/apps/runtime/dist/docs/dev/plugins/examples.md +101 -0
  136. package/apps/runtime/dist/docs/dev/plugins/index.md +78 -0
  137. package/apps/runtime/dist/docs/dev/plugins/layout.md +90 -0
  138. package/apps/runtime/dist/docs/dev/plugins/meta.json +28 -0
  139. package/apps/runtime/dist/docs/dev/plugins/quick-start.md +94 -0
  140. package/apps/runtime/dist/docs/dev/plugins/reference.md +348 -0
  141. package/apps/runtime/dist/docs/dev/plugins/reloading.md +76 -0
  142. package/apps/runtime/dist/docs/dev/plugins/routes.md +185 -0
  143. package/apps/runtime/dist/docs/dev/plugins/runners.md +230 -0
  144. package/apps/runtime/dist/docs/dev/plugins/server.md +281 -0
  145. package/apps/runtime/dist/docs/dev/plugins/shipping.md +79 -0
  146. package/apps/runtime/dist/docs/dev/plugins/space.md +297 -0
  147. package/apps/runtime/dist/docs/dev/plugins/starters.md +70 -0
  148. package/apps/runtime/dist/docs/dev/plugins/studio.md +363 -0
  149. package/apps/runtime/dist/docs/dev/plugins/styling.md +129 -0
  150. package/apps/runtime/dist/docs/dev/plugins/tables.md +104 -0
  151. package/apps/runtime/dist/docs/dev/plugins/tools.md +139 -0
  152. package/apps/runtime/dist/docs/dev/wizard-format.md +125 -0
  153. package/apps/runtime/dist/docs/meta.json +3 -0
  154. package/apps/runtime/dist/docs/user/ai-apps.md +112 -0
  155. package/apps/runtime/dist/docs/user/assistant.md +77 -0
  156. package/apps/runtime/dist/docs/user/build-a-wizard.md +116 -0
  157. package/apps/runtime/dist/docs/user/command-line.md +83 -0
  158. package/apps/runtime/dist/docs/user/connectors.md +90 -0
  159. package/apps/runtime/dist/docs/user/create-account.md +52 -0
  160. package/apps/runtime/dist/docs/user/data.md +66 -0
  161. package/apps/runtime/dist/docs/user/first-start.md +60 -0
  162. package/apps/runtime/dist/docs/user/index.md +49 -0
  163. package/apps/runtime/dist/docs/user/install.md +123 -0
  164. package/apps/runtime/dist/docs/user/local-only.md +42 -0
  165. package/apps/runtime/dist/docs/user/meta.json +32 -0
  166. package/apps/runtime/dist/docs/user/models.md +156 -0
  167. package/apps/runtime/dist/docs/user/plugins.md +71 -0
  168. package/apps/runtime/dist/docs/user/run.md +98 -0
  169. package/apps/runtime/dist/docs/user/server.md +52 -0
  170. package/apps/runtime/dist/docs/user/space.md +126 -0
  171. package/apps/runtime/dist/docs/user/steps.md +220 -0
  172. package/apps/runtime/dist/docs/user/test-and-share.md +224 -0
  173. package/apps/runtime/dist/docs/user/troubleshooting.md +67 -0
  174. package/apps/runtime/dist/docs/user/wordpress.md +121 -0
  175. package/apps/runtime/dist/documents/parse.js +246 -0
  176. package/apps/runtime/dist/engenty/connections-external/build-connector.js +193 -0
  177. package/apps/runtime/dist/engenty/connections-external/errors.js +11 -0
  178. package/apps/runtime/dist/engenty/connections-external/import-service.js +270 -0
  179. package/apps/runtime/dist/engenty/connections-external/importer/classify.js +34 -0
  180. package/apps/runtime/dist/engenty/connections-external/importer/map-auth.js +185 -0
  181. package/apps/runtime/dist/engenty/connections-external/importer/normalize-mcp.js +63 -0
  182. package/apps/runtime/dist/engenty/connections-external/importer/normalize-openapi.js +130 -0
  183. package/apps/runtime/dist/engenty/connections-external/invoke/http-invoker.js +143 -0
  184. package/apps/runtime/dist/engenty/connections-external/invoke/mcp-client.js +143 -0
  185. package/apps/runtime/dist/engenty/connections-external/net/guarded-fetch.js +119 -0
  186. package/apps/runtime/dist/engenty/connections-external/oauth-dcr.js +88 -0
  187. package/apps/runtime/dist/engenty/connections-external/registry-client.js +336 -0
  188. package/apps/runtime/dist/engenty/connections-external/registry-source.js +82 -0
  189. package/apps/runtime/dist/engenty/connections-external/types.js +7 -0
  190. package/apps/runtime/dist/engenty/connections-github/connector.js +209 -0
  191. package/apps/runtime/dist/engenty/connections-google/connectors/calendar.js +381 -0
  192. package/apps/runtime/dist/engenty/connections-google/connectors/contacts.js +94 -0
  193. package/apps/runtime/dist/engenty/connections-google/connectors/drive.js +290 -0
  194. package/apps/runtime/dist/engenty/connections-google/connectors/gmail.js +567 -0
  195. package/apps/runtime/dist/engenty/connections-google/definitions.js +11 -0
  196. package/apps/runtime/dist/engenty/connections-google/shared.js +73 -0
  197. package/apps/runtime/dist/engenty/connections-hubspot/connector.js +140 -0
  198. package/apps/runtime/dist/engenty/connections-microsoft/action.js +17 -0
  199. package/apps/runtime/dist/engenty/connections-microsoft/graph.js +114 -0
  200. package/apps/runtime/dist/engenty/connections-microsoft/onedrive.js +286 -0
  201. package/apps/runtime/dist/engenty/connections-microsoft/outlook.js +492 -0
  202. package/apps/runtime/dist/engenty/connections-s3/s3.js +328 -0
  203. package/apps/runtime/dist/engenty/connections-sdk/files-capability.js +86 -0
  204. package/apps/runtime/dist/engenty/connections-sdk/oauth2.js +150 -0
  205. package/apps/runtime/dist/engenty/connections-sdk/registry.js +89 -0
  206. package/apps/runtime/dist/engenty/connections-sdk/storage-capability.js +84 -0
  207. package/apps/runtime/dist/engenty/connections-sdk/types.js +30 -0
  208. package/apps/runtime/dist/engenty/connections-slack/connector.js +360 -0
  209. package/apps/runtime/dist/engenty/csv-import/csv-matrix.js +178 -0
  210. package/apps/runtime/dist/engenty/csv-import/import-sources.js +87 -0
  211. package/apps/runtime/dist/engenty/csv-import/parse-csv.js +129 -0
  212. package/apps/runtime/dist/engenty/csv-import/serialize-csv.js +20 -0
  213. package/apps/runtime/dist/engenty/csv-import/types.js +1 -0
  214. package/apps/runtime/dist/engenty/csv-import/xlsx-workbook.js +159 -0
  215. package/apps/runtime/dist/engenty/doc-converter/interface.js +9 -0
  216. package/apps/runtime/dist/engenty/doc-converter/page-break.js +92 -0
  217. package/apps/runtime/dist/engenty/doc-converter/providers/local/index.js +72 -0
  218. package/apps/runtime/dist/engenty/document-scanner/schemas/classifier.js +30 -0
  219. package/apps/runtime/dist/engenty/document-scanner/schemas/index.js +4 -0
  220. package/apps/runtime/dist/engenty/document-scanner/schemas/invoice.js +73 -0
  221. package/apps/runtime/dist/engenty/document-scanner/schemas/receipt.js +63 -0
  222. package/apps/runtime/dist/engenty/document-scanner/schemas/shared.js +40 -0
  223. package/apps/runtime/dist/engenty/search-index/chunks.js +164 -0
  224. package/apps/runtime/dist/engenty/search-index/contracts.js +9 -0
  225. package/apps/runtime/dist/engenty/shims/connections-sdk.js +39 -0
  226. package/apps/runtime/dist/engenty/shims/plugin-sdk.js +1 -0
  227. package/apps/runtime/dist/engenty/shims/web-ingest.js +19 -0
  228. package/apps/runtime/dist/engenty/web-ingest/ssrf.js +277 -0
  229. package/apps/runtime/dist/engine/asks.js +82 -0
  230. package/apps/runtime/dist/engine/decide.js +82 -0
  231. package/apps/runtime/dist/engine/device.js +194 -0
  232. package/apps/runtime/dist/engine/events.js +128 -0
  233. package/apps/runtime/dist/engine/input.js +208 -0
  234. package/apps/runtime/dist/engine/owner.js +32 -0
  235. package/apps/runtime/dist/engine/prepare.js +90 -0
  236. package/apps/runtime/dist/engine/push.js +58 -0
  237. package/apps/runtime/dist/engine/requirements.js +355 -0
  238. package/apps/runtime/dist/engine/resources.js +198 -0
  239. package/apps/runtime/dist/engine/runner.js +970 -0
  240. package/apps/runtime/dist/engine/steps.js +1000 -0
  241. package/apps/runtime/dist/engine/surface.js +91 -0
  242. package/apps/runtime/dist/engine/template.js +240 -0
  243. package/apps/runtime/dist/engine/types.js +4 -0
  244. package/apps/runtime/dist/env.js +295 -0
  245. package/apps/runtime/dist/features.js +123 -0
  246. package/apps/runtime/dist/files/blobs.js +22 -0
  247. package/apps/runtime/dist/files/objects.js +86 -0
  248. package/apps/runtime/dist/files/storage.js +120 -0
  249. package/apps/runtime/dist/files/web-images.js +101 -0
  250. package/apps/runtime/dist/film/project.js +257 -0
  251. package/apps/runtime/dist/film/skills.js +91 -0
  252. package/apps/runtime/dist/film/sounds.js +122 -0
  253. package/apps/runtime/dist/film/step.js +289 -0
  254. package/apps/runtime/dist/film/tools.js +99 -0
  255. package/apps/runtime/dist/geocode.js +58 -0
  256. package/apps/runtime/dist/harness/antigravity.js +129 -0
  257. package/apps/runtime/dist/harness/apple.js +270 -0
  258. package/apps/runtime/dist/harness/claude.js +147 -0
  259. package/apps/runtime/dist/harness/codex.js +229 -0
  260. package/apps/runtime/dist/harness/cursor.js +93 -0
  261. package/apps/runtime/dist/harness/env.js +124 -0
  262. package/apps/runtime/dist/harness/index.js +95 -0
  263. package/apps/runtime/dist/harness/model.js +279 -0
  264. package/apps/runtime/dist/harness/prompt.js +121 -0
  265. package/apps/runtime/dist/harness/terminal.js +194 -0
  266. package/apps/runtime/dist/harness/types.js +7 -0
  267. package/apps/runtime/dist/index.js +113 -0
  268. package/apps/runtime/dist/limits.js +81 -0
  269. package/apps/runtime/dist/link-preview.js +60 -0
  270. package/apps/runtime/dist/log.js +106 -0
  271. package/apps/runtime/dist/manage.js +249 -0
  272. package/apps/runtime/dist/mcp/auth.js +161 -0
  273. package/apps/runtime/dist/mcp/bridge.js +59 -0
  274. package/apps/runtime/dist/mcp/flow-app.js +97 -0
  275. package/apps/runtime/dist/mcp/handler.js +54 -0
  276. package/apps/runtime/dist/mcp/scopes.js +14 -0
  277. package/apps/runtime/dist/mcp/seen.js +65 -0
  278. package/apps/runtime/dist/mcp/tools.js +572 -0
  279. package/apps/runtime/dist/media/conversation.js +167 -0
  280. package/apps/runtime/dist/media/ffmpeg.js +121 -0
  281. package/apps/runtime/dist/media/generate.js +120 -0
  282. package/apps/runtime/dist/media/marking.js +121 -0
  283. package/apps/runtime/dist/media/transcribe.js +198 -0
  284. package/apps/runtime/dist/model-errors.js +42 -0
  285. package/apps/runtime/dist/models.js +1164 -0
  286. package/apps/runtime/dist/plugin.js +61 -0
  287. package/apps/runtime/dist/plugins/channels.js +78 -0
  288. package/apps/runtime/dist/plugins/claims.js +56 -0
  289. package/apps/runtime/dist/plugins/discovery.js +155 -0
  290. package/apps/runtime/dist/plugins/events.js +63 -0
  291. package/apps/runtime/dist/plugins/jobs.js +64 -0
  292. package/apps/runtime/dist/plugins/loader.js +508 -0
  293. package/apps/runtime/dist/plugins/migrations.js +69 -0
  294. package/apps/runtime/dist/plugins/pro-keys.js +34 -0
  295. package/apps/runtime/dist/plugins/pro-state.js +83 -0
  296. package/apps/runtime/dist/plugins/pro.js +310 -0
  297. package/apps/runtime/dist/plugins/public.js +44 -0
  298. package/apps/runtime/dist/plugins/registry.js +122 -0
  299. package/apps/runtime/dist/plugins/runs.js +210 -0
  300. package/apps/runtime/dist/render/browser-path.js +54 -0
  301. package/apps/runtime/dist/render/chromium.js +98 -0
  302. package/apps/runtime/dist/render/convert.js +158 -0
  303. package/apps/runtime/dist/render/downloads.js +299 -0
  304. package/apps/runtime/dist/render/guard.js +25 -0
  305. package/apps/runtime/dist/render/shaped.js +137 -0
  306. package/apps/runtime/dist/routes/api.js +440 -0
  307. package/apps/runtime/dist/routes/debug.js +42 -0
  308. package/apps/runtime/dist/routes/delivery.js +90 -0
  309. package/apps/runtime/dist/routes/internal.js +81 -0
  310. package/apps/runtime/dist/routes/lang.js +25 -0
  311. package/apps/runtime/dist/routes/marketplace.js +43 -0
  312. package/apps/runtime/dist/routes/plugin-public.js +113 -0
  313. package/apps/runtime/dist/routes/plugins.js +212 -0
  314. package/apps/runtime/dist/routes/runs.js +1422 -0
  315. package/apps/runtime/dist/routes/studio.js +1629 -0
  316. package/apps/runtime/dist/routes/wizard-stream.js +30 -0
  317. package/apps/runtime/dist/running.js +39 -0
  318. package/apps/runtime/dist/sandbox/docker.js +75 -0
  319. package/apps/runtime/dist/sandbox/index.js +23 -0
  320. package/apps/runtime/dist/sandbox/types.js +1 -0
  321. package/apps/runtime/dist/secrets/crypto.js +28 -0
  322. package/apps/runtime/dist/secrets/signing.js +52 -0
  323. package/apps/runtime/dist/secrets/vault.js +59 -0
  324. package/apps/runtime/dist/services/access.js +88 -0
  325. package/apps/runtime/dist/services/api.js +248 -0
  326. package/apps/runtime/dist/services/architect.js +95 -0
  327. package/apps/runtime/dist/services/assistant-chats.js +311 -0
  328. package/apps/runtime/dist/services/brand.js +85 -0
  329. package/apps/runtime/dist/services/cloud.js +456 -0
  330. package/apps/runtime/dist/services/draft-events.js +27 -0
  331. package/apps/runtime/dist/services/engenty-shapes.js +71 -0
  332. package/apps/runtime/dist/services/errors.js +29 -0
  333. package/apps/runtime/dist/services/files.js +178 -0
  334. package/apps/runtime/dist/services/knowledge-model.js +559 -0
  335. package/apps/runtime/dist/services/knowledge.js +721 -0
  336. package/apps/runtime/dist/services/links.js +16 -0
  337. package/apps/runtime/dist/services/marketplace.js +492 -0
  338. package/apps/runtime/dist/services/onboarding.js +152 -0
  339. package/apps/runtime/dist/services/package-file.js +82 -0
  340. package/apps/runtime/dist/services/package.js +170 -0
  341. package/apps/runtime/dist/services/profile.js +51 -0
  342. package/apps/runtime/dist/services/project-files.js +439 -0
  343. package/apps/runtime/dist/services/project-index.js +707 -0
  344. package/apps/runtime/dist/services/projects.js +387 -0
  345. package/apps/runtime/dist/services/relevance.js +58 -0
  346. package/apps/runtime/dist/services/runners.js +178 -0
  347. package/apps/runtime/dist/services/runs.js +524 -0
  348. package/apps/runtime/dist/services/shares.js +130 -0
  349. package/apps/runtime/dist/services/site.js +270 -0
  350. package/apps/runtime/dist/services/space-categories.js +861 -0
  351. package/apps/runtime/dist/services/space-data.js +792 -0
  352. package/apps/runtime/dist/services/space-origin.js +207 -0
  353. package/apps/runtime/dist/services/spaces.js +656 -0
  354. package/apps/runtime/dist/services/translations.js +306 -0
  355. package/apps/runtime/dist/services/widgets.js +34 -0
  356. package/apps/runtime/dist/services/wizard-icon.js +157 -0
  357. package/apps/runtime/dist/services/wizards.js +420 -0
  358. package/apps/runtime/dist/settings.js +16 -0
  359. package/apps/runtime/dist/store/errors.js +4 -0
  360. package/apps/runtime/dist/store/index.js +299 -0
  361. package/apps/runtime/dist/store/shared-lists.js +123 -0
  362. package/apps/runtime/dist/tenants/control.js +238 -0
  363. package/apps/runtime/dist/tenants/tenant.js +26 -0
  364. package/apps/runtime/dist/texts.js +207 -0
  365. package/apps/runtime/dist/tools/browser.js +703 -0
  366. package/apps/runtime/dist/tools/connector.js +204 -0
  367. package/apps/runtime/dist/tools/index.js +291 -0
  368. package/apps/runtime/dist/tools/mail.js +104 -0
  369. package/apps/runtime/dist/tools/net-guard.js +170 -0
  370. package/apps/runtime/dist/tools/pages.js +81 -0
  371. package/apps/runtime/dist/tools/plugin.js +180 -0
  372. package/apps/runtime/dist/tools/project.js +154 -0
  373. package/apps/runtime/dist/tools/shared.js +69 -0
  374. package/apps/runtime/dist/tools/store.js +238 -0
  375. package/apps/runtime/dist/update.js +113 -0
  376. package/apps/runtime/dist/widgets/bundle.js +99 -0
  377. package/apps/runtime/dist/widgets/render.js +329 -0
  378. package/apps/runtime/dist/widgets/runtime.js +108 -0
  379. package/apps/runtime/dist/widgets/script.js +30 -0
  380. package/apps/runtime/dist/widgets/step.js +223 -0
  381. package/apps/web/dist/ai-labels/ai-black.svg +20 -0
  382. package/apps/web/dist/ai-labels/ai-generated-black.svg +31 -0
  383. package/apps/web/dist/ai-labels/ai-generated-white.svg +32 -0
  384. package/apps/web/dist/ai-labels/ai-modified-black.svg +30 -0
  385. package/apps/web/dist/ai-labels/ai-modified-white.svg +31 -0
  386. package/apps/web/dist/ai-labels/ai-white.svg +21 -0
  387. package/apps/web/dist/assets/AboutDialog-D4mvc-zu.js +1 -0
  388. package/apps/web/dist/assets/ChangelogDialog-DLqpJsF6.js +1 -0
  389. package/apps/web/dist/assets/ChatView-3laypRcE.js +10 -0
  390. package/apps/web/dist/assets/EditorPage-BalA5U2Y.js +3 -0
  391. package/apps/web/dist/assets/FlowPreview-CusP7ci9.js +1 -0
  392. package/apps/web/dist/assets/Harness-BrP-ENHg.css +1 -0
  393. package/apps/web/dist/assets/Harness-iYLtOLaK.js +16 -0
  394. package/apps/web/dist/assets/NewWizardChannels-CbwJ9A56.js +1 -0
  395. package/apps/web/dist/assets/NewWizardPage-BOBYiB9i.js +7 -0
  396. package/apps/web/dist/assets/OnboardingPage-CUwCiVIr.js +1 -0
  397. package/apps/web/dist/assets/ProjectPage-Bb16MdYG.js +1 -0
  398. package/apps/web/dist/assets/PublicRunner-BCt7Q6C-.js +1 -0
  399. package/apps/web/dist/assets/ReadOnly-kIHX2TEy.js +1 -0
  400. package/apps/web/dist/assets/RunDrawer-hZ9oeSXu.js +4 -0
  401. package/apps/web/dist/assets/RunnerView-DUS9fPmx.js +1 -0
  402. package/apps/web/dist/assets/SettingsPage-BzwR50fi.js +1 -0
  403. package/apps/web/dist/assets/SetupPage-gAp7rPxp.js +1 -0
  404. package/apps/web/dist/assets/SharePage-DqZWHva_.js +1 -0
  405. package/apps/web/dist/assets/changelog-DugmCNSf.js +1 -0
  406. package/apps/web/dist/assets/engenty-eXZ-EAwd.js +1 -0
  407. package/apps/web/dist/assets/esm-DXeMu8Lb.js +7 -0
  408. package/apps/web/dist/assets/fluffy-engenty-ClRou7yu.js +456 -0
  409. package/apps/web/dist/assets/index-AfUa8xKD.css +1 -0
  410. package/apps/web/dist/assets/index-C5Sm7tTR.js +14 -0
  411. package/apps/web/dist/assets/jsx-runtime-BNakU3Ej.js +1 -0
  412. package/apps/web/dist/assets/lock-R_CfU0Xo.js +1 -0
  413. package/apps/web/dist/assets/oss-credits-cZ9NUaLZ.js +1 -0
  414. package/apps/web/dist/assets/pdfmake-Cx9scTbD.js +228 -0
  415. package/apps/web/dist/assets/phone-CgrIS4_-.js +1 -0
  416. package/apps/web/dist/assets/preload-helper-CNEI7N0N.js +1 -0
  417. package/apps/web/dist/assets/qr-scanner-worker.min-CJaXo3yu.js +98 -0
  418. package/apps/web/dist/assets/qr-scanner.min-C_UI0gH-.js +1 -0
  419. package/apps/web/dist/assets/rolldown-runtime-hePW80VL.js +1 -0
  420. package/apps/web/dist/assets/settings-menu-2IMOOlLl.js +1 -0
  421. package/apps/web/dist/assets/ui-dzGvc3xk.js +137 -0
  422. package/apps/web/dist/assets/upload-BSuTilFF.js +1 -0
  423. package/apps/web/dist/assets/vfs_fonts-DllDSYt1.js +1 -0
  424. package/apps/web/dist/embed.js +266 -0
  425. package/apps/web/dist/favicon.svg +1 -0
  426. package/apps/web/dist/icons/apple-touch-icon.png +0 -0
  427. package/apps/web/dist/icons/icon-192.png +0 -0
  428. package/apps/web/dist/icons/icon-512.png +0 -0
  429. package/apps/web/dist/icons/icon-maskable-512.png +0 -0
  430. package/apps/web/dist/index.html +48 -0
  431. package/apps/web/dist/install.sh +577 -0
  432. package/apps/web/dist/manifest.webmanifest +21 -0
  433. package/apps/web/dist/mcp/flow.html +980 -0
  434. package/apps/web/dist/sw.js +15 -0
  435. package/bin/wizards.mjs +288 -0
  436. package/modules/README.md +15 -0
  437. package/node_modules/@engenty/wizards/dist/plugin/index.d.ts +1150 -0
  438. package/node_modules/@engenty/wizards/dist/plugin/index.js +4 -0
  439. package/node_modules/@engenty/wizards/dist/plugin/studio.d.ts +322 -0
  440. package/node_modules/@engenty/wizards/dist/plugin/studio.js +4 -0
  441. package/node_modules/@engenty/wizards/dist/plugin/thread.d.ts +174 -0
  442. package/node_modules/@engenty/wizards/dist/plugin/thread.js +821 -0
  443. package/node_modules/@engenty/wizards/package.json +11 -0
  444. package/node_modules/@engenty-wizards/shared/dist/assistant.d.ts +174 -0
  445. package/node_modules/@engenty-wizards/shared/dist/assistant.js +65 -0
  446. package/node_modules/@engenty-wizards/shared/dist/changes.d.ts +22 -0
  447. package/node_modules/@engenty-wizards/shared/dist/changes.js +61 -0
  448. package/node_modules/@engenty-wizards/shared/dist/connectors.d.ts +77 -0
  449. package/node_modules/@engenty-wizards/shared/dist/connectors.js +2 -0
  450. package/node_modules/@engenty-wizards/shared/dist/decision.d.ts +76 -0
  451. package/node_modules/@engenty-wizards/shared/dist/decision.js +147 -0
  452. package/node_modules/@engenty-wizards/shared/dist/definition.d.ts +2922 -0
  453. package/node_modules/@engenty-wizards/shared/dist/definition.js +1920 -0
  454. package/node_modules/@engenty-wizards/shared/dist/engenty/data-tables/columns-format.d.ts +5 -0
  455. package/node_modules/@engenty-wizards/shared/dist/engenty/data-tables/columns-format.js +132 -0
  456. package/node_modules/@engenty-wizards/shared/dist/engenty/data-tables/columns-value.d.ts +11 -0
  457. package/node_modules/@engenty-wizards/shared/dist/engenty/data-tables/columns-value.js +209 -0
  458. package/node_modules/@engenty-wizards/shared/dist/engenty/data-tables/columns.d.ts +532 -0
  459. package/node_modules/@engenty-wizards/shared/dist/engenty/data-tables/columns.js +217 -0
  460. package/node_modules/@engenty-wizards/shared/dist/engenty/data-tables/index.d.ts +3 -0
  461. package/node_modules/@engenty-wizards/shared/dist/engenty/data-tables/index.js +3 -0
  462. package/node_modules/@engenty-wizards/shared/dist/engenty/search-index/catalog-lexical.d.ts +14 -0
  463. package/node_modules/@engenty-wizards/shared/dist/engenty/search-index/catalog-lexical.js +166 -0
  464. package/node_modules/@engenty-wizards/shared/dist/engenty/search-index/catalog-rank.d.ts +33 -0
  465. package/node_modules/@engenty-wizards/shared/dist/engenty/search-index/catalog-rank.js +99 -0
  466. package/node_modules/@engenty-wizards/shared/dist/feature-flags.d.ts +78 -0
  467. package/node_modules/@engenty-wizards/shared/dist/feature-flags.js +70 -0
  468. package/node_modules/@engenty-wizards/shared/dist/features.d.ts +41 -0
  469. package/node_modules/@engenty-wizards/shared/dist/features.js +89 -0
  470. package/node_modules/@engenty-wizards/shared/dist/fit.d.ts +71 -0
  471. package/node_modules/@engenty-wizards/shared/dist/fit.js +382 -0
  472. package/node_modules/@engenty-wizards/shared/dist/json-schema.d.ts +14 -0
  473. package/node_modules/@engenty-wizards/shared/dist/json-schema.js +66 -0
  474. package/node_modules/@engenty-wizards/shared/dist/knowledge.d.ts +199 -0
  475. package/node_modules/@engenty-wizards/shared/dist/knowledge.js +68 -0
  476. package/node_modules/@engenty-wizards/shared/dist/marketplace-entry.d.ts +35 -0
  477. package/node_modules/@engenty-wizards/shared/dist/marketplace-entry.js +107 -0
  478. package/node_modules/@engenty-wizards/shared/dist/marketplace-search.d.ts +20 -0
  479. package/node_modules/@engenty-wizards/shared/dist/marketplace-search.js +136 -0
  480. package/node_modules/@engenty-wizards/shared/dist/marketplace.d.ts +227 -0
  481. package/node_modules/@engenty-wizards/shared/dist/marketplace.js +354 -0
  482. package/node_modules/@engenty-wizards/shared/dist/merge.d.ts +7 -0
  483. package/node_modules/@engenty-wizards/shared/dist/merge.js +40 -0
  484. package/node_modules/@engenty-wizards/shared/dist/numbers.d.ts +24 -0
  485. package/node_modules/@engenty-wizards/shared/dist/numbers.js +54 -0
  486. package/node_modules/@engenty-wizards/shared/dist/projects.d.ts +224 -0
  487. package/node_modules/@engenty-wizards/shared/dist/projects.js +319 -0
  488. package/node_modules/@engenty-wizards/shared/dist/providers.d.ts +101 -0
  489. package/node_modules/@engenty-wizards/shared/dist/providers.js +390 -0
  490. package/node_modules/@engenty-wizards/shared/dist/run.d.ts +680 -0
  491. package/node_modules/@engenty-wizards/shared/dist/run.js +620 -0
  492. package/node_modules/@engenty-wizards/shared/dist/runner-texts.d.ts +546 -0
  493. package/node_modules/@engenty-wizards/shared/dist/runner-texts.js +523 -0
  494. package/node_modules/@engenty-wizards/shared/dist/runners.d.ts +93 -0
  495. package/node_modules/@engenty-wizards/shared/dist/runners.js +146 -0
  496. package/node_modules/@engenty-wizards/shared/dist/shape.d.ts +102 -0
  497. package/node_modules/@engenty-wizards/shared/dist/shape.js +318 -0
  498. package/node_modules/@engenty-wizards/shared/dist/space-data.d.ts +89 -0
  499. package/node_modules/@engenty-wizards/shared/dist/space-data.js +47 -0
  500. package/node_modules/@engenty-wizards/shared/dist/store.d.ts +117 -0
  501. package/node_modules/@engenty-wizards/shared/dist/store.js +81 -0
  502. package/node_modules/@engenty-wizards/shared/dist/surface.d.ts +115 -0
  503. package/node_modules/@engenty-wizards/shared/dist/surface.js +442 -0
  504. package/node_modules/@engenty-wizards/shared/dist/texts.d.ts +45 -0
  505. package/node_modules/@engenty-wizards/shared/dist/texts.js +54 -0
  506. package/node_modules/@engenty-wizards/shared/dist/translation.d.ts +23 -0
  507. package/node_modules/@engenty-wizards/shared/dist/translation.js +154 -0
  508. package/node_modules/@engenty-wizards/shared/dist/wizard-package.d.ts +48 -0
  509. package/node_modules/@engenty-wizards/shared/dist/wizard-package.js +49 -0
  510. package/node_modules/@engenty-wizards/shared/dist/workspace.d.ts +16 -0
  511. package/node_modules/@engenty-wizards/shared/dist/workspace.js +51 -0
  512. package/node_modules/@engenty-wizards/shared/package.json +10 -0
  513. package/package.json +77 -4
  514. package/plugin/.claude-plugin/plugin.json +9 -0
  515. package/plugin/.mcp.json +8 -0
  516. package/plugin/commands/wizard.md +8 -0
  517. package/plugin/skills/build-wizard/SKILL.md +27 -0
  518. package/plugin/skills/use-wizard/SKILL.md +18 -0
@@ -0,0 +1,1150 @@
1
+ import type { LibSQLDatabase } from "drizzle-orm/libsql";
2
+ import type { z } from "zod";
3
+ /**
4
+ * What the runtime hands a plugin's server half. A plugin is a file or a folder the runtime finds
5
+ * at start (docs/content/dev/plugins); its default export is a factory that registers what it adds. The
6
+ * runtime remembers every registration under the plugin's id and takes it back when the plugin
7
+ * unloads or reloads.
8
+ */
9
+ /** `engenty.plugin.json`, the file an engenty module has too. A plugin of one file has none. */
10
+ export interface PluginManifest {
11
+ /** Lower case, digits and `-`: part of the plugin's addresses and of its tools' ids. */
12
+ id: string;
13
+ name: string;
14
+ version: string;
15
+ description?: string;
16
+ kind?: string;
17
+ provides?: string[];
18
+ requires?: string[];
19
+ /** The server half, from the plugin's folder. Default `src/plugin.ts`. */
20
+ server?: string;
21
+ /** The studio half, built. Default `dist/client.js`. */
22
+ studio?: string;
23
+ /** The studio half's styles, built. Default `dist/client.css`. */
24
+ styles?: string;
25
+ /**
26
+ * The plugin's feature switches, by short name; each is known as `<id>.<name>` everywhere
27
+ * (`wizards features`, the `.features` file, the Manage-App's admin). `true`/`false` is the
28
+ * default alone; a `plan` switch is one a plan includes.
29
+ */
30
+ features?: Record<string, boolean | {
31
+ kind?: "release" | "plan";
32
+ default?: boolean;
33
+ label?: string;
34
+ hint?: string;
35
+ }>;
36
+ }
37
+ export type PluginRole = "owner" | "admin" | "member";
38
+ /** The signed-in person a request acts as. */
39
+ export interface PluginPrincipal {
40
+ id: string;
41
+ tenantId: string;
42
+ role: PluginRole;
43
+ name: string;
44
+ email: string;
45
+ }
46
+ export interface PluginRequest {
47
+ /** The web request as it came in. */
48
+ request: Request;
49
+ /** The address below the plugin's own: `/` for `/api/studio/plugins/<id>/`. */
50
+ path: string;
51
+ /** What `:name` parts of the route's path matched. */
52
+ params: Record<string, string>;
53
+ query: URLSearchParams;
54
+ user: PluginPrincipal;
55
+ /** The body as JSON; an empty body is `{}`. */
56
+ json<T = unknown>(): Promise<T>;
57
+ }
58
+ export type PluginHttpMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
59
+ /** A route below `/api/studio/plugins/<id>`: signed in, inside the person's tenant. */
60
+ export interface PluginRoute {
61
+ method: PluginHttpMethod;
62
+ /** `/`, `/items`, `/items/:id`. */
63
+ path: string;
64
+ /** `admin`: owners and admins only. Default: every member. */
65
+ role?: "member" | "admin";
66
+ /**
67
+ * Answers with a `Response`, or with a value that goes out as JSON. An error thrown with a
68
+ * `status` and a `code` goes out as `{ error, code }` with that status.
69
+ */
70
+ handler(request: PluginRequest): unknown | Promise<unknown>;
71
+ }
72
+ /** A space: what all its wizards share. The runtime's own tables call it a project. */
73
+ export interface PluginSpace {
74
+ id: string;
75
+ /** What the studio's switcher calls it. */
76
+ name: string;
77
+ }
78
+ /** What a tool knows about the step that calls it. */
79
+ export interface PluginStepContext {
80
+ runId: string;
81
+ stepId: string;
82
+ tenantId: string;
83
+ /** The space of the step's wizard. */
84
+ space: PluginSpace;
85
+ /** The same as `space`, by its older name. */
86
+ project: {
87
+ id: string;
88
+ name: string;
89
+ };
90
+ wizard: {
91
+ id: string;
92
+ title: string;
93
+ };
94
+ /** "test": a test run from the studio. Keep what it makes apart from what real runs make. */
95
+ mode: "test" | "live";
96
+ /** Aborted when the run is cancelled. */
97
+ signal: AbortSignal;
98
+ /** Tells the person what the step is doing right now. */
99
+ emit(message: string): Promise<void>;
100
+ }
101
+ /** A tool for agent steps. A step allowlists it as `<plugin id>.<name>`. */
102
+ export interface PluginTool<S extends z.ZodType = z.ZodType> {
103
+ /** Lower case, digits and `_`. */
104
+ name: string;
105
+ /** What the editor calls it; default: the name. */
106
+ title?: string;
107
+ /** For the model: what the tool does and when to use it. */
108
+ description: string;
109
+ inputSchema: S;
110
+ execute(input: z.infer<S>, ctx: PluginStepContext): unknown | Promise<unknown>;
111
+ }
112
+ /** A run that reached its end. It fires again when a finished run is redone and ends again. */
113
+ export interface PluginRunEvent {
114
+ run: {
115
+ id: string;
116
+ wizardId: string;
117
+ mode: "test" | "live";
118
+ status: "done" | "failed" | "cancelled";
119
+ };
120
+ wizard: {
121
+ id: string;
122
+ title: string;
123
+ projectId: string;
124
+ };
125
+ /** What the person answered, by field id. */
126
+ values: Record<string, unknown>;
127
+ }
128
+ /** A space was made, changed (title, about, colours, facts, systems) or deleted. */
129
+ export interface PluginSpaceEvent {
130
+ space: {
131
+ id: string;
132
+ };
133
+ }
134
+ /** A file of a space: read and ready (a document is in the index then), or removed. */
135
+ export interface PluginSpaceFileEvent {
136
+ space: {
137
+ id: string;
138
+ };
139
+ file: {
140
+ id: string;
141
+ name: string;
142
+ kind: "logo" | "asset" | "document" | "pattern";
143
+ mime: string;
144
+ };
145
+ }
146
+ export interface PluginEvents {
147
+ "run.done": PluginRunEvent;
148
+ "run.failed": PluginRunEvent;
149
+ "run.cancelled": PluginRunEvent;
150
+ "space.created": PluginSpaceEvent;
151
+ "space.updated": PluginSpaceEvent;
152
+ "space.deleted": PluginSpaceEvent;
153
+ "space.file.ready": PluginSpaceFileEvent;
154
+ "space.file.removed": PluginSpaceFileEvent;
155
+ }
156
+ /** The tenant's database. A plugin reads and writes its own tables with it. */
157
+ export type PluginDb = LibSQLDatabase<Record<string, never>>;
158
+ /** What a plugin asks a model. */
159
+ export interface PluginGenerateRequest<T = undefined> {
160
+ prompt: string;
161
+ system?: string;
162
+ /** The answer as an object of this shape instead of text. */
163
+ schema?: z.ZodType<T>;
164
+ /** The tenant's model class. Default `standard`; `classifier` is the fast, cheap one. */
165
+ model?: "classifier" | "standard" | "high" | "highest";
166
+ maxOutputTokens?: number;
167
+ /** Default: two minutes. */
168
+ signal?: AbortSignal;
169
+ /**
170
+ * Pictures (PNG, JPEG, WebP, GIF) and PDFs the model looks at with the prompt: a screenshot to
171
+ * build after, a brand guide. Text files go into the prompt as text.
172
+ */
173
+ files?: {
174
+ data: Uint8Array;
175
+ mediaType: string;
176
+ name?: string;
177
+ }[];
178
+ }
179
+ export interface PluginGenerateResult<T = undefined> {
180
+ text: string;
181
+ /** Set when the request had a `schema`. */
182
+ object: T;
183
+ }
184
+ /** What a plugin adds to the AI steps of a space's wizards: every agent step, unless `steps` says. */
185
+ export interface PluginSpaceContext {
186
+ /**
187
+ * A block of the step's instructions, after what the space says about itself and its
188
+ * documents: what the plugin holds for the space, and which of its tools read it. Empty or
189
+ * null: the step gets neither the block nor the tools.
190
+ */
191
+ block(space: PluginSpace): string | null | Promise<string | null>;
192
+ /** Tools the step gets with the block, named `<plugin>_<name>` for the model. */
193
+ tools?: PluginTool[];
194
+ /**
195
+ * The steps that get it: `agent` (default), `html` — the steps that write a document or a
196
+ * dashboard as HTML, which get the block without the tools.
197
+ */
198
+ steps?: ("agent" | "html")[];
199
+ }
200
+ /** A space's brand as the studio's Info & brand has it: what a plugin draws or writes in its look. */
201
+ export interface PluginBrand {
202
+ /** The title end users see. */
203
+ name: string;
204
+ /** The colours in order: the first is the accent. */
205
+ colors: {
206
+ name: string;
207
+ value: string;
208
+ }[];
209
+ /** The fonts, each with what it is for ("Headings") and the weights the brand uses. */
210
+ fonts: {
211
+ family: string;
212
+ role: string;
213
+ weights: number[];
214
+ }[];
215
+ }
216
+ /** A text a plugin puts into a space's search index, beside the space's documents. */
217
+ export interface PluginIndexEntry {
218
+ /** The space's id. */
219
+ space: string;
220
+ /** The plugin's own name for it: putting the same key again replaces what it had. */
221
+ key: string;
222
+ /** What a hit is called: a page's title, a question. */
223
+ title: string;
224
+ /** Markdown, cut into passages like a document's text. */
225
+ text: string;
226
+ /** Where the studio shows it, an address of the studio: `/space#faq`. */
227
+ link?: string;
228
+ }
229
+ export interface PluginIndex {
230
+ /** Puts the entry in; `project_search` finds it from then on. */
231
+ put(entry: PluginIndexEntry): Promise<void>;
232
+ /** Takes one key out, or without a key every entry of the plugin in the space. */
233
+ remove(space: string, key?: string): Promise<void>;
234
+ }
235
+ /** A category of a space: a typed property set on pages, tables, rows and files of Knowledge. */
236
+ export interface PluginCategory {
237
+ name: string;
238
+ type: "choice" | "date" | "number" | "text" | "boolean";
239
+ /** A number's unit: `h`, `€`, `kg`. */
240
+ unit?: string;
241
+ /** A choice: several values per item. */
242
+ multiple?: boolean;
243
+ /** A choice whose values are ranked, in the order of `values`. */
244
+ ordered?: boolean;
245
+ /** Where its values come from, in a few words: "Kopfzeile", "Filter der Website". */
246
+ hint?: string;
247
+ /** A choice's values, known beforehand: a site's filter. Others are added as items bring them. */
248
+ values?: string[];
249
+ /** A column of a table the plugin wrote (by the table's key) whose cells are its values. */
250
+ column?: {
251
+ table: string;
252
+ column: string;
253
+ };
254
+ }
255
+ /**
256
+ * Categories of an item, by their names: a choice's value (or a list of them), a day as
257
+ * `YYYY-MM-DD`, a number, a short text, true or false. Null takes one off.
258
+ */
259
+ export type PluginCategoryValues = Record<string, string | number | boolean | (string | number)[] | null>;
260
+ /** The original an item was read from, kept as the evidence beside it. */
261
+ export interface PluginOriginal {
262
+ name: string;
263
+ mime: string;
264
+ data: Uint8Array;
265
+ }
266
+ /** `written`: the plugin's version stands. `kept`: a person changed it, the plugin no longer writes it. */
267
+ export type PluginItemState = "written" | "kept";
268
+ export interface PluginPageInput {
269
+ space: string;
270
+ /** The plugin's own name for the page: the same key again rewrites it, never doubles it. */
271
+ key: string;
272
+ /** What the person knows its source as: "Tagesberichte". */
273
+ label?: string;
274
+ title: string;
275
+ markdown: string;
276
+ /** The key of a page the plugin wrote before, to stand under it as a sub-page. */
277
+ parent?: string;
278
+ position?: number;
279
+ original?: PluginOriginal;
280
+ categories?: PluginCategoryValues;
281
+ /** A model fills the space's categories the page did not get from `categories`. */
282
+ fill?: boolean;
283
+ /** Why a person should look at it ("hardly readable"); shown in Knowledge. */
284
+ review?: string | null;
285
+ }
286
+ export interface PluginTableInput {
287
+ space: string;
288
+ key: string;
289
+ label?: string;
290
+ title: string;
291
+ /** Typed columns, as a table of the space has them (`text`, `number`, `date`, `select` …). */
292
+ columns: unknown[];
293
+ /** Cells by column id. They replace the rows the key had. */
294
+ rows: Record<string, unknown>[];
295
+ /** `faq`: a question and its answer per row. */
296
+ format?: "faq";
297
+ original?: PluginOriginal;
298
+ categories?: PluginCategoryValues;
299
+ review?: string | null;
300
+ }
301
+ export interface PluginFileInput {
302
+ space: string;
303
+ key: string;
304
+ label?: string;
305
+ name: string;
306
+ mime: string;
307
+ data: Uint8Array;
308
+ /** What it is, in a sentence: a file that is no page is found by its name and this. */
309
+ description?: string;
310
+ /** What a step reads of it, when there is text. */
311
+ text?: string;
312
+ categories?: PluginCategoryValues;
313
+ }
314
+ export interface PluginDocumentInput {
315
+ space: string;
316
+ key: string;
317
+ label?: string;
318
+ name: string;
319
+ mime: string;
320
+ data: Uint8Array;
321
+ /** Set on what it becomes: its first page, its first table, or the file. */
322
+ categories?: PluginCategoryValues;
323
+ /** A model fills the space's categories it did not get from `categories`. */
324
+ fill?: boolean;
325
+ }
326
+ /** What a document became: pages and tables (the first is the one it is found as), or a file. */
327
+ export interface PluginDocumentResult {
328
+ /** The file, kept as the original. */
329
+ id: string;
330
+ path: string;
331
+ state: PluginItemState;
332
+ items: {
333
+ kind: "page" | "table";
334
+ id: string;
335
+ path: string;
336
+ title: string;
337
+ }[];
338
+ /** Why a person should look at it: hardly readable, or not readable at all. */
339
+ review: string | null;
340
+ }
341
+ /** A page of a space, as a plugin reads it. */
342
+ export interface PluginSpacePage {
343
+ id: string;
344
+ title: string;
345
+ /** How a step names it: `pages/…`. */
346
+ path: string;
347
+ parentId: string | null;
348
+ markdown: string;
349
+ /** The plugin that wrote it, or null for one made in the studio or uploaded. */
350
+ origin: string | null;
351
+ originKey: string | null;
352
+ updatedAt: string;
353
+ }
354
+ /** A file of a space, as a plugin reads it. */
355
+ export interface PluginSpaceFile {
356
+ id: string;
357
+ name: string;
358
+ mime: string;
359
+ size: number;
360
+ kind: "logo" | "asset" | "document" | "pattern";
361
+ updatedAt: string;
362
+ }
363
+ /** What a plugin wrote into a space. */
364
+ export interface PluginSpaceItem {
365
+ key: string;
366
+ kind: "page" | "table" | "file";
367
+ id: string;
368
+ title: string;
369
+ /** How a step names it: `pages/…`, `tables/…`, `files/…`. */
370
+ path: string;
371
+ state: PluginItemState;
372
+ review: string | null;
373
+ updatedAt: string;
374
+ }
375
+ /**
376
+ * Knowledge of a space, written by a plugin: pages, tables and files under keys of its own, with
377
+ * their categories. Every write is indexed: `project_search` finds it a moment later.
378
+ */
379
+ export interface PluginSpaceData {
380
+ /**
381
+ * Adds categories to the space, or values to ones it has. `proposed`: shown to the person to
382
+ * confirm, never filled before; a later call without it takes them.
383
+ */
384
+ putCategories(input: {
385
+ space: string;
386
+ categories: PluginCategory[];
387
+ proposed?: boolean;
388
+ }): Promise<void>;
389
+ putPage(input: PluginPageInput): Promise<{
390
+ id: string;
391
+ path: string;
392
+ state: PluginItemState;
393
+ }>;
394
+ putTable(input: PluginTableInput): Promise<{
395
+ id: string;
396
+ path: string;
397
+ state: PluginItemState;
398
+ }>;
399
+ putFile(input: PluginFileInput): Promise<{
400
+ id: string;
401
+ path: string;
402
+ }>;
403
+ /**
404
+ * A document read as an upload is: a page (sub-pages when it is long and has headings of its
405
+ * own), a table per sheet of a workbook, or a file when nothing reads it. The document stays as
406
+ * the original. The same key again reads it again, unless a person changed what it became.
407
+ */
408
+ putDocument(input: PluginDocumentInput): Promise<PluginDocumentResult>;
409
+ /** Everything the plugin wrote into the space. */
410
+ list(space: string): Promise<PluginSpaceItem[]>;
411
+ /**
412
+ * The space's own pages (not a wizard's), whoever wrote them, with their Markdown: for a
413
+ * plugin that reads what the space knows. `parent`: only the pages under that page.
414
+ */
415
+ readPages(space: string, opts?: {
416
+ parent?: string;
417
+ }): Promise<PluginSpacePage[]>;
418
+ /** The space's files of a kind (`document` when left out), newest first. */
419
+ files(space: string, kind?: "logo" | "asset" | "document" | "pattern"): Promise<PluginSpaceFile[]>;
420
+ /** One file of the space with its bytes: a price list someone dropped into Knowledge. */
421
+ readFile(space: string, fileId: string): Promise<PluginSpaceFile & {
422
+ data: Uint8Array;
423
+ }>;
424
+ /** Takes out one key, or every item of the plugin in the space; what a person changed stays. */
425
+ remove(space: string, key?: string): Promise<number>;
426
+ /**
427
+ * Writes the summary of values: of one, or of every value of a choice (or of every choice)
428
+ * that has three items or more. Returns how many were written. Costs a model call each.
429
+ */
430
+ summarize(space: string, category?: string, value?: string): Promise<number>;
431
+ }
432
+ /** What a tool of the space assistant knows about the turn that calls it. */
433
+ export interface PluginAssistantContext {
434
+ tenantId: string;
435
+ space: PluginSpace;
436
+ /** The person talking to the assistant. */
437
+ userId: string;
438
+ /** Aborted when the person leaves or stops the turn. */
439
+ signal: AbortSignal;
440
+ /** Tells the person what the assistant is doing right now: "Liest die Sitemap …". */
441
+ emit(message: string): void;
442
+ /** Say so when the tool changed what the space page shows: the page draws it again. */
443
+ changed(): void;
444
+ }
445
+ /** A tool of the space assistant: the chat on the space page that fills the space in. */
446
+ export interface PluginAssistantTool<S extends z.ZodType = z.ZodType> {
447
+ /** Lower case, digits and `_`. The model sees it as `<plugin>_<name>`. */
448
+ name: string;
449
+ /** For the model: what the tool does and when to use it. */
450
+ description: string;
451
+ inputSchema: S;
452
+ /**
453
+ * The result also goes to the chat, where the card the studio half registered for this tool
454
+ * (`registerAssistantCard`) draws it. It is sent as it is: keep such a result small.
455
+ */
456
+ card?: boolean;
457
+ execute(input: z.infer<S>, ctx: PluginAssistantContext): unknown | Promise<unknown>;
458
+ }
459
+ /** A page of the web, as `web.read` gives it. */
460
+ export interface PluginWebPage {
461
+ /** Where it ended up, after redirects. */
462
+ url: string;
463
+ status: number;
464
+ /** As the server sent them, for asking later whether the page changed. */
465
+ etag: string | null;
466
+ lastModified: string | null;
467
+ title: string;
468
+ description: string;
469
+ /** The page's text as Markdown. */
470
+ text: string;
471
+ /** Every link of the page, absolute, each once. */
472
+ links: {
473
+ url: string;
474
+ text: string;
475
+ }[];
476
+ /**
477
+ * The page's structured data: its `application/ld+json` blocks, parsed, a `@graph` spread
478
+ * out. A shop's product page says title, price, availability and image here exactly.
479
+ */
480
+ jsonld: unknown[];
481
+ }
482
+ export interface PluginWeb {
483
+ /**
484
+ * `fetch`, behind the guard of the runtime's own requests: addresses of this machine and of
485
+ * the local network are refused, after a redirect too.
486
+ */
487
+ fetch(url: string, init?: RequestInit): Promise<Response>;
488
+ /**
489
+ * A page read the way the space assistant reads one: guarded as `fetch`, and drawn in a
490
+ * browser when it has hardly any text without its scripts.
491
+ */
492
+ read(url: string, options?: {
493
+ signal?: AbortSignal;
494
+ }): Promise<PluginWebPage>;
495
+ }
496
+ export interface PluginDocuments {
497
+ /**
498
+ * A file as Markdown: PDF and Word by their text, scans and photos by a vision model (paid
499
+ * like every model call), spreadsheets as tables. Kept by content: the same bytes are read once.
500
+ */
501
+ parse(file: {
502
+ data: Uint8Array;
503
+ name: string;
504
+ mime: string;
505
+ }, options?: {
506
+ signal?: AbortSignal;
507
+ }): Promise<{
508
+ markdown: string;
509
+ pages: number | null;
510
+ }>;
511
+ }
512
+ /** One turn of a job `every` runs. */
513
+ export interface PluginTick {
514
+ tenantId: string;
515
+ /** When it ran for this tenant before; null the first time. */
516
+ lastRun: Date | null;
517
+ /** Aborted when the plugin unloads. */
518
+ signal: AbortSignal;
519
+ }
520
+ /** What a public route's handler gets. Nobody is signed in. */
521
+ export interface PluginPublicRequest {
522
+ request: Request;
523
+ /** The address below the plugin's public one. */
524
+ path: string;
525
+ params: Record<string, string>;
526
+ query: URLSearchParams;
527
+ /** The tenant whose address was called; the handler runs inside it. */
528
+ tenantId: string;
529
+ json<T = unknown>(): Promise<T>;
530
+ }
531
+ /**
532
+ * A route anyone may call, below the address `publicUrl` gives: a CMS that says a page
533
+ * changed, a service's webhook. Check a secret of your own in it, a token or a signature.
534
+ */
535
+ export interface PluginPublicRoute {
536
+ method: PluginHttpMethod;
537
+ path: string;
538
+ handler(request: PluginPublicRequest): unknown | Promise<unknown>;
539
+ }
540
+ /** What a shared route's handler gets: nobody is signed in, and no tenant yet. */
541
+ export interface PluginSharedRequest {
542
+ request: Request;
543
+ /** The address below the plugin's shared one. */
544
+ path: string;
545
+ params: Record<string, string>;
546
+ query: URLSearchParams;
547
+ /**
548
+ * Runs `work` inside the tenant whose public address has this ref (`server.publicRef()`),
549
+ * when the tenant is active and has the plugin. Throws with the status `404` and the code
550
+ * `not_found` otherwise.
551
+ */
552
+ inTenant<T>(ref: string, work: () => T | Promise<T>): Promise<T>;
553
+ }
554
+ /**
555
+ * A route for every tenant at once, at the address `sharedUrl` gives: for a service that posts
556
+ * to one webhook for all of them (one account of the runtime's, one app). The call names its
557
+ * tenant only by what it carries – the ref of the tenant's address, handed to the service
558
+ * before (`publicRef`) – so check the service's signature first, then `inTenant`.
559
+ */
560
+ export interface PluginSharedRoute {
561
+ method: PluginHttpMethod;
562
+ path: string;
563
+ handler(request: PluginSharedRequest): unknown | Promise<unknown>;
564
+ }
565
+ /** A kind of use of a number of the Manage-App's. */
566
+ export type PluginChannelKind = "sms" | "call" | "whatsapp";
567
+ /**
568
+ * The numbers a Manage-App gives the tenant (docs/manage-contract.md): its own number for
569
+ * texts and calls, asked for and assigned there, and the numbers every tenant shares.
570
+ */
571
+ export interface PluginChannels {
572
+ number: {
573
+ /** With the country code: `+43…`. */
574
+ number: string;
575
+ /** ISO 3166, upper case: `AT`. */
576
+ country: string;
577
+ kinds: PluginChannelKind[];
578
+ /** The provider's id of the number (Twilio's `PN…`); null when none was entered. */
579
+ providerRef: string | null;
580
+ } | null;
581
+ /** The tenant's open request for its number; null for none. */
582
+ request: {
583
+ id: string;
584
+ country: string;
585
+ wish: string | null;
586
+ createdAt: string;
587
+ } | null;
588
+ shared: {
589
+ number: string;
590
+ country: string;
591
+ kinds: PluginChannelKind[];
592
+ }[];
593
+ /** The tenant's plan has a number of its own; false on a plan without one (Free). */
594
+ allowed: boolean;
595
+ }
596
+ /** An account a plugin connected for a space: a calendar, a mailbox. */
597
+ export interface PluginConnection {
598
+ id: string;
599
+ /** The space it was connected for. */
600
+ space: string;
601
+ /** The built-in connector behind it: `google-calendar`, `microsoft-outlook`. */
602
+ connector: string;
603
+ /** The account, as the provider names it: an e-mail address. */
604
+ label: string;
605
+ /** The actions it was connected for; the provider granted what they need. */
606
+ actions: string[];
607
+ createdAt: string;
608
+ }
609
+ /**
610
+ * Accounts a plugin connects on its own, for a space rather than for a wizard's run: the
611
+ * runtime's built-in connectors (Google, Microsoft, …), signed in with OAuth. The runtime keeps
612
+ * the tokens sealed, refreshes them, and on a local install connects Google through the linked
613
+ * account's Manage-App, as it does for wizards.
614
+ */
615
+ /** A connector a plugin may connect: signed in with OAuth, or with keys the person types. */
616
+ export interface PluginConnectorOffer {
617
+ id: string;
618
+ name: string;
619
+ auth: "oauth2" | "api_key";
620
+ /** `api_key`: what to ask the person for, in this order. */
621
+ fields?: {
622
+ key: string;
623
+ label: string;
624
+ placeholder?: string;
625
+ /** Default: true. */
626
+ required?: boolean;
627
+ /** A password field: never shown again. */
628
+ secret?: boolean;
629
+ }[];
630
+ }
631
+ export interface PluginConnections {
632
+ /** Of these connector ids, the ones a person can connect on this runtime now, with their names. */
633
+ available(connectors: string[]): Promise<PluginConnectorOffer[]>;
634
+ /**
635
+ * The provider's sign-in page of an `oauth2` connector. Open it in a window: when the person
636
+ * is done, the window posts `{ type: "wizards:connected", ok }` to the studio and closes.
637
+ * `actions` are the connector's actions the plugin will call; only the rights they need are
638
+ * asked for. `lang` is the language the person reads; the page they come back to speaks it,
639
+ * else their browser's.
640
+ */
641
+ start(input: {
642
+ space: string;
643
+ connector: string;
644
+ actions: string[];
645
+ lang?: "de" | "en";
646
+ }): Promise<{
647
+ url: string;
648
+ }>;
649
+ /**
650
+ * Connects an `api_key` connector with the keys the person typed (`fields` of the offer, by
651
+ * key). The connector tries them once first; keys it refuses throw an error with the status
652
+ * `400` and the code `credentials`, whose message says what was wrong. The same account
653
+ * connected again for the space replaces the first connection's keys and actions.
654
+ */
655
+ connect(input: {
656
+ space: string;
657
+ connector: string;
658
+ actions: string[];
659
+ credentials: Record<string, string>;
660
+ }): Promise<PluginConnection>;
661
+ /** What is connected for the space, the newest first. */
662
+ list(space: string): Promise<PluginConnection[]>;
663
+ /** One connection by its id, or null. */
664
+ get(connectionId: string): Promise<PluginConnection | null>;
665
+ /**
666
+ * Runs one of the connector's actions with the connection's account. Throws when the action
667
+ * is not one the connection was made for, or when the provider refuses (the account was
668
+ * disconnected there: connect again).
669
+ */
670
+ call<T = unknown>(connectionId: string, action: string, input: Record<string, unknown>): Promise<T>;
671
+ /** Forgets the connection and its tokens. */
672
+ remove(connectionId: string): Promise<void>;
673
+ }
674
+ /**
675
+ * A wizard a plugin brings as a template: offered beside the marketplace's starters when a
676
+ * wizard is made, and to the assistant and AI apps as an example to copy.
677
+ */
678
+ export interface PluginStarter {
679
+ /** Lower case, digits and `-`; the starter is known as `<plugin id>.<id>`. */
680
+ id: string;
681
+ title: string;
682
+ /** What it makes, in one or two sentences. */
683
+ description: string;
684
+ /** The language its texts are in. Default: English. */
685
+ language?: "de" | "en";
686
+ /** A complete wizard definition. Checked when it is registered. */
687
+ definition: unknown;
688
+ /** Workspace files it needs (widgets, sample data), by path. */
689
+ files?: Record<string, string | Uint8Array>;
690
+ }
691
+ /**
692
+ * What the space assistant is told when the admin talks to it from the plugin's own page (the
693
+ * studio half's `studio.Assistant`): what the page holds now, so it can change it with the
694
+ * plugin's assistant tools.
695
+ */
696
+ export interface PluginAssistantPage {
697
+ /** Text for the assistant: the state of the page, in a few lines. Cut at 8,000 characters. */
698
+ block(space: PluginSpace): string | null | Promise<string | null>;
699
+ }
700
+ /** What a runner can take in and show; the runtime works out per wizard how far it gets. */
701
+ export interface PluginRunnerCapabilities {
702
+ /** The field kinds the runner asks itself (`text`, `select`, `image`, …); the rest hand off. */
703
+ input: string[];
704
+ output: {
705
+ /** What it shows as it is: `text`, `data`, `image`, `video`, `voice`, `document`, `dashboard`, `widget`, `film`, `surface`. */
706
+ shows: string[];
707
+ /** What it shows as a picture with a link to the real thing. Anything else is a link. */
708
+ pictures: string[];
709
+ };
710
+ /** A sign-in is typed on a page the model never sees: only a browser can take it. */
711
+ asks: ("confirm" | "login")[];
712
+ review: ("accept" | "regenerate" | "edit")[];
713
+ /** Stays through a step that takes minutes, with a note now and then. */
714
+ waits: boolean;
715
+ /** How a link to the run page reaches the person for what the runner cannot do itself. */
716
+ handoff: ("screen" | "thread" | "sms" | "push")[];
717
+ }
718
+ /** What a page runner's handler gets: the wizard behind the address, nobody signed in. */
719
+ export interface PluginRunnerRequest {
720
+ request: Request;
721
+ tenantId: string;
722
+ wizard: {
723
+ id: string;
724
+ token: string;
725
+ title: string;
726
+ };
727
+ /** The rest of the address below `/w/<token>/<runner>`. */
728
+ path: string;
729
+ query: URLSearchParams;
730
+ }
731
+ /**
732
+ * Where a person reaches a wizard through a channel runner, as the share dialog shows it: the
733
+ * number with the keyword that picks the wizard there, and the link that opens the channel with
734
+ * the keyword written.
735
+ */
736
+ export interface PluginRunnerAddress {
737
+ /** The number people write to or call, with the country code: `+43660…`. */
738
+ number?: string | null;
739
+ /** The word that picks this wizard on that number. */
740
+ keyword?: string | null;
741
+ /** Opens the channel with the keyword written (`sms:…`, `https://wa.me/…`): copied, and as a QR code. */
742
+ link?: string | null;
743
+ }
744
+ /** A runner's problem, with what the share dialog's row says about it. */
745
+ export interface PluginRunnerProblem {
746
+ /** In the owner's words, as a text problem. */
747
+ text: string;
748
+ /**
749
+ * `setup` (the default): something to set up, the row offers "Einrichten". `waiting`: set up
750
+ * and waiting for someone else (a number asked for), nothing to do. `plan`: the tenant's plan
751
+ * does not have it, the row offers the plans.
752
+ */
753
+ kind?: "setup" | "waiting" | "plan";
754
+ /** What the row says instead of "Noch nicht eingerichtet": "Nummer angefragt", "Ab Pro". */
755
+ note?: {
756
+ de: string;
757
+ en: string;
758
+ };
759
+ /** `plan`: the plan that has it, for the row's button ("Pro ansehen"). */
760
+ plan?: string;
761
+ }
762
+ /**
763
+ * A runner: a door a wizard runs through, beside the built-in page and chat. A `page` runner is
764
+ * served at `/w/<token>/<id>` for every wizard that switched it on; a `channel` runner has an
765
+ * address of its own (a number, a bot) and drives runs from its webhooks.
766
+ */
767
+ export interface PluginRunner {
768
+ /** Lower case, digits and "-", at most 24 characters; the sub-path of the wizard's address. */
769
+ id: string;
770
+ label: {
771
+ de: string;
772
+ en: string;
773
+ };
774
+ kind: "page" | "channel";
775
+ capabilities: PluginRunnerCapabilities;
776
+ /** A page runner: what its address answers with. */
777
+ page?(request: PluginRunnerRequest): Response | Promise<Response>;
778
+ /**
779
+ * Why the runner cannot be used in the current tenant right now, in the owner's words ("Not
780
+ * connected: Settings → WhatsApp"), or null when it can. Asked inside the tenant whenever the
781
+ * studio lists the runners; a runner with a problem cannot be switched on. A text is something
782
+ * to set up: the share dialog's row says so and offers "Einrichten". An object says what kind of
783
+ * problem it is.
784
+ */
785
+ problem?(): string | PluginRunnerProblem | null | Promise<string | PluginRunnerProblem | null>;
786
+ /**
787
+ * A channel runner: where a person reaches the wizard, for the share dialog; null while the
788
+ * runner is not set up. Asked inside the tenant for each wizard that has the runner on.
789
+ */
790
+ address?(wizard: {
791
+ id: string;
792
+ title: string;
793
+ token: string;
794
+ }): PluginRunnerAddress | null | Promise<PluginRunnerAddress | null>;
795
+ }
796
+ /**
797
+ * How a run answers a review: accept it, with edits where the review allows (a text, or the
798
+ * data of a json step), or ask for one of the shown steps again.
799
+ */
800
+ export type PluginReviewAction = {
801
+ type: "accept";
802
+ edits?: Record<string, string | Record<string, unknown>>;
803
+ } | {
804
+ type: "regenerate";
805
+ target: string;
806
+ note: string;
807
+ items?: number[];
808
+ };
809
+ /** A field of the page a run waits for, as the report lists it. */
810
+ export interface PluginRunField {
811
+ id: string;
812
+ label: string;
813
+ kind: string;
814
+ required: boolean;
815
+ options?: string[];
816
+ placeholder?: string;
817
+ help?: string;
818
+ default?: unknown;
819
+ value?: unknown;
820
+ columns?: unknown;
821
+ /** An image or file field that takes several: the value is then a list of asset ids. */
822
+ multiple?: boolean;
823
+ /** Answerable as a value; false for what only the person's device gives (a file, a signature). */
824
+ inChat: boolean;
825
+ /** A condition on earlier answers; the field is asked only while it holds. */
826
+ when?: unknown;
827
+ /** Whether `when` holds on what is known now. */
828
+ shown?: boolean;
829
+ }
830
+ /** What a run waits for: a page, a review, or a question of a running step. */
831
+ export type PluginRunWaiting = {
832
+ page: string;
833
+ title: string;
834
+ known: Record<string, unknown>;
835
+ fields: PluginRunField[];
836
+ hint: string;
837
+ } | {
838
+ review: string;
839
+ title: string;
840
+ show: string[];
841
+ editable: boolean;
842
+ hint: string;
843
+ } | {
844
+ ask: string;
845
+ kind: "confirm";
846
+ reason: string;
847
+ service: string;
848
+ action: string;
849
+ input: string;
850
+ hint: string;
851
+ } | {
852
+ ask: string;
853
+ kind: "login";
854
+ reason: string;
855
+ site: string;
856
+ hint: string;
857
+ };
858
+ /** What a run did so far, as the MCP tools report it: outputs with signed links, cost, errors. */
859
+ export interface PluginRunReport {
860
+ runId: string;
861
+ wizardId: string;
862
+ mode: "test" | "live";
863
+ /** The wizard's language: what to say to the person in. */
864
+ lang: "de" | "en";
865
+ status: "waiting_input" | "running" | "done" | "failed" | "cancelled";
866
+ step: {
867
+ id: string;
868
+ type: string;
869
+ title: string;
870
+ } | null;
871
+ passed: string[];
872
+ waitingFor?: PluginRunWaiting;
873
+ error: string | null;
874
+ credits: number;
875
+ events: {
876
+ step: string | null;
877
+ type: string;
878
+ message: string;
879
+ }[];
880
+ outputs: {
881
+ stepId: string;
882
+ title: string;
883
+ text?: string;
884
+ json?: string;
885
+ assets: {
886
+ name: string;
887
+ mime: string;
888
+ url: string;
889
+ }[];
890
+ /** Signed download links by format, valid one hour. */
891
+ downloads: Record<string, string>;
892
+ /** A signed link to the output as a PNG, for a door that shows a picture with a link; null where it is one already, or has no picture. */
893
+ picture: string | null;
894
+ }[];
895
+ /** The run page, for what the door cannot do itself. */
896
+ browserUrl: string | null;
897
+ }
898
+ /** Something changed on a run: a new event, or its status (`event` null). */
899
+ export interface PluginRunSignal {
900
+ runId: string;
901
+ event: {
902
+ id: number;
903
+ at: string;
904
+ stepId: string | null;
905
+ type: "step_started" | "step_done" | "tool" | "info" | "error";
906
+ message: string;
907
+ /** The same as the run page shows it, in both languages; null for free text. */
908
+ note: {
909
+ code: string;
910
+ text: {
911
+ de: string;
912
+ en: string;
913
+ };
914
+ } | null;
915
+ } | null;
916
+ }
917
+ /**
918
+ * Runs a plugin's door drives: the functions behind the MCP tools, on the public path. The
919
+ * plugin keeps who the person is; the runtime keeps only a hash of it as the run's visitor, so
920
+ * what the wizard remembers is theirs on the run page too.
921
+ */
922
+ export interface PluginRuns {
923
+ /** Starts a live run of a published wizard, by its share token or id, for a person of the door. */
924
+ start(input: ({
925
+ token: string;
926
+ } | {
927
+ wizardId: string;
928
+ }) & {
929
+ person: {
930
+ channel: string;
931
+ id: string;
932
+ };
933
+ /** Answers for the first page; what did not fit comes back as `refused`. */
934
+ answers?: Record<string, unknown>;
935
+ /** Kept on the run; default: the plugin's id. */
936
+ runner?: string;
937
+ }): Promise<{
938
+ runId: string;
939
+ /** Opens the run's own routes (`/api/runs/<id>?rt=…`); `handoffUrl` carries it. */
940
+ ticket: string;
941
+ refused: {
942
+ field: string;
943
+ message: string;
944
+ }[] | null;
945
+ }>;
946
+ /**
947
+ * The run as it stands, after waiting up to `waitSeconds` (at most 45) while it works. A door
948
+ * that asks a page one field at a time passes what it has as `draft`: the fields' `shown` is
949
+ * then worked out on those answers, so a field whose condition depends on another of the same
950
+ * page comes and goes as it would on the screen.
951
+ */
952
+ report(runId: string, options?: {
953
+ waitSeconds?: number;
954
+ draft?: Record<string, unknown>;
955
+ }): Promise<PluginRunReport>;
956
+ /** The published wizards of the tenant that switched the given runner on: what the door offers. */
957
+ wizards(runner: string): Promise<{
958
+ wizardId: string;
959
+ token: string;
960
+ title: string;
961
+ lang: "de" | "en";
962
+ }[]>;
963
+ answerPage(runId: string, stepId: string, values: Record<string, unknown>): Promise<void>;
964
+ review(runId: string, stepId: string, action: PluginReviewAction): Promise<void>;
965
+ /** A running step asks before it changes something in a connected account: allow it once, or skip. */
966
+ answerAsk(runId: string, askId: string, answer: "allow" | "skip"): Promise<void>;
967
+ control(runId: string, action: "back" | "retry" | "cancel"): Promise<void>;
968
+ /** Hears every change of the run until the function returned is called. */
969
+ subscribe(runId: string, listener: (signal: PluginRunSignal) => void): () => void;
970
+ /** The run page with the run's ticket: the link to send the person for what the door cannot do. */
971
+ handoffUrl(runId: string): Promise<string>;
972
+ /** A file of the person (a photo sent in the thread): the asset id goes into a field with `answerPage`. */
973
+ upload(runId: string, file: {
974
+ data: Uint8Array | ArrayBuffer;
975
+ mime: string;
976
+ name: string;
977
+ }): Promise<{
978
+ assetId: string;
979
+ }>;
980
+ /** What is said in a recording of the person (a voice message), written down and charged to the run. */
981
+ transcribe(runId: string, file: {
982
+ data: Uint8Array | ArrayBuffer;
983
+ mime: string;
984
+ }): Promise<{
985
+ text: string;
986
+ }>;
987
+ }
988
+ /** Keys a plugin keeps: sealed with the runtime's own key, as it seals a connection's tokens. */
989
+ export interface PluginSecrets {
990
+ /** Anything that is JSON, as a sealed string to keep in a table. */
991
+ seal(value: unknown): string;
992
+ /** What was sealed, or null when it was sealed on another install. */
993
+ unseal<T = unknown>(sealed: string): T | null;
994
+ }
995
+ export interface PluginServerApi {
996
+ registerHttpRoute(route: PluginRoute): void;
997
+ /** A runner the owner can switch on per wizard. */
998
+ registerRunner(runner: PluginRunner): void;
999
+ /** Runs the plugin's door drives. */
1000
+ runs: PluginRuns;
1001
+ /**
1002
+ * The tenant's realtime speech model, for a live conversation a plugin drives itself (a call):
1003
+ * the key and the model the chat's live voice runs on. Throws with the status `503` and the
1004
+ * code `no_model` while none is set up.
1005
+ */
1006
+ speech: {
1007
+ conversation(): Promise<{
1008
+ provider: "openai";
1009
+ apiKey: string;
1010
+ model: string;
1011
+ }>;
1012
+ };
1013
+ registerTool<S extends z.ZodType>(tool: PluginTool<S>): void;
1014
+ /** A block and tools for every agent step of a space's wizards, or a block for its HTML steps. */
1015
+ registerSpaceContext(context: PluginSpaceContext): void;
1016
+ /** A tool of the space assistant. */
1017
+ registerAssistantTool<S extends z.ZodType>(tool: PluginAssistantTool<S>): void;
1018
+ /** What the space assistant is told when the admin talks to it from the plugin's own page. */
1019
+ registerAssistantContext(context: PluginAssistantPage): void;
1020
+ registerPublicRoute(route: PluginPublicRoute): void;
1021
+ /** The full address of a public route for the current tenant: what to hand to whoever calls it. */
1022
+ publicUrl(path: string): Promise<string>;
1023
+ /** The part of `publicUrl` that names the current tenant: what a shared route's call carries. */
1024
+ publicRef(): Promise<string>;
1025
+ /** A route for every tenant at once (one webhook of a service for all of them). */
1026
+ registerSharedRoute(route: PluginSharedRoute): void;
1027
+ /**
1028
+ * Keys the plugin holds across the runtime's tenants, each for one tenant at a time: a keyword
1029
+ * on a number every tenant shares, who writes to it, a number a tenant connected. A shared
1030
+ * route finds its tenant with `holder` and enters it with `inTenant`. Keys are the plugin's
1031
+ * own, 1 to 200 characters.
1032
+ */
1033
+ claims: {
1034
+ /** Takes `key` for the current tenant; false when another tenant holds it. */
1035
+ take(key: string): Promise<boolean>;
1036
+ /** Gives `key` to the current tenant, whoever held it. */
1037
+ put(key: string): Promise<void>;
1038
+ /** Gives up the current tenant's `key`; nothing when another tenant holds it. */
1039
+ drop(key: string): Promise<void>;
1040
+ /** The ref of the tenant that holds `key` (for `inTenant`), or null. Asked outside a tenant too. */
1041
+ holder(key: string): Promise<string | null>;
1042
+ /** Whether the current tenant holds `key`. */
1043
+ mine(key: string): Promise<boolean>;
1044
+ };
1045
+ /** The full address of a shared route, the same for every tenant. */
1046
+ sharedUrl(path: string): string;
1047
+ /**
1048
+ * The numbers the Manage-App gives the current tenant. `get` is null on a runtime without a
1049
+ * Manage-App; there `request` and `withdraw` throw, and `book` books nothing.
1050
+ */
1051
+ channels: {
1052
+ /** Kept for a minute. */
1053
+ get(): Promise<PluginChannels | null>;
1054
+ /**
1055
+ * A person of the tenant asks for its number. Throws with the status `403` and the code
1056
+ * `plan` on a plan without one, `409` and `has_number` when the tenant has it; asking again
1057
+ * answers the open request.
1058
+ */
1059
+ request(input: {
1060
+ userId: string;
1061
+ /** ISO 3166: `AT`. */
1062
+ country: string;
1063
+ wish?: string | null;
1064
+ lang: "de" | "en";
1065
+ }): Promise<NonNullable<PluginChannels["request"]>>;
1066
+ /** Takes the open request back; false when there was none. */
1067
+ withdraw(): Promise<boolean>;
1068
+ /**
1069
+ * Books what the tenant's number carried, at the Manage-App's prices: `sms` by segment
1070
+ * (sent or received), `call` by started minute, `whatsapp` by message sent. The same `key`
1071
+ * twice books once.
1072
+ */
1073
+ book(input: {
1074
+ kind: "sms" | "call" | "whatsapp";
1075
+ quantity: number;
1076
+ key: string;
1077
+ runId?: string | null;
1078
+ }): Promise<{
1079
+ credits: number;
1080
+ }>;
1081
+ };
1082
+ /**
1083
+ * Runs `handler` for every tenant that has the plugin, at most once per `everyMs` (a minute
1084
+ * at least), inside that tenant. When it ran is kept: a restart does not start the count again,
1085
+ * and a runtime that was off runs it once when it starts, not once per turn it missed. One turn
1086
+ * per tenant at a time; a turn that throws counts as run.
1087
+ */
1088
+ every(name: string, everyMs: number, handler: (tick: PluginTick) => void | Promise<void>): void;
1089
+ /** The space's search index, which `project_search` asks. */
1090
+ index: PluginIndex;
1091
+ /** Knowledge of a space: pages, tables and files the plugin writes, with their categories. */
1092
+ spaceData: PluginSpaceData;
1093
+ spaces: {
1094
+ /** The space's brand, of the current tenant; null for a space it does not have. */
1095
+ brand(space: string): Promise<PluginBrand | null>;
1096
+ };
1097
+ web: PluginWeb;
1098
+ documents: PluginDocuments;
1099
+ /**
1100
+ * A folder of `.sql` files with the plugin's own tables. Every tenant database gets each file
1101
+ * once, in the order of the file names. Nothing is taken back when the plugin unloads.
1102
+ */
1103
+ registerMigrations(folder: string): void;
1104
+ /** The listener runs inside the tenant the event belongs to. */
1105
+ on<E extends keyof PluginEvents>(event: E, listener: (payload: PluginEvents[E]) => void | Promise<void>): void;
1106
+ /** The database of the tenant the current request, step or event belongs to. */
1107
+ getTenantDb(): PluginDb;
1108
+ /**
1109
+ * Asks a model of the current tenant, on the models its studio is set up with; the call is
1110
+ * paid like any other of the tenant's. When no model is set up it throws an error with the
1111
+ * status 503 and the code `no_model`, which a route passes on as it is.
1112
+ */
1113
+ generate<T = undefined>(request: PluginGenerateRequest<T>): Promise<PluginGenerateResult<T>>;
1114
+ /** Accounts the plugin connects for a space, through the runtime's built-in connectors. */
1115
+ connections: PluginConnections;
1116
+ /** Keys of the plugin's own (a shop's API tokens), sealed before they go into a table. */
1117
+ secrets: PluginSecrets;
1118
+ /** A wizard the plugin brings as a template. */
1119
+ registerStarter(starter: PluginStarter): void;
1120
+ /** Something to undo when the plugin unloads or reloads: a timer, a socket. */
1121
+ onUnload(dispose: () => void | Promise<void>): void;
1122
+ }
1123
+ export interface WizardsPluginApi {
1124
+ plugin: PluginManifest;
1125
+ server: PluginServerApi;
1126
+ /** Settings of this install: its `.env`. Name them after the plugin (`NOTIFY_URL`). */
1127
+ config: {
1128
+ get(key: string): string | undefined;
1129
+ };
1130
+ /**
1131
+ * Feature switches of the tenant at hand: the runtime's own (`teamPlans`) and the plugin's,
1132
+ * named with its id (`contacts.leadScoring`), as the Manage-App, the install's `.features`
1133
+ * file or `FEATURES` set them. Off unless something turned a switch on.
1134
+ */
1135
+ features: {
1136
+ /** `has("leadScoring")` asks for the plugin's own switch; a full name (`teamPlans`) for any. */
1137
+ has(name: string): Promise<boolean>;
1138
+ all(): Promise<Record<string, boolean>>;
1139
+ };
1140
+ log: {
1141
+ info(...args: unknown[]): void;
1142
+ warn(...args: unknown[]): void;
1143
+ error(...args: unknown[]): void;
1144
+ };
1145
+ /** A file of the plugin as an absolute path. */
1146
+ resolvePath(relative: string): string;
1147
+ }
1148
+ export type WizardsPluginFactory = (wizards: WizardsPluginApi) => void | Promise<void>;
1149
+ /** Types the factory; it does nothing else. */
1150
+ export declare function definePlugin(factory: WizardsPluginFactory): WizardsPluginFactory;