@@ -15,6 +15,7 @@ DEFAULT_SWTPM_PORT="${AGENT_GATEWAY_DEMO_SWTPM_PORT:-2321}"
1515TPM2_PKCS11_STORE=" ${TPM2_PKCS11_STORE:- $HOME / .tpm2_pkcs11} "
1616TOKEN_LABEL=" ${AGENT_GATEWAY_TPM_TOKEN_LABEL:- agent-gateway} "
1717USER_PIN=" ${AGENT_GATEWAY_TPM_USER_PIN:- } "
18+ DASHBOARD_URL=" ${AGENT_GATEWAY_DEMO_DASHBOARD_URL:- http:// localhost: 3000} "
1819export TPM2_PKCS11_STORE
1920
2021usage () {
@@ -149,7 +150,12 @@ write_state() {
149150
150151sidecar_running () {
151152 local dir=" $1 "
152- [[ -f " $dir /sidecar_pid" ]] && kill -0 " $( < " $dir /sidecar_pid" ) " 2> /dev/null
153+ local pid
154+ [[ -f " $dir /sidecar_pid" ]] || return 1
155+ pid=" $( < " $dir /sidecar_pid" ) "
156+ kill -0 " $pid " 2> /dev/null || return 1
157+ # Exclude zombie processes — they pass kill -0 but are not actually running
158+ [[ " $( cat /proc/" $pid " /status 2> /dev/null | awk ' /^State:/{print $2}' ) " != " Z" ]]
153159}
154160
155161ensure_sidecar () {
@@ -229,6 +235,11 @@ cmd_create() {
229235 grant_permissions
230236 ensure_sidecar " $STATE_DIR_CURRENT "
231237
238+ curl -sf --max-time 2 -X POST " $DASHBOARD_URL /api/events" \
239+ -H ' Content-Type: application/json' \
240+ -d " {\" event_type\" :\" agent.created\" ,\" source\" :\" agent-platform\" ,\" attributes\" :{\" user.id\" :\" $PRINCIPAL \" ,\" agent.id\" :\" $IDENTITY \" }}" \
241+ > /dev/null || true
242+
232243 echo " $HANDLE "
233244}
234245
@@ -271,6 +282,10 @@ cmd_prompt() {
271282 done
272283
273284 [[ -n " $PROMPT " ]] || { echo " error: prompt requires --prompt" >&2 ; exit 2; }
285+ curl -sf --max-time 2 -X POST " $DASHBOARD_URL /api/events" \
286+ -H ' Content-Type: application/json' \
287+ -d " {\" event_type\" :\" agent.prompted\" ,\" source\" :\" agent-platform\" ,\" attributes\" :{\" user.id\" :\" $PRINCIPAL \" ,\" agent.id\" :\" $IDENTITY \" }}" \
288+ > /dev/null || true
274289 ensure_sidecar " $STATE_DIR_CURRENT "
275290 [[ -f " $DEFAULT_MOCK_CA " ]] || {
276291 echo " error: mock service CA file not found: $DEFAULT_MOCK_CA " >&2
0 commit comments