claude-chatter 0.2.1__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.
- claude_chatter-0.2.1/LICENSE +21 -0
- claude_chatter-0.2.1/PKG-INFO +119 -0
- claude_chatter-0.2.1/README.md +93 -0
- claude_chatter-0.2.1/claude_chatter/__init__.py +21 -0
- claude_chatter-0.2.1/claude_chatter/cli.py +155 -0
- claude_chatter-0.2.1/claude_chatter/client.py +783 -0
- claude_chatter-0.2.1/claude_chatter/exceptions.py +16 -0
- claude_chatter-0.2.1/claude_chatter/jobs.py +122 -0
- claude_chatter-0.2.1/claude_chatter/protocol.py +9 -0
- claude_chatter-0.2.1/claude_chatter/standalone.py +48 -0
- claude_chatter-0.2.1/claude_chatter/storage.py +686 -0
- claude_chatter-0.2.1/claude_chatter/wire.py +254 -0
- claude_chatter-0.2.1/claude_chatter.egg-info/PKG-INFO +119 -0
- claude_chatter-0.2.1/claude_chatter.egg-info/SOURCES.txt +19 -0
- claude_chatter-0.2.1/claude_chatter.egg-info/dependency_links.txt +1 -0
- claude_chatter-0.2.1/claude_chatter.egg-info/entry_points.txt +3 -0
- claude_chatter-0.2.1/claude_chatter.egg-info/requires.txt +6 -0
- claude_chatter-0.2.1/claude_chatter.egg-info/top_level.txt +1 -0
- claude_chatter-0.2.1/pyproject.toml +44 -0
- claude_chatter-0.2.1/setup.cfg +4 -0
- claude_chatter-0.2.1/tests/test_suite.py +1817 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 non7top
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: claude-chatter
|
|
3
|
+
Version: 0.2.1
|
|
4
|
+
Summary: Claude Code peer messaging protocol and client library.
|
|
5
|
+
Author: non7top
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/non7top/claude-chatter
|
|
8
|
+
Project-URL: Issues, https://github.com/non7top/claude-chatter/issues
|
|
9
|
+
Project-URL: Changelog, https://github.com/non7top/claude-chatter/blob/master/CHANGELOG.md
|
|
10
|
+
Keywords: claude-code,ipc,unix-domain-sockets,peer-messaging
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Operating System :: POSIX
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
16
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
17
|
+
Requires-Python: >=3.10
|
|
18
|
+
Description-Content-Type: text/markdown
|
|
19
|
+
License-File: LICENSE
|
|
20
|
+
Requires-Dist: psutil>=5.9.0
|
|
21
|
+
Provides-Extra: dev
|
|
22
|
+
Requires-Dist: pytest>=7.0.0; extra == "dev"
|
|
23
|
+
Requires-Dist: flake8>=6.0.0; extra == "dev"
|
|
24
|
+
Requires-Dist: build>=1.0.0; extra == "dev"
|
|
25
|
+
Dynamic: license-file
|
|
26
|
+
|
|
27
|
+
# claude-chatter
|
|
28
|
+
|
|
29
|
+
Claude Code peer messaging protocol and client library.
|
|
30
|
+
|
|
31
|
+
`claude-chatter` provides a standalone Python implementation of the Claude Code peer-to-peer messaging protocol. It handles peer discovery via local session descriptors (`~/.claude/sessions/*.json`), background jobs inspection (`~/.claude/jobs`), UNIX domain socket IPC, NDJSON message framing, and local SQLite mailbox persistence.
|
|
32
|
+
|
|
33
|
+
This library has no dependencies on FastMCP or Antigravity and can be used directly in any Python application or CLI workflow.
|
|
34
|
+
|
|
35
|
+
## Installation
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
pip install claude-chatter
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Messaging tools
|
|
42
|
+
|
|
43
|
+
The library implements the peer messaging tools that Claude Code exposes to its own agents (`SendMessage` and `ListAgents`), so any Python program can act as a peer:
|
|
44
|
+
|
|
45
|
+
- `ClaudeClient.send_message(target_session, message_content, priority="next")` delivers a message to a live session over its UNIX socket. The target is resolved by name, PID, session id or a partial name match.
|
|
46
|
+
- `ClaudeClient.list_sessions()` returns the live sessions found in `~/.claude/sessions`, with peer tokens redacted unless `redact_tokens=False`. `ClaudeWire.scan_sessions()` does the same without a client.
|
|
47
|
+
|
|
48
|
+
Received messages are stored in the local mailbox and read with `get_unread_messages()` and `get_history()`. The CLI equivalents are `--send`, `--list`, `--inbox` and `--history`.
|
|
49
|
+
|
|
50
|
+
## Quick Start
|
|
51
|
+
|
|
52
|
+
### As a Library
|
|
53
|
+
|
|
54
|
+
```python
|
|
55
|
+
import asyncio
|
|
56
|
+
from claude_chatter import ClaudeClient, ClaudeWire
|
|
57
|
+
|
|
58
|
+
async def main():
|
|
59
|
+
# Stateless discovery
|
|
60
|
+
sessions = ClaudeWire.scan_sessions()
|
|
61
|
+
print("Discovered sessions:", sessions)
|
|
62
|
+
|
|
63
|
+
# Initialize client node
|
|
64
|
+
client = ClaudeClient(session_name="my-worker")
|
|
65
|
+
|
|
66
|
+
# Send message to an active session
|
|
67
|
+
res = await client.send_message(
|
|
68
|
+
target_session="other-session",
|
|
69
|
+
message_content="Hello from claude-chatter"
|
|
70
|
+
)
|
|
71
|
+
print("Send status:", res)
|
|
72
|
+
|
|
73
|
+
if __name__ == "__main__":
|
|
74
|
+
asyncio.run(main())
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### Inbound Message Callback
|
|
78
|
+
|
|
79
|
+
```python
|
|
80
|
+
async def on_message(event):
|
|
81
|
+
print(f"Received frame {event['msg_id']} from {event['sender']}: {event['content']}")
|
|
82
|
+
|
|
83
|
+
client = ClaudeClient(session_name="listener", on_inbound_message=on_message)
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### CLI Tool
|
|
87
|
+
|
|
88
|
+
The package installs both `claude-chatter` and `chatter` CLI entry points:
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
# List all active Claude Code sessions
|
|
92
|
+
claude-chatter --list
|
|
93
|
+
|
|
94
|
+
# List Claude Code background jobs
|
|
95
|
+
claude-chatter --jobs
|
|
96
|
+
|
|
97
|
+
# Inspect unread messages from local mailbox
|
|
98
|
+
claude-chatter --inbox
|
|
99
|
+
|
|
100
|
+
# View full persisted message history
|
|
101
|
+
claude-chatter --history
|
|
102
|
+
|
|
103
|
+
# Send message to a target session
|
|
104
|
+
claude-chatter --send target-session "Hello peer"
|
|
105
|
+
|
|
106
|
+
# Run standalone daemon socket listener
|
|
107
|
+
claude-chatter --standalone --name my-daemon
|
|
108
|
+
|
|
109
|
+
# Proactively scan and purge dead session files
|
|
110
|
+
claude-chatter --purge
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
## Provenance
|
|
114
|
+
|
|
115
|
+
`claude-chatter` was extracted from [non7top/claude-chatter-mcp](https://github.com/non7top/claude-chatter-mcp) to provide a reusable, host-independent library for the Claude Code peer messaging protocol with zero MCP dependencies. Full commit history of the protocol core was preserved during the separation.
|
|
116
|
+
|
|
117
|
+
## License
|
|
118
|
+
|
|
119
|
+
MIT
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# claude-chatter
|
|
2
|
+
|
|
3
|
+
Claude Code peer messaging protocol and client library.
|
|
4
|
+
|
|
5
|
+
`claude-chatter` provides a standalone Python implementation of the Claude Code peer-to-peer messaging protocol. It handles peer discovery via local session descriptors (`~/.claude/sessions/*.json`), background jobs inspection (`~/.claude/jobs`), UNIX domain socket IPC, NDJSON message framing, and local SQLite mailbox persistence.
|
|
6
|
+
|
|
7
|
+
This library has no dependencies on FastMCP or Antigravity and can be used directly in any Python application or CLI workflow.
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
pip install claude-chatter
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Messaging tools
|
|
16
|
+
|
|
17
|
+
The library implements the peer messaging tools that Claude Code exposes to its own agents (`SendMessage` and `ListAgents`), so any Python program can act as a peer:
|
|
18
|
+
|
|
19
|
+
- `ClaudeClient.send_message(target_session, message_content, priority="next")` delivers a message to a live session over its UNIX socket. The target is resolved by name, PID, session id or a partial name match.
|
|
20
|
+
- `ClaudeClient.list_sessions()` returns the live sessions found in `~/.claude/sessions`, with peer tokens redacted unless `redact_tokens=False`. `ClaudeWire.scan_sessions()` does the same without a client.
|
|
21
|
+
|
|
22
|
+
Received messages are stored in the local mailbox and read with `get_unread_messages()` and `get_history()`. The CLI equivalents are `--send`, `--list`, `--inbox` and `--history`.
|
|
23
|
+
|
|
24
|
+
## Quick Start
|
|
25
|
+
|
|
26
|
+
### As a Library
|
|
27
|
+
|
|
28
|
+
```python
|
|
29
|
+
import asyncio
|
|
30
|
+
from claude_chatter import ClaudeClient, ClaudeWire
|
|
31
|
+
|
|
32
|
+
async def main():
|
|
33
|
+
# Stateless discovery
|
|
34
|
+
sessions = ClaudeWire.scan_sessions()
|
|
35
|
+
print("Discovered sessions:", sessions)
|
|
36
|
+
|
|
37
|
+
# Initialize client node
|
|
38
|
+
client = ClaudeClient(session_name="my-worker")
|
|
39
|
+
|
|
40
|
+
# Send message to an active session
|
|
41
|
+
res = await client.send_message(
|
|
42
|
+
target_session="other-session",
|
|
43
|
+
message_content="Hello from claude-chatter"
|
|
44
|
+
)
|
|
45
|
+
print("Send status:", res)
|
|
46
|
+
|
|
47
|
+
if __name__ == "__main__":
|
|
48
|
+
asyncio.run(main())
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### Inbound Message Callback
|
|
52
|
+
|
|
53
|
+
```python
|
|
54
|
+
async def on_message(event):
|
|
55
|
+
print(f"Received frame {event['msg_id']} from {event['sender']}: {event['content']}")
|
|
56
|
+
|
|
57
|
+
client = ClaudeClient(session_name="listener", on_inbound_message=on_message)
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### CLI Tool
|
|
61
|
+
|
|
62
|
+
The package installs both `claude-chatter` and `chatter` CLI entry points:
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
# List all active Claude Code sessions
|
|
66
|
+
claude-chatter --list
|
|
67
|
+
|
|
68
|
+
# List Claude Code background jobs
|
|
69
|
+
claude-chatter --jobs
|
|
70
|
+
|
|
71
|
+
# Inspect unread messages from local mailbox
|
|
72
|
+
claude-chatter --inbox
|
|
73
|
+
|
|
74
|
+
# View full persisted message history
|
|
75
|
+
claude-chatter --history
|
|
76
|
+
|
|
77
|
+
# Send message to a target session
|
|
78
|
+
claude-chatter --send target-session "Hello peer"
|
|
79
|
+
|
|
80
|
+
# Run standalone daemon socket listener
|
|
81
|
+
claude-chatter --standalone --name my-daemon
|
|
82
|
+
|
|
83
|
+
# Proactively scan and purge dead session files
|
|
84
|
+
claude-chatter --purge
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## Provenance
|
|
88
|
+
|
|
89
|
+
`claude-chatter` was extracted from [non7top/claude-chatter-mcp](https://github.com/non7top/claude-chatter-mcp) to provide a reusable, host-independent library for the Claude Code peer messaging protocol with zero MCP dependencies. Full commit history of the protocol core was preserved during the separation.
|
|
90
|
+
|
|
91
|
+
## License
|
|
92
|
+
|
|
93
|
+
MIT
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"""
|
|
2
|
+
claude-chatter: Generic peer messaging and session protocol library for Claude Code.
|
|
3
|
+
"""
|
|
4
|
+
from .wire import ClaudeWire
|
|
5
|
+
from .client import ClaudeClient
|
|
6
|
+
from .protocol import ClaudeMessagingProtocol
|
|
7
|
+
from .jobs import list_jobs
|
|
8
|
+
from .storage import MessageStore, ResponseStore
|
|
9
|
+
from .exceptions import ChatterError, SessionNameInUseError, StorageError
|
|
10
|
+
|
|
11
|
+
__all__ = [
|
|
12
|
+
"ClaudeWire",
|
|
13
|
+
"ClaudeClient",
|
|
14
|
+
"ClaudeMessagingProtocol",
|
|
15
|
+
"list_jobs",
|
|
16
|
+
"MessageStore",
|
|
17
|
+
"ResponseStore",
|
|
18
|
+
"ChatterError",
|
|
19
|
+
"SessionNameInUseError",
|
|
20
|
+
"StorageError",
|
|
21
|
+
]
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
"""
|
|
2
|
+
CLI entry point for claude-chatter: argument parsing and mode dispatch.
|
|
3
|
+
"""
|
|
4
|
+
import os
|
|
5
|
+
import sys
|
|
6
|
+
import json
|
|
7
|
+
import asyncio
|
|
8
|
+
import logging
|
|
9
|
+
import argparse
|
|
10
|
+
from logging.handlers import RotatingFileHandler
|
|
11
|
+
|
|
12
|
+
if __package__:
|
|
13
|
+
from .client import ClaudeClient
|
|
14
|
+
from .standalone import run_standalone
|
|
15
|
+
else:
|
|
16
|
+
from pathlib import Path
|
|
17
|
+
sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
|
|
18
|
+
from claude_chatter.client import ClaudeClient
|
|
19
|
+
from claude_chatter.standalone import run_standalone
|
|
20
|
+
|
|
21
|
+
_LOG_FORMAT = "%(asctime)s [%(levelname)s] [pid=%(process)d] %(message)s"
|
|
22
|
+
_log_handlers = [logging.StreamHandler(sys.stderr)]
|
|
23
|
+
try:
|
|
24
|
+
_log_dir = os.path.expanduser("~/.claude/logs")
|
|
25
|
+
os.makedirs(_log_dir, exist_ok=True)
|
|
26
|
+
_log_handlers.append(
|
|
27
|
+
RotatingFileHandler(
|
|
28
|
+
os.path.join(_log_dir, "claude-chatter.log"),
|
|
29
|
+
maxBytes=5 * 1024 * 1024,
|
|
30
|
+
backupCount=3
|
|
31
|
+
)
|
|
32
|
+
)
|
|
33
|
+
except OSError:
|
|
34
|
+
pass
|
|
35
|
+
|
|
36
|
+
logging.basicConfig(level=logging.INFO, format=_LOG_FORMAT, handlers=_log_handlers)
|
|
37
|
+
logger = logging.getLogger("claude_chatter")
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def main():
|
|
41
|
+
parser = argparse.ArgumentParser(description="Claude Code peer messaging protocol and client CLI tool")
|
|
42
|
+
parser.add_argument("--socket", type=str, default=None, help="Path to bridge Unix socket")
|
|
43
|
+
parser.add_argument("--name", type=str, default=None, help="Session name announced to Claude Code (default: derived from cwd)")
|
|
44
|
+
parser.add_argument("--db", type=str, default=None, help="Path to SQLite database for message persistence")
|
|
45
|
+
parser.add_argument("--project-path", type=str, default=None, help="Explicit project directory path")
|
|
46
|
+
|
|
47
|
+
mode_group = parser.add_argument_group("Execution Modes")
|
|
48
|
+
mode_group.add_argument("--standalone", "--daemon", action="store_true", help="Run as standalone daemon listener")
|
|
49
|
+
mode_group.add_argument("--list", action="store_true", help="List all active Claude Code sessions")
|
|
50
|
+
mode_group.add_argument("--jobs", action="store_true", help="List Claude Code background jobs from ~/.claude/jobs")
|
|
51
|
+
mode_group.add_argument("--inbox", action="store_true", help="List unread inbound messages from persisted inbox")
|
|
52
|
+
mode_group.add_argument("--history", action="store_true", help="List full persisted message history")
|
|
53
|
+
mode_group.add_argument("--send", nargs=2, metavar=("SESSION", "MESSAGE"), help="Send message to target Claude Code session")
|
|
54
|
+
mode_group.add_argument("--purge", action="store_true", help="Proactively scan and purge dead session files")
|
|
55
|
+
|
|
56
|
+
args = parser.parse_args()
|
|
57
|
+
|
|
58
|
+
if args.list:
|
|
59
|
+
client = ClaudeClient(bridge_socket_path=args.socket, session_name=args.name, enable_storage=False, as_bridge=False, project_path=args.project_path)
|
|
60
|
+
|
|
61
|
+
async def _cmd_list():
|
|
62
|
+
peers = await client.verify_and_purge_sessions()
|
|
63
|
+
print(json.dumps(client.redact_peers(peers), indent=2))
|
|
64
|
+
asyncio.run(_cmd_list())
|
|
65
|
+
sys.exit(0)
|
|
66
|
+
|
|
67
|
+
elif args.jobs:
|
|
68
|
+
from .jobs import list_jobs
|
|
69
|
+
client = ClaudeClient(bridge_socket_path=args.socket, session_name=args.name, enable_storage=False, as_bridge=False, project_path=args.project_path)
|
|
70
|
+
|
|
71
|
+
async def _cmd_jobs():
|
|
72
|
+
peers = await client.verify_and_purge_sessions()
|
|
73
|
+
print(json.dumps(list_jobs(live_sessions=peers), indent=2))
|
|
74
|
+
asyncio.run(_cmd_jobs())
|
|
75
|
+
sys.exit(0)
|
|
76
|
+
|
|
77
|
+
elif args.inbox:
|
|
78
|
+
target_name = ClaudeClient.resolve_session_name(args.name, project_path=args.project_path, db_path=args.db)
|
|
79
|
+
if not target_name:
|
|
80
|
+
print(json.dumps({}, indent=2))
|
|
81
|
+
sys.exit(0)
|
|
82
|
+
db_file = args.db or os.environ.get("CHATTER_DB_PATH") or os.path.join(os.path.expanduser("~"), ".claude", "chatter-messages.db")
|
|
83
|
+
if not os.path.exists(db_file):
|
|
84
|
+
print(json.dumps({}, indent=2))
|
|
85
|
+
sys.exit(0)
|
|
86
|
+
from .storage import MessageStore
|
|
87
|
+
store = MessageStore(db_file, read_only=True)
|
|
88
|
+
all_msgs = store.load_session_messages(target_name)
|
|
89
|
+
unread = {
|
|
90
|
+
k: v for k, v in all_msgs.items()
|
|
91
|
+
if v.get("direction") == "inbound" and not v.get("read", False)
|
|
92
|
+
}
|
|
93
|
+
unread = dict(sorted(unread.items(), key=lambda kv: kv[1].get("timestamp", 0)))
|
|
94
|
+
print(json.dumps(unread, indent=2))
|
|
95
|
+
store.close()
|
|
96
|
+
sys.exit(0)
|
|
97
|
+
|
|
98
|
+
elif args.history:
|
|
99
|
+
target_name = ClaudeClient.resolve_session_name(args.name, project_path=args.project_path, db_path=args.db)
|
|
100
|
+
if not target_name:
|
|
101
|
+
print(json.dumps({}, indent=2))
|
|
102
|
+
sys.exit(0)
|
|
103
|
+
db_file = args.db or os.environ.get("CHATTER_DB_PATH") or os.path.join(os.path.expanduser("~"), ".claude", "chatter-messages.db")
|
|
104
|
+
if not os.path.exists(db_file):
|
|
105
|
+
print(json.dumps({}, indent=2))
|
|
106
|
+
sys.exit(0)
|
|
107
|
+
from .storage import MessageStore
|
|
108
|
+
store = MessageStore(db_file, read_only=True)
|
|
109
|
+
all_msgs = store.load_session_messages(target_name)
|
|
110
|
+
all_msgs = dict(sorted(all_msgs.items(), key=lambda kv: kv[1].get("timestamp", 0)))
|
|
111
|
+
print(json.dumps(all_msgs, indent=2))
|
|
112
|
+
store.close()
|
|
113
|
+
sys.exit(0)
|
|
114
|
+
|
|
115
|
+
elif args.purge:
|
|
116
|
+
client = ClaudeClient(bridge_socket_path=args.socket, session_name=args.name, enable_storage=False, as_bridge=False, project_path=args.project_path)
|
|
117
|
+
|
|
118
|
+
async def _cmd_purge():
|
|
119
|
+
peers = await client.verify_and_purge_sessions()
|
|
120
|
+
print(f"Purge scan completed. Active sessions remaining: {len(peers)}")
|
|
121
|
+
asyncio.run(_cmd_purge())
|
|
122
|
+
sys.exit(0)
|
|
123
|
+
|
|
124
|
+
elif args.send:
|
|
125
|
+
client = ClaudeClient(bridge_socket_path=args.socket, session_name=args.name, enable_storage=False, as_bridge=False, project_path=args.project_path)
|
|
126
|
+
target_session, message_text = args.send[0], args.send[1]
|
|
127
|
+
|
|
128
|
+
async def _cmd_send():
|
|
129
|
+
res = await client.send_message(
|
|
130
|
+
target_session=target_session,
|
|
131
|
+
message_content=message_text
|
|
132
|
+
)
|
|
133
|
+
print(json.dumps(res, indent=2))
|
|
134
|
+
if not res.get("success"):
|
|
135
|
+
sys.exit(1)
|
|
136
|
+
asyncio.run(_cmd_send())
|
|
137
|
+
sys.exit(0)
|
|
138
|
+
|
|
139
|
+
elif args.standalone:
|
|
140
|
+
client = ClaudeClient(bridge_socket_path=args.socket, session_name=args.name, db_path=args.db, as_bridge=True, project_path=args.project_path)
|
|
141
|
+
try:
|
|
142
|
+
asyncio.run(run_standalone(client))
|
|
143
|
+
except (KeyboardInterrupt, SystemExit):
|
|
144
|
+
logger.info("Shutting down standalone daemon gracefully.")
|
|
145
|
+
except Exception as e:
|
|
146
|
+
logger.error(f"Fatal standalone server error: {e}")
|
|
147
|
+
sys.exit(0)
|
|
148
|
+
|
|
149
|
+
else:
|
|
150
|
+
parser.print_help()
|
|
151
|
+
sys.exit(0)
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
if __name__ == "__main__":
|
|
155
|
+
main()
|