@moltium/core 0.1.5 → 0.1.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.d.cts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +99 -39
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +99 -39
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1002,46 +1002,104 @@ var Agent = class {
|
|
|
1002
1002
|
}
|
|
1003
1003
|
}
|
|
1004
1004
|
async initSocialAdapters() {
|
|
1005
|
-
const
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1005
|
+
const social = this.config.social;
|
|
1006
|
+
await this.initMoltbook(social);
|
|
1007
|
+
await this.initTwitter(social);
|
|
1008
|
+
if (Object.keys(this.socialAdapters).length === 0) {
|
|
1009
|
+
logger4.warn("Social: No adapters connected. Set MOLTBOOK_API_KEY or Twitter env vars in your .env to enable.");
|
|
1010
|
+
}
|
|
1011
|
+
}
|
|
1012
|
+
async initMoltbook(social) {
|
|
1013
|
+
const envKey = process.env.MOLTBOOK_API_KEY;
|
|
1014
|
+
const configMoltbook = social.moltbook;
|
|
1015
|
+
const apiKey = configMoltbook?.apiKey || envKey || "";
|
|
1016
|
+
const isPlaceholder = !apiKey || apiKey === "your-moltbook-key-here";
|
|
1017
|
+
const explicitlyDisabled = configMoltbook && configMoltbook.enabled === false;
|
|
1018
|
+
const shouldConnect = !isPlaceholder && !explicitlyDisabled;
|
|
1019
|
+
if (explicitlyDisabled) {
|
|
1020
|
+
logger4.info("Moltbook: Disabled in config (enabled: false) \u2014 skipping");
|
|
1021
|
+
return;
|
|
1022
|
+
}
|
|
1023
|
+
if (isPlaceholder) {
|
|
1024
|
+
if (configMoltbook?.enabled || envKey) {
|
|
1025
|
+
logger4.warn("Moltbook: MOLTBOOK_API_KEY is missing or still a placeholder.");
|
|
1026
|
+
logger4.warn(" Fix: Set a valid MOLTBOOK_API_KEY in your .env file.");
|
|
1022
1027
|
}
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1028
|
+
return;
|
|
1029
|
+
}
|
|
1030
|
+
if (!shouldConnect) return;
|
|
1031
|
+
const source = configMoltbook?.apiKey ? "config" : "environment";
|
|
1032
|
+
const baseUrl = configMoltbook?.baseUrl || process.env.MOLTBOOK_BASE_URL || "https://www.moltbook.com/api/v1";
|
|
1033
|
+
const defaultSubmolt = configMoltbook?.defaultSubmolt || "general";
|
|
1034
|
+
const effectiveConfig = {
|
|
1035
|
+
enabled: true,
|
|
1036
|
+
apiKey,
|
|
1037
|
+
baseUrl,
|
|
1038
|
+
defaultSubmolt,
|
|
1039
|
+
...configMoltbook,
|
|
1040
|
+
// Ensure env-resolved values win when config didn't set them
|
|
1041
|
+
...configMoltbook?.apiKey ? {} : { apiKey },
|
|
1042
|
+
...configMoltbook?.baseUrl ? {} : { baseUrl }
|
|
1043
|
+
};
|
|
1044
|
+
logger4.info(`Moltbook: API key detected from ${source}`);
|
|
1045
|
+
logger4.info(`Moltbook: Connecting to ${baseUrl} ...`);
|
|
1046
|
+
const adapter = new MoltbookAdapter(effectiveConfig);
|
|
1047
|
+
try {
|
|
1048
|
+
await adapter.connect();
|
|
1049
|
+
this.socialAdapters["moltbook"] = adapter;
|
|
1050
|
+
social.moltbook = effectiveConfig;
|
|
1051
|
+
logger4.info(`Moltbook: Connected successfully (submolt: ${defaultSubmolt})`);
|
|
1052
|
+
} catch (error) {
|
|
1053
|
+
logger4.error(`Moltbook: Connection FAILED \u2014 ${error.message || error}`);
|
|
1054
|
+
this.logPlatformError("Moltbook", error);
|
|
1055
|
+
}
|
|
1056
|
+
}
|
|
1057
|
+
async initTwitter(social) {
|
|
1058
|
+
const configTwitter = social.twitter;
|
|
1059
|
+
const envApiKey = process.env.TWITTER_API_KEY;
|
|
1060
|
+
const envApiSecret = process.env.TWITTER_API_SECRET;
|
|
1061
|
+
const envAccessToken = process.env.TWITTER_ACCESS_TOKEN;
|
|
1062
|
+
const envAccessSecret = process.env.TWITTER_ACCESS_SECRET;
|
|
1063
|
+
const creds = configTwitter?.credentials;
|
|
1064
|
+
const apiKey = creds?.apiKey || envApiKey || "";
|
|
1065
|
+
const apiSecret = creds?.apiSecret || envApiSecret || "";
|
|
1066
|
+
const accessToken = creds?.accessToken || envAccessToken || "";
|
|
1067
|
+
const accessSecret = creds?.accessSecret || envAccessSecret || "";
|
|
1068
|
+
const hasKey = apiKey && apiKey !== "your-twitter-api-key";
|
|
1069
|
+
const hasAllCreds = hasKey && apiSecret && accessToken && accessSecret;
|
|
1070
|
+
const explicitlyDisabled = configTwitter && configTwitter.enabled === false;
|
|
1071
|
+
if (explicitlyDisabled) {
|
|
1072
|
+
logger4.info("Twitter: Disabled in config (enabled: false) \u2014 skipping");
|
|
1073
|
+
return;
|
|
1074
|
+
}
|
|
1075
|
+
if (!hasKey) {
|
|
1076
|
+
if (configTwitter?.enabled || envApiKey) {
|
|
1077
|
+
logger4.warn("Twitter: Credentials are missing or still placeholders.");
|
|
1078
|
+
logger4.warn(" Fix: Set valid Twitter keys in your .env file.");
|
|
1042
1079
|
}
|
|
1043
|
-
|
|
1044
|
-
|
|
1080
|
+
return;
|
|
1081
|
+
}
|
|
1082
|
+
if (!hasAllCreds) {
|
|
1083
|
+
logger4.warn("Twitter: Some credentials are missing. Need: TWITTER_API_KEY, TWITTER_API_SECRET, TWITTER_ACCESS_TOKEN, TWITTER_ACCESS_SECRET");
|
|
1084
|
+
return;
|
|
1085
|
+
}
|
|
1086
|
+
const source = creds?.apiKey ? "config" : "environment";
|
|
1087
|
+
logger4.info(`Twitter: Credentials detected from ${source}`);
|
|
1088
|
+
logger4.info("Twitter: Connecting...");
|
|
1089
|
+
const effectiveConfig = {
|
|
1090
|
+
enabled: true,
|
|
1091
|
+
...configTwitter,
|
|
1092
|
+
credentials: { apiKey, apiSecret, accessToken, accessSecret }
|
|
1093
|
+
};
|
|
1094
|
+
const adapter = new TwitterAdapter(effectiveConfig);
|
|
1095
|
+
try {
|
|
1096
|
+
await adapter.connect();
|
|
1097
|
+
this.socialAdapters["twitter"] = adapter;
|
|
1098
|
+
social.twitter = effectiveConfig;
|
|
1099
|
+
logger4.info("Twitter: Connected successfully");
|
|
1100
|
+
} catch (error) {
|
|
1101
|
+
logger4.error(`Twitter: Connection FAILED \u2014 ${error.message || error}`);
|
|
1102
|
+
this.logPlatformError("Twitter", error);
|
|
1045
1103
|
}
|
|
1046
1104
|
}
|
|
1047
1105
|
async postStartupMessages() {
|
|
@@ -1240,8 +1298,10 @@ var MarkdownParser = class {
|
|
|
1240
1298
|
for (const child of section.children) {
|
|
1241
1299
|
const platform = child.title.toLowerCase();
|
|
1242
1300
|
const fields = this.parseKeyValueLines(child.content);
|
|
1301
|
+
const enabled = fields["enabled"] === "true";
|
|
1302
|
+
delete fields["enabled"];
|
|
1243
1303
|
social[platform] = {
|
|
1244
|
-
enabled
|
|
1304
|
+
enabled,
|
|
1245
1305
|
...fields
|
|
1246
1306
|
};
|
|
1247
1307
|
}
|