dev3000 0.0.108 → 0.0.109
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dev-environment.d.ts.map +1 -1
- package/dist/dev-environment.js +34 -1
- package/dist/dev-environment.js.map +1 -1
- package/mcp-server/.next/BUILD_ID +1 -1
- package/mcp-server/.next/build-manifest.json +2 -2
- package/mcp-server/.next/fallback-build-manifest.json +2 -2
- package/mcp-server/.next/next-server.js.nft.json +1 -1
- package/mcp-server/.next/prerender-manifest.json +3 -3
- package/mcp-server/.next/server/app/_global-error.html +2 -2
- package/mcp-server/.next/server/app/_global-error.rsc +1 -1
- package/mcp-server/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
- package/mcp-server/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/mcp-server/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/mcp-server/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/mcp-server/.next/server/app/_not-found.html +1 -1
- package/mcp-server/.next/server/app/_not-found.rsc +1 -1
- package/mcp-server/.next/server/app/_not-found.segments/_full.segment.rsc +1 -1
- package/mcp-server/.next/server/app/_not-found.segments/_index.segment.rsc +1 -1
- package/mcp-server/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
- package/mcp-server/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
- package/mcp-server/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
- package/mcp-server/.next/server/app/auth/error.html +1 -1
- package/mcp-server/.next/server/app/auth/error.rsc +1 -1
- package/mcp-server/.next/server/app/auth/error.segments/_full.segment.rsc +1 -1
- package/mcp-server/.next/server/app/auth/error.segments/_index.segment.rsc +1 -1
- package/mcp-server/.next/server/app/auth/error.segments/_tree.segment.rsc +1 -1
- package/mcp-server/.next/server/app/auth/error.segments/auth/error/__PAGE__.segment.rsc +1 -1
- package/mcp-server/.next/server/app/auth/error.segments/auth/error.segment.rsc +1 -1
- package/mcp-server/.next/server/app/auth/error.segments/auth.segment.rsc +1 -1
- package/mcp-server/.next/server/app/index.html +1 -1
- package/mcp-server/.next/server/app/index.rsc +1 -1
- package/mcp-server/.next/server/app/index.segments/__PAGE__.segment.rsc +1 -1
- package/mcp-server/.next/server/app/index.segments/_full.segment.rsc +1 -1
- package/mcp-server/.next/server/app/index.segments/_index.segment.rsc +1 -1
- package/mcp-server/.next/server/app/index.segments/_tree.segment.rsc +1 -1
- package/mcp-server/.next/server/chunks/5e4c3_next_dist_esm_build_templates_app-route_22611d04.js +106 -106
- package/mcp-server/.next/server/chunks/5e4c3_next_dist_esm_build_templates_app-route_22611d04.js.map +1 -1
- package/mcp-server/.next/server/chunks/[root-of-the-server]__2e1a5f43._.js.map +1 -1
- package/mcp-server/.next/server/chunks/[root-of-the-server]__8a84f9f4._.js +13 -3
- package/mcp-server/.next/server/chunks/[root-of-the-server]__8a84f9f4._.js.map +1 -1
- package/mcp-server/.next/server/chunks/[root-of-the-server]__cc067478._.js.map +1 -1
- package/mcp-server/.next/server/chunks/[root-of-the-server]__dec55307._.js +64 -64
- package/mcp-server/.next/server/chunks/[root-of-the-server]__dec55307._.js.map +1 -1
- package/mcp-server/.next/server/server-reference-manifest.js +1 -1
- package/mcp-server/.next/server/server-reference-manifest.json +1 -1
- package/mcp-server/app/api/cloud/start-fix/route.ts +2 -2
- package/mcp-server/app/mcp/tools.ts +34 -4
- package/mcp-server/next-env.d.ts +1 -1
- package/mcp-server/package.json +1 -1
- package/package.json +1 -1
- /package/mcp-server/.next/static/{BPOqN_mYRkwZey5aViiMr → wKql3X2v8Qm8F_X099H8t}/_buildManifest.js +0 -0
- /package/mcp-server/.next/static/{BPOqN_mYRkwZey5aViiMr → wKql3X2v8Qm8F_X099H8t}/_clientMiddlewareManifest.json +0 -0
- /package/mcp-server/.next/static/{BPOqN_mYRkwZey5aViiMr → wKql3X2v8Qm8F_X099H8t}/_ssgManifest.js +0 -0
package/mcp-server/.next/server/chunks/5e4c3_next_dist_esm_build_templates_app-route_22611d04.js
CHANGED
|
@@ -44,7 +44,108 @@ Create an API key: https://vercel.com/d?to=%2F%5Bteam%5D%2F%7E%2Fai%2Fapi-keys
|
|
|
44
44
|
Provide via 'apiKey' option or 'AI_GATEWAY_API_KEY' environment variable.
|
|
45
45
|
|
|
46
46
|
Option 2 - OIDC token:
|
|
47
|
-
Run 'npx vercel link' to link your project, then 'vc env pull' to fetch the token.`,statusCode:i,cause:a})}},uJ="GatewayInvalidRequestError",uB=Symbol.for(`vercel.ai.gateway.error.${uJ}`),uV=class extends(f=uR,m=uB,f){constructor({message:e="Invalid request",statusCode:t=400,cause:r}={}){super({message:e,statusCode:t,cause:r}),this[m]=!0,this.name=uJ,this.type="invalid_request_error"}static isInstance(e){return uR.hasMarker(e)&&uB in e}},uK="GatewayRateLimitError",uG=Symbol.for(`vercel.ai.gateway.error.${uK}`),uW=class extends(v=uR,g=uG,v){constructor({message:e="Rate limit exceeded",statusCode:t=429,cause:r}={}){super({message:e,statusCode:t,cause:r}),this[g]=!0,this.name=uK,this.type="rate_limit_exceeded"}static isInstance(e){return uR.hasMarker(e)&&uG in e}},uq="GatewayModelNotFoundError",uH=Symbol.for(`vercel.ai.gateway.error.${uq}`),uY=rl(()=>rV(uA.object({modelId:uA.string()}))),uX=class extends(y=uR,h=uH,y){constructor({message:e="Model not found",statusCode:t=404,modelId:r,cause:n}={}){super({message:e,statusCode:t,cause:n}),this[h]=!0,this.name=uq,this.type="model_not_found",this.modelId=r}static isInstance(e){return uR.hasMarker(e)&&uH in e}},uQ="GatewayInternalServerError",u0=Symbol.for(`vercel.ai.gateway.error.${uQ}`),u4=class extends(b=uR,$=u0,b){constructor({message:e="Internal server error",statusCode:t=500,cause:r}={}){super({message:e,statusCode:t,cause:r}),this[$]=!0,this.name=uQ,this.type="internal_server_error"}static isInstance(e){return uR.hasMarker(e)&&u0 in e}},u1="GatewayResponseError",u6=Symbol.for(`vercel.ai.gateway.error.${u1}`),u2=class extends(w=uR,_=u6,w){constructor({message:e="Invalid response from Gateway",statusCode:t=502,response:r,validationError:n,cause:i}={}){super({message:e,statusCode:t,cause:i}),this[_]=!0,this.name=u1,this.type="response_error",this.response=r,this.validationError=n}static isInstance(e){return uR.hasMarker(e)&&u6 in e}};async function u9({response:e,statusCode:t,defaultMessage:r="Gateway request failed",cause:n,authMethod:i}){let a=await rc({value:e,schema:u3});if(!a.success)return new u2({message:`Invalid error response format: ${r}`,statusCode:t,response:e,validationError:a.error,cause:n});let o=a.value,s=o.error.type,l=o.error.message;switch(s){case"authentication_error":return uM.createContextualError({apiKeyProvided:"api-key"===i,oidcTokenProvided:"oidc"===i,statusCode:t,cause:n});case"invalid_request_error":return new uV({message:l,statusCode:t,cause:n});case"rate_limit_exceeded":return new uW({message:l,statusCode:t,cause:n});case"model_not_found":{let e=await rc({value:o.error.param,schema:uY});return new uX({message:l,statusCode:t,modelId:e.success?e.value.modelId:void 0,cause:n})}default:return new u4({message:l,statusCode:t,cause:n})}}var u3=rl(()=>rV(uA.object({error:uA.object({message:uA.string(),type:uA.string().nullish(),param:uA.unknown().nullish(),code:uA.union([uA.string(),uA.number()]).nullish()})})));function u5(e,t){var r;return uR.isInstance(e)?e:ea.isInstance(e)?u9({response:function(e){if(void 0!==e.data)return e.data;if(null!=e.responseBody)try{return JSON.parse(e.responseBody)}catch(t){return e.responseBody}return{}}(e),statusCode:null!=(r=e.statusCode)?r:500,defaultMessage:"Gateway request failed",cause:e,authMethod:t}):u9({response:{},statusCode:500,defaultMessage:e instanceof Error?`Gateway request failed: ${e.message}`:"Unknown Gateway error",cause:e,authMethod:t})}var u7="ai-gateway-auth-method";async function u8(e){let t=await rc({value:e[u7],schema:ce});return t.success?t.value:void 0}var ce=rl(()=>rV(uA.union([uA.literal("api-key"),uA.literal("oidc")]))),ct=class{constructor(e){this.config=e}async getAvailableModels(){try{let{value:e}=await rr({url:`${this.config.baseURL}/config`,headers:await rv(this.config.headers()),successfulResponseHandler:ry(cr),failedResponseHandler:rh({errorSchema:uA.any(),errorToMessage:e=>e}),fetch:this.config.fetch});return e}catch(e){throw await u5(e)}}async getCredits(){try{let e=new URL(this.config.baseURL),{value:t}=await rr({url:`${e.origin}/v1/credits`,headers:await rv(this.config.headers()),successfulResponseHandler:ry(cn),failedResponseHandler:rh({errorSchema:uA.any(),errorToMessage:e=>e}),fetch:this.config.fetch});return t}catch(e){throw await u5(e)}}},cr=rl(()=>rV(uA.object({models:uA.array(uA.object({id:uA.string(),name:uA.string(),description:uA.string().nullish(),pricing:uA.object({input:uA.string(),output:uA.string(),input_cache_read:uA.string().nullish(),input_cache_write:uA.string().nullish()}).transform(({input:e,output:t,input_cache_read:r,input_cache_write:n})=>({input:e,output:t,...r?{cachedInputTokens:r}:{},...n?{cacheCreationInputTokens:n}:{}})).nullish(),specification:uA.object({specificationVersion:uA.literal("v2"),provider:uA.string(),modelId:uA.string()}),modelType:uA.enum(["language","embedding","image"]).nullish()}))}))),cn=rl(()=>rV(uA.object({balance:uA.string(),total_used:uA.string()}).transform(({balance:e,total_used:t})=>({balance:e,totalUsed:t})))),ci=class{constructor(e,t){this.modelId=e,this.config=t,this.specificationVersion="v2",this.supportedUrls={"*/*":[/.*/]}}get provider(){return this.config.provider}async getArgs(e){let{abortSignal:t,...r}=e;return{args:this.maybeEncodeFileParts(r),warnings:[]}}async doGenerate(e){let{args:t,warnings:r}=await this.getArgs(e),{abortSignal:n}=e,i=await rv(this.config.headers());try{let{responseHeaders:a,value:o,rawValue:s}=await rf({url:this.getUrl(),headers:tQ(i,e.headers,this.getModelConfigHeaders(this.modelId,!1),await rv(this.config.o11yHeaders)),body:t,successfulResponseHandler:ry(uA.any()),failedResponseHandler:rh({errorSchema:uA.any(),errorToMessage:e=>e}),...n&&{abortSignal:n},fetch:this.config.fetch});return{...o,request:{body:t},response:{headers:a,body:s},warnings:r}}catch(e){throw await u5(e,await u8(i))}}async doStream(e){let{args:t,warnings:r}=await this.getArgs(e),{abortSignal:n}=e,i=await rv(this.config.headers());try{let a,{value:o,responseHeaders:s}=await rf({url:this.getUrl(),headers:tQ(i,e.headers,this.getModelConfigHeaders(this.modelId,!0),await rv(this.config.o11yHeaders)),body:t,successfulResponseHandler:(a=uA.any(),async({response:e})=>{let t=t1(e);if(null==e.body)throw new eu({});return{responseHeaders:t,value:function({stream:e,schema:t}){return e.pipeThrough(new TextDecoderStream).pipeThrough(new eZ.EventSourceParserStream).pipeThrough(new TransformStream({async transform({data:e},r){"[DONE]"!==e&&r.enqueue(await rp({text:e,schema:t}))}}))}({stream:e.body,schema:a})}}),failedResponseHandler:rh({errorSchema:uA.any(),errorToMessage:e=>e}),...n&&{abortSignal:n},fetch:this.config.fetch});return{stream:o.pipeThrough(new TransformStream({start(e){r.length>0&&e.enqueue({type:"stream-start",warnings:r})},transform(t,r){if(t.success){let n=t.value;("raw"!==n.type||e.includeRawChunks)&&("response-metadata"===n.type&&n.timestamp&&"string"==typeof n.timestamp&&(n.timestamp=new Date(n.timestamp)),r.enqueue(n))}else r.error(t.error)}})),request:{body:t},response:{headers:s}}}catch(e){throw await u5(e,await u8(i))}}isFilePart(e){return e&&"object"==typeof e&&"type"in e&&"file"===e.type}maybeEncodeFileParts(e){for(let t of e.prompt)for(let e of t.content)if(this.isFilePart(e)&&e.data instanceof Uint8Array){let t=Uint8Array.from(e.data),r=Buffer.from(t).toString("base64");e.data=new URL(`data:${e.mediaType||"application/octet-stream"};base64,${r}`)}return e}getUrl(){return`${this.config.baseURL}/language-model`}getModelConfigHeaders(e,t){return{"ai-language-model-specification-version":"2","ai-language-model-id":e,"ai-language-model-streaming":String(t)}}},ca=class{constructor(e,t){this.modelId=e,this.config=t,this.specificationVersion="v2",this.maxEmbeddingsPerCall=2048,this.supportsParallelCalls=!0}get provider(){return this.config.provider}async doEmbed({values:e,headers:t,abortSignal:r,providerOptions:n}){var i;let a=await rv(this.config.headers());try{let{responseHeaders:o,value:s,rawValue:l}=await rf({url:this.getUrl(),headers:tQ(a,null!=t?t:{},this.getModelConfigHeaders(),await rv(this.config.o11yHeaders)),body:{input:1===e.length?e[0]:e,...n?{providerOptions:n}:{}},successfulResponseHandler:ry(co),failedResponseHandler:rh({errorSchema:uA.any(),errorToMessage:e=>e}),...r&&{abortSignal:r},fetch:this.config.fetch});return{embeddings:s.embeddings,usage:null!=(i=s.usage)?i:void 0,providerMetadata:s.providerMetadata,response:{headers:o,body:l}}}catch(e){throw await u5(e,await u8(a))}}getUrl(){return`${this.config.baseURL}/embedding-model`}getModelConfigHeaders(){return{"ai-embedding-model-specification-version":"2","ai-model-id":this.modelId}}},co=rl(()=>rV(uA.object({embeddings:uA.array(uA.array(uA.number())),usage:uA.object({tokens:uA.number()}).nullish(),providerMetadata:uA.record(uA.string(),uA.record(uA.string(),uA.unknown())).optional()})));async function cs(){var e;return null==(e=(0,uD.getContext)().headers)?void 0:e["x-vercel-id"]}function cl(e={}){var t,r,n;let i=null,a=null,o=null!=(t=e.metadataCacheRefreshMillis)?t:3e5,s=0,l=null!=(r=null==(n=e.baseURL)?void 0:n.replace(/\/$/,""))?r:"https://ai-gateway.vercel.sh/v1/ai",u=async()=>{let t=await cc(e);if(t)return t8({Authorization:`Bearer ${t.token}`,"ai-gateway-protocol-version":"0.0.1",[u7]:t.authMethod,...e.headers},"ai-sdk/gateway/2.0.7");throw uM.createContextualError({apiKeyProvided:!1,oidcTokenProvided:!1,statusCode:401})},c=()=>{let e=rn({settingValue:void 0,environmentVariableName:"VERCEL_DEPLOYMENT_ID"}),t=rn({settingValue:void 0,environmentVariableName:"VERCEL_ENV"}),r=rn({settingValue:void 0,environmentVariableName:"VERCEL_REGION"});return async()=>{let n=await cs();return{...e&&{"ai-o11y-deployment-id":e},...t&&{"ai-o11y-environment":t},...r&&{"ai-o11y-region":r},...n&&{"ai-o11y-request-id":n}}}},d=t=>new ci(t,{provider:"gateway",baseURL:l,headers:u,fetch:e.fetch,o11yHeaders:c()}),p=async()=>new ct({baseURL:l,headers:u,fetch:e.fetch}).getCredits().catch(async e=>{throw await u5(e,await u8(await u()))}),m=function(e){if(new.target)throw Error("The Gateway Provider model function cannot be called with the new keyword.");return d(e)};return m.getAvailableModels=async()=>{var t,r,n;let c=null!=(n=null==(r=null==(t=e._internal)?void 0:t.currentDate)?void 0:r.call(t).getTime())?n:Date.now();return(!i||c-s>o)&&(s=c,i=new ct({baseURL:l,headers:u,fetch:e.fetch}).getAvailableModels().then(e=>(a=e,e)).catch(async e=>{throw await u5(e,await u8(await u()))})),a?Promise.resolve(a):i},m.getCredits=p,m.imageModel=e=>{throw new eS({modelId:e,modelType:"imageModel"})},m.languageModel=d,m.textEmbeddingModel=t=>new ca(t,{provider:"gateway",baseURL:l,headers:u,fetch:e.fetch,o11yHeaders:c()}),m}var cu=cl();async function cc(e){let t=rn({settingValue:e.apiKey,environmentVariableName:"AI_GATEWAY_API_KEY"});if(t)return{token:t,authMethod:"api-key"};try{return{token:await (0,uD.getVercelOidcToken)(),authMethod:"oidc"}}catch(e){return null}}var uA=uA,cd=e.i(74812),cp=e.i(14664),cm=Object.defineProperty,cf="AI_NoOutputSpecifiedError",cg=`vercel.ai.error.${cf}`,cv=Symbol.for(cg),ch=class extends et{constructor({message:e="No output specified."}={}){super({name:cf,message:e}),this[x]=!0}static isInstance(e){return et.hasMarker(e,cg)}};x=cv;var cy=!1,c$=e=>{if(0===e.length)return;let t=globalThis.AI_SDK_LOG_WARNINGS;if(!1!==t){if("function"==typeof t)return void t(e);for(let t of(cy||(cy=!0,console.info("AI SDK Warning System: To turn off warning logging, set the AI_SDK_LOG_WARNINGS global to false.")),e))console.warn(function(e){let t="AI SDK Warning:";switch(e.type){case"unsupported-setting":{let r=`${t} The "${e.setting}" setting is not supported by this model`;return e.details&&(r+=` - ${e.details}`),r}case"unsupported-tool":{let r="name"in e.tool?e.tool.name:"unknown tool",n=`${t} The tool "${r}" is not supported by this model`;return e.details&&(n+=` - ${e.details}`),n}case"other":return`${t} ${e.message}`;default:return`${t} ${JSON.stringify(e,null,2)}`}}(t))}},cb="AI_InvalidArgumentError",c_=`vercel.ai.error.${cb}`,cw=Symbol.for(c_),cx=class extends et{constructor({parameter:e,value:t,message:r}){super({name:cb,message:`Invalid argument for parameter ${e}: ${r}`}),this[k]=!0,this.parameter=e,this.value=t}static isInstance(e){return et.hasMarker(e,c_)}};k=cw,Symbol.for("vercel.ai.error.AI_InvalidStreamPartError");var ck="AI_InvalidToolInputError",cI=`vercel.ai.error.${ck}`,cS=Symbol.for(cI),cO=class extends et{constructor({toolInput:e,toolName:t,cause:r,message:n=`Invalid input for tool ${t}: ${ec(r)}`}){super({name:ck,message:n,cause:r}),this[I]=!0,this.toolInput=e,this.toolName=t}static isInstance(e){return et.hasMarker(e,cI)}};I=cS,Symbol.for("vercel.ai.error.AI_NoImageGeneratedError");var cP="AI_NoObjectGeneratedError",cE=`vercel.ai.error.${cP}`,cN=Symbol.for(cE),cZ=class extends et{constructor({message:e="No object generated.",cause:t,text:r,response:n,usage:i,finishReason:a}){super({name:cP,message:e,cause:t}),this[S]=!0,this.text=r,this.response=n,this.usage=i,this.finishReason=a}static isInstance(e){return et.hasMarker(e,cE)}};S=cN,Symbol.for("vercel.ai.error.AI_NoOutputGeneratedError");var cz="AI_NoSuchToolError",cT=`vercel.ai.error.${cz}`,cj=Symbol.for(cT),cU=class extends et{constructor({toolName:e,availableTools:t,message:r=`Model tried to call unavailable tool '${e}'. ${void 0===t?"No tools are available.":`Available tools: ${t.join(", ")}.`}`}){super({name:cz,message:r}),this[O]=!0,this.toolName=e,this.availableTools=t}static isInstance(e){return et.hasMarker(e,cT)}};O=cj;var cA="AI_ToolCallRepairError",cD=`vercel.ai.error.${cA}`,cC=Symbol.for(cD),cR=class extends et{constructor({cause:e,originalError:t,message:r=`Error repairing tool call: ${ec(e)}`}){super({name:cA,message:r,cause:e}),this[P]=!0,this.originalError=t}static isInstance(e){return et.hasMarker(e,cD)}};P=cC;var cL=class extends et{constructor(e){super({name:"AI_UnsupportedModelVersionError",message:`Unsupported model version ${e.version} for provider "${e.provider}" and model "${e.modelId}". AI SDK 5 only supports models that implement specification version "v2".`}),this.version=e.version,this.provider=e.provider,this.modelId=e.modelId}},cF=(Symbol.for("vercel.ai.error.AI_InvalidDataContentError"),"AI_InvalidMessageRoleError"),cM=`vercel.ai.error.${cF}`,cJ=Symbol.for(cM),cB=class extends et{constructor({role:e,message:t=`Invalid message role: '${e}'. Must be one of: "system", "user", "assistant", "tool".`}){super({name:cF,message:t}),this[E]=!0,this.role=e}static isInstance(e){return et.hasMarker(e,cM)}};E=cJ,Symbol.for("vercel.ai.error.AI_MessageConversionError");var cV="AI_DownloadError",cK=`vercel.ai.error.${cV}`,cG=Symbol.for(cK),cW=class extends et{constructor({url:e,statusCode:t,statusText:r,cause:n,message:i=null==n?`Failed to download ${e}: ${t} ${r}`:`Failed to download ${e}: ${n}`}){super({name:cV,message:i,cause:n}),this[N]=!0,this.url=e,this.statusCode=t,this.statusText=r}static isInstance(e){return et.hasMarker(e,cK)}};N=cG;var cq="AI_RetryError",cH=`vercel.ai.error.${cq}`,cY=Symbol.for(cH),cX=class extends et{constructor({message:e,reason:t,errors:r}){super({name:cq,message:e}),this[Z]=!0,this.reason=t,this.errors=r,this.lastError=r[r.length-1]}static isInstance(e){return et.hasMarker(e,cH)}};function cQ(e){var t;if("string"!=typeof e){if("v2"!==e.specificationVersion)throw new cL({version:e.specificationVersion,provider:e.provider,modelId:e.modelId});return e}return(null!=(t=globalThis.AI_SDK_DEFAULT_PROVIDER)?t:cu).languageModel(e)}Z=cY;var c0=[{mediaType:"image/gif",bytesPrefix:[71,73,70]},{mediaType:"image/png",bytesPrefix:[137,80,78,71]},{mediaType:"image/jpeg",bytesPrefix:[255,216]},{mediaType:"image/webp",bytesPrefix:[82,73,70,70,null,null,null,null,87,69,66,80]},{mediaType:"image/bmp",bytesPrefix:[66,77]},{mediaType:"image/tiff",bytesPrefix:[73,73,42,0]},{mediaType:"image/tiff",bytesPrefix:[77,77,0,42]},{mediaType:"image/avif",bytesPrefix:[0,0,0,32,102,116,121,112,97,118,105,102]},{mediaType:"image/heic",bytesPrefix:[0,0,0,32,102,116,121,112,104,101,105,99]}],c4="5.0.89",c1=async({url:e})=>{var t;let r=e.toString();try{let e=await fetch(r,{headers:t8({},`ai-sdk/${c4}`,t7())});if(!e.ok)throw new cW({url:r,statusCode:e.status,statusText:e.statusText});return{data:new Uint8Array(await e.arrayBuffer()),mediaType:null!=(t=e.headers.get("content-type"))?t:void 0}}catch(e){if(cW.isInstance(e))throw e;throw new cW({url:r,cause:e})}},c6=uA.union([uA.string(),uA.instanceof(Uint8Array),uA.instanceof(ArrayBuffer),uA.custom(e=>{var t,r;return null!=(r=null==(t=globalThis.Buffer)?void 0:t.isBuffer(e))&&r},{message:"Must be a Buffer"})]);function c2(e){if(e instanceof Uint8Array)return{data:e,mediaType:void 0};if(e instanceof ArrayBuffer)return{data:new Uint8Array(e),mediaType:void 0};if("string"==typeof e)try{e=new URL(e)}catch(e){}if(e instanceof URL&&"data:"===e.protocol){let{mediaType:t,base64Content:r}=function(e){try{let[t,r]=e.split(",");return{mediaType:t.split(";")[0].split(":")[1],base64Content:r}}catch(e){return{mediaType:void 0,base64Content:void 0}}}(e.toString());if(null==t||null==r)throw new et({name:"InvalidDataContentError",message:`Invalid data URL format in content ${e.toString()}`});return{data:r,mediaType:t}}return{data:e,mediaType:void 0}}async function c9({prompt:e,supportedUrls:t,download:r=((e=c1)=>t=>Promise.all(t.map(async t=>t.isUrlSupportedByModel?null:e(t))))()}){let n=await c3(e.messages,r,t);return[...null!=e.system?[{role:"system",content:e.system}]:[],...e.messages.map(e=>(function({message:e,downloadedAssets:t}){let r=e.role;switch(r){case"system":return{role:"system",content:e.content,providerOptions:e.providerOptions};case"user":if("string"==typeof e.content)return{role:"user",content:[{type:"text",text:e.content}],providerOptions:e.providerOptions};return{role:"user",content:e.content.map(e=>(function(e,t){var r;let n;if("text"===e.type)return{type:"text",text:e.text,providerOptions:e.providerOptions};let i=e.type;switch(i){case"image":n=e.image;break;case"file":n=e.data;break;default:throw Error(`Unsupported part type: ${i}`)}let{data:a,mediaType:o}=c2(n),s=null!=o?o:e.mediaType,l=a;if(l instanceof URL){let e=t[l.toString()];e&&(l=e.data,null!=s||(s=e.mediaType))}switch(i){case"image":return(l instanceof Uint8Array||"string"==typeof l)&&(s=null!=(r=function({data:e,signatures:t}){let r,n,i="string"==typeof e&&e.startsWith("SUQz")||"string"!=typeof e&&e.length>10&&73===e[0]&&68===e[1]&&51===e[2]?(n=(127&(r="string"==typeof e?rY(e):e)[6])<<21|(127&r[7])<<14|(127&r[8])<<7|127&r[9],r.slice(n+10)):e,a="string"==typeof i?rY(i.substring(0,Math.min(i.length,24))):i;for(let e of t)if(a.length>=e.bytesPrefix.length&&e.bytesPrefix.every((e,t)=>null===e||a[t]===e))return e.mediaType}({data:l,signatures:c0}))?r:s),{type:"file",mediaType:null!=s?s:"image/*",filename:void 0,data:l,providerOptions:e.providerOptions};case"file":if(null==s)throw Error("Media type is missing for file part");return{type:"file",mediaType:s,filename:e.filename,data:l,providerOptions:e.providerOptions}}})(e,t)).filter(e=>"text"!==e.type||""!==e.text),providerOptions:e.providerOptions};case"assistant":if("string"==typeof e.content)return{role:"assistant",content:[{type:"text",text:e.content}],providerOptions:e.providerOptions};return{role:"assistant",content:e.content.filter(e=>"text"!==e.type||""!==e.text||null!=e.providerOptions).map(e=>{let t=e.providerOptions;switch(e.type){case"file":{let{data:r,mediaType:n}=c2(e.data);return{type:"file",data:r,filename:e.filename,mediaType:null!=n?n:e.mediaType,providerOptions:t}}case"reasoning":return{type:"reasoning",text:e.text,providerOptions:t};case"text":return{type:"text",text:e.text,providerOptions:t};case"tool-call":return{type:"tool-call",toolCallId:e.toolCallId,toolName:e.toolName,input:e.input,providerExecuted:e.providerExecuted,providerOptions:t};case"tool-result":return{type:"tool-result",toolCallId:e.toolCallId,toolName:e.toolName,output:e.output,providerOptions:t}}}),providerOptions:e.providerOptions};case"tool":return{role:"tool",content:e.content.map(e=>({type:"tool-result",toolCallId:e.toolCallId,toolName:e.toolName,output:e.output,providerOptions:e.providerOptions})),providerOptions:e.providerOptions};default:throw new cB({role:r})}})({message:e,downloadedAssets:n}))]}async function c3(e,t,r){let n=e.filter(e=>"user"===e.role).map(e=>e.content).filter(e=>Array.isArray(e)).flat().filter(e=>"image"===e.type||"file"===e.type).map(e=>{var t;let r=null!=(t=e.mediaType)?t:"image"===e.type?"image/*":void 0,n="image"===e.type?e.image:e.data;if("string"==typeof n)try{n=new URL(n)}catch(e){}return{mediaType:r,data:n}}).filter(e=>e.data instanceof URL).map(e=>({url:e.data,isUrlSupportedByModel:null!=e.mediaType&&function({mediaType:e,url:t,supportedUrls:r}){return t=t.toLowerCase(),e=e.toLowerCase(),Object.entries(r).map(([e,t])=>{let r=e.toLowerCase();return"*"===r||"*/*"===r?{mediaTypePrefix:"",regexes:t}:{mediaTypePrefix:r.replace(/\*/,""),regexes:t}}).filter(({mediaTypePrefix:t})=>e.startsWith(t)).flatMap(({regexes:e})=>e).some(e=>e.test(t))}({url:e.data.toString(),mediaType:e.mediaType,supportedUrls:r})}));return Object.fromEntries((await t(n)).map((e,t)=>null==e?null:[n[t].url.toString(),{data:e.data,mediaType:e.mediaType}]).filter(e=>null!=e))}function c5({maxOutputTokens:e,temperature:t,topP:r,topK:n,presencePenalty:i,frequencyPenalty:a,seed:o,stopSequences:s}){if(null!=e){if(!Number.isInteger(e))throw new cx({parameter:"maxOutputTokens",value:e,message:"maxOutputTokens must be an integer"});if(e<1)throw new cx({parameter:"maxOutputTokens",value:e,message:"maxOutputTokens must be >= 1"})}if(null!=t&&"number"!=typeof t)throw new cx({parameter:"temperature",value:t,message:"temperature must be a number"});if(null!=r&&"number"!=typeof r)throw new cx({parameter:"topP",value:r,message:"topP must be a number"});if(null!=n&&"number"!=typeof n)throw new cx({parameter:"topK",value:n,message:"topK must be a number"});if(null!=i&&"number"!=typeof i)throw new cx({parameter:"presencePenalty",value:i,message:"presencePenalty must be a number"});if(null!=a&&"number"!=typeof a)throw new cx({parameter:"frequencyPenalty",value:a,message:"frequencyPenalty must be a number"});if(null!=o&&!Number.isInteger(o))throw new cx({parameter:"seed",value:o,message:"seed must be an integer"});return{maxOutputTokens:e,temperature:t,topP:r,topK:n,presencePenalty:i,frequencyPenalty:a,stopSequences:s,seed:o}}var c7=uA.lazy(()=>uA.union([uA.null(),uA.string(),uA.number(),uA.boolean(),uA.record(uA.string(),c7),uA.array(c7)])),c8=uA.record(uA.string(),uA.record(uA.string(),c7)),de=uA.object({type:uA.literal("text"),text:uA.string(),providerOptions:c8.optional()}),dt=uA.object({type:uA.literal("image"),image:uA.union([c6,uA.instanceof(URL)]),mediaType:uA.string().optional(),providerOptions:c8.optional()}),dr=uA.object({type:uA.literal("file"),data:uA.union([c6,uA.instanceof(URL)]),filename:uA.string().optional(),mediaType:uA.string(),providerOptions:c8.optional()}),dn=uA.object({type:uA.literal("reasoning"),text:uA.string(),providerOptions:c8.optional()}),di=uA.object({type:uA.literal("tool-call"),toolCallId:uA.string(),toolName:uA.string(),input:uA.unknown(),providerOptions:c8.optional(),providerExecuted:uA.boolean().optional()}),da=uA.discriminatedUnion("type",[uA.object({type:uA.literal("text"),value:uA.string()}),uA.object({type:uA.literal("json"),value:c7}),uA.object({type:uA.literal("error-text"),value:uA.string()}),uA.object({type:uA.literal("error-json"),value:c7}),uA.object({type:uA.literal("content"),value:uA.array(uA.union([uA.object({type:uA.literal("text"),text:uA.string()}),uA.object({type:uA.literal("media"),data:uA.string(),mediaType:uA.string()})]))})]),ds=uA.object({type:uA.literal("tool-result"),toolCallId:uA.string(),toolName:uA.string(),output:da,providerOptions:c8.optional()}),dl=uA.object({role:uA.literal("system"),content:uA.string(),providerOptions:c8.optional()}),du=uA.object({role:uA.literal("user"),content:uA.union([uA.string(),uA.array(uA.union([de,dt,dr]))]),providerOptions:c8.optional()}),dc=uA.object({role:uA.literal("assistant"),content:uA.union([uA.string(),uA.array(uA.union([de,dr,dn,di,ds]))]),providerOptions:c8.optional()}),dd=uA.object({role:uA.literal("tool"),content:uA.array(ds),providerOptions:c8.optional()}),dp=uA.union([dl,du,dc,dd]);async function dm(e){let t;if(null==e.prompt&&null==e.messages)throw new ey({prompt:e,message:"prompt or messages must be defined"});if(null!=e.prompt&&null!=e.messages)throw new ey({prompt:e,message:"prompt and messages cannot be defined at the same time"});if(null!=e.system&&"string"!=typeof e.system)throw new ey({prompt:e,message:"system must be a string"});if(null!=e.prompt&&"string"==typeof e.prompt)t=[{role:"user",content:e.prompt}];else if(null!=e.prompt&&Array.isArray(e.prompt))t=e.prompt;else if(null!=e.messages)t=e.messages;else throw new ey({prompt:e,message:"prompt or messages must be defined"});if(0===t.length)throw new ey({prompt:e,message:"messages must not be empty"});let r=await rc({value:t,schema:uA.array(dp)});if(!r.success)throw new ey({prompt:e,message:"The messages must be a ModelMessage[]. If you have passed a UIMessage[], you can use convertToModelMessages to convert them.",cause:r.error});return{messages:t,system:e.system}}function df({operationId:e,telemetry:t}){return{"operation.name":`${e}${(null==t?void 0:t.functionId)!=null?` ${t.functionId}`:""}`,"resource.name":null==t?void 0:t.functionId,"ai.operationId":e,"ai.telemetry.functionId":null==t?void 0:t.functionId}}var dg={startSpan:()=>dv,startActiveSpan:(e,t,r,n)=>"function"==typeof t?t(dv):"function"==typeof r?r(dv):"function"==typeof n?n(dv):void 0},dv={spanContext:()=>dh,setAttribute(){return this},setAttributes(){return this},addEvent(){return this},addLink(){return this},addLinks(){return this},setStatus(){return this},updateName(){return this},end(){return this},isRecording:()=>!1,recordException(){return this}},dh={traceId:"",spanId:"",traceFlags:0};function dy({name:e,tracer:t,attributes:r,fn:n,endWhenDone:i=!0}){return t.startActiveSpan(e,{attributes:r},async e=>{try{let t=await n(e);return i&&e.end(),t}catch(t){try{d$(e,t)}finally{e.end()}throw t}})}function d$(e,t){t instanceof Error?(e.recordException({name:t.name,message:t.message,stack:t.stack}),e.setStatus({code:cp.SpanStatusCode.ERROR,message:t.message})):e.setStatus({code:cp.SpanStatusCode.ERROR})}function db({telemetry:e,attributes:t}){return(null==e?void 0:e.isEnabled)!==!0?{}:Object.entries(t).reduce((t,[r,n])=>{if(null==n)return t;if("object"==typeof n&&"input"in n&&"function"==typeof n.input){if((null==e?void 0:e.recordInputs)===!1)return t;let i=n.input();return null==i?t:{...t,[r]:i}}if("object"==typeof n&&"output"in n&&"function"==typeof n.output){if((null==e?void 0:e.recordOutputs)===!1)return t;let i=n.output();return null==i?t:{...t,[r]:i}}return{...t,[r]:n}},{})}function d_(e,t){return null==e&&null==t?void 0:(null!=e?e:0)+(null!=t?t:0)}async function dw(e,{maxRetries:t,delayInMs:r,backoffFactor:n,abortSignal:i},a=[]){try{return await e()}catch(u){if(t9(u)||0===t)throw u;let o=t2(u),s=[...a,u],l=s.length;if(l>t)throw new cX({message:`Failed after ${l} attempts. Last error: ${o}`,reason:"maxRetriesExceeded",errors:s});if(u instanceof Error&&ea.isInstance(u)&&!0===u.isRetryable&&l<=t)return await t0(function({error:e,exponentialBackoffDelay:t}){let r,n=e.responseHeaders;if(!n)return t;let i=n["retry-after-ms"];if(i){let e=parseFloat(i);Number.isNaN(e)||(r=e)}let a=n["retry-after"];if(a&&void 0===r){let e=parseFloat(a);r=Number.isNaN(e)?Date.parse(a)-Date.now():1e3*e}return null!=r&&!Number.isNaN(r)&&0<=r&&(r<6e4||r<t)?r:t}({error:u,exponentialBackoffDelay:r}),{abortSignal:i}),dw(e,{maxRetries:t,delayInMs:n*r,backoffFactor:n,abortSignal:i},s);if(1===l)throw u;throw new cX({message:`Failed after ${l} attempts with non-retryable error: '${o}'`,reason:"errorNotRetryable",errors:s})}}function dx(e){let t=e.filter(e=>"text"===e.type);if(0!==t.length)return t.map(e=>e.text).join("")}var dk=class{constructor({data:e,mediaType:t}){const r=e instanceof Uint8Array;this.base64Data=r?void 0:e,this.uint8ArrayData=r?e:void 0,this.mediaType=t}get base64(){return null==this.base64Data&&(this.base64Data=rX(this.uint8ArrayData)),this.base64Data}get uint8Array(){return null==this.uint8ArrayData&&(this.uint8ArrayData=rY(this.base64Data)),this.uint8ArrayData}};async function dI({toolCall:e,tools:t,repairToolCall:r,system:n,messages:i}){try{if(null==t)throw new cU({toolName:e.toolName});try{return await dS({toolCall:e,tools:t})}catch(o){if(null==r||!(cU.isInstance(o)||cO.isInstance(o)))throw o;let a=null;try{a=await r({toolCall:e,tools:t,inputSchema:({toolName:e})=>{let{inputSchema:r}=t[e];return rW(r).jsonSchema},system:n,messages:i,error:o})}catch(e){throw new cR({cause:e,originalError:o})}if(null==a)throw o;return await dS({toolCall:a,tools:t})}}catch(n){let t=await rp({text:e.input}),r=t.success?t.value:e.input;return{type:"tool-call",toolCallId:e.toolCallId,toolName:e.toolName,input:r,dynamic:!0,invalid:!0,error:n}}}async function dS({toolCall:e,tools:t}){let r=e.toolName,n=t[r];if(null==n)throw new cU({toolName:e.toolName,availableTools:Object.keys(t)});let i=rW(n.inputSchema),a=""===e.input.trim()?await rc({value:{},schema:i}):await rp({text:e.input,schema:i});if(!1===a.success)throw new cO({toolName:r,toolInput:e.input,cause:a.error});return"dynamic"===n.type?{type:"tool-call",toolCallId:e.toolCallId,toolName:e.toolName,input:a.value,providerExecuted:e.providerExecuted,providerMetadata:e.providerMetadata,dynamic:!0}:{type:"tool-call",toolCallId:e.toolCallId,toolName:r,input:a.value,providerExecuted:e.providerExecuted,providerMetadata:e.providerMetadata}}var dO=class{constructor({content:e,finishReason:t,usage:r,warnings:n,request:i,response:a,providerMetadata:o}){this.content=e,this.finishReason=t,this.usage=r,this.warnings=n,this.request=i,this.response=a,this.providerMetadata=o}get text(){return this.content.filter(e=>"text"===e.type).map(e=>e.text).join("")}get reasoning(){return this.content.filter(e=>"reasoning"===e.type)}get reasoningText(){return 0===this.reasoning.length?void 0:this.reasoning.map(e=>e.text).join("")}get files(){return this.content.filter(e=>"file"===e.type).map(e=>e.file)}get sources(){return this.content.filter(e=>"source"===e.type)}get toolCalls(){return this.content.filter(e=>"tool-call"===e.type)}get staticToolCalls(){return this.toolCalls.filter(e=>!0!==e.dynamic)}get dynamicToolCalls(){return this.toolCalls.filter(e=>!0===e.dynamic)}get toolResults(){return this.content.filter(e=>"tool-result"===e.type)}get staticToolResults(){return this.toolResults.filter(e=>!0!==e.dynamic)}get dynamicToolResults(){return this.toolResults.filter(e=>!0===e.dynamic)}};async function dP({stopConditions:e,steps:t}){return(await Promise.all(e.map(e=>e({steps:t})))).some(e=>e)}function dE({output:e,tool:t,errorMode:r}){return"text"===r?{type:"error-text",value:ec(e)}:"json"===r?{type:"error-json",value:dN(e)}:(null==t?void 0:t.toModelOutput)?t.toModelOutput(e):"string"==typeof e?{type:"text",value:e}:{type:"json",value:dN(e)}}function dN(e){return void 0===e?null:e}var dZ=t6({prefix:"aitxt",size:24});async function dz({model:e,tools:t,toolChoice:r,system:n,prompt:i,messages:a,maxRetries:o,abortSignal:s,headers:l,stopWhen:u=function(e){return({steps:e})=>1===e.length}(0),experimental_output:c,experimental_telemetry:d,providerOptions:p,experimental_activeTools:m,activeTools:f=m,experimental_prepareStep:g,prepareStep:v=g,experimental_repairToolCall:h,experimental_download:y,experimental_context:$,_internal:{generateId:b=dZ,currentDate:_=()=>new Date}={},onStepFinish:w,...x}){let k=cQ(e),I=void 0===u?[]:Array.isArray(u)?u:[u],{maxRetries:S,retry:O}=function({maxRetries:e,abortSignal:t}){if(null!=e){if(!Number.isInteger(e))throw new cx({parameter:"maxRetries",value:e,message:"maxRetries must be an integer"});if(e<0)throw new cx({parameter:"maxRetries",value:e,message:"maxRetries must be >= 0"})}let r=null!=e?e:2;return{maxRetries:r,retry:(({maxRetries:e=2,initialDelayInMs:t=2e3,backoffFactor:r=2,abortSignal:n}={})=>async i=>dw(i,{maxRetries:e,delayInMs:t,backoffFactor:r,abortSignal:n}))({maxRetries:r,abortSignal:t})}}({maxRetries:o,abortSignal:s}),P=c5(x),E=t8(null!=l?l:{},`ai/${c4}`),N=function({model:e,settings:t,telemetry:r,headers:n}){var i;return{"ai.model.provider":e.provider,"ai.model.id":e.modelId,...Object.entries(t).reduce((e,[t,r])=>(e[`ai.settings.${t}`]=r,e),{}),...Object.entries(null!=(i=null==r?void 0:r.metadata)?i:{}).reduce((e,[t,r])=>(e[`ai.telemetry.metadata.${t}`]=r,e),{}),...Object.entries(null!=n?n:{}).reduce((e,[t,r])=>(void 0!==r&&(e[`ai.request.headers.${t}`]=r),e),{})}}({model:k,telemetry:d,headers:E,settings:{...P,maxRetries:S}}),Z=await dm({system:n,prompt:i,messages:a}),z=function({isEnabled:e=!1,tracer:t}={}){return e?t||cd.trace.getTracer("ai"):dg}(d);try{return await dy({name:"ai.generateText",attributes:db({telemetry:d,attributes:{...df({operationId:"ai.generateText",telemetry:d}),...N,"ai.model.provider":k.provider,"ai.model.id":k.modelId,"ai.prompt":{input:()=>JSON.stringify({system:n,prompt:i,messages:a})}}}),tracer:z,fn:async e=>{var i,a,o,l,u,m,g;let S,P,T=c5(x),j=[],U=[],A=[],D=[];do{let e=[...Z.messages,...A],I=await (null==v?void 0:v({model:k,steps:D,stepNumber:D.length,messages:e})),P=cQ(null!=(i=null==I?void 0:I.model)?i:k),C=await c9({prompt:{system:null!=(a=null==I?void 0:I.system)?a:Z.system,messages:null!=(o=null==I?void 0:I.messages)?o:e},supportedUrls:await P.supportedUrls,download:y}),{toolChoice:R,tools:L}=function({tools:e,toolChoice:t,activeTools:r}){return null!=e&&Object.keys(e).length>0?{tools:(null!=r?Object.entries(e).filter(([e])=>r.includes(e)):Object.entries(e)).map(([e,t])=>{let r=t.type;switch(r){case void 0:case"dynamic":case"function":return{type:"function",name:e,description:t.description,inputSchema:rW(t.inputSchema).jsonSchema,providerOptions:t.providerOptions};case"provider-defined":return{type:"provider-defined",name:e,id:t.id,args:t.args};default:throw Error(`Unsupported tool type: ${r}`)}}),toolChoice:null==t?{type:"auto"}:"string"==typeof t?{type:t}:{type:"tool",toolName:t.toolName}}:{tools:void 0,toolChoice:void 0}}({tools:t,toolChoice:null!=(l=null==I?void 0:I.toolChoice)?l:r,activeTools:null!=(u=null==I?void 0:I.activeTools)?u:f});S=await O(()=>{var e;return dy({name:"ai.generateText.doGenerate",attributes:db({telemetry:d,attributes:{...df({operationId:"ai.generateText.doGenerate",telemetry:d}),...N,"ai.model.provider":P.provider,"ai.model.id":P.modelId,"ai.prompt.messages":{input:()=>JSON.stringify(C.map(e=>({...e,content:"string"==typeof e.content?e.content:e.content.map(e=>{var t;return"file"===e.type?{...e,data:e.data instanceof Uint8Array?"string"==typeof(t=e.data)?t:t instanceof ArrayBuffer?rX(new Uint8Array(t)):rX(t):e.data}:e})})))},"ai.prompt.tools":{input:()=>null==L?void 0:L.map(e=>JSON.stringify(e))},"ai.prompt.toolChoice":{input:()=>null!=R?JSON.stringify(R):void 0},"gen_ai.system":P.provider,"gen_ai.request.model":P.modelId,"gen_ai.request.frequency_penalty":x.frequencyPenalty,"gen_ai.request.max_tokens":x.maxOutputTokens,"gen_ai.request.presence_penalty":x.presencePenalty,"gen_ai.request.stop_sequences":x.stopSequences,"gen_ai.request.temperature":null!=(e=x.temperature)?e:void 0,"gen_ai.request.top_k":x.topK,"gen_ai.request.top_p":x.topP}}),tracer:z,fn:async e=>{var t,r,n,i,a,o,l,u;let m=await P.doGenerate({...T,tools:L,toolChoice:R,responseFormat:null==c?void 0:c.responseFormat,prompt:C,providerOptions:p,abortSignal:s,headers:E}),f={id:null!=(r=null==(t=m.response)?void 0:t.id)?r:b(),timestamp:null!=(i=null==(n=m.response)?void 0:n.timestamp)?i:_(),modelId:null!=(o=null==(a=m.response)?void 0:a.modelId)?o:P.modelId,headers:null==(l=m.response)?void 0:l.headers,body:null==(u=m.response)?void 0:u.body};return e.setAttributes(db({telemetry:d,attributes:{"ai.response.finishReason":m.finishReason,"ai.response.text":{output:()=>dx(m.content)},"ai.response.toolCalls":{output:()=>{let e=dU(m.content);return null==e?void 0:JSON.stringify(e)}},"ai.response.id":f.id,"ai.response.model":f.modelId,"ai.response.timestamp":f.timestamp.toISOString(),"ai.response.providerMetadata":JSON.stringify(m.providerMetadata),"ai.usage.promptTokens":m.usage.inputTokens,"ai.usage.completionTokens":m.usage.outputTokens,"gen_ai.response.finish_reasons":[m.finishReason],"gen_ai.response.id":f.id,"gen_ai.response.model":f.modelId,"gen_ai.usage.input_tokens":m.usage.inputTokens,"gen_ai.usage.output_tokens":m.usage.outputTokens}})),{...m,response:f}}})});let F=await Promise.all(S.content.filter(e=>"tool-call"===e.type).map(r=>dI({toolCall:r,tools:t,repairToolCall:h,system:n,messages:e})));for(let r of F){if(r.invalid)continue;let n=t[r.toolName];(null==n?void 0:n.onInputAvailable)!=null&&await n.onInputAvailable({input:r.input,toolCallId:r.toolCallId,messages:e,abortSignal:s,experimental_context:$})}let M=F.filter(e=>e.invalid&&e.dynamic);for(let e of(U=[],M))U.push({type:"tool-error",toolCallId:e.toolCallId,toolName:e.toolName,input:e.input,error:t2(e.error),dynamic:!0});j=F.filter(e=>!e.providerExecuted),null!=t&&U.push(...await dT({toolCalls:j.filter(e=>!e.invalid),tools:t,tracer:z,telemetry:d,messages:e,abortSignal:s,experimental_context:$}));let J=function({content:e,toolCalls:t,toolOutputs:r}){return[...e.map(e=>{switch(e.type){case"text":case"reasoning":case"source":return e;case"file":return{type:"file",file:new dk(e)};case"tool-call":return t.find(t=>t.toolCallId===e.toolCallId);case"tool-result":{let r=t.find(t=>t.toolCallId===e.toolCallId);if(null==r)throw Error(`Tool call ${e.toolCallId} not found.`);if(e.isError)return{type:"tool-error",toolCallId:e.toolCallId,toolName:e.toolName,input:r.input,error:e.result,providerExecuted:!0,dynamic:r.dynamic};return{type:"tool-result",toolCallId:e.toolCallId,toolName:e.toolName,input:r.input,output:e.result,providerExecuted:!0,dynamic:r.dynamic}}}}),...r]}({content:S.content,toolCalls:F,toolOutputs:U});A.push(...function({content:e,tools:t}){let r=[],n=e.filter(e=>"source"!==e.type).filter(e=>("tool-result"!==e.type||e.providerExecuted)&&("tool-error"!==e.type||e.providerExecuted)).filter(e=>"text"!==e.type||e.text.length>0).map(e=>{switch(e.type){case"text":return{type:"text",text:e.text,providerOptions:e.providerMetadata};case"reasoning":return{type:"reasoning",text:e.text,providerOptions:e.providerMetadata};case"file":return{type:"file",data:e.file.base64,mediaType:e.file.mediaType,providerOptions:e.providerMetadata};case"tool-call":return{type:"tool-call",toolCallId:e.toolCallId,toolName:e.toolName,input:e.input,providerExecuted:e.providerExecuted,providerOptions:e.providerMetadata};case"tool-result":return{type:"tool-result",toolCallId:e.toolCallId,toolName:e.toolName,output:dE({tool:null==t?void 0:t[e.toolName],output:e.output,errorMode:"none"}),providerExecuted:!0,providerOptions:e.providerMetadata};case"tool-error":return{type:"tool-result",toolCallId:e.toolCallId,toolName:e.toolName,output:dE({tool:null==t?void 0:t[e.toolName],output:e.error,errorMode:"json"}),providerOptions:e.providerMetadata}}});n.length>0&&r.push({role:"assistant",content:n});let i=e.filter(e=>"tool-result"===e.type||"tool-error"===e.type).filter(e=>!e.providerExecuted).map(e=>({type:"tool-result",toolCallId:e.toolCallId,toolName:e.toolName,output:dE({tool:null==t?void 0:t[e.toolName],output:"tool-result"===e.type?e.output:e.error,errorMode:"tool-error"===e.type?"text":"none"})}));return i.length>0&&r.push({role:"tool",content:i}),r}({content:J,tools:t}));let B=new dO({content:J,finishReason:S.finishReason,usage:S.usage,warnings:S.warnings,providerMetadata:S.providerMetadata,request:null!=(m=S.request)?m:{},response:{...S.response,messages:structuredClone(A)}});c$(null!=(g=S.warnings)?g:[]),D.push(B),await (null==w?void 0:w(B))}while(j.length>0&&U.length===j.length&&!await dP({stopConditions:I,steps:D}))e.setAttributes(db({telemetry:d,attributes:{"ai.response.finishReason":S.finishReason,"ai.response.text":{output:()=>dx(S.content)},"ai.response.toolCalls":{output:()=>{let e=dU(S.content);return null==e?void 0:JSON.stringify(e)}},"ai.response.providerMetadata":JSON.stringify(S.providerMetadata),"ai.usage.promptTokens":S.usage.inputTokens,"ai.usage.completionTokens":S.usage.outputTokens}}));let C=D[D.length-1];return"stop"===C.finishReason&&(P=await (null==c?void 0:c.parseOutput({text:C.text},{response:C.response,usage:C.usage,finishReason:C.finishReason}))),new dj({steps:D,resolvedOutput:P})}})}catch(e){throw uM.isInstance(e)||uX.isInstance(e)?new et({name:"GatewayError",message:"Vercel AI Gateway access failed. If you want to use AI SDK providers directly, use the providers, e.g. @ai-sdk/openai, or register a different global default provider.",cause:e}):e}}async function dT({toolCalls:e,tools:t,tracer:r,telemetry:n,messages:i,abortSignal:a,experimental_context:o}){return(await Promise.all(e.map(async({toolCallId:e,toolName:s,input:l})=>{let u=t[s];if((null==u?void 0:u.execute)!=null)return dy({name:"ai.toolCall",attributes:db({telemetry:n,attributes:{...df({operationId:"ai.toolCall",telemetry:n}),"ai.toolCall.name":s,"ai.toolCall.id":e,"ai.toolCall.args":{output:()=>JSON.stringify(l)}}}),tracer:r,fn:async t=>{try{let r;for await(let t of rQ({execute:u.execute.bind(u),input:l,options:{toolCallId:e,messages:i,abortSignal:a,experimental_context:o}}))"final"===t.type&&(r=t.output);try{t.setAttributes(db({telemetry:n,attributes:{"ai.toolCall.result":{output:()=>JSON.stringify(r)}}}))}catch(e){}return{type:"tool-result",toolCallId:e,toolName:s,input:l,output:r,dynamic:"dynamic"===u.type}}catch(r){return d$(t,r),{type:"tool-error",toolCallId:e,toolName:s,input:l,error:r,dynamic:"dynamic"===u.type}}}})}))).filter(e=>null!=e)}var dj=class{constructor(e){this.steps=e.steps,this.resolvedOutput=e.resolvedOutput}get finalStep(){return this.steps[this.steps.length-1]}get content(){return this.finalStep.content}get text(){return this.finalStep.text}get files(){return this.finalStep.files}get reasoningText(){return this.finalStep.reasoningText}get reasoning(){return this.finalStep.reasoning}get toolCalls(){return this.finalStep.toolCalls}get staticToolCalls(){return this.finalStep.staticToolCalls}get dynamicToolCalls(){return this.finalStep.dynamicToolCalls}get toolResults(){return this.finalStep.toolResults}get staticToolResults(){return this.finalStep.staticToolResults}get dynamicToolResults(){return this.finalStep.dynamicToolResults}get sources(){return this.finalStep.sources}get finishReason(){return this.finalStep.finishReason}get warnings(){return this.finalStep.warnings}get providerMetadata(){return this.finalStep.providerMetadata}get response(){return this.finalStep.response}get request(){return this.finalStep.request}get usage(){return this.finalStep.usage}get totalUsage(){return this.steps.reduce((e,t)=>{var r;return r=t.usage,{inputTokens:d_(e.inputTokens,r.inputTokens),outputTokens:d_(e.outputTokens,r.outputTokens),totalTokens:d_(e.totalTokens,r.totalTokens),reasoningTokens:d_(e.reasoningTokens,r.reasoningTokens),cachedInputTokens:d_(e.cachedInputTokens,r.cachedInputTokens)}},{inputTokens:void 0,outputTokens:void 0,totalTokens:void 0,reasoningTokens:void 0,cachedInputTokens:void 0})}get experimental_output(){if(null==this.resolvedOutput)throw new ch;return this.resolvedOutput}};function dU(e){let t=e.filter(e=>"tool-call"===e.type);if(0!==t.length)return t.map(e=>({toolCallId:e.toolCallId,toolName:e.toolName,input:e.input}))}async function dA(e){if(void 0===e)return{value:void 0,state:"undefined-input"};let t=await rp({text:e});return t.success?{value:t.value,state:"successful-parse"}:(t=await rp({text:function(e){let t=["ROOT"],r=-1,n=null;function i(e,i,a){switch(e){case'"':r=i,t.pop(),t.push(a),t.push("INSIDE_STRING");break;case"f":case"t":case"n":r=i,n=i,t.pop(),t.push(a),t.push("INSIDE_LITERAL");break;case"-":t.pop(),t.push(a),t.push("INSIDE_NUMBER");break;case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":r=i,t.pop(),t.push(a),t.push("INSIDE_NUMBER");break;case"{":r=i,t.pop(),t.push(a),t.push("INSIDE_OBJECT_START");break;case"[":r=i,t.pop(),t.push(a),t.push("INSIDE_ARRAY_START")}}function a(e,n){switch(e){case",":t.pop(),t.push("INSIDE_OBJECT_AFTER_COMMA");break;case"}":r=n,t.pop()}}function o(e,n){switch(e){case",":t.pop(),t.push("INSIDE_ARRAY_AFTER_COMMA");break;case"]":r=n,t.pop()}}for(let s=0;s<e.length;s++){let l=e[s];switch(t[t.length-1]){case"ROOT":i(l,s,"FINISH");break;case"INSIDE_OBJECT_START":switch(l){case'"':t.pop(),t.push("INSIDE_OBJECT_KEY");break;case"}":r=s,t.pop()}break;case"INSIDE_OBJECT_AFTER_COMMA":'"'===l&&(t.pop(),t.push("INSIDE_OBJECT_KEY"));break;case"INSIDE_OBJECT_KEY":'"'===l&&(t.pop(),t.push("INSIDE_OBJECT_AFTER_KEY"));break;case"INSIDE_OBJECT_AFTER_KEY":":"===l&&(t.pop(),t.push("INSIDE_OBJECT_BEFORE_VALUE"));break;case"INSIDE_OBJECT_BEFORE_VALUE":i(l,s,"INSIDE_OBJECT_AFTER_VALUE");break;case"INSIDE_OBJECT_AFTER_VALUE":a(l,s);break;case"INSIDE_STRING":switch(l){case'"':t.pop(),r=s;break;case"\\":t.push("INSIDE_STRING_ESCAPE");break;default:r=s}break;case"INSIDE_ARRAY_START":"]"===l?(r=s,t.pop()):(r=s,i(l,s,"INSIDE_ARRAY_AFTER_VALUE"));break;case"INSIDE_ARRAY_AFTER_VALUE":switch(l){case",":t.pop(),t.push("INSIDE_ARRAY_AFTER_COMMA");break;case"]":r=s,t.pop();break;default:r=s}break;case"INSIDE_ARRAY_AFTER_COMMA":i(l,s,"INSIDE_ARRAY_AFTER_VALUE");break;case"INSIDE_STRING_ESCAPE":t.pop(),r=s;break;case"INSIDE_NUMBER":switch(l){case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":r=s;break;case"e":case"E":case"-":case".":break;case",":t.pop(),"INSIDE_ARRAY_AFTER_VALUE"===t[t.length-1]&&o(l,s),"INSIDE_OBJECT_AFTER_VALUE"===t[t.length-1]&&a(l,s);break;case"}":t.pop(),"INSIDE_OBJECT_AFTER_VALUE"===t[t.length-1]&&a(l,s);break;case"]":t.pop(),"INSIDE_ARRAY_AFTER_VALUE"===t[t.length-1]&&o(l,s);break;default:t.pop()}break;case"INSIDE_LITERAL":{let i=e.substring(n,s+1);"false".startsWith(i)||"true".startsWith(i)||"null".startsWith(i)?r=s:(t.pop(),"INSIDE_OBJECT_AFTER_VALUE"===t[t.length-1]?a(l,s):"INSIDE_ARRAY_AFTER_VALUE"===t[t.length-1]&&o(l,s))}}}let s=e.slice(0,r+1);for(let r=t.length-1;r>=0;r--)switch(t[r]){case"INSIDE_STRING":s+='"';break;case"INSIDE_OBJECT_KEY":case"INSIDE_OBJECT_AFTER_KEY":case"INSIDE_OBJECT_AFTER_COMMA":case"INSIDE_OBJECT_START":case"INSIDE_OBJECT_BEFORE_VALUE":case"INSIDE_OBJECT_AFTER_VALUE":s+="}";break;case"INSIDE_ARRAY_START":case"INSIDE_ARRAY_AFTER_COMMA":case"INSIDE_ARRAY_AFTER_VALUE":s+="]";break;case"INSIDE_LITERAL":{let t=e.substring(n,e.length);"true".startsWith(t)?s+="true".slice(t.length):"false".startsWith(t)?s+="false".slice(t.length):"null".startsWith(t)&&(s+="null".slice(t.length))}}return s}(e)})).success?{value:t.value,state:"repaired-parse"}:{value:void 0,state:"failed-parse"}}TransformStream,rl(()=>rV(uA.union([uA.strictObject({type:uA.literal("text-start"),id:uA.string(),providerMetadata:c8.optional()}),uA.strictObject({type:uA.literal("text-delta"),id:uA.string(),delta:uA.string(),providerMetadata:c8.optional()}),uA.strictObject({type:uA.literal("text-end"),id:uA.string(),providerMetadata:c8.optional()}),uA.strictObject({type:uA.literal("error"),errorText:uA.string()}),uA.strictObject({type:uA.literal("tool-input-start"),toolCallId:uA.string(),toolName:uA.string(),providerExecuted:uA.boolean().optional(),dynamic:uA.boolean().optional()}),uA.strictObject({type:uA.literal("tool-input-delta"),toolCallId:uA.string(),inputTextDelta:uA.string()}),uA.strictObject({type:uA.literal("tool-input-available"),toolCallId:uA.string(),toolName:uA.string(),input:uA.unknown(),providerExecuted:uA.boolean().optional(),providerMetadata:c8.optional(),dynamic:uA.boolean().optional()}),uA.strictObject({type:uA.literal("tool-input-error"),toolCallId:uA.string(),toolName:uA.string(),input:uA.unknown(),providerExecuted:uA.boolean().optional(),providerMetadata:c8.optional(),dynamic:uA.boolean().optional(),errorText:uA.string()}),uA.strictObject({type:uA.literal("tool-output-available"),toolCallId:uA.string(),output:uA.unknown(),providerExecuted:uA.boolean().optional(),dynamic:uA.boolean().optional(),preliminary:uA.boolean().optional()}),uA.strictObject({type:uA.literal("tool-output-error"),toolCallId:uA.string(),errorText:uA.string(),providerExecuted:uA.boolean().optional(),dynamic:uA.boolean().optional()}),uA.strictObject({type:uA.literal("reasoning-start"),id:uA.string(),providerMetadata:c8.optional()}),uA.strictObject({type:uA.literal("reasoning-delta"),id:uA.string(),delta:uA.string(),providerMetadata:c8.optional()}),uA.strictObject({type:uA.literal("reasoning-end"),id:uA.string(),providerMetadata:c8.optional()}),uA.strictObject({type:uA.literal("source-url"),sourceId:uA.string(),url:uA.string(),title:uA.string().optional(),providerMetadata:c8.optional()}),uA.strictObject({type:uA.literal("source-document"),sourceId:uA.string(),mediaType:uA.string(),title:uA.string(),filename:uA.string().optional(),providerMetadata:c8.optional()}),uA.strictObject({type:uA.literal("file"),url:uA.string(),mediaType:uA.string(),providerMetadata:c8.optional()}),uA.strictObject({type:uA.custom(e=>"string"==typeof e&&e.startsWith("data-"),{message:'Type must start with "data-"'}),id:uA.string().optional(),data:uA.unknown(),transient:uA.boolean().optional()}),uA.strictObject({type:uA.literal("start-step")}),uA.strictObject({type:uA.literal("finish-step")}),uA.strictObject({type:uA.literal("start"),messageId:uA.string().optional(),messageMetadata:uA.unknown().optional()}),uA.strictObject({type:uA.literal("finish"),messageMetadata:uA.unknown().optional()}),uA.strictObject({type:uA.literal("abort")}),uA.strictObject({type:uA.literal("message-metadata"),messageMetadata:uA.unknown()})]))),t6({prefix:"aitxt",size:24}),t6({prefix:"aiobj",size:24}),t6({prefix:"aiobj",size:24});var dD={},dC={object:()=>dF,text:()=>dL};for(var dR in dC)cm(dD,dR,{get:dC[dR],enumerable:!0});var dL=()=>({type:"text",responseFormat:{type:"text"},parsePartial:async({text:e})=>({partial:e}),parseOutput:async({text:e})=>e}),dF=({schema:e})=>{let t=rW(e);return{type:"object",responseFormat:{type:"json",schema:t.jsonSchema},async parsePartial({text:e}){let t=await dA(e);switch(t.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":return{partial:t.value};default:{let e=t.state;throw Error(`Unsupported parse state: ${e}`)}}},async parseOutput({text:e},r){let n=await rp({text:e});if(!n.success)throw new cZ({message:"No object generated: could not parse the response.",cause:n.error,text:e,response:r.response,usage:r.usage,finishReason:r.finishReason});let i=await rc({value:n.value,schema:t});if(!i.success)throw new cZ({message:"No object generated: response did not match schema.",cause:i.error,text:e,response:r.response,usage:r.usage,finishReason:r.finishReason});return i.value}}};Symbol.for("vercel.ai.error.AI_NoSuchProviderError"),rl(()=>rV(uA.array(uA.object({id:uA.string(),role:uA.enum(["system","user","assistant"]),metadata:uA.unknown().optional(),parts:uA.array(uA.union([uA.object({type:uA.literal("text"),text:uA.string(),state:uA.enum(["streaming","done"]).optional(),providerMetadata:c8.optional()}),uA.object({type:uA.literal("reasoning"),text:uA.string(),state:uA.enum(["streaming","done"]).optional(),providerMetadata:c8.optional()}),uA.object({type:uA.literal("source-url"),sourceId:uA.string(),url:uA.string(),title:uA.string().optional(),providerMetadata:c8.optional()}),uA.object({type:uA.literal("source-document"),sourceId:uA.string(),mediaType:uA.string(),title:uA.string(),filename:uA.string().optional(),providerMetadata:c8.optional()}),uA.object({type:uA.literal("file"),mediaType:uA.string(),filename:uA.string().optional(),url:uA.string(),providerMetadata:c8.optional()}),uA.object({type:uA.literal("step-start")}),uA.object({type:uA.string().startsWith("data-"),id:uA.string().optional(),data:uA.unknown()}),uA.object({type:uA.literal("dynamic-tool"),toolName:uA.string(),toolCallId:uA.string(),state:uA.literal("input-streaming"),input:uA.unknown().optional(),providerExecuted:uA.boolean().optional(),output:uA.never().optional(),errorText:uA.never().optional()}),uA.object({type:uA.literal("dynamic-tool"),toolName:uA.string(),toolCallId:uA.string(),state:uA.literal("input-available"),input:uA.unknown(),providerExecuted:uA.boolean().optional(),output:uA.never().optional(),errorText:uA.never().optional(),callProviderMetadata:c8.optional()}),uA.object({type:uA.literal("dynamic-tool"),toolName:uA.string(),toolCallId:uA.string(),state:uA.literal("output-available"),input:uA.unknown(),providerExecuted:uA.boolean().optional(),output:uA.unknown(),errorText:uA.never().optional(),callProviderMetadata:c8.optional(),preliminary:uA.boolean().optional()}),uA.object({type:uA.literal("dynamic-tool"),toolName:uA.string(),toolCallId:uA.string(),state:uA.literal("output-error"),input:uA.unknown(),providerExecuted:uA.boolean().optional(),output:uA.never().optional(),errorText:uA.string(),callProviderMetadata:c8.optional()}),uA.object({type:uA.string().startsWith("tool-"),toolCallId:uA.string(),state:uA.literal("input-streaming"),providerExecuted:uA.boolean().optional(),input:uA.unknown().optional(),output:uA.never().optional(),errorText:uA.never().optional(),approval:uA.never().optional()}),uA.object({type:uA.string().startsWith("tool-"),toolCallId:uA.string(),state:uA.literal("input-available"),providerExecuted:uA.boolean().optional(),input:uA.unknown(),output:uA.never().optional(),errorText:uA.never().optional(),callProviderMetadata:c8.optional(),approval:uA.never().optional()}),uA.object({type:uA.string().startsWith("tool-"),toolCallId:uA.string(),state:uA.literal("approval-requested"),input:uA.unknown(),providerExecuted:uA.boolean().optional(),output:uA.never().optional(),errorText:uA.never().optional(),callProviderMetadata:c8.optional(),approval:uA.object({id:uA.string(),approved:uA.never().optional(),reason:uA.never().optional()})}),uA.object({type:uA.string().startsWith("tool-"),toolCallId:uA.string(),state:uA.literal("approval-responded"),input:uA.unknown(),providerExecuted:uA.boolean().optional(),output:uA.never().optional(),errorText:uA.never().optional(),callProviderMetadata:c8.optional(),approval:uA.object({id:uA.string(),approved:uA.boolean(),reason:uA.string().optional()})}),uA.object({type:uA.string().startsWith("tool-"),toolCallId:uA.string(),state:uA.literal("output-available"),providerExecuted:uA.boolean().optional(),input:uA.unknown(),output:uA.unknown(),errorText:uA.never().optional(),callProviderMetadata:c8.optional(),preliminary:uA.boolean().optional(),approval:uA.object({id:uA.string(),approved:uA.literal(!0),reason:uA.string().optional()}).optional()}),uA.object({type:uA.string().startsWith("tool-"),toolCallId:uA.string(),state:uA.literal("output-error"),providerExecuted:uA.boolean().optional(),input:uA.unknown(),output:uA.never().optional(),errorText:uA.string(),callProviderMetadata:c8.optional(),approval:uA.object({id:uA.string(),approved:uA.literal(!0),reason:uA.string().optional()}).optional()}),uA.object({type:uA.string().startsWith("tool-"),toolCallId:uA.string(),state:uA.literal("output-denied"),providerExecuted:uA.boolean().optional(),input:uA.unknown(),output:uA.never().optional(),errorText:uA.never().optional(),callProviderMetadata:c8.optional(),approval:uA.object({id:uA.string(),approved:uA.literal(!1),reason:uA.string().optional()})})]))}))));var dM=e.i(5898),dJ=e.i(27577);async function dB(e){let{repoUrl:t,branch:r="main",timeout:n="30m",projectDir:i="",framework:a="Next.js",packageManager:o="pnpm",debug:s=!1}=e,l=i||t.split("/").pop()?.replace(".git","")||"app";s&&(console.log("🚀 Creating d3k sandbox..."),console.log(` Repository: ${t}`),console.log(` Branch/SHA: ${r}${40===r.length?" (git commit SHA)":" (branch name)"}`),console.log(` Project: ${l}`),console.log(` Framework: ${a}`));let u=process.env.VERCEL_TOKEN||process.env.VERCEL_OIDC_TOKEN;if(!u)throw Error("Missing VERCEL_TOKEN or VERCEL_OIDC_TOKEN environment variable. Vercel AI Workflows should automatically provide VERCEL_OIDC_TOKEN. Check your workflow configuration and ensure it has access to Vercel API credentials.");s&&console.log(` Token type: ${process.env.VERCEL_OIDC_TOKEN?"OIDC":"static"}`);let c=(0,dJ.default)(n),d=await dM.Sandbox.create({teamId:process.env.VERCEL_TEAM_ID||"team_nLlpyC6REAqxydlFKbrMDlud",projectId:process.env.VERCEL_PROJECT_ID||"prj_21F00Vr3bXzc1VSC8D9j2YJUzd0Q",token:u,source:{url:`${t}.git`,type:"git",...r?{revision:r}:{}},resources:{vcpus:4},timeout:c,ports:[3e3,3684],runtime:"node22"});s&&console.log(" ✅ Sandbox created");try{let e=i?`/vercel/sandbox/${i}`:"/vercel/sandbox";s&&console.log(" 📦 Installing project dependencies...");let t=await d.runCommand({cmd:o,args:["install"],cwd:e,stdout:s?process.stdout:void 0,stderr:s?process.stderr:void 0});if(0!==t.exitCode)throw Error(`Project dependency installation failed with exit code ${t.exitCode}`);s&&console.log(" ✅ Project dependencies installed"),s&&console.log(" 📦 Installing d3k globally (pnpm i -g dev3000)...");let r=await d.runCommand({cmd:"pnpm",args:["i","-g","dev3000"],stdout:s?process.stdout:void 0,stderr:s?process.stderr:void 0});if(0!==r.exitCode)throw Error(`d3k installation failed with exit code ${r.exitCode}`);s&&console.log(" ✅ d3k installed globally"),s&&console.log(" 🚀 Starting d3k..."),await d.runCommand({cmd:"sh",args:["-c",`cd ${e} && MCP_SKIP_PERMISSIONS=true d3k --no-tui --debug > /tmp/d3k.log 2>&1`],detached:!0}),s&&console.log(" ⏳ Waiting for dev server..."),await dV(d,3e3,12e4);let n=d.domain(3e3);s&&console.log(` ✅ Dev server ready: ${n}`),s&&console.log(" ⏳ Waiting for MCP server..."),await dV(d,3684,6e4);let a=d.domain(3684);s&&console.log(` ✅ MCP server ready: ${a}`),s&&console.log(" ⏳ Waiting for d3k to initialize MCPs and browser..."),await new Promise(e=>setTimeout(e,1e4)),console.log(" 📋 Checking d3k logs...");let u=await d.runCommand({cmd:"tail",args:["-n","100","/tmp/d3k.log"]});if(0===u.exitCode){let e="string"==typeof u.stdout?u.stdout:"function"==typeof u.stdout?await u.stdout():String(u.stdout||"");console.log(" 📋 d3k log (last 100 lines):"),console.log(e)}else{console.log(` ⚠️ Could not read d3k logs (exit code: ${u.exitCode})`);let e="string"==typeof u.stderr?u.stderr:"function"==typeof u.stderr?await u.stderr():String(u.stderr||"");e&&console.log(` ⚠️ stderr: ${e}`)}return s&&console.log(" ✅ d3k sandbox ready!"),{sandbox:d,devUrl:n,mcpUrl:a,projectName:l,cleanup:async()=>{s&&console.log(" 🧹 Cleaning up sandbox..."),await d.stop(),s&&console.log(" ✅ Sandbox stopped")}}}catch(e){try{await d.stop()}catch{}throw e}}async function dV(e,t,r){let n=Date.now(),i=e.domain(t);for(;Date.now()-n<r;){try{let e=await fetch(i,{method:"HEAD"});if(e.ok||404===e.status)return}catch{}await new Promise(e=>setTimeout(e,1e3))}throw Error(`Server on port ${t} did not become ready within ${r}ms`)}e.i(43954);var dK=e.i(72972),dG=Object.defineProperty,dW=Object.getOwnPropertyNames,dq=(e,t)=>dG(e,"name",{value:t,configurable:!0}),dH=(e,t)=>function(){return e&&(t=(0,e[dW(e)[0]])(e=0)),t},dY=(e,t)=>{for(var r in t)dG(e,r,{get:t[r],enumerable:!0})},dX={};async function dQ(e,t,r,n,i){console.log(`[Step 0] Creating d3k sandbox for ${r}...`),console.log(`[Step 0] Repository: ${e}`),console.log(`[Step 0] Branch: ${t}`),console.log(`[Step 0] VERCEL_OIDC_TOKEN from env: ${!!process.env.VERCEL_OIDC_TOKEN}`),console.log(`[Step 0] VERCEL_OIDC_TOKEN passed as param: ${!!i}`),console.log(`[Step 0] VERCEL_TOKEN available: ${!!process.env.VERCEL_TOKEN}`),console.log(`[Step 0] User access token provided: ${!!n}`),i&&!process.env.VERCEL_OIDC_TOKEN&&(process.env.VERCEL_OIDC_TOKEN=i,console.log("[Step 0] Set VERCEL_OIDC_TOKEN from workflow context"));let a=await dB({repoUrl:e,branch:t,projectDir:"",packageManager:"pnpm",debug:!0});console.log("[Step 0] Sandbox created successfully"),console.log(`[Step 0] Dev URL: ${a.devUrl}`),console.log(`[Step 0] MCP URL: ${a.mcpUrl}`),console.log("[Step 0] Verifying sandbox URLs are accessible...");try{let e=await fetch(a.devUrl,{method:"HEAD"});console.log(`[Step 0] Dev server check: ${e.status} ${e.statusText}`)}catch(e){console.log(`[Step 0] Dev server check FAILED: ${e instanceof Error?e.message:String(e)}`)}try{let e=await fetch(`${a.mcpUrl}/mcp`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({jsonrpc:"2.0",id:0,method:"tools/list"})});if(console.log(`[Step 0] MCP server check: ${e.status} ${e.statusText}`),e.ok){let t=await e.text();console.log(`[Step 0] MCP server response length: ${t.length} bytes`),console.log(`[Step 0] MCP server response preview: ${t.substring(0,200)}`);try{let e=JSON.parse(t),r=e.result?.tools?.length||0;console.log(`[Step 0] MCP server has ${r} tools available`)}catch(e){console.log(`[Step 0] Failed to parse MCP response as JSON: ${e instanceof Error?e.message:String(e)}`),console.log(`[Step 0] Full response text: ${t}`)}}else{let t=await e.text();console.log(`[Step 0] MCP server returned error response: ${t}`)}}catch(e){console.log(`[Step 0] MCP server check FAILED: ${e instanceof Error?e.message:String(e)}`)}return{mcpUrl:a.mcpUrl,devUrl:a.devUrl}}async function d0(e,t,r){let n=!!r,i=r||e,a=n?e:null;console.log(`[Step 1] Fetching logs from: ${i}`),console.log(`[Step 1] Using sandbox: ${n?"yes":"no"}`),a&&console.log(`[Step 1] MCP URL: ${a}`),console.log(`[Step 1] Bypass token: ${t?"provided":"not provided"}`);try{let e=t?`${i}?x-vercel-protection-bypass=${t}`:i;if(console.log(`[Step 1] Final URL: ${e.replace(t||"","***")}`),n&&a){console.log("[Step 1] Using d3k MCP server to capture CLS metrics and errors..."),console.log("[Step 1] Validating d3k MCP server access...");try{let e=await fetch(`${a}/mcp`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({jsonrpc:"2.0",id:0,method:"tools/list"})});if(e.ok){let t=await e.text();try{let e=JSON.parse(t),r=e.result?.tools?.map(e=>e.name)||[];console.log(`[Step 1] \u2705 d3k MCP server accessible`),console.log(`[Step 1] Available tools (${r.length}): ${r.join(", ")}`);let n=r.some(e=>e.includes("chrome-devtools")),i=r.some(e=>e.includes("nextjs")),a=r.includes("fix_my_app");console.log(`[Step 1] Chrome DevTools MCP: ${n?"✅":"❌"}`),console.log(`[Step 1] Next.js DevTools MCP: ${i?"✅":"❌"}`),console.log(`[Step 1] fix_my_app tool: ${a?"✅":"❌"}`)}catch{console.log(`[Step 1] MCP server responded but couldn't parse tools list: ${t.substring(0,200)}`)}}else console.log(`[Step 1] \u26A0\uFE0F MCP server not accessible: ${e.status}`)}catch(e){console.log(`[Step 1] \u26A0\uFE0F Failed to validate MCP server: ${e instanceof Error?e.message:String(e)}`)}console.log("[Step 1] Navigating browser to app URL...");let t=await fetch(`${a}/mcp`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({jsonrpc:"2.0",id:0,method:"tools/call",params:{name:"execute_browser_action",arguments:{action:"navigate",params:{url:e}}}})});t.ok?console.log("[Step 1] Browser navigation completed"):console.log(`[Step 1] Browser navigation failed: ${t.status}`),console.log("[Step 1] Waiting 5s for page load..."),await new Promise(e=>setTimeout(e,5e3)),console.log("[Step 1] Fetching d3k logs from sandbox to verify it's working...");try{let e=await fetch(`${a}/api/logs`);if(e.ok){let t=await e.text();console.log(`[Step 1] d3k logs (last 1000 chars):
|
|
47
|
+
Run 'npx vercel link' to link your project, then 'vc env pull' to fetch the token.`,statusCode:i,cause:a})}},uJ="GatewayInvalidRequestError",uB=Symbol.for(`vercel.ai.gateway.error.${uJ}`),uV=class extends(f=uR,m=uB,f){constructor({message:e="Invalid request",statusCode:t=400,cause:r}={}){super({message:e,statusCode:t,cause:r}),this[m]=!0,this.name=uJ,this.type="invalid_request_error"}static isInstance(e){return uR.hasMarker(e)&&uB in e}},uK="GatewayRateLimitError",uG=Symbol.for(`vercel.ai.gateway.error.${uK}`),uW=class extends(v=uR,g=uG,v){constructor({message:e="Rate limit exceeded",statusCode:t=429,cause:r}={}){super({message:e,statusCode:t,cause:r}),this[g]=!0,this.name=uK,this.type="rate_limit_exceeded"}static isInstance(e){return uR.hasMarker(e)&&uG in e}},uq="GatewayModelNotFoundError",uH=Symbol.for(`vercel.ai.gateway.error.${uq}`),uY=rl(()=>rV(uA.object({modelId:uA.string()}))),uX=class extends(y=uR,h=uH,y){constructor({message:e="Model not found",statusCode:t=404,modelId:r,cause:n}={}){super({message:e,statusCode:t,cause:n}),this[h]=!0,this.name=uq,this.type="model_not_found",this.modelId=r}static isInstance(e){return uR.hasMarker(e)&&uH in e}},uQ="GatewayInternalServerError",u0=Symbol.for(`vercel.ai.gateway.error.${uQ}`),u4=class extends(b=uR,$=u0,b){constructor({message:e="Internal server error",statusCode:t=500,cause:r}={}){super({message:e,statusCode:t,cause:r}),this[$]=!0,this.name=uQ,this.type="internal_server_error"}static isInstance(e){return uR.hasMarker(e)&&u0 in e}},u1="GatewayResponseError",u6=Symbol.for(`vercel.ai.gateway.error.${u1}`),u2=class extends(w=uR,_=u6,w){constructor({message:e="Invalid response from Gateway",statusCode:t=502,response:r,validationError:n,cause:i}={}){super({message:e,statusCode:t,cause:i}),this[_]=!0,this.name=u1,this.type="response_error",this.response=r,this.validationError=n}static isInstance(e){return uR.hasMarker(e)&&u6 in e}};async function u9({response:e,statusCode:t,defaultMessage:r="Gateway request failed",cause:n,authMethod:i}){let a=await rc({value:e,schema:u3});if(!a.success)return new u2({message:`Invalid error response format: ${r}`,statusCode:t,response:e,validationError:a.error,cause:n});let o=a.value,s=o.error.type,l=o.error.message;switch(s){case"authentication_error":return uM.createContextualError({apiKeyProvided:"api-key"===i,oidcTokenProvided:"oidc"===i,statusCode:t,cause:n});case"invalid_request_error":return new uV({message:l,statusCode:t,cause:n});case"rate_limit_exceeded":return new uW({message:l,statusCode:t,cause:n});case"model_not_found":{let e=await rc({value:o.error.param,schema:uY});return new uX({message:l,statusCode:t,modelId:e.success?e.value.modelId:void 0,cause:n})}default:return new u4({message:l,statusCode:t,cause:n})}}var u3=rl(()=>rV(uA.object({error:uA.object({message:uA.string(),type:uA.string().nullish(),param:uA.unknown().nullish(),code:uA.union([uA.string(),uA.number()]).nullish()})})));function u5(e,t){var r;return uR.isInstance(e)?e:ea.isInstance(e)?u9({response:function(e){if(void 0!==e.data)return e.data;if(null!=e.responseBody)try{return JSON.parse(e.responseBody)}catch(t){return e.responseBody}return{}}(e),statusCode:null!=(r=e.statusCode)?r:500,defaultMessage:"Gateway request failed",cause:e,authMethod:t}):u9({response:{},statusCode:500,defaultMessage:e instanceof Error?`Gateway request failed: ${e.message}`:"Unknown Gateway error",cause:e,authMethod:t})}var u7="ai-gateway-auth-method";async function u8(e){let t=await rc({value:e[u7],schema:ce});return t.success?t.value:void 0}var ce=rl(()=>rV(uA.union([uA.literal("api-key"),uA.literal("oidc")]))),ct=class{constructor(e){this.config=e}async getAvailableModels(){try{let{value:e}=await rr({url:`${this.config.baseURL}/config`,headers:await rv(this.config.headers()),successfulResponseHandler:ry(cr),failedResponseHandler:rh({errorSchema:uA.any(),errorToMessage:e=>e}),fetch:this.config.fetch});return e}catch(e){throw await u5(e)}}async getCredits(){try{let e=new URL(this.config.baseURL),{value:t}=await rr({url:`${e.origin}/v1/credits`,headers:await rv(this.config.headers()),successfulResponseHandler:ry(cn),failedResponseHandler:rh({errorSchema:uA.any(),errorToMessage:e=>e}),fetch:this.config.fetch});return t}catch(e){throw await u5(e)}}},cr=rl(()=>rV(uA.object({models:uA.array(uA.object({id:uA.string(),name:uA.string(),description:uA.string().nullish(),pricing:uA.object({input:uA.string(),output:uA.string(),input_cache_read:uA.string().nullish(),input_cache_write:uA.string().nullish()}).transform(({input:e,output:t,input_cache_read:r,input_cache_write:n})=>({input:e,output:t,...r?{cachedInputTokens:r}:{},...n?{cacheCreationInputTokens:n}:{}})).nullish(),specification:uA.object({specificationVersion:uA.literal("v2"),provider:uA.string(),modelId:uA.string()}),modelType:uA.enum(["language","embedding","image"]).nullish()}))}))),cn=rl(()=>rV(uA.object({balance:uA.string(),total_used:uA.string()}).transform(({balance:e,total_used:t})=>({balance:e,totalUsed:t})))),ci=class{constructor(e,t){this.modelId=e,this.config=t,this.specificationVersion="v2",this.supportedUrls={"*/*":[/.*/]}}get provider(){return this.config.provider}async getArgs(e){let{abortSignal:t,...r}=e;return{args:this.maybeEncodeFileParts(r),warnings:[]}}async doGenerate(e){let{args:t,warnings:r}=await this.getArgs(e),{abortSignal:n}=e,i=await rv(this.config.headers());try{let{responseHeaders:a,value:o,rawValue:s}=await rf({url:this.getUrl(),headers:tQ(i,e.headers,this.getModelConfigHeaders(this.modelId,!1),await rv(this.config.o11yHeaders)),body:t,successfulResponseHandler:ry(uA.any()),failedResponseHandler:rh({errorSchema:uA.any(),errorToMessage:e=>e}),...n&&{abortSignal:n},fetch:this.config.fetch});return{...o,request:{body:t},response:{headers:a,body:s},warnings:r}}catch(e){throw await u5(e,await u8(i))}}async doStream(e){let{args:t,warnings:r}=await this.getArgs(e),{abortSignal:n}=e,i=await rv(this.config.headers());try{let a,{value:o,responseHeaders:s}=await rf({url:this.getUrl(),headers:tQ(i,e.headers,this.getModelConfigHeaders(this.modelId,!0),await rv(this.config.o11yHeaders)),body:t,successfulResponseHandler:(a=uA.any(),async({response:e})=>{let t=t1(e);if(null==e.body)throw new eu({});return{responseHeaders:t,value:function({stream:e,schema:t}){return e.pipeThrough(new TextDecoderStream).pipeThrough(new eZ.EventSourceParserStream).pipeThrough(new TransformStream({async transform({data:e},r){"[DONE]"!==e&&r.enqueue(await rp({text:e,schema:t}))}}))}({stream:e.body,schema:a})}}),failedResponseHandler:rh({errorSchema:uA.any(),errorToMessage:e=>e}),...n&&{abortSignal:n},fetch:this.config.fetch});return{stream:o.pipeThrough(new TransformStream({start(e){r.length>0&&e.enqueue({type:"stream-start",warnings:r})},transform(t,r){if(t.success){let n=t.value;("raw"!==n.type||e.includeRawChunks)&&("response-metadata"===n.type&&n.timestamp&&"string"==typeof n.timestamp&&(n.timestamp=new Date(n.timestamp)),r.enqueue(n))}else r.error(t.error)}})),request:{body:t},response:{headers:s}}}catch(e){throw await u5(e,await u8(i))}}isFilePart(e){return e&&"object"==typeof e&&"type"in e&&"file"===e.type}maybeEncodeFileParts(e){for(let t of e.prompt)for(let e of t.content)if(this.isFilePart(e)&&e.data instanceof Uint8Array){let t=Uint8Array.from(e.data),r=Buffer.from(t).toString("base64");e.data=new URL(`data:${e.mediaType||"application/octet-stream"};base64,${r}`)}return e}getUrl(){return`${this.config.baseURL}/language-model`}getModelConfigHeaders(e,t){return{"ai-language-model-specification-version":"2","ai-language-model-id":e,"ai-language-model-streaming":String(t)}}},ca=class{constructor(e,t){this.modelId=e,this.config=t,this.specificationVersion="v2",this.maxEmbeddingsPerCall=2048,this.supportsParallelCalls=!0}get provider(){return this.config.provider}async doEmbed({values:e,headers:t,abortSignal:r,providerOptions:n}){var i;let a=await rv(this.config.headers());try{let{responseHeaders:o,value:s,rawValue:l}=await rf({url:this.getUrl(),headers:tQ(a,null!=t?t:{},this.getModelConfigHeaders(),await rv(this.config.o11yHeaders)),body:{input:1===e.length?e[0]:e,...n?{providerOptions:n}:{}},successfulResponseHandler:ry(co),failedResponseHandler:rh({errorSchema:uA.any(),errorToMessage:e=>e}),...r&&{abortSignal:r},fetch:this.config.fetch});return{embeddings:s.embeddings,usage:null!=(i=s.usage)?i:void 0,providerMetadata:s.providerMetadata,response:{headers:o,body:l}}}catch(e){throw await u5(e,await u8(a))}}getUrl(){return`${this.config.baseURL}/embedding-model`}getModelConfigHeaders(){return{"ai-embedding-model-specification-version":"2","ai-model-id":this.modelId}}},co=rl(()=>rV(uA.object({embeddings:uA.array(uA.array(uA.number())),usage:uA.object({tokens:uA.number()}).nullish(),providerMetadata:uA.record(uA.string(),uA.record(uA.string(),uA.unknown())).optional()})));async function cs(){var e;return null==(e=(0,uD.getContext)().headers)?void 0:e["x-vercel-id"]}function cl(e={}){var t,r,n;let i=null,a=null,o=null!=(t=e.metadataCacheRefreshMillis)?t:3e5,s=0,l=null!=(r=null==(n=e.baseURL)?void 0:n.replace(/\/$/,""))?r:"https://ai-gateway.vercel.sh/v1/ai",u=async()=>{let t=await cc(e);if(t)return t8({Authorization:`Bearer ${t.token}`,"ai-gateway-protocol-version":"0.0.1",[u7]:t.authMethod,...e.headers},"ai-sdk/gateway/2.0.7");throw uM.createContextualError({apiKeyProvided:!1,oidcTokenProvided:!1,statusCode:401})},c=()=>{let e=rn({settingValue:void 0,environmentVariableName:"VERCEL_DEPLOYMENT_ID"}),t=rn({settingValue:void 0,environmentVariableName:"VERCEL_ENV"}),r=rn({settingValue:void 0,environmentVariableName:"VERCEL_REGION"});return async()=>{let n=await cs();return{...e&&{"ai-o11y-deployment-id":e},...t&&{"ai-o11y-environment":t},...r&&{"ai-o11y-region":r},...n&&{"ai-o11y-request-id":n}}}},d=t=>new ci(t,{provider:"gateway",baseURL:l,headers:u,fetch:e.fetch,o11yHeaders:c()}),p=async()=>new ct({baseURL:l,headers:u,fetch:e.fetch}).getCredits().catch(async e=>{throw await u5(e,await u8(await u()))}),m=function(e){if(new.target)throw Error("The Gateway Provider model function cannot be called with the new keyword.");return d(e)};return m.getAvailableModels=async()=>{var t,r,n;let c=null!=(n=null==(r=null==(t=e._internal)?void 0:t.currentDate)?void 0:r.call(t).getTime())?n:Date.now();return(!i||c-s>o)&&(s=c,i=new ct({baseURL:l,headers:u,fetch:e.fetch}).getAvailableModels().then(e=>(a=e,e)).catch(async e=>{throw await u5(e,await u8(await u()))})),a?Promise.resolve(a):i},m.getCredits=p,m.imageModel=e=>{throw new eS({modelId:e,modelType:"imageModel"})},m.languageModel=d,m.textEmbeddingModel=t=>new ca(t,{provider:"gateway",baseURL:l,headers:u,fetch:e.fetch,o11yHeaders:c()}),m}var cu=cl();async function cc(e){let t=rn({settingValue:e.apiKey,environmentVariableName:"AI_GATEWAY_API_KEY"});if(t)return{token:t,authMethod:"api-key"};try{return{token:await (0,uD.getVercelOidcToken)(),authMethod:"oidc"}}catch(e){return null}}var uA=uA,cd=e.i(74812),cp=e.i(14664),cm=Object.defineProperty,cf="AI_NoOutputSpecifiedError",cg=`vercel.ai.error.${cf}`,cv=Symbol.for(cg),ch=class extends et{constructor({message:e="No output specified."}={}){super({name:cf,message:e}),this[x]=!0}static isInstance(e){return et.hasMarker(e,cg)}};x=cv;var cy=!1,c$=e=>{if(0===e.length)return;let t=globalThis.AI_SDK_LOG_WARNINGS;if(!1!==t){if("function"==typeof t)return void t(e);for(let t of(cy||(cy=!0,console.info("AI SDK Warning System: To turn off warning logging, set the AI_SDK_LOG_WARNINGS global to false.")),e))console.warn(function(e){let t="AI SDK Warning:";switch(e.type){case"unsupported-setting":{let r=`${t} The "${e.setting}" setting is not supported by this model`;return e.details&&(r+=` - ${e.details}`),r}case"unsupported-tool":{let r="name"in e.tool?e.tool.name:"unknown tool",n=`${t} The tool "${r}" is not supported by this model`;return e.details&&(n+=` - ${e.details}`),n}case"other":return`${t} ${e.message}`;default:return`${t} ${JSON.stringify(e,null,2)}`}}(t))}},cb="AI_InvalidArgumentError",c_=`vercel.ai.error.${cb}`,cw=Symbol.for(c_),cx=class extends et{constructor({parameter:e,value:t,message:r}){super({name:cb,message:`Invalid argument for parameter ${e}: ${r}`}),this[k]=!0,this.parameter=e,this.value=t}static isInstance(e){return et.hasMarker(e,c_)}};k=cw,Symbol.for("vercel.ai.error.AI_InvalidStreamPartError");var ck="AI_InvalidToolInputError",cI=`vercel.ai.error.${ck}`,cS=Symbol.for(cI),cO=class extends et{constructor({toolInput:e,toolName:t,cause:r,message:n=`Invalid input for tool ${t}: ${ec(r)}`}){super({name:ck,message:n,cause:r}),this[I]=!0,this.toolInput=e,this.toolName=t}static isInstance(e){return et.hasMarker(e,cI)}};I=cS,Symbol.for("vercel.ai.error.AI_NoImageGeneratedError");var cP="AI_NoObjectGeneratedError",cE=`vercel.ai.error.${cP}`,cN=Symbol.for(cE),cZ=class extends et{constructor({message:e="No object generated.",cause:t,text:r,response:n,usage:i,finishReason:a}){super({name:cP,message:e,cause:t}),this[S]=!0,this.text=r,this.response=n,this.usage=i,this.finishReason=a}static isInstance(e){return et.hasMarker(e,cE)}};S=cN,Symbol.for("vercel.ai.error.AI_NoOutputGeneratedError");var cz="AI_NoSuchToolError",cT=`vercel.ai.error.${cz}`,cj=Symbol.for(cT),cU=class extends et{constructor({toolName:e,availableTools:t,message:r=`Model tried to call unavailable tool '${e}'. ${void 0===t?"No tools are available.":`Available tools: ${t.join(", ")}.`}`}){super({name:cz,message:r}),this[O]=!0,this.toolName=e,this.availableTools=t}static isInstance(e){return et.hasMarker(e,cT)}};O=cj;var cA="AI_ToolCallRepairError",cD=`vercel.ai.error.${cA}`,cC=Symbol.for(cD),cR=class extends et{constructor({cause:e,originalError:t,message:r=`Error repairing tool call: ${ec(e)}`}){super({name:cA,message:r,cause:e}),this[P]=!0,this.originalError=t}static isInstance(e){return et.hasMarker(e,cD)}};P=cC;var cL=class extends et{constructor(e){super({name:"AI_UnsupportedModelVersionError",message:`Unsupported model version ${e.version} for provider "${e.provider}" and model "${e.modelId}". AI SDK 5 only supports models that implement specification version "v2".`}),this.version=e.version,this.provider=e.provider,this.modelId=e.modelId}},cF=(Symbol.for("vercel.ai.error.AI_InvalidDataContentError"),"AI_InvalidMessageRoleError"),cM=`vercel.ai.error.${cF}`,cJ=Symbol.for(cM),cB=class extends et{constructor({role:e,message:t=`Invalid message role: '${e}'. Must be one of: "system", "user", "assistant", "tool".`}){super({name:cF,message:t}),this[E]=!0,this.role=e}static isInstance(e){return et.hasMarker(e,cM)}};E=cJ,Symbol.for("vercel.ai.error.AI_MessageConversionError");var cV="AI_DownloadError",cK=`vercel.ai.error.${cV}`,cG=Symbol.for(cK),cW=class extends et{constructor({url:e,statusCode:t,statusText:r,cause:n,message:i=null==n?`Failed to download ${e}: ${t} ${r}`:`Failed to download ${e}: ${n}`}){super({name:cV,message:i,cause:n}),this[N]=!0,this.url=e,this.statusCode=t,this.statusText=r}static isInstance(e){return et.hasMarker(e,cK)}};N=cG;var cq="AI_RetryError",cH=`vercel.ai.error.${cq}`,cY=Symbol.for(cH),cX=class extends et{constructor({message:e,reason:t,errors:r}){super({name:cq,message:e}),this[Z]=!0,this.reason=t,this.errors=r,this.lastError=r[r.length-1]}static isInstance(e){return et.hasMarker(e,cH)}};function cQ(e){var t;if("string"!=typeof e){if("v2"!==e.specificationVersion)throw new cL({version:e.specificationVersion,provider:e.provider,modelId:e.modelId});return e}return(null!=(t=globalThis.AI_SDK_DEFAULT_PROVIDER)?t:cu).languageModel(e)}Z=cY;var c0=[{mediaType:"image/gif",bytesPrefix:[71,73,70]},{mediaType:"image/png",bytesPrefix:[137,80,78,71]},{mediaType:"image/jpeg",bytesPrefix:[255,216]},{mediaType:"image/webp",bytesPrefix:[82,73,70,70,null,null,null,null,87,69,66,80]},{mediaType:"image/bmp",bytesPrefix:[66,77]},{mediaType:"image/tiff",bytesPrefix:[73,73,42,0]},{mediaType:"image/tiff",bytesPrefix:[77,77,0,42]},{mediaType:"image/avif",bytesPrefix:[0,0,0,32,102,116,121,112,97,118,105,102]},{mediaType:"image/heic",bytesPrefix:[0,0,0,32,102,116,121,112,104,101,105,99]}],c4="5.0.89",c1=async({url:e})=>{var t;let r=e.toString();try{let e=await fetch(r,{headers:t8({},`ai-sdk/${c4}`,t7())});if(!e.ok)throw new cW({url:r,statusCode:e.status,statusText:e.statusText});return{data:new Uint8Array(await e.arrayBuffer()),mediaType:null!=(t=e.headers.get("content-type"))?t:void 0}}catch(e){if(cW.isInstance(e))throw e;throw new cW({url:r,cause:e})}},c6=uA.union([uA.string(),uA.instanceof(Uint8Array),uA.instanceof(ArrayBuffer),uA.custom(e=>{var t,r;return null!=(r=null==(t=globalThis.Buffer)?void 0:t.isBuffer(e))&&r},{message:"Must be a Buffer"})]);function c2(e){if(e instanceof Uint8Array)return{data:e,mediaType:void 0};if(e instanceof ArrayBuffer)return{data:new Uint8Array(e),mediaType:void 0};if("string"==typeof e)try{e=new URL(e)}catch(e){}if(e instanceof URL&&"data:"===e.protocol){let{mediaType:t,base64Content:r}=function(e){try{let[t,r]=e.split(",");return{mediaType:t.split(";")[0].split(":")[1],base64Content:r}}catch(e){return{mediaType:void 0,base64Content:void 0}}}(e.toString());if(null==t||null==r)throw new et({name:"InvalidDataContentError",message:`Invalid data URL format in content ${e.toString()}`});return{data:r,mediaType:t}}return{data:e,mediaType:void 0}}async function c9({prompt:e,supportedUrls:t,download:r=((e=c1)=>t=>Promise.all(t.map(async t=>t.isUrlSupportedByModel?null:e(t))))()}){let n=await c3(e.messages,r,t);return[...null!=e.system?[{role:"system",content:e.system}]:[],...e.messages.map(e=>(function({message:e,downloadedAssets:t}){let r=e.role;switch(r){case"system":return{role:"system",content:e.content,providerOptions:e.providerOptions};case"user":if("string"==typeof e.content)return{role:"user",content:[{type:"text",text:e.content}],providerOptions:e.providerOptions};return{role:"user",content:e.content.map(e=>(function(e,t){var r;let n;if("text"===e.type)return{type:"text",text:e.text,providerOptions:e.providerOptions};let i=e.type;switch(i){case"image":n=e.image;break;case"file":n=e.data;break;default:throw Error(`Unsupported part type: ${i}`)}let{data:a,mediaType:o}=c2(n),s=null!=o?o:e.mediaType,l=a;if(l instanceof URL){let e=t[l.toString()];e&&(l=e.data,null!=s||(s=e.mediaType))}switch(i){case"image":return(l instanceof Uint8Array||"string"==typeof l)&&(s=null!=(r=function({data:e,signatures:t}){let r,n,i="string"==typeof e&&e.startsWith("SUQz")||"string"!=typeof e&&e.length>10&&73===e[0]&&68===e[1]&&51===e[2]?(n=(127&(r="string"==typeof e?rY(e):e)[6])<<21|(127&r[7])<<14|(127&r[8])<<7|127&r[9],r.slice(n+10)):e,a="string"==typeof i?rY(i.substring(0,Math.min(i.length,24))):i;for(let e of t)if(a.length>=e.bytesPrefix.length&&e.bytesPrefix.every((e,t)=>null===e||a[t]===e))return e.mediaType}({data:l,signatures:c0}))?r:s),{type:"file",mediaType:null!=s?s:"image/*",filename:void 0,data:l,providerOptions:e.providerOptions};case"file":if(null==s)throw Error("Media type is missing for file part");return{type:"file",mediaType:s,filename:e.filename,data:l,providerOptions:e.providerOptions}}})(e,t)).filter(e=>"text"!==e.type||""!==e.text),providerOptions:e.providerOptions};case"assistant":if("string"==typeof e.content)return{role:"assistant",content:[{type:"text",text:e.content}],providerOptions:e.providerOptions};return{role:"assistant",content:e.content.filter(e=>"text"!==e.type||""!==e.text||null!=e.providerOptions).map(e=>{let t=e.providerOptions;switch(e.type){case"file":{let{data:r,mediaType:n}=c2(e.data);return{type:"file",data:r,filename:e.filename,mediaType:null!=n?n:e.mediaType,providerOptions:t}}case"reasoning":return{type:"reasoning",text:e.text,providerOptions:t};case"text":return{type:"text",text:e.text,providerOptions:t};case"tool-call":return{type:"tool-call",toolCallId:e.toolCallId,toolName:e.toolName,input:e.input,providerExecuted:e.providerExecuted,providerOptions:t};case"tool-result":return{type:"tool-result",toolCallId:e.toolCallId,toolName:e.toolName,output:e.output,providerOptions:t}}}),providerOptions:e.providerOptions};case"tool":return{role:"tool",content:e.content.map(e=>({type:"tool-result",toolCallId:e.toolCallId,toolName:e.toolName,output:e.output,providerOptions:e.providerOptions})),providerOptions:e.providerOptions};default:throw new cB({role:r})}})({message:e,downloadedAssets:n}))]}async function c3(e,t,r){let n=e.filter(e=>"user"===e.role).map(e=>e.content).filter(e=>Array.isArray(e)).flat().filter(e=>"image"===e.type||"file"===e.type).map(e=>{var t;let r=null!=(t=e.mediaType)?t:"image"===e.type?"image/*":void 0,n="image"===e.type?e.image:e.data;if("string"==typeof n)try{n=new URL(n)}catch(e){}return{mediaType:r,data:n}}).filter(e=>e.data instanceof URL).map(e=>({url:e.data,isUrlSupportedByModel:null!=e.mediaType&&function({mediaType:e,url:t,supportedUrls:r}){return t=t.toLowerCase(),e=e.toLowerCase(),Object.entries(r).map(([e,t])=>{let r=e.toLowerCase();return"*"===r||"*/*"===r?{mediaTypePrefix:"",regexes:t}:{mediaTypePrefix:r.replace(/\*/,""),regexes:t}}).filter(({mediaTypePrefix:t})=>e.startsWith(t)).flatMap(({regexes:e})=>e).some(e=>e.test(t))}({url:e.data.toString(),mediaType:e.mediaType,supportedUrls:r})}));return Object.fromEntries((await t(n)).map((e,t)=>null==e?null:[n[t].url.toString(),{data:e.data,mediaType:e.mediaType}]).filter(e=>null!=e))}function c5({maxOutputTokens:e,temperature:t,topP:r,topK:n,presencePenalty:i,frequencyPenalty:a,seed:o,stopSequences:s}){if(null!=e){if(!Number.isInteger(e))throw new cx({parameter:"maxOutputTokens",value:e,message:"maxOutputTokens must be an integer"});if(e<1)throw new cx({parameter:"maxOutputTokens",value:e,message:"maxOutputTokens must be >= 1"})}if(null!=t&&"number"!=typeof t)throw new cx({parameter:"temperature",value:t,message:"temperature must be a number"});if(null!=r&&"number"!=typeof r)throw new cx({parameter:"topP",value:r,message:"topP must be a number"});if(null!=n&&"number"!=typeof n)throw new cx({parameter:"topK",value:n,message:"topK must be a number"});if(null!=i&&"number"!=typeof i)throw new cx({parameter:"presencePenalty",value:i,message:"presencePenalty must be a number"});if(null!=a&&"number"!=typeof a)throw new cx({parameter:"frequencyPenalty",value:a,message:"frequencyPenalty must be a number"});if(null!=o&&!Number.isInteger(o))throw new cx({parameter:"seed",value:o,message:"seed must be an integer"});return{maxOutputTokens:e,temperature:t,topP:r,topK:n,presencePenalty:i,frequencyPenalty:a,stopSequences:s,seed:o}}var c7=uA.lazy(()=>uA.union([uA.null(),uA.string(),uA.number(),uA.boolean(),uA.record(uA.string(),c7),uA.array(c7)])),c8=uA.record(uA.string(),uA.record(uA.string(),c7)),de=uA.object({type:uA.literal("text"),text:uA.string(),providerOptions:c8.optional()}),dt=uA.object({type:uA.literal("image"),image:uA.union([c6,uA.instanceof(URL)]),mediaType:uA.string().optional(),providerOptions:c8.optional()}),dr=uA.object({type:uA.literal("file"),data:uA.union([c6,uA.instanceof(URL)]),filename:uA.string().optional(),mediaType:uA.string(),providerOptions:c8.optional()}),dn=uA.object({type:uA.literal("reasoning"),text:uA.string(),providerOptions:c8.optional()}),di=uA.object({type:uA.literal("tool-call"),toolCallId:uA.string(),toolName:uA.string(),input:uA.unknown(),providerOptions:c8.optional(),providerExecuted:uA.boolean().optional()}),da=uA.discriminatedUnion("type",[uA.object({type:uA.literal("text"),value:uA.string()}),uA.object({type:uA.literal("json"),value:c7}),uA.object({type:uA.literal("error-text"),value:uA.string()}),uA.object({type:uA.literal("error-json"),value:c7}),uA.object({type:uA.literal("content"),value:uA.array(uA.union([uA.object({type:uA.literal("text"),text:uA.string()}),uA.object({type:uA.literal("media"),data:uA.string(),mediaType:uA.string()})]))})]),ds=uA.object({type:uA.literal("tool-result"),toolCallId:uA.string(),toolName:uA.string(),output:da,providerOptions:c8.optional()}),dl=uA.object({role:uA.literal("system"),content:uA.string(),providerOptions:c8.optional()}),du=uA.object({role:uA.literal("user"),content:uA.union([uA.string(),uA.array(uA.union([de,dt,dr]))]),providerOptions:c8.optional()}),dc=uA.object({role:uA.literal("assistant"),content:uA.union([uA.string(),uA.array(uA.union([de,dr,dn,di,ds]))]),providerOptions:c8.optional()}),dd=uA.object({role:uA.literal("tool"),content:uA.array(ds),providerOptions:c8.optional()}),dp=uA.union([dl,du,dc,dd]);async function dm(e){let t;if(null==e.prompt&&null==e.messages)throw new ey({prompt:e,message:"prompt or messages must be defined"});if(null!=e.prompt&&null!=e.messages)throw new ey({prompt:e,message:"prompt and messages cannot be defined at the same time"});if(null!=e.system&&"string"!=typeof e.system)throw new ey({prompt:e,message:"system must be a string"});if(null!=e.prompt&&"string"==typeof e.prompt)t=[{role:"user",content:e.prompt}];else if(null!=e.prompt&&Array.isArray(e.prompt))t=e.prompt;else if(null!=e.messages)t=e.messages;else throw new ey({prompt:e,message:"prompt or messages must be defined"});if(0===t.length)throw new ey({prompt:e,message:"messages must not be empty"});let r=await rc({value:t,schema:uA.array(dp)});if(!r.success)throw new ey({prompt:e,message:"The messages must be a ModelMessage[]. If you have passed a UIMessage[], you can use convertToModelMessages to convert them.",cause:r.error});return{messages:t,system:e.system}}function df({operationId:e,telemetry:t}){return{"operation.name":`${e}${(null==t?void 0:t.functionId)!=null?` ${t.functionId}`:""}`,"resource.name":null==t?void 0:t.functionId,"ai.operationId":e,"ai.telemetry.functionId":null==t?void 0:t.functionId}}var dg={startSpan:()=>dv,startActiveSpan:(e,t,r,n)=>"function"==typeof t?t(dv):"function"==typeof r?r(dv):"function"==typeof n?n(dv):void 0},dv={spanContext:()=>dh,setAttribute(){return this},setAttributes(){return this},addEvent(){return this},addLink(){return this},addLinks(){return this},setStatus(){return this},updateName(){return this},end(){return this},isRecording:()=>!1,recordException(){return this}},dh={traceId:"",spanId:"",traceFlags:0};function dy({name:e,tracer:t,attributes:r,fn:n,endWhenDone:i=!0}){return t.startActiveSpan(e,{attributes:r},async e=>{try{let t=await n(e);return i&&e.end(),t}catch(t){try{d$(e,t)}finally{e.end()}throw t}})}function d$(e,t){t instanceof Error?(e.recordException({name:t.name,message:t.message,stack:t.stack}),e.setStatus({code:cp.SpanStatusCode.ERROR,message:t.message})):e.setStatus({code:cp.SpanStatusCode.ERROR})}function db({telemetry:e,attributes:t}){return(null==e?void 0:e.isEnabled)!==!0?{}:Object.entries(t).reduce((t,[r,n])=>{if(null==n)return t;if("object"==typeof n&&"input"in n&&"function"==typeof n.input){if((null==e?void 0:e.recordInputs)===!1)return t;let i=n.input();return null==i?t:{...t,[r]:i}}if("object"==typeof n&&"output"in n&&"function"==typeof n.output){if((null==e?void 0:e.recordOutputs)===!1)return t;let i=n.output();return null==i?t:{...t,[r]:i}}return{...t,[r]:n}},{})}function d_(e,t){return null==e&&null==t?void 0:(null!=e?e:0)+(null!=t?t:0)}async function dw(e,{maxRetries:t,delayInMs:r,backoffFactor:n,abortSignal:i},a=[]){try{return await e()}catch(u){if(t9(u)||0===t)throw u;let o=t2(u),s=[...a,u],l=s.length;if(l>t)throw new cX({message:`Failed after ${l} attempts. Last error: ${o}`,reason:"maxRetriesExceeded",errors:s});if(u instanceof Error&&ea.isInstance(u)&&!0===u.isRetryable&&l<=t)return await t0(function({error:e,exponentialBackoffDelay:t}){let r,n=e.responseHeaders;if(!n)return t;let i=n["retry-after-ms"];if(i){let e=parseFloat(i);Number.isNaN(e)||(r=e)}let a=n["retry-after"];if(a&&void 0===r){let e=parseFloat(a);r=Number.isNaN(e)?Date.parse(a)-Date.now():1e3*e}return null!=r&&!Number.isNaN(r)&&0<=r&&(r<6e4||r<t)?r:t}({error:u,exponentialBackoffDelay:r}),{abortSignal:i}),dw(e,{maxRetries:t,delayInMs:n*r,backoffFactor:n,abortSignal:i},s);if(1===l)throw u;throw new cX({message:`Failed after ${l} attempts with non-retryable error: '${o}'`,reason:"errorNotRetryable",errors:s})}}function dx(e){let t=e.filter(e=>"text"===e.type);if(0!==t.length)return t.map(e=>e.text).join("")}var dk=class{constructor({data:e,mediaType:t}){const r=e instanceof Uint8Array;this.base64Data=r?void 0:e,this.uint8ArrayData=r?e:void 0,this.mediaType=t}get base64(){return null==this.base64Data&&(this.base64Data=rX(this.uint8ArrayData)),this.base64Data}get uint8Array(){return null==this.uint8ArrayData&&(this.uint8ArrayData=rY(this.base64Data)),this.uint8ArrayData}};async function dI({toolCall:e,tools:t,repairToolCall:r,system:n,messages:i}){try{if(null==t)throw new cU({toolName:e.toolName});try{return await dS({toolCall:e,tools:t})}catch(o){if(null==r||!(cU.isInstance(o)||cO.isInstance(o)))throw o;let a=null;try{a=await r({toolCall:e,tools:t,inputSchema:({toolName:e})=>{let{inputSchema:r}=t[e];return rW(r).jsonSchema},system:n,messages:i,error:o})}catch(e){throw new cR({cause:e,originalError:o})}if(null==a)throw o;return await dS({toolCall:a,tools:t})}}catch(n){let t=await rp({text:e.input}),r=t.success?t.value:e.input;return{type:"tool-call",toolCallId:e.toolCallId,toolName:e.toolName,input:r,dynamic:!0,invalid:!0,error:n}}}async function dS({toolCall:e,tools:t}){let r=e.toolName,n=t[r];if(null==n)throw new cU({toolName:e.toolName,availableTools:Object.keys(t)});let i=rW(n.inputSchema),a=""===e.input.trim()?await rc({value:{},schema:i}):await rp({text:e.input,schema:i});if(!1===a.success)throw new cO({toolName:r,toolInput:e.input,cause:a.error});return"dynamic"===n.type?{type:"tool-call",toolCallId:e.toolCallId,toolName:e.toolName,input:a.value,providerExecuted:e.providerExecuted,providerMetadata:e.providerMetadata,dynamic:!0}:{type:"tool-call",toolCallId:e.toolCallId,toolName:r,input:a.value,providerExecuted:e.providerExecuted,providerMetadata:e.providerMetadata}}var dO=class{constructor({content:e,finishReason:t,usage:r,warnings:n,request:i,response:a,providerMetadata:o}){this.content=e,this.finishReason=t,this.usage=r,this.warnings=n,this.request=i,this.response=a,this.providerMetadata=o}get text(){return this.content.filter(e=>"text"===e.type).map(e=>e.text).join("")}get reasoning(){return this.content.filter(e=>"reasoning"===e.type)}get reasoningText(){return 0===this.reasoning.length?void 0:this.reasoning.map(e=>e.text).join("")}get files(){return this.content.filter(e=>"file"===e.type).map(e=>e.file)}get sources(){return this.content.filter(e=>"source"===e.type)}get toolCalls(){return this.content.filter(e=>"tool-call"===e.type)}get staticToolCalls(){return this.toolCalls.filter(e=>!0!==e.dynamic)}get dynamicToolCalls(){return this.toolCalls.filter(e=>!0===e.dynamic)}get toolResults(){return this.content.filter(e=>"tool-result"===e.type)}get staticToolResults(){return this.toolResults.filter(e=>!0!==e.dynamic)}get dynamicToolResults(){return this.toolResults.filter(e=>!0===e.dynamic)}};async function dP({stopConditions:e,steps:t}){return(await Promise.all(e.map(e=>e({steps:t})))).some(e=>e)}function dE({output:e,tool:t,errorMode:r}){return"text"===r?{type:"error-text",value:ec(e)}:"json"===r?{type:"error-json",value:dN(e)}:(null==t?void 0:t.toModelOutput)?t.toModelOutput(e):"string"==typeof e?{type:"text",value:e}:{type:"json",value:dN(e)}}function dN(e){return void 0===e?null:e}var dZ=t6({prefix:"aitxt",size:24});async function dz({model:e,tools:t,toolChoice:r,system:n,prompt:i,messages:a,maxRetries:o,abortSignal:s,headers:l,stopWhen:u=function(e){return({steps:e})=>1===e.length}(0),experimental_output:c,experimental_telemetry:d,providerOptions:p,experimental_activeTools:m,activeTools:f=m,experimental_prepareStep:g,prepareStep:v=g,experimental_repairToolCall:h,experimental_download:y,experimental_context:$,_internal:{generateId:b=dZ,currentDate:_=()=>new Date}={},onStepFinish:w,...x}){let k=cQ(e),I=void 0===u?[]:Array.isArray(u)?u:[u],{maxRetries:S,retry:O}=function({maxRetries:e,abortSignal:t}){if(null!=e){if(!Number.isInteger(e))throw new cx({parameter:"maxRetries",value:e,message:"maxRetries must be an integer"});if(e<0)throw new cx({parameter:"maxRetries",value:e,message:"maxRetries must be >= 0"})}let r=null!=e?e:2;return{maxRetries:r,retry:(({maxRetries:e=2,initialDelayInMs:t=2e3,backoffFactor:r=2,abortSignal:n}={})=>async i=>dw(i,{maxRetries:e,delayInMs:t,backoffFactor:r,abortSignal:n}))({maxRetries:r,abortSignal:t})}}({maxRetries:o,abortSignal:s}),P=c5(x),E=t8(null!=l?l:{},`ai/${c4}`),N=function({model:e,settings:t,telemetry:r,headers:n}){var i;return{"ai.model.provider":e.provider,"ai.model.id":e.modelId,...Object.entries(t).reduce((e,[t,r])=>(e[`ai.settings.${t}`]=r,e),{}),...Object.entries(null!=(i=null==r?void 0:r.metadata)?i:{}).reduce((e,[t,r])=>(e[`ai.telemetry.metadata.${t}`]=r,e),{}),...Object.entries(null!=n?n:{}).reduce((e,[t,r])=>(void 0!==r&&(e[`ai.request.headers.${t}`]=r),e),{})}}({model:k,telemetry:d,headers:E,settings:{...P,maxRetries:S}}),Z=await dm({system:n,prompt:i,messages:a}),z=function({isEnabled:e=!1,tracer:t}={}){return e?t||cd.trace.getTracer("ai"):dg}(d);try{return await dy({name:"ai.generateText",attributes:db({telemetry:d,attributes:{...df({operationId:"ai.generateText",telemetry:d}),...N,"ai.model.provider":k.provider,"ai.model.id":k.modelId,"ai.prompt":{input:()=>JSON.stringify({system:n,prompt:i,messages:a})}}}),tracer:z,fn:async e=>{var i,a,o,l,u,m,g;let S,P,T=c5(x),j=[],U=[],A=[],D=[];do{let e=[...Z.messages,...A],I=await (null==v?void 0:v({model:k,steps:D,stepNumber:D.length,messages:e})),P=cQ(null!=(i=null==I?void 0:I.model)?i:k),C=await c9({prompt:{system:null!=(a=null==I?void 0:I.system)?a:Z.system,messages:null!=(o=null==I?void 0:I.messages)?o:e},supportedUrls:await P.supportedUrls,download:y}),{toolChoice:R,tools:L}=function({tools:e,toolChoice:t,activeTools:r}){return null!=e&&Object.keys(e).length>0?{tools:(null!=r?Object.entries(e).filter(([e])=>r.includes(e)):Object.entries(e)).map(([e,t])=>{let r=t.type;switch(r){case void 0:case"dynamic":case"function":return{type:"function",name:e,description:t.description,inputSchema:rW(t.inputSchema).jsonSchema,providerOptions:t.providerOptions};case"provider-defined":return{type:"provider-defined",name:e,id:t.id,args:t.args};default:throw Error(`Unsupported tool type: ${r}`)}}),toolChoice:null==t?{type:"auto"}:"string"==typeof t?{type:t}:{type:"tool",toolName:t.toolName}}:{tools:void 0,toolChoice:void 0}}({tools:t,toolChoice:null!=(l=null==I?void 0:I.toolChoice)?l:r,activeTools:null!=(u=null==I?void 0:I.activeTools)?u:f});S=await O(()=>{var e;return dy({name:"ai.generateText.doGenerate",attributes:db({telemetry:d,attributes:{...df({operationId:"ai.generateText.doGenerate",telemetry:d}),...N,"ai.model.provider":P.provider,"ai.model.id":P.modelId,"ai.prompt.messages":{input:()=>JSON.stringify(C.map(e=>({...e,content:"string"==typeof e.content?e.content:e.content.map(e=>{var t;return"file"===e.type?{...e,data:e.data instanceof Uint8Array?"string"==typeof(t=e.data)?t:t instanceof ArrayBuffer?rX(new Uint8Array(t)):rX(t):e.data}:e})})))},"ai.prompt.tools":{input:()=>null==L?void 0:L.map(e=>JSON.stringify(e))},"ai.prompt.toolChoice":{input:()=>null!=R?JSON.stringify(R):void 0},"gen_ai.system":P.provider,"gen_ai.request.model":P.modelId,"gen_ai.request.frequency_penalty":x.frequencyPenalty,"gen_ai.request.max_tokens":x.maxOutputTokens,"gen_ai.request.presence_penalty":x.presencePenalty,"gen_ai.request.stop_sequences":x.stopSequences,"gen_ai.request.temperature":null!=(e=x.temperature)?e:void 0,"gen_ai.request.top_k":x.topK,"gen_ai.request.top_p":x.topP}}),tracer:z,fn:async e=>{var t,r,n,i,a,o,l,u;let m=await P.doGenerate({...T,tools:L,toolChoice:R,responseFormat:null==c?void 0:c.responseFormat,prompt:C,providerOptions:p,abortSignal:s,headers:E}),f={id:null!=(r=null==(t=m.response)?void 0:t.id)?r:b(),timestamp:null!=(i=null==(n=m.response)?void 0:n.timestamp)?i:_(),modelId:null!=(o=null==(a=m.response)?void 0:a.modelId)?o:P.modelId,headers:null==(l=m.response)?void 0:l.headers,body:null==(u=m.response)?void 0:u.body};return e.setAttributes(db({telemetry:d,attributes:{"ai.response.finishReason":m.finishReason,"ai.response.text":{output:()=>dx(m.content)},"ai.response.toolCalls":{output:()=>{let e=dU(m.content);return null==e?void 0:JSON.stringify(e)}},"ai.response.id":f.id,"ai.response.model":f.modelId,"ai.response.timestamp":f.timestamp.toISOString(),"ai.response.providerMetadata":JSON.stringify(m.providerMetadata),"ai.usage.promptTokens":m.usage.inputTokens,"ai.usage.completionTokens":m.usage.outputTokens,"gen_ai.response.finish_reasons":[m.finishReason],"gen_ai.response.id":f.id,"gen_ai.response.model":f.modelId,"gen_ai.usage.input_tokens":m.usage.inputTokens,"gen_ai.usage.output_tokens":m.usage.outputTokens}})),{...m,response:f}}})});let F=await Promise.all(S.content.filter(e=>"tool-call"===e.type).map(r=>dI({toolCall:r,tools:t,repairToolCall:h,system:n,messages:e})));for(let r of F){if(r.invalid)continue;let n=t[r.toolName];(null==n?void 0:n.onInputAvailable)!=null&&await n.onInputAvailable({input:r.input,toolCallId:r.toolCallId,messages:e,abortSignal:s,experimental_context:$})}let M=F.filter(e=>e.invalid&&e.dynamic);for(let e of(U=[],M))U.push({type:"tool-error",toolCallId:e.toolCallId,toolName:e.toolName,input:e.input,error:t2(e.error),dynamic:!0});j=F.filter(e=>!e.providerExecuted),null!=t&&U.push(...await dT({toolCalls:j.filter(e=>!e.invalid),tools:t,tracer:z,telemetry:d,messages:e,abortSignal:s,experimental_context:$}));let J=function({content:e,toolCalls:t,toolOutputs:r}){return[...e.map(e=>{switch(e.type){case"text":case"reasoning":case"source":return e;case"file":return{type:"file",file:new dk(e)};case"tool-call":return t.find(t=>t.toolCallId===e.toolCallId);case"tool-result":{let r=t.find(t=>t.toolCallId===e.toolCallId);if(null==r)throw Error(`Tool call ${e.toolCallId} not found.`);if(e.isError)return{type:"tool-error",toolCallId:e.toolCallId,toolName:e.toolName,input:r.input,error:e.result,providerExecuted:!0,dynamic:r.dynamic};return{type:"tool-result",toolCallId:e.toolCallId,toolName:e.toolName,input:r.input,output:e.result,providerExecuted:!0,dynamic:r.dynamic}}}}),...r]}({content:S.content,toolCalls:F,toolOutputs:U});A.push(...function({content:e,tools:t}){let r=[],n=e.filter(e=>"source"!==e.type).filter(e=>("tool-result"!==e.type||e.providerExecuted)&&("tool-error"!==e.type||e.providerExecuted)).filter(e=>"text"!==e.type||e.text.length>0).map(e=>{switch(e.type){case"text":return{type:"text",text:e.text,providerOptions:e.providerMetadata};case"reasoning":return{type:"reasoning",text:e.text,providerOptions:e.providerMetadata};case"file":return{type:"file",data:e.file.base64,mediaType:e.file.mediaType,providerOptions:e.providerMetadata};case"tool-call":return{type:"tool-call",toolCallId:e.toolCallId,toolName:e.toolName,input:e.input,providerExecuted:e.providerExecuted,providerOptions:e.providerMetadata};case"tool-result":return{type:"tool-result",toolCallId:e.toolCallId,toolName:e.toolName,output:dE({tool:null==t?void 0:t[e.toolName],output:e.output,errorMode:"none"}),providerExecuted:!0,providerOptions:e.providerMetadata};case"tool-error":return{type:"tool-result",toolCallId:e.toolCallId,toolName:e.toolName,output:dE({tool:null==t?void 0:t[e.toolName],output:e.error,errorMode:"json"}),providerOptions:e.providerMetadata}}});n.length>0&&r.push({role:"assistant",content:n});let i=e.filter(e=>"tool-result"===e.type||"tool-error"===e.type).filter(e=>!e.providerExecuted).map(e=>({type:"tool-result",toolCallId:e.toolCallId,toolName:e.toolName,output:dE({tool:null==t?void 0:t[e.toolName],output:"tool-result"===e.type?e.output:e.error,errorMode:"tool-error"===e.type?"text":"none"})}));return i.length>0&&r.push({role:"tool",content:i}),r}({content:J,tools:t}));let B=new dO({content:J,finishReason:S.finishReason,usage:S.usage,warnings:S.warnings,providerMetadata:S.providerMetadata,request:null!=(m=S.request)?m:{},response:{...S.response,messages:structuredClone(A)}});c$(null!=(g=S.warnings)?g:[]),D.push(B),await (null==w?void 0:w(B))}while(j.length>0&&U.length===j.length&&!await dP({stopConditions:I,steps:D}))e.setAttributes(db({telemetry:d,attributes:{"ai.response.finishReason":S.finishReason,"ai.response.text":{output:()=>dx(S.content)},"ai.response.toolCalls":{output:()=>{let e=dU(S.content);return null==e?void 0:JSON.stringify(e)}},"ai.response.providerMetadata":JSON.stringify(S.providerMetadata),"ai.usage.promptTokens":S.usage.inputTokens,"ai.usage.completionTokens":S.usage.outputTokens}}));let C=D[D.length-1];return"stop"===C.finishReason&&(P=await (null==c?void 0:c.parseOutput({text:C.text},{response:C.response,usage:C.usage,finishReason:C.finishReason}))),new dj({steps:D,resolvedOutput:P})}})}catch(e){throw uM.isInstance(e)||uX.isInstance(e)?new et({name:"GatewayError",message:"Vercel AI Gateway access failed. If you want to use AI SDK providers directly, use the providers, e.g. @ai-sdk/openai, or register a different global default provider.",cause:e}):e}}async function dT({toolCalls:e,tools:t,tracer:r,telemetry:n,messages:i,abortSignal:a,experimental_context:o}){return(await Promise.all(e.map(async({toolCallId:e,toolName:s,input:l})=>{let u=t[s];if((null==u?void 0:u.execute)!=null)return dy({name:"ai.toolCall",attributes:db({telemetry:n,attributes:{...df({operationId:"ai.toolCall",telemetry:n}),"ai.toolCall.name":s,"ai.toolCall.id":e,"ai.toolCall.args":{output:()=>JSON.stringify(l)}}}),tracer:r,fn:async t=>{try{let r;for await(let t of rQ({execute:u.execute.bind(u),input:l,options:{toolCallId:e,messages:i,abortSignal:a,experimental_context:o}}))"final"===t.type&&(r=t.output);try{t.setAttributes(db({telemetry:n,attributes:{"ai.toolCall.result":{output:()=>JSON.stringify(r)}}}))}catch(e){}return{type:"tool-result",toolCallId:e,toolName:s,input:l,output:r,dynamic:"dynamic"===u.type}}catch(r){return d$(t,r),{type:"tool-error",toolCallId:e,toolName:s,input:l,error:r,dynamic:"dynamic"===u.type}}}})}))).filter(e=>null!=e)}var dj=class{constructor(e){this.steps=e.steps,this.resolvedOutput=e.resolvedOutput}get finalStep(){return this.steps[this.steps.length-1]}get content(){return this.finalStep.content}get text(){return this.finalStep.text}get files(){return this.finalStep.files}get reasoningText(){return this.finalStep.reasoningText}get reasoning(){return this.finalStep.reasoning}get toolCalls(){return this.finalStep.toolCalls}get staticToolCalls(){return this.finalStep.staticToolCalls}get dynamicToolCalls(){return this.finalStep.dynamicToolCalls}get toolResults(){return this.finalStep.toolResults}get staticToolResults(){return this.finalStep.staticToolResults}get dynamicToolResults(){return this.finalStep.dynamicToolResults}get sources(){return this.finalStep.sources}get finishReason(){return this.finalStep.finishReason}get warnings(){return this.finalStep.warnings}get providerMetadata(){return this.finalStep.providerMetadata}get response(){return this.finalStep.response}get request(){return this.finalStep.request}get usage(){return this.finalStep.usage}get totalUsage(){return this.steps.reduce((e,t)=>{var r;return r=t.usage,{inputTokens:d_(e.inputTokens,r.inputTokens),outputTokens:d_(e.outputTokens,r.outputTokens),totalTokens:d_(e.totalTokens,r.totalTokens),reasoningTokens:d_(e.reasoningTokens,r.reasoningTokens),cachedInputTokens:d_(e.cachedInputTokens,r.cachedInputTokens)}},{inputTokens:void 0,outputTokens:void 0,totalTokens:void 0,reasoningTokens:void 0,cachedInputTokens:void 0})}get experimental_output(){if(null==this.resolvedOutput)throw new ch;return this.resolvedOutput}};function dU(e){let t=e.filter(e=>"tool-call"===e.type);if(0!==t.length)return t.map(e=>({toolCallId:e.toolCallId,toolName:e.toolName,input:e.input}))}async function dA(e){if(void 0===e)return{value:void 0,state:"undefined-input"};let t=await rp({text:e});return t.success?{value:t.value,state:"successful-parse"}:(t=await rp({text:function(e){let t=["ROOT"],r=-1,n=null;function i(e,i,a){switch(e){case'"':r=i,t.pop(),t.push(a),t.push("INSIDE_STRING");break;case"f":case"t":case"n":r=i,n=i,t.pop(),t.push(a),t.push("INSIDE_LITERAL");break;case"-":t.pop(),t.push(a),t.push("INSIDE_NUMBER");break;case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":r=i,t.pop(),t.push(a),t.push("INSIDE_NUMBER");break;case"{":r=i,t.pop(),t.push(a),t.push("INSIDE_OBJECT_START");break;case"[":r=i,t.pop(),t.push(a),t.push("INSIDE_ARRAY_START")}}function a(e,n){switch(e){case",":t.pop(),t.push("INSIDE_OBJECT_AFTER_COMMA");break;case"}":r=n,t.pop()}}function o(e,n){switch(e){case",":t.pop(),t.push("INSIDE_ARRAY_AFTER_COMMA");break;case"]":r=n,t.pop()}}for(let s=0;s<e.length;s++){let l=e[s];switch(t[t.length-1]){case"ROOT":i(l,s,"FINISH");break;case"INSIDE_OBJECT_START":switch(l){case'"':t.pop(),t.push("INSIDE_OBJECT_KEY");break;case"}":r=s,t.pop()}break;case"INSIDE_OBJECT_AFTER_COMMA":'"'===l&&(t.pop(),t.push("INSIDE_OBJECT_KEY"));break;case"INSIDE_OBJECT_KEY":'"'===l&&(t.pop(),t.push("INSIDE_OBJECT_AFTER_KEY"));break;case"INSIDE_OBJECT_AFTER_KEY":":"===l&&(t.pop(),t.push("INSIDE_OBJECT_BEFORE_VALUE"));break;case"INSIDE_OBJECT_BEFORE_VALUE":i(l,s,"INSIDE_OBJECT_AFTER_VALUE");break;case"INSIDE_OBJECT_AFTER_VALUE":a(l,s);break;case"INSIDE_STRING":switch(l){case'"':t.pop(),r=s;break;case"\\":t.push("INSIDE_STRING_ESCAPE");break;default:r=s}break;case"INSIDE_ARRAY_START":"]"===l?(r=s,t.pop()):(r=s,i(l,s,"INSIDE_ARRAY_AFTER_VALUE"));break;case"INSIDE_ARRAY_AFTER_VALUE":switch(l){case",":t.pop(),t.push("INSIDE_ARRAY_AFTER_COMMA");break;case"]":r=s,t.pop();break;default:r=s}break;case"INSIDE_ARRAY_AFTER_COMMA":i(l,s,"INSIDE_ARRAY_AFTER_VALUE");break;case"INSIDE_STRING_ESCAPE":t.pop(),r=s;break;case"INSIDE_NUMBER":switch(l){case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":r=s;break;case"e":case"E":case"-":case".":break;case",":t.pop(),"INSIDE_ARRAY_AFTER_VALUE"===t[t.length-1]&&o(l,s),"INSIDE_OBJECT_AFTER_VALUE"===t[t.length-1]&&a(l,s);break;case"}":t.pop(),"INSIDE_OBJECT_AFTER_VALUE"===t[t.length-1]&&a(l,s);break;case"]":t.pop(),"INSIDE_ARRAY_AFTER_VALUE"===t[t.length-1]&&o(l,s);break;default:t.pop()}break;case"INSIDE_LITERAL":{let i=e.substring(n,s+1);"false".startsWith(i)||"true".startsWith(i)||"null".startsWith(i)?r=s:(t.pop(),"INSIDE_OBJECT_AFTER_VALUE"===t[t.length-1]?a(l,s):"INSIDE_ARRAY_AFTER_VALUE"===t[t.length-1]&&o(l,s))}}}let s=e.slice(0,r+1);for(let r=t.length-1;r>=0;r--)switch(t[r]){case"INSIDE_STRING":s+='"';break;case"INSIDE_OBJECT_KEY":case"INSIDE_OBJECT_AFTER_KEY":case"INSIDE_OBJECT_AFTER_COMMA":case"INSIDE_OBJECT_START":case"INSIDE_OBJECT_BEFORE_VALUE":case"INSIDE_OBJECT_AFTER_VALUE":s+="}";break;case"INSIDE_ARRAY_START":case"INSIDE_ARRAY_AFTER_COMMA":case"INSIDE_ARRAY_AFTER_VALUE":s+="]";break;case"INSIDE_LITERAL":{let t=e.substring(n,e.length);"true".startsWith(t)?s+="true".slice(t.length):"false".startsWith(t)?s+="false".slice(t.length):"null".startsWith(t)&&(s+="null".slice(t.length))}}return s}(e)})).success?{value:t.value,state:"repaired-parse"}:{value:void 0,state:"failed-parse"}}TransformStream,rl(()=>rV(uA.union([uA.strictObject({type:uA.literal("text-start"),id:uA.string(),providerMetadata:c8.optional()}),uA.strictObject({type:uA.literal("text-delta"),id:uA.string(),delta:uA.string(),providerMetadata:c8.optional()}),uA.strictObject({type:uA.literal("text-end"),id:uA.string(),providerMetadata:c8.optional()}),uA.strictObject({type:uA.literal("error"),errorText:uA.string()}),uA.strictObject({type:uA.literal("tool-input-start"),toolCallId:uA.string(),toolName:uA.string(),providerExecuted:uA.boolean().optional(),dynamic:uA.boolean().optional()}),uA.strictObject({type:uA.literal("tool-input-delta"),toolCallId:uA.string(),inputTextDelta:uA.string()}),uA.strictObject({type:uA.literal("tool-input-available"),toolCallId:uA.string(),toolName:uA.string(),input:uA.unknown(),providerExecuted:uA.boolean().optional(),providerMetadata:c8.optional(),dynamic:uA.boolean().optional()}),uA.strictObject({type:uA.literal("tool-input-error"),toolCallId:uA.string(),toolName:uA.string(),input:uA.unknown(),providerExecuted:uA.boolean().optional(),providerMetadata:c8.optional(),dynamic:uA.boolean().optional(),errorText:uA.string()}),uA.strictObject({type:uA.literal("tool-output-available"),toolCallId:uA.string(),output:uA.unknown(),providerExecuted:uA.boolean().optional(),dynamic:uA.boolean().optional(),preliminary:uA.boolean().optional()}),uA.strictObject({type:uA.literal("tool-output-error"),toolCallId:uA.string(),errorText:uA.string(),providerExecuted:uA.boolean().optional(),dynamic:uA.boolean().optional()}),uA.strictObject({type:uA.literal("reasoning-start"),id:uA.string(),providerMetadata:c8.optional()}),uA.strictObject({type:uA.literal("reasoning-delta"),id:uA.string(),delta:uA.string(),providerMetadata:c8.optional()}),uA.strictObject({type:uA.literal("reasoning-end"),id:uA.string(),providerMetadata:c8.optional()}),uA.strictObject({type:uA.literal("source-url"),sourceId:uA.string(),url:uA.string(),title:uA.string().optional(),providerMetadata:c8.optional()}),uA.strictObject({type:uA.literal("source-document"),sourceId:uA.string(),mediaType:uA.string(),title:uA.string(),filename:uA.string().optional(),providerMetadata:c8.optional()}),uA.strictObject({type:uA.literal("file"),url:uA.string(),mediaType:uA.string(),providerMetadata:c8.optional()}),uA.strictObject({type:uA.custom(e=>"string"==typeof e&&e.startsWith("data-"),{message:'Type must start with "data-"'}),id:uA.string().optional(),data:uA.unknown(),transient:uA.boolean().optional()}),uA.strictObject({type:uA.literal("start-step")}),uA.strictObject({type:uA.literal("finish-step")}),uA.strictObject({type:uA.literal("start"),messageId:uA.string().optional(),messageMetadata:uA.unknown().optional()}),uA.strictObject({type:uA.literal("finish"),messageMetadata:uA.unknown().optional()}),uA.strictObject({type:uA.literal("abort")}),uA.strictObject({type:uA.literal("message-metadata"),messageMetadata:uA.unknown()})]))),t6({prefix:"aitxt",size:24}),t6({prefix:"aiobj",size:24}),t6({prefix:"aiobj",size:24});var dD={},dC={object:()=>dF,text:()=>dL};for(var dR in dC)cm(dD,dR,{get:dC[dR],enumerable:!0});var dL=()=>({type:"text",responseFormat:{type:"text"},parsePartial:async({text:e})=>({partial:e}),parseOutput:async({text:e})=>e}),dF=({schema:e})=>{let t=rW(e);return{type:"object",responseFormat:{type:"json",schema:t.jsonSchema},async parsePartial({text:e}){let t=await dA(e);switch(t.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":return{partial:t.value};default:{let e=t.state;throw Error(`Unsupported parse state: ${e}`)}}},async parseOutput({text:e},r){let n=await rp({text:e});if(!n.success)throw new cZ({message:"No object generated: could not parse the response.",cause:n.error,text:e,response:r.response,usage:r.usage,finishReason:r.finishReason});let i=await rc({value:n.value,schema:t});if(!i.success)throw new cZ({message:"No object generated: response did not match schema.",cause:i.error,text:e,response:r.response,usage:r.usage,finishReason:r.finishReason});return i.value}}};Symbol.for("vercel.ai.error.AI_NoSuchProviderError"),rl(()=>rV(uA.array(uA.object({id:uA.string(),role:uA.enum(["system","user","assistant"]),metadata:uA.unknown().optional(),parts:uA.array(uA.union([uA.object({type:uA.literal("text"),text:uA.string(),state:uA.enum(["streaming","done"]).optional(),providerMetadata:c8.optional()}),uA.object({type:uA.literal("reasoning"),text:uA.string(),state:uA.enum(["streaming","done"]).optional(),providerMetadata:c8.optional()}),uA.object({type:uA.literal("source-url"),sourceId:uA.string(),url:uA.string(),title:uA.string().optional(),providerMetadata:c8.optional()}),uA.object({type:uA.literal("source-document"),sourceId:uA.string(),mediaType:uA.string(),title:uA.string(),filename:uA.string().optional(),providerMetadata:c8.optional()}),uA.object({type:uA.literal("file"),mediaType:uA.string(),filename:uA.string().optional(),url:uA.string(),providerMetadata:c8.optional()}),uA.object({type:uA.literal("step-start")}),uA.object({type:uA.string().startsWith("data-"),id:uA.string().optional(),data:uA.unknown()}),uA.object({type:uA.literal("dynamic-tool"),toolName:uA.string(),toolCallId:uA.string(),state:uA.literal("input-streaming"),input:uA.unknown().optional(),providerExecuted:uA.boolean().optional(),output:uA.never().optional(),errorText:uA.never().optional()}),uA.object({type:uA.literal("dynamic-tool"),toolName:uA.string(),toolCallId:uA.string(),state:uA.literal("input-available"),input:uA.unknown(),providerExecuted:uA.boolean().optional(),output:uA.never().optional(),errorText:uA.never().optional(),callProviderMetadata:c8.optional()}),uA.object({type:uA.literal("dynamic-tool"),toolName:uA.string(),toolCallId:uA.string(),state:uA.literal("output-available"),input:uA.unknown(),providerExecuted:uA.boolean().optional(),output:uA.unknown(),errorText:uA.never().optional(),callProviderMetadata:c8.optional(),preliminary:uA.boolean().optional()}),uA.object({type:uA.literal("dynamic-tool"),toolName:uA.string(),toolCallId:uA.string(),state:uA.literal("output-error"),input:uA.unknown(),providerExecuted:uA.boolean().optional(),output:uA.never().optional(),errorText:uA.string(),callProviderMetadata:c8.optional()}),uA.object({type:uA.string().startsWith("tool-"),toolCallId:uA.string(),state:uA.literal("input-streaming"),providerExecuted:uA.boolean().optional(),input:uA.unknown().optional(),output:uA.never().optional(),errorText:uA.never().optional(),approval:uA.never().optional()}),uA.object({type:uA.string().startsWith("tool-"),toolCallId:uA.string(),state:uA.literal("input-available"),providerExecuted:uA.boolean().optional(),input:uA.unknown(),output:uA.never().optional(),errorText:uA.never().optional(),callProviderMetadata:c8.optional(),approval:uA.never().optional()}),uA.object({type:uA.string().startsWith("tool-"),toolCallId:uA.string(),state:uA.literal("approval-requested"),input:uA.unknown(),providerExecuted:uA.boolean().optional(),output:uA.never().optional(),errorText:uA.never().optional(),callProviderMetadata:c8.optional(),approval:uA.object({id:uA.string(),approved:uA.never().optional(),reason:uA.never().optional()})}),uA.object({type:uA.string().startsWith("tool-"),toolCallId:uA.string(),state:uA.literal("approval-responded"),input:uA.unknown(),providerExecuted:uA.boolean().optional(),output:uA.never().optional(),errorText:uA.never().optional(),callProviderMetadata:c8.optional(),approval:uA.object({id:uA.string(),approved:uA.boolean(),reason:uA.string().optional()})}),uA.object({type:uA.string().startsWith("tool-"),toolCallId:uA.string(),state:uA.literal("output-available"),providerExecuted:uA.boolean().optional(),input:uA.unknown(),output:uA.unknown(),errorText:uA.never().optional(),callProviderMetadata:c8.optional(),preliminary:uA.boolean().optional(),approval:uA.object({id:uA.string(),approved:uA.literal(!0),reason:uA.string().optional()}).optional()}),uA.object({type:uA.string().startsWith("tool-"),toolCallId:uA.string(),state:uA.literal("output-error"),providerExecuted:uA.boolean().optional(),input:uA.unknown(),output:uA.never().optional(),errorText:uA.string(),callProviderMetadata:c8.optional(),approval:uA.object({id:uA.string(),approved:uA.literal(!0),reason:uA.string().optional()}).optional()}),uA.object({type:uA.string().startsWith("tool-"),toolCallId:uA.string(),state:uA.literal("output-denied"),providerExecuted:uA.boolean().optional(),input:uA.unknown(),output:uA.never().optional(),errorText:uA.never().optional(),callProviderMetadata:c8.optional(),approval:uA.object({id:uA.string(),approved:uA.literal(!1),reason:uA.string().optional()})})]))}))));var dM=e.i(5898),dJ=e.i(27577);async function dB(e){let{repoUrl:t,branch:r="main",timeout:n="30m",projectDir:i="",framework:a="Next.js",packageManager:o="pnpm",debug:s=!1}=e,l=i||t.split("/").pop()?.replace(".git","")||"app";s&&(console.log("🚀 Creating d3k sandbox..."),console.log(` Repository: ${t}`),console.log(` Branch/SHA: ${r}${40===r.length?" (git commit SHA)":" (branch name)"}`),console.log(` Project: ${l}`),console.log(` Framework: ${a}`));let u=process.env.VERCEL_TOKEN||process.env.VERCEL_OIDC_TOKEN;if(!u)throw Error("Missing VERCEL_TOKEN or VERCEL_OIDC_TOKEN environment variable. Vercel AI Workflows should automatically provide VERCEL_OIDC_TOKEN. Check your workflow configuration and ensure it has access to Vercel API credentials.");s&&console.log(` Token type: ${process.env.VERCEL_OIDC_TOKEN?"OIDC":"static"}`);let c=(0,dJ.default)(n),d=await dM.Sandbox.create({teamId:process.env.VERCEL_TEAM_ID||"team_nLlpyC6REAqxydlFKbrMDlud",projectId:process.env.VERCEL_PROJECT_ID||"prj_21F00Vr3bXzc1VSC8D9j2YJUzd0Q",token:u,source:{url:`${t}.git`,type:"git",...r?{revision:r}:{}},resources:{vcpus:4},timeout:c,ports:[3e3,3684],runtime:"node22"});s&&console.log(" ✅ Sandbox created");try{let e=i?`/vercel/sandbox/${i}`:"/vercel/sandbox";s&&console.log(" 📦 Installing project dependencies...");let t=await d.runCommand({cmd:o,args:["install"],cwd:e,stdout:s?process.stdout:void 0,stderr:s?process.stderr:void 0});if(0!==t.exitCode)throw Error(`Project dependency installation failed with exit code ${t.exitCode}`);s&&console.log(" ✅ Project dependencies installed"),s&&console.log(" 📦 Installing d3k globally from git...");let r=await d.runCommand({cmd:"pnpm",args:["i","-g","github:vercel-labs/dev3000#main"],stdout:s?process.stdout:void 0,stderr:s?process.stderr:void 0});if(0!==r.exitCode)throw Error(`d3k installation failed with exit code ${r.exitCode}`);s&&console.log(" ✅ d3k installed globally"),s&&console.log(" 🚀 Starting d3k..."),await d.runCommand({cmd:"sh",args:["-c",`cd ${e} && MCP_SKIP_PERMISSIONS=true d3k --no-tui --debug > /tmp/d3k.log 2>&1`],detached:!0}),s&&console.log(" ⏳ Waiting for dev server..."),await dV(d,3e3,12e4);let n=d.domain(3e3);s&&console.log(` ✅ Dev server ready: ${n}`),s&&console.log(" ⏳ Waiting for MCP server..."),await dV(d,3684,6e4);let a=d.domain(3684);s&&console.log(` ✅ MCP server ready: ${a}`),s&&console.log(" ⏳ Waiting for d3k to initialize MCPs and browser..."),await new Promise(e=>setTimeout(e,1e4)),console.log(" 📋 Checking d3k logs...");let u=await d.runCommand({cmd:"tail",args:["-n","100","/tmp/d3k.log"]});if(0===u.exitCode){let e="string"==typeof u.stdout?u.stdout:"function"==typeof u.stdout?await u.stdout():String(u.stdout||"");console.log(" 📋 d3k log (last 100 lines):"),console.log(e)}else{console.log(` ⚠️ Could not read d3k logs (exit code: ${u.exitCode})`);let e="string"==typeof u.stderr?u.stderr:"function"==typeof u.stderr?await u.stderr():String(u.stderr||"");e&&console.log(` ⚠️ stderr: ${e}`)}return s&&console.log(" ✅ d3k sandbox ready!"),{sandbox:d,devUrl:n,mcpUrl:a,projectName:l,cleanup:async()=>{s&&console.log(" 🧹 Cleaning up sandbox..."),await d.stop(),s&&console.log(" ✅ Sandbox stopped")}}}catch(e){try{await d.stop()}catch{}throw e}}async function dV(e,t,r){let n=Date.now(),i=e.domain(t);for(;Date.now()-n<r;){try{let e=await fetch(i,{method:"HEAD"});if(e.ok||404===e.status)return}catch{}await new Promise(e=>setTimeout(e,1e3))}throw Error(`Server on port ${t} did not become ready within ${r}ms`)}e.i(43954);var dK=e.i(72972),dG=Object.defineProperty,dW=Object.getOwnPropertyNames,dq=(e,t)=>dG(e,"name",{value:t,configurable:!0}),dH=(e,t)=>function(){return e&&(t=(0,e[dW(e)[0]])(e=0)),t},dY=(e,t)=>{for(var r in t)dG(e,r,{get:t[r],enumerable:!0})},dX={};async function dQ(e,t){console.log(`[Step 1] Identifying affected pages from ${e.length} changed files...`);let r=[/\/pages\/(.*)\.(tsx?|jsx?)$/,/\/app\/(.*)\/(page|route)\.(tsx?|jsx?)$/,/\/routes\/(.*)\.(tsx?|jsx?)$/,/\/src\/routes\/(.*)\.(svelte|tsx?|jsx?)$/,/\.page\.(tsx?|jsx?)$/,/\.route\.(tsx?|jsx?)$/],n=[];for(let t of e)for(let e of r){let r=t.match(e);if(r){let e=r[1]||"";(e=(e=e.replace(/\/(page|route|index)$/,""))||"/").startsWith("/")||(e=`/${e}`),n.includes(e)||n.push(e);break}}if(console.log(`[Step 1] Detected ${n.length} pages from file patterns`),t&&t.length>10){console.log("[Step 1] Analyzing PR description for mentioned pages...");let r=cl({apiKey:process.env.AI_GATEWAY_API_KEY,baseURL:"https://ai-gateway.vercel.sh/v1/ai"})("anthropic/claude-sonnet-4-20250514"),i=`Analyze this PR description and extract any URL paths or routes that are mentioned or affected.
|
|
48
|
+
|
|
49
|
+
PR Description:
|
|
50
|
+
${t}
|
|
51
|
+
|
|
52
|
+
Changed files:
|
|
53
|
+
${e.join("\n")}
|
|
54
|
+
|
|
55
|
+
Return ONLY a JSON array of paths (e.g., ["/", "/about", "/api/users"]). If no specific paths are mentioned, return an empty array [].
|
|
56
|
+
Do not include explanations, just the JSON array.`;try{let{text:e}=await dz({model:r,prompt:i,maxTokens:500}),t=e.match(/\[.*\]/);if(t){let e=JSON.parse(t[0]);for(let t of e)t&&!n.includes(t)&&n.push(t);console.log(`[Step 1] AI found ${e.length} additional pages`)}}catch(e){console.error("[Step 1] AI analysis failed:",e)}}return 0===n.length&&(console.log("[Step 1] No specific pages detected, checking homepage"),n.push("/")),console.log(`[Step 1] Final pages to check: ${n.join(", ")}`),n}async function d0(e,t){console.log(`[Step 2] Crawling ${t.length} pages on ${e}`);let r=[];for(let n of t){console.log(`[Step 2] Crawling: ${n}`);try{let t=`${e}${n}`,i=await fetch(t,{method:"GET",headers:{"User-Agent":"dev3000-pr-checker/1.0",Accept:"text/html,application/json,*/*"}}),a=i.headers.get("content-type")||"",o=a.includes("text/html"),s=a.includes("application/json"),l="";(o||s)&&(l=(await i.text()).substring(0,1e3)),r.push({page:n,url:t,status:i.status,statusText:i.statusText,contentType:a,bodyPreview:l,headers:Object.fromEntries(i.headers.entries())}),console.log(`[Step 2] ${n}: ${i.status} ${i.statusText}`)}catch(t){console.error(`[Step 2] Failed to crawl ${n}:`,t),r.push({page:n,url:`${e}${n}`,status:0,statusText:"Fetch failed",error:t instanceof Error?t.message:String(t)})}}return console.log(`[Step 2] Crawled ${r.length} pages`),r}async function d4(e,t,r,n){console.log("[Step 3] Verifying PR claims against actual behavior...");let i=cl({apiKey:process.env.AI_GATEWAY_API_KEY,baseURL:"https://ai-gateway.vercel.sh/v1/ai"})("anthropic/claude-sonnet-4-20250514"),a=`You are verifying a Pull Request for accuracy. Compare the PR's claims with the actual deployment behavior.
|
|
57
|
+
|
|
58
|
+
PR Title: ${e}
|
|
59
|
+
|
|
60
|
+
PR Description:
|
|
61
|
+
${t}
|
|
62
|
+
|
|
63
|
+
Changed Files:
|
|
64
|
+
${n.join("\n")}
|
|
65
|
+
|
|
66
|
+
Crawl Results from Preview Deployment:
|
|
67
|
+
${JSON.stringify(r,null,2)}
|
|
68
|
+
|
|
69
|
+
Your task:
|
|
70
|
+
1. Analyze whether the PR's claimed changes match the actual behavior shown in the crawl results
|
|
71
|
+
2. Check if pages load successfully (200 status codes)
|
|
72
|
+
3. Identify any errors or unexpected behavior
|
|
73
|
+
4. Verify the changes work as described
|
|
74
|
+
|
|
75
|
+
Respond in this exact JSON format:
|
|
76
|
+
{
|
|
77
|
+
"allChecksPassed": boolean,
|
|
78
|
+
"summary": "Brief summary of findings",
|
|
79
|
+
"details": {
|
|
80
|
+
"claimsVerified": ["List of claims that were verified"],
|
|
81
|
+
"issues": ["List of any issues found"],
|
|
82
|
+
"warnings": ["List of warnings"]
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
Only return valid JSON, no additional text.`;try{let{text:e}=await dz({model:i,prompt:a,maxTokens:1500}),t=e.match(/\{[\s\S]*\}/);if(t){let e=JSON.parse(t[0]);return console.log(`[Step 3] Verification complete: ${e.allChecksPassed?"PASSED":"FAILED"}`),e}return console.error("[Step 3] Failed to parse AI response"),{allChecksPassed:!1,summary:"Verification failed - could not parse AI response",details:{claimsVerified:[],issues:["AI verification returned invalid format"],warnings:[]}}}catch(e){return console.error("[Step 3] Verification failed:",e),{allChecksPassed:!1,summary:`Verification error: ${e instanceof Error?e.message:String(e)}`,details:{claimsVerified:[],issues:[e instanceof Error?e.message:String(e)],warnings:[]}}}}async function d1(e,t){console.log(`[Step 4] Checking performance for ${t.length} pages`);let r=[];for(let n of t){console.log(`[Step 4] Measuring performance: ${n}`);try{let t=`${e}${n}`,i=Date.now(),a=await fetch(t,{method:"GET",headers:{"User-Agent":"dev3000-pr-checker/1.0",Accept:"text/html,*/*"}}),o=Date.now()-i,s=Number.parseInt(a.headers.get("content-length")||"0",10);r.push({page:n,loadTime:o,contentLength:s,status:a.status,isSlow:o>2e3}),console.log(`[Step 4] ${n}: ${o}ms, ${s} bytes`)}catch(e){console.error(`[Step 4] Performance check failed for ${n}:`,e),r.push({page:n,loadTime:0,contentLength:0,status:0,error:e instanceof Error?e.message:String(e),isSlow:!1})}}let n=r.filter(e=>e.isSlow);return console.log(`[Step 4] Performance check complete. ${n.length} slow pages found.`),{results:r,slowPagesCount:n.length,summary:{avgLoadTime:r.reduce((e,t)=>e+t.loadTime,0)/r.length,slowPages:n.map(e=>e.page)}}}async function d6(e){console.log("[Step 5] Generating comprehensive report...");let{prTitle:t,prBody:r,prNumber:n,previewUrl:i,changedFiles:a,pagesToCheck:o,crawlResults:s,verification:l,performanceResults:u,repoOwner:c,repoName:d}=e,p=`# PR Verification Report
|
|
87
|
+
|
|
88
|
+
`;for(let e of(p+=`**PR**: #${n} - ${t}
|
|
89
|
+
**Repository**: ${c}/${d}
|
|
90
|
+
**Preview URL**: ${i}
|
|
91
|
+
**Timestamp**: ${new Date().toISOString()}
|
|
92
|
+
|
|
93
|
+
## Summary
|
|
94
|
+
|
|
95
|
+
${l.allChecksPassed?"✅":"❌"} ${l.summary}
|
|
96
|
+
|
|
97
|
+
## Changed Files
|
|
98
|
+
|
|
99
|
+
`,a))p+=`- ${e}
|
|
100
|
+
`;for(let e of(p+=`
|
|
101
|
+
## Pages Checked
|
|
102
|
+
|
|
103
|
+
`,o))p+=`- ${e}
|
|
104
|
+
`;if(p+=`
|
|
105
|
+
## Verification Results
|
|
106
|
+
|
|
107
|
+
`,l.details.claimsVerified.length>0){for(let e of(p+=`### Claims Verified \u2705
|
|
108
|
+
|
|
109
|
+
`,l.details.claimsVerified))p+=`- ${e}
|
|
110
|
+
`;p+=`
|
|
111
|
+
`}if(l.details.issues.length>0){for(let e of(p+=`### Issues Found \u274C
|
|
112
|
+
|
|
113
|
+
`,l.details.issues))p+=`- ${e}
|
|
114
|
+
`;p+=`
|
|
115
|
+
`}if(l.details.warnings.length>0){for(let e of(p+=`### Warnings \u26A0\uFE0F
|
|
116
|
+
|
|
117
|
+
`,l.details.warnings))p+=`- ${e}
|
|
118
|
+
`;p+=`
|
|
119
|
+
`}for(let e of(p+=`## Crawl Results
|
|
120
|
+
|
|
121
|
+
`,s)){let t=200===e.status?"✅":e.status>=400?"❌":"⚠️";p+=`### ${t} ${e.page}
|
|
122
|
+
|
|
123
|
+
- **URL**: ${e.url}
|
|
124
|
+
- **Status**: ${e.status} ${e.statusText}
|
|
125
|
+
`,e.contentType&&(p+=`- **Content-Type**: ${e.contentType}
|
|
126
|
+
`),e.error&&(p+=`- **Error**: ${e.error}
|
|
127
|
+
`),p+=`
|
|
128
|
+
`}if(p+=`## Performance Analysis
|
|
129
|
+
|
|
130
|
+
**Average Load Time**: ${Math.round(u.summary.avgLoadTime)}ms
|
|
131
|
+
|
|
132
|
+
`,u.slowPagesCount>0){for(let e of(p+=`\u26A0\uFE0F **Slow Pages** (>2s):
|
|
133
|
+
`,u.summary.slowPages))p+=`- ${e}
|
|
134
|
+
`;p+=`
|
|
135
|
+
`}else p+=`\u2705 All pages loaded in under 2 seconds
|
|
136
|
+
|
|
137
|
+
`;for(let e of(p+=`### Detailed Metrics
|
|
138
|
+
|
|
139
|
+
`,u.results))p+=`- **${e.page}**: ${e.loadTime}ms (${e.contentLength} bytes)
|
|
140
|
+
`;return p+=`
|
|
141
|
+
## PR Description
|
|
142
|
+
|
|
143
|
+
${r||"(No description provided)"}
|
|
144
|
+
|
|
145
|
+
---
|
|
146
|
+
|
|
147
|
+
*Generated by dev3000 PR Checker*
|
|
148
|
+
`,console.log(`[Step 5] Report generated (${p.length} characters)`),p}async function d2(e,t,r,n){console.log("[Step 6] Uploading report to blob storage...");let i=new Date().toISOString().replace(/[:.]/g,"-"),a=`pr-check-${t}-${r}-pr${n}-${i}.md`,o=await (0,Y.put)(a,e,{access:"public",contentType:"text/markdown"});return console.log(`[Step 6] Report uploaded: ${o.url}`),{blobUrl:o.url,filename:a}}dY(dX,{checkPerformance:()=>d1,crawlPreviewPages:()=>d0,generateReport:()=>d6,identifyAffectedPages:()=>dQ,uploadReport:()=>d2,verifyPRClaims:()=>d4});var d9=dH({"app/api/cloud/check-pr/steps.ts"(){dq(dQ,"identifyAffectedPages"),dq(d0,"crawlPreviewPages"),dq(d4,"verifyPRClaims"),dq(d1,"checkPerformance"),dq(d6,"generateReport"),dq(d2,"uploadReport"),(0,H.registerStepFunction)("step//app/api/cloud/check-pr/steps.ts//identifyAffectedPages",dQ),(0,H.registerStepFunction)("step//app/api/cloud/check-pr/steps.ts//crawlPreviewPages",d0),(0,H.registerStepFunction)("step//app/api/cloud/check-pr/steps.ts//verifyPRClaims",d4),(0,H.registerStepFunction)("step//app/api/cloud/check-pr/steps.ts//checkPerformance",d1),(0,H.registerStepFunction)("step//app/api/cloud/check-pr/steps.ts//generateReport",d6),(0,H.registerStepFunction)("step//app/api/cloud/check-pr/steps.ts//uploadReport",d2)}}),d3={};async function d5(e,t,r,n,i){console.log(`[Step 0] Creating d3k sandbox for ${r}...`),console.log(`[Step 0] Repository: ${e}`),console.log(`[Step 0] Branch: ${t}`),console.log(`[Step 0] VERCEL_OIDC_TOKEN from env: ${!!process.env.VERCEL_OIDC_TOKEN}`),console.log(`[Step 0] VERCEL_OIDC_TOKEN passed as param: ${!!i}`),console.log(`[Step 0] VERCEL_TOKEN available: ${!!process.env.VERCEL_TOKEN}`),console.log(`[Step 0] User access token provided: ${!!n}`),i&&!process.env.VERCEL_OIDC_TOKEN&&(process.env.VERCEL_OIDC_TOKEN=i,console.log("[Step 0] Set VERCEL_OIDC_TOKEN from workflow context"));let a=await dB({repoUrl:e,branch:t,projectDir:"",packageManager:"pnpm",debug:!0});console.log("[Step 0] Sandbox created successfully"),console.log(`[Step 0] Dev URL: ${a.devUrl}`),console.log(`[Step 0] MCP URL: ${a.mcpUrl}`),console.log("[Step 0] Verifying sandbox URLs are accessible...");try{let e=await fetch(a.devUrl,{method:"HEAD"});console.log(`[Step 0] Dev server check: ${e.status} ${e.statusText}`)}catch(e){console.log(`[Step 0] Dev server check FAILED: ${e instanceof Error?e.message:String(e)}`)}try{let e=await fetch(`${a.mcpUrl}/mcp`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({jsonrpc:"2.0",id:0,method:"tools/list"})});if(console.log(`[Step 0] MCP server check: ${e.status} ${e.statusText}`),e.ok){let t=await e.text();console.log(`[Step 0] MCP server response length: ${t.length} bytes`),console.log(`[Step 0] MCP server response preview: ${t.substring(0,200)}`);try{let e=JSON.parse(t),r=e.result?.tools?.length||0;console.log(`[Step 0] MCP server has ${r} tools available`)}catch(e){console.log(`[Step 0] Failed to parse MCP response as JSON: ${e instanceof Error?e.message:String(e)}`),console.log(`[Step 0] Full response text: ${t}`)}}else{let t=await e.text();console.log(`[Step 0] MCP server returned error response: ${t}`)}}catch(e){console.log(`[Step 0] MCP server check FAILED: ${e instanceof Error?e.message:String(e)}`)}return{mcpUrl:a.mcpUrl,devUrl:a.devUrl}}async function d7(e,t,r){let n=!!r,i=r||e,a=n?e:null;console.log(`[Step 1] Fetching logs from: ${i}`),console.log(`[Step 1] Using sandbox: ${n?"yes":"no"}`),a&&console.log(`[Step 1] MCP URL: ${a}`),console.log(`[Step 1] Bypass token: ${t?"provided":"not provided"}`);try{let e=t?`${i}?x-vercel-protection-bypass=${t}`:i;if(console.log(`[Step 1] Final URL: ${e.replace(t||"","***")}`),n&&a){console.log("[Step 1] Using d3k MCP server to capture CLS metrics and errors..."),console.log("[Step 1] Validating d3k MCP server access...");try{let e=await fetch(`${a}/mcp`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({jsonrpc:"2.0",id:0,method:"tools/list"})});if(e.ok){let t=await e.text();try{let e=JSON.parse(t),r=e.result?.tools?.map(e=>e.name)||[];console.log(`[Step 1] \u2705 d3k MCP server accessible`),console.log(`[Step 1] Available tools (${r.length}): ${r.join(", ")}`);let n=r.some(e=>e.includes("chrome-devtools")),i=r.some(e=>e.includes("nextjs")),a=r.includes("fix_my_app");console.log(`[Step 1] Chrome DevTools MCP: ${n?"✅":"❌"}`),console.log(`[Step 1] Next.js DevTools MCP: ${i?"✅":"❌"}`),console.log(`[Step 1] fix_my_app tool: ${a?"✅":"❌"}`)}catch{console.log(`[Step 1] MCP server responded but couldn't parse tools list: ${t.substring(0,200)}`)}}else console.log(`[Step 1] \u26A0\uFE0F MCP server not accessible: ${e.status}`)}catch(e){console.log(`[Step 1] \u26A0\uFE0F Failed to validate MCP server: ${e instanceof Error?e.message:String(e)}`)}console.log("[Step 1] Navigating browser to app URL...");let t=await fetch(`${a}/mcp`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({jsonrpc:"2.0",id:0,method:"tools/call",params:{name:"execute_browser_action",arguments:{action:"navigate",params:{url:e}}}})});t.ok?console.log("[Step 1] Browser navigation completed"):console.log(`[Step 1] Browser navigation failed: ${t.status}`),console.log("[Step 1] Waiting 5s for page load..."),await new Promise(e=>setTimeout(e,5e3)),console.log("[Step 1] Fetching d3k logs from sandbox to verify it's working...");try{let e=await fetch(`${a}/api/logs`);if(e.ok){let t=await e.text();console.log(`[Step 1] d3k logs (last 1000 chars):
|
|
48
149
|
${t.slice(-1e3)}`)}else console.log(`[Step 1] Could not fetch d3k logs: ${e.status}`)}catch(e){console.log(`[Step 1] Failed to fetch d3k logs: ${e instanceof Error?e.message:String(e)}`)}console.log("[Step 1] Calling fix_my_app with focusArea='performance'...");let r=await fetch(`${a}/mcp`,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json, text/event-stream"},body:JSON.stringify({jsonrpc:"2.0",id:1,method:"tools/call",params:{name:"fix_my_app",arguments:{mode:"snapshot",focusArea:"performance",timeRangeMinutes:5,returnRawData:!1}}})});if(!r.ok)throw Error(`MCP request failed: ${r.status}`);let n=await r.text();console.log(`[Step 1] fix_my_app response length: ${n.length} bytes`),console.log(`[Step 1] fix_my_app response preview (first 500 chars):
|
|
49
150
|
${n.substring(0,500)}`);let o=n.split("\n");console.log(`[Step 1] Response split into ${o.length} lines`);let s="",l=0,u=0;for(let e of o)if(e.startsWith("data: ")){l++;try{let t=JSON.parse(e.substring(6));if(console.log(`[Step 1] Parsed JSON line ${l}:`,JSON.stringify(t).substring(0,200)),t.result?.content)for(let e of t.result.content)"text"===e.type&&(u++,s+=e.text,console.log(`[Step 1] Added text content block ${u}, length: ${e.text.length}`));else t.error&&console.log(`[Step 1] ERROR in response: ${JSON.stringify(t.error)}`)}catch(t){console.log(`[Step 1] Failed to parse JSON line ${l}: ${t instanceof Error?t.message:String(t)}`),console.log(`[Step 1] Problem line: ${e.substring(0,200)}`)}}return console.log(`[Step 1] Processed ${l} data lines, ${u} content blocks`),console.log(`[Step 1] Got ${s.length} chars from fix_my_app (performance analysis)`),0===s.length&&console.log(`[Step 1] WARNING: fix_my_app returned NO data. Full response:
|
|
50
151
|
${n}`),`d3k Performance Analysis for ${i}
|
|
@@ -88,7 +189,7 @@ ${a.substring(0,2e3)}
|
|
|
88
189
|
|
|
89
190
|
Error: ${e}
|
|
90
191
|
|
|
91
|
-
This may indicate the dev server is not accessible or has crashed.`}}}async function
|
|
192
|
+
This may indicate the dev server is not accessible or has crashed.`}}}async function d8(e,t){console.log("[Step 2] Invoking AI agent to analyze logs...");let r=cl({apiKey:process.env.AI_GATEWAY_API_KEY,baseURL:"https://ai-gateway.vercel.sh/v1/ai"})("anthropic/claude-sonnet-4-20250514"),n=`You are a skilled software engineer debugging an application.
|
|
92
193
|
|
|
93
194
|
The dev server is running at: ${t}
|
|
94
195
|
|
|
@@ -139,7 +240,7 @@ curl [BLOB_URL] | git apply
|
|
|
139
240
|
\`\`\`
|
|
140
241
|
|
|
141
242
|
IMPORTANT: The Git Patch section must be a valid unified diff that can be applied directly with 'git apply'.
|
|
142
|
-
If no errors are found, respond with "No critical issues detected."`,{text:i}=await dz({model:r,prompt:n});return console.log(`[Step 2] AI agent response (first 500 chars): ${i.substring(0,500)}...`),i}async function
|
|
243
|
+
If no errors are found, respond with "No critical issues detected."`,{text:i}=await dz({model:r,prompt:n});return console.log(`[Step 2] AI agent response (first 500 chars): ${i.substring(0,500)}...`),i}async function pe(e,t,r,n){console.log("[Step 3] Uploading fix proposal to blob storage...");let i=new Date().toISOString(),a=`# Fix Proposal for ${t}
|
|
143
244
|
|
|
144
245
|
**Generated**: ${i}
|
|
145
246
|
**Powered by**: [dev3000](https://github.com/vercel-labs/dev3000) with Claude Code
|
|
@@ -175,7 +276,7 @@ dev3000 monitors your development server, captures errors in real-time, and uses
|
|
|
175
276
|
- Suggest specific code changes
|
|
176
277
|
|
|
177
278
|
Learn more at https://github.com/vercel-labs/dev3000
|
|
178
|
-
`,o=i.replace(/[:.]/g,"-"),s=`fix-${t}-${o}.md`,l=await (0,Y.put)(s,a,{access:"public",contentType:"text/markdown"});return console.log(`[Step 3] Fix proposal uploaded to: ${l.url}`),{success:!0,projectName:t,fixProposal:e,blobUrl:l.url,message:"Fix analysis completed and uploaded to blob storage"}}async function
|
|
279
|
+
`,o=i.replace(/[:.]/g,"-"),s=`fix-${t}-${o}.md`,l=await (0,Y.put)(s,a,{access:"public",contentType:"text/markdown"});return console.log(`[Step 3] Fix proposal uploaded to: ${l.url}`),{success:!0,projectName:t,fixProposal:e,blobUrl:l.url,message:"Fix analysis completed and uploaded to blob storage"}}async function pt(e,t,r,n,i,a){console.log(`[Step 4] Creating GitHub PR for ${r}/${n}...`);let o=process.env.GITHUB_TOKEN;if(!o)return console.error("[Step 4] GITHUB_TOKEN not found in environment"),{success:!1,error:"GitHub token not configured"};try{let s=e.match(/```diff\n([\s\S]*?)\n```/);if(!s)return console.error("[Step 4] No git patch found in fix proposal"),{success:!1,error:"No git patch found in fix proposal"};let l=s[1];console.log(`[Step 4] Extracted patch (${l.length} chars)`);let u=pr(l);if(0===u.length)return console.error("[Step 4] Failed to parse any file changes from patch"),{success:!1,error:"Failed to parse file changes from patch"};console.log(`[Step 4] Parsed ${u.length} file change(s)`);let c=`dev3000-fix-${a}-${Date.now()}`;console.log(`[Step 4] Branch name: ${c}`);let d=await fetch(`https://api.github.com/repos/${r}/${n}/git/ref/heads/${i}`,{headers:{Authorization:`Bearer ${o}`,Accept:"application/vnd.github.v3+json"}});if(!d.ok){let e=await d.text();return console.error(`[Step 4] Failed to get base branch: ${e}`),{success:!1,error:`Failed to get base branch: ${d.status}`}}let p=(await d.json()).object.sha;console.log(`[Step 4] Base SHA: ${p}`);let m=await fetch(`https://api.github.com/repos/${r}/${n}/git/refs`,{method:"POST",headers:{Authorization:`Bearer ${o}`,Accept:"application/vnd.github.v3+json","Content-Type":"application/json"},body:JSON.stringify({ref:`refs/heads/${c}`,sha:p})});if(!m.ok){let e=await m.text();return console.error(`[Step 4] Failed to create branch: ${e}`),{success:!1,error:`Failed to create branch: ${m.status}`}}for(let e of(console.log(`[Step 4] Created branch: ${c}`),u)){console.log(`[Step 4] Processing file: ${e.path}`);let t=await fetch(`https://api.github.com/repos/${r}/${n}/contents/${e.path}?ref=${c}`,{headers:{Authorization:`Bearer ${o}`,Accept:"application/vnd.github.v3+json"}}),i="",s="";if(t.ok){let e=await t.json();s=e.sha,i=Buffer.from(e.content,"base64").toString("utf-8")}else console.log("[Step 4] File doesn't exist, will create new file");let l=pn(i,e.changes),u=await fetch(`https://api.github.com/repos/${r}/${n}/contents/${e.path}`,{method:"PUT",headers:{Authorization:`Bearer ${o}`,Accept:"application/vnd.github.v3+json","Content-Type":"application/json"},body:JSON.stringify({message:`Fix: Apply dev3000 fix for ${a}`,content:Buffer.from(l).toString("base64"),branch:c,...s&&{sha:s}})});if(!u.ok){let t=await u.text();return console.error(`[Step 4] Failed to update file ${e.path}: ${t}`),{success:!1,error:`Failed to update file ${e.path}: ${u.status}`}}console.log(`[Step 4] Updated file: ${e.path}`)}let f=`## Automated Fix Proposal
|
|
179
280
|
|
|
180
281
|
This PR was automatically generated by [dev3000](https://github.com/vercel-labs/dev3000) after analyzing your application.
|
|
181
282
|
|
|
@@ -188,107 +289,6 @@ ${e}
|
|
|
188
289
|
|
|
189
290
|
\u{1F916} Generated with [Claude Code](https://claude.com/claude-code)
|
|
190
291
|
|
|
191
|
-
Co-Authored-By: Claude (dev3000) <noreply@anthropic.com>`,g=await fetch(`https://api.github.com/repos/${r}/${n}/pulls`,{method:"POST",headers:{Authorization:`Bearer ${o}`,Accept:"application/vnd.github.v3+json","Content-Type":"application/json"},body:JSON.stringify({title:`Fix: ${a} - Automated fix from dev3000`,head:c,base:i,body:f})});if(!g.ok){let e=await g.text();return console.error(`[Step 4] Failed to create PR: ${e}`),{success:!1,error:`Failed to create PR: ${g.status}`}}let v=await g.json();return console.log(`[Step 4] Created PR: ${v.html_url}`),{success:!0,prUrl:v.html_url,prNumber:v.number,branch:c}}catch(e){return console.error("[Step 4] Error creating PR:",e),{success:!1,error:e instanceof Error?e.message:String(e)}}}function d2(e){let t=[];for(let r of e.split(/diff --git /).filter(Boolean)){let e=r.split("\n"),n=e[0].match(/a\/(.*?) b\//);if(!n)continue;let i=n[1],a=e.slice(1).join("\n");t.push({path:i,changes:a})}return t}function d9(e,t){let r=e.split("\n"),n=t.split("\n"),i=0,a=[];for(let e of n)if(e.startsWith("@@")){let t=e.match(/@@ -(\d+)/);t&&(i=Number.parseInt(t[1],10)-1)}else e.startsWith("-")?i++:e.startsWith("+")?a.push(e.substring(1)):e.startsWith(" ")&&i<r.length&&(a.push(r[i]),i++);return a.join("\n")}async function d3(e){console.log("[Cleanup] Stopping sandbox...");try{await e(),console.log("[Cleanup] Sandbox stopped successfully")}catch(e){console.error("[Cleanup] Error stopping sandbox:",e)}}dY(dX,{analyzeLogsWithAgent:()=>d4,cleanupSandbox:()=>d3,createD3kSandbox:()=>dQ,createGitHubPR:()=>d6,fetchRealLogs:()=>d0,uploadToBlob:()=>d1});var d5=dH({"app/api/cloud/fix-workflow/steps.ts"(){dq(dQ,"createD3kSandbox"),dq(d0,"fetchRealLogs"),dq(d4,"analyzeLogsWithAgent"),dq(d1,"uploadToBlob"),dq(d6,"createGitHubPR"),dq(d2,"parsePatchToFileChanges"),dq(d9,"applyPatchChanges"),dq(d3,"cleanupSandbox"),(0,H.registerStepFunction)("step//app/api/cloud/fix-workflow/steps.ts//createD3kSandbox",dQ),(0,H.registerStepFunction)("step//app/api/cloud/fix-workflow/steps.ts//fetchRealLogs",d0),(0,H.registerStepFunction)("step//app/api/cloud/fix-workflow/steps.ts//analyzeLogsWithAgent",d4),(0,H.registerStepFunction)("step//app/api/cloud/fix-workflow/steps.ts//uploadToBlob",d1),(0,H.registerStepFunction)("step//app/api/cloud/fix-workflow/steps.ts//createGitHubPR",d6),(0,H.registerStepFunction)("step//app/api/cloud/fix-workflow/steps.ts//cleanupSandbox",d3)}}),d7={};async function d8(e,t){console.log(`[Step 1] Identifying affected pages from ${e.length} changed files...`);let r=[/\/pages\/(.*)\.(tsx?|jsx?)$/,/\/app\/(.*)\/(page|route)\.(tsx?|jsx?)$/,/\/routes\/(.*)\.(tsx?|jsx?)$/,/\/src\/routes\/(.*)\.(svelte|tsx?|jsx?)$/,/\.page\.(tsx?|jsx?)$/,/\.route\.(tsx?|jsx?)$/],n=[];for(let t of e)for(let e of r){let r=t.match(e);if(r){let e=r[1]||"";(e=(e=e.replace(/\/(page|route|index)$/,""))||"/").startsWith("/")||(e=`/${e}`),n.includes(e)||n.push(e);break}}if(console.log(`[Step 1] Detected ${n.length} pages from file patterns`),t&&t.length>10){console.log("[Step 1] Analyzing PR description for mentioned pages...");let r=cl({apiKey:process.env.AI_GATEWAY_API_KEY,baseURL:"https://ai-gateway.vercel.sh/v1/ai"})("anthropic/claude-sonnet-4-20250514"),i=`Analyze this PR description and extract any URL paths or routes that are mentioned or affected.
|
|
192
|
-
|
|
193
|
-
PR Description:
|
|
194
|
-
${t}
|
|
195
|
-
|
|
196
|
-
Changed files:
|
|
197
|
-
${e.join("\n")}
|
|
198
|
-
|
|
199
|
-
Return ONLY a JSON array of paths (e.g., ["/", "/about", "/api/users"]). If no specific paths are mentioned, return an empty array [].
|
|
200
|
-
Do not include explanations, just the JSON array.`;try{let{text:e}=await dz({model:r,prompt:i,maxTokens:500}),t=e.match(/\[.*\]/);if(t){let e=JSON.parse(t[0]);for(let t of e)t&&!n.includes(t)&&n.push(t);console.log(`[Step 1] AI found ${e.length} additional pages`)}}catch(e){console.error("[Step 1] AI analysis failed:",e)}}return 0===n.length&&(console.log("[Step 1] No specific pages detected, checking homepage"),n.push("/")),console.log(`[Step 1] Final pages to check: ${n.join(", ")}`),n}async function pe(e,t){console.log(`[Step 2] Crawling ${t.length} pages on ${e}`);let r=[];for(let n of t){console.log(`[Step 2] Crawling: ${n}`);try{let t=`${e}${n}`,i=await fetch(t,{method:"GET",headers:{"User-Agent":"dev3000-pr-checker/1.0",Accept:"text/html,application/json,*/*"}}),a=i.headers.get("content-type")||"",o=a.includes("text/html"),s=a.includes("application/json"),l="";(o||s)&&(l=(await i.text()).substring(0,1e3)),r.push({page:n,url:t,status:i.status,statusText:i.statusText,contentType:a,bodyPreview:l,headers:Object.fromEntries(i.headers.entries())}),console.log(`[Step 2] ${n}: ${i.status} ${i.statusText}`)}catch(t){console.error(`[Step 2] Failed to crawl ${n}:`,t),r.push({page:n,url:`${e}${n}`,status:0,statusText:"Fetch failed",error:t instanceof Error?t.message:String(t)})}}return console.log(`[Step 2] Crawled ${r.length} pages`),r}async function pt(e,t,r,n){console.log("[Step 3] Verifying PR claims against actual behavior...");let i=cl({apiKey:process.env.AI_GATEWAY_API_KEY,baseURL:"https://ai-gateway.vercel.sh/v1/ai"})("anthropic/claude-sonnet-4-20250514"),a=`You are verifying a Pull Request for accuracy. Compare the PR's claims with the actual deployment behavior.
|
|
201
|
-
|
|
202
|
-
PR Title: ${e}
|
|
203
|
-
|
|
204
|
-
PR Description:
|
|
205
|
-
${t}
|
|
206
|
-
|
|
207
|
-
Changed Files:
|
|
208
|
-
${n.join("\n")}
|
|
209
|
-
|
|
210
|
-
Crawl Results from Preview Deployment:
|
|
211
|
-
${JSON.stringify(r,null,2)}
|
|
212
|
-
|
|
213
|
-
Your task:
|
|
214
|
-
1. Analyze whether the PR's claimed changes match the actual behavior shown in the crawl results
|
|
215
|
-
2. Check if pages load successfully (200 status codes)
|
|
216
|
-
3. Identify any errors or unexpected behavior
|
|
217
|
-
4. Verify the changes work as described
|
|
218
|
-
|
|
219
|
-
Respond in this exact JSON format:
|
|
220
|
-
{
|
|
221
|
-
"allChecksPassed": boolean,
|
|
222
|
-
"summary": "Brief summary of findings",
|
|
223
|
-
"details": {
|
|
224
|
-
"claimsVerified": ["List of claims that were verified"],
|
|
225
|
-
"issues": ["List of any issues found"],
|
|
226
|
-
"warnings": ["List of warnings"]
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
Only return valid JSON, no additional text.`;try{let{text:e}=await dz({model:i,prompt:a,maxTokens:1500}),t=e.match(/\{[\s\S]*\}/);if(t){let e=JSON.parse(t[0]);return console.log(`[Step 3] Verification complete: ${e.allChecksPassed?"PASSED":"FAILED"}`),e}return console.error("[Step 3] Failed to parse AI response"),{allChecksPassed:!1,summary:"Verification failed - could not parse AI response",details:{claimsVerified:[],issues:["AI verification returned invalid format"],warnings:[]}}}catch(e){return console.error("[Step 3] Verification failed:",e),{allChecksPassed:!1,summary:`Verification error: ${e instanceof Error?e.message:String(e)}`,details:{claimsVerified:[],issues:[e instanceof Error?e.message:String(e)],warnings:[]}}}}async function pr(e,t){console.log(`[Step 4] Checking performance for ${t.length} pages`);let r=[];for(let n of t){console.log(`[Step 4] Measuring performance: ${n}`);try{let t=`${e}${n}`,i=Date.now(),a=await fetch(t,{method:"GET",headers:{"User-Agent":"dev3000-pr-checker/1.0",Accept:"text/html,*/*"}}),o=Date.now()-i,s=Number.parseInt(a.headers.get("content-length")||"0",10);r.push({page:n,loadTime:o,contentLength:s,status:a.status,isSlow:o>2e3}),console.log(`[Step 4] ${n}: ${o}ms, ${s} bytes`)}catch(e){console.error(`[Step 4] Performance check failed for ${n}:`,e),r.push({page:n,loadTime:0,contentLength:0,status:0,error:e instanceof Error?e.message:String(e),isSlow:!1})}}let n=r.filter(e=>e.isSlow);return console.log(`[Step 4] Performance check complete. ${n.length} slow pages found.`),{results:r,slowPagesCount:n.length,summary:{avgLoadTime:r.reduce((e,t)=>e+t.loadTime,0)/r.length,slowPages:n.map(e=>e.page)}}}async function pn(e){console.log("[Step 5] Generating comprehensive report...");let{prTitle:t,prBody:r,prNumber:n,previewUrl:i,changedFiles:a,pagesToCheck:o,crawlResults:s,verification:l,performanceResults:u,repoOwner:c,repoName:d}=e,p=`# PR Verification Report
|
|
231
|
-
|
|
232
|
-
`;for(let e of(p+=`**PR**: #${n} - ${t}
|
|
233
|
-
**Repository**: ${c}/${d}
|
|
234
|
-
**Preview URL**: ${i}
|
|
235
|
-
**Timestamp**: ${new Date().toISOString()}
|
|
236
|
-
|
|
237
|
-
## Summary
|
|
238
|
-
|
|
239
|
-
${l.allChecksPassed?"✅":"❌"} ${l.summary}
|
|
240
|
-
|
|
241
|
-
## Changed Files
|
|
242
|
-
|
|
243
|
-
`,a))p+=`- ${e}
|
|
244
|
-
`;for(let e of(p+=`
|
|
245
|
-
## Pages Checked
|
|
246
|
-
|
|
247
|
-
`,o))p+=`- ${e}
|
|
248
|
-
`;if(p+=`
|
|
249
|
-
## Verification Results
|
|
250
|
-
|
|
251
|
-
`,l.details.claimsVerified.length>0){for(let e of(p+=`### Claims Verified \u2705
|
|
252
|
-
|
|
253
|
-
`,l.details.claimsVerified))p+=`- ${e}
|
|
254
|
-
`;p+=`
|
|
255
|
-
`}if(l.details.issues.length>0){for(let e of(p+=`### Issues Found \u274C
|
|
256
|
-
|
|
257
|
-
`,l.details.issues))p+=`- ${e}
|
|
258
|
-
`;p+=`
|
|
259
|
-
`}if(l.details.warnings.length>0){for(let e of(p+=`### Warnings \u26A0\uFE0F
|
|
260
|
-
|
|
261
|
-
`,l.details.warnings))p+=`- ${e}
|
|
262
|
-
`;p+=`
|
|
263
|
-
`}for(let e of(p+=`## Crawl Results
|
|
264
|
-
|
|
265
|
-
`,s)){let t=200===e.status?"✅":e.status>=400?"❌":"⚠️";p+=`### ${t} ${e.page}
|
|
266
|
-
|
|
267
|
-
- **URL**: ${e.url}
|
|
268
|
-
- **Status**: ${e.status} ${e.statusText}
|
|
269
|
-
`,e.contentType&&(p+=`- **Content-Type**: ${e.contentType}
|
|
270
|
-
`),e.error&&(p+=`- **Error**: ${e.error}
|
|
271
|
-
`),p+=`
|
|
272
|
-
`}if(p+=`## Performance Analysis
|
|
273
|
-
|
|
274
|
-
**Average Load Time**: ${Math.round(u.summary.avgLoadTime)}ms
|
|
275
|
-
|
|
276
|
-
`,u.slowPagesCount>0){for(let e of(p+=`\u26A0\uFE0F **Slow Pages** (>2s):
|
|
277
|
-
`,u.summary.slowPages))p+=`- ${e}
|
|
278
|
-
`;p+=`
|
|
279
|
-
`}else p+=`\u2705 All pages loaded in under 2 seconds
|
|
280
|
-
|
|
281
|
-
`;for(let e of(p+=`### Detailed Metrics
|
|
282
|
-
|
|
283
|
-
`,u.results))p+=`- **${e.page}**: ${e.loadTime}ms (${e.contentLength} bytes)
|
|
284
|
-
`;return p+=`
|
|
285
|
-
## PR Description
|
|
286
|
-
|
|
287
|
-
${r||"(No description provided)"}
|
|
288
|
-
|
|
289
|
-
---
|
|
290
|
-
|
|
291
|
-
*Generated by dev3000 PR Checker*
|
|
292
|
-
`,console.log(`[Step 5] Report generated (${p.length} characters)`),p}async function pi(e,t,r,n){console.log("[Step 6] Uploading report to blob storage...");let i=new Date().toISOString().replace(/[:.]/g,"-"),a=`pr-check-${t}-${r}-pr${n}-${i}.md`,o=await (0,Y.put)(a,e,{access:"public",contentType:"text/markdown"});return console.log(`[Step 6] Report uploaded: ${o.url}`),{blobUrl:o.url,filename:a}}dY(d7,{checkPerformance:()=>pr,crawlPreviewPages:()=>pe,generateReport:()=>pn,identifyAffectedPages:()=>d8,uploadReport:()=>pi,verifyPRClaims:()=>pt});var pa=dH({"app/api/cloud/check-pr/steps.ts"(){dq(d8,"identifyAffectedPages"),dq(pe,"crawlPreviewPages"),dq(pt,"verifyPRClaims"),dq(pr,"checkPerformance"),dq(pn,"generateReport"),dq(pi,"uploadReport"),(0,H.registerStepFunction)("step//app/api/cloud/check-pr/steps.ts//identifyAffectedPages",d8),(0,H.registerStepFunction)("step//app/api/cloud/check-pr/steps.ts//crawlPreviewPages",pe),(0,H.registerStepFunction)("step//app/api/cloud/check-pr/steps.ts//verifyPRClaims",pt),(0,H.registerStepFunction)("step//app/api/cloud/check-pr/steps.ts//checkPerformance",pr),(0,H.registerStepFunction)("step//app/api/cloud/check-pr/steps.ts//generateReport",pn),(0,H.registerStepFunction)("step//app/api/cloud/check-pr/steps.ts//uploadReport",pi)}});async function po(e){return e.arrayBuffer()}async function ps(e){return e.json()}async function pl(e){return e.text()}async function pu(e,t,r,n,i){let{createD3kSandbox:a}=await Promise.resolve().then(()=>(d5(),dX));return a(e,t,r,n,i)}async function pc(e,t,r){let{fetchRealLogs:n}=await Promise.resolve().then(()=>(d5(),dX));return n(e,t,r)}async function pd(e,t){let{analyzeLogsWithAgent:r}=await Promise.resolve().then(()=>(d5(),dX));return r(e,t)}async function pp(e,t,r,n){let{uploadToBlob:i}=await Promise.resolve().then(()=>(d5(),dX));return i(e,t,r,n)}async function pm(e,t,r,n,i,a){let{createGitHubPR:o}=await Promise.resolve().then(()=>(d5(),dX));return o(e,t,r,n,i,a)}async function pf(e,t){let{identifyAffectedPages:r}=await Promise.resolve().then(()=>(pa(),d7));return r(e,t)}async function pg(e,t){let{crawlPreviewPages:r}=await Promise.resolve().then(()=>(pa(),d7));return r(e,t)}async function pv(e,t,r,n){let{verifyPRClaims:i}=await Promise.resolve().then(()=>(pa(),d7));return i(e,t,r,n)}async function ph(e,t){let{checkPerformance:r}=await Promise.resolve().then(()=>(pa(),d7));return r(e,t)}async function py(e){let{generateReport:t}=await Promise.resolve().then(()=>(pa(),d7));return t(e)}async function p$(e,t,r,n){let{uploadReport:i}=await Promise.resolve().then(()=>(pa(),d7));return i(e,t,r,n)}dq(po,"__builtin_response_array_buffer"),dq(ps,"__builtin_response_json"),dq(pl,"__builtin_response_text"),(0,H.registerStepFunction)("__builtin_response_array_buffer",po),(0,H.registerStepFunction)("__builtin_response_json",ps),(0,H.registerStepFunction)("__builtin_response_text",pl),dq(pu,"createD3kSandbox"),dq(pc,"fetchRealLogs"),dq(pd,"analyzeLogsWithAgent"),dq(pp,"uploadToBlob"),dq(pm,"createGitHubPR"),(0,H.registerStepFunction)("step//app/api/cloud/fix-workflow/workflow.ts//createD3kSandbox",pu),(0,H.registerStepFunction)("step//app/api/cloud/fix-workflow/workflow.ts//fetchRealLogs",pc),(0,H.registerStepFunction)("step//app/api/cloud/fix-workflow/workflow.ts//analyzeLogsWithAgent",pd),(0,H.registerStepFunction)("step//app/api/cloud/fix-workflow/workflow.ts//uploadToBlob",pp),(0,H.registerStepFunction)("step//app/api/cloud/fix-workflow/workflow.ts//createGitHubPR",pm),dq(pf,"identifyAffectedPagesStep"),dq(pg,"crawlPreviewPagesStep"),dq(pv,"verifyPRClaimsStep"),dq(ph,"checkPerformanceStep"),dq(py,"generateReportStep"),dq(p$,"uploadReportStep"),(0,H.registerStepFunction)("step//app/api/cloud/check-pr/workflow.ts//identifyAffectedPagesStep",pf),(0,H.registerStepFunction)("step//app/api/cloud/check-pr/workflow.ts//crawlPreviewPagesStep",pg),(0,H.registerStepFunction)("step//app/api/cloud/check-pr/workflow.ts//verifyPRClaimsStep",pv),(0,H.registerStepFunction)("step//app/api/cloud/check-pr/workflow.ts//checkPerformanceStep",ph),(0,H.registerStepFunction)("step//app/api/cloud/check-pr/workflow.ts//generateReportStep",py),(0,H.registerStepFunction)("step//app/api/cloud/check-pr/workflow.ts//uploadReportStep",p$),d5(),pa(),e.s([],43048),e.i(43048),e.s(["POST",()=>dK.stepEntrypoint],42530);var pb=e.i(42530);let p_=new z.AppRouteRouteModule({definition:{kind:T.RouteKind.APP_ROUTE,page:"/.well-known/workflow/v1/step/route",pathname:"/.well-known/workflow/v1/step",filename:"route",bundlePath:""},distDir:".next",relativeProjectDir:"",resolvedPagePath:"[project]/mcp-server/app/.well-known/workflow/v1/step/route.js",nextConfigOutput:"",userland:pb}),{workAsyncStorage:pw,workUnitAsyncStorage:px,serverHooks:pk}=p_;function pI(){return(0,j.patchFetch)({workAsyncStorage:pw,workUnitAsyncStorage:px})}async function pS(e,t,r){p_.isDev&&(0,U.addRequestMeta)(e,"devRequestTimingInternalsEnd",process.hrtime.bigint());let n="/.well-known/workflow/v1/step/route";n=n.replace(/\/index$/,"")||"/";let i=await p_.prepare(e,t,{srcPage:n,multiZoneDraftMode:!1});if(!i)return t.statusCode=400,t.end("Bad Request"),null==r.waitUntil||r.waitUntil.call(r,Promise.resolve()),null;let{buildId:a,params:o,nextConfig:s,parsedUrl:l,isDraftMode:u,prerenderManifest:c,routerServerContext:d,isOnDemandRevalidate:p,revalidateOnlyGenerated:m,resolvedPathname:f,clientReferenceManifest:g,serverActionsManifest:v}=i,h=(0,R.normalizeAppPath)(n),y=!!(c.dynamicRoutes[h]||c.routes[f]),$=async()=>((null==d?void 0:d.render404)?await d.render404(e,t,l,!1):t.end("This page could not be found"),null);if(y&&!u){let e=!!c.routes[f],t=c.dynamicRoutes[h];if(t&&!1===t.fallback&&!e){if(s.experimental.adapterPath)return await $();throw new W.NoFallbackError}}let b=null;!y||p_.isDev||u||(b="/index"===(b=f)?"/":b);let _=!0===p_.isDev||!y,w=y&&!_;v&&g&&(0,D.setReferenceManifestsSingleton)({page:n,clientReferenceManifest:g,serverActionsManifest:v,serverModuleMap:(0,C.createServerModuleMap)({serverActionsManifest:v})});let x=e.method||"GET",k=(0,A.getTracer)(),I=k.getActiveScopeSpan(),S={params:o,prerenderManifest:c,renderOpts:{experimental:{authInterrupts:!!s.experimental.authInterrupts},cacheComponents:!!s.cacheComponents,supportsDynamicResponse:_,incrementalCache:(0,U.getRequestMeta)(e,"incrementalCache"),cacheLifeProfiles:s.cacheLife,waitUntil:r.waitUntil,onClose:e=>{t.on("close",e)},onAfterTaskError:void 0,onInstrumentationRequestError:(t,r,n)=>p_.onRequestError(e,t,n,d)},sharedContext:{buildId:a}},O=new L.NodeNextRequest(e),P=new L.NodeNextResponse(t),E=F.NextRequestAdapter.fromNodeNextRequest(O,(0,F.signalFromNodeResponse)(t));try{let i=async e=>p_.handle(E,S).finally(()=>{if(!e)return;e.setAttributes({"http.status_code":t.statusCode,"next.rsc":!1});let r=k.getRootSpanAttributes();if(!r)return;if(r.get("next.span_type")!==M.BaseServerSpan.handleRequest)return void console.warn(`Unexpected root span type '${r.get("next.span_type")}'. Please report this Next.js issue https://github.com/vercel/next.js`);let i=r.get("next.route");if(i){let t=`${x} ${i}`;e.setAttributes({"next.route":i,"http.route":i,"next.span_name":t}),e.updateName(t)}else e.updateName(`${x} ${n}`)}),a=!!(0,U.getRequestMeta)(e,"minimalMode"),o=async o=>{var l,f;let g=async({previousCacheEntry:s})=>{try{if(!a&&p&&m&&!s)return t.statusCode=404,t.setHeader("x-nextjs-cache","REVALIDATED"),t.end("This page could not be found"),null;let n=await i(o);e.fetchMetrics=S.renderOpts.fetchMetrics;let l=S.renderOpts.pendingWaitUntil;l&&r.waitUntil&&(r.waitUntil(l),l=void 0);let u=S.renderOpts.collectedTags;if(!y)return await (0,B.sendResponse)(O,P,n,S.renderOpts.pendingWaitUntil),null;{let e=await n.blob(),t=(0,V.toNodeOutgoingHttpHeaders)(n.headers);u&&(t[G.NEXT_CACHE_TAGS_HEADER]=u),!t["content-type"]&&e.type&&(t["content-type"]=e.type);let r=void 0!==S.renderOpts.collectedRevalidate&&!(S.renderOpts.collectedRevalidate>=G.INFINITE_CACHE)&&S.renderOpts.collectedRevalidate,i=void 0===S.renderOpts.collectedExpire||S.renderOpts.collectedExpire>=G.INFINITE_CACHE?void 0:S.renderOpts.collectedExpire;return{value:{kind:q.CachedRouteKind.APP_ROUTE,status:n.status,body:Buffer.from(await e.arrayBuffer()),headers:t},cacheControl:{revalidate:r,expire:i}}}}catch(t){throw(null==s?void 0:s.isStale)&&await p_.onRequestError(e,t,{routerKind:"App Router",routePath:n,routeType:"route",revalidateReason:(0,J.getRevalidateReason)({isStaticGeneration:w,isOnDemandRevalidate:p})},d),t}},v=await p_.handleResponse({req:e,nextConfig:s,cacheKey:b,routeKind:T.RouteKind.APP_ROUTE,isFallback:!1,prerenderManifest:c,isRoutePPREnabled:!1,isOnDemandRevalidate:p,revalidateOnlyGenerated:m,responseGenerator:g,waitUntil:r.waitUntil,isMinimalMode:a});if(!y)return null;if((null==v||null==(l=v.value)?void 0:l.kind)!==q.CachedRouteKind.APP_ROUTE)throw Object.defineProperty(Error(`Invariant: app-route received invalid cache entry ${null==v||null==(f=v.value)?void 0:f.kind}`),"__NEXT_ERROR_CODE",{value:"E701",enumerable:!1,configurable:!0});a||t.setHeader("x-nextjs-cache",p?"REVALIDATED":v.isMiss?"MISS":v.isStale?"STALE":"HIT"),u&&t.setHeader("Cache-Control","private, no-cache, no-store, max-age=0, must-revalidate");let h=(0,V.fromNodeOutgoingHttpHeaders)(v.value.headers);return a&&y||h.delete(G.NEXT_CACHE_TAGS_HEADER),!v.cacheControl||t.getHeader("Cache-Control")||h.get("Cache-Control")||h.set("Cache-Control",(0,K.getCacheControlHeader)(v.cacheControl)),await (0,B.sendResponse)(O,P,new Response(v.value.body,{headers:h,status:v.value.status||200})),null};I?await o(I):await k.withPropagatedContext(e.headers,()=>k.trace(M.BaseServerSpan.handleRequest,{spanName:`${x} ${n}`,kind:A.SpanKind.SERVER,attributes:{"http.method":x,"http.target":e.url}},o))}catch(t){if(t instanceof W.NoFallbackError||await p_.onRequestError(e,t,{routerKind:"App Router",routePath:h,routeType:"route",revalidateReason:(0,J.getRevalidateReason)({isStaticGeneration:w,isOnDemandRevalidate:p})}),y)throw t;return await (0,B.sendResponse)(O,P,new Response(null,{status:500})),null}}e.s(["handler",()=>pS,"patchFetch",()=>pI,"routeModule",()=>p_,"serverHooks",()=>pk,"workAsyncStorage",()=>pw,"workUnitAsyncStorage",()=>px],42845)}];
|
|
292
|
+
Co-Authored-By: Claude (dev3000) <noreply@anthropic.com>`,g=await fetch(`https://api.github.com/repos/${r}/${n}/pulls`,{method:"POST",headers:{Authorization:`Bearer ${o}`,Accept:"application/vnd.github.v3+json","Content-Type":"application/json"},body:JSON.stringify({title:`Fix: ${a} - Automated fix from dev3000`,head:c,base:i,body:f})});if(!g.ok){let e=await g.text();return console.error(`[Step 4] Failed to create PR: ${e}`),{success:!1,error:`Failed to create PR: ${g.status}`}}let v=await g.json();return console.log(`[Step 4] Created PR: ${v.html_url}`),{success:!0,prUrl:v.html_url,prNumber:v.number,branch:c}}catch(e){return console.error("[Step 4] Error creating PR:",e),{success:!1,error:e instanceof Error?e.message:String(e)}}}function pr(e){let t=[];for(let r of e.split(/diff --git /).filter(Boolean)){let e=r.split("\n"),n=e[0].match(/a\/(.*?) b\//);if(!n)continue;let i=n[1],a=e.slice(1).join("\n");t.push({path:i,changes:a})}return t}function pn(e,t){let r=e.split("\n"),n=t.split("\n"),i=0,a=[];for(let e of n)if(e.startsWith("@@")){let t=e.match(/@@ -(\d+)/);t&&(i=Number.parseInt(t[1],10)-1)}else e.startsWith("-")?i++:e.startsWith("+")?a.push(e.substring(1)):e.startsWith(" ")&&i<r.length&&(a.push(r[i]),i++);return a.join("\n")}async function pi(e){console.log("[Cleanup] Stopping sandbox...");try{await e(),console.log("[Cleanup] Sandbox stopped successfully")}catch(e){console.error("[Cleanup] Error stopping sandbox:",e)}}dY(d3,{analyzeLogsWithAgent:()=>d8,cleanupSandbox:()=>pi,createD3kSandbox:()=>d5,createGitHubPR:()=>pt,fetchRealLogs:()=>d7,uploadToBlob:()=>pe});var pa=dH({"app/api/cloud/fix-workflow/steps.ts"(){dq(d5,"createD3kSandbox"),dq(d7,"fetchRealLogs"),dq(d8,"analyzeLogsWithAgent"),dq(pe,"uploadToBlob"),dq(pt,"createGitHubPR"),dq(pr,"parsePatchToFileChanges"),dq(pn,"applyPatchChanges"),dq(pi,"cleanupSandbox"),(0,H.registerStepFunction)("step//app/api/cloud/fix-workflow/steps.ts//createD3kSandbox",d5),(0,H.registerStepFunction)("step//app/api/cloud/fix-workflow/steps.ts//fetchRealLogs",d7),(0,H.registerStepFunction)("step//app/api/cloud/fix-workflow/steps.ts//analyzeLogsWithAgent",d8),(0,H.registerStepFunction)("step//app/api/cloud/fix-workflow/steps.ts//uploadToBlob",pe),(0,H.registerStepFunction)("step//app/api/cloud/fix-workflow/steps.ts//createGitHubPR",pt),(0,H.registerStepFunction)("step//app/api/cloud/fix-workflow/steps.ts//cleanupSandbox",pi)}});async function po(e){return e.arrayBuffer()}async function ps(e){return e.json()}async function pl(e){return e.text()}async function pu(e,t){let{identifyAffectedPages:r}=await Promise.resolve().then(()=>(d9(),dX));return r(e,t)}async function pc(e,t){let{crawlPreviewPages:r}=await Promise.resolve().then(()=>(d9(),dX));return r(e,t)}async function pd(e,t,r,n){let{verifyPRClaims:i}=await Promise.resolve().then(()=>(d9(),dX));return i(e,t,r,n)}async function pp(e,t){let{checkPerformance:r}=await Promise.resolve().then(()=>(d9(),dX));return r(e,t)}async function pm(e){let{generateReport:t}=await Promise.resolve().then(()=>(d9(),dX));return t(e)}async function pf(e,t,r,n){let{uploadReport:i}=await Promise.resolve().then(()=>(d9(),dX));return i(e,t,r,n)}async function pg(e,t,r,n,i){let{createD3kSandbox:a}=await Promise.resolve().then(()=>(pa(),d3));return a(e,t,r,n,i)}async function pv(e,t,r){let{fetchRealLogs:n}=await Promise.resolve().then(()=>(pa(),d3));return n(e,t,r)}async function ph(e,t){let{analyzeLogsWithAgent:r}=await Promise.resolve().then(()=>(pa(),d3));return r(e,t)}async function py(e,t,r,n){let{uploadToBlob:i}=await Promise.resolve().then(()=>(pa(),d3));return i(e,t,r,n)}async function p$(e,t,r,n,i,a){let{createGitHubPR:o}=await Promise.resolve().then(()=>(pa(),d3));return o(e,t,r,n,i,a)}dq(po,"__builtin_response_array_buffer"),dq(ps,"__builtin_response_json"),dq(pl,"__builtin_response_text"),(0,H.registerStepFunction)("__builtin_response_array_buffer",po),(0,H.registerStepFunction)("__builtin_response_json",ps),(0,H.registerStepFunction)("__builtin_response_text",pl),dq(pu,"identifyAffectedPagesStep"),dq(pc,"crawlPreviewPagesStep"),dq(pd,"verifyPRClaimsStep"),dq(pp,"checkPerformanceStep"),dq(pm,"generateReportStep"),dq(pf,"uploadReportStep"),(0,H.registerStepFunction)("step//app/api/cloud/check-pr/workflow.ts//identifyAffectedPagesStep",pu),(0,H.registerStepFunction)("step//app/api/cloud/check-pr/workflow.ts//crawlPreviewPagesStep",pc),(0,H.registerStepFunction)("step//app/api/cloud/check-pr/workflow.ts//verifyPRClaimsStep",pd),(0,H.registerStepFunction)("step//app/api/cloud/check-pr/workflow.ts//checkPerformanceStep",pp),(0,H.registerStepFunction)("step//app/api/cloud/check-pr/workflow.ts//generateReportStep",pm),(0,H.registerStepFunction)("step//app/api/cloud/check-pr/workflow.ts//uploadReportStep",pf),dq(pg,"createD3kSandbox"),dq(pv,"fetchRealLogs"),dq(ph,"analyzeLogsWithAgent"),dq(py,"uploadToBlob"),dq(p$,"createGitHubPR"),(0,H.registerStepFunction)("step//app/api/cloud/fix-workflow/workflow.ts//createD3kSandbox",pg),(0,H.registerStepFunction)("step//app/api/cloud/fix-workflow/workflow.ts//fetchRealLogs",pv),(0,H.registerStepFunction)("step//app/api/cloud/fix-workflow/workflow.ts//analyzeLogsWithAgent",ph),(0,H.registerStepFunction)("step//app/api/cloud/fix-workflow/workflow.ts//uploadToBlob",py),(0,H.registerStepFunction)("step//app/api/cloud/fix-workflow/workflow.ts//createGitHubPR",p$),d9(),pa(),e.s([],43048),e.i(43048),e.s(["POST",()=>dK.stepEntrypoint],42530);var pb=e.i(42530);let p_=new z.AppRouteRouteModule({definition:{kind:T.RouteKind.APP_ROUTE,page:"/.well-known/workflow/v1/step/route",pathname:"/.well-known/workflow/v1/step",filename:"route",bundlePath:""},distDir:".next",relativeProjectDir:"",resolvedPagePath:"[project]/mcp-server/app/.well-known/workflow/v1/step/route.js",nextConfigOutput:"",userland:pb}),{workAsyncStorage:pw,workUnitAsyncStorage:px,serverHooks:pk}=p_;function pI(){return(0,j.patchFetch)({workAsyncStorage:pw,workUnitAsyncStorage:px})}async function pS(e,t,r){p_.isDev&&(0,U.addRequestMeta)(e,"devRequestTimingInternalsEnd",process.hrtime.bigint());let n="/.well-known/workflow/v1/step/route";n=n.replace(/\/index$/,"")||"/";let i=await p_.prepare(e,t,{srcPage:n,multiZoneDraftMode:!1});if(!i)return t.statusCode=400,t.end("Bad Request"),null==r.waitUntil||r.waitUntil.call(r,Promise.resolve()),null;let{buildId:a,params:o,nextConfig:s,parsedUrl:l,isDraftMode:u,prerenderManifest:c,routerServerContext:d,isOnDemandRevalidate:p,revalidateOnlyGenerated:m,resolvedPathname:f,clientReferenceManifest:g,serverActionsManifest:v}=i,h=(0,R.normalizeAppPath)(n),y=!!(c.dynamicRoutes[h]||c.routes[f]),$=async()=>((null==d?void 0:d.render404)?await d.render404(e,t,l,!1):t.end("This page could not be found"),null);if(y&&!u){let e=!!c.routes[f],t=c.dynamicRoutes[h];if(t&&!1===t.fallback&&!e){if(s.experimental.adapterPath)return await $();throw new W.NoFallbackError}}let b=null;!y||p_.isDev||u||(b="/index"===(b=f)?"/":b);let _=!0===p_.isDev||!y,w=y&&!_;v&&g&&(0,D.setReferenceManifestsSingleton)({page:n,clientReferenceManifest:g,serverActionsManifest:v,serverModuleMap:(0,C.createServerModuleMap)({serverActionsManifest:v})});let x=e.method||"GET",k=(0,A.getTracer)(),I=k.getActiveScopeSpan(),S={params:o,prerenderManifest:c,renderOpts:{experimental:{authInterrupts:!!s.experimental.authInterrupts},cacheComponents:!!s.cacheComponents,supportsDynamicResponse:_,incrementalCache:(0,U.getRequestMeta)(e,"incrementalCache"),cacheLifeProfiles:s.cacheLife,waitUntil:r.waitUntil,onClose:e=>{t.on("close",e)},onAfterTaskError:void 0,onInstrumentationRequestError:(t,r,n)=>p_.onRequestError(e,t,n,d)},sharedContext:{buildId:a}},O=new L.NodeNextRequest(e),P=new L.NodeNextResponse(t),E=F.NextRequestAdapter.fromNodeNextRequest(O,(0,F.signalFromNodeResponse)(t));try{let i=async e=>p_.handle(E,S).finally(()=>{if(!e)return;e.setAttributes({"http.status_code":t.statusCode,"next.rsc":!1});let r=k.getRootSpanAttributes();if(!r)return;if(r.get("next.span_type")!==M.BaseServerSpan.handleRequest)return void console.warn(`Unexpected root span type '${r.get("next.span_type")}'. Please report this Next.js issue https://github.com/vercel/next.js`);let i=r.get("next.route");if(i){let t=`${x} ${i}`;e.setAttributes({"next.route":i,"http.route":i,"next.span_name":t}),e.updateName(t)}else e.updateName(`${x} ${n}`)}),a=!!(0,U.getRequestMeta)(e,"minimalMode"),o=async o=>{var l,f;let g=async({previousCacheEntry:s})=>{try{if(!a&&p&&m&&!s)return t.statusCode=404,t.setHeader("x-nextjs-cache","REVALIDATED"),t.end("This page could not be found"),null;let n=await i(o);e.fetchMetrics=S.renderOpts.fetchMetrics;let l=S.renderOpts.pendingWaitUntil;l&&r.waitUntil&&(r.waitUntil(l),l=void 0);let u=S.renderOpts.collectedTags;if(!y)return await (0,B.sendResponse)(O,P,n,S.renderOpts.pendingWaitUntil),null;{let e=await n.blob(),t=(0,V.toNodeOutgoingHttpHeaders)(n.headers);u&&(t[G.NEXT_CACHE_TAGS_HEADER]=u),!t["content-type"]&&e.type&&(t["content-type"]=e.type);let r=void 0!==S.renderOpts.collectedRevalidate&&!(S.renderOpts.collectedRevalidate>=G.INFINITE_CACHE)&&S.renderOpts.collectedRevalidate,i=void 0===S.renderOpts.collectedExpire||S.renderOpts.collectedExpire>=G.INFINITE_CACHE?void 0:S.renderOpts.collectedExpire;return{value:{kind:q.CachedRouteKind.APP_ROUTE,status:n.status,body:Buffer.from(await e.arrayBuffer()),headers:t},cacheControl:{revalidate:r,expire:i}}}}catch(t){throw(null==s?void 0:s.isStale)&&await p_.onRequestError(e,t,{routerKind:"App Router",routePath:n,routeType:"route",revalidateReason:(0,J.getRevalidateReason)({isStaticGeneration:w,isOnDemandRevalidate:p})},d),t}},v=await p_.handleResponse({req:e,nextConfig:s,cacheKey:b,routeKind:T.RouteKind.APP_ROUTE,isFallback:!1,prerenderManifest:c,isRoutePPREnabled:!1,isOnDemandRevalidate:p,revalidateOnlyGenerated:m,responseGenerator:g,waitUntil:r.waitUntil,isMinimalMode:a});if(!y)return null;if((null==v||null==(l=v.value)?void 0:l.kind)!==q.CachedRouteKind.APP_ROUTE)throw Object.defineProperty(Error(`Invariant: app-route received invalid cache entry ${null==v||null==(f=v.value)?void 0:f.kind}`),"__NEXT_ERROR_CODE",{value:"E701",enumerable:!1,configurable:!0});a||t.setHeader("x-nextjs-cache",p?"REVALIDATED":v.isMiss?"MISS":v.isStale?"STALE":"HIT"),u&&t.setHeader("Cache-Control","private, no-cache, no-store, max-age=0, must-revalidate");let h=(0,V.fromNodeOutgoingHttpHeaders)(v.value.headers);return a&&y||h.delete(G.NEXT_CACHE_TAGS_HEADER),!v.cacheControl||t.getHeader("Cache-Control")||h.get("Cache-Control")||h.set("Cache-Control",(0,K.getCacheControlHeader)(v.cacheControl)),await (0,B.sendResponse)(O,P,new Response(v.value.body,{headers:h,status:v.value.status||200})),null};I?await o(I):await k.withPropagatedContext(e.headers,()=>k.trace(M.BaseServerSpan.handleRequest,{spanName:`${x} ${n}`,kind:A.SpanKind.SERVER,attributes:{"http.method":x,"http.target":e.url}},o))}catch(t){if(t instanceof W.NoFallbackError||await p_.onRequestError(e,t,{routerKind:"App Router",routePath:h,routeType:"route",revalidateReason:(0,J.getRevalidateReason)({isStaticGeneration:w,isOnDemandRevalidate:p})}),y)throw t;return await (0,B.sendResponse)(O,P,new Response(null,{status:500})),null}}e.s(["handler",()=>pS,"patchFetch",()=>pI,"routeModule",()=>p_,"serverHooks",()=>pk,"workAsyncStorage",()=>pw,"workUnitAsyncStorage",()=>px],42845)}];
|
|
293
293
|
|
|
294
294
|
//# sourceMappingURL=5e4c3_next_dist_esm_build_templates_app-route_22611d04.js.map
|