@kiberon-labs/behave-graph-flow 2.0.0 → 3.0.0
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/.storybook/manager.ts +6 -0
- package/.storybook/preview.ts +49 -1
- package/.storybook/styles.css +9 -3
- package/.turbo/turbo-build.log +1 -1
- package/CHANGELOG.md +368 -0
- package/dist/AnyControlImpl-Ds-CShIB.js +20 -0
- package/dist/AnyControlImpl-Ds-CShIB.js.map +1 -0
- package/dist/DocumentationBrowserPanelImpl-deZNzFX8.js +166 -0
- package/dist/DocumentationBrowserPanelImpl-deZNzFX8.js.map +1 -0
- package/dist/index.css +36 -33
- package/dist/index.css.map +1 -1
- package/dist/index.d.ts +1865 -550
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +14357 -11221
- package/dist/index.js.map +1 -1
- package/dist/noteImpl-KkrrWgJd.js +242 -0
- package/dist/noteImpl-KkrrWgJd.js.map +1 -0
- package/dist/styles.module-CvmpDkZj.css +3 -0
- package/dist/styles.module-CvmpDkZj.css.map +1 -0
- package/dist/styles.module-DZxg8aW9.js +271 -0
- package/dist/styles.module-DZxg8aW9.js.map +1 -0
- package/dist/useChangeNodeData-ChQGK7AI.js +23 -0
- package/dist/useChangeNodeData-ChQGK7AI.js.map +1 -0
- package/docs/protocol.md +43 -20
- package/package.json +5 -9
- package/src/components/FloatingToolbar/index.module.css +5 -13
- package/src/components/FloatingToolbar/index.tsx +9 -9
- package/src/components/Flow.tsx +34 -23
- package/src/components/contextMenus/DynamicContextMenu.tsx +85 -0
- package/src/components/contextMenus/NodePicker.module.css +13 -13
- package/src/components/contextMenus/edge.tsx +9 -95
- package/src/components/contextMenus/node.tsx +9 -149
- package/src/components/contextMenus/selection.tsx +5 -71
- package/src/components/controls/any/AnyControlImpl.tsx +14 -0
- package/src/components/controls/any/index.tsx +13 -2
- package/src/components/edges/index.tsx +75 -69
- package/src/components/layoutController/index.module.css +3 -0
- package/src/components/layoutController/index.tsx +24 -1
- package/src/components/layoutController/utils.ts +46 -3
- package/src/components/menubar/defaults.tsx +55 -19
- package/src/components/menubar/menuItem.module.css +18 -3
- package/src/components/menubar/menuItem.tsx +34 -1
- package/src/components/nodes/behave/NodeContainer.module.css +26 -25
- package/src/components/nodes/group/index.tsx +3 -3
- package/src/components/nodes/wrapper/styles.module.css +6 -32
- package/src/components/panels/alignment/index.module.css +0 -10
- package/src/components/panels/alignment/index.tsx +4 -4
- package/src/components/panels/base/styles.module.css +2 -2
- package/src/components/panels/common/PanelHeader.module.css +24 -0
- package/src/components/panels/common/PanelHeader.tsx +22 -0
- package/src/components/panels/common/SectionTitle.module.css +13 -0
- package/src/components/panels/common/SectionTitle.tsx +10 -0
- package/src/components/panels/events/EditEventPanel.tsx +14 -5
- package/src/components/panels/events/ManageEventsPanel.tsx +11 -8
- package/src/components/panels/events/styles.module.css +6 -64
- package/src/components/panels/graphProperties/index.tsx +125 -0
- package/src/components/panels/history/index.tsx +2 -2
- package/src/components/panels/history/styles.module.css +0 -9
- package/src/components/panels/keymaps/index.module.css +3 -13
- package/src/components/panels/keymaps/index.tsx +1 -2
- package/src/components/panels/layers/index.tsx +20 -15
- package/src/components/panels/layers/styles.module.css +9 -12
- package/src/components/panels/legend/index.tsx +1 -1
- package/src/components/panels/logs/index.module.css +25 -19
- package/src/components/panels/logs/index.tsx +7 -7
- package/src/components/panels/nodeInputs/InputsGroup.tsx +1 -0
- package/src/components/panels/nodeInputs/NodeSettings.tsx +2 -2
- package/src/components/panels/nodeInputs/NodeTitleEditor.tsx +1 -1
- package/src/components/panels/nodeInputs/OutputsGroup.tsx +2 -12
- package/src/components/panels/nodeInputs/index.module.css +99 -75
- package/src/components/panels/nodeInputs/index.tsx +21 -11
- package/src/components/panels/nodeInputs/useNodeHandlers.ts +2 -2
- package/src/components/panels/nodeInputs/useNodeInputsData.ts +23 -43
- package/src/components/panels/nodePicker/index.tsx +8 -8
- package/src/components/panels/panel/index.module.css +7 -7
- package/src/components/panels/search/index.module.css +0 -50
- package/src/components/panels/search/index.tsx +2 -2
- package/src/components/panels/systemSettings/ConversionsSettings.tsx +203 -0
- package/src/components/panels/systemSettings/index.tsx +221 -176
- package/src/components/panels/systemSettings/styles.module.css +135 -8
- package/src/components/panels/traces/GridLines.tsx +1 -1
- package/src/components/panels/traces/TimeGrid.tsx +3 -3
- package/src/components/panels/traces/TraceLane.tsx +1 -1
- package/src/components/panels/traces/index.module.css +1 -8
- package/src/components/panels/traces/index.tsx +8 -4
- package/src/components/panels/traces/useDerivedSpans.ts +241 -146
- package/src/components/panels/traces/utils.ts +8 -0
- package/src/components/panels/variables/CreateVariableScreen.tsx +3 -3
- package/src/components/panels/variables/ManageVariablesScreen.tsx +12 -9
- package/src/components/panels/variables/index.tsx +2 -2
- package/src/components/panels/variables/styles.module.css +4 -91
- package/src/components/primitives/icon.module.css +4 -4
- package/src/components/sockets/input/index.tsx +9 -2
- package/src/components/sockets/input/styles.module.css +2 -3
- package/src/components/sockets/output/index.tsx +10 -3
- package/src/components/sockets/output/styles.module.css +1 -6
- package/src/css/notes.css +135 -0
- package/src/css/prosemirror.css +3 -3
- package/src/css/rc-dock.css +143 -43
- package/src/css/rc-menu.css +56 -55
- package/src/css/themes/kiberon.css +127 -0
- package/src/css/vars.css +197 -13
- package/src/css/vscode-elements.css +124 -0
- package/src/generators/CallSubgraphGenerator.tsx +136 -0
- package/src/generators/CustomEventOnTriggeredGenerator.tsx +2 -2
- package/src/generators/GraphBoundaryGenerator.module.css +32 -0
- package/src/generators/GraphBoundaryGenerator.tsx +193 -0
- package/src/generators/SequenceGenerator.tsx +2 -2
- package/src/generators/SwitchOnIntegerGenerator.tsx +2 -2
- package/src/generators/SwitchOnStringGenerator.tsx +2 -2
- package/src/generators/callSubgraphSync.ts +126 -0
- package/src/generators/registerDefaultGenerators.ts +21 -0
- package/src/generators/registerDefaults.ts +26 -0
- package/src/hooks/useBehaveGraphFlow.ts +2 -2
- package/src/hooks/useFlowHandlers.ts +47 -9
- package/src/hooks/useWasdPan.ts +26 -4
- package/src/index.css +4 -16
- package/src/index.ts +17 -0
- package/src/manifest/contributionRegistry.ts +93 -0
- package/src/manifest/index.ts +4 -0
- package/src/manifest/loadManifest.ts +82 -0
- package/src/manifest/manifestPlugin.ts +29 -0
- package/src/manifest/passthroughValueType.ts +40 -0
- package/src/plugin/alignment/index.ts +22 -12
- package/src/plugin/autosave/controller.ts +366 -0
- package/src/plugin/autosave/index.tsx +114 -0
- package/src/plugin/autosave/panel/BackupPanel.tsx +141 -0
- package/src/plugin/autosave/panel/index.tsx +1 -0
- package/src/plugin/autosave/panel/styles.module.css +56 -0
- package/src/plugin/autosave/settings.ts +65 -0
- package/src/plugin/autosave/storage.ts +147 -0
- package/src/plugin/docs/index.tsx +2 -4
- package/src/plugin/docs/panel/DocumentationBrowserPanelImpl.tsx +200 -0
- package/src/plugin/docs/panel/index.tsx +15 -194
- package/src/plugin/docs/panel/styles.module.css +8 -8
- package/src/plugin/graphrunner/actions.ts +258 -185
- package/src/plugin/graphrunner/buttons.tsx +34 -26
- package/src/plugin/graphrunner/client.ts +4 -1
- package/src/plugin/graphrunner/index.tsx +29 -100
- package/src/plugin/graphrunner/panel.tsx +2 -2
- package/src/plugin/graphrunner/runController.ts +283 -0
- package/src/plugin/graphrunner/runner.ts +21 -192
- package/src/plugin/graphrunner/store.ts +14 -24
- package/src/plugin/graphrunner/styles.module.css +17 -57
- package/src/plugin/graphrunner/transport.ts +26 -0
- package/src/plugin/graphrunner/types.ts +21 -0
- package/src/plugin/graphrunner-local/execution-utils.ts +260 -80
- package/src/plugin/graphrunner-local/index.tsx +8 -2
- package/src/plugin/graphrunner-local/panel.tsx +131 -175
- package/src/plugin/graphrunner-local/styles.module.css +57 -76
- package/src/plugin/graphrunner-local/transport.ts +151 -184
- package/src/plugin/graphrunner-webworker/graph-executor.worker.ts +2 -0
- package/src/plugin/graphrunner-webworker/index.tsx +4 -10
- package/src/plugin/graphrunner-webworker/store.ts +9 -0
- package/src/plugin/kitchen-sink/index.ts +38 -0
- package/src/{layout/dagre.tsx → plugin/layout/dagre.ts} +17 -5
- package/src/{layout → plugin/layout}/elk.ts +22 -6
- package/src/plugin/layout/index.ts +80 -0
- package/src/plugin/notes/FormatToolbar.tsx +200 -0
- package/src/plugin/notes/index.tsx +191 -0
- package/src/plugin/notes/nodeActions.ts +100 -0
- package/src/plugin/notes/note.tsx +20 -0
- package/src/plugin/notes/noteImpl.tsx +89 -0
- package/src/plugin/realtime/realtimeRunner.ts +58 -4
- package/src/specifics/CustomEventOnTriggeredSpecific.tsx +2 -2
- package/src/specifics/CustomEventTriggerSpecific.tsx +2 -2
- package/src/specifics/VariableGetSpecific.tsx +2 -2
- package/src/specifics/VariableSetSpecific.tsx +2 -2
- package/src/store/actions.tsx +5 -5
- package/src/store/commands.ts +278 -0
- package/src/store/contextMenu.ts +192 -0
- package/src/store/conversions.ts +47 -0
- package/src/store/flow.tsx +23 -38
- package/src/store/graphMeta.ts +39 -0
- package/src/store/hotKeys.tsx +301 -260
- package/src/store/layers.ts +3 -3
- package/src/store/registry.ts +12 -4
- package/src/store/selection.ts +3 -3
- package/src/store/settings.ts +82 -82
- package/src/store/settingsSchema.ts +210 -0
- package/src/store/tabs.ts +5 -1
- package/src/store/traces.ts +3 -3
- package/src/system/graph.ts +11 -14
- package/src/system/graphSession.ts +172 -0
- package/src/system/index.ts +3 -0
- package/src/system/notifications.ts +13 -0
- package/src/system/persistence.ts +82 -0
- package/src/system/plugin.ts +28 -0
- package/src/system/provider.tsx +64 -0
- package/src/system/system.ts +518 -88
- package/src/system/tabLoader.tsx +70 -32
- package/src/system/undoRedo.ts +1 -1
- package/src/transformers/Uigraph.ts +5 -4
- package/src/transformers/contract.ts +87 -0
- package/src/transformers/flowToBehave.ts +13 -5
- package/src/types/nodes.ts +8 -3
- package/src/types.ts +2 -0
- package/src/util/autoConvert.ts +200 -0
- package/src/util/isValidConnection.ts +23 -2
- package/stories/defaults/defaultStoryProvider.tsx +17 -14
- package/stories/defaults/systemGenerator.ts +6 -1
- package/stories/{components/nodes/comment.stories.tsx → plugins/notes.stories.tsx} +24 -30
- package/tests/autoConvert.test.ts +329 -0
- package/tests/autosavePlugin.test.ts +204 -0
- package/tests/callSubgraphSync.test.ts +148 -0
- package/tests/commandRegistry.test.ts +137 -0
- package/tests/contract.test.ts +51 -0
- package/tests/contractSerialize.test.ts +62 -0
- package/tests/deriveSpans.test.ts +71 -0
- package/tests/flowToBehave.test.ts +2 -1
- package/tests/hotkeys.test.ts +79 -0
- package/tests/keepAliveLifecycle.test.ts +167 -0
- package/tests/loadManifest.test.ts +113 -0
- package/tests/noteMarkdown.test.ts +65 -0
- package/tests/notesPlugin.test.ts +162 -0
- package/tests/persistence.test.ts +51 -0
- package/tests/saveLoad.test.ts +7 -6
- package/tests/settings.test.ts +178 -0
- package/tests/traceStore.test.ts +46 -0
- package/tests/visual/README.md +2 -2
- package/tests/visual/__screenshots__/panels.visual.test.tsx/panel-conversation-chromium-win32.png +0 -0
- package/tests/visual/__screenshots__/panels.visual.test.tsx/panel-events-chromium-win32.png +0 -0
- package/tests/visual/__screenshots__/panels.visual.test.tsx/panel-history-chromium-win32.png +0 -0
- package/tests/visual/__screenshots__/panels.visual.test.tsx/panel-keymaps-chromium-win32.png +0 -0
- package/tests/visual/__screenshots__/panels.visual.test.tsx/panel-layers-chromium-win32.png +0 -0
- package/tests/visual/__screenshots__/panels.visual.test.tsx/panel-legend-chromium-win32.png +0 -0
- package/tests/visual/__screenshots__/panels.visual.test.tsx/panel-localGraphRunner-chromium-win32.png +0 -0
- package/tests/visual/__screenshots__/panels.visual.test.tsx/panel-logs-chromium-win32.png +0 -0
- package/tests/visual/__screenshots__/panels.visual.test.tsx/panel-nodeInputs-chromium-win32.png +0 -0
- package/tests/visual/__screenshots__/panels.visual.test.tsx/panel-nodePicker-chromium-win32.png +0 -0
- package/tests/visual/__screenshots__/panels.visual.test.tsx/panel-panel-chromium-win32.png +0 -0
- package/tests/visual/__screenshots__/panels.visual.test.tsx/panel-search-chromium-win32.png +0 -0
- package/tests/visual/__screenshots__/panels.visual.test.tsx/panel-systemSettings-chromium-win32.png +0 -0
- package/tests/visual/__screenshots__/panels.visual.test.tsx/panel-variables-chromium-win32.png +0 -0
- package/tests/visual/panels.visual.test.tsx +3 -3
- package/tests/wasdPan.test.ts +71 -0
- package/vitest.config.ts +1 -1
- package/vitest.visual.config.ts +7 -0
- package/.storybook/vscode.css +0 -814
- package/src/components/nodes/comment/FormatToolbar.tsx +0 -118
- package/src/components/nodes/comment/comment.tsx +0 -103
- package/src/components/nodes/comment/styles.module.css +0 -150
- package/src/components/panels/conversation/index.module.css +0 -151
- package/src/components/panels/conversation/index.tsx +0 -162
- package/src/components/panels/events/CustomEventsEditor.tsx +0 -384
- package/src/css/vscode.css +0 -13
- package/src/hooks/useDetachNodes.ts +0 -39
- package/src/plugin/graphrunner-webworker/types.ts +0 -17
- package/src/specifics/registerDefaultSpecifics.ts +0 -5
- package/src/store/chat.ts +0 -73
- package/src/store/graphRunnerClient.ts +0 -110
|
@@ -1,384 +0,0 @@
|
|
|
1
|
-
import React, { useEffect, useMemo, useState } from 'react';
|
|
2
|
-
import { useStore } from 'zustand';
|
|
3
|
-
import {
|
|
4
|
-
VscodeButton,
|
|
5
|
-
VscodeCollapsible,
|
|
6
|
-
VscodeDivider,
|
|
7
|
-
VscodeOption,
|
|
8
|
-
VscodeSingleSelect,
|
|
9
|
-
VscodeTextfield
|
|
10
|
-
} from '@vscode-elements/react-elements';
|
|
11
|
-
import { useSystem } from '@/system';
|
|
12
|
-
import type { GraphJSON } from '@kiberon-labs/behave-graph';
|
|
13
|
-
import { Download, Plus, Trash } from 'iconoir-react';
|
|
14
|
-
|
|
15
|
-
type CustomEventJSON = NonNullable<GraphJSON['customEvents']>[number];
|
|
16
|
-
|
|
17
|
-
type CustomEventParameterJSON = NonNullable<
|
|
18
|
-
CustomEventJSON['parameters']
|
|
19
|
-
>[number];
|
|
20
|
-
|
|
21
|
-
const nextNumericId = (events: Array<{ id: string }>) => {
|
|
22
|
-
const used = new Set(events.map((e) => String(e.id)));
|
|
23
|
-
let i = 0;
|
|
24
|
-
while (used.has(String(i))) i += 1;
|
|
25
|
-
return String(i);
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
export const CustomEventsEditor: React.FC = () => {
|
|
29
|
-
const system = useSystem();
|
|
30
|
-
|
|
31
|
-
const eventsStoreApi = system.eventsStore;
|
|
32
|
-
const persistedEvents = useStore(system.eventsStore, (s) =>
|
|
33
|
-
Object.values(s.customEvents)
|
|
34
|
-
);
|
|
35
|
-
|
|
36
|
-
const controls = useStore(system.controlStore, (s) => s.controls);
|
|
37
|
-
const defaultControl = useStore(system.controlStore, (s) => s.defaultControl);
|
|
38
|
-
|
|
39
|
-
const valueTypeOptions = useMemo(
|
|
40
|
-
() => Object.keys(controls).sort((a, b) => a.localeCompare(b)),
|
|
41
|
-
[controls]
|
|
42
|
-
);
|
|
43
|
-
|
|
44
|
-
const [newEventName, setNewEventName] = useState('');
|
|
45
|
-
|
|
46
|
-
const [dirtyEventUiIds, setDirtyEventUiIds] = useState<string[]>([]);
|
|
47
|
-
const [draftEvents, setDraftEvents] = useState<CustomEventJSON[]>([]);
|
|
48
|
-
|
|
49
|
-
const isClean = dirtyEventUiIds.length === 0;
|
|
50
|
-
|
|
51
|
-
const markDirty = (uiId: string) => {
|
|
52
|
-
setDirtyEventUiIds((prev) =>
|
|
53
|
-
prev.includes(uiId) ? prev : [...prev, uiId]
|
|
54
|
-
);
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
const markClean = (uiId: string) => {
|
|
58
|
-
setDirtyEventUiIds((prev) => prev.filter((id) => id !== uiId));
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
useEffect(() => {
|
|
62
|
-
if (!isClean) return;
|
|
63
|
-
setDraftEvents(persistedEvents);
|
|
64
|
-
}, [isClean, persistedEvents]);
|
|
65
|
-
|
|
66
|
-
const commitEvent = (uiId: string) => {
|
|
67
|
-
const draft = draftEvents.find((e) => String(e.id) === uiId);
|
|
68
|
-
if (!draft) return;
|
|
69
|
-
|
|
70
|
-
const persisted = persistedEvents;
|
|
71
|
-
const existing = persisted.find((e) => String(e.id) === uiId);
|
|
72
|
-
const oldId = existing ? String(existing.id ?? '') : undefined;
|
|
73
|
-
|
|
74
|
-
const usedIds = new Set(
|
|
75
|
-
persisted.filter((e) => String(e.id) !== uiId).map((e) => String(e.id))
|
|
76
|
-
);
|
|
77
|
-
|
|
78
|
-
const desiredId = String(draft.id);
|
|
79
|
-
let finalId = desiredId;
|
|
80
|
-
if (usedIds.has(desiredId)) {
|
|
81
|
-
finalId = oldId ?? nextNumericId(persisted);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
const normalized = { ...draft, id: finalId };
|
|
85
|
-
|
|
86
|
-
const nextPersisted = existing
|
|
87
|
-
? persisted.map((e) => (String(e.id) === uiId ? normalized : e))
|
|
88
|
-
: [...persisted, normalized];
|
|
89
|
-
|
|
90
|
-
// Convert array to Record for store
|
|
91
|
-
const nextPersistedRecord: Record<string, CustomEventJSON> = {};
|
|
92
|
-
nextPersisted.forEach((evt) => {
|
|
93
|
-
nextPersistedRecord[String(evt.id)] = evt;
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
eventsStoreApi.getState().setCustomEvents(nextPersistedRecord);
|
|
97
|
-
|
|
98
|
-
const stored = eventsStoreApi.getState().getCustomEvents();
|
|
99
|
-
const storedEvent = stored.find((e) => String(e.id) === uiId);
|
|
100
|
-
if (storedEvent) {
|
|
101
|
-
setDraftEvents((prev) =>
|
|
102
|
-
prev.map((e) => (String(e.id) === uiId ? storedEvent : e))
|
|
103
|
-
);
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
markClean(uiId);
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
const updateDraftEvent = (id: string, patch: Partial<CustomEventJSON>) => {
|
|
110
|
-
setDraftEvents((prev) =>
|
|
111
|
-
prev.map((e) => {
|
|
112
|
-
if (String(e.id) !== String(id)) return e;
|
|
113
|
-
return { ...e, ...patch };
|
|
114
|
-
})
|
|
115
|
-
);
|
|
116
|
-
markDirty(id);
|
|
117
|
-
};
|
|
118
|
-
|
|
119
|
-
const removeDraftEvent = (uiId: string) => {
|
|
120
|
-
const persisted = persistedEvents;
|
|
121
|
-
const persistedMatch = persisted.find((e) => String(e.id) === uiId);
|
|
122
|
-
|
|
123
|
-
setDraftEvents((prev) => prev.filter((e) => String(e.id) !== String(uiId)));
|
|
124
|
-
|
|
125
|
-
// If it exists in the store, delete it immediately.
|
|
126
|
-
if (persistedMatch) {
|
|
127
|
-
const idToRemove = String(persistedMatch.id);
|
|
128
|
-
if (idToRemove) eventsStoreApi.getState().removeCustomEvent(idToRemove);
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
markClean(uiId);
|
|
132
|
-
};
|
|
133
|
-
|
|
134
|
-
const addDraftEvent = () => {
|
|
135
|
-
const nextId = nextNumericId(draftEvents);
|
|
136
|
-
const created: CustomEventJSON = {
|
|
137
|
-
id: nextId,
|
|
138
|
-
name: newEventName.trim() || 'NewCustomEvent',
|
|
139
|
-
parameters: []
|
|
140
|
-
};
|
|
141
|
-
setDraftEvents((prev) => [...prev, created]);
|
|
142
|
-
setNewEventName('');
|
|
143
|
-
markDirty(String(created.id));
|
|
144
|
-
};
|
|
145
|
-
|
|
146
|
-
const addDraftParameter = (uiId: string) => {
|
|
147
|
-
const vt = valueTypeOptions[0] ?? 'string';
|
|
148
|
-
const defaultValue =
|
|
149
|
-
vt === 'boolean'
|
|
150
|
-
? false
|
|
151
|
-
: vt === 'number' || vt === 'float' || vt === 'integer'
|
|
152
|
-
? 0
|
|
153
|
-
: '';
|
|
154
|
-
|
|
155
|
-
setDraftEvents((prev) =>
|
|
156
|
-
prev.map((e) => {
|
|
157
|
-
if (String(e.id) !== String(uiId)) return e;
|
|
158
|
-
const parameters = [
|
|
159
|
-
...((e.parameters ?? []) as CustomEventParameterJSON[]),
|
|
160
|
-
{
|
|
161
|
-
name: 'param',
|
|
162
|
-
valueTypeName: vt,
|
|
163
|
-
defaultValue
|
|
164
|
-
}
|
|
165
|
-
];
|
|
166
|
-
return { ...e, parameters };
|
|
167
|
-
})
|
|
168
|
-
);
|
|
169
|
-
markDirty(uiId);
|
|
170
|
-
};
|
|
171
|
-
|
|
172
|
-
const updateDraftParameter = (
|
|
173
|
-
uiId: string,
|
|
174
|
-
index: number,
|
|
175
|
-
patch: Partial<CustomEventParameterJSON>
|
|
176
|
-
) => {
|
|
177
|
-
setDraftEvents((prev) =>
|
|
178
|
-
prev.map((e) => {
|
|
179
|
-
if (String(e.id) !== String(uiId)) return e;
|
|
180
|
-
const parameters = [
|
|
181
|
-
...((e.parameters ?? []) as CustomEventParameterJSON[])
|
|
182
|
-
];
|
|
183
|
-
if (!parameters[index]) return e;
|
|
184
|
-
parameters[index] = { ...parameters[index], ...patch };
|
|
185
|
-
return { ...e, parameters };
|
|
186
|
-
})
|
|
187
|
-
);
|
|
188
|
-
markDirty(uiId);
|
|
189
|
-
};
|
|
190
|
-
|
|
191
|
-
const removeDraftParameter = (uiId: string, index: number) => {
|
|
192
|
-
setDraftEvents((prev) =>
|
|
193
|
-
prev.map((e) => {
|
|
194
|
-
if (String(e.id) !== String(uiId)) return e;
|
|
195
|
-
const parameters = [
|
|
196
|
-
...((e.parameters ?? []) as CustomEventParameterJSON[])
|
|
197
|
-
];
|
|
198
|
-
parameters.splice(index, 1);
|
|
199
|
-
return { ...e, parameters };
|
|
200
|
-
})
|
|
201
|
-
);
|
|
202
|
-
markDirty(uiId);
|
|
203
|
-
};
|
|
204
|
-
|
|
205
|
-
return (
|
|
206
|
-
<div className="h-full w-full flex flex-col p-2 gap-2">
|
|
207
|
-
<div className="flex items-center gap-2 pb-2 border-b border-gray-700">
|
|
208
|
-
<h2 className="text-lg font-semibold">Custom Events</h2>
|
|
209
|
-
</div>
|
|
210
|
-
|
|
211
|
-
<div className="flex items-center gap-2">
|
|
212
|
-
<VscodeTextfield
|
|
213
|
-
placeholder="New event name"
|
|
214
|
-
value={newEventName}
|
|
215
|
-
onInput={(e: Event) => {
|
|
216
|
-
const target = e.target as HTMLInputElement;
|
|
217
|
-
setNewEventName(target.value);
|
|
218
|
-
}}
|
|
219
|
-
/>
|
|
220
|
-
<VscodeButton onClick={addDraftEvent}>Add</VscodeButton>
|
|
221
|
-
</div>
|
|
222
|
-
|
|
223
|
-
<VscodeDivider />
|
|
224
|
-
|
|
225
|
-
{draftEvents.length === 0 ? (
|
|
226
|
-
<div className="text-gray-500 text-center py-4">
|
|
227
|
-
No custom events yet.
|
|
228
|
-
</div>
|
|
229
|
-
) : (
|
|
230
|
-
<div className="flex flex-col gap-2">
|
|
231
|
-
{draftEvents.map((evt) => {
|
|
232
|
-
const parameters = (evt.parameters ??
|
|
233
|
-
[]) as CustomEventParameterJSON[];
|
|
234
|
-
const eventId = String(evt.id);
|
|
235
|
-
const uiKey = String(evt.id);
|
|
236
|
-
const isEventDirty = dirtyEventUiIds.includes(uiKey);
|
|
237
|
-
|
|
238
|
-
return (
|
|
239
|
-
<VscodeCollapsible key={uiKey} title={`${evt.name} (${eventId})`}>
|
|
240
|
-
<div className="flex flex-col gap-2 p-2">
|
|
241
|
-
<div className="grid grid-cols-12 gap-2 items-end">
|
|
242
|
-
<div className="col-span-4 flex flex-col gap-1">
|
|
243
|
-
<div className="text-xs text-gray-300">id</div>
|
|
244
|
-
<VscodeTextfield
|
|
245
|
-
value={String(evt.id)}
|
|
246
|
-
onInput={(e: Event) => {
|
|
247
|
-
const target = e.target as HTMLInputElement;
|
|
248
|
-
updateDraftEvent(uiKey, {
|
|
249
|
-
id: String(target.value)
|
|
250
|
-
});
|
|
251
|
-
}}
|
|
252
|
-
/>
|
|
253
|
-
</div>
|
|
254
|
-
|
|
255
|
-
<div className="col-span-6 flex flex-col gap-1">
|
|
256
|
-
<div className="text-xs text-gray-300">name</div>
|
|
257
|
-
<VscodeTextfield
|
|
258
|
-
value={String(evt.name)}
|
|
259
|
-
onInput={(e: Event) => {
|
|
260
|
-
const target = e.target as HTMLInputElement;
|
|
261
|
-
updateDraftEvent(uiKey, {
|
|
262
|
-
name: String(target.value)
|
|
263
|
-
});
|
|
264
|
-
}}
|
|
265
|
-
/>
|
|
266
|
-
</div>
|
|
267
|
-
|
|
268
|
-
<div className="col-span-2 flex justify-end gap-1">
|
|
269
|
-
<VscodeButton
|
|
270
|
-
iconOnly
|
|
271
|
-
title="Save"
|
|
272
|
-
disabled={!isEventDirty}
|
|
273
|
-
onClick={() => commitEvent(uiKey)}
|
|
274
|
-
>
|
|
275
|
-
<Download />
|
|
276
|
-
</VscodeButton>
|
|
277
|
-
<VscodeButton
|
|
278
|
-
secondary
|
|
279
|
-
iconOnly
|
|
280
|
-
title="Delete event"
|
|
281
|
-
onClick={() => removeDraftEvent(uiKey)}
|
|
282
|
-
>
|
|
283
|
-
<Trash />
|
|
284
|
-
</VscodeButton>
|
|
285
|
-
</div>
|
|
286
|
-
</div>
|
|
287
|
-
|
|
288
|
-
<VscodeDivider />
|
|
289
|
-
|
|
290
|
-
<div className="flex items-center justify-between">
|
|
291
|
-
<div className="text-sm font-semibold">Parameters</div>
|
|
292
|
-
<VscodeButton
|
|
293
|
-
secondary
|
|
294
|
-
iconOnly
|
|
295
|
-
title="Add parameter"
|
|
296
|
-
onClick={() => addDraftParameter(uiKey)}
|
|
297
|
-
>
|
|
298
|
-
<Plus />
|
|
299
|
-
</VscodeButton>
|
|
300
|
-
</div>
|
|
301
|
-
|
|
302
|
-
{parameters.length === 0 ? (
|
|
303
|
-
<div className="text-gray-500 text-sm">No parameters.</div>
|
|
304
|
-
) : (
|
|
305
|
-
<div className="flex flex-col gap-2">
|
|
306
|
-
<div className="grid grid-cols-12 gap-2 text-xs text-gray-300">
|
|
307
|
-
<div className="col-span-4">name</div>
|
|
308
|
-
<div className="col-span-3">type</div>
|
|
309
|
-
<div className="col-span-4">default</div>
|
|
310
|
-
<div className="col-span-1" />
|
|
311
|
-
</div>
|
|
312
|
-
|
|
313
|
-
{parameters.map((param, index) => {
|
|
314
|
-
const Control =
|
|
315
|
-
controls[String(param.valueTypeName)] ??
|
|
316
|
-
defaultControl;
|
|
317
|
-
|
|
318
|
-
return (
|
|
319
|
-
<div
|
|
320
|
-
key={`${eventId}:${index}`}
|
|
321
|
-
className="grid grid-cols-12 gap-2 items-center"
|
|
322
|
-
>
|
|
323
|
-
<VscodeTextfield
|
|
324
|
-
className="col-span-4"
|
|
325
|
-
value={String(param.name)}
|
|
326
|
-
onInput={(e: Event) => {
|
|
327
|
-
const target = e.target as HTMLInputElement;
|
|
328
|
-
updateDraftParameter(uiKey, index, {
|
|
329
|
-
name: String(target.value)
|
|
330
|
-
});
|
|
331
|
-
}}
|
|
332
|
-
/>
|
|
333
|
-
|
|
334
|
-
<VscodeSingleSelect
|
|
335
|
-
className="col-span-3"
|
|
336
|
-
value={String(param.valueTypeName)}
|
|
337
|
-
onChange={(e: Event) => {
|
|
338
|
-
const target = e.target as HTMLSelectElement;
|
|
339
|
-
updateDraftParameter(uiKey, index, {
|
|
340
|
-
valueTypeName: String(target.value)
|
|
341
|
-
});
|
|
342
|
-
}}
|
|
343
|
-
>
|
|
344
|
-
{valueTypeOptions.map((vt) => (
|
|
345
|
-
<VscodeOption key={vt} value={vt}>
|
|
346
|
-
{vt}
|
|
347
|
-
</VscodeOption>
|
|
348
|
-
))}
|
|
349
|
-
</VscodeSingleSelect>
|
|
350
|
-
|
|
351
|
-
<div className="col-span-4 min-w-0">
|
|
352
|
-
<Control
|
|
353
|
-
value={param.defaultValue}
|
|
354
|
-
onChange={(v) =>
|
|
355
|
-
updateDraftParameter(uiKey, index, {
|
|
356
|
-
defaultValue: v
|
|
357
|
-
})
|
|
358
|
-
}
|
|
359
|
-
valueType={String(param.valueTypeName ?? '')}
|
|
360
|
-
/>
|
|
361
|
-
</div>
|
|
362
|
-
|
|
363
|
-
<VscodeButton
|
|
364
|
-
secondary
|
|
365
|
-
iconOnly
|
|
366
|
-
title="Delete parameter"
|
|
367
|
-
onClick={() => removeDraftParameter(uiKey, index)}
|
|
368
|
-
>
|
|
369
|
-
<Trash />
|
|
370
|
-
</VscodeButton>
|
|
371
|
-
</div>
|
|
372
|
-
);
|
|
373
|
-
})}
|
|
374
|
-
</div>
|
|
375
|
-
)}
|
|
376
|
-
</div>
|
|
377
|
-
</VscodeCollapsible>
|
|
378
|
-
);
|
|
379
|
-
})}
|
|
380
|
-
</div>
|
|
381
|
-
)}
|
|
382
|
-
</div>
|
|
383
|
-
);
|
|
384
|
-
};
|
package/src/css/vscode.css
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
:root {
|
|
2
|
-
--vscode-button-border: #313131;
|
|
3
|
-
--vscode-foreground: #cccccc;
|
|
4
|
-
--vscode-editorWidget-background: #202020;
|
|
5
|
-
--vscode-editorWidget-foreground: #cccccc;
|
|
6
|
-
--vscode-editorWidget-border: #454545;
|
|
7
|
-
--vscode-editor-background: #1f1f1f;
|
|
8
|
-
--vscode-editor-foreground: #cccccc;
|
|
9
|
-
--vscode-editorGroupHeader-tabsBackground: #181818;
|
|
10
|
-
--vscode-sideBarSectionHeader-background: #181818;
|
|
11
|
-
--vscode-sideBarSectionHeader-foreground: #cccccc;
|
|
12
|
-
--vscode-sideBarSectionHeader-border: #2b2b2b;
|
|
13
|
-
}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { useSystem } from '@/system';
|
|
2
|
-
import { useCallback } from 'react';
|
|
3
|
-
import { useStoreApi } from 'reactflow';
|
|
4
|
-
import { useStore } from 'zustand';
|
|
5
|
-
|
|
6
|
-
export function useDetachNodes() {
|
|
7
|
-
const sys = useSystem();
|
|
8
|
-
const setNodes = useStore(sys.nodeStore, (x) => x.setNodes);
|
|
9
|
-
const store = useStoreApi();
|
|
10
|
-
|
|
11
|
-
const detachNodes = useCallback(
|
|
12
|
-
(ids: string[], removeParentId?: string) => {
|
|
13
|
-
const { nodeInternals } = store.getState();
|
|
14
|
-
const nextNodes = Array.from(nodeInternals.values()).map((n) => {
|
|
15
|
-
if (ids.includes(n.id) && n.parentId) {
|
|
16
|
-
const parentNode = nodeInternals.get(n.parentId);
|
|
17
|
-
|
|
18
|
-
//Remove parent reference and recalculate in global space
|
|
19
|
-
return {
|
|
20
|
-
...n,
|
|
21
|
-
position: {
|
|
22
|
-
x: n.position.x + (parentNode?.positionAbsolute?.x ?? 0),
|
|
23
|
-
y: n.position.y + (parentNode?.positionAbsolute?.y ?? 0)
|
|
24
|
-
},
|
|
25
|
-
extent: undefined,
|
|
26
|
-
parentId: undefined
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
return n;
|
|
30
|
-
});
|
|
31
|
-
setNodes(
|
|
32
|
-
nextNodes.filter((n) => !removeParentId || n.id !== removeParentId)
|
|
33
|
-
);
|
|
34
|
-
},
|
|
35
|
-
[setNodes, store]
|
|
36
|
-
);
|
|
37
|
-
|
|
38
|
-
return detachNodes;
|
|
39
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Type definitions for Web Worker Graph Runner
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import type { StoreApi } from 'zustand';
|
|
6
|
-
import type { WebWorkerGraphRunnerStore } from './store.js';
|
|
7
|
-
|
|
8
|
-
declare module '@/system/system' {
|
|
9
|
-
interface System {
|
|
10
|
-
/**
|
|
11
|
-
* Web Worker Graph Runner store
|
|
12
|
-
*/
|
|
13
|
-
webWorkerGraphRunnerStore: StoreApi<WebWorkerGraphRunnerStore>;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export type { WebWorkerGraphRunnerStore };
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
// Re-export specific factories for easy external registration
|
|
2
|
-
export { getCustomEventOnTriggeredSpecific } from './CustomEventOnTriggeredSpecific';
|
|
3
|
-
export { getCustomEventTriggerSpecific } from './CustomEventTriggerSpecific';
|
|
4
|
-
export { getVariableGetSpecific } from './VariableGetSpecific';
|
|
5
|
-
export { getVariableSetSpecific } from './VariableSetSpecific';
|
package/src/store/chat.ts
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import { create } from 'zustand';
|
|
2
|
-
|
|
3
|
-
export interface AgentConfig {
|
|
4
|
-
model?: string;
|
|
5
|
-
systemPrompt?: string;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export interface ChatMessage {
|
|
9
|
-
id: string;
|
|
10
|
-
role: 'user' | 'assistant' | 'system';
|
|
11
|
-
content: string;
|
|
12
|
-
timestamp: Date;
|
|
13
|
-
isStreaming?: boolean;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export type ChatStore = {
|
|
17
|
-
messages: ChatMessage[];
|
|
18
|
-
agent: AgentConfig | undefined;
|
|
19
|
-
isStreaming: boolean;
|
|
20
|
-
inputValue: string;
|
|
21
|
-
|
|
22
|
-
setAgent: (agent: AgentConfig) => void;
|
|
23
|
-
clearAgent: () => void;
|
|
24
|
-
addMessage: (message: ChatMessage) => void;
|
|
25
|
-
updateStreamingMessage: (id: string, content: string) => void;
|
|
26
|
-
finalizeStreamingMessage: (id: string) => void;
|
|
27
|
-
setIsStreaming: (streaming: boolean) => void;
|
|
28
|
-
setInputValue: (value: string) => void;
|
|
29
|
-
clearMessages: () => void;
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
let messageCounter = 0;
|
|
33
|
-
|
|
34
|
-
export function createMessageId(): string {
|
|
35
|
-
messageCounter += 1;
|
|
36
|
-
return `msg-${Date.now()}-${String(messageCounter)}`;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export const chatStoreFactory = () =>
|
|
40
|
-
create<ChatStore>((set) => ({
|
|
41
|
-
messages: [],
|
|
42
|
-
agent: undefined,
|
|
43
|
-
isStreaming: false,
|
|
44
|
-
inputValue: '',
|
|
45
|
-
|
|
46
|
-
setAgent: (agent: AgentConfig) => set({ agent }),
|
|
47
|
-
clearAgent: () => set({ agent: undefined }),
|
|
48
|
-
|
|
49
|
-
addMessage: (message: ChatMessage) =>
|
|
50
|
-
set((state) => ({
|
|
51
|
-
messages: [...state.messages, message]
|
|
52
|
-
})),
|
|
53
|
-
|
|
54
|
-
updateStreamingMessage: (id: string, content: string) =>
|
|
55
|
-
set((state) => ({
|
|
56
|
-
messages: state.messages.map((msg) =>
|
|
57
|
-
msg.id === id ? { ...msg, content } : msg
|
|
58
|
-
)
|
|
59
|
-
})),
|
|
60
|
-
|
|
61
|
-
finalizeStreamingMessage: (id: string) =>
|
|
62
|
-
set((state) => ({
|
|
63
|
-
messages: state.messages.map((msg) =>
|
|
64
|
-
msg.id === id ? { ...msg, isStreaming: false } : msg
|
|
65
|
-
)
|
|
66
|
-
})),
|
|
67
|
-
|
|
68
|
-
setIsStreaming: (streaming: boolean) => set({ isStreaming: streaming }),
|
|
69
|
-
|
|
70
|
-
setInputValue: (value: string) => set({ inputValue: value }),
|
|
71
|
-
|
|
72
|
-
clearMessages: () => set({ messages: [] })
|
|
73
|
-
}));
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
import { createStore } from 'zustand/vanilla';
|
|
2
|
-
import type { GraphRunnerClient } from '../plugin/graphrunner/client';
|
|
3
|
-
import type {
|
|
4
|
-
AuthCredentials,
|
|
5
|
-
GraphRunnerCapabilities,
|
|
6
|
-
ServerVariable,
|
|
7
|
-
ServerEvent
|
|
8
|
-
} from '../plugin/graphrunner/types';
|
|
9
|
-
import type { NodeSpecJSON } from '@kiberon-labs/behave-graph';
|
|
10
|
-
|
|
11
|
-
export interface ConnectionConfig {
|
|
12
|
-
url: string;
|
|
13
|
-
auth: AuthCredentials;
|
|
14
|
-
autoReconnect: boolean;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export interface ConnectionInfo {
|
|
18
|
-
serverId: string | null;
|
|
19
|
-
userId: string | null;
|
|
20
|
-
sessionId: string | null;
|
|
21
|
-
authenticated: boolean;
|
|
22
|
-
capabilities: GraphRunnerCapabilities | null;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export interface GraphRunnerClientStore {
|
|
26
|
-
// Connection state
|
|
27
|
-
connectionState:
|
|
28
|
-
| 'disconnected'
|
|
29
|
-
| 'connecting'
|
|
30
|
-
| 'authenticating'
|
|
31
|
-
| 'connected';
|
|
32
|
-
connectionConfig: ConnectionConfig;
|
|
33
|
-
connectionInfo: ConnectionInfo;
|
|
34
|
-
error: string | null;
|
|
35
|
-
|
|
36
|
-
// Client instance
|
|
37
|
-
client: GraphRunnerClient | null;
|
|
38
|
-
|
|
39
|
-
// Server metadata
|
|
40
|
-
serverVariables: ServerVariable[];
|
|
41
|
-
serverEvents: ServerEvent[];
|
|
42
|
-
nodeTypes: NodeSpecJSON[];
|
|
43
|
-
|
|
44
|
-
// Actions
|
|
45
|
-
setConnectionConfig: (config: Partial<ConnectionConfig>) => void;
|
|
46
|
-
setClient: (client: GraphRunnerClient | null) => void;
|
|
47
|
-
setConnectionState: (
|
|
48
|
-
state: 'disconnected' | 'connecting' | 'authenticating' | 'connected'
|
|
49
|
-
) => void;
|
|
50
|
-
setConnectionInfo: (info: Partial<ConnectionInfo>) => void;
|
|
51
|
-
setError: (error: string | null) => void;
|
|
52
|
-
setServerVariables: (variables: ServerVariable[]) => void;
|
|
53
|
-
setServerEvents: (events: ServerEvent[]) => void;
|
|
54
|
-
setNodeTypes: (nodeTypes: NodeSpecJSON[]) => void;
|
|
55
|
-
clearServerMetadata: () => void;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export const graphRunnerClientStoreFactory = () => {
|
|
59
|
-
return createStore<GraphRunnerClientStore>((set) => ({
|
|
60
|
-
// Initial state
|
|
61
|
-
connectionState: 'disconnected',
|
|
62
|
-
connectionConfig: {
|
|
63
|
-
url: '',
|
|
64
|
-
auth: { type: 'none' },
|
|
65
|
-
autoReconnect: true
|
|
66
|
-
},
|
|
67
|
-
connectionInfo: {
|
|
68
|
-
serverId: null,
|
|
69
|
-
userId: null,
|
|
70
|
-
sessionId: null,
|
|
71
|
-
authenticated: false,
|
|
72
|
-
capabilities: null
|
|
73
|
-
},
|
|
74
|
-
error: null,
|
|
75
|
-
client: null,
|
|
76
|
-
serverVariables: [],
|
|
77
|
-
serverEvents: [],
|
|
78
|
-
nodeTypes: [],
|
|
79
|
-
|
|
80
|
-
// Actions
|
|
81
|
-
setConnectionConfig: (config) =>
|
|
82
|
-
set((state) => ({
|
|
83
|
-
connectionConfig: { ...state.connectionConfig, ...config }
|
|
84
|
-
})),
|
|
85
|
-
|
|
86
|
-
setClient: (client) => set({ client }),
|
|
87
|
-
|
|
88
|
-
setConnectionState: (connectionState) => set({ connectionState }),
|
|
89
|
-
|
|
90
|
-
setConnectionInfo: (info) =>
|
|
91
|
-
set((state) => ({
|
|
92
|
-
connectionInfo: { ...state.connectionInfo, ...info }
|
|
93
|
-
})),
|
|
94
|
-
|
|
95
|
-
setError: (error) => set({ error }),
|
|
96
|
-
|
|
97
|
-
setServerVariables: (serverVariables) => set({ serverVariables }),
|
|
98
|
-
|
|
99
|
-
setServerEvents: (serverEvents) => set({ serverEvents }),
|
|
100
|
-
|
|
101
|
-
setNodeTypes: (nodeTypes) => set({ nodeTypes }),
|
|
102
|
-
|
|
103
|
-
clearServerMetadata: () =>
|
|
104
|
-
set({
|
|
105
|
-
serverVariables: [],
|
|
106
|
-
serverEvents: [],
|
|
107
|
-
nodeTypes: []
|
|
108
|
-
})
|
|
109
|
-
}));
|
|
110
|
-
};
|