@dxos/app-framework 0.8.3 → 0.8.4-main.28f8d3d

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 (314) hide show
  1. package/.swc/plugins/v7_linux_x86_64_13.0.0/c614d7475354583212fbd7669acbae95b9832c305bf51bdaabe2e6de05abb6bf +0 -0
  2. package/.swc/plugins/v7_linux_x86_64_13.0.0/fce1bdb8e20a094e4af08bad09cc81497ed0e2e7c51223b07d371063cca18429 +0 -0
  3. package/README.md +0 -8
  4. package/dist/lib/browser/{app-graph-builder-BI4VVKSW.mjs → app-graph-builder-MOVKFH3J.mjs} +5 -5
  5. package/dist/lib/browser/app-graph-builder-MOVKFH3J.mjs.map +7 -0
  6. package/dist/lib/browser/{chunk-EHM4UI3V.mjs → chunk-NKCIDYDI.mjs} +322 -242
  7. package/dist/lib/browser/chunk-NKCIDYDI.mjs.map +7 -0
  8. package/dist/lib/browser/{chunk-WWEJRWFX.mjs → chunk-ORWHM7CO.mjs} +2 -2
  9. package/dist/lib/browser/{chunk-DIBVO47Z.mjs → chunk-OSBZFKMO.mjs} +58 -36
  10. package/dist/lib/browser/chunk-OSBZFKMO.mjs.map +7 -0
  11. package/dist/lib/browser/index.mjs +10 -10
  12. package/dist/lib/browser/index.mjs.map +3 -3
  13. package/dist/lib/browser/{intent-dispatcher-XVBOMF2Y.mjs → intent-dispatcher-FTTJLVGN.mjs} +2 -2
  14. package/dist/lib/browser/{intent-resolver-3QMBXLIY.mjs → intent-resolver-ZCGEAG3E.mjs} +4 -4
  15. package/dist/lib/browser/intent-resolver-ZCGEAG3E.mjs.map +7 -0
  16. package/dist/lib/browser/meta.json +1 -1
  17. package/dist/lib/browser/{store-5H7XPJGA.mjs → store-3QB6Q2BC.mjs} +3 -3
  18. package/dist/lib/browser/{store-5H7XPJGA.mjs.map → store-3QB6Q2BC.mjs.map} +1 -1
  19. package/dist/lib/browser/testing/index.mjs +3 -3
  20. package/dist/lib/browser/testing/index.mjs.map +2 -2
  21. package/dist/lib/browser/worker.mjs +1 -1
  22. package/dist/lib/node-esm/{app-graph-builder-NROP6RPQ.mjs → app-graph-builder-ODE4B5GT.mjs} +5 -5
  23. package/dist/lib/node-esm/app-graph-builder-ODE4B5GT.mjs.map +7 -0
  24. package/dist/lib/node-esm/{chunk-I6BVZMAH.mjs → chunk-UMZQERLE.mjs} +2 -2
  25. package/dist/lib/node-esm/{chunk-FHNZZWP4.mjs → chunk-WU3QN5B6.mjs} +58 -36
  26. package/dist/lib/node-esm/chunk-WU3QN5B6.mjs.map +7 -0
  27. package/dist/lib/node-esm/{chunk-2J6FVECI.mjs → chunk-YEN7NKTF.mjs} +322 -242
  28. package/dist/lib/node-esm/chunk-YEN7NKTF.mjs.map +7 -0
  29. package/dist/lib/node-esm/index.mjs +10 -10
  30. package/dist/lib/node-esm/index.mjs.map +3 -3
  31. package/dist/lib/node-esm/{intent-dispatcher-7JPGLCQ5.mjs → intent-dispatcher-YQIQ55LJ.mjs} +2 -2
  32. package/dist/lib/node-esm/{intent-resolver-VY4X5UHN.mjs → intent-resolver-KG27L7EQ.mjs} +4 -4
  33. package/dist/lib/node-esm/intent-resolver-KG27L7EQ.mjs.map +7 -0
  34. package/dist/lib/node-esm/meta.json +1 -1
  35. package/dist/lib/node-esm/{store-UKD2R2KA.mjs → store-TIJAVO3D.mjs} +3 -3
  36. package/dist/lib/node-esm/{store-UKD2R2KA.mjs.map → store-TIJAVO3D.mjs.map} +1 -1
  37. package/dist/lib/node-esm/testing/index.mjs +3 -3
  38. package/dist/lib/node-esm/testing/index.mjs.map +2 -2
  39. package/dist/lib/node-esm/worker.mjs +1 -1
  40. package/dist/types/src/App.d.ts +1 -1
  41. package/dist/types/src/App.d.ts.map +1 -1
  42. package/dist/types/src/common/capabilities.d.ts +82 -7
  43. package/dist/types/src/common/capabilities.d.ts.map +1 -1
  44. package/dist/types/src/common/events.d.ts.map +1 -1
  45. package/dist/types/src/common/surface.d.ts +1 -1
  46. package/dist/types/src/common/surface.d.ts.map +1 -1
  47. package/dist/types/src/core/capabilities.d.ts.map +1 -1
  48. package/dist/types/src/core/manager.d.ts +6 -2
  49. package/dist/types/src/core/manager.d.ts.map +1 -1
  50. package/dist/types/src/playground/generator/Toolbar.d.ts.map +1 -1
  51. package/dist/types/src/playground/generator/generator.d.ts.map +1 -1
  52. package/dist/types/src/playground/logger/Toolbar.d.ts.map +1 -1
  53. package/dist/types/src/playground/logger/plugin.d.ts.map +1 -1
  54. package/dist/types/src/playground/playground.stories.d.ts.map +1 -1
  55. package/dist/types/src/plugin-intent/IntentPlugin.d.ts.map +1 -1
  56. package/dist/types/src/plugin-intent/intent-dispatcher.d.ts +2 -2
  57. package/dist/types/src/plugin-intent/intent-dispatcher.d.ts.map +1 -1
  58. package/dist/types/src/plugin-settings/SettingsPlugin.d.ts.map +1 -1
  59. package/dist/types/src/plugin-settings/app-graph-builder.d.ts.map +1 -1
  60. package/dist/types/src/plugin-settings/intent-resolver.d.ts.map +1 -1
  61. package/dist/types/src/plugin-settings/store.d.ts.map +1 -1
  62. package/dist/types/src/plugin-settings/translations.d.ts +7 -8
  63. package/dist/types/src/plugin-settings/translations.d.ts.map +1 -1
  64. package/dist/types/src/react/ErrorBoundary.d.ts +13 -14
  65. package/dist/types/src/react/ErrorBoundary.d.ts.map +1 -1
  66. package/dist/types/src/react/IntentContext.d.ts.map +1 -1
  67. package/dist/types/src/react/Surface.d.ts.map +1 -1
  68. package/dist/types/src/react/Surface.stories.d.ts.map +1 -1
  69. package/dist/types/src/react/common.d.ts.map +1 -1
  70. package/dist/types/src/react/useCapabilities.d.ts.map +1 -1
  71. package/dist/types/src/testing/withPluginManager.d.ts +2 -0
  72. package/dist/types/src/testing/withPluginManager.d.ts.map +1 -1
  73. package/dist/types/src/testing/withPluginManager.stories.d.ts.map +1 -1
  74. package/dist/types/tsconfig.tsbuildinfo +1 -1
  75. package/moon.yml +14 -0
  76. package/package.json +32 -28
  77. package/src/App.tsx +13 -5
  78. package/src/common/capabilities.ts +103 -9
  79. package/src/common/events.ts +3 -1
  80. package/src/common/surface.ts +1 -1
  81. package/src/core/capabilities.test.ts +1 -1
  82. package/src/core/capabilities.ts +1 -0
  83. package/src/core/manager.test.ts +5 -5
  84. package/src/core/manager.ts +132 -54
  85. package/src/helpers.test.ts +1 -1
  86. package/src/playground/generator/Toolbar.tsx +2 -1
  87. package/src/playground/generator/generator.ts +2 -2
  88. package/src/playground/layout/plugin.ts +1 -1
  89. package/src/playground/logger/Toolbar.tsx +2 -1
  90. package/src/playground/logger/plugin.ts +3 -2
  91. package/src/playground/playground.stories.tsx +4 -3
  92. package/src/plugin-intent/IntentPlugin.ts +2 -1
  93. package/src/plugin-intent/intent-dispatcher.test.ts +1 -1
  94. package/src/plugin-intent/intent-dispatcher.ts +6 -5
  95. package/src/plugin-settings/SettingsPlugin.ts +3 -2
  96. package/src/plugin-settings/app-graph-builder.ts +4 -3
  97. package/src/plugin-settings/intent-resolver.ts +3 -2
  98. package/src/plugin-settings/store.ts +1 -1
  99. package/src/plugin-settings/translations.ts +4 -2
  100. package/src/react/ErrorBoundary.tsx +24 -15
  101. package/src/react/IntentContext.tsx +3 -2
  102. package/src/react/Surface.stories.tsx +3 -2
  103. package/src/react/Surface.tsx +4 -3
  104. package/src/react/common.ts +2 -1
  105. package/src/react/useCapabilities.ts +2 -1
  106. package/src/testing/withPluginManager.stories.tsx +3 -2
  107. package/src/testing/withPluginManager.tsx +8 -5
  108. package/tsconfig.json +4 -1
  109. package/vitest.config.ts +5 -2
  110. package/.eslintrc.cjs +0 -9
  111. package/README.yml +0 -5
  112. package/dist/lib/browser/app-graph-builder-BI4VVKSW.mjs.map +0 -7
  113. package/dist/lib/browser/chunk-DIBVO47Z.mjs.map +0 -7
  114. package/dist/lib/browser/chunk-EHM4UI3V.mjs.map +0 -7
  115. package/dist/lib/browser/intent-resolver-3QMBXLIY.mjs.map +0 -7
  116. package/dist/lib/node/app-graph-builder-H7QVE4MJ.cjs +0 -146
  117. package/dist/lib/node/app-graph-builder-H7QVE4MJ.cjs.map +0 -7
  118. package/dist/lib/node/chunk-G774ASXO.cjs +0 -58
  119. package/dist/lib/node/chunk-G774ASXO.cjs.map +0 -7
  120. package/dist/lib/node/chunk-VSOSVDQ3.cjs +0 -1551
  121. package/dist/lib/node/chunk-VSOSVDQ3.cjs.map +0 -7
  122. package/dist/lib/node/chunk-YGAY3H34.cjs +0 -429
  123. package/dist/lib/node/chunk-YGAY3H34.cjs.map +0 -7
  124. package/dist/lib/node/index.cjs +0 -193
  125. package/dist/lib/node/index.cjs.map +0 -7
  126. package/dist/lib/node/intent-dispatcher-C3SVKJ62.cjs +0 -32
  127. package/dist/lib/node/intent-dispatcher-C3SVKJ62.cjs.map +0 -7
  128. package/dist/lib/node/intent-resolver-IOJDYO34.cjs +0 -46
  129. package/dist/lib/node/intent-resolver-IOJDYO34.cjs.map +0 -7
  130. package/dist/lib/node/meta.json +0 -1
  131. package/dist/lib/node/store-ESF5VR57.cjs +0 -45
  132. package/dist/lib/node/store-ESF5VR57.cjs.map +0 -7
  133. package/dist/lib/node/testing/index.cjs +0 -119
  134. package/dist/lib/node/testing/index.cjs.map +0 -7
  135. package/dist/lib/node/worker.cjs +0 -101
  136. package/dist/lib/node/worker.cjs.map +0 -7
  137. package/dist/lib/node-esm/app-graph-builder-NROP6RPQ.mjs.map +0 -7
  138. package/dist/lib/node-esm/chunk-2J6FVECI.mjs.map +0 -7
  139. package/dist/lib/node-esm/chunk-FHNZZWP4.mjs.map +0 -7
  140. package/dist/lib/node-esm/intent-resolver-VY4X5UHN.mjs.map +0 -7
  141. package/project.json +0 -29
  142. package/typedoc/.nojekyll +0 -1
  143. package/typedoc/assets/hierarchy.js +0 -1
  144. package/typedoc/assets/highlight.css +0 -106
  145. package/typedoc/assets/icons.js +0 -18
  146. package/typedoc/assets/icons.svg +0 -1
  147. package/typedoc/assets/main.js +0 -60
  148. package/typedoc/assets/navigation.js +0 -1
  149. package/typedoc/assets/search.js +0 -1
  150. package/typedoc/assets/style.css +0 -1640
  151. package/typedoc/classes/CollaborationActions.InsertContent.html +0 -421
  152. package/typedoc/classes/ErrorBoundary.html +0 -125
  153. package/typedoc/classes/IntentAction.ShowUndo.html +0 -227
  154. package/typedoc/classes/IntentAction.Track.html +0 -266
  155. package/typedoc/classes/LayoutAction.AddToast.html +0 -265
  156. package/typedoc/classes/LayoutAction.Close.html +0 -382
  157. package/typedoc/classes/LayoutAction.Expose.html +0 -265
  158. package/typedoc/classes/LayoutAction.Open.html +0 -1123
  159. package/typedoc/classes/LayoutAction.RevertWorkspace.html +0 -343
  160. package/typedoc/classes/LayoutAction.ScrollIntoView.html +0 -460
  161. package/typedoc/classes/LayoutAction.Set.html +0 -460
  162. package/typedoc/classes/LayoutAction.SetLayoutMode.html +0 -499
  163. package/typedoc/classes/LayoutAction.SwitchWorkspace.html +0 -265
  164. package/typedoc/classes/LayoutAction.UpdateComplementary.html +0 -616
  165. package/typedoc/classes/LayoutAction.UpdateDialog.html +0 -1123
  166. package/typedoc/classes/LayoutAction.UpdateLayout.html +0 -461
  167. package/typedoc/classes/LayoutAction.UpdatePopover.html +0 -1435
  168. package/typedoc/classes/LayoutAction.UpdateSidebar.html +0 -616
  169. package/typedoc/classes/Plugin.html +0 -6
  170. package/typedoc/classes/PluginContext.html +0 -38
  171. package/typedoc/classes/PluginManager.html +0 -43
  172. package/typedoc/classes/PluginModule.html +0 -18
  173. package/typedoc/classes/SettingsAction.Open.html +0 -226
  174. package/typedoc/classes/SettingsAction.OpenPluginRegistry.html +0 -265
  175. package/typedoc/functions/Events.createStateEvent.html +0 -2
  176. package/typedoc/functions/IntentPlugin.html +0 -1
  177. package/typedoc/functions/SettingsPlugin.html +0 -1
  178. package/typedoc/functions/allOf.html +0 -2
  179. package/typedoc/functions/chain.html +0 -3
  180. package/typedoc/functions/contributes.html +0 -2
  181. package/typedoc/functions/createDispatcher.html +0 -3
  182. package/typedoc/functions/createIntent.html +0 -6
  183. package/typedoc/functions/createResolver.html +0 -2
  184. package/typedoc/functions/createSurface.html +0 -2
  185. package/typedoc/functions/defineCapability.html +0 -2
  186. package/typedoc/functions/defineEvent.html +0 -2
  187. package/typedoc/functions/defineModule.html +0 -2
  188. package/typedoc/functions/definePlugin.html +0 -2
  189. package/typedoc/functions/eventKey.html +0 -2
  190. package/typedoc/functions/getEvents.html +0 -2
  191. package/typedoc/functions/isAllOf.html +0 -2
  192. package/typedoc/functions/isOneOf.html +0 -2
  193. package/typedoc/functions/isSurfaceAvailable.html +0 -2
  194. package/typedoc/functions/lazy.html +0 -2
  195. package/typedoc/functions/oneOf.html +0 -2
  196. package/typedoc/functions/useApp.html +0 -6
  197. package/typedoc/functions/useAppGraph.html +0 -1
  198. package/typedoc/functions/useCapabilities.html +0 -3
  199. package/typedoc/functions/useCapability.html +0 -4
  200. package/typedoc/functions/useIntentDispatcher.html +0 -1
  201. package/typedoc/functions/useIntentResolver.html +0 -1
  202. package/typedoc/functions/useLayout.html +0 -1
  203. package/typedoc/functions/usePluginManager.html +0 -2
  204. package/typedoc/hierarchy.html +0 -1
  205. package/typedoc/index.html +0 -16
  206. package/typedoc/interfaces/LayoutAction.Toast.html +0 -10
  207. package/typedoc/media/LICENSE +0 -8
  208. package/typedoc/modules/Capabilities.html +0 -1
  209. package/typedoc/modules/CollaborationActions.html +0 -1
  210. package/typedoc/modules/Events.html +0 -1
  211. package/typedoc/modules/IntentAction.html +0 -1
  212. package/typedoc/modules/LayoutAction.html +0 -2
  213. package/typedoc/modules/SettingsAction.html +0 -1
  214. package/typedoc/modules.html +0 -1
  215. package/typedoc/types/ActivationEvent.html +0 -8
  216. package/typedoc/types/ActivationEvents.html +0 -2
  217. package/typedoc/types/AnyCapability.html +0 -1
  218. package/typedoc/types/AnyIntent.html +0 -1
  219. package/typedoc/types/AnyIntentChain.html +0 -1
  220. package/typedoc/types/AnyIntentEffectResult.html +0 -1
  221. package/typedoc/types/AnyIntentResolver.html +0 -1
  222. package/typedoc/types/AnyIntentResult.html +0 -1
  223. package/typedoc/types/Capabilities.FileUploader.html +0 -1
  224. package/typedoc/types/Capabilities.IntentResolver.html +0 -1
  225. package/typedoc/types/Capabilities.Layout.html +0 -1
  226. package/typedoc/types/Capabilities.Metadata.html +0 -1
  227. package/typedoc/types/Capabilities.ReactContext.html +0 -1
  228. package/typedoc/types/Capabilities.ReactRoot.html +0 -1
  229. package/typedoc/types/Capabilities.ReactSurface.html +0 -1
  230. package/typedoc/types/Capabilities.Settings.html +0 -4
  231. package/typedoc/types/Capability.html +0 -9
  232. package/typedoc/types/CreateAppOptions.html +0 -10
  233. package/typedoc/types/FileInfo.html +0 -1
  234. package/typedoc/types/Intent.html +0 -10
  235. package/typedoc/types/IntentChain.html +0 -6
  236. package/typedoc/types/IntentContext.html +0 -5
  237. package/typedoc/types/IntentData.html +0 -1
  238. package/typedoc/types/IntentDispatcher.html +0 -2
  239. package/typedoc/types/IntentDispatcherResult.html +0 -2
  240. package/typedoc/types/IntentEffectDefinition.html +0 -2
  241. package/typedoc/types/IntentEffectResult.html +0 -15
  242. package/typedoc/types/IntentParams.html +0 -3
  243. package/typedoc/types/IntentResolver.html +0 -2
  244. package/typedoc/types/IntentResultData.html +0 -1
  245. package/typedoc/types/IntentSchema.html +0 -1
  246. package/typedoc/types/IntentUndo.html +0 -2
  247. package/typedoc/types/InterfaceDef.html +0 -4
  248. package/typedoc/types/Label.html +0 -1
  249. package/typedoc/types/NodeSerializer.html +0 -8
  250. package/typedoc/types/PluginManagerOptions.html +0 -6
  251. package/typedoc/types/PluginMeta.html +0 -21
  252. package/typedoc/types/PromiseIntentDispatcher.html +0 -2
  253. package/typedoc/types/PromiseIntentUndo.html +0 -2
  254. package/typedoc/types/Resource.html +0 -1
  255. package/typedoc/types/ResourceKey.html +0 -1
  256. package/typedoc/types/ResourceLanguage.html +0 -1
  257. package/typedoc/types/SerializedNode.html +0 -4
  258. package/typedoc/types/SurfaceComponent.html +0 -2
  259. package/typedoc/types/SurfaceDefinition.html +0 -2
  260. package/typedoc/types/SurfaceProps.html +0 -4
  261. package/typedoc/variables/Capabilities.AnchorSort.html +0 -1
  262. package/typedoc/variables/Capabilities.AppGraph.html +0 -1
  263. package/typedoc/variables/Capabilities.AppGraphBuilder.html +0 -1
  264. package/typedoc/variables/Capabilities.AppGraphSerializer.html +0 -1
  265. package/typedoc/variables/Capabilities.ArtifactDefinition.html +0 -1
  266. package/typedoc/variables/Capabilities.FileUploader.html +0 -1
  267. package/typedoc/variables/Capabilities.IntentDispatcher.html +0 -1
  268. package/typedoc/variables/Capabilities.IntentResolver.html +0 -1
  269. package/typedoc/variables/Capabilities.Layout.html +0 -1
  270. package/typedoc/variables/Capabilities.Metadata.html +0 -1
  271. package/typedoc/variables/Capabilities.Null.html +0 -1
  272. package/typedoc/variables/Capabilities.PluginManager.html +0 -1
  273. package/typedoc/variables/Capabilities.ReactContext.html +0 -1
  274. package/typedoc/variables/Capabilities.ReactRoot.html +0 -1
  275. package/typedoc/variables/Capabilities.ReactSurface.html +0 -1
  276. package/typedoc/variables/Capabilities.RxRegistry.html +0 -1
  277. package/typedoc/variables/Capabilities.Settings.html +0 -1
  278. package/typedoc/variables/Capabilities.SettingsStore.html +0 -1
  279. package/typedoc/variables/Capabilities.Tools.html +0 -1
  280. package/typedoc/variables/Capabilities.Translations.html +0 -1
  281. package/typedoc/variables/Events.AppGraphReady.html +0 -2
  282. package/typedoc/variables/Events.DispatcherReady.html +0 -2
  283. package/typedoc/variables/Events.LayoutReady.html +0 -1
  284. package/typedoc/variables/Events.SettingsReady.html +0 -2
  285. package/typedoc/variables/Events.SetupAppGraph.html +0 -2
  286. package/typedoc/variables/Events.SetupArtifactDefinition.html +0 -2
  287. package/typedoc/variables/Events.SetupIntentResolver.html +0 -2
  288. package/typedoc/variables/Events.SetupMetadata.html +0 -2
  289. package/typedoc/variables/Events.SetupReactSurface.html +0 -2
  290. package/typedoc/variables/Events.SetupSettings.html +0 -2
  291. package/typedoc/variables/Events.SetupTranslations.html +0 -2
  292. package/typedoc/variables/Events.Startup.html +0 -2
  293. package/typedoc/variables/FileInfoSchema.html +0 -1
  294. package/typedoc/variables/INTENT_ACTION.html +0 -1
  295. package/typedoc/variables/INTENT_PLUGIN.html +0 -1
  296. package/typedoc/variables/LAYOUT_ACTION.html +0 -1
  297. package/typedoc/variables/LAYOUT_PLUGIN.html +0 -1
  298. package/typedoc/variables/Label.html +0 -1
  299. package/typedoc/variables/LayoutAction.Toast.html +0 -1
  300. package/typedoc/variables/LayoutAction.UPDATE_LAYOUT.html +0 -1
  301. package/typedoc/variables/PluginManagerProvider.html +0 -2
  302. package/typedoc/variables/Resource.html +0 -2
  303. package/typedoc/variables/ResourceKey.html +0 -1
  304. package/typedoc/variables/ResourceLanguage.html +0 -1
  305. package/typedoc/variables/SETTINGS_ACTION.html +0 -1
  306. package/typedoc/variables/SETTINGS_ID.html +0 -1
  307. package/typedoc/variables/SETTINGS_KEY.html +0 -1
  308. package/typedoc/variables/SETTINGS_PLUGIN.html +0 -1
  309. package/typedoc/variables/Surface.html +0 -2
  310. package/typedoc/variables/defaultFileTypes.html +0 -1
  311. /package/dist/lib/browser/{chunk-WWEJRWFX.mjs.map → chunk-ORWHM7CO.mjs.map} +0 -0
  312. /package/dist/lib/browser/{intent-dispatcher-XVBOMF2Y.mjs.map → intent-dispatcher-FTTJLVGN.mjs.map} +0 -0
  313. /package/dist/lib/node-esm/{chunk-I6BVZMAH.mjs.map → chunk-UMZQERLE.mjs.map} +0 -0
  314. /package/dist/lib/node-esm/{intent-dispatcher-7JPGLCQ5.mjs.map → intent-dispatcher-YQIQ55LJ.mjs.map} +0 -0
@@ -1,110 +1,16 @@
1
- // packages/sdk/app-framework/src/plugin-intent/intent-dispatcher.ts
2
- import { Effect as Effect3, Option, pipe as pipe2, Ref as Ref2 } from "effect";
1
+ // src/plugin-intent/intent-dispatcher.ts
2
+ import { Effect as Effect3, Option, Ref as Ref3, pipe as pipe2 } from "effect";
3
3
  import { live as live2 } from "@dxos/live-object";
4
4
  import { log as log3 } from "@dxos/log";
5
5
  import { byPosition } from "@dxos/util";
6
6
 
7
- // packages/sdk/app-framework/src/plugin-intent/actions.ts
8
- import { Schema as Schema2 } from "effect";
9
-
10
- // packages/sdk/app-framework/src/plugin-intent/intent.ts
11
- import { Schema } from "effect";
12
- var createIntent = (schema, data = {}, params = {}) => {
13
- const _ = Schema.validateSync(schema.fields.input)(data);
14
- const intent = {
15
- ...params,
16
- _schema: schema,
17
- id: schema._tag,
18
- data
19
- };
20
- return {
21
- first: intent,
22
- last: intent,
23
- all: [
24
- intent
25
- ]
26
- };
27
- };
28
- var chain = (schema, data = {}, params = {}) => (intent) => {
29
- const intents = "all" in intent ? intent.all : [
30
- intent
31
- ];
32
- const first = intents[0];
33
- const last = {
34
- ...params,
35
- _schema: schema,
36
- id: schema._tag,
37
- data
38
- };
39
- return {
40
- first,
41
- last,
42
- all: [
43
- ...intents,
44
- last
45
- ]
46
- };
47
- };
48
- var Label = Schema.Union(Schema.String, Schema.mutable(Schema.Tuple(Schema.String, Schema.mutable(Schema.Struct({
49
- ns: Schema.String,
50
- count: Schema.optional(Schema.Number),
51
- defaultValue: Schema.optional(Schema.String)
52
- })))));
53
-
54
- // packages/sdk/app-framework/src/plugin-intent/actions.ts
55
- var INTENT_PLUGIN = "dxos.org/plugin/intent";
56
- var INTENT_ACTION = `${INTENT_PLUGIN}/action`;
57
- (function(IntentAction2) {
58
- class Track extends Schema2.TaggedClass()(`${INTENT_ACTION}/track`, {
59
- input: Schema2.Struct({
60
- intents: Schema2.Array(Schema2.String),
61
- error: Schema2.optional(Schema2.String)
62
- }),
63
- output: Schema2.Void
64
- }) {
65
- }
66
- IntentAction2.Track = Track;
67
- class ShowUndo extends Schema2.TaggedClass()(`${INTENT_ACTION}/show-undo`, {
68
- input: Schema2.Struct({
69
- message: Label
70
- }),
71
- output: Schema2.Void
72
- }) {
73
- }
74
- IntentAction2.ShowUndo = ShowUndo;
75
- })(IntentAction || (IntentAction = {}));
76
- var IntentAction;
77
-
78
- // packages/sdk/app-framework/src/plugin-intent/errors.ts
79
- var BaseError = class extends Error {
80
- constructor(code, message, context) {
81
- super(message ?? code, {
82
- cause: context
83
- }), this.code = code, this.context = context;
84
- this.name = code;
85
- Object.setPrototypeOf(this, new.target.prototype);
86
- }
87
- };
88
- var NoResolversError = class extends BaseError {
89
- constructor(action) {
90
- super("NO_RESOLVERS", "No resolvers were found for the action", {
91
- action
92
- });
93
- }
94
- };
95
- var CycleDetectedError = class extends BaseError {
96
- constructor(context) {
97
- super("CYCLE_DETECTED", "Intent execution limit exceeded. This is likely due to an infinite loop within intent resolvers.", context);
98
- }
99
- };
100
-
101
- // packages/sdk/app-framework/src/core/capabilities.ts
7
+ // src/core/capabilities.ts
102
8
  import { Rx } from "@effect-rx/rx-react";
103
9
  import { Effect } from "effect";
104
10
  import { Trigger } from "@dxos/async";
105
11
  import { invariant } from "@dxos/invariant";
106
12
  import { log } from "@dxos/log";
107
- var __dxlog_file = "/home/runner/work/dxos/dxos/packages/sdk/app-framework/src/core/capabilities.ts";
13
+ var __dxlog_file = "/__w/dxos/dxos/packages/sdk/app-framework/src/core/capabilities.ts";
108
14
  var InterfaceDefTypeId = Symbol.for("InterfaceDefTypeId");
109
15
  var defineCapability = (identifier) => {
110
16
  return {
@@ -112,6 +18,8 @@ var defineCapability = (identifier) => {
112
18
  };
113
19
  };
114
20
  var CapabilityImpl = class {
21
+ moduleId;
22
+ implementation;
115
23
  constructor(moduleId, implementation) {
116
24
  this.moduleId = moduleId;
117
25
  this.implementation = implementation;
@@ -129,31 +37,44 @@ var lazy = (c) => async (props) => {
129
37
  return async () => getCapability(props);
130
38
  };
131
39
  var PluginContext = class {
132
- constructor({ registry, activate, reset }) {
133
- this._capabilityImpls = Rx.family(() => {
134
- return Rx.make([]).pipe(Rx.keepAlive);
135
- });
136
- this._capabilities = Rx.family((id) => {
137
- return Rx.make((get) => {
138
- const current = get(this._capabilityImpls(id));
139
- return current.map((c) => c.implementation);
140
- });
40
+ _registry;
41
+ _capabilityImpls = Rx.family(() => {
42
+ return Rx.make([]).pipe(Rx.keepAlive);
43
+ });
44
+ _capabilities = Rx.family((id) => {
45
+ return Rx.make((get) => {
46
+ const current = get(this._capabilityImpls(id));
47
+ return current.map((c) => c.implementation);
141
48
  });
142
- this._capability = Rx.family((id) => {
143
- return Rx.make((get) => {
144
- const current = get(this._capabilities(id));
145
- invariant(current.length > 0, `No capability found for ${id}`, {
146
- F: __dxlog_file,
147
- L: 117,
148
- S: this,
149
- A: [
150
- "current.length > 0",
151
- "`No capability found for ${id}`"
152
- ]
153
- });
154
- return current[0];
49
+ });
50
+ _capability = Rx.family((id) => {
51
+ return Rx.make((get) => {
52
+ const current = get(this._capabilities(id));
53
+ invariant(current.length > 0, `No capability found for ${id}`, {
54
+ F: __dxlog_file,
55
+ L: 118,
56
+ S: this,
57
+ A: [
58
+ "current.length > 0",
59
+ "`No capability found for ${id}`"
60
+ ]
155
61
  });
62
+ return current[0];
156
63
  });
64
+ });
65
+ /**
66
+ * Activates plugins based on the activation event.
67
+ * @param event The activation event.
68
+ * @returns Whether the activation was successful.
69
+ */
70
+ activate;
71
+ /**
72
+ * Re-activates the modules that were activated by the event.
73
+ * @param event The activation event.
74
+ * @returns Whether the reset was successful.
75
+ */
76
+ reset;
77
+ constructor({ registry, activate, reset }) {
157
78
  this._registry = registry;
158
79
  this.activate = activate;
159
80
  this.reset = reset;
@@ -177,7 +98,7 @@ var PluginContext = class {
177
98
  count: current.length
178
99
  }, {
179
100
  F: __dxlog_file,
180
- L: 161,
101
+ L: 162,
181
102
  S: this,
182
103
  C: (f, a) => f(...a)
183
104
  });
@@ -198,7 +119,7 @@ var PluginContext = class {
198
119
  count: current.length
199
120
  }, {
200
121
  F: __dxlog_file,
201
- L: 180,
122
+ L: 181,
202
123
  S: this,
203
124
  C: (f, a) => f(...a)
204
125
  });
@@ -207,7 +128,7 @@ var PluginContext = class {
207
128
  id: interfaceDef.identifier
208
129
  }, {
209
130
  F: __dxlog_file,
210
- L: 182,
131
+ L: 183,
211
132
  S: this,
212
133
  C: (f, a) => f(...a)
213
134
  });
@@ -274,7 +195,7 @@ var PluginContext = class {
274
195
  }
275
196
  };
276
197
 
277
- // packages/sdk/app-framework/src/core/events.ts
198
+ // src/core/events.ts
278
199
  var defineEvent = (id, specifier) => {
279
200
  return {
280
201
  id,
@@ -296,21 +217,29 @@ var getEvents = (events) => "type" in events ? events.events : [
296
217
  events
297
218
  ];
298
219
 
299
- // packages/sdk/app-framework/src/core/manager.ts
220
+ // src/core/manager.ts
300
221
  import { Registry } from "@effect-rx/rx-react";
301
222
  import { untracked } from "@preact/signals-core";
302
- import { Array as A, Effect as Effect2, Either, Match, pipe } from "effect";
223
+ import { Array, Duration, Effect as Effect2, Fiber, HashSet, Match, Ref, pipe } from "effect";
303
224
  import { Event } from "@dxos/async";
304
225
  import { live } from "@dxos/live-object";
305
226
  import { log as log2 } from "@dxos/log";
306
- var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/sdk/app-framework/src/core/manager.ts";
227
+ var __dxlog_file2 = "/__w/dxos/dxos/packages/sdk/app-framework/src/core/manager.ts";
307
228
  var isPromise = (value) => {
308
229
  return value !== null && typeof value === "object" && "then" in value;
309
230
  };
310
231
  var PluginManager = class {
232
+ activation = new Event();
233
+ context;
234
+ registry;
235
+ // TODO(wittjosiah): Replace with Rx.
236
+ _state;
237
+ _pluginLoader;
238
+ _capabilities = /* @__PURE__ */ new Map();
239
+ _moduleMemoMap = /* @__PURE__ */ new Map();
240
+ _activatingEvents = Effect2.runSync(Ref.make([]));
241
+ _activatingModules = Effect2.runSync(Ref.make([]));
311
242
  constructor({ pluginLoader, plugins = [], core = plugins.map(({ meta }) => meta.id), enabled = [], registry }) {
312
- this.activation = new Event();
313
- this._capabilities = /* @__PURE__ */ new Map();
314
243
  this.registry = registry ?? Registry.make();
315
244
  this.context = new PluginContext({
316
245
  registry: this.registry,
@@ -324,8 +253,8 @@ var PluginManager = class {
324
253
  enabled,
325
254
  modules: [],
326
255
  active: [],
327
- pendingReset: [],
328
- eventsFired: []
256
+ eventsFired: [],
257
+ pendingReset: []
329
258
  });
330
259
  plugins.forEach((plugin) => this._addPlugin(plugin));
331
260
  core.forEach((id) => this.enable(id));
@@ -397,7 +326,7 @@ var PluginManager = class {
397
326
  id
398
327
  }, {
399
328
  F: __dxlog_file2,
400
- L: 154,
329
+ L: 157,
401
330
  S: this,
402
331
  C: (f, a) => f(...a)
403
332
  });
@@ -416,7 +345,7 @@ var PluginManager = class {
416
345
  id
417
346
  }, {
418
347
  F: __dxlog_file2,
419
- L: 167,
348
+ L: 170,
420
349
  S: this,
421
350
  C: (f, a) => f(...a)
422
351
  });
@@ -437,7 +366,7 @@ var PluginManager = class {
437
366
  ]
438
367
  }, {
439
368
  F: __dxlog_file2,
440
- L: 182,
369
+ L: 185,
441
370
  S: this,
442
371
  C: (f, a) => f(...a)
443
372
  });
@@ -457,7 +386,7 @@ var PluginManager = class {
457
386
  id
458
387
  }, {
459
388
  F: __dxlog_file2,
460
- L: 200,
389
+ L: 203,
461
390
  S: this,
462
391
  C: (f, a) => f(...a)
463
392
  });
@@ -479,7 +408,7 @@ var PluginManager = class {
479
408
  id
480
409
  }, {
481
410
  F: __dxlog_file2,
482
- L: 217,
411
+ L: 220,
483
412
  S: this,
484
413
  C: (f, a) => f(...a)
485
414
  });
@@ -531,7 +460,7 @@ var PluginManager = class {
531
460
  id: plugin.meta.id
532
461
  }, {
533
462
  F: __dxlog_file2,
534
- L: 270,
463
+ L: 273,
535
464
  S: this,
536
465
  C: (f, a) => f(...a)
537
466
  });
@@ -546,7 +475,7 @@ var PluginManager = class {
546
475
  id
547
476
  }, {
548
477
  F: __dxlog_file2,
549
- L: 279,
478
+ L: 283,
550
479
  S: this,
551
480
  C: (f, a) => f(...a)
552
481
  });
@@ -562,7 +491,7 @@ var PluginManager = class {
562
491
  id: module.id
563
492
  }, {
564
493
  F: __dxlog_file2,
565
- L: 289,
494
+ L: 293,
566
495
  S: this,
567
496
  C: (f, a) => f(...a)
568
497
  });
@@ -577,7 +506,7 @@ var PluginManager = class {
577
506
  id
578
507
  }, {
579
508
  F: __dxlog_file2,
580
- L: 298,
509
+ L: 303,
581
510
  S: this,
582
511
  C: (f, a) => f(...a)
583
512
  });
@@ -605,13 +534,13 @@ var PluginManager = class {
605
534
  _setPendingResetByModule(module) {
606
535
  return untracked(() => {
607
536
  const activationEvents = getEvents(module.activatesOn).map(eventKey).filter((key) => this._state.eventsFired.includes(key));
608
- const pendingReset = Array.from(new Set(activationEvents)).filter((event) => !this._state.pendingReset.includes(event));
537
+ const pendingReset = Array.fromIterable(new Set(activationEvents)).filter((event) => !this._state.pendingReset.includes(event));
609
538
  if (pendingReset.length > 0) {
610
539
  log2("pending reset", {
611
540
  events: pendingReset
612
541
  }, {
613
542
  F: __dxlog_file2,
614
- L: 336,
543
+ L: 341,
615
544
  S: this,
616
545
  C: (f, a) => f(...a)
617
546
  });
@@ -623,35 +552,40 @@ var PluginManager = class {
623
552
  * @internal
624
553
  */
625
554
  // TODO(wittjosiah): Improve error typing.
626
- _activate(event) {
555
+ _activate(event, params) {
627
556
  return Effect2.gen(this, function* () {
628
557
  const key = typeof event === "string" ? event : eventKey(event);
629
558
  log2("activating", {
630
- key
559
+ key,
560
+ ...params
631
561
  }, {
632
562
  F: __dxlog_file2,
633
- L: 349,
563
+ L: 357,
634
564
  S: this,
635
565
  C: (f, a) => f(...a)
636
566
  });
567
+ yield* Ref.update(this._activatingEvents, (activating) => Array.append(activating, key));
637
568
  const pendingIndex = this._state.pendingReset.findIndex((event2) => event2 === key);
638
569
  if (pendingIndex !== -1) {
639
570
  this._state.pendingReset.splice(pendingIndex, 1);
640
571
  }
572
+ const activatingEvents = yield* this._activatingEvents;
573
+ const activatingModules = yield* this._activatingModules;
641
574
  const modules = this._getInactiveModulesByEvent(key).filter((module) => {
642
575
  const allOf2 = isAllOf(module.activatesOn);
643
576
  if (!allOf2) {
644
577
  return true;
645
578
  }
646
579
  const events = module.activatesOn.events.filter((event2) => eventKey(event2) !== key);
647
- return events.every((event2) => this._state.eventsFired.includes(eventKey(event2)));
580
+ return events.every((event2) => this._state.eventsFired.includes(eventKey(event2)) || activatingEvents.includes(eventKey(event2))) && !activatingModules.includes(module.id);
648
581
  });
582
+ yield* Ref.update(this._activatingModules, (activating) => Array.appendAll(activating, modules.map((module) => module.id)));
649
583
  if (modules.length === 0) {
650
584
  log2("no modules to activate", {
651
585
  key
652
586
  }, {
653
587
  F: __dxlog_file2,
654
- L: 365,
588
+ L: 388,
655
589
  S: this,
656
590
  C: (f, a) => f(...a)
657
591
  });
@@ -665,7 +599,7 @@ var PluginManager = class {
665
599
  modules: modules.map((module) => module.id)
666
600
  }, {
667
601
  F: __dxlog_file2,
668
- L: 372,
602
+ L: 395,
669
603
  S: this,
670
604
  C: (f, a) => f(...a)
671
605
  });
@@ -673,29 +607,36 @@ var PluginManager = class {
673
607
  event: key,
674
608
  state: "activating"
675
609
  });
676
- const getCapabilities = yield* Effect2.all(modules.map(({ activate }) => Effect2.tryPromise({
677
- try: async () => activate(this.context),
678
- catch: (error) => error
679
- })), {
610
+ yield* pipe(modules, Array.flatMap((module) => module.activatesBefore ?? []), HashSet.fromIterable, HashSet.toValues, Array.filter((event2) => !activatingEvents.includes(eventKey(event2))), Array.map((event2) => this._activate(event2, {
611
+ before: key
612
+ })), Effect2.allWith({
680
613
  concurrency: "unbounded"
681
- });
682
- const result = yield* pipe(
683
- modules,
684
- A.zip(getCapabilities),
685
- A.map(([module, getCapabilities2]) => this._activateModule(module, getCapabilities2)),
686
- // TODO(wittjosiah): This currently can't be run in parallel.
687
- // Running this with concurrency causes races with `allOf` activation events.
688
- Effect2.all,
689
- Effect2.either
690
- );
691
- if (Either.isLeft(result)) {
614
+ }));
615
+ const getCapabilities = yield* pipe(modules, Array.map((mod) => this._loadModule(mod)), Effect2.allWith({
616
+ concurrency: "unbounded"
617
+ }), Effect2.catchAll((error) => {
692
618
  this.activation.emit({
693
619
  event: key,
694
620
  state: "error",
695
- error: result.left
621
+ error
696
622
  });
697
- yield* Effect2.fail(result.left);
698
- }
623
+ return Effect2.fail(error);
624
+ }));
625
+ yield* pipe(
626
+ modules,
627
+ Array.zip(getCapabilities),
628
+ Array.map(([module, capabilities]) => this._contributeCapabilities(module, capabilities)),
629
+ // TODO(wittjosiah): This currently can't be run in parallel.
630
+ // Running this with concurrency causes races with `allOf` activation events.
631
+ Effect2.all
632
+ );
633
+ yield* pipe(modules, Array.flatMap((module) => module.activatesAfter ?? []), HashSet.fromIterable, HashSet.toValues, Array.filter((event2) => !activatingEvents.includes(eventKey(event2))), Array.map((event2) => this._activate(event2, {
634
+ after: key
635
+ })), Effect2.allWith({
636
+ concurrency: "unbounded"
637
+ }));
638
+ yield* Ref.update(this._activatingEvents, (activating) => Array.filter(activating, (event2) => event2 !== key));
639
+ yield* Ref.update(this._activatingModules, (activating) => Array.filter(activating, (module) => !modules.map((module2) => module2.id).includes(module)));
699
640
  if (!this._state.eventsFired.includes(key)) {
700
641
  this._state.eventsFired.push(key);
701
642
  }
@@ -707,39 +648,76 @@ var PluginManager = class {
707
648
  key
708
649
  }, {
709
650
  F: __dxlog_file2,
710
- L: 406,
651
+ L: 451,
711
652
  S: this,
712
653
  C: (f, a) => f(...a)
713
654
  });
714
655
  return true;
715
656
  });
716
657
  }
717
- _activateModule(module, getCapabilities) {
658
+ // Memoized with _moduleMemoMap
659
+ _loadModule = (mod) => Effect2.tryPromise({
660
+ try: async () => {
661
+ const entry = this._moduleMemoMap.get(mod.id);
662
+ if (entry) {
663
+ return entry;
664
+ }
665
+ const promise = (async () => {
666
+ const start = performance.now();
667
+ let failed = false;
668
+ try {
669
+ log2("loading module", {
670
+ module: mod.id
671
+ }, {
672
+ F: __dxlog_file2,
673
+ L: 470,
674
+ S: this,
675
+ C: (f, a) => f(...a)
676
+ });
677
+ let activationResult = await mod.activate(this.context);
678
+ if (typeof activationResult === "function") {
679
+ activationResult = await activationResult();
680
+ }
681
+ return Array.isArray(activationResult) ? activationResult : [
682
+ activationResult
683
+ ];
684
+ } catch (error) {
685
+ failed = true;
686
+ throw error;
687
+ } finally {
688
+ performance.measure("activate-module", {
689
+ start,
690
+ end: performance.now(),
691
+ detail: {
692
+ module: mod.id
693
+ }
694
+ });
695
+ log2("loaded module", {
696
+ module: mod.id,
697
+ elapsed: performance.now() - start,
698
+ failed
699
+ }, {
700
+ F: __dxlog_file2,
701
+ L: 488,
702
+ S: this,
703
+ C: (f, a) => f(...a)
704
+ });
705
+ }
706
+ })();
707
+ this._moduleMemoMap.set(mod.id, promise);
708
+ return promise;
709
+ },
710
+ catch: (error) => error
711
+ }).pipe(Effect2.withSpan("PluginManager._loadModule"), together(Effect2.sleep(Duration.seconds(10)).pipe(Effect2.andThen(Effect2.sync(() => log2.warn(`module is taking a long time to activate`, {
712
+ module: mod.id
713
+ }, {
714
+ F: __dxlog_file2,
715
+ L: 499,
716
+ S: this,
717
+ C: (f, a) => f(...a)
718
+ }))))));
719
+ _contributeCapabilities(module, capabilities) {
718
720
  return Effect2.gen(this, function* () {
719
- yield* Effect2.all(module.activatesBefore?.map((event) => this._activate(event)) ?? [], {
720
- concurrency: "unbounded"
721
- });
722
- log2("activating module...", {
723
- module: module.id
724
- }, {
725
- F: __dxlog_file2,
726
- L: 421,
727
- S: this,
728
- C: (f, a) => f(...a)
729
- });
730
- const maybeCapabilities = typeof getCapabilities === "function" ? getCapabilities() : getCapabilities;
731
- const resolvedCapabilities = yield* Match.value(maybeCapabilities).pipe(
732
- // TODO(wittjosiah): Activate with an effect?
733
- // Match.when(Effect.isEffect, (effect) => effect),
734
- Match.when(isPromise, (promise) => Effect2.tryPromise({
735
- try: () => promise,
736
- catch: (error) => error
737
- })),
738
- Match.orElse((program) => Effect2.succeed(program))
739
- );
740
- const capabilities = Match.value(resolvedCapabilities).pipe(Match.when(Array.isArray, (array) => array), Match.orElse((value) => [
741
- value
742
- ]));
743
721
  capabilities.forEach((capability) => {
744
722
  this.context.contributeCapability({
745
723
  module: module.id,
@@ -748,17 +726,6 @@ var PluginManager = class {
748
726
  });
749
727
  this._state.active.push(module.id);
750
728
  this._capabilities.set(module.id, capabilities);
751
- log2("activated module", {
752
- module: module.id
753
- }, {
754
- F: __dxlog_file2,
755
- L: 444,
756
- S: this,
757
- C: (f, a) => f(...a)
758
- });
759
- yield* Effect2.all(module.activatesAfter?.map((event) => this._activate(event)) ?? [], {
760
- concurrency: "unbounded"
761
- });
762
729
  });
763
730
  }
764
731
  _deactivate(id) {
@@ -781,10 +748,11 @@ var PluginManager = class {
781
748
  id
782
749
  }, {
783
750
  F: __dxlog_file2,
784
- L: 471,
751
+ L: 533,
785
752
  S: this,
786
753
  C: (f, a) => f(...a)
787
754
  });
755
+ this._moduleMemoMap.delete(id);
788
756
  const capabilities = this._capabilities.get(id);
789
757
  if (capabilities) {
790
758
  for (const capability of capabilities) {
@@ -805,7 +773,7 @@ var PluginManager = class {
805
773
  id
806
774
  }, {
807
775
  F: __dxlog_file2,
808
- L: 497,
776
+ L: 560,
809
777
  S: this,
810
778
  C: (f, a) => f(...a)
811
779
  });
@@ -819,7 +787,7 @@ var PluginManager = class {
819
787
  key
820
788
  }, {
821
789
  F: __dxlog_file2,
822
- L: 505,
790
+ L: 568,
823
791
  S: this,
824
792
  C: (f, a) => f(...a)
825
793
  });
@@ -835,9 +803,20 @@ var PluginManager = class {
835
803
  });
836
804
  }
837
805
  };
806
+ var together = (togetherEffect) => (effect) => Effect2.gen(function* () {
807
+ const togetherFiber = yield* Effect2.fork(togetherEffect);
808
+ const result = yield* effect;
809
+ yield* Fiber.interrupt(togetherFiber);
810
+ return result;
811
+ });
838
812
 
839
- // packages/sdk/app-framework/src/core/plugin.ts
813
+ // src/core/plugin.ts
840
814
  var PluginModule = class {
815
+ id;
816
+ activatesOn;
817
+ activatesBefore;
818
+ activatesAfter;
819
+ activate;
841
820
  constructor(options) {
842
821
  this.id = options.id;
843
822
  this.activatesOn = options.activatesOn;
@@ -848,6 +827,8 @@ var PluginModule = class {
848
827
  };
849
828
  var defineModule = (options) => new PluginModule(options);
850
829
  var Plugin = class {
830
+ meta;
831
+ modules;
851
832
  constructor(meta, modules) {
852
833
  this.meta = meta;
853
834
  this.modules = modules;
@@ -857,10 +838,10 @@ var definePlugin = (meta, modules) => {
857
838
  return new Plugin(meta, modules);
858
839
  };
859
840
 
860
- // packages/sdk/app-framework/src/common/capabilities.ts
841
+ // src/common/capabilities.ts
861
842
  (function(Capabilities2) {
862
- Capabilities2.PluginManager = defineCapability("dxos.org/app-framework/capability/plugin-manager");
863
843
  Capabilities2.Null = defineCapability("dxos.org/app-framework/capability/null");
844
+ Capabilities2.PluginManager = defineCapability("dxos.org/app-framework/capability/plugin-manager");
864
845
  Capabilities2.RxRegistry = defineCapability("dxos.org/app-framework/capability/rx-registry");
865
846
  Capabilities2.ReactContext = defineCapability("dxos.org/app-framework/capability/react-context");
866
847
  Capabilities2.ReactRoot = defineCapability("dxos.org/app-framework/capability/react-root");
@@ -876,33 +857,36 @@ var definePlugin = (meta, modules) => {
876
857
  Capabilities2.Settings = defineCapability("dxos.org/app-framework/capability/settings");
877
858
  Capabilities2.Metadata = defineCapability("dxos.org/app-framework/capability/metadata");
878
859
  Capabilities2.Tools = defineCapability("dxos.org/app-framework/capability/tools");
879
- Capabilities2.ArtifactDefinition = defineCapability("dxos.org/app-framework/capability/artifact-definition");
860
+ Capabilities2.Toolkit = defineCapability("dxos.org/app-framework/capability/ai-toolkit");
861
+ Capabilities2.ToolkitHandler = defineCapability("dxos.org/app-framework/capability/ai-toolkit-handler");
862
+ Capabilities2.BlueprintDefinition = defineCapability("dxos.org/app-framework/capability/blueprint-definition");
863
+ Capabilities2.Functions = defineCapability("dxos.org/app-framework/capability/functions");
880
864
  Capabilities2.FileUploader = defineCapability("dxos.org/app-framework/capability/file-uploader");
881
865
  Capabilities2.AnchorSort = defineCapability("dxos.org/app-framework/capability/anchor-sort");
882
866
  })(Capabilities || (Capabilities = {}));
883
867
  var Capabilities;
884
868
 
885
- // packages/sdk/app-framework/src/common/collaboration.ts
886
- import { Schema as Schema3 } from "effect";
887
- import { Expando, Ref } from "@dxos/echo-schema";
869
+ // src/common/collaboration.ts
870
+ import { Schema } from "effect";
871
+ import { Expando, Ref as Ref2 } from "@dxos/echo-schema";
888
872
  (function(CollaborationActions2) {
889
- class InsertContent extends Schema3.TaggedClass()("assistant/intent-content", {
890
- input: Schema3.Struct({
873
+ class InsertContent extends Schema.TaggedClass()("assistant/intent-content", {
874
+ input: Schema.Struct({
891
875
  target: Expando,
892
- object: Ref(Expando),
893
- at: Schema3.optional(Schema3.String),
894
- label: Schema3.String.pipe(Schema3.optional)
876
+ object: Ref2(Expando),
877
+ at: Schema.optional(Schema.String),
878
+ label: Schema.String.pipe(Schema.optional)
895
879
  }).annotations({
896
880
  description: "Enables plugins to inject content blocks or references into a related entity."
897
881
  }),
898
- output: Schema3.Void
882
+ output: Schema.Void
899
883
  }) {
900
884
  }
901
885
  CollaborationActions2.InsertContent = InsertContent;
902
886
  })(CollaborationActions || (CollaborationActions = {}));
903
887
  var CollaborationActions;
904
888
 
905
- // packages/sdk/app-framework/src/common/events.ts
889
+ // src/common/events.ts
906
890
  (function(Events2) {
907
891
  Events2.Startup = defineEvent("dxos.org/app-framework/event/startup");
908
892
  Events2.SetupReactSurface = defineEvent("dxos.org/app-framework/event/setup-react-surface");
@@ -920,8 +904,8 @@ var CollaborationActions;
920
904
  })(Events || (Events = {}));
921
905
  var Events;
922
906
 
923
- // packages/sdk/app-framework/src/common/file.ts
924
- import { Schema as Schema4 } from "effect";
907
+ // src/common/file.ts
908
+ import { Schema as Schema2 } from "effect";
925
909
  var defaultFileTypes = {
926
910
  images: [
927
911
  "png",
@@ -941,17 +925,88 @@ var defaultFileTypes = {
941
925
  "md"
942
926
  ]
943
927
  };
944
- var FileInfoSchema = Schema4.Struct({
945
- name: Schema4.String,
946
- type: Schema4.String,
947
- url: Schema4.optional(Schema4.String),
948
- cid: Schema4.optional(Schema4.String)
928
+ var FileInfoSchema = Schema2.Struct({
929
+ name: Schema2.String,
930
+ type: Schema2.String,
931
+ url: Schema2.optional(Schema2.String),
932
+ cid: Schema2.optional(Schema2.String)
949
933
  });
950
934
 
951
- // packages/sdk/app-framework/src/common/layout.ts
935
+ // src/common/layout.ts
952
936
  import { Schema as Schema5 } from "effect";
953
937
 
954
- // packages/sdk/app-framework/src/plugin-intent/IntentPlugin.ts
938
+ // src/plugin-intent/actions.ts
939
+ import { Schema as Schema4 } from "effect";
940
+
941
+ // src/plugin-intent/intent.ts
942
+ import { Schema as Schema3 } from "effect";
943
+ var createIntent = (schema, data = {}, params = {}) => {
944
+ const _ = Schema3.validateSync(schema.fields.input)(data);
945
+ const intent = {
946
+ ...params,
947
+ _schema: schema,
948
+ id: schema._tag,
949
+ data
950
+ };
951
+ return {
952
+ first: intent,
953
+ last: intent,
954
+ all: [
955
+ intent
956
+ ]
957
+ };
958
+ };
959
+ var chain = (schema, data = {}, params = {}) => (intent) => {
960
+ const intents = "all" in intent ? intent.all : [
961
+ intent
962
+ ];
963
+ const first = intents[0];
964
+ const last = {
965
+ ...params,
966
+ _schema: schema,
967
+ id: schema._tag,
968
+ data
969
+ };
970
+ return {
971
+ first,
972
+ last,
973
+ all: [
974
+ ...intents,
975
+ last
976
+ ]
977
+ };
978
+ };
979
+ var Label = Schema3.Union(Schema3.String, Schema3.mutable(Schema3.Tuple(Schema3.String, Schema3.mutable(Schema3.Struct({
980
+ ns: Schema3.String,
981
+ count: Schema3.optional(Schema3.Number),
982
+ defaultValue: Schema3.optional(Schema3.String)
983
+ })))));
984
+
985
+ // src/plugin-intent/actions.ts
986
+ var INTENT_PLUGIN = "dxos.org/plugin/intent";
987
+ var INTENT_ACTION = `${INTENT_PLUGIN}/action`;
988
+ (function(IntentAction2) {
989
+ class Track extends Schema4.TaggedClass()(`${INTENT_ACTION}/track`, {
990
+ input: Schema4.Struct({
991
+ intents: Schema4.Array(Schema4.String),
992
+ error: Schema4.optional(Schema4.String)
993
+ }),
994
+ output: Schema4.Void
995
+ }) {
996
+ }
997
+ IntentAction2.Track = Track;
998
+ class ShowUndo extends Schema4.TaggedClass()(`${INTENT_ACTION}/show-undo`, {
999
+ input: Schema4.Struct({
1000
+ message: Label
1001
+ }),
1002
+ output: Schema4.Void
1003
+ }) {
1004
+ }
1005
+ IntentAction2.ShowUndo = ShowUndo;
1006
+ })(IntentAction || (IntentAction = {}));
1007
+ var IntentAction;
1008
+
1009
+ // src/plugin-intent/IntentPlugin.ts
955
1010
  var IntentPlugin = () => definePlugin({
956
1011
  id: INTENT_PLUGIN,
957
1012
  name: "Intent"
@@ -965,11 +1020,11 @@ var IntentPlugin = () => definePlugin({
965
1020
  activatesAfter: [
966
1021
  Events.DispatcherReady
967
1022
  ],
968
- activate: lazy(() => import("./intent-dispatcher-XVBOMF2Y.mjs"))
1023
+ activate: lazy(() => import("./intent-dispatcher-FTTJLVGN.mjs"))
969
1024
  })
970
1025
  ]);
971
1026
 
972
- // packages/sdk/app-framework/src/common/layout.ts
1027
+ // src/common/layout.ts
973
1028
  var LAYOUT_PLUGIN = "dxos.org/plugin/layout";
974
1029
  var LAYOUT_ACTION = `${LAYOUT_PLUGIN}/action`;
975
1030
  (function(LayoutAction2) {
@@ -1306,10 +1361,10 @@ var LAYOUT_ACTION = `${LAYOUT_PLUGIN}/action`;
1306
1361
  })(LayoutAction || (LayoutAction = {}));
1307
1362
  var LayoutAction;
1308
1363
 
1309
- // packages/sdk/app-framework/src/common/surface.ts
1364
+ // src/common/surface.ts
1310
1365
  var createSurface = (definition) => definition;
1311
1366
 
1312
- // packages/sdk/app-framework/src/common/translations.ts
1367
+ // src/common/translations.ts
1313
1368
  import { Schema as Schema6 } from "effect";
1314
1369
  var ResourceKey = Schema6.Union(Schema6.String, Schema6.Record({
1315
1370
  key: Schema6.String,
@@ -1324,14 +1379,39 @@ var Resource = Schema6.Record({
1324
1379
  value: ResourceLanguage
1325
1380
  });
1326
1381
 
1327
- // packages/sdk/app-framework/src/plugin-intent/intent-dispatcher.ts
1328
- var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/sdk/app-framework/src/plugin-intent/intent-dispatcher.ts";
1382
+ // src/plugin-intent/errors.ts
1383
+ var BaseError = class extends Error {
1384
+ code;
1385
+ context;
1386
+ constructor(code, message, context) {
1387
+ super(message ?? code, {
1388
+ cause: context
1389
+ }), this.code = code, this.context = context;
1390
+ this.name = code;
1391
+ Object.setPrototypeOf(this, new.target.prototype);
1392
+ }
1393
+ };
1394
+ var NoResolversError = class extends BaseError {
1395
+ constructor(action) {
1396
+ super("NO_RESOLVERS", "No resolvers were found for the action", {
1397
+ action
1398
+ });
1399
+ }
1400
+ };
1401
+ var CycleDetectedError = class extends BaseError {
1402
+ constructor(context) {
1403
+ super("CYCLE_DETECTED", "Intent execution limit exceeded. This is likely due to an infinite loop within intent resolvers.", context);
1404
+ }
1405
+ };
1406
+
1407
+ // src/plugin-intent/intent-dispatcher.ts
1408
+ var __dxlog_file3 = "/__w/dxos/dxos/packages/sdk/app-framework/src/plugin-intent/intent-dispatcher.ts";
1329
1409
  var EXECUTION_LIMIT = 100;
1330
1410
  var HISTORY_LIMIT = 100;
1331
1411
  var createResolver = (resolver) => resolver;
1332
1412
  var isUndoable = (historyEntry) => historyEntry.length > 0 && historyEntry.every(({ undoable }) => !!undoable);
1333
1413
  var createDispatcher = (getResolvers, { executionLimit = EXECUTION_LIMIT, historyLimit = HISTORY_LIMIT } = {}) => {
1334
- const historyRef = Effect3.runSync(Ref2.make([]));
1414
+ const historyRef = Effect3.runSync(Ref3.make([]));
1335
1415
  const handleIntent = (intent) => Effect3.gen(function* () {
1336
1416
  const candidates = getResolvers().filter((resolver) => resolver.intent._tag === intent.id).filter((resolver) => !resolver.filter || resolver.filter(intent.data)).toSorted(byPosition);
1337
1417
  if (candidates.length === 0) {
@@ -1349,7 +1429,7 @@ var createDispatcher = (getResolvers, { executionLimit = EXECUTION_LIMIT, histor
1349
1429
  if (depth > executionLimit) {
1350
1430
  yield* Effect3.fail(new CycleDetectedError());
1351
1431
  }
1352
- const resultsRef = yield* Ref2.make([]);
1432
+ const resultsRef = yield* Ref3.make([]);
1353
1433
  for (const intent of intentChain.all) {
1354
1434
  const { data: prev } = (yield* resultsRef.get)[0] ?? {};
1355
1435
  const result2 = yield* handleIntent({
@@ -1359,7 +1439,7 @@ var createDispatcher = (getResolvers, { executionLimit = EXECUTION_LIMIT, histor
1359
1439
  ...prev
1360
1440
  }
1361
1441
  });
1362
- yield* Ref2.update(resultsRef, (results2) => [
1442
+ yield* Ref3.update(resultsRef, (results2) => [
1363
1443
  result2,
1364
1444
  ...results2
1365
1445
  ]);
@@ -1374,7 +1454,7 @@ var createDispatcher = (getResolvers, { executionLimit = EXECUTION_LIMIT, histor
1374
1454
  }
1375
1455
  const results = yield* resultsRef.get;
1376
1456
  const result = results[0];
1377
- yield* Ref2.update(historyRef, (history) => {
1457
+ yield* Ref3.update(historyRef, (history) => {
1378
1458
  const next = [
1379
1459
  ...history,
1380
1460
  results
@@ -1398,7 +1478,7 @@ var createDispatcher = (getResolvers, { executionLimit = EXECUTION_LIMIT, histor
1398
1478
  })).catch((error) => {
1399
1479
  log3.catch(error, void 0, {
1400
1480
  F: __dxlog_file3,
1401
- L: 270,
1481
+ L: 271,
1402
1482
  S: void 0,
1403
1483
  C: (f, a) => f(...a)
1404
1484
  });
@@ -1430,7 +1510,7 @@ var createDispatcher = (getResolvers, { executionLimit = EXECUTION_LIMIT, histor
1430
1510
  last: all.at(-1),
1431
1511
  all
1432
1512
  };
1433
- yield* Ref2.update(historyRef, (h) => h.filter((_, index) => index !== last));
1513
+ yield* Ref3.update(historyRef, (h) => h.filter((_, index) => index !== last));
1434
1514
  return yield* dispatch(intent);
1435
1515
  }
1436
1516
  });
@@ -1515,4 +1595,4 @@ export {
1515
1595
  ResourceLanguage,
1516
1596
  Resource
1517
1597
  };
1518
- //# sourceMappingURL=chunk-EHM4UI3V.mjs.map
1598
+ //# sourceMappingURL=chunk-NKCIDYDI.mjs.map