@@ -21,8 +21,6 @@ GATEWAY_CA="${AGENT_GATEWAY_DEMO_GATEWAY_CA:-$REPO_ROOT/certs/server-ca.pem}"
2121MOCK_CA=" ${AGENT_GATEWAY_DEMO_MOCK_CA:- $REPO_ROOT / certs/ mock-ca.pem} "
2222SIDECAR_BIN=" $REPO_ROOT /target/debug/agent_gateway_sidecar"
2323GATEWAY_IMAGE=" ${AGENT_GATEWAY_DEMO_GATEWAY_IMAGE:- ghcr.io/ sl5taskforce/ agent-gateway: main} "
24- VERIFY_TIMEOUT_SECONDS=" ${AGENT_GATEWAY_DEMO_VERIFY_TIMEOUT_SECONDS:- 120} "
25-
2624export COMPOSE_PROJECT_NAME
2725export AGENT_GATEWAY_DEMO_GATEWAY_IMAGE=" $GATEWAY_IMAGE "
2826
@@ -97,41 +95,46 @@ state_dir() {
9795 printf ' %s/%s\n' " $STATE_ROOT " " $HANDLE "
9896}
9997
100- print_verification_diagnostics () {
101- local sidecar_log
102- sidecar_log=" $( state_dir) /sidecar.log"
103-
104- echo " Check the gateway, sidecar, and mock service logs before retrying." >&2
105- echo " Sidecar log: $sidecar_log " >&2
106- if [[ -f " $sidecar_log " ]]; then
107- echo >&2
108- echo " Recent sidecar log lines:" >&2
109- tail -n 80 " $sidecar_log " >&2 || true
110- fi
98+ enroll () {
99+ demo_env=(
100+ " AGENT_GATEWAY_DATABASE_URL=$DATABASE_URL "
101+ " AGENT_GATEWAY_DEMO_GATEWAY=$GATEWAY "
102+ " AGENT_GATEWAY_DEMO_GATEWAY_CA=$GATEWAY_CA "
103+ " AGENT_GATEWAY_DEMO_MOCK_CA=$MOCK_CA "
104+ " AGENT_GATEWAY_DEMO_SIDECAR_BIN=$SIDECAR_BIN "
105+ " AGENT_GATEWAY_DEMO_STATE_DIR=$STATE_ROOT "
106+ " AGENT_GATEWAY_TPM_USER_PIN=$USER_PIN "
107+ " AGENT_GATEWAY_TPM_SO_PIN=$SO_PIN "
108+ " AGENT_GATEWAY_RESET_TPM_STORE=false"
109+ " CLAUDE_CODE_PROXY_RESOLVES_HOSTS=1"
110+ " CURL_CA_BUNDLE=$MOCK_CA "
111+ " NODE_EXTRA_CA_CERTS=$MOCK_CA "
112+ " SSL_CERT_FILE=$MOCK_CA "
113+ " TPM2_PKCS11_STORE=$TPM2_PKCS11_STORE "
114+ " AGENT_GATEWAY_DEMO_DASHBOARD_URL=http://localhost:3000"
115+ )
116+
117+ echo " ==> Registering demo principal $PRINCIPAL "
118+ env " ${demo_env[@]} " " $REPO_ROOT /registry-cli/register-principal-key.sh" " $PRINCIPAL "
119+
120+ echo " ==> Granting demo scopes"
121+ env " ${demo_env[@]} " " $REPO_ROOT /registry-cli/grant-principal-scope.sh" " $PRINCIPAL " docstore messaging api.anthropic.com
122+
123+ echo " ==> Creating demo agent $HANDLE "
124+ env " ${demo_env[@]} " " $SCRIPT_DIR /demo-agent.sh" create \
125+ --identity " $IDENTITY " \
126+ --handle " $HANDLE " \
127+ --grant docstore \
128+ --grant api.anthropic.com > /dev/null
111129}
112130
113- demo_env=(
114- " AGENT_GATEWAY_DATABASE_URL=$DATABASE_URL "
115- " AGENT_GATEWAY_DEMO_GATEWAY=$GATEWAY "
116- " AGENT_GATEWAY_DEMO_GATEWAY_CA=$GATEWAY_CA "
117- " AGENT_GATEWAY_DEMO_MOCK_CA=$MOCK_CA "
118- " AGENT_GATEWAY_DEMO_SIDECAR_BIN=$SIDECAR_BIN "
119- " AGENT_GATEWAY_DEMO_STATE_DIR=$STATE_ROOT "
120- " AGENT_GATEWAY_TPM_USER_PIN=$USER_PIN "
121- " AGENT_GATEWAY_TPM_SO_PIN=$SO_PIN "
122- " AGENT_GATEWAY_RESET_TPM_STORE=false"
123- " CLAUDE_CODE_PROXY_RESOLVES_HOSTS=1"
124- " CURL_CA_BUNDLE=$MOCK_CA "
125- " NODE_EXTRA_CA_CERTS=$MOCK_CA "
126- " SSL_CERT_FILE=$MOCK_CA "
127- " TPM2_PKCS11_STORE=$TPM2_PKCS11_STORE "
128- )
131+ # ── Main ──────────────────────────────────────────────────────────────────────
129132
130133select_compose
131134require_cmd cargo
132135require_cmd openssl
133136require_cmd psql
134- require_cmd timeout
137+ require_cmd node
135138
136139cd " $REPO_ROOT "
137140
@@ -142,6 +145,9 @@ if [[ ! -f "$REPO_ROOT/config.toml" ]]; then
142145 echo " ==> Creating config.toml from config.example.toml"
143146 cp " $REPO_ROOT /config.example.toml" " $REPO_ROOT /config.toml"
144147fi
148+ # Ensure the gateway (running in Docker) sends OTLP to the collector service name,
149+ # not localhost (which would be the gateway container itself).
150+ sed -i ' s|otlp_endpoint = "http://localhost:4317"|otlp_endpoint = "http://otel-collector:4317"|' " $REPO_ROOT /config.toml"
145151
146152echo " ==> Building local sidecar"
147153cargo build -p agent_gateway_sidecar
@@ -153,51 +159,16 @@ compose up -d --force-recreate postgres mock-services
153159wait_for_postgres
154160apply_migrations
155161
156- echo " ==> Starting gateway"
162+ echo " ==> Starting gateway, otel-collector, and dashboard "
157163compose up -d --force-recreate gateway otel-collector dashboard
158164
159- echo " ==> Registering demo principal $PRINCIPAL "
160- env " ${demo_env[@]} " " $REPO_ROOT /registry-cli/register-principal-key.sh" " $PRINCIPAL "
161-
162- echo " ==> Granting demo scopes"
163- env " ${demo_env[@]} " " $REPO_ROOT /registry-cli/grant-principal-scope.sh" " $PRINCIPAL " docstore messaging api.anthropic.com
164-
165- echo " ==> Creating demo agent $HANDLE "
166- env " ${demo_env[@]} " " $SCRIPT_DIR /demo-agent.sh" create \
167- --identity " $IDENTITY " \
168- --handle " $HANDLE " \
169- --grant docstore \
170- --grant api.anthropic.com \
171- --grant messaging > /dev/null
172-
173- echo " ==> Verifying Claude Code HTTP requests through the gateway"
174- if ! timeout " $VERIFY_TIMEOUT_SECONDS " env " ${demo_env[@]} " " $SCRIPT_DIR /demo-agent.sh" prompt " $HANDLE " --prompt \
175- " Access https://docstore/health using curl and return only the raw response body.
176- Return only the raw response body." ; then
177- cat >&2 << EOF
178- error: Claude Code could not fetch https://docstore/health through the demo gateway.
179-
180- Expected environment:
181- HTTPS_PROXY=http://127.0.0.1:3128
182- CURL_CA_BUNDLE=$MOCK_CA
183- NODE_EXTRA_CA_CERTS=$MOCK_CA
184- SSL_CERT_FILE=$MOCK_CA
185- CLAUDE_CODE_PROXY_RESOLVES_HOSTS=1
186- AGENT_GATEWAY_DEMO_SIDECAR_BIN=$SIDECAR_BIN
187-
188- EOF
189- print_verification_diagnostics
190- exit 1
191- fi
192-
193- rm -f " $( state_dir) /claude_started"
165+ enroll
194166
195167cat << EOF
196168
197169Demo is ready.
198170
199- Dashboard URL:
200- http://localhost:3000
171+ Dashboard: http://localhost:3000
201172
202173Mock service URLs available through the gateway:
203174 https://docstore/health
0 commit comments