|
1 | | -import type { Spell } from '@magickml/spells/runtime/utils' |
2 | | -// We should re-export these from behave-graph in our node/spell packages |
3 | | -import { |
4 | | - createNode, |
5 | | - makeGraphApi, |
6 | | - makeOrGenerateSockets, |
7 | | -} from '@magickml/behave-graph' |
8 | | -import { useRuntimeConfig } from 'nitro/runtime' |
| 1 | +import { defineSpellGraph } from '@magickml/spells/runtime/utils' |
9 | 2 |
|
10 | | -const exampleSpell: Spell = { |
11 | | - id: 'example-spell', |
12 | | - name: 'Example Spell', |
13 | | - description: 'A simple example spell', |
14 | | - graph: { |
15 | | - name: 'Example Graph', |
16 | | - nodes: {}, |
17 | | - variables: {}, |
18 | | - customEvents: {}, |
19 | | - metadata: {}, |
20 | | - }, |
21 | | -} |
22 | | - |
23 | | -// Add nodes to the graph |
24 | | -const graph = makeGraphApi({ |
25 | | - ...useRuntimeConfig().registry, |
26 | | - variables: exampleSpell.graph.variables, |
27 | | - customEvents: exampleSpell.graph.customEvents, |
28 | | -}) |
29 | | - |
30 | | -// e we have our defineNode definers but these behave-graph utils are still useful |
31 | | -// I feel like this createNode is better for programmatic use |
32 | | -// where our defineNode is better for declarative use/conntected to the registry/editor |
33 | | - |
34 | | -const startNode = createNode({ |
35 | | - id: 'start', |
36 | | - graph, |
37 | | - registry: useRuntimeConfig().registry, // replace this with useNodeSpec() |
38 | | - nodeTypeName: 'lifecycle/onStart', |
39 | | -}) |
40 | | - |
41 | | -const logNode = createNode({ |
42 | | - id: 'log', |
43 | | - graph, |
44 | | - registry: useRuntimeConfig().registry, |
45 | | - nodeTypeName: 'debug/log', |
46 | | - nodeConfiguration: { |
47 | | - text: 'Hello from Example Spell!', |
48 | | - }, |
| 3 | +export default defineSpellGraph({ |
| 4 | + name: 'Test Spell', |
| 5 | + nodes: [], |
| 6 | + variables: [], |
49 | 7 | }) |
50 | | - |
51 | | -exampleSpell.graph.nodes[startNode.id] = startNode |
52 | | -exampleSpell.graph.nodes[logNode.id] = logNode |
53 | | - |
54 | | -// implement sometihng like this to grab node config |
55 | | -// const nodeConfig = useNodeSpec() |
56 | | - |
57 | | -// we can store a node config in the nitro object |
58 | | -// or generate on the fly |
59 | | - |
60 | | -export default exampleSpell |
0 commit comments