@rizom/ops 0.2.0-alpha.329 → 0.2.0-alpha.330
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/brains-ops.js +86 -91
- package/dist/index.js +8 -13
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -8,8 +8,12 @@ WORKDIR /app
|
|
|
8
8
|
|
|
9
9
|
RUN apt-get update && apt-get install -y --no-install-recommends \\
|
|
10
10
|
curl ca-certificates git tini \\
|
|
11
|
+
chromium-headless-shell fontconfig \\
|
|
12
|
+
fonts-freefont-ttf fonts-ipafont-gothic fonts-liberation \\
|
|
13
|
+
fonts-noto-color-emoji fonts-tlwg-loma-otf fonts-unifont fonts-wqy-zenhei \\
|
|
11
14
|
&& rm -rf /var/lib/apt/lists/*
|
|
12
15
|
|
|
16
|
+
ENV BUN_CHROME_PATH=/usr/bin/chromium-headless-shell
|
|
13
17
|
ENV XDG_DATA_HOME=/data
|
|
14
18
|
ENV XDG_CONFIG_HOME=/config
|
|
15
19
|
RUN mkdir -p /app/data /app/cache /app/brain-data && \\
|
|
@@ -27,28 +31,19 @@ CMD ["bun", "./node_modules/@rizom/brain/dist/brain.js", "start"]
|
|
|
27
31
|
FROM runtime AS standalone
|
|
28
32
|
COPY package.json ./package.json
|
|
29
33
|
RUN bun install --production --ignore-scripts
|
|
30
|
-
RUN bunx playwright-core install --with-deps chromium-headless-shell \\
|
|
31
|
-
&& rm -rf /var/lib/apt/lists/* /tmp/*
|
|
32
34
|
COPY . .
|
|
33
35
|
|
|
34
36
|
# --- fleet: install published brain at pinned version (ops deploy) ---
|
|
35
37
|
FROM runtime AS fleet
|
|
36
38
|
ARG BRAIN_VERSION
|
|
37
39
|
ARG SITE_PACKAGES
|
|
38
|
-
# playwright-core is also installed explicitly so the chromium install
|
|
39
|
-
# below resolves against an installed package rather than relying on
|
|
40
|
-
# transitive resolution from @rizom/brain. The brain bundle externalizes
|
|
41
|
-
# playwright-core, so a missing or mismatched install would fail at
|
|
42
|
-
# runtime rather than build time.
|
|
43
40
|
RUN test -n "$BRAIN_VERSION" \\
|
|
44
41
|
&& printf '{"name":"rover-pilot-runtime","private":true}\\n' > package.json \\
|
|
45
42
|
&& if [ -n "$SITE_PACKAGES" ]; then \\
|
|
46
|
-
bun add @rizom/brain@$BRAIN_VERSION
|
|
43
|
+
bun add @rizom/brain@$BRAIN_VERSION $SITE_PACKAGES; \\
|
|
47
44
|
else \\
|
|
48
|
-
bun add @rizom/brain@$BRAIN_VERSION
|
|
45
|
+
bun add @rizom/brain@$BRAIN_VERSION; \\
|
|
49
46
|
fi
|
|
50
|
-
RUN bunx playwright-core install --with-deps chromium-headless-shell \\
|
|
51
|
-
&& rm -rf /var/lib/apt/lists/* /tmp/*
|
|
52
47
|
`;var X_=()=>{};var tE=`service: __SERVICE_NAME__
|
|
53
48
|
image: <%= ENV['IMAGE_REPOSITORY'] %>
|
|
54
49
|
|
|
@@ -111,7 +106,7 @@ for host in "\${HOSTS[@]}"; do
|
|
|
111
106
|
scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null "$BRAIN_FILE" "\${SSH_USER}@\${host}:/opt/brain.yaml"
|
|
112
107
|
done
|
|
113
108
|
`}import{appendFileSync as Gse,readFileSync as eU}from"fs";function Xm(e,t){let n=[],i=new Set,r=t?.skipSections??new Set,o=!1,s=!1,a=!1;for(let c of e.split(/\r?\n/)){let l=c.trim();if(tU.test(l)){o=r.has(l),s=!1,a=!1;continue}if(o)continue;if(l.startsWith("#")){if(l.includes("@required"))s=!0;if(l.includes("@sensitive"))a=!0;continue}let u=l.match(/^([A-Z][A-Z0-9_]*)=/);if(!u?.[1]){s=!1,a=!1;continue}let f=u[1];if(!i.has(f))i.add(f),n.push({key:f,required:s,sensitive:a});s=!1,a=!1}return n}function Qm(e,t){return Xm(eU(e,"utf8"),t)}var tU;var nE=se(()=>{tU=/^# ---- .+ ----$/});import{existsSync as nU,readFileSync as rU}from"fs";import{homedir as iU}from"os";import{isAbsolute as oU,join as eh,resolve as sU}from"path";function Rn(e){let t={};for(let n of[eh(e,".env"),eh(e,".env.local")]){if(!nU(n))continue;let i=aU(rU(n,"utf8"));for(let[r,o]of Object.entries(i))t[r]=o}return t}function gt(e,t,n){return t[e]??n[e]}function zr(e,t){if(e.startsWith("~/"))return eh(process.env.HOME??iU(),e.slice(2));if(oU(e))return e;return sU(t,e)}function aU(e){let t={};for(let n of e.split(/\r?\n/)){let i=n.trim();if(i.length===0||i.startsWith("#"))continue;let r=n.match(/^\s*(?:export\s+)?([A-Z][A-Z0-9_]*)\s*=\s*(.*)\s*$/),o=r?.[1],s=r?.[2];if(!o||s===void 0)continue;t[o]=cU(s)}return t}function cU(e){if(e.length>=2&&e.startsWith("'")&&e.endsWith("'"))return e.slice(1,-1);if(e.length>=2&&e.startsWith('"')&&e.endsWith('"'))return e.slice(1,-1).replace(/\\n/g,`
|
|
114
|
-
`).replace(/\\r/g,"\r").replace(/\\t/g,"\t").replace(/\\"/g,'"').replace(/\\\\/g,"\\");return e}var th=()=>{};function sE(e,t,n){if(t===n)return!1;return t.includes(pU[e])}function aE(){return Q_}function cE(e){if(e.includes('LABEL ai.rizom.brain.watchdog="true"')&&e.includes("http://127.0.0.1:8080/health/live")&&e.includes('ENTRYPOINT ["/usr/bin/tini", "--"]')&&e.includes('CMD ["bun", "./node_modules/@rizom/brain/dist/brain.js", "start"]'))return!1;
|
|
109
|
+
`).replace(/\\r/g,"\r").replace(/\\t/g,"\t").replace(/\\"/g,'"').replace(/\\\\/g,"\\");return e}var th=()=>{};function sE(e,t,n){if(t===n)return!1;return t.includes(pU[e])}function aE(){return Q_}function cE(e){if(e.includes('LABEL ai.rizom.brain.watchdog="true"')&&e.includes("http://127.0.0.1:8080/health/live")&&e.includes('ENTRYPOINT ["/usr/bin/tini", "--"]')&&e.includes("BUN_CHROME_PATH=/usr/bin/chromium-headless-shell")&&e.includes('CMD ["bun", "./node_modules/@rizom/brain/dist/brain.js", "start"]'))return!1;let n=e.includes('CMD ["./node_modules/.bin/brain", "start"]')||e.includes('CMD ["bun", "./node_modules/@rizom/brain/dist/brain.js", "start"]'),i=e.includes("chromium-headless-shell");return n&&i&&["ARG BUN_VERSION=","FROM oven/bun:${BUN_VERSION}-slim AS runtime","FROM runtime AS standalone","FROM runtime AS fleet"].every((r)=>e.includes(r))}function du(e){return tE.replace("__SERVICE_NAME__",e.serviceName)}function Yo(e){return e.replace(/\nvolumes:\n(?: {2}- .*\n)+$/,`
|
|
115
110
|
volumes:
|
|
116
111
|
- __VOLUMES__
|
|
117
112
|
`)}function rE(e){return e.replace(/\n {4}# <% if ENV\['WWW_DOMAIN'\] && !ENV\['WWW_DOMAIN'\]\.empty\? %>\n {4}- <%= ENV\['WWW_DOMAIN'\] %>\n {4}# <% end %>/,"")}function lE(e,t,n=(i)=>i){let i=rE(n(e)),r=rE(n(du({serviceName:t}))),o=mU.every((c)=>i.includes(c)),s=r.replace("path: /health/ready","path: /health"),a=Yo(i);return i===s||!o&&(a===Yo(r)||a===Yo(s))}var oE,pU,mU;var zi=se(()=>{X_();eE();nE();th();oE=["install-health-watchdog.ts","provision-server.ts","update-dns.ts","validate-secrets.ts","write-kamal-secrets.ts","write-ssh-key.ts"],pU={"install-health-watchdog.ts":"/usr/local/sbin/brains-health-watchdog","provision-server.ts":'requireEnv("HCLOUD_TOKEN")',"update-dns.ts":'requireEnv("CF_API_TOKEN")',"validate-secrets.ts":"const requiredKeys = schema","write-kamal-secrets.ts":".kamal/secrets","write-ssh-key.ts":'requireEnv("KAMAL_SSH_PRIVATE_KEY")'};mU=["/opt/brain-runtime:/app/data","/opt/brain-state:/data","/opt/brain-config:/config","/opt/brain-dist:/app/dist"]});function hU(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function ja(){if(uE)return Lr;uE=1;function e(s){return typeof s>"u"||s===null}function t(s){return typeof s==="object"&&s!==null}function n(s){if(Array.isArray(s))return s;else if(e(s))return[];return[s]}function i(s,a){if(a){let c=Object.keys(a);for(let l=0,u=c.length;l<u;l+=1){let f=c[l];s[f]=a[f]}}return s}function r(s,a){let c="";for(let l=0;l<a;l+=1)c+=s;return c}function o(s){return s===0&&Number.NEGATIVE_INFINITY===1/s}return Lr.isNothing=e,Lr.isObject=t,Lr.toArray=n,Lr.repeat=r,Lr.isNegativeZero=o,Lr.extend=i,Lr}function Fa(){if(fE)return nh;fE=1;function e(n,i){let r="",o=n.reason||"(unknown reason)";if(!n.mark)return o;if(n.mark.name)r+='in "'+n.mark.name+'" ';if(r+="("+(n.mark.line+1)+":"+(n.mark.column+1)+")",!i&&n.mark.snippet)r+=`
|
|
@@ -724,7 +719,7 @@ printf 'REMOTE_ARTIFACT_DIR=%s\\n' "$remote_dir"
|
|
|
724
719
|
`),o}async function yB(e,t){let n=await ut(e),i=n.users.find((r)=>r.handle===t);if(!i)throw Error(`Unknown pilot user: ${t}`);return{pilot:n.pilot,user:i}}async function bB(e){let t=await Ose(ur(Rse(),"brains-ops-watchdog-smoke-")),n=ur(t,"id_ed25519"),i=ur(t,"known_hosts");try{let r=encodeURIComponent(`brain=${e.target.pilot.contentRepoPrefix}${e.target.user.handle}`),o=await e.fetchImpl(`https://api.hetzner.cloud/v1/servers?label_selector=${r}`,{headers:{Authorization:`Bearer ${e.environment.HCLOUD_TOKEN}`}});if(!o.ok)throw Error(`Hetzner server lookup failed with ${o.status}`);let s=Pse.parse(await o.json());if(s.servers.length!==1)throw Error(`Expected one smoke server, found ${s.servers.length}`);let a=s.servers[0];if(a?.status!=="running")throw Error("Smoke server is not running");await Da(n,zse(e.environment.KAMAL_SSH_PRIVATE_KEY),{mode:384}),await Cse(n,384);let c=await e.commandRunner("ssh-keyscan",["-T","10","-t","ed25519",a.public_net.ipv4.ip]);if(c.exitCode!==0||!c.stdout.trim())throw Error("Unable to resolve watchdog smoke SSH host key");return await Da(i,c.stdout,{mode:384}),{temporaryRoot:t,sshKeyPath:n,knownHostsPath:i,serverIp:a.public_net.ipv4.ip,commandRunner:e.commandRunner}}catch(r){throw await H_(t,{recursive:!0,force:!0}),r}}async function Z_(e,t,n){return e.commandRunner("ssh",[...xB(e),`root@${e.serverIp}`,"bash","-s","--",t,n],{stdin:K_()})}async function Nse(e,t,n){return e.commandRunner("scp",[...xB(e),"-r",`root@${e.serverIp}:${t}/.`,n])}function xB(e){return["-i",e.sshKeyPath,"-o","BatchMode=yes","-o","IdentitiesOnly=yes","-o","ConnectTimeout=10","-o","StrictHostKeyChecking=yes","-o",`UserKnownHostsFile=${e.knownHostsPath}`]}async function Dse(e){try{return await Tse(e),!0}catch{return!1}}async function Hm(e,t,n){await Promise.all([Da(ur(e,`${t}.stdout.log`),n.stdout),Da(ur(e,`${t}.stderr.log`),n.stderr)])}function zse(e){return`${e.replace(/\r\n/g,`
|
|
725
720
|
`).replace(/\\n/g,`
|
|
726
721
|
`).trimEnd()}
|
|
727
|
-
`}var mB,Pse;var Vm=se(async()=>{Ne();uB();Yn();su();await lB();mB=h.object({HCLOUD_TOKEN:h.string().min(1),KAMAL_SSH_PRIVATE_KEY:h.string().min(1)}),Pse=h.object({servers:h.array(h.object({status:h.string(),public_net:h.object({ipv4:h.object({ip:h.string().min(1)})})}))})});import{access as dT,chmod as jv,mkdir as td,readFile as mT,writeFile as pT}from"fs/promises";import{dirname as zF,join as As}from"path";import{fileURLToPath as LF}from"url";var fu={name:"@rizom/ops",version:"0.2.0-alpha.
|
|
722
|
+
`}var mB,Pse;var Vm=se(async()=>{Ne();uB();Yn();su();await lB();mB=h.object({HCLOUD_TOKEN:h.string().min(1),KAMAL_SSH_PRIVATE_KEY:h.string().min(1)}),Pse=h.object({servers:h.array(h.object({status:h.string(),public_net:h.object({ipv4:h.object({ip:h.string().min(1)})})}))})});import{access as dT,chmod as jv,mkdir as td,readFile as mT,writeFile as pT}from"fs/promises";import{dirname as zF,join as As}from"path";import{fileURLToPath as LF}from"url";var fu={name:"@rizom/ops",version:"0.2.0-alpha.330",description:"Operator CLI for managing private brain fleet registry repos",keywords:["brains","ops","cli","deploy","fleet","operator"],license:"AGPL-3.0-only",author:"Yeehaa <yeehaa@rizom.ai> (https://rizom.ai)",bin:{"brains-ops":"./dist/brains-ops.js"},bugs:"https://github.com/rizom-ai/brains/issues",dependencies:{"age-encryption":"^0.3.0",yaml:"^2.9.0"},devDependencies:{"@brains/deploy-support":"workspace:*","@brains/eslint-config":"workspace:*","@brains/profile":"workspace:*","@brains/site-composition":"workspace:*","@brains/test-utils":"workspace:*","@brains/typescript-config":"workspace:*","@brains/utils":"workspace:*","@types/bun":"^1.4.0",typescript:"^7.0.2"},engines:{bun:">=1.3.3"},exports:{".":{types:"./dist/index.d.ts",import:"./dist/index.js"},"./deploy":{types:"./dist/deploy.d.ts",import:"./dist/deploy.js",bun:"./dist/deploy.js"}},files:["dist","templates"],homepage:"https://github.com/rizom-ai/brains/tree/main/packages/brains-ops#readme",main:"./dist/index.js",publishConfig:{access:"public"},repository:{type:"git",url:"https://github.com/rizom-ai/brains.git",directory:"packages/brains-ops"},scripts:{build:"bun scripts/build.ts",lint:"eslint . --max-warnings 0","lint:fix":"eslint . --max-warnings 0 --fix",prepublishOnly:"bun scripts/build.ts",test:"bun run build && bun test --timeout 20000","test:smoke":"bun run build && RUN_SMOKE_TESTS=1 bun test --timeout 60000",typecheck:"tsc --noEmit"},type:"module",types:"./dist/index.d.ts"};zi();Cc();var BF=["pilot.yaml","package.json",".env.schema",".gitignore","cohorts/cohort-1.yaml","users/alice.yaml",".github/actions/varlock-env/action.yml",".github/workflows/build.yml",".github/workflows/deploy.yml",".github/workflows/directory-sync-stress.yml",".github/workflows/health-watchdog-smoke.yml",".github/workflows/reconcile.yml",".github/workflows/upgrade.yml","deploy/Dockerfile","deploy/kamal/deploy.yml","deploy/scripts/helpers.ts","deploy/scripts/install-health-watchdog.ts","deploy/scripts/provision-server.ts","deploy/scripts/update-dns.ts","deploy/scripts/write-ssh-key.ts","deploy/scripts/decrypt-user-secrets.ts","deploy/scripts/validate-secrets.ts","deploy/scripts/write-kamal-secrets.ts","deploy/scripts/resolve-user-config.ts","deploy/scripts/resolve-missing-images.ts","deploy/scripts/resolve-deploy-handles.ts","deploy/scripts/sync-content-repo.ts",".kamal/hooks/pre-deploy","docs/onboarding-checklist.md","docs/canonical-crossover-record.md","docs/operator-playbook.md","docs/user-onboarding.md","README.md"],Fv=new Set([".kamal/hooks/pre-deploy"]),UF=new Set(["cohorts/cohort-1.yaml","users/alice.yaml","docs/canonical-crossover-record.md"]),jF=LF(new URL("../templates/rover-pilot/",import.meta.url)),FF=[`service: rover
|
|
728
723
|
image: <%= ENV['IMAGE_REPOSITORY'] %>
|
|
729
724
|
|
|
730
725
|
servers:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rizom/ops",
|
|
3
|
-
"version": "0.2.0-alpha.
|
|
3
|
+
"version": "0.2.0-alpha.330",
|
|
4
4
|
"description": "Operator CLI for managing private brain fleet registry repos",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"brains",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"@brains/test-utils": "workspace:*",
|
|
29
29
|
"@brains/typescript-config": "workspace:*",
|
|
30
30
|
"@brains/utils": "workspace:*",
|
|
31
|
-
"@types/bun": "^1.
|
|
31
|
+
"@types/bun": "^1.4.0",
|
|
32
32
|
"typescript": "^7.0.2"
|
|
33
33
|
},
|
|
34
34
|
"engines": {
|