@netlify/agent-runner-cli 1.39.0 → 1.39.1-alpha

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.
Files changed (2) hide show
  1. package/dist/bin.js +1 -1
  2. package/package.json +1 -1
package/dist/bin.js CHANGED
@@ -126,5 +126,5 @@ Below are all of the logs with potential issues that we extracted. Some of them
126
126
 
127
127
  ${e.pop()}
128
128
  `;import Nr from"process";var le=_("deploy"),mt=async({netlify:e,hasRepo:t,skipBuild:r,message:n="Agent Preview",deploySubdomain:o,cliPath:s,filter:l})=>{try{let a=["deploy","--message",`"${n}"`,"--json","--draft","--verbose"];t||(le.log("Deploy: Uploading source zip"),a.push("--upload-source-zip")),o&&a.push("--alias",o),l&&a.push("--filter",l),r?(le.log("Deploy: Skipping build"),a.push("--no-build")):a.push("--context","deploy-preview");let i=s||"netlify";le.log(`Running: ${i} ${a.join(" ")}`);let p=await e.utils.run(i,a,{stdio:["ignore","pipe","pipe"]}),c=JSON.parse(p.stdout.trim());le.log(`
129
- Preview deploy created successfully:`,{deployId:c.deploy_id,deployUrl:c.deploy_url,siteId:c.site_id});let m={deployId:c.deploy_id,previewUrl:c.deploy_url,logsUrl:c.logs,siteId:c.site_id};return t||(m.sourceZipFilename=c.source_zip_filename),m}catch(a){throw le.error("Failed to create preview deploy via CLI:",a),a}};var ue=_("deploy_stage"),De=async({cliPath:e,config:t,context:r,result:n,filter:o})=>{let s=await et({config:t,netlify:r});if(ue.info("Resolved git",{hasChanges:s.hasChanges,ignored:s.ignored??[]}),!s.hasChanges)return{diff:"",hasChanges:!1,previewInfo:null};let{diff:l,resultDiff:a,diffBinary:i,resultDiffBinary:p}=s,c=!0;ue.log("Preview deploy condition check:",{resultUndefined:n===void 0,resultType:typeof n,hasChanges:c,wouldCreatePreview:n!==void 0&&c});let m=null;if(n!==void 0&&c)try{let h;try{let E=await Me(t.id,t.sessionId);E?.title&&(h=E.title)}catch(E){ue.warn("Failed to fetch session title, using fallback message:",E.message)}m=await mt({cliPath:e,netlify:r,hasRepo:t.hasRepo,message:h,skipBuild:!1,deploySubdomain:ze(t.id,Nr.env.SITE_NAME),filter:o})}catch(h){return ue.warn("Failed to create preview deploy (continuing with agent run):",h),{diff:l,resultDiff:a,hasChanges:c,previewInfo:null,diffBinary:i,resultDiffBinary:p,deployError:h instanceof Error?h.message:String(h)}}return ue.log("Git status",{hasDiff:!!l,hasChanges:c}),{diff:l,resultDiff:a,hasChanges:c,previewInfo:m,diffBinary:i,resultDiffBinary:p}};async function gt(e,t){let{maxRetries:r,baseDelay:n,onRetry:o}=t,s;for(let l=1;l<=r;l++)try{return await e()}catch(a){if(s=a,l===r)throw s;o&&o(l,s),await new Promise(i=>setTimeout(i,n*l))}throw s}var se=_("cleanup_stage"),ht=async({config:e,diff:t,result:r,duration:n,resultDiff:o,diffBinary:s,resultDiffBinary:l,previewInfo:a})=>{let i={result_diff:t,result:r||"Done",duration:n,result_diff_binary:s};return a&&a.deployId&&(i.deploy_id=a.deployId),a&&a.sourceZipFilename&&(i.result_zip_file_name=a.sourceZipFilename),o||l?(se.log("Updating total agent result diff"),await de(e.id,{result_diff:o,result_diff_binary:l})):se.log("No total result diff, not updating"),se.log("Updated agent runner with result"),await gt(()=>K(e.id,e.sessionId,i),{maxRetries:3,baseDelay:1e3,onRetry:(p,c)=>{se.error(`Error updating agent runner session (attempt ${p}):`,c),se.log("Retrying...")}}),se.log("Finished updating agent runner with result"),{sessionUpdate:i}};import{getTracer as wr}from"@netlify/otel";var Ar=Ir(import.meta.url),Et=Ar("../package.json"),_t=_("pipeline_index"),xe=3,yt=async({config:e,apiToken:t,cliPath:r="netlify",cwd:n,errorLogsPath:o,filter:s,traceExporterUrl:l})=>{let a;try{await Ue(Et.version,e.id,l);let i=wr();await V(i,"run-pipeline",async()=>{let p,{aiGateway:c,context:m,persistSteps:h,runner:E,sha:y}=await ct({config:e,apiToken:t,cliPath:r,cwd:n,errorLogsPath:o,filter:s,runnerVersion:Et.version});a=E.clean,e.sha=y;let{runnerResult:T}=await Te({cliPath:r,config:e,context:m,runner:E.runner,persistSteps:h,aiGateway:c});await K(e.id,e.sessionId,{steps:[{title:"Deploying the run preview"}]});let f=await De({cliPath:r,config:e,context:m,result:T.result,filter:s}),w=T,A=[];if(f.hasChanges&&f.deployError){A.push(Ge(f.deployError));let d=1;for(;d<=xe&&!f.previewInfo;)_t.log(`Deploy attempt had errors. Retrying. ${d}/${xe}`),await V(i,"stage-deploy",async u=>{u?.setAttributes({"stage.attempt":d});let{runnerResult:g}=await Te({cliPath:r,config:e,context:m,runner:E.runner,persistSteps:h,aiGateway:c,buildErrors:A});w={...g,steps:[...w.steps||[],...g.steps||[]],duration:(w.duration||0)+(g.duration||0)},f=await De({cliPath:r,config:e,context:m,result:g.result,filter:s}),f.deployError&&A.push(f.deployError),d++});d>xe&&!f.previewInfo&&(p=new Error(`Deploy validation failed after ${xe} attempts`))}let{diff:S,resultDiff:I,previewInfo:R,diffBinary:x,resultDiffBinary:N}=f;if(await ht({config:e,diff:S,result:w.result,duration:w.duration,resultDiff:I,diffBinary:x,resultDiffBinary:N,previewInfo:R}),p)throw p;await E.clean?.()})}catch(i){_t.error("Got error while running pipeline",i),await a?.();let p=i instanceof Error&&i.message;throw await K(e.id,e.sessionId,{result:p||"Encountered error when running agent",state:"error"}),i}};import O from"process";var Cr="claude",Sr=e=>(e??[]).filter(t=>t.request&&t.response),Pr=e=>(e??[]).filter(t=>t.site_context),Tt=_("config"),xt=()=>{let e=O.env.NETLIFY_AGENT_RUNNER_ID,t=O.env.NETLIFY_AGENT_RUNNER_SESSION_ID;if(!e||!t)throw new Error("ID of agent runner is not provided");let r=O.env.NETLIFY_AGENT_RUNNER_RESULT_BRANCH,n=O.env.NETLIFY_AGENT_RUNNER_PROMPT;if(!n)throw new Error("Prompt is not provided");let o=O.env.NETLIFY_AGENT_RUNNER_AGENT||Cr,s=O.env.NETLIFY_AGENT_RUNNER_MODEL,l=O.env.NETLIFY_FF_AGENT_RUNNER_POST_EXECUTION_VALIDATION_ENABLED==="1",a=O.env.NETLIFY_FF_AGENT_RUNNER_POST_EXECUTION_VALIDATION_WITH_BUILD_ENABLED==="1",i=O.env.ERROR_LOGS_PATH,p=me(O.env.NETLIFY_AGENT_RUNNER_CONTEXT,!0,Tt),c=Sr(p),m=Pr(p),h=O.env.NETLIFY_AGENT_RUNNER_HAS_REPO!=="0",E=!O.env.NETLIFY_FF_AGENT_RUNNER_BYOK_ENABLED,y=O.env.NETLIFY_AGENT_RUNNER_SHA,T=vr(),f=Ze(),w={id:e,sessionId:t,resultBranch:r,prompt:n,runner:o,model:s,validateAgent:l,errorLogsPath:i,sessionHistoryContext:c,siteContext:m,hasRepo:h,useGateway:E,sha:y,accountType:T,validateAgentWithBuild:a,modelVersionOverrides:f};return Tt.log({fullConfig:w}),w},vr=()=>{let e=O.env.NETLIFY_TEAM_TYPE;return e?e.includes("personal")?G:e.includes("pro")?"pro":e.startsWith("enterprise")?Y:e.startsWith("free")?M:U:U};var Rt=_("bin_cmd"),ie=Or(Fe.argv.slice(2),{string:["auth","cwd","cli-path","error-logs-path","filter","trace-exporter-url"]});try{let e=xt();await yt({config:e,apiToken:ie.auth,cwd:ie.cwd,cliPath:ie["cli-path"],errorLogsPath:ie["error-logs-path"],filter:ie.filter,traceExporterUrl:ie["trace-exporter-url"]}),Rt.info("Finished agent"),Fe.exit(0)}catch(e){Rt.error("Error running agent pipeline:",e),Fe.exit(1)}
129
+ Preview deploy created successfully:`,{deployId:c.deploy_id,deployUrl:c.deploy_url,siteId:c.site_id});let m={deployId:c.deploy_id,previewUrl:c.deploy_url,logsUrl:c.logs,siteId:c.site_id};return t||(m.sourceZipFilename=c.source_zip_filename),m}catch(a){throw le.error("Failed to create preview deploy via CLI:",a),a}};var ue=_("deploy_stage"),De=async({cliPath:e,config:t,context:r,result:n,filter:o})=>{let s=await et({config:t,netlify:r});if(ue.info("Resolved git",{hasChanges:s.hasChanges,ignored:s.ignored??[]}),!s.hasChanges)return{diff:"",hasChanges:!1,previewInfo:null};let{diff:l,resultDiff:a,diffBinary:i,resultDiffBinary:p}=s,c=!0;ue.log("Preview deploy condition check:",{resultUndefined:n===void 0,resultType:typeof n,hasChanges:c,wouldCreatePreview:n!==void 0&&c});let m=null;if(n!==void 0&&c)try{let h;try{let E=await Me(t.id,t.sessionId);E?.title&&(h=E.title)}catch(E){ue.warn("Failed to fetch session title, using fallback message:",E.message)}m=await mt({cliPath:e,netlify:r,hasRepo:t.hasRepo,message:h,skipBuild:!1,deploySubdomain:ze(t.id,Nr.env.SITE_NAME),filter:o})}catch(h){return ue.warn("Failed to create preview deploy (continuing with agent run):",h),{diff:l,resultDiff:a,hasChanges:c,previewInfo:null,diffBinary:i,resultDiffBinary:p,deployError:h instanceof Error?h.message:String(h)}}return ue.log("Git status",{hasDiff:!!l,hasChanges:c}),{diff:l,resultDiff:a,hasChanges:c,previewInfo:m,diffBinary:i,resultDiffBinary:p}};async function gt(e,t){let{maxRetries:r,baseDelay:n,onRetry:o}=t,s;for(let l=1;l<=r;l++)try{return await e()}catch(a){if(s=a,l===r)throw s;o&&o(l,s),await new Promise(i=>setTimeout(i,n*l))}throw s}var se=_("cleanup_stage"),ht=async({config:e,diff:t,result:r,duration:n,resultDiff:o,diffBinary:s,resultDiffBinary:l,previewInfo:a})=>{let i={result_diff:t,result:r||"Done",duration:n,result_diff_binary:s};return a&&a.deployId&&(i.deploy_id=a.deployId),a&&a.sourceZipFilename&&(i.result_zip_file_name=a.sourceZipFilename),o||l?(se.log("Updating total agent result diff"),await de(e.id,{result_diff:o,result_diff_binary:l})):se.log("No total result diff, not updating"),se.log("Updated agent runner with result"),await gt(()=>K(e.id,e.sessionId,i),{maxRetries:3,baseDelay:1e3,onRetry:(p,c)=>{se.error(`Error updating agent runner session (attempt ${p}):`,c),se.log("Retrying...")}}),se.log("Finished updating agent runner with result"),{sessionUpdate:i}};import{getTracer as wr}from"@netlify/otel";var Ar=Ir(import.meta.url),Et=Ar("../package.json"),_t=_("pipeline_index"),xe=3,yt=async({config:e,apiToken:t,cliPath:r="netlify",cwd:n,errorLogsPath:o,filter:s,traceExporterUrl:l})=>{let a;try{await Ue(Et.version,e.id,l);let i=wr();await V(i,"run-pipeline",async()=>{let p,{aiGateway:c,context:m,persistSteps:h,runner:E,sha:y}=await ct({config:e,apiToken:t,cliPath:r,cwd:n,errorLogsPath:o,filter:s,runnerVersion:Et.version});a=E.clean,e.sha=y;let{runnerResult:T}=await Te({cliPath:r,config:e,context:m,runner:E.runner,persistSteps:h,aiGateway:c});await K(e.id,e.sessionId,{steps:[{title:"Deploying the run preview"}]});let f=await De({cliPath:r,config:e,context:m,result:T.result,filter:s}),w=T,A=[];if(f.hasChanges&&f.deployError){A.push(Ge(f.deployError));let d=1;for(;d<=xe&&!f.previewInfo;)_t.log(`Deploy attempt had errors. Retrying. ${d}/${xe}`),await V(i,"stage-deploy",async u=>{u?.setAttributes({"stage.attempt":d});let{runnerResult:g}=await Te({cliPath:r,config:e,context:m,runner:E.runner,persistSteps:h,aiGateway:c,buildErrors:A});w={...g,steps:[...w.steps||[],...g.steps||[]],duration:(w.duration||0)+(g.duration||0)},f=await De({cliPath:r,config:e,context:m,result:g.result,filter:s}),f.deployError&&A.push(f.deployError),d++});d>xe&&!f.previewInfo&&(p=new Error(`Deploy validation failed after ${xe} attempts`))}let{diff:S,resultDiff:I,previewInfo:R,diffBinary:x,resultDiffBinary:N}=f;if(await ht({config:e,diff:S,result:w.result,duration:w.duration,resultDiff:I,diffBinary:x,resultDiffBinary:N,previewInfo:R}),p)throw p;await E.clean?.()})}catch(i){_t.error("Got error while running pipeline",i),await a?.();let p=i instanceof Error&&i.message;throw await K(e.id,e.sessionId,{result:p||"Encountered error when running agent",state:"error"}),i}};import O from"process";var Cr="codex",Sr=e=>(e??[]).filter(t=>t.request&&t.response),Pr=e=>(e??[]).filter(t=>t.site_context),Tt=_("config"),xt=()=>{let e=O.env.NETLIFY_AGENT_RUNNER_ID,t=O.env.NETLIFY_AGENT_RUNNER_SESSION_ID;if(!e||!t)throw new Error("ID of agent runner is not provided");let r=O.env.NETLIFY_AGENT_RUNNER_RESULT_BRANCH,n=O.env.NETLIFY_AGENT_RUNNER_PROMPT;if(!n)throw new Error("Prompt is not provided");let o=O.env.NETLIFY_AGENT_RUNNER_AGENT||Cr,s=O.env.NETLIFY_AGENT_RUNNER_MODEL,l=O.env.NETLIFY_FF_AGENT_RUNNER_POST_EXECUTION_VALIDATION_ENABLED==="1",a=O.env.NETLIFY_FF_AGENT_RUNNER_POST_EXECUTION_VALIDATION_WITH_BUILD_ENABLED==="1",i=O.env.ERROR_LOGS_PATH,p=me(O.env.NETLIFY_AGENT_RUNNER_CONTEXT,!0,Tt),c=Sr(p),m=Pr(p),h=O.env.NETLIFY_AGENT_RUNNER_HAS_REPO!=="0",E=!O.env.NETLIFY_FF_AGENT_RUNNER_BYOK_ENABLED,y=O.env.NETLIFY_AGENT_RUNNER_SHA,T=vr(),f=Ze(),w={id:e,sessionId:t,resultBranch:r,prompt:n,runner:o,model:s,validateAgent:l,errorLogsPath:i,sessionHistoryContext:c,siteContext:m,hasRepo:h,useGateway:E,sha:y,accountType:T,validateAgentWithBuild:a,modelVersionOverrides:f};return Tt.log({fullConfig:w}),w},vr=()=>{let e=O.env.NETLIFY_TEAM_TYPE;return e?e.includes("personal")?G:e.includes("pro")?"pro":e.startsWith("enterprise")?Y:e.startsWith("free")?M:U:U};var Rt=_("bin_cmd"),ie=Or(Fe.argv.slice(2),{string:["auth","cwd","cli-path","error-logs-path","filter","trace-exporter-url"]});try{let e=xt();await yt({config:e,apiToken:ie.auth,cwd:ie.cwd,cliPath:ie["cli-path"],errorLogsPath:ie["error-logs-path"],filter:ie.filter,traceExporterUrl:ie["trace-exporter-url"]}),Rt.info("Finished agent"),Fe.exit(0)}catch(e){Rt.error("Error running agent pipeline:",e),Fe.exit(1)}
130
130
  //# sourceMappingURL=bin.js.map
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@netlify/agent-runner-cli",
3
3
  "type": "module",
4
- "version": "1.39.0",
4
+ "version": "1.39.1-alpha",
5
5
  "description": "CLI tool for running Netlify agents",
6
6
  "main": "./dist/index.js",
7
7
  "types": "./dist/index.d.ts",