@trillboards/edge-sdk 0.2.245 → 0.2.253

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.
Files changed (134) hide show
  1. package/deploy/detector/bench/detect_frames.py +88 -0
  2. package/deploy/detector/bench/openvino_parity.py +152 -0
  3. package/deploy/detector/pyproject.toml +10 -1
  4. package/deploy/detector/tests/test_actor_tracking.py +168 -0
  5. package/deploy/detector/tests/test_actor_tracking_wire.py +22 -0
  6. package/deploy/detector/tests/test_loader.py +25 -0
  7. package/deploy/detector/tests/test_openvino_engines.py +251 -0
  8. package/deploy/detector/tests/test_registry.py +53 -0
  9. package/deploy/detector/tests/test_server.py +43 -0
  10. package/deploy/detector/tests/test_version_stamp.py +17 -4
  11. package/deploy/detector/trillboards_detector/_version.py +2 -2
  12. package/deploy/detector/trillboards_detector/actor_tracking.py +139 -2
  13. package/deploy/detector/trillboards_detector/cli.py +5 -0
  14. package/deploy/detector/trillboards_detector/detections.py +5 -0
  15. package/deploy/detector/trillboards_detector/execution.py +386 -0
  16. package/deploy/detector/trillboards_detector/loader.py +40 -1
  17. package/deploy/detector/trillboards_detector/registry.py +33 -1
  18. package/deploy/detector/trillboards_detector/server.py +43 -1
  19. package/deploy/detector/trillboards_detector/session.py +81 -3
  20. package/deploy/detector/trillboards_detector/track_records.py +113 -0
  21. package/deploy/windows/build-windows.ps1 +1 -0
  22. package/deploy/windows/ci/test-detector-looks-field.ps1 +15 -3
  23. package/deploy/windows/ci/test-detector-reinstall.ps1 +645 -0
  24. package/deploy/windows/ci/test-rollout-proofs.ps1 +3 -2
  25. package/deploy/windows/ensure-detector.ps1 +255 -0
  26. package/deploy/windows/install-update.ps1 +4 -3
  27. package/deploy/windows/setup-detector.ps1 +122 -29
  28. package/deploy/windows/stop-existing.ps1 +1 -0
  29. package/deploy/windows/trillboards-edge.cmd +10 -22
  30. package/dist/ActorTracking.d.ts +38 -0
  31. package/dist/ActorTracking.d.ts.map +1 -1
  32. package/dist/ActorTracking.js +40 -0
  33. package/dist/ActorTracking.js.map +1 -1
  34. package/dist/AlertClips.d.ts +4 -2
  35. package/dist/AlertClips.d.ts.map +1 -1
  36. package/dist/AlertClips.js +24 -9
  37. package/dist/AlertClips.js.map +1 -1
  38. package/dist/CloudSensingManager.d.ts +9 -0
  39. package/dist/CloudSensingManager.d.ts.map +1 -1
  40. package/dist/CloudSensingManager.js +52 -4
  41. package/dist/CloudSensingManager.js.map +1 -1
  42. package/dist/ConnectorStatusClient.d.ts +8 -0
  43. package/dist/ConnectorStatusClient.d.ts.map +1 -1
  44. package/dist/ConnectorStatusClient.js +3 -0
  45. package/dist/ConnectorStatusClient.js.map +1 -1
  46. package/dist/DurableVlmCandidateSpool.d.ts +11 -0
  47. package/dist/DurableVlmCandidateSpool.d.ts.map +1 -1
  48. package/dist/DurableVlmCandidateSpool.js +31 -2
  49. package/dist/DurableVlmCandidateSpool.js.map +1 -1
  50. package/dist/EdgeAgent.js +1 -1
  51. package/dist/FrameGroupingShadow.d.ts +57 -0
  52. package/dist/FrameGroupingShadow.d.ts.map +1 -1
  53. package/dist/FrameGroupingShadow.js +123 -5
  54. package/dist/FrameGroupingShadow.js.map +1 -1
  55. package/dist/LocalDetectorClient.d.ts +44 -1
  56. package/dist/LocalDetectorClient.d.ts.map +1 -1
  57. package/dist/LocalDetectorClient.js +88 -4
  58. package/dist/LocalDetectorClient.js.map +1 -1
  59. package/dist/LocalVideoBuffer.d.ts +14 -2
  60. package/dist/LocalVideoBuffer.d.ts.map +1 -1
  61. package/dist/LocalVideoBuffer.js +23 -3
  62. package/dist/LocalVideoBuffer.js.map +1 -1
  63. package/dist/NativeReadiness.d.ts +21 -2
  64. package/dist/NativeReadiness.d.ts.map +1 -1
  65. package/dist/NativeReadiness.js +25 -6
  66. package/dist/NativeReadiness.js.map +1 -1
  67. package/dist/OrderedReviewClient.d.ts +3 -0
  68. package/dist/OrderedReviewClient.d.ts.map +1 -1
  69. package/dist/OrderedReviewClient.js +3 -0
  70. package/dist/OrderedReviewClient.js.map +1 -1
  71. package/dist/SensingProfileClient.d.ts.map +1 -1
  72. package/dist/SensingProfileClient.js +3 -0
  73. package/dist/SensingProfileClient.js.map +1 -1
  74. package/dist/TemporalReviewClient.d.ts +3 -0
  75. package/dist/TemporalReviewClient.d.ts.map +1 -1
  76. package/dist/TemporalReviewClient.js +3 -0
  77. package/dist/TemporalReviewClient.js.map +1 -1
  78. package/dist/VideoSegmentUploader.d.ts +14 -7
  79. package/dist/VideoSegmentUploader.d.ts.map +1 -1
  80. package/dist/VideoSegmentUploader.js +34 -38
  81. package/dist/VideoSegmentUploader.js.map +1 -1
  82. package/dist/VlmCandidateBuffer.d.ts +13 -0
  83. package/dist/VlmCandidateBuffer.d.ts.map +1 -1
  84. package/dist/VlmCandidateBuffer.js.map +1 -1
  85. package/dist/autoSense.d.ts +4 -0
  86. package/dist/autoSense.d.ts.map +1 -1
  87. package/dist/autoSense.js +7 -0
  88. package/dist/autoSense.js.map +1 -1
  89. package/dist/cli.d.ts.map +1 -1
  90. package/dist/cli.js +3 -0
  91. package/dist/cli.js.map +1 -1
  92. package/dist/connectorUpdate.d.ts +18 -9
  93. package/dist/connectorUpdate.d.ts.map +1 -1
  94. package/dist/connectorUpdate.js +66 -3
  95. package/dist/connectorUpdate.js.map +1 -1
  96. package/dist/connectorUpdateApply.d.ts +20 -1
  97. package/dist/connectorUpdateApply.d.ts.map +1 -1
  98. package/dist/connectorUpdateApply.js +55 -1
  99. package/dist/connectorUpdateApply.js.map +1 -1
  100. package/dist/connectorUpdateApplyMac.d.ts +3 -1
  101. package/dist/connectorUpdateApplyMac.d.ts.map +1 -1
  102. package/dist/connectorUpdateApplyMac.js +6 -0
  103. package/dist/connectorUpdateApplyMac.js.map +1 -1
  104. package/dist/continuousReview.d.ts +6 -2
  105. package/dist/continuousReview.d.ts.map +1 -1
  106. package/dist/continuousReview.js.map +1 -1
  107. package/dist/detectorBackendRelay.d.ts +24 -0
  108. package/dist/detectorBackendRelay.d.ts.map +1 -0
  109. package/dist/detectorBackendRelay.js +70 -0
  110. package/dist/detectorBackendRelay.js.map +1 -0
  111. package/dist/detectorEndpointState.d.ts +30 -0
  112. package/dist/detectorEndpointState.d.ts.map +1 -0
  113. package/dist/detectorEndpointState.js +125 -0
  114. package/dist/detectorEndpointState.js.map +1 -0
  115. package/dist/detectorLauncher.d.ts +23 -0
  116. package/dist/detectorLauncher.d.ts.map +1 -0
  117. package/dist/detectorLauncher.js +94 -0
  118. package/dist/detectorLauncher.js.map +1 -0
  119. package/dist/diagnose.d.ts +1 -1
  120. package/dist/diagnose.js +1 -1
  121. package/dist/localSensing.d.ts +72 -0
  122. package/dist/localSensing.d.ts.map +1 -1
  123. package/dist/localSensing.js +280 -31
  124. package/dist/localSensing.js.map +1 -1
  125. package/dist/pipelineSwitches.d.ts +59 -0
  126. package/dist/pipelineSwitches.d.ts.map +1 -0
  127. package/dist/pipelineSwitches.js +240 -0
  128. package/dist/pipelineSwitches.js.map +1 -0
  129. package/package.json +4 -4
  130. package/retained/ProfileAuthorityClient.cjs +4 -0
  131. package/retained/RetainedCaptureClient.cjs +41 -2
  132. package/retained/WebsiteAdmissionCaptureClient.cjs +57 -2
  133. package/retained/__tests__/look-reuse.test.cjs +167 -0
  134. package/retained/manager.cjs +28 -2
@@ -0,0 +1,255 @@
1
+ <#
2
+ ensure-detector.ps1 -- the connector launcher's check of the on-device object
3
+ detector (127.0.0.1:9380), started hidden by trillboards-edge.cmd on every
4
+ connector start, so node starts at once while this decides.
5
+
6
+ WHY IT IS NOT A ONE-LINE CURL ANY MORE. Through 0.2.252 the launcher asked
7
+ /health with a 2 s timeout and re-provisioned the detector (setup-detector.ps1:
8
+ a trial install, then a stop, a swap and a restart) whenever nothing answered
9
+ in time. On the Texas store PC the detector is busy close to 100% of the time
10
+ (an i7-7700 serving every alert camera), so a working detector that took more
11
+ than 2 s to answer was torn down and rebuilt: about two minutes of refused
12
+ connections, during which the alert cameras paused or fell back to Gemma.
13
+
14
+ THE RULES, in order:
15
+ 1. Another check is already deciding (this script's own per-user mutex):
16
+ exit, record nothing.
17
+ 2. The detector provisioner is running (setup-detector.ps1's per-user
18
+ mutex): leave it alone, decision `provisioning_in_progress`.
19
+ 3. The TrillboardsDetector task is missing: re-provision,
20
+ `reprovision_task_missing`.
21
+ 4. Up to -Probes GET /health calls, -ProbeTimeoutSec each. ANY HTTP answer
22
+ (200, 503 while the model loads, anything) means a detector is listening:
23
+ leave it alone, `answered`.
24
+ 5. Every probe timed out and none was refused: something is listening but
25
+ not answering. Leave it alone, `no_answer_left_alone`. This removes the
26
+ launcher's only restart of a hung detector, deliberately: the launcher has
27
+ no look evidence, and a busy detector looks exactly like a hung one from
28
+ here. The server's stall sweep, which sees the looks, owns that decision.
29
+ 6. Refused with the task registered: if the task is disabled, never start
30
+ it (`task_disabled_left_alone`). Otherwise start it (`started_task`) and
31
+ re-probe every 5 s for -StartWaitSec (twice that when the task was
32
+ already running: a detector still importing after a reboot). Refused on
33
+ every probe to the end: re-provision, `reprovision_still_refused`. A
34
+ probe that timed out means something is listening: left alone.
35
+ The provisioner mutex is re-checked before every re-provision.
36
+
37
+ THE DECISION FILE, %LOCALAPPDATA%\Trillboards\detector-launcher.json, one
38
+ JSON object, replaced atomically on every decision (and once more when a
39
+ re-provision finishes). The connector reads it and reports it on its
40
+ status beacon, so a detector restart can be told from a slow detector.
41
+
42
+ Windows PowerShell 5.1 (the launcher's host): no -SkipHttpErrorCheck, no
43
+ ternaries, no null-coalescing.
44
+ #>
45
+ [CmdletBinding()]
46
+ param(
47
+ [string]$HealthUrl = 'http://127.0.0.1:9380/health',
48
+ [ValidateRange(1, 60)][int]$ProbeTimeoutSec = 10,
49
+ [ValidateRange(1, 10)][int]$Probes = 3,
50
+ [ValidateRange(5, 600)][int]$StartWaitSec = 60,
51
+ [string]$TaskName = 'TrillboardsDetector',
52
+ [string]$SetupScript = '',
53
+ [string]$DecisionPath = ''
54
+ )
55
+
56
+ $ErrorActionPreference = 'Continue'
57
+ $Here = Split-Path -Parent $MyInvocation.MyCommand.Path
58
+ if (-not $SetupScript) { $SetupScript = Join-Path $Here 'setup-detector.ps1' }
59
+ if (-not $DecisionPath) { $DecisionPath = Join-Path $env:LOCALAPPDATA 'Trillboards\detector-launcher.json' }
60
+ $LogDir = Join-Path $env:LOCALAPPDATA 'Trillboards\logs'
61
+ $LogPath = Join-Path $LogDir 'detector-setup.log'
62
+
63
+ function Log([string]$Message) {
64
+ $line = '[trillboards ensure-detector] {0} {1}' -f (Get-Date -Format 'HH:mm:ss'), $Message
65
+ Write-Host $line
66
+ try {
67
+ New-Item -ItemType Directory -Force -Path $LogDir | Out-Null
68
+ Add-Content -LiteralPath $LogPath -Value $line -Encoding UTF8
69
+ } catch { }
70
+ }
71
+
72
+ $record = [ordered]@{ version = 1; decision = $null; decidedAt = $null; probes = @() }
73
+
74
+ function Write-Decision([string]$Decision) {
75
+ $record.decision = $Decision
76
+ $record.decidedAt = [DateTimeOffset]::UtcNow.ToString('yyyy-MM-ddTHH:mm:ss.fffZ')
77
+ try {
78
+ $dir = Split-Path -Parent $DecisionPath
79
+ New-Item -ItemType Directory -Force -Path $dir | Out-Null
80
+ $tmp = $DecisionPath + '.tmp'
81
+ [IO.File]::WriteAllText($tmp, ($record | ConvertTo-Json -Compress -Depth 4), (New-Object Text.UTF8Encoding $false))
82
+ Move-Item -LiteralPath $tmp -Destination $DecisionPath -Force
83
+ } catch { Log ('could not write the decision file: ' + $_.Exception.Message) }
84
+ }
85
+
86
+ # One GET /health. Returns @{ code = <int> } for any HTTP answer, else
87
+ # @{ error = 'refused' | 'timeout' | 'error' }, with the call's milliseconds.
88
+ # The failure is read off the whole exception chain: PowerShell wraps a .NET
89
+ # method's exception (MethodInvocationException), .NET Framework puts the
90
+ # SocketException right under the WebException, and .NET (Core) puts an
91
+ # HttpRequestException between them.
92
+ function Invoke-Probe([int]$TimeoutSec) {
93
+ $watch = [Diagnostics.Stopwatch]::StartNew()
94
+ $result = [ordered]@{}
95
+ $response = $null
96
+ try {
97
+ $request = [Net.HttpWebRequest]::Create($HealthUrl)
98
+ $request.Method = 'GET'
99
+ $request.Proxy = $null
100
+ $request.KeepAlive = $false
101
+ $request.Timeout = $TimeoutSec * 1000
102
+ $request.ReadWriteTimeout = $TimeoutSec * 1000
103
+ $response = $request.GetResponse()
104
+ $result.code = [int]$response.StatusCode
105
+ } catch {
106
+ $web = $null; $socket = $null; $timedOut = $false
107
+ for ($e = $_.Exception; $e; $e = $e.InnerException) {
108
+ if (-not $web -and $e -is [Net.WebException]) { $web = $e }
109
+ if (-not $socket -and $e -is [Net.Sockets.SocketException]) { $socket = $e }
110
+ if ($e -is [TimeoutException] -or $e -is [Threading.Tasks.TaskCanceledException]) { $timedOut = $true }
111
+ }
112
+ if ($web -and $web.Response) {
113
+ $result.code = [int]$web.Response.StatusCode
114
+ try { $web.Response.Close() } catch { }
115
+ } elseif ($socket -and ($socket.SocketErrorCode -eq [Net.Sockets.SocketError]::ConnectionRefused -or
116
+ $socket.SocketErrorCode -eq [Net.Sockets.SocketError]::ConnectionReset)) {
117
+ $result.error = 'refused'
118
+ } elseif ($timedOut -or ($web -and $web.Status -eq [Net.WebExceptionStatus]::Timeout) -or
119
+ ($socket -and $socket.SocketErrorCode -eq [Net.Sockets.SocketError]::TimedOut)) {
120
+ $result.error = 'timeout'
121
+ } elseif ($web -and $web.Status -eq [Net.WebExceptionStatus]::ConnectFailure -and -not $socket) {
122
+ $result.error = 'refused'
123
+ } else {
124
+ $result.error = 'error'
125
+ }
126
+ } finally {
127
+ if ($response) { try { $response.Close() } catch { } }
128
+ }
129
+ $result.ms = [int]$watch.ElapsedMilliseconds
130
+ return $result
131
+ }
132
+
133
+ function Test-ProvisionerRunning {
134
+ $mutex = New-Object System.Threading.Mutex($false, ('Global\TrillboardsDetectorSetup-' + $script:Sid))
135
+ try {
136
+ $held = $false
137
+ try { $held = $mutex.WaitOne(0) } catch [System.Threading.AbandonedMutexException] { $held = $true }
138
+ if ($held) { $mutex.ReleaseMutex(); return $false }
139
+ return $true
140
+ } finally { $mutex.Dispose() }
141
+ }
142
+
143
+ function Get-DetectorTask {
144
+ Get-ScheduledTask -TaskName $TaskName -TaskPath '\' -ErrorAction SilentlyContinue
145
+ }
146
+
147
+ function Invoke-Reprovision([string]$Decision) {
148
+ if (Test-ProvisionerRunning) {
149
+ Write-Decision 'provisioning_in_progress'
150
+ Log 'the detector provisioner is already running; left it alone'
151
+ return
152
+ }
153
+ $record.reprovisionedAt = [DateTimeOffset]::UtcNow.ToString('yyyy-MM-ddTHH:mm:ss.fffZ')
154
+ Write-Decision $Decision
155
+ if (-not (Test-Path -LiteralPath $SetupScript)) {
156
+ $record.setupExit = 'missing'
157
+ Write-Decision $Decision
158
+ Log ($Decision + ': the provisioner is not installed; nothing to run')
159
+ return
160
+ }
161
+ Log ($Decision + ': re-provisioning the detector')
162
+ $powershell = Join-Path $env:WINDIR 'System32\WindowsPowerShell\v1.0\powershell.exe'
163
+ try {
164
+ $setup = Start-Process -FilePath $powershell -ArgumentList @('-NoProfile', '-ExecutionPolicy', 'Bypass',
165
+ '-WindowStyle', 'Hidden', '-File', ('"' + $SetupScript + '"')) -WindowStyle Hidden -Wait -PassThru
166
+ $record.setupExit = $setup.ExitCode
167
+ } catch {
168
+ $record.setupExit = 'failed_to_start'
169
+ Log ('the provisioner did not start: ' + $_.Exception.Message)
170
+ }
171
+ Write-Decision $Decision
172
+ }
173
+
174
+ $script:Sid = [System.Security.Principal.WindowsIdentity]::GetCurrent().User.Value
175
+ $self = New-Object System.Threading.Mutex($false, ('Global\TrillboardsEnsureDetector-' + $script:Sid))
176
+ $haveSelf = $false
177
+ try { $haveSelf = $self.WaitOne(0) } catch [System.Threading.AbandonedMutexException] { $haveSelf = $true }
178
+ if (-not $haveSelf) { $self.Dispose(); exit 0 }
179
+ try {
180
+ if (Test-ProvisionerRunning) {
181
+ Write-Decision 'provisioning_in_progress'
182
+ Log 'the detector provisioner is running; left it alone'
183
+ exit 0
184
+ }
185
+ if (-not (Get-DetectorTask)) {
186
+ Invoke-Reprovision 'reprovision_task_missing'
187
+ exit 0
188
+ }
189
+
190
+ $refused = $false
191
+ for ($i = 0; $i -lt $Probes; $i++) {
192
+ $probe = Invoke-Probe $ProbeTimeoutSec
193
+ $record.probes += , $probe
194
+ if ($probe.Contains('code')) {
195
+ Write-Decision 'answered'
196
+ exit 0
197
+ }
198
+ if ($probe.error -eq 'refused') { $refused = $true; break }
199
+ }
200
+ if (-not $refused) {
201
+ Write-Decision 'no_answer_left_alone'
202
+ Log ('the detector did not answer ' + $Probes + ' probe(s) of ' + $ProbeTimeoutSec + ' s and never refused; left it alone')
203
+ exit 0
204
+ }
205
+
206
+ if (Test-ProvisionerRunning) {
207
+ Write-Decision 'provisioning_in_progress'
208
+ Log 'the detector provisioner started meanwhile; left it alone'
209
+ exit 0
210
+ }
211
+ $task = Get-DetectorTask
212
+ if (-not $task) {
213
+ Invoke-Reprovision 'reprovision_task_missing'
214
+ exit 0
215
+ }
216
+ if (($task.Settings -and -not $task.Settings.Enabled) -or [string]$task.State -eq 'Disabled') {
217
+ Write-Decision 'task_disabled_left_alone'
218
+ Log 'the detector refused connections and its task is disabled; never starting a disabled task'
219
+ exit 0
220
+ }
221
+ $record.taskState = [string]$task.State
222
+ $waitSec = $StartWaitSec
223
+ if ($record.taskState -eq 'Running') { $waitSec = 2 * $StartWaitSec }
224
+ $record.startedTaskAt = [DateTimeOffset]::UtcNow.ToString('yyyy-MM-ddTHH:mm:ss.fffZ')
225
+ Write-Decision 'started_task'
226
+ Log ('the detector refused connections with its task registered (' + $record.taskState + '); starting the task')
227
+ try { Start-ScheduledTask -TaskName $TaskName -TaskPath '\' -ErrorAction Stop }
228
+ catch { Log ('starting the task failed: ' + $_.Exception.Message) }
229
+ $watch = [Diagnostics.Stopwatch]::StartNew()
230
+ $listening = $false
231
+ $probe = $null
232
+ while ($watch.Elapsed.TotalSeconds -lt $waitSec) {
233
+ Start-Sleep -Seconds 5
234
+ $probe = Invoke-Probe ([Math]::Min(5, $ProbeTimeoutSec))
235
+ if ($probe.Contains('code')) {
236
+ $record.answeredAfterStartMs = [int]$watch.ElapsedMilliseconds
237
+ $record.probes += , $probe
238
+ Write-Decision 'started_task'
239
+ Log ('the detector answered ' + $probe.code + ' after the task start')
240
+ exit 0
241
+ }
242
+ if ($probe.error -eq 'timeout') { $listening = $true }
243
+ }
244
+ if ($probe) { $record.probes += , $probe }
245
+ if ($listening) {
246
+ Write-Decision 'started_task'
247
+ Log ('the detector is listening but did not answer within ' + $waitSec + ' s of the task start; left it alone')
248
+ exit 0
249
+ }
250
+ Invoke-Reprovision 'reprovision_still_refused'
251
+ } finally {
252
+ try { $self.ReleaseMutex() } catch { }
253
+ $self.Dispose()
254
+ }
255
+ exit 0
@@ -281,9 +281,10 @@ function Restore-LocalAiRuntime {
281
281
  Carry the detector's RAM ceiling onto an EXISTING install.
282
282
 
283
283
  WHY THE UPDATE TRANSACTION HAS TO DO THIS. Nothing else on an upgraded box
284
- will. This script only calls Register-Connector, and trillboards-edge.cmd
285
- re-runs setup-detector.ps1 only when the task is MISSING or /health answers
286
- 000 - so a HEALTHY detector keeps the task action it was registered with. A
284
+ will. This script only calls Register-Connector, and the launcher's check
285
+ (ensure-detector.ps1) re-runs setup-detector.ps1 only when the task is
286
+ MISSING or still refuses connections after a task start - so a HEALTHY
287
+ detector keeps the task action it was registered with. A
287
288
  box that updates normally would therefore keep an action with no
288
289
  `--ram-budget-mb` for ever, every delivered specialist would stay `idle`, and
289
290
  the fix would reach NEW INSTALLS ONLY. That is the exact shape of the
@@ -227,11 +227,6 @@ if (-not $source) {
227
227
  # --refresh-package trillboards-detector, NOT --refresh: the latter also
228
228
  # re-downloads the pinned ~250 MB onnxruntime wheel on a shop PC every time, for
229
229
  # nothing - an exact pin cannot resolve to different bytes.
230
- Log "installing/repairing trillboards-detector from $source with uv-managed Python $DetectorPython"
231
- try { Stop-OwnedDetectorForRepair } catch {
232
- Log "ERROR: detector service could not be safely stopped before repair: $($_.Exception.Message)"
233
- exit 0
234
- }
235
230
  $runtimeExtra = 'cpu'
236
231
  if ($Runtime -eq 'auto') {
237
232
  try {
@@ -241,17 +236,130 @@ if ($Runtime -eq 'auto') {
241
236
  if ($nvidia.Count) { $runtimeExtra = 'cuda' }
242
237
  } catch { Log "WARN: GPU inventory unavailable; selecting CPU: $($_.Exception.Message)" }
243
238
  }
244
- Log "Selected detector runtime: $runtimeExtra (NVIDIA CUDA only; Intel integrated graphics retain CPU)"
239
+ # Plan v7 W8: an Intel host without NVIDIA also gets the pinned OpenVINO runtime
240
+ # ([openvino], beside [cpu]). It changes nothing by being installed: ONNX Runtime
241
+ # keeps answering until the server asks for OpenVINO (CCTV_DETECTOR_BACKEND) and
242
+ # the engine's own parity probe passes on this host. The Texas store PC (i7-7700,
243
+ # HD 630) is the case: its iGPU was idle under every model.
244
+ $openVinoExtra = $false
245
+ if ($runtimeExtra -eq 'cpu') {
246
+ try {
247
+ $processor = @(Get-CimInstance Win32_Processor -ErrorAction Stop | Select-Object -First 1)
248
+ if ($processor.Count -and [string]$processor[0].Manufacturer -match 'GenuineIntel') { $openVinoExtra = $true }
249
+ } catch { Log "WARN: processor inventory unavailable; OpenVINO is not installed: $($_.Exception.Message)" }
250
+ }
251
+ Log ("Selected detector runtime: $runtimeExtra" + $(if ($openVinoExtra) { ' + openvino (Intel CPU; serves only when the server asks and its parity probe passes)' } else { '' }))
252
+ $installFromStagedCache = $false
253
+ # ONE `uv tool install` per cache mode.
254
+ #
255
+ # ONLINE (the trial install below, and the repair rung): --refresh-package
256
+ # trillboards-detector, so the staged bytes are rebuilt rather than served from
257
+ # uv's cached wheel (see above).
258
+ #
259
+ # OFFLINE (the replacement, once the trial has passed): every byte it needs is in
260
+ # uv's cache, and --offline serves cached index pages at any age, so the step
261
+ # that begins by deleting the old venv cannot wait on or fail on the network. It
262
+ # carries NO refresh: current uv refuses the pair ("the argument `--offline`
263
+ # cannot be used with `--refresh`", uv 0.11.15), and it needs none - it installs
264
+ # the wheel the trial's --refresh-package just rebuilt. Measured 2026-11-17 on
265
+ # uv 0.11.15 with the network dead: same source path, version unchanged, new
266
+ # bytes installed.
267
+ function Invoke-DetectorToolInstall([string]$Extras) {
268
+ if ($script:installFromStagedCache) {
269
+ & $uvCmd.Source tool install --offline --python $DetectorPython --managed-python --force ($source + '[' + $Extras + ']') *>> $LogPath
270
+ } else {
271
+ & $uvCmd.Source tool install --python $DetectorPython --managed-python --force --refresh-package trillboards-detector ($source + '[' + $Extras + ']') *>> $LogPath
272
+ }
273
+ }
245
274
  function Install-DetectorRuntime {
246
- & $uvCmd.Source tool install --python $DetectorPython --managed-python --force --refresh-package trillboards-detector ($source + '[' + $script:runtimeExtra + ']') *>> $LogPath
247
- if ($LASTEXITCODE -ne 0 -and $script:runtimeExtra -eq 'cuda') {
248
- Log 'WARN: CUDA runtime installation failed; retrying the same detector with CPU dependencies'
249
- $script:runtimeExtra = 'cpu'
250
- & $uvCmd.Source tool install --python $DetectorPython --managed-python --force --refresh-package trillboards-detector ($source + '[cpu]') *>> $LogPath
275
+ $extras = if ($script:openVinoExtra) { $script:runtimeExtra + ',openvino' } else { $script:runtimeExtra }
276
+ Invoke-DetectorToolInstall $extras
277
+ if ($LASTEXITCODE -ne 0 -and ($script:openVinoExtra -or $script:runtimeExtra -eq 'cuda')) {
278
+ # ONE fallback rung: OpenVINO is only ever beside CPU, so it is either "the same
279
+ # detector without OpenVINO" or "CUDA's detector on the CPU".
280
+ if ($script:openVinoExtra) {
281
+ Log 'WARN: the OpenVINO runtime did not install; retrying the same detector with ONNX Runtime only'
282
+ $script:openVinoExtra = $false
283
+ } else {
284
+ Log 'WARN: CUDA runtime installation failed; retrying the same detector with CPU dependencies'
285
+ $script:runtimeExtra = 'cpu'
286
+ }
287
+ Invoke-DetectorToolInstall $script:runtimeExtra
251
288
  }
252
289
  return $LASTEXITCODE
253
290
  }
291
+ function Get-StagedDetectorVersion {
292
+ param([string] $SourceDir)
293
+ $pyproject = Join-Path $SourceDir 'pyproject.toml'
294
+ if (-not (Test-Path -LiteralPath $pyproject)) { return $null }
295
+ foreach ($line in (Get-Content -LiteralPath $pyproject)) {
296
+ if ($line -match '^\s*version\s*=\s*"([^"]+)"\s*$') { return $Matches[1] }
297
+ }
298
+ return $null
299
+ }
300
+ function Get-InstalledDetectorVersion {
301
+ param([string] $Exe)
302
+ if (-not (Test-Path -LiteralPath $Exe)) { return $null }
303
+ # `--version` prints "trillboards-detector <version>"; take the last token.
304
+ $out = & $Exe --version 2>$null
305
+ if ($LASTEXITCODE -ne 0 -or -not $out) { return $null }
306
+ return ([string]$out).Trim().Split(' ')[-1]
307
+ }
308
+
309
+ # --- 2a. A trial install first, while the running detector keeps answering ----
310
+ # `uv tool install --force` RECREATES the tool venv (uv 0.10.10+: "Recreate Python
311
+ # environments under `uv tool install --force`"). It resolves first, so an index
312
+ # it cannot reach leaves the old venv alone. But once resolution succeeds it
313
+ # deletes the old venv AND trillboards-detector.exe, and only then downloads and
314
+ # installs; if that fails it deletes the new venv as well. With the service
315
+ # already stopped, a WAN drop during the download (the [openvino] wheel alone is
316
+ # 85 MB) left a store PC with NO detector: the finally below restarted a task
317
+ # whose executable uv had deleted, and nothing but the launcher's repair at the
318
+ # next connector start would bring it back (found from code before the 0.2.246
319
+ # install, 2026-11-17).
320
+ #
321
+ # So the identical install runs first into a THROWAWAY tool directory, while the
322
+ # old service keeps serving: it resolves, downloads, builds, and must report the
323
+ # staged version. If that fails with and without OpenVINO, this script exits
324
+ # without having touched the running detector. Only after it passes is the
325
+ # service stopped and the real venv replaced, offline, from what the trial just
326
+ # cached, with the extras that passed.
327
+ $stageRoot = Join-Path $env:LOCALAPPDATA 'Trillboards\detector-stage'
328
+ function Invoke-DetectorTrialInstall {
329
+ $saved = @{}
330
+ foreach ($name in @('UV_TOOL_DIR', 'UV_TOOL_BIN_DIR')) { $saved[$name] = [Environment]::GetEnvironmentVariable($name, 'Process') }
331
+ try {
332
+ [Environment]::SetEnvironmentVariable('UV_TOOL_DIR', (Join-Path $script:stageRoot 'tools'), 'Process')
333
+ [Environment]::SetEnvironmentVariable('UV_TOOL_BIN_DIR', (Join-Path $script:stageRoot 'bin'), 'Process')
334
+ if ((Install-DetectorRuntime) -ne 0) { return $false }
335
+ $trialVersion = Get-InstalledDetectorVersion -Exe (Join-Path $script:stageRoot 'bin\trillboards-detector.exe')
336
+ $packageVersion = Get-StagedDetectorVersion -SourceDir $source
337
+ if (-not $trialVersion -or ($packageVersion -and $trialVersion -ne $packageVersion)) {
338
+ Log "ERROR: the trial-installed detector reports '$trialVersion' but the package is '$packageVersion'"
339
+ return $false
340
+ }
341
+ return $true
342
+ } finally {
343
+ foreach ($name in $saved.Keys) { [Environment]::SetEnvironmentVariable($name, $saved[$name], 'Process') }
344
+ }
345
+ }
346
+ $trialWatch = [Diagnostics.Stopwatch]::StartNew()
347
+ Log "trial-installing trillboards-detector into $stageRoot while the running detector keeps serving"
348
+ if (-not (Invoke-DetectorTrialInstall)) {
349
+ Log "ERROR: the new detector runtime did not install (see above); the running detector was not touched and keeps serving"
350
+ Remove-Item -LiteralPath $stageRoot -Recurse -Force -ErrorAction SilentlyContinue
351
+ exit 0
352
+ }
353
+ Log ("trial install passed in {0:N1} s with [{1}]; replacing the running detector offline, from uv's cache" -f $trialWatch.Elapsed.TotalSeconds, $(if ($openVinoExtra) { $runtimeExtra + ',openvino' } else { $runtimeExtra }))
354
+ $installFromStagedCache = $true
355
+
356
+ Log "installing/repairing trillboards-detector from $source with uv-managed Python $DetectorPython"
357
+ try { Stop-OwnedDetectorForRepair } catch {
358
+ Log "ERROR: detector service could not be safely stopped before repair: $($_.Exception.Message)"
359
+ exit 0
360
+ }
254
361
  $runtimeInstallExit = Install-DetectorRuntime
362
+ Remove-Item -LiteralPath $stageRoot -Recurse -Force -ErrorAction SilentlyContinue
255
363
  if ($runtimeInstallExit -ne 0) {
256
364
  Log "ERROR: trillboards-detector install failed; the cascade stays off (the VLM still runs every frame)"
257
365
  exit 0
@@ -274,24 +382,6 @@ Log "trillboards-detector installed at $detectorPath"
274
382
  # so this comparison is the only thing in the chain that can tell a real install
275
383
  # from a convincing no-op. It reads the STAGED pyproject rather than a constant:
276
384
  # a constant here would be a fourth place the same version is written down.
277
- function Get-StagedDetectorVersion {
278
- param([string] $SourceDir)
279
- $pyproject = Join-Path $SourceDir 'pyproject.toml'
280
- if (-not (Test-Path -LiteralPath $pyproject)) { return $null }
281
- foreach ($line in (Get-Content -LiteralPath $pyproject)) {
282
- if ($line -match '^\s*version\s*=\s*"([^"]+)"\s*$') { return $Matches[1] }
283
- }
284
- return $null
285
- }
286
- function Get-InstalledDetectorVersion {
287
- param([string] $Exe)
288
- if (-not (Test-Path -LiteralPath $Exe)) { return $null }
289
- # `--version` prints "trillboards-detector <version>"; take the last token.
290
- $out = & $Exe --version 2>$null
291
- if ($LASTEXITCODE -ne 0 -or -not $out) { return $null }
292
- return ([string]$out).Trim().Split(' ')[-1]
293
- }
294
-
295
385
  $wantVersion = Get-StagedDetectorVersion -SourceDir $source
296
386
  $haveVersion = Get-InstalledDetectorVersion -Exe $detectorPath
297
387
  if (-not $wantVersion) {
@@ -303,6 +393,9 @@ if (-not $wantVersion) {
303
393
  Log "WARN: the installed detector reports '$haveVersion' but the staged package is '$wantVersion' - reinstalling from scratch"
304
394
  Stop-OwnedDetectorForRepair
305
395
  & $uvCmd.Source tool uninstall trillboards-detector *>> $LogPath
396
+ # Online, with --refresh-package: the offline replacement installed what the
397
+ # cache holds, so rebuild from the staged directory instead of asking it again.
398
+ $installFromStagedCache = $false
306
399
  $runtimeInstallExit = Install-DetectorRuntime
307
400
  $haveVersion = Get-InstalledDetectorVersion -Exe $detectorPath
308
401
  if ($haveVersion -eq $wantVersion) {
@@ -59,6 +59,7 @@ function Get-TrillboardsEdgeProcesses {
59
59
  'trillboards-pair.cmd',
60
60
  'setup-litertlm.ps1',
61
61
  'setup-detector.ps1',
62
+ 'ensure-detector.ps1',
62
63
  'cli.js',
63
64
  'ffmpeg.exe'
64
65
  )
@@ -53,29 +53,17 @@ if /I "%~1"=="auto-sense" (
53
53
  )
54
54
  )
55
55
 
56
- REM The on-device OBJECT DETECTOR, repaired on the same logon trigger. TWO
57
- REM signals only -- the task exists, and the service answers on :9380.
58
- REM
59
- REM THE HEALTH PROBE ASKS WHETHER IT ANSWERS, NOT WHETHER IT IS READY, and
60
- REM that is why there is no `--fail` here. The detector's model is OTA'd, so a
61
- REM correctly-installed service reports 503 for as long as the artifact has not
62
- REM landed -- minutes on a fresh install, indefinitely on a box that cannot
63
- REM reach the CDN. Treating 503 as broken would reinstall a working tool on
64
- REM every single logon. `curl.exe -o NUL -w %%{http_code}` returns 000 only
65
- REM when nothing answered at all, which is the state worth repairing.
66
- REM
67
- REM There is deliberately no config-file check to match the litert-lm BOM test
68
- REM above: this service is configured entirely on its command line, so it has
69
- REM no file whose encoding could silently break it.
70
- set "NEEDS_DETECTOR=0"
71
- schtasks /Query /TN "TrillboardsDetector" >nul 2>&1
72
- if errorlevel 1 set "NEEDS_DETECTOR=1"
73
- for /f %%C in ('curl.exe --silent --output NUL --write-out "%%{http_code}" --max-time 2 http://127.0.0.1:9380/health 2^>nul') do set "DETECTOR_CODE=%%C"
74
- if not defined DETECTOR_CODE set "NEEDS_DETECTOR=1"
75
- if "!DETECTOR_CODE!"=="000" set "NEEDS_DETECTOR=1"
76
- if "!NEEDS_DETECTOR!"=="1" if exist "%BIN%setup-detector.ps1" (
56
+ REM The on-device OBJECT DETECTOR, checked on the same logon trigger by its
57
+ REM own hidden helper, so node starts at once while it decides.
58
+ REM ensure-detector.ps1 holds the rules and records each decision for the
59
+ REM status beacon. It re-provisions only a detector whose task is missing,
60
+ REM or that still refuses connections after its task was started; ANY HTTP
61
+ REM answer leaves the detector alone. Through 0.2.252 this was a 2 s curl here,
62
+ REM and a working detector that was merely busy for 2 s was torn down and
63
+ REM rebuilt (about two minutes of refused connections on a store PC).
64
+ if exist "%BIN%ensure-detector.ps1" (
77
65
  set "HIDDEN_RUN=%WINDIR%\System32\wscript.exe"
78
- "!HIDDEN_RUN!" "%BIN%trillboards-hidden-run.vbs" "powershell.exe" "-NoProfile" "-ExecutionPolicy" "Bypass" "-WindowStyle" "Hidden" "-File" "%BIN%setup-detector.ps1"
66
+ "!HIDDEN_RUN!" "%BIN%trillboards-hidden-run.vbs" "powershell.exe" "-NoProfile" "-ExecutionPolicy" "Bypass" "-WindowStyle" "Hidden" "-File" "%BIN%ensure-detector.ps1"
79
67
  )
80
68
  )
81
69
 
@@ -32,4 +32,42 @@ export declare function validateActorIdentity(value: unknown, cameraId: string,
32
32
  export declare function parseActorTrackingResult(value: unknown, request: ActorTrackingRequest, jpeg: Buffer, modelHashes: Record<string, string>, detections: ReadonlyArray<{
33
33
  label: string;
34
34
  }>, appearance?: ActorAppearancePin): ActorTrackingResult;
35
+ /**
36
+ * One live actor's running record, served as `tracks` beside `tracking` on a tracked
37
+ * /detect (detector trillboards_detector/track_records.py, wire version 1). First and
38
+ * last OBSERVED capture times, observed-frame count, newest observed box and score.
39
+ * The record is deleted with its actor, so a record never outlives its track.
40
+ *
41
+ * `face` is a reserved slot, null everywhere today. Its one intended writer is the
42
+ * face watchlist (plan v7 T1), through the detector journal's record_face; nothing
43
+ * else computes or stores a face vector, and the slot ends with the track.
44
+ */
45
+ export interface ActorFaceSlot {
46
+ modelId: string;
47
+ modelSha256: string;
48
+ dims: number;
49
+ vector: number[];
50
+ frameId: string;
51
+ capturedAtMs: number;
52
+ quality: number;
53
+ }
54
+ export interface ActorTrackRecord {
55
+ version: 1;
56
+ actorId: string;
57
+ kind: 'person';
58
+ epoch: string;
59
+ firstSeenAtMs: number;
60
+ lastSeenAtMs: number;
61
+ frames: number;
62
+ box: {
63
+ x: number;
64
+ y: number;
65
+ width: number;
66
+ height: number;
67
+ };
68
+ confidence: number;
69
+ face: ActorFaceSlot | null;
70
+ }
71
+ /** Records for the tracked frame: one per live actor of its epoch, each observed actor current. */
72
+ export declare function parseActorTrackRecords(value: unknown, tracking: ActorTrackingResult): ActorTrackRecord[];
35
73
  //# sourceMappingURL=ActorTracking.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ActorTracking.d.ts","sourceRoot":"","sources":["../src/ActorTracking.ts"],"names":[],"mappings":"AACA,OAAO,EAA4D,KAAK,kBAAkB,EAAC,KAAK,uBAAuB,EAAC,MAAM,mBAAmB,CAAC;AAClJ,OAAO,KAAK,EAAC,qBAAqB,EAAC,MAAM,yBAAyB,CAAC;AAEnE,6EAA6E;AAC7E,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAC,CAAC,CAAC;IAAC,QAAQ,EAAC,MAAM,CAAC;IAAC,QAAQ,EAAC,MAAM,CAAC;IAAC,OAAO,EAAC,MAAM,CAAC;IAAC,YAAY,EAAC,MAAM,CAAC;CAClF;AACD,MAAM,WAAW,mBAAoB,SAAQ,oBAAoB;IAC/D,SAAS,EAAC,iBAAiB,CAAC;IAAC,KAAK,EAAC,MAAM,CAAC;IAAC,WAAW,EAAC,MAAM,CAAC;IAAC,aAAa,EAAC,MAAM,CAAC;IACpF,WAAW,EAAC,MAAM,CAAC,MAAM,EAAC,MAAM,CAAC,CAAC;IAAC,MAAM,EAAC,MAAM,CAAC;IAAC,aAAa,CAAC,EAAC,uBAAuB,CAAC;IACzF,UAAU,EAAC,OAAO,GAAC,WAAW,GAAC,WAAW,GAAC,eAAe,GAAC,gBAAgB,CAAC;IAC5E,MAAM,EAAC,KAAK,CAAC;QAAC,cAAc,EAAC,MAAM,CAAC;QAAA,KAAK,EAAC,qBAAqB,CAAA;KAAC,CAAC,CAAC;IAClE,WAAW,EAAC,MAAM,EAAE,CAAC;IAAC,WAAW,EAAC,qBAAqB,EAAE,CAAC;CAC3D;AAaD,eAAO,MAAM,gBAAgB,GAAE,OAAM,OAAO,KAAE,MAAwC,CAAC;AACvF,eAAO,MAAM,cAAc,GAAE,OAAM,OAAO,WACa,CAAC;AACxD,wBAAgB,4BAA4B,CAAC,KAAK,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a,EAAC,MAAM,CAAC;IAAC,YAAY,EAAC,MAAM,CAAC;IAAC,MAAM,EAAC,MAAM,CAAC;IACzD,GAAG,EAAC;QAAC,CAAC,EAAC,MAAM,CAAC;QAAA,CAAC,EAAC,MAAM,CAAC;QAAA,KAAK,EAAC,MAAM,CAAC;QAAA,MAAM,EAAC,MAAM,CAAA;KAAC,CAAC;IAAC,UAAU,EAAC,MAAM,CAAC;IACtE,IAAI,EAAC,aAAa,GAAC,IAAI,CAAC;CACzB;AAWD,mGAAmG;AACnG,wBAAgB,sBAAsB,CAAC,KAAK,EAAC,OAAO,EAAC,QAAQ,EAAC,mBAAmB,GAAE,gBAAgB,EAAE,CAqBpG"}
@@ -4,6 +4,7 @@ exports.actorProofHash = exports.actorProofSource = void 0;
4
4
  exports.validateActorTrackingRequest = validateActorTrackingRequest;
5
5
  exports.validateActorIdentity = validateActorIdentity;
6
6
  exports.parseActorTrackingResult = parseActorTrackingResult;
7
+ exports.parseActorTrackRecords = parseActorTrackRecords;
7
8
  const crypto_1 = require("crypto");
8
9
  const ActorAppearance_1 = require("./ActorAppearance");
9
10
  const id = /^[a-zA-Z0-9][a-zA-Z0-9_.-]{0,127}$/;
@@ -94,4 +95,43 @@ function parseActorTrackingResult(value, request, jpeg, modelHashes, detections,
94
95
  }
95
96
  return JSON.parse(JSON.stringify(v));
96
97
  }
98
+ const finite = (v) => typeof v === 'number' && Number.isFinite(v);
99
+ function parseFaceSlot(value) {
100
+ if (value === null)
101
+ return null;
102
+ const v = value;
103
+ if (!keys(v, 'capturedAtMs,dims,frameId,modelId,modelSha256,quality,vector') || !isId(v.modelId) || !isSha(v.modelSha256)
104
+ || !isId(v.frameId) || !Number.isSafeInteger(v.capturedAtMs) || v.capturedAtMs < 0 || !finite(v.quality) || v.quality < 0 || v.quality > 1
105
+ || !Array.isArray(v.vector) || v.vector.length < 1 || v.vector.length > 1024 || v.dims !== v.vector.length
106
+ || !v.vector.every(finite))
107
+ throw Error('Invalid actor face slot');
108
+ return { ...v, vector: [...v.vector] };
109
+ }
110
+ /** Records for the tracked frame: one per live actor of its epoch, each observed actor current. */
111
+ function parseActorTrackRecords(value, tracking) {
112
+ if (!Array.isArray(value) || value.length > 256)
113
+ throw Error('Invalid actor track records');
114
+ const seen = new Set();
115
+ const records = value.map((entry) => {
116
+ const v = entry;
117
+ if (!keys(v, 'actorId,box,confidence,epoch,face,firstSeenAtMs,frames,kind,lastSeenAtMs,version') || v.version !== 1
118
+ || v.kind !== 'person' || !isId(v.actorId) || v.epoch !== tracking.epoch || seen.has(v.actorId)
119
+ || !Number.isSafeInteger(v.firstSeenAtMs) || !Number.isSafeInteger(v.lastSeenAtMs) || v.firstSeenAtMs < 0
120
+ || v.firstSeenAtMs > v.lastSeenAtMs || v.lastSeenAtMs > tracking.capturedAtMs
121
+ || !Number.isSafeInteger(v.frames) || v.frames < 1 || !finite(v.confidence) || v.confidence < 0 || v.confidence > 1
122
+ || !keys(v.box, 'height,width,x,y') || ![v.box.x, v.box.y, v.box.width, v.box.height].every(finite)
123
+ || v.box.width <= 0 || v.box.height <= 0)
124
+ throw Error('Invalid actor track record');
125
+ seen.add(v.actorId);
126
+ return { ...v, box: { ...v.box }, face: parseFaceSlot(v.face) };
127
+ });
128
+ for (const { actor } of tracking.actors) {
129
+ const record = records.find((r) => r.actorId === actor.id);
130
+ if (!record || record.lastSeenAtMs !== tracking.capturedAtMs)
131
+ throw Error('Observed actor has no current track record');
132
+ }
133
+ if (tracking.endedActors.some((a) => seen.has(a.id)))
134
+ throw Error('Ended actor still has a track record');
135
+ return records;
136
+ }
97
137
  //# sourceMappingURL=ActorTracking.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ActorTracking.js","sourceRoot":"","sources":["../src/ActorTracking.ts"],"names":[],"mappings":";;;AA8BA,oEAMC;AACD,sDAKC;AAED,4DA4CC;AAxFD,mCAAkC;AAClC,uDAAkJ;AAclJ,MAAM,EAAE,GAAC,oCAAoC,CAAC;AAC9C,MAAM,GAAG,GAA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