dispach 0.1.2 → 0.1.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.
- package/README.md +134 -85
- package/dist/App-qfqvx9c7.js +11 -0
- package/dist/{App-b1yrwrcq.js.map → App-qfqvx9c7.js.map} +6 -7
- package/dist/ConfigEditor-apcnj4nj.js +6 -0
- package/dist/{ConfigEditor-n8hdw6r7.js.map → ConfigEditor-apcnj4nj.js.map} +2 -2
- package/dist/KeyProbe-ya5t3v3v.js +5 -0
- package/dist/{KeyProbe-9jjeze5r.js.map → KeyProbe-ya5t3v3v.js.map} +2 -2
- package/dist/Picker-b7mn0mjg.js +5 -0
- package/dist/{Picker-hfeh1g6m.js.map → Picker-b7mn0mjg.js.map} +1 -1
- package/dist/SessionPicker-vacfwczg.js +5 -0
- package/dist/{SessionPicker-zyqkg4dn.js.map → SessionPicker-vacfwczg.js.map} +2 -2
- package/dist/SkillBrowser-66ntwaa9.js +5 -0
- package/dist/{SkillBrowser-3qdp8080.js.map → SkillBrowser-66ntwaa9.js.map} +1 -1
- package/dist/WizardApp-123998yh.js +5 -0
- package/dist/{WizardApp-vzpbydy3.js.map → WizardApp-123998yh.js.map} +3 -3
- package/dist/agents.d.ts +19 -3
- package/dist/agents.d.ts.map +1 -1
- package/dist/channels-q4fwqq87.js +31 -0
- package/dist/channels-q4fwqq87.js.map +10 -0
- package/dist/channels.d.ts +26 -0
- package/dist/channels.d.ts.map +1 -0
- package/dist/client.js +10 -10
- package/dist/client.js.map +3 -3
- package/dist/config-64q4mgxc.js +24 -0
- package/dist/{config-g7za9x13.js.map → config-64q4mgxc.js.map} +2 -2
- package/dist/{credential-npr6z8c8.js → credential-2sj7vsmw.js} +5 -5
- package/dist/{credential-npr6z8c8.js.map → credential-2sj7vsmw.js.map} +1 -1
- package/dist/daemon.d.ts.map +1 -1
- package/dist/index-0k3w2mxf.js +6 -0
- package/dist/{index-hwpvhaza.js.map → index-0k3w2mxf.js.map} +1 -1
- package/dist/index-1s81qstp.js +6 -0
- package/dist/{index-v8e92nfw.js.map → index-1s81qstp.js.map} +1 -1
- package/dist/index-2rycma8x.js +12 -0
- package/dist/{index-258d8bzg.js.map → index-2rycma8x.js.map} +4 -3
- package/dist/index-2zye08c4.js +6 -0
- package/dist/{index-vgc3y3rm.js.map → index-2zye08c4.js.map} +2 -2
- package/dist/{index-gme2egyq.js → index-3km1jwh7.js} +4 -4
- package/dist/{index-gme2egyq.js.map → index-3km1jwh7.js.map} +1 -1
- package/dist/index-3mtgcvkq.js +429 -0
- package/dist/index-3mtgcvkq.js.map +11 -0
- package/dist/index-4knb5vjm.js +90 -0
- package/dist/index-4knb5vjm.js.map +13 -0
- package/dist/{index-3g3ny01d.js → index-5nwwekk0.js} +4 -4
- package/dist/{index-3g3ny01d.js.map → index-5nwwekk0.js.map} +1 -1
- package/dist/index-5rm7dwq4.js +6 -0
- package/dist/index-5rm7dwq4.js.map +11 -0
- package/dist/index-79epttpm.js +6 -0
- package/dist/index-79epttpm.js.map +10 -0
- package/dist/{index-4cf6v9nb.js → index-7yk1zvds.js} +4 -4
- package/dist/{index-4cf6v9nb.js.map → index-7yk1zvds.js.map} +1 -1
- package/dist/index-81gb4ey4.js +6 -0
- package/dist/{index-4z7axw4r.js.map → index-81gb4ey4.js.map} +1 -1
- package/dist/index-8a5d8sfe.js +6 -0
- package/dist/{index-0d93hyfc.js.map → index-8a5d8sfe.js.map} +1 -1
- package/dist/index-a21zyy54.js +6 -0
- package/dist/index-a21zyy54.js.map +9 -0
- package/dist/index-b6da6c16.js +92 -0
- package/dist/index-b6da6c16.js.map +15 -0
- package/dist/index-byxrc961.js +903 -0
- package/dist/{index-tv4yv7d2.js.map → index-byxrc961.js.map} +16 -15
- package/dist/{index-ammv5st7.js → index-cgfg6t5a.js} +6 -6
- package/dist/{index-ammv5st7.js.map → index-cgfg6t5a.js.map} +1 -1
- package/dist/{index-s9mbq7h6.js → index-ehzwdnc3.js} +4 -4
- package/dist/{index-s9mbq7h6.js.map → index-ehzwdnc3.js.map} +1 -1
- package/dist/index-fzmmhmk2.js +7 -0
- package/dist/index-fzmmhmk2.js.map +11 -0
- package/dist/index-g3pk0kc0.js +6 -0
- package/dist/{index-9r0wyj6w.js.map → index-g3pk0kc0.js.map} +2 -2
- package/dist/index-h828nk24.js +153 -0
- package/dist/index-h828nk24.js.map +20 -0
- package/dist/{index-02dn6m2j.js → index-jq999vcw.js} +5 -5
- package/dist/{index-02dn6m2j.js.map → index-jq999vcw.js.map} +2 -2
- package/dist/index-k2aq5bg0.js +9 -0
- package/dist/{index-6p999cx4.js.map → index-k2aq5bg0.js.map} +4 -6
- package/dist/{index-cqqb6gaq.js → index-k3y8y3wj.js} +5 -5
- package/dist/{index-cqqb6gaq.js.map → index-k3y8y3wj.js.map} +1 -1
- package/dist/index-k59wwdgz.js +9 -0
- package/dist/{index-ff514z3y.js.map → index-k59wwdgz.js.map} +3 -5
- package/dist/index-nmnnwa02.js +6 -0
- package/dist/{index-6q4wf8e3.js.map → index-nmnnwa02.js.map} +1 -1
- package/dist/index-nn3tk25c.js +6 -0
- package/dist/{index-d4x6yvqh.js.map → index-nn3tk25c.js.map} +3 -4
- package/dist/index-q0hxh57v.js +126 -0
- package/dist/index-q0hxh57v.js.map +14 -0
- package/dist/index-srmhk9g5.js +11 -0
- package/dist/index-srmhk9g5.js.map +11 -0
- package/dist/index-swtyfhha.js +6 -0
- package/dist/{index-fex44816.js.map → index-swtyfhha.js.map} +2 -2
- package/dist/index-whq42sat.js +6 -0
- package/dist/{index-h9mw7b9d.js.map → index-whq42sat.js.map} +1 -1
- package/dist/{index-j7gyr5nx.js → index-wzsmh5j0.js} +7 -7
- package/dist/{index-j7gyr5nx.js.map → index-wzsmh5j0.js.map} +1 -1
- package/dist/{index-j55s3ehk.js → index-x7v1zq89.js} +7 -7
- package/dist/{index-j55s3ehk.js.map → index-x7v1zq89.js.map} +2 -2
- package/dist/index-xhzmv4dh.js +66 -0
- package/dist/index-xhzmv4dh.js.map +12 -0
- package/dist/index-xmv47vs0.js +6 -0
- package/dist/{index-gz9x25tz.js.map → index-xmv47vs0.js.map} +2 -2
- package/dist/index-y4c32wn7.js +6 -0
- package/dist/{index-qdbq8crg.js.map → index-y4c32wn7.js.map} +2 -2
- package/dist/index-yjcdp72k.js +6 -0
- package/dist/{index-tf71ap9v.js.map → index-yjcdp72k.js.map} +1 -1
- package/dist/index-zn24991r.js +6 -0
- package/dist/index-zn24991r.js.map +10 -0
- package/dist/index.js +374 -443
- package/dist/index.js.map +23 -27
- package/dist/init.d.ts.map +1 -1
- package/dist/lib/channel-actions.d.ts +103 -0
- package/dist/lib/channel-actions.d.ts.map +1 -0
- package/dist/lib/chat-frame.d.ts +12 -1
- package/dist/lib/chat-frame.d.ts.map +1 -1
- package/dist/lib/commands.d.ts +13 -0
- package/dist/lib/commands.d.ts.map +1 -1
- package/dist/lib/const.d.ts +1 -1
- package/dist/lib/host-actions.d.ts +121 -0
- package/dist/lib/host-actions.d.ts.map +1 -0
- package/dist/lib/init-flow.d.ts +32 -0
- package/dist/lib/init-flow.d.ts.map +1 -1
- package/dist/lib/init-whatsapp.d.ts +52 -0
- package/dist/lib/init-whatsapp.d.ts.map +1 -0
- package/dist/lib/plugin-install.d.ts +120 -0
- package/dist/lib/plugin-install.d.ts.map +1 -0
- package/dist/lib/providers.d.ts.map +1 -1
- package/dist/lib/provision.d.ts.map +1 -1
- package/dist/lib/readme-table.d.ts +15 -0
- package/dist/lib/readme-table.d.ts.map +1 -0
- package/dist/lib/sandbox.d.ts +15 -0
- package/dist/lib/sandbox.d.ts.map +1 -1
- package/dist/lib/schema.d.ts +34 -1
- package/dist/lib/schema.d.ts.map +1 -1
- package/dist/lib/subcommand.d.ts.map +1 -1
- package/dist/lib/web-url.d.ts +15 -0
- package/dist/lib/web-url.d.ts.map +1 -0
- package/dist/lib/wizard.d.ts.map +1 -1
- package/dist/memory.d.ts.map +1 -1
- package/dist/model.d.ts.map +1 -1
- package/dist/plugins.d.ts +27 -8
- package/dist/plugins.d.ts.map +1 -1
- package/dist/restart.d.ts +21 -0
- package/dist/restart.d.ts.map +1 -0
- package/dist/run.d.ts.map +1 -1
- package/dist/schedules.d.ts.map +1 -1
- package/dist/serve.d.ts.map +1 -1
- package/dist/sessions.d.ts.map +1 -1
- package/dist/skills.d.ts.map +1 -1
- package/dist/status.d.ts +16 -0
- package/dist/status.d.ts.map +1 -0
- package/dist/tools.d.ts.map +1 -1
- package/dist/validate.d.ts.map +1 -1
- package/dist/web-923c7f5e.js +14 -0
- package/dist/{web-vkb16r62.js.map → web-923c7f5e.js.map} +3 -3
- package/dist/web.d.ts +2 -13
- package/dist/web.d.ts.map +1 -1
- package/dist/workspace.d.ts.map +1 -1
- package/dist/wrapper-0w9b3my0.js +11 -0
- package/dist/wrapper-0w9b3my0.js.map +23 -0
- package/package.json +6 -3
- package/dist/App-b1yrwrcq.js +0 -11
- package/dist/ConfigEditor-n8hdw6r7.js +0 -6
- package/dist/KeyProbe-9jjeze5r.js +0 -5
- package/dist/Picker-hfeh1g6m.js +0 -5
- package/dist/SessionPicker-zyqkg4dn.js +0 -5
- package/dist/SkillBrowser-3qdp8080.js +0 -5
- package/dist/WizardApp-vzpbydy3.js +0 -5
- package/dist/config-g7za9x13.js +0 -24
- package/dist/index-0d93hyfc.js +0 -6
- package/dist/index-1c5113t4.js +0 -66
- package/dist/index-1c5113t4.js.map +0 -12
- package/dist/index-258d8bzg.js +0 -12
- package/dist/index-4z7axw4r.js +0 -6
- package/dist/index-6p999cx4.js +0 -9
- package/dist/index-6q4wf8e3.js +0 -6
- package/dist/index-9r0wyj6w.js +0 -6
- package/dist/index-d4x6yvqh.js +0 -6
- package/dist/index-fecm8xe7.js +0 -77
- package/dist/index-fecm8xe7.js.map +0 -12
- package/dist/index-fex44816.js +0 -6
- package/dist/index-ff514z3y.js +0 -14
- package/dist/index-gz9x25tz.js +0 -6
- package/dist/index-h9mw7b9d.js +0 -6
- package/dist/index-hwpvhaza.js +0 -6
- package/dist/index-mtn0g9vc.js +0 -7
- package/dist/index-mtn0g9vc.js.map +0 -11
- package/dist/index-qdbq8crg.js +0 -6
- package/dist/index-tf71ap9v.js +0 -6
- package/dist/index-ttwyrdjs.js +0 -427
- package/dist/index-ttwyrdjs.js.map +0 -11
- package/dist/index-tv4yv7d2.js +0 -903
- package/dist/index-ty24n0jh.js +0 -167
- package/dist/index-ty24n0jh.js.map +0 -19
- package/dist/index-v8e92nfw.js +0 -6
- package/dist/index-vgc3y3rm.js +0 -6
- package/dist/index-whaw4b18.js +0 -6
- package/dist/index-whaw4b18.js.map +0 -10
- package/dist/web-vkb16r62.js +0 -14
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{o,I}from"./index-nn3tk25c.js";import{G}from"./index-zn24991r.js";import{Box as y,Text as d}from"ink";import{jsxs as r}from"react/jsx-runtime";function Be({items:e,index:n,numbered:t,maxRows:x}){let p=x===void 0?e.length:Math.max(1,x),{from:c,to:u}=G(e.length,n,p),m=e.slice(c,u).map((l,i)=>({at:c+i,item:l}));return r(y,{flexDirection:"column",children:[c>0?r(d,{dimColor:!0,wrap:"truncate",children:[" ",I.ellipsis," ",c," above"]}):null,m.map(({at:l,item:i})=>{let a=l===n,s=t===!0?`${l+1}. `:"";return r(d,{wrap:"truncate",...a?{color:o.accent}:{},children:[a?I.pointer:" ",r(d,{bold:a,children:[s,i.label]}),i.hint===void 0?"":r(d,{dimColor:!0,...a?{color:o.muted}:{},children:[" ",i.hint]})]},`row-${l}`)}),u<e.length?r(d,{dimColor:!0,wrap:"truncate",children:[" ",I.ellipsis," ",e.length-u," below"]}):null]})}function W(e,n){if(e.count===0)return e;let t=e.count-1;switch(n.kind){case"up":return{...e,index:Math.max(0,e.index-1)};case"down":return{...e,index:Math.min(t,e.index+1)};case"first":return{...e,index:0};case"last":return{...e,index:t};case"jump":return n.index<0||n.index>t?e:{...e,index:n.index}}}
|
|
3
|
+
export{Be,W};
|
|
4
|
+
|
|
5
|
+
//# debugId=ADDEF9D4F0A7A21564756E2164756E21
|
|
6
|
+
//# sourceMappingURL=index-xmv47vs0.js.map
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"/**\n * An arrow-key select list: ❯ on the selected row, hints dim, optional numbering.\n *\n * Controlled and presentational — `index` comes from the parent's reducer (`lib/select.ts`), and values\n * stay with the parent, which maps the index back to its own data. This component never listens to input;\n * the screen root owns the single `useInput`.\n *\n * ## Windowing\n *\n * `maxRows` is not decoration. This rendered every item it was given, which was fine for a sandbox of\n * three agents and is not fine for a store with fifty conversations: on the alternate screen a list taller\n * than the terminal pushes the frame apart, and there is no scrollback to recover it from. It windows\n * through `viewport` — the same function the composer and the catalogue use, because \"keep the selected\n * row visible\" is one rule and not three.\n *\n * Numbering stays **absolute** while windowed. A digit jumps the cursor by absolute index, so numbering\n * the visible rows 1..n would make `3` mean a different row depending on where the window sat. The\n * consequence, stated: digits reach the first nine rows and the arrows reach the rest.\n */\n\nimport { Box, Text } from \"ink\"\nimport { viewport } from \"#lib/rows\"\nimport { GLYPH, THEME } from \"#lib/theme\"\n\nexport interface SelectItem {\n readonly label: string\n /** Dim, after the label — a model id, a relative time, a one-line description. */\n readonly hint?: string\n}\n\nexport interface SelectListProps {\n readonly items: readonly SelectItem[]\n readonly index: number\n /** `1.`-style prefixes; digits then jump the cursor (they never choose). */\n readonly numbered?: boolean\n /** Visible rows before the list scrolls to follow the selection. Unbounded when omitted. */\n readonly maxRows?: number\n}\n\nexport function SelectList({ items, index, numbered, maxRows }: SelectListProps) {\n const window = maxRows === undefined ? items.length : Math.max(1, maxRows)\n const { from, to } = viewport(items.length, index, window)\n // Absolute row numbers computed before the map, so a React key is a position rather than a callback\n // index — and so the printed number does not change when the window moves.\n const visible = items.slice(from, to).map((item, offset) => ({ at: from + offset, item }))\n\n return (\n <Box flexDirection=\"column\">\n {from > 0 ? (\n <Text dimColor wrap=\"truncate\">\n {\" \"}\n {GLYPH.ellipsis} {from} above\n </Text>\n ) : null}\n {visible.map(({ at, item }) => {\n const selected = at === index\n const number = numbered === true ? `${at + 1}. ` : \"\"\n return (\n // `wrap=\"truncate\"` is the backstop, not the layout: a row wider than the frame\n // otherwise wraps onto a continuation line carrying no pointer and no number,\n // which reads as an extra list item. Label before hint, so what clips is the\n // reason rather than the thing being named.\n <Text\n key={`row-${at}`}\n wrap=\"truncate\"\n {...(selected ? { color: THEME.accent } : {})}\n >\n {selected ? GLYPH.pointer : \" \"}\n <Text bold={selected}>\n {number}\n {item.label}\n </Text>\n {item.hint === undefined ? (\n \"\"\n ) : (\n <Text dimColor {...(selected ? { color: THEME.muted } : {})}>\n {\" \"}\n {item.hint}\n </Text>\n )}\n </Text>\n )\n })}\n {to < items.length ? (\n <Text dimColor wrap=\"truncate\">\n {\" \"}\n {GLYPH.ellipsis} {items.length - to} below\n </Text>\n ) : null}\n </Box>\n )\n}\n",
|
|
6
6
|
"/**\n * List-cursor state: an index and the moves that change it. Pure, like every reducer here.\n */\n\nexport interface SelectState {\n readonly index: number\n readonly count: number\n}\n\nexport type SelectMove =\n | { readonly kind: \"up\" }\n | { readonly kind: \"down\" }\n | { readonly kind: \"first\" }\n | { readonly kind: \"last\" }\n /** 0-based. A digit key jumps the cursor — visibly and reversibly; it never chooses. */\n | { readonly kind: \"jump\"; readonly index: number }\n\nexport function moveSelect(state: SelectState, move: SelectMove): SelectState {\n if (state.count === 0) return state\n const last = state.count - 1\n switch (move.kind) {\n case \"up\":\n return { ...state, index: Math.max(0, state.index - 1) }\n case \"down\":\n return { ...state, index: Math.min(last, state.index + 1) }\n case \"first\":\n return { ...state, index: 0 }\n case \"last\":\n return { ...state, index: last }\n case \"jump\":\n return move.index < 0 || move.index > last ? state : { ...state, index: move.index }\n }\n}\n"
|
|
7
7
|
],
|
|
8
|
-
"mappings": ";
|
|
9
|
-
"debugId": "
|
|
8
|
+
"mappings": ";wEAoBA,cAAS,UAAK,qDAmBP,SAAS,EAAU,EAAG,QAAO,QAAO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,MAAO,KAAK,IAAI,EAAM,EAAM,MAAQ,CAAC,CAAE,MACzD,QACD,MAAO,IAAK,EAAO,MAAO,CAAE,MAC3B,OACD,MAAO,IAAK,EAAO,MAAO,CAAK,MAC9B,OACD,OAAO,EAAK,MAAQ,GAAK,EAAK,MAAQ,EAAO,EAAQ,IAAK,EAAO,MAAO,EAAK,KAAM",
|
|
9
|
+
"debugId": "ADDEF9D4F0A7A21564756E2164756E21",
|
|
10
10
|
"names": []
|
|
11
11
|
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{e,p,b,k,L,C}from"./index-byxrc961.js";import{Q,R}from"./index-fzmmhmk2.js";async function Ho(t,i,n){let s=[];if(t.length===0)for(let a of R(i)){if(a.problem!==void 0||a.id===void 0)continue;s.push({agentId:a.id,manifestPath:a.manifestPath})}else for(let a of t){let r=p(a);s.push({agentId:r.id??"",manifestPath:a})}let o=await f(async(a)=>new Map((await a.agentState.list()).filter((r)=>!r.enabled).map((r)=>[r.agentId,r.reason])),n);return s.map((a)=>{let r=o?.get(a.agentId),d=o?.has(a.agentId)===!0;return{...a,enabled:!d,...r===void 0?{}:{reason:r}}})}async function f(t,i){let n;try{return n=await L.open({path:i??Q()}),await t(n)}catch{return}finally{await n?.close()}}async function Bn(t,i,n,s){await f(async(o)=>{if(i)await o.agentState.enable(t);else await o.agentState.disable(t,new Date().toISOString(),n===void 0?void 0:n)},s)}async function fn(t,i){return await f(async(n)=>{let s=await n.agentState.get(t);if(s===void 0)return{enabled:!0};return{enabled:s.enabled,...s.reason===void 0?{}:{reason:s.reason}}},i)}async function ne(t,i){return await f(async(n)=>{let s=await n.leases.get(t);if(s===void 0)return;if(s.pid===process.pid||!k(s.pid))return;return s},i)}async function oe(t){return[...(await Oe(t)).filter((n)=>n.baseUrl!==void 0)].sort((n,s)=>n.agentId.localeCompare(s.agentId))[0]}async function Oe(t){return await f(async(i)=>(await i.leases.all()).filter((n)=>n.pid!==process.pid&&k(n.pid)),t)??[]}function H(t){return t===void 0||t===""?"":p(t).id??""}function fA(t){let i=process.env[`${e.envPrefix}API_TOKEN`];try{let n=b(t,{env:C([t])}),s=n.env[n.manifest.server.tokenEnv];return s===void 0||s===""?i:s}catch{return i===""?void 0:i}}async function fe(t,i,n,s){let o=t.baseUrl;if(o===void 0)return{ok:!1,status:0,detail:"this host serves no HTTP"};let a=s===void 0?void 0:fA(s);try{let r=await fetch(`${o}${i}`,{method:"POST",headers:{"content-type":"application/json",...a===void 0?{}:{authorization:`Bearer ${a}`}},body:JSON.stringify(n),signal:AbortSignal.timeout(c)});if(r.ok){let u=await r.json().catch(()=>{return});return{ok:!0,status:r.status,...u===void 0?{}:{body:u}}}let d=await r.json().catch(()=>{return});return{ok:!1,status:r.status,...d?.error?.message===void 0?{}:{detail:d.error.message},...d?.error?.hint===void 0?{}:{hint:d.error.hint}}}catch(r){return{ok:!1,status:0,detail:r instanceof Error?r.message:String(r)}}}async function YA(t,i,n,s){let o=t.baseUrl;if(o===void 0)return{ok:!1,status:0,detail:"this host serves no HTTP"};let a=s===void 0?void 0:fA(s);try{let r=await fetch(`${o}${n}`,{method:i,headers:a===void 0?{}:{authorization:`Bearer ${a}`},signal:AbortSignal.timeout(c)}),d=await r.json().catch(()=>{return});if(r.ok)return{ok:!0,status:r.status,...d===void 0?{}:{body:d}};let u=d;return{ok:!1,status:r.status,...u?.error?.message===void 0?{}:{detail:u.error.message},...u?.error?.hint===void 0?{}:{hint:u.error.hint}}}catch(r){return{ok:!1,status:0,detail:r instanceof Error?r.message:String(r)}}}var c=1e4;function Bt(t,i){for(let n of R(i))if(n.id===t)return n.manifestPath;return}
|
|
3
|
+
export{Ho,Bn,fn,ne,oe,Oe,H,fA,fe,YA,Bt};
|
|
4
|
+
|
|
5
|
+
//# debugId=4A3139EA63D4D70964756E2164756E21
|
|
6
|
+
//# sourceMappingURL=index-y4c32wn7.js.map
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"sourcesContent": [
|
|
5
5
|
"/**\n * Reaching a running host, and reading the durable on/off switch.\n *\n * Shared by `serve`, `stop` and `start`, because all three ask the same two questions and a second\n * answer to either is a disagreement waiting to happen: *which agents is this sandbox supposed to\n * run*, and *where is the process already running them*.\n *\n * **Why an HTTP request rather than a signal.** Since one process hosts several agents, stopping\n * one by signalling the lease holder takes every other agent in that process down with it. A signal\n * also cannot name an agent. So `stop` posts to the host, which disposes exactly one — and the\n * address comes off the lease row rather than from a manifest, because `--port` overrides the file,\n * `--port 0` picks one at random and a container republishes it. Guessing 7420 is how a second host\n * on 7421 becomes invisible to the one command that must never miss it.\n *\n * **The fallback is the old behaviour, not an error.** A lease with no address is a `run` REPL or an\n * embedded runtime — real states, serving no HTTP — and those are still stopped by signalling the\n * process, which is what `stop` did for every lease before any of this existed.\n */\n\nimport { dirname } from \"node:path\"\nimport {\n BRAND,\n type LeaseRecord,\n loadManifest,\n processAlive,\n readManifestHeader,\n SqliteStore,\n} from \"@dispach/core\"\nimport { ambientEnv } from \"#lib/ambient\"\nimport { listAgents, storePath } from \"#lib/sandbox\"\n\n/** An agent the sandbox holds, with the durable switch resolved. */\nexport interface HostableAgent {\n readonly agentId: string\n readonly manifestPath: string\n readonly enabled: boolean\n /** Why it was switched off, when somebody said. */\n readonly reason?: string\n}\n\n/**\n * The manifests a bare `serve` should host, and the ones it should not.\n *\n * A listing rather than a filter, because the caller has to *report* what it is skipping: an agent\n * missing from a banner with no line explaining it is the \"I set this up and it is not running\"\n * failure the switch exists to make explicable.\n *\n * Broken entries are dropped here rather than surfaced, and that is the one thing this hides: a\n * directory whose header will not parse has no id, so there is nothing to look the state up by and\n * nothing to serve. the agents listing is what shows those, and it shows them already.\n */\nexport async function hostableAgents(\n paths: readonly string[],\n env: Readonly<Record<string, string | undefined>>,\n store?: string,\n): Promise<readonly HostableAgent[]> {\n const found: { agentId: string; manifestPath: string }[] = []\n\n if (paths.length === 0) {\n // The bare form: whatever the sandbox holds. This is what the service unit runs, and it is\n // why `agent_state` exists — \"every agent here\" needs an answer to \"except which\".\n for (const agent of listAgents(env)) {\n if (agent.problem !== undefined || agent.id === undefined) continue\n found.push({ agentId: agent.id, manifestPath: agent.manifestPath })\n }\n } else {\n for (const manifestPath of paths) {\n // The header, not a full load: reading a manifest to learn its id must not depend on\n // the agent's credentials being present, which is the whole reason\n // `readManifestHeader` exists and why the picker is built on it.\n const header = readManifestHeader(manifestPath)\n found.push({ agentId: header.id ?? \"\", manifestPath })\n }\n }\n\n const disabled = await withStore(\n async (db) =>\n new Map(\n (await db.agentState.list())\n .filter((row) => !row.enabled)\n .map((row) => [row.agentId, row.reason]),\n ),\n store,\n )\n\n return found.map((entry) => {\n const reason = disabled?.get(entry.agentId)\n const off = disabled?.has(entry.agentId) === true\n return {\n ...entry,\n enabled: !off,\n ...(reason === undefined ? {} : { reason }),\n }\n })\n}\n\n/**\n * Open the store, ask one question, close it.\n *\n * Deliberately a second, short-lived connection rather than the one `Runtime.create` opens: the\n * answer is needed *before* the runtime exists, because it decides which agents the runtime is\n * asked for. Handing the runtime a caller-owned store would work and would move shutdown ownership\n * into the command, which is a larger change than one sequential read deserves — the migrations are\n * already applied, so this costs a couple of milliseconds.\n *\n * `undefined` on any failure, and the callers treat that as \"nothing is disabled\". A missing store\n * is the ordinary first-run state, and a `serve` that refused to start because it could not read an\n * on/off table would be a worse failure than the one it was guarding against.\n *\n * **The path is threaded rather than defaulted at each call site**, because `serve` honours\n * `--store` and these helpers did not — so a host serving out of one database would have read its\n * on/off switch from another. Invisible in normal use, where both resolve to the sandbox, and\n * wrong in exactly the configuration the tests use.\n */\nasync function withStore<T>(\n work: (store: SqliteStore) => Promise<T>,\n path?: string,\n): Promise<T | undefined> {\n let store: SqliteStore | undefined\n try {\n store = await SqliteStore.open({ path: path ?? storePath() })\n return await work(store)\n } catch {\n return undefined\n } finally {\n await store?.close()\n }\n}\n\n/** The durable switch, written from a command rather than through a host. */\nexport async function writeAgentState(\n agentId: string,\n enabled: boolean,\n reason?: string,\n store?: string,\n): Promise<void> {\n await withStore(async (db) => {\n if (enabled) await db.agentState.enable(agentId)\n else\n await db.agentState.disable(\n agentId,\n new Date().toISOString(),\n reason === undefined ? undefined : reason,\n )\n }, store)\n}\n\n/** Whether this agent is switched off, and why. */\nexport async function agentStateOf(\n agentId: string,\n store?: string,\n): Promise<{ enabled: boolean; reason?: string } | undefined> {\n return await withStore(async (db) => {\n const row = await db.agentState.get(agentId)\n if (row === undefined) return { enabled: true }\n return { enabled: row.enabled, ...(row.reason === undefined ? {} : { reason: row.reason }) }\n }, store)\n}\n\n/**\n * The live process serving this agent, if there is one.\n *\n * Liveness is re-checked here rather than trusted from the row, for the recorded reason: a boot\n * that fails *after* claiming leaves a lease seconds old with no process under it, and anything\n * reading a lease to decide what to do has to probe rather than believe the heartbeat.\n */\nexport async function liveHostOf(\n agentId: string,\n store?: string,\n): Promise<LeaseRecord | undefined> {\n return await withStore(async (db) => {\n const lease = await db.leases.get(agentId)\n if (lease === undefined) return undefined\n if (lease.pid === process.pid || !processAlive(lease.pid)) return undefined\n return lease\n }, store)\n}\n\n/**\n * Any live host with an HTTP address, for `start`.\n *\n * **Not `liveHostOf(agentId)`, and that is the whole reason this exists.** A stopped agent has no\n * lease — `dispose` released it — so looking for \"the host holding this agent\" finds nothing and\n * `start` would report that nothing was running while a host sat there ready to adopt it. Found by\n * running the pair in order rather than by reading either one.\n *\n * With several hosts this asks the first by agent id. Nondeterministic and harmless: any host can\n * serve any agent in the sandbox, and one that cannot look the manifest up answers `501` rather\n * than failing quietly.\n */\nexport async function anyLiveHost(store?: string): Promise<LeaseRecord | undefined> {\n const hosts = (await liveHosts(store)).filter((lease) => lease.baseUrl !== undefined)\n return [...hosts].sort((a, b) => a.agentId.localeCompare(b.agentId))[0]\n}\n\n/** Every live lease, for the commands that report on the whole sandbox. */\nexport async function liveHosts(store?: string): Promise<readonly LeaseRecord[]> {\n return (\n (await withStore(\n async (db) =>\n (\n await db.leases.all()\n ).filter((lease) => lease.pid !== process.pid && processAlive(lease.pid)),\n store,\n )) ?? []\n )\n}\n\n/**\n * The credential a running host will want, best effort.\n *\n * The manifest's live env is the authority — that is where `serve` itself read the token from — so\n * this loads it. When the load fails it falls back to the process environment under the brand's\n * default variable, because the common reason for a failed load is a missing *model* key and\n * refusing to stop an agent over that would be absurd. A wrong or absent token is not silent: the\n * request comes back `401` and the caller says which variable to set.\n */\n/**\n * The agent id a manifest declares, without loading it.\n *\n * `readManifestHeader` rather than `loadManifest` for the reason `lib/sandbox.ts` already records:\n * loading checks that the key variables are set, so a *lookup* built on it fails exactly when the\n * agent is misconfigured — which is when you most need to name it. Here that would mean `run` and\n * `web` refusing to find a host for an agent whose `.env` is incomplete.\n */\nexport function agentIdFor(manifestPath: string | undefined): string {\n return manifestPath === undefined || manifestPath === \"\"\n ? \"\"\n : (readManifestHeader(manifestPath).id ?? \"\")\n}\n\nexport function hostToken(manifestPath: string): string | undefined {\n const fallback = process.env[`${BRAND.envPrefix}API_TOKEN`]\n try {\n const loaded = loadManifest(manifestPath, { env: ambientEnv([manifestPath]) })\n const configured = loaded.env[loaded.manifest.server.tokenEnv]\n return configured === undefined || configured === \"\" ? fallback : configured\n } catch {\n return fallback === \"\" ? undefined : fallback\n }\n}\n\nexport interface HostReply {\n readonly ok: boolean\n readonly status: number\n /** The server's own `error.message`, when it sent one. */\n readonly detail?: string\n /**\n * The parsed success body, for the callers that need one.\n *\n * `stop` and `start` only ever asked whether it worked, so this was discarded. Minting a\n * credential is the first caller that needs what came back — the secret is printed **once** and\n * exists nowhere else, so throwing the body away would make the command useless.\n */\n readonly body?: unknown\n /** The server's `error.hint`, which is the half a person acts on. */\n readonly hint?: string\n}\n\n/**\n * POST to a running host, with a bounded wait.\n *\n * Bounded because the alternative is a stop command that hangs on a wedged host, and the whole\n * brief for `stop` is that a person reaching for it is not in a position to go investigating. A\n * timeout falls through to the process-level stop, which is the thing that works on a host that has\n * stopped answering.\n */\nexport async function postToHost(\n lease: LeaseRecord,\n path: string,\n body: Readonly<Record<string, unknown>>,\n manifestPath?: string,\n): Promise<HostReply> {\n const base = lease.baseUrl\n if (base === undefined) return { ok: false, status: 0, detail: \"this host serves no HTTP\" }\n const token = manifestPath === undefined ? undefined : hostToken(manifestPath)\n\n try {\n const response = await fetch(`${base}${path}`, {\n method: \"POST\",\n headers: {\n \"content-type\": \"application/json\",\n ...(token === undefined ? {} : { authorization: `Bearer ${token}` }),\n },\n body: JSON.stringify(body),\n signal: AbortSignal.timeout(HOST_TIMEOUT_MS),\n })\n if (response.ok) {\n const body: unknown = await response.json().catch(() => undefined)\n return {\n ok: true,\n status: response.status,\n ...(body === undefined ? {} : { body }),\n }\n }\n const parsed = (await response.json().catch(() => undefined)) as\n | { error?: { message?: string; hint?: string } }\n | undefined\n return {\n ok: false,\n status: response.status,\n ...(parsed?.error?.message === undefined ? {} : { detail: parsed.error.message }),\n ...(parsed?.error?.hint === undefined ? {} : { hint: parsed.error.hint }),\n }\n } catch (error) {\n return {\n ok: false,\n status: 0,\n detail: error instanceof Error ? error.message : String(error),\n }\n }\n}\n\n/**\n * Any method against a running host, with the same bound and the same error shape.\n *\n * `postToHost` is this with `POST` and a body; both exist because a `GET` with a `content-type` and\n * an empty body is a request some proxies mangle, and because the one-method version read better at\n * the four call sites that had it. This is what `credential list` and `credential revoke` need.\n */\nexport async function callHost(\n lease: LeaseRecord,\n method: string,\n path: string,\n manifestPath?: string,\n): Promise<HostReply> {\n const base = lease.baseUrl\n if (base === undefined) return { ok: false, status: 0, detail: \"this host serves no HTTP\" }\n const token = manifestPath === undefined ? undefined : hostToken(manifestPath)\n try {\n const response = await fetch(`${base}${path}`, {\n method,\n headers: token === undefined ? {} : { authorization: `Bearer ${token}` },\n signal: AbortSignal.timeout(HOST_TIMEOUT_MS),\n })\n const body: unknown = await response.json().catch(() => undefined)\n if (response.ok) {\n return { ok: true, status: response.status, ...(body === undefined ? {} : { body }) }\n }\n const parsed = body as { error?: { message?: string; hint?: string } } | undefined\n return {\n ok: false,\n status: response.status,\n ...(parsed?.error?.message === undefined ? {} : { detail: parsed.error.message }),\n ...(parsed?.error?.hint === undefined ? {} : { hint: parsed.error.hint }),\n }\n } catch (error) {\n return {\n ok: false,\n status: 0,\n detail: error instanceof Error ? error.message : String(error),\n }\n }\n}\n\n/** Long enough for a dispose that waits on a channel to stop, short enough not to read as a hang. */\nconst HOST_TIMEOUT_MS = 10_000\n\n/** The sandbox manifest declaring this id, for the host's `resolveAgent` lookup. */\nexport function manifestForId(\n agentId: string,\n env?: Readonly<Record<string, string | undefined>>,\n): string | undefined {\n for (const agent of listAgents(env)) {\n if (agent.id === agentId) return agent.manifestPath\n }\n return undefined\n}\n\n/** The directory an agent's manifest sits in, for messages that name a `.env`. */\nexport function agentDirOf(manifestPath: string): string {\n return dirname(manifestPath)\n}\n"
|
|
6
6
|
],
|
|
7
|
-
"mappings": ";kFAmDA,eAAsB,EAAc,CAChC,EACA,EACA,EACiC,CACjC,IAAM,EAAqD,CAAC,EAE5D,GAAI,EAAM,SAAW,EAGjB,QAAW,KAAS,EAAW,CAAG,EAAG,CACjC,GAAI,EAAM,UAAY,QAAa,EAAM,KAAO,OAAW,SAC3D,EAAM,KAAK,CAAE,QAAS,EAAM,GAAI,aAAc,EAAM,YAAa,CAAC,EAGtE,aAAW,KAAgB,EAAO,CAI9B,IAAM,EAAS,EAAmB,CAAY,EAC9C,EAAM,KAAK,CAAE,QAAS,EAAO,IAAM,GAAI,cAAa,CAAC,EAI7D,IAAM,EAAW,MAAM,EACnB,MAAO,IACH,IAAI,KACC,MAAM,EAAG,WAAW,KAAK,GACrB,OAAO,CAAC,IAAQ,CAAC,EAAI,OAAO,EAC5B,IAAI,CAAC,IAAQ,CAAC,EAAI,QAAS,EAAI,MAAM,CAAC,CAC/C,EACJ,CACJ,EAEA,OAAO,EAAM,IAAI,CAAC,IAAU,CACxB,IAAM,EAAS,GAAU,IAAI,EAAM,OAAO,EACpC,EAAM,GAAU,IAAI,EAAM,OAAO,IAAM,GAC7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./index-byxrc961.js";import{existsSync as b,readFileSync as E}from"node:fs";import{dirname as l,join as o,resolve as u}from"node:path";function LA(n){let e=o(l(n),".env"),r={};if(b(e))try{r=be(E(e,"utf8"))}catch{}return Rt(r,C([n]))}function ko(n,e){let r=n[e];return r!==void 0&&r!==""}function f(n,e,r={}){let i=l(n),t=u(r.cwd??process.cwd()),d=r.readDir??lo,v=r.env??process.env,g=C([n],r),m=d(i),p=d(t),a=g[e];if(a!==void 0&&a!==""){let y=u(i)===t,c=p[e];if(!y&&c!==void 0&&v[e]===c)return{kind:"ambiguous",path:o(t,".env")};return{kind:"export"}}let s=m[e];if(s!==void 0&&s!=="")return{kind:"agent",path:o(i,".env")};return{kind:"unset"}}function Oo(n){switch(n.kind){case"export":return"from the environment, not a .env file";case"ambiguous":return"from the environment or ./.env — indistinguishable";case"agent":return;case"unset":return"not set"}}function No(n){let e=[],r=h(n.rawModelId);if(r!==void 0)e.push({field:"model.main.id",variable:r,origin:f(n.manifestPath,r,n.options??{})});if(n.apiKeyEnv!==void 0)e.push({field:"model.main.apiKeyEnv",variable:n.apiKeyEnv,origin:f(n.manifestPath,n.apiKeyEnv,n.options??{})});return e}function h(n){if(n===void 0)return;return/^\$\{([A-Za-z_][A-Za-z0-9_]*)\}$/.exec(n.trim())?.[1]}
|
|
3
|
+
export{LA,ko,Oo,No};
|
|
4
|
+
|
|
5
|
+
//# debugId=BCF9590A293B590F64756E2164756E21
|
|
6
|
+
//# sourceMappingURL=index-yjcdp72k.js.map
|
|
@@ -5,6 +5,6 @@
|
|
|
5
5
|
"/**\n * Whether a variable an agent depends on is actually set, from that agent's point of view.\n *\n * `ambientEnv` is **not** this. It layers the *cwd*'s `.env` against an agent's — demoting a colliding\n * variable so a project checkout cannot silently change which model a sandbox agent runs on — and it\n * returns `process.env` unchanged whenever nothing is in tension. It never *adds* the agent's own file.\n *\n * The agent's `.env` is merged by `loadManifest`, through core's `layeredEnv`, and that is the answer a\n * question about this agent needs. Reading `process.env` alone reported a variable as unset while the\n * file beside the manifest plainly had it — the same class of mistake `serve` made once, reporting\n * \"unauthenticated\" for a token sitting next to the manifest. It showed up here as an editor row that\n * still read `(not set)` immediately after somebody set it, which is the \"did that work?\" failure this\n * whole surface exists to remove.\n *\n * Precedence is core's, unchanged: the real environment wins, because an operator's export has to beat\n * a file for a container to be able to configure the agent it runs.\n */\n\nimport { existsSync, readFileSync } from \"node:fs\"\nimport { dirname, join, resolve } from \"node:path\"\nimport { type EnvSource, layeredEnv, parseDotEnv } from \"@dispach/core\"\nimport { type AmbientOptions, ambientEnv, readDotEnv } from \"#lib/ambient\"\n\n/** The environment this agent will actually see: its own `.env` under the ambient one. */\nexport function agentEnv(manifestPath: string): EnvSource {\n const path = join(dirname(manifestPath), \".env\")\n let beside: Record<string, string> = {}\n if (existsSync(path)) {\n try {\n beside = parseDotEnv(readFileSync(path, \"utf8\"))\n } catch {\n // An unreadable `.env` is reported by the loader, in the words the loader uses. Here it\n // simply means nothing is known to be set, which is the safe reading for a \"is it set?\"\n // question — claiming a variable is present when the file cannot be read would be worse.\n }\n }\n return layeredEnv(beside, ambientEnv([manifestPath]))\n}\n\n/** Whether `name` has a non-empty value. Empty counts as unset: it fails a load exactly as absent does. */\nexport function isSet(env: EnvSource, name: string): boolean {\n const value = env[name]\n return value !== undefined && value !== \"\"\n}\n\n/**\n * Where a value came from, which is a different question from whether it is set.\n *\n * Three layers can supply one variable and the winner is not obvious from any of them:\n *\n * 1. the real environment — an operator's export, or a container's `environment:` block\n * 2. the `.env` beside the agent's manifest\n * 3. a `.env` in the directory the command was run from, demoted beneath (2) by `ambientEnv`\n *\n * Every one of those is correct on its own, and the composition is unreadable. It produced a real\n * confusion in a container: `docker compose` passes `MODEL_ID` and friends as process environment,\n * so an agent scaffolded inside that container silently ran on the *mounted*\n * agent's model, and the `0600` `.env` that `init` had just written was ignored for exactly those\n * keys — with nothing anywhere saying so.\n *\n * The precedence is not the bug and is not changed here. What was missing is a sentence, and the\n * recorded lesson from the last time this surfaced is that *a warning explained the surprise and\n * did not remove it* — so this reports rather than intervenes.\n */\nexport type EnvOrigin =\n /** The real environment won: an export, or a container's own configuration. */\n | { readonly kind: \"export\" }\n /** The `.env` beside the manifest won. */\n | { readonly kind: \"agent\"; readonly path: string }\n /**\n * Either an export or the cwd's `.env`, and **they cannot be told apart**.\n *\n * Bun auto-loads a `.env` from the current directory into `process.env` before any of this code\n * runs, so once the two agree on a string there is no evidence left distinguishing them. Said\n * rather than guessed: naming one would be a coin toss printed as a fact.\n */\n | { readonly kind: \"ambiguous\"; readonly path: string }\n | { readonly kind: \"unset\" }\n\n/**\n * Which layer supplies `name` for this agent.\n *\n * Mirrors `ambientEnv`'s precedence by *calling* it rather than by restating it — the demotion rule\n * is subtle (a cwd variable is demoted only when the agent's own file also sets it *and* the values\n * match), and a second implementation of that would drift on the first edit.\n */\nexport function sourceOf(\n manifestPath: string,\n name: string,\n options: AmbientOptions = {},\n): EnvOrigin {\n const agentDir = dirname(manifestPath)\n const cwd = resolve(options.cwd ?? process.cwd())\n const read = options.readDir ?? readDotEnv\n const raw = options.env ?? process.env\n\n const ambient = ambientEnv([manifestPath], options)\n const beside = read(agentDir)\n const inCwd = read(cwd)\n\n const fromAmbient = ambient[name]\n if (fromAmbient !== undefined && fromAmbient !== \"\") {\n // The cwd file is only a candidate when it is a *different* directory from the agent's: when\n // they are the same directory, that file **is** the agent's own and `ambientEnv` says so.\n const sameDir = resolve(agentDir) === cwd\n const cwdValue = inCwd[name]\n if (!sameDir && cwdValue !== undefined && raw[name] === cwdValue) {\n return { kind: \"ambiguous\", path: join(cwd, \".env\") }\n }\n return { kind: \"export\" }\n }\n\n const fromFile = beside[name]\n if (fromFile !== undefined && fromFile !== \"\") {\n return { kind: \"agent\", path: join(agentDir, \".env\") }\n }\n\n return { kind: \"unset\" }\n}\n\n/**\n * The phrase for a status line — short, because it rides after a value somebody is already reading.\n *\n * Returns `undefined` for the ordinary case, which is the whole point: a line that always carries a\n * provenance note is a line nobody reads it on. The agent's own `.env` winning is what an author\n * expects, so only the surprising sources say anything.\n */\nexport function describeOrigin(origin: EnvOrigin): string | undefined {\n switch (origin.kind) {\n case \"export\":\n return \"from the environment, not a .env file\"\n case \"ambiguous\":\n return \"from the environment or ./.env — indistinguishable\"\n case \"agent\":\n return undefined\n case \"unset\":\n return \"not set\"\n }\n}\n\n/** One env-backed field, the variable behind it, and where the value came from. */\nexport interface Provenance {\n readonly field: string\n readonly variable: string\n readonly origin: EnvOrigin\n}\n\n/**\n * The env-backed fields worth saying something about, and only when there is something to say.\n *\n * Two fields, chosen because they are the two that produced a real confusion in a container:\n * `docker compose` passes `MODEL_ID` and `MODEL_API_KEY` as process environment, and the ambient\n * environment deliberately beats the agent's own file so an operator can configure the agent their\n * container runs. So an agent scaffolded in that container ran on the *mounted*\n * agent's model and ignored the `0600` `.env` init had just written.\n *\n * The model id is included **only when the manifest writes it as a variable**. A generated manifest\n * carries it literally (which is why `readManifestHeader` can list agents without credentials), and\n * a literal has no provenance to report — printing \"from the environment\" about a value nothing read\n * from the environment would be worse than silence. `apiKeyEnv` is always a variable name by hard\n * rule 10, so it is always askable.\n */\nexport function envProvenance(input: {\n readonly manifestPath: string\n /** The raw, unexpanded `model.main.id` — `readManifestHeader().modelId`. */\n readonly rawModelId: string | undefined\n readonly apiKeyEnv: string | undefined\n readonly options?: AmbientOptions\n}): readonly Provenance[] {\n const rows: Provenance[] = []\n const variable = soleVariable(input.rawModelId)\n if (variable !== undefined) {\n rows.push({\n field: \"model.main.id\",\n variable,\n origin: sourceOf(input.manifestPath, variable, input.options ?? {}),\n })\n }\n if (input.apiKeyEnv !== undefined) {\n rows.push({\n field: \"model.main.apiKeyEnv\",\n variable: input.apiKeyEnv,\n origin: sourceOf(input.manifestPath, input.apiKeyEnv, input.options ?? {}),\n })\n }\n return rows\n}\n\n/**\n * The variable name when a value is exactly one `${VAR}` reference, and nothing otherwise.\n *\n * Deliberately narrow. `prefix-${VAR}` expands from the environment too, but its provenance is a\n * sentence about part of a string, and a half-true note on a compound value is the kind of detail\n * that gets believed whole.\n */\nfunction soleVariable(raw: string | undefined): string | undefined {\n if (raw === undefined) return undefined\n const match = /^\\$\\{([A-Za-z_][A-Za-z0-9_]*)\\}$/.exec(raw.trim())\n return match?.[1]\n}\n"
|
|
6
6
|
],
|
|
7
7
|
"mappings": ";4CAkBA,qBAAS,kBAAY,gBACrB,kBAAS,UAAS,aAAM,kBAKjB,SAAS,EAAQ,CAAC,EAAiC,CACtD,IAAM,EAAO,EAAK,EAAQ,CAAY,EAAG,MAAM,EAC3C,EAAiC,CAAC,EACtC,GAAI,EAAW,CAAI,EACf,GAAI,CACA,EAAS,GAAY,EAAa,EAAM,MAAM,CAAC,EACjD,KAAM,EAMZ,OAAO,GAAW,EAAQ,EAAW,CAAC,CAAY,CAAC,CAAC,EAIjD,SAAS,EAAK,CAAC,EAAgB,EAAuB,CACzD,IAAM,EAAQ,EAAI,GAClB,OAAO,IAAU,QAAa,IAAU,GA4CrC,SAAS,CAAQ,CACpB,EACA,EACA,EAA0B,CAAC,EAClB,CACT,IAAM,EAAW,EAAQ,CAAY,EAC/B,EAAM,EAAQ,EAAQ,KAAO,QAAQ,IAAI,CAAC,EAC1C,EAAO,EAAQ,SAAW,GAC1B,EAAM,EAAQ,KAAO,QAAQ,IAE7B,EAAU,EAAW,CAAC,CAAY,EAAG,CAAO,EAC5C,EAAS,EAAK,CAAQ,EACtB,EAAQ,EAAK,CAAG,EAEhB,EAAc,EAAQ,GAC5B,GAAI,IAAgB,QAAa,IAAgB,GAAI,CAGjD,IAAM,EAAU,EAAQ,CAAQ,IAAM,EAChC,EAAW,EAAM,GACvB,GAAI,CAAC,GAAW,IAAa,QAAa,EAAI,KAAU,EACpD,MAAO,CAAE,KAAM,YAAa,KAAM,EAAK,EAAK,MAAM,CAAE,EAExD,MAAO,CAAE,KAAM,QAAS,EAG5B,IAAM,EAAW,EAAO,GACxB,GAAI,IAAa,QAAa,IAAa,GACvC,MAAO,CAAE,KAAM,QAAS,KAAM,EAAK,EAAU,MAAM,CAAE,EAGzD,MAAO,CAAE,KAAM,OAAQ,EAUpB,SAAS,EAAc,CAAC,EAAuC,CAClE,OAAQ,EAAO,UACN,SACD,MAAO,4CACN,YACD,MAAO,yDACN,QACD,WACC,QACD,MAAO,WA0BZ,SAAS,EAAa,CAAC,EAMJ,CACtB,IAAM,EAAqB,CAAC,EACtB,EAAW,EAAa,EAAM,UAAU,EAC9C,GAAI,IAAa,OACb,EAAK,KAAK,CACN,MAAO,gBACP,WACA,OAAQ,EAAS,EAAM,aAAc,EAAU,EAAM,SAAW,CAAC,CAAC,CACtE,CAAC,EAEL,GAAI,EAAM,YAAc,OACpB,EAAK,KAAK,CACN,MAAO,uBACP,SAAU,EAAM,UAChB,OAAQ,EAAS,EAAM,aAAc,EAAM,UAAW,EAAM,SAAW,CAAC,CAAC,CAC7E,CAAC,EAEL,OAAO,EAUX,SAAS,CAAY,CAAC,EAA6C,CAC/D,GAAI,IAAQ,OAAW,OAEvB,MADc,mCAAmC,KAAK,EAAI,KAAK,CAAC,IACjD",
|
|
8
|
-
"debugId": "
|
|
8
|
+
"debugId": "BCF9590A293B590F64756E2164756E21",
|
|
9
9
|
"names": []
|
|
10
10
|
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
function i(e){if(e<1000)return String(e);let n=e/1000;return n<10?`${n.toFixed(1)}k`:`${Math.round(n)}k`}function mi(e,n,r){if(r)return"installed";let t=i(e);return n===0?t:`${t} · ${n} script${n===1?"":"s"}`}function D(e,n){if(n<=0)return"";let r=e.replace(/\s+/g," ").trim();if(r.length<=n)return r;if(n===1)return"…";return`${r.slice(0,n-1)}…`}function Vt(e,n,r={}){let t=Math.max(18,Math.min(r.nameMax??34,n)),o=18,a=6;if(a+t+o>e)o=Math.max(6,e-a-t);if(a+t+o>e)t=Math.max(6,e-a-o);let m=e-(a+t+o+2);if(e<60||m<24)return{name:t,meta:o,description:0};return{name:t,meta:o,description:m}}function Wt(e,n){return{name:D(e.name,n.name).padEnd(n.name),meta:D(e.meta,n.meta).padEnd(n.meta),description:n.description===0?"":D(e.description,n.description)}}function Zt(e,n){let r=D(e,Math.max(0,n-8)),t=r.length+3;return`${r} ${"─".repeat(Math.max(0,Math.min(n,80)-t))}`}function G(e,n,r){if(e<=r)return{from:0,to:e};let t=Math.floor(r/2),o=Math.min(Math.max(0,n-t),e-r);return{from:o,to:o+r}}
|
|
3
|
+
export{mi,D,Vt,Wt,Zt,G};
|
|
4
|
+
|
|
5
|
+
//# debugId=828B40E9F9AB911864756E2164756E21
|
|
6
|
+
//# sourceMappingURL=index-zn24991r.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/lib/rows.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"/**\n * Laying a catalogue row out in a fixed number of columns. Pure, so the layout is testable as strings.\n *\n * ## Why this is not a component's problem\n *\n * The first version put the name, the size and the whole description in one `<Text>` and let Ink wrap.\n * Every row longer than the terminal became two or three lines, the checkbox column stopped lining up,\n * and a list of forty skills was unreadable. Wrapping is not a styling detail in a list — it destroys the\n * one property a list has, which is that a row is a row.\n *\n * So the width arithmetic lives here, in one place, as functions over numbers and strings: pad the name to\n * a column, pad the meta to a column, give the description whatever is left, and **truncate every field\n * before it can wrap**. `Text` also carries `wrap=\"truncate\"` as a backstop, but a backstop is not a\n * layout — the columns have to add up, or the description gets cut at a width nobody chose.\n */\n\n/** Terminal columns below which the description is dropped rather than shown as three characters. */\nconst NARROW = 60\n/** The name column, wide enough for `create-architectural-decision-record` to be recognisable. */\nconst NAME_MIN = 18\nconst NAME_MAX = 34\n/** `12.3k · 15 scripts` is the widest realistic meta string. */\nconst META = 18\n/** Checkbox plus pointer, both two characters. */\nconst GUTTER = 4\nconst GAP = 2\n\n/** `2284` → `2.3k`. A row is scanned, not audited, and five digits of precision cost a column. */\nexport function compactTokens(tokens: number): string {\n if (tokens < 1000) return String(tokens)\n const thousands = tokens / 1000\n return thousands < 10 ? `${thousands.toFixed(1)}k` : `${Math.round(thousands)}k`\n}\n\nexport function metaOf(tokens: number, scripts: number, installed: boolean): string {\n if (installed) return \"installed\"\n const size = compactTokens(tokens)\n return scripts === 0 ? size : `${size} · ${scripts} script${scripts === 1 ? \"\" : \"s\"}`\n}\n\n/** Cut to `width`, with an ellipsis when anything was lost. Never returns more than `width`. */\nexport function clip(text: string, width: number): string {\n if (width <= 0) return \"\"\n const flat = text.replace(/\\s+/g, \" \").trim()\n if (flat.length <= width) return flat\n if (width === 1) return \"…\"\n return `${flat.slice(0, width - 1)}…`\n}\n\nexport interface RowColumns {\n readonly name: number\n readonly meta: number\n readonly description: number\n}\n\n/**\n * How wide each column is at a given terminal width.\n *\n * The name column flexes with the longest name actually present rather than being fixed: a catalogue of\n * short names should not leave a third of the row empty, and one long name should not push the\n * description off the screen. Clamped at both ends for both reasons.\n */\nexport function columnsFor(\n width: number,\n longestName: number,\n options: { readonly nameMax?: number } = {},\n): RowColumns {\n // Overridden by the plain path, whose names carry a `source/` prefix and which has no cursor to keep\n // near them. Passing a wider name column *without* going through this function is what pushed every\n // piped row twelve characters over the width it was laid out for.\n let name = Math.max(NAME_MIN, Math.min(options.nameMax ?? NAME_MAX, longestName))\n let meta = META\n\n // The name and meta columns shrink before anything else does. Without this the *fixed* part of the row\n // could exceed the terminal on its own — at 40 columns with a 34-character name it came to 60, so every\n // row wrapped no matter what the description did, which is the bug this module exists to remove.\n const chrome = GUTTER + GAP\n if (chrome + name + meta > width) meta = Math.max(6, width - chrome - name)\n if (chrome + name + meta > width) name = Math.max(6, width - chrome - meta)\n\n const description = width - (chrome + name + meta + GAP)\n // Below the threshold the description is dropped entirely. Three characters of a sentence is worse than\n // none: it takes the same column and carries no information.\n if (width < NARROW || description < 24) return { name, meta, description: 0 }\n return { name, meta, description }\n}\n\n/**\n * One row, exactly `width` characters wide or less, in three aligned columns.\n *\n * Returned as one string rather than as fields, because alignment is the whole point and a caller that\n * assembled the parts could get the padding wrong. Colour is applied by the component *around* this — the\n * arithmetic must not know about escape codes, which do not occupy columns and would break every count.\n */\nexport function layoutRow(\n input: {\n readonly name: string\n readonly meta: string\n readonly description: string\n },\n columns: RowColumns,\n): { readonly name: string; readonly meta: string; readonly description: string } {\n return {\n name: clip(input.name, columns.name).padEnd(columns.name),\n meta: clip(input.meta, columns.meta).padEnd(columns.meta),\n description: columns.description === 0 ? \"\" : clip(input.description, columns.description),\n }\n}\n\n/** A heading, drawn as a rule so groups separate without costing a blank line each. */\nexport function headingRule(label: string, width: number): string {\n const text = clip(label, Math.max(0, width - 8))\n const filled = text.length + 3\n return `${text} ${\"─\".repeat(Math.max(0, Math.min(width, 80) - filled))}`\n}\n\n/**\n * Which slice of a longer list to show.\n *\n * Shared by the catalogue list and the input box, which want the same rule for the same reason: both\n * are taller than their allowance and both have a position that must stay visible. It lives here rather\n * than in either component because the second caller is what proved it was layout arithmetic and not a\n * detail of one screen.\n *\n * Originally: Keeps the cursor inside the window rather than paging, because a cursor that jumps a\n * whole viewport loses the reader's place.\n */\nexport function viewport(\n total: number,\n index: number,\n window: number,\n): { readonly from: number; readonly to: number } {\n if (total <= window) return { from: 0, to: total }\n const half = Math.floor(window / 2)\n const from = Math.min(Math.max(0, index - half), total - window)\n return { from, to: from + window }\n}\n"
|
|
6
|
+
],
|
|
7
|
+
"mappings": ";AA4BO,SAAS,CAAa,CAAC,EAAwB,CAClD,GAAI,EAAS,KAAM,OAAO,OAAO,CAAM,EACvC,IAAM,EAAY,EAAS,KAC3B,OAAO,EAAY,GAAK,GAAG,EAAU,QAAQ,CAAC,KAAO,GAAG,KAAK,MAAM,CAAS,KAGzE,SAAS,EAAM,CAAC,EAAgB,EAAiB,EAA4B,CAChF,GAAI,EAAW,MAAO,YACtB,IAAM,EAAO,EAAc,CAAM,EACjC,OAAO,IAAY,EAAI,EAAO,GAAG,OAAU,WAAiB,IAAY,EAAI,GA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