@rizom/brain 0.2.0-alpha.865 → 0.2.0-alpha.866

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/testing.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{ge as k,he as V,ie as U}from"./chunks/index-b8tcxs85.js";import{Ae as A,Be as x,bf as N,cf as O,df as z,ef as M,ff as q,gf as J,hf as L,je as E,jf as _,kf as j,me as I}from"./chunks/index-1va59d20.js";import"./chunks/index-n3cy8ttx.js";import{of as D}from"./chunks/index-zy2sedrg.js";import{Ro as B,gj as C,sg as h,sl as P,tl as w}from"./chunks/index-yvqqp899.js";import{cq as p}from"./chunks/index-m2qv3p6y.js";import{qu as S,su as v}from"./chunks/index-0k63cxm5.js";import"./chunks/index-rwrp530c.js";import"./chunks/index-njqkf4cd.js";import"./chunks/index-74vg6r70.js";import"./chunks/index-cyq5dhvm.js";import{mkdtemp as K,rm as b}from"fs/promises";import{tmpdir as X}from"os";import{join as m}from"path";var y="none";function s(){return Promise.reject(Error("A test brain has no AI provider"))}function W(e){return{specificationVersion:"v3",provider:"test-brain",modelId:e,supportedUrls:{},doGenerate:s,doStream:s}}function T(e){let r={...e};return{generateText:s,generateObject:s,judge:s,generateImage:s,getModel:()=>W(r.model??"none"),canGenerateImages:()=>!1,getConfig:()=>({...r}),updateConfig:(o)=>{r={...r,...o}}}}function R(){return{identity:{model:"test:none",dimensions:1536,promptRevision:0},embedQuery:s,embedDocuments:s}}var Y="shell",ee=20;function te(e){if("needsConfirmation"in e)return{needsConfirmation:!0,summary:e.summary};if(!e.success)return{success:!1,error:e.error,...p({code:e.code})};return{success:!0,...p({data:e.data,message:e.message})}}function re(e,r){if(e.status==="completed"||e.status==="failed")return!0;return e.status==="pending"&&e.lastError!==null&&e.scheduledFor>r}function ne(e,r){return e.flatMap((o)=>{if(!D(o))throw Error("A test brain runs packages configured with use(), as defineBrain does");return P(o.definition,o.config,r)})}async function F(e,r){let o=k(r.directory);V(o,r.brainVersion);let f=ne(e.plugins,{name:o.name,version:o.version}),a=await K(m(r.temporaryRoot??X(),"rizom-test-brain-")),g={...E({dataDir:a,cacheDir:m(a,"cache"),distDir:m(a,"dist")}),embedding:{enabled:!1}},i;try{await new J(v.createFresh({level:S.WARN,context:"test-brain"}),{getStandardConfigWithDirectories:async()=>g,migrateEntities:O,migrateJobQueue:z,migrateConversations:M,migrateRuntimeState:q}).runAllMigrations();let t=_({name:o.name,version:o.version,logLevel:"warn",plugins:f,shellConfig:{...g,dataDir:m(a,"brain-data"),ai:{model:y}}}),n=I(j(t));i=N.createFresh(n,{aiService:T(A(n)),embeddingService:R()}),await i.initialize()}catch(t){throw await b(a,{recursive:!0,force:!0}),t}let Z=f.map((t)=>t.id),H,Q=async()=>{try{await i.shutdown()}finally{await b(a,{recursive:!0,force:!0})}};return Object.freeze({async tool(t,n){let l=i.getMCPService().listTools(),d=l.find(({tool:u})=>u.name===t);if(!d)throw Error(`No tool "${t}"; this brain has ${l.map(({tool:u})=>u.name).join(", ")}`);return te(await d.tool.handler(n,L()))},request:(t,n)=>h(i.getMessageBus(),t,n,Y),async fetch(t){let n=x(B(i),t.method.toUpperCase(),new URL(t.url).pathname);if(!n)return new Response("Not Found",{status:404});if(n.sharedHostAdmission==="deny")return new Response("Unauthorized",{status:401});return n.handler(t)},entities:C(i.getEntityService(),"restricted"),jobs:Object.freeze({async wait(t,n){let l=i.getJobQueueService(),d=async()=>{let c=await l.getStatus(n);if(!c||!Z.some((G)=>c.type===`${G}:${t.name}`))return null;if(re(c,Date.now()))return c;return await Bun.sleep(ee),d()},u=await d();return u?w(t,u):null}}),stop:()=>H??=Q()})}function Ee(e){return F(e,{brainVersion:U.version,directory:process.cwd()})}export{Ee as startTestBrain};
2
+ import{ge as k,he as V,ie as U}from"./chunks/index-bgkd36a5.js";import{Ae as A,Be as x,bf as N,cf as O,df as z,ef as M,ff as q,gf as J,hf as L,je as E,jf as _,kf as j,me as I}from"./chunks/index-1va59d20.js";import"./chunks/index-n3cy8ttx.js";import{of as D}from"./chunks/index-zy2sedrg.js";import{Ro as B,gj as C,sg as h,sl as P,tl as w}from"./chunks/index-yvqqp899.js";import{cq as p}from"./chunks/index-m2qv3p6y.js";import{qu as S,su as v}from"./chunks/index-0k63cxm5.js";import"./chunks/index-rwrp530c.js";import"./chunks/index-njqkf4cd.js";import"./chunks/index-74vg6r70.js";import"./chunks/index-cyq5dhvm.js";import{mkdtemp as K,rm as b}from"fs/promises";import{tmpdir as X}from"os";import{join as m}from"path";var y="none";function s(){return Promise.reject(Error("A test brain has no AI provider"))}function W(e){return{specificationVersion:"v3",provider:"test-brain",modelId:e,supportedUrls:{},doGenerate:s,doStream:s}}function T(e){let r={...e};return{generateText:s,generateObject:s,judge:s,generateImage:s,getModel:()=>W(r.model??"none"),canGenerateImages:()=>!1,getConfig:()=>({...r}),updateConfig:(o)=>{r={...r,...o}}}}function R(){return{identity:{model:"test:none",dimensions:1536,promptRevision:0},embedQuery:s,embedDocuments:s}}var Y="shell",ee=20;function te(e){if("needsConfirmation"in e)return{needsConfirmation:!0,summary:e.summary};if(!e.success)return{success:!1,error:e.error,...p({code:e.code})};return{success:!0,...p({data:e.data,message:e.message})}}function re(e,r){if(e.status==="completed"||e.status==="failed")return!0;return e.status==="pending"&&e.lastError!==null&&e.scheduledFor>r}function ne(e,r){return e.flatMap((o)=>{if(!D(o))throw Error("A test brain runs packages configured with use(), as defineBrain does");return P(o.definition,o.config,r)})}async function F(e,r){let o=k(r.directory);V(o,r.brainVersion);let f=ne(e.plugins,{name:o.name,version:o.version}),a=await K(m(r.temporaryRoot??X(),"rizom-test-brain-")),g={...E({dataDir:a,cacheDir:m(a,"cache"),distDir:m(a,"dist")}),embedding:{enabled:!1}},i;try{await new J(v.createFresh({level:S.WARN,context:"test-brain"}),{getStandardConfigWithDirectories:async()=>g,migrateEntities:O,migrateJobQueue:z,migrateConversations:M,migrateRuntimeState:q}).runAllMigrations();let t=_({name:o.name,version:o.version,logLevel:"warn",plugins:f,shellConfig:{...g,dataDir:m(a,"brain-data"),ai:{model:y}}}),n=I(j(t));i=N.createFresh(n,{aiService:T(A(n)),embeddingService:R()}),await i.initialize()}catch(t){throw await b(a,{recursive:!0,force:!0}),t}let Z=f.map((t)=>t.id),H,Q=async()=>{try{await i.shutdown()}finally{await b(a,{recursive:!0,force:!0})}};return Object.freeze({async tool(t,n){let l=i.getMCPService().listTools(),d=l.find(({tool:u})=>u.name===t);if(!d)throw Error(`No tool "${t}"; this brain has ${l.map(({tool:u})=>u.name).join(", ")}`);return te(await d.tool.handler(n,L()))},request:(t,n)=>h(i.getMessageBus(),t,n,Y),async fetch(t){let n=x(B(i),t.method.toUpperCase(),new URL(t.url).pathname);if(!n)return new Response("Not Found",{status:404});if(n.sharedHostAdmission==="deny")return new Response("Unauthorized",{status:401});return n.handler(t)},entities:C(i.getEntityService(),"restricted"),jobs:Object.freeze({async wait(t,n){let l=i.getJobQueueService(),d=async()=>{let c=await l.getStatus(n);if(!c||!Z.some((G)=>c.type===`${G}:${t.name}`))return null;if(re(c,Date.now()))return c;return await Bun.sleep(ee),d()},u=await d();return u?w(t,u):null}}),stop:()=>H??=Q()})}function Ee(e){return F(e,{brainVersion:U.version,directory:process.cwd()})}export{Ee as startTestBrain};
3
3
 
4
4
  //# debugId=9CCBF3506BC4ABC264756E2164756E21
5
5
  //# sourceMappingURL=testing.js.map
@@ -744,7 +744,7 @@
744
744
  .x1otrvri:not(#\#):not(#\#):not(#\#){grid-template-columns:22px minmax(0,1fr)}
745
745
  .xp2jwox:not(#\#):not(#\#):not(#\#){grid-template-columns:232px minmax(0,1fr) minmax(260px,420px) auto}
746
746
  .x1i9x5af:not(#\#):not(#\#):not(#\#){grid-template-columns:232px minmax(0,1fr)}
747
- .x1n2e3sn:not(#\#):not(#\#):not(#\#){grid-template-columns:28px minmax(0,1fr)}
747
+ .xhhciqg:not(#\#):not(#\#):not(#\#){grid-template-columns:28px minmax(0,1fr) auto}
748
748
  .x4u00d1:not(#\#):not(#\#):not(#\#){grid-template-columns:36px 64px minmax(0,1fr) auto}
749
749
  .x770nye:not(#\#):not(#\#):not(#\#){grid-template-columns:36px minmax(0,1fr) auto}
750
750
  .x1hxcnyl:not(#\#):not(#\#):not(#\#){grid-template-columns:68px minmax(0,1fr)}
@@ -848,6 +848,7 @@
848
848
  .x162tt16:not(#\#):not(#\#):not(#\#){padding-inline-start:30px}
849
849
  .xhikr00:not(#\#):not(#\#):not(#\#){padding-inline-start:31px}
850
850
  .x25sj25:not(#\#):not(#\#):not(#\#){padding-inline-start:6px}
851
+ .xmzvs34:not(#\#):not(#\#):not(#\#){padding-inline-start:8px}
851
852
  .x47corl:not(#\#):not(#\#):not(#\#){pointer-events:none}
852
853
  .x10l6tqk:not(#\#):not(#\#):not(#\#){position:absolute}
853
854
  .xixxii4:not(#\#):not(#\#):not(#\#){position:fixed}