|
| 1 | +--- |
| 2 | +sidebar_position: 19 |
| 3 | +--- |
| 4 | + |
| 5 | +# Global Skill Sync |
| 6 | + |
| 7 | +Global Skill sync lets Backend install user-selected Skills into an online local executor device's Claude Code global Skill directory, so Project tasks can reuse those local capabilities by default. |
| 8 | + |
| 9 | +The current version syncs Skills only. MCP sync is temporarily disabled: Backend returns `422` when the request body contains non-empty `mcp_ids`, and the executor rejects WebSocket payloads that contain `mcps`. |
| 10 | + |
| 11 | +## API |
| 12 | + |
| 13 | +Request: |
| 14 | + |
| 15 | +```http |
| 16 | +POST /api/local-executor/devices/{device_id}/capabilities/sync |
| 17 | +``` |
| 18 | + |
| 19 | +Body: |
| 20 | + |
| 21 | +```json |
| 22 | +{ |
| 23 | + "skill_ids": [1336], |
| 24 | + "mode": "merge" |
| 25 | +} |
| 26 | +``` |
| 27 | + |
| 28 | +`device_id` must belong to the current user and be online. `skill_ids` are `Kind.id` values, and each resource must satisfy: |
| 29 | + |
| 30 | +- `kind == "Skill"` |
| 31 | +- `is_active == true` |
| 32 | +- `user_id` equals the current user, or `user_id == 0` for public Skills |
| 33 | + |
| 34 | +Successful response example: |
| 35 | + |
| 36 | +```json |
| 37 | +{ |
| 38 | + "success": true, |
| 39 | + "device_id": "c675be0c-560e-4432-9076-6731ddc6341b", |
| 40 | + "mode": "merge", |
| 41 | + "skills": [ |
| 42 | + { |
| 43 | + "id": 1336, |
| 44 | + "name": "browser", |
| 45 | + "status": "synced" |
| 46 | + } |
| 47 | + ], |
| 48 | + "errors": [] |
| 49 | +} |
| 50 | +``` |
| 51 | + |
| 52 | +MCP-disabled response example: |
| 53 | + |
| 54 | +```json |
| 55 | +{ |
| 56 | + "detail": "MCP capability sync is temporarily disabled" |
| 57 | +} |
| 58 | +``` |
| 59 | + |
| 60 | +## Backend Behavior |
| 61 | + |
| 62 | +Backend validates device ownership, online state, and Skill authorization. After validation, Backend resolves each Skill into an executor download reference: |
| 63 | + |
| 64 | +```json |
| 65 | +{ |
| 66 | + "id": 1336, |
| 67 | + "name": "browser", |
| 68 | + "namespace": "default", |
| 69 | + "is_public": false, |
| 70 | + "download_path": "/api/v1/kinds/skills/1336/download?namespace=default" |
| 71 | +} |
| 72 | +``` |
| 73 | + |
| 74 | +Backend does not expose local paths to the frontend and does not accept arbitrary installation directories. The sync action is delivered to the target device through the `device:sync_capabilities` event in the `/local-executor` Socket.IO namespace. |
| 75 | + |
| 76 | +## Executor Behavior |
| 77 | + |
| 78 | +When the local executor receives `device:sync_capabilities`, it: |
| 79 | + |
| 80 | +1. Validates `mode`; only `merge` and `replace` are accepted. |
| 81 | +2. Rejects payloads containing `mcps`. |
| 82 | +3. Uses the existing `SkillDownloader` to download and install Skills by Skill ID. |
| 83 | +4. Installs Skills into `~/.claude/skills/{skill_name}`. |
| 84 | +5. Records Wegent-managed Skills in `~/.wegent-executor/capabilities.json`. |
| 85 | +6. Forces the next heartbeat to include the full capability list. |
| 86 | + |
| 87 | +The manifest records only Wegent-managed Skills and does not record MCP entries: |
| 88 | + |
| 89 | +```json |
| 90 | +{ |
| 91 | + "version": 1, |
| 92 | + "revision": 2, |
| 93 | + "skills": { |
| 94 | + "browser": { |
| 95 | + "skill_id": 1336, |
| 96 | + "namespace": "default", |
| 97 | + "updated_at": "2026-05-27T02:29:17+00:00" |
| 98 | + } |
| 99 | + }, |
| 100 | + "last_sync_at": "2026-05-27T02:29:17+00:00" |
| 101 | +} |
| 102 | +``` |
| 103 | + |
| 104 | +If an older manifest contains an `mcps` field, the new code drops that field when reading or writing the manifest. |
| 105 | + |
| 106 | +## Heartbeat |
| 107 | + |
| 108 | +Executor heartbeat reports sanitized global Skill state: |
| 109 | + |
| 110 | +```json |
| 111 | +{ |
| 112 | + "capabilities": { |
| 113 | + "revision": 2, |
| 114 | + "digest": "sha256:c193c44afdbf51c8a1772e62b98915c8b9ffa68b266a641bc505868370495edb", |
| 115 | + "full": true, |
| 116 | + "skills": [ |
| 117 | + { |
| 118 | + "name": "browser", |
| 119 | + "skill_id": 1336, |
| 120 | + "namespace": "default", |
| 121 | + "source": "wegent" |
| 122 | + } |
| 123 | + ], |
| 124 | + "last_sync_at": "2026-05-27T02:29:17+00:00" |
| 125 | + } |
| 126 | +} |
| 127 | +``` |
| 128 | + |
| 129 | +Backend stores the latest state in Redis. Non-full heartbeats refresh only revision and digest and do not overwrite the previous full list. Heartbeats no longer report `mcps`. |
| 130 | + |
| 131 | +## Project Task Runtime |
| 132 | + |
| 133 | +Project tasks enable the global Skill directory: |
| 134 | + |
| 135 | +```text |
| 136 | +SKILLS_DIR=~/.claude/skills |
| 137 | +``` |
| 138 | + |
| 139 | +The local executor still sets a task-scoped `CLAUDE_CONFIG_DIR` to isolate Claude Code's non-sensitive configuration. Because Claude Code scans Skills from the active `CLAUDE_CONFIG_DIR/skills`, Project task startup also links the task `.claude/skills` directory to `~/.claude/skills`: |
| 140 | + |
| 141 | +```text |
| 142 | +{task_config_dir}/skills -> ~/.claude/skills |
| 143 | +``` |
| 144 | + |
| 145 | +This lets Claude Code discover global Skills through its native lookup path without writing sensitive model configuration into global Claude Code config. |
| 146 | + |
| 147 | +Non-Project tasks continue to use task-scoped `.claude/skills` directories to preserve isolation. |
| 148 | + |
| 149 | +The current version does not read Claude Code global MCP configuration and does not merge global MCP entries into Project task `mcp_servers`. Task-level MCP supplied by the current Bot, Ghost, or Skill still follows the existing task-level flow. |
| 150 | + |
| 151 | +## Verification |
| 152 | + |
| 153 | +Verify MCP is disabled: |
| 154 | + |
| 155 | +```bash |
| 156 | +curl -i -X POST "http://localhost:8000/api/local-executor/devices/${DEVICE_ID}/capabilities/sync" \ |
| 157 | + -H "Authorization: Bearer ${TOKEN}" \ |
| 158 | + -H "Content-Type: application/json" \ |
| 159 | + -d '{ |
| 160 | + "skill_ids": [], |
| 161 | + "mcp_ids": ["dingtalk/docs"], |
| 162 | + "mode": "merge" |
| 163 | + }' |
| 164 | +``` |
| 165 | + |
| 166 | +Expected response: `422`. |
| 167 | + |
| 168 | +Verify Skill sync: |
| 169 | + |
| 170 | +```bash |
| 171 | +curl -i -X POST "http://localhost:8000/api/local-executor/devices/${DEVICE_ID}/capabilities/sync" \ |
| 172 | + -H "Authorization: Bearer ${TOKEN}" \ |
| 173 | + -H "Content-Type: application/json" \ |
| 174 | + -d '{ |
| 175 | + "skill_ids": [1336], |
| 176 | + "mode": "merge" |
| 177 | + }' |
| 178 | +``` |
| 179 | + |
| 180 | +Expected response: `200`, and `~/.claude/skills/browser/SKILL.md` should exist on the device. |
0 commit comments