@opentrust/dashboard 7.3.31 → 7.3.33

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,10 +1,9 @@
1
1
  import { Router } from "express";
2
- import { db, hostQueries, hostCommandQueries, agentQueries, settingsQueries } from "@opentrust/db";
3
- import { ensureSystemApiKey } from "./settings.js";
2
+ import { db, hostQueries, hostCommandQueries, agentQueries } from "@opentrust/db";
3
+ import { renderOpenclawConfig } from "./settings.js";
4
4
  const hosts = hostQueries(db);
5
5
  const cmds = hostCommandQueries(db);
6
6
  const agentsDb = agentQueries(db);
7
- const settingsDb = settingsQueries(db);
8
7
  export const hostsRouter = Router();
9
8
  const VALID_COMMAND_TYPES = [
10
9
  "start_service",
@@ -89,33 +88,11 @@ hostsRouter.post("/commands", async (req, res, next) => {
89
88
  }
90
89
  let finalPayload = payload ?? {};
91
90
  if (type === "install_openclaw") {
92
- const raw = await settingsDb.get("openclaw_config");
93
- if (!raw) {
91
+ const rendered = await renderOpenclawConfig();
92
+ if (!rendered) {
94
93
  res.status(400).json({ success: false, error: "No OpenClaw config template. Configure it in Settings first." });
95
94
  return;
96
95
  }
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
96
  finalPayload = { ...finalPayload, config: rendered };
120
97
  }
121
98
  await cmds.create({ hostId, type, payload: finalPayload, tenantId });
@@ -109,36 +109,64 @@ settingsRouter.put("/openclaw-config", async (req, res, next) => {
109
109
  next(err);
110
110
  }
111
111
  });
112
+ /**
113
+ * Render a full openclaw.json from the stored template, injecting runtime fields:
114
+ * meta, wizard, gateway.auth.token, plugins.entries.opentrust-guard
115
+ */
116
+ export async function renderOpenclawConfig() {
117
+ const raw = await settings.get("openclaw_config");
118
+ if (!raw)
119
+ return null;
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 now = new Date().toISOString();
125
+ const rendered = {
126
+ meta: {
127
+ lastTouchedVersion: "2026.3.1",
128
+ lastTouchedAt: now,
129
+ },
130
+ wizard: {
131
+ lastRunAt: now,
132
+ lastRunVersion: "2026.3.1",
133
+ lastRunCommand: "opentrust-install",
134
+ lastRunMode: "remote",
135
+ },
136
+ ...template,
137
+ };
138
+ if (!rendered.gateway)
139
+ rendered.gateway = {};
140
+ if (!rendered.gateway.auth)
141
+ rendered.gateway.auth = { mode: "token" };
142
+ if (!rendered.gateway.auth.token) {
143
+ rendered.gateway.auth.token = randomBytes(24).toString("hex");
144
+ }
145
+ rendered.plugins = {
146
+ ...template.plugins,
147
+ entries: {
148
+ ...template.plugins?.entries,
149
+ "opentrust-guard": {
150
+ enabled: true,
151
+ config: {
152
+ coreUrl,
153
+ dashboardUrl,
154
+ apiKey,
155
+ ...(template.plugins?.entries?.["opentrust-guard"]?.config ?? {}),
156
+ },
157
+ },
158
+ },
159
+ };
160
+ return rendered;
161
+ }
112
162
  // GET /api/settings/openclaw-config/rendered — full openclaw.json with secrets injected
113
163
  settingsRouter.get("/openclaw-config/rendered", async (_req, res, next) => {
114
164
  try {
115
- const raw = await settings.get("openclaw_config");
116
- if (!raw) {
165
+ const rendered = await renderOpenclawConfig();
166
+ if (!rendered) {
117
167
  res.status(404).json({ success: false, error: "No OpenClaw config template configured. Go to Settings to set one up." });
118
168
  return;
119
169
  }
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
170
  res.json({ success: true, data: rendered });
143
171
  }
144
172
  catch (err) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opentrust/dashboard",
3
- "version": "7.3.31",
3
+ "version": "7.3.33",
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/shared": "7.3.31",
23
- "@opentrust/db": "7.3.31"
22
+ "@opentrust/db": "7.3.33",
23
+ "@opentrust/shared": "7.3.33"
24
24
  },
25
25
  "devDependencies": {
26
26
  "@types/cors": "^2.8.17",