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.
12345678910111213141516171819202122232425262728293031323334353637#!/usr/bin/env bash# Compile the daemon and copy its code into $1 beside a launcher, then print the# launcher's path for ALBEDO_DAEMON. Test daemons boot from the copy instead of# `gleam run`: none of them takes the build lock, so they boot side by side and# beside a running `gleam test`, and a rebuild during the run cannot change the# code under a daemon that is still loading modules.set -euo pipefailroot="$(cd "$(dirname "$0")/.." && pwd)"out="$1"# A git dependency fetch must not walk up into the checkout's shared .git (see# nix/devShells.nix).export GIT_CEILING_DIRECTORIES="$root/build${GIT_CEILING_DIRECTORIES:+:$GIT_CEILING_DIRECTORIES}"# A reused directory would keep the previous beams, and `ln -s` would follow its# old priv link into the checkout.rm -rf "$out"(cd "$root" && gleam build) >&2mkdir -p "$out"for ebin in "$root"/build/dev/erlang/*/ebin; do package="$(dirname "$ebin")" name="$(basename "$package")" mkdir -p "$out/$name" cp -R "$ebin" "$out/$name/ebin" # A sealed snapshot owns its priv tree too; later source edits cannot change it. if [ -d "$package/priv" ]; then cp -RL "$package/priv" "$out/$name/priv" fidone# Python caches are build artifacts, not changes to a sealed snapshot.python3 -m compileall -q -f --invalidation-mode checked-hash "$out/albedo/priv/python"ALBEDO_BUILD_APP="$out/albedo" "$root/priv/bin/albedo-daemon" erl -pa "$out"/*/ebin -noshell -eval 'application:ensure_all_started(crypto), ok = albedo_daemon:seal_build(unicode:characters_to_binary(os:getenv("ALBEDO_BUILD_APP"))), halt().'cat >"$out/albedo-daemon" <<EOF#!/bin/shexec "$root/priv/bin/albedo-daemon" erl -pa "$out"/*/ebin -eval 'albedo@@main:run(albedo)' -noshell -extra "\$@"EOFchmod +x "$out/albedo-daemon"echo "$out/albedo-daemon"