package com.infoepoch.pms.agent.observability.ai;

/**
 * AI 观测上下文。
 */
public record AiObservationContext(
        String traceId,
        String requestId,
        String sessionId,
        String flowId,
        String scene,
        AiComponentType componentType,
        String componentName,
        String agentName,
        String modelProvider,
        String modelName,
        String toolName
) {

    public static Builder builder() {
        return new Builder();
    }

    public Builder toBuilder() {
        return new Builder()
                .traceId(traceId)
                .requestId(requestId)
                .sessionId(sessionId)
                .flowId(flowId)
                .scene(scene)
                .componentType(componentType)
                .componentName(componentName)
                .agentName(agentName)
                .modelProvider(modelProvider)
                .modelName(modelName)
                .toolName(toolName);
    }

    public static final class Builder {

        private String traceId;
        private String requestId;
        private String sessionId;
        private String flowId;
        private String scene;
        private AiComponentType componentType;
        private String componentName;
        private String agentName;
        private String modelProvider;
        private String modelName;
        private String toolName;

        private Builder() {
        }

        public Builder traceId(String traceId) {
            this.traceId = traceId;
            return this;
        }

        public Builder requestId(String requestId) {
            this.requestId = requestId;
            return this;
        }

        public Builder sessionId(String sessionId) {
            this.sessionId = sessionId;
            return this;
        }

        public Builder flowId(String flowId) {
            this.flowId = flowId;
            return this;
        }

        public Builder scene(String scene) {
            this.scene = scene;
            return this;
        }

        public Builder componentType(AiComponentType componentType) {
            this.componentType = componentType;
            return this;
        }

        public Builder componentName(String componentName) {
            this.componentName = componentName;
            return this;
        }

        public Builder agentName(String agentName) {
            this.agentName = agentName;
            return this;
        }

        public Builder modelProvider(String modelProvider) {
            this.modelProvider = modelProvider;
            return this;
        }

        public Builder modelName(String modelName) {
            this.modelName = modelName;
            return this;
        }

        public Builder toolName(String toolName) {
            this.toolName = toolName;
            return this;
        }

        public AiObservationContext build() {
            return new AiObservationContext(
                    traceId,
                    requestId,
                    sessionId,
                    flowId,
                    scene,
                    componentType,
                    componentName,
                    agentName,
                    modelProvider,
                    modelName,
                    toolName
            );
        }
    }
}
