@cliphijack/santaclaude 1.0.1 → 1.0.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/santaclaude.js +10 -6
package/package.json
CHANGED
package/santaclaude.js
CHANGED
|
@@ -240,16 +240,19 @@ async function run(conf) {
|
|
|
240
240
|
console.log(`[발사] ${new Date().toISOString()} → ${tgt}: ${String(j.message).slice(0, 60)}`);
|
|
241
241
|
try { inject(tgt, '[SantaClaude] ' + j.message); } catch (e) { console.warn(` 주입 실패(${tgt}): ${e.message}`); }
|
|
242
242
|
}
|
|
243
|
-
function sendHb() { if (ws && ws.readyState === 1) { try { ws.send(JSON.stringify({ type: 'hb', pane, sessions: listWindows(session)
|
|
243
|
+
function sendHb() { if (ws && ws.readyState === 1) { try { ws.send(JSON.stringify({ type: 'hb', pane, sessions: listWindows(session) })); } catch (e) {} } }
|
|
244
|
+
// 화면 미러 — 변경됐을 때만 전송(claude 멈추면 0). 2.5초 체크라 응답 직후 빠르게 반영
|
|
245
|
+
let lastScr = '';
|
|
246
|
+
function sendScreen() { if (!ws || ws.readyState !== 1) return; let cur; try { cur = JSON.stringify(captureAll(session)); } catch (e) { return; } if (cur === lastScr) return; lastScr = cur; try { ws.send(JSON.stringify({ type: 'screen', screens: JSON.parse(cur) })); } catch (e) {} }
|
|
244
247
|
|
|
245
248
|
// ── WebSocket 상시 연결 (폴링 제거 — DO가 예약/명령을 push) ──
|
|
246
249
|
const wsUrl = api.replace(/^http/, 'ws') + '/ws?token=' + encodeURIComponent(token);
|
|
247
|
-
let ws = null, hbIv = null;
|
|
250
|
+
let ws = null, hbIv = null, scrIv = null;
|
|
248
251
|
function connectWS() {
|
|
249
252
|
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); });
|
|
253
|
+
ws.addEventListener('open', () => { console.log(' 🔌 클라우드 연결됨 (WebSocket).'); lastScr = ''; sendHb(); sendScreen(); clearInterval(hbIv); clearInterval(scrIv); hbIv = setInterval(sendHb, Math.max(every, 15000)); scrIv = setInterval(sendScreen, 2500); });
|
|
251
254
|
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); });
|
|
255
|
+
ws.addEventListener('close', () => { clearInterval(hbIv); clearInterval(scrIv); console.log(' 🔌 연결 끊김 — 5초 후 재연결'); setTimeout(connectWS, 5000); });
|
|
253
256
|
ws.addEventListener('error', () => { try { ws.close(); } catch (e) {} });
|
|
254
257
|
}
|
|
255
258
|
// 폴링 폴백 (node<21 = WebSocket 미지원) — 워커가 DO 백엔드라 폴링이어도 KV write 0
|
|
@@ -264,10 +267,10 @@ async function run(conf) {
|
|
|
264
267
|
const scanIv = setInterval(scanPublish, Math.max(every, 10000)); // 로컬 클린등록 폴더 감지(주기)
|
|
265
268
|
if (typeof WebSocket !== 'undefined') {
|
|
266
269
|
connectWS();
|
|
267
|
-
process.on('SIGINT', () => { clearInterval(hbIv); clearInterval(scanIv); try { ws && ws.close(); } catch (e) {} console.log('\n🛷 커넥터 종료. 너의 루돌프들은 자러 간다.'); process.exit(0); });
|
|
270
|
+
process.on('SIGINT', () => { clearInterval(hbIv); clearInterval(scrIv); clearInterval(scanIv); try { ws && ws.close(); } catch (e) {} console.log('\n🛷 커넥터 종료. 너의 루돌프들은 자러 간다.'); process.exit(0); });
|
|
268
271
|
} else {
|
|
269
272
|
console.log(` ℹ️ 이 node는 WebSocket(21+) 미지원 — 폴링 모드로 동작 (DO 백엔드라 KV write 0 동일, 발사 ±${Math.round(every / 1000)}초). node 21+ 쓰면 자동 WebSocket.`);
|
|
270
|
-
await pollTick(); const pollIv = setInterval(pollTick, every);
|
|
273
|
+
await pollTick(); const pollIv = setInterval(pollTick, Math.max(every, 60000)); // 폴백은 최소 60초(서버 부담↓, 비실시간 유저라 OK)
|
|
271
274
|
process.on('SIGINT', () => { clearInterval(pollIv); clearInterval(scanIv); console.log('\n🛷 커넥터 종료. 너의 루돌프들은 자러 간다.'); process.exit(0); });
|
|
272
275
|
}
|
|
273
276
|
}
|
|
@@ -282,6 +285,7 @@ async function main() {
|
|
|
282
285
|
const conf = { token, pane, api: a.api || DEFAULT_API, every: a.every ? Number(a.every) : 20 };
|
|
283
286
|
if (a['no-spawn']) conf.spawn = false;
|
|
284
287
|
if (a['claude-cmd']) conf.claudeCmd = a['claude-cmd'];
|
|
288
|
+
if (a.publisher) conf.publisher = String(a.publisher).replace(/[^a-zA-Z0-9-]/g, '').toLowerCase(); // 마켓 publisher
|
|
285
289
|
saveConf(conf);
|
|
286
290
|
console.log(`✅ 페어링 저장 → ${CONF}`);
|
|
287
291
|
return run(conf);
|