support-bot: use published simplex-chat, drop build.sh/start.sh

This commit is contained in:
shum
2026-04-25 14:00:54 +00:00
parent a836c50f60
commit 9bed4cf921
4 changed files with 453 additions and 258 deletions
-55
View File
@@ -1,55 +0,0 @@
#!/usr/bin/env bash
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
REPO_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
TYPES_PKG="$REPO_ROOT/packages/simplex-chat-client/types/typescript"
NODEJS_PKG="$REPO_ROOT/packages/simplex-chat-nodejs"
# npm's `file:` deps are copied into node_modules, so when the source
# package changes (e.g. after `git pull`) consumers keep seeing the old
# copy — this is what produced the TS2345 "Property 'comments' is missing
# in type ... FullGroupPreferences" errors. Replacing those copies with
# symlinks removes the possibility of drift: there is one physical package
# and every consumer sees the current version.
link_workspace_dep() {
local host="$1" name="$2" target="$3"
local dest="$host/node_modules/$name"
if [ -L "$dest" ] && [ "$(readlink -f "$dest")" = "$target" ]; then
return
fi
mkdir -p "$(dirname "$dest")"
rm -rf "$dest"
ln -s "$target" "$dest"
}
# Only run `npm install` when something it cares about actually changed
# — missing node_modules, or a package manifest newer than the installed
# lockfile marker. Avoids the multi-minute reinstall on every build.
ensure_installed() {
local dir="$1"
local marker="$dir/node_modules/.package-lock.json"
if [ ! -d "$dir/node_modules" ] \
|| [ ! -f "$marker" ] \
|| [ "$dir/package.json" -nt "$marker" ] \
|| { [ -f "$dir/package-lock.json" ] && [ "$dir/package-lock.json" -nt "$marker" ]; }; then
(cd "$dir" && npm install)
fi
}
echo "Building @simplex-chat/types..."
(cd "$TYPES_PKG" && npm run build)
echo "Building simplex-chat..."
ensure_installed "$NODEJS_PKG"
link_workspace_dep "$NODEJS_PKG" "@simplex-chat/types" "$TYPES_PKG"
(cd "$NODEJS_PKG" && npm run build)
echo "Building simplex-support-bot..."
ensure_installed "$SCRIPT_DIR"
link_workspace_dep "$SCRIPT_DIR" "@simplex-chat/types" "$TYPES_PKG"
link_workspace_dep "$SCRIPT_DIR" "simplex-chat" "$NODEJS_PKG"
(cd "$SCRIPT_DIR" && npm run build)
echo "Build complete. Output in $SCRIPT_DIR/dist/"
File diff suppressed because it is too large Load Diff
+3 -2
View File
@@ -8,9 +8,10 @@
"start": "node dist/index.js"
},
"dependencies": {
"@simplex-chat/types": "file:../../packages/simplex-chat-client/types/typescript",
"@simplex-chat/types": "^0.5.0",
"async-mutex": "^0.5.0",
"simplex-chat": "file:../../packages/simplex-chat-nodejs"
"commander": "^14.0.3",
"simplex-chat": "^6.5.0-beta.10"
},
"devDependencies": {
"@types/node": "^22.0.0",
-37
View File
@@ -1,37 +0,0 @@
#!/usr/bin/env bash
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
cd "$SCRIPT_DIR"
# --- Required ---
# GROK_API_KEY xAI API key (env var)
# --team-group Team group display name
# --pg-conn PostgreSQL connection string. Required only when
# simplex-chat-nodejs was installed with the postgres
# backend (SIMPLEX_BACKEND=postgres, .npmrc, or
# --simplex_backend=postgres at install time).
# --- Optional ---
# --state-file Path to the bot's state JSON (default: ./data/state.json)
# --sqlite-file-prefix SQLite DB file prefix (default: ./data/simplex)
# --sqlite-key SQLCipher encryption key (default: unencrypted)
# --pg-schema PostgreSQL schema prefix (default: simplex_v1)
# --auto-add-team-members (-a) Comma-separated ID:name pairs (e.g. 1:Alice,2:Bob)
# --group-links Public group link(s) shown in welcome message
# --timezone IANA timezone for weekend detection (default: UTC)
# --complete-hours Hours of inactivity before auto-complete (default: 3)
if [ -z "${GROK_API_KEY:-}" ]; then
echo "Error: GROK_API_KEY environment variable is required" >&2
exit 1
fi
if [ ! -f dist/index.js ]; then
echo "Error: dist/index.js not found. Run ./build.sh first." >&2
exit 1
fi
# Run via `npm start` so npm exposes `.npmrc` values (e.g. simplex_backend=postgres)
# as `npm_config_*` env vars to the bot.
exec npm --silent start -- "$@"