1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
// Location: ./crates/cpex/src/lib.rs
// Copyright 2025
// SPDX-License-Identifier: Apache-2.0
// Authors: Fred Araujo
//! **CPEX is a policy enforcement runtime for AI agents.**
//!
//! It is a deterministic reference monitor between an agent and every
//! capability it invokes: tools, prompts, resources, inference providers, and
//! A2A methods. Each operation runs through a policy-defined pipeline that can
//! resolve identity, make an authorization decision (delegated to an engine
//! like Cedar or CEL), exchange and reduce credentials before a downstream
//! call, redact inputs and outputs, track information flow across calls, and
//! audit. You write that policy declaratively in APL, the configuration that
//! defines each operation's pipeline; CPEX evaluates and enforces it at the
//! boundary, against state the model cannot observe or forge.
//!
//! - Guide and concepts: <https://contextforge-org.github.io/cpex/>
//! - Source and issues: <https://github.com/contextforge-org/cpex>
//!
//! # This crate
//!
//! `cpex` is the **host facade**: one dependency that re-exports the CPEX
//! runtime (`cpex-core`, `apl-core`, `apl-cmf`, `apl-cpex`), so a host depends
//! on this crate instead of pinning each of them separately.
//!
//! By default it is the **engine only**: no builtin plugins are compiled in.
//! The bundled extension set lives in [`cpex-builtins`](cpex_builtins) and is
//! pulled in only when a builtins feature is enabled. The out-of-process
//! Python plugin host is separate again, behind `python-host`.
//!
//! # Usage
//!
//! Engine only (register your own factories):
//!
//! ```no_run
//! use std::sync::Arc;
//! use cpex::PluginManager;
//!
//! let mgr = Arc::new(PluginManager::default());
//! // ... register host factories, then `apl_cpex::register_apl(&mgr, opts)`.
//! ```
//!
//! With the bundled builtins (enable the `builtins` or `full` feature):
//!
//! ```ignore
//! use std::sync::Arc;
//! use cpex::PluginManager;
//!
//! let mgr = Arc::new(PluginManager::default());
//! // Register every enabled builtin factory and install the APL config
//! // visitor (in-process defaults) in one call:
//! cpex::install_builtins(&mgr);
//! // ... then load a config that references the enabled `kind`s.
//! ```
//!
//! # Features
//!
//! No plugins are on by default (`cpex = "0.2"` is the engine alone).
//! `builtins` enables the common in-process set; `full` adds the Valkey
//! session store; or pick a granular subset (`jwt`, `oauth`, `pii`,
//! `audit`, `cedar`, `cel`, `valkey`). When any builtins feature is on, the
//! registration helpers and the concrete factory types are re-exported here
//! from [`cpex-builtins`](cpex_builtins).
//!
//! `python-host` is orthogonal to all of those, and is in neither `builtins`
//! nor `full`. It pulls
//! [`cpex-hosts-python`](cpex_hosts_python), which runs existing Python CPEX
//! plugins out-of-process — one cached virtualenv and one `worker.py`
//! subprocess per plugin — and re-exports [`IsolatedVenvFactory`] and
//! [`ISOLATED_VENV_KIND`] here. Unlike the builtins there is no
//! `install_*` helper: register the factory yourself, because the `kind` is
//! one host serving arbitrarily many Python plugins.
//!
//! ```ignore
//! use cpex::{IsolatedVenvFactory, PluginManager, ISOLATED_VENV_KIND};
//! use cpex::cpex_core::factory::PluginFactoryRegistry;
//!
//! let mut factories = PluginFactoryRegistry::new();
//! factories.register(ISOLATED_VENV_KIND, Box::new(IsolatedVenvFactory));
//! let mgr = PluginManager::from_config(config, &factories)?;
//! // `initialize()` builds each venv and launches its worker — a cold pip
//! // install is measured in minutes, so do it at startup, not on demand.
//! mgr.initialize().await?;
//! ```
// Whole-crate re-exports for advanced use (types not surfaced below).
pub use ;
pub use PdpFactory;
pub use ;
pub use PluginManager;
// The whole aggregator, for advanced use.
pub use cpex_builtins;
// The whole Python host crate, for advanced use (venv and worker internals).
pub use cpex_hosts_python;
// Registration helpers — delegated to cpex-builtins, keeping the facade's
// historical names (`register_builtin_plugins`, `builtin_pdp_factories`).
pub use ;
// Concrete factory types + KIND consts, each behind its facade feature
// (which forwards to the matching cpex-builtins feature).
pub use CedarDirectPdpFactory;
pub use CelPdpFactory;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
// The Python host's `KIND` is renamed on re-export: bare `KIND` at the facade
// root says nothing about which plugin kind it is, and the builtins above all
// use a prefixed const.
pub use ;