mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-23 14:11:18 +00:00
* refactor(plugins): trim activation and contract exports * test(plugins): restore fixture cleanup * refactor(plugins): trim install and loader exports * test(plugins): fully reset loader caches * refactor(plugins): trim metadata and catalog exports * test(plugins): preserve catalog trust coverage * refactor(plugins): trim provider and plugin exports * refactor(plugins): trim runtime and tool exports * test(plugins): update dead-export consumers * test(plugins): remove empty dead-export suites * refactor(plugins): align exports with split registry * refactor(plugins): trim drifted loader exports * style(plugins): format test fixtures * refactor(scripts): use supported plugin APIs * refactor(plugins): finish dead export cleanup * chore(deadcode): refresh export baseline * test(cli): mock production memory state * chore(deadcode): sync latest export baseline * fix(tests): keep plugin fixtures inside core * chore(deadcode): refresh rebased export baseline * chore(deadcode): sync current ratchets * fix(plugins): retain reserved slot invariant * fix(plugins): preserve dead-export invariants * test(plugins): use neutral catalog query fixture * test(plugins): satisfy catalog lint * test(plugins): preserve integrity drift coverage * fix(ci): register skill experience live proof
40 lines
1.5 KiB
TypeScript
40 lines
1.5 KiB
TypeScript
/** Tracks plugin API lifecycle callbacks registered during runtime activation. */
|
|
import type { OpenClawPluginApi } from "./types.js";
|
|
|
|
type FunctionPropertyNames<T> = Extract<
|
|
{
|
|
[K in keyof T]-?: Exclude<T[K], undefined> extends (...args: unknown[]) => unknown ? K : never;
|
|
}[keyof T],
|
|
string
|
|
>;
|
|
|
|
/** Names of plugin API methods exposed on the OpenClaw plugin API. */
|
|
type PluginApiMethodName = FunctionPropertyNames<OpenClawPluginApi>;
|
|
|
|
/** Lifecycle policy for whether a plugin API method can be called after registration. */
|
|
type PluginApiLifecyclePolicy = {
|
|
phase: "registration" | "runtime";
|
|
lateCallable: boolean;
|
|
};
|
|
|
|
const PLUGIN_API_METHOD_POLICIES: Partial<Record<PluginApiMethodName, PluginApiLifecyclePolicy>> = {
|
|
emitAgentEvent: { phase: "runtime", lateCallable: true },
|
|
sendSessionAttachment: { phase: "runtime", lateCallable: true },
|
|
scheduleSessionTurn: { phase: "runtime", lateCallable: true },
|
|
unscheduleSessionTurnsByTag: { phase: "runtime", lateCallable: true },
|
|
};
|
|
|
|
/** Returns lifecycle policy for one plugin API method name. */
|
|
function getPluginApiMethodLifecyclePolicy(
|
|
methodName: string,
|
|
): PluginApiLifecyclePolicy | undefined {
|
|
return PLUGIN_API_METHOD_POLICIES[methodName as PluginApiMethodName];
|
|
}
|
|
|
|
/** True when a plugin API method remains callable after registration. */
|
|
export function isLateCallablePluginApiMethod(
|
|
methodName: string,
|
|
): methodName is PluginApiMethodName {
|
|
return getPluginApiMethodLifecyclePolicy(methodName)?.lateCallable === true;
|
|
}
|