@dxos/plugin-script 0.9.0 → 0.9.1-staging.ee54ba693a

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 (318) hide show
  1. package/PLUGIN.mdl +9 -9
  2. package/dist/lib/neutral/{DeploymentDialog-M3AFYQHC.mjs → DeploymentDialog-7OIIL7LB.mjs} +10 -10
  3. package/dist/lib/neutral/DeploymentDialog-7OIIL7LB.mjs.map +7 -0
  4. package/dist/lib/neutral/{NotebookArticle-NV4AHOOS.mjs → NotebookArticle-AOBB3XGD.mjs} +28 -46
  5. package/dist/lib/neutral/NotebookArticle-AOBB3XGD.mjs.map +7 -0
  6. package/dist/lib/neutral/{ScriptArticle-QW26LOKU.mjs → ScriptArticle-I3DOJARR.mjs} +4 -4
  7. package/dist/lib/neutral/ScriptArticle-I3DOJARR.mjs.map +7 -0
  8. package/dist/lib/neutral/ScriptPlugin.mjs +6 -6
  9. package/dist/lib/neutral/ScriptPlugin.mjs.map +4 -4
  10. package/dist/lib/neutral/ScriptPlugin.node.mjs +3 -3
  11. package/dist/lib/neutral/ScriptPlugin.node.mjs.map +3 -3
  12. package/dist/lib/neutral/{ScriptProperties-RLXNAN3N.mjs → ScriptProperties-RHDQGMGT.mjs} +153 -154
  13. package/dist/lib/neutral/ScriptProperties-RHDQGMGT.mjs.map +7 -0
  14. package/dist/lib/neutral/ScriptSettings-NS3ZY7ZR.mjs +35 -0
  15. package/dist/lib/neutral/ScriptSettings-NS3ZY7ZR.mjs.map +7 -0
  16. package/dist/lib/neutral/{app-graph-builder-7AWFCEQF.mjs → app-graph-builder-POP3CX6G.mjs} +3 -3
  17. package/dist/lib/neutral/{app-graph-builder-7AWFCEQF.mjs.map → app-graph-builder-POP3CX6G.mjs.map} +3 -3
  18. package/dist/lib/neutral/capabilities/index.mjs +8 -8
  19. package/dist/lib/neutral/capabilities/index.mjs.map +3 -3
  20. package/dist/lib/neutral/capabilities/node.mjs +6 -6
  21. package/dist/lib/neutral/capabilities/node.mjs.map +3 -3
  22. package/dist/lib/neutral/{chunk-HABDH5SS.mjs → chunk-652CIABA.mjs} +14 -13
  23. package/dist/lib/neutral/chunk-652CIABA.mjs.map +7 -0
  24. package/dist/lib/neutral/{chunk-TRKXIP2Q.mjs → chunk-6DOWVKIW.mjs} +4 -5
  25. package/dist/lib/neutral/chunk-6DOWVKIW.mjs.map +7 -0
  26. package/dist/lib/neutral/{chunk-BDHDBPVM.mjs → chunk-CHNFYLKW.mjs} +12 -12
  27. package/dist/lib/neutral/chunk-CHNFYLKW.mjs.map +7 -0
  28. package/dist/lib/neutral/{chunk-VXDJH6OL.mjs → chunk-INFWOSTM.mjs} +14 -8
  29. package/dist/lib/neutral/chunk-INFWOSTM.mjs.map +7 -0
  30. package/dist/lib/neutral/{chunk-BKXYHCJ6.mjs → chunk-KSVKXCTX.mjs} +2 -2
  31. package/dist/lib/neutral/chunk-NVV5UYY4.mjs +50 -0
  32. package/dist/lib/neutral/chunk-NVV5UYY4.mjs.map +7 -0
  33. package/dist/lib/neutral/chunk-USJ44FIU.mjs +8 -0
  34. package/dist/lib/neutral/{chunk-XFM63AKT.mjs.map → chunk-USJ44FIU.mjs.map} +1 -1
  35. package/dist/lib/neutral/{chunk-PHKPB5JN.mjs → chunk-WAGQ77UQ.mjs} +16 -16
  36. package/dist/lib/neutral/chunk-WAGQ77UQ.mjs.map +7 -0
  37. package/dist/lib/neutral/components/index.mjs +124 -93
  38. package/dist/lib/neutral/components/index.mjs.map +4 -4
  39. package/dist/lib/neutral/containers/index.mjs +6 -4
  40. package/dist/lib/neutral/containers/index.mjs.map +3 -3
  41. package/dist/lib/neutral/{create-AAA53WDL.mjs → create-SGHWWTET.mjs} +4 -4
  42. package/dist/lib/neutral/{create-AAA53WDL.mjs.map → create-SGHWWTET.mjs.map} +4 -4
  43. package/dist/lib/neutral/{create-object-FZM5ASWM.mjs → create-object-QW66KQWS.mjs} +1 -3
  44. package/dist/lib/neutral/{create-object-FZM5ASWM.mjs.map → create-object-QW66KQWS.mjs.map} +3 -3
  45. package/dist/lib/neutral/{create-script-P46JOEHH.mjs → create-script-CIEJOBIU.mjs} +4 -4
  46. package/dist/lib/neutral/{create-script-P46JOEHH.mjs.map → create-script-CIEJOBIU.mjs.map} +3 -3
  47. package/dist/lib/neutral/{delete-HCQIQFVP.mjs → delete-72RXVLVI.mjs} +3 -3
  48. package/dist/lib/neutral/{delete-HCQIQFVP.mjs.map → delete-72RXVLVI.mjs.map} +1 -1
  49. package/dist/lib/neutral/{deploy-7JVMMHSH.mjs → deploy-PJTJAQZY.mjs} +10 -6
  50. package/dist/lib/neutral/deploy-PJTJAQZY.mjs.map +7 -0
  51. package/dist/lib/neutral/hooks/index.mjs +6 -6
  52. package/dist/lib/neutral/hooks/index.mjs.map +3 -3
  53. package/dist/lib/neutral/index.mjs +9 -9
  54. package/dist/lib/neutral/{inspect-invocations-TAOYDT4H.mjs → inspect-invocations-ZUXVUAML.mjs} +5 -5
  55. package/dist/lib/neutral/inspect-invocations-ZUXVUAML.mjs.map +7 -0
  56. package/dist/lib/neutral/{install-function-FJIE2JAI.mjs → install-function-YFDZLVMJ.mjs} +4 -4
  57. package/dist/lib/neutral/{install-function-FJIE2JAI.mjs.map → install-function-YFDZLVMJ.mjs.map} +1 -1
  58. package/dist/lib/neutral/{invoke-3HVWY2KF.mjs → invoke-CDRBQ2WA.mjs} +4 -4
  59. package/dist/lib/neutral/{invoke-3HVWY2KF.mjs.map → invoke-CDRBQ2WA.mjs.map} +1 -1
  60. package/dist/lib/neutral/meta.json +1 -1
  61. package/dist/lib/neutral/meta.mjs +1 -1
  62. package/dist/lib/neutral/{operation-handler-YMUADD7Y.mjs → operation-handler-M3B6IRMV.mjs} +3 -3
  63. package/dist/lib/neutral/{operation-handler-YMUADD7Y.mjs.map → operation-handler-M3B6IRMV.mjs.map} +1 -1
  64. package/dist/lib/neutral/operations/index.mjs +1 -1
  65. package/dist/lib/neutral/plugin.mjs +2 -2
  66. package/dist/lib/neutral/{query-deployed-functions-F4FHJNWO.mjs → query-deployed-functions-RBQMGON2.mjs} +4 -4
  67. package/dist/lib/neutral/{query-deployed-functions-F4FHJNWO.mjs.map → query-deployed-functions-RBQMGON2.mjs.map} +1 -1
  68. package/dist/lib/neutral/{react-surface-ACNZ35FV.mjs → react-surface-GEXOZLBC.mjs} +7 -8
  69. package/dist/lib/neutral/react-surface-GEXOZLBC.mjs.map +7 -0
  70. package/dist/lib/neutral/{read-RQESBAQI.mjs → read-OY3K5R3V.mjs} +3 -3
  71. package/dist/lib/neutral/{read-RQESBAQI.mjs.map → read-OY3K5R3V.mjs.map} +3 -3
  72. package/dist/lib/neutral/{settings-VJBW4OMK.mjs → settings-FD7HXEY6.mjs} +3 -3
  73. package/dist/lib/neutral/{settings-VJBW4OMK.mjs.map → settings-FD7HXEY6.mjs.map} +3 -3
  74. package/dist/lib/neutral/skill-definition-JZ7UYBT7.mjs +15 -0
  75. package/dist/lib/neutral/skill-definition-JZ7UYBT7.mjs.map +7 -0
  76. package/dist/lib/neutral/skills/index.mjs +10 -0
  77. package/dist/lib/neutral/templates/index.mjs +1 -1
  78. package/dist/lib/neutral/translations.mjs +7 -8
  79. package/dist/lib/neutral/translations.mjs.map +3 -3
  80. package/dist/lib/neutral/types/index.mjs +2 -2
  81. package/dist/lib/neutral/update-Z5VGOLBN.mjs +44 -0
  82. package/dist/lib/neutral/update-Z5VGOLBN.mjs.map +7 -0
  83. package/dist/types/dx.config.d.ts +28 -0
  84. package/dist/types/dx.config.d.ts.map +1 -0
  85. package/dist/types/src/capabilities/app-graph-builder.d.ts +1 -2
  86. package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -1
  87. package/dist/types/src/capabilities/compiler.d.ts +1 -2
  88. package/dist/types/src/capabilities/compiler.d.ts.map +1 -1
  89. package/dist/types/src/capabilities/create-object.d.ts +1 -12
  90. package/dist/types/src/capabilities/create-object.d.ts.map +1 -1
  91. package/dist/types/src/capabilities/index.d.ts +6 -17
  92. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  93. package/dist/types/src/capabilities/node.d.ts +4 -15
  94. package/dist/types/src/capabilities/node.d.ts.map +1 -1
  95. package/dist/types/src/capabilities/react-surface.d.ts +2 -2
  96. package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
  97. package/dist/types/src/capabilities/settings.d.ts +1 -3
  98. package/dist/types/src/capabilities/settings.d.ts.map +1 -1
  99. package/dist/types/src/capabilities/skill-definition.d.ts +5 -0
  100. package/dist/types/src/capabilities/skill-definition.d.ts.map +1 -0
  101. package/dist/types/src/components/NotebookStack/NotebookCell.d.ts.map +1 -1
  102. package/dist/types/src/components/NotebookStack/NotebookStack.d.ts +2 -3
  103. package/dist/types/src/components/NotebookStack/NotebookStack.d.ts.map +1 -1
  104. package/dist/types/src/components/NotebookStack/NotebookStack.stories.d.ts +18 -21
  105. package/dist/types/src/components/NotebookStack/NotebookStack.stories.d.ts.map +1 -1
  106. package/dist/types/src/components/QueryEditor/QueryEditor.stories.d.ts.map +1 -1
  107. package/dist/types/src/components/ScriptToolbar/ScriptToolbar.d.ts.map +1 -1
  108. package/dist/types/src/components/ScriptToolbar/ScriptToolbar.stories.d.ts +18 -21
  109. package/dist/types/src/components/ScriptToolbar/ScriptToolbar.stories.d.ts.map +1 -1
  110. package/dist/types/src/components/TypescriptEditor/TypescriptEditor.d.ts.map +1 -1
  111. package/dist/types/src/components/index.d.ts +0 -2
  112. package/dist/types/src/components/index.d.ts.map +1 -1
  113. package/dist/types/src/constants.d.ts.map +1 -1
  114. package/dist/types/src/containers/DeploymentDialog/DeploymentDialog.d.ts.map +1 -1
  115. package/dist/types/src/containers/DeploymentDialog/DeploymentDialog.stories.d.ts +18 -21
  116. package/dist/types/src/containers/DeploymentDialog/DeploymentDialog.stories.d.ts.map +1 -1
  117. package/dist/types/src/containers/NotebookArticle/NotebookArticle.d.ts.map +1 -1
  118. package/dist/types/src/containers/NotebookArticle/NotebookArticle.stories.d.ts.map +1 -1
  119. package/dist/types/src/containers/ScriptArticle/ScriptArticle.stories.d.ts +20 -23
  120. package/dist/types/src/containers/ScriptArticle/ScriptArticle.stories.d.ts.map +1 -1
  121. package/dist/types/src/containers/ScriptProperties/ScriptProperties.d.ts.map +1 -1
  122. package/dist/types/src/containers/ScriptProperties/ScriptProperties.stories.d.ts +20 -23
  123. package/dist/types/src/containers/ScriptProperties/ScriptProperties.stories.d.ts.map +1 -1
  124. package/dist/types/src/containers/ScriptProperties/SkillEditor.d.ts +7 -0
  125. package/dist/types/src/containers/ScriptProperties/SkillEditor.d.ts.map +1 -0
  126. package/dist/types/src/containers/ScriptSettings/ScriptSettings.d.ts +8 -0
  127. package/dist/types/src/containers/ScriptSettings/ScriptSettings.d.ts.map +1 -0
  128. package/dist/types/src/{components/ScriptPluginSettings/ScriptPluginSettings.stories.d.ts → containers/ScriptSettings/ScriptSettings.stories.d.ts} +20 -23
  129. package/dist/types/src/containers/ScriptSettings/ScriptSettings.stories.d.ts.map +1 -0
  130. package/dist/types/src/containers/ScriptSettings/index.d.ts +2 -0
  131. package/dist/types/src/containers/ScriptSettings/index.d.ts.map +1 -0
  132. package/dist/types/src/containers/index.d.ts +1 -0
  133. package/dist/types/src/containers/index.d.ts.map +1 -1
  134. package/dist/types/src/hooks/deploy.d.ts +14 -15
  135. package/dist/types/src/hooks/deploy.d.ts.map +1 -1
  136. package/dist/types/src/hooks/format.d.ts +6 -1
  137. package/dist/types/src/hooks/format.d.ts.map +1 -1
  138. package/dist/types/src/hooks/template.d.ts +6 -1
  139. package/dist/types/src/hooks/template.d.ts.map +1 -1
  140. package/dist/types/src/index.d.ts +1 -1
  141. package/dist/types/src/index.d.ts.map +1 -1
  142. package/dist/types/src/meta.d.ts +32 -2
  143. package/dist/types/src/meta.d.ts.map +1 -1
  144. package/dist/types/src/operations/create-script.d.ts.map +1 -1
  145. package/dist/types/src/skills/functions/create.d.ts.map +1 -0
  146. package/dist/types/src/skills/functions/definitions.d.ts +75 -0
  147. package/dist/types/src/skills/functions/definitions.d.ts.map +1 -0
  148. package/dist/types/src/skills/functions/delete.d.ts +7 -0
  149. package/dist/types/src/skills/functions/delete.d.ts.map +1 -0
  150. package/dist/types/src/skills/functions/deploy.d.ts +11 -0
  151. package/dist/types/src/skills/functions/deploy.d.ts.map +1 -0
  152. package/dist/types/src/skills/functions/index.d.ts.map +1 -0
  153. package/dist/types/src/skills/functions/inspect-invocations.d.ts +18 -0
  154. package/dist/types/src/skills/functions/inspect-invocations.d.ts.map +1 -0
  155. package/dist/types/src/skills/functions/install-function.d.ts.map +1 -0
  156. package/dist/types/src/skills/functions/invoke.d.ts +11 -0
  157. package/dist/types/src/skills/functions/invoke.d.ts.map +1 -0
  158. package/dist/types/src/skills/functions/query-deployed-functions.d.ts.map +1 -0
  159. package/dist/types/src/skills/functions/read.d.ts +11 -0
  160. package/dist/types/src/skills/functions/read.d.ts.map +1 -0
  161. package/dist/types/src/skills/functions/update.d.ts +16 -0
  162. package/dist/types/src/skills/functions/update.d.ts.map +1 -0
  163. package/dist/types/src/skills/index.d.ts +2 -0
  164. package/dist/types/src/skills/index.d.ts.map +1 -0
  165. package/dist/types/src/skills/script-skill.d.ts +4 -0
  166. package/dist/types/src/skills/script-skill.d.ts.map +1 -0
  167. package/dist/types/src/templates/chess-bot.d.ts +1 -4
  168. package/dist/types/src/templates/chess-bot.d.ts.map +1 -1
  169. package/dist/types/src/templates/commentary.d.ts +1 -4
  170. package/dist/types/src/templates/commentary.d.ts.map +1 -1
  171. package/dist/types/src/testing/test-script.d.ts.map +1 -1
  172. package/dist/types/src/translations.d.ts +18 -21
  173. package/dist/types/src/translations.d.ts.map +1 -1
  174. package/dist/types/src/types/Notebook.d.ts +11 -81
  175. package/dist/types/src/types/Notebook.d.ts.map +1 -1
  176. package/dist/types/src/types/ScriptCapabilities.d.ts.map +1 -1
  177. package/dist/types/src/types/ScriptEvents.d.ts.map +1 -1
  178. package/dist/types/src/types/ScriptOperation.d.ts +2 -10
  179. package/dist/types/src/types/ScriptOperation.d.ts.map +1 -1
  180. package/dist/types/src/util/deploy.d.ts +1 -1
  181. package/dist/types/src/util/deploy.d.ts.map +1 -1
  182. package/dist/types/tsconfig.tsbuildinfo +1 -1
  183. package/dx.config.ts +26 -0
  184. package/package.json +77 -75
  185. package/src/ScriptPlugin.node.ts +2 -2
  186. package/src/ScriptPlugin.test.ts +2 -2
  187. package/src/ScriptPlugin.tsx +3 -3
  188. package/src/capabilities/app-graph-builder.ts +2 -2
  189. package/src/capabilities/create-object.ts +0 -2
  190. package/src/capabilities/index.ts +1 -7
  191. package/src/capabilities/node.ts +1 -7
  192. package/src/capabilities/operation-handler.ts +1 -1
  193. package/src/capabilities/react-surface.tsx +11 -9
  194. package/src/capabilities/settings.ts +2 -2
  195. package/src/capabilities/skill-definition.ts +14 -0
  196. package/src/components/NotebookStack/NotebookCell.tsx +13 -31
  197. package/src/components/NotebookStack/NotebookMenu.tsx +1 -1
  198. package/src/components/NotebookStack/NotebookStack.stories.tsx +3 -3
  199. package/src/components/NotebookStack/NotebookStack.tsx +102 -44
  200. package/src/components/QueryEditor/QueryEditor.stories.tsx +2 -7
  201. package/src/components/ScriptToolbar/ScriptToolbar.tsx +3 -2
  202. package/src/components/TestPanel/TestPanel.tsx +1 -1
  203. package/src/components/TypescriptEditor/TypescriptEditor.stories.tsx +2 -2
  204. package/src/components/TypescriptEditor/TypescriptEditor.tsx +7 -7
  205. package/src/components/index.ts +0 -4
  206. package/src/constants.ts +1 -1
  207. package/src/containers/DeploymentDialog/DeploymentDialog.tsx +15 -9
  208. package/src/containers/NotebookArticle/NotebookArticle.stories.tsx +6 -5
  209. package/src/containers/NotebookArticle/NotebookArticle.tsx +21 -43
  210. package/src/containers/ScriptArticle/ScriptArticle.stories.tsx +5 -5
  211. package/src/containers/ScriptArticle/ScriptArticle.tsx +3 -3
  212. package/src/containers/ScriptProperties/FunctionBinding.tsx +2 -2
  213. package/src/containers/ScriptProperties/FunctionPublishing.tsx +2 -2
  214. package/src/containers/ScriptProperties/ScriptProperties.stories.tsx +5 -5
  215. package/src/containers/ScriptProperties/ScriptProperties.tsx +13 -6
  216. package/src/containers/ScriptProperties/{BlueprintEditor.tsx → SkillEditor.tsx} +23 -23
  217. package/src/{components/ScriptPluginSettings/ScriptPluginSettings.stories.tsx → containers/ScriptSettings/ScriptSettings.stories.tsx} +4 -4
  218. package/src/containers/ScriptSettings/ScriptSettings.tsx +47 -0
  219. package/src/containers/ScriptSettings/index.ts +5 -0
  220. package/src/containers/index.ts +1 -0
  221. package/src/e2e/ai.test.ts +14 -11
  222. package/src/e2e/deploy.test.ts +5 -1
  223. package/src/hooks/deploy.ts +4 -4
  224. package/src/hooks/format.ts +1 -1
  225. package/src/index.ts +1 -1
  226. package/src/meta.ts +3 -19
  227. package/src/operations/create-script.ts +1 -1
  228. package/src/{blueprints → skills}/functions/create.ts +1 -1
  229. package/src/{blueprints → skills}/functions/definitions.ts +4 -2
  230. package/src/{blueprints → skills}/functions/deploy.ts +7 -2
  231. package/src/{blueprints → skills}/functions/inspect-invocations.ts +2 -2
  232. package/src/{blueprints → skills}/functions/read.ts +1 -1
  233. package/src/skills/functions/update.ts +48 -0
  234. package/src/skills/index.ts +5 -0
  235. package/src/{blueprints/script-blueprint.ts → skills/script-skill.ts} +12 -12
  236. package/src/templates/anthropic.ts +1 -1
  237. package/src/templates/chess-bot.ts +2 -2
  238. package/src/templates/commentary.ts +8 -7
  239. package/src/templates/discord.ts +1 -1
  240. package/src/templates/gmail.ts +1 -1
  241. package/src/testing/test-notebook.ts +5 -5
  242. package/src/testing/test-script.ts +1 -1
  243. package/src/translations.ts +7 -8
  244. package/src/types/Notebook.ts +9 -13
  245. package/src/types/ScriptCapabilities.ts +4 -2
  246. package/src/types/ScriptEvents.ts +1 -1
  247. package/src/types/ScriptOperation.ts +3 -3
  248. package/src/util/deploy.ts +7 -3
  249. package/src/util/functions.ts +3 -3
  250. package/dist/lib/neutral/DeploymentDialog-M3AFYQHC.mjs.map +0 -7
  251. package/dist/lib/neutral/NotebookArticle-NV4AHOOS.mjs.map +0 -7
  252. package/dist/lib/neutral/ScriptArticle-QW26LOKU.mjs.map +0 -7
  253. package/dist/lib/neutral/ScriptPluginSettings-T4JMUSHN.mjs +0 -31
  254. package/dist/lib/neutral/ScriptPluginSettings-T4JMUSHN.mjs.map +0 -7
  255. package/dist/lib/neutral/ScriptProperties-RLXNAN3N.mjs.map +0 -7
  256. package/dist/lib/neutral/blueprint-definition-PJ7I3JIQ.mjs +0 -15
  257. package/dist/lib/neutral/blueprint-definition-PJ7I3JIQ.mjs.map +0 -7
  258. package/dist/lib/neutral/blueprints/index.mjs +0 -10
  259. package/dist/lib/neutral/chunk-BDHDBPVM.mjs.map +0 -7
  260. package/dist/lib/neutral/chunk-HABDH5SS.mjs.map +0 -7
  261. package/dist/lib/neutral/chunk-PHKPB5JN.mjs.map +0 -7
  262. package/dist/lib/neutral/chunk-TRKXIP2Q.mjs.map +0 -7
  263. package/dist/lib/neutral/chunk-UA3BWOCZ.mjs +0 -38
  264. package/dist/lib/neutral/chunk-UA3BWOCZ.mjs.map +0 -7
  265. package/dist/lib/neutral/chunk-VXDJH6OL.mjs.map +0 -7
  266. package/dist/lib/neutral/chunk-XFM63AKT.mjs +0 -8
  267. package/dist/lib/neutral/deploy-7JVMMHSH.mjs.map +0 -7
  268. package/dist/lib/neutral/inspect-invocations-TAOYDT4H.mjs.map +0 -7
  269. package/dist/lib/neutral/react-surface-ACNZ35FV.mjs.map +0 -7
  270. package/dist/lib/neutral/update-CO7B6UBS.mjs +0 -63
  271. package/dist/lib/neutral/update-CO7B6UBS.mjs.map +0 -7
  272. package/dist/types/src/blueprints/functions/create.d.ts.map +0 -1
  273. package/dist/types/src/blueprints/functions/definitions.d.ts +0 -135
  274. package/dist/types/src/blueprints/functions/definitions.d.ts.map +0 -1
  275. package/dist/types/src/blueprints/functions/delete.d.ts +0 -17
  276. package/dist/types/src/blueprints/functions/delete.d.ts.map +0 -1
  277. package/dist/types/src/blueprints/functions/deploy.d.ts +0 -21
  278. package/dist/types/src/blueprints/functions/deploy.d.ts.map +0 -1
  279. package/dist/types/src/blueprints/functions/index.d.ts.map +0 -1
  280. package/dist/types/src/blueprints/functions/inspect-invocations.d.ts +0 -28
  281. package/dist/types/src/blueprints/functions/inspect-invocations.d.ts.map +0 -1
  282. package/dist/types/src/blueprints/functions/install-function.d.ts.map +0 -1
  283. package/dist/types/src/blueprints/functions/invoke.d.ts +0 -21
  284. package/dist/types/src/blueprints/functions/invoke.d.ts.map +0 -1
  285. package/dist/types/src/blueprints/functions/query-deployed-functions.d.ts.map +0 -1
  286. package/dist/types/src/blueprints/functions/read.d.ts +0 -21
  287. package/dist/types/src/blueprints/functions/read.d.ts.map +0 -1
  288. package/dist/types/src/blueprints/functions/update.d.ts +0 -26
  289. package/dist/types/src/blueprints/functions/update.d.ts.map +0 -1
  290. package/dist/types/src/blueprints/index.d.ts +0 -2
  291. package/dist/types/src/blueprints/index.d.ts.map +0 -1
  292. package/dist/types/src/blueprints/script-blueprint.d.ts +0 -4
  293. package/dist/types/src/blueprints/script-blueprint.d.ts.map +0 -1
  294. package/dist/types/src/capabilities/blueprint-definition.d.ts +0 -6
  295. package/dist/types/src/capabilities/blueprint-definition.d.ts.map +0 -1
  296. package/dist/types/src/components/ScriptPluginSettings/ScriptPluginSettings.d.ts +0 -8
  297. package/dist/types/src/components/ScriptPluginSettings/ScriptPluginSettings.d.ts.map +0 -1
  298. package/dist/types/src/components/ScriptPluginSettings/ScriptPluginSettings.stories.d.ts.map +0 -1
  299. package/dist/types/src/components/ScriptPluginSettings/index.d.ts +0 -2
  300. package/dist/types/src/components/ScriptPluginSettings/index.d.ts.map +0 -1
  301. package/dist/types/src/containers/ScriptProperties/BlueprintEditor.d.ts +0 -7
  302. package/dist/types/src/containers/ScriptProperties/BlueprintEditor.d.ts.map +0 -1
  303. package/src/blueprints/functions/update.ts +0 -68
  304. package/src/blueprints/index.ts +0 -5
  305. package/src/capabilities/blueprint-definition.ts +0 -19
  306. package/src/components/ScriptPluginSettings/ScriptPluginSettings.tsx +0 -42
  307. package/src/components/ScriptPluginSettings/index.ts +0 -5
  308. /package/dist/lib/neutral/{chunk-BKXYHCJ6.mjs.map → chunk-KSVKXCTX.mjs.map} +0 -0
  309. /package/dist/lib/neutral/{blueprints → skills}/index.mjs.map +0 -0
  310. /package/dist/types/src/{blueprints → skills}/functions/create.d.ts +0 -0
  311. /package/dist/types/src/{blueprints → skills}/functions/index.d.ts +0 -0
  312. /package/dist/types/src/{blueprints → skills}/functions/install-function.d.ts +0 -0
  313. /package/dist/types/src/{blueprints → skills}/functions/query-deployed-functions.d.ts +0 -0
  314. /package/src/{blueprints → skills}/functions/delete.ts +0 -0
  315. /package/src/{blueprints → skills}/functions/index.ts +0 -0
  316. /package/src/{blueprints → skills}/functions/install-function.ts +0 -0
  317. /package/src/{blueprints → skills}/functions/invoke.ts +0 -0
  318. /package/src/{blueprints → skills}/functions/query-deployed-functions.ts +0 -0
package/PLUGIN.mdl CHANGED
@@ -8,7 +8,7 @@ A scripting plugin for `DXOS` Composer that lets users write, deploy, and run cu
8
8
  ECHO objects inside their spaces.
9
9
  Scripts execute on the Cloudflare Workers-based EDGE runtime and can call DXOS SDK packages, Effect-TS,
10
10
  and a curated set of third-party libraries.
11
- An AI assistant blueprint wires CRUD, deploy, invoke, and inspection operations as tools so an agent can
11
+ An AI assistant skill wires CRUD, deploy, invoke, and inspection operations as tools so an agent can
12
12
  scaffold, iterate, and test scripts entirely within a chat session.
13
13
 
14
14
  ## Extensions
@@ -143,7 +143,7 @@ component ScriptPluginSettings
143
143
 
144
144
  ## Operations
145
145
 
146
- Blueprint operations (called by the Script assistant via its tool set).
146
+ Skill operations (called by the Script assistant via its tool set).
147
147
 
148
148
  ```mdl
149
149
  op create
@@ -329,14 +329,14 @@ feat F-4: Execute Companion
329
329
  ```
330
330
 
331
331
  ```mdl
332
- feat F-5: Script Blueprint
332
+ feat F-5: Script Skill
333
333
 
334
- req F-5.1: A blueprint with key `org.dxos.blueprint.script` is contributed via `addBlueprintDefinitionModule`.
335
- req F-5.2: Blueprint tool set includes: create, read, update, delete, deploy, invoke,
334
+ req F-5.1: A skill with key `org.dxos.skill.script` is contributed via `addSkillDefinitionModule`.
335
+ req F-5.2: Skill tool set includes: create, read, update, delete, deploy, invoke,
336
336
  inspectInvocations, queryDeployedFunctions, installFunction.
337
337
  req F-5.3: System instructions describe the EDGE Operation pattern, required export format,
338
338
  and available packages.
339
- req F-5.4: Blueprint is agent-enabled; the assistant can activate it autonomously.
339
+ req F-5.4: Skill is agent-enabled; the assistant can activate it autonomously.
340
340
  ```
341
341
 
342
342
  ```mdl
@@ -413,11 +413,11 @@ test T-6: Inspect invocations
413
413
  ```
414
414
 
415
415
  ```mdl
416
- test T-7: Blueprint tools resolve
416
+ test T-7: Skill tools resolve
417
417
  given: composer-app with plugin-script loaded
418
- when: AppCapabilities.BlueprintDefinition is queried for `org.dxos.blueprint.script`
418
+ when: AppCapabilities.SkillDefinition is queried for `org.dxos.skill.script`
419
419
  then:
420
- - blueprint is present
420
+ - skill is present
421
421
  - tool set includes create, read, update, delete, deploy, invoke,
422
422
  inspectInvocations, queryDeployedFunctions, and installFunction
423
423
  ```
@@ -9,7 +9,7 @@ import { Button, Dialog, useTranslation } from "@dxos/react-ui";
9
9
  import { useCreateAndDeployScriptTemplates } from "#hooks";
10
10
  import { meta } from "#meta";
11
11
  var DeploymentDialog = ({ accessToken, scriptTemplates }) => {
12
- const { t } = useTranslation(meta.id);
12
+ const { t } = useTranslation(meta.profile.key);
13
13
  const space = useMemo(() => getSpace(accessToken), [
14
14
  accessToken
15
15
  ]);
@@ -18,27 +18,27 @@ var DeploymentDialog = ({ accessToken, scriptTemplates }) => {
18
18
  useEffect(() => {
19
19
  if (status === "success") {
20
20
  void invokePromise(LayoutOperation.AddToast, {
21
- id: `${meta.id}.deployment-success`,
21
+ id: `${meta.profile.key}.deployment-success`,
22
22
  icon: "ph--check--regular",
23
23
  duration: Infinity,
24
24
  title: [
25
25
  "script-deployment-toast.label",
26
26
  {
27
- ns: meta.id,
27
+ ns: meta.profile.key,
28
28
  count: scriptTemplates.length
29
29
  }
30
30
  ],
31
31
  description: [
32
32
  "script-deployment-toast.description",
33
33
  {
34
- ns: meta.id,
34
+ ns: meta.profile.key,
35
35
  count: scriptTemplates.length
36
36
  }
37
37
  ],
38
38
  closeLabel: [
39
39
  "script-deployment-toast-close.label",
40
40
  {
41
- ns: meta.id,
41
+ ns: meta.profile.key,
42
42
  count: scriptTemplates.length
43
43
  }
44
44
  ]
@@ -52,27 +52,27 @@ var DeploymentDialog = ({ accessToken, scriptTemplates }) => {
52
52
  state: false
53
53
  });
54
54
  void invokePromise(LayoutOperation.AddToast, {
55
- id: `${meta.id}.deployment-error`,
55
+ id: `${meta.profile.key}.deployment-error`,
56
56
  icon: "ph--warning--regular",
57
57
  duration: Infinity,
58
58
  title: [
59
59
  "script-deployment-error-toast.label",
60
60
  {
61
- ns: meta.id,
61
+ ns: meta.profile.key,
62
62
  count: scriptTemplates.length
63
63
  }
64
64
  ],
65
65
  description: [
66
66
  "script-deployment-error-toast.description",
67
67
  {
68
- ns: meta.id,
68
+ ns: meta.profile.key,
69
69
  count: scriptTemplates.length
70
70
  }
71
71
  ],
72
72
  closeLabel: [
73
73
  "script-deployment-error-toast-close.label",
74
74
  {
75
- ns: meta.id,
75
+ ns: meta.profile.key,
76
76
  count: scriptTemplates.length
77
77
  }
78
78
  ]
@@ -111,4 +111,4 @@ var DeploymentDialog = ({ accessToken, scriptTemplates }) => {
111
111
  export {
112
112
  DeploymentDialog as default
113
113
  };
114
- //# sourceMappingURL=DeploymentDialog-M3AFYQHC.mjs.map
114
+ //# sourceMappingURL=DeploymentDialog-7OIIL7LB.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/containers/DeploymentDialog/DeploymentDialog.tsx"],
4
+ "sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport React, { useEffect, useMemo } from 'react';\n\nimport { useOperationInvoker } from '@dxos/app-framework/ui';\nimport { LayoutOperation } from '@dxos/app-toolkit';\nimport { getSpace } from '@dxos/react-client/echo';\nimport { Button, Dialog, useTranslation } from '@dxos/react-ui';\nimport { type AccessToken } from '@dxos/types';\n\nimport { useCreateAndDeployScriptTemplates } from '#hooks';\nimport { meta } from '#meta';\n\nimport { type Template } from '../../templates';\n\n// TODO(ZaymonFC):\n// - Show activity and feedback to the user.\n// - Only take an array of templateIds and get the name from the data.\n// - Pending / onError states.\n\nexport type DeploymentDialogProps = {\n accessToken: AccessToken.AccessToken;\n scriptTemplates: Template[];\n};\n\nexport const DeploymentDialog = ({ accessToken, scriptTemplates }: DeploymentDialogProps) => {\n const { t } = useTranslation(meta.profile.key);\n const space = useMemo(() => getSpace(accessToken), [accessToken]);\n\n // TODO(ZaymonFC): Thinking further. All of this should get moved to intents to run async in the background.\n // Deployment shouldn't be tied to the lifecycle of the dialogue component.\n const { handleCreateAndDeployScripts, status } = useCreateAndDeployScriptTemplates(space, scriptTemplates);\n const { invokePromise } = useOperationInvoker();\n\n useEffect(() => {\n if (status === 'success') {\n // TODO(ZaymonFC): We can probably re-use this toast for normal script deployment.\n void invokePromise(LayoutOperation.AddToast, {\n id: `${meta.profile.key}.deployment-success`,\n icon: 'ph--check--regular',\n duration: Infinity,\n title: ['script-deployment-toast.label', { ns: meta.profile.key, count: scriptTemplates.length }],\n description: ['script-deployment-toast.description', { ns: meta.profile.key, count: scriptTemplates.length }],\n closeLabel: ['script-deployment-toast-close.label', { ns: meta.profile.key, count: scriptTemplates.length }],\n });\n void invokePromise(LayoutOperation.UpdateDialog, { state: false });\n }\n if (status === 'error') {\n void invokePromise(LayoutOperation.UpdateDialog, { state: false });\n void invokePromise(LayoutOperation.AddToast, {\n id: `${meta.profile.key}.deployment-error`,\n icon: 'ph--warning--regular',\n duration: Infinity,\n title: ['script-deployment-error-toast.label', { ns: meta.profile.key, count: scriptTemplates.length }],\n description: [\n 'script-deployment-error-toast.description',\n { ns: meta.profile.key, count: scriptTemplates.length },\n ],\n closeLabel: [\n 'script-deployment-error-toast-close.label',\n { ns: meta.profile.key, count: scriptTemplates.length },\n ],\n });\n }\n }, [status, invokePromise]);\n\n return (\n <Dialog.Content>\n <Dialog.Header>\n <Dialog.Title>{t('deployment-dialog.title')}</Dialog.Title>\n <Dialog.Close asChild>\n <Dialog.ActionIconButton action='close' />\n </Dialog.Close>\n </Dialog.Header>\n <Dialog.Body>\n <p>\n {t('deployment-dialog-scripts-found.message', {\n count: scriptTemplates.length,\n })}\n </p>\n <ul className='pt-2'>\n {scriptTemplates.map((template) => {\n return <li key={template.id}>{template.name}</li>;\n })}\n </ul>\n </Dialog.Body>\n <Dialog.ActionBar>\n <Dialog.Close asChild>\n <Button disabled={status === 'pending'}>{t('deployment-dialog-skip-button.label')}</Button>\n </Dialog.Close>\n <Button variant='primary' onClick={handleCreateAndDeployScripts} disabled={status === 'pending'}>\n {status === 'pending'\n ? t('deployment-dialog-deploy-functions-pending-button.label', {\n count: scriptTemplates.length,\n })\n : t('deployment-dialog-deploy-functions-button.label', {\n count: scriptTemplates.length,\n })}\n </Button>\n </Dialog.ActionBar>\n </Dialog.Content>\n );\n};\n"],
5
+ "mappings": ";;;AAIA,OAAOA,SAASC,WAAWC,eAAe;AAE1C,SAASC,2BAA2B;AACpC,SAASC,uBAAuB;AAChC,SAASC,gBAAgB;AACzB,SAASC,QAAQC,QAAQC,sBAAsB;AAG/C,SAASC,yCAAyC;AAClD,SAASC,YAAY;AAcd,IAAMC,mBAAmB,CAAC,EAAEC,aAAaC,gBAAe,MAAyB;AACtF,QAAM,EAAEC,EAAC,IAAKN,eAAeE,KAAKK,QAAQC,GAAG;AAC7C,QAAMC,QAAQf,QAAQ,MAAMG,SAASO,WAAAA,GAAc;IAACA;GAAY;AAIhE,QAAM,EAAEM,8BAA8BC,OAAM,IAAKV,kCAAkCQ,OAAOJ,eAAAA;AAC1F,QAAM,EAAEO,cAAa,IAA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kBAAgB;IAACC,QAAO;QAGpC,sBAAA,cAACjC,OAAOkC,MAAI,MACV,sBAAA,cAACC,KAAAA,MACE5B,EAAE,2CAA2C;IAC5Cc,OAAOf,gBAAgBgB;EACzB,CAAA,CAAA,GAEF,sBAAA,cAACc,MAAAA;IAAGC,WAAU;KACX/B,gBAAgBgC,IAAI,CAACC,aAAAA;AACpB,WAAO,sBAAA,cAACC,MAAAA;MAAG/B,KAAK8B,SAASxB;OAAKwB,SAASE,IAAI;EAC7C,CAAA,CAAA,CAAA,GAGJ,sBAAA,cAACzC,OAAO0C,WAAS,MACf,sBAAA,cAAC1C,OAAO8B,OAAK;IAACC,SAAAA;KACZ,sBAAA,cAAChC,QAAAA;IAAO4C,UAAU/B,WAAW;KAAYL,EAAE,qCAAA,CAAA,CAAA,GAE7C,sBAAA,cAACR,QAAAA;IAAO6C,SAAQ;IAAUC,SAASlC;IAA8BgC,UAAU/B,WAAW;KACnFA,WAAW,YACRL,EAAE,2DAA2D;IAC3Dc,OAAOf,gBAAgBgB;EACzB,CAAA,IACAf,EAAE,mDAAmD;IACnDc,OAAOf,gBAAgBgB;EACzB,CAAA,CAAA,CAAA,CAAA;AAKd;",
6
+ "names": ["React", "useEffect", "useMemo", "useOperationInvoker", "LayoutOperation", "getSpace", "Button", "Dialog", "useTranslation", "useCreateAndDeployScriptTemplates", "meta", "DeploymentDialog", "accessToken", "scriptTemplates", "t", "profile", "key", "space", "handleCreateAndDeployScripts", "status", "invokePromise", "AddToast", "id", "icon", "duration", "Infinity", "title", "ns", "count", "length", "description", "closeLabel", "UpdateDialog", "state", "Content", "Header", "Title", "Close", "asChild", "ActionIconButton", "action", "Body", "p", "ul", "className", "map", "template", "li", "name", "ActionBar", "disabled", "variant", "onClick"]
7
+ }
@@ -7,8 +7,8 @@ import * as Effect from "effect/Effect";
7
7
  import * as Exit from "effect/Exit";
8
8
  import React, { useCallback, useContext, useMemo, useState } from "react";
9
9
  import { useSpaceCallback } from "@dxos/app-framework/ui";
10
- import { AgentPrompt } from "@dxos/assistant-toolkit";
11
- import { Blueprint, Routine } from "@dxos/compute";
10
+ import { RunInstructions } from "@dxos/assistant-toolkit";
11
+ import { Instructions, Skill } from "@dxos/compute";
12
12
  import { Operation } from "@dxos/compute";
13
13
  import { Filter, Obj, Query, Ref } from "@dxos/echo";
14
14
  import { QueryBuilder } from "@dxos/echo-query";
@@ -546,15 +546,15 @@ var ComputeGraph = class {
546
546
 
547
547
  // src/containers/NotebookArticle/NotebookArticle.tsx
548
548
  var __dxlog_file3 = "/__w/dxos/dxos/packages/plugins/plugin-script/src/containers/NotebookArticle/NotebookArticle.tsx";
549
- var INCLUDE_BLUEPRINTS = [
550
- "org.dxos.blueprint.assistant",
551
- "org.dxos.blueprint.database",
552
- "org.dxos.blueprint.markdown"
549
+ var INCLUDE_SKILLS = [
550
+ "org.dxos.skill.assistant",
551
+ "org.dxos.skill.database",
552
+ "org.dxos.skill.markdown"
553
553
  ];
554
554
  var NotebookArticle = ({ role, subject: notebook, attendableId, env }) => {
555
- const { t } = useTranslation(meta.id);
555
+ const { t } = useTranslation(meta.profile.key);
556
556
  const registry = useContext(RegistryContext);
557
- const db = Obj.getDatabase(notebook);
557
+ const db = notebook ? Obj.getDatabase(notebook) : void 0;
558
558
  const { hasAttention } = useAttention(attendableId);
559
559
  const graph = useMemo(() => notebook && new ComputeGraph(notebook, registry), [
560
560
  notebook,
@@ -616,17 +616,17 @@ var NotebookArticle = ({ role, subject: notebook, attendableId, env }) => {
616
616
  const [promptResults, setPromptResults] = useState({});
617
617
  const handleExecPrompts = useSpaceCallback(db?.spaceId, [], Effect.fnUntraced(function* () {
618
618
  invariant2(graph, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 96, S: this, A: ["graph", ""] });
619
- const prompts = notebook?.cells.filter((cell) => cell.type === "prompt").map((cell) => cell.prompt).filter(isNonNullable) ?? [];
620
- for (const prompt of prompts) {
619
+ const allInstructions = notebook?.cells.filter((cell) => cell.type === "prompt").map((cell) => cell.prompt).filter(isNonNullable) ?? [];
620
+ for (const instructions of allInstructions) {
621
621
  yield* runPrompt({
622
- prompt,
622
+ instructions,
623
623
  input: {
624
624
  ...queryValues,
625
625
  ...graph.getValuesByName()
626
626
  },
627
627
  onResult: (result) => setPromptResults((prev) => ({
628
628
  ...prev,
629
- [prompt.uri]: result
629
+ [instructions.uri]: result
630
630
  }))
631
631
  });
632
632
  }
@@ -644,23 +644,8 @@ var NotebookArticle = ({ role, subject: notebook, attendableId, env }) => {
644
644
  handleExecQueries,
645
645
  handleExecPrompts
646
646
  ]);
647
- const handleRearrange = useCallback((source, target) => {
648
- invariant2(notebook, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 128, S: void 0, A: ["notebook", ""] });
649
- const from = notebook.cells.findIndex((cell) => cell.id === source.id);
650
- const to = notebook.cells.findIndex((cell) => cell.id === target.id);
651
- if (from != null && to != null) {
652
- Obj.update(notebook, (notebook2) => {
653
- const cell = notebook2.cells.splice(from, 1)[0];
654
- if (cell) {
655
- notebook2.cells.splice(to, 0, cell);
656
- }
657
- });
658
- }
659
- }, [
660
- notebook
661
- ]);
662
647
  const handleCellInsert = useCallback(async (type, after) => {
663
- invariant2(notebook, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 143, S: void 0, A: ["notebook", ""] });
648
+ invariant2(notebook, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 128, S: void 0, A: ["notebook", ""] });
664
649
  const cell = {
665
650
  id: crypto.randomUUID(),
666
651
  type
@@ -674,14 +659,14 @@ var NotebookArticle = ({ role, subject: notebook, attendableId, env }) => {
674
659
  }
675
660
  case "prompt": {
676
661
  if (db) {
677
- const objects = await db.query(Query.select(Filter.type(Blueprint.Blueprint))).run();
678
- const blueprints = objects.filter((blueprint) => {
679
- const key = Obj.getMeta(blueprint).key;
680
- return key !== void 0 && INCLUDE_BLUEPRINTS.includes(key);
681
- }).map((blueprint) => Ref.make(blueprint));
682
- cell.prompt = Ref.make(Routine.make({
683
- instructions: "",
684
- blueprints
662
+ const objects = await db.query(Query.select(Filter.type(Skill.Skill))).run();
663
+ const skills = objects.filter((skill) => {
664
+ const key = Obj.getMeta(skill).key;
665
+ return key !== void 0 && INCLUDE_SKILLS.includes(key);
666
+ }).map((skill) => Ref.make(skill));
667
+ cell.prompt = Ref.make(Instructions.make({
668
+ text: "",
669
+ skills
685
670
  }));
686
671
  }
687
672
  break;
@@ -696,7 +681,7 @@ var NotebookArticle = ({ role, subject: notebook, attendableId, env }) => {
696
681
  notebook
697
682
  ]);
698
683
  const handleCellDelete = useCallback((id) => {
699
- invariant2(notebook, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 181, S: void 0, A: ["notebook", ""] });
684
+ invariant2(notebook, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 166, S: void 0, A: ["notebook", ""] });
700
685
  const idx = notebook.cells.findIndex((cell) => cell.id === id);
701
686
  if (idx !== -1) {
702
687
  Obj.update(notebook, (notebook2) => {
@@ -727,29 +712,26 @@ var NotebookArticle = ({ role, subject: notebook, attendableId, env }) => {
727
712
  label: t("compute.label"),
728
713
  classNames: "text-success-text",
729
714
  onClick: handleCompute
730
- }))), /* @__PURE__ */ React.createElement(Panel.Content, {
731
- asChild: true
732
- }, /* @__PURE__ */ React.createElement(NotebookStack, {
715
+ }))), /* @__PURE__ */ React.createElement(Panel.Content, null, /* @__PURE__ */ React.createElement(NotebookStack, {
733
716
  db,
734
717
  notebook,
735
718
  graph,
736
719
  env,
737
720
  promptResults,
738
- onRearrange: handleRearrange,
739
721
  onCellInsert: handleCellInsert,
740
722
  onCellDelete: handleCellDelete
741
723
  })));
742
724
  };
743
- var runPrompt = Effect.fn(function* ({ prompt, input, onResult }) {
725
+ var runPrompt = Effect.fn(function* ({ instructions, input, onResult }) {
744
726
  const inputData = {
745
- prompt,
727
+ instructions,
746
728
  input
747
729
  };
748
- const result = yield* Operation.invoke(AgentPrompt, inputData).pipe(Effect.orDie, Effect.exit);
730
+ const result = yield* Operation.invoke(RunInstructions, inputData).pipe(Effect.orDie, Effect.exit);
749
731
  Exit.match(result, {
750
732
  onFailure: (cause) => {
751
733
  const error = Cause.prettyErrors(cause)[0];
752
- log2.error(error.message, error.cause ?? error.stack, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 236, S: this });
734
+ log2.error(error.message, error.cause ?? error.stack, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 218, S: this });
753
735
  onResult(error.message);
754
736
  },
755
737
  onSuccess: (result2) => {
@@ -760,4 +742,4 @@ var runPrompt = Effect.fn(function* ({ prompt, input, onResult }) {
760
742
  export {
761
743
  NotebookArticle as default
762
744
  };
763
- //# sourceMappingURL=NotebookArticle-NV4AHOOS.mjs.map
745
+ //# sourceMappingURL=NotebookArticle-AOBB3XGD.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/containers/NotebookArticle/NotebookArticle.tsx", "../../../src/notebook/compute-graph.ts", "../../../src/notebook/eval.ts", "../../../src/notebook/vfs-parser.ts"],
4
+ "sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { RegistryContext } from '@effect-atom/atom-react';\nimport * as Cause from 'effect/Cause';\nimport * as Effect from 'effect/Effect';\nimport * as Exit from 'effect/Exit';\nimport type * as Types from 'effect/Types';\nimport React, { useCallback, useContext, useMemo, useState } from 'react';\n\nimport { useSpaceCallback } from '@dxos/app-framework/ui';\nimport { type AppSurface } from '@dxos/app-toolkit/ui';\nimport { RunInstructions } from '@dxos/assistant-toolkit';\nimport { Instructions, Skill } from '@dxos/compute';\nimport { Operation } from '@dxos/compute';\nimport { Filter, Obj, Query, Ref } from '@dxos/echo';\nimport { QueryBuilder } from '@dxos/echo-query';\nimport { invariant } from '@dxos/invariant';\nimport { log } from '@dxos/log';\nimport { Graph } from '@dxos/plugin-explorer';\nimport { DropdownMenu, IconButton, Panel, Toolbar, useTranslation } from '@dxos/react-ui';\nimport { useAttention } from '@dxos/react-ui-attention';\nimport { Text, ViewModel } from '@dxos/schema';\nimport { isNonNullable } from '@dxos/util';\n\nimport { NotebookMenu, NotebookStack, type NotebookStackProps, type TypescriptEditorProps } from '#components';\nimport { meta } from '#meta';\nimport { type Notebook } from '#types';\n\nimport { ComputeGraph } from '../../notebook';\n\nconst INCLUDE_SKILLS = ['org.dxos.skill.assistant', 'org.dxos.skill.database', 'org.dxos.skill.markdown'];\n\n// TODO(burdon): Support calling named deployed functions (as with sheet).\n\nexport type NotebookArticleProps = AppSurface.ObjectArticleProps<Notebook.Notebook, Pick<TypescriptEditorProps, 'env'>>;\n\nexport const NotebookArticle = ({ role, subject: notebook, attendableId, env }: NotebookArticleProps) => {\n const { t } = useTranslation(meta.profile.key);\n const registry = useContext(RegistryContext);\n const db = notebook ? Obj.getDatabase(notebook) : undefined;\n const { hasAttention } = useAttention(attendableId);\n\n // TODO(burdon): Consolidate execution and state (with graph).\n // Generalize ComputeGraph evaluation function (using effects).\n const graph = useMemo(() => notebook && new ComputeGraph(notebook, registry), [notebook, registry]);\n\n const [queryValues, setQueryValues] = useState<Record<string, any>>({});\n const handleExecQueries = useCallback(async () => {\n invariant(db);\n\n const builder = new QueryBuilder();\n for (const cell of notebook?.cells ?? []) {\n if (cell.type === 'query') {\n if (cell.source?.target) {\n const source = cell.source.target.content;\n const { name, filter } = builder.build(source);\n if (filter) {\n const ast = Query.select(filter).ast;\n const graph = cell.graph?.target;\n if (!graph) {\n const { view } = await ViewModel.makeFromDatabase({ db });\n const newGraph = Graph.make({ query: { ast }, view });\n Obj.update(notebook!, (obj) => {\n const c = obj.cells.find((c) => c.id === cell.id);\n if (c) {\n c.graph = Ref.make(newGraph);\n c.name = name;\n }\n });\n } else {\n Obj.update(graph, (graph) => {\n graph.query.ast = ast as Obj.Mutable<typeof ast>;\n });\n }\n }\n }\n\n if (cell.name && cell.graph?.target) {\n const graph = Obj.getSnapshot(cell.graph?.target);\n const query = Query.fromAst(graph.query.ast);\n const objects = await db.query(query).run();\n const objectIds = objects?.map((obj) => obj.id);\n setQueryValues((prev) => ({ ...prev, [cell.name!]: objectIds }));\n }\n }\n }\n }, [db, notebook, graph]);\n\n const [promptResults, setPromptResults] = useState<Record<string, string>>({});\n const handleExecPrompts = useSpaceCallback(\n db?.spaceId,\n [] as const,\n Effect.fnUntraced(function* () {\n invariant(graph);\n\n const allInstructions =\n notebook?.cells\n .filter((cell) => cell.type === 'prompt')\n .map((cell) => cell.prompt)\n .filter(isNonNullable) ?? [];\n\n for (const instructions of allInstructions) {\n yield* runPrompt({\n instructions,\n input: { ...queryValues, ...graph.getValuesByName() },\n onResult: (result) =>\n setPromptResults((prev) => ({\n ...prev,\n [instructions.uri]: result,\n })),\n });\n }\n }),\n [notebook, graph, queryValues],\n );\n\n // TODO(burdon): Cache values in context (preserve when switched).\n const handleCompute = useCallback(async () => {\n // TODO(burdon): Generalize executors (dependencies).\n await graph?.evaluate();\n await handleExecQueries();\n await handleExecPrompts();\n }, [graph, handleExecQueries, handleExecPrompts]);\n\n const handleCellInsert = useCallback<NonNullable<NotebookStackProps['onCellInsert']>>(\n async (type, after) => {\n invariant(notebook);\n const cell: Types.Mutable<Notebook.Cell> = { id: crypto.randomUUID(), type };\n switch (type) {\n case 'markdown':\n case 'script':\n case 'query': {\n cell.source = Ref.make(Text.make());\n break;\n }\n\n case 'prompt': {\n if (db) {\n const objects = await db.query(Query.select(Filter.type(Skill.Skill))).run();\n const skills = objects\n .filter((skill) => {\n const key = Obj.getMeta(skill).key;\n return key !== undefined && INCLUDE_SKILLS.includes(key);\n })\n .map((skill) => Ref.make(skill));\n cell.prompt = Ref.make(Instructions.make({ text: '', skills }));\n }\n break;\n }\n }\n\n const idx = after ? notebook.cells.findIndex((cell) => cell.id === after) : notebook.cells.length;\n Obj.update(notebook, (notebook) => {\n notebook.cells.splice(idx, 0, cell);\n });\n },\n [db, notebook],\n );\n\n const handleCellDelete = useCallback<NonNullable<NotebookStackProps['onCellDelete']>>(\n (id) => {\n invariant(notebook);\n const idx = notebook.cells.findIndex((cell) => cell.id === id);\n if (idx !== -1) {\n Obj.update(notebook, (notebook) => {\n notebook.cells.splice(idx, 1);\n });\n }\n },\n [notebook],\n );\n\n return (\n <Panel.Root role={role} className='dx-document'>\n <Panel.Toolbar asChild>\n <Toolbar.Root disabled={!hasAttention}>\n <DropdownMenu.Root>\n <DropdownMenu.Trigger asChild>\n <IconButton icon='ph--plus--regular' iconOnly label={t('notebook-cell-insert.label')} />\n </DropdownMenu.Trigger>\n <NotebookMenu onCellInsert={handleCellInsert} />\n </DropdownMenu.Root>\n <Toolbar.IconButton\n icon='ph--play--fill'\n iconOnly\n label={t('compute.label')}\n classNames='text-success-text'\n onClick={handleCompute}\n />\n </Toolbar.Root>\n </Panel.Toolbar>\n <Panel.Content>\n <NotebookStack\n db={db}\n notebook={notebook}\n graph={graph}\n env={env}\n promptResults={promptResults}\n onCellInsert={handleCellInsert}\n onCellDelete={handleCellDelete}\n />\n </Panel.Content>\n </Panel.Root>\n );\n};\n\n// TODO(wittjosiah): Factor out. Copied from PromptArticle in plugin-assistant.\nconst runPrompt = Effect.fn(function* ({\n instructions,\n input,\n onResult,\n}: {\n instructions: Ref.Ref<Instructions.Instructions>;\n input: Record<string, any>;\n onResult: (result: string) => void;\n}) {\n const inputData: Operation.Definition.Input<typeof RunInstructions> = { instructions, input };\n // Invoke the function.\n const result = yield* Operation.invoke(RunInstructions, inputData).pipe(Effect.orDie, Effect.exit);\n\n Exit.match(result, {\n onFailure: (cause) => {\n const error = Cause.prettyErrors(cause)[0];\n log.error(error.message, error.cause ?? error.stack);\n onResult(error.message);\n },\n onSuccess: (result: any) => {\n onResult(result.note);\n },\n });\n});\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { Atom, type Registry } from '@effect-atom/atom-react';\n\nimport { log } from '@dxos/log';\n\nimport { type Notebook } from '#types';\n\nimport { evalScript } from './eval';\nimport { type ParsedExpression, VirtualTypeScriptParser } from './vfs-parser';\n\n/**\n * Compute graph that evaluates the notebook cells.\n */\n// TODO(burdon): Reconcile with @dxos/conductor.\nexport class ComputeGraph {\n private readonly _parser = new VirtualTypeScriptParser();\n\n private _expressionsAtom = Atom.make<Record<string, ParsedExpression>>({});\n private _valuesByCellIdAtom = Atom.make<Record<string, any>>({});\n private _valuesByNameAtom = Atom.make<Record<string, any>>({});\n\n constructor(\n private readonly _notebook: Notebook.Notebook,\n private readonly _registry: Registry.Registry,\n ) {}\n\n /**\n * Atom for parsed expressions by cell ID.\n */\n get expressions(): Atom.Atom<Record<string, ParsedExpression>> {\n return this._expressionsAtom;\n }\n\n /**\n * Get current expressions by cell ID.\n */\n getExpressions(): Record<string, ParsedExpression> {\n return this._registry.get(this._expressionsAtom);\n }\n\n /**\n * Atom for computed values by cell ID.\n */\n get values(): Atom.Atom<Record<string, any>> {\n return this._valuesByCellIdAtom;\n }\n\n /**\n * Get computed values by cell ID.\n */\n getValues(): Record<string, any> {\n return this._registry.get(this._valuesByCellIdAtom);\n }\n\n /**\n * Atom for computed values by name.\n */\n get valuesByName(): Atom.Atom<Record<string, any>> {\n return this._valuesByNameAtom;\n }\n\n /**\n * Get current values by name.\n */\n getValuesByName(): Record<string, any> {\n return this._registry.get(this._valuesByNameAtom);\n }\n\n /**\n * Get computed value by cell ID.\n */\n getValue(cellId: string): any {\n return this._registry.get(this._valuesByCellIdAtom)[cellId];\n }\n\n /**\n * Compute values.\n */\n async evaluate() {\n // Parse expressions.\n const { expressions, dependencyGraph } = this.parse();\n this._registry.set(this._valuesByCellIdAtom, {});\n this._registry.set(this._valuesByNameAtom, {});\n\n // Create a map of cell IDs to expressions for easy lookup.\n const cellExpressions = new Map<string, ParsedExpression>();\n Object.entries(expressions).forEach(([id, expr]) => {\n cellExpressions.set(id, expr);\n });\n\n // Topological sort to determine evaluation order.\n const evaluationOrder = this.topologicalSort(Object.keys(expressions), dependencyGraph);\n\n // Values by reference name.\n const valuesByName: Record<string, any> = {};\n const valuesByCellId: Record<string, any> = {};\n\n // Evaluate cells in dependency order.\n for (const cellId of evaluationOrder) {\n const expr = cellExpressions.get(cellId);\n if (!expr) {\n log.error('no expression for cell', { cellId });\n continue;\n }\n\n const cellSource = this._notebook.cells.find((cell) => cell.id === cellId)?.source?.target?.content;\n if (!cellSource) {\n log.error('no source for cell', { cellId });\n continue;\n }\n\n try {\n // For assignments or declarations, evaluate and store the value.\n if (expr.name && expr.value !== undefined) {\n // If the parser extracted a literal value, use it directly.\n valuesByName[expr.name] = expr.value;\n valuesByCellId[cellId] = expr.value;\n } else if (expr.name) {\n // For non-literal assignments, we need to evaluate the expression.\n // The parser identifies it's an assignment, so we can extract the RHS.\n const equalIndex = cellSource.indexOf('=');\n if (equalIndex !== -1) {\n // Find the actual assignment operator (not in strings or other contexts).\n let rhs = cellSource.substring(equalIndex + 1).trim();\n\n // Handle semicolon at the end.\n if (rhs.endsWith(';')) {\n rhs = rhs.slice(0, -1).trim();\n }\n\n const result = await this.eval(rhs, valuesByName);\n valuesByName[expr.name] = result;\n if (typeof result !== 'function') {\n valuesByCellId[cellId] = result;\n }\n }\n } else {\n // For expressions without assignment, just evaluate.\n const result = await this.eval(cellSource, valuesByName);\n valuesByCellId[cellId] = result;\n }\n } catch (error) {\n // TODO(burdon): Set error state.\n log.error('error evaluating cell', { cellId, error });\n }\n }\n\n this._registry.set(this._valuesByCellIdAtom, valuesByCellId);\n this._registry.set(this._valuesByNameAtom, valuesByName);\n return valuesByCellId;\n }\n\n private async eval(source: string, values: Record<string, any>) {\n return evalScript(source, values);\n }\n\n /**\n * Parse expressions.\n */\n parse() {\n const expressions = this._notebook.cells\n .filter((cell) => cell.type === 'script')\n .reduce<Record<string, ParsedExpression>>((acc, cell) => {\n const text = cell.source?.target?.content.trim();\n if (text) {\n const parsed = this._parser.parseExpression(text);\n acc[cell.id] = parsed;\n }\n\n return acc;\n }, {});\n\n // Build dependency graph.\n const dependencyGraph = this.buildDependencyGraph(expressions);\n this._registry.set(this._expressionsAtom, expressions);\n return { expressions, dependencyGraph };\n }\n\n private topologicalSort(nodes: string[], dependencies: Record<string, string[]>): string[] {\n const visited = new Set<string>();\n const result: string[] = [];\n\n const visit = (node: string) => {\n if (visited.has(node)) {\n return;\n }\n\n visited.add(node);\n\n // Visit dependencies first.\n const deps = dependencies[node] || [];\n deps.forEach((dep) => visit(dep));\n result.push(node);\n };\n\n // Visit all nodes.\n nodes.forEach((node) => visit(node));\n return result;\n }\n\n private buildDependencyGraph(expressions: Record<string, ParsedExpression>): Record<string, string[]> {\n // Create a map of variable names to their cell IDs.\n const nameToCellId = new Map<string, string>();\n Object.entries(expressions).forEach(([id, expr]) => {\n if (expr.name) {\n nameToCellId.set(expr.name, id);\n }\n });\n\n // Build the dependency graph using cell IDs.\n const graph: Record<string, string[]> = {};\n Object.entries(expressions).forEach(([id, expr]) => {\n if (expr.references && expr.references.length > 0) {\n // Map variable references to cell IDs.\n const dependencyCellIds = expr.references\n .map((ref) => nameToCellId.get(ref))\n .filter((cellId): cellId is string => cellId !== undefined && cellId !== id);\n\n if (dependencyCellIds.length > 0) {\n graph[id] = dependencyCellIds;\n }\n }\n });\n\n return graph;\n }\n}\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { trim } from '@dxos/util';\n\n/**\n * Evaluate the script (with dependencies as arguments).\n */\nexport const evalScript = async (code: string, deps: Record<string, any> = {}) => {\n // Create a sandboxed environment that blocks access to window and document.\n const sandbox = {\n ...deps,\n\n // Block access to global objects.\n console: undefined,\n document: undefined,\n global: undefined,\n globalThis: undefined,\n self: undefined,\n window: undefined,\n\n // Allow some safe globals.\n Array,\n Boolean,\n Date,\n Error,\n JSON,\n Map,\n Math,\n Number,\n Object,\n Promise,\n RegExp,\n Set,\n String,\n\n // Functions.\n isFinite,\n isNaN,\n parseFloat,\n parseInt,\n\n // Note: undefined and null are not included as they are keywords, not variables.\n };\n\n // Create function with all sandbox keys as parameters.\n const sandboxKeys = Object.keys(sandbox);\n const sandboxValues = Object.values(sandbox);\n\n // eslint-disable-next-line @typescript-eslint/no-implied-eval\n const fn = new Function(\n ...sandboxKeys,\n trim`\n 'use strict';\n return ${code};\n `,\n );\n\n return fn(...sandboxValues);\n};\n\n/**\n * Globals.\n */\nexport const builtIns = new Set([\n // Types.\n 'Array',\n 'Date',\n 'Error',\n 'JSON',\n 'Map',\n 'Math',\n 'Number',\n 'Object',\n 'Promise',\n 'RegExp',\n 'Set',\n 'String',\n\n // Functions.\n 'isFinite',\n 'isNaN',\n 'parseFloat',\n 'parseInt',\n]);\n\n/**\n * Default system definitions.\n */\nexport const systemDefinitions = trim`\n interface Array<T> { length: number; [n: number]: T; }\n interface Boolean {}\n interface Function {}\n interface IArguments {}\n interface Number {}\n interface Object {}\n interface RegExp {}\n interface String { length: number; }\n\n interface CallableFunction extends Function {}\n interface NewableFunction extends Function {}\n\n declare var console: { log(...args: any[]): void };\n`;\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { createSystem, createVirtualTypeScriptEnvironment } from '@typescript/vfs';\nimport ts from 'typescript';\n\nimport { invariant } from '@dxos/invariant';\n\nimport { builtIns, systemDefinitions } from './eval';\n\n/**\n * Default system definitions.\n */\nconst systemFiles: VirtualFile[] = [\n {\n filename: '/lib.d.ts',\n content: systemDefinitions,\n },\n];\n\nexport type ParsedExpression = {\n name?: string;\n type?: 'function' | 'variable' | 'class' | 'interface';\n value?: any;\n valueType?: string;\n parameters?: Array<{ name: string; type: string }>;\n returnType?: string;\n references?: string[];\n};\n\nexport type VirtualFile = {\n filename: string;\n content: string;\n};\n\n/**\n * TypeScript parser using Virtual File System for browser compatibility.\n * This provides full TypeScript analysis including type information.\n */\nexport class VirtualTypeScriptParser {\n protected compilerOptions: ts.CompilerOptions = {\n target: ts.ScriptTarget.ES2020,\n module: ts.ModuleKind.ESNext,\n moduleResolution: ts.ModuleResolutionKind.Bundler,\n strict: true,\n esModuleInterop: true,\n skipLibCheck: true,\n forceConsistentCasingInfilenames: true,\n jsx: ts.JsxEmit.React,\n noLib: true, // Don't automatically include default lib files.\n };\n\n /**\n * Parse a single expression or statement.\n */\n parseExpression(input: string): ParsedExpression {\n invariant(input.trim() !== '', 'input must not be empty');\n const files: VirtualFile[] = [{ filename: '/temp.ts', content: input }];\n const analysis = this.analyzeFiles(files);\n\n // If no declarations found, check for standalone expression references.\n if (analysis.length === 0) {\n const sourcefilename = '/temp.ts';\n const env = this.createEnvironment([{ filename: sourcefilename, content: input }]);\n const sourceFile = env.getSourceFile(sourcefilename);\n const typeChecker = env.languageService.getProgram()?.getTypeChecker();\n\n if (sourceFile && typeChecker) {\n // Check for assignment expressions.\n const assignmentInfo = this.findAssignmentExpression(sourceFile, typeChecker);\n if (assignmentInfo) {\n return assignmentInfo;\n }\n\n const references = this.findAllReferences(sourceFile, typeChecker);\n return { references };\n }\n }\n\n return analysis[0];\n }\n\n /**\n * Analyze multiple files with full type information.\n */\n analyzeFiles(files: VirtualFile[]): ParsedExpression[] {\n const env = this.createEnvironment(files);\n const results: ParsedExpression[] = [];\n const typeChecker = env.languageService.getProgram()?.getTypeChecker();\n\n // Analyze each file.\n files.forEach((file) => {\n const sourceFile = env.getSourceFile(file.filename);\n if (!sourceFile || !typeChecker) {\n return;\n }\n\n const fileResults = this.analyzeSourceFile(sourceFile, typeChecker);\n results.push(...fileResults);\n });\n\n return results;\n }\n\n /**\n * Analyze a source file with type information.\n */\n protected analyzeSourceFile(sourceFile: ts.SourceFile, typeChecker: ts.TypeChecker): ParsedExpression[] {\n const results: ParsedExpression[] = [];\n\n const visit = (node: ts.Node) => {\n // Function declarations.\n if (ts.isFunctionDeclaration(node) && node.name) {\n const symbol = typeChecker.getSymbolAtLocation(node.name);\n const type = symbol && typeChecker.getTypeOfSymbolAtLocation(symbol, node);\n const signature = type && typeChecker.getSignaturesOfType(type, ts.SignatureKind.Call)[0];\n\n results.push({\n name: node.name.text,\n type: 'function',\n parameters: this.extractParameters(signature, typeChecker),\n returnType: signature ? typeChecker.typeToString(signature.getReturnType()) : 'any',\n references: this.findReferences(node, sourceFile, typeChecker),\n });\n }\n\n // Variable declarations.\n else if (ts.isVariableStatement(node)) {\n node.declarationList.declarations.forEach((declaration) => {\n if (ts.isIdentifier(declaration.name)) {\n const symbol = typeChecker.getSymbolAtLocation(declaration.name);\n const type = symbol && typeChecker.getTypeOfSymbolAtLocation(symbol, declaration);\n\n let kind: 'function' | 'variable' = 'variable';\n let parameters: Array<{ name: string; type: string }> | undefined;\n let returnType: string | undefined;\n let value: any;\n\n // Get the type string.\n const typeString = type ? typeChecker.typeToString(type) : 'any';\n\n // Check if it's a function.\n if (declaration.initializer) {\n if (ts.isArrowFunction(declaration.initializer) || ts.isFunctionExpression(declaration.initializer)) {\n kind = 'function';\n const funcType = typeChecker.getTypeAtLocation(declaration.initializer);\n const signature = typeChecker.getSignaturesOfType(funcType, ts.SignatureKind.Call)[0];\n if (signature) {\n parameters = this.extractParameters(signature, typeChecker);\n returnType = typeChecker.typeToString(signature.getReturnType());\n }\n } else {\n // Extract literal values\n if (ts.isNumericLiteral(declaration.initializer)) {\n value = Number(declaration.initializer.text);\n } else if (ts.isStringLiteral(declaration.initializer)) {\n value = declaration.initializer.text;\n }\n }\n }\n\n // Find references in the initializer only.\n const refs = declaration.initializer\n ? this.findReferences(declaration.initializer, sourceFile, typeChecker)\n : [];\n\n results.push({\n name: declaration.name.text,\n type: kind,\n valueType: typeString,\n value,\n parameters,\n returnType,\n references: refs,\n });\n }\n });\n }\n\n // Class declarations.\n else if (ts.isClassDeclaration(node) && node.name) {\n results.push({\n name: node.name.text,\n type: 'class',\n references: this.findReferences(node, sourceFile, typeChecker),\n });\n }\n\n // Interface declarations.\n else if (ts.isInterfaceDeclaration(node)) {\n results.push({\n name: node.name.text,\n type: 'interface',\n references: this.findReferences(node, sourceFile, typeChecker),\n });\n }\n\n ts.forEachChild(node, visit);\n };\n\n visit(sourceFile);\n return results;\n }\n\n /**\n * Extract parameter information from a signature.\n */\n private extractParameters(\n signature: ts.Signature | undefined,\n typeChecker: ts.TypeChecker,\n ): Array<{ name: string; type: string }> {\n if (!signature) {\n return [];\n }\n\n return signature.parameters.map((param) => ({\n name: param.getName(),\n type: typeChecker.typeToString(typeChecker.getTypeOfSymbolAtLocation(param, param.valueDeclaration!)),\n }));\n }\n\n /**\n * Find all references to variables used in a node.\n */\n private findReferences(node: ts.Node, _sourceFile: ts.SourceFile, _typeChecker: ts.TypeChecker): string[] {\n const references = new Set<string>();\n const localSymbols = new Set<string>();\n\n // First, collect local symbols (parameters, local variables).\n const collectLocalSymbols = (node: ts.Node) => {\n if (ts.isFunctionDeclaration(node) || ts.isArrowFunction(node) || ts.isFunctionExpression(node)) {\n node.parameters.forEach((param) => {\n if (ts.isIdentifier(param.name)) {\n localSymbols.add(param.name.text);\n }\n });\n }\n\n if (ts.isVariableDeclaration(node) && ts.isIdentifier(node.name)) {\n localSymbols.add(node.name.text);\n }\n\n ts.forEachChild(node, collectLocalSymbols);\n };\n\n collectLocalSymbols(node);\n\n // Then find all identifier references.\n const findRefs = (node: ts.Node) => {\n if (ts.isIdentifier(node)) {\n // Skip if it's a local symbol.\n if (!localSymbols.has(node.text)) {\n // Check if it's a reference (not a declaration).\n const parent = node.parent;\n const isDeclaration =\n (ts.isVariableDeclaration(parent) && parent.name === node) ||\n (ts.isFunctionDeclaration(parent) && parent.name === node) ||\n (ts.isParameter(parent) && parent.name === node);\n\n if (!isDeclaration && !this.isBuiltIn(node.text)) {\n references.add(node.text);\n }\n }\n }\n ts.forEachChild(node, findRefs);\n };\n\n findRefs(node);\n return Array.from(references);\n }\n\n /**\n * Check if a name is a built-in global.\n */\n protected isBuiltIn(name: string): boolean {\n return builtIns.has(name);\n }\n\n /**\n * Find assignment expressions in a source file.\n */\n private findAssignmentExpression(sourceFile: ts.SourceFile, typeChecker: ts.TypeChecker): ParsedExpression | null {\n let result: ParsedExpression | null = null;\n\n const visit = (node: ts.Node) => {\n if (ts.isExpressionStatement(node) && ts.isBinaryExpression(node.expression)) {\n const expr = node.expression;\n if (expr.operatorToken.kind === ts.SyntaxKind.EqualsToken && ts.isIdentifier(expr.left)) {\n const type = typeChecker.getTypeAtLocation(expr.right);\n const typeString = typeChecker.typeToString(type);\n\n // Get the literal value if it's a literal.\n let value: any;\n if (ts.isNumericLiteral(expr.right)) {\n value = Number(expr.right.text);\n } else if (ts.isStringLiteral(expr.right)) {\n value = expr.right.text;\n }\n\n // Find references in the right-hand side.\n const references = this.findReferences(expr.right, sourceFile, typeChecker);\n\n result = {\n name: expr.left.text,\n type: 'variable',\n valueType: typeString,\n value,\n references,\n };\n }\n }\n if (!result) {\n ts.forEachChild(node, visit);\n }\n };\n\n visit(sourceFile);\n return result;\n }\n\n /**\n * Find all identifier references in a source file.\n */\n protected findAllReferences(sourceFile: ts.SourceFile, _typeChecker: ts.TypeChecker): string[] {\n const references = new Set<string>();\n\n const visit = (node: ts.Node) => {\n if (ts.isIdentifier(node)) {\n // Skip if it's a declaration.\n const parent = node.parent;\n const isDeclaration =\n (ts.isVariableDeclaration(parent) && parent.name === node) ||\n (ts.isFunctionDeclaration(parent) && parent.name === node) ||\n (ts.isParameter(parent) && parent.name === node);\n\n // Skip if it's the left-hand side of an assignment.\n const isAssignmentTarget =\n ts.isBinaryExpression(parent) &&\n parent.operatorToken.kind === ts.SyntaxKind.EqualsToken &&\n parent.left === node;\n\n if (!isDeclaration && !isAssignmentTarget && !this.isBuiltIn(node.text)) {\n references.add(node.text);\n }\n }\n ts.forEachChild(node, visit);\n };\n\n visit(sourceFile);\n return Array.from(references);\n }\n\n protected createEnvironment(files: VirtualFile[]) {\n const allFiles = [...systemFiles, ...files];\n\n const fileMap = new Map<string, string>();\n allFiles.forEach(({ filename, content }) => {\n fileMap.set(filename, content);\n });\n\n const system = createSystem(fileMap);\n return createVirtualTypeScriptEnvironment(\n system,\n allFiles.map(({ filename }) => filename),\n ts,\n this.compilerOptions,\n );\n }\n}\n\n/**\n * Notebook-specific parser with dependency analysis.\n */\nexport class NotebookVirtualParser extends VirtualTypeScriptParser {\n /**\n * Analyze notebook cells with full type checking.\n */\n analyzeNotebook(cells: Array<{ id: string; code: string }>) {\n // Create cumulative environment where each cell can see previous cells.\n const cumulativeCode: string[] = [];\n const cellAnalysis: Map<\n string,\n {\n exports: ParsedExpression[];\n imports: string[];\n errors: ts.Diagnostic[];\n }\n > = new Map();\n\n cells.forEach((cell) => {\n // Create files for all cells up to current.\n const files: VirtualFile[] = [];\n\n // Add previous cells as context.\n if (cumulativeCode.length > 0) {\n files.push({\n filename: '/context.ts',\n content: cumulativeCode.join('\\n'),\n });\n }\n\n // Add current cell.\n const filename = `/cell/${cell.id}.ts`;\n files.push({\n filename,\n content: cell.code,\n });\n\n // Create environment.\n const env = this.createEnvironment(files);\n\n // Get diagnostics (errors).\n const diagnostics = env.languageService.getSemanticDiagnostics(filename);\n\n // Analyze current cell.\n const sourceFile = env.getSourceFile(filename);\n const typeChecker = env.languageService.getProgram()?.getTypeChecker();\n\n if (sourceFile && typeChecker) {\n const exports = this.analyzeSourceFile(sourceFile, typeChecker);\n\n // Find all references in the current cell.\n const allRefs = new Set<string>();\n exports.forEach((exp) => {\n exp.references?.forEach((ref) => allRefs.add(ref));\n });\n\n // Also check for references not in exports (e.g., console.log(y)).\n const additionalRefs = this.findAllReferences(sourceFile, typeChecker);\n additionalRefs.forEach((ref) => allRefs.add(ref));\n\n // Determine which references are imports from previous cells.\n const previousExports = new Set<string>();\n for (const [_prevCellId, prevAnalysis] of cellAnalysis) {\n prevAnalysis.exports.forEach((exp) => {\n if (exp.name) {\n previousExports.add(exp.name);\n }\n });\n }\n\n const imports = Array.from(allRefs).filter((ref) => previousExports.has(ref));\n\n cellAnalysis.set(cell.id, {\n exports,\n imports,\n errors: diagnostics,\n });\n }\n\n // Add current cell code to cumulative.\n cumulativeCode.push(cell.code);\n });\n\n return cellAnalysis;\n }\n}\n"],
5
+ "mappings": ";;;AAIA,SAASA,uBAAuB;AAChC,YAAYC,WAAW;AACvB,YAAYC,YAAY;AACxB,YAAYC,UAAU;AAEtB,OAAO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A;KAAS;IAGZ;;SACoC,sBAAA,cAAA,MAAA,MAAA;;IACjBuD,WAAAA;KACb,sBAAA,cAACC,MAAAA,SAAY;IAACC,SAAAA;KACZ,sBAAA,cAACC,QAAAA,MAAaC;IACUJ,UAAAA,CAAAA;KACpB,sBAAA,cAACK,aAAAA,MAAAA,MAAAA,sBAAAA,cAAAA,aAAAA,SAAAA;IAAWC,SAAK;KAAoBC,sBAAAA,cAAAA,YAAAA;IAASC,MAAAA;;IAElCC,OAAAA,EAAAA,4BAAcC;OAE9B,sBAAA,cAACT,cAAQI;IACPC,cAAK;OACLC,sBAAAA,cAAAA,QAAAA,YAAAA;IACAC,MAAAA;IACAG,UAAAA;IACAC,OAAAA,EAASC,eAAAA;;IAMXrE,SAAIA;QACMC,sBAAAA,cAAAA,MAAAA,SAAAA,MAAAA,sBAAAA,cAAAA,eAAAA;IACVgB;IACAqD;IACAC;IACAN;IACAO;;IAKR,cAAA;EAEF,CAAA,CAAA,CAAA;AACA;gBAS0EpC,UAAAA,WAAAA,EAAAA,cAAAA,OAAAA,SAAAA,GAAAA;QAAcC,YAAAA;IAAM;IAC5F;EACA;QAGEoC,SAAW,OAACC,UAAAA,OAAAA,iBAAAA,SAAAA,EAAAA,KAAAA,cAAAA,WAAAA;aACV,QAAMC;eACFA,CAAAA,UAAYC;AAChBtC,YAAAA,QAAesC,mBAAO,KAAA,EAAA,CAAA;AACxB,MAAAC,KAAA,MAAA,MAAA,SAAA,MAAA,SAAA,MAAA,OAAA,EAAA,YAAA,YAAA,GAAAlF,eAAA,GAAA,KAAA,GAAA,KAAA,CAAA;AACAmF,eAAYvC,MAAAA,OAAAA;;IAEZ,WAAA,CAAAA,YAAA;AACF,eAAAA,QAAA,IAAA;IACF;;;",
6
+ "names": ["RegistryContext", "Cause", "Effect", "Exit", "React", "useCallback", "useContext", "useMemo", "useState", "useSpaceCallback", "RunInstructions", "Instructions", "Skill", "Operation", "Filter", "Obj", "Query", "Ref", "QueryBuilder", "invariant", "log", "Graph", "DropdownMenu", "IconButton", "Panel", "Toolbar", "useTranslation", "useAttention", "Text", "ViewModel", "isNonNullable", "NotebookMenu", "NotebookStack", "meta", "Atom", "log", "trim", "evalScript", "code", "deps", "sandbox", "console", "undefined", "document", "global", "globalThis", "self", "window", "Array", "Boolean", "Date", "Error", "JSON", "Map", "Math", "Number", "Object", "Promise", "RegExp", "Set", "String", "isFinite", "isNaN", "parseFloat", "parseInt", "sandboxKeys", "keys", "sandboxValues", "values", "fn", "Function", "builtIns", "systemDefinitions", "createSystem", "createVirtualTypeScriptEnvironment", "ts", "invariant", "filename", "target", "ts", "ModuleKind", "moduleResolution", "ModuleResolutionKind", "strict", "esModuleInterop", "skipLibCheck", "forceConsistentCasingInfilenames", "jsx", "JsxEmit", "noLib", "analysis", "length", "env", "createEnvironment", "sourcefilename", "sourceFile", "typeChecker", "assignmentInfo", "references", "results", "languageService", "getProgram", "files", "forEach", "file", "node", "isFunctionDeclaration", "getTypeOfSymbolAtLocation", "signature", "getSignaturesOfType", "name", "type", "parameters", "returnType", "findReferences", "isVariableStatement", "declaration", "symbol", "getSymbolAtLocation", "kind", "value", "initializer", "getTypeAtLocation", "extractParameters", "isStringLiteral", "valueType", "typeString", "isInterfaceDeclaration", "forEachChild", "visit", "typeToString", "localSymbols", "Set", "collectLocalSymbols", "param", "has", "parent", "isDeclaration", "text", "findRefs", "isExpressionStatement", "expr", "SyntaxKind", "EqualsToken", "isIdentifier", "right", "isAssignmentTarget", "isBinaryExpression", "operatorToken", "systemFiles", "fileMap", "allFiles", "system", "createSystem", "__dxlog_file", "_parser", "_expressionsAtom", "_valuesByCellIdAtom", "_valuesByNameAtom", "Atom", "_registry", "_notebook", "expressions", "cellExpressions", "Map", "id", "expr", "valuesByName", "evaluationOrder", "log", "cellId", "name", "cellSource", "rhs", "endsWith", "result", "eval", "valuesByCellId", "error", "source", "parsed", "parseExpression", "acc", "cell", "dependencyGraph", "topologicalSort", "visit", "node", "visited", "has", "deps", "dependencies", "nodes", "buildDependencyGraph", "nameToCellId", "references", "dependencyCellIds", "map", "ref", "graph", "__dxlog_file", "INCLUDE_SKILLS", "registry", "useContext", "RegistryContext", "db", "notebook", "getDatabase", "hasAttention", "useAttention", "attendableId", "invariant", "QueryBuilder", "cell", "cells", "type", "source", "target", "filter", "ast", "Query", "select", "graph", "view", "update", "Ref", "make", "newGraph", "c", "name", "Obj", "query", "fromAst", "objects", "objectIds", "map", "obj", "id", "setQueryValues", "prev", "allInstructions", "instructions", "input", "onResult", "result", "setPromptResults", "queryValues", "evaluate", "handleExecPrompts", "crypto", "randomUUID", "getMeta", "skill", "key", "undefined", "Instructions", "text", "skills", "idx", "splice", "findIndex", "asChild", "Toolbar", "disabled", "DropdownMenu", "Root", "IconButton", "icon", "iconOnly", "label", "onCellInsert", "handleCellInsert", "classNames", "onClick", "handleCompute", "env", "promptResults", "onCellDelete", "onFailure", "cause", "error", "message", "log", "onSuccess"]
7
+ }
@@ -3,11 +3,11 @@ import "./chunk-J5LGTIGS.mjs";
3
3
  // src/containers/ScriptArticle/ScriptArticle.tsx
4
4
  import React, { useMemo } from "react";
5
5
  import { Obj } from "@dxos/echo";
6
- import { createDocAccessor } from "@dxos/echo-client";
6
+ import { Doc } from "@dxos/echo-doc";
7
7
  import { getSpace } from "@dxos/react-client/echo";
8
8
  import { useIdentity } from "@dxos/react-client/halo";
9
9
  import { Panel } from "@dxos/react-ui";
10
- import { createDataExtensions, listener, editorClassNames } from "@dxos/ui-editor";
10
+ import { createDataExtensions, editorClassNames, listener } from "@dxos/ui-editor";
11
11
  import { ScriptToolbar, TypescriptEditor } from "#components";
12
12
  import { useDeployState, useToolbarState } from "#hooks";
13
13
  var ScriptArticle = ({ role, attendableId, subject: script, settings = {
@@ -27,7 +27,7 @@ var ScriptArticle = ({ role, attendableId, subject: script, settings = {
27
27
  return [
28
28
  createDataExtensions({
29
29
  id: script.id,
30
- text: createDocAccessor(script.source.target, [
30
+ text: Doc.createAccessor(script.source.target, [
31
31
  "content"
32
32
  ]),
33
33
  messenger: space,
@@ -76,4 +76,4 @@ var ScriptArticle = ({ role, attendableId, subject: script, settings = {
76
76
  export {
77
77
  ScriptArticle as default
78
78
  };
79
- //# sourceMappingURL=ScriptArticle-QW26LOKU.mjs.map
79
+ //# sourceMappingURL=ScriptArticle-I3DOJARR.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/containers/ScriptArticle/ScriptArticle.tsx"],
4
+ "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport React, { useMemo } from 'react';\n\nimport { type AppSurface } from '@dxos/app-toolkit/ui';\nimport { type Script } from '@dxos/compute';\nimport { Obj } from '@dxos/echo';\nimport { Doc } from '@dxos/echo-doc';\nimport { getSpace } from '@dxos/react-client/echo';\nimport { useIdentity } from '@dxos/react-client/halo';\nimport { Panel } from '@dxos/react-ui';\nimport { createDataExtensions, editorClassNames, listener } from '@dxos/ui-editor';\n\nimport { ScriptToolbar, TypescriptEditor, type TypescriptEditorProps } from '#components';\nimport { useDeployState, useToolbarState } from '#hooks';\nimport { type Settings } from '#types';\n\nexport type ScriptEditorProps = AppSurface.ObjectArticleProps<\n Script.Script,\n {\n settings?: Settings.Settings;\n } & Pick<TypescriptEditorProps, 'env'>\n>;\n\nexport const ScriptArticle = ({\n role,\n attendableId,\n subject: script,\n settings = { editorInputMode: 'vscode' },\n env,\n}: ScriptEditorProps) => {\n const identity = useIdentity();\n const space = getSpace(script);\n const state = useToolbarState();\n useDeployState({ script, state });\n\n const extensions = useMemo(() => {\n if (!script.source.target) {\n return [];\n }\n\n return [\n createDataExtensions({\n id: script.id,\n text: Doc.createAccessor(script.source.target, ['content']),\n messenger: space,\n identity,\n }),\n listener({\n onChange: ({ text }) => {\n if (script.source.target?.content !== text) {\n Obj.update(script, (script) => {\n script.changed = true;\n });\n }\n },\n }),\n ];\n }, [identity, space, script, script.source.target]);\n\n if (!extensions.length) {\n return null;\n }\n\n return (\n <Panel.Root role={role}>\n <Panel.Toolbar asChild>\n <ScriptToolbar script={script} attendableId={attendableId} state={state} role={role} />\n </Panel.Toolbar>\n <Panel.Content asChild>\n <TypescriptEditor\n classNames={editorClassNames(role)}\n id={script.id}\n env={env}\n initialValue={script.source?.target?.content}\n extensions={extensions}\n inputMode={settings.editorInputMode}\n toolbar\n />\n </Panel.Content>\n </Panel.Root>\n );\n};\n"],
5
+ "mappings": ";;;AAIA,OAAOA,SAASC,eAAe;AAI/B,SAASC,WAAW;AACpB,SAASC,WAAW;AACpB,SAASC,gBAAgB;AACzB,SAASC,mBAAmB;AAC5B,SAASC,aAAa;AACtB,SAASC,sBAAsBC,kBAAkBC,gBAAgB;AAEjE,SAASC,eAAeC,wBAAoD;AAC5E,SAASC,gBAAgBC,uBAAuB;AAUzC,IAAMC,gBAAgB,CAAC,EAC5BC,MACAC,cACAC,SAASC,QACTC,WAAW;EAAEC,iBAAiB;AAAS,GACvCC,IAAG,MACe;AAClB,QAAMC,WAAWjB,YAAAA;AACjB,QAAMkB,QAAQnB,SAASc,MAAAA;AACvB,QAAMM,QAAQX,gBAAAA;AACdD,iBAAe;IAAEM;IAAQM;EAAM,CAAA;AAE/B,QAAMC,aAAaxB,QAAQ,MAAA;AACzB,QAAI,CAACiB,OAAOQ,OAAOC,QAAQ;AACzB,aAAO,CAAA;IACT;AAEA,WAAO;MACLpB,qBAAqB;QACnBqB,IAAIV,OAAOU;QACXC,MAAM1B,IAAI2B,eAAeZ,OAAOQ,OAAOC,QAAQ;UAAC;SAAU;QAC1DI,WAAWR;QACXD;MACF,CAAA;MACAb,SAAS;QACPuB,UAAU,CAAC,EAAEH,KAAI,MAAE;AACjB,cAAIX,OAAOQ,OAAOC,QAAQM,YAAYJ,MAAM;AAC1C3B,gBAAIgC,OAAOhB,QAAQ,CAACA,YAAAA;AAClBA,cAAAA,QAAOiB,UAAU;YACnB,CAAA;UACF;QACF;MACF,CAAA;;EAEJ,GAAG;IAACb;IAAUC;IAAOL;IAAQA,OAAOQ,OAAOC;GAAO;AAElD,MAAI,CAACF,WAAWW,QAAQ;AACtB,WAAO;EACT;AAEA,SACE,sBAAA,cAAC9B,MAAM+B,MAAI;IAACtB;KACV,sBAAA,cAACT,MAAMgC,SAAO;IAACC,SAAAA;KACb,sBAAA,cAAC7B,eAAAA;IAAcQ;IAAgBF;IAA4BQ;IAAcT;OAE3E,sBAAA,cAACT,MAAMkC,SAAO;IAACD,SAAAA;KACb,sBAAA,cAAC5B,kBAAAA;IACC8B,YAAYjC,iBAAiBO,IAAAA;IAC7Ba,IAAIV,OAAOU;IACXP;IACAqB,cAAcxB,OAAOQ,QAAQC,QAAQM;IACrCR;IACAkB,WAAWxB,SAASC;IACpBwB,SAAAA;;AAKV;",
6
+ "names": ["React", "useMemo", "Obj", "Doc", "getSpace", "useIdentity", "Panel", "createDataExtensions", "editorClassNames", "listener", "ScriptToolbar", "TypescriptEditor", "useDeployState", "useToolbarState", "ScriptArticle", "role", "attendableId", "subject", "script", "settings", "editorInputMode", "env", "identity", "space", "state", "extensions", "source", "target", "id", "text", "createAccessor", "messenger", "onChange", "content", "update", "changed", "length", "Root", "Toolbar", "asChild", "Content", "classNames", "initialValue", "inputMode", "toolbar"]
7
+ }
@@ -4,19 +4,19 @@ import "./chunk-J5LGTIGS.mjs";
4
4
  import { Plugin } from "@dxos/app-framework";
5
5
  import { AppActivationEvents, AppPlugin } from "@dxos/app-toolkit";
6
6
  import { Script } from "@dxos/compute";
7
- import { AppGraphBuilder, BlueprintDefinition, Compiler, CreateObject, OperationHandler, ReactSurface, ScriptSettings } from "#capabilities";
7
+ import { AppGraphBuilder, Compiler, CreateObject, OperationHandler, ReactSurface, ScriptSettings, SkillDefinition } from "#capabilities";
8
8
  import { meta } from "#meta";
9
9
  import { translations } from "#translations";
10
10
  import { ScriptEvents } from "#types";
11
11
 
12
- // raw-loader:/__w/dxos/dxos/packages/plugins/plugin-script/PLUGIN.mdl?raw
13
- var PLUGIN_default = '---\nid: org.dxos.plugin.script\nname: ScriptPlugin\nversion: 0.1.0\n---\n\nA scripting plugin for `DXOS` Composer that lets users write, deploy, and run custom TypeScript functions as\nECHO objects inside their spaces.\nScripts execute on the Cloudflare Workers-based EDGE runtime and can call DXOS SDK packages, Effect-TS,\nand a curated set of third-party libraries.\nAn AI assistant blueprint wires CRUD, deploy, invoke, and inspection operations as tools so an agent can\nscaffold, iterate, and test scripts entirely within a chat session.\n\n## Extensions\n\nThe following extension dialects are used in this document.\nEach extension is defined in the Appendix or resolved via its URI.\n\n| Term | URI |\n|-------------|--------------------------------|\n| `type` | `org.dxos.mdl.type@1.0` |\n| `feat` | `org.dxos.mdl.feat@1.0` |\n| `test` | `org.dxos.mdl.test@1.0` |\n| `component` | `org.dxos.mdl.component@1.0` |\n| `op` | `org.dxos.mdl.op@1.0` |\n\n## Types\n\n```mdl\ntype Script\n desc: |\n Root ECHO object (typename from @dxos/compute Script.Script).\n Represents a single deployable TypeScript function.\n fields:\n name?: string\n source: string # TypeScript source, must follow Operation pattern\n description?: string\n```\n\n```mdl\ntype Notebook\n desc: |\n Root ECHO object for a multi-cell notebook view.\n Each cell is a Script; the Notebook provides a sequential execution surface.\n fields:\n name?: string\n```\n\n```mdl\ntype Settings\n desc: Plugin-scoped settings atom. Persisted across sessions.\n fields:\n editorInputMode?: EditorInputMode # default, vim, or emacs keybindings\n```\n\n```mdl\ntype InvocationSpan\n desc: A single function invocation record from the EDGE trace feed.\n fields:\n id: string\n timestamp: number # epoch ms\n duration: number # ms\n outcome: success | failure | pending\n input: object\n error?: object\n```\n\n```mdl\ntype DeployedFunction\n desc: Metadata about a function already deployed to the EDGE runtime.\n fields:\n key?: string # unique key; pass to InstallFunction\n name: string\n version: string\n description?: string\n updated?: string # ISO timestamp\n```\n\n## Components\n\n```mdl\ncomponent ScriptArticle\n desc: |\n Primary editor surface for a Script object. Rendered for the Article and\n Section roles. Shows a TypeScript CodeMirror editor with syntax highlight,\n lint, and completion. Companion panels (Execute and Logs) are available\n via the app graph for running and inspecting the script.\n props:\n role: string\n subject: Script\n attendableId?: string\n settings?: Settings\n env?: CompilerEnvironment\n layout: |\n \u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\n \u2502 ScriptToolbar (run, deploy, \u2026) \u2502\n \u251C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524\n \u2502 TypescriptEditor (CodeMirror) \u2502\n \u2502 \u2502\n \u2502 // script source \u2502\n \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\n```\n\n```mdl\ncomponent NotebookArticle\n desc: |\n Multi-cell notebook surface for a Notebook object. Each cell renders a\n ScriptArticle in Section role. Cells can be added, removed, and reordered.\n props:\n role: string\n subject: Notebook\n attendableId?: string\n env?: CompilerEnvironment\n```\n\n```mdl\ncomponent TestContainer\n desc: |\n Execute companion panel. Renders a form driven by the script\'s Operation\n input schema; submits the form to invoke the script and shows the response.\n props:\n script: Script\n role: string\n```\n\n```mdl\ncomponent DeploymentDialog\n desc: |\n Dialog for deploying or redeploying a Script to the EDGE runtime.\n Shows current deployment status and lets the user trigger a new deployment.\n props:\n script: Script\n```\n\n```mdl\ncomponent ScriptPluginSettings\n desc: Plugin settings panel; exposes editor keybinding mode selector.\n props:\n settings: Settings\n onSettingsChange: (settings: Settings) \u2192 void\n onAuthenticate: () \u2192 Promise<void>\n```\n\n## Operations\n\nBlueprint operations (called by the Script assistant via its tool set).\n\n```mdl\nop create\n desc: |\n Creates a new Script ECHO object with the given name and TypeScript source,\n and adds it to the space. Optionally seeds from a built-in template or a\n GitHub Gist URL. Returns a function reference ID.\n input:\n name: string\n source?: string\n templateId?: string\n output: { function: string }\n effects: [echo:write]\n note: Operation key `org.dxos.function.script.create`.\n```\n\n```mdl\nop read\n desc: Reads the name, source code, and description of an existing Script.\n input:\n function: Ref<Script>\n output: { name?: string, source: string, description?: string }\n effects: [echo:read]\n note: Operation key `org.dxos.function.script.read`.\n```\n\n```mdl\nop update\n desc: |\n Applies one or more string edits (find/replace pairs) to a Script\'s source\n and optionally updates its name and description.\n input:\n function: Ref<Script>\n name?: string\n description?: string\n edits?: { oldString: string, newString: string, replaceAll?: boolean }[]\n output: { function: string }\n effects: [echo:read, echo:write]\n note: Operation key `org.dxos.function.script.update`.\n```\n\n```mdl\nop delete\n desc: Permanently removes a Script and its source from the space.\n input:\n function: Ref<Script>\n output: void\n effects: [echo:read, echo:write]\n note: Operation key `org.dxos.function.script.delete`.\n```\n\n```mdl\nop deploy\n desc: |\n Compiles and deploys a Script to the EDGE (Cloudflare Workers) runtime.\n The source must export a single Operation handler as default.\n Returns the deployed function ID and optional public URL.\n input:\n function: Ref<Script>\n output: { function: string, functionUrl?: string }\n effects: [echo:read, http]\n errors:\n CompileError: TypeScript source fails to compile\n DeploymentFailed: EDGE runtime rejected the deployment\n note: Operation key `org.dxos.function.script.deploy`.\n```\n\n```mdl\nop invoke\n desc: Calls a deployed EDGE function with an optional JSON payload.\n input:\n function: Ref<Script>\n payload?: unknown\n output: { response: unknown }\n effects: [http]\n errors:\n NotDeployed: function has not been deployed\n InvocationError: function threw at runtime\n note: Operation key `org.dxos.function.script.invoke`.\n```\n\n```mdl\nop inspectInvocations\n desc: |\n Queries the EDGE invocation trace feed for a function and returns\n recent invocation spans (id, timestamp, duration, outcome, input, error).\n input:\n function: Ref<Script>\n limit?: number # default 20\n output: { invocations: InvocationSpan[], total: number }\n effects: [echo:read]\n note: Operation key `org.dxos.function.script.inspect-invocations`.\n```\n\n```mdl\nop queryDeployedFunctions\n desc: Lists all functions currently deployed to the EDGE runtime.\n input:\n (none)\n output: { functions: DeployedFunction[] }\n effects: [http]\n note: Operation key `org.dxos.function.script.query-deployed`.\n```\n\n```mdl\nop installFunction\n desc: |\n Installs a globally-deployed EDGE function into the current space by key.\n Creates a Script ECHO object backed by the remote function.\n The returned function ID can be passed directly to op:invoke.\n input:\n key: string\n output: { function: string, name: string, version: string }\n effects: [echo:write, http]\n note: Operation key `org.dxos.function.script.install`.\n```\n\nUI-facing operation (creates Script via the navtree / "create object" flow).\n\n```mdl\nop createScript\n desc: Creates a new Script ECHO object via the Composer create-object flow.\n input:\n name?: string\n gistUrl?: string\n initialTemplateId?: string\n db: Database\n output: { object: Script }\n effects: [echo:write]\n note: Operation key `org.dxos.plugin.script.operation.create-script`.\n```\n\n## Features\n\n```mdl\nfeat F-1: Script ECHO Object\n\n req F-1.1: Script objects are registered via `addSchemaModule` and visible in space object lists.\n req F-1.2: Script objects can be created from the navtree "+" menu.\n req F-1.3:\n when: user creates a Script without a template\n then: source is seeded from the default template\n req F-1.4:\n when: user provides a GitHub Gist URL\n then: gist content is fetched and used as initial source\n```\n\n```mdl\nfeat F-2: Script Editor\n\n req F-2.1: ScriptArticle renders a TypeScript-aware CodeMirror editor for the Article role.\n req F-2.2: Editor keybinding mode (default/vim/emacs) is configurable via plugin settings.\n req F-2.3: Changes to source are persisted to the Script ECHO object reactively.\n req F-2.4:\n when: script object changes externally (peer edit)\n then: editor content updates without losing cursor position if possible\n```\n\n```mdl\nfeat F-3: Deploy to EDGE\n\n req F-3.1: A Deploy button in the ScriptToolbar opens the DeploymentDialog.\n req F-3.2:\n when: user confirms deployment\n then: op:deploy is called; script compiled and sent to EDGE runtime\n req F-3.3:\n when: compilation fails\n then: error messages are surfaced to the user; no deployment occurs\n req F-3.4:\n when: deployment succeeds\n then: dialog shows the function URL (if available)\n```\n\n```mdl\nfeat F-4: Execute Companion\n\n req F-4.1: An "Execute" companion node is added to every Script in the app graph.\n req F-4.2: TestContainer renders a form derived from the script\'s Operation input schema.\n req F-4.3:\n when: user submits the form\n then: op:invoke is called with the form payload; response displayed\n req F-4.4: A "Logs" companion node shows the invocation trace via InvocationTraceContainer.\n```\n\n```mdl\nfeat F-5: Script Blueprint\n\n req F-5.1: A blueprint with key `org.dxos.blueprint.script` is contributed via `addBlueprintDefinitionModule`.\n req F-5.2: Blueprint tool set includes: create, read, update, delete, deploy, invoke,\n inspectInvocations, queryDeployedFunctions, installFunction.\n req F-5.3: System instructions describe the EDGE Operation pattern, required export format,\n and available packages.\n req F-5.4: Blueprint is agent-enabled; the assistant can activate it autonomously.\n```\n\n```mdl\nfeat F-6: Notebook\n\n req F-6.1: Notebook objects are registered and can be created from the navtree.\n req F-6.2: NotebookArticle renders each linked Script as a sequential cell.\n req F-6.3: Cells can be added and removed independently.\n```\n\n```mdl\nfeat F-7: Plugin Settings\n\n req F-7.1: ScriptPluginSettings is rendered via the app settings surface.\n req F-7.2: Editor input mode is persisted in the Settings atom.\n req F-7.3: An Authenticate button lets the user write an access credential to HALO.\n```\n\n## Acceptance\n\n```mdl\ntest T-1: Create script from default template\n given: a space is open and plugin-script is loaded\n when: user creates a new Script without template selection\n then:\n - a Script object appears in the space\n - its source contains the default template code\n - ScriptArticle renders the source in the editor\n```\n\n```mdl\ntest T-2: Create script from Gist\n given: a public GitHub Gist URL is known\n when: user creates a Script with the Gist URL\n then:\n - gist content is fetched and stored as the script source\n - editor shows the fetched content\n```\n\n```mdl\ntest T-3: Edit and persist source\n given: a Script is open in ScriptArticle\n when: user edits the source\n then:\n - the Script ECHO object\'s source field is updated\n - closing and reopening the article shows the same content\n```\n\n```mdl\ntest T-4: Deploy script\n given: a Script with valid source following the Operation pattern\n when: user opens DeploymentDialog and confirms\n then:\n - op:deploy succeeds\n - dialog shows success state and function URL\n```\n\n```mdl\ntest T-5: Invoke deployed function\n given: a Script is deployed\n when: user opens the Execute companion and submits a payload\n then:\n - op:invoke is called with the payload\n - response is displayed in TestContainer\n```\n\n```mdl\ntest T-6: Inspect invocations\n given: a Script has been invoked at least once\n when: user opens the Logs companion\n then:\n - InvocationTraceContainer shows at least one invocation span\n - span includes timestamp, duration, and outcome\n```\n\n```mdl\ntest T-7: Blueprint tools resolve\n given: composer-app with plugin-script loaded\n when: AppCapabilities.BlueprintDefinition is queried for `org.dxos.blueprint.script`\n then:\n - blueprint is present\n - tool set includes create, read, update, delete, deploy, invoke,\n inspectInvocations, queryDeployedFunctions, and installFunction\n```\n\n```mdl\ntest T-8: Agent creates and deploys script\n given: a Script assistant session is active\n when: agent calls op:create with a name and source\n then: a Script object is created in the space\n when: agent calls op:deploy\n then: function is deployed; op returns a function ID\n when: agent calls op:invoke with a payload\n then: response is returned without error\n```\n\n```mdl\ntest T-9: QueryDeployedFunctions and install\n given: at least one function is deployed to the EDGE runtime\n when: op:queryDeployedFunctions is called\n then:\n - result contains at least one DeployedFunction entry\n when: op:installFunction is called with that entry\'s key\n then:\n - a new Script ECHO object appears in the space\n - op returns the function ID, name, and version\n```\n\n---\n\n## Appendix: Extension Definitions\n\nExtension block types used in this document are defined below using\nthe core `ext` primitive \u2014 the only construct the base language provides.\n\n```mdl\next type\n uri: org.dxos.mdl.type@1.0\n desc: A named data structure with typed fields and optional literals.\n fields:\n desc?: Prose\n fields?: FieldMap # name[?]: TypeExpr (# inline comment)\n literals?: UnionList # a | b | c\n extends?: TypeRef[]\n```\n\n```mdl\next feat\n uri: org.dxos.mdl.feat@1.0\n desc: A named feature grouping one or more requirements.\n fields:\n desc?: Prose\n req: RequirementList\n nesting: self # feat blocks may contain feat blocks\n```\n\n```mdl\next test\n uri: org.dxos.mdl.test@1.0\n desc: An acceptance scenario expressed as given / when / then steps.\n fields:\n given?: Step | Step[]\n when?: Step | Step[]\n then: Step | Step[]\n tags?: TagList\n```\n\n```mdl\next component\n uri: org.dxos.mdl.component@1.0\n desc: A UI component with props, internal state, slots, actions, and events.\n fields:\n desc?: Prose\n props?: FieldMap # external inputs (immutable inside component)\n state?: FieldMap # internal reactive state\n slots?: FieldMap # named ReactNode injection points\n actions?: ActionMap # methods the component exposes or handles\n emits?: EventMap # events the component raises to its parent\n layout?: CodeBlock # ASCII sketch of visual structure (non-normative)\n```\n\n```mdl\next op\n uri: org.dxos.mdl.op@1.0\n desc: |\n A named operation with typed inputs, outputs, and declared errors.\n Pure ops have no effects or requires. Effectful ops declare both.\n fields:\n desc?: Prose\n input?: FieldMap # named input parameters\n output?: TypeExpr # return type\n errors?: ErrorMap # name: Prose (when this error occurs)\n effects?: EffectList # echo:read | echo:write | http | fs | ...\n requires?: ServiceList # injected service dependencies\n note?: Prose # implementation guidance (non-normative)\n```\n';
12
+ // raw-loader:/__w/dxos/dxos/packages/plugins/plugin-script/PLUGIN.mdl
13
+ var PLUGIN_default = '---\nid: org.dxos.plugin.script\nname: ScriptPlugin\nversion: 0.1.0\n---\n\nA scripting plugin for `DXOS` Composer that lets users write, deploy, and run custom TypeScript functions as\nECHO objects inside their spaces.\nScripts execute on the Cloudflare Workers-based EDGE runtime and can call DXOS SDK packages, Effect-TS,\nand a curated set of third-party libraries.\nAn AI assistant skill wires CRUD, deploy, invoke, and inspection operations as tools so an agent can\nscaffold, iterate, and test scripts entirely within a chat session.\n\n## Extensions\n\nThe following extension dialects are used in this document.\nEach extension is defined in the Appendix or resolved via its URI.\n\n| Term | URI |\n|-------------|--------------------------------|\n| `type` | `org.dxos.mdl.type@1.0` |\n| `feat` | `org.dxos.mdl.feat@1.0` |\n| `test` | `org.dxos.mdl.test@1.0` |\n| `component` | `org.dxos.mdl.component@1.0` |\n| `op` | `org.dxos.mdl.op@1.0` |\n\n## Types\n\n```mdl\ntype Script\n desc: |\n Root ECHO object (typename from @dxos/compute Script.Script).\n Represents a single deployable TypeScript function.\n fields:\n name?: string\n source: string # TypeScript source, must follow Operation pattern\n description?: string\n```\n\n```mdl\ntype Notebook\n desc: |\n Root ECHO object for a multi-cell notebook view.\n Each cell is a Script; the Notebook provides a sequential execution surface.\n fields:\n name?: string\n```\n\n```mdl\ntype Settings\n desc: Plugin-scoped settings atom. Persisted across sessions.\n fields:\n editorInputMode?: EditorInputMode # default, vim, or emacs keybindings\n```\n\n```mdl\ntype InvocationSpan\n desc: A single function invocation record from the EDGE trace feed.\n fields:\n id: string\n timestamp: number # epoch ms\n duration: number # ms\n outcome: success | failure | pending\n input: object\n error?: object\n```\n\n```mdl\ntype DeployedFunction\n desc: Metadata about a function already deployed to the EDGE runtime.\n fields:\n key?: string # unique key; pass to InstallFunction\n name: string\n version: string\n description?: string\n updated?: string # ISO timestamp\n```\n\n## Components\n\n```mdl\ncomponent ScriptArticle\n desc: |\n Primary editor surface for a Script object. Rendered for the Article and\n Section roles. Shows a TypeScript CodeMirror editor with syntax highlight,\n lint, and completion. Companion panels (Execute and Logs) are available\n via the app graph for running and inspecting the script.\n props:\n role: string\n subject: Script\n attendableId?: string\n settings?: Settings\n env?: CompilerEnvironment\n layout: |\n \u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\n \u2502 ScriptToolbar (run, deploy, \u2026) \u2502\n \u251C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524\n \u2502 TypescriptEditor (CodeMirror) \u2502\n \u2502 \u2502\n \u2502 // script source \u2502\n \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\n```\n\n```mdl\ncomponent NotebookArticle\n desc: |\n Multi-cell notebook surface for a Notebook object. Each cell renders a\n ScriptArticle in Section role. Cells can be added, removed, and reordered.\n props:\n role: string\n subject: Notebook\n attendableId?: string\n env?: CompilerEnvironment\n```\n\n```mdl\ncomponent TestContainer\n desc: |\n Execute companion panel. Renders a form driven by the script\'s Operation\n input schema; submits the form to invoke the script and shows the response.\n props:\n script: Script\n role: string\n```\n\n```mdl\ncomponent DeploymentDialog\n desc: |\n Dialog for deploying or redeploying a Script to the EDGE runtime.\n Shows current deployment status and lets the user trigger a new deployment.\n props:\n script: Script\n```\n\n```mdl\ncomponent ScriptPluginSettings\n desc: Plugin settings panel; exposes editor keybinding mode selector.\n props:\n settings: Settings\n onSettingsChange: (settings: Settings) \u2192 void\n onAuthenticate: () \u2192 Promise<void>\n```\n\n## Operations\n\nSkill operations (called by the Script assistant via its tool set).\n\n```mdl\nop create\n desc: |\n Creates a new Script ECHO object with the given name and TypeScript source,\n and adds it to the space. Optionally seeds from a built-in template or a\n GitHub Gist URL. Returns a function reference ID.\n input:\n name: string\n source?: string\n templateId?: string\n output: { function: string }\n effects: [echo:write]\n note: Operation key `org.dxos.function.script.create`.\n```\n\n```mdl\nop read\n desc: Reads the name, source code, and description of an existing Script.\n input:\n function: Ref<Script>\n output: { name?: string, source: string, description?: string }\n effects: [echo:read]\n note: Operation key `org.dxos.function.script.read`.\n```\n\n```mdl\nop update\n desc: |\n Applies one or more string edits (find/replace pairs) to a Script\'s source\n and optionally updates its name and description.\n input:\n function: Ref<Script>\n name?: string\n description?: string\n edits?: { oldString: string, newString: string, replaceAll?: boolean }[]\n output: { function: string }\n effects: [echo:read, echo:write]\n note: Operation key `org.dxos.function.script.update`.\n```\n\n```mdl\nop delete\n desc: Permanently removes a Script and its source from the space.\n input:\n function: Ref<Script>\n output: void\n effects: [echo:read, echo:write]\n note: Operation key `org.dxos.function.script.delete`.\n```\n\n```mdl\nop deploy\n desc: |\n Compiles and deploys a Script to the EDGE (Cloudflare Workers) runtime.\n The source must export a single Operation handler as default.\n Returns the deployed function ID and optional public URL.\n input:\n function: Ref<Script>\n output: { function: string, functionUrl?: string }\n effects: [echo:read, http]\n errors:\n CompileError: TypeScript source fails to compile\n DeploymentFailed: EDGE runtime rejected the deployment\n note: Operation key `org.dxos.function.script.deploy`.\n```\n\n```mdl\nop invoke\n desc: Calls a deployed EDGE function with an optional JSON payload.\n input:\n function: Ref<Script>\n payload?: unknown\n output: { response: unknown }\n effects: [http]\n errors:\n NotDeployed: function has not been deployed\n InvocationError: function threw at runtime\n note: Operation key `org.dxos.function.script.invoke`.\n```\n\n```mdl\nop inspectInvocations\n desc: |\n Queries the EDGE invocation trace feed for a function and returns\n recent invocation spans (id, timestamp, duration, outcome, input, error).\n input:\n function: Ref<Script>\n limit?: number # default 20\n output: { invocations: InvocationSpan[], total: number }\n effects: [echo:read]\n note: Operation key `org.dxos.function.script.inspect-invocations`.\n```\n\n```mdl\nop queryDeployedFunctions\n desc: Lists all functions currently deployed to the EDGE runtime.\n input:\n (none)\n output: { functions: DeployedFunction[] }\n effects: [http]\n note: Operation key `org.dxos.function.script.query-deployed`.\n```\n\n```mdl\nop installFunction\n desc: |\n Installs a globally-deployed EDGE function into the current space by key.\n Creates a Script ECHO object backed by the remote function.\n The returned function ID can be passed directly to op:invoke.\n input:\n key: string\n output: { function: string, name: string, version: string }\n effects: [echo:write, http]\n note: Operation key `org.dxos.function.script.install`.\n```\n\nUI-facing operation (creates Script via the navtree / "create object" flow).\n\n```mdl\nop createScript\n desc: Creates a new Script ECHO object via the Composer create-object flow.\n input:\n name?: string\n gistUrl?: string\n initialTemplateId?: string\n db: Database\n output: { object: Script }\n effects: [echo:write]\n note: Operation key `org.dxos.plugin.script.operation.create-script`.\n```\n\n## Features\n\n```mdl\nfeat F-1: Script ECHO Object\n\n req F-1.1: Script objects are registered via `addSchemaModule` and visible in space object lists.\n req F-1.2: Script objects can be created from the navtree "+" menu.\n req F-1.3:\n when: user creates a Script without a template\n then: source is seeded from the default template\n req F-1.4:\n when: user provides a GitHub Gist URL\n then: gist content is fetched and used as initial source\n```\n\n```mdl\nfeat F-2: Script Editor\n\n req F-2.1: ScriptArticle renders a TypeScript-aware CodeMirror editor for the Article role.\n req F-2.2: Editor keybinding mode (default/vim/emacs) is configurable via plugin settings.\n req F-2.3: Changes to source are persisted to the Script ECHO object reactively.\n req F-2.4:\n when: script object changes externally (peer edit)\n then: editor content updates without losing cursor position if possible\n```\n\n```mdl\nfeat F-3: Deploy to EDGE\n\n req F-3.1: A Deploy button in the ScriptToolbar opens the DeploymentDialog.\n req F-3.2:\n when: user confirms deployment\n then: op:deploy is called; script compiled and sent to EDGE runtime\n req F-3.3:\n when: compilation fails\n then: error messages are surfaced to the user; no deployment occurs\n req F-3.4:\n when: deployment succeeds\n then: dialog shows the function URL (if available)\n```\n\n```mdl\nfeat F-4: Execute Companion\n\n req F-4.1: An "Execute" companion node is added to every Script in the app graph.\n req F-4.2: TestContainer renders a form derived from the script\'s Operation input schema.\n req F-4.3:\n when: user submits the form\n then: op:invoke is called with the form payload; response displayed\n req F-4.4: A "Logs" companion node shows the invocation trace via InvocationTraceContainer.\n```\n\n```mdl\nfeat F-5: Script Skill\n\n req F-5.1: A skill with key `org.dxos.skill.script` is contributed via `addSkillDefinitionModule`.\n req F-5.2: Skill tool set includes: create, read, update, delete, deploy, invoke,\n inspectInvocations, queryDeployedFunctions, installFunction.\n req F-5.3: System instructions describe the EDGE Operation pattern, required export format,\n and available packages.\n req F-5.4: Skill is agent-enabled; the assistant can activate it autonomously.\n```\n\n```mdl\nfeat F-6: Notebook\n\n req F-6.1: Notebook objects are registered and can be created from the navtree.\n req F-6.2: NotebookArticle renders each linked Script as a sequential cell.\n req F-6.3: Cells can be added and removed independently.\n```\n\n```mdl\nfeat F-7: Plugin Settings\n\n req F-7.1: ScriptPluginSettings is rendered via the app settings surface.\n req F-7.2: Editor input mode is persisted in the Settings atom.\n req F-7.3: An Authenticate button lets the user write an access credential to HALO.\n```\n\n## Acceptance\n\n```mdl\ntest T-1: Create script from default template\n given: a space is open and plugin-script is loaded\n when: user creates a new Script without template selection\n then:\n - a Script object appears in the space\n - its source contains the default template code\n - ScriptArticle renders the source in the editor\n```\n\n```mdl\ntest T-2: Create script from Gist\n given: a public GitHub Gist URL is known\n when: user creates a Script with the Gist URL\n then:\n - gist content is fetched and stored as the script source\n - editor shows the fetched content\n```\n\n```mdl\ntest T-3: Edit and persist source\n given: a Script is open in ScriptArticle\n when: user edits the source\n then:\n - the Script ECHO object\'s source field is updated\n - closing and reopening the article shows the same content\n```\n\n```mdl\ntest T-4: Deploy script\n given: a Script with valid source following the Operation pattern\n when: user opens DeploymentDialog and confirms\n then:\n - op:deploy succeeds\n - dialog shows success state and function URL\n```\n\n```mdl\ntest T-5: Invoke deployed function\n given: a Script is deployed\n when: user opens the Execute companion and submits a payload\n then:\n - op:invoke is called with the payload\n - response is displayed in TestContainer\n```\n\n```mdl\ntest T-6: Inspect invocations\n given: a Script has been invoked at least once\n when: user opens the Logs companion\n then:\n - InvocationTraceContainer shows at least one invocation span\n - span includes timestamp, duration, and outcome\n```\n\n```mdl\ntest T-7: Skill tools resolve\n given: composer-app with plugin-script loaded\n when: AppCapabilities.SkillDefinition is queried for `org.dxos.skill.script`\n then:\n - skill is present\n - tool set includes create, read, update, delete, deploy, invoke,\n inspectInvocations, queryDeployedFunctions, and installFunction\n```\n\n```mdl\ntest T-8: Agent creates and deploys script\n given: a Script assistant session is active\n when: agent calls op:create with a name and source\n then: a Script object is created in the space\n when: agent calls op:deploy\n then: function is deployed; op returns a function ID\n when: agent calls op:invoke with a payload\n then: response is returned without error\n```\n\n```mdl\ntest T-9: QueryDeployedFunctions and install\n given: at least one function is deployed to the EDGE runtime\n when: op:queryDeployedFunctions is called\n then:\n - result contains at least one DeployedFunction entry\n when: op:installFunction is called with that entry\'s key\n then:\n - a new Script ECHO object appears in the space\n - op returns the function ID, name, and version\n```\n\n---\n\n## Appendix: Extension Definitions\n\nExtension block types used in this document are defined below using\nthe core `ext` primitive \u2014 the only construct the base language provides.\n\n```mdl\next type\n uri: org.dxos.mdl.type@1.0\n desc: A named data structure with typed fields and optional literals.\n fields:\n desc?: Prose\n fields?: FieldMap # name[?]: TypeExpr (# inline comment)\n literals?: UnionList # a | b | c\n extends?: TypeRef[]\n```\n\n```mdl\next feat\n uri: org.dxos.mdl.feat@1.0\n desc: A named feature grouping one or more requirements.\n fields:\n desc?: Prose\n req: RequirementList\n nesting: self # feat blocks may contain feat blocks\n```\n\n```mdl\next test\n uri: org.dxos.mdl.test@1.0\n desc: An acceptance scenario expressed as given / when / then steps.\n fields:\n given?: Step | Step[]\n when?: Step | Step[]\n then: Step | Step[]\n tags?: TagList\n```\n\n```mdl\next component\n uri: org.dxos.mdl.component@1.0\n desc: A UI component with props, internal state, slots, actions, and events.\n fields:\n desc?: Prose\n props?: FieldMap # external inputs (immutable inside component)\n state?: FieldMap # internal reactive state\n slots?: FieldMap # named ReactNode injection points\n actions?: ActionMap # methods the component exposes or handles\n emits?: EventMap # events the component raises to its parent\n layout?: CodeBlock # ASCII sketch of visual structure (non-normative)\n```\n\n```mdl\next op\n uri: org.dxos.mdl.op@1.0\n desc: |\n A named operation with typed inputs, outputs, and declared errors.\n Pure ops have no effects or requires. Effectful ops declare both.\n fields:\n desc?: Prose\n input?: FieldMap # named input parameters\n output?: TypeExpr # return type\n errors?: ErrorMap # name: Prose (when this error occurs)\n effects?: EffectList # echo:read | echo:write | http | fs | ...\n requires?: ServiceList # injected service dependencies\n note?: Prose # implementation guidance (non-normative)\n```\n';
14
14
 
15
15
  // src/ScriptPlugin.tsx
16
16
  var ScriptPlugin = Plugin.define(meta).pipe(AppPlugin.addAppGraphModule({
17
17
  activate: AppGraphBuilder
18
- }), AppPlugin.addBlueprintDefinitionModule({
19
- activate: BlueprintDefinition
18
+ }), AppPlugin.addSkillDefinitionModule({
19
+ activate: SkillDefinition
20
20
  }), AppPlugin.addCreateObjectModule({
21
21
  activate: CreateObject
22
22
  }), AppPlugin.addOperationHandlerModule({
@@ -37,7 +37,7 @@ var ScriptPlugin = Plugin.define(meta).pipe(AppPlugin.addAppGraphModule({
37
37
  activate: Compiler
38
38
  }), AppPlugin.addPluginAssetModule({
39
39
  asset: {
40
- pluginId: meta.id,
40
+ pluginId: meta.profile.key,
41
41
  path: "PLUGIN.mdl",
42
42
  content: PLUGIN_default,
43
43
  mimeType: "application/x-mdl"