@blunking/codexlink 0.1.2 → 0.1.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,189 +1,299 @@
1
1
  param(
2
- [string]$Profile = "default"
2
+ [string]$Profile = "default"
3
+ )
4
+
5
+ $ErrorActionPreference = "Stop"
6
+
7
+ function Try-ReadJson {
8
+ param([string]$Path)
9
+ if (-not (Test-Path $Path)) { return $null }
10
+ try { return Get-Content -Raw -Path $Path | ConvertFrom-Json } catch { return $null }
11
+ }
12
+
13
+ function Read-DotEnvFile {
14
+ param([string]$Path)
15
+ $values = @{}
16
+ if (-not (Test-Path $Path)) { return $values }
17
+ foreach ($line in (Get-Content -Path $Path)) {
18
+ if (-not $line) { continue }
19
+ if ($line.Trim().StartsWith("#")) { continue }
20
+ $parts = $line -split "=", 2
21
+ if ($parts.Count -ne 2) { continue }
22
+ $values[$parts[0].Trim()] = $parts[1]
23
+ }
24
+ return $values
25
+ }
26
+
27
+ function Test-PidAlive {
28
+ param([int]$ProcId)
29
+ if ($ProcId -le 0) { return $false }
30
+ return $null -ne (Get-Process -Id $ProcId -ErrorAction SilentlyContinue)
31
+ }
32
+
33
+ function Normalize-Preview {
34
+ param([string]$Value, [int]$MaxLength = 72)
35
+ $text = [string]$Value
36
+ $text = $text -replace "\s+", " "
37
+ $text = $text.Trim()
38
+ if (-not $text) { return "" }
39
+ if ($text.Length -le $MaxLength) { return $text }
40
+ return ($text.Substring(0, [Math]::Max(0, $MaxLength - 3)).TrimEnd() + "...")
41
+ }
42
+
43
+ function Get-IsoAgeMs {
44
+ param([string]$IsoString)
45
+ if (-not $IsoString) { return [double]::PositiveInfinity }
46
+ try {
47
+ $parsed = [DateTimeOffset]::Parse($IsoString)
48
+ return [Math]::Max(0, ([DateTimeOffset]::UtcNow - $parsed.ToUniversalTime()).TotalMilliseconds)
49
+ } catch {
50
+ return [double]::PositiveInfinity
51
+ }
52
+ }
53
+
54
+ function Resolve-ConfiguredPath {
55
+ param([string]$Value, [string]$RuntimeRoot)
56
+ if (-not $Value) { return "" }
57
+ $expanded = [Environment]::ExpandEnvironmentVariables($Value)
58
+ if ([System.IO.Path]::IsPathRooted($expanded)) { return $expanded }
59
+ return [System.IO.Path]::GetFullPath((Join-Path $RuntimeRoot $expanded))
60
+ }
61
+
62
+ function Get-TelegramPluginRoot {
63
+ param([string]$RuntimeRoot)
64
+
65
+ $candidates = @()
66
+ if ($env:BLUN_CODEX_TELEGRAM_PLUGIN_ROOT) {
67
+ $candidates += $env:BLUN_CODEX_TELEGRAM_PLUGIN_ROOT
68
+ }
69
+ $candidates += (Join-Path $RuntimeRoot "telegram-plugin")
70
+
71
+ foreach ($candidate in $candidates) {
72
+ if (-not $candidate) { continue }
73
+ if ((Test-Path (Join-Path $candidate "app-server-cli.js")) -and (Test-Path (Join-Path $candidate "sidecar-manager.js"))) {
74
+ return $candidate
75
+ }
76
+ }
77
+
78
+ return $null
79
+ }
80
+
81
+ function Get-ProfilePath {
82
+ param(
83
+ [string]$RuntimeRoot,
84
+ [string]$ProfileName
85
+ )
86
+
87
+ $normalized = [string]$ProfileName
88
+ if (-not $normalized) { $normalized = "" }
89
+ $normalized = $normalized.ToLower()
90
+ $candidates = @()
91
+ if ($env:BLUN_CODEX_PROFILE_ROOT) {
92
+ $candidates += (Join-Path $env:BLUN_CODEX_PROFILE_ROOT ($normalized + ".json"))
93
+ }
94
+ $candidates += (Join-Path $env:USERPROFILE (".codex\\profiles\\codexlink\\" + $normalized + ".json"))
95
+ $candidates += (Join-Path $RuntimeRoot ("profiles\\" + $normalized + ".json"))
96
+
97
+ foreach ($candidate in $candidates) {
98
+ if ($candidate -and (Test-Path $candidate)) {
99
+ return $candidate
100
+ }
101
+ }
102
+
103
+ return $candidates[-1]
104
+ }
105
+
106
+ $runtimeRoot = Split-Path -Parent $MyInvocation.MyCommand.Path
107
+ $profilePath = Get-ProfilePath -RuntimeRoot $runtimeRoot -ProfileName $Profile
108
+ $profileJson = Try-ReadJson -Path $profilePath
109
+ $profileAgent = if ($profileJson -and $profileJson.agent_name) { [string]$profileJson.agent_name } else { $Profile.ToLower() }
110
+ $runtimeDir = Join-Path $env:USERPROFILE (".codex\\runtimes\\" + $profileAgent)
111
+ $stateDir = if ($profileJson -and $profileJson.telegram -and $profileJson.telegram.state_dir) {
112
+ Resolve-ConfiguredPath -Value ([string]$profileJson.telegram.state_dir) -RuntimeRoot $runtimeRoot
113
+ } else {
114
+ Join-Path $env:USERPROFILE (".codex\\channels\\telegram-" + $profileAgent)
115
+ }
116
+ $currentRuntime = Try-ReadJson -Path (Join-Path $runtimeDir "current-remote-runtime.json")
117
+ $state = Try-ReadJson -Path (Join-Path $stateDir "state.json")
118
+ $envFile = Read-DotEnvFile -Path (Join-Path $stateDir ".env")
119
+ $loadedThreads = @()
120
+ $ambientQueueTtlMs = if ($envFile["BLUN_TELEGRAM_AMBIENT_QUEUE_TTL_MS"]) { [int]$envFile["BLUN_TELEGRAM_AMBIENT_QUEUE_TTL_MS"] } else { 600000 }
121
+ $queue = @($state.queue)
122
+ $staleAmbientQueued = @($queue | Where-Object {
123
+ $_.status -eq "queued" -and
124
+ [string]$_.relevance -eq "ambient" -and
125
+ (Get-IsoAgeMs -IsoString ([string]$_.ts)) -ge $ambientQueueTtlMs
126
+ })
127
+ $queued = @($queue | Where-Object {
128
+ if ($_.status -ne "queued") { return $false }
129
+ if ([string]$_.relevance -eq "ambient" -and (Get-IsoAgeMs -IsoString ([string]$_.ts)) -ge $ambientQueueTtlMs) { return $false }
130
+ return $true
131
+ })
132
+ $directQueued = @($queued | Where-Object { @("direct", "lane") -contains [string]$_.relevance })
133
+ $ambientQueued = @($queued | Where-Object { [string]$_.relevance -eq "ambient" })
134
+ $escalationQueued = @($queued | Where-Object { [string]$_.relevance -eq "escalation" })
135
+ $submitted = @($queue | Where-Object { $_.status -eq "submitted" })
136
+ $delivered = @($queue | Where-Object { $_.status -eq "delivered" })
137
+ $errors = @($queue | Where-Object { $_.status -eq "error" })
138
+ $pendingReplies = @($state.pendingReplies | Where-Object { -not $_.sentAt -and @("error", "expired", "ignored_bot", "suppressed_ack", "superseded", "sent", "stale_thread") -notcontains $_.status })
139
+ $expiredPendingReplies = @($state.pendingReplies | Where-Object { $_.status -eq "expired" })
140
+ $pollerPid = if (Test-Path (Join-Path $stateDir "poller.pid")) { (Get-Content -Raw (Join-Path $stateDir "poller.pid")).Trim() } else { $null }
141
+ $dispatcherPid = if (Test-Path (Join-Path $stateDir "dispatcher.pid")) { (Get-Content -Raw (Join-Path $stateDir "dispatcher.pid")).Trim() } else { $null }
142
+ $responderPid = if (Test-Path (Join-Path $stateDir "responder.pid")) { (Get-Content -Raw (Join-Path $stateDir "responder.pid")).Trim() } else { $null }
143
+ $stateThreadId = if ($state.currentThreadId) { [string]$state.currentThreadId } else { "" }
144
+ $runtimeThreadId = if ($currentRuntime -and $currentRuntime.thread_id) { [string]$currentRuntime.thread_id } else { "" }
145
+ $telegramPluginRoot = Get-TelegramPluginRoot -RuntimeRoot $runtimeRoot
146
+ $dispatchMode = if ($envFile["BLUN_TELEGRAM_DISPATCH_MODE"]) { [string]$envFile["BLUN_TELEGRAM_DISPATCH_MODE"] } else { "deferred" }
147
+ $idleCooldownMs = if ($envFile["BLUN_TELEGRAM_IDLE_COOLDOWN_MS"]) { [int]$envFile["BLUN_TELEGRAM_IDLE_COOLDOWN_MS"] } else { 15000 }
148
+ $eligibleQueued = if ($dispatchMode -eq "legacy") {
149
+ @($queued)
150
+ } else {
151
+ @($queued | Where-Object {
152
+ [string]$_.chatType -eq "private" -or @("direct", "lane", "escalation") -contains [string]$_.relevance
153
+ })
154
+ }
155
+ $nextQueued = @(
156
+ $eligibleQueued |
157
+ Sort-Object `
158
+ @{ Expression = {
159
+ if ([string]$_.relevance -eq "escalation") { 0 }
160
+ elseif ([string]$_.chatType -eq "private" -or @("direct", "lane") -contains [string]$_.relevance) { 1 }
161
+ else { 2 }
162
+ }
163
+ },
164
+ @{ Expression = { [string]$_.ts } },
165
+ @{ Expression = { [int]$_.messageId } } |
166
+ Select-Object -First 1
3
167
  )
4
-
5
- $ErrorActionPreference = "Stop"
6
-
7
- function Try-ReadJson {
8
- param([string]$Path)
9
- if (-not (Test-Path $Path)) { return $null }
10
- try { return Get-Content -Raw -Path $Path | ConvertFrom-Json } catch { return $null }
11
- }
12
-
13
- function Read-DotEnvFile {
14
- param([string]$Path)
15
- $values = @{}
16
- if (-not (Test-Path $Path)) { return $values }
17
- foreach ($line in (Get-Content -Path $Path)) {
18
- if (-not $line) { continue }
19
- if ($line.Trim().StartsWith("#")) { continue }
20
- $parts = $line -split "=", 2
21
- if ($parts.Count -ne 2) { continue }
22
- $values[$parts[0].Trim()] = $parts[1]
23
- }
24
- return $values
25
- }
26
-
27
- function Test-PidAlive {
28
- param([int]$ProcId)
29
- if ($ProcId -le 0) { return $false }
30
- return $null -ne (Get-Process -Id $ProcId -ErrorAction SilentlyContinue)
31
- }
32
-
33
- function Resolve-ConfiguredPath {
34
- param([string]$Value, [string]$RuntimeRoot)
35
- if (-not $Value) { return "" }
36
- $expanded = [Environment]::ExpandEnvironmentVariables($Value)
37
- if ([System.IO.Path]::IsPathRooted($expanded)) { return $expanded }
38
- return [System.IO.Path]::GetFullPath((Join-Path $RuntimeRoot $expanded))
39
- }
40
-
41
- function Get-TelegramPluginRoot {
42
- param([string]$RuntimeRoot)
43
-
44
- $candidates = @()
45
- if ($env:BLUN_CODEX_TELEGRAM_PLUGIN_ROOT) {
46
- $candidates += $env:BLUN_CODEX_TELEGRAM_PLUGIN_ROOT
47
- }
48
- $candidates += (Join-Path $RuntimeRoot "telegram-plugin")
49
-
50
- foreach ($candidate in $candidates) {
51
- if (-not $candidate) { continue }
52
- if ((Test-Path (Join-Path $candidate "app-server-cli.js")) -and (Test-Path (Join-Path $candidate "sidecar-manager.js"))) {
53
- return $candidate
54
- }
55
- }
56
-
57
- return $null
58
- }
59
-
60
- function Get-ProfilePath {
61
- param(
62
- [string]$RuntimeRoot,
63
- [string]$ProfileName
64
- )
65
-
66
- $normalized = [string]$ProfileName
67
- if (-not $normalized) { $normalized = "" }
68
- $normalized = $normalized.ToLower()
69
- $candidates = @()
70
- if ($env:BLUN_CODEX_PROFILE_ROOT) {
71
- $candidates += (Join-Path $env:BLUN_CODEX_PROFILE_ROOT ($normalized + ".json"))
72
- }
73
- $candidates += (Join-Path $env:USERPROFILE (".codex\\profiles\\codexlink\\" + $normalized + ".json"))
74
- $candidates += (Join-Path $RuntimeRoot ("profiles\\" + $normalized + ".json"))
75
-
76
- foreach ($candidate in $candidates) {
77
- if ($candidate -and (Test-Path $candidate)) {
78
- return $candidate
79
- }
80
- }
81
-
82
- return $candidates[-1]
83
- }
84
-
85
- $runtimeRoot = Split-Path -Parent $MyInvocation.MyCommand.Path
86
- $profilePath = Get-ProfilePath -RuntimeRoot $runtimeRoot -ProfileName $Profile
87
- $profileJson = Try-ReadJson -Path $profilePath
88
- $profileAgent = if ($profileJson -and $profileJson.agent_name) { [string]$profileJson.agent_name } else { $Profile.ToLower() }
89
- $runtimeDir = Join-Path $env:USERPROFILE (".codex\\runtimes\\" + $profileAgent)
90
- $stateDir = if ($profileJson -and $profileJson.telegram -and $profileJson.telegram.state_dir) {
91
- Resolve-ConfiguredPath -Value ([string]$profileJson.telegram.state_dir) -RuntimeRoot $runtimeRoot
168
+ $nextPendingReply = @(
169
+ $pendingReplies |
170
+ Sort-Object `
171
+ @{ Expression = { [string]$_.createdAt } },
172
+ @{ Expression = { [int]$_.messageId } } |
173
+ Select-Object -First 1
174
+ )
175
+ $waitReason = if ($pendingReplies.Count -gt 0) {
176
+ "wartet auf Antwort"
177
+ } elseif ($queued.Count -eq 0) {
178
+ $null
179
+ } elseif ($state.lastInjectAt -and (Get-IsoAgeMs -IsoString ([string]$state.lastInjectAt)) -lt $idleCooldownMs) {
180
+ "wartet auf Ruhe"
92
181
  } else {
93
- Join-Path $env:USERPROFILE (".codex\\channels\\telegram-" + $profileAgent)
94
- }
95
- $currentRuntime = Try-ReadJson -Path (Join-Path $runtimeDir "current-remote-runtime.json")
96
- $state = Try-ReadJson -Path (Join-Path $stateDir "state.json")
97
- $envFile = Read-DotEnvFile -Path (Join-Path $stateDir ".env")
98
- $loadedThreads = @()
99
- $queue = @($state.queue)
100
- $queued = @($queue | Where-Object { $_.status -eq "queued" })
101
- $ambient = @($queued | Where-Object { $_.relevance -eq "ambient" })
102
- $submitted = @($queue | Where-Object { $_.status -eq "submitted" })
103
- $delivered = @($queue | Where-Object { $_.status -eq "delivered" })
104
- $errors = @($queue | Where-Object { $_.status -eq "error" })
105
- $pendingReplies = @($state.pendingReplies | Where-Object { -not $_.sentAt -and $_.status -ne "error" })
106
- $pollerPid = if (Test-Path (Join-Path $stateDir "poller.pid")) { (Get-Content -Raw (Join-Path $stateDir "poller.pid")).Trim() } else { $null }
107
- $dispatcherPid = if (Test-Path (Join-Path $stateDir "dispatcher.pid")) { (Get-Content -Raw (Join-Path $stateDir "dispatcher.pid")).Trim() } else { $null }
108
- $responderPid = if (Test-Path (Join-Path $stateDir "responder.pid")) { (Get-Content -Raw (Join-Path $stateDir "responder.pid")).Trim() } else { $null }
109
- $stateThreadId = if ($state.currentThreadId) { [string]$state.currentThreadId } else { "" }
110
- $telegramPluginRoot = Get-TelegramPluginRoot -RuntimeRoot $runtimeRoot
111
-
112
- if ($currentRuntime) {
113
- if ($stateThreadId) {
114
- if ($currentRuntime.PSObject.Properties.Name.Contains("thread_id")) {
115
- $currentRuntime.thread_id = $stateThreadId
116
- } else {
117
- $currentRuntime | Add-Member -NotePropertyName "thread_id" -NotePropertyValue $stateThreadId
118
- }
119
- }
120
- if ($pollerPid) {
121
- if ($currentRuntime.PSObject.Properties.Name.Contains("poller_pid")) {
122
- $currentRuntime.poller_pid = $pollerPid
123
- } else {
124
- $currentRuntime | Add-Member -NotePropertyName "poller_pid" -NotePropertyValue $pollerPid
125
- }
126
- }
127
- if ($dispatcherPid) {
128
- if ($currentRuntime.PSObject.Properties.Name.Contains("dispatcher_pid")) {
129
- $currentRuntime.dispatcher_pid = $dispatcherPid
130
- } else {
131
- $currentRuntime | Add-Member -NotePropertyName "dispatcher_pid" -NotePropertyValue $dispatcherPid
132
- }
182
+ "wartet in Queue"
183
+ }
184
+
185
+ if ($currentRuntime) {
186
+ if ($stateThreadId) {
187
+ if ($currentRuntime.PSObject.Properties.Name.Contains("thread_id")) {
188
+ $currentRuntime.thread_id = $stateThreadId
189
+ } else {
190
+ $currentRuntime | Add-Member -NotePropertyName "thread_id" -NotePropertyValue $stateThreadId
191
+ }
192
+ }
193
+ if ($pollerPid) {
194
+ if ($currentRuntime.PSObject.Properties.Name.Contains("poller_pid")) {
195
+ $currentRuntime.poller_pid = $pollerPid
196
+ } else {
197
+ $currentRuntime | Add-Member -NotePropertyName "poller_pid" -NotePropertyValue $pollerPid
198
+ }
199
+ }
200
+ if ($dispatcherPid) {
201
+ if ($currentRuntime.PSObject.Properties.Name.Contains("dispatcher_pid")) {
202
+ $currentRuntime.dispatcher_pid = $dispatcherPid
203
+ } else {
204
+ $currentRuntime | Add-Member -NotePropertyName "dispatcher_pid" -NotePropertyValue $dispatcherPid
205
+ }
206
+ }
207
+ if ($responderPid) {
208
+ if ($currentRuntime.PSObject.Properties.Name.Contains("responder_pid")) {
209
+ $currentRuntime.responder_pid = $responderPid
210
+ } else {
211
+ $currentRuntime | Add-Member -NotePropertyName "responder_pid" -NotePropertyValue $responderPid
212
+ }
213
+ }
214
+ }
215
+
216
+ if ($envFile["BLUN_TELEGRAM_APP_SERVER_WS_URL"] -and $telegramPluginRoot) {
217
+ try {
218
+ $bootstrapScript = Join-Path $telegramPluginRoot "app-server-cli.js"
219
+ $loaded = & node $bootstrapScript "list-loaded" "--ws-url" $envFile["BLUN_TELEGRAM_APP_SERVER_WS_URL"] | ConvertFrom-Json
220
+ $loadedThreads = @($loaded.data)
221
+ } catch {
222
+ $loadedThreads = @()
223
+ }
224
+ }
225
+
226
+ $result = [ordered]@{
227
+ profile = $profileAgent
228
+ state_dir = $stateDir
229
+ plugin_root = $telegramPluginRoot
230
+ active_ws = $envFile["BLUN_TELEGRAM_APP_SERVER_WS_URL"]
231
+ dispatch_mode = $dispatchMode
232
+ idle_cooldown_ms = $idleCooldownMs
233
+ ambient_queue_ttl_ms = $ambientQueueTtlMs
234
+ pending_reply_timeout_ms = $(if ($envFile["BLUN_TELEGRAM_PENDING_REPLY_TIMEOUT_MS"]) { $envFile["BLUN_TELEGRAM_PENDING_REPLY_TIMEOUT_MS"] } else { "1800000" })
235
+ env_thread_id = $envFile["BLUN_TELEGRAM_THREAD_ID"]
236
+ runtime_thread_id = $runtimeThreadId
237
+ state_thread_id = $stateThreadId
238
+ active_thread_id = if ($runtimeThreadId) { $runtimeThreadId } elseif ($envFile["BLUN_TELEGRAM_THREAD_ID"]) { $envFile["BLUN_TELEGRAM_THREAD_ID"] } else { $stateThreadId }
239
+ frontend_owner_pid = $(if ($currentRuntime -and $currentRuntime.frontend_host_pid) { [string]$currentRuntime.frontend_host_pid } else { "" })
240
+ queue_notifier_pid = $(if ($currentRuntime -and $currentRuntime.queue_notifier_pid) { [string]$currentRuntime.queue_notifier_pid } else { "" })
241
+ current_runtime = $currentRuntime
242
+ loaded_threads = $loadedThreads
243
+ queue_depth = $queued.Count
244
+ visible_waiting_depth = ($queued.Count + $pendingReplies.Count)
245
+ direct_queue_depth = $directQueued.Count
246
+ ambient_queue_depth = $ambientQueued.Count
247
+ escalation_queue_depth = $escalationQueued.Count
248
+ parked_queue_depth = $staleAmbientQueued.Count
249
+ submitted_depth = $submitted.Count
250
+ pending_reply_depth = $pendingReplies.Count
251
+ expired_pending_reply_depth = $expiredPendingReplies.Count
252
+ delivered_count = $delivered.Count
253
+ error_count = $errors.Count
254
+ history_count = $queue.Count
255
+ last_inbound = $state.lastInbound
256
+ last_outbound = $state.lastOutbound
257
+ poller_pid = $pollerPid
258
+ dispatcher_pid = $dispatcherPid
259
+ responder_pid = $responderPid
260
+ next_queued = if ($nextQueued.Count -gt 0) {
261
+ [ordered]@{
262
+ chat_id = $nextQueued[0].chatId
263
+ message_id = $nextQueued[0].messageId
264
+ relevance = $nextQueued[0].relevance
265
+ preview = Normalize-Preview -Value ([string]$nextQueued[0].text)
266
+ }
267
+ } else {
268
+ $null
133
269
  }
134
- if ($responderPid) {
135
- if ($currentRuntime.PSObject.Properties.Name.Contains("responder_pid")) {
136
- $currentRuntime.responder_pid = $responderPid
137
- } else {
138
- $currentRuntime | Add-Member -NotePropertyName "responder_pid" -NotePropertyValue $responderPid
270
+ pending_message = if ($nextPendingReply.Count -gt 0) {
271
+ [ordered]@{
272
+ chat_id = $nextPendingReply[0].chatId
273
+ message_id = $nextPendingReply[0].messageId
274
+ relevance = $nextPendingReply[0].relevance
275
+ preview = Normalize-Preview -Value ([string]$nextPendingReply[0].sourceText)
139
276
  }
277
+ } else {
278
+ $null
140
279
  }
280
+ wait_reason = $waitReason
141
281
  }
142
-
143
- if ($envFile["BLUN_TELEGRAM_APP_SERVER_WS_URL"] -and $telegramPluginRoot) {
144
- try {
145
- $bootstrapScript = Join-Path $telegramPluginRoot "app-server-cli.js"
146
- $loaded = & node $bootstrapScript "list-loaded" "--ws-url" $envFile["BLUN_TELEGRAM_APP_SERVER_WS_URL"] | ConvertFrom-Json
147
- $loadedThreads = @($loaded.data)
148
- } catch {
149
- $loadedThreads = @()
150
- }
151
- }
152
-
153
- $result = [ordered]@{
154
- profile = $profileAgent
155
- state_dir = $stateDir
156
- plugin_root = $telegramPluginRoot
157
- active_ws = $envFile["BLUN_TELEGRAM_APP_SERVER_WS_URL"]
158
- dispatch_mode = $(if ($envFile["BLUN_TELEGRAM_DISPATCH_MODE"]) { $envFile["BLUN_TELEGRAM_DISPATCH_MODE"] } else { "deferred" })
159
- idle_cooldown_ms = $(if ($envFile["BLUN_TELEGRAM_IDLE_COOLDOWN_MS"]) { $envFile["BLUN_TELEGRAM_IDLE_COOLDOWN_MS"] } else { "15000" })
160
- env_thread_id = $envFile["BLUN_TELEGRAM_THREAD_ID"]
161
- state_thread_id = $stateThreadId
162
- active_thread_id = if ($stateThreadId) { $stateThreadId } else { $envFile["BLUN_TELEGRAM_THREAD_ID"] }
163
- current_runtime = $currentRuntime
164
- loaded_threads = $loadedThreads
165
- queue_depth = $queued.Count
166
- ambient_queue_depth = $ambient.Count
167
- submitted_depth = $submitted.Count
168
- pending_reply_depth = $pendingReplies.Count
169
- delivered_count = $delivered.Count
170
- error_count = $errors.Count
171
- history_count = $queue.Count
172
- last_inbound = $state.lastInbound
173
- last_outbound = $state.lastOutbound
174
- poller_pid = $pollerPid
175
- dispatcher_pid = $dispatcherPid
176
- responder_pid = $responderPid
177
- }
178
-
179
- if ($result.poller_pid) {
180
- $result["poller_alive"] = Test-PidAlive -ProcId ([int]$result.poller_pid)
181
- }
182
- if ($result.dispatcher_pid) {
183
- $result["dispatcher_alive"] = Test-PidAlive -ProcId ([int]$result.dispatcher_pid)
184
- }
185
- if ($result.responder_pid) {
186
- $result["responder_alive"] = Test-PidAlive -ProcId ([int]$result.responder_pid)
187
- }
188
-
189
- $result | ConvertTo-Json -Depth 8
282
+
283
+ if ($result.poller_pid) {
284
+ $result["poller_alive"] = Test-PidAlive -ProcId ([int]$result.poller_pid)
285
+ }
286
+ if ($result.dispatcher_pid) {
287
+ $result["dispatcher_alive"] = Test-PidAlive -ProcId ([int]$result.dispatcher_pid)
288
+ }
289
+ if ($result.responder_pid) {
290
+ $result["responder_alive"] = Test-PidAlive -ProcId ([int]$result.responder_pid)
291
+ }
292
+ if ($result.frontend_owner_pid) {
293
+ $result["frontend_owner_alive"] = Test-PidAlive -ProcId ([int]$result.frontend_owner_pid)
294
+ }
295
+ if ($result.queue_notifier_pid) {
296
+ $result["queue_notifier_alive"] = Test-PidAlive -ProcId ([int]$result.queue_notifier_pid)
297
+ }
298
+
299
+ $result | ConvertTo-Json -Depth 8