Skip to main content

apl_cpex/
lib.rs

1// Location: ./crates/apl-cpex/src/lib.rs
2// Copyright 2025
3// SPDX-License-Identifier: Apache-2.0
4// Authors: Teryl Taylor
5//
6// apl-cpex — bridge between APL evaluator (`apl-core`) and CPEX runtime
7// (`cpex-core`).
8//
9// `apl-core::PluginInvoker` is string-typed by design (so `apl-core`
10// stays free of CPEX deps). The actual typed boundary lives in this
11// crate: one `PluginInvoker` implementation per `HookTypeDef`. The
12// payload type is locked at the impl level — e.g. [`CmfPluginInvoker`]
13// can only dispatch to CMF hooks because every internal call goes
14// through `invoke_named::<CmfHook>`, and the compiler enforces that
15// the payload is `MessagePayload`.
16//
17// # v0 simplification — single-view-per-Message
18//
19// CMF spec §4.2 distinguishes two messaging patterns:
20//   - LLM wire format — bundled multi-part Messages (thinking + text +
21//     tool_call(s)) — many MessageViews per Message.
22//   - Framework/protocol format (MCP, A2A, LangGraph) — single
23//     ContentPart per Message — one view per Message.
24//
25// v0 only handles request-side flows (outbound LLM call from the user,
26// outbound MCP tools/call from the agent). Both are single-part, so the
27// route → MessageView matching collapses to "one route fires per
28// Message." When response-side handling lands, this assumption breaks
29// and apl-core's route-matching layer needs to switch from
30// routes-as-map to routes-as-list with a `match:` block filtering on
31// MessageView attributes. See the APL implementation memory's
32// "list-with-matchers" deferred item.
33
34pub mod cmf_invoker;
35pub mod delegation_invoker;
36pub mod dispatch_plan;
37pub mod parallel_safety;
38pub mod pdp_router;
39pub mod register;
40pub mod route_handler;
41pub mod session_resolver;
42pub mod session_store;
43pub mod visitor;
44
45pub use cmf_invoker::CmfPluginInvoker;
46pub use delegation_invoker::DelegationPluginInvoker;
47pub use dispatch_plan::{DispatchCache, RouteDispatchPlan, RoutePluginEntry};
48pub use pdp_router::PdpRouter;
49pub use register::{register_apl, AplOptions};
50pub use route_handler::{AplRouteHandler, Phase};
51pub use session_store::{MemorySessionStore, SessionStore, SessionStoreError, SessionStoreFactory};
52pub use visitor::AplConfigVisitor;