@nordbyte/nordrelay 0.4.1 → 0.5.0
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/.env.example +155 -64
- package/README.md +69 -59
- package/dist/access-control.js +124 -115
- package/dist/agent-updates.js +19 -1
- package/dist/bot-rendering.js +838 -0
- package/dist/bot.js +87 -1288
- package/dist/channel-runtime.js +89 -0
- package/dist/config-metadata.js +238 -0
- package/dist/config.js +0 -58
- package/dist/index.js +8 -0
- package/dist/relay-runtime.js +36 -12
- package/dist/settings-service.js +2 -117
- package/dist/telegram-access-commands.js +123 -0
- package/dist/telegram-access-middleware.js +129 -0
- package/dist/telegram-channel-runtime.js +132 -0
- package/dist/telegram-command-menu.js +54 -0
- package/dist/telegram-output.js +216 -0
- package/dist/telegram-update-commands.js +88 -0
- package/dist/user-management.js +708 -0
- package/dist/web-api-contract.js +56 -0
- package/dist/web-dashboard-assets.js +33 -2
- package/dist/web-dashboard-ui.js +14 -14
- package/dist/web-dashboard.js +595 -133
- package/dist/webui-assets/dashboard.css +919 -0
- package/dist/webui-assets/dashboard.js +1611 -0
- package/package.json +6 -3
- package/plugins/nordrelay/.codex-plugin/plugin.json +1 -1
- package/plugins/nordrelay/commands/remote.md +1 -1
- package/plugins/nordrelay/scripts/nordrelay.mjs +227 -78
- package/plugins/nordrelay/skills/telegram-remote/SKILL.md +1 -1
- package/dist/web-dashboard-client.js +0 -275
- package/dist/web-dashboard-style.js +0 -9
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
export const WEB_API_ROUTES = [
|
|
2
|
+
...exact(["/api/bootstrap", "/api/health", "/api/snapshot", "/api/tasks", "/api/progress"], "inspect"),
|
|
3
|
+
...exact(["/api/version", "/api/adapters/health"], "inspect"),
|
|
4
|
+
...exact(["/api/diagnostics"], "diagnostics.read"),
|
|
5
|
+
...prefix(["/api/users", "/api/groups", "/api/telegram-chats"], readWrite("users.read", "users.write")),
|
|
6
|
+
...exact(["/api/permissions"], "users.read"),
|
|
7
|
+
...exact(["/api/audit"], "audit.read"),
|
|
8
|
+
...exact(["/api/control-options"], "settings.read"),
|
|
9
|
+
...exact(["/api/settings"], readWrite("settings.read", "settings.write")),
|
|
10
|
+
...exact(["/api/update"], "updates.run"),
|
|
11
|
+
...prefix(["/api/agent-update"], "updates.run"),
|
|
12
|
+
...exact(["/api/logs"], "logs.read"),
|
|
13
|
+
...exact(["/api/logs/clear"], "logs.clear"),
|
|
14
|
+
...exact(["/api/runtime/restart"], "system.restart"),
|
|
15
|
+
...prefix(["/api/sessions"], readWrite("sessions.read", "sessions.write")),
|
|
16
|
+
...exact(["/api/agent", "/api/sync", "/api/handback", "/api/locks"], readWrite("sessions.read", "sessions.write")),
|
|
17
|
+
...prefix(["/api/auth/"], readWrite("inspect", "auth.manage")),
|
|
18
|
+
...prefix(["/api/models", "/api/session/"], readWrite("settings.read", "settings.write")),
|
|
19
|
+
...exact(["/api/queue"], readWrite("queue.read", "queue.write")),
|
|
20
|
+
...exact(["/api/prompt", "/api/prompt/upload", "/api/retry"], readWrite("inspect", "prompt.send")),
|
|
21
|
+
...exact(["/api/abort", "/api/stop"], "prompt.abort"),
|
|
22
|
+
...prefix(["/api/chat"], readWrite("sessions.read", "sessions.write")),
|
|
23
|
+
...prefix(["/api/activity"], "sessions.read"),
|
|
24
|
+
...prefix(["/api/artifacts"], readWrite("files.read", "files.write")),
|
|
25
|
+
];
|
|
26
|
+
export function permissionForWebRequestFromContract(method, pathname) {
|
|
27
|
+
const verb = normalizeMethod(method);
|
|
28
|
+
const rule = WEB_API_ROUTES.find((candidate) => (candidate.path !== undefined && candidate.path === pathname) ||
|
|
29
|
+
(candidate.prefix !== undefined && pathname.startsWith(candidate.prefix)));
|
|
30
|
+
if (!rule) {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
return resolvePermission(rule.permissions, verb);
|
|
34
|
+
}
|
|
35
|
+
function exact(paths, permissions) {
|
|
36
|
+
return paths.map((path) => ({ path, permissions }));
|
|
37
|
+
}
|
|
38
|
+
function prefix(prefixes, permissions) {
|
|
39
|
+
return prefixes.map((pathPrefix) => ({ prefix: pathPrefix, permissions }));
|
|
40
|
+
}
|
|
41
|
+
function readWrite(read, write) {
|
|
42
|
+
return { read, write };
|
|
43
|
+
}
|
|
44
|
+
function resolvePermission(rule, verb) {
|
|
45
|
+
if (typeof rule === "string") {
|
|
46
|
+
return rule;
|
|
47
|
+
}
|
|
48
|
+
return verb === "GET" ? rule.read : rule.write;
|
|
49
|
+
}
|
|
50
|
+
function normalizeMethod(method) {
|
|
51
|
+
const upper = (method ?? "GET").toUpperCase();
|
|
52
|
+
if (upper === "GET" || upper === "POST" || upper === "PATCH" || upper === "PUT" || upper === "DELETE") {
|
|
53
|
+
return upper;
|
|
54
|
+
}
|
|
55
|
+
return "GET";
|
|
56
|
+
}
|
|
@@ -1,2 +1,33 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
const moduleDir = path.dirname(fileURLToPath(import.meta.url));
|
|
5
|
+
const clientSources = [
|
|
6
|
+
"client/core/runtime.js",
|
|
7
|
+
"client/overview.js",
|
|
8
|
+
"client/events.js",
|
|
9
|
+
"client/workflows.js",
|
|
10
|
+
"client/admin.js",
|
|
11
|
+
];
|
|
12
|
+
const styleSources = [
|
|
13
|
+
"styles/theme.css",
|
|
14
|
+
"styles/components.css",
|
|
15
|
+
"styles/layout.css",
|
|
16
|
+
"styles/responsive.css",
|
|
17
|
+
];
|
|
18
|
+
export function dashboardJs() {
|
|
19
|
+
return readDashboardAsset("dashboard.js", clientSources);
|
|
20
|
+
}
|
|
21
|
+
export function dashboardCss() {
|
|
22
|
+
return readDashboardAsset("dashboard.css", styleSources);
|
|
23
|
+
}
|
|
24
|
+
function readDashboardAsset(assetName, sourceFiles) {
|
|
25
|
+
const builtAsset = path.join(moduleDir, "webui-assets", assetName);
|
|
26
|
+
if (existsSync(builtAsset)) {
|
|
27
|
+
return readFileSync(builtAsset, "utf8");
|
|
28
|
+
}
|
|
29
|
+
const sourceDir = path.join(moduleDir, "webui");
|
|
30
|
+
return sourceFiles
|
|
31
|
+
.map((file) => readFileSync(path.join(sourceDir, file), "utf8"))
|
|
32
|
+
.join("\n");
|
|
33
|
+
}
|
package/dist/web-dashboard-ui.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
export const DASHBOARD_PAGES = [
|
|
2
|
-
{ id: "overview", label: "Overview" },
|
|
3
|
-
{ id: "chat", label: "Chat" },
|
|
4
|
-
{ id: "sessions", label: "Sessions" },
|
|
5
|
-
{ id: "queue", label: "Queue" },
|
|
6
|
-
{ id: "tasks", label: "Tasks" },
|
|
7
|
-
{ id: "activity", label: "Activity" },
|
|
8
|
-
{ id: "artifacts", label: "Artifacts" },
|
|
9
|
-
{ id: "adapters", label: "Adapters" },
|
|
10
|
-
{ id: "access", label: "
|
|
11
|
-
{ id: "version", label: "Version" },
|
|
12
|
-
{ id: "settings", label: "Settings" },
|
|
13
|
-
{ id: "logs", label: "Logs" },
|
|
14
|
-
{ id: "diagnostics", label: "Diagnostics" },
|
|
2
|
+
{ id: "overview", label: "Overview", permission: "inspect" },
|
|
3
|
+
{ id: "chat", label: "Chat", permission: "sessions.read" },
|
|
4
|
+
{ id: "sessions", label: "Sessions", permission: "sessions.read" },
|
|
5
|
+
{ id: "queue", label: "Queue", permission: "queue.read" },
|
|
6
|
+
{ id: "tasks", label: "Tasks", permission: "inspect" },
|
|
7
|
+
{ id: "activity", label: "Activity", permission: "sessions.read" },
|
|
8
|
+
{ id: "artifacts", label: "Artifacts", permission: "files.read" },
|
|
9
|
+
{ id: "adapters", label: "Adapters", permission: "inspect" },
|
|
10
|
+
{ id: "access", label: "Users", permission: "users.read" },
|
|
11
|
+
{ id: "version", label: "Version", permission: "inspect" },
|
|
12
|
+
{ id: "settings", label: "Settings", permission: "settings.read" },
|
|
13
|
+
{ id: "logs", label: "Logs", permission: "logs.read" },
|
|
14
|
+
{ id: "diagnostics", label: "Diagnostics", permission: "diagnostics.read" },
|
|
15
15
|
];
|
|
16
16
|
export function renderDashboardNav(activePage = "overview") {
|
|
17
|
-
return DASHBOARD_PAGES.map((page) => `<button data-page="${page.id}"${page.id === activePage ? ' class="active"' : ""}>${page.label}</button>`).join("\n ");
|
|
17
|
+
return DASHBOARD_PAGES.map((page) => `<button data-page="${page.id}" data-permission="${page.permission}"${page.id === activePage ? ' class="active"' : ""}>${page.label}</button>`).join("\n ");
|
|
18
18
|
}
|