openmagic 0.12.0 → 0.13.0
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/cli.js +19 -25
- package/dist/cli.js.map +1 -1
- package/dist/toolbar/index.global.js +34 -34
- package/dist/toolbar/index.global.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -68,8 +68,9 @@ function saveConfig(updates) {
|
|
|
68
68
|
const tmpFile = CONFIG_FILE + ".tmp";
|
|
69
69
|
writeFileSync(tmpFile, JSON.stringify(merged, null, 2), { encoding: "utf-8", mode: 384 });
|
|
70
70
|
renameSync(tmpFile, CONFIG_FILE);
|
|
71
|
+
return { ok: true };
|
|
71
72
|
} catch (e) {
|
|
72
|
-
|
|
73
|
+
return { ok: false, error: e.message };
|
|
73
74
|
}
|
|
74
75
|
}
|
|
75
76
|
|
|
@@ -78,7 +79,7 @@ import {
|
|
|
78
79
|
readFileSync as readFileSync2,
|
|
79
80
|
writeFileSync as writeFileSync2,
|
|
80
81
|
existsSync as existsSync2,
|
|
81
|
-
|
|
82
|
+
lstatSync,
|
|
82
83
|
readdirSync,
|
|
83
84
|
copyFileSync,
|
|
84
85
|
mkdirSync as mkdirSync2,
|
|
@@ -184,10 +185,11 @@ function listFiles(rootPath, roots, maxDepth = 4) {
|
|
|
184
185
|
const fullPath = join2(dir, item);
|
|
185
186
|
let stat;
|
|
186
187
|
try {
|
|
187
|
-
stat =
|
|
188
|
+
stat = lstatSync(fullPath);
|
|
188
189
|
} catch {
|
|
189
190
|
continue;
|
|
190
191
|
}
|
|
192
|
+
if (stat.isSymbolicLink()) continue;
|
|
191
193
|
const relPath = relative(rootPath, fullPath);
|
|
192
194
|
if (stat.isDirectory()) {
|
|
193
195
|
entries.push({ path: relPath, type: "dir", name: item });
|
|
@@ -1356,7 +1358,7 @@ async function handleLlmChat(params, onChunk, onDone, onError) {
|
|
|
1356
1358
|
}
|
|
1357
1359
|
|
|
1358
1360
|
// src/server.ts
|
|
1359
|
-
var VERSION = "0.
|
|
1361
|
+
var VERSION = "0.13.0";
|
|
1360
1362
|
var __dirname = dirname2(fileURLToPath(import.meta.url));
|
|
1361
1363
|
function attachOpenMagic(httpServer, roots) {
|
|
1362
1364
|
function handleRequest(req, res) {
|
|
@@ -1438,7 +1440,7 @@ async function handleMessage(ws, msg, state, roots) {
|
|
|
1438
1440
|
provider: config.provider,
|
|
1439
1441
|
model: config.model,
|
|
1440
1442
|
hasApiKey: !!config.apiKey,
|
|
1441
|
-
apiKeys: config.apiKeys || {}
|
|
1443
|
+
apiKeys: Object.fromEntries(Object.entries(config.apiKeys || {}).map(([k]) => [k, true]))
|
|
1442
1444
|
}
|
|
1443
1445
|
}
|
|
1444
1446
|
});
|
|
@@ -1504,7 +1506,7 @@ async function handleMessage(ws, msg, state, roots) {
|
|
|
1504
1506
|
await handleLlmChat(
|
|
1505
1507
|
{
|
|
1506
1508
|
provider,
|
|
1507
|
-
model: payload.model || config.model || "gpt-4o",
|
|
1509
|
+
model: payload.model || config.model || MODEL_REGISTRY[provider]?.models[0]?.id || "gpt-4o",
|
|
1508
1510
|
apiKey,
|
|
1509
1511
|
messages: payload.messages,
|
|
1510
1512
|
context: payload.context
|
|
@@ -1552,12 +1554,12 @@ async function handleMessage(ws, msg, state, roots) {
|
|
|
1552
1554
|
} else if (payload.apiKey !== void 0) {
|
|
1553
1555
|
updates.apiKey = payload.apiKey;
|
|
1554
1556
|
}
|
|
1555
|
-
saveConfig(updates);
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
payload: { ok: true }
|
|
1560
|
-
}
|
|
1557
|
+
const result = saveConfig(updates);
|
|
1558
|
+
if (!result.ok) {
|
|
1559
|
+
sendError(ws, "config_error", result.error || "Failed to save", msg.id);
|
|
1560
|
+
} else {
|
|
1561
|
+
send(ws, { id: msg.id, type: "config.saved", payload: { ok: true } });
|
|
1562
|
+
}
|
|
1561
1563
|
break;
|
|
1562
1564
|
}
|
|
1563
1565
|
default:
|
|
@@ -1637,6 +1639,7 @@ function createProxyServer(targetHost, targetPort, roots) {
|
|
|
1637
1639
|
delete headers["x-content-security-policy"];
|
|
1638
1640
|
delete headers["etag"];
|
|
1639
1641
|
delete headers["last-modified"];
|
|
1642
|
+
headers["cache-control"] = "no-store";
|
|
1640
1643
|
res.writeHead(proxyRes.statusCode || 200, headers);
|
|
1641
1644
|
res.end(body);
|
|
1642
1645
|
}).catch(() => {
|
|
@@ -1703,18 +1706,7 @@ async function collectBody(stream) {
|
|
|
1703
1706
|
}
|
|
1704
1707
|
}
|
|
1705
1708
|
function buildInjectionScript(token) {
|
|
1706
|
-
return
|
|
1707
|
-
<script data-openmagic="true">
|
|
1708
|
-
(function() {
|
|
1709
|
-
if (window.__OPENMAGIC_LOADED__) return;
|
|
1710
|
-
window.__OPENMAGIC_LOADED__ = true;
|
|
1711
|
-
window.__OPENMAGIC_TOKEN__ = "${token}";
|
|
1712
|
-
var s = document.createElement("script");
|
|
1713
|
-
s.src = "/__openmagic__/toolbar.js";
|
|
1714
|
-
s.dataset.openmagic = "true";
|
|
1715
|
-
document.body.appendChild(s);
|
|
1716
|
-
})();
|
|
1717
|
-
</script>`;
|
|
1709
|
+
return `<script src="/__openmagic__/toolbar.js?v=${Date.now()}" data-openmagic="true" data-openmagic-token="${token}" defer></script>`;
|
|
1718
1710
|
}
|
|
1719
1711
|
|
|
1720
1712
|
// src/detect.ts
|
|
@@ -1740,6 +1732,8 @@ var COMMON_DEV_PORTS = [
|
|
|
1740
1732
|
// Common alternate
|
|
1741
1733
|
4e3,
|
|
1742
1734
|
// Phoenix, generic
|
|
1735
|
+
5e3,
|
|
1736
|
+
// Flask
|
|
1743
1737
|
1234,
|
|
1744
1738
|
// Parcel
|
|
1745
1739
|
4321,
|
|
@@ -1891,7 +1885,7 @@ process.on("uncaughtException", (err) => {
|
|
|
1891
1885
|
process.exit(1);
|
|
1892
1886
|
});
|
|
1893
1887
|
var childProcesses = [];
|
|
1894
|
-
var VERSION2 = "0.
|
|
1888
|
+
var VERSION2 = "0.13.0";
|
|
1895
1889
|
function ask(question) {
|
|
1896
1890
|
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
1897
1891
|
return new Promise((resolve3) => {
|