Tags: rickcrawford/tokenomics
Tags
Include build information in GitHub Actions release builds The release workflow was missing version information flags in ldflags, causing 'tokenomics version' to show "unknown" for commit and built date. Now computes and includes: - Version (from git describe --tags --always --dirty) - Commit (short SHA from git rev-parse) - BuildDate (ISO 8601 UTC timestamp) These are passed via -X flags in ldflags for both Unix and Windows builds, matching the Makefile behavior. Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Implement complete OpenClaw integration with jailbreak detection, met… …adata tracking, cost attribution, and webhook events Phases completed: **Phase 1 - Jailbreak Detection** - Added 8 regex patterns for prompt injection detection (ignore_previous, forget_previous, developer_mode, harmful_roleplay, hypothetical_harm, known_jailbreaks) - Pre-compiled patterns for performance optimization - Rule type validation and enforcement in policy engine - 14 test cases with comprehensive coverage **Phase 2 - OpenClaw Metadata Integration** - Extract metadata from X-OpenClaw-* request headers (6 fields: agent_id, agent_type, team, channel, skill, environment) - Added OpenClawMetadata struct and extractOpenClawMetadata() function - Metadata flows through request pipeline to ledger for cost attribution - 10 new test cases covering metadata extraction and conversion **Phase 3 - OpenClaw Cost Attribution & Analytics** - New OpenClawAnalytics engine for querying sessions by metadata - ByMetadataKey() - aggregate costs by any field (team, channel, agent_id, etc.) - ByTeamAndChannel() - specialized multi-dimensional aggregation - FilteredSessions() - query by time range, metadata, token hash - 6 test functions with 9+ test cases **Phase 4 - OpenClaw Webhook Events** - 4 new event types: OpenClawAgentRequest, OpenClawAgentSuccess, OpenClawAgentError - Event emission at key points in request lifecycle - Rule violations include OpenClaw metadata for better correlation - All events include token_hash, model, status, and metadata fields **Phase 5 - Documentation & Launch** - Created comprehensive docs/OPENCLAW.md user guide (500+ lines) - Covers architecture, quick start, configuration, examples, best practices - Integration examples for Slack, Discord, cost attribution scripts - Troubleshooting and security considerations **Test Coverage** - 680+ tests passing (added 30+ new test cases) - All existing tests continue to pass (backward compatible) - Build succeeds cleanly **Files Modified/Created** - internal/proxy: handler.go, handler_chat.go, handler_passthrough.go, handler_test.go - internal/events: events.go (new event types) - internal/policy: pii.go, policy.go, policy_test.go (jailbreak detection) - internal/ledger: openclaw_analytics.go, openclaw_analytics_test.go (analytics engine) - docs: OPENCLAW.md (user documentation) - examples/openclaw: 13 example files (configs, policies, tests) - README.md: updated with new documentation links Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>