@arcforge/axon 2.0.173 → 2.0.174
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/app.js +82 -82
- package/axond.js +1 -1
- package/package.json +1 -1
package/axond.js
CHANGED
|
@@ -1576,4 +1576,4 @@ export {}
|
|
|
1576
1576
|
}
|
|
1577
1577
|
|
|
1578
1578
|
export {}
|
|
1579
|
-
`;var Sg4=["./**/*.d.ts",`${Se}/**/*.ts`],m84=2,Ig4="../".repeat(m84);GL6();var u84;function RL6(){return u84??=Sb6()}var Yu4={allowJs:!1,noEmit:!0,target:RL6().ScriptTarget.ESNext,module:RL6().ModuleKind.ESNext,moduleResolution:RL6().ModuleResolutionKind.Bundler,skipLibCheck:!0,strict:!0};var Jc4=new URL("../../bin/test-preload.ts",import.meta.url).pathname;function SL6(H=[]){return{get all(){return H},for(A){return H.find((F)=>F.claims(A))??null},async load(A){let F=this.for(A);if(!F)throw eJ("MODEL_NO_RUNTIME",{detail:`no runtime on this machine can execute ${A}`,context:{path:A,runtimes:H.map((_)=>_.runtime)}});return{runtime:F.runtime,weight:await F.load(A)}}}}import{existsSync as o84,mkdirSync as t84,readFileSync as s84,writeFileSync as e84}from"fs";import{homedir as $94}from"os";import{dirname as J94,join as z94}from"path";function Ce(H){let A=H.indexOf(":"),F=A>0?H.slice(0,A):"hf",_=A>0&&(F==="hf"||F==="ollama")?H.slice(A+1):H,R=_.split("@")[0]??_,[y,$$]=R.split("/");return{id:H,name:$$??y??R,owner:$$?y??"":"",scheme:F}}function wL6(H={}){let A=H.root??z94($94(),".axon","cache","models-catalog.json"),F=H.fetch??fetch,_=R();function R(){try{return o84(A)?JSON.parse(s84(A,"utf-8")).queries??{}:{}}catch{return{}}}function y(){try{t84(J94(A),{recursive:!0}),e84(A,JSON.stringify({fetchedAt:Date.now(),queries:_}),"utf-8")}catch{}}return{get path(){return A},cached(L$){return _[IL6(L$)]??[]},search(L$,x$){let _$=_[IL6(L$)];return $$(L$).then((h$)=>{if(!h$)return;if(JSON.stringify(h$)!==JSON.stringify(_$))x$?.(h$)}),_$??[]},refresh:$$};async function $$(L$){try{let x$=await Q94(F,L$);return _={..._,[IL6(L$)]:x$},y(),x$}catch{return null}}}function IL6(H){return H.trim().toLowerCase()}async function Q94(H,A){let F=new URLSearchParams({search:A,filter:"onnx",limit:"40",sort:"downloads",direction:"-1"}),_=await H(`https://huggingface.co/api/models?${F}`);if(!_.ok)throw Error(`huggingface search failed: ${_.status}`);return(await _.json()).map((y)=>{let $$=Ce(`hf:${y.modelId}`);return{id:$$.id,name:$$.name,owner:$$.owner,source:"huggingface",runtime:null,type:Cb6(y.pipeline_tag),in:[],out:[],bytes:null,path:null,cached:!1,resident:!1,description:y.pipeline_tag??null,downloads:y.downloads??null}})}function Cb6(H){if(!H)return"transform";if(H.includes("text-generation")||H.includes("text2text"))return"generate";if(H.includes("voice-activity"))return"stream";return"transform"}async function _b6(H,A=fetch){let F=H.replace(/^hf:/,"").split("@")[0],_=await A(`https://huggingface.co/api/models/${F}`);if(!_.ok)throw Error(`huggingface model failed: ${_.status}`);let R=await _.json(),y=Ce(`hf:${F}`),$$=(R.siblings??[]).map((L$)=>L$.rfilename);return{id:y.id,name:y.name,owner:y.owner,type:Cb6(R.pipeline_tag),downloads:R.downloads??null,likes:R.likes??null,updatedAt:R.lastModified?Date.parse(R.lastModified):null,weights:$$.filter((L$)=>L$.toLowerCase().endsWith(".onnx")),readme:$$.includes("README.md")?await X94(F,A):null}}async function X94(H,A){let F=await A(`https://huggingface.co/${H}/raw/main/README.md`);if(!F.ok)return null;return await F.text()}async function xb6(H,A=fetch){let F=H.replace(/^hf:/,"").split("@")[0],_=await A(`https://huggingface.co/api/models/${F}`);if(!_.ok)throw Error(`huggingface model failed: ${_.status}`);return((await _.json()).siblings??[]).map((y)=>y.rfilename).filter((y)=>y.toLowerCase().endsWith(".onnx"))}function kb6(H){return H.find((A)=>A==="onnx/model.onnx"||A==="model.onnx")??null}import{statSync as Y94}from"fs";function CL6(){let H=null;function A(){return H??=import("onnxruntime-node").then((_)=>_).catch(()=>null),H}return{runtime:"onnx",claims(F){return F.toLowerCase().endsWith(".onnx")},async load(F){let _=await A();if(!_)throw eJ("MODEL_RUNTIME_MISSING",{detail:"onnxruntime-node is not installed \u2014 run `axon models runtime onnx` to add it",context:{runtime:"onnx",path:F}});let R;try{R=await _.InferenceSession.create(F)}catch(y){throw eJ("MODEL_LOAD_FAILED",{detail:`${F} \u2014 ${y instanceof Error?y.message:String(y)}`,context:{runtime:"onnx",path:F},cause:y})}return{bytes:Y94(F).size,async run(y){return R.run(y)},async unload(){await R.release?.().catch(()=>{})}}}}}function _L6(H){let A=pV$(H.root!==void 0?{root:H.root}:{}),F=H.adapters??SL6([CL6()]),_=H.catalog??wL6(),R=nV$({store:A}),y=new Map,$$=[];function L$(h$){let e$=Ce(h$.id),K$=$$.find((V6)=>{let l$=Ce(V6.id);return l$.name===e$.name&&l$.owner===e$.owner});if(!K$)return h$;return{...h$,runtime:K$.runtime,bytes:K$.bytes,path:K$.path,cached:!0,resident:y.has(K$.id)}}async function x$(){return $$=(await A.list()).map((e$)=>ih$({model:e$.specifier,bytes:e$.bytes,path:e$.path,runtime:F.for(e$.path)?.runtime??null,cached:!0,resident:y.has(e$.specifier)})),$$}async function _$(h$){let e$=y.get(h$);if(!e$)return!1;return y.delete(h$),H.machine.residency.release(e$.hold),await e$.weight.unload(),!0}return{adapters:F,catalog:_,async search(h$){let e$=_.cached(h$);if(e$.length>0)return _.refresh(h$),e$.map(L$);return(await _.refresh(h$))?.map(L$)??[]},async at(h$){let e$=await _b6(h$);return{...L$(ih$({model:e$.id,bytes:null,runtime:null,type:e$.type,downloads:e$.downloads,cached:!1,resident:!1})),weights:e$.weights,readme:e$.readme}},async searchFresh(h$){return(await _.refresh(h$))?.map(L$)??_.cached(h$).map(L$)},state(){return{cached:$$,resident:[...y.values()].map((h$)=>h$.record),root:A.root}},refresh:x$,async fetch(h$){let{specifier:e$,file:K$}=typeof h$==="string"?{specifier:h$,file:void 0}:h$,V6=await A.resolved(e$);if(V6)return await x$(),ih$({model:e$,bytes:V6.bytes,path:V6.path,runtime:F.for(V6.path)?.runtime??null,cached:!0,resident:y.has(e$)});let l$=K$??kb6(await xb6(e$));if(!l$)throw eJ("MODEL_NO_SINGLE_WEIGHT",{detail:`${e$} publishes no single weight \u2014 name the file to fetch`,context:{specifier:e$}});let d$=`${e$}/${l$}`,{paths:E4}=await R.resolve({weight:d$}),V4=E4.weight;return await x$(),ih$({model:d$,bytes:W94(V4).size,path:V4,runtime:F.for(V4)?.runtime??null,cached:!0,resident:y.has(d$)})},async load(h$){let e$=y.get(h$.model);if(e$)return e$.record;let{runtime:K$,weight:V6}=await F.load(h$.path),l$=H.machine.admit(V6.bytes);if(!l$.ok)throw await V6.unload(),eJ("MODEL_WILL_NOT_FIT",{detail:`${h$.model} needs ${V6.bytes} bytes and ${l$.available} are available`,context:{model:h$.model,wanted:l$.wanted,available:l$.available,holders:l$.holders.map((V4)=>`${V4.agent}:${V4.model}`)}});let d$=H.machine.residency.take({agent:h$.agent,role:h$.role,model:h$.model,bytes:V6.bytes}),E4=ih$({model:h$.model,bytes:V6.bytes,path:h$.path,runtime:K$,cached:!0,resident:!0});return y.set(h$.model,{weight:V6,record:E4,hold:d$.id}),E4},unload:_$,async run(h$,e$){let K$=y.get(h$);if(!K$)throw eJ("MODEL_NOT_RESIDENT",{detail:`${h$} is not loaded \u2014 load it before running inference against it`,context:{model:h$}});return K$.weight.run(e$)},async dispose(){await Promise.all([...y.keys()].map((h$)=>_$(h$)))}}}function ih$(H){let A=Ce(H.model);return{id:A.id,name:A.name,owner:A.owner,source:A.scheme==="ollama"?"ollama":"huggingface",runtime:H.runtime,type:H.type??"transform",in:[],out:[],bytes:H.bytes,path:H.path??null,cached:H.cached,resident:H.resident,description:null,downloads:H.downloads??null}}function xL6(H={}){return{state(){throw eJ("DAEMON_NOT_WIRED",{detail:"schedule is not wired yet"})}}}function bb6(H={}){let A=YB6(H.root),F=H.version??"0.0.0",_=KB6({command:H.bootCommand??["axon","daemon","serve"],...H.bootRoot!==void 0?{root:H.bootRoot}:{}}),R=WB6({paths:A,version:F,entrypoint:H.entrypoint??"",onStale:()=>L$.list().length===0}),y=hB6(H.residencyRoot!==void 0?{residencyRoot:H.residencyRoot}:{}),$$=H.cloud?nj6({cloud:H.cloud}):void 0,L$=sB6({...$$?{supervise:$$}:{},machineId:()=>y.identity.current().id,...H.agentsRoot!==void 0?{root:H.agentsRoot}:{}}),x$=_L6({machine:y,...H.modelsRoot!==void 0?{root:H.modelsRoot}:{}}),_$=xL6(),h$=GB6({domains:{machine:y,agents:L$,models:x$,schedule:_$,version:()=>F}}),e$=vB6({paths:A,dispatch:h$});return{paths:A,version:F,lifecycle:R,server:e$,boot:_,machine:y,agents:L$,models:x$,schedule:_$,async serve(){let K$=R.pid();if(K$!==null)throw eJ("DAEMON_ALREADY_RUNNING",{detail:`pid ${K$} is already listening on ${A.socket}`,context:{pid:K$,socket:A.socket}});e$.listen(),R.claim(),y.start(),x$.refresh()},async shutdown(){await L$.dispose(),await x$.dispose(),y.stop(),await e$.close(),R.release()}}}var vb6={name:"@arcforge/axond",version:"2.0.
|
|
1579
|
+
`;var Sg4=["./**/*.d.ts",`${Se}/**/*.ts`],m84=2,Ig4="../".repeat(m84);GL6();var u84;function RL6(){return u84??=Sb6()}var Yu4={allowJs:!1,noEmit:!0,target:RL6().ScriptTarget.ESNext,module:RL6().ModuleKind.ESNext,moduleResolution:RL6().ModuleResolutionKind.Bundler,skipLibCheck:!0,strict:!0};var Jc4=new URL("../../bin/test-preload.ts",import.meta.url).pathname;function SL6(H=[]){return{get all(){return H},for(A){return H.find((F)=>F.claims(A))??null},async load(A){let F=this.for(A);if(!F)throw eJ("MODEL_NO_RUNTIME",{detail:`no runtime on this machine can execute ${A}`,context:{path:A,runtimes:H.map((_)=>_.runtime)}});return{runtime:F.runtime,weight:await F.load(A)}}}}import{existsSync as o84,mkdirSync as t84,readFileSync as s84,writeFileSync as e84}from"fs";import{homedir as $94}from"os";import{dirname as J94,join as z94}from"path";function Ce(H){let A=H.indexOf(":"),F=A>0?H.slice(0,A):"hf",_=A>0&&(F==="hf"||F==="ollama")?H.slice(A+1):H,R=_.split("@")[0]??_,[y,$$]=R.split("/");return{id:H,name:$$??y??R,owner:$$?y??"":"",scheme:F}}function wL6(H={}){let A=H.root??z94($94(),".axon","cache","models-catalog.json"),F=H.fetch??fetch,_=R();function R(){try{return o84(A)?JSON.parse(s84(A,"utf-8")).queries??{}:{}}catch{return{}}}function y(){try{t84(J94(A),{recursive:!0}),e84(A,JSON.stringify({fetchedAt:Date.now(),queries:_}),"utf-8")}catch{}}return{get path(){return A},cached(L$){return _[IL6(L$)]??[]},search(L$,x$){let _$=_[IL6(L$)];return $$(L$).then((h$)=>{if(!h$)return;if(JSON.stringify(h$)!==JSON.stringify(_$))x$?.(h$)}),_$??[]},refresh:$$};async function $$(L$){try{let x$=await Q94(F,L$);return _={..._,[IL6(L$)]:x$},y(),x$}catch{return null}}}function IL6(H){return H.trim().toLowerCase()}async function Q94(H,A){let F=new URLSearchParams({search:A,filter:"onnx",limit:"40",sort:"downloads",direction:"-1"}),_=await H(`https://huggingface.co/api/models?${F}`);if(!_.ok)throw Error(`huggingface search failed: ${_.status}`);return(await _.json()).map((y)=>{let $$=Ce(`hf:${y.modelId}`);return{id:$$.id,name:$$.name,owner:$$.owner,source:"huggingface",runtime:null,type:Cb6(y.pipeline_tag),in:[],out:[],bytes:null,path:null,cached:!1,resident:!1,description:y.pipeline_tag??null,downloads:y.downloads??null}})}function Cb6(H){if(!H)return"transform";if(H.includes("text-generation")||H.includes("text2text"))return"generate";if(H.includes("voice-activity"))return"stream";return"transform"}async function _b6(H,A=fetch){let F=H.replace(/^hf:/,"").split("@")[0],_=await A(`https://huggingface.co/api/models/${F}`);if(!_.ok)throw Error(`huggingface model failed: ${_.status}`);let R=await _.json(),y=Ce(`hf:${F}`),$$=(R.siblings??[]).map((L$)=>L$.rfilename);return{id:y.id,name:y.name,owner:y.owner,type:Cb6(R.pipeline_tag),downloads:R.downloads??null,likes:R.likes??null,updatedAt:R.lastModified?Date.parse(R.lastModified):null,weights:$$.filter((L$)=>L$.toLowerCase().endsWith(".onnx")),readme:$$.includes("README.md")?await X94(F,A):null}}async function X94(H,A){let F=await A(`https://huggingface.co/${H}/raw/main/README.md`);if(!F.ok)return null;return await F.text()}async function xb6(H,A=fetch){let F=H.replace(/^hf:/,"").split("@")[0],_=await A(`https://huggingface.co/api/models/${F}`);if(!_.ok)throw Error(`huggingface model failed: ${_.status}`);return((await _.json()).siblings??[]).map((y)=>y.rfilename).filter((y)=>y.toLowerCase().endsWith(".onnx"))}function kb6(H){return H.find((A)=>A==="onnx/model.onnx"||A==="model.onnx")??null}import{statSync as Y94}from"fs";function CL6(){let H=null;function A(){return H??=import("onnxruntime-node").then((_)=>_).catch(()=>null),H}return{runtime:"onnx",claims(F){return F.toLowerCase().endsWith(".onnx")},async load(F){let _=await A();if(!_)throw eJ("MODEL_RUNTIME_MISSING",{detail:"onnxruntime-node is not installed \u2014 run `axon models runtime onnx` to add it",context:{runtime:"onnx",path:F}});let R;try{R=await _.InferenceSession.create(F)}catch(y){throw eJ("MODEL_LOAD_FAILED",{detail:`${F} \u2014 ${y instanceof Error?y.message:String(y)}`,context:{runtime:"onnx",path:F},cause:y})}return{bytes:Y94(F).size,async run(y){return R.run(y)},async unload(){await R.release?.().catch(()=>{})}}}}}function _L6(H){let A=pV$(H.root!==void 0?{root:H.root}:{}),F=H.adapters??SL6([CL6()]),_=H.catalog??wL6(),R=nV$({store:A}),y=new Map,$$=[];function L$(h$){let e$=Ce(h$.id),K$=$$.find((V6)=>{let l$=Ce(V6.id);return l$.name===e$.name&&l$.owner===e$.owner});if(!K$)return h$;return{...h$,runtime:K$.runtime,bytes:K$.bytes,path:K$.path,cached:!0,resident:y.has(K$.id)}}async function x$(){return $$=(await A.list()).map((e$)=>ih$({model:e$.specifier,bytes:e$.bytes,path:e$.path,runtime:F.for(e$.path)?.runtime??null,cached:!0,resident:y.has(e$.specifier)})),$$}async function _$(h$){let e$=y.get(h$);if(!e$)return!1;return y.delete(h$),H.machine.residency.release(e$.hold),await e$.weight.unload(),!0}return{adapters:F,catalog:_,async search(h$){let e$=_.cached(h$);if(e$.length>0)return _.refresh(h$),e$.map(L$);return(await _.refresh(h$))?.map(L$)??[]},async at(h$){let e$=await _b6(h$);return{...L$(ih$({model:e$.id,bytes:null,runtime:null,type:e$.type,downloads:e$.downloads,cached:!1,resident:!1})),weights:e$.weights,readme:e$.readme}},async searchFresh(h$){return(await _.refresh(h$))?.map(L$)??_.cached(h$).map(L$)},state(){return{cached:$$,resident:[...y.values()].map((h$)=>h$.record),root:A.root}},refresh:x$,async fetch(h$){let{specifier:e$,file:K$}=typeof h$==="string"?{specifier:h$,file:void 0}:h$,V6=await A.resolved(e$);if(V6)return await x$(),ih$({model:e$,bytes:V6.bytes,path:V6.path,runtime:F.for(V6.path)?.runtime??null,cached:!0,resident:y.has(e$)});let l$=K$??kb6(await xb6(e$));if(!l$)throw eJ("MODEL_NO_SINGLE_WEIGHT",{detail:`${e$} publishes no single weight \u2014 name the file to fetch`,context:{specifier:e$}});let d$=`${e$}/${l$}`,{paths:E4}=await R.resolve({weight:d$}),V4=E4.weight;return await x$(),ih$({model:d$,bytes:W94(V4).size,path:V4,runtime:F.for(V4)?.runtime??null,cached:!0,resident:y.has(d$)})},async load(h$){let e$=y.get(h$.model);if(e$)return e$.record;let{runtime:K$,weight:V6}=await F.load(h$.path),l$=H.machine.admit(V6.bytes);if(!l$.ok)throw await V6.unload(),eJ("MODEL_WILL_NOT_FIT",{detail:`${h$.model} needs ${V6.bytes} bytes and ${l$.available} are available`,context:{model:h$.model,wanted:l$.wanted,available:l$.available,holders:l$.holders.map((V4)=>`${V4.agent}:${V4.model}`)}});let d$=H.machine.residency.take({agent:h$.agent,role:h$.role,model:h$.model,bytes:V6.bytes}),E4=ih$({model:h$.model,bytes:V6.bytes,path:h$.path,runtime:K$,cached:!0,resident:!0});return y.set(h$.model,{weight:V6,record:E4,hold:d$.id}),E4},unload:_$,async run(h$,e$){let K$=y.get(h$);if(!K$)throw eJ("MODEL_NOT_RESIDENT",{detail:`${h$} is not loaded \u2014 load it before running inference against it`,context:{model:h$}});return K$.weight.run(e$)},async dispose(){await Promise.all([...y.keys()].map((h$)=>_$(h$)))}}}function ih$(H){let A=Ce(H.model);return{id:A.id,name:A.name,owner:A.owner,source:A.scheme==="ollama"?"ollama":"huggingface",runtime:H.runtime,type:H.type??"transform",in:[],out:[],bytes:H.bytes,path:H.path??null,cached:H.cached,resident:H.resident,description:null,downloads:H.downloads??null}}function xL6(H={}){return{state(){throw eJ("DAEMON_NOT_WIRED",{detail:"schedule is not wired yet"})}}}function bb6(H={}){let A=YB6(H.root),F=H.version??"0.0.0",_=KB6({command:H.bootCommand??["axon","daemon","serve"],...H.bootRoot!==void 0?{root:H.bootRoot}:{}}),R=WB6({paths:A,version:F,entrypoint:H.entrypoint??"",onStale:()=>L$.list().length===0}),y=hB6(H.residencyRoot!==void 0?{residencyRoot:H.residencyRoot}:{}),$$=H.cloud?nj6({cloud:H.cloud}):void 0,L$=sB6({...$$?{supervise:$$}:{},machineId:()=>y.identity.current().id,...H.agentsRoot!==void 0?{root:H.agentsRoot}:{}}),x$=_L6({machine:y,...H.modelsRoot!==void 0?{root:H.modelsRoot}:{}}),_$=xL6(),h$=GB6({domains:{machine:y,agents:L$,models:x$,schedule:_$,version:()=>F}}),e$=vB6({paths:A,dispatch:h$});return{paths:A,version:F,lifecycle:R,server:e$,boot:_,machine:y,agents:L$,models:x$,schedule:_$,async serve(){let K$=R.pid();if(K$!==null)throw eJ("DAEMON_ALREADY_RUNNING",{detail:`pid ${K$} is already listening on ${A.socket}`,context:{pid:K$,socket:A.socket}});e$.listen(),R.claim(),y.start(),x$.refresh()},async shutdown(){await L$.dispose(),await x$.dispose(),y.stop(),await e$.close(),R.release()}}}var vb6={name:"@arcforge/axond",version:"2.0.174",type:"module",exports:{".":{types:"./src/index.ts",default:"./src/index.ts"},"./types":{types:"./types/index.ts",default:"./types/index.ts"},"./bin/axond.ts":"./bin/axond.ts"},bin:{axond:"./bin/axond.ts"},files:["src/**/*.ts","types/**/*.ts","bin/**/*.ts"],scripts:{test:"bun test --parallel=4",typecheck:"tsc --noEmit"},dependencies:{"@arcforge/err":"workspace:*","@arcforge/link":"workspace:*","@arcforge/platform":"workspace:*","@arcforge/types":"workspace:*","@arcforge/cloud":"workspace:*","@arcforge/arcline":"workspace:*"},devDependencies:{"@types/bun":"latest","@arclabs/repo":"workspace:*"},peerDependencies:{typescript:"^5"},optionalDependencies:{"onnxruntime-node":"^1.29.0"}};var K94=bb6({version:vb6.version,entrypoint:import.meta.path}),Ge=bB6({axond:K94}),yb6=process.argv[2];try{switch(yb6){case"up":console.log(await Ge.up(process.argv.includes("--json")));break;case"down":console.log(Ge.down());break;case"status":console.log(Ge.status());break;case"machine":console.log(Ge.machine());break;case"agents":console.log(Ge.agents());break;case"disable":console.log(Ge.disable());break;case"serve":await Ge.serve();break;default:if(console.log(Ge.help()),yb6!==void 0)process.exit(1)}}catch(H){console.error(Ge.failure(H)),process.exit(1)}
|
package/package.json
CHANGED