refactor(skills): cleanup dead code + full workflow A→B→C→D integration
Cleanup: - Remove unused validate_yaml() helper from lib.sh - Remove USER_MANUAL.html + mqtt-broker-setup.html (no refs found) Workflow A (create_session ↔ delegate-job): - Add --submit-job <prompt> option to create_session.sh - Auto-register session in delegate-job registry, store delegate_job_id in YAML Workflow B (push-based monitor): - Migrate reconcile.sh to MQTT subscriber mode (polling fallback preserved) Workflow C (unified status): - status.sh now shows session + delegate-job state in single column Workflow D (audit log + perms): - JSON job files chmod 600 - create/delete/resume now publish lifecycle events to delegate-job
This commit is contained in:
+36
-41
@@ -7,7 +7,6 @@
|
||||
# - atomic_dump_yaml : flock + temp+rename + .bak + validate (P0-B)
|
||||
# - env_python : env-safe Python (no heredoc injection) (P0-B / P1-B)
|
||||
# - find_workspace_uuid : workspace-SCOPED resume id lookup (P0-C)
|
||||
# - validate_yaml : schema check (P1-G)
|
||||
#
|
||||
# Source it from each script with a path computed from the script location:
|
||||
# source "$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)/lib.sh"
|
||||
@@ -256,46 +255,6 @@ finally:
|
||||
PYEOF
|
||||
}
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# validate_yaml [yaml_path]
|
||||
#
|
||||
# Schema check (P1-G). Exits non-zero with an actionable message on failure.
|
||||
# Safe to call as a preflight in any mutator.
|
||||
# ---------------------------------------------------------------------------
|
||||
validate_yaml() {
|
||||
local yaml_path="${1:-$AGENT_SESSIONS_YAML}"
|
||||
YAML_PATH="$yaml_path" python3 - <<'PYEOF'
|
||||
import os, sys
|
||||
import yaml
|
||||
path = os.environ['YAML_PATH']
|
||||
try:
|
||||
with open(path) as f:
|
||||
d = yaml.safe_load(f)
|
||||
except FileNotFoundError:
|
||||
print(f"VALIDATE: file not found: {path}", file=sys.stderr); sys.exit(1)
|
||||
except yaml.YAMLError as e:
|
||||
print(f"VALIDATE: YAML parse error: {e}", file=sys.stderr); sys.exit(1)
|
||||
d = d or {}
|
||||
if not isinstance(d, dict):
|
||||
print("VALIDATE: top-level is not a mapping", file=sys.stderr); sys.exit(1)
|
||||
sessions = d.get('tmux_sessions', [])
|
||||
if not isinstance(sessions, list):
|
||||
print("VALIDATE: tmux_sessions is not a list", file=sys.stderr); sys.exit(1)
|
||||
valid = {'running', 'terminated', 'archived'}
|
||||
for i, s in enumerate(sessions):
|
||||
if not isinstance(s, dict):
|
||||
print(f"VALIDATE: tmux_sessions[{i}] not a mapping", file=sys.stderr); sys.exit(1)
|
||||
for k in ('name', 'status'):
|
||||
if not s.get(k):
|
||||
print(f"VALIDATE: tmux_sessions[{i}] missing '{k}'", file=sys.stderr); sys.exit(1)
|
||||
if s['status'] not in valid:
|
||||
print(f"VALIDATE: tmux_sessions[{i}] {s.get('name')!r} bad status {s['status']!r}",
|
||||
file=sys.stderr); sys.exit(1)
|
||||
if not isinstance(s.get('pane'), dict):
|
||||
print(f"VALIDATE: tmux_sessions[{i}] {s.get('name')!r} missing pane", file=sys.stderr); sys.exit(1)
|
||||
print(f"VALIDATE OK: {len(sessions)} session(s)")
|
||||
PYEOF
|
||||
}
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# find_workspace_uuid <workspace> <agent>
|
||||
@@ -401,3 +360,39 @@ if ai.get('project_cwd') == ws:
|
||||
print('')
|
||||
PYEOF
|
||||
}
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# delegate_submit_job <prompt> <agent> <agent_session>
|
||||
#
|
||||
# Register a job in the delegate-job registry. Auto-detects the virtualenv python
|
||||
# and prints the new JID on stdout.
|
||||
# ---------------------------------------------------------------------------
|
||||
delegate_submit_job() {
|
||||
local prompt="$1" agent="$2" session="$3"
|
||||
local skill_dir
|
||||
skill_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
|
||||
local py_bin="python3"
|
||||
local d="$skill_dir"
|
||||
while [ "$d" != "/" ] && [ -n "$d" ]; do
|
||||
if [ -x "$d/.venv/bin/python" ]; then
|
||||
py_bin="$d/.venv/bin/python"
|
||||
break
|
||||
fi
|
||||
d="$(dirname "$d")"
|
||||
done
|
||||
|
||||
local registry_py="$skill_dir/delegate-job/scripts/registry.py"
|
||||
if [ ! -f "$registry_py" ]; then
|
||||
registry_py="$(find "$skill_dir" -name "registry.py" | head -n 1 || echo "")"
|
||||
fi
|
||||
if [ -z "$registry_py" ] || [ ! -f "$registry_py" ]; then
|
||||
registry_py="/home/godopu16/PuKi/laa/canary_projects/advanced_multi_agent/skills/delegate-job/scripts/registry.py"
|
||||
fi
|
||||
|
||||
"$py_bin" "$registry_py" register \
|
||||
--prompt "$prompt" \
|
||||
--agent "$agent" \
|
||||
--agent-session "$session"
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user