@switchbot/openapi-cli 2.7.2 → 3.1.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.
Files changed (69) hide show
  1. package/README.md +481 -103
  2. package/dist/api/client.js +23 -1
  3. package/dist/commands/agent-bootstrap.js +47 -2
  4. package/dist/commands/auth.js +354 -0
  5. package/dist/commands/batch.js +20 -4
  6. package/dist/commands/capabilities.js +155 -65
  7. package/dist/commands/config.js +109 -0
  8. package/dist/commands/daemon.js +367 -0
  9. package/dist/commands/devices.js +62 -11
  10. package/dist/commands/doctor.js +417 -8
  11. package/dist/commands/events.js +3 -3
  12. package/dist/commands/explain.js +1 -2
  13. package/dist/commands/health.js +113 -0
  14. package/dist/commands/install.js +246 -0
  15. package/dist/commands/mcp.js +888 -7
  16. package/dist/commands/plan.js +379 -103
  17. package/dist/commands/policy.js +586 -0
  18. package/dist/commands/rules.js +875 -0
  19. package/dist/commands/scenes.js +140 -0
  20. package/dist/commands/schema.js +0 -2
  21. package/dist/commands/status-sync.js +131 -0
  22. package/dist/commands/uninstall.js +237 -0
  23. package/dist/commands/upgrade-check.js +88 -0
  24. package/dist/config.js +14 -0
  25. package/dist/credentials/backends/file.js +101 -0
  26. package/dist/credentials/backends/linux.js +129 -0
  27. package/dist/credentials/backends/macos.js +129 -0
  28. package/dist/credentials/backends/windows.js +215 -0
  29. package/dist/credentials/keychain.js +88 -0
  30. package/dist/credentials/prime.js +52 -0
  31. package/dist/devices/catalog.js +4 -10
  32. package/dist/index.js +30 -1
  33. package/dist/install/default-steps.js +257 -0
  34. package/dist/install/preflight.js +212 -0
  35. package/dist/install/steps.js +67 -0
  36. package/dist/lib/command-keywords.js +17 -0
  37. package/dist/lib/daemon-state.js +46 -0
  38. package/dist/lib/destructive-mode.js +12 -0
  39. package/dist/lib/devices.js +1 -1
  40. package/dist/lib/plan-store.js +68 -0
  41. package/dist/policy/add-rule.js +124 -0
  42. package/dist/policy/diff.js +91 -0
  43. package/dist/policy/examples/policy.example.yaml +99 -0
  44. package/dist/policy/format.js +57 -0
  45. package/dist/policy/load.js +61 -0
  46. package/dist/policy/migrate.js +67 -0
  47. package/dist/policy/schema/v0.2.json +331 -0
  48. package/dist/policy/schema.js +18 -0
  49. package/dist/policy/validate.js +262 -0
  50. package/dist/rules/action.js +205 -0
  51. package/dist/rules/audit-query.js +89 -0
  52. package/dist/rules/conflict-analyzer.js +203 -0
  53. package/dist/rules/cron-scheduler.js +186 -0
  54. package/dist/rules/destructive.js +52 -0
  55. package/dist/rules/engine.js +757 -0
  56. package/dist/rules/matcher.js +230 -0
  57. package/dist/rules/pid-file.js +95 -0
  58. package/dist/rules/quiet-hours.js +45 -0
  59. package/dist/rules/suggest.js +95 -0
  60. package/dist/rules/throttle.js +116 -0
  61. package/dist/rules/types.js +34 -0
  62. package/dist/rules/webhook-listener.js +223 -0
  63. package/dist/rules/webhook-token.js +90 -0
  64. package/dist/status-sync/manager.js +268 -0
  65. package/dist/utils/audit.js +12 -2
  66. package/dist/utils/health.js +101 -0
  67. package/dist/utils/output.js +72 -23
  68. package/dist/utils/retry.js +81 -0
  69. package/package.json +12 -4
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Destructive command parsing — single source of truth shared between the
3
+ * policy validator post-hook (rejects destructive commands inside
4
+ * `automation.rules[].then[].command`) and the runtime executor (second-
5
+ * line guard that refuses to shell out even if validation was bypassed).
6
+ */
7
+ export const DESTRUCTIVE_COMMANDS = [
8
+ 'lock',
9
+ 'unlock',
10
+ 'deleteWebhook',
11
+ 'deleteScene',
12
+ 'factoryReset',
13
+ ];
14
+ /**
15
+ * Parse the verb out of a rule action command string. The expected form
16
+ * mirrors what the engine will eventually build: `devices command <id> <verb> [args...]`.
17
+ * We also accept scene shorthands (`scenes run <id>`, `webhooks delete <id>`).
18
+ *
19
+ * Returns null for anything we cannot confidently attribute to a known verb
20
+ * slot — the validator treats null as "probably fine, let the engine's own
21
+ * guard handle it if it's not."
22
+ */
23
+ export function extractVerb(cmd) {
24
+ const trimmed = cmd.trim();
25
+ if (!trimmed)
26
+ return null;
27
+ const tokens = trimmed.split(/\s+/);
28
+ // `devices command <id> <verb> [args]`
29
+ if (tokens[0] === 'devices' && tokens[1] === 'command' && tokens.length >= 4) {
30
+ return tokens[3];
31
+ }
32
+ // `webhooks delete <id>` → verb is "deleteWebhook"
33
+ if (tokens[0] === 'webhooks' && tokens[1] === 'delete')
34
+ return 'deleteWebhook';
35
+ // `scenes delete <id>` → verb is "deleteScene"
36
+ if (tokens[0] === 'scenes' && tokens[1] === 'delete')
37
+ return 'deleteScene';
38
+ return null;
39
+ }
40
+ export function isDestructiveCommand(cmd) {
41
+ const verb = extractVerb(cmd);
42
+ if (!verb)
43
+ return false;
44
+ return DESTRUCTIVE_COMMANDS.includes(verb);
45
+ }
46
+ export function destructiveVerbOf(cmd) {
47
+ const verb = extractVerb(cmd);
48
+ if (verb && DESTRUCTIVE_COMMANDS.includes(verb)) {
49
+ return verb;
50
+ }
51
+ return null;
52
+ }