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