rterm-backend 1.9.0 → 1.9.2

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 (4) hide show
  1. package/LICENSE.md +1 -0
  2. package/README.md +56 -47
  3. package/bin/gybackend.js +14782 -2282
  4. package/package.json +6 -2
package/LICENSE.md CHANGED
@@ -23,6 +23,7 @@ Notable bundled/linked components include:
23
23
  - **node-pty** (MIT) — pseudo-terminal bindings
24
24
  - **better-sqlite3** (MIT) — SQLite bindings
25
25
  - **ws** (MIT) — WebSocket library
26
+ - **@nats-io/transport-node, @nats-io/nats-core** (Apache-2.0) — NATS client
26
27
  - **@langchain/core, @langchain/langgraph** (MIT) — agent orchestration
27
28
  - **@modelcontextprotocol/sdk** (MIT) — Model Context Protocol
28
29
  - **web-tree-sitter, tree-sitter-bash** (MIT) — command parsing
package/README.md CHANGED
@@ -10,7 +10,10 @@ drive it remotely.
10
10
  │ your agent / │ ◄────────────────────► │ rterm-backend (gybackend) │
11
11
  │ program / CI │ │ • AI agent (LLM + tools) │
12
12
  └──────────────┘ │ • SSH / WinRM / Serial / local │
13
- │ • fleet orchestration
13
+ │ • advanced automation
14
+ │ (event-driven triggers, DAG │
15
+ │ playbooks, idempotent runs) │
16
+ │ • NATS event mesh (fleet-wide) │
14
17
  │ • scheduled automation (cron) │
15
18
  │ • change management (MOP) │
16
19
  └──────────────────────────────────┘
@@ -22,10 +25,10 @@ drive it remotely.
22
25
  npm install -g rterm-backend
23
26
  ```
24
27
 
25
- This installs the `gybackend` CLI plus the small set of native/runtime
26
- dependencies (`better-sqlite3`, `node-pty`, `ssh2`, tree-sitter wasm, and
27
- optional `serialport`). Everything else — the AI agent, MCP SDK, SSH/WinRM/
28
- Serial handling, automation engine — is bundled into the single CLI file.
28
+ This installs the `gybackend` CLI plus a small set of native/runtime deps
29
+ (`better-sqlite3`, `node-pty`, `ssh2`, tree-sitter wasm, `@nats-io/transport-node`,
30
+ and optional `serialport`). Everything else — the AI agent, MCP SDK, SSH/WinRM/
31
+ Serial handling, the automation engine, the NATS client — is bundled in.
29
32
 
30
33
  ## Run
31
34
 
@@ -33,11 +36,7 @@ Serial handling, automation engine — is bundled into the single CLI file.
33
36
  gybackend
34
37
  ```
35
38
 
36
- Or without a global install:
37
-
38
- ```bash
39
- npx rterm-backend
40
- ```
39
+ Or without a global install: `npx rterm-backend`.
41
40
 
42
41
  On boot it prints the gateway endpoint:
43
42
 
@@ -47,6 +46,42 @@ On boot it prints the gateway endpoint:
47
46
  [gybackend] Data directory: ./.gybackend-data
48
47
  ```
49
48
 
49
+ ## Advanced Automation (v1.9.x)
50
+
51
+ - **Event-driven triggers** — fire a playbook (or propose a MOP change) when a
52
+ terminal-output **pattern** matches, a monitor **threshold** is crossed, or a
53
+ **webhook** fires. Per-trigger cooldown + concurrency cap prevent storms.
54
+ Manage via the `manage_trigger` RPC/tool; persisted in the data dir.
55
+ - **DAG / parallel playbooks** — `dependsOn` step graphs with capped parallelism
56
+ (`maxParallelSteps`), cycle detection, fan-out/fan-in.
57
+ - **Parameterized runbooks with secrets** — `params[]` injected at run time,
58
+ `{{param.name}}` substitution, secret values masked in records/logs.
59
+ - **Idempotent desired-state config** — steps with `desiredState` are skipped
60
+ when the target is already in the desired state (converge-style).
61
+ - **Cross-host orchestration variables** — `captureVar` from one step's output
62
+ feeds `{{var}}` into later steps.
63
+
64
+ ## NATS event mesh (fleet-wide triggers)
65
+
66
+ Point the backend at a [NATS server](https://nats.io) and every instance's
67
+ terminal output + monitor snapshots publish onto shared subjects — so a trigger
68
+ fires **across the whole fleet**, not just the local host. Configure in
69
+ `settings.json`:
70
+
71
+ ```jsonc
72
+ {
73
+ "nats": {
74
+ "enabled": true,
75
+ "url": "nats://localhost:4222", // or "servers": ["nats://a:4222", "nats://b:4222"]
76
+ "prefix": "rterm" // subject prefix (default "rterm")
77
+ }
78
+ }
79
+ ```
80
+
81
+ Subjects: `rterm.term.data`, `rterm.monitor.snapshot`, `rterm.trigger.fire`.
82
+ Run a NATS server with `nats-server` (single binary) as the mesh hub. Best-effort:
83
+ a NATS outage never blocks local automation.
84
+
50
85
  ## Configure (environment variables)
51
86
 
52
87
  | Var | Default | Meaning |
@@ -56,17 +91,13 @@ On boot it prints the gateway endpoint:
56
91
  | `GYBACKEND_WS_PORT` | `17888` | gateway port |
57
92
  | `GYBACKEND_DATA_DIR` | `./.gybackend-data` | settings, ledgers, skills, sessions |
58
93
  | `GYBACKEND_BOOTSTRAP_LOCAL_TERMINAL` | `true` | open a local shell tab on boot |
59
- | `GYBACKEND_TERMINAL_ID` | `local-main` | id of the bootstrap terminal |
60
- | `GYBACKEND_TERMINAL_TITLE` | `Local` | title of the bootstrap terminal |
61
- | `GYBACKEND_TERMINAL_CWD` | — | cwd of the bootstrap terminal |
62
- | `GYBACKEND_TERMINAL_SHELL` | — | shell of the bootstrap terminal |
94
+ | `GYBACKEND_TERMINAL_ID` | `local-main` | bootstrap terminal id |
95
+ | `GYBACKEND_TERMINAL_TITLE` | `Local` | bootstrap terminal title |
96
+ | `GYBACKEND_TERMINAL_CWD` | — | bootstrap terminal cwd |
97
+ | `GYBACKEND_TERMINAL_SHELL` | — | bootstrap terminal shell |
63
98
 
64
99
  ### Share settings with the desktop app
65
100
 
66
- By default the daemon uses its **own** data dir (a blank slate). To reuse the
67
- desktop RTerm app's settings, saved connections, and model keys, point it at
68
- the app's settings directory:
69
-
70
101
  ```bash
71
102
  # macOS
72
103
  GYBACKEND_DATA_DIR="$HOME/Library/Application Support/rterm" gybackend
@@ -78,45 +109,23 @@ set GYBACKEND_DATA_DIR=%APPDATA%\rterm && gybackend
78
109
 
79
110
  ## Drive it remotely
80
111
 
81
- The gateway is **WebSocket JSON-RPC**. Request `{ "id": "1", "method": "<name>",
112
+ The gateway is **WebSocket JSON-RPC**: request `{ "id": "1", "method": "<name>",
82
113
  "params": {...} }` → response `{ "type": "gateway:response", "id": "1", "ok":
83
- true|false, "result"|"error" }`. Progress streams back as `gateway:event` /
84
- `gateway:raw` messages. Localhost connections skip token auth by default.
85
-
86
- Quick check with [`websocat`](https://github.com/vi/websocat):
114
+ true|false, "result"|"error" }`. Localhost skips token auth by default.
87
115
 
88
116
  ```bash
89
117
  echo '{"id":"1","method":"gateway:ping"}' | websocat -n1 ws://127.0.0.1:17888
90
118
  # -> {"type":"gateway:response","id":"1","ok":true,"result":{"pong":true,...}}
91
119
  ```
92
120
 
93
- Run an AI agent task on a server:
94
-
95
- ```bash
96
- websocat ws://127.0.0.1:17888
97
- {"id":"1","method":"gateway:createSession"}
98
- {"id":"2","method":"agent:startTaskAsync","params":{"sessionId":"<sid>","userInput":"Update AV signatures on the saved WinRM connection AWS-Windows-Server-1 and report the version"}}
99
- ```
100
-
101
- **Full RPC reference + client libraries** (Node CLI, Python, websocat examples):
102
- see the [`rterm-gateway` skill](https://github.com/DrOlu/agent-skills/tree/main/skills/rterm-gateway).
103
-
104
- ## What you can do with it
105
-
106
- - **AI agent tasks** — `agent:startTask` / `agent:startTaskAsync` (multi-step, tool-using)
107
- - **Terminals** — open/run SSH, WinRM, Serial, local tabs and send commands
108
- - **Files** — read/write/transfer on any connected host (`filesystem:*`)
109
- - **Fleet** — run a command across many servers, collect structured results
110
- - **Automation** — playbooks, scheduled cron jobs, config templates
111
- - **Change management (MOP)** — plan → approve → run with validation + automatic rollback
112
- - **Settings/policy** — manage connections, command policy, skills, memory, models
121
+ **Full RPC reference + clients:** the [`rterm-gateway` skill](https://github.com/DrOlu/agent-skills/tree/main/skills/rterm-gateway) (Node CLI, Python, websocat).
122
+ **Lifecycle management:** the [`rterm-backend` skill](https://github.com/DrOlu/agent-skills/tree/main/skills/rterm-backend).
113
123
 
114
124
  ## Requirements
115
125
 
116
- - **Node.js ≥ 18** on the host. Native deps (`better-sqlite3`, `node-pty`,
117
- `ssh2` crypto, tree-sitter) install prebuilt binaries for common platforms;
118
- on unusual platforms they build from source (needs a C/C++ toolchain).
126
+ **Node.js ≥ 18.** Native deps install prebuilt binaries for common platforms; on
127
+ unusual platforms they compile from source (needs a C/C++ toolchain).
119
128
 
120
129
  ## License
121
130
 
122
- See `LICENSE.md`. RTerm — Hyperspace Technologies — https://github.com/DrOlu/RTerm
131
+ CC BY-NC 4.0 — see `LICENSE.md`. RTerm — Hyperspace Technologies — https://github.com/DrOlu/RTerm