pantheon-opencode 1.6.1 → 1.6.2-beta.2
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/AGENTS.global.md +11 -11
- package/AGENTS.md +2 -2
- package/CHANGELOG.md +29 -0
- package/README.md +100 -19
- package/README.pt-BR.md +27 -11
- package/bin/pantheon-init.mjs +106 -19
- package/package.json +3 -2
- package/plugin.json +1 -1
- package/pyproject.toml +1 -1
- package/scripts/build-agents-md.mjs +1 -1
- package/scripts/doctor.mjs +213 -45
- package/scripts/install/agents-md.mjs +2 -1
- package/scripts/install/config-migration.mjs +344 -393
- package/scripts/install/config-paths.mjs +15 -0
- package/scripts/install/mcp-permissions.mjs +164 -0
- package/scripts/install/opencode-version.mjs +31 -13
- package/scripts/install/opencode-wildcard.mjs +106 -0
- package/scripts/install/opencode.mjs +240 -69
- package/scripts/install/plan-artifact.mjs +12 -1
- package/scripts/install/plugin.mjs +17 -1
- package/scripts/install/v2-capabilities.mjs +5 -6
- package/scripts/package-evidence.mjs +1 -0
- package/scripts/sandbox-env.sh +174 -0
- package/scripts/setup-v2-config.mjs +1703 -0
- package/scripts/setup.mjs +415 -0
- package/scripts/sync-tui.mjs +9 -1
- package/scripts/test-opencode-v2-sandbox.sh +438 -151
- package/scripts/update-skills-lock.mjs +30 -0
- package/skills-lock.json +10 -10
- package/src/agents/aphrodite.md +5 -2
- package/src/agents/apollo.md +5 -0
- package/src/agents/athena.md +6 -1
- package/src/agents/demeter.md +5 -1
- package/src/agents/gaia.md +4 -0
- package/src/agents/hephaestus.md +6 -1
- package/src/agents/hermes.md +6 -3
- package/src/agents/iris.md +5 -1
- package/src/agents/mnemosyne.md +20 -50
- package/src/agents/nyx.md +5 -1
- package/src/agents/prometheus.md +4 -0
- package/src/agents/talos.md +4 -0
- package/src/agents/themis.md +4 -0
- package/src/agents/zeus.md +9 -3
- package/src/instructions/agent-return-format.instructions.md +1 -1
- package/src/instructions/memory-protocol.instructions.md +3 -3
- package/src/instructions/test-economy.instructions.md +6 -6
- package/src/mcp/pantheon_vision.py +37 -36
- package/src/pantheon/cost-command.ts +30 -133
- package/src/pantheon/model-pricing.ts +1 -536
- package/src/pantheon/v2-vision.ts +34 -29
- package/src/pantheon/vision.ts +43 -10
- package/src/plugin-v2.ts +30 -53
- package/src/plugins/tui/THIRD_PARTY_NOTICES.md +24 -0
- package/src/plugins/tui/dist/cost-data-CCZUs1aJ.js +749 -0
- package/src/plugins/tui/dist/cost-data-CCZUs1aJ.js.map +1 -0
- package/src/plugins/tui/dist/quota-adapters.d.ts +89 -0
- package/src/plugins/tui/dist/quota-adapters.d.ts.map +1 -0
- package/src/plugins/tui/dist/quota-adapters.js +1142 -0
- package/src/plugins/tui/dist/quota-adapters.js.map +1 -0
- package/src/plugins/tui/dist/quota-cli.d.ts +17 -0
- package/src/plugins/tui/dist/quota-cli.d.ts.map +1 -0
- package/src/plugins/tui/dist/quota-cli.js +184 -0
- package/src/plugins/tui/dist/quota-cli.js.map +1 -0
- package/src/plugins/tui/dist/quota-rpc-DMmXBhBe.js +684 -0
- package/src/plugins/tui/dist/quota-rpc-DMmXBhBe.js.map +1 -0
- package/src/plugins/tui/dist/server-v2.d.ts +14 -0
- package/src/plugins/tui/dist/server-v2.d.ts.map +1 -0
- package/src/plugins/tui/dist/server-v2.js +796 -0
- package/src/plugins/tui/dist/server-v2.js.map +1 -0
- package/src/plugins/tui/dist/tui-v2.d.ts +375 -53
- package/src/plugins/tui/dist/tui-v2.d.ts.map +1 -1
- package/src/plugins/tui/dist/tui-v2.js +5876 -530
- package/src/plugins/tui/dist/tui-v2.js.map +1 -1
- package/src/plugins/tui/dist/tui.js +1 -1
- package/src/plugins/tui/dist/usage-history-contract-nt1rnBPE.js +118 -0
- package/src/plugins/tui/dist/usage-history-contract-nt1rnBPE.js.map +1 -0
- package/src/plugins/tui/dist/usage-history-worker.js +25 -0
- package/src/plugins/tui/dist/usage-history-worker.js.map +1 -0
- package/src/plugins/tui/index-v2.ts +3 -6
- package/src/plugins/tui/package-lock.json +17 -2
- package/src/plugins/tui/package.json +6 -3
- package/src/plugins/tui/src/context-gauge.ts +59 -0
- package/src/plugins/tui/src/cost-data.ts +607 -0
- package/src/plugins/tui/src/go-key-diagnostic-ui.ts +100 -0
- package/src/plugins/tui/src/go-key-diagnostic.ts +125 -0
- package/src/plugins/tui/src/index-v2.tsx +231 -240
- package/src/plugins/tui/src/model-pricing.ts +536 -0
- package/src/plugins/tui/src/model-usage-limits.ts +4 -0
- package/src/plugins/tui/src/quota-adapters.ts +1598 -0
- package/src/plugins/tui/src/quota-cli.ts +237 -0
- package/src/plugins/tui/src/quota-rpc.ts +373 -0
- package/src/plugins/tui/src/quota-v2-model.ts +1032 -0
- package/src/plugins/tui/src/quota-v2.tsx +1238 -0
- package/src/plugins/tui/src/server-v2.ts +985 -0
- package/src/plugins/tui/src/sidebar-width.ts +129 -0
- package/src/plugins/tui/src/usage-history-contract.ts +217 -0
- package/src/plugins/tui/src/usage-history-validation.ts +104 -0
- package/src/plugins/tui/src/usage-history-view.tsx +236 -0
- package/src/plugins/tui/src/usage-history-worker.ts +25 -0
- package/src/plugins/tui/src/usage-view-model.ts +272 -0
- package/src/plugins/tui/tsconfig.typecheck.json +6 -1
- package/src/plugins/tui/tsdown.config.ts +44 -5
- package/src/routing.yml +72 -13
- package/src/skills/README.md +4 -0
- package/src/skills/agent-coordination/SKILL.md +0 -3
- package/src/skills/artifact-management/SKILL.md +0 -3
- package/src/skills/auto-continue/SKILL.md +0 -3
- package/src/skills/code-review-checklist/SKILL.md +0 -3
- package/src/skills/context-compression/SKILL.md +0 -3
- package/src/skills/memory-bank/SKILL.md +6 -28
- package/src/skills/session-goal/SKILL.md +0 -3
- package/src/skills/simplify/SKILL.md +5 -4
- package/src/skills/tdd-with-agents/SKILL.md +0 -3
- package/src/skills/visual-review-pipeline/SKILL.md +0 -1
- package/src/pantheon/memory-context.ts +0 -1017
|
@@ -49,21 +49,81 @@
|
|
|
49
49
|
# sandbox root that overlaps either protected repo.
|
|
50
50
|
# PANTHEON_SANDBOX_MODEL Model used by init/prompts
|
|
51
51
|
# (default: opencode-go/mimo-v2.5)
|
|
52
|
+
# PANTHEON_V2_CONFIG Config file path (must be inside the sandbox root)
|
|
53
|
+
# PANTHEON_V2_DB Database path (must be inside the sandbox root)
|
|
52
54
|
# PANTHEON_PROMPT_TIMEOUT Per-prompt timeout in seconds (default: 300)
|
|
53
55
|
# Exit codes: 0 = every required check returned explicit PASS,
|
|
54
56
|
# 1 = any failure or untested check (see reports in the sandbox root),
|
|
55
57
|
# 2 = usage error, 3 = sandbox not prepared.
|
|
56
58
|
set -euo pipefail
|
|
57
59
|
|
|
58
|
-
|
|
60
|
+
# Keep this bootstrap self-contained: do not source, execute, create, chmod, or
|
|
61
|
+
# clean up anything until both the configured root and adjacent helper pass the
|
|
62
|
+
# same basic path checks. The sourced helper repeats these checks for callers.
|
|
63
|
+
BOOTSTRAP_NORMALIZED=""
|
|
64
|
+
bootstrap_normalize_path() {
|
|
65
|
+
local path="$1" current="/" rest component normalized=""
|
|
66
|
+
local LC_ALL=C
|
|
67
|
+
|
|
68
|
+
[[ "$path" == /* && ! "$path" =~ [[:cntrl:]] ]] || return 1
|
|
69
|
+
rest="${path#/}"
|
|
70
|
+
while [[ -n "$rest" ]]; do
|
|
71
|
+
if [[ "$rest" == */* ]]; then
|
|
72
|
+
component="${rest%%/*}"
|
|
73
|
+
rest="${rest#*/}"
|
|
74
|
+
else
|
|
75
|
+
component="$rest"
|
|
76
|
+
rest=""
|
|
77
|
+
fi
|
|
78
|
+
case "$component" in
|
|
79
|
+
'' | .) continue ;;
|
|
80
|
+
..) return 1 ;;
|
|
81
|
+
esac
|
|
82
|
+
if [[ "$current" == / ]]; then
|
|
83
|
+
current="/$component"
|
|
84
|
+
else
|
|
85
|
+
current="$current/$component"
|
|
86
|
+
fi
|
|
87
|
+
[[ ! -L "$current" ]] || return 1
|
|
88
|
+
normalized="$current"
|
|
89
|
+
done
|
|
90
|
+
BOOTSTRAP_NORMALIZED="${normalized:-/}"
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
bootstrap_fail() {
|
|
94
|
+
printf '%s\n' 'ERROR: sandbox preflight validation failed.' >&2
|
|
95
|
+
exit 2
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
BOOTSTRAP_ROOT="${PANTHEON_SANDBOX_ROOT:-${HOME:-}/pantheon-sandbox}"
|
|
99
|
+
bootstrap_normalize_path "$BOOTSTRAP_ROOT" || bootstrap_fail
|
|
100
|
+
SANDBOX_ROOT="$BOOTSTRAP_NORMALIZED"
|
|
101
|
+
[[ "$SANDBOX_ROOT" != / ]] || bootstrap_fail
|
|
102
|
+
|
|
103
|
+
BOOTSTRAP_ENTRY="${BASH_SOURCE[0]}"
|
|
104
|
+
if [[ "$BOOTSTRAP_ENTRY" != /* ]]; then
|
|
105
|
+
BOOTSTRAP_ENTRY="$PWD/$BOOTSTRAP_ENTRY"
|
|
106
|
+
fi
|
|
107
|
+
bootstrap_normalize_path "$BOOTSTRAP_ENTRY" || bootstrap_fail
|
|
108
|
+
BOOTSTRAP_ENTRY="$BOOTSTRAP_NORMALIZED"
|
|
109
|
+
[[ -f "$BOOTSTRAP_ENTRY" && ! -L "$BOOTSTRAP_ENTRY" ]] || bootstrap_fail
|
|
110
|
+
SCRIPT_DIR="${BOOTSTRAP_ENTRY%/*}"
|
|
111
|
+
[[ "${SCRIPT_DIR##*/}" == scripts \
|
|
112
|
+
&& "${BOOTSTRAP_ENTRY##*/}" == test-opencode-v2-sandbox.sh ]] || bootstrap_fail
|
|
113
|
+
|
|
114
|
+
SANDBOX_ENV_HELPER="$SCRIPT_DIR/sandbox-env.sh"
|
|
115
|
+
bootstrap_normalize_path "$SANDBOX_ENV_HELPER" || bootstrap_fail
|
|
116
|
+
[[ "$BOOTSTRAP_NORMALIZED" == "$SANDBOX_ENV_HELPER" \
|
|
117
|
+
&& -f "$SANDBOX_ENV_HELPER" && ! -L "$SANDBOX_ENV_HELPER" ]] || bootstrap_fail
|
|
118
|
+
|
|
119
|
+
source "$SANDBOX_ENV_HELPER"
|
|
120
|
+
pantheon_validate_sandbox_root "$SANDBOX_ROOT" || exit 2
|
|
59
121
|
# Derived from this script's own location so the sandbox is always built from
|
|
60
122
|
# the checkout that CONTAINS this harness. It must never be inferred from a
|
|
61
123
|
# sibling directory: a sibling may be a different checkout (or a different
|
|
62
124
|
# branch) with unrelated uncommitted work, and --prepare runs `npm pack` inside
|
|
63
125
|
# it, writing a tarball into that tree.
|
|
64
126
|
REPO_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
|
|
65
|
-
|
|
66
|
-
SANDBOX_ROOT="${PANTHEON_SANDBOX_ROOT:-$HOME/pantheon-sandbox}"
|
|
67
127
|
SANDBOX_HOME="$SANDBOX_ROOT/home"
|
|
68
128
|
NPM_PREFIX="$SANDBOX_HOME/.npm-global"
|
|
69
129
|
|
|
@@ -137,19 +197,31 @@ sandbox_bin() { # echoes the V2 binary path; rc 1 if missing
|
|
|
137
197
|
# ── Sandbox environment isolation ─────────────────────────────────────────────
|
|
138
198
|
|
|
139
199
|
sandbox_env() {
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
200
|
+
pantheon_validate_sandbox_config_path "$SANDBOX_ROOT" "$V2_CONFIG" || return $?
|
|
201
|
+
pantheon_validate_sandbox_file_path "$SANDBOX_ROOT" "$V2_DB" || return $?
|
|
202
|
+
pantheon_sandbox_env \
|
|
203
|
+
"$SANDBOX_ROOT" \
|
|
204
|
+
"$SANDBOX_HOME" \
|
|
205
|
+
"$NPM_PREFIX" \
|
|
206
|
+
"$SANDBOX_HOME/.config/opencode/.venv" \
|
|
207
|
+
"$(dirname "$V2_CONFIG")"
|
|
148
208
|
export OPENCODE_DB="$V2_DB"
|
|
209
|
+
pantheon_validate_sandbox_file_path "$SANDBOX_ROOT" "$OPENCODE_DB" || return $?
|
|
149
210
|
export PANTHEON_V2_PORT="$V2_PORT"
|
|
150
211
|
export PORT="$V2_PORT"
|
|
151
|
-
|
|
212
|
+
pantheon_validate_sandbox_path "$SANDBOX_ROOT" || return $?
|
|
213
|
+
pantheon_validate_sandbox_config_path "$SANDBOX_ROOT" "$V2_CONFIG" || return $?
|
|
214
|
+
pantheon_validate_sandbox_file_path "$SANDBOX_ROOT" "$V2_DB" || return $?
|
|
215
|
+
pantheon_validate_sandbox_file_path "$SANDBOX_ROOT" "$OPENCODE_DB" || return $?
|
|
216
|
+
pantheon_validate_sandbox_path "$(dirname "$V2_DB")" || return $?
|
|
217
|
+
pantheon_validate_sandbox_path "$(dirname "$V2_SERVICE_STATE")" || return $?
|
|
152
218
|
mkdir -p "$SANDBOX_ROOT" "$(dirname "$V2_DB")" "$(dirname "$V2_SERVICE_STATE")"
|
|
219
|
+
pantheon_validate_sandbox_path "$SANDBOX_ROOT" || return $?
|
|
220
|
+
pantheon_validate_sandbox_config_path "$SANDBOX_ROOT" "$V2_CONFIG" || return $?
|
|
221
|
+
pantheon_validate_sandbox_file_path "$SANDBOX_ROOT" "$V2_DB" || return $?
|
|
222
|
+
pantheon_validate_sandbox_file_path "$SANDBOX_ROOT" "$OPENCODE_DB" || return $?
|
|
223
|
+
pantheon_validate_sandbox_path "$(dirname "$V2_DB")" || return $?
|
|
224
|
+
pantheon_validate_sandbox_path "$(dirname "$V2_SERVICE_STATE")" || return $?
|
|
153
225
|
}
|
|
154
226
|
|
|
155
227
|
stop_v2_service() {
|
|
@@ -157,6 +229,7 @@ stop_v2_service() {
|
|
|
157
229
|
kill "$V2_SERVER_PID" 2>/dev/null || true
|
|
158
230
|
wait "$V2_SERVER_PID" 2>/dev/null || true
|
|
159
231
|
fi
|
|
232
|
+
pantheon_validate_sandbox_path "$V2_SERVICE_STATE" || return $?
|
|
160
233
|
rm -f "$V2_SERVICE_STATE"
|
|
161
234
|
V2_SERVER_PID=""
|
|
162
235
|
}
|
|
@@ -164,23 +237,22 @@ stop_v2_service() {
|
|
|
164
237
|
print_v2_diagnostics() {
|
|
165
238
|
printf '%s\n' '--- V2 service registration ---' >&2
|
|
166
239
|
if [ -f "$V2_SERVICE_STATE" ]; then
|
|
167
|
-
|
|
168
|
-
printf '\n' >&2
|
|
240
|
+
printf '%s\n' 'service registration exists (contents omitted)' >&2
|
|
169
241
|
else
|
|
170
|
-
printf '
|
|
242
|
+
printf '%s\n' 'service registration is missing' >&2
|
|
171
243
|
fi
|
|
172
244
|
printf '%s\n' '--- V2 service log ---' >&2
|
|
173
245
|
if [ -f "$V2_SERVER_LOG" ]; then
|
|
174
|
-
|
|
246
|
+
printf '%s\n' 'service log exists (contents omitted)' >&2
|
|
175
247
|
else
|
|
176
|
-
printf '
|
|
248
|
+
printf '%s\n' 'service log is missing' >&2
|
|
177
249
|
fi
|
|
178
|
-
local runtime_log="$
|
|
250
|
+
local runtime_log="$LOG_PATH"
|
|
179
251
|
printf '%s\n' '--- OpenCode runtime log ---' >&2
|
|
180
252
|
if [ -f "$runtime_log" ]; then
|
|
181
|
-
|
|
253
|
+
printf '%s\n' 'runtime log exists (contents omitted)' >&2
|
|
182
254
|
else
|
|
183
|
-
printf '
|
|
255
|
+
printf '%s\n' 'runtime log is missing' >&2
|
|
184
256
|
fi
|
|
185
257
|
}
|
|
186
258
|
|
|
@@ -224,8 +296,7 @@ PY
|
|
|
224
296
|
fi
|
|
225
297
|
sleep 1
|
|
226
298
|
done
|
|
227
|
-
printf '
|
|
228
|
-
"$V2_HANDSHAKE_TIMEOUT" "$registration_url" "$registration_pid" >&2
|
|
299
|
+
printf '%s\n' 'ERROR: timed out waiting for V2 service registration.' >&2
|
|
229
300
|
print_v2_diagnostics
|
|
230
301
|
return 1
|
|
231
302
|
}
|
|
@@ -291,7 +362,7 @@ PY
|
|
|
291
362
|
}
|
|
292
363
|
|
|
293
364
|
wait_for_v2_handshakes() {
|
|
294
|
-
local runtime_log="$
|
|
365
|
+
local runtime_log="$LOG_PATH"
|
|
295
366
|
local names=(
|
|
296
367
|
pantheon-code-mode
|
|
297
368
|
pantheon-memory
|
|
@@ -337,7 +408,14 @@ wait_for_v2_handshakes() {
|
|
|
337
408
|
}
|
|
338
409
|
|
|
339
410
|
start_v2_service() { # binary project
|
|
340
|
-
local bin="$1" project="$2" ready=0 attempt
|
|
411
|
+
local bin="$1" project="$2" ready=0 attempt runtime_log
|
|
412
|
+
# Re-apply the shared environment at the actual direct-CI launch boundary;
|
|
413
|
+
# do not rely on whichever XDG variables the parent shell inherited.
|
|
414
|
+
sandbox_env || return $?
|
|
415
|
+
runtime_log="$LOG_PATH"
|
|
416
|
+
pantheon_validate_sandbox_config_path "$SANDBOX_ROOT" "$V2_CONFIG" || return $?
|
|
417
|
+
pantheon_validate_sandbox_file_path "$SANDBOX_ROOT" "$V2_DB" || return $?
|
|
418
|
+
pantheon_validate_sandbox_file_path "$SANDBOX_ROOT" "$OPENCODE_DB" || return $?
|
|
341
419
|
if [ -n "$V2_SERVER_PID" ] && kill -0 "$V2_SERVER_PID" 2>/dev/null; then
|
|
342
420
|
return 0
|
|
343
421
|
fi
|
|
@@ -350,8 +428,16 @@ start_v2_service() { # binary project
|
|
|
350
428
|
die "dedicated V2 port ${V2_PORT} is already in use; refusing to reuse an unrelated service"
|
|
351
429
|
fi
|
|
352
430
|
|
|
353
|
-
|
|
354
|
-
|
|
431
|
+
pantheon_validate_sandbox_path "$project" || return $?
|
|
432
|
+
pantheon_validate_sandbox_path "$V2_SERVER_LOG" || return $?
|
|
433
|
+
pantheon_validate_sandbox_path "$V2_SERVICE_STATE" || return $?
|
|
434
|
+
pantheon_validate_sandbox_path "$runtime_log" || return $?
|
|
435
|
+
rm -f "$V2_SERVER_LOG" "$V2_SERVICE_STATE" "$runtime_log"
|
|
436
|
+
(
|
|
437
|
+
sandbox_env || exit $?
|
|
438
|
+
cd "$project"
|
|
439
|
+
exec "$bin" serve --hostname "$V2_LOOPBACK_HOST" --port "$V2_PORT" --service
|
|
440
|
+
) \
|
|
355
441
|
>"$V2_SERVER_LOG" 2>&1 &
|
|
356
442
|
V2_SERVER_PID=$!
|
|
357
443
|
|
|
@@ -384,67 +470,174 @@ trap stop_v2_service EXIT
|
|
|
384
470
|
# ── Gate (b): sandbox run-test.sh with pantheon://agents content validation ──
|
|
385
471
|
|
|
386
472
|
write_run_test_sh() {
|
|
473
|
+
local path expected_repo_q
|
|
474
|
+
pantheon_validate_sandbox_root "$SANDBOX_ROOT" || return $?
|
|
475
|
+
for path in \
|
|
476
|
+
"$SANDBOX_ROOT/.repo-dir" \
|
|
477
|
+
"$SANDBOX_ROOT/sandbox-env.sh" \
|
|
478
|
+
"$SANDBOX_ROOT/run-test.sh" \
|
|
479
|
+
"$SANDBOX_ROOT/start-pantheon.sh"; do
|
|
480
|
+
pantheon_validate_sandbox_path "$path" || return $?
|
|
481
|
+
done
|
|
482
|
+
|
|
387
483
|
# Quoted heredoc: the body is emitted verbatim, so nothing inside is expanded
|
|
388
|
-
# at generation time.
|
|
389
|
-
#
|
|
390
|
-
#
|
|
391
|
-
# replacement text AND the double-quoted shell context it lands in), and only
|
|
392
|
-
# the first set was escaped — a path containing `$`, a backtick, a backslash
|
|
393
|
-
# or a quote was silently rewritten or executed by the generated script.
|
|
484
|
+
# at generation time. Keep the metadata file for format/integrity checking,
|
|
485
|
+
# but do not trust it as the source selector: the runner below also embeds a
|
|
486
|
+
# safely quoted expected value and requires the file to match it exactly.
|
|
394
487
|
printf '%s\n' "$REPO_DIR" > "$SANDBOX_ROOT/.repo-dir"
|
|
395
|
-
|
|
396
|
-
|
|
488
|
+
cp "$SANDBOX_ENV_HELPER" "$SANDBOX_ROOT/sandbox-env.sh"
|
|
489
|
+
# Keep a trusted copy of the generated source path in the runner. Bash's %q
|
|
490
|
+
# emits a shell word (including ANSI-C quoting when needed), so adversarial
|
|
491
|
+
# path characters cannot become code when this assignment is evaluated.
|
|
492
|
+
printf -v expected_repo_q '%q' "$REPO_DIR"
|
|
493
|
+
{
|
|
494
|
+
printf '%s\n' '#!/usr/bin/env bash'
|
|
495
|
+
printf 'EXPECTED_REPO_DIR=%s\n' "$expected_repo_q"
|
|
496
|
+
cat <<'RUNTEST'
|
|
397
497
|
# Generated by pantheon-opencode scripts/test-opencode-v2-sandbox.sh --prepare
|
|
398
498
|
# Validates the global install: the V2 binary, exactly 5 connected MCPs, doctor
|
|
399
499
|
# 0 errors, AND the CONTENT of pantheon://agents (zeus/hermes present).
|
|
400
500
|
set -euo pipefail
|
|
401
501
|
|
|
402
|
-
|
|
502
|
+
pantheon_launcher_preflight() {
|
|
503
|
+
local entrypoint="$1" current="/" component helper
|
|
504
|
+
local -a components
|
|
505
|
+
local LC_ALL=C
|
|
506
|
+
|
|
507
|
+
[[ ! "$entrypoint" =~ [[:cntrl:]] ]] || {
|
|
508
|
+
printf '%s\n' 'ERROR: sandbox launcher preflight validation failed.' >&2
|
|
509
|
+
return 2
|
|
510
|
+
}
|
|
511
|
+
if [[ "$entrypoint" != /* ]]; then entrypoint="$PWD/$entrypoint"; fi
|
|
512
|
+
IFS='/' read -r -a components <<< "$entrypoint"
|
|
513
|
+
for component in "${components[@]}"; do
|
|
514
|
+
case "$component" in
|
|
515
|
+
'' | .) continue ;;
|
|
516
|
+
..)
|
|
517
|
+
printf '%s\n' 'ERROR: sandbox launcher preflight validation failed.' >&2
|
|
518
|
+
return 2
|
|
519
|
+
;;
|
|
520
|
+
esac
|
|
521
|
+
if [[ "$current" == / ]]; then
|
|
522
|
+
current="/$component"
|
|
523
|
+
else
|
|
524
|
+
current="$current/$component"
|
|
525
|
+
fi
|
|
526
|
+
if [[ -L "$current" ]]; then
|
|
527
|
+
printf '%s\n' 'ERROR: sandbox launcher preflight validation failed.' >&2
|
|
528
|
+
return 2
|
|
529
|
+
fi
|
|
530
|
+
done
|
|
531
|
+
|
|
532
|
+
if [[ ! -f "$current" || -L "$current" ]]; then
|
|
533
|
+
printf '%s\n' 'ERROR: sandbox launcher preflight validation failed.' >&2
|
|
534
|
+
return 2
|
|
535
|
+
fi
|
|
536
|
+
SANDBOX_DIR="${current%/*}"
|
|
537
|
+
[[ -n "$SANDBOX_DIR" ]] || SANDBOX_DIR=/
|
|
538
|
+
if [[ "$SANDBOX_DIR" == / ]]; then
|
|
539
|
+
printf '%s\n' 'ERROR: sandbox launcher preflight validation failed.' >&2
|
|
540
|
+
return 2
|
|
541
|
+
fi
|
|
542
|
+
helper="$SANDBOX_DIR/sandbox-env.sh"
|
|
543
|
+
if [[ ! -f "$helper" || -L "$helper" ]]; then
|
|
544
|
+
printf '%s\n' 'ERROR: sandbox launcher preflight validation failed.' >&2
|
|
545
|
+
return 2
|
|
546
|
+
fi
|
|
547
|
+
SANDBOX_ENV_HELPER="$helper"
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
pantheon_launcher_preflight "$0" || exit $?
|
|
551
|
+
source "$SANDBOX_ENV_HELPER"
|
|
552
|
+
pantheon_validate_sandbox_root "$SANDBOX_DIR" || exit $?
|
|
403
553
|
SANDBOX_HOME="$SANDBOX_DIR/home"
|
|
404
554
|
NPM_PREFIX="$SANDBOX_HOME/.npm-global"
|
|
405
555
|
PANTHEON_GLOBAL="$SANDBOX_HOME/.config/opencode"
|
|
406
556
|
SANDBOX_VENV="$PANTHEON_GLOBAL/.venv"
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
#
|
|
412
|
-
#
|
|
413
|
-
#
|
|
414
|
-
#
|
|
415
|
-
|
|
557
|
+
V2_CONFIG="${PANTHEON_V2_CONFIG:-$SANDBOX_DIR/project-v2/opencode.json}"
|
|
558
|
+
V2_DB="${PANTHEON_V2_DB:-$SANDBOX_DIR/opencode-v2.db}"
|
|
559
|
+
pantheon_validate_sandbox_config_path "$SANDBOX_DIR" "$V2_CONFIG" || exit $?
|
|
560
|
+
pantheon_validate_sandbox_file_path "$SANDBOX_DIR" "$V2_DB" || exit $?
|
|
561
|
+
# Validate the generated metadata against the trusted path embedded above before
|
|
562
|
+
# using it. Python opens with O_NOFOLLOW and verifies the complete byte stream,
|
|
563
|
+
# avoiding both symlink traversal and shell-read quirks such as ignored NULs.
|
|
564
|
+
# Keep diagnostics value-free: failed opens and validation details are hidden.
|
|
565
|
+
if ! python3 - "$SANDBOX_DIR/.repo-dir" "$EXPECTED_REPO_DIR" 2>/dev/null <<'CHECK_REPO_METADATA'
|
|
566
|
+
import os
|
|
567
|
+
import stat
|
|
568
|
+
import sys
|
|
569
|
+
|
|
570
|
+
metadata_path, expected_text = sys.argv[1:]
|
|
571
|
+
expected = os.fsencode(expected_text)
|
|
572
|
+
if not os.path.isabs(expected) or any(byte < 0x20 or byte == 0x7f for byte in expected):
|
|
573
|
+
raise SystemExit(1)
|
|
574
|
+
no_follow = getattr(os, "O_NOFOLLOW", None)
|
|
575
|
+
if no_follow is None:
|
|
576
|
+
raise SystemExit(1)
|
|
577
|
+
try:
|
|
578
|
+
if not stat.S_ISREG(os.stat(metadata_path, follow_symlinks=False).st_mode):
|
|
579
|
+
raise SystemExit(1)
|
|
580
|
+
descriptor = os.open(metadata_path, os.O_RDONLY | no_follow | os.O_NONBLOCK)
|
|
581
|
+
try:
|
|
582
|
+
if not stat.S_ISREG(os.fstat(descriptor).st_mode):
|
|
583
|
+
raise SystemExit(1)
|
|
584
|
+
content = os.read(descriptor, len(expected) + 2)
|
|
585
|
+
if content != expected + b"\n" or os.read(descriptor, 1):
|
|
586
|
+
raise SystemExit(1)
|
|
587
|
+
finally:
|
|
588
|
+
os.close(descriptor)
|
|
589
|
+
if not os.path.isdir(os.fsdecode(expected)):
|
|
590
|
+
raise SystemExit(1)
|
|
591
|
+
except OSError:
|
|
592
|
+
raise SystemExit(1)
|
|
593
|
+
CHECK_REPO_METADATA
|
|
594
|
+
then
|
|
595
|
+
printf '%s\n' 'ERROR: sandbox repository metadata validation failed.' >&2
|
|
596
|
+
exit 2
|
|
597
|
+
fi
|
|
598
|
+
REPO_DIR="${PANTHEON_REPO:-$EXPECTED_REPO_DIR}"
|
|
416
599
|
|
|
417
600
|
echo "=== Pantheon Sandbox Test (OpenCode V2) ==="
|
|
418
|
-
echo "Sandbox: $SANDBOX_DIR"
|
|
419
|
-
echo "Repo: $REPO_DIR"
|
|
420
601
|
|
|
421
|
-
export HOME="$SANDBOX_HOME"
|
|
422
|
-
export PATH="$NPM_PREFIX/bin:$SANDBOX_VENV/bin:$PATH"
|
|
423
|
-
export npm_config_prefix="$NPM_PREFIX"
|
|
424
|
-
export XDG_STATE_HOME="$SANDBOX_HOME/.local/state"
|
|
425
602
|
# The V2 CLI resolves `mcp list` through its service. Keep generated sandbox
|
|
426
603
|
# runs isolated from any config/database/port inherited from the host.
|
|
427
|
-
V2_CONFIG="$SANDBOX_DIR/project-v2/opencode.json"
|
|
428
|
-
V2_DB="${PANTHEON_V2_DB:-$SANDBOX_DIR/opencode-v2.db}"
|
|
429
604
|
V2_PORT="${PANTHEON_V2_PORT:-49376}"
|
|
430
605
|
V2_LOOPBACK_HOST="${PANTHEON_V2_HOST:-127.0.0.1}"
|
|
431
606
|
V2_HANDSHAKE_TIMEOUT="${PANTHEON_V2_HANDSHAKE_TIMEOUT:-60}"
|
|
432
607
|
V2_MCP_LIST_TIMEOUT="${PANTHEON_V2_MCP_LIST_TIMEOUT:-15}"
|
|
608
|
+
pantheon_validate_sandbox_config_path "$SANDBOX_DIR" "$V2_CONFIG" || exit $?
|
|
609
|
+
pantheon_validate_sandbox_file_path "$SANDBOX_DIR" "$V2_DB" || exit $?
|
|
610
|
+
pantheon_sandbox_env \
|
|
611
|
+
"$SANDBOX_DIR" \
|
|
612
|
+
"$SANDBOX_HOME" \
|
|
613
|
+
"$NPM_PREFIX" \
|
|
614
|
+
"$SANDBOX_VENV" \
|
|
615
|
+
"$(dirname "$V2_CONFIG")"
|
|
616
|
+
pantheon_validate_sandbox_config_path "$SANDBOX_DIR" "$V2_CONFIG" || exit $?
|
|
617
|
+
pantheon_validate_sandbox_file_path "$SANDBOX_DIR" "$V2_DB" || exit $?
|
|
433
618
|
V2_SERVER_LOG="$SANDBOX_DIR/v2-server.log"
|
|
434
619
|
V2_SERVICE_STATE="$SANDBOX_HOME/.local/state/opencode/service.json"
|
|
435
620
|
V2_SERVER_PID=""
|
|
436
|
-
export OPENCODE_CONFIG_DIR="$(dirname "$V2_CONFIG")"
|
|
437
621
|
export OPENCODE_DB="$V2_DB"
|
|
622
|
+
pantheon_validate_sandbox_file_path "$SANDBOX_DIR" "$OPENCODE_DB" || exit $?
|
|
438
623
|
export PANTHEON_V2_PORT="$V2_PORT"
|
|
439
624
|
export PORT="$V2_PORT"
|
|
440
625
|
unset OPENCODE_CONFIG OPENCODE_CONFIG_CONTENT OPENCODE_CONFIG_PROJECT_DISABLE
|
|
626
|
+
pantheon_validate_sandbox_path "$V2_SERVICE_STATE" || exit $?
|
|
627
|
+
pantheon_validate_sandbox_path "$(dirname "$V2_SERVICE_STATE")" || exit $?
|
|
441
628
|
mkdir -p "$(dirname "$V2_SERVICE_STATE")"
|
|
629
|
+
pantheon_validate_sandbox_config_path "$SANDBOX_DIR" "$V2_CONFIG" || exit $?
|
|
630
|
+
pantheon_validate_sandbox_file_path "$SANDBOX_DIR" "$V2_DB" || exit $?
|
|
631
|
+
pantheon_validate_sandbox_file_path "$SANDBOX_DIR" "$OPENCODE_DB" || exit $?
|
|
632
|
+
pantheon_validate_sandbox_path "$V2_SERVICE_STATE" || exit $?
|
|
633
|
+
pantheon_validate_sandbox_path "$(dirname "$V2_SERVICE_STATE")" || exit $?
|
|
442
634
|
|
|
443
635
|
stop_v2_service() {
|
|
444
636
|
if [ -n "$V2_SERVER_PID" ] && kill -0 "$V2_SERVER_PID" 2>/dev/null; then
|
|
445
637
|
kill "$V2_SERVER_PID" 2>/dev/null || true
|
|
446
638
|
wait "$V2_SERVER_PID" 2>/dev/null || true
|
|
447
639
|
fi
|
|
640
|
+
pantheon_validate_sandbox_path "$V2_SERVICE_STATE" || return $?
|
|
448
641
|
rm -f "$V2_SERVICE_STATE"
|
|
449
642
|
V2_SERVER_PID=""
|
|
450
643
|
}
|
|
@@ -452,16 +645,24 @@ stop_v2_service() {
|
|
|
452
645
|
print_v2_diagnostics() {
|
|
453
646
|
printf '%s\n' '--- V2 service registration ---' >&2
|
|
454
647
|
if [ -f "$V2_SERVICE_STATE" ]; then
|
|
455
|
-
|
|
456
|
-
printf '\n' >&2
|
|
648
|
+
printf '%s\n' 'service registration exists (contents omitted)' >&2
|
|
457
649
|
else
|
|
458
|
-
printf '
|
|
650
|
+
printf '%s\n' 'service registration is missing' >&2
|
|
459
651
|
fi
|
|
460
652
|
printf '%s\n' '--- V2 service log ---' >&2
|
|
461
|
-
[ -f "$V2_SERVER_LOG" ]
|
|
462
|
-
|
|
653
|
+
if [ -f "$V2_SERVER_LOG" ]; then
|
|
654
|
+
printf '%s\n' 'service log exists (contents omitted)' >&2
|
|
655
|
+
else
|
|
656
|
+
printf '%s\n' 'service log is missing' >&2
|
|
657
|
+
fi
|
|
658
|
+
local runtime_log
|
|
659
|
+
runtime_log="$LOG_PATH"
|
|
463
660
|
printf '%s\n' '--- OpenCode runtime log ---' >&2
|
|
464
|
-
[ -f "$runtime_log" ]
|
|
661
|
+
if [ -f "$runtime_log" ]; then
|
|
662
|
+
printf '%s\n' 'runtime log exists (contents omitted)' >&2
|
|
663
|
+
else
|
|
664
|
+
printf '%s\n' 'runtime log is missing' >&2
|
|
665
|
+
fi
|
|
465
666
|
}
|
|
466
667
|
|
|
467
668
|
wait_for_v2_service_registration() {
|
|
@@ -502,8 +703,7 @@ PY
|
|
|
502
703
|
fi
|
|
503
704
|
sleep 1
|
|
504
705
|
done
|
|
505
|
-
printf 'ERROR: timed out
|
|
506
|
-
"$V2_HANDSHAKE_TIMEOUT" "$registration_url" "$registration_pid" >&2
|
|
706
|
+
printf '%s\n' 'ERROR: timed out waiting for V2 service registration.' >&2
|
|
507
707
|
print_v2_diagnostics
|
|
508
708
|
return 1
|
|
509
709
|
}
|
|
@@ -566,7 +766,10 @@ PY
|
|
|
566
766
|
}
|
|
567
767
|
|
|
568
768
|
start_v2_service() {
|
|
569
|
-
local bin="$1" project="$2" attempt ready=0
|
|
769
|
+
local bin="$1" project="$2" attempt ready=0 runtime_log
|
|
770
|
+
pantheon_validate_sandbox_config_path "$SANDBOX_DIR" "$V2_CONFIG" || return $?
|
|
771
|
+
pantheon_validate_sandbox_file_path "$SANDBOX_DIR" "$V2_DB" || return $?
|
|
772
|
+
pantheon_validate_sandbox_file_path "$SANDBOX_DIR" "$OPENCODE_DB" || return $?
|
|
570
773
|
if [ -n "$V2_SERVER_PID" ] && kill -0 "$V2_SERVER_PID" 2>/dev/null; then
|
|
571
774
|
return 0
|
|
572
775
|
fi
|
|
@@ -575,7 +778,12 @@ start_v2_service() {
|
|
|
575
778
|
echo "ERROR: dedicated V2 port $V2_PORT is already in use" >&2
|
|
576
779
|
return 1
|
|
577
780
|
fi
|
|
578
|
-
|
|
781
|
+
runtime_log="$LOG_PATH"
|
|
782
|
+
pantheon_validate_sandbox_path "$project" || return $?
|
|
783
|
+
pantheon_validate_sandbox_path "$V2_SERVER_LOG" || return $?
|
|
784
|
+
pantheon_validate_sandbox_path "$V2_SERVICE_STATE" || return $?
|
|
785
|
+
pantheon_validate_sandbox_path "$runtime_log" || return $?
|
|
786
|
+
rm -f "$V2_SERVER_LOG" "$V2_SERVICE_STATE" "$runtime_log"
|
|
579
787
|
(cd "$project" && "$bin" serve --hostname "$V2_LOOPBACK_HOST" --port "$V2_PORT" --service) \
|
|
580
788
|
>"$V2_SERVER_LOG" 2>&1 &
|
|
581
789
|
V2_SERVER_PID=$!
|
|
@@ -603,7 +811,8 @@ start_v2_service() {
|
|
|
603
811
|
}
|
|
604
812
|
|
|
605
813
|
wait_for_v2_handshakes() {
|
|
606
|
-
local runtime_log
|
|
814
|
+
local runtime_log
|
|
815
|
+
runtime_log="$LOG_PATH"
|
|
607
816
|
local names=(pantheon-code-mode pantheon-memory pantheon-persistence pantheon-resources pantheon-vision)
|
|
608
817
|
local attempt name ready connected_names connected_count
|
|
609
818
|
for attempt in $(seq 1 "$V2_HANDSHAKE_TIMEOUT"); do
|
|
@@ -642,8 +851,9 @@ rewrite_v2_mcp_config() {
|
|
|
642
851
|
local config_path="$V2_CONFIG"
|
|
643
852
|
local runtime_dir="$SANDBOX_DIR/project-v2/.opencode"
|
|
644
853
|
local python_bin="$SANDBOX_DIR/project-v2/.venv/bin/python3"
|
|
645
|
-
|
|
646
|
-
[ -
|
|
854
|
+
pantheon_validate_sandbox_file_path "$SANDBOX_DIR" "$config_path" || return $?
|
|
855
|
+
[ -f "$config_path" ] || { echo 'ERROR: sandbox config is unavailable.' >&2; return 1; }
|
|
856
|
+
[ -x "$python_bin" ] || { echo 'ERROR: sandbox MCP runtime is unavailable.' >&2; return 1; }
|
|
647
857
|
CONFIG_PATH="$config_path" RUNTIME_DIR="$runtime_dir" MCP_PYTHON="$python_bin" \
|
|
648
858
|
python3 - <<'PY'
|
|
649
859
|
import json
|
|
@@ -662,29 +872,44 @@ managed = {
|
|
|
662
872
|
}
|
|
663
873
|
try:
|
|
664
874
|
config = json.loads(config_path.read_text(encoding="utf-8"))
|
|
665
|
-
except (OSError, json.JSONDecodeError)
|
|
666
|
-
raise SystemExit(
|
|
875
|
+
except (OSError, json.JSONDecodeError):
|
|
876
|
+
raise SystemExit("ERROR: sandbox config validation failed.") from None
|
|
667
877
|
if not isinstance(config, dict):
|
|
668
|
-
raise SystemExit(
|
|
878
|
+
raise SystemExit("ERROR: sandbox config validation failed.")
|
|
669
879
|
mcp = config.setdefault("mcp", {})
|
|
670
880
|
if not isinstance(mcp, dict):
|
|
671
|
-
raise SystemExit("
|
|
881
|
+
raise SystemExit("ERROR: sandbox config validation failed.")
|
|
882
|
+
servers = mcp.setdefault("servers", {})
|
|
883
|
+
if not isinstance(servers, dict):
|
|
884
|
+
raise SystemExit("ERROR: sandbox config validation failed.")
|
|
672
885
|
for name, script in managed.items():
|
|
673
|
-
entry =
|
|
886
|
+
entry = servers.get(name) if isinstance(servers.get(name), dict) else {}
|
|
674
887
|
entry.pop("disabled", None)
|
|
675
888
|
entry.update(type="local", cwd=runtime_dir, command=[python_bin, f"scripts/{script}"], enabled=True)
|
|
676
|
-
|
|
889
|
+
servers[name] = entry
|
|
677
890
|
tmp_path = config_path.with_name(config_path.name + ".sandbox-tmp")
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
891
|
+
try:
|
|
892
|
+
tmp_path.write_text(json.dumps(config, indent=2) + "\n", encoding="utf-8")
|
|
893
|
+
os.replace(tmp_path, config_path)
|
|
894
|
+
except OSError:
|
|
895
|
+
try:
|
|
896
|
+
tmp_path.unlink()
|
|
897
|
+
except OSError:
|
|
898
|
+
pass
|
|
899
|
+
raise SystemExit("ERROR: sandbox config validation failed.") from None
|
|
900
|
+
try:
|
|
901
|
+
validated = json.loads(config_path.read_text(encoding="utf-8"))
|
|
902
|
+
except (OSError, json.JSONDecodeError):
|
|
903
|
+
raise SystemExit("ERROR: sandbox config validation failed.") from None
|
|
904
|
+
if not isinstance(validated, dict):
|
|
905
|
+
raise SystemExit("ERROR: sandbox config validation failed.")
|
|
681
906
|
for name, script in managed.items():
|
|
682
|
-
entry = validated.get("mcp", {}).get(name)
|
|
907
|
+
entry = validated.get("mcp", {}).get("servers", {}).get(name)
|
|
683
908
|
expected = {"type": "local", "cwd": runtime_dir, "command": [python_bin, f"scripts/{script}"], "enabled": True}
|
|
684
909
|
if not isinstance(entry, dict) or any(entry.get(key) != value for key, value in expected.items()):
|
|
685
|
-
raise SystemExit(
|
|
910
|
+
raise SystemExit("ERROR: sandbox MCP validation failed.")
|
|
686
911
|
if not Path(entry["cwd"]).is_dir() or not Path(entry["command"][0]).is_file() or not (Path(entry["cwd"]) / entry["command"][1]).is_file():
|
|
687
|
-
raise SystemExit(
|
|
912
|
+
raise SystemExit("ERROR: sandbox MCP validation failed.")
|
|
688
913
|
PY
|
|
689
914
|
}
|
|
690
915
|
|
|
@@ -724,11 +949,11 @@ check_mcp() { # label binary project
|
|
|
724
949
|
local label="$1" bin="$2" project="$3" out connected_count rc=0 list_file list_pid
|
|
725
950
|
local final_file final_pid final_rc final_count
|
|
726
951
|
if ! command -v "$bin" >/dev/null 2>&1; then
|
|
727
|
-
record_status "$label MCP" "FAIL" "
|
|
952
|
+
record_status "$label MCP" "FAIL" "MCP connectivity check failed"
|
|
728
953
|
return 0
|
|
729
954
|
fi
|
|
730
955
|
if [ ! -d "$project" ]; then
|
|
731
|
-
record_status "$label MCP" "FAIL" "
|
|
956
|
+
record_status "$label MCP" "FAIL" "MCP connectivity check failed"
|
|
732
957
|
return 0
|
|
733
958
|
fi
|
|
734
959
|
if ! start_v2_service "$bin" "$project"; then
|
|
@@ -747,9 +972,8 @@ check_mcp() { # label binary project
|
|
|
747
972
|
if ! wait_for_v2_mcp_registrations "$project/.opencode" "$project/.venv/bin/python3"; then
|
|
748
973
|
kill "$list_pid" 2>/dev/null || true
|
|
749
974
|
wait "$list_pid" 2>/dev/null || true
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
record_status "$label MCP" "FAIL" "MCP registrations did not match the active sandbox"
|
|
975
|
+
rm -f "$list_file"
|
|
976
|
+
record_status "$label MCP" "FAIL" "MCP registration check failed"
|
|
753
977
|
return 0
|
|
754
978
|
fi
|
|
755
979
|
if wait_for_v2_handshakes; then
|
|
@@ -757,9 +981,8 @@ check_mcp() { # label binary project
|
|
|
757
981
|
else
|
|
758
982
|
kill "$list_pid" 2>/dev/null || true
|
|
759
983
|
wait "$list_pid" 2>/dev/null || true
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
record_status "$label MCP" "FAIL" "MCP handshakes did not become ready after mcp list started"
|
|
984
|
+
rm -f "$list_file"
|
|
985
|
+
record_status "$label MCP" "FAIL" "MCP connectivity check failed"
|
|
763
986
|
return 0
|
|
764
987
|
fi
|
|
765
988
|
if wait "$list_pid"; then
|
|
@@ -767,7 +990,7 @@ check_mcp() { # label binary project
|
|
|
767
990
|
else
|
|
768
991
|
rc=$?
|
|
769
992
|
fi
|
|
770
|
-
out="$(cat "$list_file")"
|
|
993
|
+
out="$(cat "$list_file" 2>/dev/null || true)"
|
|
771
994
|
rm -f "$list_file"
|
|
772
995
|
connected_count="$(printf '%s' "$out" | grep -Eic '(^|[^[:alnum:]_])connected([^[:alnum:]_]|$)' || true)"
|
|
773
996
|
if [ "$rc" -eq 0 ] && [ "$connected_count" -ne 5 ]; then
|
|
@@ -783,16 +1006,15 @@ check_mcp() { # label binary project
|
|
|
783
1006
|
else
|
|
784
1007
|
final_rc=$?
|
|
785
1008
|
fi
|
|
786
|
-
out="$(cat "$final_file")"
|
|
1009
|
+
out="$(cat "$final_file" 2>/dev/null || true)"
|
|
787
1010
|
rm -f "$final_file"
|
|
788
1011
|
if [ "$final_rc" -ne 0 ]; then
|
|
789
1012
|
rc="$final_rc"
|
|
790
1013
|
fi
|
|
791
1014
|
fi
|
|
792
1015
|
out="$(printf '%s' "$out" | sed -E $'s/\x1B\\[[0-?]*[ -/]*[@-~]//g')"
|
|
793
|
-
printf '%s\n' "$out"
|
|
794
1016
|
if [ "$rc" -ne 0 ]; then
|
|
795
|
-
record_status "$label MCP" "FAIL" "
|
|
1017
|
+
record_status "$label MCP" "FAIL" "MCP connectivity check failed"
|
|
796
1018
|
return 0
|
|
797
1019
|
fi
|
|
798
1020
|
connected_count="$(printf '%s' "$out" | grep -Eic '(^|[^[:alnum:]_])connected([^[:alnum:]_]|$)')" || connected_count=0
|
|
@@ -805,7 +1027,7 @@ check_mcp() { # label binary project
|
|
|
805
1027
|
&& printf '%s' "$out" | grep -Fq 'pantheon-vision'; then
|
|
806
1028
|
record_status "$label MCP" "PASS" "exactly 5 connected MCPs"
|
|
807
1029
|
else
|
|
808
|
-
record_status "$label MCP" "FAIL" "
|
|
1030
|
+
record_status "$label MCP" "FAIL" "MCP connectivity check failed"
|
|
809
1031
|
fi
|
|
810
1032
|
}
|
|
811
1033
|
|
|
@@ -823,11 +1045,15 @@ if ! git -C "$REPO_DIR" ls-files --error-unmatch -- "$TGZ" >/dev/null 2>&1; then
|
|
|
823
1045
|
echo "--- Init (headless) ---"
|
|
824
1046
|
pantheon-opencode init --headless -y
|
|
825
1047
|
rewrite_v2_mcp_config
|
|
826
|
-
node "$REPO_DIR/scripts/validate-sandbox-install.mjs" \
|
|
1048
|
+
if ! node "$REPO_DIR/scripts/validate-sandbox-install.mjs" \
|
|
827
1049
|
--repo "$REPO_DIR" \
|
|
828
1050
|
--install "$NPM_PREFIX/lib/node_modules/pantheon-opencode" \
|
|
829
1051
|
--project-config "$V2_CONFIG" \
|
|
830
|
-
--config "$PANTHEON_GLOBAL/opencode.json"
|
|
1052
|
+
--config "$PANTHEON_GLOBAL/opencode.json" \
|
|
1053
|
+
>/dev/null 2>&1; then
|
|
1054
|
+
echo 'ERROR: sandbox package/config validation failed.' >&2
|
|
1055
|
+
exit 1
|
|
1056
|
+
fi
|
|
831
1057
|
|
|
832
1058
|
echo "--- MCP Validation ---"
|
|
833
1059
|
check_mcp "V2" opencode2 "$SANDBOX_DIR/project-v2"
|
|
@@ -850,7 +1076,7 @@ fi
|
|
|
850
1076
|
echo "--- Gate (b): pantheon://agents CONTENT check ---"
|
|
851
1077
|
RESOURCES_SRV="$PANTHEON_GLOBAL/scripts/mcp_resources.py"
|
|
852
1078
|
if [ ! -f "$RESOURCES_SRV" ]; then
|
|
853
|
-
record_status "pantheon://agents resource" "FAIL" "resources server
|
|
1079
|
+
record_status "pantheon://agents resource" "FAIL" "resources server is unavailable"
|
|
854
1080
|
else
|
|
855
1081
|
set +e
|
|
856
1082
|
AGENTS_CONTENT="$("$SANDBOX_VENV/bin/python" - "$RESOURCES_SRV" <<'PYEOF'
|
|
@@ -889,6 +1115,8 @@ if [ "$FINAL_VERDICT" != "PASS" ]; then
|
|
|
889
1115
|
fi
|
|
890
1116
|
echo "Next: open the isolated TUI with: $SANDBOX_DIR/start-pantheon.sh"
|
|
891
1117
|
RUNTEST
|
|
1118
|
+
} > "$SANDBOX_ROOT/run-test.sh"
|
|
1119
|
+
pantheon_validate_sandbox_path "$SANDBOX_ROOT/run-test.sh" || return $?
|
|
892
1120
|
chmod +x "$SANDBOX_ROOT/run-test.sh"
|
|
893
1121
|
|
|
894
1122
|
cat > "$SANDBOX_ROOT/start-pantheon.sh" <<'STARTPANTHEON'
|
|
@@ -897,20 +1125,82 @@ RUNTEST
|
|
|
897
1125
|
# Launches the installed OpenCode beta with only this sandbox's HOME/config/db.
|
|
898
1126
|
set -euo pipefail
|
|
899
1127
|
|
|
900
|
-
|
|
1128
|
+
pantheon_launcher_preflight() {
|
|
1129
|
+
local entrypoint="$1" current="/" component helper
|
|
1130
|
+
local -a components
|
|
1131
|
+
local LC_ALL=C
|
|
1132
|
+
|
|
1133
|
+
[[ ! "$entrypoint" =~ [[:cntrl:]] ]] || {
|
|
1134
|
+
printf '%s\n' 'ERROR: sandbox launcher preflight validation failed.' >&2
|
|
1135
|
+
return 2
|
|
1136
|
+
}
|
|
1137
|
+
if [[ "$entrypoint" != /* ]]; then entrypoint="$PWD/$entrypoint"; fi
|
|
1138
|
+
IFS='/' read -r -a components <<< "$entrypoint"
|
|
1139
|
+
for component in "${components[@]}"; do
|
|
1140
|
+
case "$component" in
|
|
1141
|
+
'' | .) continue ;;
|
|
1142
|
+
..)
|
|
1143
|
+
printf '%s\n' 'ERROR: sandbox launcher preflight validation failed.' >&2
|
|
1144
|
+
return 2
|
|
1145
|
+
;;
|
|
1146
|
+
esac
|
|
1147
|
+
if [[ "$current" == / ]]; then
|
|
1148
|
+
current="/$component"
|
|
1149
|
+
else
|
|
1150
|
+
current="$current/$component"
|
|
1151
|
+
fi
|
|
1152
|
+
if [[ -L "$current" ]]; then
|
|
1153
|
+
printf '%s\n' 'ERROR: sandbox launcher preflight validation failed.' >&2
|
|
1154
|
+
return 2
|
|
1155
|
+
fi
|
|
1156
|
+
done
|
|
1157
|
+
|
|
1158
|
+
if [[ ! -f "$current" || -L "$current" ]]; then
|
|
1159
|
+
printf '%s\n' 'ERROR: sandbox launcher preflight validation failed.' >&2
|
|
1160
|
+
return 2
|
|
1161
|
+
fi
|
|
1162
|
+
SANDBOX_DIR="${current%/*}"
|
|
1163
|
+
[[ -n "$SANDBOX_DIR" ]] || SANDBOX_DIR=/
|
|
1164
|
+
if [[ "$SANDBOX_DIR" == / ]]; then
|
|
1165
|
+
printf '%s\n' 'ERROR: sandbox launcher preflight validation failed.' >&2
|
|
1166
|
+
return 2
|
|
1167
|
+
fi
|
|
1168
|
+
helper="$SANDBOX_DIR/sandbox-env.sh"
|
|
1169
|
+
if [[ ! -f "$helper" || -L "$helper" ]]; then
|
|
1170
|
+
printf '%s\n' 'ERROR: sandbox launcher preflight validation failed.' >&2
|
|
1171
|
+
return 2
|
|
1172
|
+
fi
|
|
1173
|
+
SANDBOX_ENV_HELPER="$helper"
|
|
1174
|
+
}
|
|
1175
|
+
|
|
1176
|
+
pantheon_launcher_preflight "$0" || exit $?
|
|
1177
|
+
source "$SANDBOX_ENV_HELPER"
|
|
1178
|
+
pantheon_validate_sandbox_root "$SANDBOX_DIR" || exit $?
|
|
901
1179
|
SANDBOX_HOME="$SANDBOX_DIR/home"
|
|
902
1180
|
NPM_PREFIX="$SANDBOX_HOME/.npm-global"
|
|
903
1181
|
SANDBOX_VENV="$SANDBOX_HOME/.config/opencode/.venv"
|
|
904
1182
|
V2_PORT="${PANTHEON_V2_PORT:-49376}"
|
|
1183
|
+
V2_CONFIG="${PANTHEON_V2_CONFIG:-$SANDBOX_DIR/project-v2/opencode.json}"
|
|
1184
|
+
V2_DB="${PANTHEON_V2_DB:-$SANDBOX_DIR/opencode-v2.db}"
|
|
1185
|
+
pantheon_validate_sandbox_config_path "$SANDBOX_DIR" "$V2_CONFIG" || exit $?
|
|
1186
|
+
pantheon_validate_sandbox_file_path "$SANDBOX_DIR" "$V2_DB" || exit $?
|
|
905
1187
|
if [[ ! "$V2_PORT" =~ ^[0-9]{1,5}$ ]]; then
|
|
906
|
-
echo
|
|
1188
|
+
echo 'ERROR: PANTHEON_V2_PORT must be an integer from 1 through 65535.' >&2
|
|
907
1189
|
exit 1
|
|
908
1190
|
fi
|
|
909
1191
|
V2_PORT=$((10#$V2_PORT))
|
|
910
1192
|
if [ "$V2_PORT" -lt 1 ] || [ "$V2_PORT" -gt 65535 ]; then
|
|
911
|
-
echo
|
|
1193
|
+
echo 'ERROR: PANTHEON_V2_PORT must be an integer from 1 through 65535.' >&2
|
|
912
1194
|
exit 1
|
|
913
1195
|
fi
|
|
1196
|
+
pantheon_sandbox_env \
|
|
1197
|
+
"$SANDBOX_DIR" \
|
|
1198
|
+
"$SANDBOX_HOME" \
|
|
1199
|
+
"$NPM_PREFIX" \
|
|
1200
|
+
"$SANDBOX_VENV" \
|
|
1201
|
+
"$(dirname "$V2_CONFIG")"
|
|
1202
|
+
pantheon_validate_sandbox_config_path "$SANDBOX_DIR" "$V2_CONFIG" || exit $?
|
|
1203
|
+
pantheon_validate_sandbox_file_path "$SANDBOX_DIR" "$V2_DB" || exit $?
|
|
914
1204
|
if ! python3 - "$V2_PORT" "$NPM_PREFIX" <<'CHECKPORT'
|
|
915
1205
|
import errno
|
|
916
1206
|
import os
|
|
@@ -1002,26 +1292,21 @@ then
|
|
|
1002
1292
|
exit 1
|
|
1003
1293
|
fi
|
|
1004
1294
|
|
|
1005
|
-
export
|
|
1006
|
-
|
|
1007
|
-
export npm_config_prefix="$NPM_PREFIX"
|
|
1008
|
-
export XDG_CONFIG_HOME="$SANDBOX_HOME/.config"
|
|
1009
|
-
export XDG_CONFIG_DIRS="$SANDBOX_HOME/.config/xdg"
|
|
1010
|
-
export XDG_DATA_HOME="$SANDBOX_HOME/.local/share"
|
|
1011
|
-
export XDG_DATA_DIRS="$SANDBOX_HOME/.local/share/xdg"
|
|
1012
|
-
export XDG_STATE_HOME="$SANDBOX_HOME/.local/state"
|
|
1013
|
-
export XDG_CACHE_HOME="$SANDBOX_HOME/.cache"
|
|
1014
|
-
export OPENCODE_CONFIG_DIR="$SANDBOX_DIR/project-v2"
|
|
1015
|
-
export OPENCODE_DB="${PANTHEON_V2_DB:-$SANDBOX_DIR/opencode-v2.db}"
|
|
1295
|
+
export OPENCODE_DB="$V2_DB"
|
|
1296
|
+
pantheon_validate_sandbox_file_path "$SANDBOX_DIR" "$OPENCODE_DB" || exit $?
|
|
1016
1297
|
export PANTHEON_V2_PORT="$V2_PORT"
|
|
1017
1298
|
export PORT="$PANTHEON_V2_PORT"
|
|
1018
1299
|
unset OPENCODE_CONFIG OPENCODE_CONFIG_CONTENT OPENCODE_CONFIG_PROJECT_DISABLE \
|
|
1019
1300
|
OPENCODE_DATA_DIR OPENCODE_STATE_DIR OPENCODE_CACHE_DIR OPENCODE_STORAGE_PATH
|
|
1020
1301
|
|
|
1302
|
+
pantheon_validate_sandbox_config_path "$SANDBOX_DIR" "$V2_CONFIG" || exit $?
|
|
1303
|
+
pantheon_validate_sandbox_file_path "$SANDBOX_DIR" "$V2_DB" || exit $?
|
|
1304
|
+
pantheon_validate_sandbox_path "$SANDBOX_DIR/project-v2" || exit $?
|
|
1021
1305
|
"$NPM_PREFIX/bin/opencode2" service set port "$V2_PORT"
|
|
1022
1306
|
cd "$SANDBOX_DIR/project-v2"
|
|
1023
1307
|
exec "$NPM_PREFIX/bin/opencode2" "$@"
|
|
1024
1308
|
STARTPANTHEON
|
|
1309
|
+
pantheon_validate_sandbox_path "$SANDBOX_ROOT/start-pantheon.sh" || return $?
|
|
1025
1310
|
chmod +x "$SANDBOX_ROOT/start-pantheon.sh"
|
|
1026
1311
|
}
|
|
1027
1312
|
|
|
@@ -1092,26 +1377,26 @@ cmd_reset() {
|
|
|
1092
1377
|
# generated script pack a tarball into it.
|
|
1093
1378
|
local protected canonical_root canonical_home canonical_protected
|
|
1094
1379
|
canonical_root="$(canonicalize_path "$SANDBOX_ROOT")" \
|
|
1095
|
-
|| die "refusing to reset sandbox root
|
|
1380
|
+
|| die "refusing to reset unsafe sandbox root"
|
|
1096
1381
|
canonical_home="$(canonicalize_path "$HOME")" \
|
|
1097
|
-
|| die "refusing to reset
|
|
1382
|
+
|| die "refusing to reset unsafe sandbox root"
|
|
1098
1383
|
[ "$canonical_root" != "/" ] \
|
|
1099
|
-
|| die "refusing to reset unsafe sandbox root
|
|
1384
|
+
|| die "refusing to reset unsafe sandbox root"
|
|
1100
1385
|
[ "$canonical_root" != "$canonical_home" ] \
|
|
1101
|
-
|| die "refusing to reset unsafe sandbox root
|
|
1386
|
+
|| die "refusing to reset unsafe sandbox root"
|
|
1102
1387
|
if path_is_same_or_descendant "$canonical_home" "$canonical_root"; then
|
|
1103
|
-
die "refusing to reset unsafe sandbox root
|
|
1388
|
+
die "refusing to reset unsafe sandbox root"
|
|
1104
1389
|
fi
|
|
1105
1390
|
|
|
1106
1391
|
for protected in "$REPO_DIR" "${PANTHEON_REPO:-}"; do
|
|
1107
1392
|
[ -n "$protected" ] || continue
|
|
1108
1393
|
canonical_protected="$(canonicalize_path "$protected")" \
|
|
1109
|
-
|| die "refusing to reset
|
|
1394
|
+
|| die "refusing to reset unsafe sandbox root"
|
|
1110
1395
|
if path_is_same_or_descendant "$canonical_root" "$canonical_protected"; then
|
|
1111
|
-
die "refusing to reset unsafe sandbox root
|
|
1396
|
+
die "refusing to reset unsafe sandbox root"
|
|
1112
1397
|
fi
|
|
1113
1398
|
if path_is_same_or_descendant "$canonical_protected" "$canonical_root"; then
|
|
1114
|
-
die "refusing to reset unsafe sandbox root
|
|
1399
|
+
die "refusing to reset unsafe sandbox root"
|
|
1115
1400
|
fi
|
|
1116
1401
|
done
|
|
1117
1402
|
log "Resetting sandbox: $SANDBOX_ROOT"
|
|
@@ -1123,7 +1408,7 @@ install_binaries() {
|
|
|
1123
1408
|
local tgz_path
|
|
1124
1409
|
if [ -n "$SANDBOX_TARBALL" ]; then
|
|
1125
1410
|
[ -f "$SANDBOX_TARBALL" ] \
|
|
1126
|
-
|| die "
|
|
1411
|
+
|| die "sandbox package artifact is unavailable"
|
|
1127
1412
|
tgz_path="$(cd "$(dirname "$SANDBOX_TARBALL")" && pwd)/$(basename "$SANDBOX_TARBALL")"
|
|
1128
1413
|
log "--- Installing pantheon-opencode (from supplied release tarball) ---"
|
|
1129
1414
|
else
|
|
@@ -1152,7 +1437,7 @@ prepare_project() {
|
|
|
1152
1437
|
|| die "pantheon-opencode not installed in sandbox prefix — run $0 --prepare first"
|
|
1153
1438
|
log "--- Regenerating config in $dir ---"
|
|
1154
1439
|
(cd "$dir" && "$pan" init --project --version "$TARGET_VERSION" --model "$PANTHEON_SANDBOX_MODEL" -y) \
|
|
1155
|
-
|| die "
|
|
1440
|
+
|| die "sandbox project initialization failed"
|
|
1156
1441
|
rewrite_v2_mcp_config
|
|
1157
1442
|
validate_sandbox_install
|
|
1158
1443
|
}
|
|
@@ -1164,14 +1449,14 @@ prepare_project() {
|
|
|
1164
1449
|
rewrite_v2_mcp_config() {
|
|
1165
1450
|
local runtime_dir="$(project_dir)/.opencode"
|
|
1166
1451
|
local python_bin="$(project_dir)/.venv/bin/python3"
|
|
1167
|
-
|
|
1168
|
-
[ -
|
|
1452
|
+
pantheon_validate_sandbox_config_path "$SANDBOX_ROOT" "$V2_CONFIG" || return $?
|
|
1453
|
+
[ -f "$V2_CONFIG" ] || die "sandbox config is unavailable"
|
|
1454
|
+
[ -x "$python_bin" ] || die "sandbox MCP runtime is unavailable"
|
|
1169
1455
|
|
|
1170
1456
|
CONFIG_PATH="$V2_CONFIG" RUNTIME_DIR="$runtime_dir" MCP_PYTHON="$python_bin" \
|
|
1171
1457
|
python3 - <<'PY'
|
|
1172
1458
|
import json
|
|
1173
1459
|
import os
|
|
1174
|
-
import sys
|
|
1175
1460
|
from pathlib import Path
|
|
1176
1461
|
|
|
1177
1462
|
config_path = Path(os.environ["CONFIG_PATH"])
|
|
@@ -1187,16 +1472,19 @@ managed = {
|
|
|
1187
1472
|
|
|
1188
1473
|
try:
|
|
1189
1474
|
config = json.loads(config_path.read_text(encoding="utf-8"))
|
|
1190
|
-
except (OSError, json.JSONDecodeError)
|
|
1191
|
-
raise SystemExit(
|
|
1475
|
+
except (OSError, json.JSONDecodeError):
|
|
1476
|
+
raise SystemExit("ERROR: sandbox config validation failed.") from None
|
|
1192
1477
|
if not isinstance(config, dict):
|
|
1193
|
-
raise SystemExit(
|
|
1478
|
+
raise SystemExit("ERROR: sandbox config validation failed.")
|
|
1194
1479
|
mcp = config.setdefault("mcp", {})
|
|
1195
1480
|
if not isinstance(mcp, dict):
|
|
1196
|
-
raise SystemExit("
|
|
1481
|
+
raise SystemExit("ERROR: sandbox config validation failed.")
|
|
1482
|
+
servers = mcp.setdefault("servers", {})
|
|
1483
|
+
if not isinstance(servers, dict):
|
|
1484
|
+
raise SystemExit("ERROR: sandbox config validation failed.")
|
|
1197
1485
|
|
|
1198
1486
|
for name, script in managed.items():
|
|
1199
|
-
entry =
|
|
1487
|
+
entry = servers.get(name)
|
|
1200
1488
|
if not isinstance(entry, dict):
|
|
1201
1489
|
entry = {}
|
|
1202
1490
|
# Do not retain command/cwd values from the merged config. These are the
|
|
@@ -1208,25 +1496,25 @@ for name, script in managed.items():
|
|
|
1208
1496
|
command=[python_bin, f"scripts/{script}"],
|
|
1209
1497
|
enabled=True,
|
|
1210
1498
|
)
|
|
1211
|
-
|
|
1499
|
+
servers[name] = entry
|
|
1212
1500
|
|
|
1213
1501
|
tmp_path = config_path.with_name(config_path.name + ".sandbox-tmp")
|
|
1214
1502
|
try:
|
|
1215
1503
|
tmp_path.write_text(json.dumps(config, indent=2) + "\n", encoding="utf-8")
|
|
1216
1504
|
os.replace(tmp_path, config_path)
|
|
1217
|
-
except OSError
|
|
1505
|
+
except OSError:
|
|
1218
1506
|
try:
|
|
1219
1507
|
tmp_path.unlink()
|
|
1220
1508
|
except OSError:
|
|
1221
1509
|
pass
|
|
1222
|
-
raise SystemExit(
|
|
1510
|
+
raise SystemExit("ERROR: sandbox config validation failed.") from None
|
|
1223
1511
|
|
|
1224
1512
|
try:
|
|
1225
1513
|
validated = json.loads(config_path.read_text(encoding="utf-8"))
|
|
1226
|
-
except (OSError, json.JSONDecodeError)
|
|
1227
|
-
raise SystemExit(
|
|
1514
|
+
except (OSError, json.JSONDecodeError):
|
|
1515
|
+
raise SystemExit("ERROR: sandbox config validation failed.") from None
|
|
1228
1516
|
for name, script in managed.items():
|
|
1229
|
-
entry = validated.get("mcp", {}).get(name)
|
|
1517
|
+
entry = validated.get("mcp", {}).get("servers", {}).get(name)
|
|
1230
1518
|
expected = {
|
|
1231
1519
|
"type": "local",
|
|
1232
1520
|
"cwd": runtime_dir,
|
|
@@ -1234,11 +1522,11 @@ for name, script in managed.items():
|
|
|
1234
1522
|
"enabled": True,
|
|
1235
1523
|
}
|
|
1236
1524
|
if not isinstance(entry, dict) or any(entry.get(key) != value for key, value in expected.items()):
|
|
1237
|
-
raise SystemExit(
|
|
1525
|
+
raise SystemExit("ERROR: sandbox MCP validation failed.")
|
|
1238
1526
|
if not Path(entry["cwd"]).is_dir() or not Path(entry["command"][0]).is_file():
|
|
1239
|
-
raise SystemExit(
|
|
1527
|
+
raise SystemExit("ERROR: sandbox MCP validation failed.")
|
|
1240
1528
|
if not (Path(entry["cwd"]) / entry["command"][1]).is_file():
|
|
1241
|
-
raise SystemExit(
|
|
1529
|
+
raise SystemExit("ERROR: sandbox MCP validation failed.")
|
|
1242
1530
|
PY
|
|
1243
1531
|
}
|
|
1244
1532
|
|
|
@@ -1248,13 +1536,16 @@ validate_sandbox_install() {
|
|
|
1248
1536
|
--install "$NPM_PREFIX/lib/node_modules/pantheon-opencode" \
|
|
1249
1537
|
--project-config "$V2_CONFIG" \
|
|
1250
1538
|
--config "$SANDBOX_HOME/.config/opencode/opencode.json" \
|
|
1539
|
+
>/dev/null 2>&1 \
|
|
1251
1540
|
|| die "sandbox package/config validation failed"
|
|
1252
1541
|
}
|
|
1253
1542
|
|
|
1254
1543
|
cmd_prepare() {
|
|
1544
|
+
sandbox_env
|
|
1545
|
+
pantheon_validate_sandbox_path "$NPM_PREFIX" || die "invalid sandbox path"
|
|
1255
1546
|
mkdir -p "$SANDBOX_HOME" "$NPM_PREFIX"
|
|
1547
|
+
pantheon_validate_sandbox_path "$NPM_PREFIX" || die "invalid sandbox path"
|
|
1256
1548
|
write_run_test_sh
|
|
1257
|
-
sandbox_env
|
|
1258
1549
|
install_binaries
|
|
1259
1550
|
local pan
|
|
1260
1551
|
pan="$(sandbox_bin_for "pantheon-opencode")" \
|
|
@@ -1407,10 +1698,11 @@ run_prompt() { # v idx current_bin — exactly one attempt
|
|
|
1407
1698
|
}
|
|
1408
1699
|
|
|
1409
1700
|
check_mcp_list() { # v
|
|
1410
|
-
local v="$1" bin out connected_count rc=0
|
|
1701
|
+
local v="$1" bin out connected_count rc=0
|
|
1411
1702
|
local list_file list_pid final_file final_pid final_rc
|
|
1412
1703
|
if ! bin="$(sandbox_bin)"; then
|
|
1413
|
-
|
|
1704
|
+
printf '%s\n' 'MCP connectivity check failed' >&2
|
|
1705
|
+
record "$v" "mcp-list" "FAIL" "MCP connectivity check failed"
|
|
1414
1706
|
return 0
|
|
1415
1707
|
fi
|
|
1416
1708
|
if ! start_v2_service "$bin" "$(project_dir)"; then
|
|
@@ -1428,7 +1720,8 @@ check_mcp_list() { # v
|
|
|
1428
1720
|
kill "$list_pid" 2>/dev/null || true
|
|
1429
1721
|
wait "$list_pid" 2>/dev/null || true
|
|
1430
1722
|
rm -f "$list_file"
|
|
1431
|
-
|
|
1723
|
+
printf '%s\n' 'MCP registration check failed' >&2
|
|
1724
|
+
record "$v" "mcp-list" "FAIL" "MCP registration check failed"
|
|
1432
1725
|
return 0
|
|
1433
1726
|
fi
|
|
1434
1727
|
if wait_for_v2_handshakes; then
|
|
@@ -1437,7 +1730,8 @@ check_mcp_list() { # v
|
|
|
1437
1730
|
kill "$list_pid" 2>/dev/null || true
|
|
1438
1731
|
wait "$list_pid" 2>/dev/null || true
|
|
1439
1732
|
rm -f "$list_file"
|
|
1440
|
-
|
|
1733
|
+
printf '%s\n' 'MCP connectivity check failed' >&2
|
|
1734
|
+
record "$v" "mcp-list" "FAIL" "MCP connectivity check failed"
|
|
1441
1735
|
return 0
|
|
1442
1736
|
fi
|
|
1443
1737
|
if wait "$list_pid"; then
|
|
@@ -1445,7 +1739,7 @@ check_mcp_list() { # v
|
|
|
1445
1739
|
else
|
|
1446
1740
|
rc=$?
|
|
1447
1741
|
fi
|
|
1448
|
-
out="$(cat "$list_file")"
|
|
1742
|
+
out="$(cat "$list_file" 2>/dev/null || true)"
|
|
1449
1743
|
rm -f "$list_file"
|
|
1450
1744
|
connected_count="$(printf '%s' "$out" | grep -Eic '(^|[^[:alnum:]_])connected([^[:alnum:]_]|$)' || true)"
|
|
1451
1745
|
if [ "$rc" -eq 0 ] && [ "$connected_count" -ne 5 ]; then
|
|
@@ -1461,15 +1755,13 @@ check_mcp_list() { # v
|
|
|
1461
1755
|
else
|
|
1462
1756
|
final_rc=$?
|
|
1463
1757
|
fi
|
|
1464
|
-
out="$(cat "$final_file")"
|
|
1758
|
+
out="$(cat "$final_file" 2>/dev/null || true)"
|
|
1465
1759
|
rm -f "$final_file"
|
|
1466
1760
|
if [ "$final_rc" -ne 0 ]; then
|
|
1467
1761
|
rc="$final_rc"
|
|
1468
1762
|
fi
|
|
1469
1763
|
fi
|
|
1470
1764
|
out="$(printf '%s' "$out" | sed -E $'s/\x1B\\[[0-?]*[ -/]*[@-~]//g')"
|
|
1471
|
-
last_out="$out"
|
|
1472
|
-
last_rc="$rc"
|
|
1473
1765
|
connected_count="$(printf '%s' "$out" | grep -Eic '(^|[^[:alnum:]_])connected([^[:alnum:]_]|$)' || true)"
|
|
1474
1766
|
if [ "$rc" -eq 0 ] \
|
|
1475
1767
|
&& [ "$connected_count" -eq 5 ] \
|
|
@@ -1479,18 +1771,13 @@ check_mcp_list() { # v
|
|
|
1479
1771
|
&& printf '%s' "$out" | grep -Fq 'pantheon-persistence' \
|
|
1480
1772
|
&& printf '%s' "$out" | grep -Fq 'pantheon-resources' \
|
|
1481
1773
|
&& printf '%s' "$out" | grep -Fq 'pantheon-vision'; then
|
|
1482
|
-
printf '%s\n' "$out"
|
|
1483
1774
|
record "$v" "mcp-list" "PASS" "exactly 5 connected MCPs"
|
|
1484
1775
|
return 0
|
|
1485
1776
|
fi
|
|
1486
1777
|
|
|
1487
|
-
printf '%s\n' '
|
|
1488
|
-
printf '%s\n' "$last_out" >&2
|
|
1489
|
-
printf 'mcp list exit=%s; connected=%s; expected exactly 5\n' \
|
|
1490
|
-
"$last_rc" "$connected_count" >&2
|
|
1778
|
+
printf '%s\n' 'MCP connectivity check failed' >&2
|
|
1491
1779
|
print_v2_diagnostics
|
|
1492
|
-
record "$v" "mcp-list" "FAIL"
|
|
1493
|
-
"expected exactly 5 connected MCPs; last exit $last_rc found $connected_count"
|
|
1780
|
+
record "$v" "mcp-list" "FAIL" "MCP connectivity check failed"
|
|
1494
1781
|
}
|
|
1495
1782
|
|
|
1496
1783
|
check_doctor() { # v
|