@chosengeneration/light-code 0.204.0 → 0.207.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.
Files changed (3) hide show
  1. package/dist/cli.cjs +241 -52
  2. package/dist/server.cjs +238 -49
  3. package/package.json +1 -1
package/dist/server.cjs CHANGED
@@ -39918,6 +39918,16 @@ var mcpServersSchema = external_exports.record(external_exports.string(), mcpSer
39918
39918
  function isStdioServer(config2) {
39919
39919
  return "command" in config2;
39920
39920
  }
39921
+ function isJoinedLine(line) {
39922
+ const trimmed = line.trim();
39923
+ return /\s/.test(trimmed) && !/["'\\]/.test(trimmed) && /(^|\s)--?[A-Za-z]/.test(trimmed);
39924
+ }
39925
+ function stdioCommandLine(config2) {
39926
+ const words2 = (line) => line.trim().split(/\s+/);
39927
+ const head = isJoinedLine(config2.command) ? words2(config2.command) : [config2.command];
39928
+ const args = (config2.args ?? []).flatMap((arg) => isJoinedLine(arg) ? words2(arg) : [arg]).filter((arg) => arg.length > 0);
39929
+ return { command: head[0] ?? config2.command, args: [...head.slice(1), ...args] };
39930
+ }
39921
39931
  function resolveToolPermission(toolName, namespacedName, disabledTools, alwaysAllowedTools) {
39922
39932
  if (disabledTools?.includes(toolName) === true)
39923
39933
  return "never";
@@ -60368,9 +60378,10 @@ async function interpolateSecrets(values, secrets, options = {}) {
60368
60378
  async function buildTransport(config2, secrets, options) {
60369
60379
  if (isStdioServer(config2)) {
60370
60380
  const configuredEnv = await interpolateSecrets(config2.env, secrets, options);
60381
+ const line = stdioCommandLine(config2);
60371
60382
  return new StdioClientTransport({
60372
- command: config2.command,
60373
- ...config2.args !== void 0 ? { args: config2.args } : {},
60383
+ command: line.command,
60384
+ ...line.args.length > 0 ? { args: line.args } : {},
60374
60385
  ...config2.cwd !== void 0 ? { cwd: config2.cwd } : {},
60375
60386
  // Passing `env` *replaces* the SDK's default rather than merging, so a server given
60376
60387
  // any env var at all would otherwise lose PATH and fail to spawn. The SDK's default
@@ -67148,9 +67159,7 @@ function chromeServerProblems(config2) {
67148
67159
  if (typeof record2.url === "string" || typeof record2.command !== "string")
67149
67160
  return ["The Chrome DevTools MCP server must run on this PC (a command), not as a remote server at a URL."];
67150
67161
  const problems = [];
67151
- const words2 = commandWords([record2.command, ...record2.args ?? []].join(" "));
67152
- const command = words2[0] ?? record2.command;
67153
- const args = words2.slice(1);
67162
+ const { command, args } = stdioCommandLine({ command: record2.command, args: record2.args ?? [] });
67154
67163
  const runner = command.split(/[\\/]/).pop()?.toLowerCase() ?? "";
67155
67164
  if (runner === "npx" || runner === "npx.cmd") {
67156
67165
  const spec = npxPackage(args);
@@ -67179,11 +67188,56 @@ function chromeServerProblems(config2) {
67179
67188
  }
67180
67189
  return problems;
67181
67190
  }
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;
67191
+ var TESTED_CHROME_MCP = "chrome-devtools-mcp@1.13.0";
67192
+ function fixChromeServer(config2) {
67193
+ if (config2 === void 0)
67194
+ return void 0;
67195
+ const record2 = config2;
67196
+ if (typeof record2.url === "string" || typeof record2.command !== "string")
67197
+ return void 0;
67198
+ const line = stdioCommandLine({ command: record2.command, args: record2.args ?? [] });
67199
+ const args = [...line.args];
67200
+ const runner = line.command.split(/[\\/]/).pop()?.toLowerCase() ?? "";
67201
+ if (runner === "npx" || runner === "npx.cmd") {
67202
+ const spec = npxPackage(args);
67203
+ if (spec === void 0)
67204
+ return void 0;
67205
+ if (!isPinned(spec)) {
67206
+ if (!/^chrome-devtools-mcp(@[^@]*)?$/.test(spec))
67207
+ return void 0;
67208
+ args[args.indexOf(spec)] = TESTED_CHROME_MCP;
67209
+ }
67210
+ if (!args.includes("-y") && !args.includes("--yes"))
67211
+ args.unshift("-y");
67212
+ } else if (isPackageRunnerCommand(line.command)) {
67213
+ return void 0;
67214
+ }
67215
+ for (const flag of REQUIRED_CHROME_FLAGS)
67216
+ if (!args.includes(flag))
67217
+ args.push(flag);
67218
+ const fixed = { ...config2, command: line.command, args };
67219
+ return chromeServerProblems(fixed).length === 0 ? fixed : void 0;
67220
+ }
67221
+ var AUTO_CONNECT = /^--?(autoConnect|auto-connect)(=true)?$/;
67222
+ var NAMES_CHROME = /^--?(browserUrl|browser-url|u|wsEndpoint|ws-endpoint|w)(=|$)/;
67223
+ function chromeMode(config2) {
67224
+ const record2 = config2;
67225
+ if (record2 === void 0 || typeof record2.command !== "string")
67226
+ return void 0;
67227
+ const { args } = stdioCommandLine({ command: record2.command, args: record2.args ?? [] });
67228
+ if (args.some((arg) => NAMES_CHROME.test(arg)))
67229
+ return "address";
67230
+ return args.some((arg) => AUTO_CONNECT.test(arg)) ? "own" : "started";
67231
+ }
67232
+ function withChromeMode(config2, mode) {
67233
+ const record2 = config2;
67234
+ if (typeof record2.command !== "string" || chromeMode(config2) === "address")
67235
+ return void 0;
67236
+ const line = stdioCommandLine({ command: record2.command, args: record2.args ?? [] });
67237
+ const args = line.args.filter((arg) => !AUTO_CONNECT.test(arg));
67238
+ if (mode === "own")
67239
+ args.push("--autoConnect");
67240
+ return { ...config2, command: line.command, args };
67187
67241
  }
67188
67242
  function isLoopback2(host) {
67189
67243
  return host === "localhost" || host === "::1" || /^127\./.test(host);
@@ -67239,36 +67293,74 @@ function sseEvents(text2) {
67239
67293
  }
67240
67294
  return events;
67241
67295
  }
67242
- function findAnswer(responseText, contentType2, exclude) {
67243
- const notQuestion = (text2) => text2.trim().length > 0 && text2.split(exclude).join("").replace(/[\s"'`.,:;!?()[\]{}-]/g, "").length >= 3;
67244
- const events = (contentType2 ?? "").includes("event-stream") || /^data:/m.test(responseText) ? sseEvents(responseText) : void 0;
67245
- if (events !== void 0 && events.length > 0) {
67246
- const byPath = /* @__PURE__ */ new Map();
67247
- for (const event of events) {
67248
- const found2 = [];
67249
- leaves(event, [], found2);
67250
- for (const leaf of found2) {
67251
- const entry = byPath.get(keyOf(leaf.path)) ?? { path: leaf.path, values: [] };
67252
- entry.values.push(leaf.text);
67253
- byPath.set(keyOf(leaf.path), entry);
67254
- }
67296
+ var nameLike = (text2) => /^[A-Za-z0-9_.:/#@+-]*$/.test(text2);
67297
+ function labelsEvents(values, eventCount) {
67298
+ if (values.length < 2 || values.length < eventCount * 0.8)
67299
+ return false;
67300
+ return values.every(nameLike) && new Set(values).size > 1;
67301
+ }
67302
+ function combine(values, mode) {
67303
+ if (mode === "cumulative")
67304
+ return values.at(-1) ?? "";
67305
+ if (values.length > 1) {
67306
+ const before = values.slice(0, -1).join("");
67307
+ const last = values.at(-1) ?? "";
67308
+ if (before.trim().length > 0 && last.trim() === before.trim())
67309
+ return last;
67310
+ }
67311
+ return values.join("");
67312
+ }
67313
+ function sseFields(events) {
67314
+ const byPath = /* @__PURE__ */ new Map();
67315
+ for (const event of events) {
67316
+ const found2 = [];
67317
+ leaves(event, [], found2);
67318
+ for (const leaf of found2) {
67319
+ const entry = byPath.get(keyOf(leaf.path)) ?? { path: leaf.path, values: [] };
67320
+ entry.values.push(leaf.text);
67321
+ byPath.set(keyOf(leaf.path), entry);
67255
67322
  }
67256
- let best;
67257
- for (const entry of byPath.values()) {
67258
- const cumulative = entry.values.length > 1 && entry.values.every((value, i) => i === 0 || value.startsWith(entry.values[i - 1] ?? ""));
67259
- const answer = cumulative ? entry.values.at(-1) ?? "" : entry.values.join("");
67260
- if (!notQuestion(answer))
67261
- continue;
67262
- if (best === void 0 || answer.length > best.answer.length)
67263
- best = { spec: { kind: "sse", path: entry.path, mode: cumulative ? "cumulative" : "delta" }, answer };
67323
+ }
67324
+ return [...byPath.values()];
67325
+ }
67326
+ var isProse = (text2) => /\s/.test(text2.trim());
67327
+ function answerRank(text2, path70) {
67328
+ const key4 = String(path70.filter((part) => typeof part === "string").at(-1) ?? "");
67329
+ if (/(^|_|-)id$|Id$|^uuid$/i.test(key4))
67330
+ return 0;
67331
+ if (isProse(text2))
67332
+ return 2;
67333
+ if (/\d/.test(text2) && /^[A-Za-z0-9_-]+$/.test(text2.trim()))
67334
+ return 0;
67335
+ return 1;
67336
+ }
67337
+ function bestSse(events, accept) {
67338
+ let best;
67339
+ for (const entry of sseFields(events)) {
67340
+ if (labelsEvents(entry.values, events.length))
67341
+ continue;
67342
+ const cumulative = entry.values.length > 1 && entry.values.every((value, i) => i === 0 || value.startsWith(entry.values[i - 1] ?? ""));
67343
+ const mode = cumulative ? "cumulative" : "delta";
67344
+ const answer = combine(entry.values, mode);
67345
+ if (!accept(answer))
67346
+ continue;
67347
+ const rank4 = answerRank(answer, entry.path);
67348
+ if (best === void 0 || rank4 > best.rank || rank4 === best.rank && answer.length > best.answer.length) {
67349
+ best = { spec: { kind: "sse", path: entry.path, mode }, answer, rank: rank4 };
67264
67350
  }
67265
- return best;
67266
67351
  }
67352
+ return best === void 0 ? void 0 : { spec: best.spec, answer: best.answer };
67353
+ }
67354
+ function findAnswer(responseText, contentType2, exclude) {
67355
+ const notQuestion = (text2) => text2.trim().length > 0 && text2.split(exclude).join("").replace(/[\s"'`.,:;!?()[\]{}-]/g, "").length >= 3;
67356
+ const events = (contentType2 ?? "").includes("event-stream") || /^data:/m.test(responseText) ? sseEvents(responseText) : void 0;
67357
+ if (events !== void 0 && events.length > 0)
67358
+ return bestSse(events, notQuestion);
67267
67359
  try {
67268
67360
  const document = JSON.parse(responseText);
67269
67361
  const found2 = [];
67270
67362
  leaves(document, [], found2);
67271
- const best = found2.filter((leaf) => notQuestion(leaf.text)).sort((a, b) => b.text.length - a.text.length)[0];
67363
+ const best = found2.filter((leaf) => notQuestion(leaf.text)).sort((a, b) => answerRank(b.text, b.path) - answerRank(a.text, a.path) || b.text.length - a.text.length)[0];
67272
67364
  return best === void 0 ? void 0 : { spec: { kind: "json", path: best.path }, answer: best.text };
67273
67365
  } catch {
67274
67366
  return notQuestion(responseText) ? { spec: { kind: "text" }, answer: responseText } : void 0;
@@ -67287,9 +67379,28 @@ function readAnswer(responseText, spec) {
67287
67379
  }
67288
67380
  const events = sseEvents(responseText) ?? [];
67289
67381
  const values = events.map((event) => at(event, spec.path ?? [])).filter((value) => typeof value === "string");
67382
+ if (labelsEvents(values, events.length))
67383
+ return bestSse(events, (text2) => text2.trim().length > 0)?.answer;
67290
67384
  if (values.length === 0)
67291
67385
  return void 0;
67292
- return spec.mode === "cumulative" ? values.at(-1) : values.join("");
67386
+ return combine(values, spec.mode === "cumulative" ? "cumulative" : "delta");
67387
+ }
67388
+ function replyShape(responseText) {
67389
+ const events = /^data:/m.test(responseText) ? sseEvents(responseText) : void 0;
67390
+ if (events !== void 0 && events.length > 0) {
67391
+ const fields = sseFields(events).map((entry) => {
67392
+ const chars = entry.values.reduce((sum, value) => sum + value.length, 0);
67393
+ return `${entry.path.join(".")} \xD7${String(entry.values.length)} (${String(chars)} chars${labelsEvents(entry.values, events.length) ? ", event labels" : ""})`;
67394
+ });
67395
+ return `${String(events.length)} events; fields: ${fields.join(", ")}`;
67396
+ }
67397
+ try {
67398
+ const found2 = [];
67399
+ leaves(JSON.parse(responseText), [], found2);
67400
+ return `JSON; text fields: ${found2.map((leaf) => `${leaf.path.join(".")} (${String(leaf.text.length)} chars)`).join(", ")}`;
67401
+ } catch {
67402
+ return `plain text, ${String(responseText.length)} chars`;
67403
+ }
67293
67404
  }
67294
67405
 
67295
67406
  // ../../packages/core/dist/webchat/inpage.js
@@ -67518,9 +67629,25 @@ function sameOrigin(url2, origin) {
67518
67629
  return false;
67519
67630
  }
67520
67631
  }
67632
+ function explainChromeError(text2) {
67633
+ const clipped = text2.slice(0, 300);
67634
+ if (/already running for/i.test(text2)) {
67635
+ return `${clipped}
67636
+
67637
+ Another copy of the Chrome DevTools MCP server (in VS Code, Fire Code or another chat) has already started its own Chrome with that profile, and only one can. In Settings \u2192 Agents \u2192 Web chat, set "Which Chrome" to "Your own Chrome" (and switch remote debugging on once in your Chrome at chrome://inspect/#remote-debugging): every copy then uses your own Chrome, where you are signed in to the web chat. Or close the other one.`;
67638
+ }
67639
+ if (/DevToolsActivePort|Could not connect to Chrome/i.test(text2)) {
67640
+ return `${clipped}
67641
+
67642
+ The server is set to use your own Chrome, and your Chrome is not accepting it. Either: open chrome://inspect/#remote-debugging in your Chrome and switch remote debugging on (Chrome 144 or newer; your organisation may block it), then try again - or, in Settings \u2192 Agents \u2192 Web chat, set "Which Chrome" to "A Chrome it starts": the server opens a Chrome of its own (sign in to the web chat there once; it remembers) - only one app at a time can use that one.`;
67643
+ }
67644
+ return clipped;
67645
+ }
67521
67646
  async function selectWebChatPage(chrome, pageUrl) {
67522
67647
  const origin = new URL(pageUrl).origin;
67523
67648
  const listed = await chrome.call("list_pages", {});
67649
+ if (listed.isError && /already running for/i.test(listed.text))
67650
+ throw new Error(`Chrome could not start: ${explainChromeError(listed.text)}`);
67524
67651
  const existing = listed.isError ? [] : pagesIn(listed.text).filter((page) => sameOrigin(page.url, origin));
67525
67652
  const chosen = existing.find((page) => page.selected) ?? existing[0];
67526
67653
  if (chosen !== void 0) {
@@ -67529,13 +67656,13 @@ async function selectWebChatPage(chrome, pageUrl) {
67529
67656
  const key4 = names.includes("pageId") ? "pageId" : names.find((name) => /idx|index|id/i.test(name)) ?? "pageId";
67530
67657
  const selected = await chrome.call("select_page", { [key4]: chosen.id });
67531
67658
  if (selected.isError)
67532
- throw new Error(`Chrome could not select the web chat tab: ${selected.text.slice(0, 300)}`);
67659
+ throw new Error(`Chrome could not select the web chat tab: ${explainChromeError(selected.text)}`);
67533
67660
  }
67534
67661
  return chosen.id;
67535
67662
  }
67536
67663
  const opened = await chrome.call("new_page", { url: pageUrl });
67537
67664
  if (opened.isError)
67538
- throw new Error(`Chrome could not open ${pageUrl}: ${opened.text.slice(0, 300)}`);
67665
+ throw new Error(`Chrome could not open ${pageUrl}: ${explainChromeError(opened.text)}`);
67539
67666
  const now = pagesIn(opened.text).filter((page) => sameOrigin(page.url, origin));
67540
67667
  const fresh = now.find((page) => page.selected) ?? now.at(-1);
67541
67668
  if (fresh !== void 0)
@@ -67557,13 +67684,13 @@ async function runScript(chrome, source, pageId) {
67557
67684
  args["waitForStableDom"] = false;
67558
67685
  const result = await chrome.call("evaluate_script", args);
67559
67686
  if (result.isError)
67560
- throw new Error(`Chrome could not run the script: ${result.text.slice(0, 400)}`);
67687
+ throw new Error(`Chrome could not run the script: ${explainChromeError(result.text)}`);
67561
67688
  const value = result.structured ?? scriptResult(result.text);
67562
67689
  if (value === null || typeof value !== "object")
67563
67690
  throw new Error(`Chrome returned something unexpected: ${result.text.slice(0, 300)}`);
67564
67691
  return value;
67565
67692
  }
67566
- async function askWebChat(chrome, setup, question) {
67693
+ async function askWebChat(chrome, setup, question, options = {}) {
67567
67694
  const origin = new URL(setup.pageUrl).origin;
67568
67695
  const pageId = await selectWebChatPage(chrome, setup.pageUrl);
67569
67696
  const watched = await runScript(chrome, watchScript(origin, void 0, setup.backendUrl ?? new URL(setup.request.path, origin).href), pageId);
@@ -67580,6 +67707,7 @@ async function askWebChat(chrome, setup, question) {
67580
67707
  throw new Error(`The web chat answered HTTP ${String(status2)}: sign in to it again in Chrome, then ask again.`);
67581
67708
  if (status2 >= 400)
67582
67709
  throw new Error(`The web chat answered HTTP ${String(status2)}: ${String(sent["text"] ?? "").slice(0, 300)}`);
67710
+ options.onReply?.(String(sent["text"] ?? ""));
67583
67711
  const answer = readAnswer(String(sent["text"] ?? ""), setup.response);
67584
67712
  if (answer === void 0 || answer.trim().length === 0) {
67585
67713
  throw new Error("The answer was not where the capture found it - the web chat may have changed how it replies. Capture again in Settings \u2192 Agents \u2192 Web chat.");
@@ -67613,6 +67741,7 @@ async function askThroughWindow(chrome, setup, question, options = {}) {
67613
67741
  throw new Error(`The web chat answered HTTP ${String(status2)}: sign in to it again in Chrome, then ask again.`);
67614
67742
  if (status2 >= 400)
67615
67743
  throw new Error(`The web chat answered HTTP ${String(status2)}: ${String(reply.response ?? "").slice(0, 300)}`);
67744
+ options.onReply?.(String(reply.response ?? ""));
67616
67745
  const answer = readAnswer(String(reply.response ?? ""), setup.response);
67617
67746
  if (answer !== void 0 && answer.trim().length > 0)
67618
67747
  return { answer, from: "reply" };
@@ -91565,19 +91694,22 @@ ${error51.stack.split("\n").slice(1, 6).join("\n")}`;
91565
91694
  const clip3 = (text2) => text2.length > 300 ? `${text2.slice(0, 300)}\u2026` : text2;
91566
91695
  post({ type: "webChatTest", running: "direct" });
91567
91696
  let started = Date.now();
91697
+ let reply;
91698
+ const shape = () => reply === void 0 ? {} : { shape: replyShape(reply) };
91568
91699
  try {
91569
- const answer = await askWebChat(chromeAccess(server), setup, question);
91570
- results.push({ way: "direct", ok: true, text: clip3(answer), ms: Date.now() - started });
91700
+ const answer = await askWebChat(chromeAccess(server), setup, question, { onReply: (text2) => reply = text2 });
91701
+ results.push({ way: "direct", ok: true, text: clip3(answer), ms: Date.now() - started, ...shape() });
91571
91702
  } catch (error51) {
91572
- results.push({ way: "direct", ok: false, text: error51 instanceof Error ? error51.message : String(error51), ms: Date.now() - started });
91703
+ results.push({ way: "direct", ok: false, text: error51 instanceof Error ? error51.message : String(error51), ms: Date.now() - started, ...shape() });
91573
91704
  }
91574
91705
  post({ type: "webChatTest", results, running: "window" });
91575
91706
  started = Date.now();
91707
+ reply = void 0;
91576
91708
  try {
91577
- const read = await askThroughWindow(chromeAccess(server), setup, question);
91578
- results.push({ way: "window", ok: true, text: clip3(read.answer), ms: Date.now() - started, from: read.from });
91709
+ const read = await askThroughWindow(chromeAccess(server), setup, question, { onReply: (text2) => reply = text2 });
91710
+ results.push({ way: "window", ok: true, text: clip3(read.answer), ms: Date.now() - started, from: read.from, ...shape() });
91579
91711
  } catch (error51) {
91580
- results.push({ way: "window", ok: false, text: error51 instanceof Error ? error51.message : String(error51), ms: Date.now() - started });
91712
+ results.push({ way: "window", ok: false, text: error51 instanceof Error ? error51.message : String(error51), ms: Date.now() - started, ...shape() });
91581
91713
  }
91582
91714
  post({ type: "webChatTest", results });
91583
91715
  } finally {
@@ -91603,13 +91735,37 @@ ${error51.stack.split("\n").slice(1, 6).join("\n")}`;
91603
91735
  }
91604
91736
  } : {},
91605
91737
  chrome: {
91606
- servers: await Promise.all(servers.map(async (name) => ({ name, problems: await chromeProblems(name), ...await npxRegistryFor(name) }))),
91738
+ servers: await Promise.all(servers.map(async (name) => {
91739
+ const problems = await chromeProblems(name);
91740
+ const mode = chromeMode(mcp.serverConfig(name));
91741
+ return { name, problems, fixable: problems.length > 0 && fixChromeServer(mcp.serverConfig(name)) !== void 0, ...mode !== void 0 ? { mode } : {}, ...await npxRegistryFor(name) };
91742
+ })),
91607
91743
  ...setup?.server !== void 0 ? { chosen: setup.server } : {}
91608
91744
  },
91609
91745
  ...setup !== void 0 ? { hostProblem: await hostProblem(setup.pageUrl).catch((error51) => String(error51)) ?? "" } : {},
91610
91746
  ...message6 !== void 0 ? { message: message6 } : {}
91611
91747
  });
91612
91748
  }
91749
+ async function fixWebChatServer(server) {
91750
+ const fixed = fixChromeServer(mcp.serverConfig(server));
91751
+ if (fixed === void 0) {
91752
+ await postWebChat(`"${server}" cannot be fixed automatically - change it in Settings \u2192 MCP.`);
91753
+ return;
91754
+ }
91755
+ await handleSaveMcpServer(server, server, fixed);
91756
+ const args = fixed.args ?? [];
91757
+ await postWebChat(`Fixed "${server}": ${fixed.command} ${args.join(" ")}. It is restarting with these options.`);
91758
+ }
91759
+ async function setWebChatChrome(server, mode) {
91760
+ const config2 = mcp.serverConfig(server);
91761
+ const changed = config2 === void 0 ? void 0 : withChromeMode(config2, mode);
91762
+ if (changed === void 0) {
91763
+ await postWebChat(`"${server}" names a Chrome by address - change it in Settings \u2192 MCP.`);
91764
+ return;
91765
+ }
91766
+ await handleSaveMcpServer(server, server, changed);
91767
+ await postWebChat(mode === "own" ? `"${server}" now uses your own Chrome. Switch remote debugging on once at chrome://inspect/#remote-debugging in that Chrome (Chrome 144 or newer).` : `"${server}" now opens a Chrome of its own. Sign in to the web chat in that Chrome once; it remembers. Only one app at a time can use it.`);
91768
+ }
91613
91769
  function stopWebChatCapture() {
91614
91770
  if (webChatCapture?.timer !== void 0)
91615
91771
  clearInterval(webChatCapture.timer);
@@ -99948,6 +100104,10 @@ ${answer.slice(0, 16e3)}` } }, (d) => d.best !== void 0 && d.best.probability >=
99948
100104
  })();
99949
100105
  } else if (message6.type === "testWebChat") {
99950
100106
  reportFailure("testWebChat", testWebChat());
100107
+ } else if (message6.type === "setWebChatChrome") {
100108
+ reportFailure("setWebChatChrome", setWebChatChrome(message6.server, message6.mode));
100109
+ } else if (message6.type === "fixWebChatServer") {
100110
+ reportFailure("fixWebChatServer", fixWebChatServer(message6.server));
99951
100111
  } else if (message6.type === "clearWebChat") {
99952
100112
  stopWebChatCapture();
99953
100113
  if (webChatFile !== void 0)
@@ -106262,6 +106422,17 @@ transcript was written.
106262
106422
  "test both ways",
106263
106423
  "backup way",
106264
106424
  "primary way",
106425
+ "fix it for me",
106426
+ "cannot be used yet",
106427
+ "must include",
106428
+ "which chrome",
106429
+ "devtoolsactiveport",
106430
+ "could not connect to chrome",
106431
+ "remote debugging",
106432
+ "already running",
106433
+ "isolated",
106434
+ "wrong answer",
106435
+ "answer extraction",
106265
106436
  "inside the network",
106266
106437
  "outside the organisation"
106267
106438
  ],
@@ -106275,8 +106446,18 @@ DevTools MCP server is connected, and never on a shared server.
106275
106446
  1. **Give the web chat a Chrome DevTools MCP server of its own** - a second entry in Settings \u2192 MCP under its own name
106276
106447
  (e.g. chrome-webchat), so any Chrome server you already use is left exactly as it is - and choose it in the Web chat
106277
106448
  panel. Add it with \`--autoConnect\`, \`--no-usage-statistics\` and
106278
- \`--no-performance-crux\` (the panel shows the entry to paste), and allow it in Chrome at
106279
- chrome://inspect/#remote-debugging. Either installed once (\`npm i -g chrome-devtools-mcp\`), or run with **npx**
106449
+ \`--no-performance-crux\`. Typed on one line, or the whole command line typed into Command, they are split into
106450
+ separate arguments when the server starts (a line with quotes or a backslash is left as typed). When the panel says
106451
+ the server **cannot be used yet**, press **Fix it for me**: it adds what is missing to that server's entry (each
106452
+ option on its own line, npx pinned to the tested version) and restarts it. The panel shows the entry to paste.
106453
+ **Which Chrome** (in the panel, once a server is chosen):
106454
+ - **Your own Chrome** (\`--autoConnect\`): the Chrome you have open, already signed in; VS Code and Fire Code can
106455
+ both use it. Needs Chrome 144 or newer with remote debugging switched on once at chrome://inspect/#remote-debugging
106456
+ - otherwise it fails with "Could not connect to Chrome ... DevToolsActivePort". Your organisation may block it.
106457
+ - **A Chrome it starts**: the server opens a Chrome with a profile of its own - sign in to the web chat there once
106458
+ and it remembers. Only one app at a time can have it ("The browser is already running ... Use --isolated" means
106459
+ another app has it).
106460
+ Either installed once (\`npm i -g chrome-devtools-mcp\`), or run with **npx**
106280
106461
  and a pinned version (\`chrome-devtools-mcp@1.13.0\`, not \`@latest\`); the panel shows where npx downloads it from
106281
106462
  (\`npm config get registry\` - it should be your organisation's registry).
106282
106463
  2. Type the web chat page's address and press **Capture**. In the tab Light Code selects, start a new chat, choose the
@@ -106292,8 +106473,16 @@ DevTools MCP server is connected, and never on a shared server.
106292
106473
  that is plainly an id (a conversation id) may differ; anything else must match. When no such reply is seen (a chat
106293
106474
  over a WebSocket), the answer is read off the screen once it stops changing, and the result says so. A sign-in
106294
106475
  refusal (401/403) is not retried this way - sign in to the web chat in Chrome.
106295
- - **Test both ways** (beside Capture again) asks one short question each way and shows which works here, and how long
106296
- each took.
106476
+ - **Test both ways** (beside Capture again) asks one short question each way and shows which works here, how long
106477
+ each took, the answer, and what the reply was made of (its fields and sizes, never its text) - send that line if the
106478
+ answer looks wrong.
106479
+
106480
+ **If the answer is wrong** (a run of words like \`chat_idprogresscompletion\u2026\`): the answer was read from the field that
106481
+ labels each event. Since 0.229.0 such fields are never taken, ids rank below words, and a capture saved earlier is read
106482
+ afresh - no need to capture again. **"The browser is already running \u2026 Use --isolated"**: this copy of the Chrome
106483
+ DevTools server is starting a Chrome of its own while another copy (VS Code's, another chat's) already has - give it
106484
+ \`--autoConnect\` on its own line so every copy uses your own Chrome. \`--isolated\` would start a Chrome that is not
106485
+ signed in to the web chat.
106297
106486
 
106298
106487
  **It cannot go outside the organisation, by rule - each checked before every consultation, and nothing is sent when one fails:**
106299
106488
  - Light Code opens no connection itself: the request runs inside the chat page, in your Chrome, to the approved
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chosengeneration/light-code",
3
- "version": "0.204.0",
3
+ "version": "0.207.0",
4
4
  "description": "A minimal agentic coding assistant, served to your browser from a local Node server",
5
5
  "license": "MIT",
6
6
  "type": "module",