callme-openclaw-plugin 1.0.7 โ†’ 1.0.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.
@@ -25,7 +25,6 @@
25
25
  "description": "Language code"
26
26
  }
27
27
  },
28
- "required": ["apiKey"],
29
28
  "additionalProperties": false
30
29
  },
31
30
  "uiHints": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "callme-openclaw-plugin",
3
- "version": "1.0.7",
3
+ "version": "1.0.8",
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
@@ -13,7 +13,6 @@ const readline = require('readline');
13
13
  const execAsync = promisify(exec);
14
14
 
15
15
  const OPENCLAW_DIR = path.join(process.env.HOME, '.openclaw');
16
- const PLUGIN_DIR = path.join(OPENCLAW_DIR, 'plugins', 'callme');
17
16
  const CONFIG_FILE = path.join(OPENCLAW_DIR, 'config.yaml');
18
17
 
19
18
  const rl = readline.createInterface({
@@ -47,91 +46,74 @@ async function main() {
47
46
  process.exit(1);
48
47
  }
49
48
 
50
- // Step 3: Clean stale config first
51
- console.log('\n๐Ÿงน Cleaning stale config...');
49
+ // Step 3: Install plugin FIRST (apiKey is optional in schema, so install won't fail)
50
+ console.log('\n๐Ÿ“ฆ Installing plugin...');
52
51
 
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');
52
+ try {
53
+ await execAsync('openclaw plugins install callme-openclaw-plugin 2>&1');
54
+ console.log('โœ… Plugin installed');
55
+ } catch (error) {
56
+ // Check if it's already installed
57
+ if (error.message.includes('already installed')) {
58
+ console.log('โœ… Plugin already installed');
59
+ } else {
60
+ console.error('โŒ Failed to install plugin:', error.message);
61
+ console.log('\n๐Ÿ“‹ Manual fallback:');
62
+ console.log(' 1. Run: openclaw plugins install callme-openclaw-plugin');
63
+ console.log(' 2. Edit ~/.openclaw/config.yaml manually');
64
+ process.exit(1);
65
+ }
74
66
  }
75
67
 
76
- // Step 4: Update config FIRST (before install)
68
+ // Step 4: Write config AFTER plugin install
77
69
  console.log('\nโš™๏ธ Writing plugin config...');
78
70
 
79
- const configAddition = `\nplugins:
80
- entries:
81
- callme:
71
+ if (!fs.existsSync(CONFIG_FILE)) {
72
+ console.error('โŒ Config file not found at:', CONFIG_FILE);
73
+ console.log('Run: openclaw config');
74
+ process.exit(1);
75
+ }
76
+
77
+ let config = fs.readFileSync(CONFIG_FILE, 'utf8');
78
+
79
+ // Strategy: Find and replace or append
80
+ const callmeConfig = ` callme:
82
81
  enabled: true
83
82
  config:
84
83
  apiKey: "${apiKey}"
85
84
  defaultVoice: "nova"
86
- language: "en"
87
- `;
88
-
89
- if (fs.existsSync(CONFIG_FILE)) {
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`
103
- );
104
- } else {
105
- // No plugins section, append
106
- config += configAddition;
107
- }
108
-
109
- fs.writeFileSync(CONFIG_FILE, config);
85
+ language: "en"`;
86
+
87
+ if (config.match(/plugins:\s*\n.*entries:\s*\n.*callme:/s)) {
88
+ // Replace existing callme section
89
+ config = config.replace(
90
+ /(\s+)callme:\s*\n(?:\s+.*\n)*/,
91
+ callmeConfig + '\n'
92
+ );
93
+ } else if (config.match(/plugins:\s*\n.*entries:/s)) {
94
+ // Add callme under existing entries
95
+ config = config.replace(
96
+ /(plugins:\s*\n.*entries:\s*\n)/s,
97
+ `$1${callmeConfig}\n`
98
+ );
99
+ } else if (config.match(/plugins:/)) {
100
+ // Add entries section with callme
101
+ config = config.replace(
102
+ /(plugins:\s*\n)/,
103
+ `$1 entries:\n${callmeConfig}\n`
104
+ );
110
105
  } else {
111
- fs.mkdirSync(path.dirname(CONFIG_FILE), { recursive: true });
112
- fs.writeFileSync(CONFIG_FILE, configAddition);
106
+ // Append full plugins section
107
+ config += `\nplugins:\n entries:\n${callmeConfig}\n`;
113
108
  }
114
- console.log('โœ… Config written');
115
-
116
- // Step 5: Install plugin via OpenClaw CLI
117
- console.log('\n๐Ÿ“ฆ Installing plugin...');
118
109
 
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);
129
- }
110
+ fs.writeFileSync(CONFIG_FILE, config);
111
+ console.log('โœ… Config updated');
130
112
 
131
113
  // Done!
132
114
  console.log('\nโœจ \x1b[1;32mSetup complete!\x1b[0m\n');
133
115
 
134
- // Step 6: Offer to restart gateway
116
+ // Step 5: Offer to restart gateway
135
117
  const shouldRestart = await question('๐Ÿ”„ Restart OpenClaw Gateway now? (y/n): ');
136
118
 
137
119
  if (shouldRestart.toLowerCase() === 'y' || shouldRestart.toLowerCase() === 'yes') {