fix(hooks): expose typed gateway startup context

This commit is contained in:
Vincent Koc
2026-04-22 11:21:27 -07:00
parent 3e24898690
commit 6d003cbcee
9 changed files with 262 additions and 216 deletions

View File

@@ -475,6 +475,9 @@ export type PluginHookSubagentEndedEvent = {
export type PluginHookGatewayContext = {
port?: number;
config?: OpenClawConfig;
workspaceDir?: string;
getCron?: () => PluginHookGatewayCronService | undefined;
};
export type PluginHookGatewayStartEvent = {
@@ -485,6 +488,55 @@ export type PluginHookGatewayStopEvent = {
reason?: string;
};
export type PluginHookGatewayCronJob = {
id: string;
name?: string;
description?: string;
enabled?: boolean;
schedule?: {
kind?: string;
expr?: string;
tz?: string;
};
sessionTarget?: string;
wakeMode?: string;
payload?: {
kind?: string;
text?: string;
};
createdAtMs?: number;
};
export type PluginHookGatewayCronCreateInput = {
name: string;
description: string;
enabled: boolean;
schedule: {
kind: string;
expr: string;
tz?: string;
};
sessionTarget: string;
wakeMode: string;
payload: {
kind: string;
text?: string;
};
};
export type PluginHookGatewayCronUpdateInput = Partial<PluginHookGatewayCronCreateInput>;
export type PluginHookGatewayCronRemoveResult = {
removed?: boolean;
};
export type PluginHookGatewayCronService = {
list: (opts?: { includeDisabled?: boolean }) => Promise<PluginHookGatewayCronJob[]>;
add: (input: PluginHookGatewayCronCreateInput) => Promise<unknown>;
update: (id: string, patch: PluginHookGatewayCronUpdateInput) => Promise<unknown>;
remove: (id: string) => Promise<PluginHookGatewayCronRemoveResult>;
};
export type PluginInstallTargetType = "skill" | "plugin";
export type PluginInstallRequestKind =
| "skill-install"

View File

@@ -31,7 +31,12 @@ async function expectGatewayHookCall(params: {
}
describe("gateway hook runner methods", () => {
const gatewayCtx = { port: 18789 };
const gatewayCtx = {
port: 18789,
config: {} as never,
workspaceDir: "/tmp/openclaw-workspace",
getCron: () => undefined,
};
it.each([
{