feat: add plugin startup activation metadata

This commit is contained in:
Shakker
2026-04-28 02:55:42 +01:00
parent a0a0ab4d9e
commit b16fe2b229
2 changed files with 12 additions and 0 deletions

View File

@@ -127,6 +127,7 @@ describe("loadPluginManifest JSON5 tolerance", () => {
const json5Content = `{
id: "openai",
activation: {
onStartup: false,
onProviders: ["openai", "", "openai-codex"],
onCommands: ["models", ""],
onChannels: ["web", ""],
@@ -150,6 +151,7 @@ describe("loadPluginManifest JSON5 tolerance", () => {
expect(result.ok).toBe(true);
if (result.ok) {
expect(result.manifest.activation).toEqual({
onStartup: false,
onProviders: ["openai", "openai-codex"],
onCommands: ["models"],
onChannels: ["web"],

View File

@@ -140,6 +140,14 @@ export type PluginManifestProviderRequest = {
export type PluginManifestActivationCapability = "provider" | "channel" | "tool" | "hook";
export type PluginManifestActivation = {
/**
* Explicit Gateway startup activation. Every plugin should set this as
* OpenClaw moves away from implicit startup sidecar loading. Set true when
* the plugin must be imported during Gateway startup; set false to opt out
* of the deprecated implicit startup sidecar fallback when no other
* activation trigger matches.
*/
onStartup?: boolean;
/**
* Provider ids that should include this plugin in activation/load plans.
* This is planner metadata only; runtime behavior still comes from register().
@@ -920,6 +928,7 @@ function normalizeManifestActivation(value: unknown): PluginManifestActivation |
const onChannels = normalizeTrimmedStringList(value.onChannels);
const onRoutes = normalizeTrimmedStringList(value.onRoutes);
const onConfigPaths = normalizeTrimmedStringList(value.onConfigPaths);
const onStartup = typeof value.onStartup === "boolean" ? value.onStartup : undefined;
const onCapabilities = normalizeTrimmedStringList(value.onCapabilities).filter(
(capability): capability is PluginManifestActivationCapability =>
capability === "provider" ||
@@ -929,6 +938,7 @@ function normalizeManifestActivation(value: unknown): PluginManifestActivation |
);
const activation = {
...(onStartup !== undefined ? { onStartup } : {}),
...(onProviders.length > 0 ? { onProviders } : {}),
...(onAgentHarnesses.length > 0 ? { onAgentHarnesses } : {}),
...(onCommands.length > 0 ? { onCommands } : {}),