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.
- {meshcode-2.1.2 → meshcode-2.2.0}/PKG-INFO +1 -1
- {meshcode-2.1.2 → meshcode-2.2.0}/meshcode/__init__.py +1 -1
- {meshcode-2.1.2 → meshcode-2.2.0}/meshcode/meshcode_mcp/server.py +29 -14
- {meshcode-2.1.2 → meshcode-2.2.0}/meshcode.egg-info/PKG-INFO +1 -1
- {meshcode-2.1.2 → meshcode-2.2.0}/pyproject.toml +1 -1
- {meshcode-2.1.2 → meshcode-2.2.0}/README.md +0 -0
- {meshcode-2.1.2 → meshcode-2.2.0}/meshcode/cli.py +0 -0
- {meshcode-2.1.2 → meshcode-2.2.0}/meshcode/comms_v4.py +0 -0
- {meshcode-2.1.2 → meshcode-2.2.0}/meshcode/invites.py +0 -0
- {meshcode-2.1.2 → meshcode-2.2.0}/meshcode/launcher.py +0 -0
- {meshcode-2.1.2 → meshcode-2.2.0}/meshcode/launcher_install.py +0 -0
- {meshcode-2.1.2 → meshcode-2.2.0}/meshcode/meshcode_mcp/__init__.py +0 -0
- {meshcode-2.1.2 → meshcode-2.2.0}/meshcode/meshcode_mcp/__main__.py +0 -0
- {meshcode-2.1.2 → meshcode-2.2.0}/meshcode/meshcode_mcp/backend.py +0 -0
- {meshcode-2.1.2 → meshcode-2.2.0}/meshcode/meshcode_mcp/realtime.py +0 -0
- {meshcode-2.1.2 → meshcode-2.2.0}/meshcode/meshcode_mcp/test_backend.py +0 -0
- {meshcode-2.1.2 → meshcode-2.2.0}/meshcode/meshcode_mcp/test_realtime.py +0 -0
- {meshcode-2.1.2 → meshcode-2.2.0}/meshcode/meshcode_mcp/test_server_wrapper.py +0 -0
- {meshcode-2.1.2 → meshcode-2.2.0}/meshcode/preferences.py +0 -0
- {meshcode-2.1.2 → meshcode-2.2.0}/meshcode/protocol_v2.py +0 -0
- {meshcode-2.1.2 → meshcode-2.2.0}/meshcode/run_agent.py +0 -0
- {meshcode-2.1.2 → meshcode-2.2.0}/meshcode/secrets.py +0 -0
- {meshcode-2.1.2 → meshcode-2.2.0}/meshcode/self_update.py +0 -0
- {meshcode-2.1.2 → meshcode-2.2.0}/meshcode/setup_clients.py +0 -0
- {meshcode-2.1.2 → meshcode-2.2.0}/meshcode.egg-info/SOURCES.txt +0 -0
- {meshcode-2.1.2 → meshcode-2.2.0}/meshcode.egg-info/dependency_links.txt +0 -0
- {meshcode-2.1.2 → meshcode-2.2.0}/meshcode.egg-info/entry_points.txt +0 -0
- {meshcode-2.1.2 → meshcode-2.2.0}/meshcode.egg-info/requires.txt +0 -0
- {meshcode-2.1.2 → meshcode-2.2.0}/meshcode.egg-info/top_level.txt +0 -0
- {meshcode-2.1.2 → meshcode-2.2.0}/setup.cfg +0 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"""MeshCode — Real-time communication between AI agents."""
|
|
2
|
-
__version__ = "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
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
_set_state("
|
|
725
|
-
|
|
726
|
-
|
|
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
|
-
#
|
|
755
|
-
|
|
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
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|