Skip to content

Commit 384bf3d

Browse files
committed
Emit agent lifecycle events to dashboard
1 parent b1659c3 commit 384bf3d

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

demo/demo-agent.sh

Lines changed: 10 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() {
@@ -549,6 +550,11 @@ cmd_create() {
549550
grant_permissions
550551
start_sidecar "$dir"
551552

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+
552558
echo "$HANDLE"
553559
}
554560

@@ -592,6 +598,10 @@ cmd_prompt() {
592598
done
593599

594600
[[ -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
595605
ensure_runtime "$dir"
596606
[[ -f "$DEFAULT_MOCK_CA" ]] || {
597607
echo "error: mock service CA file not found: $DEFAULT_MOCK_CA" >&2

0 commit comments

Comments
 (0)