@rizom/brain 0.2.0-alpha.836 → 0.2.0-alpha.837

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-dkkzdvsq.js";import{$e as N,Ae as A,Be as x,af as O,bf as z,cf as M,df as q,ef as J,ff as L,hf as _,if as j,je as E,me as I}from"./chunks/index-rfhjnswy.js";import"./chunks/index-b1p8dc6h.js";import{mf as D}from"./chunks/index-r7wta18y.js";import{Go as B,Yi as C,il as P,jl as w,qg as h}from"./chunks/index-z2vkw38q.js";import{Tp as p}from"./chunks/index-ccr2wtqg.js";import{$t as S,bu as v}from"./chunks/index-w95s5nd1.js";import"./chunks/index-vtq8grrc.js";import"./chunks/index-56q7tcn7.js";import"./chunks/index-mcmwn790.js";import"./chunks/index-dhgpvctn.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-ptpg82x2.js";import{$e as N,Ae as A,Be as x,af as O,bf as z,cf as M,df as q,ef as J,ff as L,hf as _,if as j,je as E,me as I}from"./chunks/index-rfhjnswy.js";import"./chunks/index-b1p8dc6h.js";import{mf as D}from"./chunks/index-r7wta18y.js";import{Go as B,Yi as C,il as P,jl as w,qg as h}from"./chunks/index-z2vkw38q.js";import{Tp as p}from"./chunks/index-ccr2wtqg.js";import{$t as S,bu as v}from"./chunks/index-w95s5nd1.js";import"./chunks/index-vtq8grrc.js";import"./chunks/index-56q7tcn7.js";import"./chunks/index-mcmwn790.js";import"./chunks/index-dhgpvctn.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=F868F595EA1966FE64756E2164756E21
5
5
  //# sourceMappingURL=testing.js.map
@@ -238,6 +238,7 @@
238
238
  .x108lf0y:not(#\#){margin:10px 0 0}
239
239
  .x1rbkbsg:not(#\#){margin:10px 2px 0}
240
240
  .x1uud7ro:not(#\#){margin:12px 0 0}
241
+ .x1bjd80g:not(#\#){margin:12px 0 4px}
241
242
  .xzmowlt:not(#\#){margin:14px 0 0}
242
243
  .xjvutul:not(#\#){margin:14px 0 4px}
243
244
  .x6a0dku:not(#\#){margin:14px 16px 4px}
@@ -248,6 +249,7 @@
248
249
  .x108hnsc:not(#\#){margin:24px 36px 0}
249
250
  .xh8a1rz:not(#\#){margin:2px 0 8px 19px}
250
251
  .x91luw6:not(#\#){margin:7px 0 3px}
252
+ .xe6w4ck:not(#\#){margin:8px 0 0}
251
253
  .xri99sx:not(#\#){padding:0 0 12px}
252
254
  .xyfktp2:not(#\#){padding:0 0 6px}
253
255
  .x6jaaxu:not(#\#){padding:0 10px 0 36px}
@@ -745,6 +747,7 @@
745
747
  .x1yzlmg0:not(#\#):not(#\#):not(#\#){grid-template-columns:minmax(120px,160px) minmax(0,1fr)}
746
748
  .xoilou0:not(#\#):not(#\#):not(#\#){grid-template-columns:minmax(260px,320px) minmax(0,1fr)}
747
749
  .xnby9oq:not(#\#):not(#\#):not(#\#){grid-template-columns:repeat(2,minmax(0,1fr))}
750
+ .x1sipb5g:not(#\#):not(#\#):not(#\#){grid-template-columns:repeat(4,minmax(0,1fr))}
748
751
  .x11qjcnl:not(#\#):not(#\#):not(#\#){grid-template-columns:repeat(auto-fill,minmax(150px,1fr))}
749
752
  .x1rdfzu:not(#\#):not(#\#):not(#\#){grid-template-columns:repeat(auto-fit,minmax(150px,1fr))}
750
753
  .x12p5jtz:not(#\#):not(#\#):not(#\#){grid-template-columns:repeat(auto-fit,minmax(min(100%,260px),1fr))}
@@ -901,6 +904,7 @@
901
904
  .x1bguay0:is([data-state='checked']):not(#\#):not(#\#):not(#\#){background-color:var(--console-on-accent)}
902
905
  .x10zscow:is([data-climate='instrument'] *):not(#\#):not(#\#):not(#\#){background-color:var(--console-rule-strong)}
903
906
  .x13txrro:is([aria-pressed="true"]):not(#\#):not(#\#):not(#\#){background-color:var(--console-rule)}
907
+ .xzwmdui:focus-within:not(#\#):not(#\#):not(#\#){background-color:var(--console-rule)}
904
908
  .x79sx2d:focus-within:not(#\#):not(#\#):not(#\#){box-shadow:0 0 0 1px var(--console-accent)}
905
909
  .x1o00wks:focus-visible:not(#\#):not(#\#):not(#\#){box-shadow:0 0 0 3px color-mix(in srgb,var(--console-accent) 18%,transparent)}
906
910
  .x1x9skyz:focus-visible:not(#\#):not(#\#):not(#\#){box-shadow:0 0 0 3px color-mix(in srgb,var(--console-accent) 20%,transparent)}
@@ -1035,6 +1039,7 @@
1035
1039
  @media (max-width: 640px){.x4jmfmw.x4jmfmw:not(#\#):not(#\#):not(#\#){grid-template-columns:minmax(0,1fr)}}
1036
1040
  @media (max-width: 900px){.xirox3h.xirox3h:not(#\#):not(#\#):not(#\#){grid-template-columns:minmax(0,1fr)}}
1037
1041
  @media (min-width: 641px) and (max-width: 900px){.x8ef1wo.x8ef1wo:not(#\#):not(#\#):not(#\#){grid-template-columns:minmax(0,1fr)}}
1042
+ @media (max-width: 640px){.x9ov8se.x9ov8se:not(#\#):not(#\#):not(#\#){grid-template-columns:repeat(3,minmax(0,1fr))}}
1038
1043
  @media (max-width: 640px){.x1s4lsyz.x1s4lsyz:not(#\#):not(#\#):not(#\#){grid-template-rows:auto 44px minmax(180px,1fr)}}
1039
1044
  @media (max-width: 640px){.x1y6iwit.x1y6iwit:not(#\#):not(#\#):not(#\#){grid-template-rows:auto minmax(0,1fr) auto}}
1040
1045
  @media (max-width: 640px){.xch1w8t.xch1w8t:not(#\#):not(#\#):not(#\#){grid-template-rows:auto}}