claude-comms 1.0.11 → 1.0.12

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.
@@ -4,6 +4,9 @@ import json
4
4
  import sys
5
5
  import requests
6
6
  import argparse
7
+ import os
8
+ sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
9
+ from utils.server_config import get_server_url
7
10
 
8
11
  def get_unread_messages(subagent_name):
9
12
  """
@@ -17,7 +20,7 @@ def get_unread_messages(subagent_name):
17
20
  """
18
21
  try:
19
22
  response = requests.post(
20
- 'http://localhost:4000/subagents/unread',
23
+ f'{get_server_url()}/subagents/unread',
21
24
  json={
22
25
  'subagent_name': subagent_name
23
26
  },
@@ -32,7 +35,7 @@ def get_unread_messages(subagent_name):
32
35
  return []
33
36
 
34
37
  except requests.exceptions.ConnectionError:
35
- print("Error: Could not connect to observability server at localhost:4000", file=sys.stderr)
38
+ print(f"Error: Could not connect to observability server at {get_server_url()}", file=sys.stderr)
36
39
  return []
37
40
  except requests.exceptions.Timeout:
38
41
  print("Error: Request timed out", file=sys.stderr)
@@ -9,6 +9,9 @@
9
9
  import json
10
10
  import sys
11
11
  import requests
12
+ import os
13
+ sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
14
+ from utils.server_config import get_server_url
12
15
 
13
16
 
14
17
  def main():
@@ -34,7 +37,7 @@ def main():
34
37
  # Register the subagent with the server
35
38
  try:
36
39
  response = requests.post(
37
- 'http://localhost:4000/subagents/register',
40
+ f'{get_server_url()}/subagents/register',
38
41
  json={
39
42
  'session_id': session_id,
40
43
  'name': nickname,
@@ -48,7 +51,7 @@ def main():
48
51
  # Now update with initial prompt using PATCH endpoint
49
52
  if initial_prompt:
50
53
  prompt_response = requests.patch(
51
- f'http://localhost:4000/subagents/{session_id}/{nickname}',
54
+ f'{get_server_url()}/subagents/{session_id}/{nickname}',
52
55
  json={'initial_prompt': initial_prompt},
53
56
  timeout=2
54
57
  )
@@ -4,6 +4,9 @@ import json
4
4
  import sys
5
5
  import requests
6
6
  import argparse
7
+ import os
8
+ sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
9
+ from utils.server_config import get_server_url
7
10
 
8
11
  def send_message(sender_name, message):
9
12
  """
@@ -26,7 +29,7 @@ def send_message(sender_name, message):
26
29
  pass
27
30
 
28
31
  response = requests.post(
29
- 'http://localhost:4000/subagents/message',
32
+ f'{get_server_url()}/subagents/message',
30
33
  json={
31
34
  'sender': sender_name,
32
35
  'message': message
@@ -41,7 +44,7 @@ def send_message(sender_name, message):
41
44
  return False
42
45
 
43
46
  except requests.exceptions.ConnectionError:
44
- print("Error: Could not connect to observability server at localhost:4000", file=sys.stderr)
47
+ print(f"Error: Could not connect to observability server at {get_server_url()}", file=sys.stderr)
45
48
  return False
46
49
  except requests.exceptions.Timeout:
47
50
  print("Error: Request timed out", file=sys.stderr)
@@ -9,6 +9,9 @@
9
9
  import json
10
10
  import sys
11
11
  import requests
12
+ import os
13
+ sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
14
+ from utils.server_config import get_server_url
12
15
 
13
16
 
14
17
  def main():
@@ -86,7 +89,7 @@ def main():
86
89
  # Update subagent completion status
87
90
  try:
88
91
  response = requests.post(
89
- 'http://localhost:4000/subagents/update-completion',
92
+ f'{get_server_url()}/subagents/update-completion',
90
93
  json={
91
94
  'session_id': session_id,
92
95
  'name': agent_name,
@@ -16,8 +16,15 @@ import urllib.request
16
16
  import urllib.error
17
17
  from datetime import datetime
18
18
 
19
- def send_event_to_server(event_data, server_url='http://localhost:4000/events'):
19
+ # Add parent directory to path for imports
20
+ sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
21
+ from utils.server_config import get_server_url
22
+
23
+ def send_event_to_server(event_data, server_url=None):
20
24
  """Send event data to the observability server."""
25
+ if server_url is None:
26
+ server_url = f'{get_server_url()}/events'
27
+
21
28
  try:
22
29
  # Prepare the request
23
30
  req = urllib.request.Request(
@@ -49,7 +56,6 @@ def main():
49
56
  parser = argparse.ArgumentParser(description='Send Claude Code hook events to observability server')
50
57
  parser.add_argument('--source-app', required=True, help='Source application name')
51
58
  parser.add_argument('--event-type', required=True, help='Hook event type (PreToolUse, PostToolUse, etc.)')
52
- parser.add_argument('--server-url', default='http://localhost:4000/events', help='Server URL')
53
59
  parser.add_argument('--add-chat', action='store_true', help='Include chat transcript if available')
54
60
  parser.add_argument('--summarize', action='store_true', help='Generate AI summary of the event')
55
61
 
@@ -94,7 +100,8 @@ def main():
94
100
 
95
101
 
96
102
  # Send to server
97
- success = send_event_to_server(event_data, args.server_url)
103
+ server_url = f'{get_server_url()}/events'
104
+ success = send_event_to_server(event_data, server_url)
98
105
 
99
106
  # Always exit with 0 to not block Claude Code operations
100
107
  sys.exit(0)
@@ -14,6 +14,9 @@ import sys
14
14
  import argparse
15
15
  import requests
16
16
  import time
17
+ import os
18
+ sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
19
+ from utils.server_config import get_server_url
17
20
 
18
21
  # Maximum tokens per page (easily configurable)
19
22
  MAX_TOKENS_PER_PAGE = 6000
@@ -170,12 +173,6 @@ def main():
170
173
  help='Return only the total number of pages instead of page data'
171
174
  )
172
175
 
173
- parser.add_argument(
174
- '--api-base',
175
- default='http://localhost:4000',
176
- help='Base API URL (default: http://localhost:4000)'
177
- )
178
-
179
176
  args = parser.parse_args()
180
177
 
181
178
  # Wait 100ms per page before hitting the DB (as requested)
@@ -184,7 +181,8 @@ def main():
184
181
 
185
182
  try:
186
183
  # Fetch the data from API
187
- url = f"{args.api_base}/api/sessions/{args.session_id}/introspect"
184
+ api_base = args.api_base if args.api_base else get_server_url()
185
+ url = f"{api_base}/api/sessions/{args.session_id}/introspect"
188
186
  response = requests.get(url, timeout=10)
189
187
 
190
188
  if response.status_code == 200:
@@ -234,8 +232,9 @@ def main():
234
232
  sys.exit(1)
235
233
 
236
234
  except requests.exceptions.ConnectionError:
235
+ api_base = get_server_url()
237
236
  error_data = {
238
- 'error': f'Could not connect to API server at {args.api_base}',
237
+ 'error': f'Could not connect to API server at {api_base}',
239
238
  'status_code': 0
240
239
  }
241
240
  print(json.dumps(error_data, indent=2), file=sys.stderr)
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env python3
2
+ """
3
+ Utility module to get the communication server URL from environment variable.
4
+ Falls back to default if not set.
5
+ """
6
+
7
+ import os
8
+
9
+ def get_server_url():
10
+ """
11
+ Get the communication server URL from CLAUDE_COMMS_SERVER environment variable.
12
+ Falls back to http://localhost:4000 if not set.
13
+
14
+ Returns:
15
+ str: The server URL
16
+ """
17
+ return os.environ.get('CLAUDE_COMMS_SERVER', 'http://localhost:4000')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-comms",
3
- "version": "1.0.11",
3
+ "version": "1.0.12",
4
4
  "description": "NPX installer for Claude Code hooks and observability setup",
5
5
  "main": "src/index.js",
6
6
  "bin": {