sweetspot-remote-agent 1.8.4 → 1.8.6
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/mcp-server.js +27 -4
- package/package.json +1 -1
package/mcp-server.js
CHANGED
|
@@ -367,10 +367,33 @@ async function executeAction(msg) {
|
|
|
367
367
|
case "sysinfo": { return { action, success: true, info: getSystemInfo() }; }
|
|
368
368
|
case "applescript": {
|
|
369
369
|
const { execSync } = await import("child_process");
|
|
370
|
-
const
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
370
|
+
const { writeFileSync, unlinkSync } = await import("fs");
|
|
371
|
+
const tmpFile = `/tmp/sweetspot_${Date.now()}.applescript`;
|
|
372
|
+
writeFileSync(tmpFile, msg.script, "utf-8");
|
|
373
|
+
try {
|
|
374
|
+
const output = execSync(`osascript '${tmpFile}'`, { timeout: 15000, encoding: "utf-8", maxBuffer: 1024 * 1024 });
|
|
375
|
+
return { action, success: true, output: output || "(실행 완료)" };
|
|
376
|
+
} finally {
|
|
377
|
+
try { unlinkSync(tmpFile); } catch {}
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
case "write_note": {
|
|
381
|
+
// 메모 앱 노트 작성 — body를 temp 파일로 전달해 인코딩 문제 방지
|
|
382
|
+
const { execSync } = await import("child_process");
|
|
383
|
+
const { writeFileSync, unlinkSync } = await import("fs");
|
|
384
|
+
const ts = Date.now();
|
|
385
|
+
const contentFile = `/tmp/sweetspot_note_${ts}.txt`;
|
|
386
|
+
const scriptFile = `/tmp/sweetspot_script_${ts}.applescript`;
|
|
387
|
+
const title = (msg.title || "Sophy 노트").replace(/\\/g, "\\\\").replace(/"/g, '\\"');
|
|
388
|
+
writeFileSync(contentFile, msg.body || "", "utf-8");
|
|
389
|
+
const script = `tell application "Notes"\nset noteBody to read POSIX file "${contentFile}" as «class utf8»\nmake new note with properties {name:"${title}", body:noteBody}\nend tell`;
|
|
390
|
+
writeFileSync(scriptFile, script, "utf-8");
|
|
391
|
+
try {
|
|
392
|
+
const output = execSync(`osascript '${scriptFile}'`, { timeout: 15000, encoding: "utf-8" });
|
|
393
|
+
return { action, success: true, output: output || "(노트 작성 완료)" };
|
|
394
|
+
} finally {
|
|
395
|
+
try { unlinkSync(scriptFile); unlinkSync(contentFile); } catch {}
|
|
396
|
+
}
|
|
374
397
|
}
|
|
375
398
|
case "list_files": {
|
|
376
399
|
const { execSync } = await import("child_process");
|