apex-dev 3.10.17 → 3.10.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli.js +43 -7
- package/dist/index.js +13 -2
- package/package.json +1 -1
package/cli.js
CHANGED
|
@@ -152,10 +152,12 @@ function downloadBinary(destPath) {
|
|
|
152
152
|
|
|
153
153
|
return new Promise((resolve, reject) => {
|
|
154
154
|
const file = fs.createWriteStream(destPath, { mode: 0o755 });
|
|
155
|
-
|
|
156
|
-
|
|
155
|
+
const DOWNLOAD_TIMEOUT = 10000;
|
|
156
|
+
|
|
157
|
+
const req = https
|
|
158
|
+
.get(url, { timeout: DOWNLOAD_TIMEOUT }, (response) => {
|
|
157
159
|
if (response.statusCode === 302 || response.statusCode === 301) {
|
|
158
|
-
https.get(response.headers.location, (redirectRes) => {
|
|
160
|
+
const redirectReq = https.get(response.headers.location, { timeout: DOWNLOAD_TIMEOUT }, (redirectRes) => {
|
|
159
161
|
if (redirectRes.statusCode !== 200) {
|
|
160
162
|
reject(new Error(`Download failed with status ${redirectRes.statusCode}`));
|
|
161
163
|
return;
|
|
@@ -165,7 +167,12 @@ function downloadBinary(destPath) {
|
|
|
165
167
|
file.close();
|
|
166
168
|
resolve();
|
|
167
169
|
});
|
|
168
|
-
})
|
|
170
|
+
});
|
|
171
|
+
redirectReq.on("error", reject);
|
|
172
|
+
redirectReq.on("timeout", () => {
|
|
173
|
+
redirectReq.destroy();
|
|
174
|
+
reject(new Error("Download timed out after 10s"));
|
|
175
|
+
});
|
|
169
176
|
return;
|
|
170
177
|
}
|
|
171
178
|
if (response.statusCode !== 200) {
|
|
@@ -177,8 +184,13 @@ function downloadBinary(destPath) {
|
|
|
177
184
|
file.close();
|
|
178
185
|
resolve();
|
|
179
186
|
});
|
|
180
|
-
})
|
|
181
|
-
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
req.on("error", reject);
|
|
190
|
+
req.on("timeout", () => {
|
|
191
|
+
req.destroy();
|
|
192
|
+
reject(new Error("Download timed out after 10s"));
|
|
193
|
+
});
|
|
182
194
|
});
|
|
183
195
|
}
|
|
184
196
|
|
|
@@ -186,7 +198,17 @@ async function ensureBinary() {
|
|
|
186
198
|
const localPath = getLocalBinaryPath();
|
|
187
199
|
|
|
188
200
|
if (fs.existsSync(localPath)) {
|
|
189
|
-
|
|
201
|
+
// Check for empty/partial downloads and remove them
|
|
202
|
+
try {
|
|
203
|
+
const stat = fs.statSync(localPath);
|
|
204
|
+
if (stat.size === 0) {
|
|
205
|
+
fs.unlinkSync(localPath);
|
|
206
|
+
} else {
|
|
207
|
+
return localPath;
|
|
208
|
+
}
|
|
209
|
+
} catch {
|
|
210
|
+
try { fs.unlinkSync(localPath); } catch {}
|
|
211
|
+
}
|
|
190
212
|
}
|
|
191
213
|
|
|
192
214
|
try {
|
|
@@ -195,6 +217,7 @@ async function ensureBinary() {
|
|
|
195
217
|
return localPath;
|
|
196
218
|
} catch (err) {
|
|
197
219
|
console.error(`Failed to download binary: ${err.message}`);
|
|
220
|
+
try { fs.unlinkSync(localPath); } catch {}
|
|
198
221
|
return null;
|
|
199
222
|
}
|
|
200
223
|
}
|
|
@@ -221,6 +244,10 @@ function runWithBun() {
|
|
|
221
244
|
const child = spawn(bunPath, [distPath, ...process.argv.slice(2)], {
|
|
222
245
|
stdio: "inherit",
|
|
223
246
|
});
|
|
247
|
+
child.on("error", (err) => {
|
|
248
|
+
console.error(`Failed to launch bun: ${err.message}`);
|
|
249
|
+
process.exit(1);
|
|
250
|
+
});
|
|
224
251
|
child.on("exit", (code) => {
|
|
225
252
|
process.exit(code || 0);
|
|
226
253
|
});
|
|
@@ -229,6 +256,10 @@ function runWithBun() {
|
|
|
229
256
|
const child = spawn(bunPath, [scriptPath, ...process.argv.slice(2)], {
|
|
230
257
|
stdio: "inherit",
|
|
231
258
|
});
|
|
259
|
+
child.on("error", (err) => {
|
|
260
|
+
console.error(`Failed to launch bun: ${err.message}`);
|
|
261
|
+
process.exit(1);
|
|
262
|
+
});
|
|
232
263
|
child.on("exit", (code) => {
|
|
233
264
|
process.exit(code || 0);
|
|
234
265
|
});
|
|
@@ -295,6 +326,7 @@ async function ensureApiKeys() {
|
|
|
295
326
|
console.error(`\n\u2713 ${configured.length} provider(s) configured`);
|
|
296
327
|
} else {
|
|
297
328
|
console.error("\n\u26A0 No API keys configured. Launching interactive provider selection.");
|
|
329
|
+
process.env.APEX_DEV_NEEDS_CONFIG = "true";
|
|
298
330
|
}
|
|
299
331
|
}
|
|
300
332
|
|
|
@@ -328,6 +360,10 @@ async function main() {
|
|
|
328
360
|
const child = spawn(binaryPath, args, {
|
|
329
361
|
stdio: "inherit",
|
|
330
362
|
});
|
|
363
|
+
child.on("error", (err) => {
|
|
364
|
+
console.error(`Failed to launch binary: ${err.message}`);
|
|
365
|
+
process.exit(1);
|
|
366
|
+
});
|
|
331
367
|
child.on("exit", (code) => {
|
|
332
368
|
process.exit(code || 0);
|
|
333
369
|
});
|
package/dist/index.js
CHANGED
|
@@ -301,6 +301,8 @@ var require_utils3 = __commonJS((exports, module2) => {
|
|
|
301
301
|
});
|
|
302
302
|
var require_config = __commonJS((exports, module) => {
|
|
303
303
|
const OpenAI = __require("openai");
|
|
304
|
+
const fs = __require("fs");
|
|
305
|
+
const path = __require("path");
|
|
304
306
|
const PROVIDERS = {
|
|
305
307
|
fireworks: {
|
|
306
308
|
label: "Fireworks AI",
|
|
@@ -866,6 +868,15 @@ The user asks you to implement a new feature. You respond in multiple steps:
|
|
|
866
868
|
minimax: { model: "minimax/minimax-01", temperature: 0.1, maxTokens: 8192 }
|
|
867
869
|
};
|
|
868
870
|
const _initialProvider = PROVIDERS[currentProvider];
|
|
871
|
+
try {
|
|
872
|
+
const configPath = path.join(__require("os").homedir(), ".apex-dev", "config.json");
|
|
873
|
+
if (fs.existsSync(configPath)) {
|
|
874
|
+
const savedConfig = JSON.parse(fs.readFileSync(configPath, "utf-8"));
|
|
875
|
+
if (savedConfig[currentProvider] && !process.env[_initialProvider.envKey]) {
|
|
876
|
+
process.env[_initialProvider.envKey] = savedConfig[currentProvider];
|
|
877
|
+
}
|
|
878
|
+
}
|
|
879
|
+
} catch (e) {}
|
|
869
880
|
const _initialKey = process.env[_initialProvider.envKey] || "no-key";
|
|
870
881
|
let _internalClient = new OpenAI({
|
|
871
882
|
apiKey: _initialKey,
|
|
@@ -947,7 +958,6 @@ The user asks you to implement a new feature. You respond in multiple steps:
|
|
|
947
958
|
}
|
|
948
959
|
return str;
|
|
949
960
|
}
|
|
950
|
-
const path = __require("path");
|
|
951
961
|
function resolvePath(p) {
|
|
952
962
|
if (!p)
|
|
953
963
|
return PROJECT_ROOT;
|
|
@@ -2985,7 +2995,7 @@ var require_agent = __commonJS((exports, module2) => {
|
|
|
2985
2995
|
});
|
|
2986
2996
|
break;
|
|
2987
2997
|
} catch (apiErr) {
|
|
2988
|
-
if (attempt < maxRetries && apiErr.status
|
|
2998
|
+
if (attempt < maxRetries && (!apiErr.status || apiErr.status >= 500)) {
|
|
2989
2999
|
await sleep(1000 * Math.pow(2, attempt));
|
|
2990
3000
|
continue;
|
|
2991
3001
|
}
|
|
@@ -4703,6 +4713,7 @@ function App() {
|
|
|
4703
4713
|
]
|
|
4704
4714
|
});
|
|
4705
4715
|
}
|
|
4716
|
+
globalThis._App = App;
|
|
4706
4717
|
async function main2() {
|
|
4707
4718
|
if (process.env.APEX_LOCAL_SERVER === "1") {
|
|
4708
4719
|
const srv = globalThis.require_server ? globalThis.require_server() : null;
|