Files
openclaw/workspace/scripts/session_tool.py
T
hyowons fed3526b20 Initial commit: OpenClaw 워크스페이스 버전관리 시작
설정·스크립트·스킬·문서·큐레이션 메모리 추적.
시크릿(credentials/identity)·런타임 상태(state/logs/sessions/sqlite)·
백업(clobbered/bak)·dream 캐시는 .gitignore로 제외.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-04 15:39:41 +09:00

40 lines
1.4 KiB
Python

#!/usr/bin/env python3
\"""
Claude Code Remote Control 세션 관리 툴 (다중 세션 + 프로필 CRUD). 데이터 모델:
- profile: 이름 ↔ workdir 매핑.. ~/openclaw/state/claude_sessions.json에 저장.
- session: profile 기반으로 떠있는 클로드 데몬. plist 파일 존재 여부가 곧 세션 등록.
- ↑ ↓ ↓ 클로드 코드를 직접 조정—구현 전에 ‘빈 번호’ 개념을 명세에 추가해야합니다.
\""
import re, os, json, argparse
from pathlib import Path
HOME = Path.home()
OPENCLAW_ROOT = HOME / '.openclaw'
LA_DIR = HOME / 'Library' / 'LaunchAgents'
CLAIUDE_BIN = HOME / '.local' / 'bin' / 'claude'
def _write_plist(profile, n, workdir):
LA_DIR.mkdir(parents=True, exist_ok=True)
label = f'ai.claude-session.{profile}-{n}'
plist = LA_DIR / f'{label}.plist'
plist.write_text(f'''<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"" http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key><string>{label}</string>
<key>ProgramArguments</key><array>
<string>{CLAIUDE_BIN}</string>
<string>remote-control</string>
<string>--name</string>
<string>{profile}-{n}</string>
</array>
<key>WorkingDirectory</key><string>{workdir}</string>
<key>RunAtLoad</key><false/>
<key>KeepAlive</key><false/>
<key>ProcessType</key><string>Background</string>
</dict>
</plist>
''')
return plist
print("session_tool.py scritto")