Move LLM and agent into ext/ai with host tool catalog and call_fn.

Consolidate official AI extensions under ext/ai/, add agent history/context host APIs, dynamic call_fn, and a first-pass TOOL:name loop so runbooks can list zero-arg tools in a table.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
cflmyandCursor committed 2026-08-06 15:28:39 +08:00
1 parent c4ffb9473f
commit 92d88fe761
29 files changed
+1019 -558

No files matched your search

+16
View File
@@ -65,11 +65,16 @@ pub fn compile_module(path: Option<&Path>, module: &Module) -> Result<Program> {
functions.push(compile_function(i, &flat, path_buf.as_deref())?);
}
let parents: Vec<Option<usize>> = flat.iter().map(|f| f.parent).collect();
let children: Vec<Vec<usize>> = flat.iter().map(|f| f.children.clone()).collect();
Ok(Program {
functions,
entry,
objects,
methods,
parents,
children,
})
}
@@ -470,6 +475,17 @@ impl<'a> FnCompiler<'a> {
}
return Ok(());
}
"call_fn" => {
let name_expr = self
.named_or_first(&call, "name")
.ok_or_else(|| self.err("call_fn requires name"))?;
self.compile_expr(name_expr)?;
self.emit(Op::CallFn);
if as_stmt {
self.emit(Op::Pop);
}
return Ok(());
}
other if crate::host::HostFn::from_name(other).is_some() => {
let hf = crate::host::HostFn::from_name(other).unwrap();
let params = hf.all_params();