@deckasoft/waify 0.3.7 → 0.3.8
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/index.js +15 -7
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -1019,11 +1019,6 @@ var registerSetup = (program2) => {
|
|
|
1019
1019
|
console.warn("Creating config directory...");
|
|
1020
1020
|
mkdirSync4(join2(homedir2(), ".config", "waify"), { recursive: true });
|
|
1021
1021
|
const baseUrl = loadConfig().openwaBaseUrl;
|
|
1022
|
-
const rawApiKey = await promptLine(
|
|
1023
|
-
rl,
|
|
1024
|
-
'OpenWA API key (press Enter to use default "dev-admin-key"):\n> '
|
|
1025
|
-
);
|
|
1026
|
-
const openwaApiKey = rawApiKey.trim() || "dev-admin-key";
|
|
1027
1022
|
let geminiKey = "";
|
|
1028
1023
|
while (!geminiKey.trim()) {
|
|
1029
1024
|
geminiKey = await promptLine(
|
|
@@ -1046,8 +1041,8 @@ var registerSetup = (program2) => {
|
|
|
1046
1041
|
}
|
|
1047
1042
|
}
|
|
1048
1043
|
const chatId = `${recipientNumber.trim()}@c.us`;
|
|
1049
|
-
saveSecrets({ GEMINI_API_KEY: geminiKey.trim(), OPENWA_API_KEY:
|
|
1050
|
-
saveConfig({ ...loadConfig(),
|
|
1044
|
+
saveSecrets({ GEMINI_API_KEY: geminiKey.trim(), OPENWA_API_KEY: "" });
|
|
1045
|
+
saveConfig({ ...loadConfig(), recipients: [{ chatId }] });
|
|
1051
1046
|
console.warn("Writing docker-compose.yml...");
|
|
1052
1047
|
writeFileSync5(composePath(), composeTemplate(), "utf-8");
|
|
1053
1048
|
console.warn("Starting OpenWA containers (this may take a minute on first run)...");
|
|
@@ -1079,6 +1074,19 @@ var registerSetup = (program2) => {
|
|
|
1079
1074
|
process.exitCode = 1;
|
|
1080
1075
|
return;
|
|
1081
1076
|
}
|
|
1077
|
+
console.warn("Reading API key from container...");
|
|
1078
|
+
const keyResult = spawnSync(
|
|
1079
|
+
"docker",
|
|
1080
|
+
["compose", "-f", composePath(), "exec", "-T", "openwa-api", "cat", "/app/data/.api-key"],
|
|
1081
|
+
{ encoding: "utf-8" }
|
|
1082
|
+
);
|
|
1083
|
+
const openwaApiKey = keyResult.stdout?.trim();
|
|
1084
|
+
if (keyResult.status !== 0 || !openwaApiKey) {
|
|
1085
|
+
const errorMsg = keyResult.stderr?.trim() || "Could not read API key from container.";
|
|
1086
|
+
throw new Error(`${errorMsg} Check logs with: docker compose -f ${composePath()} logs openwa-api`);
|
|
1087
|
+
}
|
|
1088
|
+
saveSecrets({ GEMINI_API_KEY: geminiKey.trim(), OPENWA_API_KEY: openwaApiKey });
|
|
1089
|
+
saveConfig({ ...loadConfig(), openwaApiKey, recipients: [{ chatId }] });
|
|
1082
1090
|
console.warn("Creating WhatsApp session...");
|
|
1083
1091
|
const sessionRes = await fetchWithTimeout(`${baseUrl}/api/sessions`, {
|
|
1084
1092
|
method: "POST",
|