@clwnt/clawnet 0.5.3 → 0.5.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clwnt/clawnet",
3
- "version": "0.5.3",
3
+ "version": "0.5.4",
4
4
  "type": "module",
5
5
  "description": "ClawNet integration for OpenClaw — poll inbox, route messages to hooks",
6
6
  "files": [
package/src/cli.ts CHANGED
@@ -687,11 +687,11 @@ export function registerClawnetCli(params: { program: Command; api: any; cfg: Cl
687
687
  console.log("");
688
688
  });
689
689
 
690
- // --- uninstall ---
690
+ // --- disable ---
691
691
  root
692
- .command("uninstall")
693
- .option("--purge", "Remove config entirely (default: just disable)")
694
- .description("Disable ClawNet plugin and remove hook mapping")
692
+ .command("disable")
693
+ .option("--purge", "Also remove account config (tokens, accounts)")
694
+ .description("Disable ClawNet plugin and remove hook mappings")
695
695
  .action(async (opts) => {
696
696
  const currentConfig = api.runtime.config.loadConfig();
697
697
  const cfg = { ...currentConfig };
@@ -716,20 +716,69 @@ export function registerClawnetCli(params: { program: Command; api: any; cfg: Cl
716
716
  }
717
717
  const removedCount = beforeCount - (cfg.hooks?.mappings?.length ?? 0);
718
718
 
719
- console.log("\n ClawNet uninstalled.\n");
720
- console.log(" - Plugin disabled");
719
+ console.log("\n ClawNet disabled.\n");
720
+ console.log(" - Plugin disabled (polling stopped)");
721
+ console.log(" - Hook mappings removed");
721
722
  if (removedCount > 0) {
722
- console.log(` - ${removedCount} hook mapping(s) removed`);
723
+ console.log(` (${removedCount} mapping(s) cleaned up)`);
723
724
  }
725
+ console.log("");
726
+ console.log(" To re-enable: openclaw clawnet setup");
727
+ console.log(" To fully remove: openclaw plugins uninstall clawnet");
724
728
 
725
729
  // Do NOT touch: hooks.enabled, hooks.token, allowedSessionKeyPrefixes, allowedAgentIds
726
730
 
727
731
  await api.runtime.config.writeConfigFile(cfg);
728
732
 
729
- console.log(" - hooks.enabled, hooks.token left untouched");
730
733
  if (opts.purge) {
731
- console.log(" - Plugin config purged");
734
+ console.log(" - Account config purged");
735
+ }
736
+ console.log("\n Restart the Gateway to apply: openclaw gateway restart\n");
737
+ });
738
+
739
+ // --- enable ---
740
+ root
741
+ .command("enable")
742
+ .description("Re-enable a previously disabled ClawNet plugin")
743
+ .action(async () => {
744
+ const currentConfig = api.runtime.config.loadConfig();
745
+ const cfg = structuredClone(currentConfig);
746
+
747
+ const pluginEntry = cfg.plugins?.entries?.clawnet;
748
+ if (!pluginEntry) {
749
+ console.log("\n No ClawNet config found. Run `openclaw clawnet setup` first.\n");
750
+ return;
732
751
  }
752
+
753
+ if (pluginEntry.enabled) {
754
+ console.log("\n ClawNet is already enabled.\n");
755
+ return;
756
+ }
757
+
758
+ pluginEntry.enabled = true;
759
+
760
+ // Restore hook mappings from accounts
761
+ const accounts: any[] = pluginEntry.config?.accounts ?? [];
762
+ const enabled = accounts.filter((a: any) => a.enabled !== false);
763
+ if (enabled.length > 0) {
764
+ cfg.hooks ??= {};
765
+ let mappings = cfg.hooks.mappings ?? [];
766
+ for (const account of enabled) {
767
+ const channel = pluginEntry.config?.deliver?.channel ?? "last";
768
+ mappings = upsertMapping(mappings, buildClawnetMapping(
769
+ account.id,
770
+ channel,
771
+ account.openclawAgentId ?? account.id,
772
+ ));
773
+ }
774
+ cfg.hooks.mappings = mappings;
775
+ }
776
+
777
+ await api.runtime.config.writeConfigFile(cfg);
778
+
779
+ console.log("\n ClawNet enabled.\n");
780
+ console.log(` - Plugin enabled (${enabled.length} account(s))`);
781
+ console.log(` - Hook mappings restored`);
733
782
  console.log("\n Restart the Gateway to apply: openclaw gateway restart\n");
734
783
  });
735
784
  }
package/src/service.ts CHANGED
@@ -72,7 +72,7 @@ async function reloadOnboardingMessage(): Promise<void> {
72
72
 
73
73
  const SKILL_UPDATE_INTERVAL_MS = 6 * 60 * 60 * 1000; // 6 hours
74
74
  const SKILL_FILES = ["skill.json", "api-reference.md", "inbox-handler.md", "capabilities.json", "hook-template.txt", "tool-descriptions.json", "onboarding-message.txt"];
75
- export const PLUGIN_VERSION = "0.5.3"; // Reported to server via PATCH /me every 6h
75
+ export const PLUGIN_VERSION = "0.5.4"; // Reported to server via PATCH /me every 6h
76
76
 
77
77
  // --- Service ---
78
78