fix(plugins): deprecate deactivate hook alias · openclaw/openclaw@a85cd65
vincentkoc
·
2026-05-16
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -20,7 +20,7 @@ Docs: https://docs.openclaw.ai
|
20 | 20 | - Telegram: persist polling updates through restart replay so queued same-topic messages resume in order instead of losing context after a gateway restart. (#82256) Thanks @VACInc. |
21 | 21 | - Gateway/Gmail: abort in-flight Gmail watcher startup and hot-reload restarts before shutdown so reloads cannot spawn `gog serve` after the Gateway is closing. Thanks @frankekn. |
22 | 22 | - MCP plugin tools: forward host MCP `tools/call` `AbortSignal` through `createPluginToolsMcpHandlers().callTool` into plugin `tool.execute`, so host cancellation actually cancels in-flight plugin tool calls instead of letting them run to completion. Fixes #82424. (#82443) Thanks @joshavant. |
23 | | -- Plugins: accept `api.on("deactivate")` as a compatibility alias for `gateway_stop`, so external plugin cleanup handlers run on Gateway shutdown instead of being ignored as unknown hooks. |
| 23 | +- Plugins: accept deprecated `api.on("deactivate")` registrations as a dated compatibility alias for `gateway_stop`, so external plugin cleanup handlers run on Gateway shutdown while authors get migration guidance. |
24 | 24 | - Media: ignore image MIME and filename hints when bytes sniff as generic containers, so zip/octet-stream payloads mislabeled as images do not become local image media or keep image file extensions when staged. |
25 | 25 | - Update/doctor: avoid materializing `groupAllowFrom` for channel schemas that reject it, so package-swap doctor repairs do not fail on externalized Slack configs. |
26 | 26 | - Gateway/media: prevent image filenames from overriding generic non-image byte sniffing, so zip/octet-stream payloads mislabeled as images are offloaded or rejected before they become inline image attachments. |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -112,6 +112,8 @@ Current compatibility records include:
|
112 | 112 | |
113 | 113 | - legacy broad SDK imports such as `openclaw/plugin-sdk/compat` |
114 | 114 | - legacy hook-only plugin shapes and `before_agent_start` |
| 115 | +- legacy `api.on("deactivate", ...)` cleanup hook names while plugins migrate to |
| 116 | +`gateway_stop` |
115 | 117 | - legacy `activate(api)` plugin entrypoints while plugins migrate to |
116 | 118 | `register(api)` |
117 | 119 | - legacy SDK aliases such as `openclaw/extension-api`, |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -145,7 +145,7 @@ observation-only.
|
145 | 145 | **Lifecycle** |
146 | 146 | |
147 | 147 | - `gateway_start` / `gateway_stop` - start or stop plugin-owned services with the Gateway |
148 | | -- `deactivate` - compatibility alias for `gateway_stop`; prefer `gateway_stop` in new plugins |
| 148 | +- `deactivate` - deprecated compatibility alias for `gateway_stop`; use `gateway_stop` in new plugins |
149 | 149 | - `cron_changed` - observe gateway-owned cron lifecycle changes (added, updated, removed, started, finished, scheduled) |
150 | 150 | - **`before_install`** - inspect skill or plugin install scans and optionally block |
151 | 151 | |
@@ -438,8 +438,8 @@ before the next major release:
|
438 | 438 | - **`before_agent_start`** remains for compatibility. New plugins should use |
439 | 439 | `before_model_resolve` and `before_prompt_build` instead of the combined |
440 | 440 | phase. |
441 | | -- **`deactivate`** remains as a cleanup compatibility alias. New plugins should |
442 | | - use `gateway_stop`. |
| 441 | +- **`deactivate`** remains as a deprecated cleanup compatibility alias until |
| 442 | +after 2026-08-16. New plugins should use `gateway_stop`. |
443 | 443 | - **`onResolution` in `before_tool_call`** now uses the typed |
444 | 444 | `PluginApprovalResolution` union (`allow-once` / `allow-always` / `deny` / |
445 | 445 | `timeout` / `cancelled`) instead of a free-form `string`. |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -757,6 +757,29 @@ canonical replacement.
|
757 | 757 | |
758 | 758 | </Accordion> |
759 | 759 | |
| 760 | +<Accordion title="deactivate hook → gateway_stop"> |
| 761 | +**Old**: `api.on("deactivate", handler)`. |
| 762 | + |
| 763 | +**New**: `api.on("gateway_stop", handler)`. The event and context are the |
| 764 | +same shutdown cleanup contract; only the hook name changes. |
| 765 | + |
| 766 | +```typescript |
| 767 | +// Before |
| 768 | +api.on("deactivate", async (event, ctx) => { |
| 769 | + await stopPluginService(ctx); |
| 770 | +}); |
| 771 | + |
| 772 | +// After |
| 773 | +api.on("gateway_stop", async (event, ctx) => { |
| 774 | + await stopPluginService(ctx); |
| 775 | +}); |
| 776 | +``` |
| 777 | + |
| 778 | +`deactivate` remains wired as a deprecated compatibility alias until after |
| 779 | +2026-08-16. |
| 780 | + |
| 781 | +</Accordion> |
| 782 | + |
760 | 783 | <Accordion title="Provider discovery types → provider catalog types"> |
761 | 784 | Four discovery type aliases are now thin wrappers over the |
762 | 785 | catalog-era types: |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -135,6 +135,11 @@ const knownDeprecatedSurfaceMarkers = [
|
135 | 135 | file: "src/plugin-sdk/compat.ts", |
136 | 136 | marker: "@deprecated Use `openclaw/plugin-sdk/channel-message`.", |
137 | 137 | }, |
| 138 | +{ |
| 139 | +code: "legacy-deactivate-hook-alias", |
| 140 | +file: "src/plugins/hook-types.ts", |
| 141 | +marker: "@deprecated Use gateway_stop", |
| 142 | +}, |
138 | 143 | { |
139 | 144 | code: "channel-route-key-aliases", |
140 | 145 | file: "src/plugin-sdk/channel-route.ts", |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -23,6 +23,22 @@ export const PLUGIN_COMPAT_RECORDS = [
|
23 | 23 | releaseNote: |
24 | 24 | "Legacy `before_agent_start` hook compatibility remains wired while plugins migrate to modern hook stages.", |
25 | 25 | }, |
| 26 | +{ |
| 27 | +code: "legacy-deactivate-hook-alias", |
| 28 | +status: "deprecated", |
| 29 | +owner: "sdk", |
| 30 | +introduced: "2026-05-16", |
| 31 | +deprecated: "2026-05-16", |
| 32 | +warningStarts: "2026-05-16", |
| 33 | +removeAfter: "2026-08-16", |
| 34 | +replacement: "`gateway_stop` hook", |
| 35 | +docsPath: "/plugins/hooks#upcoming-deprecations", |
| 36 | +surfaces: ["api.on(\"deactivate\", ...)", "plugin typed hook registration"], |
| 37 | +diagnostics: ["plugin runtime compatibility warning"], |
| 38 | +tests: ["src/plugins/loader.test.ts"], |
| 39 | +releaseNote: |
| 40 | +"`api.on(\"deactivate\", ...)` remains wired as a deprecated compatibility alias while plugins migrate to `gateway_stop`.", |
| 41 | +}, |
26 | 42 | { |
27 | 43 | code: "hook-only-plugin-shape", |
28 | 44 | status: "active", |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -94,6 +94,7 @@ export type PluginHookName =
|
94 | 94 | | "subagent_delivery_target" |
95 | 95 | | "subagent_spawned" |
96 | 96 | | "subagent_ended" |
| 97 | +/** @deprecated Use gateway_stop. */ |
97 | 98 | | "deactivate" |
98 | 99 | | "gateway_start" |
99 | 100 | | "gateway_stop" |
@@ -1003,11 +1004,13 @@ export type PluginHookHandlerMap = {
|
1003 | 1004 | ctx: PluginHookSubagentContext, |
1004 | 1005 | ) => Promise<void> | void; |
1005 | 1006 | /** |
1006 | | - * Compatibility alias for gateway_stop. |
| 1007 | + * Deprecated compatibility alias for gateway_stop. |
1007 | 1008 | * |
1008 | 1009 | * New plugins should register gateway_stop directly; the loader normalizes |
1009 | 1010 | * deactivate registrations onto gateway_stop so cleanup handlers still run |
1010 | 1011 | * during Gateway shutdown. |
| 1012 | + * |
| 1013 | + * @deprecated Use gateway_stop. |
1011 | 1014 | */ |
1012 | 1015 | deactivate: ( |
1013 | 1016 | event: PluginHookGatewayStopEvent, |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -5939,7 +5939,8 @@ module.exports = {
|
5939 | 5939 | registry.diagnostics.some( |
5940 | 5940 | (diag) => |
5941 | 5941 | diag.pluginId === "legacy-deactivate-hook" && |
5942 | | -diag.message === 'typed hook "deactivate" is a compatibility alias for "gateway_stop"', |
| 5942 | +diag.message === |
| 5943 | +'typed hook "deactivate" is deprecated (legacy-deactivate-hook-alias); use "gateway_stop". This compatibility alias will be removed after 2026-08-16.', |
5943 | 5944 | ), |
5944 | 5945 | ).toBe(true); |
5945 | 5946 | }); |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -51,6 +51,7 @@ import {
|
51 | 51 | import { buildPluginApi } from "./api-builder.js"; |
52 | 52 | import { normalizeRegisteredChannelPlugin } from "./channel-validation.js"; |
53 | 53 | import { CODEX_APP_SERVER_EXTENSION_RUNTIME_ID } from "./codex-app-server-extension-factory.js"; |
| 54 | +import { getPluginCompatRecord } from "./compat/registry.js"; |
54 | 55 | import type { CodexAppServerExtensionFactory } from "./codex-app-server-extension-types.js"; |
55 | 56 | import { |
56 | 57 | isReservedCommandName, |
@@ -187,6 +188,16 @@ export type PluginHttpRouteRegistration = RegistryTypesPluginHttpRouteRegistrati
|
187 | 188 | }; |
188 | 189 | |
189 | 190 | const GATEWAY_METHOD_DISPATCH_CONTRACT = "authenticated-request"; |
| 191 | +const LEGACY_DEACTIVATE_HOOK_ALIAS_COMPAT = getPluginCompatRecord("legacy-deactivate-hook-alias"); |
| 192 | + |
| 193 | +function formatLegacyDeactivateHookAliasDiagnostic(): string { |
| 194 | +const removeAfter = |
| 195 | +LEGACY_DEACTIVATE_HOOK_ALIAS_COMPAT.removeAfter ?? "a future breaking release"; |
| 196 | +return ( |
| 197 | +`typed hook "deactivate" is deprecated (${LEGACY_DEACTIVATE_HOOK_ALIAS_COMPAT.code}); ` + |
| 198 | +`use "gateway_stop". This compatibility alias will be removed after ${removeAfter}.` |
| 199 | +); |
| 200 | +} |
190 | 201 | |
191 | 202 | type PluginOwnedProviderRegistration<T extends { id: string }> = { |
192 | 203 | pluginId: string; |
@@ -2304,7 +2315,7 @@ export function createPluginRegistry(registryParams: PluginRegistryParams) {
|
2304 | 2315 | level: "warn", |
2305 | 2316 | pluginId: record.id, |
2306 | 2317 | source: record.source, |
2307 | | -message: 'typed hook "deactivate" is a compatibility alias for "gateway_stop"', |
| 2318 | +message: formatLegacyDeactivateHookAliasDiagnostic(), |
2308 | 2319 | }); |
2309 | 2320 | } |
2310 | 2321 | let effectiveHandler = handler; |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。