fix: stabilization pass — fail-closed auth, ai flag validation, lint/config/security hardening, regression tests
gates / consistency-and-conventions (push) Successful in 26s
gates / consistency-and-conventions (push) Successful in 26s
17-point code-level audit executed via Explorer->Architect->Builder->Tester->Reviewer;
Reviewer accepted (APPROVE_WITH_NOTES; 3 block-list items resolved):
- security: telegram sender-owner AND-gate + TELEGRAM_OWNER_ID, matrix
MATRIX_ROOM_ID fail-closed, gpg --passphrase-fd 3 (no argv secret),
/dev/tcp positional-arg form (checkport/smb-client/share-lib/NET_PROBE),
eval deny-by-default + --no-command-execution carried by both chat bridges,
tty-gated --trust; config/{telegram,matrix}.env reference templates
- ai: all ExecStart flags validated against installed llama.cpp
(requested->error, default->omit+warn, CONFIG_REQUESTED_FLAGS); single-file
hf download failure rc=1 + no .hf-meta; LLAMACPP_HOST coherent;
POS_SUBCMDS + metadata gaps closed
- tooling: lint-conventions Bash-native rewrite (~24-30x faster, rules and
output byte-identical, :num restored); pos system uninstall covers all 12
libs + scale-tail + flags dir + systemd user units (|| true) + plugin
markers; anchored .bash_completion/.bashrc removal replaces sed -i '/pos/d'
- config: canonical load_env_file in lib/config-ui.sh (CRLF strip, env-wins,
XDG, LOADED_ENV_KEYS); 9 tools migrated; entertainment-lib collapsed to
wrappers; docker-compose deliberately unmigrated (source semantics)
- tests: first committed regression suite — tests/run-tests.sh zero-dep
runner + make test; 12 files / 179 checks / 0 skip / ~52s; hard skip
contract; systemd-analyze verify on generated unit PASS
Verified: make gen idempotent; make check green; make lint 0 FAIL, 0 WARN;
make test green; bash -n clean; git diff --check clean. Audit deliverables +
agent reports + AGENT_TODO Done entry included.
This commit is contained in:
@@ -9,15 +9,18 @@
|
||||
provider_name() { printf 'Local llama.cpp'; }
|
||||
|
||||
provider_default_model() {
|
||||
local port="${LLAMACPP_PORT:-8088}"
|
||||
# Honor LLAMACPP_HOST — must match the address the server binds (default
|
||||
# 127.0.0.1); otherwise the adapter talks to a different host than the one
|
||||
# the server actually listens on.
|
||||
local host="${LLAMACPP_HOST:-127.0.0.1}" port="${LLAMACPP_PORT:-8088}"
|
||||
local model
|
||||
model="$(curl -sf "http://127.0.0.1:$port/v1/models" 2>/dev/null | jq -r '.data[0].id // empty')"
|
||||
model="$(curl -sf "http://$host:$port/v1/models" 2>/dev/null | jq -r '.data[0].id // empty')"
|
||||
[ -n "$model" ] && printf '%s' "$model" || printf '(no model loaded)'
|
||||
}
|
||||
|
||||
# $1=model $2=messages JSON ({"messages":[{role,content}]}) $3=optional system prompt
|
||||
provider_generate() {
|
||||
local model="$1" messages="$2" system="${3:-}" port="${LLAMACPP_PORT:-8088}"
|
||||
local model="$1" messages="$2" system="${3:-}" host="${LLAMACPP_HOST:-127.0.0.1}" port="${LLAMACPP_PORT:-8088}"
|
||||
local body resp code body_out
|
||||
# Build messages array with optional system prompt
|
||||
if [ -n "$system" ]; then
|
||||
@@ -28,7 +31,7 @@ provider_generate() {
|
||||
fi
|
||||
body="$(printf '%s' "$body" | jq -nc --arg m "$model" --argjson msgs "$body" \
|
||||
'{model:$m, messages:$msgs, stream:false}')"
|
||||
resp="$(curl -sS -m 120 -X POST "http://127.0.0.1:$port/v1/chat/completions" \
|
||||
resp="$(curl -sS -m 120 -X POST "http://$host:$port/v1/chat/completions" \
|
||||
-H "Content-Type: application/json" \
|
||||
--write-out $'\n%{http_code}' \
|
||||
--data "$body")" || { echo "request failed (curl exit $?)" >&2; return 1; }
|
||||
@@ -43,8 +46,8 @@ provider_generate() {
|
||||
|
||||
# $1=current default model → stdout=formatted model list
|
||||
provider_models_list() {
|
||||
local model="$1" port="${LLAMACPP_PORT:-8088}" resp code body
|
||||
resp="$(curl -sf "http://127.0.0.1:$port/v1/models" \
|
||||
local model="$1" host="${LLAMACPP_HOST:-127.0.0.1}" port="${LLAMACPP_PORT:-8088}" resp code body
|
||||
resp="$(curl -sf "http://$host:$port/v1/models" \
|
||||
--write-out $'\n%{http_code}')" || { echo "server not running" >&2; return 1; }
|
||||
code="${resp##*$'\n'}"
|
||||
body="${resp%$'\n'*}"
|
||||
|
||||
Reference in New Issue
Block a user