rax-flow 0.1.5 → 0.1.7

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 (223) hide show
  1. package/LICENSE +21 -0
  2. package/dist/bin.js +27 -3
  3. package/dist/bin.js.map +1 -1
  4. package/dist/hub/__tests__/commands.test.d.ts.map +1 -0
  5. package/dist/hub/__tests__/commands.test.js +72 -0
  6. package/dist/hub/__tests__/commands.test.js.map +1 -0
  7. package/dist/hub/__tests__/history.test.d.ts.map +1 -0
  8. package/dist/hub/__tests__/history.test.js +119 -0
  9. package/dist/hub/__tests__/history.test.js.map +1 -0
  10. package/dist/hub/__tests__/parser.test.d.ts.map +1 -0
  11. package/dist/hub/__tests__/parser.test.js +92 -0
  12. package/dist/hub/__tests__/parser.test.js.map +1 -0
  13. package/dist/hub/chat/ChatApp.d.ts +2 -0
  14. package/dist/hub/chat/ChatApp.d.ts.map +1 -0
  15. package/dist/hub/chat/ChatApp.js +146 -0
  16. package/dist/hub/chat/ChatApp.js.map +1 -0
  17. package/dist/hub/chat/components/ChatInput.d.ts +9 -0
  18. package/dist/hub/chat/components/ChatInput.d.ts.map +1 -0
  19. package/dist/hub/chat/components/ChatInput.js +19 -0
  20. package/dist/hub/chat/components/ChatInput.js.map +1 -0
  21. package/dist/hub/chat/components/MessageList.d.ts +7 -0
  22. package/dist/hub/chat/components/MessageList.d.ts.map +1 -0
  23. package/dist/hub/chat/components/MessageList.js +6 -0
  24. package/dist/hub/chat/components/MessageList.js.map +1 -0
  25. package/dist/hub/chat/context.d.ts.map +1 -0
  26. package/dist/hub/chat/context.js +42 -0
  27. package/dist/hub/chat/context.js.map +1 -0
  28. package/dist/hub/chat/hooks/useChatHistory.d.ts +7 -0
  29. package/dist/hub/chat/hooks/useChatHistory.d.ts.map +1 -0
  30. package/dist/hub/chat/hooks/useChatHistory.js +31 -0
  31. package/dist/hub/chat/hooks/useChatHistory.js.map +1 -0
  32. package/dist/hub/chat/index.d.ts.map +1 -0
  33. package/dist/hub/chat/index.js +7 -0
  34. package/dist/hub/chat/index.js.map +1 -0
  35. package/dist/hub/chat/intent-parser.d.ts.map +1 -0
  36. package/dist/hub/chat/intent-parser.js +48 -0
  37. package/dist/hub/chat/intent-parser.js.map +1 -0
  38. package/dist/hub/chat/types.d.ts.map +1 -0
  39. package/dist/hub/chat/types.js +2 -0
  40. package/dist/hub/chat/types.js.map +1 -0
  41. package/dist/hub/commands/agents.d.ts.map +1 -0
  42. package/dist/hub/commands/agents.js +36 -0
  43. package/dist/hub/commands/agents.js.map +1 -0
  44. package/dist/hub/commands/index.d.ts.map +1 -0
  45. package/dist/hub/commands/index.js +120 -0
  46. package/dist/hub/commands/index.js.map +1 -0
  47. package/dist/hub/commands/logs.d.ts.map +1 -0
  48. package/dist/hub/commands/logs.js +53 -0
  49. package/dist/hub/commands/logs.js.map +1 -0
  50. package/dist/hub/commands/memory.d.ts.map +1 -0
  51. package/dist/hub/commands/memory.js +40 -0
  52. package/dist/hub/commands/memory.js.map +1 -0
  53. package/dist/hub/commands/metrics.d.ts.map +1 -0
  54. package/dist/hub/commands/metrics.js +35 -0
  55. package/dist/hub/commands/metrics.js.map +1 -0
  56. package/dist/hub/commands/providers.d.ts.map +1 -0
  57. package/dist/hub/commands/providers.js +26 -0
  58. package/dist/hub/commands/providers.js.map +1 -0
  59. package/dist/hub/commands/run.d.ts.map +1 -0
  60. package/dist/hub/commands/run.js +31 -0
  61. package/dist/hub/commands/run.js.map +1 -0
  62. package/dist/hub/commands/status.d.ts.map +1 -0
  63. package/dist/hub/commands/status.js +61 -0
  64. package/dist/hub/commands/status.js.map +1 -0
  65. package/dist/hub/commands/workflows.d.ts.map +1 -0
  66. package/dist/hub/commands/workflows.js +45 -0
  67. package/dist/hub/commands/workflows.js.map +1 -0
  68. package/dist/hub/config-loader.d.ts.map +1 -0
  69. package/dist/hub/config-loader.js +27 -0
  70. package/dist/hub/config-loader.js.map +1 -0
  71. package/dist/hub/event-listener.d.ts.map +1 -0
  72. package/dist/hub/event-listener.js +8 -0
  73. package/dist/hub/event-listener.js.map +1 -0
  74. package/dist/hub/history.d.ts.map +1 -0
  75. package/dist/hub/history.js +59 -0
  76. package/dist/hub/history.js.map +1 -0
  77. package/dist/hub/index.d.ts.map +1 -0
  78. package/dist/hub/index.js +102 -0
  79. package/dist/hub/index.js.map +1 -0
  80. package/dist/hub/parser.d.ts.map +1 -0
  81. package/dist/hub/parser.js +98 -0
  82. package/dist/hub/parser.js.map +1 -0
  83. package/dist/hub/styles/borders.d.ts.map +1 -0
  84. package/dist/hub/styles/borders.js +64 -0
  85. package/dist/hub/styles/borders.js.map +1 -0
  86. package/dist/hub/styles/colors.d.ts.map +1 -0
  87. package/dist/hub/styles/colors.js +115 -0
  88. package/dist/hub/styles/colors.js.map +1 -0
  89. package/dist/hub/styles/typography.d.ts.map +1 -0
  90. package/dist/hub/styles/typography.js +60 -0
  91. package/dist/hub/styles/typography.js.map +1 -0
  92. package/dist/hub/tui/App.d.ts +2 -0
  93. package/dist/hub/tui/App.d.ts.map +1 -0
  94. package/dist/hub/tui/App.js +53 -0
  95. package/dist/hub/tui/App.js.map +1 -0
  96. package/dist/hub/tui/components/AgentQueue.d.ts +6 -0
  97. package/dist/hub/tui/components/AgentQueue.d.ts.map +1 -0
  98. package/dist/hub/tui/components/AgentQueue.js +20 -0
  99. package/dist/hub/tui/components/AgentQueue.js.map +1 -0
  100. package/dist/hub/tui/components/DAGPanel.d.ts +16 -0
  101. package/dist/hub/tui/components/DAGPanel.d.ts.map +1 -0
  102. package/dist/hub/tui/components/DAGPanel.js +51 -0
  103. package/dist/hub/tui/components/DAGPanel.js.map +1 -0
  104. package/dist/hub/tui/components/Header.d.ts +7 -0
  105. package/dist/hub/tui/components/Header.d.ts.map +1 -0
  106. package/dist/hub/tui/components/Header.js +17 -0
  107. package/dist/hub/tui/components/Header.js.map +1 -0
  108. package/dist/hub/tui/components/LogsPanel.d.ts +6 -0
  109. package/dist/hub/tui/components/LogsPanel.d.ts.map +1 -0
  110. package/dist/hub/tui/components/LogsPanel.js +26 -0
  111. package/dist/hub/tui/components/LogsPanel.js.map +1 -0
  112. package/dist/hub/tui/components/StatusBar.d.ts +8 -0
  113. package/dist/hub/tui/components/StatusBar.d.ts.map +1 -0
  114. package/dist/hub/tui/components/StatusBar.js +7 -0
  115. package/dist/hub/tui/components/StatusBar.js.map +1 -0
  116. package/dist/hub/tui/hooks/useEvents.d.ts +2 -0
  117. package/dist/hub/tui/hooks/useEvents.d.ts.map +1 -0
  118. package/dist/hub/tui/hooks/useEvents.js +13 -0
  119. package/dist/hub/tui/hooks/useEvents.js.map +1 -0
  120. package/dist/hub/tui/index.d.ts.map +1 -0
  121. package/dist/hub/tui/index.js +7 -0
  122. package/dist/hub/tui/index.js.map +1 -0
  123. package/dist/hub/tui/types.d.ts.map +1 -0
  124. package/dist/hub/tui/types.js +2 -0
  125. package/dist/hub/tui/types.js.map +1 -0
  126. package/dist/hub/types.d.ts.map +1 -0
  127. package/dist/hub/types.js +2 -0
  128. package/dist/hub/types.js.map +1 -0
  129. package/dist/tui/App.d.ts +2 -0
  130. package/dist/tui/App.d.ts.map +1 -0
  131. package/dist/tui/App.js +31 -0
  132. package/dist/tui/App.js.map +1 -0
  133. package/dist/tui/components/ChatPanel.d.ts +14 -0
  134. package/dist/tui/components/ChatPanel.d.ts.map +1 -0
  135. package/dist/tui/components/ChatPanel.js +30 -0
  136. package/dist/tui/components/ChatPanel.js.map +1 -0
  137. package/dist/tui/components/Header.d.ts +9 -0
  138. package/dist/tui/components/Header.d.ts.map +1 -0
  139. package/dist/tui/components/Header.js +17 -0
  140. package/dist/tui/components/Header.js.map +1 -0
  141. package/dist/tui/components/InputBar.d.ts +8 -0
  142. package/dist/tui/components/InputBar.d.ts.map +1 -0
  143. package/dist/tui/components/InputBar.js +16 -0
  144. package/dist/tui/components/InputBar.js.map +1 -0
  145. package/dist/tui/components/StatusPanel.d.ts +20 -0
  146. package/dist/tui/components/StatusPanel.d.ts.map +1 -0
  147. package/dist/tui/components/StatusPanel.js +20 -0
  148. package/dist/tui/components/StatusPanel.js.map +1 -0
  149. package/dist/tui/hooks/useAppState.d.ts +38 -0
  150. package/dist/tui/hooks/useAppState.d.ts.map +1 -0
  151. package/dist/tui/hooks/useAppState.js +127 -0
  152. package/dist/tui/hooks/useAppState.js.map +1 -0
  153. package/dist/tui/index.d.ts +3 -0
  154. package/dist/tui/index.d.ts.map +1 -0
  155. package/dist/tui/index.js +8 -0
  156. package/dist/tui/index.js.map +1 -0
  157. package/package.json +17 -11
  158. package/src/bin.ts +29 -3
  159. package/src/hub/__tests__/commands.test.ts +84 -0
  160. package/src/hub/__tests__/history.test.ts +137 -0
  161. package/src/hub/__tests__/parser.test.ts +105 -0
  162. package/src/hub/commands/agents.ts +53 -0
  163. package/src/hub/commands/index.ts +137 -0
  164. package/src/hub/commands/logs.ts +70 -0
  165. package/src/hub/commands/memory.ts +47 -0
  166. package/src/hub/commands/metrics.ts +49 -0
  167. package/src/hub/commands/providers.ts +39 -0
  168. package/src/hub/commands/run.ts +37 -0
  169. package/src/hub/commands/status.ts +69 -0
  170. package/src/hub/commands/workflows.ts +64 -0
  171. package/src/hub/config-loader.ts +37 -0
  172. package/src/hub/event-listener.ts +13 -0
  173. package/src/hub/history.ts +66 -0
  174. package/src/hub/index.ts +120 -0
  175. package/src/hub/parser.ts +107 -0
  176. package/src/hub/styles/borders.ts +74 -0
  177. package/src/hub/styles/colors.ts +129 -0
  178. package/src/hub/styles/typography.ts +68 -0
  179. package/src/hub/types.ts +31 -0
  180. package/src/tui/App.tsx +61 -0
  181. package/src/tui/components/ChatPanel.tsx +79 -0
  182. package/src/tui/components/Header.tsx +53 -0
  183. package/src/tui/components/InputBar.tsx +55 -0
  184. package/src/tui/components/StatusPanel.tsx +85 -0
  185. package/src/tui/hooks/useAppState.ts +168 -0
  186. package/src/tui/index.ts +9 -0
  187. package/tsconfig.json +19 -3
  188. package/tsconfig.tsbuildinfo +1 -0
  189. package/dist/benchmark.d.ts +0 -10
  190. package/dist/bin.d.ts +0 -3
  191. package/dist/bootstrap.d.ts +0 -8
  192. package/dist/bridge-adapter-templates.d.ts +0 -4
  193. package/dist/bridge-test.d.ts +0 -7
  194. package/dist/dashboard.d.ts +0 -4
  195. package/dist/doctor.d.ts +0 -6
  196. package/dist/evolve.d.ts +0 -7
  197. package/dist/host-init-templates.d.ts +0 -16
  198. package/dist/index.d.ts +0 -11
  199. package/dist/init-host.d.ts +0 -10
  200. package/dist/install.d.ts +0 -8
  201. package/dist/run.d.ts +0 -16
  202. package/dist/styles.d.ts +0 -12
  203. package/dist/vendor-manifests.d.ts +0 -22
  204. package/package/dashboard/index.html +0 -420
  205. package/package/package.json +0 -28
  206. package/package/src/benchmark.ts +0 -156
  207. package/package/src/bin.ts +0 -127
  208. package/package/src/bootstrap.ts +0 -36
  209. package/package/src/bridge-adapter-templates.ts +0 -181
  210. package/package/src/bridge-test.ts +0 -107
  211. package/package/src/dashboard.ts +0 -51
  212. package/package/src/doctor.ts +0 -92
  213. package/package/src/evolve.ts +0 -74
  214. package/package/src/host-init-templates.ts +0 -134
  215. package/package/src/index.ts +0 -10
  216. package/package/src/init-host.ts +0 -285
  217. package/package/src/install.ts +0 -118
  218. package/package/src/run.ts +0 -317
  219. package/package/src/styles.ts +0 -12
  220. package/package/src/vendor-manifests.ts +0 -113
  221. package/package/src/ws-relay.ts +0 -156
  222. package/package/tsconfig.json +0 -12
  223. package/rax-flow-0.1.1.tgz +0 -0
@@ -1,156 +0,0 @@
1
- import { WebSocketServer, WebSocket } from "ws";
2
- import { RuntimeEventBus } from "rax-flow-core";
3
- import { readdir, readFile, mkdir, writeFile } from "node:fs/promises";
4
- import path from "node:path";
5
-
6
- export class WebSocketRelay {
7
- private wss: WebSocketServer | null = null;
8
- private clients = new Set<WebSocket>();
9
- private bus: RuntimeEventBus | null = null;
10
-
11
- constructor(private port: number = 3002) { }
12
-
13
- public start(eventBus: RuntimeEventBus): void {
14
- this.bus = eventBus;
15
- try {
16
- this.wss = new WebSocketServer({ port: this.port });
17
- console.log(`\n[UI] 📡 WebSocket relay started on ws://localhost:${this.port}`);
18
-
19
- this.wss.on("connection", (ws) => {
20
- this.clients.add(ws);
21
- ws.send(JSON.stringify({ type: "HELLO", timestamp: Date.now() }));
22
-
23
- ws.on("close", () => {
24
- this.clients.delete(ws);
25
- });
26
-
27
- ws.on("message", async (data) => {
28
- try {
29
- const message = JSON.parse(data.toString());
30
- const historyDir = path.join(process.cwd(), ".rax-flow", "history");
31
-
32
- if (message.type === "GET_HISTORY") {
33
- try {
34
- const files = await readdir(historyDir);
35
- const runs = await Promise.all(
36
- files.filter(f => f.endsWith(".json")).map(async f => {
37
- const content = await readFile(path.join(historyDir, f), "utf8");
38
- const parsed = JSON.parse(content);
39
- return {
40
- taskId: parsed.taskId,
41
- timestamp: parsed.timestamp,
42
- prompt: parsed.prompt,
43
- success: parsed.result.success,
44
- costUsd: parsed.metrics.totalCostUsd
45
- };
46
- })
47
- );
48
- ws.send(JSON.stringify({ type: "HISTORY_LIST", runs: runs.sort((a, b) => b.timestamp - a.timestamp) }));
49
- } catch {
50
- ws.send(JSON.stringify({ type: "HISTORY_LIST", runs: [] }));
51
- }
52
- }
53
-
54
- else if (message.type === "LOAD_RUN") {
55
- try {
56
- const file = path.join(historyDir, `${message.taskId}.json`);
57
- const content = await readFile(file, "utf8");
58
- ws.send(JSON.stringify({ type: "RUN_DATA", data: JSON.parse(content) }));
59
- } catch (err) {
60
- ws.send(JSON.stringify({ type: "ERROR", message: "Run not found" }));
61
- }
62
- }
63
-
64
- else if (message.type === "LIST_WORKFLOWS") {
65
- const workflowsDir = path.join(process.cwd(), ".rax-flow", "workflows");
66
- try {
67
- const files = await readdir(workflowsDir);
68
- const list = files.filter(f => f.endsWith(".json")).map(f => ({
69
- id: f.replace(".json", ""),
70
- filename: f
71
- }));
72
- ws.send(JSON.stringify({ type: "WORKFLOW_LIST", workflows: list }));
73
- } catch {
74
- ws.send(JSON.stringify({ type: "WORKFLOW_LIST", workflows: [] }));
75
- }
76
- }
77
-
78
- else if (message.type === "RESOLVE_APPROVAL") {
79
- this.bus?.emit({
80
- type: "INTERNAL_RESOLVE_APPROVAL",
81
- taskId: message.taskId,
82
- nodeId: message.nodeId,
83
- approved: message.approved,
84
- feedback: message.feedback
85
- } as any);
86
- }
87
-
88
- else if (message.type === "SAVE_WORKFLOW") {
89
- try {
90
- const workflowsDir = path.join(process.cwd(), ".rax-flow", "workflows");
91
- await mkdir(workflowsDir, { recursive: true });
92
- const file = path.join(workflowsDir, `${message.id}.json`);
93
- const data = {
94
- id: message.id,
95
- nodes: message.nodes,
96
- edges: message.edges
97
- };
98
- await writeFile(file, JSON.stringify(data, null, 2));
99
- ws.send(JSON.stringify({ type: "INFO", message: `Workflow ${message.id} saved.` }));
100
- this.broadcast({ type: "REFRESH_WORKFLOWS" });
101
- } catch (err) {
102
- ws.send(JSON.stringify({ type: "ERROR", message: "Failed to save workflow" }));
103
- }
104
- }
105
-
106
- else if (message.type === "DELETE_WORKFLOW") {
107
- try {
108
- const url = path.join(process.cwd(), ".rax-flow", "workflows", `${message.id}.json`);
109
- const { unlink } = await import("node:fs/promises");
110
- await unlink(url);
111
- this.broadcast({ type: "REFRESH_WORKFLOWS" });
112
- } catch (err) {
113
- ws.send(JSON.stringify({ type: "ERROR", message: "Failed to delete workflow" }));
114
- }
115
- }
116
- } catch (e) {
117
- console.error("[WS] Message parse error:", e);
118
- }
119
- });
120
-
121
- ws.on("error", () => {
122
- this.clients.delete(ws);
123
- });
124
- });
125
-
126
- this.wss.on("error", (err) => {
127
- console.error(`[UI] WebSocket server error: ${err.message}`);
128
- });
129
-
130
- eventBus.onEvent((event) => {
131
- this.broadcast(event);
132
- });
133
- } catch (err) {
134
- console.error(`[UI] Failed to start WebSocket server: ${err}`);
135
- }
136
- }
137
-
138
- private broadcast(event: unknown): void {
139
- if (!this.wss) return;
140
- const payload = JSON.stringify(event);
141
- for (const client of this.clients) {
142
- if (client.readyState === WebSocket.OPEN) {
143
- client.send(payload);
144
- }
145
- }
146
- }
147
-
148
- public stop(): void {
149
- if (this.wss) {
150
- this.wss.close();
151
- this.wss = null;
152
- this.clients.clear();
153
- console.log("[UI] 📡 WebSocket relay stopped.");
154
- }
155
- }
156
- }
@@ -1,12 +0,0 @@
1
- {
2
- "extends": "../../tsconfig.base.json",
3
- "compilerOptions": {
4
- "rootDir": "src",
5
- "outDir": "dist",
6
- "composite": true,
7
- "declaration": true,
8
- "declarationMap": true
9
- },
10
- "include": ["src/**/*.ts"],
11
- "references": [{ "path": "../core" }, { "path": "../agents" }, { "path": "../providers" }]
12
- }
Binary file