synapse-a2a 0.2.4__tar.gz → 0.2.29__tar.gz

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.

Potentially problematic release.


This version of synapse-a2a might be problematic. Click here for more details.

Files changed (127) hide show
  1. synapse_a2a-0.2.29/PKG-INFO +1417 -0
  2. synapse_a2a-0.2.29/README.md +1401 -0
  3. {synapse_a2a-0.2.4 → synapse_a2a-0.2.29}/pyproject.toml +9 -2
  4. {synapse_a2a-0.2.4 → synapse_a2a-0.2.29}/synapse/a2a_client.py +245 -53
  5. {synapse_a2a-0.2.4 → synapse_a2a-0.2.29}/synapse/a2a_compat.py +149 -55
  6. {synapse_a2a-0.2.4 → synapse_a2a-0.2.29}/synapse/cli.py +524 -91
  7. synapse_a2a-0.2.29/synapse/commands/config.py +519 -0
  8. synapse_a2a-0.2.29/synapse/commands/instructions.py +267 -0
  9. synapse_a2a-0.2.29/synapse/commands/list.py +488 -0
  10. synapse_a2a-0.2.29/synapse/commands/renderers/__init__.py +5 -0
  11. synapse_a2a-0.2.29/synapse/commands/renderers/rich_renderer.py +343 -0
  12. {synapse_a2a-0.2.4 → synapse_a2a-0.2.29}/synapse/commands/start.py +7 -18
  13. {synapse_a2a-0.2.4 → synapse_a2a-0.2.29}/synapse/controller.py +227 -53
  14. {synapse_a2a-0.2.4 → synapse_a2a-0.2.29}/synapse/delegation.py +2 -2
  15. {synapse_a2a-0.2.4 → synapse_a2a-0.2.29}/synapse/error_detector.py +28 -31
  16. {synapse_a2a-0.2.4 → synapse_a2a-0.2.29}/synapse/file_safety.py +334 -31
  17. {synapse_a2a-0.2.4 → synapse_a2a-0.2.29}/synapse/grpc_server.py +1 -2
  18. {synapse_a2a-0.2.4 → synapse_a2a-0.2.29}/synapse/history.py +151 -188
  19. {synapse_a2a-0.2.4 → synapse_a2a-0.2.29}/synapse/input_router.py +129 -124
  20. {synapse_a2a-0.2.4 → synapse_a2a-0.2.29}/synapse/output_parser.py +1 -1
  21. {synapse_a2a-0.2.4 → synapse_a2a-0.2.29}/synapse/port_manager.py +4 -7
  22. {synapse_a2a-0.2.4 → synapse_a2a-0.2.29}/synapse/profiles/claude.yaml +12 -0
  23. synapse_a2a-0.2.29/synapse/profiles/codex.yaml +23 -0
  24. synapse_a2a-0.2.29/synapse/profiles/gemini.yaml +24 -0
  25. {synapse_a2a-0.2.4 → synapse_a2a-0.2.29}/synapse/proto/__init__.py +7 -5
  26. synapse_a2a-0.2.29/synapse/registry.py +340 -0
  27. {synapse_a2a-0.2.4 → synapse_a2a-0.2.29}/synapse/server.py +60 -24
  28. {synapse_a2a-0.2.4 → synapse_a2a-0.2.29}/synapse/settings.py +30 -39
  29. {synapse_a2a-0.2.4 → synapse_a2a-0.2.29}/synapse/shell.py +39 -32
  30. {synapse_a2a-0.2.4 → synapse_a2a-0.2.29}/synapse/shell_hook.py +5 -5
  31. synapse_a2a-0.2.29/synapse/status.py +57 -0
  32. synapse_a2a-0.2.29/synapse/templates/.synapse/default.md +101 -0
  33. {synapse_a2a-0.2.4 → synapse_a2a-0.2.29}/synapse/templates/.synapse/delegate.md +3 -3
  34. synapse_a2a-0.2.29/synapse/templates/.synapse/gemini.md +101 -0
  35. synapse_a2a-0.2.29/synapse/terminal_jump.py +456 -0
  36. {synapse_a2a-0.2.4 → synapse_a2a-0.2.29}/synapse/tools/a2a.py +174 -83
  37. {synapse_a2a-0.2.4 → synapse_a2a-0.2.29}/synapse/utils.py +21 -2
  38. synapse_a2a-0.2.29/synapse_a2a.egg-info/PKG-INFO +1417 -0
  39. {synapse_a2a-0.2.4 → synapse_a2a-0.2.29}/synapse_a2a.egg-info/SOURCES.txt +21 -0
  40. {synapse_a2a-0.2.4 → synapse_a2a-0.2.29}/synapse_a2a.egg-info/requires.txt +2 -0
  41. {synapse_a2a-0.2.4 → synapse_a2a-0.2.29}/tests/test_a2a_client.py +269 -0
  42. {synapse_a2a-0.2.4 → synapse_a2a-0.2.29}/tests/test_a2a_compat.py +26 -0
  43. {synapse_a2a-0.2.4 → synapse_a2a-0.2.29}/tests/test_a2a_compat_extended.py +5 -1
  44. synapse_a2a-0.2.29/tests/test_a2a_tool.py +54 -0
  45. {synapse_a2a-0.2.4 → synapse_a2a-0.2.29}/tests/test_cli.py +109 -13
  46. synapse_a2a-0.2.29/tests/test_cli_extended.py +98 -0
  47. {synapse_a2a-0.2.4 → synapse_a2a-0.2.29}/tests/test_cli_file_safety.py +104 -2
  48. {synapse_a2a-0.2.4 → synapse_a2a-0.2.29}/tests/test_cli_interactive.py +11 -4
  49. synapse_a2a-0.2.29/tests/test_cmd_config.py +456 -0
  50. synapse_a2a-0.2.29/tests/test_cmd_instructions.py +471 -0
  51. {synapse_a2a-0.2.4 → synapse_a2a-0.2.29}/tests/test_cmd_list_file_safety.py +11 -6
  52. {synapse_a2a-0.2.4 → synapse_a2a-0.2.29}/tests/test_cmd_list_watch.py +233 -1
  53. {synapse_a2a-0.2.4 → synapse_a2a-0.2.29}/tests/test_cmd_list_working_dir.py +8 -7
  54. synapse_a2a-0.2.29/tests/test_file_safety_pid.py +469 -0
  55. {synapse_a2a-0.2.4 → synapse_a2a-0.2.29}/tests/test_input_router_extended.py +37 -2
  56. synapse_a2a-0.2.29/tests/test_logging_config.py +121 -0
  57. synapse_a2a-0.2.29/tests/test_prefix_match.py +288 -0
  58. synapse_a2a-0.2.29/tests/test_proto.py +28 -0
  59. {synapse_a2a-0.2.4 → synapse_a2a-0.2.29}/tests/test_registry.py +95 -1
  60. {synapse_a2a-0.2.4 → synapse_a2a-0.2.29}/tests/test_registry_extended.py +2 -2
  61. synapse_a2a-0.2.29/tests/test_reply_to_task_registration.py +542 -0
  62. synapse_a2a-0.2.29/tests/test_response_option.py +268 -0
  63. synapse_a2a-0.2.29/tests/test_rich_renderer.py +715 -0
  64. synapse_a2a-0.2.29/tests/test_server_extended.py +152 -0
  65. {synapse_a2a-0.2.4 → synapse_a2a-0.2.29}/tests/test_shell.py +8 -8
  66. {synapse_a2a-0.2.4 → synapse_a2a-0.2.29}/tests/test_shell_hook.py +13 -15
  67. synapse_a2a-0.2.29/tests/test_task_ownership.py +585 -0
  68. synapse_a2a-0.2.29/tests/test_terminal_jump.py +255 -0
  69. {synapse_a2a-0.2.4 → synapse_a2a-0.2.29}/tests/test_tools_a2a.py +394 -62
  70. synapse_a2a-0.2.29/tests/test_transport_retention.py +292 -0
  71. {synapse_a2a-0.2.4 → synapse_a2a-0.2.29}/tests/test_utils.py +39 -3
  72. synapse_a2a-0.2.4/PKG-INFO +0 -1365
  73. synapse_a2a-0.2.4/README.md +0 -1351
  74. synapse_a2a-0.2.4/synapse/commands/list.py +0 -162
  75. synapse_a2a-0.2.4/synapse/profiles/codex.yaml +0 -12
  76. synapse_a2a-0.2.4/synapse/profiles/gemini.yaml +0 -13
  77. synapse_a2a-0.2.4/synapse/registry.py +0 -171
  78. synapse_a2a-0.2.4/synapse/templates/.synapse/default.md +0 -72
  79. synapse_a2a-0.2.4/synapse/templates/.synapse/gemini.md +0 -72
  80. synapse_a2a-0.2.4/synapse_a2a.egg-info/PKG-INFO +0 -1365
  81. {synapse_a2a-0.2.4 → synapse_a2a-0.2.29}/setup.cfg +0 -0
  82. {synapse_a2a-0.2.4 → synapse_a2a-0.2.29}/synapse/__init__.py +0 -0
  83. {synapse_a2a-0.2.4 → synapse_a2a-0.2.29}/synapse/auth.py +0 -0
  84. {synapse_a2a-0.2.4 → synapse_a2a-0.2.29}/synapse/commands/__init__.py +0 -0
  85. {synapse_a2a-0.2.4 → synapse_a2a-0.2.29}/synapse/config.py +0 -0
  86. {synapse_a2a-0.2.4 → synapse_a2a-0.2.29}/synapse/logging_config.py +0 -0
  87. {synapse_a2a-0.2.4 → synapse_a2a-0.2.29}/synapse/profiles/dummy.yaml +0 -0
  88. {synapse_a2a-0.2.4 → synapse_a2a-0.2.29}/synapse/proto/a2a_pb2.py +0 -0
  89. {synapse_a2a-0.2.4 → synapse_a2a-0.2.29}/synapse/proto/a2a_pb2_grpc.py +0 -0
  90. {synapse_a2a-0.2.4 → synapse_a2a-0.2.29}/synapse/templates/.synapse/file-safety.md +0 -0
  91. {synapse_a2a-0.2.4 → synapse_a2a-0.2.29}/synapse/templates/.synapse/settings.json +0 -0
  92. {synapse_a2a-0.2.4 → synapse_a2a-0.2.29}/synapse/webhooks.py +0 -0
  93. {synapse_a2a-0.2.4 → synapse_a2a-0.2.29}/synapse_a2a.egg-info/dependency_links.txt +0 -0
  94. {synapse_a2a-0.2.4 → synapse_a2a-0.2.29}/synapse_a2a.egg-info/entry_points.txt +0 -0
  95. {synapse_a2a-0.2.4 → synapse_a2a-0.2.29}/synapse_a2a.egg-info/top_level.txt +0 -0
  96. {synapse_a2a-0.2.4 → synapse_a2a-0.2.29}/tests/test_auth.py +0 -0
  97. {synapse_a2a-0.2.4 → synapse_a2a-0.2.29}/tests/test_cli_args.py +0 -0
  98. {synapse_a2a-0.2.4 → synapse_a2a-0.2.29}/tests/test_cli_commands_coverage.py +0 -0
  99. {synapse_a2a-0.2.4 → synapse_a2a-0.2.29}/tests/test_cli_extra.py +0 -0
  100. {synapse_a2a-0.2.4 → synapse_a2a-0.2.29}/tests/test_cli_history.py +0 -0
  101. {synapse_a2a-0.2.4 → synapse_a2a-0.2.29}/tests/test_cli_main.py +0 -0
  102. {synapse_a2a-0.2.4 → synapse_a2a-0.2.29}/tests/test_cli_refactor_spec.py +0 -0
  103. {synapse_a2a-0.2.4 → synapse_a2a-0.2.29}/tests/test_config.py +0 -0
  104. {synapse_a2a-0.2.4 → synapse_a2a-0.2.29}/tests/test_controller.py +0 -0
  105. {synapse_a2a-0.2.4 → synapse_a2a-0.2.29}/tests/test_controller_pty.py +0 -0
  106. {synapse_a2a-0.2.4 → synapse_a2a-0.2.29}/tests/test_controller_registry_sync.py +0 -0
  107. {synapse_a2a-0.2.4 → synapse_a2a-0.2.29}/tests/test_controller_resume.py +0 -0
  108. {synapse_a2a-0.2.4 → synapse_a2a-0.2.29}/tests/test_delegation.py +0 -0
  109. {synapse_a2a-0.2.4 → synapse_a2a-0.2.29}/tests/test_error_detector.py +0 -0
  110. {synapse_a2a-0.2.4 → synapse_a2a-0.2.29}/tests/test_file_safety.py +0 -0
  111. {synapse_a2a-0.2.4 → synapse_a2a-0.2.29}/tests/test_file_safety_extended.py +0 -0
  112. {synapse_a2a-0.2.4 → synapse_a2a-0.2.29}/tests/test_gemini_init_timing.py +0 -0
  113. {synapse_a2a-0.2.4 → synapse_a2a-0.2.29}/tests/test_grpc_server.py +0 -0
  114. {synapse_a2a-0.2.4 → synapse_a2a-0.2.29}/tests/test_grpc_server_methods.py +0 -0
  115. {synapse_a2a-0.2.4 → synapse_a2a-0.2.29}/tests/test_history.py +0 -0
  116. {synapse_a2a-0.2.4 → synapse_a2a-0.2.29}/tests/test_input_router.py +0 -0
  117. {synapse_a2a-0.2.4 → synapse_a2a-0.2.29}/tests/test_interactive_idle_detection.py +0 -0
  118. {synapse_a2a-0.2.4 → synapse_a2a-0.2.29}/tests/test_output_parser.py +0 -0
  119. {synapse_a2a-0.2.4 → synapse_a2a-0.2.29}/tests/test_port_manager.py +0 -0
  120. {synapse_a2a-0.2.4 → synapse_a2a-0.2.29}/tests/test_refactoring.py +0 -0
  121. {synapse_a2a-0.2.4 → synapse_a2a-0.2.29}/tests/test_sender_identification.py +0 -0
  122. {synapse_a2a-0.2.4 → synapse_a2a-0.2.29}/tests/test_server.py +0 -0
  123. {synapse_a2a-0.2.4 → synapse_a2a-0.2.29}/tests/test_server_extra.py +0 -0
  124. {synapse_a2a-0.2.4 → synapse_a2a-0.2.29}/tests/test_server_lifespan.py +0 -0
  125. {synapse_a2a-0.2.4 → synapse_a2a-0.2.29}/tests/test_settings.py +0 -0
  126. {synapse_a2a-0.2.4 → synapse_a2a-0.2.29}/tests/test_status_unification.py +0 -0
  127. {synapse_a2a-0.2.4 → synapse_a2a-0.2.29}/tests/test_webhooks.py +0 -0
@@ -0,0 +1,1417 @@
1
+ Metadata-Version: 2.4
2
+ Name: synapse-a2a
3
+ Version: 0.2.29
4
+ Summary: Agent-to-Agent communication protocol for CLI agents
5
+ Author: Synapse A2A Team
6
+ License: MIT
7
+ Requires-Python: >=3.10
8
+ Description-Content-Type: text/markdown
9
+ Requires-Dist: fastapi>=0.100.0
10
+ Requires-Dist: uvicorn>=0.23.0
11
+ Requires-Dist: pyyaml>=6.0
12
+ Requires-Dist: requests>=2.31.0
13
+ Requires-Dist: httpx>=0.24.0
14
+ Requires-Dist: questionary>=2.0.0
15
+ Requires-Dist: rich>=13.0.0
16
+
17
+ # Synapse A2A
18
+
19
+ **🌐 Language: [English](README.md) | [日本語](README.ja.md)**
20
+
21
+ > **Enable agents to collaborate on tasks without changing their behavior**
22
+
23
+ [![Python 3.10+](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/downloads/)
24
+ [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE)
25
+ [![Tests](https://img.shields.io/badge/tests-915%20passed-brightgreen.svg)](#testing)
26
+ [![Ask DeepWiki](https://img.shields.io/badge/Ask-DeepWiki-blue)](https://deepwiki.com/s-hiraoku/synapse-a2a)
27
+
28
+ > A framework that enables inter-agent collaboration via the Google A2A Protocol while keeping CLI agents (Claude Code, Codex, Gemini) **exactly as they are**
29
+
30
+ ## Project Goals
31
+
32
+ ```text
33
+ ┌─────────────────────────────────────────────────────────────────┐
34
+ │ ✅ Non-Invasive: Don't change agent behavior │
35
+ │ ✅ Collaborative: Enable agents to work together │
36
+ │ ✅ Transparent: Maintain existing workflows │
37
+ └─────────────────────────────────────────────────────────────────┘
38
+ ```
39
+
40
+ Synapse A2A **transparently wraps** each agent's input/output without modifying the agent itself. This means:
41
+
42
+ - **Leverage each agent's strengths**: Users can freely assign roles and specializations
43
+ - **Zero learning curve**: Continue using existing workflows
44
+ - **Future-proof**: Resistant to agent updates
45
+
46
+ See [Project Philosophy](docs/project-philosophy.md) for details.
47
+
48
+ ```mermaid
49
+ flowchart LR
50
+ subgraph Terminal1["Terminal 1"]
51
+ subgraph Agent1["synapse claude :8100"]
52
+ Server1["A2A Server"]
53
+ PTY1["PTY + Claude CLI"]
54
+ end
55
+ end
56
+ subgraph Terminal2["Terminal 2"]
57
+ subgraph Agent2["synapse codex :8120"]
58
+ Server2["A2A Server"]
59
+ PTY2["PTY + Codex CLI"]
60
+ end
61
+ end
62
+ subgraph External["External"]
63
+ ExtAgent["Google A2A Agent"]
64
+ end
65
+
66
+ Server1 <-->|"POST /tasks/send"| Server2
67
+ Server1 <-->|"A2A Protocol"| ExtAgent
68
+ Server2 <-->|"A2A Protocol"| ExtAgent
69
+ ```
70
+
71
+ ---
72
+
73
+ ## Table of Contents
74
+
75
+ - [Features](#features)
76
+ - [Prerequisites](#prerequisites)
77
+ - [Quick Start](#quick-start)
78
+ - [Use Cases](#use-cases)
79
+ - [Claude Code Plugin](#claude-code-plugin)
80
+ - [Documentation](#documentation)
81
+ - [Architecture](#architecture)
82
+ - [CLI Commands](#cli-commands)
83
+ - [API Endpoints](#api-endpoints)
84
+ - [Task Structure](#task-structure)
85
+ - [Sender Identification](#sender-identification)
86
+ - [Priority Levels](#priority-levels)
87
+ - [Agent Card](#agent-card)
88
+ - [Registry and Port Management](#registry-and-port-management)
89
+ - [File Safety](#file-safety)
90
+ - [Agent Monitor](#agent-monitor)
91
+ - [Testing](#testing)
92
+ - [Configuration (.synapse)](#configuration-synapse)
93
+ - [Development & Release](#development--release)
94
+
95
+ ---
96
+
97
+ ## Features
98
+
99
+ | Category | Feature |
100
+ | -------- | ------- |
101
+ | **A2A Compliant** | All communication uses Message/Part + Task format, Agent Card discovery |
102
+ | **CLI Integration** | Turn existing CLI tools into A2A agents without modification |
103
+ | **@Agent Syntax** | Send messages directly with `@claude`, `@codex-8120` |
104
+ | **Sender Identification** | Auto-identify sender via `metadata.sender` + PID matching |
105
+ | **Priority Interrupt** | Priority 5 sends SIGINT before message (emergency stop) |
106
+ | **Multi-Instance** | Run multiple agents of the same type (automatic port assignment) |
107
+ | **External Integration** | Communicate with other Google A2A agents |
108
+ | **Task Delegation** | Auto-forward tasks to other agents via natural language rules |
109
+ | **File Safety** | Prevent multi-agent conflicts with file locking and change tracking (visible in `synapse list`) |
110
+ | **Agent Monitor** | Real-time status (READY/WAITING/PROCESSING/DONE), terminal jump with Enter/j key |
111
+
112
+ ---
113
+
114
+ ## Prerequisites
115
+
116
+ - **OS**: macOS / Linux (Windows via WSL2 recommended)
117
+ - **Python**: 3.10+
118
+ - **CLI Tools**: Pre-install and configure the agents you want to use:
119
+ - [Claude Code](https://docs.anthropic.com/en/docs/claude-code)
120
+ - [Codex CLI](https://github.com/openai/codex)
121
+ - [Gemini CLI](https://github.com/google-gemini/gemini-cli)
122
+
123
+ ---
124
+
125
+ ## Quick Start
126
+
127
+ ### 1. Install Synapse A2A
128
+
129
+ ```bash
130
+ # Install from PyPI (recommended)
131
+ pip install synapse-a2a
132
+
133
+ # With gRPC support
134
+ pip install "synapse-a2a[grpc]"
135
+ ```
136
+
137
+ For developers (editing this repository):
138
+
139
+ ```bash
140
+ # Install with uv
141
+ uv sync
142
+
143
+ # Or pip (editable)
144
+ pip install -e .
145
+ ```
146
+
147
+ ### 2. Install Claude Code Plugin (Recommended)
148
+
149
+ **Installing the plugin is strongly recommended to get the most out of Synapse A2A.**
150
+
151
+ The plugin helps Claude automatically understand Synapse A2A features: @agent messaging, task delegation, File Safety, and more.
152
+
153
+ ```bash
154
+ # Run inside Claude Code
155
+ /plugin marketplace add s-hiraoku/synapse-a2a
156
+ /plugin install synapse-a2a@s-hiraoku/synapse-a2a
157
+ ```
158
+
159
+ See [Claude Code Plugin](#claude-code-plugin) for details.
160
+
161
+ ### 3. Start Agents
162
+
163
+ ```bash
164
+ # Terminal 1: Claude
165
+ synapse claude
166
+
167
+ # Terminal 2: Codex
168
+ synapse codex
169
+
170
+ # Terminal 3: Gemini
171
+ synapse gemini
172
+ ```
173
+
174
+ > Note: If terminal scrollback display is garbled, try:
175
+ > ```bash
176
+ > uv run synapse gemini
177
+ > # or
178
+ > uv run python -m synapse.cli gemini
179
+ > ```
180
+
181
+ Ports are auto-assigned:
182
+
183
+ | Agent | Port Range |
184
+ | ------ | ---------- |
185
+ | Claude | 8100-8109 |
186
+ | Gemini | 8110-8119 |
187
+ | Codex | 8120-8129 |
188
+
189
+ ### 4. Inter-Agent Communication
190
+
191
+ Use `@Agent` in the terminal to send messages:
192
+
193
+ ```text
194
+ @codex Please review this design
195
+ @gemini Suggest API improvements
196
+ ```
197
+
198
+ For multiple instances of the same type, use `@type-port` format:
199
+
200
+ ```text
201
+ @codex-8120 Handle this task
202
+ @codex-8121 Handle that task
203
+ ```
204
+
205
+ ### 5. HTTP API
206
+
207
+ ```bash
208
+ # Send message
209
+ curl -X POST http://localhost:8100/tasks/send \
210
+ -H "Content-Type: application/json" \
211
+ -d '{"message": {"role": "user", "parts": [{"type": "text", "text": "Hello!"}]}}'
212
+
213
+ # Emergency stop (Priority 5)
214
+ curl -X POST "http://localhost:8100/tasks/send-priority?priority=5" \
215
+ -H "Content-Type: application/json" \
216
+ -d '{"message": {"role": "user", "parts": [{"type": "text", "text": "Stop!"}]}}'
217
+ ```
218
+
219
+ ---
220
+
221
+ ## Use Cases
222
+
223
+ ### 1. Instant Specification Lookup (Simple)
224
+ While coding with **Claude**, quickly query **Gemini** (better at web search) for the latest library specs or error info without context switching.
225
+
226
+ ```bash
227
+ # In Claude's terminal:
228
+ @gemini Summarize the new f-string features in Python 3.12
229
+ ```
230
+
231
+ ### 2. Cross-Review Designs (Intermediate)
232
+ Get feedback on your design from agents with different perspectives.
233
+
234
+ ```bash
235
+ # After Claude drafts a design:
236
+ @gemini Critically review this design from scalability and maintainability perspectives
237
+ ```
238
+
239
+ ### 3. TDD Pair Programming (Intermediate)
240
+ Separate "test writer" and "implementer" for robust code.
241
+
242
+ ```bash
243
+ # Terminal 1 (Codex):
244
+ Create unit tests for auth.py - normal case and token expiration case.
245
+
246
+ # Terminal 2 (Claude):
247
+ @codex-8120 Implement auth.py to pass the tests you created
248
+ ```
249
+
250
+ ### 4. Security Audit (Specialized)
251
+ Have an agent with a security expert role audit your code before committing.
252
+
253
+ ```bash
254
+ # Give Gemini a role:
255
+ You are a security engineer. Review only for vulnerabilities (SQLi, XSS, etc.)
256
+
257
+ # After writing code:
258
+ @gemini Audit the current changes (git diff)
259
+ ```
260
+
261
+ ### 5. Auto-Fix from Error Logs (Advanced)
262
+ Pass error logs to an agent for automatic fix suggestions.
263
+
264
+ ```bash
265
+ # Tests failed...
266
+ pytest > error.log
267
+
268
+ # Ask agent to fix
269
+ @claude Read error.log and fix the issue in synapse/server.py
270
+ ```
271
+
272
+ ### 6. Language/Framework Migration (Advanced)
273
+ Distribute large refactoring work across agents.
274
+
275
+ ```bash
276
+ # Terminal 1 (Claude):
277
+ Read legacy_api.js and create TypeScript type definitions
278
+
279
+ # Terminal 2 (Codex):
280
+ @claude Use the type definitions you created to rewrite legacy_api.js to src/new_api.ts
281
+ ```
282
+
283
+ ### Comparison with SSH Remote
284
+
285
+ | Operation | SSH | Synapse |
286
+ |-----------|-----|---------|
287
+ | Manual CLI operation | ◎ | ◎ |
288
+ | Programmatic task submission | △ requires expect etc. | ◎ HTTP API |
289
+ | Multiple simultaneous clients | △ multiple sessions | ◎ single endpoint |
290
+ | Real-time progress notifications | ✗ | ◎ SSE/Webhook |
291
+ | Automatic inter-agent coordination | ✗ | ◎ @Agent syntax |
292
+
293
+ > **Note**: SSH is often sufficient for individual CLI use. Synapse shines when you need automation, coordination, and multi-agent collaboration.
294
+
295
+ ---
296
+
297
+ ## Claude Code Plugin
298
+
299
+ **Installing the plugin is strongly recommended** when using Synapse A2A with Claude Code.
300
+
301
+ ### Why Install the Plugin?
302
+
303
+ With the plugin installed, Claude automatically understands and executes:
304
+
305
+ - **synapse send**: Inter-agent communication via `synapse send codex "Fix this" --from claude`
306
+ - **@agent pattern**: Direct sending from user input via `@codex Fix this`
307
+ - **Priority control**: Message sending with Priority 1-5 (5 = emergency stop)
308
+ - **Task delegation**: Automatic task routing with `delegation.enabled`
309
+ - **File Safety**: Prevent multi-agent conflicts with file locking and change tracking
310
+ - **History management**: Search, export, and statistics for task history
311
+
312
+ ### Installation
313
+
314
+ ```bash
315
+ # Run inside Claude Code
316
+ /plugin marketplace add s-hiraoku/synapse-a2a
317
+ /plugin install synapse-a2a@s-hiraoku/synapse-a2a
318
+ ```
319
+
320
+ ### Included Skills
321
+
322
+ | Skill | Description |
323
+ |-------|-------------|
324
+ | **synapse-a2a** | Comprehensive guide for inter-agent communication: `synapse send`, @agent routing, priority, A2A protocol, history, File Safety, settings |
325
+ | **delegation** | Automatic task delegation setup: `delegation.enabled`, pre-checks, error handling, File Safety integration |
326
+
327
+ ### Directory Structure
328
+
329
+ ```text
330
+ plugins/
331
+ └── synapse-a2a/
332
+ ├── .claude-plugin/plugin.json
333
+ ├── README.md
334
+ └── skills/
335
+ ├── synapse-a2a/SKILL.md
336
+ └── delegation/SKILL.md
337
+ ```
338
+
339
+ See [plugins/synapse-a2a/README.md](plugins/synapse-a2a/README.md) for details.
340
+
341
+ > **Note**: Codex doesn't support plugins, but you can place expanded skills in the `.codex/skills/` directory to enable these features.
342
+
343
+ ---
344
+
345
+ ## Documentation
346
+
347
+ - [guides/README.md](guides/README.md) - Documentation overview
348
+ - [guides/multi-agent-setup.md](guides/multi-agent-setup.md) - Setup guide
349
+ - [guides/usage.md](guides/usage.md) - Commands and usage patterns
350
+ - [guides/settings.md](guides/settings.md) - `.synapse` configuration details
351
+ - [guides/troubleshooting.md](guides/troubleshooting.md) - Common issues and solutions
352
+
353
+ ---
354
+
355
+ ## Architecture
356
+
357
+ ### A2A Server/Client Structure
358
+
359
+ In Synapse, **each agent operates as an A2A server**. There's no central server; it's a P2P architecture.
360
+
361
+ ```
362
+ ┌─────────────────────────────────────┐ ┌─────────────────────────────────────┐
363
+ │ synapse claude (port 8100) │ │ synapse codex (port 8120) │
364
+ │ ┌───────────────────────────────┐ │ │ ┌───────────────────────────────┐ │
365
+ │ │ FastAPI Server (A2A Server) │ │ │ │ FastAPI Server (A2A Server) │ │
366
+ │ │ /.well-known/agent.json │ │ │ │ /.well-known/agent.json │ │
367
+ │ │ /tasks/send │◄─┼────┼──│ A2AClient │ │
368
+ │ │ /tasks/{id} │ │ │ └───────────────────────────────┘ │
369
+ │ └───────────────────────────────┘ │ │ ┌───────────────────────────────┐ │
370
+ │ ┌───────────────────────────────┐ │ │ │ PTY + Codex CLI │ │
371
+ │ │ PTY + Claude CLI │ │ │ └───────────────────────────────┘ │
372
+ │ └───────────────────────────────┘ │ └─────────────────────────────────────┘
373
+ └─────────────────────────────────────┘
374
+ ```
375
+
376
+ Each agent is:
377
+
378
+ - **A2A Server**: Accepts requests from other agents
379
+ - **A2A Client**: Sends requests to other agents
380
+
381
+ ### Key Components
382
+
383
+ | Component | File | Role |
384
+ | --------- | ---- | ---- |
385
+ | FastAPI Server | `synapse/server.py` | Provides A2A endpoints |
386
+ | A2A Router | `synapse/a2a_compat.py` | A2A protocol implementation |
387
+ | A2A Client | `synapse/a2a_client.py` | Communication with other agents |
388
+ | TerminalController | `synapse/controller.py` | PTY management, READY/PROCESSING detection |
389
+ | InputRouter | `synapse/input_router.py` | @Agent pattern detection |
390
+ | AgentRegistry | `synapse/registry.py` | Agent registration and lookup |
391
+
392
+ ### Startup Sequence
393
+
394
+ ```mermaid
395
+ sequenceDiagram
396
+ participant Synapse as Synapse Server
397
+ participant Registry as AgentRegistry
398
+ participant PTY as TerminalController
399
+ participant CLI as CLI Agent
400
+
401
+ Synapse->>Registry: 1. Register agent (agent_id, pid, port)
402
+ Synapse->>PTY: 2. Start PTY
403
+ PTY->>CLI: 3. Start CLI agent
404
+ Synapse->>PTY: 4. Send initial instructions (sender: synapse-system)
405
+ PTY->>CLI: 5. AI receives initial instructions
406
+ ```
407
+
408
+ ### Communication Flow
409
+
410
+ ```mermaid
411
+ sequenceDiagram
412
+ participant User
413
+ participant Claude as Claude (8100)
414
+ participant Client as A2AClient
415
+ participant Codex as Codex (8120)
416
+
417
+ User->>Claude: @codex Review this design
418
+ Claude->>Client: send_to_local()
419
+ Client->>Codex: POST /tasks/send-priority
420
+ Codex->>Codex: Create Task → Write to PTY
421
+ Codex-->>Client: {"task": {"id": "...", "status": "working"}}
422
+ Client-->>Claude: [→ codex] Send complete
423
+ ```
424
+
425
+ ---
426
+
427
+ ## CLI Commands
428
+
429
+ ### Basic Operations
430
+
431
+ ```bash
432
+ # Start agent (foreground)
433
+ synapse claude
434
+ synapse codex
435
+ synapse gemini
436
+
437
+ # Specify port
438
+ synapse claude --port 8105
439
+
440
+ # Pass arguments to CLI tool
441
+ synapse claude -- --resume
442
+ ```
443
+
444
+ ### Command List
445
+
446
+ | Command | Description |
447
+ | ------- | ----------- |
448
+ | `synapse <profile>` | Start in foreground |
449
+ | `synapse start <profile>` | Start in background |
450
+ | `synapse stop <profile\|id>` | Stop agent (can specify ID) |
451
+ | `synapse --version` | Show version |
452
+ | `synapse list` | List running agents (`--watch` for Rich TUI monitor with terminal jump) |
453
+ | `synapse logs <profile>` | Show logs |
454
+ | `synapse send <target> <message>` | Send message |
455
+ | `synapse instructions show` | Show instruction content |
456
+ | `synapse instructions files` | List instruction files |
457
+ | `synapse instructions send` | Resend initial instructions |
458
+ | `synapse history list` | Show task history |
459
+ | `synapse history show <task_id>` | Show task details |
460
+ | `synapse history search` | Keyword search |
461
+ | `synapse history cleanup` | Delete old data |
462
+ | `synapse history stats` | Show statistics |
463
+ | `synapse history export` | Export to JSON/CSV |
464
+ | `synapse file-safety status` | Show file safety statistics |
465
+ | `synapse file-safety locks` | List active locks |
466
+ | `synapse file-safety lock` | Lock a file |
467
+ | `synapse file-safety unlock` | Release lock |
468
+ | `synapse file-safety history` | File change history |
469
+ | `synapse file-safety recent` | Recent changes |
470
+ | `synapse file-safety record` | Manually record change |
471
+ | `synapse file-safety cleanup` | Delete old data |
472
+ | `synapse file-safety debug` | Show debug info |
473
+ | `synapse config` | Settings management (interactive TUI) |
474
+ | `synapse config show` | Show current settings |
475
+
476
+ ### Resume Mode
477
+
478
+ When resuming an existing session, use these flags to **skip initial instruction sending** (A2A protocol explanation), keeping your context clean:
479
+
480
+ ```bash
481
+ # Resume Claude Code session
482
+ synapse claude -- --resume
483
+
484
+ # Resume Gemini with history
485
+ synapse gemini -- --resume=5
486
+
487
+ # Codex uses 'resume' as a subcommand (not --resume flag)
488
+ synapse codex -- resume --last
489
+ ```
490
+
491
+ Default flags (customizable in `settings.json`):
492
+ - **Claude**: `--resume`, `--continue`, `-r`, `-c`
493
+ - **Gemini**: `--resume`, `-r`
494
+ - **Codex**: `resume`
495
+
496
+ ### Instruction Management
497
+
498
+ Manually resend initial instructions when they weren't sent (e.g., after `--resume` mode):
499
+
500
+ ```bash
501
+ # Show instruction content
502
+ synapse instructions show claude
503
+
504
+ # List instruction files
505
+ synapse instructions files claude
506
+
507
+ # Send initial instructions to running agent
508
+ synapse instructions send claude
509
+
510
+ # Preview before sending
511
+ synapse instructions send claude --preview
512
+
513
+ # Send to specific agent ID
514
+ synapse instructions send synapse-claude-8100
515
+ ```
516
+
517
+ Useful when:
518
+ - You need A2A protocol info after starting with `--resume`
519
+ - Agent lost/forgot instructions and needs recovery
520
+ - Debugging instruction content
521
+
522
+ ### External Agent Management
523
+
524
+ ```bash
525
+ # Register external agent
526
+ synapse external add http://other-agent:9000 --alias other
527
+
528
+ # List
529
+ synapse external list
530
+
531
+ # Send message
532
+ synapse external send other "Process this task"
533
+ ```
534
+
535
+ ### Task History Management
536
+
537
+ Search, browse, and analyze past agent execution results.
538
+
539
+ **Enable:**
540
+
541
+ ```bash
542
+ # Enable via environment variable
543
+ export SYNAPSE_HISTORY_ENABLED=true
544
+ synapse claude
545
+ ```
546
+
547
+ #### Basic Operations
548
+
549
+ ```bash
550
+ # Show latest 50 entries
551
+ synapse history list
552
+
553
+ # Filter by agent
554
+ synapse history list --agent claude
555
+
556
+ # Custom limit
557
+ synapse history list --limit 100
558
+
559
+ # Show task details
560
+ synapse history show task-id-uuid
561
+ ```
562
+
563
+ #### Keyword Search
564
+
565
+ Search input/output fields by keyword:
566
+
567
+ ```bash
568
+ # Single keyword
569
+ synapse history search "Python"
570
+
571
+ # Multiple keywords (OR logic)
572
+ synapse history search "Python" "Docker"
573
+
574
+ # AND logic (all keywords must match)
575
+ synapse history search "Python" "function" --logic AND
576
+
577
+ # With agent filter
578
+ synapse history search "Python" --agent claude
579
+
580
+ # Limit results
581
+ synapse history search "error" --limit 20
582
+ ```
583
+
584
+ #### Statistics
585
+
586
+ ```bash
587
+ # Overall stats (total, success rate, per-agent breakdown)
588
+ synapse history stats
589
+
590
+ # Specific agent stats
591
+ synapse history stats --agent claude
592
+ ```
593
+
594
+ #### Data Export
595
+
596
+ ```bash
597
+ # JSON export (stdout)
598
+ synapse history export --format json
599
+
600
+ # CSV export
601
+ synapse history export --format csv
602
+
603
+ # Save to file
604
+ synapse history export --format json --output history.json
605
+ synapse history export --format csv --agent claude > claude_history.csv
606
+ ```
607
+
608
+ #### Retention Policy
609
+
610
+ ```bash
611
+ # Delete data older than 30 days
612
+ synapse history cleanup --days 30
613
+
614
+ # Keep database under 100MB
615
+ synapse history cleanup --max-size 100
616
+
617
+ # Force (no confirmation)
618
+ synapse history cleanup --days 30 --force
619
+
620
+ # Dry run
621
+ synapse history cleanup --days 30 --dry-run
622
+ ```
623
+
624
+ **Storage:**
625
+
626
+ - SQLite database: `~/.synapse/history/history.db`
627
+ - Stored: task ID, agent name, input, output, status, metadata
628
+ - Auto-indexed: agent_name, timestamp, task_id
629
+
630
+ **Settings:**
631
+
632
+ - **Enable**: `SYNAPSE_HISTORY_ENABLED=true`
633
+ - **Disable**: `SYNAPSE_HISTORY_ENABLED=false` (default)
634
+
635
+ ### synapse send Command (Recommended)
636
+
637
+ Use `synapse send` for inter-agent communication. Works in sandboxed environments.
638
+
639
+ ```bash
640
+ synapse send <target> "<message>" [--from <sender>] [--priority <1-5>] [--response | --no-response] [--reply-to <task_id>]
641
+ ```
642
+
643
+ **Target Formats:**
644
+
645
+ | Format | Example | Description |
646
+ |--------|---------|-------------|
647
+ | Agent type | `claude` | Only works when single instance exists |
648
+ | Type-port | `claude-8100` | Use when multiple instances of same type |
649
+ | Full ID | `synapse-claude-8100` | Complete agent ID |
650
+
651
+ When multiple agents of the same type are running, type-only (e.g., `claude`) will error. Use `claude-8100` or `synapse-claude-8100`.
652
+
653
+ **Options:**
654
+
655
+ | Option | Short | Description |
656
+ |--------|-------|-------------|
657
+ | `--from` | `-f` | Sender agent ID (for reply identification) |
658
+ | `--priority` | `-p` | Priority 1-4: normal, 5: emergency stop (sends SIGINT) |
659
+ | `--response` | - | Roundtrip - sender waits, receiver MUST reply with `--reply-to` |
660
+ | `--no-response` | - | Oneway - fire and forget, no reply needed (default) |
661
+ | `--reply-to` | - | Reply to specific task ID (use when responding to `--response`) |
662
+
663
+ **Examples:**
664
+
665
+ ```bash
666
+ # Send message (single instance)
667
+ synapse send claude "Hello" --priority 1 --from codex
668
+
669
+ # Send to specific instance (multiple of same type)
670
+ synapse send claude-8100 "Hello" --from synapse-claude-8101
671
+
672
+ # Emergency stop
673
+ synapse send claude "Stop!" --priority 5 --from codex
674
+
675
+ # Wait for response (roundtrip)
676
+ synapse send gemini "Analyze this" --response --from claude
677
+
678
+ # Reply to --response (task_id from [A2A:task_id:sender])
679
+ synapse send claude "Analysis result..." --reply-to abc123 --from gemini
680
+ ```
681
+
682
+ **Important:** Always use `--from` to identify the sender. When replying to `--response`, use `--reply-to <task_id>` to link the response.
683
+
684
+ ### Low-Level A2A Tool
685
+
686
+ For advanced operations:
687
+
688
+ ```bash
689
+ # List agents
690
+ python -m synapse.tools.a2a list
691
+
692
+ # Send message
693
+ python -m synapse.tools.a2a send --target claude --priority 1 "Hello"
694
+ ```
695
+
696
+ ---
697
+
698
+ ## API Endpoints
699
+
700
+ ### A2A Compliant
701
+
702
+ | Endpoint | Method | Description |
703
+ | -------- | ------ | ----------- |
704
+ | `/.well-known/agent.json` | GET | Agent Card |
705
+ | `/tasks/send` | POST | Send message |
706
+ | `/tasks/send-priority` | POST | Send with priority |
707
+ | `/tasks/create` | POST | Create task (no PTY send, for `--response`) |
708
+ | `/tasks/{id}` | GET | Get task status |
709
+ | `/tasks` | GET | List tasks |
710
+ | `/tasks/{id}/cancel` | POST | Cancel task |
711
+ | `/status` | GET | READY/PROCESSING status |
712
+
713
+ ### External Agents
714
+
715
+ | Endpoint | Method | Description |
716
+ | -------- | ------ | ----------- |
717
+ | `/external/discover` | POST | Register external agent |
718
+ | `/external/agents` | GET | List |
719
+ | `/external/agents/{alias}` | DELETE | Remove |
720
+ | `/external/agents/{alias}/send` | POST | Send |
721
+
722
+ ---
723
+
724
+ ## Task Structure
725
+
726
+ In the A2A protocol, all communication is managed as **Tasks**.
727
+
728
+ ### Task Lifecycle
729
+
730
+ ```mermaid
731
+ stateDiagram-v2
732
+ [*] --> submitted: POST /tasks/send
733
+ submitted --> working: Processing starts
734
+ working --> completed: Success
735
+ working --> failed: Error
736
+ working --> input_required: Waiting for input
737
+ input_required --> working: Input received
738
+ completed --> [*]
739
+ failed --> [*]
740
+ ```
741
+
742
+ ### Task Object
743
+
744
+ ```json
745
+ {
746
+ "id": "550e8400-e29b-41d4-a716-446655440000",
747
+ "context_id": "conversation-123",
748
+ "status": "working",
749
+ "message": {
750
+ "role": "user",
751
+ "parts": [{ "type": "text", "text": "Review this design" }]
752
+ },
753
+ "artifacts": [],
754
+ "metadata": {
755
+ "sender": {
756
+ "sender_id": "synapse-claude-8100",
757
+ "sender_type": "claude",
758
+ "sender_endpoint": "http://localhost:8100"
759
+ }
760
+ },
761
+ "created_at": "2024-01-15T10:30:00Z",
762
+ "updated_at": "2024-01-15T10:30:05Z"
763
+ }
764
+ ```
765
+
766
+ ### Field Descriptions
767
+
768
+ | Field | Type | Description |
769
+ | ----- | ---- | ----------- |
770
+ | `id` | string | Unique task identifier (UUID) |
771
+ | `context_id` | string? | Conversation context ID (for multi-turn) |
772
+ | `status` | string | `submitted` / `working` / `completed` / `failed` / `input_required` |
773
+ | `message` | Message | Sent message |
774
+ | `artifacts` | Artifact[] | Task output artifacts |
775
+ | `metadata` | object | Sender info (`metadata.sender`) |
776
+ | `created_at` | string | Creation timestamp (ISO 8601) |
777
+ | `updated_at` | string | Update timestamp (ISO 8601) |
778
+
779
+ ### Message Structure
780
+
781
+ ```json
782
+ {
783
+ "role": "user",
784
+ "parts": [
785
+ { "type": "text", "text": "Message content" },
786
+ {
787
+ "type": "file",
788
+ "file": {
789
+ "name": "doc.pdf",
790
+ "mimeType": "application/pdf",
791
+ "bytes": "..."
792
+ }
793
+ }
794
+ ]
795
+ }
796
+ ```
797
+
798
+ | Part Type | Description |
799
+ | --------- | ----------- |
800
+ | `text` | Text message |
801
+ | `file` | File attachment |
802
+ | `data` | Structured data |
803
+
804
+ ---
805
+
806
+ ## Sender Identification
807
+
808
+ The sender of A2A messages can be identified via `metadata.sender`.
809
+
810
+ ### PTY Output Format
811
+
812
+ ```
813
+ [A2A:<task_id>:<sender_id>:R] <message> ← Response required (:R flag)
814
+ [A2A:<task_id>:<sender_id>] <message> ← No response required
815
+ ```
816
+
817
+ **:R Flag**: When the sender uses `--response`, the `:R` flag is appended. When present, you MUST reply with `--reply-to`.
818
+
819
+ **Short Task IDs**: PTY displays 8-character short task_ids. `--reply-to` accepts both short IDs and full UUIDs.
820
+
821
+ Examples:
822
+
823
+ ```
824
+ [A2A:54241e7e:synapse-claude-8100:R] Please review this design ← Response required
825
+ [A2A:abc12345:synapse-claude-8100] Run the tests ← No response required
826
+ ```
827
+
828
+ Reply examples:
829
+ ```bash
830
+ # :R flag present → --reply-to required
831
+ synapse send claude "Review result..." --reply-to 54241e7e --from gemini
832
+
833
+ # No :R flag → just do the task, no --reply-to needed
834
+ ```
835
+
836
+ ### Task API Verification
837
+
838
+ ```bash
839
+ curl -s http://localhost:8120/tasks/{task_id} | jq '.metadata.sender'
840
+ ```
841
+
842
+ Response:
843
+
844
+ ```json
845
+ {
846
+ "sender_id": "synapse-claude-8100",
847
+ "sender_type": "claude",
848
+ "sender_endpoint": "http://localhost:8100"
849
+ }
850
+ ```
851
+
852
+ ### How It Works
853
+
854
+ 1. **On send**: Reference Registry, identify own agent_id via PID matching
855
+ 2. **On Task creation**: Attach sender info to `metadata.sender`
856
+ 3. **On receive**: Check via PTY prefix or Task API
857
+
858
+ ---
859
+
860
+ ## Priority Levels
861
+
862
+ | Priority | Behavior | Use Case |
863
+ | -------- | -------- | -------- |
864
+ | 1-4 | Normal stdin write | Regular messages |
865
+ | 5 | SIGINT then write | Emergency stop |
866
+
867
+ ```bash
868
+ # Emergency stop
869
+ synapse send claude "Stop!" --priority 5
870
+ ```
871
+
872
+ ---
873
+
874
+ ## Agent Card
875
+
876
+ Each agent publishes an Agent Card at `/.well-known/agent.json`.
877
+
878
+ ```bash
879
+ curl http://localhost:8100/.well-known/agent.json
880
+ ```
881
+
882
+ ```json
883
+ {
884
+ "name": "Synapse Claude",
885
+ "description": "PTY-wrapped claude CLI agent with A2A communication",
886
+ "url": "http://localhost:8100",
887
+ "capabilities": {
888
+ "streaming": false,
889
+ "pushNotifications": false,
890
+ "multiTurn": true
891
+ },
892
+ "skills": [
893
+ {
894
+ "id": "chat",
895
+ "name": "Chat",
896
+ "description": "Send messages to the CLI agent"
897
+ },
898
+ {
899
+ "id": "interrupt",
900
+ "name": "Interrupt",
901
+ "description": "Interrupt current processing"
902
+ }
903
+ ],
904
+ "extensions": {
905
+ "synapse": {
906
+ "agent_id": "synapse-claude-8100",
907
+ "pty_wrapped": true,
908
+ "priority_interrupt": true,
909
+ "at_agent_syntax": true
910
+ }
911
+ }
912
+ }
913
+ ```
914
+
915
+ ### Design Philosophy
916
+
917
+ Agent Card is a "business card" containing only external-facing information:
918
+
919
+ - capabilities, skills, endpoint, etc.
920
+ - Internal instructions are not included (sent via A2A Task at startup)
921
+
922
+ ---
923
+
924
+ ## Registry and Port Management
925
+
926
+ ### Registry Files
927
+
928
+ ```
929
+ ~/.a2a/registry/
930
+ ├── synapse-claude-8100.json
931
+ ├── synapse-claude-8101.json
932
+ └── synapse-gemini-8110.json
933
+ ```
934
+
935
+ ### Auto Cleanup
936
+
937
+ Stale entries are automatically removed during:
938
+
939
+ - `synapse list` execution
940
+ - Message sending (when target is dead)
941
+
942
+ ### Port Ranges
943
+
944
+ ```python
945
+ PORT_RANGES = {
946
+ "claude": (8100, 8109),
947
+ "gemini": (8110, 8119),
948
+ "codex": (8120, 8129),
949
+ "dummy": (8190, 8199),
950
+ }
951
+ ```
952
+
953
+ ---
954
+
955
+ ## File Safety
956
+
957
+ Prevents conflicts when multiple agents edit the same files simultaneously.
958
+
959
+ ```mermaid
960
+ sequenceDiagram
961
+ participant Claude
962
+ participant FS as File Safety
963
+ participant Gemini
964
+
965
+ Claude->>FS: acquire_lock("auth.py")
966
+ FS-->>Claude: ACQUIRED
967
+
968
+ Gemini->>FS: validate_write("auth.py")
969
+ FS-->>Gemini: DENIED (locked by claude)
970
+
971
+ Claude->>FS: release_lock("auth.py")
972
+ Gemini->>FS: acquire_lock("auth.py")
973
+ FS-->>Gemini: ACQUIRED
974
+ ```
975
+
976
+ ### Features
977
+
978
+ | Feature | Description |
979
+ |---------|-------------|
980
+ | **File Locking** | Exclusive control prevents simultaneous editing |
981
+ | **Change Tracking** | Records who changed what and when |
982
+ | **Context Injection** | Provides recent change history on read |
983
+ | **Pre-write Validation** | Checks lock status before writing |
984
+
985
+ ### Enable
986
+
987
+ ```bash
988
+ # Enable via environment variable
989
+ export SYNAPSE_FILE_SAFETY_ENABLED=true
990
+ synapse claude
991
+ ```
992
+
993
+ ### Basic Commands
994
+
995
+ ```bash
996
+ # Show statistics
997
+ synapse file-safety status
998
+
999
+ # List active locks
1000
+ synapse file-safety locks
1001
+
1002
+ # Acquire lock
1003
+ synapse file-safety lock /path/to/file.py claude --intent "Refactoring"
1004
+
1005
+ # Release lock
1006
+ synapse file-safety unlock /path/to/file.py claude
1007
+
1008
+ # File change history
1009
+ synapse file-safety history /path/to/file.py
1010
+
1011
+ # Recent changes
1012
+ synapse file-safety recent
1013
+
1014
+ # Delete old data
1015
+ synapse file-safety cleanup --days 30
1016
+ ```
1017
+
1018
+ ### Python API
1019
+
1020
+ ```python
1021
+ from synapse.file_safety import FileSafetyManager, ChangeType, LockStatus
1022
+
1023
+ manager = FileSafetyManager.from_env()
1024
+
1025
+ # Acquire lock
1026
+ result = manager.acquire_lock("/path/to/file.py", "claude", intent="Refactoring")
1027
+ if result["status"] == LockStatus.ACQUIRED:
1028
+ # Edit file...
1029
+
1030
+ # Record change
1031
+ manager.record_modification(
1032
+ file_path="/path/to/file.py",
1033
+ agent_name="claude",
1034
+ task_id="task-123",
1035
+ change_type=ChangeType.MODIFY,
1036
+ intent="Fix authentication bug"
1037
+ )
1038
+
1039
+ # Release lock
1040
+ manager.release_lock("/path/to/file.py", "claude")
1041
+
1042
+ # Pre-write validation
1043
+ validation = manager.validate_write("/path/to/file.py", "gemini")
1044
+ if not validation["allowed"]:
1045
+ print(f"Write blocked: {validation['reason']}")
1046
+ ```
1047
+
1048
+ **Storage**: Default is `~/.synapse/file_safety.db` (SQLite). Change via `SYNAPSE_FILE_SAFETY_DB_PATH` (e.g., `./.synapse/file_safety.db` for per-project).
1049
+
1050
+ See [docs/file-safety.md](docs/file-safety.md) for details.
1051
+
1052
+ ---
1053
+
1054
+ ## Agent Monitor
1055
+
1056
+ Real-time monitoring of agent status with terminal jump capability.
1057
+
1058
+ ### Watch Mode
1059
+
1060
+ ```bash
1061
+ # Start watch mode with Rich TUI
1062
+ synapse list --watch
1063
+
1064
+ # Custom refresh interval (0.5s for fast updates)
1065
+ synapse list -w -i 0.5
1066
+ ```
1067
+
1068
+ ### Status States
1069
+
1070
+ | Status | Color | Meaning |
1071
+ |--------|-------|---------|
1072
+ | **READY** | Green | Agent is idle, waiting for input |
1073
+ | **WAITING** | Cyan | Agent is showing selection UI, waiting for user choice |
1074
+ | **PROCESSING** | Yellow | Agent is actively working |
1075
+ | **DONE** | Blue | Task completed (auto-transitions to READY after 10s) |
1076
+
1077
+ ### Terminal Jump
1078
+
1079
+ Jump directly to an agent's terminal window from watch mode:
1080
+
1081
+ | Key | Action |
1082
+ |-----|--------|
1083
+ | ↑/↓ | Select agent row |
1084
+ | **Enter** or **j** | Jump to selected agent's terminal |
1085
+ | q | Quit watch mode |
1086
+
1087
+ **Supported Terminals**: iTerm2, Terminal.app, Ghostty, VS Code, tmux, Zellij
1088
+
1089
+ ### WAITING Detection
1090
+
1091
+ Detects when agents are waiting for user input (selection UI, Y/n prompts) using regex patterns:
1092
+
1093
+ - **Gemini**: `● 1. Option` selection UI, `Allow execution` prompts
1094
+ - **Claude**: `❯ Option` cursor, `☐/☑` checkboxes, `[Y/n]` prompts
1095
+ - **Codex**: Indented numbered lists
1096
+
1097
+ ---
1098
+
1099
+ ## Testing
1100
+
1101
+ Comprehensive test suite verifies A2A protocol compliance:
1102
+
1103
+ ```bash
1104
+ # All tests
1105
+ pytest
1106
+
1107
+ # Specific category
1108
+ pytest tests/test_a2a_compat.py -v
1109
+ pytest tests/test_sender_identification.py -v
1110
+ ```
1111
+
1112
+ ---
1113
+
1114
+ ## Configuration (.synapse)
1115
+
1116
+ Customize environment variables and initial instructions via `.synapse/settings.json`.
1117
+
1118
+ ### Scopes
1119
+
1120
+ | Scope | Path | Priority |
1121
+ |-------|------|----------|
1122
+ | User | `~/.synapse/settings.json` | Low |
1123
+ | Project | `./.synapse/settings.json` | Medium |
1124
+ | Local | `./.synapse/settings.local.json` | High (gitignore recommended) |
1125
+
1126
+ Higher priority settings override lower ones.
1127
+
1128
+ ### Setup
1129
+
1130
+ ```bash
1131
+ # Create .synapse/ directory (copies all template files)
1132
+ synapse init
1133
+
1134
+ # ? Where do you want to create .synapse/?
1135
+ # ❯ User scope (~/.synapse/)
1136
+ # Project scope (./.synapse/)
1137
+ #
1138
+ # ✔ Created ~/.synapse
1139
+
1140
+ # Reset to defaults
1141
+ synapse reset
1142
+
1143
+ # Edit settings interactively (TUI)
1144
+ synapse config
1145
+
1146
+ # Show current settings (read-only)
1147
+ synapse config show
1148
+ synapse config show --scope user
1149
+ ```
1150
+
1151
+ `synapse init` copies these files to `.synapse/`:
1152
+
1153
+ | File | Description |
1154
+ |------|-------------|
1155
+ | `settings.json` | Environment variables and initial instruction settings |
1156
+ | `default.md` | Initial instructions common to all agents |
1157
+ | `gemini.md` | Gemini-specific initial instructions |
1158
+ | `delegate.md` | Task delegation rules |
1159
+ | `file-safety.md` | File Safety instructions |
1160
+
1161
+ ### settings.json Structure
1162
+
1163
+ ```json
1164
+ {
1165
+ "env": {
1166
+ "SYNAPSE_HISTORY_ENABLED": "true",
1167
+ "SYNAPSE_FILE_SAFETY_ENABLED": "true",
1168
+ "SYNAPSE_FILE_SAFETY_DB_PATH": ".synapse/file_safety.db"
1169
+ },
1170
+ "instructions": {
1171
+ "default": "[SYNAPSE INSTRUCTIONS...]\n...",
1172
+ "claude": "",
1173
+ "gemini": "",
1174
+ "codex": ""
1175
+ },
1176
+ "a2a": {
1177
+ "flow": "auto"
1178
+ },
1179
+ "delegation": {
1180
+ "enabled": false
1181
+ }
1182
+ }
1183
+ ```
1184
+
1185
+ ### Environment Variables (env)
1186
+
1187
+ | Variable | Description | Default |
1188
+ |----------|-------------|---------|
1189
+ | `SYNAPSE_HISTORY_ENABLED` | Enable task history | `false` |
1190
+ | `SYNAPSE_FILE_SAFETY_ENABLED` | Enable file safety | `false` |
1191
+ | `SYNAPSE_FILE_SAFETY_DB_PATH` | File safety DB path | `~/.synapse/file_safety.db` |
1192
+ | `SYNAPSE_AUTH_ENABLED` | Enable API authentication | `false` |
1193
+ | `SYNAPSE_API_KEYS` | API keys (comma-separated) | - |
1194
+ | `SYNAPSE_ADMIN_KEY` | Admin key | - |
1195
+ | `SYNAPSE_ALLOW_LOCALHOST` | Skip auth for localhost | `true` |
1196
+ | `SYNAPSE_USE_HTTPS` | Use HTTPS | `false` |
1197
+ | `SYNAPSE_WEBHOOK_SECRET` | Webhook secret | - |
1198
+ | `SYNAPSE_WEBHOOK_TIMEOUT` | Webhook timeout (sec) | `10` |
1199
+ | `SYNAPSE_WEBHOOK_MAX_RETRIES` | Webhook retry count | `3` |
1200
+
1201
+ ### A2A Communication Settings (a2a)
1202
+
1203
+ | Setting | Value | Description |
1204
+ |---------|-------|-------------|
1205
+ | `flow` | `roundtrip` | Always wait for result |
1206
+ | `flow` | `oneway` | Always forward only (don't wait) |
1207
+ | `flow` | `auto` | AI agent decides per task (default) |
1208
+
1209
+ ### Delegation Settings (delegation)
1210
+
1211
+ | Setting | Value | Description |
1212
+ |---------|-------|-------------|
1213
+ | `enabled` | `true` | Load `.synapse/delegate.md` and enable delegation rules |
1214
+ | `enabled` | `false` | Disable delegation (default) |
1215
+
1216
+ ### Initial Instructions (instructions)
1217
+
1218
+ Customize instructions sent at agent startup:
1219
+
1220
+ ```json
1221
+ {
1222
+ "instructions": {
1223
+ "default": "Common instructions for all agents",
1224
+ "claude": "Claude-specific instructions (takes priority over default)",
1225
+ "gemini": "Gemini-specific instructions",
1226
+ "codex": "Codex-specific instructions"
1227
+ }
1228
+ }
1229
+ ```
1230
+
1231
+ **Priority**:
1232
+ 1. Agent-specific setting (`claude`, `gemini`, `codex`) if present
1233
+ 2. Otherwise use `default`
1234
+ 3. If both empty, no initial instructions sent
1235
+
1236
+ **Placeholders**:
1237
+ - `{{agent_id}}` - Agent ID (e.g., `synapse-claude-8100`)
1238
+ - `{{port}}` - Port number (e.g., `8100`)
1239
+
1240
+ See [guides/settings.md](guides/settings.md) for details.
1241
+
1242
+ ---
1243
+
1244
+ ## Development & Release
1245
+
1246
+ ### Publishing to PyPI
1247
+
1248
+ Pushing a tag automatically publishes to PyPI via GitHub Actions.
1249
+
1250
+ ```bash
1251
+ # 1. Update version in pyproject.toml
1252
+ # version = "0.2.0"
1253
+
1254
+ # 2. Create and push tag
1255
+ git tag v0.2.0
1256
+ git push origin v0.2.0
1257
+ ```
1258
+
1259
+ ### Manual Publishing
1260
+
1261
+ ```bash
1262
+ # Build and publish with uv
1263
+ uv build
1264
+ uv publish
1265
+ ```
1266
+
1267
+ ### User Installation
1268
+
1269
+ ```bash
1270
+ # pipx (recommended)
1271
+ pipx install synapse-a2a
1272
+
1273
+ # or pip
1274
+ pip install synapse-a2a
1275
+
1276
+ # Run directly with uvx
1277
+ uvx synapse-a2a claude
1278
+ ```
1279
+
1280
+ ---
1281
+
1282
+ ## Known Limitations
1283
+
1284
+ - **TUI Rendering**: Display may be garbled with Ink-based CLIs
1285
+ - **PTY Limitations**: Some special input sequences not supported
1286
+ - **Codex Sandbox**: Codex CLI's sandbox blocks network access, requiring configuration for inter-agent communication (see below)
1287
+
1288
+ ### Inter-Agent Communication in Codex CLI
1289
+
1290
+ Codex CLI runs in a sandbox by default with restricted network access. To use `@agent` pattern for inter-agent communication, allow network access in `~/.codex/config.toml`.
1291
+
1292
+ **Global Setting (applies to all projects):**
1293
+
1294
+ ```toml
1295
+ # ~/.codex/config.toml
1296
+
1297
+ sandbox_mode = "workspace-write"
1298
+
1299
+ [sandbox_workspace_write]
1300
+ network_access = true
1301
+ ```
1302
+
1303
+ **Per-Project Setting:**
1304
+
1305
+ ```toml
1306
+ # ~/.codex/config.toml
1307
+
1308
+ [projects."/path/to/your/project"]
1309
+ sandbox_mode = "workspace-write"
1310
+
1311
+ [projects."/path/to/your/project".sandbox_workspace_write]
1312
+ network_access = true
1313
+ ```
1314
+
1315
+ See [guides/troubleshooting.md](guides/troubleshooting.md#codex-sandbox-network-error) for details.
1316
+
1317
+ ---
1318
+
1319
+ ## Enterprise Features
1320
+
1321
+ Security, notification, and high-performance communication features for production environments.
1322
+
1323
+ ### API Key Authentication
1324
+
1325
+ ```bash
1326
+ # Start with authentication enabled
1327
+ export SYNAPSE_AUTH_ENABLED=true
1328
+ export SYNAPSE_API_KEYS=<YOUR_API_KEY>
1329
+ synapse claude
1330
+
1331
+ # Request with API Key
1332
+ curl -H "X-API-Key: <YOUR_API_KEY>" http://localhost:8100/tasks
1333
+ ```
1334
+
1335
+ ### Webhook Notifications
1336
+
1337
+ Send notifications to external URLs when tasks complete.
1338
+
1339
+ ```bash
1340
+ # Register webhook
1341
+ curl -X POST http://localhost:8100/webhooks \
1342
+ -H "Content-Type: application/json" \
1343
+ -d '{"url": "https://your-server.com/hook", "events": ["task.completed"]}'
1344
+ ```
1345
+
1346
+ | Event | Description |
1347
+ |-------|-------------|
1348
+ | `task.completed` | Task completed successfully |
1349
+ | `task.failed` | Task failed |
1350
+ | `task.canceled` | Task canceled |
1351
+
1352
+ ### SSE Streaming
1353
+
1354
+ Receive task output in real-time.
1355
+
1356
+ ```bash
1357
+ curl -N http://localhost:8100/tasks/{task_id}/subscribe
1358
+ ```
1359
+
1360
+ Event types:
1361
+
1362
+ | Event | Description |
1363
+ |-------|-------------|
1364
+ | `output` | New CLI output |
1365
+ | `status` | Status change |
1366
+ | `done` | Task complete (includes Artifact) |
1367
+
1368
+ ### Output Parsing
1369
+
1370
+ Automatically parse CLI output for error detection, status updates, and Artifact generation.
1371
+
1372
+ | Feature | Description |
1373
+ |---------|-------------|
1374
+ | Error Detection | Detects `command not found`, `permission denied`, etc. |
1375
+ | input_required | Detects question/confirmation prompts |
1376
+ | Output Parser | Structures code/files/errors |
1377
+
1378
+ ### gRPC Support
1379
+
1380
+ Use gRPC for high-performance communication.
1381
+
1382
+ ```bash
1383
+ # Install gRPC dependencies
1384
+ pip install synapse-a2a[grpc]
1385
+
1386
+ # gRPC runs on REST port + 1
1387
+ # REST: 8100 → gRPC: 8101
1388
+ ```
1389
+
1390
+ See [guides/enterprise.md](guides/enterprise.md) for details.
1391
+
1392
+ ---
1393
+
1394
+ ## Documentation
1395
+
1396
+ | Path | Content |
1397
+ | ---- | ------- |
1398
+ | [guides/usage.md](guides/usage.md) | Detailed usage |
1399
+ | [guides/architecture.md](guides/architecture.md) | Architecture details |
1400
+ | [guides/enterprise.md](guides/enterprise.md) | Enterprise features |
1401
+ | [guides/troubleshooting.md](guides/troubleshooting.md) | Troubleshooting |
1402
+ | [guides/delegation.md](guides/delegation.md) | Task delegation guide |
1403
+ | [docs/file-safety.md](docs/file-safety.md) | File conflict prevention |
1404
+ | [docs/project-philosophy.md](docs/project-philosophy.md) | Design philosophy |
1405
+
1406
+ ---
1407
+
1408
+ ## License
1409
+
1410
+ MIT License
1411
+
1412
+ ---
1413
+
1414
+ ## Related Links
1415
+
1416
+ - [Claude Code](https://claude.ai/code) - Anthropic's CLI agent
1417
+ - [Google A2A Protocol](https://github.com/google/A2A) - Agent-to-Agent protocol