diff options
Diffstat (limited to 'src/integration/assets')
| -rw-r--r-- | src/integration/assets/qwen/herdr-agent-session.ps1 | 37 | ||||
| -rw-r--r-- | src/integration/assets/qwen/herdr-agent-session.sh | 48 |
2 files changed, 85 insertions, 0 deletions
diff --git a/src/integration/assets/qwen/herdr-agent-session.ps1 b/src/integration/assets/qwen/herdr-agent-session.ps1 new file mode 100644 index 00000000..882caf86 --- /dev/null +++ b/src/integration/assets/qwen/herdr-agent-session.ps1 @@ -0,0 +1,37 @@ +# installed by herdr +# managed by herdr; reinstalling or updating the integration overwrites this file. +# add custom hooks beside this file instead of editing it. +# HERDR_INTEGRATION_ID=qwen +# HERDR_INTEGRATION_VERSION=1 + +param([string]$Action = "") + +if ($Action -ne "session") { exit 0 } +if ($env:HERDR_ENV -ne "1") { exit 0 } +if ([string]::IsNullOrWhiteSpace($env:HERDR_PANE_ID)) { exit 0 } +if ([string]::IsNullOrWhiteSpace($env:HERDR_SOCKET_PATH)) { exit 0 } + +$inputText = [Console]::In.ReadToEnd() +try { + $payload = if ([string]::IsNullOrWhiteSpace($inputText)) { $null } else { $inputText | ConvertFrom-Json } +} catch { + $payload = $null +} + +if ($null -eq $payload -or [string]::IsNullOrWhiteSpace($payload.session_id)) { exit 0 } + +$seq = [DateTime]::UtcNow.Ticks +$herdr = if ([string]::IsNullOrWhiteSpace($env:HERDR_BIN_PATH)) { "herdr" } else { $env:HERDR_BIN_PATH } +$commandArgs = @( + "pane", "report-agent-session", $env:HERDR_PANE_ID, + "--source", "herdr:qwen", "--agent", "qwen", + "--agent-session-id", [string]$payload.session_id, + "--seq", [string]$seq +) +if ($payload.source -in @("startup", "resume", "clear", "compact", "branch")) { + $commandArgs += @("--session-start-source", [string]$payload.source) +} +try { + & $herdr @commandArgs 2>$null | Out-Null +} catch { +} diff --git a/src/integration/assets/qwen/herdr-agent-session.sh b/src/integration/assets/qwen/herdr-agent-session.sh new file mode 100644 index 00000000..226c2a97 --- /dev/null +++ b/src/integration/assets/qwen/herdr-agent-session.sh @@ -0,0 +1,48 @@ +#!/bin/sh +# managed by herdr; reinstalling the integration replaces this file. +# HERDR_INTEGRATION_ID=qwen +# HERDR_INTEGRATION_VERSION=1 + +[ "${1:-}" = "session" ] || exit 0 +[ "${HERDR_ENV:-}" = "1" ] || exit 0 +[ -n "${HERDR_PANE_ID:-}" ] || exit 0 +[ -n "${HERDR_SOCKET_PATH:-}" ] || exit 0 +if [ -n "${HERDR_BIN_PATH:-}" ]; then + [ -x "$HERDR_BIN_PATH" ] || exit 0 +else + command -v herdr >/dev/null 2>&1 || exit 0 +fi +command -v python3 >/dev/null 2>&1 || exit 0 + +python3 -c ' +import json +import os +import subprocess +import sys +import time + +try: + payload = json.load(sys.stdin) + session_id = payload.get("session_id") + source = payload.get("source") + if not isinstance(session_id, str) or not session_id: + raise ValueError + command = os.environ.get("HERDR_BIN_PATH") or "herdr" + args = [ + command, "pane", "report-agent-session", os.environ["HERDR_PANE_ID"], + "--source", "herdr:qwen", "--agent", "qwen", + "--agent-session-id", session_id, "--seq", str(time.time_ns()), + ] + if source in ("startup", "resume", "clear", "compact", "branch"): + args.extend(["--session-start-source", source]) + subprocess.run( + args, + stdin=subprocess.DEVNULL, + stdout=subprocess.DEVNULL, + stderr=subprocess.DEVNULL, + timeout=1, + check=False, + ) +except Exception: + pass +' 2>/dev/null || true |
