@jmanuelcorral/bond-app 0.1.4 → 0.1.6
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/README.md +241 -7
- package/app/brand/TOKENS.md +5 -5
- package/app/layouts/bond.json +10 -14
- package/app/mods/bond-agents/api.js +35 -0
- package/app/mods/bond-agents/branch.svg +1 -0
- package/app/mods/bond-agents/brand.js +53 -2
- package/app/mods/bond-agents/config.js +8 -0
- package/app/mods/bond-agents/eye-off.svg +1 -0
- package/app/mods/bond-agents/eye.svg +1 -0
- package/app/mods/bond-agents/main.js +316 -330
- package/app/mods/bond-agents/model.js +400 -6
- package/app/mods/bond-board/api.js +35 -0
- package/app/mods/bond-board/branch.svg +1 -0
- package/app/mods/bond-board/brand.js +53 -2
- package/app/mods/bond-board/config.js +8 -0
- package/app/mods/bond-board/main.js +1054 -366
- package/app/mods/bond-board/model.js +138 -17
- package/app/mods/bond-pane/close.svg +1 -0
- package/app/mods/bond-pane/hide.svg +1 -0
- package/app/mods/bond-pane/main.js +103 -0
- package/app/mods/bond-pane/mod.json +1 -0
- package/app/mods/bond-pane/model.js +18 -0
- package/app/mods/bond-pane/split-down.svg +1 -0
- package/app/mods/bond-pane/split-right.svg +1 -0
- package/app/mods/bond-pane/unzoom.svg +1 -0
- package/app/mods/bond-pane/zoom.svg +1 -0
- package/app/mods/bond-settings/api.js +35 -0
- package/app/mods/bond-settings/brand.js +53 -2
- package/app/mods/bond-settings/config.js +8 -0
- package/app/mods/bond-settings/main.js +1645 -87
- package/app/mods/bond-settings/mod.json +1 -1
- package/app/mods/bond-settings/pi-models.js +144 -0
- package/app/mods/bond-status/api.js +35 -0
- package/app/mods/bond-status/brand.js +53 -2
- package/app/mods/bond-status/config.js +8 -0
- package/app/mods/bond-status/main.js +37 -15
- package/app/mods/bond-status/model.js +19 -1
- package/app/mods/bond-tabs/brand.js +53 -2
- package/app/mods/bond-tabs/main.js +45 -3
- package/app/mods/bond-titlebar/brand.js +53 -2
- package/app/mods/bond-titlebar/main.js +115 -55
- package/app/mods/bond-titlebar/version.js +3 -0
- package/app/themes/bond-dark.json +5 -5
- package/app/themes/bond-light.json +5 -5
- package/package.json +1 -1
- package/runner/Dockerfile +58 -15
- package/runner/SPIKE-BOND.md +89 -0
- package/runner/build-config/.none +0 -0
- package/runner/build-creds/.none +0 -0
- package/runner/config.example/README.md +27 -0
- package/runner/config.example/pi/models.json +22 -0
- package/runner/credentials.example.env +27 -0
- package/runner/entrypoint.sh +16 -0
- package/runner/setup.sh +927 -0
- package/runner/versions.env +61 -0
- package/scripts/app-install.ts +64 -1
- package/src/cli.ts +53 -3
- package/src/config.ts +8 -0
- package/src/core/agy-login.ts +682 -0
- package/src/core/delivery.ts +3 -1
- package/src/core/hub-session.ts +9 -7
- package/src/core/orchestrator.ts +1186 -168
- package/src/core/repo-host.ts +60 -0
- package/src/core/setup.ts +239 -0
- package/src/core/watchdog.ts +6 -6
- package/src/db/database.ts +55 -1
- package/src/db/settings-repo.ts +440 -7
- package/src/db/ticket-repo.ts +73 -17
- package/src/index.ts +4 -4
- package/src/runner/azure-devops-client.ts +163 -0
- package/src/runner/docker-client.ts +84 -5
- package/src/runner/github-client.ts +146 -0
- package/src/runner/hc-client.ts +40 -5
- package/src/runner/image-builder.ts +268 -10
- package/src/runner/jira-client.ts +368 -0
- package/src/runner/tool-catalog.ts +84 -0
- package/src/server/app.ts +585 -9
- package/src/types.ts +168 -1
package/runner/setup.sh
ADDED
|
@@ -0,0 +1,927 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# runner/setup.sh — instalador de agentes del runner de bond-app (P1).
|
|
3
|
+
#
|
|
4
|
+
# Instala en un Debian bookworm-slim (base de la imagen del runner) los CLIs de los
|
|
5
|
+
# agentes elegidos, más `gh` (repo apt oficial de GitHub) y `azure-cli` + la extensión
|
|
6
|
+
# `azure-devops` (repo apt oficial de Microsoft), y monta en el home del usuario
|
|
7
|
+
# `runner` la config por agente que se le pase con --config y, opcionalmente,
|
|
8
|
+
# credenciales con --credentials.
|
|
9
|
+
#
|
|
10
|
+
# SEGURIDAD
|
|
11
|
+
# - Los valores de las credenciales NUNCA se loguean ni viajan por args de comando.
|
|
12
|
+
# - Una imagen construida con --credentials es un secreto local (D-A): nunca
|
|
13
|
+
# subirla a un registry.
|
|
14
|
+
# - La config horneada no lleva secretos; si hay config horneada y config inyectada
|
|
15
|
+
# por run (D7/D8), la inyectada por stdin sigue teniendo prioridad en el run.
|
|
16
|
+
#
|
|
17
|
+
# MECANISMOS VERIFICADOS (D-C, 2026-11-19):
|
|
18
|
+
# - copilot: npm oficial @github/copilot (Node 22+); autentica por variables de
|
|
19
|
+
# entorno (COPILOT_GITHUB_TOKEN/GH_TOKEN/GITHUB_TOKEN) o por el fallback de `gh`
|
|
20
|
+
# autenticado; sin formato documentado de fichero de token
|
|
21
|
+
# (docs.github.com «Authenticating GitHub Copilot CLI»). Con GH_TOKEN,
|
|
22
|
+
# «gh auth login --with-token» cubre a copilot.
|
|
23
|
+
# - agy (Antigravity CLI): instalador oficial de Google (binario único, sha512
|
|
24
|
+
# verificado, sin pin de versión: siempre la última del manifiesto oficial; la
|
|
25
|
+
# versión real queda en el manifiesto). Config:
|
|
26
|
+
# ~/.gemini/antigravity-cli/settings.json. Credenciales solo por keyring/OAuth o
|
|
27
|
+
# GEMINI_API_KEY en el entorno; sin fichero de credenciales offline
|
|
28
|
+
# (antigravity.google/docs «Authenticate») → sigue con la inyección por stdin.
|
|
29
|
+
# - codex: auth.json con OPENAI_API_KEY en ~/.codex; config en ~/.codex/config.toml.
|
|
30
|
+
# - claude: settings.json en ~/.claude; token de larga duración de «claude setup-token»
|
|
31
|
+
# (un año, solo inferencia) en ~/.claude/oauth-token (0600). La CLI no lo lee de un
|
|
32
|
+
# fichero: un envoltorio sustituye a `claude` en el PATH y la arranca con
|
|
33
|
+
# CLAUDE_CODE_OAUTH_TOKEN solo en su proceso (decisión 2026-11-23, matiza D7). La
|
|
34
|
+
# sesión de «claude auth login» (~/.claude/.credentials.json) no sirve en los runs:
|
|
35
|
+
# su refreshToken rota y es de un solo uso (spike del plan bond-app-claude-agente).
|
|
36
|
+
# - azure-cli: repo apt de packages.microsoft.com soporta bookworm
|
|
37
|
+
# (learn.microsoft.com «Install the Azure CLI on Linux»).
|
|
38
|
+
#
|
|
39
|
+
# Excepciones a la regla «sin credenciales en la imagen» (D8): la horneada con
|
|
40
|
+
# --credentials es la excepción acotada por D-A/D-E; el flujo por defecto (opción A)
|
|
41
|
+
# no la usa.
|
|
42
|
+
#
|
|
43
|
+
# Uso:
|
|
44
|
+
# setup.sh --agents pi,copilot [--config DIR] [--credentials FICHERO]
|
|
45
|
+
# Variables de entorno (para pruebas; en producción se usan los valores por defecto):
|
|
46
|
+
# RUNNER_HOME (=/home/runner) RUNNER_USER (=runner) MANIFEST_PATH (=/opt/runner-agents)
|
|
47
|
+
# VERSIONS_FILE (=junto a este script) SETUP_DRY_RUN (=0; 1: no instala CLIs ni
|
|
48
|
+
# agentes; valida y copia config/credenciales locales igualmente; «gh auth login»
|
|
49
|
+
# solo se ejecuta si gh ya está en el PATH)
|
|
50
|
+
|
|
51
|
+
set -Eeuo pipefail
|
|
52
|
+
|
|
53
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
54
|
+
|
|
55
|
+
SUPPORTED_AGENTS=(pi claude codex copilot agy)
|
|
56
|
+
SUPPORTED_JOINED="${SUPPORTED_AGENTS[0]}"
|
|
57
|
+
for _s in "${SUPPORTED_AGENTS[@]:1}"; do SUPPORTED_JOINED="$SUPPORTED_JOINED, $_s"; done
|
|
58
|
+
RUNNER_HOME="${RUNNER_HOME:-/home/runner}"
|
|
59
|
+
RUNNER_USER="${RUNNER_USER:-runner}"
|
|
60
|
+
MANIFEST_PATH="${MANIFEST_PATH:-/opt/runner-agents}"
|
|
61
|
+
VERSIONS_FILE="${VERSIONS_FILE:-${SCRIPT_DIR}/versions.env}"
|
|
62
|
+
DRY_RUN="${SETUP_DRY_RUN:-0}"
|
|
63
|
+
|
|
64
|
+
log() { printf 'setup.sh: %s\n' "$*"; }
|
|
65
|
+
die() { printf 'setup.sh: ERROR: %s\n' "$*" >&2; exit 1; }
|
|
66
|
+
mask() { printf 'setup.sh: %s (valor no registrado)\n' "$*"; }
|
|
67
|
+
|
|
68
|
+
usage() {
|
|
69
|
+
cat <<'EOF'
|
|
70
|
+
Uso: setup.sh --agents pi,copilot [--config DIR] [--credentials FICHERO] [--skip-gh] [--skip-az] [--with-bond]
|
|
71
|
+
[--tools esenciales,busqueda,shell] [--apt-extra paquete1,paquete2]
|
|
72
|
+
--agents LISTA agentes a instalar, separados por comas (pi, claude, codex, copilot, agy)
|
|
73
|
+
--config DIR config por agente (subcarpeta por agente, un fichero cada una; sin secretos)
|
|
74
|
+
--credentials FICHERO fichero 0600 con GH_TOKEN/CLAUDE_TOKEN/CODEX_TOKEN (opcional; ver credentials.example.env)
|
|
75
|
+
--skip-gh no instalar gh (por defecto, sí se instala)
|
|
76
|
+
--skip-az no instalar azure-cli + extensión azure-devops (por defecto, sí se instala)
|
|
77
|
+
--with-bond instala bond (pin BOND_VERSION de versions.env) y deja su config de
|
|
78
|
+
máquina hecha para el usuario runner (D-H/D-I; ver runner/SPIKE-BOND.md)
|
|
79
|
+
--tools LISTA grupos de herramientas de developer, separados por comas:
|
|
80
|
+
esenciales, busqueda, shell, python, go, rust, java, dotnet, js, db, cloud, docker
|
|
81
|
+
(cloud incluye azure-cli: anula --skip-az)
|
|
82
|
+
--apt-extra LISTA paquetes apt de Debian adicionales, separados por comas
|
|
83
|
+
EOF
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
# --- Ficheros de config soportados por agente: «fichero|ruta-relativa-al-home|formato»
|
|
87
|
+
config_spec() {
|
|
88
|
+
case "$1" in
|
|
89
|
+
pi) echo "models.json|.pi/agent/models.json|json" ;;
|
|
90
|
+
claude) echo "settings.json|.claude/settings.json|json" ;;
|
|
91
|
+
codex) echo "config.toml|.codex/config.toml|toml" ;;
|
|
92
|
+
copilot) echo "config.json|.copilot/config.json|json" ;;
|
|
93
|
+
agy) echo "settings.json|.gemini/antigravity-cli/settings.json|json" ;;
|
|
94
|
+
*) return 1 ;;
|
|
95
|
+
esac
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
# --- Parseo de argumentos -------------------------------------------------------
|
|
99
|
+
AGENTS_RAW=""
|
|
100
|
+
CONFIG_DIR=""
|
|
101
|
+
CRED_FILE=""
|
|
102
|
+
SKIP_GH=0
|
|
103
|
+
SKIP_AZ=0
|
|
104
|
+
WITH_BOND=0
|
|
105
|
+
TOOLS_RAW=""
|
|
106
|
+
APT_EXTRA_RAW=""
|
|
107
|
+
while [ "$#" -gt 0 ]; do
|
|
108
|
+
case "$1" in
|
|
109
|
+
--agents) [ $# -ge 2 ] || die "--agents necesita un valor (p. ej. --agents pi,copilot)"
|
|
110
|
+
AGENTS_RAW="$2"; shift 2 ;;
|
|
111
|
+
--config) [ $# -ge 2 ] || die "--config necesita un directorio"
|
|
112
|
+
CONFIG_DIR="$2"; shift 2 ;;
|
|
113
|
+
--credentials) [ $# -ge 2 ] || die "--credentials necesita un fichero"
|
|
114
|
+
CRED_FILE="$2"; shift 2 ;;
|
|
115
|
+
--skip-gh) SKIP_GH=1; shift ;;
|
|
116
|
+
--skip-az) SKIP_AZ=1; shift ;;
|
|
117
|
+
--with-bond) WITH_BOND=1; shift ;;
|
|
118
|
+
--tools) [ $# -ge 2 ] || die "--tools necesita un valor (p. ej. --tools esenciales,shell)"
|
|
119
|
+
TOOLS_RAW="$2"; shift 2 ;;
|
|
120
|
+
--apt-extra) [ $# -ge 2 ] || die "--apt-extra necesita un valor (p. ej. --apt-extra graphviz)"
|
|
121
|
+
APT_EXTRA_RAW="$2"; shift 2 ;;
|
|
122
|
+
-h|--help) usage; exit 0 ;;
|
|
123
|
+
*) die "opción desconocida: $1 (usa --help)" ;;
|
|
124
|
+
esac
|
|
125
|
+
done
|
|
126
|
+
|
|
127
|
+
[ -n "$AGENTS_RAW" ] || { usage >&2; die "falta --agents (lista separada por comas)"; }
|
|
128
|
+
|
|
129
|
+
# Lista pedida → AGENTS_ordered (sin duplicados, sin espacios)
|
|
130
|
+
IFS=',' read -r -a REQUESTED <<< "$AGENTS_RAW"
|
|
131
|
+
AGENTS_ordered=()
|
|
132
|
+
for a in "${REQUESTED[@]}"; do
|
|
133
|
+
[ -n "$a" ] || die "lista de agentes vacía o con entradas vacías: '$AGENTS_RAW'"
|
|
134
|
+
known=0
|
|
135
|
+
for s in "${SUPPORTED_AGENTS[@]}"; do [ "$a" = "$s" ] && known=1 && break; done
|
|
136
|
+
[ "$known" -eq 1 ] || die "agente no soportado: '$a' (soportados: $SUPPORTED_JOINED)"
|
|
137
|
+
for p in "${AGENTS_ordered[@]}"; do [ "$p" = "$a" ] && die "agente duplicado en --agents: '$a'"; done
|
|
138
|
+
AGENTS_ordered+=("$a")
|
|
139
|
+
done
|
|
140
|
+
[ "${#AGENTS_ordered[@]}" -gt 0 ] || die "lista de agentes vacía"
|
|
141
|
+
|
|
142
|
+
# Grupos de herramientas (plan bond-app-ajustes-imagen P2). El catálogo de la API
|
|
143
|
+
# (src/runner/tool-catalog.ts) tiene la misma lista; un test las mantiene iguales.
|
|
144
|
+
SUPPORTED_TOOLS=(esenciales busqueda shell python go rust java dotnet js db cloud docker)
|
|
145
|
+
TOOLS_ordered=()
|
|
146
|
+
if [ -n "$TOOLS_RAW" ]; then
|
|
147
|
+
IFS=',' read -r -a REQ_TOOLS <<< "$TOOLS_RAW"
|
|
148
|
+
for t in "${REQ_TOOLS[@]}"; do
|
|
149
|
+
[ -n "$t" ] || die "lista de herramientas con entradas vacías: '$TOOLS_RAW'"
|
|
150
|
+
known=0
|
|
151
|
+
for s in "${SUPPORTED_TOOLS[@]}"; do [ "$t" = "$s" ] && known=1 && break; done
|
|
152
|
+
[ "$known" -eq 1 ] || die "grupo de herramientas no soportado: '$t' (soportados: ${SUPPORTED_TOOLS[*]})"
|
|
153
|
+
for p in "${TOOLS_ordered[@]}"; do [ "$p" = "$t" ] && die "grupo duplicado en --tools: '$t'"; done
|
|
154
|
+
TOOLS_ordered+=("$t")
|
|
155
|
+
done
|
|
156
|
+
fi
|
|
157
|
+
APT_EXTRA=()
|
|
158
|
+
if [ -n "$APT_EXTRA_RAW" ]; then
|
|
159
|
+
IFS=',' read -r -a REQ_APT <<< "$APT_EXTRA_RAW"
|
|
160
|
+
for pkg in "${REQ_APT[@]}"; do
|
|
161
|
+
# Nombres de paquete Debian: minúsculas, dígitos y + - . (nada de opciones ni rutas).
|
|
162
|
+
[[ "$pkg" =~ ^[a-z0-9][a-z0-9+.-]{1,62}$ ]] || die "paquete apt no válido en --apt-extra: '$pkg'"
|
|
163
|
+
APT_EXTRA+=("$pkg")
|
|
164
|
+
done
|
|
165
|
+
fi
|
|
166
|
+
|
|
167
|
+
tool_requested() {
|
|
168
|
+
local want="$1" t
|
|
169
|
+
for t in "${TOOLS_ordered[@]}"; do [ "$t" = "$want" ] && return 0; done
|
|
170
|
+
return 1
|
|
171
|
+
}
|
|
172
|
+
# cloud trae azure-cli: con él, --skip-az no aplica.
|
|
173
|
+
tool_requested cloud && SKIP_AZ=0
|
|
174
|
+
|
|
175
|
+
agent_requested() {
|
|
176
|
+
local want="$1" a
|
|
177
|
+
for a in "${AGENTS_ordered[@]}"; do [ "$a" = "$want" ] && return 0; done
|
|
178
|
+
return 1
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
# --- Versiones fijadas ----------------------------------------------------------
|
|
182
|
+
[ -f "$VERSIONS_FILE" ] || die "no encuentro $VERSIONS_FILE"
|
|
183
|
+
# shellcheck source=/dev/null
|
|
184
|
+
. "$VERSIONS_FILE"
|
|
185
|
+
pin_for() {
|
|
186
|
+
case "$1" in
|
|
187
|
+
pi) echo "$PI_VERSION" ;;
|
|
188
|
+
claude) echo "$CLAUDE_VERSION" ;;
|
|
189
|
+
codex) echo "$CODEX_VERSION" ;;
|
|
190
|
+
copilot) echo "$COPILOT_VERSION" ;;
|
|
191
|
+
agy) echo "$AGY_VERSION" ;;
|
|
192
|
+
esac
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
# --- Utilidades ------------------------------------------------------------------
|
|
196
|
+
am_root() { [ "$(id -u)" -eq 0 ]; }
|
|
197
|
+
runner_account_exists() { [ -n "$RUNNER_USER" ] && id -u "$RUNNER_USER" >/dev/null 2>&1; }
|
|
198
|
+
|
|
199
|
+
# Ejecuta una orden como el usuario runner con su HOME (si aplica; si no, tal cual).
|
|
200
|
+
as_runner() {
|
|
201
|
+
if am_root && runner_account_exists && [ "$(id -un)" != "$RUNNER_USER" ]; then
|
|
202
|
+
runuser -u "$RUNNER_USER" -- env HOME="$RUNNER_HOME" "$@"
|
|
203
|
+
else
|
|
204
|
+
"$@"
|
|
205
|
+
fi
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
chown_if_runner() {
|
|
209
|
+
if am_root && runner_account_exists; then
|
|
210
|
+
chown "$RUNNER_USER:$RUNNER_USER" "$@"
|
|
211
|
+
fi
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
ensure_python3() {
|
|
215
|
+
if ! command -v python3 >/dev/null 2>&1; then
|
|
216
|
+
if [ "$DRY_RUN" = "1" ]; then
|
|
217
|
+
die "python3 es necesario para validar config y no está disponible (modo dry-run)"
|
|
218
|
+
fi
|
|
219
|
+
am_root || die "python3 es necesario para validar la config; ejecuta setup.sh como root"
|
|
220
|
+
log "instalando python3 (necesario para validar la config)"
|
|
221
|
+
apt-get update -qq && apt-get install -y -qq --no-install-recommends python3 >/dev/null
|
|
222
|
+
fi
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
validate_json() {
|
|
226
|
+
local f="$1"
|
|
227
|
+
if ! command -v node >/dev/null 2>&1 && ! command -v python3 >/dev/null 2>&1; then
|
|
228
|
+
ensure_python3
|
|
229
|
+
fi
|
|
230
|
+
if command -v node >/dev/null 2>&1; then
|
|
231
|
+
node -e 'JSON.parse(require("fs").readFileSync(process.argv[1],"utf8"))' "$f" \
|
|
232
|
+
|| die "JSON inválido: $f"
|
|
233
|
+
else
|
|
234
|
+
python3 -c 'import json,sys; json.load(open(sys.argv[1]))' "$f" \
|
|
235
|
+
|| die "JSON inválido: $f"
|
|
236
|
+
fi
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
validate_toml() {
|
|
240
|
+
local f="$1"
|
|
241
|
+
ensure_python3
|
|
242
|
+
python3 -c 'import sys,tomllib; tomllib.load(open(sys.argv[1],"rb"))' "$f" \
|
|
243
|
+
|| die "TOML inválido: $f"
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
# --- Validación de --config (antes de instalar nada: sin efectos secundarios) -----
|
|
247
|
+
[ -z "$CONFIG_DIR" ] || { [ -d "$CONFIG_DIR" ] || die "--config no es un directorio: $CONFIG_DIR"; }
|
|
248
|
+
|
|
249
|
+
declare -A CONFIG_SRC=() CONFIG_DEST=() CONFIG_HASH=()
|
|
250
|
+
if [ -n "$CONFIG_DIR" ]; then
|
|
251
|
+
for f in "$CONFIG_DIR"/*; do
|
|
252
|
+
[ -e "$f" ] || die "--config está vacía: $CONFIG_DIR"
|
|
253
|
+
# único fichero suelto admitido: la documentación de la plantilla (sin config)
|
|
254
|
+
[ "$(basename "$f")" = "README.md" ] && [ -f "$f" ] && continue
|
|
255
|
+
[ -d "$f" ] || die "--config admite solo subcarpetas por agente; fichero suelto: $f"
|
|
256
|
+
agent="$(basename "$f")"
|
|
257
|
+
spec="$(config_spec "$agent" 2>/dev/null)" || die "--config: agente desconocido: '$agent' (soportados: $SUPPORTED_JOINED)"
|
|
258
|
+
agent_requested "$agent" || die "--config: '$agent' no está en la lista de --agents (sin entrada)"
|
|
259
|
+
src_rel="${spec%%|*}"; rest="${spec#*|}"; dest_rel="${rest%%|*}"; kind="${rest##*|}"
|
|
260
|
+
src="$f/$src_rel"
|
|
261
|
+
[ -f "$src" ] || die "--config/$agent: falta el fichero '$src_rel' (esperado: $src)"
|
|
262
|
+
extra="$(find "$f" -mindepth 1 ! -name "$src_rel" -print -quit)"
|
|
263
|
+
[ -z "$extra" ] || die "--config/$agent: solo se admite '$src_rel' (sorprendente: $extra)"
|
|
264
|
+
case "$kind" in
|
|
265
|
+
json) validate_json "$src" ;;
|
|
266
|
+
toml) validate_toml "$src" ;;
|
|
267
|
+
esac
|
|
268
|
+
CONFIG_SRC[$agent]="$src"
|
|
269
|
+
CONFIG_DEST[$agent]="$RUNNER_HOME/$dest_rel"
|
|
270
|
+
done
|
|
271
|
+
fi
|
|
272
|
+
|
|
273
|
+
# --- Validación de --credentials --------------------------------------------------
|
|
274
|
+
[ -z "$CRED_FILE" ] || {
|
|
275
|
+
[ -f "$CRED_FILE" ] || die "--credentials no es un fichero: $CRED_FILE"
|
|
276
|
+
mode="$(stat -c '%a' "$CRED_FILE")"
|
|
277
|
+
[ "$mode" = "600" ] || die "credenciales deben tener permisos 0600 (tiene $mode): chmod 600 $CRED_FILE"
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
# --- Instalación de CLIs de sistema (gh + azure-cli) ------------------------------
|
|
281
|
+
install_system_deps() {
|
|
282
|
+
if [ "$DRY_RUN" = "1" ]; then return 0; fi
|
|
283
|
+
am_root || die "instalar dependencias requiere root"
|
|
284
|
+
apt-get update -qq
|
|
285
|
+
apt-get install -y -qq --no-install-recommends curl ca-certificates gnupg dpkg >/dev/null
|
|
286
|
+
rm -rf /var/lib/apt/lists/*
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
install_gh() {
|
|
290
|
+
if [ "$SKIP_GH" = "1" ]; then GH_STATE="skipped"; log "gh omitido por --skip-gh"; return 0; fi
|
|
291
|
+
GH_STATE="yes"
|
|
292
|
+
if [ "$DRY_RUN" = "1" ]; then log "dry-run: instalaría gh (repo apt oficial de GitHub)"; return 0; fi
|
|
293
|
+
am_root || die "instalar gh requiere root"
|
|
294
|
+
local keyring=/usr/share/keyrings/githubcli-archive-keyring.gpg
|
|
295
|
+
[ -f "$keyring" ] || curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg -o "$keyring"
|
|
296
|
+
echo "deb [arch=$(dpkg --print-architecture) signed-by=$keyring] https://cli.github.com/packages stable main" \
|
|
297
|
+
> /etc/apt/sources.list.d/github-cli.list
|
|
298
|
+
apt-get update -qq && apt-get install -y -qq gh >/dev/null
|
|
299
|
+
log "gh instalado: $(gh --version | head -n1)"
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
install_az() {
|
|
303
|
+
if [ "$SKIP_AZ" = "1" ]; then AZ_STATE="skipped"; log "azure-cli omitido por --skip-az"; return 0; fi
|
|
304
|
+
AZ_STATE="yes"
|
|
305
|
+
if [ "$DRY_RUN" = "1" ]; then log "dry-run: instalaría azure-cli + extensión azure-devops"; return 0; fi
|
|
306
|
+
am_root || die "instalar azure-cli requiere root"
|
|
307
|
+
local keyring=/etc/apt/keyrings/microsoft.gpg
|
|
308
|
+
mkdir -p /etc/apt/keyrings
|
|
309
|
+
[ -f "$keyring" ] || curl -sLS https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > "$keyring"
|
|
310
|
+
chmod go+r "$keyring"
|
|
311
|
+
# shellcheck disable=SC1091
|
|
312
|
+
. /etc/os-release
|
|
313
|
+
{
|
|
314
|
+
echo "Types: deb"
|
|
315
|
+
echo "URIs: https://packages.microsoft.com/repos/azure-cli/"
|
|
316
|
+
echo "Suites: ${VERSION_CODENAME}"
|
|
317
|
+
echo "Components: main"
|
|
318
|
+
echo "Architectures: $(dpkg --print-architecture)"
|
|
319
|
+
echo "Signed-by: $keyring"
|
|
320
|
+
} > /etc/apt/sources.list.d/azure-cli.sources
|
|
321
|
+
apt-get update -qq
|
|
322
|
+
if [ -n "${AZURE_CLI_VERSION:-}" ]; then
|
|
323
|
+
apt-get install -y -qq "azure-cli=${AZURE_CLI_VERSION}-1~${VERSION_CODENAME}" >/dev/null
|
|
324
|
+
else
|
|
325
|
+
apt-get install -y -qq azure-cli >/dev/null
|
|
326
|
+
fi
|
|
327
|
+
if ! az extension list --query "[].name" -o tsv 2>/dev/null | grep -qx azure-devops; then
|
|
328
|
+
az extension add --name azure-devops >/dev/null
|
|
329
|
+
fi
|
|
330
|
+
log "azure-cli instalado: $(az --version 2>/dev/null | head -n1 || echo '?')"
|
|
331
|
+
az devops -h >/dev/null || die "az devops no responde tras instalar la extensión"
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
# --- Instalación de agentes --------------------------------------------------------
|
|
335
|
+
npm_install_agent() {
|
|
336
|
+
local agent="$1" pkg="$2" ver="$3"
|
|
337
|
+
if [ "$DRY_RUN" = "1" ]; then log "dry-run: instalaría $agent@$ver (npm $pkg@$ver)"; return 0; fi
|
|
338
|
+
command -v npm >/dev/null 2>&1 || die "$agent se instala con npm y npm no está en el PATH"
|
|
339
|
+
npm install -g --registry=https://registry.npmjs.org "$pkg@$ver" >/dev/null
|
|
340
|
+
npm cache clean --force >/dev/null 2>&1 || true
|
|
341
|
+
log "agente instalado: $agent@$ver"
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
install_agents() {
|
|
345
|
+
for a in "${AGENTS_ordered[@]}"; do
|
|
346
|
+
case "$a" in
|
|
347
|
+
pi) npm_install_agent pi '@earendil-works/pi-coding-agent' "$PI_VERSION" ;;
|
|
348
|
+
claude) install_claude ;;
|
|
349
|
+
codex) install_codex ;;
|
|
350
|
+
copilot) install_copilot ;;
|
|
351
|
+
agy) install_agy ;;
|
|
352
|
+
esac
|
|
353
|
+
done
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
# supi: sugerencias de prompt para pi (D-J del plan de la imagen). Solo con pi en la
|
|
357
|
+
# lista; el supi/config.json que bond-app inyecta por run es inerte sin este paquete.
|
|
358
|
+
install_supi() {
|
|
359
|
+
agent_requested pi || return 0
|
|
360
|
+
if [ "$DRY_RUN" = "1" ]; then log "dry-run: instalaría supi@$SUPI_VERSION (npm @mrclrchtr/supi-prompt-suggestions)"; SUPI_DONE=1; return 0; fi
|
|
361
|
+
command -v npm >/dev/null 2>&1 || die "supi se instala con npm y npm no está en el PATH"
|
|
362
|
+
npm install -g --registry=https://registry.npmjs.org "@mrclrchtr/supi-prompt-suggestions@$SUPI_VERSION" >/dev/null
|
|
363
|
+
npm cache clean --force >/dev/null 2>&1 || true
|
|
364
|
+
SUPI_DONE=1
|
|
365
|
+
log "supi instalado: @$SUPI_VERSION (sugerencias de prompt para pi)"
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
# bond: el harness que lanzará el agente (D-G/D-H). Versión fijada en versions.env
|
|
369
|
+
# (1.16.4: antes no existe `bond tui`). Además de la CLI, deja la config de máquina del
|
|
370
|
+
# usuario runner horneada: `bond setup --yes` (integraciones de Herdr y skills, que son
|
|
371
|
+
# lo que pinta la barra de estado del agente) y [update] auto=false (D-I: nada de
|
|
372
|
+
# actualizaciones sorpresa en un contenedor; el pin lo manda la imagen).
|
|
373
|
+
install_bond() {
|
|
374
|
+
[ "$WITH_BOND" = "1" ] || return 0
|
|
375
|
+
[ -n "${BOND_VERSION:-}" ] || die "--with-bond necesita BOND_VERSION en $VERSIONS_FILE"
|
|
376
|
+
if [ "$DRY_RUN" = "1" ]; then log "dry-run: instalaría bond@$BOND_VERSION (npm @jmanuelcorral/bond) + «bond setup --yes»"; BOND_DONE=1; return 0; fi
|
|
377
|
+
command -v npm >/dev/null 2>&1 || die "bond se instala con npm y npm no está en el PATH"
|
|
378
|
+
local have
|
|
379
|
+
have="$(bond --version 2>/dev/null || true)"
|
|
380
|
+
if [ "$have" = "$BOND_VERSION" ]; then
|
|
381
|
+
log "bond ya presente: $have"
|
|
382
|
+
else
|
|
383
|
+
log "instalando bond@$BOND_VERSION (npm @jmanuelcorral/bond)"
|
|
384
|
+
npm install -g --registry=https://registry.npmjs.org "@jmanuelcorral/bond@$BOND_VERSION" >/dev/null
|
|
385
|
+
npm cache clean --force >/dev/null 2>&1 || true
|
|
386
|
+
[ "$(bond --version 2>/dev/null)" = "$BOND_VERSION" ] || die "bond instalado pero «bond --version» no responde $BOND_VERSION"
|
|
387
|
+
fi
|
|
388
|
+
# Config de máquina no interactiva (escribe en el HOME del usuario runner).
|
|
389
|
+
as_runner bond setup --yes --no-suggestions >/dev/null || die "bond setup --yes falló"
|
|
390
|
+
local conf="$RUNNER_HOME/.bond/config.toml"
|
|
391
|
+
if [ -f "$conf" ] && ! grep -q '^\[update\]' "$conf"; then
|
|
392
|
+
printf '\n[update]\nauto = false\n' >> "$conf"
|
|
393
|
+
fi
|
|
394
|
+
chown_if_runner "$conf"
|
|
395
|
+
BOND_DONE=1
|
|
396
|
+
log "bond instalado: $(bond --version) (config de máquina lista)"
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
install_agy() {
|
|
400
|
+
# P2/P3: Hornear onboarding y trustedWorkspaces para evitar prompts interactivos iniciales
|
|
401
|
+
local agy_dir="$RUNNER_HOME/.gemini/antigravity-cli"
|
|
402
|
+
install -d -m 0700 "$agy_dir/cache"
|
|
403
|
+
printf '{"consumerOnboardingComplete":true,"enterpriseOnboardingComplete":true,"onboardingComplete":true}\n' > "$agy_dir/cache/onboarding.json"
|
|
404
|
+
chmod 0644 "$agy_dir/cache/onboarding.json"
|
|
405
|
+
|
|
406
|
+
if [ ! -f "$agy_dir/settings.json" ]; then
|
|
407
|
+
printf '{\n "trustedWorkspaces": [\n "/workspace",\n "/workspace/repo"\n ]\n}\n' > "$agy_dir/settings.json"
|
|
408
|
+
chmod 0644 "$agy_dir/settings.json"
|
|
409
|
+
fi
|
|
410
|
+
chown_if_runner "$RUNNER_HOME/.gemini" "$agy_dir" "$agy_dir/cache" "$agy_dir/cache/onboarding.json" "$agy_dir/settings.json"
|
|
411
|
+
|
|
412
|
+
if [ "$DRY_RUN" = "1" ]; then log "dry-run: instalaría agy (instalador oficial; sin pin de versión)"; return 0; fi
|
|
413
|
+
local bindir=/usr/local/bin
|
|
414
|
+
if [ -x "$bindir/agy" ]; then log "agy ya presente en $bindir/agy"; return 0; fi
|
|
415
|
+
# Instalador oficial de Google: binario único con sha512 verificado contra su
|
|
416
|
+
# manifiesto; siempre la última versión (D-C). El paso final «agy install» solo
|
|
417
|
+
# toca perfiles de shell y no es crítico (|| true del propio script oficial).
|
|
418
|
+
curl -fsSL https://antigravity.google/cli/install.sh | bash -s -- --dir "$bindir" >/dev/null
|
|
419
|
+
log "agy instalado: $(agy --version 2>/dev/null | head -n1 || echo '?')"
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
# claude: la CLI por npm (versión fijada) y un envoltorio en su sitio del PATH que la arranca
|
|
423
|
+
# con el token de ~/.claude/oauth-token, si existe, solo en ese proceso. Nada se hornea con
|
|
424
|
+
# secretos: el token llega por run (stdin) o, como excepción D-A, con --credentials.
|
|
425
|
+
install_claude() {
|
|
426
|
+
npm_install_agent claude '@anthropic-ai/claude-code' "$CLAUDE_VERSION"
|
|
427
|
+
if [ "$DRY_RUN" = "1" ]; then log "dry-run: envolvería claude para leer ~/.claude/oauth-token"; return 0; fi
|
|
428
|
+
local entry real
|
|
429
|
+
entry="$(command -v claude)" || die "claude instalado pero no está en el PATH"
|
|
430
|
+
real="$(readlink -f "$entry")"
|
|
431
|
+
[ -n "$real" ] && [ "$real" != "$entry" ] || die "no encuentro el binario real de claude tras $entry"
|
|
432
|
+
rm -f "$entry"
|
|
433
|
+
cat > "$entry" <<WRAP
|
|
434
|
+
#!/bin/sh
|
|
435
|
+
# bond-app (runner/setup.sh): claude con el token de «claude setup-token» que bond-app
|
|
436
|
+
# inyecta por stdin en ~/.claude/oauth-token (0600). La variable existe solo en este
|
|
437
|
+
# proceso y sus hijos; nunca en docker -e, argumentos ni la imagen.
|
|
438
|
+
t="\${HOME}/.claude/oauth-token"
|
|
439
|
+
if [ -z "\${CLAUDE_CODE_OAUTH_TOKEN:-}" ] && [ -r "\$t" ]; then
|
|
440
|
+
CLAUDE_CODE_OAUTH_TOKEN="\$(cat "\$t")"
|
|
441
|
+
export CLAUDE_CODE_OAUTH_TOKEN
|
|
442
|
+
fi
|
|
443
|
+
exec "$real" "\$@"
|
|
444
|
+
WRAP
|
|
445
|
+
chmod 0755 "$entry"
|
|
446
|
+
log "claude envuelto: $entry → $real"
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
# claude sin preguntas al arrancar: onboarding hecho, confianza en las carpetas de los runs,
|
|
450
|
+
# sin la confirmación de --dangerously-skip-permissions, sin auto-update (la versión la
|
|
451
|
+
# fija la imagen) y sin sugerencias de prompt: claude escribe en gris una propuesta en su
|
|
452
|
+
# caja de entrada y quien lee la pantalla (pi al delegar, hc read) la toma por texto real. Se combina con el settings.json que traiga --config, sin pisarlo.
|
|
453
|
+
# hasCompletedOnboarding y projects.<dir>.hasTrustDialogAccepted no están documentados:
|
|
454
|
+
# verificados con claude 2.1.328 (spike del plan bond-app-claude-agente).
|
|
455
|
+
bake_claude() {
|
|
456
|
+
agent_requested claude || return 0
|
|
457
|
+
install -d -m 0700 "$RUNNER_HOME/.claude"
|
|
458
|
+
chown_if_runner "$RUNNER_HOME/.claude"
|
|
459
|
+
CLAUDE_STATE="$RUNNER_HOME/.claude.json" CLAUDE_SETTINGS="$RUNNER_HOME/.claude/settings.json" node -e '
|
|
460
|
+
const fs = require("fs");
|
|
461
|
+
const read = (p) => { try { return JSON.parse(fs.readFileSync(p, "utf8")); } catch { return {}; } };
|
|
462
|
+
const state = read(process.env.CLAUDE_STATE);
|
|
463
|
+
state.hasCompletedOnboarding = true;
|
|
464
|
+
state.projects = state.projects || {};
|
|
465
|
+
for (const dir of ["/workspace", "/workspace/repo", "/workspace/hub"]) {
|
|
466
|
+
state.projects[dir] = { ...(state.projects[dir] || {}), hasTrustDialogAccepted: true };
|
|
467
|
+
}
|
|
468
|
+
fs.writeFileSync(process.env.CLAUDE_STATE, JSON.stringify(state, null, 2) + "\n", { mode: 0o600 });
|
|
469
|
+
const settings = read(process.env.CLAUDE_SETTINGS);
|
|
470
|
+
if (!settings.theme) settings.theme = "dark";
|
|
471
|
+
settings.skipDangerousModePermissionPrompt = true;
|
|
472
|
+
// Sin pedir permisos aunque lo arranque un delegado sin --dangerously-skip-permissions.
|
|
473
|
+
settings.permissions = { ...(settings.permissions || {}), defaultMode: "bypassPermissions" };
|
|
474
|
+
settings.promptSuggestionEnabled = false;
|
|
475
|
+
settings.env = { ...(settings.env || {}), DISABLE_AUTOUPDATER: "1" };
|
|
476
|
+
fs.writeFileSync(process.env.CLAUDE_SETTINGS, JSON.stringify(settings, null, 2) + "\n", { mode: 0o644 });
|
|
477
|
+
' || die "no se pudo hornear la configuración de claude"
|
|
478
|
+
chmod 0600 "$RUNNER_HOME/.claude.json"
|
|
479
|
+
chmod 0644 "$RUNNER_HOME/.claude/settings.json"
|
|
480
|
+
chown_if_runner "$RUNNER_HOME/.claude.json" "$RUNNER_HOME/.claude/settings.json"
|
|
481
|
+
log "claude horneado: onboarding, confianza en /workspace, sin confirmación de bypass, auto-update ni sugerencias"
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
# --- Herramientas de developer (--tools / --apt-extra) -------------------------------
|
|
485
|
+
# Paquetes apt de cada grupo (Debian bookworm). Lo que no está en apt se descarga con
|
|
486
|
+
# versión y sha256 fijados en versions.env.
|
|
487
|
+
tool_apt_packages() {
|
|
488
|
+
case "$1" in
|
|
489
|
+
esenciales) echo "ripgrep fd-find jq tree less file zip unzip xz-utils patch sqlite3 make build-essential python3 python3-venv python3-pip" ;;
|
|
490
|
+
busqueda) echo "shellcheck" ;;
|
|
491
|
+
shell) echo "zsh fzf bat git" ;;
|
|
492
|
+
js) echo "unzip" ;;
|
|
493
|
+
db) echo "postgresql-client redis-tools" ;;
|
|
494
|
+
cloud) echo "unzip" ;;
|
|
495
|
+
*) echo "" ;;
|
|
496
|
+
esac
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
# Descarga $1 en $2 y comprueba su sha256 ($3); nunca deja un fichero sin verificar.
|
|
500
|
+
fetch_verified() {
|
|
501
|
+
local url="$1" dest="$2" sum="$3"
|
|
502
|
+
curl -fsSL -o "$dest" "$url" || die "no se pudo descargar $url"
|
|
503
|
+
echo "$sum $dest" | sha256sum -c - >/dev/null 2>&1 || { rm -f "$dest"; die "sha256 no coincide: $url"; }
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
# Clona un repo en un commit fijado (git verifica el contenido por el hash del commit).
|
|
507
|
+
clone_pinned() {
|
|
508
|
+
local url="$1" dest="$2" commit="$3"
|
|
509
|
+
git init -q "$dest"
|
|
510
|
+
git -C "$dest" fetch -q --depth 1 "$url" "$commit" || die "no se pudo traer $url@$commit"
|
|
511
|
+
git -C "$dest" -c advice.detachedHead=false checkout -q FETCH_HEAD
|
|
512
|
+
[ "$(git -C "$dest" rev-parse HEAD)" = "$commit" ] || die "$url no está en el commit fijado $commit"
|
|
513
|
+
rm -rf "$dest/.git"
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
install_tool_shell() {
|
|
517
|
+
ln -sf /usr/bin/batcat /usr/local/bin/bat
|
|
518
|
+
local tmp; tmp="$(mktemp -d)"
|
|
519
|
+
fetch_verified "https://github.com/dandavison/delta/releases/download/${DELTA_VERSION}/git-delta_${DELTA_VERSION}_amd64.deb" "$tmp/delta.deb" "$DELTA_SHA256"
|
|
520
|
+
dpkg -i "$tmp/delta.deb" >/dev/null
|
|
521
|
+
fetch_verified "https://github.com/starship/starship/releases/download/${STARSHIP_VERSION}/starship-x86_64-unknown-linux-musl.tar.gz" "$tmp/starship.tgz" "$STARSHIP_SHA256"
|
|
522
|
+
tar -xzf "$tmp/starship.tgz" -C /usr/local/bin starship
|
|
523
|
+
rm -rf "$tmp"
|
|
524
|
+
# oh-my-zsh compartido y de solo lectura en /opt; cada usuario lo carga desde su .zshrc.
|
|
525
|
+
rm -rf /opt/oh-my-zsh
|
|
526
|
+
clone_pinned https://github.com/ohmyzsh/ohmyzsh.git /opt/oh-my-zsh "$OHMYZSH_COMMIT"
|
|
527
|
+
clone_pinned https://github.com/zsh-users/zsh-autosuggestions.git /opt/oh-my-zsh/custom/plugins/zsh-autosuggestions "$ZSH_AUTOSUGGESTIONS_COMMIT"
|
|
528
|
+
clone_pinned https://github.com/zsh-users/zsh-syntax-highlighting.git /opt/oh-my-zsh/custom/plugins/zsh-syntax-highlighting "$ZSH_SYNTAX_HIGHLIGHTING_COMMIT"
|
|
529
|
+
# zsh es solo para quien abre una shell (botón Shell): la shell de runner sigue siendo
|
|
530
|
+
# bash, porque los agentes ejecutan sus comandos con $SHELL y claude copia su config.
|
|
531
|
+
local rc="$RUNNER_HOME/.zshrc"
|
|
532
|
+
if [ ! -f "$rc" ]; then
|
|
533
|
+
cat > "$rc" <<'ZSHRC'
|
|
534
|
+
# bond-app (runner/setup.sh, grupo «shell»): oh-my-zsh fijado en /opt, sin autoactualizar.
|
|
535
|
+
export ZSH=/opt/oh-my-zsh
|
|
536
|
+
export ZSH_CACHE_DIR="$HOME/.cache/oh-my-zsh"
|
|
537
|
+
mkdir -p "$ZSH_CACHE_DIR"
|
|
538
|
+
ZSH_THEME=""
|
|
539
|
+
zstyle ':omz:update' mode disabled
|
|
540
|
+
DISABLE_AUTO_UPDATE=true
|
|
541
|
+
# Sin el plugin fzf: busca sus atajos en /usr/share/doc, que la imagen slim no trae.
|
|
542
|
+
plugins=(git zsh-autosuggestions zsh-syntax-highlighting)
|
|
543
|
+
source "$ZSH/oh-my-zsh.sh"
|
|
544
|
+
command -v starship >/dev/null && eval "$(starship init zsh)"
|
|
545
|
+
alias cat='bat --paging=never --style=plain'
|
|
546
|
+
ZSHRC
|
|
547
|
+
chmod 0644 "$rc"
|
|
548
|
+
chown_if_runner "$rc"
|
|
549
|
+
fi
|
|
550
|
+
if command -v git >/dev/null && as_runner git config --global --get core.pager >/dev/null 2>&1; then :; else
|
|
551
|
+
as_runner git config --global core.pager delta || true
|
|
552
|
+
as_runner git config --global interactive.diffFilter "delta --color-only" || true
|
|
553
|
+
fi
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
install_tool_rust() {
|
|
557
|
+
local tmp; tmp="$(mktemp -d)"
|
|
558
|
+
fetch_verified "https://static.rust-lang.org/rustup/archive/${RUSTUP_VERSION}/x86_64-unknown-linux-gnu/rustup-init" "$tmp/rustup-init" "$RUSTUP_SHA256"
|
|
559
|
+
chmod 0755 "$tmp/rustup-init"
|
|
560
|
+
chown_if_runner "$tmp" "$tmp/rustup-init"
|
|
561
|
+
# En el home de runner (cargo install escribe ahí); los proxies van al PATH del sistema.
|
|
562
|
+
as_runner "$tmp/rustup-init" -y --no-modify-path --profile minimal --default-toolchain stable >/dev/null
|
|
563
|
+
rm -rf "$tmp"
|
|
564
|
+
local b
|
|
565
|
+
for b in "$RUNNER_HOME"/.cargo/bin/*; do ln -sf "$b" "/usr/local/bin/$(basename "$b")"; done
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
install_tool_java() {
|
|
569
|
+
local keyring=/etc/apt/keyrings/adoptium.gpg
|
|
570
|
+
mkdir -p /etc/apt/keyrings
|
|
571
|
+
[ -f "$keyring" ] || curl -fsSL https://packages.adoptium.net/artifactory/api/gpg/key/public | gpg --dearmor > "$keyring"
|
|
572
|
+
chmod go+r "$keyring"
|
|
573
|
+
# shellcheck disable=SC1091
|
|
574
|
+
. /etc/os-release
|
|
575
|
+
echo "deb [signed-by=$keyring] https://packages.adoptium.net/artifactory/deb ${VERSION_CODENAME} main" > /etc/apt/sources.list.d/adoptium.list
|
|
576
|
+
apt-get update -qq && apt-get install -y -qq --no-install-recommends temurin-21-jdk maven >/dev/null
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
install_tool_dotnet() {
|
|
580
|
+
local keyring=/etc/apt/keyrings/microsoft.gpg
|
|
581
|
+
mkdir -p /etc/apt/keyrings
|
|
582
|
+
[ -f "$keyring" ] || curl -sLS https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > "$keyring"
|
|
583
|
+
chmod go+r "$keyring"
|
|
584
|
+
# shellcheck disable=SC1091
|
|
585
|
+
. /etc/os-release
|
|
586
|
+
echo "deb [arch=amd64 signed-by=$keyring] https://packages.microsoft.com/debian/${VERSION_ID}/prod ${VERSION_CODENAME} main" > /etc/apt/sources.list.d/microsoft-prod.list
|
|
587
|
+
apt-get update -qq && apt-get install -y -qq --no-install-recommends dotnet-sdk-8.0 >/dev/null
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
# Docker en el run (plan bond-app-ajustes-imagen P4): el motor y sus plugins del repo apt
|
|
591
|
+
# oficial de Docker (firmado), la CLI de devcontainers fijada, y runner en el grupo docker.
|
|
592
|
+
# dockerd solo arranca en los runs que lo piden (entrypoint.sh con BOND_DIND=1, contenedor
|
|
593
|
+
# --privileged); en los demás el binario está pero no hay demonio ni permisos para él.
|
|
594
|
+
install_tool_docker() {
|
|
595
|
+
local keyring=/etc/apt/keyrings/docker.asc
|
|
596
|
+
mkdir -p /etc/apt/keyrings
|
|
597
|
+
[ -f "$keyring" ] || curl -fsSL https://download.docker.com/linux/debian/gpg -o "$keyring"
|
|
598
|
+
chmod go+r "$keyring"
|
|
599
|
+
# shellcheck disable=SC1091
|
|
600
|
+
. /etc/os-release
|
|
601
|
+
echo "deb [arch=$(dpkg --print-architecture) signed-by=$keyring] https://download.docker.com/linux/debian ${VERSION_CODENAME} stable" > /etc/apt/sources.list.d/docker.list
|
|
602
|
+
apt-get update -qq && apt-get install -y -qq --no-install-recommends \
|
|
603
|
+
docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin iptables >/dev/null
|
|
604
|
+
command -v npm >/dev/null 2>&1 || die "la CLI de devcontainers se instala con npm y npm no está en el PATH"
|
|
605
|
+
npm install -g --registry=https://registry.npmjs.org "@devcontainers/cli@$DEVCONTAINERS_CLI_VERSION" >/dev/null
|
|
606
|
+
npm cache clean --force >/dev/null 2>&1 || true
|
|
607
|
+
if runner_account_exists; then usermod -aG docker "$RUNNER_USER"; fi
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
install_tool_group() {
|
|
611
|
+
local tmp
|
|
612
|
+
case "$1" in
|
|
613
|
+
esenciales)
|
|
614
|
+
ln -sf /usr/bin/fdfind /usr/local/bin/fd
|
|
615
|
+
fetch_verified "https://github.com/mikefarah/yq/releases/download/${YQ_VERSION}/yq_linux_amd64" /usr/local/bin/yq "$YQ_SHA256"
|
|
616
|
+
chmod 0755 /usr/local/bin/yq ;;
|
|
617
|
+
busqueda)
|
|
618
|
+
command -v npm >/dev/null 2>&1 || die "ast-grep se instala con npm y npm no está en el PATH"
|
|
619
|
+
npm install -g --registry=https://registry.npmjs.org "@ast-grep/cli@$AST_GREP_VERSION" >/dev/null
|
|
620
|
+
npm cache clean --force >/dev/null 2>&1 || true ;;
|
|
621
|
+
shell) install_tool_shell ;;
|
|
622
|
+
python)
|
|
623
|
+
tmp="$(mktemp -d)"
|
|
624
|
+
fetch_verified "https://github.com/astral-sh/uv/releases/download/${UV_VERSION}/uv-x86_64-unknown-linux-gnu.tar.gz" "$tmp/uv.tgz" "$UV_SHA256"
|
|
625
|
+
tar -xzf "$tmp/uv.tgz" -C "$tmp"
|
|
626
|
+
install -m 0755 "$tmp"/uv-x86_64-unknown-linux-gnu/uv "$tmp"/uv-x86_64-unknown-linux-gnu/uvx /usr/local/bin/
|
|
627
|
+
rm -rf "$tmp" ;;
|
|
628
|
+
go)
|
|
629
|
+
tmp="$(mktemp -d)"
|
|
630
|
+
fetch_verified "https://go.dev/dl/go${GO_VERSION}.linux-amd64.tar.gz" "$tmp/go.tgz" "$GO_SHA256"
|
|
631
|
+
rm -rf /usr/local/go && tar -xzf "$tmp/go.tgz" -C /usr/local
|
|
632
|
+
ln -sf /usr/local/go/bin/go /usr/local/bin/go
|
|
633
|
+
ln -sf /usr/local/go/bin/gofmt /usr/local/bin/gofmt
|
|
634
|
+
rm -rf "$tmp" ;;
|
|
635
|
+
rust) install_tool_rust ;;
|
|
636
|
+
java) install_tool_java ;;
|
|
637
|
+
dotnet) install_tool_dotnet ;;
|
|
638
|
+
js)
|
|
639
|
+
corepack enable >/dev/null
|
|
640
|
+
# pnpm y yarn bajados ya, en versiones fijadas: si no, corepack pregunta antes de
|
|
641
|
+
# descargarlos la primera vez y un agente se quedaría esperando esa respuesta.
|
|
642
|
+
as_runner env COREPACK_ENABLE_DOWNLOAD_PROMPT=0 corepack install -g "pnpm@$PNPM_VERSION" "yarn@$YARN_VERSION" >/dev/null
|
|
643
|
+
tmp="$(mktemp -d)"
|
|
644
|
+
fetch_verified "https://github.com/oven-sh/bun/releases/download/bun-v${BUN_VERSION}/bun-linux-x64.zip" "$tmp/bun.zip" "$BUN_SHA256"
|
|
645
|
+
unzip -q "$tmp/bun.zip" -d "$tmp"
|
|
646
|
+
install -m 0755 "$tmp/bun-linux-x64/bun" /usr/local/bin/bun
|
|
647
|
+
ln -sf /usr/local/bin/bun /usr/local/bin/bunx
|
|
648
|
+
rm -rf "$tmp" ;;
|
|
649
|
+
db) ;;
|
|
650
|
+
docker) install_tool_docker ;;
|
|
651
|
+
cloud)
|
|
652
|
+
fetch_verified "https://dl.k8s.io/release/${KUBECTL_VERSION}/bin/linux/amd64/kubectl" /usr/local/bin/kubectl "$KUBECTL_SHA256"
|
|
653
|
+
chmod 0755 /usr/local/bin/kubectl
|
|
654
|
+
tmp="$(mktemp -d)"
|
|
655
|
+
fetch_verified "https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_linux_amd64.zip" "$tmp/tf.zip" "$TERRAFORM_SHA256"
|
|
656
|
+
unzip -q "$tmp/tf.zip" -d "$tmp" && install -m 0755 "$tmp/terraform" /usr/local/bin/terraform
|
|
657
|
+
rm -rf "$tmp" ;;
|
|
658
|
+
esac
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
install_tools() {
|
|
662
|
+
[ "${#TOOLS_ordered[@]}" -gt 0 ] || [ "${#APT_EXTRA[@]}" -gt 0 ] || return 0
|
|
663
|
+
local pkgs=() t
|
|
664
|
+
for t in "${TOOLS_ordered[@]}"; do
|
|
665
|
+
# shellcheck disable=SC2207
|
|
666
|
+
pkgs+=($(tool_apt_packages "$t"))
|
|
667
|
+
done
|
|
668
|
+
pkgs+=("${APT_EXTRA[@]}")
|
|
669
|
+
if [ "$DRY_RUN" = "1" ]; then
|
|
670
|
+
for t in "${TOOLS_ordered[@]}"; do log "dry-run: instalaría el grupo $t ($(tool_apt_packages "$t"))"; done
|
|
671
|
+
[ "${#APT_EXTRA[@]}" -eq 0 ] || log "dry-run: instalaría de apt: ${APT_EXTRA[*]}"
|
|
672
|
+
return 0
|
|
673
|
+
fi
|
|
674
|
+
am_root || die "instalar herramientas requiere root"
|
|
675
|
+
if [ "${#pkgs[@]}" -gt 0 ]; then
|
|
676
|
+
apt-get update -qq
|
|
677
|
+
# shellcheck disable=SC2068
|
|
678
|
+
apt-get install -y -qq --no-install-recommends $(printf '%s\n' "${pkgs[@]}" | sort -u) >/dev/null \
|
|
679
|
+
|| die "apt-get no pudo instalar: ${pkgs[*]}"
|
|
680
|
+
fi
|
|
681
|
+
for t in "${TOOLS_ordered[@]}"; do
|
|
682
|
+
install_tool_group "$t"
|
|
683
|
+
log "herramientas instaladas: $t"
|
|
684
|
+
done
|
|
685
|
+
rm -rf /var/lib/apt/lists/*
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
# codex y copilot sin preguntas al arrancar (plan bond-app-codex-copilot). Se combinan con
|
|
689
|
+
# la config que ya haya (la de --config, o la que deja «bond setup»), sin pisarla.
|
|
690
|
+
bake_codex() {
|
|
691
|
+
agent_requested codex || return 0
|
|
692
|
+
install -d -m 0700 "$RUNNER_HOME/.codex"
|
|
693
|
+
chown_if_runner "$RUNNER_HOME/.codex"
|
|
694
|
+
CODEX_CONFIG="$RUNNER_HOME/.codex/config.toml" node -e '
|
|
695
|
+
const fs = require("fs");
|
|
696
|
+
const f = process.env.CODEX_CONFIG;
|
|
697
|
+
let t = ""; try { t = fs.readFileSync(f, "utf8"); } catch {}
|
|
698
|
+
// Las claves sueltas de TOML van antes de la primera tabla.
|
|
699
|
+
if (!/^check_for_update_on_startup\s*=/m.test(t)) t = "check_for_update_on_startup = false\n" + t;
|
|
700
|
+
if (!/^\[notice\]/m.test(t)) t += "\n[notice]\nhide_full_access_warning = true\n";
|
|
701
|
+
for (const dir of ["/workspace", "/workspace/repo", "/workspace/hub"]) {
|
|
702
|
+
if (!t.includes(`[projects."${dir}"]`)) t += `\n[projects."${dir}"]\ntrust_level = "trusted"\n`;
|
|
703
|
+
}
|
|
704
|
+
fs.writeFileSync(f, t, { mode: 0o644 });
|
|
705
|
+
' || die "no se pudo hornear la configuración de codex"
|
|
706
|
+
chmod 0644 "$RUNNER_HOME/.codex/config.toml"
|
|
707
|
+
chown_if_runner "$RUNNER_HOME/.codex/config.toml"
|
|
708
|
+
log "codex horneado: confianza en /workspace, sin comprobar actualizaciones ni aviso de acceso total"
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
bake_copilot() {
|
|
712
|
+
agent_requested copilot || return 0
|
|
713
|
+
install -d -m 0700 "$RUNNER_HOME/.copilot"
|
|
714
|
+
chown_if_runner "$RUNNER_HOME/.copilot"
|
|
715
|
+
COPILOT_SETTINGS="$RUNNER_HOME/.copilot/settings.json" node -e '
|
|
716
|
+
const fs = require("fs");
|
|
717
|
+
const f = process.env.COPILOT_SETTINGS;
|
|
718
|
+
let s = {}; try { s = JSON.parse(fs.readFileSync(f, "utf8")); } catch {}
|
|
719
|
+
// Sin llavero en el contenedor: el token del login va a ~/.copilot/config.json sin preguntar.
|
|
720
|
+
s.storeTokenPlaintext = true;
|
|
721
|
+
s.trustedFolders = [...new Set([...(s.trustedFolders || []), "/workspace", "/workspace/repo", "/workspace/hub"])];
|
|
722
|
+
s.autoUpdate = false;
|
|
723
|
+
if (!s.banner) s.banner = "never";
|
|
724
|
+
fs.writeFileSync(f, JSON.stringify(s, null, 2) + "\n", { mode: 0o644 });
|
|
725
|
+
' || die "no se pudo hornear la configuración de copilot"
|
|
726
|
+
chmod 0644 "$RUNNER_HOME/.copilot/settings.json"
|
|
727
|
+
chown_if_runner "$RUNNER_HOME/.copilot/settings.json"
|
|
728
|
+
log "copilot horneado: token en fichero, carpetas de confianza, sin autoactualizar ni banner"
|
|
729
|
+
}
|
|
730
|
+
|
|
731
|
+
# codex: la CLI por npm y un envoltorio que, en modo interactivo (sin subcomando), la arranca
|
|
732
|
+
# con --dangerously-bypass-hook-trust (bond le pone hooks y codex se para en «Hooks need
|
|
733
|
+
# review» cada vez que cambian) y --dangerously-bypass-approvals-and-sandbox, como el run
|
|
734
|
+
# principal; así vale también cuando lo lanza un delegado (bond-delegate lo arranca sin
|
|
735
|
+
# argumentos). Los subcomandos (login, exec…) van tal cual.
|
|
736
|
+
install_codex() {
|
|
737
|
+
npm_install_agent codex '@openai/codex' "$CODEX_VERSION"
|
|
738
|
+
if [ "$DRY_RUN" = "1" ]; then log "dry-run: envolvería codex (sin confirmar hooks)"; return 0; fi
|
|
739
|
+
local entry real
|
|
740
|
+
entry="$(command -v codex)" || die "codex instalado pero no está en el PATH"
|
|
741
|
+
real="$(readlink -f "$entry")"
|
|
742
|
+
[ -n "$real" ] && [ "$real" != "$entry" ] || die "no encuentro el binario real de codex tras $entry"
|
|
743
|
+
rm -f "$entry"
|
|
744
|
+
cat > "$entry" <<WRAP
|
|
745
|
+
#!/bin/sh
|
|
746
|
+
# bond-app (runner/setup.sh): codex interactivo sin pararse a confirmar los hooks de bond.
|
|
747
|
+
case "\${1:-}" in
|
|
748
|
+
exec|e|review|login|logout|mcp|plugin|app-server|remote-control|completion|update|doctor|sandbox|debug|apply|a|queue|archive|delete|migrate-*|unarchive|cloud|exec-server|features|help|agents|-h|--help|-V|--version)
|
|
749
|
+
exec "$real" "\$@" ;;
|
|
750
|
+
esac
|
|
751
|
+
# Lo mismo que lleva el run principal, también para los delegados (bond-delegate lo lanza
|
|
752
|
+
# sin argumentos): sin confirmar hooks ni pedir aprobaciones; el contenedor es el sandbox.
|
|
753
|
+
hooks=--dangerously-bypass-hook-trust
|
|
754
|
+
bypass=--dangerously-bypass-approvals-and-sandbox
|
|
755
|
+
for a in "\$@"; do
|
|
756
|
+
[ "\$a" = "\$hooks" ] && hooks=
|
|
757
|
+
[ "\$a" = "\$bypass" ] && bypass=
|
|
758
|
+
done
|
|
759
|
+
exec "$real" \$hooks \$bypass "\$@"
|
|
760
|
+
WRAP
|
|
761
|
+
chmod 0755 "$entry"
|
|
762
|
+
log "codex envuelto: $entry → $real"
|
|
763
|
+
}
|
|
764
|
+
|
|
765
|
+
# copilot: la CLI por npm y un envoltorio en su sitio del PATH que la arranca confiando en
|
|
766
|
+
# la carpeta del run (COPILOT_ALLOW_ALL=true exacto: su trustedFolders de settings.json no
|
|
767
|
+
# basta, sigue preguntando) y sin autoactualizarse. Solo en su proceso; nada secreto.
|
|
768
|
+
install_copilot() {
|
|
769
|
+
npm_install_agent copilot '@github/copilot' "$COPILOT_VERSION"
|
|
770
|
+
if [ "$DRY_RUN" = "1" ]; then log "dry-run: envolvería copilot (confianza en la carpeta, sin autoactualizar)"; return 0; fi
|
|
771
|
+
local entry real
|
|
772
|
+
entry="$(command -v copilot)" || die "copilot instalado pero no está en el PATH"
|
|
773
|
+
real="$(readlink -f "$entry")"
|
|
774
|
+
[ -n "$real" ] && [ "$real" != "$entry" ] || die "no encuentro el binario real de copilot tras $entry"
|
|
775
|
+
rm -f "$entry"
|
|
776
|
+
cat > "$entry" <<WRAP
|
|
777
|
+
#!/bin/sh
|
|
778
|
+
# bond-app (runner/setup.sh): copilot sin preguntar si confía en la carpeta del run y sin
|
|
779
|
+
# autoactualizarse (la versión la fija la imagen). Solo en este proceso y sus hijos.
|
|
780
|
+
: "\${COPILOT_ALLOW_ALL:=true}"
|
|
781
|
+
: "\${COPILOT_AUTO_UPDATE:=false}"
|
|
782
|
+
export COPILOT_ALLOW_ALL COPILOT_AUTO_UPDATE
|
|
783
|
+
exec "$real" "\$@"
|
|
784
|
+
WRAP
|
|
785
|
+
chmod 0755 "$entry"
|
|
786
|
+
log "copilot envuelto: $entry → $real"
|
|
787
|
+
}
|
|
788
|
+
|
|
789
|
+
version_of() {
|
|
790
|
+
local agent="$1" ver
|
|
791
|
+
if [ "$DRY_RUN" = "1" ]; then pin_for "$agent"; return 0; fi
|
|
792
|
+
ver="$("$agent" --version 2>/dev/null | head -n1 | grep -oE '[0-9]+(\.[0-9A-Za-z-]+)+' | head -n1)" || ver=""
|
|
793
|
+
if [ -n "$ver" ]; then echo "$ver"; else pin_for "$agent"; fi
|
|
794
|
+
}
|
|
795
|
+
|
|
796
|
+
# --- Copia de config ---------------------------------------------------------------
|
|
797
|
+
install_config() {
|
|
798
|
+
for agent in "${!CONFIG_SRC[@]}"; do
|
|
799
|
+
local src="${CONFIG_SRC[$agent]}" dest="${CONFIG_DEST[$agent]}"
|
|
800
|
+
install -d -m 0700 "$(dirname "$dest")"
|
|
801
|
+
chown_if_runner "$(dirname "$dest")"
|
|
802
|
+
install -m 0644 "$src" "$dest"
|
|
803
|
+
chown_if_runner "$dest"
|
|
804
|
+
CONFIG_HASH[$agent]="$(sha256sum "$dest" | cut -d' ' -f1)"
|
|
805
|
+
log "config instalada: $agent → $dest"
|
|
806
|
+
done
|
|
807
|
+
}
|
|
808
|
+
|
|
809
|
+
# --- Credenciales -------------------------------------------------------------------
|
|
810
|
+
# Claves admitidas (ver credentials.example.env). Nunca se registran valores.
|
|
811
|
+
CRED_KEYS="GH_TOKEN CLAUDE_TOKEN CODEX_TOKEN"
|
|
812
|
+
CRED_REJECTED_KEYS="COPILOT_TOKEN AGY_TOKEN"
|
|
813
|
+
|
|
814
|
+
guard_cred_agent() {
|
|
815
|
+
agent_requested "$1" || die "el fichero de credenciales trae $2 pero '$1' no está en --agents"
|
|
816
|
+
}
|
|
817
|
+
|
|
818
|
+
read_credentials() {
|
|
819
|
+
GH_TOKEN_V="" CLAUDE_TOKEN_V="" CODEX_TOKEN_V=""
|
|
820
|
+
local line key value
|
|
821
|
+
while IFS= read -r line || [ -n "$line" ]; do
|
|
822
|
+
line="${line%$'\r'}"
|
|
823
|
+
case "$line" in ''|'#'*) continue ;; esac
|
|
824
|
+
key="${line%%=*}"; value="${line#*=}"
|
|
825
|
+
case " $CRED_REJECTED_KEYS " in
|
|
826
|
+
*" $key "*) die "$key no tiene fichero de credenciales soportado (D-C): usa GH_TOKEN (cubre a copilot vía gh) o la inyección por stdin de bond-app (agy)" ;;
|
|
827
|
+
esac
|
|
828
|
+
case " $CRED_KEYS " in
|
|
829
|
+
*" $key "*) printf -v "${key}_V" '%s' "$value" ;;
|
|
830
|
+
*) die "clave desconocida en el fichero de credenciales: $key" ;;
|
|
831
|
+
esac
|
|
832
|
+
case "$value" in
|
|
833
|
+
*[!A-Za-z0-9._=/+:-]*) die "caracteres no soportados en el valor de $key" ;;
|
|
834
|
+
esac
|
|
835
|
+
done < "$CRED_FILE"
|
|
836
|
+
}
|
|
837
|
+
|
|
838
|
+
write_token_file() {
|
|
839
|
+
# write_token_file <ruta> <contenido> — 0600, del usuario runner.
|
|
840
|
+
local dest="$1" content="$2"
|
|
841
|
+
install -d -m 0700 "$(dirname "$dest")"
|
|
842
|
+
chown_if_runner "$(dirname "$dest")"
|
|
843
|
+
(umask 077 && printf '%s\n' "$content" > "$dest")
|
|
844
|
+
chmod 0600 "$dest"
|
|
845
|
+
chown_if_runner "$dest"
|
|
846
|
+
}
|
|
847
|
+
|
|
848
|
+
install_credentials() {
|
|
849
|
+
CRED_WRITTEN=""
|
|
850
|
+
[ -n "$CRED_FILE" ] || return 0
|
|
851
|
+
read_credentials
|
|
852
|
+
[ -z "$CODEX_TOKEN_V" ] || guard_cred_agent codex CODEX_TOKEN
|
|
853
|
+
[ -z "$CLAUDE_TOKEN_V" ] || guard_cred_agent claude CLAUDE_TOKEN
|
|
854
|
+
if [ -n "$GH_TOKEN_V" ]; then
|
|
855
|
+
mask "autenticando gh con GH_TOKEN"
|
|
856
|
+
if [ "$DRY_RUN" = "1" ] && ! command -v gh >/dev/null 2>&1; then
|
|
857
|
+
log "dry-run: gh no disponible; no se ejecuta «gh auth login --with-token»"
|
|
858
|
+
else
|
|
859
|
+
# El token viaja por stdin de la orden; nunca por args ni se loguea.
|
|
860
|
+
printf '%s' "$GH_TOKEN_V" | as_runner gh auth login --with-token \
|
|
861
|
+
|| die "gh auth login falló"
|
|
862
|
+
fi
|
|
863
|
+
CRED_WRITTEN="$CRED_WRITTEN gh"
|
|
864
|
+
fi
|
|
865
|
+
if [ -n "$CODEX_TOKEN_V" ]; then
|
|
866
|
+
mask "escribiendo credenciales de codex"
|
|
867
|
+
write_token_file "$RUNNER_HOME/.codex/auth.json" "{\"OPENAI_API_KEY\":\"$CODEX_TOKEN_V\"}"
|
|
868
|
+
CRED_WRITTEN="$CRED_WRITTEN codex"
|
|
869
|
+
fi
|
|
870
|
+
if [ -n "$CLAUDE_TOKEN_V" ]; then
|
|
871
|
+
mask "escribiendo credenciales de claude"
|
|
872
|
+
write_token_file "$RUNNER_HOME/.claude/oauth-token" "$CLAUDE_TOKEN_V"
|
|
873
|
+
CRED_WRITTEN="$CRED_WRITTEN claude"
|
|
874
|
+
fi
|
|
875
|
+
}
|
|
876
|
+
|
|
877
|
+
# --- Manifiesto -----------------------------------------------------------------------
|
|
878
|
+
# Formato: comentario de cabecera + una línea por agente instalado:
|
|
879
|
+
# agent=<nombre> version=<versión instalada o pin> config_sha256=<sha256|none> credentials=<yes|no>
|
|
880
|
+
# y una línea pkg=<paquete> ... por soporte no-agente instalado (supi); parseRunnerManifest
|
|
881
|
+
# solo lee las líneas agent=.
|
|
882
|
+
# Las líneas tool=<gh|az> installed=<yes|skipped> reflejan si las CLIs de sistema se
|
|
883
|
+
# instalaron u omitieron (--skip-gh/--skip-az).
|
|
884
|
+
write_manifest() {
|
|
885
|
+
local tmp agent has_cred line
|
|
886
|
+
tmp="$(mktemp "${MANIFEST_PATH}.XXXXXX")"
|
|
887
|
+
{
|
|
888
|
+
echo "# runner-agents — generado por runner/setup.sh (no editar)."
|
|
889
|
+
echo "# agent=<nombre> version=<v> config_sha256=<sha256|none> credentials=<yes|no>"
|
|
890
|
+
for agent in "${AGENTS_ordered[@]}"; do
|
|
891
|
+
has_cred=no
|
|
892
|
+
case " $CRED_WRITTEN " in *" $agent "*) has_cred=yes ;; esac
|
|
893
|
+
line="agent=$agent version=$(version_of "$agent") config_sha256=${CONFIG_HASH[$agent]:-none} credentials=$has_cred"
|
|
894
|
+
printf '%s\n' "$line"
|
|
895
|
+
done
|
|
896
|
+
if [ -n "${SUPI_DONE:-}" ]; then
|
|
897
|
+
printf 'pkg=supi version=%s config_sha256=none credentials=no\n' "$SUPI_VERSION"
|
|
898
|
+
fi
|
|
899
|
+
if [ -n "${BOND_DONE:-}" ]; then
|
|
900
|
+
printf 'pkg=bond version=%s config_sha256=none credentials=no\n' "$(bond --version 2>/dev/null || echo "$BOND_VERSION")"
|
|
901
|
+
fi
|
|
902
|
+
for t in "${TOOLS_ordered[@]}"; do printf 'group=%s installed=yes\n' "$t"; done
|
|
903
|
+
[ "${#APT_EXTRA[@]}" -eq 0 ] || printf 'apt_extra=%s\n' "$(IFS=,; echo "${APT_EXTRA[*]}")"
|
|
904
|
+
printf 'tool=gh installed=%s\n' "${GH_STATE:-yes}"
|
|
905
|
+
printf 'tool=az installed=%s\n' "${AZ_STATE:-yes}"
|
|
906
|
+
} > "$tmp"
|
|
907
|
+
mv "$tmp" "$MANIFEST_PATH"
|
|
908
|
+
chmod 0644 "$MANIFEST_PATH"
|
|
909
|
+
log "manifiesto escrito en $MANIFEST_PATH"
|
|
910
|
+
}
|
|
911
|
+
|
|
912
|
+
# --- Main -----------------------------------------------------------------------------
|
|
913
|
+
log "agentes pedidos: ${AGENTS_ordered[*]} (config: ${CONFIG_DIR:-ninguna}; credenciales: ${CRED_FILE:-ningunas})"
|
|
914
|
+
install_system_deps
|
|
915
|
+
install_gh
|
|
916
|
+
install_az
|
|
917
|
+
install_tools
|
|
918
|
+
install_agents
|
|
919
|
+
install_supi
|
|
920
|
+
install_bond
|
|
921
|
+
install_config
|
|
922
|
+
bake_claude
|
|
923
|
+
bake_codex
|
|
924
|
+
bake_copilot
|
|
925
|
+
install_credentials
|
|
926
|
+
write_manifest
|
|
927
|
+
log "listo"
|