Something went wrong. Try again.
small gleam coding and persistent agent daemon with a detachable cli and a canvas ui forked from okami.mom/albedo
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576"""Record modules a first text turn loads for the daemon's background code warm.
Run with nix develop -c python3 test/manual/record_boot_modules.py. Uses a privatefake-provider daemon, no credentials or Python kernel; writes priv/boot-modules.txt."""
from __future__ import annotations
import argparseimport jsonfrom pathlib import Pathimport sysimport subprocessfrom types import SimpleNamespace
ROOT = Path(__file__).resolve().parents[2]sys.path.insert(0, str(ROOT / "test/e2e"))import harness # noqa: E402from harness import Albedo, Daemon, Provider, text # noqa: E402from inspect_support import Inspection # noqa: E402
def loaded(app): return set( json.loads( Inspection(app).evaluate( "io:put_chars(json:encode([atom_to_binary(M) || {M,_} <- Call(code, all_loaded, [])]))" ) ) )
def record(protocol): daemon = Daemon("boot-modules") daemon.env.update(ALBEDO_INSPECT="1", ALBEDO_PRELOAD="0") try: daemon.boot() before = loaded( SimpleNamespace( daemon=daemon, root=daemon.root, home=daemon.home, env=daemon.env ) ) with ( harness.on_daemon(daemon), Albedo(Provider(lambda _: text("ok")), protocol=protocol) as app, ): session = app.session() app.prompt(session, "hello").close() app.idle(session) return loaded(app) - before finally: daemon.shutdown() remaining = [ line for line in subprocess.check_output( ["ps", "-axo", "pid=,command="], text=True ).splitlines() if str(daemon.home) in line ] if remaining: raise AssertionError(remaining)
def main(): parser = argparse.ArgumentParser(description=__doc__) parser.add_argument("--output", type=Path, default=ROOT / "priv/boot-modules.txt") args = parser.parse_args() harness.snapshot_daemon() modules = sorted(record("chat_completions") | record("responses")) args.output.write_text("\n".join(modules) + "\n") print(f"{len(modules)} modules written to {args.output}")
if __name__ == "__main__": main()