callme-openclaw-plugin 1.0.6 ā 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.
- package/openclaw.plugin.json +0 -1
- package/package.json +1 -1
- package/setup.js +52 -36
package/openclaw.plugin.json
CHANGED
package/package.json
CHANGED
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,51 +46,68 @@ async function main() {
|
|
|
47
46
|
process.exit(1);
|
|
48
47
|
}
|
|
49
48
|
|
|
50
|
-
// Step 3: Install plugin
|
|
49
|
+
// Step 3: Install plugin FIRST (apiKey is optional in schema, so install won't fail)
|
|
51
50
|
console.log('\nš¦ Installing plugin...');
|
|
52
51
|
|
|
53
52
|
try {
|
|
54
|
-
|
|
55
|
-
await execAsync('openclaw plugins install callme-openclaw-plugin');
|
|
53
|
+
await execAsync('openclaw plugins install callme-openclaw-plugin 2>&1');
|
|
56
54
|
console.log('ā
Plugin installed');
|
|
57
55
|
} catch (error) {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
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
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// Step 4: Write config AFTER plugin install
|
|
69
|
+
console.log('\nāļø Writing plugin config...');
|
|
70
|
+
|
|
71
|
+
if (!fs.existsSync(CONFIG_FILE)) {
|
|
72
|
+
console.error('ā Config file not found at:', CONFIG_FILE);
|
|
73
|
+
console.log('Run: openclaw config');
|
|
62
74
|
process.exit(1);
|
|
63
75
|
}
|
|
64
76
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
const
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
77
|
+
let config = fs.readFileSync(CONFIG_FILE, 'utf8');
|
|
78
|
+
|
|
79
|
+
// Strategy: Find and replace or append
|
|
80
|
+
const callmeConfig = ` callme:
|
|
81
|
+
enabled: true
|
|
82
|
+
config:
|
|
83
|
+
apiKey: "${apiKey}"
|
|
84
|
+
defaultVoice: "nova"
|
|
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
|
+
);
|
|
91
105
|
} else {
|
|
92
|
-
|
|
93
|
-
|
|
106
|
+
// Append full plugins section
|
|
107
|
+
config += `\nplugins:\n entries:\n${callmeConfig}\n`;
|
|
94
108
|
}
|
|
109
|
+
|
|
110
|
+
fs.writeFileSync(CONFIG_FILE, config);
|
|
95
111
|
console.log('ā
Config updated');
|
|
96
112
|
|
|
97
113
|
// Done!
|