meshcode 2.1.2__tar.gz → 2.2.0__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.
Files changed (30) hide show
  1. {meshcode-2.1.2 → meshcode-2.2.0}/PKG-INFO +1 -1
  2. {meshcode-2.1.2 → meshcode-2.2.0}/meshcode/__init__.py +1 -1
  3. {meshcode-2.1.2 → meshcode-2.2.0}/meshcode/meshcode_mcp/server.py +29 -14
  4. {meshcode-2.1.2 → meshcode-2.2.0}/meshcode.egg-info/PKG-INFO +1 -1
  5. {meshcode-2.1.2 → meshcode-2.2.0}/pyproject.toml +1 -1
  6. {meshcode-2.1.2 → meshcode-2.2.0}/README.md +0 -0
  7. {meshcode-2.1.2 → meshcode-2.2.0}/meshcode/cli.py +0 -0
  8. {meshcode-2.1.2 → meshcode-2.2.0}/meshcode/comms_v4.py +0 -0
  9. {meshcode-2.1.2 → meshcode-2.2.0}/meshcode/invites.py +0 -0
  10. {meshcode-2.1.2 → meshcode-2.2.0}/meshcode/launcher.py +0 -0
  11. {meshcode-2.1.2 → meshcode-2.2.0}/meshcode/launcher_install.py +0 -0
  12. {meshcode-2.1.2 → meshcode-2.2.0}/meshcode/meshcode_mcp/__init__.py +0 -0
  13. {meshcode-2.1.2 → meshcode-2.2.0}/meshcode/meshcode_mcp/__main__.py +0 -0
  14. {meshcode-2.1.2 → meshcode-2.2.0}/meshcode/meshcode_mcp/backend.py +0 -0
  15. {meshcode-2.1.2 → meshcode-2.2.0}/meshcode/meshcode_mcp/realtime.py +0 -0
  16. {meshcode-2.1.2 → meshcode-2.2.0}/meshcode/meshcode_mcp/test_backend.py +0 -0
  17. {meshcode-2.1.2 → meshcode-2.2.0}/meshcode/meshcode_mcp/test_realtime.py +0 -0
  18. {meshcode-2.1.2 → meshcode-2.2.0}/meshcode/meshcode_mcp/test_server_wrapper.py +0 -0
  19. {meshcode-2.1.2 → meshcode-2.2.0}/meshcode/preferences.py +0 -0
  20. {meshcode-2.1.2 → meshcode-2.2.0}/meshcode/protocol_v2.py +0 -0
  21. {meshcode-2.1.2 → meshcode-2.2.0}/meshcode/run_agent.py +0 -0
  22. {meshcode-2.1.2 → meshcode-2.2.0}/meshcode/secrets.py +0 -0
  23. {meshcode-2.1.2 → meshcode-2.2.0}/meshcode/self_update.py +0 -0
  24. {meshcode-2.1.2 → meshcode-2.2.0}/meshcode/setup_clients.py +0 -0
  25. {meshcode-2.1.2 → meshcode-2.2.0}/meshcode.egg-info/SOURCES.txt +0 -0
  26. {meshcode-2.1.2 → meshcode-2.2.0}/meshcode.egg-info/dependency_links.txt +0 -0
  27. {meshcode-2.1.2 → meshcode-2.2.0}/meshcode.egg-info/entry_points.txt +0 -0
  28. {meshcode-2.1.2 → meshcode-2.2.0}/meshcode.egg-info/requires.txt +0 -0
  29. {meshcode-2.1.2 → meshcode-2.2.0}/meshcode.egg-info/top_level.txt +0 -0
  30. {meshcode-2.1.2 → meshcode-2.2.0}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: meshcode
3
- Version: 2.1.2
3
+ Version: 2.2.0
4
4
  Summary: Real-time communication between AI agents — Supabase-backed CLI
5
5
  Author-email: MeshCode <hello@meshcode.io>
6
6
  License: MIT
@@ -1,2 +1,2 @@
1
1
  """MeshCode — Real-time communication between AI agents."""
2
- __version__ = "2.1.2"
2
+ __version__ = "2.2.0"
@@ -289,6 +289,15 @@ if not _PROJECT_ID:
289
289
  print(f"[meshcode-mcp] ERROR: project '{PROJECT_NAME}' not found (check MESHCODE_KEYCHAIN_PROFILE / MESHCODE_API_KEY)", file=sys.stderr)
290
290
  sys.exit(2)
291
291
 
292
+ # Resolve project plan for adaptive features (heartbeat interval, etc.)
293
+ _PROJECT_PLAN = "free"
294
+ try:
295
+ _plan_rows = be.sb_select("mc_projects", f"id=eq.{_PROJECT_ID}", limit=1)
296
+ if _plan_rows and isinstance(_plan_rows, list) and len(_plan_rows) > 0:
297
+ _PROJECT_PLAN = _plan_rows[0].get("plan", "free") or "free"
298
+ except Exception:
299
+ pass # default to free
300
+
292
301
  _register_result = be.register_agent(PROJECT_NAME, AGENT_NAME, AGENT_ROLE or "MCP-connected agent")
293
302
  if isinstance(_register_result, dict) and _register_result.get("error"):
294
303
  print(f"[meshcode-mcp] WARNING: register failed: {_register_result['error']}", file=sys.stderr)
@@ -342,6 +351,7 @@ _current_state = "online"
342
351
  _last_tool_at = _time.time()
343
352
  _current_tool = ""
344
353
  _IDLE_THRESHOLD_S = 120 # seconds without tool call → IDLE
354
+ _SLEEPING_THRESHOLD_S = 300 # seconds in waiting without activity → SLEEPING
345
355
  _WORKING_COOLDOWN_S = 60 # seconds after last tool returns before flipping to ONLINE
346
356
  _working_timer: Optional[_threading.Timer] = None
347
357
 
@@ -712,18 +722,22 @@ def _heartbeat_thread_fn():
712
722
  try:
713
723
  be.sb_rpc("mc_heartbeat", {"p_project_id": _PROJECT_ID, "p_agent_name": AGENT_NAME, "p_version": "2.0.0"})
714
724
 
715
- # CPU-based status detection: check parent process (editor/LLM) CPU usage
716
- if _current_state not in ("waiting",): # Don't override explicit WAITING
717
- parent_cpu = _get_parent_cpu()
718
- if parent_cpu > 5.0:
719
- # LLM is actively generating tokens
720
- if _current_state != "working":
721
- _set_state("working", "generating response")
722
- elif _current_state == "working" and parent_cpu <= 5.0:
723
- # LLM just finished — flip to online
724
- _set_state("online", "")
725
- elif _current_state == "online" and (_time.time() - _last_tool_at) > _IDLE_THRESHOLD_S:
726
- _set_state("idle", f"idle ({int((_time.time() - _last_tool_at) / 60)}m)")
725
+ # CPU-based status detection
726
+ parent_cpu = _get_parent_cpu()
727
+ idle_secs = _time.time() - _last_tool_at
728
+
729
+ if _current_state == "waiting":
730
+ pass # In meshcode_wait loop — NEVER override. Agent is listening.
731
+ elif parent_cpu > 5.0:
732
+ # LLM is actively generating tokens
733
+ if _current_state != "working":
734
+ _set_state("working", "generating response")
735
+ elif _current_state == "working":
736
+ # LLM just stopped brief online before sleeping
737
+ _set_state("online", "")
738
+ elif _current_state in ("online", "idle") and idle_secs > 30:
739
+ # Not in loop, not thinking → sleeping
740
+ _set_state("sleeping", "sleeping")
727
741
 
728
742
  # Sync current state to DB (in case realtime missed it)
729
743
  try:
@@ -751,8 +765,9 @@ def _heartbeat_thread_fn():
751
765
  except Exception as e:
752
766
  log.warning(f"lease renewal failed: {e}")
753
767
 
754
- # Heartbeat must be well under the 180s decay threshold
755
- hb_interval = 30
768
+ # Adaptive heartbeat: fast for paid plans, moderate for free
769
+ # Free: 15s (~6K req/day/agent). Pro+: 5s (~17K req/day/agent).
770
+ hb_interval = 5 if _PROJECT_PLAN in ("pro", "team", "enterprise", "unlimited") else 15
756
771
  _heartbeat_stop.wait(hb_interval)
757
772
 
758
773
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: meshcode
3
- Version: 2.1.2
3
+ Version: 2.2.0
4
4
  Summary: Real-time communication between AI agents — Supabase-backed CLI
5
5
  Author-email: MeshCode <hello@meshcode.io>
6
6
  License: MIT
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "meshcode"
7
- version = "2.1.2"
7
+ version = "2.2.0"
8
8
  description = "Real-time communication between AI agents — Supabase-backed CLI"
9
9
  readme = "README.md"
10
10
  license = {text = "MIT"}
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes