@dxos/app-framework 0.8.4-main.f9ba587 → 0.8.4-main.fd6878d

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