safari-mcp 2.11.8 โ†’ 2.11.9

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 (3) hide show
  1. package/README.md +1 -1
  2. package/package.json +1 -1
  3. package/safari.js +17 -7
package/README.md CHANGED
@@ -46,7 +46,7 @@ Your AI drives the **Safari you're already logged into** โ€” Gmail, GitHub, Ahre
46
46
 
47
47
  Native WebKit. ~60% less CPU. Background operation. 80 tools. One `npx` command. macOS only.
48
48
 
49
- > ๐Ÿ“ฐ **Featured on HackerNoon:** [I Had to Reverse-Engineer React, Shadow DOM, and CSP to Automate Safari Without Chrome](https://hackernoon.com/i-had-to-reverse-engineer-react-shadow-dom-and-csp-to-automate-safari-without-chrome)
49
+ > ๐Ÿ“ฐ **Featured on freeCodeCamp:** [How to Connect Your AI Coding Agent to a Browser on macOS](https://www.freecodecamp.org/news/how-to-connect-your-ai-coding-agent-to-a-browser-on-macos/) ยท [HackerNoon: Reverse-Engineering React, Shadow DOM, and CSP](https://hackernoon.com/i-had-to-reverse-engineer-react-shadow-dom-and-csp-to-automate-safari-without-chrome)
50
50
 
51
51
  ---
52
52
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "safari-mcp",
3
- "version": "2.11.8",
3
+ "version": "2.11.9",
4
4
  "mcpName": "io.github.achiya-automation/safari-mcp",
5
5
  "description": "Safari browser automation for AI agents โ€” native macOS, zero Chrome overhead. 80 tools via AppleScript + JavaScript.",
6
6
  "type": "module",
package/safari.js CHANGED
@@ -307,13 +307,23 @@ if (SAFARI_PROFILE) {
307
307
 
308
308
  // Initialize profile window at startup (ES module top-level await)
309
309
  if (SAFARI_PROFILE) {
310
- await new Promise(r => setTimeout(r, 50)); // Let helper process initialize
311
- await refreshTargetWindow(true);
312
- if (_targetWindowRef) {
313
- _logProfile(`Startup: Profile "${SAFARI_PROFILE}" โ†’ targeting ${_targetWindowRef}`);
314
- } else {
315
- _logProfile(`WARNING: Profile "${SAFARI_PROFILE}" window NOT found at startup`);
316
- }
310
+ // Run profile-window detection off the critical path so module init โ€” and
311
+ // therefore the MCP initialize handshake โ€” completes immediately. Tool calls
312
+ // that arrive before this finishes already trigger lazy refresh via
313
+ // getTargetWindowRef(), so correctness is preserved.
314
+ // Why this matters: a blocking `await refreshTargetWindow(true)` here could
315
+ // run >30s when Safari was busy or AppleScript was stalled, tripping Claude
316
+ // Code's 30s MCP timeout and leaving the conversation's tool catalog without
317
+ // safari tools until a new conversation is started.
318
+ (async () => {
319
+ await new Promise(r => setTimeout(r, 50)); // Let helper process initialize
320
+ await refreshTargetWindow(true);
321
+ if (_targetWindowRef) {
322
+ _logProfile(`Startup: Profile "${SAFARI_PROFILE}" โ†’ targeting ${_targetWindowRef}`);
323
+ } else {
324
+ _logProfile(`WARNING: Profile "${SAFARI_PROFILE}" window NOT found at startup`);
325
+ }
326
+ })();
317
327
  }
318
328
 
319
329
  // Detect stale window ID errors and invalidate cache