@coworker-jp/aidr 0.1.296 → 0.1.298

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 (2) hide show
  1. package/package.json +1 -1
  2. package/src/templates.mjs +27 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coworker-jp/aidr",
3
- "version": "0.1.296",
3
+ "version": "0.1.298",
4
4
  "description": "AIDR setup CLI - installs ai-scanner hooks for 19+ AI coding agents",
5
5
  "type": "module",
6
6
  "bin": {
package/src/templates.mjs CHANGED
@@ -230,9 +230,34 @@ fi
230
230
  # only ever describes the machine's CURRENT state.
231
231
  rm -f "$UNSCANNED_STAMP"
232
232
 
233
- # Binary exists — throttled self-update check
233
+ # Binary exists — throttled self-update check.
234
+ #
235
+ # The self-update goes to the license server BAKED INTO the binary, not to
236
+ # DOWNLOAD_BASE. So a binary built for another environment keeps updating itself
237
+ # from that environment forever: its key is rejected, detection logs are refused
238
+ # with 403, and the batch is discarded. Nothing about that is visible here —
239
+ # the hook is fail-open, so the session still looks protected (issue #1860).
240
+ #
241
+ # Two things follow, and they are separate:
242
+ # 1. If the binary names a DIFFERENT license server than the one this
243
+ # installation downloads from, no key this installation has can ever
244
+ # license it. Re-download from DOWNLOAD_BASE — that is the only path back.
245
+ # A missing/odd "version" output leaves the binary alone (fail-open), but
246
+ # says so, because "we did not check" must not read as "it is fine".
247
+ # 2. Do not swallow the update result. A failed self-update is a fact the
248
+ # operator can act on; "|| true" turned it into silence.
234
249
  if should_check_update; then
235
- "$BIN" update 2>/dev/null || true
250
+ want_host=$(printf '%s' "$DOWNLOAD_BASE" | sed -E 's#^[a-z]+://([^/]+).*#\\1#')
251
+ have_host=$("$BIN" version 2>/dev/null | sed -n 's#^server: [a-z]*://\\([^/]*\\).*#\\1#p' | head -1)
252
+ if [ -n "$have_host" ] && [ -n "$want_host" ] && [ "$have_host" != "$want_host" ]; then
253
+ echo "ai-scanner: the installed binary talks to $have_host, but this installation provisions from $want_host, so its access key can never be accepted (detection logs are refused and discarded). Re-downloading the matching binary." >&2
254
+ download_binary "\${DOWNLOAD_BASE}/\${PLATFORM_SLUG}" || \\
255
+ echo "ai-scanner: could not replace the mismatched binary: \${UNVERIFIED_REASON:-the download failed}. Scanning continues locally, but detection logs will keep being refused. Re-run the installer, or contact your IT administrator with this message." >&2
256
+ elif [ -z "$have_host" ]; then
257
+ echo "ai-scanner: could not read which license server the installed binary uses, so the environment match was NOT checked. If detection logs are being refused, re-run the installer." >&2
258
+ fi
259
+ "$BIN" update 2>/dev/null || \\
260
+ echo "ai-scanner: the scanner could not update itself just now. It keeps scanning with the rules it already has; if this repeats, re-run the installer or contact your IT administrator." >&2
236
261
  date +%s > "$PULL_STAMP"
237
262
  fi
238
263