@yunuseon/kayra 0.22.1 → 0.22.3

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.
@@ -54,6 +54,8 @@
54
54
  - role: monitor
55
55
  become: true
56
56
  when: monitor is defined
57
+ vars:
58
+ monitor_page: true
57
59
 
58
60
  post_tasks:
59
61
  - name: Record which kayra set this server up
@@ -4,4 +4,4 @@ collections:
4
4
  - name: ansible.posix
5
5
  version: 2.2.2
6
6
  - name: community.docker
7
- version: 5.3.0
7
+ version: 5.4.0
@@ -5,7 +5,8 @@
5
5
  # monitor_endpoints and monitor_hosts) plus monitor.extra, and alerting through
6
6
  # the notifier's ntfy after three failures, again once it has recovered.
7
7
  # Watched names are pinned to their servers' addresses (extra_hosts), so home
8
- # names resolve through the tunnel from the edge as they do at home.
8
+ # names resolve through the tunnel from the edge as they do at home. On a
9
+ # platform server (monitor_page) its page is status.<domain>, behind the login.
9
10
  # =============================================================================
10
11
 
11
12
  - name: Check the monitor has a notifier and its tokens
@@ -9,9 +9,28 @@ services:
9
9
  volumes:
10
10
  - ./config:/config:ro
11
11
  mem_limit: 128m
12
+ {% if monitor_page | default(false) %}
13
+ # status.<domain>, for staff only: Traefik reaches it on platform-internal.
14
+ networks: [default, platform-internal]
15
+ labels:
16
+ - "traefik.enable=true"
17
+ - "traefik.docker.network=platform-internal"
18
+ - "traefik.http.routers.status.rule=Host(`status.{{ domain }}`)"
19
+ - "traefik.http.routers.status.entrypoints=websecure"
20
+ - "traefik.http.routers.status.tls.certresolver=le"
21
+ - "traefik.http.routers.status.middlewares=authelia@file"
22
+ - "traefik.http.services.status.loadbalancer.server.port=8080"
23
+ {% endif %}
12
24
  {% if monitor_hosts | length > 0 %}
13
25
  extra_hosts:
14
26
  {% for host, address in monitor_hosts | dictsort %}
15
27
  - "{{ host }}:{{ address }}"
16
28
  {% endfor %}
17
29
  {% endif %}
30
+ {% if monitor_page | default(false) %}
31
+
32
+ networks:
33
+ platform-internal:
34
+ name: platform-internal
35
+ external: true
36
+ {% endif %}
@@ -2,6 +2,6 @@
2
2
  `):z(``),Ct=(e,t)=>Object.freeze(Object.fromEntries(xt(e).map(e=>[e.name,St(t[e.name]??e.default)]))),wt=(e,t)=>Object.freeze(Object.fromEntries(xt(e).flatMap(e=>{let n=t[e.name];return e.type===`boolean`?z([[e.name,n===!0]]):z(typeof n!=`string`||n===``?[]:[[e.name,e.type===`array`?n.split(/\r?\n/):n]])}))),Tt=(e,t)=>Object.freeze(e.filter(e=>e.scope===`app`&&t.kind===`platform`||e.scope===`server`&&(t.commands.some(t=>t===e.name)||e.name===`ssh`||e.name===`ssh.exec`||e.name===`hosts`&&t.target===`multipass`))),Et=(e,t)=>{let n=t.toLowerCase().replace(/\s+/g,``);if(n===``)return z(0);let r=e.toLowerCase(),i=Array.from(n).reduce((e,t)=>{if(e===void 0)return;let n=r.indexOf(t,e.at);return n===-1?void 0:{at:n+1,gaps:e.gaps+(e.first===-1?0:n-e.at),first:e.first===-1?n:e.first}},{at:0,gaps:0,first:-1});return i===void 0?void 0:i.gaps*2+i.first+(r.startsWith(n)?-10:0)},Dt=(e,t)=>Object.freeze(e.flatMap(e=>{let n=Et(`${e.label} ${e.hint}`,t);return Object.freeze(n===void 0?[]:[{choice:e,scored:n}])}).toSorted((e,t)=>e.scored-t.scored).map(e=>e.choice)),Ot=e=>e,kt=async(e,t)=>e.ok?z({ok:!0,value:Ot(await t(e))}):z({ok:!1,failure:{status:e.status,message:(await e.text()).trim()}}),At=async e=>{try{return await e()}catch{return z({ok:!1,failure:{status:0,message:`Cannot reach kayra. Check that kayra serve is still running.`}})}},jt=e=>At(()=>fetch(e).then(e=>kt(e,e=>e.json()))),Mt=(e,t)=>At(async()=>kt(await fetch(e,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)}),async e=>e.status===204?void 0:e.json())),Nt=(e,t)=>Mt(`/api/operations/${e.name}/preview`,{input:e.input,options:t}),Pt=(e,t,n)=>Mt(`/api/operations/${e.name}`,{input:e.input,options:t,...n===void 0?{}:{confirm:n}}),Ft=(e,t={})=>Mt(`/api/operations/${e}`,{input:t}),It=(e,t)=>Mt(`/api/runs/${encodeURIComponent(e)}/answers`,{text:t}),Lt=e=>Mt(`/api/runs/${encodeURIComponent(e)}/cancel`,{}),Rt=(e,t)=>Mt(`/api/sessions/${encodeURIComponent(e)}/input`,{text:t}),zt=e=>At(async()=>kt(await fetch(`/api/sessions/${encodeURIComponent(e)}`,{method:`DELETE`}),()=>Promise.resolve(void 0))),Bt=()=>jt(`/api/runs`),Vt=(e,t,n,r,i)=>{let a=new AbortController;return(async()=>{let n=await fetch(e,{signal:a.signal,...r===void 0?{}:{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(r)}});if(!n.ok){i?.({status:n.status,message:(await n.text()).trim()});return}if(n.body===null)throw Error(`No stream`);let o=n.body.getReader(),s=new TextDecoder,c={text:``},l=async()=>{let e=await o.read();if(e.done)return;let n=(c.text+s.decode(e.value,{stream:!0})).split(`
3
3
 
4
4
  `);c.text=n.pop()??``,n.forEach(e=>{e.startsWith(`data: `)&&t(Ot(JSON.parse(e.slice(6))))}),await l()};await l()})().catch(()=>{a.signal.aborted||i?.({status:0,message:`The connection to kayra was interrupted.`})}).finally(n),()=>{a.abort()}},Ht=/^[A-Za-z0-9._-]+$/,Ut=e=>{let t=e.split(`/`).filter(e=>e!==``).map(decodeURIComponent);if(!t.every(e=>Ht.test(e)))return z({page:`missing`,path:e});let[n,r,i,a]=t;return n===void 0?z({page:`fleet`}):n===`runs`&&r===void 0?z({page:`runs`}):n===`runs`&&r!==void 0&&i===void 0?z({page:`run`,id:r}):n===`sessions`&&r!==void 0&&i===void 0?z({page:`session`,id:r}):n===`validate`&&r===void 0?z({page:`validate`}):n===`servers`&&r!==void 0&&i===void 0?z({page:`server`,server:r}):n===`servers`&&r!==void 0&&i===`apps`&&a!==void 0&&t.length===4?z({page:`app`,server:r,app:a}):z({page:`missing`,path:e})},Wt=e=>{switch(e.page){case`fleet`:return`/`;case`server`:return`/servers/${encodeURIComponent(e.server)}`;case`app`:return`/servers/${encodeURIComponent(e.server)}/apps/${encodeURIComponent(e.app)}`;case`runs`:return`/runs`;case`run`:return`/runs/${encodeURIComponent(e.id)}`;case`session`:return`/sessions/${encodeURIComponent(e.id)}`;case`validate`:return`/validate`;case`missing`:return e.path}},Gt=e=>{let t=z({label:`servers`,to:{page:`fleet`}}),n=z({label:`runs`,to:{page:`runs`}}),r=e=>e.split(`-`).at(-1)??e;switch(e.page){case`fleet`:return z([{label:`overview`}]);case`server`:return z([t,{label:e.server}]);case`app`:return z([t,{label:e.server,to:{page:`server`,server:e.server}},{label:e.app}]);case`runs`:return z([{label:`runs`}]);case`run`:return z([n,{label:r(e.id)}]);case`session`:return z([n,{label:`session ${r(e.id)}`}]);case`validate`:return z([{label:`validate`}]);case`missing`:return z([{label:e.path}])}},Kt=`kayra.theme`,qt=(e,t)=>z(e===`dark`||e===`light`?e:t?`dark`:`light`),B=R(Ut(location.pathname)),Jt=e=>{history.pushState(null,``,Wt(e)),B.value=e,scrollTo({top:0})};addEventListener(`popstate`,()=>{B.value=Ut(location.pathname)});var V=R({state:`loading`}),H=R({state:`loading`}),Yt=async()=>{let e=await jt(`/api/operations`);H.value=e.ok?{state:`ready`,value:e.value}:{state:`failed`,failure:e.failure}},U=R({value:void 0,live:!1}),Xt=R({state:`loading`}),Zt=async()=>{let e=await jt(`/api/fleet`);V.value=e.ok?{state:`ready`,value:e.value}:{state:`failed`,failure:e.failure}},Qt=()=>{U.value={value:U.value.value,live:!0},Vt(`/api/operations/status`,e=>{U.value={value:e,live:!0}},()=>{U.value={value:U.value.value,live:!1}},{input:{}})},$t=async()=>{Xt.value={state:`loading`};let e=await Ft(`validate`);Xt.value=e.ok?{state:`ready`,value:e.value}:{state:`failed`,failure:e.failure}},W=R({state:`loading`}),en=async()=>{let e=await Bt();e.ok?W.value={state:`ready`,value:e.value}:W.value.state!==`ready`&&(W.value={state:`failed`,failure:e.failure})},tn=R(Date.now()),nn=()=>{en();let e=setInterval(()=>{tn.value=Date.now(),en()},3e3);return()=>{clearInterval(e)}},rn=()=>{try{return localStorage.getItem(Kt)}catch{return null}},an=matchMedia(`(prefers-color-scheme: dark)`),on=R(qt(rn(),an.matches));it(()=>{document.documentElement.setAttribute(`data-theme`,on.value)}),an.addEventListener(`change`,e=>{rn()===null&&(on.value=e.matches?`dark`:`light`)});var sn=()=>{on.value=on.value===`dark`?`light`:`dark`;try{localStorage.setItem(Kt,on.value)}catch{}},cn=e=>e===null?``:` · ${String(e)} ms`,ln={pending:`asking`,open:`open`,answered:`answered`,refused:`refused`,"no-answer":`no answer`,unreachable:`unreachable`,"unknown-host":`unknown host`,"bad-certificate":`bad certificate`,failed:`failed`,skipped:`not asked`},un=e=>{let{state:t,address:n,reason:r}=e.machine;switch(t){case`pending`:return z({text:`asking OpenTofu`,tone:`waiting`});case`found`:return z({text:n??`an address OpenTofu does not give`,tone:n===null?`warn`:`strong`});case`not-provisioned`:return z({text:`not provisioned`,tone:`muted`});case`no-machine`:return z({text:`no machine in its state`,tone:`muted`});case`unreadable`:return z({text:`state unreadable`,tone:`bad`,...r===null?{}:{title:r}})}},dn=e=>{let{state:t,error:n}=e.ssh;switch(t){case`pending`:return z({text:`connecting`,tone:`waiting`});case`open`:return z({text:`port ${String(e.ssh.port)} open${cn(e.ssh.ms)}`,tone:`ok`});case`refused`:return z({text:`off (refused)`,tone:`warn`,title:`Nothing listens: SSH may be on only on demand.`});case`skipped`:return z({text:`not asked`,tone:`muted`});case`answered`:case`no-answer`:case`unreachable`:case`unknown-host`:case`bad-certificate`:case`failed`:return z({text:ln[t],tone:`bad`,...n===null?{}:{title:n}})}},fn=e=>{let{https:t}=e;if(t!==null)switch(t.state){case`pending`:return z({text:`asking`,tone:`waiting`});case`answered`:return z({text:`HTTP ${String(t.status??`?`)}${cn(t.ms)}`,tone:t.status!==null&&t.status<400?`ok`:`bad`});case`skipped`:return z({text:`not asked`,tone:`muted`});case`open`:case`refused`:case`no-answer`:case`unreachable`:case`unknown-host`:case`bad-certificate`:case`failed`:return z({text:ln[t.state],tone:`bad`,...t.error===null?{}:{title:t.error}})}},pn=e=>{let{state:t,pin:n,version:r,error:i}=e.kayra,a=`This fleet pins kayra ${n}: a setup records it.`;switch(t){case`pending`:return z({text:`asking`,tone:`waiting`});case`recorded`:return z(r===n?{text:n,tone:`ok`}:{text:`${r??`?`} → ${n}`,tone:`warn`,title:a});case`unrecorded`:return z({text:`unrecorded → ${n}`,tone:`warn`,title:`Set up by a kayra that recorded no version. ${a}`});case`unreadable`:return z({text:`unreadable`,tone:`bad`,...i===null?{}:{title:i}});case`skipped`:return z({text:`not asked`,tone:`muted`})}},mn=e=>{if(e===void 0)return z(`waiting`);let t=[un(e),dn(e),fn(e)].flatMap(e=>Object.freeze(e===void 0?[]:[e.tone]));return t.includes(`waiting`)?z(`waiting`):t.includes(`bad`)?z(`bad`):t.includes(`warn`)?z(`warn`):t.includes(`ok`)?z(`ok`):z(`muted`)},hn=e=>{let t=mn(e);return t===`waiting`?z({word:`ASKING`,tone:t}):t===`bad`?z({word:`FAIL`,tone:t}):t===`warn`?z({word:`WARN`,tone:t}):e!==void 0&&pn(e).tone===`warn`?z({word:`BEHIND`,tone:`warn`}):z(t===`ok`?{word:`OK`,tone:t}:{word:`--`,tone:t})},gn=e=>{let t=Math.max(0,6-e.length);return`[${` `.repeat(Math.floor(t/2))}${e}${` `.repeat(Math.ceil(t/2))}]`},_n={ok:`●`,warn:`▲`,bad:`✕`,waiting:`◌`,active:`◐`,muted:`○`,strong:`●`,accent:`◆`},vn=0;Array.isArray;function G(e,n,r,i,a,o){n||={};var s,c,l=n;if(`ref`in l)for(c in l={},n)c==`ref`?s=n[c]:l[c]=n[c];var u={type:e,props:l,key:r,ref:s,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--vn,__i:-1,__u:0,__source:a,__self:o};if(typeof e==`function`&&(s=e.defaultProps))for(c in s)l[c]===void 0&&(l[c]=s[c]);return t.vnode&&t.vnode(u),u}var yn=(e,t)=>{if(typeof e==`string`)return e;let n=e.tone===void 0?void 0:`tone-${e.tone}`;return e.href===void 0?G(`span`,{class:n,children:e.text},t):G(`a`,{class:n,href:e.href,target:`_blank`,rel:`noreferrer`,children:e.text},t)},bn=({text:e})=>G(C,{children:(typeof e==`string`?[e]:e).map(yn)}),xn=({lines:e})=>G(`div`,{class:`lines`,children:e.map((e,t)=>G(`div`,{children:G(bn,{text:e})},t))}),K=({tone:e,label:t})=>G(`span`,{class:`dot dot-${e}`,title:t,"aria-label":t,role:t===void 0?void 0:`img`,"aria-hidden":t===void 0||void 0,children:_n[e]}),Sn=({word:e,tone:t})=>G(`span`,{class:`tag tone-${t}${t===`waiting`||t===`active`?` pulse`:``}`,children:gn(e)}),Cn={reads:`read only`,changes:`changes`,destroys:`destroys`},wn=({effect:e})=>G(`span`,{class:`badge badge-${e}`,children:Cn[e]}),Tn=({children:e,tone:t})=>G(`span`,{class:`pill${t===void 0?``:` pill-${t}`}`,children:e}),En=({label:e,cell:t})=>t===void 0?null:G(`div`,{class:`fact`,children:[G(`dt`,{children:e}),G(`dd`,{title:t.title,children:[G(K,{tone:t.tone}),G(`span`,{class:t.tone===`waiting`?`tone-muted`:`tone-${t.tone}`,children:t.text})]})]}),q=({failure:e})=>G(`div`,{class:`problem`,role:`alert`,children:[G(`strong`,{children:e.status===0?`Connection problem`:`kayra answered ${String(e.status)}`}),G(`pre`,{children:e.message})]}),J=({what:e})=>G(`div`,{class:`waiting`,children:[G(`span`,{class:`spinner`,"aria-hidden":`true`}),` `,e]}),Y=({kicker:e,title:t,tag:n,sub:r,children:i})=>G(`header`,{class:`page-header`,children:[G(`div`,{class:`page-title`,children:[e===void 0?null:G(`div`,{class:`kicker`,children:e}),G(`div`,{class:`title-row`,children:[G(`h1`,{children:t}),n]}),r===void 0?null:G(`div`,{class:`sub`,children:r})]}),i===void 0?null:G(`div`,{class:`actions`,children:i})]}),X=({title:e,meta:t,aside:n,children:r,class:i})=>G(`section`,{class:i===void 0?`section`:`section ${i}`,"aria-label":e,children:[G(`div`,{class:`section-head`,children:[G(`h2`,{children:e}),G(`span`,{class:`rule`,"aria-hidden":`true`}),t===void 0?null:G(`span`,{class:`meta`,children:t}),n]}),r]}),Dn=({initial:e,choose:t,close:n})=>{let[r,i]=N(e===``?`.`:e),[a,o]=N(void 0);return P(()=>{let e={current:!1};return o(void 0),jt(`/api/directories?path=${encodeURIComponent(r)}`).then(t=>{e.current||o(t)}),()=>{e.current=!0}},[r]),G(`section`,{class:`directory-picker`,"aria-label":`Choose a local directory`,children:[G(`div`,{class:`buttons`,children:[G(`strong`,{children:`Choose a local directory`}),G(`button`,{type:`button`,class:`button small`,onClick:n,children:`Close picker`})]}),a===void 0?G(J,{what:`Reading directories`}):a.ok?G(C,{children:[G(`code`,{class:`directory-path`,children:a.value.path}),G(`ul`,{class:`directory-list`,children:[a.value.parent===a.value.path?null:G(`li`,{children:G(`button`,{type:`button`,onClick:()=>{i(a.value.parent)},children:`↑ Parent directory`})}),a.value.directories.map(e=>G(`li`,{children:G(`button`,{type:`button`,onClick:()=>{i(e.path)},children:[`▸ `,e.name]})},e.path))]}),G(`button`,{type:`button`,class:`button`,onClick:()=>{t(a.value.path)},children:`Use this directory`})]}):G(q,{failure:a.failure})]})},On=R(void 0),Z=(e,t={})=>{On.value={name:e,input:t}},kn=e=>{Z(e.name,Object.fromEntries(Object.entries(e).filter(([e])=>e!==`name`)))},An=()=>{On.value=void 0},jn={guard:{glyph:`◆`,tone:`tone-warn`},check:{glyph:`◇`,tone:`tone-muted`},confirm:{glyph:`?`,tone:`tone-bad`},run:{glyph:`❯`,tone:`tone-accent`},session:{glyph:`>`,tone:`tone-accent`},note:{glyph:`·`,tone:`tone-muted`}},Mn=({step:e})=>{let t=jn[e.kind]??{glyph:`·`,tone:`tone-muted`};return G(C,{children:[e.opens===void 0?null:G(`li`,{class:`part`,children:e.opens}),G(`li`,{class:`plan-step`,children:[G(`span`,{class:`plan-index`,children:e.index+1}),G(`span`,{class:t.tone,"aria-hidden":`true`,children:t.glyph}),G(`div`,{children:[G(`span`,{children:e.title}),G(`span`,{class:`plan-kind`,children:e.kind}),e.command===void 0?null:G(`code`,{class:`plan-command`,children:e.command})]})]})]})},Nn=()=>G(`button`,{type:`button`,class:`iconbtn`,onClick:An,"aria-label":`Close`,children:G(`svg`,{width:`14`,height:`14`,viewBox:`0 0 14 14`,"aria-hidden":`true`,fill:`none`,stroke:`currentColor`,"stroke-width":`1.5`,"stroke-linecap":`round`,children:G(`path`,{d:`M3 3l8 8M11 3l-8 8`})})}),Pn=({field:e,value:t,change:n,server:r})=>{let[i,a]=N(!1),o=V.value,s=o.state===`ready`?o.value.servers:[],c=typeof t==`string`?t:``,l=`operation-${e.name}`;return e.type===`boolean`?G(`label`,{class:`toggle`,children:[G(`input`,{type:`checkbox`,checked:t===!0,onChange:e=>{n(e.currentTarget.checked)}}),e.description||e.name]}):G(`div`,{class:`operation-field`,children:[G(`label`,{for:l,children:[e.name,e.required?``:` (optional)`]}),e.name===`server`||e.choices.length>0?G(`select`,{id:l,required:e.required,value:c,onChange:e=>{n(e.currentTarget.value)},children:[G(`option`,{value:``,children:e.required?`Choose…`:`All servers`}),(e.name===`server`?s.map(e=>e.name):e.choices).map(e=>G(`option`,{value:e,children:e},e))]}):e.type===`array`?G(`textarea`,{id:l,rows:3,value:c,required:e.required,placeholder:`One item per line`,onInput:e=>{n(e.currentTarget.value)}}):G(`div`,{class:`inline`,children:[G(`input`,{id:l,value:c,required:e.required,minLength:e.minLength,pattern:e.pattern,list:e.name===`app`?`operation-apps`:void 0,spellcheck:!1,onInput:e=>{n(e.currentTarget.value)}}),e.name===`dir`?G(`button`,{type:`button`,class:`button`,onClick:()=>{a(!i)},children:`Browse…`}):null]}),e.name===`app`?G(`datalist`,{id:`operation-apps`,children:s.find(e=>e.name===r)?.apps.map(e=>G(`option`,{value:e},e))}):null,e.description===``?null:G(`span`,{class:`hint`,children:e.description}),e.type===`array`?G(`span`,{class:`hint`,children:[`One `,e.name===`command`?`argument`:`item`,` per line. Spaces within a line are preserved.`]}):null,i?G(Dn,{initial:c,close:()=>{a(!1)},choose:e=>{n(e),a(!1)}}):null]})},Fn=({info:e,seed:t,options:n,submit:r})=>{let[i,a]=N(()=>Ct(e.input,t.input)),[o,s]=N(n.verbose??!1),[c,l]=N(n.dryRun??!1),u=e.kind===`plan`||e.kind===`session`,d=xt(e.input),f=d.some(e=>!e.supported);return G(`form`,{onSubmit:t=>{t.preventDefault(),r({draft:{name:e.name,input:wt(e.input,i)},options:{verbose:o,dryRun:c}})},children:[G(`div`,{class:`sheet-body operation-fields`,children:[d.map(e=>G(Pn,{field:e,value:i[e.name]??``,server:i.server,change:t=>{a({...i,[e.name]:t})}},e.name)),f?G(`p`,{role:`alert`,children:`This operation has an unsupported input. Update the UI before running it.`}):null,u?G(`fieldset`,{class:`run-options`,children:[G(`legend`,{children:`Run options`}),G(`label`,{class:`toggle`,children:[G(`input`,{type:`checkbox`,checked:o,onChange:e=>{s(e.currentTarget.checked)}}),`Verbose output`]}),G(`label`,{class:`toggle`,children:[G(`input`,{type:`checkbox`,checked:c,onChange:e=>{l(e.currentTarget.checked)}}),`Dry run — preview only`]})]}):null]}),G(`div`,{class:`sheet-foot`,children:G(`div`,{class:`buttons`,children:[G(`button`,{type:`button`,class:`button`,onClick:An,children:[`cancel `,G(`kbd`,{children:`esc`})]}),G(`span`,{class:`spacer`}),G(`button`,{type:`submit`,class:`button primary`,disabled:f,children:u?`show the plan`:e.kind===`stream`?`follow it`:`ask`})]})})]})},In=e=>{if(H.value.state===`ready`&&H.value.value.some(t=>t.name===e.name&&t.local))return;let t=V.value,n=t.state===`ready`?t.value.servers.find(t=>t.name===e.input.server):void 0;return n?.target===`multipass`?void 0:n?.name},Ln=({prepared:e,effect:t,back:n})=>{let{draft:r,options:i}=e,[a,o]=N(void 0),[s,c]=N(``),[l,u]=N(void 0);if(P(()=>{Nt(r,i).then(o)},[e]),a===void 0)return G(`div`,{class:`sheet-body`,children:G(J,{what:`Planning`})});if(!a.ok)return G(`div`,{class:`sheet-body`,children:[G(q,{failure:a.failure}),G(`button`,{class:`button`,onClick:n,children:`Edit inputs`})]});let{invocation:d,steps:f,changes:p}=a.value,m=p&&!i.dryRun?In(r):void 0,h=m===void 0||s===m,g=m===void 0||s===``?void 0:h?{text:`✓ matches`,tone:`tone-ok`}:m.startsWith(s)?{text:`keep going`,tone:`tone-muted`}:{text:`✕ not ${m}`,tone:`tone-bad`},_=async()=>{u(`starting`);let e=await Pt(r,i,m===void 0?void 0:s);e.ok?(An(),Jt(`session`in e.value?{page:`session`,id:e.value.session}:{page:`run`,id:e.value.run})):u(e.failure)};return G(C,{children:[G(`div`,{class:`sheet-body`,children:[G(`div`,{children:[G(`code`,{class:`command`,children:d.command}),G(`p`,{class:`sub`,children:[d.about.join(` · `),d.about.length===0?``:` · `,p?`changes things`:`reads only`,i.verbose?` · verbose`:``,i.dryRun?` · dry run, nothing changes`:``]})]}),G(`div`,{class:`plan-head`,children:[G(`span`,{children:`the plan`}),G(`span`,{class:`rule`,"aria-hidden":`true`}),G(`span`,{children:[f.length,` steps`]})]}),G(`ol`,{class:`plan`,children:f.map(e=>G(Mn,{step:e},e.index))})]}),G(`form`,{class:`sheet-foot`,onSubmit:e=>{e.preventDefault(),h&&!i.dryRun&&_()},children:[m===void 0?null:G(`div`,{class:`confirm`,children:[G(`label`,{for:`operation-confirm`,children:[`Type `,G(`strong`,{children:m}),` to approve. The server checks the name too.`]}),G(`div`,{class:`field`,children:[G(`span`,{class:`prompt`,"aria-hidden":`true`,children:`❯`}),G(`input`,{id:`operation-confirm`,value:s,onInput:e=>{c(e.currentTarget.value)},placeholder:m,autoComplete:`off`,spellcheck:!1}),g===void 0?null:G(`span`,{class:`match ${g.tone}`,children:g.text})]})]}),l===void 0||l===`starting`?null:G(q,{failure:l}),G(`div`,{class:`buttons`,children:[G(`button`,{type:`button`,class:`button`,onClick:n,disabled:l===`starting`,children:`edit inputs`}),G(`span`,{class:`spacer`}),i.dryRun?G(`button`,{type:`button`,class:`button primary`,onClick:An,children:`done`}):G(`button`,{type:`submit`,class:t===`destroys`?`button danger`:`button primary`,disabled:!h||l===`starting`,children:l===`starting`?`starting…`:m===void 0?r.name===`ssh`?`open terminal`:`run`:`approve · ${d.command}`})]})]})]})},Rn=({prepared:e,info:t,back:n})=>{let[r,i]=N(void 0),[a,o]=N(t.kind===`stream`);return P(()=>{let n={current:!0};return t.kind===`stream`?Vt(`/api/operations/${t.name}`,e=>{i({ok:!0,value:e})},()=>{o(!1)},{input:e.draft.input},e=>{i({ok:!1,failure:e})}):(Ft(t.name,e.draft.input).then(e=>{n.current&&i(e)}),()=>{n.current=!1})},[e]),G(C,{children:[G(`div`,{class:`sheet-body`,children:[r===void 0?G(J,{what:`Asking kayra`}):r.ok?G(`pre`,{class:`query-result`,children:typeof r.value==`string`?r.value:JSON.stringify(r.value,null,2)}):G(q,{failure:r.failure}),a?G(J,{what:`Receiving updates`}):null]}),G(`div`,{class:`sheet-foot`,children:G(`div`,{class:`buttons`,children:[G(`button`,{type:`button`,class:`button`,onClick:n,children:`edit inputs`}),G(`span`,{class:`spacer`}),G(`button`,{type:`button`,class:`button`,onClick:An,children:`close`})]})})]})},zn=({draft:e,info:t})=>{let[n,r]=N(void 0),[i,a]=N({draft:e,options:{}}),o=()=>{n!==void 0&&a(n),r(void 0)},s=t.effect===`reads`||n?.options.dryRun===!0?void 0:In(n?.draft??e);return G(C,{children:[G(`div`,{class:s===void 0?`sheet-bar`:`sheet-bar real`,children:[G(`span`,{class:s===void 0?`prompt`:`tone-warn`,"aria-hidden":`true`,children:s===void 0?`❯`:`▲`}),G(`strong`,{children:s===void 0?`kayra ${t.name.replace(`.`,` `)}`:`this changes ${s}, a real server`}),G(wn,{effect:t.effect}),G(Nn,{})]}),G(`div`,{class:`sheet-head`,children:[G(`h2`,{id:`operation-title`,children:_t[t.name].label}),G(`p`,{class:`sub`,children:t.summary})]}),n===void 0?G(Fn,{info:t,seed:i.draft,options:i.options,submit:r}):t.kind===`plan`||t.kind===`session`?G(Ln,{prepared:n,effect:t.effect,back:o}):G(Rn,{prepared:n,info:t,back:o})]})},Bn=()=>{let e=On.value,t=Oe(null),n=e!==void 0;if(P(()=>{if(!n)return;let e=document.activeElement;t.current?.focus();let r=e=>{if(e.key===`Escape`&&An(),e.key===`Tab`){let n=t.current?.querySelectorAll(`button:not(:disabled), input:not(:disabled), select:not(:disabled), textarea:not(:disabled)`),r=n?.[0],i=n?.[n.length-1];r===void 0?e.preventDefault():e.shiftKey&&(document.activeElement===r||document.activeElement===t.current)?(e.preventDefault(),i?.focus()):!e.shiftKey&&document.activeElement===i&&(e.preventDefault(),r.focus())}};return addEventListener(`keydown`,r),()=>{removeEventListener(`keydown`,r),e instanceof HTMLElement&&e.focus()}},[n]),e===void 0)return null;let r=H.value,i=r.state===`ready`?r.value.find(t=>t.name===e.name):void 0;return G(`div`,{class:`overlay`,onClick:An,children:G(`div`,{ref:t,tabIndex:-1,class:`sheet`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`operation-title`,onClick:e=>{e.stopPropagation()},children:r.state===`loading`?G(J,{what:`Reading operations`}):r.state===`failed`?G(q,{failure:r.failure}):i===void 0?G(`p`,{role:`alert`,children:`Operation unavailable.`}):G(zn,{draft:e,info:i},JSON.stringify(e))})})},Q=R(!1),Vn=e=>e.replace(`.`,` `),Hn=()=>{let e=V.value,t=e.state===`ready`?e.value.servers:[],n=H.value.state===`ready`?H.value.value:[];return z([{label:`overview`,hint:`every server`,icon:`›`,line:`open /`,go:{page:`fleet`}},{label:`runs`,hint:`what ran from here`,icon:`›`,line:`open /runs`,go:{page:`runs`}},{label:`validate`,hint:`the fleet beyond its schemas`,icon:`›`,line:`open /validate`,go:{page:`validate`}},...n.filter(e=>e.scope===`fleet`||e.scope===`repo`).map(e=>z({label:Vn(e.name),hint:e.summary,icon:_t[e.name].icon,line:`kayra ${Vn(e.name)}`,run:{name:e.name,input:{}},effect:e.effect,real:!1})),...t.flatMap(e=>z([{label:e.name,hint:`${e.kind} on ${e.target} · ${e.domain}`,icon:`●`,line:`open /servers/${e.name}`,go:{page:`server`,server:e.name}},...e.apps.map(t=>z({label:`${e.name}/${t}`,hint:`app`,icon:`▸`,line:`open /servers/${e.name}/apps/${t}`,go:{page:`app`,server:e.name,app:t}})),...Tt(n,e).map(t=>z({label:`${Vn(t.name)} ${e.name}`,hint:t.summary,icon:_t[t.name].icon,line:`kayra ${Vn(t.name)} ${e.name}`,run:{name:t.name,input:{server:e.name}},effect:t.effect,real:e.target!==`multipass`}))]))])},Un=e=>{if(`go`in e)return{text:`jump`,class:`badge badge-jump`,guard:`opens it`};if(e.effect===`reads`)return{text:`read only`,class:`badge badge-reads`,guard:`reads, changes nothing`};let t=e.real?`shows its plan, then asks for the server's name`:`shows its plan first`;return e.effect===`destroys`?{text:`destroys`,class:`badge badge-destroys`,guard:t}:{text:`changes`,class:`badge badge-changes`,guard:t}},Wn=e=>{Q.value=!1,`go`in e?Jt(e.go):Z(e.run.name,e.run.input)},Gn=()=>{let[e,t]=N(``),[n,r]=N(0),i=Oe(null),a=Q.value;if(P(()=>{a&&i.current?.focus()},[a]),P(()=>{let e=e=>{(e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`k`?(e.preventDefault(),Q.value=!Q.value,t(``),r(0)):e.key===`Escape`&&(Q.value=!1)};return addEventListener(`keydown`,e),()=>{removeEventListener(`keydown`,e)}},[]),!Q.value)return null;let o=Dt(Hn(),e).slice(0,12),s=o[n],c=s===void 0?void 0:Un(s);return G(`div`,{class:`overlay`,onClick:()=>{Q.value=!1},children:G(`div`,{class:`palette`,role:`dialog`,"aria-modal":`true`,"aria-label":`Go to, or run`,onClick:e=>{e.stopPropagation()},children:[G(`div`,{class:`palette-input`,children:[G(`span`,{class:`prompt`,"aria-hidden":`true`,children:`❯`}),G(`input`,{ref:i,value:e,placeholder:`a command, a server, a page…`,"aria-label":`Go to, or run`,spellcheck:!1,autoComplete:`off`,onInput:e=>{t(e.currentTarget.value),r(0)},onKeyDown:e=>{if(e.key===`ArrowDown`)r(Math.min(n+1,o.length-1));else if(e.key===`ArrowUp`)r(Math.max(n-1,0));else if(e.key===`Enter`)s!==void 0&&Wn(s);else return;e.preventDefault()}}),G(`kbd`,{children:`esc`})]}),G(`div`,{class:`palette-head`,children:[G(`span`,{children:e.trim()===``?`everything`:`matches`}),G(`span`,{class:`rule`,"aria-hidden":`true`}),G(`span`,{children:o.length})]}),G(`ul`,{role:`listbox`,"aria-label":`Results`,children:[o.map((e,t)=>{let i=Un(e);return G(`li`,{role:`option`,"aria-selected":t===n,class:t===n?`selected`:void 0,onMouseEnter:()=>{r(t)},onClick:()=>{Wn(e)},children:[G(`span`,{class:`prompt`,"aria-hidden":`true`,children:e.icon}),G(`span`,{class:`label`,children:e.label}),G(`span`,{class:`hint`,children:e.hint}),G(`span`,{class:i.class,children:i.text})]},e.label)}),o.length===0?G(`li`,{class:`empty`,children:[`Nothing matches “`,e,`”: try a server's name or a verb.`]}):null]}),s===void 0||c===void 0?null:G(`div`,{class:`palette-preview`,"aria-live":`polite`,children:[G(`div`,{class:`line`,children:[G(`span`,{class:`tone-muted`,"aria-hidden":`true`,children:`$`}),G(`strong`,{class:`ellipsis`,children:s.line}),G(`span`,{class:`spacer`}),G(`span`,{class:c.class.replace(`badge `,``),children:c.guard})]}),G(`p`,{children:s.hint})]}),G(`div`,{class:`palette-foot`,children:[G(`span`,{children:[G(`kbd`,{children:`↑↓`}),` move`]}),G(`span`,{children:[G(`kbd`,{children:`↵`}),` open`]}),G(`span`,{children:[G(`kbd`,{children:`esc`}),` close`]}),G(`span`,{class:`spacer`}),G(`span`,{children:`nothing changes before its plan is shown`})]})]})})},Kn=()=>{Q.value=!0},$=({to:e,children:t,class:n,current:r})=>G(`a`,{href:Wt(e),class:n,"aria-current":r===!0?`page`:void 0,onClick:t=>{t.metaKey||t.ctrlKey||t.shiftKey||t.button!==0||(t.preventDefault(),Jt(e))},children:t}),qn=(e,t)=>Wt(e)===Wt(t),Jn=()=>G(`svg`,{class:`logo`,width:`22`,height:`22`,viewBox:`0 0 22 22`,"aria-hidden":`true`,children:[G(`rect`,{width:`22`,height:`22`,rx:`5`}),G(`path`,{d:`M6.5 7l4 4-4 4M12 15.5h4`})]}),Yn=()=>G(`svg`,{width:`16`,height:`16`,viewBox:`0 0 16 16`,"aria-hidden":`true`,fill:`none`,stroke:`currentColor`,"stroke-width":`1.5`,"stroke-linecap":`round`,children:[G(`circle`,{cx:`8`,cy:`8`,r:`3`}),G(`path`,{d:`M8 1.5v1.6M8 12.9v1.6M1.5 8h1.6M12.9 8h1.6M3.4 3.4l1.1 1.1M11.5 11.5l1.1 1.1M3.4 12.6l1.1-1.1M11.5 4.5l1.1-1.1`})]}),Xn=()=>G(`svg`,{width:`16`,height:`16`,viewBox:`0 0 16 16`,"aria-hidden":`true`,fill:`none`,stroke:`currentColor`,"stroke-width":`1.5`,"stroke-linejoin":`round`,children:G(`path`,{d:`M13.5 9.6A5.6 5.6 0 0 1 6.4 2.5a5.6 5.6 0 1 0 7.1 7.1z`})}),Zn=()=>{let e=V.value,t=Gt(B.value),n=on.value===`dark`;return G(`header`,{class:`topbar`,children:[G($,{to:{page:`fleet`},class:`brand`,children:[G(Jn,{}),G(`span`,{children:[`kayra`,G(`span`,{class:`cursor`,"aria-hidden":`true`,children:`▌`})]})]}),G(`span`,{class:`slash`,"aria-hidden":`true`,children:`/`}),G(`span`,{class:`fleet-name`,title:`The fleet kayra serve was started in`,children:e.state===`ready`?e.value.fleet:`…`}),G(`span`,{class:`slash`,"aria-hidden":`true`,children:`/`}),G(`nav`,{class:`crumbs`,"aria-label":`Breadcrumb`,children:t.map((e,t)=>G(`span`,{class:`crumb`,children:[t===0?null:G(`span`,{class:`slash`,"aria-hidden":`true`,children:`/`}),e.to===void 0?G(`span`,{"aria-current":`page`,children:e.label}):G($,{to:e.to,children:e.label})]},e.label))}),G(`span`,{class:`spacer`}),G(`button`,{type:`button`,class:`cmdbar`,onClick:Kn,children:[G(`span`,{class:`prompt`,"aria-hidden":`true`,children:`❯`}),G(`span`,{children:`run a command or jump to…`}),G(`kbd`,{children:`⌘K`})]}),G(`button`,{type:`button`,class:`iconbtn`,onClick:sn,"aria-label":n?`Switch to light mode`:`Switch to dark mode`,title:n?`Light mode`:`Dark mode`,children:G(n?Yn:Xn,{})})]})},Qn=({children:e,count:t})=>G(`div`,{class:`rail-title`,children:[G(`span`,{children:e}),G(`span`,{class:`rule`,"aria-hidden":`true`}),t===void 0?null:G(`span`,{children:t})]}),$n=({to:e,label:t})=>{let n=qn(B.value,e);return G($,{to:e,class:n?`rail-item on`:`rail-item`,current:n,children:[G(`span`,{class:`rail-mark`,"aria-hidden":`true`,children:n?`›`:``}),G(`span`,{children:t})]})},er=()=>{let e=V.value,t=B.value,n=U.value.value?.servers;return G(`div`,{class:`rail`,children:G(`div`,{class:`rail-inner`,children:[G(`nav`,{"aria-label":`Servers`,children:[G(Qn,{count:e.state===`ready`?e.value.servers.length:void 0,children:`servers`}),e.state===`ready`?e.value.servers.map(e=>{let r=`server`in t&&t.server===e.name,i=hn(n?.find(t=>t.name===e.name));return G($,{to:{page:`server`,server:e.name},class:r?`rail-item on`:`rail-item`,current:r&&t.page===`server`,children:[G(K,{tone:i.tone,label:i.word.toLowerCase()}),G(`span`,{class:`name`,children:e.name}),G(`span`,{class:`meta`,children:e.kind})]},e.name)}):null]}),G(`nav`,{"aria-label":`Pages`,children:[G(Qn,{children:`views`}),G($n,{to:{page:`fleet`},label:`overview`}),G($n,{to:{page:`runs`},label:`runs`}),G($n,{to:{page:`validate`},label:`validate`}),G(`button`,{type:`button`,class:`rail-item`,onClick:()=>{kn({name:`doctor`})},children:[G(`span`,{class:`rail-mark`,"aria-hidden":`true`}),G(`span`,{children:`doctor`})]})]})]})})},tr={fleet:`FLEET`,server:`SERVER`,app:`APP`,runs:`RUNS`,run:`RUN`,session:`SSH`,validate:`VALIDATE`,missing:`?`},nr=()=>{let e=V.value,{value:t,live:n}=U.value,r=t?.servers??[],i=r.filter(e=>mn(e)===`ok`).length,a=r.filter(e=>pn(e).tone===`warn`).length,o=new Date(tn.value).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`});return G(`footer`,{class:`statusline`,children:[G(`span`,{class:`seg seg-mode`,children:tr[B.value.page]}),G(`span`,{class:`seg`,children:e.state===`ready`?e.value.fleet:`…`}),G(`span`,{class:`seg`,children:[`kayra `,e.state===`ready`?e.value.version:`…`]}),G(`span`,{class:`seg wide-only`,children:[G(K,{tone:`ok`}),`real servers ask for their name`]}),G(`span`,{class:`spacer`}),G(`span`,{class:`seg end`,children:[n?G(C,{children:[G(K,{tone:`waiting`}),` asking`]}):`${String(i)}/${String(r.length)} answering`,a===0?null:G(`span`,{class:`tone-warn`,children:[` · `,a,` behind`]})]}),G(`span`,{class:`seg end wide-only`,children:location.host}),G(`span`,{class:`seg end`,children:o})]})},rr=({children:e})=>G(`div`,{class:`app`,children:[G(Zn,{}),G(`div`,{class:`body`,children:[G(er,{}),G(`main`,{class:`main`,children:e})]}),G(nr,{})]}),ir=e=>{let t=Math.max(0,e)/1e3;if(t<10)return`${(Math.floor(t*10)/10).toFixed(1)}s`;if(t<60)return`${String(Math.floor(t))}s`;let n=Math.floor(t/60);return n<60?`${String(n)}m${String(Math.floor(t%60)).padStart(2,`0`)}s`:`${String(Math.floor(n/60))}h${String(n%60).padStart(2,`0`)}m`},ar=e=>{let t=Math.floor(Math.max(0,e)/1e3);if(t<10)return`just now`;if(t<60)return`${String(t)}s ago`;let n=Math.floor(t/60);if(n<60)return`${String(n)}m ago`;let r=Math.floor(n/60);return r<48?`${String(r)}h ago`:`${String(Math.floor(r/24))}d ago`},or=(e,t)=>{let n=new Date(e);return n.toDateString()===new Date(t).toDateString()?n.toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`}):n.toLocaleDateString([],{day:`numeric`,month:`short`})},sr=e=>Date.parse(e),cr=(e,t)=>{let[n,r]=N(void 0),i=()=>{r(void 0),e().then(r)};return P(i,[t]),z([n,i])},lr=e=>e===`success`?`ok`:e===`failure`?`bad`:`waiting`,ur=({server:e,app:t,open:n})=>{let[r]=cr(()=>Ft(`app.runs`,{server:e,app:t}),`${e}/${t}`);if(r===void 0)return G(J,{what:`Asking the deployer`});if(!r.ok)return G(q,{failure:r.failure});let i=Date.now(),{live:a,runs:o}=r.value;return G(C,{children:[G(`p`,{class:`sub`,children:a===void 0?`Not deployed yet.`:`Live: ${a.sha.slice(0,7)} since ${ar(i-Date.parse(a.time))}`}),G(`table`,{class:`table`,children:[G(`thead`,{children:G(`tr`,{children:[G(`th`,{}),G(`th`,{children:`Commit`}),G(`th`,{children:`Why`}),G(`th`,{children:`What`}),G(`th`,{class:`right`,children:`When`}),G(`th`,{class:`right`,children:`Took`})]})}),G(`tbody`,{children:o.map(e=>G(`tr`,{class:`clickable`,onClick:()=>{n(e.id)},children:[G(`td`,{class:`narrow`,children:G(K,{tone:lr(e.state),label:e.state})}),G(`td`,{children:G(`code`,{children:e.sha?.slice(0,7)??``})}),G(`td`,{children:e.why}),G(`td`,{children:e.what}),G(`td`,{class:`right tone-muted`,children:ar(i-Date.parse(e.started))}),G(`td`,{class:`right tone-muted`,children:e.finished===void 0?``:ir(Date.parse(e.finished)-Date.parse(e.started))})]},e.id))})]})]})},dr=({server:e,app:t})=>{let[n]=cr(()=>Ft(`app.releases`,{server:e,app:t}),`${e}/${t}`);if(n===void 0)return G(J,{what:`Asking the deployer`});if(!n.ok)return G(q,{failure:n.failure});let r=Date.now();return G(`ul`,{class:`releases`,children:n.value.releases.map(n=>G(`li`,{children:[G(`code`,{children:n.sha.slice(0,12)}),G(`span`,{class:`tone-muted`,children:ar(r-Date.parse(n.time))}),n.live?G(Tn,{tone:`ok`,children:`live`}):G(`button`,{class:`button small`,onClick:()=>{kn({name:`app.rollback`,server:e,app:t,sha:n.sha})},children:`Roll back to it`})]},n.sha))})},fr=e=>{if(/\b(error|failed|fatal|refused)\b/i.test(e))return z(`tone-bad`);if(/\bwarn(ing)?\b/i.test(e))return z(`tone-warn`)},pr=({server:e,app:t,run:n})=>{let[r]=cr(()=>Ft(`app.log`,{server:e,app:t,...n===void 0?{}:{run:n}}),`${e}/${t}/${n??``}`);return r===void 0?G(J,{what:`Fetching the log`}):r.ok?G(`pre`,{class:`log`,children:r.value.split(`
5
- `).map((e,t)=>G(`div`,{class:fr(e),children:e===``?` `:e},t))}):G(q,{failure:r.failure})},mr=({server:e,app:t})=>{let[n,r]=N(`runs`),[i,a]=N(void 0),[o,s]=N(``);return G(C,{children:[G(Y,{kicker:`app`,title:t,sub:`on ${e}`,children:G(`form`,{class:`inline`,onSubmit:n=>{n.preventDefault(),kn({name:`app.deploy`,server:e,app:t,...o.trim()===``?{}:{ref:o.trim()}})},children:[G(`input`,{value:o,onInput:e=>{s(e.currentTarget.value)},placeholder:`its ref`,spellcheck:!1,"aria-label":`Branch, tag or commit`}),G(`button`,{type:`submit`,class:`button primary`,children:`Deploy`})]})}),G(`nav`,{class:`tabs`,role:`tablist`,children:[`runs`,`releases`,`log`].map(e=>G(`button`,{role:`tab`,"aria-selected":n===e,class:n===e?`tab current`:`tab`,onClick:()=>{r(e)},children:[e,e===`log`&&i!==void 0?` · ${i}`:``]},e))}),G(`section`,{class:`card`,children:n===`runs`?G(ur,{server:e,app:t,open:e=>{a(e),r(`log`)}}):n===`releases`?G(dr,{server:e,app:t}):G(pr,{server:e,app:t,run:i})}),G(`p`,{class:`tone-muted small`,children:[`Purging an app's data is irreversible:`,` `,G(`button`,{class:`link danger-link`,onClick:()=>{kn({name:`app.purge`,server:e,app:t})},children:[`purge `,t,`'s volumes`]})]})]})},hr=({remedy:e,first:t})=>{let n=t?`button small primary`:`button small`;switch(e.kind){case`run`:return G(`button`,{type:`button`,class:n,onClick:()=>{Z(e.draft.name,e.draft.input)},children:e.label});case`go`:return G($,{to:e.to,class:n,children:e.label});case`ask`:return G(`button`,{type:`button`,class:n,disabled:U.value.live,onClick:Qt,children:U.value.live?`asking…`:e.label})}},gr=({notes:e,quiet:t})=>e.length===0?G(`p`,{class:`note`,children:[G(`span`,{class:`note-title`,children:[G(K,{tone:`ok`}),` nothing needs you`]}),G(`span`,{class:`hint`,children:t})]}):G(`div`,{class:`notes`,children:e.map(e=>G(`div`,{class:`note note-${e.tone}`,children:[G(`div`,{class:`note-title`,children:[G(K,{tone:e.tone===`active`?`waiting`:e.tone}),G(`span`,{children:e.title})]}),e.text===``?null:G(`p`,{children:e.text}),G(`div`,{class:`actions`,children:e.remedies.map((e,t)=>G(hr,{remedy:e,first:t===0},e.label))})]},e.title))}),_r=({server:e})=>{let t=H.value;return t.state===`loading`?G(J,{what:`Reading operations`}):t.state===`failed`?G(q,{failure:t.failure}):G(`div`,{class:`action-grid`,children:(e===void 0?t.value.filter(e=>e.scope===`fleet`||e.scope===`repo`):Tt(t.value,e)).map(t=>G(`button`,{type:`button`,class:`action${t.effect===`destroys`?` danger`:``}`,onClick:()=>{Z(t.name,e===void 0?{}:{server:e.name})},children:[G(`span`,{class:`icon`,"aria-hidden":`true`,children:_t[t.name].icon}),G(`strong`,{children:_t[t.name].label}),G(wn,{effect:t.effect}),G(`span`,{class:`about`,children:t.summary})]},t.name))})},vr=e=>Object.freeze(e.toSorted((e,t)=>t.started.localeCompare(e.started))),yr=(e,t,n)=>Object.freeze(vr(e).filter(e=>e.server===t).slice(0,n).toReversed().map(e=>e.state)),br=e=>{if(e.length===0)return`No runs from here yet`;let t=z([`passed`,`failed`,`interrupted`,`declined`,`running`]).flatMap(t=>{let n=e.filter(e=>e===t).length;return Object.freeze(n===0?[]:[`${String(n)} ${t}`])});return`Last ${String(e.length)} runs: ${t.join(`, `)}`},xr=e=>e.kind===`platform`&&e.commands.includes(`deploy`)?z(`deploy`):e.commands.includes(`setup`)?z(`setup`):void 0,Sr=(e,t)=>t?.tone===`bad`?Object.freeze([`${e} ${t.text}`]):Object.freeze([]),Cr=(e,t)=>{let n=z({kind:`go`,label:`open ${e.name}`,to:{page:`server`,server:e.name}}),r=z({kind:`ask`,label:`ask again`}),i=mn(t)===`bad`?[z({tone:`bad`,title:`${e.name} does not answer`,text:[...Sr(`address`,un(t)),...Sr(`ssh`,dn(t)),...Sr(`login`,fn(t))].join(` · `),remedies:[n,r]})]:[],a=t.ssh.state===`refused`?[z({tone:`warn`,title:`${e.name}: SSH is off`,text:`Nothing listens on port ${String(t.ssh.port)}. If its SSH is on only on demand, switch it on, then ask again.`,remedies:[r,n]})]:[],o=xr(e),s=pn(t).tone===`warn`?[z({tone:`warn`,title:t.kayra.version===null?`${e.name} records no kayra version`:`${e.name} runs kayra ${t.kayra.version}`,text:`This fleet pins ${t.kayra.pin}${o===void 0?`.`:`: ${o} records it.`}`,remedies:o===void 0?[n]:[{kind:`run`,label:`${o} ${e.name}`,draft:{name:o,input:{server:e.name}}},n]})]:[];return Object.freeze([...i,...a,...s])},wr=(e,t,n)=>{let r=vr(n),i=e.flatMap(e=>{let n=t.find(t=>t.name===e.name);return n===void 0?Object.freeze([]):Cr(e,n)}),a=e.flatMap(e=>{let t=r.find(t=>t.server===e.name&&t.state!==`running`);return t?.state===`failed`?Object.freeze([z({tone:`bad`,title:`${t.command} failed`,text:`The last run on ${e.name} failed. Its log says where.`,remedies:[{kind:`go`,label:`open the run`,to:{page:t.session?`session`:`run`,id:t.id}}]})]):Object.freeze([])}),o=r.filter(e=>e.state===`running`).map(e=>z({tone:`active`,title:`running: ${e.command}`,text:e.session?`An SSH session is open.`:`Still going.`,remedies:[{kind:`go`,label:e.session?`open the session`:`follow it`,to:{page:e.session?`session`:`run`,id:e.id}}]}));return Object.freeze([...i.filter(e=>e.tone===`bad`),...a,...i.filter(e=>e.tone!==`bad`),...o])},Tr={running:`waiting`,passed:`ok`,failed:`bad`,interrupted:`warn`,declined:`warn`},Er=({server:e,limit:t})=>{let n=W.value;if(n.state===`loading`)return G(J,{what:`Reading the runs`});if(n.state===`failed`)return G(q,{failure:n.failure});let r=vr(n.value).filter(t=>e===void 0||t.server===e).slice(0,t??1/0);if(r.length===0)return G(`p`,{class:`empty panel pad`,children:`Nothing run from here yet.`});let i=tn.value;return G(`div`,{class:`panel scroll-x`,children:G(`div`,{class:`journal`,children:r.map(e=>G($,{to:{page:e.session?`session`:`run`,id:e.id},class:`jrow`,children:[G(`span`,{class:`when`,children:or(e.started,i)}),G(K,{tone:Tr[e.state],label:e.state}),G(`span`,{class:`ellipsis`,children:e.command}),G(`span`,{class:`state tone-${Tr[e.state]===`waiting`?`active`:Tr[e.state]}`,children:e.state}),G(`span`,{class:`ago`,children:ar(i-sr(e.started))})]},e.id))})})},Dr=()=>G(C,{children:[G(Y,{kicker:`journal`,title:`runs`,sub:`Every command run from here, recorded in the fleet's .cache/ui/runs.`}),G(Er,{})]}),Or=864e5,kr=({cell:e})=>e===void 0?G(`span`,{class:`tone-muted`,children:`—`}):G(`span`,{class:`cell`,title:e.title,children:[G(K,{tone:e.tone}),G(`span`,{class:e.tone===`waiting`?`tone-muted`:`tone-${e.tone}`,children:e.text})]}),Ar=({facts:e,seen:t})=>{let n=hn(t),r=W.value.state===`ready`?W.value.value:[],i=yr(r,e.name,16),a=vr(r).find(t=>t.server===e.name),o=xr(e);return G(`div`,{class:`grow-row`,children:[G(Sn,{word:n.word,tone:n.tone}),G(`div`,{class:`ellipsis`,children:[G($,{to:{page:`server`,server:e.name},children:G(`strong`,{children:e.name})}),G(`span`,{class:`second ellipsis`,children:[e.kind,` · `,e.target,` · `,e.domain]})]}),G(kr,{cell:t===void 0?void 0:un(t)}),G(kr,{cell:t===void 0?void 0:dn(t)}),G(kr,{cell:t===void 0?void 0:fn(t)}),G(kr,{cell:t===void 0?void 0:pn(t)}),G(`div`,{children:[G(`span`,{class:`strip`,role:`img`,"aria-label":br(i),children:i.map((e,t)=>G(`span`,{class:e},t))}),G(`span`,{class:`second`,children:a===void 0?`no runs yet`:ar(tn.value-sr(a.started))})]}),G(`div`,{class:`row-actions`,children:[e.commands.includes(`plan`)?G(`button`,{type:`button`,class:`button small`,onClick:()=>{Z(`plan`,{server:e.name})},children:`plan`}):null,o===void 0?null:G(`button`,{type:`button`,class:`button small primary`,onClick:()=>{Z(o,{server:e.name})},children:o})]})]})},jr=({servers:e,seen:t})=>{let n=e=>t.find(t=>t.name===e),r=e.filter(e=>mn(n(e.name))===`ok`),i=t.filter(e=>e.kayra.state!==`skipped`&&e.kayra.state!==`pending`),a=i.filter(e=>pn(e).tone===`warn`),o=t[0]?.kayra.pin,s=W.value.state===`ready`?W.value.value:[],c=s.filter(e=>tn.value-sr(e.started)<Or),l=c.filter(e=>e.state===`failed`).length,u=s.filter(e=>e.state===`running`).length,d=e.flatMap(e=>e.apps),f=e.filter(e=>e.kind===`platform`).length,p=e.filter(e=>mn(n(e.name))!==`ok`).map(e=>e.name);return G(`div`,{class:`tiles`,children:[G(`div`,{class:`tile`,children:[G(`div`,{class:`tile-label`,children:[G(`span`,{children:`servers`}),G(`span`,{class:U.value.live?void 0:p.length===0?`tone-ok`:`tone-warn`,children:U.value.live?`asking`:p.length===0?`all answer`:`${String(p.length)} not answering`})]}),G(`div`,{class:`tile-value`,children:[r.length,G(`small`,{children:[`/`,e.length,` answering`]})]}),G(`div`,{class:`tile-sub bar`,"aria-hidden":`true`,children:e.map(e=>G(`span`,{class:`tone-${hn(n(e.name)).tone}`,children:`█`},e.name))})]}),G(`div`,{class:`tile`,children:[G(`div`,{class:`tile-label`,children:[G(`span`,{children:`kayra`}),G(`span`,{class:i.length===0?void 0:a.length===0?`tone-ok`:`tone-warn`,children:i.length===0?`not asked`:a.length===0?`on the pin`:`${String(a.length)} behind`})]}),G(`div`,{class:`tile-value`,children:[i.length-a.length,G(`small`,{children:[`/`,i.length,` on `,o??`the pin`]})]}),G(`div`,{class:`tile-sub ellipsis`,children:a.length===0?i.length===0?`read over SSH; none open yet`:`every server asked runs it`:a.map(e=>e.name).join(`, `)})]}),G(`div`,{class:`tile`,children:[G(`div`,{class:`tile-label`,children:[G(`span`,{children:`runs · 24h`}),G(`span`,{class:l===0?void 0:`tone-bad`,children:l===0?`none failed`:`${String(l)} failed`})]}),G(`div`,{class:`tile-value`,children:c.length}),G(`div`,{class:`tile-sub`,children:u===0?`nothing running`:`${String(u)} running now`})]}),G(`div`,{class:`tile`,children:[G(`div`,{class:`tile-label`,children:[G(`span`,{children:`apps`}),G(`span`,{children:[f,` platform`]})]}),G(`div`,{class:`tile-value`,children:d.length}),G(`div`,{class:`tile-sub ellipsis`,children:d.length===0?`none in any server.yml`:d.join(`, `)})]})]})},Mr=()=>{let[e,t]=N(``),n=V.value;if(n.state===`loading`)return G(J,{what:`Reading the fleet`});if(n.state===`failed`)return G(q,{failure:n.failure});let{value:r,live:i}=U.value,a=r?.servers??[],{servers:o,version:s}=n.value,c=e.trim().toLowerCase(),l=o.filter(e=>c===``||[e.name,e.kind,e.target,e.domain].join(` `).includes(c)),u=W.value.state===`ready`?W.value.value:[];return G(C,{children:[G(Y,{kicker:`fleet`,title:n.value.fleet,sub:`${String(o.length)} servers · kayra ${s} pinned · every command from this machine`,children:[G(`button`,{type:`button`,class:`button`,onClick:Qt,disabled:i,children:[i?`asking…`:`ask again`,G(`span`,{class:`aside`,children:`status`})]}),G($,{to:{page:`validate`},class:`button`,children:[`validate`,G(`span`,{class:`aside`,children:`read only`})]})]}),G(jr,{servers:o,seen:a}),G(X,{title:`servers`,aside:G(`label`,{class:`filter`,children:[G(`span`,{class:`prompt`,"aria-hidden":`true`,children:`/`}),G(`span`,{class:`visually-hidden`,children:`Filter servers`}),G(`input`,{value:e,placeholder:`filter`,spellcheck:!1,onInput:e=>{t(e.currentTarget.value)}})]}),children:G(`div`,{class:`panel scroll-x servers-table`,children:G(`div`,{class:`gtable`,children:[G(`div`,{class:`ghead`,children:[G(`span`,{children:`state`}),G(`span`,{children:`server`}),G(`span`,{children:`address`}),G(`span`,{children:`ssh`}),G(`span`,{children:`login`}),G(`span`,{children:`kayra`}),G(`span`,{children:`last runs`}),G(`span`,{class:`right`,children:`actions`})]}),l.map(e=>G(Ar,{facts:e,seen:a.find(t=>t.name===e.name)},e.name)),l.length===0?G(`p`,{class:`empty pad`,children:[`No server matches “`,e,`”.`]}):null]})})}),G(`div`,{class:`split`,children:[G(`div`,{class:`wide`,children:G(X,{title:`journal`,aside:G($,{to:{page:`runs`},class:`small`,children:`all runs →`}),children:G(Er,{limit:8})})}),G(`div`,{class:`side`,children:G(X,{title:`needs you`,children:G(gr,{notes:wr(o,a,u),quiet:r===void 0?`Still asking every server.`:`Every server answered; no run failed last.`})})})]}),G(X,{title:`fleet commands`,children:G(_r,{})})]})},Nr=({id:e,question:t})=>{let[n,r]=N(``),[i,a]=N(!1),[o,s]=N(void 0),c=Oe(null);P(()=>{c.current?.focus()},[]);let l=async t=>{a(!0),r(``);let n=await It(e,t);n.ok||(s(n.failure),a(!1))};return G(`form`,{class:`ask`,onSubmit:e=>{e.preventDefault(),i||l(n)},children:[G(`label`,{for:`run-answer`,children:G(bn,{text:t.prompt})}),G(`input`,{id:`run-answer`,ref:c,type:t.secret?`password`:`text`,autoComplete:`off`,value:n,disabled:i,onInput:e=>{r(e.currentTarget.value)},spellcheck:!1}),G(`button`,{type:`submit`,class:`button primary`,disabled:i,children:i?`Sending…`:`Answer`}),G(`button`,{type:`button`,class:`button`,disabled:i,onClick:()=>{l(``)},children:`Decline`}),o===void 0?null:G(q,{failure:o})]})},Pr={invocation:void 0,steps:[],current:void 0,asking:void 0,ended:void 0},Fr=(e,t,n)=>t===void 0?e:z({...e,steps:e.steps.map((e,r)=>r===t?n(e):e)}),Ir=(e,t)=>Fr(e,e.current,e=>({...e,said:[...e.said,t]})),Lr=(e,t,n)=>{switch(t.kind){case`plan`:return z({...e,invocation:t.invocation,steps:t.steps.map(e=>({listed:e,state:`waiting`,said:[]}))});case`started`:return Fr({...e,current:t.index},t.index,e=>({...e,state:`running`,started:n}));case`done`:return Fr(e,t.index,e=>({...e,state:t.failed?`failed`:t.stopped?`stopped`:`passed`,ms:t.ms,...t.why===void 0?{}:{why:t.why}}));case`ended`:{let n={failures:t.failures,ms:t.ms,footer:t.footer,...t.stop===void 0?{}:{stop:t.stop}};return z({...e,asking:void 0,ended:n,steps:e.steps.map((e,n)=>e.state===`running`||t.stop?.why===`interrupted`&&t.stop.index===n?{...e,state:`stopped`}:e.state===`waiting`?{...e,state:`skipped`}:e)})}case`output`:return Ir(e,{kind:`output`,stream:t.stream,chunk:t.chunk});case`said`:return Ir(e,{kind:`said`,stream:t.stream,text:t.text});case`ask`:return z({...e,asking:t});case`answered`:return z({...e,asking:void 0})}},Rr=e=>{let{ended:t}=e;return t===void 0?z(`running`):t.stop?.why===`interrupted`?z(`interrupted`):t.stop?.why===`declined`?z(`declined`):t.failures===0?z(`passed`):z(`failed`)},zr={fg:void 0,bold:!1,dim:!1},Br=[`black`,`red`,`green`,`yellow`,`blue`,`magenta`,`cyan`,`white`],Vr=(e,t)=>{let n=t===``?[0]:t.split(`;`).map(Number),r=(e,t)=>{let[n,...i]=t;return n===void 0?e:n===38||n===48?r(e,i[0]===5?i.slice(2):i[0]===2?i.slice(4):i):r(n===0?zr:n===1?{...e,bold:!0}:n===2?{...e,dim:!0}:n===22?{...e,bold:!1,dim:!1}:n===39?{...e,fg:void 0}:n>=30&&n<=37?{...e,fg:Br[n-30]}:n>=90&&n<=97?{...e,fg:`bright-${Br[n-90]??`white`}`}:e,i)};return r(e,n)},Hr=e=>[e.fg===void 0?``:`sgr-${e.fg}`,e.bold?`sgr-bold`:``,e.dim?`sgr-dim`:``].filter(e=>e!==``).join(` `),Ur=/\u001b\[([0-9;]*)m|\u001b\[[0-9;?]*[A-Za-z]|\u001b\][^\u0007\u001b]*(?:\u0007|\u001b\\)/g,Wr=e=>{let t=[...e.matchAll(Ur)].reduce((t,n)=>{let r=e.slice(t.at,n.index),i=r===``?t.out:[...t.out,{text:r,classes:Hr(t.look)}],a=n[1];return{out:i,look:a===void 0?t.look:Vr(t.look,a),at:n.index+n[0].length}},{out:[],look:zr,at:0}),n=e.slice(t.at);return n===``?t.out:z([...t.out,{text:n,classes:Hr(t.look)}])},Gr={running:{word:`RUN`,tone:`active`},passed:{word:`OK`,tone:`ok`},failed:{word:`FAILED`,tone:`bad`},interrupted:{word:`STOPPED`,tone:`warn`},declined:{word:`DECLINED`,tone:`warn`}},Kr={waiting:{glyph:`○`,tone:`tone-muted`},running:{glyph:`◐`,tone:`tone-active pulse`},passed:{glyph:`✓`,tone:`tone-ok`},failed:{glyph:`✕`,tone:`tone-bad`},stopped:{glyph:`■`,tone:`tone-warn`},skipped:{glyph:`–`,tone:`tone-muted`}},qr=({step:e})=>G(C,{children:e.said.map((e,t)=>e.kind===`output`?G(`span`,{class:e.stream===`stderr`?`stderr`:void 0,children:Wr(e.chunk).map((e,t)=>G(`span`,{class:e.classes===``?void 0:e.classes,children:e.text},t))},t):G(`div`,{class:e.stream===`err`?`said said-err`:`said`,children:G(bn,{text:e.text})},t))}),Jr=(e,t)=>e.ms??(e.started===void 0?void 0:t-e.started),Yr=({steps:e,now:t,picked:n,pick:r})=>G(`ol`,{class:`steps panel`,children:e.map(e=>{let i=Jr(e,t),a=e.listed.index,o=n===a;return G(`li`,{children:[e.listed.opens===void 0?null:G(`div`,{class:`part`,children:e.listed.opens}),G(`button`,{type:`button`,"aria-pressed":o,class:`step-button step-${e.state}${o?` on`:e.state===`running`||e.state===`failed`?` ${e.state}`:``}`,onClick:()=>{r(o?void 0:a)},children:[G(`span`,{class:Kr[e.state].tone,"aria-label":e.state,children:Kr[e.state].glyph}),G(`span`,{children:[G(`span`,{class:`step-title`,children:e.listed.title}),G(`span`,{class:`step-kind`,children:e.why===void 0?e.listed.kind:`${e.listed.kind} · ${e.why}`})]}),G(`span`,{class:`step-time`,children:i===void 0?e.state:ir(i)})]})]},a)})}),Xr=({id:e})=>{let[t,n]=De((e,t)=>Lr(e,t,Date.now()),Pr),[r,i]=N(Date.now()),[a,o]=N(void 0),[s,c]=N(void 0),[l,u]=N(!0),d=Oe(null);P(()=>Vt(`/api/runs/${encodeURIComponent(e)}/events`,n,()=>void 0,void 0,o),[e]);let f=Rr(t)===`running`;P(()=>{if(!f)return;let e=setInterval(()=>{i(Date.now())},250);return()=>{clearInterval(e)}},[f]),P(()=>{l&&d.current?.scrollTo({top:d.current.scrollHeight})},[t,l,s]);let{invocation:p,steps:m,ended:h,asking:g}=t;if(p===void 0)return a===void 0?G(J,{what:`Starting`}):G(q,{failure:a});let _=Gr[Rr(t)],v=m.flatMap(e=>e.started===void 0?[]:[e.started]),y=h?.ms??(v.length===0?0:r-Math.min(...v)),b=m.filter(e=>e.state===`passed`).length,x=h?.stop,S=x===void 0?void 0:m.find(e=>e.listed.index===x.index),w=m.find(e=>e.state===`failed`),T=m.filter(e=>(s===void 0||e.listed.index===s)&&e.said.length>0);return G(C,{children:[G(Y,{kicker:`run · ${e}`,title:G(`code`,{children:p.command}),tag:G(Sn,{word:_.word,tone:_.tone}),sub:[...p.about,`${String(m.length)} steps`].join(` · `),children:[G(`div`,{class:`elapsed`,children:[G(`strong`,{children:ir(y)}),G(`span`,{children:[b,` of `,m.length,` steps passed`]})]}),f?G(`button`,{type:`button`,class:`button danger`,onClick:()=>{Lt(e).then(e=>{e.ok||o(e.failure)})},children:`stop`}):null]}),G(`div`,{class:`progress`,role:`img`,"aria-label":`${String(b)} of ${String(m.length)} steps passed`,children:m.map(e=>G(`span`,{class:e.state},e.listed.index))}),a===void 0?null:G(q,{failure:a}),x===void 0||S===void 0?null:G(`div`,{class:`banner ${x.why===`failed`?`banner-bad`:`banner-warn`}`,role:`alert`,children:[G(`span`,{class:x.why===`failed`?`tone-bad`:`tone-warn`,"aria-hidden":`true`,children:x.why===`failed`?`✕`:`■`}),G(`div`,{class:`prose`,children:[G(`strong`,{children:[x.why===`failed`?`Stopped at`:x.why===`declined`?`Declined at`:`Interrupted at`,` `,S.listed.title,`.`]}),` `,S.why??``,` Nothing after it ran.`]}),G(`button`,{type:`button`,class:`button small`,onClick:()=>{c(x.index)},children:`show it`})]}),x!==void 0||h===void 0||h.failures===0||w===void 0?null:G(`div`,{class:`banner banner-bad`,role:`alert`,children:[G(`span`,{class:`tone-bad`,"aria-hidden":`true`,children:`✕`}),G(`div`,{class:`prose`,children:[G(`strong`,{children:[h.failures,` `,h.failures===1?`step`:`steps`,` failed,`]}),` `,`the first at `,w.listed.title,`. The rest ran; the footer says what to do.`]}),G(`button`,{type:`button`,class:`button small`,onClick:()=>{c(w.listed.index)},children:`show it`})]}),g===void 0?null:G(Nr,{id:e,question:g},JSON.stringify(g)),G(`div`,{class:`split`,children:[G(`div`,{class:`side`,children:G(X,{title:`steps`,meta:`from the plan`,children:G(Yr,{steps:m,now:r,picked:s,pick:c})})}),G(`div`,{class:`wide`,children:G(X,{title:`log`,aside:G(C,{children:[s===void 0?null:G(`button`,{type:`button`,class:`button small`,onClick:()=>{c(void 0)},"aria-label":`Show every step`,children:[m.find(e=>e.listed.index===s)?.listed.title??``,` ×`]}),G(`button`,{type:`button`,class:`button small`,"aria-pressed":l,onClick:()=>{u(!l)},children:[G(`span`,{class:l&&f?`tone-active pulse`:`tone-muted`,"aria-hidden":`true`,children:`●`}),l?`following`:`follow`]})]}),children:G(`div`,{class:`terminal-panel`,children:[G(`div`,{ref:d,class:`terminal-scrollbox`,onWheel:e=>{e.deltaY<0&&u(!1)},children:[T.length===0?G(`span`,{class:`tone-muted`,children:f?`Waiting for output…`:`Nothing was printed here.`}):T.map(e=>G(`div`,{children:[G(`div`,{class:`log-step`,children:[`── `,e.listed.index+1,` · `,e.listed.title,` ──`]}),G(qr,{step:e})]},e.listed.index)),f&&l?G(`span`,{class:`cursor`,"aria-hidden":`true`,children:`▌`}):null]}),h===void 0?null:G(`footer`,{class:`run-footer`,children:G(xn,{lines:h.footer})})]})})})]})]})},Zr=({name:e})=>{let t=V.value;if(t.state!==`ready`)return G(J,{what:`Reading the fleet`});let n=t.value.servers.find(t=>t.name===e);if(n===void 0)return G(`p`,{class:`empty`,children:[`No server `,e,` in this fleet.`]});let{value:r,live:i}=U.value,a=r?.servers.find(t=>t.name===e),o=hn(a),s=xr(n),c=W.value.state===`ready`?W.value.value.filter(t=>t.server===e):[],l=wr([n],a===void 0?[]:[a],c).map(e=>({...e,remedies:e.remedies.filter(e=>e.kind!==`go`||e.to.page!==`server`)})),u=e=>()=>{Z(e,{server:n.name})};return G(C,{children:[G(Y,{kicker:`server`,title:n.name,tag:G(Sn,{word:o.word,tone:o.tone}),sub:G(C,{children:[G(`span`,{children:[`kind `,G(`span`,{class:`tone-strong`,children:n.kind})]}),G(`span`,{children:[`target `,G(`span`,{class:`tone-strong`,children:n.target})]}),G(`span`,{children:[`domain`,` `,G(`a`,{href:`https://${n.domain}`,target:`_blank`,rel:`noreferrer`,class:`tone-strong`,children:n.domain})]})]}),children:[G(`button`,{type:`button`,class:`button`,onClick:u(`ssh`),children:[`ssh`,a?.ssh.state===`refused`?G(`span`,{class:`aside`,children:`off`}):null]}),n.commands.includes(`verify`)?G(`button`,{type:`button`,class:`button`,onClick:u(`verify`),children:[`verify`,G(`span`,{class:`aside`,children:`read only`})]}):null,n.commands.includes(`plan`)?G(`button`,{type:`button`,class:`button`,onClick:u(`plan`),children:[`plan`,G(`span`,{class:`aside`,children:`dry run`})]}):null,s===void 0?null:G(`button`,{type:`button`,class:`button primary`,onClick:u(s),children:[s,` `,n.name]})]}),l.length===0?null:G(gr,{notes:l,quiet:``}),G(`div`,{class:`split`,children:[G(`div`,{class:`wide`,children:[n.kind===`platform`?G(X,{title:`apps`,meta:n.apps.length,children:n.apps.length===0?G(`p`,{class:`empty panel pad`,children:`None in server.yml.`}):G(`ul`,{class:`links panel`,children:n.apps.map(e=>G(`li`,{children:G($,{to:{page:`app`,server:n.name,app:e},children:[G(`span`,{class:`prompt`,"aria-hidden":`true`,children:`▸`}),G(`span`,{children:e})]})},e))})}):null,G(X,{title:`runs from here`,children:G(Er,{server:n.name})}),G(X,{title:`commands`,children:G(_r,{server:n})})]}),G(`div`,{class:`side`,children:G(X,{title:`reach`,aside:G(`button`,{type:`button`,class:`button small`,onClick:Qt,disabled:i,children:i?`asking…`:`ask again`}),children:G(`div`,{class:`panel pad`,children:a===void 0?G(J,{what:`asking`}):G(`dl`,{class:`facts`,children:[G(En,{label:`address`,cell:un(a)}),G(En,{label:`ssh`,cell:dn(a)}),G(En,{label:`login`,cell:fn(a)}),G(En,{label:`kayra`,cell:pn(a)})]})})})})]})]})},Qr=e=>e===`problem`?`bad`:e===`unchecked`?`warn`:`ok`,$r=e=>e===`problem`?`✗`:e===`unchecked`?`·`:`✓`,ei={problem:`problems`,unchecked:`partly checked`,passed:`holds`},ti=()=>{P(()=>{$t()},[]);let e=Xt.value;if(e.state===`loading`)return G(J,{what:`Checking the fleet beyond its schemas`});if(e.state===`failed`)return G(q,{failure:e.failure});let{result:t,servers:n}=e.value,r=e=>n.flatMap(e=>e.findings).filter(t=>t.result===e).length;return G(C,{children:[G(Y,{kicker:`fleet`,title:`validate`,tag:G(Sn,{word:t===`problem`?`FAIL`:t===`unchecked`?`PART`:`OK`,tone:Qr(t)}),sub:`Secrets, apps against their contract, stacks, routes · ${String(r(`problem`))} problems · ${String(r(`unchecked`))} not checked`,children:G(`button`,{type:`button`,class:`button`,onClick:()=>void $t(),children:[`check again`,G(`span`,{class:`aside`,children:`read only`})]})}),n.map(e=>G(`section`,{class:`card`,children:[G(`div`,{class:`card-head`,children:[G(K,{tone:Qr(e.result)}),G(`h2`,{children:e.name}),G(Tn,{children:e.kind}),G(Tn,{children:e.target}),G(`span`,{class:`grow`}),G(Tn,{tone:Qr(e.result),children:ei[e.result]})]}),G(`ul`,{class:`findings`,children:e.findings.map((e,t)=>G(`li`,{class:`finding finding-${e.result}`,children:[G(`span`,{class:`glyph tone-${Qr(e.result)}`,children:$r(e.result)}),G(`span`,{children:[e.text,e.hint===null?null:G(`span`,{class:`hint`,children:[`→ `,e.hint]})]})]},t))})]},e.name))]})},ni=e=>typeof e==`string`?e:e.map(e=>typeof e==`string`?e:e.text).join(``),ri=e=>e.kind===`output`?e.chunk:e.kind===`said`?`${ni(e.text)}\r\n`:``,ii=(e,t)=>{let n={current:Promise.resolve(!0)};return r=>{n.current=n.current.then(async n=>{if(!n)return!1;let i=await e(r);return i.ok||t(i.failure),i.ok})}},ai=`modulepreload`,oi=function(e){return`/`+e},si={},ci=function(e){return e.pathname.endsWith(`.css`)},li=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e,i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?new URL(import.meta.resolve(e)):new URL(e,import.meta.url)}r=o(t.map(t=>{t=oi(t,n);let r=s(t);if(r.href in si)return;si[r.href]=!0;let i=ci(r);if(e===void 0){e={all:new Set,styles:new Set};let t=document.getElementsByTagName(`link`);for(let n=t.length-1;n>=0;n--){let r=t[n];e.all.add(r.href),r.rel===`stylesheet`&&e.styles.add(r.href)}}if((i?e.styles:e.all).has(r.href))return;let o=document.createElement(`link`);if(o.rel=i?`stylesheet`:ai,i||(o.as=`script`),o.crossOrigin=``,o.href=r.href,a&&o.setAttribute(`nonce`,a),document.head.appendChild(o),i)return new Promise((e,t)=>{o.addEventListener(`load`,e),o.addEventListener(`error`,()=>t(Error(`Unable to preload CSS for ${r}`)))})}).filter(e=>e!==void 0))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},ui=({id:e})=>{let t=Oe(null),[n,r]=N(void 0),[i,a]=N(void 0),[o,s]=N(`running`),[c,l]=N(void 0),[u,d]=N(!1);P(()=>{let n={current:!0},i={current:()=>void 0};return(async()=>{let{Terminal:o}=await li(async()=>{let{Terminal:e}=await import(`./xterm-CerOhKYV.js`);return{Terminal:e}},[]);if(!n.current||t.current===null)return;let c=new o({cols:120,rows:32,fontSize:13,cursorBlink:!0,disableStdin:!0,theme:{background:`#0a0a0c`,foreground:`#e4e4e8`}});c.open(t.current),c.focus();let u={current:[]},d={current:!1},f={current:!1},p={current:!1},m=e=>{f.current=!e,c.options.disableStdin=e},h=e=>{p.current=!0,m(!0),l(e)},g=ii(t=>Rt(e,t),h),_=c.onData(e=>{f.current&&g(e)}),v=Vt(`/api/sessions/${encodeURIComponent(e)}/output`,e=>{e.kind===`plan`&&(r(e.invocation),u.current=e.steps),e.kind===`started`&&u.current.find(t=>t.index===e.index)?.kind===`session`&&m(!1),e.kind===`ask`&&(m(!0),a(e)),e.kind===`answered`&&a(void 0);let t=ri(e);t!==``&&c.write(t),e.kind===`ended`&&(d.current=!0,m(!0),s(e.stop?.why===`interrupted`?`interrupted`:e.stop?.why===`declined`?`declined`:e.failures>0||e.stop!==void 0?`failed`:`passed`),c.write(`\r
5
+ `).map((e,t)=>G(`div`,{class:fr(e),children:e===``?` `:e},t))}):G(q,{failure:r.failure})},mr=({server:e,app:t})=>{let[n,r]=N(`runs`),[i,a]=N(void 0),[o,s]=N(``);return G(C,{children:[G(Y,{kicker:`app`,title:t,sub:`on ${e}`,children:G(`form`,{class:`inline`,onSubmit:n=>{n.preventDefault(),kn({name:`app.deploy`,server:e,app:t,...o.trim()===``?{}:{ref:o.trim()}})},children:[G(`input`,{value:o,onInput:e=>{s(e.currentTarget.value)},placeholder:`its ref`,spellcheck:!1,"aria-label":`Branch, tag or commit`}),G(`button`,{type:`submit`,class:`button primary`,children:`Deploy`})]})}),G(`nav`,{class:`tabs`,role:`tablist`,children:[`runs`,`releases`,`log`].map(e=>G(`button`,{role:`tab`,"aria-selected":n===e,class:n===e?`tab current`:`tab`,onClick:()=>{r(e)},children:[e,e===`log`&&i!==void 0?` · ${i}`:``]},e))}),G(`section`,{class:`card`,children:n===`runs`?G(ur,{server:e,app:t,open:e=>{a(e),r(`log`)}}):n===`releases`?G(dr,{server:e,app:t}):G(pr,{server:e,app:t,run:i})}),G(`p`,{class:`tone-muted small`,children:[`Purging an app's data is irreversible:`,` `,G(`button`,{class:`link danger-link`,onClick:()=>{kn({name:`app.purge`,server:e,app:t})},children:[`purge `,t,`'s volumes`]})]})]})},hr=({remedy:e,first:t})=>{let n=t?`button small primary`:`button small`;switch(e.kind){case`run`:return G(`button`,{type:`button`,class:n,onClick:()=>{Z(e.draft.name,e.draft.input)},children:e.label});case`go`:return G($,{to:e.to,class:n,children:e.label});case`ask`:return G(`button`,{type:`button`,class:n,disabled:U.value.live,onClick:Qt,children:U.value.live?`asking…`:e.label})}},gr=({notes:e,quiet:t})=>e.length===0?G(`p`,{class:`note`,children:[G(`span`,{class:`note-title`,children:[G(K,{tone:`ok`}),` nothing needs you`]}),G(`span`,{class:`hint`,children:t})]}):G(`div`,{class:`notes`,children:e.map(e=>G(`div`,{class:`note note-${e.tone}`,children:[G(`div`,{class:`note-title`,children:[G(K,{tone:e.tone===`active`?`waiting`:e.tone}),G(`span`,{children:e.title})]}),e.text===``?null:G(`p`,{children:e.text}),G(`div`,{class:`actions`,children:e.remedies.map((e,t)=>G(hr,{remedy:e,first:t===0},e.label))})]},e.title))}),_r=({server:e})=>{let t=H.value;return t.state===`loading`?G(J,{what:`Reading operations`}):t.state===`failed`?G(q,{failure:t.failure}):G(`div`,{class:`action-grid`,children:(e===void 0?t.value.filter(e=>e.scope===`fleet`||e.scope===`repo`):Tt(t.value,e)).map(t=>G(`button`,{type:`button`,class:`action${t.effect===`destroys`?` danger`:``}`,onClick:()=>{Z(t.name,e===void 0?{}:{server:e.name})},children:[G(`span`,{class:`icon`,"aria-hidden":`true`,children:_t[t.name].icon}),G(`strong`,{children:_t[t.name].label}),G(wn,{effect:t.effect}),G(`span`,{class:`about`,children:t.summary})]},t.name))})},vr=e=>Object.freeze(e.toSorted((e,t)=>t.started.localeCompare(e.started))),yr=(e,t,n)=>Object.freeze(vr(e).filter(e=>e.server===t).slice(0,n).toReversed().map(e=>e.state)),br=e=>{if(e.length===0)return`No runs from here yet`;let t=z([`passed`,`failed`,`interrupted`,`declined`,`running`]).flatMap(t=>{let n=e.filter(e=>e===t).length;return Object.freeze(n===0?[]:[`${String(n)} ${t}`])});return`Last ${String(e.length)} runs: ${t.join(`, `)}`},xr=e=>e.kind===`platform`&&e.commands.includes(`deploy`)?z(`deploy`):e.commands.includes(`setup`)?z(`setup`):void 0,Sr=(e,t)=>t?.tone===`bad`?Object.freeze([`${e} ${t.text}`]):Object.freeze([]),Cr=(e,t)=>{let n=z({kind:`go`,label:`open ${e.name}`,to:{page:`server`,server:e.name}}),r=z({kind:`ask`,label:`ask again`}),i=mn(t)===`bad`?[z({tone:`bad`,title:`${e.name} does not answer`,text:[...Sr(`address`,un(t)),...Sr(`ssh`,dn(t)),...Sr(`login`,fn(t))].join(` · `),remedies:[n,r]})]:[],a=t.ssh.state===`refused`?[z({tone:`warn`,title:`${e.name}: SSH is off`,text:`Nothing listens on port ${String(t.ssh.port)}. If its SSH is on only on demand, switch it on, then ask again.`,remedies:[r,n]})]:[],o=xr(e),s=pn(t).tone===`warn`?[z({tone:`warn`,title:t.kayra.version===null?`${e.name} records no kayra version`:`${e.name} runs kayra ${t.kayra.version}`,text:`This fleet pins ${t.kayra.pin}${o===void 0?`.`:`: ${o} records it.`}`,remedies:o===void 0?[n]:[{kind:`run`,label:`${o} ${e.name}`,draft:{name:o,input:{server:e.name}}},n]})]:[];return Object.freeze([...i,...a,...s])},wr=(e,t,n)=>{let r=vr(n),i=e.flatMap(e=>{let n=t.find(t=>t.name===e.name);return n===void 0?Object.freeze([]):Cr(e,n)}),a=e.flatMap(e=>{let t=r.find(t=>t.server===e.name&&t.state!==`running`);return t?.state===`failed`?Object.freeze([z({tone:`bad`,title:`${t.command} failed`,text:`The last run on ${e.name} failed. Its log says where.`,remedies:[{kind:`go`,label:`open the run`,to:{page:t.session?`session`:`run`,id:t.id}}]})]):Object.freeze([])}),o=r.filter(e=>e.state===`running`).map(e=>z({tone:`active`,title:`running: ${e.command}`,text:e.session?`An SSH session is open.`:`Still going.`,remedies:[{kind:`go`,label:e.session?`open the session`:`follow it`,to:{page:e.session?`session`:`run`,id:e.id}}]}));return Object.freeze([...i.filter(e=>e.tone===`bad`),...a,...i.filter(e=>e.tone!==`bad`),...o])},Tr={running:`waiting`,passed:`ok`,failed:`bad`,interrupted:`warn`,declined:`warn`},Er=({server:e,limit:t})=>{let n=W.value;if(n.state===`loading`)return G(J,{what:`Reading the runs`});if(n.state===`failed`)return G(q,{failure:n.failure});let r=vr(n.value).filter(t=>e===void 0||t.server===e).slice(0,t??1/0);if(r.length===0)return G(`p`,{class:`empty panel pad`,children:`Nothing run from here yet.`});let i=tn.value;return G(`div`,{class:`panel scroll-x`,children:G(`div`,{class:`journal`,children:r.map(e=>G($,{to:{page:e.session?`session`:`run`,id:e.id},class:`jrow`,children:[G(`span`,{class:`when`,children:or(e.started,i)}),G(K,{tone:Tr[e.state],label:e.state}),G(`span`,{class:`ellipsis`,children:e.command}),G(`span`,{class:`state tone-${Tr[e.state]===`waiting`?`active`:Tr[e.state]}`,children:e.state}),G(`span`,{class:`ago`,children:ar(i-sr(e.started))})]},e.id))})})},Dr=()=>G(C,{children:[G(Y,{kicker:`journal`,title:`runs`,sub:`Every command run from here, recorded in the fleet's .cache/ui/runs.`}),G(Er,{})]}),Or=864e5,kr=({cell:e})=>e===void 0?G(`span`,{class:`tone-muted`,children:`—`}):G(`span`,{class:`cell`,title:e.title,children:[G(K,{tone:e.tone}),G(`span`,{class:e.tone===`waiting`?`tone-muted`:`tone-${e.tone}`,children:e.text})]}),Ar=({facts:e,seen:t})=>{let n=hn(t),r=W.value.state===`ready`?W.value.value:[],i=yr(r,e.name,16),a=vr(r).find(t=>t.server===e.name),o=xr(e);return G(`div`,{class:`grow-row`,children:[G(Sn,{word:n.word,tone:n.tone}),G(`div`,{class:`ellipsis`,children:[G($,{to:{page:`server`,server:e.name},children:G(`strong`,{children:e.name})}),G(`span`,{class:`second ellipsis`,children:[e.kind,` · `,e.target,` · `,e.domain]})]}),G(kr,{cell:t===void 0?void 0:un(t)}),G(kr,{cell:t===void 0?void 0:dn(t)}),G(kr,{cell:t===void 0?void 0:fn(t)}),G(kr,{cell:t===void 0?void 0:pn(t)}),G(`div`,{children:[G(`span`,{class:`strip`,role:`img`,"aria-label":br(i),children:i.map((e,t)=>G(`span`,{class:e},t))}),G(`span`,{class:`second`,children:a===void 0?`no runs yet`:ar(tn.value-sr(a.started))})]}),G(`div`,{class:`row-actions`,children:[e.commands.includes(`plan`)?G(`button`,{type:`button`,class:`button small`,onClick:()=>{Z(`plan`,{server:e.name})},children:`plan`}):null,o===void 0?null:G(`button`,{type:`button`,class:`button small primary`,onClick:()=>{Z(o,{server:e.name})},children:o})]})]})},jr=({servers:e,seen:t})=>{let n=e=>t.find(t=>t.name===e),r=e.filter(e=>mn(n(e.name))===`ok`),i=t.filter(e=>e.kayra.state!==`skipped`&&e.kayra.state!==`pending`),a=i.filter(e=>pn(e).tone===`warn`),o=t[0]?.kayra.pin,s=W.value.state===`ready`?W.value.value:[],c=s.filter(e=>tn.value-sr(e.started)<Or),l=c.filter(e=>e.state===`failed`).length,u=s.filter(e=>e.state===`running`).length,d=e.flatMap(e=>e.apps),f=e.filter(e=>e.kind===`platform`).length,p=e.filter(e=>mn(n(e.name))!==`ok`).map(e=>e.name);return G(`div`,{class:`tiles`,children:[G(`div`,{class:`tile`,children:[G(`div`,{class:`tile-label`,children:[G(`span`,{children:`servers`}),G(`span`,{class:U.value.live?void 0:p.length===0?`tone-ok`:`tone-warn`,children:U.value.live?`asking`:p.length===0?`all answer`:`${String(p.length)} not answering`})]}),G(`div`,{class:`tile-value`,children:[r.length,G(`small`,{children:[`/`,e.length,` answering`]})]}),G(`div`,{class:`tile-sub bar`,"aria-hidden":`true`,children:e.map(e=>G(`span`,{class:`tone-${hn(n(e.name)).tone}`,children:`█`},e.name))})]}),G(`div`,{class:`tile`,children:[G(`div`,{class:`tile-label`,children:[G(`span`,{children:`kayra`}),G(`span`,{class:i.length===0?void 0:a.length===0?`tone-ok`:`tone-warn`,children:i.length===0?`not asked`:a.length===0?`on the pin`:`${String(a.length)} behind`})]}),G(`div`,{class:`tile-value`,children:[i.length-a.length,G(`small`,{children:[`/`,i.length,` on `,o??`the pin`]})]}),G(`div`,{class:`tile-sub ellipsis`,children:a.length===0?i.length===0?`read over SSH; none open yet`:`every server asked runs it`:a.map(e=>e.name).join(`, `)})]}),G(`div`,{class:`tile`,children:[G(`div`,{class:`tile-label`,children:[G(`span`,{children:`runs · 24h`}),G(`span`,{class:l===0?void 0:`tone-bad`,children:l===0?`none failed`:`${String(l)} failed`})]}),G(`div`,{class:`tile-value`,children:c.length}),G(`div`,{class:`tile-sub`,children:u===0?`nothing running`:`${String(u)} running now`})]}),G(`div`,{class:`tile`,children:[G(`div`,{class:`tile-label`,children:[G(`span`,{children:`apps`}),G(`span`,{children:[f,` platform`]})]}),G(`div`,{class:`tile-value`,children:d.length}),G(`div`,{class:`tile-sub ellipsis`,children:d.length===0?`none in any server.yml`:d.join(`, `)})]})]})},Mr=()=>{let[e,t]=N(``),n=V.value;if(n.state===`loading`)return G(J,{what:`Reading the fleet`});if(n.state===`failed`)return G(q,{failure:n.failure});let{value:r,live:i}=U.value,a=r?.servers??[],{servers:o,version:s}=n.value,c=e.trim().toLowerCase(),l=o.filter(e=>c===``||[e.name,e.kind,e.target,e.domain].join(` `).includes(c)),u=W.value.state===`ready`?W.value.value:[];return G(C,{children:[G(Y,{kicker:`fleet`,title:n.value.fleet,sub:`${String(o.length)} servers · kayra ${s} pinned · every command from this machine`,children:[G(`button`,{type:`button`,class:`button`,onClick:Qt,disabled:i,children:[i?`asking…`:`ask again`,G(`span`,{class:`aside`,children:`status`})]}),G($,{to:{page:`validate`},class:`button`,children:[`validate`,G(`span`,{class:`aside`,children:`read only`})]})]}),G(jr,{servers:o,seen:a}),G(X,{title:`servers`,aside:G(`label`,{class:`filter`,children:[G(`span`,{class:`prompt`,"aria-hidden":`true`,children:`/`}),G(`span`,{class:`visually-hidden`,children:`Filter servers`}),G(`input`,{value:e,placeholder:`filter`,spellcheck:!1,onInput:e=>{t(e.currentTarget.value)}})]}),children:G(`div`,{class:`panel scroll-x servers-table`,children:G(`div`,{class:`gtable`,children:[G(`div`,{class:`ghead`,children:[G(`span`,{children:`state`}),G(`span`,{children:`server`}),G(`span`,{children:`address`}),G(`span`,{children:`ssh`}),G(`span`,{children:`login`}),G(`span`,{children:`kayra`}),G(`span`,{children:`last runs`}),G(`span`,{class:`right`,children:`actions`})]}),l.map(e=>G(Ar,{facts:e,seen:a.find(t=>t.name===e.name)},e.name)),l.length===0?G(`p`,{class:`empty pad`,children:[`No server matches “`,e,`”.`]}):null]})})}),G(`div`,{class:`split`,children:[G(`div`,{class:`wide`,children:G(X,{title:`journal`,aside:G($,{to:{page:`runs`},class:`small`,children:`all runs →`}),children:G(Er,{limit:8})})}),G(`div`,{class:`side`,children:G(X,{title:`needs you`,children:G(gr,{notes:wr(o,a,u),quiet:r===void 0?`Still asking every server.`:`Every server answered; no run failed last.`})})})]}),G(X,{title:`fleet commands`,children:G(_r,{})})]})},Nr=({id:e,question:t})=>{let[n,r]=N(``),[i,a]=N(!1),[o,s]=N(void 0),c=Oe(null);P(()=>{c.current?.focus()},[]);let l=async t=>{a(!0),r(``);let n=await It(e,t);n.ok||(s(n.failure),a(!1))};return G(`form`,{class:`ask`,onSubmit:e=>{e.preventDefault(),i||l(n)},children:[G(`label`,{for:`run-answer`,children:G(bn,{text:t.prompt})}),G(`input`,{id:`run-answer`,ref:c,type:t.secret?`password`:`text`,autoComplete:`off`,value:n,disabled:i,onInput:e=>{r(e.currentTarget.value)},spellcheck:!1}),G(`button`,{type:`submit`,class:`button primary`,disabled:i,children:i?`Sending…`:`Answer`}),G(`button`,{type:`button`,class:`button`,disabled:i,onClick:()=>{l(``)},children:`Decline`}),o===void 0?null:G(q,{failure:o})]})},Pr={invocation:void 0,steps:[],current:void 0,asking:void 0,ended:void 0},Fr=(e,t,n)=>t===void 0?e:z({...e,steps:e.steps.map((e,r)=>r===t?n(e):e)}),Ir=(e,t)=>Fr(e,e.current,e=>({...e,said:[...e.said,t]})),Lr=(e,t,n)=>{switch(t.kind){case`plan`:return z({...e,invocation:t.invocation,steps:t.steps.map(e=>({listed:e,state:`waiting`,said:[]}))});case`started`:return Fr({...e,current:t.index},t.index,e=>({...e,state:`running`,started:n}));case`done`:return Fr(e,t.index,e=>({...e,state:t.failed?`failed`:t.stopped?`stopped`:`passed`,ms:t.ms,...t.why===void 0?{}:{why:t.why}}));case`ended`:{let n={failures:t.failures,ms:t.ms,footer:t.footer,...t.stop===void 0?{}:{stop:t.stop}};return z({...e,asking:void 0,ended:n,steps:e.steps.map((e,n)=>e.state===`running`||t.stop?.why===`interrupted`&&t.stop.index===n?{...e,state:`stopped`}:e.state===`waiting`?{...e,state:`skipped`}:e)})}case`output`:return Ir(e,{kind:`output`,stream:t.stream,chunk:t.chunk});case`said`:return Ir(e,{kind:`said`,stream:t.stream,text:t.text});case`ask`:return z({...e,asking:t});case`answered`:return z({...e,asking:void 0})}},Rr=e=>{let{ended:t}=e;return t===void 0?z(`running`):t.stop?.why===`interrupted`?z(`interrupted`):t.stop?.why===`declined`?z(`declined`):t.failures===0?z(`passed`):z(`failed`)},zr={fg:void 0,bold:!1,dim:!1},Br=[`black`,`red`,`green`,`yellow`,`blue`,`magenta`,`cyan`,`white`],Vr=(e,t)=>{let n=t===``?[0]:t.split(`;`).map(Number),r=(e,t)=>{let[n,...i]=t;return n===void 0?e:n===38||n===48?r(e,i[0]===5?i.slice(2):i[0]===2?i.slice(4):i):r(n===0?zr:n===1?{...e,bold:!0}:n===2?{...e,dim:!0}:n===22?{...e,bold:!1,dim:!1}:n===39?{...e,fg:void 0}:n>=30&&n<=37?{...e,fg:Br[n-30]}:n>=90&&n<=97?{...e,fg:`bright-${Br[n-90]??`white`}`}:e,i)};return r(e,n)},Hr=e=>[e.fg===void 0?``:`sgr-${e.fg}`,e.bold?`sgr-bold`:``,e.dim?`sgr-dim`:``].filter(e=>e!==``).join(` `),Ur=/\u001b\[([0-9;]*)m|\u001b\[[0-9;?]*[A-Za-z]|\u001b\][^\u0007\u001b]*(?:\u0007|\u001b\\)/g,Wr=e=>{let t=[...e.matchAll(Ur)].reduce((t,n)=>{let r=e.slice(t.at,n.index),i=r===``?t.out:[...t.out,{text:r,classes:Hr(t.look)}],a=n[1];return{out:i,look:a===void 0?t.look:Vr(t.look,a),at:n.index+n[0].length}},{out:[],look:zr,at:0}),n=e.slice(t.at);return n===``?t.out:z([...t.out,{text:n,classes:Hr(t.look)}])},Gr={running:{word:`RUN`,tone:`active`},passed:{word:`OK`,tone:`ok`},failed:{word:`FAILED`,tone:`bad`},interrupted:{word:`STOPPED`,tone:`warn`},declined:{word:`DECLINED`,tone:`warn`}},Kr={waiting:{glyph:`○`,tone:`tone-muted`},running:{glyph:`◐`,tone:`tone-active pulse`},passed:{glyph:`✓`,tone:`tone-ok`},failed:{glyph:`✕`,tone:`tone-bad`},stopped:{glyph:`■`,tone:`tone-warn`},skipped:{glyph:`–`,tone:`tone-muted`}},qr=({step:e})=>G(C,{children:e.said.map((e,t)=>e.kind===`output`?G(`span`,{class:e.stream===`stderr`?`stderr`:void 0,children:Wr(e.chunk).map((e,t)=>G(`span`,{class:e.classes===``?void 0:e.classes,children:e.text},t))},t):G(`div`,{class:e.stream===`err`?`said said-err`:`said`,children:G(bn,{text:e.text})},t))}),Jr=(e,t)=>e.ms??(e.started===void 0?void 0:t-e.started),Yr=({steps:e,now:t,picked:n,pick:r})=>G(`ol`,{class:`steps panel`,children:e.map(e=>{let i=Jr(e,t),a=e.listed.index,o=n===a;return G(`li`,{children:[e.listed.opens===void 0?null:G(`div`,{class:`part`,children:e.listed.opens}),G(`button`,{type:`button`,"aria-pressed":o,class:`step-button step-${e.state}${o?` on`:e.state===`running`||e.state===`failed`?` ${e.state}`:``}`,onClick:()=>{r(o?void 0:a)},children:[G(`span`,{class:Kr[e.state].tone,"aria-label":e.state,children:Kr[e.state].glyph}),G(`span`,{children:[G(`span`,{class:`step-title`,children:e.listed.title}),G(`span`,{class:`step-kind`,children:e.why===void 0?e.listed.kind:`${e.listed.kind} · ${e.why}`})]}),G(`span`,{class:`step-time`,children:i===void 0?e.state:ir(i)})]})]},a)})}),Xr=({id:e})=>{let[t,n]=De((e,t)=>Lr(e,t,Date.now()),Pr),[r,i]=N(Date.now()),[a,o]=N(void 0),[s,c]=N(void 0),[l,u]=N(!0),d=Oe(null);P(()=>Vt(`/api/runs/${encodeURIComponent(e)}/events`,n,()=>void 0,void 0,o),[e]);let f=Rr(t)===`running`;P(()=>{if(!f)return;let e=setInterval(()=>{i(Date.now())},250);return()=>{clearInterval(e)}},[f]),P(()=>{l&&d.current?.scrollTo({top:d.current.scrollHeight})},[t,l,s]);let{invocation:p,steps:m,ended:h,asking:g}=t;if(p===void 0)return a===void 0?G(J,{what:`Starting`}):G(q,{failure:a});let _=Gr[Rr(t)],v=m.flatMap(e=>e.started===void 0?[]:[e.started]),y=h?.ms??(v.length===0?0:r-Math.min(...v)),b=m.filter(e=>e.state===`passed`).length,x=h?.stop,S=x===void 0?void 0:m.find(e=>e.listed.index===x.index),w=m.find(e=>e.state===`failed`),T=m.filter(e=>(s===void 0||e.listed.index===s)&&e.said.length>0);return G(C,{children:[G(Y,{kicker:`run · ${e}`,title:G(`code`,{children:p.command}),tag:G(Sn,{word:_.word,tone:_.tone}),sub:[...p.about,`${String(m.length)} steps`].join(` · `),children:[G(`div`,{class:`elapsed`,children:[G(`strong`,{children:ir(y)}),G(`span`,{children:[b,` of `,m.length,` steps passed`]})]}),f?G(`button`,{type:`button`,class:`button danger`,onClick:()=>{Lt(e).then(e=>{e.ok||o(e.failure)})},children:`stop`}):null]}),G(`div`,{class:`progress`,role:`img`,"aria-label":`${String(b)} of ${String(m.length)} steps passed`,children:m.map(e=>G(`span`,{class:e.state},e.listed.index))}),a===void 0?null:G(q,{failure:a}),x===void 0||S===void 0?null:G(`div`,{class:`banner ${x.why===`failed`?`banner-bad`:`banner-warn`}`,role:`alert`,children:[G(`span`,{class:x.why===`failed`?`tone-bad`:`tone-warn`,"aria-hidden":`true`,children:x.why===`failed`?`✕`:`■`}),G(`div`,{class:`prose`,children:[G(`strong`,{children:[x.why===`failed`?`Stopped at`:x.why===`declined`?`Declined at`:`Interrupted at`,` `,S.listed.title,`.`]}),` `,S.why??``,` Nothing after it ran.`]}),G(`button`,{type:`button`,class:`button small`,onClick:()=>{c(x.index)},children:`show it`})]}),x!==void 0||h===void 0||h.failures===0||w===void 0?null:G(`div`,{class:`banner banner-bad`,role:`alert`,children:[G(`span`,{class:`tone-bad`,"aria-hidden":`true`,children:`✕`}),G(`div`,{class:`prose`,children:[G(`strong`,{children:[h.failures,` `,h.failures===1?`step`:`steps`,` failed,`]}),` `,`the first at `,w.listed.title,`. The rest ran; the footer says what to do.`]}),G(`button`,{type:`button`,class:`button small`,onClick:()=>{c(w.listed.index)},children:`show it`})]}),g===void 0?null:G(Nr,{id:e,question:g},JSON.stringify(g)),G(`div`,{class:`split`,children:[G(`div`,{class:`side`,children:G(X,{title:`steps`,meta:`from the plan`,children:G(Yr,{steps:m,now:r,picked:s,pick:c})})}),G(`div`,{class:`wide`,children:G(X,{title:`log`,aside:G(C,{children:[s===void 0?null:G(`button`,{type:`button`,class:`button small`,onClick:()=>{c(void 0)},"aria-label":`Show every step`,children:[m.find(e=>e.listed.index===s)?.listed.title??``,` ×`]}),G(`button`,{type:`button`,class:`button small`,"aria-pressed":l,onClick:()=>{u(!l)},children:[G(`span`,{class:l&&f?`tone-active pulse`:`tone-muted`,"aria-hidden":`true`,children:`●`}),l?`following`:`follow`]})]}),children:G(`div`,{class:`terminal-panel`,children:[G(`div`,{ref:d,class:`terminal-scrollbox`,onWheel:e=>{e.deltaY<0&&u(!1)},children:[T.length===0?G(`span`,{class:`tone-muted`,children:f?`Waiting for output…`:`Nothing was printed here.`}):T.map(e=>G(`div`,{children:[G(`div`,{class:`log-step`,children:[`── `,e.listed.index+1,` · `,e.listed.title,` ──`]}),G(qr,{step:e})]},e.listed.index)),f&&l?G(`span`,{class:`cursor`,"aria-hidden":`true`,children:`▌`}):null]}),h===void 0?null:G(`footer`,{class:`run-footer`,children:G(xn,{lines:h.footer})})]})})})]})]})},Zr=({name:e})=>{let t=V.value;if(t.state!==`ready`)return G(J,{what:`Reading the fleet`});let n=t.value.servers.find(t=>t.name===e);if(n===void 0)return G(`p`,{class:`empty`,children:[`No server `,e,` in this fleet.`]});let{value:r,live:i}=U.value,a=r?.servers.find(t=>t.name===e),o=hn(a),s=xr(n),c=W.value.state===`ready`?W.value.value.filter(t=>t.server===e):[],l=wr([n],a===void 0?[]:[a],c).map(e=>({...e,remedies:e.remedies.filter(e=>e.kind!==`go`||e.to.page!==`server`)})),u=e=>()=>{Z(e,{server:n.name})};return G(C,{children:[G(Y,{kicker:`server`,title:n.name,tag:G(Sn,{word:o.word,tone:o.tone}),sub:G(C,{children:[G(`span`,{children:[`kind `,G(`span`,{class:`tone-strong`,children:n.kind})]}),G(`span`,{children:[`target `,G(`span`,{class:`tone-strong`,children:n.target})]}),G(`span`,{children:[`domain`,` `,G(`a`,{href:`https://${n.domain}`,target:`_blank`,rel:`noreferrer`,class:`tone-strong`,children:n.domain})]})]}),children:[G(`button`,{type:`button`,class:`button`,onClick:u(`ssh`),children:[`ssh`,a?.ssh.state===`refused`?G(`span`,{class:`aside`,children:`off`}):null]}),n.commands.includes(`verify`)?G(`button`,{type:`button`,class:`button`,onClick:u(`verify`),children:[`verify`,G(`span`,{class:`aside`,children:`read only`})]}):null,n.commands.includes(`plan`)?G(`button`,{type:`button`,class:`button`,onClick:u(`plan`),children:[`plan`,G(`span`,{class:`aside`,children:`dry run`})]}):null,s===void 0?null:G(`button`,{type:`button`,class:`button primary`,onClick:u(s),children:[s,` `,n.name]})]}),l.length===0?null:G(gr,{notes:l,quiet:``}),G(`div`,{class:`split`,children:[G(`div`,{class:`wide`,children:[n.kind===`platform`?G(X,{title:`apps`,meta:n.apps.length,children:n.apps.length===0?G(`p`,{class:`empty panel pad`,children:`None in server.yml.`}):G(`ul`,{class:`links panel`,children:n.apps.map(e=>G(`li`,{children:G($,{to:{page:`app`,server:n.name,app:e},children:[G(`span`,{class:`prompt`,"aria-hidden":`true`,children:`▸`}),G(`span`,{children:e})]})},e))})}):null,G(X,{title:`runs from here`,children:G(Er,{server:n.name})}),G(X,{title:`commands`,children:G(_r,{server:n})})]}),G(`div`,{class:`side`,children:G(X,{title:`reach`,aside:G(`button`,{type:`button`,class:`button small`,onClick:Qt,disabled:i,children:i?`asking…`:`ask again`}),children:G(`div`,{class:`panel pad`,children:a===void 0?G(J,{what:`asking`}):G(`dl`,{class:`facts`,children:[G(En,{label:`address`,cell:un(a)}),G(En,{label:`ssh`,cell:dn(a)}),G(En,{label:`login`,cell:fn(a)}),G(En,{label:`kayra`,cell:pn(a)})]})})})})]})]})},Qr=e=>e===`problem`?`bad`:e===`unchecked`?`warn`:`ok`,$r=e=>e===`problem`?`✗`:e===`unchecked`?`·`:`✓`,ei={problem:`problems`,unchecked:`partly checked`,passed:`holds`},ti=()=>{P(()=>{$t()},[]);let e=Xt.value;if(e.state===`loading`)return G(J,{what:`Checking the fleet beyond its schemas`});if(e.state===`failed`)return G(q,{failure:e.failure});let{result:t,servers:n}=e.value,r=e=>n.flatMap(e=>e.findings).filter(t=>t.result===e).length;return G(C,{children:[G(Y,{kicker:`fleet`,title:`validate`,tag:G(Sn,{word:t===`problem`?`FAIL`:t===`unchecked`?`PART`:`OK`,tone:Qr(t)}),sub:`Secrets, apps against their contract, stacks, routes · ${String(r(`problem`))} problems · ${String(r(`unchecked`))} not checked`,children:G(`button`,{type:`button`,class:`button`,onClick:()=>void $t(),children:[`check again`,G(`span`,{class:`aside`,children:`read only`})]})}),n.map(e=>G(`section`,{class:`card`,children:[G(`div`,{class:`card-head`,children:[G(K,{tone:Qr(e.result)}),G(`h2`,{children:e.name}),G(Tn,{children:e.kind}),G(Tn,{children:e.target}),G(`span`,{class:`grow`}),G(Tn,{tone:Qr(e.result),children:ei[e.result]})]}),G(`ul`,{class:`findings`,children:e.findings.map((e,t)=>G(`li`,{class:`finding finding-${e.result}`,children:[G(`span`,{class:`glyph tone-${Qr(e.result)}`,children:$r(e.result)}),G(`span`,{children:[e.text,e.hint===null?null:G(`span`,{class:`hint`,children:[`→ `,e.hint]})]})]},t))})]},e.name))]})},ni=e=>typeof e==`string`?e:e.map(e=>typeof e==`string`?e:e.text).join(``),ri=e=>e.kind===`output`?e.chunk:e.kind===`said`?`${ni(e.text)}\r\n`:``,ii=(e,t)=>{let n={current:Promise.resolve(!0)};return r=>{n.current=n.current.then(async n=>{if(!n)return!1;let i=await e(r);return i.ok||t(i.failure),i.ok})}},ai=`modulepreload`,oi=function(e){return`/`+e},si={},ci=function(e){return e.pathname.endsWith(`.css`)},li=function(e,t,n){if(t in e)return e[t];let r=n();if(!r){e[t]=void 0;return}let i=r.then(()=>{e[t]=void 0},n=>{throw e[t]=void 0,n});return e[t]=i,i},ui=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e,i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?new URL(import.meta.resolve(e)):new URL(e,import.meta.url)}r=o(t.map(t=>{t=oi(t,n);let r=s(t),i=ci(r);return li(si,r.href,()=>{if(e===void 0){e={all:new Set,styles:new Set};let t=document.getElementsByTagName(`link`);for(let n=t.length-1;n>=0;n--){let r=t[n];e.all.add(r.href),r.rel===`stylesheet`&&e.styles.add(r.href)}}if((i?e.styles:e.all).has(r.href))return;let t=document.createElement(`link`);if(t.rel=i?`stylesheet`:ai,i||(t.as=`script`),t.crossOrigin=``,t.href=r.href,a&&t.setAttribute(`nonce`,a),document.head.appendChild(t),i)return new Promise((e,n)=>{t.addEventListener(`load`,e),t.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${r}`)))})})}).filter(e=>e!==void 0))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},di=({id:e})=>{let t=Oe(null),[n,r]=N(void 0),[i,a]=N(void 0),[o,s]=N(`running`),[c,l]=N(void 0),[u,d]=N(!1);P(()=>{let n={current:!0},i={current:()=>void 0};return(async()=>{let{Terminal:o}=await ui(async()=>{let{Terminal:e}=await import(`./xterm-CerOhKYV.js`);return{Terminal:e}},[]);if(!n.current||t.current===null)return;let c=new o({cols:120,rows:32,fontSize:13,cursorBlink:!0,disableStdin:!0,theme:{background:`#0a0a0c`,foreground:`#e4e4e8`}});c.open(t.current),c.focus();let u={current:[]},d={current:!1},f={current:!1},p={current:!1},m=e=>{f.current=!e,c.options.disableStdin=e},h=e=>{p.current=!0,m(!0),l(e)},g=ii(t=>Rt(e,t),h),_=c.onData(e=>{f.current&&g(e)}),v=Vt(`/api/sessions/${encodeURIComponent(e)}/output`,e=>{e.kind===`plan`&&(r(e.invocation),u.current=e.steps),e.kind===`started`&&u.current.find(t=>t.index===e.index)?.kind===`session`&&m(!1),e.kind===`ask`&&(m(!0),a(e)),e.kind===`answered`&&a(void 0);let t=ri(e);t!==``&&c.write(t),e.kind===`ended`&&(d.current=!0,m(!0),s(e.stop?.why===`interrupted`?`interrupted`:e.stop?.why===`declined`?`declined`:e.failures>0||e.stop!==void 0?`failed`:`passed`),c.write(`\r
6
6
  [Session ended]\r
7
- `))},()=>{m(!0),n.current&&!d.current&&!p.current&&l({status:0,message:`Session output disconnected. Reload this page to reconnect.`})},void 0,h);i.current=()=>{v(),_.dispose(),c.dispose()}})().catch(()=>{n.current&&l({status:0,message:`The terminal could not start. Reload this page to reconnect.`})}),()=>{n.current=!1,i.current()}},[e]);let f=async()=>{d(!0);let t=await zt(e);t.ok||(l(t.failure),d(!1))};return G(C,{children:[G(Y,{kicker:`ssh session`,title:G(`code`,{children:n?.command??`kayra ssh`}),sub:`120 columns × 32 rows`,children:[G(Tn,{tone:o===`running`?`active`:o===`passed`?`ok`:`warn`,children:o}),o===`running`?G(`button`,{class:`button danger`,disabled:u,onClick:()=>{f()},children:u?`Closing…`:`Close session`}):null]}),c===void 0?null:G(q,{failure:c}),i===void 0?null:G(Nr,{id:e,question:i},JSON.stringify(i)),G(`div`,{class:`terminal-scroll`,children:G(`div`,{ref:t,class:`terminal`})}),G(`p`,{class:`hint`,children:`Leaving this page keeps the session open. Use Close session to disconnect.`})]})},di=()=>{let e=B.value;switch(e.page){case`fleet`:return G(Mr,{});case`server`:return G(Zr,{name:e.server});case`app`:return G(mr,{server:e.server,app:e.app});case`runs`:return G(Dr,{});case`run`:return G(Xr,{id:e.id},e.id);case`session`:return G(ui,{id:e.id},e.id);case`validate`:return G(ti,{});case`missing`:return G(`p`,{class:`empty`,children:[`Nothing at `,e.path,`.`]})}},fi=()=>(P(()=>(Zt(),Yt(),Qt(),nn()),[]),G(C,{children:[G(rr,{children:G(di,{})}),G(Bn,{}),G(Gn,{})]})),pi=document.getElementById(`app`);pi!==null&&me(G(fi,{}),pi);
7
+ `))},()=>{m(!0),n.current&&!d.current&&!p.current&&l({status:0,message:`Session output disconnected. Reload this page to reconnect.`})},void 0,h);i.current=()=>{v(),_.dispose(),c.dispose()}})().catch(()=>{n.current&&l({status:0,message:`The terminal could not start. Reload this page to reconnect.`})}),()=>{n.current=!1,i.current()}},[e]);let f=async()=>{d(!0);let t=await zt(e);t.ok||(l(t.failure),d(!1))};return G(C,{children:[G(Y,{kicker:`ssh session`,title:G(`code`,{children:n?.command??`kayra ssh`}),sub:`120 columns × 32 rows`,children:[G(Tn,{tone:o===`running`?`active`:o===`passed`?`ok`:`warn`,children:o}),o===`running`?G(`button`,{class:`button danger`,disabled:u,onClick:()=>{f()},children:u?`Closing…`:`Close session`}):null]}),c===void 0?null:G(q,{failure:c}),i===void 0?null:G(Nr,{id:e,question:i},JSON.stringify(i)),G(`div`,{class:`terminal-scroll`,children:G(`div`,{ref:t,class:`terminal`})}),G(`p`,{class:`hint`,children:`Leaving this page keeps the session open. Use Close session to disconnect.`})]})},fi=()=>{let e=B.value;switch(e.page){case`fleet`:return G(Mr,{});case`server`:return G(Zr,{name:e.server});case`app`:return G(mr,{server:e.server,app:e.app});case`runs`:return G(Dr,{});case`run`:return G(Xr,{id:e.id},e.id);case`session`:return G(di,{id:e.id},e.id);case`validate`:return G(ti,{});case`missing`:return G(`p`,{class:`empty`,children:[`Nothing at `,e.path,`.`]})}},pi=()=>(P(()=>(Zt(),Yt(),Qt(),nn()),[]),G(C,{children:[G(rr,{children:G(fi,{})}),G(Bn,{}),G(Gn,{})]})),mi=document.getElementById(`app`);mi!==null&&me(G(pi,{}),mi);
@@ -13,7 +13,7 @@
13
13
  if (chosen === "dark" || chosen === "light") document.documentElement.setAttribute("data-theme", chosen);
14
14
  } catch {}
15
15
  </script>
16
- <script type="module" crossorigin src="/assets/index-SP8bCDrl.js"></script>
16
+ <script type="module" crossorigin src="/assets/index-Cjm17KRz.js"></script>
17
17
  <link rel="stylesheet" crossorigin href="/assets/index-DzIVPXyL.css">
18
18
  </head>
19
19
  <body>
@@ -94,6 +94,11 @@ access_control:
94
94
  policy: '{{ env "AUTH_POLICY" }}'
95
95
  subject:
96
96
  - 'group:admin'
97
+ # The monitor's page, where the server runs one.
98
+ - domain: 'status.{{ env "DOMAIN" }}'
99
+ policy: '{{ env "AUTH_POLICY" }}'
100
+ subject:
101
+ - 'group:admin'
97
102
 
98
103
  session:
99
104
  name: 'authelia_session'
@@ -11,10 +11,10 @@
11
11
  # code and the platform scripts).
12
12
  # =============================================================================
13
13
 
14
- FROM node:24.21.0-trixie-slim@sha256:173f125896c3b47ddf056734c7ea789d04595a6a08769a8f78e0df642781fb66
14
+ FROM node:24.22.1-trixie-slim@sha256:43b9ba1142b8dcf33fa8f922ca1be85714adc444e0586c7cf7726daaeabc1bea
15
15
 
16
16
  # renovate: datasource=github-releases depName=moby/buildkit
17
- ARG BUILDKIT_VERSION=v0.34.0
17
+ ARG BUILDKIT_VERSION=v0.34.1
18
18
  # renovate: datasource=github-releases depName=mikefarah/yq
19
19
  ARG YQ_VERSION=v4.54.1
20
20
 
@@ -7,13 +7,13 @@
7
7
  # Context: <platform_dir>/kayra, copied by the platform role.
8
8
  # =============================================================================
9
9
 
10
- FROM node:24.21.0-trixie-slim@sha256:173f125896c3b47ddf056734c7ea789d04595a6a08769a8f78e0df642781fb66
10
+ FROM node:24.22.1-trixie-slim@sha256:43b9ba1142b8dcf33fa8f922ca1be85714adc444e0586c7cf7726daaeabc1bea
11
11
 
12
12
  # renovate: datasource=github-releases depName=moby/buildkit
13
- ARG BUILDKIT_VERSION=v0.34.0
13
+ ARG BUILDKIT_VERSION=v0.34.1
14
14
  # What the Renovate job runs, pinned here so Renovate keeps it current itself.
15
15
  # renovate: datasource=docker depName=renovate/renovate
16
- ARG RENOVATE_VERSION=44.115.10
16
+ ARG RENOVATE_VERSION=44.181.0
17
17
  ENV RENOVATE_IMAGE=renovate/renovate:${RENOVATE_VERSION}
18
18
 
19
19
  RUN apt-get update && \
@@ -30,7 +30,7 @@ services:
30
30
  # container, not the box.
31
31
  # ---------------------------------------------------------------------------
32
32
  buildkitd:
33
- image: moby/buildkit:v0.34.0-rootless@sha256:65eca3c01cd1180c8f64565c4e3c5983af5145818b0e6fa863385d099eb73855
33
+ image: moby/buildkit:v0.34.1-rootless@sha256:f68752a5a94acfcdad2d07867b7075601a421638e17fc5f28efc1c814d0c4f89
34
34
  restart: unless-stopped
35
35
  # Flags go in the command: this image does not read BUILDKITD_FLAGS (that
36
36
  # is a buildx convention), and without them it listens on a unix socket
@@ -5,7 +5,7 @@
5
5
 
6
6
  services:
7
7
  traefik:
8
- image: traefik:v3.7.14@sha256:575fa15b135078fe5e50aa847987d96dbddd7b093c172429618404df73f3fa7c
8
+ image: traefik:v3.7.16@sha256:c8a121e4bb1347e8fd52657fab12f2cb70b68f8a018895e2068f92c9e519b9c2
9
9
  restart: unless-stopped
10
10
  ports:
11
11
  - "80:80"
package/hosts.conf CHANGED
@@ -1,6 +1,9 @@
1
1
  # Platform subdomains to add to /etc/hosts and to the mkcert SAN list.
2
2
  # App subdomains live in each app's app.yml; apps may not claim these.
3
3
  # One subdomain per line. Read by scripts/local/setup-hosts.sh and scripts/local/certs.sh.
4
+ # status is routed only where the server runs a monitor (monitor in vars.yml);
5
+ # verify and the monitors expect it only there.
4
6
  deploy
5
7
  auth
6
8
  traefik
9
+ status
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yunuseon/kayra",
3
- "version": "0.22.1",
3
+ "version": "0.22.3",
4
4
  "description": "A self-hosted app platform and the CLI that runs it: Traefik, Authelia, a registry, rootless BuildKit and a small deployer per server, set up with OpenTofu and Ansible.",
5
5
  "license": "MIT",
6
6
  "author": "Yunus Öztürk",
@@ -44,22 +44,22 @@
44
44
  "signatures": "rm -rf .cache/signatures && tsc -p cli/tsconfig.build.json --declaration --emitDeclarationOnly --outDir .cache/signatures"
45
45
  },
46
46
  "dependencies": {
47
- "@modelcontextprotocol/server": "2.3.1",
48
- "@optique/core": "1.3.3",
49
- "@optique/run": "1.3.3",
47
+ "@modelcontextprotocol/server": "2.4.0",
48
+ "@optique/core": "1.3.6",
49
+ "@optique/run": "1.3.6",
50
50
  "yaml": "2.9.1",
51
- "zod": "4.6.5"
51
+ "zod": "4.6.7"
52
52
  },
53
53
  "devDependencies": {
54
54
  "@eslint/js": "10.0.1",
55
- "@modelcontextprotocol/client": "2.3.1",
55
+ "@modelcontextprotocol/client": "2.4.0",
56
56
  "@tsconfig/node24": "24.0.5",
57
57
  "@tsconfig/strictest": "2.0.8",
58
- "@types/node": "24.19.1",
59
- "eslint": "10.12.0",
58
+ "@types/node": "24.19.2",
59
+ "eslint": "10.13.0",
60
60
  "eslint-plugin-functional": "10.0.1",
61
61
  "typescript": "6.0.3",
62
- "typescript-eslint": "8.71.1"
62
+ "typescript-eslint": "8.72.0"
63
63
  },
64
64
  "overrides": {
65
65
  "eslint-plugin-functional": {
@@ -3,8 +3,8 @@
3
3
  # monitor-endpoints.sh <server> — what the server's monitor (Gatus, the
4
4
  # monitor role) checks, from the same sources as verify.sh: for each server in
5
5
  # its vars.yml's monitor.watch,
6
- # platform: auth.<domain> answers; the platform's pages (hosts.conf) send a
7
- # browser to the login; every app route answers, not 5xx;
6
+ # platform: auth.<domain> answers; the platform's pages (hosts.conf, status
7
+ # where it runs a monitor) send a browser to the login; every app route answers, not 5xx;
8
8
  # deploy.<domain>/health is 200 (monitor_health_tokens.<server>)
9
9
  # edge: every edge_routes name answers, not 5xx
10
10
  # nas: nothing of its own: its stacks are monitor.extra
@@ -50,7 +50,9 @@ watched() {
50
50
  case "$kind" in
51
51
  platform)
52
52
  endpoint "auth.${domain}" "$server" "https://auth.${domain}/" false false '[STATUS] == 200' "$cert"
53
+ monitored="$( [ -f "${dir}/vars.yml" ] && yq -r '.monitor != null' "${dir}/vars.yml" || echo false)"
53
54
  awk '!/^[[:space:]]*(#|$)/ {print $1}' "${KAYRA_ROOT}/hosts.conf" | while IFS= read -r sub; do
55
+ [ "$sub" != status ] || [ "$monitored" = true ] || continue
54
56
  [ "$sub" = auth ] || endpoint "${sub}.${domain}" "$server" "https://${sub}.${domain}/" false false '[STATUS] == 302' "$cert"
55
57
  done
56
58
  endpoint "deploy.${domain}/health" "$server" "https://deploy.${domain}/health" false true '[STATUS] == 200'
@@ -5,8 +5,9 @@
5
5
  #
6
6
  # From here, the way the world reaches it (each name pinned to the server's
7
7
  # address, so neither DNS nor /etc/hosts has to be in place yet):
8
- # - auth.<domain> answers; the platform's own pages (hosts.conf) send a
9
- # browser to the login, not a 403 from rules Authelia never loaded
8
+ # - auth.<domain> answers; the platform's own pages (hosts.conf; status only
9
+ # where a monitor runs) send a browser to the login, not a 403 from rules
10
+ # Authelia never loaded
10
11
  # - every certificate is a real one (Let's Encrypt or mkcert), never
11
12
  # Traefik's default
12
13
  # - an unsigned webhook is refused (with webhooks: false, /hook is not
@@ -87,8 +88,13 @@ check() {
87
88
  }
88
89
 
89
90
  check "auth.${domain} answers" "auth.${domain}" GET answers
91
+ monitored="$( [ -f "${dir}/vars.yml" ] && yq -r '.monitor != null' "${dir}/vars.yml" || echo false)"
90
92
  while IFS= read -r sub; do
91
- [ "$sub" = auth ] || check "${sub}.${domain} sends a browser to the login" "${sub}.${domain}" GET to_login
93
+ case "$sub" in
94
+ auth) ;;
95
+ status) [ "$monitored" != true ] || check "${sub}.${domain} sends a browser to the login" "${sub}.${domain}" GET to_login ;;
96
+ *) check "${sub}.${domain} sends a browser to the login" "${sub}.${domain}" GET to_login ;;
97
+ esac
92
98
  done < <(awk '!/^[[:space:]]*(#|$)/ {print $1}' "${KAYRA_ROOT}/hosts.conf")
93
99
 
94
100
  first_app="$(head -1 <<< "$registered_wanted")"
@@ -28,9 +28,14 @@ locals {
28
28
  }
29
29
  uncloned = [for name, manifest in local.manifests : name if !fileexists(manifest)]
30
30
 
31
+ # status only where the server runs a monitor, which serves it.
32
+ vars_file = "${var.fleet_root}/servers/${var.server}/vars.yml"
33
+ monitored = fileexists(local.vars_file) ? try(yamldecode(file(local.vars_file)).monitor, null) != null : false
31
34
  platform_subdomains = [
32
- for line in split("\n", file("${path.module}/../../../hosts.conf")) :
33
- split(" ", trimspace(line))[0] if trimspace(line) != "" && !startswith(trimspace(line), "#")
35
+ for sub in [
36
+ for line in split("\n", file("${path.module}/../../../hosts.conf")) :
37
+ split(" ", trimspace(line))[0] if trimspace(line) != "" && !startswith(trimspace(line), "#")
38
+ ] : sub if sub != "status" || local.monitored
34
39
  ]
35
40
  app_subdomains = flatten([
36
41
  for name, manifest in local.manifests :
@@ -0,0 +1,6 @@
1
+ kind: platform
2
+ target: hetzner
3
+ domain: example.com
4
+ apps:
5
+ - {name: shop, repo: https://github.com/acme/shop.git}
6
+ - {name: blog, repo: https://github.com/acme/blog.git, path: site}
@@ -62,3 +62,18 @@ run "app_not_cloned" {
62
62
 
63
63
  expect_failures = [hcloud_zone_rrset.a]
64
64
  }
65
+
66
+ # A server running a monitor serves its page, status.<domain>, too.
67
+ run "monitor_page" {
68
+ command = plan
69
+
70
+ variables {
71
+ server = "watching"
72
+ zone = "example.com"
73
+ }
74
+
75
+ assert {
76
+ condition = contains(output.hosts, "status.example.com")
77
+ error_message = "status should be a host where the server runs a monitor"
78
+ }
79
+ }