@alfe.ai/openclaw-webhooks 0.0.9 → 0.0.11

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/dist/plugin.cjs CHANGED
@@ -52,16 +52,14 @@ const plugin = {
52
52
  version: "0.1.0",
53
53
  activate(api) {
54
54
  const log = api.logger;
55
- if (api.registrationMode === "cli-metadata") {
56
- log.debug("CLI metadata mode skipping webhooks resource init");
57
- return;
58
- }
59
- const alreadyActivated = globalThis.__alfeWebhooksPluginActivated === true;
60
- globalThis.__alfeWebhooksPluginActivated = true;
61
- if (alreadyActivated) log.debug("Alfe Webhooks plugin re-registering gateway methods");
62
- else log.info("Alfe Webhooks plugin activating...");
63
- if (!alreadyActivated) {
64
- const pluginConfig = (api.config ?? {}).plugins?.entries?.["@alfe.ai/openclaw-webhooks"]?.config ?? {};
55
+ const pluginConfig = (api.config ?? {}).plugins?.entries?.["@alfe.ai/openclaw-webhooks"]?.config ?? {};
56
+ const startWebhooksService = () => {
57
+ if (globalThis.__alfeWebhooksPluginActivated === true) {
58
+ log.debug("Alfe Webhooks plugin already activated — skipping duplicate");
59
+ return;
60
+ }
61
+ globalThis.__alfeWebhooksPluginActivated = true;
62
+ log.info("Alfe Webhooks plugin activating...");
65
63
  let alfeConfig = null;
66
64
  try {
67
65
  alfeConfig = (0, _alfe_ai_config.resolveConfig)();
@@ -97,7 +95,25 @@ const plugin = {
97
95
  webhooksClient.start();
98
96
  log.info("Webhooks service client started");
99
97
  } else log.info("Webhooks service URL not configured — running without webhooks relay");
100
- }
98
+ };
99
+ const stopWebhooksService = () => {
100
+ globalThis.__alfeWebhooksPluginActivated = false;
101
+ if (webhooksClient) {
102
+ webhooksClient.stop();
103
+ webhooksClient = null;
104
+ log.info("Webhooks service client stopped");
105
+ }
106
+ if (daemonIpcClient) {
107
+ try {
108
+ daemonIpcClient.stop();
109
+ log.info("Disconnected from Alfe daemon");
110
+ } catch (err) {
111
+ log.debug(`Error disconnecting from daemon: ${err.message}`);
112
+ }
113
+ daemonIpcClient = null;
114
+ }
115
+ log.info("Alfe Webhooks plugin deactivated");
116
+ };
101
117
  if (typeof api.registerGatewayMethod === "function") {
102
118
  api.registerGatewayMethod("webhooks.create", async (...args) => {
103
119
  const params = args[0];
@@ -160,6 +176,16 @@ const plugin = {
160
176
  });
161
177
  log.info("Registered gateway RPC methods: webhooks.create, webhooks.list, webhooks.delete, webhooks.rotate, webhooks.deliveries");
162
178
  }
179
+ if (api.registerService) api.registerService({
180
+ id: "alfe-webhooks-relay",
181
+ start: () => {
182
+ startWebhooksService();
183
+ },
184
+ stop: () => {
185
+ stopWebhooksService();
186
+ }
187
+ });
188
+ else if (!(globalThis.__alfeWebhooksPluginActivated === true)) startWebhooksService();
163
189
  log.info("Alfe Webhooks plugin activated");
164
190
  },
165
191
  deactivate(api) {
package/dist/plugin.d.cts CHANGED
@@ -26,11 +26,22 @@ interface OpenClawConfig {
26
26
  };
27
27
  [key: string]: unknown;
28
28
  }
29
+ interface PluginServiceContext {
30
+ config: Record<string, unknown>;
31
+ workspaceDir?: string;
32
+ stateDir: string;
33
+ logger: Logger;
34
+ }
29
35
  interface OpenClawPluginApi {
30
36
  logger: Logger;
31
37
  registrationMode?: 'full' | 'setup-only' | 'setup-runtime' | 'cli-metadata';
32
38
  config?: OpenClawConfig;
33
39
  registerGatewayMethod?(name: string, handler: (...args: unknown[]) => Promise<unknown>): void;
40
+ registerService?(service: {
41
+ id: string;
42
+ start: (ctx: PluginServiceContext) => void | Promise<void>;
43
+ stop?: (ctx: PluginServiceContext) => void | Promise<void>;
44
+ }): void;
34
45
  on(event: string, handler: (...args: unknown[]) => void | Promise<void>, options?: {
35
46
  priority?: number;
36
47
  }): void;
package/dist/plugin.d.ts CHANGED
@@ -26,11 +26,22 @@ interface OpenClawConfig {
26
26
  };
27
27
  [key: string]: unknown;
28
28
  }
29
+ interface PluginServiceContext {
30
+ config: Record<string, unknown>;
31
+ workspaceDir?: string;
32
+ stateDir: string;
33
+ logger: Logger;
34
+ }
29
35
  interface OpenClawPluginApi {
30
36
  logger: Logger;
31
37
  registrationMode?: 'full' | 'setup-only' | 'setup-runtime' | 'cli-metadata';
32
38
  config?: OpenClawConfig;
33
39
  registerGatewayMethod?(name: string, handler: (...args: unknown[]) => Promise<unknown>): void;
40
+ registerService?(service: {
41
+ id: string;
42
+ start: (ctx: PluginServiceContext) => void | Promise<void>;
43
+ stop?: (ctx: PluginServiceContext) => void | Promise<void>;
44
+ }): void;
34
45
  on(event: string, handler: (...args: unknown[]) => void | Promise<void>, options?: {
35
46
  priority?: number;
36
47
  }): void;
package/dist/plugin.js CHANGED
@@ -52,16 +52,14 @@ const plugin = {
52
52
  version: "0.1.0",
53
53
  activate(api) {
54
54
  const log = api.logger;
55
- if (api.registrationMode === "cli-metadata") {
56
- log.debug("CLI metadata mode skipping webhooks resource init");
57
- return;
58
- }
59
- const alreadyActivated = globalThis.__alfeWebhooksPluginActivated === true;
60
- globalThis.__alfeWebhooksPluginActivated = true;
61
- if (alreadyActivated) log.debug("Alfe Webhooks plugin re-registering gateway methods");
62
- else log.info("Alfe Webhooks plugin activating...");
63
- if (!alreadyActivated) {
64
- const pluginConfig = (api.config ?? {}).plugins?.entries?.["@alfe.ai/openclaw-webhooks"]?.config ?? {};
55
+ const pluginConfig = (api.config ?? {}).plugins?.entries?.["@alfe.ai/openclaw-webhooks"]?.config ?? {};
56
+ const startWebhooksService = () => {
57
+ if (globalThis.__alfeWebhooksPluginActivated === true) {
58
+ log.debug("Alfe Webhooks plugin already activated — skipping duplicate");
59
+ return;
60
+ }
61
+ globalThis.__alfeWebhooksPluginActivated = true;
62
+ log.info("Alfe Webhooks plugin activating...");
65
63
  let alfeConfig = null;
66
64
  try {
67
65
  alfeConfig = resolveConfig();
@@ -97,7 +95,25 @@ const plugin = {
97
95
  webhooksClient.start();
98
96
  log.info("Webhooks service client started");
99
97
  } else log.info("Webhooks service URL not configured — running without webhooks relay");
100
- }
98
+ };
99
+ const stopWebhooksService = () => {
100
+ globalThis.__alfeWebhooksPluginActivated = false;
101
+ if (webhooksClient) {
102
+ webhooksClient.stop();
103
+ webhooksClient = null;
104
+ log.info("Webhooks service client stopped");
105
+ }
106
+ if (daemonIpcClient) {
107
+ try {
108
+ daemonIpcClient.stop();
109
+ log.info("Disconnected from Alfe daemon");
110
+ } catch (err) {
111
+ log.debug(`Error disconnecting from daemon: ${err.message}`);
112
+ }
113
+ daemonIpcClient = null;
114
+ }
115
+ log.info("Alfe Webhooks plugin deactivated");
116
+ };
101
117
  if (typeof api.registerGatewayMethod === "function") {
102
118
  api.registerGatewayMethod("webhooks.create", async (...args) => {
103
119
  const params = args[0];
@@ -160,6 +176,16 @@ const plugin = {
160
176
  });
161
177
  log.info("Registered gateway RPC methods: webhooks.create, webhooks.list, webhooks.delete, webhooks.rotate, webhooks.deliveries");
162
178
  }
179
+ if (api.registerService) api.registerService({
180
+ id: "alfe-webhooks-relay",
181
+ start: () => {
182
+ startWebhooksService();
183
+ },
184
+ stop: () => {
185
+ stopWebhooksService();
186
+ }
187
+ });
188
+ else if (!(globalThis.__alfeWebhooksPluginActivated === true)) startWebhooksService();
163
189
  log.info("Alfe Webhooks plugin activated");
164
190
  },
165
191
  deactivate(api) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alfe.ai/openclaw-webhooks",
3
- "version": "0.0.9",
3
+ "version": "0.0.11",
4
4
  "description": "OpenClaw webhooks plugin for Alfe — receive and manage external webhooks",
5
5
  "type": "module",
6
6
  "main": "./dist/plugin.js",