@switchbot/openapi-cli 3.3.2 → 3.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.
@@ -78,6 +78,37 @@
78
78
  "rules": {
79
79
  "type": ["array", "null"],
80
80
  "items": { "$ref": "#/$defs/rule" }
81
+ },
82
+ "audit": {
83
+ "type": ["object", "null"],
84
+ "additionalProperties": false,
85
+ "description": "Controls rule-evaluate trace recording.",
86
+ "properties": {
87
+ "evaluate_trace": {
88
+ "enum": ["full", "sampled", "off"],
89
+ "default": "sampled",
90
+ "description": "full=every evaluation; sampled=skip high-freq blocked-by-condition; off=disabled."
91
+ },
92
+ "evaluate_retention_days": {
93
+ "type": "integer",
94
+ "minimum": 1,
95
+ "default": 7,
96
+ "description": "Days to retain rule-evaluate records."
97
+ }
98
+ }
99
+ },
100
+ "llm_budget": {
101
+ "type": ["object", "null"],
102
+ "additionalProperties": false,
103
+ "description": "Global LLM call budget applied across all llm conditions.",
104
+ "properties": {
105
+ "max_calls_per_hour": {
106
+ "type": "integer",
107
+ "minimum": 0,
108
+ "default": 60,
109
+ "description": "Maximum LLM condition calls per hour across all rules."
110
+ }
111
+ }
81
112
  }
82
113
  }
83
114
  },
@@ -299,15 +330,54 @@
299
330
  "description": "Negates the sub-condition."
300
331
  }
301
332
  }
333
+ },
334
+ {
335
+ "type": "object",
336
+ "additionalProperties": false,
337
+ "required": ["llm"],
338
+ "properties": {
339
+ "llm": {
340
+ "type": "object",
341
+ "additionalProperties": false,
342
+ "required": ["prompt"],
343
+ "description": "Evaluate the condition using an LLM decision call.",
344
+ "properties": {
345
+ "prompt": { "type": "string", "minLength": 1, "description": "Prompt template sent to the LLM." },
346
+ "provider": { "enum": ["auto", "openai", "anthropic"], "default": "auto" },
347
+ "timeout_ms": { "type": "integer", "minimum": 500, "maximum": 10000, "default": 5000 },
348
+ "cache_ttl": { "type": "string", "pattern": "^(none|\\d+[smh])$", "default": "5m" },
349
+ "budget": {
350
+ "type": ["object", "null"],
351
+ "additionalProperties": false,
352
+ "properties": {
353
+ "max_calls_per_hour": { "type": "integer", "minimum": 0, "default": 10 }
354
+ }
355
+ },
356
+ "on_error": { "enum": ["fail", "pass", "skip"], "default": "fail" },
357
+ "recent_events": { "type": "integer", "minimum": 0, "maximum": 20, "default": 5 }
358
+ }
359
+ }
360
+ }
302
361
  }
303
362
  ]
304
363
  },
305
364
 
306
365
  "action": {
366
+ "oneOf": [
367
+ { "$ref": "#/$defs/commandAction" },
368
+ { "$ref": "#/$defs/notifyAction" }
369
+ ]
370
+ },
371
+
372
+ "commandAction": {
307
373
  "type": "object",
308
374
  "additionalProperties": false,
309
375
  "required": ["command"],
310
376
  "properties": {
377
+ "type": {
378
+ "enum": ["command"],
379
+ "description": "Optional discriminator. Omit for backwards compatibility."
380
+ },
311
381
  "command": {
312
382
  "type": "string",
313
383
  "description": "A CLI invocation fragment, e.g. `devices command <id> turnOn`. The engine prepends `switchbot` and appends `--audit-log`."
@@ -326,6 +396,38 @@
326
396
  "description": "If this action fails, should the rule keep executing its remaining `then[]` entries?"
327
397
  }
328
398
  }
399
+ },
400
+
401
+ "notifyAction": {
402
+ "type": "object",
403
+ "additionalProperties": false,
404
+ "required": ["type", "channel", "to"],
405
+ "properties": {
406
+ "type": { "const": "notify" },
407
+ "channel": {
408
+ "enum": ["webhook", "openclaw", "file"],
409
+ "description": "Delivery channel."
410
+ },
411
+ "to": {
412
+ "type": "string",
413
+ "minLength": 1,
414
+ "description": "URL for webhook/openclaw; absolute file path for file channel."
415
+ },
416
+ "template": {
417
+ "type": "string",
418
+ "description": "Template string with {{ rule.name }}, {{ event.* }}, {{ device.id }} substitutions."
419
+ },
420
+ "on_failure": {
421
+ "enum": ["log", "retry", "ignore"],
422
+ "default": "log",
423
+ "description": "What to do when delivery fails."
424
+ },
425
+ "on_error": {
426
+ "enum": ["continue", "stop"],
427
+ "default": "continue",
428
+ "description": "If this action fails, should the rule keep executing its remaining `then[]` entries?"
429
+ }
430
+ }
329
431
  }
330
432
  }
331
433
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@switchbot/openapi-cli",
3
- "version": "3.3.2",
3
+ "version": "3.4.0",
4
4
  "description": "SwitchBot smart home CLI — control devices, run scenes, stream real-time events, and integrate AI agents via MCP. Full API v1.1 coverage.",
5
5
  "keywords": [
6
6
  "switchbot",