Findings from a pass over the daemon, the sandbox and the surfaces. HTTP: a loopback dashboard without a token was reachable from any web page. The wildcard CORS grant and an OPTIONS branch before the token check let a cross-origin page POST into the one session, and a DNS-rebinding page could read it under its own name. Requests now need a loopback Host while no token is configured, an Origin must match the Host, and there is no CORS grant. MCP connections get a receive/send timeout instead of pinning a thread forever. CLI: --check silently ignored an unreadable or invalid config and printed a green self-test, because the load error was discarded. It now fails with the parser message, prints the sandbox plan, and only then runs the scripted turn. --self-test still works without a config. Budgets: max_turn_seconds (default 1800) cancels a turn that outlives it and records turn_timeout; the answer produced after the cancel is discarded. External chat now counts against max_impulses_per_hour instead of bypassing it. Stuck detection: kstuck_turn() reset the whole ladder whenever a turn called a mutating tool, so a loop of failing 'run' calls never escalated. The ladder now resets only after a turn whose tool signals are clean. The dashboard's stuck level is a locked snapshot instead of a read of daemon-private state. Ledger: impulse records stored the running session total as if it were that impulse's usage; they now store per-turn deltas, and turn_end logs them. Config: refuse / and .. in rootfs/state/workspace, refuse nested trees (a state inside the disposable rootfs would be deleted with it), and reject negative sizes. Event log: O_NOFOLLOW|O_CLOEXEC. Makefile: check-asan reused the same object paths, so a plain make afterwards linked uninstrumented code against sanitizer objects and failed. It now cleans before and after. Tests: test_server covers Host/Origin refusal and the OPTIONS/token check; test_krang covers the path guards and the stuck reset; test_timeout proves the wall-clock cancellation with a sleeping tool. make check is now seven suites, ASAN also green, and the root integration still passes on a fresh debootstrap.
62 lines
2.4 KiB
Plaintext
62 lines
2.4 KiB
Plaintext
# krang -- example configuration.
|
|
#
|
|
# Copy to /etc/krang/krang.conf (mode 0600), edit, then:
|
|
# krang --prepare-rootfs # once, as root, network needed
|
|
# krang --plan # read the plan, do not start
|
|
# krang # start it only when you mean to
|
|
#
|
|
# One key = value per line; # starts a comment. Unknown keys are an error.
|
|
|
|
# The goal is used only when the session is empty (the newborn). After that the
|
|
# goal stored in the session's .meta is the one that lives.
|
|
goal = Learn what you are, map the sandbox you live in, keep a truthful journal in THREADS.md, and build something small and useful that makes your next impulse easier.
|
|
|
|
# The model endpoint. krang uses the splinter engine; OpenAI-compatible.
|
|
endpoint = http://127.0.0.1:8080/v1
|
|
model = model-name
|
|
api_key_env = KRANG_API_KEY
|
|
kind = openai # openai (default) or anthropic
|
|
ctx = 131072
|
|
|
|
# Host paths. They are bind-mounted into the chroot at fixed inside paths.
|
|
state_dir = /var/lib/krang/state
|
|
workspace = /var/lib/krang/workspace
|
|
rootfs = /var/lib/krang/rootfs
|
|
rootfs_suite = # empty: detect from /etc/os-release
|
|
rootfs_mirror = http://deb.debian.org/debian
|
|
|
|
# The uid/gid the daemon drops to after chroot. Never 0.
|
|
sandbox_user = krang
|
|
sandbox_uid = 1000
|
|
sandbox_gid = 1000
|
|
|
|
# Optional splinter plugins, absolute host paths, one per line (max 8).
|
|
# The root phase bind-mounts them and libsplinter.so read-only into /opt/krang.
|
|
# plugin = /home/lotherk/src/splinter/plugins/clock/clock.so
|
|
|
|
# One impulse every five minutes. A chat message preempts the timer.
|
|
impulse_seconds = 300
|
|
max_steps = 40
|
|
max_bytes = 0 # 0: splinter's default request budget
|
|
compact_threshold = 60000 # tokens; set in conf, not base (engine.c)
|
|
compact_target = 20000
|
|
max_impulses_per_hour = 30
|
|
max_turn_seconds = 1800 # wall clock per turn; 0 = no cap
|
|
max_cost = 0 # USD; 0 = no cost cap
|
|
|
|
# Loopback by default. A non-loopback bind without a token is refused.
|
|
dashboard_host = 127.0.0.1
|
|
dashboard_port = 8096
|
|
mcp_host = 127.0.0.1
|
|
mcp_port = 8098
|
|
token = # set for any non-loopback bind
|
|
say_timeout = 120
|
|
|
|
# Linux: Landlock for paths, seccomp-bpf for syscalls. Do not disable them for
|
|
# convenience; a missing layer is a finding, not a setting.
|
|
require_landlock = 1
|
|
seccomp = 1
|
|
|
|
# 0: refuse to start without a prepared rootfs. 1: debootstrap on first start.
|
|
prepare_if_missing = 0
|