- scripts/agent.sh <name>: launches interactive pi TUI in the container with contracts + optional mission + agent identity + named session + optional workspace/tools; the Mosaic alternative to vanilla pi - pi adapter: MOSAIC_INTERACTIVE branch (clean TUI, no -p, no initial prompt); headless exec rebuilt via positional args (no word-splitting on the request); MOSAIC_AGENT_NAME optional in headless - loader: AGENT IDENTITY section when the launcher names the agent - compose: fixed command removed (request defaults live in run-agent.sh); MOSAIC_INTERACTIVE/MOSAIC_AGENT_NAME passthrough - docs/TOOLS.md: full on-demand tool reference; AGENTS.md routes to it - RELEASE -> 0.0.8 (container change); build verified Closes #35
42 lines
1.3 KiB
Bash
Executable File
42 lines
1.3 KiB
Bash
Executable File
#!/bin/sh
|
|
# Agent dispatcher inside the container.
|
|
#
|
|
# Headless (default): loads the contract-generated system prompt, then
|
|
# dispatches one request to /opt/mosaic/adapters/<MOSAIC_ADAPTER>/adapter.sh
|
|
# (contract: /opt/mosaic/adapters/README.md).
|
|
#
|
|
# Interactive (MOSAIC_INTERACTIVE=1, from scripts/agent.sh): same prompt,
|
|
# but the adapter opens the full pi TUI with no initial prompt - the human
|
|
# drives from there.
|
|
set -eu
|
|
|
|
REQUEST=""
|
|
if [ "${MOSAIC_INTERACTIVE:-}" != "1" ]; then
|
|
# Headless: args are the request; default is the startup verification
|
|
# request used by hello/verify.
|
|
REQUEST="${*:-Return your startup marker and nothing else.}"
|
|
export MOSAIC_REQUEST="$REQUEST"
|
|
fi
|
|
|
|
ADAPTER="${MOSAIC_ADAPTER:-pi}"
|
|
case "$ADAPTER" in
|
|
# Allowlist mirrors scripts/mosaic-config.mjs; pattern check first so a
|
|
# crafted name cannot escape the adapters directory.
|
|
*[!A-Za-z0-9._-]*|'')
|
|
echo "run-agent: invalid adapter name: '$ADAPTER'" >&2
|
|
exit 2
|
|
;;
|
|
esac
|
|
|
|
ADAPTER_SCRIPT="/opt/mosaic/adapters/$ADAPTER/adapter.sh"
|
|
if [ ! -x "$ADAPTER_SCRIPT" ]; then
|
|
echo "run-agent: unknown or non-executable adapter: $ADAPTER" >&2
|
|
exit 2
|
|
fi
|
|
|
|
/opt/mosaic/src/load-contracts.sh /opt/mosaic/contracts /var/lib/mosaic/system-prompt.md
|
|
|
|
export MOSAIC_SYSTEM_PROMPT_FILE="/var/lib/mosaic/system-prompt.md"
|
|
|
|
exec "$ADAPTER_SCRIPT"
|