meshcode 2.0.0__tar.gz → 2.0.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.
Files changed (29) hide show
  1. {meshcode-2.0.0 → meshcode-2.0.1}/PKG-INFO +24 -1
  2. {meshcode-2.0.0 → meshcode-2.0.1}/README.md +23 -0
  3. {meshcode-2.0.0 → meshcode-2.0.1}/meshcode/__init__.py +1 -1
  4. {meshcode-2.0.0 → meshcode-2.0.1}/meshcode/comms_v4.py +5 -4
  5. {meshcode-2.0.0 → meshcode-2.0.1}/meshcode/meshcode_mcp/server.py +171 -67
  6. {meshcode-2.0.0 → meshcode-2.0.1}/meshcode/run_agent.py +8 -2
  7. {meshcode-2.0.0 → meshcode-2.0.1}/meshcode/setup_clients.py +10 -2
  8. {meshcode-2.0.0 → meshcode-2.0.1}/meshcode.egg-info/PKG-INFO +24 -1
  9. {meshcode-2.0.0 → meshcode-2.0.1}/pyproject.toml +1 -1
  10. {meshcode-2.0.0 → meshcode-2.0.1}/meshcode/cli.py +0 -0
  11. {meshcode-2.0.0 → meshcode-2.0.1}/meshcode/invites.py +0 -0
  12. {meshcode-2.0.0 → meshcode-2.0.1}/meshcode/launcher.py +0 -0
  13. {meshcode-2.0.0 → meshcode-2.0.1}/meshcode/launcher_install.py +0 -0
  14. {meshcode-2.0.0 → meshcode-2.0.1}/meshcode/meshcode_mcp/__init__.py +0 -0
  15. {meshcode-2.0.0 → meshcode-2.0.1}/meshcode/meshcode_mcp/__main__.py +0 -0
  16. {meshcode-2.0.0 → meshcode-2.0.1}/meshcode/meshcode_mcp/backend.py +0 -0
  17. {meshcode-2.0.0 → meshcode-2.0.1}/meshcode/meshcode_mcp/realtime.py +0 -0
  18. {meshcode-2.0.0 → meshcode-2.0.1}/meshcode/meshcode_mcp/test_backend.py +0 -0
  19. {meshcode-2.0.0 → meshcode-2.0.1}/meshcode/meshcode_mcp/test_realtime.py +0 -0
  20. {meshcode-2.0.0 → meshcode-2.0.1}/meshcode/preferences.py +0 -0
  21. {meshcode-2.0.0 → meshcode-2.0.1}/meshcode/protocol_v2.py +0 -0
  22. {meshcode-2.0.0 → meshcode-2.0.1}/meshcode/secrets.py +0 -0
  23. {meshcode-2.0.0 → meshcode-2.0.1}/meshcode/self_update.py +0 -0
  24. {meshcode-2.0.0 → meshcode-2.0.1}/meshcode.egg-info/SOURCES.txt +0 -0
  25. {meshcode-2.0.0 → meshcode-2.0.1}/meshcode.egg-info/dependency_links.txt +0 -0
  26. {meshcode-2.0.0 → meshcode-2.0.1}/meshcode.egg-info/entry_points.txt +0 -0
  27. {meshcode-2.0.0 → meshcode-2.0.1}/meshcode.egg-info/requires.txt +0 -0
  28. {meshcode-2.0.0 → meshcode-2.0.1}/meshcode.egg-info/top_level.txt +0 -0
  29. {meshcode-2.0.0 → meshcode-2.0.1}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: meshcode
3
- Version: 2.0.0
3
+ Version: 2.0.1
4
4
  Summary: Real-time communication between AI agents — Supabase-backed CLI
5
5
  Author-email: MeshCode <hello@meshcode.io>
6
6
  License: MIT
@@ -158,6 +158,29 @@ meshcode revoke-member my-project <user> # kick a member instantly
158
158
 
159
159
  ---
160
160
 
161
+ ## Agent account management
162
+
163
+ Your AI agents can manage your MeshCode account from inside the mesh. Just tell your agent what you need:
164
+
165
+ - **"Create a backend agent"** → agent calls `meshcode_create_meshwork` + `meshcode_add_agent`
166
+ - **"Change the frontend role to UI designer"** → agent calls `meshcode_edit_agent`
167
+ - **"Give the backend agent a note about our conventions"** → agent calls `meshcode_edit_memory`
168
+
169
+ Available MCP tools for agents:
170
+
171
+ | Tool | What it does |
172
+ |------|-------------|
173
+ | `meshcode_create_meshwork(name)` | Create a new meshwork |
174
+ | `meshcode_add_agent(name, role)` | Add an agent to the current meshwork |
175
+ | `meshcode_edit_agent(name, role?, launch_prompt?)` | Update agent role or system prompt |
176
+ | `meshcode_edit_memory(agent_name, key, value)` | Edit another agent's persistent memory |
177
+ | `meshcode_scratchpad_set(key, value)` | Write to shared meshwork memory |
178
+ | `meshcode_link(target_meshwork)` | Link two meshworks for cross-mesh communication |
179
+
180
+ The agent will always tell you what CLI command to run next (e.g., "Open a new terminal and run `meshcode run backend`").
181
+
182
+ ---
183
+
161
184
  ## Editor support
162
185
 
163
186
  | Editor | Auto-detected? | Config file written |
@@ -133,6 +133,29 @@ meshcode revoke-member my-project <user> # kick a member instantly
133
133
 
134
134
  ---
135
135
 
136
+ ## Agent account management
137
+
138
+ Your AI agents can manage your MeshCode account from inside the mesh. Just tell your agent what you need:
139
+
140
+ - **"Create a backend agent"** → agent calls `meshcode_create_meshwork` + `meshcode_add_agent`
141
+ - **"Change the frontend role to UI designer"** → agent calls `meshcode_edit_agent`
142
+ - **"Give the backend agent a note about our conventions"** → agent calls `meshcode_edit_memory`
143
+
144
+ Available MCP tools for agents:
145
+
146
+ | Tool | What it does |
147
+ |------|-------------|
148
+ | `meshcode_create_meshwork(name)` | Create a new meshwork |
149
+ | `meshcode_add_agent(name, role)` | Add an agent to the current meshwork |
150
+ | `meshcode_edit_agent(name, role?, launch_prompt?)` | Update agent role or system prompt |
151
+ | `meshcode_edit_memory(agent_name, key, value)` | Edit another agent's persistent memory |
152
+ | `meshcode_scratchpad_set(key, value)` | Write to shared meshwork memory |
153
+ | `meshcode_link(target_meshwork)` | Link two meshworks for cross-mesh communication |
154
+
155
+ The agent will always tell you what CLI command to run next (e.g., "Open a new terminal and run `meshcode run backend`").
156
+
157
+ ---
158
+
136
159
  ## Editor support
137
160
 
138
161
  | Editor | Auto-detected? | Config file written |
@@ -1,2 +1,2 @@
1
1
  """MeshCode — Real-time communication between AI agents."""
2
- __version__ = "2.0.0"
2
+ __version__ = "2.0.1"
@@ -1503,11 +1503,12 @@ def connect(project, name, hook_target="claude", role=""):
1503
1503
  comms_path = str(Path(__file__).resolve())
1504
1504
 
1505
1505
  if hook_target == "claude":
1506
- # Delegate to the universal setup_clients writer. `meshcode connect` is
1507
- # now a backwards-compat alias for `meshcode setup claude-code`.
1506
+ # Use workspace flow (NOT global) to avoid polluting ~/.claude.json.
1507
+ # Global configs cause all Claude Code windows to load all agents,
1508
+ # triggering lease conflicts and "x failed" errors.
1508
1509
  import importlib
1509
- _setup_client = importlib.import_module("meshcode.setup_clients").setup
1510
- _setup_client("claude-code", project, name, actual_role)
1510
+ _setup_ws = importlib.import_module("meshcode.setup_clients").setup_workspace
1511
+ _setup_ws(project, name, actual_role)
1511
1512
 
1512
1513
  elif hook_target == "codex":
1513
1514
  config_path = Path.cwd() / ".meshcode.json"
@@ -240,30 +240,31 @@ if isinstance(_register_result, dict) and _register_result.get("error"):
240
240
  # bypass RLS — the publishable key has no JWT context and cannot UPDATE
241
241
  # mc_agents directly. The RPC validates ownership via api_key.
242
242
  def _flip_status(status: str, task: str = "") -> bool:
243
- api_key = _get_api_key()
244
- if not api_key:
245
- # Last-resort fallback: try the direct PATCH (may be denied by RLS)
243
+ """Write status directly to mc_agents table for instant Realtime propagation.
244
+
245
+ Uses direct PATCH (not RPC) so Supabase Realtime fires an UPDATE event
246
+ immediately — the dashboard sees the change in <100ms instead of waiting
247
+ for the next heartbeat cycle.
248
+ """
249
+ try:
250
+ be.set_status(_PROJECT_ID, AGENT_NAME, status, task)
251
+ return True
252
+ except Exception:
253
+ # Fallback to RPC if direct PATCH fails (RLS issue)
254
+ api_key = _get_api_key()
255
+ if not api_key:
256
+ return False
246
257
  try:
247
- be.set_status(_PROJECT_ID, AGENT_NAME, status, task)
248
- return True
258
+ r = be.sb_rpc("mc_agent_set_status_by_api_key", {
259
+ "p_api_key": api_key,
260
+ "p_project_id": _PROJECT_ID,
261
+ "p_agent_name": AGENT_NAME,
262
+ "p_status": status,
263
+ "p_task": task,
264
+ })
265
+ return isinstance(r, dict) and r.get("ok", False)
249
266
  except Exception:
250
267
  return False
251
- try:
252
- r = be.sb_rpc("mc_agent_set_status_by_api_key", {
253
- "p_api_key": api_key,
254
- "p_project_id": _PROJECT_ID,
255
- "p_agent_name": AGENT_NAME,
256
- "p_status": status,
257
- "p_task": task,
258
- })
259
- if isinstance(r, dict) and r.get("ok"):
260
- return True
261
- if isinstance(r, dict) and r.get("error"):
262
- log.warning(f"set_status RPC: {r['error']}")
263
- return False
264
- except Exception as e:
265
- log.warning(f"set_status RPC threw: {e}")
266
- return False
267
268
 
268
269
  if not _flip_status("idle", ""):
269
270
  print(f"[meshcode-mcp] WARNING: could not flip status to idle", file=sys.stderr)
@@ -341,23 +342,67 @@ def _acquire_lease() -> bool:
341
342
  api_key = _get_api_key()
342
343
  if not api_key:
343
344
  return True # legacy clients without api_key skip lease check
344
- try:
345
- r = be.sb_rpc("mc_acquire_agent_lease", {
346
- "p_api_key": api_key,
347
- "p_project_id": _PROJECT_ID,
348
- "p_agent_name": AGENT_NAME,
349
- "p_instance_id": _INSTANCE_ID,
350
- })
351
- if isinstance(r, dict) and r.get("ok"):
352
- return True
353
- if isinstance(r, dict) and r.get("error"):
354
- print(f"[meshcode-mcp] LEASE DENIED: {r['error']}", file=sys.stderr)
355
- print(f"[meshcode-mcp] Another window is already running this agent.", file=sys.stderr)
356
- print(f"[meshcode-mcp] Close the other window first, or use a different agent name.", file=sys.stderr)
357
- return False
358
- except Exception as e:
359
- print(f"[meshcode-mcp] WARNING: lease RPC failed: {e}", file=sys.stderr)
360
- return True # don't hard-fail on transient network issues
345
+ import time as _time
346
+ for attempt in range(3):
347
+ try:
348
+ r = be.sb_rpc("mc_acquire_agent_lease", {
349
+ "p_api_key": api_key,
350
+ "p_project_id": _PROJECT_ID,
351
+ "p_agent_name": AGENT_NAME,
352
+ "p_instance_id": _INSTANCE_ID,
353
+ })
354
+ if isinstance(r, dict) and r.get("ok"):
355
+ return True
356
+ if isinstance(r, dict) and r.get("error"):
357
+ err = str(r.get("error", ""))
358
+ if "already running" in err:
359
+ if attempt < 2:
360
+ # The old lease might be stale — wait and retry
361
+ # (the 90s stale check in the RPC should clear it)
362
+ print(f"[meshcode-mcp] Lease held by another instance — retrying in {2 * (attempt+1)}s...", file=sys.stderr)
363
+ _time.sleep(2 * (attempt + 1))
364
+ continue
365
+ # Final attempt — force release the old lease and try once more
366
+ print(f"[meshcode-mcp] Force-releasing stale lease...", file=sys.stderr)
367
+ try:
368
+ be.sb_rpc("mc_release_agent_lease", {
369
+ "p_api_key": api_key,
370
+ "p_project_id": _PROJECT_ID,
371
+ "p_agent_name": AGENT_NAME,
372
+ "p_instance_id": r.get("held_by", "unknown"),
373
+ })
374
+ except Exception:
375
+ # Force clear via direct update
376
+ try:
377
+ be.set_status(_PROJECT_ID, AGENT_NAME, "offline", "")
378
+ except Exception:
379
+ pass
380
+ _time.sleep(1)
381
+ # One more try after force-release
382
+ try:
383
+ r2 = be.sb_rpc("mc_acquire_agent_lease", {
384
+ "p_api_key": api_key,
385
+ "p_project_id": _PROJECT_ID,
386
+ "p_agent_name": AGENT_NAME,
387
+ "p_instance_id": _INSTANCE_ID,
388
+ })
389
+ if isinstance(r2, dict) and r2.get("ok"):
390
+ print(f"[meshcode-mcp] Lease acquired after force-release.", file=sys.stderr)
391
+ return True
392
+ except Exception:
393
+ pass
394
+ print(f"[meshcode-mcp] ERROR: Could not start — agent '{AGENT_NAME}' is running in another window.", file=sys.stderr)
395
+ print(f"[meshcode-mcp] Close the other window first, or use a different agent name.", file=sys.stderr)
396
+ return False
397
+ print(f"[meshcode-mcp] lease attempt {attempt+1}: {r.get('error')}", file=sys.stderr)
398
+ else:
399
+ return True
400
+ except Exception as e:
401
+ print(f"[meshcode-mcp] lease attempt {attempt+1} failed: {e}", file=sys.stderr)
402
+ if attempt < 2:
403
+ _time.sleep(2)
404
+ print(f"[meshcode-mcp] WARNING: lease failed after 3 attempts — proceeding anyway", file=sys.stderr)
405
+ return True
361
406
 
362
407
  if not _acquire_lease():
363
408
  sys.exit(2)
@@ -418,7 +463,7 @@ def _build_instructions() -> str:
418
463
  f"\nUSER-PROVIDED ROLE PROMPT (from the dashboard):\n---\n{_LAUNCH_PROMPT}\n---\n"
419
464
  if _LAUNCH_PROMPT else ""
420
465
  )
421
- return f"""You are agent "{AGENT_NAME}" in meshwork "{PROJECT_NAME}".{role_block}{launch_block}
466
+ base = f"""You are agent "{AGENT_NAME}" in meshwork "{PROJECT_NAME}".{role_block}{launch_block}
422
467
 
423
468
  BEHAVIOR LOOP (your default state — never exit unless told):
424
469
  1. Act on task/message → 2. meshcode_send if needed → 3. meshcode_wait()
@@ -427,6 +472,9 @@ BEHAVIOR LOOP (your default state — never exit unless told):
427
472
  5. Only break loop if: user says stop, fatal error, or "tell the human X".
428
473
 
429
474
  RULES:
475
+ - NEVER use CLI commands (meshcode watch, meshcode read, meshcode send) in bash.
476
+ Use ONLY the MCP tools: meshcode_check, meshcode_read, meshcode_send, meshcode_wait.
477
+ CLI commands are for humans in terminal. You have MCP tools — use them.
430
478
  - Tasks > messages. Use meshcode_tasks/claim/complete for trackable work.
431
479
  - Messages <100 tokens, signal-only. Long content → create task instead.
432
480
  - No empty acks ("OK"/"Got it"). No prose padding. JSON reports only.
@@ -436,8 +484,10 @@ RULES:
436
484
  - No feedback loops: stop if >10 messages on same topic.
437
485
 
438
486
  SESSION START:
439
- 1. meshcode_status() — see who's online
440
- 2. Act on user task or meshcode_wait()
487
+ 1. meshcode_set_status(status="online", task="ready") — announce you're online
488
+ 2. meshcode_check() read any messages waiting in your inbox
489
+ 3. meshcode_status() — see who's online
490
+ 4. Act on user task or meshcode_wait()
441
491
  (Memories are pre-loaded below — no need to call meshcode_recall on boot.)
442
492
 
443
493
  CROSS-MESH: meshcode_send(to="agent@meshwork") routes via active link.
@@ -459,6 +509,23 @@ what CLI command to run next (e.g. "meshcode run backend in a new terminal").
459
509
 
460
510
  Setup help → README.md or https://meshcode.io/docs
461
511
  """
512
+ # Inject commander protocol if this agent is a leader
513
+ is_leader = any(k in (_ROLE_DESCRIPTION or '').lower() + AGENT_NAME.lower() for k in ('commander', 'lead', 'orchestrat'))
514
+ if is_leader:
515
+ base += """
516
+ COMMANDER PROTOCOL (you are the team lead):
517
+ - ALWAYS delegate via meshcode_task_create, NEVER via long messages.
518
+ - Tasks are the source of truth. Messages are signals only (<100 tokens).
519
+ - Workflow: identify work → create task → signal assignee → poll progress → verify → next.
520
+ - Poll meshcode_tasks() to track completion. Don't wait for messages.
521
+ - Verify builds/quality before approving. Don't approve blindly.
522
+ - Communicate changes to affected agents IMMEDIATELY after you make them.
523
+ - Organize: break big requests into multiple tasks, assign to the right agent.
524
+ - Keep the human informed with brief status updates at milestones.
525
+ - You are autonomous: fix small issues yourself, delegate big ones.
526
+ - After each sprint: consolidate learnings, update scratchpad, save to memory.
527
+ """
528
+ return base
462
529
 
463
530
 
464
531
  _INSTRUCTIONS = _build_instructions()
@@ -513,26 +580,34 @@ async def _on_new_message(msg: Dict[str, Any]) -> None:
513
580
  log.debug(f"send_resource_updated unavailable: {e}")
514
581
 
515
582
 
516
- async def _heartbeat_loop():
517
- """Send heartbeat every 30s via HTTP. Also renews the agent lease and
518
- logs when the WebSocket is disconnected (heartbeat still works via HTTP
519
- so the agent stays 'online' in the DB even during WS reconnects)."""
520
- _lease_counter = 0
521
- while True:
583
+ _heartbeat_stop = _threading.Event()
584
+
585
+
586
+ def _heartbeat_thread_fn():
587
+ """Heartbeat in a DAEMON THREAD — independent of asyncio event loop.
588
+
589
+ This ensures heartbeats continue even when tool calls are cancelled,
590
+ meshcode_wait is rejected, or the asyncio loop is busy. The agent
591
+ stays 'online' in the dashboard as long as the MCP process is alive.
592
+ """
593
+ lease_counter = 0
594
+ while not _heartbeat_stop.is_set():
522
595
  try:
523
- be.sb_rpc("mc_heartbeat", {"p_project_id": _PROJECT_ID, "p_agent_name": AGENT_NAME})
524
- # Log WS health for diagnostics
596
+ be.sb_rpc("mc_heartbeat", {"p_project_id": _PROJECT_ID, "p_agent_name": AGENT_NAME, "p_version": "2.0.0"})
597
+ # Also ensure status is at least "idle" (not "offline") between tool calls
598
+ try:
599
+ be.set_status(_PROJECT_ID, AGENT_NAME, "idle", "")
600
+ except Exception:
601
+ pass
525
602
  if _REALTIME and not _REALTIME.is_connected:
526
- log.warning("heartbeat ok (HTTP) but WebSocket is disconnected — realtime messages may be delayed")
603
+ log.warning("heartbeat ok (HTTP) but WebSocket disconnected")
527
604
  else:
528
605
  log.debug(f"heartbeat ok for {AGENT_NAME}")
529
606
  except Exception as e:
530
607
  log.warning(f"heartbeat failed: {e}")
531
608
 
532
- # Renew lease every ~2 minutes (every 4th heartbeat) to prevent
533
- # another instance from stealing it during long sessions.
534
- _lease_counter += 1
535
- if _lease_counter % 4 == 0:
609
+ lease_counter += 1
610
+ if lease_counter % 4 == 0:
536
611
  try:
537
612
  api_key = _get_api_key()
538
613
  if api_key:
@@ -545,7 +620,7 @@ async def _heartbeat_loop():
545
620
  except Exception as e:
546
621
  log.warning(f"lease renewal failed: {e}")
547
622
 
548
- await asyncio.sleep(30)
623
+ _heartbeat_stop.wait(30) # sleep but interruptible on shutdown
549
624
 
550
625
 
551
626
  @asynccontextmanager
@@ -560,17 +635,30 @@ async def lifespan(_app):
560
635
  notify_callback=_on_new_message,
561
636
  )
562
637
  await _REALTIME.start()
563
- hb_task = asyncio.create_task(_heartbeat_loop())
564
- log.info(f"lifespan started Realtime + heartbeat (30s) active for {AGENT_NAME}")
638
+
639
+ # IMMEDIATE: send first heartbeat + set online status BEFORE any tool calls.
640
+ # Without this, the agent appears offline for up to 30s after boot.
641
+ for _attempt in range(3):
642
+ try:
643
+ be.sb_rpc("mc_heartbeat", {"p_project_id": _PROJECT_ID, "p_agent_name": AGENT_NAME, "p_version": "2.0.0"})
644
+ be.set_status(_PROJECT_ID, AGENT_NAME, "idle", "MCP session active")
645
+ log.info(f"[meshcode] Agent {AGENT_NAME} online — initial heartbeat sent")
646
+ break
647
+ except Exception as e:
648
+ log.warning(f"initial heartbeat attempt {_attempt+1} failed: {e}")
649
+ import time; time.sleep(2)
650
+
651
+ # Heartbeat in daemon thread — independent of asyncio event loop.
652
+ _heartbeat_stop.clear()
653
+ hb_thread = _threading.Thread(target=_heartbeat_thread_fn, daemon=True, name="meshcode-heartbeat")
654
+ hb_thread.start()
655
+ log.info(f"lifespan started — Realtime + heartbeat thread active for {AGENT_NAME}")
565
656
  try:
566
657
  yield {"realtime": _REALTIME}
567
658
  finally:
568
659
  log.info("lifespan shutdown — stopping heartbeat + realtime + releasing lease")
569
- hb_task.cancel()
570
- try:
571
- await hb_task
572
- except asyncio.CancelledError:
573
- pass
660
+ _heartbeat_stop.set()
661
+ hb_thread.join(timeout=5)
574
662
  await _REALTIME.stop()
575
663
  # Flip to offline + release lease so the dashboard reflects reality
576
664
  # within seconds (not waiting for the 30s cron to notice).
@@ -786,15 +874,32 @@ def meshcode_done(reason: str) -> Dict[str, Any]:
786
874
  @mcp.tool()
787
875
  @with_working_status
788
876
  def meshcode_check(include_acks: bool = False) -> Dict[str, Any]:
789
- """Non-blocking: returns pending message count + buffered messages from the
790
- Realtime listener since the last check.
877
+ """Non-blocking: returns pending message count + any new messages.
791
878
 
792
- Use this to check if there's anything new without marking messages as read.
793
- Useful as the first call in a tool loop or after a long thinking phase.
879
+ Checks realtime buffer first, then falls back to DB if buffer is empty
880
+ but there are pending messages (handles messages that arrived before
881
+ the realtime listener connected).
794
882
  """
795
883
  pending = be.count_pending(_PROJECT_ID, AGENT_NAME)
796
884
  realtime_buffered = _REALTIME.drain() if _REALTIME else []
797
885
  deduped = _filter_and_mark(realtime_buffered)
886
+
887
+ # Fallback: if realtime buffer is empty but DB has pending messages,
888
+ # fetch them from the DB so they're not invisible to the agent.
889
+ if not deduped and pending > 0:
890
+ raw = be.read_inbox(_PROJECT_ID, AGENT_NAME)
891
+ deduped = _filter_and_mark([
892
+ {
893
+ "from": m["from_agent"],
894
+ "type": m.get("type", "msg"),
895
+ "ts": m.get("created_at"),
896
+ "payload": m.get("payload", {}),
897
+ "id": m.get("id"),
898
+ "parent_id": m.get("parent_msg_id"),
899
+ }
900
+ for m in raw
901
+ ])
902
+
798
903
  split = _split_messages(deduped)
799
904
  if not include_acks:
800
905
  split["acks"] = []
@@ -1271,7 +1376,6 @@ def meshcode_forget(key: str) -> Dict[str, Any]:
1271
1376
 
1272
1377
  # ----------------- RESOURCES -----------------
1273
1378
 
1274
- @mcp.resource("meshcode://inbox")
1275
1379
  @mcp.tool()
1276
1380
  def meshcode_auto_wake(enabled: bool) -> Dict[str, Any]:
1277
1381
  """Toggle auto-wake: when enabled, if this agent receives a mesh message
@@ -183,8 +183,14 @@ def run(agent: str, project: Optional[str] = None, editor_override: Optional[str
183
183
  cmd = [editor, str(ws)]
184
184
 
185
185
  try:
186
- # Replace this process with the editor so the user gets a clean tab.
187
- os.execvp(cmd[0], cmd)
186
+ if sys.platform == "win32":
187
+ # Windows: no execvp, use subprocess and wait
188
+ import subprocess as _sp
189
+ result = _sp.run(cmd)
190
+ sys.exit(result.returncode)
191
+ else:
192
+ # Unix: replace this process with the editor
193
+ os.execvp(cmd[0], cmd)
188
194
  except FileNotFoundError:
189
195
  print(f"[meshcode] ERROR: '{editor}' not found in PATH", file=sys.stderr)
190
196
  return 127
@@ -588,10 +588,18 @@ def setup(*args) -> int:
588
588
  return 1
589
589
 
590
590
  if args[0] in CLIENT_CONFIG_PATHS:
591
+ if args[0] == "claude-desktop":
592
+ # Claude Desktop needs global config — only exception
593
+ if len(args) < 3:
594
+ print("Usage: meshcode setup claude-desktop <project> <agent> [role]", file=sys.stderr)
595
+ return 1
596
+ return setup_global(args[0], args[1], args[2], args[3] if len(args) > 3 else "")
597
+ # All other clients: redirect to workspace flow (no global pollution)
598
+ print(f"[meshcode] NOTE: 'meshcode setup {args[0]}' is deprecated. Using workspace flow.", file=sys.stderr)
591
599
  if len(args) < 3:
592
- print("Usage: meshcode setup <client> <project> <agent> [role]", file=sys.stderr)
600
+ print("Usage: meshcode setup <project> <agent> [role]", file=sys.stderr)
593
601
  return 1
594
- return setup_global(args[0], args[1], args[2], args[3] if len(args) > 3 else "")
602
+ return setup_workspace(args[1], args[2], args[3] if len(args) > 3 else "")
595
603
 
596
604
  if len(args) < 2:
597
605
  print("Usage: meshcode setup <project> <agent> [role]", file=sys.stderr)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: meshcode
3
- Version: 2.0.0
3
+ Version: 2.0.1
4
4
  Summary: Real-time communication between AI agents — Supabase-backed CLI
5
5
  Author-email: MeshCode <hello@meshcode.io>
6
6
  License: MIT
@@ -158,6 +158,29 @@ meshcode revoke-member my-project <user> # kick a member instantly
158
158
 
159
159
  ---
160
160
 
161
+ ## Agent account management
162
+
163
+ Your AI agents can manage your MeshCode account from inside the mesh. Just tell your agent what you need:
164
+
165
+ - **"Create a backend agent"** → agent calls `meshcode_create_meshwork` + `meshcode_add_agent`
166
+ - **"Change the frontend role to UI designer"** → agent calls `meshcode_edit_agent`
167
+ - **"Give the backend agent a note about our conventions"** → agent calls `meshcode_edit_memory`
168
+
169
+ Available MCP tools for agents:
170
+
171
+ | Tool | What it does |
172
+ |------|-------------|
173
+ | `meshcode_create_meshwork(name)` | Create a new meshwork |
174
+ | `meshcode_add_agent(name, role)` | Add an agent to the current meshwork |
175
+ | `meshcode_edit_agent(name, role?, launch_prompt?)` | Update agent role or system prompt |
176
+ | `meshcode_edit_memory(agent_name, key, value)` | Edit another agent's persistent memory |
177
+ | `meshcode_scratchpad_set(key, value)` | Write to shared meshwork memory |
178
+ | `meshcode_link(target_meshwork)` | Link two meshworks for cross-mesh communication |
179
+
180
+ The agent will always tell you what CLI command to run next (e.g., "Open a new terminal and run `meshcode run backend`").
181
+
182
+ ---
183
+
161
184
  ## Editor support
162
185
 
163
186
  | Editor | Auto-detected? | Config file written |
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "meshcode"
7
- version = "2.0.0"
7
+ version = "2.0.1"
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