@opentrust/dashboard 7.3.30 → 7.3.31

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.
@@ -1,8 +1,10 @@
1
1
  import { Router } from "express";
2
- import { db, hostQueries, hostCommandQueries, agentQueries } from "@opentrust/db";
2
+ import { db, hostQueries, hostCommandQueries, agentQueries, settingsQueries } from "@opentrust/db";
3
+ import { ensureSystemApiKey } from "./settings.js";
3
4
  const hosts = hostQueries(db);
4
5
  const cmds = hostCommandQueries(db);
5
6
  const agentsDb = agentQueries(db);
7
+ const settingsDb = settingsQueries(db);
6
8
  export const hostsRouter = Router();
7
9
  const VALID_COMMAND_TYPES = [
8
10
  "start_service",
@@ -19,6 +21,7 @@ const VALID_COMMAND_TYPES = [
19
21
  "update_config",
20
22
  "install_guards",
21
23
  "upgrade_guards",
24
+ "install_openclaw",
22
25
  ];
23
26
  const OFFLINE_THRESHOLD_MS = 90_000;
24
27
  function withOnlineStatus(host) {
@@ -84,7 +87,38 @@ hostsRouter.post("/commands", async (req, res, next) => {
84
87
  });
85
88
  return;
86
89
  }
87
- await cmds.create({ hostId, type, payload, tenantId });
90
+ let finalPayload = payload ?? {};
91
+ if (type === "install_openclaw") {
92
+ const raw = await settingsDb.get("openclaw_config");
93
+ if (!raw) {
94
+ res.status(400).json({ success: false, error: "No OpenClaw config template. Configure it in Settings first." });
95
+ return;
96
+ }
97
+ const template = JSON.parse(raw);
98
+ const apiKey = await ensureSystemApiKey();
99
+ const dashboardUrl = (await settingsDb.get("og_dashboard_url")) || "http://localhost:53667";
100
+ const coreUrl = (await settingsDb.get("og_core_url")) || "http://localhost:53666";
101
+ const rendered = {
102
+ ...template,
103
+ plugins: {
104
+ ...template.plugins,
105
+ entries: {
106
+ ...template.plugins?.entries,
107
+ "opentrust-guard": {
108
+ enabled: true,
109
+ config: {
110
+ apiKey,
111
+ coreUrl,
112
+ dashboardUrl,
113
+ ...(template.plugins?.entries?.["opentrust-guard"]?.config ?? {}),
114
+ },
115
+ },
116
+ },
117
+ },
118
+ };
119
+ finalPayload = { ...finalPayload, config: rendered };
120
+ }
121
+ await cmds.create({ hostId, type, payload: finalPayload, tenantId });
88
122
  res.status(201).json({ success: true });
89
123
  }
90
124
  catch (err) {
@@ -83,6 +83,68 @@ settingsRouter.post("/generate-key", async (_req, res, next) => {
83
83
  next(err);
84
84
  }
85
85
  });
86
+ // GET /api/settings/openclaw-config
87
+ settingsRouter.get("/openclaw-config", async (_req, res, next) => {
88
+ try {
89
+ const raw = await settings.get("openclaw_config");
90
+ const config = raw ? JSON.parse(raw) : null;
91
+ res.json({ success: true, data: config });
92
+ }
93
+ catch (err) {
94
+ next(err);
95
+ }
96
+ });
97
+ // PUT /api/settings/openclaw-config
98
+ settingsRouter.put("/openclaw-config", async (req, res, next) => {
99
+ try {
100
+ const config = req.body;
101
+ if (!config || typeof config !== "object") {
102
+ res.status(400).json({ success: false, error: "Body must be a JSON object" });
103
+ return;
104
+ }
105
+ await settings.set("openclaw_config", JSON.stringify(config));
106
+ res.json({ success: true });
107
+ }
108
+ catch (err) {
109
+ next(err);
110
+ }
111
+ });
112
+ // GET /api/settings/openclaw-config/rendered — full openclaw.json with secrets injected
113
+ settingsRouter.get("/openclaw-config/rendered", async (_req, res, next) => {
114
+ try {
115
+ const raw = await settings.get("openclaw_config");
116
+ if (!raw) {
117
+ res.status(404).json({ success: false, error: "No OpenClaw config template configured. Go to Settings to set one up." });
118
+ return;
119
+ }
120
+ const template = JSON.parse(raw);
121
+ const apiKey = await ensureSystemApiKey();
122
+ const dashboardUrl = await settings.get("og_dashboard_url") || "http://localhost:53667";
123
+ const coreUrl = await settings.get("og_core_url") || "http://localhost:53666";
124
+ const rendered = {
125
+ ...template,
126
+ plugins: {
127
+ ...template.plugins,
128
+ entries: {
129
+ ...template.plugins?.entries,
130
+ "opentrust-guard": {
131
+ enabled: true,
132
+ config: {
133
+ apiKey,
134
+ coreUrl,
135
+ dashboardUrl,
136
+ ...(template.plugins?.entries?.["opentrust-guard"]?.config ?? {}),
137
+ },
138
+ },
139
+ },
140
+ },
141
+ };
142
+ res.json({ success: true, data: rendered });
143
+ }
144
+ catch (err) {
145
+ next(err);
146
+ }
147
+ });
86
148
  // POST /api/settings/test-connection
87
149
  settingsRouter.post("/test-connection", async (_req, res, next) => {
88
150
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opentrust/dashboard",
3
- "version": "7.3.30",
3
+ "version": "7.3.31",
4
4
  "type": "module",
5
5
  "description": "OpenTrust Dashboard — management panel for AI Agent security (API + embedded web)",
6
6
  "main": "dist/index.js",
@@ -19,8 +19,8 @@
19
19
  "morgan": "^1.10.0",
20
20
  "nodemailer": "^8.0.1",
21
21
  "zod": "^3.23.0",
22
- "@opentrust/db": "7.3.30",
23
- "@opentrust/shared": "7.3.30"
22
+ "@opentrust/shared": "7.3.31",
23
+ "@opentrust/db": "7.3.31"
24
24
  },
25
25
  "devDependencies": {
26
26
  "@types/cors": "^2.8.17",