@netlify/agent-runner-cli 1.119.3-alpha.0 → 1.119.3-init.1
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/README.md +1 -0
- package/dist/bin-local.js +3 -260
- package/dist/bin.js +1 -271
- package/dist/chunk-2PERVUPF.js +23 -0
- package/dist/chunk-6BDGZ7YC.js +2 -0
- package/dist/chunk-AMROU6YU.js +198 -0
- package/dist/chunk-G4E552O7.js +24 -0
- package/dist/chunk-OUIDKGFH.js +2 -0
- package/dist/chunk-Y5TT773K.js +9 -0
- package/dist/claude-BJDJV2C3.js +2 -0
- package/dist/codex-R5HKE55E.js +2 -0
- package/dist/create-DE7SRLKP.js +18 -0
- package/dist/gemini-OHQJC65Z.js +4 -0
- package/dist/index.d.ts +1 -10
- package/dist/index.js +1 -258
- package/dist/scripts/scaffold.d.ts +2 -0
- package/dist/scripts/scaffold.js +13 -0
- package/package.json +11 -16
- package/scripts/scenarios/install-skills.mjs +57 -0
- package/scripts/scenarios/netlify-deploy.mjs +311 -0
- package/scripts/scenarios/prewarm-template-mirror.mjs +69 -0
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
import{c as at}from"./chunk-Y5TT773K.js";import{c as lt}from"./chunk-G4E552O7.js";import{a as we,c as _e,i as ot,l as Fe,n as Se}from"./chunk-6BDGZ7YC.js";import{a as x,b as E}from"./chunk-OUIDKGFH.js";import{A as ee,B as A,C as st,a as w,b as ie,c as Ke,d as $e,e as Ze,f as Qe,g as P,h as et,i as tt,j as se,k as rt,l as Oe,m as Y,n as ye,o as he,p as nt,z as it}from"./chunk-2PERVUPF.js";import{readFileSync as sn}from"fs";import on from"path";import{createRequire as an}from"module";var mr=["error","failed","exception","fatal","panic","abort","crash"];function ut(e){let t=e.split(`
|
|
2
|
+
`),r=[],i=-1,n=0;for(;n<t.length;){let o=t[n].slice(0,500).toLowerCase();if(mr.some(l=>o.includes(l))){let l=Math.max(0,n-10,i+1),g=Math.min(t.length-1,n+20),d=[];for(let u=l;u<=g;u++)d.push(t[u]);r.push(d.join(`
|
|
3
|
+
`)),i=g,n=g+1}else n++}if(r.length===0)return e;let s=r.map((a,o)=>`<extracted_error_chunk order="${o+1}">
|
|
4
|
+
${a}
|
|
5
|
+
</extracted_error_chunk>`).join(`
|
|
6
|
+
|
|
7
|
+
`);return s.length>e.length*.8?e:s}import{execSync as Ir}from"child_process";import Pt from"fs/promises";import vr from"path";import re from"process";import ge from"process";var H=class extends Error{constructor(r,i,n,s=!1){super(r);this.statusCode=i;this.userMessage=n;this.isCreditLimitExceeded=s;this.name="GracefulShutdownError"}},oe=e=>e instanceof H,te=class extends Error{constructor(t){super(t),this.name="ProviderError"}},dn=e=>e instanceof te;var be=ge.env.NETLIFY_API_URL,xe=ge.env.NETLIFY_API_TOKEN,F=w("api"),ae=()=>ge.env.NETLIFY_LOCAL_MODE==="true",j=async(e,t={})=>{if(!be||!xe)throw new Error("No API URL or token");let r=new URL(e,be),i={...t,headers:{...t.headers,Authorization:`Bearer ${xe}`}};ge.env.AGENT_RUNNERS_DEBUG==="true"&&(i.headers["x-nf-debug-logging"]="true"),t.json&&(i.headers||={},i.headers["Content-Type"]="application/json",i.body=JSON.stringify(t.json));let n=await fetch(r,i),s=n.ok&&n.status<=299;if(ge.env.AGENT_RUNNERS_DEBUG==="true")F.log(`Response headers for ${r}:`),n.headers.forEach((o,c)=>{F.log(` ${c}: ${o}`)});else{let o=n.headers.get("x-request-id")||n.headers.get("x-nf-request-id");F.log(`Request ID for ${r}: ${o||"N/A"}`)}if(s||F.error(`Got status ${n.status} for request ${r}`),t.raw){if(!s)throw new Error(`API request failed: ${n.status} ${n.statusText}`);return n}let a=await(n.headers.get("content-type")?.includes("application/json")?n.json():n.text());if(!s){let o=typeof a=="string"?a:JSON.stringify(a);throw n.status===404?new H(`API request failed: 404 - ${o}`,404,"The site associated with this agent run no longer exists."):n.status===503&&t.gracefulOn503&&o.toLowerCase().includes("usage exceeded")?new H(`API request failed: 503 - ${o}`,503,"Credit limit reached. Please add more credits to continue using Agent Runners.",!0):new Error(`API request failed: ${n.status} - ${o}`)}return a},ct=e=>{F.log("Setting details for api",{apiUrl:e?.constants?.NETLIFY_API_HOST,token:!!e?.constants?.NETLIFY_API_TOKEN}),e?.constants?.NETLIFY_API_HOST&&(be=`https://${e.constants.NETLIFY_API_HOST}`),e?.constants?.NETLIFY_API_TOKEN&&(xe=e.constants.NETLIFY_API_TOKEN)},dt=()=>({apiUrl:be,token:xe}),fe=async(e,t)=>ae()?(F.log("Mock API: updateRunner called",{runnerId:e,data:t}),{id:e,...t}):j(`/api/v1/agent_runners/${e}`,{method:"PUT",json:t}),q=async(e,t,r)=>ae()?(F.log("Mock API: updateRunnerSession called",JSON.stringify({runnerId:e,sessionId:t,data:r},null,2)),{id:e,sessionId:t,...r}):j(`/api/v1/agent_runners/${e}/sessions/${t}`,{method:"PUT",json:r});var pt=async e=>ae()?(F.log("Mock API: getSite called",{siteId:e}),{id:e,published_deploy:{id:"id"}}):j(`/api/v1/sites/${e}`),gt=async(e,t)=>ae()?(F.log("Mock API: getRunnerSession called",{runnerId:e,sessionId:t}),{id:t,runnerId:e,state:"running"}):j(`/api/v1/agent_runners/${e}/sessions/${t}`),ft=(e,t,r)=>j(`/api/v1/accounts/${e}/ai-gateway/token`,{headers:{"X-Nf-Agent-Runner-Id":t,"X-Nf-Agent-Runner-Session-Id":r},gracefulOn503:!0}),mt=(e,t,r)=>j(`/api/v1/sites/${e}/ai-gateway/token`,{headers:{"X-Nf-Agent-Runner-Id":t,"X-Nf-Agent-Runner-Session-Id":r},gracefulOn503:!0}),yt=async(e,t)=>ae()?(F.log("Mock API: getDiffUploadUrls called",{runnerId:e,sessionId:t}),{result:{upload_url:"https://s3.mock.com/mock-upload-url-result",s3_key:"mock-s3-key-result"},cumulative:{upload_url:"https://s3.mock.com/mock-upload-url-cumulative",s3_key:"mock-s3-key-cumulative"}}):j(`/api/v1/agent_runners/${e}/sessions/${t}/diff/upload_urls`,{method:"POST"}),ht=async(e,t)=>ae()?(F.log("Mock API: updateSessionUsage called",{runnerId:e,sessionId:t}),{id:t,runnerId:e,usage:0}):j(`/api/v1/agent_runners/${e}/sessions/${t}/update_usage`,{method:"POST"}),wt="netlifydb_readonly",_t=async e=>(await j(`/api/v1/sites/${e}/database?role=${wt}`,{raw:!0})).json(),St=async(e,t)=>(await j(`/api/v1/sites/${e}/database/branch/${encodeURIComponent(t)}?role=${wt}`,{raw:!0})).json(),bt=async e=>j(`/api/v1/sites/${e}/database`,{method:"POST",json:{}}),xt=async(e,t)=>j(`/api/v1/sites/${e}/database/branch`,{method:"POST",json:{branch_id:t}}),Le=async(e,t,{maxRetries:r=3,baseDelayMs:i=500}={})=>{F.log(`Uploading diff to S3: ${e.substring(0,50)}...`);for(let n=1;n<=r;n++)try{let s=await fetch(e,{method:"PUT",body:t,headers:{"Content-Type":"text/plain"}});if(!s.ok)throw new Error(`S3 upload failed with status ${s.status}`);return s}catch(s){if(n===r)throw s;let a=i*2**(n-1);F.warn(`S3 upload attempt ${n}/${r} failed: ${s.message}. Retrying in ${a}ms...`),await new Promise(o=>setTimeout(o,a))}};var le=w("ai_gateway"),Me=null;var Ee=async()=>{if(Me)return Me;le.log("Fetching available AI gateway providers");let e=await fetch(`${dt().apiUrl}/api/v1/ai-gateway/providers`);if(!e.ok)throw new Error(`Failed to fetch AI gateway providers: ${e.statusText}`);let t=await e.json();return Me=t,le.log("Cached AI gateway providers",{providerCount:Object.keys(t.providers).length}),t},yr=async(e,t)=>{let i=(await Ee()).providers[e];if(!i)return le.log(`Provider '${e}' not found`),!1;let n=i.models.includes(t);return le.log(`Model validation for ${e}/${t}`,{isAvailable:n}),n},Et=async({config:e})=>{let t,r,i,n,s=!e.site?.published_deploy;if(!(s?e.accountId:e.siteId))throw new Error(`No entity id for ${s?"account":"site"}`);let o=async()=>{clearTimeout(i),le.log("Requesting AI gateway information");let l=await(s?ft(e.accountId,e.id,e.sessionId):mt(e.siteId,e.id,e.sessionId));if({token:t,url:n}=l,r=l.expires_at?l.expires_at*1e3:void 0,process.env.NETLIFY_AI_GATEWAY_KEY=t,process.env.NETLIFY_AI_GATEWAY_BASE_URL=n,le.log("Got AI gateway information",{token:!!t,expiresAt:r,url:n}),r){let g=r-Date.now()-6e4;g>0&&(i=setTimeout(()=>{o()},g))}};return await Promise.all([o(),Ee()]),{get url(){return n},get token(){return t},isModelAvailableForProvider:yr}};import{Buffer as It}from"buffer";import hr from"path";var vt=w("repo"),Rt=async({config:e,isRetry:t,cwd:r=process.cwd()})=>{vt.info("Getting runner diffs");let i=await _r(r),{hasChanges:n}=i,{status:s}=i;if(!n)return{hasChanges:!1};if(!t){let S=br(s);await xr(S,r)}vt.info("Changes after processing"),await Ge(r);let a=await Be(s,r);if(await Ue(a,r),n=await Sr(r),!n)return{hasChanges:!1,ignored:a};process.env.NETLIFY_INTERNAL_GIT="1";try{await A("git",["commit","-m","Agent runner"],{cwd:r})}finally{process.env.NETLIFY_INTERNAL_GIT="0"}let o={stdio:["ignore","pipe","pipe"],cwd:r},c=await A("git",["diff",e.runSha,"HEAD"],o),l=String(c.stdout??"");if(n=!!l,!n)return await At(r),{hasChanges:!1,ignored:a};let g=await A("git",["diff",e.runSha,"HEAD","--binary"],o),d=String(g.stdout??""),u,p;if(e.sha){let S=await A("git",["diff",e.sha,"HEAD"],o);u=String(S.stdout??"");let _=await A("git",["diff",e.sha,"HEAD","--binary"],o),h=String(_.stdout??"");u!==h&&(p=It.from(h).toString("base64"))}await At(r);let f={hasChanges:!0,diff:l,resultDiff:u,ignored:a};return l!==d&&(f.diffBinary=It.from(d).toString("base64")),p&&(f.resultDiffBinary=p),f},At=async(e=process.cwd())=>{process.env.NETLIFY_LOCAL_MODE&&await A("git",["reset","--soft","HEAD~1"],{cwd:e})},Ue=async(e=[],t=process.cwd())=>{process.env.NETLIFY_INTERNAL_GIT="1";try{await A("git",["add",".",...e],{cwd:t})}finally{process.env.NETLIFY_INTERNAL_GIT="0"}},Ge=async(e=process.cwd())=>{let t=await A("git",["status","-s"],{cwd:e});return String(t.stdout??"")},Tt=/.. (.+)?\.log$/,wr=[Tt],_r=async(e=process.cwd())=>{let t=await Ge(e);return{hasChanges:(t.trim().length===0?[]:t.split(`
|
|
8
|
+
`).filter(n=>wr.some(a=>a instanceof RegExp?a.test(n):n===a)?!1:n[1]?.trim()!=="")).length!==0,status:t}},Sr=async(e=process.cwd())=>{try{return await A("git",["diff","--staged","--quiet"],{cwd:e}),!1}catch{return!0}},je=async(e=process.cwd())=>{let{stdout:t}=await A("git",["rev-parse","HEAD"],{cwd:e});return String(t??"").trim()},Ct=async(e=process.cwd())=>{let{stdout:t}=await A("git",["rev-list","--max-parents=0","HEAD"],{cwd:e});return String(t??"").trim()},Be=async(e,t=process.cwd())=>{e||=await Ge(t);let r=[".netlify","node_modules","dist",".next","out",".nuxt",".output",".cache",".turbo",".parcel-cache","coverage",".nyc_output","storybook-static","public/build","CLAUDE.local.md"],i=[];return e.split(`
|
|
9
|
+
`).forEach(n=>{r.forEach(a=>{let o=n===`?? ${a}`,c=n.startsWith(`?? ${a}/`)||n.startsWith(`?? ${a}${hr.sep}`);(o||c)&&i.push(`:!${a}`)});let s=n.match(Tt)?.[1];s&&i.push(`:!${s}.log`)}),i},Ye=async(e=process.cwd())=>{await A("git",["reset","--hard","HEAD"],{cwd:e})},br=e=>{let t=e.split(`
|
|
10
|
+
`).reduce((r,i)=>{if(!i)return r;let[n,s,,...a]=i,o=a.join(""),c=n.trim(),l=s.trim();return r[o]?r[o].change=l:r[o]={filePath:o,stage:c,change:l},r},{});return Object.values(t)},xr=async(e,t=process.cwd())=>{let r=e.filter(i=>i.stage&&!i.change).map(i=>i.filePath);r.length!==0&&await A("git",["restore","--staged","--worktree","--pathspec-from-file=-"],{cwd:t,input:r.join(`
|
|
11
|
+
`)})};var Er={claude:async()=>{let e=await import("./claude-BJDJV2C3.js");return{runner:e.default,clean:e.clean}},codex:async()=>{let e=await import("./codex-R5HKE55E.js");return{runner:e.default,clean:e.clean}},gemini:async()=>{let e=await import("./gemini-OHQJC65Z.js");return{runner:e.default,clean:e.clean}}},Ie=Er;var ue=w("init_stage"),Dt=async({config:e,apiThrottle:t,apiToken:r,runnerVersion:i})=>await E(x(),"init-stage",async n=>{let s=performance.now();n?.setAttributes({"init.runner":e.runner,"init.id":e.id,"init.sessionId":e.sessionId,"init.hasRepo":e.hasRepo,"init.useGateway":e.useGateway,"init.runnerVersion":i||"unknown"});let a=Ie[e.runner];if(!a)throw n?.setAttributes({"init.error":"unsupported_runner"}),new Error(`${e.runner} is not supported`);let o=await a(),c=Rr({apiToken:r,config:e});if(ct(c),e.siteId)try{e.site=await pt(e.siteId)}catch(_){ue.error("Failed to get the site information",{error:_})}let l=e.useGateway?await Et({config:e}):void 0;n?.setAttributes({"init.aiGateway.created":!!l}),await q(e.id,e.sessionId,{steps:[{title:"Environment ready",category:ee.Environment,type:"ready"}]});let g=5*1024,d=1e4,u=_e(async({steps:_=[],duration:h})=>{let y=_.map(v=>{let R=v.title?Fe(ie(v.title),g):void 0,z=v.category===ee.AgentMessage||v.category===ee.UserMessage,k=v.message?ie(v.message):void 0,$=k&&!z?Fe(k,d):k,M=v.category===ee.UserMessage,Z=$&&!M?Se($):$;return Z!==$&&ue.info("Sanitized internal error from step message",{original:$}),{...v,title:R,message:Z}});_.length=0;try{return await q(e.id,e.sessionId,{steps:y,duration:h})}catch(v){ue.error("persistSteps failed",{error:v?.message||v})}},t);ue.info("Adding build files to stage");let p=await Be();await Ue(p),re.env.NETLIFY_LOCAL_MODE||await Ar();let f;e.hasRepo?e.sha?(f=e.sha,n?.setAttributes({"init.sha.source":"provided"})):(f=await je(),await fe(e.id,{sha:f}),n?.setAttributes({"init.sha.source":"current_commit"})):(f=await Ct(),n?.setAttributes({"init.sha.source":"first_commit","init.source":"zip"})),e.runSha=await je();let S=performance.now()-s;return n?.setAttributes({"init.sha":f||"unknown","init.duration.ms":S,"init.status":"success"}),{aiGateway:l,context:c,persistSteps:u,runner:o,sha:f}}),Ar=async()=>{let e="/usr/bin/git";try{e=Ir("which git").toString().trim()||e}catch{}let t="/tmp/netlify-git-wrapper",r=vr.join(t,"git"),i=`#!/bin/bash
|
|
12
|
+
# Git wrapper that blocks add and commit commands
|
|
13
|
+
# The deployment system handles staging and commits automatically
|
|
14
|
+
|
|
15
|
+
# Allow internal system calls to bypass the wrapper
|
|
16
|
+
if [ "$NETLIFY_INTERNAL_GIT" = "1" ]; then
|
|
17
|
+
exec ${e} "$@"
|
|
18
|
+
fi
|
|
19
|
+
|
|
20
|
+
case "$1" in
|
|
21
|
+
add)
|
|
22
|
+
echo ""
|
|
23
|
+
echo "Note: 'git add' is disabled in this environment."
|
|
24
|
+
echo "The deployment system automatically detects your file changes."
|
|
25
|
+
echo "Just edit files directly - no need to stage them manually."
|
|
26
|
+
echo ""
|
|
27
|
+
exit 1
|
|
28
|
+
;;
|
|
29
|
+
commit)
|
|
30
|
+
echo ""
|
|
31
|
+
echo "Note: 'git commit' is disabled in this environment."
|
|
32
|
+
echo "The deployment system handles commits automatically."
|
|
33
|
+
echo "Just edit files and leave them uncommitted."
|
|
34
|
+
echo ""
|
|
35
|
+
exit 1
|
|
36
|
+
;;
|
|
37
|
+
*)
|
|
38
|
+
exec ${e} "$@"
|
|
39
|
+
;;
|
|
40
|
+
esac
|
|
41
|
+
`;try{await Pt.mkdir(t,{recursive:!0}),await Pt.writeFile(r,i,{mode:493}),re.env.PATH=`${t}:${re.env.PATH}`,re.env.NETLIFY_INTERNAL_GIT="0",ue.info("Installed git wrapper to block add/commit commands")}catch(n){ue.warn("Failed to install git wrapper",{error:n?.message||n})}},Rr=({apiToken:e,config:t})=>({constants:{NETLIFY_API_HOST:re.env.NETLIFY_API_HOST||"api.netlify.com",NETLIFY_API_TOKEN:e||re.env.NETLIFY_API_TOKEN,SITE_ID:t.siteId,FUNCTIONS_DIST:re.env.FUNCTIONS_DIST||"netlify/functions"},utils:{run:A}});import Tr from"crypto";import T from"fs/promises";import qe from"os";import I from"path";import V from"process";import{fileURLToPath as Cr}from"url";var B=w("context"),Pr=Cr(import.meta.url),Dr=I.dirname(Pr),kt={claude:I.join(qe.homedir(),".claude","skills"),gemini:I.join(qe.homedir(),".agents","skills"),codex:I.join(qe.homedir(),".agents","skills")},Nt=I.join(Dr,"skills"),$t=e=>e.replace(/<\/user_request/gi,"</user_request"),Ot=e=>typeof e=="string"&&/^[A-Za-z0-9_-]+$/.test(e)?e:null,Nr=({userRequest:e,buildErrorContextText:t="",projectContext:r="",sessionHistoryContextText:i="",additionalContext:n="",netlifyInfo:s={},cliPath:a="netlify",skillsDir:o="",netlifyFolder:c=Y,resultsFilename:l=ye,assetsFolder:g=he,sessionId:d,nodeVersion:u=V.version||"unknown"})=>{let p=Ot(d),f=n?`<additional_rules>
|
|
42
|
+
${n}
|
|
43
|
+
</additional_rules>`:"";return`
|
|
44
|
+
You're an AI agent designed to assist with tasks related to a Netlify project. Please review, understand, and use the context provided to complete the user's request as needed.
|
|
45
|
+
|
|
46
|
+
<request>
|
|
47
|
+
<user_request>
|
|
48
|
+
${$t(e)}
|
|
49
|
+
</user_request>
|
|
50
|
+
${t}
|
|
51
|
+
</request>
|
|
52
|
+
|
|
53
|
+
<requirements>
|
|
54
|
+
<responses>
|
|
55
|
+
- Do not speak in first person. You may speak as "the agent".
|
|
56
|
+
- When work is complete, write a changes summary in ${c}/${l} as a standalone PR description. Explain what was accomplished and why (avoid too many implementation details), assuming the reader has no prior context. Use past tense and write in prose without calling it a "PR", "Changelog", etc. This is the core of a PR message or summary page that already has a heading.
|
|
57
|
+
- If the user's request is informational in nature (asking for output, status, information, or analysis rather than asking you to make changes), write the requested information directly to the ${c}/${l} file.
|
|
58
|
+
- Do not attempt to create git commits, PRs, etc. directly. You can use git to review information if required but the system that runs this agent will handle creating PRs or commits of the changes it performs.
|
|
59
|
+
- NEVER look into the \`.git\` folder
|
|
60
|
+
- NEVER print potentially sensitive values (like secrets) in the planning output or results
|
|
61
|
+
- If the user asks for "a plan", "just planning", or similar (without asking for implementation) you may use plan mode to explore the codebase in read-only mode, design your implementation approach and write the complete plan to ${c}/${l}. Stop there, do not wait for approval and do not implement unless explicitly asked.
|
|
62
|
+
</responses>
|
|
63
|
+
<attachements>
|
|
64
|
+
- for requests that require work with attachments or assets, take into account that uploaded attachments are stored in ${c}/${g} folder${p?`, specifically in ${c}/${g}/${p}/ for the current session`:""}
|
|
65
|
+
- move assets from ${c}/${g} folder to the project assets folder if they are referenced in a code or applied changes
|
|
66
|
+
</attachements>
|
|
67
|
+
<rules>
|
|
68
|
+
- Read files efficiently. Use glob first to find the right paths before reading
|
|
69
|
+
- Prefer editing over writing entire files when possible
|
|
70
|
+
- Do NOT run any build commands (e.g. \`netlify build\`, \`netlify functions:build\`, \`npm run build\`, \`yarn build\`, \`pnpm build\`). The system validates builds automatically after your changes. Running these commands can produce build artifacts that pollute the repository.
|
|
71
|
+
- When the task requires data storage or persistence, you MUST use Netlify platform primitives. Use the \`general-database\` skill to determine the right storage solution. NEVER use in-memory data structures, local JSON files, or external database services for data that needs to persist.
|
|
72
|
+
- You have access to Netlify specific skills in ${o}. Before implementing a feature, read the relevant skill's SKILL.md for instructions. Some skills have activation scripts (e.g. \`node scripts/enable.cjs\`) that you MUST run after implementing the feature. Currently, Netlify Forms and Netlify Identity have activation scripts. Skipping this step will cause the feature to not be enabled on deploy.
|
|
73
|
+
</rules>
|
|
74
|
+
${it}
|
|
75
|
+
${f}
|
|
76
|
+
${r}
|
|
77
|
+
</requirements>
|
|
78
|
+
|
|
79
|
+
<extra_context>
|
|
80
|
+
<metadata>
|
|
81
|
+
- Site/Project ID: ${s.siteId}
|
|
82
|
+
- Account/Team ID: ${s.accountId}
|
|
83
|
+
- User ID: ${s.userId}
|
|
84
|
+
- Site/Project Slug: ${s.siteSlug}
|
|
85
|
+
- Netlify Functions directory: ${s.functionsDir}
|
|
86
|
+
</metadata>
|
|
87
|
+
<environment>
|
|
88
|
+
- Node Version: ${u}
|
|
89
|
+
- Environment variables are set globally (e.g. \`echo $VARIABLE_NAME\` can be used to check if a var is set).
|
|
90
|
+
- 'netlify-cli' npm package is already available as a global package. Don't try to install it again
|
|
91
|
+
- If you need to start a local development server in order to fulfill the request, try using the Netlify CLI over by running the shell command '${a} dev'. This will start a local HTTP server on port 8888, including live-reloading of any changes and, most critically, it offers local emulation for all Netlify features.
|
|
92
|
+
</environment>
|
|
93
|
+
<docs>
|
|
94
|
+
- Netlify Docs: https://docs.netlify.com
|
|
95
|
+
- LLM Resources Index: https://docs.netlify.com/llms.txt
|
|
96
|
+
</docs>
|
|
97
|
+
</extra_context>
|
|
98
|
+
|
|
99
|
+
${i}
|
|
100
|
+
`},ze=null;var ve="SKILL.md",kr=()=>{let e=we().skillVariations;return B.log(`Active skill variations: ${e.length?e.join(", "):"none"}`),e},Ft=e=>{let t=e.match(/^(.+)@([^.]+)(.*)$/);return t?{baseName:`${t[1]}${t[3]}`,variation:t[2]}:{baseName:e,variation:null}},$r=async(e,t=[])=>{try{let r=await T.readdir(e);for(let i of r){let{baseName:n,variation:s}=Ft(i);if(s&&n===ve&&t.includes(s))return{filename:i,variation:s}}}catch{}return{filename:ve,variation:null}},Or=async(e,{targetDir:t}={})=>{let r=t||kt[e];if(!r)return B.warn(`Unknown runner: ${e}, skipping skills setup`),[];if(ze)return ze;let i=[],n=kr();try{await T.mkdir(r,{recursive:!0});let s=await T.readdir(Nt);for(let a of s){let o=I.join(Nt,a);if(!(await T.stat(o)).isDirectory())continue;let{baseName:l,variation:g}=Ft(a);if(g&&!n.includes(g))continue;let d=I.join(r,l);try{await T.cp(o,d,{recursive:!0});let u=await $r(o,n);u.variation&&(await T.copyFile(I.join(o,u.filename),I.join(d,ve)),await T.unlink(I.join(d,u.filename)),B.log(`Using skill variation for ${l}: ${u.filename}`)),i.push(l),g&&B.log(`Installed skill variation: ${l} (variation: ${g})`)}catch(u){B.warn(`Failed to copy skill ${l}:`,u.message)}}}catch(s){B.warn("Failed to setup agent skills:",s.message)}if(i.includes("netlify-ai-gateway"))try{let s=await Ee(),a=I.join(r,"netlify-ai-gateway",ve),o=await T.readFile(a,"utf-8");if(o.includes("<!-- AVAILABLE_MODELS -->")){let c=Object.entries(s.providers).map(([l,g])=>`### ${l}
|
|
101
|
+
|
|
102
|
+
${g.models.map(d=>`- \`${d}\``).join(`
|
|
103
|
+
`)}`).join(`
|
|
104
|
+
|
|
105
|
+
`);o=o.replace("<!-- AVAILABLE_MODELS -->",c),await T.writeFile(a,o,"utf-8"),B.log("Injected dynamic model list into AI Gateway skill",{modelList:c})}}catch(s){B.warn("Failed to inject dynamic model list into AI Gateway skill:",s.message)}return i.length>0&&B.log(`Installed ${i.length} skills for ${e}: ${i.join(", ")}`,{runner:e,skills:i,targetDir:r}),ze=i,i},Fr=e=>{let t=e?.constants||{};return{siteId:t.SITE_ID,accountId:V.env.NETLIFY_TEAM_ID,userId:V.env.NETLIFY_AGENT_RUNNER_USER_ID,siteSlug:V.env.SITE_NAME,apiHost:t.NETLIFY_API_HOST,functionsDir:t.FUNCTIONS_DIST}},Lr=10,Mr=async e=>{let{name:t,ext:r}=I.parse(e),i=e,n=I.join(V.cwd(),Y,i),s=0;for(;await Lt(n);){if(s>=Lr)throw new Error("Failed to generate context file");i=`${t}-${Tr.randomUUID().slice(0,5)}${r}`,n=I.join(V.cwd(),Y,i),s+=1}return i},Lt=async e=>{try{return await T.access(e),!0}catch{return!1}},Mt=async({cliPath:e,netlify:t,config:r,buildErrorContext:i,additionalContext:n})=>{let s=Fr(t),a=await Mr(rt),o=I.join(V.cwd(),Y);await T.mkdir(o,{recursive:!0});let c=I.join(Y,a),l=I.join(V.cwd(),c),g=I.join(V.cwd(),Y,ye);try{await T.unlink(g),B.log(`Deleted old results file: ${g}`)}catch{}let d=i?`You've already made changes to complete the above request. However, the build is currently failing after your changes.
|
|
106
|
+
Your task is to analyze and fix the build errors.
|
|
107
|
+
Don't apply techniques of reverting changes. Apply fixes related to errors.
|
|
108
|
+
Don't try to run build by yourself. Just fix the errors.
|
|
109
|
+
|
|
110
|
+
<build_error_context>
|
|
111
|
+
${i}
|
|
112
|
+
</build_error_context>`:"",u="";r.siteContext&&r.siteContext.length!==0&&(u=`
|
|
113
|
+
<project_rules>
|
|
114
|
+
${r.siteContext.filter(_=>_.site_context).map(_=>typeof _.site_context=="string"?_.site_context:typeof _.site_context=="object"?JSON.stringify(_.site_context):"").join(`
|
|
115
|
+
|
|
116
|
+
`)}
|
|
117
|
+
</project_rules>
|
|
118
|
+
`);let p="";if(r.sessionHistoryContext?.length){let _=I.join(V.cwd(),Y,Oe);await T.mkdir(_,{recursive:!0});let h=await Promise.all(r.sessionHistoryContext.map(async(y,v)=>{let R=v+1,z=`attempt-${R}.md`,k=I.join(_,z),$=I.join(Y,Oe,z),M=Ot(y.id),Z=M?` ID ${M}`:"",C="";if(M){let U=I.resolve(o,he),W=I.resolve(U,M);W.startsWith(U+I.sep)&&await Lt(W)&&(C=`
|
|
119
|
+
---
|
|
120
|
+
|
|
121
|
+
## Assets: ${W}/
|
|
122
|
+
`)}let pe=`# Task History - Attempt ${R}${Z}
|
|
123
|
+
|
|
124
|
+
## Request - what the user asked for
|
|
125
|
+
${y.request}
|
|
126
|
+
|
|
127
|
+
---
|
|
128
|
+
|
|
129
|
+
## Response - what the agent replied with after its work
|
|
130
|
+
|
|
131
|
+
${y.response}
|
|
132
|
+
${C}`;return await T.writeFile(k,pe,"utf-8"),B.log(`Created history file: ${$}`),$}));p+=`
|
|
133
|
+
<session_history_context>
|
|
134
|
+
History of prior work on this task.
|
|
135
|
+
You MUST review ALL of the files below as context to understand the context of previous attempts. Use this information to continue the discussion appropriately.
|
|
136
|
+
|
|
137
|
+
${h.slice(-5).map(y=>`- ${y}`).join(`
|
|
138
|
+
`)}
|
|
139
|
+
|
|
140
|
+
</session_history_context>
|
|
141
|
+
`}let f=r.skillsTargetDir||kt[r.runner];r.runner&&await Or(r.runner,{targetDir:r.skillsTargetDir});let S=Nr({userRequest:r.prompt,buildErrorContextText:d,projectContext:u,sessionHistoryContextText:p,additionalContext:n,netlifyInfo:s,cliPath:e,skillsDir:f,netlifyFolder:o,resultsFilename:ye,assetsFolder:he,sessionId:r.sessionId});return await T.writeFile(l,S,"utf-8"),B.log(`Generated agent context document at: ${l}`),S.length>5e5&&(S=`
|
|
142
|
+
You're an AI agent designed to assist with tasks related to a Netlify project. Please review, understand, and use the context provided to complete the user's request as needed.
|
|
143
|
+
|
|
144
|
+
<request>
|
|
145
|
+
<user_request>
|
|
146
|
+
${$t(r.prompt)}
|
|
147
|
+
</user_request>
|
|
148
|
+
${d}
|
|
149
|
+
</request>
|
|
150
|
+
|
|
151
|
+
Use the following file for the complete context of the ask, the environment, and what's available. ${l} You MUST READ ALL OF IT. Make sure to read it first. Never cite or paraphrase private context.
|
|
152
|
+
`),S};var Ur=w("prompt"),Ut=async({cliPath:e,config:t,netlify:r,buildErrorContext:i,additionalContext:n})=>{let s=await Mt({cliPath:e,config:t,netlify:r,buildErrorContext:i,additionalContext:n});return process.env.AGENT_RUNNER_DEBUG&&Ur.log("Contextful Prompt:",s),{prompt:s}};var Ae=w("inference_stage"),Gt=5,ne=async e=>{let{additionalContext:t,cliPath:r,config:i,context:n,buildErrors:s,runner:a,persistSteps:o,aiGateway:c,attempt:l,contextPrefix:g,priorAgentSessionId:d,cwd:u}=e;Ae.log(`Running inference stage, attempt ${l} of ${Gt}`);let p=await E(x(),"inference-stage",async f=>{f?.setAttributes({"inference.attempt":l||1}),Ke();let{prompt:S}=await E(x(),"compose-prompt",async()=>await Ut({cliPath:r,config:i,buildErrorContext:Gr(s),netlify:n,additionalContext:t})),_=`
|
|
153
|
+
${g||""}
|
|
154
|
+
${S}
|
|
155
|
+
`.trim(),h={...i,prompt:_},y=await E(x(),`run-${i.runner}`,async()=>await a({aiGateway:c,config:h,netlify:n,persistSteps:o,continueSession:!!(l&&l>1),priorAgentSessionId:d,cwd:u}));return y.result&&(y.result=ie(y.result)),y.error&&(y.error=ie(y.error)),await o.flush(),y});if(p.error){if(Ae.error("Runner failed",{stepsCount:p.steps.length,duration:p.duration,error:p.error,isRetryableError:p.isRetryableError,attempt:l||1,agentSessionId:p.agentSessionId}),p.isRetryableError&&(!l||l<Gt))return Ae.log("Retrying inference stage"),await new Promise(S=>setTimeout(S,5e3)),{runnerResult:(await ne({...e,attempt:(l||1)+1,priorAgentSessionId:p.agentSessionId,contextPrefix:p.agentSessionId?"":"<important> The agent has already started on this work but ran into networking errors trying to complete it. Please continue from where it left off (you can use git commands to see what's currently changed thus far) and do not start over. Here is the full prompt for context: </important>"})).runnerResult};throw Ae.log("Do not retry inference stage"),p.error.toLowerCase().includes("usage exceeded")?new H(p.error,503,"Credit limit reached. Please add more credits to continue using Agent Runners.",!0):p.isRetryableError||p.isProviderUnavailableError?new te(p.error):new Error(p.error)}return{runnerResult:p}},Gr=e=>!e||e.length===0?"":`
|
|
156
|
+
Deploy failed failed. Here are the errors to review on the latest build:
|
|
157
|
+
|
|
158
|
+
Below are all of the logs with potential issues that we extracted. Some of them may be false positives, discern them carefully and ensure fixes are relevant.
|
|
159
|
+
|
|
160
|
+
${e.pop()}
|
|
161
|
+
`;var ce=w("deploy"),jr=e=>e===""||/[\s"\\]/u.test(e)?JSON.stringify(e):e,jt=async e=>await E(x(),"create-preview-deploy",async t=>Br(e,t)),Br=async({netlify:e,hasRepo:t,skipBuild:r,message:i="Agent Preview",deploySubdomain:n,cliPath:s,filter:a,prodDeploy:o},c)=>{try{let l=["deploy","--message",i,"--json","--verbose",o?"--prod":"--draft"];ce.log("Deploy: Uploading source zip"),l.push("--upload-source-zip"),n&&!o&&l.push("--alias",n),a&&l.push("--filter",a),r?(ce.log("Deploy: Skipping build"),l.push("--no-build")):l.push("--context",o?"production":"deploy-preview");let g=s||"netlify";ce.log(`Running: ${g} ${l.map(jr).join(" ")}`),c?.setAttributes({cmd:g,args:l});let d=await e.utils.run(g,l,{stdio:["ignore","pipe","pipe"],env:{...process.env,NETLIFY_DEPLOY_SOURCE:"agent_runner"}});d.stderr&&ce.log(String(d.stderr));let u=JSON.parse(String(d.stdout??"").trim());c?.setAttributes({success:!0,deployId:u.deploy_id,deployUrl:u.deploy_url,siteId:u.site_id}),ce.log(`
|
|
162
|
+
Preview deploy created successfully:`,{deployId:u.deploy_id,deployUrl:u.deploy_url,siteId:u.site_id});let p={deployId:u.deploy_id,previewUrl:u.deploy_url,logsUrl:u.logs,siteId:u.site_id};return t||(p.sourceZipFilename=u.source_zip_filename),p}catch(l){throw ce.error("Failed to create preview deploy via CLI:",l),c?.setAttributes({success:!1,error:l.message}),l}};var Re=e=>["dtn-prod-iteration","create"].includes(e);import Bt from"fs";import He from"path";var Yt=(e=process.cwd())=>{let t=He.join(e,Y,nt);return{hasNetlifyForm:Bt.existsSync(He.join(t,"netlify-forms")),hasNetlifyIdentity:Bt.existsSync(He.join(t,"netlify-identity"))}};var Q=w("deploy_stage"),Te=async e=>await E(x(),"run-deploy-stage",async()=>Yr(e)),Yr=async({cliPath:e,config:t,context:r,result:i,filter:n,isRetry:s,deploySubdomain:a})=>{let o=await E(x(),"get-runner-diffs",async()=>await Rt({config:t,isRetry:s}));if(Q.info("Resolved git",{hasChanges:o.hasChanges,ignored:o.ignored??[]}),!o.hasChanges&&t.mode!=="redeploy")return{diff:"",hasChanges:!1,previewInfo:null,isProdDeploy:!1,hasNetlifyForm:!1,hasNetlifyIdentity:!1};let c=o.hasChanges?o.diff:"",l=o.hasChanges?o.resultDiff:void 0,g=o.hasChanges?o.diffBinary:void 0,d=o.hasChanges?o.resultDiffBinary:void 0,u=o.hasChanges||t.mode==="redeploy",{hasNetlifyForm:p,hasNetlifyIdentity:f}=Yt();if(p||f){let h={};p&&(Q.log("Detected Netlify Forms enablement \u2014 enabling early"),h.has_netlify_form=!0),f&&(Q.log("Detected Netlify Identity enablement \u2014 enabling early"),h.has_netlify_identity=!0);try{await q(t.id,t.sessionId,h)}catch(y){Q.warn("Failed to send early feature enablement (continuing):",y)}}Q.log("Deploy condition check:",{resultUndefined:i===void 0,resultType:typeof i,hasChanges:u,isRedeploy:t.mode==="redeploy",wouldCreateDeploy:i!==void 0&&(u||t.mode==="redeploy")});let S=Re(t.mode),_=null;if(i!==void 0&&(u||t.mode==="redeploy"))try{let h;try{let y=await E(x(),"get-runner-session",async()=>await gt(t.id,t.sessionId));y?.title&&(h=y.title)}catch(y){Q.warn("Failed to fetch session title, using fallback message:",y.message)}await q(t.id,t.sessionId,{steps:[{title:S?"Deploying project":"Deploying preview",category:ee.Deployment}]}),_=await jt({cliPath:e,netlify:r,hasRepo:t.hasRepo,message:h,skipBuild:!1,deploySubdomain:a,filter:n,prodDeploy:S})}catch(h){return Q.warn("Failed to create preview deploy (continuing with agent run):",h),{diff:c,resultDiff:l,hasChanges:u,previewInfo:null,diffBinary:g,resultDiffBinary:d,deployError:h instanceof Error?h.message:String(h),isProdDeploy:S,hasNetlifyForm:p,hasNetlifyIdentity:f}}return Q.log("Git status",{hasDiff:!!c,hasChanges:u}),{diff:c,resultDiff:l,hasChanges:u,previewInfo:_,diffBinary:g,resultDiffBinary:d,isProdDeploy:S,hasNetlifyForm:p,hasNetlifyIdentity:f}};async function qt(e,t){let{maxRetries:r,baseDelay:i,onRetry:n}=t,s;for(let a=1;a<=r;a++)try{return await e()}catch(o){if(s=o,a===r)throw s;n&&n(a,s),await new Promise(c=>setTimeout(c,i*a))}throw s}var L=w("cleanup_stage"),We=async e=>await E(x(),"cleanup-stage",async()=>qr(e)),Ve=1024*1024*10,qr=async({config:e,diff:t,result:r,duration:i,resultDiff:n,diffBinary:s,resultDiffBinary:a,previewInfo:o,isProdDeploy:c,hasNetlifyForm:l,hasNetlifyIdentity:g})=>{let d={result:r||"Done",duration:i};o&&o.deployId&&(d.deploy_id=o.deployId),o&&o.sourceZipFilename&&(d.result_zip_file_name=o.sourceZipFilename),c&&(d.is_published=!0);let u=t||s||n||a;if(u&&(d.diff_produced=!0),l&&(d.has_netlify_form=!0),g&&(d.has_netlify_identity=!0),u)try{L.log("Getting pre-signed URLs for diff upload");let p=await yt(e.id,e.sessionId),f=[];(t||s)&&f.push(Le(p.result.upload_url,s||t).then(()=>{d.result_diff_s3_key=p.result.s3_key,L.log("Successfully uploaded result_diff to S3")})),(n||a)&&f.push(Le(p.cumulative.upload_url,a||n).then(()=>{d.cumulative_diff_s3_key=p.cumulative.s3_key,L.log("Successfully uploaded cumulative_diff to S3")})),L.log(`Uploading ${f.length} diff(s) to S3 in parallel`),await Promise.all(f),(n||a)&&(L.log("Updating agent runner with cumulative diff S3 key"),await E(x(),"update-runner",async()=>{await fe(e.id,{result_diff_s3_key:p.cumulative.s3_key})}))}catch(p){L.error("S3 upload failed, falling back to inline diffs:",p);let f=Buffer.byteLength(t||s||""),S=Buffer.byteLength(a||n||"");if(f>Ve||S>Ve){let _=`Diffs exceed maximum inline size of ${Ve} bytes.`;throw L.error(_),new Error(_)}d.result_diff=t,d.result_diff_binary=s,(n||a)&&(d.cumulative_diff=n,d.cumulative_diff_binary=a,L.log("Updating agent runner with inline diffs (fallback)"),await E(x(),"update-runner",async()=>{await fe(e.id,{result_diff:n,result_diff_binary:a})}))}else L.log("No diffs to upload");return L.log("Updated agent runner with result"),await qt(async()=>await E(x(),"update-runner-session",()=>q(e.id,e.sessionId,d)),{maxRetries:3,baseDelay:1e3,onRetry:(p,f)=>{L.error(`Error updating agent runner session (attempt ${p}):`,f),L.log("Retrying...")}}),L.log("Finished updating agent runner with result"),{sessionUpdate:d}};import X from"fs";import K from"path";import zr from"process";var D=w("db_migrations"),Hr=new Set(["drizzle.config.ts","drizzle.config.js","drizzle.config.mjs"]),Vr="netlify/database/migrations",zt=/^[a-z0-9_]{1,50}$/,de=50,Wt=(e,t)=>{if(!t)return K.join(e,Vr);let r=K.isAbsolute(t)?t:K.resolve(e,t),i=K.relative(e,r);if(i!==""&&(i.startsWith("..")||K.isAbsolute(i))){D.warn(`Refusing to use migrations directory outside cwd: ${r} (cwd: ${e})`);return}return r},Wr=e=>`Your task: return a short snake_case slug that summarises a SQL database migration.
|
|
163
|
+
|
|
164
|
+
Rules:
|
|
165
|
+
- Lowercase letters, digits, and underscores only. Match the regex ^[a-z0-9_]{1,${de}}$.
|
|
166
|
+
- Start with an imperative verb (add, create, drop, alter, rename, index).
|
|
167
|
+
- At most ${de} characters.
|
|
168
|
+
|
|
169
|
+
Good examples:
|
|
170
|
+
- \`CREATE TABLE users (...)\` -> \`create_users_table\`
|
|
171
|
+
- \`ALTER TABLE users ADD COLUMN bio text\` -> \`add_users_bio\`
|
|
172
|
+
- \`CREATE INDEX idx_posts_author_id ON posts(author_id)\` -> \`index_posts_author_id\`
|
|
173
|
+
- \`DROP TABLE legacy_sessions\` -> \`drop_legacy_sessions\`
|
|
174
|
+
|
|
175
|
+
Bad (do NOT do this):
|
|
176
|
+
- \`Added an optional bio field to the users table\` (prose sentence)
|
|
177
|
+
- \`Add users bio\` (contains spaces, not a slug)
|
|
178
|
+
- \`AddUsersBio\` (wrong case)
|
|
179
|
+
|
|
180
|
+
SQL:
|
|
181
|
+
\`\`\`sql
|
|
182
|
+
${e}
|
|
183
|
+
\`\`\`
|
|
184
|
+
|
|
185
|
+
Output a single slug. No sentences, no markdown, no quotes, no newlines. Your entire response must match ^[a-z0-9_]{1,${de}}$.`,Jr=e=>{let t=e.toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"");if(!t)return;if(t.length<=de)return t;let r=t.slice(0,de),i=r.lastIndexOf("_");return i>=Math.floor(de*2/3)?r.slice(0,i):r},Jt=async(e,t)=>{let r=Wt(e,t);if(r)try{let i=await X.promises.readdir(r);return new Set(i)}catch(i){if(i.code==="ENOENT")return new Set;D.warn(`Failed to snapshot migrations directory ${r} \u2014 rename disabled for this run`,{code:i.code,error:i.message});return}},Xr="claude-haiku-4-5",Kr="gpt-5.4-nano",Ht=async(e,t)=>{let r={...t,maxTokens:80},{response:i,text:n}=e==="claude"?await at({...r,model:Xr}):await lt({...r,model:Kr});return i?.usage&&et(i.usage,{agent:e}),n},Zr=async({sql:e,aiGateway:t,config:r})=>{let i=r.runner==="codex"?"codex":"claude",n=i==="claude"?"codex":"claude",s={aiGateway:t,config:r,prompt:Wr(e)},a;try{a=await Ht(i,s)}catch(l){D.warn(`${i} request failed for migration slug; trying ${n}`,{error:l.message});try{a=await Ht(n,s)}catch(g){D.warn(`${n} request also failed for migration slug`,{error:g.message});return}}let o=a.trim();if(zt.test(o))return o;let c=Jr(o);if(c&&zt.test(c))return D.warn(`Provider returned a non-conforming migration slug "${o}" \u2014 using normalized fallback "${c}"`),c;D.warn(`Provider returned invalid migration slug: ${o}`)},Qr=async({cwd:e,migrationsPath:t,snapshot:r,applied:i,config:n,aiGateway:s})=>{let a=Wt(e,t);if(!a)return;let o;try{o=await X.promises.readdir(a)}catch{return}let c=o.filter(d=>!r.has(d)),l=[];for(let d of c){if(i?.has(d))continue;let u=K.join(a,d),p;try{p=await X.promises.stat(u)}catch{continue}if(!p.isDirectory())continue;let f=K.join(u,"migration.sql");if(!X.existsSync(f))continue;let S=d.match(/^(\d{14})_(.+)$/);if(!S)continue;let[,_,h]=S;l.push({name:d,prefix:_,currentSuffix:h,entryPath:u,sqlPath:f})}l.length>0&&D.log(`Considering ${l.length} migration(s) for rename`,{migrations:l.map(d=>d.name)});for(let{name:d,prefix:u,currentSuffix:p,entryPath:f,sqlPath:S}of l){let _;try{_=await X.promises.readFile(S,"utf8")}catch(R){D.warn(`Failed to read ${S} \u2014 skipping rename for ${d}`,{code:R.code,error:R.message}),P.inc("db_migrations.rename",1,{outcome:"sql_read_failed"});continue}let h=await Zr({sql:_,config:n,aiGateway:s});if(!h){P.inc("db_migrations.rename",1,{outcome:"no_slug"});continue}if(h===p){P.inc("db_migrations.rename",1,{outcome:"slug_unchanged"});continue}let y=`${u}_${h}`,v=K.join(a,y);if(X.existsSync(v)){D.warn(`Cannot rename migration ${d} \u2192 ${y}: target already exists`),P.inc("db_migrations.rename",1,{outcome:"target_exists"});continue}try{await X.promises.rename(f,v),D.log(`Renamed migration ${d} \u2192 ${y}`),P.inc("db_migrations.rename",1,{outcome:"renamed"})}catch(R){D.warn(`Failed to rename migration ${d} \u2192 ${y}`,{error:R.message}),P.inc("db_migrations.rename",1,{outcome:"rename_failed"})}}let g=await X.promises.readdir(a).catch(()=>[]);r.clear();for(let d of g)r.add(d)},Ce=async e=>await Ze({stage:"db-migrations"},()=>E(x(),"db-migrations",async t=>{let r=e.cwd||zr.cwd();if(!(await Vt("@netlify/database",r)||await Vt("@netlify/db",r)))return t?.setAttributes({skipped:!0,reason:"@netlify/database is not installed"}),P.inc("db_migrations.run",1,{outcome:"skipped",reason:"no_module"}),{skipped:!0};let n=[...Hr].find(s=>X.existsSync(K.join(r,s)));if(!n)return t?.setAttributes({skipped:!0,reason:"no drizzle config found"}),P.inc("db_migrations.run",1,{outcome:"skipped",reason:"no_config"}),{skipped:!0};t?.setAttributes({configFile:n}),D.log(`Found ${n}, running drizzle-kit generate to ensure migrations are up to date`);try{let s=await A("npx",["drizzle-kit","generate"],{cwd:r,stdio:["ignore","pipe","pipe"]});return s.stdout&&D.log(String(s.stdout)),t?.setAttributes({success:!0}),P.inc("db_migrations.run",1,{outcome:"success"}),e.snapshot&&await Qr({cwd:r,migrationsPath:e.migrationsPath,snapshot:e.snapshot,applied:e.applied,config:e.config,aiGateway:e.aiGateway}),{skipped:!1}}catch(s){let a=en(s);return D.warn("drizzle-kit generate failed:",a),t?.setAttributes({success:!1,error:a}),P.inc("db_migrations.run",1,{outcome:"failure"}),{skipped:!1,error:a}}})),Vt=async(e,t)=>{try{return await st(`node -e "require.resolve('${e}')"`,{cwd:t,stdio:"ignore"}),!0}catch{return!1}},en=e=>{if(e&&typeof e=="object"){let t=[];if("stderr"in e&&e.stderr&&t.push(String(e.stderr)),"stdout"in e&&e.stdout&&t.push(String(e.stdout)),t.length>0)return t.join(`
|
|
186
|
+
`)}return e instanceof Error?e.message:String(e)};var Je=w("migration_state"),Pe=async({cliPath:e,cwd:t})=>{let r="";try{let i=await A(e,["db","status","--json"],{cwd:t,stdio:["ignore","pipe","pipe"]});r=i.stdout?String(i.stdout):""}catch(i){let n=i;throw Je.warn("`netlify db status --json` failed",{exitCode:n.exitCode,stdout:n.stdout,stderr:n.stderr}),i}Je.log("`netlify db status --json` output",{stdout:r});try{return JSON.parse(r)}catch(i){throw Je.warn("Failed to parse `netlify db status --json` output",{stdout:r,error:String(i)}),i}},Xt=()=>["## Netlify Database","","A Netlify Database (managed Postgres) is available for this site.","It will be provisioned automatically on first connection.","No migrations have been applied yet \u2014 this is a fresh database.","","Use `@netlify/database` with Drizzle ORM for persistent data storage.","Define your schema in `db/schema.ts` and migrations will be generated automatically at deploy time.","Read the `netlify-database` skill for setup instructions."].join(`
|
|
187
|
+
`),Kt=e=>{if(e.applied.length===0&&e.pending.length===0)return null;let t=["## CRITICAL: Current Netlify Database state",""];if(e.applied.length>0){t.push("The following migrations are **already applied** to your preview database branch. They are immutable:","");for(let r of e.applied)t.push(`- ${r.name}`);t.push("","**Never delete, rename, or edit an applied migration file.** Doing so will break the deploy \u2014 the","platform requires every migration applied to the branch to exist on disk with its original content. If","you think an applied migration is wrong, roll forward with a NEW migration that corrects whatever it","did. That's always safe; deletion isn't.")}else t.push("No migrations are applied to your preview database branch yet.");if(e.pending.length>0){t.push(""),t.push("The following migration files exist on disk but have NOT yet been applied:","");for(let r of e.pending)t.push(`- ${r.name}`);t.push("","Pending files can be modified or deleted freely \u2014 use `netlify db migrations reset` to remove them","cleanly, then regenerate via `npx drizzle-kit generate` if you want a replacement.")}return t.join(`
|
|
188
|
+
`)},Zt=e=>{let t=[];return e.missingOnDisk.length>0&&t.push("You deleted the following migration file(s) that are already applied to the preview database branch:",...e.missingOnDisk.map(r=>`- ${r.name}`),"","Applied migrations cannot be removed \u2014 the deploy will fail because the platform requires every applied","migration to exist on disk with its original content. Please revise your work:","","1. Restore the deleted file(s) by running `netlify db migrations pull --force`, which overwrites the"," local migrations directory with the authoritative state of the branch. Note this also wipes any"," unapplied migration files you generated this session \u2014 regenerate them via `npx drizzle-kit generate`"," afterwards if you still need them (your `db/schema.ts` edits aren't affected by the pull).","2. If the underlying problem is that an applied migration is wrong, add a NEW migration on top that"," corrects whatever it did (drop a column, rename a table, etc.). Do not touch the original."),e.outOfOrder.length>0&&(t.length>0&&t.push(""),t.push("The following pending migration file(s) have a version prefix that sorts BEFORE migrations already","applied to the branch, so the platform will reject them on deploy:",...e.outOfOrder.map(r=>`- ${r.name} (version ${r.version} \u2264 applied max ${r.maxApplied})`),"","Delete these out-of-order files (use `netlify db migrations reset` \u2014 it only removes unapplied files),","then run `npx drizzle-kit generate` to produce a replacement whose version sorts after the applied","migrations.")),t.length===0?null:t.join(`
|
|
189
|
+
`)},Qt=e=>e.missingOnDisk.length>0||e.outOfOrder.length>0;var er=w("db_migrations_verify"),tr=async e=>await E(x(),"db-migrations-verify-stage",async t=>{let r;try{r=await Pe({cliPath:e.cliPath,cwd:e.cwd})}catch(n){return er.warn("Skipping migration verification \u2014 failed to read status",{error:n}),t?.setAttributes({"verify.skipped":!0,"verify.skip_reason":"status_error"}),{}}if(!Qt(r))return t?.setAttributes({"verify.drift":!1}),{};let i=Zt(r);return t?.setAttributes({"verify.drift":!0,"verify.missing_on_disk_count":r.missingOnDisk.length,"verify.out_of_order_count":r.outOfOrder.length}),er.log("Detected post-inference migration drift",{missingOnDisk:r.missingOnDisk.map(n=>n.name),outOfOrder:r.outOfOrder.map(n=>n.name)}),{error:i??void 0}});import Xe from"process";import{NetlifyDBProxy as tn}from"@netlify/database-proxy";var De=w("db_setup"),rr=async({siteId:e,isProd:t,alias:r,connectionString:i})=>await E(x(),"db-setup-stage",async n=>{n?.setAttributes({"db_setup.site_id":e,"db_setup.is_prod":t,...r&&{"db_setup.alias":r}});let s;if(t?s="production":r&&(s=r),Xe.env.NETLIFY_DB_BRANCH=s,i)return n?.setAttributes({"db_setup.source":"config","db_setup.has_proxy":!1}),De.log("Using database connection string provided by the API"),Xe.env.NETLIFY_DB_URL=i,{connectionString:i};let a=new tn({logger:(...c)=>De.log("db-proxy:",...c),provision:async()=>(De.log("Provisioning database for site via API"),await bt(e),await rn(e,t,r))}),o=await a.start();return n?.setAttributes({"db_setup.source":"proxy","db_setup.has_proxy":!0}),De.log("Local DB proxy started",{connectionString:o}),Xe.env.NETLIFY_DB_URL=o,{connectionString:o,proxy:a}}),rn=async(e,t,r)=>t||!r?(await _t(e)).connection_string:(await xt(e,r),(await St(e,r)).connection_string);var me=w("usage_tracker"),nn=4e3,nr=(e,t,r)=>{let i=!1,n=!1,s=!1,o=_e(async()=>{try{let g=await ht(e,t);me.log("Usage update response",{usage:g?.usage}),r!=null&&g?.usage?.total_credits_cost!=null&&g.usage.total_credits_cost>=r&&(me.log("Credit limit exceeded",{totalCreditsCost:g.usage.total_credits_cost,enforcedCreditsRemaining:r}),s=!0),g?.credit_limit_exceeded&&(me.log("Credit limit exceeded (flagged by API)"),s=!0)}catch(g){me.warn("Failed to update usage",{error:g?.message||g})}},nn);return{onAgentOutput:()=>{if(s)throw new H("AI credit usage exceeded enforced limit.",503,"Credit limit reached. Check credit limits to continue using Agent Runners.",!0);n||(i=!0,o())},stop:async()=>{n||(n=!0,i&&(me.log("Sending final usage update"),o(),await o.flush()))}}};var ln=an(import.meta.url),ir=ln("../package.json"),N=w("pipeline_index"),Ne=3,un=["codex","gemini"],Ps=async({config:e,apiToken:t,cliPath:r="netlify",cwd:i,filter:n})=>{let s,a,o,{withStageTimer:c}=tt(se.timeUnits.hours(4));N.log(`Agent runner orchestrator v${ir.version}`,{featureFlags:we().raw,metrics:Qe()}),$e({agent:e.runner,mode:e.mode,is_follow_up:e.sessionHistoryContext.length>0});let l=Date.now(),g=Number(process.env.NETLIFY_AGENT_RUNNER_SPAWN_AT_MS);Number.isFinite(g)&&g>0&&g<=l&&P.timing("startup.duration",l-g,{from:"spawn"});let d=Number(process.env.NETLIFY_AGENT_RUNNER_ENQUEUED_AT_MS);Number.isFinite(d)&&d>0&&d<=l&&P.timing("startup.duration",l-d,{from:"enqueue"});try{await E(x(),"run-pipeline",async()=>{let{aiGateway:u,context:p,persistSteps:f,runner:S,sha:_}=await c("init",()=>Dt({config:e,apiToken:t,cliPath:r,cwd:i,filter:n,runnerVersion:ir.version}),se.timeUnits.minutes(10)),h=S.runner;s=S.clean,a=nr(e.id,e.sessionId,e.enforcedAICreditsRemaining);let y=Re(e.mode),v;e.deployAlias&&e.deployAlias.length>0?v=e.deployAlias:(e.deployAlias!==void 0&&!y&&N.warn("Received empty deploy alias for a non-prod deploy, falling back to local computation"),v=ot(e.id,process.env.SITE_NAME,y));let R,z=Object.assign(async m=>{try{a?.onAgentOutput()}catch(b){oe(b)?R??=b:N.warn("Unexpected error in onAgentOutput",{error:b?.message||b});return}return f(m)},{flush:f.flush.bind(f)});if(e.sha=_,e.mode==="redeploy"){let m=await c("deploy",()=>Te({cliPath:r,config:e,context:p,result:"Redeploy completed",filter:n,isRetry:!1,deploySubdomain:v}));m.deployError&&N.warn(`Redeploy deploy failed: ${m.deployError}`);let{diff:b,resultDiff:J,previewInfo:O,diffBinary:G,resultDiffBinary:pr,hasNetlifyForm:gr,hasNetlifyIdentity:fr}=m;await a?.stop(),await c("cleanup",()=>We({config:e,diff:b,result:"Redeploy completed",duration:0,resultDiff:J,diffBinary:G,resultDiffBinary:pr,previewInfo:O,isProdDeploy:y,hasNetlifyForm:gr,hasNetlifyIdentity:fr}),se.timeUnits.minutes(10)),process.env.NETLIFY_LOCAL_MODE||(await s?.(),await o?.stop(),await Ye());return}let k;if(e.mode==="create"){let{runCreateStage:m}=await import("./create-DE7SRLKP.js");k=(await c("create",()=>m({config:e,cwd:i}))).additionalContext}process.env.EXPERIMENTAL_NETLIFY_DB_ENABLED="1";let $,M;if(!process.env.NETLIFY_LOCAL_MODE&&e.siteId){let m=await c("db-setup",()=>rr({siteId:e.siteId,isProd:y,alias:v,connectionString:e.dbConnectionString}),se.timeUnits.minutes(10));if(o=m.proxy,i)if(m.proxy)k=[Xt(),k].filter(Boolean).join(`
|
|
190
|
+
|
|
191
|
+
`);else try{let b=await Pe({cliPath:r,cwd:i});$=new Set(b.applied.map(O=>O.name)),M=b.migrationsPath;let J=Kt(b);J&&(k=[J,k].filter(Boolean).join(`
|
|
192
|
+
|
|
193
|
+
`))}catch(b){N.warn("Skipping migration context injection \u2014 failed to build state block",{error:b})}}let Z=await Jt(i??process.cwd(),M),{runnerResult:C}=await c("inference",async()=>{try{return await ne({cliPath:r,config:e,context:p,runner:h,persistSteps:z,aiGateway:u,additionalContext:k,cwd:i})}catch(m){if(!(m instanceof te)||e.mode!=="rebase"&&e.mode!=="conflict_resolution")throw m;for(let b of un){if(R&&oe(R))throw R;if(b===e.runner)continue;let J=Ie[b];if(!J)continue;let O=await J();N.log(`Primary runner ${e.runner} failed in ${e.mode} mode, falling back to ${b}`),$e({agent:b,mode:e.mode});try{let G=await ne({cliPath:r,config:{...e,runner:b},context:p,runner:O.runner,persistSteps:z,aiGateway:u,additionalContext:k,cwd:i});return e.runner=b,h=O.runner,s=O.clean,G}catch(G){if(oe(G))throw G;N.error(`Fallback runner ${b} also failed`,{error:String(G)})}}throw m}});if(e.mode==="create")try{let m=JSON.parse(sn(on.join(i??process.cwd(),".netlify","scaffold-result.json"),"utf8"));await E(x(),"create-scaffold-telemetry",b=>{b?.setAttributes({"create.template":m.template,"create.packageManager":m.packageManager})})}catch{await E(x(),"create-scaffold-telemetry",m=>{m?.setAttributes({"create.template":"none","create.packageManager":"none"})})}if(R)throw R;let pe=await Ce({cwd:i,migrationsPath:M,snapshot:Z,applied:$,config:e,aiGateway:u});if(pe.error){N.log("Migration generation failed, running inference to fix the issue");let{runnerResult:m}=await c("inference-migration-fix",()=>ne({cliPath:r,config:e,context:p,runner:h,persistSteps:z,aiGateway:u,buildErrors:[`Running \`drizzle-kit generate\` to generate database migrations failed with the following error:
|
|
194
|
+
|
|
195
|
+
${pe.error}
|
|
196
|
+
|
|
197
|
+
Please fix the issue and do NOT run \`drizzle-kit generate\` yourself \u2014 it will be run automatically after you're done.`],priorAgentSessionId:C.agentSessionId}));C={...m,steps:[...C.steps||[],...m.steps||[]],duration:(C.duration||0)+(m.duration||0)},await Ce({cwd:i,migrationsPath:M,snapshot:Z,applied:$,config:e,aiGateway:u})}if(i&&!pe.skipped){let m=await c("db-migrations-verify",()=>tr({cliPath:r,cwd:i}));if(m.error){N.log("Migration drift detected, running inference to fix");let{runnerResult:b}=await c("inference-migration-drift-fix",()=>ne({cliPath:r,config:e,context:p,runner:h,persistSteps:z,aiGateway:u,buildErrors:[m.error],priorAgentSessionId:C.agentSessionId}));C={...b,steps:[...C.steps||[],...b.steps||[]],duration:(C.duration||0)+(b.duration||0)}}}let U=await c("deploy",()=>Te({cliPath:r,config:e,context:p,result:C.result,filter:n,isRetry:!1,deploySubdomain:v})),W=C,ke=[];if(U.hasChanges&&U.deployError){ke.push(ut(U.deployError));let m=1,b=!1;for(;m<=Ne&&!U.previewInfo&&!b;)N.log(`Deploy attempt had errors. Retrying. ${m}/${Ne}`),await E(x(),"deploy-stage",async J=>{J?.setAttributes({"stage.attempt":m});let O;try{O=(await c(`inference-retry-${m}`,()=>ne({cliPath:r,config:e,context:p,runner:h,persistSteps:z,aiGateway:u,buildErrors:ke,priorAgentSessionId:C.agentSessionId}))).runnerResult}catch(G){if(oe(G))throw G;N.warn(`Inference retry ${m} failed, stopping deploy retries:`,G),b=!0;return}if(R)throw R;W={...O,steps:[...W.steps||[],...O.steps||[]],duration:(W.duration||0)+(O.duration||0)},await Ce({cwd:i,migrationsPath:M,snapshot:Z,applied:$,config:e,aiGateway:u}),U=await c(`deploy-retry-${m}`,()=>Te({cliPath:r,config:e,context:p,result:O.result,filter:n,isRetry:!0,deploySubdomain:v})),U.deployError&&ke.push(U.deployError),m++});m>Ne&&!U.previewInfo&&console.warn(`Deploy validation failed after ${Ne} attempts`)}let{diff:sr,resultDiff:or,previewInfo:ar,diffBinary:lr,resultDiffBinary:ur,hasNetlifyForm:cr,hasNetlifyIdentity:dr}=U;await a?.stop(),await c("cleanup",()=>We({config:e,diff:sr,result:W.result,duration:W.duration,resultDiff:or,diffBinary:lr,resultDiffBinary:ur,previewInfo:ar,isProdDeploy:y,hasNetlifyForm:cr,hasNetlifyIdentity:dr}),se.timeUnits.minutes(10)),process.env.NETLIFY_LOCAL_MODE||(await s?.(),await o?.stop(),await Ye())})}catch(u){if(oe(u)){N.info("Agent run terminated gracefully",{statusCode:u.statusCode,reason:u.message}),await a?.stop(),await s?.(),await o?.stop();try{await q(e.id,e.sessionId,{result:u.userMessage,state:u.isCreditLimitExceeded?"cancelled":"error",...u.isCreditLimitExceeded&&{credit_limit_exceeded:!0}})}catch{N.info("Could not update session (site may have been deleted)")}return}N.error("Got error while running pipeline",u),await a?.stop(),await s?.(),await o?.stop();let p=u instanceof Error&&u.message,f=p?Se(p):"Encountered error when running agent";throw await q(e.id,e.sessionId,{result:f,state:"error"}),u}};export{dn as a,je as b,Ps as c};
|
|
198
|
+
//# sourceMappingURL=chunk-AMROU6YU.js.map
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import{d as V,f as M,g as N,k as j,m as W,o as H,p as X,q as z}from"./chunk-6BDGZ7YC.js";import{A as g,E as J,a as q,y as G}from"./chunk-2PERVUPF.js";import S from"fs/promises";import F from"os";import v from"path";import f from"process";import re from"readline";import ie from"openai";var c=q("runner_codex"),D="Codex CLI",E="gpt-5.5",se=({catchError:t,runCmd:n,error:r,result:s,runnerName:a})=>(c.log(`${a} command completed with catch handler triggered`,{hadExistingError:!!r,hadExistingResult:!!s,resultLength:s?s.length:0,catchError:t?.message||"No error object",processExitCode:n.exitCode,processKilled:n.killed}),s?(c.log("Preserving existing result despite catch handler being triggered"),r?{error:r,result:s}:{error:"Process completed with errors but result was captured",result:s}):(c.log("Setting result to undefined because no valid result was captured"),{error:r||`${a} failed`,result:void 0}));async function Q({aiGateway:t,config:n,model:r}){let s=r;if(t)if(n.modelVersionOverrides?.codex){let a=n.modelVersionOverrides?.codex?.[n.accountType];if(a){if(!await t.isModelAvailableForProvider("openai",a))throw new Error(`Model override '${a}' is not available for openai provider`);s=a}}else if(r){if(!await t.isModelAvailableForProvider("openai",r))throw new Error(`Model '${r}' is not available for openai provider`)}else!!E&&await t.isModelAvailableForProvider("openai",E)?(s=E,c.log(`Using default model: ${E}`)):E&&c.log(`Default model ${E} is not available, proceeding without model specification`);return s}function Z({aiGateway:t}){if(t){let{token:n,url:r}=t;if(!n||!r)throw new Error("No token or url provided from AI Gateway");f.env.OPENAI_API_KEY=n,f.env.OPENAI_BASE_URL=r}else if(!f.env.OPENAI_API_KEY)throw new Error("OPENAI_API_KEY is not provided")}async function ae({config:t,netlify:n,persistSteps:r,sendSteps:s,aiGateway:a,cwd:d=f.cwd()}){let{prompt:o}=t,{model:u}=t;Z({aiGateway:a});let m=await Q({config:t,aiGateway:a,model:u}),y=[],b=[],U=[],$={},w=new Set,B=0,I=0,R,h,K=`${f.env.NVM_BIN}/node`,P=v.join(F.homedir(),".codex"),te=v.join(P,"config.toml"),ne=v.join(P,"auth.json");try{await S.mkdir(P,{recursive:!0});let l={OPENAI_API_KEY:f.env.OPENAI_API_KEY};await S.writeFile(ne,JSON.stringify(l,null,2),"utf-8"),c.log("Created Codex auth.json file");let e=f.env.OPENAI_BASE_URL,i=['forced_login_method = "api"'];e&&i.push('model_provider = "openai_proxy"',"","[model_providers.openai_proxy]",'name = "OpenAI Proxy"',`base_url = "${e}"`,'env_key = "OPENAI_API_KEY"','wire_api = "responses"',"supports_websockets = false","requires_openai_auth = true"),await S.writeFile(te,`${i.join(`
|
|
2
|
+
`)}
|
|
3
|
+
`,"utf-8"),c.log("Wrote Codex config.toml")}catch(l){let e=l instanceof Error?l.message:String(l);throw c.warn("Failed to setup Codex config and credentials",{error:e}),new Error(`Codex setup failed: ${e}`)}let oe=m==="gpt-5.5",T=[J(d,"codex"),"exec","--yolo","--json",...oe?["-c",'model_reasoning_effort="low"']:[],...m?["--model",m]:[],o].filter(Boolean);c.log(`Running ${K} ${T.join(" ")}`);let O=n.utils.run(K,T,{all:!0,cwd:d,env:{...f.env},stdin:"ignore",idleTimeout:G}),A=V(()=>{r?.({steps:y,duration:I}),s?.({steps:b,duration:I}),b=[]},250),_=(l,e)=>{let i={...l,id:B};B+=1,U.push(i),y.push(i),b.push(i),e||A.flush(),A(),e&&A.flush()};_({title:`Using ${D} with ${m||"default"}`,category:g.Environment},!0);let k=re.createInterface({input:O.all});return k.on("error",l=>{c.error("Readline interface error",{error:l.message,stack:l.stack})}),k.on("line",l=>{let e=null;try{e=JSON.parse(l)}catch{c.log("Could not parse line",l);return}if(e?.duration_ms&&(I=e.duration_ms),e?.type==="item.started"&&e?.item?.type==="command_execution")$[e.item.id]=e.item;else if(e?.type==="item.completed"&&e?.item?.type==="command_execution"){let i=e.item,C=de(i);C&&_(C,!0);let p=i.command?.match(/\.agents\/skills\/([^\s/]+)/)?.[1];if(p&&!w.has(p)){w.add(p);let L=M(p);N(c,L),_({title:`Use ${L}`,category:g.Skill,type:p},!0)}}else if(e?.type==="item.completed"&&e?.item?.type==="reasoning"){let i={title:"Reasoning",message:e.item.text,category:g.Reasoning};_(i,!0)}else if(e?.type==="local_shell_call"){let i=e;$[i.call_id]=i}else if(e?.type==="local_shell_call_output"){let i=e,C=$[i.call_id],p=ue(C,i);p&&_(p,!0);let x=(C?.action?.command?.join(" ")??"").match(/\.agents\/skills\/([^\s/]+)/)?.[1];if(x&&!w.has(x)){w.add(x);let Y=M(x);N(c,Y),_({title:`Use ${Y}`,category:g.Skill,type:x},!0)}}else e?.type==="message"&&e.role==="assistant"?R=e.content?.map(i=>i.text).join(`
|
|
4
|
+
`):e?.type==="message"&&e.role==="system"&&(h=e.content?.map(i=>i.text).join(`
|
|
5
|
+
`))}),await O.catch(l=>{let e=se({catchError:l,runCmd:O,error:h,result:R,runnerName:"Codex"});h=e.error,R=e.result}),k.close(),A.flush(),{steps:U,duration:I,result:await W({initialResult:R,agentName:D,hasError:!!h}),error:H({error:h,agentName:D}),isRetryableError:X(h),isProviderUnavailableError:z(h)}}var we=async()=>{let t=v.join(F.homedir(),".codex");await S.rm(t,{recursive:!0,force:!0});let n=v.join(F.homedir(),".agents","skills");await S.rm(n,{recursive:!0,force:!0})},le=new Set(["bash","-lc"]),ce=/^sed\s+-n\s+(?:'[^']*'|"[^"]*"|\S+)\s+(\S+)\s*$/,ee=t=>{let n=t.match(ce);return n?{title:`Reading \`${n[1]}\``,category:g.FileRead}:{title:`Running \`${t}\``,category:g.RunCommand}},de=t=>{if(!t||t.type!=="command_execution")return null;let n=t.command;n=n.replace(/^(\/usr\/bin\/)?bash -lc ['"]/,"").replace(/['"]$/,"");let{command:r,heredocContent:s}=j(n),{title:a,category:d}=ee(r),o=t.aggregated_output?.trim();return s?o=`\`\`\`
|
|
6
|
+
${s}
|
|
7
|
+
\`\`\`${o?`
|
|
8
|
+
|
|
9
|
+
\`\`\`
|
|
10
|
+
${o}
|
|
11
|
+
\`\`\``:""}`:o&&(o=`\`\`\`
|
|
12
|
+
${o}
|
|
13
|
+
\`\`\``),t.status==="failed"&&t.exit_code!==0&&(o=o?`${o}
|
|
14
|
+
|
|
15
|
+
*Exit code: ${t.exit_code}*`:`*Command failed with exit code: ${t.exit_code}*`),{title:a,message:o,category:d}},ue=(t,n)=>{if(!t||!n||t.call_id!==n.call_id)return null;let r=t.action?.command?.filter(u=>!le.has(u)),s,a=g.RunCommand,d;if(r){let u=j(r.join(" ")),m=ee(u.command);s=m.title,a=m.category,d=u.heredocContent}let o;try{o=JSON.parse(n.output).output?.trim()}catch(u){c.error("Could not decode outputMsg",u,n.output)}return d?o=`\`\`\`
|
|
16
|
+
${d}
|
|
17
|
+
\`\`\`${o?`
|
|
18
|
+
|
|
19
|
+
\`\`\`
|
|
20
|
+
${o.trim()}
|
|
21
|
+
\`\`\``:""}`:o&&(o=`\`\`\`
|
|
22
|
+
${o.trim()}
|
|
23
|
+
\`\`\``),{title:s,message:o,category:a}},Ie=async({aiGateway:t,config:n,model:r,prompt:s,systemPrompt:a="",outputFormat:d,maxTokens:o=4096})=>{Z({aiGateway:t});let u=await Q({config:n,aiGateway:t,model:r});if(!u)throw new Error("Model is required");let y=await new ie().responses.parse({model:u,max_output_tokens:o,input:[...a?[{role:"system",content:a}]:[],{role:"user",content:s}],...d&&{text:{format:{...d,name:"output"}}}});return{response:y,text:y.output_text}};export{ae as a,we as b,Ie as c};
|
|
24
|
+
//# sourceMappingURL=chunk-G4E552O7.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a as u}from"./chunk-2PERVUPF.js";var i=u("tracing"),a=class{constructor(){this.attributes={}}setAttributes(t){Object.assign(this.attributes,t)}},d=r=>{let t=Object.entries(r);return t.length===0?"":` [${t.map(([e,n])=>e.includes("duration")&&typeof n=="number"?`${e}=${n.toFixed(2)}ms`:`${e}=${n}`).join(", ")}]`},p=()=>{},m=async(r,t,e)=>{i.log(`\u23F3 ${t} starting...`);let n=new a,c=performance.now();try{let o=await e(n),s=(performance.now()-c).toFixed(2);return i.log(`\u2705 ${t} completed in ${s}ms${d(n.attributes)}`),o}catch(o){let s=(performance.now()-c).toFixed(2);throw i.log(`\u274C ${t} failed in ${s}ms${d(n.attributes)}`),o}};export{p as a,m as b};
|
|
2
|
+
//# sourceMappingURL=chunk-OUIDKGFH.js.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import{d as X,f as Z,g as ee,h as te,m as re,o as se,p as oe,q as ne}from"./chunk-6BDGZ7YC.js";import{A as s,E as z,a as V,h as J,t as L,y as Q}from"./chunk-2PERVUPF.js";import v from"fs/promises";import pe from"os";import P from"path";import y from"process";import ge from"readline";import me from"@anthropic-ai/sdk";var u=V("runner_claude"),I="Claude Code",ae="claude-opus-4-6",fe={[L]:"claude-sonnet-4-6"},x={Task:{name:"Task",category:s.Task},Bash:{name:"Run command",category:s.RunCommand},Glob:{name:"Find files",category:s.Explore},Grep:{name:"Search files",category:s.Explore},LS:{name:"List directory",category:s.Explore},ExitPlanMode:{name:"Exit planning",category:s.Plan},Read:{name:"Read file",category:s.FileRead},Edit:{name:"Edit file",category:s.FileWrite},MultiEdit:{name:"Edit multiple files",category:s.FileWrite},Write:{name:"Edit file",category:s.FileWrite},NotebookEdit:{name:"Edit notebook",category:s.Notebook},WebFetch:{name:"Fetch web",category:s.Web},TodoWrite:{name:"Update task list",category:s.Todo},WebSearch:{name:"Search web",category:s.Web},BashOutput:{name:"Get command output",category:s.RunCommand},KillBash:{name:"Stop command",category:s.RunCommand}},ie=r=>x[r]?.name||r,he=({catchError:r,runCmd:n,error:o,result:l,runnerName:d})=>(u.log(`${d} command completed with catch handler triggered`,{hadExistingError:!!o,hadExistingResult:!!l,resultLength:l?l.length:0,catchError:r?.message||"No error object",processExitCode:n.exitCode,processKilled:n.killed}),l?(u.log("Preserving existing result despite catch handler being triggered"),o?{error:o,result:l}:{error:"Process completed with errors but result was captured",result:l}):(u.log("Setting result to undefined because no valid result was captured"),{error:o||`${d} failed`,result:void 0}));async function le({aiGateway:r,config:n,model:o}){let l=o;if(r)if(n.modelVersionOverrides?.claude){let d=n.modelVersionOverrides?.claude?.[n.accountType];if(d){if(!await r.isModelAvailableForProvider("anthropic",d))throw new Error(`Model override '${d}' is not available for anthropic provider`);l=d}}else if(o){if(!await r.isModelAvailableForProvider("anthropic",o))throw new Error(`Model '${o}' is not available for anthropic provider`)}else{let d=fe[n.accountType],c=d||ae;!!c&&await r.isModelAvailableForProvider("anthropic",c)?(u.log(`Using ${d?"account override":"default"} model: ${c}`),l=c):c&&u.log(`Model ${c} is not available, proceeding without model specification`)}return l}function de({aiGateway:r}){if(r){let{token:n,url:o}=r;if(!n||!o)throw new Error("No token or url provided from AI Gateway");y.env.ANTHROPIC_API_KEY=n,y.env.ANTHROPIC_BASE_URL=o}else if(!y.env.ANTHROPIC_API_KEY)throw new Error("ANTHROPIC_API_KEY is not provided")}async function ye(){let r=P.join(y.cwd(),"AGENTS.md");try{await v.access(r)}catch{return}let n=P.join(y.cwd(),"CLAUDE.local.md"),o="@AGENTS.md";try{if((await v.readFile(n,"utf-8")).includes(o))return;await v.appendFile(n,`
|
|
2
|
+
${o}
|
|
3
|
+
`)}catch{await v.writeFile(n,`${o}
|
|
4
|
+
`)}u.log("Added @AGENTS.md import to CLAUDE.local.md")}async function _e({config:r,netlify:n,persistSteps:o,aiGateway:l,continueSession:d,priorAgentSessionId:c,cwd:_=y.cwd()}){let b=r,{prompt:B}=b,{model:M}=r,R="";await ye(),de({aiGateway:l});let E=await le({config:r,aiGateway:l,model:M}),S=[],$=[],j={},D=0,F=0,w,h,U="mode"in r&&r.mode==="create"&&r.accountType===L,q=["ExitPlanMode","AskUserQuestion"];U&&q.push("TodoWrite");let O=z(_,"claude");if(!O)throw new Error("Claude CLI binary not found");let K=["--permission-mode","bypassPermissions","--dangerously-skip-permissions","--output-format","stream-json","--verbose","--disallowed-tools",q.join(","),"--effort",U?"low":"high",...E?["--model",E]:[],...d?["--continue"]:[],...d&&c?["--resume",c]:[],"-p",B];u.log(`Running ${O} ${K.join(" ")}`);let A=n.utils.run(O,K,{all:!0,env:y.env,cwd:_,idleTimeout:Q});A.stdin?.end();let C=X(()=>{o?.({steps:S,duration:F})},250),f=(m,t)=>{let{wrapMessage:e,...i}=m,p=te({...i,id:D});p.message&&(p.message=p.message.replace(/\n?<system-reminder>.+?<\/system-reminder>\n?/gs,"").trim(),e&&p.message&&(p.message=`\`\`\`
|
|
5
|
+
${p.message}
|
|
6
|
+
\`\`\``)),D+=1,$.push(p),S.push(p),t||C.flush(),C(),t&&C.flush()},Y=E||ae,ue=U?`Using ${I} in low credit usage mode due to low remaining credits. Setting model to ${Y} and extra effort to low`:`Using ${I} with ${Y}`;f({title:ue,category:s.Environment},!0);let N=ge.createInterface({input:A.all});return N.on("error",m=>{u.error("Readline interface error",{error:m.message,stack:m.stack})}),N.on("line",m=>{let t=null;try{t=JSON.parse(m)}catch{u.log("Could not parse line",m)}t?.session_id&&t.session_id!==R&&(R=t.session_id),Array.isArray(t?.message?.content)?t.message.content.forEach(e=>{switch(e.type){case"text":{if(e.text){if(e.text.startsWith("Base directory for this skill:"))break;f({message:e.text,category:t.message?.role==="user"?s.UserMessage:s.AgentMessage,parentGroupId:t.parent_tool_use_id||void 0})}break}case"image":{typeof e.source=="object"&&e.source&&e.source.type==="base64"&&e.source.media_type?f({message:``,category:s.AgentMessage,parentGroupId:t.parent_tool_use_id||void 0}):u.log(`Unsupported image type ${e.source?.type}`,e.source);break}case"tool_use":{if(e.name==="Task"){let i=e.input?.description&&`\`${e.input.description}\``;f({title:[ie(e.name),i].filter(Boolean).join(" "),category:x[e.name]?.category,groupId:e.id,parentGroupId:t.parent_tool_use_id||void 0})}e.id&&(j[e.id]=e),C.flush();break}case"tool_result":{let i=e.tool_use_id?j[e.tool_use_id]:void 0,p=i?.name==="Task";if(i?.name==="Skill"&&i?.input?.skill){let g=Z(i.input.skill?.toString());ee(u,g),f({title:`Use ${g}`,category:s.Skill,type:i.input.skill?.toString(),parentGroupId:t.parent_tool_use_id||void 0},!0);break}if(i?.name==="TodoWrite"){let{name:g,category:a}=x.TodoWrite;f({title:g,category:a,parentGroupId:t.parent_tool_use_id||void 0,tasks:t.tool_use_result?.newTodos?.map(k=>({name:k.status==="in_progress"?k.activeForm:k.content,value:k.status}))},!0);break}let H;if(!p&&i){let g=i.input?.file_path&&P.relative(_,i.input.file_path);g||(g=i.input?.pattern||i.input?.command);let a=g&&`\`${g}\``;H=[ie(i.name||""),a].filter(Boolean).join(" ")}let ce=["Bash","Glob","Grep","LS","Read","Edit","Write"].includes(i?.name||""),W=t.parent_tool_use_id||void 0;!W&&p&&(W=e.tool_use_id);let G,T=p&&t.tool_use_result?.content||e.content;if(typeof T=="string")G=T;else if(Array.isArray(T)){let g=[];T.forEach(a=>{a?.type==="text"&&typeof a.text=="string"?g.push(a.text):a?.type==="image"&&typeof a.source=="object"&&a.source?a.source.type==="base64"&&a.source.media_type?g.push(``):u.log(`Unsupported image type ${a.source.type}`,a.source):u.log(`Unsupported block type ${a?.type}`)}),G=g.join(`
|
|
7
|
+
|
|
8
|
+
`)}f({title:H,message:G,wrapMessage:ce,category:p?s.AgentMessage:x[i?.name??""]?.category||s.AgentMessage,parentGroupId:W},!0);break}case"thinking":{e.thinking&&f({title:"Reasoning",message:e.thinking,category:s.Reasoning,parentGroupId:t.parent_tool_use_id||void 0},!0);break}default:u.log(`Message content type is not supported ${e.type}`,e)}}):t?.type==="result"&&(F=t.duration_ms||0,t.is_error?h=t.result:w=t.result,t.usage&&J(t.usage),[$,S].forEach(e=>{e[e.length-1]?.message===w&&e.pop()}))}),await A.catch(m=>{({error:h,result:w}=he({catchError:m,runCmd:A,error:h,result:w,runnerName:"Claude"}))}),N.close(),C.flush(),{steps:$,duration:F,result:await re({initialResult:w,agentName:I,hasError:!!h}),error:se({error:h,agentName:I}),isRetryableError:oe(h),isProviderUnavailableError:ne(h),agentSessionId:R}}var Pe=async()=>{let r=P.join(pe.homedir(),".claude");await v.rm(r,{recursive:!0,force:!0})},Se=async({aiGateway:r,config:n,model:o,prompt:l,systemPrompt:d,outputFormat:c,maxTokens:_})=>{de({aiGateway:r});let b=await le({config:n,aiGateway:r,model:o});if(!b)throw new Error("Model is required");let M=await new me().messages.create({max_tokens:_||4096,model:b,system:d,messages:[{role:"user",content:l}],...c&&{output_config:{format:c}}}),R=M.content.map(E=>"text"in E&&E.text).filter(Boolean).join("");return{response:M,text:R}};export{_e as a,Pe as b,Se as c};
|
|
9
|
+
//# sourceMappingURL=chunk-Y5TT773K.js.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import{a as u,b as f}from"./chunk-OUIDKGFH.js";import{B as g,E as h,a as m}from"./chunk-2PERVUPF.js";import l from"process";import{fileURLToPath as S}from"url";import{createRequire as _}from"module";import c from"path";import{readdir as C,rm as A}from"fs/promises";import{join as b}from"path";async function y(e,n=[]){let o=(await C(e)).filter(r=>!n.includes(r));await Promise.all(o.map(r=>A(b(e,r),{recursive:!0,force:!0})))}var j=c.dirname(S(import.meta.url)),w=_(import.meta.url),I=c.resolve(j,"scripts/scaffold.js"),s=m("create_stage"),x="After completing the user's request:\n- Add a README.md to the project root describing what the project is, the key technologies used, and how to run it locally.\n- Add an AGENTS.md to the project root describing the project architecture, key directories, coding conventions, and any non-obvious decisions. This file is read by AI agents in future sessions to understand the project.\n\nDo not install dependencies (`npm install`, `pnpm install`, `yarn install`) and do not run local validation or dev-server commands to check your work \u2014 specifically `tsc`, `npx tsc`, `vite build`, `vite dev`, or any equivalent build/start/test command. The build pipeline installs and validates the project automatically after your edits. Verify your changes by reading the files you edited.\n\nCommands that generate or modify project files are fine to run when the task requires them \u2014 for example `drizzle-kit generate` to write a database migration after a schema change, or other code-generation utilities documented in the skills.",E="./.netlify-cache",k=({cwd:e=l.cwd()}={})=>{let n=l.env.NVM_BIN?`${l.env.NVM_BIN}/node`:"node",t;try{let o=w.resolve("@netlify/ts-cli/package.json"),r=c.dirname(o),i=w("@netlify/ts-cli/package.json");t=c.join(r,i.bin)}catch{t=h(e,"ts-cli")}return{nodeCmd:n,tsCliPath:t}},R=e=>{let n=[];try{if(!e)throw new Error("empty response");n=JSON.parse(e)}catch(t){return s.error("Failed to parse template list from ts-cli",{raw:e,error:t.message}),[]}return n.filter(t=>t.type==="example").map(t=>{let{type:o,...r}=t;return r})},L=({templates:e,nodeCmd:n,scaffoldScriptPath:t})=>{let o=JSON.stringify(e.map(({id:i,name:a,description:d})=>({id:i,name:a,description:d})),null,2);return["You are creating a new Netlify project to fulfill the user's request. The project directory is currently empty.",e.length>0?`## Available Templates
|
|
2
|
+
|
|
3
|
+
Start with one of the following templates by using the Bash command below, unless there's a strong reason to start from scratch based on the users prompt.
|
|
4
|
+
|
|
5
|
+
\`\`\`json
|
|
6
|
+
${o}
|
|
7
|
+
\`\`\`
|
|
8
|
+
|
|
9
|
+
To scaffold a template, run:
|
|
10
|
+
|
|
11
|
+
\`\`\`bash
|
|
12
|
+
NETLIFY_BUILD_BASE="\${NETLIFY_BUILD_BASE:-${E}}" ${n} ${t} <template-id> [--package-manager npm|pnpm|yarn]
|
|
13
|
+
\`\`\`
|
|
14
|
+
|
|
15
|
+
Replace \`<template-id>\` with the matching template \`id\`. Include \`--package-manager\` only if the user specified one. The templates can include relevant agent skills. The \`NETLIFY_BUILD_BASE=\u2026\` prefix lets the scaffold use a local template mirror if the platform set one \u2014 leave it as-is. Follow the instructions printed by the scaffold command.`:"",x].filter(Boolean).join(`
|
|
16
|
+
|
|
17
|
+
`)},Y=async({config:e,cwd:n=l.cwd()})=>await f(u(),"create-stage",async t=>{let o=performance.now();t?.setAttributes({"create.runner":e.runner,"create.id":e.id,"create.sessionId":e.sessionId}),await y(n,[".netlify",".git","node_modules"]),s.info("Cleaned cwd folder");let{nodeCmd:r,tsCliPath:i}=k({cwd:n}),a=[];if(i){let p=[i,"--list-addons-json"];s.log(`Running ${r} ${p.join(" ")}`);let{stdout:v}=await g(r,p);a=R(v),s.info("Retrieved add-ons")}else s.warn("ts-cli binary not resolved; create-mode prompt will omit template section");let d=L({templates:a,nodeCmd:r,scaffoldScriptPath:I}),T=performance.now()-o;return t?.setAttributes({"create.duration.ms":T,"create.status":"success"}),{additionalContext:d}});export{x as CREATE_MODE_INSTRUCTIONS,E as TS_CLI_TEMPLATE_MIRROR_FALLBACK_BASE,L as buildCreateStageAdditionalContext,R as parseAddonsList,k as resolveTsCliInvocation,Y as runCreateStage,I as scaffoldScriptPath};
|
|
18
|
+
//# sourceMappingURL=create-DE7SRLKP.js.map
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{d as z,e as V,f as R,g as q,m as H,o as Q,p as X,q as Z}from"./chunk-6BDGZ7YC.js";import{A as o,E as Y,a as W,h as J,y as K}from"./chunk-2PERVUPF.js";import v from"fs/promises";import L from"os";import _ from"path";import g from"process";import ie from"readline";var a=W("runner_gemini"),P="Gemini CLI",f="gemini-3.5-flash",se=({catchError:s,runCmd:l,error:r,result:n,runnerName:m})=>(a.log(`${m} command completed with catch handler triggered`,{hadExistingError:!!r,hadExistingResult:!!n,resultLength:n?n.length:0,catchError:s?.message||"No error object",processExitCode:l.exitCode,processKilled:l.killed}),n?(a.log("Preserving existing result despite catch handler being triggered"),r?{error:r,result:n}:{error:"Process completed with errors but result was captured",result:n}):(a.log("Setting result to undefined because no valid result was captured"),{error:r||`${m} failed`,result:void 0})),ee={list_directory:{name:"List directory",category:o.Explore},read_file:{name:"Read file",category:o.FileRead},write_file:{name:"Edit file",category:o.FileWrite},glob:{name:"Find files",category:o.Explore},search_file_content:{name:"Search files",category:o.Explore},replace:{name:"Edit file",category:o.FileWrite},run_shell_command:{name:"Run command",category:o.RunCommand},web_fetch:{name:"Fetch web",category:o.Web},web_search:{name:"Search web",category:o.Web},read_many_files:{name:"Read files",category:o.FileRead},save_memory:{name:"Memorize",category:o.Memorize},activate_skill:{name:"Use Skill",category:o.Skill},grep_search:{name:"Search files",category:o.Explore}},ae=async()=>{let s=_.join(L.homedir(),".gemini"),l=_.join(s,"settings.json");try{await v.mkdir(s,{recursive:!0});let r={};try{let n=await v.readFile(l,"utf-8");r=JSON.parse(n)}catch{a.log("Creating new Gemini CLI settings file")}r.general||(r.general={}),r.general.previewFeatures||(r.general.previewFeatures=!0),r.model||(r.model={}),r.model.compressionThreshold!==.3&&(r.model.compressionThreshold=.3),r.skills||(r.skills={}),r.skills.enabled=!0,r.context||(r.context={}),r.context.fileName=["GEMINI.md","AGENTS.md"],await v.writeFile(l,JSON.stringify(r,null,2),"utf-8"),a.log("Configured Gemini CLI settings (preview features and compression threshold)")}catch(r){a.error("Failed to ensure Gemini CLI settings",{error:r.message})}},ne=s=>{s?.category===o.Skill&&s.type&&q(a,R(s.type))};async function le({config:s,netlify:l,persistSteps:r=void 0,sendSteps:n=void 0,aiGateway:m,cwd:M=g.cwd()}){let{accountType:G,prompt:re,modelVersionOverrides:A}=s,{model:c}=s;if(await ae(),m){let{token:t,url:e}=m;if(!t||!e)throw new Error("No token or url provided from AI Gateway");if(A?.gemini){let i=A?.gemini?.[G];if(i){if(!await m.isModelAvailableForProvider("gemini",i))throw new Error(`Model override '${i}' is not available for gemini provider`);c=i}}if(!c)!!f&&await m.isModelAvailableForProvider("gemini",f)?(c=f,a.log(`Using default model: ${f}`)):f&&a.log(`Default model ${f} is not available, proceeding without model specification`);else if(c&&!A?.gemini?.[G]&&!await m.isModelAvailableForProvider("gemini",c))throw new Error(`Model '${c}' is not available for gemini provider`);g.env.GEMINI_API_KEY=t,g.env.GOOGLE_GEMINI_BASE_URL=e}else if(!g.env.GEMINI_API_KEY)throw new Error("GEMINI_API_KEY is not provided");let C=[],x=[],T=[],U={},j=0,E=0,b,d,O=[Y(M,"gemini"),...c?["--model",c]:[],"--yolo","--skip-trust","--output-format","stream-json","-p",re],D=`${g.env.NVM_BIN}/node`;a.log(`Running ${D} ${O.join(" ")}`);let y=l.utils.run(D,O,{all:!0,env:g.env,cwd:M,idleTimeout:K});y.stdin?.end();let u=z(()=>{r?.({steps:C,duration:E}),n?.({steps:x,duration:E}),x=[]},250),$=(t,e)=>{t.id=j,j+=1,T.push(t),C.push(t),x.push(t),e||u.flush(),u(),e&&u.flush()};$({title:`Using ${P} with ${c||"default"}`,category:o.Environment},!0);let N=ie.createInterface({input:y.all});N.on("error",t=>{a.error("Readline interface error",{error:t.message,stack:t.stack})});let p="",te=()=>{p&&$({message:p.trim(),category:o.AgentMessage}),p=""};return N.on("line",t=>{let e=null;try{if(t.startsWith("[API Error")){let i=t.match(/\[api error: (.+?)]$/i)?.[1];e={type:"error",value:V(i,!1)?.error?.message||i||"Gemini encountered error"}}else e=JSON.parse(t)}catch{return}if(e)switch(["message","result"].includes(e.type)||te(),e.type){case"message":{e.role!=="user"&&e.content&&(p+=e.content);break}case"tool_use":{let i=ee[e.tool_name]?.name??e.tool_name,k=e.parameters?.file_path,F=k&&_.relative(M,k),B=e.parameters?.command,w=e.tool_name==="activate_skill"&&e.parameters?.name,h=[i,F&&`\`${F}\``,B&&`\`${B}\``].filter(Boolean).join(" ");if(w)h=`Use ${R(w)}`;else if(e.tool_name==="grep_search"){let{dir_path:I,pattern:S}=e.parameters||{};I&&S?h=`Search in \`${I}\` for \`${S}\``:I?h=`Search in \`${I}\``:S&&(h=`Search for \`${S}\``)}let oe={title:h,category:ee[e.tool_name]?.category,...w&&{type:w}};U[e.tool_id]=oe,u.flush();break}case"tool_result":{let i=U[e.tool_id];i&&(e.output&&(i.message=`\`\`\`
|
|
2
|
+
${e.output.trim()}
|
|
3
|
+
\`\`\``),$(i,!0),ne(i));break}case"result":{E=e.stats?.duration_ms,e.stats&&J(e.stats),e.status==="error"?d=e.error?.message:b=p.trim();break}case"error":{d=e.error;break}case"finished":break;case"init":break;default:{a.warn("Unhandled message type:",e.type);break}}}),await y.catch(t=>{({error:d,result:b}=se({catchError:t,runCmd:y,error:d,result:b,runnerName:"Gemini"}))}),N.close(),u.flush(),{steps:T,duration:E,result:await H({initialResult:b,agentName:P,hasError:!!d}),error:Q({error:d,agentName:P}),isRetryableError:X(d),isProviderUnavailableError:Z(d)}}var ye=async()=>{let s=_.join(L.homedir(),".gemini");await v.rm(s,{recursive:!0,force:!0});let l=_.join(L.homedir(),".agents","skills");await v.rm(l,{recursive:!0,force:!0})};export{ye as clean,le as default};
|
|
4
|
+
//# sourceMappingURL=gemini-OHQJC65Z.js.map
|
package/dist/index.d.ts
CHANGED
|
@@ -78,16 +78,7 @@ interface PipelineOptions {
|
|
|
78
78
|
cliPath?: string;
|
|
79
79
|
cwd?: string;
|
|
80
80
|
filter?: string;
|
|
81
|
-
tracing?: {
|
|
82
|
-
exporterUrl?: string;
|
|
83
|
-
traceparent?: string;
|
|
84
|
-
langfuse?: {
|
|
85
|
-
publicKey: string;
|
|
86
|
-
secretKey: string;
|
|
87
|
-
baseUrl: string;
|
|
88
|
-
};
|
|
89
|
-
};
|
|
90
81
|
}
|
|
91
|
-
declare const runPipeline: ({ config, apiToken, cliPath, cwd, filter
|
|
82
|
+
declare const runPipeline: ({ config, apiToken, cliPath, cwd, filter }: PipelineOptions) => Promise<void>;
|
|
92
83
|
|
|
93
84
|
export { type Context, type PipelineOptions, runPipeline };
|