@north-light/cli 0.3.681 → 0.3.682

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.
@@ -17,6 +17,10 @@ export declare const RUN_USER = "crtr";
17
17
  /** Where the image installs the recipe's pi packages: one pi agent dir of its own, not any app's. The start script (`sandbox-start.mjs`) links its
18
18
  * `npm`/`git` trees into, and merges its `packages` setting with, the agent dir of whichever app the node runs in. Keep the two in step. */
19
19
  export declare const RECIPE_PI_AGENT_DIR = "/var/lib/crtr/recipe-pi-agent";
20
+ /** Blaxel runs a slimming pass after the Docker build that deletes `make`, `gcc`, `g++`, headers and static libraries from the image, so a recipe's apk-installed
21
+ * toolchain compiled in the build stage and was gone in the running sandbox. `slim = false` in the uploaded `blaxel.toml` keeps them. */
22
+ export declare const BLAXEL_TOML_FILE = "blaxel.toml";
23
+ export declare const BLAXEL_TOML = "[build]\nslim = false\n";
20
24
  export declare const SETUP_SCRIPT_FILE = "recipe-setup.sh";
21
25
  export declare const REPOS_DIR = "repos";
22
26
  /** Where the image keeps the setup script's output, and its exit status when it failed. `sandbox-start.mjs` reads both (it derives them from `/work/.crtr`). */
@@ -1,6 +1,8 @@
1
- var Y=Object.defineProperty;var c=(t,r)=>Y(t,"name",{value:r,configurable:!0});import{spawn as K}from"node:child_process";import{constants as v,lstatSync as j,mkdirSync as q,readFileSync as z,readdirSync as H,readlinkSync as J,rmSync as W,writeFileSync as _}from"node:fs";import{join as E,relative as V}from"node:path";import{crc32 as Z,deflateRawSync as Q}from"node:zlib";import{BlaxelApiError as X}from"./client.js";const tt="public.ecr.aws/docker/library/node:24-alpine",et="ghcr.io/blaxel-ai/sandbox:latest",f="crtr",A="/var/lib/crtr/recipe-pi-agent",rt="1.1.0",b="recipe-setup.sh",L="repos",D="/work/.crtr/setup.log",P="/work/.crtr/setup-failed",B=c(t=>`'${t.replace(/'/g,"'\\''")}'`,"shellQuote"),nt=c(t=>(t??"").split(`
2
- `).map(r=>r.trim()).filter(r=>r!==""),"lines"),$=c((t,r)=>`RUN { ${r}; } >> ${D} 2>&1 || echo ${B(t)} "exited $?" >> ${P}`,"guarded");function st(t,r,i=!1){const o=nt(t.pi_packages),a=t.setup_script!==null&&t.setup_script.trim()!=="",n=[`FROM ${tt}`,"RUN apk add --no-cache bash git curl ripgrep",`COPY --from=${et} /sandbox-api /usr/local/bin/sandbox-api`,`RUN adduser -D -h /home/${f} -s /bin/sh ${f} && mkdir -p /work/.crtr ${A} && chown -R ${f} /work /var/lib/crtr`],e=[`${n[0]} AS build`,...i?["ARG NODE_AUTH_TOKEN"]:[],...n.slice(1),`RUN rm -f ${P} ${D}`,$("npm install -g pnpm","npm install -g pnpm && mkdir -p /var/lib/postgresql")];t.repositories.length>0&&e.push(`COPY --chown=${f} ${L}/ /work/`),o.length>0&&e.push($("npm install pi",`npm install -g @earendil-works/pi-coding-agent@${rt}`)),a&&e.push(`COPY ${b} /tmp/${b}`),e.push("WORKDIR /work");for(const s of o)e.push($(`pi install ${s}`,`HOME=/var/lib/crtr PI_CODING_AGENT_DIR=${A} pi install ${B(s)}`));a&&e.push($("setup script",`bash /tmp/${b}`)),e.push($("finalize",`echo ${Math.trunc(r)} > /work/.crtr/recipe-revision && chown -R ${f} /work /home/${f} /var/lib/crtr`)),e.push("",...n);for(const s of["/work",`/home/${f}`,"/var/lib/crtr"])e.push(`COPY --from=build --chown=${f}:${f} ${s} ${s}`);for(const s of["/usr/local","/usr","/etc","/lib"])e.push(`COPY --from=build ${s} ${s}`);return e.push("COPY --from=build /var/lib/postgresql /var/lib/postgresql"),e.push("RUN if getent passwd postgres >/dev/null; then chown -R postgres:postgres /var/lib/postgresql; fi"),i&&e.push(`RUN rm -f /work/.npmrc /home/${f}/.npmrc`),e.push(`USER ${f}`,"WORKDIR /work",'ENTRYPOINT ["/usr/local/bin/sandbox-api"]',""),e.join(`
3
- `)}c(st,"recipeDockerfile");const ot=c((t,r,i)=>new Promise((o,a)=>{const n=K("git",t,{cwd:i,env:{...process.env,...r,GIT_TERMINAL_PROMPT:"0"},stdio:["ignore","ignore","pipe"]});let e="";n.stderr.on("data",s=>{e+=s.toString()}),n.on("error",a),n.on("close",s=>{s===0?o():a(new Error(`git ${t[0]} failed (${s}): ${e.slice(0,300)}`))})}),"runGit");async function ht(t){const r=t.git??ot,i=t.packagesToken??null,o=t.cloneUrl??(n=>`https://github.com/${n}.git`);q(E(t.dir,L),{recursive:!0});const a=t.token===null?{}:{GIT_CONFIG_COUNT:"1",GIT_CONFIG_KEY_0:"http.https://github.com/.extraheader",GIT_CONFIG_VALUE_0:`AUTHORIZATION: basic ${Buffer.from(`x-access-token:${t.token}`).toString("base64")}`};for(const n of t.recipe.repositories){if(!/^[A-Za-z0-9._-]+$/.test(n.name)||n.name==="."||n.name==="..")throw new Error(`repository name ${JSON.stringify(n.name)} is not a plain directory name`);await r(["clone","--quiet","--branch",n.default_branch,o(n.github_full_name),E(L,n.name)],a,t.dir)}_(E(t.dir,"Dockerfile"),st(t.recipe,t.revision,i!==null)),i!==null&&_(E(t.dir,".env.build"),`NODE_AUTH_TOKEN=${i}
4
- `,{mode:384}),t.recipe.setup_script!==null&&t.recipe.setup_script.trim()!==""&&_(E(t.dir,b),t.recipe.setup_script.endsWith(`
1
+ var Y=Object.defineProperty;var c=(t,r)=>Y(t,"name",{value:r,configurable:!0});import{spawn as K}from"node:child_process";import{constants as v,lstatSync as j,mkdirSync as q,readFileSync as z,readdirSync as H,readlinkSync as J,rmSync as W,writeFileSync as b}from"node:fs";import{join as E,relative as X}from"node:path";import{crc32 as V,deflateRawSync as Z}from"node:zlib";import{BlaxelApiError as Q}from"./client.js";const tt="public.ecr.aws/docker/library/node:24-alpine",et="ghcr.io/blaxel-ai/sandbox:latest",f="crtr",A="/var/lib/crtr/recipe-pi-agent",rt="blaxel.toml",nt=`[build]
2
+ slim = false
3
+ `,st="1.1.0",x="recipe-setup.sh",L="repos",D="/work/.crtr/setup.log",P="/work/.crtr/setup-failed",B=c(t=>`'${t.replace(/'/g,"'\\''")}'`,"shellQuote"),ot=c(t=>(t??"").split(`
4
+ `).map(r=>r.trim()).filter(r=>r!==""),"lines"),I=c((t,r)=>`RUN { ${r}; } >> ${D} 2>&1 || echo ${B(t)} "exited $?" >> ${P}`,"guarded");function it(t,r,i=!1){const o=ot(t.pi_packages),a=t.setup_script!==null&&t.setup_script.trim()!=="",n=[`FROM ${tt}`,"RUN apk add --no-cache bash git curl ripgrep",`COPY --from=${et} /sandbox-api /usr/local/bin/sandbox-api`,`RUN adduser -D -h /home/${f} -s /bin/sh ${f} && mkdir -p /work/.crtr ${A} && chown -R ${f} /work /var/lib/crtr`],e=[`${n[0]} AS build`,...i?["ARG NODE_AUTH_TOKEN"]:[],...n.slice(1),`RUN rm -f ${P} ${D}`,I("npm install -g pnpm","npm install -g pnpm && mkdir -p /var/lib/postgresql")];t.repositories.length>0&&e.push(`COPY --chown=${f} ${L}/ /work/`),o.length>0&&e.push(I("npm install pi",`npm install -g @earendil-works/pi-coding-agent@${st}`)),a&&e.push(`COPY ${x} /tmp/${x}`),e.push("WORKDIR /work");for(const s of o)e.push(I(`pi install ${s}`,`HOME=/var/lib/crtr PI_CODING_AGENT_DIR=${A} pi install ${B(s)}`));a&&e.push(I("setup script",`bash /tmp/${x}`)),e.push(I("finalize",`echo ${Math.trunc(r)} > /work/.crtr/recipe-revision && chown -R ${f} /work /home/${f} /var/lib/crtr`)),e.push("",...n);for(const s of["/work",`/home/${f}`,"/var/lib/crtr"])e.push(`COPY --from=build --chown=${f}:${f} ${s} ${s}`);for(const s of["/usr/local","/usr","/etc","/lib"])e.push(`COPY --from=build ${s} ${s}`);return e.push("COPY --from=build /var/lib/postgresql /var/lib/postgresql"),e.push("RUN if getent passwd postgres >/dev/null; then chown -R postgres:postgres /var/lib/postgresql; fi"),i&&e.push(`RUN rm -f /work/.npmrc /home/${f}/.npmrc`),e.push(`USER ${f}`,"WORKDIR /work",'ENTRYPOINT ["/usr/local/bin/sandbox-api"]',""),e.join(`
5
+ `)}c(it,"recipeDockerfile");const at=c((t,r,i)=>new Promise((o,a)=>{const n=K("git",t,{cwd:i,env:{...process.env,...r,GIT_TERMINAL_PROMPT:"0"},stdio:["ignore","ignore","pipe"]});let e="";n.stderr.on("data",s=>{e+=s.toString()}),n.on("error",a),n.on("close",s=>{s===0?o():a(new Error(`git ${t[0]} failed (${s}): ${e.slice(0,300)}`))})}),"runGit");async function wt(t){const r=t.git??at,i=t.packagesToken??null,o=t.cloneUrl??(n=>`https://github.com/${n}.git`);q(E(t.dir,L),{recursive:!0});const a=t.token===null?{}:{GIT_CONFIG_COUNT:"1",GIT_CONFIG_KEY_0:"http.https://github.com/.extraheader",GIT_CONFIG_VALUE_0:`AUTHORIZATION: basic ${Buffer.from(`x-access-token:${t.token}`).toString("base64")}`};for(const n of t.recipe.repositories){if(!/^[A-Za-z0-9._-]+$/.test(n.name)||n.name==="."||n.name==="..")throw new Error(`repository name ${JSON.stringify(n.name)} is not a plain directory name`);await r(["clone","--quiet","--branch",n.default_branch,o(n.github_full_name),E(L,n.name)],a,t.dir)}b(E(t.dir,rt),nt),b(E(t.dir,"Dockerfile"),it(t.recipe,t.revision,i!==null)),i!==null&&b(E(t.dir,".env.build"),`NODE_AUTH_TOKEN=${i}
6
+ `,{mode:384}),t.recipe.setup_script!==null&&t.recipe.setup_script.trim()!==""&&b(E(t.dir,x),t.recipe.setup_script.endsWith(`
5
7
  `)?t.recipe.setup_script:`${t.recipe.setup_script}
6
- `)}c(ht,"prepareBuildDir");function C(t,r,i){for(const o of H(r).sort()){const a=E(r,o),n=j(a),e=V(t,a).split("\\").join("/");n.isDirectory()?C(t,a,i):n.isSymbolicLink()?i.push({name:e,data:Buffer.from(J(a)),mode:v.S_IFLNK|511}):n.isFile()&&i.push({name:e,data:z(a),mode:v.S_IFREG|n.mode&511})}}c(C,"walk");function it(t){const r=[];C(t,t,r);const i=[],o=[];let a=0;for(const s of r){const u=Buffer.from(s.name),g=Q(s.data),I=Z(s.data),p=Buffer.alloc(30);p.writeUInt32LE(67324752,0),p.writeUInt16LE(20,4),p.writeUInt16LE(2048,6),p.writeUInt16LE(8,8),p.writeUInt32LE(33,12),p.writeUInt32LE(I,14),p.writeUInt32LE(g.length,18),p.writeUInt32LE(s.data.length,22),p.writeUInt16LE(u.length,26),i.push(p,u,g);const l=Buffer.alloc(46);l.writeUInt32LE(33639248,0),l.writeUInt16LE(788,4),l.writeUInt16LE(20,6),l.writeUInt16LE(2048,8),l.writeUInt16LE(8,10),l.writeUInt32LE(33,14),l.writeUInt32LE(I,16),l.writeUInt32LE(g.length,20),l.writeUInt32LE(s.data.length,24),l.writeUInt16LE(u.length,28),l.writeUInt32LE(s.mode<<16>>>0,38),l.writeUInt32LE(a,42),o.push(l,u),a+=p.length+u.length+g.length}const n=Buffer.concat(o),e=Buffer.alloc(22);return e.writeUInt32LE(101010256,0),e.writeUInt16LE(r.length,8),e.writeUInt16LE(r.length,10),e.writeUInt32LE(n.length,12),e.writeUInt32LE(a,16),Buffer.concat([...i,n,e])}c(it,"zipDirectory");async function R(t,r,i,o,a=[]){const n=`${t.controlUrl??"https://api.blaxel.ai/v0"}${i}`,e=await(t.fetch??fetch)(n,{method:r,headers:{authorization:`Bearer ${t.apiKey}`,"x-blaxel-workspace":t.workspace,"content-type":"application/json"},...o===void 0?{}:{body:JSON.stringify(o)}}),s=await e.text();let u=null;if(s!=="")try{u=JSON.parse(s)}catch{u={raw:s}}if(!e.ok&&!a.includes(e.status))throw new X(e.status,null,`Blaxel ${r} ${n} failed (${e.status}): ${s.slice(0,300)}`);return{status:e.status,headers:e.headers,json:u}}c(R,"api");async function G(t,r){const{status:i,json:o}=await R(t,"GET",`/images/sandbox/${encodeURIComponent(r)}`,void 0,[404]);return i===404?null:o}c(G,"getImage");async function mt(t,r){await R(t,"DELETE",`/images/sandbox/${encodeURIComponent(r)}`,void 0,[404])}c(mt,"deleteImage");async function wt(t,r,i,o={}){const a=o.sleep??(h=>new Promise(d=>setTimeout(d,h))),n=o.now??Date.now,e=n(),s=await G(t,r),u=new Set((s?.spec?.tags??[]).map(h=>h.name)),g=c(h=>(h?.metadata?.events??[]).map(d=>Date.parse(d.time??"")).filter(d=>!Number.isNaN(d)),"eventTimes"),I=Math.max(-1/0,...g(s)),l=(await R(t,"POST","/images",{resourceType:"sandbox",name:r})).headers.get("x-blaxel-upload-url");if(l===null)throw new Error(`Blaxel gave no upload URL for image ${r}`);const U=await(t.fetch??fetch)(l,{method:"PUT",headers:{"content-type":"application/zip"},body:new Uint8Array(it(i))});if(!U.ok)throw new Error(`uploading the build context of image ${r} failed (${U.status}): ${(await U.text()).slice(0,300)}`);const F=e+(o.timeoutMs??20*6e4);let N=null;for(;;){const h=await G(t,r),d=h?.metadata?.status,k=g(h).filter(m=>m>I).sort((m,x)=>m-x);if(d==="BUILT"&&k.length>=2){N??=n();const m=(h?.spec?.tags??[]).filter(w=>w.name!==void 0),x=k[0],O=c(w=>Date.parse(w??"")>=x,"touchedSince"),T=m.filter(w=>!u.has(w.name)||O(w.createdAt)||O(w.updatedAt)),y=n()-N>=(o.tagGraceMs??6e4),S=(T.length>0?T:y?m:[]).sort((w,M)=>(M.updatedAt??"").localeCompare(w.updatedAt??""))[0]?.name;if(S!==void 0)return{ref:`sandbox/${r}:${S}`,buildMs:n()-e};if(y)throw new Error(`Blaxel built image ${r} but no tag appeared`)}if(d==="FAILED"||d==="TERMINATED"){const m=h?.metadata?.events??[];throw new Error(`building image ${r} ${d.toLowerCase()}: ${m[m.length-1]?.message??"no message"}`)}if(n()>F)throw new Error(`building image ${r} did not finish within ${o.timeoutMs??20*6e4} ms (last status ${d??"none"})`);await a(o.pollMs??3e3)}}c(wt,"buildImage");const gt=c(t=>`env-${t}`,"environmentImageName");function Et(t){W(t,{recursive:!0,force:!0})}c(Et,"removeBuildDir");export{tt as NODE_BASE_IMAGE,A as RECIPE_PI_AGENT_DIR,L as REPOS_DIR,f as RUN_USER,et as SANDBOX_API_IMAGE,P as SETUP_FAILED_FILE,D as SETUP_LOG_FILE,b as SETUP_SCRIPT_FILE,wt as buildImage,mt as deleteImage,gt as environmentImageName,G as getImage,ht as prepareBuildDir,st as recipeDockerfile,Et as removeBuildDir,it as zipDirectory};
8
+ `)}c(wt,"prepareBuildDir");function C(t,r,i){for(const o of H(r).sort()){const a=E(r,o),n=j(a),e=X(t,a).split("\\").join("/");n.isDirectory()?C(t,a,i):n.isSymbolicLink()?i.push({name:e,data:Buffer.from(J(a)),mode:v.S_IFLNK|511}):n.isFile()&&i.push({name:e,data:z(a),mode:v.S_IFREG|n.mode&511})}}c(C,"walk");function ct(t){const r=[];C(t,t,r);const i=[],o=[];let a=0;for(const s of r){const d=Buffer.from(s.name),g=Z(s.data),$=V(s.data),p=Buffer.alloc(30);p.writeUInt32LE(67324752,0),p.writeUInt16LE(20,4),p.writeUInt16LE(2048,6),p.writeUInt16LE(8,8),p.writeUInt32LE(33,12),p.writeUInt32LE($,14),p.writeUInt32LE(g.length,18),p.writeUInt32LE(s.data.length,22),p.writeUInt16LE(d.length,26),i.push(p,d,g);const l=Buffer.alloc(46);l.writeUInt32LE(33639248,0),l.writeUInt16LE(788,4),l.writeUInt16LE(20,6),l.writeUInt16LE(2048,8),l.writeUInt16LE(8,10),l.writeUInt32LE(33,14),l.writeUInt32LE($,16),l.writeUInt32LE(g.length,20),l.writeUInt32LE(s.data.length,24),l.writeUInt16LE(d.length,28),l.writeUInt32LE(s.mode<<16>>>0,38),l.writeUInt32LE(a,42),o.push(l,d),a+=p.length+d.length+g.length}const n=Buffer.concat(o),e=Buffer.alloc(22);return e.writeUInt32LE(101010256,0),e.writeUInt16LE(r.length,8),e.writeUInt16LE(r.length,10),e.writeUInt32LE(n.length,12),e.writeUInt32LE(a,16),Buffer.concat([...i,n,e])}c(ct,"zipDirectory");async function O(t,r,i,o,a=[]){const n=`${t.controlUrl??"https://api.blaxel.ai/v0"}${i}`,e=await(t.fetch??fetch)(n,{method:r,headers:{authorization:`Bearer ${t.apiKey}`,"x-blaxel-workspace":t.workspace,"content-type":"application/json"},...o===void 0?{}:{body:JSON.stringify(o)}}),s=await e.text();let d=null;if(s!=="")try{d=JSON.parse(s)}catch{d={raw:s}}if(!e.ok&&!a.includes(e.status))throw new Q(e.status,null,`Blaxel ${r} ${n} failed (${e.status}): ${s.slice(0,300)}`);return{status:e.status,headers:e.headers,json:d}}c(O,"api");async function G(t,r){const{status:i,json:o}=await O(t,"GET",`/images/sandbox/${encodeURIComponent(r)}`,void 0,[404]);return i===404?null:o}c(G,"getImage");async function gt(t,r){await O(t,"DELETE",`/images/sandbox/${encodeURIComponent(r)}`,void 0,[404])}c(gt,"deleteImage");async function Et(t,r,i,o={}){const a=o.sleep??(h=>new Promise(u=>setTimeout(u,h))),n=o.now??Date.now,e=n(),s=await G(t,r),d=new Set((s?.spec?.tags??[]).map(h=>h.name)),g=c(h=>(h?.metadata?.events??[]).map(u=>Date.parse(u.time??"")).filter(u=>!Number.isNaN(u)),"eventTimes"),$=Math.max(-1/0,...g(s)),l=(await O(t,"POST","/images",{resourceType:"sandbox",name:r})).headers.get("x-blaxel-upload-url");if(l===null)throw new Error(`Blaxel gave no upload URL for image ${r}`);const U=await(t.fetch??fetch)(l,{method:"PUT",headers:{"content-type":"application/zip"},body:new Uint8Array(ct(i))});if(!U.ok)throw new Error(`uploading the build context of image ${r} failed (${U.status}): ${(await U.text()).slice(0,300)}`);const M=e+(o.timeoutMs??20*6e4);let R=null;for(;;){const h=await G(t,r),u=h?.metadata?.status,N=g(h).filter(m=>m>$).sort((m,_)=>m-_);if(u==="BUILT"&&N.length>=2){R??=n();const m=(h?.spec?.tags??[]).filter(w=>w.name!==void 0),_=N[0],T=c(w=>Date.parse(w??"")>=_,"touchedSince"),k=m.filter(w=>!d.has(w.name)||T(w.createdAt)||T(w.updatedAt)),y=n()-R>=(o.tagGraceMs??6e4),S=(k.length>0?k:y?m:[]).sort((w,F)=>(F.updatedAt??"").localeCompare(w.updatedAt??""))[0]?.name;if(S!==void 0)return{ref:`sandbox/${r}:${S}`,buildMs:n()-e};if(y)throw new Error(`Blaxel built image ${r} but no tag appeared`)}if(u==="FAILED"||u==="TERMINATED"){const m=h?.metadata?.events??[];throw new Error(`building image ${r} ${u.toLowerCase()}: ${m[m.length-1]?.message??"no message"}`)}if(n()>M)throw new Error(`building image ${r} did not finish within ${o.timeoutMs??20*6e4} ms (last status ${u??"none"})`);await a(o.pollMs??3e3)}}c(Et,"buildImage");const It=c(t=>`env-${t}`,"environmentImageName");function $t(t){W(t,{recursive:!0,force:!0})}c($t,"removeBuildDir");export{nt as BLAXEL_TOML,rt as BLAXEL_TOML_FILE,tt as NODE_BASE_IMAGE,A as RECIPE_PI_AGENT_DIR,L as REPOS_DIR,f as RUN_USER,et as SANDBOX_API_IMAGE,P as SETUP_FAILED_FILE,D as SETUP_LOG_FILE,x as SETUP_SCRIPT_FILE,Et as buildImage,gt as deleteImage,It as environmentImageName,G as getImage,wt as prepareBuildDir,it as recipeDockerfile,$t as removeBuildDir,ct as zipDirectory};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@north-light/cli",
3
- "version": "0.3.681",
3
+ "version": "0.3.682",
4
4
  "description": "crtr — agent runtime with memory, plugins, and marketplaces",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -156,8 +156,8 @@
156
156
  },
157
157
  "license": "UNLICENSED",
158
158
  "dependencies": {
159
- "@north-light/identity": "0.3.681",
160
- "@north-light/plugin": "0.3.681",
159
+ "@north-light/identity": "0.3.682",
160
+ "@north-light/plugin": "0.3.682",
161
161
  "@earendil-works/chord": "1.5.2",
162
162
  "@earendil-works/pi-agent-core": "1.5.2",
163
163
  "@earendil-works/pi-ai": "1.5.2",
@@ -17,6 +17,10 @@ export const RUN_USER = 'crtr';
17
17
  /** Where the image installs the recipe's pi packages: one pi agent dir of its own, not any app's. The start script (`sandbox-start.mjs`) links its
18
18
  * `npm`/`git` trees into, and merges its `packages` setting with, the agent dir of whichever app the node runs in. Keep the two in step. */
19
19
  export const RECIPE_PI_AGENT_DIR = '/var/lib/crtr/recipe-pi-agent';
20
+ /** Blaxel runs a slimming pass after the Docker build that deletes `make`, `gcc`, `g++`, headers and static libraries from the image, so a recipe's apk-installed
21
+ * toolchain compiled in the build stage and was gone in the running sandbox. `slim = false` in the uploaded `blaxel.toml` keeps them. */
22
+ export const BLAXEL_TOML_FILE = 'blaxel.toml';
23
+ export const BLAXEL_TOML = '[build]\nslim = false\n';
20
24
  const PI_VERSION = '1.1.0';
21
25
  export const SETUP_SCRIPT_FILE = 'recipe-setup.sh';
22
26
  export const REPOS_DIR = 'repos';
@@ -97,6 +101,7 @@ export async function prepareBuildDir(input) {
97
101
  throw new Error(`repository name ${JSON.stringify(repo.name)} is not a plain directory name`);
98
102
  await git(['clone', '--quiet', '--branch', repo.default_branch, cloneUrl(repo.github_full_name), join(REPOS_DIR, repo.name)], auth, input.dir);
99
103
  }
104
+ writeFileSync(join(input.dir, BLAXEL_TOML_FILE), BLAXEL_TOML);
100
105
  writeFileSync(join(input.dir, 'Dockerfile'), recipeDockerfile(input.recipe, input.revision, packagesToken !== null));
101
106
  if (packagesToken !== null)
102
107
  writeFileSync(join(input.dir, '.env.build'), `NODE_AUTH_TOKEN=${packagesToken}\n`, { mode: 0o600 });
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@north-light/api",
3
- "version": "0.3.681",
3
+ "version": "0.3.682",
4
4
  "description": "Typed crtrd /v1 API contract — DTOs, route builders, the error contract, the CrtrClient, and the command-plugin manifest format. Zero runtime dependencies.",
5
5
  "type": "module",
6
6
  "main": "./dist/api/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@north-light/identity",
3
- "version": "0.3.681",
3
+ "version": "0.3.682",
4
4
  "description": "Northlight access-token verification and scope rules",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@north-light/plugin",
3
- "version": "0.3.681",
3
+ "version": "0.3.682",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -27,8 +27,8 @@
27
27
  "postpack": "node ../../scripts/pack-minify.mjs postpack packages/crouter-plugin"
28
28
  },
29
29
  "dependencies": {
30
- "@north-light/api": "0.3.681",
31
- "@north-light/identity": "0.3.681"
30
+ "@north-light/api": "0.3.682",
31
+ "@north-light/identity": "0.3.682"
32
32
  },
33
33
  "license": "UNLICENSED",
34
34
  "publishConfig": {
package/runtime.lock.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@north-light/cli",
3
- "version": "0.3.681",
3
+ "version": "0.3.682",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@north-light/cli",
9
- "version": "0.3.681",
9
+ "version": "0.3.682",
10
10
  "hasInstallScript": true,
11
11
  "license": "UNLICENSED",
12
12
  "workspaces": [
@@ -28,8 +28,8 @@
28
28
  "@milkdown/preset-gfm": "^7.22.3",
29
29
  "@milkdown/prose": "^7.22.3",
30
30
  "@milkdown/utils": "^7.22.3",
31
- "@north-light/identity": "0.3.681",
32
- "@north-light/plugin": "0.3.681",
31
+ "@north-light/identity": "0.3.682",
32
+ "@north-light/plugin": "0.3.682",
33
33
  "cron-parser": "^5.6.0",
34
34
  "esbuild": "0.28.2",
35
35
  "jose": "^6.2.12",
@@ -10667,17 +10667,17 @@
10667
10667
  },
10668
10668
  "packages/crouter-api": {
10669
10669
  "name": "@north-light/api",
10670
- "version": "0.3.681",
10670
+ "version": "0.3.682",
10671
10671
  "license": "UNLICENSED"
10672
10672
  },
10673
10673
  "packages/crouter-env-docker": {
10674
10674
  "name": "@north-light/env-docker",
10675
- "version": "0.3.681",
10675
+ "version": "0.3.682",
10676
10676
  "license": "UNLICENSED"
10677
10677
  },
10678
10678
  "packages/crouter-identity": {
10679
10679
  "name": "@north-light/identity",
10680
- "version": "0.3.681",
10680
+ "version": "0.3.682",
10681
10681
  "license": "UNLICENSED",
10682
10682
  "dependencies": {
10683
10683
  "jose": "^6.2.1"
@@ -10685,21 +10685,21 @@
10685
10685
  },
10686
10686
  "packages/crouter-plugin": {
10687
10687
  "name": "@north-light/plugin",
10688
- "version": "0.3.681",
10688
+ "version": "0.3.682",
10689
10689
  "license": "UNLICENSED",
10690
10690
  "dependencies": {
10691
- "@north-light/api": "0.3.681",
10692
- "@north-light/identity": "0.3.681"
10691
+ "@north-light/api": "0.3.682",
10692
+ "@north-light/identity": "0.3.682"
10693
10693
  }
10694
10694
  },
10695
10695
  "packages/crouter-sdk": {
10696
10696
  "name": "@north-light/sdk",
10697
- "version": "0.3.681",
10697
+ "version": "0.3.682",
10698
10698
  "license": "UNLICENSED",
10699
10699
  "dependencies": {
10700
- "@north-light/api": "0.3.681",
10701
- "@north-light/identity": "0.3.681",
10702
- "@north-light/plugin": "0.3.681",
10700
+ "@north-light/api": "0.3.682",
10701
+ "@north-light/identity": "0.3.682",
10702
+ "@north-light/plugin": "0.3.682",
10703
10703
  "jose": "^6.2.1"
10704
10704
  },
10705
10705
  "bin": {
@@ -520,7 +520,8 @@ async function start(env) {
520
520
  if (scopesFile) writeFileSync(scopesFile, JSON.stringify(launch.scopes ?? []));
521
521
  const models = launch.models;
522
522
  if (models) writeFileSync(join(agentDir, 'models.json'), `${JSON.stringify(models, null, 2)}\n`);
523
- writeFileSync(join(runDir, 'broker-launch.json'), JSON.stringify({ ...launch, argv }));
523
+ // The recipe's env names the control plane's homes (`/opt/crouter/runtime`, `/work/crtr`); the broker merges it into its own env, which would put them back in every tool the node runs. The sandbox's own homes win.
524
+ writeFileSync(join(runDir, 'broker-launch.json'), JSON.stringify({ ...launch, argv, env: { ...launch.env, CRTR_HOME: root, CRTR_RUNTIME_HOME: join(root, 'runtime') } }));
524
525
  const settingsPath = join(agentDir, 'settings.json');
525
526
  const builtin = join(releaseDir, 'dist', 'builtin-pi-packages', 'pi-crtr-extensions');
526
527
  let settings = {};