conductor-remote 1.27.2 → 1.27.4

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/dist/index.html CHANGED
@@ -13,7 +13,7 @@
13
13
  <title>Conductor Remote</title>
14
14
  <!-- Runs before the module bundle so it can catch a stale shell that fails to boot. -->
15
15
  <script src="/self-heal.js"></script>
16
- <script type="module" crossorigin src="/assets/index-BK1VlcLX.js"></script>
16
+ <script type="module" crossorigin src="/assets/index-DgCZgSTk.js"></script>
17
17
  <link rel="stylesheet" crossorigin href="/assets/index-DnE5ulTu.css">
18
18
  <link rel="manifest" href="/manifest.webmanifest"></head>
19
19
  <body>
package/dist/sw.js CHANGED
@@ -1 +1 @@
1
- if(!self.define){let e,i={};const n=(n,s)=>(n=new URL(n+".js",s).href,i[n]||new Promise(i=>{if("document"in self){const e=document.createElement("script");e.src=n,e.onload=i,document.head.appendChild(e)}else e=n,importScripts(n),i()}).then(()=>{let e=i[n];if(!e)throw new Error(`Module ${n} didn’t register its module`);return e}));self.define=(s,r)=>{const o=e||("document"in self?document.currentScript.src:"")||location.href;if(i[o])return;let l={};const c=e=>n(e,o),t={module:{uri:o},exports:l,require:c};i[o]=Promise.all(s.map(e=>t[e]||c(e))).then(e=>(r(...e),l))}}define(["./workbox-9c191d2f"],function(e){"use strict";self.addEventListener("message",e=>{e.data&&"SKIP_WAITING"===e.data.type&&self.skipWaiting()}),e.clientsClaim(),e.precacheAndRoute([{url:"self-heal.js",revision:"49bd63adb25a09341f8d2610e8bd3c76"},{url:"index.html",revision:"4a324603f0ee46fc5bafbe0e20a1b712"},{url:"assets/workbox-window.prod.es5-BBnX5xw4.js",revision:null},{url:"assets/index-DnE5ulTu.css",revision:null},{url:"assets/index-BK1VlcLX.js",revision:null},{url:"apple-touch-icon.png",revision:"2b9301416b880d45d4bb655f2600d1f2"},{url:"icon-192.png",revision:"c5e01ac58768627e18ee7b8b6a9239ef"},{url:"icon-512.png",revision:"a40638c55e310312457a621c9a0002c8"},{url:"icon-maskable-512.png",revision:"a40638c55e310312457a621c9a0002c8"},{url:"icon.svg",revision:"c1aee186821798733dd477e69a0ef243"},{url:"manifest.webmanifest",revision:"cf88fbc5755108a7fe0616fa160a8a15"}],{}),e.cleanupOutdatedCaches(),e.registerRoute(new e.NavigationRoute(e.createHandlerBoundToURL("/index.html"),{denylist:[/^\/api\//]}))});
1
+ if(!self.define){let e,i={};const n=(n,s)=>(n=new URL(n+".js",s).href,i[n]||new Promise(i=>{if("document"in self){const e=document.createElement("script");e.src=n,e.onload=i,document.head.appendChild(e)}else e=n,importScripts(n),i()}).then(()=>{let e=i[n];if(!e)throw new Error(`Module ${n} didn’t register its module`);return e}));self.define=(s,r)=>{const o=e||("document"in self?document.currentScript.src:"")||location.href;if(i[o])return;let l={};const c=e=>n(e,o),t={module:{uri:o},exports:l,require:c};i[o]=Promise.all(s.map(e=>t[e]||c(e))).then(e=>(r(...e),l))}}define(["./workbox-9c191d2f"],function(e){"use strict";self.addEventListener("message",e=>{e.data&&"SKIP_WAITING"===e.data.type&&self.skipWaiting()}),e.clientsClaim(),e.precacheAndRoute([{url:"self-heal.js",revision:"49bd63adb25a09341f8d2610e8bd3c76"},{url:"index.html",revision:"83ffcb8926c341d0bda6b343b1649bf7"},{url:"assets/workbox-window.prod.es5-BBnX5xw4.js",revision:null},{url:"assets/index-DnE5ulTu.css",revision:null},{url:"assets/index-DgCZgSTk.js",revision:null},{url:"apple-touch-icon.png",revision:"2b9301416b880d45d4bb655f2600d1f2"},{url:"icon-192.png",revision:"c5e01ac58768627e18ee7b8b6a9239ef"},{url:"icon-512.png",revision:"a40638c55e310312457a621c9a0002c8"},{url:"icon-maskable-512.png",revision:"a40638c55e310312457a621c9a0002c8"},{url:"icon.svg",revision:"c1aee186821798733dd477e69a0ef243"},{url:"manifest.webmanifest",revision:"cf88fbc5755108a7fe0616fa160a8a15"}],{}),e.cleanupOutdatedCaches(),e.registerRoute(new e.NavigationRoute(e.createHandlerBoundToURL("/index.html"),{denylist:[/^\/api\//]}))});
@@ -67,50 +67,135 @@ on splitLines(s)
67
67
  return parts
68
68
  end splitLines
69
69
 
70
- on hasWindow()
71
- -- Also false when the process itself is gone: "tell process" errors there.
70
+ on windowProbe()
71
+ -- One read, three outcomes, none of them guessed: {count, errNum, errText}.
72
+ -- count is -1 when macOS refused the read at all. Everything that wants to
73
+ -- know about windows goes through here, because "returned 0" and "refused to
74
+ -- answer" are different facts and only this handler still has both.
72
75
  try
73
76
  tell application "System Events" to tell process "Conductor"
74
- return (count of windows) > 0
77
+ set winCount to (count of windows)
75
78
  end tell
79
+ return {winCount, 0, ""}
80
+ on error errText number errNum
81
+ return {-1, errNum, errText}
82
+ end try
83
+ end windowProbe
84
+
85
+ on hasWindow()
86
+ -- Also false when the process is gone or macOS refused: callers that only
87
+ -- need a boolean keep getting one. windowFailure() is what tells them why.
88
+ return (item 1 of my windowProbe()) > 0
89
+ end hasWindow
90
+
91
+ on refusalReason(probe)
92
+ -- macOS's own words, matched on the error it actually returned rather than on
93
+ -- a capability flag we hope is accurate. "UI elements enabled" was the earlier
94
+ -- attempt at this and is not trustworthy — it can report true for a process
95
+ -- that is not itself trusted, and then the refusal reappears downstream as
96
+ -- "no open window". These strings are the two grants the write path needs.
97
+ set errNum to item 2 of probe
98
+ set errText to item 3 of probe
99
+ if errText contains "assistive access" then return "the relay is not trusted for Accessibility - grant it to the node binary running the relay in System Settings > Privacy & Security > Accessibility, then restart the relay (upgrading node silently revokes it). macOS said: " & errText
100
+ if errNum is -1743 or errText contains "Not authorized" then return "macOS blocked the relay from controlling the UI - grant Automation permission to the node binary running the relay in System Settings > Privacy & Security > Automation. macOS said: " & errText
101
+ return ""
102
+ end refusalReason
103
+
104
+ on conductorRunning()
105
+ try
106
+ tell application "System Events" to return (exists process "Conductor")
76
107
  on error
77
108
  return false
78
109
  end try
79
- end hasWindow
110
+ end conductorRunning
111
+
112
+ on windowFailure()
113
+ -- "" when a window is there; otherwise why not, in words the phone can act on.
114
+ -- ASCII on purpose: these reach the phone, and osascript decodes -e by the
115
+ -- caller's locale, which a LaunchAgent doesn't set. The last branch carries
116
+ -- the raw error number and text on purpose — an unrecognised refusal must
117
+ -- arrive as itself, not as the most plausible-sounding of the known causes.
118
+ set probe to my windowProbe()
119
+ set winCount to item 1 of probe
120
+ if winCount > 0 then return ""
121
+ if winCount is 0 then return "Conductor has no open window - open it on your Mac and try again"
122
+ set refusal to my refusalReason(probe)
123
+ if refusal is not "" then return refusal
124
+ if not (my conductorRunning()) then return "Conductor is not running - the relay started it, but it did not come up in time. Try again in a few seconds."
125
+ return "couldn't read Conductor's windows (" & (item 2 of probe) & "): " & (item 3 of probe)
126
+ end windowFailure
80
127
 
81
128
  on requireWindow()
82
- -- ASCII on purpose: this one reaches the phone, and osascript decodes -e by the
83
- -- caller's locale, which a LaunchAgent doesn't set.
84
- if not (my hasWindow()) then error "Conductor has no open window - open it on your Mac and try again"
129
+ set reason to my windowFailure()
130
+ if reason is not "" then error reason
85
131
  end requireWindow
86
132
 
87
- on activateConductor()
88
- -- Conductor keeps running with every window closed (standard macOS: the red
89
- -- button doesn't quit), and a cold launch needs a moment to build one. Both
90
- -- look identical from here, and both used to surface as "Can't get window 1 of
91
- -- process Conductor. Invalid index." from whichever handler happened to run
92
- -- first. So wait for a real window, nudge twice, then say it in words the phone
93
- -- can act on. "reopen" is the dock-click event — that is what recreates a
94
- -- closed window; "activate" on its own does not.
133
+ on openNewWindow()
134
+ -- Last resort when "reopen" draws nothing: press the app's own New Window.
135
+ -- Exact match only "New Workspace" is a different command and would create a
136
+ -- workspace nobody asked for so an app without that item fails closed and
137
+ -- silent, leaving windowFailure() to report the honest "no open window".
95
138
  try
96
- tell application "Conductor" to activate
97
- on error errText
98
- error "couldn't bring Conductor to the front: " & errText
139
+ tell application "System Events" to tell process "Conductor"
140
+ repeat with topMenu in (menu bar items of menu bar 1)
141
+ try
142
+ click (first menu item of menu 1 of topMenu whose name is "New Window")
143
+ return true
144
+ end try
145
+ end repeat
146
+ end tell
99
147
  end try
100
- delay 0.4
101
- -- ~4s of patience: enough for a reopen to draw, short enough that the caller's
102
- -- osascript timeout still has room for the send itself. A cold launch slower
103
- -- than this fails with the message below, and the retry finds a warm app.
104
- repeat with attempt from 1 to 16
105
- if my hasWindow() then return
106
- if attempt is 2 or attempt is 8 then
148
+ return false
149
+ end openNewWindow
150
+
151
+ on waitForWindow(attempts)
152
+ -- "reopen" is the dock-click event — that is what recreates a closed window;
153
+ -- "activate" on its own does not. Nudge a few times across the wait: a cold
154
+ -- launch can reach "process exists" long before it draws anything. If reopen
155
+ -- has drawn nothing by ~3s, the app isn't answering that event at all, so
156
+ -- escalate to its own menu item rather than repeating what already failed.
157
+ repeat with attempt from 1 to attempts
158
+ if my hasWindow() then return true
159
+ if attempt is 2 or attempt is 8 or attempt is 20 then
107
160
  try
108
161
  tell application "Conductor" to reopen
109
162
  tell application "Conductor" to activate
110
163
  end try
111
164
  end if
165
+ if attempt is 12 or attempt is 28 then my openNewWindow()
112
166
  delay 0.25
113
167
  end repeat
168
+ return false
169
+ end waitForWindow
170
+
171
+ on activateConductor()
172
+ -- Conductor keeps running with every window closed (standard macOS: the red
173
+ -- button doesn't quit), and it may not be running at all. Both used to surface
174
+ -- as "Can't get window 1 of process Conductor. Invalid index." from whichever
175
+ -- handler happened to run first. So: launch-or-front it ("activate" starts it
176
+ -- when it isn't running), wait for a real window, then say what actually went
177
+ -- wrong in words the phone can act on.
178
+ -- Permissions first: a refusal reads as "no process, no window" from every
179
+ -- probe below, and waiting out the patience budget to say the wrong thing
180
+ -- helps nobody. A refusal is the one failure launching can't fix.
181
+ set firstProbe to my windowProbe()
182
+ set refusal to my refusalReason(firstProbe)
183
+ if refusal is not "" then error refusal
184
+ set wasRunning to (item 1 of firstProbe) >= 0
185
+ try
186
+ tell application "Conductor" to activate
187
+ on error errText
188
+ error "couldn't bring Conductor to the front: " & errText
189
+ end try
190
+ delay 0.4
191
+ -- Patience sized to what we're waiting for. A running app only has to redraw a
192
+ -- window (~4s is plenty, and the caller's osascript timeout still needs room
193
+ -- for the send itself). A cold launch is a whole app start, so it gets ~9s —
194
+ -- still inside the 20s script budget once the send's own delays are counted.
195
+ -- Anything slower fails with the message above and finds a warm app on retry.
196
+ set patience to 16
197
+ if not wasRunning then set patience to 36
198
+ if my waitForWindow(patience) then return
114
199
  my requireWindow()
115
200
  end activateConductor
116
201
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "conductor-remote",
3
- "version": "1.27.2",
3
+ "version": "1.27.4",
4
4
  "type": "module",
5
5
  "packageManager": "yarn@4.15.0",
6
6
  "description": "Phone control panel for local Conductor agents. Reads ride SQLite + git; prompts ride Conductor's own dispatch path.",