conductor-remote 1.4.0 → 1.5.0

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/writes.ts +36 -21
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "conductor-remote",
3
- "version": "1.4.0",
3
+ "version": "1.5.0",
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.",
package/src/writes.ts CHANGED
@@ -62,29 +62,48 @@ export class SidecarActuator implements Actuator {
62
62
  }
63
63
 
64
64
  /**
65
- * Drives Conductor's real send path via macOS Accessibility (AppleScript):
66
- * activate the app, paste the prompt, press Enter. Uses whatever model /
65
+ * Drives Conductor's real send path via macOS Accessibility (AppleScript): focus
66
+ * the target workspace, paste the prompt, press Enter. Uses whatever model /
67
67
  * permission mode the session already has (zero risk of altering the agent),
68
- * which is why it's the default. Its one limit is that it lands in the session
69
- * Conductor currently has focused — bring the target workspace to front first.
68
+ * which is why it's the default.
69
+ *
70
+ * Precise targeting comes from focusing the intended workspace first through
71
+ * Conductor's command palette (Cmd+K → branch → Enter) before pasting, so the
72
+ * prompt lands in the right session regardless of what was focused — no private
73
+ * IPC and nothing to rebreak on a Conductor update (unlike the sidecar).
70
74
  */
71
75
  export class AppleScriptActuator implements Actuator {
72
76
  readonly name = 'applescript'
73
- readonly caveat =
74
- 'Lands in the session Conductor currently has focused. Bring the target workspace to front first; for precise targeting run with WRITE_STRATEGY=sidecar.'
75
- readonly precise = false
77
+ readonly caveat = 'Focuses the target workspace via the command palette (Cmd+K) before sending.'
78
+ readonly precise = true
76
79
 
77
- async send(_target: SendTarget, text: string): Promise<SendResult> {
78
- // Paste beats keystroke for long/multibyte prompts. We stash the clipboard,
79
- // paste, send, and restore.
80
+ async send(target: SendTarget, text: string): Promise<SendResult> {
81
+ // The branch is Conductor's unique per-workspace key in the command palette;
82
+ // anything less specific can match a *command* (e.g. unarchive) instead of a
83
+ // workspace, so prefer branch and pass it via env to dodge AppleScript escaping.
84
+ const ws = target.workspace
85
+ const navQuery = ws.branch || ws.workspace_name || ws.directory_name || ''
86
+ const navigate = navQuery
87
+ ? `
88
+ key code 53
89
+ delay 0.25
90
+ keystroke "k" using {command down}
91
+ delay 0.7
92
+ keystroke (system attribute "RELAY_WS_QUERY")
93
+ delay 0.9
94
+ key code 36
95
+ delay 1.3`
96
+ : ''
97
+ // Paste beats keystroke for long/multibyte prompts. Stash the clipboard,
98
+ // focus the target workspace, paste, send, and restore.
80
99
  const script = `
81
100
  set savedClipboard to the clipboard
82
- set the clipboard to (do shell script "cat" & " " & quoted form of (system attribute "RELAY_PROMPT_FILE"))
83
101
  tell application "Conductor" to activate
84
- delay 0.35
85
- tell application "System Events"
102
+ delay 0.4
103
+ tell application "System Events"${navigate}
104
+ set the clipboard to (do shell script "cat" & " " & quoted form of (system attribute "RELAY_PROMPT_FILE"))
86
105
  keystroke "v" using {command down}
87
- delay 0.1
106
+ delay 0.15
88
107
  key code 36
89
108
  end tell
90
109
  delay 0.1
@@ -98,14 +117,10 @@ set the clipboard to savedClipboard
98
117
  await fs.writeFile(tmp, text, 'utf8')
99
118
  try {
100
119
  await exec('osascript', ['-e', script], {
101
- env: { ...process.env, RELAY_PROMPT_FILE: tmp },
102
- timeout: 10000
120
+ env: { ...process.env, RELAY_PROMPT_FILE: tmp, RELAY_WS_QUERY: navQuery },
121
+ timeout: 15000
103
122
  })
104
- return {
105
- ok: true,
106
- strategy: this.name,
107
- warning: 'Delivered to the focused Conductor session — confirm it landed in the intended workspace.'
108
- }
123
+ return { ok: true, strategy: this.name }
109
124
  } catch (err) {
110
125
  return {
111
126
  ok: false,