@clawdreyhepburn/carapace 1.0.0 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/index.ts +3 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clawdreyhepburn/carapace",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "Cedar policy enforcement for agent tool access via OpenClaw's before_tool_call hook.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
package/src/index.ts CHANGED
@@ -35,7 +35,7 @@ interface OpenClawPluginApi {
35
35
  },
36
36
  opts?: { optional?: boolean },
37
37
  ): void;
38
- registerHook?(hookName: string, handler: (event: any) => Promise<any> | any): void;
38
+ registerHook?(hookName: string | string[], handler: (event: any) => Promise<any> | any, opts?: { name: string; description?: string; priority?: number }): void;
39
39
  registerCli?(fn: (ctx: { program: any }) => void, opts?: { commands: string[] }): void;
40
40
  registerGatewayMethod?(name: string, handler: (ctx: { respond: (ok: boolean, data: any) => void }) => void): void;
41
41
  }
@@ -105,8 +105,8 @@ export default function register(api: OpenClawPluginApi) {
105
105
  };
106
106
 
107
107
  // --- Register before_tool_call hook ---
108
- if (api.registerHook) {
109
- api.registerHook("before_tool_call", async (event: any) => {
108
+ if (api.on) {
109
+ api.on("before_tool_call", async (event: any) => {
110
110
  const toolName: string = event.toolName ?? event.tool ?? event.name ?? "";
111
111
  const params: Record<string, unknown> = event.params ?? event.arguments ?? event.input ?? {};
112
112