Files
neuron/build.sh
T
Will Anderson 71ab7eafde add chat_as_soul handler for multi-soul rooms
Routes a new event_type "chat_as_soul" through dharma/recv. The Studio
preassembles the system_prompt + transcript and dispatches per-speaker;
the soul-binary just performs the LLM call as the requested speaker_slug.
No engram_compile here — each soul has its own engram (88xx) and the
Studio queries it before composing the prompt.

Also: track the previously-untracked split source modules (chat, routes,
memory, awareness, studio) and add build.sh so the binary can be rebuilt
without the studio’s concat trick. elb resolves the import graph and
emits one .c per .el; we link them together with cc. dist/soul-el now
points at dist/neuron via symlink (matching the launchctl plist).
2026-05-03 04:17:02 -05:00

66 lines
2.0 KiB
Bash
Executable File

#!/usr/bin/env bash
#
# build.sh - Compile the Neuron soul-binary.
#
# Pipeline:
# 1. elb resolves the import graph from soul.el and runs `elc <module>` per
# module, emitting one .c file per .el into dist/.
# 2. cc links all dist/*.c plus el_runtime.c into a single native binary
# (dist/neuron). elb's own link step does not pass -I for the runtime
# headers, so we run cc ourselves.
# 3. Refresh dist/soul-el so the launchctl plist (which execs dist/soul ->
# dist/soul-el -> dist/neuron) picks up the new binary.
#
# Usage:
# ./build.sh - build dist/neuron and refresh dist/soul-el
# ./build.sh --kickstart - also kickstart the launchctl service
#
# Environment overrides:
# EL_HOME - path to foundation/el (default: ../foundation/el)
set -euo pipefail
cd "$(dirname "$0")"
NEURON_DIR=$(pwd)
EL_HOME="${EL_HOME:-${NEURON_DIR}/../foundation/el}"
ELB="${EL_HOME}/dist/platform/elb"
ELC="${EL_HOME}/dist/platform/elc"
RUNTIME_DIR="${EL_HOME}/el-compiler/runtime"
if [ ! -x "${ELB}" ] || [ ! -x "${ELC}" ]; then
echo "elb/elc not found in ${EL_HOME}/dist/platform" >&2
exit 1
fi
if [ ! -f "${RUNTIME_DIR}/el_runtime.c" ]; then
echo "runtime not found at ${RUNTIME_DIR}" >&2
exit 1
fi
mkdir -p dist
rm -f dist/*.c dist/*.elh
echo "==> elb compile (manifest entry: soul.el)"
PATH="${EL_HOME}/dist/platform:${PATH}" "${ELB}" --runtime="${RUNTIME_DIR}" \
> /tmp/neuron-elb.log 2>&1 || true
# elb's link step lacks -I for the runtime headers, so we always re-link
# manually below regardless of what elb reported.
OUT="dist/neuron"
echo "==> cc link -> ${OUT}"
cc -O2 -I "${RUNTIME_DIR}" \
-o "${OUT}" \
dist/*.c \
"${RUNTIME_DIR}/el_runtime.c" \
-lcurl -lpthread
echo "==> refresh dist/soul-el -> dist/neuron"
( cd dist && ln -sf neuron soul-el )
echo "==> built $(stat -f '%z' ${OUT}) bytes -> ${OUT}"
if [ "${1:-}" = "--kickstart" ]; then
echo "==> launchctl kickstart soul"
launchctl kickstart -k "gui/$(id -u)/ai.neurontechnologies.soul"
fi