import '../../../core/api_gateway.dart'; import 'artifact_record.dart'; import 'artifact_url.dart'; import 'artifact_groups.dart'; /// Run provenance supplied by the owner of an artifact gallery. class ArtifactChatContext { const ArtifactChatContext({ required this.runId, required this.runTitle, required this.pipelineName, this.pipelineVersion, this.stageKey, this.visit, this.configuredEndpoint = '', this.recordedSteps = const {}, }); final String runId; final String runTitle; final String pipelineName; final String? pipelineVersion; final String? stageKey; final int? visit; final String configuredEndpoint; final JsonMap recordedSteps; } String artifactChatReference( ArtifactChatContext context, ArtifactGroup group, ArtifactRecord artifact, ) { final resolved = artifact.hasUrl ? resolveArtifactUrl(context.configuredEndpoint, artifact.url) : null; final readable = resolved == null ? 'The server did not provide a safe readable URL for this artifact; ' 'inspect the run to locate it.' : 'The chat agent can read it at ${resolved.url}'; final version = context.pipelineVersion == null ? '' : ' v${context.pipelineVersion}'; return 'Artifact "${artifact.name}" from run ${context.runId} ' '("${context.runTitle}"), pipeline "${context.pipelineName}"$version, ' 'stage "${context.stageKey ?? group.stageKey}", visit ' '${context.visit ?? group.visit}. $readable. ' 'Use `pipelines inspect ${context.runId}` for the authoritative run ' 'and artifact metadata.'; }