@trillboards/edge-sdk 0.2.191 → 0.2.194
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.
- package/deploy/detector/pyproject.toml +1 -1
- package/deploy/detector/tests/test_detection_colors_wire.py +134 -0
- package/deploy/detector/trillboards_detector/_version.py +2 -2
- package/deploy/detector/trillboards_detector/colors.py +85 -0
- package/deploy/detector/trillboards_detector/server.py +27 -0
- package/deploy/macos/apply-update.sh +254 -104
- package/deploy/macos/ci/connector-stand-in.js +42 -0
- package/deploy/macos/ci/helper-stand-in.sh +23 -0
- package/deploy/macos/ci/launchd-matrix.js +39 -0
- package/deploy/macos/ci/lib.sh +339 -0
- package/deploy/macos/ci/test-field-self-update.sh +153 -0
- package/deploy/macos/ci/test-update-launchd-boundary.sh +260 -0
- package/dist/DetectionColors.d.ts +44 -0
- package/dist/DetectionColors.d.ts.map +1 -0
- package/dist/DetectionColors.js +51 -0
- package/dist/DetectionColors.js.map +1 -0
- package/dist/DetectorFields.d.ts +213 -0
- package/dist/DetectorFields.d.ts.map +1 -0
- package/dist/DetectorFields.js +205 -0
- package/dist/DetectorFields.js.map +1 -0
- package/dist/EdgeAgent.js +1 -1
- package/dist/LocalDetectorClient.d.ts +4 -1
- package/dist/LocalDetectorClient.d.ts.map +1 -1
- package/dist/LocalDetectorClient.js +24 -1
- package/dist/LocalDetectorClient.js.map +1 -1
- package/dist/RetainedFieldContract.d.ts +1 -1
- package/dist/RetainedFieldContract.d.ts.map +1 -1
- package/dist/RetainedFieldContract.js +8 -1
- package/dist/RetainedFieldContract.js.map +1 -1
- package/dist/ReviewModelUse.d.ts.map +1 -1
- package/dist/ReviewModelUse.js +4 -0
- package/dist/ReviewModelUse.js.map +1 -1
- package/dist/ScopedVlmReview.d.ts +41 -0
- package/dist/ScopedVlmReview.d.ts.map +1 -1
- package/dist/ScopedVlmReview.js +160 -8
- package/dist/ScopedVlmReview.js.map +1 -1
- package/dist/SensingProfileClient.d.ts +3 -0
- package/dist/SensingProfileClient.d.ts.map +1 -1
- package/dist/SensingProfileClient.js +2 -0
- package/dist/SensingProfileClient.js.map +1 -1
- package/dist/connectorUpdate.d.ts.map +1 -1
- package/dist/connectorUpdate.js +19 -0
- package/dist/connectorUpdate.js.map +1 -1
- package/dist/diagnose.d.ts +1 -1
- package/dist/diagnose.js +1 -1
- package/dist/localSensing.d.ts +8 -0
- package/dist/localSensing.d.ts.map +1 -1
- package/dist/localSensing.js +86 -4
- package/dist/localSensing.js.map +1 -1
- package/package.json +1 -1
- package/retained/ProfileAuthorityClient.cjs +2 -1
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
#
|
|
3
|
+
# test-update-launchd-boundary.sh — does the connector's own hand-off start the
|
|
4
|
+
# macOS update helper from inside its LaunchAgent, does the helper verify a
|
|
5
|
+
# published package with tools a customer Mac has, and does it outlive the
|
|
6
|
+
# connector it replaces?
|
|
7
|
+
#
|
|
8
|
+
# Every arm runs the REAL code from INSIDE com.trillboards.edge in the gui
|
|
9
|
+
# domain, on a runner whose developer tools are moved aside and proven absent,
|
|
10
|
+
# against a published, signed, notarized code-only package:
|
|
11
|
+
#
|
|
12
|
+
# 1 record how launchd treats the ways a LaunchAgent can start a helper,
|
|
13
|
+
# across the job's clean exit and a bootout of the job.
|
|
14
|
+
# 2 control the hand-off and helper every connector through 0.2.193 ships
|
|
15
|
+
# (published 0.2.140): the stage must NOT complete and must leave
|
|
16
|
+
# NO outcome. That is the field defect (run 41934336173); if it
|
|
17
|
+
# does not reproduce, this rig cannot prove the fix and says so.
|
|
18
|
+
# 3 subject the compiled connectorUpdateApplyMac.ts and this checkout's
|
|
19
|
+
# apply-update.sh: the stage verifies and completes.
|
|
20
|
+
# 4 subject a refused stage (wrong hash) and a lock left by a killed helper:
|
|
21
|
+
# the refusal is recorded in outcome.json, the stale lock is cleared.
|
|
22
|
+
# 5 subject the commit: the stand-in exits 0 like requestExit(); the helper
|
|
23
|
+
# outlives it and its own bootout of com.trillboards.edge, runs
|
|
24
|
+
# Installer, rolls back (this runner has no local AI, so the
|
|
25
|
+
# package's postinstall refuses), records why, and relaunches the
|
|
26
|
+
# LaunchAgent. The successful swap is test-field-self-update.sh.
|
|
27
|
+
# 6 subject a commit the helper refuses (staged version mismatch): recorded,
|
|
28
|
+
# and com.trillboards.edge comes back on the current version.
|
|
29
|
+
#
|
|
30
|
+
# Execute only on a fresh GitHub-hosted macOS runner.
|
|
31
|
+
set -u
|
|
32
|
+
if [ "${GITHUB_ACTIONS:-}" != true ] || [ "${RUNNER_OS:-}" != macOS ] || [ "${RUNNER_ENVIRONMENT:-}" != github-hosted ]; then
|
|
33
|
+
echo 'The launchd-boundary qualification registers LaunchAgents and moves Xcode; run it only on a fresh GitHub-hosted macOS runner' >&2
|
|
34
|
+
exit 2
|
|
35
|
+
fi
|
|
36
|
+
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
37
|
+
PKGROOT="$(cd "$HERE/../../.." && pwd)"
|
|
38
|
+
# shellcheck source=deploy/macos/ci/lib.sh
|
|
39
|
+
. "$HERE/lib.sh"
|
|
40
|
+
rig_init update-launchd-boundary
|
|
41
|
+
# Leave the machine as it was found: the field proof runs next in this job and
|
|
42
|
+
# must start from a Mac that has never had a connector.
|
|
43
|
+
boundary_cleanup() {
|
|
44
|
+
launchctl bootout "$EDGE_SERVICE" >/dev/null 2>&1 || true
|
|
45
|
+
pkill -f 'share/apply-update.sh' 2>/dev/null || true
|
|
46
|
+
rm -rf "$EDGE" "$UPD" "$HOME/Library/Trillboards/edge.previous" "$EDGE_PLIST"
|
|
47
|
+
rig_teardown
|
|
48
|
+
}
|
|
49
|
+
trap 'boundary_cleanup' EXIT
|
|
50
|
+
TYPESCRIPT="$PKGROOT/../../node_modules/typescript"
|
|
51
|
+
[ -d "$TYPESCRIPT" ] || { echo 'Run npm ci in trillboards-edge-sdk first: the subject arms compile connectorUpdateApplyMac.ts' >&2; exit 2; }
|
|
52
|
+
|
|
53
|
+
FAILURES=0
|
|
54
|
+
pass() { note "PASS - $*"; }
|
|
55
|
+
bad() { note "FAIL - $*"; FAILURES=$((FAILURES + 1)); }
|
|
56
|
+
record() { note "RECORD - $*"; }
|
|
57
|
+
|
|
58
|
+
# The released build every Mac in the field runs (0.2.140, 2026-09-17) and a
|
|
59
|
+
# published, notarized package to stage — both immutable, both pinned.
|
|
60
|
+
RELEASED_COMMIT='98629a19a90bad6d9af7f588d2249aee36dbe0e8'
|
|
61
|
+
RELEASED_SHA='264a9fcbd4038b253ba622339bf3ad4d9292dcc9cd1d3ca66276844d4bee04bb'
|
|
62
|
+
TARGET_VERSION='0.2.193'
|
|
63
|
+
TARGET_URL='https://screen.trillboards.com/connector/updates/c5f87bbdd536ce05699f5a7cbe6ebdd2cb6c80c4/trillboards-connector-macos-update.pkg'
|
|
64
|
+
TARGET_SHA='021f1aa63affc2e3da0051c595b33873d2d0b4fbbbe17deccb769414afeede25'
|
|
65
|
+
TARGET_SIZE='72778110'
|
|
66
|
+
|
|
67
|
+
curl -fsS --retry 3 -o "$OUT/released.pkg" "$ORIGIN/connector/updates/$RELEASED_COMMIT/trillboards-connector-macos-update.pkg"
|
|
68
|
+
[ "$(sha256_of "$OUT/released.pkg")" = "$RELEASED_SHA" ] || { bad 'the released 0.2.140 package does not match its pinned hash'; exit 1; }
|
|
69
|
+
/usr/sbin/pkgutil --expand-full "$OUT/released.pkg" "$OUT/released" >/dev/null
|
|
70
|
+
RELEASED_TREE="$(find "$OUT/released" -path '*Payload/Library/Trillboards/edge' -type d | head -1)"
|
|
71
|
+
[ -n "$RELEASED_TREE" ] || { bad 'could not expand the released package'; exit 1; }
|
|
72
|
+
|
|
73
|
+
# The subject: this checkout's applier, compiled with the repo's TypeScript.
|
|
74
|
+
mkdir -p "$OUT/subject"
|
|
75
|
+
node -e '
|
|
76
|
+
const ts = require(process.argv[1]); const fs = require("fs"); const path = require("path");
|
|
77
|
+
for (const name of ["connectorUpdateApply", "connectorUpdateApplyMac"]) {
|
|
78
|
+
const out = ts.transpileModule(fs.readFileSync(path.join(process.argv[2], name + ".ts"), "utf8"),
|
|
79
|
+
{ compilerOptions: { module: ts.ModuleKind.CommonJS, target: ts.ScriptTarget.ES2020, esModuleInterop: true } });
|
|
80
|
+
fs.writeFileSync(path.join(process.argv[3], name + ".js"), out.outputText);
|
|
81
|
+
}' "$TYPESCRIPT" "$PKGROOT/src" "$OUT/subject" || { bad 'could not compile the applier'; exit 1; }
|
|
82
|
+
|
|
83
|
+
# --- 0: what the released trust check needed (record, developer tools present)
|
|
84
|
+
curl -fsS --retry 3 -o "$OUT/target.pkg" "$ORIGIN/${TARGET_URL#https://screen.trillboards.com/}"
|
|
85
|
+
[ "$(sha256_of "$OUT/target.pkg")" = "$TARGET_SHA" ] || { bad 'the pinned target package does not match its hash'; exit 1; }
|
|
86
|
+
cp "$OUT/target.pkg" "$OUT/target.pkg.download"
|
|
87
|
+
for f in target.pkg target.pkg.download; do
|
|
88
|
+
out="$(run_bounded 60 /usr/bin/xcrun stapler validate "$OUT/$f" 2>&1)"; rc=$?
|
|
89
|
+
record "0: with Xcode, xcrun stapler validate $f -> exit $rc: $(printf '%s' "$out" | tr '\n' ' ' | cut -c1-200)"
|
|
90
|
+
done
|
|
91
|
+
rm -f "$OUT/target.pkg.download"
|
|
92
|
+
|
|
93
|
+
hide_developer_tools
|
|
94
|
+
prove_developer_tools_hidden || { bad 'developer tools are still reachable; this is not a customer Mac'; exit 1; }
|
|
95
|
+
out="$(run_bounded 60 /usr/bin/xcrun stapler validate "$OUT/target.pkg" 2>&1)"; rc=$?
|
|
96
|
+
record "0: without developer tools, xcrun stapler validate target.pkg -> exit $rc: $(printf '%s' "$out" | head -1)"
|
|
97
|
+
for tool in "/usr/sbin/pkgutil --check-signature" "/usr/sbin/spctl --assess --type install -vv"; do
|
|
98
|
+
out="$($tool "$OUT/target.pkg" 2>&1)"; rc=$?
|
|
99
|
+
record "0: without developer tools, $tool -> exit $rc: $(printf '%s' "$out" | grep -E 'Status:|Notarization:|1\. |accepted|rejected|source=|origin=' | tr '\n' '|' | cut -c1-400)"
|
|
100
|
+
done
|
|
101
|
+
|
|
102
|
+
# An install tree at the one path the helper accepts. $1 = helper script.
|
|
103
|
+
lay_down_install() {
|
|
104
|
+
launchctl bootout "$EDGE_SERVICE" >/dev/null 2>&1 || true
|
|
105
|
+
launchctl bootout "gui/$(id -u)/com.trillboards.edge.update" >/dev/null 2>&1 || true
|
|
106
|
+
rm -rf "$EDGE" "$UPD" "$HOME/Library/Trillboards/edge.previous"
|
|
107
|
+
mkdir -p "$(dirname "$EDGE")"
|
|
108
|
+
/usr/bin/ditto "$RELEASED_TREE" "$EDGE"
|
|
109
|
+
cp "$1" "$EDGE/share/apply-update.sh"
|
|
110
|
+
}
|
|
111
|
+
# com.trillboards.edge running the stand-in under the shipped node, with the
|
|
112
|
+
# LaunchAgent shape pairing installs (KeepAlive only on an unsuccessful exit).
|
|
113
|
+
start_stand_in() { # dir applier.js phase sha
|
|
114
|
+
mkdir -p "$1"
|
|
115
|
+
rm -f "$1/connector.ran"
|
|
116
|
+
cat > "$EDGE_PLIST" <<PLIST
|
|
117
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
118
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
119
|
+
<plist version="1.0"><dict>
|
|
120
|
+
<key>Label</key><string>com.trillboards.edge</string>
|
|
121
|
+
<key>ProgramArguments</key><array><string>$EDGE/bin/node</string><string>$HERE/connector-stand-in.js</string><string>$1</string><string>$2</string><string>$EDGE</string><string>$3</string><string>$TARGET_VERSION</string><string>$TARGET_URL</string><string>$4</string><string>$TARGET_SIZE</string><string>0.2.140</string></array>
|
|
122
|
+
<key>RunAtLoad</key><true/>
|
|
123
|
+
<key>KeepAlive</key><dict><key>SuccessfulExit</key><false/></dict>
|
|
124
|
+
<key>ThrottleInterval</key><integer>10</integer>
|
|
125
|
+
<key>ProcessType</key><string>Background</string>
|
|
126
|
+
<key>StandardOutPath</key><string>$1/agent.out.log</string>
|
|
127
|
+
<key>StandardErrorPath</key><string>$1/agent.err.log</string>
|
|
128
|
+
</dict></plist>
|
|
129
|
+
PLIST
|
|
130
|
+
launchctl bootstrap "gui/$(id -u)" "$EDGE_PLIST"
|
|
131
|
+
}
|
|
132
|
+
helper_running() { ps -axo command | grep -v grep | grep -q 'share/apply-update.sh'; }
|
|
133
|
+
wait_for() { # seconds condition...
|
|
134
|
+
local deadline=$(( $(date +%s) + $1 )); shift
|
|
135
|
+
while [ "$(date +%s)" -lt "$deadline" ]; do "$@" && return 0; sleep 2; done
|
|
136
|
+
"$@"
|
|
137
|
+
}
|
|
138
|
+
has_staged() { [ -f "$UPD/staged.json" ]; }
|
|
139
|
+
has_outcome() { [ -f "$UPD/outcome.json" ]; }
|
|
140
|
+
relaunched() { grep -q RELAUNCHED "$1/connector.log" 2>/dev/null; }
|
|
141
|
+
helper_lines() { /usr/bin/log show --start "$1" --style compact --predicate 'process == "logger" AND eventMessage CONTAINS "apply-update"' 2>/dev/null | grep apply-update | sed 's/^.*apply-update: / /'; }
|
|
142
|
+
|
|
143
|
+
# --- 1: launchd lifecycle (record) -------------------------------------------
|
|
144
|
+
matrix() { # name selfBootout
|
|
145
|
+
local d="$OUT/matrix-$1" label="com.trillboards.boundary.$1" f age
|
|
146
|
+
mkdir -p "$d"
|
|
147
|
+
cat > "$HOME/Library/LaunchAgents/$label.plist" <<PLIST
|
|
148
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
149
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
150
|
+
<plist version="1.0"><dict>
|
|
151
|
+
<key>Label</key><string>$label</string>
|
|
152
|
+
<key>ProgramArguments</key><array><string>$(command -v node)</string><string>$HERE/launchd-matrix.js</string><string>$d</string><string>$HERE/helper-stand-in.sh</string><string>$(id -u)</string><string>$label</string><string>$2</string></array>
|
|
153
|
+
<key>RunAtLoad</key><true/>
|
|
154
|
+
<key>KeepAlive</key><dict><key>SuccessfulExit</key><false/></dict>
|
|
155
|
+
<key>ProcessType</key><string>Background</string>
|
|
156
|
+
</dict></plist>
|
|
157
|
+
PLIST
|
|
158
|
+
launchctl bootstrap "gui/$(id -u)" "$HOME/Library/LaunchAgents/$label.plist"
|
|
159
|
+
sleep 32
|
|
160
|
+
[ "$2" = 1 ] || launchctl bootout "gui/$(id -u)/$label" >/dev/null 2>&1
|
|
161
|
+
sleep 6
|
|
162
|
+
for f in "$d"/*.hb; do
|
|
163
|
+
[ -f "$f" ] || continue
|
|
164
|
+
age=$(( $(date +%s) - $(stat -f %m "$f") ))
|
|
165
|
+
record "1 [$1]: helper started $(basename "$f" .hb): $( [ "$age" -le 4 ] && echo 'alive after' || echo "DEAD ${age}s before the end of" ) the job's exit at 8 s and $( [ "$2" = 1 ] && echo 'its own bootout of the job at 20 s' || echo 'a bootout of the job at 32 s' )"
|
|
166
|
+
done
|
|
167
|
+
for f in "$d"/*.log; do record "1 [$1]: $(basename "$f"): $(tr '\n' '|' < "$f" | cut -c1-300)"; done
|
|
168
|
+
launchctl bootout "gui/$(id -u)/$label" >/dev/null 2>&1 || true
|
|
169
|
+
launchctl bootout "gui/$(id -u)/$label.helper" >/dev/null 2>&1 || true
|
|
170
|
+
pkill -f "helper-stand-in.sh $d" 2>/dev/null || true
|
|
171
|
+
}
|
|
172
|
+
matrix outside 0
|
|
173
|
+
matrix self 1
|
|
174
|
+
|
|
175
|
+
# --- 2: the released hand-off and helper (control) ----------------------------
|
|
176
|
+
lay_down_install "$RELEASED_TREE/share/apply-update.sh"
|
|
177
|
+
since="$(date '+%Y-%m-%d %H:%M:%S')"
|
|
178
|
+
start_stand_in "$OUT/control" "$EDGE/lib/edge-sdk/dist/connectorUpdateApplyMac.js" stage "$TARGET_SHA"
|
|
179
|
+
wait_for 30 helper_running && record '2: the released hand-off started apply-update.sh from inside com.trillboards.edge'
|
|
180
|
+
wait_for 180 has_staged
|
|
181
|
+
sleep 5
|
|
182
|
+
record "2: helper said:"; helper_lines "$since" | while read -r l; do record " $l"; done
|
|
183
|
+
if ! has_staged && ! has_outcome && ! helper_running; then
|
|
184
|
+
pass '2 control: the released helper never staged a published notarized package on a stock Mac and left no outcome (the field defect, reproduced)'
|
|
185
|
+
else
|
|
186
|
+
bad "2 control: the released helper staged=$(has_staged && echo yes || echo no) outcome=$(has_outcome && echo yes || echo no) here, so this rig cannot reproduce the field defect"
|
|
187
|
+
fi
|
|
188
|
+
|
|
189
|
+
# --- 3: the compiled hand-off and this checkout's helper (subject, stage) ----
|
|
190
|
+
lay_down_install "$PKGROOT/deploy/macos/apply-update.sh"
|
|
191
|
+
start_stand_in "$OUT/stage" "$OUT/subject/connectorUpdateApplyMac.js" stage "$TARGET_SHA"
|
|
192
|
+
if wait_for 300 has_staged; then
|
|
193
|
+
pass "3: staged on a stock Mac: $(cat "$UPD/staged.json")"
|
|
194
|
+
grep -q 'Notarization: trusted by the Apple notary service' "$UPD/signature.txt" && grep -q '^source=Notarized Developer ID' "$UPD/signature.txt" \
|
|
195
|
+
&& pass '3: pkgutil and spctl both report a notarized Aethercorp Developer ID package' || bad '3: signature.txt lacks the notarization verdicts'
|
|
196
|
+
else
|
|
197
|
+
bad "3: the subject did not stage within 300 s (outcome: $(cat "$UPD/outcome.json" 2>/dev/null))"
|
|
198
|
+
fi
|
|
199
|
+
record "3: helper log: $(tr '\n' '|' < "$UPD/apply-update.log" 2>/dev/null | cut -c1-600)"
|
|
200
|
+
grep -q 'start: --stage .*started from com.trillboards.edge' "$UPD/apply-update.log" 2>/dev/null \
|
|
201
|
+
&& pass '3: the connector hand-off started the helper from inside com.trillboards.edge' \
|
|
202
|
+
|| bad '3: the helper log does not show a stage started from inside com.trillboards.edge'
|
|
203
|
+
|
|
204
|
+
# --- 4: refusal and a stale lock (subject) -----------------------------------
|
|
205
|
+
lay_down_install "$PKGROOT/deploy/macos/apply-update.sh"
|
|
206
|
+
mkdir -p "$UPD/lock" # what a killed helper leaves: no live holder
|
|
207
|
+
start_stand_in "$OUT/refusal" "$OUT/subject/connectorUpdateApplyMac.js" stage "$(printf 'f%.0s' $(seq 1 64))"
|
|
208
|
+
if wait_for 300 has_outcome && grep -q '"result":"rejected"' "$UPD/outcome.json" && grep -q 'SHA-256 mismatch' "$UPD/outcome.json"; then
|
|
209
|
+
pass "4: a refused stage is recorded: $(cat "$UPD/outcome.json")"
|
|
210
|
+
else
|
|
211
|
+
bad "4: no rejected outcome for a wrong hash (outcome: $(cat "$UPD/outcome.json" 2>/dev/null))"
|
|
212
|
+
fi
|
|
213
|
+
grep -q 'clearing a stale update lock' "$UPD/apply-update.log" 2>/dev/null \
|
|
214
|
+
&& pass '4: a lock with no live holder was cleared instead of refusing every later update' \
|
|
215
|
+
|| bad '4: the stale lock was not cleared'
|
|
216
|
+
has_staged && bad '4: a refused package was staged'
|
|
217
|
+
|
|
218
|
+
# --- 5: the commit (subject) -------------------------------------------------
|
|
219
|
+
lay_down_install "$PKGROOT/deploy/macos/apply-update.sh"
|
|
220
|
+
start_stand_in "$OUT/commit" "$OUT/subject/connectorUpdateApplyMac.js" full "$TARGET_SHA"
|
|
221
|
+
wait_for 300 grep -q 'commit() -> true' "$OUT/commit/connector.log" || bad "5: the stand-in never handed over: $(tail -3 "$OUT/commit/connector.log" 2>/dev/null)"
|
|
222
|
+
if wait_for 900 relaunched "$OUT/commit"; then
|
|
223
|
+
pass '5: com.trillboards.edge was relaunched after the hand-off'
|
|
224
|
+
else
|
|
225
|
+
bad '5: com.trillboards.edge was not relaunched within 15 minutes of the hand-off'
|
|
226
|
+
fi
|
|
227
|
+
wait_for 60 has_outcome
|
|
228
|
+
record "5: helper log: $(tr '\n' '|' < "$UPD/apply-update.log" 2>/dev/null | cut -c1-1200)"
|
|
229
|
+
if has_outcome && grep -q '"result":"failed"' "$UPD/outcome.json" && grep -q 'previous version 0.2.140 restored' "$UPD/outcome.json"; then
|
|
230
|
+
pass "5: the helper outlived the connector and its bootout, rolled back and recorded why: $(cat "$UPD/outcome.json")"
|
|
231
|
+
else
|
|
232
|
+
bad "5: unexpected commit outcome: $(cat "$UPD/outcome.json" 2>/dev/null)"
|
|
233
|
+
fi
|
|
234
|
+
[ "$(installed_version)" = '0.2.140' ] && pass '5: the previous install is back in place' || bad "5: installed $(installed_version) after rollback"
|
|
235
|
+
|
|
236
|
+
# --- 6: a commit the helper refuses still brings the connector back (subject) --
|
|
237
|
+
# The connector exits 0 when it hands over, and launchd restarts only an
|
|
238
|
+
# unsuccessful exit; a refusal that does not restart it stops sensing until the
|
|
239
|
+
# next login. The released helper did exactly that on every refusal path.
|
|
240
|
+
lay_down_install "$PKGROOT/deploy/macos/apply-update.sh"
|
|
241
|
+
mkdir -p "$UPD"
|
|
242
|
+
printf '{"version":"9.9.9","currentVersion":"0.2.140","sha256":"%s","sizeBytes":%s}\n' "$TARGET_SHA" "$TARGET_SIZE" > "$UPD/staged.json"
|
|
243
|
+
cp "$OUT/target.pkg" "$UPD/connector-update.pkg"
|
|
244
|
+
start_stand_in "$OUT/refused-commit" "$OUT/subject/connectorUpdateApplyMac.js" commit-staged "$TARGET_SHA"
|
|
245
|
+
if wait_for 300 relaunched "$OUT/refused-commit"; then
|
|
246
|
+
pass '6: after a refused commit com.trillboards.edge was relaunched on the current version'
|
|
247
|
+
else
|
|
248
|
+
bad "6: com.trillboards.edge stayed down after a refused commit ($(launchctl print "$EDGE_SERVICE" 2>&1 | grep -E 'state =' | head -1))"
|
|
249
|
+
fi
|
|
250
|
+
if has_outcome && grep -q '"result":"rejected"' "$UPD/outcome.json"; then
|
|
251
|
+
pass "6: the refusal is recorded: $(cat "$UPD/outcome.json")"
|
|
252
|
+
else
|
|
253
|
+
bad "6: no rejected outcome for a mismatched staged version: $(cat "$UPD/outcome.json" 2>/dev/null)"
|
|
254
|
+
fi
|
|
255
|
+
[ "$(installed_version)" = '0.2.140' ] || bad "6: the install changed on a refused commit ($(installed_version))"
|
|
256
|
+
|
|
257
|
+
collect_evidence
|
|
258
|
+
cp -R "$OUT"/control "$OUT"/stage "$OUT"/refusal "$OUT"/commit "$OUT"/refused-commit "$OUT/evidence/" 2>/dev/null || true
|
|
259
|
+
if [ "$FAILURES" -gt 0 ]; then note "$FAILURES launchd-boundary assertion(s) failed"; exit 1; fi
|
|
260
|
+
note 'PASS: the released helper fails silently on a stock Mac; the fixed hand-off stages, refuses loudly, and outlives the connector it replaces'
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The detector service's `detection_colors` task: the share of each confident
|
|
3
|
+
* person box whose pixels are a requested colour, measured on the original
|
|
4
|
+
* frame with Pillow's 8-bit HSV (deploy/detector/trillboards_detector/colors.py).
|
|
5
|
+
* No model and no decision: the connector turns the share into "this person
|
|
6
|
+
* wears the store's uniform".
|
|
7
|
+
*/
|
|
8
|
+
export interface DetectionColorsRequest {
|
|
9
|
+
version: 1;
|
|
10
|
+
minScore: number;
|
|
11
|
+
maxBoxes: number;
|
|
12
|
+
hue: Array<[number, number]>;
|
|
13
|
+
minSaturation: number;
|
|
14
|
+
minValue: number;
|
|
15
|
+
}
|
|
16
|
+
export interface DetectionColorsResult {
|
|
17
|
+
version: 1;
|
|
18
|
+
imageSha256: string;
|
|
19
|
+
frameSize: {
|
|
20
|
+
width: number;
|
|
21
|
+
height: number;
|
|
22
|
+
};
|
|
23
|
+
request: DetectionColorsRequest;
|
|
24
|
+
people: Array<{
|
|
25
|
+
detectionIndex: number;
|
|
26
|
+
fraction: number;
|
|
27
|
+
}>;
|
|
28
|
+
}
|
|
29
|
+
export declare const MAX_COLOR_BOXES = 32;
|
|
30
|
+
export declare function validateDetectionColorsRequest(value: unknown): DetectionColorsRequest;
|
|
31
|
+
/** The service's own box selection: person boxes at or above minScore, highest score first. */
|
|
32
|
+
export declare function colorBoxIndices(detections: ReadonlyArray<{
|
|
33
|
+
label: string;
|
|
34
|
+
confidence: number;
|
|
35
|
+
}>, request: DetectionColorsRequest): number[];
|
|
36
|
+
/** Exactly the eligible people of this original frame, each with a share in [0,1]. */
|
|
37
|
+
export declare function parseDetectionColorsResult(value: unknown, request: DetectionColorsRequest, jpeg: Buffer, originalSize: {
|
|
38
|
+
width: number;
|
|
39
|
+
height: number;
|
|
40
|
+
}, detections: ReadonlyArray<{
|
|
41
|
+
label: string;
|
|
42
|
+
confidence: number;
|
|
43
|
+
}>): DetectionColorsResult;
|
|
44
|
+
//# sourceMappingURL=DetectionColors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DetectionColors.d.ts","sourceRoot":"","sources":["../src/DetectionColors.ts"],"names":[],"mappings":"AAGA;;;;;;GAMG;AACH,MAAM,WAAW,sBAAsB;IACrC,OAAO,EAAC,CAAC,CAAC;IAAC,QAAQ,EAAC,MAAM,CAAC;IAAC,QAAQ,EAAC,MAAM,CAAC;IAC5C,GAAG,EAAC,KAAK,CAAC,CAAC,MAAM,EAAC,MAAM,CAAC,CAAC,CAAC;IAAC,aAAa,EAAC,MAAM,CAAC;IAAC,QAAQ,EAAC,MAAM,CAAC;CACnE;AACD,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAC,CAAC,CAAC;IAAC,WAAW,EAAC,MAAM,CAAC;IAAC,SAAS,EAAC;QAAC,KAAK,EAAC,MAAM,CAAC;QAAA,MAAM,EAAC,MAAM,CAAA;KAAC,CAAC;IACtE,OAAO,EAAC,sBAAsB,CAAC;IAC/B,MAAM,EAAC,KAAK,CAAC;QAAC,cAAc,EAAC,MAAM,CAAC;QAAA,QAAQ,EAAC,MAAM,CAAA;KAAC,CAAC,CAAC;CACvD;AACD,eAAO,MAAM,eAAe,KAAG,CAAC;AAKhC,wBAAgB,8BAA8B,CAAC,KAAK,EAAC,OAAO,GAAE,sBAAsB,CAUnF;AAED,+FAA+F;AAC/F,wBAAgB,eAAe,CAAC,UAAU,EAAC,aAAa,CAAC;IAAC,KAAK,EAAC,MAAM,CAAC;IAAA,UAAU,EAAC,MAAM,CAAA;CAAC,CAAC,EACxF,OAAO,EAAC,sBAAsB,GAAE,MAAM,EAAE,CAKzC;AAED,sFAAsF;AACtF,wBAAgB,0BAA0B,CAAC,KAAK,EAAC,OAAO,EAAC,OAAO,EAAC,sBAAsB,EAAC,IAAI,EAAC,MAAM,EACjG,YAAY,EAAC;IAAC,KAAK,EAAC,MAAM,CAAC;IAAA,MAAM,EAAC,MAAM,CAAA;CAAC,EAAC,UAAU,EAAC,aAAa,CAAC;IAAC,KAAK,EAAC,MAAM,CAAC;IAAA,UAAU,EAAC,MAAM,CAAA;CAAC,CAAC,GAAE,qBAAqB,CAe5H"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MAX_COLOR_BOXES = void 0;
|
|
4
|
+
exports.validateDetectionColorsRequest = validateDetectionColorsRequest;
|
|
5
|
+
exports.colorBoxIndices = colorBoxIndices;
|
|
6
|
+
exports.parseDetectionColorsResult = parseDetectionColorsResult;
|
|
7
|
+
const crypto_1 = require("crypto");
|
|
8
|
+
const util_1 = require("util");
|
|
9
|
+
exports.MAX_COLOR_BOXES = 32;
|
|
10
|
+
const keys = (v, want) => !!v && typeof v === 'object' && !Array.isArray(v) && Object.keys(v).sort().join(',') === want;
|
|
11
|
+
const finite = (v) => typeof v === 'number' && Number.isFinite(v);
|
|
12
|
+
const byte = (v) => Number.isSafeInteger(v) && v >= 0 && v <= 255;
|
|
13
|
+
function validateDetectionColorsRequest(value) {
|
|
14
|
+
const v = value;
|
|
15
|
+
if (!keys(v, 'hue,maxBoxes,minSaturation,minScore,minValue,version') || v.version !== 1
|
|
16
|
+
|| !finite(v.minScore) || v.minScore <= 0 || v.minScore > 1
|
|
17
|
+
|| !Number.isSafeInteger(v.maxBoxes) || v.maxBoxes < 1 || v.maxBoxes > exports.MAX_COLOR_BOXES
|
|
18
|
+
|| !byte(v.minSaturation) || !byte(v.minValue)
|
|
19
|
+
|| !Array.isArray(v.hue) || v.hue.length < 1 || v.hue.length > 4
|
|
20
|
+
|| v.hue.some(r => !Array.isArray(r) || r.length !== 2 || !byte(r[0]) || !byte(r[1]) || r[0] > r[1]))
|
|
21
|
+
throw Error('Invalid detection colour request');
|
|
22
|
+
return JSON.parse(JSON.stringify(v));
|
|
23
|
+
}
|
|
24
|
+
/** The service's own box selection: person boxes at or above minScore, highest score first. */
|
|
25
|
+
function colorBoxIndices(detections, request) {
|
|
26
|
+
return detections.map((d, index) => ({ d, index }))
|
|
27
|
+
.filter(({ d }) => d.label === 'person' && d.confidence >= request.minScore)
|
|
28
|
+
.sort((a, b) => b.d.confidence - a.d.confidence || a.index - b.index)
|
|
29
|
+
.slice(0, request.maxBoxes).map(e => e.index);
|
|
30
|
+
}
|
|
31
|
+
/** Exactly the eligible people of this original frame, each with a share in [0,1]. */
|
|
32
|
+
function parseDetectionColorsResult(value, request, jpeg, originalSize, detections) {
|
|
33
|
+
validateDetectionColorsRequest(request);
|
|
34
|
+
const v = value;
|
|
35
|
+
if (!keys(v, 'frameSize,imageSha256,people,request,version') || v.version !== 1
|
|
36
|
+
|| v.imageSha256 !== (0, crypto_1.createHash)('sha256').update(jpeg).digest('hex')
|
|
37
|
+
|| !keys(v.frameSize, 'height,width') || v.frameSize.width !== originalSize.width
|
|
38
|
+
|| v.frameSize.height !== originalSize.height || !(0, util_1.isDeepStrictEqual)(v.request, request)
|
|
39
|
+
|| !Array.isArray(v.people))
|
|
40
|
+
throw Error('Invalid colour proof for the original detected frame');
|
|
41
|
+
const eligible = colorBoxIndices(detections, request);
|
|
42
|
+
if (v.people.length !== eligible.length)
|
|
43
|
+
throw Error('Colours do not cover exactly the confident people');
|
|
44
|
+
v.people.forEach((row, i) => {
|
|
45
|
+
if (!keys(row, 'detectionIndex,fraction') || row.detectionIndex !== eligible[i]
|
|
46
|
+
|| !finite(row.fraction) || row.fraction < 0 || row.fraction > 1)
|
|
47
|
+
throw Error('Invalid detection colour association');
|
|
48
|
+
});
|
|
49
|
+
return JSON.parse(JSON.stringify(v));
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=DetectionColors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DetectionColors.js","sourceRoot":"","sources":["../src/DetectionColors.ts"],"names":[],"mappings":";;;AAwBA,wEAUC;AAGD,0CAMC;AAGD,gEAgBC;AA9DD,mCAAkC;AAClC,+BAAuC;AAkB1B,QAAA,eAAe,GAAC,EAAE,CAAC;AAChC,MAAM,IAAI,GAAC,CAAC,CAAS,EAAC,IAAW,EAAC,EAAE,CAAA,CAAC,CAAC,CAAC,IAAE,OAAO,CAAC,KAAG,QAAQ,IAAE,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,IAAE,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,KAAG,IAAI,CAAC;AACxH,MAAM,MAAM,GAAC,CAAC,CAAS,EAAa,EAAE,CAAA,OAAO,CAAC,KAAG,QAAQ,IAAE,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;AAC9E,MAAM,IAAI,GAAC,CAAC,CAAS,EAAC,EAAE,CAAA,MAAM,CAAC,aAAa,CAAC,CAAC,CAAC,IAAG,CAAY,IAAE,CAAC,IAAG,CAAY,IAAE,GAAG,CAAC;AAEtF,SAAgB,8BAA8B,CAAC,KAAa;IAC1D,MAAM,CAAC,GAAC,KAA+B,CAAC;IACxC,IAAG,CAAC,IAAI,CAAC,CAAC,EAAC,sDAAsD,CAAC,IAAE,CAAC,CAAC,OAAO,KAAG,CAAC;WAC7E,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAE,CAAC,CAAC,QAAQ,IAAE,CAAC,IAAE,CAAC,CAAC,QAAQ,GAAC,CAAC;WAChD,CAAC,MAAM,C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GAAG,EAAC,CAAC,EAAC,EAAE;QACxB,IAAG,CAAC,IAAI,CAAC,GAAG,EAAC,yBAAyB,CAAC,IAAE,GAAG,CAAC,cAAc,KAAG,QAAQ,CAAC,CAAC,CAAC;eACrE,CAAC,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAE,GAAG,CAAC,QAAQ,GAAC,CAAC,IAAE,GAAG,CAAC,QAAQ,GAAC,CAAC;YAAC,MAAM,KAAK,CAAC,sCAAsC,CAAC,CAAC;IAChH,CAAC,CAAC,CAAC;IACH,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;AACvC,CAAC"}
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
import type { Detection } from './LocalDetectorClient';
|
|
2
|
+
import type { DetectionColorsRequest, DetectionColorsResult } from './DetectionColors';
|
|
3
|
+
import { type NormalizedPoint } from './zoneContainment';
|
|
4
|
+
/**
|
|
5
|
+
* Declared website questions the box's own detector answers on the ORIGINAL
|
|
6
|
+
* frame, so the language model is not asked on every frame. Server-selected per
|
|
7
|
+
* camera (retained profile `detectorFields`, CCTV_DETECTOR_FIELDS_SCREENS) and
|
|
8
|
+
* pinned: every number below is the one measured. The question stays declared;
|
|
9
|
+
* only who answers it changes.
|
|
10
|
+
*
|
|
11
|
+
* Measured 2026-11-04 on the Texas store (docs/runbooks/cctv-detector-tier.md
|
|
12
|
+
* section 5b), the pinned RF-DETR Medium through the detector service's own
|
|
13
|
+
* code; 324 ms detection per frame on 4 pinned cores, ~0.6 s on the Texas box:
|
|
14
|
+
*
|
|
15
|
+
* unattended_customer_v1 paint counter, 3,153 reviewed frames (09:18-14:57),
|
|
16
|
+
* every person hand-labelled staff or customer. Per frame: 56 of 63
|
|
17
|
+
* customer-alone frames caught, 6 false (90% precision, 89% recall); 1
|
|
18
|
+
* route alert in 5.6 store hours. Gemma as deployed: 0 of 63.
|
|
19
|
+
* detected_labels_v1 the detector's raw object list for a profile's
|
|
20
|
+
* `detected_objects` raw-output field (Gemma answered [] on 56 of 63 frames
|
|
21
|
+
* with cars parked in them).
|
|
22
|
+
* vehicle_arrival_gate_v1 a parked-vehicle question Gemma still answers, asked
|
|
23
|
+
* only when a vehicle has newly stopped (or one left while the answer was
|
|
24
|
+
* yes) and reused otherwise: 109 questions in 12 store hours of parking-lot
|
|
25
|
+
* video instead of one on every reviewed frame.
|
|
26
|
+
*/
|
|
27
|
+
declare const RF_SHA = "8e8197112112b79d7cc5d0a94ecef659c05317a658aadc7c7643374c539d7615";
|
|
28
|
+
type Box = {
|
|
29
|
+
x: number;
|
|
30
|
+
y: number;
|
|
31
|
+
width: number;
|
|
32
|
+
height: number;
|
|
33
|
+
};
|
|
34
|
+
export interface UnattendedCustomerMethod {
|
|
35
|
+
field: string;
|
|
36
|
+
method: 'unattended_customer_v1';
|
|
37
|
+
minPersonConfidence: 0.25;
|
|
38
|
+
screenLabels: ['laptop', 'tv'];
|
|
39
|
+
screenContainment: 0.8;
|
|
40
|
+
maxPeople: 32;
|
|
41
|
+
uniform: {
|
|
42
|
+
hue: [[0, 10], [240, 255]];
|
|
43
|
+
minSaturation: 100;
|
|
44
|
+
minValue: 60;
|
|
45
|
+
staffFraction: 0.08;
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
export interface DetectedLabelsMethod {
|
|
49
|
+
field: string;
|
|
50
|
+
method: 'detected_labels_v1';
|
|
51
|
+
minConfidence: 0.5;
|
|
52
|
+
}
|
|
53
|
+
export interface VehicleArrivalGateMethod {
|
|
54
|
+
field: string;
|
|
55
|
+
method: 'vehicle_arrival_gate_v1';
|
|
56
|
+
vehicleLabels: ['bus', 'car', 'motorcycle', 'truck'];
|
|
57
|
+
minConfidence: 0.5;
|
|
58
|
+
minArea: 0.04;
|
|
59
|
+
sameVehicleIou: 0.6;
|
|
60
|
+
stationaryIou: 0.8;
|
|
61
|
+
minStationaryMs: 10000;
|
|
62
|
+
maxGapMs: 120000;
|
|
63
|
+
}
|
|
64
|
+
export type DetectorFieldMethod = UnattendedCustomerMethod | DetectedLabelsMethod | VehicleArrivalGateMethod;
|
|
65
|
+
export interface DetectorFieldsPolicy {
|
|
66
|
+
version: 1;
|
|
67
|
+
detector: {
|
|
68
|
+
modelId: 'rfdetr_medium';
|
|
69
|
+
format: 'onnx';
|
|
70
|
+
sha256: typeof RF_SHA;
|
|
71
|
+
};
|
|
72
|
+
fields: DetectorFieldMethod[];
|
|
73
|
+
}
|
|
74
|
+
/** Only the exact pinned methods; anything else is refused, never adapted. */
|
|
75
|
+
export declare function parseDetectorFields(value: unknown): DetectorFieldsPolicy | undefined;
|
|
76
|
+
/** One detector call serves every detector-answered question of the frame. */
|
|
77
|
+
export declare function detectorFieldsRequest(policy: DetectorFieldsPolicy): {
|
|
78
|
+
classes: string[];
|
|
79
|
+
minConfidence: number;
|
|
80
|
+
expectedModel: {
|
|
81
|
+
modelId: string;
|
|
82
|
+
sha256: string;
|
|
83
|
+
};
|
|
84
|
+
colors?: DetectionColorsRequest;
|
|
85
|
+
};
|
|
86
|
+
export declare const policySha256: (policy: DetectorFieldsPolicy) => string;
|
|
87
|
+
export interface UnattendedCustomerTrace {
|
|
88
|
+
method: 'unattended_customer_v1';
|
|
89
|
+
imageSha256: string;
|
|
90
|
+
policySha256: string;
|
|
91
|
+
/** Person boxes at or above the person bar; pictures are people inside a detected screen. */
|
|
92
|
+
people: number;
|
|
93
|
+
pictures: number[];
|
|
94
|
+
staff: Array<{
|
|
95
|
+
index: number;
|
|
96
|
+
fraction: number;
|
|
97
|
+
}>;
|
|
98
|
+
customers: Array<{
|
|
99
|
+
index: number;
|
|
100
|
+
fraction: number;
|
|
101
|
+
}>;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* A customer is in view and no staff member is: a person box that is not a
|
|
105
|
+
* picture on a screen and does not wear the store's uniform colour, and no box
|
|
106
|
+
* that does. Pure; the same inputs always give the same answer and trace.
|
|
107
|
+
*
|
|
108
|
+
* Staff are counted anywhere in the frame (a staff member at the far shelf is
|
|
109
|
+
* attending the floor); a drawn polygon limits only where a customer stands
|
|
110
|
+
* (box bottom-centre, as every zone rule here). The 60-second wait is the
|
|
111
|
+
* route's own wait/recheck, not this frame's answer.
|
|
112
|
+
*/
|
|
113
|
+
export declare function decideUnattendedCustomer(input: {
|
|
114
|
+
jpeg: Buffer;
|
|
115
|
+
policy: DetectorFieldsPolicy;
|
|
116
|
+
method: UnattendedCustomerMethod;
|
|
117
|
+
frame: {
|
|
118
|
+
width: number;
|
|
119
|
+
height: number;
|
|
120
|
+
};
|
|
121
|
+
detections: ReadonlyArray<Detection>;
|
|
122
|
+
colors: DetectionColorsResult;
|
|
123
|
+
region?: ReadonlyArray<NormalizedPoint>;
|
|
124
|
+
}): {
|
|
125
|
+
value: boolean;
|
|
126
|
+
trace: UnattendedCustomerTrace;
|
|
127
|
+
};
|
|
128
|
+
export interface DetectedLabelsTrace {
|
|
129
|
+
method: 'detected_labels_v1';
|
|
130
|
+
imageSha256: string;
|
|
131
|
+
policySha256: string;
|
|
132
|
+
labels: Array<{
|
|
133
|
+
label: string;
|
|
134
|
+
count: number;
|
|
135
|
+
maxConfidence: number;
|
|
136
|
+
}>;
|
|
137
|
+
}
|
|
138
|
+
/** The detector's own object list: every class it found at or above the bar, once. */
|
|
139
|
+
export declare function decideDetectedLabels(input: {
|
|
140
|
+
jpeg: Buffer;
|
|
141
|
+
policy: DetectorFieldsPolicy;
|
|
142
|
+
method: DetectedLabelsMethod;
|
|
143
|
+
detections: ReadonlyArray<Detection>;
|
|
144
|
+
}): {
|
|
145
|
+
value: string[];
|
|
146
|
+
trace: DetectedLabelsTrace;
|
|
147
|
+
};
|
|
148
|
+
/**
|
|
149
|
+
* The vehicles the remembered answer describes. One per camera field, in memory
|
|
150
|
+
* only: losing it costs one extra question, never a wrong answer.
|
|
151
|
+
*/
|
|
152
|
+
export interface VehicleGateMemory {
|
|
153
|
+
version: 1;
|
|
154
|
+
lastAtMs: number;
|
|
155
|
+
/** Every vehicle box of the previous frame and when it first stood there. */
|
|
156
|
+
tracks: Array<{
|
|
157
|
+
box: Box;
|
|
158
|
+
firstSeenAtMs: number;
|
|
159
|
+
}>;
|
|
160
|
+
/** The parked vehicles the answer covers; one unseen for under minStationaryMs is still parked. */
|
|
161
|
+
parked: Array<{
|
|
162
|
+
box: Box;
|
|
163
|
+
lastSeenAtMs: number;
|
|
164
|
+
}>;
|
|
165
|
+
answer: boolean;
|
|
166
|
+
answerFrom: {
|
|
167
|
+
imageSha256: string;
|
|
168
|
+
capturedAtMs: number;
|
|
169
|
+
} | null;
|
|
170
|
+
}
|
|
171
|
+
export interface VehicleGateTrace {
|
|
172
|
+
method: 'vehicle_arrival_gate_v1';
|
|
173
|
+
imageSha256: string;
|
|
174
|
+
policySha256: string;
|
|
175
|
+
action: 'no_vehicle' | 'no_parked_vehicle' | 'reuse' | 'ask';
|
|
176
|
+
vehicles: number;
|
|
177
|
+
stationary: number;
|
|
178
|
+
parked: number;
|
|
179
|
+
arrivals: number;
|
|
180
|
+
departures: number;
|
|
181
|
+
answerFrom: {
|
|
182
|
+
imageSha256: string;
|
|
183
|
+
capturedAtMs: number;
|
|
184
|
+
} | null;
|
|
185
|
+
}
|
|
186
|
+
export interface VehicleGatePlan {
|
|
187
|
+
ask: boolean;
|
|
188
|
+
value?: boolean;
|
|
189
|
+
trace: VehicleGateTrace;
|
|
190
|
+
/** The memory after this frame; `answer` is the model's answer when `ask`. */
|
|
191
|
+
commit: (answer?: boolean) => VehicleGateMemory;
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Ask the language model only when a vehicle has newly stopped (in the same
|
|
195
|
+
* place for minStationaryMs), or when a parked vehicle left while the answer was
|
|
196
|
+
* yes; otherwise reuse the answer for the vehicles still parked. No vehicle, or
|
|
197
|
+
* none parked, is a definite no: nothing parked can be parked backwards. A
|
|
198
|
+
* memory older than maxGapMs, or a frame not after it, starts afresh.
|
|
199
|
+
*/
|
|
200
|
+
export declare function planVehicleGate(input: {
|
|
201
|
+
jpeg: Buffer;
|
|
202
|
+
policy: DetectorFieldsPolicy;
|
|
203
|
+
method: VehicleArrivalGateMethod;
|
|
204
|
+
frame: {
|
|
205
|
+
width: number;
|
|
206
|
+
height: number;
|
|
207
|
+
};
|
|
208
|
+
detections: ReadonlyArray<Detection>;
|
|
209
|
+
capturedAtMs: number;
|
|
210
|
+
memory?: VehicleGateMemory;
|
|
211
|
+
}): VehicleGatePlan;
|
|
212
|
+
export {};
|
|
213
|
+
//# sourceMappingURL=DetectorFields.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DetectorFields.d.ts","sourceRoot":"","sources":["../src/DetectorFields.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,uBAAuB,CAAC;AACrD,OAAO,KAAK,EAAC,sBAAsB,EAAE,qBAAqB,EAAC,MAAM,mBAAmB,CAAC;AACrF,OAAO,EAAiB,KAAK,eAAe,EAAC,MAAM,mBAAmB,CAAC;AAEvE;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,QAAA,MAAM,MAAM,qEAAmE,CAAC;AAChF,KAAK,GAAG,GAAC;IAAC,CAAC,EAAC,MAAM,CAAC;IAAA,CAAC,EAAC,MAAM,CAAC;IAAA,KAAK,EAAC,MAAM,CAAC;IAAA,MAAM,EAAC,MAAM,CAAA;CAAC,CAAC;AAExD,MAAM,WAAW,wBAAwB;IACvC,KAAK,EAAC,MAAM,CAAC;IAAC,MAAM,EAAC,wBAAwB,CAAC;IAC9C,mBAAmB,EAAC,IAAI,CAAC;IAAC,YAAY,EAAC,CAAC,QAAQ,EAAC,IAAI,CAAC,CAAC;IAAC,iBAAiB,EAAC,GAAG,CAAC;IAAC,SAAS,EAAC,EAAE,CAAC;IAC5F,OAAO,EAAC;QAAC,GAAG,EAAC,CAAC,CAAC,CAAC,EAAC,EAAE,CAAC,EAAC,CAAC,GAAG,EAAC,GAAG,CAA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