{
  "schemaVersion": "1.0",
  "item": {
    "slug": "ai-collab",
    "name": "Ai Collab",
    "source": "tencent",
    "type": "skill",
    "category": "通讯协作",
    "sourceUrl": "https://clawhub.ai/jeremysommerfeld8910-cpu/ai-collab",
    "canonicalUrl": "https://clawhub.ai/jeremysommerfeld8910-cpu/ai-collab",
    "targetPlatform": "OpenClaw"
  },
  "install": {
    "downloadMode": "redirect",
    "downloadUrl": "/downloads/ai-collab",
    "sourceDownloadUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=ai-collab",
    "sourcePlatform": "tencent",
    "targetPlatform": "OpenClaw",
    "installMethod": "Manual import",
    "extraction": "Extract archive",
    "prerequisites": [
      "OpenClaw"
    ],
    "packageFormat": "ZIP package",
    "includedAssets": [
      "SKILL.md",
      "_meta.json",
      "examples/claude-claude.md",
      "examples/claude-gpt.md",
      "examples/jim-workflow-prompt.md",
      "references/protocol.md"
    ],
    "primaryDoc": "SKILL.md",
    "quickSetup": [
      "Download the package from Yavira.",
      "Extract the archive and review SKILL.md first.",
      "Import or place the package into your OpenClaw setup."
    ],
    "agentAssist": {
      "summary": "Hand the extracted package to your coding agent with a concrete install brief instead of figuring it out manually.",
      "steps": [
        "Download the package from Yavira.",
        "Extract it into a folder your agent can access.",
        "Paste one of the prompts below and point your agent at the extracted folder."
      ],
      "prompts": [
        {
          "label": "New install",
          "body": "I downloaded a skill package from Yavira. Read SKILL.md from the extracted folder and install it by following the included instructions. Tell me what you changed and call out any manual steps you could not complete."
        },
        {
          "label": "Upgrade existing",
          "body": "I downloaded an updated skill package from Yavira. Read SKILL.md from the extracted folder, compare it with my current installation, and upgrade it while preserving any custom configuration unless the package docs explicitly say otherwise. Summarize what changed and any follow-up checks I should run."
        }
      ]
    },
    "sourceHealth": {
      "source": "tencent",
      "status": "healthy",
      "reason": "direct_download_ok",
      "recommendedAction": "download",
      "checkedAt": "2026-04-23T16:43:11.935Z",
      "expiresAt": "2026-04-30T16:43:11.935Z",
      "httpStatus": 200,
      "finalUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=4claw-imageboard",
      "contentType": "application/zip",
      "probeMethod": "head",
      "details": {
        "probeUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=4claw-imageboard",
        "contentDisposition": "attachment; filename=\"4claw-imageboard-1.0.1.zip\"",
        "redirectLocation": null,
        "bodySnippet": null
      },
      "scope": "source",
      "summary": "Source download looks usable.",
      "detail": "Yavira can redirect you to the upstream package for this source.",
      "primaryActionLabel": "Download for OpenClaw",
      "primaryActionHref": "/downloads/ai-collab"
    },
    "validation": {
      "installChecklist": [
        "Use the Yavira download entry.",
        "Review SKILL.md after the package is downloaded.",
        "Confirm the extracted package contains the expected setup assets."
      ],
      "postInstallChecks": [
        "Confirm the extracted package includes the expected docs or setup files.",
        "Validate the skill or prompts are available in your target agent workspace.",
        "Capture any manual follow-up steps the agent could not complete."
      ]
    },
    "downloadPageUrl": "https://openagent3.xyz/downloads/ai-collab",
    "agentPageUrl": "https://openagent3.xyz/skills/ai-collab/agent",
    "manifestUrl": "https://openagent3.xyz/skills/ai-collab/agent.json",
    "briefUrl": "https://openagent3.xyz/skills/ai-collab/agent.md"
  },
  "agentAssist": {
    "summary": "Hand the extracted package to your coding agent with a concrete install brief instead of figuring it out manually.",
    "steps": [
      "Download the package from Yavira.",
      "Extract it into a folder your agent can access.",
      "Paste one of the prompts below and point your agent at the extracted folder."
    ],
    "prompts": [
      {
        "label": "New install",
        "body": "I downloaded a skill package from Yavira. Read SKILL.md from the extracted folder and install it by following the included instructions. Tell me what you changed and call out any manual steps you could not complete."
      },
      {
        "label": "Upgrade existing",
        "body": "I downloaded an updated skill package from Yavira. Read SKILL.md from the extracted folder, compare it with my current installation, and upgrade it while preserving any custom configuration unless the package docs explicitly say otherwise. Summarize what changed and any follow-up checks I should run."
      }
    ]
  },
  "documentation": {
    "source": "clawhub",
    "primaryDoc": "SKILL.md",
    "sections": [
      {
        "title": "ai-collab — Autonomous Multi-Agent Collaboration",
        "body": "Two OpenClaw agents working in parallel on shared tasks, coordinated via a structured chat log and daemon inbox protocol."
      },
      {
        "title": "Architecture Overview",
        "body": "┌─────────────────────────────────────────────────────────┐\n│                     User (Jeremy)                       │\n│               Telegram / Direct Message                  │\n└──────────────────────┬──────────────────────────────────┘\n                       │\n         ┌─────────────┴──────────────┐\n         ▼                            ▼\n┌─────────────────┐         ┌──────────────────┐\n│   AGENT A       │         │   AGENT B        │\n│  (Jim / main)   │◄───────►│ (Clawdy / daemon)│\n│  claude code    │         │ claude --print    │\n│  port: main     │         │ inbox: filesystem │\n└────────┬────────┘         └────────┬─────────┘\n         │                           │\n         └──────────┬────────────────┘\n                    ▼\n         ┌──────────────────┐\n         │   chat.log       │ ← THE shared record\n         │   collab/inbox/  │ ← A→B messages\n         └──────────────────┘\n\nAgent A (Primary): Interactive Claude Code session. Handles browser, complex tasks, user-facing responses.\n\nAgent B (Daemon): claude --print subprocess. Handles background tasks, monitoring, quick lookups. Triggered by messages dropped in inbox."
      },
      {
        "title": "Configuration",
        "body": "All settings via environment variables — no hardcoded values:\n\n# ~/.openclaw/workspace/collab/.ai-collab.env\nexport AGENT_A_NAME=Jim\nexport AGENT_B_NAME=Clawdy\nexport AGENT_B_MODEL=claude-haiku-4-5-20251001   # Any claude --print compatible model\nexport AGENT_B_SESSION=clawdy-session             # tmux session name\nexport COLLAB_INBOX=$HOME/.openclaw/workspace/collab/inbox\nexport COLLAB_LOG=$HOME/.openclaw/workspace/collab/chat.log\n\nSupported models for AGENT_B_MODEL:\n\nclaude-haiku-4-5-20251001 — fastest, cheapest (recommended for daemon)\nclaude-sonnet-4-6 — more capable, higher cost\nAny OpenAI model if using the GPT daemon variant (see examples/claude-gpt.md)"
      },
      {
        "title": "Quick Setup",
        "body": "# 1. Source config\nsource ~/.openclaw/workspace/collab/.ai-collab.env\n\n# 2. Create the collab workspace\nmkdir -p \"$COLLAB_INBOX\"\n\n# 3. Start Agent B daemon (in a tmux session)\ntmux new-session -d -s \"$AGENT_B_SESSION\" \\\n  \"source ~/.openclaw/workspace/collab/.ai-collab.env && \\\n   bash ~/.openclaw/workspace/skills/ai-collab/scripts/daemon.sh\"\n\n# 4. Start message polling (Agent B → Agent A routing, runs every 60s via cron)\nbash ~/.openclaw/workspace/skills/ai-collab/scripts/poll_chatlog.sh &\n\n# 5. Test the link\nbash ~/.openclaw/workspace/skills/ai-collab/scripts/send.sh \"Hello from Agent A\""
      },
      {
        "title": "Communication Protocol",
        "body": "Every message between agents follows this format. No open loops.\n\nTagDirectionMeaning[TASK:name]A→B or B→AAssign a task[ACK:name]receiverAcknowledged, starting work[DONE:name]executorTask complete + one-line result[BLOCKED:name]executorCan't complete + reason[HANDOFF:name]either\"Do X, reply [DONE:name] when finished\"[STATUS:update]eitherAsync update on long-running task[QUESTION:topic]eitherNeeds info before proceeding\n\nRules:\n\nAnswer questions before asking new ones\nClose tasks before starting new ones\nEvery message moves work forward or closes a loop\nNever: \"let me know\", \"ready when you are\", \"standing by\"\n\nExample exchange:\n\nA → B: [TASK:price-check] Get BTC price from CoinGecko\nB → A: [ACK:price-check] Checking now.\nB → A: [DONE:price-check] BTC $94,230 as of 03:15 UTC"
      },
      {
        "title": "Daemon Script (Agent B)",
        "body": "scripts/daemon.sh — drop in your collab directory:\n\n#!/bin/bash\nPIDFILE=\"/tmp/agentb_daemon.pid\"\nif [ -f \"$PIDFILE\" ] && kill -0 \"$(cat $PIDFILE)\" 2>/dev/null; then\n  echo \"Daemon already running (PID $(cat $PIDFILE)). Exiting.\" >&2\n  exit 1\nfi\necho $$ > \"$PIDFILE\"\ntrap \"rm -f $PIDFILE\" EXIT\n\n# Required: unset so nested claude --print works\nunset CLAUDECODE\n\nINBOX=\"$HOME/.openclaw/workspace/collab/inbox\"\nLOG=\"$HOME/.openclaw/workspace/collab/chat.log\"\nmkdir -p \"$INBOX\"\n\nlogline() {\n  printf \"%s %s\\n\" \"$(date '+%Y-%m-%d %H:%M:%S')\" \"$1\" >> \"$LOG\"\n}\n\nlogline \"SYSTEM: Agent B daemon started\"\n\ninotifywait -m -e moved_to \"$INBOX\" 2>/dev/null | while read dir event file; do\n  FULLPATH=\"$INBOX/$file\"\n  [ ! -f \"$FULLPATH\" ] && continue\n\n  MSG=$(cat \"$FULLPATH\")\n  rm \"$FULLPATH\"\n\n  logline \"A -> B: $MSG\"\n\n  # Run Agent B (claude --print)\n  RESPONSE=$(claude --print --model claude-haiku-4-5-20251001 \\\n    \"You are Agent B. Agent A says: $MSG\nRespond in under 100 words. Use [DONE:taskname] or [BLOCKED:taskname] to close loops.\nContext: shared collab system. Chat log: $LOG\" 2>/dev/null)\n\n  logline \"B -> A: $RESPONSE\"\n\n  # Route response back to Agent A\n  openclaw agent --agent main -m \"[AgentB]: $RESPONSE\" --json > /dev/null 2>&1\ndone"
      },
      {
        "title": "Sending Messages (A → B)",
        "body": "# From Agent A, send to Agent B daemon inbox\nbash ~/.openclaw/workspace/skills/ai-collab/scripts/send.sh \"your message\"\n\nAtomic write pattern (prevents partial reads):\n\nINBOX=\"$HOME/.openclaw/workspace/collab/inbox\"\nTMPFILE=$(mktemp \"$INBOX/.msg.XXXXXX\")\necho \"$*\" > \"$TMPFILE\"\nmv \"$TMPFILE\" \"$INBOX/msg_$(date +%s%N).txt\"\n\nAlways use mktemp + mv — never write directly to inbox. inotifywait fires on moved_to, not close_write."
      },
      {
        "title": "Chat Log Polling (B → A)",
        "body": "scripts/poll_chatlog.sh — run via cron every 60s:\n\n#!/bin/bash\nLOG=\"$HOME/.openclaw/workspace/collab/chat.log\"\nPTR_FILE=\"/tmp/chatlog_ptr\"\n\n[ ! -f \"$LOG\" ] && exit 0\n\nTOTAL=$(wc -l < \"$LOG\")\nLAST=$(cat \"$PTR_FILE\" 2>/dev/null || echo \"0\")\n[ \"$TOTAL\" -le \"$LAST\" ] && echo \"$TOTAL\" > \"$PTR_FILE\" && exit 0\n\nNEW=$(tail -n +\"$((LAST + 1))\" \"$LOG\" | grep \"B -> A:\" | sed 's/.*B -> A: //')\necho \"$TOTAL\" > \"$PTR_FILE\"\n[ -z \"$NEW\" ] && exit 0\n\nwhile IFS= read -r line; do\n  [ -z \"$line\" ] && continue\n  openclaw agent --agent main -m \"[AgentB]: $line\" --json > /dev/null 2>&1\ndone <<< \"$NEW\"\n\nAdd to crontab:\n\n* * * * * /bin/bash ~/.openclaw/workspace/collab/poll_chatlog.sh"
      },
      {
        "title": "Shared Filesystem Conventions",
        "body": "~/.openclaw/workspace/collab/\n  chat.log          # THE shared record — all messages logged here\n  inbox/            # A→B message queue (atomic mv only)\n  .env              # Shared secrets (chmod 600, never log)\n  task_queue.md     # Optional: structured task backlog\n  status_tracker.md # Optional: current task status per agent\n\nLogging to chat.log:\n\nprintf \"%s %s\\n\" \"$(date '+%Y-%m-%d %H:%M:%S')\" \"A -> B: [TASK:name] Description\" >> \"$LOG\"\n\nRules:\n\nNever log secrets from .env\nAlways timestamp every line\nPrefix with sender: A -> B: or B -> A: or SYSTEM: or JEREMY ->"
      },
      {
        "title": "Telegram Bridge (Optional)",
        "body": "Route user Telegram messages into Agent B's inbox. Full setup guide: references/telegram-bridge.md\n\nQuick summary:\n\nCreate a bot via @BotFather → get BOT_TOKEN\nAdd bot to your group → get GROUP_ID (negative number, e.g. -1001234567890)\nDisable Group Privacy Mode in BotFather so bot can read all messages\nGet your Telegram USER_ID from @userinfobot\nSet in ~/.openclaw/.env: TELEGRAM_BOT_TOKEN, TELEGRAM_GROUP_ID, TELEGRAM_USER_ID\nRun the bridge in tmux: tmux new-session -d -s tg-bridge \"bash references/telegram-bridge.md\"\n\n# Minimal bridge loop (inline version):\nsource ~/.openclaw/.env\nOFFSET_FILE=\"/tmp/tg_offset\"\nwhile true; do\n  OFFSET=$(cat \"$OFFSET_FILE\" 2>/dev/null || echo \"0\")\n  UPDATES=$(curl -s \"https://api.telegram.org/bot${TELEGRAM_BOT_TOKEN}/getUpdates?offset=$((OFFSET+1))&timeout=20\")\n  # Parse updates, drop user messages into inbox with USER: prefix\n  # See references/telegram-bridge.md for full parsing implementation\n  sleep 1\ndone\n\nSee references/telegram-bridge.md for the complete production-ready implementation with message parsing, offset tracking, and error handling."
      },
      {
        "title": "Agent Configurations",
        "body": "See examples/ for full configs:"
      },
      {
        "title": "Claude ↔ Claude (Jim + Clawdy)",
        "body": "Agent A: claude code (interactive, full tool access)\nAgent B: claude --print claude-haiku-4-5-20251001 (fast, scripting-optimized)\nBest for: heavy task parallelism, one agent researches while other implements"
      },
      {
        "title": "Claude ↔ GPT",
        "body": "Agent A: Claude Code (full tool use)\nAgent B: openai api chat.completions.create via script\nBest for: cross-model verification, Claude builds → GPT reviews"
      },
      {
        "title": "GPT ↔ GPT",
        "body": "Agent A: GPT-4o via openai CLI\nAgent B: GPT-4o-mini for fast background checks\nBest for: speed + cost optimization when all context is OpenAI"
      },
      {
        "title": "Task Handoff Pattern",
        "body": "When Agent A needs Agent B to own a task completely:\n\nA → B: [HANDOFF:data-fetch] Fetch all BTC trades from Kraken API last 7 days.\n       Save to ~/.openclaw/workspace/collab/kraken_trades.json.\n       Reply [DONE:data-fetch] when finished.\n\nB → A: [ACK:data-fetch] Fetching now.\nB → A: [DONE:data-fetch] 847 trades saved to kraken_trades.json. Date range: 2026-02-15 to 2026-02-22.\n\nAgent A does not check on progress — waits for DONE or BLOCKED."
      },
      {
        "title": "Approval Pattern",
        "body": "When Agent B's daemon needs user approval for a terminal command:\n\n# From Agent A / user terminal:\nbash ~/.openclaw/workspace/skills/ai-collab/scripts/approve.sh \"Yes\"\n# or for numbered selections:\nbash ~/.openclaw/workspace/skills/ai-collab/scripts/approve.sh \"2\"\n\napprove.sh sends keystrokes to the tmux session running Agent B:\n\nSESSION=$(tmux ls | grep agentb-session | head -1 | cut -d: -f1)\ntmux send-keys -t \"$SESSION\" \"$1\" Enter"
      },
      {
        "title": "Rate Limiting",
        "body": "Agent B should implement a rate governor to prevent runaway API calls:\n\n# In daemon loop, before calling claude --print:\nCALLS_FILE=\"/tmp/agentb_calls\"\nWINDOW=60  # seconds\nMAX_CALLS=10\n\n# Count calls in last window\nRECENT=$(awk -v cutoff=\"$(($(date +%s) - WINDOW))\" '$1 > cutoff' \"$CALLS_FILE\" 2>/dev/null | wc -l)\nif [ \"$RECENT\" -ge \"$MAX_CALLS\" ]; then\n  logline \"SYSTEM: Rate limited — $RECENT calls in ${WINDOW}s\"\n  sleep 10\n  continue\nfi\ndate +%s >> \"$CALLS_FILE\""
      },
      {
        "title": "Financial Gate Protocol (TIERED — updated 2026-02-22)",
        "body": "Three tiers based on amount:\n\nTierAmountRule1Under $20Either agent acts independently — no approval needed2$20–$50Both agents PROPOSE + APPROVE before acting3Over $50Requires [AUTHORIZED:financial:amount:timestamp:Jeremy] tag\n\n# Tier 3 tag format (Jeremy must write to chat.log):\n[AUTHORIZED:financial:buy:BTC:$100:2026-02-22:Jeremy]\n\n# Tier 2 example flow:\n# Clawdy proposes: \"PROPOSE: buy $35 of SOL for DePIN gas — approve?\"\n# Jim approves:    \"APPROVED: buy $35 SOL\"\n# Then Clawdy acts.\n\nDaemon tiered gate logic:\n\n# <$20: proceed. $20-50: flag as tier2. >$50: block without AUTHORIZED tag.\nAMOUNT=$(echo \"$MSG\" | grep -oP '[$]?\\d+' | head -1 | tr -d '$')\nif [ -n \"$AMOUNT\" ] && [ \"$AMOUNT\" -gt 50 ] && ! echo \"$MSG\" | grep -q \"\\[AUTHORIZED:financial:\"; then\n  logline \"BLOCKED:financial-gate:tier3 — amount>$50, no AUTHORIZED tag\"; continue\nelif [ -n \"$AMOUNT\" ] && [ \"$AMOUNT\" -ge 20 ]; then\n  logline \"FINANCIAL:tier2 — propose before acting\"\nfi\n\nIf Tier 3 blocked: log [BLOCKED:financial-gate:tier3], send Telegram alert, do NOT execute."
      },
      {
        "title": "Daemon Watchdog Pattern",
        "body": "Check daemon health every 15 minutes. If silent >15 min, restart:\n\n# check_daemon.sh (add to crontab: */15 * * * *)\nPIDFILE=\"/tmp/agentb_daemon.pid\"\nLOG=\"$HOME/.openclaw/workspace/collab/chat.log\"\n\n# Check PID alive\npid_alive=0\n[ -f \"$PIDFILE\" ] && kill -0 \"$(cat $PIDFILE)\" 2>/dev/null && pid_alive=1\n\n# Check last activity within 15 min\nlast_ts=$(grep -oP '^\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}' \"$LOG\" 2>/dev/null | tail -1)\nrecent=0\nif [ -n \"$last_ts\" ]; then\n  age=$(( ($(date +%s) - $(date -d \"$last_ts\" +%s 2>/dev/null || echo 0)) / 60 ))\n  [ \"$age\" -lt 15 ] && recent=1\nfi\n\nif [ \"$pid_alive\" = \"0\" ] || [ \"$recent\" = \"0\" ]; then\n  tmux send-keys -t agentb-session \"bash daemon.sh\" Enter\nfi"
      },
      {
        "title": "Task Takeover Threshold",
        "body": "If Agent A (Jim) blocks on the same task twice, Agent B (Clawdy) takes it over:\n\nB → A: [TASK:fetch-data] Fetch X. Reply [DONE:fetch-data].\n# 10 min timer...\nA → B: [BLOCKED:fetch-data] Can't access endpoint.\nB → A: [RETRY:fetch-data] Try alternate: curl -s https://backup-endpoint.com/x\n# Another 10 min...\nA → B: [BLOCKED:fetch-data] Still failing.\n# Clawdy takes over immediately:\nB: *executes task directly, logs [DONE:fetch-data] to chat.log*\n\nRule: Blocked 2x on same task → take it over, don't reassign."
      },
      {
        "title": "Daemon Error Diagnosis",
        "body": "When daemon produces blank/error responses:\n\nCheck /tmp/clawdy_last_err — contains last stderr from claude --print\nCheck ANSI-stripped chat.log for CLAWDY_ERR: lines\nVerify RESPONSE trimming line not corrupted (common issue: accidentally set to RESPONSE=\"\")\nRestart daemon: kill $(cat /tmp/clawdy_daemon.pid) && sleep 1 && bash clawdy_daemon.sh\n\nAuto-approve: Use Bash(*) in ~/.claude/settings.local.json. NEVER use tmux send-keys cron — it sends keypresses blindly to the wrong sessions."
      }
    ],
    "body": "ai-collab — Autonomous Multi-Agent Collaboration\n\nTwo OpenClaw agents working in parallel on shared tasks, coordinated via a structured chat log and daemon inbox protocol.\n\nArchitecture Overview\n┌─────────────────────────────────────────────────────────┐\n│                     User (Jeremy)                       │\n│               Telegram / Direct Message                  │\n└──────────────────────┬──────────────────────────────────┘\n                       │\n         ┌─────────────┴──────────────┐\n         ▼                            ▼\n┌─────────────────┐         ┌──────────────────┐\n│   AGENT A       │         │   AGENT B        │\n│  (Jim / main)   │◄───────►│ (Clawdy / daemon)│\n│  claude code    │         │ claude --print    │\n│  port: main     │         │ inbox: filesystem │\n└────────┬────────┘         └────────┬─────────┘\n         │                           │\n         └──────────┬────────────────┘\n                    ▼\n         ┌──────────────────┐\n         │   chat.log       │ ← THE shared record\n         │   collab/inbox/  │ ← A→B messages\n         └──────────────────┘\n\n\nAgent A (Primary): Interactive Claude Code session. Handles browser, complex tasks, user-facing responses.\n\nAgent B (Daemon): claude --print subprocess. Handles background tasks, monitoring, quick lookups. Triggered by messages dropped in inbox.\n\nConfiguration\n\nAll settings via environment variables — no hardcoded values:\n\n# ~/.openclaw/workspace/collab/.ai-collab.env\nexport AGENT_A_NAME=Jim\nexport AGENT_B_NAME=Clawdy\nexport AGENT_B_MODEL=claude-haiku-4-5-20251001   # Any claude --print compatible model\nexport AGENT_B_SESSION=clawdy-session             # tmux session name\nexport COLLAB_INBOX=$HOME/.openclaw/workspace/collab/inbox\nexport COLLAB_LOG=$HOME/.openclaw/workspace/collab/chat.log\n\n\nSupported models for AGENT_B_MODEL:\n\nclaude-haiku-4-5-20251001 — fastest, cheapest (recommended for daemon)\nclaude-sonnet-4-6 — more capable, higher cost\nAny OpenAI model if using the GPT daemon variant (see examples/claude-gpt.md)\nQuick Setup\n# 1. Source config\nsource ~/.openclaw/workspace/collab/.ai-collab.env\n\n# 2. Create the collab workspace\nmkdir -p \"$COLLAB_INBOX\"\n\n# 3. Start Agent B daemon (in a tmux session)\ntmux new-session -d -s \"$AGENT_B_SESSION\" \\\n  \"source ~/.openclaw/workspace/collab/.ai-collab.env && \\\n   bash ~/.openclaw/workspace/skills/ai-collab/scripts/daemon.sh\"\n\n# 4. Start message polling (Agent B → Agent A routing, runs every 60s via cron)\nbash ~/.openclaw/workspace/skills/ai-collab/scripts/poll_chatlog.sh &\n\n# 5. Test the link\nbash ~/.openclaw/workspace/skills/ai-collab/scripts/send.sh \"Hello from Agent A\"\n\nCommunication Protocol\n\nEvery message between agents follows this format. No open loops.\n\nTag\tDirection\tMeaning\n[TASK:name]\tA→B or B→A\tAssign a task\n[ACK:name]\treceiver\tAcknowledged, starting work\n[DONE:name]\texecutor\tTask complete + one-line result\n[BLOCKED:name]\texecutor\tCan't complete + reason\n[HANDOFF:name]\teither\t\"Do X, reply [DONE:name] when finished\"\n[STATUS:update]\teither\tAsync update on long-running task\n[QUESTION:topic]\teither\tNeeds info before proceeding\n\nRules:\n\nAnswer questions before asking new ones\nClose tasks before starting new ones\nEvery message moves work forward or closes a loop\nNever: \"let me know\", \"ready when you are\", \"standing by\"\n\nExample exchange:\n\nA → B: [TASK:price-check] Get BTC price from CoinGecko\nB → A: [ACK:price-check] Checking now.\nB → A: [DONE:price-check] BTC $94,230 as of 03:15 UTC\n\nDaemon Script (Agent B)\n\nscripts/daemon.sh — drop in your collab directory:\n\n#!/bin/bash\nPIDFILE=\"/tmp/agentb_daemon.pid\"\nif [ -f \"$PIDFILE\" ] && kill -0 \"$(cat $PIDFILE)\" 2>/dev/null; then\n  echo \"Daemon already running (PID $(cat $PIDFILE)). Exiting.\" >&2\n  exit 1\nfi\necho $$ > \"$PIDFILE\"\ntrap \"rm -f $PIDFILE\" EXIT\n\n# Required: unset so nested claude --print works\nunset CLAUDECODE\n\nINBOX=\"$HOME/.openclaw/workspace/collab/inbox\"\nLOG=\"$HOME/.openclaw/workspace/collab/chat.log\"\nmkdir -p \"$INBOX\"\n\nlogline() {\n  printf \"%s %s\\n\" \"$(date '+%Y-%m-%d %H:%M:%S')\" \"$1\" >> \"$LOG\"\n}\n\nlogline \"SYSTEM: Agent B daemon started\"\n\ninotifywait -m -e moved_to \"$INBOX\" 2>/dev/null | while read dir event file; do\n  FULLPATH=\"$INBOX/$file\"\n  [ ! -f \"$FULLPATH\" ] && continue\n\n  MSG=$(cat \"$FULLPATH\")\n  rm \"$FULLPATH\"\n\n  logline \"A -> B: $MSG\"\n\n  # Run Agent B (claude --print)\n  RESPONSE=$(claude --print --model claude-haiku-4-5-20251001 \\\n    \"You are Agent B. Agent A says: $MSG\nRespond in under 100 words. Use [DONE:taskname] or [BLOCKED:taskname] to close loops.\nContext: shared collab system. Chat log: $LOG\" 2>/dev/null)\n\n  logline \"B -> A: $RESPONSE\"\n\n  # Route response back to Agent A\n  openclaw agent --agent main -m \"[AgentB]: $RESPONSE\" --json > /dev/null 2>&1\ndone\n\nSending Messages (A → B)\n# From Agent A, send to Agent B daemon inbox\nbash ~/.openclaw/workspace/skills/ai-collab/scripts/send.sh \"your message\"\n\n\nAtomic write pattern (prevents partial reads):\n\nINBOX=\"$HOME/.openclaw/workspace/collab/inbox\"\nTMPFILE=$(mktemp \"$INBOX/.msg.XXXXXX\")\necho \"$*\" > \"$TMPFILE\"\nmv \"$TMPFILE\" \"$INBOX/msg_$(date +%s%N).txt\"\n\n\nAlways use mktemp + mv — never write directly to inbox. inotifywait fires on moved_to, not close_write.\n\nChat Log Polling (B → A)\n\nscripts/poll_chatlog.sh — run via cron every 60s:\n\n#!/bin/bash\nLOG=\"$HOME/.openclaw/workspace/collab/chat.log\"\nPTR_FILE=\"/tmp/chatlog_ptr\"\n\n[ ! -f \"$LOG\" ] && exit 0\n\nTOTAL=$(wc -l < \"$LOG\")\nLAST=$(cat \"$PTR_FILE\" 2>/dev/null || echo \"0\")\n[ \"$TOTAL\" -le \"$LAST\" ] && echo \"$TOTAL\" > \"$PTR_FILE\" && exit 0\n\nNEW=$(tail -n +\"$((LAST + 1))\" \"$LOG\" | grep \"B -> A:\" | sed 's/.*B -> A: //')\necho \"$TOTAL\" > \"$PTR_FILE\"\n[ -z \"$NEW\" ] && exit 0\n\nwhile IFS= read -r line; do\n  [ -z \"$line\" ] && continue\n  openclaw agent --agent main -m \"[AgentB]: $line\" --json > /dev/null 2>&1\ndone <<< \"$NEW\"\n\n\nAdd to crontab:\n\n* * * * * /bin/bash ~/.openclaw/workspace/collab/poll_chatlog.sh\n\nShared Filesystem Conventions\n~/.openclaw/workspace/collab/\n  chat.log          # THE shared record — all messages logged here\n  inbox/            # A→B message queue (atomic mv only)\n  .env              # Shared secrets (chmod 600, never log)\n  task_queue.md     # Optional: structured task backlog\n  status_tracker.md # Optional: current task status per agent\n\n\nLogging to chat.log:\n\nprintf \"%s %s\\n\" \"$(date '+%Y-%m-%d %H:%M:%S')\" \"A -> B: [TASK:name] Description\" >> \"$LOG\"\n\n\nRules:\n\nNever log secrets from .env\nAlways timestamp every line\nPrefix with sender: A -> B: or B -> A: or SYSTEM: or JEREMY ->\nTelegram Bridge (Optional)\n\nRoute user Telegram messages into Agent B's inbox. Full setup guide: references/telegram-bridge.md\n\nQuick summary:\n\nCreate a bot via @BotFather → get BOT_TOKEN\nAdd bot to your group → get GROUP_ID (negative number, e.g. -1001234567890)\nDisable Group Privacy Mode in BotFather so bot can read all messages\nGet your Telegram USER_ID from @userinfobot\nSet in ~/.openclaw/.env: TELEGRAM_BOT_TOKEN, TELEGRAM_GROUP_ID, TELEGRAM_USER_ID\nRun the bridge in tmux: tmux new-session -d -s tg-bridge \"bash references/telegram-bridge.md\"\n# Minimal bridge loop (inline version):\nsource ~/.openclaw/.env\nOFFSET_FILE=\"/tmp/tg_offset\"\nwhile true; do\n  OFFSET=$(cat \"$OFFSET_FILE\" 2>/dev/null || echo \"0\")\n  UPDATES=$(curl -s \"https://api.telegram.org/bot${TELEGRAM_BOT_TOKEN}/getUpdates?offset=$((OFFSET+1))&timeout=20\")\n  # Parse updates, drop user messages into inbox with USER: prefix\n  # See references/telegram-bridge.md for full parsing implementation\n  sleep 1\ndone\n\n\nSee references/telegram-bridge.md for the complete production-ready implementation with message parsing, offset tracking, and error handling.\n\nAgent Configurations\n\nSee examples/ for full configs:\n\nClaude ↔ Claude (Jim + Clawdy)\nAgent A: claude code (interactive, full tool access)\nAgent B: claude --print claude-haiku-4-5-20251001 (fast, scripting-optimized)\nBest for: heavy task parallelism, one agent researches while other implements\nClaude ↔ GPT\nAgent A: Claude Code (full tool use)\nAgent B: openai api chat.completions.create via script\nBest for: cross-model verification, Claude builds → GPT reviews\nGPT ↔ GPT\nAgent A: GPT-4o via openai CLI\nAgent B: GPT-4o-mini for fast background checks\nBest for: speed + cost optimization when all context is OpenAI\nTask Handoff Pattern\n\nWhen Agent A needs Agent B to own a task completely:\n\nA → B: [HANDOFF:data-fetch] Fetch all BTC trades from Kraken API last 7 days.\n       Save to ~/.openclaw/workspace/collab/kraken_trades.json.\n       Reply [DONE:data-fetch] when finished.\n\nB → A: [ACK:data-fetch] Fetching now.\nB → A: [DONE:data-fetch] 847 trades saved to kraken_trades.json. Date range: 2026-02-15 to 2026-02-22.\n\n\nAgent A does not check on progress — waits for DONE or BLOCKED.\n\nApproval Pattern\n\nWhen Agent B's daemon needs user approval for a terminal command:\n\n# From Agent A / user terminal:\nbash ~/.openclaw/workspace/skills/ai-collab/scripts/approve.sh \"Yes\"\n# or for numbered selections:\nbash ~/.openclaw/workspace/skills/ai-collab/scripts/approve.sh \"2\"\n\n\napprove.sh sends keystrokes to the tmux session running Agent B:\n\nSESSION=$(tmux ls | grep agentb-session | head -1 | cut -d: -f1)\ntmux send-keys -t \"$SESSION\" \"$1\" Enter\n\nRate Limiting\n\nAgent B should implement a rate governor to prevent runaway API calls:\n\n# In daemon loop, before calling claude --print:\nCALLS_FILE=\"/tmp/agentb_calls\"\nWINDOW=60  # seconds\nMAX_CALLS=10\n\n# Count calls in last window\nRECENT=$(awk -v cutoff=\"$(($(date +%s) - WINDOW))\" '$1 > cutoff' \"$CALLS_FILE\" 2>/dev/null | wc -l)\nif [ \"$RECENT\" -ge \"$MAX_CALLS\" ]; then\n  logline \"SYSTEM: Rate limited — $RECENT calls in ${WINDOW}s\"\n  sleep 10\n  continue\nfi\ndate +%s >> \"$CALLS_FILE\"\n\nFinancial Gate Protocol (TIERED — updated 2026-02-22)\n\nThree tiers based on amount:\n\nTier\tAmount\tRule\n1\tUnder $20\tEither agent acts independently — no approval needed\n2\t$20–$50\tBoth agents PROPOSE + APPROVE before acting\n3\tOver $50\tRequires [AUTHORIZED:financial:amount:timestamp:Jeremy] tag\n# Tier 3 tag format (Jeremy must write to chat.log):\n[AUTHORIZED:financial:buy:BTC:$100:2026-02-22:Jeremy]\n\n# Tier 2 example flow:\n# Clawdy proposes: \"PROPOSE: buy $35 of SOL for DePIN gas — approve?\"\n# Jim approves:    \"APPROVED: buy $35 SOL\"\n# Then Clawdy acts.\n\n\nDaemon tiered gate logic:\n\n# <$20: proceed. $20-50: flag as tier2. >$50: block without AUTHORIZED tag.\nAMOUNT=$(echo \"$MSG\" | grep -oP '[$]?\\d+' | head -1 | tr -d '$')\nif [ -n \"$AMOUNT\" ] && [ \"$AMOUNT\" -gt 50 ] && ! echo \"$MSG\" | grep -q \"\\[AUTHORIZED:financial:\"; then\n  logline \"BLOCKED:financial-gate:tier3 — amount>$50, no AUTHORIZED tag\"; continue\nelif [ -n \"$AMOUNT\" ] && [ \"$AMOUNT\" -ge 20 ]; then\n  logline \"FINANCIAL:tier2 — propose before acting\"\nfi\n\n\nIf Tier 3 blocked: log [BLOCKED:financial-gate:tier3], send Telegram alert, do NOT execute.\n\nDaemon Watchdog Pattern\n\nCheck daemon health every 15 minutes. If silent >15 min, restart:\n\n# check_daemon.sh (add to crontab: */15 * * * *)\nPIDFILE=\"/tmp/agentb_daemon.pid\"\nLOG=\"$HOME/.openclaw/workspace/collab/chat.log\"\n\n# Check PID alive\npid_alive=0\n[ -f \"$PIDFILE\" ] && kill -0 \"$(cat $PIDFILE)\" 2>/dev/null && pid_alive=1\n\n# Check last activity within 15 min\nlast_ts=$(grep -oP '^\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}' \"$LOG\" 2>/dev/null | tail -1)\nrecent=0\nif [ -n \"$last_ts\" ]; then\n  age=$(( ($(date +%s) - $(date -d \"$last_ts\" +%s 2>/dev/null || echo 0)) / 60 ))\n  [ \"$age\" -lt 15 ] && recent=1\nfi\n\nif [ \"$pid_alive\" = \"0\" ] || [ \"$recent\" = \"0\" ]; then\n  tmux send-keys -t agentb-session \"bash daemon.sh\" Enter\nfi\n\nTask Takeover Threshold\n\nIf Agent A (Jim) blocks on the same task twice, Agent B (Clawdy) takes it over:\n\nB → A: [TASK:fetch-data] Fetch X. Reply [DONE:fetch-data].\n# 10 min timer...\nA → B: [BLOCKED:fetch-data] Can't access endpoint.\nB → A: [RETRY:fetch-data] Try alternate: curl -s https://backup-endpoint.com/x\n# Another 10 min...\nA → B: [BLOCKED:fetch-data] Still failing.\n# Clawdy takes over immediately:\nB: *executes task directly, logs [DONE:fetch-data] to chat.log*\n\n\nRule: Blocked 2x on same task → take it over, don't reassign.\n\nDaemon Error Diagnosis\n\nWhen daemon produces blank/error responses:\n\nCheck /tmp/clawdy_last_err — contains last stderr from claude --print\nCheck ANSI-stripped chat.log for CLAWDY_ERR: lines\nVerify RESPONSE trimming line not corrupted (common issue: accidentally set to RESPONSE=\"\")\nRestart daemon: kill $(cat /tmp/clawdy_daemon.pid) && sleep 1 && bash clawdy_daemon.sh\n\nAuto-approve: Use Bash(*) in ~/.claude/settings.local.json. NEVER use tmux send-keys cron — it sends keypresses blindly to the wrong sessions."
  },
  "trust": {
    "sourceLabel": "tencent",
    "provenanceUrl": "https://clawhub.ai/jeremysommerfeld8910-cpu/ai-collab",
    "publisherUrl": "https://clawhub.ai/jeremysommerfeld8910-cpu/ai-collab",
    "owner": "jeremysommerfeld8910-cpu",
    "version": "2.0.0",
    "license": null,
    "verificationStatus": "Indexed source record"
  },
  "links": {
    "detailUrl": "https://openagent3.xyz/skills/ai-collab",
    "downloadUrl": "https://openagent3.xyz/downloads/ai-collab",
    "agentUrl": "https://openagent3.xyz/skills/ai-collab/agent",
    "manifestUrl": "https://openagent3.xyz/skills/ai-collab/agent.json",
    "briefUrl": "https://openagent3.xyz/skills/ai-collab/agent.md"
  }
}