kaizen-agent 1.75.0 → 1.75.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli/term-history.ts +49 -0
- package/cli/web.ts +11 -0
- package/package.json +1 -1
- package/web/board.html +8 -3
- package/web/board.js +1 -1
- package/web/notebook.js +1 -1
- package/web/term.js +48 -48
- package/web/term.ts +61 -22
- package/web/video.js +1 -1
package/web/term.ts
CHANGED
|
@@ -226,7 +226,7 @@ function mountTerm(el: HTMLElement, key: string, onEnd?: () => void): () => void
|
|
|
226
226
|
// pair as a paste and keeps the newline in its input instead of submitting.
|
|
227
227
|
const form = document.createElement("form");
|
|
228
228
|
form.className = "compose";
|
|
229
|
-
msg.placeholder = "
|
|
229
|
+
msg.placeholder = "Paste text here...";
|
|
230
230
|
msg.enterKeyHint = "send";
|
|
231
231
|
msg.autocomplete = "off";
|
|
232
232
|
msg.setAttribute("aria-label", "Message the agent");
|
|
@@ -266,32 +266,52 @@ function mountTerm(el: HTMLElement, key: string, onEnd?: () => void): () => void
|
|
|
266
266
|
const grid = document.createElement("div");
|
|
267
267
|
grid.className = "termgrid";
|
|
268
268
|
grid.hidden = true;
|
|
269
|
-
const
|
|
270
|
-
["⇧ Tab", "\x1b[Z"], ["?", "?"], ["/", "/"],
|
|
271
|
-
["Esc", "\x1b"], ["Tab", "\t"],
|
|
272
|
-
["^C", "\x03"], ["^D", "\x04"], ["^Z", "\x1a"],
|
|
273
|
-
["↑", arrow("A")], ["↓", arrow("B")], ["←", arrow("D")], ["→", arrow("C")],
|
|
274
|
-
["Home", "\x1b[H"], ["PgUp", "\x1b[5~"], ["PgDn", "\x1b[6~"], ["End", "\x1b[F"],
|
|
275
|
-
..."= : ; ! * $ % ^ < > ( ) { } [ ] | ~ - @".split(" ").map((c): [string, string] => [c, c]),
|
|
276
|
-
["Del", "\x1b[3~"], ["Ins", "\x1b[2~"], ["↵", "\r"],
|
|
277
|
-
...Array.from({ length: 12 }, (_, i): [string, string] => [
|
|
278
|
-
`F${i + 1}`, i < 4 ? `\x1bO${"PQRS"[i]}` : `\x1b[${[15, 17, 18, 19, 20, 21, 23, 24][i - 4]}~`,
|
|
279
|
-
]),
|
|
280
|
-
];
|
|
281
|
-
for (const [label, value] of extras) grid.append(key(label, () => {
|
|
269
|
+
const press = (value: string | (() => string)) => {
|
|
282
270
|
send({ t: "i", d: (mods.alt ? "\x1b" : "") + (typeof value === "function" ? value() : value) });
|
|
283
271
|
mods.alt = false;
|
|
284
272
|
bar?.querySelectorAll(".alt").forEach((b) => b.classList.remove("on"));
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
|
|
273
|
+
};
|
|
274
|
+
const group = (name: string) => {
|
|
275
|
+
const section = document.createElement("div");
|
|
276
|
+
section.className = "termkeygroup " + name;
|
|
277
|
+
grid.append(section);
|
|
278
|
+
return section;
|
|
279
|
+
};
|
|
280
|
+
const add = (parent: HTMLElement, label: string, value: string | (() => string), position?: string) => {
|
|
281
|
+
const b = key(label, () => press(value));
|
|
282
|
+
if (position) b.style.gridArea = position;
|
|
283
|
+
parent.append(b);
|
|
284
|
+
return b;
|
|
285
|
+
};
|
|
286
|
+
const primary = group("primary");
|
|
287
|
+
add(primary, "Esc", "\x1b", "1 / 1");
|
|
288
|
+
add(primary, "Tab", "\t", "1 / 2");
|
|
289
|
+
add(primary, "⇧ Tab", "\x1b[Z", "1 / 3");
|
|
290
|
+
primary.append(key("Ctrl", () => { pad.hidden = !pad.hidden; }));
|
|
291
|
+
add(primary, "^C", "\x03", "2 / 1");
|
|
292
|
+
add(primary, "^D", "\x04", "2 / 2");
|
|
293
|
+
add(primary, "^Z", "\x1a", "2 / 3");
|
|
288
294
|
const alt = key("Alt", () => {
|
|
289
295
|
mods.alt = !mods.alt;
|
|
290
296
|
bar?.querySelectorAll(".alt").forEach((b) => b.classList.toggle("on", mods.alt));
|
|
291
297
|
});
|
|
292
298
|
alt.className = "alt";
|
|
293
|
-
|
|
294
|
-
|
|
299
|
+
alt.style.gridArea = "2 / 4";
|
|
300
|
+
primary.append(alt);
|
|
301
|
+
add(primary, "↑", arrow("A"), "1 / 6");
|
|
302
|
+
add(primary, "←", arrow("D"), "2 / 5");
|
|
303
|
+
add(primary, "↓", arrow("B"), "2 / 6");
|
|
304
|
+
add(primary, "→", arrow("C"), "2 / 7");
|
|
305
|
+
const enter = add(primary, "↵", "\r", "1 / 8 / span 2 / 9");
|
|
306
|
+
enter.setAttribute("aria-label", "Enter");
|
|
307
|
+
enter.className = "enter";
|
|
308
|
+
const navigation = group("navigation");
|
|
309
|
+
for (const [label, value] of [["Home", "\x1b[H"], ["End", "\x1b[F"], ["PgUp", "\x1b[5~"], ["PgDn", "\x1b[6~"], ["Ins", "\x1b[2~"], ["Del", "\x1b[3~"]]) add(navigation, label, value);
|
|
310
|
+
navigation.append(key("Paste", () => { void paste(); }), key("Image", () => picker.click()));
|
|
311
|
+
const symbols = group("symbols");
|
|
312
|
+
for (const c of "? / = : ; ! * $ % ^ < > ( ) { } [ ] | ~ - @".split(" ")) add(symbols, c, c);
|
|
313
|
+
const functions = group("functions");
|
|
314
|
+
for (let i = 0; i < 12; i++) add(functions, `F${i + 1}`, i < 4 ? `\x1bO${"PQRS"[i]}` : `\x1b[${[15, 17, 18, 19, 20, 21, 23, 24][i - 4]}~`);
|
|
295
315
|
const history = document.createElement("div");
|
|
296
316
|
history.className = "termhistory";
|
|
297
317
|
history.hidden = true;
|
|
@@ -306,9 +326,24 @@ function mountTerm(el: HTMLElement, key: string, onEnd?: () => void): () => void
|
|
|
306
326
|
return Array.isArray(value) ? value.filter((s): s is string => typeof s === "string").slice(0, 100) : [];
|
|
307
327
|
} catch { return []; }
|
|
308
328
|
};
|
|
329
|
+
let savedHistory: string[] = [];
|
|
330
|
+
let historyStatus = "";
|
|
331
|
+
const loadHistory = async () => {
|
|
332
|
+
historyStatus = "Loading shell history…";
|
|
333
|
+
drawHistory();
|
|
334
|
+
try {
|
|
335
|
+
const response = await fetch("/pty/history", { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ key }) });
|
|
336
|
+
if (!response.ok) throw new Error("history unavailable");
|
|
337
|
+
const data = await response.json();
|
|
338
|
+
savedHistory = Array.isArray(data.history) ? data.history.filter((s: unknown): s is string => typeof s === "string") : [];
|
|
339
|
+
historyStatus = "";
|
|
340
|
+
} catch { historyStatus = "Could not load shell history. Reopen History to retry."; }
|
|
341
|
+
drawHistory();
|
|
342
|
+
};
|
|
309
343
|
const drawHistory = () => {
|
|
310
344
|
list.replaceChildren();
|
|
311
|
-
|
|
345
|
+
const entries = [...new Set([...readHistory(), ...savedHistory])];
|
|
346
|
+
for (const text of entries.filter((s) => s.toLowerCase().includes(filter.value.toLowerCase()))) {
|
|
312
347
|
const use = document.createElement("button");
|
|
313
348
|
use.type = "button";
|
|
314
349
|
use.textContent = text;
|
|
@@ -316,7 +351,11 @@ function mountTerm(el: HTMLElement, key: string, onEnd?: () => void): () => void
|
|
|
316
351
|
use.onclick = () => { msg.value = text; showPanel(""); msg.focus(); };
|
|
317
352
|
list.append(use);
|
|
318
353
|
}
|
|
319
|
-
if (
|
|
354
|
+
if (historyStatus) {
|
|
355
|
+
const status = document.createElement("p");
|
|
356
|
+
status.textContent = historyStatus;
|
|
357
|
+
list.append(status);
|
|
358
|
+
} else if (!list.childElementCount) list.textContent = filter.value ? "No matching commands." : "No saved shell commands or messages yet.";
|
|
320
359
|
};
|
|
321
360
|
filter.oninput = drawHistory;
|
|
322
361
|
history.append(filter, list);
|
|
@@ -354,7 +393,7 @@ function mountTerm(el: HTMLElement, key: string, onEnd?: () => void): () => void
|
|
|
354
393
|
msg.blur();
|
|
355
394
|
ta?.blur();
|
|
356
395
|
}
|
|
357
|
-
if (next === "history")
|
|
396
|
+
if (next === "history") void loadHistory();
|
|
358
397
|
};
|
|
359
398
|
for (const [label, name, svg] of [["Keyboard", "keys", keyboardIcon], ["History", "history", historyIcon]]) {
|
|
360
399
|
const b = key("", () => showPanel(name), false);
|
package/web/video.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* kaizen video page
|
|
1
|
+
/* kaizen video page 23a30ab41f16ba8c -- generated by bun run build:web from web/video.ts; do not edit */
|
|
2
2
|
(()=>{function Lr(e){return e.filter((t)=>!t.archived&&(t.kind==="run"&&t.status==="waiting"||t.pty?.alive&&t.pty.asking)).length}var lo=null,Tr=null,Mr=(e)=>{Tr=e};function co(e,t,n){if(ro++,lo=e,typeof window<"u")dispatchEvent(new Event("kz-all-cards"));Tr?.(e,t,n)}var ro=0,xr="",io=!1,Qs=!1,pu=2000,Er=0,Ar;async function dt(){if(io){Qs=!0;return}let e=Er+pu-Date.now();if(e>0){Ar??=setTimeout(()=>{Ar=void 0,dt()},e);return}Er=Date.now(),io=!0;do{Qs=!1;let t=ro;try{let n=await fetch("/state?all=1");if(!n.ok)continue;let s=await n.text(),a=s.replace(/"now":\d+\}$/,"");if(a===xr)continue;let{cards:o,projects:i,rail:r,agents:m}=JSON.parse(s);if(!Qs&&t===ro)xr=a,co(o,[...i,...r??[]],m)}catch{}}while(Qs);io=!1}var h={S:{project:null,projects:[],cards:[],now:Date.now(),all:!1,dir:null},all:new URLSearchParams(location.search).get("all")!=="0",dir:null,openKey:null,mode:null,modeKey:null,menuKey:null,flash:new Set,tab:"request",lastTab:"request",runDoc:null,clearMenu:!1,sevMenu:!1,wantTerm:null,wantPty:null,shells:[],setQ:"",setScope:"all",setPage:null,setBack:!1,pageGen:0,PL:[],shown:new Set((()=>{try{return JSON.parse(localStorage.getItem("kz-show"))||[]}catch(e){return[]}})())};var c=(e)=>document.getElementById(e),bn=(e)=>String(e).replace(/[&<>"]/g,(t)=>({"&":"&","<":"<",">":">",'"':"""})[t]);class po{s;constructor(e){this.s=e}toString(){return this.s}}var D=(e)=>new po(String(e)),Cr=(e)=>e instanceof po?e.s:Array.isArray(e)?e.map(Cr).join(""):e==null||e===!1?"":bn(e),l=(e,...t)=>D(e.reduce((n,s,a)=>n+Cr(t[a-1])+s)),H=(e)=>D(`<svg><use href="#i-${e}"/></svg>`),Hr=D('<div aria-busy="true" aria-label="Loading"><span class="skel" style="height:16px;width:35%;margin:20px 0 14px"></span>'+'<span class="skel" style="height:44px;margin-bottom:10px"></span>'.repeat(4)+"</div>"),mu=1500000;async function fu(e){if(e.size<=mu||!/^image\/(jpeg|png|webp|bmp|heic|heif)$/.test(e.type))return e;try{let t=await createImageBitmap(e),n=Math.min(1,2560/Math.max(t.width,t.height)),s=document.createElement("canvas");s.width=Math.round(t.width*n),s.height=Math.round(t.height*n),s.getContext("2d").drawImage(t,0,0,s.width,s.height);let a=await new Promise((o)=>s.toBlob(o,"image/jpeg",0.85));return a&&a.size<e.size?new File([a],e.name.replace(/\.\w+$/,"")+".jpg",{type:"image/jpeg"}):e}catch{return e}}var yn=(e)=>Promise.all(e.map(async(t)=>{let n=await fu(t);return new Promise((s)=>{let a=new FileReader;a.onload=()=>s({name:n.name,data:a.result}),a.readAsDataURL(n)})}));function Xe(e){let t=document.createElement("dialog");return t.className="kz",t.innerHTML=`<form class="inl" method="dialog">${e}</form>`,t.onclose=()=>t.remove(),t.onclick=(n)=>{if(n.target===t)t.close()},document.body.appendChild(t),t.showModal(),t}var ms=()=>{let e=document.documentElement.dataset.motion;return e?e==="full":!matchMedia("(prefers-reduced-motion: reduce)").matches},zn=(e)=>ms()&&document.startViewTransition?document.startViewTransition(e).updateCallbackDone:(e(),Promise.resolve()),uo=[5,25,50,100];function _s(e){let t=25;try{let n=Number(localStorage.getItem("kz-page:"+e));if(uo.includes(n))t=n}catch{}return{id:e,size:t,at:0,total:0}}function Ys(e,t){return e.total=t.length,e.at=Math.max(0,Math.min(e.at,Math.ceil(t.length/e.size)-1)),t.slice(e.at*e.size,(e.at+1)*e.size)}function Xs(e){if(e.total<=uo[0])return"";let t=e.at*e.size+1,n=Math.min(e.total,t+e.size-1);return l`<div class="kpager" id="pg-${e.id}"><label>Rows<select class="sel" aria-label="Rows per page">${uo.map((s)=>l`<option${s===e.size?D(" selected"):""}>${s}</option>`)}</select></label><span>${t}–${n} of ${e.total}</span><button class="btn sm" type="button" data-to="-1"${e.at?"":D(" disabled")}>Prev</button><button class="btn sm" type="button" data-to="1"${n<e.total?"":D(" disabled")}>Next</button></div>`}function Zs(e,t){let n=c("pg-"+e.id);if(!n)return;n.querySelector("select").onchange=(s)=>{e.size=+s.target.value,e.at=0;try{localStorage.setItem("kz-page:"+e.id,String(e.size))}catch{}t()},n.querySelectorAll("[data-to]").forEach((s)=>s.onclick=()=>{e.at+=+s.dataset.to,t()})}var hu=!1;try{hu=localStorage.getItem("kz-res-disk")==="1"}catch{}var qr=86400000,Se=(e,t)=>{let n=t-e;return n<3600000?Math.round(n/60000)+"m":n<86400000?Math.round(n/3600000)+"h":Math.round(n/86400000)+"d"},fs={claude:"Claude Code",codex:"Codex",agy:"Antigravity",opencode:"OpenCode",gemini:"Gemini",cursor:"Cursor",yolo:"yolo",unrechecked:"fix not rechecked"},jr={claude:1,codex:1,agy:1,opencode:1,gemini:1,cursor:1,full:1,lite:1},Rr=(e,t,n)=>t&&e.includes(t)?t:n?null:e[0]??null,Dr=["Tasks","Planning","Building","Review","Done"],_t={idea:"idea",starting:"start",running:"run",stalled:"stall",waiting:"wait",done:"done",abandoned:"aband"},gu={"approvals.plan":"plan needs your approval","approvals.review":"review needs your approval"},Lt=(e)=>gu[e]||e,Yt={idea:"idea",starting:"starting",running:"running",stalled:"stalled",waiting:"waiting on you",done:"done",abandoned:"abandoned"};var ye=(e)=>typeof e==="string"?[e]:e.kids.flatMap(ye);function Un(e,t){if(typeof e==="string")return t(e)?e:null;let n=[],s=[];if(e.kids.forEach((a,o)=>{let i=Un(a,t);if(i)n.push(i),s.push(e.sizes[o]??1)}),!n.length)return null;if(n.length===1)return n[0];return n.length===e.kids.length&&n.every((a,o)=>a===e.kids[o])?e:{dir:e.dir,kids:n,sizes:s}}var wn=(e,t)=>`ws:${e}:${t}`,kn=(e)=>e.kind==="run"&&e.status==="done"&&e.accept!=="needs"&&!e.archived&&e.git==="pending",ea=(e)=>e.gitDue==="push"?"push":"commit",$n=(e)=>e.kind==="run"&&(e.status==="abandoned"||e.status==="done"&&e.accept!=="needs"&&!kn(e)),Or=(e,t,n,s)=>e.state===t&&s(e)===n,ho=(e,t,n,s)=>e.filter((a)=>!a.archived&&Or(a,t,n,s)&&(a.kind==="idea"?!!a.pty:a.kind==="run"&&!$n(a))),go=(e,t,n,s)=>e.filter((a)=>$n(a)&&Or(a,t,n,s)).sort((a,o)=>(o.moved??0)-(a.moved??0));function zr(e,t,n,s){let a=!1;for(let o of t){let i=n(o),r=e[i];if(!r)continue;let m=e[wn(o.state,s(o))]||={tabs:[],hidden:[],screens:[],on:null},d=new Set(m.screens.flatMap((f)=>ye(f.tree)));for(let f of r.tabs??[])if(!m.tabs.some((y)=>y.id===f.id))m.tabs.push(f);for(let f of r.hidden??[])if(!m.hidden.includes(f))m.hidden.push(f);for(let f of r.screens??[]){let y=f.tree&&Un(f.tree,(u)=>!d.has(u));if(!y)continue;ye(y).forEach((u)=>d.add(u)),m.screens.push({...f,tree:y,focus:ye(y).includes(f.focus)?f.focus:ye(y)[0]})}m.on??=r.on,delete e[i],a=!0}return a}var vn=(e)=>e.kind==="run"&&(e.status==="waiting"||e.status==="done"&&e.accept==="needs"||kn(e)||!!(e.pty?.alive&&e.pty.asking)),Br=(e,t,n,s)=>ho(e,t,n,s).filter((a)=>a.kind==="run").sort((a,o)=>+vn(o)-+vn(a)||(o.moved??0)-(a.moved??0)),Ur=(e,t,n,s=(a)=>a.id)=>[...e,...t].find((a)=>s(a)===n)??e[0]??null;function bu(e){if(e?.kind!=="run")return{};let t=e?.pty?.all??[],n=e?.pty?.stages??{},s={};for(let i of["impl","review"])if(n[i]&&t.includes(n[i]))s[i]=n[i];if(n.plan&&t.includes(n.plan))s.plan=n.plan;let a=t.find((i)=>!Object.values(n).includes(i)),o={1:"plan",2:"impl",3:"review"}[e.column];if(a&&o&&!Object.keys(n).length)s[o]=a;return s}function Kr(e,t){let n={plan:"Plan",impl:"Build",review:"Review"},s=e?.pty?e.pty.all??[e.pty.key]:[],a=new Map(Object.entries(bu(e)).map(([m,d])=>[d,n[m]])),o=s.filter((m)=>!a.has(m)),i=n[{1:"plan",2:"impl",3:"review"}[e?.column]??""],r=s.at(-1);if(i&&r&&a.has(r))a.set(r,i);return s.map((m)=>({key:m,title:a.has(m)?`${a.get(m)} · ${t}`:t+(o.length>1?" "+(o.indexOf(m)+1):"")}))}var Wr=(e)=>e.kind==="run"&&(e.column===3||e.status==="done"),bo=(e)=>e?/https?:\/\/(?:localhost|127\.0\.0\.1|\[::1\])(?::\d+)?[^\s)`'"<>]*/.exec(e)?.[0]:void 0;function ta(e,t){let n=e?[...e.matchAll(/https?:\/\/(?:localhost|127\.0\.0\.1|\[::1\])(?::\d+)?[^\s)`'"<>]*/g)].map((a)=>a[0]):[],s=(a)=>Number(new URL(a).port||80);return n.find((a)=>t.includes(s(a)))??(t.length?`http://localhost:${t[0]}`:n[0])}var Gr=3000,na=new Map,hs=(e)=>e.key+"@"+(e.born??0),Pr={conflict:0,failed:0,asking:0,working:1,done:2},Bn={conflict:"Conflict",failed:"Land failed",asking:"Asking",working:"Working",done:"Done"},sa={conflict:"fail",failed:"fail",asking:"wait",working:"build",done:"done"};function yo(e,t,n=na){if(e.land)return e.land==="conflict"?"conflict":"failed";if(e.asking)return"asking";if(e.busy)return n.set(hs(e),t),"working";return t-(n.get(hs(e))??-1/0)<Gr?"working":"done"}var Fr=(e,t,n=na)=>Math.min(1/0,...e.filter((s)=>!s.asking&&!s.busy&&n.has(hs(s))).map((s)=>Gr-(t-n.get(hs(s)))).filter((s)=>s>0)),Vr=(e,t=na)=>{let n=new Set(e.map(hs));for(let s of t.keys())if(!n.has(s))t.delete(s)},Jr=(e,t,n,s,a,o=na)=>e.filter((i)=>i.dir===t&&s({state:i.dir,ws:i.ws})===n).map((i)=>({a:i,st:yo(i,a,o)})).sort((i,r)=>Pr[i.st]-Pr[r.st]),Nr=({a:e,st:t})=>(e.land?"":e.last)||`${Bn[t]} - ${e.name}`,Ir=(e,t)=>!e?"":t-e<60000?"now":Se(e,t),yu=(e,t)=>e+"\x00"+t;function Qr(e,t,n){let s=yu(t,n);if(e[s])delete e[s];else e[s]=!0;return e}var vu=["claude","codex","gemini"],mo=(e)=>l`<svg aria-hidden="true"><use href="#i-${vu.includes(e.agent??"")?e.agent:"ai"}"/></svg>`,fo=(e)=>l`<i class="si ${sa[e]}"></i>`,wu=l`<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M6 9l6 6 6-6" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>`;function _r(e,t,n,s,a){if(!e.length)return"";let o=l`data-dir="${s}" data-ws="${a}"`;if(e.length===1){let m=e[0];return l`<div class="wag"><button type="button" class="aone" data-term="${m.a.key}" ${o} title="${m.a.name}: open its terminal">${fo(m.st)}${mo(m.a)}<span class="atx">${Bn[m.st]} - ${m.a.name}</span><small>${Ir(m.a.at,t)}</small></button></div>`}let i=l`<button type="button" class="wchev${n?" on":""}" data-wopen ${o} aria-expanded="${String(n)}" aria-label="${String(e.length)} agents: ${n?"hide":"show"} the list">${wu}</button>`;if(n)return l`<div class="wag"><span class="aht">${String(e.length)} agents</span>${i}</div><div class="alist">${e.map((m)=>l`<button type="button" class="arow" data-term="${m.a.key}" ${o} title="${Nr(m)}">${fo(m.st)}${mo(m.a)}<span class="atx">${Nr(m)}</span><small>${Ir(m.a.at,t)}</small></button>`)}</div>`;let r=["conflict","failed","asking","working","done"].map((m)=>({st:m,rs:e.filter((d)=>d.st===m)})).filter((m)=>m.rs.length);return l`<div class="wag"><span class="chips">${r.map((m)=>l`<span class="chip">${fo(m.st)}${m.rs.map((d)=>l`<button type="button" class="amark" data-term="${d.a.key}" ${o} title="${d.a.name} - ${Bn[m.st]}: open its terminal" aria-label="${d.a.name} - ${Bn[m.st]}: open its terminal">${mo(d.a)}</button>`)}</span>`)}</span>${i}</div>`}function vo(e){return e.toLowerCase().trim().replace(/[^a-z0-9/._-]+/g,"-").replace(/\.{2,}/g,".").replace(/\/{2,}/g,"/").replace(/(^|\/)[-.]+/g,"$1").slice(0,60).replace(/[-./]+(\/|$)/g,"$1").replace(/\/$/,"").replace(/\.lock(\/|$)/g,"-lock$1")}var Yr;function T(e,t){let n=c("toast");if(n.textContent=e,n.classList.toggle("rep",!!t),t){let s=document.createElement("a");s.href="/issue?"+new URLSearchParams(t),s.target="_blank",s.rel="noopener",s.textContent="Report",n.append(" ",s)}n.classList.add("on"),clearTimeout(Yr),Yr=setTimeout(()=>n.classList.remove("on"),t?8000:4000)}function Tt(){try{if(typeof Notification<"u"&&Notification.permission==="default")Notification.requestPermission()}catch(e){}}var Zr=(e,t)=>{try{return localStorage.getItem(e)||t}catch(n){return t}},aa=()=>Zr("kz-notify","on")==="on",Kn=()=>Zr("kz-sound","Bellatrix"),el=["Adara","Alya","Bellatrix","Beryllium","Cobalt","Fluorine","Krypton","Palladium","Rubidium","Xenon"],oa=["off",...el,"chime","bell","pop"],Xr={chime:[[880,0,0.25],[1320,0.12,0.35]],bell:[[660,0,0.9]],pop:[[520,0,0.08]]},vt;function gs(e=Kn()){try{if(el.includes(e)){let n=new Audio(`/sounds/${e}.mp3`);n.volume=0.35,n.play().catch(()=>{});return}if(!Xr[e])return;vt=vt||new AudioContext,vt.resume();let t=vt.currentTime+0.02;for(let[n,s,a]of Xr[e]){let o=vt.createOscillator(),i=vt.createGain();o.type=e==="pop"?"triangle":"sine",o.frequency.value=n,i.gain.setValueAtTime(0.0001,t+s),i.gain.exponentialRampToValueAtTime(0.25,t+s+0.01),i.gain.exponentialRampToValueAtTime(0.0001,t+s+a),o.connect(i).connect(vt.destination),o.start(t+s),o.stop(t+s+a+0.05)}}catch(t){}}addEventListener("pointerdown",()=>{try{vt=vt||new AudioContext,vt.resume()}catch(e){}},{once:!0});function wo(e,t){if(!aa())return;gs();try{if(typeof Notification<"u"&&Notification.permission==="granted")new Notification("kaizen",{body:e,icon:"/logo.png",tag:t})}catch(n){}}var ia=null,ra=null,tl=null,Sn=(e)=>e.pty?"running in its workspace":"opened in your terminal",bs=()=>tl||=new Promise((e,t)=>{let n=document.createElement("link");n.rel="stylesheet",n.href="/term.css",document.head.append(n);let s=document.createElement("script");s.src="/term.js",s.onload=()=>e(window.kzTerm),s.onerror=()=>{tl=null,t()},document.head.append(s)});function Mt(){if(ra)ra();ra=null,ia=null,c("panel").classList.remove("wide")}async function ko(e){let t=e.pty.key;if(ia===t&&c("pbody").querySelector(".term"))return;Mt(),ia=t,c("panel").classList.add("wide"),c("pbody").innerHTML='<div class="term" aria-label="Agent terminal"></div>';let n;try{n=await bs()}catch{c("pbody").innerHTML='<p style="color:var(--dim)">The terminal could not load.</p>';return}if(ia!==t)return;ra=n(c("pbody").querySelector(".term"),t,()=>ne(!0))}var sl="kz-mic",$o=()=>{try{return localStorage.getItem(sl)||""}catch{return""}},nl=(e="")=>({channelCount:1,noiseSuppression:!0,echoCancellation:!0,...e?{deviceId:{exact:e}}:{}});async function al(e,t,n){try{return await e(nl(t))}catch(s){if(!t||s?.name!=="OverconstrainedError")throw s;return n("Chosen microphone not found. Using the default"),e(nl())}}var ol=()=>l`<select class="sel" id="v-mic" aria-labelledby="v-mic-l"><option value="">System default</option></select>`;async function il(){let e=c("v-mic");if(!e||!navigator.mediaDevices?.enumerateDevices)return;let t=$o(),n=(await navigator.mediaDevices.enumerateDevices().catch(()=>[])).filter((s)=>s.kind==="audioinput"&&s.deviceId&&s.deviceId!=="default");e.innerHTML=l`<option value="">System default</option>${n.map((s,a)=>l`<option value="${s.deviceId}">${s.label||`Microphone ${a+1}`}</option>`)}`.s,e.value=n.some((s)=>s.deviceId===t)?t:"",e.onchange=()=>{try{localStorage.setItem(sl,e.value)}catch{}}}var ku="https://cdn.jsdelivr.net/npm/@huggingface/transformers@4.3.0",rl={tiny:"onnx-community/whisper-tiny",base:"onnx-community/whisper-base",small:"onnx-community/whisper-small","large-v3-turbo":"onnx-community/whisper-large-v3-turbo"},So=null,$u=`import{pipeline}from"${ku}";let asr=null;
|
|
3
3
|
onmessage=async e=>{const m=e.data;try{
|
|
4
4
|
if(m.type==="load"){const prog=p=>{if(p.status==="progress")postMessage({type:"progress",file:p.file,pct:p.progress||0})};
|