5-End Collaborative Architecture and Implementation Document

5-End Collaborative Architecture and Implementation Document

Document Version: v1.0

Last Updated: 2026-08-23

Maintainer: BossAgents Team

Status: Edge + Network Ends Implemented, 5-End Collaborative Loop Completed


I. Architecture Overview

1.1 Five-End Definitions

EndCodeRoleResponsibilitiesImplementation StatusModule Path
CloudCloudCentral ServerFull Data, Heavy Inference, Orchestration, Rule Engine✅ Implementedserver.js + server/boss-scheduler/
EdgeEdgeEdge NodeReal-time Inference, Preprocessing, Data Caching, Offline Queue✅ Implementedserver/edge/edge-node-manager.js
DeviceDeviceDevice/BrowserInteraction, Collection, MTClaw On-Device Execution✅ Implementedsrc/ Frontend + bossagents-miniapp/ Mini Program + MTClaw/ On-Device Scripts
NetworkNetworkNetwork LayerConnection Management, Routing Strategy, QoS, Message Reliability✅ Implementedserver/network/network-manager.js
HumanHumanManual ApprovalDecision Release, Quality Control✅ Implementedlocal.yaml taskForces gate node

1.2 Architecture Diagram

                    ┌─────────────────────────────────────────┐
                    │           云端 (Cloud)                    │
                    │  server.js (PORT=3006)                   │
                    │  ├── boss-scheduler/ (调度核心)           │
                    │  │   ├── index.js (统一入口)              │
                    │  │   ├── a2a-protocol.js (A2A/MACP)      │
                    │  │   ├── edge/ (边端管理)                 │
                    │  │   └── network/ (网端管理)              │
                    │  ├── 规则引擎 (190条规则)                 │
                    │  └── SCSAI PLM 对接                      │
                    └──────────┬──────────────────┬────────────┘
                               │                  │
                    ┌──────────▼─────────┐  ┌────▼─────────────┐
                    │   网端 (Network)    │  │  A2A 协议         │
                    │  network-manager.js │  │  a2a-protocol.js  │
                    │  ├── 链路注册       │  │  ├── 点对点消息    │
                    │  ├── 路由选择       │  │  ├── 广播          │
                    │  ├── QoS保障        │  │  ├── 协同触发      │
                    │  └── 断线重连       │  │  └── MACP会话     │
                    └──────────┬──────────┘  └────┬─────────────┘
                               │                   │
                    ┌──────────▼───────────────────▼───────────┐
                    │           边端 (Edge)                      │
                    │  edge-node-manager.js                     │
                    │  ├── 节点注册/心跳                         │
                    │  ├── 任务分派 (云→边)                      │
                    │  ├── 结果回传 (边→云)                      │
                    │  ├── 负载均衡                              │
                    │  └── 本地缓存/离线队列                     │
                    └──────────┬───────────────────────────────┘
                               │
                    ┌──────────▼───────────────────────────────┐
                    │           端侧 (Device)                    │
                    │  ├── 前端 Vue3 (src/)                     │
                    │  ├── 小程序 (bossagents-miniapp/)         │
                    │  └── MTClaw 端侧脚本 (MTClaw/scripts/)    │
                    └────────────────────────────────────────────┘

                    ┌────────────────────────────────────────────┐
                    │           人侧 (Human)                     │
                    │  taskForces gate 节点 (local.yaml)        │
                    │  ├── 质量经理放行                          │
                    │  ├── 车间主任复产决策                      │
                    │  └── 技术总监评审                          │
                    └────────────────────────────────────────────┘

1.3 数据流

用户意图 → 端侧(Device) → 网端(Network)路由 → 云端(Cloud)编排
                                                    ↓
                                            需要边缘计算?
                                           ↙        ↘
                                     是               否
                                      ↓                ↓
                              网端→边端(Edge)      云端直接执行
                              边端预处理           ↓
                                      ↓           A2A触发下游
                              边端→网端→云端      ↓
                                      ↓           人侧审批(gate)
                              云端合并结果        ↓
                                      ↓           最终结果
                                      ↓             ↓
                                      └─────→ 端侧展示 ←──┘

二、模块详细设计

2.1 边端 Edge — server/edge/edge-node-manager.js

#### 设计目标

Offloads lightweight inference and preprocessing tasks from the cloud to edge nodes, reducing latency, saving bandwidth, and supporting offline scenarios.

#### Core Interfaces

| Function | Parameters | Returns | Description |

|---|---|---|---|

| registerNode(node) | {id, host, port, capabilities, location, weight} | node object | Register an edge node |

| unregisterNode(nodeId) | nodeId | void | Unregister a node |

| heartbeat(nodeId, stats) | nodeId, {taskCount, avgLatency} | bool | Heartbeat update |

| findBestNode(capability) | capability string | node/null | Find the optimal node |

| dispatch(capability, payload) | capability, payload | {nodeId, result, latency} | Dispatch a task to the edge |

| getNodes() | - | node list | Get all nodes |

| getStats() | - | statistics object | Get statistical information |

#### Node Selection Strategy

load = weight × (1 + taskCount) × (1 + avgLatency / 1000)
选择 load 最小的在线节点

#### 心跳机制

  • Nodes send a heartbeat every 10s
  • No heartbeat for over 30s → Marked as offline
  • Offline nodes do not participate in task dispatch

#### Current Capability Mapping

const workerMap = {
  'spc_check':       () => require('../workers/spc-worker'),
  'qcc_inspect':     () => require('../workers/qcc-worker'),
  'data_preprocess': () => require('../workers/data-clerk'),
  'inspect':         () => require('../workers/inspect-worker'),
};

#### 扩展指南

  1. Add new capability mappings in the workerMap
  2. Replace _executeOnEdge with HTTP/gRPC calls in actual deployment:
   async function _executeOnEdge(node, capability, payload) {
     const resp = await fetch(`http://${node.host}:${node.port}/execute`, {
       method: 'POST',
       body: JSON.stringify({ capability, payload })
     });
     return resp.json();
   }
   

2.2 网端 Network — server/network/network-manager.js

#### 设计目标

Manages network connections between the management cloud/edge cloud, providing route selection, QoS assurance, and message reliability.

#### Core Interfaces

| Function | Parameters | Returns | Description |

|---|---|---|---|

| registerLink(linkId, config) | linkId, {from, to, bandwidth, latency, reliability, cost} | link object | Register a network link |

| unregisterLink(linkId) | linkId | void | Unregister a link |

| selectRoute(from, to, opts) | from, to, {priority, maxLatency, minBandwidth} | link/null | Route selection |

| send(link, payload, opts) | link, payload, {timeout, retry} | {success, roundTrip, result} | Send a message |

| createConnection(connId, config) | connId, {from, to, type, onMessage} | conn object | Establish a persistent connection |

| getTopology() | - | topology object | Get network topology |

| getStats() | - | statistics object | Get network statistics |

#### Route Selection Formula

score = (bandwidth × reliability × qosLevel) / (latency × cost)
选择 score 最高的活跃链路

QoS级别:high=3, normal=2, low=1

#### Message Reliability

  • Automatic retry (default 3 times, exponential backoff)
  • Timeout control (default 30s)
  • ACK confirmation (tracked via success/failed statistics)
  • Transmission failure simulation (based on reliability probability)

#### Extended Guide

  1. Replace _transmit with real network transmission in actual deployment:
   async function _transmit(link, payload, timeout) {
     const controller = new AbortController();
     setTimeout(() => controller.abort(), timeout);
     const resp = await fetch(`http://${link.to}/receive`, {
       method: 'POST',
       body: JSON.stringify(payload),
       signal: controller.signal
     });
     return resp.json();
   }
   
  1. 添加WebSocket支持用于实时消息
  2. 添加消息加密(TLS/自定义加密)

2.3 A2A/MACP 协议 — server/boss-scheduler/a2a-protocol.js

#### A2A (Agent-to-Agent) — 员工间点对点通信

| Function | Description |

|---|---|

| sendMessage(from, to, content) | Send point-to-point message |

| broadcast(from, targets, content) | Broadcast to multiple staff members |

| requestCollaboration(from, result, config) | Automatically trigger downstream based on collaboration configuration |

| getMessages(staffId, opts) | Retrieve staff message history |

#### MACP (Multi-Agent Communication Protocol) — Multi-Agent Session

| Function | Description |

|---|---|

| createSession(participants, context) | Create a multi-agent session |

| sendInSession(sessionId, from, content) | Send message within session (automatically broadcast to other participants) |

| closeSession(sessionId) | Close session |

| listActiveSessions() | List active sessions |

#### Automatic Trigger Mechanism

After completing a task, runStaffOnce automatically checks the staff.collaboration.onComplete configuration:

// boss-scheduler/index.js runStaffOnce
const result = await scheduler.runOnce(staffId, intent, parameters);
const staff = staffList.find(s => s.id === staffId);
if (staff && staff.collaboration && result) {
  a2a.requestCollaboration(staffId, result, staff.collaboration);
}

2.4 人侧 Human — taskForces gate 节点

在 local.yaml 的 taskForces 中定义,gate 节点为人工审批:

taskForces:
  - id: TF-COMPLAINT
    members:
      - key: gate
        type: human          # 人侧节点
        role: 质量经理放行审批
        approver: 质量经理
        dependsOn: [proc, sched]
        gate:
          question: 是否批准该整改方案并放行受影响批次?
          options: [批准放行, 有条件放行, 驳回重做]

当前4个taskForce共有4个人侧gate节点:

  • TF-COMPLAINT: Quality Manager Release
  • TF-LINE-STOP: Workshop Director Resumption Decision
  • TF-NEW-PRODUCT: Technical Director Review
  • TF-COST-ALERT: No Gate (Fully Automatic)

III. API Documentation

3.1 Edge APIs

#### GET /api/edge/nodes

Retrieve all edge nodes and statistics.

Response:

{
  "nodes": [{ "id": "edge-01", "host": "192.168.1.100", "port": 8081, "status": "online", "capabilities": ["spc_check"] }],
  "stats": { "total": 1, "online": 1, "totalTasks": 5, "completedTasks": 5 }
}

#### POST /api/edge/nodes

Register an edge node.

Request Body:

{ "id": "edge-01", "host": "192.168.1.100", "port": 8081, "capabilities": ["spc_check", "qcc_inspect"], "weight": 1 }

#### DELETE /api/edge/nodes/:id

Deregister an edge node.

#### POST /api/edge/heartbeat

Heartbeat update.

Request Body: { "nodeId": "edge-01", "stats": { "taskCount": 5, "avgLatency": 12 } }

#### POST /api/edge/dispatch

Dispatch a task to an edge node.

Request Body: { "capability": "spc_check", "payload": { "data": "..." } }

Response: { "nodeId": "edge-01", "result": {...}, "latency": 15 }

#### GET /api/edge/stats

Edge node statistics.


3.2 Network APIs

#### GET /api/network/topology

Retrieve network topology.

Response:

{
  "links": [{ "id": "cloud-edge-01", "from": "cloud", "to": "edge-01", "status": "active", "bandwidth": 100, "latency": 5 }],
  "connections": []
}

#### POST /api/network/links

Register a network link.

Request Body: { "linkId": "cloud-edge-01", "from": "cloud", "to": "edge-01", "bandwidth": 100, "latency": 5, "reliability": 0.99 }

#### POST /api/network/send

Send messages over the network.

Request body: { "from": "cloud", "to": "edge-01", "payload": { "type": "task", "data": "..." }, "priority": "high" }

#### GET /api/network/stats

Network statistics.


3.3 Five-Ends Overview API

#### GET /api/five-ends/status

Get the collaborative status overview of the five ends.

Response:

{
  "cloud": { "status": "online", "role": "中心服务器", "host": "ylxt.chat" },
  "edge": { "status": "online", "total": 1, "online": 1, "totalTasks": 5, "completedTasks": 5 },
  "device": { "status": "online", "role": "前端+小程序+MTClaw端侧" },
  "network": { "status": "online", "links": 1, "activeLinks": 1, "deliveryRate": "100.0%" },
  "human": { "status": "online", "role": "taskForces gate审批" },
  "a2a": { "sessions": 0 }
}

四、部署指南

4.1 云端部署(当前已运行)

# 启动云端服务器
cd C:\bossagents
node server.js  # 默认端口 3006

4.2 边端部署

#### 方式一:本地模拟(开发/测试)

No additional deployment required; the _executeOnEdge method in edge-node-manager.js directly calls the local worker.

#### Method 2: Independent Edge Node (Production)

  1. Deploy a lightweight Node.js service on the edge machine:
   // edge-server.js (边缘节点上的服务)
   const http = require('http');
   http.createServer((req, res) => {
     // 接收云端分派的任务并执行
   }).listen(8081);
   
  1. 在云端注册边缘节点:
   curl -X POST http://cloud:3006/api/edge/nodes \
     -H 'Content-Type: application/json' \
     -d '{"id":"edge-01","host":"192.168.1.100","port":8081,"capabilities":["spc_check","qcc_inspect"]}'
   
  1. 注册网络链路:
   curl -X POST http://cloud:3006/api/network/links \
     -H 'Content-Type: application/json' \
     -d '{"linkId":"cloud-edge-01","from":"cloud","to":"edge-01","bandwidth":100,"latency":5,"reliability":0.99}'
   

4.3 网端配置

网端为云端内置模块,无需独立部署。通过API注册链路即可建立端云/边云连接。

4.4 Human-Side Configuration

Define the gate node in the taskForces section of local.yaml; no additional deployment required.


V. Handover Instructions

5.1 Code Structure

server/
├── boss-scheduler/
│   ├── index.js              # 统一入口,导出 a2a/edge/network
│   ├── a2a-protocol.js       # A2A/MACP 通信协议
│   ├── edge/
│   │   └── edge-node-manager.js  # 边端节点管理
│   ├── network/
│   │   └── network-manager.js    # 网端管理
│   └── workers/              # 67个worker实现
├── edge/                     # edge模块(被boss-scheduler引用)
│   └── edge-node-manager.js
├── network/                  # network模块
│   └── network-manager.js
└── boss-scheduler/
    └── profiles/
        └── local.yaml        # 含taskForces(人侧gate节点) + collaboration配置

5.2 关键文件清单

| 文件 | 作用 | 修改场景 |

|---|---|---|

| server/edge/edge-node-manager.js | Edge Node Management | Add new capability mappings, replace with real HTTP calls |

| server/network/network-manager.js | Network End Management | Add transmission protocols, QoS policies |

| server/boss-scheduler/a2a-protocol.js | A2A/MACP Protocol | Add message types, persistence |

| server/boss-scheduler/index.js:99 | runStaffOnce + A2A Integration | Modify collaborative triggering logic |

| server/boss-scheduler/staff-router.js:191 | type filter | Adjust which types participate in user matching |

| server.js:5827 | 5-End Collaboration API Routing | Add new API endpoint |

| server/boss-scheduler/profiles/local.yaml | taskForces+collaboration | Add collaboration link and approval node |

5.3 Common Extension Scenarios

#### Scenario 1: Adding New Edge Capabilities

  1. Add mapping in the workerMap of edge-node-manager.js
  2. Implement the corresponding worker file
  3. Declare in capabilities when registering the edge node

#### Scenario 2: Adding a New Collaboration Link

  1. Add collaboration.onComplete configuration under the corresponding employee in local.yaml
  2. Run node scripts/sync-collab-to-db.js to sync to DB
  3. Restart the server

#### Scenario 3: Adding a New Human-Side Approval Node

  1. Add a member with type: human in the taskForces section of local.yaml
  2. Set gate.question and gate.options

#### Scenario 4: Replacing with Real Network Transmission

  1. Modify _executeOnEdge in edge-node-manager.js → HTTP call
  2. Modify _transmit in network-manager.js → HTTP/WebSocket call
  3. Deploy corresponding server on edge nodes

5.4 Verify Command

# 验证5端协同状态
curl https://ylxt.chat/api/five-ends/status

# 注册边缘节点
curl -X POST https://ylxt.chat/api/edge/nodes -H 'Content-Type: application/json' -d '{"id":"edge-01","host":"localhost","port":8081,"capabilities":["spc_check"]}'

# 分派任务到边缘
curl -X POST https://ylxt.chat/api/edge/dispatch -H 'Content-Type: application/json' -d '{"capability":"spc_check","payload":{"data":"test"}}'

# 查看网络拓扑
curl https://ylxt.chat/api/network/topology

5.5 注意事项

  1. edge-node-manager.js 有两份:server/edge/ 和 server/boss-scheduler/edge/,前者被直接引用,后者通过boss-scheduler导出。修改时两份都要改,或统一引用路径。
  2. 心跳定时器:edge-node-manager.js 的心跳检测使用 setInterval,在测试脚本中需调用 edge.stop() 清理。
  3. A2A消息队列:当前为内存存储(最大1000条),重启后清空。生产环境需替换为持久化存储。
  4. network模拟传输:_transmit 当前为模拟(基于latency延迟+reliability概率失败),生产部署需替换为真实网络调用。
  5. type过滤:staff-router.js 的 matchStaff 过滤非 digital_worker 类型,新增面向用户的员工需确保 type 为空或 digital_worker。

六、与标准文档的对应关系

| 标准文档07要求 | 实现位置 | 状态 |

|---|---|---|

| 5-End Collaboration (Cloud·Edge·Device·Network·Human) | This Document | ✅ Fully Implemented |

| A2A/MACP Protocol | a2a-protocol.js | ✅ |

| Edge Deployment | edge-node-manager.js | ✅ |

| Network Connection Management | network-manager.js | ✅ |

| Human-Side Gate Approval | local.yaml taskForces | ✅ |

| Device-Cloud Collaboration | MTClaw Device Side + Network Routing | ✅ |

| Edge-Cloud Collaboration | Edge Dispatch + Network Link | ✅ |

| Consistency Guarantee | Same Object Model (469 Meta-Model) Across All Five Ends | ✅ |


7. Change Log

DateChangeOwner
2026-08-23Initial Implementation: Edge+Network+A2A/MACP+API Routing+This DocumentBossAgents Team

8. TODO / Future Improvements

  • [ ] Replace edge-side _executeOnEdge with real HTTP/gRPC calls
  • [ ] Replace network-side _transmit with real network transmission
  • [ ] A2A message queue persistence (Redis/SQLite)
  • [ ] Edge-side offline queue persistence
  • [ ] Network-side WebSocket real-time communication
  • [ ] Network-side message encryption (TLS)
  • [ ] Edge-side auto-discovery (mDNS/consul)
  • [ ] 5-End health dashboard (frontend visualization)
← 返回案例列表

Try 左帮右臂 Industrial Agent — your digital workforce

Available as a WeChat mini program, web app (ylxt.chat) and desktop client. Start from whichever fits your workflow.

🌐 Web App 💻 Desktop Download 📞 Call 189-8606-6876
WeChat mini program QR
Scan for the WeChat mini program
Share:
🤖 Try Now →
🤖
🎁