@chosengeneration/light-code 0.198.0 → 0.199.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.cjs +45 -32
- package/dist/server.cjs +42 -29
- package/package.json +1 -1
package/dist/server.cjs
CHANGED
|
@@ -90543,11 +90543,11 @@ ${preview.text}` } : {}
|
|
|
90543
90543
|
const combined = new ToolRegistry();
|
|
90544
90544
|
for (const tool of builtinTools.list())
|
|
90545
90545
|
combined.register(tool);
|
|
90546
|
-
const chrome =
|
|
90547
|
-
mcp.reserve(chrome !== void 0
|
|
90546
|
+
const chrome = webChatServer();
|
|
90547
|
+
mcp.reserve(chrome !== void 0 ? [chrome] : []);
|
|
90548
90548
|
for (const tool of mcp.enabledTools())
|
|
90549
90549
|
combined.register(tool, { dispatchOnly: dispatcher });
|
|
90550
|
-
if (chrome !== void 0 && webChatFile !== void 0)
|
|
90550
|
+
if (chrome !== void 0 && webChatFile !== void 0 && cachedWebChat !== void 0)
|
|
90551
90551
|
combined.register(createAskWebChatTool(webChatTool));
|
|
90552
90552
|
for (const tool of python.managementTools())
|
|
90553
90553
|
combined.register(tool);
|
|
@@ -91308,14 +91308,12 @@ ${error51.stack.split("\n").slice(1, 6).join("\n")}`;
|
|
|
91308
91308
|
cachedWebChat = webChatFile === void 0 ? void 0 : await readWebChatSetup(webChatFile);
|
|
91309
91309
|
return cachedWebChat;
|
|
91310
91310
|
}
|
|
91311
|
-
function
|
|
91312
|
-
|
|
91313
|
-
|
|
91314
|
-
|
|
91315
|
-
|
|
91316
|
-
|
|
91317
|
-
}
|
|
91318
|
-
return void 0;
|
|
91311
|
+
function chromeServers() {
|
|
91312
|
+
return mcp.states_().filter((state) => state.enabled && state.status === "ready" && isChromeDevToolsServer(state.tools.map((tool) => tool.name))).map((state) => state.name);
|
|
91313
|
+
}
|
|
91314
|
+
function webChatServer() {
|
|
91315
|
+
const chosen = webChatCapture?.server ?? cachedWebChat?.server;
|
|
91316
|
+
return chosen !== void 0 && chromeServers().includes(chosen) ? chosen : void 0;
|
|
91319
91317
|
}
|
|
91320
91318
|
function chromeAccess(server) {
|
|
91321
91319
|
return {
|
|
@@ -91354,10 +91352,9 @@ ${error51.stack.split("\n").slice(1, 6).join("\n")}`;
|
|
|
91354
91352
|
webChatHostChecks.set(pageUrl, { at: Date.now(), problem });
|
|
91355
91353
|
return problem;
|
|
91356
91354
|
}
|
|
91357
|
-
async function webChatProblem(pageUrl) {
|
|
91358
|
-
const server = chromeServer();
|
|
91355
|
+
async function webChatProblem(pageUrl, server) {
|
|
91359
91356
|
if (server === void 0)
|
|
91360
|
-
return "
|
|
91357
|
+
return "The Chrome DevTools MCP server chosen for the web chat is not connected (Settings \u2192 Agents \u2192 Web chat, and Settings \u2192 MCP).";
|
|
91361
91358
|
const problems = await chromeProblems(server);
|
|
91362
91359
|
if (problems.length > 0)
|
|
91363
91360
|
return `The Chrome DevTools MCP server "${server}" may not be used for the web chat: ${problems.join(" ")}`;
|
|
@@ -91374,19 +91371,19 @@ ${error51.stack.split("\n").slice(1, 6).join("\n")}`;
|
|
|
91374
91371
|
},
|
|
91375
91372
|
problem: async () => {
|
|
91376
91373
|
const setup = cachedWebChat ?? await loadWebChat();
|
|
91377
|
-
return setup === void 0 ? "The web chat is not set up." : webChatProblem(setup.pageUrl);
|
|
91374
|
+
return setup === void 0 ? "The web chat is not set up." : webChatProblem(setup.pageUrl, webChatServer());
|
|
91378
91375
|
},
|
|
91379
91376
|
ask: async (question) => {
|
|
91380
91377
|
const setup = cachedWebChat ?? await loadWebChat();
|
|
91381
|
-
const server =
|
|
91378
|
+
const server = webChatServer();
|
|
91382
91379
|
if (setup === void 0 || server === void 0)
|
|
91383
|
-
throw new Error("The web chat or
|
|
91380
|
+
throw new Error("The web chat or its Chrome DevTools MCP server is not available.");
|
|
91384
91381
|
return askWebChat(chromeAccess(server), setup, question);
|
|
91385
91382
|
}
|
|
91386
91383
|
};
|
|
91387
91384
|
async function postWebChat(message6) {
|
|
91388
91385
|
const setup = await loadWebChat();
|
|
91389
|
-
const
|
|
91386
|
+
const servers = chromeServers();
|
|
91390
91387
|
post({
|
|
91391
91388
|
type: "webChat",
|
|
91392
91389
|
available: webChatFile !== void 0,
|
|
@@ -91401,7 +91398,10 @@ ${error51.stack.split("\n").slice(1, 6).join("\n")}`;
|
|
|
91401
91398
|
capturedAt: setup.capturedAt
|
|
91402
91399
|
}
|
|
91403
91400
|
} : {},
|
|
91404
|
-
chrome: {
|
|
91401
|
+
chrome: {
|
|
91402
|
+
servers: await Promise.all(servers.map(async (name) => ({ name, problems: await chromeProblems(name) }))),
|
|
91403
|
+
...setup?.server !== void 0 ? { chosen: setup.server } : {}
|
|
91404
|
+
},
|
|
91405
91405
|
...setup !== void 0 ? { hostProblem: await hostProblem(setup.pageUrl).catch((error51) => String(error51)) ?? "" } : {},
|
|
91406
91406
|
...message6 !== void 0 ? { message: message6 } : {}
|
|
91407
91407
|
});
|
|
@@ -91411,14 +91411,14 @@ ${error51.stack.split("\n").slice(1, 6).join("\n")}`;
|
|
|
91411
91411
|
clearInterval(webChatCapture.timer);
|
|
91412
91412
|
webChatCapture = void 0;
|
|
91413
91413
|
}
|
|
91414
|
-
async function startWebChatCapture(pageUrl) {
|
|
91414
|
+
async function startWebChatCapture(pageUrl, chosen) {
|
|
91415
91415
|
stopWebChatCapture();
|
|
91416
|
-
const problem = await webChatProblem(pageUrl);
|
|
91416
|
+
const problem = await webChatProblem(pageUrl, chromeServers().includes(chosen) ? chosen : void 0);
|
|
91417
91417
|
if (problem !== void 0) {
|
|
91418
91418
|
post({ type: "webChatCapture", phase: "failed", message: problem });
|
|
91419
91419
|
return;
|
|
91420
91420
|
}
|
|
91421
|
-
const server =
|
|
91421
|
+
const server = chosen;
|
|
91422
91422
|
const chrome = chromeAccess(server);
|
|
91423
91423
|
const origin = new URL(pageUrl).origin;
|
|
91424
91424
|
const phrase = capturePhrase();
|
|
@@ -91429,7 +91429,7 @@ ${error51.stack.split("\n").slice(1, 6).join("\n")}`;
|
|
|
91429
91429
|
post({ type: "webChatCapture", phase: "failed", message: String(installed["error"] ?? "The page could not be watched.") });
|
|
91430
91430
|
return;
|
|
91431
91431
|
}
|
|
91432
|
-
webChatCapture = { pageUrl, phrase, startedAt: Date.now(), candidates: [] };
|
|
91432
|
+
webChatCapture = { pageUrl, server, phrase, startedAt: Date.now(), candidates: [] };
|
|
91433
91433
|
post({ type: "webChatCapture", phase: "waiting", phrase });
|
|
91434
91434
|
const capture = webChatCapture;
|
|
91435
91435
|
let polling = false;
|
|
@@ -99689,10 +99689,10 @@ ${answer.slice(0, 16e3)}` } }, (d) => d.best !== void 0 && d.best.probability >=
|
|
|
99689
99689
|
} else if (message6.type === "requestWebChat") {
|
|
99690
99690
|
reportFailure("postWebChat", postWebChat());
|
|
99691
99691
|
} else if (message6.type === "startWebChatCapture") {
|
|
99692
|
-
void startWebChatCapture(message6.pageUrl.trim()).catch((error51) => post({ type: "webChatCapture", phase: "failed", message: error51 instanceof Error ? error51.message : String(error51) }));
|
|
99692
|
+
void startWebChatCapture(message6.pageUrl.trim(), message6.server).catch((error51) => post({ type: "webChatCapture", phase: "failed", message: error51 instanceof Error ? error51.message : String(error51) }));
|
|
99693
99693
|
} else if (message6.type === "sendWebChatPhrase") {
|
|
99694
99694
|
const capture = webChatCapture;
|
|
99695
|
-
const server =
|
|
99695
|
+
const server = capture?.server;
|
|
99696
99696
|
if (capture !== void 0 && server !== void 0) {
|
|
99697
99697
|
void runScript(chromeAccess(server), typePhraseScript(new URL(capture.pageUrl).origin, capture.phrase)).then((done) => {
|
|
99698
99698
|
if (done["ok"] !== true)
|
|
@@ -99701,15 +99701,24 @@ ${answer.slice(0, 16e3)}` } }, (d) => d.best !== void 0 && d.best.probability >=
|
|
|
99701
99701
|
}
|
|
99702
99702
|
} else if (message6.type === "confirmWebChatCapture") {
|
|
99703
99703
|
const chosen = webChatCapture?.candidates[message6.index];
|
|
99704
|
+
const chosenServer = webChatCapture?.server;
|
|
99704
99705
|
stopWebChatCapture();
|
|
99705
99706
|
if (chosen === void 0 || webChatFile === void 0) {
|
|
99706
99707
|
void postWebChat("Nothing to save: capture again.");
|
|
99707
99708
|
} else {
|
|
99708
|
-
void writeWebChatSetup(webChatFile, chosen.setup).then(() => postWebChat(`Saved. Consultations go to ${chosen.backend} only.`)).catch((error51) => postWebChat(`Could not save: ${error51 instanceof Error ? error51.message : String(error51)}`));
|
|
99709
|
+
void writeWebChatSetup(webChatFile, { ...chosen.setup, server: chosenServer }).then(() => postWebChat(`Saved. Consultations go to ${chosen.backend} only.`)).catch((error51) => postWebChat(`Could not save: ${error51 instanceof Error ? error51.message : String(error51)}`));
|
|
99709
99710
|
}
|
|
99710
99711
|
} else if (message6.type === "cancelWebChatCapture") {
|
|
99711
99712
|
stopWebChatCapture();
|
|
99712
99713
|
void postWebChat();
|
|
99714
|
+
} else if (message6.type === "setWebChatServer") {
|
|
99715
|
+
void (async () => {
|
|
99716
|
+
const setup = await loadWebChat();
|
|
99717
|
+
if (setup === void 0 || webChatFile === void 0)
|
|
99718
|
+
return;
|
|
99719
|
+
await writeWebChatSetup(webChatFile, { ...setup, server: message6.server });
|
|
99720
|
+
await postWebChat(`The web chat now uses "${message6.server}". Any other Chrome server is left as it was.`);
|
|
99721
|
+
})();
|
|
99713
99722
|
} else if (message6.type === "setWebChatModel") {
|
|
99714
99723
|
void (async () => {
|
|
99715
99724
|
const setup = await loadWebChat();
|
|
@@ -106043,7 +106052,9 @@ DevTools MCP server. Set it up in Settings \u2192 Agents \u2192 **Web chat**; it
|
|
|
106043
106052
|
DevTools MCP server is connected, and never on a shared server.
|
|
106044
106053
|
|
|
106045
106054
|
**Setting it up (once, for every chat and codebase on this PC):**
|
|
106046
|
-
1.
|
|
106055
|
+
1. **Give the web chat a Chrome DevTools MCP server of its own** - a second entry in Settings \u2192 MCP under its own name
|
|
106056
|
+
(e.g. chrome-webchat), so any Chrome server you already use is left exactly as it is - and choose it in the Web chat
|
|
106057
|
+
panel. Add it with \`--autoConnect\`, \`--no-usage-statistics\` and
|
|
106047
106058
|
\`--no-performance-crux\` (the panel shows the entry to paste), and allow it in Chrome at
|
|
106048
106059
|
chrome://inspect/#remote-debugging. Either installed once (\`npm i -g chrome-devtools-mcp\`), or run with **npx** -
|
|
106049
106060
|
allowed when npm downloads from your organisation's registry (an Artifactory inside the network, checked with
|
|
@@ -106062,8 +106073,10 @@ DevTools MCP server is connected, and never on a shared server.
|
|
|
106062
106073
|
- The Chrome DevTools MCP server must run on this PC (not a remote server) - installed, or through npx only when npm's
|
|
106063
106074
|
registry is inside the network and the version is pinned - with its reporting to Google off (both flags above),
|
|
106064
106075
|
attached to this PC's Chrome only.
|
|
106065
|
-
- **The assistant never gets
|
|
106066
|
-
|
|
106076
|
+
- **The assistant never gets the web chat's Chrome server's tools**: it cannot open a page, click or run anything
|
|
106077
|
+
through it - \`ask_web_chat\` and its one approved request are the only way in. Its tools are replaced by that one
|
|
106078
|
+
tool, so the assistant is given fewer tools, not more. Any other Chrome server you have is untouched - and with it the
|
|
106079
|
+
assistant can still browse as before, with your approvals; only the web chat's server is held to these rules.
|
|
106067
106080
|
- Every consultation asks you first, showing the exact text and the backend address. Never in scheduled runs.
|
|
106068
106081
|
|
|
106069
106082
|
What stays outside Light Code's control: where your organisation's web chat itself sends what it is given - the same as
|