mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 08:20:43 +00:00
feat: add plugin startup activation metadata
This commit is contained in:
@@ -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"],
|
||||
|
||||
@@ -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 } : {}),
|
||||
|
||||
Reference in New Issue
Block a user