mirror of
https://github.com/hanzoai/kai.git
synced 2026-10-17 11:18:06 +00:00
The curl scripts piped any response into jq and exited 0, so a refused key read as success; they now run under set -euo pipefail with --fail-with-body. noul.sh sent "spent 2,000" because the shell expanded $1 inside "$12,000". Go returns errors instead of panicking and gets a go.mod so `go run .` and the CI toolchain find it. Rust reports a missing key as an error rather than a panic and uses rustls, so it builds without system OpenSSL. Both say in one line why they use plain HTTP: go-sdk v8.5.623 refuses a choice question with named criteria, and hanzo-client 8.5.156 has no /v1/decisions. Co-authored-by: Hanzo Dev <[email protected]>
48 lines
1.5 KiB
Bash
Executable File
48 lines
1.5 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Multi-question compound decision example with Kai / Jev
|
|
# Usage:
|
|
# ./multi.sh # uses default model "kai"
|
|
# KAI_MODEL="typesafe/jev-1.13" ./multi.sh # uses Jev
|
|
|
|
set -euo pipefail
|
|
|
|
MODEL="${KAI_MODEL:-kai}"
|
|
API_KEY="${HANZO_API_KEY:-${1:-}}"
|
|
|
|
if [ -z "$API_KEY" ]; then
|
|
echo "Error: HANZO_API_KEY is required (set env var or pass as first argument)" >&2
|
|
exit 1
|
|
fi
|
|
|
|
curl -sS --fail-with-body -X POST https://api.hanzo.ai/v1/decisions \
|
|
-H "Authorization: Bearer $API_KEY" \
|
|
-H "Content-Type: application/json" \
|
|
-d "{
|
|
\"model\": \"$MODEL\",
|
|
\"state\": {
|
|
\"command\": \"rm -rf /var/log/*\",
|
|
\"user_role\": \"developer\",
|
|
\"environment\": \"production\"
|
|
},
|
|
\"questions\": {
|
|
\"risk_level\": {
|
|
\"type\": \"score\",
|
|
\"instructions\": \"Assess command destruction risk\",
|
|
\"criteria\": [\"safe: read only\", \"guarded: reversible write\", \"destructive: irreversible deletion\"]
|
|
},
|
|
\"requires_mfa\": {
|
|
\"type\": \"noul\",
|
|
\"instructions\": \"Should multi-factor authentication be enforced before execution?\"
|
|
},
|
|
\"action\": {
|
|
\"type\": \"choice\",
|
|
\"instructions\": \"Select gate policy verdict\",
|
|
\"criteria\": {
|
|
\"allow\": \"safe to run automatically\",
|
|
\"ask\": \"require manager confirmation\",
|
|
\"deny\": \"block command completely\"
|
|
}
|
|
}
|
|
}
|
|
}" | jq .
|