@the-agenticflow/openflows 0.1.10 → 0.1.12

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 (2) hide show
  1. package/bin/openflows.js +75 -5
  2. package/package.json +1 -1
package/bin/openflows.js CHANGED
@@ -15,6 +15,44 @@ const fs = require('fs');
15
15
  const os = require('os');
16
16
  const http = require('http');
17
17
 
18
+ // Try to load .env file before checking environment
19
+ function loadEnvFile() {
20
+ const envPaths = [
21
+ path.join(process.cwd(), '.env'),
22
+ path.join(os.homedir(), '.agentflow', '.env'),
23
+ ];
24
+
25
+ for (const envPath of envPaths) {
26
+ if (fs.existsSync(envPath)) {
27
+ try {
28
+ const content = fs.readFileSync(envPath, 'utf8');
29
+ content.split('\n').forEach(line => {
30
+ const trimmed = line.trim();
31
+ // Skip comments and empty lines
32
+ if (!trimmed || trimmed.startsWith('#')) return;
33
+
34
+ const eqIndex = trimmed.indexOf('=');
35
+ if (eqIndex > 0) {
36
+ const key = trimmed.substring(0, eqIndex).trim();
37
+ const value = trimmed.substring(eqIndex + 1).trim();
38
+ // Only set if not already defined
39
+ if (!process.env[key]) {
40
+ process.env[key] = value;
41
+ }
42
+ }
43
+ });
44
+ console.log(`[openflows] Loaded environment from ${envPath}`);
45
+ return;
46
+ } catch (err) {
47
+ // Ignore errors
48
+ }
49
+ }
50
+ }
51
+ }
52
+
53
+ // Load .env file early
54
+ loadEnvFile();
55
+
18
56
  const binaryPath = path.join(__dirname, '..', 'bin', 'agentflow-bin');
19
57
  const PROXY_PORT = process.env.PROXY_PORT || 8765;
20
58
  const PROXY_STARTUP_TIMEOUT = 5000;
@@ -62,6 +100,12 @@ function needsProxy() {
62
100
  return { needed: true, reason: 'Gateway configured, no direct keys' };
63
101
  }
64
102
 
103
+ // Check if there's a .env file that might have config
104
+ const envPath = path.join(process.cwd(), '.env');
105
+ if (fs.existsSync(envPath)) {
106
+ return { needed: false, reason: 'No direct API key found, .env will be loaded by binary' };
107
+ }
108
+
65
109
  // No API config at all - let the binary handle the error
66
110
  return { needed: false, reason: 'No API config - will error in binary' };
67
111
  }
@@ -83,12 +127,26 @@ async function startProxy() {
83
127
  proxyBinary = altProxy;
84
128
  }
85
129
 
130
+ // Build proxy environment with all necessary variables
131
+ const proxyEnv = {
132
+ ...process.env,
133
+ PORT: PROXY_PORT.toString(),
134
+ RUST_LOG: process.env.RUST_LOG || 'info'
135
+ };
136
+
137
+ // Ensure gateway config is passed (for Fireworks or custom gateways)
138
+ if (process.env.FIREWORKS_API_KEY && !process.env.GATEWAY_URL) {
139
+ proxyEnv.GATEWAY_URL = 'https://api.fireworks.ai/inference/v1/';
140
+ proxyEnv.GATEWAY_API_KEY = process.env.FIREWORKS_API_KEY;
141
+ if (!process.env.MODEL_MAP) {
142
+ // Default model mapping for common Claude models to Fireworks
143
+ proxyEnv.MODEL_MAP = 'claude-haiku-4-5-20251001=accounts/fireworks/models/glm-5,claude-3-5-haiku-20241022=accounts/fireworks/models/glm-5';
144
+ }
145
+ console.log('[openflows] Configured proxy for Fireworks gateway');
146
+ }
147
+
86
148
  const proxy = spawn(proxyBinary, [], {
87
- env: {
88
- ...process.env,
89
- PORT: PROXY_PORT.toString(),
90
- RUST_LOG: process.env.RUST_LOG || 'info'
91
- },
149
+ env: proxyEnv,
92
150
  stdio: ['ignore', 'pipe', 'pipe']
93
151
  });
94
152
 
@@ -244,11 +302,23 @@ Documentation: https://openflows.dev
244
302
 
245
303
  if (proxyRunning) {
246
304
  console.log(`[openflows] ✓ Proxy already running on port ${PROXY_PORT}`);
305
+ // Set PROXY_URL for the main binary
306
+ env.PROXY_URL = `http://localhost:${PROXY_PORT}/v1`;
307
+ if (process.env.FIREWORKS_API_KEY) {
308
+ env.PROXY_API_KEY = process.env.FIREWORKS_API_KEY;
309
+ }
247
310
  } else {
248
311
  proxy = await startProxy();
249
312
  if (proxy) {
250
313
  // Set PROXY_URL for the main binary
251
314
  env.PROXY_URL = `http://localhost:${PROXY_PORT}/v1`;
315
+ // Set PROXY_API_KEY for authentication
316
+ if (process.env.FIREWORKS_API_KEY) {
317
+ env.PROXY_API_KEY = process.env.FIREWORKS_API_KEY;
318
+ } else if (process.env.GATEWAY_API_KEY) {
319
+ env.PROXY_API_KEY = process.env.GATEWAY_API_KEY;
320
+ }
321
+ console.log(`[openflows] ✓ Proxy started, PROXY_URL set to ${env.PROXY_URL}`);
252
322
  }
253
323
  }
254
324
  } else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@the-agenticflow/openflows",
3
- "version": "0.1.10",
3
+ "version": "0.1.12",
4
4
  "description": "Autonomous AI development team — turns GitHub issues into working PRs",
5
5
  "main": "index.js",
6
6
  "bin": {