@seeed-studio/solution-cli 0.3.1 → 0.4.0
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.
- package/README.md +157 -104
- package/bin/cli.js +410 -58
- package/bin/runner.js +1 -1
- package/catalog/client-config.json +2 -2
- package/catalog/knowledge-core.json +58452 -488
- package/docs/cli-guide.md +173 -200
- package/lib/agent.js +74 -15
- package/lib/catalog-dto.js +14 -1
- package/lib/detector.js +3 -3
- package/lib/doctor.js +19 -1
- package/lib/downloader.js +24 -0
- package/lib/gotchas.js +126 -0
- package/lib/installer.js +113 -19
- package/lib/integration.js +265 -0
- package/lib/knowledge.js +838 -100
- package/lib/ledger.js +1 -1
- package/package.json +3 -6
- package/skills/{sensecraft → solution-cli}/SKILL.md +125 -30
- package/skills/{sensecraft → solution-cli}/references/consult-and-select.md +61 -13
- package/skills/solution-cli/references/deploy.md +112 -0
- package/skills/solution-cli/references/device-management.md +298 -0
- package/skills/{sensecraft → solution-cli}/references/diagnose.md +15 -0
- package/skills/solution-cli/references/edge-gotchas.md +205 -0
- package/skills/solution-cli/references/generic-rk3588.md +106 -0
- package/skills/{sensecraft → solution-cli}/references/hardware-bom.md +9 -3
- package/skills/solution-cli/references/sales-feasibility.md +65 -0
- package/skills/{sensecraft → solution-cli}/references/secondary-development.md +10 -7
- package/skills/sensecraft/references/deploy.md +0 -300
- package/skills/sensecraft/references/device-management.md +0 -126
- /package/skills/{sensecraft → solution-cli}/references/app-only.md +0 -0
- /package/skills/{sensecraft → solution-cli}/references/error-catalog.md +0 -0
- /package/skills/{sensecraft → solution-cli}/references/offline.md +0 -0
- /package/skills/{sensecraft → solution-cli}/references/verify.md +0 -0
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file integration.js
|
|
3
|
+
* Integration contracts and system ingestion specifications for Solution CLI.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
export const INTEGRATION_CONTRACTS = {
|
|
7
|
+
fall_detection: {
|
|
8
|
+
solution_id: 'fall_detection',
|
|
9
|
+
protocols: ['mqtt', 'http', 'webhook', 'rtsp'],
|
|
10
|
+
interfaces: [
|
|
11
|
+
{
|
|
12
|
+
protocol: 'mqtt',
|
|
13
|
+
port: 1883,
|
|
14
|
+
topic: '<device_name>/fall-detection/results/<stream_id>',
|
|
15
|
+
direction: 'publish',
|
|
16
|
+
description: '实时人体姿态与跌倒识别结果,一路摄像头对应一个子主题。',
|
|
17
|
+
payload_example: {
|
|
18
|
+
state: 'fallen',
|
|
19
|
+
fall_detected: true,
|
|
20
|
+
fall_event: true,
|
|
21
|
+
event_id: 7,
|
|
22
|
+
person_count: 1,
|
|
23
|
+
fallen_count: 1,
|
|
24
|
+
persons: [
|
|
25
|
+
{
|
|
26
|
+
track_id: 3,
|
|
27
|
+
state: 'fallen',
|
|
28
|
+
bbox: [0.51, 0.72, 0.34, 0.21],
|
|
29
|
+
confidence: 0.94
|
|
30
|
+
}
|
|
31
|
+
],
|
|
32
|
+
timestamp: 1788581337000
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
protocol: 'mqtt',
|
|
37
|
+
port: 1883,
|
|
38
|
+
topic: 'homeassistant/',
|
|
39
|
+
direction: 'publish',
|
|
40
|
+
description: 'Home Assistant MQTT Discovery 自动发现协议,跌倒传感器、事件编号会自动出现。'
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
protocol: 'webhook',
|
|
44
|
+
port: 8080,
|
|
45
|
+
endpoint: '配置中的 ALARM_WEBHOOK_URL',
|
|
46
|
+
direction: 'outbound_post',
|
|
47
|
+
description: '跌倒告警确认后向外部系统发送 HTTP POST 通知,附带防重复通知的幂等键。',
|
|
48
|
+
payload_example: {
|
|
49
|
+
id: 'a-17',
|
|
50
|
+
kind: 'fall',
|
|
51
|
+
zone_id: 'bedroom',
|
|
52
|
+
stream_id: 'cam-01',
|
|
53
|
+
state: 'notified',
|
|
54
|
+
event_timestamp: 1788581337237,
|
|
55
|
+
operator: 'duty-nurse'
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
protocol: 'http',
|
|
60
|
+
port: 8080,
|
|
61
|
+
endpoint: '/api/alarms',
|
|
62
|
+
direction: 'inbound_rest',
|
|
63
|
+
description: '告警面板 REST API,支持查询当前告警列表、执行确认 (confirm) 与驳回 (dismiss)。'
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
protocol: 'rtsp',
|
|
67
|
+
port: 8554,
|
|
68
|
+
endpoint: '/live0',
|
|
69
|
+
direction: 'stream',
|
|
70
|
+
description: '设备实时处理叠加视频流,支持 NVR 录像或第三方视频播放器调阅。'
|
|
71
|
+
}
|
|
72
|
+
],
|
|
73
|
+
input_requirements: [
|
|
74
|
+
{
|
|
75
|
+
type: 'rtsp',
|
|
76
|
+
description: '标准 RTSP 摄像头流输入(如 rtsp://admin:pass@192.168.1.100:554/live/ch0),支持海康、大华等 IP 摄像头。'
|
|
77
|
+
}
|
|
78
|
+
],
|
|
79
|
+
system_ingestion_guide: [
|
|
80
|
+
'1. 接入自建 MQTT Broker:在方案配置中将 MQTT_BROKER 改为自建服务器地址,订阅 fall-detection/results/# 获取每帧 JSON。',
|
|
81
|
+
'2. 接入业务告警中心:在告警面板中配置 Webhook 地址,有人跌倒经确认后会自动向该地址 POST 结构化事件。',
|
|
82
|
+
'3. 接入 Home Assistant:保证同一局域网下 MQTT Broker 互通,HA 会自动发现跌倒感应实体。'
|
|
83
|
+
]
|
|
84
|
+
},
|
|
85
|
+
|
|
86
|
+
'edge-anpr-plate-recognition': {
|
|
87
|
+
solution_id: 'edge-anpr-plate-recognition',
|
|
88
|
+
protocols: ['mqtt', 'http', 'webhook', 'rtsp'],
|
|
89
|
+
interfaces: [
|
|
90
|
+
{
|
|
91
|
+
protocol: 'mqtt',
|
|
92
|
+
port: 1883,
|
|
93
|
+
topic: 'edge/anpr/results',
|
|
94
|
+
direction: 'publish',
|
|
95
|
+
description: '抓拍过车车牌识别结果上报。',
|
|
96
|
+
payload_example: {
|
|
97
|
+
plate_number: '粤B12345',
|
|
98
|
+
confidence: 0.98,
|
|
99
|
+
direction: 'inbound',
|
|
100
|
+
lane_id: 1,
|
|
101
|
+
timestamp: 1788581350000,
|
|
102
|
+
vehicle_color: 'white',
|
|
103
|
+
vehicle_type: 'sedan'
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
protocol: 'webhook',
|
|
108
|
+
endpoint: '配置中的 ANPR_WEBHOOK_URL',
|
|
109
|
+
direction: 'outbound_post',
|
|
110
|
+
description: '过车事件向停车计费或园区管理系统推送。'
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
protocol: 'rtsp',
|
|
114
|
+
direction: 'input',
|
|
115
|
+
description: 'IP 监控摄像头 RTSP 视频流接入。'
|
|
116
|
+
}
|
|
117
|
+
],
|
|
118
|
+
system_ingestion_guide: [
|
|
119
|
+
'1. 订阅 MQTT topic "edge/anpr/results" 获取结构化车牌及进出方向。',
|
|
120
|
+
'2. 可配置道闸联动继电器或向道闸系统发送 HTTP 开闸指令。'
|
|
121
|
+
]
|
|
122
|
+
},
|
|
123
|
+
|
|
124
|
+
smart_agriculture_sensing: {
|
|
125
|
+
solution_id: 'smart-agriculture-sensing',
|
|
126
|
+
protocols: ['lorawan', 'mqtt', 'modbus'],
|
|
127
|
+
interfaces: [
|
|
128
|
+
{
|
|
129
|
+
protocol: 'mqtt',
|
|
130
|
+
port: 1883,
|
|
131
|
+
topic: 'sensecap/data/telemetry',
|
|
132
|
+
direction: 'publish',
|
|
133
|
+
description: '农田微气象与土壤墒情周期上报。',
|
|
134
|
+
payload_example: {
|
|
135
|
+
station_id: 's700-01',
|
|
136
|
+
air_temperature: 24.5,
|
|
137
|
+
air_humidity: 65.2,
|
|
138
|
+
soil_moisture: 38.1,
|
|
139
|
+
soil_temperature: 21.0,
|
|
140
|
+
soil_ec: 1.2,
|
|
141
|
+
light_lux: 45000,
|
|
142
|
+
battery_pct: 95
|
|
143
|
+
}
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
protocol: 'modbus',
|
|
147
|
+
port: 'RS485',
|
|
148
|
+
direction: 'bus',
|
|
149
|
+
description: '标准 Modbus RTU 工业总线控制水泵与电磁阀组。'
|
|
150
|
+
}
|
|
151
|
+
],
|
|
152
|
+
system_ingestion_guide: [
|
|
153
|
+
'1. LoRaWAN 测点通过 SenseCAP M2 网关汇聚,通过 MQTT 集中推送到企业平台。',
|
|
154
|
+
'2. 边缘网关就地根据阈值自动执行 Modbus 继电器启停,保证断网时本地闭环运行。'
|
|
155
|
+
]
|
|
156
|
+
},
|
|
157
|
+
|
|
158
|
+
edge_inspection_surface: {
|
|
159
|
+
solution_id: 'edge_inspection_surface',
|
|
160
|
+
protocols: ['mqtt', 'gpio', 'http'],
|
|
161
|
+
interfaces: [
|
|
162
|
+
{
|
|
163
|
+
protocol: 'mqtt',
|
|
164
|
+
port: 1883,
|
|
165
|
+
topic: 'inspection/defect/events',
|
|
166
|
+
direction: 'publish',
|
|
167
|
+
description: '流水线工业质检缺陷判别事件。',
|
|
168
|
+
payload_example: {
|
|
169
|
+
part_id: 'part-20261015-081',
|
|
170
|
+
is_defective: true,
|
|
171
|
+
defect_type: 'scratch',
|
|
172
|
+
confidence: 0.96,
|
|
173
|
+
bbox: [120, 340, 45, 12],
|
|
174
|
+
timestamp: 1788581360000
|
|
175
|
+
}
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
protocol: 'gpio',
|
|
179
|
+
direction: 'digital_out',
|
|
180
|
+
description: '隔离数字量输出 (DO),发现次品时直接输出 24V 脉冲联动气缸执行剔除。'
|
|
181
|
+
}
|
|
182
|
+
],
|
|
183
|
+
system_ingestion_guide: [
|
|
184
|
+
'1. 订阅缺陷事件 MQTT 用于车间看板展示不良率与缺陷类别分布。',
|
|
185
|
+
'2. 硬件 DO 端子直接接入产线 PLC 计数或剔除机构。'
|
|
186
|
+
]
|
|
187
|
+
}
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Extracts or generates system integration contract for a given solution or reference design.
|
|
192
|
+
*
|
|
193
|
+
* @param {string} solutionId
|
|
194
|
+
* @param {Object} [options]
|
|
195
|
+
* @param {string} [options.guideText] - Deployment guide text for fallback scanning
|
|
196
|
+
* @returns {Object} Integration contract specification
|
|
197
|
+
*/
|
|
198
|
+
export function getIntegrationContract(solutionId, { guideText = '' } = {}) {
|
|
199
|
+
const normId = String(solutionId || '').replace(/-/g, '_').toLowerCase();
|
|
200
|
+
for (const [key, contract] of Object.entries(INTEGRATION_CONTRACTS)) {
|
|
201
|
+
const normKey = key.replace(/-/g, '_').toLowerCase();
|
|
202
|
+
if (normId === normKey || normId.includes(normKey) || normKey.includes(normId)) {
|
|
203
|
+
return contract;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
// Fallback: smart heuristic scan over deployment guide text
|
|
208
|
+
const protocols = [];
|
|
209
|
+
const interfaces = [];
|
|
210
|
+
const g = String(guideText || '');
|
|
211
|
+
|
|
212
|
+
if (/mqtt/i.test(g)) {
|
|
213
|
+
protocols.push('mqtt');
|
|
214
|
+
interfaces.push({
|
|
215
|
+
protocol: 'mqtt',
|
|
216
|
+
port: 1883,
|
|
217
|
+
topic: `${solutionId}/results`,
|
|
218
|
+
direction: 'publish',
|
|
219
|
+
description: 'MQTT 业务结果与状态发布总线'
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
if (/webhook/i.test(g)) {
|
|
223
|
+
protocols.push('webhook');
|
|
224
|
+
interfaces.push({
|
|
225
|
+
protocol: 'webhook',
|
|
226
|
+
endpoint: '配置中的 WEBHOOK_URL',
|
|
227
|
+
direction: 'outbound_post',
|
|
228
|
+
description: '事件触发向外部系统推送 HTTP POST 回调'
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
if (/rtsp/i.test(g)) {
|
|
232
|
+
protocols.push('rtsp');
|
|
233
|
+
interfaces.push({
|
|
234
|
+
protocol: 'rtsp',
|
|
235
|
+
port: 8554,
|
|
236
|
+
direction: 'stream',
|
|
237
|
+
description: '视频流接入或实时画面分发'
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
if (/http|dashboard|api/i.test(g)) {
|
|
241
|
+
protocols.push('http');
|
|
242
|
+
interfaces.push({
|
|
243
|
+
protocol: 'http',
|
|
244
|
+
port: 8080,
|
|
245
|
+
endpoint: '/api',
|
|
246
|
+
direction: 'inbound_rest',
|
|
247
|
+
description: 'REST API 或管理控制面板'
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
if (protocols.length === 0) {
|
|
252
|
+
protocols.push('mqtt', 'http');
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
return {
|
|
256
|
+
solution_id: solutionId,
|
|
257
|
+
protocols,
|
|
258
|
+
interfaces,
|
|
259
|
+
input_requirements: [],
|
|
260
|
+
system_ingestion_guide: [
|
|
261
|
+
'1. 详情请查阅该方案的具体部署指南与环境变量说明。',
|
|
262
|
+
'2. 通过标准网络协议(MQTT/HTTP)完成与自有业务系统的对接。'
|
|
263
|
+
]
|
|
264
|
+
};
|
|
265
|
+
}
|