Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
ef20ca2
feat: Add CoinGecko OPG/USD price feed background service
kylexqian Apr 20, 2026
e6d5217
refactor: Reorganize price feed into tee_gateway/price_feed/ package
kylexqian Apr 20, 2026
01bbb1e
refactor: dependency injection for OPG price feed via make_cost_calcu…
kylexqian Apr 20, 2026
4dfb1bb
refactor: replace make_cost_calculator factory with calculate_session…
kylexqian Apr 20, 2026
cc6e6dc
feat: include price feed status in /health response
kylexqian Apr 20, 2026
63be5c9
test: verify calculate_session_cost fetches live price on every call
kylexqian Apr 20, 2026
fe7ec1f
fix: update test_pricing.py for calculate_session_cost signature change
kylexqian Apr 20, 2026
2b356bc
fix: address Copilot review comments on price feed
kylexqian Apr 20, 2026
e0ac776
Update .github/workflows/test.yml
kylexqian Apr 20, 2026
4491f75
fix: update stale dynamic_session_cost_calculator references
kylexqian Apr 20, 2026
284cdf3
feat: add pre-inference pricing gate and remove ineffective monkey-patch
kylexqian Apr 20, 2026
8850d73
fix: address Copilot review comments (docstrings, defensive coding, t…
kylexqian Apr 20, 2026
4b82bef
feat: TGE fallback price and CoinGecko sanity checks
kylexqian Apr 20, 2026
2ac733b
feat: expire stale OPG price after 4 hours
kylexqian Apr 20, 2026
9fc0134
Defer x402 middleware setup to injection time; unify facilitator_url
kylexqian Apr 20, 2026
5f4927a
Remove redundant os.getenv in facilitator_url fallback
kylexqian Apr 20, 2026
a52435a
Fix payment_middleware receiving wsgi_app function instead of Flask app
kylexqian Apr 20, 2026
c6426db
Remove manual wsgi_app assignment — PaymentMiddleware self-wires on init
kylexqian Apr 20, 2026
6ac43d1
Address Copilot review feedback
kylexqian Apr 20, 2026
5193d20
Change .env.example
kylexqian Apr 21, 2026
1ec6f98
Fix completion max value for session
kylexqian Apr 21, 2026
32fc53a
Revert token session cap
kylexqian Apr 21, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ XAI_API_KEY=
# If HEARTBEAT_CONTRACT_ADDRESS and HEARTBEAT_FACILITATOR_URL are set, the enclave
# signs heartbeat payloads and the facilitator relays on-chain txs.
HEARTBEAT_CONTRACT_ADDRESS=
HEARTBEAT_FACILITATOR_URL=
FACILITATOR_URL=
TEE_HEARTBEAT_INTERVAL=900
5 changes: 4 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,7 @@ jobs:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v5
- name: Run unit tests
run: uv run --group test pytest tee_gateway/test/test_tool_forwarding.py tee_gateway/test/test_tee_core.py tests/test_pricing.py -v --import-mode=importlib
run: uv run --group test pytest tee_gateway/test/test_tool_forwarding.py tee_gateway/test/test_tee_core.py tee_gateway/test/test_price_feed.py tests/test_pricing.py -v --import-mode=importlib
# To also run integration tests (real CoinGecko network calls), add:
# env:
# RUN_INTEGRATION_TESTS: "1"
22 changes: 14 additions & 8 deletions scripts/run-enclave.sh
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,11 @@ if [ -f "$ENV_FILE" ]; then
ANTHROPIC_API_KEY="$(grep -E '^ANTHROPIC_API_KEY=' "$ENV_FILE" | cut -d'=' -f2-)"
XAI_API_KEY="$(grep -E '^XAI_API_KEY=' "$ENV_FILE" | cut -d'=' -f2-)"

# Heartbeat configuration (optional — wallet key is generated inside the TEE)
# FACILITATOR_URL is used for both x402 payment verification and the heartbeat relay.
# HEARTBEAT_CONTRACT_ADDRESS and TEE_HEARTBEAT_INTERVAL are optional heartbeat parameters.
# The TEE wallet key is generated inside the enclave and never injected.
HEARTBEAT_CONTRACT_ADDRESS="$(grep -E '^HEARTBEAT_CONTRACT_ADDRESS=' "$ENV_FILE" | cut -d'=' -f2-)"
HEARTBEAT_FACILITATOR_URL="$(grep -E '^HEARTBEAT_FACILITATOR_URL=' "$ENV_FILE" | cut -d'=' -f2-)"
FACILITATOR_URL="$(grep -E '^FACILITATOR_URL=' "$ENV_FILE" | cut -d'=' -f2-)"
TEE_HEARTBEAT_INTERVAL="$(grep -E '^TEE_HEARTBEAT_INTERVAL=' "$ENV_FILE" | cut -d'=' -f2-)"

# Build the JSON payload using jq for safe escaping
Expand All @@ -103,7 +105,7 @@ if [ -f "$ENV_FILE" ]; then
--arg anthropic "$ANTHROPIC_API_KEY" \
--arg xai "$XAI_API_KEY" \
--arg hb_contract "$HEARTBEAT_CONTRACT_ADDRESS" \
--arg hb_facilitator "$HEARTBEAT_FACILITATOR_URL" \
--arg facilitator "$FACILITATOR_URL" \
--arg hb_interval "$TEE_HEARTBEAT_INTERVAL" \
'{
openai_api_key: $openai,
Expand All @@ -112,7 +114,7 @@ if [ -f "$ENV_FILE" ]; then
xai_api_key: $xai
}
+ if $hb_contract != "" then {heartbeat_contract_address: $hb_contract} else {} end
+ if $hb_facilitator != "" then {heartbeat_facilitator_url: $hb_facilitator} else {} end
+ if $facilitator != "" then {facilitator_url: $facilitator} else {} end
+ if $hb_interval != "" then {tee_heartbeat_interval: $hb_interval} else {} end
')

Expand All @@ -125,18 +127,22 @@ if [ -f "$ENV_FILE" ]; then

if [ "$http_status" = "200" ]; then
echo "[ec2] API keys injected successfully."
if [ -n "$HEARTBEAT_CONTRACT_ADDRESS" ] && [ -n "$HEARTBEAT_FACILITATOR_URL" ]; then
echo "[ec2] Heartbeat service configured via facilitator relay (contract: ${HEARTBEAT_CONTRACT_ADDRESS})"
if [ -n "$HEARTBEAT_CONTRACT_ADDRESS" ]; then
if [ -n "$FACILITATOR_URL" ]; then
echo "[ec2] Heartbeat service configured via facilitator relay (contract: ${HEARTBEAT_CONTRACT_ADDRESS})"
else
echo "[ec2] Heartbeat service configured using enclave default facilitator URL (contract: ${HEARTBEAT_CONTRACT_ADDRESS})"
fi
else
echo "[ec2] Heartbeat service not configured (missing env vars)."
echo "[ec2] Heartbeat service not configured (missing HEARTBEAT_CONTRACT_ADDRESS)."
fi
else
echo "[ec2] Warning: Key injection returned HTTP $http_status. Check enclave logs."
fi

# Clear key variables from this shell immediately after use
unset OPENAI_API_KEY GOOGLE_API_KEY ANTHROPIC_API_KEY XAI_API_KEY
unset HEARTBEAT_CONTRACT_ADDRESS HEARTBEAT_FACILITATOR_URL TEE_HEARTBEAT_INTERVAL
unset HEARTBEAT_CONTRACT_ADDRESS FACILITATOR_URL TEE_HEARTBEAT_INTERVAL
fi
else
echo "[ec2] No .env file found at $ENV_FILE"
Expand Down
Loading
Loading