| 206 | } |
| 207 | |
| 208 | func (s *Server) RecordInterceptionEnded(ctx context.Context, in *proto.RecordInterceptionEndedRequest) (*proto.RecordInterceptionEndedResponse, error) { |
| 209 | //nolint:gocritic // AIBridged has specific authz rules. |
| 210 | ctx = dbauthz.AsAIBridged(ctx) |
| 211 | |
| 212 | intcID, err := uuid.Parse(in.GetId()) |
| 213 | if err != nil { |
| 214 | return nil, xerrors.Errorf("invalid interception ID %q: %w", in.GetId(), err) |
| 215 | } |
| 216 | |
| 217 | if s.structuredLogging { |
| 218 | s.logger.Info(ctx, InterceptionLogMarker, |
| 219 | slog.F("record_type", "interception_end"), |
| 220 | slog.F("interception_id", intcID.String()), |
| 221 | slog.F("ended_at", in.EndedAt.AsTime()), |
| 222 | ) |
| 223 | } |
| 224 | |
| 225 | _, err = s.store.UpdateAIBridgeInterceptionEnded(ctx, database.UpdateAIBridgeInterceptionEndedParams{ |
| 226 | ID: intcID, |
| 227 | EndedAt: in.EndedAt.AsTime(), |
| 228 | CredentialHint: in.CredentialHint, |
| 229 | }) |
| 230 | if err != nil { |
| 231 | return nil, xerrors.Errorf("end interception: %w", err) |
| 232 | } |
| 233 | |
| 234 | return &proto.RecordInterceptionEndedResponse{}, nil |
| 235 | } |
| 236 | |
| 237 | func (s *Server) RecordTokenUsage(ctx context.Context, in *proto.RecordTokenUsageRequest) (*proto.RecordTokenUsageResponse, error) { |
| 238 | //nolint:gocritic // AIBridged has specific authz rules. |