callme-openclaw-plugin 1.0.6 โ 1.0.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/package.json +1 -1
- package/setup.js +68 -34
package/package.json
CHANGED
package/setup.js
CHANGED
|
@@ -47,57 +47,91 @@ async function main() {
|
|
|
47
47
|
process.exit(1);
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
// Step 3:
|
|
51
|
-
console.log('\n
|
|
50
|
+
// Step 3: Clean stale config first
|
|
51
|
+
console.log('\n๐งน Cleaning stale config...');
|
|
52
52
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
53
|
+
if (fs.existsSync(CONFIG_FILE)) {
|
|
54
|
+
let config = fs.readFileSync(CONFIG_FILE, 'utf8');
|
|
55
|
+
|
|
56
|
+
// Remove old callme entries (wrong structure)
|
|
57
|
+
config = config.replace(
|
|
58
|
+
/# callme\.ai Voice Plugin\s*\n/g,
|
|
59
|
+
''
|
|
60
|
+
);
|
|
61
|
+
config = config.replace(
|
|
62
|
+
/^plugins:\s*\n\s*callme:[\s\S]*?(?=\n[a-zA-Z]|\n\n|$)/gm,
|
|
63
|
+
''
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
// Remove from plugins.entries too (if malformed)
|
|
67
|
+
config = config.replace(
|
|
68
|
+
/(\s+callme:\s*\n(?:\s+\w+:.*\n)*?)(?=\n\s{0,4}\w|$)/g,
|
|
69
|
+
''
|
|
70
|
+
);
|
|
71
|
+
|
|
72
|
+
fs.writeFileSync(CONFIG_FILE, config);
|
|
73
|
+
console.log('โ
Stale config removed');
|
|
63
74
|
}
|
|
64
75
|
|
|
65
|
-
// Step 4: Update config
|
|
66
|
-
console.log('\nโ๏ธ
|
|
76
|
+
// Step 4: Update config FIRST (before install)
|
|
77
|
+
console.log('\nโ๏ธ Writing plugin config...');
|
|
67
78
|
|
|
68
|
-
const
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
79
|
+
const configAddition = `\nplugins:
|
|
80
|
+
entries:
|
|
81
|
+
callme:
|
|
82
|
+
enabled: true
|
|
83
|
+
config:
|
|
84
|
+
apiKey: "${apiKey}"
|
|
85
|
+
defaultVoice: "nova"
|
|
86
|
+
language: "en"
|
|
76
87
|
`;
|
|
77
88
|
|
|
78
89
|
if (fs.existsSync(CONFIG_FILE)) {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
90
|
+
let config = fs.readFileSync(CONFIG_FILE, 'utf8');
|
|
91
|
+
|
|
92
|
+
if (config.includes('plugins:') && config.includes('entries:')) {
|
|
93
|
+
// plugins.entries exists, add callme under it
|
|
94
|
+
config = config.replace(
|
|
95
|
+
/(plugins:\s*\n\s*entries:\s*\n)/,
|
|
96
|
+
`$1 callme:\n enabled: true\n config:\n apiKey: "${apiKey}"\n defaultVoice: "nova"\n language: "en"\n`
|
|
97
|
+
);
|
|
98
|
+
} else if (config.includes('plugins:')) {
|
|
99
|
+
// plugins exists but no entries, add entries section
|
|
100
|
+
config = config.replace(
|
|
101
|
+
/(plugins:\s*\n)/,
|
|
102
|
+
`$1 entries:\n callme:\n enabled: true\n config:\n apiKey: "${apiKey}"\n defaultVoice: "nova"\n language: "en"\n`
|
|
85
103
|
);
|
|
86
|
-
fs.writeFileSync(CONFIG_FILE, updated);
|
|
87
104
|
} else {
|
|
88
|
-
//
|
|
89
|
-
|
|
105
|
+
// No plugins section, append
|
|
106
|
+
config += configAddition;
|
|
90
107
|
}
|
|
108
|
+
|
|
109
|
+
fs.writeFileSync(CONFIG_FILE, config);
|
|
91
110
|
} else {
|
|
92
111
|
fs.mkdirSync(path.dirname(CONFIG_FILE), { recursive: true });
|
|
93
|
-
fs.writeFileSync(CONFIG_FILE,
|
|
112
|
+
fs.writeFileSync(CONFIG_FILE, configAddition);
|
|
113
|
+
}
|
|
114
|
+
console.log('โ
Config written');
|
|
115
|
+
|
|
116
|
+
// Step 5: Install plugin via OpenClaw CLI
|
|
117
|
+
console.log('\n๐ฆ Installing plugin...');
|
|
118
|
+
|
|
119
|
+
try {
|
|
120
|
+
// Use OpenClaw's plugin installer (official method)
|
|
121
|
+
await execAsync('openclaw plugins install callme-openclaw-plugin');
|
|
122
|
+
console.log('โ
Plugin installed');
|
|
123
|
+
} catch (error) {
|
|
124
|
+
console.error('โ Failed to install plugin:', error.message);
|
|
125
|
+
console.log('\n๐ Manual fallback:');
|
|
126
|
+
console.log(' 1. Run: openclaw plugins install callme-openclaw-plugin');
|
|
127
|
+
console.log(' 2. Restart gateway: openclaw gateway restart');
|
|
128
|
+
process.exit(1);
|
|
94
129
|
}
|
|
95
|
-
console.log('โ
Config updated');
|
|
96
130
|
|
|
97
131
|
// Done!
|
|
98
132
|
console.log('\nโจ \x1b[1;32mSetup complete!\x1b[0m\n');
|
|
99
133
|
|
|
100
|
-
// Step
|
|
134
|
+
// Step 6: Offer to restart gateway
|
|
101
135
|
const shouldRestart = await question('๐ Restart OpenClaw Gateway now? (y/n): ');
|
|
102
136
|
|
|
103
137
|
if (shouldRestart.toLowerCase() === 'y' || shouldRestart.toLowerCase() === 'yes') {
|