@chosengeneration/light-code 0.143.0 → 0.145.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 +226 -67
- package/dist/server.cjs +219 -60
- package/package.json +1 -1
package/dist/server.cjs
CHANGED
|
@@ -24258,7 +24258,7 @@ __export(server_exports, {
|
|
|
24258
24258
|
});
|
|
24259
24259
|
module.exports = __toCommonJS(server_exports);
|
|
24260
24260
|
var import_promises34 = __toESM(require("node:fs/promises"), 1);
|
|
24261
|
-
var
|
|
24261
|
+
var import_node_fs15 = require("node:fs");
|
|
24262
24262
|
var import_node_http = require("node:http");
|
|
24263
24263
|
var import_node_path61 = __toESM(require("node:path"), 1);
|
|
24264
24264
|
|
|
@@ -58886,9 +58886,22 @@ var McpConnection = class {
|
|
|
58886
58886
|
return result.tools.map((tool) => ({
|
|
58887
58887
|
name: tool.name,
|
|
58888
58888
|
description: tool.description ?? "",
|
|
58889
|
-
inputSchema: tool.inputSchema
|
|
58889
|
+
inputSchema: tool.inputSchema,
|
|
58890
|
+
...tool._meta?.["lightCode/panelOnly"] === true ? { panelOnly: true } : {}
|
|
58890
58891
|
}));
|
|
58891
58892
|
}
|
|
58893
|
+
/** The same call, keeping what a button needs that the model's text rendering drops. */
|
|
58894
|
+
async callToolRaw(name, args) {
|
|
58895
|
+
if (this.client === void 0)
|
|
58896
|
+
throw new Error(`MCP server "${this.serverName}" is not connected.`);
|
|
58897
|
+
const timeoutSeconds = this.config.toolTimeouts?.[name] ?? this.config.timeout ?? this.defaultTimeout?.();
|
|
58898
|
+
const result = await this.client.callTool({ name, arguments: args }, void 0, timeoutSeconds === void 0 ? void 0 : { timeout: timeoutSeconds * 1e3 });
|
|
58899
|
+
return {
|
|
58900
|
+
text: renderToolResult(result),
|
|
58901
|
+
isError: result.isError === true,
|
|
58902
|
+
...result.structuredContent !== void 0 ? { structured: result.structuredContent } : {}
|
|
58903
|
+
};
|
|
58904
|
+
}
|
|
58892
58905
|
async callTool(name, args) {
|
|
58893
58906
|
if (this.client === void 0)
|
|
58894
58907
|
throw new Error(`MCP server "${this.serverName}" is not connected.`);
|
|
@@ -59039,6 +59052,8 @@ var McpRegistry = class {
|
|
|
59039
59052
|
statuses = /* @__PURE__ */ new Map();
|
|
59040
59053
|
errors = /* @__PURE__ */ new Map();
|
|
59041
59054
|
toolsByServer = /* @__PURE__ */ new Map();
|
|
59055
|
+
/** Tools a server marked for its own settings-tab buttons only: never offered to the model. */
|
|
59056
|
+
panelTools = /* @__PURE__ */ new Map();
|
|
59042
59057
|
logs = /* @__PURE__ */ new Map();
|
|
59043
59058
|
servers = {};
|
|
59044
59059
|
constructor(secrets, events, logger, getAlwaysAllowed = () => [], defaultTimeout = void 0, isRepositoryServer = async () => false) {
|
|
@@ -59163,7 +59178,9 @@ var McpRegistry = class {
|
|
|
59163
59178
|
if (connection === void 0)
|
|
59164
59179
|
return;
|
|
59165
59180
|
try {
|
|
59166
|
-
const
|
|
59181
|
+
const listed = await connection.listTools();
|
|
59182
|
+
this.panelTools.set(name, new Set(listed.filter((descriptor) => descriptor.panelOnly === true).map((descriptor) => descriptor.name)));
|
|
59183
|
+
const descriptors = listed.filter((descriptor) => descriptor.panelOnly !== true);
|
|
59167
59184
|
this.toolsByServer.set(name, descriptors.map((descriptor) => ({
|
|
59168
59185
|
descriptor,
|
|
59169
59186
|
tool: adaptTool(name, descriptor.name, descriptor.description, descriptor.inputSchema, async (args) => {
|
|
@@ -59194,6 +59211,22 @@ var McpRegistry = class {
|
|
|
59194
59211
|
if (options.silent !== true)
|
|
59195
59212
|
this.events.onStateChanged();
|
|
59196
59213
|
}
|
|
59214
|
+
/**
|
|
59215
|
+
* Calls one of a server's tools for a button the user pressed, returning the structured answer as
|
|
59216
|
+
* well as the text. Reaches a panel-only tool, and an ordinary one; deny rules still apply.
|
|
59217
|
+
*/
|
|
59218
|
+
async callPanelTool(server, tool, args) {
|
|
59219
|
+
const connection = this.connections.get(server);
|
|
59220
|
+
if (connection === void 0)
|
|
59221
|
+
throw new Error(`MCP server "${server}" is not running.`);
|
|
59222
|
+
const known = this.panelTools.get(server)?.has(tool) === true || (this.toolsByServer.get(server) ?? []).some((entry) => entry.descriptor.name === tool);
|
|
59223
|
+
if (!known)
|
|
59224
|
+
throw new Error(`"${server}" offers no tool "${tool}".`);
|
|
59225
|
+
const decision = denyCheck(tool, args, this.servers[server]?.deny);
|
|
59226
|
+
if (decision.denied)
|
|
59227
|
+
throw new Error(decision.message ?? "Refused by a deny rule.");
|
|
59228
|
+
return connection.callToolRaw(tool, args);
|
|
59229
|
+
}
|
|
59197
59230
|
async restart(name) {
|
|
59198
59231
|
await this.disconnect(name);
|
|
59199
59232
|
const config2 = this.servers[name];
|
|
@@ -64290,7 +64323,14 @@ var addonPageSchema = external_exports.object({
|
|
|
64290
64323
|
* - "Test connection". Pressed by the user, about a record they are looking at, so it is not an
|
|
64291
64324
|
* agent's tool call and asks no approval.
|
|
64292
64325
|
*/
|
|
64293
|
-
actions: external_exports.array(external_exports.object({
|
|
64326
|
+
actions: external_exports.array(external_exports.object({
|
|
64327
|
+
label: external_exports.string().min(1).max(40),
|
|
64328
|
+
tool: external_exports.string().regex(/^[a-zA-Z0-9_-]{1,64}$/),
|
|
64329
|
+
/** Shown before it runs, needing a second press: for an action that changes something. */
|
|
64330
|
+
confirm: external_exports.string().max(800).optional(),
|
|
64331
|
+
/** Offered only for records with this value - "Set up SSH key" for password sign-in. */
|
|
64332
|
+
showWhen: external_exports.object({ field: external_exports.string().regex(KEY), equals: external_exports.union([external_exports.string(), external_exports.array(external_exports.string())]) }).optional()
|
|
64333
|
+
})).max(5).optional(),
|
|
64294
64334
|
max: external_exports.number().int().positive().max(500).optional()
|
|
64295
64335
|
}).optional()
|
|
64296
64336
|
});
|
|
@@ -64345,6 +64385,10 @@ function cleanAddonValues(fields, values) {
|
|
|
64345
64385
|
}
|
|
64346
64386
|
return { ok: true, values: out };
|
|
64347
64387
|
}
|
|
64388
|
+
function recordUpdateFrom(structured) {
|
|
64389
|
+
const update = structured?.lightCode?.recordUpdate;
|
|
64390
|
+
return update !== null && typeof update === "object" && !Array.isArray(update) ? update : void 0;
|
|
64391
|
+
}
|
|
64348
64392
|
function isShown(field2, values) {
|
|
64349
64393
|
if (field2.showWhen === void 0)
|
|
64350
64394
|
return true;
|
|
@@ -64354,21 +64398,27 @@ function isShown(field2, values) {
|
|
|
64354
64398
|
}
|
|
64355
64399
|
|
|
64356
64400
|
// ../../packages/core/dist/addons/discover.js
|
|
64357
|
-
function defaultAddonFolders(env2, execPath, platform) {
|
|
64401
|
+
function defaultAddonFolders(env2, execPath, platform, npmrc) {
|
|
64358
64402
|
const folders = [];
|
|
64359
|
-
const
|
|
64403
|
+
const configured = npmrc?.split(/\r?\n/).map((line) => /^\s*prefix\s*=\s*(.+?)\s*$/.exec(line)?.[1]).find((value) => value !== void 0)?.replace(/^["']|["']$/g, "");
|
|
64404
|
+
const prefixes = [env2["npm_config_prefix"] ?? env2["NPM_CONFIG_PREFIX"], configured].filter((p) => p !== void 0 && p.length > 0);
|
|
64360
64405
|
if (platform === "win32") {
|
|
64361
|
-
|
|
64362
|
-
folders.push(import_node_path32.default.join(prefix, "node_modules"));
|
|
64406
|
+
for (const prefix of prefixes)
|
|
64407
|
+
folders.push(import_node_path32.default.join(expandWindows(prefix, env2), "node_modules"));
|
|
64363
64408
|
if (env2["APPDATA"] !== void 0)
|
|
64364
64409
|
folders.push(import_node_path32.default.join(env2["APPDATA"], "npm", "node_modules"));
|
|
64410
|
+
if (import_node_path32.default.basename(execPath).toLowerCase() === "node.exe")
|
|
64411
|
+
folders.push(import_node_path32.default.join(import_node_path32.default.dirname(execPath), "node_modules"));
|
|
64365
64412
|
} else {
|
|
64366
|
-
|
|
64367
|
-
folders.push(import_node_path32.default.join(prefix, "lib", "node_modules"));
|
|
64413
|
+
for (const prefix of prefixes)
|
|
64414
|
+
folders.push(import_node_path32.default.join(prefix.replace(/^~(?=\/|$)/, env2["HOME"] ?? "~"), "lib", "node_modules"));
|
|
64368
64415
|
folders.push(import_node_path32.default.join(import_node_path32.default.dirname(import_node_path32.default.dirname(execPath)), "lib", "node_modules"));
|
|
64369
64416
|
}
|
|
64370
64417
|
return [...new Set(folders.map((folder) => import_node_path32.default.resolve(folder)))];
|
|
64371
64418
|
}
|
|
64419
|
+
function expandWindows(value, env2) {
|
|
64420
|
+
return value.replace(/%([^%]+)%|\$\{([^}]+)\}/g, (whole, a, b) => env2[a ?? b ?? ""] ?? whole);
|
|
64421
|
+
}
|
|
64372
64422
|
function addonServerName(pkg) {
|
|
64373
64423
|
const bare = pkg.replace(/^@[^/]+\//, "").replace(/^(light-code|lightcode|fire-code)-addon-/i, "");
|
|
64374
64424
|
const slug = bare.toLowerCase().replace(/[^a-z0-9-]+/g, "-").replace(/^-+|-+$/g, "");
|
|
@@ -64586,6 +64636,7 @@ var import_node_path33 = __toESM(require("node:path"), 1);
|
|
|
64586
64636
|
var SETTINGS_ENV = "LIGHT_CODE_ADDON_SETTINGS";
|
|
64587
64637
|
var DATA_ENV = "LIGHT_CODE_ADDON_DATA";
|
|
64588
64638
|
var DOWNLOADS_ENV = "LIGHT_CODE_ADDON_DOWNLOADS";
|
|
64639
|
+
var PANEL_TOOLS_ENV = "LIGHT_CODE_ADDON_PANEL_TOOLS";
|
|
64589
64640
|
function addonDataDir(storageDir, addon) {
|
|
64590
64641
|
return import_node_path33.default.join(storageDir, "addons", addon.server);
|
|
64591
64642
|
}
|
|
@@ -64601,7 +64652,8 @@ function deliveryFor(storageDir, addon, settings, stored) {
|
|
|
64601
64652
|
const env2 = {
|
|
64602
64653
|
[SETTINGS_ENV]: file2,
|
|
64603
64654
|
[DATA_ENV]: dir,
|
|
64604
|
-
[DOWNLOADS_ENV]: addonDownloadsDir(storageDir, addon)
|
|
64655
|
+
[DOWNLOADS_ENV]: addonDownloadsDir(storageDir, addon),
|
|
64656
|
+
[PANEL_TOOLS_ENV]: "1"
|
|
64605
64657
|
};
|
|
64606
64658
|
const secrets = {};
|
|
64607
64659
|
const secretFields = (owner) => ((owner === "record" ? addon.page?.records?.fields : addon.page?.fields) ?? []).filter((field2) => field2.type === "secret").map((field2) => field2.key);
|
|
@@ -65596,6 +65648,7 @@ function pick2(hubs, name) {
|
|
|
65596
65648
|
|
|
65597
65649
|
// ../../packages/core/dist/host/bridge.js
|
|
65598
65650
|
var import_node_os6 = __toESM(require("node:os"), 1);
|
|
65651
|
+
var import_node_fs11 = require("node:fs");
|
|
65599
65652
|
var import_node_path50 = __toESM(require("node:path"), 1);
|
|
65600
65653
|
|
|
65601
65654
|
// ../../packages/core/dist/modes/autoGuidance.js
|
|
@@ -78610,6 +78663,8 @@ ${preview.text}` } : {}
|
|
|
78610
78663
|
let backgroundRun = false;
|
|
78611
78664
|
let backgroundRunErrors = [];
|
|
78612
78665
|
let userTurnRunning = false;
|
|
78666
|
+
let userTurnSettled;
|
|
78667
|
+
let userTurnWindingDown = false;
|
|
78613
78668
|
let scheduledRunInFlight;
|
|
78614
78669
|
let pythonNestedContext;
|
|
78615
78670
|
let pythonNestedCallsAllowed = false;
|
|
@@ -79631,10 +79686,28 @@ ${preview.text}` } : {}
|
|
|
79631
79686
|
let installedAddons = [];
|
|
79632
79687
|
let addonProblems = [];
|
|
79633
79688
|
const addonRoot = services.codebaseDir ?? storageDir;
|
|
79689
|
+
let mcpStartProblem;
|
|
79690
|
+
function describeFailure2(error51, stack = false) {
|
|
79691
|
+
if (!(error51 instanceof Error))
|
|
79692
|
+
return String(error51);
|
|
79693
|
+
const code = error51.code;
|
|
79694
|
+
const head = `${error51.message}${typeof code === "string" && !error51.message.includes(code) ? ` (${code})` : ""}`;
|
|
79695
|
+
if (!stack || error51.stack === void 0)
|
|
79696
|
+
return head;
|
|
79697
|
+
return `${head}
|
|
79698
|
+
${error51.stack.split("\n").slice(1, 6).join("\n")}`;
|
|
79699
|
+
}
|
|
79700
|
+
function readUserNpmrc() {
|
|
79701
|
+
try {
|
|
79702
|
+
return (0, import_node_fs11.readFileSync)(process.env["NPM_CONFIG_USERCONFIG"] ?? import_node_path50.default.join(import_node_os6.default.homedir(), ".npmrc"), "utf8");
|
|
79703
|
+
} catch {
|
|
79704
|
+
return void 0;
|
|
79705
|
+
}
|
|
79706
|
+
}
|
|
79634
79707
|
function addonFolders(config2) {
|
|
79635
79708
|
return {
|
|
79636
79709
|
configured: (config2.addons?.folders ?? []).map((folder) => import_node_path50.default.resolve(folder)),
|
|
79637
|
-
defaults: defaultAddonFolders(process.env, process.execPath, process.platform)
|
|
79710
|
+
defaults: defaultAddonFolders(process.env, process.execPath, process.platform, readUserNpmrc())
|
|
79638
79711
|
};
|
|
79639
79712
|
}
|
|
79640
79713
|
async function rescanAddons(config2) {
|
|
@@ -79650,17 +79723,17 @@ ${preview.text}` } : {}
|
|
|
79650
79723
|
if (addon.page === void 0)
|
|
79651
79724
|
continue;
|
|
79652
79725
|
const settings = config2.addons?.settings?.[addon.package];
|
|
79653
|
-
const stored = /* @__PURE__ */ new Set();
|
|
79654
|
-
for (const ref of possibleSecretRefs(addon, settings))
|
|
79655
|
-
if (await secrets.get(ref) !== void 0)
|
|
79656
|
-
stored.add(ref);
|
|
79657
|
-
const delivery = deliveryFor(addonRoot, addon, settings, stored);
|
|
79658
79726
|
try {
|
|
79727
|
+
const stored = /* @__PURE__ */ new Set();
|
|
79728
|
+
for (const ref of possibleSecretRefs(addon, settings))
|
|
79729
|
+
if (await secrets.get(ref) !== void 0)
|
|
79730
|
+
stored.add(ref);
|
|
79731
|
+
const delivery = deliveryFor(addonRoot, addon, settings, stored);
|
|
79659
79732
|
await writeFileAtomically(delivery.file, JSON.stringify(delivery.contents, null, 2));
|
|
79660
79733
|
await import_promises27.default.mkdir(addonDownloadsDir(addonRoot, addon), { recursive: true });
|
|
79661
79734
|
delivered.set(addon.package, delivery.env);
|
|
79662
79735
|
} catch (error51) {
|
|
79663
|
-
logger.warn(`Could not
|
|
79736
|
+
logger.warn(`Could not prepare the settings for add-on ${addon.package}: ${describeFailure2(error51)}`);
|
|
79664
79737
|
}
|
|
79665
79738
|
}
|
|
79666
79739
|
await mcp.configure(runnableServers(servers, installedAddons, { execPath: process.execPath, electron: process.versions["electron"] !== void 0 }, workspaceMcpServers, (addon) => delivered.get(addon.package) ?? {}));
|
|
@@ -79693,7 +79766,14 @@ ${preview.text}` } : {}
|
|
|
79693
79766
|
state: addonState(addon, config2.mcpServers ?? {}),
|
|
79694
79767
|
values: settings?.values ?? {},
|
|
79695
79768
|
secretsSet: await isSet(void 0, addon.page.fields ?? []),
|
|
79696
|
-
records: await Promise.all((settings?.records ?? []).map(async (record2) => ({ ...record2, secretsSet: await isSet(record2.id, addon.page?.records?.fields ?? []) })))
|
|
79769
|
+
records: await Promise.all((settings?.records ?? []).map(async (record2) => ({ ...record2, secretsSet: await isSet(record2.id, addon.page?.records?.fields ?? []) }))),
|
|
79770
|
+
tools: (mcp.states_().find((server) => server.name === addon.server)?.tools ?? []).map((tool) => ({
|
|
79771
|
+
name: tool.namespacedName,
|
|
79772
|
+
server: addon.server,
|
|
79773
|
+
tool: tool.name,
|
|
79774
|
+
description: tool.description,
|
|
79775
|
+
permission: tool.permission
|
|
79776
|
+
}))
|
|
79697
79777
|
}
|
|
79698
79778
|
});
|
|
79699
79779
|
}
|
|
@@ -79782,18 +79862,23 @@ ${preview.text}` } : {}
|
|
|
79782
79862
|
return reply(false, "That button is not one this add-on declares.");
|
|
79783
79863
|
const { config: config2 } = await configManager.load();
|
|
79784
79864
|
if (addonState(addon, config2.mcpServers ?? {}) !== "enabled")
|
|
79785
|
-
return reply(false, `Enable ${addon.displayName} first
|
|
79865
|
+
return reply(false, `Enable ${addon.displayName} first, on the Add-ons tab in Settings.`);
|
|
79786
79866
|
const record2 = (config2.addons?.settings?.[pkg]?.records ?? []).find((candidate) => candidate.id === id);
|
|
79787
79867
|
if (record2 === void 0)
|
|
79788
79868
|
return reply(false, `That ${spec.noun} no longer exists.`);
|
|
79789
79869
|
await mcp.ensureConnected();
|
|
79790
|
-
const target = mcp.enabledTools().find((candidate) => candidate.name === `${addon.server}__${tool}`);
|
|
79791
|
-
if (target === void 0)
|
|
79792
|
-
return reply(false, `${addon.displayName} is not running, or offers no "${tool}". See its log in Settings \u2192 MCP.`);
|
|
79793
79870
|
try {
|
|
79794
|
-
const result = await
|
|
79795
|
-
const
|
|
79796
|
-
|
|
79871
|
+
const result = await mcp.callPanelTool(addon.server, tool, { [spec.keyField]: record2.values[spec.keyField] });
|
|
79872
|
+
const update = result.isError ? void 0 : recordUpdateFrom(result.structured);
|
|
79873
|
+
if (update !== void 0) {
|
|
79874
|
+
const cleaned = cleanAddonValues(spec.fields, { ...record2.values, ...update });
|
|
79875
|
+
if (cleaned.ok) {
|
|
79876
|
+
const current = config2.addons?.settings?.[pkg] ?? {};
|
|
79877
|
+
await storeAddonSettings(addon, { ...current, records: (current.records ?? []).map((r) => r.id === id ? { id, values: cleaned.values } : r) });
|
|
79878
|
+
await postAddonPage(pkg);
|
|
79879
|
+
}
|
|
79880
|
+
}
|
|
79881
|
+
reply(!result.isError, result.text.slice(0, 4e3));
|
|
79797
79882
|
} catch (error51) {
|
|
79798
79883
|
reply(false, error51 instanceof Error ? error51.message : String(error51));
|
|
79799
79884
|
}
|
|
@@ -79824,7 +79909,13 @@ ${preview.text}` } : {}
|
|
|
79824
79909
|
...state === "updated" && enabled !== void 0 ? { enabledVersion: enabled } : {},
|
|
79825
79910
|
...addon.page !== void 0 ? { pageTitle: addon.page.title } : {},
|
|
79826
79911
|
...addon.icon !== void 0 ? { icon: addon.icon } : {},
|
|
79827
|
-
...addon.pageProblem !== void 0 ? { pageProblem: addon.pageProblem } : {}
|
|
79912
|
+
...addon.pageProblem !== void 0 ? { pageProblem: addon.pageProblem } : {},
|
|
79913
|
+
...(() => {
|
|
79914
|
+
const running = state === "enabled" ? mcp.states_().find((server) => server.name === addon.server) : void 0;
|
|
79915
|
+
if (running === void 0)
|
|
79916
|
+
return {};
|
|
79917
|
+
return { status: running.status, ...running.error !== void 0 ? { error: running.error } : {}, logs: running.logs.slice(-40) };
|
|
79918
|
+
})()
|
|
79828
79919
|
};
|
|
79829
79920
|
});
|
|
79830
79921
|
post({
|
|
@@ -79838,7 +79929,10 @@ ${preview.text}` } : {}
|
|
|
79838
79929
|
})),
|
|
79839
79930
|
folders: folders.configured,
|
|
79840
79931
|
defaultFolders: folders.defaults,
|
|
79841
|
-
|
|
79932
|
+
.../* @__PURE__ */ (() => {
|
|
79933
|
+
const shown2 = error51 ?? mcpStartProblem;
|
|
79934
|
+
return shown2 !== void 0 ? { error: shown2 } : {};
|
|
79935
|
+
})()
|
|
79842
79936
|
});
|
|
79843
79937
|
}
|
|
79844
79938
|
async function handleEnableAddon(pkg) {
|
|
@@ -79859,10 +79953,23 @@ ${preview.text}` } : {}
|
|
|
79859
79953
|
const next = { ...servers, [addon.server]: addonServerEntry(addon, existing) };
|
|
79860
79954
|
await configManager.save("user", { mcpServers: next });
|
|
79861
79955
|
setMcpServersState(next);
|
|
79862
|
-
|
|
79863
|
-
|
|
79864
|
-
|
|
79865
|
-
|
|
79956
|
+
mcpStartProblem = void 0;
|
|
79957
|
+
try {
|
|
79958
|
+
await configureMcp(next);
|
|
79959
|
+
postMcp();
|
|
79960
|
+
await postAddons();
|
|
79961
|
+
await mcp.ensureConnected();
|
|
79962
|
+
} catch (error51) {
|
|
79963
|
+
logger.warn(`Starting add-on ${addon.package} failed: ${describeFailure2(error51, true)}`);
|
|
79964
|
+
postMcp();
|
|
79965
|
+
await postAddons(`${addon.displayName} is enabled, but starting it failed: ${describeFailure2(error51)}. To retry, press Disable and then Enable.`);
|
|
79966
|
+
return;
|
|
79967
|
+
}
|
|
79968
|
+
const started = mcp.states_().find((server) => server.name === addon.server);
|
|
79969
|
+
if (started?.status === "failed") {
|
|
79970
|
+
const said = started.logs.filter((line) => !/^(Starting |Failed: )/.test(line)).slice(-3).join(" | ");
|
|
79971
|
+
await postAddons(`${addon.displayName} was enabled but could not start: ${started.error ?? "no reason given"}${said.length > 0 ? ` - it said: ${said}` : ""}. Its full log is under Log on its row below.`);
|
|
79972
|
+
}
|
|
79866
79973
|
}
|
|
79867
79974
|
async function handleRemoveAddon(server) {
|
|
79868
79975
|
const { config: config2 } = await configManager.load();
|
|
@@ -80026,6 +80133,9 @@ ${preview.text}` } : {}
|
|
|
80026
80133
|
if (handoffAbort !== void 0)
|
|
80027
80134
|
return;
|
|
80028
80135
|
const progress = (phase, extra = {}) => post({ type: "handoffProgress", phase, ...extra });
|
|
80136
|
+
if (userTurnRunning && userTurnWindingDown && userTurnSettled !== void 0) {
|
|
80137
|
+
await Promise.race([userTurnSettled, new Promise((resolve) => setTimeout(resolve, 3e4))]);
|
|
80138
|
+
}
|
|
80029
80139
|
if (userTurnRunning || scheduledRunInFlight !== void 0) {
|
|
80030
80140
|
progress("failed", { message: "A reply is still running. Wait for it to finish, or press Stop, then try again." });
|
|
80031
80141
|
return;
|
|
@@ -80587,7 +80697,10 @@ ${direction}` : attachMentions(text, mentions);
|
|
|
80587
80697
|
taskCheckpoint = checkpoint;
|
|
80588
80698
|
post({ type: "checkpointAvailable" });
|
|
80589
80699
|
},
|
|
80590
|
-
onDone: (ending) =>
|
|
80700
|
+
onDone: (ending) => {
|
|
80701
|
+
userTurnWindingDown = true;
|
|
80702
|
+
post({ type: "done", ...ending === "question" ? { awaitingAnswer: true } : {} });
|
|
80703
|
+
},
|
|
80591
80704
|
onError: (message4) => post({ type: "error", message: message4 })
|
|
80592
80705
|
}, turnOptions);
|
|
80593
80706
|
} catch (error51) {
|
|
@@ -85735,6 +85848,20 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
85735
85848
|
post({ type: "error", message: error51 instanceof Error ? error51.message : String(error51) });
|
|
85736
85849
|
}
|
|
85737
85850
|
}
|
|
85851
|
+
function reportAddonFailure(operation, work, pkg) {
|
|
85852
|
+
work.catch(async (error51) => {
|
|
85853
|
+
logger.warn(`${operation} failed: ${describeFailure2(error51, true)}`);
|
|
85854
|
+
const said = `${operation} failed: ${describeFailure2(error51)}`;
|
|
85855
|
+
try {
|
|
85856
|
+
if (pkg !== void 0)
|
|
85857
|
+
await postAddonPage(pkg, { error: said });
|
|
85858
|
+
else
|
|
85859
|
+
await postAddons(said);
|
|
85860
|
+
} catch {
|
|
85861
|
+
post({ type: "error", message: said });
|
|
85862
|
+
}
|
|
85863
|
+
});
|
|
85864
|
+
}
|
|
85738
85865
|
function reportFailure(operation, work) {
|
|
85739
85866
|
work.catch((error51) => {
|
|
85740
85867
|
const reason = error51 instanceof Error ? error51.message : String(error51);
|
|
@@ -85755,10 +85882,14 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
85755
85882
|
await scheduledRunInFlight;
|
|
85756
85883
|
}
|
|
85757
85884
|
userTurnRunning = true;
|
|
85885
|
+
userTurnWindingDown = false;
|
|
85886
|
+
const turn = handleSendMessage(composeUserText(message4.text, { replyTo: boundedQuote(message4.replyTo), reactions: takeReactions() }), message4.images);
|
|
85887
|
+
userTurnSettled = turn.then(() => void 0, () => void 0);
|
|
85758
85888
|
try {
|
|
85759
|
-
await
|
|
85889
|
+
await turn;
|
|
85760
85890
|
} finally {
|
|
85761
85891
|
userTurnRunning = false;
|
|
85892
|
+
userTurnWindingDown = false;
|
|
85762
85893
|
}
|
|
85763
85894
|
})();
|
|
85764
85895
|
} else if (message4.type === "compactConversation") {
|
|
@@ -85986,21 +86117,21 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
85986
86117
|
} else if (message4.type === "requestAddonPage") {
|
|
85987
86118
|
reportFailure("postAddonPage", postAddonPage(message4.package));
|
|
85988
86119
|
} else if (message4.type === "saveAddonRecord") {
|
|
85989
|
-
|
|
86120
|
+
reportAddonFailure("Saving", handleSaveAddonRecord(message4), message4.package);
|
|
85990
86121
|
} else if (message4.type === "deleteAddonRecord") {
|
|
85991
|
-
|
|
86122
|
+
reportAddonFailure("Removing", handleDeleteAddonRecord(message4.package, message4.id), message4.package);
|
|
85992
86123
|
} else if (message4.type === "saveAddonValues") {
|
|
85993
|
-
|
|
86124
|
+
reportAddonFailure("Saving", handleSaveAddonValues(message4), message4.package);
|
|
85994
86125
|
} else if (message4.type === "runAddonAction") {
|
|
85995
|
-
|
|
86126
|
+
reportAddonFailure(message4.tool, handleRunAddonAction(message4.package, message4.id, message4.tool), message4.package);
|
|
85996
86127
|
} else if (message4.type === "requestAddons") {
|
|
85997
86128
|
reportFailure("postAddons", postAddons());
|
|
85998
86129
|
} else if (message4.type === "enableAddon") {
|
|
85999
|
-
|
|
86130
|
+
reportAddonFailure("Enabling", handleEnableAddon(message4.package));
|
|
86000
86131
|
} else if (message4.type === "removeAddon") {
|
|
86001
|
-
|
|
86132
|
+
reportAddonFailure("Disabling", handleRemoveAddon(message4.server));
|
|
86002
86133
|
} else if (message4.type === "saveAddonFolders") {
|
|
86003
|
-
|
|
86134
|
+
reportAddonFailure("Saving the folders", handleSaveAddonFolders(message4.folders));
|
|
86004
86135
|
} else if (message4.type === "openCodebaseInstructions") {
|
|
86005
86136
|
reportFailure("handleOpenCodebaseInstructions", handleOpenCodebaseInstructions());
|
|
86006
86137
|
} else if (message4.type === "requestAtlassian") {
|
|
@@ -86415,8 +86546,11 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
86415
86546
|
const { config: config2 } = await configManager.load();
|
|
86416
86547
|
await syncMcpFromConfig(config2);
|
|
86417
86548
|
await mcp.ensureConnected();
|
|
86549
|
+
mcpStartProblem = void 0;
|
|
86418
86550
|
} catch (error51) {
|
|
86419
|
-
logger.warn(`Could not start MCP servers: ${error51
|
|
86551
|
+
logger.warn(`Could not start MCP servers: ${describeFailure2(error51, true)}`);
|
|
86552
|
+
mcpStartProblem = `Starting MCP servers and add-ons failed when Light Code opened: ${describeFailure2(error51)}`;
|
|
86553
|
+
await postAddons().catch(() => void 0);
|
|
86420
86554
|
}
|
|
86421
86555
|
})();
|
|
86422
86556
|
void (async () => {
|
|
@@ -87338,7 +87472,7 @@ var import_promises28 = __toESM(require("node:fs/promises"), 1);
|
|
|
87338
87472
|
var import_node_path52 = __toESM(require("node:path"), 1);
|
|
87339
87473
|
|
|
87340
87474
|
// ../../packages/core/dist/lsp/catalog.js
|
|
87341
|
-
var
|
|
87475
|
+
var import_node_fs12 = require("node:fs");
|
|
87342
87476
|
var import_node_path51 = __toESM(require("node:path"), 1);
|
|
87343
87477
|
var c = (command, ...args) => ({ command, args });
|
|
87344
87478
|
var LSP_LANGUAGES = [
|
|
@@ -87397,7 +87531,7 @@ function languageIdFor(language, file2) {
|
|
|
87397
87531
|
var found = /* @__PURE__ */ new Map();
|
|
87398
87532
|
function findOnPath(command, env2 = process.env) {
|
|
87399
87533
|
if (import_node_path51.default.isAbsolute(command))
|
|
87400
|
-
return (0,
|
|
87534
|
+
return (0, import_node_fs12.existsSync)(command) ? command : void 0;
|
|
87401
87535
|
if (env2 !== process.env)
|
|
87402
87536
|
return searchPath(command, env2);
|
|
87403
87537
|
const hit = found.get(command);
|
|
@@ -87413,7 +87547,7 @@ function searchPath(command, env2) {
|
|
|
87413
87547
|
for (const dir of dirs) {
|
|
87414
87548
|
for (const ext of exts) {
|
|
87415
87549
|
const candidate = import_node_path51.default.join(dir, command + ext);
|
|
87416
|
-
if ((0,
|
|
87550
|
+
if ((0, import_node_fs12.existsSync)(candidate) && (process.platform !== "win32" || ext !== "" || /\.(exe|cmd|bat)$/i.test(candidate)))
|
|
87417
87551
|
return candidate;
|
|
87418
87552
|
}
|
|
87419
87553
|
}
|
|
@@ -90014,7 +90148,19 @@ Settings \u2192 Export source code saves the whole repository as a zip that buil
|
|
|
90014
90148
|
"bastion",
|
|
90015
90149
|
"host key",
|
|
90016
90150
|
"addon tab",
|
|
90017
|
-
"linux tab"
|
|
90151
|
+
"linux tab",
|
|
90152
|
+
"add-ons tab",
|
|
90153
|
+
"enable addon",
|
|
90154
|
+
"disable addon",
|
|
90155
|
+
"linux tab missing",
|
|
90156
|
+
"addon could not start",
|
|
90157
|
+
"addon failed",
|
|
90158
|
+
"start again",
|
|
90159
|
+
"ssh key",
|
|
90160
|
+
"set up ssh key",
|
|
90161
|
+
"key setup",
|
|
90162
|
+
"authorized_keys",
|
|
90163
|
+
"passwordless"
|
|
90018
90164
|
],
|
|
90019
90165
|
body: `
|
|
90020
90166
|
**An add-on is an npm package that runs an MCP server**, labelled in its \`package.json\`:
|
|
@@ -90031,11 +90177,12 @@ Settings \u2192 Export source code saves the whole repository as a zip that buil
|
|
|
90031
90177
|
\`registerTool\`, \`StdioServerTransport\`). \`examples/light-code-addon-hello\` in the source is a
|
|
90032
90178
|
complete one. Light Code, Fire Code, the Node host and the JetBrains plugin all use the same add-ons.
|
|
90033
90179
|
|
|
90034
|
-
**Install it** with \`npm i -g <package or folder>\`, then **Settings \u2192
|
|
90035
|
-
|
|
90036
|
-
|
|
90037
|
-
|
|
90038
|
-
|
|
90180
|
+
**Install it** with \`npm i -g <package or folder>\`, then open **Settings \u2192 Add-ons** (the puzzle
|
|
90181
|
+
piece). Light Code finds it by itself in npm's global folder - also where \`npm config set prefix\` moved
|
|
90182
|
+
it, and beside node.exe - and in any folders listed there (Browse\u2026 adds one). **Installed is not
|
|
90183
|
+
enabled**: press Enable, read the program it will run, and confirm. Its tools then appear as
|
|
90184
|
+
\`addon-<name>__<tool>\` and are asked about like every other tool. An add-on's server is not listed on
|
|
90185
|
+
the MCP tab, which keeps the servers you configured yourself.
|
|
90039
90186
|
|
|
90040
90187
|
**An update stays off until you enable the new version** - new code is looked at first. An add-on
|
|
90041
90188
|
that is no longer installed stays off and is listed so you can remove it. Enabling writes an ordinary
|
|
@@ -90047,13 +90194,14 @@ can never switch an add-on on. \`addons.folders\` is user-scope only.
|
|
|
90047
90194
|
editor's own Node inside VS Code, so no Node install is needed there; Fire Code uses its Node.
|
|
90048
90195
|
|
|
90049
90196
|
**An add-on can bring its own settings tab**, with its own icon - it appears in Settings only while
|
|
90050
|
-
the add-on is installed
|
|
90197
|
+
the add-on is installed **and enabled**; disable it and the tab goes (what you entered is kept). The tab
|
|
90198
|
+
lists the tools the add-on gives the assistant, each with Ask first / Always allow / Never. The add-on describes the fields in \`package.json\`
|
|
90051
90199
|
(\`lightCode.addon.settings\`: a title, its own fields, and a list such as "machines" with buttons like
|
|
90052
90200
|
Test connection); Light Code draws the form. What you enter is kept in your settings, passwords in
|
|
90053
90201
|
secret storage, and the add-on receives them when it starts - saving the tab restarts it.
|
|
90054
90202
|
|
|
90055
|
-
**The Linux add-on** (\`npm i -g @chosengeneration/light-code-addon-linux\`): enable it
|
|
90056
|
-
|
|
90203
|
+
**The Linux add-on** (\`npm i -g @chosengeneration/light-code-addon-linux\`): enable it on the
|
|
90204
|
+
**Add-ons** tab, then add machines on its **Linux** tab, each with a short label (\`prod-web-1\`), host, user
|
|
90057
90205
|
and sign-in (Pageant - the default - the Windows OpenSSH agent, a key file, or a password), and press
|
|
90058
90206
|
Test connection. The assistant can then list the machines, **run read-only commands** (\`df -h\`, \`tail\`,
|
|
90059
90207
|
\`grep\`, \`ps\`, \`journalctl\`, \`systemctl status\`, \`docker ps\`... joined with \`|\`; nothing that writes,
|
|
@@ -90062,7 +90210,18 @@ ssh.exe, no new program - with one sign-in per machine reused, and a refused sig
|
|
|
90062
90210
|
it does not set off security monitoring or lock an account. Host keys are trusted the first time and
|
|
90063
90211
|
checked after; a changed key is refused until you press Forget host key. A machine behind a bastion:
|
|
90064
90212
|
add the bastion too and put its label in *Connect through*. Newer PuTTY keys (.ppk version 3): load
|
|
90065
|
-
them into Pageant, or export an OpenSSH key from PuTTYgen.
|
|
90213
|
+
them into Pageant, or export an OpenSSH key from PuTTYgen. **No key yet?** Choose Password, then press
|
|
90214
|
+
**Set up SSH key** on the machine: it makes one key for this PC (\`.ssh\\light-code_ed25519\`), adds its
|
|
90215
|
+
public half to the server's authorized_keys with the stored password, proves the key works, and switches
|
|
90216
|
+
the machine to it. It is a button only - the assistant cannot call it - and the tab lists the tools the
|
|
90217
|
+
assistant does get. A globally installed add-on is found by itself (npm's folder, your .npmrc prefix,
|
|
90218
|
+
or beside node.exe); the folder box is only for somewhere else.
|
|
90219
|
+
|
|
90220
|
+
**The Linux tab is missing, or Enable seemed to do nothing?** Look at the add-on's row on the **Add-ons**
|
|
90221
|
+
tab: once enabled it says Running, or *Could not start* with the reason, a **Log** with what the add-on
|
|
90222
|
+
printed, and **Start again**. An add-on that cannot start is still enabled, so its tab is there. Any
|
|
90223
|
+
other failure is shown at the top of the Add-ons tab (not in the chat). Fire Code writes the full error to
|
|
90224
|
+
the agent's log too (right-click the codebase \u2192 View agent log); VS Code to View \u2192 Output \u2192 Light Code.
|
|
90066
90225
|
`
|
|
90067
90226
|
},
|
|
90068
90227
|
{
|
|
@@ -93243,7 +93402,7 @@ var RoutedSecretStore = class {
|
|
|
93243
93402
|
|
|
93244
93403
|
// src/userVariables.ts
|
|
93245
93404
|
var import_promises32 = __toESM(require("node:fs/promises"), 1);
|
|
93246
|
-
var
|
|
93405
|
+
var import_node_fs13 = require("node:fs");
|
|
93247
93406
|
var import_node_path58 = __toESM(require("node:path"), 1);
|
|
93248
93407
|
var UserVariableStore = class {
|
|
93249
93408
|
constructor(filePath) {
|
|
@@ -93277,7 +93436,7 @@ function userVariablesPath(userDir) {
|
|
|
93277
93436
|
}
|
|
93278
93437
|
function readVariablesFile(filePath) {
|
|
93279
93438
|
try {
|
|
93280
|
-
const raw = JSON.parse((0,
|
|
93439
|
+
const raw = JSON.parse((0, import_node_fs13.readFileSync)(filePath, "utf8"));
|
|
93281
93440
|
const parsed = sessionVariablesSchema.safeParse(raw["variables"]);
|
|
93282
93441
|
return parsed.success ? parsed.data : [];
|
|
93283
93442
|
} catch {
|
|
@@ -93301,7 +93460,7 @@ function hostedUser(env2 = process.env) {
|
|
|
93301
93460
|
}
|
|
93302
93461
|
|
|
93303
93462
|
// src/session.ts
|
|
93304
|
-
var
|
|
93463
|
+
var import_node_fs14 = require("node:fs");
|
|
93305
93464
|
var import_promises33 = __toESM(require("node:fs/promises"), 1);
|
|
93306
93465
|
var import_node_path60 = __toESM(require("node:path"), 1);
|
|
93307
93466
|
|
|
@@ -93560,7 +93719,7 @@ var FileConfigStore = class {
|
|
|
93560
93719
|
};
|
|
93561
93720
|
let watcher;
|
|
93562
93721
|
try {
|
|
93563
|
-
watcher = (0,
|
|
93722
|
+
watcher = (0, import_node_fs14.watch)(import_node_path60.default.dirname(filePath), (_event, filename) => {
|
|
93564
93723
|
if (filename === import_node_path60.default.basename(filePath)) onChange();
|
|
93565
93724
|
});
|
|
93566
93725
|
} catch {
|
|
@@ -94358,7 +94517,7 @@ async function startServer(options) {
|
|
|
94358
94517
|
connection.transport.post({ type: "credentials", credentials: await readCredentials() });
|
|
94359
94518
|
}
|
|
94360
94519
|
if (options.credentialsFile !== void 0) {
|
|
94361
|
-
(0,
|
|
94520
|
+
(0, import_node_fs15.watchFile)(options.credentialsFile, { interval: 1500 }, () => {
|
|
94362
94521
|
for (const connection of connections.values()) void postCredentials(connection);
|
|
94363
94522
|
});
|
|
94364
94523
|
}
|