codetether-agent 4.7.0-a-002.4

A2A-native AI coding agent for the CodeTether ecosystem
Documentation
use anyhow::Result;
use tetherscript::value::Value as TetherScriptValue;

use crate::tool::tetherscript::convert::tetherscript_to_json;

use super::outcome::{self, TetherScriptOutcome};

pub fn finish(
    stdout: String,
    call_result: Result<TetherScriptValue, tetherscript::interp::Unwind>,
) -> Result<TetherScriptOutcome> {
    let (tether_val, success) = match call_result {
        Ok(value) => {
            let success = outcome::is_success(&value);
            (value, success)
        }
        Err(unwind) => (
            TetherScriptValue::Str(std::rc::Rc::new(super::unwind::message(unwind))),
            false,
        ),
    };
    Ok(TetherScriptOutcome {
        output: outcome::output(stdout, &tether_val),
        success,
        value: tetherscript_to_json(&tether_val),
    })
}