jishushell 0.0.1 → 0.4.2-beta2

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 (139) hide show
  1. package/INSTALL-NOTICE +41 -0
  2. package/LICENSE +202 -0
  3. package/README.md +36 -0
  4. package/THIRD-PARTY-NOTICES +387 -0
  5. package/dist/auth.d.ts +6 -0
  6. package/dist/auth.js +88 -0
  7. package/dist/auth.js.map +1 -0
  8. package/dist/cli.d.ts +2 -0
  9. package/dist/cli.js +290 -0
  10. package/dist/cli.js.map +1 -0
  11. package/dist/config.d.ts +24 -0
  12. package/dist/config.js +226 -0
  13. package/dist/config.js.map +1 -0
  14. package/dist/constants.d.ts +3 -0
  15. package/dist/constants.js +15 -0
  16. package/dist/constants.js.map +1 -0
  17. package/dist/control.d.ts +44 -0
  18. package/dist/control.js +1359 -0
  19. package/dist/control.js.map +1 -0
  20. package/dist/crypto-shim.d.ts +1 -0
  21. package/dist/crypto-shim.js +2 -0
  22. package/dist/crypto-shim.js.map +1 -0
  23. package/dist/doctor.d.ts +46 -0
  24. package/dist/doctor.js +937 -0
  25. package/dist/doctor.js.map +1 -0
  26. package/dist/install.d.ts +27 -0
  27. package/dist/install.js +570 -0
  28. package/dist/install.js.map +1 -0
  29. package/dist/routes/auth.d.ts +4 -0
  30. package/dist/routes/auth.js +151 -0
  31. package/dist/routes/auth.js.map +1 -0
  32. package/dist/routes/instances.d.ts +2 -0
  33. package/dist/routes/instances.js +1303 -0
  34. package/dist/routes/instances.js.map +1 -0
  35. package/dist/routes/setup.d.ts +2 -0
  36. package/dist/routes/setup.js +139 -0
  37. package/dist/routes/setup.js.map +1 -0
  38. package/dist/routes/system.d.ts +2 -0
  39. package/dist/routes/system.js +102 -0
  40. package/dist/routes/system.js.map +1 -0
  41. package/dist/server.d.ts +6 -0
  42. package/dist/server.js +392 -0
  43. package/dist/server.js.map +1 -0
  44. package/dist/services/instance-manager.d.ts +67 -0
  45. package/dist/services/instance-manager.js +1319 -0
  46. package/dist/services/instance-manager.js.map +1 -0
  47. package/dist/services/llm-proxy/adapters.d.ts +3 -0
  48. package/dist/services/llm-proxy/adapters.js +309 -0
  49. package/dist/services/llm-proxy/adapters.js.map +1 -0
  50. package/dist/services/llm-proxy/circuit-breaker.d.ts +9 -0
  51. package/dist/services/llm-proxy/circuit-breaker.js +73 -0
  52. package/dist/services/llm-proxy/circuit-breaker.js.map +1 -0
  53. package/dist/services/llm-proxy/encryption.d.ts +6 -0
  54. package/dist/services/llm-proxy/encryption.js +61 -0
  55. package/dist/services/llm-proxy/encryption.js.map +1 -0
  56. package/dist/services/llm-proxy/index.d.ts +24 -0
  57. package/dist/services/llm-proxy/index.js +708 -0
  58. package/dist/services/llm-proxy/index.js.map +1 -0
  59. package/dist/services/llm-proxy/rate-limiter.d.ts +1 -0
  60. package/dist/services/llm-proxy/rate-limiter.js +39 -0
  61. package/dist/services/llm-proxy/rate-limiter.js.map +1 -0
  62. package/dist/services/llm-proxy/sse.d.ts +10 -0
  63. package/dist/services/llm-proxy/sse.js +378 -0
  64. package/dist/services/llm-proxy/sse.js.map +1 -0
  65. package/dist/services/llm-proxy/ssrf.d.ts +16 -0
  66. package/dist/services/llm-proxy/ssrf.js +185 -0
  67. package/dist/services/llm-proxy/ssrf.js.map +1 -0
  68. package/dist/services/llm-proxy/types.d.ts +52 -0
  69. package/dist/services/llm-proxy/types.js +2 -0
  70. package/dist/services/llm-proxy/types.js.map +1 -0
  71. package/dist/services/llm-proxy/usage.d.ts +12 -0
  72. package/dist/services/llm-proxy/usage.js +108 -0
  73. package/dist/services/llm-proxy/usage.js.map +1 -0
  74. package/dist/services/nomad-manager.d.ts +22 -0
  75. package/dist/services/nomad-manager.js +828 -0
  76. package/dist/services/nomad-manager.js.map +1 -0
  77. package/dist/services/plugin-installer.d.ts +22 -0
  78. package/dist/services/plugin-installer.js +102 -0
  79. package/dist/services/plugin-installer.js.map +1 -0
  80. package/dist/services/process-manager.d.ts +25 -0
  81. package/dist/services/process-manager.js +531 -0
  82. package/dist/services/process-manager.js.map +1 -0
  83. package/dist/services/setup-manager.d.ts +93 -0
  84. package/dist/services/setup-manager.js +1922 -0
  85. package/dist/services/setup-manager.js.map +1 -0
  86. package/dist/services/system-monitor.d.ts +1 -0
  87. package/dist/services/system-monitor.js +79 -0
  88. package/dist/services/system-monitor.js.map +1 -0
  89. package/dist/services/telemetry/activation.d.ts +12 -0
  90. package/dist/services/telemetry/activation.js +78 -0
  91. package/dist/services/telemetry/activation.js.map +1 -0
  92. package/dist/services/telemetry/client.d.ts +21 -0
  93. package/dist/services/telemetry/client.js +36 -0
  94. package/dist/services/telemetry/client.js.map +1 -0
  95. package/dist/services/telemetry/device-fingerprint.d.ts +18 -0
  96. package/dist/services/telemetry/device-fingerprint.js +123 -0
  97. package/dist/services/telemetry/device-fingerprint.js.map +1 -0
  98. package/dist/services/telemetry/heartbeat.d.ts +13 -0
  99. package/dist/services/telemetry/heartbeat.js +87 -0
  100. package/dist/services/telemetry/heartbeat.js.map +1 -0
  101. package/dist/services/telemetry/index.d.ts +3 -0
  102. package/dist/services/telemetry/index.js +4 -0
  103. package/dist/services/telemetry/index.js.map +1 -0
  104. package/dist/types.d.ts +51 -0
  105. package/dist/types.js +2 -0
  106. package/dist/types.js.map +1 -0
  107. package/dist/utils/safe-json.d.ts +2 -0
  108. package/dist/utils/safe-json.js +80 -0
  109. package/dist/utils/safe-json.js.map +1 -0
  110. package/dist/utils/ttl-cache.d.ts +29 -0
  111. package/dist/utils/ttl-cache.js +77 -0
  112. package/dist/utils/ttl-cache.js.map +1 -0
  113. package/install/jishu-install.sh +2920 -0
  114. package/install/jishu-uninstall.sh +811 -0
  115. package/install/post-install.sh +124 -0
  116. package/install/post-uninstall.sh +46 -0
  117. package/package.json +57 -8
  118. package/public/assets/Dashboard-Dxsq690N.js +1 -0
  119. package/public/assets/InitPassword-CslWYy8G.js +1 -0
  120. package/public/assets/InstanceDetail-DmEkMj-t.js +14 -0
  121. package/public/assets/Login-d45wtgVA.js +1 -0
  122. package/public/assets/NewInstance-Czp5-AJe.js +1 -0
  123. package/public/assets/Settings-BKMGck05.js +1 -0
  124. package/public/assets/Setup-D3rfLWjZ.js +1 -0
  125. package/public/assets/index-77Ug7feY.css +1 -0
  126. package/public/assets/index-DkDnIohs.js +16 -0
  127. package/public/assets/logo-black-theme-DywLAtFy.png +0 -0
  128. package/public/assets/logo-white-theme-DXffFAWw.png +0 -0
  129. package/public/assets/providers-lBSOjUWy.js +1 -0
  130. package/public/assets/usePolling-CqQ8hrNc.js +1 -0
  131. package/public/assets/vendor-i18n-Bvxxh8Di.js +9 -0
  132. package/public/assets/vendor-react-DONn7uBV.js +59 -0
  133. package/public/index.html +15 -0
  134. package/scripts/build-image.sh +55 -0
  135. package/scripts/run.sh +310 -0
  136. package/scripts/setup-pi.sh +80 -0
  137. package/scripts/start-feishu1.js +46 -0
  138. package/index.js +0 -0
  139. package/jishushell-0.0.1.tgz +0 -0
@@ -0,0 +1,124 @@
1
+ #!/bin/bash
2
+ set -uo pipefail
3
+
4
+ # CI environments run `npm install` only to fetch deps — skip post-install entirely.
5
+ if [[ "${CI:-}" == "true" || -n "${CI_PIPELINE_ID:-}" ]]; then
6
+ exit 0
7
+ fi
8
+
9
+ # Only run when installed globally via `npm install -g jishushell`.
10
+ # Local installs (npm install, npm run build) skip post-install entirely.
11
+ if [[ -n "${npm_lifecycle_event:-}" && "${npm_config_global:-false}" != "true" ]]; then
12
+ _tty=/dev/tty
13
+ [[ -w "$_tty" ]] || _tty=/dev/stderr
14
+ {
15
+ echo ""
16
+ echo " JishuShell requires global installation."
17
+ echo " Please use: npm install -g jishushell"
18
+ echo ""
19
+ } > "$_tty"
20
+ exit 0
21
+ fi
22
+
23
+ # ═══════════════════════════════════════════════════════════════════════════════
24
+ # JishuShell Post-Install Script
25
+ #
26
+ # Executed automatically via `npm postinstall` after `npm install -g jishushell`.
27
+ # Installs all runtime dependencies (Docker, Nomad, OpenClaw) and registers the
28
+ # JishuShell service.
29
+ #
30
+ # Skips:
31
+ # • Node.js — already installed (npm is running on it)
32
+ # • npm install -g jishushell — npm just installed the package itself
33
+ #
34
+ # Sources jishu-install.sh for all shared functions.
35
+ # ═══════════════════════════════════════════════════════════════════════════════
36
+
37
+ # When post-install.sh is triggered by npm's postinstall hook that was itself
38
+ # launched from inside jishu-install.sh (i.e. jishu-install.sh called
39
+ # `npm install -g jishushell`), all installation steps have already been run
40
+ # by the parent script. Only write the wrapper + service registration, then exit.
41
+ if [[ "${JISHU_RUNNING_IN_INSTALLER:-0}" == "1" ]]; then
42
+ echo " [post-install] Detected parent jishu-install.sh — skipping redundant install steps"
43
+ JISHU_SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" && pwd)"
44
+ source "${JISHU_SCRIPT_DIR}/jishu-install.sh"
45
+ SKIP_NODE=1
46
+ SKIP_DOCKER=1
47
+ SKIP_NOMAD=1
48
+ SKIP_OPENCLAW=1
49
+ export JISHUSHELL_SKIP_NPM_INSTALL=1
50
+ detect_os
51
+ detect_arch
52
+ if [[ $EUID -eq 0 ]]; then SUDO=""; else SUDO="sudo"; fi
53
+ install_jishushell || true
54
+ install_jishushell_service || true
55
+ # Backup scripts
56
+ _jishu_install_backup="${REAL_HOME}/.jishushell/install"
57
+ mkdir -p "$_jishu_install_backup"
58
+ cp -f "${JISHU_SCRIPT_DIR}/jishu-install.sh" "${_jishu_install_backup}/jishu-install.sh" 2>/dev/null || true
59
+ cp -f "${JISHU_SCRIPT_DIR}/jishu-uninstall.sh" "${_jishu_install_backup}/jishu-uninstall.sh" 2>/dev/null || true
60
+ cp -f "${JISHU_SCRIPT_DIR}/post-uninstall.sh" "${_jishu_install_backup}/post-uninstall.sh" 2>/dev/null || true
61
+ chmod +x "${_jishu_install_backup}/jishu-uninstall.sh" "${_jishu_install_backup}/post-uninstall.sh" 2>/dev/null || true
62
+ exit 0
63
+ fi
64
+
65
+ JISHU_SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" && pwd)"
66
+ JISHU_INSTALL_SH="${JISHU_SCRIPT_DIR}/jishu-install.sh"
67
+
68
+ if [[ ! -f "$JISHU_INSTALL_SH" ]]; then
69
+ echo "ERROR: cannot find jishu-install.sh at ${JISHU_INSTALL_SH}" >&2
70
+ exit 1
71
+ fi
72
+
73
+ # Source shared functions (double-source guard is built in)
74
+ # shellcheck disable=SC1090
75
+ source "$JISHU_INSTALL_SH"
76
+
77
+ # Skip steps handled by npm
78
+ SKIP_NODE=1
79
+ export JISHUSHELL_SKIP_NPM_INSTALL=1
80
+
81
+ # Parse any extra args forwarded via npm (e.g. --dry-run, --yes, --skip-docker)
82
+ parse_args "$@"
83
+
84
+ # ── Log setup ─────────────────────────────────────────────────────────────────
85
+ # npm captures lifecycle script stdout/stderr and only shows it on error.
86
+ # Writing to /dev/tty bypasses that capture so progress is visible in real time.
87
+ # The log file is always written regardless of tty availability.
88
+ mkdir -p "${REAL_HOME}/.jishushell"
89
+ LOG_FILE="${REAL_HOME}/.jishushell/post-install-$(date +%Y-%m-%d-%H-%M-%S)-$$.log"
90
+ if [[ -w /dev/tty ]] && echo -n '' > /dev/tty 2>/dev/null; then
91
+ # tee writes to $LOG_FILE; its stdout (>/dev/tty) goes straight to the terminal,
92
+ # bypassing npm's stdout capture entirely.
93
+ exec > >(tee -a "$LOG_FILE" >/dev/tty) 2>&1
94
+ else
95
+ # Non-interactive / CI: fall back to npm's stdout (visible with --foreground-scripts)
96
+ exec > >(tee -a "$LOG_FILE") 2>&1
97
+ fi
98
+
99
+ echo ""
100
+ ui_info "Log: ${LOG_FILE}"
101
+ echo ""
102
+
103
+ # ── Run install steps ─────────────────────────────────────────────────────────
104
+ detect_os
105
+ detect_arch
106
+ check_sudo
107
+ ensure_prerequisites
108
+ run_install_components --with-jishushell || true
109
+ _rc=$?
110
+ show_summary --with-jishushell
111
+
112
+ # ── Persist uninstall scripts for postuninstall lifecycle hook ────────────────
113
+ # npm removes package files BEFORE postuninstall runs, so we keep a copy in
114
+ # ~/.jishushell/install/ that the postuninstall script can always find.
115
+ _jishu_install_backup="${REAL_HOME}/.jishushell/install"
116
+ mkdir -p "$_jishu_install_backup"
117
+ cp -f "${JISHU_SCRIPT_DIR}/jishu-install.sh" "${_jishu_install_backup}/jishu-install.sh" 2>/dev/null || true
118
+ cp -f "${JISHU_SCRIPT_DIR}/jishu-uninstall.sh" "${_jishu_install_backup}/jishu-uninstall.sh" 2>/dev/null || true
119
+ cp -f "${JISHU_SCRIPT_DIR}/post-uninstall.sh" "${_jishu_install_backup}/post-uninstall.sh" 2>/dev/null || true
120
+ chmod +x "${_jishu_install_backup}/jishu-uninstall.sh" "${_jishu_install_backup}/post-uninstall.sh" 2>/dev/null || true
121
+
122
+ echo ""
123
+ ui_info "Full log saved to: ${LOG_FILE}"
124
+ exit $_rc
@@ -0,0 +1,46 @@
1
+ #!/bin/bash
2
+ # ═══════════════════════════════════════════════════════════════════════════════
3
+ # JishuShell Pre-Uninstall Script
4
+ #
5
+ # Called by npm's preuninstall lifecycle hook during `npm uninstall -g jishushell`.
6
+ # Runs BEFORE npm removes the package files.
7
+ #
8
+ # Guard: only clean up when ~/.jishushell exists (indicates a real global install).
9
+ # This makes the script safe regardless of npm_config_global being set or not.
10
+ # ═══════════════════════════════════════════════════════════════════════════════
11
+
12
+ if [ ! -d "${HOME}/.jishushell" ]; then
13
+ exit 0
14
+ fi
15
+
16
+ _SUDO=""
17
+ if [ "$(id -u)" -ne 0 ] && command -v sudo >/dev/null 2>&1; then
18
+ _SUDO="sudo"
19
+ fi
20
+
21
+ echo "· JishuShell: stopping services and cleaning up..."
22
+
23
+ # ── systemd (Linux) ───────────────────────────────────────────────────────────
24
+ if command -v systemctl >/dev/null 2>&1; then
25
+ for svc in jishushell nomad; do
26
+ $_SUDO systemctl stop "$svc" 2>/dev/null || true
27
+ $_SUDO systemctl disable "$svc" 2>/dev/null || true
28
+ $_SUDO rm -f "/etc/systemd/system/${svc}.service" 2>/dev/null || true
29
+ done
30
+ $_SUDO systemctl daemon-reload 2>/dev/null || true
31
+ fi
32
+
33
+ # ── launchd (macOS) ──────────────────────────────────────────────────────────
34
+ if [ "$(uname -s)" = "Darwin" ]; then
35
+ for label in com.jishushell.backend com.jishushell.nomad; do
36
+ launchctl unload -w "${HOME}/Library/LaunchAgents/${label}.plist" 2>/dev/null || true
37
+ rm -f "${HOME}/Library/LaunchAgents/${label}.plist" 2>/dev/null || true
38
+ done
39
+ fi
40
+
41
+ # ── Remove ~/.jishushell data directory ──────────────────────────────────────
42
+ if [ -d "${HOME}/.jishushell" ]; then
43
+ $_SUDO rm -rf "${HOME}/.jishushell"
44
+ echo "· Removed ${HOME}/.jishushell"
45
+ fi
46
+
package/package.json CHANGED
@@ -1,13 +1,62 @@
1
1
  {
2
2
  "name": "jishushell",
3
- "version": "0.0.1",
4
- "description": "OpenSource Agent Management Framework(Coming Soon)",
5
- "main": "index.js",
3
+ "version": "0.4.2-beta2",
4
+ "description": "JishuShell - Multi-Agent Framework Management",
5
+ "type": "module",
6
+ "bin": {
7
+ "jishushell": "./dist/cli.js"
8
+ },
9
+ "files": [
10
+ "dist/",
11
+ "public/",
12
+ "scripts/",
13
+ "install/",
14
+ "INSTALL-NOTICE",
15
+ "THIRD-PARTY-NOTICES"
16
+ ],
6
17
  "scripts": {
7
- "test": "echo \"Error: no test specified\" && exit 1"
18
+ "build": "npm install && tsc && cd frontend && npm install && npm run build",
19
+ "build:backend": "npm install && tsc",
20
+ "build:frontend": "cd frontend && npm install && npm run build",
21
+ "start": "node dist/cli.js serve",
22
+ "dev": "tsc --watch",
23
+ "test": "vitest run",
24
+ "test:unit:backend": "vitest run tests/unit",
25
+ "test:integration": "vitest run tests/integration",
26
+ "test:watch": "vitest",
27
+ "test:coverage": "vitest run --coverage",
28
+ "test:ci": "npm run build:backend && vitest run --coverage && cd frontend && npm install && npm run test",
29
+ "prepublishOnly": "npm run build && chmod +x dist/cli.js",
30
+ "postinstall": "bash install/post-install.sh",
31
+ "preuninstall": "bash install/post-uninstall.sh",
32
+ "prepare": "git config core.hooksPath .githooks 2>/dev/null || true",
33
+ "build:pack": "npm run build && npm pack",
34
+ "version": "node -e \"const fs=require('fs'),v=JSON.parse(fs.readFileSync('./package.json','utf8')).version,fp='./frontend/package.json',p=JSON.parse(fs.readFileSync(fp,'utf8'));p.version=v;fs.writeFileSync(fp,JSON.stringify(p,null,2)+'\\n')\" && git add frontend/package.json"
35
+ },
36
+ "engines": {
37
+ "node": ">=22"
38
+ },
39
+ "keywords": [
40
+ "raspberry-pi",
41
+ "server-panel",
42
+ "openclaw"
43
+ ],
44
+ "license": "Apache-2.0",
45
+ "dependencies": {
46
+ "@fastify/static": "^8.1.0",
47
+ "@noble/hashes": "^2.0.1",
48
+ "bcryptjs": "^2.4.3",
49
+ "fastify": "^5.2.0",
50
+ "jsonwebtoken": "^9.0.2",
51
+ "systeminformation": "^5.23.0"
8
52
  },
9
- "keywords": [],
10
- "author": "",
11
- "license": "ISC",
12
- "type": "commonjs"
53
+ "devDependencies": {
54
+ "@types/bcryptjs": "^2.4.6",
55
+ "@types/jsonwebtoken": "^9.0.7",
56
+ "@types/node": "^22.19.15",
57
+ "@vitest/coverage-v8": "^4.1.1",
58
+ "pptxgenjs": "^4.0.1",
59
+ "typescript": "^5.7.0",
60
+ "vitest": "^4.1.1"
61
+ }
13
62
  }
@@ -0,0 +1 @@
1
+ import{h as L,k as A,j as e,L as R,l as F,m as U,n as W,o as K,p as T,q as D,t as I,v as P,w as q,x as G}from"./index-DkDnIohs.js";import{r as l,u as H}from"./vendor-react-DONn7uBV.js";import{u as z}from"./usePolling-CqQ8hrNc.js";import{u as S}from"./vendor-i18n-Bvxxh8Di.js";function J(t){if(!t)return"-";const n=Math.floor(t/86400),d=Math.floor(t%86400/3600),r=Math.floor(t%3600/60);return n>0?`${n}d ${d}h`:d>0?`${d}h ${r}m`:`${r}m`}function O({status:t}){const{t:n}=S(),r={running:{cls:"bg-emerald-500/10 text-emerald-400 border border-emerald-500/20",labelKey:"status.running"},pending:{cls:"bg-amber-500/10 text-amber-400 border border-amber-500/20",labelKey:"status.starting"},failed:{cls:"bg-red-500/10 text-red-400 border border-red-500/20",labelKey:"status.failed"},dead:{cls:"bg-red-500/10 text-red-400 border border-red-500/20",labelKey:"status.crashed"}}[t]||{cls:"bg-[var(--card)] text-muted border border-[var(--border)]",labelKey:"status.stopped"};return e.jsx("span",{className:`inline-flex items-center text-xs px-2 py-0.5 rounded-full font-medium ${r.cls}`,children:n(r.labelKey)})}function ee(){const{t}=S(["dashboard","common"]),[n,d]=l.useState([]),[r,_]=l.useState(null),[b,j]=l.useState(""),[y,v]=l.useState(""),[p,f]=l.useState(!1),[o,N]=l.useState(null),[w,k]=l.useState(!1),C=H(),{showToast:c}=L(),m=()=>{K().then(s=>{d(s),v("")}).catch(s=>v(s.message||t("common:error.loadFailed"))),T().then(_).catch(()=>{})};z(m,1e4),l.useEffect(()=>{A().then(s=>{s.hasUpdate&&N({currentVersion:s.currentVersion,latestVersion:s.latestVersion})}).catch(()=>{})},[]);const B=async()=>{if(window.confirm(t("update.confirm",{currentVersion:o==null?void 0:o.currentVersion,latestVersion:o==null?void 0:o.latestVersion}))){k(!0);try{await D(),c(t("update.started"),"success"),N(null)}catch(s){c(s.message||t("update.failed"),"error")}finally{k(!1)}}},V=async()=>{if(window.confirm(t("engine.restartConfirm"))){f(!0);try{await I(),c(t("engine.restarted"),"success"),setTimeout(m,2e3)}catch(s){c(s.message||t("engine.restartFailed"),"error")}finally{f(!1)}}},g=async(s,a,i)=>{s.stopPropagation(),j(`${i}-${a}`);try{a==="start"&&await P(i),a==="stop"&&await q(i),a==="restart"&&await G(i),c(t(`common:action.${a}Done`),"success"),setTimeout(m,1e3)}catch(h){c(h.message||t("common:error.operationFailed"),"error")}finally{j("")}},E=n.filter(s=>{var a;return((a=s.service)==null?void 0:a.status)==="running"}).length,u=!!r&&r.disk.percent>90,M=r?[{label:t("stats.runningInstances"),value:`${E} / ${n.length}`,sub:r.nomad_running?t("stats.engineRunning"):t("stats.engineStopped"),subColor:r.nomad_running?"text-emerald-400":"text-red-400",icon:e.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.5,children:[e.jsx("rect",{x:"2",y:"3",width:"20",height:"14",rx:"2"}),e.jsx("line",{x1:"8",y1:"21",x2:"16",y2:"21"}),e.jsx("line",{x1:"12",y1:"17",x2:"12",y2:"21"})]}),iconColor:"text-[#0066FF]",glowColor:"rgba(0,102,255,0.12)",accent:"border-l-2 border-l-[#0066FF]"},{label:t("stats.cpu"),value:`${r.cpu_percent}%`,sub:r.temperature?`${r.temperature}°C`:null,icon:e.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.5,children:[e.jsx("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"}),e.jsx("rect",{x:"9",y:"9",width:"6",height:"6"}),e.jsx("line",{x1:"9",y1:"2",x2:"9",y2:"4"}),e.jsx("line",{x1:"15",y1:"2",x2:"15",y2:"4"}),e.jsx("line",{x1:"9",y1:"20",x2:"9",y2:"22"}),e.jsx("line",{x1:"15",y1:"20",x2:"15",y2:"22"}),e.jsx("line",{x1:"20",y1:"9",x2:"22",y2:"9"}),e.jsx("line",{x1:"20",y1:"15",x2:"22",y2:"15"}),e.jsx("line",{x1:"2",y1:"9",x2:"4",y2:"9"}),e.jsx("line",{x1:"2",y1:"15",x2:"4",y2:"15"})]}),iconColor:"text-[#0066FF]",glowColor:"rgba(0,102,255,0.12)",accent:"border-l-2 border-l-[#0066FF]",warn:r.cpu_percent>90},{label:t("stats.memory"),value:`${r.memory.percent}%`,sub:`${r.memory.used_mb}MB / ${r.memory.total_mb}MB`,icon:e.jsx("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.5,children:e.jsx("path",{d:"M6 19v-8m4 8v-4m4 4v-6m4 6v-2"})}),iconColor:"text-[#00D4AA]",glowColor:"rgba(0,212,170,0.12)",accent:"border-l-2 border-l-[#00D4AA]"},{label:t("stats.disk"),value:`${r.disk.percent}%`,sub:`${r.disk.used_gb}GB / ${r.disk.total_gb}GB`,icon:e.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.5,children:[e.jsx("ellipse",{cx:"12",cy:"5",rx:"9",ry:"3"}),e.jsx("path",{d:"M3 5v14a9 3 0 0018 0V5"}),e.jsx("line",{x1:"12",y1:"8",x2:"12",y2:"22"})]}),iconColor:u?"text-red-400":"text-[#0066FF]",glowColor:u?"rgba(239,68,68,0.12)":"rgba(0,102,255,0.12)",accent:u?"border-l-2 border-l-red-400":"border-l-2 border-l-[#0066FF]",warn:u}]:[];return e.jsxs("div",{className:"p-4 max-w-5xl mx-auto",children:[o&&e.jsxs("div",{className:"mb-4 flex items-center justify-between gap-3 bg-amber-500/10 border border-amber-500/30 rounded-lg px-4 py-2.5",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx("svg",{className:"w-4 h-4 text-amber-400 shrink-0",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.5,children:e.jsx("path",{d:"M12 2v6m0 0 2-2m-2 2-2-2M4.93 10.93A10 10 0 1 0 21 12"})}),e.jsxs("span",{className:"text-amber-300",children:[t("update.found"),e.jsx("span",{className:"font-mono text-amber-200 ml-1",children:o.currentVersion}),e.jsx("span",{className:"mx-1 text-amber-500",children:"→"}),e.jsx("span",{className:"font-mono text-amber-200",children:o.latestVersion})]})]}),e.jsx("button",{onClick:B,disabled:w,className:"shrink-0 bg-amber-500 hover:bg-amber-400 disabled:opacity-50 text-black text-xs font-semibold px-3 py-1 rounded-md transition-colors",children:t(w?"update.upgrading":"update.upgradeNow")})]}),e.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-base font-semibold text-foreground",children:t("title")}),e.jsx("p",{className:"text-xs text-muted mt-0.5",children:t("subtitle")})]}),e.jsx(R,{})]}),r&&e.jsx("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-3 mb-4",children:M.map(s=>e.jsxs("div",{className:`bg-[var(--card)] border border-[var(--border)] rounded-lg p-3 relative overflow-hidden hover:border-[var(--border-hover)] hover:bg-[var(--card-hover)] transition-all duration-200 ${s.accent}`,children:[e.jsx("div",{className:"absolute top-0 right-0 w-16 h-16 rounded-full opacity-60 pointer-events-none",style:{background:`radial-gradient(circle, ${s.glowColor} 0%, transparent 70%)`}}),e.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[e.jsx("span",{className:"text-[11px] text-muted",children:s.label}),e.jsx("span",{className:`${s.iconColor} opacity-80`,children:s.icon})]}),e.jsx("div",{className:`text-lg font-semibold ${s.warn?"text-red-400":"text-foreground"}`,children:s.value}),s.sub&&e.jsx("div",{className:`text-[11px] mt-0.5 truncate ${s.subColor??"text-muted"}`,children:s.sub})]},s.label))}),e.jsxs("div",{className:"bg-[var(--card)] border border-[var(--border)] rounded-xl overflow-hidden",children:[e.jsxs("div",{className:"px-4 py-2.5 border-b border-[var(--border)] flex items-center justify-between",children:[e.jsx("h2",{className:"text-sm font-medium text-foreground",children:t("instances.title")}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>C("/instances/new"),className:"bg-[#0066FF] text-white px-3 py-1.5 rounded-md text-xs font-medium hover:bg-[#0066FF]/90 transition-all duration-200 shadow-[0_0_12px_rgba(0,102,255,0.3)]",children:t("instances.new")}),e.jsxs("button",{onClick:V,disabled:p,title:t("instances.restartEngineTitle"),className:"flex items-center gap-1.5 px-2.5 py-1.5 rounded-md text-xs font-medium text-red-400 border border-red-500/20 bg-red-500/5 hover:bg-red-500/15 disabled:opacity-40 disabled:cursor-not-allowed transition-all duration-200",children:[e.jsx(F,{className:`w-3 h-3 ${p?"animate-spin":""}`}),t(p?"instances.restarting":"instances.restartEngine")]})]})]}),y?e.jsxs("div",{className:"text-center py-12 px-4",children:[e.jsx("p",{className:"text-sm text-red-400 mb-2",children:t("instances.loadError",{error:y})}),e.jsx("button",{onClick:m,className:"text-xs text-muted hover:text-foreground underline",children:t("common:action.retry")})]}):n.length===0?e.jsxs("div",{className:"text-center py-12 px-4",children:[e.jsx("div",{className:"text-muted opacity-40 mb-3",children:e.jsxs("svg",{className:"w-8 h-8 mx-auto",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"2",y:"3",width:"20",height:"14",rx:"2"}),e.jsx("line",{x1:"8",y1:"21",x2:"16",y2:"21"}),e.jsx("line",{x1:"12",y1:"17",x2:"12",y2:"21"})]})}),e.jsx("p",{className:"text-sm text-muted mb-1",children:t("instances.empty")}),e.jsx("p",{className:"text-xs text-muted opacity-60",children:t("instances.emptyHint")})]}):e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"text-xs text-muted border-b border-[var(--border)]",children:[e.jsx("th",{className:"text-left font-medium px-4 py-2",children:t("table.name")}),e.jsx("th",{className:"text-left font-medium px-4 py-2",children:t("table.status")}),e.jsx("th",{className:"text-left font-medium px-4 py-2 hidden sm:table-cell",children:t("table.uptime")}),e.jsx("th",{className:"text-left font-medium px-4 py-2 hidden md:table-cell",children:t("table.memory")}),e.jsx("th",{className:"text-right font-medium px-4 py-2",children:t("table.actions")})]})}),e.jsx("tbody",{className:"divide-y divide-[var(--border)]",children:n.map(s=>{var h,$;const a=((h=s.service)==null?void 0:h.status)||"stopped",i=a==="running";return e.jsxs("tr",{className:"hover:bg-[var(--card-hover)] cursor-pointer transition-colors duration-150",onClick:()=>C(`/instances/${s.id}`),children:[e.jsxs("td",{className:"px-4 py-2.5",children:[e.jsx("div",{className:"font-medium text-foreground",children:s.name}),e.jsx("div",{className:"text-xs text-muted font-mono",children:s.id})]}),e.jsx("td",{className:"px-4 py-2.5",children:e.jsx(O,{status:a})}),e.jsx("td",{className:"px-4 py-2.5 text-muted hidden sm:table-cell font-mono text-xs",children:i?J(s.service.uptime):"-"}),e.jsx("td",{className:"px-4 py-2.5 text-muted hidden md:table-cell font-mono text-xs",children:($=s.service)!=null&&$.memory_mb?`${s.service.memory_mb} MB`:"-"}),e.jsx("td",{className:"px-4 py-2.5 text-right",children:e.jsx("div",{className:"inline-flex items-center gap-1",children:i||a==="pending"?e.jsxs(e.Fragment,{children:[e.jsx("button",{title:t("common:action.restart"),onClick:x=>g(x,"restart",s.id),disabled:!!b,className:"p-1.5 rounded-md text-muted hover:text-foreground hover:bg-[var(--card-hover)] disabled:opacity-30 transition-colors duration-150",children:e.jsx(F,{className:"w-3.5 h-3.5"})}),e.jsx("button",{title:t("common:action.stop"),onClick:x=>g(x,"stop",s.id),disabled:!!b,className:"p-1.5 rounded-md text-muted hover:text-red-400 hover:bg-red-500/10 disabled:opacity-30 transition-colors duration-150",children:e.jsx(U,{className:"w-3.5 h-3.5"})})]}):e.jsx("button",{title:t("common:action.start"),onClick:x=>g(x,"start",s.id),disabled:!!b,className:"p-1.5 rounded-md text-muted hover:text-emerald-400 hover:bg-emerald-500/10 disabled:opacity-30 transition-colors duration-150",children:e.jsx(W,{className:"w-3.5 h-3.5"})})})})]},s.id)})})]})]})]})}export{ee as default};
@@ -0,0 +1 @@
1
+ import{j as e,T as j,I as v,a as w,c as N,s as y}from"./index-DkDnIohs.js";import{r}from"./vendor-react-DONn7uBV.js";import{u as F}from"./vendor-i18n-Bvxxh8Di.js";const x="w-full bg-[var(--input-bg)] border border-[var(--border)] rounded-md px-3 py-2.5 text-sm text-foreground placeholder-[var(--muted)] focus:outline-none focus:ring-1 focus:ring-[#0066FF]/60 focus:border-[#0066FF]/60 transition-colors duration-200";function _({onDone:p}){const{t}=F("auth"),[s,h]=r.useState(""),[n,b]=r.useState(""),[o,f]=r.useState(!1),[l,d]=r.useState(""),[c,m]=r.useState(!1),u=s.length>=8&&s===n,g=async a=>{if(a.preventDefault(),!!u){d(""),m(!0);try{const i=await N(s);y(i.token),p()}catch(i){d(i.message||t("init.failed"))}finally{m(!1)}}};return e.jsxs("div",{className:"min-h-screen flex items-center justify-center p-4 bg-background relative overflow-hidden",children:[e.jsx("div",{className:"grid-bg absolute inset-0 pointer-events-none"}),e.jsx("div",{className:"absolute top-1/3 left-1/2 -translate-x-1/2 -translate-y-1/2 w-[500px] h-[300px] rounded-full bg-[#0066FF]/[0.07] blur-[90px] pointer-events-none"}),e.jsxs("div",{className:"w-full max-w-sm relative z-10",children:[e.jsxs("div",{className:"text-center mb-8",children:[e.jsx(j,{className:"w-40 h-40 mx-auto mb-4 object-contain"}),e.jsx("p",{className:"text-sm text-muted mt-1",children:t("init.title")})]}),e.jsxs("form",{onSubmit:g,className:"space-y-4",children:[l&&e.jsx("div",{className:"bg-red-500/10 border border-red-500/20 text-red-400 text-sm rounded-lg px-3 py-2.5",children:l}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-muted mb-1.5",children:t("init.password")}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:o?"text":"password",value:s,onChange:a=>h(a.target.value),placeholder:t("init.passwordPlaceholder"),className:`${x} pr-10`,autoFocus:!0}),e.jsx("button",{type:"button",onClick:()=>f(!o),className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted hover:text-foreground transition-colors duration-200",children:o?e.jsx(v,{}):e.jsx(w,{})})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-muted mb-1.5",children:t("init.confirm")}),e.jsx("input",{type:o?"text":"password",value:n,onChange:a=>b(a.target.value),placeholder:t("init.confirmPlaceholder"),className:x}),s&&n&&s!==n&&e.jsx("p",{className:"text-red-400 text-xs mt-1.5",children:t("init.mismatch")})]}),e.jsx("button",{type:"submit",disabled:c||!u,className:"w-full bg-[#0066FF] text-white rounded-md py-2.5 text-sm font-medium hover:bg-[#0066FF]/90 disabled:opacity-40 disabled:cursor-not-allowed transition-all duration-200 shadow-[0_0_20px_rgba(0,102,255,0.3)] hover:shadow-[0_0_28px_rgba(0,102,255,0.45)]",children:c?e.jsxs("span",{className:"inline-flex items-center gap-2",children:[e.jsx("span",{className:"w-3.5 h-3.5 border-2 border-white/30 border-t-white rounded-full animate-spin"}),t("init.loading")]}):t("init.submit")})]})]})]})}export{_ as default};