@rizom/brain 0.2.0-alpha.655 → 0.2.0-alpha.656
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/brain.js +42 -42
- package/dist/chunks/{app-9qnfq61y.js → app-3tmqf3j6.js} +2 -2
- package/dist/chunks/{index-6mvmghaw.js → index-6k028s7g.js} +3 -3
- package/dist/chunks/{index-6mvmghaw.js.map → index-6k028s7g.js.map} +1 -1
- package/dist/chunks/{index-431xeecj.js → index-94n3e70q.js} +2 -2
- package/dist/chunks/{index-wnssjj5s.js → index-m79damwn.js} +3 -3
- package/dist/chunks/{index-wnssjj5s.js.map → index-m79damwn.js.map} +1 -1
- package/dist/model.js +42 -42
- package/dist/model.js.map +4 -4
- package/dist/testing.js +1 -1
- package/package.json +1 -1
- /package/dist/chunks/{app-9qnfq61y.js.map → app-3tmqf3j6.js.map} +0 -0
- /package/dist/chunks/{index-431xeecj.js.map → index-94n3e70q.js.map} +0 -0
package/dist/testing.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{V as j,W as k,X as V,Y as U}from"./chunks/index-
|
|
2
|
+
import{V as j,W as k,X as V,Y as U}from"./chunks/index-6k028s7g.js";import{$ as I,Ha as x,Ia as N,Ja as O,Ka as z,La as M,Ma as q,Na as J,Pa as L,Qa as _,Z as E,pa as A}from"./chunks/index-tcfqv5xm.js";import{Sa as D}from"./chunks/index-rshk5nc4.js";import{Qg as w,Rg as B,gg as P,ue as h,xe as C}from"./chunks/index-gah7ynt5.js";import"./chunks/index-3aed6wdt.js";import{ds as p}from"./chunks/index-ewvsx01d.js";import"./chunks/index-beafty8j.js";import{cv as S,dv as v}from"./chunks/index-np6n8r2b.js";import"./chunks/index-ec1497ep.js";import"./chunks/index-30aa0axa.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:(i)=>{r={...r,...i}}}}function R(){return{dimensions:1536,generateEmbedding:s,generateEmbeddings: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((i)=>{if(!D(i))throw Error("A test brain runs packages configured with use(), as defineBrain does");return w(i.definition,i.config,r)})}async function F(e,r){let i=j(r.directory);k(i,r.brainVersion);let f=ne(e.plugins,{name:i.name,version:i.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}},o;try{await new q(v.createFresh({level:S.WARN,context:"test-brain"}),{getStandardConfigWithDirectories:async()=>g,migrateEntities:N,migrateJobQueue:O,migrateConversations:z,migrateRuntimeState:M}).runAllMigrations();let t=L({name:i.name,version:i.version,logLevel:"warn",plugins:f,shellConfig:{...g,dataDir:m(a,"brain-data"),ai:{model:y}}}),n=I(_(t));o=x.createFresh(n,{aiService:T(A(n)),embeddingService:R()}),await o.initialize()}catch(t){throw await b(a,{recursive:!0,force:!0}),t}let Z=f.map((t)=>t.id),H,G=async()=>{try{await o.shutdown()}finally{await b(a,{recursive:!0,force:!0})}};return Object.freeze({async tool(t,n){let l=o.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,J()))},request:(t,n)=>C(o.getMessageBus(),t,n,Y),async fetch(t){let n=V(P(o),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:h(o.getEntityService(),"restricted"),jobs:Object.freeze({async wait(t,n){let l=o.getJobQueueService(),d=async()=>{let c=await l.getStatus(n);if(!c||!Z.some((Q)=>c.type===`${Q}:${t.name}`))return null;if(re(c,Date.now()))return c;return await Bun.sleep(ee),d()},u=await d();return u?B(t,u):null}}),stop:()=>H??=G()})}function Ee(e){return F(e,{brainVersion:U.version,directory:process.cwd()})}export{Ee as startTestBrain};
|
|
3
3
|
|
|
4
4
|
//# debugId=466876223D619DED64756E2164756E21
|
|
5
5
|
//# sourceMappingURL=testing.js.map
|
package/package.json
CHANGED
|
File without changes
|
|
File without changes
|