aboutsummaryrefslogtreecommitdiff
path: root/src/integration/assets
diff options
context:
space:
mode:
authorOgulcan Celik <ogulcancelik@gmail.com>2026-06-07 19:45:16 +0300
committerOgulcan Celik <ogulcancelik@gmail.com>2026-06-07 19:45:16 +0300
commitc01b947d0bde1663980a15727938ac666ce31f61 (patch)
tree009ad30854d0112f75a0a5ae964b9a6c72ff41ee /src/integration/assets
parent9c101b71d83941ee59d2b68f32f624afd7e2d78e (diff)
fix: support windows agent hooks and input paths
Diffstat (limited to 'src/integration/assets')
-rw-r--r--src/integration/assets/claude/herdr-agent-state.ps129
-rw-r--r--src/integration/assets/codex/herdr-agent-state.ps127
-rw-r--r--src/integration/assets/copilot/herdr-agent-state.ps1104
-rw-r--r--src/integration/assets/droid/herdr-agent-state.ps126
-rw-r--r--src/integration/assets/kimi/herdr-agent-state.ps122
-rw-r--r--src/integration/assets/qodercli/herdr-agent-state.ps135
6 files changed, 243 insertions, 0 deletions
diff --git a/src/integration/assets/claude/herdr-agent-state.ps1 b/src/integration/assets/claude/herdr-agent-state.ps1
new file mode 100644
index 00000000..71417e9c
--- /dev/null
+++ b/src/integration/assets/claude/herdr-agent-state.ps1
@@ -0,0 +1,29 @@
+# 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=claude
+# HERDR_INTEGRATION_VERSION=5
+
+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 }
+
+$inputText = [Console]::In.ReadToEnd()
+try {
+ $payload = if ([string]::IsNullOrWhiteSpace($inputText)) { $null } else { $inputText | ConvertFrom-Json }
+} catch {
+ exit 0
+}
+
+if ($payload.hook_event_name -eq "SubagentStop") { exit 0 }
+
+$sessionId = $payload.session_id
+if ([string]::IsNullOrWhiteSpace($sessionId)) { exit 0 }
+
+$seq = [DateTimeOffset]::UtcNow.ToUnixTimeMilliseconds()
+try {
+ & herdr pane report-agent-session $env:HERDR_PANE_ID --source herdr:claude --agent claude --seq $seq --agent-session-id $sessionId 2>$null | Out-Null
+} catch {
+}
diff --git a/src/integration/assets/codex/herdr-agent-state.ps1 b/src/integration/assets/codex/herdr-agent-state.ps1
new file mode 100644
index 00000000..e56948f5
--- /dev/null
+++ b/src/integration/assets/codex/herdr-agent-state.ps1
@@ -0,0 +1,27 @@
+# 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=codex
+# HERDR_INTEGRATION_VERSION=5
+
+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 }
+
+$inputText = [Console]::In.ReadToEnd()
+try {
+ $payload = if ([string]::IsNullOrWhiteSpace($inputText)) { $null } else { $inputText | ConvertFrom-Json }
+} catch {
+ exit 0
+}
+
+$sessionId = $payload.session_id
+if ([string]::IsNullOrWhiteSpace($sessionId)) { exit 0 }
+
+$seq = [DateTimeOffset]::UtcNow.ToUnixTimeMilliseconds()
+try {
+ & herdr pane report-agent-session $env:HERDR_PANE_ID --source herdr:codex --agent codex --seq $seq --agent-session-id $sessionId 2>$null | Out-Null
+} catch {
+}
diff --git a/src/integration/assets/copilot/herdr-agent-state.ps1 b/src/integration/assets/copilot/herdr-agent-state.ps1
new file mode 100644
index 00000000..61cec0c9
--- /dev/null
+++ b/src/integration/assets/copilot/herdr-agent-state.ps1
@@ -0,0 +1,104 @@
+# 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=copilot
+# HERDR_INTEGRATION_VERSION=1
+
+if ($env:HERDR_ENV -ne "1") { exit 0 }
+if ([string]::IsNullOrWhiteSpace($env:HERDR_PANE_ID)) { exit 0 }
+
+$inputText = [Console]::In.ReadToEnd()
+try {
+ $payload = if ([string]::IsNullOrWhiteSpace($inputText)) { @{} } else { $inputText | ConvertFrom-Json }
+} catch {
+ $payload = @{}
+}
+
+function First-Text {
+ param([object[]]$Names)
+ foreach ($name in $Names) {
+ $value = $payload.$name
+ if ($value -is [string] -and -not [string]::IsNullOrWhiteSpace($value)) {
+ return $value
+ }
+ }
+ return $null
+}
+
+function Normalize-Event {
+ param([string]$Event)
+ if ([string]::IsNullOrWhiteSpace($Event)) { return "" }
+ return $Event.Replace("_", "").Replace("-", "").ToLowerInvariant()
+}
+
+function Infer-Event {
+ $explicit = First-Text @("hook_event_name", "hookEventName")
+ if ($explicit) { return $explicit }
+ if (First-Text @("notification_type", "notificationType")) { return "notification" }
+ if ($payload.PSObject.Properties.Name -contains "toolResult" -or $payload.PSObject.Properties.Name -contains "tool_result") { return "postToolUse" }
+ if (($payload.PSObject.Properties.Name -contains "error") -and (First-Text @("tool_name", "toolName"))) { return "postToolUseFailure" }
+ if (First-Text @("tool_name", "toolName")) { return "preToolUse" }
+ if (First-Text @("stop_reason", "stopReason")) { return "agentStop" }
+ if (First-Text @("reason")) { return "sessionEnd" }
+ if ($payload.PSObject.Properties.Name -contains "prompt") { return "userPromptSubmitted" }
+ if (
+ $payload.PSObject.Properties.Name -contains "initial_prompt" -or
+ $payload.PSObject.Properties.Name -contains "initialPrompt" -or
+ $payload.PSObject.Properties.Name -contains "source" -or
+ (First-Text @("session_id", "sessionId"))
+ ) { return "sessionStart" }
+ return ""
+}
+
+function Has-Initial-Prompt {
+ $value = $payload.initial_prompt
+ if ($null -eq $value) { $value = $payload.initialPrompt }
+ return ($value -is [string] -and -not [string]::IsNullOrWhiteSpace($value))
+}
+
+function Report-State {
+ param([string]$State, [string]$SessionId)
+ $seq = [DateTimeOffset]::UtcNow.ToUnixTimeMilliseconds()
+ $args = @("pane", "report-agent", $env:HERDR_PANE_ID, "--source", "herdr:copilot", "--agent", "copilot", "--state", $State, "--seq", "$seq")
+ if (-not [string]::IsNullOrWhiteSpace($SessionId)) {
+ $args += @("--agent-session-id", $SessionId)
+ }
+ & herdr @args 2>$null | Out-Null
+}
+
+function Release-Agent {
+ $seq = [DateTimeOffset]::UtcNow.ToUnixTimeMilliseconds()
+ & herdr pane release-agent $env:HERDR_PANE_ID --source herdr:copilot --agent copilot --seq $seq 2>$null | Out-Null
+}
+
+try {
+ $eventKey = Normalize-Event (Infer-Event)
+ $sessionId = First-Text @("session_id", "sessionId")
+ $toolName = First-Text @("tool_name", "toolName")
+ $notificationType = First-Text @("notification_type", "notificationType")
+ $stopReason = First-Text @("stop_reason", "stopReason")
+ $reason = First-Text @("reason")
+
+ if ($eventKey -eq "sessionstart") {
+ Report-State ($(if (Has-Initial-Prompt) { "working" } else { "idle" })) $sessionId
+ } elseif ($eventKey -in @("userpromptsubmit", "userpromptsubmitted")) {
+ Report-State "working" $sessionId
+ } elseif ($eventKey -eq "pretooluse") {
+ Report-State ($(if ($toolName -in @("ask_user", "exit_plan_mode")) { "blocked" } else { "working" })) $sessionId
+ } elseif ($eventKey -in @("posttooluse", "posttoolusefailure")) {
+ if ($toolName -ne "report_intent") { Report-State "working" $sessionId }
+ } elseif ($eventKey -eq "notification") {
+ if ($notificationType -in @("permission_prompt", "elicitation_dialog")) {
+ Report-State "blocked" $sessionId
+ } elseif ($notificationType -eq "agent_idle") {
+ Report-State "idle" $sessionId
+ }
+ } elseif ($eventKey -in @("stop", "agentstop", "sessionstop")) {
+ if ([string]::IsNullOrWhiteSpace($stopReason) -or $stopReason -eq "end_turn") {
+ Report-State "idle" $sessionId
+ }
+ } elseif ($eventKey -eq "sessionend") {
+ if ($reason -in @("user_exit", "abort")) { Release-Agent }
+ }
+} catch {
+}
diff --git a/src/integration/assets/droid/herdr-agent-state.ps1 b/src/integration/assets/droid/herdr-agent-state.ps1
new file mode 100644
index 00000000..ad035d72
--- /dev/null
+++ b/src/integration/assets/droid/herdr-agent-state.ps1
@@ -0,0 +1,26 @@
+# 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=droid
+# HERDR_INTEGRATION_VERSION=1
+
+if ($env:HERDR_ENV -ne "1") { exit 0 }
+if ([string]::IsNullOrWhiteSpace($env:HERDR_PANE_ID)) { exit 0 }
+
+$inputText = [Console]::In.ReadToEnd()
+try {
+ $payload = if ([string]::IsNullOrWhiteSpace($inputText)) { $null } else { $inputText | ConvertFrom-Json }
+} catch {
+ exit 0
+}
+
+if ($payload.hook_event_name -ne "SessionStart") { exit 0 }
+
+$sessionId = $payload.session_id
+if ([string]::IsNullOrWhiteSpace($sessionId)) { exit 0 }
+
+$seq = [DateTimeOffset]::UtcNow.ToUnixTimeMilliseconds()
+try {
+ & herdr pane report-agent-session $env:HERDR_PANE_ID --source herdr:droid --agent droid --seq $seq --agent-session-id $sessionId 2>$null | Out-Null
+} catch {
+}
diff --git a/src/integration/assets/kimi/herdr-agent-state.ps1 b/src/integration/assets/kimi/herdr-agent-state.ps1
new file mode 100644
index 00000000..a230a627
--- /dev/null
+++ b/src/integration/assets/kimi/herdr-agent-state.ps1
@@ -0,0 +1,22 @@
+# 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=kimi
+# HERDR_INTEGRATION_VERSION=1
+
+param([string]$Action = "")
+
+if ($Action -notin @("working", "idle", "blocked", "release")) { exit 0 }
+if ($env:HERDR_ENV -ne "1") { exit 0 }
+if ([string]::IsNullOrWhiteSpace($env:HERDR_PANE_ID)) { exit 0 }
+
+[Console]::In.ReadToEnd() | Out-Null
+$seq = [DateTimeOffset]::UtcNow.ToUnixTimeMilliseconds()
+try {
+ if ($Action -eq "release") {
+ & herdr pane release-agent $env:HERDR_PANE_ID --source herdr:kimi --agent kimi --seq $seq 2>$null | Out-Null
+ } else {
+ & herdr pane report-agent $env:HERDR_PANE_ID --source herdr:kimi --agent kimi --state $Action --seq $seq 2>$null | Out-Null
+ }
+} catch {
+}
diff --git a/src/integration/assets/qodercli/herdr-agent-state.ps1 b/src/integration/assets/qodercli/herdr-agent-state.ps1
new file mode 100644
index 00000000..f7102817
--- /dev/null
+++ b/src/integration/assets/qodercli/herdr-agent-state.ps1
@@ -0,0 +1,35 @@
+# 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=qodercli
+# HERDR_INTEGRATION_VERSION=1
+
+param([string]$Action = "")
+
+if ($Action -notin @("working", "idle", "blocked", "release")) { exit 0 }
+if ($env:HERDR_ENV -ne "1") { exit 0 }
+if ([string]::IsNullOrWhiteSpace($env:HERDR_PANE_ID)) { exit 0 }
+
+$inputText = [Console]::In.ReadToEnd()
+try {
+ $payload = if ([string]::IsNullOrWhiteSpace($inputText)) { $null } else { $inputText | ConvertFrom-Json }
+} catch {
+ $payload = $null
+}
+
+if ($payload.hook_event_name -eq "SubagentStop") { exit 0 }
+if ($payload.agent_id -and $Action -in @("idle", "release")) { exit 0 }
+
+$seq = [DateTimeOffset]::UtcNow.ToUnixTimeMilliseconds()
+try {
+ if ($Action -eq "release") {
+ & herdr pane release-agent $env:HERDR_PANE_ID --source herdr:qodercli --agent qodercli --seq $seq 2>$null | Out-Null
+ } else {
+ $args = @("pane", "report-agent", $env:HERDR_PANE_ID, "--source", "herdr:qodercli", "--agent", "qodercli", "--state", $Action, "--seq", "$seq")
+ if (-not [string]::IsNullOrWhiteSpace($payload.session_id)) {
+ $args += @("--agent-session-id", $payload.session_id)
+ }
+ & herdr @args 2>$null | Out-Null
+ }
+} catch {
+}