local-operator-ui 0.31.0 → 0.31.1
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/out/main/index.js +3 -2
- package/out/renderer/assets/{_basePickBy-C4iSwCk_.js → _basePickBy-Crl5Z_Pk.js} +1 -1
- package/out/renderer/assets/{_baseUniq-CoR3b7Pb.js → _baseUniq-lQY3ywEZ.js} +1 -1
- package/out/renderer/assets/{agent-details-page-BrVmQlq3.js → agent-details-page-BzDE7WbM.js} +1 -1
- package/out/renderer/assets/{agent-hub-page-DhQgRhtE.js → agent-hub-page-DR48vILu.js} +1 -1
- package/out/renderer/assets/{agents-page-amh_zIfd.js → agents-page-BfwkfrEO.js} +2 -2
- package/out/renderer/assets/{arc-BgzcPy1_.js → arc-gshxvskr.js} +1 -1
- package/out/renderer/assets/{architectureDiagram-IEHRJDOE-DBQelo90.js → architectureDiagram-IEHRJDOE-C3dQvrMH.js} +1 -1
- package/out/renderer/assets/{blockDiagram-JOT3LUYC-B6Tj9M-m.js → blockDiagram-JOT3LUYC-DQTNXYLN.js} +1 -1
- package/out/renderer/assets/{book-open-BAndGvXv.js → book-open-CykMtqSE.js} +1 -1
- package/out/renderer/assets/browser-page-7T5O7_eK.js +1 -0
- package/out/renderer/assets/{browser-webauthn-prompt-DRUBwhbd.js → browser-webauthn-prompt-DzDALs8L.js} +1 -1
- package/out/renderer/assets/{c4Diagram-VJAJSXHY-DZffC4DW.js → c4Diagram-VJAJSXHY-DeNuMdtv.js} +1 -1
- package/out/renderer/assets/channel-B1YKOpml.js +1 -0
- package/out/renderer/assets/{chunk-4BMEZGHF-CzJZJ_Kr.js → chunk-4BMEZGHF-CfQJf7ZV.js} +1 -1
- package/out/renderer/assets/{chunk-A2AXSNBT-FDhQL1W7.js → chunk-A2AXSNBT-QLV_8ftp.js} +1 -1
- package/out/renderer/assets/{chunk-AEK57VVT-BSVY08cz.js → chunk-AEK57VVT-CYj_TvcV.js} +1 -1
- package/out/renderer/assets/{chunk-D6G4REZN-3NnvkvEu.js → chunk-D6G4REZN-BTwxHZFL.js} +1 -1
- package/out/renderer/assets/{chunk-RZ5BOZE2-B6vH5nHy.js → chunk-RZ5BOZE2-JwBm2JL9.js} +1 -1
- package/out/renderer/assets/{chunk-XZIHB7SX-DbDfwswt.js → chunk-XZIHB7SX-DPAqSKiB.js} +1 -1
- package/out/renderer/assets/classDiagram-GIVACNV2-BwbP74kr.js +1 -0
- package/out/renderer/assets/classDiagram-v2-COTLJTTW-BwbP74kr.js +1 -0
- package/out/renderer/assets/clone-CkMWxgkB.js +1 -0
- package/out/renderer/assets/{compact-pagination-DacmIceV.js → compact-pagination-B0hoPapl.js} +1 -1
- package/out/renderer/assets/{console-mirror-CzhHBJ89.js → console-mirror-naCglSJA.js} +1 -1
- package/out/renderer/assets/{consoleCapture-Ff67EfR-.js → consoleCapture-BmsgtbeJ.js} +1 -1
- package/out/renderer/assets/{dagre-OKDRZEBW-DcDJ_xq8.js → dagre-OKDRZEBW-BNS66odd.js} +1 -1
- package/out/renderer/assets/{diagram-SSKATNLV-B_9mY_Gx.js → diagram-SSKATNLV-TQ8UWNaL.js} +1 -1
- package/out/renderer/assets/{diagram-VNBRO52H-N-VUNAsp.js → diagram-VNBRO52H-zxD3pv8s.js} +1 -1
- package/out/renderer/assets/{erDiagram-Q7BY3M3F-CoBFM5wz.js → erDiagram-Q7BY3M3F-VXo3Cqqj.js} +1 -1
- package/out/renderer/assets/{error-boundary-OyyPDgmi.js → error-boundary-Du4Xf2hu.js} +17 -17
- package/out/renderer/assets/{flowDiagram-4HSFHLVR-U31R127Z.js → flowDiagram-4HSFHLVR-CAdzCrMJ.js} +1 -1
- package/out/renderer/assets/{ganttDiagram-APWFNJXF-B6HIP3LX.js → ganttDiagram-APWFNJXF-CGVbBlO6.js} +1 -1
- package/out/renderer/assets/{gitGraphDiagram-7IBYFJ6S-CLTQlpsI.js → gitGraphDiagram-7IBYFJ6S-DbLEZe6o.js} +1 -1
- package/out/renderer/assets/{graph-CPZjs5mz.js → graph-Do1SGRQn.js} +1 -1
- package/out/renderer/assets/{index-Dgpr-4wJ.js → index-1qEdZEMQ.js} +1 -1
- package/out/renderer/assets/{index-Brz4xf_N.js → index-CZlj7Oq2.js} +1 -1
- package/out/renderer/assets/{index-CE03vul4.js → index-DjpNajWu.js} +1 -1
- package/out/renderer/assets/index-OpIz2cV2.css +1 -0
- package/out/renderer/assets/{index-CXCGQLAf.js → index-YQ32HBTm.js} +401 -391
- package/out/renderer/assets/{infoDiagram-PH2N3AL5-Bn8r1GBu.js → infoDiagram-PH2N3AL5-CuB0GSNM.js} +1 -1
- package/out/renderer/assets/{installer-D8YScrG7.js → installer-Cu5fgVHl.js} +1 -1
- package/out/renderer/assets/{journeyDiagram-U35MCT3I-B90sRmxY.js → journeyDiagram-U35MCT3I-BqN69StY.js} +1 -1
- package/out/renderer/assets/{kanban-definition-NDS4AKOZ-CdQk4JVL.js → kanban-definition-NDS4AKOZ-CO2S4ykb.js} +1 -1
- package/out/renderer/assets/{layout-DKBN0F9A.js → layout-7oQ5xKpW.js} +1 -1
- package/out/renderer/assets/{legacy-agents-page-L5nl_vP8.js → legacy-agents-page-B-wHGQFq.js} +1 -1
- package/out/renderer/assets/{mermaid.core-D22o0-Xw.js → mermaid.core-SWP-HDAp.js} +5 -5
- package/out/renderer/assets/{mindmap-definition-ALO5MXBD-lMzKnedt.js → mindmap-definition-ALO5MXBD-ClOBpdLn.js} +1 -1
- package/out/renderer/assets/{page-header-BosNuEEY.js → page-header-dIIc14HB.js} +1 -1
- package/out/renderer/assets/parseISO-BWtr7JL9.js +1 -0
- package/out/renderer/assets/{pieDiagram-IB7DONF6-BPCgHz97.js → pieDiagram-IB7DONF6-UfaIVAHl.js} +1 -1
- package/out/renderer/assets/{publication-validation-B1Ho4y5X.js → publication-validation-7J4xzRVZ.js} +1 -1
- package/out/renderer/assets/{quadrantDiagram-7GDLP6J5-BN7q6nRl.js → quadrantDiagram-7GDLP6J5-CFqb2JGS.js} +1 -1
- package/out/renderer/assets/{radar-MK3ICKWK-DVteWlkm.js → radar-MK3ICKWK-B10S5swo.js} +1 -1
- package/out/renderer/assets/{radient-auth-buttons-DsuZI5F-.js → radient-auth-buttons-QWV7OGyX.js} +1 -1
- package/out/renderer/assets/{requirementDiagram-KVF5MWMF-B19ClXnf.js → requirementDiagram-KVF5MWMF-BK2G66d1.js} +1 -1
- package/out/renderer/assets/{sankeyDiagram-QLVOVGJD-gohXveM_.js → sankeyDiagram-QLVOVGJD-D6ZCPpc5.js} +1 -1
- package/out/renderer/assets/{schedules-page-BJYsnsA_.js → schedules-page-CWzMhoam.js} +5 -5
- package/out/renderer/assets/{sequenceDiagram-X6HHIX6F-DAxdPXaF.js → sequenceDiagram-X6HHIX6F-AtPuLuMe.js} +1 -1
- package/out/renderer/assets/{settings-page-Cn4iJPhy.js → settings-page-CAn17oJ5.js} +5 -5
- package/out/renderer/assets/{stateDiagram-DGXRK772-CmAoNGXc.js → stateDiagram-DGXRK772-CeU2ihmd.js} +1 -1
- package/out/renderer/assets/stateDiagram-v2-YXO3MK2T-a70Okwiy.js +1 -0
- package/out/renderer/assets/{timeline-definition-BDJGKUSR-Cxg2i86G.js → timeline-definition-BDJGKUSR-I9TCj8Py.js} +1 -1
- package/out/renderer/assets/{use-download-agent-mutation-B3fB2cnC.js → use-download-agent-mutation-9tp697PV.js} +1 -1
- package/out/renderer/assets/{xychartDiagram-VJFVF3MP-Bm7vUCym.js → xychartDiagram-VJFVF3MP-COG1JJYK.js} +1 -1
- package/out/renderer/console-capture.html +4 -4
- package/out/renderer/index.html +5 -5
- package/out/renderer/installer.html +4 -4
- package/package.json +32 -3
- package/out/renderer/assets/browser-page-DXM0wVmK.js +0 -1
- package/out/renderer/assets/channel-YJZLLu8D.js +0 -1
- package/out/renderer/assets/classDiagram-GIVACNV2-BA8uIyub.js +0 -1
- package/out/renderer/assets/classDiagram-v2-COTLJTTW-BA8uIyub.js +0 -1
- package/out/renderer/assets/clone-8Z28G76s.js +0 -1
- package/out/renderer/assets/index-DapmdGGl.css +0 -1
- package/out/renderer/assets/parseISO-CG_r30eq.js +0 -6
- package/out/renderer/assets/stateDiagram-v2-YXO3MK2T-DH3xoVHZ.js +0 -1
package/out/main/index.js
CHANGED
|
@@ -11201,7 +11201,7 @@ function managedPythonOptions() {
|
|
|
11201
11201
|
arch: process.arch
|
|
11202
11202
|
};
|
|
11203
11203
|
}
|
|
11204
|
-
const linuxInstallScriptRaw = '#!/bin/bash\n# Local Operator Backend Installation Script for Linux\n# This script sets up a virtual environment for the Local Operator backend\n# without requiring sudo or admin privileges.\n\n# Exit on error, undefined variables, and failed pipe commands\nset -e # Exit immediately if a command exits with a non-zero status\nset -u # Error on unset variables\nset -o pipefail # Fail if any command in a pipe fails\n\n# Configuration\n# Variables APP_NAME and MIN_PYTHON_VERSION removed as they were unused\nVENV_NAME="local-operator-venv"\nAPP_DATA_DIR="${HOME}/.config/local-operator"\nVENV_PATH="${APP_DATA_DIR}/${VENV_NAME}"\nLOG_FILE="${APP_DATA_DIR}/backend-install.log"\nTIMESTAMP=$(date +"%Y-%m-%d_%H-%M-%S")\n\n# Which environment this installs into - the app\'s decision, handed in. See the\n# macOS script for why the script must not re-derive it (a packaged and an\n# unpackaged instance use different environments, and only the app knows which\n# it is); `LOCAL_OPERATOR_VENV_PATH` is set from `managedVenvPath`.\n: "${LOCAL_OPERATOR_VENV_PATH:=$VENV_PATH}"\nVENV_PATH="$LOCAL_OPERATOR_VENV_PATH"\n\n# Keep CPython\'s bytecode cache out of the application directory.\n#\n# Same reason as the macOS script: an interpreter writing __pycache__/*.pyc\n# beside its own stdlib sources writes into the installed tree. Linux does not\n# code-seal the app the way macOS does, so this is uniformity and hygiene here\n# rather than the load-bearing fix it is on macOS - but it is also the value a\n# standalone run of this script has to agree with, because the app and the\n# script must not disagree about where bytecode goes.\n: "${PYTHONPYCACHEPREFIX:=${APP_DATA_DIR}/python-bytecode-cache}"\nexport PYTHONPYCACHEPREFIX\n\n# The refusal half of the pair, set rather than merged with whatever the caller\n# had: CPython reads the flag before its first import, so nothing this script\n# runs - `-m venv`, pip, the venv they create - can write a `__pycache__` at\n# all. Kept in step with the app\'s `withPythonBytecodeCache`, which sets both\n# variables on every python it spawns.\nexport PYTHONDONTWRITEBYTECODE=1\n\n# Create app data directory if it doesn\'t exist\nif ! mkdir -p "${APP_DATA_DIR}"; then\n echo "ERROR: Unable to create app data directory at ${APP_DATA_DIR}"\n echo "Please check permissions and try again."\n exit 1\nfi\n\n# Handle cleanup on script exit\ncleanup() {\n # Remove any temporary files created during execution\n if [ -f "${APP_DATA_DIR}/get-pip.py" ]; then\n rm -f "${APP_DATA_DIR}/get-pip.py"\n fi\n echo "$(date): Cleanup completed."\n}\n\n# Set trap only for manual interruption (SIGINT, SIGTERM), not normal exits\ntrap cleanup SIGINT SIGTERM\n\n\n# Start logging\nexec > >(tee -a "${LOG_FILE}") 2>&1\necho "[${TIMESTAMP}]: Starting Local Operator backend installation..."\necho "[${TIMESTAMP}]: System information: $(uname -a)"\n\n# Nothing is fetched here but the package itself.\n#\n# This script used to download a third-party FFmpeg binary from a GitHub release\n# into `${APP_DATA_DIR}/bin`, and under `set -e` a failed download killed the\n# install before the venv existed - so a machine that can reach PyPI but not\n# github.com could not install at all. Nothing in the app or in `local-operator`\n# ever executed that binary. Tooling a task actually needs is acquired later, on\n# demand, through the app\'s Console with the user\'s approval; this script\'s job is\n# the environment below and nothing else. (`_log_internal`, the logging helper\n# that read like a second `log` and existed only for that section, went with it.)\n# Function to check if a command exists\ncommand_exists() {\n command -v "$1" >/dev/null 2>&1\n}\n\n# Function to log messages with timestamp\nlog() {\n local timestamp\n timestamp=$(date +"%Y-%m-%d %H:%M:%S")\n echo "[${timestamp}] $1"\n}\n\n# Function to display error messages and exit\nerror_exit() {\n log "ERROR: $1" >&2\n exit "${2:-1}"\n}\n\n# Function to check if Python binary is valid for current architecture\nis_valid_python_binary() {\n local python_path="$1"\n \n # First check if file exists and is executable\n if [ ! -f "${python_path}" ] || [ ! -x "${python_path}" ]; then\n return 1\n fi\n \n # Try to run a simple Python command to verify it works on current architecture\n "${python_path}" -c "print(\'Testing Python executable\')" >/dev/null 2>&1\n return $?\n}\n\n# Check for network connectivity to key servers.\n#\n# Bounded on both spellings: `--connect-timeout 5`/`--max-time 30` for curl and\n# `--timeout=30`/`--tries=1` for wget (a single attempt, whose timeout covers\n# connect and read since wget has no separate connect bound for BusyBox). 5 ends\n# a black-hole network; 30 is the stall bound and is deliberately well above a\n# slow-but-working link\'s answer time, because a probe that fails a working\n# connection is noise users learn to ignore.\n#\n# `--fail` turns an HTTP error status into a non-zero exit (a proxy\'s 403/407,\n# any 4xx/5xx). It does NOT notice a captive portal answering 200 with its own\n# HTML page - measured, a portal-shaped 200 exits 0 with and without the flag -\n# so this check answers "did a request to the host complete", and the PyPI probe\n# below is the one that also checks WHAT came back.\ncheck_connectivity() {\n log "Checking network connectivity..."\n local servers=("pypi.org" "bootstrap.pypa.io")\n local has_connectivity=false\n \n for server in "${servers[@]}"; do\n if command_exists curl; then\n if curl --fail --connect-timeout 5 --max-time 30 -s "https://${server}" -o /dev/null; then\n has_connectivity=true\n break\n fi\n elif command_exists wget; then\n if wget --timeout=30 --tries=1 -q --spider "https://${server}"; then\n has_connectivity=true\n break\n fi\n fi\n done\n \n if [ "$has_connectivity" = false ]; then\n log "WARNING: Network connectivity issues detected. This may affect installation."\n else\n log "Network connectivity confirmed."\n fi\n}\n\n# Call connectivity check\ncheck_connectivity\n\n# Check if PYTHON_BIN is already set by the installer\nif [ -n "${PYTHON_BIN:-}" ]; then\n log "Using Python executable provided by installer: ${PYTHON_BIN}"\n # Verify the provided Python binary works on this architecture\n if ! is_valid_python_binary "${PYTHON_BIN}"; then\n log "Warning: The provided Python binary is not compatible with this system architecture."\n log "Will attempt to find a system Python installation instead."\n PYTHON_BIN=""\n fi\nfi\n\n# If PYTHON_BIN is empty or invalid, try to find a suitable Python installation\nif [ -z "${PYTHON_BIN:-}" ] || ! is_valid_python_binary "${PYTHON_BIN:-}"; then\n # Try to find a suitable Python installation\n log "Looking for a suitable Python installation..."\n \n # Try multiple possible locations to find Python\n POSSIBLE_PYTHON_PATHS=(\n # System paths first (more likely to be compatible with current architecture)\n "/usr/local/bin/python3.12"\n "/usr/bin/python3.12"\n "/usr/local/bin/python3"\n "/usr/bin/python3"\n # From environment variable (set by the installer)\n "${ELECTRON_RESOURCE_PATH:-}/python/bin/python3"\n # Development paths\n "$(dirname "$0")/../../../resources/python/bin/python3"\n "$(pwd)/resources/python/bin/python3"\n )\n\n # Find the first Python that exists and is version 3.12+ and works on this architecture\n PYTHON_BIN=""\n for path in "${POSSIBLE_PYTHON_PATHS[@]}"; do\n # Skip empty paths that might come from unset environment variables\n if [ -z "${path}" ]; then\n continue\n fi\n \n if is_valid_python_binary "${path}"; then\n # Check Python version\n if PY_VERSION=$("${path}" -c "import sys; print(f\'{sys.version_info.major}.{sys.version_info.minor}\')" 2>/dev/null); then\n MAJOR=$(echo "${PY_VERSION}" | cut -d. -f1)\n MINOR=$(echo "${PY_VERSION}" | cut -d. -f2)\n if [ "${MAJOR}" -eq 3 ] && [ "${MINOR}" -ge 12 ]; then\n PYTHON_BIN="${path}"\n log "Found suitable Python ${PY_VERSION} at ${path}"\n break\n else\n log "Python at ${path} is version ${PY_VERSION}, which is below the required 3.12+"\n fi\n fi\n else\n if [ -f "${path}" ]; then\n log "Python at ${path} exists but is not compatible with this system architecture"\n fi\n fi\n done\n\n # If we couldn\'t find a suitable Python, exit with error\n if [ -z "${PYTHON_BIN:-}" ]; then\n error_exit "No suitable Python installation found (version 3.12 or higher required).\\nPlease install Python 3.12 or higher before running this script.\\nYou can install Python from https://www.python.org/downloads/"\n fi\nfi\n\necho "Using Python: $PYTHON_BIN"\n"$PYTHON_BIN" --version || {\n echo "Error: Failed to run Python. Please ensure it is executable and accessible."\n echo "System architecture: $(uname -m)"\n echo "Python binary architecture: $(file "$PYTHON_BIN" 2>/dev/null || echo \'Unable to determine\')"\n exit 1\n}\n\n# Detect the Linux distribution to provide specific instructions\nif command_exists lsb_release; then\n DISTRO=$(lsb_release -is)\n DISTRO_VERSION=$(lsb_release -rs)\n echo "Detected Linux distribution: $DISTRO $DISTRO_VERSION"\nelif [ -f /etc/os-release ]; then\n DISTRO=$(grep -oP \'(?<=^ID=).+\' /etc/os-release | tr -d \'"\')\n DISTRO_VERSION=$(grep -oP \'(?<=^VERSION_ID=).+\' /etc/os-release | tr -d \'"\')\n echo "Detected Linux distribution: $DISTRO $DISTRO_VERSION"\nelse\n DISTRO="unknown"\n echo "Unable to detect Linux distribution"\nfi\n\n# Check if Python has venv module and ensurepip available\nlog "Checking for venv module and ensurepip availability..."\nVENV_AVAILABLE=0\nENSUREPIP_AVAILABLE=0\n\n"${PYTHON_BIN}" -c "import venv" > /dev/null 2>&1 || VENV_AVAILABLE=1\n"${PYTHON_BIN}" -c "import ensurepip" > /dev/null 2>&1 || ENSUREPIP_AVAILABLE=1\n\n# If venv is still not available, try to use virtualenv as a fallback\nif [ $VENV_AVAILABLE -ne 0 ]; then\n echo "venv module is not available. Checking for virtualenv as an alternative..."\n \n # Check if virtualenv is already installed\n if "$PYTHON_BIN" -c "import virtualenv" > /dev/null 2>&1; then\n echo "virtualenv is available, will use it instead of venv"\n else\n echo "ERROR: Neither venv nor virtualenv is available."\n echo "Python 3.12 and venv should be installed as package dependencies."\n echo "Please ensure Python 3.12 and venv are properly installed on your system."\n exit 1\n fi\nfi\n\n# Create virtual environment if it doesn\'t exist\nif [ ! -d "$VENV_PATH" ]; then\n echo "|LO1:environment"\n echo "Creating virtual environment at $VENV_PATH..."\n # Remove any potentially corrupted virtual environment\n if [ -e "$VENV_PATH" ]; then\n echo "Removing existing but potentially corrupted venv directory..."\n rm -rf "$VENV_PATH"\n fi\n \n # Make sure parent directory exists and is writable\n mkdir -p "$(dirname "$VENV_PATH")"\n \n # Try different methods to create a virtual environment\n VENV_CREATE_STATUS=1\n \n # First try with venv if available\n if [ $VENV_AVAILABLE -eq 0 ] && [ $ENSUREPIP_AVAILABLE -eq 0 ]; then\n echo "Creating virtual environment using venv module..."\n "$PYTHON_BIN" -m venv "$VENV_PATH"\n VENV_CREATE_STATUS=$?\n fi\n \n # If venv failed, try virtualenv\n if [ $VENV_CREATE_STATUS -ne 0 ]; then\n echo "venv creation failed with status $VENV_CREATE_STATUS. Falling back to virtualenv..."\n if command_exists virtualenv; then\n virtualenv -p "$PYTHON_BIN" "$VENV_PATH"\n VENV_CREATE_STATUS=$?\n elif "$PYTHON_BIN" -m pip list | grep -q virtualenv; then\n "$PYTHON_BIN" -m virtualenv -p "$PYTHON_BIN" "$VENV_PATH"\n VENV_CREATE_STATUS=$?\n else\n echo "ERROR: Both venv and virtualenv are unavailable or failed."\n echo "Python 3.12 and venv should be installed as package dependencies."\n echo "Please ensure Python 3.12 and venv are properly installed on your system."\n echo "You can install Python 3.12 from https://www.python.org/downloads/"\n exit 1\n fi\n fi\n \n # Check if virtual environment creation was successful\n if [ $VENV_CREATE_STATUS -ne 0 ]; then\n log "ERROR: Failed to create virtual environment. Exit code: $VENV_CREATE_STATUS"\n log "Virtual environment path: $VENV_PATH"\n log "Python binary used: $PYTHON_BIN"\n ls -la "$(dirname "$VENV_PATH")" || true\n log "Python executable permissions:"\n ls -la "$PYTHON_BIN" || true\n \n # Check for common issues\n log "Checking for common virtual environment creation issues..."\n \n # Check disk space\n df -h "$(dirname "$VENV_PATH")" || true\n \n # Check if directory is writable\n if [ ! -w "$(dirname "$VENV_PATH")" ]; then\n log "ERROR: Directory $(dirname "$VENV_PATH") is not writable"\n fi\n \n # Try to create a minimal virtual environment manually as a last resort\n log "Attempting to create a minimal virtual environment manually..."\n mkdir -p "$VENV_PATH/bin" || error_exit "Could not create directory $VENV_PATH/bin"\n echo "#!/bin/bash" > "$VENV_PATH/bin/activate"\n echo "export VIRTUAL_ENV=\\"$VENV_PATH\\"" >> "$VENV_PATH/bin/activate"\n echo "export PATH=\\"$VENV_PATH/bin:\\$PATH\\"" >> "$VENV_PATH/bin/activate"\n echo "unset PYTHONHOME" >> "$VENV_PATH/bin/activate"\n chmod +x "$VENV_PATH/bin/activate" || error_exit "Could not set execute permissions on activate script"\n \n # Create symlinks to the system Python\n ln -sf "$PYTHON_BIN" "$VENV_PATH/bin/python" || log "WARNING: Failed to create symlink for python"\n ln -sf "$PYTHON_BIN" "$VENV_PATH/bin/python3" || log "WARNING: Failed to create symlink for python3"\n \n # Try to bootstrap pip\n log "Bootstrapping pip in the minimal virtual environment..."\n if command_exists curl; then\n curl -s --fail --connect-timeout 10 --max-time 60 https://bootstrap.pypa.io/get-pip.py -o "$APP_DATA_DIR/get-pip.py" || log "WARNING: Failed to download get-pip.py"\n elif command_exists wget; then\n wget -q --timeout=30 --tries=1 -O "$APP_DATA_DIR/get-pip.py" https://bootstrap.pypa.io/get-pip.py || log "WARNING: Failed to download get-pip.py"\n else\n log "ERROR: Neither curl nor wget available to download get-pip.py"\n error_exit "Installation cannot continue without being able to download pip"\n fi\n \n # shellcheck disable=SC1090\n source "$VENV_PATH/bin/activate" && python "$APP_DATA_DIR/get-pip.py" --no-warn-script-location\n \n if [ ! -f "$VENV_PATH/bin/pip" ]; then\n error_exit "Failed to create even a minimal virtual environment."\n else\n log "Created a minimal virtual environment as a fallback."\n fi\n else\n log "Successfully created virtual environment"\n fi\nfi\n\n# Verify the virtual environment structure\necho "Verifying virtual environment structure..."\nif [ ! -f "$VENV_PATH/bin/python" ]; then\n echo "Python executable missing in virtual environment, creating symlink..."\n ln -sf "$PYTHON_BIN" "$VENV_PATH/bin/python"\nfi\n\nif [ ! -f "$VENV_PATH/bin/pip" ]; then\n echo "pip missing in virtual environment, attempting to bootstrap it..."\n curl -s --fail --connect-timeout 10 --max-time 60 https://bootstrap.pypa.io/get-pip.py -o "$APP_DATA_DIR/get-pip.py"\n "$VENV_PATH/bin/python" "$APP_DATA_DIR/get-pip.py" --no-warn-script-location\n \n if [ ! -f "$VENV_PATH/bin/pip" ]; then\n echo "ERROR: Failed to bootstrap pip in the virtual environment"\n exit 1\n fi\nfi\n\necho "Virtual environment structure verified"\n\n# --- The package install: uv when there is one, pip otherwise ------------------\n#\n# Same shape as the macOS script, and for the same reasons: uv resolves and\n# fetches in parallel - measured there, cold cache, three runs each, same\n# interpreter: uv\'s package install is 12.8-16.1 s against pip\'s 33.0-40.7 s,\n# plus the 2.3-2.8 s pip self-upgrade this path skips, so 1.5-2.8x across two\n# operators rather than the "14.8 s against 128.9 s" quoted here before that\n# reading was withdrawn (`docs/BUILD.md` has the full set). The pip path below is\n# unchanged and runs whenever uv is absent or cannot do the job, and pip STAYS in the venv\n# because the app\'s backend-update path runs `pip install --upgrade\n# local-operator` inside this same environment - which is also why the venv is\n# still created with `python -m venv` rather than `uv venv`.\n#\n# Nothing here searches PATH for a uv: an installed uv is a version and a\n# configuration nobody in this repository chose. `LOCAL_OPERATOR_UV_BIN` is the\n# app\'s own answer (`src/main/backend/uv-tool.ts`).\nUV_BIN="${LOCAL_OPERATOR_UV_BIN:-}"\n\n# Drop every UV_* variable the launching environment carried. Measured on uv\n# 0.12.17: a user-level `uv.toml` naming an unreachable index is obeyed by\n# `uv pip install` and ignored with `UV_NO_CONFIG=1`; an ambient `UV_INDEX_URL`\n# changes where packages come from, while `PIP_INDEX_URL` does not affect uv at\n# all. A name list would drift the day uv adds a variable - the namespace cannot.\n#\n# IT RUNS BEFORE THE SETTINGS BELOW ARE SET: a sweep after them takes them away,\n# and an empty `UV_CACHE_DIR` makes uv exit 2 with `a value is required for\n# \'--cache-dir <CACHE_DIR>\'` rather than falling back to a default.\nfor uv_ambient in $(env | sed -n \'s/^\\(UV_[A-Za-z0-9_]*\\)=.*/\\1/p\'); do\n unset "$uv_ambient"\ndone\n\n# The cache lives under the app\'s own support directory rather than the user\'s\n# shared `~/.cache/uv`, and is handed to uv per invocation rather than exported.\n# It persists (~118 MB for a full install, measured on macOS) and nothing else\n# reads it today; it is what makes a retry converge in seconds rather than tens\n# of seconds.\nUV_CACHE_DIR="${APP_DATA_DIR}/uv-cache"\n\n# Is the handed-down uv something we can actually run?\nuv_is_usable() {\n [ -n "${UV_BIN}" ] && [ -x "${UV_BIN}" ] && "${UV_BIN}" --version >/dev/null 2>&1\n}\n\n# UV_NO_CONFIG: never read `pyproject.toml`/`uv.toml`, wherever they are.\n# UV_PYTHON_DOWNLOADS=never: this install uses the interpreter it was handed and\n# never fetches another.\nuv_run() {\n UV_NO_CONFIG=1 UV_PYTHON_DOWNLOADS=never UV_CACHE_DIR="${UV_CACHE_DIR}" \\\n "${UV_BIN}" "$@"\n}\n\n# Activate virtual environment and install local-operator\necho "Installing local-operator in virtual environment..."\nsource "$VENV_PATH/bin/activate"\n\n# Check network connectivity to PyPI. A DIAGNOSTIC, not a gate: the install below\n# decides whether it can proceed.\n#\n# What this answers, stated precisely because an earlier version of this comment\n# claimed more than the flags buy: "did a TLS fetch to PyPI\'s JSON API complete,\n# and did the answer come back as JSON?". `--fail` turns an HTTP ERROR status\n# into a non-zero exit, and does NOT notice a captive portal answering 200 with\n# its own HTML page (measured: a portal-shaped 200 exits 0 with and without the\n# flag). Both spellings therefore check the CONTENT TYPE as well, since a portal\n# that reports "reachable" while pip is about to fail is the false negative this\n# warning exists to catch: curl through `-w \'%{content_type}\'`, and wget through\n# the response headers `-S` prints (`-S`/`--server-response` is in BusyBox\'s wget\n# since 2017 as well as GNU\'s, which is the wget a system without curl has).\n#\n# What the content type does NOT prove, stated so this paragraph is not read as\n# more than it says: a proxy answering 200 with `application/json` and an error\n# body (`{"detail":"blocked by proxy policy"}`) is silent here, because the\n# answer did come back as JSON. Only parsing the body - a fetch of PyPI\'s own\n# payload shape - would tell those apart, and a diagnostic that costs a parse is\n# not what stands in front of an install.\n#\n# Two bounds, two jobs: the connect bound ends a black-hole network, the total\n# stops a connected-but-stalled peer. Both must be POSITIVE - `--max-time 0` and\n# `--timeout=0` disable the bound rather than making it immediate on both curl and\n# wget. 30 rather than 10 because the total must not fire on a slow-but-working\n# link: a working endpoint that answered in 15s tripped a 10s bound and printed\n# this warning on an install that then succeeded.\necho "Checking network connectivity to PyPI..."\nif command_exists curl; then\n PYPI_PROBE_CONTENT_TYPE=$(curl -s --fail --connect-timeout 5 --max-time 30 -o /dev/null -w \'%{content_type}\' https://pypi.org/pypi/local-operator/json) || PYPI_PROBE_CONTENT_TYPE=""\n if [[ "${PYPI_PROBE_CONTENT_TYPE}" != application/json* ]]; then\n echo "WARNING: Could not reach PyPI. Network connectivity issues might prevent installation."\n fi\nelif command_exists wget; then\n # The headers are captured into a variable and matched with a here-string\n # rather than piped into `grep -q`: `-q` exits on the first match, the closed\n # pipe gives wget SIGPIPE, and the script runs under `set -o pipefail`, so a\n # WORKING link printed this warning whenever the match landed before wget had\n # finished writing its headers. The piped shape was this remediation\'s own - the\n # first fix piped it and was measured warning 1 time in 20 against real PyPI\n # (and 1 in 20 against a healthy local endpoint) while this shape warns 0 in 40\n # with the same flags - so the trap is recorded here because it is one line away\n # from being reintroduced, not because the released script ever shipped it.\n PYPI_PROBE_HEADERS=$(wget -q -S --spider --timeout=30 --tries=1 https://pypi.org/pypi/local-operator/json 2>&1) || PYPI_PROBE_HEADERS=""\n if ! grep -qi \'^ *content-type: application/json\' <<< "$PYPI_PROBE_HEADERS"; then\n echo "WARNING: Could not reach PyPI. Network connectivity issues might prevent installation."\n fi\nfi\n\n# --- Progress markers -------------------------------------------------------\n# One whole line per phase, read by the app and shown in the setup window. The\n# app matches the ENTIRE line (`|LO1:<phase>`, see src/shared/install-progress.ts)\n# and never a substring, so a marker has to stand alone: do not wrap it in\n# other text, do not re-indent it into a longer sentence, and do not emit one\n# for work this script does not actually do. A missing marker leaves the window\n# on its previous step, which is the honest failure; a marker a log line also\n# happens to produce is a wrong step presented as a measurement.\n#\n# WHY THE SCRIPT AND NOT ONLY THE APP: the install below is minutes of work on a\n# cold machine, and the app cannot see inside the venv it is about to create -\n# this is the only process that knows when the environment exists and when the\n# download starts.\necho "|LO1:components"\nUV_INSTALLED=false\nif uv_is_usable; then\n echo "Installing local-operator with uv ($("${UV_BIN}" --version 2>/dev/null || echo \'version unavailable\'))..."\n # No `pip install --upgrade pip` on this path: uv does not use pip.\n if uv_run pip install --python "${VENV_PATH}/bin/python" --upgrade local-operator; then\n UV_INSTALLED=true\n echo "local-operator installation with uv successful"\n else\n # The exit code matters here for the same reason it does on macOS: the\n # fallback is deliberately forgiving, so this line is the only evidence that\n # a bundled uv is present and failing for every user (QA Q2).\n UV_STATUS=$?\n echo "WARNING: the bundled uv is present but its install failed (exit ${UV_STATUS}); retrying with pip, which is what this script used before uv was bundled."\n fi\nelse\n echo "Bundled uv not available (LOCAL_OPERATOR_UV_BIN=${UV_BIN:-unset}); installing with pip."\nfi\n\nif [ "${UV_INSTALLED}" != true ]; then\n echo "Upgrading pip..."\n python -m pip install --upgrade pip || {\n echo "WARNING: Failed to upgrade pip. Will try to continue with existing pip version."\n pip --version\n }\n\n echo "Installing local-operator package..."\n python -m pip install --verbose local-operator || {\n echo "ERROR: Failed to install local-operator package. Exit code: $?"\n echo "Python version:"\n python --version\n echo "pip version:"\n pip --version\n echo "Available pip packages:"\n pip list\n exit 1\n }\nfi\necho "local-operator installation successful"\n\n# Verify installation\nif [ -f "$VENV_PATH/bin/local-operator" ]; then\n log "Local Operator backend installed successfully!"\n \n # Show more information about the installed binary\n ls -la "$VENV_PATH/bin/local-operator" || true\n file "$VENV_PATH/bin/local-operator" 2>/dev/null || log "Note: \'file\' command not available"\n \n # Try to run the version command with full error output\n log "Testing local-operator binary..."\n "$VENV_PATH/bin/local-operator" --version || {\n log "ERROR: local-operator binary exists but failed to execute. Exit code: $?"\n log "Binary details:"\n file "$VENV_PATH/bin/local-operator" 2>/dev/null || log "Note: \'file\' command not available"\n log "Binary permissions:"\n ls -la "$VENV_PATH/bin/local-operator" || true\n log ""\n log "This could be due to missing dependencies or architecture incompatibility."\n log "Try running the binary manually to see specific errors."\n \n # Don\'t exit here - just warn the user\n log "WARNING: Installation completed but binary verification failed."\n }\n \n # Create a summary of the installation\n SUMMARY_FILE="${APP_DATA_DIR}/installation-summary-${TIMESTAMP}.txt"\n {\n echo "=== Local Operator Backend Installation Summary ==="\n echo "Timestamp: $(date)"\n echo "Python Version: $("${PYTHON_BIN}" --version 2>&1)"\n echo "Virtual Environment: ${VENV_PATH}"\n echo "Binary Location: ${VENV_PATH}/bin/local-operator"\n echo "To activate the virtual environment, run: source ${VENV_PATH}/bin/activate"\n echo "To test the installation, run: ${VENV_PATH}/bin/local-operator --version"\n echo "Log file: ${LOG_FILE}"\n echo "=================================================="\n } > "${SUMMARY_FILE}"\n \n log "Installation summary saved to: ${SUMMARY_FILE}"\nelse\n log "Error: Failed to install Local Operator backend. Binary not found."\n log "Contents of bin directory:"\n ls -la "$VENV_PATH/bin/" || true\n log "Check the log file for details: ${LOG_FILE}"\n error_exit "Installation failed. Binary not installed properly."\nfi\n\nlog "Installation completed successfully at $(date)"\n\n# Clean up temporary files now that installation is complete\ncleanup\n\n# Print final instructions\nlog ""\nlog "=== INSTALLATION COMPLETE ==="\nlog "You can now use the Local Operator backend by running: ${VENV_PATH}/bin/local-operator"\nlog "Installation directory: ${VENV_PATH}"\nlog "Log file: ${LOG_FILE}"\nlog "================================"\n';
|
|
11204
|
+
const linuxInstallScriptRaw = '#!/bin/bash\n# Local Operator Backend Installation Script for Linux\n# This script sets up a virtual environment for the Local Operator backend\n# without requiring sudo or admin privileges.\n\n# Exit on error, undefined variables, and failed pipe commands\nset -e # Exit immediately if a command exits with a non-zero status\nset -u # Error on unset variables\nset -o pipefail # Fail if any command in a pipe fails\n\n# Configuration\n# Variables APP_NAME and MIN_PYTHON_VERSION removed as they were unused\nVENV_NAME="local-operator-venv"\nAPP_DATA_DIR="${HOME}/.config/local-operator"\nVENV_PATH="${APP_DATA_DIR}/${VENV_NAME}"\nLOG_FILE="${APP_DATA_DIR}/backend-install.log"\nTIMESTAMP=$(date +"%Y-%m-%d_%H-%M-%S")\n\n# Which environment this installs into - the app\'s decision, handed in. See the\n# macOS script for why the script must not re-derive it (a packaged and an\n# unpackaged instance use different environments, and only the app knows which\n# it is); `LOCAL_OPERATOR_VENV_PATH` is set from `managedVenvPath`.\n: "${LOCAL_OPERATOR_VENV_PATH:=$VENV_PATH}"\nVENV_PATH="$LOCAL_OPERATOR_VENV_PATH"\n\n# Keep CPython\'s bytecode cache out of the application directory.\n#\n# Same reason as the macOS script: an interpreter writing __pycache__/*.pyc\n# beside its own stdlib sources writes into the installed tree. Linux does not\n# code-seal the app the way macOS does, so this is uniformity and hygiene here\n# rather than the load-bearing fix it is on macOS - but it is also the value a\n# standalone run of this script has to agree with, because the app and the\n# script must not disagree about where bytecode goes.\n: "${PYTHONPYCACHEPREFIX:=${APP_DATA_DIR}/python-bytecode-cache}"\nexport PYTHONPYCACHEPREFIX\n\n# The refusal half of the pair, set rather than merged with whatever the caller\n# had: CPython reads the flag before its first import, so nothing this script\n# runs - `-m venv`, pip, the venv they create - can write a `__pycache__` at\n# all. Kept in step with the app\'s `withPythonBytecodeCache`, which sets both\n# variables on every python it spawns.\nexport PYTHONDONTWRITEBYTECODE=1\n\n# Create app data directory if it doesn\'t exist\nif ! mkdir -p "${APP_DATA_DIR}"; then\n echo "ERROR: Unable to create app data directory at ${APP_DATA_DIR}"\n echo "Please check permissions and try again."\n exit 1\nfi\n\n# Handle cleanup on script exit\ncleanup() {\n # Remove any temporary files created during execution\n if [ -f "${APP_DATA_DIR}/get-pip.py" ]; then\n rm -f "${APP_DATA_DIR}/get-pip.py"\n fi\n echo "$(date): Cleanup completed."\n}\n\n# Set trap only for manual interruption (SIGINT, SIGTERM), not normal exits\ntrap cleanup SIGINT SIGTERM\n\n\n# Start logging\nexec > >(tee -a "${LOG_FILE}") 2>&1\necho "[${TIMESTAMP}]: Starting Local Operator backend installation..."\necho "[${TIMESTAMP}]: System information: $(uname -a)"\n\n# Nothing is fetched here but the package itself.\n#\n# This script used to download a third-party FFmpeg binary from a GitHub release\n# into `${APP_DATA_DIR}/bin`, and under `set -e` a failed download killed the\n# install before the venv existed - so a machine that can reach PyPI but not\n# github.com could not install at all. Nothing in the app or in `local-operator`\n# ever executed that binary. Tooling a task actually needs is acquired later, on\n# demand, through the app\'s Console with the user\'s approval; this script\'s job is\n# the environment below and nothing else. (`_log_internal`, the logging helper\n# that read like a second `log` and existed only for that section, went with it.)\n# Function to check if a command exists\ncommand_exists() {\n command -v "$1" >/dev/null 2>&1\n}\n\n# Function to log messages with timestamp\nlog() {\n local timestamp\n timestamp=$(date +"%Y-%m-%d %H:%M:%S")\n echo "[${timestamp}] $1"\n}\n\n# Function to display error messages and exit\nerror_exit() {\n log "ERROR: $1" >&2\n exit "${2:-1}"\n}\n\n# Function to check if Python binary is valid for current architecture\nis_valid_python_binary() {\n local python_path="$1"\n \n # First check if file exists and is executable\n if [ ! -f "${python_path}" ] || [ ! -x "${python_path}" ]; then\n return 1\n fi\n \n # Try to run a simple Python command to verify it works on current architecture\n "${python_path}" -c "print(\'Testing Python executable\')" >/dev/null 2>&1\n return $?\n}\n\n# Check for network connectivity to key servers.\n#\n# Bounded on both spellings: `--connect-timeout 5`/`--max-time 30` for curl and\n# `--timeout=30`/`--tries=1` for wget (a single attempt, whose timeout covers\n# connect and read since wget has no separate connect bound for BusyBox). 5 ends\n# a black-hole network; 30 is the stall bound and is deliberately well above a\n# slow-but-working link\'s answer time, because a probe that fails a working\n# connection is noise users learn to ignore.\n#\n# `--fail` turns an HTTP error status into a non-zero exit (a proxy\'s 403/407,\n# any 4xx/5xx). It does NOT notice a captive portal answering 200 with its own\n# HTML page - measured, a portal-shaped 200 exits 0 with and without the flag -\n# so this check answers "did a request to the host complete", and the PyPI probe\n# below is the one that also checks WHAT came back.\ncheck_connectivity() {\n log "Checking network connectivity..."\n local servers=("pypi.org" "bootstrap.pypa.io")\n local has_connectivity=false\n \n for server in "${servers[@]}"; do\n if command_exists curl; then\n if curl --fail --connect-timeout 5 --max-time 30 -s "https://${server}" -o /dev/null; then\n has_connectivity=true\n break\n fi\n elif command_exists wget; then\n if wget --timeout=30 --tries=1 -q --spider "https://${server}"; then\n has_connectivity=true\n break\n fi\n fi\n done\n \n if [ "$has_connectivity" = false ]; then\n log "WARNING: Network connectivity issues detected. This may affect installation."\n else\n log "Network connectivity confirmed."\n fi\n}\n\n# Call connectivity check\ncheck_connectivity\n\n# Check if PYTHON_BIN is already set by the installer\nif [ -n "${PYTHON_BIN:-}" ]; then\n log "Using Python executable provided by installer: ${PYTHON_BIN}"\n # Verify the provided Python binary works on this architecture\n if ! is_valid_python_binary "${PYTHON_BIN}"; then\n log "Warning: The provided Python binary is not compatible with this system architecture."\n log "Will attempt to find a system Python installation instead."\n PYTHON_BIN=""\n fi\nfi\n\n# If PYTHON_BIN is empty or invalid, try to find a suitable Python installation\nif [ -z "${PYTHON_BIN:-}" ] || ! is_valid_python_binary "${PYTHON_BIN:-}"; then\n # Try to find a suitable Python installation\n log "Looking for a suitable Python installation..."\n \n # Try multiple possible locations to find Python\n POSSIBLE_PYTHON_PATHS=(\n # System paths first (more likely to be compatible with current architecture)\n "/usr/local/bin/python3.12"\n "/usr/bin/python3.12"\n "/usr/local/bin/python3"\n "/usr/bin/python3"\n # From environment variable (set by the installer)\n "${ELECTRON_RESOURCE_PATH:-}/python/bin/python3"\n # Development paths\n "$(dirname "$0")/../../../resources/python/bin/python3"\n "$(pwd)/resources/python/bin/python3"\n )\n\n # Find the first Python that exists and is version 3.12+ and works on this architecture\n PYTHON_BIN=""\n for path in "${POSSIBLE_PYTHON_PATHS[@]}"; do\n # Skip empty paths that might come from unset environment variables\n if [ -z "${path}" ]; then\n continue\n fi\n \n if is_valid_python_binary "${path}"; then\n # Check Python version\n if PY_VERSION=$("${path}" -c "import sys; print(f\'{sys.version_info.major}.{sys.version_info.minor}\')" 2>/dev/null); then\n MAJOR=$(echo "${PY_VERSION}" | cut -d. -f1)\n MINOR=$(echo "${PY_VERSION}" | cut -d. -f2)\n if [ "${MAJOR}" -eq 3 ] && [ "${MINOR}" -ge 12 ]; then\n PYTHON_BIN="${path}"\n log "Found suitable Python ${PY_VERSION} at ${path}"\n break\n else\n log "Python at ${path} is version ${PY_VERSION}, which is below the required 3.12+"\n fi\n fi\n else\n if [ -f "${path}" ]; then\n log "Python at ${path} exists but is not compatible with this system architecture"\n fi\n fi\n done\n\n # If we couldn\'t find a suitable Python, exit with error\n if [ -z "${PYTHON_BIN:-}" ]; then\n error_exit "No suitable Python installation found (version 3.12 or higher required).\\nPlease install Python 3.12 or higher before running this script.\\nYou can install Python from https://www.python.org/downloads/"\n fi\nfi\n\necho "Using Python: $PYTHON_BIN"\n"$PYTHON_BIN" --version || {\n echo "Error: Failed to run Python. Please ensure it is executable and accessible."\n echo "System architecture: $(uname -m)"\n echo "Python binary architecture: $(file "$PYTHON_BIN" 2>/dev/null || echo \'Unable to determine\')"\n exit 1\n}\n\n# Detect the Linux distribution to provide specific instructions\nif command_exists lsb_release; then\n DISTRO=$(lsb_release -is)\n DISTRO_VERSION=$(lsb_release -rs)\n echo "Detected Linux distribution: $DISTRO $DISTRO_VERSION"\nelif [ -f /etc/os-release ]; then\n DISTRO=$(grep -oP \'(?<=^ID=).+\' /etc/os-release | tr -d \'"\')\n DISTRO_VERSION=$(grep -oP \'(?<=^VERSION_ID=).+\' /etc/os-release | tr -d \'"\')\n echo "Detected Linux distribution: $DISTRO $DISTRO_VERSION"\nelse\n DISTRO="unknown"\n echo "Unable to detect Linux distribution"\nfi\n\n# Check if Python has venv module and ensurepip available\nlog "Checking for venv module and ensurepip availability..."\nVENV_AVAILABLE=0\nENSUREPIP_AVAILABLE=0\n\n"${PYTHON_BIN}" -c "import venv" > /dev/null 2>&1 || VENV_AVAILABLE=1\n"${PYTHON_BIN}" -c "import ensurepip" > /dev/null 2>&1 || ENSUREPIP_AVAILABLE=1\n\n# If venv is still not available, try to use virtualenv as a fallback\nif [ $VENV_AVAILABLE -ne 0 ]; then\n echo "venv module is not available. Checking for virtualenv as an alternative..."\n \n # Check if virtualenv is already installed\n if "$PYTHON_BIN" -c "import virtualenv" > /dev/null 2>&1; then\n echo "virtualenv is available, will use it instead of venv"\n else\n echo "ERROR: Neither venv nor virtualenv is available."\n echo "Python 3.12 and venv should be installed as package dependencies."\n echo "Please ensure Python 3.12 and venv are properly installed on your system."\n exit 1\n fi\nfi\n\n# Create virtual environment if it doesn\'t exist\nif [ ! -d "$VENV_PATH" ]; then\n echo "|LO1:environment"\n echo "Creating virtual environment at $VENV_PATH..."\n # Remove any potentially corrupted virtual environment\n if [ -e "$VENV_PATH" ]; then\n echo "Removing existing but potentially corrupted venv directory..."\n rm -rf "$VENV_PATH"\n fi\n \n # Make sure parent directory exists and is writable\n mkdir -p "$(dirname "$VENV_PATH")"\n \n # Try different methods to create a virtual environment\n VENV_CREATE_STATUS=1\n \n # First try with venv if available\n if [ $VENV_AVAILABLE -eq 0 ] && [ $ENSUREPIP_AVAILABLE -eq 0 ]; then\n echo "Creating virtual environment using venv module..."\n "$PYTHON_BIN" -m venv "$VENV_PATH"\n VENV_CREATE_STATUS=$?\n fi\n \n # If venv failed, try virtualenv\n if [ $VENV_CREATE_STATUS -ne 0 ]; then\n echo "venv creation failed with status $VENV_CREATE_STATUS. Falling back to virtualenv..."\n if command_exists virtualenv; then\n virtualenv -p "$PYTHON_BIN" "$VENV_PATH"\n VENV_CREATE_STATUS=$?\n elif "$PYTHON_BIN" -m pip list | grep -q virtualenv; then\n "$PYTHON_BIN" -m virtualenv -p "$PYTHON_BIN" "$VENV_PATH"\n VENV_CREATE_STATUS=$?\n else\n echo "ERROR: Both venv and virtualenv are unavailable or failed."\n echo "Python 3.12 and venv should be installed as package dependencies."\n echo "Please ensure Python 3.12 and venv are properly installed on your system."\n echo "You can install Python 3.12 from https://www.python.org/downloads/"\n exit 1\n fi\n fi\n \n # Check if virtual environment creation was successful\n if [ $VENV_CREATE_STATUS -ne 0 ]; then\n log "ERROR: Failed to create virtual environment. Exit code: $VENV_CREATE_STATUS"\n log "Virtual environment path: $VENV_PATH"\n log "Python binary used: $PYTHON_BIN"\n ls -la "$(dirname "$VENV_PATH")" || true\n log "Python executable permissions:"\n ls -la "$PYTHON_BIN" || true\n \n # Check for common issues\n log "Checking for common virtual environment creation issues..."\n \n # Check disk space\n df -h "$(dirname "$VENV_PATH")" || true\n \n # Check if directory is writable\n if [ ! -w "$(dirname "$VENV_PATH")" ]; then\n log "ERROR: Directory $(dirname "$VENV_PATH") is not writable"\n fi\n \n # Try to create a minimal virtual environment manually as a last resort\n log "Attempting to create a minimal virtual environment manually..."\n mkdir -p "$VENV_PATH/bin" || error_exit "Could not create directory $VENV_PATH/bin"\n echo "#!/bin/bash" > "$VENV_PATH/bin/activate"\n echo "export VIRTUAL_ENV=\\"$VENV_PATH\\"" >> "$VENV_PATH/bin/activate"\n echo "export PATH=\\"$VENV_PATH/bin:\\$PATH\\"" >> "$VENV_PATH/bin/activate"\n echo "unset PYTHONHOME" >> "$VENV_PATH/bin/activate"\n chmod +x "$VENV_PATH/bin/activate" || error_exit "Could not set execute permissions on activate script"\n \n # Create symlinks to the system Python\n ln -sf "$PYTHON_BIN" "$VENV_PATH/bin/python" || log "WARNING: Failed to create symlink for python"\n ln -sf "$PYTHON_BIN" "$VENV_PATH/bin/python3" || log "WARNING: Failed to create symlink for python3"\n \n # Try to bootstrap pip\n log "Bootstrapping pip in the minimal virtual environment..."\n if command_exists curl; then\n curl -s --fail --connect-timeout 10 --max-time 60 https://bootstrap.pypa.io/get-pip.py -o "$APP_DATA_DIR/get-pip.py" || log "WARNING: Failed to download get-pip.py"\n elif command_exists wget; then\n wget -q --timeout=30 --tries=1 -O "$APP_DATA_DIR/get-pip.py" https://bootstrap.pypa.io/get-pip.py || log "WARNING: Failed to download get-pip.py"\n else\n log "ERROR: Neither curl nor wget available to download get-pip.py"\n error_exit "Installation cannot continue without being able to download pip"\n fi\n \n # shellcheck disable=SC1090\n source "$VENV_PATH/bin/activate" && python "$APP_DATA_DIR/get-pip.py" --no-warn-script-location\n \n if [ ! -f "$VENV_PATH/bin/pip" ]; then\n error_exit "Failed to create even a minimal virtual environment."\n else\n log "Created a minimal virtual environment as a fallback."\n fi\n else\n log "Successfully created virtual environment"\n fi\nfi\n\n# Verify the virtual environment structure\necho "Verifying virtual environment structure..."\nif [ ! -f "$VENV_PATH/bin/python" ]; then\n echo "Python executable missing in virtual environment, creating symlink..."\n ln -sf "$PYTHON_BIN" "$VENV_PATH/bin/python"\nfi\n\nif [ ! -f "$VENV_PATH/bin/pip" ]; then\n echo "pip missing in virtual environment, attempting to bootstrap it..."\n curl -s --fail --connect-timeout 10 --max-time 60 https://bootstrap.pypa.io/get-pip.py -o "$APP_DATA_DIR/get-pip.py"\n "$VENV_PATH/bin/python" "$APP_DATA_DIR/get-pip.py" --no-warn-script-location\n \n if [ ! -f "$VENV_PATH/bin/pip" ]; then\n echo "ERROR: Failed to bootstrap pip in the virtual environment"\n exit 1\n fi\nfi\n\necho "Virtual environment structure verified"\n\n# --- The package install: uv when there is one, pip otherwise ------------------\n#\n# Same shape as the macOS script, and for the same reasons: uv resolves and\n# fetches in parallel - measured there, cold cache, three runs each, same\n# interpreter: uv\'s package install is 12.8-16.1 s against pip\'s 33.0-40.7 s,\n# plus the 2.3-2.8 s pip self-upgrade this path skips, so 1.5-2.8x across two\n# operators rather than the "14.8 s against 128.9 s" quoted here before that\n# reading was withdrawn (`docs/BUILD.md` has the full set). The pip path below is\n# unchanged and runs whenever uv is absent or cannot do the job, and pip STAYS in the venv\n# because the app\'s backend-update path runs `pip install --upgrade\n# local-operator` inside this same environment - which is also why the venv is\n# still created with `python -m venv` rather than `uv venv`.\n#\n# Nothing here searches PATH for a uv: an installed uv is a version and a\n# configuration nobody in this repository chose. `LOCAL_OPERATOR_UV_BIN` is the\n# app\'s own answer (`src/main/backend/uv-tool.ts`).\nUV_BIN="${LOCAL_OPERATOR_UV_BIN:-}"\n\n# Drop every UV_* variable the launching environment carried. Measured on uv\n# 0.12.17: a user-level `uv.toml` naming an unreachable index is obeyed by\n# `uv pip install` and ignored with `UV_NO_CONFIG=1`; an ambient `UV_INDEX_URL`\n# changes where packages come from, while `PIP_INDEX_URL` does not affect uv at\n# all. A name list would drift the day uv adds a variable - the namespace cannot.\n#\n# IT RUNS BEFORE THE SETTINGS BELOW ARE SET: a sweep after them takes them away,\n# and an empty `UV_CACHE_DIR` makes uv exit 2 with `a value is required for\n# \'--cache-dir <CACHE_DIR>\'` rather than falling back to a default.\nfor uv_ambient in $(env | sed -n \'s/^\\(UV_[A-Za-z0-9_]*\\)=.*/\\1/p\'); do\n unset "$uv_ambient"\ndone\n\n# The cache lives under the app\'s own support directory rather than the user\'s\n# shared `~/.cache/uv`, and is handed to uv per invocation rather than exported.\n# It persists (~118 MB for a full install, measured on macOS) and nothing else\n# reads it today; it is what makes a retry converge in seconds rather than tens\n# of seconds.\nUV_CACHE_DIR="${APP_DATA_DIR}/uv-cache"\n\n# Is the handed-down uv something we can actually run?\nuv_is_usable() {\n [ -n "${UV_BIN}" ] && [ -x "${UV_BIN}" ] && "${UV_BIN}" --version >/dev/null 2>&1\n}\n\n# UV_NO_CONFIG: never read `pyproject.toml`/`uv.toml`, wherever they are.\n# UV_PYTHON_DOWNLOADS=never: this install uses the interpreter it was handed and\n# never fetches another.\nuv_run() {\n UV_NO_CONFIG=1 UV_PYTHON_DOWNLOADS=never UV_CACHE_DIR="${UV_CACHE_DIR}" \\\n "${UV_BIN}" "$@"\n}\n\n# Activate virtual environment and install local-operator\necho "Installing local-operator in virtual environment..."\nsource "$VENV_PATH/bin/activate"\n\n# Check network connectivity to PyPI. A DIAGNOSTIC, not a gate: the install below\n# decides whether it can proceed.\n#\n# What this answers, stated precisely because an earlier version of this comment\n# claimed more than the flags buy: "did a TLS fetch to PyPI\'s JSON API complete,\n# and did the answer come back as JSON?". `--fail` turns an HTTP ERROR status\n# into a non-zero exit, and does NOT notice a captive portal answering 200 with\n# its own HTML page (measured: a portal-shaped 200 exits 0 with and without the\n# flag). Both spellings therefore check the CONTENT TYPE as well, since a portal\n# that reports "reachable" while pip is about to fail is the false negative this\n# warning exists to catch: curl through `-w \'%{content_type}\'`, and wget through\n# the response headers `-S` prints (`-S`/`--server-response` is in BusyBox\'s wget\n# since 2017 as well as GNU\'s, which is the wget a system without curl has).\n#\n# What the content type does NOT prove, stated so this paragraph is not read as\n# more than it says: a proxy answering 200 with `application/json` and an error\n# body (`{"detail":"blocked by proxy policy"}`) is silent here, because the\n# answer did come back as JSON. Only parsing the body - a fetch of PyPI\'s own\n# payload shape - would tell those apart, and a diagnostic that costs a parse is\n# not what stands in front of an install.\n#\n# Two bounds, two jobs: the connect bound ends a black-hole network, the total\n# stops a connected-but-stalled peer. Both must be POSITIVE - `--max-time 0` and\n# `--timeout=0` disable the bound rather than making it immediate on both curl and\n# wget. 30 rather than 10 because the total must not fire on a slow-but-working\n# link: a working endpoint that answered in 15s tripped a 10s bound and printed\n# this warning on an install that then succeeded.\necho "Checking network connectivity to PyPI..."\nif command_exists curl; then\n PYPI_PROBE_CONTENT_TYPE=$(curl -s --fail --connect-timeout 5 --max-time 30 -o /dev/null -w \'%{content_type}\' https://pypi.org/pypi/local-operator/json) || PYPI_PROBE_CONTENT_TYPE=""\n if [[ "${PYPI_PROBE_CONTENT_TYPE}" != application/json* ]]; then\n echo "WARNING: Could not reach PyPI. Network connectivity issues might prevent installation."\n fi\nelif command_exists wget; then\n # The headers are captured into a variable and matched with a here-string\n # rather than piped into `grep -q`: `-q` exits on the first match, the closed\n # pipe gives wget SIGPIPE, and the script runs under `set -o pipefail`, so a\n # WORKING link printed this warning whenever the match landed before wget had\n # finished writing its headers. The piped shape was this remediation\'s own - the\n # first fix piped it and was measured warning 1 time in 20 against real PyPI\n # (and 1 in 20 against a healthy local endpoint) while this shape warns 0 in 40\n # with the same flags - so the trap is recorded here because it is one line away\n # from being reintroduced, not because the released script ever shipped it.\n PYPI_PROBE_HEADERS=$(wget -q -S --spider --timeout=30 --tries=1 https://pypi.org/pypi/local-operator/json 2>&1) || PYPI_PROBE_HEADERS=""\n if ! grep -qi \'^ *content-type: application/json\' <<< "$PYPI_PROBE_HEADERS"; then\n echo "WARNING: Could not reach PyPI. Network connectivity issues might prevent installation."\n fi\nfi\n\n# --- Progress markers -------------------------------------------------------\n# One whole line per phase, read by the app and shown in the setup window. The\n# app matches the ENTIRE line (`|LO1:<phase>`, see src/shared/install-progress.ts)\n# and never a substring, so a marker has to stand alone: do not wrap it in\n# other text, do not re-indent it into a longer sentence, and do not emit one\n# for work this script does not actually do. A missing marker leaves the window\n# on its previous step, which is the honest failure; a marker a log line also\n# happens to produce is a wrong step presented as a measurement.\n#\n# WHY THE SCRIPT AND NOT ONLY THE APP: the install below is minutes of work on a\n# cold machine, and the app cannot see inside the venv it is about to create -\n# this is the only process that knows when the environment exists and when the\n# download starts.\necho "|LO1:components"\nUV_INSTALLED=false\nif uv_is_usable; then\n echo "Installing local-operator with uv ($("${UV_BIN}" --version 2>/dev/null || echo \'version unavailable\'))..."\n # No `pip install --upgrade pip` on this path: uv does not use pip.\n if uv_run pip install --python "${VENV_PATH}/bin/python" --upgrade local-operator; then\n UV_INSTALLED=true\n echo "local-operator installation with uv successful"\n else\n # The exit code matters here for the same reason it does on macOS: the\n # fallback is deliberately forgiving, so this line is the only evidence that\n # a bundled uv is present and failing for every user (QA Q2).\n UV_STATUS=$?\n echo "WARNING: the bundled uv is present but its install failed (exit ${UV_STATUS}); retrying with pip, which is what this script used before uv was bundled."\n fi\nelse\n if [ -n "${UV_BIN}" ]; then\n # Present but not runnable - the wrong architecture for this machine, a\n # truncated copy, a mount that lost the execute bit. Named apart from the\n # absent case below because the two are different facts about the install\n # (the Windows script has the same split, and this line\'s absence is how a\n # staged-for-the-wrong-arch uv reads as "nothing was staged"): both fall\n # back to pip, and only this one is a defect in what was delivered.\n echo "Bundled uv at ${UV_BIN} could not be run on this machine; installing with pip."\n else\n echo "Bundled uv not available (LOCAL_OPERATOR_UV_BIN=${UV_BIN:-unset}); installing with pip."\n fi\nfi\n\nif [ "${UV_INSTALLED}" != true ]; then\n echo "Upgrading pip..."\n python -m pip install --upgrade pip || {\n echo "WARNING: Failed to upgrade pip. Will try to continue with existing pip version."\n pip --version\n }\n\n echo "Installing local-operator package..."\n python -m pip install --verbose local-operator || {\n echo "ERROR: Failed to install local-operator package. Exit code: $?"\n echo "Python version:"\n python --version\n echo "pip version:"\n pip --version\n echo "Available pip packages:"\n pip list\n exit 1\n }\nfi\necho "local-operator installation successful"\n\n# Verify installation\nif [ -f "$VENV_PATH/bin/local-operator" ]; then\n log "Local Operator backend installed successfully!"\n \n # Show more information about the installed binary\n ls -la "$VENV_PATH/bin/local-operator" || true\n file "$VENV_PATH/bin/local-operator" 2>/dev/null || log "Note: \'file\' command not available"\n \n # Try to run the version command with full error output\n log "Testing local-operator binary..."\n "$VENV_PATH/bin/local-operator" --version || {\n log "ERROR: local-operator binary exists but failed to execute. Exit code: $?"\n log "Binary details:"\n file "$VENV_PATH/bin/local-operator" 2>/dev/null || log "Note: \'file\' command not available"\n log "Binary permissions:"\n ls -la "$VENV_PATH/bin/local-operator" || true\n log ""\n log "This could be due to missing dependencies or architecture incompatibility."\n log "Try running the binary manually to see specific errors."\n \n # Don\'t exit here - just warn the user\n log "WARNING: Installation completed but binary verification failed."\n }\n \n # Create a summary of the installation\n SUMMARY_FILE="${APP_DATA_DIR}/installation-summary-${TIMESTAMP}.txt"\n {\n echo "=== Local Operator Backend Installation Summary ==="\n echo "Timestamp: $(date)"\n echo "Python Version: $("${PYTHON_BIN}" --version 2>&1)"\n echo "Virtual Environment: ${VENV_PATH}"\n echo "Binary Location: ${VENV_PATH}/bin/local-operator"\n echo "To activate the virtual environment, run: source ${VENV_PATH}/bin/activate"\n echo "To test the installation, run: ${VENV_PATH}/bin/local-operator --version"\n echo "Log file: ${LOG_FILE}"\n echo "=================================================="\n } > "${SUMMARY_FILE}"\n \n log "Installation summary saved to: ${SUMMARY_FILE}"\nelse\n log "Error: Failed to install Local Operator backend. Binary not found."\n log "Contents of bin directory:"\n ls -la "$VENV_PATH/bin/" || true\n log "Check the log file for details: ${LOG_FILE}"\n error_exit "Installation failed. Binary not installed properly."\nfi\n\nlog "Installation completed successfully at $(date)"\n\n# Clean up temporary files now that installation is complete\ncleanup\n\n# Print final instructions\nlog ""\nlog "=== INSTALLATION COMPLETE ==="\nlog "You can now use the Local Operator backend by running: ${VENV_PATH}/bin/local-operator"\nlog "Installation directory: ${VENV_PATH}"\nlog "Log file: ${LOG_FILE}"\nlog "================================"\n';
|
|
11205
11205
|
const macosInstallScriptRaw = '#!/bin/bash\n# Local Operator Backend Installation Script for macOS\n# This script uses the bundled standalone Python and sets up a virtual environment for the Local Operator backend.\n\nset -e # Exit immediately if a command exits with a non-zero status\n\n# Configuration\nAPP_NAME="Local Operator"\nVENV_NAME="local-operator-venv"\nAPP_DATA_DIR="${LOCAL_OPERATOR_SUPPORT_PATH:-$HOME/Library/Application Support/$APP_NAME}"\nVENV_PATH="$APP_DATA_DIR/$VENV_NAME"\nLOG_FILE="$APP_DATA_DIR/backend-install.log"\n\n# Which environment this installs into. The path is the app\'s decision, not this\n# script\'s: a packaged install and an unpackaged one must not share an\n# environment (the venv is built on whatever interpreter the instance resolves,\n# and the installed bundle\'s stdlib lives inside the code-sealed .app), and only\n# the app knows which one it is. The app passes its answer in\n# (`LOCAL_OPERATOR_VENV_PATH`, set from `managedVenvPath` in\n# src/main/backend/venv-paths.ts).\n#\n# macOS REFUSES a standalone run rather than falling back, and the asymmetry with\n# the Linux and Windows scripts is deliberate. Their default is the packaged name,\n# which is harmless there; here it is the exact environment this split exists to\n# stop a second instance from writing into - the measured failure is a dev-venv\n# interpreter whose stdlib is `/Applications/Local Operator.app/Contents/\n# Resources/python_aarch64`, so a silent default would rebuild that venv and\n# `pip install` into it, which is what R1 of the review caught. A caller that\n# cannot name the environment is a caller that should not be installing into one.\n: "${LOCAL_OPERATOR_VENV_PATH:?Pass the resolved managed environment path (see venv-paths.ts); this script will not guess which instance it belongs to}"\nVENV_PATH="$LOCAL_OPERATOR_VENV_PATH"\n\n# Keep CPython\'s bytecode cache out of the application bundle.\n#\n# The bundled interpreter writes __pycache__/*.pyc beside the stdlib sources it\n# imports, and those sources live inside the code-signed .app - which is the\n# build\'s own extraResource. Every such write is a change to a sealed resource:\n# measured on an installed 0.17.3, `codesign --verify --deep` reported 308\n# `file added:` violations, all of them .pyc, and ShipIt then refuses the\n# in-place update with -67028 errSecCSBadBundleFormat. A file codesign reports\n# as *added* can be deleted and the seal comes back; a *modified* one cannot,\n# which is why nothing may ship a .pyc at all. The app sets this variable when\n# it spawns us; defaulting it here keeps a standalone run of this script in\n# agreement with the app about where bytecode goes. It is not a complete answer:\n# the app does not spawn every python that runs this interpreter, and a python\n# started by something else - a shell, a CLI script, an agent - has no prefix at\n# all (measured: a venv over this tree wrote 25 .pyc into it that way). The half\n# that covers those is the app\'s seal on the tree itself\n# (src/main/python-bytecode-cache.ts), which a standalone run of this script does\n# not apply. $HOME is the right place for the cache for the same reason the venv\n# lives there: it is never inside the thing that gets signed and swapped.\n: "${PYTHONPYCACHEPREFIX:=$APP_DATA_DIR/python-bytecode-cache}"\nexport PYTHONPYCACHEPREFIX\n\n# And the refusal half of the same pair, so a standalone run of this script\n# cannot write bytecode into the bundle even where the redirect above does not\n# apply - a relative or unwritable prefix, or a child that drops the variable.\n# CPython reads the flag before its first import, so this script\'s own\n# `python -m venv`, its pip runs and the venv they create all compile without\n# writing a `__pycache__` anywhere. Measured on CPython: `0` and the empty\n# string are the two falsy spellings, so the value is set rather than merged\n# with whatever the caller had.\nexport PYTHONDONTWRITEBYTECODE=1\n\n# The architecture block that used to live here computed and logged the name of\n# a directory for an in-bundle search this script no longer performs: every run\n# announced which architecture-named directory it was about to use, and then\n# installed from `PYTHON_BIN` anyway - the line stated the opposite of how the\n# script finds Python, and the names it computed were used nowhere else (review\n# N1). Which interpreter to build the environment with is the caller\'s decision,\n# checked immediately below.\n\n# The app prepares a complete external runtime before invoking this script.\n# Searching /Applications here would reintroduce legacy-bundle execution during\n# migration. Standalone callers must make the same explicit path decision.\n: "${PYTHON_BIN:?Pass an external prepared Python executable}"\ncase "$PYTHON_BIN" in\n *.app/*) echo "Refusing to execute Python inside an application bundle" >&2; exit 1 ;;\nesac\n\n# Create app data directory if it doesn\'t exist\nmkdir -p "$APP_DATA_DIR"\n\n# Start logging - capture everything and ensure it\'s visible to parent process\nexec > >(tee -a "$LOG_FILE") 2> >(tee -a "$LOG_FILE" >&2)\necho "=============================================="\necho "$(date): Starting Local Operator backend installation..."\necho "=============================================="\necho "Python bin path: $PYTHON_BIN"\necho "Virtual environment path: $VENV_PATH"\necho "App data directory: $APP_DATA_DIR"\necho "Log file: $LOG_FILE"\necho "=============================================="\n\n# Nothing is fetched here but the package itself.\n#\n# This script used to download a third-party FFmpeg binary from a GitHub\n# release into `$APP_DATA_DIR/bin`. The macOS asset names it asked for do not\n# exist (curl without `--fail` wrote the 404 body to the binary path, `chmod +x`\n# made it executable, its own `[ -f ] && [ -x ]` verification passed and the next\n# run skipped the download, so the broken file was permanent), nothing in the app\n# or in `local-operator` ever executed it, and under `set -e` a failed download\n# killed the install before the venv existed - so a machine that can reach PyPI\n# but not github.com could not install at all. Tooling a task actually needs is\n# acquired later, on demand, through the app\'s Console with the user\'s approval;\n# this script\'s job is the environment below and nothing else.\n# Verify bundled Python exists\nif [ ! -f "$PYTHON_BIN" ]; then\n echo "Error: Bundled Python not found at $PYTHON_BIN"\n echo "Please ensure standalone Python is properly installed in the application resources."\n exit 1\nfi\n\n# Make sure Python binary is executable\necho "Using bundled Python: $PYTHON_BIN"\n"$PYTHON_BIN" --version\n\n# Check if Python has venv module available\necho "Checking for venv module availability..."\n"$PYTHON_BIN" -m venv --help > /dev/null 2>&1 || {\n echo "ERROR: Python venv module not available in the Python installation"\n echo "Python details:"\n "$PYTHON_BIN" --version\n "$PYTHON_BIN" -c "import sys; print(\'Prefix:\', sys.prefix); print(\'Exec Prefix:\', sys.exec_prefix)"\n "$PYTHON_BIN" -c "import sys; print(\'Modules path:\'); print(\'\\n\'.join(sys.path))"\n exit 1\n}\necho "venv module is available"\n\n# Create virtual environment if it doesn\'t exist\nif [ ! -d "$VENV_PATH" ]; then\n echo "|LO1:environment"\n echo "Creating virtual environment at $VENV_PATH..."\n # Never repair a path we did not create. Preparation allocates a fresh final\n # pathname; a collision is evidence to preserve, not a reason to delete it.\n if [ -e "$VENV_PATH" ] || [ -L "$VENV_PATH" ]; then\n echo "Refusing to replace an existing environment path: $VENV_PATH" >&2\n exit 1\n fi\n \n # Make sure parent directory exists and is writable\n mkdir -p "$(dirname "$VENV_PATH")"\n \n # Create the virtual environment with verbosity\n "$PYTHON_BIN" -m venv "$VENV_PATH" || {\n echo "ERROR: Failed to create virtual environment. Exit code: $?"\n echo "Virtual environment path: $VENV_PATH"\n echo "Python binary used: $PYTHON_BIN"\n ls -la "$(dirname "$VENV_PATH")"\n echo "Python executable permissions:"\n ls -la "$PYTHON_BIN"\n exit 1\n }\n echo "Successfully created virtual environment"\nfi\n\n# Verify the virtual environment structure\necho "Verifying virtual environment structure..."\nif [ ! -f "$VENV_PATH/bin/python" ] || [ ! -f "$VENV_PATH/bin/pip" ]; then\n echo "ERROR: Virtual environment is missing critical components"\n echo "Contents of virtual environment directory:"\n ls -la "$VENV_PATH"\n if [ -d "$VENV_PATH/bin" ]; then\n echo "Contents of bin directory:"\n ls -la "$VENV_PATH/bin"\n fi\n exit 1\nfi\necho "Virtual environment structure verified"\n\n# --- The package install: uv when there is one, pip otherwise ------------------\n#\n# WHY UV. Installing the backend is the phase a user waits through on a first\n# run, and pip spends it resolving and fetching serially. Measured on this\n# machine, cold cache, three runs each, the same interpreter and dependency set:\n# pip\'s package install is 33.0-40.7 s against uv\'s 12.8-16.1 s, plus the\n# 2.3-2.8 s `pip install --upgrade pip` the uv path skips. QA\'s independent pair\n# on a quieter box was 33.9 s against 22.8 s, so read the ratio as 1.5-2.8x\n# ACROSS those two operators, and the seconds as this box\'s. Warm, a retry or a\n# repair: 15.9-33.8 s against 0.65-1.57 s.\n#\n# THE FIGURES THIS COMMENT USED TO QUOTE ARE WITHDRAWN, and this note is here so\n# they are not restored: "pip 128.9 s against uv 14.8 s, 178.3 s against 4.5 s\n# warm". The pip reading was taken at load ~90 and did not reproduce at five\n# further attempts. A comment that argues from a withdrawn number is how the next\n# maintainer decides on a ratio five times the measured one - and the decision it\n# argues is whether ~16-20 MiB per artifact earns its place, so the number is\n# load-bearing. `docs/BUILD.md` carries the full set.\n#\n# WHY A FALLBACK RATHER THAN UV ALONE. uv is a NEW resource in the bundle, and\n# every artifact built before this change has none. The pip path below is the one\n# that shipped until now, unchanged, and it runs whenever uv is absent or cannot\n# do the job - a dev checkout whose `pnpm setup-python` was never run, an older\n# artifact, a uv the platform refuses to spawn, a uv install that failed. A\n# fallback that has never been exercised is a claim rather than a feature, which\n# is why the CI install-script jobs run this script with no uv at all.\n#\n# WHY pip STAYS IN THE VENV, and why this does NOT use `uv venv`: the app\'s\n# backend-update path runs `pip install --upgrade local-operator` inside this same\n# environment (`update-service.ts`, and `update-install.ts` documents why pip is\n# the right command there). `python -m venv` seeds pip from the interpreter\'s own\n# `ensurepip` wheel, where `uv venv` produces an environment with no pip at all -\n# so switching the creation would silently break every later update. The check\n# above (`"$VENV_PATH/bin/pip"`) is what holds that on both paths.\n#\n# The app hands the path of the pinned, bundled uv in `LOCAL_OPERATOR_UV_BIN`\n# (`src/main/backend/uv-tool.ts`). Nothing here searches PATH for a uv: an\n# installed uv is a version and a configuration nobody in this repository chose,\n# and the point of bundling one is that the install is the same for every user.\nUV_BIN="${LOCAL_OPERATOR_UV_BIN:-}"\n\n# Drop every UV_* variable the launching environment carried.\n#\n# WHY THE WHOLE NAMESPACE rather than a list of the dangerous ones: uv reads its\n# configuration from `UV_*` and from `uv.toml`, and both are the caller\'s, not\n# this app\'s. Measured on uv 0.12.17: with a user-level `uv.toml` naming an index\n# that is not reachable, `uv pip install --dry-run six` fails with `tcp connect\n# error`; `UV_NO_CONFIG=1` makes the same command resolve from PyPI. And an\n# ambient `UV_INDEX_URL` changes where packages come from - while `PIP_INDEX_URL`\n# does not affect uv at all (measured, both directions). Unsetting a name list\n# would drift the day uv adds a variable; unsetting the namespace cannot.\n#\n# IT RUNS BEFORE THE SETTINGS BELOW ARE SET, and that order is load-bearing: a\n# sweep after them takes them away, and an empty `UV_CACHE_DIR` is not "use the\n# default cache" - uv exits 2 with `a value is required for \'--cache-dir\n# <CACHE_DIR>\'`. Measured by running this script on the uv path, where the\n# failure first surfaced as a silent pip install, because the fallback below\n# caught it exactly as designed.\nfor uv_ambient in $(env | sed -n \'s/^\\(UV_[A-Za-z0-9_]*\\)=.*/\\1/p\'); do\n unset "$uv_ambient"\ndone\n\n# The cache lives under the app\'s own support directory rather than the user\'s\n# shared `~/.cache/uv`, so the install neither reads nor pollutes a cache that\n# another tool (or another version of uv) is maintaining. Written here, after the\n# sweep, and handed to uv per invocation rather than exported.\n#\n# IT PERSISTS, and that is worth knowing on a user\'s disk: a full install leaves\n# ~118 MB there (measured; pip\'s own cache for the same dependency set is ~40 MB\n# and it also persists). Nothing else reads it today - the app\'s backend-update\n# path installs with pip - so it is there for the next provisioning or repair,\n# and it is what makes a retry converge in ~1.5 s instead of ~20 s.\nUV_CACHE_DIR="$APP_DATA_DIR/uv-cache"\n\n# Is the handed-down uv something we can actually run?\nuv_is_usable() {\n [ -n "$UV_BIN" ] && [ -x "$UV_BIN" ] && "$UV_BIN" --version >/dev/null 2>&1\n}\n\n# UV_NO_CONFIG: never read `pyproject.toml`/`uv.toml`, wherever they are.\n# UV_PYTHON_DOWNLOADS=never: this install uses the interpreter it was handed and\n# may never fetch another, which is also what keeps it working offline.\n# UV_CACHE_DIR: this install\'s own cache, passed explicitly for the same reason.\nuv_run() {\n UV_NO_CONFIG=1 UV_PYTHON_DOWNLOADS=never UV_CACHE_DIR="$UV_CACHE_DIR" \\\n "$UV_BIN" "$@"\n}\n\n# Activate virtual environment and install local-operator\necho "Installing local-operator in virtual environment..."\nsource "$VENV_PATH/bin/activate"\n\n# Check network connectivity to PyPI. A DIAGNOSTIC, not a gate: the install below\n# decides whether it can proceed.\n#\n# What this answers, stated precisely because an earlier version of this comment\n# claimed more than the flags buy: "did a TLS fetch to PyPI\'s JSON API complete,\n# and did the answer come back as JSON?". `--fail` turns an HTTP ERROR status\n# into a non-zero exit - a proxy\'s 403/407, any 4xx/5xx - and does NOT notice a\n# captive portal answering 200 with its own HTML page (measured: a portal-shaped\n# 200 returns exit 0 with AND without the flag). `-o /dev/null` cannot tell a\n# portal\'s page from PyPI\'s JSON either, so the content type is what\n# discriminates, and on a captive network a probe that reports "reachable" while\n# pip is about to fail is the false negative this warning exists to catch.\n#\n# What the content type does NOT prove, stated so this paragraph is not read as\n# more than it says: a proxy answering 200 with `application/json` and an error\n# body (`{"detail":"blocked by proxy policy"}`) is silent here, because the\n# answer did come back as JSON. Only parsing the body - a fetch of PyPI\'s own\n# payload shape - would tell those apart, and a diagnostic that costs a parse is\n# not what stands in front of an install.\n#\n# Two bounds, two jobs: `--connect-timeout 5` ends a black-hole network (a\n# connect that never completes), `--max-time 30` stops a connected-but-stalled\n# peer. Both must be POSITIVE: `--max-time 0` and `--connect-timeout 0` disable\n# the bound rather than making it immediate, which is why the test beside this\n# script requires `[1-9]`. 30 rather than 10 because the total must not fire on a\n# slow-but-working link: a working endpoint that answered in 15s tripped a 10s\n# total bound and printed this warning on an install that then succeeded, and a\n# warning that cries wolf is one users learn to ignore.\necho "Checking network connectivity to PyPI..."\nPYPI_PROBE_CONTENT_TYPE=$(curl -s --fail --connect-timeout 5 --max-time 30 -o /dev/null -w \'%{content_type}\' https://pypi.org/pypi/local-operator/json) || PYPI_PROBE_CONTENT_TYPE=""\nif [[ "$PYPI_PROBE_CONTENT_TYPE" != application/json* ]]; then\n echo "WARNING: Could not reach PyPI. Network connectivity issues might prevent installation."\n echo "Attempting to ping common domains to diagnose network issues:"\n ping -c 1 -W 2000 google.com || echo "Cannot ping google.com"\n ping -c 1 -W 2000 pypi.org || echo "Cannot ping pypi.org"\nfi\n\n# --- Progress markers -------------------------------------------------------\n# One whole line per phase, read by the app and shown in the setup window. The\n# app matches the ENTIRE line (`|LO1:<phase>`, see src/shared/install-progress.ts)\n# and never a substring, so a marker has to stand alone: do not wrap it in\n# other text, do not re-indent it into a longer sentence, and do not emit one\n# for work this script does not actually do. A missing marker leaves the window\n# on its previous step, which is the honest failure; a marker a log line also\n# happens to produce is a wrong step presented as a measurement.\n#\n# WHY THE SCRIPT AND NOT ONLY THE APP: the install below is minutes of work on a\n# cold machine, and the app cannot see inside the venv it is about to create -\n# this is the only process that knows when the environment exists and when the\n# download starts.\necho "|LO1:components"\nUV_INSTALLED=false\nif uv_is_usable; then\n echo "Installing local-operator with uv ($("$UV_BIN" --version 2>/dev/null || echo \'version unavailable\'))..."\n # No `pip install --upgrade pip` on this path: uv does not use pip, so the\n # upgrade would be a whole extra network round trip that changes nothing about\n # the result.\n if uv_run pip install --python "$VENV_PATH/bin/python" --upgrade local-operator; then\n UV_INSTALLED=true\n echo "local-operator installation with uv successful"\n else\n # WHY THE EXIT CODE IS PRINTED (review round 1, QA Q2): this fallback has to\n # be forgiving - an install must not fail because uv did - but "a bundled uv\n # is present and fails" is a defect rather than a degraded path, and this line\n # is the only place it shows up: the exit code is 0 and the UI is unchanged.\n # `uv_is_usable` passing and a uv install SUCCEEDING are two different facts.\n UV_STATUS=$?\n echo "WARNING: the bundled uv is present but its install failed (exit ${UV_STATUS}); retrying with pip, which is what this script used before uv was bundled."\n fi\nelse\n echo "Bundled uv not available (LOCAL_OPERATOR_UV_BIN=${UV_BIN:-unset}); installing with pip."\nfi\n\nif [ "$UV_INSTALLED" != true ]; then\n echo "Upgrading pip..."\n python -m pip install --upgrade pip || {\n echo "ERROR: Failed to upgrade pip. Exit code: $?"\n echo "pip version before failing:"\n pip --version\n exit 1\n }\n echo "pip upgrade successful:"\n pip --version\n\n echo "Installing local-operator package..."\n python -m pip install --upgrade --verbose local-operator || {\n echo "ERROR: Failed to install local-operator package. Exit code: $?"\n echo "Python version:"\n python --version\n echo "pip version:"\n pip --version\n echo "Available pip packages:"\n pip list\n echo "Pip config:"\n pip config list\n echo "Network diagnosis:"\n curl -sI --fail --connect-timeout 5 --max-time 30 https://pypi.org || echo "Cannot reach PyPI server"\n exit 1\n }\nfi\necho "local-operator installation successful"\n\n# Verify installation\nif [ -f "$VENV_PATH/bin/local-operator" ]; then\n echo "Local Operator backend installed successfully!"\n \n # Show more information about the installed binary\n ls -la "$VENV_PATH/bin/local-operator"\n file "$VENV_PATH/bin/local-operator"\n \n # Try to run the version command with full error output\n echo "Testing local-operator binary..."\n "$VENV_PATH/bin/local-operator" --version || {\n echo "ERROR: local-operator binary exists but failed to execute. Exit code: $?"\n echo "Binary details:"\n file "$VENV_PATH/bin/local-operator"\n echo "Binary permissions:"\n ls -la "$VENV_PATH/bin/local-operator"\n echo "Dependencies:"\n if command -v otool >/dev/null; then\n otool -L "$VENV_PATH/bin/local-operator" || echo "Could not get dependencies with otool"\n fi\n exit 1\n }\nelse\n echo "Error: Failed to install Local Operator backend. Binary not found."\n echo "Contents of bin directory:"\n ls -la "$VENV_PATH/bin/"\n exit 1\nfi\n\necho "$(date): Installation completed successfully."\n';
|
|
11206
11206
|
const windowsInstallScriptRaw = '# Local Operator Backend Installation Script for Windows\n# This script installs pyenv-win, Python 3.12, and sets up a virtual environment for the Local Operator backend.\n\n# Configuration\n$AppName = "Local Operator"\n$PythonVersion = "3.12.0"\n$VenvName = "local-operator-venv"\n$AppDataDir = "$env:APPDATA\\\\$AppName"\n$VenvPath = "$AppDataDir\\\\$VenvName"\n$LogFile = "$AppDataDir\\\\backend-install-shell.log"\n$PyenvDir = "$env:USERPROFILE\\\\.pyenv"\n\n# Which environment this installs into - the app\'s decision, handed in rather\n# than re-derived. A packaged install and an unpackaged one must not share an\n# environment (the venv is built on whatever interpreter the instance resolves),\n# and only the app knows which it is: LOCAL_OPERATOR_VENV_PATH carries\n# managedVenvPath\'s answer (src/main/backend/venv-paths.ts). The default above is\n# what a standalone run uses - the packaged name, because that is what every\n# install on a disk today has.\nif ($env:LOCAL_OPERATOR_VENV_PATH) {\n $VenvPath = $env:LOCAL_OPERATOR_VENV_PATH\n}\n\n# Keep CPython\'s bytecode cache out of the application directory.\n#\n# Same rule as the macOS script, and stated here for the same reason: an\n# interpreter writes __pycache__/*.pyc beside the stdlib sources it imports. On\n# Windows those sources are the bundled python directory rather than a\n# code-signed bundle, so this is hygiene rather than the load-bearing fix it is\n# on macOS - but the app and the script must not disagree about where bytecode\n# goes. $AppDataDir is used for the same reason the venv is: it is never inside\n# the installed application tree.\nif (-not $env:PYTHONPYCACHEPREFIX) {\n $env:PYTHONPYCACHEPREFIX = "$AppDataDir\\\\python-bytecode-cache"\n}\n\n# The refusal half of the same pair, kept in step with the app\'s\n# `withPythonBytecodeCache`: CPython reads the flag before its first import, so\n# nothing this script runs can write a __pycache__ at all.\n$env:PYTHONDONTWRITEBYTECODE = "1"\n\n# Create app data directory if it doesn\'t exist\nif (-not (Test-Path $AppDataDir)) {\n New-Item -ItemType Directory -Path $AppDataDir -Force | Out-Null\n}\n\n# Start logging\nStart-Transcript -Path $LogFile -Append\nWrite-Output "$(Get-Date): Starting Local Operator backend installation..."\n\n# Nothing is fetched here but the package itself and Python\'s own toolchain.\n#\n# This script used to download a third-party FFmpeg binary from a GitHub release\n# into `$AppDataDir\\bin`. Nothing in the app or in `local-operator` ever executed\n# it. Tooling a task actually needs is acquired later, on demand, through the\n# app\'s Console with the user\'s approval; this script\'s job is the environment\n# below and nothing else. (pyenv-win\'s source archive below is the one remaining\n# third-party fetch, and it is a source archive the Windows install cannot do\n# without - see `scripts/install-scripts-network.test.mjs`, which keeps that list\n# down to the fetches each platform genuinely needs.)\n\n# Function to check if a command exists\nfunction Test-CommandExists {\n param ($command)\n $oldPreference = $ErrorActionPreference\n $ErrorActionPreference = \'stop\'\n try {\n if (Get-Command $command) { return $true }\n } catch {\n return $false\n } finally {\n $ErrorActionPreference = $oldPreference\n }\n}\n\n# Install pyenv-win if not installed\nif (-not (Test-Path $PyenvDir)) {\n Write-Output "Installing pyenv-win..."\n \n # Create temporary directory\n $TempDir = "$env:TEMP\\\\pyenv-win"\n if (Test-Path $TempDir) {\n Remove-Item -Path $TempDir -Recurse -Force\n }\n New-Item -ItemType Directory -Path $TempDir -Force | Out-Null\n \n # Download and extract pyenv-win\n $PyenvZip = "$TempDir\\\\pyenv-win.zip"\n # Bounded, and the bound FAILS LOUDLY. An unbounded request here holds a\n # first-run install open behind the progress bar forever on a black-hole\n # network; and without -ErrorAction Stop a fired -TimeoutSec is a\n # NON-TERMINATING error, so the script would walk straight into\n # Expand-Archive with an absent or partial zip and report an archive error\n # instead of "the download timed out". The partial file is removed in the\n # failure branch so a later run cannot expand what this one failed to fetch\n # (the next run clears $TempDir before it downloads at all, which is the\n # `if (Test-Path $TempDir) { Remove-Item ... }` above - named rather than\n # cited by line, because a line number in a script that keeps changing is\n # what a stale citation is made of).\n # 120 seconds is a payload bound rather than the 30-second stall bound the PyPI\n # probes use: this downloads a source archive instead of answering an API\n # call, so it only has to stop an indefinite hang.\n #\n # WHICH BOUND `-TimeoutSec` ACTUALLY IS DEPENDS ON THE POWERSHELL, and that is\n # a trap worth naming because the two paths differ here. The app spawns this\n # script with `powershell.exe` (Windows PowerShell 5.1, see\n # backend-installer.ts), where -TimeoutSec is the REQUEST\'s timeout - 120\n # seconds to complete the transfer. On PowerShell 7.4+ it was renamed to\n # -OperationTimeoutSeconds and -TimeoutSec survives only as an ALIAS of\n # -ConnectionTimeoutSeconds, i.e. a connect bound, so on a 7.x host (the CI\n # runner is one) a mirror that accepts and then stalls is not ended by this.\n # Do not "fix" that by adding the 7.x spelling: 5.1 does not know\n # -OperationTimeoutSeconds, and an unknown parameter is a binding error which\n # the catch below turns into `exit 1` on every install. The version-agnostic\n # answer is a bound on the transfer itself (a BITS job or a size/rate check),\n # which is a larger change than this one and is recorded rather than made.\n try {\n Invoke-WebRequest -Uri "https://github.com/pyenv-win/pyenv-win/archive/master.zip" -OutFile $PyenvZip -TimeoutSec 120 -ErrorAction Stop\n } catch {\n Remove-Item -Path $PyenvZip -Force -ErrorAction SilentlyContinue\n Write-Error "Failed to download pyenv-win from https://github.com/pyenv-win/pyenv-win/archive/master.zip within 120 seconds: $($_.Exception.Message)"\n exit 1\n }\n # -ErrorAction Stop for the same reason as the download: a truncated archive\n # must fail here rather than half-copy into $PyenvDir.\n Expand-Archive -Path $PyenvZip -DestinationPath $TempDir -ErrorAction Stop\n \n # Create .pyenv directory\n New-Item -ItemType Directory -Path $PyenvDir -Force | Out-Null\n \n # Copy pyenv-win files\n Copy-Item -Path "$TempDir\\\\pyenv-win-master\\\\*" -Destination $PyenvDir -Recurse\n \n # Set environment variables\n [System.Environment]::SetEnvironmentVariable("PYENV", "$PyenvDir\\\\pyenv-win", "User")\n [System.Environment]::SetEnvironmentVariable("PYENV_HOME", "$PyenvDir\\\\pyenv-win", "User")\n \n # Update PATH - ensure both bin and shims are added separately for better compatibility\n $Path = [System.Environment]::GetEnvironmentVariable("PATH", "User")\n $PyenvBinPath = "$PyenvDir\\\\pyenv-win\\\\bin"\n $PyenvShimsPath = "$PyenvDir\\\\pyenv-win\\\\shims"\n \n # Add bin path if not already in PATH\n if ($Path -notlike "*$PyenvBinPath*") {\n [System.Environment]::SetEnvironmentVariable("PATH", "$PyenvBinPath;$Path", "User")\n $Path = [System.Environment]::GetEnvironmentVariable("PATH", "User")\n }\n \n # Add shims path if not already in PATH\n if ($Path -notlike "*$PyenvShimsPath*") {\n [System.Environment]::SetEnvironmentVariable("PATH", "$PyenvShimsPath;$Path", "User")\n }\n \n # Set PYENV environment variables\n [System.Environment]::SetEnvironmentVariable("PYENV", "$PyenvDir\\\\pyenv-win", "User")\n [System.Environment]::SetEnvironmentVariable("PYENV_HOME", "$PyenvDir\\\\pyenv-win", "User")\n \n # Update current session PATH\n $env:PYENV = "$PyenvDir\\\\pyenv-win"\n $env:PYENV_HOME = "$PyenvDir\\\\pyenv-win"\n $env:PATH = "$PyenvDir\\\\pyenv-win\\\\bin;$PyenvDir\\\\pyenv-win\\\\shims;$env:PATH"\n \n # Refresh environment variables for the current process\n $env:Path = [System.Environment]::GetEnvironmentVariable("Path", "User") + ";" + [System.Environment]::GetEnvironmentVariable("Path", "Machine")\n \n # Clean up\n Remove-Item -Path $TempDir -Recurse -Force\n}\n\n# Refresh environment variables for current session\n$env:PYENV = "$PyenvDir\\\\pyenv-win"\n$env:PYENV_HOME = "$PyenvDir\\\\pyenv-win"\n$env:PATH = "$PyenvDir\\\\pyenv-win\\\\bin;$PyenvDir\\\\pyenv-win\\\\shims;$env:PATH"\n\n# Install Python 3.12 if not installed\n$PythonInstalled = $false\ntry {\n $InstalledVersions = & pyenv versions\n if ($InstalledVersions -like "*$PythonVersion*") {\n $PythonInstalled = $true\n }\n} catch {\n $PythonInstalled = $false\n}\n\nif (-not $PythonInstalled) {\n Write-Output "Installing Python $PythonVersion..."\n & pyenv install $PythonVersion\n if ($LASTEXITCODE -ne 0) {\n Write-Error "Failed to install Python $PythonVersion"\n exit 1\n }\n}\n\n# Set Python 3.12 as the local version\n& pyenv local $PythonVersion\nif ($LASTEXITCODE -ne 0) {\n Write-Error "Failed to set Python $PythonVersion as local version"\n exit 1\n}\n\n# Create virtual environment if it doesn\'t exist\nif (-not (Test-Path $VenvPath)) {\n Write-Output "|LO1:environment"\n Write-Output "Creating virtual environment at $VenvPath..."\n \n # Ensure the directory exists\n if (-not (Test-Path $AppDataDir)) {\n New-Item -ItemType Directory -Path $AppDataDir -Force | Out-Null\n Write-Output "Created directory: $AppDataDir"\n }\n \n # Use the full path to python from pyenv\n $PythonExe = "$PyenvDir\\\\pyenv-win\\\\versions\\\\$PythonVersion\\\\python.exe"\n \n if (Test-Path $PythonExe) {\n Write-Output "Using Python at: $PythonExe"\n & $PythonExe -m venv $VenvPath\n } else {\n Write-Output "Using system Python"\n & python -m venv $VenvPath\n }\n \n if ($LASTEXITCODE -ne 0) {\n Write-Error "Failed to create virtual environment"\n exit 1\n }\n}\n\n# Verify the virtual environment was created\nif (-not (Test-Path "$VenvPath\\\\Scripts\\\\Activate.ps1")) {\n Write-Error "Virtual environment activation script not found at $VenvPath\\\\Scripts\\\\Activate.ps1"\n exit 1\n}\n\n# --- The package install: uv when there is one, pip otherwise ------------------\n#\n# Same shape as the macOS and Linux scripts, and for the same reasons: uv resolves\n# and fetches in parallel - measured on macOS, cold cache, three runs each, same\n# interpreter: uv\'s package install is 12.8-16.1 s against pip\'s 33.0-40.7 s,\n# plus the 2.3-2.8 s pip self-upgrade this path skips, so 1.5-2.8x across two\n# operators rather than the "14.8 s against 128.9 s" quoted here before that\n# reading was withdrawn (`docs/BUILD.md` has the full set). The pip path below is\n# unchanged and runs whenever uv is absent or cannot do the job, and pip STAYS in the venv\n# because the app\'s backend-update path runs `pip install --upgrade\n# local-operator` inside this same environment - which is also why the venv is\n# still created with `python -m venv` rather than `uv venv`.\n#\n# Nothing here searches PATH for a uv: an installed uv is a version and a\n# configuration nobody in this repository chose. `LOCAL_OPERATOR_UV_BIN` is the\n# app\'s own answer (`src/main/backend/uv-tool.ts`).\n$UvBin = $env:LOCAL_OPERATOR_UV_BIN\n$UvCacheDir = "$AppDataDir\\uv-cache"\n\nfunction Test-UvUsable {\n if (-not $UvBin) { return $false }\n if (-not (Test-Path $UvBin)) { return $false }\n try {\n & $UvBin --version | Out-Null\n return ($LASTEXITCODE -eq 0)\n } catch {\n return $false\n }\n}\n\n# Drop every UV_* variable the launching environment carried, then set the three\n# settings this install depends on. Measured on uv 0.12.17: a user-level\n# `uv.toml` naming an unreachable index is obeyed by `uv pip install` and ignored\n# with `UV_NO_CONFIG=1`; an ambient `UV_INDEX_URL` changes where packages come\n# from, while `PIP_INDEX_URL` does not affect uv at all. A name list would drift\n# the day uv adds a variable - the namespace cannot.\n#\n# The names are MATERIALISED first (`@(...)` over a property projection):\n# removing entries of a collection that is still being enumerated is the shape\n# that throws `Collection was modified`.\n$uvAmbientNames = @(\n Get-ChildItem env: |\n Where-Object { $_.Name -like \'UV_*\' } |\n Select-Object -ExpandProperty Name\n)\nforeach ($uvAmbientName in $uvAmbientNames) {\n Remove-Item "env:$uvAmbientName" -ErrorAction SilentlyContinue\n}\n\n# UV_NO_CONFIG: never read `pyproject.toml`/`uv.toml`, wherever they are.\n# UV_PYTHON_DOWNLOADS=never: this install uses the interpreter it was handed and\n# never fetches another.\n# UV_CACHE_DIR: under the app\'s own support directory rather than the user\'s\n# shared uv cache.\n$env:UV_NO_CONFIG = "1"\n$env:UV_PYTHON_DOWNLOADS = "never"\n$env:UV_CACHE_DIR = $UvCacheDir\n\n# Activate virtual environment and install local-operator\n# --- Progress markers -------------------------------------------------------\n# One whole line per phase, read by the app and shown in the setup window. The\n# app matches the ENTIRE line (`|LO1:<phase>`, see src/shared/install-progress.ts)\n# and never a substring, so a marker has to stand alone: do not wrap it in\n# other text, do not re-indent it into a longer sentence, and do not emit one\n# for work this script does not actually do. A missing marker leaves the window\n# on its previous step, which is the honest failure; a marker a log line also\n# happens to produce is a wrong step presented as a measurement.\n#\n# WHY THE SCRIPT AND NOT ONLY THE APP: the install below is minutes of work on a\n# cold machine, and the app cannot see inside the venv it is about to create -\n# this is the only process that knows when the environment exists and when the\n# download starts.\nWrite-Output "|LO1:components"\nWrite-Output "Installing local-operator in virtual environment..."\n# Use PowerShell to run the activation script\n& "$VenvPath\\\\Scripts\\\\Activate.ps1"\n\n$UvInstalled = $false\nif (Test-UvUsable) {\n Write-Output "Installing local-operator with uv..."\n # No `pip install --upgrade pip` on this path: uv does not use pip.\n & $UvBin pip install --python "$VenvPath\\Scripts\\python.exe" --upgrade local-operator\n if ($LASTEXITCODE -eq 0) {\n $UvInstalled = $true\n Write-Output "local-operator installation with uv successful"\n } else {\n # The exit code is printed for the same reason as on macOS and Linux: the\n # fallback is deliberately forgiving, so this line is the only evidence\n # that a bundled uv is present and failing for every user (QA Q2).\n Write-Output "WARNING: the bundled uv is present but its install failed (exit $LASTEXITCODE); retrying with pip, which is what this script used before uv was bundled."\n }\n} else {\n if ($UvBin) {\n Write-Output "Bundled uv at $UvBin could not be run on this machine; installing with pip."\n } else {\n Write-Output "Bundled uv not available (LOCAL_OPERATOR_UV_BIN unset); installing with pip."\n }\n}\n\nif (-not $UvInstalled) {\n & python -m pip install --upgrade pip\n & python -m pip install --upgrade local-operator\n\n if ($LASTEXITCODE -ne 0) {\n Write-Error "Failed to install packages in virtual environment"\n exit 1\n }\n}\n\n# Verify installation\n$LocalOperatorInstalled = $false\ntry {\n # First try to run local-operator directly (it should be in PATH from the activated venv)\n $Version = & local-operator --version\n $LocalOperatorInstalled = $true\n Write-Output "Local Operator backend installed successfully!"\n Write-Output $Version\n} catch {\n Write-Output "Could not run local-operator directly, trying with full path..."\n try {\n # Try with explicit path\n $LocalOperatorExe = "$VenvPath\\\\Scripts\\\\local-operator.exe"\n if (Test-Path $LocalOperatorExe) {\n $Version = & $LocalOperatorExe --version\n $LocalOperatorInstalled = $true\n Write-Output "Local Operator backend installed successfully at $LocalOperatorExe!"\n Write-Output $Version\n } else {\n # Try without .exe extension\n $LocalOperatorCmd = "$VenvPath\\\\Scripts\\\\local-operator"\n if (Test-Path $LocalOperatorCmd) {\n $Version = & $LocalOperatorCmd --version\n $LocalOperatorInstalled = $true\n Write-Output "Local Operator backend installed successfully at $LocalOperatorCmd!"\n Write-Output $Version\n } else {\n Write-Error "Error: local-operator executable not found in expected locations."\n \n # Create a symlink to make it more accessible\n Write-Output "Attempting to create a symlink for local-operator..."\n $PythonModule = "$VenvPath\\\\Lib\\\\site-packages\\\\local_operator"\n if (Test-Path $PythonModule) {\n Write-Output "Found local_operator module at $PythonModule"\n \n # Create a batch file that runs the module\n $BatchContent = "@echo off`npython -m local_operator %*"\n Set-Content -Path "$VenvPath\\\\Scripts\\\\local-operator.bat" -Value $BatchContent\n \n # Test the batch file\n if (Test-Path "$VenvPath\\\\Scripts\\\\local-operator.bat") {\n Write-Output "Created local-operator.bat in Scripts directory"\n $LocalOperatorInstalled = $true\n } else {\n Write-Error "Failed to create local-operator.bat"\n exit 1\n }\n } else {\n Write-Error "local_operator module not found in site-packages"\n exit 1\n }\n }\n }\n } catch {\n Write-Error "Error: Failed to install Local Operator backend."\n Write-Error $_.Exception.Message\n exit 1\n }\n}\n\n# If we got here, installation was successful\nif ($LocalOperatorInstalled) {\n Write-Output "Local Operator backend installation verified."\n} else {\n Write-Error "Error: Failed to verify Local Operator backend installation."\n exit 1\n}\n\nWrite-Output "$(Get-Date): Installation completed successfully."\n\n# Properly close the transcript and ensure it\'s released\ntry {\n Write-Output "Finalizing installation and releasing resources..."\n # Flush any pending output\n [System.Console]::Out.Flush()\n # Stop transcript properly\n Stop-Transcript\n \n # Add a small delay to ensure file handles are released\n Start-Sleep -Seconds 1\n \n # Explicitly release any COM objects\n [System.GC]::Collect()\n [System.GC]::WaitForPendingFinalizers()\n \n Write-Output "Installation completed and resources released."\n} catch {\n Write-Error "Error during cleanup: $_"\n}\n';
|
|
11207
11207
|
const macosInstallScript = macosInstallScriptRaw;
|
|
@@ -11289,8 +11289,9 @@ function ensureUvToolExecutable(options) {
|
|
|
11289
11289
|
mode: null,
|
|
11290
11290
|
reason: "no bundled uv is staged for this architecture (a dev checkout whose `pnpm setup-python` has not run, or an artifact built before uv was bundled)"
|
|
11291
11291
|
};
|
|
11292
|
+
const platform = options.platform ?? process.platform;
|
|
11292
11293
|
const mode = fs.statSync(path2).mode & 511;
|
|
11293
|
-
if ((mode & OWNER_EXECUTE$1) !== 0)
|
|
11294
|
+
if (platform === "win32" || (mode & OWNER_EXECUTE$1) !== 0)
|
|
11294
11295
|
return { path: path2, healed: false, mode, reason: null };
|
|
11295
11296
|
try {
|
|
11296
11297
|
fs.chmodSync(path2, UV_TOOL_MODE);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{e as o,c as b,g as v,k as O,h as P,j as p,l as w,m as A,n as x,t as c,o as N}from"./_baseUniq-
|
|
1
|
+
import{e as o,c as b,g as v,k as O,h as P,j as p,l as w,m as A,n as x,t as c,o as N}from"./_baseUniq-lQY3ywEZ.js";import{as as g,aa as y,at as E,au as F,av as M,aw as I,ax as _,ay as $,az as B,aA as T}from"./mermaid.core-SWP-HDAp.js";var S=/\s/;function z(n){for(var r=n.length;r--&&S.test(n.charAt(r)););return r}var G=/^\s+/;function H(n){return n&&n.slice(0,z(n)+1).replace(G,"")}var m=NaN,L=/^[-+]0x[0-9a-f]+$/i,R=/^0b[01]+$/i,q=/^0o[0-7]+$/i,C=parseInt;function K(n){if(typeof n=="number")return n;if(o(n))return m;if(g(n)){var r=typeof n.valueOf=="function"?n.valueOf():n;n=g(r)?r+"":r}if(typeof n!="string")return n===0?n:+n;n=H(n);var t=R.test(n);return t||q.test(n)?C(n.slice(2),t?2:8):L.test(n)?m:+n}var W=1/0,X=17976931348623157e292;function Y(n){if(!n)return n===0?n:0;if(n=K(n),n===W||n===-1/0){var r=n<0?-1:1;return r*X}return n===n?n:0}function D(n){var r=Y(n),t=r%1;return r===r?t?r-t:r:0}function fn(n){var r=n==null?0:n.length;return r?b(n):[]}var l=Object.prototype,J=l.hasOwnProperty,dn=y(function(n,r){n=Object(n);var t=-1,e=r.length,a=e>2?r[2]:void 0;for(a&&E(r[0],r[1],a)&&(e=1);++t<e;)for(var f=r[t],i=F(f),s=-1,d=i.length;++s<d;){var u=i[s],h=n[u];(h===void 0||M(h,l[u])&&!J.call(n,u))&&(n[u]=f[u])}return n});function un(n){var r=n==null?0:n.length;return r?n[r-1]:void 0}function Q(n){return function(r,t,e){var a=Object(r);if(!I(r)){var f=v(t);r=O(r),t=function(s){return f(a[s],s,a)}}var i=n(r,t,e);return i>-1?a[f?r[i]:i]:void 0}}var U=Math.max;function Z(n,r,t){var e=n==null?0:n.length;if(!e)return-1;var a=t==null?0:D(t);return a<0&&(a=U(e+a,0)),P(n,v(r),a)}var hn=Q(Z);function V(n,r){var t=-1,e=I(n)?Array(n.length):[];return p(n,function(a,f,i){e[++t]=r(a,f,i)}),e}function gn(n,r){var t=_(n)?w:V;return t(n,v(r))}var j=Object.prototype,k=j.hasOwnProperty;function nn(n,r){return n!=null&&k.call(n,r)}function vn(n,r){return n!=null&&A(n,r,nn)}function rn(n,r){return n<r}function tn(n,r,t){for(var e=-1,a=n.length;++e<a;){var f=n[e],i=r(f);if(i!=null&&(s===void 0?i===i&&!o(i):t(i,s)))var s=i,d=f}return d}function mn(n){return n&&n.length?tn(n,$,rn):void 0}function an(n,r,t,e){if(!g(n))return n;r=x(r,n);for(var a=-1,f=r.length,i=f-1,s=n;s!=null&&++a<f;){var d=c(r[a]),u=t;if(d==="__proto__"||d==="constructor"||d==="prototype")return n;if(a!=i){var h=s[d];u=void 0,u===void 0&&(u=g(h)?h:B(r[a+1])?[]:{})}T(s,d,u),s=s[d]}return n}function on(n,r,t){for(var e=-1,a=r.length,f={};++e<a;){var i=r[e],s=N(n,i);t(s,i)&&an(f,x(i,n),s)}return f}export{rn as a,tn as b,V as c,on as d,mn as e,fn as f,hn as g,vn as h,dn as i,D as j,un as l,gn as m,Y as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{aH as S,aI as Rn,ax as T,aJ as w,aK as xn,aL as Mn,aw as sn,aM as mn,aN as un,aO as x,au as U,aP as Cn,aQ as on,aR as Fn,aS as E,aF as gn,aT as R,as as ln,aU as Dn,aV as D,aW as Gn,aX as Un,aY as _,aA as Nn,aZ as Bn,av as Kn,a_ as X,a$ as Hn,b0 as jn,az as Yn,ay as cn,aD as Zn,b1 as m}from"./mermaid.core-D22o0-Xw.js";var qn="[object Symbol]";function N(n){return typeof n=="symbol"||S(n)&&Rn(n)==qn}function dn(n,r){for(var e=-1,t=n==null?0:n.length,a=Array(t);++e<t;)a[e]=r(n[e],e,n);return a}var J=w?w.prototype:void 0,Q=J?J.toString:void 0;function pn(n){if(typeof n=="string")return n;if(T(n))return dn(n,pn)+"";if(N(n))return Q?Q.call(n):"";var r=n+"";return r=="0"&&1/n==-1/0?"-0":r}function Xn(){}function An(n,r){for(var e=-1,t=n==null?0:n.length;++e<t&&r(n[e],e,n)!==!1;);return n}function Jn(n,r,e,t){for(var a=n.length,i=e+-1;++i<a;)if(r(n[i],i,n))return i;return-1}function Qn(n){return n!==n}function Wn(n,r,e){for(var t=e-1,a=n.length;++t<a;)if(n[t]===r)return t;return-1}function zn(n,r,e){return r===r?Wn(n,r,e):Jn(n,Qn,e)}function Vn(n,r){var e=n==null?0:n.length;return!!e&&zn(n,r,0)>-1}function $(n){return sn(n)?xn(n):Mn(n)}var kn=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,nr=/^\w*$/;function B(n,r){if(T(n))return!1;var e=typeof n;return e=="number"||e=="symbol"||e=="boolean"||n==null||N(n)?!0:nr.test(n)||!kn.test(n)||r!=null&&n in Object(r)}var rr=500;function er(n){var r=mn(n,function(t){return e.size===rr&&e.clear(),t}),e=r.cache;return r}var tr=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,ir=/\\(\\)?/g,ar=er(function(n){var r=[];return n.charCodeAt(0)===46&&r.push(""),n.replace(tr,function(e,t,a,i){r.push(a?i.replace(ir,"$1"):t||e)}),r});function fr(n){return n==null?"":pn(n)}function yn(n,r){return T(n)?n:B(n,r)?[n]:ar(fr(n))}function M(n){if(typeof n=="string"||N(n))return n;var r=n+"";return r=="0"&&1/n==-1/0?"-0":r}function bn(n,r){r=yn(r,n);for(var e=0,t=r.length;n!=null&&e<t;)n=n[M(r[e++])];return e&&e==t?n:void 0}function sr(n,r,e){var t=n==null?void 0:bn(n,r);return t===void 0?e:t}function K(n,r){for(var e=-1,t=r.length,a=n.length;++e<t;)n[a+e]=r[e];return n}var W=w?w.isConcatSpreadable:void 0;function ur(n){return T(n)||un(n)||!!(W&&n&&n[W])}function Ot(n,r,e,t,a){var i=-1,f=n.length;for(e||(e=ur),a||(a=[]);++i<f;){var s=n[i];e(s)?K(a,s):t||(a[a.length]=s)}return a}function or(n,r,e,t){var a=-1,i=n==null?0:n.length;for(t&&i&&(e=n[++a]);++a<i;)e=r(e,n[a],a,n);return e}function gr(n,r){return n&&x(r,$(r),n)}function lr(n,r){return n&&x(r,U(r),n)}function Tn(n,r){for(var e=-1,t=n==null?0:n.length,a=0,i=[];++e<t;){var f=n[e];r(f,e,n)&&(i[a++]=f)}return i}function hn(){return[]}var cr=Object.prototype,dr=cr.propertyIsEnumerable,z=Object.getOwnPropertySymbols,H=z?function(n){return n==null?[]:(n=Object(n),Tn(z(n),function(r){return dr.call(n,r)}))}:hn;function pr(n,r){return x(n,H(n),r)}var Ar=Object.getOwnPropertySymbols,wn=Ar?function(n){for(var r=[];n;)K(r,H(n)),n=Cn(n);return r}:hn;function yr(n,r){return x(n,wn(n),r)}function On(n,r,e){var t=r(n);return T(n)?t:K(t,e(n))}function G(n){return On(n,$,H)}function br(n){return On(n,U,wn)}var Tr=Object.prototype,hr=Tr.hasOwnProperty;function wr(n){var r=n.length,e=new n.constructor(r);return r&&typeof n[0]=="string"&&hr.call(n,"index")&&(e.index=n.index,e.input=n.input),e}function Or(n,r){var e=r?on(n.buffer):n.buffer;return new n.constructor(e,n.byteOffset,n.byteLength)}var $r=/\w*$/;function _r(n){var r=new n.constructor(n.source,$r.exec(n));return r.lastIndex=n.lastIndex,r}var V=w?w.prototype:void 0,k=V?V.valueOf:void 0;function Sr(n){return k?Object(k.call(n)):{}}var Er="[object Boolean]",Ir="[object Date]",Pr="[object Map]",vr="[object Number]",Lr="[object RegExp]",Rr="[object Set]",xr="[object String]",Mr="[object Symbol]",mr="[object ArrayBuffer]",Cr="[object DataView]",Fr="[object Float32Array]",Dr="[object Float64Array]",Gr="[object Int8Array]",Ur="[object Int16Array]",Nr="[object Int32Array]",Br="[object Uint8Array]",Kr="[object Uint8ClampedArray]",Hr="[object Uint16Array]",jr="[object Uint32Array]";function Yr(n,r,e){var t=n.constructor;switch(r){case mr:return on(n);case Er:case Ir:return new t(+n);case Cr:return Or(n,e);case Fr:case Dr:case Gr:case Ur:case Nr:case Br:case Kr:case Hr:case jr:return Fn(n,e);case Pr:return new t;case vr:case xr:return new t(n);case Lr:return _r(n);case Rr:return new t;case Mr:return Sr(n)}}var Zr="[object Map]";function qr(n){return S(n)&&E(n)==Zr}var nn=R&&R.isMap,Xr=nn?gn(nn):qr,Jr="[object Set]";function Qr(n){return S(n)&&E(n)==Jr}var rn=R&&R.isSet,Wr=rn?gn(rn):Qr,zr=1,Vr=2,kr=4,$n="[object Arguments]",ne="[object Array]",re="[object Boolean]",ee="[object Date]",te="[object Error]",_n="[object Function]",ie="[object GeneratorFunction]",ae="[object Map]",fe="[object Number]",Sn="[object Object]",se="[object RegExp]",ue="[object Set]",oe="[object String]",ge="[object Symbol]",le="[object WeakMap]",ce="[object ArrayBuffer]",de="[object DataView]",pe="[object Float32Array]",Ae="[object Float64Array]",ye="[object Int8Array]",be="[object Int16Array]",Te="[object Int32Array]",he="[object Uint8Array]",we="[object Uint8ClampedArray]",Oe="[object Uint16Array]",$e="[object Uint32Array]",g={};g[$n]=g[ne]=g[ce]=g[de]=g[re]=g[ee]=g[pe]=g[Ae]=g[ye]=g[be]=g[Te]=g[ae]=g[fe]=g[Sn]=g[se]=g[ue]=g[oe]=g[ge]=g[he]=g[we]=g[Oe]=g[$e]=!0;g[te]=g[_n]=g[le]=!1;function C(n,r,e,t,a,i){var f,s=r&zr,u=r&Vr,d=r&kr;if(f!==void 0)return f;if(!ln(n))return n;var l=T(n);if(l){if(f=wr(n),!s)return Dn(n,f)}else{var o=E(n),c=o==_n||o==ie;if(D(n))return Gn(n,s);if(o==Sn||o==$n||c&&!a){if(f=u||c?{}:Un(n),!s)return u?yr(n,lr(f,n)):pr(n,gr(f,n))}else{if(!g[o])return a?n:{};f=Yr(n,o,s)}}i||(i=new _);var h=i.get(n);if(h)return h;i.set(n,f),Wr(n)?n.forEach(function(p){f.add(C(p,r,e,p,n,i))}):Xr(n)&&n.forEach(function(p,A){f.set(A,C(p,r,e,A,n,i))});var y=d?u?br:G:u?U:$,b=l?void 0:y(n);return An(b||n,function(p,A){b&&(A=p,p=n[A]),Nn(f,A,C(p,r,e,A,n,i))}),f}var _e="__lodash_hash_undefined__";function Se(n){return this.__data__.set(n,_e),this}function Ee(n){return this.__data__.has(n)}function I(n){var r=-1,e=n==null?0:n.length;for(this.__data__=new Bn;++r<e;)this.add(n[r])}I.prototype.add=I.prototype.push=Se;I.prototype.has=Ee;function Ie(n,r){for(var e=-1,t=n==null?0:n.length;++e<t;)if(r(n[e],e,n))return!0;return!1}function En(n,r){return n.has(r)}var Pe=1,ve=2;function In(n,r,e,t,a,i){var f=e&Pe,s=n.length,u=r.length;if(s!=u&&!(f&&u>s))return!1;var d=i.get(n),l=i.get(r);if(d&&l)return d==r&&l==n;var o=-1,c=!0,h=e&ve?new I:void 0;for(i.set(n,r),i.set(r,n);++o<s;){var y=n[o],b=r[o];if(t)var p=f?t(b,y,o,r,n,i):t(y,b,o,n,r,i);if(p!==void 0){if(p)continue;c=!1;break}if(h){if(!Ie(r,function(A,O){if(!En(h,O)&&(y===A||a(y,A,e,t,i)))return h.push(O)})){c=!1;break}}else if(!(y===b||a(y,b,e,t,i))){c=!1;break}}return i.delete(n),i.delete(r),c}function Le(n){var r=-1,e=Array(n.size);return n.forEach(function(t,a){e[++r]=[a,t]}),e}function j(n){var r=-1,e=Array(n.size);return n.forEach(function(t){e[++r]=t}),e}var Re=1,xe=2,Me="[object Boolean]",me="[object Date]",Ce="[object Error]",Fe="[object Map]",De="[object Number]",Ge="[object RegExp]",Ue="[object Set]",Ne="[object String]",Be="[object Symbol]",Ke="[object ArrayBuffer]",He="[object DataView]",en=w?w.prototype:void 0,F=en?en.valueOf:void 0;function je(n,r,e,t,a,i,f){switch(e){case He:if(n.byteLength!=r.byteLength||n.byteOffset!=r.byteOffset)return!1;n=n.buffer,r=r.buffer;case Ke:return!(n.byteLength!=r.byteLength||!i(new X(n),new X(r)));case Me:case me:case De:return Kn(+n,+r);case Ce:return n.name==r.name&&n.message==r.message;case Ge:case Ne:return n==r+"";case Fe:var s=Le;case Ue:var u=tℜif(s||(s=j),n.size!=r.size&&!u)return!1;var d=f.get(n);if(d)return d==r;t|=xe,f.set(n,r);var l=In(s(n),s(r),t,a,i,f);return f.delete(n),l;case Be:if(F)return F.call(n)==F.call(r)}return!1}var Ye=1,Ze=Object.prototype,qe=Ze.hasOwnProperty;function Xe(n,r,e,t,a,i){var f=e&Ye,s=G(n),u=s.length,d=G(r),l=d.length;if(u!=l&&!f)return!1;for(var o=u;o--;){var c=s[o];if(!(f?c in r:qe.call(r,c)))return!1}var h=i.get(n),y=i.get(r);if(h&&y)return h==r&&y==n;var b=!0;i.set(n,r),i.set(r,n);for(var p=f;++o<u;){c=s[o];var A=n[c],O=r[c];if(t)var q=f?t(O,A,c,r,n,i):t(A,O,c,n,r,i);if(!(q===void 0?A===O||a(A,O,e,t,i):q)){b=!1;break}p||(p=c=="constructor")}if(b&&!p){var P=n.constructor,v=r.constructor;P!=v&&"constructor"in n&&"constructor"in r&&!(typeof P=="function"&&P instanceof P&&typeof v=="function"&&v instanceof v)&&(b=!1)}return i.delete(n),i.delete(r),b}var Je=1,tn="[object Arguments]",an="[object Array]",L="[object Object]",Qe=Object.prototype,fn=Qe.hasOwnProperty;function We(n,r,e,t,a,i){var f=T(n),s=T(r),u=f?an:E(n),d=s?an:E(r);u=u==tn?L:u,d=d==tn?L:d;var l=u==L,o=d==L,c=u==d;if(c&&D(n)){if(!D(r))return!1;f=!0,l=!1}if(c&&!l)return i||(i=new _),f||Hn(n)?In(n,r,e,t,a,i):je(n,r,u,e,t,a,i);if(!(e&Je)){var h=l&&fn.call(n,"__wrapped__"),y=o&&fn.call(r,"__wrapped__");if(h||y){var b=h?n.value():n,p=y?r.value():r;return i||(i=new _),a(b,p,e,t,i)}}return c?(i||(i=new _),Xe(n,r,e,t,a,i)):!1}function Y(n,r,e,t,a){return n===r?!0:n==null||r==null||!S(n)&&!S(r)?n!==n&&r!==r:We(n,r,e,t,Y,a)}var ze=1,Ve=2;function ke(n,r,e,t){var a=e.length,i=a;if(n==null)return!i;for(n=Object(n);a--;){var f=e[a];if(f[2]?f[1]!==n[f[0]]:!(f[0]in n))return!1}for(;++a<i;){f=e[a];var s=f[0],u=n[s],d=f[1];if(f[2]){if(u===void 0&&!(s in n))return!1}else{var l=new _,o;if(!(o===void 0?Y(d,u,ze|Ve,t,l):o))return!1}}return!0}function Pn(n){return n===n&&!ln(n)}function nt(n){for(var r=$(n),e=r.length;e--;){var t=r[e],a=n[t];r[e]=[t,a,Pn(a)]}return r}function vn(n,r){return function(e){return e==null?!1:e[n]===r&&(r!==void 0||n in Object(e))}}function rt(n){var r=nt(n);return r.length==1&&r[0][2]?vn(r[0][0],r[0][1]):function(e){return e===n||ke(e,n,r)}}function et(n,r){return n!=null&&r in Object(n)}function tt(n,r,e){r=yn(r,n);for(var t=-1,a=r.length,i=!1;++t<a;){var f=M(r[t]);if(!(i=n!=null&&e(n,f)))break;n=n[f]}return i||++t!=a?i:(a=n==null?0:n.length,!!a&&jn(a)&&Yn(f,a)&&(T(n)||un(n)))}function it(n,r){return n!=null&&tt(n,r,et)}var at=1,ft=2;function st(n,r){return B(n)&&Pn(r)?vn(M(n),r):function(e){var t=sr(e,n);return t===void 0&&t===r?it(e,n):Y(r,t,at|ft)}}function ut(n){return function(r){return r?.[n]}}function ot(n){return function(r){return bn(r,n)}}function gt(n){return B(n)?ut(M(n)):ot(n)}function Ln(n){return typeof n=="function"?n:n==null?cn:typeof n=="object"?T(n)?st(n[0],n[1]):rt(n):gt(n)}function lt(n,r){return n&&Zn(n,r,$)}function ct(n,r){return function(e,t){if(e==null)return e;if(!sn(e))return n(e,t);for(var a=e.length,i=-1,f=Object(e);++i<a&&t(f[i],i,f)!==!1;);return e}}var Z=ct(lt);function dt(n){return typeof n=="function"?n:cn}function $t(n,r){var e=T(n)?An:Z;return e(n,dt(r))}function pt(n,r){var e=[];return Z(n,function(t,a,i){r(t,a,i)&&e.push(t)}),e}function _t(n,r){var e=T(n)?Tn:pt;return e(n,Ln(r))}function At(n,r){return dn(r,function(e){return n[e]})}function St(n){return n==null?[]:At(n,$(n))}function Et(n){return n===void 0}function yt(n,r,e,t,a){return a(n,function(i,f,s){e=t?(t=!1,i):r(e,i,f,s)}),e}function It(n,r,e){var t=T(n)?or:yt,a=arguments.length<3;return t(n,Ln(r),e,a,Z)}var bt=1/0,Tt=m&&1/j(new m([,-0]))[1]==bt?function(n){return new m(n)}:Xn,ht=200;function Pt(n,r,e){var t=-1,a=Vn,i=n.length,f=!0,s=[],u=s;if(i>=ht){var d=r?null:Tt(n);if(d)return j(d);f=!1,a=En,u=new I}else u=r?[]:s;n:for(;++t<i;){var l=n[t],o=r?r(l):l;if(l=l!==0?l:0,f&&o===o){for(var c=u.length;c--;)if(u[c]===o)continue n;r&&u.push(o),s.push(l)}else a(u,o,e)||(u!==s&&u.push(o),s.push(l))}return s}export{Tn as A,pt as B,Ie as C,Xn as D,I as S,Pt as a,C as b,Ot as c,$t as d,N as e,_t as f,Ln as g,Jn as h,Et as i,Z as j,$ as k,dn as l,tt as m,yn as n,bn as o,dt as p,lt as q,It as r,it as s,M as t,fr as u,St as v,Vn as w,En as x,zn as y,br as z};
|
|
1
|
+
import{aH as S,aI as Rn,ax as T,aJ as w,aK as xn,aL as Mn,aw as sn,aM as mn,aN as un,aO as x,au as U,aP as Cn,aQ as on,aR as Fn,aS as E,aF as gn,aT as R,as as ln,aU as Dn,aV as D,aW as Gn,aX as Un,aY as _,aA as Nn,aZ as Bn,av as Kn,a_ as X,a$ as Hn,b0 as jn,az as Yn,ay as cn,aD as Zn,b1 as m}from"./mermaid.core-SWP-HDAp.js";var qn="[object Symbol]";function N(n){return typeof n=="symbol"||S(n)&&Rn(n)==qn}function dn(n,r){for(var e=-1,t=n==null?0:n.length,a=Array(t);++e<t;)a[e]=r(n[e],e,n);return a}var J=w?w.prototype:void 0,Q=J?J.toString:void 0;function pn(n){if(typeof n=="string")return n;if(T(n))return dn(n,pn)+"";if(N(n))return Q?Q.call(n):"";var r=n+"";return r=="0"&&1/n==-1/0?"-0":r}function Xn(){}function An(n,r){for(var e=-1,t=n==null?0:n.length;++e<t&&r(n[e],e,n)!==!1;);return n}function Jn(n,r,e,t){for(var a=n.length,i=e+-1;++i<a;)if(r(n[i],i,n))return i;return-1}function Qn(n){return n!==n}function Wn(n,r,e){for(var t=e-1,a=n.length;++t<a;)if(n[t]===r)return t;return-1}function zn(n,r,e){return r===r?Wn(n,r,e):Jn(n,Qn,e)}function Vn(n,r){var e=n==null?0:n.length;return!!e&&zn(n,r,0)>-1}function $(n){return sn(n)?xn(n):Mn(n)}var kn=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,nr=/^\w*$/;function B(n,r){if(T(n))return!1;var e=typeof n;return e=="number"||e=="symbol"||e=="boolean"||n==null||N(n)?!0:nr.test(n)||!kn.test(n)||r!=null&&n in Object(r)}var rr=500;function er(n){var r=mn(n,function(t){return e.size===rr&&e.clear(),t}),e=r.cache;return r}var tr=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,ir=/\\(\\)?/g,ar=er(function(n){var r=[];return n.charCodeAt(0)===46&&r.push(""),n.replace(tr,function(e,t,a,i){r.push(a?i.replace(ir,"$1"):t||e)}),r});function fr(n){return n==null?"":pn(n)}function yn(n,r){return T(n)?n:B(n,r)?[n]:ar(fr(n))}function M(n){if(typeof n=="string"||N(n))return n;var r=n+"";return r=="0"&&1/n==-1/0?"-0":r}function bn(n,r){r=yn(r,n);for(var e=0,t=r.length;n!=null&&e<t;)n=n[M(r[e++])];return e&&e==t?n:void 0}function sr(n,r,e){var t=n==null?void 0:bn(n,r);return t===void 0?e:t}function K(n,r){for(var e=-1,t=r.length,a=n.length;++e<t;)n[a+e]=r[e];return n}var W=w?w.isConcatSpreadable:void 0;function ur(n){return T(n)||un(n)||!!(W&&n&&n[W])}function Ot(n,r,e,t,a){var i=-1,f=n.length;for(e||(e=ur),a||(a=[]);++i<f;){var s=n[i];e(s)?K(a,s):t||(a[a.length]=s)}return a}function or(n,r,e,t){var a=-1,i=n==null?0:n.length;for(t&&i&&(e=n[++a]);++a<i;)e=r(e,n[a],a,n);return e}function gr(n,r){return n&&x(r,$(r),n)}function lr(n,r){return n&&x(r,U(r),n)}function Tn(n,r){for(var e=-1,t=n==null?0:n.length,a=0,i=[];++e<t;){var f=n[e];r(f,e,n)&&(i[a++]=f)}return i}function hn(){return[]}var cr=Object.prototype,dr=cr.propertyIsEnumerable,z=Object.getOwnPropertySymbols,H=z?function(n){return n==null?[]:(n=Object(n),Tn(z(n),function(r){return dr.call(n,r)}))}:hn;function pr(n,r){return x(n,H(n),r)}var Ar=Object.getOwnPropertySymbols,wn=Ar?function(n){for(var r=[];n;)K(r,H(n)),n=Cn(n);return r}:hn;function yr(n,r){return x(n,wn(n),r)}function On(n,r,e){var t=r(n);return T(n)?t:K(t,e(n))}function G(n){return On(n,$,H)}function br(n){return On(n,U,wn)}var Tr=Object.prototype,hr=Tr.hasOwnProperty;function wr(n){var r=n.length,e=new n.constructor(r);return r&&typeof n[0]=="string"&&hr.call(n,"index")&&(e.index=n.index,e.input=n.input),e}function Or(n,r){var e=r?on(n.buffer):n.buffer;return new n.constructor(e,n.byteOffset,n.byteLength)}var $r=/\w*$/;function _r(n){var r=new n.constructor(n.source,$r.exec(n));return r.lastIndex=n.lastIndex,r}var V=w?w.prototype:void 0,k=V?V.valueOf:void 0;function Sr(n){return k?Object(k.call(n)):{}}var Er="[object Boolean]",Ir="[object Date]",Pr="[object Map]",vr="[object Number]",Lr="[object RegExp]",Rr="[object Set]",xr="[object String]",Mr="[object Symbol]",mr="[object ArrayBuffer]",Cr="[object DataView]",Fr="[object Float32Array]",Dr="[object Float64Array]",Gr="[object Int8Array]",Ur="[object Int16Array]",Nr="[object Int32Array]",Br="[object Uint8Array]",Kr="[object Uint8ClampedArray]",Hr="[object Uint16Array]",jr="[object Uint32Array]";function Yr(n,r,e){var t=n.constructor;switch(r){case mr:return on(n);case Er:case Ir:return new t(+n);case Cr:return Or(n,e);case Fr:case Dr:case Gr:case Ur:case Nr:case Br:case Kr:case Hr:case jr:return Fn(n,e);case Pr:return new t;case vr:case xr:return new t(n);case Lr:return _r(n);case Rr:return new t;case Mr:return Sr(n)}}var Zr="[object Map]";function qr(n){return S(n)&&E(n)==Zr}var nn=R&&R.isMap,Xr=nn?gn(nn):qr,Jr="[object Set]";function Qr(n){return S(n)&&E(n)==Jr}var rn=R&&R.isSet,Wr=rn?gn(rn):Qr,zr=1,Vr=2,kr=4,$n="[object Arguments]",ne="[object Array]",re="[object Boolean]",ee="[object Date]",te="[object Error]",_n="[object Function]",ie="[object GeneratorFunction]",ae="[object Map]",fe="[object Number]",Sn="[object Object]",se="[object RegExp]",ue="[object Set]",oe="[object String]",ge="[object Symbol]",le="[object WeakMap]",ce="[object ArrayBuffer]",de="[object DataView]",pe="[object Float32Array]",Ae="[object Float64Array]",ye="[object Int8Array]",be="[object Int16Array]",Te="[object Int32Array]",he="[object Uint8Array]",we="[object Uint8ClampedArray]",Oe="[object Uint16Array]",$e="[object Uint32Array]",g={};g[$n]=g[ne]=g[ce]=g[de]=g[re]=g[ee]=g[pe]=g[Ae]=g[ye]=g[be]=g[Te]=g[ae]=g[fe]=g[Sn]=g[se]=g[ue]=g[oe]=g[ge]=g[he]=g[we]=g[Oe]=g[$e]=!0;g[te]=g[_n]=g[le]=!1;function C(n,r,e,t,a,i){var f,s=r&zr,u=r&Vr,d=r&kr;if(f!==void 0)return f;if(!ln(n))return n;var l=T(n);if(l){if(f=wr(n),!s)return Dn(n,f)}else{var o=E(n),c=o==_n||o==ie;if(D(n))return Gn(n,s);if(o==Sn||o==$n||c&&!a){if(f=u||c?{}:Un(n),!s)return u?yr(n,lr(f,n)):pr(n,gr(f,n))}else{if(!g[o])return a?n:{};f=Yr(n,o,s)}}i||(i=new _);var h=i.get(n);if(h)return h;i.set(n,f),Wr(n)?n.forEach(function(p){f.add(C(p,r,e,p,n,i))}):Xr(n)&&n.forEach(function(p,A){f.set(A,C(p,r,e,A,n,i))});var y=d?u?br:G:u?U:$,b=l?void 0:y(n);return An(b||n,function(p,A){b&&(A=p,p=n[A]),Nn(f,A,C(p,r,e,A,n,i))}),f}var _e="__lodash_hash_undefined__";function Se(n){return this.__data__.set(n,_e),this}function Ee(n){return this.__data__.has(n)}function I(n){var r=-1,e=n==null?0:n.length;for(this.__data__=new Bn;++r<e;)this.add(n[r])}I.prototype.add=I.prototype.push=Se;I.prototype.has=Ee;function Ie(n,r){for(var e=-1,t=n==null?0:n.length;++e<t;)if(r(n[e],e,n))return!0;return!1}function En(n,r){return n.has(r)}var Pe=1,ve=2;function In(n,r,e,t,a,i){var f=e&Pe,s=n.length,u=r.length;if(s!=u&&!(f&&u>s))return!1;var d=i.get(n),l=i.get(r);if(d&&l)return d==r&&l==n;var o=-1,c=!0,h=e&ve?new I:void 0;for(i.set(n,r),i.set(r,n);++o<s;){var y=n[o],b=r[o];if(t)var p=f?t(b,y,o,r,n,i):t(y,b,o,n,r,i);if(p!==void 0){if(p)continue;c=!1;break}if(h){if(!Ie(r,function(A,O){if(!En(h,O)&&(y===A||a(y,A,e,t,i)))return h.push(O)})){c=!1;break}}else if(!(y===b||a(y,b,e,t,i))){c=!1;break}}return i.delete(n),i.delete(r),c}function Le(n){var r=-1,e=Array(n.size);return n.forEach(function(t,a){e[++r]=[a,t]}),e}function j(n){var r=-1,e=Array(n.size);return n.forEach(function(t){e[++r]=t}),e}var Re=1,xe=2,Me="[object Boolean]",me="[object Date]",Ce="[object Error]",Fe="[object Map]",De="[object Number]",Ge="[object RegExp]",Ue="[object Set]",Ne="[object String]",Be="[object Symbol]",Ke="[object ArrayBuffer]",He="[object DataView]",en=w?w.prototype:void 0,F=en?en.valueOf:void 0;function je(n,r,e,t,a,i,f){switch(e){case He:if(n.byteLength!=r.byteLength||n.byteOffset!=r.byteOffset)return!1;n=n.buffer,r=r.buffer;case Ke:return!(n.byteLength!=r.byteLength||!i(new X(n),new X(r)));case Me:case me:case De:return Kn(+n,+r);case Ce:return n.name==r.name&&n.message==r.message;case Ge:case Ne:return n==r+"";case Fe:var s=Le;case Ue:var u=tℜif(s||(s=j),n.size!=r.size&&!u)return!1;var d=f.get(n);if(d)return d==r;t|=xe,f.set(n,r);var l=In(s(n),s(r),t,a,i,f);return f.delete(n),l;case Be:if(F)return F.call(n)==F.call(r)}return!1}var Ye=1,Ze=Object.prototype,qe=Ze.hasOwnProperty;function Xe(n,r,e,t,a,i){var f=e&Ye,s=G(n),u=s.length,d=G(r),l=d.length;if(u!=l&&!f)return!1;for(var o=u;o--;){var c=s[o];if(!(f?c in r:qe.call(r,c)))return!1}var h=i.get(n),y=i.get(r);if(h&&y)return h==r&&y==n;var b=!0;i.set(n,r),i.set(r,n);for(var p=f;++o<u;){c=s[o];var A=n[c],O=r[c];if(t)var q=f?t(O,A,c,r,n,i):t(A,O,c,n,r,i);if(!(q===void 0?A===O||a(A,O,e,t,i):q)){b=!1;break}p||(p=c=="constructor")}if(b&&!p){var P=n.constructor,v=r.constructor;P!=v&&"constructor"in n&&"constructor"in r&&!(typeof P=="function"&&P instanceof P&&typeof v=="function"&&v instanceof v)&&(b=!1)}return i.delete(n),i.delete(r),b}var Je=1,tn="[object Arguments]",an="[object Array]",L="[object Object]",Qe=Object.prototype,fn=Qe.hasOwnProperty;function We(n,r,e,t,a,i){var f=T(n),s=T(r),u=f?an:E(n),d=s?an:E(r);u=u==tn?L:u,d=d==tn?L:d;var l=u==L,o=d==L,c=u==d;if(c&&D(n)){if(!D(r))return!1;f=!0,l=!1}if(c&&!l)return i||(i=new _),f||Hn(n)?In(n,r,e,t,a,i):je(n,r,u,e,t,a,i);if(!(e&Je)){var h=l&&fn.call(n,"__wrapped__"),y=o&&fn.call(r,"__wrapped__");if(h||y){var b=h?n.value():n,p=y?r.value():r;return i||(i=new _),a(b,p,e,t,i)}}return c?(i||(i=new _),Xe(n,r,e,t,a,i)):!1}function Y(n,r,e,t,a){return n===r?!0:n==null||r==null||!S(n)&&!S(r)?n!==n&&r!==r:We(n,r,e,t,Y,a)}var ze=1,Ve=2;function ke(n,r,e,t){var a=e.length,i=a;if(n==null)return!i;for(n=Object(n);a--;){var f=e[a];if(f[2]?f[1]!==n[f[0]]:!(f[0]in n))return!1}for(;++a<i;){f=e[a];var s=f[0],u=n[s],d=f[1];if(f[2]){if(u===void 0&&!(s in n))return!1}else{var l=new _,o;if(!(o===void 0?Y(d,u,ze|Ve,t,l):o))return!1}}return!0}function Pn(n){return n===n&&!ln(n)}function nt(n){for(var r=$(n),e=r.length;e--;){var t=r[e],a=n[t];r[e]=[t,a,Pn(a)]}return r}function vn(n,r){return function(e){return e==null?!1:e[n]===r&&(r!==void 0||n in Object(e))}}function rt(n){var r=nt(n);return r.length==1&&r[0][2]?vn(r[0][0],r[0][1]):function(e){return e===n||ke(e,n,r)}}function et(n,r){return n!=null&&r in Object(n)}function tt(n,r,e){r=yn(r,n);for(var t=-1,a=r.length,i=!1;++t<a;){var f=M(r[t]);if(!(i=n!=null&&e(n,f)))break;n=n[f]}return i||++t!=a?i:(a=n==null?0:n.length,!!a&&jn(a)&&Yn(f,a)&&(T(n)||un(n)))}function it(n,r){return n!=null&&tt(n,r,et)}var at=1,ft=2;function st(n,r){return B(n)&&Pn(r)?vn(M(n),r):function(e){var t=sr(e,n);return t===void 0&&t===r?it(e,n):Y(r,t,at|ft)}}function ut(n){return function(r){return r?.[n]}}function ot(n){return function(r){return bn(r,n)}}function gt(n){return B(n)?ut(M(n)):ot(n)}function Ln(n){return typeof n=="function"?n:n==null?cn:typeof n=="object"?T(n)?st(n[0],n[1]):rt(n):gt(n)}function lt(n,r){return n&&Zn(n,r,$)}function ct(n,r){return function(e,t){if(e==null)return e;if(!sn(e))return n(e,t);for(var a=e.length,i=-1,f=Object(e);++i<a&&t(f[i],i,f)!==!1;);return e}}var Z=ct(lt);function dt(n){return typeof n=="function"?n:cn}function $t(n,r){var e=T(n)?An:Z;return e(n,dt(r))}function pt(n,r){var e=[];return Z(n,function(t,a,i){r(t,a,i)&&e.push(t)}),e}function _t(n,r){var e=T(n)?Tn:pt;return e(n,Ln(r))}function At(n,r){return dn(r,function(e){return n[e]})}function St(n){return n==null?[]:At(n,$(n))}function Et(n){return n===void 0}function yt(n,r,e,t,a){return a(n,function(i,f,s){e=t?(t=!1,i):r(e,i,f,s)}),e}function It(n,r,e){var t=T(n)?or:yt,a=arguments.length<3;return t(n,Ln(r),e,a,Z)}var bt=1/0,Tt=m&&1/j(new m([,-0]))[1]==bt?function(n){return new m(n)}:Xn,ht=200;function Pt(n,r,e){var t=-1,a=Vn,i=n.length,f=!0,s=[],u=s;if(i>=ht){var d=r?null:Tt(n);if(d)return j(d);f=!1,a=En,u=new I}else u=r?[]:s;n:for(;++t<i;){var l=n[t],o=r?r(l):l;if(l=l!==0?l:0,f&&o===o){for(var c=u.length;c--;)if(u[c]===o)continue n;r&&u.push(o),s.push(l)}else a(u,o,e)||(u!==s&&u.push(o),s.push(l))}return s}export{Tn as A,pt as B,Ie as C,Xn as D,I as S,Pt as a,C as b,Ot as c,$t as d,N as e,_t as f,Ln as g,Jn as h,Et as i,Z as j,$ as k,dn as l,tt as m,yn as n,bn as o,dt as p,lt as q,It as r,it as s,M as t,fr as u,St as v,Vn as w,En as x,zn as y,br as z};
|
package/out/renderer/assets/{agent-details-page-BrVmQlq3.js → agent-details-page-BzDE7WbM.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as D,j as e,c as V}from"./index-
|
|
1
|
+
import{r as D,j as e,c as V}from"./index-CZlj7Oq2.js";import{a as le}from"./publication-validation-7J4xzRVZ.js";import{g as te,f as L,am as b,ar as M,al as O,as as I,at as ce,au as de,av as se,h as ae,u as ue,a4 as me,aw as he,B as xe,an as ge,ao as je,ax as X,ak as fe,ay as ye,az as pe}from"./index-YQ32HBTm.js";import{c as ve,L as we,j as Z,B as l,S as z,k as ne,l as q,m as _,a as v,X as be,T as w,A as G,h as J,i as ee}from"./error-boundary-Du4Xf2hu.js";import{l as Ce,g as Ne,h as Ae,j as ke,f as R,k as Se,m as De,n as Ee,e as Te,i as Fe,u as Pe,a as qe,b as _e,H as ze,A as Le}from"./use-download-agent-mutation-9tp697PV.js";import"./console-mirror-naCglSJA.js";import"./en-US-BkS8Ixxl.js";import"./book-open-CykMtqSE.js";/**
|
|
2
2
|
* @license lucide-react v0.507.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r,j as e,c as _}from"./index-
|
|
1
|
+
import{r,j as e,c as _}from"./index-CZlj7Oq2.js";import{h as te,am as $,an as he,ao as G,ap as me,r as xe,aq as fe,a4 as ge}from"./index-YQ32HBTm.js";import{C as pe}from"./compact-pagination-B0hoPapl.js";import{P as be}from"./page-header-dIIc14HB.js";import{c as je,T as L,B as N,a as c,I as ve,b as Q,d as Z,e as J,f as W,g as X,A as Ne,h as we,i as ye}from"./error-boundary-Du4Xf2hu.js";import{a as ke}from"./publication-validation-7J4xzRVZ.js";import{A as Ce,f as Se,H as Ae,u as Re,a as Te,b as _e,c as se,C as Ee,d as Pe,e as Le,i as Fe}from"./use-download-agent-mutation-9tp697PV.js";import"./console-mirror-naCglSJA.js";import"./en-US-BkS8Ixxl.js";import"./book-open-CykMtqSE.js";/**
|
|
2
2
|
* @license lucide-react v0.507.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./legacy-agents-page-
|
|
2
|
-
import{u as O,a as Q,b as J,d as V,c as W,e as G,f as H,g as X,B as Y,U as Z,P as ee,r as te,_ as ae,h as $,i as z,j as U}from"./index-CXCGQLAf.js";import{j as e,r as n,c as P}from"./index-Brz4xf_N.js";import{B as u}from"./error-boundary-OyyPDgmi.js";import"./console-mirror-CzhHBJ89.js";const se=n.lazy(()=>ae(()=>import("./legacy-agents-page-L5nl_vP8.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11]),import.meta.url).then(t=>({default:t.LegacyAgentsPage}))),d="w-full rounded-md border border-control bg-surface px-3 py-2 text-body-sm text-ink";function T({profile:t,creating:v,onSaved:g}){const[r,k]=n.useState(!1),[o,m]=n.useState(v),[p,b]=n.useState(t?.name??""),[x,C]=n.useState(t?.kind??"role"),[h,y]=n.useState(t?.description??""),[j,S]=n.useState(t?.instructions??""),[_,D]=n.useState(t?.tools?.join(", ")??""),[I,N]=n.useState(t?.effort??"inherit"),[R,L]=n.useState(t?.delegate??!1),[f,a]=n.useState(!1),[c,l]=n.useState(null),i=n.useRef(null),w=$(),E=v||r,K=async s=>{if(s.preventDefault(),f)return;const M={kind:x,description:h,instructions:j,tools:_.split(",").map(q=>q.trim()).filter(Boolean),effort:I,delegate:R},A=JSON.stringify({name:p,fields:M,fresh:E});if(i.current&&i.current.body!==A){l("The previous save has not been confirmed. Retry it unchanged or reload the profile to reconcile before editing again.");return}i.current??={id:crypto.randomUUID(),body:A},a(!0),l(null);try{const q=await U({op:E?"profiles.create":"profiles.update",requestId:i.current.id,name:p,fields:M});i.current=null,m(!1),g(q.name)}catch(q){l(q instanceof Error?q.message:"Profile could not be saved.")}finally{a(!1)}},F=async()=>{if(!(!t||f)){a(!0),l(null);try{const s=await U({op:"profiles.install",name:t.name,requestId:crypto.randomUUID()});m(!1),k(!1),i.current=null,b(s.name),C(s.kind),y(s.description??""),S(s.instructions??""),D(s.tools?.join(", ")??""),N(s.effort??"inherit"),L(s.delegate??!1),g(s.name)}catch(s){l(s instanceof Error?s.message:"Profile could not be installed.")}finally{a(!1)}}};return e.jsxs("div",{className:"max-w-3xl space-y-6",children:[e.jsxs("header",{children:[e.jsx("h1",{className:"text-title",children:E?r?"Extend agent":"Create agent":t?.name}),e.jsx("p",{className:"mt-2 text-body-sm text-ink-muted",children:"Reusable instructions shared by agent commands, subagents and teams. Chats remain separate."})]}),t&&!E&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("span",{className:"text-meta text-ink-muted",children:[t.source==="builtin"?"Built-in":t.source==="installed"?"Installed":"Custom",t.divergent_fields?.length?" · Modified":""," ·"," ",t.kind]}),t.source==="builtin"?e.jsx(u,{variant:"outline",onClick:F,disabled:f,children:"Install"}):e.jsx(u,{variant:"outline",onClick:()=>m(!0),children:"Edit"}),e.jsx(u,{variant:"outline",onClick:()=>{k(!0),m(!0),b(""),i.current=null},children:"Extend"}),e.jsx(u,{onClick:()=>{z.getState().stageDraft({kind:"agent",name:t.name}),w("/chat")},children:"New chat"})]}),c&&e.jsx("p",{role:"alert",className:"text-body-sm text-danger",children:c}),!o&&t?.source==="builtin"&&e.jsx("p",{id:"builtin-readonly",className:"text-body-sm text-ink-muted",children:"Built-in agents are read-only. Install this one to edit it, or Extend it to start a separate agent from its instructions."}),e.jsxs("form",{onSubmit:K,className:"space-y-4",children:[e.jsxs("fieldset",{disabled:!o||f,className:"space-y-4",children:[e.jsxs("label",{className:"block space-y-1 text-body-sm",children:[e.jsx("span",{children:"Name"}),e.jsx("input",{className:d,value:p,disabled:!E,required:!0,"aria-describedby":t?.source==="builtin"?"builtin-readonly":void 0,onChange:s=>b(s.target.value)})]}),e.jsxs("label",{className:"block space-y-1 text-body-sm",children:[e.jsx("span",{children:"Kind"}),e.jsxs("select",{className:d,value:x,disabled:!E,onChange:s=>C(s.target.value),children:[e.jsx("option",{value:"role",children:"Role"}),e.jsx("option",{value:"specialist",children:"Specialist"})]})]}),e.jsxs("label",{className:"block space-y-1 text-body-sm",children:[e.jsx("span",{children:"When to use this agent"}),e.jsx("input",{className:d,value:h,maxLength:8e3,onChange:s=>y(s.target.value)})]}),e.jsxs("label",{className:"block space-y-1 text-body-sm",children:[e.jsx("span",{children:"Instructions"}),e.jsx("textarea",{className:P(d,"min-h-52"),value:j,required:!0,maxLength:8e3,onChange:s=>S(s.target.value)})]}),x==="role"&&e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"block space-y-1 text-body-sm",children:[e.jsx("span",{children:"Allowed tools"}),e.jsx("input",{className:d,value:_,onChange:s=>D(s.target.value),placeholder:"All tools when empty; otherwise comma-separated names"})]}),e.jsxs("label",{className:"block space-y-1 text-body-sm",children:[e.jsx("span",{children:"Effort tier"}),e.jsx("input",{className:d,value:I,onChange:s=>N(s.target.value),"aria-describedby":"effort-help"}),e.jsx("span",{id:"effort-help",className:"text-meta text-ink-muted",children:"Use inherit, or a tier configured in backend settings. Unsupported tiers are rejected before saving."})]}),e.jsxs("label",{className:"flex items-center gap-2 text-body-sm",children:[e.jsx("input",{type:"checkbox",checked:R,onChange:s=>L(s.target.checked)}),"May delegate to subagents"]})]})]}),o&&e.jsx(u,{type:"submit",disabled:f,children:f?"Saving…":E?"Create agent":"Save changes"})]}),!o&&t?.packaged_instructions&&t.divergent_fields?.length?e.jsxs("details",{className:"text-body-sm",children:[e.jsx("summary",{children:"Compare packaged instructions"}),e.jsx("pre",{className:"mt-2 whitespace-pre-wrap text-body-sm text-ink-muted",children:t.packaged_instructions})]}):null]})}function B({team:t,onSaved:v}){const[g,r]=n.useState(t?.name??""),[k,o]=n.useState(t?.description??""),[m,p]=n.useState(t?.manager??"manager"),[b,x]=n.useState((t?.members??[]).map(a=>({...a,key:crypto.randomUUID()}))),[C,h]=n.useState(t?.instructions??""),[y,j]=n.useState(t?.project??""),[S,_]=n.useState(!1),[D,I]=n.useState(null),N=n.useRef(null),R=$(),L=async a=>{if(a.preventDefault(),S)return;const c={name:g,description:k,manager:m,members:b.map(({key:i,...w})=>w),instructions:C,project:y},l=JSON.stringify(c);if(N.current&&N.current.body!==l){I("The previous save has not been confirmed. Reload the team before changing that request.");return}N.current??={id:crypto.randomUUID(),body:l},_(!0),I(null);try{const i=t?await U({op:"teams.update",name:t.name,requestId:N.current.id,fields:c}):await U({op:"teams.create",requestId:N.current.id,fields:c});N.current=null,v(i.name)}catch(i){I(i instanceof Error?i.message:"Team could not be saved.")}finally{_(!1)}},f=(a,c)=>x(l=>l.map((i,w)=>w===a?{...i,...c}:i));return e.jsxs("div",{className:"max-w-3xl space-y-6",children:[e.jsxs("header",{children:[e.jsx("h1",{className:"text-title",children:t?t.name:"Create team"}),e.jsx("p",{className:"mt-2 text-body-sm text-ink-muted",children:"The manager leads the chat. Members retain their own instructions and start only when delegated work."})]}),t&&e.jsx(u,{onClick:()=>{z.getState().stageDraft({kind:"team",name:t.name}),R("/chat")},children:"New team chat"}),D&&e.jsx("p",{role:"alert",className:"text-body-sm text-danger",children:D}),e.jsxs("form",{onSubmit:L,className:"space-y-4",children:[e.jsxs("fieldset",{disabled:S,className:"space-y-4",children:[e.jsxs("label",{className:"block space-y-1 text-body-sm",children:[e.jsx("span",{children:"Name"}),e.jsx("input",{className:d,required:!0,maxLength:64,value:g,onChange:a=>r(a.target.value)})]}),e.jsxs("label",{className:"block space-y-1 text-body-sm",children:[e.jsx("span",{children:"Description"}),e.jsx("input",{className:d,value:k,onChange:a=>o(a.target.value)})]}),e.jsxs("label",{className:"block space-y-1 text-body-sm",children:[e.jsx("span",{children:"Manager agent"}),e.jsx("input",{className:d,required:!0,value:m,onChange:a=>p(a.target.value)})]}),e.jsxs("section",{className:"space-y-2",children:[e.jsx("h2",{className:"text-heading",children:"Members"}),b.map((a,c)=>e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("input",{className:P(d,"w-48 flex-1"),"aria-label":`Member ${c+1} name`,required:!0,value:a.role,onChange:l=>f(c,{role:l.target.value})}),e.jsxs("select",{className:P(d,"w-32"),"aria-label":`Member ${c+1} kind`,value:a.kind,onChange:l=>f(c,{kind:l.target.value}),children:[e.jsx("option",{value:"agent",children:"Agent"}),e.jsx("option",{value:"team",children:"Nested team"})]}),e.jsx("input",{className:P(d,"w-20"),"aria-label":`Member ${c+1} count`,type:"number",min:1,max:16,value:a.count,onChange:l=>f(c,{count:Number(l.target.value)})}),e.jsx(u,{type:"button",variant:"ghost",onClick:()=>x(l=>l.filter((i,w)=>w!==c)),children:"Remove"})]},a.key)),e.jsx(u,{type:"button",variant:"outline",onClick:()=>x(a=>[...a,{role:"",count:1,kind:"agent",key:crypto.randomUUID()}]),children:"Add member"})]}),e.jsxs("label",{className:"block space-y-1 text-body-sm",children:[e.jsx("span",{children:"Collaboration instructions"}),e.jsx("textarea",{className:P(d,"min-h-36"),maxLength:8e3,value:C,onChange:a=>h(a.target.value)})]}),e.jsxs("label",{className:"block space-y-1 text-body-sm",children:[e.jsx("span",{children:"Project brief"}),e.jsx("textarea",{className:P(d,"min-h-36"),maxLength:8e3,value:y,onChange:a=>j(a.target.value)})]})]}),e.jsx(u,{type:"submit",disabled:S,children:S?"Saving…":t?"Save team":"Create team"})]})]})}function ce(){const{agentId:t}=O(),[v,g]=Q(),r=v.get("kind")==="team"||v.get("create")==="team",k=v.has("create"),o=v.get("name"),m=J(),p=V(m.data,r?"team_catalogue":"profile_catalogue"),b=W(p&&!r),x=G(p&&r),C=H(),h=X({queryKey:["desktop",r?"team":"profile",o],enabled:p&&!!o&&!k,queryFn:()=>U({op:r?"teams.get":"profiles.get",name:o??""}),retry:!1}),y=async j=>{await C.invalidateQueries({queryKey:["desktop"]}),g({kind:r?"team":"agent",name:j})};return t?e.jsx(n.Suspense,{fallback:e.jsx("p",{className:"p-6 text-body",children:"Loading saved agent…"}),children:e.jsx(se,{})}):e.jsxs("div",{className:"flex h-full min-h-0 bg-canvas text-ink",children:[e.jsxs("aside",{className:"flex w-64 shrink-0 flex-col gap-4 border-r border-hairline bg-surface p-4",children:[e.jsx("h1",{className:"text-heading",children:"Agents and teams"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(u,{variant:r?"ghost":"outline",onClick:()=>g({kind:"agent"}),children:[e.jsx(Y,{className:"size-4"}),"Agents"]}),e.jsxs(u,{variant:r?"outline":"ghost",onClick:()=>g({kind:"team"}),children:[e.jsx(Z,{className:"size-4"}),"Teams"]})]}),e.jsxs(u,{variant:"outline",disabled:!p,onClick:()=>g({create:r?"team":"agent"}),children:[e.jsx(ee,{className:"size-4"}),r?"Create team":"Create agent"]}),e.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto",children:(r?x.data:b.data)?.map(j=>e.jsx("button",{type:"button",className:P("flex h-8 w-full items-center rounded-md px-2 text-left text-body-sm hover:bg-row-hover",j.name===o&&te),onClick:()=>g({kind:r?"team":"agent",name:j.name}),children:e.jsx("span",{className:"truncate",children:j.name})},j.name))})]}),e.jsx("main",{className:"min-w-0 flex-1 overflow-auto p-6",children:p?b.error||x.error||h.error?e.jsxs("div",{role:"alert",children:[e.jsx("p",{className:"text-danger",children:b.error?.message||x.error?.message||h.error?.message}),e.jsx(u,{variant:"outline",onClick:()=>{b.refetch(),x.refetch(),h.refetch()},children:"Retry"})]}):k?r?e.jsx(B,{onSaved:y},"create-team"):e.jsx(T,{creating:!0,onSaved:y},"create-agent"):o&&h.isLoading?e.jsx("p",{"aria-live":"polite",children:"Loading details…"}):o&&h.data?r?e.jsx(B,{team:h.data,onSaved:y},o):e.jsx(T,{profile:h.data,creating:!1,onSaved:y},`${o}:${h.data.source}`):e.jsxs("div",{children:[e.jsx("h2",{className:"text-title",children:r?"Reusable teams":"Reusable agents"}),e.jsx("p",{className:"mt-2 text-body text-ink-muted",children:"Select a definition to view or edit it. A new chat does not change its definition."})]}):e.jsxs("div",{"aria-live":"polite",className:"space-y-3 text-body-sm",children:[e.jsx("p",{children:m.isLoading?"Connecting to the backend…":m.error?m.error.message:"Update the backend to manage reusable agents and teams. Saved chats are unchanged."}),e.jsx(u,{variant:"outline",onClick:()=>void m.refetch(),children:"Retry connection"})]})})]})}export{ce as AgentsPage};
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./legacy-agents-page-B-wHGQFq.js","./index-CZlj7Oq2.js","./index-OpIz2cV2.css","./page-header-dIIc14HB.js","./error-boundary-Du4Xf2hu.js","./index-YQ32HBTm.js","./console-mirror-naCglSJA.js","./console-mirror-DOrYoP_4.css","./index-CSPo12AE.css","./radient-auth-buttons-QWV7OGyX.js","./compact-pagination-B0hoPapl.js","./publication-validation-7J4xzRVZ.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{u as O,a as Q,b as J,d as V,c as W,e as G,f as H,g as X,B as Y,U as Z,P as ee,r as te,_ as ae,h as $,i as z,j as U}from"./index-YQ32HBTm.js";import{j as e,r as n,c as P}from"./index-CZlj7Oq2.js";import{B as u}from"./error-boundary-Du4Xf2hu.js";import"./console-mirror-naCglSJA.js";const se=n.lazy(()=>ae(()=>import("./legacy-agents-page-B-wHGQFq.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11]),import.meta.url).then(t=>({default:t.LegacyAgentsPage}))),d="w-full rounded-md border border-control bg-surface px-3 py-2 text-body-sm text-ink";function T({profile:t,creating:v,onSaved:g}){const[r,k]=n.useState(!1),[o,m]=n.useState(v),[p,b]=n.useState(t?.name??""),[x,C]=n.useState(t?.kind??"role"),[h,y]=n.useState(t?.description??""),[j,S]=n.useState(t?.instructions??""),[_,D]=n.useState(t?.tools?.join(", ")??""),[I,N]=n.useState(t?.effort??"inherit"),[R,L]=n.useState(t?.delegate??!1),[f,a]=n.useState(!1),[c,l]=n.useState(null),i=n.useRef(null),w=$(),E=v||r,K=async s=>{if(s.preventDefault(),f)return;const M={kind:x,description:h,instructions:j,tools:_.split(",").map(q=>q.trim()).filter(Boolean),effort:I,delegate:R},A=JSON.stringify({name:p,fields:M,fresh:E});if(i.current&&i.current.body!==A){l("The previous save has not been confirmed. Retry it unchanged or reload the profile to reconcile before editing again.");return}i.current??={id:crypto.randomUUID(),body:A},a(!0),l(null);try{const q=await U({op:E?"profiles.create":"profiles.update",requestId:i.current.id,name:p,fields:M});i.current=null,m(!1),g(q.name)}catch(q){l(q instanceof Error?q.message:"Profile could not be saved.")}finally{a(!1)}},F=async()=>{if(!(!t||f)){a(!0),l(null);try{const s=await U({op:"profiles.install",name:t.name,requestId:crypto.randomUUID()});m(!1),k(!1),i.current=null,b(s.name),C(s.kind),y(s.description??""),S(s.instructions??""),D(s.tools?.join(", ")??""),N(s.effort??"inherit"),L(s.delegate??!1),g(s.name)}catch(s){l(s instanceof Error?s.message:"Profile could not be installed.")}finally{a(!1)}}};return e.jsxs("div",{className:"max-w-3xl space-y-6",children:[e.jsxs("header",{children:[e.jsx("h1",{className:"text-title",children:E?r?"Extend agent":"Create agent":t?.name}),e.jsx("p",{className:"mt-2 text-body-sm text-ink-muted",children:"Reusable instructions shared by agent commands, subagents and teams. Chats remain separate."})]}),t&&!E&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("span",{className:"text-meta text-ink-muted",children:[t.source==="builtin"?"Built-in":t.source==="installed"?"Installed":"Custom",t.divergent_fields?.length?" · Modified":""," ·"," ",t.kind]}),t.source==="builtin"?e.jsx(u,{variant:"outline",onClick:F,disabled:f,children:"Install"}):e.jsx(u,{variant:"outline",onClick:()=>m(!0),children:"Edit"}),e.jsx(u,{variant:"outline",onClick:()=>{k(!0),m(!0),b(""),i.current=null},children:"Extend"}),e.jsx(u,{onClick:()=>{z.getState().stageDraft({kind:"agent",name:t.name}),w("/chat")},children:"New chat"})]}),c&&e.jsx("p",{role:"alert",className:"text-body-sm text-danger",children:c}),!o&&t?.source==="builtin"&&e.jsx("p",{id:"builtin-readonly",className:"text-body-sm text-ink-muted",children:"Built-in agents are read-only. Install this one to edit it, or Extend it to start a separate agent from its instructions."}),e.jsxs("form",{onSubmit:K,className:"space-y-4",children:[e.jsxs("fieldset",{disabled:!o||f,className:"space-y-4",children:[e.jsxs("label",{className:"block space-y-1 text-body-sm",children:[e.jsx("span",{children:"Name"}),e.jsx("input",{className:d,value:p,disabled:!E,required:!0,"aria-describedby":t?.source==="builtin"?"builtin-readonly":void 0,onChange:s=>b(s.target.value)})]}),e.jsxs("label",{className:"block space-y-1 text-body-sm",children:[e.jsx("span",{children:"Kind"}),e.jsxs("select",{className:d,value:x,disabled:!E,onChange:s=>C(s.target.value),children:[e.jsx("option",{value:"role",children:"Role"}),e.jsx("option",{value:"specialist",children:"Specialist"})]})]}),e.jsxs("label",{className:"block space-y-1 text-body-sm",children:[e.jsx("span",{children:"When to use this agent"}),e.jsx("input",{className:d,value:h,maxLength:8e3,onChange:s=>y(s.target.value)})]}),e.jsxs("label",{className:"block space-y-1 text-body-sm",children:[e.jsx("span",{children:"Instructions"}),e.jsx("textarea",{className:P(d,"min-h-52"),value:j,required:!0,maxLength:8e3,onChange:s=>S(s.target.value)})]}),x==="role"&&e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"block space-y-1 text-body-sm",children:[e.jsx("span",{children:"Allowed tools"}),e.jsx("input",{className:d,value:_,onChange:s=>D(s.target.value),placeholder:"All tools when empty; otherwise comma-separated names"})]}),e.jsxs("label",{className:"block space-y-1 text-body-sm",children:[e.jsx("span",{children:"Effort tier"}),e.jsx("input",{className:d,value:I,onChange:s=>N(s.target.value),"aria-describedby":"effort-help"}),e.jsx("span",{id:"effort-help",className:"text-meta text-ink-muted",children:"Use inherit, or a tier configured in backend settings. Unsupported tiers are rejected before saving."})]}),e.jsxs("label",{className:"flex items-center gap-2 text-body-sm",children:[e.jsx("input",{type:"checkbox",checked:R,onChange:s=>L(s.target.checked)}),"May delegate to subagents"]})]})]}),o&&e.jsx(u,{type:"submit",disabled:f,children:f?"Saving…":E?"Create agent":"Save changes"})]}),!o&&t?.packaged_instructions&&t.divergent_fields?.length?e.jsxs("details",{className:"text-body-sm",children:[e.jsx("summary",{children:"Compare packaged instructions"}),e.jsx("pre",{className:"mt-2 whitespace-pre-wrap text-body-sm text-ink-muted",children:t.packaged_instructions})]}):null]})}function B({team:t,onSaved:v}){const[g,r]=n.useState(t?.name??""),[k,o]=n.useState(t?.description??""),[m,p]=n.useState(t?.manager??"manager"),[b,x]=n.useState((t?.members??[]).map(a=>({...a,key:crypto.randomUUID()}))),[C,h]=n.useState(t?.instructions??""),[y,j]=n.useState(t?.project??""),[S,_]=n.useState(!1),[D,I]=n.useState(null),N=n.useRef(null),R=$(),L=async a=>{if(a.preventDefault(),S)return;const c={name:g,description:k,manager:m,members:b.map(({key:i,...w})=>w),instructions:C,project:y},l=JSON.stringify(c);if(N.current&&N.current.body!==l){I("The previous save has not been confirmed. Reload the team before changing that request.");return}N.current??={id:crypto.randomUUID(),body:l},_(!0),I(null);try{const i=t?await U({op:"teams.update",name:t.name,requestId:N.current.id,fields:c}):await U({op:"teams.create",requestId:N.current.id,fields:c});N.current=null,v(i.name)}catch(i){I(i instanceof Error?i.message:"Team could not be saved.")}finally{_(!1)}},f=(a,c)=>x(l=>l.map((i,w)=>w===a?{...i,...c}:i));return e.jsxs("div",{className:"max-w-3xl space-y-6",children:[e.jsxs("header",{children:[e.jsx("h1",{className:"text-title",children:t?t.name:"Create team"}),e.jsx("p",{className:"mt-2 text-body-sm text-ink-muted",children:"The manager leads the chat. Members retain their own instructions and start only when delegated work."})]}),t&&e.jsx(u,{onClick:()=>{z.getState().stageDraft({kind:"team",name:t.name}),R("/chat")},children:"New team chat"}),D&&e.jsx("p",{role:"alert",className:"text-body-sm text-danger",children:D}),e.jsxs("form",{onSubmit:L,className:"space-y-4",children:[e.jsxs("fieldset",{disabled:S,className:"space-y-4",children:[e.jsxs("label",{className:"block space-y-1 text-body-sm",children:[e.jsx("span",{children:"Name"}),e.jsx("input",{className:d,required:!0,maxLength:64,value:g,onChange:a=>r(a.target.value)})]}),e.jsxs("label",{className:"block space-y-1 text-body-sm",children:[e.jsx("span",{children:"Description"}),e.jsx("input",{className:d,value:k,onChange:a=>o(a.target.value)})]}),e.jsxs("label",{className:"block space-y-1 text-body-sm",children:[e.jsx("span",{children:"Manager agent"}),e.jsx("input",{className:d,required:!0,value:m,onChange:a=>p(a.target.value)})]}),e.jsxs("section",{className:"space-y-2",children:[e.jsx("h2",{className:"text-heading",children:"Members"}),b.map((a,c)=>e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("input",{className:P(d,"w-48 flex-1"),"aria-label":`Member ${c+1} name`,required:!0,value:a.role,onChange:l=>f(c,{role:l.target.value})}),e.jsxs("select",{className:P(d,"w-32"),"aria-label":`Member ${c+1} kind`,value:a.kind,onChange:l=>f(c,{kind:l.target.value}),children:[e.jsx("option",{value:"agent",children:"Agent"}),e.jsx("option",{value:"team",children:"Nested team"})]}),e.jsx("input",{className:P(d,"w-20"),"aria-label":`Member ${c+1} count`,type:"number",min:1,max:16,value:a.count,onChange:l=>f(c,{count:Number(l.target.value)})}),e.jsx(u,{type:"button",variant:"ghost",onClick:()=>x(l=>l.filter((i,w)=>w!==c)),children:"Remove"})]},a.key)),e.jsx(u,{type:"button",variant:"outline",onClick:()=>x(a=>[...a,{role:"",count:1,kind:"agent",key:crypto.randomUUID()}]),children:"Add member"})]}),e.jsxs("label",{className:"block space-y-1 text-body-sm",children:[e.jsx("span",{children:"Collaboration instructions"}),e.jsx("textarea",{className:P(d,"min-h-36"),maxLength:8e3,value:C,onChange:a=>h(a.target.value)})]}),e.jsxs("label",{className:"block space-y-1 text-body-sm",children:[e.jsx("span",{children:"Project brief"}),e.jsx("textarea",{className:P(d,"min-h-36"),maxLength:8e3,value:y,onChange:a=>j(a.target.value)})]})]}),e.jsx(u,{type:"submit",disabled:S,children:S?"Saving…":t?"Save team":"Create team"})]})]})}function ce(){const{agentId:t}=O(),[v,g]=Q(),r=v.get("kind")==="team"||v.get("create")==="team",k=v.has("create"),o=v.get("name"),m=J(),p=V(m.data,r?"team_catalogue":"profile_catalogue"),b=W(p&&!r),x=G(p&&r),C=H(),h=X({queryKey:["desktop",r?"team":"profile",o],enabled:p&&!!o&&!k,queryFn:()=>U({op:r?"teams.get":"profiles.get",name:o??""}),retry:!1}),y=async j=>{await C.invalidateQueries({queryKey:["desktop"]}),g({kind:r?"team":"agent",name:j})};return t?e.jsx(n.Suspense,{fallback:e.jsx("p",{className:"p-6 text-body",children:"Loading saved agent…"}),children:e.jsx(se,{})}):e.jsxs("div",{className:"flex h-full min-h-0 bg-canvas text-ink",children:[e.jsxs("aside",{className:"flex w-64 shrink-0 flex-col gap-4 border-r border-hairline bg-surface p-4",children:[e.jsx("h1",{className:"text-heading",children:"Agents and teams"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(u,{variant:r?"ghost":"outline",onClick:()=>g({kind:"agent"}),children:[e.jsx(Y,{className:"size-4"}),"Agents"]}),e.jsxs(u,{variant:r?"outline":"ghost",onClick:()=>g({kind:"team"}),children:[e.jsx(Z,{className:"size-4"}),"Teams"]})]}),e.jsxs(u,{variant:"outline",disabled:!p,onClick:()=>g({create:r?"team":"agent"}),children:[e.jsx(ee,{className:"size-4"}),r?"Create team":"Create agent"]}),e.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto",children:(r?x.data:b.data)?.map(j=>e.jsx("button",{type:"button",className:P("flex h-8 w-full items-center rounded-md px-2 text-left text-body-sm hover:bg-row-hover",j.name===o&&te),onClick:()=>g({kind:r?"team":"agent",name:j.name}),children:e.jsx("span",{className:"truncate",children:j.name})},j.name))})]}),e.jsx("main",{className:"min-w-0 flex-1 overflow-auto p-6",children:p?b.error||x.error||h.error?e.jsxs("div",{role:"alert",children:[e.jsx("p",{className:"text-danger",children:b.error?.message||x.error?.message||h.error?.message}),e.jsx(u,{variant:"outline",onClick:()=>{b.refetch(),x.refetch(),h.refetch()},children:"Retry"})]}):k?r?e.jsx(B,{onSaved:y},"create-team"):e.jsx(T,{creating:!0,onSaved:y},"create-agent"):o&&h.isLoading?e.jsx("p",{"aria-live":"polite",children:"Loading details…"}):o&&h.data?r?e.jsx(B,{team:h.data,onSaved:y},o):e.jsx(T,{profile:h.data,creating:!1,onSaved:y},`${o}:${h.data.source}`):e.jsxs("div",{children:[e.jsx("h2",{className:"text-title",children:r?"Reusable teams":"Reusable agents"}),e.jsx("p",{className:"mt-2 text-body text-ink-muted",children:"Select a definition to view or edit it. A new chat does not change its definition."})]}):e.jsxs("div",{"aria-live":"polite",className:"space-y-3 text-body-sm",children:[e.jsx("p",{children:m.isLoading?"Connecting to the backend…":m.error?m.error.message:"Update the backend to manage reusable agents and teams. Saved chats are unchanged."}),e.jsx(u,{variant:"outline",onClick:()=>void m.refetch(),children:"Retry connection"})]})})]})}export{ce as AgentsPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{w as ln,p as un,l as H,s as q,m as B,n as an,o as y,t as tn,q as L,v as _,x as rn,y as o,z as sn,A as on,D as fn}from"./index-
|
|
1
|
+
import{w as ln,p as un,l as H,s as q,m as B,n as an,o as y,t as tn,q as L,v as _,x as rn,y as o,z as sn,A as on,D as fn}from"./index-YQ32HBTm.js";function cn(l){return l.innerRadius}function yn(l){return l.outerRadius}function gn(l){return l.startAngle}function mn(l){return l.endAngle}function pn(l){return l&&l.padAngle}function dn(l,h,E,D,v,A,C,u){var I=E-l,s=D-h,n=C-v,m=u-A,a=m*I-n*s;if(!(a*a<y))return a=(n*(h-A)-m*(l-v))/a,[l+a*I,h+a*s]}function W(l,h,E,D,v,A,C){var u=l-E,I=h-D,s=(C?A:-A)/L(u*u+I*I),n=s*I,m=-s*u,a=l+n,i=h+m,f=E+n,c=D+m,F=(a+f)/2,t=(i+c)/2,p=f-a,g=c-i,R=p*p+g*g,T=v-A,P=a*c-f*i,O=(g<0?-1:1)*L(on(0,T*T*R-P*P)),S=(P*g-p*O)/R,j=(-P*p-g*O)/R,w=(P*g+p*O)/R,d=(-P*p+g*O)/R,x=S-F,e=j-t,r=w-F,G=d-t;return x*x+e*e>r*r+G*G&&(S=w,j=d),{cx:S,cy:j,x01:-n,y01:-m,x11:S*(v/T-1),y11:j*(v/T-1)}}function hn(){var l=cn,h=yn,E=B(0),D=null,v=gn,A=mn,C=pn,u=null,I=ln(s);function s(){var n,m,a=+l.apply(this,arguments),i=+h.apply(this,arguments),f=v.apply(this,arguments)-an,c=A.apply(this,arguments)-an,F=rn(c-f),t=c>f;if(u||(u=n=I()),i<a&&(m=i,i=a,a=m),!(i>y))u.moveTo(0,0);else if(F>tn-y)u.moveTo(i*H(f),i*q(f)),u.arc(0,0,i,f,c,!t),a>y&&(u.moveTo(a*H(c),a*q(c)),u.arc(0,0,a,c,f,t));else{var p=f,g=c,R=f,T=c,P=F,O=F,S=C.apply(this,arguments)/2,j=S>y&&(D?+D.apply(this,arguments):L(a*a+i*i)),w=_(rn(i-a)/2,+E.apply(this,arguments)),d=w,x=w,e,r;if(j>y){var G=sn(j/a*q(S)),M=sn(j/i*q(S));(P-=G*2)>y?(G*=t?1:-1,R+=G,T-=G):(P=0,R=T=(f+c)/2),(O-=M*2)>y?(M*=t?1:-1,p+=M,g-=M):(O=0,p=g=(f+c)/2)}var J=i*H(p),K=i*q(p),N=a*H(T),Q=a*q(T);if(w>y){var U=i*H(g),V=i*q(g),X=a*H(R),Y=a*q(R),z;if(F<un)if(z=dn(J,K,X,Y,U,V,N,Q)){var Z=J-z[0],$=K-z[1],k=U-z[0],b=V-z[1],nn=1/q(fn((Z*k+$*b)/(L(Z*Z+$*$)*L(k*k+b*b)))/2),en=L(z[0]*z[0]+z[1]*z[1]);d=_(w,(a-en)/(nn-1)),x=_(w,(i-en)/(nn+1))}else d=x=0}O>y?x>y?(e=W(X,Y,J,K,i,x,t),r=W(U,V,N,Q,i,x,t),u.moveTo(e.cx+e.x01,e.cy+e.y01),x<w?u.arc(e.cx,e.cy,x,o(e.y01,e.x01),o(r.y01,r.x01),!t):(u.arc(e.cx,e.cy,x,o(e.y01,e.x01),o(e.y11,e.x11),!t),u.arc(0,0,i,o(e.cy+e.y11,e.cx+e.x11),o(r.cy+r.y11,r.cx+r.x11),!t),u.arc(r.cx,r.cy,x,o(r.y11,r.x11),o(r.y01,r.x01),!t))):(u.moveTo(J,K),u.arc(0,0,i,p,g,!t)):u.moveTo(J,K),!(a>y)||!(P>y)?u.lineTo(N,Q):d>y?(e=W(N,Q,U,V,a,-d,t),r=W(J,K,X,Y,a,-d,t),u.lineTo(e.cx+e.x01,e.cy+e.y01),d<w?u.arc(e.cx,e.cy,d,o(e.y01,e.x01),o(r.y01,r.x01),!t):(u.arc(e.cx,e.cy,d,o(e.y01,e.x01),o(e.y11,e.x11),!t),u.arc(0,0,a,o(e.cy+e.y11,e.cx+e.x11),o(r.cy+r.y11,r.cx+r.x11),t),u.arc(r.cx,r.cy,d,o(r.y11,r.x11),o(r.y01,r.x01),!t))):u.arc(0,0,a,T,R,t)}if(u.closePath(),n)return u=null,n+""||null}return s.centroid=function(){var n=(+l.apply(this,arguments)+ +h.apply(this,arguments))/2,m=(+v.apply(this,arguments)+ +A.apply(this,arguments))/2-un/2;return[H(m)*n,q(m)*n]},s.innerRadius=function(n){return arguments.length?(l=typeof n=="function"?n:B(+n),s):l},s.outerRadius=function(n){return arguments.length?(h=typeof n=="function"?n:B(+n),s):h},s.cornerRadius=function(n){return arguments.length?(E=typeof n=="function"?n:B(+n),s):E},s.padRadius=function(n){return arguments.length?(D=n==null?null:typeof n=="function"?n:B(+n),s):D},s.startAngle=function(n){return arguments.length?(v=typeof n=="function"?n:B(+n),s):v},s.endAngle=function(n){return arguments.length?(A=typeof n=="function"?n:B(+n),s):A},s.padAngle=function(n){return arguments.length?(C=typeof n=="function"?n:B(+n),s):C},s.context=function(n){return arguments.length?(u=n??null,s):u},s}export{hn as d};
|