kaizen-agent 1.55.0 → 1.56.0

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/web/term.ts CHANGED
@@ -82,9 +82,10 @@ function mountTerm(el: HTMLElement, key: string, onEnd?: () => void): () => void
82
82
  onEnd?.();
83
83
  };
84
84
  };
85
- // Phone/tablet: a bar of the keys a soft keyboard lacks. Alt is sticky for the next key.
86
- // Ctrl opens its own a-z pad instead of waiting on the native keyboard, whose IME can
87
- // deliver the letter without the modifier. The handle above the bar hides it.
85
+ // Phone/tablet: a row of chips for the keys a soft keyboard lacks, and a message box
86
+ // that types into the agent and presses Enter. Alt is sticky for the next key. Ctrl
87
+ // opens its own a-z pad instead of waiting on the native keyboard, whose IME can
88
+ // deliver the letter without the modifier. ⋯ holds Search, Paste and Raw keyboard.
88
89
  const mods = { alt: false };
89
90
  const typed = term.onData((d) => {
90
91
  if (mods.alt) d = "\x1b" + d;
@@ -96,24 +97,25 @@ function mountTerm(el: HTMLElement, key: string, onEnd?: () => void): () => void
96
97
  if (matchMedia("(pointer: coarse)").matches) {
97
98
  const arrow = (c: string) => () => `\x1b${term.modes.applicationCursorKeysMode ? "O" : "["}${c}`;
98
99
  const paste = () => navigator.clipboard?.readText().then((t) => t && term.paste(t), () => {});
99
- // inverted T: Up above Down, Left and Right beside it
100
- const keys: [string, string | (() => unknown) | "alt" | "ctrl" | ""][] = [
101
- ["Esc", "\x1b"], ["Paste", paste], ["↵", "\r"], ["⇧⇥", "\x1b[Z"], ["↑", arrow("A")], ["", ""],
102
- ["Ctrl", "ctrl"], ["Alt", "alt"], ["^C", "\x03"], ["←", arrow("D")], ["↓", arrow("B")], ["→", arrow("C")],
100
+ // 1-3 answer the agent's numbered prompts; the rest are the keys it asks for most.
101
+ const keys: [string, string | (() => unknown) | "alt" | "ctrl" | "more"][] = [
102
+ ["1", "1"], ["2", "2"], ["3", "3"], ["Esc", "\x1b"], ["^C", "\x03"], ["↑", arrow("A")], ["↓", arrow("B")],
103
+ ["←", arrow("D")], ["→", arrow("C")], ["↵", "\r"], ["⇧⇥", "\x1b[Z"], ["Ctrl", "ctrl"], ["Alt", "alt"], ["⋯", "more"],
103
104
  ];
104
105
  bar = document.createElement("div");
105
106
  bar.className = "termkeys";
106
- // pointerdown + preventDefault: a tap must not move focus off the terminal.
107
+ const msg = document.createElement("input");
108
+ // pointerdown + preventDefault: a tap must not move focus off the terminal, nor
109
+ // close the soft keyboard while the message box is being typed in.
107
110
  const key = (label: string, fn: () => void) => {
108
111
  const b = document.createElement("button");
109
112
  b.type = "button";
110
113
  b.textContent = label;
111
- b.addEventListener("pointerdown", (e) => { e.preventDefault(); fn(); term.focus(); });
114
+ b.addEventListener("pointerdown", (e) => { e.preventDefault(); fn(); if (document.activeElement !== msg) term.focus(); });
112
115
  return b;
113
116
  };
114
- const grid = document.createElement("div");
115
- grid.className = "keygrid";
116
- const setPad = (on: boolean) => { pad.hidden = !on; grid.hidden = on; };
117
+ const chips = document.createElement("div");
118
+ chips.className = "chips";
117
119
  const pad = document.createElement("div");
118
120
  pad.className = "ctrlpad";
119
121
  pad.hidden = true;
@@ -122,40 +124,55 @@ function mountTerm(el: HTMLElement, key: string, onEnd?: () => void): () => void
122
124
  const r = document.createElement("div");
123
125
  for (const c of row) r.append(key(c, () => {
124
126
  if (c !== "✕") send({ t: "i", d: String.fromCharCode(c.charCodeAt(0) & 31) });
125
- setPad(false);
127
+ pad.hidden = true;
126
128
  }));
127
129
  pad.append(r);
128
130
  }
131
+ // The native keyboard stays shut over the terminal (inputmode none) until Raw keyboard
132
+ // asks for it; the message box below has its own.
133
+ const ta = term.textarea;
134
+ if (ta) ta.inputMode = "none";
135
+ const more = document.createElement("div");
136
+ more.className = "tmore";
137
+ more.hidden = true;
138
+ const raw = key("Raw keyboard", () => {
139
+ more.hidden = true;
140
+ if (!ta) return;
141
+ const on = raw.classList.toggle("on");
142
+ ta.inputMode = on ? "text" : "none";
143
+ ta.blur(); // inputmode is read on focus; the key's term.focus() reopens it
144
+ });
145
+ more.append(key("Search", () => { more.hidden = true; openSearch(); }), key("Paste", () => { more.hidden = true; paste(); }), raw);
129
146
  for (const [label, v] of keys) {
130
- if (!label) { grid.append(document.createElement("i")); continue; }
131
147
  const b = key(label, () => {
132
148
  if (v === "alt") b.classList.toggle("on", (mods.alt = !mods.alt));
133
- else if (v === "ctrl") setPad(true);
149
+ else if (v === "ctrl") { pad.hidden = !pad.hidden; more.hidden = true; }
150
+ else if (v === "more") { more.hidden = !more.hidden; pad.hidden = true; }
134
151
  else send({ t: "i", d: (typeof v === "function" ? v() : v) as string });
135
152
  });
136
153
  if (v === "alt") b.classList.add(v);
137
- grid.append(b);
154
+ chips.append(b);
138
155
  }
139
- const hide = key("Keys ▾", () => {
140
- const off = hide.textContent === "Keys ▾";
141
- grid.hidden = pad.hidden = true;
142
- if (!off) grid.hidden = false;
143
- hide.textContent = off ? "Keys ▴" : "Keys ▾";
144
- });
145
- // The native keyboard stays shut (inputmode none) until this button asks for it, so
146
- // tapping the terminal or a key never pops it over the Ctrl pad and Paste.
147
- const ta = term.textarea;
148
- if (ta) ta.inputMode = "none";
149
- const kbd = key("⌨", () => {
150
- if (!ta) return;
151
- const on = kbd.classList.toggle("on");
152
- ta.inputMode = on ? "text" : "none";
153
- ta.blur(); // inputmode is read on focus; the key's term.focus() reopens it
156
+ // Send types the text, then Enter a beat later: sent together, a TUI agent reads the
157
+ // pair as a paste and keeps the newline in its input instead of submitting.
158
+ const form = document.createElement("form");
159
+ form.className = "compose";
160
+ msg.placeholder = "Message the agent…";
161
+ msg.enterKeyHint = "send";
162
+ msg.autocomplete = "off";
163
+ msg.setAttribute("aria-label", "Message the agent");
164
+ const go = document.createElement("button");
165
+ go.textContent = "➤";
166
+ go.setAttribute("aria-label", "Send");
167
+ go.addEventListener("pointerdown", (e) => e.preventDefault()); // keep the keyboard up
168
+ form.append(msg, go);
169
+ form.addEventListener("submit", (e) => {
170
+ e.preventDefault();
171
+ if (msg.value) send({ t: "i", d: msg.value });
172
+ msg.value = "";
173
+ setTimeout(() => send({ t: "i", d: "\r" }), 60);
154
174
  });
155
- const top = document.createElement("div");
156
- top.className = "keytop";
157
- top.append(hide, kbd);
158
- bar.append(top, pad, grid);
175
+ bar.append(pad, more, chips, form);
159
176
  el.after(bar);
160
177
  }
161
178
  // xterm.js has no touch scrolling, so on a phone a swipe did nothing. Each line's
package/web/video.js CHANGED
@@ -1,4 +1,4 @@
1
- /* kaizen video page ec9b9a1a8ab3db13 -- generated by bun run build:web from web/video.ts; do not edit */
1
+ /* kaizen video page 72c88849625f1d4d -- generated by bun run build:web from web/video.ts; do not edit */
2
2
  (()=>{var W={TikTok:"9x16","Instagram Reels":"9x16","YouTube Shorts":"9x16","WhatsApp Status":"9x16",YouTube:"16x9","Instagram feed":"4x5"},de={"9x16":[1080,1920],"16x9":[1920,1080],"4x5":[1080,1350]},X=["#b4462f","#a8720a","#2d50a5","#0f8fa3","#1f9d55","#7a4fb5","#c2416b","#5b6b8c"],p=(e)=>document.getElementById(e),l=(e)=>String(e??"").replace(/[&<>"']/g,(t)=>`&#${t.charCodeAt(0)};`),E=(e)=>e==null?"":`${Math.floor(e/60)}:${String(Math.round(e%60)).padStart(2,"0")}`,O=(e)=>(e??"9x16").replace("x",":"),I=(e,t)=>`/video/f/${e.place}/${encodeURIComponent(e.name)}/${t.split("/").map(encodeURIComponent).join("/")}`,ce={draft:"Draft",queued:"Queued",building:"Building preview",rendering:"Rendering",ready:"Ready",failed:"Failed"},_=[],ue=[],pe=[],He=(e,t)=>ue.filter((n)=>n.place===e&&n.name===t).sort((n,i)=>i.at-n.at)[0],D="",Ee;function h(e){let t=p("toast");t.textContent=e,t.classList.add("on"),clearTimeout(Ee),Ee=setTimeout(()=>t.classList.remove("on"),3200)}async function M(e,t){let n=await fetch(e,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(t)}),i=await n.json().catch(()=>({}));if(!n.ok)throw Error(i.error||i.why||`${n.status}`);return i}async function R(){let e;try{e=await fetch("/video/list")}catch{h("The board is not running");return}let t=await e.json();if(_=t.videos,ue=t.agents??[],pe=t.places,p("emptyhow").innerHTML=`Videos are folders under <code>videos/</code> in ${t.places.map((n)=>`<code>${l(n.dir)}</code>`).join(" or ")}. Ask the kaizen-video skill to make one, and it shows up here.`,me(),y)xe(),Ae();ye()}function De(){return _.flatMap((e)=>{let t=e.outputs.filter((s)=>s.kind!=="history"&&s.kind!=="trying"),n=t.length?t:[null],i=new Map;for(let s of n)if(!i.has(s?.format??e.formats[0]))i.set(s?.format??e.formats[0],s);return[...i].map(([s,a])=>({v:e,f:s,o:a}))})}function me(){let e=p("q").value.trim().toLowerCase().split(/\s+/).filter(Boolean),t=De(),n=t.filter(({v:s})=>{let a=[s.title,s.name,s.text,s.preset,s.where,s.mode,...s.platforms].join(" ").toLowerCase();return(D==="busy"?["queued","building","rendering"].includes(s.status):!D||s.status===D)&&e.every((o)=>a.includes(o))}),i=ue.filter((s)=>s.alive&&!_.some((a)=>a.place===s.place&&a.name===s.name)&&e.every((a)=>s.name.includes(a))&&(!D||D==="busy"||D==="draft"));p("grid").removeAttribute("aria-busy"),p("grid").innerHTML=i.map((s)=>`<article class="vid" tabindex="0" data-p="${s.place}" data-n="${l(s.name)}" aria-label="${l(s.name)}, being made">
3
3
  <div class="thumb making" style="--ar:9/16"><span class="t">${s.asking?"Claude is asking you something":"Claude is making this"}</span></div>
4
4
  <div class="meta"><b>${l(s.name)}</b><div class="plats"><i class="where">${l(pe[s.place]?.label??"")}</i></div>