@deckasoft/waify 0.3.6 → 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 -13
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -1000,12 +1000,6 @@ var composeTemplate = () => `services:
|
|
|
1000
1000
|
- openwa-data:/app/data
|
|
1001
1001
|
restart: unless-stopped
|
|
1002
1002
|
|
|
1003
|
-
openwa-dashboard:
|
|
1004
|
-
image: ghcr.io/deckasoft/openwa-dashboard:latest
|
|
1005
|
-
ports:
|
|
1006
|
-
- '2886:80'
|
|
1007
|
-
restart: unless-stopped
|
|
1008
|
-
|
|
1009
1003
|
volumes:
|
|
1010
1004
|
openwa-data:
|
|
1011
1005
|
`;
|
|
@@ -1025,11 +1019,6 @@ var registerSetup = (program2) => {
|
|
|
1025
1019
|
console.warn("Creating config directory...");
|
|
1026
1020
|
mkdirSync4(join2(homedir2(), ".config", "waify"), { recursive: true });
|
|
1027
1021
|
const baseUrl = loadConfig().openwaBaseUrl;
|
|
1028
|
-
const rawApiKey = await promptLine(
|
|
1029
|
-
rl,
|
|
1030
|
-
'OpenWA API key (press Enter to use default "dev-admin-key"):\n> '
|
|
1031
|
-
);
|
|
1032
|
-
const openwaApiKey = rawApiKey.trim() || "dev-admin-key";
|
|
1033
1022
|
let geminiKey = "";
|
|
1034
1023
|
while (!geminiKey.trim()) {
|
|
1035
1024
|
geminiKey = await promptLine(
|
|
@@ -1052,8 +1041,8 @@ var registerSetup = (program2) => {
|
|
|
1052
1041
|
}
|
|
1053
1042
|
}
|
|
1054
1043
|
const chatId = `${recipientNumber.trim()}@c.us`;
|
|
1055
|
-
saveSecrets({ GEMINI_API_KEY: geminiKey.trim(), OPENWA_API_KEY:
|
|
1056
|
-
saveConfig({ ...loadConfig(),
|
|
1044
|
+
saveSecrets({ GEMINI_API_KEY: geminiKey.trim(), OPENWA_API_KEY: "" });
|
|
1045
|
+
saveConfig({ ...loadConfig(), recipients: [{ chatId }] });
|
|
1057
1046
|
console.warn("Writing docker-compose.yml...");
|
|
1058
1047
|
writeFileSync5(composePath(), composeTemplate(), "utf-8");
|
|
1059
1048
|
console.warn("Starting OpenWA containers (this may take a minute on first run)...");
|
|
@@ -1085,6 +1074,19 @@ var registerSetup = (program2) => {
|
|
|
1085
1074
|
process.exitCode = 1;
|
|
1086
1075
|
return;
|
|
1087
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 }] });
|
|
1088
1090
|
console.warn("Creating WhatsApp session...");
|
|
1089
1091
|
const sessionRes = await fetchWithTimeout(`${baseUrl}/api/sessions`, {
|
|
1090
1092
|
method: "POST",
|