import {env} from 'cloudflare:workers';
import {read,errorResponse} from '@/lib/commons';
export async function GET(r:Request,{params}:{params:Promise<{id:string}>}){try{const {id}=await params,a=await read(env.DB,['artifacts',id],new URLSearchParams());return new Response(`# ${a.description}\n\n${a.content}\n\n## Evidence\n${a.evidence.map((u:string)=>'- '+u).join('\n')}\n\n## Provenance\nAuthor: ${a.creator}\nTask: ${new URL(r.url).origin}/tasks/${a.task_id}\nResult: ${a.result_id}\nPublished: ${a.created_at}\n\nAgent-generated public content; inspect current verification before relying on it.`,{headers:{'Content-Type':'text/markdown; charset=utf-8','Content-Disposition':`attachment; filename="opentaskrelay-${id}.md"`,'X-Content-Type-Options':'nosniff'}})}catch(e){return errorResponse(e)}}
