feat: render top-level Endor scripts through embedded Aster
Verify Tessera GUI / verify (push) Failing after 6m52s

This commit is contained in:
2026-10-20 13:47:29 +08:00
parent 8cb2bf8607
commit 47ab2aa3a6
14 changed files with 695 additions and 89 deletions
+17 -10
View File
@@ -299,9 +299,10 @@ fn agent_guide(namespace: &NamespaceState) -> String {
Current namespace: `{name}`
Current revision: `{revision}`
Submit ordinary Endor functions. Tessera embeds Aster's frontend, compiler and VM.
The namespace comes from the request path. Declare a zero-argument `main` returning
a UI node. Type annotations are currently syntax only in Aster.
Submit an ordinary Endor script. Tessera embeds Aster's frontend, compiler and VM.
The namespace comes from the request path. Top-level bindings share the candidate
VM's globals; `ui.page().render(root)` selects the visible UI. No main function is
required. Typed helper functions and the older main-returning-View form also work.
## Code CRUD
@@ -322,11 +323,17 @@ Positional arguments only:
- `ui.rect(width, height, radius = 0, color = "#DCE8FF")`.
- `ui.column(padding, gap, child...)` and `ui.row(padding, gap, child...)`.
- `ui.spacer(size)`.
- `ui.page()` creates a page; `page.render(root)` sets its root. The last render
in a successful submission selects the page shown in this namespace.
Defaults above describe the host API; do not write keyword arguments in Endor.
Colors use #RRGGBB or #RRGGBBAA. Dimensions are finite numbers in 0..1000000.
Limits: 1 MiB source, 4096 constructed nodes, 64 UI levels, 10000 expanded layout
nodes, 16 KiB per text, 128 VM frames and 1000000 instructions per execution.
Use newlines between complete top-level statements. Multiline calls, function
bodies and expression continuations are passed to Aster as complete inputs.
Limits: 1 MiB source, 4096 constructed nodes, 64 pages, 64 UI levels, 10000 expanded
layout nodes, 16 KiB per text, 128 VM frames. Script statements each receive an
equal share of a total 1000000-instruction allowance. Older module initialization
and main execution each retain their own 1000000-instruction allowance.
PUT waits for its worker result. Errors return 422 with diagnostics and preserve
the last successful revision. A newer accepted PUT or DELETE supersedes older
@@ -339,7 +346,7 @@ future work. It is not an untrusted-code sandbox.
name = namespace.name,
revision = namespace.revision,
address = API_ADDRESS,
example = include_str!("../examples/hello.endor"),
example = include_str!("../examples/page.endor"),
)
}
@@ -466,10 +473,10 @@ mod tests {
api: Some(api),
};
let route = "/v1/namespaces/app.main/code";
let example = include_str!("../examples/hello.endor");
let example = include_str!("../examples/page.endor");
let (status, _, guide) = client.request("GET", "/agent", "");
assert_eq!(status, 200);
assert!(guide.contains("function main(): View"));
assert!(guide.contains("let myui = ui.page()"));
let (status, _, body) = client.request("PUT", route, example);
assert_eq!(status, 200, "{body}");
assert_eq!(
@@ -540,7 +547,7 @@ mod tests {
let release = Release(release_tx);
let client = &client;
let route = "/v1/namespaces/app.main/code";
let example = include_str!("../examples/hello.endor");
let example = include_str!("../examples/page.endor");
let first = scope.spawn(move || client.request("PUT", route, example));
entered_rx.recv_timeout(Duration::from_secs(10)).unwrap();
let pending = scope.spawn(move || client.request("PUT", route, example));
@@ -573,7 +580,7 @@ mod tests {
fn guide_contains_only_code_crud_routes() {
let guide = agent_guide(&NamespaceState::default());
assert!(guide.contains("Code CRUD"));
assert!(guide.contains("function main(): View"));
assert!(guide.contains("let myui = ui.page()"));
assert!(!guide.contains("export scene"));
assert!(guide.contains("PUT http://127.0.0.1:4737"));
assert!(!guide.contains("display_list"));