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

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-SPKDYRXU.mjs} +98 -70
  3. package/dist/lib/browser/ScriptContainer-SPKDYRXU.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-REL2R7SB.mjs → chunk-GB5OS4JQ.mjs} +20 -3
  11. package/dist/lib/browser/chunk-GB5OS4JQ.mjs.map +7 -0
  12. package/dist/lib/browser/{chunk-XPGBHZ3L.mjs → chunk-N46LE7FS.mjs} +2 -2
  13. package/dist/lib/browser/{chunk-SIOGRRPF.mjs → chunk-XTD6J6PC.mjs} +21 -9
  14. package/dist/lib/browser/chunk-XTD6J6PC.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-IKIQWAL4.mjs +45 -0
  20. package/dist/lib/browser/intent-resolver-IKIQWAL4.mjs.map +7 -0
  21. package/dist/lib/browser/meta.json +1 -1
  22. package/dist/lib/browser/{react-surface-GAWVYTJ5.mjs → react-surface-ZP2FXWYA.mjs} +12 -14
  23. package/dist/lib/browser/react-surface-ZP2FXWYA.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-M3PIEFIA.cjs} +101 -71
  28. package/dist/lib/node/ScriptContainer-M3PIEFIA.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-EFTZN5X7.cjs → chunk-5UH3F7TA.cjs} +8 -5
  32. package/dist/lib/node/chunk-5UH3F7TA.cjs.map +7 -0
  33. package/dist/lib/node/{chunk-A2DI2G4D.cjs → chunk-ALY3N6PW.cjs} +6 -6
  34. package/dist/lib/node/{chunk-6VKZJ4MH.cjs → chunk-DJGLGRQV.cjs} +6 -6
  35. package/dist/lib/node/{chunk-TJ4BTPOS.cjs → chunk-FGJJPY2L.cjs} +19 -6
  36. package/dist/lib/node/chunk-FGJJPY2L.cjs.map +7 -0
  37. package/dist/lib/node/{chunk-5V3XGLTR.cjs → chunk-HEDZVP6A.cjs} +24 -12
  38. package/dist/lib/node/chunk-HEDZVP6A.cjs.map +7 -0
  39. package/dist/lib/node/{chunk-DQRAVZM7.cjs → chunk-IID7WUQS.cjs} +6 -6
  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-BLLSSUIM.cjs} +31 -28
  45. package/dist/lib/node/intent-resolver-BLLSSUIM.cjs.map +7 -0
  46. package/dist/lib/node/meta.json +1 -1
  47. package/dist/lib/node/{react-surface-OMBMSFZT.cjs → react-surface-BI5NMAJM.cjs} +23 -25
  48. package/dist/lib/node/react-surface-BI5NMAJM.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-6GCPTLOV.mjs} +98 -70
  54. package/dist/lib/node-esm/ScriptContainer-6GCPTLOV.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-XUWS7OTK.mjs → chunk-CGF7EOGD.mjs} +2 -2
  58. package/dist/lib/node-esm/{chunk-675XSDRN.mjs → chunk-CP5LXTK5.mjs} +2 -2
  59. package/dist/lib/node-esm/{chunk-XPIKUBGS.mjs → chunk-DWVYAASV.mjs} +21 -9
  60. package/dist/lib/node-esm/chunk-DWVYAASV.mjs.map +7 -0
  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-JJZYWSD7.mjs → chunk-RFVLVTYI.mjs} +20 -3
  64. package/dist/lib/node-esm/chunk-RFVLVTYI.mjs.map +7 -0
  65. package/dist/lib/node-esm/{chunk-JHGOPQVO.mjs → chunk-UNQFIERE.mjs} +2 -2
  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-QFIYWOWQ.mjs +46 -0
  71. package/dist/lib/node-esm/intent-resolver-QFIYWOWQ.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-N4Z5HGAC.mjs} +12 -14
  74. package/dist/lib/node-esm/react-surface-N4Z5HGAC.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 +86 -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,262 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var artifact_IPGGY2Z2_exports = {};
20
+ __export(artifact_IPGGY2Z2_exports, {
21
+ default: () => artifact_default
22
+ });
23
+ module.exports = __toCommonJS(artifact_IPGGY2Z2_exports);
24
+ var import_app_framework = require("@dxos/app-framework");
25
+ var import_artifact = require("@dxos/artifact");
26
+ var import_assistant = require("@dxos/assistant");
27
+ var import_echo_schema = require("@dxos/echo-schema");
28
+ var import_functions = require("@dxos/functions");
29
+ var import_invariant = require("@dxos/invariant");
30
+ var import_types = require("@dxos/plugin-space/types");
31
+ var import_echo = require("@dxos/react-client/echo");
32
+ var import_schema = require("@dxos/schema");
33
+ var __dxlog_file = "/home/runner/work/dxos/dxos/packages/plugins/experimental/plugin-script/src/capabilities/artifact.ts";
34
+ var artifact_default = () => {
35
+ const definition = (0, import_artifact.defineArtifact)({
36
+ id: "plugin-script",
37
+ // TODO(dmaretskyi): Since writing scripts requires a lot of domain knowledge,
38
+ // we should offload the work of synthesizing the code to a separate model.
39
+ // The main reasoning model will give it a concrete task and the script model will synthesize the code, knowing all the docs.
40
+ instructions: `
41
+ If the user explicitly requests you to write a script, you can create one.
42
+ If the user requests you to change one of the existing script, you can update it.
43
+ Scripts are short code pieces of executable code that can be used to perform computations, integrate with external systems, and perform automated tasks.
44
+ Each script must follow as strict shape for the definition but the body can contain any valid executable code.
45
+ Scripts are written in JavaScript or TypeScript.
46
+ Each script must define an input schema and output schema.
47
+ Each script must have its own detailed description.
48
+
49
+ Important: You cannot execute scripts. Scripts are only available as tools after the user deploys them. You must only call the available tools.
50
+
51
+ Description:
52
+ The description is a detailed description of the script.
53
+ It is used to describe the script's purpose, input, and output.
54
+ The description is used to generate the script's documentation.
55
+ The description is also goes into the script metadata.
56
+ The description is used by AI to understand the script and its purpose.
57
+ The description must provide cases on when the script should be used.
58
+
59
+ Schema:
60
+ The schema is defined using a schema-DSL library called Effect Schema.
61
+ The input schema describes the arguments that the script accepts.
62
+ The output schema describes the result that the script produces.
63
+ The schema is used to validate the script's input and output.
64
+ The schema is also goes into the script metadata.
65
+ The properties in the schema must have valid descriptions.
66
+ The input and output schemas must both be a struct of fields.
67
+
68
+ Restricts:
69
+ The scripts can only import code from "dxos:functions" module. No other modules are allowed.
70
+ Some web APIs are available - like fetch.
71
+
72
+ Reasoning:
73
+ Before writing a script, synthesize the following information:
74
+ - Description
75
+ - What APIs will be used.
76
+ - Detailed input schema
77
+ - Detailed output schema
78
+
79
+ <apis>
80
+ export function defineFunction(params: {
81
+ description: string,
82
+ inputSchema: S.Schema,
83
+ outputSchema: S.Schema,
84
+ handler: (params: { event: { data: TInput } }) => Promise<TOutput>
85
+ }): FunctionDefinition
86
+ /**
87
+ * Effect Schema
88
+ */
89
+ export const S;
90
+
91
+ // Examples:
92
+
93
+ S.String
94
+ S.Number
95
+ S.Boolean
96
+ S.Struct({
97
+ from: S.String.annotations({ description: 'The source currency' }),
98
+ to: S.String.annotations({ description: 'The target currency' }),
99
+ })
100
+ S.Array(S.String)
101
+ S.Union(S.String, S.Number)
102
+ S.optional(S.String)
103
+ S.String.annotations({ description: 'The source currency' })
104
+ </apis>
105
+
106
+ <handler_function>
107
+ Async function that takes the argument in the form of:
108
+
109
+ type HandlerFunctionParam = {
110
+ event: {
111
+ data: T // The input schema
112
+ },
113
+ }
114
+
115
+ The function must return the result that matches the output schema.
116
+ </handler_function>
117
+
118
+ <example>
119
+ import { defineFunction, S } from 'dxos:functions';
120
+
121
+ export default defineFunction({
122
+ description: 'Returns the exchange rate between two currencies.',
123
+
124
+ inputSchema: S.Struct({
125
+ from: S.String.annotations({ description: 'The source currency' }),
126
+ to: S.String.annotations({ description: 'The target currency' }),
127
+ }),
128
+
129
+ outputSchema: S.Struct({
130
+ rate: S.String.annotations({ description: 'The exchange rate' }),
131
+ }),
132
+
133
+ handler: async ({
134
+ event: {
135
+ data: { from, to },
136
+ },
137
+ }: any) => {
138
+ const res = await fetch(\`https://free.ratesdb.com/v1/rates?from=\${from}&to=\${to}\`);
139
+ const {
140
+ data: { rates },
141
+ } = await res.json();
142
+
143
+ return { rate: rates[to].toString() };
144
+ },
145
+ });
146
+ </example>
147
+ `,
148
+ schema: import_functions.ScriptType,
149
+ tools: [
150
+ (0, import_artifact.defineTool)({
151
+ name: "script_new",
152
+ description: "Create a new script. Returns the artifact definition for the script",
153
+ schema: import_echo_schema.S.Struct({
154
+ name: import_echo_schema.S.String.annotations({
155
+ description: "The name of the script"
156
+ }),
157
+ code: import_echo_schema.S.String.annotations({
158
+ description: "The full code of the script in JavaScript or TypeScript. Must be valid executable code."
159
+ })
160
+ }),
161
+ execute: async ({ name, code }, { extensions }) => {
162
+ (0, import_invariant.invariant)(extensions?.space, "No space", {
163
+ F: __dxlog_file,
164
+ L: 149,
165
+ S: void 0,
166
+ A: [
167
+ "extensions?.space",
168
+ "'No space'"
169
+ ]
170
+ });
171
+ (0, import_invariant.invariant)(extensions?.dispatch, "No intent dispatcher", {
172
+ F: __dxlog_file,
173
+ L: 150,
174
+ S: void 0,
175
+ A: [
176
+ "extensions?.dispatch",
177
+ "'No intent dispatcher'"
178
+ ]
179
+ });
180
+ const script = (0, import_echo.create)(import_functions.ScriptType, {
181
+ name,
182
+ source: (0, import_echo.makeRef)((0, import_echo.create)(import_schema.TextType, {
183
+ content: code
184
+ }))
185
+ });
186
+ extensions.space.db.add(script);
187
+ await extensions.space.db.flush();
188
+ const intent = (0, import_app_framework.createIntent)(import_types.SpaceAction.AddObject, {
189
+ target: extensions.space,
190
+ object: script
191
+ });
192
+ const { data, error } = await extensions.dispatch(intent);
193
+ if (!data || error) {
194
+ return import_artifact.ToolResult.Error(error?.message ?? "Failed to create chess game");
195
+ }
196
+ return import_artifact.ToolResult.Success((0, import_assistant.createArtifactElement)(script.id));
197
+ }
198
+ }),
199
+ (0, import_artifact.defineTool)({
200
+ name: "script_inspect",
201
+ description: "Inspect a script. Returns the artifact definition for the script",
202
+ schema: import_echo_schema.S.Struct({
203
+ id: import_echo_schema.ObjectId
204
+ }),
205
+ execute: async ({ id }, { extensions }) => {
206
+ (0, import_invariant.invariant)(extensions?.space, "No space", {
207
+ F: __dxlog_file,
208
+ L: 178,
209
+ S: void 0,
210
+ A: [
211
+ "extensions?.space",
212
+ "'No space'"
213
+ ]
214
+ });
215
+ const script = await extensions.space.db.query({
216
+ id
217
+ }).first();
218
+ const { content } = await script.source.load();
219
+ return import_artifact.ToolResult.Success({
220
+ name: script.name,
221
+ code: content
222
+ });
223
+ }
224
+ }),
225
+ (0, import_artifact.defineTool)({
226
+ name: "script_update",
227
+ description: "Update a script. Returns the artifact definition for the script",
228
+ schema: import_echo_schema.S.Struct({
229
+ id: import_echo_schema.ObjectId,
230
+ code: import_echo_schema.S.String.annotations({
231
+ description: "The full code of the script in JavaScript or TypeScript. Must be valid executable code."
232
+ })
233
+ }),
234
+ execute: async ({ id, code }, { extensions }) => {
235
+ (0, import_invariant.invariant)(extensions?.space, "No space", {
236
+ F: __dxlog_file,
237
+ L: 199,
238
+ S: void 0,
239
+ A: [
240
+ "extensions?.space",
241
+ "'No space'"
242
+ ]
243
+ });
244
+ const script = await extensions.space.db.query({
245
+ id
246
+ }).first();
247
+ const source = await script.source.load();
248
+ if (!source) {
249
+ return import_artifact.ToolResult.Error("Script not found");
250
+ }
251
+ source.content = code;
252
+ await extensions.space?.db.flush();
253
+ return import_artifact.ToolResult.Success({
254
+ name: script.name
255
+ });
256
+ }
257
+ })
258
+ ]
259
+ });
260
+ return (0, import_app_framework.contributes)(import_app_framework.Capabilities.ArtifactDefinition, definition);
261
+ };
262
+ //# sourceMappingURL=artifact-IPGGY2Z2.cjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/capabilities/artifact.ts"],
4
+ "sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { Capabilities, contributes, createIntent, type PromiseIntentDispatcher } from '@dxos/app-framework';\nimport { defineArtifact, defineTool, ToolResult } from '@dxos/artifact';\nimport { createArtifactElement } from '@dxos/assistant';\nimport { ObjectId, S } from '@dxos/echo-schema';\nimport { ScriptType } from '@dxos/functions';\nimport { invariant } from '@dxos/invariant';\nimport { SpaceAction } from '@dxos/plugin-space/types';\nimport { create, makeRef, type Space } from '@dxos/react-client/echo';\nimport { TextType } from '@dxos/schema';\n\n// TODO(burdon): Factor out.\ndeclare global {\n interface ToolContextExtensions {\n space?: Space;\n dispatch?: PromiseIntentDispatcher;\n }\n}\n\nexport default () => {\n const definition = defineArtifact({\n id: 'plugin-script',\n // TODO(dmaretskyi): Since writing scripts requires a lot of domain knowledge,\n // we should offload the work of synthesizing the code to a separate model.\n // The main reasoning model will give it a concrete task and the script model will synthesize the code, knowing all the docs.\n instructions: `\n If the user explicitly requests you to write a script, you can create one.\n If the user requests you to change one of the existing script, you can update it.\n Scripts are short code pieces of executable code that can be used to perform computations, integrate with external systems, and perform automated tasks.\n Each script must follow as strict shape for the definition but the body can contain any valid executable code.\n Scripts are written in JavaScript or TypeScript.\n Each script must define an input schema and output schema.\n Each script must have its own detailed description.\n\n Important: You cannot execute scripts. Scripts are only available as tools after the user deploys them. You must only call the available tools.\n\n Description:\n The description is a detailed description of the script.\n It is used to describe the script's purpose, input, and output.\n The description is used to generate the script's documentation.\n The description is also goes into the script metadata.\n The description is used by AI to understand the script and its purpose.\n The description must provide cases on when the script should be used.\n\n Schema: \n The schema is defined using a schema-DSL library called Effect Schema.\n The input schema describes the arguments that the script accepts.\n The output schema describes the result that the script produces.\n The schema is used to validate the script's input and output.\n The schema is also goes into the script metadata.\n The properties in the schema must have valid descriptions.\n The input and output schemas must both be a struct of fields.\n\n Restricts:\n The scripts can only import code from \"dxos:functions\" module. No other modules are allowed.\n Some web APIs are available - like fetch.\n\n Reasoning:\n Before writing a script, synthesize the following information:\n - Description\n - What APIs will be used.\n - Detailed input schema\n - Detailed output schema\n\n <apis>\n export function defineFunction(params: { \n description: string, \n inputSchema: S.Schema, \n outputSchema: S.Schema, \n handler: (params: { event: { data: TInput } }) => Promise<TOutput> \n }): FunctionDefinition\n /**\n * Effect Schema\n */\n export const S; \n\n // Examples: \n\n S.String\n S.Number\n S.Boolean\n S.Struct({\n from: S.String.annotations({ description: 'The source currency' }),\n to: S.String.annotations({ description: 'The target currency' }),\n })\n S.Array(S.String)\n S.Union(S.String, S.Number)\n S.optional(S.String)\n S.String.annotations({ description: 'The source currency' })\n </apis>\n\n <handler_function>\n Async function that takes the argument in the form of:\n\n type HandlerFunctionParam = {\n event: {\n data: T // The input schema\n },\n }\n\n The function must return the result that matches the output schema.\n </handler_function>\n \n <example>\n import { defineFunction, S } from 'dxos:functions';\n\n export default defineFunction({\n description: 'Returns the exchange rate between two currencies.',\n\n inputSchema: S.Struct({\n from: S.String.annotations({ description: 'The source currency' }),\n to: S.String.annotations({ description: 'The target currency' }),\n }),\n\n outputSchema: S.Struct({\n rate: S.String.annotations({ description: 'The exchange rate' }),\n }),\n\n handler: async ({\n event: {\n data: { from, to },\n },\n }: any) => {\n const res = await fetch(\\`https://free.ratesdb.com/v1/rates?from=\\${from}&to=\\${to}\\`);\n const {\n data: { rates },\n } = await res.json();\n\n return { rate: rates[to].toString() };\n },\n });\n </example>\n `,\n schema: ScriptType,\n tools: [\n defineTool({\n name: 'script_new',\n description: 'Create a new script. Returns the artifact definition for the script',\n schema: S.Struct({\n name: S.String.annotations({ description: 'The name of the script' }),\n code: S.String.annotations({\n description: 'The full code of the script in JavaScript or TypeScript. Must be valid executable code.',\n }),\n }),\n execute: async ({ name, code }, { extensions }) => {\n invariant(extensions?.space, 'No space');\n invariant(extensions?.dispatch, 'No intent dispatcher');\n const script = create(ScriptType, {\n name,\n source: makeRef(\n create(TextType, {\n content: code,\n }),\n ),\n });\n extensions.space.db.add(script);\n await extensions.space.db.flush();\n\n const intent = createIntent(SpaceAction.AddObject, { target: extensions.space, object: script });\n const { data, error } = await extensions.dispatch(intent);\n if (!data || error) {\n return ToolResult.Error(error?.message ?? 'Failed to create chess game');\n }\n\n return ToolResult.Success(createArtifactElement(script.id));\n },\n }),\n defineTool({\n name: 'script_inspect',\n description: 'Inspect a script. Returns the artifact definition for the script',\n schema: S.Struct({\n id: ObjectId,\n }),\n execute: async ({ id }, { extensions }) => {\n invariant(extensions?.space, 'No space');\n\n const script = (await extensions.space.db.query({ id }).first()) as ScriptType;\n const { content } = await script.source.load();\n\n return ToolResult.Success({\n name: script.name,\n code: content,\n });\n },\n }),\n defineTool({\n name: 'script_update',\n description: 'Update a script. Returns the artifact definition for the script',\n schema: S.Struct({\n id: ObjectId,\n code: S.String.annotations({\n description: 'The full code of the script in JavaScript or TypeScript. Must be valid executable code.',\n }),\n }),\n execute: async ({ id, code }, { extensions }) => {\n invariant(extensions?.space, 'No space');\n\n const script = (await extensions.space.db.query({ id }).first()) as ScriptType;\n const source = await script.source.load();\n if (!source) {\n return ToolResult.Error('Script not found');\n }\n\n source.content = code;\n await extensions.space?.db.flush();\n\n return ToolResult.Success({\n name: script.name,\n });\n },\n }),\n ],\n });\n\n return contributes(Capabilities.ArtifactDefinition, definition);\n};\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAIA,2BAAsF;AACtF,sBAAuD;AACvD,uBAAsC;AACtC,yBAA4B;AAC5B,uBAA2B;AAC3B,uBAA0B;AAC1B,mBAA4B;AAC5B,kBAA4C;AAC5C,oBAAyB;;AAUzB,IAAA,mBAAe,MAAA;AACb,QAAMA,iBAAaC,gCAAe;IAChCC,IAAI;;;;IAIJC,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IA4GdC,QAAQC;IACRC,OAAO;UACLC,4BAAW;QACTC,MAAM;QACNC,aAAa;QACbL,QAAQM,qBAAEC,OAAO;UACfH,MAAME,qBAAEE,OAAOC,YAAY;YAAEJ,aAAa;UAAyB,CAAA;UACnEK,MAAMJ,qBAAEE,OAAOC,YAAY;YACzBJ,aAAa;UACf,CAAA;QACF,CAAA;QACAM,SAAS,OAAO,EAAEP,MAAMM,KAAI,GAAI,EAAEE,WAAU,MAAE;AAC5CC,0CAAUD,YAAYE,OAAO,YAAA;;;;;;;;;AAC7BD,0CAAUD,YAAYG,UAAU,wBAAA;;;;;;;;;AAChC,gBAAMC,aAASC,oBAAOhB,6BAAY;YAChCG;YACAc,YAAQC,yBACNF,oBAAOG,wBAAU;cACfC,SAASX;YACX,CAAA,CAAA;UAEJ,CAAA;AACAE,qBAAWE,MAAMQ,GAAGC,IAAIP,MAAAA;AACxB,gBAAMJ,WAAWE,MAAMQ,GAAGE,MAAK;AAE/B,gBAAMC,aAASC,mCAAaC,yBAAYC,WAAW;YAAEC,QAAQjB,WAAWE;YAAOgB,QAAQd;UAAO,CAAA;AAC9F,gBAAM,EAAEe,MAAMC,MAAK,IAAK,MAAMpB,WAAWG,SAASU,MAAAA;AAClD,cAAI,CAACM,QAAQC,OAAO;AAClB,mBAAOC,2BAAWC,MAAMF,OAAOG,WAAW,6BAAA;UAC5C;AAEA,iBAAOF,2BAAWG,YAAQC,wCAAsBrB,OAAOlB,EAAE,CAAA;QAC3D;MACF,CAAA;UACAK,4BAAW;QACTC,MAAM;QACNC,aAAa;QACbL,QAAQM,qBAAEC,OAAO;UACfT,IAAIwC;QACN,CAAA;QACA3B,SAAS,OAAO,EAAEb,GAAE,GAAI,EAAEc,WAAU,MAAE;AACpCC,0CAAUD,YAAYE,OAAO,YAAA;;;;;;;;;AAE7B,gBAAME,SAAU,MAAMJ,WAAWE,MAAMQ,GAAGiB,MAAM;YAAEzC;UAAG,CAAA,EAAG0C,MAAK;AAC7D,gBAAM,EAAEnB,QAAO,IAAK,MAAML,OAAOE,OAAOuB,KAAI;AAE5C,iBAAOR,2BAAWG,QAAQ;YACxBhC,MAAMY,OAAOZ;YACbM,MAAMW;UACR,CAAA;QACF;MACF,CAAA;UACAlB,4BAAW;QACTC,MAAM;QACNC,aAAa;QACbL,QAAQM,qBAAEC,OAAO;UACfT,IAAIwC;UACJ5B,MAAMJ,qBAAEE,OAAOC,YAAY;YACzBJ,aAAa;UACf,CAAA;QACF,CAAA;QACAM,SAAS,OAAO,EAAEb,IAAIY,KAAI,GAAI,EAAEE,WAAU,MAAE;AAC1CC,0CAAUD,YAAYE,OAAO,YAAA;;;;;;;;;AAE7B,gBAAME,SAAU,MAAMJ,WAAWE,MAAMQ,GAAGiB,MAAM;YAAEzC;UAAG,CAAA,EAAG0C,MAAK;AAC7D,gBAAMtB,SAAS,MAAMF,OAAOE,OAAOuB,KAAI;AACvC,cAAI,CAACvB,QAAQ;AACX,mBAAOe,2BAAWC,MAAM,kBAAA;UAC1B;AAEAhB,iBAAOG,UAAUX;AACjB,gBAAME,WAAWE,OAAOQ,GAAGE,MAAAA;AAE3B,iBAAOS,2BAAWG,QAAQ;YACxBhC,MAAMY,OAAOZ;UACf,CAAA;QACF;MACF,CAAA;;EAEJ,CAAA;AAEA,aAAOsC,kCAAYC,kCAAaC,oBAAoBhD,UAAAA;AACtD;",
6
+ "names": ["definition", "defineArtifact", "id", "instructions", "schema", "ScriptType", "tools", "defineTool", "name", "description", "S", "Struct", "String", "annotations", "code", "execute", "extensions", "invariant", "space", "dispatch", "script", "create", "source", "makeRef", "TextType", "content", "db", "add", "flush", "intent", "createIntent", "SpaceAction", "AddObject", "target", "object", "data", "error", "ToolResult", "Error", "message", "Success", "createArtifactElement", "ObjectId", "query", "first", "load", "contributes", "Capabilities", "ArtifactDefinition"]
7
+ }
@@ -16,21 +16,24 @@ var __copyProps = (to, from, except, desc) => {
16
16
  return to;
17
17
  };
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var chunk_EFTZN5X7_exports = {};
20
- __export(chunk_EFTZN5X7_exports, {
19
+ var chunk_5UH3F7TA_exports = {};
20
+ __export(chunk_5UH3F7TA_exports, {
21
21
  SCRIPT_PLUGIN: () => SCRIPT_PLUGIN,
22
22
  meta: () => meta
23
23
  });
24
- module.exports = __toCommonJS(chunk_EFTZN5X7_exports);
24
+ module.exports = __toCommonJS(chunk_5UH3F7TA_exports);
25
25
  var SCRIPT_PLUGIN = "dxos.org/plugin/script";
26
26
  var meta = {
27
27
  id: SCRIPT_PLUGIN,
28
28
  name: "Scripts",
29
- description: "Distributed functions.",
29
+ description: "Scripts in Composer allow you to deploy custom functions that run on the edge. These functions can be referenced by your AI agent and called inside of cells in any Sheet. Use scripts to interact with API\u2019s or external data inside of Composer.",
30
30
  icon: "ph--code--regular",
31
31
  source: "https://github.com/dxos/dxos/tree/main/packages/plugins/experimental/plugin-explorer",
32
32
  tags: [
33
33
  "experimental"
34
+ ],
35
+ screenshots: [
36
+ "https://dxos.network/plugin-details-scripts-dark.png"
34
37
  ]
35
38
  };
36
39
  // Annotate the CommonJS export names for ESM import in node:
@@ -38,4 +41,4 @@ var meta = {
38
41
  SCRIPT_PLUGIN,
39
42
  meta
40
43
  });
41
- //# sourceMappingURL=chunk-EFTZN5X7.cjs.map
44
+ //# sourceMappingURL=chunk-5UH3F7TA.cjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/meta.ts"],
4
+ "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { type PluginMeta } from '@dxos/app-framework';\n\nexport const SCRIPT_PLUGIN = 'dxos.org/plugin/script';\n\nexport const meta = {\n id: SCRIPT_PLUGIN,\n name: 'Scripts',\n description:\n 'Scripts in Composer allow you to deploy custom functions that run on the edge. These functions can be referenced by your AI agent and called inside of cells in any Sheet. Use scripts to interact with API’s or external data inside of Composer.',\n icon: 'ph--code--regular',\n source: 'https://github.com/dxos/dxos/tree/main/packages/plugins/experimental/plugin-explorer',\n tags: ['experimental'],\n screenshots: ['https://dxos.network/plugin-details-scripts-dark.png'],\n} satisfies PluginMeta;\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAMO,IAAMA,gBAAgB;AAEtB,IAAMC,OAAO;EAClBC,IAAIF;EACJG,MAAM;EACNC,aACE;EACFC,MAAM;EACNC,QAAQ;EACRC,MAAM;IAAC;;EACPC,aAAa;IAAC;;AAChB;",
6
+ "names": ["SCRIPT_PLUGIN", "meta", "id", "name", "description", "icon", "source", "tags", "screenshots"]
7
+ }
@@ -16,19 +16,19 @@ var __copyProps = (to, from, except, desc) => {
16
16
  return to;
17
17
  };
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var chunk_A2DI2G4D_exports = {};
20
- __export(chunk_A2DI2G4D_exports, {
19
+ var chunk_ALY3N6PW_exports = {};
20
+ __export(chunk_ALY3N6PW_exports, {
21
21
  ScriptCapabilities: () => ScriptCapabilities
22
22
  });
23
- module.exports = __toCommonJS(chunk_A2DI2G4D_exports);
24
- var import_chunk_EFTZN5X7 = require("./chunk-EFTZN5X7.cjs");
23
+ module.exports = __toCommonJS(chunk_ALY3N6PW_exports);
24
+ var import_chunk_5UH3F7TA = require("./chunk-5UH3F7TA.cjs");
25
25
  var import_app_framework = require("@dxos/app-framework");
26
26
  var ScriptCapabilities;
27
27
  (function(ScriptCapabilities2) {
28
- ScriptCapabilities2.Compiler = (0, import_app_framework.defineCapability)(`${import_chunk_EFTZN5X7.SCRIPT_PLUGIN}/capability/compiler`);
28
+ ScriptCapabilities2.Compiler = (0, import_app_framework.defineCapability)(`${import_chunk_5UH3F7TA.SCRIPT_PLUGIN}/capability/compiler`);
29
29
  })(ScriptCapabilities || (ScriptCapabilities = {}));
30
30
  // Annotate the CommonJS export names for ESM import in node:
31
31
  0 && (module.exports = {
32
32
  ScriptCapabilities
33
33
  });
34
- //# sourceMappingURL=chunk-A2DI2G4D.cjs.map
34
+ //# sourceMappingURL=chunk-ALY3N6PW.cjs.map
@@ -16,13 +16,13 @@ var __copyProps = (to, from, except, desc) => {
16
16
  return to;
17
17
  };
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var chunk_6VKZJ4MH_exports = {};
20
- __export(chunk_6VKZJ4MH_exports, {
19
+ var chunk_DJGLGRQV_exports = {};
20
+ __export(chunk_DJGLGRQV_exports, {
21
21
  ScriptAction: () => ScriptAction,
22
22
  ScriptSettingsSchema: () => ScriptSettingsSchema
23
23
  });
24
- module.exports = __toCommonJS(chunk_6VKZJ4MH_exports);
25
- var import_chunk_EFTZN5X7 = require("./chunk-EFTZN5X7.cjs");
24
+ module.exports = __toCommonJS(chunk_DJGLGRQV_exports);
25
+ var import_chunk_5UH3F7TA = require("./chunk-5UH3F7TA.cjs");
26
26
  var import_AST = require("@effect/schema/AST");
27
27
  var import_echo = require("@dxos/client/echo");
28
28
  var import_echo_schema = require("@dxos/echo-schema");
@@ -30,7 +30,7 @@ var import_functions = require("@dxos/functions");
30
30
  var import_react_ui_editor = require("@dxos/react-ui-editor");
31
31
  var ScriptAction;
32
32
  (function(ScriptAction2) {
33
- const SCRIPT_ACTION = `${import_chunk_EFTZN5X7.SCRIPT_PLUGIN}/action`;
33
+ const SCRIPT_ACTION = `${import_chunk_5UH3F7TA.SCRIPT_PLUGIN}/action`;
34
34
  ScriptAction2.CreateScriptSchema = import_echo_schema.S.Struct({
35
35
  name: import_echo_schema.S.optional(import_echo_schema.S.String),
36
36
  // TODO(wittjosiah): Placeholder annotation?
@@ -57,4 +57,4 @@ var ScriptSettingsSchema = import_echo_schema.S.mutable(import_echo_schema.S.Str
57
57
  ScriptAction,
58
58
  ScriptSettingsSchema
59
59
  });
60
- //# sourceMappingURL=chunk-6VKZJ4MH.cjs.map
60
+ //# sourceMappingURL=chunk-DJGLGRQV.cjs.map
@@ -16,16 +16,18 @@ var __copyProps = (to, from, except, desc) => {
16
16
  return to;
17
17
  };
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var chunk_TJ4BTPOS_exports = {};
20
- __export(chunk_TJ4BTPOS_exports, {
19
+ var chunk_FGJJPY2L_exports = {};
20
+ __export(chunk_FGJJPY2L_exports, {
21
21
  templates: () => templates
22
22
  });
23
- module.exports = __toCommonJS(chunk_TJ4BTPOS_exports);
23
+ module.exports = __toCommonJS(chunk_FGJJPY2L_exports);
24
24
  var chat_default = "//\n// Copyright 2024 DXOS.org\n//\n\n// @ts-ignore\nimport { transformServerSentEvents } from 'https://esm.sh/@dxos/script-toolbox';\n\n/**\n * Chatbot that answers questions based on the context data.\n */\nexport default async ({\n event: {\n data: { request },\n },\n context: { space, ai },\n}: any) => {\n const textBody = await request.text();\n let parsedRequest: any;\n try {\n parsedRequest = JSON.parse(textBody);\n } catch (err) {\n const answer = await ai.run('@cf/meta/llama-3.1-8b-instruct', {\n stream: true,\n prompt: `\n Using only the context data below to answer the user's question.\n If you cannot answer the question from the provided content, then reply with \"I don't know.\"\n\n CONTEXT:\n ${await getContext({ space })}\n\n QUESTION:\n ${textBody}\n `,\n });\n return new Response(transformServerSentEvents(answer));\n }\n\n const promptId = parsedRequest.trigger.promptId;\n const promptObject = await space.crud.query({ id: promptId }).first();\n\n if (parsedRequest.data.objects.length !== 1) {\n return new Response('Message batches not supported.');\n }\n\n const messageId = parsedRequest.data.objects[0];\n let message;\n try {\n message = await space.crud.query({ id: messageId }).first();\n } catch (err) {\n return new Response('Message not replicated yet.', { status: 409 });\n }\n\n if (message.text.includes('--------')) {\n return new Response('Message was already processed.');\n }\n\n let prompt = promptObject.template;\n for (const input of promptObject.inputs) {\n let value: string | null = null;\n if (input.type === ChainInputType.VALUE) {\n value = String(input.value);\n } else if (input.type === ChainInputType.RETRIEVER) {\n value = await getContext({ space });\n } else if (input.type === ChainInputType.PASS_THROUGH) {\n value = message.text;\n }\n if (value) {\n prompt = prompt.replaceAll(`{${input.name}}`, value);\n }\n }\n\n const answer = await ai.run('@cf/meta/llama-3.1-8b-instruct', {\n stream: false,\n prompt,\n });\n const response = { response: answer.response, prompt, message };\n const textWithAnswer = message.text + '\\n--------\\n\\n' + answer.response;\n await space.crud.update({ id: messageId }, { text: textWithAnswer });\n\n return new Response(JSON.stringify(response));\n};\n\nconst getContext = async ({ space }: any) => {\n let context = '';\n const { objects: docs } = await space.crud.query({ __typename: 'dxos.org/type/Document' }).run();\n for (const doc of docs) {\n const { content } = await space.crud.query({ id: doc.content }).first();\n context += content + '\\n\\n';\n }\n return context;\n};\n\nenum ChainInputType {\n VALUE = 0,\n PASS_THROUGH = 1,\n RETRIEVER = 2,\n FUNCTION = 3,\n QUERY = 4,\n RESOLVER = 5,\n CONTEXT = 6,\n SCHEMA = 7,\n}\n";
25
25
  var chess_default = "//\n// Copyright 2024 DXOS.org\n//\n\n// @ts-ignore\nimport { Chess } from 'https://esm.sh/chess.js@0.13.1';\n\n/**\n * Plays a random move in a chess game.\n */\nexport default async ({\n event: {\n data: { request },\n },\n context: { space },\n}: any) => {\n const {\n data: {\n objects: [gameId],\n player = 'b',\n },\n } = await request.json();\n\n const { pgn } = await space.crud.query({ id: gameId }).first();\n const game = new Chess();\n game.load_pgn(pgn);\n if (game.turn() !== player) {\n return new Response('Invalid turn', { status: 409 });\n }\n\n const moves = game.moves();\n const move = moves[Math.floor(Math.random() * moves.length)];\n if (!move) {\n return new Response('No legal moves', { status: 406 });\n }\n\n game.move(move);\n const newPgn = game.pgn();\n await space.crud.update({ id: gameId }, { pgn: newPgn });\n return new Response(game.ascii());\n};\n";
26
- var echo_default = "//\n// Copyright 2024 DXOS.org\n//\n\n/**\n * Echos the request data.\n */\nexport default async ({\n event: {\n data: { request },\n },\n}: any) => {\n const data = await request.json();\n return new Response(JSON.stringify(data ?? {}), { headers: { 'Content-Type': 'application/json' } });\n};\n";
26
+ var discord_default = "//\n// Copyright 2025 DXOS.org\n//\n\n// @ts-ignore\nimport { createStatic, EchoObject, defineFunction, DXN, Filter, ObjectId, S } from 'dxos:functions';\nimport {\n FetchHttpClient,\n // @ts-ignore\n} from 'https://esm.sh/@effect/platform@0.77.2?deps=effect@3.13.3';\n// @ts-ignore\nimport { DiscordConfig, DiscordREST, DiscordRESTMemoryLive } from 'https://esm.sh/dfx@0.113.0?deps=effect@3.13.3';\n// @ts-ignore\nimport { Effect, Config, Redacted } from 'https://esm.sh/effect@3.13.3';\n\nconst MessageSchema = S.Struct({\n id: S.String,\n foreignId: S.Number,\n content: S.String,\n}).pipe(EchoObject('example.com/type/Message', '0.1.0'));\n\nexport default defineFunction({\n inputSchema: S.Struct({\n channelId: S.String,\n queueId: S.String,\n pageSize: S.optional(S.Number),\n }),\n\n outputSchema: S.Struct({\n newMessages: S.Number,\n }),\n\n handler: ({\n event: {\n data: { channelId, queueId, pageSize = 5 },\n },\n context: { space },\n }: any) =>\n Effect.gen(function* () {\n const { token } = yield* Effect.tryPromise(() =>\n space.db.query(Filter.typename('dxos.org/type/AccessToken', { source: 'discord.com' })).first(),\n );\n\n const enqueueMessages = Effect.gen(function* () {\n const rest = yield* DiscordREST;\n const { objects } = yield* Effect.tryPromise(() => space.queues.queryQueue(DXN.parse(queueId)));\n\n let newMessages = 0;\n let lastMessage = objects.at(-1);\n while (true) {\n // NOTE: If `after` is specified, the specified message is included in the results.\n const messages = yield* rest\n .getChannelMessages(channelId, { after: lastMessage?.foreignId, limit: pageSize })\n .pipe((res: any) => res.json);\n if (messages.length === 1) {\n break;\n }\n const queueMessages = messages\n .map((message: any) =>\n createStatic(MessageSchema, {\n id: ObjectId.random(),\n foreignId: parseInt(message.id),\n content: message.content,\n }),\n )\n .slice(lastMessage ? 1 : 0)\n .toReversed();\n yield* Effect.tryPromise(() => space.queues.insertIntoQueue(DXN.parse(queueId), queueMessages));\n newMessages += queueMessages.length;\n lastMessage = queueMessages.at(-1);\n }\n\n return { newMessages };\n }).pipe(\n Effect.provide(DiscordRESTMemoryLive),\n Effect.provide(\n DiscordConfig.layerConfig({\n token: Config.succeed(Redacted.make(token)),\n }),\n ),\n Effect.provide(FetchHttpClient.layer),\n );\n\n return yield* enqueueMessages;\n }),\n});\n";
27
+ var echo_default = "//\n// Copyright 2024 DXOS.org\n//\n\n/**\n * Echos the request data.\n */\nexport default async ({\n event: {\n data: { request },\n },\n}: any) => {\n const data = await request.json();\n return new Response(JSON.stringify(data ?? {}), {\n headers: {\n 'Content-Type': 'application/json',\n },\n });\n};\n";
27
28
  var email_default = "//\n// Copyright 2024 DXOS.org\n//\n\n/**\n * Appends a message to the end of a Document configured through a trigger.\n * Trigger must have a targetDocumentId field set in Meta.\n */\nexport default async ({\n event: {\n data: { request },\n },\n context: { space },\n}: any) => {\n const { data, trigger } = (await request.json()) as RequestPayload;\n\n const documentId = trigger.meta.targetDocumentId;\n const document = await space.db.query({ id: documentId }, { format: 'plain' }).first();\n\n const contentId = document.content['/'].split(':')[3];\n const documentContent = await space.db.query({ id: contentId }, { format: 'plain' }).first();\n const modifiedContent = [\n documentContent.content,\n '',\n '---',\n `**From:** ${data.from}`,\n `**Subject:** ${data.subject}`,\n `**Date:** ${data.created}`,\n '',\n data.body,\n ].join('\\n');\n\n await space.db.update({ id: contentId }, { content: modifiedContent });\n\n return new Response(JSON.stringify({ success: true }));\n};\n\ntype RequestPayload = {\n data: { from: string; subject: string; created: string; body: string };\n trigger: { meta: { targetDocumentId: string } };\n};\n";
28
- var forex_default = "//\n// Copyright 2024 DXOS.org\n//\n\n/**\n * Returns the exchange rate between two currencies.\n */\nexport default async ({\n event: {\n data: { request },\n },\n}: any) => {\n const { args: [from = 'EUR', to = 'USD'] = [] } = await request.json();\n\n const res = await fetch(`https://free.ratesdb.com/v1/rates?from=${from}&to=${to}`);\n const {\n data: { rates },\n } = await res.json();\n\n return new Response(rates[to].toString());\n};\n";
29
+ var forex_effect_default = "//\n// Copyright 2025 DXOS.org\n//\n\n// @ts-ignore\nimport { defineFunction, S } from 'dxos:functions';\nimport {\n HttpClient,\n HttpClientRequest,\n FetchHttpClient,\n // @ts-ignore\n} from 'https://esm.sh/@effect/platform@0.77.2?deps=effect@3.13.3';\n// @ts-ignore\nimport { Effect, Schedule } from 'https://esm.sh/effect@3.13.3';\n\n/**\n * Returns the exchange rate between two currencies.\n */\nexport default defineFunction({\n inputSchema: S.Struct({\n from: S.String.annotations({ description: 'The source currency' }),\n to: S.String.annotations({ description: 'The target currency' }),\n }),\n\n outputSchema: S.Struct({\n rate: S.Number,\n }),\n\n handler: async ({\n event: {\n data: { from, to },\n },\n }: any) =>\n Effect.gen(function* () {\n const res = yield* HttpClientRequest.get(`https://free.ratesdb.com/v1/rates?from=${from}&to=${to}`).pipe(\n HttpClient.execute,\n Effect.flatMap((res: any) => res.json),\n Effect.timeout('1 second'),\n Effect.retry(Schedule.exponential(1000).pipe(Schedule.compose(Schedule.recurs(3)))),\n Effect.scoped,\n );\n return { rate: res.data.rates[to].toString() };\n }).pipe(Effect.provide(FetchHttpClient.layer)),\n});\n";
30
+ var forex_default = "//\n// Copyright 2025 DXOS.org\n//\n\n// @ts-ignore\nimport { defineFunction, S } from 'dxos:functions';\n\n/**\n * Returns the exchange rate between two currencies.\n */\nexport default defineFunction({\n inputSchema: S.Struct({\n from: S.String.annotations({ description: 'The source currency' }),\n to: S.String.annotations({ description: 'The target currency' }),\n }),\n\n handler: async ({\n event: {\n data: { from, to },\n },\n }: any) => {\n const res = await fetch(`https://free.ratesdb.com/v1/rates?from=${from}&to=${to}`);\n const {\n data: { rates },\n } = await res.json();\n\n return rates[to].toString();\n },\n});\n";
29
31
  var removeHeader = (str) => str.split("\n").slice(4).join("\n");
30
32
  var templates = [
31
33
  {
@@ -38,6 +40,11 @@ var templates = [
38
40
  name: "Forex",
39
41
  source: removeHeader(forex_default)
40
42
  },
43
+ {
44
+ id: "dxos.org/script/forex-effect",
45
+ name: "Forex (Effect)",
46
+ source: removeHeader(forex_effect_default)
47
+ },
41
48
  {
42
49
  id: "dxos.org/script/gpt",
43
50
  name: "Gpt",
@@ -55,10 +62,16 @@ var templates = [
55
62
  name: "Email",
56
63
  source: removeHeader(email_default),
57
64
  presetId: "dxos.org/function/email"
65
+ },
66
+ {
67
+ id: "dxos.org/script/discord",
68
+ name: "Discord",
69
+ source: removeHeader(discord_default),
70
+ presetId: "dxos.org/function/discord"
58
71
  }
59
72
  ];
60
73
  // Annotate the CommonJS export names for ESM import in node:
61
74
  0 && (module.exports = {
62
75
  templates
63
76
  });
64
- //# sourceMappingURL=chunk-TJ4BTPOS.cjs.map
77
+ //# sourceMappingURL=chunk-FGJJPY2L.cjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["raw-loader:./chat.ts?raw", "raw-loader:./chess.ts?raw", "raw-loader:./discord.ts?raw", "raw-loader:./echo.ts?raw", "raw-loader:./email.ts?raw", "raw-loader:./forex-effect.ts?raw", "raw-loader:./forex.ts?raw", "../../../src/templates/index.ts"],
4
+ "sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\n// @ts-ignore\nimport { transformServerSentEvents } from 'https://esm.sh/@dxos/script-toolbox';\n\n/**\n * Chatbot that answers questions based on the context data.\n */\nexport default async ({\n event: {\n data: { request },\n },\n context: { space, ai },\n}: any) => {\n const textBody = await request.text();\n let parsedRequest: any;\n try {\n parsedRequest = JSON.parse(textBody);\n } catch (err) {\n const answer = await ai.run('@cf/meta/llama-3.1-8b-instruct', {\n stream: true,\n prompt: `\n Using only the context data below to answer the user's question.\n If you cannot answer the question from the provided content, then reply with \"I don't know.\"\n\n CONTEXT:\n ${await getContext({ space })}\n\n QUESTION:\n ${textBody}\n `,\n });\n return new Response(transformServerSentEvents(answer));\n }\n\n const promptId = parsedRequest.trigger.promptId;\n const promptObject = await space.crud.query({ id: promptId }).first();\n\n if (parsedRequest.data.objects.length !== 1) {\n return new Response('Message batches not supported.');\n }\n\n const messageId = parsedRequest.data.objects[0];\n let message;\n try {\n message = await space.crud.query({ id: messageId }).first();\n } catch (err) {\n return new Response('Message not replicated yet.', { status: 409 });\n }\n\n if (message.text.includes('--------')) {\n return new Response('Message was already processed.');\n }\n\n let prompt = promptObject.template;\n for (const input of promptObject.inputs) {\n let value: string | null = null;\n if (input.type === ChainInputType.VALUE) {\n value = String(input.value);\n } else if (input.type === ChainInputType.RETRIEVER) {\n value = await getContext({ space });\n } else if (input.type === ChainInputType.PASS_THROUGH) {\n value = message.text;\n }\n if (value) {\n prompt = prompt.replaceAll(`{${input.name}}`, value);\n }\n }\n\n const answer = await ai.run('@cf/meta/llama-3.1-8b-instruct', {\n stream: false,\n prompt,\n });\n const response = { response: answer.response, prompt, message };\n const textWithAnswer = message.text + '\\n--------\\n\\n' + answer.response;\n await space.crud.update({ id: messageId }, { text: textWithAnswer });\n\n return new Response(JSON.stringify(response));\n};\n\nconst getContext = async ({ space }: any) => {\n let context = '';\n const { objects: docs } = await space.crud.query({ __typename: 'dxos.org/type/Document' }).run();\n for (const doc of docs) {\n const { content } = await space.crud.query({ id: doc.content }).first();\n context += content + '\\n\\n';\n }\n return context;\n};\n\nenum ChainInputType {\n VALUE = 0,\n PASS_THROUGH = 1,\n RETRIEVER = 2,\n FUNCTION = 3,\n QUERY = 4,\n RESOLVER = 5,\n CONTEXT = 6,\n SCHEMA = 7,\n}\n", "//\n// Copyright 2024 DXOS.org\n//\n\n// @ts-ignore\nimport { Chess } from 'https://esm.sh/chess.js@0.13.1';\n\n/**\n * Plays a random move in a chess game.\n */\nexport default async ({\n event: {\n data: { request },\n },\n context: { space },\n}: any) => {\n const {\n data: {\n objects: [gameId],\n player = 'b',\n },\n } = await request.json();\n\n const { pgn } = await space.crud.query({ id: gameId }).first();\n const game = new Chess();\n game.load_pgn(pgn);\n if (game.turn() !== player) {\n return new Response('Invalid turn', { status: 409 });\n }\n\n const moves = game.moves();\n const move = moves[Math.floor(Math.random() * moves.length)];\n if (!move) {\n return new Response('No legal moves', { status: 406 });\n }\n\n game.move(move);\n const newPgn = game.pgn();\n await space.crud.update({ id: gameId }, { pgn: newPgn });\n return new Response(game.ascii());\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\n// @ts-ignore\nimport { createStatic, EchoObject, defineFunction, DXN, Filter, ObjectId, S } from 'dxos:functions';\nimport {\n FetchHttpClient,\n // @ts-ignore\n} from 'https://esm.sh/@effect/platform@0.77.2?deps=effect@3.13.3';\n// @ts-ignore\nimport { DiscordConfig, DiscordREST, DiscordRESTMemoryLive } from 'https://esm.sh/dfx@0.113.0?deps=effect@3.13.3';\n// @ts-ignore\nimport { Effect, Config, Redacted } from 'https://esm.sh/effect@3.13.3';\n\nconst MessageSchema = S.Struct({\n id: S.String,\n foreignId: S.Number,\n content: S.String,\n}).pipe(EchoObject('example.com/type/Message', '0.1.0'));\n\nexport default defineFunction({\n inputSchema: S.Struct({\n channelId: S.String,\n queueId: S.String,\n pageSize: S.optional(S.Number),\n }),\n\n outputSchema: S.Struct({\n newMessages: S.Number,\n }),\n\n handler: ({\n event: {\n data: { channelId, queueId, pageSize = 5 },\n },\n context: { space },\n }: any) =>\n Effect.gen(function* () {\n const { token } = yield* Effect.tryPromise(() =>\n space.db.query(Filter.typename('dxos.org/type/AccessToken', { source: 'discord.com' })).first(),\n );\n\n const enqueueMessages = Effect.gen(function* () {\n const rest = yield* DiscordREST;\n const { objects } = yield* Effect.tryPromise(() => space.queues.queryQueue(DXN.parse(queueId)));\n\n let newMessages = 0;\n let lastMessage = objects.at(-1);\n while (true) {\n // NOTE: If `after` is specified, the specified message is included in the results.\n const messages = yield* rest\n .getChannelMessages(channelId, { after: lastMessage?.foreignId, limit: pageSize })\n .pipe((res: any) => res.json);\n if (messages.length === 1) {\n break;\n }\n const queueMessages = messages\n .map((message: any) =>\n createStatic(MessageSchema, {\n id: ObjectId.random(),\n foreignId: parseInt(message.id),\n content: message.content,\n }),\n )\n .slice(lastMessage ? 1 : 0)\n .toReversed();\n yield* Effect.tryPromise(() => space.queues.insertIntoQueue(DXN.parse(queueId), queueMessages));\n newMessages += queueMessages.length;\n lastMessage = queueMessages.at(-1);\n }\n\n return { newMessages };\n }).pipe(\n Effect.provide(DiscordRESTMemoryLive),\n Effect.provide(\n DiscordConfig.layerConfig({\n token: Config.succeed(Redacted.make(token)),\n }),\n ),\n Effect.provide(FetchHttpClient.layer),\n );\n\n return yield* enqueueMessages;\n }),\n});\n", "//\n// Copyright 2024 DXOS.org\n//\n\n/**\n * Echos the request data.\n */\nexport default async ({\n event: {\n data: { request },\n },\n}: any) => {\n const data = await request.json();\n return new Response(JSON.stringify(data ?? {}), {\n headers: {\n 'Content-Type': 'application/json',\n },\n });\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\n/**\n * Appends a message to the end of a Document configured through a trigger.\n * Trigger must have a targetDocumentId field set in Meta.\n */\nexport default async ({\n event: {\n data: { request },\n },\n context: { space },\n}: any) => {\n const { data, trigger } = (await request.json()) as RequestPayload;\n\n const documentId = trigger.meta.targetDocumentId;\n const document = await space.db.query({ id: documentId }, { format: 'plain' }).first();\n\n const contentId = document.content['/'].split(':')[3];\n const documentContent = await space.db.query({ id: contentId }, { format: 'plain' }).first();\n const modifiedContent = [\n documentContent.content,\n '',\n '---',\n `**From:** ${data.from}`,\n `**Subject:** ${data.subject}`,\n `**Date:** ${data.created}`,\n '',\n data.body,\n ].join('\\n');\n\n await space.db.update({ id: contentId }, { content: modifiedContent });\n\n return new Response(JSON.stringify({ success: true }));\n};\n\ntype RequestPayload = {\n data: { from: string; subject: string; created: string; body: string };\n trigger: { meta: { targetDocumentId: string } };\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\n// @ts-ignore\nimport { defineFunction, S } from 'dxos:functions';\nimport {\n HttpClient,\n HttpClientRequest,\n FetchHttpClient,\n // @ts-ignore\n} from 'https://esm.sh/@effect/platform@0.77.2?deps=effect@3.13.3';\n// @ts-ignore\nimport { Effect, Schedule } from 'https://esm.sh/effect@3.13.3';\n\n/**\n * Returns the exchange rate between two currencies.\n */\nexport default defineFunction({\n inputSchema: S.Struct({\n from: S.String.annotations({ description: 'The source currency' }),\n to: S.String.annotations({ description: 'The target currency' }),\n }),\n\n outputSchema: S.Struct({\n rate: S.Number,\n }),\n\n handler: async ({\n event: {\n data: { from, to },\n },\n }: any) =>\n Effect.gen(function* () {\n const res = yield* HttpClientRequest.get(`https://free.ratesdb.com/v1/rates?from=${from}&to=${to}`).pipe(\n HttpClient.execute,\n Effect.flatMap((res: any) => res.json),\n Effect.timeout('1 second'),\n Effect.retry(Schedule.exponential(1000).pipe(Schedule.compose(Schedule.recurs(3)))),\n Effect.scoped,\n );\n return { rate: res.data.rates[to].toString() };\n }).pipe(Effect.provide(FetchHttpClient.layer)),\n});\n", "//\n// Copyright 2025 DXOS.org\n//\n\n// @ts-ignore\nimport { defineFunction, S } from 'dxos:functions';\n\n/**\n * Returns the exchange rate between two currencies.\n */\nexport default defineFunction({\n inputSchema: S.Struct({\n from: S.String.annotations({ description: 'The source currency' }),\n to: S.String.annotations({ description: 'The target currency' }),\n }),\n\n handler: async ({\n event: {\n data: { from, to },\n },\n }: any) => {\n const res = await fetch(`https://free.ratesdb.com/v1/rates?from=${from}&to=${to}`);\n const {\n data: { rates },\n } = await res.json();\n\n return rates[to].toString();\n },\n});\n", "//\n// Copyright 2024 DXOS.org\n//\n\n// @ts-ignore\nimport chat from './chat.ts?raw';\n// @ts-ignore\nimport chess from './chess.ts?raw';\n// @ts-ignore\nimport discord from './discord.ts?raw';\n// @ts-ignore\nimport echo from './echo.ts?raw';\n// @ts-ignore\nimport email from './email.ts?raw';\n// @ts-ignore\nimport forexEffect from './forex-effect.ts?raw';\n// @ts-ignore\nimport forex from './forex.ts?raw';\n\nconst removeHeader = (str: string) => str.split('\\n').slice(4).join('\\n');\n\nexport type Template = {\n id: string;\n name: string;\n source: string;\n presetId?: string;\n};\n\nexport const templates: Template[] = [\n {\n id: 'dxos.org/script/echo',\n name: 'Echo',\n source: removeHeader(echo),\n },\n {\n id: 'dxos.org/script/forex',\n name: 'Forex',\n source: removeHeader(forex),\n },\n {\n id: 'dxos.org/script/forex-effect',\n name: 'Forex (Effect)',\n source: removeHeader(forexEffect),\n },\n {\n id: 'dxos.org/script/gpt',\n name: 'Gpt',\n source: removeHeader(chat),\n presetId: 'dxos.org/function/gpt',\n },\n {\n id: 'dxos.org/script/chess',\n name: 'Chess',\n source: removeHeader(chess),\n presetId: 'dxos.org/function/chess',\n },\n {\n id: 'dxos.org/script/email',\n name: 'Email',\n source: removeHeader(email),\n presetId: 'dxos.org/function/email',\n },\n {\n id: 'dxos.org/script/discord',\n name: 'Discord',\n source: removeHeader(discord),\n presetId: 'dxos.org/function/discord',\n },\n];\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAA,eAAA;ACAA,IAAA,gBAAA;ACAA,IAAA,kBAAA;ACAA,IAAA,eAAA;ACAA,IAAA,gBAAA;ACAA,IAAA,uBAAA;ACAA,IAAA,gBAAA;ACmBA,IAAMA,eAAe,CAACC,QAAgBA,IAAIC,MAAM,IAAA,EAAMC,MAAM,CAAA,EAAGC,KAAK,IAAA;AAS7D,IAAMC,YAAwB;EACnC;IACEC,IAAI;IACJC,MAAM;IACNC,QAAQR,aAAaS,YAAAA;EACvB;EACA;IACEH,IAAI;IACJC,MAAM;IACNC,QAAQR,aAAaU,aAAAA;EACvB;EACA;IACEJ,IAAI;IACJC,MAAM;IACNC,QAAQR,aAAaW,oBAAAA;EACvB;EACA;IACEL,IAAI;IACJC,MAAM;IACNC,QAAQR,aAAaY,YAAAA;IACrBC,UAAU;EACZ;EACA;IACEP,IAAI;IACJC,MAAM;IACNC,QAAQR,aAAac,aAAAA;IACrBD,UAAU;EACZ;EACA;IACEP,IAAI;IACJC,MAAM;IACNC,QAAQR,aAAae,aAAAA;IACrBF,UAAU;EACZ;EACA;IACEP,IAAI;IACJC,MAAM;IACNC,QAAQR,aAAagB,eAAAA;IACrBH,UAAU;EACZ;;",
6
+ "names": ["removeHeader", "str", "split", "slice", "join", "templates", "id", "name", "source", "echo", "forex", "forexEffect", "chat", "presetId", "chess", "email", "discord"]
7
+ }
@@ -26,15 +26,15 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
26
26
  mod
27
27
  ));
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var chunk_5V3XGLTR_exports = {};
30
- __export(chunk_5V3XGLTR_exports, {
29
+ var chunk_HEDZVP6A_exports = {};
30
+ __export(chunk_HEDZVP6A_exports, {
31
31
  AutomationPanel: () => AutomationPanel,
32
32
  ScriptContainer: () => ScriptContainer,
33
33
  ScriptSettings: () => ScriptSettings,
34
34
  ScriptSettingsPanel: () => ScriptSettingsPanel
35
35
  });
36
- module.exports = __toCommonJS(chunk_5V3XGLTR_exports);
37
- var import_chunk_EFTZN5X7 = require("./chunk-EFTZN5X7.cjs");
36
+ module.exports = __toCommonJS(chunk_HEDZVP6A_exports);
37
+ var import_chunk_5UH3F7TA = require("./chunk-5UH3F7TA.cjs");
38
38
  var import_react = __toESM(require("react"));
39
39
  var import_react_client = require("@dxos/react-client");
40
40
  var import_react_ui = require("@dxos/react-ui");
@@ -51,7 +51,7 @@ var import_react_ui2 = require("@dxos/react-ui");
51
51
  var import_schema = require("@dxos/schema");
52
52
  var import_react3 = require("react");
53
53
  var ScriptSettings = ({ settings }) => {
54
- const { t } = (0, import_react_ui.useTranslation)(import_chunk_EFTZN5X7.SCRIPT_PLUGIN);
54
+ const { t } = (0, import_react_ui.useTranslation)(import_chunk_5UH3F7TA.SCRIPT_PLUGIN);
55
55
  const client = (0, import_react_client.useClient)();
56
56
  const handleAuthenticate = async () => {
57
57
  const { identityKey } = client.halo.identity.get();
@@ -74,7 +74,7 @@ var ScriptSettings = ({ settings }) => {
74
74
  }
75
75
  ]);
76
76
  };
77
- return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, /* @__PURE__ */ import_react.default.createElement(import_react_ui_form.DeprecatedFormInput, {
77
+ return /* @__PURE__ */ import_react.default.createElement(import_react_ui_form.DeprecatedFormContainer, null, /* @__PURE__ */ import_react.default.createElement(import_react_ui_form.DeprecatedFormInput, {
78
78
  label: t("authenticate action label")
79
79
  }, /* @__PURE__ */ import_react.default.createElement(import_react_ui.Button, {
80
80
  onClick: handleAuthenticate
@@ -95,7 +95,7 @@ var ScriptSettings = ({ settings }) => {
95
95
  var __dxlog_file = "/home/runner/work/dxos/dxos/packages/plugins/experimental/plugin-script/src/components/ScriptSettingsPanel.tsx";
96
96
  var kebabize = (str) => str.replace(/[A-Z]+(?![a-z])|[A-Z]/g, ($, ofs) => (ofs ? "-" : "") + $.toLowerCase());
97
97
  var ScriptSettingsPanel = ({ script }) => {
98
- const { t } = (0, import_react_ui2.useTranslation)(import_chunk_EFTZN5X7.SCRIPT_PLUGIN);
98
+ const { t } = (0, import_react_ui2.useTranslation)(import_chunk_5UH3F7TA.SCRIPT_PLUGIN);
99
99
  const { dispatchPromise: dispatch } = (0, import_app_framework.useIntentDispatcher)();
100
100
  const client = (0, import_react_client2.useClient)();
101
101
  const space = (0, import_echo.getSpace)(script);
@@ -138,7 +138,7 @@ var ScriptSettingsPanel = ({ script }) => {
138
138
  githubToken,
139
139
  gistKey
140
140
  ]);
141
- const [binding, setBinding] = (0, import_react_ui2.useControlledValue)(fn?.binding ?? "");
141
+ const [binding, setBinding] = (0, import_react_ui2.useControlledState)(fn?.binding ?? "");
142
142
  const handleBindingChange = (0, import_react2.useCallback)((event) => {
143
143
  setBinding(event.target.value);
144
144
  }, [
@@ -198,7 +198,19 @@ var ScriptSettingsPanel = ({ script }) => {
198
198
  script,
199
199
  githubToken
200
200
  ]);
201
- return /* @__PURE__ */ import_react2.default.createElement(import_react2.default.Fragment, null, fn && functionUrl && /* @__PURE__ */ import_react2.default.createElement(import_react2.default.Fragment, null, /* @__PURE__ */ import_react2.default.createElement(import_react_ui2.Separator, null), /* @__PURE__ */ import_react2.default.createElement("div", {
201
+ return /* @__PURE__ */ import_react2.default.createElement(import_react2.default.Fragment, null, /* @__PURE__ */ import_react2.default.createElement("div", {
202
+ role: "form",
203
+ className: "flex flex-col w-full p-2 gap-4"
204
+ }, /* @__PURE__ */ import_react2.default.createElement(import_react_ui2.Input.Root, null, /* @__PURE__ */ import_react2.default.createElement("div", {
205
+ role: "none",
206
+ className: "flex flex-col gap-1"
207
+ }, /* @__PURE__ */ import_react2.default.createElement(import_react_ui2.Input.Label, null, t("description label")), /* @__PURE__ */ import_react2.default.createElement(import_react_ui2.Input.TextInput, {
208
+ placeholder: t("description placeholder"),
209
+ value: script.description ?? "",
210
+ onChange: (event) => {
211
+ script.description = event.target.value;
212
+ }
213
+ })))), fn && functionUrl && /* @__PURE__ */ import_react2.default.createElement(import_react2.default.Fragment, null, /* @__PURE__ */ import_react2.default.createElement(import_react_ui2.Separator, null), /* @__PURE__ */ import_react2.default.createElement("div", {
202
214
  role: "form",
203
215
  className: "flex flex-col w-full p-2 gap-4"
204
216
  }, /* @__PURE__ */ import_react2.default.createElement("h2", null, t("remote function settings heading")), /* @__PURE__ */ import_react2.default.createElement(import_react_ui2.Input.Root, null, /* @__PURE__ */ import_react2.default.createElement("div", {
@@ -240,8 +252,8 @@ var ScriptSettingsPanel = ({ script }) => {
240
252
  onClick: handlePublish
241
253
  }, t(publishing ? "publishing label" : "publish label")))));
242
254
  };
243
- var AutomationPanel = (0, import_react3.lazy)(() => import("./AutomationPanel-EPRDDR3A.cjs"));
244
- var ScriptContainer = (0, import_react3.lazy)(() => import("./ScriptContainer-BV56I4OL.cjs"));
255
+ var AutomationPanel = (0, import_react3.lazy)(() => import("./AutomationPanel-4M55FURO.cjs"));
256
+ var ScriptContainer = (0, import_react3.lazy)(() => import("./ScriptContainer-M3PIEFIA.cjs"));
245
257
  // Annotate the CommonJS export names for ESM import in node:
246
258
  0 && (module.exports = {
247
259
  AutomationPanel,
@@ -249,4 +261,4 @@ var ScriptContainer = (0, import_react3.lazy)(() => import("./ScriptContainer-BV
249
261
  ScriptSettings,
250
262
  ScriptSettingsPanel
251
263
  });
252
- //# sourceMappingURL=chunk-5V3XGLTR.cjs.map
264
+ //# sourceMappingURL=chunk-HEDZVP6A.cjs.map