@@ -275,51 +275,47 @@ ${windowsScopedEnvFunction}
275275function Remove-FuturePluginEntries {
276276 $configPath = Join-Path $env:USERPROFILE '.openclaw\\openclaw.json'
277277 if (-not (Test-Path $configPath)) { return }
278- try { $config = Get-Content $configPath -Raw | ConvertFrom-Json } catch { return }
279- $plugins = Get-OpenClawJsonProperty $config 'plugins'
280- if ($null -eq $plugins) { return }
281- $entries = Get-OpenClawJsonProperty $plugins 'entries'
282- if ($null -ne $entries) {
283- foreach ($pluginId in @('feishu', 'whatsapp', 'openai')) {
284- Remove-OpenClawJsonProperty $entries $pluginId
278+ $nodeScript = @'
279+ const fs = require("node:fs");
280+ const configPath = process.argv[2];
281+ let config;
282+ try {
283+ config = JSON.parse(fs.readFileSync(configPath, "utf8").replace(/^\\uFEFF/u, ""));
284+ } catch {
285+ process.exit(0);
286+ }
287+ const plugins = config.plugins;
288+ if (!plugins || typeof plugins !== "object") {
289+ process.exit(0);
290+ }
291+ const futurePluginIds = new Set(["feishu", "whatsapp", "openai"]);
292+ let changed = false;
293+ if (plugins.entries && typeof plugins.entries === "object") {
294+ for (const pluginId of futurePluginIds) {
295+ if (Object.hasOwn(plugins.entries, pluginId)) {
296+ delete plugins.entries[pluginId];
297+ changed = true;
285298 }
286299 }
287- $allow = Get-OpenClawJsonProperty $plugins 'allow'
288- if ($allow -is [array]) {
289- Set-OpenClawJsonProperty $plugins 'allow' @($allow | Where-Object { $_ -notin @('feishu', 'whatsapp', 'openai') })
290- }
291- $config | ConvertTo-Json -Depth 100 | Set-Content -Path $configPath -Encoding UTF8
292- }
293- function Get-OpenClawJsonProperty {
294- param([object]$Object, [string]$Name)
295- if ($null -eq $Object) { return $null }
296- if ($Object -is [System.Collections.IDictionary]) { return $Object[$Name] }
297- $property = $Object.PSObject.Properties[$Name]
298- if ($null -eq $property) { return $null }
299- return $property.Value
300- }
301- function Set-OpenClawJsonProperty {
302- param([object]$Object, [string]$Name, [object]$Value)
303- if ($Object -is [System.Collections.IDictionary]) {
304- $Object[$Name] = $Value
305- return
306- }
307- $property = $Object.PSObject.Properties[$Name]
308- if ($null -ne $property) {
309- $property.Value = $Value
310- return
311- }
312- $Object | Add-Member -NotePropertyName $Name -NotePropertyValue $Value
313- }
314- function Remove-OpenClawJsonProperty {
315- param([object]$Object, [string]$Name)
316- if ($null -eq $Object) { return }
317- if ($Object -is [System.Collections.IDictionary]) {
318- if ($Object.Contains($Name)) { $Object.Remove($Name) }
319- return
300+ }
301+ if (Array.isArray(plugins.allow)) {
302+ const allow = plugins.allow.filter((pluginId) => !futurePluginIds.has(pluginId));
303+ if (allow.length !== plugins.allow.length) {
304+ plugins.allow = allow;
305+ changed = true;
320306 }
321- if ($null -ne $Object.PSObject.Properties[$Name]) {
322- $Object.PSObject.Properties.Remove($Name)
307+ }
308+ if (changed) {
309+ fs.writeFileSync(configPath, JSON.stringify(config, null, 2) + "\\n");
310+ }
311+ '@
312+ $nodeScriptPath = Join-Path ([System.IO.Path]::GetTempPath()) ('openclaw-future-plugin-scrub-' + [guid]::NewGuid().ToString('N') + '.cjs')
313+ try {
314+ $nodeScript | Set-Content -Path $nodeScriptPath -Encoding UTF8
315+ & node.exe $nodeScriptPath $configPath
316+ if ($LASTEXITCODE -ne 0) { throw "failed to scrub future plugin entries" }
317+ } finally {
318+ Remove-Item $nodeScriptPath -Force -ErrorAction SilentlyContinue
323319 }
324320}
325321function Stop-OpenClawGatewayProcesses {
0 commit comments