@vainplex/openclaw-governance 0.1.0
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 +297 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +30 -0
- package/dist/index.js.map +1 -0
- package/dist/src/audit-redactor.d.ts +3 -0
- package/dist/src/audit-redactor.d.ts.map +1 -0
- package/dist/src/audit-redactor.js +68 -0
- package/dist/src/audit-redactor.js.map +1 -0
- package/dist/src/audit-trail.d.ts +27 -0
- package/dist/src/audit-trail.d.ts.map +1 -0
- package/dist/src/audit-trail.js +192 -0
- package/dist/src/audit-trail.js.map +1 -0
- package/dist/src/builtin-policies.d.ts +3 -0
- package/dist/src/builtin-policies.d.ts.map +1 -0
- package/dist/src/builtin-policies.js +152 -0
- package/dist/src/builtin-policies.js.map +1 -0
- package/dist/src/conditions/context.d.ts +3 -0
- package/dist/src/conditions/context.d.ts.map +1 -0
- package/dist/src/conditions/context.js +60 -0
- package/dist/src/conditions/context.js.map +1 -0
- package/dist/src/conditions/index.d.ts +4 -0
- package/dist/src/conditions/index.d.ts.map +1 -0
- package/dist/src/conditions/index.js +28 -0
- package/dist/src/conditions/index.js.map +1 -0
- package/dist/src/conditions/simple.d.ts +10 -0
- package/dist/src/conditions/simple.d.ts.map +1 -0
- package/dist/src/conditions/simple.js +94 -0
- package/dist/src/conditions/simple.js.map +1 -0
- package/dist/src/conditions/time.d.ts +3 -0
- package/dist/src/conditions/time.d.ts.map +1 -0
- package/dist/src/conditions/time.js +48 -0
- package/dist/src/conditions/time.js.map +1 -0
- package/dist/src/conditions/tool.d.ts +3 -0
- package/dist/src/conditions/tool.d.ts.map +1 -0
- package/dist/src/conditions/tool.js +57 -0
- package/dist/src/conditions/tool.js.map +1 -0
- package/dist/src/config.d.ts +3 -0
- package/dist/src/config.d.ts.map +1 -0
- package/dist/src/config.js +80 -0
- package/dist/src/config.js.map +1 -0
- package/dist/src/cross-agent.d.ts +23 -0
- package/dist/src/cross-agent.d.ts.map +1 -0
- package/dist/src/cross-agent.js +142 -0
- package/dist/src/cross-agent.js.map +1 -0
- package/dist/src/engine.d.ts +29 -0
- package/dist/src/engine.d.ts.map +1 -0
- package/dist/src/engine.js +195 -0
- package/dist/src/engine.js.map +1 -0
- package/dist/src/frequency-tracker.d.ts +12 -0
- package/dist/src/frequency-tracker.d.ts.map +1 -0
- package/dist/src/frequency-tracker.js +44 -0
- package/dist/src/frequency-tracker.js.map +1 -0
- package/dist/src/hooks.d.ts +4 -0
- package/dist/src/hooks.d.ts.map +1 -0
- package/dist/src/hooks.js +198 -0
- package/dist/src/hooks.js.map +1 -0
- package/dist/src/policy-evaluator.d.ts +16 -0
- package/dist/src/policy-evaluator.d.ts.map +1 -0
- package/dist/src/policy-evaluator.js +99 -0
- package/dist/src/policy-evaluator.js.map +1 -0
- package/dist/src/policy-loader.d.ts +8 -0
- package/dist/src/policy-loader.d.ts.map +1 -0
- package/dist/src/policy-loader.js +105 -0
- package/dist/src/policy-loader.js.map +1 -0
- package/dist/src/risk-assessor.d.ts +8 -0
- package/dist/src/risk-assessor.d.ts.map +1 -0
- package/dist/src/risk-assessor.js +80 -0
- package/dist/src/risk-assessor.js.map +1 -0
- package/dist/src/trust-manager.d.ts +29 -0
- package/dist/src/trust-manager.d.ts.map +1 -0
- package/dist/src/trust-manager.js +219 -0
- package/dist/src/trust-manager.js.map +1 -0
- package/dist/src/types.d.ts +438 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/src/types.js +3 -0
- package/dist/src/types.js.map +1 -0
- package/dist/src/util.d.ts +28 -0
- package/dist/src/util.d.ts.map +1 -0
- package/dist/src/util.js +125 -0
- package/dist/src/util.js.map +1 -0
- package/openclaw.plugin.json +87 -0
- package/package.json +48 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,+DAA+D"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { TimeContext, TrustTier } from "./types.js";
|
|
2
|
+
/** Parse "HH:MM" to minutes since midnight */
|
|
3
|
+
export declare function parseTimeToMinutes(time: string): number;
|
|
4
|
+
/** Check if currentMinutes is within the range [after, before), handling midnight wrap */
|
|
5
|
+
export declare function isInTimeRange(currentMinutes: number, afterMinutes: number, beforeMinutes: number): boolean;
|
|
6
|
+
/** Get current time context for a timezone */
|
|
7
|
+
export declare function getCurrentTime(timezone: string): TimeContext;
|
|
8
|
+
/** Convert a glob pattern to a RegExp (supports * and ?) */
|
|
9
|
+
export declare function globToRegex(pattern: string): RegExp;
|
|
10
|
+
/** SHA-256 hash of a string */
|
|
11
|
+
export declare function sha256(data: string): string;
|
|
12
|
+
/** Clamp a value between min and max */
|
|
13
|
+
export declare function clamp(value: number, min: number, max: number): number;
|
|
14
|
+
/** Current time in microseconds (from performance.now) */
|
|
15
|
+
export declare function nowUs(): number;
|
|
16
|
+
/** Extract agent ID from session key or explicit agentId */
|
|
17
|
+
export declare function extractAgentId(sessionKey?: string, agentId?: string): string;
|
|
18
|
+
/** Check if a session key indicates a sub-agent */
|
|
19
|
+
export declare function isSubAgent(sessionKey?: string): boolean;
|
|
20
|
+
/** Extract parent session key from a sub-agent session key.
|
|
21
|
+
* "agent:main:subagent:forge:abc" → "agent:main"
|
|
22
|
+
* Returns null for root agents. */
|
|
23
|
+
export declare function extractParentSessionKey(sessionKey: string): string | null;
|
|
24
|
+
/** Map trust score to tier */
|
|
25
|
+
export declare function scoreToTier(score: number): TrustTier;
|
|
26
|
+
/** Map trust tier to its ordinal for comparisons */
|
|
27
|
+
export declare function tierOrdinal(tier: TrustTier): number;
|
|
28
|
+
//# sourceMappingURL=util.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../src/util.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEzD,8CAA8C;AAC9C,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAQvD;AAED,0FAA0F;AAC1F,wBAAgB,aAAa,CAC3B,cAAc,EAAE,MAAM,EACtB,YAAY,EAAE,MAAM,EACpB,aAAa,EAAE,MAAM,GACpB,OAAO,CAMT;AAED,8CAA8C;AAC9C,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,WAAW,CAoC5D;AAED,4DAA4D;AAC5D,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAMnD;AAED,+BAA+B;AAC/B,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE3C;AAED,wCAAwC;AACxC,wBAAgB,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAErE;AAED,0DAA0D;AAC1D,wBAAgB,KAAK,IAAI,MAAM,CAE9B;AAED,4DAA4D;AAC5D,wBAAgB,cAAc,CAC5B,UAAU,CAAC,EAAE,MAAM,EACnB,OAAO,CAAC,EAAE,MAAM,GACf,MAAM,CAWR;AAED,mDAAmD;AACnD,wBAAgB,UAAU,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO,CAGvD;AAED;;oCAEoC;AACpC,wBAAgB,uBAAuB,CACrC,UAAU,EAAE,MAAM,GACjB,MAAM,GAAG,IAAI,CAIf;AAED,8BAA8B;AAC9B,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,CAMpD;AAED,oDAAoD;AACpD,wBAAgB,WAAW,CAAC,IAAI,EAAE,SAAS,GAAG,MAAM,CASnD"}
|
package/dist/src/util.js
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
/** Parse "HH:MM" to minutes since midnight */
|
|
3
|
+
export function parseTimeToMinutes(time) {
|
|
4
|
+
const parts = time.split(":");
|
|
5
|
+
const h = Number(parts[0]);
|
|
6
|
+
const m = Number(parts[1]);
|
|
7
|
+
if (Number.isNaN(h) || Number.isNaN(m) || h < 0 || h > 23 || m < 0 || m > 59) {
|
|
8
|
+
return -1;
|
|
9
|
+
}
|
|
10
|
+
return h * 60 + m;
|
|
11
|
+
}
|
|
12
|
+
/** Check if currentMinutes is within the range [after, before), handling midnight wrap */
|
|
13
|
+
export function isInTimeRange(currentMinutes, afterMinutes, beforeMinutes) {
|
|
14
|
+
if (afterMinutes <= beforeMinutes) {
|
|
15
|
+
return currentMinutes >= afterMinutes && currentMinutes < beforeMinutes;
|
|
16
|
+
}
|
|
17
|
+
// Midnight wrap: e.g., after=23:00(1380), before=06:00(360)
|
|
18
|
+
return currentMinutes >= afterMinutes || currentMinutes < beforeMinutes;
|
|
19
|
+
}
|
|
20
|
+
/** Get current time context for a timezone */
|
|
21
|
+
export function getCurrentTime(timezone) {
|
|
22
|
+
const now = new Date();
|
|
23
|
+
const formatter = new Intl.DateTimeFormat("en-US", {
|
|
24
|
+
timeZone: timezone,
|
|
25
|
+
hour: "numeric",
|
|
26
|
+
minute: "numeric",
|
|
27
|
+
weekday: "short",
|
|
28
|
+
year: "numeric",
|
|
29
|
+
month: "2-digit",
|
|
30
|
+
day: "2-digit",
|
|
31
|
+
hour12: false,
|
|
32
|
+
});
|
|
33
|
+
const parts = formatter.formatToParts(now);
|
|
34
|
+
const get = (type) => parts.find((p) => p.type === type)?.value ?? "0";
|
|
35
|
+
const hour = Number(get("hour")) % 24;
|
|
36
|
+
const minute = Number(get("minute"));
|
|
37
|
+
const year = get("year");
|
|
38
|
+
const month = get("month");
|
|
39
|
+
const day = get("day");
|
|
40
|
+
const dayMap = {
|
|
41
|
+
Sun: 0, Mon: 1, Tue: 2, Wed: 3, Thu: 4, Fri: 5, Sat: 6,
|
|
42
|
+
};
|
|
43
|
+
const weekday = get("weekday");
|
|
44
|
+
const dayOfWeek = dayMap[weekday] ?? 0;
|
|
45
|
+
return {
|
|
46
|
+
hour,
|
|
47
|
+
minute,
|
|
48
|
+
dayOfWeek,
|
|
49
|
+
date: `${year}-${month}-${day}`,
|
|
50
|
+
timezone,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
/** Convert a glob pattern to a RegExp (supports * and ?) */
|
|
54
|
+
export function globToRegex(pattern) {
|
|
55
|
+
const escaped = pattern
|
|
56
|
+
.replace(/[.+^${}()|[\]\\]/g, "\\$&")
|
|
57
|
+
.replace(/\*/g, ".*")
|
|
58
|
+
.replace(/\?/g, ".");
|
|
59
|
+
return new RegExp(`^${escaped}$`);
|
|
60
|
+
}
|
|
61
|
+
/** SHA-256 hash of a string */
|
|
62
|
+
export function sha256(data) {
|
|
63
|
+
return createHash("sha256").update(data).digest("hex");
|
|
64
|
+
}
|
|
65
|
+
/** Clamp a value between min and max */
|
|
66
|
+
export function clamp(value, min, max) {
|
|
67
|
+
return Math.max(min, Math.min(max, value));
|
|
68
|
+
}
|
|
69
|
+
/** Current time in microseconds (from performance.now) */
|
|
70
|
+
export function nowUs() {
|
|
71
|
+
return Math.round(performance.now() * 1000);
|
|
72
|
+
}
|
|
73
|
+
/** Extract agent ID from session key or explicit agentId */
|
|
74
|
+
export function extractAgentId(sessionKey, agentId) {
|
|
75
|
+
if (agentId)
|
|
76
|
+
return agentId;
|
|
77
|
+
if (!sessionKey)
|
|
78
|
+
return "unknown";
|
|
79
|
+
// "agent:main:subagent:forge:abc123" → "forge"
|
|
80
|
+
// "agent:main" → "main"
|
|
81
|
+
const parts = sessionKey.split(":");
|
|
82
|
+
if (parts.length >= 4 && parts[2] === "subagent") {
|
|
83
|
+
return parts[3] ?? "unknown";
|
|
84
|
+
}
|
|
85
|
+
return parts[1] ?? "unknown";
|
|
86
|
+
}
|
|
87
|
+
/** Check if a session key indicates a sub-agent */
|
|
88
|
+
export function isSubAgent(sessionKey) {
|
|
89
|
+
if (!sessionKey)
|
|
90
|
+
return false;
|
|
91
|
+
return sessionKey.includes(":subagent:");
|
|
92
|
+
}
|
|
93
|
+
/** Extract parent session key from a sub-agent session key.
|
|
94
|
+
* "agent:main:subagent:forge:abc" → "agent:main"
|
|
95
|
+
* Returns null for root agents. */
|
|
96
|
+
export function extractParentSessionKey(sessionKey) {
|
|
97
|
+
const idx = sessionKey.indexOf(":subagent:");
|
|
98
|
+
if (idx === -1)
|
|
99
|
+
return null;
|
|
100
|
+
return sessionKey.substring(0, idx);
|
|
101
|
+
}
|
|
102
|
+
/** Map trust score to tier */
|
|
103
|
+
export function scoreToTier(score) {
|
|
104
|
+
if (score >= 80)
|
|
105
|
+
return "privileged";
|
|
106
|
+
if (score >= 60)
|
|
107
|
+
return "trusted";
|
|
108
|
+
if (score >= 40)
|
|
109
|
+
return "standard";
|
|
110
|
+
if (score >= 20)
|
|
111
|
+
return "restricted";
|
|
112
|
+
return "untrusted";
|
|
113
|
+
}
|
|
114
|
+
/** Map trust tier to its ordinal for comparisons */
|
|
115
|
+
export function tierOrdinal(tier) {
|
|
116
|
+
const map = {
|
|
117
|
+
untrusted: 0,
|
|
118
|
+
restricted: 1,
|
|
119
|
+
standard: 2,
|
|
120
|
+
trusted: 3,
|
|
121
|
+
privileged: 4,
|
|
122
|
+
};
|
|
123
|
+
return map[tier];
|
|
124
|
+
}
|
|
125
|
+
//# sourceMappingURL=util.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util.js","sourceRoot":"","sources":["../../src/util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAGzC,8CAA8C;AAC9C,MAAM,UAAU,kBAAkB,CAAC,IAAY;IAC7C,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC9B,MAAM,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IAC3B,MAAM,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC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G,CAAC,CAAC;AACtC,CAAC;AAED,8BAA8B;AAC9B,MAAM,UAAU,WAAW,CAAC,KAAa;IACvC,IAAI,KAAK,IAAI,EAAE;QAAE,OAAO,YAAY,CAAC;IACrC,IAAI,KAAK,IAAI,EAAE;QAAE,OAAO,SAAS,CAAC;IAClC,IAAI,KAAK,IAAI,EAAE;QAAE,OAAO,UAAU,CAAC;IACnC,IAAI,KAAK,IAAI,EAAE;QAAE,OAAO,YAAY,CAAC;IACrC,OAAO,WAAW,CAAC;AACrB,CAAC;AAED,oDAAoD;AACpD,MAAM,UAAU,WAAW,CAAC,IAAe;IACzC,MAAM,GAAG,GAA8B;QACrC,SAAS,EAAE,CAAC;QACZ,UAAU,EAAE,CAAC;QACb,QAAQ,EAAE,CAAC;QACX,OAAO,EAAE,CAAC;QACV,UAAU,EAAE,CAAC;KACd,CAAC;IACF,OAAO,GAAG,CAAC,IAAI,CAAC,CAAC;AACnB,CAAC"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "openclaw-governance",
|
|
3
|
+
"name": "OpenClaw Governance",
|
|
4
|
+
"description": "Contextual, learning, cross-agent governance for AI agents",
|
|
5
|
+
"version": "0.1.0",
|
|
6
|
+
"configSchema": {
|
|
7
|
+
"type": "object",
|
|
8
|
+
"additionalProperties": false,
|
|
9
|
+
"properties": {
|
|
10
|
+
"enabled": {
|
|
11
|
+
"type": "boolean",
|
|
12
|
+
"default": true,
|
|
13
|
+
"description": "Enable/disable the governance engine"
|
|
14
|
+
},
|
|
15
|
+
"timezone": {
|
|
16
|
+
"type": "string",
|
|
17
|
+
"default": "UTC",
|
|
18
|
+
"description": "Timezone for time-aware policies (IANA format)"
|
|
19
|
+
},
|
|
20
|
+
"failMode": {
|
|
21
|
+
"type": "string",
|
|
22
|
+
"enum": ["open", "closed"],
|
|
23
|
+
"default": "open",
|
|
24
|
+
"description": "Behavior on engine errors: open (allow) or closed (deny)"
|
|
25
|
+
},
|
|
26
|
+
"policies": {
|
|
27
|
+
"type": "array",
|
|
28
|
+
"default": [],
|
|
29
|
+
"description": "Policy definitions"
|
|
30
|
+
},
|
|
31
|
+
"timeWindows": {
|
|
32
|
+
"type": "object",
|
|
33
|
+
"default": {},
|
|
34
|
+
"description": "Named time windows for time conditions"
|
|
35
|
+
},
|
|
36
|
+
"trust": {
|
|
37
|
+
"type": "object",
|
|
38
|
+
"properties": {
|
|
39
|
+
"enabled": { "type": "boolean", "default": true },
|
|
40
|
+
"defaults": { "type": "object", "default": { "main": 60, "*": 10 } },
|
|
41
|
+
"persistIntervalSeconds": { "type": "number", "default": 60 },
|
|
42
|
+
"decay": {
|
|
43
|
+
"type": "object",
|
|
44
|
+
"properties": {
|
|
45
|
+
"enabled": { "type": "boolean", "default": true },
|
|
46
|
+
"inactivityDays": { "type": "number", "default": 30 },
|
|
47
|
+
"rate": { "type": "number", "default": 0.95 }
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
"weights": { "type": "object" },
|
|
51
|
+
"maxHistoryPerAgent": { "type": "number", "default": 100 }
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
"audit": {
|
|
55
|
+
"type": "object",
|
|
56
|
+
"properties": {
|
|
57
|
+
"enabled": { "type": "boolean", "default": true },
|
|
58
|
+
"retentionDays": { "type": "number", "default": 90 },
|
|
59
|
+
"redactPatterns": { "type": "array", "items": { "type": "string" }, "default": [] },
|
|
60
|
+
"level": { "type": "string", "enum": ["minimal", "standard", "verbose"], "default": "standard" }
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
"toolRiskOverrides": {
|
|
64
|
+
"type": "object",
|
|
65
|
+
"additionalProperties": { "type": "integer", "minimum": 0, "maximum": 100 },
|
|
66
|
+
"description": "Tool sensitivity overrides (tool name → risk score 0-100)"
|
|
67
|
+
},
|
|
68
|
+
"builtinPolicies": {
|
|
69
|
+
"type": "object",
|
|
70
|
+
"properties": {
|
|
71
|
+
"nightMode": {},
|
|
72
|
+
"credentialGuard": { "type": "boolean" },
|
|
73
|
+
"productionSafeguard": { "type": "boolean" },
|
|
74
|
+
"rateLimiter": {}
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
"performance": {
|
|
78
|
+
"type": "object",
|
|
79
|
+
"properties": {
|
|
80
|
+
"maxEvalUs": { "type": "number", "default": 5000 },
|
|
81
|
+
"maxContextMessages": { "type": "number", "default": 10 },
|
|
82
|
+
"frequencyBufferSize": { "type": "number", "default": 1000 }
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@vainplex/openclaw-governance",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Contextual, learning, cross-agent governance for AI agents",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist/",
|
|
10
|
+
"openclaw.plugin.json",
|
|
11
|
+
"README.md"
|
|
12
|
+
],
|
|
13
|
+
"scripts": {
|
|
14
|
+
"build": "tsc",
|
|
15
|
+
"test": "vitest run",
|
|
16
|
+
"test:watch": "vitest",
|
|
17
|
+
"test:coverage": "vitest run --coverage",
|
|
18
|
+
"clean": "rm -rf dist/"
|
|
19
|
+
},
|
|
20
|
+
"devDependencies": {
|
|
21
|
+
"@types/node": "^25.2.3",
|
|
22
|
+
"@vitest/coverage-v8": "^3.0.0",
|
|
23
|
+
"typescript": "^5.7.0",
|
|
24
|
+
"vitest": "^3.0.0"
|
|
25
|
+
},
|
|
26
|
+
"engines": {
|
|
27
|
+
"node": ">=22.0.0"
|
|
28
|
+
},
|
|
29
|
+
"license": "MIT",
|
|
30
|
+
"author": "Albert Hild <albert@vainplex.dev>",
|
|
31
|
+
"repository": {
|
|
32
|
+
"type": "git",
|
|
33
|
+
"url": "https://github.com/alberthild/openclaw-governance.git"
|
|
34
|
+
},
|
|
35
|
+
"keywords": [
|
|
36
|
+
"openclaw",
|
|
37
|
+
"governance",
|
|
38
|
+
"ai-agents",
|
|
39
|
+
"policy-engine",
|
|
40
|
+
"trust",
|
|
41
|
+
"audit"
|
|
42
|
+
],
|
|
43
|
+
"openclaw": {
|
|
44
|
+
"extensions": [
|
|
45
|
+
"./dist/index.js"
|
|
46
|
+
]
|
|
47
|
+
}
|
|
48
|
+
}
|