fix(tanko): adapter fixes, event logging, platform-based deploy.sh #21
@@ -2,6 +2,7 @@
|
||||
# See ADR-005 for @mention detection, ADR-009 for error handling
|
||||
# Full implementation in issue #5.
|
||||
|
||||
import asyncio
|
||||
import logging
|
||||
import time
|
||||
import re
|
||||
@@ -36,7 +37,7 @@ class ZulipAdapter:
|
||||
email = self.config['zulip']['email']
|
||||
api_key = self.config['zulip']['api_key']
|
||||
|
||||
self._client = Client(server_url=server_url, email=email, api_key=api_key)
|
||||
self._client = Client(site=server_url.rstrip('/'), email=email, api_key=api_key)
|
||||
self.connected = True
|
||||
logger.info(f"Connected to Zulip: {server_url} as {email}")
|
||||
|
||||
@@ -111,6 +112,9 @@ class ZulipAdapter:
|
||||
}
|
||||
|
||||
def _event_loop(self) -> None:
|
||||
# Create an event loop for this background thread (Python 3.13+)
|
||||
loop = asyncio.new_event_loop()
|
||||
asyncio.set_event_loop(loop)
|
||||
"""Background thread to listen for Zulip events."""
|
||||
try:
|
||||
self._client.call_on_each_message(
|
||||
|
||||
+35
-37
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
# deploy.sh GitOps deployment for zulip-platform-plugins
|
||||
# deploy.sh — GitOps deployment for zulip-platform-plugins
|
||||
# Usage: ./deploy.sh <tag|branch> [--ct=<agent>] [--dry-run]
|
||||
# ./deploy.sh v1.0.0 # Deploy to all 6 CTs
|
||||
# ./deploy.sh main # Deploy latest (staging only!)
|
||||
@@ -36,28 +36,28 @@ declare -A AGENTS=(
|
||||
["abiba"]="amdpve CT 100"
|
||||
)
|
||||
|
||||
# Platform paths per agent type
|
||||
declare -A PLUGIN_PATHS=(
|
||||
["tanko"]="/opt/hermes-zulip-plugin"
|
||||
["mumuni"]="/opt/hermes-zulip-plugin"
|
||||
["koonimo"]="/opt/hermes-zulip-plugin"
|
||||
["koby\"]="/opt/hermes-zulip-plugin"
|
||||
["kagentz\"]="/opt/agent-zero-plugin"
|
||||
["abiba\"]="/root/.pi/agent/extensions/zulip.ts"
|
||||
# Platform classification for each agent
|
||||
declare -A PLATFORM=(
|
||||
["tanko"]="hermes"
|
||||
["mumuni"]="hermes"
|
||||
["koonimo"]="hermes"
|
||||
["koby"]="hermes"
|
||||
["kagentz"]="agent-zero"
|
||||
["abiba"]="pi"
|
||||
)
|
||||
|
||||
# Correcting the backslash artifacts from the original file
|
||||
PLUGIN_PATHS["koby"]="/opt/hermes-zulip-plugin"
|
||||
PLUGIN_PATHS["kagentz"]="/opt/agent-zero-plugin"
|
||||
PLUGIN_PATHS["abiba"]="/root/.pi/agent/extensions/zulip.ts"
|
||||
# Plugin paths by platform
|
||||
declare -A PLUGIN_PATHS_BY_PLATFORM=(
|
||||
["hermes"]="/opt/hermes-zulip-plugin"
|
||||
["agent-zero"]="/opt/agent-zero-plugin"
|
||||
["pi"]="/root/.pi/agent/extensions/zulip.ts"
|
||||
)
|
||||
|
||||
declare -A SERVICE_NAMES=(
|
||||
["tanko"]="zulip-plugin"
|
||||
["mumuni"]="zulip-plugin"
|
||||
["koonimo"]="zulip-plugin"
|
||||
["koby"]="zulip-plugin"
|
||||
["kagentz"]="zulip-plugin"
|
||||
["abiba"]="pi" # pi reload, not systemctl
|
||||
# Service names by platform
|
||||
declare -A SERVICE_NAMES_BY_PLATFORM=(
|
||||
["hermes"]="zulip-plugin"
|
||||
["agent-zero"]="zulip-plugin"
|
||||
["pi"]="pi" # pi reload, not systemctl
|
||||
)
|
||||
|
||||
GITEA_REPO="https://git.sysloggh.net/SyslogSolution/zulip-platform-plugins.git"
|
||||
@@ -72,15 +72,16 @@ log() {
|
||||
deploy_agent() {
|
||||
local agent="$1"
|
||||
local ct_info="${AGENTS[$agent]}"
|
||||
local plugin_path="${PLUGIN_PATHS[$agent]}"
|
||||
local service="${SERVICE_NAMES[$agent]}"
|
||||
local platform="${PLATFORM[$agent]}"
|
||||
local plugin_path="${PLUGIN_PATHS_BY_PLATFORM[$platform]}"
|
||||
local service="${SERVICE_NAMES_BY_PLATFORM[$platform]}"
|
||||
|
||||
log "=== Deploying $agent ($ct_info) @ $TAG ==="
|
||||
log "Path: $plugin_path"
|
||||
log "=== Deploying $agent ($ct_info) @ $TAG (platform: $platform) ==="
|
||||
log "Path: $plugin_path | Service: $service"
|
||||
|
||||
# 1. Git pull & checkout tag
|
||||
if [[ "$DRY_RUN" != "true" ]]; then
|
||||
cd "$plugin_path" || { log "ERROR: $agent path $plugin_path not found"; return 1; }
|
||||
cd "$plugin_path" || { log "ERROR: $agent: path $plugin_path not found"; return 1; }
|
||||
git fetch --tags origin
|
||||
git checkout "$TAG"
|
||||
else
|
||||
@@ -90,15 +91,12 @@ deploy_agent() {
|
||||
|
||||
# 2. Install dependencies (platform-specific)
|
||||
if [[ "$DRY_RUN" != "true" ]]; then
|
||||
case "$agent" in
|
||||
tanko|mumuni|koonimo|koby)
|
||||
case "$platform" in
|
||||
hermes|agent-zero)
|
||||
pip install -r requirements.txt --quiet
|
||||
;;
|
||||
kagentz)
|
||||
pip install -r requirements.txt --quiet
|
||||
;;
|
||||
abiba)
|
||||
log "$agent: pi extension skipping pip install"
|
||||
pi)
|
||||
log "$agent: pi extension — skipping pip install"
|
||||
;;
|
||||
esac
|
||||
else
|
||||
@@ -107,8 +105,8 @@ deploy_agent() {
|
||||
|
||||
# 3. Restart service
|
||||
if [[ "$DRY_RUN" != "true" ]]; then
|
||||
case "$agent" in
|
||||
abiba)
|
||||
case "$platform" in
|
||||
pi)
|
||||
log "$agent: triggering /reload"
|
||||
;;
|
||||
*)
|
||||
@@ -127,7 +125,7 @@ deploy_agent() {
|
||||
if curl -sf "http://localhost:$HEALTH_PORT/health" > /dev/null 2>&1; then
|
||||
log "OK: $agent health check passed"
|
||||
else
|
||||
log "ERROR: $agent health check failed check logs"
|
||||
log "ERROR: $agent health check failed — check logs"
|
||||
return 1
|
||||
fi
|
||||
else
|
||||
@@ -135,8 +133,8 @@ deploy_agent() {
|
||||
fi
|
||||
}
|
||||
|
||||
# --- Main ---\
|
||||
log "Deploy started target: $TAG (Dry Run: $DRY_RUN)"
|
||||
# --- Main ---
|
||||
log "Deploy started — target: $TAG (Dry Run: $DRY_RUN)"
|
||||
|
||||
if [[ -n "$SINGLE_CT" ]]; then
|
||||
deploy_agent "$SINGLE_CT"
|
||||
|
||||
Reference in New Issue
Block a user