@dxos/plugin-script 0.7.5-main.9d26e3a → 0.7.5-main.b19bfc8
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.
- package/dist/lib/browser/{AutomationPanel-RFQAQ7NF.mjs → AutomationPanel-6HFRNRWV.mjs} +3 -3
- package/dist/lib/browser/ScriptContainer-U3BFT76B.mjs +713 -0
- package/dist/lib/browser/ScriptContainer-U3BFT76B.mjs.map +7 -0
- package/dist/lib/browser/artifact-definition-NAWYXFF5.mjs +243 -0
- package/dist/lib/browser/artifact-definition-NAWYXFF5.mjs.map +7 -0
- package/dist/lib/browser/{chunk-K7KY6YMG.mjs → chunk-5SXOHNAK.mjs} +4 -4
- package/dist/lib/browser/chunk-5SXOHNAK.mjs.map +7 -0
- package/dist/lib/browser/chunk-6MOQ4BP3.mjs +15 -0
- package/dist/lib/browser/chunk-6MOQ4BP3.mjs.map +7 -0
- package/dist/lib/browser/chunk-FVVCAWNP.mjs +21 -0
- package/dist/lib/browser/chunk-FVVCAWNP.mjs.map +7 -0
- package/dist/lib/browser/chunk-HJNS3BBK.mjs +236 -0
- package/dist/lib/browser/chunk-HJNS3BBK.mjs.map +7 -0
- package/dist/lib/browser/chunk-N46LE7FS.mjs +40 -0
- package/dist/lib/browser/chunk-N46LE7FS.mjs.map +7 -0
- package/dist/lib/browser/chunk-PZPYF7M4.mjs +69 -0
- package/dist/lib/browser/chunk-PZPYF7M4.mjs.map +7 -0
- package/dist/lib/browser/compiler-YY2XSKHQ.mjs +82 -0
- package/dist/lib/browser/compiler-YY2XSKHQ.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +129 -288
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/intent-resolver-D6FPY5ZA.mjs +45 -0
- package/dist/lib/browser/intent-resolver-D6FPY5ZA.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/react-surface-DIXYM2HA.mjs +65 -0
- package/dist/lib/browser/react-surface-DIXYM2HA.mjs.map +7 -0
- package/dist/lib/browser/settings-SZCDKHWO.mjs +24 -0
- package/dist/lib/browser/settings-SZCDKHWO.mjs.map +7 -0
- package/dist/lib/browser/types.mjs +6 -4
- package/dist/lib/node/{AutomationPanel-5CJEF4MI.cjs → AutomationPanel-RBQ4DODN.cjs} +8 -8
- package/dist/lib/node/ScriptContainer-PSLB34RX.cjs +719 -0
- package/dist/lib/node/ScriptContainer-PSLB34RX.cjs.map +7 -0
- package/dist/lib/node/artifact-definition-7AANUS3X.cjs +262 -0
- package/dist/lib/node/artifact-definition-7AANUS3X.cjs.map +7 -0
- package/dist/lib/node/chunk-2UNNYU2C.cjs +264 -0
- package/dist/lib/node/chunk-2UNNYU2C.cjs.map +7 -0
- package/dist/lib/node/{chunk-6LYX73ZT.cjs → chunk-5UH3F7TA.cjs} +11 -8
- package/dist/lib/node/chunk-5UH3F7TA.cjs.map +7 -0
- package/dist/lib/node/{meta.cjs → chunk-ALY3N6PW.cjs} +12 -8
- package/dist/lib/node/chunk-ALY3N6PW.cjs.map +7 -0
- package/dist/lib/node/{chunk-PK3OQP5L.cjs → chunk-DJGLGRQV.cjs} +26 -11
- package/dist/lib/node/chunk-DJGLGRQV.cjs.map +7 -0
- package/dist/lib/node/chunk-ITAJ3WRW.cjs +77 -0
- package/dist/lib/node/chunk-ITAJ3WRW.cjs.map +7 -0
- package/dist/lib/node/{chunk-4INUJLXL.cjs → chunk-K3ZZWVXS.cjs} +7 -7
- package/dist/lib/node/chunk-K3ZZWVXS.cjs.map +7 -0
- package/dist/lib/node/compiler-UIBLKJKG.cjs +104 -0
- package/dist/lib/node/compiler-UIBLKJKG.cjs.map +7 -0
- package/dist/lib/node/index.cjs +122 -277
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/intent-resolver-NYJFPD5B.cjs +59 -0
- package/dist/lib/node/intent-resolver-NYJFPD5B.cjs.map +7 -0
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/react-surface-JOMWTFI2.cjs +84 -0
- package/dist/lib/node/react-surface-JOMWTFI2.cjs.map +7 -0
- package/dist/lib/node/settings-SZFSMSKM.cjs +38 -0
- package/dist/lib/node/settings-SZFSMSKM.cjs.map +7 -0
- package/dist/lib/node/types.cjs +6 -4
- package/dist/lib/node/types.cjs.map +2 -2
- package/dist/lib/node-esm/{AutomationPanel-7Y6REBNJ.mjs → AutomationPanel-WTVVVMRH.mjs} +3 -3
- package/dist/lib/node-esm/ScriptContainer-E4J6XXE6.mjs +714 -0
- package/dist/lib/node-esm/ScriptContainer-E4J6XXE6.mjs.map +7 -0
- package/dist/lib/node-esm/artifact-definition-KBASPVMM.mjs +245 -0
- package/dist/lib/node-esm/artifact-definition-KBASPVMM.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-OFYGBUNI.mjs → chunk-2AFXX34U.mjs} +4 -4
- package/dist/lib/node-esm/chunk-2AFXX34U.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-4OCRARHP.mjs +237 -0
- package/dist/lib/node-esm/chunk-4OCRARHP.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-CP5LXTK5.mjs +16 -0
- package/dist/lib/node-esm/chunk-CP5LXTK5.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-SLTZMY34.mjs → chunk-P2V2Y5LV.mjs} +7 -4
- package/dist/lib/node-esm/chunk-P2V2Y5LV.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-UNQFIERE.mjs +41 -0
- package/dist/lib/node-esm/chunk-UNQFIERE.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-YIWRJ25J.mjs +71 -0
- package/dist/lib/node-esm/chunk-YIWRJ25J.mjs.map +7 -0
- package/dist/lib/node-esm/compiler-XTXFGZJM.mjs +83 -0
- package/dist/lib/node-esm/compiler-XTXFGZJM.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +129 -288
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/intent-resolver-KLBHSMW4.mjs +46 -0
- package/dist/lib/node-esm/intent-resolver-KLBHSMW4.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/react-surface-OLH7N3DK.mjs +66 -0
- package/dist/lib/node-esm/react-surface-OLH7N3DK.mjs.map +7 -0
- package/dist/lib/node-esm/settings-GR4O2WHZ.mjs +25 -0
- package/dist/lib/node-esm/settings-GR4O2WHZ.mjs.map +7 -0
- package/dist/lib/node-esm/types.mjs +6 -4
- package/dist/types/src/ScriptPlugin.d.ts +1 -3
- package/dist/types/src/ScriptPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/artifact-definition.d.ts +11 -0
- package/dist/types/src/capabilities/artifact-definition.d.ts.map +1 -0
- package/dist/types/src/capabilities/capabilities.d.ts +5 -0
- package/dist/types/src/capabilities/capabilities.d.ts.map +1 -0
- package/dist/types/src/capabilities/compiler.d.ts +4 -0
- package/dist/types/src/capabilities/compiler.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +7 -0
- package/dist/types/src/capabilities/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/intent-resolver.d.ts +4 -0
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface.d.ts +4 -0
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -0
- package/dist/types/src/capabilities/settings.d.ts +4 -0
- package/dist/types/src/capabilities/settings.d.ts.map +1 -0
- package/dist/types/src/components/AutomationPanel/AutomationPanel.d.ts +1 -2
- package/dist/types/src/components/AutomationPanel/AutomationPanel.d.ts.map +1 -1
- package/dist/types/src/components/DebugPanel/DebugPanel.d.ts +1 -2
- package/dist/types/src/components/DebugPanel/DebugPanel.d.ts.map +1 -1
- package/dist/types/src/components/FrameContainer/FrameContainer.d.ts +3 -4
- package/dist/types/src/components/FrameContainer/FrameContainer.d.ts.map +1 -1
- package/dist/types/src/components/ScriptContainer.d.ts +10 -3
- package/dist/types/src/components/ScriptContainer.d.ts.map +1 -1
- package/dist/types/src/components/ScriptSettings/ScriptSettings.d.ts +1 -2
- package/dist/types/src/components/ScriptSettings/ScriptSettings.d.ts.map +1 -1
- package/dist/types/src/components/ScriptSettingsPanel.d.ts +1 -2
- package/dist/types/src/components/ScriptSettingsPanel.d.ts.map +1 -1
- package/dist/types/src/components/ScriptToolbar/ScriptToolbar.d.ts +10 -0
- package/dist/types/src/components/ScriptToolbar/ScriptToolbar.d.ts.map +1 -0
- package/dist/types/src/components/{Toolbar/Toolbar.stories.d.ts → ScriptToolbar/ScriptToolbar.stories.d.ts} +1 -1
- package/dist/types/src/components/ScriptToolbar/ScriptToolbar.stories.d.ts.map +1 -0
- package/dist/types/src/components/ScriptToolbar/index.d.ts +2 -0
- package/dist/types/src/components/ScriptToolbar/index.d.ts.map +1 -0
- package/dist/types/src/components/TypescriptEditor/TypescriptEditor.d.ts +4 -3
- package/dist/types/src/components/TypescriptEditor/TypescriptEditor.d.ts.map +1 -1
- package/dist/types/src/components/TypescriptEditor/TypescriptEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +2 -2
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/events.d.ts +4 -0
- package/dist/types/src/events.d.ts.map +1 -0
- package/dist/types/src/hooks/deploy.d.ts +48 -0
- package/dist/types/src/hooks/deploy.d.ts.map +1 -0
- package/dist/types/src/hooks/format.d.ts +25 -0
- package/dist/types/src/hooks/format.d.ts.map +1 -0
- package/dist/types/src/hooks/index.d.ts +7 -0
- package/dist/types/src/hooks/index.d.ts.map +1 -0
- package/dist/types/src/hooks/template.d.ts +31 -0
- package/dist/types/src/hooks/template.d.ts.map +1 -0
- package/dist/types/src/hooks/useToolbarAction.d.ts +14 -0
- package/dist/types/src/hooks/useToolbarAction.d.ts.map +1 -0
- package/dist/types/src/hooks/useToolbarState.d.ts +10 -0
- package/dist/types/src/hooks/useToolbarState.d.ts.map +1 -0
- package/dist/types/src/hooks/view.d.ts +33 -0
- package/dist/types/src/hooks/view.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +2 -5
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +2 -2
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/templates/chess.d.ts +1 -4
- package/dist/types/src/templates/chess.d.ts.map +1 -1
- package/dist/types/src/templates/discord.d.ts +3 -0
- package/dist/types/src/templates/discord.d.ts.map +1 -0
- package/dist/types/src/templates/echo.d.ts.map +1 -1
- package/dist/types/src/templates/email.d.ts +2 -1
- package/dist/types/src/templates/email.d.ts.map +1 -1
- package/dist/types/src/templates/forex-effect.d.ts +3 -0
- package/dist/types/src/templates/forex-effect.d.ts.map +1 -0
- package/dist/types/src/templates/forex.d.ts +1 -4
- package/dist/types/src/templates/forex.d.ts.map +1 -1
- package/dist/types/src/{templates.d.ts → templates/index.d.ts} +1 -1
- package/dist/types/src/templates/index.d.ts.map +1 -0
- package/dist/types/src/translations.d.ts +97 -0
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types.d.ts +14 -6
- package/dist/types/src/types.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +45 -46
- package/src/ScriptPlugin.tsx +70 -90
- package/src/capabilities/artifact-definition.ts +219 -0
- package/src/capabilities/capabilities.ts +12 -0
- package/src/capabilities/compiler.ts +33 -0
- package/src/capabilities/index.ts +13 -0
- package/src/capabilities/intent-resolver.ts +46 -0
- package/src/capabilities/react-surface.tsx +54 -0
- package/src/capabilities/settings.ts +14 -0
- package/src/compiler/compiler.browser.test.ts +1 -1
- package/src/components/DebugPanel/DebugPanel.tsx +2 -2
- package/src/components/FrameContainer/FrameContainer.tsx +5 -4
- package/src/components/ScriptContainer.tsx +69 -9
- package/src/components/ScriptSettings/ScriptSettings.tsx +28 -4
- package/src/components/ScriptSettingsPanel.tsx +139 -51
- package/src/components/{Toolbar/Toolbar.stories.tsx → ScriptToolbar/ScriptToolbar.stories.tsx} +2 -2
- package/src/components/ScriptToolbar/ScriptToolbar.tsx +53 -0
- package/src/{bundler → components/ScriptToolbar}/index.ts +1 -1
- package/src/components/TypescriptEditor/TypescriptEditor.stories.tsx +2 -0
- package/src/components/TypescriptEditor/TypescriptEditor.tsx +75 -10
- package/src/events.ts +11 -0
- package/src/hooks/deploy.ts +169 -0
- package/src/hooks/format.ts +47 -0
- package/src/hooks/index.ts +11 -0
- package/src/hooks/template.ts +64 -0
- package/src/hooks/useToolbarAction.ts +54 -0
- package/src/hooks/useToolbarState.ts +16 -0
- package/src/hooks/view.ts +52 -0
- package/src/index.ts +2 -7
- package/src/meta.ts +4 -2
- package/src/templates/chat.ts +4 -4
- package/src/templates/chess.ts +42 -35
- package/src/templates/discord.ts +103 -0
- package/src/templates/echo.ts +5 -1
- package/src/templates/email.ts +26 -23
- package/src/templates/forex-effect.ts +41 -0
- package/src/templates/forex.ts +23 -16
- package/src/{templates.ts → templates/index.ts} +20 -5
- package/src/translations.ts +23 -0
- package/src/types.ts +19 -18
- package/dist/lib/browser/ScriptContainer-GDVBWFI7.mjs +0 -415
- package/dist/lib/browser/ScriptContainer-GDVBWFI7.mjs.map +0 -7
- package/dist/lib/browser/chunk-4UTRJLQ3.mjs +0 -286
- package/dist/lib/browser/chunk-4UTRJLQ3.mjs.map +0 -7
- package/dist/lib/browser/chunk-C7VBULMK.mjs +0 -18
- package/dist/lib/browser/chunk-C7VBULMK.mjs.map +0 -7
- package/dist/lib/browser/chunk-K7KY6YMG.mjs.map +0 -7
- package/dist/lib/browser/chunk-RQA3EB5K.mjs +0 -26
- package/dist/lib/browser/chunk-RQA3EB5K.mjs.map +0 -7
- package/dist/lib/browser/meta.mjs +0 -9
- package/dist/lib/browser/meta.mjs.map +0 -7
- package/dist/lib/node/ScriptContainer-YWXXNLG6.cjs +0 -426
- package/dist/lib/node/ScriptContainer-YWXXNLG6.cjs.map +0 -7
- package/dist/lib/node/chunk-4INUJLXL.cjs.map +0 -7
- package/dist/lib/node/chunk-6LYX73ZT.cjs.map +0 -7
- package/dist/lib/node/chunk-PK3OQP5L.cjs.map +0 -7
- package/dist/lib/node/chunk-WPP65EYS.cjs +0 -298
- package/dist/lib/node/chunk-WPP65EYS.cjs.map +0 -7
- package/dist/lib/node/meta.cjs.map +0 -7
- package/dist/lib/node-esm/ScriptContainer-BG2PHKEH.mjs +0 -416
- package/dist/lib/node-esm/ScriptContainer-BG2PHKEH.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-4SRPREUK.mjs +0 -288
- package/dist/lib/node-esm/chunk-4SRPREUK.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-H6BBLQ5Q.mjs +0 -27
- package/dist/lib/node-esm/chunk-H6BBLQ5Q.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-OFYGBUNI.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-SLTZMY34.mjs.map +0 -7
- package/dist/lib/node-esm/meta.mjs +0 -10
- package/dist/lib/node-esm/meta.mjs.map +0 -7
- package/dist/types/src/bundler/bundler.d.ts +0 -39
- package/dist/types/src/bundler/bundler.d.ts.map +0 -1
- package/dist/types/src/bundler/bundler.test.d.ts +0 -2
- package/dist/types/src/bundler/bundler.test.d.ts.map +0 -1
- package/dist/types/src/bundler/index.d.ts +0 -2
- package/dist/types/src/bundler/index.d.ts.map +0 -1
- package/dist/types/src/components/ScriptBlock/ScriptBlock.d.ts +0 -12
- package/dist/types/src/components/ScriptBlock/ScriptBlock.d.ts.map +0 -1
- package/dist/types/src/components/ScriptBlock/ScriptBlock.stories.d.ts +0 -6
- package/dist/types/src/components/ScriptBlock/ScriptBlock.stories.d.ts.map +0 -1
- package/dist/types/src/components/ScriptBlock/index.d.ts +0 -2
- package/dist/types/src/components/ScriptBlock/index.d.ts.map +0 -1
- package/dist/types/src/components/ScriptEditor.d.ts +0 -9
- package/dist/types/src/components/ScriptEditor.d.ts.map +0 -1
- package/dist/types/src/components/Toolbar/Toolbar.d.ts +0 -23
- package/dist/types/src/components/Toolbar/Toolbar.d.ts.map +0 -1
- package/dist/types/src/components/Toolbar/Toolbar.stories.d.ts.map +0 -1
- package/dist/types/src/components/Toolbar/index.d.ts +0 -2
- package/dist/types/src/components/Toolbar/index.d.ts.map +0 -1
- package/dist/types/src/templates.d.ts.map +0 -1
- package/src/bundler/bundler.test.ts +0 -54
- package/src/bundler/bundler.ts +0 -250
- package/src/components/ScriptBlock/ScriptBlock.stories.tsx +0 -55
- package/src/components/ScriptBlock/ScriptBlock.tsx +0 -102
- package/src/components/ScriptBlock/index.ts +0 -5
- package/src/components/ScriptEditor.tsx +0 -193
- package/src/components/Toolbar/Toolbar.tsx +0 -177
- package/src/components/Toolbar/index.ts +0 -5
- /package/dist/lib/browser/{AutomationPanel-RFQAQ7NF.mjs.map → AutomationPanel-6HFRNRWV.mjs.map} +0 -0
- /package/dist/lib/node/{AutomationPanel-5CJEF4MI.cjs.map → AutomationPanel-RBQ4DODN.cjs.map} +0 -0
- /package/dist/lib/node-esm/{AutomationPanel-7Y6REBNJ.mjs.map → AutomationPanel-WTVVVMRH.mjs.map} +0 -0
package/package.json
CHANGED
|
@@ -1,23 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/plugin-script",
|
|
3
|
-
"version": "0.7.5-main.
|
|
3
|
+
"version": "0.7.5-main.b19bfc8",
|
|
4
4
|
"description": "Braneframe notebook plugin",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"author": "DXOS.org",
|
|
9
9
|
"sideEffects": true,
|
|
10
|
+
"type": "module",
|
|
10
11
|
"exports": {
|
|
11
12
|
".": {
|
|
12
13
|
"types": "./dist/types/src/index.d.ts",
|
|
13
14
|
"browser": "./dist/lib/browser/index.mjs",
|
|
14
15
|
"node": "./dist/lib/node-esm/index.mjs"
|
|
15
16
|
},
|
|
16
|
-
"./meta": {
|
|
17
|
-
"types": "./dist/types/src/meta.d.ts",
|
|
18
|
-
"browser": "./dist/lib/browser/meta.mjs",
|
|
19
|
-
"node": "./dist/lib/node-esm/meta.mjs"
|
|
20
|
-
},
|
|
21
17
|
"./types": {
|
|
22
18
|
"types": "./dist/types/src/types/index.d.ts",
|
|
23
19
|
"browser": "./dist/lib/browser/types/index.mjs",
|
|
@@ -27,9 +23,6 @@
|
|
|
27
23
|
"types": "dist/types/src/index.d.ts",
|
|
28
24
|
"typesVersions": {
|
|
29
25
|
"*": {
|
|
30
|
-
"meta": [
|
|
31
|
-
"dist/types/src/meta.d.ts"
|
|
32
|
-
],
|
|
33
26
|
"types": [
|
|
34
27
|
"dist/types/src/types/index.d.ts"
|
|
35
28
|
]
|
|
@@ -49,8 +42,11 @@
|
|
|
49
42
|
"@codemirror/view": "^6.34.1",
|
|
50
43
|
"@effect/schema": "^0.75.5",
|
|
51
44
|
"@lezer/common": "^1.2.2",
|
|
45
|
+
"@lezer/highlight": "^1.2.1",
|
|
46
|
+
"@octokit/core": "^4.0.4",
|
|
52
47
|
"@preact/signals-core": "^1.6.0",
|
|
53
48
|
"@typescript/vfs": "^1.6.0",
|
|
49
|
+
"@valtown/codemirror-continue": "^2.3.1",
|
|
54
50
|
"@valtown/codemirror-ts": "^2.2.0",
|
|
55
51
|
"codemirror": "^6.0.1",
|
|
56
52
|
"esbuild-wasm": "^0.16.14",
|
|
@@ -58,35 +54,40 @@
|
|
|
58
54
|
"prettier": "^3.2.4",
|
|
59
55
|
"react-syntax-highlighter": "^15.5.0",
|
|
60
56
|
"typescript": "^5.7.2",
|
|
61
|
-
"@dxos/app-framework": "0.7.5-main.
|
|
62
|
-
"@dxos/
|
|
63
|
-
"@dxos/
|
|
64
|
-
"@dxos/
|
|
65
|
-
"@dxos/
|
|
66
|
-
"@dxos/
|
|
67
|
-
"@dxos/
|
|
68
|
-
"@dxos/
|
|
69
|
-
"@dxos/
|
|
70
|
-
"@dxos/
|
|
71
|
-
"@dxos/
|
|
72
|
-
"@dxos/
|
|
73
|
-
"@dxos/
|
|
74
|
-
"@dxos/
|
|
75
|
-
"@dxos/log": "0.7.5-main.
|
|
76
|
-
"@dxos/plugin-
|
|
77
|
-
"@dxos/plugin-
|
|
78
|
-
"@dxos/plugin-
|
|
79
|
-
"@dxos/plugin-
|
|
80
|
-
"@dxos/plugin-
|
|
81
|
-
"@dxos/
|
|
82
|
-
"@dxos/
|
|
83
|
-
"@dxos/
|
|
84
|
-
"@dxos/react-
|
|
85
|
-
"@dxos/react-ui-
|
|
86
|
-
"@dxos/react-ui-
|
|
87
|
-
"@dxos/
|
|
88
|
-
"@dxos/
|
|
89
|
-
"@dxos/
|
|
57
|
+
"@dxos/app-framework": "0.7.5-main.b19bfc8",
|
|
58
|
+
"@dxos/artifact": "0.7.5-main.b19bfc8",
|
|
59
|
+
"@dxos/async": "0.7.5-main.b19bfc8",
|
|
60
|
+
"@dxos/assistant": "0.7.5-main.b19bfc8",
|
|
61
|
+
"@dxos/client": "0.7.5-main.b19bfc8",
|
|
62
|
+
"@dxos/client-protocol": "0.7.5-main.b19bfc8",
|
|
63
|
+
"@dxos/compute": "0.7.5-main.b19bfc8",
|
|
64
|
+
"@dxos/debug": "0.7.5-main.b19bfc8",
|
|
65
|
+
"@dxos/echo-schema": "0.7.5-main.b19bfc8",
|
|
66
|
+
"@dxos/functions": "0.7.5-main.b19bfc8",
|
|
67
|
+
"@dxos/invariant": "0.7.5-main.b19bfc8",
|
|
68
|
+
"@dxos/keys": "0.7.5-main.b19bfc8",
|
|
69
|
+
"@dxos/live-object": "0.7.5-main.b19bfc8",
|
|
70
|
+
"@dxos/local-storage": "0.7.5-main.b19bfc8",
|
|
71
|
+
"@dxos/log": "0.7.5-main.b19bfc8",
|
|
72
|
+
"@dxos/plugin-client": "0.7.5-main.b19bfc8",
|
|
73
|
+
"@dxos/plugin-explorer": "0.7.5-main.b19bfc8",
|
|
74
|
+
"@dxos/plugin-graph": "0.7.5-main.b19bfc8",
|
|
75
|
+
"@dxos/plugin-space": "0.7.5-main.b19bfc8",
|
|
76
|
+
"@dxos/plugin-stack": "0.7.5-main.b19bfc8",
|
|
77
|
+
"@dxos/plugin-theme": "0.7.5-main.b19bfc8",
|
|
78
|
+
"@dxos/plugin-markdown": "0.7.5-main.b19bfc8",
|
|
79
|
+
"@dxos/protocols": "0.7.5-main.b19bfc8",
|
|
80
|
+
"@dxos/react-client": "0.7.5-main.b19bfc8",
|
|
81
|
+
"@dxos/react-ui-attention": "0.7.5-main.b19bfc8",
|
|
82
|
+
"@dxos/react-ui-editor": "0.7.5-main.b19bfc8",
|
|
83
|
+
"@dxos/react-ui-menu": "0.7.5-main.b19bfc8",
|
|
84
|
+
"@dxos/react-ui-form": "0.7.5-main.b19bfc8",
|
|
85
|
+
"@dxos/react-ui-stack": "0.7.5-main.b19bfc8",
|
|
86
|
+
"@dxos/react-ui-syntax-highlighter": "0.7.5-main.b19bfc8",
|
|
87
|
+
"@dxos/rpc": "0.7.5-main.b19bfc8",
|
|
88
|
+
"@dxos/schema": "0.7.5-main.b19bfc8",
|
|
89
|
+
"@dxos/rpc-tunnel": "0.7.5-main.b19bfc8",
|
|
90
|
+
"@dxos/util": "0.7.5-main.b19bfc8"
|
|
90
91
|
},
|
|
91
92
|
"devDependencies": {
|
|
92
93
|
"@phosphor-icons/react": "^2.1.5",
|
|
@@ -96,19 +97,17 @@
|
|
|
96
97
|
"react": "~18.2.0",
|
|
97
98
|
"react-dom": "~18.2.0",
|
|
98
99
|
"vite": "5.4.7",
|
|
99
|
-
"@dxos/random": "0.7.5-main.
|
|
100
|
-
"@dxos/react-ui": "0.7.5-main.
|
|
101
|
-
"@dxos/
|
|
102
|
-
"@dxos/
|
|
103
|
-
"@dxos/react-ui-theme": "0.7.5-main.9d26e3a"
|
|
100
|
+
"@dxos/random": "0.7.5-main.b19bfc8",
|
|
101
|
+
"@dxos/react-ui": "0.7.5-main.b19bfc8",
|
|
102
|
+
"@dxos/storybook-utils": "0.7.5-main.b19bfc8",
|
|
103
|
+
"@dxos/react-ui-theme": "0.7.5-main.b19bfc8"
|
|
104
104
|
},
|
|
105
105
|
"peerDependencies": {
|
|
106
106
|
"@phosphor-icons/react": "^2.1.5",
|
|
107
107
|
"react": "~18.2.0",
|
|
108
108
|
"react-dom": "~18.2.0",
|
|
109
|
-
"@dxos/react-ui": "0.7.5-main.
|
|
110
|
-
"@dxos/react-ui
|
|
111
|
-
"@dxos/react-ui-theme": "0.7.5-main.9d26e3a"
|
|
109
|
+
"@dxos/react-ui-theme": "0.7.5-main.b19bfc8",
|
|
110
|
+
"@dxos/react-ui": "0.7.5-main.b19bfc8"
|
|
112
111
|
},
|
|
113
112
|
"publishConfig": {
|
|
114
113
|
"access": "public"
|
package/src/ScriptPlugin.tsx
CHANGED
|
@@ -3,104 +3,84 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
// @ts-ignore
|
|
6
|
-
import wasmUrl from 'esbuild-wasm/esbuild.wasm?url';
|
|
7
|
-
import React from 'react';
|
|
8
6
|
|
|
9
|
-
import { createIntent,
|
|
7
|
+
import { Capabilities, contributes, createIntent, defineModule, definePlugin, Events } from '@dxos/app-framework';
|
|
10
8
|
import { FunctionType, ScriptType } from '@dxos/functions';
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
9
|
+
import { RefArray } from '@dxos/live-object';
|
|
10
|
+
import { ClientCapabilities, ClientEvents } from '@dxos/plugin-client';
|
|
11
|
+
import { SpaceCapabilities } from '@dxos/plugin-space';
|
|
12
|
+
import { defineObjectForm } from '@dxos/plugin-space/types';
|
|
13
13
|
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import meta, { SCRIPT_PLUGIN } from './meta';
|
|
18
|
-
import { templates } from './templates';
|
|
14
|
+
import { ArtifactDefinition, Compiler, IntentResolver, ReactSurface, ScriptSettings } from './capabilities';
|
|
15
|
+
import { ScriptEvents } from './events';
|
|
16
|
+
import { meta, SCRIPT_PLUGIN } from './meta';
|
|
19
17
|
import translations from './translations';
|
|
20
|
-
import { ScriptAction
|
|
18
|
+
import { ScriptAction } from './types';
|
|
21
19
|
|
|
22
|
-
export const ScriptPlugin = ()
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
records: {
|
|
47
|
-
[ScriptType.typename]: {
|
|
48
|
-
createObject: (props: { name?: string }) => createIntent(ScriptAction.Create, props),
|
|
20
|
+
export const ScriptPlugin = () =>
|
|
21
|
+
definePlugin(meta, [
|
|
22
|
+
defineModule({
|
|
23
|
+
id: `${meta.id}/module/settings`,
|
|
24
|
+
activatesOn: Events.SetupSettings,
|
|
25
|
+
activate: ScriptSettings,
|
|
26
|
+
}),
|
|
27
|
+
defineModule({
|
|
28
|
+
id: `${meta.id}/module/compiler`,
|
|
29
|
+
activatesOn: ScriptEvents.SetupCompiler,
|
|
30
|
+
activate: Compiler,
|
|
31
|
+
}),
|
|
32
|
+
defineModule({
|
|
33
|
+
id: `${meta.id}/module/translations`,
|
|
34
|
+
activatesOn: Events.SetupTranslations,
|
|
35
|
+
activate: () => contributes(Capabilities.Translations, translations),
|
|
36
|
+
}),
|
|
37
|
+
defineModule({
|
|
38
|
+
id: `${meta.id}/module/metadata`,
|
|
39
|
+
activatesOn: Events.SetupMetadata,
|
|
40
|
+
activate: () =>
|
|
41
|
+
contributes(Capabilities.Metadata, {
|
|
42
|
+
id: ScriptType.typename,
|
|
43
|
+
metadata: {
|
|
49
44
|
placeholder: ['object title placeholder', { ns: SCRIPT_PLUGIN }],
|
|
50
45
|
icon: 'ph--code--regular',
|
|
51
46
|
// TODO(wittjosiah): Move out of metadata.
|
|
52
47
|
loadReferences: async (script: ScriptType) => await RefArray.loadAll([script.source]),
|
|
53
48
|
},
|
|
54
|
-
},
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
filter: (data): data is any => data.subject === SCRIPT_PLUGIN,
|
|
67
|
-
component: () => <ScriptSettings settings={{}} />,
|
|
68
|
-
}),
|
|
69
|
-
createSurface({
|
|
70
|
-
id: `${SCRIPT_PLUGIN}/article`,
|
|
71
|
-
role: 'article',
|
|
72
|
-
filter: (data): data is { subject: ScriptType } => data.subject instanceof ScriptType,
|
|
73
|
-
component: ({ data }) => <ScriptContainer script={data.subject} env={compiler.environment} />,
|
|
74
|
-
}),
|
|
75
|
-
createSurface({
|
|
76
|
-
id: `${SCRIPT_PLUGIN}/automation`,
|
|
77
|
-
role: 'complementary--automation',
|
|
78
|
-
disposition: 'hoist',
|
|
79
|
-
filter: (data): data is { subject: ScriptType } => data.subject instanceof ScriptType,
|
|
80
|
-
component: ({ data }) => <AutomationPanel subject={data.subject} />,
|
|
81
|
-
}),
|
|
82
|
-
createSurface({
|
|
83
|
-
id: `${SCRIPT_PLUGIN}/settings-panel`,
|
|
84
|
-
role: 'complementary--settings',
|
|
85
|
-
filter: (data): data is { subject: ScriptType } => data.subject instanceof ScriptType,
|
|
86
|
-
component: ({ data }) => <ScriptSettingsPanel script={data.subject} />,
|
|
49
|
+
}),
|
|
50
|
+
}),
|
|
51
|
+
defineModule({
|
|
52
|
+
id: `${meta.id}/module/object-form`,
|
|
53
|
+
activatesOn: ClientEvents.SetupSchema,
|
|
54
|
+
activate: () =>
|
|
55
|
+
contributes(
|
|
56
|
+
SpaceCapabilities.ObjectForm,
|
|
57
|
+
defineObjectForm({
|
|
58
|
+
objectSchema: ScriptType,
|
|
59
|
+
formSchema: ScriptAction.CreateScriptSchema,
|
|
60
|
+
getIntent: (props, options) => createIntent(ScriptAction.Create, { ...props, space: options.space }),
|
|
87
61
|
}),
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
}
|
|
62
|
+
),
|
|
63
|
+
}),
|
|
64
|
+
defineModule({
|
|
65
|
+
id: `${meta.id}/module/schema`,
|
|
66
|
+
activatesOn: ClientEvents.SetupSchema,
|
|
67
|
+
activate: () => contributes(ClientCapabilities.Schema, [FunctionType]),
|
|
68
|
+
}),
|
|
69
|
+
defineModule({
|
|
70
|
+
id: `${meta.id}/module/react-surface`,
|
|
71
|
+
activatesOn: Events.SetupReactSurface,
|
|
72
|
+
// TODO(wittjosiah): Should occur before the script editor is loaded when surfaces activation is more granular.
|
|
73
|
+
activatesBefore: [ScriptEvents.SetupCompiler],
|
|
74
|
+
activate: ReactSurface,
|
|
75
|
+
}),
|
|
76
|
+
defineModule({
|
|
77
|
+
id: `${meta.id}/module/intent-resolver`,
|
|
78
|
+
activatesOn: Events.SetupIntentResolver,
|
|
79
|
+
activate: IntentResolver,
|
|
80
|
+
}),
|
|
81
|
+
defineModule({
|
|
82
|
+
id: `${meta.id}/module/artifact-definition`,
|
|
83
|
+
activatesOn: Events.SetupArtifactDefinition,
|
|
84
|
+
activate: ArtifactDefinition,
|
|
85
|
+
}),
|
|
86
|
+
]);
|
|
@@ -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
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { defineCapability } from '@dxos/app-framework';
|
|
6
|
+
|
|
7
|
+
import { type Compiler } from '../compiler';
|
|
8
|
+
import { SCRIPT_PLUGIN } from '../meta';
|
|
9
|
+
|
|
10
|
+
export namespace ScriptCapabilities {
|
|
11
|
+
export const Compiler = defineCapability<Compiler>(`${SCRIPT_PLUGIN}/capability/compiler`);
|
|
12
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
// @ts-ignore
|
|
6
|
+
import wasmUrl from 'esbuild-wasm/esbuild.wasm?url';
|
|
7
|
+
|
|
8
|
+
import { contributes } from '@dxos/app-framework';
|
|
9
|
+
import { initializeBundler } from '@dxos/functions/bundler';
|
|
10
|
+
|
|
11
|
+
import { ScriptCapabilities } from './capabilities';
|
|
12
|
+
import { Compiler } from '../compiler';
|
|
13
|
+
|
|
14
|
+
export default async () => {
|
|
15
|
+
const compiler = new Compiler();
|
|
16
|
+
|
|
17
|
+
await compiler.initialize();
|
|
18
|
+
// TODO(wittjosiah): Fetch types for https modules.
|
|
19
|
+
compiler.setFile('/src/typings.d.ts', "declare module 'https://*';");
|
|
20
|
+
// TODO(wittjosiah): Proper function handler types.
|
|
21
|
+
// TODO(wittjosiah): Remove.
|
|
22
|
+
compiler.setFile(
|
|
23
|
+
'/src/runtime.ts',
|
|
24
|
+
`
|
|
25
|
+
export const Filter: any = {};
|
|
26
|
+
export type FunctionHandler = ({ event, context }: { event: any; context: any }) => Promise<Response>;
|
|
27
|
+
export const functionHandler = (handler: FunctionHandler) => handler;
|
|
28
|
+
`,
|
|
29
|
+
);
|
|
30
|
+
await initializeBundler({ wasmUrl });
|
|
31
|
+
|
|
32
|
+
return contributes(ScriptCapabilities.Compiler, compiler);
|
|
33
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { lazy } from '@dxos/app-framework';
|
|
6
|
+
|
|
7
|
+
export const Compiler = lazy(() => import('./compiler'));
|
|
8
|
+
export const IntentResolver = lazy(() => import('./intent-resolver'));
|
|
9
|
+
export const ReactSurface = lazy(() => import('./react-surface'));
|
|
10
|
+
export const ScriptSettings = lazy(() => import('./settings'));
|
|
11
|
+
export const ArtifactDefinition = lazy(() => import('./artifact-definition'));
|
|
12
|
+
|
|
13
|
+
export * from './capabilities';
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { Octokit } from '@octokit/core';
|
|
6
|
+
|
|
7
|
+
import { contributes, Capabilities, createResolver } from '@dxos/app-framework';
|
|
8
|
+
import { ScriptType } from '@dxos/functions';
|
|
9
|
+
import { create, makeRef } from '@dxos/live-object';
|
|
10
|
+
import { TextType } from '@dxos/schema';
|
|
11
|
+
|
|
12
|
+
import { templates } from '../templates';
|
|
13
|
+
import { ScriptAction } from '../types';
|
|
14
|
+
|
|
15
|
+
export default () =>
|
|
16
|
+
contributes(
|
|
17
|
+
Capabilities.IntentResolver,
|
|
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
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return {
|
|
37
|
+
data: {
|
|
38
|
+
object: create(ScriptType, {
|
|
39
|
+
name,
|
|
40
|
+
source: makeRef(create(TextType, { content })),
|
|
41
|
+
}),
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
},
|
|
45
|
+
}),
|
|
46
|
+
);
|