Skip to main content

Crate evorule_plugin_kit

Crate evorule_plugin_kit 

Source
Expand description

In-process native plugin mechanism common crate for evorule-services.

This crate defines the NativeService trait, the NativeServiceDef declaration entry, and the generic filter router shared by all plugin families. Each family keeps its own declaration table; the host mounts the router with a per-family enable set.

§Components

  • NativeService: the uniform in-process service entry point.
  • NativeServiceDef: declarative registration entry (name, sensitivity flag, one-line description, optional JSON Schema parameter contract, instance constructor).
  • NativeServiceRouter: composite IoHandler that dispatches by service_name to a native service and falls back to HTTP otherwise.
  • mount_router: mount helper producing an Arc<dyn IoHandler>.

§Enable semantics

NativeServiceRouter::with_enabled and mount_router enforce three fail-fast rejections: unknown name, duplicate name, empty enable set. Router lookup always follows declaration order, regardless of the order of the enable set passed in.

§Async extension point

NativeService::execute_async is an async extension point whose default implementation wraps the synchronous execute in an immediately-ready future, so non-overriding services keep byte-for-byte identical behavior. The router always awaits execute_async, which makes overriding fully transparent to callers.

Services that need external I/O (HTTP egress, long polling, and similar) MUST override this method; they must not perform egress from the synchronous execute (no runtime support on that path). Any degraded result (e.g. a local stub while the external service is unavailable) must be truthfully labeled in the returned body; a stub must never impersonate the real service.

§Usage (plugin side)

  • Export a &'static [NativeServiceDef] declaration table: adding a native capability = append one entry + enable it in the plugin manifest; the host and the mechanism need zero changes.
  • Services with a fixed parameter surface declare parameters as a JSON Schema string (OpenAI function parameters subset); it is forwarded to LLM consumers via the capability inventory.
  • Wrap the table with mount_router (or use NativeServiceRouter directly) to obtain the mountable handler.

Modules§

executor
元指令执行器 - 5 个元指令 + io_request 信号 + enforce 强制原语

Structs§

NativeServiceDef
Native service declaration entry (declarative registration: adding a native capability = appending one entry to the plugin declaration table; the router, the capability inventory, and binding checks need zero changes).
NativeServiceRouter
Composite IoHandler: a service_name hit on a native service name dispatches natively; otherwise falls back to HTTP.

Enums§

JsonValue
JSON 值类型(确定性实现)

Traits§

IoHandler
I/O Handler trait —— 所有 I/O handler 实现此接口
NativeService
Uniform entry point for native services: receives args (with __ paths already resolved to concrete values by the engine) and returns the business result.

Functions§

mount_router
Mount helper: builds an Arc<dyn IoHandler> with enable semantics (referenced directly by the server-side PluginDef, avoiding per-family wrapper constructors).
serde_to_tcb
Convert a serde_json::Value into the canonical JsonValue form.

Type Aliases§

IoResult
I/O 执行结果
ObjectMap
Object 后端类型(BTreeMap 保证确定性迭代)