@lead-routing/cli 0.6.6 → 0.6.7
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/index.js +35 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1408,14 +1408,46 @@ The managed package is already installed \u2014 just click "Connect Salesforce"
|
|
|
1408
1408
|
try {
|
|
1409
1409
|
let webhookSecret = "";
|
|
1410
1410
|
const envEngineContent = readFileSync4(join5(dir, ".env.engine"), "utf-8");
|
|
1411
|
-
const
|
|
1412
|
-
if (
|
|
1411
|
+
const wsMatch = envEngineContent.match(/^(?:ENGINE_)?WEBHOOK_SECRET=(.+)$/m);
|
|
1412
|
+
if (wsMatch) webhookSecret = wsMatch[1].trim();
|
|
1413
|
+
let apiToken = "";
|
|
1414
|
+
if (webhookSecret) {
|
|
1415
|
+
try {
|
|
1416
|
+
log7.step("Generating MCP API token...");
|
|
1417
|
+
const loginRes = await fetch(`${cfg.appUrl}/api/auth/login`, {
|
|
1418
|
+
method: "POST",
|
|
1419
|
+
headers: { "Content-Type": "application/json" },
|
|
1420
|
+
body: JSON.stringify({ email: cfg.adminEmail, password: cfg.adminPassword }),
|
|
1421
|
+
redirect: "manual"
|
|
1422
|
+
});
|
|
1423
|
+
if (loginRes.ok) {
|
|
1424
|
+
const cookies = loginRes.headers.getSetCookie?.() ?? [];
|
|
1425
|
+
const cookieHeader = cookies.join("; ");
|
|
1426
|
+
const tokenRes = await fetch(`${cfg.appUrl}/api/tokens`, {
|
|
1427
|
+
method: "POST",
|
|
1428
|
+
headers: {
|
|
1429
|
+
"Content-Type": "application/json",
|
|
1430
|
+
"Cookie": cookieHeader
|
|
1431
|
+
},
|
|
1432
|
+
body: JSON.stringify({ name: "Claude Code MCP", scopes: ["read", "write", "route"] })
|
|
1433
|
+
});
|
|
1434
|
+
if (tokenRes.ok) {
|
|
1435
|
+
const tokenData = await tokenRes.json();
|
|
1436
|
+
apiToken = tokenData.token;
|
|
1437
|
+
log7.success("MCP API token created");
|
|
1438
|
+
}
|
|
1439
|
+
}
|
|
1440
|
+
} catch {
|
|
1441
|
+
}
|
|
1442
|
+
}
|
|
1413
1443
|
if (webhookSecret) {
|
|
1414
1444
|
const mcpDir = join5(homedir3(), ".lead-routing");
|
|
1415
1445
|
mkdirSync3(mcpDir, { recursive: true });
|
|
1446
|
+
const mcpConfig = { appUrl: cfg.appUrl, engineUrl: cfg.engineUrl, webhookSecret };
|
|
1447
|
+
if (apiToken) mcpConfig.apiToken = apiToken;
|
|
1416
1448
|
writeFileSync4(
|
|
1417
1449
|
join5(mcpDir, "mcp.json"),
|
|
1418
|
-
JSON.stringify(
|
|
1450
|
+
JSON.stringify(mcpConfig, null, 2),
|
|
1419
1451
|
"utf-8"
|
|
1420
1452
|
);
|
|
1421
1453
|
note3(
|