@cliphijack/santaclaude 0.9.6 → 1.0.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/package.json +1 -1
- package/santaclaude.js +26 -21
package/package.json
CHANGED
package/santaclaude.js
CHANGED
|
@@ -226,31 +226,36 @@ async function run(conf) {
|
|
|
226
226
|
execFileSync('tmux', ['send-keys', '-t', pane, '-l', '🏪 "' + name + '" 마켓에 클린 등록됐어!']);
|
|
227
227
|
setTimeout(() => { try { execFileSync('tmux', ['send-keys', '-t', pane, 'Enter']); } catch (e) {} }, 300);
|
|
228
228
|
} else { console.warn(` 스킬 등록 실패(${name}): ${j.error}`); try { fs.unlinkSync(path.join(d, 'READY')); } catch (e) {} }
|
|
229
|
-
} catch (e) {}
|
|
229
|
+
} catch (e) { console.error('[scan fetch err]', e.message); }
|
|
230
230
|
}
|
|
231
|
-
} catch (e) {}
|
|
231
|
+
} catch (e) { console.error('[scan err]', e.message); }
|
|
232
232
|
}
|
|
233
233
|
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
} catch (e) { console.error('
|
|
234
|
+
// 예약 발사(job) → 해당 탭에 주입
|
|
235
|
+
function onJob(j) {
|
|
236
|
+
if (!paneExists(session)) { if (!warned) { console.warn(` ⚠️ 작업장 "${session}" 없음 — 보류`); warned = true; } return; }
|
|
237
|
+
warned = false;
|
|
238
|
+
const tname = j.target && String(j.target).trim();
|
|
239
|
+
const tgt = (tname && windowExists(session, tname)) ? (session + ':' + tname) : pane;
|
|
240
|
+
console.log(`[발사] ${new Date().toISOString()} → ${tgt}: ${String(j.message).slice(0, 60)}`);
|
|
241
|
+
try { inject(tgt, '[SantaClaude] ' + j.message); } catch (e) { console.warn(` 주입 실패(${tgt}): ${e.message}`); }
|
|
242
|
+
}
|
|
243
|
+
function sendHb() { if (ws && ws.readyState === 1) { try { ws.send(JSON.stringify({ type: 'hb', pane, sessions: listWindows(session), screens: captureAll(session) })); } catch (e) {} } }
|
|
244
|
+
|
|
245
|
+
// ── WebSocket 상시 연결 (폴링 제거 — DO가 예약/명령을 push) ──
|
|
246
|
+
const wsUrl = api.replace(/^http/, 'ws') + '/ws?token=' + encodeURIComponent(token);
|
|
247
|
+
let ws = null, hbIv = null;
|
|
248
|
+
function connectWS() {
|
|
249
|
+
try { ws = new WebSocket(wsUrl); } catch (e) { console.error(' WebSocket 생성 실패:', e.message); setTimeout(connectWS, 5000); return; }
|
|
250
|
+
ws.addEventListener('open', () => { console.log(' 🔌 클라우드 연결됨 (WebSocket).'); sendHb(); clearInterval(hbIv); hbIv = setInterval(sendHb, every); });
|
|
251
|
+
ws.addEventListener('message', (e) => { let m; try { m = JSON.parse(typeof e.data === 'string' ? e.data : e.data.toString()); } catch { return; } if (m.type === 'job') onJob(m); else if (m.type === 'ctl') runControl(m.cmd); });
|
|
252
|
+
ws.addEventListener('close', () => { clearInterval(hbIv); console.log(' 🔌 연결 끊김 — 5초 후 재연결'); setTimeout(connectWS, 5000); });
|
|
253
|
+
ws.addEventListener('error', () => { try { ws.close(); } catch (e) {} });
|
|
250
254
|
}
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
255
|
+
if (typeof WebSocket === 'undefined') { console.error(' ⚠️ 이 node는 WebSocket 미지원(18+ 필요). node 버전 확인.'); process.exit(1); }
|
|
256
|
+
connectWS();
|
|
257
|
+
const scanIv = setInterval(scanPublish, Math.max(every, 10000)); // 로컬 클린등록 폴더 감지(주기)
|
|
258
|
+
process.on('SIGINT', () => { clearInterval(hbIv); clearInterval(scanIv); try { ws && ws.close(); } catch (e) {} console.log('\n🛷 커넥터 종료. 너의 루돌프들은 자러 간다.'); process.exit(0); });
|
|
254
259
|
}
|
|
255
260
|
|
|
256
261
|
async function main() {
|