yingclaw 1.8.2 → 1.9.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.
- package/lib/desktop.js +17 -9
- package/package.json +1 -1
package/lib/desktop.js
CHANGED
|
@@ -21,12 +21,12 @@ function getClaudeDesktopConfigPath(options = {}) {
|
|
|
21
21
|
const homeDir = options.homeDir || os.homedir();
|
|
22
22
|
|
|
23
23
|
if (platform === 'darwin') {
|
|
24
|
-
return path.join(homeDir, 'Library', 'Application Support', 'Claude
|
|
24
|
+
return path.join(homeDir, 'Library', 'Application Support', 'Claude', 'claude_desktop_config.json');
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
if (platform === 'win32') {
|
|
28
28
|
const appData = options.appData || process.env.APPDATA || path.join(homeDir, 'AppData', 'Roaming');
|
|
29
|
-
return path.join(appData, 'Claude
|
|
29
|
+
return path.join(appData, 'Claude', 'claude_desktop_config.json');
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
return null;
|
|
@@ -126,11 +126,13 @@ function clearClaudeDesktopConfig(options = {}) {
|
|
|
126
126
|
|
|
127
127
|
function buildClaudeDesktopOpenCommands(platform = process.platform) {
|
|
128
128
|
if (platform !== 'darwin') return null;
|
|
129
|
-
// 先 graceful quit
|
|
129
|
+
// 先 graceful quit,SIGTERM 兜底,SIGKILL 强制清理,再 open,最后 activate
|
|
130
130
|
return [
|
|
131
|
-
{ command: 'osascript', args: ['-e', 'tell application "Claude" to quit'], optional: true, waitAfter:
|
|
132
|
-
{ command: 'pkill', args: ['-x', 'Claude'], optional: true, waitAfter:
|
|
133
|
-
{ command: '
|
|
131
|
+
{ command: 'osascript', args: ['-e', 'tell application "Claude" to quit'], optional: true, waitAfter: 800 },
|
|
132
|
+
{ command: 'pkill', args: ['-TERM', '-x', 'Claude'], optional: true, waitAfter: 500 },
|
|
133
|
+
{ command: 'pkill', args: ['-KILL', '-x', 'Claude'], optional: true, waitAfter: 800 },
|
|
134
|
+
{ command: 'open', args: ['-a', 'Claude'], waitAfter: 600 },
|
|
135
|
+
{ command: 'osascript', args: ['-e', 'tell application "Claude" to activate'], optional: true },
|
|
134
136
|
];
|
|
135
137
|
}
|
|
136
138
|
|
|
@@ -146,17 +148,23 @@ async function openClaudeDesktop(options = {}) {
|
|
|
146
148
|
const runner = options.runner || spawnSync;
|
|
147
149
|
const isMocked = options.runner !== undefined;
|
|
148
150
|
|
|
151
|
+
const trace = [];
|
|
149
152
|
for (const { command, args, optional, waitAfter } of commands) {
|
|
150
|
-
const result = runner(command, args, { stdio: '
|
|
153
|
+
const result = runner(command, args, { stdio: 'pipe', encoding: 'utf8', windowsHide: true });
|
|
154
|
+
const stderr = (result.stderr || '').toString().trim();
|
|
155
|
+
trace.push({ command, args, status: result.status, stderr });
|
|
156
|
+
|
|
151
157
|
if (result.status !== 0 && !optional) {
|
|
152
|
-
|
|
158
|
+
const detail = stderr ? `: ${stderr}` : '';
|
|
159
|
+
const trail = trace.map(t => `${t.command} ${t.args.join(' ')} → ${t.status}${t.stderr ? ' (' + t.stderr + ')' : ''}`).join('\n ');
|
|
160
|
+
throw new Error(`Claude 桌面应用打开失败${detail}\n ${trail}`);
|
|
153
161
|
}
|
|
154
162
|
if (waitAfter && !isMocked) {
|
|
155
163
|
await sleep(waitAfter);
|
|
156
164
|
}
|
|
157
165
|
}
|
|
158
166
|
|
|
159
|
-
return { result: 'reopened' };
|
|
167
|
+
return { result: 'reopened', trace };
|
|
160
168
|
}
|
|
161
169
|
|
|
162
170
|
module.exports = {
|