@dxos/plugin-script 0.8.4-main.3fbcb4aa9b → 0.8.4-main.4668b7de9b
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +102 -5
- package/PLUGIN.mdl +515 -0
- package/dist/lib/neutral/{DeploymentDialog-6DBF3V6C.mjs → DeploymentDialog-M3AFYQHC.mjs} +4 -2
- package/dist/lib/neutral/{DeploymentDialog-6DBF3V6C.mjs.map → DeploymentDialog-M3AFYQHC.mjs.map} +3 -3
- package/dist/lib/neutral/{NotebookContainer-FIAQI3A2.mjs → NotebookArticle-NV4AHOOS.mjs} +15 -12
- package/dist/lib/neutral/NotebookArticle-NV4AHOOS.mjs.map +7 -0
- package/dist/lib/neutral/{ScriptContainer-2OPBAXFB.mjs → ScriptArticle-UBT27SB6.mjs} +4 -4
- package/dist/lib/neutral/{ScriptContainer-2OPBAXFB.mjs.map → ScriptArticle-UBT27SB6.mjs.map} +4 -4
- package/dist/lib/neutral/ScriptPlugin.mjs +12 -0
- package/dist/lib/neutral/ScriptPlugin.mjs.map +4 -4
- package/dist/lib/neutral/ScriptPlugin.workerd.mjs +21 -0
- package/dist/lib/neutral/ScriptPlugin.workerd.mjs.map +7 -0
- package/dist/lib/neutral/{ScriptProperties-F6NE6M4H.mjs → ScriptProperties-RLXNAN3N.mjs} +9 -8
- package/dist/lib/neutral/ScriptProperties-RLXNAN3N.mjs.map +7 -0
- package/dist/lib/neutral/{TestContainer-JNFPLAJX.mjs → TestContainer-AFVTBYSJ.mjs} +5 -5
- package/dist/lib/neutral/TestContainer-AFVTBYSJ.mjs.map +7 -0
- package/dist/lib/neutral/blueprints/index.mjs +3 -3
- package/dist/lib/neutral/capabilities/index.mjs +4 -4
- package/dist/lib/neutral/capabilities/node.mjs +3 -3
- package/dist/lib/neutral/{chunk-D7DFASAE.mjs → chunk-2REUEDUA.mjs} +8 -4
- package/dist/lib/neutral/chunk-2REUEDUA.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-BDRB6ZX2.mjs → chunk-BDHDBPVM.mjs} +2 -2
- package/dist/lib/neutral/{chunk-PDB6UOSB.mjs → chunk-C4O7EV6M.mjs} +11 -13
- package/dist/lib/neutral/chunk-C4O7EV6M.mjs.map +7 -0
- package/dist/lib/neutral/chunk-H2BRWQMY.mjs +96 -0
- package/dist/lib/neutral/chunk-H2BRWQMY.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-B4FVQEHV.mjs → chunk-LHEJXJEL.mjs} +2 -2
- package/dist/lib/neutral/{chunk-B4FVQEHV.mjs.map → chunk-LHEJXJEL.mjs.map} +2 -2
- package/dist/lib/neutral/chunk-NQOIENTU.mjs +8 -0
- package/dist/lib/neutral/{chunk-MI6X5CTJ.mjs → chunk-TRKXIP2Q.mjs} +30 -21
- package/dist/lib/neutral/chunk-TRKXIP2Q.mjs.map +7 -0
- package/dist/lib/neutral/chunk-UA3BWOCZ.mjs +38 -0
- package/dist/lib/neutral/chunk-UA3BWOCZ.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-4RJALG6K.mjs → chunk-VXDJH6OL.mjs} +9 -10
- package/dist/lib/neutral/chunk-VXDJH6OL.mjs.map +7 -0
- package/dist/lib/neutral/{compiler-SMVIP5UN.mjs → compiler-ODK4UA2N.mjs} +2 -2
- package/dist/lib/neutral/components/index.mjs +93 -148
- package/dist/lib/neutral/components/index.mjs.map +4 -4
- package/dist/lib/neutral/containers/index.mjs +7 -7
- package/dist/lib/neutral/containers/index.mjs.map +3 -3
- package/dist/lib/neutral/{create-OZRIZ7RN.mjs → create-WQJXMOUE.mjs} +7 -5
- package/dist/lib/neutral/create-WQJXMOUE.mjs.map +7 -0
- package/dist/lib/neutral/{create-object-F2NWICFV.mjs → create-object-FZM5ASWM.mjs} +4 -3
- package/dist/lib/neutral/create-object-FZM5ASWM.mjs.map +7 -0
- package/dist/lib/neutral/{create-script-VBA3SLSU.mjs → create-script-66DO3UJO.mjs} +3 -3
- package/dist/lib/neutral/{delete-PAUWA2QM.mjs → delete-HCQIQFVP.mjs} +2 -2
- package/dist/lib/neutral/{deploy-CXVW54JJ.mjs → deploy-7JVMMHSH.mjs} +6 -5
- package/dist/lib/neutral/{deploy-CXVW54JJ.mjs.map → deploy-7JVMMHSH.mjs.map} +3 -3
- package/dist/lib/neutral/hooks/index.mjs +2 -2
- package/dist/lib/neutral/index.mjs +7 -7
- package/dist/lib/neutral/{inspect-invocations-LEOEP5I2.mjs → inspect-invocations-6MW73SDV.mjs} +3 -3
- package/dist/lib/neutral/{inspect-invocations-LEOEP5I2.mjs.map → inspect-invocations-6MW73SDV.mjs.map} +3 -3
- package/dist/lib/neutral/{install-function-5N24Q45W.mjs → install-function-FJIE2JAI.mjs} +7 -9
- package/dist/lib/neutral/install-function-FJIE2JAI.mjs.map +7 -0
- package/dist/lib/neutral/{invoke-5QVEZ3X5.mjs → invoke-3HVWY2KF.mjs} +7 -8
- package/dist/lib/neutral/invoke-3HVWY2KF.mjs.map +7 -0
- package/dist/lib/neutral/meta.json +1 -1
- package/dist/lib/neutral/meta.mjs +1 -1
- package/dist/lib/neutral/{operation-handler-OTCWYDFI.mjs → operation-handler-X44IGZXS.mjs} +3 -3
- package/dist/lib/neutral/operations/index.mjs +1 -1
- package/dist/lib/neutral/plugin.mjs +2 -2
- package/dist/lib/neutral/{query-deployed-functions-FVD7NYPA.mjs → query-deployed-functions-F4FHJNWO.mjs} +14 -10
- package/dist/lib/neutral/query-deployed-functions-F4FHJNWO.mjs.map +7 -0
- package/dist/lib/neutral/{react-surface-JH2AOK7V.mjs → react-surface-ACNZ35FV.mjs} +17 -13
- package/dist/lib/neutral/react-surface-ACNZ35FV.mjs.map +7 -0
- package/dist/lib/neutral/{read-FFOSK6A3.mjs → read-RQESBAQI.mjs} +2 -2
- package/dist/lib/neutral/templates/index.mjs +1 -1
- package/dist/lib/neutral/translations.mjs +3 -2
- package/dist/lib/neutral/translations.mjs.map +3 -3
- package/dist/lib/neutral/types/index.mjs +2 -2
- package/dist/lib/neutral/{update-PJS5GG3Y.mjs → update-JZUNJYZM.mjs} +3 -3
- package/dist/lib/neutral/{update-PJS5GG3Y.mjs.map → update-JZUNJYZM.mjs.map} +3 -3
- package/dist/types/src/ScriptPlugin.d.ts.map +1 -1
- package/dist/types/src/ScriptPlugin.workerd.d.ts +4 -0
- package/dist/types/src/ScriptPlugin.workerd.d.ts.map +1 -0
- package/dist/types/src/blueprints/functions/create.d.ts.map +1 -1
- package/dist/types/src/blueprints/functions/definitions.d.ts +24 -30
- package/dist/types/src/blueprints/functions/definitions.d.ts.map +1 -1
- package/dist/types/src/blueprints/functions/delete.d.ts +4 -5
- package/dist/types/src/blueprints/functions/deploy.d.ts +4 -5
- package/dist/types/src/blueprints/functions/inspect-invocations.d.ts +4 -5
- package/dist/types/src/blueprints/functions/invoke.d.ts +5 -6
- package/dist/types/src/blueprints/functions/invoke.d.ts.map +1 -1
- package/dist/types/src/blueprints/functions/read.d.ts +4 -5
- package/dist/types/src/blueprints/functions/update.d.ts +4 -5
- package/dist/types/src/capabilities/create-object.d.ts.map +1 -1
- package/dist/types/src/compiler/compiler.d.ts.map +1 -1
- package/dist/types/src/components/NotebookStack/NotebookStack.d.ts.map +1 -1
- package/dist/types/src/components/QueryEditor/QueryEditor.d.ts.map +1 -1
- package/dist/types/src/components/ScriptToolbar/ScriptToolbar.d.ts.map +1 -1
- package/dist/types/src/components/TestPanel/TestPanel.d.ts.map +1 -1
- package/dist/types/src/components/TypescriptEditor/TypescriptEditor.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +0 -1
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/constants.d.ts +2 -1
- package/dist/types/src/constants.d.ts.map +1 -1
- package/dist/types/src/containers/NotebookArticle/NotebookArticle.d.ts +7 -0
- package/dist/types/src/containers/NotebookArticle/NotebookArticle.d.ts.map +1 -0
- package/dist/types/src/containers/NotebookArticle/NotebookArticle.stories.d.ts +7 -0
- package/dist/types/src/containers/NotebookArticle/NotebookArticle.stories.d.ts.map +1 -0
- package/dist/types/src/containers/NotebookArticle/index.d.ts +2 -0
- package/dist/types/src/containers/{ScriptContainer → NotebookArticle}/index.d.ts.map +1 -1
- package/dist/types/src/containers/{ScriptContainer/ScriptContainer.d.ts → ScriptArticle/ScriptArticle.d.ts} +2 -2
- package/dist/types/src/containers/ScriptArticle/ScriptArticle.d.ts.map +1 -0
- package/dist/types/src/containers/{ScriptContainer/ScriptContainer.stories.d.ts → ScriptArticle/ScriptArticle.stories.d.ts} +1 -1
- package/dist/types/src/containers/ScriptArticle/ScriptArticle.stories.d.ts.map +1 -0
- package/dist/types/src/containers/ScriptArticle/index.d.ts +2 -0
- package/dist/types/src/containers/ScriptArticle/index.d.ts.map +1 -0
- package/dist/types/src/containers/ScriptProperties/BlueprintEditor.d.ts.map +1 -1
- package/dist/types/src/containers/ScriptProperties/ScriptProperties.stories.d.ts.map +1 -1
- package/dist/types/src/containers/index.d.ts +2 -2
- package/dist/types/src/containers/index.d.ts.map +1 -1
- package/dist/types/src/hooks/deploy.d.ts +5 -6
- package/dist/types/src/hooks/deploy.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +1 -1
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/operations/index.d.ts.map +1 -1
- package/dist/types/src/templates/chess-bot.d.ts +4 -2
- package/dist/types/src/templates/chess-bot.d.ts.map +1 -1
- package/dist/types/src/templates/commentary.d.ts +6 -4
- package/dist/types/src/templates/commentary.d.ts.map +1 -1
- package/dist/types/src/templates/index.d.ts +0 -5
- package/dist/types/src/templates/index.d.ts.map +1 -1
- package/dist/types/src/testing/test-script.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/Notebook.d.ts +28 -47
- package/dist/types/src/types/Notebook.d.ts.map +1 -1
- package/dist/types/src/types/ScriptOperation.d.ts +6 -6
- package/dist/types/src/types/ScriptOperation.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +84 -84
- package/src/ScriptPlugin.tsx +6 -0
- package/src/ScriptPlugin.workerd.ts +18 -0
- package/src/blueprints/functions/create.ts +3 -3
- package/src/blueprints/functions/definitions.ts +20 -11
- package/src/blueprints/functions/deploy.ts +3 -2
- package/src/blueprints/functions/inspect-invocations.ts +1 -1
- package/src/blueprints/functions/install-function.ts +5 -5
- package/src/blueprints/functions/invoke.ts +4 -5
- package/src/blueprints/functions/query-deployed-functions.ts +11 -7
- package/src/blueprints/functions/update.ts +1 -1
- package/src/capabilities/create-object.ts +3 -2
- package/src/capabilities/react-surface.tsx +6 -6
- package/src/compiler/compiler.ts +4 -0
- package/src/components/NotebookStack/NotebookCell.tsx +2 -2
- package/src/components/NotebookStack/NotebookStack.stories.tsx +2 -2
- package/src/components/NotebookStack/NotebookStack.tsx +1 -1
- package/src/components/QueryEditor/QueryEditor.tsx +3 -1
- package/src/components/ScriptToolbar/ScriptToolbar.stories.tsx +3 -3
- package/src/components/ScriptToolbar/ScriptToolbar.tsx +1 -1
- package/src/components/TestPanel/TestPanel.tsx +2 -1
- package/src/components/TypescriptEditor/TypescriptEditor.tsx +1 -1
- package/src/components/index.ts +0 -1
- package/src/constants.ts +3 -1
- package/src/containers/DeploymentDialog/DeploymentDialog.stories.tsx +3 -3
- package/src/containers/DeploymentDialog/DeploymentDialog.tsx +1 -1
- package/src/containers/{NotebookContainer/NotebookContainer.stories.tsx → NotebookArticle/NotebookArticle.stories.tsx} +10 -10
- package/src/containers/{NotebookContainer/NotebookContainer.tsx → NotebookArticle/NotebookArticle.tsx} +10 -9
- package/src/containers/NotebookArticle/index.ts +5 -0
- package/src/containers/{ScriptContainer/ScriptContainer.stories.tsx → ScriptArticle/ScriptArticle.stories.tsx} +6 -5
- package/src/containers/{ScriptContainer/ScriptContainer.tsx → ScriptArticle/ScriptArticle.tsx} +1 -1
- package/src/containers/ScriptArticle/index.ts +5 -0
- package/src/containers/ScriptProperties/BlueprintEditor.tsx +8 -7
- package/src/containers/ScriptProperties/ScriptProperties.stories.tsx +3 -2
- package/src/containers/TestContainer/TestContainer.tsx +4 -4
- package/src/containers/index.ts +2 -2
- package/src/meta.ts +13 -7
- package/src/operations/index.ts +1 -4
- package/src/templates/anthropic.ts +2 -1
- package/src/templates/chess-bot.ts +2 -2
- package/src/templates/commentary.ts +19 -17
- package/src/templates/data-generator.ts +1 -1
- package/src/templates/discord.ts +5 -5
- package/src/templates/forex-effect.ts +2 -1
- package/src/templates/forex.ts +2 -1
- package/src/templates/gmail.ts +5 -5
- package/src/templates/index.ts +0 -7
- package/src/templates/ping.ts +2 -1
- package/src/testing/test-notebook.ts +2 -2
- package/src/testing/test-script.ts +1 -2
- package/src/translations.ts +3 -2
- package/src/types/Notebook.ts +5 -11
- package/src/types/ScriptOperation.ts +4 -4
- package/src/util/deploy.ts +1 -1
- package/src/util/functions.ts +4 -4
- package/src/vite-env.d.ts +5 -0
- package/dist/lib/neutral/NotebookContainer-FIAQI3A2.mjs.map +0 -7
- package/dist/lib/neutral/ScriptProperties-F6NE6M4H.mjs.map +0 -7
- package/dist/lib/neutral/TestContainer-JNFPLAJX.mjs.map +0 -7
- package/dist/lib/neutral/access-token-created-ENMCEGVU.mjs +0 -34
- package/dist/lib/neutral/access-token-created-ENMCEGVU.mjs.map +0 -7
- package/dist/lib/neutral/chunk-2DMPFVUM.mjs +0 -8
- package/dist/lib/neutral/chunk-4RJALG6K.mjs.map +0 -7
- package/dist/lib/neutral/chunk-BUKQITZT.mjs +0 -105
- package/dist/lib/neutral/chunk-BUKQITZT.mjs.map +0 -7
- package/dist/lib/neutral/chunk-D7DFASAE.mjs.map +0 -7
- package/dist/lib/neutral/chunk-MI6X5CTJ.mjs.map +0 -7
- package/dist/lib/neutral/chunk-P2F3STZN.mjs +0 -8
- package/dist/lib/neutral/chunk-P2F3STZN.mjs.map +0 -7
- package/dist/lib/neutral/chunk-PDB6UOSB.mjs.map +0 -7
- package/dist/lib/neutral/chunk-UYR3YH4Q.mjs +0 -31
- package/dist/lib/neutral/chunk-UYR3YH4Q.mjs.map +0 -7
- package/dist/lib/neutral/create-OZRIZ7RN.mjs.map +0 -7
- package/dist/lib/neutral/create-object-F2NWICFV.mjs.map +0 -7
- package/dist/lib/neutral/install-function-5N24Q45W.mjs.map +0 -7
- package/dist/lib/neutral/invoke-5QVEZ3X5.mjs.map +0 -7
- package/dist/lib/neutral/query-deployed-functions-FVD7NYPA.mjs.map +0 -7
- package/dist/lib/neutral/react-surface-JH2AOK7V.mjs.map +0 -7
- package/dist/types/src/capabilities/artifact-definition.d.ts +0 -12
- package/dist/types/src/capabilities/artifact-definition.d.ts.map +0 -1
- package/dist/types/src/components/FramePanel/FramePanel.d.ts +0 -12
- package/dist/types/src/components/FramePanel/FramePanel.d.ts.map +0 -1
- package/dist/types/src/components/FramePanel/index.d.ts +0 -2
- package/dist/types/src/components/FramePanel/index.d.ts.map +0 -1
- package/dist/types/src/containers/NotebookContainer/NotebookContainer.d.ts +0 -7
- package/dist/types/src/containers/NotebookContainer/NotebookContainer.d.ts.map +0 -1
- package/dist/types/src/containers/NotebookContainer/NotebookContainer.stories.d.ts +0 -7
- package/dist/types/src/containers/NotebookContainer/NotebookContainer.stories.d.ts.map +0 -1
- package/dist/types/src/containers/NotebookContainer/index.d.ts +0 -2
- package/dist/types/src/containers/NotebookContainer/index.d.ts.map +0 -1
- package/dist/types/src/containers/ScriptContainer/ScriptContainer.d.ts.map +0 -1
- package/dist/types/src/containers/ScriptContainer/ScriptContainer.stories.d.ts.map +0 -1
- package/dist/types/src/containers/ScriptContainer/index.d.ts +0 -2
- package/dist/types/src/operations/access-token-created.d.ts +0 -5
- package/dist/types/src/operations/access-token-created.d.ts.map +0 -1
- package/dist/types/src/templates/chat.d.ts +0 -6
- package/dist/types/src/templates/chat.d.ts.map +0 -1
- package/src/capabilities/artifact-definition.ts +0 -226
- package/src/components/FramePanel/FramePanel.tsx +0 -85
- package/src/components/FramePanel/index.ts +0 -5
- package/src/containers/NotebookContainer/index.ts +0 -5
- package/src/containers/ScriptContainer/index.ts +0 -5
- package/src/operations/access-token-created.ts +0 -37
- package/src/templates/chat.ts +0 -96
- /package/dist/lib/neutral/{chunk-BDRB6ZX2.mjs.map → chunk-BDHDBPVM.mjs.map} +0 -0
- /package/dist/lib/neutral/{chunk-2DMPFVUM.mjs.map → chunk-NQOIENTU.mjs.map} +0 -0
- /package/dist/lib/neutral/{compiler-SMVIP5UN.mjs.map → compiler-ODK4UA2N.mjs.map} +0 -0
- /package/dist/lib/neutral/{create-script-VBA3SLSU.mjs.map → create-script-66DO3UJO.mjs.map} +0 -0
- /package/dist/lib/neutral/{delete-PAUWA2QM.mjs.map → delete-HCQIQFVP.mjs.map} +0 -0
- /package/dist/lib/neutral/{operation-handler-OTCWYDFI.mjs.map → operation-handler-X44IGZXS.mjs.map} +0 -0
- /package/dist/lib/neutral/{read-FFOSK6A3.mjs.map → read-RQESBAQI.mjs.map} +0 -0
|
@@ -3,8 +3,8 @@ import "./chunk-J5LGTIGS.mjs";
|
|
|
3
3
|
// src/containers/TestContainer/TestContainer.tsx
|
|
4
4
|
import React, { useCallback, useMemo } from "react";
|
|
5
5
|
import { Context } from "@dxos/context";
|
|
6
|
+
import { Obj } from "@dxos/echo";
|
|
6
7
|
import { FunctionsServiceClient } from "@dxos/functions-runtime/edge";
|
|
7
|
-
import { getSpace } from "@dxos/react-client/echo";
|
|
8
8
|
import { Panel } from "@dxos/react-ui";
|
|
9
9
|
import { TestPanel } from "#components";
|
|
10
10
|
import { useDeployDeps } from "#hooks";
|
|
@@ -13,7 +13,7 @@ var TestContainer = ({ role, script }) => {
|
|
|
13
13
|
const { client, fn, existingFunctionId } = useDeployDeps({
|
|
14
14
|
script
|
|
15
15
|
});
|
|
16
|
-
const
|
|
16
|
+
const spaceId = Obj.getDatabase(script)?.spaceId;
|
|
17
17
|
const functionsClient = useMemo(() => FunctionsServiceClient.fromClient(client), [
|
|
18
18
|
client
|
|
19
19
|
]);
|
|
@@ -22,12 +22,12 @@ var TestContainer = ({ role, script }) => {
|
|
|
22
22
|
throw new Error("Function not deployed");
|
|
23
23
|
}
|
|
24
24
|
return functionsClient.invoke(Context.default(void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 23 }), fn, input, {
|
|
25
|
-
spaceId
|
|
25
|
+
spaceId
|
|
26
26
|
});
|
|
27
27
|
}, [
|
|
28
28
|
fn,
|
|
29
29
|
functionsClient,
|
|
30
|
-
|
|
30
|
+
spaceId
|
|
31
31
|
]);
|
|
32
32
|
return /* @__PURE__ */ React.createElement(Panel.Root, {
|
|
33
33
|
role,
|
|
@@ -41,4 +41,4 @@ var TestContainer = ({ role, script }) => {
|
|
|
41
41
|
export {
|
|
42
42
|
TestContainer as default
|
|
43
43
|
};
|
|
44
|
-
//# sourceMappingURL=TestContainer-
|
|
44
|
+
//# sourceMappingURL=TestContainer-AFVTBYSJ.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/containers/TestContainer/TestContainer.tsx"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport React, { useCallback, useMemo } from 'react';\n\nimport { type Script } from '@dxos/compute';\nimport { Context } from '@dxos/context';\nimport { Obj } from '@dxos/echo';\nimport { FunctionsServiceClient } from '@dxos/functions-runtime/edge';\nimport { Panel } from '@dxos/react-ui';\n\nimport { TestPanel } from '#components';\nimport { useDeployDeps } from '#hooks';\n\nexport type TestContainerProps = {\n role: string;\n script: Script.Script;\n};\n\nexport const TestContainer = ({ role, script }: TestContainerProps) => {\n const { client, fn, existingFunctionId } = useDeployDeps({ script });\n const spaceId = Obj.getDatabase(script)?.spaceId;\n\n const functionsClient = useMemo(() => FunctionsServiceClient.fromClient(client), [client]);\n\n const handleInvoke = useCallback(\n async (input: unknown) => {\n if (!fn) {\n throw new Error('Function not deployed');\n }\n return functionsClient.invoke(Context.default(), fn, input, { spaceId });\n },\n [fn, functionsClient, spaceId],\n );\n\n return (\n <Panel.Root role={role} className='dx-document'>\n <Panel.Content asChild>\n <TestPanel onInvoke={existingFunctionId ? handleInvoke : undefined} />\n </Panel.Content>\n </Panel.Root>\n );\n};\n"],
|
|
5
|
+
"mappings": ";;;AAIA,OAAOA,SAASC,aAAaC,eAAe;AAG5C,SAASC,eAAe;AACxB,SAASC,WAAW;AACpB,SAASC,8BAA8B;AACvC,SAASC,aAAa;AAEtB,SAASC,iBAAiB;AAC1B,SAASC,qBAAqB;AAO9B,IAAA,eAAaC;IACgDC,gBAAAA,CAAAA,EAAAA,MAAAA,OAAAA,MAAAA;AAAO,QAAA,EAAA,QAAA,IAAA,mBAAA,IAAA,cAAA;IAClE;EAEA,CAAA;QAAkFC,UAAAA,IAAAA,YAAAA,MAAAA,GAAAA;QAAO,kBAAA,QAAA,MAAA,uBAAA,WAAA,MAAA,GAAA;IAEzF;;uBAGgBC,YAAM,OAAA,UAAA;AAClB,QAAA,CAAA,IAAA;AACA,YAAOC,IAAAA,MAAAA,uBAA+BC;;AAAgC,WAAA,gBAAA,OAAA,QAAA,QAAA,QAAA,EAAA,YAAA,YAAA,GAAA,cAAA,GAAA,GAAA,CAAA,GAAA,IAAA,OAAA;MAExE;IAACC,CAAAA;;IAAqBC;IAAQ;IAGhC;;SACoC,sBAAA,cAAA,MAAA,MAAA;;IACjBC,WAAAA;KACb,sBAAA,cAACV,MAAAA,SAAAA;IAAUW,SAAAA;;IAIjB,UAAA,qBAAA,eAAA;;;",
|
|
6
|
+
"names": ["React", "useCallback", "useMemo", "Context", "Obj", "FunctionsServiceClient", "Panel", "TestPanel", "useDeployDeps", "TestContainer", "script", "client", "Error", "functionsClient", "default", "fn", "spaceId", "asChild", "onInvoke"]
|
|
7
|
+
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
script_blueprint_default
|
|
3
|
-
} from "../chunk-
|
|
4
|
-
import "../chunk-
|
|
5
|
-
import "../chunk-
|
|
3
|
+
} from "../chunk-BDHDBPVM.mjs";
|
|
4
|
+
import "../chunk-NQOIENTU.mjs";
|
|
5
|
+
import "../chunk-TRKXIP2Q.mjs";
|
|
6
6
|
import "../chunk-J5LGTIGS.mjs";
|
|
7
7
|
export {
|
|
8
8
|
script_blueprint_default as ScriptBlueprint
|
|
@@ -4,10 +4,10 @@ import "../chunk-J5LGTIGS.mjs";
|
|
|
4
4
|
import { Capability } from "@dxos/app-framework";
|
|
5
5
|
var AppGraphBuilder = Capability.lazy("AppGraphBuilder", () => import("../app-graph-builder-7AWFCEQF.mjs"));
|
|
6
6
|
var BlueprintDefinition = Capability.lazy("BlueprintDefinition", () => import("../blueprint-definition-T33SBPP2.mjs"));
|
|
7
|
-
var CreateObject = Capability.lazy("CreateObject", () => import("../create-object-
|
|
8
|
-
var Compiler = Capability.lazy("Compiler", () => import("../compiler-
|
|
9
|
-
var OperationHandler = Capability.lazy("OperationHandler", () => import("../operation-handler-
|
|
10
|
-
var ReactSurface = Capability.lazy("ReactSurface", () => import("../react-surface-
|
|
7
|
+
var CreateObject = Capability.lazy("CreateObject", () => import("../create-object-FZM5ASWM.mjs"));
|
|
8
|
+
var Compiler = Capability.lazy("Compiler", () => import("../compiler-ODK4UA2N.mjs"));
|
|
9
|
+
var OperationHandler = Capability.lazy("OperationHandler", () => import("../operation-handler-X44IGZXS.mjs"));
|
|
10
|
+
var ReactSurface = Capability.lazy("ReactSurface", () => import("../react-surface-ACNZ35FV.mjs"));
|
|
11
11
|
var ScriptSettings = Capability.lazy("ScriptSettings", () => import("../settings-VJBW4OMK.mjs"));
|
|
12
12
|
export {
|
|
13
13
|
AppGraphBuilder,
|
|
@@ -4,9 +4,9 @@ import "../chunk-J5LGTIGS.mjs";
|
|
|
4
4
|
import { Capability } from "@dxos/app-framework";
|
|
5
5
|
var AppGraphBuilder = Capability.lazy("AppGraphBuilder", () => import("../app-graph-builder-7AWFCEQF.mjs"));
|
|
6
6
|
var BlueprintDefinition = Capability.lazy("BlueprintDefinition", () => import("../blueprint-definition-T33SBPP2.mjs"));
|
|
7
|
-
var CreateObject = Capability.lazy("CreateObject", () => import("../create-object-
|
|
8
|
-
var Compiler = Capability.lazy("Compiler", () => import("../compiler-
|
|
9
|
-
var OperationHandler = Capability.lazy("OperationHandler", () => import("../operation-handler-
|
|
7
|
+
var CreateObject = Capability.lazy("CreateObject", () => import("../create-object-FZM5ASWM.mjs"));
|
|
8
|
+
var Compiler = Capability.lazy("Compiler", () => import("../compiler-ODK4UA2N.mjs"));
|
|
9
|
+
var OperationHandler = Capability.lazy("OperationHandler", () => import("../operation-handler-X44IGZXS.mjs"));
|
|
10
10
|
export {
|
|
11
11
|
AppGraphBuilder,
|
|
12
12
|
BlueprintDefinition,
|
|
@@ -10,7 +10,11 @@ var defaultOptions = {
|
|
|
10
10
|
"DOM",
|
|
11
11
|
"es2022"
|
|
12
12
|
],
|
|
13
|
-
target: ts.ScriptTarget.ES2022
|
|
13
|
+
target: ts.ScriptTarget.ES2022,
|
|
14
|
+
// Override `@typescript/vfs`'s default of `NodeJs` (== deprecated `node10`).
|
|
15
|
+
// TypeScript 6 throws on that as a `getCompilerOptionsDiagnostics()` error,
|
|
16
|
+
// which surfaces as an unhandled rejection inside the storybook task.
|
|
17
|
+
moduleResolution: ts.ModuleResolutionKind.Bundler
|
|
14
18
|
};
|
|
15
19
|
var Compiler = class {
|
|
16
20
|
_options;
|
|
@@ -34,11 +38,11 @@ var Compiler = class {
|
|
|
34
38
|
this._env = createVirtualTypeScriptEnvironment(system, rootFiles, ts, this._options);
|
|
35
39
|
}
|
|
36
40
|
get environment() {
|
|
37
|
-
invariant(this._env, "Compiler environment not initialized.", { "~LogMeta": "~LogMeta", F: __dxlog_file, L:
|
|
41
|
+
invariant(this._env, "Compiler environment not initialized.", { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 48, S: this, A: ["this._env", "'Compiler environment not initialized.'"] });
|
|
38
42
|
return this._env;
|
|
39
43
|
}
|
|
40
44
|
setFile(fileName, content) {
|
|
41
|
-
invariant(this._fsMap, "File system map not initialized.", { "~LogMeta": "~LogMeta", F: __dxlog_file, L:
|
|
45
|
+
invariant(this._fsMap, "File system map not initialized.", { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 52, S: this, A: ["this._fsMap", "'File system map not initialized.'"] });
|
|
42
46
|
this.environment.createFile(fileName, content);
|
|
43
47
|
}
|
|
44
48
|
compile(fileName) {
|
|
@@ -49,4 +53,4 @@ var Compiler = class {
|
|
|
49
53
|
export {
|
|
50
54
|
Compiler
|
|
51
55
|
};
|
|
52
|
-
//# sourceMappingURL=chunk-
|
|
56
|
+
//# sourceMappingURL=chunk-2REUEDUA.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/compiler/compiler.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport {\n type VirtualTypeScriptEnvironment,\n createDefaultMapFromCDN,\n createSystem,\n createVirtualTypeScriptEnvironment,\n} from '@typescript/vfs';\nimport ts from 'typescript';\n\nimport { invariant } from '@dxos/invariant';\n\nconst GLOBALS = 'globals.d.ts';\n\n/** TS version hosted on playgroundcdn.typescriptlang.org used to fetch lib .d.ts files.\n * Pinned to 5.6.3 because 5.7+ removed lib.es2022.sharedmemory.d.ts from the CDN.\n * The remaining 404s (lib.core.d.ts, lib.core.es6/7.d.ts, lib.es7.d.ts) are phantom\n * entries in @typescript/vfs's hardcoded file list and are harmlessly caught.\n */\nconst CDN_TS_VERSION = '5.6.3';\n\nconst defaultOptions: ts.CompilerOptions = {\n lib: ['DOM', 'es2022'],\n target: ts.ScriptTarget.ES2022,\n // Override `@typescript/vfs`'s default of `NodeJs` (== deprecated `node10`).\n // TypeScript 6 throws on that as a `getCompilerOptionsDiagnostics()` error,\n // which surfaces as an unhandled rejection inside the storybook task.\n moduleResolution: ts.ModuleResolutionKind.Bundler,\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(globals?: string): Promise<void> {\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, CDN_TS_VERSION, true, ts);\n if (globals) {\n this._fsMap.set(GLOBALS, globals);\n }\n\n const rootFiles = globals ? [GLOBALS] : [];\n const system = createSystem(this._fsMap);\n this._env = createVirtualTypeScriptEnvironment(system, rootFiles, 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): void {\n invariant(this._fsMap, 'File system map not initialized.');\n this.environment.createFile(fileName, content);\n }\n\n compile(fileName: string): ts.EmitOutput {\n return this.environment.languageService.getEmitOutput(fileName);\n }\n}\n"],
|
|
5
|
+
"mappings": ";AAIA,SAEEA,yBACAC,cACAC,0CACK;AACP,OAAOC,QAAQ;AAEf,SAASC,iBAAiB;AAE1B,IAAA,eAAgB;;AAUdC,IAAK,iBAAA;qBAAC;OAAO;IAAS;IACtBC;EACA;EACA,QAAA,GAAA,aAAA;;;;EAKF,kBAAaC,GAAAA,qBAAAA;;AACHC,IAA+C,WAA/CA,MAA+C;EAC/CC;EAER;;EAA6E,YAAA,WAAA,gBAAA;AAE7E,SAAMC,WAAWC;;mBAEb,SAAA;AACF,QAAA,KAAA,MAAA;AAEA;IACA;SAGE,SAAKF,MAAWG,wBAASD,KAAAA,UAAAA,gBAAAA,MAAAA,EAAAA;AAC3B,QAAA,SAAA;AAEA,WAAME,OAAAA,IAAYF,SAAU,OAAA;;UAAc,YAAA,UAAA;MAC1C;IACA,IAAI,CAACH;AACP,UAAA,SAAA,aAAA,KAAA,MAAA;AAEIM,SAAAA,OAAAA,mCAAc,QAAA,WAAA,IAAA,KAAA,QAAA;;MAEhB,cAAYN;AACd,cAAA,KAAA,MAAA,yCAAA,EAAA,YAAA,YAAA,GAAA,cAAA,GAAA,IAAA,GAAA,MAAA,GAAA,CAAA,aAAA,yCAAA,EAAA,CAAA;AAEAO,WAAQC,KAAgB;;UAElB,UAACF,SAAYG;AACnB,cAAA,KAAA,QAAA,oCAAA,EAAA,YAAA,YAAA,GAAA,cAAA,GAAA,IAAA,GAAA,MAAA,GAAA,CAAA,eAAA,oCAAA,EAAA,CAAA;AAEAC,SAAQF,YAAiC,WAAA,UAAA,OAAA;;EAEzC,QAAA,UAAA;AACF,WAAA,KAAA,YAAA,gBAAA,cAAA,QAAA;;;",
|
|
6
|
+
"names": ["createDefaultMapFromCDN", "createSystem", "createVirtualTypeScriptEnvironment", "ts", "invariant", "lib", "target", "Compiler", "_env", "_fsMap", "initialize", "globals", "GLOBALS", "rootFiles", "environment", "setFile", "fileName", "createFile", "compile"]
|
|
7
|
+
}
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
QueryDeployedFunctions,
|
|
9
9
|
Read,
|
|
10
10
|
Update
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-TRKXIP2Q.mjs";
|
|
12
12
|
|
|
13
13
|
// src/blueprints/script-blueprint.ts
|
|
14
14
|
import { Blueprint, Template } from "@dxos/compute";
|
|
@@ -49,4 +49,4 @@ var script_blueprint_default = blueprint;
|
|
|
49
49
|
export {
|
|
50
50
|
script_blueprint_default
|
|
51
51
|
};
|
|
52
|
-
//# sourceMappingURL=chunk-
|
|
52
|
+
//# sourceMappingURL=chunk-BDHDBPVM.mjs.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
templates
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-H2BRWQMY.mjs";
|
|
4
4
|
import {
|
|
5
5
|
__export
|
|
6
6
|
} from "./chunk-J5LGTIGS.mjs";
|
|
@@ -28,7 +28,7 @@ __export(Notebook_exports, {
|
|
|
28
28
|
});
|
|
29
29
|
import * as Schema2 from "effect/Schema";
|
|
30
30
|
import { Routine } from "@dxos/compute";
|
|
31
|
-
import { Annotation, Obj, Ref, Type } from "@dxos/echo";
|
|
31
|
+
import { DXN, Annotation, Obj, Ref, Type } from "@dxos/echo";
|
|
32
32
|
import { FormInputAnnotation } from "@dxos/echo/internal";
|
|
33
33
|
import { LabelAnnotation } from "@dxos/echo/internal";
|
|
34
34
|
import { Graph } from "@dxos/plugin-explorer";
|
|
@@ -45,15 +45,12 @@ var Cell = Schema2.Struct({
|
|
|
45
45
|
var Notebook = Schema2.Struct({
|
|
46
46
|
name: Schema2.String.pipe(Schema2.optional),
|
|
47
47
|
cells: Cell.pipe(Schema2.Array, FormInputAnnotation.set(false))
|
|
48
|
-
}).pipe(
|
|
49
|
-
typename: "org.dxos.type.notebook",
|
|
50
|
-
version: "0.1.0"
|
|
51
|
-
}), LabelAnnotation.set([
|
|
48
|
+
}).pipe(LabelAnnotation.set([
|
|
52
49
|
"name"
|
|
53
50
|
]), Annotation.IconAnnotation.set({
|
|
54
51
|
icon: "ph--notebook--regular",
|
|
55
52
|
hue: "sky"
|
|
56
|
-
}));
|
|
53
|
+
}), Type.makeObject(DXN.make("org.dxos.type.notebook", "0.1.0")));
|
|
57
54
|
var make = (props = {
|
|
58
55
|
cells: []
|
|
59
56
|
}) => Obj.make(Notebook, props);
|
|
@@ -87,9 +84,9 @@ __export(ScriptOperation_exports, {
|
|
|
87
84
|
});
|
|
88
85
|
import * as Schema3 from "effect/Schema";
|
|
89
86
|
import { Script, Operation } from "@dxos/compute";
|
|
90
|
-
import { Database } from "@dxos/echo";
|
|
87
|
+
import { Database, Type as Type2, DXN as DXN2 } from "@dxos/echo";
|
|
91
88
|
import { meta as meta3 } from "#meta";
|
|
92
|
-
var
|
|
89
|
+
var makeKey = (name) => DXN2.make(`${meta3.id}.operation.${name}`);
|
|
93
90
|
var ScriptProps = Schema3.Struct({
|
|
94
91
|
name: Schema3.optional(Schema3.String),
|
|
95
92
|
gistUrl: Schema3.optional(Schema3.String.annotations({
|
|
@@ -104,14 +101,15 @@ var NotebookProps = Schema3.Struct({
|
|
|
104
101
|
});
|
|
105
102
|
var CreateScript = Operation.make({
|
|
106
103
|
meta: {
|
|
107
|
-
key:
|
|
108
|
-
name: "Create Script"
|
|
104
|
+
key: makeKey("createScript"),
|
|
105
|
+
name: "Create Script",
|
|
106
|
+
icon: "ph--code--regular"
|
|
109
107
|
},
|
|
110
108
|
input: Schema3.extend(ScriptProps, Schema3.Struct({
|
|
111
109
|
db: Database.Database
|
|
112
110
|
})),
|
|
113
111
|
output: Schema3.Struct({
|
|
114
|
-
object: Script.Script
|
|
112
|
+
object: Type2.getSchema(Script.Script)
|
|
115
113
|
})
|
|
116
114
|
});
|
|
117
115
|
|
|
@@ -122,4 +120,4 @@ export {
|
|
|
122
120
|
ScriptEvents_exports,
|
|
123
121
|
ScriptOperation_exports
|
|
124
122
|
};
|
|
125
|
-
//# sourceMappingURL=chunk-
|
|
123
|
+
//# sourceMappingURL=chunk-C4O7EV6M.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/types/Settings.ts", "../../../src/types/Notebook.ts", "../../../src/types/ScriptCapabilities.ts", "../../../src/types/ScriptEvents.ts", "../../../src/types/ScriptOperation.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\n// @import-as-namespace\n\nimport * as Schema from 'effect/Schema';\n\nimport { EditorInputMode } from '@dxos/ui-editor/types';\n\nexport const Settings = Schema.mutable(\n Schema.Struct({\n editorInputMode: EditorInputMode.annotations({\n title: 'Editor input mode',\n description: 'Choose the keybinding style for the script editor.',\n }),\n }),\n);\n\nexport interface Settings extends Schema.Schema.Type<typeof Settings> {}\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\n\nimport { Routine } from '@dxos/compute';\nimport { DXN, Annotation, Obj, Ref, Type } from '@dxos/echo';\nimport { FormInputAnnotation } from '@dxos/echo/internal';\nimport { LabelAnnotation } from '@dxos/echo/internal';\nimport { Graph } from '@dxos/plugin-explorer';\nimport { Text } from '@dxos/schema';\n\nexport type CellType = 'markdown' | 'script' | 'query' | 'prompt' | 'view';\n\nexport const Cell = Schema.Struct({\n id: Schema.String,\n type: Schema.String,\n name: Schema.optional(Schema.String),\n // TODO(burdon): Union type.\n source: Schema.optional(Ref.Ref(Text.Text)),\n prompt: Schema.optional(Ref.Ref(Routine.Routine)),\n graph: Schema.optional(Ref.Ref(Graph.Graph)),\n});\n\nexport type Cell = Schema.Schema.Type<typeof Cell>;\n\nexport const Notebook = Schema.Struct({\n name: Schema.String.pipe(Schema.optional),\n cells: Cell.pipe(Schema.Array, FormInputAnnotation.set(false)),\n}).pipe(\n LabelAnnotation.set(['name']),\n Annotation.IconAnnotation.set({ icon: 'ph--notebook--regular', hue: 'sky' }),\n Type.makeObject(DXN.make('org.dxos.type.notebook', '0.1.0')),\n);\n\nexport type Notebook = Type.InstanceType<typeof Notebook>;\n\nexport const make = (props: Obj.MakeProps<typeof Notebook> = { cells: [] }): Notebook => Obj.make(Notebook, props);\n", "//\n// Copyright 2025 DXOS.org\n//\n\n// @import-as-namespace\n\nimport { type Atom } from '@effect-atom/atom-react';\n\nimport { Capability } from '@dxos/app-framework';\n\nimport { meta } from '#meta';\n\nimport { type Compiler as CompilerType } from '../compiler';\n\n// Inline import to avoid `Settings` namespace alias colliding with the\n// `Settings` capability export below.\nexport const Settings = Capability.make<Atom.Writable<import('./Settings').Settings>>(`${meta.id}.capability.settings`);\nexport const Compiler = Capability.make<CompilerType>(`${meta.id}.capability.compiler`);\n", "//\n// Copyright 2025 DXOS.org\n//\n\n// @import-as-namespace\n\nimport { ActivationEvent } from '@dxos/app-framework';\n\nimport { meta } from '#meta';\n\nexport const SetupCompiler = ActivationEvent.make(`${meta.id}.event.setup-compiler`);\n", "//\n// Copyright 2025 DXOS.org\n//\n\n// @import-as-namespace\n\nimport * as Schema from 'effect/Schema';\n\nimport { Script, Operation } from '@dxos/compute';\nimport { Database, Type, DXN } from '@dxos/echo';\n\nimport { meta } from '#meta';\n\nimport { templates } from '../templates';\n\nconst makeKey = (name: string) => DXN.make(`${meta.id}.operation.${name}`);\n\nexport const ScriptProps = Schema.Struct({\n name: Schema.optional(Schema.String),\n gistUrl: Schema.optional(Schema.String.annotations({ title: 'Import from Gist (url)' })),\n initialTemplateId: Schema.Literal(...templates.map(({ id }) => id)).pipe(\n Schema.annotations({ title: 'Template' }),\n Schema.optional,\n ),\n});\n\nexport const NotebookProps = Schema.Struct({\n name: Schema.optional(Schema.String),\n});\n\nexport const CreateScript = Operation.make({\n meta: { key: makeKey('createScript'), name: 'Create Script', icon: 'ph--code--regular' },\n input: Schema.extend(\n ScriptProps,\n Schema.Struct({\n db: Database.Database,\n }),\n ),\n output: Schema.Struct({\n object: Type.getSchema(Script.Script),\n }),\n});\n"],
|
|
5
|
+
"mappings": ";;;;;;;;AAAA;;;;AAMA,YAAYA,YAAY;AAExB,SAASC,uBAAuB;AAEzB,IAAMC,WAAkBC,eACtBC,cAAO;EACZC,iBAAiBJ,gBAAgBK,YAAY;IAC3CC,OAAO;IACPC,aAAa;EACf,CAAA;AACF,CAAA,CAAA;;;AChBF;;;;;;AAIA,YAAYC,aAAY;AAExB,SAASC,eAAe;AACxB,SAASC,KAAKC,YAAYC,KAAKC,KAAKC,YAAY;AAChD,SAASC,2BAA2B;AACpC,SAASC,uBAAuB;AAChC,SAASC,aAAa;AACtB,SAASC,YAAY;AAId,IAAMC,OAAcC,eAAO;EAChCC,IAAWC;EACXC,MAAaD;EACbE,MAAaC,iBAAgBH,cAAM;;EAEnCI,QAAeD,iBAASZ,IAAIA,IAAIK,KAAKA,IAAI,CAAA;EACzCS,QAAeF,iBAASZ,IAAIA,IAAIJ,QAAQA,OAAO,CAAA;EAC/CmB,OAAcH,iBAASZ,IAAIA,IAAII,MAAMA,KAAK,CAAA;AAC5C,CAAA;AAIO,IAAMY,WAAkBT,eAAO;EACpCI,MAAaF,eAAOQ,KAAYL,gBAAQ;EACxCM,OAAOZ,KAAKW,KAAYE,eAAOjB,oBAAoBkB,IAAI,KAAA,CAAA;AACzD,CAAA,EAAGH,KACDd,gBAAgBiB,IAAI;EAAC;CAAO,GAC5BtB,WAAWuB,eAAeD,IAAI;EAAEE,MAAM;EAAyBC,KAAK;AAAM,CAAA,GAC1EtB,KAAKuB,WAAW3B,IAAI4B,KAAK,0BAA0B,OAAA,CAAA,CAAA;AAK9C,IAAMA,OAAO,CAACC,QAAwC;EAAER,OAAO,CAAA;AAAG,MAAgBnB,IAAI0B,KAAKT,UAAUU,KAAAA;;;ACtC5G;;;kBAAAC;;AAQA,SAASC,kBAAkB;AAE3B,SAASC,YAAY;AAMd,IAAMF,YAAWC,WAAWE,KAAmD,GAAGD,KAAKE,EAAE,sBAAsB;AAC/G,IAAMC,WAAWJ,WAAWE,KAAmB,GAAGD,KAAKE,EAAE,sBAAsB;;;ACjBtF;;;;AAMA,SAASE,uBAAuB;AAEhC,SAASC,QAAAA,aAAY;AAEd,IAAMC,gBAAgBF,gBAAgBG,KAAK,GAAGF,MAAKG,EAAE,uBAAuB;;;ACVnF;;;;;;AAMA,YAAYC,aAAY;AAExB,SAASC,QAAQC,iBAAiB;AAClC,SAASC,UAAUC,QAAAA,OAAMC,OAAAA,YAAW;AAEpC,SAASC,QAAAA,aAAY;AAIrB,IAAMC,UAAU,CAACC,SAAiBC,KAAIC,KAAK,GAAGC,MAAKC,EAAE,cAAcJ,IAAAA,EAAM;AAElE,IAAMK,cAAqBC,eAAO;EACvCN,MAAaO,iBAAgBC,cAAM;EACnCC,SAAgBF,iBAAgBC,eAAOE,YAAY;IAAEC,OAAO;EAAyB,CAAA,CAAA;EACrFC,mBAA0BC,gBAAO,GAAIC,UAAUC,IAAI,CAAC,EAAEX,GAAE,MAAOA,EAAAA,CAAAA,EAAKY,KAC3DN,oBAAY;IAAEC,OAAO;EAAW,CAAA,GAChCJ,gBAAQ;AAEnB,CAAA;AAEO,IAAMU,gBAAuBX,eAAO;EACzCN,MAAaO,iBAAgBC,cAAM;AACrC,CAAA;AAEO,IAAMU,eAAeC,UAAUjB,KAAK;EACzCC,MAAM;IAAEiB,KAAKrB,QAAQ,cAAA;IAAiBC,MAAM;IAAiBqB,MAAM;EAAoB;EACvFC,OAAcC,eACZlB,aACOC,eAAO;IACZkB,IAAIC,SAASA;EACf,CAAA,CAAA;EAEFC,QAAepB,eAAO;IACpBqB,QAAQC,MAAKC,UAAUC,OAAOA,MAAM;EACtC,CAAA;AACF,CAAA;",
|
|
6
|
+
"names": ["Schema", "EditorInputMode", "Settings", "mutable", "Struct", "editorInputMode", "annotations", "title", "description", "Schema", "Routine", "DXN", "Annotation", "Obj", "Ref", "Type", "FormInputAnnotation", "LabelAnnotation", "Graph", "Text", "Cell", "Struct", "id", "String", "type", "name", "optional", "source", "prompt", "graph", "Notebook", "pipe", "cells", "Array", "set", "IconAnnotation", "icon", "hue", "makeObject", "make", "props", "Settings", "Capability", "meta", "make", "id", "Compiler", "ActivationEvent", "meta", "SetupCompiler", "make", "id", "Schema", "Script", "Operation", "Database", "Type", "DXN", "meta", "makeKey", "name", "DXN", "make", "meta", "id", "ScriptProps", "Struct", "optional", "String", "gistUrl", "annotations", "title", "initialTemplateId", "Literal", "templates", "map", "pipe", "NotebookProps", "CreateScript", "Operation", "key", "icon", "input", "extend", "db", "Database", "output", "object", "Type", "getSchema", "Script"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
// raw-loader:/__w/dxos/dxos/packages/plugins/plugin-script/src/templates/anthropic.ts?raw
|
|
2
|
+
var anthropic_default = "//\n// Copyright 2025 DXOS.org\n//\n\nimport * as LanguageModel from '@effect/ai/LanguageModel';\nimport * as Chunk from 'effect/Chunk';\nimport * as Effect from 'effect/Effect';\nimport * as Schema from 'effect/Schema';\nimport * as Stream from 'effect/Stream';\n\nimport { AiService } from '@dxos/ai';\nimport { Operation } from '@dxos/compute';\nimport { DXN } from '@dxos/keys';\n\nconst Anthropic = Operation.make({\n meta: {\n key: DXN.make('org.dxos.script.anthropic'),\n name: 'Anthropic Chat',\n description: 'Chat with Anthropic',\n },\n input: Schema.Struct({\n message: Schema.String,\n }),\n output: Schema.Any,\n services: [AiService.AiService],\n});\n\nexport default Anthropic.pipe(\n Operation.withHandler(\n Effect.fn(function* ({ message }) {\n const model = (yield* AiService.AiService).model('@anthropic/claude-sonnet-4-5');\n\n //\n // Basic example.\n //\n const { text } = yield* LanguageModel.generateText({ prompt: message }).pipe(Effect.provide(model));\n\n //\n // Streaming example.\n //\n const parts = yield* LanguageModel.streamText({\n prompt: 'Count from 1 to 5, one number per line.',\n }).pipe(Stream.runCollect, Effect.map(Chunk.toArray), Effect.provide(model));\n const textDeltas = parts.filter((p) => p.type === 'text-delta');\n const fullText = textDeltas.map((p) => (p as { delta: string }).delta).join('');\n\n return { response: text, streamText: fullText };\n }),\n ),\n);\n";
|
|
3
|
+
|
|
4
|
+
// raw-loader:/__w/dxos/dxos/packages/plugins/plugin-script/src/templates/chess-bot.ts?raw
|
|
5
|
+
var chess_bot_default = "//\n// Copyright 2025 DXOS.org\n//\n\nimport { Chess as ChessJS } from 'chess.js';\nimport * as Effect from 'effect/Effect';\nimport * as Schema from 'effect/Schema';\n\nimport { Operation } from '@dxos/compute';\nimport { Database, Obj, DXN } from '@dxos/echo';\nimport { Chess } from '@dxos/plugin-chess';\nimport { GameRef, Game, loadGame } from '@dxos/plugin-game';\n\nconst ChessBot = Operation.make({\n meta: {\n key: DXN.make('org.dxos.script.chessBot'),\n name: 'Chess Bot',\n description: 'Plays a random move in a chess game.',\n },\n input: Schema.Struct({\n game: GameRef(Chess.State).annotations({\n description: 'The chess game to comment on.',\n }),\n player: Schema.optional(Schema.Literal('white', 'black')).annotations({\n description: 'The player to play the game as.',\n }),\n }),\n output: Schema.Struct({\n state: Schema.String.annotations({\n description: 'The state of the game as an ASCII art board.',\n }),\n }),\n types: [Game, Chess.State],\n services: [Database.Service],\n});\n\nexport default ChessBot.pipe(\n Operation.withHandler(\n Effect.fnUntraced(function* ({ game, player = 'black' }) {\n const { variant } = yield* loadGame(game, Chess.State);\n const chess = new ChessJS();\n chess.loadPgn(variant.pgn ?? '');\n if (chess.turn() !== (player === 'white' ? 'w' : 'b')) {\n return { state: chess.ascii() };\n }\n\n const moves = chess.moves({ verbose: true });\n const move = moves[Math.floor(Math.random() * moves.length)];\n if (!move) {\n return { state: chess.ascii() };\n }\n\n chess.move(move.san);\n const newPgn = chess.pgn();\n Obj.update(variant, (variant) => {\n const mutable = variant as Obj.Mutable<typeof variant>;\n mutable.pgn = newPgn;\n });\n yield* Database.flush();\n return { state: chess.ascii() };\n }),\n ),\n);\n";
|
|
6
|
+
|
|
7
|
+
// raw-loader:/__w/dxos/dxos/packages/plugins/plugin-script/src/templates/commentary.ts?raw
|
|
8
|
+
var commentary_default = "//\n// Copyright 2025 DXOS.org\n//\n\nimport * as A from '@automerge/automerge';\nimport { Chess as ChessJS } from 'chess.js';\nimport * as Array from 'effect/Array';\nimport * as Effect from 'effect/Effect';\nimport * as Function from 'effect/Function';\nimport * as Layer from 'effect/Layer';\nimport * as Option from 'effect/Option';\nimport * as Schema from 'effect/Schema';\n\nimport { AiService, ConsolePrinter, ToolExecutionService, ToolResolverService } from '@dxos/ai';\nimport { RootCollectionAnnotation } from '@dxos/app-toolkit';\nimport { AiRequest, GenerationObserver } from '@dxos/assistant';\nimport { Trace, Operation, OperationRegistry } from '@dxos/compute';\nimport { Annotation, Collection, Database, DXN, Filter, Obj, Ref, Relation, URI } from '@dxos/echo';\nimport { createDocAccessor } from '@dxos/echo-db';\nimport { log } from '@dxos/log';\nimport { Chess } from '@dxos/plugin-chess';\nimport { Game, GameRef, loadGame } from '@dxos/plugin-game';\nimport { Markdown } from '@dxos/plugin-markdown';\nimport { Text } from '@dxos/schema';\nimport { HasSubject } from '@dxos/types';\nimport { trim } from '@dxos/util';\n\nconst Commentary = Operation.make({\n meta: {\n key: DXN.make('org.dxos.function.chess.commentary'),\n name: 'Commentary',\n description: 'Adds commentary about the most recent move to a markdown document associated with the chess game.',\n },\n input: Schema.Struct({\n game: GameRef(Chess.State).annotations({\n description: 'The chess game to comment on.',\n }),\n }),\n output: Schema.Union(\n Schema.Struct({\n documentId: URI.Schema.annotations({\n description: 'The ID of the markdown document that was updated or created.',\n }),\n commentary: Schema.String.annotations({\n description: 'The commentary that was added.',\n }),\n }),\n Schema.Void.annotations({\n description: 'Function did not find anything to comment on.',\n }),\n ),\n types: [Game, Chess.State, Markdown.Document, Text.Text, HasSubject.HasSubject, Collection.Collection],\n services: [AiService.AiService, Database.Service],\n});\n\nexport default Commentary.pipe(\n Operation.withHandler(\n Effect.fnUntraced(\n function* ({ game: gameRef }) {\n // Load the game and its Chess variant state.\n log.info('load game', { gameRef });\n const { game: chessGame, variant: chessState } = yield* loadGame(gameRef, Chess.State);\n\n // Load the chess position from PGN or FEN.\n const chess = new ChessJS();\n if (chessState.pgn) {\n chess.loadPgn(chessState.pgn);\n } else if (chessState.fen) {\n chess.load(chessState.fen);\n } else {\n log.info('Early return: no pgn or fen');\n return;\n }\n\n // Get the most recent move\n const history = chess.history({ verbose: true });\n if (history.length === 0) {\n throw new Error('No moves have been played yet');\n }\n const lastMove = history[history.length - 1];\n const moveNumber = Math.ceil(history.length / 2);\n const isWhiteMove = history.length % 2 === 1;\n const player = isWhiteMove ? 'White' : 'Black';\n const moveNotation = lastMove.san;\n\n // Generate AI commentary about the move\n const result = yield* new AiRequest.Request({\n observer: GenerationObserver.fromPrinter(new ConsolePrinter({ tag: 'chess-commentary' })),\n }).run({\n prompt:\n `Comment on this chess move as if you're commentating a live match for an audience:\\n\\n` +\n `Move ${moveNumber}: ${player} plays ${moveNotation} (${lastMove.from} to ${lastMove.to})${lastMove.captured ? `, capturing ${lastMove.captured}` : ''}\\n` +\n `Current position: ${chess.fen()}\\n` +\n `${chess.isCheck() ? 'The king is in check! ' : ''}` +\n `${chess.isCheckmate() ? 'CHECKMATE! ' : ''}` +\n `${chess.isStalemate() ? 'STALEMATE! ' : ''}` +\n `\\nGame so far:\\n${chess.pgn()}`,\n system: COMMENTARY_SYSTEM_PROMPT,\n history: [],\n });\n\n const commentaryText = Function.pipe(\n result,\n Array.findLast((msg) => msg.sender.role === 'assistant' && msg.blocks.some((block) => block._tag === 'text')),\n Option.flatMap((msg) =>\n Function.pipe(\n msg.blocks,\n Array.findLast((block) => block._tag === 'text'),\n Option.map((block) => block.text),\n ),\n ),\n Option.getOrThrowWith(() => new Error('No commentary generated')),\n );\n\n const commentary = `## Move ${moveNumber}: ${player} plays ${moveNotation}\\n\\n${commentaryText}\\n\\n`;\n log.info('commentary', { commentary });\n\n // TODO(wittjosiah): Functions currently don't support traversals.\n // const docs = yield* Database.runQuery(\n // Query.select(Filter.id(chessGame.id)).targetOf(HasSubject.HasSubject).source(),\n // ).pipe(Effect.map((objects) => objects.filter((object) => Obj.instanceOf(Markdown.Document, object))));\n const docs = yield* Database.runQuery(Filter.type(HasSubject.HasSubject)).pipe(\n Effect.map((relations) =>\n relations.filter((relation) => {\n // TODO(wittjosiah): This is a workaround for getTarget not handling deleted objects.\n try {\n log.info('relation', {\n source: Obj.getURI(Relation.getTarget(relation)),\n game: Obj.getURI(chessGame),\n });\n return Obj.getURI(Relation.getTarget(relation)) === Obj.getURI(chessGame);\n } catch {\n return false;\n }\n }),\n ),\n Effect.map((relations) =>\n relations\n .map((relation) => {\n // TODO(wittjosiah): This is a workaround for getSource not handling deleted objects.\n try {\n return Relation.getSource(relation);\n } catch {\n return undefined;\n }\n })\n .filter((source) => source !== undefined),\n ),\n Effect.map((sources) => {\n const docs = sources.filter((source) => Obj.instanceOf(Markdown.Document, source));\n log.info('docs', { sources, docs });\n return docs;\n }),\n );\n log.info('docs', { count: docs.length });\n\n let document: Markdown.Document;\n if (docs.length === 0) {\n // TODO(wittjosiah): Deploy fails if `SpaceProperties` schema is imported because its from `client-protocol`.\n const [properties] = yield* Database.runQuery(Filter.typename('org.dxos.type.spaceProperties'));\n const rootCollectionRef = Annotation.get(properties, RootCollectionAnnotation).pipe(Option.getOrUndefined);\n const rootCollection = rootCollectionRef\n ? yield* Database.load<Collection.Collection>(rootCollectionRef)\n : undefined;\n\n log.info('rootCollection', { rootCollection });\n\n // Create a new markdown document\n const gameName = chessGame.name || 'Chess Game';\n document = yield* Database.add(\n Markdown.make({\n name: `${gameName} Commentary`,\n content: `# ${gameName} Commentary\\n\\n${commentary}`,\n }),\n );\n\n const documentRef = Ref.make(document);\n if (rootCollection) {\n Obj.update(rootCollection, (rootCollection) => {\n rootCollection.objects.push(documentRef);\n });\n }\n\n // Create the HasSubject relation\n yield* Database.add(\n Relation.make(HasSubject.HasSubject, {\n [Relation.Source]: document,\n [Relation.Target]: chessGame,\n completedAt: new Date().toISOString(),\n }),\n );\n } else {\n document = docs[0];\n\n // Load the text content and append the commentary\n const text = yield* Database.load(document.content);\n const accessor = createDocAccessor(text, ['content']);\n accessor.handle.change((doc: A.Doc<Text.Text>) => {\n A.splice(doc, accessor.path.slice(), text.content.length, 0, commentary);\n });\n }\n\n log.info('result', { documentId: Obj.getURI(document), commentary });\n\n yield* Database.flush();\n\n return {\n documentId: Obj.getURI(document),\n commentary,\n };\n },\n Effect.provide(\n Layer.mergeAll(\n AiService.model('@anthropic/claude-haiku-4-5'),\n ToolResolverService.layerEmpty,\n ToolExecutionService.layerEmpty,\n Trace.writerLayerNoop,\n Database.notAvailable,\n Layer.succeed(Operation.Service, {\n invoke: () => Effect.die('Not available.'),\n schedule: () => Effect.die('Not available.'),\n invokePromise: async () => ({ error: new Error('Not available.') }),\n } as any),\n Layer.succeed(OperationRegistry.Service, { resolve: () => Effect.succeed(undefined) } as any),\n ),\n ),\n ),\n ),\n);\n\nconst COMMENTARY_SYSTEM_PROMPT = trim`\n You are a professional chess commentator providing live commentary for a chess match.\n\n # Style\n - Write in an engaging, enthusiastic style as if commentating for a live audience\n - Be concise but informative (2-4 sentences)\n - Explain the strategic implications of the move\n - Note any tactical elements (captures, threats, checks)\n - Comment on the position and what it means for the game\n\n # Format\n - Write in plain text (no markdown formatting in the commentary itself)\n - Be natural and conversational\n - Use chess terminology appropriately but keep it accessible\n\n # Special Situations\n - If it's checkmate, express excitement about the conclusion\n - If it's check, note the pressure on the king\n - If a piece is captured, mention the material exchange\n - Comment on the development of pieces and control of key squares when relevant\n`;\n";
|
|
9
|
+
|
|
10
|
+
// raw-loader:/__w/dxos/dxos/packages/plugins/plugin-script/src/templates/data-generator.ts?raw
|
|
11
|
+
var data_generator_default = "//\n// Copyright 2025 DXOS.org\n//\n\n// @ts-ignore\nimport { Expando, S, create, defineFunction } from 'dxos:functions';\n// @ts-ignore\nimport { randText } from 'https://esm.sh/@ngneat/falso@7.1.1?bundle=false';\n\nexport default defineFunction({\n key: 'org.dxos.script.data-generator',\n name: 'Data Generator',\n inputSchema: S.Struct({\n documentAmount: S.optional(S.Number),\n textSize: S.optional(S.Number),\n mutationAmount: S.optional(S.Number),\n waitAfterCreation: S.optional(S.Number),\n }),\n\n outputSchema: S.Struct({}),\n\n handler: async ({\n data: { documentAmount = 1, textSize = 10, mutationAmount = 0, waitAfterCreation = 10_000 },\n context: { space },\n }: any) => {\n space.db.graph.registry.add([Expando]);\n const result: Record<string, any> = {};\n const objects: Expando[] = [];\n\n // Create objects.\n for (let i = 0; i < documentAmount; i++) {\n const obj = space.db.add(\n create(Expando, {\n name: 'scriptGenerated',\n content: randText({ charCount: textSize }),\n }),\n );\n objects.push(obj);\n const objectResult: any = {};\n // Mutate the object.\n for (let i = 0; i < mutationAmount; i++) {\n obj.content = randText({ charCount: textSize });\n }\n objectResult.mutations = mutationAmount;\n objectResult.contentLength = obj.content.length;\n result[obj.id] = objectResult;\n }\n\n // Flush and wait for data to propagate.\n await space.db.flush();\n await new Promise((resolve) => setTimeout(resolve, waitAfterCreation));\n return { createdObjects: objects.length };\n },\n});\n";
|
|
12
|
+
|
|
13
|
+
// raw-loader:/__w/dxos/dxos/packages/plugins/plugin-script/src/templates/discord.ts?raw
|
|
14
|
+
var discord_default = "//\n// Copyright 2025 DXOS.org\n//\n\n// @ts-ignore\nimport { DXN, EchoObject, Filter, EntityId, S, create, defineFunction } from 'dxos:functions';\n// @ts-ignore\nimport { FetchHttpClient } from 'https://esm.sh/@effect/platform@0.89.0?deps=effect@3.17.0&bundle=false';\nimport {\n DiscordConfig,\n DiscordREST,\n DiscordRESTMemoryLive,\n // @ts-ignore\n} from 'https://esm.sh/dfx@0.113.0?deps=effect@3.17.0&bundle=false';\n// @ts-ignore\nimport * as Config from 'https://esm.sh/effect@3.17.0/Config?bundle=false';\n// @ts-ignore\nimport * as Effect from 'https://esm.sh/effect@3.17.0/Effect?bundle=false';\n// @ts-ignore\nimport * as Redacted from 'https://esm.sh/effect@3.17.0/Redacted?bundle=false';\n// @ts-ignore\nimport * as Ref from 'https://esm.sh/effect@3.17.0/Ref?bundle=false';\n\nconst MessageSchema = S.Struct({\n id: EntityId,\n foreignId: S.Any, // bigint?\n from: S.String,\n created: S.String,\n content: S.String,\n}).pipe(\n EchoObject({\n typename: 'com.example.type.message',\n version: '0.1.0',\n }),\n);\n\nconst DEFAULT_AFTER = 1704067200; // 2024-01-01\n\nconst generateSnowflake = (unixTimestamp: number): bigint => {\n const discordEpoch = 1420070400000n; // Discord Epoch (ms)\n return (BigInt(unixTimestamp * 1000) - discordEpoch) << 22n;\n};\n\nexport default defineFunction({\n key: 'org.dxos.script.discord',\n name: 'Discord',\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 after: S.optional(S.Number),\n pageSize: S.optional(S.Number),\n queueId: S.String,\n }),\n\n outputSchema: S.Struct({\n newMessages: S.Number,\n }),\n\n handler: ({ data: { channelId, queueId, after = DEFAULT_AFTER, pageSize = 5 }, context: { space } }: any) =>\n Effect.gen(function* () {\n const { token } = yield* Effect.tryPromise({\n try: () => space.db.query(Filter.typename('org.dxos.type.accessToken', { source: 'discord.com' })).first(),\n catch: (e: any) => e,\n });\n const { objects } = yield* Effect.tryPromise({\n try: () => space.queues.queryQueue(DXN.tryMake(queueId)!),\n catch: (e: any) => e,\n });\n const backfill = objects.length === 0;\n const newMessages = yield* Ref.make(0);\n const lastMessage = yield* Ref.make(objects.at(-1));\n\n const enqueueMessages = Effect.gen(function* () {\n const rest = yield* DiscordREST;\n\n while (true) {\n const last = yield* Ref.get(lastMessage);\n const options = {\n after: backfill && !last ? `${generateSnowflake(after)}` : last?.foreignId,\n limit: pageSize,\n };\n const messages = yield* rest.getChannelMessages(channelId, options).pipe((res: any) => res.json);\n const queueMessages = messages\n .map((message: any) =>\n create(MessageSchema, {\n id: EntityId.random(),\n foreignId: message.id,\n from: message.author.username,\n created: message.timestamp,\n content: message.content,\n }),\n )\n .toReversed();\n if (queueMessages.length > 0) {\n yield* Effect.tryPromise({\n try: () => space.queues.insertIntoQueue(DXN.tryMake(queueId)!, queueMessages),\n catch: (e: any) => e,\n });\n yield* Ref.update(newMessages, (n: any) => n + queueMessages.length);\n yield* Ref.update(lastMessage, (m: any) => queueMessages.at(-1));\n }\n if (messages.length < pageSize) {\n break;\n }\n }\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 yield* enqueueMessages;\n return { newMessages: yield* Ref.get(newMessages) };\n }),\n});\n";
|
|
15
|
+
|
|
16
|
+
// raw-loader:/__w/dxos/dxos/packages/plugins/plugin-script/src/templates/email.ts?raw
|
|
17
|
+
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 ({ data: { bodyText }, context: { space } }: any) => {\n const { email, targetDocumentId: documentId } = JSON.parse(bodyText) as RequestPayload;\n\n const document = await space.db.query({ id: documentId }).first();\n\n const contentId = document.content['/'].split(':')[3];\n const documentContent = await space.db.query({ id: contentId }).first();\n const modifiedContent = [\n documentContent.content,\n '',\n '---',\n `**From:** ${email.from}`,\n `**Subject:** ${email.subject}`,\n `**Date:** ${email.created}`,\n '',\n email.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 email: { from: string; subject: string; created: string; body: string };\n targetDocumentId: string;\n};\n";
|
|
18
|
+
|
|
19
|
+
// raw-loader:/__w/dxos/dxos/packages/plugins/plugin-script/src/templates/forex-effect.ts?raw
|
|
20
|
+
var forex_effect_default = "//\n// Copyright 2025 DXOS.org\n//\n\nimport * as FetchHttpClient from '@effect/platform/FetchHttpClient';\nimport * as HttpClient from '@effect/platform/HttpClient';\nimport * as HttpClientRequest from '@effect/platform/HttpClientRequest';\nimport * as Effect from 'effect/Effect';\nimport * as Schedule from 'effect/Schedule';\nimport * as Schema from 'effect/Schema';\n\nimport { Operation } from '@dxos/compute';\nimport { DXN } from '@dxos/keys';\n\nconst ForexEffect = Operation.make({\n meta: {\n key: DXN.make('org.dxos.script.forexEffect'),\n name: 'Forex Effect',\n description: 'Returns the exchange rate between two currencies.',\n },\n input: Schema.Struct({\n from: Schema.String.annotations({ description: 'The source currency' }),\n to: Schema.String.annotations({ description: 'The target currency' }),\n }),\n output: Schema.Any,\n});\n\nexport default ForexEffect.pipe(\n Operation.withHandler(\n Effect.fnUntraced(function* ({ from: rawFrom, to: rawTo }) {\n const from = rawFrom.toUpperCase();\n const to = rawTo.toUpperCase();\n const json: any = yield* HttpClientRequest.get(`https://free.ratesdb.com/v1/rates?from=${from}&to=${to}`).pipe(\n HttpClient.execute,\n Effect.flatMap((response) => response.json),\n Effect.timeout('5 seconds'),\n Effect.retry(Schedule.exponential(1_000).pipe(Schedule.compose(Schedule.recurs(3)))),\n Effect.scoped,\n );\n\n const rate = json?.data?.rates?.[to];\n if (rate == null) {\n return yield* Effect.fail(new Error(`No rate found for ${from} -> ${to}`));\n }\n\n return rate.toString();\n }, Effect.provide(FetchHttpClient.layer)),\n ),\n);\n";
|
|
21
|
+
|
|
22
|
+
// raw-loader:/__w/dxos/dxos/packages/plugins/plugin-script/src/templates/forex.ts?raw
|
|
23
|
+
var forex_default = "//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Effect from 'effect/Effect';\nimport * as Schema from 'effect/Schema';\n\nimport { Operation } from '@dxos/compute';\nimport { DXN } from '@dxos/keys';\n\nconst Forex = Operation.make({\n meta: {\n key: DXN.make('org.dxos.script.forex'),\n name: 'Forex',\n description: 'Returns the exchange rate between two currencies.',\n },\n input: Schema.Struct({\n from: Schema.String.annotations({ description: 'The source currency' }),\n to: Schema.String.annotations({ description: 'The target currency' }),\n }),\n output: Schema.Any,\n});\n\nexport default Forex.pipe(\n Operation.withHandler(\n Effect.fn(function* ({ from: rawFrom, to: rawTo }) {\n const from = rawFrom.toUpperCase();\n const to = rawTo.toUpperCase();\n const res = yield* Effect.promise(() => fetch(`https://free.ratesdb.com/v1/rates?from=${from}&to=${to}`));\n const {\n data: { rates },\n } = yield* Effect.promise(() => res.json());\n\n return rates[to].toString();\n }),\n ),\n);\n";
|
|
24
|
+
|
|
25
|
+
// raw-loader:/__w/dxos/dxos/packages/plugins/plugin-script/src/templates/gmail.ts?raw
|
|
26
|
+
var gmail_default = "//\n// Copyright 2025 DXOS.org\n//\n\n// @ts-ignore\nimport { EchoObject, Filter, EntityId, S, create, defineFunction } from 'dxos:functions';\n// @ts-ignore\nimport {\n FetchHttpClient,\n HttpClient,\n HttpClientRequest,\n // @ts-ignore\n} from 'https://esm.sh/@effect/platform@0.89.0?deps=effect@3.17.0&bundle=false';\n// @ts-ignore\nimport { format, subDays } from 'https://esm.sh/date-fns@3.3.1?bundle=false';\n// @ts-ignore\nimport * as Chunk from 'https://esm.sh/effect@3.17.0/Chunk?bundle=false';\n// @ts-ignore\nimport * as Effect from 'https://esm.sh/effect@3.17.0/Effect?bundle=false';\n// @ts-ignore\nimport * as Function from 'https://esm.sh/effect@3.17.0/Function?bundle=false';\n// @ts-ignore\nimport * as Ref from 'https://esm.sh/effect@3.17.0/Ref?bundle=false';\n// @ts-ignore\nimport * as Schedule from 'https://esm.sh/effect@3.17.0/Schedule?bundle=false';\n// @ts-ignore\nimport * as Stream from 'https://esm.sh/effect@3.17.0/Stream?bundle=false';\n\nexport default defineFunction({\n key: 'org.dxos.script.gmail',\n name: 'Gmail',\n inputSchema: S.Struct({\n mailboxId: S.String,\n userId: S.optional(S.String).pipe(S.withDecodingDefault(() => 'me')),\n after: S.optional(S.Union(S.Number, S.String)).pipe(\n S.withDecodingDefault(() => format(subDays(new Date(), 30), 'yyyy-MM-dd')),\n ),\n pageSize: S.optional(S.Number).pipe(S.withDecodingDefault(() => 100)),\n // TODO(wittjosiah): Remove. This is used to provide a terminal for a cron trigger.\n tick: S.optional(S.String),\n }),\n\n outputSchema: S.Struct({\n newMessages: S.Number,\n }),\n\n handler: ({ context: { space }, data: { mailboxId, userId, after, pageSize } }: any) =>\n Effect.gen(function* () {\n const { token } = yield* Effect.tryPromise({\n try: () => space.db.query(Filter.typename('org.dxos.type.accessToken', { source: 'gmail.com' })).first(),\n catch: (e: any) => e,\n });\n\n // NOTE: Google API bundles size is v. large and caused runtime issues.\n const makeRequest = (url: string) =>\n Function.pipe(\n url,\n HttpClientRequest.get,\n HttpClientRequest.setHeaders({ Authorization: `Bearer ${token}`, Accept: 'application/json' }),\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\n const listMessages = (userId: string, q: string, pageSize: number, pageToken: string | null) =>\n makeRequest(getUrl(userId, undefined, { q, pageSize, pageToken }));\n\n const getMessage = (userId: string, messageId: string) => makeRequest(getUrl(userId, messageId));\n\n const mailbox = yield* Effect.tryPromise({\n try: () => space.db.query({ id: mailboxId }).first(),\n catch: (e: any) => e,\n });\n const { objects } = yield* Effect.tryPromise({\n try: () => space.queues.queryQueue(mailbox.queue.uri),\n catch: (e: any) => e,\n });\n const newMessages = yield* Ref.make([]);\n const nextPage = yield* Ref.make(null);\n\n do {\n const last = objects.at(-1);\n const q = last\n ? `in:inbox after:${Math.floor(new Date(last.created).getTime() / 1000)}`\n : `in:inbox after:${after}`;\n const pageToken = yield* Ref.get(nextPage);\n const { messages, nextPageToken } = yield* listMessages(userId, q, pageSize, pageToken);\n yield* Ref.update(nextPage, () => nextPageToken);\n for (const message of messages) {\n const messageDetails = yield* getMessage(userId, message.id);\n const created = new Date(parseInt(messageDetails.internalDate)).toISOString();\n const from = messageDetails.payload.headers.find((h: any) => h.name === 'From');\n const sender = from && parseFromHeader(from.value);\n // TODO(wittjosiah): Improve parsing of email contents.\n const content =\n messageDetails.payload.body?.data ??\n messageDetails.payload.parts?.find((p: any) => p.mimeType === 'text/plain')?.body.data;\n // Skip the message if content or sender is missing.\n // Skip the message if it's the same as the last message.\n // TODO(wittjosiah): This comparison should be done via foreignId probably.\n if (!content || !sender || created === last?.created) {\n continue;\n }\n const subject = messageDetails.payload.headers.find((h: any) => h.name === 'Subject')?.value;\n const object = create(MessageType, {\n id: EntityId.random(),\n created,\n sender,\n blocks: [\n {\n _tag: 'text',\n text: Buffer.from(content, 'base64').toString('utf-8'),\n },\n ],\n properties: {\n subject,\n threadId: message.threadId,\n },\n });\n // TODO(wittjosiah): Set foreignId in object meta.\n yield* Ref.update(newMessages, (n: any) => [object, ...n]);\n }\n } while (yield* Ref.get(nextPage));\n\n const queueMessages = yield* Ref.get(newMessages);\n if (queueMessages.length > 0) {\n yield* Function.pipe(\n queueMessages,\n Stream.fromIterable,\n Stream.grouped(10),\n Stream.flatMap((batch: any) =>\n Effect.tryPromise({\n try: () => space.queues.insertIntoQueue(mailbox.queue.uri, Chunk.toReadonlyArray(batch)),\n catch: (e: any) => e,\n }),\n ),\n Stream.runDrain,\n );\n }\n\n return { newMessages: queueMessages.length };\n }).pipe(Effect.provide(FetchHttpClient.layer)),\n});\n\nconst getUrl = (userId: string, messageId?: string, params?: Record<string, any>) => {\n const api = new URL(\n [`https://gmail.googleapis.com/gmail/v1/users/${userId}/messages`, messageId].filter(Boolean).join('/'),\n );\n Object.entries(params ?? {})\n .filter(([_, value]) => value != null)\n .forEach(([key, value]) => api.searchParams.set(key, value));\n return api.toString();\n};\n\n/**\n * Parses an email string in the format \"Name <email@example.com>\" into separate name and email components.\n */\nconst parseFromHeader = (value: string): { name?: string; email: string } | undefined => {\n const EMAIL_REGEX = /^([^<]+?)\\s*<([^>]+@[^>]+)>$/;\n const removeOuterQuotes = (str: string) => str.replace(/^['\"]|['\"]$/g, '');\n const match = value.match(EMAIL_REGEX);\n if (match) {\n const [, name, email] = match;\n return {\n name: removeOuterQuotes(name.trim()),\n email: email.trim(),\n };\n }\n};\n\n//\n// Schemas\n// TODO(wittjosiah): These schemas should be imported from @dxos/schema.\n//\n\nconst ActorRole = S.Literal('user', 'assistant');\ntype ActorRole = S.Schema.Type<typeof ActorRole>;\n\nconst ActorSchema = S.Struct({\n identityKey: S.optional(S.String),\n email: S.optional(S.String),\n name: S.optional(S.String),\n role: S.optional(ActorRole),\n});\n\nconst Base = S.Struct({\n pending: S.optional(S.Boolean),\n});\ntype Base = S.Schema.Type<typeof Base>;\nconst Text = S.TaggedStruct('text', {\n mimeType: S.optional(S.String),\n text: S.String,\n ...Base.fields,\n}).pipe(S.mutable);\ninterface Text extends S.Schema.Type<typeof Text> {}\n\nconst MessageType = S.Struct({\n id: EntityId,\n created: S.String.annotations({\n description: 'ISO date string when the message was sent.',\n }),\n sender: ActorSchema.annotations({\n description: 'Identity of the message sender.',\n }),\n blocks: S.Array(Text).annotations({\n description: 'Contents of the message.',\n }),\n properties: S.optional(\n S.mutable(\n S.Record({ key: S.String, value: S.Any }).annotations({\n description: 'Custom properties for specific message types (e.g. attention context, email subject, etc.).',\n }),\n ),\n ),\n}).pipe(\n EchoObject({\n typename: 'org.dxos.type.message',\n version: '0.1.0',\n }),\n);\ntype MessageType = S.Schema.Type<typeof MessageType>;\n";
|
|
27
|
+
|
|
28
|
+
// raw-loader:/__w/dxos/dxos/packages/plugins/plugin-script/src/templates/ping.ts?raw
|
|
29
|
+
var ping_default = "//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Effect from 'effect/Effect';\nimport * as Schema from 'effect/Schema';\n\nimport { Operation } from '@dxos/compute';\nimport { DXN } from '@dxos/keys';\n\nconst Ping = Operation.make({\n meta: {\n key: DXN.make('org.dxos.script.ping'),\n name: 'Ping',\n },\n input: Schema.Any,\n output: Schema.Any,\n});\n\nexport default Ping.pipe(\n Operation.withHandler(\n Effect.fn(function* (data) {\n return data;\n }),\n ),\n);\n";
|
|
30
|
+
|
|
31
|
+
// src/templates/index.ts
|
|
32
|
+
var removeHeader = (str) => str.split("\n").slice(4).join("\n");
|
|
33
|
+
var templates = [
|
|
34
|
+
{
|
|
35
|
+
id: "org.dxos.script.ping",
|
|
36
|
+
name: "Ping",
|
|
37
|
+
source: removeHeader(ping_default)
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
id: "org.dxos.script.forex",
|
|
41
|
+
name: "Forex",
|
|
42
|
+
source: removeHeader(forex_default)
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
id: "org.dxos.script.forex-effect",
|
|
46
|
+
name: "Forex (Effect)",
|
|
47
|
+
source: removeHeader(forex_effect_default)
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
id: "org.dxos.script.chess-bot",
|
|
51
|
+
name: "Chess Bot",
|
|
52
|
+
source: removeHeader(chess_bot_default),
|
|
53
|
+
presetId: "org.dxos.function.chess-bot"
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
id: "org.dxos.script.email",
|
|
57
|
+
name: "Email",
|
|
58
|
+
source: removeHeader(email_default),
|
|
59
|
+
presetId: "org.dxos.function.email"
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
id: "org.dxos.script.discord",
|
|
63
|
+
name: "Discord",
|
|
64
|
+
source: removeHeader(discord_default),
|
|
65
|
+
presetId: "org.dxos.function.discord"
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
id: "org.dxos.script.gmail",
|
|
69
|
+
name: "Gmail",
|
|
70
|
+
source: removeHeader(gmail_default),
|
|
71
|
+
presetId: "org.dxos.function.gmail"
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
id: "org.dxos.script.data-generator",
|
|
75
|
+
name: "Data Generator",
|
|
76
|
+
source: removeHeader(data_generator_default),
|
|
77
|
+
presetId: "org.dxos.function.data-generator"
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
id: "org.dxos.script.anthropic",
|
|
81
|
+
name: "Anthropic",
|
|
82
|
+
source: removeHeader(anthropic_default)
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
id: "org.dxos.script.commentary",
|
|
86
|
+
name: "Commentary",
|
|
87
|
+
source: removeHeader(commentary_default),
|
|
88
|
+
presetId: "org.dxos.function.chess.commentary"
|
|
89
|
+
}
|
|
90
|
+
];
|
|
91
|
+
|
|
92
|
+
export {
|
|
93
|
+
data_generator_default,
|
|
94
|
+
templates
|
|
95
|
+
};
|
|
96
|
+
//# sourceMappingURL=chunk-H2BRWQMY.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["raw-loader:/__w/dxos/dxos/packages/plugins/plugin-script/src/templates/anthropic.ts?raw", "raw-loader:/__w/dxos/dxos/packages/plugins/plugin-script/src/templates/chess-bot.ts?raw", "raw-loader:/__w/dxos/dxos/packages/plugins/plugin-script/src/templates/commentary.ts?raw", "raw-loader:/__w/dxos/dxos/packages/plugins/plugin-script/src/templates/data-generator.ts?raw", "raw-loader:/__w/dxos/dxos/packages/plugins/plugin-script/src/templates/discord.ts?raw", "raw-loader:/__w/dxos/dxos/packages/plugins/plugin-script/src/templates/email.ts?raw", "raw-loader:/__w/dxos/dxos/packages/plugins/plugin-script/src/templates/forex-effect.ts?raw", "raw-loader:/__w/dxos/dxos/packages/plugins/plugin-script/src/templates/forex.ts?raw", "raw-loader:/__w/dxos/dxos/packages/plugins/plugin-script/src/templates/gmail.ts?raw", "raw-loader:/__w/dxos/dxos/packages/plugins/plugin-script/src/templates/ping.ts?raw", "../../../src/templates/index.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport * as LanguageModel from '@effect/ai/LanguageModel';\nimport * as Chunk from 'effect/Chunk';\nimport * as Effect from 'effect/Effect';\nimport * as Schema from 'effect/Schema';\nimport * as Stream from 'effect/Stream';\n\nimport { AiService } from '@dxos/ai';\nimport { Operation } from '@dxos/compute';\nimport { DXN } from '@dxos/keys';\n\nconst Anthropic = Operation.make({\n meta: {\n key: DXN.make('org.dxos.script.anthropic'),\n name: 'Anthropic Chat',\n description: 'Chat with Anthropic',\n },\n input: Schema.Struct({\n message: Schema.String,\n }),\n output: Schema.Any,\n services: [AiService.AiService],\n});\n\nexport default Anthropic.pipe(\n Operation.withHandler(\n Effect.fn(function* ({ message }) {\n const model = (yield* AiService.AiService).model('@anthropic/claude-sonnet-4-5');\n\n //\n // Basic example.\n //\n const { text } = yield* LanguageModel.generateText({ prompt: message }).pipe(Effect.provide(model));\n\n //\n // Streaming example.\n //\n const parts = yield* LanguageModel.streamText({\n prompt: 'Count from 1 to 5, one number per line.',\n }).pipe(Stream.runCollect, Effect.map(Chunk.toArray), Effect.provide(model));\n const textDeltas = parts.filter((p) => p.type === 'text-delta');\n const fullText = textDeltas.map((p) => (p as { delta: string }).delta).join('');\n\n return { response: text, streamText: fullText };\n }),\n ),\n);\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { Chess as ChessJS } from 'chess.js';\nimport * as Effect from 'effect/Effect';\nimport * as Schema from 'effect/Schema';\n\nimport { Operation } from '@dxos/compute';\nimport { Database, Obj, DXN } from '@dxos/echo';\nimport { Chess } from '@dxos/plugin-chess';\nimport { GameRef, Game, loadGame } from '@dxos/plugin-game';\n\nconst ChessBot = Operation.make({\n meta: {\n key: DXN.make('org.dxos.script.chessBot'),\n name: 'Chess Bot',\n description: 'Plays a random move in a chess game.',\n },\n input: Schema.Struct({\n game: GameRef(Chess.State).annotations({\n description: 'The chess game to comment on.',\n }),\n player: Schema.optional(Schema.Literal('white', 'black')).annotations({\n description: 'The player to play the game as.',\n }),\n }),\n output: Schema.Struct({\n state: Schema.String.annotations({\n description: 'The state of the game as an ASCII art board.',\n }),\n }),\n types: [Game, Chess.State],\n services: [Database.Service],\n});\n\nexport default ChessBot.pipe(\n Operation.withHandler(\n Effect.fnUntraced(function* ({ game, player = 'black' }) {\n const { variant } = yield* loadGame(game, Chess.State);\n const chess = new ChessJS();\n chess.loadPgn(variant.pgn ?? '');\n if (chess.turn() !== (player === 'white' ? 'w' : 'b')) {\n return { state: chess.ascii() };\n }\n\n const moves = chess.moves({ verbose: true });\n const move = moves[Math.floor(Math.random() * moves.length)];\n if (!move) {\n return { state: chess.ascii() };\n }\n\n chess.move(move.san);\n const newPgn = chess.pgn();\n Obj.update(variant, (variant) => {\n const mutable = variant as Obj.Mutable<typeof variant>;\n mutable.pgn = newPgn;\n });\n yield* Database.flush();\n return { state: chess.ascii() };\n }),\n ),\n);\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport * as A from '@automerge/automerge';\nimport { Chess as ChessJS } from 'chess.js';\nimport * as Array from 'effect/Array';\nimport * as Effect from 'effect/Effect';\nimport * as Function from 'effect/Function';\nimport * as Layer from 'effect/Layer';\nimport * as Option from 'effect/Option';\nimport * as Schema from 'effect/Schema';\n\nimport { AiService, ConsolePrinter, ToolExecutionService, ToolResolverService } from '@dxos/ai';\nimport { RootCollectionAnnotation } from '@dxos/app-toolkit';\nimport { AiRequest, GenerationObserver } from '@dxos/assistant';\nimport { Trace, Operation, OperationRegistry } from '@dxos/compute';\nimport { Annotation, Collection, Database, DXN, Filter, Obj, Ref, Relation, URI } from '@dxos/echo';\nimport { createDocAccessor } from '@dxos/echo-db';\nimport { log } from '@dxos/log';\nimport { Chess } from '@dxos/plugin-chess';\nimport { Game, GameRef, loadGame } from '@dxos/plugin-game';\nimport { Markdown } from '@dxos/plugin-markdown';\nimport { Text } from '@dxos/schema';\nimport { HasSubject } from '@dxos/types';\nimport { trim } from '@dxos/util';\n\nconst Commentary = Operation.make({\n meta: {\n key: DXN.make('org.dxos.function.chess.commentary'),\n name: 'Commentary',\n description: 'Adds commentary about the most recent move to a markdown document associated with the chess game.',\n },\n input: Schema.Struct({\n game: GameRef(Chess.State).annotations({\n description: 'The chess game to comment on.',\n }),\n }),\n output: Schema.Union(\n Schema.Struct({\n documentId: URI.Schema.annotations({\n description: 'The ID of the markdown document that was updated or created.',\n }),\n commentary: Schema.String.annotations({\n description: 'The commentary that was added.',\n }),\n }),\n Schema.Void.annotations({\n description: 'Function did not find anything to comment on.',\n }),\n ),\n types: [Game, Chess.State, Markdown.Document, Text.Text, HasSubject.HasSubject, Collection.Collection],\n services: [AiService.AiService, Database.Service],\n});\n\nexport default Commentary.pipe(\n Operation.withHandler(\n Effect.fnUntraced(\n function* ({ game: gameRef }) {\n // Load the game and its Chess variant state.\n log.info('load game', { gameRef });\n const { game: chessGame, variant: chessState } = yield* loadGame(gameRef, Chess.State);\n\n // Load the chess position from PGN or FEN.\n const chess = new ChessJS();\n if (chessState.pgn) {\n chess.loadPgn(chessState.pgn);\n } else if (chessState.fen) {\n chess.load(chessState.fen);\n } else {\n log.info('Early return: no pgn or fen');\n return;\n }\n\n // Get the most recent move\n const history = chess.history({ verbose: true });\n if (history.length === 0) {\n throw new Error('No moves have been played yet');\n }\n const lastMove = history[history.length - 1];\n const moveNumber = Math.ceil(history.length / 2);\n const isWhiteMove = history.length % 2 === 1;\n const player = isWhiteMove ? 'White' : 'Black';\n const moveNotation = lastMove.san;\n\n // Generate AI commentary about the move\n const result = yield* new AiRequest.Request({\n observer: GenerationObserver.fromPrinter(new ConsolePrinter({ tag: 'chess-commentary' })),\n }).run({\n prompt:\n `Comment on this chess move as if you're commentating a live match for an audience:\\n\\n` +\n `Move ${moveNumber}: ${player} plays ${moveNotation} (${lastMove.from} to ${lastMove.to})${lastMove.captured ? `, capturing ${lastMove.captured}` : ''}\\n` +\n `Current position: ${chess.fen()}\\n` +\n `${chess.isCheck() ? 'The king is in check! ' : ''}` +\n `${chess.isCheckmate() ? 'CHECKMATE! ' : ''}` +\n `${chess.isStalemate() ? 'STALEMATE! ' : ''}` +\n `\\nGame so far:\\n${chess.pgn()}`,\n system: COMMENTARY_SYSTEM_PROMPT,\n history: [],\n });\n\n const commentaryText = Function.pipe(\n result,\n Array.findLast((msg) => msg.sender.role === 'assistant' && msg.blocks.some((block) => block._tag === 'text')),\n Option.flatMap((msg) =>\n Function.pipe(\n msg.blocks,\n Array.findLast((block) => block._tag === 'text'),\n Option.map((block) => block.text),\n ),\n ),\n Option.getOrThrowWith(() => new Error('No commentary generated')),\n );\n\n const commentary = `## Move ${moveNumber}: ${player} plays ${moveNotation}\\n\\n${commentaryText}\\n\\n`;\n log.info('commentary', { commentary });\n\n // TODO(wittjosiah): Functions currently don't support traversals.\n // const docs = yield* Database.runQuery(\n // Query.select(Filter.id(chessGame.id)).targetOf(HasSubject.HasSubject).source(),\n // ).pipe(Effect.map((objects) => objects.filter((object) => Obj.instanceOf(Markdown.Document, object))));\n const docs = yield* Database.runQuery(Filter.type(HasSubject.HasSubject)).pipe(\n Effect.map((relations) =>\n relations.filter((relation) => {\n // TODO(wittjosiah): This is a workaround for getTarget not handling deleted objects.\n try {\n log.info('relation', {\n source: Obj.getURI(Relation.getTarget(relation)),\n game: Obj.getURI(chessGame),\n });\n return Obj.getURI(Relation.getTarget(relation)) === Obj.getURI(chessGame);\n } catch {\n return false;\n }\n }),\n ),\n Effect.map((relations) =>\n relations\n .map((relation) => {\n // TODO(wittjosiah): This is a workaround for getSource not handling deleted objects.\n try {\n return Relation.getSource(relation);\n } catch {\n return undefined;\n }\n })\n .filter((source) => source !== undefined),\n ),\n Effect.map((sources) => {\n const docs = sources.filter((source) => Obj.instanceOf(Markdown.Document, source));\n log.info('docs', { sources, docs });\n return docs;\n }),\n );\n log.info('docs', { count: docs.length });\n\n let document: Markdown.Document;\n if (docs.length === 0) {\n // TODO(wittjosiah): Deploy fails if `SpaceProperties` schema is imported because its from `client-protocol`.\n const [properties] = yield* Database.runQuery(Filter.typename('org.dxos.type.spaceProperties'));\n const rootCollectionRef = Annotation.get(properties, RootCollectionAnnotation).pipe(Option.getOrUndefined);\n const rootCollection = rootCollectionRef\n ? yield* Database.load<Collection.Collection>(rootCollectionRef)\n : undefined;\n\n log.info('rootCollection', { rootCollection });\n\n // Create a new markdown document\n const gameName = chessGame.name || 'Chess Game';\n document = yield* Database.add(\n Markdown.make({\n name: `${gameName} Commentary`,\n content: `# ${gameName} Commentary\\n\\n${commentary}`,\n }),\n );\n\n const documentRef = Ref.make(document);\n if (rootCollection) {\n Obj.update(rootCollection, (rootCollection) => {\n rootCollection.objects.push(documentRef);\n });\n }\n\n // Create the HasSubject relation\n yield* Database.add(\n Relation.make(HasSubject.HasSubject, {\n [Relation.Source]: document,\n [Relation.Target]: chessGame,\n completedAt: new Date().toISOString(),\n }),\n );\n } else {\n document = docs[0];\n\n // Load the text content and append the commentary\n const text = yield* Database.load(document.content);\n const accessor = createDocAccessor(text, ['content']);\n accessor.handle.change((doc: A.Doc<Text.Text>) => {\n A.splice(doc, accessor.path.slice(), text.content.length, 0, commentary);\n });\n }\n\n log.info('result', { documentId: Obj.getURI(document), commentary });\n\n yield* Database.flush();\n\n return {\n documentId: Obj.getURI(document),\n commentary,\n };\n },\n Effect.provide(\n Layer.mergeAll(\n AiService.model('@anthropic/claude-haiku-4-5'),\n ToolResolverService.layerEmpty,\n ToolExecutionService.layerEmpty,\n Trace.writerLayerNoop,\n Database.notAvailable,\n Layer.succeed(Operation.Service, {\n invoke: () => Effect.die('Not available.'),\n schedule: () => Effect.die('Not available.'),\n invokePromise: async () => ({ error: new Error('Not available.') }),\n } as any),\n Layer.succeed(OperationRegistry.Service, { resolve: () => Effect.succeed(undefined) } as any),\n ),\n ),\n ),\n ),\n);\n\nconst COMMENTARY_SYSTEM_PROMPT = trim`\n You are a professional chess commentator providing live commentary for a chess match.\n\n # Style\n - Write in an engaging, enthusiastic style as if commentating for a live audience\n - Be concise but informative (2-4 sentences)\n - Explain the strategic implications of the move\n - Note any tactical elements (captures, threats, checks)\n - Comment on the position and what it means for the game\n\n # Format\n - Write in plain text (no markdown formatting in the commentary itself)\n - Be natural and conversational\n - Use chess terminology appropriately but keep it accessible\n\n # Special Situations\n - If it's checkmate, express excitement about the conclusion\n - If it's check, note the pressure on the king\n - If a piece is captured, mention the material exchange\n - Comment on the development of pieces and control of key squares when relevant\n`;\n", "//\n// Copyright 2025 DXOS.org\n//\n\n// @ts-ignore\nimport { Expando, S, create, defineFunction } from 'dxos:functions';\n// @ts-ignore\nimport { randText } from 'https://esm.sh/@ngneat/falso@7.1.1?bundle=false';\n\nexport default defineFunction({\n key: 'org.dxos.script.data-generator',\n name: 'Data Generator',\n inputSchema: S.Struct({\n documentAmount: S.optional(S.Number),\n textSize: S.optional(S.Number),\n mutationAmount: S.optional(S.Number),\n waitAfterCreation: S.optional(S.Number),\n }),\n\n outputSchema: S.Struct({}),\n\n handler: async ({\n data: { documentAmount = 1, textSize = 10, mutationAmount = 0, waitAfterCreation = 10_000 },\n context: { space },\n }: any) => {\n space.db.graph.registry.add([Expando]);\n const result: Record<string, any> = {};\n const objects: Expando[] = [];\n\n // Create objects.\n for (let i = 0; i < documentAmount; i++) {\n const obj = space.db.add(\n create(Expando, {\n name: 'scriptGenerated',\n content: randText({ charCount: textSize }),\n }),\n );\n objects.push(obj);\n const objectResult: any = {};\n // Mutate the object.\n for (let i = 0; i < mutationAmount; i++) {\n obj.content = randText({ charCount: textSize });\n }\n objectResult.mutations = mutationAmount;\n objectResult.contentLength = obj.content.length;\n result[obj.id] = objectResult;\n }\n\n // Flush and wait for data to propagate.\n await space.db.flush();\n await new Promise((resolve) => setTimeout(resolve, waitAfterCreation));\n return { createdObjects: objects.length };\n },\n});\n", "//\n// Copyright 2025 DXOS.org\n//\n\n// @ts-ignore\nimport { DXN, EchoObject, Filter, EntityId, S, create, defineFunction } from 'dxos:functions';\n// @ts-ignore\nimport { FetchHttpClient } from 'https://esm.sh/@effect/platform@0.89.0?deps=effect@3.17.0&bundle=false';\nimport {\n DiscordConfig,\n DiscordREST,\n DiscordRESTMemoryLive,\n // @ts-ignore\n} from 'https://esm.sh/dfx@0.113.0?deps=effect@3.17.0&bundle=false';\n// @ts-ignore\nimport * as Config from 'https://esm.sh/effect@3.17.0/Config?bundle=false';\n// @ts-ignore\nimport * as Effect from 'https://esm.sh/effect@3.17.0/Effect?bundle=false';\n// @ts-ignore\nimport * as Redacted from 'https://esm.sh/effect@3.17.0/Redacted?bundle=false';\n// @ts-ignore\nimport * as Ref from 'https://esm.sh/effect@3.17.0/Ref?bundle=false';\n\nconst MessageSchema = S.Struct({\n id: EntityId,\n foreignId: S.Any, // bigint?\n from: S.String,\n created: S.String,\n content: S.String,\n}).pipe(\n EchoObject({\n typename: 'com.example.type.message',\n version: '0.1.0',\n }),\n);\n\nconst DEFAULT_AFTER = 1704067200; // 2024-01-01\n\nconst generateSnowflake = (unixTimestamp: number): bigint => {\n const discordEpoch = 1420070400000n; // Discord Epoch (ms)\n return (BigInt(unixTimestamp * 1000) - discordEpoch) << 22n;\n};\n\nexport default defineFunction({\n key: 'org.dxos.script.discord',\n name: 'Discord',\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 after: S.optional(S.Number),\n pageSize: S.optional(S.Number),\n queueId: S.String,\n }),\n\n outputSchema: S.Struct({\n newMessages: S.Number,\n }),\n\n handler: ({ data: { channelId, queueId, after = DEFAULT_AFTER, pageSize = 5 }, context: { space } }: any) =>\n Effect.gen(function* () {\n const { token } = yield* Effect.tryPromise({\n try: () => space.db.query(Filter.typename('org.dxos.type.accessToken', { source: 'discord.com' })).first(),\n catch: (e: any) => e,\n });\n const { objects } = yield* Effect.tryPromise({\n try: () => space.queues.queryQueue(DXN.tryMake(queueId)!),\n catch: (e: any) => e,\n });\n const backfill = objects.length === 0;\n const newMessages = yield* Ref.make(0);\n const lastMessage = yield* Ref.make(objects.at(-1));\n\n const enqueueMessages = Effect.gen(function* () {\n const rest = yield* DiscordREST;\n\n while (true) {\n const last = yield* Ref.get(lastMessage);\n const options = {\n after: backfill && !last ? `${generateSnowflake(after)}` : last?.foreignId,\n limit: pageSize,\n };\n const messages = yield* rest.getChannelMessages(channelId, options).pipe((res: any) => res.json);\n const queueMessages = messages\n .map((message: any) =>\n create(MessageSchema, {\n id: EntityId.random(),\n foreignId: message.id,\n from: message.author.username,\n created: message.timestamp,\n content: message.content,\n }),\n )\n .toReversed();\n if (queueMessages.length > 0) {\n yield* Effect.tryPromise({\n try: () => space.queues.insertIntoQueue(DXN.tryMake(queueId)!, queueMessages),\n catch: (e: any) => e,\n });\n yield* Ref.update(newMessages, (n: any) => n + queueMessages.length);\n yield* Ref.update(lastMessage, (m: any) => queueMessages.at(-1));\n }\n if (messages.length < pageSize) {\n break;\n }\n }\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 yield* enqueueMessages;\n return { newMessages: yield* Ref.get(newMessages) };\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 ({ data: { bodyText }, context: { space } }: any) => {\n const { email, targetDocumentId: documentId } = JSON.parse(bodyText) as RequestPayload;\n\n const document = await space.db.query({ id: documentId }).first();\n\n const contentId = document.content['/'].split(':')[3];\n const documentContent = await space.db.query({ id: contentId }).first();\n const modifiedContent = [\n documentContent.content,\n '',\n '---',\n `**From:** ${email.from}`,\n `**Subject:** ${email.subject}`,\n `**Date:** ${email.created}`,\n '',\n email.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 email: { from: string; subject: string; created: string; body: string };\n targetDocumentId: string;\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport * as FetchHttpClient from '@effect/platform/FetchHttpClient';\nimport * as HttpClient from '@effect/platform/HttpClient';\nimport * as HttpClientRequest from '@effect/platform/HttpClientRequest';\nimport * as Effect from 'effect/Effect';\nimport * as Schedule from 'effect/Schedule';\nimport * as Schema from 'effect/Schema';\n\nimport { Operation } from '@dxos/compute';\nimport { DXN } from '@dxos/keys';\n\nconst ForexEffect = Operation.make({\n meta: {\n key: DXN.make('org.dxos.script.forexEffect'),\n name: 'Forex Effect',\n description: 'Returns the exchange rate between two currencies.',\n },\n input: Schema.Struct({\n from: Schema.String.annotations({ description: 'The source currency' }),\n to: Schema.String.annotations({ description: 'The target currency' }),\n }),\n output: Schema.Any,\n});\n\nexport default ForexEffect.pipe(\n Operation.withHandler(\n Effect.fnUntraced(function* ({ from: rawFrom, to: rawTo }) {\n const from = rawFrom.toUpperCase();\n const to = rawTo.toUpperCase();\n const json: any = yield* HttpClientRequest.get(`https://free.ratesdb.com/v1/rates?from=${from}&to=${to}`).pipe(\n HttpClient.execute,\n Effect.flatMap((response) => response.json),\n Effect.timeout('5 seconds'),\n Effect.retry(Schedule.exponential(1_000).pipe(Schedule.compose(Schedule.recurs(3)))),\n Effect.scoped,\n );\n\n const rate = json?.data?.rates?.[to];\n if (rate == null) {\n return yield* Effect.fail(new Error(`No rate found for ${from} -> ${to}`));\n }\n\n return rate.toString();\n }, Effect.provide(FetchHttpClient.layer)),\n ),\n);\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Effect from 'effect/Effect';\nimport * as Schema from 'effect/Schema';\n\nimport { Operation } from '@dxos/compute';\nimport { DXN } from '@dxos/keys';\n\nconst Forex = Operation.make({\n meta: {\n key: DXN.make('org.dxos.script.forex'),\n name: 'Forex',\n description: 'Returns the exchange rate between two currencies.',\n },\n input: Schema.Struct({\n from: Schema.String.annotations({ description: 'The source currency' }),\n to: Schema.String.annotations({ description: 'The target currency' }),\n }),\n output: Schema.Any,\n});\n\nexport default Forex.pipe(\n Operation.withHandler(\n Effect.fn(function* ({ from: rawFrom, to: rawTo }) {\n const from = rawFrom.toUpperCase();\n const to = rawTo.toUpperCase();\n const res = yield* Effect.promise(() => fetch(`https://free.ratesdb.com/v1/rates?from=${from}&to=${to}`));\n const {\n data: { rates },\n } = yield* Effect.promise(() => res.json());\n\n return rates[to].toString();\n }),\n ),\n);\n", "//\n// Copyright 2025 DXOS.org\n//\n\n// @ts-ignore\nimport { EchoObject, Filter, EntityId, S, create, defineFunction } from 'dxos:functions';\n// @ts-ignore\nimport {\n FetchHttpClient,\n HttpClient,\n HttpClientRequest,\n // @ts-ignore\n} from 'https://esm.sh/@effect/platform@0.89.0?deps=effect@3.17.0&bundle=false';\n// @ts-ignore\nimport { format, subDays } from 'https://esm.sh/date-fns@3.3.1?bundle=false';\n// @ts-ignore\nimport * as Chunk from 'https://esm.sh/effect@3.17.0/Chunk?bundle=false';\n// @ts-ignore\nimport * as Effect from 'https://esm.sh/effect@3.17.0/Effect?bundle=false';\n// @ts-ignore\nimport * as Function from 'https://esm.sh/effect@3.17.0/Function?bundle=false';\n// @ts-ignore\nimport * as Ref from 'https://esm.sh/effect@3.17.0/Ref?bundle=false';\n// @ts-ignore\nimport * as Schedule from 'https://esm.sh/effect@3.17.0/Schedule?bundle=false';\n// @ts-ignore\nimport * as Stream from 'https://esm.sh/effect@3.17.0/Stream?bundle=false';\n\nexport default defineFunction({\n key: 'org.dxos.script.gmail',\n name: 'Gmail',\n inputSchema: S.Struct({\n mailboxId: S.String,\n userId: S.optional(S.String).pipe(S.withDecodingDefault(() => 'me')),\n after: S.optional(S.Union(S.Number, S.String)).pipe(\n S.withDecodingDefault(() => format(subDays(new Date(), 30), 'yyyy-MM-dd')),\n ),\n pageSize: S.optional(S.Number).pipe(S.withDecodingDefault(() => 100)),\n // TODO(wittjosiah): Remove. This is used to provide a terminal for a cron trigger.\n tick: S.optional(S.String),\n }),\n\n outputSchema: S.Struct({\n newMessages: S.Number,\n }),\n\n handler: ({ context: { space }, data: { mailboxId, userId, after, pageSize } }: any) =>\n Effect.gen(function* () {\n const { token } = yield* Effect.tryPromise({\n try: () => space.db.query(Filter.typename('org.dxos.type.accessToken', { source: 'gmail.com' })).first(),\n catch: (e: any) => e,\n });\n\n // NOTE: Google API bundles size is v. large and caused runtime issues.\n const makeRequest = (url: string) =>\n Function.pipe(\n url,\n HttpClientRequest.get,\n HttpClientRequest.setHeaders({ Authorization: `Bearer ${token}`, Accept: 'application/json' }),\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\n const listMessages = (userId: string, q: string, pageSize: number, pageToken: string | null) =>\n makeRequest(getUrl(userId, undefined, { q, pageSize, pageToken }));\n\n const getMessage = (userId: string, messageId: string) => makeRequest(getUrl(userId, messageId));\n\n const mailbox = yield* Effect.tryPromise({\n try: () => space.db.query({ id: mailboxId }).first(),\n catch: (e: any) => e,\n });\n const { objects } = yield* Effect.tryPromise({\n try: () => space.queues.queryQueue(mailbox.queue.uri),\n catch: (e: any) => e,\n });\n const newMessages = yield* Ref.make([]);\n const nextPage = yield* Ref.make(null);\n\n do {\n const last = objects.at(-1);\n const q = last\n ? `in:inbox after:${Math.floor(new Date(last.created).getTime() / 1000)}`\n : `in:inbox after:${after}`;\n const pageToken = yield* Ref.get(nextPage);\n const { messages, nextPageToken } = yield* listMessages(userId, q, pageSize, pageToken);\n yield* Ref.update(nextPage, () => nextPageToken);\n for (const message of messages) {\n const messageDetails = yield* getMessage(userId, message.id);\n const created = new Date(parseInt(messageDetails.internalDate)).toISOString();\n const from = messageDetails.payload.headers.find((h: any) => h.name === 'From');\n const sender = from && parseFromHeader(from.value);\n // TODO(wittjosiah): Improve parsing of email contents.\n const content =\n messageDetails.payload.body?.data ??\n messageDetails.payload.parts?.find((p: any) => p.mimeType === 'text/plain')?.body.data;\n // Skip the message if content or sender is missing.\n // Skip the message if it's the same as the last message.\n // TODO(wittjosiah): This comparison should be done via foreignId probably.\n if (!content || !sender || created === last?.created) {\n continue;\n }\n const subject = messageDetails.payload.headers.find((h: any) => h.name === 'Subject')?.value;\n const object = create(MessageType, {\n id: EntityId.random(),\n created,\n sender,\n blocks: [\n {\n _tag: 'text',\n text: Buffer.from(content, 'base64').toString('utf-8'),\n },\n ],\n properties: {\n subject,\n threadId: message.threadId,\n },\n });\n // TODO(wittjosiah): Set foreignId in object meta.\n yield* Ref.update(newMessages, (n: any) => [object, ...n]);\n }\n } while (yield* Ref.get(nextPage));\n\n const queueMessages = yield* Ref.get(newMessages);\n if (queueMessages.length > 0) {\n yield* Function.pipe(\n queueMessages,\n Stream.fromIterable,\n Stream.grouped(10),\n Stream.flatMap((batch: any) =>\n Effect.tryPromise({\n try: () => space.queues.insertIntoQueue(mailbox.queue.uri, Chunk.toReadonlyArray(batch)),\n catch: (e: any) => e,\n }),\n ),\n Stream.runDrain,\n );\n }\n\n return { newMessages: queueMessages.length };\n }).pipe(Effect.provide(FetchHttpClient.layer)),\n});\n\nconst getUrl = (userId: string, messageId?: string, params?: Record<string, any>) => {\n const api = new URL(\n [`https://gmail.googleapis.com/gmail/v1/users/${userId}/messages`, messageId].filter(Boolean).join('/'),\n );\n Object.entries(params ?? {})\n .filter(([_, value]) => value != null)\n .forEach(([key, value]) => api.searchParams.set(key, value));\n return api.toString();\n};\n\n/**\n * Parses an email string in the format \"Name <email@example.com>\" into separate name and email components.\n */\nconst parseFromHeader = (value: string): { name?: string; email: string } | undefined => {\n const EMAIL_REGEX = /^([^<]+?)\\s*<([^>]+@[^>]+)>$/;\n const removeOuterQuotes = (str: string) => str.replace(/^['\"]|['\"]$/g, '');\n const match = value.match(EMAIL_REGEX);\n if (match) {\n const [, name, email] = match;\n return {\n name: removeOuterQuotes(name.trim()),\n email: email.trim(),\n };\n }\n};\n\n//\n// Schemas\n// TODO(wittjosiah): These schemas should be imported from @dxos/schema.\n//\n\nconst ActorRole = S.Literal('user', 'assistant');\ntype ActorRole = S.Schema.Type<typeof ActorRole>;\n\nconst ActorSchema = S.Struct({\n identityKey: S.optional(S.String),\n email: S.optional(S.String),\n name: S.optional(S.String),\n role: S.optional(ActorRole),\n});\n\nconst Base = S.Struct({\n pending: S.optional(S.Boolean),\n});\ntype Base = S.Schema.Type<typeof Base>;\nconst Text = S.TaggedStruct('text', {\n mimeType: S.optional(S.String),\n text: S.String,\n ...Base.fields,\n}).pipe(S.mutable);\ninterface Text extends S.Schema.Type<typeof Text> {}\n\nconst MessageType = S.Struct({\n id: EntityId,\n created: S.String.annotations({\n description: 'ISO date string when the message was sent.',\n }),\n sender: ActorSchema.annotations({\n description: 'Identity of the message sender.',\n }),\n blocks: S.Array(Text).annotations({\n description: 'Contents of the message.',\n }),\n properties: S.optional(\n S.mutable(\n S.Record({ key: S.String, value: S.Any }).annotations({\n description: 'Custom properties for specific message types (e.g. attention context, email subject, etc.).',\n }),\n ),\n ),\n}).pipe(\n EchoObject({\n typename: 'org.dxos.type.message',\n version: '0.1.0',\n }),\n);\ntype MessageType = S.Schema.Type<typeof MessageType>;\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Effect from 'effect/Effect';\nimport * as Schema from 'effect/Schema';\n\nimport { Operation } from '@dxos/compute';\nimport { DXN } from '@dxos/keys';\n\nconst Ping = Operation.make({\n meta: {\n key: DXN.make('org.dxos.script.ping'),\n name: 'Ping',\n },\n input: Schema.Any,\n output: Schema.Any,\n});\n\nexport default Ping.pipe(\n Operation.withHandler(\n Effect.fn(function* (data) {\n return data;\n }),\n ),\n);\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport anthropic from './anthropic.ts?raw';\nimport chessBot from './chess-bot.ts?raw';\nimport commentary from './commentary.ts?raw';\nimport dataGenerator from './data-generator.ts?raw';\nimport discord from './discord.ts?raw';\nimport email from './email.ts?raw';\nimport forexEffect from './forex-effect.ts?raw';\nimport forex from './forex.ts?raw';\nimport gmail from './gmail.ts?raw';\nimport ping from './ping.ts?raw';\n\nconst removeHeader = (str: string) => str.split('\\n').slice(4).join('\\n');\n\nexport { dataGenerator };\n\nexport type Template = {\n id: string;\n name: string;\n source: string;\n presetId?: string;\n};\n\nexport const templates = [\n {\n id: 'org.dxos.script.ping',\n name: 'Ping',\n source: removeHeader(ping),\n },\n {\n id: 'org.dxos.script.forex',\n name: 'Forex',\n source: removeHeader(forex),\n },\n {\n id: 'org.dxos.script.forex-effect',\n name: 'Forex (Effect)',\n source: removeHeader(forexEffect),\n },\n {\n id: 'org.dxos.script.chess-bot',\n name: 'Chess Bot',\n source: removeHeader(chessBot),\n presetId: 'org.dxos.function.chess-bot',\n },\n {\n id: 'org.dxos.script.email',\n name: 'Email',\n source: removeHeader(email),\n presetId: 'org.dxos.function.email',\n },\n {\n id: 'org.dxos.script.discord',\n name: 'Discord',\n source: removeHeader(discord),\n presetId: 'org.dxos.function.discord',\n },\n {\n id: 'org.dxos.script.gmail',\n name: 'Gmail',\n source: removeHeader(gmail),\n presetId: 'org.dxos.function.gmail',\n },\n {\n id: 'org.dxos.script.data-generator',\n name: 'Data Generator',\n source: removeHeader(dataGenerator),\n presetId: 'org.dxos.function.data-generator',\n },\n {\n id: 'org.dxos.script.anthropic',\n name: 'Anthropic',\n source: removeHeader(anthropic),\n },\n {\n id: 'org.dxos.script.commentary',\n name: 'Commentary',\n source: removeHeader(commentary),\n presetId: 'org.dxos.function.chess.commentary',\n },\n] as const;\n"],
|
|
5
|
+
"mappings": ";AAAA;;;ACAA;;;ACAA;;;ACAA;;;ACAA;;;ACAA;;;ACAA;;;ACAA;;;ACAA;;;ACAA;;;ACeA,IAAMA,eAAe,CAACC,QAAgBA,IAAIC,MAAM,IAAA,EAAMC,MAAM,CAAA,EAAGC,KAAK,IAAA;AAW7D,IAAMC,YAAY;EACvB;IACEC,IAAI;IACJC,MAAM;IACNC,QAAQC,aAAaC,YAAAA;EACvB;EACA;IACEJ,IAAI;IACJC,MAAM;IACNC,QAAQC,aAAaE,aAAAA;EACvB;EACA;IACEL,IAAI;IACJC,MAAM;IACNC,QAAQC,aAAaG,oBAAAA;EACvB;EACA;IACEN,IAAI;IACJC,MAAM;IACNC,QAAQC,aAAaI,iBAAAA;IACrBC,UAAU;EACZ;EACA;IACER,IAAI;IACJC,MAAM;IACNC,QAAQC,aAAaM,aAAAA;IACrBD,UAAU;EACZ;EACA;IACER,IAAI;IACJC,MAAM;IACNC,QAAQC,aAAaO,eAAAA;IACrBF,UAAU;EACZ;EACA;IACER,IAAI;IACJC,MAAM;IACNC,QAAQC,aAAaQ,aAAAA;IACrBH,UAAU;EACZ;EACA;IACER,IAAI;IACJC,MAAM;IACNC,QAAQC,aAAaS,sBAAAA;IACrBJ,UAAU;EACZ;EACA;IACER,IAAI;IACJC,MAAM;IACNC,QAAQC,aAAaU,iBAAAA;EACvB;EACA;IACEb,IAAI;IACJC,MAAM;IACNC,QAAQC,aAAaW,kBAAAA;IACrBN,UAAU;EACZ;;",
|
|
6
|
+
"names": ["removeHeader", "str", "split", "slice", "join", "templates", "id", "name", "source", "removeHeader", "ping", "forex", "forexEffect", "chessBot", "presetId", "email", "discord", "gmail", "dataGenerator", "anthropic", "commentary"]
|
|
7
|
+
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// src/operations/index.ts
|
|
2
2
|
import { OperationHandlerSet } from "@dxos/compute";
|
|
3
|
-
var ScriptOperationHandlerSet = OperationHandlerSet.lazy(() => import("./
|
|
3
|
+
var ScriptOperationHandlerSet = OperationHandlerSet.lazy(() => import("./create-script-66DO3UJO.mjs"));
|
|
4
4
|
|
|
5
5
|
export {
|
|
6
6
|
ScriptOperationHandlerSet
|
|
7
7
|
};
|
|
8
|
-
//# sourceMappingURL=chunk-
|
|
8
|
+
//# sourceMappingURL=chunk-LHEJXJEL.mjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/operations/index.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { OperationHandlerSet } from '@dxos/compute';\n\nexport const ScriptOperationHandlerSet = OperationHandlerSet.lazy(
|
|
5
|
-
"mappings": ";AAIA,SAASA,2BAA2B;AAE7B,IAAMC,4BAA4BD,oBAAoBE,
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { OperationHandlerSet } from '@dxos/compute';\n\nexport const ScriptOperationHandlerSet = OperationHandlerSet.lazy(() => import('./create-script'));\n"],
|
|
5
|
+
"mappings": ";AAIA,SAASA,2BAA2B;AAE7B,IAAMC,4BAA4BD,oBAAoBE,KAAK,MAAM,OAAO,8BAAA,CAAA;",
|
|
6
6
|
"names": ["OperationHandlerSet", "ScriptOperationHandlerSet", "lazy"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// src/blueprints/functions/index.ts
|
|
2
|
+
import { OperationHandlerSet } from "@dxos/compute";
|
|
3
|
+
var ScriptHandlers = OperationHandlerSet.lazy(() => import("./create-WQJXMOUE.mjs"), () => import("./read-RQESBAQI.mjs"), () => import("./update-JZUNJYZM.mjs"), () => import("./delete-HCQIQFVP.mjs"), () => import("./deploy-7JVMMHSH.mjs"), () => import("./invoke-3HVWY2KF.mjs"), () => import("./inspect-invocations-6MW73SDV.mjs"), () => import("./query-deployed-functions-F4FHJNWO.mjs"), () => import("./install-function-FJIE2JAI.mjs"));
|
|
4
|
+
|
|
5
|
+
export {
|
|
6
|
+
ScriptHandlers
|
|
7
|
+
};
|
|
8
|
+
//# sourceMappingURL=chunk-NQOIENTU.mjs.map
|