Skip to main content

Module op

Module op 

Source
Expand description

Op-in API in crates/protocol (issue #5261, Phase A1 of the core/protocol extraction spec).

The TUI engine already had an internal channel (Op in crates/tui/src/core/ops.rs with tx_op / rx_op and tx_steer). This protocol file formalizes that channel so TUI, CLI, app-server, and tests share one serializable API. The wire is OpEnvelope + Op; transports that already speak JSON (app-server, tests) can send the envelope directly, while in-process callers continue to use the typed enum.

Parity is compile-enforced from the engine side: crates/tui/src/core/protocol_parity.rs matches every engine Op variant exhaustively into a protocol Op (protocol_covers_engine_ops).

What is deliberately stripped at this boundary:

  • mpsc / oneshot reply channels (GetSubAgentSettlement, GetSessionSnapshot, GetProviderRuntimeStatus, BootstrapMcp, RetryMcpServer, ReloadMcp). Over the wire the reply is an EventMsg or a response frame, not a channel.
  • Arc<HookExecutor> on SendMessage: hooks are host configuration, not turn input.
  • Resolved provider routes and clients. Only the non-secret receipt (model, model_provider) crosses; the engine re-resolves.
  • Ruleset, transcript Messages, and SystemPrompt cross as serde_json::Value from their own Serialize until typed in a later phase.

Steer and Cancel have no engine Op twin on purpose: the engine carries them on tx_steer and the cancellation token. They are protocol operations regardless, because every out-of-process client needs them.

Structs§

CompactionPolicy
Compaction policy derived from a provider route. Twin of the engine’s CompactionConfig.
OpEnvelope
Every Op is paired with the ids that route it. This is the Op-in half of the Op-in / EventMsg-out contract.
RouteLimits
Token-limit facts for a route. None is unknown, never zero.

Enums§

Op
Operations that can be submitted to the core engine. This is the protocol view of crates/tui/src/core/ops::Op — same lifecycle, same provenance gate — but serializable and free of mpsc / oneshot fields. In-process callers convert at the boundary; out-of-process callers send the JSON directly.

Constants§

OP_KINDS
Every wire tag Op can carry, in declaration order.

Functions§

headless_send_message_op
Build a headless SendMessage envelope with fresh ids. This is the one-line helper every headless caller (CLI exec, app-server, tests) uses so TUI and headless start a session identically.