@@ -35,6 +35,7 @@ import {
3535 type StoredLogEntry ,
3636 sendableQueuePrefixLength ,
3737 sessionSupportsNativeSteer ,
38+ type TaskRunArtifact ,
3839 type TaskRunStatus ,
3940} from "@posthog/shared" ;
4041import { ANALYTICS_EVENTS } from "@posthog/shared/analytics-events" ;
@@ -1599,7 +1600,7 @@ export class SessionService {
15991600 /** Deduplicates concurrent manifest reads when a message renders many images. */
16001601 private cloudAttachmentManifestRequests = new Map <
16011602 string ,
1602- Promise < Array < { id ?: string ; storage_path ?: string } > >
1603+ Promise < TaskRunArtifact [ ] >
16031604 > ( ) ;
16041605 private idleKilledSubscription : { unsubscribe : ( ) => void } | null = null ;
16051606 /**
@@ -4673,6 +4674,7 @@ export class SessionService {
46734674 cloudStatus : run . status ,
46744675 cloudStage : run . stage ?? null ,
46754676 cloudOutput : run . output ?? null ,
4677+ cloudArtifacts : run . artifacts ?? [ ] ,
46764678 cloudErrorMessage : run . error_message ,
46774679 logUrl : run . log_url ?? session . logUrl ,
46784680 } ) ;
@@ -7293,22 +7295,34 @@ export class SessionService {
72937295 }
72947296 }
72957297
7298+ async getCloudRunArtifacts (
7299+ taskId : string ,
7300+ runId : string ,
7301+ ) : Promise < TaskRunArtifact [ ] > {
7302+ const authStatus = await this . getAuthCredentialsStatus ( ) ;
7303+ if ( authStatus . kind !== "ready" ) return [ ] ;
7304+
7305+ return this . getCloudAttachmentManifest (
7306+ authStatus . auth . client ,
7307+ `${ authStatus . auth . apiHost } :${ authStatus . auth . projectId } ` ,
7308+ taskId ,
7309+ runId ,
7310+ ) ;
7311+ }
7312+
72967313 private getCloudAttachmentManifest (
72977314 client : AuthClient ,
72987315 authIdentity : string ,
72997316 taskId : string ,
73007317 runId : string ,
7301- ) : Promise < Array < { id ?: string ; storage_path ?: string } > > {
7318+ ) : Promise < TaskRunArtifact [ ] > {
73027319 const key = `${ authIdentity } :${ taskId } :${ runId } ` ;
73037320 const existing = this . cloudAttachmentManifestRequests . get ( key ) ;
73047321 if ( existing ) return existing ;
73057322
73067323 const request = client
73077324 . getTaskRun ( taskId , runId )
7308- . then (
7309- ( run : { artifacts ?: Array < { id ?: string ; storage_path ?: string } > } ) =>
7310- run . artifacts ?? [ ] ,
7311- ) ;
7325+ . then ( ( run : { artifacts ?: TaskRunArtifact [ ] } ) => run . artifacts ?? [ ] ) ;
73127326 this . cloudAttachmentManifestRequests . set ( key , request ) ;
73137327
73147328 const clear = ( ) => {
0 commit comments