@dxos/react-ui-canvas-compute 0.7.5-labs.071a3e2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (155) hide show
  1. package/LICENSE +8 -0
  2. package/README.md +1 -0
  3. package/dist/lib/browser/index.mjs +2535 -0
  4. package/dist/lib/browser/index.mjs.map +7 -0
  5. package/dist/lib/browser/meta.json +1 -0
  6. package/dist/lib/node/index.cjs +2627 -0
  7. package/dist/lib/node/index.cjs.map +7 -0
  8. package/dist/lib/node/meta.json +1 -0
  9. package/dist/lib/node-esm/index.mjs +2535 -0
  10. package/dist/lib/node-esm/index.mjs.map +7 -0
  11. package/dist/lib/node-esm/meta.json +1 -0
  12. package/dist/types/src/components/DiagnosticOverlay.d.ts +7 -0
  13. package/dist/types/src/components/DiagnosticOverlay.d.ts.map +1 -0
  14. package/dist/types/src/components/index.d.ts +2 -0
  15. package/dist/types/src/components/index.d.ts.map +1 -0
  16. package/dist/types/src/compute-layout.d.ts +9 -0
  17. package/dist/types/src/compute-layout.d.ts.map +1 -0
  18. package/dist/types/src/compute.stories.d.ts +28 -0
  19. package/dist/types/src/compute.stories.d.ts.map +1 -0
  20. package/dist/types/src/graph/controller.d.ts +142 -0
  21. package/dist/types/src/graph/controller.d.ts.map +1 -0
  22. package/dist/types/src/graph/index.d.ts +3 -0
  23. package/dist/types/src/graph/index.d.ts.map +1 -0
  24. package/dist/types/src/graph/node-defs.d.ts +6 -0
  25. package/dist/types/src/graph/node-defs.d.ts.map +1 -0
  26. package/dist/types/src/hooks/compute-context.d.ts +7 -0
  27. package/dist/types/src/hooks/compute-context.d.ts.map +1 -0
  28. package/dist/types/src/hooks/index.d.ts +4 -0
  29. package/dist/types/src/hooks/index.d.ts.map +1 -0
  30. package/dist/types/src/hooks/useComputeNodeState.d.ts +19 -0
  31. package/dist/types/src/hooks/useComputeNodeState.d.ts.map +1 -0
  32. package/dist/types/src/hooks/useGraphMonitor.d.ts +14 -0
  33. package/dist/types/src/hooks/useGraphMonitor.d.ts.map +1 -0
  34. package/dist/types/src/index.d.ts +6 -0
  35. package/dist/types/src/index.d.ts.map +1 -0
  36. package/dist/types/src/json.test.d.ts +21 -0
  37. package/dist/types/src/json.test.d.ts.map +1 -0
  38. package/dist/types/src/registry.d.ts +9 -0
  39. package/dist/types/src/registry.d.ts.map +1 -0
  40. package/dist/types/src/schema.test.d.ts +2 -0
  41. package/dist/types/src/schema.test.d.ts.map +1 -0
  42. package/dist/types/src/shapes/Append.d.ts +54 -0
  43. package/dist/types/src/shapes/Append.d.ts.map +1 -0
  44. package/dist/types/src/shapes/Array.d.ts +38 -0
  45. package/dist/types/src/shapes/Array.d.ts.map +1 -0
  46. package/dist/types/src/shapes/Audio.d.ts +54 -0
  47. package/dist/types/src/shapes/Audio.d.ts.map +1 -0
  48. package/dist/types/src/shapes/Beacon.d.ts +54 -0
  49. package/dist/types/src/shapes/Beacon.d.ts.map +1 -0
  50. package/dist/types/src/shapes/Boolean.d.ts +233 -0
  51. package/dist/types/src/shapes/Boolean.d.ts.map +1 -0
  52. package/dist/types/src/shapes/Chat.d.ts +57 -0
  53. package/dist/types/src/shapes/Chat.d.ts.map +1 -0
  54. package/dist/types/src/shapes/Constant.d.ts +60 -0
  55. package/dist/types/src/shapes/Constant.d.ts.map +1 -0
  56. package/dist/types/src/shapes/Database.d.ts +54 -0
  57. package/dist/types/src/shapes/Database.d.ts.map +1 -0
  58. package/dist/types/src/shapes/Function.d.ts +54 -0
  59. package/dist/types/src/shapes/Function.d.ts.map +1 -0
  60. package/dist/types/src/shapes/Gpt.d.ts +54 -0
  61. package/dist/types/src/shapes/Gpt.d.ts.map +1 -0
  62. package/dist/types/src/shapes/GptRealtime.d.ts +54 -0
  63. package/dist/types/src/shapes/GptRealtime.d.ts.map +1 -0
  64. package/dist/types/src/shapes/Json.d.ts +107 -0
  65. package/dist/types/src/shapes/Json.d.ts.map +1 -0
  66. package/dist/types/src/shapes/Logic.d.ts +109 -0
  67. package/dist/types/src/shapes/Logic.d.ts.map +1 -0
  68. package/dist/types/src/shapes/Queue.d.ts +58 -0
  69. package/dist/types/src/shapes/Queue.d.ts.map +1 -0
  70. package/dist/types/src/shapes/RNG.d.ts +58 -0
  71. package/dist/types/src/shapes/RNG.d.ts.map +1 -0
  72. package/dist/types/src/shapes/Scope.d.ts +54 -0
  73. package/dist/types/src/shapes/Scope.d.ts.map +1 -0
  74. package/dist/types/src/shapes/Surface.d.ts +54 -0
  75. package/dist/types/src/shapes/Surface.d.ts.map +1 -0
  76. package/dist/types/src/shapes/Switch.d.ts +54 -0
  77. package/dist/types/src/shapes/Switch.d.ts.map +1 -0
  78. package/dist/types/src/shapes/Table.d.ts +54 -0
  79. package/dist/types/src/shapes/Table.d.ts.map +1 -0
  80. package/dist/types/src/shapes/Template.d.ts +56 -0
  81. package/dist/types/src/shapes/Template.d.ts.map +1 -0
  82. package/dist/types/src/shapes/Text.d.ts +54 -0
  83. package/dist/types/src/shapes/Text.d.ts.map +1 -0
  84. package/dist/types/src/shapes/TextToImage.d.ts +54 -0
  85. package/dist/types/src/shapes/TextToImage.d.ts.map +1 -0
  86. package/dist/types/src/shapes/Thread.d.ts +58 -0
  87. package/dist/types/src/shapes/Thread.d.ts.map +1 -0
  88. package/dist/types/src/shapes/Trigger.d.ts +64 -0
  89. package/dist/types/src/shapes/Trigger.d.ts.map +1 -0
  90. package/dist/types/src/shapes/common/Box.d.ts +25 -0
  91. package/dist/types/src/shapes/common/Box.d.ts.map +1 -0
  92. package/dist/types/src/shapes/common/FunctionBody.d.ts +15 -0
  93. package/dist/types/src/shapes/common/FunctionBody.d.ts.map +1 -0
  94. package/dist/types/src/shapes/common/TypeSelect.d.ts +4 -0
  95. package/dist/types/src/shapes/common/TypeSelect.d.ts.map +1 -0
  96. package/dist/types/src/shapes/common/index.d.ts +4 -0
  97. package/dist/types/src/shapes/common/index.d.ts.map +1 -0
  98. package/dist/types/src/shapes/defs.d.ts +39 -0
  99. package/dist/types/src/shapes/defs.d.ts.map +1 -0
  100. package/dist/types/src/shapes/index.d.ts +27 -0
  101. package/dist/types/src/shapes/index.d.ts.map +1 -0
  102. package/dist/types/src/testing/circuits.d.ts +193 -0
  103. package/dist/types/src/testing/circuits.d.ts.map +1 -0
  104. package/dist/types/src/testing/index.d.ts +2 -0
  105. package/dist/types/src/testing/index.d.ts.map +1 -0
  106. package/dist/types/tsconfig.tsbuildinfo +1 -0
  107. package/package.json +85 -0
  108. package/src/README.md +47 -0
  109. package/src/components/DiagnosticOverlay.tsx +23 -0
  110. package/src/components/index.ts +5 -0
  111. package/src/compute-layout.ts +37 -0
  112. package/src/compute.stories.tsx +365 -0
  113. package/src/graph/controller.ts +419 -0
  114. package/src/graph/index.ts +6 -0
  115. package/src/graph/node-defs.ts +82 -0
  116. package/src/hooks/compute-context.ts +19 -0
  117. package/src/hooks/index.ts +7 -0
  118. package/src/hooks/useComputeNodeState.ts +83 -0
  119. package/src/hooks/useGraphMonitor.ts +133 -0
  120. package/src/index.ts +9 -0
  121. package/src/json.test.ts +35 -0
  122. package/src/registry.ts +100 -0
  123. package/src/schema.test.ts +62 -0
  124. package/src/shapes/Append.tsx +43 -0
  125. package/src/shapes/Array.tsx +61 -0
  126. package/src/shapes/Audio.tsx +55 -0
  127. package/src/shapes/Beacon.tsx +56 -0
  128. package/src/shapes/Boolean.tsx +215 -0
  129. package/src/shapes/Chat.tsx +77 -0
  130. package/src/shapes/Constant.tsx +125 -0
  131. package/src/shapes/Database.tsx +39 -0
  132. package/src/shapes/Function.tsx +40 -0
  133. package/src/shapes/Gpt.tsx +91 -0
  134. package/src/shapes/GptRealtime.tsx +175 -0
  135. package/src/shapes/Json.tsx +103 -0
  136. package/src/shapes/Logic.tsx +82 -0
  137. package/src/shapes/Queue.tsx +78 -0
  138. package/src/shapes/RNG.tsx +84 -0
  139. package/src/shapes/Scope.tsx +54 -0
  140. package/src/shapes/Surface.tsx +57 -0
  141. package/src/shapes/Switch.tsx +53 -0
  142. package/src/shapes/Table.tsx +45 -0
  143. package/src/shapes/Template.tsx +98 -0
  144. package/src/shapes/Text.tsx +56 -0
  145. package/src/shapes/TextToImage.tsx +39 -0
  146. package/src/shapes/Thread.tsx +87 -0
  147. package/src/shapes/Trigger.tsx +152 -0
  148. package/src/shapes/common/Box.tsx +74 -0
  149. package/src/shapes/common/FunctionBody.tsx +122 -0
  150. package/src/shapes/common/TypeSelect.tsx +31 -0
  151. package/src/shapes/common/index.ts +7 -0
  152. package/src/shapes/defs.ts +50 -0
  153. package/src/shapes/index.ts +31 -0
  154. package/src/testing/circuits.ts +320 -0
  155. package/src/testing/index.ts +5 -0
@@ -0,0 +1,2627 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var node_exports = {};
30
+ __export(node_exports, {
31
+ AndShape: () => AndShape,
32
+ AppendComponent: () => AppendComponent,
33
+ AppendShape: () => AppendShape,
34
+ AudioComponent: () => AudioComponent,
35
+ AudioShape: () => AudioShape,
36
+ BeaconComponent: () => BeaconComponent,
37
+ BeaconShape: () => BeaconShape,
38
+ Box: () => Box,
39
+ ChatShape: () => ChatShape,
40
+ ComputeContext: () => ComputeContext,
41
+ ComputeGraphController: () => ComputeGraphController,
42
+ ComputeShape: () => ComputeShape,
43
+ ComputeShapeLayout: () => ComputeShapeLayout,
44
+ ConstantComponent: () => ConstantComponent,
45
+ ConstantShape: () => ConstantShape,
46
+ DatabaseComponent: () => DatabaseComponent,
47
+ DatabaseShape: () => DatabaseShape,
48
+ FunctionBody: () => FunctionBody,
49
+ FunctionComponent: () => FunctionComponent,
50
+ FunctionShape: () => FunctionShape,
51
+ GptComponent: () => GptComponent,
52
+ GptRealtimeComponent: () => GptRealtimeComponent,
53
+ GptRealtimeShape: () => GptRealtimeShape,
54
+ GptShape: () => GptShape,
55
+ IfComponent: () => IfComponent,
56
+ IfElseComponent: () => IfElseComponent,
57
+ IfElseShape: () => IfElseShape,
58
+ IfShape: () => IfShape,
59
+ InvalidStateError: () => InvalidStateError,
60
+ JsonComponent: () => JsonComponent,
61
+ JsonShape: () => JsonShape,
62
+ JsonTransformComponent: () => JsonTransformComponent,
63
+ JsonTransformShape: () => JsonTransformShape,
64
+ NotShape: () => NotShape,
65
+ OrShape: () => OrShape,
66
+ QueueComponent: () => QueueComponent,
67
+ QueueItem: () => QueueItem,
68
+ QueueShape: () => QueueShape,
69
+ RandomComponent: () => RandomComponent,
70
+ RandomShape: () => RandomShape,
71
+ ReducerComponent: () => ReducerComponent,
72
+ ReducerShape: () => ReducerShape,
73
+ ScopeComponent: () => ScopeComponent,
74
+ ScopeShape: () => ScopeShape,
75
+ SurfaceComponent: () => SurfaceComponent,
76
+ SurfaceShape: () => SurfaceShape,
77
+ SwitchComponent: () => SwitchComponent,
78
+ SwitchShape: () => SwitchShape,
79
+ TableComponent: () => TableComponent,
80
+ TableShape: () => TableShape,
81
+ TemplateShape: () => TemplateShape,
82
+ TextComponent: () => TextComponent,
83
+ TextInputComponent: () => TextInputComponent,
84
+ TextShape: () => TextShape,
85
+ TextToImageComponent: () => TextToImageComponent,
86
+ TextToImageShape: () => TextToImageShape,
87
+ ThreadComponent: () => ThreadComponent,
88
+ ThreadItem: () => ThreadItem,
89
+ ThreadShape: () => ThreadShape,
90
+ TriggerComponent: () => TriggerComponent,
91
+ TriggerShape: () => TriggerShape,
92
+ TypeSelect: () => TypeSelect,
93
+ andShape: () => andShape,
94
+ appendShape: () => appendShape,
95
+ audioShape: () => audioShape,
96
+ beaconShape: () => beaconShape,
97
+ chatShape: () => chatShape,
98
+ computeShapes: () => computeShapes,
99
+ constantShape: () => constantShape,
100
+ createAnchorId: () => createAnchorId,
101
+ createAnd: () => createAnd,
102
+ createAppend: () => createAppend,
103
+ createAudio: () => createAudio,
104
+ createBeacon: () => createBeacon,
105
+ createChat: () => createChat,
106
+ createComputeGraph: () => createComputeGraph,
107
+ createComputeGraphController: () => createComputeGraphController,
108
+ createComputeNode: () => createComputeNode,
109
+ createConstant: () => createConstant,
110
+ createDatabase: () => createDatabase,
111
+ createFunction: () => createFunction,
112
+ createFunctionAnchors: () => createFunctionAnchors,
113
+ createGpt: () => createGpt,
114
+ createGptRealtime: () => createGptRealtime,
115
+ createIf: () => createIf,
116
+ createIfElse: () => createIfElse,
117
+ createJson: () => createJson,
118
+ createJsonTransform: () => createJsonTransform,
119
+ createNot: () => createNot,
120
+ createOr: () => createOr,
121
+ createQueue: () => createQueue,
122
+ createRandom: () => createRandom,
123
+ createReducer: () => createReducer,
124
+ createScope: () => createScope,
125
+ createShape: () => createShape,
126
+ createSurface: () => createSurface,
127
+ createSwitch: () => createSwitch,
128
+ createTable: () => createTable,
129
+ createTemplate: () => createTemplate,
130
+ createText: () => createText,
131
+ createTextToImage: () => createTextToImage,
132
+ createThread: () => createThread,
133
+ createTrigger: () => createTrigger,
134
+ databaseShape: () => databaseShape,
135
+ footerHeight: () => footerHeight,
136
+ functionShape: () => functionShape,
137
+ getHeight: () => getHeight,
138
+ getProperties: () => getProperties,
139
+ gptRealtimeShape: () => gptRealtimeShape,
140
+ gptShape: () => gptShape,
141
+ headerHeight: () => headerHeight,
142
+ ifElseShape: () => ifElseShape,
143
+ ifShape: () => ifShape,
144
+ isValidComputeNode: () => isValidComputeNode,
145
+ jsonShape: () => jsonShape,
146
+ jsonTransformShape: () => jsonTransformShape,
147
+ mapEdge: () => mapEdge,
148
+ notShape: () => notShape,
149
+ orShape: () => orShape,
150
+ parseAnchorId: () => parseAnchorId,
151
+ queueShape: () => queueShape,
152
+ randomShape: () => randomShape,
153
+ reducerShape: () => reducerShape,
154
+ resolveComputeNode: () => resolveComputeNode,
155
+ scopeShape: () => scopeShape,
156
+ surfaceShape: () => surfaceShape,
157
+ switchShape: () => switchShape,
158
+ tableShape: () => tableShape,
159
+ templateShape: () => templateShape,
160
+ textShape: () => textShape,
161
+ textToImageShape: () => textToImageShape,
162
+ threadShape: () => threadShape,
163
+ triggerShape: () => triggerShape,
164
+ useComputeContext: () => useComputeContext,
165
+ useComputeNodeState: () => useComputeNodeState,
166
+ useGraphMonitor: () => useGraphMonitor
167
+ });
168
+ module.exports = __toCommonJS(node_exports);
169
+ var import_effect = require("effect");
170
+ var import_async = require("@dxos/async");
171
+ var import_conductor = require("@dxos/conductor");
172
+ var import_context = require("@dxos/context");
173
+ var import_log = require("@dxos/log");
174
+ var import_conductor2 = require("@dxos/conductor");
175
+ var import_debug = require("@dxos/debug");
176
+ var import_echo_schema = require("@dxos/echo-schema");
177
+ var import_invariant = require("@dxos/invariant");
178
+ var import_react = require("react");
179
+ var import_debug2 = require("@dxos/debug");
180
+ var import_react2 = require("react");
181
+ var import_echo_schema2 = require("@dxos/echo-schema");
182
+ var import_invariant2 = require("@dxos/invariant");
183
+ var import_react3 = require("react");
184
+ var import_conductor3 = require("@dxos/conductor");
185
+ var import_echo_schema3 = require("@dxos/echo-schema");
186
+ var import_invariant3 = require("@dxos/invariant");
187
+ var import_keys = require("@dxos/keys");
188
+ var import_echo = require("@dxos/react-client/echo");
189
+ var import_util = require("@dxos/util");
190
+ var import_react_ui_canvas_editor = require("@dxos/react-ui-canvas-editor");
191
+ var import_react4 = __toESM(require("react"));
192
+ var import_invariant4 = require("@dxos/invariant");
193
+ var import_react_ui = require("@dxos/react-ui");
194
+ var import_react_ui_canvas_editor2 = require("@dxos/react-ui-canvas-editor");
195
+ var import_react_ui_theme = require("@dxos/react-ui-theme");
196
+ var import_react5 = __toESM(require("react"));
197
+ var import_conductor4 = require("@dxos/conductor");
198
+ var import_echo_schema4 = require("@dxos/echo-schema");
199
+ var import_react_ui_canvas = require("@dxos/react-ui-canvas");
200
+ var import_react_ui_canvas_editor3 = require("@dxos/react-ui-canvas-editor");
201
+ var import_schema = require("@effect/schema");
202
+ var import_conductor5 = require("@dxos/conductor");
203
+ var import_echo_schema5 = require("@dxos/echo-schema");
204
+ var import_react_ui_canvas_editor4 = require("@dxos/react-ui-canvas-editor");
205
+ var import_react6 = __toESM(require("react"));
206
+ var import_conductor6 = require("@dxos/conductor");
207
+ var import_react_ui2 = require("@dxos/react-ui");
208
+ var import_react7 = __toESM(require("react"));
209
+ var import_conductor7 = require("@dxos/conductor");
210
+ var import_echo_schema6 = require("@dxos/echo-schema");
211
+ var import_react8 = __toESM(require("react"));
212
+ var import_conductor8 = require("@dxos/conductor");
213
+ var import_echo_schema7 = require("@dxos/echo-schema");
214
+ var import_react9 = __toESM(require("react"));
215
+ var import_echo_schema8 = require("@dxos/echo-schema");
216
+ var import_react_ui3 = require("@dxos/react-ui");
217
+ var import_react_ui_canvas_editor5 = require("@dxos/react-ui-canvas-editor");
218
+ var import_react10 = __toESM(require("react"));
219
+ var import_conductor9 = require("@dxos/conductor");
220
+ var import_echo_schema9 = require("@dxos/echo-schema");
221
+ var import_react_ui4 = require("@dxos/react-ui");
222
+ var import_react_ui_canvas_editor6 = require("@dxos/react-ui-canvas-editor");
223
+ var import_react_ui_theme2 = require("@dxos/react-ui-theme");
224
+ var import_react11 = __toESM(require("react"));
225
+ var import_echo_schema10 = require("@dxos/echo-schema");
226
+ var import_react_ui_canvas_editor7 = require("@dxos/react-ui-canvas-editor");
227
+ var import_react12 = __toESM(require("react"));
228
+ var import_conductor10 = require("@dxos/conductor");
229
+ var import_echo_schema11 = require("@dxos/echo-schema");
230
+ var import_react_ui_canvas_editor8 = require("@dxos/react-ui-canvas-editor");
231
+ var import_react_ui_canvas_editor9 = require("@dxos/react-ui-canvas-editor");
232
+ var import_react13 = __toESM(require("react"));
233
+ var import_conductor11 = require("@dxos/conductor");
234
+ var import_echo_schema12 = require("@dxos/echo-schema");
235
+ var import_react_ui5 = require("@dxos/react-ui");
236
+ var import_react_ui_canvas_editor10 = require("@dxos/react-ui-canvas-editor");
237
+ var import_react_ui_canvas_editor11 = require("@dxos/react-ui-canvas-editor");
238
+ var import_util2 = require("@dxos/util");
239
+ var import_react14 = __toESM(require("react"));
240
+ var import_echo_schema13 = require("@dxos/echo-schema");
241
+ var import_react_ui_canvas_editor12 = require("@dxos/react-ui-canvas-editor");
242
+ var import_react15 = __toESM(require("react"));
243
+ var import_conductor12 = require("@dxos/conductor");
244
+ var import_echo_schema14 = require("@dxos/echo-schema");
245
+ var import_react16 = __toESM(require("react"));
246
+ var import_conductor13 = require("@dxos/conductor");
247
+ var import_echo_schema15 = require("@dxos/echo-schema");
248
+ var import_react17 = __toESM(require("react"));
249
+ var import_conductor14 = require("@dxos/conductor");
250
+ var import_echo_schema16 = require("@dxos/echo-schema");
251
+ var import_react_ui_canvas_editor13 = require("@dxos/react-ui-canvas-editor");
252
+ var import_react_ui_syntax_highlighter = require("@dxos/react-ui-syntax-highlighter");
253
+ var import_react18 = __toESM(require("react"));
254
+ var import_conductor15 = require("@dxos/conductor");
255
+ var import_echo_schema17 = require("@dxos/echo-schema");
256
+ var import_react19 = __toESM(require("react"));
257
+ var import_conductor16 = require("@dxos/conductor");
258
+ var import_echo_schema18 = require("@dxos/echo-schema");
259
+ var import_react_ui_theme3 = require("@dxos/react-ui-theme");
260
+ var import_react20 = __toESM(require("react"));
261
+ var import_conductor17 = require("@dxos/conductor");
262
+ var import_echo_schema19 = require("@dxos/echo-schema");
263
+ var import_react_ui6 = require("@dxos/react-ui");
264
+ var import_react_ui_canvas_editor14 = require("@dxos/react-ui-canvas-editor");
265
+ var import_react_ui_theme4 = require("@dxos/react-ui-theme");
266
+ var import_react21 = __toESM(require("react"));
267
+ var import_conductor18 = require("@dxos/conductor");
268
+ var import_echo_schema20 = require("@dxos/echo-schema");
269
+ var import_react_ui_canvas_editor15 = require("@dxos/react-ui-canvas-editor");
270
+ var import_react_ui_sfx = require("@dxos/react-ui-sfx");
271
+ var import_react22 = __toESM(require("react"));
272
+ var import_app_framework = require("@dxos/app-framework");
273
+ var import_conductor19 = require("@dxos/conductor");
274
+ var import_echo_schema21 = require("@dxos/echo-schema");
275
+ var import_react_ui_canvas_editor16 = require("@dxos/react-ui-canvas-editor");
276
+ var import_react23 = __toESM(require("react"));
277
+ var import_conductor20 = require("@dxos/conductor");
278
+ var import_echo_schema22 = require("@dxos/echo-schema");
279
+ var import_react_ui7 = require("@dxos/react-ui");
280
+ var import_react_ui_canvas_editor17 = require("@dxos/react-ui-canvas-editor");
281
+ var import_react24 = __toESM(require("react"));
282
+ var import_conductor21 = require("@dxos/conductor");
283
+ var import_echo_schema23 = require("@dxos/echo-schema");
284
+ var import_react25 = __toESM(require("react"));
285
+ var import_conductor22 = require("@dxos/conductor");
286
+ var import_echo_schema24 = require("@dxos/echo-schema");
287
+ var import_invariant5 = require("@dxos/invariant");
288
+ var import_react_ui_canvas_editor18 = require("@dxos/react-ui-canvas-editor");
289
+ var import_react26 = __toESM(require("react"));
290
+ var import_conductor23 = require("@dxos/conductor");
291
+ var import_echo_schema25 = require("@dxos/echo-schema");
292
+ var import_react_ui_canvas_editor19 = require("@dxos/react-ui-canvas-editor");
293
+ var import_react_ui_canvas_editor20 = require("@dxos/react-ui-canvas-editor");
294
+ var import_react27 = __toESM(require("react"));
295
+ var import_conductor24 = require("@dxos/conductor");
296
+ var import_echo_schema26 = require("@dxos/echo-schema");
297
+ var import_react_ui_theme5 = require("@dxos/react-ui-theme");
298
+ var import_react28 = __toESM(require("react"));
299
+ var import_echo_schema27 = require("@dxos/echo-schema");
300
+ var import_react_ui_canvas_editor21 = require("@dxos/react-ui-canvas-editor");
301
+ var import_react29 = __toESM(require("react"));
302
+ var import_conductor25 = require("@dxos/conductor");
303
+ var import_echo_schema28 = require("@dxos/echo-schema");
304
+ var import_functions = require("@dxos/functions");
305
+ var import_echo2 = require("@dxos/react-client/echo");
306
+ var import_react_ui8 = require("@dxos/react-ui");
307
+ var import_react30 = __toESM(require("react"));
308
+ var import_echo_schema29 = require("@dxos/echo-schema");
309
+ var import_log2 = require("@dxos/log");
310
+ var import_react_client = require("@dxos/react-client");
311
+ var import_react_ui9 = require("@dxos/react-ui");
312
+ var import_conductor26 = require("@dxos/conductor");
313
+ var import_echo_schema30 = require("@dxos/echo-schema");
314
+ var import_react_ui_canvas_editor22 = require("@dxos/react-ui-canvas-editor");
315
+ var __dxlog_file = "/home/runner/work/dxos/dxos/packages/ui/react-ui-canvas-compute/src/graph/node-defs.ts";
316
+ var resolveComputeNode = async (node) => {
317
+ const impl = import_conductor2.registry[node.type];
318
+ (0, import_invariant.invariant)(impl, `Unknown node type: ${node.type}`, {
319
+ F: __dxlog_file,
320
+ L: 22,
321
+ S: void 0,
322
+ A: [
323
+ "impl",
324
+ "`Unknown node type: ${node.type}`"
325
+ ]
326
+ });
327
+ return impl;
328
+ };
329
+ var isValidComputeNode = (type) => {
330
+ return nodeFactory[type] !== void 0;
331
+ };
332
+ var createComputeNode = (shape) => {
333
+ const type = shape.type ?? (0, import_debug.raise)(new Error("Type not specified"));
334
+ const factory = nodeFactory[type] ?? (0, import_debug.raise)(new Error(`Unknown shape type: ${type}`));
335
+ return factory(shape);
336
+ };
337
+ var nodeFactory = {
338
+ // System.
339
+ [import_conductor2.NODE_INPUT]: () => createNode(import_conductor2.NODE_INPUT),
340
+ [import_conductor2.NODE_OUTPUT]: () => createNode(import_conductor2.NODE_OUTPUT),
341
+ // Extensions.
342
+ ["text-to-image"]: () => createNode("text-to-image"),
343
+ ["and"]: () => createNode("and"),
344
+ ["append"]: () => createNode("append"),
345
+ ["audio"]: () => createNode("audio"),
346
+ ["beacon"]: () => createNode("beacon"),
347
+ ["chat"]: () => createNode("chat"),
348
+ ["constant"]: (shape) => createNode("constant", {
349
+ value: shape.value
350
+ }),
351
+ ["database"]: () => createNode("database"),
352
+ ["gpt"]: () => createNode("gpt"),
353
+ ["gpt-realtime"]: () => createNode("gpt-realtime"),
354
+ ["if"]: () => createNode("if"),
355
+ ["if-else"]: () => createNode("if-else"),
356
+ ["function"]: () => createNode("function"),
357
+ ["json"]: () => createNode("json"),
358
+ ["json-transform"]: () => createNode("json-transform"),
359
+ ["not"]: () => createNode("not"),
360
+ ["or"]: () => createNode("or"),
361
+ ["queue"]: () => createNode("queue"),
362
+ ["rng"]: () => createNode("rng"),
363
+ ["reducer"]: () => createNode("reducer"),
364
+ ["scope"]: () => createNode("scope"),
365
+ ["surface"]: () => createNode("surface"),
366
+ ["switch"]: () => createNode("switch"),
367
+ ["template"]: (shape) => {
368
+ const node = createNode("template", {
369
+ valueType: shape.valueType,
370
+ value: shape.text
371
+ });
372
+ node.inputSchema = (0, import_echo_schema.toJsonSchema)((0, import_conductor2.getTemplateInputSchema)(node));
373
+ return node;
374
+ },
375
+ ["text"]: () => createNode("text"),
376
+ ["thread"]: () => createNode("thread"),
377
+ ["trigger"]: () => createNode(import_conductor2.NODE_INPUT)
378
+ };
379
+ var createNode = (type, props) => ({
380
+ id: import_echo_schema.ObjectId.random(),
381
+ type,
382
+ ...props
383
+ });
384
+ var ComputeContext = (0, import_react.createContext)(null);
385
+ var useComputeContext = () => {
386
+ return (0, import_react.useContext)(ComputeContext) ?? (0, import_debug2.raise)(new Error("Missing ComputeContext"));
387
+ };
388
+ var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-canvas-compute/src/hooks/useComputeNodeState.ts";
389
+ var useComputeNodeState = (shape) => {
390
+ const { controller } = useComputeContext();
391
+ (0, import_invariant2.invariant)(controller, void 0, {
392
+ F: __dxlog_file2,
393
+ L: 32,
394
+ S: void 0,
395
+ A: [
396
+ "controller",
397
+ ""
398
+ ]
399
+ });
400
+ const [meta, setMeta] = (0, import_react2.useState)();
401
+ (0, import_react2.useEffect)(() => {
402
+ let disposed = false;
403
+ queueMicrotask(async () => {
404
+ (0, import_invariant2.invariant)(shape.node, "Node not specified", {
405
+ F: __dxlog_file2,
406
+ L: 38,
407
+ S: void 0,
408
+ A: [
409
+ "shape.node",
410
+ "'Node not specified'"
411
+ ]
412
+ });
413
+ const node = controller.getComputeNode(shape.node);
414
+ const meta2 = await controller.getMeta(node);
415
+ if (disposed) {
416
+ return;
417
+ }
418
+ setMeta(meta2);
419
+ });
420
+ return () => {
421
+ disposed = true;
422
+ };
423
+ }, [
424
+ shape.node
425
+ ]);
426
+ const evalNode = (0, import_react2.useCallback)(() => {
427
+ return controller.evalNode(shape.node);
428
+ }, [
429
+ shape.node
430
+ ]);
431
+ const subscribeToEventLog = (0, import_react2.useCallback)((cb) => {
432
+ return controller.events.on((ev) => {
433
+ if (ev.nodeId === shape.node) {
434
+ cb(ev);
435
+ }
436
+ });
437
+ }, [
438
+ shape.node
439
+ ]);
440
+ return {
441
+ node: controller.getComputeNode(shape.node),
442
+ meta: meta ?? {
443
+ input: import_echo_schema2.S.Struct({}),
444
+ output: import_echo_schema2.S.Struct({})
445
+ },
446
+ runtime: {
447
+ inputs: controller.getInputs(shape.node),
448
+ outputs: controller.getOutputs(shape.node),
449
+ setOutput: (property, value) => {
450
+ controller.setOutput(shape.node, property, value);
451
+ },
452
+ evalNode,
453
+ subscribeToEventLog
454
+ }
455
+ };
456
+ };
457
+ var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-canvas-compute/src/hooks/useGraphMonitor.ts";
458
+ var mapEdge = (graph, { source, target, output = import_conductor3.DEFAULT_OUTPUT, input = import_conductor3.DEFAULT_INPUT }) => {
459
+ const sourceNode = graph.findNode(source);
460
+ const targetNode = graph.findNode(target);
461
+ (0, import_invariant3.invariant)(sourceNode?.node, void 0, {
462
+ F: __dxlog_file3,
463
+ L: 27,
464
+ S: void 0,
465
+ A: [
466
+ "sourceNode?.node",
467
+ ""
468
+ ]
469
+ });
470
+ (0, import_invariant3.invariant)(targetNode?.node, void 0, {
471
+ F: __dxlog_file3,
472
+ L: 28,
473
+ S: void 0,
474
+ A: [
475
+ "targetNode?.node",
476
+ ""
477
+ ]
478
+ });
479
+ return {
480
+ id: import_echo_schema3.ObjectId.random(),
481
+ source: sourceNode.node,
482
+ target: targetNode.node,
483
+ output,
484
+ input
485
+ };
486
+ };
487
+ var useGraphMonitor = (model) => {
488
+ return (0, import_react3.useMemo)(() => {
489
+ return {
490
+ onCreate: ({ node }) => {
491
+ if (!model) {
492
+ return;
493
+ }
494
+ (0, import_invariant3.invariant)(node.type, void 0, {
495
+ F: __dxlog_file3,
496
+ L: 53,
497
+ S: void 0,
498
+ A: [
499
+ "node.type",
500
+ ""
501
+ ]
502
+ });
503
+ if (!isValidComputeNode(node.type)) {
504
+ return;
505
+ }
506
+ const computeNode = createComputeNode(node);
507
+ if (node.type === "trigger") {
508
+ linkTriggerToCompute(model, computeNode, node);
509
+ }
510
+ model.addNode(computeNode);
511
+ node.node = computeNode.id;
512
+ },
513
+ onLink: ({ graph, edge }) => {
514
+ if (model) {
515
+ model.addEdge(mapEdge(graph, edge));
516
+ }
517
+ },
518
+ onDelete: ({ subgraph }) => {
519
+ if (model) {
520
+ const nodeIds = subgraph.nodes.map((shape) => shape.node);
521
+ const edgeIds = subgraph.edges.map(({ source, target, output = import_conductor3.DEFAULT_OUTPUT, input = import_conductor3.DEFAULT_INPUT }) => {
522
+ return model.edges.find((computeEdge) => computeEdge.input === input && computeEdge.output === output)?.id;
523
+ }).filter(import_util.nonNullable);
524
+ model.removeNodes(nodeIds);
525
+ model.removeEdges(edgeIds);
526
+ deleteTriggerObjects(model, subgraph);
527
+ }
528
+ }
529
+ };
530
+ }, [
531
+ model
532
+ ]);
533
+ };
534
+ var createComputeGraph = (graph) => {
535
+ const computeGraph = import_conductor3.ComputeGraphModel.create();
536
+ if (graph) {
537
+ for (const shape of graph.nodes) {
538
+ if (isValidComputeNode(shape.type)) {
539
+ const node = createComputeNode(shape);
540
+ computeGraph.addNode(node);
541
+ shape.node = node.id;
542
+ }
543
+ }
544
+ for (const edge of graph.edges) {
545
+ computeGraph.addEdge(mapEdge(graph, edge));
546
+ }
547
+ }
548
+ return computeGraph;
549
+ };
550
+ var linkTriggerToCompute = (graph, computeNode, triggerData) => {
551
+ const functionTrigger = triggerData.functionTrigger?.target;
552
+ (0, import_invariant3.invariant)(functionTrigger, void 0, {
553
+ F: __dxlog_file3,
554
+ L: 116,
555
+ S: void 0,
556
+ A: [
557
+ "functionTrigger",
558
+ ""
559
+ ]
560
+ });
561
+ functionTrigger.function = import_keys.DXN.fromLocalObjectId(graph.root.id).toString();
562
+ functionTrigger.meta ??= {};
563
+ functionTrigger.meta.computeNodeId = computeNode.id;
564
+ };
565
+ var deleteTriggerObjects = (computeGraph, deleted) => {
566
+ const space = (0, import_echo.getSpace)(computeGraph.root);
567
+ if (!space) {
568
+ return;
569
+ }
570
+ for (const node of deleted.nodes) {
571
+ if (node.type === "trigger") {
572
+ const trigger = node;
573
+ space.db.remove(trigger.functionTrigger.target);
574
+ }
575
+ }
576
+ };
577
+ function _ts_decorate(decorators, target, key, desc) {
578
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
579
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
580
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
581
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
582
+ }
583
+ var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-canvas-compute/src/graph/controller.ts";
584
+ var InvalidStateError = Error;
585
+ var AUTO_TRIGGER_NODES = [
586
+ "chat",
587
+ "switch",
588
+ "constant"
589
+ ];
590
+ var createComputeGraphController = (graph, services) => {
591
+ const computeGraph = createComputeGraph(graph);
592
+ const controller = new ComputeGraphController(computeGraph);
593
+ controller.setServices(services ?? {});
594
+ return {
595
+ controller,
596
+ graph
597
+ };
598
+ };
599
+ var ComputeGraphController = class extends import_context.Resource {
600
+ constructor(_graph) {
601
+ super();
602
+ this._graph = _graph;
603
+ this._executor = new import_conductor.GraphExecutor({
604
+ computeNodeResolver: (node) => resolveComputeNode(node)
605
+ });
606
+ this._diagnostics = [];
607
+ this._services = {};
608
+ this._forcedOutputs = {};
609
+ this._runtimeStateInputs = {};
610
+ this._runtimeStateOutputs = {};
611
+ this.update = new import_async.Event();
612
+ this.output = new import_async.Event();
613
+ this.events = new import_async.Event();
614
+ }
615
+ toJSON() {
616
+ return {
617
+ graph: this._graph,
618
+ state: {
619
+ inputs: this._runtimeStateInputs,
620
+ outputs: this._runtimeStateOutputs
621
+ },
622
+ forcedOutputs: this._forcedOutputs
623
+ };
624
+ }
625
+ setServices(services) {
626
+ Object.assign(this._services, services);
627
+ }
628
+ get graph() {
629
+ return this._graph;
630
+ }
631
+ get diagnostics() {
632
+ return this._diagnostics;
633
+ }
634
+ get userState() {
635
+ return this._forcedOutputs;
636
+ }
637
+ get inputStates() {
638
+ return this._runtimeStateInputs;
639
+ }
640
+ get outputStates() {
641
+ return this._runtimeStateOutputs;
642
+ }
643
+ /**
644
+ * Inputs and outputs for all nodes.
645
+ */
646
+ get state() {
647
+ const ids = [
648
+ .../* @__PURE__ */ new Set([
649
+ ...Object.keys(this._runtimeStateInputs),
650
+ ...Object.keys(this._runtimeStateOutputs)
651
+ ])
652
+ ];
653
+ return Object.fromEntries(ids.map((id) => [
654
+ id,
655
+ {
656
+ node: this._graph.getNode(id),
657
+ input: this._runtimeStateInputs[id],
658
+ output: this._runtimeStateOutputs[id]
659
+ }
660
+ ]));
661
+ }
662
+ addNode(node) {
663
+ this._graph.addNode(node);
664
+ }
665
+ addEdge(edge) {
666
+ this._graph.addEdge(edge);
667
+ }
668
+ getComputeNode(nodeId) {
669
+ return this._graph.getNode(nodeId);
670
+ }
671
+ getInputs(nodeId) {
672
+ return this._runtimeStateInputs[nodeId] ?? {};
673
+ }
674
+ getOutputs(nodeId) {
675
+ return this._runtimeStateOutputs[nodeId] ?? {};
676
+ }
677
+ setOutput(nodeId, property, value) {
678
+ this._forcedOutputs[nodeId] ??= {};
679
+ this._forcedOutputs[nodeId][property] = value;
680
+ queueMicrotask(async () => {
681
+ try {
682
+ await this.exec(nodeId);
683
+ } catch (err) {
684
+ import_log.log.catch(err, void 0, {
685
+ F: __dxlog_file4,
686
+ L: 215,
687
+ S: this,
688
+ C: (f, a) => f(...a)
689
+ });
690
+ }
691
+ });
692
+ }
693
+ async getMeta(node) {
694
+ const { meta } = await resolveComputeNode(node);
695
+ return meta;
696
+ }
697
+ async checkGraph() {
698
+ const executor = this._executor.clone();
699
+ await executor.load(this._graph);
700
+ this._diagnostics = executor.getDiagnostics();
701
+ }
702
+ async evalNode(nodeId) {
703
+ const executor = this._executor.clone();
704
+ await executor.load(this._graph);
705
+ for (const [nodeId2, outputs] of Object.entries(this._forcedOutputs)) {
706
+ executor.setOutputs(nodeId2, import_effect.Effect.succeed((0, import_conductor.makeValueBag)(outputs)));
707
+ }
708
+ const services = this._createServiceLayer();
709
+ await import_effect.Effect.runPromise(import_effect.Effect.gen(this, function* () {
710
+ const scope = yield* import_effect.Scope.make();
711
+ const executable = yield* import_effect.Effect.promise(() => resolveComputeNode(this._graph.getNode(nodeId)));
712
+ const computingOutputs = executable.exec != null;
713
+ const effect = (computingOutputs ? executor.computeOutputs(nodeId) : executor.computeInputs(nodeId)).pipe(import_effect.Effect.withSpan("runGraph"), import_effect.Effect.provide(services), import_effect.Scope.extend(scope), import_effect.Effect.flatMap(computeValueBag), import_effect.Effect.withSpan("test"), import_effect.Effect.tap((values) => {
714
+ for (const [key, value] of Object.entries(values)) {
715
+ if (computingOutputs) {
716
+ this._onOutputComputed(nodeId, key, value);
717
+ } else {
718
+ this._onInputComputed(nodeId, key, value);
719
+ }
720
+ }
721
+ }));
722
+ yield* effect;
723
+ yield* import_effect.Scope.close(scope, import_effect.Exit.void);
724
+ }));
725
+ this.update.emit();
726
+ }
727
+ /**
728
+ * Executes the graph.
729
+ * @param startFromNode - Node to start from, otherwise all {@link AUTO_TRIGGER_NODES} are executed.
730
+ */
731
+ async exec(startFromNode) {
732
+ this._runtimeStateInputs = {};
733
+ this._runtimeStateOutputs = {};
734
+ const executor = this._executor.clone();
735
+ await executor.load(this._graph);
736
+ for (const [nodeId, outputs] of Object.entries(this._forcedOutputs)) {
737
+ executor.setOutputs(nodeId, import_effect.Effect.succeed((0, import_conductor.makeValueBag)(outputs)));
738
+ }
739
+ const triggerNodes = startFromNode != null ? [
740
+ this._graph.getNode(startFromNode)
741
+ ] : this._graph.nodes.filter((node) => node.type != null && AUTO_TRIGGER_NODES.includes(node.type));
742
+ const allAffectedNodes = [
743
+ ...new Set(triggerNodes.flatMap((node) => executor.getAllDependantNodes(node.id)))
744
+ ];
745
+ const services = this._createServiceLayer();
746
+ await import_effect.Effect.runPromise(import_effect.Effect.gen(this, function* () {
747
+ const scope = yield* import_effect.Scope.make();
748
+ const tasks = [];
749
+ for (const node of allAffectedNodes) {
750
+ const executable = yield* import_effect.Effect.promise(() => resolveComputeNode(this._graph.getNode(node)));
751
+ const computingOutputs = executable.exec != null;
752
+ const effect = (computingOutputs ? executor.computeOutputs(node) : executor.computeInputs(node)).pipe(import_effect.Effect.withSpan("runGraph"), import_effect.Effect.provide(services), import_effect.Scope.extend(scope), import_effect.Effect.flatMap(computeValueBag), import_effect.Effect.withSpan("test"), import_effect.Effect.tap((values) => {
753
+ for (const [key, value] of Object.entries(values)) {
754
+ if (computingOutputs) {
755
+ this._onOutputComputed(node, key, value);
756
+ } else {
757
+ this._onInputComputed(node, key, value);
758
+ }
759
+ }
760
+ }));
761
+ tasks.push(effect);
762
+ }
763
+ yield* import_effect.Effect.all(tasks);
764
+ yield* import_effect.Scope.close(scope, import_effect.Exit.void);
765
+ }));
766
+ this.update.emit();
767
+ }
768
+ _createServiceLayer() {
769
+ const services = {
770
+ ...DEFAULT_SERVICES,
771
+ ...this._services
772
+ };
773
+ const logLayer = import_effect.Layer.succeed(import_conductor.EventLogger, this._createLogger());
774
+ const gptLayer = import_effect.Layer.succeed(import_conductor.GptService, services.gpt);
775
+ const queueLayer = services.edgeHttpClient != null ? import_conductor.QueueService.fromClient(services.edgeHttpClient) : import_conductor.QueueService.notAvailable;
776
+ const spaceLayer = services.spaceService != null ? import_effect.Layer.succeed(import_conductor.SpaceService, services.spaceService) : import_conductor.SpaceService.empty;
777
+ return import_effect.Layer.mergeAll(logLayer, gptLayer, queueLayer, spaceLayer);
778
+ }
779
+ _createLogger() {
780
+ return {
781
+ log: (event) => {
782
+ this._handleEvent(event);
783
+ },
784
+ nodeId: void 0
785
+ };
786
+ }
787
+ _handleEvent(event) {
788
+ (0, import_log.log)("handleEvent", {
789
+ event
790
+ }, {
791
+ F: __dxlog_file4,
792
+ L: 365,
793
+ S: this,
794
+ C: (f, a) => f(...a)
795
+ });
796
+ switch (event.type) {
797
+ case "compute-input": {
798
+ this._onInputComputed(event.nodeId, event.property, {
799
+ type: "executed",
800
+ value: event.value
801
+ });
802
+ break;
803
+ }
804
+ case "compute-output": {
805
+ this._onOutputComputed(event.nodeId, event.property, {
806
+ type: "executed",
807
+ value: event.value
808
+ });
809
+ break;
810
+ }
811
+ }
812
+ this.events.emit(event);
813
+ }
814
+ _onInputComputed(nodeId, property, value) {
815
+ this._runtimeStateInputs[nodeId] ??= {};
816
+ this._runtimeStateInputs[nodeId][property] = value;
817
+ }
818
+ _onOutputComputed(nodeId, property, value) {
819
+ this._runtimeStateOutputs[nodeId] ??= {};
820
+ this._runtimeStateOutputs[nodeId][property] = value;
821
+ this.output.emit({
822
+ nodeId,
823
+ property,
824
+ value
825
+ });
826
+ }
827
+ };
828
+ _ts_decorate([
829
+ import_async.synchronized
830
+ ], ComputeGraphController.prototype, "checkGraph", null);
831
+ _ts_decorate([
832
+ import_async.synchronized
833
+ ], ComputeGraphController.prototype, "exec", null);
834
+ var DEFAULT_SERVICES = {
835
+ gpt: new import_conductor.MockGpt()
836
+ };
837
+ var computeValueBag = (bag) => {
838
+ return import_effect.Effect.all(Object.entries(bag.values).map(([key, eff]) => import_effect.Effect.either(eff).pipe(import_effect.Effect.map((value) => {
839
+ if (import_effect.Either.isLeft(value)) {
840
+ if ((0, import_conductor.isNotExecuted)(value.left)) {
841
+ return [
842
+ key,
843
+ {
844
+ type: "not-executed"
845
+ }
846
+ ];
847
+ } else {
848
+ return [
849
+ key,
850
+ {
851
+ type: "error",
852
+ error: value.left
853
+ }
854
+ ];
855
+ }
856
+ } else {
857
+ return [
858
+ key,
859
+ {
860
+ type: "executed",
861
+ value: value.right
862
+ }
863
+ ];
864
+ }
865
+ })))).pipe(import_effect.Effect.map((entries) => Object.fromEntries(entries)));
866
+ };
867
+ var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-canvas-compute/src/shapes/common/Box.tsx";
868
+ var headerHeight = 32;
869
+ var footerHeight = 32;
870
+ var Box = /* @__PURE__ */ (0, import_react4.forwardRef)(({ children, classNames, shape, title, status, open, onAction }, forwardedRef) => {
871
+ (0, import_invariant4.invariant)(shape.type, void 0, {
872
+ F: __dxlog_file5,
873
+ L: 30,
874
+ S: void 0,
875
+ A: [
876
+ "shape.type",
877
+ ""
878
+ ]
879
+ });
880
+ const { icon, name, openable } = (0, import_react_ui_canvas_editor2.useShapeDef)(shape.type) ?? {
881
+ icon: "ph--placeholder--regular"
882
+ };
883
+ const { debug } = (0, import_react_ui_canvas_editor2.useEditorContext)();
884
+ return /* @__PURE__ */ import_react4.default.createElement("div", {
885
+ ref: forwardedRef,
886
+ className: "flex flex-col h-full w-full justify-between"
887
+ }, /* @__PURE__ */ import_react4.default.createElement("div", {
888
+ className: "flex shrink-0 w-full justify-between items-center h-[32px] bg-hoverSurface"
889
+ }, /* @__PURE__ */ import_react4.default.createElement(import_react_ui.Icon, {
890
+ icon,
891
+ classNames: "mx-2"
892
+ }), /* @__PURE__ */ import_react4.default.createElement("div", {
893
+ className: "grow text-sm truncate"
894
+ }, debug ? shape.type : name ?? shape.text ?? title), /* @__PURE__ */ import_react4.default.createElement(import_react_ui.IconButton, {
895
+ classNames: "p-1 text-green-500",
896
+ variant: "ghost",
897
+ icon: "ph--play--regular",
898
+ size: 4,
899
+ label: "run",
900
+ iconOnly: true,
901
+ onDoubleClick: (ev) => ev.stopPropagation(),
902
+ onClick: (ev) => {
903
+ ev.stopPropagation();
904
+ onAction?.("run");
905
+ }
906
+ })), /* @__PURE__ */ import_react4.default.createElement("div", {
907
+ className: (0, import_react_ui_theme.mx)("flex flex-col h-full grow overflow-hidden", classNames)
908
+ }, children), /* @__PURE__ */ import_react4.default.createElement("div", {
909
+ className: "flex shrink-0 w-full justify-between items-center h-[32px] bg-hoverSurface"
910
+ }, /* @__PURE__ */ import_react4.default.createElement("div", {
911
+ className: "grow px-2 text-sm truncate"
912
+ }, debug ? shape.id : status), openable && /* @__PURE__ */ import_react4.default.createElement(import_react_ui.IconButton, {
913
+ classNames: "p-1",
914
+ variant: "ghost",
915
+ icon: open ? "ph--caret-up--regular" : "ph--caret-down--regular",
916
+ size: 4,
917
+ label: open ? "close" : "open",
918
+ iconOnly: true,
919
+ onClick: (ev) => {
920
+ ev.stopPropagation();
921
+ onAction?.(open ? "close" : "open");
922
+ }
923
+ })));
924
+ });
925
+ var getProperties = (ast) => import_schema.AST.getPropertySignatures(ast).map(({ name }) => ({
926
+ name: name.toString()
927
+ }));
928
+ var createAnchorId = (kind, property = kind === "input" ? import_conductor5.DEFAULT_INPUT : import_conductor5.DEFAULT_OUTPUT) => [
929
+ kind,
930
+ property
931
+ ].join(".");
932
+ var parseAnchorId = (id) => {
933
+ const parts = id.match(/(input|output)\.(.+)/);
934
+ return parts ? parts.slice(1) : [
935
+ void 0,
936
+ id
937
+ ];
938
+ };
939
+ var ComputeShape = import_echo_schema5.S.extend(import_react_ui_canvas_editor4.Polygon, import_echo_schema5.S.Struct({
940
+ // TODO(burdon): Rename computeNode?
941
+ node: import_echo_schema5.S.optional(import_echo_schema5.ObjectId.annotations({
942
+ [import_schema.AST.DescriptionAnnotationId]: "Compute node id"
943
+ }))
944
+ }).pipe(import_echo_schema5.S.mutable));
945
+ var createShape = ({ id, ...rest }) => {
946
+ return {
947
+ id: id ?? import_echo_schema5.ObjectId.random(),
948
+ ...rest
949
+ };
950
+ };
951
+ var bodyPadding = 8;
952
+ var expandedHeight = 200;
953
+ var FunctionBody = ({ shape, name, content, inputSchema = import_conductor4.VoidInput, outputSchema = import_conductor4.VoidOutput, ...props }) => {
954
+ const { scale } = (0, import_react_ui_canvas.useCanvasContext)();
955
+ const rootRef = (0, import_react5.useRef)(null);
956
+ const [open, setOpen] = (0, import_react5.useState)(false);
957
+ const handleAction = (action) => {
958
+ if (!rootRef.current) {
959
+ return;
960
+ }
961
+ switch (action) {
962
+ case "open": {
963
+ const el = (0, import_react_ui_canvas_editor3.getParentShapeElement)(rootRef.current, shape.id);
964
+ const { height } = el.getBoundingClientRect();
965
+ el.style.height = `${height / scale + expandedHeight}px`;
966
+ setOpen(true);
967
+ break;
968
+ }
969
+ case "close": {
970
+ const el = (0, import_react_ui_canvas_editor3.getParentShapeElement)(rootRef.current, shape.id);
971
+ el.style.height = "";
972
+ setOpen(false);
973
+ break;
974
+ }
975
+ }
976
+ };
977
+ const inputs = getProperties(inputSchema.ast);
978
+ const outputs = getProperties(outputSchema.ast);
979
+ const columnCount = inputs.length && outputs.length ? 2 : 1;
980
+ return /* @__PURE__ */ import_react5.default.createElement(Box, {
981
+ ref: rootRef,
982
+ shape,
983
+ title: name,
984
+ classNames: "divide-y divide-separator",
985
+ open,
986
+ onAction: handleAction,
987
+ ...props
988
+ }, /* @__PURE__ */ import_react5.default.createElement("div", {
989
+ className: `grid grid-cols-${columnCount} items-center`,
990
+ style: {
991
+ paddingTop: bodyPadding,
992
+ paddingBottom: bodyPadding
993
+ }
994
+ }, (inputs?.length ?? 0) > 0 && /* @__PURE__ */ import_react5.default.createElement("div", {
995
+ className: "flex flex-col"
996
+ }, inputs?.map(({ name: name2 }) => /* @__PURE__ */ import_react5.default.createElement("div", {
997
+ key: name2,
998
+ className: "px-2 truncate text-sm font-mono items-center",
999
+ style: {
1000
+ height: import_react_ui_canvas_editor3.rowHeight
1001
+ }
1002
+ }, name2))), (outputs?.length ?? 0) > 0 && /* @__PURE__ */ import_react5.default.createElement("div", {
1003
+ className: "flex flex-col"
1004
+ }, outputs?.map(({ name: name2 }) => /* @__PURE__ */ import_react5.default.createElement("div", {
1005
+ key: name2,
1006
+ className: "px-2 truncate text-sm font-mono items-center text-right",
1007
+ style: {
1008
+ height: import_react_ui_canvas_editor3.rowHeight
1009
+ }
1010
+ }, name2)))), open && /* @__PURE__ */ import_react5.default.createElement("div", {
1011
+ className: "flex flex-col grow overflow-hidden"
1012
+ }, content));
1013
+ };
1014
+ var getHeight = (input) => {
1015
+ const properties = import_echo_schema4.AST.getPropertySignatures(input.ast);
1016
+ return headerHeight + footerHeight + bodyPadding * 2 + properties.length * import_react_ui_canvas_editor3.rowHeight + 2;
1017
+ };
1018
+ var createFunctionAnchors = (shape, input = import_conductor4.VoidInput, output = import_conductor4.VoidOutput) => {
1019
+ const inputs = import_echo_schema4.AST.getPropertySignatures(input.ast).map(({ name }) => createAnchorId("input", name.toString()));
1020
+ const outputs = import_echo_schema4.AST.getPropertySignatures(output.ast).map(({ name }) => createAnchorId("output", name.toString()));
1021
+ return (0, import_react_ui_canvas_editor3.createAnchors)({
1022
+ shape,
1023
+ inputs,
1024
+ outputs,
1025
+ center: {
1026
+ x: 0,
1027
+ y: (headerHeight - footerHeight) / 2 + 1
1028
+ }
1029
+ });
1030
+ };
1031
+ var TypeSelect = ({ value, onValueChange }) => {
1032
+ return /* @__PURE__ */ import_react6.default.createElement(import_react_ui2.Select.Root, {
1033
+ value,
1034
+ onValueChange
1035
+ }, /* @__PURE__ */ import_react6.default.createElement(import_react_ui2.Select.TriggerButton, {
1036
+ variant: "ghost",
1037
+ classNames: "w-full !px-0"
1038
+ }), /* @__PURE__ */ import_react6.default.createElement(import_react_ui2.Select.Portal, null, /* @__PURE__ */ import_react6.default.createElement(import_react_ui2.Select.Content, null, /* @__PURE__ */ import_react6.default.createElement(import_react_ui2.Select.ScrollUpButton, null), /* @__PURE__ */ import_react6.default.createElement(import_react_ui2.Select.Viewport, null, import_conductor6.ComputeValueType.literals.map((type) => /* @__PURE__ */ import_react6.default.createElement(import_react_ui2.Select.Option, {
1039
+ key: type,
1040
+ value: type
1041
+ }, type))), /* @__PURE__ */ import_react6.default.createElement(import_react_ui2.Select.ScrollDownButton, null), /* @__PURE__ */ import_react6.default.createElement(import_react_ui2.Select.Arrow, null))));
1042
+ };
1043
+ var ReducerShape = import_echo_schema6.S.extend(ComputeShape, import_echo_schema6.S.Struct({
1044
+ type: import_echo_schema6.S.Literal("reducer")
1045
+ }));
1046
+ var ReducerComponent = ({ shape }) => {
1047
+ return /* @__PURE__ */ import_react7.default.createElement(FunctionBody, {
1048
+ shape,
1049
+ inputSchema: import_conductor7.ReducerInput,
1050
+ outputSchema: import_conductor7.ReducerOutput
1051
+ });
1052
+ };
1053
+ var createReducer = ({ id, size = {
1054
+ width: 192,
1055
+ height: getHeight(import_conductor7.ReducerInput)
1056
+ }, ...rest }) => createShape({
1057
+ type: "reducer",
1058
+ size,
1059
+ ...rest
1060
+ });
1061
+ var reducerShape = {
1062
+ type: "reducer",
1063
+ name: "Reducer",
1064
+ icon: "ph--repeat--regular",
1065
+ component: (props) => /* @__PURE__ */ import_react7.default.createElement(ReducerComponent, props),
1066
+ createShape: createReducer,
1067
+ getAnchors: (shape) => createFunctionAnchors(shape, import_conductor7.ReducerInput, import_conductor7.ReducerOutput)
1068
+ };
1069
+ var AppendShape = import_echo_schema7.S.extend(ComputeShape, import_echo_schema7.S.Struct({
1070
+ type: import_echo_schema7.S.Literal("append")
1071
+ }));
1072
+ var createAppend = (props) => createShape({
1073
+ type: "append",
1074
+ size: {
1075
+ width: 128,
1076
+ height: getHeight(import_conductor8.AppendInput)
1077
+ },
1078
+ ...props
1079
+ });
1080
+ var AppendComponent = ({ shape }) => {
1081
+ return /* @__PURE__ */ import_react8.default.createElement(FunctionBody, {
1082
+ shape,
1083
+ inputSchema: import_conductor8.AppendInput
1084
+ });
1085
+ };
1086
+ var appendShape = {
1087
+ type: "append",
1088
+ name: "Append",
1089
+ icon: "ph--list-plus--regular",
1090
+ component: AppendComponent,
1091
+ createShape: createAppend,
1092
+ getAnchors: (shape) => createFunctionAnchors(shape, import_conductor8.AppendInput)
1093
+ };
1094
+ var AudioShape = import_echo_schema8.S.extend(ComputeShape, import_echo_schema8.S.Struct({
1095
+ type: import_echo_schema8.S.Literal("audio")
1096
+ }));
1097
+ var createAudio = (props) => createShape({
1098
+ type: "audio",
1099
+ size: {
1100
+ width: 64,
1101
+ height: 64
1102
+ },
1103
+ ...props
1104
+ });
1105
+ var AudioComponent = ({ shape }) => {
1106
+ const { node } = useComputeNodeState(shape);
1107
+ const [active, setActive] = (0, import_react9.useState)(false);
1108
+ (0, import_react9.useEffect)(() => {
1109
+ node.value = active;
1110
+ }, [
1111
+ active
1112
+ ]);
1113
+ return /* @__PURE__ */ import_react9.default.createElement("div", {
1114
+ className: "flex w-full justify-center items-center"
1115
+ }, /* @__PURE__ */ import_react9.default.createElement(import_react_ui3.Icon, {
1116
+ icon: active ? "ph--microphone--regular" : "ph--microphone-slash--regular",
1117
+ classNames: [
1118
+ "transition opacity-20 duration-1000",
1119
+ active && "opacity-100 text-red-500"
1120
+ ],
1121
+ size: 8,
1122
+ onClick: () => setActive(!active)
1123
+ }));
1124
+ };
1125
+ var audioShape = {
1126
+ type: "audio",
1127
+ name: "Audio",
1128
+ icon: "ph--microphone--regular",
1129
+ component: AudioComponent,
1130
+ createShape: createAudio,
1131
+ getAnchors: (shape) => (0, import_react_ui_canvas_editor5.createAnchorMap)(shape, {
1132
+ [createAnchorId("output")]: {
1133
+ x: 1,
1134
+ y: 0
1135
+ }
1136
+ })
1137
+ };
1138
+ var BeaconShape = import_echo_schema9.S.extend(ComputeShape, import_echo_schema9.S.Struct({
1139
+ type: import_echo_schema9.S.Literal("beacon")
1140
+ }));
1141
+ var createBeacon = (props) => createShape({
1142
+ type: "beacon",
1143
+ size: {
1144
+ width: 64,
1145
+ height: 64
1146
+ },
1147
+ ...props
1148
+ });
1149
+ var BeaconComponent = ({ shape }) => {
1150
+ const { runtime } = useComputeNodeState(shape);
1151
+ const input = runtime.inputs[import_conductor9.DEFAULT_INPUT];
1152
+ const value = input?.type === "executed" ? input.value : false;
1153
+ return /* @__PURE__ */ import_react10.default.createElement("div", {
1154
+ className: "flex w-full justify-center items-center"
1155
+ }, /* @__PURE__ */ import_react10.default.createElement(import_react_ui4.Icon, {
1156
+ icon: "ph--sun--regular",
1157
+ classNames: (0, import_react_ui_theme2.mx)("transition opacity-20 duration-1000", (0, import_conductor9.isTruthy)(value) && "opacity-100 text-yellow-500"),
1158
+ size: 8
1159
+ }));
1160
+ };
1161
+ var beaconShape = {
1162
+ type: "beacon",
1163
+ name: "Beacon",
1164
+ icon: "ph--sun--regular",
1165
+ component: BeaconComponent,
1166
+ createShape: createBeacon,
1167
+ getAnchors: (shape) => (0, import_react_ui_canvas_editor6.createAnchorMap)(shape, {
1168
+ [createAnchorId("input")]: {
1169
+ x: -1,
1170
+ y: 0
1171
+ }
1172
+ })
1173
+ };
1174
+ var GateShape = import_echo_schema10.S.extend(ComputeShape, import_echo_schema10.S.Struct({
1175
+ type: import_echo_schema10.S.String
1176
+ }));
1177
+ var createGate = (props) => createShape({
1178
+ size: {
1179
+ width: 64,
1180
+ height: 64
1181
+ },
1182
+ ...props
1183
+ });
1184
+ var GateComponent = (Symbol22) => () => {
1185
+ return /* @__PURE__ */ import_react11.default.createElement("div", {
1186
+ className: "flex w-full justify-center items-center"
1187
+ }, /* @__PURE__ */ import_react11.default.createElement(Symbol22, null));
1188
+ };
1189
+ var defineShape = ({ type, name, icon, Symbol: Symbol22, createShape: createShape2, inputs, outputs = [
1190
+ createAnchorId("output")
1191
+ ] }) => ({
1192
+ type,
1193
+ name,
1194
+ icon,
1195
+ component: GateComponent(Symbol22),
1196
+ createShape: createShape2,
1197
+ getAnchors: (shape) => (0, import_react_ui_canvas_editor7.createAnchors)({
1198
+ shape,
1199
+ inputs,
1200
+ outputs
1201
+ })
1202
+ });
1203
+ var Symbol2 = (pathConstructor, inputs) => ({
1204
+ width = 64,
1205
+ height = 32,
1206
+ // TODO(burdon): Same as line color.
1207
+ className = "fill-neutral-200 dark:fill-neutral-800 stroke-neutral-500",
1208
+ strokeWidth = 1
1209
+ }) => {
1210
+ const startX = width * 0.25;
1211
+ const endX = width * 0.75;
1212
+ const centerY = height / 2;
1213
+ const paths = pathConstructor({
1214
+ startX,
1215
+ endX,
1216
+ height
1217
+ });
1218
+ return /* @__PURE__ */ import_react11.default.createElement("svg", {
1219
+ viewBox: `0 0 ${width} ${height}`,
1220
+ className: "w-full h-full"
1221
+ }, (0, import_react_ui_canvas_editor7.getAnchorPoints)({
1222
+ x: 0,
1223
+ y: centerY
1224
+ }, inputs).map(({ x, y }, i) => /* @__PURE__ */ import_react11.default.createElement("line", {
1225
+ key: i,
1226
+ x1: x,
1227
+ y1: y,
1228
+ x2: startX * 1.3,
1229
+ y2: y,
1230
+ strokeWidth,
1231
+ className
1232
+ })), /* @__PURE__ */ import_react11.default.createElement("line", {
1233
+ x1: endX,
1234
+ y1: centerY,
1235
+ x2: width,
1236
+ y2: centerY,
1237
+ strokeWidth,
1238
+ className
1239
+ }), paths.map((path, i) => /* @__PURE__ */ import_react11.default.createElement("path", {
1240
+ key: i,
1241
+ d: path,
1242
+ strokeWidth,
1243
+ className
1244
+ })));
1245
+ };
1246
+ var AndSymbol = Symbol2(({ startX, endX, height }) => {
1247
+ const arcRadius = (endX - startX) / 2;
1248
+ return [
1249
+ `
1250
+ M ${startX},${height * 0.1}
1251
+ L ${endX - arcRadius},${height * 0.1}
1252
+ A ${arcRadius},${height * 0.4} 0 0 1 ${endX - arcRadius},${height * 0.9}
1253
+ L ${startX},${height * 0.9}
1254
+ Z
1255
+ `
1256
+ ];
1257
+ }, 2);
1258
+ var AndShape = GateShape;
1259
+ var createAnd = (props) => {
1260
+ return createGate({
1261
+ ...props,
1262
+ type: "and"
1263
+ });
1264
+ };
1265
+ var andShape = defineShape({
1266
+ type: "and",
1267
+ name: "AND",
1268
+ icon: "ph--intersection--regular",
1269
+ Symbol: AndSymbol,
1270
+ createShape: createAnd,
1271
+ inputs: [
1272
+ "input.a",
1273
+ "input.b"
1274
+ ]
1275
+ });
1276
+ var OrSymbol = Symbol2(({ startX, endX, height }) => {
1277
+ const arcRadius = (endX - startX) / 2;
1278
+ return [
1279
+ `
1280
+ M ${startX},${height * 0.1}
1281
+ L ${endX - arcRadius},${height * 0.1}
1282
+ A ${arcRadius},${height * 0.4} 0 0 1 ${endX - arcRadius},${height * 0.9}
1283
+ L ${startX},${height * 0.9}
1284
+ C ${startX * 1.4},${height * 0.5} ${startX * 1.4},${height * 0.5} ${startX},${height * 0.1}
1285
+ Z
1286
+ `
1287
+ ];
1288
+ }, 2);
1289
+ var OrShape = GateShape;
1290
+ var createOr = (props) => {
1291
+ return createGate({
1292
+ ...props,
1293
+ type: "or"
1294
+ });
1295
+ };
1296
+ var orShape = defineShape({
1297
+ type: "or",
1298
+ name: "OR",
1299
+ icon: "ph--union--regular",
1300
+ Symbol: OrSymbol,
1301
+ createShape: createOr,
1302
+ inputs: [
1303
+ "input.a",
1304
+ "input.b"
1305
+ ]
1306
+ });
1307
+ var NotSymbol = Symbol2(({ startX, endX, height }) => {
1308
+ return [
1309
+ `
1310
+ M ${startX},${height * 0.1}
1311
+ L ${endX * 0.9},${height * 0.5}
1312
+ L ${startX},${height * 0.9}
1313
+ Z
1314
+ `,
1315
+ `
1316
+ M ${endX - height * 0.2},${height * 0.5}
1317
+ A ${height * 0.1} ${height * 0.1} 0 0 1 ${endX},${height * 0.5}
1318
+ A ${height * 0.1} ${height * 0.1} 0 0 1 ${endX - height * 0.2},${height * 0.5}
1319
+ Z
1320
+ `
1321
+ ];
1322
+ }, 1);
1323
+ var NotShape = GateShape;
1324
+ var createNot = (props) => {
1325
+ return createGate({
1326
+ ...props,
1327
+ type: "not"
1328
+ });
1329
+ };
1330
+ var notShape = defineShape({
1331
+ type: "not",
1332
+ name: "NOT",
1333
+ icon: "ph--x--regular",
1334
+ Symbol: NotSymbol,
1335
+ createShape: createNot,
1336
+ inputs: [
1337
+ createAnchorId("input")
1338
+ ]
1339
+ });
1340
+ var ChatShape = import_echo_schema11.S.extend(ComputeShape, import_echo_schema11.S.Struct({
1341
+ type: import_echo_schema11.S.Literal("chat")
1342
+ }));
1343
+ var TextInputComponent = ({ shape, title, ...props }) => {
1344
+ const { runtime } = useComputeNodeState(shape);
1345
+ const inputRef = (0, import_react12.useRef)(null);
1346
+ const handleEnter = (text) => {
1347
+ const value = text.trim();
1348
+ if (value.length) {
1349
+ runtime.setOutput(import_conductor10.DEFAULT_OUTPUT, value);
1350
+ inputRef.current?.setText("");
1351
+ }
1352
+ };
1353
+ return /* @__PURE__ */ import_react12.default.createElement(Box, {
1354
+ shape,
1355
+ title
1356
+ }, /* @__PURE__ */ import_react12.default.createElement(import_react_ui_canvas_editor8.TextBox, {
1357
+ ref: inputRef,
1358
+ onEnter: handleEnter,
1359
+ ...props
1360
+ }));
1361
+ };
1362
+ var createChat = (props) => createShape({
1363
+ type: "chat",
1364
+ size: {
1365
+ width: 256,
1366
+ height: 128
1367
+ },
1368
+ ...props
1369
+ });
1370
+ var chatShape = {
1371
+ type: "chat",
1372
+ name: "Chat",
1373
+ icon: "ph--textbox--regular",
1374
+ component: (props) => /* @__PURE__ */ import_react12.default.createElement(TextInputComponent, {
1375
+ ...props,
1376
+ title: "Prompt",
1377
+ placeholder: "Message"
1378
+ }),
1379
+ createShape: createChat,
1380
+ getAnchors: (shape) => (0, import_react_ui_canvas_editor9.createAnchorMap)(shape, {
1381
+ [createAnchorId("output")]: {
1382
+ x: 1,
1383
+ y: 0
1384
+ }
1385
+ }),
1386
+ resizable: true
1387
+ };
1388
+ var ConstantShape = import_echo_schema12.S.extend(ComputeShape, import_echo_schema12.S.Struct({
1389
+ type: import_echo_schema12.S.Literal("constant"),
1390
+ value: import_echo_schema12.S.optional(import_echo_schema12.S.Any)
1391
+ }));
1392
+ var inferType = (value) => {
1393
+ if (typeof value === "string") {
1394
+ return "string";
1395
+ } else if (typeof value === "number") {
1396
+ return "number";
1397
+ } else if (typeof value === "boolean") {
1398
+ return "boolean";
1399
+ } else if (typeof value === "object") {
1400
+ return "object";
1401
+ }
1402
+ };
1403
+ var ConstantComponent = ({ shape, title, chat, ...props }) => {
1404
+ const { node } = useComputeNodeState(shape);
1405
+ const [type, setType] = (0, import_react13.useState)(inferType(node.value) ?? import_conductor11.ComputeValueType.literals[0]);
1406
+ const inputRef = (0, import_react13.useRef)(null);
1407
+ const handleEnter = (0, import_react13.useCallback)((text) => {
1408
+ const value = text.trim();
1409
+ if (value.length) {
1410
+ if (type === "number") {
1411
+ const floatValue = parseFloat(value);
1412
+ if (!isNaN(floatValue)) {
1413
+ node.value = floatValue;
1414
+ }
1415
+ } else if (type === "object") {
1416
+ node.value = (0, import_util2.safeParseJson)(value, {});
1417
+ } else {
1418
+ node.value = value;
1419
+ }
1420
+ inputRef.current?.focus();
1421
+ }
1422
+ }, [
1423
+ type
1424
+ ]);
1425
+ return /* @__PURE__ */ import_react13.default.createElement(Box, {
1426
+ shape,
1427
+ title,
1428
+ status: /* @__PURE__ */ import_react13.default.createElement(TypeSelect, {
1429
+ value: type,
1430
+ onValueChange: setType
1431
+ })
1432
+ }, (type === "string" || type === "number") && /* @__PURE__ */ import_react13.default.createElement(import_react_ui_canvas_editor10.TextBox, {
1433
+ ...props,
1434
+ ref: inputRef,
1435
+ value: node.value,
1436
+ onEnter: handleEnter
1437
+ }), type === "object" && /* @__PURE__ */ import_react13.default.createElement(import_react_ui_canvas_editor10.TextBox, {
1438
+ ...props,
1439
+ ref: inputRef,
1440
+ value: JSON.stringify(node.value, null, 2),
1441
+ language: "json"
1442
+ }), type === "boolean" && /* @__PURE__ */ import_react13.default.createElement("div", {
1443
+ className: "flex grow justify-center items-center"
1444
+ }, /* @__PURE__ */ import_react13.default.createElement(import_react_ui5.Input.Root, null, /* @__PURE__ */ import_react13.default.createElement(import_react_ui5.Input.Switch, {
1445
+ checked: node.value,
1446
+ onCheckedChange: (value) => {
1447
+ node.value = value;
1448
+ }
1449
+ }))));
1450
+ };
1451
+ var createConstant = (props) => createShape({
1452
+ type: "constant",
1453
+ size: {
1454
+ width: 192,
1455
+ height: 128
1456
+ },
1457
+ ...props
1458
+ });
1459
+ var constantShape = {
1460
+ type: "constant",
1461
+ name: "Value",
1462
+ icon: "ph--dots-three-circle--regular",
1463
+ component: (props) => /* @__PURE__ */ import_react13.default.createElement(ConstantComponent, {
1464
+ ...props,
1465
+ placeholder: "Constant"
1466
+ }),
1467
+ createShape: createConstant,
1468
+ getAnchors: (shape) => (0, import_react_ui_canvas_editor11.createAnchorMap)(shape, {
1469
+ [createAnchorId("output")]: {
1470
+ x: 1,
1471
+ y: 0
1472
+ }
1473
+ }),
1474
+ resizable: true
1475
+ };
1476
+ var DatabaseShape = import_echo_schema13.S.extend(ComputeShape, import_echo_schema13.S.Struct({
1477
+ type: import_echo_schema13.S.Literal("database")
1478
+ }));
1479
+ var createDatabase = (props) => createShape({
1480
+ type: "database",
1481
+ size: {
1482
+ width: 128,
1483
+ height: 64
1484
+ },
1485
+ ...props
1486
+ });
1487
+ var DatabaseComponent = ({ shape }) => {
1488
+ return /* @__PURE__ */ import_react14.default.createElement(Box, {
1489
+ shape
1490
+ });
1491
+ };
1492
+ var databaseShape = {
1493
+ type: "database",
1494
+ name: "ECHO",
1495
+ icon: "ph--database--regular",
1496
+ component: DatabaseComponent,
1497
+ createShape: createDatabase,
1498
+ getAnchors: (shape) => (0, import_react_ui_canvas_editor12.createAnchorMap)(shape, {
1499
+ [createAnchorId("output")]: {
1500
+ x: 1,
1501
+ y: 0
1502
+ }
1503
+ })
1504
+ };
1505
+ var FunctionShape = import_echo_schema14.S.extend(ComputeShape, import_echo_schema14.S.Struct({
1506
+ type: import_echo_schema14.S.Literal("function")
1507
+ }));
1508
+ var createFunction = (props) => createShape({
1509
+ type: "function",
1510
+ size: {
1511
+ width: 192,
1512
+ height: getHeight(import_conductor12.FunctionInput)
1513
+ },
1514
+ ...props
1515
+ });
1516
+ var FunctionComponent = ({ shape }) => {
1517
+ return /* @__PURE__ */ import_react15.default.createElement(FunctionBody, {
1518
+ shape,
1519
+ inputSchema: import_conductor12.FunctionInput,
1520
+ outputSchema: import_conductor12.AnyOutput
1521
+ });
1522
+ };
1523
+ var functionShape = {
1524
+ type: "function",
1525
+ name: "Function",
1526
+ icon: "ph--function--regular",
1527
+ component: FunctionComponent,
1528
+ createShape: createFunction,
1529
+ // TODO(burdon): Get dynamic schema.
1530
+ getAnchors: (shape) => createFunctionAnchors(shape, import_conductor12.FunctionInput, import_conductor12.AnyOutput)
1531
+ };
1532
+ var GptShape = import_echo_schema15.S.extend(ComputeShape, import_echo_schema15.S.Struct({
1533
+ type: import_echo_schema15.S.Literal("gpt")
1534
+ }));
1535
+ var createGpt = (props) => createShape({
1536
+ type: "gpt",
1537
+ size: {
1538
+ width: 256,
1539
+ height: Math.max(getHeight(import_conductor13.GptInput), getHeight(import_conductor13.GptOutput))
1540
+ },
1541
+ ...props
1542
+ });
1543
+ var GptComponent = ({ shape }) => {
1544
+ const { meta, runtime } = useComputeNodeState(shape);
1545
+ const [text, setText] = (0, import_react16.useState)("");
1546
+ const [tokens, setTokens] = (0, import_react16.useState)(0);
1547
+ (0, import_react16.useEffect)(() => {
1548
+ return runtime.subscribeToEventLog((ev) => {
1549
+ switch (ev.type) {
1550
+ case "begin-compute": {
1551
+ setText("");
1552
+ break;
1553
+ }
1554
+ case "custom": {
1555
+ const token = ev.event;
1556
+ switch (token.type) {
1557
+ case "content_block_delta":
1558
+ switch (token.delta.type) {
1559
+ case "text_delta": {
1560
+ const delta = token.delta.text;
1561
+ setText((prev) => {
1562
+ const text2 = prev + delta;
1563
+ setTokens(text2.split(" ").length);
1564
+ return text2;
1565
+ });
1566
+ break;
1567
+ }
1568
+ }
1569
+ break;
1570
+ }
1571
+ break;
1572
+ }
1573
+ }
1574
+ });
1575
+ }, [
1576
+ runtime?.subscribeToEventLog
1577
+ ]);
1578
+ return /* @__PURE__ */ import_react16.default.createElement(FunctionBody, {
1579
+ shape,
1580
+ content: /* @__PURE__ */ import_react16.default.createElement("div", {
1581
+ className: "px-2 py-1 overflow-y-scroll"
1582
+ }, text),
1583
+ status: `${tokens} tokens`,
1584
+ inputSchema: meta.input,
1585
+ outputSchema: meta.output
1586
+ });
1587
+ };
1588
+ var gptShape = {
1589
+ type: "gpt",
1590
+ name: "GPT",
1591
+ icon: "ph--brain--regular",
1592
+ component: GptComponent,
1593
+ createShape: createGpt,
1594
+ getAnchors: (shape) => createFunctionAnchors(shape, import_conductor13.GptInput, import_conductor13.GptOutput),
1595
+ openable: true
1596
+ };
1597
+ var JsonShape = import_echo_schema16.S.extend(ComputeShape, import_echo_schema16.S.Struct({
1598
+ type: import_echo_schema16.S.Literal("json")
1599
+ }));
1600
+ var JsonTransformShape = import_echo_schema16.S.extend(ComputeShape, import_echo_schema16.S.Struct({
1601
+ type: import_echo_schema16.S.Literal("json-transform")
1602
+ }));
1603
+ var JsonComponent = ({ shape, ...props }) => {
1604
+ const { runtime } = useComputeNodeState(shape);
1605
+ const input = runtime.inputs[import_conductor14.DEFAULT_INPUT];
1606
+ const value = input?.type === "executed" ? input.value : void 0;
1607
+ return /* @__PURE__ */ import_react17.default.createElement(Box, {
1608
+ shape
1609
+ }, /* @__PURE__ */ import_react17.default.createElement(import_react_ui_syntax_highlighter.JsonFilter, {
1610
+ data: value,
1611
+ classNames: "text-xs"
1612
+ }));
1613
+ };
1614
+ var JsonTransformComponent = ({ shape, ...props }) => {
1615
+ return /* @__PURE__ */ import_react17.default.createElement(Box, {
1616
+ shape
1617
+ });
1618
+ };
1619
+ var createJson = (props) => createShape({
1620
+ type: "json",
1621
+ size: {
1622
+ width: 256,
1623
+ height: 256
1624
+ },
1625
+ ...props
1626
+ });
1627
+ var jsonShape = {
1628
+ type: "json",
1629
+ name: "JSON",
1630
+ icon: "ph--code--regular",
1631
+ component: (props) => /* @__PURE__ */ import_react17.default.createElement(JsonComponent, props),
1632
+ createShape: createJson,
1633
+ getAnchors: (shape) => (0, import_react_ui_canvas_editor13.createAnchorMap)(shape, {
1634
+ [createAnchorId("input")]: {
1635
+ x: -1,
1636
+ y: 0
1637
+ },
1638
+ [createAnchorId("output")]: {
1639
+ x: 1,
1640
+ y: 0
1641
+ }
1642
+ }),
1643
+ resizable: true
1644
+ };
1645
+ var createJsonTransform = (props) => createShape({
1646
+ type: "json-transform",
1647
+ size: {
1648
+ width: 128,
1649
+ height: getHeight(import_conductor14.JsonTransformInput)
1650
+ },
1651
+ ...props
1652
+ });
1653
+ var jsonTransformShape = {
1654
+ type: "json-transform",
1655
+ name: "Transform",
1656
+ icon: "ph--shuffle-simple--regular",
1657
+ component: (props) => /* @__PURE__ */ import_react17.default.createElement(JsonTransformComponent, props),
1658
+ createShape: createJsonTransform,
1659
+ getAnchors: (shape) => createFunctionAnchors(shape, import_conductor14.JsonTransformInput, import_conductor14.DefaultOutput),
1660
+ resizable: true
1661
+ };
1662
+ var IfShape = import_echo_schema17.S.extend(ComputeShape, import_echo_schema17.S.Struct({
1663
+ type: import_echo_schema17.S.Literal("if")
1664
+ }));
1665
+ var IfElseShape = import_echo_schema17.S.extend(ComputeShape, import_echo_schema17.S.Struct({
1666
+ type: import_echo_schema17.S.Literal("if-else")
1667
+ }));
1668
+ var IfComponent = ({ shape, ...props }) => {
1669
+ return /* @__PURE__ */ import_react18.default.createElement(FunctionBody, {
1670
+ shape,
1671
+ inputSchema: import_conductor15.IfInput,
1672
+ outputSchema: import_conductor15.IfOutput
1673
+ });
1674
+ };
1675
+ var IfElseComponent = ({ shape, ...props }) => {
1676
+ return /* @__PURE__ */ import_react18.default.createElement(FunctionBody, {
1677
+ shape,
1678
+ inputSchema: import_conductor15.IfElseInput,
1679
+ outputSchema: import_conductor15.IfElseOutput
1680
+ });
1681
+ };
1682
+ var createIf = (props) => createShape({
1683
+ type: "if",
1684
+ size: {
1685
+ width: 192,
1686
+ height: getHeight(import_conductor15.IfInput)
1687
+ },
1688
+ ...props
1689
+ });
1690
+ var ifShape = {
1691
+ type: "if",
1692
+ name: "IF",
1693
+ icon: "ph--arrows-split--regular",
1694
+ component: (props) => /* @__PURE__ */ import_react18.default.createElement(IfComponent, props),
1695
+ createShape: createIf,
1696
+ getAnchors: (shape) => createFunctionAnchors(shape, import_conductor15.IfInput, import_conductor15.IfOutput)
1697
+ };
1698
+ var createIfElse = (props) => createShape({
1699
+ type: "if-else",
1700
+ size: {
1701
+ width: 192,
1702
+ height: getHeight(import_conductor15.IfElseInput)
1703
+ },
1704
+ ...props
1705
+ });
1706
+ var ifElseShape = {
1707
+ type: "if-else",
1708
+ name: "IF/ELSE",
1709
+ icon: "ph--arrows-merge--regular",
1710
+ component: (props) => /* @__PURE__ */ import_react18.default.createElement(IfElseComponent, props),
1711
+ createShape: createIfElse,
1712
+ getAnchors: (shape) => createFunctionAnchors(shape, import_conductor15.IfElseInput, import_conductor15.IfElseOutput)
1713
+ };
1714
+ var QueueShape = import_echo_schema18.S.extend(ComputeShape, import_echo_schema18.S.Struct({
1715
+ type: import_echo_schema18.S.Literal("queue")
1716
+ }));
1717
+ var createQueue = (props) => createShape({
1718
+ type: "queue",
1719
+ size: {
1720
+ width: 256,
1721
+ height: 512
1722
+ },
1723
+ ...props
1724
+ });
1725
+ var QueueComponent = ({ shape }) => {
1726
+ const { runtime } = useComputeNodeState(shape);
1727
+ const items = runtime.outputs[import_conductor16.DEFAULT_OUTPUT]?.type === "executed" ? runtime.outputs[import_conductor16.DEFAULT_OUTPUT].value : [];
1728
+ const handleAction = (action) => {
1729
+ if (action === "run") {
1730
+ runtime.evalNode();
1731
+ }
1732
+ };
1733
+ return /* @__PURE__ */ import_react19.default.createElement(Box, {
1734
+ shape,
1735
+ status: `${items.length} items`,
1736
+ onAction: handleAction
1737
+ }, /* @__PURE__ */ import_react19.default.createElement("div", {
1738
+ className: "flex flex-col w-full overflow-y-scroll divide-y divide-separator"
1739
+ }, [
1740
+ ...items
1741
+ ].map((item, i) => /* @__PURE__ */ import_react19.default.createElement(QueueItem, {
1742
+ key: i,
1743
+ classNames: "p-1 px-2",
1744
+ item
1745
+ }))));
1746
+ };
1747
+ var QueueItem = ({ classNames, item }) => {
1748
+ if (typeof item !== "object") {
1749
+ return /* @__PURE__ */ import_react19.default.createElement("div", {
1750
+ className: (0, import_react_ui_theme3.mx)(classNames, "whitespace-pre-wrap")
1751
+ }, item);
1752
+ }
1753
+ return /* @__PURE__ */ import_react19.default.createElement("div", {
1754
+ className: (0, import_react_ui_theme3.mx)("grid grid-cols-[80px,1fr]", classNames)
1755
+ }, Object.entries(item).map(([key, value]) => /* @__PURE__ */ import_react19.default.createElement(import_react19.Fragment, {
1756
+ key
1757
+ }, /* @__PURE__ */ import_react19.default.createElement("div", {
1758
+ className: "p-1 text-xs text-subdued"
1759
+ }, key), /* @__PURE__ */ import_react19.default.createElement("div", null, typeof value === "string" ? value : JSON.stringify(value)))));
1760
+ };
1761
+ var queueShape = {
1762
+ type: "queue",
1763
+ name: "Queue",
1764
+ icon: "ph--queue--regular",
1765
+ component: QueueComponent,
1766
+ createShape: createQueue,
1767
+ getAnchors: (shape) => createFunctionAnchors(shape, import_conductor16.QueueInput, import_conductor16.QueueOutput),
1768
+ resizable: true
1769
+ };
1770
+ var RandomShape = import_echo_schema19.S.extend(ComputeShape, import_echo_schema19.S.Struct({
1771
+ type: import_echo_schema19.S.Literal("rng"),
1772
+ min: import_echo_schema19.S.optional(import_echo_schema19.S.Number),
1773
+ max: import_echo_schema19.S.optional(import_echo_schema19.S.Number)
1774
+ }));
1775
+ var createRandom = (props) => createShape({
1776
+ type: "rng",
1777
+ size: {
1778
+ width: 64,
1779
+ height: 64
1780
+ },
1781
+ ...props
1782
+ });
1783
+ var icons = [
1784
+ "ph--dice-one--regular",
1785
+ "ph--dice-two--regular",
1786
+ "ph--dice-three--regular",
1787
+ "ph--dice-four--regular",
1788
+ "ph--dice-five--regular",
1789
+ "ph--dice-six--regular"
1790
+ ];
1791
+ var pickIcon = () => icons[Math.floor(Math.random() * icons.length)];
1792
+ var RandomComponent = ({ shape }) => {
1793
+ const { runtime } = useComputeNodeState(shape);
1794
+ const [spin, setSpin] = (0, import_react20.useState)(false);
1795
+ const [icon, setIcon] = (0, import_react20.useState)(pickIcon());
1796
+ (0, import_react20.useEffect)(() => {
1797
+ if (!spin) {
1798
+ return;
1799
+ }
1800
+ const i = setInterval(() => setIcon(pickIcon()), 250);
1801
+ const t1 = setTimeout(() => clearInterval(i), 900);
1802
+ const t2 = setTimeout(() => setSpin(false), 1100);
1803
+ return () => {
1804
+ clearInterval(i);
1805
+ clearTimeout(t1);
1806
+ clearTimeout(t2);
1807
+ };
1808
+ }, [
1809
+ spin
1810
+ ]);
1811
+ const handleClick = (ev) => {
1812
+ ev.stopPropagation();
1813
+ runtime.setOutput(import_conductor17.DEFAULT_OUTPUT, Math.random());
1814
+ setSpin(true);
1815
+ };
1816
+ return /* @__PURE__ */ import_react20.default.createElement("div", {
1817
+ className: "flex grow items-center justify-center"
1818
+ }, /* @__PURE__ */ import_react20.default.createElement(import_react_ui6.Icon, {
1819
+ icon,
1820
+ classNames: (0, import_react_ui_theme4.mx)(spin && "animate-[spin_1s]"),
1821
+ size: 10,
1822
+ onClick: handleClick
1823
+ }));
1824
+ };
1825
+ var randomShape = {
1826
+ type: "rng",
1827
+ name: "Random",
1828
+ icon: "ph--dice-six--regular",
1829
+ component: RandomComponent,
1830
+ createShape: createRandom,
1831
+ getAnchors: (shape) => (0, import_react_ui_canvas_editor14.createAnchorMap)(shape, {
1832
+ [createAnchorId("output")]: {
1833
+ x: 1,
1834
+ y: 0
1835
+ }
1836
+ })
1837
+ };
1838
+ var ScopeShape = import_echo_schema20.S.extend(ComputeShape, import_echo_schema20.S.Struct({
1839
+ type: import_echo_schema20.S.Literal("scope")
1840
+ }));
1841
+ var createScope = (props) => createShape({
1842
+ type: "scope",
1843
+ size: {
1844
+ width: 128,
1845
+ height: 128
1846
+ },
1847
+ classNames: "rounded-full border-primary-800",
1848
+ ...props
1849
+ });
1850
+ var ScopeComponent = ({ shape }) => {
1851
+ const { runtime } = useComputeNodeState(shape);
1852
+ const input = runtime.inputs[import_conductor18.DEFAULT_INPUT];
1853
+ const active = input?.type === "executed" ? input.value : false;
1854
+ const { getAverage } = (0, import_react_ui_sfx.useAudioStream)(active);
1855
+ return /* @__PURE__ */ import_react21.default.createElement("div", {
1856
+ className: "flex w-full justify-center items-center bg-black"
1857
+ }, /* @__PURE__ */ import_react21.default.createElement(import_react_ui_sfx.Chaos, {
1858
+ active,
1859
+ getValue: getAverage,
1860
+ options: {
1861
+ ...import_react_ui_sfx.shaderPresets.heptapod,
1862
+ zoom: 1.2
1863
+ }
1864
+ }));
1865
+ };
1866
+ var scopeShape = {
1867
+ type: "scope",
1868
+ name: "Scope",
1869
+ icon: "ph--waveform--regular",
1870
+ component: ScopeComponent,
1871
+ createShape: createScope,
1872
+ getAnchors: (shape) => (0, import_react_ui_canvas_editor15.createAnchorMap)(shape, {
1873
+ [createAnchorId("input")]: {
1874
+ x: -1,
1875
+ y: 0
1876
+ }
1877
+ })
1878
+ };
1879
+ var SurfaceShape = import_echo_schema21.S.extend(ComputeShape, import_echo_schema21.S.Struct({
1880
+ type: import_echo_schema21.S.Literal("surface")
1881
+ }));
1882
+ var createSurface = (props) => createShape({
1883
+ type: "surface",
1884
+ size: {
1885
+ width: 384,
1886
+ height: 384
1887
+ },
1888
+ ...props
1889
+ });
1890
+ var SurfaceComponent = ({ shape }) => {
1891
+ const { runtime } = useComputeNodeState(shape);
1892
+ const input = runtime.inputs[import_conductor19.DEFAULT_INPUT];
1893
+ const value = input?.type === "executed" ? input.value : null;
1894
+ const handleAction = (action) => {
1895
+ if (action === "run") {
1896
+ runtime.evalNode();
1897
+ }
1898
+ };
1899
+ return /* @__PURE__ */ import_react22.default.createElement(Box, {
1900
+ shape,
1901
+ onAction: handleAction
1902
+ }, value !== null && /* @__PURE__ */ import_react22.default.createElement(import_app_framework.Surface, {
1903
+ role: "canvas-node",
1904
+ data: {
1905
+ value
1906
+ },
1907
+ limit: 1
1908
+ }));
1909
+ };
1910
+ var surfaceShape = {
1911
+ type: "surface",
1912
+ name: "Surface",
1913
+ icon: "ph--frame-corners--regular",
1914
+ component: SurfaceComponent,
1915
+ createShape: createSurface,
1916
+ getAnchors: (shape) => (0, import_react_ui_canvas_editor16.createAnchorMap)(shape, {
1917
+ [createAnchorId("input")]: {
1918
+ x: -1,
1919
+ y: 0
1920
+ }
1921
+ }),
1922
+ resizable: true
1923
+ };
1924
+ var SwitchShape = import_echo_schema22.S.extend(ComputeShape, import_echo_schema22.S.Struct({
1925
+ type: import_echo_schema22.S.Literal("switch")
1926
+ }));
1927
+ var createSwitch = (props) => createShape({
1928
+ type: "switch",
1929
+ size: {
1930
+ width: 64,
1931
+ height: 64
1932
+ },
1933
+ ...props
1934
+ });
1935
+ var SwitchComponent = ({ shape }) => {
1936
+ const { runtime } = useComputeNodeState(shape);
1937
+ const [value, setValue] = (0, import_react23.useState)(false);
1938
+ (0, import_react23.useEffect)(() => {
1939
+ runtime.setOutput(import_conductor20.DEFAULT_OUTPUT, value);
1940
+ }, [
1941
+ value
1942
+ ]);
1943
+ return /* @__PURE__ */ import_react23.default.createElement("div", {
1944
+ className: "flex w-full justify-center items-center",
1945
+ onClick: (ev) => ev.stopPropagation()
1946
+ }, /* @__PURE__ */ import_react23.default.createElement(import_react_ui7.Input.Root, null, /* @__PURE__ */ import_react23.default.createElement(import_react_ui7.Input.Switch, {
1947
+ checked: value,
1948
+ onCheckedChange: (value2) => setValue(value2)
1949
+ })));
1950
+ };
1951
+ var switchShape = {
1952
+ type: "switch",
1953
+ name: "Switch",
1954
+ icon: "ph--toggle-left--regular",
1955
+ component: SwitchComponent,
1956
+ createShape: createSwitch,
1957
+ getAnchors: (shape) => (0, import_react_ui_canvas_editor17.createAnchorMap)(shape, {
1958
+ [createAnchorId("output")]: {
1959
+ x: 1,
1960
+ y: 0
1961
+ }
1962
+ })
1963
+ };
1964
+ var InputSchema = (0, import_conductor21.createInputSchema)(import_conductor21.GptMessage);
1965
+ var OutputSchema = (0, import_conductor21.createOutputSchema)(import_echo_schema23.S.mutable(import_echo_schema23.S.Array(import_conductor21.GptMessage)));
1966
+ var TableShape = import_echo_schema23.S.extend(ComputeShape, import_echo_schema23.S.Struct({
1967
+ type: import_echo_schema23.S.Literal("table")
1968
+ }));
1969
+ var createTable = (props) => createShape({
1970
+ type: "table",
1971
+ size: {
1972
+ width: 320,
1973
+ height: 512
1974
+ },
1975
+ ...props
1976
+ });
1977
+ var TableComponent = ({ shape }) => {
1978
+ return /* @__PURE__ */ import_react24.default.createElement(Box, {
1979
+ shape
1980
+ });
1981
+ };
1982
+ var tableShape = {
1983
+ type: "table",
1984
+ name: "Table",
1985
+ icon: "ph--table--regular",
1986
+ component: TableComponent,
1987
+ createShape: createTable,
1988
+ getAnchors: (shape) => createFunctionAnchors(shape, InputSchema, OutputSchema),
1989
+ resizable: true
1990
+ };
1991
+ var __dxlog_file6 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-canvas-compute/src/shapes/Template.tsx";
1992
+ var TemplateShape = import_echo_schema24.S.extend(ComputeShape, import_echo_schema24.S.Struct({
1993
+ type: import_echo_schema24.S.Literal("template"),
1994
+ valueType: import_echo_schema24.S.optional(import_conductor22.ComputeValueType)
1995
+ }));
1996
+ var TextInputComponent2 = ({ shape, title, ...props }) => {
1997
+ const { node } = useComputeNodeState(shape);
1998
+ const inputRef = (0, import_react25.useRef)(null);
1999
+ const handleEnter = (text) => {
2000
+ const value = text.trim();
2001
+ if (value.length) {
2002
+ const schema = (0, import_conductor22.getTemplateInputSchema)(node);
2003
+ node.value = value;
2004
+ node.inputSchema = (0, import_echo_schema24.toJsonSchema)(schema);
2005
+ }
2006
+ };
2007
+ const handleTypeChange = (newType) => {
2008
+ (0, import_invariant5.invariant)(import_echo_schema24.S.is(import_conductor22.ComputeValueType)(newType), "Invalid type", {
2009
+ F: __dxlog_file6,
2010
+ L: 57,
2011
+ S: void 0,
2012
+ A: [
2013
+ "S.is(ComputeValueType)(newType)",
2014
+ "'Invalid type'"
2015
+ ]
2016
+ });
2017
+ node.valueType = newType;
2018
+ node.inputSchema = (0, import_echo_schema24.toJsonSchema)((0, import_conductor22.getTemplateInputSchema)(node));
2019
+ };
2020
+ return /* @__PURE__ */ import_react25.default.createElement(Box, {
2021
+ shape,
2022
+ title: "Template",
2023
+ status: /* @__PURE__ */ import_react25.default.createElement(TypeSelect, {
2024
+ value: node.valueType ?? "string",
2025
+ onValueChange: handleTypeChange
2026
+ })
2027
+ }, /* @__PURE__ */ import_react25.default.createElement(import_react_ui_canvas_editor18.TextBox, {
2028
+ ...props,
2029
+ ref: inputRef,
2030
+ value: node.value,
2031
+ language: node.valueType === "object" ? "json" : void 0,
2032
+ onBlur: handleEnter,
2033
+ onEnter: handleEnter
2034
+ }));
2035
+ };
2036
+ var createTemplate = (props) => createShape({
2037
+ type: "template",
2038
+ size: {
2039
+ width: 256,
2040
+ height: 384
2041
+ },
2042
+ ...props
2043
+ });
2044
+ var templateShape = {
2045
+ type: "template",
2046
+ name: "Template",
2047
+ icon: "ph--article--regular",
2048
+ component: (props) => /* @__PURE__ */ import_react25.default.createElement(TextInputComponent2, {
2049
+ ...props,
2050
+ placeholder: "Prompt"
2051
+ }),
2052
+ createShape: createTemplate,
2053
+ getAnchors: (shape) => createFunctionAnchors(shape, import_conductor22.VoidInput, import_conductor22.TemplateOutput),
2054
+ resizable: true
2055
+ };
2056
+ var TextShape = import_echo_schema25.S.extend(ComputeShape, import_echo_schema25.S.Struct({
2057
+ type: import_echo_schema25.S.Literal("text")
2058
+ }));
2059
+ var createText = (props) => createShape({
2060
+ type: "text",
2061
+ size: {
2062
+ width: 384,
2063
+ height: 384
2064
+ },
2065
+ ...props
2066
+ });
2067
+ var TextComponent = ({ shape }) => {
2068
+ const { runtime } = useComputeNodeState(shape);
2069
+ const input = runtime.inputs[import_conductor23.DEFAULT_INPUT];
2070
+ const value = input?.type === "executed" ? input.value : 0;
2071
+ const handleAction = (action) => {
2072
+ if (action === "run") {
2073
+ runtime.evalNode();
2074
+ }
2075
+ };
2076
+ return /* @__PURE__ */ import_react26.default.createElement(Box, {
2077
+ shape,
2078
+ onAction: handleAction
2079
+ }, /* @__PURE__ */ import_react26.default.createElement(import_react_ui_canvas_editor19.TextBox, {
2080
+ value
2081
+ }));
2082
+ };
2083
+ var textShape = {
2084
+ type: "text",
2085
+ name: "Text",
2086
+ icon: "ph--article--regular",
2087
+ component: TextComponent,
2088
+ createShape: createText,
2089
+ getAnchors: (shape) => (0, import_react_ui_canvas_editor20.createAnchorMap)(shape, {
2090
+ [createAnchorId("input")]: {
2091
+ x: -1,
2092
+ y: 0
2093
+ }
2094
+ }),
2095
+ resizable: true
2096
+ };
2097
+ var InputSchema2 = (0, import_conductor24.createInputSchema)(import_conductor24.GptMessage);
2098
+ var OutputSchema2 = (0, import_conductor24.createOutputSchema)(import_echo_schema26.S.mutable(import_echo_schema26.S.Array(import_conductor24.GptMessage)));
2099
+ var ThreadShape = import_echo_schema26.S.extend(ComputeShape, import_echo_schema26.S.Struct({
2100
+ type: import_echo_schema26.S.Literal("thread")
2101
+ }));
2102
+ var createThread = (props) => createShape({
2103
+ type: "thread",
2104
+ size: {
2105
+ width: 384,
2106
+ height: 384
2107
+ },
2108
+ ...props
2109
+ });
2110
+ var ThreadComponent = ({ shape }) => {
2111
+ const items = [];
2112
+ const scrollRef = (0, import_react27.useRef)(null);
2113
+ (0, import_react27.useEffect)(() => {
2114
+ if (scrollRef.current) {
2115
+ scrollRef.current.scrollTop = scrollRef.current.scrollHeight;
2116
+ }
2117
+ }, [
2118
+ items
2119
+ ]);
2120
+ return /* @__PURE__ */ import_react27.default.createElement(Box, {
2121
+ shape
2122
+ }, /* @__PURE__ */ import_react27.default.createElement("div", {
2123
+ ref: scrollRef,
2124
+ className: "flex flex-col w-full overflow-y-scroll gap-2 p-2"
2125
+ }, [
2126
+ ...items
2127
+ ].map((item, i) => /* @__PURE__ */ import_react27.default.createElement(ThreadItem, {
2128
+ key: i,
2129
+ item
2130
+ }))));
2131
+ };
2132
+ var ThreadItem = ({ classNames, item }) => {
2133
+ if (typeof item !== "object") {
2134
+ return /* @__PURE__ */ import_react27.default.createElement("div", {
2135
+ className: (0, import_react_ui_theme5.mx)(classNames)
2136
+ }, item);
2137
+ }
2138
+ const { role, message } = item;
2139
+ return /* @__PURE__ */ import_react27.default.createElement("div", {
2140
+ className: (0, import_react_ui_theme5.mx)("flex", classNames, role === "user" && "justify-end")
2141
+ }, /* @__PURE__ */ import_react27.default.createElement("div", {
2142
+ className: (0, import_react_ui_theme5.mx)("block rounded-md p-1 px-2 text-sm", role === "user" ? "bg-blue-100 dark:bg-blue-800" : role === "system" ? "bg-red-100, dark:bg-red-800" : "whitespace-pre-wrap bg-neutral-50 dark:bg-neutral-800")
2143
+ }, message));
2144
+ };
2145
+ var threadShape = {
2146
+ type: "thread",
2147
+ name: "Thread",
2148
+ icon: "ph--chats-circle--regular",
2149
+ component: ThreadComponent,
2150
+ createShape: createThread,
2151
+ getAnchors: (shape) => createFunctionAnchors(shape, InputSchema2, OutputSchema2),
2152
+ resizable: true
2153
+ };
2154
+ var TextToImageShape = import_echo_schema27.S.extend(ComputeShape, import_echo_schema27.S.Struct({
2155
+ type: import_echo_schema27.S.Literal("text-to-image")
2156
+ }));
2157
+ var createTextToImage = (props) => createShape({
2158
+ type: "text-to-image",
2159
+ size: {
2160
+ width: 128,
2161
+ height: 64
2162
+ },
2163
+ ...props
2164
+ });
2165
+ var TextToImageComponent = ({ shape }) => {
2166
+ return /* @__PURE__ */ import_react28.default.createElement(Box, {
2167
+ shape
2168
+ });
2169
+ };
2170
+ var textToImageShape = {
2171
+ type: "text-to-image",
2172
+ name: "Image",
2173
+ icon: "ph--image--regular",
2174
+ component: TextToImageComponent,
2175
+ createShape: createTextToImage,
2176
+ getAnchors: (shape) => (0, import_react_ui_canvas_editor21.createAnchorMap)(shape, {
2177
+ [createAnchorId("output")]: {
2178
+ x: 1,
2179
+ y: 0
2180
+ }
2181
+ })
2182
+ };
2183
+ var TriggerShape = import_echo_schema28.S.extend(ComputeShape, import_echo_schema28.S.Struct({
2184
+ type: import_echo_schema28.S.Literal("trigger"),
2185
+ functionTrigger: import_echo_schema28.S.optional((0, import_echo_schema28.Ref)(import_functions.FunctionTrigger))
2186
+ }));
2187
+ var createTrigger = (props) => {
2188
+ const functionTrigger = (0, import_echo2.create)(import_functions.FunctionTrigger, {
2189
+ enabled: true,
2190
+ spec: createTriggerSpec(props.triggerKind ?? import_functions.TriggerKind.Email)
2191
+ });
2192
+ return createShape({
2193
+ type: "trigger",
2194
+ functionTrigger: (0, import_echo2.makeRef)(functionTrigger),
2195
+ size: {
2196
+ width: 192,
2197
+ height: getHeight(import_conductor25.EmailTriggerOutput)
2198
+ },
2199
+ ...props
2200
+ });
2201
+ };
2202
+ var TriggerComponent = ({ shape }) => {
2203
+ const functionTrigger = shape.functionTrigger?.target;
2204
+ (0, import_react29.useEffect)(() => {
2205
+ if (functionTrigger && !functionTrigger.spec) {
2206
+ functionTrigger.spec = createTriggerSpec(import_functions.TriggerKind.Email);
2207
+ }
2208
+ }, [
2209
+ functionTrigger,
2210
+ functionTrigger?.spec
2211
+ ]);
2212
+ (0, import_react29.useEffect)(() => {
2213
+ shape.size.height = getHeight(getOutputSchema(functionTrigger?.spec?.type ?? import_functions.TriggerKind.Email));
2214
+ }, [
2215
+ functionTrigger?.spec?.type
2216
+ ]);
2217
+ const setKind = (kind) => {
2218
+ if (functionTrigger?.spec?.type !== kind) {
2219
+ functionTrigger.spec = createTriggerSpec(kind);
2220
+ }
2221
+ };
2222
+ if (!functionTrigger?.spec) {
2223
+ return;
2224
+ }
2225
+ return /* @__PURE__ */ import_react29.default.createElement(FunctionBody, {
2226
+ shape,
2227
+ status: /* @__PURE__ */ import_react29.default.createElement(TriggerKindSelect, {
2228
+ value: functionTrigger.spec?.type,
2229
+ onValueChange: (kind) => setKind(kind)
2230
+ }),
2231
+ inputSchema: import_conductor25.VoidInput,
2232
+ outputSchema: getOutputSchema(functionTrigger.spec.type)
2233
+ });
2234
+ };
2235
+ var TriggerKindSelect = ({ value, onValueChange }) => {
2236
+ return /* @__PURE__ */ import_react29.default.createElement(import_react_ui8.Select.Root, {
2237
+ value,
2238
+ onValueChange
2239
+ }, /* @__PURE__ */ import_react29.default.createElement(import_react_ui8.Select.TriggerButton, {
2240
+ variant: "ghost",
2241
+ classNames: "w-full !px-0"
2242
+ }), /* @__PURE__ */ import_react29.default.createElement(import_react_ui8.Select.Portal, null, /* @__PURE__ */ import_react29.default.createElement(import_react_ui8.Select.Content, null, /* @__PURE__ */ import_react29.default.createElement(import_react_ui8.Select.ScrollUpButton, null), /* @__PURE__ */ import_react29.default.createElement(import_react_ui8.Select.Viewport, null, Object.values(import_functions.TriggerKind).map((type) => /* @__PURE__ */ import_react29.default.createElement(import_react_ui8.Select.Option, {
2243
+ key: type,
2244
+ value: type
2245
+ }, type))), /* @__PURE__ */ import_react29.default.createElement(import_react_ui8.Select.ScrollDownButton, null), /* @__PURE__ */ import_react29.default.createElement(import_react_ui8.Select.Arrow, null))));
2246
+ };
2247
+ var createTriggerSpec = (kind) => {
2248
+ switch (kind) {
2249
+ case import_functions.TriggerKind.Timer:
2250
+ return {
2251
+ type: import_functions.TriggerKind.Timer,
2252
+ cron: "0 0 * * *"
2253
+ };
2254
+ case import_functions.TriggerKind.Webhook:
2255
+ return {
2256
+ type: import_functions.TriggerKind.Webhook,
2257
+ method: "POST"
2258
+ };
2259
+ case import_functions.TriggerKind.Subscription:
2260
+ return {
2261
+ type: import_functions.TriggerKind.Subscription,
2262
+ filter: {}
2263
+ };
2264
+ case import_functions.TriggerKind.Email:
2265
+ return {
2266
+ type: import_functions.TriggerKind.Email
2267
+ };
2268
+ }
2269
+ };
2270
+ var getOutputSchema = (kind) => {
2271
+ const kindToSchema = {
2272
+ [import_functions.TriggerKind.Email]: import_conductor25.EmailTriggerOutput,
2273
+ [import_functions.TriggerKind.Subscription]: import_conductor25.SubscriptionTriggerOutput,
2274
+ [import_functions.TriggerKind.Timer]: import_conductor25.TimerTriggerOutput,
2275
+ [import_functions.TriggerKind.Webhook]: import_conductor25.WebhookTriggerOutput
2276
+ };
2277
+ return kindToSchema[kind];
2278
+ };
2279
+ var triggerShape = {
2280
+ type: "trigger",
2281
+ name: "Trigger",
2282
+ icon: "ph--lightning--regular",
2283
+ component: TriggerComponent,
2284
+ createShape: createTrigger,
2285
+ getAnchors: (shape) => createFunctionAnchors(shape, import_conductor25.VoidInput, getOutputSchema(shape.functionTrigger?.target?.spec?.type ?? import_functions.TriggerKind.Email))
2286
+ };
2287
+ var __dxlog_file7 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-canvas-compute/src/shapes/GptRealtime.tsx";
2288
+ var GptRealtimeShape = import_echo_schema29.S.extend(ComputeShape, import_echo_schema29.S.Struct({
2289
+ type: import_echo_schema29.S.Literal("gpt-realtime")
2290
+ }));
2291
+ var createGptRealtime = (props) => createShape({
2292
+ type: "gpt-realtime",
2293
+ size: {
2294
+ width: 256,
2295
+ height: 256
2296
+ },
2297
+ ...props
2298
+ });
2299
+ var GptRealtimeComponent = ({ shape }) => {
2300
+ const [isLive, setIsLive] = (0, import_react30.useState)(false);
2301
+ const [isReady, setIsReady] = (0, import_react30.useState)(false);
2302
+ const config = (0, import_react_client.useConfig)();
2303
+ const start = async () => {
2304
+ setIsLive(true);
2305
+ try {
2306
+ const peerConnection = new RTCPeerConnection();
2307
+ peerConnection.ontrack = (event) => {
2308
+ const audioElement = document.createElement("audio");
2309
+ audioElement.srcObject = event.streams[0];
2310
+ audioElement.autoplay = true;
2311
+ audioElement.controls = false;
2312
+ audioElement.style.display = "none";
2313
+ document.body.appendChild(audioElement);
2314
+ setIsReady(true);
2315
+ };
2316
+ const stream = await navigator.mediaDevices.getUserMedia({
2317
+ audio: true
2318
+ });
2319
+ stream.getTracks().forEach((track) => peerConnection.addTransceiver(track, {
2320
+ direction: "sendrecv"
2321
+ }));
2322
+ const offer = await peerConnection.createOffer();
2323
+ await peerConnection.setLocalDescription(offer);
2324
+ const aiServiceUrl = new URL("/rtc-connect", config.values.runtime?.services?.ai?.server ?? DEFAULT_AI_SERVICE_URL);
2325
+ const response = await fetch(aiServiceUrl, {
2326
+ method: "POST",
2327
+ body: offer.sdp,
2328
+ headers: {
2329
+ "Content-Type": "application/sdp"
2330
+ }
2331
+ });
2332
+ const answer = await response.text();
2333
+ await peerConnection.setRemoteDescription({
2334
+ sdp: answer,
2335
+ type: "answer"
2336
+ });
2337
+ const dataChannel = peerConnection.createDataChannel("response");
2338
+ const configureData = () => {
2339
+ import_log2.log.info("Configuring data channel", void 0, {
2340
+ F: __dxlog_file7,
2341
+ L: 87,
2342
+ S: void 0,
2343
+ C: (f, a) => f(...a)
2344
+ });
2345
+ const event = {
2346
+ type: "session.update",
2347
+ session: {
2348
+ modalities: [
2349
+ "text",
2350
+ "audio"
2351
+ ],
2352
+ // Provide the tools. Note they match the keys in the `fns` object above
2353
+ tools: []
2354
+ }
2355
+ };
2356
+ dataChannel.send(JSON.stringify(event));
2357
+ };
2358
+ dataChannel.addEventListener("open", (ev) => {
2359
+ import_log2.log.info("Opening data channel", {
2360
+ ev
2361
+ }, {
2362
+ F: __dxlog_file7,
2363
+ L: 100,
2364
+ S: void 0,
2365
+ C: (f, a) => f(...a)
2366
+ });
2367
+ configureData();
2368
+ });
2369
+ dataChannel.addEventListener("message", async (ev) => {
2370
+ const msg = JSON.parse(ev.data);
2371
+ if (msg.type === "response.function_call_arguments.done") {
2372
+ }
2373
+ });
2374
+ } catch (error) {
2375
+ import_log2.log.error("Error in realtime session:", {
2376
+ error
2377
+ }, {
2378
+ F: __dxlog_file7,
2379
+ L: 140,
2380
+ S: void 0,
2381
+ C: (f, a) => f(...a)
2382
+ });
2383
+ throw error;
2384
+ }
2385
+ };
2386
+ return /* @__PURE__ */ import_react30.default.createElement("div", {
2387
+ className: "flex w-full justify-center items-center"
2388
+ }, /* @__PURE__ */ import_react30.default.createElement(import_react_ui9.Icon, {
2389
+ icon: isReady ? "ph--waveform--regular" : isLive ? "ph--pulse--regular" : "ph--play--regular",
2390
+ size: 16,
2391
+ classNames: !isLive && "cursor-pointer",
2392
+ onClick: start
2393
+ }));
2394
+ };
2395
+ var gptRealtimeShape = {
2396
+ type: "gpt-realtime",
2397
+ name: "GPT Realtime",
2398
+ icon: "ph--pulse--regular",
2399
+ component: GptRealtimeComponent,
2400
+ createShape: createGptRealtime,
2401
+ // TODO(dmaretskyi): Can we fetch the schema dynamically?
2402
+ getAnchors: (shape) => createFunctionAnchors(shape, import_echo_schema29.S.Struct({
2403
+ audio: import_echo_schema29.S.Any
2404
+ }), import_echo_schema29.S.Struct({})),
2405
+ resizable: true
2406
+ };
2407
+ var DEFAULT_AI_SERVICE_URL = "http://localhost:8788";
2408
+ var computeShapes = [
2409
+ {
2410
+ title: "Inputs",
2411
+ shapes: [
2412
+ //
2413
+ constantShape,
2414
+ templateShape,
2415
+ chatShape,
2416
+ switchShape,
2417
+ audioShape,
2418
+ triggerShape,
2419
+ randomShape
2420
+ ]
2421
+ },
2422
+ {
2423
+ title: "Transform",
2424
+ shapes: [
2425
+ //
2426
+ gptShape,
2427
+ gptRealtimeShape,
2428
+ functionShape,
2429
+ databaseShape,
2430
+ textToImageShape,
2431
+ appendShape
2432
+ ]
2433
+ },
2434
+ {
2435
+ title: "Operations",
2436
+ shapes: [
2437
+ //
2438
+ ifShape,
2439
+ ifElseShape,
2440
+ andShape,
2441
+ orShape,
2442
+ notShape,
2443
+ reducerShape,
2444
+ jsonTransformShape
2445
+ ]
2446
+ },
2447
+ {
2448
+ title: "Outputs",
2449
+ shapes: [
2450
+ //
2451
+ jsonShape,
2452
+ queueShape,
2453
+ threadShape,
2454
+ textShape,
2455
+ surfaceShape,
2456
+ beaconShape,
2457
+ scopeShape
2458
+ ]
2459
+ },
2460
+ {
2461
+ title: "Misc",
2462
+ shapes: [
2463
+ //
2464
+ import_react_ui_canvas_editor.noteShape
2465
+ ]
2466
+ }
2467
+ ];
2468
+ var ComputeShapeLayout = class extends import_react_ui_canvas_editor22.ShapeLayout {
2469
+ constructor(_controller, registry2) {
2470
+ super(registry2);
2471
+ this._controller = _controller;
2472
+ }
2473
+ // TODO(burdon): Doesn't update.
2474
+ getAnchors(shape) {
2475
+ const shapeDef = this._registry.getShapeDef(shape.type);
2476
+ let anchors = shapeDef?.getAnchors?.(shape) ?? {};
2477
+ if (shape.node) {
2478
+ const node = this._controller.graph.getNode(shape.node);
2479
+ if (node.inputSchema || node.outputSchema) {
2480
+ const inputSchema = node.inputSchema ? (0, import_echo_schema30.toEffectSchema)(node.inputSchema) : import_conductor26.DefaultInput;
2481
+ const outputSchema = node.outputSchema ? (0, import_echo_schema30.toEffectSchema)(node.outputSchema) : import_conductor26.DefaultOutput;
2482
+ anchors = createFunctionAnchors(shape, inputSchema, outputSchema);
2483
+ }
2484
+ }
2485
+ return anchors;
2486
+ }
2487
+ };
2488
+ // Annotate the CommonJS export names for ESM import in node:
2489
+ 0 && (module.exports = {
2490
+ AndShape,
2491
+ AppendComponent,
2492
+ AppendShape,
2493
+ AudioComponent,
2494
+ AudioShape,
2495
+ BeaconComponent,
2496
+ BeaconShape,
2497
+ Box,
2498
+ ChatShape,
2499
+ ComputeContext,
2500
+ ComputeGraphController,
2501
+ ComputeShape,
2502
+ ComputeShapeLayout,
2503
+ ConstantComponent,
2504
+ ConstantShape,
2505
+ DatabaseComponent,
2506
+ DatabaseShape,
2507
+ FunctionBody,
2508
+ FunctionComponent,
2509
+ FunctionShape,
2510
+ GptComponent,
2511
+ GptRealtimeComponent,
2512
+ GptRealtimeShape,
2513
+ GptShape,
2514
+ IfComponent,
2515
+ IfElseComponent,
2516
+ IfElseShape,
2517
+ IfShape,
2518
+ InvalidStateError,
2519
+ JsonComponent,
2520
+ JsonShape,
2521
+ JsonTransformComponent,
2522
+ JsonTransformShape,
2523
+ NotShape,
2524
+ OrShape,
2525
+ QueueComponent,
2526
+ QueueItem,
2527
+ QueueShape,
2528
+ RandomComponent,
2529
+ RandomShape,
2530
+ ReducerComponent,
2531
+ ReducerShape,
2532
+ ScopeComponent,
2533
+ ScopeShape,
2534
+ SurfaceComponent,
2535
+ SurfaceShape,
2536
+ SwitchComponent,
2537
+ SwitchShape,
2538
+ TableComponent,
2539
+ TableShape,
2540
+ TemplateShape,
2541
+ TextComponent,
2542
+ TextInputComponent,
2543
+ TextShape,
2544
+ TextToImageComponent,
2545
+ TextToImageShape,
2546
+ ThreadComponent,
2547
+ ThreadItem,
2548
+ ThreadShape,
2549
+ TriggerComponent,
2550
+ TriggerShape,
2551
+ TypeSelect,
2552
+ andShape,
2553
+ appendShape,
2554
+ audioShape,
2555
+ beaconShape,
2556
+ chatShape,
2557
+ computeShapes,
2558
+ constantShape,
2559
+ createAnchorId,
2560
+ createAnd,
2561
+ createAppend,
2562
+ createAudio,
2563
+ createBeacon,
2564
+ createChat,
2565
+ createComputeGraph,
2566
+ createComputeGraphController,
2567
+ createComputeNode,
2568
+ createConstant,
2569
+ createDatabase,
2570
+ createFunction,
2571
+ createFunctionAnchors,
2572
+ createGpt,
2573
+ createGptRealtime,
2574
+ createIf,
2575
+ createIfElse,
2576
+ createJson,
2577
+ createJsonTransform,
2578
+ createNot,
2579
+ createOr,
2580
+ createQueue,
2581
+ createRandom,
2582
+ createReducer,
2583
+ createScope,
2584
+ createShape,
2585
+ createSurface,
2586
+ createSwitch,
2587
+ createTable,
2588
+ createTemplate,
2589
+ createText,
2590
+ createTextToImage,
2591
+ createThread,
2592
+ createTrigger,
2593
+ databaseShape,
2594
+ footerHeight,
2595
+ functionShape,
2596
+ getHeight,
2597
+ getProperties,
2598
+ gptRealtimeShape,
2599
+ gptShape,
2600
+ headerHeight,
2601
+ ifElseShape,
2602
+ ifShape,
2603
+ isValidComputeNode,
2604
+ jsonShape,
2605
+ jsonTransformShape,
2606
+ mapEdge,
2607
+ notShape,
2608
+ orShape,
2609
+ parseAnchorId,
2610
+ queueShape,
2611
+ randomShape,
2612
+ reducerShape,
2613
+ resolveComputeNode,
2614
+ scopeShape,
2615
+ surfaceShape,
2616
+ switchShape,
2617
+ tableShape,
2618
+ templateShape,
2619
+ textShape,
2620
+ textToImageShape,
2621
+ threadShape,
2622
+ triggerShape,
2623
+ useComputeContext,
2624
+ useComputeNodeState,
2625
+ useGraphMonitor
2626
+ });
2627
+ //# sourceMappingURL=index.cjs.map