agentmux_srv\drone\executor\blocks/response.rs
1// Copyright 2026, AgentMux Corp.
2// SPDX-License-Identifier: Apache-2.0
3
4//! Response block — terminal output sink. Captures whatever the
5//! `template` field resolves to and that becomes the drone's run
6//! `output`. There must be exactly one Response block per drone
7//! (validator enforced at save-time, frontend side).
8//!
9//! Output: `{ "value": <resolved-template> }` — the engine reads
10//! `value` and stores it as the run-record `output` field.
11
12use serde_json::{json, Value};
13
14use crate::drone::data_flow::ExecutionScope;
15use crate::drone::types::FlowNode;
16
17pub async fn run(node: &FlowNode, scope: &ExecutionScope) -> Result<Value, String> {
18 let template = node
19 .data
20 .get("template")
21 .and_then(|v| v.as_str())
22 .unwrap_or("");
23 let value = scope.resolve(template);
24 Ok(json!({ "value": value }))
25}