@clawdreyhepburn/carapace 0.3.2 → 0.4.1
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/CHANGELOG.md +21 -0
- package/README.md +36 -1
- package/dist/cedar-engine-cedarling.d.ts +81 -0
- package/dist/cedar-engine-cedarling.js +651 -0
- package/dist/cedar-engine-cedarling.js.map +1 -0
- package/dist/cedar-engine.d.ts +77 -0
- package/dist/cedar-engine.js +374 -0
- package/dist/cedar-engine.js.map +1 -0
- package/dist/gui/html.d.ts +5 -0
- package/dist/gui/html.js +930 -0
- package/dist/gui/html.js.map +1 -0
- package/dist/gui/server.d.ts +28 -0
- package/dist/gui/server.js +159 -0
- package/dist/gui/server.js.map +1 -0
- package/dist/index.d.ts +46 -0
- package/dist/index.js +584 -0
- package/dist/index.js.map +1 -0
- package/dist/llm-proxy.d.ts +75 -0
- package/dist/llm-proxy.js +565 -0
- package/dist/llm-proxy.js.map +1 -0
- package/dist/mcp-aggregator.d.ts +29 -0
- package/dist/mcp-aggregator.js +144 -0
- package/dist/mcp-aggregator.js.map +1 -0
- package/dist/policy-source.d.ts +26 -0
- package/dist/policy-source.js +28 -0
- package/dist/policy-source.js.map +1 -0
- package/dist/types.d.ts +135 -0
- package/dist/types.js +5 -0
- package/dist/types.js.map +1 -0
- package/docs/carapace_proxy_tool_filter_flow_v3.svg +96 -0
- package/docs/ungated_ai_agent_capabilities.svg +143 -0
- package/package.json +1 -1
- package/src/cedar-engine-cedarling.ts +64 -5
- package/src/gui/server.ts +17 -0
- package/src/index.ts +2 -0
- package/src/llm-proxy.ts +21 -0
- package/src/policy-source.ts +44 -0
- package/vitest.config.ts +8 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## [0.4.0] - 2026-03-23
|
|
4
|
+
|
|
5
|
+
### Breaking Changes
|
|
6
|
+
- Removed agent hierarchy (OvidToken registration, agent context injection)
|
|
7
|
+
- Removed three-valued decisions (allow-proven/allow-unproven). All decisions are binary allow/deny.
|
|
8
|
+
- Removed `src/agent-context.ts` and `src/attenuation.ts`
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
- `CarapacePolicySource` implementing PolicySource interface for OVID-ME integration
|
|
12
|
+
- `/api/policy-source` endpoint on GUI server
|
|
13
|
+
|
|
14
|
+
### Changed
|
|
15
|
+
- Cedar evaluation simplified to binary allow/deny
|
|
16
|
+
- LLM proxy no longer injects agent context into Cedar evaluation
|
|
17
|
+
|
|
18
|
+
For per-agent mandate evaluation, see @clawdreyhepburn/ovid-me.
|
|
19
|
+
|
|
20
|
+
## [0.3.2] - 2026-03-19
|
|
21
|
+
- Agent hierarchy, three-valued decisions, OVID integration (now removed)
|
package/README.md
CHANGED
|
@@ -2,12 +2,13 @@
|
|
|
2
2
|
<h1 align="center">🦞 Carapace</h1>
|
|
3
3
|
<p align="center"><strong>Your agent's exoskeleton.</strong></p>
|
|
4
4
|
<p align="center">
|
|
5
|
-
|
|
5
|
+
The deployment-level policy ceiling for AI agents. Controls which tools, commands, and APIs your agent can access. Simple allow/deny Cedar evaluation — if a policy says no, it's no. For per-agent mandate evaluation, see <a href="https://github.com/clawdreyhepburn/ovid-me">@clawdreyhepburn/ovid-me</a>.
|
|
6
6
|
</p>
|
|
7
7
|
<p align="center">
|
|
8
8
|
<a href="#how-it-works">How It Works</a> •
|
|
9
9
|
<a href="#installation">Installation</a> •
|
|
10
10
|
<a href="#quick-start">Quick Start</a> •
|
|
11
|
+
<a href="#policy-source">Policy Source</a> •
|
|
11
12
|
<a href="docs/SECURITY.md">Security Guide</a> •
|
|
12
13
|
<a href="docs/RECOMMENDED-POLICIES.md">Recommended Policies</a> •
|
|
13
14
|
<a href="#the-control-gui">Control GUI</a> •
|
|
@@ -17,6 +18,10 @@
|
|
|
17
18
|
|
|
18
19
|
---
|
|
19
20
|
|
|
21
|
+
<p align="center">
|
|
22
|
+
<img src="docs/carapace_proxy_tool_filter_flow_v3.svg" alt="Carapace proxy filtering tool calls" width="700">
|
|
23
|
+
</p>
|
|
24
|
+
|
|
20
25
|
## What is Carapace?
|
|
21
26
|
|
|
22
27
|
AI agents can do a lot. They can read and write files, run shell commands, call APIs, send emails, push code — anything you give them access to. That's powerful, but it's also dangerous. An agent that can delete files can delete *all* files. An agent that can call APIs can send your data anywhere.
|
|
@@ -335,6 +340,33 @@ forbid(principal, action == Jans::Action::"call_api", resource == Jans::API::"pa
|
|
|
335
340
|
|
|
336
341
|
---
|
|
337
342
|
|
|
343
|
+
## Policy Source
|
|
344
|
+
|
|
345
|
+
Carapace is the **deployment-level policy ceiling** — it defines the maximum set of permissions any agent can have. For per-agent mandate evaluation (task-specific Cedar policy sets, delegation chains, subset proofs), see [`@clawdreyhepburn/ovid-me`](https://github.com/clawdreyhepburn/ovid-me).
|
|
346
|
+
|
|
347
|
+
### How OVID-ME queries Carapace
|
|
348
|
+
|
|
349
|
+
OVID-ME needs to know the deployment's effective Cedar policies to verify that a sub-agent's mandate is a subset of what the deployment allows. Carapace exposes this via the `PolicySource` interface:
|
|
350
|
+
|
|
351
|
+
```typescript
|
|
352
|
+
import { CarapacePolicySource } from '@clawdreyhepburn/carapace';
|
|
353
|
+
|
|
354
|
+
const policySource = new CarapacePolicySource('~/.openclaw/mcp-policies/');
|
|
355
|
+
const policies = await policySource.getEffectivePolicy('agent-id');
|
|
356
|
+
// Returns: concatenated Cedar policy text from all .cedar files
|
|
357
|
+
```
|
|
358
|
+
|
|
359
|
+
The GUI also exposes an HTTP endpoint:
|
|
360
|
+
|
|
361
|
+
```
|
|
362
|
+
GET http://localhost:19820/api/policy-source?principal=<id>
|
|
363
|
+
→ Returns Cedar policy text (text/plain)
|
|
364
|
+
```
|
|
365
|
+
|
|
366
|
+
Carapace policies are deployment-wide — the same policies apply to all principals. Principal-specific filtering happens in OVID-ME's mandate evaluation, not here.
|
|
367
|
+
|
|
368
|
+
---
|
|
369
|
+
|
|
338
370
|
## Design Philosophy
|
|
339
371
|
|
|
340
372
|
**Installing Carapace should never break your agent.** The default is `allow-all` — everything works exactly as before. You get visibility first (see what tools exist, what's being called) and control second (add restrictions when you're ready).
|
|
@@ -358,6 +390,7 @@ Most people should stay at step 3. Step 4 is for when you really understand your
|
|
|
358
390
|
- **Prompt injection** — Someone tricks your agent into running dangerous commands. If the policy says `rm` is forbidden, it doesn't matter what the prompt says.
|
|
359
391
|
- **Data exfiltration** — Your agent tries to send sensitive data to an external service. If the domain isn't permitted, the request is blocked.
|
|
360
392
|
- **Privilege escalation** — An agent tries to use one permitted tool to accomplish what a forbidden tool would do. Cedar's forbid-always-wins makes this harder.
|
|
393
|
+
- **Sub-agent over-privilege** — Carapace defines the deployment ceiling. For per-agent mandate enforcement, see [`@clawdreyhepburn/ovid-me`](https://github.com/clawdreyhepburn/ovid-me).
|
|
361
394
|
|
|
362
395
|
### What Carapace does NOT protect against
|
|
363
396
|
|
|
@@ -442,6 +475,7 @@ carapace/
|
|
|
442
475
|
│ ├── cedar-engine-cedarling.ts # Cedarling WASM engine — real Cedar 4.4.2 evaluation
|
|
443
476
|
│ ├── cedar-engine.ts # Fallback engine (string matching, no WASM needed)
|
|
444
477
|
│ ├── mcp-aggregator.ts # Connects to MCP servers, discovers tools, proxies calls
|
|
478
|
+
│ ├── policy-source.ts # PolicySource for OVID-ME integration
|
|
445
479
|
│ ├── types.ts # Shared TypeScript types
|
|
446
480
|
│ └── gui/
|
|
447
481
|
│ ├── server.ts # HTTP server for the dashboard
|
|
@@ -482,6 +516,7 @@ More at [clawdrey.com](https://clawdrey.com).
|
|
|
482
516
|
- **[Cedarling](https://github.com/JanssenProject/jans/tree/main/jans-cedarling)** — Cedar engine by [Gluu](https://gluu.org/), compiled to WebAssembly for speed.
|
|
483
517
|
- **[MCP](https://modelcontextprotocol.io/)** — Open protocol for connecting AI agents to tools.
|
|
484
518
|
- **[OpenClaw](https://github.com/openclaw/openclaw)** — Open-source AI agent platform.
|
|
519
|
+
- **[OVID-ME](https://github.com/clawdreyhepburn/ovid-me)** — Per-agent mandate evaluation (uses Carapace as its policy source).
|
|
485
520
|
|
|
486
521
|
---
|
|
487
522
|
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cedarling-powered Cedar engine for MCP tool authorization.
|
|
3
|
+
*
|
|
4
|
+
* Uses Gluu's Cedarling WASM module for proper Cedar evaluation,
|
|
5
|
+
* JWT validation, and the Policy Store format. Falls back to the
|
|
6
|
+
* homebrew engine if WASM loading fails.
|
|
7
|
+
*/
|
|
8
|
+
import type { Logger, AuthzRequest, CedarDecision, VerifyResult, CedarSchemaInfo } from "./types.js";
|
|
9
|
+
export interface CedarlingEngineOpts {
|
|
10
|
+
policyDir: string;
|
|
11
|
+
defaultPolicy: "deny-all" | "allow-all";
|
|
12
|
+
verify: boolean;
|
|
13
|
+
logger: Logger;
|
|
14
|
+
namespace?: string;
|
|
15
|
+
agentEntityType?: string;
|
|
16
|
+
}
|
|
17
|
+
export declare class CedarlingEngine {
|
|
18
|
+
private policyDir;
|
|
19
|
+
private defaultPolicy;
|
|
20
|
+
private shouldVerify;
|
|
21
|
+
private logger;
|
|
22
|
+
private namespace;
|
|
23
|
+
private agentEntityType;
|
|
24
|
+
private cedarling;
|
|
25
|
+
private wasmModule;
|
|
26
|
+
private policies;
|
|
27
|
+
private schemaJson;
|
|
28
|
+
private schemaRaw;
|
|
29
|
+
constructor(opts: CedarlingEngineOpts);
|
|
30
|
+
init(): Promise<void>;
|
|
31
|
+
/**
|
|
32
|
+
* Authorize a request using Cedarling WASM.
|
|
33
|
+
*/
|
|
34
|
+
authorize(request: AuthzRequest): Promise<CedarDecision>;
|
|
35
|
+
/**
|
|
36
|
+
* Enable a resource by adding a permit policy and rebuilding Cedarling.
|
|
37
|
+
* resourceType: "Tool" | "Shell" | "API"
|
|
38
|
+
* action: the Cedar action name (e.g., "call_tool", "exec_command", "call_api")
|
|
39
|
+
*/
|
|
40
|
+
enableResource(qualifiedName: string, resourceType?: string, action?: string): void;
|
|
41
|
+
/**
|
|
42
|
+
* Disable a resource by adding a forbid policy and rebuilding Cedarling.
|
|
43
|
+
*/
|
|
44
|
+
disableResource(qualifiedName: string, resourceType?: string, action?: string): void;
|
|
45
|
+
/** Backwards-compatible aliases */
|
|
46
|
+
enableTool(qualifiedName: string): void;
|
|
47
|
+
disableTool(qualifiedName: string): void;
|
|
48
|
+
/**
|
|
49
|
+
* Check if a tool is enabled (synchronous check against local policy state).
|
|
50
|
+
* Checks both specific tool policies AND blanket policies (those without a specific tool name).
|
|
51
|
+
*/
|
|
52
|
+
isToolEnabled(qualifiedName: string): boolean;
|
|
53
|
+
savePolicy(id: string, raw: string): void;
|
|
54
|
+
deletePolicy(id: string): boolean;
|
|
55
|
+
getDefaultPolicy(): "deny-all" | "allow-all";
|
|
56
|
+
getPolicies(): Array<{
|
|
57
|
+
id: string;
|
|
58
|
+
effect: string;
|
|
59
|
+
raw: string;
|
|
60
|
+
}>;
|
|
61
|
+
getSchema(): CedarSchemaInfo;
|
|
62
|
+
saveSchema(raw: string): void;
|
|
63
|
+
verify(): Promise<VerifyResult>;
|
|
64
|
+
private loadWasm;
|
|
65
|
+
/**
|
|
66
|
+
* Rebuild the Cedarling instance from current policies and schema.
|
|
67
|
+
* Called after any policy or schema change.
|
|
68
|
+
*/
|
|
69
|
+
private rebuildCedarling;
|
|
70
|
+
/**
|
|
71
|
+
* Build a Cedarling Policy Store JSON from current policies and schema.
|
|
72
|
+
*/
|
|
73
|
+
private buildPolicyStore;
|
|
74
|
+
private loadPoliciesFromDisk;
|
|
75
|
+
private writePolicyFile;
|
|
76
|
+
private removePolicyFile;
|
|
77
|
+
private writeDefaultSchema;
|
|
78
|
+
private buildDefaultSchemaJson;
|
|
79
|
+
private authorizeBasic;
|
|
80
|
+
private parseSchemaForGui;
|
|
81
|
+
}
|