@nordbyte/nordrelay 0.8.2 → 0.8.3

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.
Files changed (39) hide show
  1. package/README.md +4 -0
  2. package/dist/access/audit-log.js +30 -13
  3. package/dist/channels/discord/discord-bot.js +12 -27
  4. package/dist/channels/shared/channel-bridge-controller.js +1 -1
  5. package/dist/channels/shared/channel-prompt-queue.js +37 -0
  6. package/dist/channels/shared/channel-turn-service.js +23 -9
  7. package/dist/channels/slack/slack-bot.js +12 -15
  8. package/dist/channels/telegram/bot.js +18 -4
  9. package/dist/core/pagination.js +22 -0
  10. package/dist/peers/peer-store.js +16 -0
  11. package/dist/peers/peer-types.js +19 -0
  12. package/dist/peers/peer-web-proxy-contract.js +2 -0
  13. package/dist/runtime/relay-external-activity-monitor.js +15 -0
  14. package/dist/runtime/relay-queue-service.js +1 -0
  15. package/dist/runtime/relay-runtime-dashboard.js +3 -0
  16. package/dist/runtime/relay-runtime-helpers.js +3 -0
  17. package/dist/runtime/relay-runtime-prompt-queue-artifacts.js +14 -10
  18. package/dist/runtime/relay-runtime-sessions.js +8 -0
  19. package/dist/runtime/relay-runtime-trace.js +92 -0
  20. package/dist/runtime/relay-runtime-updates-jobs.js +11 -5
  21. package/dist/runtime/relay-runtime.js +16 -6
  22. package/dist/state/prompt-store.js +13 -1
  23. package/dist/web/web-api-contract.js +2 -0
  24. package/dist/web/web-dashboard-access-routes.js +15 -12
  25. package/dist/web/web-dashboard-artifact-routes.js +6 -2
  26. package/dist/web/web-dashboard-assets.js +1 -0
  27. package/dist/web/web-dashboard-pages.js +58 -20
  28. package/dist/web/web-dashboard-peer-routes.js +19 -0
  29. package/dist/web/web-dashboard-runtime-routes.js +8 -1
  30. package/dist/web/web-dashboard-session-routes.js +17 -12
  31. package/dist/web/web-dashboard-ui.js +46 -10
  32. package/dist/web/web-performance.js +2 -0
  33. package/dist/web/web-state.js +33 -4
  34. package/dist/webui-assets/dashboard.css +227 -39
  35. package/dist/webui-assets/dashboard.js +728 -58
  36. package/package.json +4 -2
  37. package/plugins/nordrelay/scripts/nordrelay.mjs +333 -8
  38. package/plugins/nordrelay/scripts/service-installer.mjs +183 -0
  39. package/scripts/postinstall.mjs +122 -0
@@ -0,0 +1,122 @@
1
+ #!/usr/bin/env node
2
+ import { execFileSync } from "node:child_process";
3
+ import path from "node:path";
4
+
5
+ const commandName = process.platform === "win32" ? "nordrelay.cmd" : "nordrelay";
6
+
7
+ function isGlobalInstall() {
8
+ return process.env.NORDRELAY_POSTINSTALL_CHECK === "1"
9
+ || process.env.npm_config_global === "true"
10
+ || process.env.npm_config_location === "global";
11
+ }
12
+
13
+ function npmPrefix() {
14
+ const configured = process.env.npm_config_prefix;
15
+ if (configured) {
16
+ return configured;
17
+ }
18
+ const npmExec = process.env.npm_execpath || "npm";
19
+ try {
20
+ return execFileSync(npmExec, ["prefix", "-g"], {
21
+ encoding: "utf8",
22
+ shell: process.platform === "win32",
23
+ stdio: ["ignore", "pipe", "ignore"],
24
+ }).trim();
25
+ } catch {
26
+ return "";
27
+ }
28
+ }
29
+
30
+ function globalBinDir(prefix, platform = process.platform) {
31
+ if (!prefix) {
32
+ return "";
33
+ }
34
+ return platform === "win32" ? prefix : path.join(prefix, "bin");
35
+ }
36
+
37
+ function normalizePathEntry(entry, platform = process.platform) {
38
+ const resolved = path.resolve(entry);
39
+ return platform === "win32" || platform === "darwin" ? resolved.toLowerCase() : resolved;
40
+ }
41
+
42
+ function pathContains(dir, envPath = process.env.PATH || "", platform = process.platform) {
43
+ if (!dir) {
44
+ return false;
45
+ }
46
+ const wanted = normalizePathEntry(dir, platform);
47
+ return envPath
48
+ .split(path.delimiter)
49
+ .filter(Boolean)
50
+ .map((entry) => normalizePathEntry(entry, platform))
51
+ .includes(wanted);
52
+ }
53
+
54
+ function shellProfile(platform = process.platform, shell = process.env.SHELL || "") {
55
+ if (platform === "win32") {
56
+ return "";
57
+ }
58
+ if (platform === "darwin") {
59
+ return shell.endsWith("/bash") ? "~/.bash_profile" : "~/.zshrc";
60
+ }
61
+ return shell.endsWith("/zsh") ? "~/.zshrc" : "~/.bashrc";
62
+ }
63
+
64
+ function quote(value) {
65
+ return `"${String(value).replaceAll('"', '\\"')}"`;
66
+ }
67
+
68
+ function warning(prefix, binDir, platform = process.env.NORDRELAY_POSTINSTALL_PLATFORM || process.platform) {
69
+ const commandPath = path.join(binDir, commandName);
70
+ if (platform === "win32") {
71
+ return [
72
+ "",
73
+ "NordRelay installed, but the npm global bin directory is not in your PATH.",
74
+ 'The `nordrelay` command may fail with "command not found".',
75
+ "",
76
+ `npm global bin: ${binDir}`,
77
+ "",
78
+ "Add it to your user PATH, then open a new terminal:",
79
+ ` [Environment]::SetEnvironmentVariable("Path", $env:Path + ";${binDir}", "User")`,
80
+ "",
81
+ "Or run NordRelay directly:",
82
+ ` & ${quote(commandPath)} init`,
83
+ "",
84
+ ].join("\n");
85
+ }
86
+
87
+ const profile = shellProfile(platform);
88
+ return [
89
+ "",
90
+ "NordRelay installed, but the npm global bin directory is not in your PATH.",
91
+ 'The `nordrelay` command may fail with "command not found".',
92
+ "",
93
+ `npm global bin: ${binDir}`,
94
+ "",
95
+ `Add this to ${profile}:`,
96
+ ` export PATH=${quote(binDir + ":$PATH")}`,
97
+ "",
98
+ "Then reload your shell and initialize NordRelay:",
99
+ ` source ${profile}`,
100
+ " nordrelay init",
101
+ "",
102
+ "Or run NordRelay directly:",
103
+ ` ${quote(commandPath)} init`,
104
+ "",
105
+ prefix ? "" : "If the npm prefix could not be detected, run `npm prefix -g` and add its bin directory to PATH.",
106
+ ].filter(Boolean).join("\n");
107
+ }
108
+
109
+ function main() {
110
+ if (!isGlobalInstall()) {
111
+ return;
112
+ }
113
+ const prefix = npmPrefix();
114
+ const platform = process.env.NORDRELAY_POSTINSTALL_PLATFORM || process.platform;
115
+ const binDir = globalBinDir(prefix, platform);
116
+ if (!binDir || pathContains(binDir, process.env.PATH || "", platform)) {
117
+ return;
118
+ }
119
+ console.warn(warning(prefix, binDir, platform));
120
+ }
121
+
122
+ main();