@ranker/raxflow 0.2.1 → 0.2.3

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 (214) hide show
  1. package/dist/benchmark.d.ts +10 -0
  2. package/dist/bin.d.ts +3 -0
  3. package/dist/bootstrap.d.ts +8 -0
  4. package/dist/bridge-adapter-templates.d.ts +4 -0
  5. package/dist/bridge-test.d.ts +7 -0
  6. package/dist/dashboard.d.ts +4 -0
  7. package/dist/doctor.d.ts +6 -0
  8. package/dist/evolve.d.ts +7 -0
  9. package/dist/host-init-templates.d.ts +16 -0
  10. package/dist/hub/__tests__/commands.test.d.ts +2 -0
  11. package/dist/hub/__tests__/history.test.d.ts +2 -0
  12. package/dist/hub/__tests__/parser.test.d.ts +2 -0
  13. package/dist/hub/commands/agents.d.ts +3 -0
  14. package/dist/hub/commands/index.d.ts +4 -0
  15. package/dist/hub/commands/logs.d.ts +3 -0
  16. package/dist/hub/commands/memory.d.ts +3 -0
  17. package/dist/hub/commands/metrics.d.ts +3 -0
  18. package/dist/hub/commands/providers.d.ts +3 -0
  19. package/dist/hub/commands/run.d.ts +3 -0
  20. package/dist/hub/commands/status.d.ts +3 -0
  21. package/dist/hub/commands/workflows.d.ts +3 -0
  22. package/dist/hub/config-loader.d.ts +4 -0
  23. package/dist/hub/history.d.ts +13 -0
  24. package/dist/hub/index.d.ts +4 -0
  25. package/dist/hub/parser.d.ts +4 -0
  26. package/dist/hub/styles/borders.d.ts +23 -0
  27. package/dist/hub/styles/colors.d.ts +63 -0
  28. package/dist/hub/styles/typography.d.ts +34 -0
  29. package/dist/hub/types.d.ts +27 -0
  30. package/{src/index.ts → dist/index.d.ts} +1 -0
  31. package/dist/init-host.d.ts +10 -0
  32. package/dist/install.d.ts +8 -0
  33. package/dist/run.d.ts +16 -0
  34. package/dist/setup/components/ProviderSelector.d.ts.map +1 -1
  35. package/dist/setup/components/ProviderSelector.js +8 -7
  36. package/dist/setup/components/ProviderSelector.js.map +1 -1
  37. package/dist/styles.d.ts +12 -0
  38. package/dist/tui/App.d.ts.map +1 -1
  39. package/dist/tui/App.js +7 -2
  40. package/dist/tui/App.js.map +1 -1
  41. package/dist/tui/components/ChatPanel.d.ts +1 -0
  42. package/dist/tui/components/ChatPanel.d.ts.map +1 -1
  43. package/dist/tui/components/ChatPanel.js +4 -3
  44. package/dist/tui/components/ChatPanel.js.map +1 -1
  45. package/dist/tui/components/DAGPanel.d.ts +1 -0
  46. package/dist/tui/components/DAGPanel.d.ts.map +1 -1
  47. package/dist/tui/components/DAGPanel.js +4 -3
  48. package/dist/tui/components/DAGPanel.js.map +1 -1
  49. package/dist/tui/components/Header.d.ts.map +1 -1
  50. package/dist/tui/components/Header.js +1 -1
  51. package/dist/tui/components/Header.js.map +1 -1
  52. package/dist/tui/components/InputBar.d.ts.map +1 -1
  53. package/dist/tui/components/InputBar.js +1 -1
  54. package/dist/tui/components/InputBar.js.map +1 -1
  55. package/dist/tui/components/LogsPanel.d.ts +1 -0
  56. package/dist/tui/components/LogsPanel.d.ts.map +1 -1
  57. package/dist/tui/components/LogsPanel.js +4 -3
  58. package/dist/tui/components/LogsPanel.js.map +1 -1
  59. package/dist/tui/components/MemoryPanel.d.ts +1 -0
  60. package/dist/tui/components/MemoryPanel.d.ts.map +1 -1
  61. package/dist/tui/components/MemoryPanel.js +2 -2
  62. package/dist/tui/components/MemoryPanel.js.map +1 -1
  63. package/dist/tui/components/MetricsPanel.d.ts +1 -0
  64. package/dist/tui/components/MetricsPanel.d.ts.map +1 -1
  65. package/dist/tui/components/MetricsPanel.js +2 -2
  66. package/dist/tui/components/MetricsPanel.js.map +1 -1
  67. package/dist/tui/components/StatusPanel.d.ts +1 -0
  68. package/dist/tui/components/StatusPanel.d.ts.map +1 -1
  69. package/dist/tui/components/StatusPanel.js +4 -3
  70. package/dist/tui/components/StatusPanel.js.map +1 -1
  71. package/dist/vendor-manifests.d.ts +22 -0
  72. package/package.json +5 -1
  73. package/dashboard/index.html +0 -420
  74. package/dist/hub/chat/ChatApp.d.ts +0 -2
  75. package/dist/hub/chat/ChatApp.d.ts.map +0 -1
  76. package/dist/hub/chat/ChatApp.js +0 -146
  77. package/dist/hub/chat/ChatApp.js.map +0 -1
  78. package/dist/hub/chat/components/ChatInput.d.ts +0 -9
  79. package/dist/hub/chat/components/ChatInput.d.ts.map +0 -1
  80. package/dist/hub/chat/components/ChatInput.js +0 -19
  81. package/dist/hub/chat/components/ChatInput.js.map +0 -1
  82. package/dist/hub/chat/components/MessageList.d.ts +0 -7
  83. package/dist/hub/chat/components/MessageList.d.ts.map +0 -1
  84. package/dist/hub/chat/components/MessageList.js +0 -6
  85. package/dist/hub/chat/components/MessageList.js.map +0 -1
  86. package/dist/hub/chat/context.d.ts.map +0 -1
  87. package/dist/hub/chat/context.js +0 -42
  88. package/dist/hub/chat/context.js.map +0 -1
  89. package/dist/hub/chat/hooks/useChatHistory.d.ts +0 -7
  90. package/dist/hub/chat/hooks/useChatHistory.d.ts.map +0 -1
  91. package/dist/hub/chat/hooks/useChatHistory.js +0 -31
  92. package/dist/hub/chat/hooks/useChatHistory.js.map +0 -1
  93. package/dist/hub/chat/index.d.ts.map +0 -1
  94. package/dist/hub/chat/index.js +0 -7
  95. package/dist/hub/chat/index.js.map +0 -1
  96. package/dist/hub/chat/intent-parser.d.ts.map +0 -1
  97. package/dist/hub/chat/intent-parser.js +0 -48
  98. package/dist/hub/chat/intent-parser.js.map +0 -1
  99. package/dist/hub/chat/types.d.ts.map +0 -1
  100. package/dist/hub/chat/types.js +0 -2
  101. package/dist/hub/chat/types.js.map +0 -1
  102. package/dist/hub/tui/App.d.ts +0 -2
  103. package/dist/hub/tui/App.d.ts.map +0 -1
  104. package/dist/hub/tui/App.js +0 -53
  105. package/dist/hub/tui/App.js.map +0 -1
  106. package/dist/hub/tui/components/AgentQueue.d.ts +0 -6
  107. package/dist/hub/tui/components/AgentQueue.d.ts.map +0 -1
  108. package/dist/hub/tui/components/AgentQueue.js +0 -20
  109. package/dist/hub/tui/components/AgentQueue.js.map +0 -1
  110. package/dist/hub/tui/components/DAGPanel.d.ts +0 -16
  111. package/dist/hub/tui/components/DAGPanel.d.ts.map +0 -1
  112. package/dist/hub/tui/components/DAGPanel.js +0 -51
  113. package/dist/hub/tui/components/DAGPanel.js.map +0 -1
  114. package/dist/hub/tui/components/Header.d.ts +0 -7
  115. package/dist/hub/tui/components/Header.d.ts.map +0 -1
  116. package/dist/hub/tui/components/Header.js +0 -17
  117. package/dist/hub/tui/components/Header.js.map +0 -1
  118. package/dist/hub/tui/components/LogsPanel.d.ts +0 -6
  119. package/dist/hub/tui/components/LogsPanel.d.ts.map +0 -1
  120. package/dist/hub/tui/components/LogsPanel.js +0 -26
  121. package/dist/hub/tui/components/LogsPanel.js.map +0 -1
  122. package/dist/hub/tui/components/StatusBar.d.ts +0 -8
  123. package/dist/hub/tui/components/StatusBar.d.ts.map +0 -1
  124. package/dist/hub/tui/components/StatusBar.js +0 -7
  125. package/dist/hub/tui/components/StatusBar.js.map +0 -1
  126. package/dist/hub/tui/hooks/useEvents.d.ts +0 -2
  127. package/dist/hub/tui/hooks/useEvents.d.ts.map +0 -1
  128. package/dist/hub/tui/hooks/useEvents.js +0 -13
  129. package/dist/hub/tui/hooks/useEvents.js.map +0 -1
  130. package/dist/hub/tui/index.d.ts.map +0 -1
  131. package/dist/hub/tui/index.js +0 -7
  132. package/dist/hub/tui/index.js.map +0 -1
  133. package/dist/hub/tui/types.d.ts.map +0 -1
  134. package/dist/hub/tui/types.js +0 -2
  135. package/dist/hub/tui/types.js.map +0 -1
  136. package/src/benchmark.ts +0 -156
  137. package/src/bin.ts +0 -156
  138. package/src/bootstrap.ts +0 -36
  139. package/src/bridge-adapter-templates.ts +0 -181
  140. package/src/bridge-test.ts +0 -107
  141. package/src/dashboard.ts +0 -51
  142. package/src/doctor.ts +0 -92
  143. package/src/evolve.ts +0 -74
  144. package/src/host-init-templates.ts +0 -134
  145. package/src/hub/__tests__/commands.test.ts +0 -84
  146. package/src/hub/__tests__/history.test.ts +0 -137
  147. package/src/hub/__tests__/parser.test.ts +0 -105
  148. package/src/hub/commands/agents.ts +0 -53
  149. package/src/hub/commands/index.ts +0 -140
  150. package/src/hub/commands/logs.ts +0 -70
  151. package/src/hub/commands/memory.ts +0 -47
  152. package/src/hub/commands/metrics.ts +0 -49
  153. package/src/hub/commands/providers.ts +0 -39
  154. package/src/hub/commands/run.ts +0 -37
  155. package/src/hub/commands/status.ts +0 -69
  156. package/src/hub/commands/workflows.ts +0 -64
  157. package/src/hub/config-loader.ts +0 -37
  158. package/src/hub/event-listener.ts +0 -17
  159. package/src/hub/history.ts +0 -66
  160. package/src/hub/index.ts +0 -132
  161. package/src/hub/parser.ts +0 -107
  162. package/src/hub/styles/borders.ts +0 -74
  163. package/src/hub/styles/colors.ts +0 -129
  164. package/src/hub/styles/typography.ts +0 -68
  165. package/src/hub/types.ts +0 -31
  166. package/src/init-host.ts +0 -285
  167. package/src/install.ts +0 -118
  168. package/src/run.ts +0 -317
  169. package/src/setup/components/ApiKeyInput.tsx +0 -158
  170. package/src/setup/components/AsciiBanner.tsx +0 -125
  171. package/src/setup/components/CliDetector.tsx +0 -230
  172. package/src/setup/components/ModeSelector.tsx +0 -137
  173. package/src/setup/components/ProviderSelector.tsx +0 -174
  174. package/src/setup/components/SetupWizard.tsx +0 -368
  175. package/src/setup/components/StepIndicator.tsx +0 -74
  176. package/src/setup/components/SuccessScreen.tsx +0 -229
  177. package/src/setup/index.ts +0 -34
  178. package/src/setup/utils/cli-detection.ts +0 -99
  179. package/src/setup/utils/config-writer.ts +0 -249
  180. package/src/styles.ts +0 -12
  181. package/src/tui/App.tsx +0 -177
  182. package/src/tui/components/AgentStateIcon.tsx +0 -84
  183. package/src/tui/components/AnimatedBranch.tsx +0 -134
  184. package/src/tui/components/ChatPanel.tsx +0 -125
  185. package/src/tui/components/DAGPanel.tsx +0 -208
  186. package/src/tui/components/ExecutionTimeline.tsx +0 -225
  187. package/src/tui/components/Header.tsx +0 -109
  188. package/src/tui/components/HelpOverlay.tsx +0 -140
  189. package/src/tui/components/InputBar.tsx +0 -69
  190. package/src/tui/components/LogsPanel.tsx +0 -129
  191. package/src/tui/components/MemoryPanel.tsx +0 -163
  192. package/src/tui/components/MetricsPanel.tsx +0 -149
  193. package/src/tui/components/StatusPanel.tsx +0 -137
  194. package/src/tui/components/TaskTree.tsx +0 -159
  195. package/src/tui/components/animations/ProgressBar.tsx +0 -160
  196. package/src/tui/components/animations/Pulse.tsx +0 -73
  197. package/src/tui/components/animations/Spinner.tsx +0 -54
  198. package/src/tui/components/animations/StatusAnimator.tsx +0 -153
  199. package/src/tui/components/animations/TypingEffect.tsx +0 -119
  200. package/src/tui/components/animations/index.ts +0 -16
  201. package/src/tui/hooks/useAnimation.ts +0 -290
  202. package/src/tui/hooks/useAppState.ts +0 -403
  203. package/src/tui/index.ts +0 -9
  204. package/src/tui/services/orchestrator.ts +0 -195
  205. package/src/tui/styles/borders.ts +0 -51
  206. package/src/tui/styles/colors.ts +0 -19
  207. package/src/tui/styles/index.ts +0 -20
  208. package/src/tui/styles/indicators.ts +0 -54
  209. package/src/tui/styles/layout.ts +0 -44
  210. package/src/tui/styles/providers.ts +0 -32
  211. package/src/tui/utils/animation.ts +0 -124
  212. package/src/vendor-manifests.ts +0 -113
  213. package/src/ws-relay.ts +0 -156
  214. package/tsconfig.json +0 -28
package/src/benchmark.ts DELETED
@@ -1,156 +0,0 @@
1
- import { mkdir, writeFile } from "node:fs/promises";
2
- import path from "node:path";
3
- import { performance } from "node:perf_hooks";
4
- import { CoreOrchestrator } from "rax-flow-core";
5
- import { buildOfficialAgentsRuntime } from "rax-flow-agents";
6
- import { ClaudeAdapter, GenericRestAdapter, HostBridgeAdapter, OpenAIAdapter } from "rax-flow-providers";
7
- import { c } from "./styles.js";
8
- import { readFile } from "node:fs/promises";
9
-
10
- interface BenchOptions {
11
- cwd: string;
12
- prompt: string;
13
- output?: string;
14
- providerOverride?: string;
15
- bridgeCommandOverride?: string;
16
- }
17
-
18
- interface RaxConfig {
19
- defaultProvider?: string;
20
- strongProvider?: string;
21
- providers?: {
22
- host?: { model?: string; mode?: "auto" | "bridge-only" | "mock"; bridgeCommandEnv?: string; timeoutMs?: number };
23
- openai?: { model?: string; apiKeyEnv?: string; baseUrl?: string };
24
- claude?: { model?: string; apiKeyEnv?: string; baseUrl?: string };
25
- rest?: { endpoint?: string; tokenEnv?: string; model?: string };
26
- };
27
- }
28
-
29
- async function loadConfig(cwd: string): Promise<RaxConfig> {
30
- const file = path.join(cwd, ".raxrc");
31
- const raw = await readFile(file, "utf8");
32
- return JSON.parse(raw) as RaxConfig;
33
- }
34
-
35
- function createProviders(config: RaxConfig, bridgeCommandOverride?: string) {
36
- const providers: Record<string, OpenAIAdapter | ClaudeAdapter | GenericRestAdapter | HostBridgeAdapter> = {};
37
-
38
- const hostCfg = config.providers?.host;
39
- const bridgeCommand = bridgeCommandOverride ?? process.env[hostCfg?.bridgeCommandEnv ?? "RAX_HOST_BRIDGE_COMMAND"];
40
- providers.host = new HostBridgeAdapter({
41
- model: hostCfg?.model ?? "host-managed",
42
- mode: hostCfg?.mode ?? "auto",
43
- command: bridgeCommand,
44
- timeoutMs: hostCfg?.timeoutMs ?? 20000
45
- });
46
-
47
- const openaiKey = process.env[config.providers?.openai?.apiKeyEnv ?? "OPENAI_API_KEY"];
48
- if (openaiKey) {
49
- providers.openai = new OpenAIAdapter(openaiKey, config.providers?.openai?.baseUrl);
50
- }
51
-
52
- const claudeKey = process.env[config.providers?.claude?.apiKeyEnv ?? "ANTHROPIC_API_KEY"];
53
- if (claudeKey) {
54
- providers.claude = new ClaudeAdapter(claudeKey, config.providers?.claude?.baseUrl);
55
- }
56
-
57
- const restEndpoint = config.providers?.rest?.endpoint;
58
- if (restEndpoint) {
59
- const restToken = process.env[config.providers?.rest?.tokenEnv ?? "RAX_REST_TOKEN"];
60
- providers.rest = new GenericRestAdapter(restEndpoint, restToken);
61
- }
62
-
63
- return providers;
64
- }
65
-
66
- function pseudoScore(text: string): number {
67
- const clean = text.trim();
68
- if (!clean) return 0;
69
- const lengthScore = Math.min(clean.length / 1200, 1);
70
- const structureScore = ["{", "}", "-", "1.", "2."].reduce((acc, token) => acc + (clean.includes(token) ? 0.08 : 0), 0);
71
- return Math.min(1, 0.45 + lengthScore * 0.35 + structureScore);
72
- }
73
-
74
- export async function runBenchmark(options: BenchOptions): Promise<number> {
75
- let config: RaxConfig;
76
- try {
77
- config = await loadConfig(options.cwd);
78
- } catch {
79
- console.error(c.red("Missing .raxrc. Run `raxflow install` first."));
80
- return 1;
81
- }
82
-
83
- const providers = createProviders(config, options.bridgeCommandOverride);
84
- const selectedProvider = options.providerOverride ?? config.defaultProvider ?? "host";
85
- const provider = providers[selectedProvider] ?? Object.values(providers)[0];
86
- if (!provider) {
87
- console.error(c.red("No provider configured for benchmark."));
88
- return 1;
89
- }
90
-
91
- const baselineStart = performance.now();
92
- const baselineRaw = await provider.callModel(options.prompt, { temperature: 0.2, maxTokens: 1200 });
93
- const baselineLatency = performance.now() - baselineStart;
94
-
95
- const agents = buildOfficialAgentsRuntime({
96
- providers,
97
- defaultProvider: selectedProvider,
98
- strongProvider: config.strongProvider ?? "host",
99
- providerModels: {
100
- host: config.providers?.host?.model ?? "host-managed",
101
- openai: config.providers?.openai?.model ?? "gpt-4.1-mini",
102
- claude: config.providers?.claude?.model ?? "claude-3-5-sonnet-latest",
103
- rest: config.providers?.rest?.model ?? "generic-llm"
104
- }
105
- });
106
-
107
- const orchestrator = new CoreOrchestrator(providers, agents, {}, { maxParallel: 4, cacheTtlMs: 0 });
108
- const raxStart = performance.now();
109
- const rax = await orchestrator.run({
110
- taskId: `bench_${Date.now()}`,
111
- userPrompt: options.prompt,
112
- context: { benchmark: true }
113
- });
114
- const raxLatency = performance.now() - raxStart;
115
-
116
- const baselineCorrectness = pseudoScore(baselineRaw.output);
117
- const report = {
118
- generatedAt: new Date().toISOString(),
119
- prompt: options.prompt,
120
- baseline: {
121
- correctness: baselineCorrectness,
122
- cost: 0,
123
- latencyMs: Math.round(baselineLatency),
124
- stability: baselineCorrectness * 0.9,
125
- humanIntervention: baselineCorrectness < 0.7 ? 0.6 : 0.3
126
- },
127
- orchestrated: {
128
- correctness: rax.result.confidence,
129
- cost: rax.metrics.totalCostUsd,
130
- latencyMs: Math.round(raxLatency),
131
- stability: rax.result.success ? 0.9 : 0.5,
132
- humanIntervention: rax.metrics.humanInterventionRequired ? 0.6 : 0.1
133
- }
134
- };
135
-
136
- const delta = {
137
- correctness: +(report.orchestrated.correctness - report.baseline.correctness).toFixed(3),
138
- cost: +(report.orchestrated.cost - report.baseline.cost).toFixed(3),
139
- latencyMs: report.orchestrated.latencyMs - report.baseline.latencyMs,
140
- stability: +(report.orchestrated.stability - report.baseline.stability).toFixed(3),
141
- humanIntervention: +(report.orchestrated.humanIntervention - report.baseline.humanIntervention).toFixed(3)
142
- };
143
-
144
- const full = { ...report, delta };
145
- const outputFile = path.resolve(options.cwd, options.output ?? "benchmarks/reports/latest.json");
146
- await mkdir(path.dirname(outputFile), { recursive: true });
147
- await writeFile(outputFile, `${JSON.stringify(full, null, 2)}\n`, "utf8");
148
-
149
- console.log(c.blue("RAXFLOW Benchmark"));
150
- console.log(`report: ${outputFile}`);
151
- console.log(`delta correctness: ${delta.correctness}`);
152
- console.log(`delta latency(ms): ${delta.latencyMs}`);
153
- console.log(`delta stability: ${delta.stability}`);
154
- console.log(`delta humanIntervention: ${delta.humanIntervention}`);
155
- return 0;
156
- }
package/src/bin.ts DELETED
@@ -1,156 +0,0 @@
1
- #!/usr/bin/env node
2
- import { runInstall } from "./install.js";
3
- import { runBenchmark } from "./benchmark.js";
4
- import { runBootstrap } from "./bootstrap.js";
5
- import { runBridgeTest } from "./bridge-test.js";
6
- import { runDoctor } from "./doctor.js";
7
- import { runInitHost } from "./init-host.js";
8
- import { runWorkflow } from "./run.js";
9
- import { runDashboard } from "./dashboard.js";
10
- import { startHubOneShot } from "./hub/index.js";
11
- import { runSetup } from "./setup/index.js";
12
-
13
- function getFlag(args: string[], flag: string): string | undefined {
14
- const index = args.indexOf(flag);
15
- if (index === -1) return undefined;
16
- return args[index + 1];
17
- }
18
-
19
- async function main() {
20
- const args = process.argv.slice(2);
21
- const command = args[0];
22
-
23
- // Mode hub interactif (défaut) - sans arguments ou avec 'hub'
24
- if (!command || command === "hub") {
25
- const { startTUI } = await import("./tui/index.js");
26
- startTUI();
27
- return;
28
- }
29
-
30
- // Mode one-shot
31
- if (command === "--run") {
32
- const prompt = getFlag(args, "--run");
33
- if (!prompt) {
34
- console.error("Missing --run <prompt>");
35
- process.exit(1);
36
- }
37
- await startHubOneShot("run", [prompt, ...args.slice(1)]);
38
- return;
39
- }
40
-
41
- // Help pour le hub
42
- if (command === "--help" || command === "-h") {
43
- console.log("Usage: raxflow [command]");
44
- console.log("");
45
- console.log("Modes:");
46
- console.log(" (no args) Launch interactive hub (default)");
47
- console.log(" hub Launch interactive hub");
48
- console.log(" --run <prompt> One-shot mode (execute and exit)");
49
- console.log("");
50
- console.log("Setup:");
51
- console.log(" setup Interactive setup wizard (TUI)");
52
- console.log(" install [--ui] Legacy setup (alias for setup)");
53
- console.log("");
54
- console.log("Commands:");
55
- console.log(" run --prompt <text> [--workflow path] [--json] [--stream] [--max-parallel N] [--no-cache-persist]");
56
- console.log(" Execute workflow");
57
- console.log(" Optional: [--provider host|openai|claude|rest] [--bridge-command \"node bridge.mjs\"]");
58
- console.log(" benchmark --prompt <text> [--output path] Compare baseline vs orchestrated");
59
- console.log(" Optional: [--provider host|openai|claude|rest] [--bridge-command \"node bridge.mjs\"]");
60
- console.log(" doctor Validate host-native bridge setup");
61
- console.log(" bridge-test [--target claude-code|codex|opencode|kilo|generic] Run bridge smoke payload");
62
- console.log(" bootstrap [--target claude-code|codex|opencode|kilo|generic] [--task \"...\"] [--json]");
63
- console.log(" Print chat bootstrap prompt");
64
- console.log(" dashboard [--port N] Start the visual insights dashboard");
65
- process.exit(0);
66
- }
67
-
68
- if (command === "install" || command === "setup") {
69
- const code = await runSetup();
70
- process.exit(code);
71
- }
72
-
73
- if (command === "run") {
74
- const prompt = getFlag(args, "--prompt");
75
- if (!prompt) {
76
- console.error("Missing --prompt");
77
- process.exit(1);
78
- }
79
- const workflowPath = getFlag(args, "--workflow");
80
- const provider = getFlag(args, "--provider");
81
- const bridgeCommand = getFlag(args, "--bridge-command");
82
- const maxParallelRaw = getFlag(args, "--max-parallel");
83
- const maxParallel = maxParallelRaw ? Number(maxParallelRaw) : undefined;
84
- const code = await runWorkflow({
85
- cwd: process.cwd(),
86
- prompt,
87
- workflowPath,
88
- asJson: args.includes("--json"),
89
- stream: args.includes("--stream"),
90
- maxParallel: Number.isFinite(maxParallel) ? maxParallel : undefined,
91
- noCachePersist: args.includes("--no-cache-persist"),
92
- providerOverride: provider,
93
- bridgeCommandOverride: bridgeCommand,
94
- ui: args.includes("--ui")
95
- });
96
- process.exit(code);
97
- }
98
-
99
- if (command === "benchmark") {
100
- const prompt = getFlag(args, "--prompt");
101
- if (!prompt) {
102
- console.error("Missing --prompt");
103
- process.exit(1);
104
- }
105
- const output = getFlag(args, "--output");
106
- const provider = getFlag(args, "--provider");
107
- const bridgeCommand = getFlag(args, "--bridge-command");
108
- const code = await runBenchmark({ cwd: process.cwd(), prompt, output, providerOverride: provider, bridgeCommandOverride: bridgeCommand });
109
- process.exit(code);
110
- }
111
-
112
- if (command === "doctor") {
113
- const code = await runDoctor({ cwd: process.cwd() });
114
- process.exit(code);
115
- }
116
-
117
- if (command === "bridge-test") {
118
- const target = getFlag(args, "--target");
119
- const code = await runBridgeTest({ cwd: process.cwd(), target });
120
- process.exit(code);
121
- }
122
-
123
- if (command === "init-host") {
124
- const target = getFlag(args, "--target");
125
- const task = getFlag(args, "--task");
126
- const code = await runInitHost({ cwd: process.cwd(), target, printOnly: args.includes("--print"), all: args.includes("--all"), task });
127
- process.exit(code);
128
- }
129
-
130
- if (command === "bootstrap") {
131
- const target = getFlag(args, "--target");
132
- const task = getFlag(args, "--task");
133
- const code = await runBootstrap({ target, task, asJson: args.includes("--json") });
134
- process.exit(code);
135
- }
136
-
137
- if (command === "dashboard") {
138
- const port = getFlag(args, "--port");
139
- const code = await runDashboard({ port: port ? Number(port) : 3003 });
140
- process.exit(code);
141
- }
142
-
143
- if (command === "evolve") {
144
- const { showEvolution } = await import("./evolve.js");
145
- const code = await showEvolution({ cwd: process.cwd(), history: args.includes("--history") });
146
- process.exit(code);
147
- }
148
-
149
- console.error(`Unknown command: ${command}`);
150
- process.exit(1);
151
- }
152
-
153
- main().catch((error) => {
154
- console.error(error);
155
- process.exit(1);
156
- });
package/src/bootstrap.ts DELETED
@@ -1,36 +0,0 @@
1
- import { c } from "./styles.js";
2
- import { HOST_TEMPLATES, buildBootstrapPrompt, parseHostTarget } from "./host-init-templates.js";
3
-
4
- interface BootstrapOptions {
5
- target?: string;
6
- asJson?: boolean;
7
- task?: string;
8
- }
9
-
10
- export async function runBootstrap(options: BootstrapOptions): Promise<number> {
11
- const target = parseHostTarget(options.target);
12
- const template = HOST_TEMPLATES[target];
13
- const prompt = buildBootstrapPrompt(target, options.task);
14
-
15
- if (options.asJson) {
16
- console.log(
17
- JSON.stringify(
18
- {
19
- target,
20
- title: template.title,
21
- autoInjectMode: template.autoInjectMode,
22
- prompt,
23
- quickCommands: template.quickCommands,
24
- sessionEntryExamples: template.sessionEntryExamples
25
- },
26
- null,
27
- 2
28
- )
29
- );
30
- return 0;
31
- }
32
-
33
- console.log(c.blue(`RAX-FLOW Bootstrap Prompt (${target})`));
34
- console.log(prompt);
35
- return 0;
36
- }
@@ -1,181 +0,0 @@
1
- import { HostTarget } from "./host-init-templates.js";
2
-
3
- function vendorCallFunction(target: HostTarget): string {
4
- if (target === "claude-code") return "callClaudeCodeRuntime";
5
- if (target === "codex") return "callCodexRuntime";
6
- if (target === "opencode") return "callOpenCodeRuntime";
7
- if (target === "kilo") return "callKiloRuntime";
8
- return "callGenericHostRuntime";
9
- }
10
-
11
- function vendorNotes(target: HostTarget): string {
12
- if (target === "claude-code") {
13
- return [
14
- "// Claude Code integration notes:",
15
- "// - Map `payload.action` to Claude Code message/runtime API.",
16
- "// - Ensure structured mode returns strict JSON object, not markdown.",
17
- ""
18
- ].join("\n");
19
- }
20
- if (target === "codex") {
21
- return [
22
- "// Codex integration notes:",
23
- "// - Map payload.options.model to your Codex runtime model selector.",
24
- "// - For callStructured, return parsed JSON object only.",
25
- ""
26
- ].join("\n");
27
- }
28
- if (target === "opencode") {
29
- return [
30
- "// OpenCode integration notes:",
31
- "// - Connect to OpenCode model invocation API/SDK.",
32
- "// - Preserve latency and model name in response when possible.",
33
- ""
34
- ].join("\n");
35
- }
36
- if (target === "kilo") {
37
- return [
38
- "// Kilo integration notes:",
39
- "// - Route both actions through Kilo's model runtime.",
40
- "// - Handle model fallback inside runtime wrapper if supported.",
41
- ""
42
- ].join("\n");
43
- }
44
- return [
45
- "// Generic host integration notes:",
46
- "// - Replace runtime call with your environment-specific function.",
47
- "// - Keep response aligned with HostBridgeResponse schema.",
48
- ""
49
- ].join("\n");
50
- }
51
-
52
- export function renderBridgeAdapter(target: HostTarget): string {
53
- const runtimeFn = vendorCallFunction(target);
54
- return [
55
- "#!/usr/bin/env node",
56
- "",
57
- "/**",
58
- ` * RAX-FLOW bridge adapter scaffold for ${target}.`,
59
- " *",
60
- " * Input : HostBridgeRequest JSON on stdin",
61
- " * Output: HostBridgeResponse JSON on stdout",
62
- " */",
63
- "",
64
- "import { readFileSync } from \"node:fs\";",
65
- "import path from \"node:path\";",
66
- "",
67
- "function readStdin() {",
68
- " return new Promise((resolve) => {",
69
- " let data = \"\";",
70
- " process.stdin.setEncoding(\"utf8\");",
71
- " process.stdin.on(\"data\", (chunk) => { data += chunk; });",
72
- " process.stdin.on(\"end\", () => resolve(data));",
73
- " });",
74
- "}",
75
- "",
76
- "function safeJsonParse(text) {",
77
- " try { return JSON.parse(text); } catch { return null; }",
78
- "}",
79
- "",
80
- "function normalizeError(error) {",
81
- " if (!error) return \"unknown_error\";",
82
- " if (typeof error === \"string\") return error;",
83
- " return error.message || String(error);",
84
- "}",
85
- "",
86
- "function isStructuredPayload(obj) {",
87
- " return obj && typeof obj === \"object\" &&",
88
- " typeof obj.agent === \"string\" &&",
89
- " typeof obj.success === \"boolean\" &&",
90
- " typeof obj.confidence === \"number\" &&",
91
- " Array.isArray(obj.risks) &&",
92
- " Array.isArray(obj.logs) &&",
93
- " obj.data && typeof obj.data === \"object\";",
94
- "}",
95
- "",
96
- "function loadRuntimeConfig() {",
97
- " const file = path.join(process.cwd(), '.rax-flow', 'host-init', '" + target + "', 'bridge-runtime-config.json');",
98
- " try {",
99
- " return JSON.parse(readFileSync(file, 'utf8'));",
100
- " } catch {",
101
- " return {",
102
- " vendor: '" + target + "',",
103
- " model: 'host-managed',",
104
- " endpoint: null,",
105
- " authEnv: null,",
106
- " structuredMode: 'json',",
107
- " responseStrict: true,",
108
- " timeoutMs: 20000",
109
- " };",
110
- " }",
111
- "}",
112
- "",
113
- vendorNotes(target),
114
- "// callHostModel is the bridge interface for runtime calls",
115
- `async function ${runtimeFn}(payload, runtimeConfig) {`,
116
- " // TODO: implement real runtime call for this vendor.",
117
- " // payload.action = callModel | callStructured",
118
- " // runtimeConfig can provide endpoint/auth/model/runtime settings.",
119
- " if (payload.action === 'callStructured') {",
120
- " return {",
121
- " ok: true,",
122
- " model: runtimeConfig.model || payload.options?.model || 'host-managed',",
123
- " latencyMs: 8,",
124
- " output: {",
125
- " agent: 'VendorBridgeTemplate',",
126
- " success: true,",
127
- " confidence: 0.73,",
128
- " risks: [],",
129
- " logs: ['replace with real vendor runtime response'],",
130
- " data: { summary: 'template structured output', nextAction: 'continue' }",
131
- " }",
132
- " };",
133
- " }",
134
- " return {",
135
- " ok: true,",
136
- " model: runtimeConfig.model || payload.options?.model || 'host-managed',",
137
- " latencyMs: 8,",
138
- " output: `template-text:${String(payload.prompt || '').slice(0, 220)}`",
139
- " };",
140
- "}",
141
- "",
142
- "async function main() {",
143
- " const input = await readStdin();",
144
- " const payload = safeJsonParse(input);",
145
- " if (!payload || payload.version !== 1 || !payload.action) {",
146
- " process.stdout.write(JSON.stringify({ ok: false, error: 'invalid_payload' }));",
147
- " return;",
148
- " }",
149
- "",
150
- " const runtimeConfig = loadRuntimeConfig();",
151
- "",
152
- " try {",
153
- ` const response = await ${runtimeFn}(payload, runtimeConfig);`,
154
- " if (payload.action === 'callStructured' && runtimeConfig.responseStrict) {",
155
- " if (!response || !isStructuredPayload(response.output)) {",
156
- " process.stdout.write(JSON.stringify({",
157
- " ok: false,",
158
- " error: 'structured_output_invalid',",
159
- " details: 'Ensure output contains agent/success/confidence/risks/logs/data',",
160
- " }));",
161
- " return;",
162
- " }",
163
- " }",
164
- " process.stdout.write(JSON.stringify(response));",
165
- " } catch (error) {",
166
- " process.stdout.write(JSON.stringify({ ok: false, error: `bridge_exception:${normalizeError(error)}` }));",
167
- " }",
168
- "}",
169
- "",
170
- "main();",
171
- ""
172
- ].join("\n");
173
- }
174
-
175
- export function bridgeAdapterFilename(target: HostTarget): string {
176
- if (target === "claude-code") return "bridge-adapter-claude-code.mjs";
177
- if (target === "codex") return "bridge-adapter-codex.mjs";
178
- if (target === "opencode") return "bridge-adapter-opencode.mjs";
179
- if (target === "kilo") return "bridge-adapter-kilo.mjs";
180
- return "bridge-adapter-generic.mjs";
181
- }
@@ -1,107 +0,0 @@
1
- import { readFile } from "node:fs/promises";
2
- import path from "node:path";
3
- import { spawn } from "node:child_process";
4
- import { c } from "./styles.js";
5
- import { parseHostTarget } from "./host-init-templates.js";
6
-
7
- interface BridgeTestOptions {
8
- cwd: string;
9
- target?: string;
10
- }
11
-
12
- function parseShellCommand(input: string): { command: string; args: string[] } {
13
- const parts = input.match(/(?:[^\s"]+|"[^"]*")+/g) ?? [];
14
- if (parts.length === 0) {
15
- throw new Error("invalid_bridge_command");
16
- }
17
- const [command, ...rawArgs] = parts;
18
- const args = rawArgs.map((arg) => arg.replace(/^"|"$/g, ""));
19
- return { command: command!, args };
20
- }
21
-
22
- async function runCommand(commandSpec: string, payload: unknown): Promise<{ code: number; stdout: string; stderr: string }> {
23
- const { command, args } = parseShellCommand(commandSpec);
24
- return await new Promise((resolve, reject) => {
25
- const child = spawn(command, args, { stdio: ["pipe", "pipe", "pipe"] });
26
- let stdout = "";
27
- let stderr = "";
28
-
29
- child.stdout.on("data", (chunk) => {
30
- stdout += String(chunk);
31
- });
32
-
33
- child.stderr.on("data", (chunk) => {
34
- stderr += String(chunk);
35
- });
36
-
37
- child.on("error", (error) => reject(error));
38
- child.on("close", (code) => resolve({ code: code ?? 1, stdout, stderr }));
39
-
40
- child.stdin.write(JSON.stringify(payload));
41
- child.stdin.end();
42
- });
43
- }
44
-
45
- export async function runBridgeTest(options: BridgeTestOptions): Promise<number> {
46
- const target = parseHostTarget(options.target);
47
- const baseDir = path.join(options.cwd, ".rax-flow", "host-init", target);
48
- const manifestFile = path.join(baseDir, "host-manifest.json");
49
- const smokeFile = path.join(baseDir, "bridge-smoke-test.json");
50
-
51
- let manifest: { bridgeCommand?: string };
52
- let smokePayload: unknown;
53
-
54
- try {
55
- manifest = JSON.parse(await readFile(manifestFile, "utf8")) as { bridgeCommand?: string };
56
- } catch {
57
- console.error(c.red(`Missing host manifest: ${manifestFile}`));
58
- return 1;
59
- }
60
-
61
- try {
62
- smokePayload = JSON.parse(await readFile(smokeFile, "utf8"));
63
- } catch {
64
- console.error(c.red(`Missing bridge smoke test payload: ${smokeFile}`));
65
- return 1;
66
- }
67
-
68
- if (!manifest.bridgeCommand) {
69
- console.error(c.red("host-manifest.json missing bridgeCommand"));
70
- return 1;
71
- }
72
-
73
- const result = await runCommand(manifest.bridgeCommand, smokePayload);
74
- console.log(c.blue(`RAX-FLOW Bridge Test (${target})`));
75
- console.log(`command: ${manifest.bridgeCommand}`);
76
- console.log(`exitCode: ${result.code}`);
77
-
78
- if (result.stdout.trim()) {
79
- console.log("stdout:");
80
- console.log(result.stdout.trim());
81
- }
82
-
83
- if (result.stderr.trim()) {
84
- console.log("stderr:");
85
- console.log(result.stderr.trim());
86
- }
87
-
88
- if (result.code !== 0) {
89
- console.log(c.red("Bridge smoke test failed."));
90
- return 1;
91
- }
92
-
93
- try {
94
- const parsed = JSON.parse(result.stdout);
95
- const ok = Boolean(parsed?.ok);
96
- if (!ok) {
97
- console.log(c.red(`Bridge responded with ok=false: ${parsed?.error ?? "unknown"}`));
98
- return 1;
99
- }
100
- } catch {
101
- console.log(c.red("Bridge output is not valid JSON."));
102
- return 1;
103
- }
104
-
105
- console.log(c.green("Bridge smoke test passed."));
106
- return 0;
107
- }
package/src/dashboard.ts DELETED
@@ -1,51 +0,0 @@
1
- import http from "node:http";
2
- import { readFile } from "node:fs/promises";
3
- import path from "node:path";
4
- import { fileURLToPath } from "node:url";
5
-
6
- const __dirname = path.dirname(fileURLToPath(import.meta.url));
7
-
8
- export async function runDashboard({ port = 3003 }: { port?: number } = {}): Promise<number> {
9
- const server = http.createServer(async (req, res) => {
10
- // Simple static server for the dashboard
11
- if (req.url === "/" || req.url === "/index.html") {
12
- try {
13
- // Try to find the dashboard file
14
- // In the monorepo, it's in packages/cli/dashboard/index.html
15
- // When installed as a package, it will be relative to this file
16
- let htmlPath = path.join(process.cwd(), "packages/cli/dashboard/index.html");
17
-
18
- // Fallback for when running from dist or installed package
19
- try {
20
- await readFile(htmlPath);
21
- } catch {
22
- htmlPath = path.join(__dirname, "..", "dashboard", "index.html");
23
- }
24
-
25
- const content = await readFile(htmlPath, "utf8");
26
- res.writeHead(200, { "Content-Type": "text/html" });
27
- res.end(content);
28
- } catch (err) {
29
- console.error("[UI] Error loading dashboard:", err);
30
- res.writeHead(500);
31
- res.end("Error loading dashboard. Please ensure you are running from the project root.");
32
- }
33
- } else {
34
- res.writeHead(404);
35
- res.end("Not Found");
36
- }
37
- });
38
-
39
- return new Promise((resolve) => {
40
- server.listen(port, () => {
41
- console.log(`\n[UI] 🚀 RAX Dashboard started on http://localhost:${port}`);
42
- console.log(`[UI] Monitoring kernel evolution and workflow health.`);
43
- console.log(`[UI] Press Ctrl+C to stop.`);
44
- });
45
-
46
- process.on("SIGINT", () => {
47
- server.close();
48
- resolve(0);
49
- });
50
- });
51
- }