Initial state: - ia_dev was historically referenced as ./ia_dev in docs and integrations, while the vendored module lives under services/ia_dev. - AnythingLLM sync and hook installation had error masking / weak exit signaling. - Proxy layers did not validate proxy path segments, allowing path normalization tricks. Motivation: - Make the IDE-oriented workflow usable (sync -> act -> deploy/preview) with explicit errors. - Reduce security footguns in proxying and script automation. Resolution: - Standardize IA_DEV_ROOT usage and documentation to services/ia_dev. - Add SSH remote data mirroring + optional AnythingLLM ingestion. - Extend AnythingLLM pull sync to support upload-all/prefix and fail on upload errors. - Harden smart-ide-sso-gateway and smart-ide-global-api proxying with safe-path checks and non-leaking error responses. - Improve ia-dev-gateway runner validation and reduce sensitive path leakage. - Add site scaffold tool (Vite/React) with OIDC + chat via sso-gateway -> orchestrator. Root cause: - Historical layout changes (submodule -> vendored tree) and missing central contracts for path resolution. - Missing validation for proxy path traversal patterns. - Overuse of silent fallbacks (|| true, exit 0 on partial failures) in automation scripts. Impacted features: - Project sync: git pull + AnythingLLM sync + remote data mirror ingestion. - Site frontends: SSO gateway proxy and orchestrator intents (rag.query, chat.local). - Agent execution: ia-dev-gateway script runner and SSE output. Code modified: - scripts/remote-data-ssh-sync.sh - scripts/anythingllm-pull-sync/sync.mjs - scripts/install-anythingllm-post-merge-hook.sh - cron/git-pull-project-clones.sh - services/smart-ide-sso-gateway/src/server.ts - services/smart-ide-global-api/src/server.ts - services/smart-ide-orchestrator/src/server.ts - services/ia-dev-gateway/src/server.ts - services/ia_dev/tools/site-generate.sh Documentation modified: - docs/** (architecture, API docs, ia_dev module + integration, scripts) Configurations modified: - config/services.local.env.example - services/*/.env.example Files in deploy modified: - services/ia_dev/deploy/* Files in logs impacted: - logs/ia_dev.log (runtime only) - .logs/* (runtime only) Databases and other sources modified: - None Off-project modifications: - None Files in .smartIde modified: - .smartIde/agents/*.md - services/ia_dev/.smartIde/** Files in .secrets modified: - None New patch version in VERSION: - 0.0.5 CHANGELOG.md updated: - yes
176 lines
4.2 KiB
Bash
Executable File
176 lines
4.2 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
ACTIVE_PROJECT_FILE="${ROOT}/projects/active-project.json"
|
|
|
|
usage() {
|
|
cat <<'EOF'
|
|
Usage:
|
|
./scripts/smart-ide-ssh-tunnel-plan.sh [--project <id>] [--env <test|pprod|prod>] [--mode <minimal|all>] [--json]
|
|
|
|
Purpose:
|
|
Print an SSH tunnel command to reach the Smart IDE services running on a remote host.
|
|
|
|
Project/env resolution (first match):
|
|
- --project / --env
|
|
- SMART_IDE_PROJECT_ID / SMART_IDE_ENV
|
|
- projects/active-project.json (local, gitignored)
|
|
|
|
The SSH target is read from:
|
|
projects/<id>/conf.json -> smart_ide.remote_data_access.environments.<env>.ssh_host_alias
|
|
|
|
Notes:
|
|
- This prints a command; it does not daemonize anything.
|
|
- Bind is limited to 127.0.0.1 on the client.
|
|
EOF
|
|
}
|
|
|
|
PROJECT_ID="${SMART_IDE_PROJECT_ID:-}"
|
|
ENV_NAME="${SMART_IDE_ENV:-}"
|
|
MODE="minimal"
|
|
AS_JSON="false"
|
|
|
|
while [[ $# -gt 0 ]]; do
|
|
case "$1" in
|
|
-h|--help)
|
|
usage
|
|
exit 0
|
|
;;
|
|
--project)
|
|
PROJECT_ID="${2:-}"
|
|
shift 2
|
|
;;
|
|
--env)
|
|
ENV_NAME="${2:-}"
|
|
shift 2
|
|
;;
|
|
--mode)
|
|
MODE="${2:-}"
|
|
shift 2
|
|
;;
|
|
--json)
|
|
AS_JSON="true"
|
|
shift 1
|
|
;;
|
|
*)
|
|
echo "Unknown argument: $1" >&2
|
|
usage >&2
|
|
exit 2
|
|
;;
|
|
esac
|
|
done
|
|
|
|
if ! command -v jq >/dev/null 2>&1; then
|
|
echo "Missing dependency: jq" >&2
|
|
exit 1
|
|
fi
|
|
|
|
if [[ -z "${PROJECT_ID}" ]] && [[ -f "${ACTIVE_PROJECT_FILE}" ]]; then
|
|
PROJECT_ID="$(jq -r '.id // empty' "${ACTIVE_PROJECT_FILE}")"
|
|
fi
|
|
|
|
if [[ -z "${ENV_NAME}" ]] && [[ -f "${ACTIVE_PROJECT_FILE}" ]]; then
|
|
ENV_NAME="$(jq -r '.default_env // empty' "${ACTIVE_PROJECT_FILE}")"
|
|
fi
|
|
|
|
if [[ -z "${PROJECT_ID}" ]]; then
|
|
echo "Missing project id. Provide --project <id> or create projects/active-project.json" >&2
|
|
exit 1
|
|
fi
|
|
|
|
if [[ -z "${ENV_NAME}" ]]; then
|
|
ENV_NAME="test"
|
|
fi
|
|
|
|
case "${ENV_NAME}" in
|
|
test|pprod|prod) ;;
|
|
*)
|
|
echo "Invalid --env: ${ENV_NAME} (expected test|pprod|prod)" >&2
|
|
exit 1
|
|
;;
|
|
esac
|
|
|
|
case "${MODE}" in
|
|
minimal|all) ;;
|
|
*)
|
|
echo "Invalid --mode: ${MODE} (expected minimal|all)" >&2
|
|
exit 1
|
|
;;
|
|
esac
|
|
|
|
CONF_FILE="${ROOT}/projects/${PROJECT_ID}/conf.json"
|
|
if [[ ! -f "${CONF_FILE}" ]]; then
|
|
echo "Missing project conf: ${CONF_FILE}" >&2
|
|
exit 1
|
|
fi
|
|
|
|
SSH_HOST_ALIAS="$(
|
|
jq -r ".smart_ide.remote_data_access.environments.${ENV_NAME}.ssh_host_alias // empty" "${CONF_FILE}"
|
|
)"
|
|
if [[ -z "${SSH_HOST_ALIAS}" ]] || [[ "${SSH_HOST_ALIAS}" == "null" ]]; then
|
|
echo "Missing ssh_host_alias for ${PROJECT_ID}/${ENV_NAME} in ${CONF_FILE}" >&2
|
|
exit 1
|
|
fi
|
|
|
|
declare -a forwards=()
|
|
|
|
add_forward() {
|
|
local port="$1"
|
|
forwards+=("-L" "127.0.0.1:${port}:127.0.0.1:${port}")
|
|
}
|
|
|
|
# Minimal: enough for Lapce to talk to orchestrator + agents + tools jobs via tunnel.
|
|
add_forward 37145 # smart-ide-orchestrator
|
|
add_forward 37144 # ia-dev-gateway
|
|
add_forward 37147 # smart-ide-tools-bridge
|
|
|
|
if [[ "${MODE}" == "all" ]]; then
|
|
add_forward 37149 # smart-ide-global-api (internal; mostly for debugging)
|
|
add_forward 37148 # smart-ide-sso-gateway (OIDC front)
|
|
add_forward 37146 # anythingllm-devtools
|
|
add_forward 37140 # repos-devtools-server
|
|
add_forward 37143 # agent-regex-search-api
|
|
add_forward 37141 # langextract-api
|
|
add_forward 37142 # claw-harness-proxy
|
|
add_forward 8000 # local-office (API)
|
|
add_forward 11434 # ollama (host service)
|
|
add_forward 3001 # anythingllm (host service, default docker)
|
|
fi
|
|
|
|
declare -a argv=(
|
|
ssh
|
|
-N
|
|
-o ExitOnForwardFailure=yes
|
|
-o BatchMode=yes
|
|
-o ServerAliveInterval=10
|
|
-o ServerAliveCountMax=6
|
|
"${forwards[@]}"
|
|
"${SSH_HOST_ALIAS}"
|
|
)
|
|
|
|
hint="Run in a dedicated terminal; stop with Ctrl+C. Ensure the local ports are free."
|
|
|
|
if [[ "${AS_JSON}" == "true" ]]; then
|
|
jq -n \
|
|
--arg projectId "${PROJECT_ID}" \
|
|
--arg env "${ENV_NAME}" \
|
|
--arg sshHostAlias "${SSH_HOST_ALIAS}" \
|
|
--arg mode "${MODE}" \
|
|
--arg hint "${hint}" \
|
|
--argjson argv "$(printf '%s\n' "${argv[@]}" | jq -R . | jq -s .)" \
|
|
'{ projectId: $projectId, env: $env, sshHostAlias: $sshHostAlias, mode: $mode, argv: $argv, hint: $hint }'
|
|
exit 0
|
|
fi
|
|
|
|
echo "projectId=${PROJECT_ID}"
|
|
echo "env=${ENV_NAME}"
|
|
echo "sshHostAlias=${SSH_HOST_ALIAS}"
|
|
echo "mode=${MODE}"
|
|
echo
|
|
printf '%q ' "${argv[@]}"
|
|
echo
|
|
echo
|
|
echo "${hint}"
|
|
|