rterm-backend 2.5.1 → 2.7.1
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/LICENSE.md +193 -25
- package/README.md +251 -102
- package/bin/gybackend.js +337 -4
- package/package.json +8 -3
package/LICENSE.md
CHANGED
|
@@ -1,33 +1,201 @@
|
|
|
1
|
-
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
2
4
|
|
|
3
|
-
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
4
6
|
|
|
5
|
-
|
|
6
|
-
reproduce, and distribute the material for any purpose, including commercial use,
|
|
7
|
-
subject to the terms of the Apache 2.0 license.
|
|
7
|
+
1. Definitions.
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
10
11
|
|
|
11
|
-
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
12
14
|
|
|
13
|
-
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
14
22
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
Notable bundled/linked components include:
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
18
25
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
- **ws** (MIT) — WebSocket library
|
|
23
|
-
- **@nats-io/transport-node, @nats-io/nats-core** (Apache-2.0) — NATS client
|
|
24
|
-
- **@langchain/core, @langchain/langgraph** (MIT) — agent orchestration
|
|
25
|
-
- **@modelcontextprotocol/sdk** (MIT) — Model Context Protocol
|
|
26
|
-
- **web-tree-sitter, tree-sitter-bash** (MIT) — command parsing
|
|
27
|
-
- **serialport** (MIT) — serial port bindings (optional)
|
|
28
|
-
- **@xterm/headless** (MIT) — headless terminal model
|
|
29
|
-
- **zod** (MIT) — schema validation
|
|
30
|
-
- **socks** (MIT) — SOCKS proxy client
|
|
31
|
-
- **uuid, diff, remeda** (MIT) — utilities
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
32
29
|
|
|
33
|
-
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
in such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 Hyperspace Technologies
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,131 +1,280 @@
|
|
|
1
|
-
#
|
|
1
|
+
# <img src="./demo_imgs/icon.png" width="40" height="40" align="center" style="margin-right: 10px;"> RTerm
|
|
2
2
|
|
|
3
|
-
**
|
|
4
|
-
single near-self-contained Node bundle that boots RTerm's full backend and
|
|
5
|
-
exposes it over a **WebSocket JSON-RPC gateway**, so any program or agent can
|
|
6
|
-
drive it remotely.
|
|
3
|
+
> **The AI-Native Terminal that thinks, executes, and collaborates with you.**
|
|
7
4
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
│ program / CI │ │ • AI agent (LLM + tools) │
|
|
12
|
-
└──────────────┘ │ • SSH / WinRM / Serial / local │
|
|
13
|
-
│ • advanced automation │
|
|
14
|
-
│ (event-driven triggers, DAG │
|
|
15
|
-
│ playbooks, idempotent runs) │
|
|
16
|
-
│ • NATS event mesh (fleet-wide) │
|
|
17
|
-
│ • scheduled automation (cron) │
|
|
18
|
-
│ • change management (MOP) │
|
|
19
|
-
└──────────────────────────────────┘
|
|
20
|
-
```
|
|
5
|
+
[](https://www.apache.org/licenses/LICENSE-2.0)
|
|
6
|
+
[](#platforms)
|
|
7
|
+
[](#key-capabilities)
|
|
21
8
|
|
|
22
|
-
|
|
9
|
+
English README | [中文 README](./README.zh-CN.md)
|
|
10
|
+
Latest release notes: [`changelogs/v1.6.0.md`](./changelogs/v1.6.0.md)
|
|
23
11
|
|
|
24
|
-
|
|
25
|
-
npm install -g rterm-backend
|
|
26
|
-
```
|
|
12
|
+
If you have any suggestions or questions, please feel free to submit them in [GitHub Discussions](https://github.com/MrOrangeJJ/RTerm/discussions).
|
|
27
13
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
14
|
+
Usage guides:
|
|
15
|
+
[`docs/mobile-web-usage.md`](./docs/mobile-web-usage.md) ·
|
|
16
|
+
[`docs/tui-usage.md`](./docs/tui-usage.md) ·
|
|
17
|
+
[`docs/gybackend-usage.md`](./docs/gybackend-usage.md)
|
|
32
18
|
|
|
33
|
-
|
|
19
|
+
> [!WARNING]
|
|
20
|
+
> **Active Development**: RTerm evolves quickly. If a version introduces history compatibility breaks, it will be called out explicitly in release notes.
|
|
34
21
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
```
|
|
22
|
+
> [!NOTE]
|
|
23
|
+
> **v1.4.0 upgrade note**: the first launch after upgrading from a pre-1.4.0 version may briefly block while RTerm migrates legacy JSON history into SQLite and writes timestamped backup files. v1.4.3 has no additional migration step.
|
|
38
24
|
|
|
39
|
-
|
|
25
|
+
<p align="center">
|
|
26
|
+
<img src="./demo_imgs/v1.6.0_dark.png" width="100%" alt="GyShell dark theme demo">
|
|
27
|
+
</p>
|
|
28
|
+
<p align="center">
|
|
29
|
+
<img src="./demo_imgs/v1.6.0_light.png" width="100%" alt="GyShell light theme demo">
|
|
30
|
+
</p>
|
|
31
|
+
<p align="center">
|
|
32
|
+
<video controls width="100%" src="https://github.com/user-attachments/assets/f9daf884-bda0-4a58-8a6d-934db0eddeb5"></video>
|
|
33
|
+
</p>
|
|
40
34
|
|
|
41
|
-
|
|
35
|
+
---
|
|
42
36
|
|
|
43
|
-
|
|
44
|
-
[gybackend] Started.
|
|
45
|
-
[gybackend] WebSocket RPC endpoint: ws://0.0.0.0:17888
|
|
46
|
-
[gybackend] Data directory: ./.gybackend-data
|
|
47
|
-
```
|
|
37
|
+
## Why RTerm Is Different
|
|
48
38
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
- **
|
|
56
|
-
|
|
57
|
-
- **
|
|
58
|
-
|
|
59
|
-
- **
|
|
60
|
-
|
|
61
|
-
- **Cross-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
39
|
+
Most AI terminal tools either generate one-shot scripts, or run in isolated sandboxes detached from real shell workflows.
|
|
40
|
+
|
|
41
|
+
RTerm is built for **persistent execution in your real terminal runtime**:
|
|
42
|
+
|
|
43
|
+
- **Persistent execution loop**: observe output -> reason -> continue.
|
|
44
|
+
- **Human-in-the-loop by design**: intervene anytime without breaking flow.
|
|
45
|
+
- **Multi-tab orchestration**: compile, inspect logs, and run fixes in parallel tabs.
|
|
46
|
+
- **Global tab inventory**: scan, reopen, drag, close, and create terminal/chat tabs from a dedicated list panel.
|
|
47
|
+
- **Workspace persistence**: terminal tabs, panel layout, and saved layout slots can survive restarts and restore quickly.
|
|
48
|
+
- **Detachable multi-window workspace**: peel panels into sub-windows and move tabs or whole panels across windows.
|
|
49
|
+
- **Adaptive panel tab display**: keep full tab strips or switch to a compact selector for narrow panel headers.
|
|
50
|
+
- **Reusable Agent setting profiles**: save and reapply complete operating profiles for models, tools, policies, memory, and workflow flags.
|
|
51
|
+
- **Cross-chat context handoff**: reference previous conversations from the composer with `Pass Chat` mentions instead of manually copying history.
|
|
52
|
+
- **Integrated file management**: browse, edit, copy, and transfer files across local and SSH sessions without leaving the workspace.
|
|
53
|
+
- **Live resource visibility**: inspect CPU, memory, disks, network, processes, sockets, and GPU from local or SSH sessions.
|
|
54
|
+
- **OpenClawd-style remote conversation control**: keep the runtime core on your own computer and steer it from anywhere through chat.
|
|
55
|
+
- **Built-in mobile-web delivery**: desktop can publish the mobile-web companion directly over your LAN with copyable access links.
|
|
56
|
+
- **Cross-surface runtime model**: desktop, TUI, and mobile-web share one gateway semantics.
|
|
57
|
+
- **Profile lock safety**: busy sessions pin active model profile for consistency.
|
|
58
|
+
- **Long-horizon context quality**: memory.md + compaction summaries + visible boundaries + deterministic fallback recovery keep long sessions understandable.
|
|
59
|
+
- **Tooling-native workflow**: skills, MCP servers, and built-in tools are runtime primitives.
|
|
60
|
+
|
|
61
|
+
### At a Glance
|
|
62
|
+
|
|
63
|
+
- **For shipping work**: not just planning, but iterative execution and correction.
|
|
64
|
+
- **For long-running tasks**: preserves session continuity and state across steps.
|
|
65
|
+
- **For real infrastructure**: shell, SSH, forwarding, file management, and multi-tab interactive terminal control.
|
|
66
|
+
- **For multi-device flow**: desktop + TUI + mobile-web with shared gateway semantics.
|
|
67
|
+
- **For multimodal workflows**: text and image inputs can be combined in one execution turn.
|
|
68
|
+
|
|
69
|
+
## v1.6.0 Key Highlights
|
|
70
|
+
|
|
71
|
+
- **Global Tab List panel**
|
|
72
|
+
- a new `TAB LIST` panel shows terminal and chat tabs as a vertical workspace inventory, with counts, status dots, latest-first ordering, drag/drop support, close actions, and quick creation for chat, local terminal, and saved-SSH terminal tabs
|
|
73
|
+
- **Default workspace refresh**
|
|
74
|
+
- new main layouts start with the list panel on the left, chat in the center, and terminal on the right, making tab-heavy sessions easier to scan immediately
|
|
75
|
+
- **More predictable background terminal tabs**
|
|
76
|
+
- local and SSH tabs created from the list panel can start in the background, stay visible in the global terminal inventory, bind to terminal panels when appropriate, and no longer unexpectedly take over linked filesystem or monitor panels
|
|
77
|
+
- **Visible compaction boundaries**
|
|
78
|
+
- long chats now persist and render a `[CTX COMPACTED]` marker at the actual retained-history cutoff across desktop, mobile-web, and TUI clients
|
|
79
|
+
- **Deterministic compaction fallback**
|
|
80
|
+
- when the compaction model fails or returns an empty summary, GyShell can recover with a local deterministic digest while preserving the protected tail and exporting exact older history for on-demand inspection when available
|
|
81
|
+
- **Safer stream recovery**
|
|
82
|
+
- empty non-tool provider stream finishes now retry through the normal path instead of silently ending a run with no answer, while valid empty tool-call finishes remain routable
|
|
83
|
+
- **Terminal inventory stability**
|
|
84
|
+
- terminal titles stay unique and stable across duplicate backend snapshots, concurrent terminal creation, explicit numeric suffixes, and detached-window terminal transfers
|
|
85
|
+
- **Mobile-web runtime refresh**
|
|
86
|
+
- Electron-packaged mobile-web assets were regenerated so desktop builds serve the updated client without requiring a separate mobile-web development server
|
|
87
|
+
|
|
88
|
+
---
|
|
89
|
+
|
|
90
|
+
## Key Capabilities
|
|
91
|
+
|
|
92
|
+
### AI-Native Runtime
|
|
93
|
+
|
|
94
|
+
- Thinking-oriented execution for complex tasks.
|
|
95
|
+
- Context-aware responses from terminal state and selected resources.
|
|
96
|
+
- Per-profile model routing for `Global`, `Thinking`, `Action`, and `Compaction` roles.
|
|
97
|
+
- Reusable Agent Setting profiles for model profile, security policy, tools, skills, memory, recursion, and experimental workflow flags.
|
|
98
|
+
- Long-session context quality with dedicated compaction models, dynamic summaries, visible `[CTX COMPACTED]` boundary markers, and deterministic fallback recovery when model compaction is unavailable.
|
|
99
|
+
- SQLite-backed conversation history with automatic one-time migration from legacy JSON storage.
|
|
100
|
+
- AI-assisted terminal command drafting from recent tab context, with paste-before-run control.
|
|
101
|
+
- Background (nowait) commands automatically notify the agent on completion, so the agent can close the loop without polling.
|
|
102
|
+
- Terminal-targeting agent tools report runtime status and refuse stale operations on disconnected tabs until reconnect succeeds.
|
|
103
|
+
- Reference previous conversations with `Pass Chat` mentions; GyShell exports the selected chat as private local Markdown and tells the agent how to read it only when needed.
|
|
104
|
+
- Classic or Seamless chat activity display, depending on how much inline tool detail you want.
|
|
105
|
+
- Persistent memory injection via `memory.md`, scoped to the active Agent Setting profile when one is applied.
|
|
106
|
+
- Multimodal user input pipeline (text + images) for compatible models.
|
|
107
|
+
- OpenAI-compatible model endpoint support, with automatic recovery from malformed empty tool-call stream finishes.
|
|
108
|
+
- Optional experimental agent tools, including asynchronous cross-machine file transfer between terminal tabs with progress polling.
|
|
109
|
+
|
|
110
|
+
### Terminal + SSH + File Management
|
|
111
|
+
|
|
112
|
+
- Shell support: Zsh, Bash, PowerShell.
|
|
113
|
+
- Older Windows PowerShell environments now use more reliable sidecar-based command completion tracking for local and SSH sessions.
|
|
114
|
+
- SSH support: password/key auth, proxy chaining, bastion workflows.
|
|
115
|
+
- SSH sessions use protocol keepalive to reduce silent idle disconnects.
|
|
116
|
+
- Port forwarding: local, remote, and dynamic SOCKS.
|
|
117
|
+
- Agent can coordinate **multiple SSH/local terminal tabs** in parallel during one task.
|
|
118
|
+
- Control-character operations for interactive terminal apps.
|
|
119
|
+
- Draft a command for the current terminal tab from recent visible output, then paste it back without auto-running it.
|
|
120
|
+
- Search within the active terminal buffer without leaving the panel.
|
|
121
|
+
- Terminal tab restoration after backend restart, plus lossless output catch-up for renderer remount/reconnect within the same backend runtime.
|
|
122
|
+
- Local terminal tabs auto-respawn their shell if it exits, so a local tab stays usable instead of going dead.
|
|
123
|
+
- Disconnected SSH tabs can be reconnected in place from the tab right-click menu using their saved connection config.
|
|
124
|
+
- **Integrated file browser panel**: browse, create, rename, delete, preview, sort, filter, and search files across local and SSH sessions.
|
|
125
|
+
- **Cross-session file transfer** (copy/move) with real-time progress, cancellation, and adaptive SFTP tuning.
|
|
126
|
+
- **Built-in file editor panel** for editing text files, plus inline preview of images (`png/jpg/gif/webp/bmp/ico/svg/avif`) and PDFs (with page navigation and zoom), all directly in the workspace.
|
|
127
|
+
- **File row right-click menu** with Copy / Cut / Paste / Rename / Delete and **Copy Full Path(s)** to the system clipboard.
|
|
128
|
+
- **Paste conflict resolution**: choose between **Overwrite** and **Keep Both** (auto-numbered names) when pasting into a folder with same-named items.
|
|
129
|
+
|
|
130
|
+
### Workspace + Monitoring
|
|
131
|
+
|
|
132
|
+
- Detach panels into dedicated sub-windows and move tabs or whole panels across windows.
|
|
133
|
+
- Use the global Tab List panel to scan terminal/chat inventory, restore unhosted tabs, drag tabs across layout targets, close tabs, and create new chat/local/SSH tabs without forcing a terminal panel to appear.
|
|
134
|
+
- Save up to three workspace layout slots and restore them from the rail.
|
|
135
|
+
- Optionally keep the computer awake while any chat session is running, with the system-sleep block released automatically when runs finish.
|
|
136
|
+
- Chat tabs show a running indicator while a session is busy, mirroring terminal tab runtime-state dots.
|
|
137
|
+
- Choose `Auto`, `Expanded`, or `Select` panel tab display modes based on how much header space your workspace has.
|
|
138
|
+
- `Ctrl/Cmd+F` opens a panel-local find bar in terminal, current chat, file browser, and file editor.
|
|
139
|
+
- Open a resource monitor panel for local and SSH terminals from the workspace rail.
|
|
140
|
+
- Monitor panel surfaces CPU, memory, disk, network, process, socket, and GPU telemetry when available.
|
|
141
|
+
- Monitor collection is shared across tabs that point at the same local or SSH target, with failover if the original source tab exits.
|
|
142
|
+
- Monitor polling can be paused or resumed per local/SSH source, with the preference kept across restarts.
|
|
143
|
+
- Compact monitor layouts now give GPU telemetry its own card with clearer VRAM usage details.
|
|
144
|
+
|
|
145
|
+
### Skills + MCP + Tools
|
|
146
|
+
|
|
147
|
+
- Folder-based skills workflow compatible with agentskills-style structure.
|
|
148
|
+
- Dynamic MCP server integration.
|
|
149
|
+
- Precision editing tools for safe, targeted file updates.
|
|
150
|
+
- Runtime tool toggles and summaries exposed to clients.
|
|
151
|
+
|
|
152
|
+
### Mobile-Web Companion
|
|
153
|
+
|
|
154
|
+
- Mobile-first remote client for active session tracking and steering.
|
|
155
|
+
- Desktop can serve the mobile-web companion directly and expose copyable access links from settings.
|
|
156
|
+
- OpenClawd-style conversational control from anywhere while your core runtime stays on your own machine.
|
|
157
|
+
- Session list with search and status hints.
|
|
158
|
+
- Pending approval badge with jump-to-blocked-session behavior, plus task-completion toasts.
|
|
159
|
+
- Conversation rollback and branch-from-message controls from mobile.
|
|
160
|
+
- Swipe-to-delete session flow for faster mobile cleanup.
|
|
161
|
+
- Read-only terminal output tails with unread indicators, local/saved-SSH terminal creation, and SSH reconnect.
|
|
162
|
+
- Detailed turn event inspection from phone browser.
|
|
163
|
+
- Tool, skill, Agent Setting profile, terminal, and settings access through gateway RPC.
|
|
164
|
+
- Long chat timelines avoid full-list rerenders during composer input, keeping history-heavy mobile sessions responsive.
|
|
165
|
+
- Gateway exposure can now be limited to localhost, LAN-only, custom CIDR ranges, or all interfaces.
|
|
166
|
+
|
|
167
|
+
---
|
|
80
168
|
|
|
81
|
-
|
|
82
|
-
Run a NATS server with `nats-server` (single binary) as the mesh hub. Best-effort:
|
|
83
|
-
a NATS outage never blocks local automation.
|
|
169
|
+
## Platforms
|
|
84
170
|
|
|
85
|
-
|
|
171
|
+
1. **Electron desktop app** (`apps/electron`)
|
|
172
|
+
2. **Standalone backend runtime** (`apps/gybackend`)
|
|
173
|
+
3. **Deprecated TUI runtime** (`apps/tui` wrapper + `packages/tui` core)
|
|
174
|
+
4. **Mobile-web runtime** (`apps/mobile-web` wrapper + `packages/mobile-web` core)
|
|
86
175
|
|
|
87
|
-
|
|
88
|
-
|---|---|---|
|
|
89
|
-
| `GYBACKEND_WS_ENABLE` | `1` | enable the WebSocket gateway |
|
|
90
|
-
| `GYBACKEND_WS_HOST` | `0.0.0.0` | bind host (`127.0.0.1` for local-only) |
|
|
91
|
-
| `GYBACKEND_WS_PORT` | `17888` | gateway port |
|
|
92
|
-
| `GYBACKEND_DATA_DIR` | `./.gybackend-data` | settings, ledgers, skills, sessions |
|
|
93
|
-
| `GYBACKEND_BOOTSTRAP_LOCAL_TERMINAL` | `true` | open a local shell tab on boot |
|
|
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 |
|
|
176
|
+
### Which Surface Should You Use?
|
|
98
177
|
|
|
99
|
-
|
|
178
|
+
- **Desktop app**: primary full-featured experience for daily development.
|
|
179
|
+
- **TUI (`gyll`)**: deprecated and unsupported. Desktop packages no longer bundle or install `gyll`.
|
|
180
|
+
- **Mobile-web**: OpenClawd-style remote conversational control from phone/browser.
|
|
181
|
+
|
|
182
|
+
---
|
|
183
|
+
|
|
184
|
+
## Quick Start
|
|
185
|
+
|
|
186
|
+
### Prerequisites
|
|
187
|
+
|
|
188
|
+
- Node.js 18+
|
|
189
|
+
- npm
|
|
190
|
+
|
|
191
|
+
### Development
|
|
100
192
|
|
|
101
193
|
```bash
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
# Windows
|
|
107
|
-
set GYBACKEND_DATA_DIR=%APPDATA%\rterm && gybackend
|
|
194
|
+
git clone https://github.com/MrOrangeJJ/RTerm.git
|
|
195
|
+
cd RTerm
|
|
196
|
+
npm install
|
|
197
|
+
npm run dev
|
|
108
198
|
```
|
|
109
199
|
|
|
110
|
-
|
|
200
|
+
### One-line Mental Model
|
|
201
|
+
|
|
202
|
+
`RTerm = persistent AI runtime + real terminal control + human override at any time.`
|
|
111
203
|
|
|
112
|
-
|
|
113
|
-
"params": {...} }` → response `{ "type": "gateway:response", "id": "1", "ok":
|
|
114
|
-
true|false, "result"|"error" }`. Localhost skips token auth by default.
|
|
204
|
+
### Mobile-web development
|
|
115
205
|
|
|
116
206
|
```bash
|
|
117
|
-
|
|
118
|
-
# -> {"type":"gateway:response","id":"1","ok":true,"result":{"pong":true,...}}
|
|
207
|
+
npm run dev:mobile-web
|
|
119
208
|
```
|
|
120
209
|
|
|
121
|
-
|
|
122
|
-
|
|
210
|
+
---
|
|
211
|
+
|
|
212
|
+
## Deprecated CLI (`gyll`)
|
|
213
|
+
|
|
214
|
+
After installing and launching RTerm desktop once, `gyll` is available from the desktop runtime setup.
|
|
215
|
+
|
|
216
|
+
When an existing user updates from a version that installed desktop-managed `gyll` launchers, the updated app removes those legacy launchers on startup while leaving any shell profile PATH block untouched.
|
|
217
|
+
|
|
218
|
+
---
|
|
219
|
+
|
|
220
|
+
## Architecture Notes
|
|
221
|
+
|
|
222
|
+
RTerm follows strict layering:
|
|
223
|
+
|
|
224
|
+
- `packages/*`: implementation logic.
|
|
225
|
+
- `apps/*`: composition/bootstrap/build wrappers.
|
|
226
|
+
- Frontend logic does not belong in `packages/backend`.
|
|
227
|
+
|
|
228
|
+
Core runtime chain (simplified):
|
|
123
229
|
|
|
124
|
-
|
|
230
|
+
1. `startElectronMain` (desktop composition root)
|
|
231
|
+
2. `GatewayService` (session runtime + transport-agnostic orchestration)
|
|
232
|
+
3. `WebSocketGatewayControlService` (policy-based ws gateway control)
|
|
233
|
+
4. `WebSocketGatewayAdapter` / `ElectronWindowTransport` (transport implementations)
|
|
234
|
+
5. Client controllers in TUI and mobile-web
|
|
125
235
|
|
|
126
|
-
|
|
127
|
-
|
|
236
|
+
See:
|
|
237
|
+
|
|
238
|
+
- `docs/monorepo-architecture.md`
|
|
239
|
+
- `docs/build-commands.md`
|
|
240
|
+
|
|
241
|
+
## Privacy and Update Policy
|
|
242
|
+
|
|
243
|
+
- Version checks query only this repository's GitHub `version.json`.
|
|
244
|
+
- No third-party auto-update endpoint is used.
|
|
245
|
+
- Version check is the only automatic background network request.
|
|
246
|
+
|
|
247
|
+
## Read More
|
|
248
|
+
|
|
249
|
+
- Release notes: `changelogs/v1.6.0.md`
|
|
250
|
+
- Build matrix and packaging: `docs/build-commands.md`
|
|
251
|
+
- Monorepo boundaries and runtime flow: `docs/monorepo-architecture.md`
|
|
252
|
+
|
|
253
|
+
---
|
|
254
|
+
|
|
255
|
+
## Build and Packaging
|
|
256
|
+
|
|
257
|
+
- `npm run build`
|
|
258
|
+
- `npm run build:backend`
|
|
259
|
+
- `npm run build:tui`
|
|
260
|
+
- `npm run build:mobile-web`
|
|
261
|
+
- `npm run dist`
|
|
262
|
+
- `npm run dist:mac`
|
|
263
|
+
- `npm run dist:win`
|
|
264
|
+
- `npm run dist:linux`
|
|
265
|
+
- `npm run dist:linux-arm64`
|
|
266
|
+
- `./build.sh --help`
|
|
267
|
+
|
|
268
|
+
For the full command matrix and packaging notes, see `docs/build-commands.md`.
|
|
269
|
+
|
|
270
|
+
---
|
|
128
271
|
|
|
129
272
|
## License
|
|
130
273
|
|
|
131
|
-
|
|
274
|
+
This project is licensed under the **Apache License, Version 2.0** ([LICENSE](./LICENSE)).
|
|
275
|
+
|
|
276
|
+
Special acknowledgment: inspirations and references from [Tabby](https://github.com/Eugeny/tabby) (MIT).
|
|
277
|
+
|
|
278
|
+
---
|
|
279
|
+
|
|
280
|
+
**RTerm** - _The shell that thinks with you._
|
package/bin/gybackend.js
CHANGED
|
@@ -254727,7 +254727,7 @@ var require_websocket = __commonJS({
|
|
|
254727
254727
|
var http2 = __require("http");
|
|
254728
254728
|
var net2 = __require("net");
|
|
254729
254729
|
var tls = __require("tls");
|
|
254730
|
-
var { randomBytes: randomBytes2, createHash } = __require("crypto");
|
|
254730
|
+
var { randomBytes: randomBytes2, createHash: createHash3 } = __require("crypto");
|
|
254731
254731
|
var { Duplex, Readable } = __require("stream");
|
|
254732
254732
|
var { URL: URL5 } = __require("url");
|
|
254733
254733
|
var PerMessageDeflate = require_permessage_deflate();
|
|
@@ -255387,7 +255387,7 @@ var require_websocket = __commonJS({
|
|
|
255387
255387
|
abortHandshake(websocket, socket, "Invalid Upgrade header");
|
|
255388
255388
|
return;
|
|
255389
255389
|
}
|
|
255390
|
-
const digest =
|
|
255390
|
+
const digest = createHash3("sha1").update(key + GUID).digest("base64");
|
|
255391
255391
|
if (res.headers["sec-websocket-accept"] !== digest) {
|
|
255392
255392
|
abortHandshake(websocket, socket, "Invalid Sec-WebSocket-Accept header");
|
|
255393
255393
|
return;
|
|
@@ -255754,7 +255754,7 @@ var require_websocket_server = __commonJS({
|
|
|
255754
255754
|
var EventEmitter4 = __require("events");
|
|
255755
255755
|
var http2 = __require("http");
|
|
255756
255756
|
var { Duplex } = __require("stream");
|
|
255757
|
-
var { createHash } = __require("crypto");
|
|
255757
|
+
var { createHash: createHash3 } = __require("crypto");
|
|
255758
255758
|
var extension = require_extension();
|
|
255759
255759
|
var PerMessageDeflate = require_permessage_deflate();
|
|
255760
255760
|
var subprotocol = require_subprotocol();
|
|
@@ -256055,7 +256055,7 @@ var require_websocket_server = __commonJS({
|
|
|
256055
256055
|
);
|
|
256056
256056
|
}
|
|
256057
256057
|
if (this._state > RUNNING) return abortHandshake(socket, 503);
|
|
256058
|
-
const digest =
|
|
256058
|
+
const digest = createHash3("sha1").update(key + GUID).digest("base64");
|
|
256059
256059
|
const headers = [
|
|
256060
256060
|
"HTTP/1.1 101 Switching Protocols",
|
|
256061
256061
|
"Upgrade: websocket",
|
|
@@ -381872,6 +381872,332 @@ var BehaviorLedger = class {
|
|
|
381872
381872
|
}
|
|
381873
381873
|
};
|
|
381874
381874
|
|
|
381875
|
+
// ../../packages/backend/src/services/aperf/aperfService.ts
|
|
381876
|
+
import { randomUUID as randomUUID20 } from "crypto";
|
|
381877
|
+
var DEFAULT_HOST_DIR = "/tmp/aperf";
|
|
381878
|
+
var DEFAULT_INTERVAL = 1;
|
|
381879
|
+
var DEFAULT_PERIOD = 60;
|
|
381880
|
+
function buildInstallCommand(hostDir = DEFAULT_HOST_DIR) {
|
|
381881
|
+
return `mkdir -p ${hostDir} && cd ${hostDir} && arch=$(uname -m) && curl -sL $(curl -s https://api.github.com/repos/aws/aperf/releases/latest | grep "browser_download_url.*$arch.*\\\\.tar\\\\.gz" | cut -d'"' -f4) | tar -xz && chmod +x ./aperf-*/aperf && ls ./aperf-*/aperf`;
|
|
381882
|
+
}
|
|
381883
|
+
function buildPrereqCommand() {
|
|
381884
|
+
return "sudo sysctl -w kernel.perf_event_paranoid=-1 2>/dev/null || true";
|
|
381885
|
+
}
|
|
381886
|
+
function buildRecordCommand(plan) {
|
|
381887
|
+
const bin = `${plan.hostDir}/aperf-*/aperf`;
|
|
381888
|
+
const cats = plan.categories && plan.categories.length > 0 ? ` --include ${plan.categories.join(",")}` : "";
|
|
381889
|
+
return `${bin} record -r ${plan.runName} -i ${plan.intervalSec} -p ${plan.periodSec}${cats}`;
|
|
381890
|
+
}
|
|
381891
|
+
function buildReportCommand(plan, reportName) {
|
|
381892
|
+
const bin = `${plan.hostDir}/aperf-*/aperf`;
|
|
381893
|
+
return `${bin} report -r ${plan.runName} -n ${reportName}`;
|
|
381894
|
+
}
|
|
381895
|
+
function buildReadReportCommand(reportName) {
|
|
381896
|
+
return `cat ${reportName}/index.html 2>/dev/null || cat ${reportName}/*.txt 2>/dev/null || echo ''`;
|
|
381897
|
+
}
|
|
381898
|
+
function parseAperfReport(text) {
|
|
381899
|
+
const summary = {};
|
|
381900
|
+
const findings = [];
|
|
381901
|
+
const topProcs = [];
|
|
381902
|
+
const lines = text.split(/\r?\n/);
|
|
381903
|
+
for (const line of lines) {
|
|
381904
|
+
const l = line.trim();
|
|
381905
|
+
const cpuM = l.match(/cpu[_ ]utilization[^\d]*(\d+(?:\.\d+)?)\s*%?/i);
|
|
381906
|
+
if (cpuM && summary.cpuUsagePercent === void 0) {
|
|
381907
|
+
summary.cpuUsagePercent = parseFloat(cpuM[1]);
|
|
381908
|
+
}
|
|
381909
|
+
const memM = l.match(/mem(?:ory)?[_ ]utili[sz]ation[^\d]*(\d+(?:\.\d+)?)\s*%?/i) || l.match(/vmstat[^\d]*(\d+(?:\.\d+)?)\s*%?/i);
|
|
381910
|
+
if (memM && summary.memUsagePercent === void 0) {
|
|
381911
|
+
summary.memUsagePercent = parseFloat(memM[1]);
|
|
381912
|
+
}
|
|
381913
|
+
const diskM = l.match(/disk(?:stats)?\b/i);
|
|
381914
|
+
if (diskM) {
|
|
381915
|
+
const nums = l.match(/(\d+(?:\.\d+)?)\s*%?$/i);
|
|
381916
|
+
if (nums) {
|
|
381917
|
+
const v = parseFloat(nums[1]);
|
|
381918
|
+
if (summary.diskUsagePercentMax === void 0 || v > summary.diskUsagePercentMax) {
|
|
381919
|
+
summary.diskUsagePercentMax = v;
|
|
381920
|
+
}
|
|
381921
|
+
}
|
|
381922
|
+
}
|
|
381923
|
+
if (!/cpu|mem|disk|util|stat|interrupt|hotline|alloc/i.test(l)) {
|
|
381924
|
+
const procM = l.match(/^([A-Za-z][A-Za-z0-9_.-]*)\s+(\d+(?:\.\d+)?)\s*%?$/);
|
|
381925
|
+
if (procM && !/^(dev|sda|sdb|nvme|hd|sr|loop|dm)/i.test(procM[1])) {
|
|
381926
|
+
topProcs.push({ name: procM[1], cpuPercent: parseFloat(procM[2]) });
|
|
381927
|
+
}
|
|
381928
|
+
}
|
|
381929
|
+
const sevM = l.match(/\b(critical|crit|warn(?:ing)?|fail)\b/i);
|
|
381930
|
+
if (sevM && l.length > 8) {
|
|
381931
|
+
const sev = /crit|fail/i.test(sevM[1]) ? "critical" : "warning";
|
|
381932
|
+
const numM = l.match(/(\d+(?:\.\d+)?)\s*%?/);
|
|
381933
|
+
findings.push({
|
|
381934
|
+
metric: l.split(/\s{2,}/)[0].slice(0, 40),
|
|
381935
|
+
value: numM ? parseFloat(numM[1]) : 0,
|
|
381936
|
+
severity: sev,
|
|
381937
|
+
message: l.slice(0, 160)
|
|
381938
|
+
});
|
|
381939
|
+
}
|
|
381940
|
+
}
|
|
381941
|
+
topProcs.sort((a, b) => b.cpuPercent - a.cpuPercent);
|
|
381942
|
+
if (topProcs.length > 0) summary.topCpuProcesses = topProcs.slice(0, 5);
|
|
381943
|
+
if (findings.length === 0) {
|
|
381944
|
+
if ((summary.cpuUsagePercent ?? 0) >= 90) {
|
|
381945
|
+
findings.push({ metric: "cpu_utilization", value: summary.cpuUsagePercent, severity: "critical", message: `aggregate CPU utilization is ${summary.cpuUsagePercent}% (>= 90%)` });
|
|
381946
|
+
} else if ((summary.cpuUsagePercent ?? 0) >= 75) {
|
|
381947
|
+
findings.push({ metric: "cpu_utilization", value: summary.cpuUsagePercent, severity: "warning", message: `aggregate CPU utilization is ${summary.cpuUsagePercent}% (>= 75%)` });
|
|
381948
|
+
}
|
|
381949
|
+
if ((summary.memUsagePercent ?? 0) >= 90) {
|
|
381950
|
+
findings.push({ metric: "memory", value: summary.memUsagePercent, severity: "critical", message: `memory utilization is ${summary.memUsagePercent}% (>= 90%)` });
|
|
381951
|
+
}
|
|
381952
|
+
if ((summary.diskUsagePercentMax ?? 0) >= 90) {
|
|
381953
|
+
findings.push({ metric: "disk", value: summary.diskUsagePercentMax, severity: "critical", message: `a disk is at ${summary.diskUsagePercentMax}% utilization (>= 90%)` });
|
|
381954
|
+
}
|
|
381955
|
+
if (summary.topCpuProcesses && summary.topCpuProcesses.length > 0) {
|
|
381956
|
+
const top = summary.topCpuProcesses[0];
|
|
381957
|
+
if (top.cpuPercent >= 50) {
|
|
381958
|
+
findings.push({ metric: `process:${top.name}`, value: top.cpuPercent, severity: "warning", message: `top CPU process "${top.name}" is using ${top.cpuPercent}% of one CPU` });
|
|
381959
|
+
}
|
|
381960
|
+
}
|
|
381961
|
+
}
|
|
381962
|
+
return { summary, findings };
|
|
381963
|
+
}
|
|
381964
|
+
var AperfService = class {
|
|
381965
|
+
constructor(deps) {
|
|
381966
|
+
this.deps = deps;
|
|
381967
|
+
this.now = deps.now ?? (() => Date.now());
|
|
381968
|
+
}
|
|
381969
|
+
now;
|
|
381970
|
+
/** Full deep-dive: install aperf if needed, record, report, parse, return. */
|
|
381971
|
+
async deepDive(host, opts = {}) {
|
|
381972
|
+
const runName = `rterm-${randomUUID20().slice(0, 8)}`;
|
|
381973
|
+
const plan = {
|
|
381974
|
+
runName,
|
|
381975
|
+
intervalSec: opts.intervalSec ?? DEFAULT_INTERVAL,
|
|
381976
|
+
periodSec: opts.periodSec ?? DEFAULT_PERIOD,
|
|
381977
|
+
hostDir: DEFAULT_HOST_DIR,
|
|
381978
|
+
...opts.categories ? { categories: opts.categories } : {}
|
|
381979
|
+
};
|
|
381980
|
+
const installed = this.deps.fileExists ? await this.deps.fileExists(`${DEFAULT_HOST_DIR}/aperf-*/aperf`).catch(() => false) : false;
|
|
381981
|
+
if (!installed) {
|
|
381982
|
+
if (this.deps.downloadAperf) {
|
|
381983
|
+
await this.deps.downloadAperf(DEFAULT_HOST_DIR);
|
|
381984
|
+
} else {
|
|
381985
|
+
await this.deps.execSsh(buildInstallCommand(DEFAULT_HOST_DIR));
|
|
381986
|
+
}
|
|
381987
|
+
}
|
|
381988
|
+
await this.deps.execSsh(buildPrereqCommand()).catch(() => "");
|
|
381989
|
+
await this.deps.execSsh(buildRecordCommand(plan));
|
|
381990
|
+
const reportName = `${runName}-report`;
|
|
381991
|
+
await this.deps.execSsh(buildReportCommand(plan, reportName));
|
|
381992
|
+
const reportText = await this.deps.execSsh(buildReadReportCommand(reportName)).catch(() => "");
|
|
381993
|
+
const { summary, findings } = parseAperfReport(reportText);
|
|
381994
|
+
return {
|
|
381995
|
+
host,
|
|
381996
|
+
runName,
|
|
381997
|
+
reportPath: `${DEFAULT_HOST_DIR}/${reportName}`,
|
|
381998
|
+
summary,
|
|
381999
|
+
findings,
|
|
382000
|
+
reportText: reportText.slice(0, 8e3),
|
|
382001
|
+
at: this.now()
|
|
382002
|
+
};
|
|
382003
|
+
}
|
|
382004
|
+
};
|
|
382005
|
+
function aperfSummaryToMetricPoint(result) {
|
|
382006
|
+
return {
|
|
382007
|
+
host: result.host,
|
|
382008
|
+
...result.summary.cpuUsagePercent !== void 0 ? { cpuUsagePercent: result.summary.cpuUsagePercent } : {},
|
|
382009
|
+
...result.summary.memUsagePercent !== void 0 ? { memoryUsagePercent: result.summary.memUsagePercent } : {},
|
|
382010
|
+
...result.summary.diskUsagePercentMax !== void 0 ? { diskUsagePercentMax: result.summary.diskUsagePercentMax } : {}
|
|
382011
|
+
};
|
|
382012
|
+
}
|
|
382013
|
+
|
|
382014
|
+
// ../../packages/backend/src/services/audit/auditLedger.ts
|
|
382015
|
+
import { createHash, randomUUID as randomUUID21 } from "crypto";
|
|
382016
|
+
var GENESIS_HASH = "0".repeat(64);
|
|
382017
|
+
function computeRecordHash(kind, actor, target, summary, detail, at, seq2) {
|
|
382018
|
+
const payload = JSON.stringify({ kind, actor, target, summary, detail, at, seq: seq2 });
|
|
382019
|
+
return createHash("sha256").update(payload).digest("hex");
|
|
382020
|
+
}
|
|
382021
|
+
var AuditLedger = class _AuditLedger {
|
|
382022
|
+
records = [];
|
|
382023
|
+
hashFn;
|
|
382024
|
+
now;
|
|
382025
|
+
constructor(deps = {}) {
|
|
382026
|
+
this.hashFn = deps.hashFn ?? ((data) => createHash("sha256").update(data).digest("hex"));
|
|
382027
|
+
this.now = deps.now ?? (() => Date.now());
|
|
382028
|
+
}
|
|
382029
|
+
/** Append an event to the audit ledger. Returns the record with hash + chain. */
|
|
382030
|
+
append(event) {
|
|
382031
|
+
const seq2 = this.records.length + 1;
|
|
382032
|
+
const at = event.at ?? this.now();
|
|
382033
|
+
const prevHash = this.records.length > 0 ? this.records[this.records.length - 1].hash : GENESIS_HASH;
|
|
382034
|
+
const contentHash = computeRecordHash(
|
|
382035
|
+
event.kind,
|
|
382036
|
+
event.actor,
|
|
382037
|
+
event.target,
|
|
382038
|
+
event.summary,
|
|
382039
|
+
event.detail,
|
|
382040
|
+
at,
|
|
382041
|
+
seq2
|
|
382042
|
+
);
|
|
382043
|
+
const hash2 = createHash("sha256").update(contentHash + prevHash).digest("hex");
|
|
382044
|
+
const record2 = {
|
|
382045
|
+
id: `audit-${randomUUID21().slice(0, 12)}`,
|
|
382046
|
+
kind: event.kind,
|
|
382047
|
+
actor: event.actor,
|
|
382048
|
+
target: event.target,
|
|
382049
|
+
summary: event.summary,
|
|
382050
|
+
...event.detail ? { detail: event.detail } : {},
|
|
382051
|
+
at,
|
|
382052
|
+
seq: seq2,
|
|
382053
|
+
hash: hash2,
|
|
382054
|
+
prevHash
|
|
382055
|
+
};
|
|
382056
|
+
this.records.push(record2);
|
|
382057
|
+
return record2;
|
|
382058
|
+
}
|
|
382059
|
+
/** Get all records (ordered by seq). */
|
|
382060
|
+
list() {
|
|
382061
|
+
return [...this.records];
|
|
382062
|
+
}
|
|
382063
|
+
/** Get records by kind. */
|
|
382064
|
+
listByKind(kind) {
|
|
382065
|
+
return this.records.filter((r) => r.kind === kind);
|
|
382066
|
+
}
|
|
382067
|
+
/** Get records for a specific target. */
|
|
382068
|
+
listByTarget(target) {
|
|
382069
|
+
return this.records.filter((r) => r.target === target);
|
|
382070
|
+
}
|
|
382071
|
+
/** Get records for a specific actor. */
|
|
382072
|
+
listByActor(actor) {
|
|
382073
|
+
return this.records.filter((r) => r.actor === actor);
|
|
382074
|
+
}
|
|
382075
|
+
/** Get records in a time range. */
|
|
382076
|
+
listInRange(fromAt, toAt) {
|
|
382077
|
+
return this.records.filter((r) => r.at >= fromAt && r.at <= toAt);
|
|
382078
|
+
}
|
|
382079
|
+
/** Verify the hash chain integrity. Returns { valid: true } or { valid: false, brokenAt: seq }. */
|
|
382080
|
+
verify() {
|
|
382081
|
+
if (this.records.length === 0) return { valid: true };
|
|
382082
|
+
for (let i = 0; i < this.records.length; i++) {
|
|
382083
|
+
const record2 = this.records[i];
|
|
382084
|
+
if (record2.seq !== i + 1) {
|
|
382085
|
+
return { valid: false, brokenAt: record2.seq, detail: `seq mismatch: expected ${i + 1}, got ${record2.seq}` };
|
|
382086
|
+
}
|
|
382087
|
+
const expectedContentHash = computeRecordHash(
|
|
382088
|
+
record2.kind,
|
|
382089
|
+
record2.actor,
|
|
382090
|
+
record2.target,
|
|
382091
|
+
record2.summary,
|
|
382092
|
+
record2.detail,
|
|
382093
|
+
record2.at,
|
|
382094
|
+
record2.seq
|
|
382095
|
+
);
|
|
382096
|
+
const expectedHash = createHash("sha256").update(expectedContentHash + record2.prevHash).digest("hex");
|
|
382097
|
+
if (record2.hash !== expectedHash) {
|
|
382098
|
+
return { valid: false, brokenAt: record2.seq, detail: `hash mismatch at seq ${record2.seq}` };
|
|
382099
|
+
}
|
|
382100
|
+
const expectedPrevHash = i === 0 ? GENESIS_HASH : this.records[i - 1].hash;
|
|
382101
|
+
if (record2.prevHash !== expectedPrevHash) {
|
|
382102
|
+
return { valid: false, brokenAt: record2.seq, detail: `prevHash mismatch at seq ${record2.seq}` };
|
|
382103
|
+
}
|
|
382104
|
+
}
|
|
382105
|
+
return { valid: true };
|
|
382106
|
+
}
|
|
382107
|
+
/** Get the current chain tip (the latest record's hash). */
|
|
382108
|
+
tip() {
|
|
382109
|
+
if (this.records.length === 0) return GENESIS_HASH;
|
|
382110
|
+
return this.records[this.records.length - 1].hash;
|
|
382111
|
+
}
|
|
382112
|
+
/** Get the total number of records. */
|
|
382113
|
+
size() {
|
|
382114
|
+
return this.records.length;
|
|
382115
|
+
}
|
|
382116
|
+
/** Export all records as JSON (for persistence). */
|
|
382117
|
+
export() {
|
|
382118
|
+
return JSON.stringify(this.records, null, 2);
|
|
382119
|
+
}
|
|
382120
|
+
/** Import records from JSON (for recovery). Verifies the chain on import. */
|
|
382121
|
+
import(json3) {
|
|
382122
|
+
const parsed = JSON.parse(json3);
|
|
382123
|
+
if (!Array.isArray(parsed)) {
|
|
382124
|
+
return { imported: 0, valid: false, detail: "not an array" };
|
|
382125
|
+
}
|
|
382126
|
+
const tempLedger = new _AuditLedger({ hashFn: this.hashFn, now: this.now });
|
|
382127
|
+
tempLedger.records = parsed;
|
|
382128
|
+
const result = tempLedger.verify();
|
|
382129
|
+
if (!result.valid) {
|
|
382130
|
+
return { imported: 0, valid: false, detail: result.detail };
|
|
382131
|
+
}
|
|
382132
|
+
this.records = parsed;
|
|
382133
|
+
return { imported: parsed.length, valid: true };
|
|
382134
|
+
}
|
|
382135
|
+
};
|
|
382136
|
+
|
|
382137
|
+
// ../../packages/backend/src/services/audit/evidenceSealer.ts
|
|
382138
|
+
import { createHash as createHash2 } from "crypto";
|
|
382139
|
+
function computeMerkleRoot(hashes) {
|
|
382140
|
+
if (hashes.length === 0) return "0".repeat(64);
|
|
382141
|
+
if (hashes.length === 1) return hashes[0];
|
|
382142
|
+
const nextLevel = [];
|
|
382143
|
+
for (let i = 0; i < hashes.length; i += 2) {
|
|
382144
|
+
const left = hashes[i];
|
|
382145
|
+
const right = i + 1 < hashes.length ? hashes[i + 1] : left;
|
|
382146
|
+
nextLevel.push(createHash2("sha256").update(left + right).digest("hex"));
|
|
382147
|
+
}
|
|
382148
|
+
return computeMerkleRoot(nextLevel);
|
|
382149
|
+
}
|
|
382150
|
+
function verifyMerkleRoot(hashes, expectedRoot) {
|
|
382151
|
+
return computeMerkleRoot(hashes) === expectedRoot;
|
|
382152
|
+
}
|
|
382153
|
+
var EvidenceSealer = class {
|
|
382154
|
+
bundles = [];
|
|
382155
|
+
now;
|
|
382156
|
+
constructor(deps = {}) {
|
|
382157
|
+
this.now = deps.now ?? (() => Date.now());
|
|
382158
|
+
}
|
|
382159
|
+
/** Seal the current state of the audit ledger into an evidence bundle. */
|
|
382160
|
+
seal(ledger, sealId) {
|
|
382161
|
+
const records = ledger.list();
|
|
382162
|
+
const recordHashes = records.map((r) => r.hash);
|
|
382163
|
+
const merkleRoot = computeMerkleRoot(recordHashes);
|
|
382164
|
+
const bundle = {
|
|
382165
|
+
merkleRoot,
|
|
382166
|
+
recordCount: records.length,
|
|
382167
|
+
fromAt: records.length > 0 ? records[0].at : 0,
|
|
382168
|
+
toAt: records.length > 0 ? records[records.length - 1].at : 0,
|
|
382169
|
+
tipHash: ledger.tip(),
|
|
382170
|
+
recordHashes,
|
|
382171
|
+
sealedAt: this.now(),
|
|
382172
|
+
sealId: sealId ?? `seal-${Date.now().toString(36)}`
|
|
382173
|
+
};
|
|
382174
|
+
this.bundles.push(bundle);
|
|
382175
|
+
return bundle;
|
|
382176
|
+
}
|
|
382177
|
+
/** Verify a sealed bundle against a set of records. */
|
|
382178
|
+
verify(bundle, records) {
|
|
382179
|
+
if (records.length !== bundle.recordCount) {
|
|
382180
|
+
return { valid: false, detail: `record count mismatch: expected ${bundle.recordCount}, got ${records.length}` };
|
|
382181
|
+
}
|
|
382182
|
+
if (records.length > 0 && records[records.length - 1].hash !== bundle.tipHash) {
|
|
382183
|
+
return { valid: false, detail: `tip hash mismatch` };
|
|
382184
|
+
}
|
|
382185
|
+
const hashes = records.map((r) => r.hash);
|
|
382186
|
+
if (!verifyMerkleRoot(hashes, bundle.merkleRoot)) {
|
|
382187
|
+
return { valid: false, detail: `Merkle root mismatch` };
|
|
382188
|
+
}
|
|
382189
|
+
return { valid: true };
|
|
382190
|
+
}
|
|
382191
|
+
/** Get all sealed bundles. */
|
|
382192
|
+
listBundles() {
|
|
382193
|
+
return [...this.bundles];
|
|
382194
|
+
}
|
|
382195
|
+
/** Get the latest sealed bundle. */
|
|
382196
|
+
latest() {
|
|
382197
|
+
return this.bundles.length > 0 ? this.bundles[this.bundles.length - 1] : void 0;
|
|
382198
|
+
}
|
|
382199
|
+
};
|
|
382200
|
+
|
|
381875
382201
|
// ../../packages/backend/src/services/observability.ts
|
|
381876
382202
|
function createObservability(deps) {
|
|
381877
382203
|
const log = deps.onLog ?? (() => {
|
|
@@ -381945,6 +382271,11 @@ function createObservability(deps) {
|
|
|
381945
382271
|
runAgent: deps.runAgentForEval ?? (async (_prompt) => ({ answer: "", toolsCalled: [] })),
|
|
381946
382272
|
isCommandBlocked: () => false
|
|
381947
382273
|
});
|
|
382274
|
+
const aperfService = new AperfService({
|
|
382275
|
+
execSsh: async () => ""
|
|
382276
|
+
});
|
|
382277
|
+
const auditLedger = new AuditLedger({});
|
|
382278
|
+
const evidenceSealer = new EvidenceSealer({});
|
|
381948
382279
|
const pluginScanRoot = (process.env.GYBACKEND_DATA_DIR ?? "./.gybackend-data") + "/plugins";
|
|
381949
382280
|
const pluginRegistry = new PluginRegistry({
|
|
381950
382281
|
scanRoots: [pluginScanRoot, "./plugins"],
|
|
@@ -381996,6 +382327,8 @@ function createObservability(deps) {
|
|
|
381996
382327
|
behaviorLedger,
|
|
381997
382328
|
dagu: { parseDaguYaml, parseDaguWorkflow, daguExecutionPlan },
|
|
381998
382329
|
notify: { slackChannel, teamsChannel, smtpChannel, telegramChannel },
|
|
382330
|
+
aperf: { service: aperfService, toMetricPoint: aperfSummaryToMetricPoint },
|
|
382331
|
+
audit: { ledger: auditLedger, sealer: evidenceSealer },
|
|
381999
382332
|
pluginRegistry
|
|
382000
382333
|
};
|
|
382001
382334
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rterm-backend",
|
|
3
|
-
"version": "2.
|
|
4
|
-
"description": "RTerm headless backend
|
|
3
|
+
"version": "2.7.1",
|
|
4
|
+
"description": "RTerm headless backend — run RTerm-as-a-service (AI agent, SSH/WinRM/Serial/local terminals, fleet orchestration, advanced automation with event-driven triggers + NATS event mesh, scheduled automation, SRE observability, Netdata integration, AWS APerf performance deep-dive, plugin system) and drive it over a WebSocket JSON-RPC gateway. No desktop UI required.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"bin": {
|
|
@@ -52,7 +52,12 @@
|
|
|
52
52
|
"websocket",
|
|
53
53
|
"rpc",
|
|
54
54
|
"rundeck",
|
|
55
|
-
"ansible"
|
|
55
|
+
"ansible",
|
|
56
|
+
"sre",
|
|
57
|
+
"observability",
|
|
58
|
+
"netdata",
|
|
59
|
+
"aperf",
|
|
60
|
+
"monitoring"
|
|
56
61
|
],
|
|
57
62
|
"author": "Hyperspace Technologies <rterm@hyperspace.ng>",
|
|
58
63
|
"homepage": "https://github.com/DrOlu/RTerm",
|