clawclamp 0.1.8 → 0.1.9
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.
- package/README.md +2 -2
- package/package.json +1 -1
- package/src/cedarling.ts +16 -1
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@ Clawclamp adds Cedar-based authorization to OpenClaw tool calls. It evaluates ev
|
|
|
5
5
|
## Features
|
|
6
6
|
|
|
7
7
|
- Cedar policy enforcement for `before_tool_call`.
|
|
8
|
-
- Long-term authorization via policy (
|
|
8
|
+
- Long-term authorization via policy (default policy denies all unless a grant is active).
|
|
9
9
|
- Short-term authorization via expiring grants.
|
|
10
10
|
- Audit UI for allowed/denied/gray-mode tool calls.
|
|
11
11
|
- Gray mode: denied calls are still executed but logged as overrides.
|
|
@@ -40,7 +40,7 @@ plugins:
|
|
|
40
40
|
includeParams: true
|
|
41
41
|
```
|
|
42
42
|
|
|
43
|
-
`policyStoreUri` points to a Cedar policy store JSON (file:// or https://). `policyStoreLocal` can be set to a raw JSON string for the policy store. If omitted, the plugin uses a built-in policy store that
|
|
43
|
+
`policyStoreUri` points to a Cedar policy store JSON (file:// or https://). `policyStoreLocal` can be set to a raw JSON string for the policy store. If omitted, the plugin uses a built-in policy store that denies all tool calls unless a grant is active or an explicit permit policy exists.
|
|
44
44
|
|
|
45
45
|
## UI
|
|
46
46
|
|
package/package.json
CHANGED
package/src/cedarling.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import initWasm, { init } from "@janssenproject/cedarling_wasm";
|
|
2
|
+
import { readFile } from "node:fs/promises";
|
|
3
|
+
import { createRequire } from "node:module";
|
|
2
4
|
|
|
3
5
|
export type CedarlingConfig = Record<string, string | number | boolean>;
|
|
4
6
|
|
|
@@ -11,7 +13,9 @@ export type CedarlingInstance = {
|
|
|
11
13
|
pop_logs: () => unknown[];
|
|
12
14
|
};
|
|
13
15
|
|
|
16
|
+
const require = createRequire(import.meta.url);
|
|
14
17
|
let cedarlingPromise: Promise<CedarlingInstance> | null = null;
|
|
18
|
+
let wasmInitPromise: Promise<void> | null = null;
|
|
15
19
|
|
|
16
20
|
export async function getCedarling(config: CedarlingConfig): Promise<CedarlingInstance> {
|
|
17
21
|
if (!cedarlingPromise) {
|
|
@@ -20,8 +24,19 @@ export async function getCedarling(config: CedarlingConfig): Promise<CedarlingIn
|
|
|
20
24
|
return cedarlingPromise;
|
|
21
25
|
}
|
|
22
26
|
|
|
27
|
+
async function ensureWasmInitialized(): Promise<void> {
|
|
28
|
+
if (!wasmInitPromise) {
|
|
29
|
+
wasmInitPromise = (async () => {
|
|
30
|
+
const wasmPath = require.resolve("@janssenproject/cedarling_wasm/cedarling_wasm_bg.wasm");
|
|
31
|
+
const wasmBytes = await readFile(wasmPath);
|
|
32
|
+
await initWasm(wasmBytes);
|
|
33
|
+
})();
|
|
34
|
+
}
|
|
35
|
+
return wasmInitPromise;
|
|
36
|
+
}
|
|
37
|
+
|
|
23
38
|
async function createCedarling(config: CedarlingConfig): Promise<CedarlingInstance> {
|
|
24
|
-
await
|
|
39
|
+
await ensureWasmInitialized();
|
|
25
40
|
const instance = await init(config);
|
|
26
41
|
return instance as CedarlingInstance;
|
|
27
42
|
}
|