pub struct SessionSpec {Show 29 fields
pub name: String,
pub version: String,
pub description: String,
pub instruction: String,
pub greeting: Option<String>,
pub modality: SpecModality,
pub voice: Option<String>,
pub tools: Vec<ToolSpec>,
pub mcp: Vec<String>,
pub extract: Vec<ExtractSpec>,
pub models: ModelsSpec,
pub decisions: BTreeMap<String, DecisionSpec>,
pub code: Option<CodeSpec>,
pub state: BTreeMap<String, StateFieldSpec>,
pub computed: Vec<ComputedSpec>,
pub memory: Option<MemorySpec>,
pub runtime: Option<RuntimeSpec>,
pub phases: Vec<PhaseSpec>,
pub initial_phase: Option<String>,
pub watch: Vec<WatchSpec>,
pub patterns: Vec<PatternSpec>,
pub fragments: BTreeMap<String, Flow>,
pub use_fragments: Vec<UseFragment>,
pub flow: Option<Flow>,
pub conversation: Option<ConversationSpec>,
pub skills: Vec<SkillSpec>,
pub task_scenarios: Vec<TaskScenario>,
pub scenarios: Vec<Scenario>,
pub tests: Vec<SpecTest>,
}Expand description
A complete Live session as one JSON document. See the module docs.
Fields§
§name: StringApp name (display and registry identity).
version: StringSpec version tag (freeform, e.g. “1” or “2025-08-24”).
description: StringHuman-readable description.
instruction: StringBase system instruction.
greeting: Option<String>Optional greeting prompt — the model speaks first on connect.
modality: SpecModalityOutput modality. Defaults to text.
voice: Option<String>Voice name for audio sessions (e.g. “Puck”).
tools: Vec<ToolSpec>Declared tools (mock or HTTP-bound).
mcp: Vec<String>MCP toolset connection strings — the whole MCP ecosystem as this app’s tool library. Resolved at connect time.
extract: Vec<ExtractSpec>Out-of-band extraction pipelines.
models: ModelsSpecThe models the spec runs on, by role.
decisions: BTreeMap<String, DecisionSpec>Questions a decision model (such as Jev) answers about the
conversation, by id. Guards name them with the decided atom, and the
runtime asks the ones the flow can act on at each decision point.
Requires SpecResources::decision_model.
code: Option<CodeSpec>A code tool: the model runs a short Python program whose functions are the declared tools, each call governed like a direct call. Use it for reads the model would otherwise add up, sort or join itself.
state: BTreeMap<String, StateFieldSpec>Declared state keys — the session’s data dictionary.
computed: Vec<ComputedSpec>Computed (derived) state variables.
memory: Option<MemorySpec>Durable memory: slots projected into state, remember effects, and
the ambient recall/manage tools. Requires a MemoryBinding in
SpecResources at apply time.
runtime: Option<RuntimeSpec>Control-plane and voice tuning.
phases: Vec<PhaseSpec>Conversation phases.
initial_phase: Option<String>Initial phase name (required when phases is non-empty).
watch: Vec<WatchSpec>State watchers.
patterns: Vec<PatternSpec>Temporal patterns (sustained / consecutive-turn conditions).
fragments: BTreeMap<String, Flow>Reusable flow fragments, spliced via use_fragments.
use_fragments: Vec<UseFragment>Fragment splice directives.
flow: Option<Flow>The governed flow DAG (optional — a spec may be phases-only).
conversation: Option<ConversationSpec>The conversation: stages, slots, digressions, commits, timing and
policies, compiled by the conversation compiler.
The higher-level alternative to flow; set one or the other. Stage
resolvers bind to the declared tools by name.
skills: Vec<SkillSpec>Reusable capabilities, each with task-private state and operations.
task_scenarios: Vec<TaskScenario>Model-free journeys through skill activation, approval and cancellation.
scenarios: Vec<Scenario>Scenarios run against conversation by
SessionSpec::run_scenarios: model-free, deterministic.
tests: Vec<SpecTest>Embedded conformance tests, replayed offline by
SessionSpec::run_tests.
Implementations§
Source§impl SessionSpec
impl SessionSpec
Sourcepub fn commit_tools(&self) -> BTreeSet<String>
pub fn commit_tools(&self) -> BTreeSet<String>
The tools that commit: a conversation stage’s commit (main flow and
overlays) and a flow’s commit steps.
Sourcepub fn code_functions(&self) -> Vec<String>
pub fn code_functions(&self) -> Vec<String>
The tools a program can call: code.functions, or every declared
tool except commits and background tools.
Sourcepub fn compile_code_mode(
&self,
sandbox: Option<Arc<dyn CodeSandbox>>,
) -> Option<CodeMode>
pub fn compile_code_mode( &self, sandbox: Option<Arc<dyn CodeSandbox>>, ) -> Option<CodeMode>
The spec’s code tool, running programs in sandbox (in this process
when None). None when the spec has no code.
Source§impl SessionSpec
impl SessionSpec
Source§impl SessionSpec
impl SessionSpec
Sourcepub fn compile_decisions(&self, model: Arc<dyn DecisionModel>) -> Decisions
pub fn compile_decisions(&self, model: Arc<dyn DecisionModel>) -> Decisions
The decisions bank as the runtime’s Decisions, over model.
Questions read outside a flow (phase transitions, patterns) are
standing: asked at every caller turn.
Source§impl SessionSpec
impl SessionSpec
Sourcepub fn to_project(&self, language: ProjectLanguage) -> Vec<ProjectFile>
pub fn to_project(&self, language: ProjectLanguage) -> Vec<ProjectFile>
A project in language that runs this spec. See the
module docs for what each language generates.
Sourcepub fn to_project_with(
&self,
language: ProjectLanguage,
options: &ProjectOptions,
) -> Vec<ProjectFile>
pub fn to_project_with( &self, language: ProjectLanguage, options: &ProjectOptions, ) -> Vec<ProjectFile>
to_project with options.
Source§impl SessionSpec
impl SessionSpec
Sourcepub fn compile_tasks(
&self,
resources: &SpecResources,
) -> Result<TaskRuntime, String>
pub fn compile_tasks( &self, resources: &SpecResources, ) -> Result<TaskRuntime, String>
Compile local skill definitions into the runtime used by Live.
Sourcepub async fn trace_tasks(
&self,
steps: &[TaskStep],
) -> Result<(Vec<TaskTraceSnapshot>, TaskSessionSnapshot), Vec<String>>
pub async fn trace_tasks( &self, steps: &[TaskStep], ) -> Result<(Vec<TaskTraceSnapshot>, TaskSessionSnapshot), Vec<String>>
Replay commands with declared mock tools only. Attached implementations, HTTP bindings and MCP servers never execute in this path.
Sourcepub async fn trace_tasks_with_resources(
&self,
steps: &[TaskStep],
resources: &SpecResources,
) -> Result<(Vec<TaskTraceSnapshot>, TaskSessionSnapshot), Vec<String>>
pub async fn trace_tasks_with_resources( &self, steps: &[TaskStep], resources: &SpecResources, ) -> Result<(Vec<TaskTraceSnapshot>, TaskSessionSnapshot), Vec<String>>
Replay with explicitly supplied controlled memory services. Tool implementations and extraction providers remain disabled; a supplied memory binding executes its project/ingest/remember methods and must be an operator-controlled fixture.
Sourcepub async fn run_task_scenarios(&self) -> Vec<ScenarioReport>
pub async fn run_task_scenarios(&self) -> Vec<ScenarioReport>
Run every declared task journey through the shared offline runtime.
Source§impl SessionSpec
impl SessionSpec
Sourcepub fn uses_default_extraction_model(&self) -> bool
pub fn uses_default_extraction_model(&self) -> bool
Whether some extraction (the spec’s or a skill’s extract entries)
names no model, so it runs on the host’s extraction_llm.
Sourcepub fn requires_extraction(&self) -> bool
pub fn requires_extraction(&self) -> bool
Whether root or task definitions need an out-of-band extraction model.
Sourcepub fn requires_memory(&self) -> bool
pub fn requires_memory(&self) -> bool
Whether root or task definitions use the contextual memory binding.
Sourcepub fn from_value(value: Value) -> Result<Self, String>
pub fn from_value(value: Value) -> Result<Self, String>
Parse a spec from a JSON value. Accepts a full document or a bare
flow ({"steps": [...]}), which is wrapped in a default spec.
Sourcepub fn json_schema() -> Value
pub fn json_schema() -> Value
The JSON Schema of the spec document itself — for editor autocomplete and for validating machine-authored specs at generation time.
Sourcepub fn tool_names(&self) -> Vec<String>
pub fn tool_names(&self) -> Vec<String>
Declared tool names (mock/HTTP; MCP names resolve at connect).
Sourcepub fn effective_flow(&self) -> Result<Flow, Vec<String>>
pub fn effective_flow(&self) -> Result<Flow, Vec<String>>
The flow with every use_fragments directive spliced in.
Sourcepub fn state_keys_written(&self) -> BTreeSet<String>
pub fn state_keys_written(&self) -> BTreeSet<String>
Every state key the session declares a writer for: tool set_state
and save_response_as, extraction names and promotion targets, phase
and watcher set effects.
Sourcepub async fn run_scenarios(&self) -> Vec<ScenarioReport>
pub async fn run_scenarios(&self) -> Vec<ScenarioReport>
Run scenarios against the conversation, in
order. Resolvers are stubbed: a scenario supplies their values with
set steps.
Sourcepub fn validate(&self) -> SpecValidation
pub fn validate(&self) -> SpecValidation
Validate the whole document: flow compilation (with the declared tool registry), fragment splicing, phase-guard restrictions, HTTP-binding support, and the read/write state-key diff.
Sourcepub fn validate_for_replay(&self) -> SpecValidation
pub fn validate_for_replay(&self) -> SpecValidation
Validate for scripted offline replay, where declared tools use mock effects and never open HTTP or MCP connections.
Checks the original document, including conflicting tool bindings. Only the requirement to compile HTTP transport support is omitted.
Sourcepub fn build_dispatcher(&self, state: &State) -> ToolDispatcher
pub fn build_dispatcher(&self, state: &State) -> ToolDispatcher
Build the dispatcher of declared tools bound to state.
Sourcepub fn build_dispatcher_with(
&self,
state: &State,
resources: &SpecResources,
) -> ToolDispatcher
pub fn build_dispatcher_with( &self, state: &State, resources: &SpecResources, ) -> ToolDispatcher
Build the dispatcher of declared tools bound to state, calling the
in-process implementations in resources where it has them. Tools
bound to the same MCP server share one connection.
Sourcepub fn run_tests(&self) -> Vec<TestReport>
pub fn run_tests(&self) -> Vec<TestReport>
Run the embedded test suite offline (no model, no network) — scripted
events replayed through the real FlowStack.
Includes installed skill workflow tests, named skill/test.
Sourcepub fn sandboxed(&self, allow: &BindingAllowlist) -> (SessionSpec, Vec<String>)
pub fn sandboxed(&self, allow: &BindingAllowlist) -> (SessionSpec, Vec<String>)
A copy of this spec that reaches only what allow permits, and one
note per binding it disabled.
mcp entries not in the allowlist are removed. A tool whose http
binding is not allowed becomes a mock: it returns its canned
response and still writes set_state, so the flow behaves the same
way offline. Use this before apply on any spec you did
not write, such as one posted by a browser.
Sourcepub fn apply(
&self,
live: Live,
state: &State,
resources: &SpecResources,
) -> Result<Live, String>
pub fn apply( &self, live: Live, state: &State, resources: &SpecResources, ) -> Result<Live, String>
Configure a Live builder from this spec.
state is the session state the declared tools bind to — pass the
same one via .state (this method does). Returns an error when
the spec fails validation or requires a resource resources lacks.
Everything code-only (callbacks, custom guards, middleware) is added on
the returned builder afterwards.
Tool bindings run as written. For a spec you did not write, call
sandboxed first.
Trait Implementations§
Source§impl Clone for SessionSpec
impl Clone for SessionSpec
Source§fn clone(&self) -> SessionSpec
fn clone(&self) -> SessionSpec
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for SessionSpec
impl Debug for SessionSpec
Source§impl Default for SessionSpec
impl Default for SessionSpec
Source§fn default() -> SessionSpec
fn default() -> SessionSpec
Source§impl<'de> Deserialize<'de> for SessionSpec
impl<'de> Deserialize<'de> for SessionSpec
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl JsonSchema for SessionSpec
impl JsonSchema for SessionSpec
Source§fn schema_name() -> String
fn schema_name() -> String
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
§fn is_referenceable() -> bool
fn is_referenceable() -> bool
$ref keyword. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for SessionSpec
impl !UnwindSafe for SessionSpec
impl Freeze for SessionSpec
impl Send for SessionSpec
impl Sync for SessionSpec
impl Unpin for SessionSpec
impl UnsafeUnpin for SessionSpec
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<T> CloneAny for T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Conv for T
impl<T> Conv for T
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
impl<S, T> Duplex<S> for Twhere
T: FromSample<S> + ToSample<S>,
§impl<T> FmtForward for T
impl<T> FmtForward for T
§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.§fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read more§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read more§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read more§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.