- adapters/README.md: the harness boundary contract (env in, response on stdout, diagnostics stderr, exit 0 success) - adapters/pi: extracted current invocation unchanged - adapters/mock: deterministic MOSAIC_MOCK_RESPONSE echo (test-only) - run-agent.sh: name-validated dispatch to adapters/<name>/adapter.sh - config: optional execution.adapter (pi|mock), default pi, configVersion stays 1 — existing configs remain valid; selection authority is the config file (load_config exports it) - compose: MOSAIC_ADAPTER / MOSAIC_MOCK_RESPONSE passthrough; Containerfile installs adapters read-only; RELEASE -> 0.0.5 Verified: hello unchanged; mock verbatim via config; unknown adapter and path-traversal names refused in-container; invalid adapter exits 2. Closes #16
54 lines
2.1 KiB
Bash
Executable File
54 lines
2.1 KiB
Bash
Executable File
# Shared helpers for the Mosaic host scripts. Not a documented entry point.
|
|
|
|
POC_ROOT_MARKER=".mosaic-poc-root"
|
|
|
|
# Load and validate the Mosaic configuration (config.json), exporting
|
|
# MOSAIC_DATA_ROOT, MOSAIC_PROVIDER, and MOSAIC_MODEL.
|
|
#
|
|
# Fails closed: a missing or invalid configuration aborts the calling
|
|
# script before any container or filesystem mutation. Run paths never
|
|
# auto-bootstrap; use scripts/bootstrap.sh explicitly.
|
|
load_config() {
|
|
local config_env
|
|
if ! config_env="$(node scripts/mosaic-config.mjs env)"; then
|
|
echo "common: configuration load failed" >&2
|
|
exit 1
|
|
fi
|
|
eval "$config_env"
|
|
export MOSAIC_DATA_ROOT MOSAIC_PROVIDER MOSAIC_MODEL MOSAIC_ADAPTER
|
|
MOSAIC_DEV_DIR="$MOSAIC_DATA_ROOT"
|
|
}
|
|
|
|
# Resolve the release identity: RELEASE is the single source of the
|
|
# release version (stays 0.0.X until declared stable); the image tag
|
|
# derives from it plus the pinned pi dependency version.
|
|
load_release() {
|
|
local release pi_version
|
|
release="$(tr -d '[:space:]' < RELEASE)"
|
|
if ! printf '%s' "$release" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+$'; then
|
|
echo "common: RELEASE must be a semver-ish version, got: '$release'" >&2
|
|
exit 1
|
|
fi
|
|
pi_version="$(node -p "require('./package.json').dependencies['@earendil-works/pi-coding-agent']")"
|
|
export MOSAIC_RELEASE="$release"
|
|
export MOSAIC_IMAGE_TAG="mosaic-poc-agent:${pi_version}-r${release}"
|
|
}
|
|
|
|
# Ensure the configured runtime data directory exists and carries this
|
|
# project's ownership marker. The marker is what scripts/reset.sh requires
|
|
# before it will delete anything.
|
|
bootstrap_runtime_dir() {
|
|
if [ -d "$MOSAIC_DEV_DIR" ]; then
|
|
if [ ! -w "$MOSAIC_DEV_DIR" ] || [ ! -x "$MOSAIC_DEV_DIR" ]; then
|
|
echo "bootstrap: $MOSAIC_DEV_DIR exists but is not writable by $(id -un)" >&2
|
|
echo "bootstrap: a root-owned directory here is usually leftover from a" >&2
|
|
echo "bootstrap: Docker-created mount source; remove it and rerun." >&2
|
|
exit 1
|
|
fi
|
|
else
|
|
mkdir -p "$MOSAIC_DEV_DIR"
|
|
echo "bootstrap: created $MOSAIC_DEV_DIR"
|
|
fi
|
|
touch "$MOSAIC_DEV_DIR/$POC_ROOT_MARKER"
|
|
}
|