@dxos/plugin-script 0.8.1-main.a06ad20 → 0.8.1-main.ba2dec9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/browser/{ScriptContainer-P7SZ65VN.mjs → ScriptContainer-AIBCQZ7S.mjs} +3 -3
- package/dist/lib/browser/ScriptContainer-AIBCQZ7S.mjs.map +7 -0
- package/dist/lib/browser/{artifact-definition-4LWPD3DH.mjs → artifact-definition-GTL3ZSF2.mjs} +2 -2
- package/dist/lib/browser/artifact-definition-GTL3ZSF2.mjs.map +7 -0
- package/dist/lib/browser/{chunk-4FWN55UF.mjs → chunk-4SSKJNMZ.mjs} +2 -2
- package/dist/lib/browser/chunk-4SSKJNMZ.mjs.map +7 -0
- package/dist/lib/browser/{chunk-NJTRYUO3.mjs → chunk-5RZVHFGR.mjs} +3 -3
- package/dist/lib/browser/{chunk-NJTRYUO3.mjs.map → chunk-5RZVHFGR.mjs.map} +1 -1
- package/dist/lib/browser/{chunk-6P4LZSOU.mjs → chunk-5WPOWUPI.mjs} +3 -3
- package/dist/lib/browser/{chunk-6P4LZSOU.mjs.map → chunk-5WPOWUPI.mjs.map} +1 -1
- package/dist/lib/browser/{chunk-2H6QBQ5Q.mjs → chunk-JL34HAEL.mjs} +2 -2
- package/dist/lib/browser/{chunk-2H6QBQ5Q.mjs.map → chunk-JL34HAEL.mjs.map} +1 -1
- package/dist/lib/browser/index.mjs +10 -10
- package/dist/lib/browser/index.mjs.map +1 -1
- package/dist/lib/browser/{intent-resolver-5BRHMSBN.mjs → intent-resolver-BJ76DBGE.mjs} +4 -4
- package/dist/lib/browser/{intent-resolver-5BRHMSBN.mjs.map → intent-resolver-BJ76DBGE.mjs.map} +1 -1
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/{react-surface-ZLM32TTL.mjs → react-surface-M4RD24IN.mjs} +5 -5
- package/dist/lib/browser/react-surface-M4RD24IN.mjs.map +7 -0
- package/dist/lib/browser/{settings-LRHZSUEJ.mjs → settings-HIWURVAS.mjs} +2 -2
- package/dist/lib/browser/types.mjs +1 -1
- package/dist/lib/node/{ScriptContainer-2LYA3N3F.cjs → ScriptContainer-ZYVN7ZW6.cjs} +14 -14
- package/dist/lib/node/ScriptContainer-ZYVN7ZW6.cjs.map +7 -0
- package/dist/lib/node/{artifact-definition-BXQCFPAH.cjs → artifact-definition-64KZC4UT.cjs} +9 -9
- package/dist/lib/node/artifact-definition-64KZC4UT.cjs.map +7 -0
- package/dist/lib/node/{chunk-OSRFLW5T.cjs → chunk-B2O7H2AU.cjs} +10 -10
- package/dist/lib/node/chunk-B2O7H2AU.cjs.map +7 -0
- package/dist/lib/node/{chunk-M2DJ5RXU.cjs → chunk-PTXU7QFZ.cjs} +9 -9
- package/dist/lib/node/{chunk-M2DJ5RXU.cjs.map → chunk-PTXU7QFZ.cjs.map} +2 -2
- package/dist/lib/node/{chunk-3ICET6JB.cjs → chunk-VJ73IG7P.cjs} +6 -6
- package/dist/lib/node/{chunk-3ICET6JB.cjs.map → chunk-VJ73IG7P.cjs.map} +2 -2
- package/dist/lib/node/{chunk-I57SKIAA.cjs → chunk-XCQNFRZ6.cjs} +5 -5
- package/dist/lib/node/chunk-XCQNFRZ6.cjs.map +7 -0
- package/dist/lib/node/index.cjs +23 -23
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/{intent-resolver-L4WJAAV3.cjs → intent-resolver-HQ3FGK2K.cjs} +10 -10
- package/dist/lib/node/intent-resolver-HQ3FGK2K.cjs.map +7 -0
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/{react-surface-TQ4OKBUS.cjs → react-surface-JDA5UZCC.cjs} +17 -17
- package/dist/lib/node/react-surface-JDA5UZCC.cjs.map +7 -0
- package/dist/lib/node/{settings-TR2CA4IH.cjs → settings-ZASSNBKR.cjs} +7 -7
- package/dist/lib/node/types.cjs +3 -3
- package/dist/lib/node/types.cjs.map +1 -1
- package/dist/lib/node-esm/{ScriptContainer-OYGIGGMK.mjs → ScriptContainer-PI7PU5T7.mjs} +3 -3
- package/dist/lib/node-esm/ScriptContainer-PI7PU5T7.mjs.map +7 -0
- package/dist/lib/node-esm/{artifact-definition-KT4DK2LQ.mjs → artifact-definition-SF46QOO7.mjs} +2 -2
- package/dist/lib/node-esm/artifact-definition-SF46QOO7.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-J5LF4LOZ.mjs → chunk-4YUSGXJ2.mjs} +2 -2
- package/dist/lib/node-esm/chunk-4YUSGXJ2.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-HZPDX247.mjs → chunk-AXFGQDAD.mjs} +3 -3
- package/dist/lib/node-esm/{chunk-HZPDX247.mjs.map → chunk-AXFGQDAD.mjs.map} +1 -1
- package/dist/lib/node-esm/{chunk-N52CCVF5.mjs → chunk-FHQKFLM7.mjs} +2 -2
- package/dist/lib/node-esm/{chunk-N52CCVF5.mjs.map → chunk-FHQKFLM7.mjs.map} +1 -1
- package/dist/lib/node-esm/{chunk-YDYGIELP.mjs → chunk-GLW67SM7.mjs} +3 -3
- package/dist/lib/node-esm/{chunk-YDYGIELP.mjs.map → chunk-GLW67SM7.mjs.map} +1 -1
- package/dist/lib/node-esm/index.mjs +10 -10
- package/dist/lib/node-esm/index.mjs.map +1 -1
- package/dist/lib/node-esm/{intent-resolver-HFXJQI5Y.mjs → intent-resolver-CDTQKQD4.mjs} +4 -4
- package/dist/lib/node-esm/{intent-resolver-HFXJQI5Y.mjs.map → intent-resolver-CDTQKQD4.mjs.map} +1 -1
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/{react-surface-3NCY6ISW.mjs → react-surface-ODWVGWV4.mjs} +5 -5
- package/dist/lib/node-esm/react-surface-ODWVGWV4.mjs.map +7 -0
- package/dist/lib/node-esm/{settings-Q6B4K7LO.mjs → settings-FDGLXN4I.mjs} +2 -2
- package/dist/lib/node-esm/types.mjs +1 -1
- package/dist/types/src/components/LogsPanel/LogsPanel.d.ts +1 -1
- package/dist/types/src/components/LogsPanel/LogsPanel.d.ts.map +1 -1
- package/dist/types/src/components/ScriptContainer.d.ts +1 -1
- package/dist/types/src/components/ScriptContainer.d.ts.map +1 -1
- package/dist/types/src/components/ScriptSettingsPanel.d.ts +1 -1
- package/dist/types/src/components/ScriptSettingsPanel.d.ts.map +1 -1
- package/dist/types/src/components/ScriptToolbar/ScriptToolbar.d.ts +1 -1
- package/dist/types/src/components/ScriptToolbar/ScriptToolbar.d.ts.map +1 -1
- package/dist/types/src/hooks/format.d.ts +1 -1
- package/dist/types/src/hooks/format.d.ts.map +1 -1
- package/dist/types/src/hooks/template.d.ts +1 -1
- package/dist/types/src/hooks/template.d.ts.map +1 -1
- package/dist/types/src/hooks/useToolbarAction.d.ts +1 -1
- package/dist/types/src/hooks/useToolbarAction.d.ts.map +1 -1
- package/dist/types/src/templates/discord.d.ts.map +1 -1
- package/dist/types/src/types.d.ts +1 -1
- package/dist/types/src/types.d.ts.map +1 -1
- package/package.json +45 -45
- package/src/ScriptPlugin.tsx +1 -1
- package/src/capabilities/artifact-definition.ts +1 -1
- package/src/capabilities/intent-resolver.ts +1 -1
- package/src/capabilities/react-surface.tsx +1 -1
- package/src/components/LogsPanel/LogsPanel.tsx +1 -1
- package/src/components/ScriptContainer.tsx +1 -1
- package/src/components/ScriptSettingsPanel.tsx +1 -1
- package/src/components/ScriptToolbar/ScriptToolbar.tsx +1 -1
- package/src/hooks/format.ts +1 -1
- package/src/hooks/template.ts +1 -1
- package/src/hooks/useToolbarAction.ts +1 -1
- package/src/templates/discord.ts +12 -5
- package/src/translations.ts +1 -1
- package/src/types.ts +1 -1
- package/dist/lib/browser/ScriptContainer-P7SZ65VN.mjs.map +0 -7
- package/dist/lib/browser/artifact-definition-4LWPD3DH.mjs.map +0 -7
- package/dist/lib/browser/chunk-4FWN55UF.mjs.map +0 -7
- package/dist/lib/browser/react-surface-ZLM32TTL.mjs.map +0 -7
- package/dist/lib/node/ScriptContainer-2LYA3N3F.cjs.map +0 -7
- package/dist/lib/node/artifact-definition-BXQCFPAH.cjs.map +0 -7
- package/dist/lib/node/chunk-I57SKIAA.cjs.map +0 -7
- package/dist/lib/node/chunk-OSRFLW5T.cjs.map +0 -7
- package/dist/lib/node/intent-resolver-L4WJAAV3.cjs.map +0 -7
- package/dist/lib/node/react-surface-TQ4OKBUS.cjs.map +0 -7
- package/dist/lib/node-esm/ScriptContainer-OYGIGGMK.mjs.map +0 -7
- package/dist/lib/node-esm/artifact-definition-KT4DK2LQ.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-J5LF4LOZ.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-3NCY6ISW.mjs.map +0 -7
- /package/dist/lib/browser/{settings-LRHZSUEJ.mjs.map → settings-HIWURVAS.mjs.map} +0 -0
- /package/dist/lib/node/{settings-TR2CA4IH.cjs.map → settings-ZASSNBKR.cjs.map} +0 -0
- /package/dist/lib/node-esm/{settings-Q6B4K7LO.mjs.map → settings-FDGLXN4I.mjs.map} +0 -0
|
@@ -16,17 +16,17 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
return to;
|
|
17
17
|
};
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var
|
|
20
|
-
__export(
|
|
19
|
+
var chunk_VJ73IG7P_exports = {};
|
|
20
|
+
__export(chunk_VJ73IG7P_exports, {
|
|
21
21
|
ScriptAction: () => ScriptAction,
|
|
22
22
|
ScriptSettingsSchema: () => ScriptSettingsSchema
|
|
23
23
|
});
|
|
24
|
-
module.exports = __toCommonJS(
|
|
24
|
+
module.exports = __toCommonJS(chunk_VJ73IG7P_exports);
|
|
25
25
|
var import_chunk_5UH3F7TA = require("./chunk-5UH3F7TA.cjs");
|
|
26
26
|
var import_SchemaAST = require("effect/SchemaAST");
|
|
27
27
|
var import_echo = require("@dxos/client/echo");
|
|
28
28
|
var import_echo_schema = require("@dxos/echo-schema");
|
|
29
|
-
var
|
|
29
|
+
var import_types = require("@dxos/functions/types");
|
|
30
30
|
var import_react_ui_editor = require("@dxos/react-ui-editor");
|
|
31
31
|
var ScriptAction;
|
|
32
32
|
(function(ScriptAction2) {
|
|
@@ -43,7 +43,7 @@ var ScriptAction;
|
|
|
43
43
|
space: import_echo.SpaceSchema
|
|
44
44
|
})),
|
|
45
45
|
output: import_echo_schema.S.Struct({
|
|
46
|
-
object:
|
|
46
|
+
object: import_types.ScriptType
|
|
47
47
|
})
|
|
48
48
|
}) {
|
|
49
49
|
}
|
|
@@ -57,4 +57,4 @@ var ScriptSettingsSchema = import_echo_schema.S.mutable(import_echo_schema.S.Str
|
|
|
57
57
|
ScriptAction,
|
|
58
58
|
ScriptSettingsSchema
|
|
59
59
|
});
|
|
60
|
-
//# sourceMappingURL=chunk-
|
|
60
|
+
//# sourceMappingURL=chunk-VJ73IG7P.cjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/types.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { TitleAnnotationId } from 'effect/SchemaAST';\n\nimport { SpaceSchema } from '@dxos/client/echo';\nimport { S } from '@dxos/echo-schema';\nimport { ScriptType } from '@dxos/functions';\nimport { EditorInputMode } from '@dxos/react-ui-editor';\n\nimport { SCRIPT_PLUGIN } from './meta';\n\nexport namespace ScriptAction {\n const SCRIPT_ACTION = `${SCRIPT_PLUGIN}/action`;\n\n export const CreateScriptSchema = S.Struct({\n name: S.optional(S.String),\n // TODO(wittjosiah): Placeholder annotation?\n gistUrl: S.optional(S.String.annotations({ [TitleAnnotationId]: 'Import from Gist (url)' })),\n });\n\n export type CreateScriptProps = S.Schema.Type<typeof CreateScriptSchema>;\n\n export class Create extends S.TaggedClass<Create>()(`${SCRIPT_ACTION}/create`, {\n input: S.extend(CreateScriptSchema, S.Struct({ space: SpaceSchema })),\n output: S.Struct({\n object: ScriptType,\n }),\n }) {}\n}\n\nexport const ScriptSettingsSchema = S.mutable(\n S.Struct({\n editorInputMode: EditorInputMode,\n }),\n);\n\nexport type ScriptSettingsProps = S.Schema.Type<typeof ScriptSettingsSchema>;\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;AAIA,uBAAkC;AAElC,kBAA4B;AAC5B,yBAAkB;AAClB,
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { TitleAnnotationId } from 'effect/SchemaAST';\n\nimport { SpaceSchema } from '@dxos/client/echo';\nimport { S } from '@dxos/echo-schema';\nimport { ScriptType } from '@dxos/functions/types';\nimport { EditorInputMode } from '@dxos/react-ui-editor';\n\nimport { SCRIPT_PLUGIN } from './meta';\n\nexport namespace ScriptAction {\n const SCRIPT_ACTION = `${SCRIPT_PLUGIN}/action`;\n\n export const CreateScriptSchema = S.Struct({\n name: S.optional(S.String),\n // TODO(wittjosiah): Placeholder annotation?\n gistUrl: S.optional(S.String.annotations({ [TitleAnnotationId]: 'Import from Gist (url)' })),\n });\n\n export type CreateScriptProps = S.Schema.Type<typeof CreateScriptSchema>;\n\n export class Create extends S.TaggedClass<Create>()(`${SCRIPT_ACTION}/create`, {\n input: S.extend(CreateScriptSchema, S.Struct({ space: SpaceSchema })),\n output: S.Struct({\n object: ScriptType,\n }),\n }) {}\n}\n\nexport const ScriptSettingsSchema = S.mutable(\n S.Struct({\n editorInputMode: EditorInputMode,\n }),\n);\n\nexport type ScriptSettingsProps = S.Schema.Type<typeof ScriptSettingsSchema>;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;AAIA,uBAAkC;AAElC,kBAA4B;AAC5B,yBAAkB;AAClB,mBAA2B;AAC3B,6BAAgC;;UAIfA,eAAAA;AACf,QAAMC,gBAAgB,GAAGC,mCAAAA;gBAEZC,qBAAqBC,qBAAEC,OAAO;IACzCC,MAAMF,qBAAEG,SAASH,qBAAEI,MAAM;;IAEzBC,SAASL,qBAAEG,SAASH,qBAAEI,OAAOE,YAAY;MAAE,CAACC,kCAAAA,GAAoB;IAAyB,CAAA,CAAA;EAC3F,CAAA;EAIO,MAAMC,eAAeR,qBAAES,YAAW,EAAW,GAAGZ,aAAAA,WAAwB;IAC7Ea,OAAOV,qBAAEW,OAAMf,cAACG,oBAAoBC,qBAAEC,OAAO;MAAEW,OAAOC;IAAY,CAAA,CAAA;IAClEC,QAAQd,qBAAEC,OAAO;MACfc,QAAQC;IACV,CAAA;EACF,CAAA,EAAA;EAAI;gBALSR,SAAAA;AAMf,GAjBiBZ,iBAAAA,eAAAA,CAAAA,EAAAA;AAmBV,IAAMqB,uBAAuBjB,qBAAEkB,QACpClB,qBAAEC,OAAO;EACPkB,iBAAiBC;AACnB,CAAA,CAAA;",
|
|
6
6
|
"names": ["ScriptAction", "SCRIPT_ACTION", "SCRIPT_PLUGIN", "CreateScriptSchema", "S", "Struct", "name", "optional", "String", "gistUrl", "annotations", "TitleAnnotationId", "Create", "TaggedClass", "input", "extend", "space", "SpaceSchema", "output", "object", "ScriptType", "ScriptSettingsSchema", "mutable", "editorInputMode", "EditorInputMode"]
|
|
7
7
|
}
|
|
@@ -16,14 +16,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
return to;
|
|
17
17
|
};
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var
|
|
20
|
-
__export(
|
|
19
|
+
var chunk_XCQNFRZ6_exports = {};
|
|
20
|
+
__export(chunk_XCQNFRZ6_exports, {
|
|
21
21
|
templates: () => templates
|
|
22
22
|
});
|
|
23
|
-
module.exports = __toCommonJS(
|
|
23
|
+
module.exports = __toCommonJS(chunk_XCQNFRZ6_exports);
|
|
24
24
|
var chat_default = "//\n// Copyright 2024 DXOS.org\n//\n\n// @ts-ignore\nimport { transformServerSentEvents } from 'https://esm.sh/@dxos/script-toolbox';\n\n/**\n * Chatbot that answers questions based on the context data.\n */\nexport default async ({\n event: {\n data: { request },\n },\n context: { space, ai },\n}: any) => {\n const textBody = await request.text();\n let parsedRequest: any;\n try {\n parsedRequest = JSON.parse(textBody);\n } catch (err) {\n const answer = await ai.run('@cf/meta/llama-3.1-8b-instruct', {\n stream: true,\n prompt: `\n Using only the context data below to answer the user's question.\n If you cannot answer the question from the provided content, then reply with \"I don't know.\"\n\n CONTEXT:\n ${await getContext({ space })}\n\n QUESTION:\n ${textBody}\n `,\n });\n return new Response(transformServerSentEvents(answer));\n }\n\n const promptId = parsedRequest.trigger.promptId;\n const promptObject = await space.crud.query({ id: promptId }).first();\n\n if (parsedRequest.data.objects.length !== 1) {\n return new Response('Message batches not supported.');\n }\n\n const messageId = parsedRequest.data.objects[0];\n let message;\n try {\n message = await space.crud.query({ id: messageId }).first();\n } catch (err) {\n return new Response('Message not replicated yet.', { status: 409 });\n }\n\n if (message.text.includes('--------')) {\n return new Response('Message was already processed.');\n }\n\n let prompt = promptObject.template;\n for (const input of promptObject.inputs) {\n let value: string | null = null;\n if (input.type === TemplateInputType.VALUE) {\n value = String(input.value);\n } else if (input.type === TemplateInputType.RETRIEVER) {\n value = await getContext({ space });\n } else if (input.type === TemplateInputType.PASS_THROUGH) {\n value = message.text;\n }\n if (value) {\n prompt = prompt.replaceAll(`{${input.name}}`, value);\n }\n }\n\n const answer = await ai.run('@cf/meta/llama-3.1-8b-instruct', {\n stream: false,\n prompt,\n });\n const response = { response: answer.response, prompt, message };\n const textWithAnswer = message.text + '\\n--------\\n\\n' + answer.response;\n await space.crud.update({ id: messageId }, { text: textWithAnswer });\n\n return new Response(JSON.stringify(response));\n};\n\nconst getContext = async ({ space }: any) => {\n let context = '';\n const { objects: docs } = await space.crud.query({ __typename: 'dxos.org/type/Document' }).run();\n for (const doc of docs) {\n const { content } = await space.crud.query({ id: doc.content }).first();\n context += content + '\\n\\n';\n }\n return context;\n};\n\nenum TemplateInputType {\n VALUE = 0,\n PASS_THROUGH = 1,\n RETRIEVER = 2,\n FUNCTION = 3,\n QUERY = 4,\n RESOLVER = 5,\n CONTEXT = 6,\n SCHEMA = 7,\n}\n";
|
|
25
25
|
var chess_default = "// @ts-ignore\nimport { defineFunction, S } from 'dxos:functions';\n// @ts-ignore\nimport { Chess } from 'https://esm.sh/chess.js@0.13.1';\n\nexport default defineFunction({\n description: 'Plays a random move in a chess game.',\n\n inputSchema: S.Struct({\n changedObjectId: S.String.annotations({\n description: 'The objects to play the game on.',\n }),\n player: S.optional(S.Literal('w', 'b')).annotations({\n description: 'The player to play the game as.',\n }),\n }),\n\n outputSchema: S.Struct({\n state: S.String.annotations({\n description: 'The state of the game as an ASCII art board.',\n }),\n }),\n\n handler: async ({\n event: {\n data: { changedObjectId, player = 'b' },\n },\n context: { space },\n }: any) => {\n const { pgn } = await space.db.query({ id: changedObjectId }).first();\n const game = new Chess();\n game.load_pgn(pgn);\n if (game.turn() !== player) {\n return new Response('Invalid turn', { status: 409 });\n }\n\n const moves = game.moves();\n const move = moves[Math.floor(Math.random() * moves.length)];\n if (!move) {\n return new Response('No legal moves', { status: 406 });\n }\n\n game.move(move);\n const newPgn = game.pgn();\n await space.db.update({ id: changedObjectId }, { pgn: newPgn, fen: game.fen() });\n return { state: game.ascii() };\n },\n});\n";
|
|
26
|
-
var discord_default = "//\n// Copyright 2025 DXOS.org\n//\n\n// @ts-ignore\nimport { createStatic, EchoObject, defineFunction, DXN, Filter, ObjectId, S } from 'dxos:functions';\nimport {\n FetchHttpClient,\n // @ts-ignore\n} from 'https://esm.sh/@effect/platform@0.77.2?deps=effect@3.13.3';\n// @ts-ignore\nimport { DiscordConfig, DiscordREST, DiscordRESTMemoryLive } from 'https://esm.sh/dfx@0.113.0?deps=effect@3.13.3';\n// @ts-ignore\nimport { Effect, Config, Redacted, Ref } from 'https://esm.sh/effect@3.13.3';\n\nconst MessageSchema = S.Struct({\n id: S.String,\n foreignId: S.Any, // bigint?\n from: S.String,\n created: S.String,\n content: S.String,\n}).pipe(EchoObject('example.com/type/Message', '0.1.0'));\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 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: ({\n event: {\n data: { channelId, queueId, after = DEFAULT_AFTER, pageSize = 5 },\n },\n context: { space },\n }: any) =>\n Effect.gen(function* () {\n const { token } = yield* Effect.tryPromise(()
|
|
26
|
+
var discord_default = "//\n// Copyright 2025 DXOS.org\n//\n\n// @ts-ignore\nimport { createStatic, EchoObject, defineFunction, DXN, Filter, ObjectId, S } from 'dxos:functions';\nimport {\n FetchHttpClient,\n // @ts-ignore\n} from 'https://esm.sh/@effect/platform@0.77.2?deps=effect@3.13.3';\n// @ts-ignore\nimport { DiscordConfig, DiscordREST, DiscordRESTMemoryLive } from 'https://esm.sh/dfx@0.113.0?deps=effect@3.13.3';\n// @ts-ignore\nimport { Effect, Config, Redacted, Ref } from 'https://esm.sh/effect@3.13.3';\n\nconst MessageSchema = S.Struct({\n id: S.String,\n foreignId: S.Any, // bigint?\n from: S.String,\n created: S.String,\n content: S.String,\n}).pipe(EchoObject('example.com/type/Message', '0.1.0'));\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 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: ({\n event: {\n data: { channelId, queueId, after = DEFAULT_AFTER, pageSize = 5 },\n },\n context: { space },\n }: any) =>\n Effect.gen(function* () {\n const { token } = yield* Effect.tryPromise({\n try: () => space.db.query(Filter.typename('dxos.org/type/AccessToken', { source: 'discord.com' })).first(),\n catch: (e: any) => e,\n });\n const { objects } = yield* Effect.tryPromise({\n try: () => space.queues.queryQueue(DXN.parse(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 createStatic(MessageSchema, {\n id: ObjectId.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.parse(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";
|
|
27
27
|
var echo_default = "//\n// Copyright 2024 DXOS.org\n//\n\n/**\n * Echos the request data.\n */\nexport default async ({\n event: {\n data: { request },\n },\n}: any) => {\n const data = await request.json();\n return new Response(JSON.stringify(data ?? {}), {\n headers: {\n 'Content-Type': 'application/json',\n },\n });\n};\n";
|
|
28
28
|
var email_default = "//\n// Copyright 2024 DXOS.org\n//\n\n/**\n * Appends a message to the end of a Document configured through a trigger.\n * Trigger must have a targetDocumentId field set in Meta.\n */\nexport default async ({\n event: {\n data: { request },\n },\n context: { space },\n}: any) => {\n const { data, trigger } = (await request.json()) as RequestPayload;\n\n const documentId = trigger.meta.targetDocumentId;\n const document = await space.db.query({ id: documentId }, { format: 'plain' }).first();\n\n const contentId = document.content['/'].split(':')[3];\n const documentContent = await space.db.query({ id: contentId }, { format: 'plain' }).first();\n const modifiedContent = [\n documentContent.content,\n '',\n '---',\n `**From:** ${data.from}`,\n `**Subject:** ${data.subject}`,\n `**Date:** ${data.created}`,\n '',\n data.body,\n ].join('\\n');\n\n await space.db.update({ id: contentId }, { content: modifiedContent });\n\n return new Response(JSON.stringify({ success: true }));\n};\n\ntype RequestPayload = {\n data: { from: string; subject: string; created: string; body: string };\n trigger: { meta: { targetDocumentId: string } };\n};\n";
|
|
29
29
|
var forex_effect_default = "//\n// Copyright 2025 DXOS.org\n//\n\n// @ts-ignore\nimport { defineFunction, S } from 'dxos:functions';\nimport {\n HttpClient,\n HttpClientRequest,\n FetchHttpClient,\n // @ts-ignore\n} from 'https://esm.sh/@effect/platform@0.77.2?deps=effect@3.13.3';\n// @ts-ignore\nimport { Effect, Schedule } from 'https://esm.sh/effect@3.13.3';\n\nexport default defineFunction({\n description: 'Returns the exchange rate between two currencies.',\n\n inputSchema: S.Struct({\n from: S.String.annotations({ description: 'The source currency' }),\n to: S.String.annotations({ description: 'The target currency' }),\n }),\n\n outputSchema: S.String.annotations({ description: 'The exchange rate between the two currencies' }),\n\n handler: async ({\n event: {\n data: { from, to },\n },\n }: any) =>\n Effect.gen(function* () {\n const res = yield* HttpClientRequest.get(`https://free.ratesdb.com/v1/rates?from=${from}&to=${to}`).pipe(\n HttpClient.execute,\n Effect.flatMap((res: any) => res.json),\n Effect.timeout('1 second'),\n Effect.retry(Schedule.exponential(1000).pipe(Schedule.compose(Schedule.recurs(3)))),\n Effect.scoped,\n );\n return res.data.rates[to].toString();\n }).pipe(Effect.provide(FetchHttpClient.layer)),\n});\n";
|
|
@@ -74,4 +74,4 @@ var templates = [
|
|
|
74
74
|
0 && (module.exports = {
|
|
75
75
|
templates
|
|
76
76
|
});
|
|
77
|
-
//# sourceMappingURL=chunk-
|
|
77
|
+
//# sourceMappingURL=chunk-XCQNFRZ6.cjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["raw-loader:./chat.ts?raw", "raw-loader:./chess.ts?raw", "raw-loader:./discord.ts?raw", "raw-loader:./echo.ts?raw", "raw-loader:./email.ts?raw", "raw-loader:./forex-effect.ts?raw", "raw-loader:./forex.ts?raw", "../../../src/templates/index.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\n// @ts-ignore\nimport { transformServerSentEvents } from 'https://esm.sh/@dxos/script-toolbox';\n\n/**\n * Chatbot that answers questions based on the context data.\n */\nexport default async ({\n event: {\n data: { request },\n },\n context: { space, ai },\n}: any) => {\n const textBody = await request.text();\n let parsedRequest: any;\n try {\n parsedRequest = JSON.parse(textBody);\n } catch (err) {\n const answer = await ai.run('@cf/meta/llama-3.1-8b-instruct', {\n stream: true,\n prompt: `\n Using only the context data below to answer the user's question.\n If you cannot answer the question from the provided content, then reply with \"I don't know.\"\n\n CONTEXT:\n ${await getContext({ space })}\n\n QUESTION:\n ${textBody}\n `,\n });\n return new Response(transformServerSentEvents(answer));\n }\n\n const promptId = parsedRequest.trigger.promptId;\n const promptObject = await space.crud.query({ id: promptId }).first();\n\n if (parsedRequest.data.objects.length !== 1) {\n return new Response('Message batches not supported.');\n }\n\n const messageId = parsedRequest.data.objects[0];\n let message;\n try {\n message = await space.crud.query({ id: messageId }).first();\n } catch (err) {\n return new Response('Message not replicated yet.', { status: 409 });\n }\n\n if (message.text.includes('--------')) {\n return new Response('Message was already processed.');\n }\n\n let prompt = promptObject.template;\n for (const input of promptObject.inputs) {\n let value: string | null = null;\n if (input.type === TemplateInputType.VALUE) {\n value = String(input.value);\n } else if (input.type === TemplateInputType.RETRIEVER) {\n value = await getContext({ space });\n } else if (input.type === TemplateInputType.PASS_THROUGH) {\n value = message.text;\n }\n if (value) {\n prompt = prompt.replaceAll(`{${input.name}}`, value);\n }\n }\n\n const answer = await ai.run('@cf/meta/llama-3.1-8b-instruct', {\n stream: false,\n prompt,\n });\n const response = { response: answer.response, prompt, message };\n const textWithAnswer = message.text + '\\n--------\\n\\n' + answer.response;\n await space.crud.update({ id: messageId }, { text: textWithAnswer });\n\n return new Response(JSON.stringify(response));\n};\n\nconst getContext = async ({ space }: any) => {\n let context = '';\n const { objects: docs } = await space.crud.query({ __typename: 'dxos.org/type/Document' }).run();\n for (const doc of docs) {\n const { content } = await space.crud.query({ id: doc.content }).first();\n context += content + '\\n\\n';\n }\n return context;\n};\n\nenum TemplateInputType {\n VALUE = 0,\n PASS_THROUGH = 1,\n RETRIEVER = 2,\n FUNCTION = 3,\n QUERY = 4,\n RESOLVER = 5,\n CONTEXT = 6,\n SCHEMA = 7,\n}\n", "// @ts-ignore\nimport { defineFunction, S } from 'dxos:functions';\n// @ts-ignore\nimport { Chess } from 'https://esm.sh/chess.js@0.13.1';\n\nexport default defineFunction({\n description: 'Plays a random move in a chess game.',\n\n inputSchema: S.Struct({\n changedObjectId: S.String.annotations({\n description: 'The objects to play the game on.',\n }),\n player: S.optional(S.Literal('w', 'b')).annotations({\n description: 'The player to play the game as.',\n }),\n }),\n\n outputSchema: S.Struct({\n state: S.String.annotations({\n description: 'The state of the game as an ASCII art board.',\n }),\n }),\n\n handler: async ({\n event: {\n data: { changedObjectId, player = 'b' },\n },\n context: { space },\n }: any) => {\n const { pgn } = await space.db.query({ id: changedObjectId }).first();\n const game = new Chess();\n game.load_pgn(pgn);\n if (game.turn() !== player) {\n return new Response('Invalid turn', { status: 409 });\n }\n\n const moves = game.moves();\n const move = moves[Math.floor(Math.random() * moves.length)];\n if (!move) {\n return new Response('No legal moves', { status: 406 });\n }\n\n game.move(move);\n const newPgn = game.pgn();\n await space.db.update({ id: changedObjectId }, { pgn: newPgn, fen: game.fen() });\n return { state: game.ascii() };\n },\n});\n", "//\n// Copyright 2025 DXOS.org\n//\n\n// @ts-ignore\nimport { createStatic, EchoObject, defineFunction, DXN, Filter, ObjectId, S } from 'dxos:functions';\nimport {\n FetchHttpClient,\n // @ts-ignore\n} from 'https://esm.sh/@effect/platform@0.77.2?deps=effect@3.13.3';\n// @ts-ignore\nimport { DiscordConfig, DiscordREST, DiscordRESTMemoryLive } from 'https://esm.sh/dfx@0.113.0?deps=effect@3.13.3';\n// @ts-ignore\nimport { Effect, Config, Redacted, Ref } from 'https://esm.sh/effect@3.13.3';\n\nconst MessageSchema = S.Struct({\n id: S.String,\n foreignId: S.Any, // bigint?\n from: S.String,\n created: S.String,\n content: S.String,\n}).pipe(EchoObject('example.com/type/Message', '0.1.0'));\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 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: ({\n event: {\n data: { channelId, queueId, after = DEFAULT_AFTER, pageSize = 5 },\n },\n context: { space },\n }: any) =>\n Effect.gen(function* () {\n const { token } = yield* Effect.tryPromise({\n try: () => space.db.query(Filter.typename('dxos.org/type/AccessToken', { source: 'discord.com' })).first(),\n catch: (e: any) => e,\n });\n const { objects } = yield* Effect.tryPromise({\n try: () => space.queues.queryQueue(DXN.parse(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 createStatic(MessageSchema, {\n id: ObjectId.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.parse(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 * Echos the request data.\n */\nexport default async ({\n event: {\n data: { request },\n },\n}: any) => {\n const data = await request.json();\n return new Response(JSON.stringify(data ?? {}), {\n headers: {\n 'Content-Type': 'application/json',\n },\n });\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\n/**\n * Appends a message to the end of a Document configured through a trigger.\n * Trigger must have a targetDocumentId field set in Meta.\n */\nexport default async ({\n event: {\n data: { request },\n },\n context: { space },\n}: any) => {\n const { data, trigger } = (await request.json()) as RequestPayload;\n\n const documentId = trigger.meta.targetDocumentId;\n const document = await space.db.query({ id: documentId }, { format: 'plain' }).first();\n\n const contentId = document.content['/'].split(':')[3];\n const documentContent = await space.db.query({ id: contentId }, { format: 'plain' }).first();\n const modifiedContent = [\n documentContent.content,\n '',\n '---',\n `**From:** ${data.from}`,\n `**Subject:** ${data.subject}`,\n `**Date:** ${data.created}`,\n '',\n data.body,\n ].join('\\n');\n\n await space.db.update({ id: contentId }, { content: modifiedContent });\n\n return new Response(JSON.stringify({ success: true }));\n};\n\ntype RequestPayload = {\n data: { from: string; subject: string; created: string; body: string };\n trigger: { meta: { targetDocumentId: string } };\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\n// @ts-ignore\nimport { defineFunction, S } from 'dxos:functions';\nimport {\n HttpClient,\n HttpClientRequest,\n FetchHttpClient,\n // @ts-ignore\n} from 'https://esm.sh/@effect/platform@0.77.2?deps=effect@3.13.3';\n// @ts-ignore\nimport { Effect, Schedule } from 'https://esm.sh/effect@3.13.3';\n\nexport default defineFunction({\n description: 'Returns the exchange rate between two currencies.',\n\n inputSchema: S.Struct({\n from: S.String.annotations({ description: 'The source currency' }),\n to: S.String.annotations({ description: 'The target currency' }),\n }),\n\n outputSchema: S.String.annotations({ description: 'The exchange rate between the two currencies' }),\n\n handler: async ({\n event: {\n data: { from, to },\n },\n }: any) =>\n Effect.gen(function* () {\n const res = yield* HttpClientRequest.get(`https://free.ratesdb.com/v1/rates?from=${from}&to=${to}`).pipe(\n HttpClient.execute,\n Effect.flatMap((res: any) => res.json),\n Effect.timeout('1 second'),\n Effect.retry(Schedule.exponential(1000).pipe(Schedule.compose(Schedule.recurs(3)))),\n Effect.scoped,\n );\n return res.data.rates[to].toString();\n }).pipe(Effect.provide(FetchHttpClient.layer)),\n});\n", "//\n// Copyright 2025 DXOS.org\n//\n\n// @ts-ignore\nimport { defineFunction, S } from 'dxos:functions';\n\nexport default defineFunction({\n description: 'Returns the exchange rate between two currencies.',\n\n inputSchema: S.Struct({\n from: S.String.annotations({ description: 'The source currency' }),\n to: S.String.annotations({ description: 'The target currency' }),\n }),\n\n handler: async ({\n event: {\n data: { from, to },\n },\n }: any) => {\n const res = await fetch(`https://free.ratesdb.com/v1/rates?from=${from}&to=${to}`);\n const {\n data: { rates },\n } = await res.json();\n\n return rates[to].toString();\n },\n});\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport chat from './chat.ts?raw';\nimport chess from './chess.ts?raw';\nimport discord from './discord.ts?raw';\nimport echo from './echo.ts?raw';\nimport email from './email.ts?raw';\nimport forexEffect from './forex-effect.ts?raw';\nimport forex from './forex.ts?raw';\n\nconst removeHeader = (str: string) => str.split('\\n').slice(4).join('\\n');\n\nexport type Template = {\n id: string;\n name: string;\n source: string;\n presetId?: string;\n};\n\nexport const templates: Template[] = [\n {\n id: 'dxos.org/script/echo',\n name: 'Echo',\n source: removeHeader(echo),\n },\n {\n id: 'dxos.org/script/forex',\n name: 'Forex',\n source: removeHeader(forex),\n },\n {\n id: 'dxos.org/script/forex-effect',\n name: 'Forex (Effect)',\n source: removeHeader(forexEffect),\n },\n {\n id: 'dxos.org/script/gpt',\n name: 'Gpt',\n source: removeHeader(chat),\n presetId: 'dxos.org/function/gpt',\n },\n {\n id: 'dxos.org/script/chess',\n name: 'Chess',\n source: removeHeader(chess),\n presetId: 'dxos.org/function/chess',\n },\n {\n id: 'dxos.org/script/email',\n name: 'Email',\n source: removeHeader(email),\n presetId: 'dxos.org/function/email',\n },\n {\n id: 'dxos.org/script/discord',\n name: 'Discord',\n source: removeHeader(discord),\n presetId: 'dxos.org/function/discord',\n },\n];\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAA,eAAA;ACAA,IAAA,gBAAA;ACAA,IAAA,kBAAA;ACAA,IAAA,eAAA;ACAA,IAAA,gBAAA;ACAA,IAAA,uBAAA;ACAA,IAAA,gBAAA;ACYA,IAAMA,eAAe,CAACC,QAAgBA,IAAIC,MAAM,IAAA,EAAMC,MAAM,CAAA,EAAGC,KAAK,IAAA;AAS7D,IAAMC,YAAwB;EACnC;IACEC,IAAI;IACJC,MAAM;IACNC,QAAQR,aAAaS,YAAAA;EACvB;EACA;IACEH,IAAI;IACJC,MAAM;IACNC,QAAQR,aAAaU,aAAAA;EACvB;EACA;IACEJ,IAAI;IACJC,MAAM;IACNC,QAAQR,aAAaW,oBAAAA;EACvB;EACA;IACEL,IAAI;IACJC,MAAM;IACNC,QAAQR,aAAaY,YAAAA;IACrBC,UAAU;EACZ;EACA;IACEP,IAAI;IACJC,MAAM;IACNC,QAAQR,aAAac,aAAAA;IACrBD,UAAU;EACZ;EACA;IACEP,IAAI;IACJC,MAAM;IACNC,QAAQR,aAAae,aAAAA;IACrBF,UAAU;EACZ;EACA;IACEP,IAAI;IACJC,MAAM;IACNC,QAAQR,aAAagB,eAAAA;IACrBH,UAAU;EACZ;;",
|
|
6
|
+
"names": ["removeHeader", "str", "split", "slice", "join", "templates", "id", "name", "source", "echo", "forex", "forexEffect", "chat", "presetId", "chess", "email", "discord"]
|
|
7
|
+
}
|
package/dist/lib/node/index.cjs
CHANGED
|
@@ -28,39 +28,39 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
29
|
var node_exports = {};
|
|
30
30
|
__export(node_exports, {
|
|
31
|
-
DebugPanel: () =>
|
|
32
|
-
LogsPanel: () =>
|
|
31
|
+
DebugPanel: () => import_chunk_PTXU7QFZ.DebugPanel,
|
|
32
|
+
LogsPanel: () => import_chunk_B2O7H2AU.LogsPanel,
|
|
33
33
|
SCRIPT_PLUGIN: () => import_chunk_5UH3F7TA.SCRIPT_PLUGIN,
|
|
34
34
|
ScriptCapabilities: () => import_chunk_ALY3N6PW.ScriptCapabilities,
|
|
35
|
-
ScriptContainer: () =>
|
|
35
|
+
ScriptContainer: () => import_chunk_PTXU7QFZ.ScriptContainer,
|
|
36
36
|
ScriptPlugin: () => ScriptPlugin,
|
|
37
|
-
ScriptSettings: () =>
|
|
38
|
-
ScriptSettingsPanel: () =>
|
|
37
|
+
ScriptSettings: () => import_chunk_PTXU7QFZ.ScriptSettings,
|
|
38
|
+
ScriptSettingsPanel: () => import_chunk_PTXU7QFZ.ScriptSettingsPanel,
|
|
39
39
|
meta: () => import_chunk_5UH3F7TA.meta
|
|
40
40
|
});
|
|
41
41
|
module.exports = __toCommonJS(node_exports);
|
|
42
|
-
var
|
|
42
|
+
var import_chunk_PTXU7QFZ = require("./chunk-PTXU7QFZ.cjs");
|
|
43
43
|
var import_chunk_ALY3N6PW = require("./chunk-ALY3N6PW.cjs");
|
|
44
|
-
var
|
|
45
|
-
var
|
|
46
|
-
var
|
|
44
|
+
var import_chunk_B2O7H2AU = require("./chunk-B2O7H2AU.cjs");
|
|
45
|
+
var import_chunk_XCQNFRZ6 = require("./chunk-XCQNFRZ6.cjs");
|
|
46
|
+
var import_chunk_VJ73IG7P = require("./chunk-VJ73IG7P.cjs");
|
|
47
47
|
var import_chunk_5UH3F7TA = require("./chunk-5UH3F7TA.cjs");
|
|
48
48
|
var import_app_framework = require("@dxos/app-framework");
|
|
49
49
|
var import_app_framework2 = require("@dxos/app-framework");
|
|
50
|
-
var
|
|
50
|
+
var import_types = require("@dxos/functions/types");
|
|
51
51
|
var import_live_object = require("@dxos/live-object");
|
|
52
52
|
var import_plugin_client = require("@dxos/plugin-client");
|
|
53
53
|
var import_plugin_deck = require("@dxos/plugin-deck");
|
|
54
54
|
var import_plugin_space = require("@dxos/plugin-space");
|
|
55
|
-
var
|
|
55
|
+
var import_types2 = require("@dxos/plugin-space/types");
|
|
56
56
|
var import_echo = require("@dxos/react-client/echo");
|
|
57
57
|
var import_app_framework3 = require("@dxos/app-framework");
|
|
58
|
-
var
|
|
58
|
+
var import_types3 = require("@dxos/functions/types");
|
|
59
59
|
var Compiler = (0, import_app_framework.lazy)(() => import("./compiler-UIBLKJKG.cjs"));
|
|
60
|
-
var IntentResolver = (0, import_app_framework.lazy)(() => import("./intent-resolver-
|
|
61
|
-
var ReactSurface = (0, import_app_framework.lazy)(() => import("./react-surface-
|
|
62
|
-
var ScriptSettings2 = (0, import_app_framework.lazy)(() => import("./settings-
|
|
63
|
-
var ArtifactDefinition = (0, import_app_framework.lazy)(() => import("./artifact-definition-
|
|
60
|
+
var IntentResolver = (0, import_app_framework.lazy)(() => import("./intent-resolver-HQ3FGK2K.cjs"));
|
|
61
|
+
var ReactSurface = (0, import_app_framework.lazy)(() => import("./react-surface-JDA5UZCC.cjs"));
|
|
62
|
+
var ScriptSettings2 = (0, import_app_framework.lazy)(() => import("./settings-ZASSNBKR.cjs"));
|
|
63
|
+
var ArtifactDefinition = (0, import_app_framework.lazy)(() => import("./artifact-definition-64KZC4UT.cjs"));
|
|
64
64
|
var ScriptEvents;
|
|
65
65
|
(function(ScriptEvents2) {
|
|
66
66
|
ScriptEvents2.SetupCompiler = (0, import_app_framework3.defineEvent)(`${import_chunk_5UH3F7TA.SCRIPT_PLUGIN}/event/setup-compiler`);
|
|
@@ -68,7 +68,7 @@ var ScriptEvents;
|
|
|
68
68
|
var translations_default = [
|
|
69
69
|
{
|
|
70
70
|
"en-US": {
|
|
71
|
-
[
|
|
71
|
+
[import_types3.ScriptType.typename]: {
|
|
72
72
|
"typename label": "Script"
|
|
73
73
|
},
|
|
74
74
|
[import_chunk_5UH3F7TA.SCRIPT_PLUGIN]: {
|
|
@@ -134,7 +134,7 @@ var ScriptPlugin = () => (0, import_app_framework2.definePlugin)(import_chunk_5U
|
|
|
134
134
|
id: `${import_chunk_5UH3F7TA.meta.id}/module/metadata`,
|
|
135
135
|
activatesOn: import_app_framework2.Events.SetupMetadata,
|
|
136
136
|
activate: () => (0, import_app_framework2.contributes)(import_app_framework2.Capabilities.Metadata, {
|
|
137
|
-
id:
|
|
137
|
+
id: import_types.ScriptType.typename,
|
|
138
138
|
metadata: {
|
|
139
139
|
placeholder: [
|
|
140
140
|
"object title placeholder",
|
|
@@ -163,16 +163,16 @@ var ScriptPlugin = () => (0, import_app_framework2.definePlugin)(import_chunk_5U
|
|
|
163
163
|
],
|
|
164
164
|
icon: "ph--terminal--regular",
|
|
165
165
|
fixed: true,
|
|
166
|
-
filter: (node) => node.data instanceof
|
|
166
|
+
filter: (node) => node.data instanceof import_types.ScriptType && !!(0, import_echo.getSpace)(node.data)
|
|
167
167
|
})
|
|
168
168
|
}),
|
|
169
169
|
(0, import_app_framework2.defineModule)({
|
|
170
170
|
id: `${import_chunk_5UH3F7TA.meta.id}/module/object-form`,
|
|
171
171
|
activatesOn: import_plugin_client.ClientEvents.SetupSchema,
|
|
172
|
-
activate: () => (0, import_app_framework2.contributes)(import_plugin_space.SpaceCapabilities.ObjectForm, (0,
|
|
173
|
-
objectSchema:
|
|
174
|
-
formSchema:
|
|
175
|
-
getIntent: (props, options) => (0, import_app_framework2.createIntent)(
|
|
172
|
+
activate: () => (0, import_app_framework2.contributes)(import_plugin_space.SpaceCapabilities.ObjectForm, (0, import_types2.defineObjectForm)({
|
|
173
|
+
objectSchema: import_types.ScriptType,
|
|
174
|
+
formSchema: import_chunk_VJ73IG7P.ScriptAction.CreateScriptSchema,
|
|
175
|
+
getIntent: (props, options) => (0, import_app_framework2.createIntent)(import_chunk_VJ73IG7P.ScriptAction.Create, {
|
|
176
176
|
...props,
|
|
177
177
|
space: options.space
|
|
178
178
|
})
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/capabilities/index.ts", "../../../src/ScriptPlugin.tsx", "../../../src/events.ts", "../../../src/translations.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { lazy } from '@dxos/app-framework';\n\nexport const Compiler = lazy(() => import('./compiler'));\nexport const IntentResolver = lazy(() => import('./intent-resolver'));\nexport const ReactSurface = lazy(() => import('./react-surface'));\nexport const ScriptSettings = lazy(() => import('./settings'));\nexport const ArtifactDefinition = lazy(() => import('./artifact-definition'));\n\nexport * from './capabilities';\n", "//\n// Copyright 2023 DXOS.org\n//\n\n// @ts-ignore\n\nimport { Capabilities, contributes, createIntent, defineModule, definePlugin, Events } from '@dxos/app-framework';\nimport { ScriptType } from '@dxos/functions';\nimport { RefArray } from '@dxos/live-object';\nimport { ClientEvents } from '@dxos/plugin-client';\nimport { DeckCapabilities, DeckEvents } from '@dxos/plugin-deck';\nimport { SpaceCapabilities } from '@dxos/plugin-space';\nimport { defineObjectForm } from '@dxos/plugin-space/types';\nimport { getSpace } from '@dxos/react-client/echo';\n\nimport { ArtifactDefinition, Compiler, IntentResolver, ReactSurface, ScriptSettings } from './capabilities';\nimport { ScriptEvents } from './events';\nimport { meta, SCRIPT_PLUGIN } from './meta';\nimport translations from './translations';\nimport { ScriptAction } from './types';\n\nexport const ScriptPlugin = () =>\n definePlugin(meta, [\n defineModule({\n id: `${meta.id}/module/settings`,\n activatesOn: Events.SetupSettings,\n activate: ScriptSettings,\n }),\n defineModule({\n id: `${meta.id}/module/compiler`,\n activatesOn: ScriptEvents.SetupCompiler,\n activate: Compiler,\n }),\n defineModule({\n id: `${meta.id}/module/translations`,\n activatesOn: Events.SetupTranslations,\n activate: () => contributes(Capabilities.Translations, translations),\n }),\n defineModule({\n id: `${meta.id}/module/metadata`,\n activatesOn: Events.SetupMetadata,\n activate: () =>\n contributes(Capabilities.Metadata, {\n id: ScriptType.typename,\n metadata: {\n placeholder: ['object title placeholder', { ns: SCRIPT_PLUGIN }],\n icon: 'ph--code--regular',\n // TODO(wittjosiah): Move out of metadata.\n loadReferences: async (script: ScriptType) => await RefArray.loadAll([script.source]),\n },\n }),\n }),\n defineModule({\n id: `${meta.id}/module/complementary-panels`,\n activatesOn: DeckEvents.SetupComplementaryPanels,\n activate: () =>\n contributes(DeckCapabilities.ComplementaryPanel, {\n id: 'function',\n label: ['function panel label', { ns: SCRIPT_PLUGIN }],\n icon: 'ph--terminal--regular',\n fixed: true,\n filter: (node) => node.data instanceof ScriptType && !!getSpace(node.data),\n }),\n }),\n defineModule({\n id: `${meta.id}/module/object-form`,\n activatesOn: ClientEvents.SetupSchema,\n activate: () =>\n contributes(\n SpaceCapabilities.ObjectForm,\n defineObjectForm({\n objectSchema: ScriptType,\n formSchema: ScriptAction.CreateScriptSchema,\n getIntent: (props, options) => createIntent(ScriptAction.Create, { ...props, space: options.space }),\n }),\n ),\n }),\n defineModule({\n id: `${meta.id}/module/react-surface`,\n activatesOn: Events.SetupReactSurface,\n // TODO(wittjosiah): Should occur before the script editor is loaded when surfaces activation is more granular.\n activatesBefore: [ScriptEvents.SetupCompiler],\n activate: ReactSurface,\n }),\n defineModule({\n id: `${meta.id}/module/intent-resolver`,\n activatesOn: Events.SetupIntentResolver,\n activate: IntentResolver,\n }),\n defineModule({\n id: `${meta.id}/module/artifact-definition`,\n activatesOn: Events.SetupArtifactDefinition,\n activate: ArtifactDefinition,\n }),\n ]);\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { defineEvent } from '@dxos/app-framework';\n\nimport { SCRIPT_PLUGIN } from './meta';\n\nexport namespace ScriptEvents {\n export const SetupCompiler = defineEvent(`${SCRIPT_PLUGIN}/event/setup-compiler`);\n}\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { ScriptType } from '@dxos/functions';\n\nimport { SCRIPT_PLUGIN } from './meta';\n\nexport default [\n {\n 'en-US': {\n [ScriptType.typename]: {\n 'typename label': 'Script',\n },\n [SCRIPT_PLUGIN]: {\n 'plugin name': 'Scripts',\n 'object title placeholder': 'New script',\n 'create object label': 'Create script',\n 'create stack section label': 'Create script',\n 'description label': 'Description',\n 'description placeholder': 'Describe what the script does.',\n 'binding placeholder': 'Function name',\n 'function request placeholder': 'Function request',\n 'deploy label': 'Deploy',\n 'deployed label': 'Current version of the script is deployed',\n 'upload failed label': 'Upload failed',\n 'copy link label': 'Copy function link',\n 'format label': 'Format',\n 'toggle details label': 'Toggle details panel',\n 'authenticate action label': 'Authenticate functions service',\n 'authenticate button label': 'Authenticate',\n 'name label': 'Name',\n 'remote function settings heading': 'Remote Function',\n 'function url label': 'Invocation URL',\n 'function binding label': 'Function binding',\n 'function binding placeholder': 'BINDING',\n 'script publish settings label': 'Publishing',\n 'script publish settings description': 'Scripts can be shared publicly as Github gists.',\n 'no github token label': 'This space has no Github access token available.',\n 'open token manager label': 'Open Token Manager',\n 'publish label': 'Publish',\n 'publishing label': 'Publishing',\n 'editor input mode label': 'Editor input mode',\n 'select editor input mode placeholder': 'Select editor input mode…',\n 'settings editor input mode default label': 'Default',\n 'settings editor input mode vim label': 'Vim',\n 'settings editor input mode vscode label': 'VS Code',\n 'view group label': 'View',\n 'view editor label': 'Editor',\n 'view split label': 'Split',\n 'view logs label': 'Logs',\n 'template select group label': 'Select template',\n 'function panel label': 'Debug Function',\n },\n },\n },\n];\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,2BAAqB;ACErB,IAAAA,wBAA4F;AAC5F,
|
|
6
|
-
"names": ["import_app_framework", "
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { lazy } from '@dxos/app-framework';\n\nexport const Compiler = lazy(() => import('./compiler'));\nexport const IntentResolver = lazy(() => import('./intent-resolver'));\nexport const ReactSurface = lazy(() => import('./react-surface'));\nexport const ScriptSettings = lazy(() => import('./settings'));\nexport const ArtifactDefinition = lazy(() => import('./artifact-definition'));\n\nexport * from './capabilities';\n", "//\n// Copyright 2023 DXOS.org\n//\n\n// @ts-ignore\n\nimport { Capabilities, contributes, createIntent, defineModule, definePlugin, Events } from '@dxos/app-framework';\nimport { ScriptType } from '@dxos/functions/types';\nimport { RefArray } from '@dxos/live-object';\nimport { ClientEvents } from '@dxos/plugin-client';\nimport { DeckCapabilities, DeckEvents } from '@dxos/plugin-deck';\nimport { SpaceCapabilities } from '@dxos/plugin-space';\nimport { defineObjectForm } from '@dxos/plugin-space/types';\nimport { getSpace } from '@dxos/react-client/echo';\n\nimport { ArtifactDefinition, Compiler, IntentResolver, ReactSurface, ScriptSettings } from './capabilities';\nimport { ScriptEvents } from './events';\nimport { meta, SCRIPT_PLUGIN } from './meta';\nimport translations from './translations';\nimport { ScriptAction } from './types';\n\nexport const ScriptPlugin = () =>\n definePlugin(meta, [\n defineModule({\n id: `${meta.id}/module/settings`,\n activatesOn: Events.SetupSettings,\n activate: ScriptSettings,\n }),\n defineModule({\n id: `${meta.id}/module/compiler`,\n activatesOn: ScriptEvents.SetupCompiler,\n activate: Compiler,\n }),\n defineModule({\n id: `${meta.id}/module/translations`,\n activatesOn: Events.SetupTranslations,\n activate: () => contributes(Capabilities.Translations, translations),\n }),\n defineModule({\n id: `${meta.id}/module/metadata`,\n activatesOn: Events.SetupMetadata,\n activate: () =>\n contributes(Capabilities.Metadata, {\n id: ScriptType.typename,\n metadata: {\n placeholder: ['object title placeholder', { ns: SCRIPT_PLUGIN }],\n icon: 'ph--code--regular',\n // TODO(wittjosiah): Move out of metadata.\n loadReferences: async (script: ScriptType) => await RefArray.loadAll([script.source]),\n },\n }),\n }),\n defineModule({\n id: `${meta.id}/module/complementary-panels`,\n activatesOn: DeckEvents.SetupComplementaryPanels,\n activate: () =>\n contributes(DeckCapabilities.ComplementaryPanel, {\n id: 'function',\n label: ['function panel label', { ns: SCRIPT_PLUGIN }],\n icon: 'ph--terminal--regular',\n fixed: true,\n filter: (node) => node.data instanceof ScriptType && !!getSpace(node.data),\n }),\n }),\n defineModule({\n id: `${meta.id}/module/object-form`,\n activatesOn: ClientEvents.SetupSchema,\n activate: () =>\n contributes(\n SpaceCapabilities.ObjectForm,\n defineObjectForm({\n objectSchema: ScriptType,\n formSchema: ScriptAction.CreateScriptSchema,\n getIntent: (props, options) => createIntent(ScriptAction.Create, { ...props, space: options.space }),\n }),\n ),\n }),\n defineModule({\n id: `${meta.id}/module/react-surface`,\n activatesOn: Events.SetupReactSurface,\n // TODO(wittjosiah): Should occur before the script editor is loaded when surfaces activation is more granular.\n activatesBefore: [ScriptEvents.SetupCompiler],\n activate: ReactSurface,\n }),\n defineModule({\n id: `${meta.id}/module/intent-resolver`,\n activatesOn: Events.SetupIntentResolver,\n activate: IntentResolver,\n }),\n defineModule({\n id: `${meta.id}/module/artifact-definition`,\n activatesOn: Events.SetupArtifactDefinition,\n activate: ArtifactDefinition,\n }),\n ]);\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { defineEvent } from '@dxos/app-framework';\n\nimport { SCRIPT_PLUGIN } from './meta';\n\nexport namespace ScriptEvents {\n export const SetupCompiler = defineEvent(`${SCRIPT_PLUGIN}/event/setup-compiler`);\n}\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { ScriptType } from '@dxos/functions/types';\n\nimport { SCRIPT_PLUGIN } from './meta';\n\nexport default [\n {\n 'en-US': {\n [ScriptType.typename]: {\n 'typename label': 'Script',\n },\n [SCRIPT_PLUGIN]: {\n 'plugin name': 'Scripts',\n 'object title placeholder': 'New script',\n 'create object label': 'Create script',\n 'create stack section label': 'Create script',\n 'description label': 'Description',\n 'description placeholder': 'Describe what the script does.',\n 'binding placeholder': 'Function name',\n 'function request placeholder': 'Function request',\n 'deploy label': 'Deploy',\n 'deployed label': 'Current version of the script is deployed',\n 'upload failed label': 'Upload failed',\n 'copy link label': 'Copy function link',\n 'format label': 'Format',\n 'toggle details label': 'Toggle details panel',\n 'authenticate action label': 'Authenticate functions service',\n 'authenticate button label': 'Authenticate',\n 'name label': 'Name',\n 'remote function settings heading': 'Remote Function',\n 'function url label': 'Invocation URL',\n 'function binding label': 'Function binding',\n 'function binding placeholder': 'BINDING',\n 'script publish settings label': 'Publishing',\n 'script publish settings description': 'Scripts can be shared publicly as Github gists.',\n 'no github token label': 'This space has no Github access token available.',\n 'open token manager label': 'Open Token Manager',\n 'publish label': 'Publish',\n 'publishing label': 'Publishing',\n 'editor input mode label': 'Editor input mode',\n 'select editor input mode placeholder': 'Select editor input mode…',\n 'settings editor input mode default label': 'Default',\n 'settings editor input mode vim label': 'Vim',\n 'settings editor input mode vscode label': 'VS Code',\n 'view group label': 'View',\n 'view editor label': 'Editor',\n 'view split label': 'Split',\n 'view logs label': 'Logs',\n 'template select group label': 'Select template',\n 'function panel label': 'Debug Function',\n },\n },\n },\n];\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,2BAAqB;ACErB,IAAAA,wBAA4F;AAC5F,mBAA2B;AAC3B,yBAAyB;AACzB,2BAA6B;AAC7B,yBAA6C;AAC7C,0BAAkC;AAClC,IAAAC,gBAAiC;AACjC,kBAAyB;ACTzB,IAAAD,wBAA4B;ACA5B,IAAAC,gBAA2B;AHEpB,IAAMC,eAAWC,2BAAK,MAAM,OAAO,yBAAA,CAAA;AACnC,IAAMC,qBAAiBD,2BAAK,MAAM,OAAO,gCAAA,CAAA;AACzC,IAAME,mBAAeF,2BAAK,MAAM,OAAO,8BAAA,CAAA;AACvC,IAAMG,sBAAiBH,2BAAK,MAAM,OAAO,yBAAA,CAAA;AACzC,IAAMI,yBAAqBJ,2BAAK,MAAM,OAAO,oCAAA,CAAA;;UEFnCK,eAAAA;gBACFC,oBAAgBC,mCAAY,GAAGC,mCAAAA,uBAAoC;AAClF,GAFiBH,iBAAAA,eAAAA,CAAAA,EAAAA;ACAjB,IAAA,uBAAe;EACb;IACE,SAAS;MACP,CAACI,yBAAWC,QAAQ,GAAG;QACrB,kBAAkB;MACpB;MACA,CAACF,mCAAAA,GAAgB;QACf,eAAe;QACf,4BAA4B;QAC5B,uBAAuB;QACvB,8BAA8B;QAC9B,qBAAqB;QACrB,2BAA2B;QAC3B,uBAAuB;QACvB,gCAAgC;QAChC,gBAAgB;QAChB,kBAAkB;QAClB,uBAAuB;QACvB,mBAAmB;QACnB,gBAAgB;QAChB,wBAAwB;QACxB,6BAA6B;QAC7B,6BAA6B;QAC7B,cAAc;QACd,oCAAoC;QACpC,sBAAsB;QACtB,0BAA0B;QAC1B,gCAAgC;QAChC,iCAAiC;QACjC,uCAAuC;QACvC,yBAAyB;QACzB,4BAA4B;QAC5B,iBAAiB;QACjB,oBAAoB;QACpB,2BAA2B;QAC3B,wCAAwC;QACxC,4CAA4C;QAC5C,wCAAwC;QACxC,2CAA2C;QAC3C,oBAAoB;QACpB,qBAAqB;QACrB,oBAAoB;QACpB,mBAAmB;QACnB,+BAA+B;QAC/B,wBAAwB;MAC1B;IACF;EACF;;AFlCK,IAAMG,eAAe,UAC1BC,oCAAaC,4BAAM;MACjBC,oCAAa;IACXC,IAAI,GAAGF,2BAAKE,EAAE;IACdC,aAAaC,6BAAOC;IACpBC,UAAUhB;EACZ,CAAA;MACAW,oCAAa;IACXC,IAAI,GAAGF,2BAAKE,EAAE;IACdC,aAAaX,aAAaC;IAC1Ba,UAAUpB;EACZ,CAAA;MACAe,oCAAa;IACXC,IAAI,GAAGF,2BAAKE,EAAE;IACdC,aAAaC,6BAAOG;IACpBD,UAAU,UAAME,mCAAYC,mCAAaC,cAAcC,oBAAAA;EACzD,CAAA;MACAV,oCAAa;IACXC,IAAI,GAAGF,2BAAKE,EAAE;IACdC,aAAaC,6BAAOQ;IACpBN,UAAU,UACRE,mCAAYC,mCAAaI,UAAU;MACjCX,IAAIN,aAAAA,WAAWC;MACfiB,UAAU;QACRC,aAAa;UAAC;UAA4B;YAAEC,IAAIrB;UAAc;;QAC9DsB,MAAM;;QAENC,gBAAgB,OAAOC,WAAuB,MAAMC,4BAASC,QAAQ;UAACF,OAAOG;SAAO;MACtF;IACF,CAAA;EACJ,CAAA;MACArB,oCAAa;IACXC,IAAI,GAAGF,2BAAKE,EAAE;IACdC,aAAaoB,8BAAWC;IACxBlB,UAAU,UACRE,mCAAYiB,oCAAiBC,oBAAoB;MAC/CxB,IAAI;MACJyB,OAAO;QAAC;QAAwB;UAAEX,IAAIrB;QAAc;;MACpDsB,MAAM;MACNW,OAAO;MACPC,QAAQ,CAACC,SAASA,KAAKC,gBAAgBnC,aAAAA,cAAc,CAAC,KAACoC,sBAASF,KAAKC,IAAI;IAC3E,CAAA;EACJ,CAAA;MACA9B,oCAAa;IACXC,IAAI,GAAGF,2BAAKE,EAAE;IACdC,aAAa8B,kCAAaC;IAC1B5B,UAAU,UACRE,mCACE2B,sCAAkBC,gBAClBC,gCAAiB;MACfC,cAAc1C,aAAAA;MACd2C,YAAYC,mCAAaC;MACzBC,WAAW,CAACC,OAAOC,gBAAYC,oCAAaL,mCAAaM,QAAQ;QAAE,GAAGH;QAAOI,OAAOH,QAAQG;MAAM,CAAA;IACpG,CAAA,CAAA;EAEN,CAAA;MACA9C,oCAAa;IACXC,IAAI,GAAGF,2BAAKE,EAAE;IACdC,aAAaC,6BAAO4C;;IAEpBC,iBAAiB;MAACzD,aAAaC;;IAC/Ba,UAAUjB;EACZ,CAAA;MACAY,oCAAa;IACXC,IAAI,GAAGF,2BAAKE,EAAE;IACdC,aAAaC,6BAAO8C;IACpB5C,UAAUlB;EACZ,CAAA;MACAa,oCAAa;IACXC,IAAI,GAAGF,2BAAKE,EAAE;IACdC,aAAaC,6BAAO+C;IACpB7C,UAAUf;EACZ,CAAA;CACD;",
|
|
6
|
+
"names": ["import_app_framework", "import_types", "Compiler", "lazy", "IntentResolver", "ReactSurface", "ScriptSettings", "ArtifactDefinition", "ScriptEvents", "SetupCompiler", "defineEvent", "SCRIPT_PLUGIN", "ScriptType", "typename", "ScriptPlugin", "definePlugin", "meta", "defineModule", "id", "activatesOn", "Events", "SetupSettings", "activate", "SetupTranslations", "contributes", "Capabilities", "Translations", "translations", "SetupMetadata", "Metadata", "metadata", "placeholder", "ns", "icon", "loadReferences", "script", "RefArray", "loadAll", "source", "DeckEvents", "SetupComplementaryPanels", "DeckCapabilities", "ComplementaryPanel", "label", "fixed", "filter", "node", "data", "getSpace", "ClientEvents", "SetupSchema", "SpaceCapabilities", "ObjectForm", "defineObjectForm", "objectSchema", "formSchema", "ScriptAction", "CreateScriptSchema", "getIntent", "props", "options", "createIntent", "Create", "space", "SetupReactSurface", "activatesBefore", "SetupIntentResolver", "SetupArtifactDefinition"]
|
|
7
7
|
}
|
|
@@ -16,23 +16,23 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
return to;
|
|
17
17
|
};
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var
|
|
20
|
-
__export(
|
|
19
|
+
var intent_resolver_HQ3FGK2K_exports = {};
|
|
20
|
+
__export(intent_resolver_HQ3FGK2K_exports, {
|
|
21
21
|
default: () => intent_resolver_default
|
|
22
22
|
});
|
|
23
|
-
module.exports = __toCommonJS(
|
|
24
|
-
var
|
|
25
|
-
var
|
|
23
|
+
module.exports = __toCommonJS(intent_resolver_HQ3FGK2K_exports);
|
|
24
|
+
var import_chunk_XCQNFRZ6 = require("./chunk-XCQNFRZ6.cjs");
|
|
25
|
+
var import_chunk_VJ73IG7P = require("./chunk-VJ73IG7P.cjs");
|
|
26
26
|
var import_chunk_5UH3F7TA = require("./chunk-5UH3F7TA.cjs");
|
|
27
27
|
var import_core = require("@octokit/core");
|
|
28
28
|
var import_app_framework = require("@dxos/app-framework");
|
|
29
|
-
var
|
|
29
|
+
var import_types = require("@dxos/functions/types");
|
|
30
30
|
var import_live_object = require("@dxos/live-object");
|
|
31
31
|
var import_schema = require("@dxos/schema");
|
|
32
32
|
var intent_resolver_default = () => (0, import_app_framework.contributes)(import_app_framework.Capabilities.IntentResolver, (0, import_app_framework.createResolver)({
|
|
33
|
-
intent:
|
|
33
|
+
intent: import_chunk_VJ73IG7P.ScriptAction.Create,
|
|
34
34
|
resolve: async ({ name, gistUrl }) => {
|
|
35
|
-
let content =
|
|
35
|
+
let content = import_chunk_XCQNFRZ6.templates[0].source;
|
|
36
36
|
const gistId = gistUrl?.split("/").at(-1);
|
|
37
37
|
if (gistId) {
|
|
38
38
|
const octokit = new import_core.Octokit();
|
|
@@ -46,7 +46,7 @@ var intent_resolver_default = () => (0, import_app_framework.contributes)(import
|
|
|
46
46
|
}
|
|
47
47
|
return {
|
|
48
48
|
data: {
|
|
49
|
-
object: (0, import_live_object.create)(
|
|
49
|
+
object: (0, import_live_object.create)(import_types.ScriptType, {
|
|
50
50
|
name,
|
|
51
51
|
source: (0, import_live_object.makeRef)((0, import_live_object.create)(import_schema.TextType, {
|
|
52
52
|
content
|
|
@@ -56,4 +56,4 @@ var intent_resolver_default = () => (0, import_app_framework.contributes)(import
|
|
|
56
56
|
};
|
|
57
57
|
}
|
|
58
58
|
}));
|
|
59
|
-
//# sourceMappingURL=intent-resolver-
|
|
59
|
+
//# sourceMappingURL=intent-resolver-HQ3FGK2K.cjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/capabilities/intent-resolver.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { Octokit } from '@octokit/core';\n\nimport { contributes, Capabilities, createResolver } from '@dxos/app-framework';\nimport { ScriptType } from '@dxos/functions/types';\nimport { create, makeRef } from '@dxos/live-object';\nimport { TextType } from '@dxos/schema';\n\nimport { templates } from '../templates';\nimport { ScriptAction } from '../types';\n\nexport default () =>\n contributes(\n Capabilities.IntentResolver,\n createResolver({\n intent: ScriptAction.Create,\n resolve: async ({ name, gistUrl }) => {\n let content = templates[0].source;\n const gistId = gistUrl?.split('/').at(-1);\n if (gistId) {\n // TODO(wittjosiah): Capability which contributes Octokit?\n // NOTE: AccessToken not needed to read public gists.\n const octokit = new Octokit();\n const response = await octokit.request('GET /gists/{gist_id}', {\n gist_id: gistId,\n });\n const gistContent = Object.values(response.data.files ?? {})[0]?.content;\n if (gistContent) {\n content = gistContent;\n }\n }\n\n return {\n data: {\n object: create(ScriptType, {\n name,\n source: makeRef(create(TextType, { content })),\n }),\n },\n };\n },\n }),\n );\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,kBAAwB;AAExB,2BAA0D;AAC1D,mBAA2B;AAC3B,yBAAgC;AAChC,oBAAyB;AAKzB,IAAA,0BAAe,UACbA,kCACEC,kCAAaC,oBACbC,qCAAe;EACbC,QAAQC,mCAAaC;EACrBC,SAAS,OAAO,EAAEC,MAAMC,QAAO,MAAE;AAC/B,QAAIC,UAAUC,gCAAU,CAAA,EAAGC;AAC3B,UAAMC,SAASJ,SAASK,MAAM,GAAA,EAAKC,GAAG,EAAC;AACvC,QAAIF,QAAQ;AAGV,YAAMG,UAAU,IAAIC,oBAAAA;AACpB,YAAMC,WAAW,MAAMF,QAAQG,QAAQ,wBAAwB;QAC7DC,SAASP;MACX,CAAA;AACA,YAAMQ,cAAcC,OAAOC,OAAOL,SAASM,KAAKC,SAAS,CAAC,CAAA,EAAG,CAAA,GAAIf;AACjE,UAAIW,aAAa;AACfX,kBAAUW;MACZ;IACF;AAEA,WAAO;MACLG,MAAM;QACJE,YAAQC,2BAAOC,yBAAY;UACzBpB;UACAI,YAAQiB,gCAAQF,2BAAOG,wBAAU;YAAEpB;UAAQ,CAAA,CAAA;QAC7C,CAAA;MACF;IACF;EACF;AACF,CAAA,CAAA;",
|
|
6
|
+
"names": ["contributes", "Capabilities", "IntentResolver", "createResolver", "intent", "ScriptAction", "Create", "resolve", "name", "gistUrl", "content", "templates", "source", "gistId", "split", "at", "octokit", "Octokit", "response", "request", "gist_id", "gistContent", "Object", "values", "data", "files", "object", "create", "ScriptType", "makeRef", "TextType"]
|
|
7
|
+
}
|