typebulb 0.15.8 → 0.15.9
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/dist/agents/claude/client.js +131 -131
- package/dist/index.js +1 -1
- package/dist/render.js +44 -44
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1138,6 +1138,6 @@ ${ev}
|
|
|
1138
1138
|
Shutting down...`),p.close(),y?.(),t(),await Cr(process.pid),process.exit(0)};process.on("SIGINT",E),process.on("SIGTERM",E)}import*as Qd from"path";import{EventEmitter as rS}from"events";async function Xd(r,e,t,n,s){let i=de(t),o=!1,a=async()=>{let{bulb:c,config:l}=await ne(r);o||($e(i,r,c.server),o=!0),await Tr(c.server,s,n,l.dependencies)};if(console.log(`Running ${Qd.basename(r)}...`),await a(),e){console.log(`Watching for changes...
|
|
1139
1139
|
`);let c=new rS;c.on("reload",async()=>{try{console.log("Re-running..."),await a()}catch(l){console.error("Error:",l)}}),Ps({bulbPath:r,emitter:c})}}import{Console as nS}from"node:console";fe();Ar();async function Zd(r,e,t,n,s){lS();try{let p=L(r),m=(await $()).find(h=>L(h.file)===p);m&&ds(m.pid,ue(m.pid).offset)}catch{}let i=de(t),{bulb:o,config:a}=await ne(r);o.server||$s("This bulb has no **server.ts** block; nothing to call."),$e(i,r,o.server);let c;try{c=await Tr(o.server,s,n,a.dependencies)}catch(p){$s(p instanceof Error?p.message:String(p))}let l=Es(c,e.fn);if(!l){let p=[...Object.keys(c).filter(m=>typeof c[m]=="function"),...Object.keys(ua)];$s(`Function '${e.fn}' not found. Available: ${p.length?p.join(", "):"(none)"}.`)}let f=await sS(e),u;try{u=await l(...f)}catch(p){$s(p instanceof Error?p.stack??p.message:String(p))}let d=aS(u);d!==void 0&&await uS(d+`
|
|
1140
1140
|
`),process.exit(0)}async function sS(r){if(r.hasArgsFlag){let e=r.argsJson??"";return e==="-"&&(e=await fS()),oS(e)}return iS(r.positional)}function iS(r){return r.map(e=>{try{return JSON.parse(e)}catch{return e}})}function oS(r){let e;try{e=JSON.parse(r)}catch(t){throw new Error(`--args must be a JSON array: ${t instanceof Error?t.message:String(t)}`)}if(!Array.isArray(e))throw new Error(`--args must be a JSON array, got ${e===null?"null":typeof e}`);return e}function aS(r){if(r!==void 0)return JSON.stringify(r,cS,2)}function cS(r,e){return typeof e=="bigint"?e.toString():e}function $s(r){process.stderr.write(r+`
|
|
1141
|
-
`),process.exit(1)}function lS(){let r=new nS(process.stderr,process.stderr);console.log=r.log.bind(r),console.info=r.info.bind(r),console.debug=r.debug.bind(r),console.dir=r.dir.bind(r)}function uS(r){return new Promise((e,t)=>{process.stdout.write(r,n=>n?t(n):e())})}async function fS(){let r=[];for await(let e of process.stdin)r.push(e);return Buffer.concat(r).toString("utf-8")}var Ta="0.15.
|
|
1141
|
+
`),process.exit(1)}function lS(){let r=new nS(process.stderr,process.stderr);console.log=r.log.bind(r),console.info=r.info.bind(r),console.debug=r.debug.bind(r),console.dir=r.dir.bind(r)}function uS(r){return new Promise((e,t)=>{process.stdout.write(r,n=>n?t(n):e())})}async function fS(){let r=[];for await(let e of process.stdin)r.push(e);return Buffer.concat(r).toString("utf-8")}var Ta="0.15.9";function ep(r,e){r||(console.error(`This bulb runs server-side Node code (server.ts), which --trust must authorize:
|
|
1142
1142
|
${e}`),process.exit(1))}async function dS(){let r=La(process.argv.slice(2));if(r.version&&(console.log(`typebulb ${Ta}`),process.exit(0)),r.help&&($a(),process.exit(0)),r.subcommand==="logs"){await td(r.file||void 0,{follow:r.follow,clear:r.clear,run:r.run,lines:r.lines});return}if(r.subcommand==="wait"){await rd(r.file||void 0,{match:r.match,timeoutSec:r.timeoutSec??1800});return}if(r.subcommand==="stop"){r.stopScope?await sd(r.stopScope):await nd(r.file||void 0);return}if(r.subcommand==="send"){await od(r.file,r.sendMessage);return}if(r.subcommand==="skill"){await Xf(Ta);return}if(r.subcommand==="models"){await zf(r.mode);return}if(r.subcommand==="agent"){if(!r.agentTarget){await Vf(Ta);return}xf(r.agentTarget)||(console.error(`Unknown agent '${r.agentTarget}'. Known: ${Or().join(", ")}.`),process.exit(1));let l=await ea(process.cwd(),r.agentTarget);if(l){console.log(`Mirror '${r.agentTarget}' is already running for this project:
|
|
1143
1143
|
${l.url}`),r.open&&await vt(l.url);return}await zd(r);return}if(r.subcommand==="trust"||r.subcommand==="untrust"){await Rf(r.file||void 0,r.subcommand==="trust");return}let e;if(!r.file||r.file==="."){let l=await bf(process.cwd());l||(console.error("No .bulb.md file found in current directory"),process.exit(1)),e=l}else e=we.resolve(r.file);await tp.access(e).then(()=>!0,()=>!1)||(Or().includes(r.file)&&(console.error(`To open the ${r.file} agent mirror, run: npx typebulb agent:${r.file}`),process.exit(1)),console.error(`File not found: ${e}`),process.exit(1)),e.endsWith(".bulb.md")||(console.error("File must have .bulb.md extension"),process.exit(1));let n=r.file&&r.file!=="."?r.file:we.relative(process.cwd(),e)||we.basename(e),s=`npx typebulb --trust ${n.includes(" ")?`"${n}"`:n}`;if(r.subcommand==="predict"){await Cf(e,s);return}let i=!r.noTrust&&We(e);i&&!r.trust&&console.log("trust: granted from memory (run `typebulb untrust` to revoke)"),r.trust=r.noTrust?!1:r.trust||i;let o;try{o=await ne(e)}catch{}let a;if(r.local){o&&!(r.local.name in(o.config.dependencies??{}))&&(console.error(`--replace: '${r.local.name}' is not a dependency in this bulb's config.json; nothing to replace.`),process.exit(1)),o&&r.subcommand!=="call"&&(!o.bulb.code||r.server)&&console.warn("warning: --replace has no effect in server mode (the override is client-only).");try{a=await Ia(r.local)}catch(l){console.error(l instanceof Error?l.message:String(l)),process.exit(1)}console.log(`replace: ${a.name} \u2192 ${we.relative(process.cwd(),a.dir)||"."}`)}if(r.subcommand==="check"){await Nf(e,a);return}let c=we.dirname(e);if(r.subcommand==="call"){ep(r.trust,s),await Zd(e,{fn:r.fn,positional:r.callArgs,argsJson:r.argsJson,hasArgsFlag:r.hasArgsFlag},r.mode,a,c);return}if(o&&o.bulb.server&&(!o.bulb.code||r.server)){ep(r.trust,s),await Xd(e,r.watch,r.mode,a,c);return}await md(e,r,s,a,c)}dS().catch(r=>{console.error("Error:",r.message),process.exit(1)});
|