feat: chained notebooks with when sections and host blocks (#11)

A notebook can include another one and continue with what it produced:

- core: parse :::when{param=a,b}, ::use{notebook= as= with=} and
  ::host{name= address= user= port= capture=}; composeNotebook namespaces
  an included notebook's params, steps, captures and templates by alias
  (cycles, missing files, depth > 4 and child errors are reported on the
  use line). Defaults may reference captures and builtins
  ({{shellbook.public_key}}); required params and secrets gate only steps
  of their own scope; secretEnv passes a scope's secrets under local names.
- protocol: NotebookResponse gains includes and builtins.
- server: compose includes on load, inject builtins (client values are
  ignored), refuse steps in inactive when sections.
- web: render when/use/host blocks, group included params in the form,
  add a created machine to Hosts and capture its name, reload when an
  included notebook changes, run all checks only for active steps,
  authoring snippets for when, use and host.
This commit is contained in:
Florian Schmidt
2026-11-16 11:42:12 +01:00
parent 28e806d641
commit 845d6c828e
24 changed files with 1407 additions and 136 deletions
+5
View File
@@ -43,6 +43,11 @@ export async function shellbookPublicKey(config: ServerConfig) {
throw httpError(503, "ShellBook key unavailable");
return `${parsed.type} ${parsed.getPublicSSH().toString("base64")}`;
}
/** Runtime values every notebook can reference ({{shellbook.public_key}}); empty when the key is unavailable. */
export async function builtinValues(config: ServerConfig): Promise<Record<string, string>> {
try { return { "shellbook.public_key": await shellbookPublicKey(config) }; }
catch { return {}; }
}
export async function hostsPlugin(
app: FastifyInstance,
{ config }: { config: ServerConfig },