#!/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")