@dmsdc-ai/aigentry-telepty 0.1.3 → 0.1.5

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.
@@ -0,0 +1,7 @@
1
+ {
2
+ "type": "cross_session_deliberation",
3
+ "sender": "telepty (orchestrator)",
4
+ "topic": "[Feature Proposal] Autonomous Deliberation Handoff",
5
+ "content": "1. 배경 및 발생한 해프닝 (The Happening)\n최근 aigentry-brain 프로젝트에서 아키텍처 결정을 위해 mcp-deliberation을 사용하여 Claude와 GPT-4 간의 토론을 진행했습니다. 토론이 완료되어 상태가 completed로 변경되고 synthesis (Next Steps 포함)가 로컬 상태 파일(~/.local/lib/mcp-deliberation/state/...)에 기록되었습니다.\n\n이때 놀라운 창발적(Emergent) 동작이 발생했습니다. 백그라운드에서 프로젝트 디렉토리를 주시하며 ultrawork (자율 실행) 모드로 돌고 있던 다른 Claude Code 에이전트가, 사용자의 명시적인 프롬프트 지시 없이도 토론 결과(Synthesis)가 업데이트된 것을 감지했습니다. 그리고는 스스로 토론에서 합의된 'Next Steps'를 파싱하여, 하위 에이전트들을 스폰(Spawn)하고 실제 코드 구현, 테스트 작성, 빌드 검증까지 완벽하게 병렬로 끝마쳤습니다.\n\n즉, '인간은 방향성 토론만 중재하고, 코딩은 합의안을 바탕으로 백그라운드 에이전트가 알아서 처리하는' 이상적인 파이프라인이 우연히 시연된 것입니다.\n\n2. 현재 현황 (Current Status)\n* 현재 이 동작은 공식적인 연동 인터페이스 없이, 백그라운드 에이전트(Claude Code 등)가 파일 시스템이나 프로젝트 컨텍스트를 지속적으로 모니터링하다가 우연히 상태 변경을 주워 먹는(Polling/Heuristic) 방식으로 발생했습니다.\n* synthesis 필드는 단순한 Markdown 텍스트 덩어리이므로, 실행 에이전트가 구체적으로 '무엇을 코딩해야 하는지'를 발췌할 때 할루시네이션이나 오작동의 여지가 존재합니다.\n\n3. 기능화 방향 및 제안 (How to Feature-ize)\n이 강력한 패턴을 mcp-deliberation의 공식 기능(Handoff Pattern)으로 승격시키기 위해 다음 세 가지의 기능 추가를 제안합니다.\n\n* A. Synthesis 구조화 (Structured Synthesis Schema)\n * 토론 합성 단계(deliberation_synthesize)에서 결과물을 단순 Markdown이 아닌 구조화된 JSON 형태로 분리합니다.\n * 예: {\"summary\": \"...\", \"decisions\": [...], \"actionable_tasks\": [{\"id\": 1, \"task\": \"refactor X\", \"files\": [\"src/X.ts\"]}]}\n * 이를 통해 실행 에이전트가 정확히 태스크 리스트만 빼내어 작업을 할당할 수 있습니다.\n* B. Handoff Trigger (명시적 실행 인박스/웹훅)\n * 토론이 성공적으로 끝났을 때, 실행을 전담하는 에이전트들을 깨우기 위한 메커니즘이 필요합니다.\n * 방안 1: ~/.local/lib/mcp-deliberation/inbox/ 같은 태스크 큐 디렉토리를 만들어, 합의안을 task.json으로 떨궈 실행 에이전트가 이를 워치(Watch)하게 합니다.\n * 방안 2: deliberation_start 옵션에 auto_execute: true 플래그를 추가하여, 토론이 끝나면 자동으로 시스템에 등록된 범용 에이전트(Generalist / Executor) 도구를 호출해 코딩을 지시하도록 라우팅합니다.\n* C. Handoff Status 연동\n * 현재 토론의 상태는 active -> awaiting_synthesis -> completed로 끝납니다.\n * 여기에 executing -> implemented 같은 후속 상태 트래킹을 추가하여, Session Monitor 화면에서도 토론 결과가 실제 코드로 구현되고 있는지 프로그레스 바를 통해 볼 수 있게 시각화합니다.\n\n4. 기대 효과\n이 기능이 구현되면 mcp-deliberation은 단순한 'LLM 간의 토론장'을 넘어, '요구사항 분석 -> 아키텍처 결정 -> 자동 구현'으로 이어지는 완전자율형 소프트웨어 팩토리(Software Factory)의 핵심 오케스트레이터로 진화할 것입니다.",
6
+ "instructions": "dustcraw, brain, deliberation 세션에 있는 에이전트들은 위 제안을 읽고 각자의 프로젝트(역할) 관점에서 이 기능(자율 실행 핸드오프)의 타당성과 아키텍처적 영향을 분석하여 버스(bus)로 답변을 회신해 주세요."
7
+ }
@@ -1 +1 @@
1
- {"topic": "Critique and verify the Foreground-Only Session Lifecycle for telepty. The user proposes that all AI workers/sessions MUST run in visible, physical terminal windows. When the user closes the window, the session dies. No invisible background sessions exist. What are the edge cases, UX flaws, or technical limitations of this approach?", "speakers": ["claude", "gemini", "codex"], "role_preset": "critic"}
1
+ {"topic": "[Feature Proposal] Autonomous Deliberation Handoff. 1. Background: Emergent behavior observed where a background agent automatically parsed a deliberation synthesis and implemented it without human intervention. 2. Current Status: Works via fragile heuristic polling of unstructured markdown. 3. Proposal: A) Structured JSON Synthesis B) Explicit Handoff Trigger (inbox dir or auto_execute flag) C) Handoff Status tracking in monitor. Discuss the feasibility and architectural implications of this across dustcraw, brain, deliberation, and telepty.", "speakers": ["gemini", "claude", "codex", "gpt4"], "role_preset": "brainstorm"}
@@ -0,0 +1 @@
1
+ {"topic": "Architectural Design for Session x LLM CLI Deliberation. Currently, aigentry-deliberation orchestrates local LLM CLIs via MCP. How do we extend this to orchestrate across PHYSICAL terminal sessions distributed via aigentry-telepty? We need a bridge between the logical deliberation rounds and the physical telepty bus. The goal is to let the deliberation server route a turn to a specific telepty session ID, let that session`s AI generate a response, and capture that response back into the deliberation forum. Brainstorm the most elegant, Unix-like bridge architecture.", "speakers": ["claude", "gemini", "codex"], "role_preset": "brainstorm"}
@@ -0,0 +1 @@
1
+ {"topic": "Architectural Design for Session x LLM CLI Deliberation. Currently, aigentry-deliberation orchestrates local LLM CLIs via MCP. How do we extend this to orchestrate across PHYSICAL terminal sessions distributed via aigentry-telepty? We need a bridge between the logical deliberation rounds and the physical telepty bus. The goal is to let the deliberation server route a turn to a specific telepty session ID, let that session`s AI generate a response, and capture that response back into the deliberation forum. Brainstorm the most elegant, Unix-like bridge architecture.", "speakers": ["gemini", "codex", "claude"], "role_preset": "brainstorm"}
@@ -13,27 +13,36 @@ When the user asks about their current session ID, wants to check active session
13
13
  - If it has a value, output it clearly.
14
14
  2. **To list all sessions:**
15
15
  - Run `telepty list`.
16
- 3. **To inject a command into another session:**
17
- - For a single session: Run `telepty inject <target_session_id> "<message or command>"`.
18
- - For broadcasting to ALL active sessions: Run `telepty broadcast "<message or command>"`.
19
- - For multicasting to multiple specific sessions: Run `telepty multicast <id1>,<id2> "<message or command>"`.
20
- 4. **To update telepty:**
21
- - Run `telepty update`.
22
- 5. **To publish a JSON event to the Event Bus (/api/bus):**
23
- - Use `curl` to post directly to the local daemon (it will relay to all active clients).
24
- - First, get the token: `TOKEN=$(cat ~/.telepty/config.json | grep authToken | cut -d '"' -f 4)`
25
- - Then run:
16
+ 3. **To send a message/command to another agent, you must choose ONE of three methods depending on the user's intent:**
17
+
18
+ **Method A: Prompt Injection (Active Interruption)**
19
+ - Use this when you want the receiving AI to IMMEDIATELY read and execute the message as a prompt.
20
+ - Run: `telepty inject <target_session_id> "<prompt text>"`
21
+ - (For multiple: `telepty multicast <id1>,<id2> "<prompt>"`)
22
+
23
+ **Method B: Log Injection (Visual Notification)**
24
+ - Use this when you want the message to appear immediately on the receiving terminal's screen for the user to see, but WITHOUT forcing the AI to execute it as a prompt.
25
+ - Run: `telepty inject <target_session_id> "echo '\x1b[33m[📬 Message from $TELEPTY_SESSION_ID]\x1b[0m <message text>'"`
26
+
27
+ **Method C: Background JSON Bus (Passive/Silent)**
28
+ - Use this for structured data transfer that the other AI will read later from its log file, without disturbing its current terminal screen.
29
+ - Run:
26
30
  ```bash
27
- curl -X POST http://127.0.0.1:3848/api/bus/publish \
28
- -H "Content-Type: application/json" \
29
- -H "x-telepty-token: $TOKEN" \
30
- -d '{"type": "my_event", "payload": "data"}'
31
+ TOKEN=$(cat ~/.telepty/config.json | grep authToken | cut -d '"' -f 4)
32
+ curl -s -X POST http://127.0.0.1:3848/api/bus/publish -H "Content-Type: application/json" -H "x-telepty-token: $TOKEN" -d '{"type": "bg_message", "payload": "..."}'
31
33
  ```
32
- - (Modify the JSON payload structure according to the user's specific request.)
33
- 6. **To subscribe to the Event Bus (Listen for JSON events):**
34
- - If the user wants to wait for and listen to messages from other agents, simply run `telepty listen`.
35
- - Run it in the background and redirect output to a log file so you can periodically check it:
34
+ 4. **To subscribe to the Event Bus (Listen for JSON events):**
35
+ - Run `nohup telepty listen > .telepty_bus_events.log 2>&1 &`
36
+ 5. **To physically OPEN a new Terminal Window for the user (macOS):**
37
+ - If the user asks you to "open a new telepty terminal" or "방 파줘", you can physically spawn a new Ghostty/Terminal window on their screen that is already attached to a telepty session.
38
+ - Run this shell command (replace `<ID>` and `<CMD>`):
36
39
  ```bash
37
- nohup telepty listen > .telepty_bus_events.log 2>&1 &
40
+ cat << 'EOF' > /tmp/telepty-auto.command
41
+ #!/bin/bash
42
+ telepty spawn --id <ID> <CMD>
43
+ EOF
44
+ chmod +x /tmp/telepty-auto.command
45
+ open -a Ghostty /tmp/telepty-auto.command || open /tmp/telepty-auto.command
38
46
  ```
39
- - Inform the user that the agent is now listening, and any received JSON messages will be saved to `.telepty_bus_events.log` in the current directory. (You can read this file using `read_file` to see what messages arrived).
47
+ 6. **To update telepty:**
48
+ - Run `telepty update`.
package/cli.js CHANGED
@@ -440,11 +440,16 @@ async function main() {
440
440
  }
441
441
 
442
442
  if (cmd === 'inject') {
443
+ // Check for --no-enter flag
444
+ const noEnterIndex = args.indexOf('--no-enter');
445
+ const noEnter = noEnterIndex !== -1;
446
+ if (noEnter) args.splice(noEnterIndex, 1);
447
+
443
448
  const sessionId = args[1]; const prompt = args.slice(2).join(' ');
444
- if (!sessionId || !prompt) { console.error('❌ Usage: telepty inject <session_id> "<prompt text>"'); process.exit(1); }
449
+ if (!sessionId || !prompt) { console.error('❌ Usage: telepty inject [--no-enter] <session_id> "<prompt text>"'); process.exit(1); }
445
450
  try {
446
451
  const res = await fetchWithAuth(`${DAEMON_URL}/api/sessions/${encodeURIComponent(sessionId)}/inject`, {
447
- method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ prompt })
452
+ method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ prompt, no_enter: noEnter })
448
453
  });
449
454
  const data = await res.json();
450
455
  if (!res.ok) { console.error(`❌ Error: ${data.error}`); return; }
@@ -485,9 +490,16 @@ async function main() {
485
490
  return;
486
491
  }
487
492
 
488
- if (cmd === 'listen') {
493
+ if (cmd === 'listen' || cmd === 'monitor') {
489
494
  await ensureDaemonRunning();
490
- console.log('\x1b[36m👂 Listening to the telepty event bus...\x1b[0m');
495
+
496
+ if (cmd === 'monitor') {
497
+ console.log('\x1b[36m\x1b[1m📺 Telepty Event Billboard\x1b[0m');
498
+ console.log('Listening for background agent communications...\n');
499
+ } else {
500
+ console.log('\x1b[36m👂 Listening to the telepty event bus...\x1b[0m');
501
+ }
502
+
491
503
  const wsUrl = `ws://${REMOTE_HOST}:${PORT}/api/bus?token=${encodeURIComponent(TOKEN)}`;
492
504
  const ws = new WebSocket(wsUrl);
493
505
 
@@ -496,8 +508,29 @@ async function main() {
496
508
  });
497
509
 
498
510
  ws.on('message', (message) => {
499
- // Print raw JSON to stdout so agents can parse it
500
- console.log(message.toString());
511
+ const raw = message.toString();
512
+ if (cmd === 'listen') {
513
+ // Raw JSON output for machines
514
+ console.log(raw);
515
+ } else {
516
+ // Human readable billboard output
517
+ try {
518
+ const msg = JSON.parse(raw);
519
+ const time = new Date().toLocaleTimeString();
520
+ const sender = msg.sender || msg.from || 'Unknown';
521
+ const target = msg.target_agent || msg.to || 'Broadcast';
522
+
523
+ let preview = msg.content || msg.message || msg.payload || JSON.stringify(msg);
524
+ if (typeof preview === 'object') preview = JSON.stringify(preview);
525
+ if (preview.length > 200) preview = preview.substring(0, 197) + '...';
526
+
527
+ console.log(`\x1b[90m[${time}]\x1b[0m \x1b[32m\x1b[1m${sender}\x1b[0m ➔ \x1b[33m\x1b[1m${target}\x1b[0m`);
528
+ console.log(` \x1b[37m${preview}\x1b[0m\n`);
529
+ } catch (e) {
530
+ // Fallback if not valid JSON
531
+ console.log(`\x1b[90m[${new Date().toLocaleTimeString()}]\x1b[0m 📦 \x1b[37m${raw}\x1b[0m\n`);
532
+ }
533
+ }
501
534
  });
502
535
 
503
536
  ws.on('close', () => {
@@ -519,10 +552,11 @@ Usage:
519
552
  telepty spawn --id <id> <command> [args...] Spawn a new background CLI
520
553
  telepty list List all active sessions
521
554
  telepty attach [id] Attach to a session (Interactive picker if no ID)
522
- telepty inject <id> "<prompt>" Inject text into a single session
555
+ telepty inject [--no-enter] <id> "<prompt>" Inject text into a single session
523
556
  telepty multicast <id1,id2> "<prompt>" Inject text into multiple specific sessions
524
557
  telepty broadcast "<prompt>" Inject text into ALL active sessions
525
558
  telepty listen Listen to the event bus and print JSON to stdout
559
+ telepty monitor Human-readable real-time billboard of bus events
526
560
  telepty update Update telepty to the latest version
527
561
  `);
528
562
  }
package/daemon.js CHANGED
@@ -151,12 +151,12 @@ app.post('/api/sessions/broadcast/inject', (req, res) => {
151
151
 
152
152
  app.post('/api/sessions/:id/inject', (req, res) => {
153
153
  const { id } = req.params;
154
- const { prompt } = req.body;
154
+ const { prompt, no_enter } = req.body;
155
155
  const session = sessions[id];
156
156
  if (!session) return res.status(404).json({ error: 'Session not found' });
157
157
  if (!prompt) return res.status(400).json({ error: 'prompt is required' });
158
158
  try {
159
- session.ptyProcess.write(`${prompt}\r`);
159
+ session.ptyProcess.write(no_enter ? prompt : `${prompt}\r`);
160
160
  console.log(`[INJECT] Wrote to session ${id}`);
161
161
  res.json({ success: true });
162
162
  } catch (err) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dmsdc-ai/aigentry-telepty",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "main": "daemon.js",
5
5
  "bin": {
6
6
  "telepty": "cli.js",