@chosengeneration/light-code 0.199.0 → 0.202.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 -68
- package/dist/server.cjs +40 -63
- package/package.json +1 -1
package/dist/server.cjs
CHANGED
|
@@ -437,7 +437,7 @@ var require_util = __commonJS({
|
|
|
437
437
|
var { kDestroyed, kBodyUsed } = require_symbols();
|
|
438
438
|
var { IncomingMessage } = require("http");
|
|
439
439
|
var stream = require("stream");
|
|
440
|
-
var
|
|
440
|
+
var net = require("net");
|
|
441
441
|
var { InvalidArgumentError } = require_errors();
|
|
442
442
|
var { Blob: Blob2 } = require("buffer");
|
|
443
443
|
var nodeUtil = require("util");
|
|
@@ -528,7 +528,7 @@ var require_util = __commonJS({
|
|
|
528
528
|
}
|
|
529
529
|
assert2.strictEqual(typeof host, "string");
|
|
530
530
|
const servername = getHostname(host);
|
|
531
|
-
if (
|
|
531
|
+
if (net.isIP(servername)) {
|
|
532
532
|
return "";
|
|
533
533
|
}
|
|
534
534
|
return servername;
|
|
@@ -5682,7 +5682,7 @@ var require_dispatcher_base = __commonJS({
|
|
|
5682
5682
|
var require_connect = __commonJS({
|
|
5683
5683
|
"../../node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/core/connect.js"(exports2, module2) {
|
|
5684
5684
|
"use strict";
|
|
5685
|
-
var
|
|
5685
|
+
var net = require("net");
|
|
5686
5686
|
var assert2 = require("assert");
|
|
5687
5687
|
var util = require_util();
|
|
5688
5688
|
var { InvalidArgumentError, ConnectTimeoutError } = require_errors();
|
|
@@ -5773,7 +5773,7 @@ var require_connect = __commonJS({
|
|
|
5773
5773
|
});
|
|
5774
5774
|
} else {
|
|
5775
5775
|
assert2(!httpSocket, "httpSocket can only be sent on TLS update");
|
|
5776
|
-
socket =
|
|
5776
|
+
socket = net.connect({
|
|
5777
5777
|
highWaterMark: 64 * 1024,
|
|
5778
5778
|
// Same as nodejs fs streams.
|
|
5779
5779
|
...options,
|
|
@@ -6366,7 +6366,7 @@ var require_client = __commonJS({
|
|
|
6366
6366
|
"../../node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/client.js"(exports2, module2) {
|
|
6367
6367
|
"use strict";
|
|
6368
6368
|
var assert2 = require("assert");
|
|
6369
|
-
var
|
|
6369
|
+
var net = require("net");
|
|
6370
6370
|
var http = require("http");
|
|
6371
6371
|
var { pipeline } = require("stream");
|
|
6372
6372
|
var util = require_util();
|
|
@@ -6558,7 +6558,7 @@ var require_client = __commonJS({
|
|
|
6558
6558
|
if (maxRequestsPerClient != null && (!Number.isInteger(maxRequestsPerClient) || maxRequestsPerClient < 0)) {
|
|
6559
6559
|
throw new InvalidArgumentError("maxRequestsPerClient must be a positive number");
|
|
6560
6560
|
}
|
|
6561
|
-
if (localAddress != null && (typeof localAddress !== "string" ||
|
|
6561
|
+
if (localAddress != null && (typeof localAddress !== "string" || net.isIP(localAddress) === 0)) {
|
|
6562
6562
|
throw new InvalidArgumentError("localAddress must be valid string IP address");
|
|
6563
6563
|
}
|
|
6564
6564
|
if (maxResponseSize != null && (!Number.isInteger(maxResponseSize) || maxResponseSize < -1)) {
|
|
@@ -7248,7 +7248,7 @@ var require_client = __commonJS({
|
|
|
7248
7248
|
const idx = hostname3.indexOf("]");
|
|
7249
7249
|
assert2(idx !== -1);
|
|
7250
7250
|
const ip = hostname3.substring(1, idx);
|
|
7251
|
-
assert2(
|
|
7251
|
+
assert2(net.isIP(ip));
|
|
7252
7252
|
hostname3 = ip;
|
|
7253
7253
|
}
|
|
7254
7254
|
client[kConnecting] = true;
|
|
@@ -67124,8 +67124,6 @@ function fillBody(setup, question) {
|
|
|
67124
67124
|
}
|
|
67125
67125
|
|
|
67126
67126
|
// ../../packages/core/dist/webchat/guard.js
|
|
67127
|
-
var import_node_dns = require("node:dns");
|
|
67128
|
-
var import_node_net2 = __toESM(require("node:net"), 1);
|
|
67129
67127
|
var REQUIRED_CHROME_FLAGS = ["--no-usage-statistics", "--no-performance-crux"];
|
|
67130
67128
|
function npxPackage(args) {
|
|
67131
67129
|
for (let i = 0; i < args.length; i += 1) {
|
|
@@ -67143,26 +67141,24 @@ function npxPackage(args) {
|
|
|
67143
67141
|
function isPinned(spec) {
|
|
67144
67142
|
return /^(@[^/\s]+\/)?[^@\s]+@\d+\.\d+\.\d+(-[0-9A-Za-z.-]+)?$/.test(spec);
|
|
67145
67143
|
}
|
|
67146
|
-
function chromeServerProblems(config2
|
|
67144
|
+
function chromeServerProblems(config2) {
|
|
67147
67145
|
if (config2 === void 0)
|
|
67148
67146
|
return ["No Chrome DevTools MCP server is configured."];
|
|
67149
67147
|
const record2 = config2;
|
|
67150
67148
|
if (typeof record2.url === "string" || typeof record2.command !== "string")
|
|
67151
67149
|
return ["The Chrome DevTools MCP server must run on this PC (a command), not as a remote server at a URL."];
|
|
67152
67150
|
const problems = [];
|
|
67153
|
-
const
|
|
67154
|
-
const
|
|
67151
|
+
const words2 = commandWords([record2.command, ...record2.args ?? []].join(" "));
|
|
67152
|
+
const command = words2[0] ?? record2.command;
|
|
67153
|
+
const args = words2.slice(1);
|
|
67154
|
+
const runner = command.split(/[\\/]/).pop()?.toLowerCase() ?? "";
|
|
67155
67155
|
if (runner === "npx" || runner === "npx.cmd") {
|
|
67156
67156
|
const spec = npxPackage(args);
|
|
67157
67157
|
if (spec === void 0 || !isPinned(spec)) {
|
|
67158
67158
|
problems.push(`With npx the version must be pinned (e.g. chrome-devtools-mcp@1.13.0, not ${spec ?? "no version"}), so an unreviewed new version is never run.`);
|
|
67159
67159
|
}
|
|
67160
|
-
|
|
67161
|
-
|
|
67162
|
-
else if (npmRegistry.problem !== void 0)
|
|
67163
|
-
problems.push(`npx downloads from npm's registry ${npmRegistry.registry}: ${npmRegistry.problem}`);
|
|
67164
|
-
} else if (isPackageRunnerCommand(record2.command)) {
|
|
67165
|
-
problems.push(`It is started with ${record2.command}, which downloads the package each start. Use npx (with a pinned version and the organisation's registry) or an installed copy.`);
|
|
67160
|
+
} else if (isPackageRunnerCommand(command)) {
|
|
67161
|
+
problems.push(`It is started with ${command}, which downloads the package each start. Use npx (with a pinned version and the organisation's registry) or an installed copy.`);
|
|
67166
67162
|
}
|
|
67167
67163
|
for (const flag of REQUIRED_CHROME_FLAGS)
|
|
67168
67164
|
if (!args.includes(flag))
|
|
@@ -67183,26 +67179,16 @@ function chromeServerProblems(config2, npmRegistry) {
|
|
|
67183
67179
|
}
|
|
67184
67180
|
return problems;
|
|
67185
67181
|
}
|
|
67182
|
+
function commandWords(line) {
|
|
67183
|
+
const words2 = [];
|
|
67184
|
+
for (const match of line.matchAll(/"([^"]*)"|'([^']*)'|(\S+)/g))
|
|
67185
|
+
words2.push(match[1] ?? match[2] ?? match[3] ?? "");
|
|
67186
|
+
return words2;
|
|
67187
|
+
}
|
|
67186
67188
|
function isLoopback2(host) {
|
|
67187
67189
|
return host === "localhost" || host === "::1" || /^127\./.test(host);
|
|
67188
67190
|
}
|
|
67189
|
-
function
|
|
67190
|
-
if (import_node_net2.default.isIPv4(address)) {
|
|
67191
|
-
const [a = 0, b = 0] = address.split(".").map(Number);
|
|
67192
|
-
return a === 10 || a === 127 || a === 172 && b >= 16 && b <= 31 || a === 192 && b === 168 || a === 100 && b >= 64 && b <= 127 || a === 169 && b === 254;
|
|
67193
|
-
}
|
|
67194
|
-
if (import_node_net2.default.isIPv6(address)) {
|
|
67195
|
-
const lower = address.toLowerCase();
|
|
67196
|
-
if (lower === "::1")
|
|
67197
|
-
return true;
|
|
67198
|
-
const mapped = /^::ffff:(\d+\.\d+\.\d+\.\d+)$/.exec(lower);
|
|
67199
|
-
if (mapped !== null)
|
|
67200
|
-
return isPrivateAddress(mapped[1] ?? "");
|
|
67201
|
-
return /^f[cd][0-9a-f]{2}:/.test(lower) || /^fe[89ab][0-9a-f]:/.test(lower);
|
|
67202
|
-
}
|
|
67203
|
-
return false;
|
|
67204
|
-
}
|
|
67205
|
-
async function webChatHostProblem(pageUrl, lookup = lookupAll) {
|
|
67191
|
+
function webChatAddressProblem(pageUrl) {
|
|
67206
67192
|
let url2;
|
|
67207
67193
|
try {
|
|
67208
67194
|
url2 = new URL(pageUrl);
|
|
@@ -67211,24 +67197,8 @@ async function webChatHostProblem(pageUrl, lookup = lookupAll) {
|
|
|
67211
67197
|
}
|
|
67212
67198
|
if (url2.protocol !== "https:" && url2.protocol !== "http:")
|
|
67213
67199
|
return "The web chat address must start with https:// (or http://).";
|
|
67214
|
-
const host = url2.hostname.replace(/^\[|\]$/g, "");
|
|
67215
|
-
let addresses2;
|
|
67216
|
-
try {
|
|
67217
|
-
addresses2 = import_node_net2.default.isIP(host) !== 0 ? [host] : await lookup(host);
|
|
67218
|
-
} catch (error51) {
|
|
67219
|
-
return `${host} could not be looked up (${error51 instanceof Error ? error51.message : String(error51)}), so it cannot be confirmed to be inside the network.`;
|
|
67220
|
-
}
|
|
67221
|
-
if (addresses2.length === 0)
|
|
67222
|
-
return `${host} has no address.`;
|
|
67223
|
-
const outside = addresses2.filter((address) => !isPrivateAddress(address));
|
|
67224
|
-
if (outside.length > 0)
|
|
67225
|
-
return `${host} resolves to ${outside.join(", ")}, which is on the public internet - the web chat must be inside the bank's network, so nothing is sent.`;
|
|
67226
67200
|
return void 0;
|
|
67227
67201
|
}
|
|
67228
|
-
async function lookupAll(host) {
|
|
67229
|
-
const found2 = await import_node_dns.promises.lookup(host, { all: true });
|
|
67230
|
-
return found2.map((entry) => entry.address);
|
|
67231
|
-
}
|
|
67232
67202
|
|
|
67233
67203
|
// ../../packages/core/dist/webchat/answer.js
|
|
67234
67204
|
function leaves(value, path70, out) {
|
|
@@ -91334,7 +91304,7 @@ ${error51.stack.split("\n").slice(1, 6).join("\n")}`;
|
|
|
91334
91304
|
child.on("close", (code) => resolve(code === 0 ? out.trim() : void 0));
|
|
91335
91305
|
setTimeout(() => child.kill(), 15e3).unref?.();
|
|
91336
91306
|
});
|
|
91337
|
-
const value = registry2 === void 0 || registry2.length === 0 ? void 0 :
|
|
91307
|
+
const value = registry2 === void 0 || registry2.length === 0 ? void 0 : registry2;
|
|
91338
91308
|
npmRegistryCheck = { at: Date.now(), value };
|
|
91339
91309
|
return value;
|
|
91340
91310
|
}
|
|
@@ -91342,13 +91312,21 @@ ${error51.stack.split("\n").slice(1, 6).join("\n")}`;
|
|
|
91342
91312
|
const config2 = mcp.serverConfig(server);
|
|
91343
91313
|
const command = config2?.command ?? "";
|
|
91344
91314
|
const npx = /(^|[\\/])npx(\.cmd)?$/i.test(command);
|
|
91345
|
-
|
|
91315
|
+
void npx;
|
|
91316
|
+
return chromeServerProblems(config2);
|
|
91317
|
+
}
|
|
91318
|
+
async function npxRegistryFor(server) {
|
|
91319
|
+
const command = mcp.serverConfig(server)?.command ?? "";
|
|
91320
|
+
if (!/(^|[\\/\s])npx(\.cmd)?(\s|$)/i.test(command))
|
|
91321
|
+
return {};
|
|
91322
|
+
const registry2 = await npmRegistry();
|
|
91323
|
+
return registry2 !== void 0 ? { registry: registry2 } : {};
|
|
91346
91324
|
}
|
|
91347
91325
|
async function hostProblem(pageUrl) {
|
|
91348
91326
|
const known = webChatHostChecks.get(pageUrl);
|
|
91349
91327
|
if (known !== void 0 && Date.now() - known.at < 6e5)
|
|
91350
91328
|
return known.problem;
|
|
91351
|
-
const problem =
|
|
91329
|
+
const problem = webChatAddressProblem(pageUrl);
|
|
91352
91330
|
webChatHostChecks.set(pageUrl, { at: Date.now(), problem });
|
|
91353
91331
|
return problem;
|
|
91354
91332
|
}
|
|
@@ -91399,7 +91377,7 @@ ${error51.stack.split("\n").slice(1, 6).join("\n")}`;
|
|
|
91399
91377
|
}
|
|
91400
91378
|
} : {},
|
|
91401
91379
|
chrome: {
|
|
91402
|
-
servers: await Promise.all(servers.map(async (name) => ({ name, problems: await chromeProblems(name) }))),
|
|
91380
|
+
servers: await Promise.all(servers.map(async (name) => ({ name, problems: await chromeProblems(name), ...await npxRegistryFor(name) }))),
|
|
91403
91381
|
...setup?.server !== void 0 ? { chosen: setup.server } : {}
|
|
91404
91382
|
},
|
|
91405
91383
|
...setup !== void 0 ? { hostProblem: await hostProblem(setup.pageUrl).catch((error51) => String(error51)) ?? "" } : {},
|
|
@@ -106056,9 +106034,9 @@ DevTools MCP server is connected, and never on a shared server.
|
|
|
106056
106034
|
(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
106035
|
panel. Add it with \`--autoConnect\`, \`--no-usage-statistics\` and
|
|
106058
106036
|
\`--no-performance-crux\` (the panel shows the entry to paste), and allow it in Chrome at
|
|
106059
|
-
chrome://inspect/#remote-debugging. Either installed once (\`npm i -g chrome-devtools-mcp\`), or run with **npx**
|
|
106060
|
-
|
|
106061
|
-
\`npm config get registry\`
|
|
106037
|
+
chrome://inspect/#remote-debugging. Either installed once (\`npm i -g chrome-devtools-mcp\`), or run with **npx**
|
|
106038
|
+
and a pinned version (\`chrome-devtools-mcp@1.13.0\`, not \`@latest\`); the panel shows where npx downloads it from
|
|
106039
|
+
(\`npm config get registry\` - it should be your organisation's registry).
|
|
106062
106040
|
2. Type the web chat page's address and press **Capture**. In the tab Light Code selects, start a new chat, choose the
|
|
106063
106041
|
model, and send the phrase shown (or press **Send it for me**).
|
|
106064
106042
|
3. Light Code shows the request that carried it: **the backend address**, the model, and the start of the answer it read.
|
|
@@ -106068,11 +106046,8 @@ DevTools MCP server is connected, and never on a shared server.
|
|
|
106068
106046
|
- Light Code opens no connection itself: the request runs inside the chat page, in your Chrome, to the approved
|
|
106069
106047
|
backend address on the chat's own site only, with redirects refused; a reply from another site is not used. Your session
|
|
106070
106048
|
never reaches Light Code - a header that carries a credential is taken from the page each time, never stored.
|
|
106071
|
-
- The
|
|
106072
|
-
|
|
106073
|
-
- The Chrome DevTools MCP server must run on this PC (not a remote server) - installed, or through npx only when npm's
|
|
106074
|
-
registry is inside the network and the version is pinned - with its reporting to Google off (both flags above),
|
|
106075
|
-
attached to this PC's Chrome only.
|
|
106049
|
+
- The Chrome DevTools MCP server must run on this PC (not a remote server) - installed, or through npx with a pinned
|
|
106050
|
+
version - with its reporting to Google off (both flags above), attached to this PC's Chrome only.
|
|
106076
106051
|
- **The assistant never gets the web chat's Chrome server's tools**: it cannot open a page, click or run anything
|
|
106077
106052
|
through it - \`ask_web_chat\` and its one approved request are the only way in. Its tools are replaced by that one
|
|
106078
106053
|
tool, so the assistant is given fewer tools, not more. Any other Chrome server you have is untouched - and with it the
|
|
@@ -109572,6 +109547,7 @@ async function createSession(options) {
|
|
|
109572
109547
|
...options.jupyterHub !== void 0 ? { jupyterHub: options.jupyterHub } : {},
|
|
109573
109548
|
...options.siblingHubs !== void 0 ? { siblingHubs: options.siblingHubs } : {},
|
|
109574
109549
|
...options.machineApprovalsFile !== void 0 ? { machineApprovalsFile: options.machineApprovalsFile } : {},
|
|
109550
|
+
...options.personalDir !== void 0 ? { personalDir: options.personalDir } : {},
|
|
109575
109551
|
...options.savedCredentials !== void 0 ? { savedCredentials: options.savedCredentials } : {},
|
|
109576
109552
|
...options.desktopNotify === true ? {
|
|
109577
109553
|
desktopNotify: (notification) => {
|
|
@@ -109840,6 +109816,7 @@ async function startServer(options) {
|
|
|
109840
109816
|
...options.jupyterHub !== void 0 ? { jupyterHub: options.jupyterHub } : {},
|
|
109841
109817
|
...options.siblingHubs !== void 0 ? { siblingHubs: options.siblingHubs } : {},
|
|
109842
109818
|
...options.machineApprovalsFile !== void 0 ? { machineApprovalsFile: options.machineApprovalsFile } : {},
|
|
109819
|
+
...options.personalDir !== void 0 ? { personalDir: options.personalDir } : {},
|
|
109843
109820
|
// Fire Code's saved credentials, for Python tools that declare one (names only; values stay in the vault).
|
|
109844
109821
|
...options.credentialsFile !== void 0 ? { savedCredentials: readCredentials } : {},
|
|
109845
109822
|
...options.fastFs !== void 0 ? { fastFs: options.fastFs } : {},
|