@dxos/plugin-script 0.7.5-labs.a279d8c → 0.7.5-labs.d453967

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 (209) hide show
  1. package/dist/lib/browser/{AutomationPanel-OOIRJFPJ.mjs → AutomationPanel-J3SZ5L3Y.mjs} +3 -3
  2. package/dist/lib/browser/{ScriptContainer-T2AOMDT3.mjs → ScriptContainer-JHAVO2KA.mjs} +98 -70
  3. package/dist/lib/browser/ScriptContainer-JHAVO2KA.mjs.map +7 -0
  4. package/dist/lib/browser/artifact-YCIVHFSS.mjs +243 -0
  5. package/dist/lib/browser/artifact-YCIVHFSS.mjs.map +7 -0
  6. package/dist/lib/browser/{chunk-SJ4J527G.mjs → chunk-45LXDWNF.mjs} +2 -2
  7. package/dist/lib/browser/{chunk-ZM6T4HPR.mjs → chunk-6MOQ4BP3.mjs} +2 -2
  8. package/dist/lib/browser/chunk-FVVCAWNP.mjs +21 -0
  9. package/dist/lib/browser/chunk-FVVCAWNP.mjs.map +7 -0
  10. package/dist/lib/browser/{chunk-XPGBHZ3L.mjs → chunk-N46LE7FS.mjs} +2 -2
  11. package/dist/lib/browser/{chunk-REL2R7SB.mjs → chunk-UDLKK74O.mjs} +20 -3
  12. package/dist/lib/browser/chunk-UDLKK74O.mjs.map +7 -0
  13. package/dist/lib/browser/{chunk-SIOGRRPF.mjs → chunk-WAXHENSY.mjs} +21 -9
  14. package/dist/lib/browser/chunk-WAXHENSY.mjs.map +7 -0
  15. package/dist/lib/browser/{compiler-HT53ILG7.mjs → compiler-YY2XSKHQ.mjs} +4 -6
  16. package/dist/lib/browser/compiler-YY2XSKHQ.mjs.map +7 -0
  17. package/dist/lib/browser/index.mjs +20 -18
  18. package/dist/lib/browser/index.mjs.map +3 -3
  19. package/dist/lib/browser/intent-resolver-RV3YXIVN.mjs +45 -0
  20. package/dist/lib/browser/intent-resolver-RV3YXIVN.mjs.map +7 -0
  21. package/dist/lib/browser/meta.json +1 -1
  22. package/dist/lib/browser/{react-surface-GAWVYTJ5.mjs → react-surface-ETY4XKFG.mjs} +12 -14
  23. package/dist/lib/browser/react-surface-ETY4XKFG.mjs.map +7 -0
  24. package/dist/lib/browser/{settings-YQQEU3DF.mjs → settings-SZCDKHWO.mjs} +3 -3
  25. package/dist/lib/browser/types.mjs +2 -2
  26. package/dist/lib/node/{AutomationPanel-EPRDDR3A.cjs → AutomationPanel-4M55FURO.cjs} +8 -8
  27. package/dist/lib/node/{ScriptContainer-BV56I4OL.cjs → ScriptContainer-EBIT6CT4.cjs} +101 -71
  28. package/dist/lib/node/ScriptContainer-EBIT6CT4.cjs.map +7 -0
  29. package/dist/lib/node/artifact-IPGGY2Z2.cjs +262 -0
  30. package/dist/lib/node/artifact-IPGGY2Z2.cjs.map +7 -0
  31. package/dist/lib/node/{chunk-5V3XGLTR.cjs → chunk-3VDHZ54A.cjs} +24 -12
  32. package/dist/lib/node/chunk-3VDHZ54A.cjs.map +7 -0
  33. package/dist/lib/node/{chunk-EFTZN5X7.cjs → chunk-5UH3F7TA.cjs} +8 -5
  34. package/dist/lib/node/chunk-5UH3F7TA.cjs.map +7 -0
  35. package/dist/lib/node/{chunk-A2DI2G4D.cjs → chunk-ALY3N6PW.cjs} +6 -6
  36. package/dist/lib/node/{chunk-6VKZJ4MH.cjs → chunk-DJGLGRQV.cjs} +6 -6
  37. package/dist/lib/node/{chunk-DQRAVZM7.cjs → chunk-IID7WUQS.cjs} +6 -6
  38. package/dist/lib/node/{chunk-TJ4BTPOS.cjs → chunk-JKPNBFU2.cjs} +19 -6
  39. package/dist/lib/node/chunk-JKPNBFU2.cjs.map +7 -0
  40. package/dist/lib/node/{compiler-457ZR24G.cjs → compiler-UIBLKJKG.cjs} +9 -9
  41. package/dist/lib/node/compiler-UIBLKJKG.cjs.map +7 -0
  42. package/dist/lib/node/index.cjs +38 -35
  43. package/dist/lib/node/index.cjs.map +3 -3
  44. package/dist/lib/node/{intent-resolver-SUAPE7H3.cjs → intent-resolver-WFLQNAID.cjs} +31 -28
  45. package/dist/lib/node/intent-resolver-WFLQNAID.cjs.map +7 -0
  46. package/dist/lib/node/meta.json +1 -1
  47. package/dist/lib/node/{react-surface-OMBMSFZT.cjs → react-surface-OIQJFA7P.cjs} +23 -25
  48. package/dist/lib/node/react-surface-OIQJFA7P.cjs.map +7 -0
  49. package/dist/lib/node/{settings-NGHDYAVK.cjs → settings-SZFSMSKM.cjs} +9 -9
  50. package/dist/lib/node/types.cjs +4 -4
  51. package/dist/lib/node/types.cjs.map +1 -1
  52. package/dist/lib/node-esm/{AutomationPanel-DMLAGQS5.mjs → AutomationPanel-W6SKG35R.mjs} +3 -3
  53. package/dist/lib/node-esm/{ScriptContainer-3S5VHJVR.mjs → ScriptContainer-QVFTCAML.mjs} +98 -70
  54. package/dist/lib/node-esm/ScriptContainer-QVFTCAML.mjs.map +7 -0
  55. package/dist/lib/node-esm/artifact-7H4HGX5W.mjs +245 -0
  56. package/dist/lib/node-esm/artifact-7H4HGX5W.mjs.map +7 -0
  57. package/dist/lib/node-esm/{chunk-JJZYWSD7.mjs → chunk-5CEKSMA5.mjs} +20 -3
  58. package/dist/lib/node-esm/chunk-5CEKSMA5.mjs.map +7 -0
  59. package/dist/lib/node-esm/{chunk-XUWS7OTK.mjs → chunk-CGF7EOGD.mjs} +2 -2
  60. package/dist/lib/node-esm/{chunk-675XSDRN.mjs → chunk-CP5LXTK5.mjs} +2 -2
  61. package/dist/lib/node-esm/{chunk-BHP545D7.mjs → chunk-P2V2Y5LV.mjs} +5 -2
  62. package/dist/lib/node-esm/chunk-P2V2Y5LV.mjs.map +7 -0
  63. package/dist/lib/node-esm/{chunk-JHGOPQVO.mjs → chunk-UNQFIERE.mjs} +2 -2
  64. package/dist/lib/node-esm/{chunk-XPIKUBGS.mjs → chunk-WCAUDRF4.mjs} +21 -9
  65. package/dist/lib/node-esm/chunk-WCAUDRF4.mjs.map +7 -0
  66. package/dist/lib/node-esm/{compiler-PEARFTFR.mjs → compiler-XTXFGZJM.mjs} +4 -6
  67. package/dist/lib/node-esm/compiler-XTXFGZJM.mjs.map +7 -0
  68. package/dist/lib/node-esm/index.mjs +20 -18
  69. package/dist/lib/node-esm/index.mjs.map +3 -3
  70. package/dist/lib/node-esm/intent-resolver-CYT6IYYH.mjs +46 -0
  71. package/dist/lib/node-esm/intent-resolver-CYT6IYYH.mjs.map +7 -0
  72. package/dist/lib/node-esm/meta.json +1 -1
  73. package/dist/lib/node-esm/{react-surface-J7NLV2V4.mjs → react-surface-N67GNKC2.mjs} +12 -14
  74. package/dist/lib/node-esm/react-surface-N67GNKC2.mjs.map +7 -0
  75. package/dist/lib/node-esm/{settings-XGXDY4NI.mjs → settings-GR4O2WHZ.mjs} +3 -3
  76. package/dist/lib/node-esm/types.mjs +2 -2
  77. package/dist/types/src/ScriptPlugin.d.ts.map +1 -1
  78. package/dist/types/src/capabilities/artifact.d.ts +11 -0
  79. package/dist/types/src/capabilities/artifact.d.ts.map +1 -0
  80. package/dist/types/src/capabilities/index.d.ts +5 -4
  81. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  82. package/dist/types/src/capabilities/intent-resolver.d.ts.map +1 -1
  83. package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
  84. package/dist/types/src/components/FrameContainer/FrameContainer.d.ts +2 -2
  85. package/dist/types/src/components/FrameContainer/FrameContainer.d.ts.map +1 -1
  86. package/dist/types/src/components/ScriptContainer.d.ts +2 -2
  87. package/dist/types/src/components/ScriptContainer.d.ts.map +1 -1
  88. package/dist/types/src/components/ScriptSettingsPanel.d.ts.map +1 -1
  89. package/dist/types/src/components/ScriptToolbar/ScriptToolbar.d.ts +1 -1
  90. package/dist/types/src/components/ScriptToolbar/ScriptToolbar.d.ts.map +1 -1
  91. package/dist/types/src/components/index.d.ts +1 -1
  92. package/dist/types/src/components/index.d.ts.map +1 -1
  93. package/dist/types/src/hooks/deploy.d.ts.map +1 -0
  94. package/dist/types/src/hooks/format.d.ts.map +1 -0
  95. package/dist/types/src/hooks/index.d.ts +7 -0
  96. package/dist/types/src/hooks/index.d.ts.map +1 -0
  97. package/dist/types/src/{components/ScriptToolbar/templateSelect.d.ts → hooks/template.d.ts} +1 -1
  98. package/dist/types/src/hooks/template.d.ts.map +1 -0
  99. package/dist/types/src/{components/ScriptToolbar → hooks}/useToolbarAction.d.ts +1 -1
  100. package/dist/types/src/hooks/useToolbarAction.d.ts.map +1 -0
  101. package/dist/types/src/hooks/useToolbarState.d.ts.map +1 -0
  102. package/dist/types/src/hooks/view.d.ts.map +1 -0
  103. package/dist/types/src/index.d.ts +0 -1
  104. package/dist/types/src/index.d.ts.map +1 -1
  105. package/dist/types/src/meta.d.ts +1 -0
  106. package/dist/types/src/meta.d.ts.map +1 -1
  107. package/dist/types/src/templates/discord.d.ts +3 -0
  108. package/dist/types/src/templates/discord.d.ts.map +1 -0
  109. package/dist/types/src/templates/echo.d.ts.map +1 -1
  110. package/dist/types/src/templates/forex-effect.d.ts +6 -0
  111. package/dist/types/src/templates/forex-effect.d.ts.map +1 -0
  112. package/dist/types/src/templates/forex.d.ts +1 -1
  113. package/dist/types/src/templates/forex.d.ts.map +1 -1
  114. package/dist/types/src/templates/index.d.ts.map +1 -1
  115. package/dist/types/src/translations.d.ts +6 -0
  116. package/dist/types/src/translations.d.ts.map +1 -1
  117. package/dist/types/tsconfig.tsbuildinfo +1 -1
  118. package/package.json +41 -41
  119. package/src/ScriptPlugin.tsx +10 -13
  120. package/src/capabilities/artifact.ts +219 -0
  121. package/src/capabilities/compiler.ts +1 -1
  122. package/src/capabilities/index.ts +1 -0
  123. package/src/capabilities/intent-resolver.ts +25 -22
  124. package/src/capabilities/react-surface.tsx +8 -8
  125. package/src/components/FrameContainer/FrameContainer.tsx +4 -3
  126. package/src/components/ScriptContainer.tsx +10 -5
  127. package/src/components/ScriptSettings/ScriptSettings.tsx +3 -3
  128. package/src/components/ScriptSettingsPanel.tsx +16 -2
  129. package/src/components/ScriptToolbar/ScriptToolbar.tsx +8 -6
  130. package/src/components/TypescriptEditor/TypescriptEditor.tsx +3 -3
  131. package/src/{components/ScriptToolbar → hooks}/deploy.ts +16 -4
  132. package/src/{components/ScriptToolbar → hooks}/format.ts +1 -1
  133. package/src/hooks/index.ts +11 -0
  134. package/src/{components/ScriptToolbar/templateSelect.ts → hooks/template.ts} +2 -2
  135. package/src/{components/ScriptToolbar → hooks}/useToolbarAction.ts +1 -1
  136. package/src/{components/ScriptToolbar → hooks}/view.ts +1 -1
  137. package/src/index.ts +0 -1
  138. package/src/meta.ts +3 -1
  139. package/src/templates/discord.ts +88 -0
  140. package/src/templates/echo.ts +5 -1
  141. package/src/templates/forex-effect.ts +44 -0
  142. package/src/templates/forex.ts +21 -13
  143. package/src/templates/index.ts +15 -0
  144. package/src/translations.ts +2 -0
  145. package/dist/lib/browser/ScriptContainer-T2AOMDT3.mjs.map +0 -7
  146. package/dist/lib/browser/chunk-5BU5ERNU.mjs +0 -18
  147. package/dist/lib/browser/chunk-5BU5ERNU.mjs.map +0 -7
  148. package/dist/lib/browser/chunk-REL2R7SB.mjs.map +0 -7
  149. package/dist/lib/browser/chunk-SDHKTS6H.mjs +0 -237
  150. package/dist/lib/browser/chunk-SDHKTS6H.mjs.map +0 -7
  151. package/dist/lib/browser/chunk-SIOGRRPF.mjs.map +0 -7
  152. package/dist/lib/browser/compiler-HT53ILG7.mjs.map +0 -7
  153. package/dist/lib/browser/intent-resolver-YPHT6HDZ.mjs +0 -42
  154. package/dist/lib/browser/intent-resolver-YPHT6HDZ.mjs.map +0 -7
  155. package/dist/lib/browser/react-surface-GAWVYTJ5.mjs.map +0 -7
  156. package/dist/lib/node/ScriptContainer-BV56I4OL.cjs.map +0 -7
  157. package/dist/lib/node/chunk-5V3XGLTR.cjs.map +0 -7
  158. package/dist/lib/node/chunk-EFTZN5X7.cjs.map +0 -7
  159. package/dist/lib/node/chunk-T4TXCRN5.cjs +0 -260
  160. package/dist/lib/node/chunk-T4TXCRN5.cjs.map +0 -7
  161. package/dist/lib/node/chunk-TJ4BTPOS.cjs.map +0 -7
  162. package/dist/lib/node/compiler-457ZR24G.cjs.map +0 -7
  163. package/dist/lib/node/intent-resolver-SUAPE7H3.cjs.map +0 -7
  164. package/dist/lib/node/react-surface-OMBMSFZT.cjs.map +0 -7
  165. package/dist/lib/node-esm/ScriptContainer-3S5VHJVR.mjs.map +0 -7
  166. package/dist/lib/node-esm/chunk-BHP545D7.mjs.map +0 -7
  167. package/dist/lib/node-esm/chunk-G76M6O46.mjs +0 -239
  168. package/dist/lib/node-esm/chunk-G76M6O46.mjs.map +0 -7
  169. package/dist/lib/node-esm/chunk-JJZYWSD7.mjs.map +0 -7
  170. package/dist/lib/node-esm/chunk-XPIKUBGS.mjs.map +0 -7
  171. package/dist/lib/node-esm/compiler-PEARFTFR.mjs.map +0 -7
  172. package/dist/lib/node-esm/intent-resolver-SZJXQ3CW.mjs +0 -43
  173. package/dist/lib/node-esm/intent-resolver-SZJXQ3CW.mjs.map +0 -7
  174. package/dist/lib/node-esm/react-surface-J7NLV2V4.mjs.map +0 -7
  175. package/dist/types/src/bundler/bundler.d.ts +0 -39
  176. package/dist/types/src/bundler/bundler.d.ts.map +0 -1
  177. package/dist/types/src/bundler/bundler.test.d.ts +0 -2
  178. package/dist/types/src/bundler/bundler.test.d.ts.map +0 -1
  179. package/dist/types/src/bundler/index.d.ts +0 -2
  180. package/dist/types/src/bundler/index.d.ts.map +0 -1
  181. package/dist/types/src/components/ScriptToolbar/deploy.d.ts.map +0 -1
  182. package/dist/types/src/components/ScriptToolbar/format.d.ts.map +0 -1
  183. package/dist/types/src/components/ScriptToolbar/templateSelect.d.ts.map +0 -1
  184. package/dist/types/src/components/ScriptToolbar/useToolbarAction.d.ts.map +0 -1
  185. package/dist/types/src/components/ScriptToolbar/useToolbarState.d.ts.map +0 -1
  186. package/dist/types/src/components/ScriptToolbar/view.d.ts.map +0 -1
  187. package/src/bundler/bundler.test.ts +0 -55
  188. package/src/bundler/bundler.ts +0 -250
  189. package/src/bundler/index.ts +0 -5
  190. /package/dist/lib/browser/{AutomationPanel-OOIRJFPJ.mjs.map → AutomationPanel-J3SZ5L3Y.mjs.map} +0 -0
  191. /package/dist/lib/browser/{chunk-SJ4J527G.mjs.map → chunk-45LXDWNF.mjs.map} +0 -0
  192. /package/dist/lib/browser/{chunk-ZM6T4HPR.mjs.map → chunk-6MOQ4BP3.mjs.map} +0 -0
  193. /package/dist/lib/browser/{chunk-XPGBHZ3L.mjs.map → chunk-N46LE7FS.mjs.map} +0 -0
  194. /package/dist/lib/browser/{settings-YQQEU3DF.mjs.map → settings-SZCDKHWO.mjs.map} +0 -0
  195. /package/dist/lib/node/{AutomationPanel-EPRDDR3A.cjs.map → AutomationPanel-4M55FURO.cjs.map} +0 -0
  196. /package/dist/lib/node/{chunk-A2DI2G4D.cjs.map → chunk-ALY3N6PW.cjs.map} +0 -0
  197. /package/dist/lib/node/{chunk-6VKZJ4MH.cjs.map → chunk-DJGLGRQV.cjs.map} +0 -0
  198. /package/dist/lib/node/{chunk-DQRAVZM7.cjs.map → chunk-IID7WUQS.cjs.map} +0 -0
  199. /package/dist/lib/node/{settings-NGHDYAVK.cjs.map → settings-SZFSMSKM.cjs.map} +0 -0
  200. /package/dist/lib/node-esm/{AutomationPanel-DMLAGQS5.mjs.map → AutomationPanel-W6SKG35R.mjs.map} +0 -0
  201. /package/dist/lib/node-esm/{chunk-XUWS7OTK.mjs.map → chunk-CGF7EOGD.mjs.map} +0 -0
  202. /package/dist/lib/node-esm/{chunk-675XSDRN.mjs.map → chunk-CP5LXTK5.mjs.map} +0 -0
  203. /package/dist/lib/node-esm/{chunk-JHGOPQVO.mjs.map → chunk-UNQFIERE.mjs.map} +0 -0
  204. /package/dist/lib/node-esm/{settings-XGXDY4NI.mjs.map → settings-GR4O2WHZ.mjs.map} +0 -0
  205. /package/dist/types/src/{components/ScriptToolbar → hooks}/deploy.d.ts +0 -0
  206. /package/dist/types/src/{components/ScriptToolbar → hooks}/format.d.ts +0 -0
  207. /package/dist/types/src/{components/ScriptToolbar → hooks}/useToolbarState.d.ts +0 -0
  208. /package/dist/types/src/{components/ScriptToolbar → hooks}/view.d.ts +0 -0
  209. /package/src/{components/ScriptToolbar → hooks}/useToolbarState.ts +0 -0
@@ -0,0 +1,7 @@
1
+ export * from './deploy';
2
+ export * from './format';
3
+ export * from './template';
4
+ export * from './view';
5
+ export * from './useToolbarAction';
6
+ export * from './useToolbarState';
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/hooks/index.ts"],"names":[],"mappings":"AAIA,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC;AAEvB,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC"}
@@ -28,4 +28,4 @@ export declare const createTemplateSelect: () => {
28
28
  export declare const useTemplateSelectHandler: ({ script }: {
29
29
  script: ScriptType;
30
30
  }) => (templateId: string) => void;
31
- //# sourceMappingURL=templateSelect.d.ts.map
31
+ //# sourceMappingURL=template.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"template.d.ts","sourceRoot":"","sources":["../../../../src/hooks/template.ts"],"names":[],"mappings":"AAMA,OAAO,EAA6B,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAO7E,MAAM,MAAM,wBAAwB,GAAG;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAmB3E,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;CAUhC,CAAC;AAEF,eAAO,MAAM,wBAAwB,eAAgB;IAAE,MAAM,EAAE,UAAU,CAAA;CAAE,kBAE1D,MAAM,SAiBtB,CAAC"}
@@ -2,7 +2,7 @@ import { type ScriptType } from '@dxos/functions';
2
2
  import { type MenuAction, type MenuActionHandler } from '@dxos/react-ui-menu';
3
3
  import { type DeployActionProperties } from './deploy';
4
4
  import { type FormatActionProperties } from './format';
5
- import { type TemplateActionProperties } from './templateSelect';
5
+ import { type TemplateActionProperties } from './template';
6
6
  import { type ScriptToolbarState } from './useToolbarState';
7
7
  import { type ViewActionProperties } from './view';
8
8
  export type ScriptToolbarActionProperties = TemplateActionProperties | ViewActionProperties | FormatActionProperties | DeployActionProperties;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useToolbarAction.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useToolbarAction.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAElD,OAAO,EAAE,KAAK,UAAU,EAAE,KAAK,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAE9E,OAAO,EAAE,KAAK,sBAAsB,EAAoC,MAAM,UAAU,CAAC;AACzF,OAAO,EAAE,KAAK,sBAAsB,EAAoB,MAAM,UAAU,CAAC;AACzE,OAAO,EAAE,KAAK,wBAAwB,EAA4B,MAAM,YAAY,CAAC;AACrF,OAAO,EAAE,KAAK,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,KAAK,oBAAoB,EAAE,MAAM,QAAQ,CAAC;AAEnD,MAAM,MAAM,6BAA6B,GACrC,wBAAwB,GACxB,oBAAoB,GACpB,sBAAsB,GACtB,sBAAsB,CAAC;AAE3B,MAAM,MAAM,mBAAmB,GAAG,UAAU,CAAC,6BAA6B,CAAC,CAAC;AAE5E,eAAO,MAAM,gBAAgB,UAAW;IAAE,KAAK,EAAE,kBAAkB,CAAC;IAAC,MAAM,EAAE,UAAU,CAAA;CAAE,sBA6BxF,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useToolbarState.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useToolbarState.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,QAAQ,CAAC;AAExC,MAAM,MAAM,kBAAkB,GAAG,OAAO,CAAC,WAAW,GAAG,SAAS,CAAC,CAAC;AAElE,eAAO,MAAM,eAAe,kBAAkB,kBAAkB;;;;;GAE/D,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"view.d.ts","sourceRoot":"","sources":["../../../../src/hooks/view.ts"],"names":[],"mappings":"AAQA,MAAM,MAAM,QAAQ,GAAG,QAAQ,GAAG,OAAO,GAAG,OAAO,CAAC;AAEpD,MAAM,MAAM,SAAS,GAAG;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,CAAC;AAE3C,MAAM,MAAM,oBAAoB,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,QAAQ,CAAA;CAAE,CAAC;AA6BrE,eAAO,MAAM,UAAU,UAAW,OAAO,CAAC,SAAS,CAAC;;;;;;;;;;;;;;;;;;;;;;;CAUnD,CAAC"}
@@ -1,4 +1,3 @@
1
- export * from './bundler';
2
1
  export { ScriptCapabilities } from './capabilities';
3
2
  export * from './components';
4
3
  export * from './meta';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAIA,cAAc,WAAW,CAAC;AAC1B,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpD,cAAc,cAAc,CAAC;AAC7B,cAAc,QAAQ,CAAC;AAEvB,cAAc,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpD,cAAc,cAAc,CAAC;AAC7B,cAAc,QAAQ,CAAC;AAEvB,cAAc,gBAAgB,CAAC"}
@@ -6,5 +6,6 @@ export declare const meta: {
6
6
  icon: string;
7
7
  source: string;
8
8
  tags: string[];
9
+ screenshots: string[];
9
10
  };
10
11
  //# sourceMappingURL=meta.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"meta.d.ts","sourceRoot":"","sources":["../../../src/meta.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,aAAa,2BAA2B,CAAC;AAEtD,eAAO,MAAM,IAAI;;;;;;;CAOK,CAAC"}
1
+ {"version":3,"file":"meta.d.ts","sourceRoot":"","sources":["../../../src/meta.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,aAAa,2BAA2B,CAAC;AAEtD,eAAO,MAAM,IAAI;;;;;;;;CASK,CAAC"}
@@ -0,0 +1,3 @@
1
+ declare const _default: any;
2
+ export default _default;
3
+ //# sourceMappingURL=discord.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"discord.d.ts","sourceRoot":"","sources":["../../../../src/templates/discord.ts"],"names":[],"mappings":";AAqBA,wBAkEG"}
@@ -1 +1 @@
1
- {"version":3,"file":"echo.d.ts","sourceRoot":"","sources":["../../../../src/templates/echo.ts"],"names":[],"mappings":"AAIA;;GAEG;6DAKA,GAAG;AAJN,wBAOE"}
1
+ {"version":3,"file":"echo.d.ts","sourceRoot":"","sources":["../../../../src/templates/echo.ts"],"names":[],"mappings":"AAIA;;GAEG;6DAKA,GAAG;AAJN,wBAWE"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Returns the exchange rate between two currencies.
3
+ */
4
+ declare const _default: any;
5
+ export default _default;
6
+ //# sourceMappingURL=forex-effect.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"forex-effect.d.ts","sourceRoot":"","sources":["../../../../src/templates/forex-effect.ts"],"names":[],"mappings":"AAeA;;GAEG;;AACH,wBAyBG"}
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Returns the exchange rate between two currencies.
3
3
  */
4
- declare const _default: ({ event: { data: { request }, }, }: any) => Promise<Response>;
4
+ declare const _default: any;
5
5
  export default _default;
6
6
  //# sourceMappingURL=forex.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"forex.d.ts","sourceRoot":"","sources":["../../../../src/templates/forex.ts"],"names":[],"mappings":"AAIA;;GAEG;6DAKA,GAAG;AAJN,wBAaE"}
1
+ {"version":3,"file":"forex.d.ts","sourceRoot":"","sources":["../../../../src/templates/forex.ts"],"names":[],"mappings":"AAOA;;GAEG;;AACH,wBAkBG"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/templates/index.ts"],"names":[],"mappings":"AAiBA,MAAM,MAAM,QAAQ,GAAG;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,eAAO,MAAM,SAAS,EAAE,QAAQ,EA6B/B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/templates/index.ts"],"names":[],"mappings":"AAqBA,MAAM,MAAM,QAAQ,GAAG;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,eAAO,MAAM,SAAS,EAAE,QAAQ,EAwC/B,CAAC"}
@@ -6,6 +6,8 @@ declare const _default: {
6
6
  'object title placeholder'?: undefined;
7
7
  'create object label'?: undefined;
8
8
  'create stack section label'?: undefined;
9
+ 'description label'?: undefined;
10
+ 'description placeholder'?: undefined;
9
11
  'binding placeholder'?: undefined;
10
12
  'function request placeholder'?: undefined;
11
13
  'deploy label'?: undefined;
@@ -42,6 +44,8 @@ declare const _default: {
42
44
  'object title placeholder': string;
43
45
  'create object label': string;
44
46
  'create stack section label': string;
47
+ 'description label': string;
48
+ 'description placeholder': string;
45
49
  'binding placeholder': string;
46
50
  'function request placeholder': string;
47
51
  'deploy label': string;
@@ -80,6 +84,8 @@ declare const _default: {
80
84
  'object title placeholder': string;
81
85
  'create object label': string;
82
86
  'create stack section label': string;
87
+ 'description label': string;
88
+ 'description placeholder': string;
83
89
  'binding placeholder': string;
84
90
  'function request placeholder': string;
85
91
  'deploy label': string;
@@ -1 +1 @@
1
- {"version":3,"file":"translations.d.ts","sourceRoot":"","sources":["../../../src/translations.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQA,wBA6CE"}
1
+ {"version":3,"file":"translations.d.ts","sourceRoot":"","sources":["../../../src/translations.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQA,wBA+CE"}
@@ -1 +1 @@
1
- {"version":"5.7.2"}
1
+ {"version":"5.7.3"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dxos/plugin-script",
3
- "version": "0.7.5-labs.a279d8c",
3
+ "version": "0.7.5-labs.d453967",
4
4
  "description": "Braneframe notebook plugin",
5
5
  "homepage": "https://dxos.org",
6
6
  "bugs": "https://github.com/dxos/dxos/issues",
@@ -53,38 +53,40 @@
53
53
  "prettier": "^3.2.4",
54
54
  "react-syntax-highlighter": "^15.5.0",
55
55
  "typescript": "^5.7.2",
56
- "@dxos/app-framework": "0.7.5-labs.a279d8c",
57
- "@dxos/async": "0.7.5-labs.a279d8c",
58
- "@dxos/client": "0.7.5-labs.a279d8c",
59
- "@dxos/client-protocol": "0.7.5-labs.a279d8c",
60
- "@dxos/compute": "0.7.5-labs.a279d8c",
61
- "@dxos/debug": "0.7.5-labs.a279d8c",
62
- "@dxos/crypto": "0.7.5-labs.a279d8c",
63
- "@dxos/echo-schema": "0.7.5-labs.a279d8c",
64
- "@dxos/functions": "0.7.5-labs.a279d8c",
65
- "@dxos/invariant": "0.7.5-labs.a279d8c",
66
- "@dxos/live-object": "0.7.5-labs.a279d8c",
67
- "@dxos/keys": "0.7.5-labs.a279d8c",
68
- "@dxos/log": "0.7.5-labs.a279d8c",
69
- "@dxos/plugin-client": "0.7.5-labs.a279d8c",
70
- "@dxos/plugin-explorer": "0.7.5-labs.a279d8c",
71
- "@dxos/plugin-graph": "0.7.5-labs.a279d8c",
72
- "@dxos/plugin-markdown": "0.7.5-labs.a279d8c",
73
- "@dxos/plugin-stack": "0.7.5-labs.a279d8c",
74
- "@dxos/plugin-space": "0.7.5-labs.a279d8c",
75
- "@dxos/plugin-theme": "0.7.5-labs.a279d8c",
76
- "@dxos/react-client": "0.7.5-labs.a279d8c",
77
- "@dxos/react-ui-attention": "0.7.5-labs.a279d8c",
78
- "@dxos/react-ui-form": "0.7.5-labs.a279d8c",
79
- "@dxos/react-ui-editor": "0.7.5-labs.a279d8c",
80
- "@dxos/react-ui-menu": "0.7.5-labs.a279d8c",
81
- "@dxos/protocols": "0.7.5-labs.a279d8c",
82
- "@dxos/react-ui-stack": "0.7.5-labs.a279d8c",
83
- "@dxos/react-ui-syntax-highlighter": "0.7.5-labs.a279d8c",
84
- "@dxos/rpc": "0.7.5-labs.a279d8c",
85
- "@dxos/rpc-tunnel": "0.7.5-labs.a279d8c",
86
- "@dxos/schema": "0.7.5-labs.a279d8c",
87
- "@dxos/util": "0.7.5-labs.a279d8c"
56
+ "@dxos/app-framework": "0.7.5-labs.d453967",
57
+ "@dxos/assistant": "0.7.5-labs.d453967",
58
+ "@dxos/artifact": "0.7.5-labs.d453967",
59
+ "@dxos/async": "0.7.5-labs.d453967",
60
+ "@dxos/client": "0.7.5-labs.d453967",
61
+ "@dxos/client-protocol": "0.7.5-labs.d453967",
62
+ "@dxos/debug": "0.7.5-labs.d453967",
63
+ "@dxos/compute": "0.7.5-labs.d453967",
64
+ "@dxos/invariant": "0.7.5-labs.d453967",
65
+ "@dxos/functions": "0.7.5-labs.d453967",
66
+ "@dxos/echo-schema": "0.7.5-labs.d453967",
67
+ "@dxos/live-object": "0.7.5-labs.d453967",
68
+ "@dxos/keys": "0.7.5-labs.d453967",
69
+ "@dxos/local-storage": "0.7.5-labs.d453967",
70
+ "@dxos/log": "0.7.5-labs.d453967",
71
+ "@dxos/plugin-client": "0.7.5-labs.d453967",
72
+ "@dxos/plugin-graph": "0.7.5-labs.d453967",
73
+ "@dxos/plugin-markdown": "0.7.5-labs.d453967",
74
+ "@dxos/plugin-space": "0.7.5-labs.d453967",
75
+ "@dxos/plugin-explorer": "0.7.5-labs.d453967",
76
+ "@dxos/plugin-theme": "0.7.5-labs.d453967",
77
+ "@dxos/plugin-stack": "0.7.5-labs.d453967",
78
+ "@dxos/react-client": "0.7.5-labs.d453967",
79
+ "@dxos/protocols": "0.7.5-labs.d453967",
80
+ "@dxos/react-ui-attention": "0.7.5-labs.d453967",
81
+ "@dxos/react-ui-editor": "0.7.5-labs.d453967",
82
+ "@dxos/react-ui-form": "0.7.5-labs.d453967",
83
+ "@dxos/react-ui-menu": "0.7.5-labs.d453967",
84
+ "@dxos/react-ui-stack": "0.7.5-labs.d453967",
85
+ "@dxos/rpc": "0.7.5-labs.d453967",
86
+ "@dxos/rpc-tunnel": "0.7.5-labs.d453967",
87
+ "@dxos/react-ui-syntax-highlighter": "0.7.5-labs.d453967",
88
+ "@dxos/schema": "0.7.5-labs.d453967",
89
+ "@dxos/util": "0.7.5-labs.d453967"
88
90
  },
89
91
  "devDependencies": {
90
92
  "@phosphor-icons/react": "^2.1.5",
@@ -94,19 +96,17 @@
94
96
  "react": "~18.2.0",
95
97
  "react-dom": "~18.2.0",
96
98
  "vite": "5.4.7",
97
- "@dxos/react-ui": "0.7.5-labs.a279d8c",
98
- "@dxos/react-ui-mosaic": "0.7.5-labs.a279d8c",
99
- "@dxos/react-ui-theme": "0.7.5-labs.a279d8c",
100
- "@dxos/random": "0.7.5-labs.a279d8c",
101
- "@dxos/storybook-utils": "0.7.5-labs.a279d8c"
99
+ "@dxos/react-ui": "0.7.5-labs.d453967",
100
+ "@dxos/random": "0.7.5-labs.d453967",
101
+ "@dxos/storybook-utils": "0.7.5-labs.d453967",
102
+ "@dxos/react-ui-theme": "0.7.5-labs.d453967"
102
103
  },
103
104
  "peerDependencies": {
104
105
  "@phosphor-icons/react": "^2.1.5",
105
106
  "react": "~18.2.0",
106
107
  "react-dom": "~18.2.0",
107
- "@dxos/react-ui": "0.7.5-labs.a279d8c",
108
- "@dxos/react-ui-mosaic": "0.7.5-labs.a279d8c",
109
- "@dxos/react-ui-theme": "0.7.5-labs.a279d8c"
108
+ "@dxos/react-ui": "0.7.5-labs.d453967",
109
+ "@dxos/react-ui-theme": "0.7.5-labs.d453967"
110
110
  },
111
111
  "publishConfig": {
112
112
  "access": "public"
@@ -4,21 +4,13 @@
4
4
 
5
5
  // @ts-ignore
6
6
 
7
- import {
8
- Capabilities,
9
- contributes,
10
- createIntent,
11
- defineModule,
12
- definePlugin,
13
- Events,
14
- oneOf,
15
- } from '@dxos/app-framework';
7
+ import { Capabilities, contributes, createIntent, defineModule, definePlugin, Events } from '@dxos/app-framework';
16
8
  import { type Space } from '@dxos/client/echo';
17
9
  import { FunctionType, ScriptType } from '@dxos/functions';
18
10
  import { RefArray } from '@dxos/live-object';
19
11
  import { ClientCapabilities, ClientEvents } from '@dxos/plugin-client';
20
12
 
21
- import { Compiler, IntentResolver, ReactSurface, ScriptSettings } from './capabilities';
13
+ import { Artifact, Compiler, IntentResolver, ReactSurface, ScriptSettings } from './capabilities';
22
14
  import { meta, SCRIPT_PLUGIN } from './meta';
23
15
  import translations from './translations';
24
16
  import { ScriptAction } from './types';
@@ -42,7 +34,7 @@ export const ScriptPlugin = () =>
42
34
  }),
43
35
  defineModule({
44
36
  id: `${meta.id}/module/metadata`,
45
- activatesOn: oneOf(Events.Startup, Events.SetupAppGraph),
37
+ activatesOn: Events.SetupMetadata,
46
38
  activate: () =>
47
39
  contributes(Capabilities.Metadata, {
48
40
  id: ScriptType.typename,
@@ -59,7 +51,7 @@ export const ScriptPlugin = () =>
59
51
  }),
60
52
  defineModule({
61
53
  id: `${meta.id}/module/schema`,
62
- activatesOn: ClientEvents.SetupClient,
54
+ activatesOn: ClientEvents.SetupSchema,
63
55
  activate: () => [
64
56
  contributes(ClientCapabilities.SystemSchema, [FunctionType]),
65
57
  contributes(ClientCapabilities.Schema, [ScriptType]),
@@ -67,7 +59,7 @@ export const ScriptPlugin = () =>
67
59
  }),
68
60
  defineModule({
69
61
  id: `${meta.id}/module/react-surface`,
70
- activatesOn: Events.Startup,
62
+ activatesOn: Events.SetupSurfaces,
71
63
  activate: ReactSurface,
72
64
  }),
73
65
  defineModule({
@@ -75,4 +67,9 @@ export const ScriptPlugin = () =>
75
67
  activatesOn: Events.SetupIntents,
76
68
  activate: IntentResolver,
77
69
  }),
70
+ defineModule({
71
+ id: `${meta.id}/module/artifact`,
72
+ activatesOn: Events.Startup,
73
+ activate: Artifact,
74
+ }),
78
75
  ]);
@@ -0,0 +1,219 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { Capabilities, contributes, createIntent, type PromiseIntentDispatcher } from '@dxos/app-framework';
6
+ import { defineArtifact, defineTool, ToolResult } from '@dxos/artifact';
7
+ import { createArtifactElement } from '@dxos/assistant';
8
+ import { ObjectId, S } from '@dxos/echo-schema';
9
+ import { ScriptType } from '@dxos/functions';
10
+ import { invariant } from '@dxos/invariant';
11
+ import { SpaceAction } from '@dxos/plugin-space/types';
12
+ import { create, makeRef, type Space } from '@dxos/react-client/echo';
13
+ import { TextType } from '@dxos/schema';
14
+
15
+ // TODO(burdon): Factor out.
16
+ declare global {
17
+ interface ToolContextExtensions {
18
+ space?: Space;
19
+ dispatch?: PromiseIntentDispatcher;
20
+ }
21
+ }
22
+
23
+ export default () => {
24
+ const definition = defineArtifact({
25
+ id: 'plugin-script',
26
+ // TODO(dmaretskyi): Since writing scripts requires a lot of domain knowledge,
27
+ // we should offload the work of synthesizing the code to a separate model.
28
+ // The main reasoning model will give it a concrete task and the script model will synthesize the code, knowing all the docs.
29
+ instructions: `
30
+ If the user explicitly requests you to write a script, you can create one.
31
+ If the user requests you to change one of the existing script, you can update it.
32
+ Scripts are short code pieces of executable code that can be used to perform computations, integrate with external systems, and perform automated tasks.
33
+ Each script must follow as strict shape for the definition but the body can contain any valid executable code.
34
+ Scripts are written in JavaScript or TypeScript.
35
+ Each script must define an input schema and output schema.
36
+ Each script must have its own detailed description.
37
+
38
+ Important: You cannot execute scripts. Scripts are only available as tools after the user deploys them. You must only call the available tools.
39
+
40
+ Description:
41
+ The description is a detailed description of the script.
42
+ It is used to describe the script's purpose, input, and output.
43
+ The description is used to generate the script's documentation.
44
+ The description is also goes into the script metadata.
45
+ The description is used by AI to understand the script and its purpose.
46
+ The description must provide cases on when the script should be used.
47
+
48
+ Schema:
49
+ The schema is defined using a schema-DSL library called Effect Schema.
50
+ The input schema describes the arguments that the script accepts.
51
+ The output schema describes the result that the script produces.
52
+ The schema is used to validate the script's input and output.
53
+ The schema is also goes into the script metadata.
54
+ The properties in the schema must have valid descriptions.
55
+ The input and output schemas must both be a struct of fields.
56
+
57
+ Restricts:
58
+ The scripts can only import code from "dxos:functions" module. No other modules are allowed.
59
+ Some web APIs are available - like fetch.
60
+
61
+ Reasoning:
62
+ Before writing a script, synthesize the following information:
63
+ - Description
64
+ - What APIs will be used.
65
+ - Detailed input schema
66
+ - Detailed output schema
67
+
68
+ <apis>
69
+ export function defineFunction(params: {
70
+ description: string,
71
+ inputSchema: S.Schema,
72
+ outputSchema: S.Schema,
73
+ handler: (params: { event: { data: TInput } }) => Promise<TOutput>
74
+ }): FunctionDefinition
75
+ /**
76
+ * Effect Schema
77
+ */
78
+ export const S;
79
+
80
+ // Examples:
81
+
82
+ S.String
83
+ S.Number
84
+ S.Boolean
85
+ S.Struct({
86
+ from: S.String.annotations({ description: 'The source currency' }),
87
+ to: S.String.annotations({ description: 'The target currency' }),
88
+ })
89
+ S.Array(S.String)
90
+ S.Union(S.String, S.Number)
91
+ S.optional(S.String)
92
+ S.String.annotations({ description: 'The source currency' })
93
+ </apis>
94
+
95
+ <handler_function>
96
+ Async function that takes the argument in the form of:
97
+
98
+ type HandlerFunctionParam = {
99
+ event: {
100
+ data: T // The input schema
101
+ },
102
+ }
103
+
104
+ The function must return the result that matches the output schema.
105
+ </handler_function>
106
+
107
+ <example>
108
+ import { defineFunction, S } from 'dxos:functions';
109
+
110
+ export default defineFunction({
111
+ description: 'Returns the exchange rate between two currencies.',
112
+
113
+ inputSchema: S.Struct({
114
+ from: S.String.annotations({ description: 'The source currency' }),
115
+ to: S.String.annotations({ description: 'The target currency' }),
116
+ }),
117
+
118
+ outputSchema: S.Struct({
119
+ rate: S.String.annotations({ description: 'The exchange rate' }),
120
+ }),
121
+
122
+ handler: async ({
123
+ event: {
124
+ data: { from, to },
125
+ },
126
+ }: any) => {
127
+ const res = await fetch(\`https://free.ratesdb.com/v1/rates?from=\${from}&to=\${to}\`);
128
+ const {
129
+ data: { rates },
130
+ } = await res.json();
131
+
132
+ return { rate: rates[to].toString() };
133
+ },
134
+ });
135
+ </example>
136
+ `,
137
+ schema: ScriptType,
138
+ tools: [
139
+ defineTool({
140
+ name: 'script_new',
141
+ description: 'Create a new script. Returns the artifact definition for the script',
142
+ schema: S.Struct({
143
+ name: S.String.annotations({ description: 'The name of the script' }),
144
+ code: S.String.annotations({
145
+ description: 'The full code of the script in JavaScript or TypeScript. Must be valid executable code.',
146
+ }),
147
+ }),
148
+ execute: async ({ name, code }, { extensions }) => {
149
+ invariant(extensions?.space, 'No space');
150
+ invariant(extensions?.dispatch, 'No intent dispatcher');
151
+ const script = create(ScriptType, {
152
+ name,
153
+ source: makeRef(
154
+ create(TextType, {
155
+ content: code,
156
+ }),
157
+ ),
158
+ });
159
+ extensions.space.db.add(script);
160
+ await extensions.space.db.flush();
161
+
162
+ const intent = createIntent(SpaceAction.AddObject, { target: extensions.space, object: script });
163
+ const { data, error } = await extensions.dispatch(intent);
164
+ if (!data || error) {
165
+ return ToolResult.Error(error?.message ?? 'Failed to create chess game');
166
+ }
167
+
168
+ return ToolResult.Success(createArtifactElement(script.id));
169
+ },
170
+ }),
171
+ defineTool({
172
+ name: 'script_inspect',
173
+ description: 'Inspect a script. Returns the artifact definition for the script',
174
+ schema: S.Struct({
175
+ id: ObjectId,
176
+ }),
177
+ execute: async ({ id }, { extensions }) => {
178
+ invariant(extensions?.space, 'No space');
179
+
180
+ const script = (await extensions.space.db.query({ id }).first()) as ScriptType;
181
+ const { content } = await script.source.load();
182
+
183
+ return ToolResult.Success({
184
+ name: script.name,
185
+ code: content,
186
+ });
187
+ },
188
+ }),
189
+ defineTool({
190
+ name: 'script_update',
191
+ description: 'Update a script. Returns the artifact definition for the script',
192
+ schema: S.Struct({
193
+ id: ObjectId,
194
+ code: S.String.annotations({
195
+ description: 'The full code of the script in JavaScript or TypeScript. Must be valid executable code.',
196
+ }),
197
+ }),
198
+ execute: async ({ id, code }, { extensions }) => {
199
+ invariant(extensions?.space, 'No space');
200
+
201
+ const script = (await extensions.space.db.query({ id }).first()) as ScriptType;
202
+ const source = await script.source.load();
203
+ if (!source) {
204
+ return ToolResult.Error('Script not found');
205
+ }
206
+
207
+ source.content = code;
208
+ await extensions.space?.db.flush();
209
+
210
+ return ToolResult.Success({
211
+ name: script.name,
212
+ });
213
+ },
214
+ }),
215
+ ],
216
+ });
217
+
218
+ return contributes(Capabilities.ArtifactDefinition, definition);
219
+ };
@@ -6,9 +6,9 @@
6
6
  import wasmUrl from 'esbuild-wasm/esbuild.wasm?url';
7
7
 
8
8
  import { contributes } from '@dxos/app-framework';
9
+ import { initializeBundler } from '@dxos/functions/bundler';
9
10
 
10
11
  import { ScriptCapabilities } from './capabilities';
11
- import { initializeBundler } from '../bundler';
12
12
  import { Compiler } from '../compiler';
13
13
 
14
14
  export default async () => {
@@ -8,5 +8,6 @@ export const Compiler = lazy(() => import('./compiler'));
8
8
  export const IntentResolver = lazy(() => import('./intent-resolver'));
9
9
  export const ReactSurface = lazy(() => import('./react-surface'));
10
10
  export const ScriptSettings = lazy(() => import('./settings'));
11
+ export const Artifact = lazy(() => import('./artifact'));
11
12
 
12
13
  export * from './capabilities';
@@ -15,29 +15,32 @@ import { ScriptAction } from '../types';
15
15
  export default () =>
16
16
  contributes(
17
17
  Capabilities.IntentResolver,
18
- createResolver(ScriptAction.Create, async ({ name, gistUrl, space }) => {
19
- let content = templates[0].source;
20
- const gistId = gistUrl?.split('/').at(-1);
21
- if (gistId) {
22
- // TODO(wittjosiah): Capability which contributes Octokit?
23
- // NOTE: AccessToken not needed to read public gists.
24
- const octokit = new Octokit();
25
- const response = await octokit.request('GET /gists/{gist_id}', {
26
- gist_id: gistId,
27
- });
28
- const gistContent = Object.values(response.data.files ?? {})[0]?.content;
29
- if (gistContent) {
30
- content = gistContent;
18
+ createResolver({
19
+ intent: ScriptAction.Create,
20
+ resolve: async ({ name, gistUrl }) => {
21
+ let content = templates[0].source;
22
+ const gistId = gistUrl?.split('/').at(-1);
23
+ if (gistId) {
24
+ // TODO(wittjosiah): Capability which contributes Octokit?
25
+ // NOTE: AccessToken not needed to read public gists.
26
+ const octokit = new Octokit();
27
+ const response = await octokit.request('GET /gists/{gist_id}', {
28
+ gist_id: gistId,
29
+ });
30
+ const gistContent = Object.values(response.data.files ?? {})[0]?.content;
31
+ if (gistContent) {
32
+ content = gistContent;
33
+ }
31
34
  }
32
- }
33
35
 
34
- return {
35
- data: {
36
- object: create(ScriptType, {
37
- name,
38
- source: makeRef(create(TextType, { content })),
39
- }),
40
- },
41
- };
36
+ return {
37
+ data: {
38
+ object: create(ScriptType, {
39
+ name,
40
+ source: makeRef(create(TextType, { content })),
41
+ }),
42
+ },
43
+ };
44
+ },
42
45
  }),
43
46
  );