Skip to content

Commit 30d7575

Browse files
authored
Merge pull request #1 from SL5TaskForce/demo-improvements
Demo improvements
2 parents 32d2c4c + f4d2d34 commit 30d7575

3 files changed

Lines changed: 55 additions & 73 deletions

File tree

demo/demo-agent.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ SWTPM_HOST="127.0.0.1"
1717
TPM2_PKCS11_STORE="${TPM2_PKCS11_STORE:-$HOME/.tpm2_pkcs11}"
1818
TOKEN_LABEL="${AGENT_GATEWAY_TPM_TOKEN_LABEL:-agent-gateway}"
1919
USER_PIN="${AGENT_GATEWAY_TPM_USER_PIN:-}"
20+
DASHBOARD_URL="${AGENT_GATEWAY_DEMO_DASHBOARD_URL:-http://localhost:3000}"
2021
export TPM2_PKCS11_STORE
2122

2223
usage() {
@@ -476,6 +477,17 @@ run_prompt() {
476477
mkdir -p "$work_dir"
477478
local claude_args=(
478479
--allowedTools "Bash(curl *)"
480+
--system-prompt "You have access to two internal services via HTTPS:
481+
482+
- docstore (https://docstore) - document storage
483+
- GET /health - health check
484+
- GET /documents - list available documents
485+
486+
- messaging (https://messaging) - internal messaging (read-only)
487+
- GET /health - health check
488+
- GET /messages - list recent messages
489+
490+
Use the Bash tool with curl to interact with these services."
479491
)
480492
local first_prompt=false
481493

@@ -538,6 +550,11 @@ cmd_create() {
538550
grant_permissions
539551
start_sidecar "$dir"
540552

553+
curl -sf --max-time 2 -X POST "$DASHBOARD_URL/api/events" \
554+
-H 'Content-Type: application/json' \
555+
-d "{\"event_type\":\"agent.created\",\"source\":\"agent-platform\",\"attributes\":{\"user.id\":\"$PRINCIPAL\",\"agent.id\":\"$IDENTITY\"}}" \
556+
>/dev/null || true
557+
541558
echo "$HANDLE"
542559
}
543560

@@ -581,6 +598,10 @@ cmd_prompt() {
581598
done
582599

583600
[[ -n "$PROMPT" ]] || { echo "error: prompt requires --prompt" >&2; exit 2; }
601+
curl -sf --max-time 2 -X POST "$DASHBOARD_URL/api/events" \
602+
-H 'Content-Type: application/json' \
603+
-d "{\"event_type\":\"agent.prompted\",\"source\":\"agent-platform\",\"attributes\":{\"user.id\":\"$PRINCIPAL\",\"agent.id\":\"$IDENTITY\"}}" \
604+
>/dev/null || true
584605
ensure_runtime "$dir"
585606
[[ -f "$DEFAULT_MOCK_CA" ]] || {
586607
echo "error: mock service CA file not found: $DEFAULT_MOCK_CA" >&2

demo/demo.sh

Lines changed: 34 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ GATEWAY_CA="${AGENT_GATEWAY_DEMO_GATEWAY_CA:-$REPO_ROOT/certs/server-ca.pem}"
2121
MOCK_CA="${AGENT_GATEWAY_DEMO_MOCK_CA:-$REPO_ROOT/certs/mock-ca.pem}"
2222
SIDECAR_BIN="$REPO_ROOT/target/debug/agent_gateway_sidecar"
2323
GATEWAY_IMAGE="${AGENT_GATEWAY_DEMO_GATEWAY_IMAGE:-ghcr.io/sl5taskforce/agent-gateway:main}"
24-
VERIFY_TIMEOUT_SECONDS="${AGENT_GATEWAY_DEMO_VERIFY_TIMEOUT_SECONDS:-120}"
25-
2624
export COMPOSE_PROJECT_NAME
2725
export AGENT_GATEWAY_DEMO_GATEWAY_IMAGE="$GATEWAY_IMAGE"
2826

@@ -109,42 +107,46 @@ state_dir() {
109107
printf '%s/%s\n' "$STATE_ROOT" "$HANDLE"
110108
}
111109

112-
print_verification_diagnostics() {
113-
local sidecar_log
114-
sidecar_log="$(state_dir)/sidecar.log"
110+
enroll() {
111+
demo_env=(
112+
"AGENT_GATEWAY_DATABASE_URL=$DATABASE_URL"
113+
"AGENT_GATEWAY_DEMO_GATEWAY=$GATEWAY"
114+
"AGENT_GATEWAY_DEMO_GATEWAY_CA=$GATEWAY_CA"
115+
"AGENT_GATEWAY_DEMO_MOCK_CA=$MOCK_CA"
116+
"AGENT_GATEWAY_DEMO_SIDECAR_BIN=$SIDECAR_BIN"
117+
"AGENT_GATEWAY_DEMO_STATE_DIR=$STATE_ROOT"
118+
"AGENT_GATEWAY_TPM_USER_PIN=$USER_PIN"
119+
"AGENT_GATEWAY_TPM_SO_PIN=$SO_PIN"
120+
"AGENT_GATEWAY_RESET_TPM_STORE=false"
121+
"CLAUDE_CODE_PROXY_RESOLVES_HOSTS=1"
122+
"CURL_CA_BUNDLE=$MOCK_CA"
123+
"NODE_EXTRA_CA_CERTS=$MOCK_CA"
124+
"SSL_CERT_FILE=$MOCK_CA"
125+
"TPM2_PKCS11_STORE=$TPM2_PKCS11_STORE"
126+
"AGENT_GATEWAY_DEMO_DASHBOARD_URL=http://localhost:3000"
127+
)
115128

116-
echo "Check the gateway, sidecar, and mock service logs before retrying." >&2
117-
echo "Sidecar log: $sidecar_log" >&2
118-
if [[ -f "$sidecar_log" ]]; then
119-
echo >&2
120-
echo "Recent sidecar log lines:" >&2
121-
tail -n 80 "$sidecar_log" >&2 || true
122-
fi
129+
echo "==> Registering demo principal $PRINCIPAL"
130+
env "${demo_env[@]}" "$REPO_ROOT/registry-cli/register-principal-key.sh" "$PRINCIPAL"
131+
132+
echo "==> Granting demo scopes"
133+
env "${demo_env[@]}" "$REPO_ROOT/registry-cli/grant-principal-scope.sh" "$PRINCIPAL" docstore messaging api.anthropic.com
134+
135+
echo "==> Creating demo agent $HANDLE"
136+
env "${demo_env[@]}" "$SCRIPT_DIR/demo-agent.sh" create \
137+
--identity "$IDENTITY" \
138+
--handle "$HANDLE" \
139+
--grant docstore \
140+
--grant api.anthropic.com >/dev/null
123141
}
124142

125-
demo_env=(
126-
"AGENT_GATEWAY_DATABASE_URL=$DATABASE_URL"
127-
"AGENT_GATEWAY_DEMO_GATEWAY=$GATEWAY"
128-
"AGENT_GATEWAY_DEMO_GATEWAY_CA=$GATEWAY_CA"
129-
"AGENT_GATEWAY_DEMO_MOCK_CA=$MOCK_CA"
130-
"AGENT_GATEWAY_DEMO_SIDECAR_BIN=$SIDECAR_BIN"
131-
"AGENT_GATEWAY_DEMO_STATE_DIR=$STATE_ROOT"
132-
"AGENT_GATEWAY_TPM_USER_PIN=$USER_PIN"
133-
"AGENT_GATEWAY_TPM_SO_PIN=$SO_PIN"
134-
"AGENT_GATEWAY_RESET_TPM_STORE=false"
135-
"CLAUDE_CODE_PROXY_RESOLVES_HOSTS=1"
136-
"CURL_CA_BUNDLE=$MOCK_CA"
137-
"NODE_EXTRA_CA_CERTS=$MOCK_CA"
138-
"SSL_CERT_FILE=$MOCK_CA"
139-
"TPM2_PKCS11_STORE=$TPM2_PKCS11_STORE"
140-
)
143+
# ── Main ──────────────────────────────────────────────────────────────────────
141144

142145
cmd_setup() {
143146
select_compose
144147
require_cmd cargo
145148
require_cmd openssl
146149
require_cmd psql
147-
require_cmd timeout
148150

149151
cd "$REPO_ROOT"
150152

@@ -166,51 +168,16 @@ cmd_setup() {
166168
wait_for_postgres
167169
apply_migrations
168170

169-
echo "==> Starting gateway"
171+
echo "==> Starting gateway, otel-collector, and dashboard"
170172
compose up -d --force-recreate gateway otel-collector dashboard
171173

172-
echo "==> Registering demo principal $PRINCIPAL"
173-
env "${demo_env[@]}" "$REPO_ROOT/registry-cli/register-principal-key.sh" "$PRINCIPAL"
174-
175-
echo "==> Granting demo scopes"
176-
env "${demo_env[@]}" "$REPO_ROOT/registry-cli/grant-principal-scope.sh" "$PRINCIPAL" docstore messaging api.anthropic.com
177-
178-
echo "==> Creating demo agent $HANDLE"
179-
env "${demo_env[@]}" "$SCRIPT_DIR/demo-agent.sh" create \
180-
--identity "$IDENTITY" \
181-
--handle "$HANDLE" \
182-
--grant docstore \
183-
--grant api.anthropic.com \
184-
--grant messaging >/dev/null
185-
186-
echo "==> Verifying Claude Code HTTP requests through the gateway"
187-
if ! timeout "$VERIFY_TIMEOUT_SECONDS" env "${demo_env[@]}" "$SCRIPT_DIR/demo-agent.sh" prompt "$HANDLE" --prompt \
188-
"Access https://docstore/health using curl and return only the raw response body.
189-
Return only the raw response body."; then
190-
cat >&2 <<EOF
191-
error: Claude Code could not fetch https://docstore/health through the demo gateway.
192-
193-
Expected environment:
194-
HTTPS_PROXY=http://127.0.0.1:3128
195-
CURL_CA_BUNDLE=$MOCK_CA
196-
NODE_EXTRA_CA_CERTS=$MOCK_CA
197-
SSL_CERT_FILE=$MOCK_CA
198-
CLAUDE_CODE_PROXY_RESOLVES_HOSTS=1
199-
AGENT_GATEWAY_DEMO_SIDECAR_BIN=$SIDECAR_BIN
200-
201-
EOF
202-
print_verification_diagnostics
203-
exit 1
204-
fi
205-
206-
rm -f "$(state_dir)/claude_started"
174+
enroll
207175

208176
cat <<EOF
209177
210178
Demo is ready.
211179
212-
Dashboard URL:
213-
http://localhost:3000
180+
Dashboard: http://localhost:3000
214181
215182
Mock service URLs available through the gateway:
216183
https://docstore/health

otel-collector.yaml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,6 @@ receivers:
44
grpc:
55
endpoint: 0.0.0.0:4317
66

7-
processors:
8-
batch:
9-
timeout: 1s
10-
send_batch_size: 50
11-
127
exporters:
138
otlphttp/dashboard:
149
endpoint: http://dashboard:3000
@@ -20,7 +15,6 @@ service:
2015
pipelines:
2116
traces:
2217
receivers: [otlp]
23-
processors: [batch]
2418
exporters: [otlphttp/dashboard]
2519

2620
telemetry:

0 commit comments

Comments
 (0)