Skip to content

Commit 7f0f45c

Browse files
committed
Separate demo and registry CLI scripts
Move the former examples into purpose-specific homes so demo scaffolding and registry mutation commands are not presented as sample code.
1 parent b9092de commit 7f0f45c

9 files changed

Lines changed: 16 additions & 485 deletions

README.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,30 +20,30 @@ sudo apt-get install libtss2-dev swtpm tpm2-tools pkg-config
2020
## Quick start
2121

2222
```bash
23-
./examples/generate-certs.sh # server CA + gateway cert under certs/
23+
./demo/generate-server-certs.sh # server CA + gateway cert under certs/
2424
cp config.example.toml config.toml # edit to taste
2525
docker compose -f docker-compose.postgres.yml up -d
2626
export AGENT_GATEWAY_DATABASE_URL=postgres://agent_gateway_admin:agent_gateway_dev@localhost:5432/agent_gateway
2727
psql "$AGENT_GATEWAY_DATABASE_URL" -f migrations/0001_signed_authorization_registry.sql
2828
```
2929

30-
`generate-certs.sh` only creates **server** TLS material (`server-ca.pem`, `server.pem`, ...). Each agent platform enrolls with `./examples/demo-agent.sh`, which starts a local `swtpm`, creates a persistent P-256 signing key in that simulated TPM, and prepares `machine-client.pem` as a certificate carrier for that public key and identity extension. The gateway does not trust a client CA bundle; it authorizes the exact subject public key recorded in signed Postgres permission rows.
30+
`demo/generate-server-certs.sh` only creates **server** TLS material (`server-ca.pem`, `server.pem`, ...). The local demo enrolls with `./demo/demo-agent.sh`, which starts a local `swtpm`, creates a persistent P-256 signing key in that simulated TPM, and prepares `machine-client.pem` as a certificate carrier for that public key and identity extension. The gateway does not trust a client CA bundle; it authorizes the exact subject public key recorded in signed Postgres permission rows.
3131

3232
Typical first-time flow:
3333

34-
1. `./examples/generate-certs.sh` and `cp config.example.toml config.toml`.
34+
1. `./demo/generate-server-certs.sh` and `cp config.example.toml config.toml`.
3535
2. Enroll a trusted principal signing key and grant its destination delegation scope.
3636
3. The principal creates an agent handle; the script prepares the subject certificate, signs permission rows for its exact SPKI DER, and starts the sidecar.
3737
4. Start the gateway (`cargo run -- --config config.toml`) before sending prompts through the sidecar.
3838

39-
On later runs, start the gateway first and use `demo-agent.sh prompt`. `connect.sh` prepares `machine-client.pem` for the current simulated TPM key and identity extension whenever it prepares or starts the sidecar. `--regenerate-certs` creates a fresh simulated TPM state; any permissions for the old subject key will no longer match.
39+
On later runs, start the gateway first and use `./demo/demo-agent.sh prompt`. `./demo/connect.sh` prepares `machine-client.pem` for the current simulated TPM key and identity extension whenever it prepares or starts the sidecar. `--regenerate-certs` creates a fresh simulated TPM state; any permissions for the old subject key will no longer match.
4040

41-
Pass a custom policy extension value: `connect.sh start-sidecar ... --extension-value agent-beta`. The extension value must match `permission_registry.subject_identity` in an active signed permission row.
41+
Pass a custom policy extension value: `./demo/connect.sh start-sidecar ... --extension-value agent-beta`. The extension value must match `permission_registry.subject_identity` in an active signed permission row.
4242

4343
The simulated TPM state lives under `$AGENT_STATE/client/swtpm/`. By default,
4444
the sidecar uses TCTI `swtpm:host=127.0.0.1,port=2321` and persistent handle
4545
`0x81010004`; override the handle or simulator data port with
46-
`connect.sh start-sidecar --tpm-handle` and
46+
`./demo/connect.sh start-sidecar --tpm-handle` and
4747
`--swtpm-port`. The swtpm control port is always the data port plus one, which
4848
matches the TSS swtpm TCTI convention.
4949

@@ -105,7 +105,7 @@ Shut down cleanly with `Ctrl-C`.
105105
Register a principal signing key from the TPM owner machine with:
106106

107107
```bash
108-
./examples/register-principal-key.sh org-alice
108+
./registry-cli/register-principal-key.sh org-alice
109109
```
110110

111111
The script creates or reuses a non-exportable TPM-backed P-256 key through `tpm2_ptool` and PKCS#11, stores only the public key in `principal_signing_keys`, and uses the friendly `key_id` (`org-alice`, `org-bob`, etc.) for the registry row. Run it on the machine that owns the TPM, with `AGENT_GATEWAY_DATABASE_URL` or `DATABASE_URL` pointing at Postgres.
@@ -114,22 +114,22 @@ For the demo, use three windows:
114114

115115
```bash
116116
# Principal shell: enroll the principal TPM public key.
117-
./examples/register-principal-key.sh org-alice
117+
./registry-cli/register-principal-key.sh org-alice
118118

119119
# Admin shell: grant destination delegation authority to that principal.
120-
./examples/grant-principal-scope.sh org-alice api.anthropic.com example.com
120+
./registry-cli/grant-principal-scope.sh org-alice api.anthropic.com example.com
121121

122122
# Principal shell: create a local agent handle with initial signed permissions.
123-
AGENT_HANDLE="$(./examples/demo-agent.sh create \
123+
AGENT_HANDLE="$(./demo/demo-agent.sh create \
124124
--identity agent-alpha \
125125
--grant api.anthropic.com)"
126126

127127
# Principal shell: send the first prompt through that agent.
128-
./examples/demo-agent.sh prompt "$AGENT_HANDLE" --prompt "test prompt"
128+
./demo/demo-agent.sh prompt "$AGENT_HANDLE" --prompt "test prompt"
129129

130130
# Principal shell: grant another destination, then continue the same Claude session.
131-
./examples/demo-agent.sh grant "$AGENT_HANDLE" --grant example.com
132-
./examples/demo-agent.sh prompt "$AGENT_HANDLE" --prompt "now try the second destination"
131+
./demo/demo-agent.sh grant "$AGENT_HANDLE" --grant example.com
132+
./demo/demo-agent.sh prompt "$AGENT_HANDLE" --prompt "now try the second destination"
133133
```
134134

135135
The dashboard runs separately and observes Postgres plus OpenTelemetry. `demo-agent.sh` keeps gateway connection details out of the principal-facing command; set `AGENT_GATEWAY_DEMO_GATEWAY` and `AGENT_GATEWAY_DEMO_GATEWAY_CA` only when overriding the local defaults. `AGENT_GATEWAY_DEMO_GATEWAY_CA` is the CA for the gateway's server certificate, not a client trust root. The first prompt uses `claude -p`; later prompts for the same handle use `claude -c -p` from the handle's working directory.
File renamed without changes.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ discover_principal() {
111111
count="$(printf '%s\n' "$labels" | sed '/^$/d' | wc -l | tr -d ' ')"
112112
if [[ "$count" -ne 1 ]]; then
113113
echo "expected exactly one TPM principal key label in token '$TOKEN_LABEL', found $count" >&2
114-
echo "hint: run ./examples/register-principal-key.sh KEY_ID first on this machine" >&2
114+
echo "hint: run ./registry-cli/register-principal-key.sh KEY_ID first on this machine" >&2
115115
[[ -n "$labels" ]] && printf '%s\n' "$labels" >&2
116116
exit 1
117117
fi
@@ -175,7 +175,7 @@ prepare_subject_certificate() {
175175
grant_permissions() {
176176
local destination
177177
for destination in "${GRANTS[@]}"; do
178-
"$SCRIPT_DIR/register-permission.sh" \
178+
"$REPO_ROOT/registry-cli/register-permission.sh" \
179179
"$PRINCIPAL" \
180180
"$IDENTITY" \
181181
"$SUBJECT_PUBLIC_KEY_SPKI_DER" \
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env bash
2-
# Dev gateway server TLS onlycerts/server-ca*.pem, certs/server*.pem. Client enrollment: examples/connect.sh.
2+
# Demo gateway server TLS only: certs/server-ca*.pem and certs/server*.pem.
33

44
set -euo pipefail
55

0 commit comments

Comments
 (0)