myaiforone 1.1.26 → 1.1.28
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/dist/web-ui.d.ts.map +1 -1
- package/dist/web-ui.js +38 -32
- package/dist/web-ui.js.map +1 -1
- package/package.json +1 -1
- package/scripts/install-service-windows.ps1 +5 -5
- package/scripts/uninstall-service-windows.ps1 +3 -3
- package/src/web-ui.ts +34 -31
package/dist/web-ui.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web-ui.d.ts","sourceRoot":"","sources":["../src/web-ui.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAa7C,UAAU,YAAY;IACpB,MAAM,EAAE,SAAS,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,gBAAgB,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACrG,SAAS,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,qBAAqB,EAAE,aAAa,CAAC,CAAC;CACtE;AAyBD,wBAAgB,UAAU,CAAC,IAAI,EAAE,YAAY,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"web-ui.d.ts","sourceRoot":"","sources":["../src/web-ui.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAa7C,UAAU,YAAY;IACpB,MAAM,EAAE,SAAS,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,gBAAgB,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACrG,SAAS,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,qBAAqB,EAAE,aAAa,CAAC,CAAC;CACtE;AAyBD,wBAAgB,UAAU,CAAC,IAAI,EAAE,YAAY,GAAG,IAAI,CA+oLnD"}
|
package/dist/web-ui.js
CHANGED
|
@@ -34,17 +34,25 @@ export function startWebUI(opts) {
|
|
|
34
34
|
}));
|
|
35
35
|
// Helper: serve an HTML page from public/ using root-relative path
|
|
36
36
|
// (avoids sendFile symlink/realpath issues on macOS npx cache)
|
|
37
|
-
|
|
37
|
+
// fallback: URL to redirect to if file missing, or null for 404
|
|
38
|
+
const servePage = (res, filename, fallback = null) => {
|
|
38
39
|
if (existsSync(join(publicDir, filename))) {
|
|
39
40
|
res.setHeader("Cache-Control", "no-cache, no-store, must-revalidate");
|
|
40
41
|
res.sendFile(filename, { root: publicDir }, (err) => {
|
|
41
|
-
if (err && !res.headersSent)
|
|
42
|
-
|
|
42
|
+
if (err && !res.headersSent) {
|
|
43
|
+
if (fallback)
|
|
44
|
+
res.redirect(fallback);
|
|
45
|
+
else
|
|
46
|
+
res.status(404).send(`${filename} not found.`);
|
|
47
|
+
}
|
|
43
48
|
});
|
|
44
49
|
}
|
|
45
|
-
else {
|
|
50
|
+
else if (fallback) {
|
|
46
51
|
res.redirect(fallback);
|
|
47
52
|
}
|
|
53
|
+
else {
|
|
54
|
+
res.status(404).send(`${filename} not found.`);
|
|
55
|
+
}
|
|
48
56
|
};
|
|
49
57
|
// ─── Mount Gym API routes (gated by gymEnabled in the router) ────
|
|
50
58
|
if (opts.config.service.gymEnabled) {
|
|
@@ -2530,7 +2538,10 @@ export function startWebUI(opts) {
|
|
|
2530
2538
|
res.setHeader("Content-Disposition", `${isInline ? "inline" : "attachment"}; filename="${fileName}"`);
|
|
2531
2539
|
res.setHeader("Content-Type", contentTypes[ext] || "application/octet-stream");
|
|
2532
2540
|
log.info(`[Download] ${agentId}: ${fileName} from ${resolvedPath}`);
|
|
2533
|
-
res.sendFile(resolvedPath)
|
|
2541
|
+
res.sendFile(basename(resolvedPath), { root: dirname(resolvedPath) }, (err) => {
|
|
2542
|
+
if (err && !res.headersSent)
|
|
2543
|
+
res.status(404).json({ error: "File send failed" });
|
|
2544
|
+
});
|
|
2534
2545
|
});
|
|
2535
2546
|
// ─── API: Create agent ──────────────────────────────────────────
|
|
2536
2547
|
app.post("/api/agents", async (req, res) => {
|
|
@@ -5227,7 +5238,7 @@ Project context and credentials are at: ${projectDir}/context.md and ${projectDi
|
|
|
5227
5238
|
// KeepAlive disabled. Spawning ensures the service always comes back.
|
|
5228
5239
|
const child = cpSpawn(process.execPath, process.argv.slice(1), {
|
|
5229
5240
|
cwd: process.cwd(),
|
|
5230
|
-
env: process.env,
|
|
5241
|
+
env: { ...process.env },
|
|
5231
5242
|
stdio: "ignore",
|
|
5232
5243
|
detached: true,
|
|
5233
5244
|
});
|
|
@@ -5253,14 +5264,20 @@ Project context and credentials are at: ${projectDir}/context.md and ${projectDi
|
|
|
5253
5264
|
let latest = current;
|
|
5254
5265
|
let updateAvailable = false;
|
|
5255
5266
|
try {
|
|
5256
|
-
const resp = await fetch("https://registry.npmjs.org/myaiforone/latest"
|
|
5267
|
+
const resp = await fetch("https://registry.npmjs.org/myaiforone/latest", {
|
|
5268
|
+
signal: AbortSignal.timeout(5000),
|
|
5269
|
+
});
|
|
5257
5270
|
if (resp.ok) {
|
|
5258
5271
|
const data = await resp.json();
|
|
5259
5272
|
latest = data.version || current;
|
|
5260
|
-
|
|
5273
|
+
// Semver comparison: only flag update if latest is actually newer
|
|
5274
|
+
const parse = (v) => v.split(".").map(Number);
|
|
5275
|
+
const [cMaj, cMin, cPat] = parse(current);
|
|
5276
|
+
const [lMaj, lMin, lPat] = parse(latest);
|
|
5277
|
+
updateAvailable = lMaj > cMaj || (lMaj === cMaj && lMin > cMin) || (lMaj === cMaj && lMin === cMin && lPat > cPat);
|
|
5261
5278
|
}
|
|
5262
5279
|
}
|
|
5263
|
-
catch { /* offline
|
|
5280
|
+
catch { /* offline or timeout */ }
|
|
5264
5281
|
res.json({ ok: true, current, latest, updateAvailable });
|
|
5265
5282
|
}
|
|
5266
5283
|
catch (e) {
|
|
@@ -5273,37 +5290,26 @@ Project context and credentials are at: ${projectDir}/context.md and ${projectDi
|
|
|
5273
5290
|
const platform = process.platform;
|
|
5274
5291
|
log.info("[Update] Platform update triggered via API");
|
|
5275
5292
|
// Clear npx cache for myaiforone
|
|
5276
|
-
|
|
5277
|
-
|
|
5278
|
-
|
|
5279
|
-
|
|
5280
|
-
|
|
5281
|
-
|
|
5282
|
-
|
|
5283
|
-
|
|
5284
|
-
}
|
|
5293
|
+
const npxDir = platform === "win32"
|
|
5294
|
+
? join(process.env.LOCALAPPDATA || "", "npm-cache", "_npx")
|
|
5295
|
+
: join(process.env.HOME || "", ".npm", "_npx");
|
|
5296
|
+
if (existsSync(npxDir)) {
|
|
5297
|
+
for (const d of readdirSync(npxDir)) {
|
|
5298
|
+
const candidate = join(npxDir, d, "node_modules", "myaiforone");
|
|
5299
|
+
if (existsSync(candidate)) {
|
|
5300
|
+
rmSync(join(npxDir, d), { recursive: true, force: true });
|
|
5301
|
+
log.info(`[Update] Cleared npx cache: ${d}`);
|
|
5285
5302
|
}
|
|
5286
5303
|
}
|
|
5287
5304
|
}
|
|
5288
5305
|
else {
|
|
5289
|
-
|
|
5290
|
-
const home = process.env.HOME || "";
|
|
5291
|
-
const npxDir = join(home, ".npm", "_npx");
|
|
5292
|
-
if (existsSync(npxDir)) {
|
|
5293
|
-
for (const d of readdirSync(npxDir)) {
|
|
5294
|
-
const candidate = join(npxDir, d, "node_modules", "myaiforone");
|
|
5295
|
-
if (existsSync(candidate)) {
|
|
5296
|
-
rmSync(join(npxDir, d), { recursive: true, force: true });
|
|
5297
|
-
log.info(`[Update] Cleared npx cache: ${d}`);
|
|
5298
|
-
}
|
|
5299
|
-
}
|
|
5300
|
-
}
|
|
5306
|
+
log.warn(`[Update] npx cache dir not found: ${npxDir}`);
|
|
5301
5307
|
}
|
|
5302
5308
|
res.json({ ok: true, message: "Cache cleared. Restarting with latest version..." });
|
|
5303
5309
|
// Respawn via npx to pull latest, then exit current process
|
|
5304
5310
|
setTimeout(() => {
|
|
5305
|
-
log.info("[Update] Spawning npx myaiforone to pull latest...");
|
|
5306
|
-
const child = cpSpawn("npx", ["myaiforone"], {
|
|
5311
|
+
log.info("[Update] Spawning npx myaiforone@latest to pull latest...");
|
|
5312
|
+
const child = cpSpawn("npx", ["myaiforone@latest"], {
|
|
5307
5313
|
cwd: process.cwd(),
|
|
5308
5314
|
env: { ...process.env },
|
|
5309
5315
|
stdio: "ignore",
|