1import{n as e}from"./rolldown-runtime-CMxvf4Kt.js";import{F as t,I as n}from"../vendor/vendor-ai-runtime-DrDK77gy.js";import{n as r,t as i}from"./agent-Doq2Q6Wt.js";import{a,n as o}from"./agent-Dh3-_0ai.js";import{m as s,p as c}from"./swr-C_leGIiU.js";import{n as l,s as u}from"./client-DUGXaJW2.js";import{Ft as d,Mt as f,N as p,P as m}from"./store-JX60g0Lu.js";import{n as h,t as g}from"./discover-v4iycg4x.js";var _,v,y,b=e((()=>{n(),s(),l(),r(),h(),p(),o(),f(),_=()=>t(`0123456789abcdefghijklmnopqrstuvwxyz`,8)(),v=()=>typeof location>`u`?`onboarding/agent-marketplace`:location.pathname,y=async(e,t)=>{if(e.length===0)return{installedAgentIds:[],skippedAgentIds:[],summaries:[]};let n=a.getState().createAgent,r=d.getState().refreshAgentList,o=c(),s=o?t?.visibility??`public`:void 0,l,f=!1;if(o){let{marketAccountId:e,created:t}=await u.workspace.ensureMarketOrganization.mutate({autoProvision:!0});l=e,f=t}let p=await Promise.all(e.map(e=>i.getAgentByForkedFromIdentifier(e))),h=[],y=[];e.forEach((e,t)=>{p[t]?h.push(e):y.push(e)});let b=await Promise.allSettled(y.map(e=>g.getAssistantDetail({identifier:e,source:`new`}))),x=[];b.forEach((e,t)=>{let n=y[t];if(e.status!==`fulfilled`){console.warn(`Failed to fetch marketplace agent detail:`,n,e.reason);return}let r=e.value;if(!r?.config){console.warn(`Marketplace agent config is missing:`,n);return}x.push({detail:r,newIdentifier:_(),sourceId:n})});let S=x.length===0?[]:await m.forkAgent(x.map(e=>({actAs:l,identifier:e.newIdentifier,name:e.detail.title,sourceIdentifier:e.sourceId,status:`published`,visibility:`public`}))),C=await Promise.allSettled(S.map(async(e,t)=>{let{detail:r,sourceId:i}=x[t];if(!e.success)throw Error(e.error.message);let a=e.data,o=await n({config:{...r.config,avatar:r.avatar,backgroundColor:r.backgroundColor,description:r.description,editorData:r.editorData,marketIdentifier:a.agent.identifier,params:{...r.config.params,forkedFromIdentifier:i},tags:r.tags,title:a.agent.name},visibility:s});return g.reportAgentEvent({event:`add`,identifier:a.agent.identifier,source:v()}),{agentId:o.agentId,sourceId:i}})),w=new Map;C.forEach((e,t)=>{e.status===`fulfilled`?w.set(e.value.sourceId,e.value.agentId):console.warn(`Failed to install marketplace agent:`,x[t]?.sourceId,e.reason)});let T=new Map;x.forEach(e=>T.set(e.sourceId,e.detail));let E=e.map(e=>{if(h.includes(e))return{skipped:!0,templateId:e};let t=T.get(e);return{avatar:t?.avatar,category:t?.category,description:t?.description||t?.summary,installedAgentId:w.get(e),skipped:!1,templateId:e,title:t?.title}}),D=Array.from(w.values());return D.length>0&&await r(),{createdMarketProfile:f,installedAgentIds:D,skippedAgentIds:h,summaries:E}}}));export{y as n,b as t};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.