feat: Added direct script invocation support for graph-based agents

This commit is contained in:
2026-05-13 12:35:10 -06:00
parent a423181451
commit 8bb55ffd75
3 changed files with 514 additions and 1 deletions
+15 -1
View File
@@ -50,8 +50,11 @@ enum BinaryType<'a> {
Agent,
}
/// Canonical set of script languages that Loki can execute. This is the
/// single source of truth for both function-tool scripts and graph script
/// nodes.
#[derive(Debug, Clone, Copy, PartialEq, Eq, AsRefStr)]
enum Language {
pub enum Language {
Bash,
Python,
TypeScript,
@@ -90,6 +93,17 @@ impl Language {
}
}
impl Language {
pub fn direct_invoker(self) -> Option<(&'static str, &'static [&'static str])> {
match self {
Language::Bash => Some(("bash", &[])),
Language::Python => Some(("python3", &[])),
Language::TypeScript => Some(("npx", &["tsx"])),
Language::Unsupported => None,
}
}
}
fn extract_shebang_runtime(path: &Path) -> Option<String> {
let file = File::open(path).ok()?;
let reader = io::BufReader::new(file);