rterm-backend 2.7.7 → 2.7.8
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/bin/gybackend.js +88 -0
- package/package.json +1 -1
package/bin/gybackend.js
CHANGED
|
@@ -382391,6 +382391,83 @@ function parsePolicyYaml(yaml) {
|
|
|
382391
382391
|
return doc;
|
|
382392
382392
|
}
|
|
382393
382393
|
|
|
382394
|
+
// ../../packages/backend/src/services/review/reviewService.ts
|
|
382395
|
+
var ReviewService = class {
|
|
382396
|
+
constructor(deps) {
|
|
382397
|
+
this.deps = deps;
|
|
382398
|
+
this.reviewerId = deps.reviewerId ?? "review-model";
|
|
382399
|
+
this.reviewMode = deps.reviewMode ?? "strict";
|
|
382400
|
+
}
|
|
382401
|
+
reviewerId;
|
|
382402
|
+
reviewMode;
|
|
382403
|
+
/** Review an action. Returns the review result. */
|
|
382404
|
+
async review(action) {
|
|
382405
|
+
if (this.reviewMode === "auto-approve" && this.isLowRisk(action)) {
|
|
382406
|
+
return {
|
|
382407
|
+
verdict: "approved",
|
|
382408
|
+
issues: [],
|
|
382409
|
+
confidence: 1,
|
|
382410
|
+
reasoning: "auto-approved (low-risk action)",
|
|
382411
|
+
reviewerId: this.reviewerId,
|
|
382412
|
+
skipped: true
|
|
382413
|
+
};
|
|
382414
|
+
}
|
|
382415
|
+
const prompt = this.buildReviewPrompt(action);
|
|
382416
|
+
const result = await this.deps.runReviewModel(prompt);
|
|
382417
|
+
let verdict = result.verdict;
|
|
382418
|
+
if (this.reviewMode === "advisory" && verdict === "escalate") {
|
|
382419
|
+
verdict = "needs_revision";
|
|
382420
|
+
}
|
|
382421
|
+
return {
|
|
382422
|
+
verdict,
|
|
382423
|
+
issues: result.issues ?? [],
|
|
382424
|
+
confidence: result.confidence ?? 0.5,
|
|
382425
|
+
reasoning: result.reasoning ?? "",
|
|
382426
|
+
reviewerId: this.reviewerId,
|
|
382427
|
+
skipped: false
|
|
382428
|
+
};
|
|
382429
|
+
}
|
|
382430
|
+
/** Check if an action is low-risk (for auto-approve mode). */
|
|
382431
|
+
isLowRisk(action) {
|
|
382432
|
+
const type2 = action.type.toLowerCase();
|
|
382433
|
+
const target = (action.target ?? "").toLowerCase();
|
|
382434
|
+
if (["read", "status", "list", "show", "get", "describe", "check"].some((w) => type2.includes(w))) return true;
|
|
382435
|
+
if (target.includes("dev") || target.includes("staging") || target.includes("test")) return true;
|
|
382436
|
+
return false;
|
|
382437
|
+
}
|
|
382438
|
+
/** Build the review prompt for the review model. */
|
|
382439
|
+
buildReviewPrompt(action) {
|
|
382440
|
+
return `You are a review model. Independently verify the following action for correctness, completeness, safety, compliance, and accuracy.
|
|
382441
|
+
|
|
382442
|
+
Action type: ${action.type}
|
|
382443
|
+
Target: ${action.target ?? "unknown"}
|
|
382444
|
+
Command: ${action.command ?? "none"}
|
|
382445
|
+
User request: ${action.userRequest ?? "unknown"}
|
|
382446
|
+
|
|
382447
|
+
Evaluate the action on 5 dimensions:
|
|
382448
|
+
1. Correctness: Is this the right action for the user's intent?
|
|
382449
|
+
2. Completeness: Does this action fully address the user's request?
|
|
382450
|
+
3. Safety: Is this action safe (not destructive, not harmful)?
|
|
382451
|
+
4. Compliance: Does this action comply with policy?
|
|
382452
|
+
5. Accuracy: Is the information in this action accurate?
|
|
382453
|
+
|
|
382454
|
+
Return your verdict: approved, needs_revision, or escalate, with issues and reasoning.`;
|
|
382455
|
+
}
|
|
382456
|
+
};
|
|
382457
|
+
function createSkippedReviewResult() {
|
|
382458
|
+
return {
|
|
382459
|
+
verdict: "approved",
|
|
382460
|
+
issues: [],
|
|
382461
|
+
confidence: 1,
|
|
382462
|
+
reasoning: "review skipped (no reviewModelId specified)",
|
|
382463
|
+
reviewerId: "none",
|
|
382464
|
+
skipped: true
|
|
382465
|
+
};
|
|
382466
|
+
}
|
|
382467
|
+
function shouldSkipReview(reviewModelId) {
|
|
382468
|
+
return !reviewModelId || reviewModelId.trim() === "";
|
|
382469
|
+
}
|
|
382470
|
+
|
|
382394
382471
|
// ../../packages/backend/src/services/observability.ts
|
|
382395
382472
|
function createObservability(deps) {
|
|
382396
382473
|
const log = deps.onLog ?? (() => {
|
|
@@ -382504,6 +382581,16 @@ function createObservability(deps) {
|
|
|
382504
382581
|
});
|
|
382505
382582
|
void policyEngine.load().catch(() => {
|
|
382506
382583
|
});
|
|
382584
|
+
const reviewService = new ReviewService({
|
|
382585
|
+
runReviewModel: deps.runReviewModel ?? (async (_prompt) => ({
|
|
382586
|
+
verdict: "approved",
|
|
382587
|
+
issues: [],
|
|
382588
|
+
reasoning: "no review model configured",
|
|
382589
|
+
confidence: 1
|
|
382590
|
+
})),
|
|
382591
|
+
reviewerId: deps.reviewerId ?? "review-model",
|
|
382592
|
+
reviewMode: deps.reviewMode ?? "strict"
|
|
382593
|
+
});
|
|
382507
382594
|
const pluginScanRoot = (process.env.GYBACKEND_DATA_DIR ?? "./.gybackend-data") + "/plugins";
|
|
382508
382595
|
const bundlePluginRoot = new URL("../../plugins/", import.meta.url).pathname;
|
|
382509
382596
|
const scanRoots = [pluginScanRoot, "./plugins"];
|
|
@@ -382578,6 +382665,7 @@ function createObservability(deps) {
|
|
|
382578
382665
|
audit: { ledger: auditLedger, sealer: evidenceSealer },
|
|
382579
382666
|
monitorStatus,
|
|
382580
382667
|
governance: { policyEngine },
|
|
382668
|
+
review: { service: reviewService, shouldSkipReview, createSkippedReviewResult },
|
|
382581
382669
|
pluginRegistry
|
|
382582
382670
|
};
|
|
382583
382671
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rterm-backend",
|
|
3
|
-
"version": "2.7.
|
|
3
|
+
"version": "2.7.8",
|
|
4
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",
|