+
    oaj                        ^ RI t ^ RIt^ RIt^ RIt^ RIt] P
                  P                  R4      t] P
                  P                  R4      t] P
                  P                  ]R4      t
] P
                  P                  ]R4      t] P                  ! ]RR7       Rt]! ]
R	4      P                  ]P!                  4       4       ]! R
4       ] P
                  P%                  ]4      '       d+   ]P&                  ! ]]R,           4       ]! R]R,           4       RRRR]
.R]RRRRR] P
                  P                  ]R4      R] P
                  P                  ]R4      /t]P*                  ! ]]! ]R4      4       ]! R4       ] P,                  ! 4       t]P0                  ! RRR] R2.RR7       ]P2                  ! ^4       ]P0                  ! RRR] 2].RR7       ]P2                  ! ^4       ]P0                  ! . R$ORRR 7      t]! R!]P6                  4       ]P0                  ! . R%ORRR 7      t]! R"]P6                  4       ]! R#4       R# )&    Nu$   ~/Claude/Projects/에이전트구축z0~/Library/LaunchAgents/com.sean.feedserver.plistzfeedserver.pylogsT)exist_oku  
import os, json, subprocess, http.server, socketserver

BASE = os.path.expanduser("~/Claude/Projects/에이전트구축")
PORT = 8899
TOKEN = "sx7k2m"
PY = "/opt/homebrew/bin/python3"
ALLOWED = {"collect_x": "collect_x.py", "collect_news": "collect_news.py"}

class H(http.server.SimpleHTTPRequestHandler):
    def __init__(self, *a, **kw):
        super().__init__(*a, directory=BASE, **kw)

    def log_message(self, *a):
        pass

    def do_GET(self):
        if self.path.startswith("/run/"):
            raw = self.path[5:]
            name, _, qs = raw.partition("?")
            name = name.strip("/")
            token = ""
            for part in qs.split("&"):
                if part.startswith("k="):
                    token = part[2:]
            if token != TOKEN:
                self.send_error(403, "bad token")
                return
            script = ALLOWED.get(name)
            if not script:
                self.send_error(404, "unknown job")
                return
            try:
                p = subprocess.run([PY, os.path.join(BASE, script)],
                                   cwd=BASE, capture_output=True,
                                   text=True, timeout=240)
                out = {"job": name, "returncode": p.returncode,
                       "stdout": p.stdout[-2000:], "stderr": p.stderr[-2000:]}
            except subprocess.TimeoutExpired:
                out = {"job": name, "returncode": -1, "error": "timeout 240s"}
            body = json.dumps(out, ensure_ascii=False).encode()
            self.send_response(200)
            self.send_header("Content-Type", "application/json; charset=utf-8")
            self.send_header("Content-Length", str(len(body)))
            self.end_headers()
            self.wfile.write(body)
            return
        super().do_GET()

class S(socketserver.ThreadingTCPServer):
    allow_reuse_address = True
    daemon_threads = True

S(("127.0.0.1", PORT), H).serve_forever()
wu   feedserver.py 작성 완료z.baku   기존 plist 백업:Labelzcom.sean.feedserverProgramArgumentsz/opt/homebrew/bin/python3WorkingDirectory	RunAtLoad	KeepAliveStandardOutPathzfeedserver.outStandardErrorPathzfeedserver.errwbu   plist 갱신 완료	launchctlbootoutzgui/z/com.sean.feedserver)capture_output	bootstrap)r   textu   파일서빙 테스트:u-   토큰없이 실행 시도(403이면 정상):u   === 세팅 완료 ===)	curl-s-m10-o	/dev/null-w%{http_code}z"http://127.0.0.1:8899/x_feed.jsonl)	r   r   r   r   r   r   r   r   z#http://127.0.0.1:8899/run/collect_x)osplistlibshutil
subprocesstimepath
expanduserBASEPLISTjoinSERVERLOGDIRmakedirsSERVER_CODEopenwritelstripprintexistscopyddumpgetuiduidrunsleeprstdoutr2     setup_trigger.py<module>r;      s   - - -	ww@A
MN	dO	,	dF	# FT "6p VS   **, - # $77>>%
KKuv~&	
 %&.1 "4f=rww||F,<=f.>? 	aeT" #  iik 
Y$se3G(HIZ^ _ 

1 
[D,>t T 

1NN :JNUY[  *^^ <LPW[] 5ryy A  r9   