@dxos/plugin-script 0.7.5-labs.071a3e2 → 0.7.5-labs.401163d

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 (102) hide show
  1. package/dist/lib/browser/{ScriptContainer-LGW52UAJ.mjs → ScriptContainer-JHAVO2KA.mjs} +36 -11
  2. package/dist/lib/browser/ScriptContainer-JHAVO2KA.mjs.map +7 -0
  3. package/dist/lib/browser/artifact-YCIVHFSS.mjs +243 -0
  4. package/dist/lib/browser/artifact-YCIVHFSS.mjs.map +7 -0
  5. package/dist/lib/browser/{chunk-VIX22OMB.mjs → chunk-UDLKK74O.mjs} +13 -4
  6. package/dist/lib/browser/chunk-UDLKK74O.mjs.map +7 -0
  7. package/dist/lib/browser/{chunk-2UXYECEH.mjs → chunk-WAXHENSY.mjs} +4 -4
  8. package/dist/lib/browser/{chunk-2UXYECEH.mjs.map → chunk-WAXHENSY.mjs.map} +2 -2
  9. package/dist/lib/browser/{compiler-K3FNRDDN.mjs → compiler-YY2XSKHQ.mjs} +2 -4
  10. package/dist/lib/browser/compiler-YY2XSKHQ.mjs.map +7 -0
  11. package/dist/lib/browser/index.mjs +10 -10
  12. package/dist/lib/browser/index.mjs.map +3 -3
  13. package/dist/lib/browser/{intent-resolver-CMKQTLBG.mjs → intent-resolver-RV3YXIVN.mjs} +2 -2
  14. package/dist/lib/browser/meta.json +1 -1
  15. package/dist/lib/browser/{react-surface-XACNR5NR.mjs → react-surface-ETY4XKFG.mjs} +2 -2
  16. package/dist/lib/node/{ScriptContainer-UI2MDBYG.cjs → ScriptContainer-EBIT6CT4.cjs} +41 -14
  17. package/dist/lib/node/ScriptContainer-EBIT6CT4.cjs.map +7 -0
  18. package/dist/lib/node/artifact-IPGGY2Z2.cjs +262 -0
  19. package/dist/lib/node/artifact-IPGGY2Z2.cjs.map +7 -0
  20. package/dist/lib/node/{chunk-73345ZL6.cjs → chunk-3VDHZ54A.cjs} +6 -6
  21. package/dist/lib/node/{chunk-73345ZL6.cjs.map → chunk-3VDHZ54A.cjs.map} +2 -2
  22. package/dist/lib/node/{chunk-PKT5DD3O.cjs → chunk-JKPNBFU2.cjs} +12 -5
  23. package/dist/lib/node/chunk-JKPNBFU2.cjs.map +7 -0
  24. package/dist/lib/node/{compiler-P2HQB22H.cjs → compiler-UIBLKJKG.cjs} +6 -6
  25. package/dist/lib/node/compiler-UIBLKJKG.cjs.map +7 -0
  26. package/dist/lib/node/index.cjs +14 -13
  27. package/dist/lib/node/index.cjs.map +3 -3
  28. package/dist/lib/node/{intent-resolver-V5ASU5DW.cjs → intent-resolver-WFLQNAID.cjs} +6 -6
  29. package/dist/lib/node/meta.json +1 -1
  30. package/dist/lib/node/{react-surface-Y3RD5FW7.cjs → react-surface-OIQJFA7P.cjs} +9 -9
  31. package/dist/lib/node-esm/{ScriptContainer-F7SNP53Z.mjs → ScriptContainer-QVFTCAML.mjs} +36 -11
  32. package/dist/lib/node-esm/ScriptContainer-QVFTCAML.mjs.map +7 -0
  33. package/dist/lib/node-esm/artifact-7H4HGX5W.mjs +245 -0
  34. package/dist/lib/node-esm/artifact-7H4HGX5W.mjs.map +7 -0
  35. package/dist/lib/node-esm/{chunk-NBAL5DXN.mjs → chunk-5CEKSMA5.mjs} +13 -4
  36. package/dist/lib/node-esm/chunk-5CEKSMA5.mjs.map +7 -0
  37. package/dist/lib/node-esm/{chunk-PRGBYF4B.mjs → chunk-WCAUDRF4.mjs} +4 -4
  38. package/dist/lib/node-esm/{chunk-PRGBYF4B.mjs.map → chunk-WCAUDRF4.mjs.map} +2 -2
  39. package/dist/lib/node-esm/{compiler-PDN46H4Y.mjs → compiler-XTXFGZJM.mjs} +2 -4
  40. package/dist/lib/node-esm/compiler-XTXFGZJM.mjs.map +7 -0
  41. package/dist/lib/node-esm/index.mjs +10 -10
  42. package/dist/lib/node-esm/index.mjs.map +3 -3
  43. package/dist/lib/node-esm/{intent-resolver-75BHFRUK.mjs → intent-resolver-CYT6IYYH.mjs} +2 -2
  44. package/dist/lib/node-esm/meta.json +1 -1
  45. package/dist/lib/node-esm/{react-surface-PKUVZH4S.mjs → react-surface-N67GNKC2.mjs} +2 -2
  46. package/dist/types/src/ScriptPlugin.d.ts.map +1 -1
  47. package/dist/types/src/capabilities/artifact.d.ts +11 -0
  48. package/dist/types/src/capabilities/artifact.d.ts.map +1 -0
  49. package/dist/types/src/capabilities/index.d.ts +1 -0
  50. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  51. package/dist/types/src/components/FrameContainer/FrameContainer.d.ts +2 -2
  52. package/dist/types/src/components/FrameContainer/FrameContainer.d.ts.map +1 -1
  53. package/dist/types/src/hooks/deploy.d.ts.map +1 -1
  54. package/dist/types/src/index.d.ts +0 -1
  55. package/dist/types/src/index.d.ts.map +1 -1
  56. package/dist/types/src/templates/discord.d.ts +3 -0
  57. package/dist/types/src/templates/discord.d.ts.map +1 -0
  58. package/dist/types/src/templates/forex-effect.d.ts.map +1 -1
  59. package/dist/types/src/templates/index.d.ts.map +1 -1
  60. package/package.json +41 -42
  61. package/src/ScriptPlugin.tsx +6 -1
  62. package/src/capabilities/artifact.ts +219 -0
  63. package/src/capabilities/compiler.ts +1 -1
  64. package/src/capabilities/index.ts +1 -0
  65. package/src/components/FrameContainer/FrameContainer.tsx +4 -3
  66. package/src/components/ScriptSettingsPanel.tsx +2 -2
  67. package/src/components/TypescriptEditor/TypescriptEditor.tsx +2 -2
  68. package/src/hooks/deploy.ts +15 -4
  69. package/src/index.ts +0 -1
  70. package/src/templates/discord.ts +88 -0
  71. package/src/templates/forex-effect.ts +16 -14
  72. package/src/templates/index.ts +10 -2
  73. package/dist/lib/browser/ScriptContainer-LGW52UAJ.mjs.map +0 -7
  74. package/dist/lib/browser/chunk-SDHKTS6H.mjs +0 -237
  75. package/dist/lib/browser/chunk-SDHKTS6H.mjs.map +0 -7
  76. package/dist/lib/browser/chunk-VIX22OMB.mjs.map +0 -7
  77. package/dist/lib/browser/compiler-K3FNRDDN.mjs.map +0 -7
  78. package/dist/lib/node/ScriptContainer-UI2MDBYG.cjs.map +0 -7
  79. package/dist/lib/node/chunk-PKT5DD3O.cjs.map +0 -7
  80. package/dist/lib/node/chunk-T4TXCRN5.cjs +0 -260
  81. package/dist/lib/node/chunk-T4TXCRN5.cjs.map +0 -7
  82. package/dist/lib/node/compiler-P2HQB22H.cjs.map +0 -7
  83. package/dist/lib/node-esm/ScriptContainer-F7SNP53Z.mjs.map +0 -7
  84. package/dist/lib/node-esm/chunk-G76M6O46.mjs +0 -239
  85. package/dist/lib/node-esm/chunk-G76M6O46.mjs.map +0 -7
  86. package/dist/lib/node-esm/chunk-NBAL5DXN.mjs.map +0 -7
  87. package/dist/lib/node-esm/compiler-PDN46H4Y.mjs.map +0 -7
  88. package/dist/types/src/bundler/bundler.d.ts +0 -39
  89. package/dist/types/src/bundler/bundler.d.ts.map +0 -1
  90. package/dist/types/src/bundler/bundler.test.d.ts +0 -2
  91. package/dist/types/src/bundler/bundler.test.d.ts.map +0 -1
  92. package/dist/types/src/bundler/index.d.ts +0 -2
  93. package/dist/types/src/bundler/index.d.ts.map +0 -1
  94. package/src/bundler/bundler.test.ts +0 -55
  95. package/src/bundler/bundler.ts +0 -250
  96. package/src/bundler/index.ts +0 -5
  97. /package/dist/lib/browser/{intent-resolver-CMKQTLBG.mjs.map → intent-resolver-RV3YXIVN.mjs.map} +0 -0
  98. /package/dist/lib/browser/{react-surface-XACNR5NR.mjs.map → react-surface-ETY4XKFG.mjs.map} +0 -0
  99. /package/dist/lib/node/{intent-resolver-V5ASU5DW.cjs.map → intent-resolver-WFLQNAID.cjs.map} +0 -0
  100. /package/dist/lib/node/{react-surface-Y3RD5FW7.cjs.map → react-surface-OIQJFA7P.cjs.map} +0 -0
  101. /package/dist/lib/node-esm/{intent-resolver-75BHFRUK.mjs.map → intent-resolver-CYT6IYYH.mjs.map} +0 -0
  102. /package/dist/lib/node-esm/{react-surface-PKUVZH4S.mjs.map → react-surface-N67GNKC2.mjs.map} +0 -0
@@ -0,0 +1,245 @@
1
+ import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
2
+
3
+ // packages/plugins/experimental/plugin-script/src/capabilities/artifact.ts
4
+ import { Capabilities, contributes, createIntent } from "@dxos/app-framework";
5
+ import { defineArtifact, defineTool, ToolResult } from "@dxos/artifact";
6
+ import { createArtifactElement } from "@dxos/assistant";
7
+ import { ObjectId, S } from "@dxos/echo-schema";
8
+ import { ScriptType } from "@dxos/functions";
9
+ import { invariant } from "@dxos/invariant";
10
+ import { SpaceAction } from "@dxos/plugin-space/types";
11
+ import { create, makeRef } from "@dxos/react-client/echo";
12
+ import { TextType } from "@dxos/schema";
13
+ var __dxlog_file = "/home/runner/work/dxos/dxos/packages/plugins/experimental/plugin-script/src/capabilities/artifact.ts";
14
+ var artifact_default = () => {
15
+ const definition = defineArtifact({
16
+ id: "plugin-script",
17
+ // TODO(dmaretskyi): Since writing scripts requires a lot of domain knowledge,
18
+ // we should offload the work of synthesizing the code to a separate model.
19
+ // The main reasoning model will give it a concrete task and the script model will synthesize the code, knowing all the docs.
20
+ instructions: `
21
+ If the user explicitly requests you to write a script, you can create one.
22
+ If the user requests you to change one of the existing script, you can update it.
23
+ Scripts are short code pieces of executable code that can be used to perform computations, integrate with external systems, and perform automated tasks.
24
+ Each script must follow as strict shape for the definition but the body can contain any valid executable code.
25
+ Scripts are written in JavaScript or TypeScript.
26
+ Each script must define an input schema and output schema.
27
+ Each script must have its own detailed description.
28
+
29
+ Important: You cannot execute scripts. Scripts are only available as tools after the user deploys them. You must only call the available tools.
30
+
31
+ Description:
32
+ The description is a detailed description of the script.
33
+ It is used to describe the script's purpose, input, and output.
34
+ The description is used to generate the script's documentation.
35
+ The description is also goes into the script metadata.
36
+ The description is used by AI to understand the script and its purpose.
37
+ The description must provide cases on when the script should be used.
38
+
39
+ Schema:
40
+ The schema is defined using a schema-DSL library called Effect Schema.
41
+ The input schema describes the arguments that the script accepts.
42
+ The output schema describes the result that the script produces.
43
+ The schema is used to validate the script's input and output.
44
+ The schema is also goes into the script metadata.
45
+ The properties in the schema must have valid descriptions.
46
+ The input and output schemas must both be a struct of fields.
47
+
48
+ Restricts:
49
+ The scripts can only import code from "dxos:functions" module. No other modules are allowed.
50
+ Some web APIs are available - like fetch.
51
+
52
+ Reasoning:
53
+ Before writing a script, synthesize the following information:
54
+ - Description
55
+ - What APIs will be used.
56
+ - Detailed input schema
57
+ - Detailed output schema
58
+
59
+ <apis>
60
+ export function defineFunction(params: {
61
+ description: string,
62
+ inputSchema: S.Schema,
63
+ outputSchema: S.Schema,
64
+ handler: (params: { event: { data: TInput } }) => Promise<TOutput>
65
+ }): FunctionDefinition
66
+ /**
67
+ * Effect Schema
68
+ */
69
+ export const S;
70
+
71
+ // Examples:
72
+
73
+ S.String
74
+ S.Number
75
+ S.Boolean
76
+ S.Struct({
77
+ from: S.String.annotations({ description: 'The source currency' }),
78
+ to: S.String.annotations({ description: 'The target currency' }),
79
+ })
80
+ S.Array(S.String)
81
+ S.Union(S.String, S.Number)
82
+ S.optional(S.String)
83
+ S.String.annotations({ description: 'The source currency' })
84
+ </apis>
85
+
86
+ <handler_function>
87
+ Async function that takes the argument in the form of:
88
+
89
+ type HandlerFunctionParam = {
90
+ event: {
91
+ data: T // The input schema
92
+ },
93
+ }
94
+
95
+ The function must return the result that matches the output schema.
96
+ </handler_function>
97
+
98
+ <example>
99
+ import { defineFunction, S } from 'dxos:functions';
100
+
101
+ export default defineFunction({
102
+ description: 'Returns the exchange rate between two currencies.',
103
+
104
+ inputSchema: S.Struct({
105
+ from: S.String.annotations({ description: 'The source currency' }),
106
+ to: S.String.annotations({ description: 'The target currency' }),
107
+ }),
108
+
109
+ outputSchema: S.Struct({
110
+ rate: S.String.annotations({ description: 'The exchange rate' }),
111
+ }),
112
+
113
+ handler: async ({
114
+ event: {
115
+ data: { from, to },
116
+ },
117
+ }: any) => {
118
+ const res = await fetch(\`https://free.ratesdb.com/v1/rates?from=\${from}&to=\${to}\`);
119
+ const {
120
+ data: { rates },
121
+ } = await res.json();
122
+
123
+ return { rate: rates[to].toString() };
124
+ },
125
+ });
126
+ </example>
127
+ `,
128
+ schema: ScriptType,
129
+ tools: [
130
+ defineTool({
131
+ name: "script_new",
132
+ description: "Create a new script. Returns the artifact definition for the script",
133
+ schema: S.Struct({
134
+ name: S.String.annotations({
135
+ description: "The name of the script"
136
+ }),
137
+ code: S.String.annotations({
138
+ description: "The full code of the script in JavaScript or TypeScript. Must be valid executable code."
139
+ })
140
+ }),
141
+ execute: async ({ name, code }, { extensions }) => {
142
+ invariant(extensions?.space, "No space", {
143
+ F: __dxlog_file,
144
+ L: 149,
145
+ S: void 0,
146
+ A: [
147
+ "extensions?.space",
148
+ "'No space'"
149
+ ]
150
+ });
151
+ invariant(extensions?.dispatch, "No intent dispatcher", {
152
+ F: __dxlog_file,
153
+ L: 150,
154
+ S: void 0,
155
+ A: [
156
+ "extensions?.dispatch",
157
+ "'No intent dispatcher'"
158
+ ]
159
+ });
160
+ const script = create(ScriptType, {
161
+ name,
162
+ source: makeRef(create(TextType, {
163
+ content: code
164
+ }))
165
+ });
166
+ extensions.space.db.add(script);
167
+ await extensions.space.db.flush();
168
+ const intent = createIntent(SpaceAction.AddObject, {
169
+ target: extensions.space,
170
+ object: script
171
+ });
172
+ const { data, error } = await extensions.dispatch(intent);
173
+ if (!data || error) {
174
+ return ToolResult.Error(error?.message ?? "Failed to create chess game");
175
+ }
176
+ return ToolResult.Success(createArtifactElement(script.id));
177
+ }
178
+ }),
179
+ defineTool({
180
+ name: "script_inspect",
181
+ description: "Inspect a script. Returns the artifact definition for the script",
182
+ schema: S.Struct({
183
+ id: ObjectId
184
+ }),
185
+ execute: async ({ id }, { extensions }) => {
186
+ invariant(extensions?.space, "No space", {
187
+ F: __dxlog_file,
188
+ L: 178,
189
+ S: void 0,
190
+ A: [
191
+ "extensions?.space",
192
+ "'No space'"
193
+ ]
194
+ });
195
+ const script = await extensions.space.db.query({
196
+ id
197
+ }).first();
198
+ const { content } = await script.source.load();
199
+ return ToolResult.Success({
200
+ name: script.name,
201
+ code: content
202
+ });
203
+ }
204
+ }),
205
+ defineTool({
206
+ name: "script_update",
207
+ description: "Update a script. Returns the artifact definition for the script",
208
+ schema: S.Struct({
209
+ id: ObjectId,
210
+ code: S.String.annotations({
211
+ description: "The full code of the script in JavaScript or TypeScript. Must be valid executable code."
212
+ })
213
+ }),
214
+ execute: async ({ id, code }, { extensions }) => {
215
+ invariant(extensions?.space, "No space", {
216
+ F: __dxlog_file,
217
+ L: 199,
218
+ S: void 0,
219
+ A: [
220
+ "extensions?.space",
221
+ "'No space'"
222
+ ]
223
+ });
224
+ const script = await extensions.space.db.query({
225
+ id
226
+ }).first();
227
+ const source = await script.source.load();
228
+ if (!source) {
229
+ return ToolResult.Error("Script not found");
230
+ }
231
+ source.content = code;
232
+ await extensions.space?.db.flush();
233
+ return ToolResult.Success({
234
+ name: script.name
235
+ });
236
+ }
237
+ })
238
+ ]
239
+ });
240
+ return contributes(Capabilities.ArtifactDefinition, definition);
241
+ };
242
+ export {
243
+ artifact_default as default
244
+ };
245
+ //# sourceMappingURL=artifact-7H4HGX5W.mjs.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,SAASA,cAAcC,aAAaC,oBAAkD;AACtF,SAASC,gBAAgBC,YAAYC,kBAAkB;AACvD,SAASC,6BAA6B;AACtC,SAASC,UAAUC,SAAS;AAC5B,SAASC,kBAAkB;AAC3B,SAASC,iBAAiB;AAC1B,SAASC,mBAAmB;AAC5B,SAASC,QAAQC,eAA2B;AAC5C,SAASC,gBAAgB;;AAUzB,IAAA,mBAAe,MAAA;AACb,QAAMC,aAAaZ,eAAe;IAChCa,IAAI;;;;IAIJC,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IA4GdC,QAAQT;IACRU,OAAO;MACLf,WAAW;QACTgB,MAAM;QACNC,aAAa;QACbH,QAAQV,EAAEc,OAAO;UACfF,MAAMZ,EAAEe,OAAOC,YAAY;YAAEH,aAAa;UAAyB,CAAA;UACnEI,MAAMjB,EAAEe,OAAOC,YAAY;YACzBH,aAAa;UACf,CAAA;QACF,CAAA;QACAK,SAAS,OAAO,EAAEN,MAAMK,KAAI,GAAI,EAAEE,WAAU,MAAE;AAC5CjB,oBAAUiB,YAAYC,OAAO,YAAA;;;;;;;;;AAC7BlB,oBAAUiB,YAAYE,UAAU,wBAAA;;;;;;;;;AAChC,gBAAMC,SAASlB,OA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AU,MAAMH,WAAWC,MAAMK,GAAGY,MAAM;YAAE7B;UAAG,CAAA,EAAG8B,MAAK;AAC7D,gBAAMf,SAAS,MAAMD,OAAOC,OAAOgB,KAAI;AACvC,cAAI,CAAChB,QAAQ;AACX,mBAAO1B,WAAWqC,MAAM,kBAAA;UAC1B;AAEAX,iBAAOC,UAAUP;AACjB,gBAAME,WAAWC,OAAOK,GAAGE,MAAAA;AAE3B,iBAAO9B,WAAWuC,QAAQ;YACxBxB,MAAMU,OAAOV;UACf,CAAA;QACF;MACF,CAAA;;EAEJ,CAAA;AAEA,SAAOnB,YAAYD,aAAagD,oBAAoBjC,UAAAA;AACtD;",
6
+ "names": ["Capabilities", "contributes", "createIntent", "defineArtifact", "defineTool", "ToolResult", "createArtifactElement", "ObjectId", "S", "ScriptType", "invariant", "SpaceAction", "create", "makeRef", "TextType", "definition", "id", "instructions", "schema", "tools", "name", "description", "Struct", "String", "annotations", "code", "execute", "extensions", "space", "dispatch", "script", "source", "content", "db", "add", "flush", "intent", "AddObject", "target", "object", "data", "error", "Error", "message", "Success", "query", "first", "load", "ArtifactDefinition"]
7
+ }
@@ -6,18 +6,21 @@ var chat_default = "//\n// Copyright 2024 DXOS.org\n//\n\n// @ts-ignore\nimport
6
6
  // raw-loader:./chess.ts?raw
7
7
  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";
8
8
 
9
+ // raw-loader:./discord.ts?raw
10
+ 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 // TODO(wittjosiah): Remove. This is used to provide a terminal for a cron trigger.\n tick: S.optional(S.String),\n channelId: S.String,\n pageSize: S.optional(S.Number),\n queueId: S.String,\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";
11
+
9
12
  // raw-loader:./echo.ts?raw
10
13
  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";
11
14
 
12
15
  // raw-loader:./email.ts?raw
13
16
  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";
14
17
 
18
+ // raw-loader:./forex-effect.ts?raw
19
+ 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";
20
+
15
21
  // raw-loader:./forex.ts?raw
16
22
  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";
17
23
 
18
- // raw-loader:./forex-effect.ts?raw
19
- 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 HttpClientResponse,\n HttpClientError,\n // @ts-ignore\n} from 'https://esm.sh/@effect/platform@0.61.0?deps=effect@3.6.0';\n// @ts-ignore\nimport type { Cause } from 'https://esm.sh/effect@3.6.0';\n// @ts-ignore\nimport { Effect, Schedule } from 'https://esm.sh/effect@3.6.0';\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.String,\n\n handler: async ({\n event: {\n data: { from, to },\n },\n }: any) =>\n HttpClientRequest.get(`https://free.ratesdb.com/v1/rates?from=${from}&to=${to}`).pipe(\n HttpClient.fetchOk,\n HttpClientResponse.json,\n Effect.timeout('1 second'),\n Effect.retry(Schedule.exponential(1000).pipe(Schedule.compose(Schedule.recurs(3)))),\n Effect.map(({ data: { rates } }: any) => rates[to].toString()),\n ),\n});\n";
20
-
21
24
  // packages/plugins/experimental/plugin-script/src/templates/index.ts
22
25
  var removeHeader = (str) => str.split("\n").slice(4).join("\n");
23
26
  var templates = [
@@ -53,10 +56,16 @@ var templates = [
53
56
  name: "Email",
54
57
  source: removeHeader(email_default),
55
58
  presetId: "dxos.org/function/email"
59
+ },
60
+ {
61
+ id: "dxos.org/script/discord",
62
+ name: "Discord",
63
+ source: removeHeader(discord_default),
64
+ presetId: "dxos.org/function/discord"
56
65
  }
57
66
  ];
58
67
 
59
68
  export {
60
69
  templates
61
70
  };
62
- //# sourceMappingURL=chunk-NBAL5DXN.mjs.map
71
+ //# sourceMappingURL=chunk-5CEKSMA5.mjs.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 // TODO(wittjosiah): Remove. This is used to provide a terminal for a cron trigger.\n tick: S.optional(S.String),\n channelId: S.String,\n pageSize: S.optional(S.Number),\n queueId: S.String,\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;;;ACAA;;;ACAA;;;ACAA;;;ACAA;;;ACAA;;;ACAA;;;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
+ }
@@ -60,7 +60,7 @@ import { FunctionType, getInvocationUrl, getUserFunctionUrlInMetadata } from "@d
60
60
  import { log } from "@dxos/log";
61
61
  import { useClient as useClient2 } from "@dxos/react-client";
62
62
  import { Filter, getMeta, getSpace, useQuery } from "@dxos/react-client/echo";
63
- import { Button as Button2, Clipboard, Input, Separator, useControlledValue, useTranslation as useTranslation2 } from "@dxos/react-ui";
63
+ import { Button as Button2, Clipboard, Input, Separator, useControlledState, useTranslation as useTranslation2 } from "@dxos/react-ui";
64
64
  import { AccessTokenType } from "@dxos/schema";
65
65
  var __dxlog_file = "/home/runner/work/dxos/dxos/packages/plugins/experimental/plugin-script/src/components/ScriptSettingsPanel.tsx";
66
66
  var kebabize = (str) => str.replace(/[A-Z]+(?![a-z])|[A-Z]/g, ($, ofs) => (ofs ? "-" : "") + $.toLowerCase());
@@ -108,7 +108,7 @@ var ScriptSettingsPanel = ({ script }) => {
108
108
  githubToken,
109
109
  gistKey
110
110
  ]);
111
- const [binding, setBinding] = useControlledValue(fn?.binding ?? "");
111
+ const [binding, setBinding] = useControlledState(fn?.binding ?? "");
112
112
  const handleBindingChange = useCallback((event) => {
113
113
  setBinding(event.target.value);
114
114
  }, [
@@ -226,7 +226,7 @@ var ScriptSettingsPanel = ({ script }) => {
226
226
  // packages/plugins/experimental/plugin-script/src/components/index.ts
227
227
  import { lazy } from "react";
228
228
  var AutomationPanel = lazy(() => import("./AutomationPanel-W6SKG35R.mjs"));
229
- var ScriptContainer = lazy(() => import("./ScriptContainer-F7SNP53Z.mjs"));
229
+ var ScriptContainer = lazy(() => import("./ScriptContainer-QVFTCAML.mjs"));
230
230
 
231
231
  export {
232
232
  ScriptSettings,
@@ -234,4 +234,4 @@ export {
234
234
  AutomationPanel,
235
235
  ScriptContainer
236
236
  };
237
- //# sourceMappingURL=chunk-PRGBYF4B.mjs.map
237
+ //# sourceMappingURL=chunk-WCAUDRF4.mjs.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/ScriptSettings/ScriptSettings.tsx", "../../../src/components/ScriptSettingsPanel.tsx", "../../../src/components/index.ts"],
4
- "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport React from 'react';\n\nimport { type Credential } from '@dxos/protocols/proto/dxos/halo/credentials';\nimport { useClient } from '@dxos/react-client';\nimport { Button, Select, useTranslation } from '@dxos/react-ui';\nimport { type EditorInputMode, EditorInputModes } from '@dxos/react-ui-editor';\nimport { DeprecatedFormContainer, DeprecatedFormInput } from '@dxos/react-ui-form';\n\nimport { SCRIPT_PLUGIN } from '../../meta';\nimport { type ScriptSettingsProps } from '../../types';\n\nexport const ScriptSettings = ({ settings }: { settings: ScriptSettingsProps }) => {\n const { t } = useTranslation(SCRIPT_PLUGIN);\n const client = useClient();\n\n // TODO(burdon): Check token.\n const handleAuthenticate = async () => {\n const { identityKey } = client.halo.identity.get()!;\n await client.halo.writeCredentials([\n {\n issuer: identityKey,\n issuanceDate: new Date(),\n subject: {\n id: identityKey,\n assertion: {\n '@type': 'dxos.halo.credentials.ServiceAccess',\n serverName: 'hub.dxos.network',\n serverKey: identityKey,\n identityKey,\n capabilities: ['composer:beta'],\n },\n },\n } satisfies Credential,\n ]);\n };\n\n return (\n <DeprecatedFormContainer>\n {/* TODO(wittjosiah): Hide outside of dev environments. */}\n <DeprecatedFormInput label={t('authenticate action label')}>\n <Button onClick={handleAuthenticate}>{t('authenticate button label')}</Button>\n </DeprecatedFormInput>\n\n <DeprecatedFormInput label={t('editor input mode label')}>\n <Select.Root\n value={settings.editorInputMode ?? 'default'}\n onValueChange={(value) => {\n settings.editorInputMode = value as EditorInputMode;\n }}\n >\n <Select.TriggerButton placeholder={t('select editor input mode placeholder')} />\n <Select.Portal>\n <Select.Content>\n <Select.Viewport>\n {EditorInputModes.map((mode) => (\n <Select.Option key={mode} value={mode}>\n {t(`settings editor input mode ${mode} label`)}\n </Select.Option>\n ))}\n </Select.Viewport>\n </Select.Content>\n </Select.Portal>\n </Select.Root>\n </DeprecatedFormInput>\n </DeprecatedFormContainer>\n );\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { Octokit } from '@octokit/core';\nimport React, { type ChangeEvent, useCallback, useEffect, useState } from 'react';\n\nimport { createIntent, SettingsAction, useIntentDispatcher } from '@dxos/app-framework';\nimport { FunctionType, type ScriptType, getInvocationUrl, getUserFunctionUrlInMetadata } from '@dxos/functions';\nimport { log } from '@dxos/log';\nimport { useClient } from '@dxos/react-client';\nimport { Filter, getMeta, getSpace, useQuery } from '@dxos/react-client/echo';\nimport { Button, Clipboard, Input, Separator, useControlledValue, useTranslation } from '@dxos/react-ui';\nimport { AccessTokenType } from '@dxos/schema';\n\nimport { SCRIPT_PLUGIN } from '../meta';\n\n// TODO(wittjosiah): Factor out.\n// From https://stackoverflow.com/a/67243723/2804332\nconst kebabize = (str: string) => str.replace(/[A-Z]+(?![a-z])|[A-Z]/g, ($, ofs) => (ofs ? '-' : '') + $.toLowerCase());\n\nexport type ScriptSettingsPanelProps = {\n script: ScriptType;\n};\n\nexport const ScriptSettingsPanel = ({ script }: ScriptSettingsPanelProps) => {\n const { t } = useTranslation(SCRIPT_PLUGIN);\n const { dispatchPromise: dispatch } = useIntentDispatcher();\n const client = useClient();\n const space = getSpace(script);\n const [fn] = useQuery(space, Filter.schema(FunctionType, { source: script }));\n const [githubToken] = useQuery(space, Filter.schema(AccessTokenType, { source: 'github.com' }));\n const gistKey = getMeta(script).keys.find(({ source }) => source === 'github.com');\n const [gistUrl, setGistUrl] = useState<string | undefined>();\n\n useEffect(() => {\n const token = githubToken?.token;\n const gistId = gistKey?.id;\n if (!token || !gistId) {\n setGistUrl(undefined);\n return;\n }\n\n const timeout = setTimeout(async () => {\n try {\n const octokit = new Octokit({ auth: githubToken.token });\n const response = await octokit.request('GET /gists/{gist_id}', {\n gist_id: gistId,\n });\n setGistUrl(response.data.html_url);\n } catch (err) {\n log.catch(err);\n setGistUrl(undefined);\n }\n });\n\n return () => clearTimeout(timeout);\n }, [githubToken, gistKey]);\n\n const [binding, setBinding] = useControlledValue(fn?.binding ?? '');\n const handleBindingChange = useCallback(\n (event: ChangeEvent<HTMLInputElement>) => {\n setBinding(event.target.value);\n },\n [setBinding],\n );\n const handleBindingBlur = useCallback(() => {\n fn.binding = binding;\n }, [fn, binding]);\n\n const functionPath = fn && getUserFunctionUrlInMetadata(getMeta(fn));\n const functionUrl =\n functionPath &&\n getInvocationUrl(functionPath, client.config.values.runtime?.services?.edge?.url ?? '', {\n spaceId: space?.id,\n });\n\n const handleOpenTokenManager = useCallback(\n () => dispatch(createIntent(SettingsAction.Open, { plugin: 'dxos.org/plugin/token-manager' })),\n [],\n );\n\n const [publishing, setPublishing] = useState(false);\n const handlePublish = useCallback(async () => {\n setPublishing(true);\n const octokit = new Octokit({ auth: githubToken.token });\n const source = await script.source.load();\n const filename = script.name ? kebabize(script.name) : 'composer-script';\n const files = { [`${filename}.ts`]: { content: source.content } };\n\n try {\n // TODO(wittjosiah): Factor out to intent.\n const meta = getMeta(script);\n const githubKey = meta.keys.find(({ source }) => source === 'github.com');\n const gistId = githubKey?.id;\n if (gistId) {\n await octokit.request('PATCH /gists/{gist_id}', {\n gist_id: gistId,\n files,\n });\n } else {\n const response = await octokit.request('POST /gists', {\n public: true,\n files,\n });\n if (response.data.id) {\n meta.keys.push({ source: 'github.com', id: response.data.id });\n }\n }\n } finally {\n setPublishing(false);\n }\n }, [script, githubToken]);\n\n return (\n <>\n <div role='form' className='flex flex-col w-full p-2 gap-4'>\n <Input.Root>\n <div role='none' className='flex flex-col gap-1'>\n <Input.Label>{t('description label')}</Input.Label>\n <Input.TextInput\n placeholder={t('description placeholder')}\n value={script.description ?? ''}\n onChange={(event) => {\n script.description = event.target.value;\n }}\n />\n </div>\n </Input.Root>\n </div>\n {fn && functionUrl && (\n <>\n <Separator />\n <div role='form' className='flex flex-col w-full p-2 gap-4'>\n <h2>{t('remote function settings heading')}</h2>\n <Input.Root>\n <div role='none' className='flex flex-col gap-1'>\n <Input.Label>{t('function url label')}</Input.Label>\n <div role='none' className='flex gap-1'>\n <Input.TextInput\n disabled\n value={functionUrl}\n onChange={(event) => {\n fn.name = event.target.value;\n }}\n />\n <Clipboard.IconButton value={functionUrl} />\n </div>\n </div>\n </Input.Root>\n <Input.Root>\n <div role='none' className='flex flex-col gap-1'>\n <Input.Label>{t('function binding label')}</Input.Label>\n <Input.TextInput\n placeholder={t('function binding placeholder')}\n value={binding}\n onChange={handleBindingChange}\n onBlur={handleBindingBlur}\n />\n </div>\n </Input.Root>\n </div>\n </>\n )}\n <Separator />\n <div className='flex flex-col w-full p-2 gap-4'>\n <div>\n <h2>{t('script publish settings label')}</h2>\n <p className='text-description text-sm'>{t('script publish settings description')}</p>\n </div>\n {!githubToken && (\n <div className='flex flex-col items-center justify-center gap-2'>\n <span>{t('no github token label')}</span>\n <Button onClick={handleOpenTokenManager}>{t('open token manager label')}</Button>\n </div>\n )}\n {githubToken && (\n <div className='flex justify-end gap-2'>\n {gistUrl && <Clipboard.IconButton value={gistUrl} />}\n <Button disabled={publishing} onClick={handlePublish}>\n {t(publishing ? 'publishing label' : 'publish label')}\n </Button>\n </div>\n )}\n </div>\n </>\n );\n};\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { lazy } from 'react';\n\nexport * from './ScriptSettings';\nexport * from './ScriptSettingsPanel';\n\nexport const AutomationPanel = lazy(() => import('./AutomationPanel'));\nexport const ScriptContainer = lazy(() => import('./ScriptContainer'));\n"],
4
+ "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport React from 'react';\n\nimport { type Credential } from '@dxos/protocols/proto/dxos/halo/credentials';\nimport { useClient } from '@dxos/react-client';\nimport { Button, Select, useTranslation } from '@dxos/react-ui';\nimport { type EditorInputMode, EditorInputModes } from '@dxos/react-ui-editor';\nimport { DeprecatedFormContainer, DeprecatedFormInput } from '@dxos/react-ui-form';\n\nimport { SCRIPT_PLUGIN } from '../../meta';\nimport { type ScriptSettingsProps } from '../../types';\n\nexport const ScriptSettings = ({ settings }: { settings: ScriptSettingsProps }) => {\n const { t } = useTranslation(SCRIPT_PLUGIN);\n const client = useClient();\n\n // TODO(burdon): Check token.\n const handleAuthenticate = async () => {\n const { identityKey } = client.halo.identity.get()!;\n await client.halo.writeCredentials([\n {\n issuer: identityKey,\n issuanceDate: new Date(),\n subject: {\n id: identityKey,\n assertion: {\n '@type': 'dxos.halo.credentials.ServiceAccess',\n serverName: 'hub.dxos.network',\n serverKey: identityKey,\n identityKey,\n capabilities: ['composer:beta'],\n },\n },\n } satisfies Credential,\n ]);\n };\n\n return (\n <DeprecatedFormContainer>\n {/* TODO(wittjosiah): Hide outside of dev environments. */}\n <DeprecatedFormInput label={t('authenticate action label')}>\n <Button onClick={handleAuthenticate}>{t('authenticate button label')}</Button>\n </DeprecatedFormInput>\n\n <DeprecatedFormInput label={t('editor input mode label')}>\n <Select.Root\n value={settings.editorInputMode ?? 'default'}\n onValueChange={(value) => {\n settings.editorInputMode = value as EditorInputMode;\n }}\n >\n <Select.TriggerButton placeholder={t('select editor input mode placeholder')} />\n <Select.Portal>\n <Select.Content>\n <Select.Viewport>\n {EditorInputModes.map((mode) => (\n <Select.Option key={mode} value={mode}>\n {t(`settings editor input mode ${mode} label`)}\n </Select.Option>\n ))}\n </Select.Viewport>\n </Select.Content>\n </Select.Portal>\n </Select.Root>\n </DeprecatedFormInput>\n </DeprecatedFormContainer>\n );\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { Octokit } from '@octokit/core';\nimport React, { type ChangeEvent, useCallback, useEffect, useState } from 'react';\n\nimport { createIntent, SettingsAction, useIntentDispatcher } from '@dxos/app-framework';\nimport { FunctionType, type ScriptType, getInvocationUrl, getUserFunctionUrlInMetadata } from '@dxos/functions';\nimport { log } from '@dxos/log';\nimport { useClient } from '@dxos/react-client';\nimport { Filter, getMeta, getSpace, useQuery } from '@dxos/react-client/echo';\nimport { Button, Clipboard, Input, Separator, useControlledState, useTranslation } from '@dxos/react-ui';\nimport { AccessTokenType } from '@dxos/schema';\n\nimport { SCRIPT_PLUGIN } from '../meta';\n\n// TODO(wittjosiah): Factor out.\n// From https://stackoverflow.com/a/67243723/2804332\nconst kebabize = (str: string) => str.replace(/[A-Z]+(?![a-z])|[A-Z]/g, ($, ofs) => (ofs ? '-' : '') + $.toLowerCase());\n\nexport type ScriptSettingsPanelProps = {\n script: ScriptType;\n};\n\nexport const ScriptSettingsPanel = ({ script }: ScriptSettingsPanelProps) => {\n const { t } = useTranslation(SCRIPT_PLUGIN);\n const { dispatchPromise: dispatch } = useIntentDispatcher();\n const client = useClient();\n const space = getSpace(script);\n const [fn] = useQuery(space, Filter.schema(FunctionType, { source: script }));\n const [githubToken] = useQuery(space, Filter.schema(AccessTokenType, { source: 'github.com' }));\n const gistKey = getMeta(script).keys.find(({ source }) => source === 'github.com');\n const [gistUrl, setGistUrl] = useState<string | undefined>();\n\n useEffect(() => {\n const token = githubToken?.token;\n const gistId = gistKey?.id;\n if (!token || !gistId) {\n setGistUrl(undefined);\n return;\n }\n\n const timeout = setTimeout(async () => {\n try {\n const octokit = new Octokit({ auth: githubToken.token });\n const response = await octokit.request('GET /gists/{gist_id}', {\n gist_id: gistId,\n });\n setGistUrl(response.data.html_url);\n } catch (err) {\n log.catch(err);\n setGistUrl(undefined);\n }\n });\n\n return () => clearTimeout(timeout);\n }, [githubToken, gistKey]);\n\n const [binding, setBinding] = useControlledState(fn?.binding ?? '');\n const handleBindingChange = useCallback(\n (event: ChangeEvent<HTMLInputElement>) => {\n setBinding(event.target.value);\n },\n [setBinding],\n );\n const handleBindingBlur = useCallback(() => {\n fn.binding = binding;\n }, [fn, binding]);\n\n const functionPath = fn && getUserFunctionUrlInMetadata(getMeta(fn));\n const functionUrl =\n functionPath &&\n getInvocationUrl(functionPath, client.config.values.runtime?.services?.edge?.url ?? '', {\n spaceId: space?.id,\n });\n\n const handleOpenTokenManager = useCallback(\n () => dispatch(createIntent(SettingsAction.Open, { plugin: 'dxos.org/plugin/token-manager' })),\n [],\n );\n\n const [publishing, setPublishing] = useState(false);\n const handlePublish = useCallback(async () => {\n setPublishing(true);\n const octokit = new Octokit({ auth: githubToken.token });\n const source = await script.source.load();\n const filename = script.name ? kebabize(script.name) : 'composer-script';\n const files = { [`${filename}.ts`]: { content: source.content } };\n\n try {\n // TODO(wittjosiah): Factor out to intent.\n const meta = getMeta(script);\n const githubKey = meta.keys.find(({ source }) => source === 'github.com');\n const gistId = githubKey?.id;\n if (gistId) {\n await octokit.request('PATCH /gists/{gist_id}', {\n gist_id: gistId,\n files,\n });\n } else {\n const response = await octokit.request('POST /gists', {\n public: true,\n files,\n });\n if (response.data.id) {\n meta.keys.push({ source: 'github.com', id: response.data.id });\n }\n }\n } finally {\n setPublishing(false);\n }\n }, [script, githubToken]);\n\n return (\n <>\n <div role='form' className='flex flex-col w-full p-2 gap-4'>\n <Input.Root>\n <div role='none' className='flex flex-col gap-1'>\n <Input.Label>{t('description label')}</Input.Label>\n <Input.TextInput\n placeholder={t('description placeholder')}\n value={script.description ?? ''}\n onChange={(event) => {\n script.description = event.target.value;\n }}\n />\n </div>\n </Input.Root>\n </div>\n {fn && functionUrl && (\n <>\n <Separator />\n <div role='form' className='flex flex-col w-full p-2 gap-4'>\n <h2>{t('remote function settings heading')}</h2>\n <Input.Root>\n <div role='none' className='flex flex-col gap-1'>\n <Input.Label>{t('function url label')}</Input.Label>\n <div role='none' className='flex gap-1'>\n <Input.TextInput\n disabled\n value={functionUrl}\n onChange={(event) => {\n fn.name = event.target.value;\n }}\n />\n <Clipboard.IconButton value={functionUrl} />\n </div>\n </div>\n </Input.Root>\n <Input.Root>\n <div role='none' className='flex flex-col gap-1'>\n <Input.Label>{t('function binding label')}</Input.Label>\n <Input.TextInput\n placeholder={t('function binding placeholder')}\n value={binding}\n onChange={handleBindingChange}\n onBlur={handleBindingBlur}\n />\n </div>\n </Input.Root>\n </div>\n </>\n )}\n <Separator />\n <div className='flex flex-col w-full p-2 gap-4'>\n <div>\n <h2>{t('script publish settings label')}</h2>\n <p className='text-description text-sm'>{t('script publish settings description')}</p>\n </div>\n {!githubToken && (\n <div className='flex flex-col items-center justify-center gap-2'>\n <span>{t('no github token label')}</span>\n <Button onClick={handleOpenTokenManager}>{t('open token manager label')}</Button>\n </div>\n )}\n {githubToken && (\n <div className='flex justify-end gap-2'>\n {gistUrl && <Clipboard.IconButton value={gistUrl} />}\n <Button disabled={publishing} onClick={handlePublish}>\n {t(publishing ? 'publishing label' : 'publish label')}\n </Button>\n </div>\n )}\n </div>\n </>\n );\n};\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { lazy } from 'react';\n\nexport * from './ScriptSettings';\nexport * from './ScriptSettingsPanel';\n\nexport const AutomationPanel = lazy(() => import('./AutomationPanel'));\nexport const ScriptContainer = lazy(() => import('./ScriptContainer'));\n"],
5
5
  "mappings": ";;;;;;AAIA,OAAOA,WAAW;AAGlB,SAASC,iBAAiB;AAC1B,SAASC,QAAQC,QAAQC,sBAAsB;AAC/C,SA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,YAAU;IAAC7C,OAAO7B;MACzC,gBAAA2D,OAAA,cAACmB,SAAAA;IAAON,UAAUzB;IAAYgC,SAAS9B;KACpCvE,EAAEqE,aAAa,qBAAqB,eAAA,CAAA,CAAA,CAAA,CAAA;AAOnD;;;ACvLA,SAASiC,YAAY;AAKd,IAAMC,kBAAkBC,KAAK,MAAM,OAAO,gCAAA,CAAA;AAC1C,IAAMC,kBAAkBD,KAAK,MAAM,OAAO,gCAAA,CAAA;",
6
- "names": ["React", "useClient", "Button", "Select", "useTranslation", "EditorInputModes", "DeprecatedFormContainer", "DeprecatedFormInput", "ScriptSettings", "settings", "t", "useTranslation", "SCRIPT_PLUGIN", "client", "useClient", "handleAuthenticate", "identityKey", "halo", "identity", "get", "writeCredentials", "issuer", "issuanceDate", "Date", "subject", "id", "assertion", "serverName", "serverKey", "capabilities", "DeprecatedFormContainer", "DeprecatedFormInput", "label", "Button", "onClick", "Select", "Root", "value", "editorInputMode", "onValueChange", "TriggerButton", "placeholder", "Portal", "Content", "Viewport", "EditorInputModes", "map", "mode", "Option", "key", "Octokit", "React", "useCallback", "useEffect", "useState", "createIntent", "SettingsAction", "useIntentDispatcher", "FunctionType", "getInvocationUrl", "getUserFunctionUrlInMetadata", "log", "useClient", "Filter", "getMeta", "getSpace", "useQuery", "Button", "Clipboard", "Input", "Separator", "useControlledValue", "useTranslation", "AccessTokenType", "kebabize", "str", "replace", "$", "ofs", "toLowerCase", "ScriptSettingsPanel", "script", "t", "useTranslation", "SCRIPT_PLUGIN", "dispatchPromise", "dispatch", "useIntentDispatcher", "client", "useClient", "space", "getSpace", "fn", "useQuery", "Filter", "schema", "FunctionType", "source", "githubToken", "AccessTokenType", "gistKey", "getMeta", "keys", "find", "gistUrl", "setGistUrl", "useState", "useEffect", "token", "gistId", "id", "undefined", "timeout", "setTimeout", "octokit", "Octokit", "auth", "response", "request", "gist_id", "data", "html_url", "err", "log", "catch", "clearTimeout", "binding", "setBinding", "useControlledValue", "handleBindingChange", "useCallback", "event", "target", "value", "handleBindingBlur", "functionPath", "getUserFunctionUrlInMetadata", "functionUrl", "getInvocationUrl", "config", "values", "runtime", "services", "edge", "url", "spaceId", "handleOpenTokenManager", "createIntent", "SettingsAction", "Open", "plugin", "publishing", "setPublishing", "handlePublish", "load", "filename", "name", "files", "content", "meta", "githubKey", "public", "push", "React", "div", "role", "className", "Input", "Root", "Label", "TextInput", "placeholder", "description", "onChange", "Separator", "h2", "disabled", "Clipboard", "IconButton", "onBlur", "p", "span", "Button", "onClick", "lazy", "AutomationPanel", "lazy", "ScriptContainer"]
6
+ "names": ["React", "useClient", "Button", "Select", "useTranslation", "EditorInputModes", "DeprecatedFormContainer", "DeprecatedFormInput", "ScriptSettings", "settings", "t", "useTranslation", "SCRIPT_PLUGIN", "client", "useClient", "handleAuthenticate", "identityKey", "halo", "identity", "get", "writeCredentials", "issuer", "issuanceDate", "Date", "subject", "id", "assertion", "serverName", "serverKey", "capabilities", "DeprecatedFormContainer", "DeprecatedFormInput", "label", "Button", "onClick", "Select", "Root", "value", "editorInputMode", "onValueChange", "TriggerButton", "placeholder", "Portal", "Content", "Viewport", "EditorInputModes", "map", "mode", "Option", "key", "Octokit", "React", "useCallback", "useEffect", "useState", "createIntent", "SettingsAction", "useIntentDispatcher", "FunctionType", "getInvocationUrl", "getUserFunctionUrlInMetadata", "log", "useClient", "Filter", "getMeta", "getSpace", "useQuery", "Button", "Clipboard", "Input", "Separator", "useControlledState", "useTranslation", "AccessTokenType", "kebabize", "str", "replace", "$", "ofs", "toLowerCase", "ScriptSettingsPanel", "script", "t", "useTranslation", "SCRIPT_PLUGIN", "dispatchPromise", "dispatch", "useIntentDispatcher", "client", "useClient", "space", "getSpace", "fn", "useQuery", "Filter", "schema", "FunctionType", "source", "githubToken", "AccessTokenType", "gistKey", "getMeta", "keys", "find", "gistUrl", "setGistUrl", "useState", "useEffect", "token", "gistId", "id", "undefined", "timeout", "setTimeout", "octokit", "Octokit", "auth", "response", "request", "gist_id", "data", "html_url", "err", "log", "catch", "clearTimeout", "binding", "setBinding", "useControlledState", "handleBindingChange", "useCallback", "event", "target", "value", "handleBindingBlur", "functionPath", "getUserFunctionUrlInMetadata", "functionUrl", "getInvocationUrl", "config", "values", "runtime", "services", "edge", "url", "spaceId", "handleOpenTokenManager", "createIntent", "SettingsAction", "Open", "plugin", "publishing", "setPublishing", "handlePublish", "load", "filename", "name", "files", "content", "meta", "githubKey", "public", "push", "React", "div", "role", "className", "Input", "Root", "Label", "TextInput", "placeholder", "description", "onChange", "Separator", "h2", "disabled", "Clipboard", "IconButton", "onBlur", "p", "span", "Button", "onClick", "lazy", "AutomationPanel", "lazy", "ScriptContainer"]
7
7
  }
@@ -1,7 +1,4 @@
1
1
  import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
2
- import {
3
- initializeBundler
4
- } from "./chunk-G76M6O46.mjs";
5
2
  import {
6
3
  ScriptCapabilities
7
4
  } from "./chunk-CP5LXTK5.mjs";
@@ -10,6 +7,7 @@ import "./chunk-P2V2Y5LV.mjs";
10
7
  // packages/plugins/experimental/plugin-script/src/capabilities/compiler.ts
11
8
  import wasmUrl from "esbuild-wasm/esbuild.wasm?url";
12
9
  import { contributes } from "@dxos/app-framework";
10
+ import { initializeBundler } from "@dxos/functions/bundler";
13
11
 
14
12
  // packages/plugins/experimental/plugin-script/src/compiler/compiler.ts
15
13
  import { createDefaultMapFromCDN, createSystem, createVirtualTypeScriptEnvironment } from "@typescript/vfs";
@@ -82,4 +80,4 @@ var compiler_default = async () => {
82
80
  export {
83
81
  compiler_default as default
84
82
  };
85
- //# sourceMappingURL=compiler-PDN46H4Y.mjs.map
83
+ //# sourceMappingURL=compiler-XTXFGZJM.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/capabilities/compiler.ts", "../../../src/compiler/compiler.ts"],
4
+ "sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\n// @ts-ignore\nimport wasmUrl from 'esbuild-wasm/esbuild.wasm?url';\n\nimport { contributes } from '@dxos/app-framework';\nimport { initializeBundler } from '@dxos/functions/bundler';\n\nimport { ScriptCapabilities } from './capabilities';\nimport { Compiler } from '../compiler';\n\nexport default async () => {\n const compiler = new Compiler();\n\n await compiler.initialize();\n // TODO(wittjosiah): Fetch types for https modules.\n compiler.setFile('/src/typings.d.ts', \"declare module 'https://*';\");\n // TODO(wittjosiah): Proper function handler types.\n // TODO(wittjosiah): Remove.\n compiler.setFile(\n '/src/runtime.ts',\n `\n export const Filter: any = {};\n export type FunctionHandler = ({ event, context }: { event: any; context: any }) => Promise<Response>;\n export const functionHandler = (handler: FunctionHandler) => handler;\n `,\n );\n await initializeBundler({ wasmUrl });\n\n return contributes(ScriptCapabilities.Compiler, compiler);\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport {\n createDefaultMapFromCDN,\n createSystem,\n createVirtualTypeScriptEnvironment,\n type VirtualTypeScriptEnvironment,\n} from '@typescript/vfs';\nimport ts from 'typescript';\n\nimport { invariant } from '@dxos/invariant';\n\nconst defaultOptions: ts.CompilerOptions = {\n lib: ['DOM', 'es2022'],\n target: ts.ScriptTarget.ES2022,\n};\n\nexport class Compiler {\n private _env: VirtualTypeScriptEnvironment | undefined;\n private _fsMap: Map<string, string> | undefined;\n\n constructor(private readonly _options: ts.CompilerOptions = defaultOptions) {}\n\n async initialize() {\n if (this._env) {\n return;\n }\n\n // TODO(wittjosiah): Figure out how to get workers working in plugin packages.\n // https://github.com/val-town/codemirror-ts?tab=readme-ov-file#setup-worker\n this._fsMap = await createDefaultMapFromCDN(this._options, '5.5.4', true, ts);\n const system = createSystem(this._fsMap);\n this._env = createVirtualTypeScriptEnvironment(system, [], ts, this._options);\n }\n\n get environment() {\n invariant(this._env, 'Compiler environment not initialized.');\n return this._env;\n }\n\n setFile(fileName: string, content: string) {\n invariant(this._fsMap, 'File system map not initialized.');\n this.environment.createFile(fileName, content);\n }\n\n compile(fileName: string) {\n return this.environment.languageService.getEmitOutput(fileName);\n }\n}\n"],
5
+ "mappings": ";;;;;;;AAKA,OAAOA,aAAa;AAEpB,SAASC,mBAAmB;AAC5B,SAASC,yBAAyB;;;ACJlC,SACEC,yBACAC,cACAC,0CAEK;AACP,OAAOC,QAAQ;AAEf,SAASC,iBAAiB;;AAE1B,IAAMC,iBAAqC;EACzCC,KAAK;IAAC;IAAO;;EACbC,QAAQJ,GAAGK,aAAaC;AAC1B;AAEO,IAAMC,WAAN,MAAMA;EAIXC,YAA6BC,WAA+BP,gBAAgB;SAA/CO,WAAAA;EAAgD;EAE7E,MAAMC,aAAa;AACjB,QAAI,KAAKC,MAAM;AACb;IACF;AAIA,SAAKC,SAAS,MAAMf,wBAAwB,KAAKY,UAAU,SAAS,MAAMT,EAAAA;AAC1E,UAAMa,SAASf,aAAa,KAAKc,MAAM;AACvC,SAAKD,OAAOZ,mCAAmCc,QAAQ,CAAA,GAAIb,IAAI,KAAKS,QAAQ;EAC9E;EAEA,IAAIK,cAAc;AAChBb,cAAU,KAAKU,MAAM,yCAAA;;;;;;;;;AACrB,WAAO,KAAKA;EACd;EAEAI,QAAQC,UAAkBC,SAAiB;AACzChB,cAAU,KAAKW,QAAQ,oCAAA;;;;;;;;;AACvB,SAAKE,YAAYI,WAAWF,UAAUC,OAAAA;EACxC;EAEAE,QAAQH,UAAkB;AACxB,WAAO,KAAKF,YAAYM,gBAAgBC,cAAcL,QAAAA;EACxD;AACF;;;ADrCA,IAAA,mBAAe,YAAA;AACb,QAAMM,WAAW,IAAIC,SAAAA;AAErB,QAAMD,SAASE,WAAU;AAEzBF,WAASG,QAAQ,qBAAqB,6BAAA;AAGtCH,WAASG,QACP,mBACA;;;;OAIG;AAEL,QAAMC,kBAAkB;IAAEC;EAAQ,CAAA;AAElC,SAAOC,YAAYC,mBAAmBN,UAAUD,QAAAA;AAClD;",
6
+ "names": ["wasmUrl", "contributes", "initializeBundler", "createDefaultMapFromCDN", "createSystem", "createVirtualTypeScriptEnvironment", "ts", "invariant", "defaultOptions", "lib", "target", "ScriptTarget", "ES2022", "Compiler", "constructor", "_options", "initialize", "_env", "_fsMap", "system", "environment", "setFile", "fileName", "content", "createFile", "compile", "languageService", "getEmitOutput", "compiler", "Compiler", "initialize", "setFile", "initializeBundler", "wasmUrl", "contributes", "ScriptCapabilities"]
7
+ }
@@ -1,14 +1,10 @@
1
1
  import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
2
- import {
3
- Bundler,
4
- initializeBundler
5
- } from "./chunk-G76M6O46.mjs";
6
2
  import {
7
3
  AutomationPanel,
8
4
  ScriptContainer,
9
5
  ScriptSettings,
10
6
  ScriptSettingsPanel
11
- } from "./chunk-PRGBYF4B.mjs";
7
+ } from "./chunk-WCAUDRF4.mjs";
12
8
  import {
13
9
  ScriptCapabilities
14
10
  } from "./chunk-CP5LXTK5.mjs";
@@ -22,10 +18,11 @@ import {
22
18
 
23
19
  // packages/plugins/experimental/plugin-script/src/capabilities/index.ts
24
20
  import { lazy } from "@dxos/app-framework";
25
- var Compiler = lazy(() => import("./compiler-PDN46H4Y.mjs"));
26
- var IntentResolver = lazy(() => import("./intent-resolver-75BHFRUK.mjs"));
27
- var ReactSurface = lazy(() => import("./react-surface-PKUVZH4S.mjs"));
21
+ var Compiler = lazy(() => import("./compiler-XTXFGZJM.mjs"));
22
+ var IntentResolver = lazy(() => import("./intent-resolver-CYT6IYYH.mjs"));
23
+ var ReactSurface = lazy(() => import("./react-surface-N67GNKC2.mjs"));
28
24
  var ScriptSettings2 = lazy(() => import("./settings-GR4O2WHZ.mjs"));
25
+ var Artifact = lazy(() => import("./artifact-7H4HGX5W.mjs"));
29
26
 
30
27
  // packages/plugins/experimental/plugin-script/src/ScriptPlugin.tsx
31
28
  import { Capabilities, contributes, createIntent, defineModule, definePlugin, Events } from "@dxos/app-framework";
@@ -147,18 +144,21 @@ var ScriptPlugin = () => definePlugin(meta, [
147
144
  id: `${meta.id}/module/intent-resolver`,
148
145
  activatesOn: Events.SetupIntents,
149
146
  activate: IntentResolver
147
+ }),
148
+ defineModule({
149
+ id: `${meta.id}/module/artifact`,
150
+ activatesOn: Events.Startup,
151
+ activate: Artifact
150
152
  })
151
153
  ]);
152
154
  export {
153
155
  AutomationPanel,
154
- Bundler,
155
156
  SCRIPT_PLUGIN,
156
157
  ScriptCapabilities,
157
158
  ScriptContainer,
158
159
  ScriptPlugin,
159
160
  ScriptSettings,
160
161
  ScriptSettingsPanel,
161
- initializeBundler,
162
162
  meta
163
163
  };
164
164
  //# sourceMappingURL=index.mjs.map