@@ -148,16 +148,21 @@ function Update-OpenClawConfig {
148148 param (
149149 [string ]$OpenClawHome ,
150150 [string ]$ConfigPath ,
151- [string ]$PluginId
151+ [string ]$PluginId ,
152+ [string ]$InstallPath ,
153+ [string ]$Spec
152154 )
153155
154156 Write-Info " Updating OpenClaw config..."
155157 New-Item - ItemType Directory - Path $OpenClawHome - Force | Out-Null
156158 $nodeScript = @'
157159const fs = require("fs");
160+ const path = require("path");
158161
159162const configPath = process.argv[2];
160163const pluginId = process.argv[3];
164+ const installPath = process.argv[4];
165+ const spec = process.argv[5];
161166
162167let config = {};
163168if (fs.existsSync(configPath)) {
@@ -187,14 +192,48 @@ if (!config.plugins.allow.includes(pluginId)) {
187192// Clean up stale contextEngine slot from previous versions
188193if (config.plugins.slots && config.plugins.slots.contextEngine) {
189194 delete config.plugins.slots.contextEngine;
190- if (Object.keys(config.plugins.slots).length === 0) {
191- delete config.plugins.slots;
192- }
193195}
194196
197+ // Register plugin in memory slot
198+ if (!config.plugins.slots || typeof config.plugins.slots !== "object") {
199+ config.plugins.slots = {};
200+ }
201+ config.plugins.slots.memory = pluginId;
202+
203+ // Ensure plugin entry is enabled (preserve existing config if present)
204+ if (!config.plugins.entries || typeof config.plugins.entries !== "object") {
205+ config.plugins.entries = {};
206+ }
207+ if (!config.plugins.entries[pluginId] || typeof config.plugins.entries[pluginId] !== "object") {
208+ config.plugins.entries[pluginId] = {};
209+ }
210+ config.plugins.entries[pluginId].enabled = true;
211+
212+ // Register plugin in installs so gateway auto-loads it on restart
213+ if (!config.plugins.installs || typeof config.plugins.installs !== "object") {
214+ config.plugins.installs = {};
215+ }
216+ const pkgJsonPath = path.join(installPath, "package.json");
217+ let resolvedName, resolvedVersion;
218+ if (fs.existsSync(pkgJsonPath)) {
219+ const pkg = JSON.parse(fs.readFileSync(pkgJsonPath, "utf8"));
220+ resolvedName = pkg.name;
221+ resolvedVersion = pkg.version;
222+ }
223+ config.plugins.installs[pluginId] = {
224+ source: "npm",
225+ spec,
226+ installPath,
227+ ...(resolvedVersion ? { version: resolvedVersion } : {}),
228+ ...(resolvedName ? { resolvedName } : {}),
229+ ...(resolvedVersion ? { resolvedVersion } : {}),
230+ ...(resolvedName && resolvedVersion ? { resolvedSpec: `${resolvedName}@${resolvedVersion}` } : {}),
231+ installedAt: new Date().toISOString(),
232+ };
233+
195234fs.writeFileSync(configPath, `${JSON.stringify(config, null, 2)}\n`, "utf8");
196235'@
197- $nodeScript | & node - $ConfigPath $PluginId
236+ $nodeScript | & node - $ConfigPath $PluginId $InstallPath $Spec
198237 Write-Success " OpenClaw config updated: $ConfigPath "
199238}
200239
@@ -320,7 +359,20 @@ if (-not (Test-Path $ExtensionDir)) {
320359 exit 1
321360}
322361
323- Update-OpenClawConfig - OpenClawHome $OpenClawHome - ConfigPath $OpenClawConfigPath - PluginId $PluginId
362+ Update-OpenClawConfig - OpenClawHome $OpenClawHome - ConfigPath $OpenClawConfigPath - PluginId $PluginId - InstallPath $ExtensionDir - Spec $PackageSpec
363+
364+ Write-Info " Installing OpenClaw Gateway service..."
365+ & npx openclaw gateway install -- port $Port -- force 2>&1
366+ if (-not $? ) { Write-Warn " Gateway service install returned a warning; continuing..." }
367+
368+ Write-Success " Starting OpenClaw Gateway service..."
369+ & npx openclaw gateway start 2>&1
324370
325- Write-Success " Restarting OpenClaw Gateway..."
326- & npx openclaw gateway run -- port $Port -- force
371+ Write-Host " "
372+ Write-Success " =========================================="
373+ Write-Success " Installation complete!"
374+ Write-Success " =========================================="
375+ Write-Host " "
376+ Write-Info " OpenClaw Web UI: http://localhost:$Port "
377+ Write-Info " Memory Viewer: http://localhost:18799"
378+ Write-Host " "
0 commit comments