yaver-cli 1.99.445 → 1.99.447

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yaver-cli",
3
- "version": "1.99.445",
3
+ "version": "1.99.447",
4
4
  "mcpName": "io.github.yaver-io/yaver",
5
5
  "description": "Unified npm bootstrap for the Yaver agent, SDK injection, and local-first developer runtime",
6
6
  "bin": {
@@ -237,23 +237,17 @@ async function downloadAndCacheAgent(asset, { quiet }) {
237
237
  if (process.platform !== 'win32') {
238
238
  fs.chmodSync(binaryPath, 0o755);
239
239
  }
240
- // Proactively strip macOS quarantine + re-adhoc-sign on
241
- // freshly-downloaded binaries. Without this:
242
- // - Gatekeeper SIGKILLs the first exec because Yaver release
243
- // tarballs are not notarized (adhoc-signed at link time only).
244
- // - If the Go linker's adhoc signature didn't survive the tarball
245
- // round-trip, the kernel refuses to load it ("load code
246
- // signature error 2"). codesign --force --sign - rebuilds a
247
- // valid adhoc signature against the current bytes.
248
- // Doing both here means the happy path never sees SIGKILL in the
249
- // first place.
240
+ // Strip quarantine, but preserve a valid release signature. Since CLI
241
+ // 1.99.446 the macOS artifacts are Developer ID signed and notarized in
242
+ // release-cli.yml. The old unconditional `codesign --sign -` below erased
243
+ // that identity after every download and silently downgraded the installed
244
+ // binary to ad-hoc. Only repair the signature when verification proves the
245
+ // archive produced an invalid Mach-O.
250
246
  if (process.platform === 'darwin') {
251
247
  try {
252
248
  spawnSync('xattr', ['-dr', 'com.apple.quarantine', binaryPath], { stdio: 'ignore' });
253
249
  } catch (_err) {}
254
- try {
255
- spawnSync('codesign', ['--force', '--sign', '-', binaryPath], { stdio: 'ignore' });
256
- } catch (_err) {}
250
+ ensureValidMacSignature(binaryPath);
257
251
  }
258
252
  // Sanity-check the extracted binary. A truncated tarball or an
259
253
  // HTML error page saved as ".tar.gz" can leave us with a file that
@@ -402,25 +396,14 @@ async function attemptSigkillRecovery(binaryPath, { quiet = false } = {}) {
402
396
  } catch (_err) {}
403
397
  try { fs.chmodSync(binaryPath, 0o755); } catch (_err) {}
404
398
 
405
- // 3. Re-adhoc-sign. When the agent's own self-update rewrites the
406
- // binary in place, the original adhoc signature no longer
407
- // matches the new contents and the kernel refuses to exec it
408
- // (dmesg: "load code signature error 2"). `codesign --force
409
- // --sign -` rebuilds the adhoc signature against the current
410
- // bytes, which is all the kernel needs to let exec proceed.
411
- try {
412
- const result = spawnSync('codesign', ['--force', '--sign', '-', binaryPath], {
413
- stdio: ['ignore', 'pipe', 'pipe'],
414
- encoding: 'utf8',
415
- });
416
- if (result.status === 0) {
417
- // Verify the resigned binary actually passes the kernel check
418
- // now. If codesign succeeded we're done — the retry will work.
419
- return 'resign-macos-adhoc';
420
- }
421
- // If codesign failed (e.g. missing developer tools), fall through
422
- // to the quarantine-only return below.
423
- } catch (_err) {}
399
+ // 3. Preserve a valid Developer ID signature. Only an actually invalid
400
+ // signature is replaced with an ad-hoc one. This keeps notarized release
401
+ // identity intact while retaining the self-heal for interrupted updates.
402
+ const signatureAction = ensureValidMacSignature(binaryPath);
403
+ if (signatureAction === 'preserve-valid-signature') {
404
+ return 'strip-macos-quarantine-preserve-signature';
405
+ }
406
+ if (signatureAction === 'resign-macos-adhoc') return signatureAction;
424
407
 
425
408
  return 'strip-macos-quarantine';
426
409
  }
@@ -746,10 +729,30 @@ async function extractTarball(archivePath, destDir) {
746
729
 
747
730
  module.exports = {
748
731
  ensureAgentBinary,
732
+ ensureValidMacSignature,
749
733
  resolveAgentInfo,
750
734
  runAgentCommand,
751
735
  };
752
736
 
737
+ function ensureValidMacSignature(binaryPath, spawnImpl = spawnSync) {
738
+ try {
739
+ const verified = spawnImpl('codesign', ['--verify', '--strict', binaryPath], {
740
+ stdio: ['ignore', 'pipe', 'pipe'],
741
+ encoding: 'utf8',
742
+ });
743
+ if (verified.status === 0) return 'preserve-valid-signature';
744
+ } catch (_err) {}
745
+
746
+ try {
747
+ const repaired = spawnImpl('codesign', ['--force', '--sign', '-', binaryPath], {
748
+ stdio: ['ignore', 'pipe', 'pipe'],
749
+ encoding: 'utf8',
750
+ });
751
+ if (repaired.status === 0) return 'resign-macos-adhoc';
752
+ } catch (_err) {}
753
+ return 'signature-repair-failed';
754
+ }
755
+
753
756
  function repoRoot() {
754
757
  return path.resolve(__dirname, '..', '..');
755
758
  }