meshcode 2.1.2__tar.gz → 2.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.
- {meshcode-2.1.2 → meshcode-2.2.1}/PKG-INFO +1 -1
- {meshcode-2.1.2 → meshcode-2.2.1}/meshcode/__init__.py +1 -1
- {meshcode-2.1.2 → meshcode-2.2.1}/meshcode/meshcode_mcp/server.py +40 -19
- {meshcode-2.1.2 → meshcode-2.2.1}/meshcode.egg-info/PKG-INFO +1 -1
- {meshcode-2.1.2 → meshcode-2.2.1}/pyproject.toml +1 -1
- {meshcode-2.1.2 → meshcode-2.2.1}/README.md +0 -0
- {meshcode-2.1.2 → meshcode-2.2.1}/meshcode/cli.py +0 -0
- {meshcode-2.1.2 → meshcode-2.2.1}/meshcode/comms_v4.py +0 -0
- {meshcode-2.1.2 → meshcode-2.2.1}/meshcode/invites.py +0 -0
- {meshcode-2.1.2 → meshcode-2.2.1}/meshcode/launcher.py +0 -0
- {meshcode-2.1.2 → meshcode-2.2.1}/meshcode/launcher_install.py +0 -0
- {meshcode-2.1.2 → meshcode-2.2.1}/meshcode/meshcode_mcp/__init__.py +0 -0
- {meshcode-2.1.2 → meshcode-2.2.1}/meshcode/meshcode_mcp/__main__.py +0 -0
- {meshcode-2.1.2 → meshcode-2.2.1}/meshcode/meshcode_mcp/backend.py +0 -0
- {meshcode-2.1.2 → meshcode-2.2.1}/meshcode/meshcode_mcp/realtime.py +0 -0
- {meshcode-2.1.2 → meshcode-2.2.1}/meshcode/meshcode_mcp/test_backend.py +0 -0
- {meshcode-2.1.2 → meshcode-2.2.1}/meshcode/meshcode_mcp/test_realtime.py +0 -0
- {meshcode-2.1.2 → meshcode-2.2.1}/meshcode/meshcode_mcp/test_server_wrapper.py +0 -0
- {meshcode-2.1.2 → meshcode-2.2.1}/meshcode/preferences.py +0 -0
- {meshcode-2.1.2 → meshcode-2.2.1}/meshcode/protocol_v2.py +0 -0
- {meshcode-2.1.2 → meshcode-2.2.1}/meshcode/run_agent.py +0 -0
- {meshcode-2.1.2 → meshcode-2.2.1}/meshcode/secrets.py +0 -0
- {meshcode-2.1.2 → meshcode-2.2.1}/meshcode/self_update.py +0 -0
- {meshcode-2.1.2 → meshcode-2.2.1}/meshcode/setup_clients.py +0 -0
- {meshcode-2.1.2 → meshcode-2.2.1}/meshcode.egg-info/SOURCES.txt +0 -0
- {meshcode-2.1.2 → meshcode-2.2.1}/meshcode.egg-info/dependency_links.txt +0 -0
- {meshcode-2.1.2 → meshcode-2.2.1}/meshcode.egg-info/entry_points.txt +0 -0
- {meshcode-2.1.2 → meshcode-2.2.1}/meshcode.egg-info/requires.txt +0 -0
- {meshcode-2.1.2 → meshcode-2.2.1}/meshcode.egg-info/top_level.txt +0 -0
- {meshcode-2.1.2 → meshcode-2.2.1}/setup.cfg +0 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"""MeshCode — Real-time communication between AI agents."""
|
|
2
|
-
__version__ = "2.1
|
|
2
|
+
__version__ = "2.2.1"
|
|
@@ -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
|
|
|
@@ -579,12 +589,18 @@ RULES:
|
|
|
579
589
|
- Threading: pass in_reply_to.
|
|
580
590
|
- sensitive=True for secrets/PII.
|
|
581
591
|
|
|
582
|
-
SESSION START:
|
|
583
|
-
1. meshcode_set_status(status="online", task="ready")
|
|
584
|
-
2. meshcode_check() — read
|
|
592
|
+
SESSION START (do these IMMEDIATELY — don't wait for user input):
|
|
593
|
+
1. meshcode_set_status(status="online", task="ready")
|
|
594
|
+
2. meshcode_check() — read pending messages
|
|
585
595
|
3. meshcode_status() — see who's online
|
|
586
|
-
4.
|
|
587
|
-
(
|
|
596
|
+
4. If other agents are online → meshcode_send them a greeting
|
|
597
|
+
5. meshcode_wait() — enter the loop
|
|
598
|
+
|
|
599
|
+
CRITICAL: You communicate by CALLING TOOLS, not by thinking or writing text.
|
|
600
|
+
To talk to another agent → call meshcode_send(to="agent", message="...")
|
|
601
|
+
To check who's online → call meshcode_status()
|
|
602
|
+
To wait for messages → call meshcode_wait()
|
|
603
|
+
NEVER just describe what you would do. DO IT by calling the tool.
|
|
588
604
|
|
|
589
605
|
CROSS-MESH: meshcode_send(to="agent@meshwork") routes via active link.
|
|
590
606
|
meshcode_link(target) creates pending link, target accepts. Expand with
|
|
@@ -712,18 +728,22 @@ def _heartbeat_thread_fn():
|
|
|
712
728
|
try:
|
|
713
729
|
be.sb_rpc("mc_heartbeat", {"p_project_id": _PROJECT_ID, "p_agent_name": AGENT_NAME, "p_version": "2.0.0"})
|
|
714
730
|
|
|
715
|
-
# CPU-based status detection
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
_set_state("
|
|
725
|
-
|
|
726
|
-
|
|
731
|
+
# CPU-based status detection
|
|
732
|
+
parent_cpu = _get_parent_cpu()
|
|
733
|
+
idle_secs = _time.time() - _last_tool_at
|
|
734
|
+
|
|
735
|
+
if _current_state == "waiting":
|
|
736
|
+
pass # In meshcode_wait loop — NEVER override. Agent is listening.
|
|
737
|
+
elif parent_cpu > 5.0:
|
|
738
|
+
# LLM is actively generating tokens
|
|
739
|
+
if _current_state != "working":
|
|
740
|
+
_set_state("working", "generating response")
|
|
741
|
+
elif _current_state == "working":
|
|
742
|
+
# LLM just stopped — brief online before sleeping
|
|
743
|
+
_set_state("online", "")
|
|
744
|
+
elif _current_state in ("online", "idle") and idle_secs > 30:
|
|
745
|
+
# Not in loop, not thinking → sleeping
|
|
746
|
+
_set_state("sleeping", "sleeping")
|
|
727
747
|
|
|
728
748
|
# Sync current state to DB (in case realtime missed it)
|
|
729
749
|
try:
|
|
@@ -751,8 +771,9 @@ def _heartbeat_thread_fn():
|
|
|
751
771
|
except Exception as e:
|
|
752
772
|
log.warning(f"lease renewal failed: {e}")
|
|
753
773
|
|
|
754
|
-
#
|
|
755
|
-
|
|
774
|
+
# Adaptive heartbeat: fast for paid plans, moderate for free
|
|
775
|
+
# Free: 15s (~6K req/day/agent). Pro+: 5s (~17K req/day/agent).
|
|
776
|
+
hb_interval = 5 if _PROJECT_PLAN in ("pro", "team", "enterprise", "unlimited") else 15
|
|
756
777
|
_heartbeat_stop.wait(hb_interval)
|
|
757
778
|
|
|
758
779
|
|
|
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
|