typebulb 0.52.2 → 0.52.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.
@@ -1912,31 +1912,33 @@ html[data-theme="dark"] .masthead-logo.dark { display: block; }
1912
1912
  pill above the last line — pin it to the text's bottom edge. */
1913
1913
  .bubble.assistant > .bubble-controls { bottom: 0; }
1914
1914
 
1915
- /* A turn's local representation selector (turnView.ts). It is a tab bar made of restrained
1916
- hyperlink-like buttons, not pills: Raw is the full chronological trace for one turn, Reply is its
1917
- exact prose, and Summary is the generated compression. Normal flow above the selected body means
1918
- every switch resizes only below itself. */
1915
+ /* A turn's local representation selector (turnView.ts). A standard tab bar: a continuous bottom
1916
+ line under all tabs, the selected tab's thicker line indicating the active view. Raw is the full
1917
+ chronological trace for one turn, Reply is its exact prose, and Summary is the generated
1918
+ compression. Normal flow above the selected body means every switch resizes only below itself. */
1919
1919
  .turn-views-row {
1920
1920
  display: flex;
1921
1921
  align-items: baseline;
1922
- gap: .35rem;
1923
- margin: 0 0 .35rem;
1922
+ gap: 0;
1923
+ width: fit-content;
1924
+ margin: .7rem auto;
1924
1925
  font-size: .8rem;
1925
1926
  line-height: 1.3;
1927
+ border-bottom: 1px solid var(--border);
1926
1928
  }
1927
1929
  .turn-view {
1928
1930
  appearance: none;
1929
- margin: 0;
1930
- padding: 0;
1931
+ margin: 0 0 -1px 0;
1932
+ padding: 0 .5rem .1rem;
1931
1933
  border: 0;
1932
- border-bottom: 1px solid transparent;
1934
+ border-bottom: 2px solid transparent;
1933
1935
  background: none;
1934
1936
  color: var(--muted);
1935
1937
  font: inherit;
1936
1938
  cursor: pointer;
1939
+ text-align: center;
1937
1940
  }
1938
1941
  .turn-view:hover, .turn-view.on { color: var(--accent); }
1939
1942
  .turn-view.on { border-bottom-color: var(--accent); }
1940
1943
  .turn-view.err { color: var(--err); }
1941
- .turn-view:focus-visible { outline: 1px solid var(--accent); outline-offset: 2px; border-radius: 2px; }
1942
- .turn-view-sep { color: var(--border); user-select: none; }
1944
+ .turn-view:focus-visible { outline: 1px solid var(--accent); outline-offset: 2px; border-radius: 2px; }
package/dist/index.js CHANGED
@@ -177,7 +177,7 @@ ${t.comment}`:t.comment}this.doc.range[2]=t.offset;break}default:this.errors.pus
177
177
  `),l=i.filter(u=>u.type==="tool_use").map(u=>({id:u.id??"",name:u.name??"",input:u.input??{}}));if(o||a||l.length){let u=Date.parse(e.timestamp??""),f=!isNaN(u)&&u>=t;r.push({type:"assistant",text:o,thinking:a,tools:l,live:f})}let c=e.message?.usage??e.usage,d=c&&{in:c.input_tokens??0,out:c.output_tokens??0,cached:c.cache_read_input_tokens??0,cacheCreate:c.cache_creation_input_tokens??0};return{events:r,usage:d,model:e.message?.model}}return{events:r}}chainWorking(e){let t;for(let o of e)(o.type==="user"||o.type==="assistant")&&(t=o);if(!t)return!1;if(t.type==="user"){try{let o=t.message?.content,a=typeof o=="string"?o:Array.isArray(o)?o.filter(c=>c&&c.type==="text").map(c=>c.text??"").join(""):"";if(!(Array.isArray(o)&&o.some(c=>c&&c.type==="tool_result"))&&a.trim()&&xt(a)==="")return!1}catch{}return!0}let s=(Array.isArray(t.message?.content)?t.message.content:[]).filter(o=>o.type==="tool_use").map(o=>o.id);if(s.length===0)return!1;let i=new Set;for(let o of e){let a=o.message?.content;if(Array.isArray(a))for(let l of a)l.type==="tool_result"&&l.tool_use_id&&i.add(l.tool_use_id)}return s.some(o=>o&&!i.has(o))}sessionAlive(e){return LE(e)}readPreview(e){return $E(e)}searchText(e){if(!e||Kr(e)||e.type!=="user"&&e.type!=="assistant")return"";let t=e.message?.content,r="";if(typeof t=="string")r=xt(t);else if(Array.isArray(t)){let s=t;r=e.type==="user"?s.map(Rc).filter(Boolean).join(" "):s.filter(i=>i.type==="text"&&typeof i.text=="string").map(i=>i.text).join(" ")}return r.replace(/\s+/g," ").trim()}}});import{statSync as ME,readdirSync as BE,openSync as DE,readSync as jE,closeSync as FE,existsSync as UE}from"fs";import{basename as qE,join as Ic,resolve as JE}from"path";import{homedir as Im}from"os";function HE(n){let e=n.trimStart();return KE.some(t=>e.startsWith(t))}function Wr(n,e){return Array.isArray(n)?n.map(t=>typeof t?.text=="string"?e&&HE(t.text)?"":we(t.text):t?.type==="input_image"&&typeof t.image_url=="string"&&t.image_url.startsWith("data:")?`![image](${t.image_url})`:"").filter(Boolean).join(`
178
178
  `):""}function WE(n){return typeof n=="string"?we(n):Wr(n,!1)}function YE(n){let e=n??"";for(let t of[/tools\.shell_command\((\{[\s\S]*?\})\)/,/tools\.shell_command\((\{[\s\S]*\})\)/]){let r=t.exec(e);if(r)try{return JSON.parse(r[1])}catch{}}return{script:e}}function VE(n){if(typeof n=="string"&&n)try{let e=JSON.parse(n);if(e&&typeof e=="object"&&!Array.isArray(e))return e}catch{}return{arguments:n??""}}function Lm(n,e){let t;try{t=DE(n,"r")}catch{return}try{let r=Buffer.alloc(e),s=jE(t,r,0,e,0);return{text:r.subarray(0,s).toString("utf8"),bytes:s}}finally{FE(t)}}function zE(n){let t=Lm(n,65536);if(t===void 0)return;let r=t.text.indexOf(`
179
179
  `);if(r<0)return t.bytes>=65536?"":void 0;try{let s=JSON.parse(t.text.slice(0,r));return s?.type==="session_meta"&&typeof s.payload?.cwd=="string"?s.payload.cwd:""}catch{return""}}var KE,$m,Cn,$c=v(()=>{"use strict";Jr();Ui();KE=["<permissions instructions>","<apps_instructions>","<plugins_instructions>","<skills_instructions>","<recommended_plugins>","<environment_context>","<user_instructions>"];$m=n=>{let e=JE(n);return process.platform==="win32"?e.toLowerCase():e},Cn=class extends kt{constructor(t=Ic(Im(),".codex","sessions")){super();this.root=t}displayName="Codex Mirror";#e=0;#t;#n=new Map;detectsSelf(){return!!process.env.CODEX_THREAD_ID}detectsInstalled(){return UE(Ic(Im(),".codex"))}sessionsDir(t){return this.root}listSessionFiles(t){let r=$m(t),s=[];for(let i of this.#r()){let o;try{let l=ME(i);if(!l.isFile())continue;o=l.mtimeMs}catch{continue}let a=this.#n.get(i);if(a===void 0){if(a=zE(i),a===void 0)continue;this.#n.set(i,a)}$m(a)===r&&s.push({sessionId:qE(i,".jsonl"),file:i,mtime:o})}return s}#r(){let t=[],r=s=>{try{return BE(s).map(i=>Ic(s,i))}catch{return[]}};for(let s of r(this.root))for(let i of r(s))for(let o of r(i))for(let a of r(o))a.endsWith(".jsonl")&&t.push(a);return t}parseEntry(t){let r;try{r=JSON.parse(t)}catch{return null}return!r||typeof r.type!="string"?null:r}idOf(t){return t.ord===void 0&&(t.ord=String(this.#e++),t.parent=this.#t,this.#t=t.ord),t.ord}parentOf(t){return t.parent}timestampOf(t){return t.timestamp}isSidechain(t){return!1}isLeafType(t){return!0}isRecoveryNoise(t){return!1}apply(t,r){let s=[],i=t.payload;if(!i)return{events:s};let o=()=>{let a=Date.parse(t.timestamp??"");return!isNaN(a)&&a>=r};if(t.type==="response_item"){if(i.type==="message"){if(i.role==="user"){let a=Wr(i.content,!0).trim();a&&s.push({type:"user",text:a})}else if(i.role==="assistant"){let a=Wr(i.content,!1);a&&s.push({type:"assistant",text:a,thinking:"",tools:[],live:o()})}return{events:s}}if(i.type==="reasoning"){let a=Wr(i.summary,!1);return a&&s.push({type:"assistant",text:"",thinking:a,tools:[],live:o()}),{events:s}}if(i.type==="custom_tool_call"||i.type==="function_call"){let a=i.type==="custom_tool_call"?YE(i.input):VE(i.arguments);return s.push({type:"assistant",text:"",thinking:"",tools:[{id:i.call_id??"",name:i.name??"",input:a}],live:o()}),{events:s}}if(i.type==="custom_tool_call_output"||i.type==="function_call_output"){let a=WE(i.output);return s.push({type:"tool_result",id:i.call_id??"",content:a,isError:!1,digest:$e(a)}),{events:s}}return{events:s}}if(t.type==="event_msg"){if(i.type==="token_count"){let a=i.info?.last_token_usage;if(!a)return{events:s};let l={in:Math.max(0,(a.input_tokens??0)-(a.cached_input_tokens??0)),out:a.output_tokens??0,cached:a.cached_input_tokens??0,cacheCreate:a.cache_write_input_tokens??0};return{events:s,usage:l}}return{events:s}}return t.type==="turn_context"?{events:s,model:i.model}:{events:s}}chainWorking(t){let r=!1;for(let s of t){if(s.type!=="event_msg")continue;let i=s.payload?.type;i==="task_started"?r=!0:(i==="task_complete"||i==="turn_aborted")&&(r=!1)}return r}sessionAlive(){}readPreview(t){for(let r of(Lm(t,256*1024)?.text??"").split(`
180
- `))if(r.includes('"user_message"'))try{let s=JSON.parse(r);if(s?.type==="event_msg"&&s.payload?.type==="user_message"&&typeof s.payload.message=="string"){let i=s.payload.message.replace(/\s+/g," ").trim();if(i)return i.slice(0,200)}}catch{}return""}searchText(t){if(t?.type!=="response_item"||t.payload?.type!=="message")return"";let r=t.payload.role;return r!=="user"&&r!=="assistant"?"":Wr(t.payload.content,r==="user").replace(/\s+/g," ").trim()}}});import{realpathSync as GE}from"fs";import{createHash as XE}from"crypto";import{join as Ki,resolve as QE}from"path";import{homedir as ZE}from"os";function Et(){let n=process.env.TYPEBULB_SERVERS_DIR;return n?Ki(n,".."):Ki(ZE(),".typebulb")}function et(){Mm||(Mm=!0,console.error(`${Et()} not writable \u2014 continuing stateless: ports won't stick, caches stay cold, and typebulb logs/wait/send/stop may not see this run`))}function tt(){return process.env.TYPEBULB_SERVERS_DIR||Ki(Et(),"servers")}function Bm(n){let e=X(n),t=XE("sha1").update(e).digest("hex").slice(0,8),r=e.slice(e.lastIndexOf("/")+1).replace(/\.bulb\.md$/,"");return Ki(Et(),"canvas",`${r}-${t}.png`)}function X(n){let e=QE(n),t=e;try{t=GE.native(e)}catch{}return(process.platform==="win32"?t.toLowerCase():t).replace(/\\/g,"/")}function Dm(n,e){let t=X(n),r=X(e);return t.startsWith(r.endsWith("/")?r:r+"/")?!t.includes("/node_modules/"):!1}var Mm,At=v(()=>{"use strict";Mm=!1});var Me,Hi=v(()=>{"use strict";Me="0.52.2"});import{spawn as jm}from"child_process";import{readdir as eA,readFile as Um,writeFile as qm,unlink as Lc,mkdir as tA}from"fs/promises";import{mkdirSync as Jm,writeFileSync as Wi,appendFileSync as nA,readFileSync as Mc}from"fs";import*as Ee from"path";import{fileURLToPath as rA}from"url";function Bc(n){return Ee.join(tt(),`${n}.json`)}function Vr(n){return Ee.join(tt(),`${n}.log`)}function Dc(n){return Ee.join(tt(),`${n}.wait.json`)}function Km(n){try{let e=JSON.parse(Mc(Dc(n),"utf8"));return e.cursors&&typeof e.cursors=="object"?e.cursors:{}}catch{return{}}}function jc(n,e=""){let t=Km(n)[e];return typeof t=="number"&&Number.isFinite(t)&&t>=0?t:void 0}function Yi(n,e,t=""){try{Jm(tt(),{recursive:!0});let r=Km(n);r[t]=e,Wi(Dc(n),JSON.stringify({cursors:r}))}catch{}}function Vi(n){let e=Vr(n);try{Jm(tt(),{recursive:!0}),Wi(e,"")}catch{return()=>{}}let t=process.stdout.write.bind(process.stdout),r=process.stderr.write.bind(process.stderr),s=0,i=!1,o=a=>{if(!i)try{let l=typeof a=="string"?Buffer.from(a,"utf8"):Buffer.from(a);if(nA(e,l),s+=l.length,s>2*Fm){let c=Mc(e),d=c.subarray(Math.max(0,c.length-Fm));Wi(e,d),s=d.length}}catch{i=!0}};return process.stdout.write=((a,...l)=>(o(a),t(a,...l))),process.stderr.write=((a,...l)=>(o(a),r(a,...l))),()=>{process.stdout.write=t,process.stderr.write=r}}function Hm(n){try{Wi(Vr(n),"")}catch{}}function We(n,e=0){try{let t=Mc(Vr(n)),r=e>=0&&e<=t.length?e:0;return{text:t.subarray(r).toString("utf8"),offset:t.length}}catch{return{text:"",offset:0}}}function Fc(n){return`\u2500\u2500 run ${n} \u2500\u2500 ${new Date().toTimeString().slice(0,8)}`}function iA(n){let e=sA.exec(n);return e?Number(e[1]):void 0}function Wm(n,e){let t=n.split(`
180
+ `))if(r.includes('"user_message"'))try{let s=JSON.parse(r);if(s?.type==="event_msg"&&s.payload?.type==="user_message"&&typeof s.payload.message=="string"){let i=s.payload.message.replace(/\s+/g," ").trim();if(i)return i.slice(0,200)}}catch{}return""}searchText(t){if(t?.type!=="response_item"||t.payload?.type!=="message")return"";let r=t.payload.role;return r!=="user"&&r!=="assistant"?"":Wr(t.payload.content,r==="user").replace(/\s+/g," ").trim()}}});import{realpathSync as GE}from"fs";import{createHash as XE}from"crypto";import{join as Ki,resolve as QE}from"path";import{homedir as ZE}from"os";function Et(){let n=process.env.TYPEBULB_SERVERS_DIR;return n?Ki(n,".."):Ki(ZE(),".typebulb")}function et(){Mm||(Mm=!0,console.error(`${Et()} not writable \u2014 continuing stateless: ports won't stick, caches stay cold, and typebulb logs/wait/send/stop may not see this run`))}function tt(){return process.env.TYPEBULB_SERVERS_DIR||Ki(Et(),"servers")}function Bm(n){let e=X(n),t=XE("sha1").update(e).digest("hex").slice(0,8),r=e.slice(e.lastIndexOf("/")+1).replace(/\.bulb\.md$/,"");return Ki(Et(),"canvas",`${r}-${t}.png`)}function X(n){let e=QE(n),t=e;try{t=GE.native(e)}catch{}return(process.platform==="win32"?t.toLowerCase():t).replace(/\\/g,"/")}function Dm(n,e){let t=X(n),r=X(e);return t.startsWith(r.endsWith("/")?r:r+"/")?!t.includes("/node_modules/"):!1}var Mm,At=v(()=>{"use strict";Mm=!1});var Me,Hi=v(()=>{"use strict";Me="0.52.3"});import{spawn as jm}from"child_process";import{readdir as eA,readFile as Um,writeFile as qm,unlink as Lc,mkdir as tA}from"fs/promises";import{mkdirSync as Jm,writeFileSync as Wi,appendFileSync as nA,readFileSync as Mc}from"fs";import*as Ee from"path";import{fileURLToPath as rA}from"url";function Bc(n){return Ee.join(tt(),`${n}.json`)}function Vr(n){return Ee.join(tt(),`${n}.log`)}function Dc(n){return Ee.join(tt(),`${n}.wait.json`)}function Km(n){try{let e=JSON.parse(Mc(Dc(n),"utf8"));return e.cursors&&typeof e.cursors=="object"?e.cursors:{}}catch{return{}}}function jc(n,e=""){let t=Km(n)[e];return typeof t=="number"&&Number.isFinite(t)&&t>=0?t:void 0}function Yi(n,e,t=""){try{Jm(tt(),{recursive:!0});let r=Km(n);r[t]=e,Wi(Dc(n),JSON.stringify({cursors:r}))}catch{}}function Vi(n){let e=Vr(n);try{Jm(tt(),{recursive:!0}),Wi(e,"")}catch{return()=>{}}let t=process.stdout.write.bind(process.stdout),r=process.stderr.write.bind(process.stderr),s=0,i=!1,o=a=>{if(!i)try{let l=typeof a=="string"?Buffer.from(a,"utf8"):Buffer.from(a);if(nA(e,l),s+=l.length,s>2*Fm){let c=Mc(e),d=c.subarray(Math.max(0,c.length-Fm));Wi(e,d),s=d.length}}catch{i=!0}};return process.stdout.write=((a,...l)=>(o(a),t(a,...l))),process.stderr.write=((a,...l)=>(o(a),r(a,...l))),()=>{process.stdout.write=t,process.stderr.write=r}}function Hm(n){try{Wi(Vr(n),"")}catch{}}function We(n,e=0){try{let t=Mc(Vr(n)),r=e>=0&&e<=t.length?e:0;return{text:t.subarray(r).toString("utf8"),offset:t.length}}catch{return{text:"",offset:0}}}function Fc(n){return`\u2500\u2500 run ${n} \u2500\u2500 ${new Date().toTimeString().slice(0,8)}`}function iA(n){let e=sA.exec(n);return e?Number(e[1]):void 0}function Wm(n,e){let t=n.split(`
181
181
  `),r=[];if(t.forEach((o,a)=>{let l=iA(o);l!==void 0&&r.push({id:l,idx:a})}),!r.length)return e==="latest"?n:"";let s=e==="latest"?r[r.length-1]:r.find(o=>o.id===e);if(!s)return"";let i=r.find(o=>o.idx>s.idx);return t.slice(s.idx,i?i.idx:t.length).join(`
182
182
  `)}function Uc(n){try{return process.kill(n,0),!0}catch(e){return e.code==="EPERM"}}async function Ym(n){try{await tA(tt(),{recursive:!0}),await qm(Bc(n.pid),JSON.stringify({version:Me,...n}))}catch{et()}}async function Vm(n,e){let t=Bc(n);try{let r=JSON.parse(await Um(t,"utf8"));if(r.denied===e)return;r.denied=e,await qm(t,JSON.stringify(r))}catch{}}async function Yr(n){await Lc(Bc(n)).catch(()=>{}),await Lc(Vr(n)).catch(()=>{}),await Lc(Dc(n)).catch(()=>{})}async function Q(n){let e;try{e=await eA(tt())}catch{return[]}let t=[];return await Promise.all(e.map(async s=>{if(!/^\d+\.json$/.test(s))return;let i=parseInt(s,10),o;try{o=JSON.parse(await Um(Ee.join(tt(),s),"utf8"))}catch{await Yr(i);return}o&&typeof o.pid=="number"&&Uc(o.pid)?t.push(o):await Yr(i)})),(n?t.filter(s=>s.agent==null&&Dm(s.file,n)):t).sort((s,i)=>s.startedAt-i.startedAt)}async function qc(n,e){let t=X(n);return(await Q()).find(r=>r.cwd!=null&&X(r.cwd)===t&&(e?r.agent===e:r.agent!=null))}async function Yt(n){try{process.kill(n,"SIGTERM")}catch{}await Yr(n)}function Rn(n,e){let t=X(e);return n.filter(r=>r.agent==null&&r.pid!==process.pid&&X(r.file)===t)}async function Jc(n){let e=Rn(await Q(),n);for(let t of e)await Yt(t.pid);return e}function aA(n,e,t){(process.platform==="win32"?jm("cmd",["/c","start","","/b",n,...e],{cwd:t,stdio:"ignore",windowsHide:!0}):jm(n,e,{cwd:t,detached:!0,stdio:"ignore"})).unref()}function zm(){return Ee.join(Ee.dirname(rA(import.meta.url)),"index.js")}function lA(n,e={}){return{command:process.execPath,args:[zm(),...e.trust?["--trust"]:[],...e.batch?["--batch",e.batch]:[],...e.mode?["--mode",e.mode]:[],n,...e.open===!1?["--no-open"]:[]]}}function cA(n){return{command:process.execPath,args:[zm(),`agent:${n}`,"--no-open"]}}async function Gm(n,e,t,r){let s=await n();if(s)return s;aA(e.command,e.args,t);let i=Date.now()+2e4;for(;Date.now()<i;){await oA(150);let o=await n();if(o)return o}throw new Error(`Launched ${r} but it did not register within 20s.`)}async function zi(n,e={}){let t=e.cwd??process.cwd(),r=Ee.resolve(t,n),[s]=await Jc(r),i={...e,batch:e.batch??s?.batch,mode:e.mode??s?.mode};return Gm(async()=>Rn(await Q(),r)[0],lA(n,i),t,Ee.basename(n))}async function Xm(n,e=process.cwd()){return Gm(()=>qc(e,n),cA(n),e,`the ${n} mirror`)}var Fm,sA,oA,Be=v(()=>{"use strict";At();Hi();Fm=1e6;sA=/^── run (\d+) ── /;oA=n=>new Promise(e=>setTimeout(e,n))});function _n(n){return{...of(n),server:n.files.get("server.ts")??""}}function Gi(n){return!!n.server&&!n.code}var zr=v(()=>{"use strict";ne();ne()});function Xi(n){let e=/^---[^\n]*\n([\s\S]*?)\n---/.exec(n),t=e?/^\s*name:\s*(.+?)\s*$/m.exec(e[1]):null;return t?t[1].replace(/^["']|["']$/g,""):void 0}function Kc(n){return Tn(Xi(n)??"bulb")||"bulb"}var Hc=v(()=>{"use strict";ne()});import{transform as uA}from"sucrase";function Wc(n,e={}){let t=e.serverOnly?["typescript"]:["typescript","jsx"];try{let{code:r}=uA(n,{transforms:t,jsxRuntime:"automatic",jsxImportSource:e.jsxImportSource||"react",production:!0});return{code:r}}catch(r){return{code:"",error:String(r)}}}var Qm=v(()=>{});function Yc(n){let e=n.split(""),t=(i,o)=>{for(let a=i;a<o&&a<e.length;a++)e[a]!==`
183
183
  `&&(e[a]=" ")},r=0,s="";for(;r<n.length;){let i=n[r],o=n[r+1];if(i==="/"&&o==="/"){let a=r;for(;a<n.length&&n[a]!==`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "typebulb",
3
- "version": "0.52.2",
3
+ "version": "0.52.3",
4
4
  "description": "Typebulb CLI to run single-file markdown apps called bulbs, either as standalone web apps or embedded in agent responses.",
5
5
  "keywords": [
6
6
  "bulb",