Add provider audit envelopes and user-input audit metadata#12
Open
Add provider audit envelopes and user-input audit metadata#12
Conversation
Expose provider-native audit envelopes on surfaced message types and propagate audit metadata through requestUserInput parsing and response serialization. This keeps provider event capture SDK-owned while preserving the existing normalized public surface for downstream consumers.
Expose NewAuditEnvelope(eventType, subtype, payload) as a public API matching the OpenRouter SDK signature, enabling consumers to construct audit envelopes from typed payloads. The existing private parse-time constructor remains for raw wire data attachment. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Add WithMaxTurns option with exec CLI flag and app-server protocol support across both backends. Add MultiSelect field to user input Question struct with camelCase/snake_case parsing.
The audit envelope payload was previously produced by re-marshaling the decoded map[string]any, which loses byte-level details like number formatting (1e+06 vs 1000000), key ordering, and whitespace from the original wire data. This is problematic for audit/provenance use cases where exact reproduction of the provider response matters. Changes: - Add internal/message/raw_json.go with AnnotateRawJSON, extractRawJSON, and stripRawJSON helpers that thread original bytes through decoded maps via a hidden sentinel key. - Widen Parse() signature from map[string]any to any, accepting []byte and json.RawMessage directly so callers can pass raw wire data. - Thread raw line bytes through the JSON-RPC notification path (RPCNotification.Raw field, toNotification parameter) and annotate events in both AppServerAdapter and CLITransport before dispatch. - Update sessions.go GetSessionMessages to pass raw line bytes to Parse. - newAuditEnvelope now prefers the annotated original bytes, falling back to re-marshal only when raw bytes are unavailable. - Add test verifying audit payloads preserve original JSON bytes verbatim. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
…Message Extend ResultMessage with session-level metadata fields returned by the Codex turn-completed event: stop_reason (optional), duration_ms, num_turns, and total_cost_usd (optional). Parse these fields from the raw event map in parseCodexTurnCompleted and add tests covering full field presence, the Parse entry point, and missing optional field defaults. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
AuditEnvelopetype to all message types, capturing provider-native event payloads at the SDK boundary for downstream audit/debuggingrequestUserInputparsing and response serializationNewAuditEnvelopeconstructor matching the OpenRouter SDK signature for cross-SDK consistencytest_examples.shto handle examples with their owngo.mod(nested modules)Test plan
go test ./...passesmake test-integrationpassestest_examples.shcorrectly runscustom_logger(nested module example)🤖 Generated with Claude Code