@geekbeer/minion 2.16.1 → 2.16.3
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 +1 -1
- package/routes/auth.js +36 -3
package/package.json
CHANGED
package/routes/auth.js
CHANGED
|
@@ -99,14 +99,28 @@ function startClaudeAuth() {
|
|
|
99
99
|
|
|
100
100
|
console.log('[Auth] Creating tmux session for claude auth login')
|
|
101
101
|
|
|
102
|
+
// Extend PATH to include common CLI installation locations
|
|
103
|
+
// (systemd provides a minimal PATH that excludes ~/.local/bin where claude is installed)
|
|
104
|
+
const additionalPaths = [
|
|
105
|
+
path.join(config.HOME_DIR, '.local', 'bin'),
|
|
106
|
+
path.join(config.HOME_DIR, 'bin'),
|
|
107
|
+
path.join(config.HOME_DIR, '.npm-global', 'bin'),
|
|
108
|
+
path.join(config.HOME_DIR, '.claude', 'bin'),
|
|
109
|
+
'/usr/local/bin',
|
|
110
|
+
]
|
|
111
|
+
const extendedPath = [...additionalPaths, process.env.PATH || '/usr/bin:/bin'].join(':')
|
|
112
|
+
|
|
102
113
|
try {
|
|
103
114
|
// Start claude auth login in a new tmux session
|
|
115
|
+
// Use inline env vars in the shell command for compatibility with all tmux versions
|
|
116
|
+
// (tmux -e flag requires tmux 3.2+)
|
|
104
117
|
// CLAUDECODE='' prevents the nesting check
|
|
105
|
-
// HOME must be set explicitly because systemd clears environment variables
|
|
106
118
|
execSync(
|
|
107
|
-
`tmux new-session -d -s ${TMUX_SESSION} -x 500 -y 40 'HOME="${config.HOME_DIR}" CLAUDECODE="" claude auth login'`,
|
|
119
|
+
`tmux new-session -d -s ${TMUX_SESSION} -x 500 -y 40 'export HOME="${config.HOME_DIR}" PATH="${extendedPath}"; CLAUDECODE="" claude auth login'`,
|
|
108
120
|
{ timeout: 5000 }
|
|
109
121
|
)
|
|
122
|
+
// Keep pane alive after command exits so we can capture error output
|
|
123
|
+
execSync(`tmux set-option -t ${TMUX_SESSION} remain-on-exit on`)
|
|
110
124
|
} catch (err) {
|
|
111
125
|
reject(new Error(`Failed to create tmux session: ${err.message}`))
|
|
112
126
|
return
|
|
@@ -125,7 +139,16 @@ function startClaudeAuth() {
|
|
|
125
139
|
const pollInterval = setInterval(() => {
|
|
126
140
|
if (resolved) return
|
|
127
141
|
|
|
128
|
-
if (
|
|
142
|
+
// Check if the process inside the pane has exited (remain-on-exit keeps pane alive)
|
|
143
|
+
let paneDead = false
|
|
144
|
+
try {
|
|
145
|
+
const deadFlag = execSync(
|
|
146
|
+
`tmux list-panes -t ${TMUX_SESSION} -F '#{pane_dead}'`,
|
|
147
|
+
{ encoding: 'utf-8', timeout: 3000 }
|
|
148
|
+
).trim()
|
|
149
|
+
paneDead = deadFlag === '1'
|
|
150
|
+
} catch {
|
|
151
|
+
// Session itself is gone
|
|
129
152
|
resolved = true
|
|
130
153
|
clearInterval(pollInterval)
|
|
131
154
|
reject(new Error('Auth session ended unexpectedly'))
|
|
@@ -135,6 +158,16 @@ function startClaudeAuth() {
|
|
|
135
158
|
const content = captureTmuxPane()
|
|
136
159
|
const clean = stripAnsi(content)
|
|
137
160
|
|
|
161
|
+
// If process exited, capture output for diagnostics and report error
|
|
162
|
+
if (paneDead) {
|
|
163
|
+
resolved = true
|
|
164
|
+
clearInterval(pollInterval)
|
|
165
|
+
console.error(`[Auth] Process exited. Pane output:\n${clean.slice(0, 1000)}`)
|
|
166
|
+
try { execSync(`tmux kill-session -t ${TMUX_SESSION} 2>/dev/null`) } catch {}
|
|
167
|
+
reject(new Error(`Auth process exited. Output: ${clean.slice(0, 300) || '(none)'}`))
|
|
168
|
+
return
|
|
169
|
+
}
|
|
170
|
+
|
|
138
171
|
// Check for URL at any stage
|
|
139
172
|
const url = extractUrlFromPane(content)
|
|
140
173
|
if (url) {
|