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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/setup.js +68 -34
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "callme-openclaw-plugin",
3
- "version": "1.0.6",
3
+ "version": "1.0.7",
4
4
  "description": "OpenClaw plugin for callme.ai - hands-free voice calls with your AI assistant",
5
5
  "main": "index.js",
6
6
  "bin": {
package/setup.js CHANGED
@@ -47,57 +47,91 @@ async function main() {
47
47
  process.exit(1);
48
48
  }
49
49
 
50
- // Step 3: Install plugin via OpenClaw CLI
51
- console.log('\n๐Ÿ“ฆ Installing plugin...');
50
+ // Step 3: Clean stale config first
51
+ console.log('\n๐Ÿงน Cleaning stale config...');
52
52
 
53
- try {
54
- // Use OpenClaw's plugin installer (official method)
55
- await execAsync('openclaw plugins install callme-openclaw-plugin');
56
- console.log('โœ… Plugin installed');
57
- } catch (error) {
58
- console.error('โŒ Failed to install plugin:', error.message);
59
- console.log('\n๐Ÿ“‹ Manual fallback:');
60
- console.log(' 1. Run: openclaw plugins install callme-openclaw-plugin');
61
- console.log(' 2. Then re-run this setup');
62
- process.exit(1);
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โš™๏ธ Updating OpenClaw config...');
76
+ // Step 4: Update config FIRST (before install)
77
+ console.log('\nโš™๏ธ Writing plugin config...');
67
78
 
68
- const configContent = `
69
- # callme.ai Voice Plugin
70
- plugins:
71
- callme:
72
- enabled: true
73
- apiKey: "${apiKey}"
74
- defaultVoice: "nova"
75
- language: "en"
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
- const existing = fs.readFileSync(CONFIG_FILE, 'utf8');
80
- if (existing.includes('callme:')) {
81
- // Replace existing
82
- const updated = existing.replace(
83
- /plugins:\s*\n\s*callme:[\s\S]*?(?=\n\S|$)/,
84
- configContent.trim()
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
- // Append
89
- fs.appendFileSync(CONFIG_FILE, configContent);
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, configContent);
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 5: Offer to restart gateway
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') {