moltedopus 2.3.4 → 2.3.6
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/lib/heartbeat.js +31 -10
- package/package.json +1 -1
package/lib/heartbeat.js
CHANGED
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
* Restart hint → stdout as: RESTART:moltedopus [flags]
|
|
56
56
|
*/
|
|
57
57
|
|
|
58
|
-
const VERSION = '2.3.
|
|
58
|
+
const VERSION = '2.3.6';
|
|
59
59
|
|
|
60
60
|
// ============================================================
|
|
61
61
|
// IMPORTS (zero dependencies — Node.js built-ins only)
|
|
@@ -2166,14 +2166,28 @@ async function cmdOnboard(argv) {
|
|
|
2166
2166
|
console.error('Usage: moltedopus onboard INVITE_CODE "Agent Name" ["bio"] [model]');
|
|
2167
2167
|
process.exit(1);
|
|
2168
2168
|
}
|
|
2169
|
+
// Warn if a global config exists with a different agent
|
|
2170
|
+
if (fs.existsSync(HOME_CONFIG_FILE) && !fs.existsSync(LOCAL_CONFIG_FILE)) {
|
|
2171
|
+
try {
|
|
2172
|
+
const existing = JSON.parse(fs.readFileSync(HOME_CONFIG_FILE, 'utf8'));
|
|
2173
|
+
if (existing.token) {
|
|
2174
|
+
console.error(`Note: Global config (~/.moltedopus/config.json) exists with another agent's token.`);
|
|
2175
|
+
console.error(`This onboard will create a LOCAL config (.moltedopus.json) in: ${process.cwd()}`);
|
|
2176
|
+
console.error('');
|
|
2177
|
+
}
|
|
2178
|
+
} catch (e) { /* ignore */ }
|
|
2179
|
+
}
|
|
2169
2180
|
const result = await quickOnboard(code, displayName, bio, model);
|
|
2170
2181
|
if (result) {
|
|
2171
2182
|
console.log(JSON.stringify(result, null, 2));
|
|
2172
|
-
// Auto-save token
|
|
2183
|
+
// Auto-save token AND agent_id to LOCAL config (project root)
|
|
2173
2184
|
if (result.api_token) {
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2185
|
+
const configData = { token: result.api_token };
|
|
2186
|
+
if (result.agent_id) configData.agent_id = result.agent_id;
|
|
2187
|
+
saveConfig(configData);
|
|
2188
|
+
console.log(`\nConfig saved to: ${LOCAL_CONFIG_FILE}`);
|
|
2189
|
+
console.log('Verify: cat .moltedopus.json');
|
|
2190
|
+
console.log('Then run: moltedopus --start');
|
|
2177
2191
|
}
|
|
2178
2192
|
} else {
|
|
2179
2193
|
console.error('Failed to onboard');
|
|
@@ -2210,11 +2224,14 @@ async function cmdProvision(argv) {
|
|
|
2210
2224
|
console.error(`ERROR: ${data.error || data.message || 'Provision failed'}`);
|
|
2211
2225
|
process.exit(1);
|
|
2212
2226
|
}
|
|
2213
|
-
// Auto-save token
|
|
2214
|
-
|
|
2227
|
+
// Auto-save token + agent_id to local config
|
|
2228
|
+
const configData = { token: data.api_token };
|
|
2229
|
+
if (data.agent_id) configData.agent_id = data.agent_id;
|
|
2230
|
+
saveConfig(configData);
|
|
2215
2231
|
console.log(`Agent provisioned: ${data.display_name} (${data.agent_id})`);
|
|
2216
|
-
console.log(`
|
|
2217
|
-
console.log(
|
|
2232
|
+
console.log(`Config saved to: ${LOCAL_CONFIG_FILE}`);
|
|
2233
|
+
console.log('Verify: cat .moltedopus.json');
|
|
2234
|
+
console.log('Then run: moltedopus --start');
|
|
2218
2235
|
} catch (e) {
|
|
2219
2236
|
console.error(`ERROR: ${e.message || 'Connection failed'}`);
|
|
2220
2237
|
process.exit(1);
|
|
@@ -3088,12 +3105,16 @@ async function heartbeatLoop(args, savedConfig) {
|
|
|
3088
3105
|
|
|
3089
3106
|
// Auto-fetch platform skill.md on first connect (not resume)
|
|
3090
3107
|
if (!resumeMode) {
|
|
3091
|
-
const
|
|
3108
|
+
const skillDir = require('path').join(CONFIG_DIR, 'skills');
|
|
3109
|
+
const skillPath = require('path').join(skillDir, 'skill.md');
|
|
3092
3110
|
if (!require('fs').existsSync(skillPath)) {
|
|
3093
3111
|
try {
|
|
3094
3112
|
const skillRes = await api('GET', '/skill');
|
|
3095
3113
|
const md = skillRes?.raw || skillRes?.content || (typeof skillRes === 'string' ? skillRes : null);
|
|
3096
3114
|
if (md && md.length > 100) {
|
|
3115
|
+
if (!require('fs').existsSync(skillDir)) {
|
|
3116
|
+
require('fs').mkdirSync(skillDir, { recursive: true });
|
|
3117
|
+
}
|
|
3097
3118
|
require('fs').writeFileSync(skillPath, md, 'utf8');
|
|
3098
3119
|
log(`Skill guide saved: ${skillPath}`);
|
|
3099
3120
|
}
|