Skip to content

Commit c43ba8e

Browse files
authored
fix(cli): speed up hook status reads through the Gateway (#118288)
* perf(cli): reuse gateway hook status (#118222) * chore(protocol): register hooks.status schema module in generated surfaces
1 parent ae4a95f commit c43ba8e

28 files changed

Lines changed: 498 additions & 41 deletions

‎apps/android/app/src/main/java/ai/openclaw/app/gateway/GatewayProtocol.kt‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,7 @@ enum class GatewayMethod(
504504
MemorySearch("memory.search"),
505505
SkillsProposalsEventsList("skills.proposals.events.list"),
506506
SkillsProposalsEvaluate("skills.proposals.evaluate"),
507+
HooksStatus("hooks.status"),
507508
}
508509

509510
enum class GatewayEvent(

‎apps/shared/OpenClawKit/Sources/OpenClawProtocol/GatewayModels.swift‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15912,6 +15912,8 @@ public struct QuestionListResult: Codable, Sendable {
1591215912
}
1591315913
}
1591415914

15915+
public struct HooksStatusParams: Codable, Sendable {}
15916+
1591515917
public struct PluginApprovalRequestParams: Codable, Sendable {
1591615918
public let pluginid: String?
1591715919
public let title: String

‎packages/gateway-protocol/src/schema-export-registry.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export {
1414
GatewaySuspendStatusResultSchema,
1515
GatewaySuspendResumeParamsSchema,
1616
GatewaySuspendResumeResultSchema,
17+
HooksStatusParamsSchema,
1718
GATEWAY_SERVER_CAPS,
1819
HelloOkSchema,
1920
RequestFrameSchema,

‎packages/gateway-protocol/src/schema-modules.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export * from "./schema/devices.js";
2424
export * from "./schema/frames.js";
2525
export * from "./schema/fs.js";
2626
export * from "./schema/gateway-suspend.js";
27+
export * from "./schema/hooks.js";
2728
export * from "./schema/logs-chat.js";
2829
export * from "./schema/migrations.js";
2930
export * from "./schema/nodes.js";
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { describe, expect, it } from "vitest";
2+
import { validateHooksStatusParams } from "../index.js";
3+
4+
describe("hook protocol schemas", () => {
5+
it("accepts an empty status request and rejects extra fields", () => {
6+
expect(validateHooksStatusParams({})).toBe(true);
7+
expect(validateHooksStatusParams({ reload: true })).toBe(false);
8+
});
9+
});
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import type { Static } from "typebox";
2+
import { closedObject } from "./closed-object.js";
3+
4+
/** Empty request payload for the live Gateway hook status report. */
5+
export const HooksStatusParamsSchema = closedObject({});
6+
7+
export type HooksStatusParams = Static<typeof HooksStatusParamsSchema>;

‎packages/gateway-protocol/src/schema/protocol-schema-fragment-plugins-lifecycle.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
import * as config from "./config.js";
22
import * as devices from "./devices.js";
33
import * as frames from "./frames.js";
4+
import * as hooks from "./hooks.js";
45
import * as logsChat from "./logs-chat.js";
56
import * as pluginApprovals from "./plugin-approvals.js";
67
import * as plugins from "./plugins.js";
78

89
export const PluginLifecycleProtocolSchemas = {
10+
HooksStatusParams: hooks.HooksStatusParamsSchema,
911
PluginApprovalRequestParams: pluginApprovals.PluginApprovalRequestParamsSchema,
1012
PluginApprovalResolveParams: pluginApprovals.PluginApprovalResolveParamsSchema,
1113
PluginCatalogClawHubInstall: plugins.PluginCatalogClawHubInstallSchema,

‎packages/gateway-protocol/src/validator-registry.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
GatewaySuspendPrepareParamsSchema,
1212
GatewaySuspendStatusParamsSchema,
1313
GatewaySuspendResumeParamsSchema,
14+
HooksStatusParamsSchema,
1415
RequestFrameSchema,
1516
MessageActionParamsSchema,
1617
SendParamsSchema,
@@ -605,6 +606,7 @@ export const validateModelsAuthLogoutParams = lazyCompile(ModelsAuthLogoutParams
605606
export const validateModelsAuthStatusParams = lazyCompile(ModelsAuthStatusParamsSchema);
606607
export const validateModelsListParams = lazyCompile(ModelsListParamsSchema);
607608
export const validateSkillsStatusParams = lazyCompile(SkillsStatusParamsSchema);
609+
export const validateHooksStatusParams = lazyCompile(HooksStatusParamsSchema);
608610
export const validateToolsCatalogParams = lazyCompile(ToolsCatalogParamsSchema);
609611
export const validateToolsEffectiveParams = lazyCompile(ToolsEffectiveParamsSchema);
610612
export const validateToolsInvokeParams = lazyCompile(ToolsInvokeParamsSchema);

‎scripts/check-protocol-registry.mjs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,8 @@ const ownerModules = [
111111
...schemaModulesSource.matchAll(/^export \* from "\.\/schema\/([^"]+)\.js";$/gmu),
112112
].map((match) => match[1]);
113113
check(
114-
ownerModules.length === 52 && new Set(ownerModules).size === ownerModules.length,
115-
"schema-modules.ts must contain one unique 52-module owner list",
114+
ownerModules.length === 53 && new Set(ownerModules).size === ownerModules.length,
115+
"schema-modules.ts must contain one unique 53-module owner list",
116116
);
117117
check(
118118
schemaModulesSource.split("\n").filter(Boolean).length === ownerModules.length,

‎src/cli/command-catalog.ts‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,21 @@ export const cliCommandCatalog: readonly CliCommandCatalogEntry[] = [
386386
exact: true,
387387
policy: { configGuard: "skip", loadPlugins: "never", networkProxy: "bypass" },
388388
},
389+
{
390+
commandPath: ["hooks", "list"],
391+
exact: true,
392+
policy: { configGuard: "skip", loadPlugins: "never", networkProxy: "bypass" },
393+
},
394+
{
395+
commandPath: ["hooks", "info"],
396+
exact: true,
397+
policy: { configGuard: "skip", loadPlugins: "never", networkProxy: "bypass" },
398+
},
399+
{
400+
commandPath: ["hooks", "check"],
401+
exact: true,
402+
policy: { configGuard: "skip", loadPlugins: "never", networkProxy: "bypass" },
403+
},
389404
{ commandPath: ["logs"], policy: { networkProxy: "bypass" } },
390405
{ commandPath: ["mcp"], policy: { networkProxy: "bypass" } },
391406
{

0 commit comments

Comments
 (0)