1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
//! Built-in JSON Schema definitions for Mecha10 configuration files.
use serde_json::Value;
// ============================================================================
// Schema Definitions
// ============================================================================
/// Get the built-in JSON Schema for mecha10.json project configuration
pub fn get_project_schema() -> Value {
serde_json::json!({
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "https://mecha10.dev/schemas/project.schema.json",
"title": "Mecha10 Project Configuration",
"description": "Configuration file for Mecha10 robotics projects",
"type": "object",
"required": ["name", "version"],
"properties": {
"$schema": {
"type": "string",
"description": "JSON Schema reference"
},
"name": {
"type": "string",
"pattern": "^[a-z0-9][a-z0-9-]*$",
"minLength": 1,
"maxLength": 64,
"description": "Project name (lowercase, alphanumeric, hyphens)"
},
"version": {
"type": "string",
"pattern": "^\\d+\\.\\d+\\.\\d+(-.+)?$",
"description": "Semantic version (e.g., '1.0.0' or '1.0.0-beta')"
},
"description": {
"type": "string",
"maxLength": 500,
"description": "Project description"
},
"author": {
"type": "string",
"maxLength": 100,
"description": "Project author"
},
"license": {
"type": "string",
"maxLength": 50,
"description": "License identifier (e.g., MIT, Apache-2.0)"
},
"robot": {
"type": "object",
"required": ["id", "type"],
"properties": {
"id": {
"type": "string",
"pattern": "^[a-zA-Z0-9_\\-${}]+$",
"description": "Robot identifier (can use ${ROBOT_ID} env var)"
},
"type": {
"type": "string",
"enum": ["service", "delivery", "industrial", "mobile", "manipulator", "custom"],
"description": "Robot type classification"
},
"platform": {
"type": "string",
"description": "Hardware platform (e.g., differential-drive, mecanum, ackermann)"
}
},
"description": "Robot hardware configuration"
},
"nodes": {
"type": "object",
"properties": {
"drivers": {
"type": "array",
"items": { "$ref": "#/definitions/node" },
"description": "Hardware driver nodes"
},
"standard": {
"type": "array",
"items": { "$ref": "#/definitions/standardNode" },
"description": "Standard/pre-built nodes from packages"
},
"custom": {
"type": "array",
"items": { "$ref": "#/definitions/node" },
"description": "Custom application nodes"
}
},
"description": "Node definitions"
},
"run_targets": {
"type": "object",
"patternProperties": {
"^[a-z][a-z0-9_-]*$": {
"$ref": "#/definitions/runTarget"
}
},
"description": "Execution targets (robot, remote, dev, etc.)"
},
"behaviors": {
"type": "object",
"properties": {
"default": {
"type": "string",
"description": "Default behavior tree file"
}
},
"additionalProperties": {
"type": "string"
},
"description": "Behavior tree configurations"
},
"simulation": {
"type": "object",
"properties": {
"enabled": {
"type": "boolean",
"description": "Enable simulation mode"
},
"environment": {
"type": "string",
"description": "Path to simulation environment file"
}
},
"description": "Simulation settings"
},
"scripts": {
"type": "object",
"patternProperties": {
"^[a-z][a-z0-9:_-]*$": {
"type": "string"
}
},
"description": "Script shortcuts (npm scripts-like)"
}
},
"definitions": {
"node": {
"type": "object",
"required": ["name", "path"],
"properties": {
"name": {
"type": "string",
"pattern": "^[a-z][a-z0-9_]*$",
"description": "Node name (snake_case)"
},
"path": {
"type": "string",
"description": "Path to node source code"
},
"config": {
"type": "string",
"description": "Path to node configuration file"
},
"description": {
"type": "string",
"maxLength": 200,
"description": "Node description"
},
"run_target": {
"type": "string",
"description": "Where to run this node (robot, remote, etc.)"
},
"enabled": {
"type": "boolean",
"default": true,
"description": "Whether node is enabled"
},
"auto_restart": {
"type": "boolean",
"default": true,
"description": "Auto-restart on crash"
},
"depends_on": {
"type": "array",
"items": {
"type": "string"
},
"description": "Node dependencies (other nodes that must start first)"
}
}
},
"standardNode": {
"type": "object",
"required": ["package", "binary"],
"properties": {
"package": {
"type": "string",
"pattern": "^@[a-z0-9-]+/[a-z0-9/-]+$",
"description": "Package identifier (e.g., @mecha10/drivers/camera-fake)"
},
"binary": {
"type": "string",
"description": "Binary name within package"
},
"config": {
"type": "string",
"description": "Path to configuration file"
}
}
},
"runTarget": {
"type": "object",
"properties": {
"description": {
"type": "string",
"maxLength": 200,
"description": "Target description"
},
"includes": {
"type": "array",
"items": {
"type": "string"
},
"description": "Node groups to include"
},
"resources": {
"type": "object",
"properties": {
"cpu_limit": {
"type": "string",
"pattern": "^\\d+(\\.\\d+)?$",
"description": "CPU limit (e.g., '2.0')"
},
"memory_limit": {
"type": "string",
"pattern": "^\\d+(K|M|G|T)?$",
"description": "Memory limit (e.g., '512M', '16G')"
},
"gpu": {
"oneOf": [
{ "type": "boolean" },
{
"type": "object",
"properties": {
"enabled": { "type": "boolean" },
"vendor": {
"type": "string",
"enum": ["nvidia", "amd", "intel"]
},
"count": {
"type": "integer",
"minimum": 1
},
"optional": { "type": "boolean" }
}
}
],
"description": "GPU requirements"
},
"storage_type": {
"type": "string",
"enum": ["local", "ssd", "hdd", "any"],
"description": "Storage type requirement"
},
"storage_size_gb": {
"type": "integer",
"minimum": 1,
"description": "Storage size in GB"
},
"model_cache": {
"type": "string",
"description": "Path to model cache directory"
},
"devices": {
"type": "array",
"items": {
"type": "string",
"pattern": "^/dev/.+$"
},
"description": "Required device files (e.g., /dev/video0)"
}
},
"description": "Resource requirements"
}
}
}
}
})
}
/// Get the JSON Schema for NodeConfig (runtime node configuration)
pub fn get_node_config_schema() -> Value {
serde_json::json!({
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Mecha10 Node Configuration",
"description": "Runtime configuration for individual nodes",
"type": "object",
"required": ["id", "executable"],
"properties": {
"id": {
"type": "string",
"pattern": "^[a-z][a-z0-9_-]*$",
"description": "Unique node identifier"
},
"name": {
"type": "string",
"maxLength": 100,
"description": "Human-readable name"
},
"executable": {
"type": "string",
"minLength": 1,
"description": "Path to executable"
},
"args": {
"type": "array",
"items": { "type": "string" },
"description": "Command-line arguments"
},
"env": {
"type": "object",
"patternProperties": {
"^[A-Z_][A-Z0-9_]*$": {
"type": "string"
}
},
"description": "Environment variables"
},
"mode": {
"type": "string",
"enum": ["local", "remote", "simulation"],
"default": "local",
"description": "Execution mode"
},
"auto_restart": {
"type": "boolean",
"default": true,
"description": "Auto-restart on crash"
},
"health_check_interval_s": {
"type": "integer",
"minimum": 1,
"maximum": 300,
"default": 5,
"description": "Health check interval in seconds"
},
"publishes": {
"type": "array",
"items": {
"type": "string",
"pattern": "^/[a-z0-9/_-]+$"
},
"description": "Topics this node publishes to"
},
"subscribes": {
"type": "array",
"items": {
"type": "string",
"pattern": "^/[a-z0-9/_-]+$"
},
"description": "Topics this node subscribes to"
},
"depends_on": {
"type": "array",
"items": {
"type": "string"
},
"description": "Node dependencies"
}
}
})
}