@nekzus/liop 2.0.0-alpha.25 → 2.0.0-alpha.27

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.
Files changed (34) hide show
  1. package/dist/bin/agent.js +1 -1
  2. package/dist/bridge.js +1 -1
  3. package/dist/{chunk-ISKM7EAL.js → chunk-AKTU6ZMX.js} +2 -2
  4. package/dist/{chunk-ISKM7EAL.js.map → chunk-AKTU6ZMX.js.map} +1 -1
  5. package/dist/{chunk-GD6EOKYV.js → chunk-BDQZURCS.js} +9 -9
  6. package/dist/chunk-BDQZURCS.js.map +1 -0
  7. package/dist/{chunk-LJQF6ULT.js → chunk-GFRRQ2EB.js} +3 -3
  8. package/dist/{chunk-LJQF6ULT.js.map → chunk-GFRRQ2EB.js.map} +1 -1
  9. package/dist/{chunk-F7B6B4XS.js → chunk-GYK2HORK.js} +3 -3
  10. package/dist/{chunk-F7B6B4XS.js.map → chunk-GYK2HORK.js.map} +1 -1
  11. package/dist/{chunk-C65RM2A3.js → chunk-RNS4FR5L.js} +11 -4
  12. package/dist/chunk-RNS4FR5L.js.map +1 -0
  13. package/dist/chunk-SW53FNSN.js +2 -0
  14. package/dist/chunk-SW53FNSN.js.map +1 -0
  15. package/dist/{chunk-ALLOYPMN.js → chunk-YTIMVS2I.js} +3 -3
  16. package/dist/{chunk-ALLOYPMN.js.map → chunk-YTIMVS2I.js.map} +1 -1
  17. package/dist/client.js +1 -1
  18. package/dist/gateway.js +1 -1
  19. package/dist/index.js +1 -1
  20. package/dist/server.js +1 -1
  21. package/dist/verifier-Z26UC7M4.js +2 -0
  22. package/dist/{verifier-6M7GY4TW.js.map → verifier-Z26UC7M4.js.map} +1 -1
  23. package/dist/workers/logic-execution.d.ts +7 -6
  24. package/dist/workers/logic-execution.js +1 -1
  25. package/dist/workers/logic-execution.js.map +1 -1
  26. package/dist/workers/zk-verifier.d.ts +4 -4
  27. package/dist/workers/zk-verifier.js +1 -1
  28. package/dist/workers/zk-verifier.js.map +1 -1
  29. package/package.json +1 -1
  30. package/dist/chunk-C65RM2A3.js.map +0 -1
  31. package/dist/chunk-GD6EOKYV.js.map +0 -1
  32. package/dist/chunk-UVTEJYHN.js +0 -2
  33. package/dist/chunk-UVTEJYHN.js.map +0 -1
  34. package/dist/verifier-6M7GY4TW.js +0 -2
@@ -1,4 +1,4 @@
1
- import {a as a$1}from'./chunk-UVTEJYHN.js';import {a as a$3}from'./chunk-DBXGYHKY.js';import {a as a$2,c}from'./chunk-V5MKJT6S.js';import {a}from'./chunk-S6RJHZV2.js';import*as z from'crypto';var H=class{name="o200k_base";countFn;constructor(e,t){this.countFn=e,t&&t(1e4);}countTokens(e){return e.length===0?0:this.countFn(e)}},B=class{name="heuristic (chars/4)";countTokens(e){return e.length===0?0:Math.ceil(e.length/4)}};async function ue(){try{let i=await import('gpt-tokenizer'),e=new H(i.countTokens,i.setMergeCacheSize);return a.debug("[LIOP-Economy] Token estimator initialized: o200k_base"),e}catch{return a.info("[LIOP-Economy] gpt-tokenizer unavailable, falling back to heuristic estimator"),new B}}function le(){return new B}var R="1.9.1";var pe=/^(\d+)\.(\d+)\.(\d+)(-(.+))?$/;function ye(i){let e=new Set([i]),t=new Set,r=i.match(pe);if(!r)return ()=>false;let s={major:+r[1],minor:+r[2],patch:+r[3],prerelease:r[4]};if(s.prerelease!=null)return function(a){return a===i};function o(c){return t.add(c),false}function n(c){return e.add(c),true}return function(a){if(e.has(a))return true;if(t.has(a))return false;let u=a.match(pe);if(!u)return o(a);let m={major:+u[1],minor:+u[2],patch:+u[3],prerelease:u[4]};return m.prerelease!=null||s.major!==m.major?o(a):s.major===0?s.minor===m.minor&&s.patch<=m.patch?n(a):o(a):s.minor<=m.minor?n(a):o(a)}}var me=ye(R);var ve=R.split(".")[0],L=Symbol.for(`opentelemetry.js.api.${ve}`),x=typeof globalThis=="object"?globalThis:typeof self=="object"?self:typeof window=="object"?window:typeof global=="object"?global:{};function j(i,e,t,r=false){var s;let o=x[L]=(s=x[L])!==null&&s!==void 0?s:{version:R};if(!r&&o[i]){let n=new Error(`@opentelemetry/api: Attempted duplicate registration of API: ${i}`);return t.error(n.stack||n.message),false}if(o.version!==R){let n=new Error(`@opentelemetry/api: Registration of version v${o.version} for ${i} does not match previously registered API v${R}`);return t.error(n.stack||n.message),false}return o[i]=e,t.debug(`@opentelemetry/api: Registered a global for ${i} v${R}.`),true}function N(i){var e,t;let r=(e=x[L])===null||e===void 0?void 0:e.version;if(!(!r||!me(r)))return (t=x[L])===null||t===void 0?void 0:t[i]}function U(i,e){e.debug(`@opentelemetry/api: Unregistering a global for ${i} v${R}.`);let t=x[L];t&&delete t[i];}var F=class{constructor(e){this._namespace=e.namespace||"DiagComponentLogger";}debug(...e){return $("debug",this._namespace,e)}error(...e){return $("error",this._namespace,e)}info(...e){return $("info",this._namespace,e)}warn(...e){return $("warn",this._namespace,e)}verbose(...e){return $("verbose",this._namespace,e)}};function $(i,e,t){let r=N("diag");if(r)return r[i](e,...t)}var _;(function(i){i[i.NONE=0]="NONE",i[i.ERROR=30]="ERROR",i[i.WARN=50]="WARN",i[i.INFO=60]="INFO",i[i.DEBUG=70]="DEBUG",i[i.VERBOSE=80]="VERBOSE",i[i.ALL=9999]="ALL";})(_||(_={}));function de(i,e){i<_.NONE?i=_.NONE:i>_.ALL&&(i=_.ALL),e=e||{};function t(r,s){let o=e[r];return typeof o=="function"&&i>=s?o.bind(e):function(){}}return {error:t("error",_.ERROR),warn:t("warn",_.WARN),info:t("info",_.INFO),debug:t("debug",_.DEBUG),verbose:t("verbose",_.VERBOSE)}}var Oe="diag",A=class i{static instance(){return this._instance||(this._instance=new i),this._instance}constructor(){function e(s){return function(...o){let n=N("diag");if(n)return n[s](...o)}}let t=this,r=(s,o={logLevel:_.INFO})=>{var n,c,a;if(s===t){let f=new Error("Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation");return t.error((n=f.stack)!==null&&n!==void 0?n:f.message),false}typeof o=="number"&&(o={logLevel:o});let u=N("diag"),m=de((c=o.logLevel)!==null&&c!==void 0?c:_.INFO,s);if(u&&!o.suppressOverrideMessage){let f=(a=new Error().stack)!==null&&a!==void 0?a:"<failed to generate stacktrace>";u.warn(`Current logger will be overwritten from ${f}`),m.warn(`Current logger will overwrite one already registered from ${f}`);}return j("diag",m,t,true)};t.setLogger=r,t.disable=()=>{U(Oe,t);},t.createComponentLogger=s=>new F(s),t.verbose=e("verbose"),t.debug=e("debug"),t.info=e("info"),t.warn=e("warn"),t.error=e("error");}};var W=class{constructor(){}createGauge(e,t){return Ie}createHistogram(e,t){return Pe}createCounter(e,t){return _e}createUpDownCounter(e,t){return Se}createObservableGauge(e,t){return ke}createObservableCounter(e,t){return Ee}createObservableUpDownCounter(e,t){return Re}addBatchObservableCallback(e,t){}removeBatchObservableCallback(e){}},M=class{},J=class extends M{add(e,t){}},K=class extends M{add(e,t){}},q=class extends M{record(e,t){}},Q=class extends M{record(e,t){}},D=class{addCallback(e){}removeCallback(e){}},X=class extends D{},Y=class extends D{},Z=class extends D{},fe=new W,_e=new J,Ie=new q,Pe=new Q,Se=new K,Ee=new X,ke=new Y,Re=new Z;var ee=class{getMeter(e,t,r){return fe}},he=new ee;var te="metrics",V=class i{constructor(){}static getInstance(){return this._instance||(this._instance=new i),this._instance}setGlobalMeterProvider(e){return j(te,e,A.instance())}getMeterProvider(){return N(te)||he}getMeter(e,t,r){return this.getMeterProvider().getMeter(e,t,r)}disable(){U(te,A.instance());}};var oe=V.getInstance();var be="@nekzus/liop",Ne="1.2.0-alpha.9",we=[1,4,16,64,256,1024,4096,16384,65536,262144,1048576,4194304,16777216,67108864],Me=[.01,.02,.04,.08,.16,.32,.64,1.28,2.56,5.12,10.24,20.48,40.96,81.92],G=class{tokenUsage;operationDuration;active=false;constructor(){try{let e=oe.getMeter(be,Ne);this.tokenUsage=e.createHistogram("gen_ai.client.token.usage",{description:"Number of tokens used in LIOP Logic-on-Origin operations",unit:"{token}",advice:{explicitBucketBoundaries:we}}),this.operationDuration=e.createHistogram("gen_ai.client.operation.duration",{description:"Duration of LIOP operations",unit:"s",advice:{explicitBucketBoundaries:Me}}),this.active=!0,a.debug("[LIOP-OTel] gen_ai.* metrics bridge initialized");}catch(e){a.debug(`[LIOP-OTel] Bridge disabled: ${e instanceof Error?e.message:String(e)}`);let t={record:()=>{}};this.tokenUsage=t,this.operationDuration=t;}}recordTokens(e,t,r,s){this.tokenUsage.record(e,{"gen_ai.system":"liop","gen_ai.operation.name":r,"gen_ai.token.type":t,"gen_ai.request.model":"liop-mesh",...s?{"liop.tool.name":s}:{}});}recordDuration(e,t,r){this.operationDuration.record(e/1e3,{"gen_ai.system":"liop","gen_ai.operation.name":t,...r?{"error.type":r}:{}});}isActive(){return this.active}};var Ce={tools_list:"chat",tool_call:"execute_tool",resource_read:"chat",resource_list:"chat",prompt_get:"chat",prompt_list:"chat",diagnostic:"chat"},P=class i{static instance=null;operations=[];sessionId;startedAt;estimator;otelBridge;constructor(){this.sessionId=crypto.randomUUID(),this.startedAt=Date.now(),this.estimator=le(),this.otelBridge=new G,this.initRealEstimator();}initRealEstimator(){ue().then(e=>{this.estimator=e;}).catch(()=>{});}static getInstance(){return i.instance||(i.instance=new i),i.instance}countTokens(e){try{return this.estimator.countTokens(e)}catch{return Math.ceil(e.length/4)}}record(e){let t={...e,timestamp:Date.now()};this.operations.push(t);try{let r=Ce[e.type]||"chat";e.estimatedInputTokens>0&&this.otelBridge.recordTokens(e.estimatedInputTokens,"input",r,e.toolName),e.estimatedOutputTokens>0&&this.otelBridge.recordTokens(e.estimatedOutputTokens,"output",r,e.toolName),e.durationMs!==void 0&&this.otelBridge.recordDuration(e.durationMs,r);}catch{}}estimateTokens(e){return this.countTokens(e)}getReport(){return {sessionId:this.sessionId,operations:[...this.operations],totalInputTokens:this.operations.reduce((e,t)=>e+t.estimatedInputTokens,0),totalOutputTokens:this.operations.reduce((e,t)=>e+t.estimatedOutputTokens,0),estimatorName:this.estimator.name,sessionUptimeMs:Date.now()-this.startedAt}}getPerToolReport(){let e=new Map;for(let t of this.operations){let r=t.toolName||t.method,s=e.get(r)||{input:0,output:0,calls:0,avgDurationMs:0},o=s.avgDurationMs*s.calls+(t.durationMs||0),n=s.calls+1;e.set(r,{input:s.input+t.estimatedInputTokens,output:s.output+t.estimatedOutputTokens,calls:n,avgDurationMs:n>0?o/n:0});}return e}formatStatusBlock(){let e=this.getReport();if(e.operations.length===0)return "";let t=this.formatUptime(e.sessionUptimeMs),r=e.totalInputTokens+e.totalOutputTokens,s=new Map;for(let d of e.operations){let g=d.type,h=s.get(g)||{count:0,input:0,output:0};s.set(g,{count:h.count+1,input:h.input+d.estimatedInputTokens,output:h.output+d.estimatedOutputTokens});}let o=Array.from(s.entries()),n=o.map(([d,g],h)=>{let k=h===o.length-1?"\u2502 \u2514\u2500":"\u2502 \u251C\u2500",S=g.output>0?` / ${g.output.toLocaleString()} out`:"";return `${k} ${d} \xD7${g.count} \u2192 ${g.input.toLocaleString()} in${S}`}),c=this.getPerToolReport(),a=Array.from(c.entries()).filter(([d])=>d!=="tools/list"&&d!=="LiopMeshStatus"),u=[];a.length>0&&(u.push("\u251C\u2500 By Tool:"),a.forEach(([d,g],h)=>{let k=h===a.length-1?"\u2502 \u2514\u2500":"\u2502 \u251C\u2500",S=g.output>0?` / ${g.output.toLocaleString()} out`:"",I=g.avgDurationMs>0?` ~${Math.round(g.avgDurationMs)}ms`:"";u.push(`${k} ${d}: ${g.input.toLocaleString()} in${S} (\xD7${g.calls})${I}`);}));let m=e.operations.filter(d=>d.durationMs!==void 0),f=m.length>0?Math.round(m.reduce((d,g)=>d+(g.durationMs||0),0)/m.length):0,l=this.otelBridge.isActive()?"gen_ai.client.token.usage \u2192 active":"disabled";return [`
1
+ import {a as a$1}from'./chunk-SW53FNSN.js';import {a as a$3}from'./chunk-DBXGYHKY.js';import {a as a$2,c}from'./chunk-V5MKJT6S.js';import {a}from'./chunk-S6RJHZV2.js';import*as z from'crypto';var H=class{name="o200k_base";countFn;constructor(e,t){this.countFn=e,t&&t(1e4);}countTokens(e){return e.length===0?0:this.countFn(e)}},B=class{name="heuristic (chars/4)";countTokens(e){return e.length===0?0:Math.ceil(e.length/4)}};async function ue(){try{let i=await import('gpt-tokenizer'),e=new H(i.countTokens,i.setMergeCacheSize);return a.debug("[LIOP-Economy] Token estimator initialized: o200k_base"),e}catch{return a.info("[LIOP-Economy] gpt-tokenizer unavailable, falling back to heuristic estimator"),new B}}function le(){return new B}var R="1.9.1";var pe=/^(\d+)\.(\d+)\.(\d+)(-(.+))?$/;function ye(i){let e=new Set([i]),t=new Set,r=i.match(pe);if(!r)return ()=>false;let s={major:+r[1],minor:+r[2],patch:+r[3],prerelease:r[4]};if(s.prerelease!=null)return function(a){return a===i};function o(c){return t.add(c),false}function n(c){return e.add(c),true}return function(a){if(e.has(a))return true;if(t.has(a))return false;let u=a.match(pe);if(!u)return o(a);let m={major:+u[1],minor:+u[2],patch:+u[3],prerelease:u[4]};return m.prerelease!=null||s.major!==m.major?o(a):s.major===0?s.minor===m.minor&&s.patch<=m.patch?n(a):o(a):s.minor<=m.minor?n(a):o(a)}}var me=ye(R);var ve=R.split(".")[0],L=Symbol.for(`opentelemetry.js.api.${ve}`),x=typeof globalThis=="object"?globalThis:typeof self=="object"?self:typeof window=="object"?window:typeof global=="object"?global:{};function j(i,e,t,r=false){var s;let o=x[L]=(s=x[L])!==null&&s!==void 0?s:{version:R};if(!r&&o[i]){let n=new Error(`@opentelemetry/api: Attempted duplicate registration of API: ${i}`);return t.error(n.stack||n.message),false}if(o.version!==R){let n=new Error(`@opentelemetry/api: Registration of version v${o.version} for ${i} does not match previously registered API v${R}`);return t.error(n.stack||n.message),false}return o[i]=e,t.debug(`@opentelemetry/api: Registered a global for ${i} v${R}.`),true}function N(i){var e,t;let r=(e=x[L])===null||e===void 0?void 0:e.version;if(!(!r||!me(r)))return (t=x[L])===null||t===void 0?void 0:t[i]}function U(i,e){e.debug(`@opentelemetry/api: Unregistering a global for ${i} v${R}.`);let t=x[L];t&&delete t[i];}var F=class{constructor(e){this._namespace=e.namespace||"DiagComponentLogger";}debug(...e){return $("debug",this._namespace,e)}error(...e){return $("error",this._namespace,e)}info(...e){return $("info",this._namespace,e)}warn(...e){return $("warn",this._namespace,e)}verbose(...e){return $("verbose",this._namespace,e)}};function $(i,e,t){let r=N("diag");if(r)return r[i](e,...t)}var _;(function(i){i[i.NONE=0]="NONE",i[i.ERROR=30]="ERROR",i[i.WARN=50]="WARN",i[i.INFO=60]="INFO",i[i.DEBUG=70]="DEBUG",i[i.VERBOSE=80]="VERBOSE",i[i.ALL=9999]="ALL";})(_||(_={}));function de(i,e){i<_.NONE?i=_.NONE:i>_.ALL&&(i=_.ALL),e=e||{};function t(r,s){let o=e[r];return typeof o=="function"&&i>=s?o.bind(e):function(){}}return {error:t("error",_.ERROR),warn:t("warn",_.WARN),info:t("info",_.INFO),debug:t("debug",_.DEBUG),verbose:t("verbose",_.VERBOSE)}}var Oe="diag",A=class i{static instance(){return this._instance||(this._instance=new i),this._instance}constructor(){function e(s){return function(...o){let n=N("diag");if(n)return n[s](...o)}}let t=this,r=(s,o={logLevel:_.INFO})=>{var n,c,a;if(s===t){let f=new Error("Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation");return t.error((n=f.stack)!==null&&n!==void 0?n:f.message),false}typeof o=="number"&&(o={logLevel:o});let u=N("diag"),m=de((c=o.logLevel)!==null&&c!==void 0?c:_.INFO,s);if(u&&!o.suppressOverrideMessage){let f=(a=new Error().stack)!==null&&a!==void 0?a:"<failed to generate stacktrace>";u.warn(`Current logger will be overwritten from ${f}`),m.warn(`Current logger will overwrite one already registered from ${f}`);}return j("diag",m,t,true)};t.setLogger=r,t.disable=()=>{U(Oe,t);},t.createComponentLogger=s=>new F(s),t.verbose=e("verbose"),t.debug=e("debug"),t.info=e("info"),t.warn=e("warn"),t.error=e("error");}};var W=class{constructor(){}createGauge(e,t){return Ie}createHistogram(e,t){return Pe}createCounter(e,t){return _e}createUpDownCounter(e,t){return Se}createObservableGauge(e,t){return ke}createObservableCounter(e,t){return Ee}createObservableUpDownCounter(e,t){return Re}addBatchObservableCallback(e,t){}removeBatchObservableCallback(e){}},M=class{},J=class extends M{add(e,t){}},K=class extends M{add(e,t){}},q=class extends M{record(e,t){}},Q=class extends M{record(e,t){}},D=class{addCallback(e){}removeCallback(e){}},X=class extends D{},Y=class extends D{},Z=class extends D{},fe=new W,_e=new J,Ie=new q,Pe=new Q,Se=new K,Ee=new X,ke=new Y,Re=new Z;var ee=class{getMeter(e,t,r){return fe}},he=new ee;var te="metrics",V=class i{constructor(){}static getInstance(){return this._instance||(this._instance=new i),this._instance}setGlobalMeterProvider(e){return j(te,e,A.instance())}getMeterProvider(){return N(te)||he}getMeter(e,t,r){return this.getMeterProvider().getMeter(e,t,r)}disable(){U(te,A.instance());}};var oe=V.getInstance();var be="@nekzus/liop",Ne="1.2.0-alpha.9",we=[1,4,16,64,256,1024,4096,16384,65536,262144,1048576,4194304,16777216,67108864],Me=[.01,.02,.04,.08,.16,.32,.64,1.28,2.56,5.12,10.24,20.48,40.96,81.92],G=class{tokenUsage;operationDuration;active=false;constructor(){try{let e=oe.getMeter(be,Ne);this.tokenUsage=e.createHistogram("gen_ai.client.token.usage",{description:"Number of tokens used in LIOP Logic-on-Origin operations",unit:"{token}",advice:{explicitBucketBoundaries:we}}),this.operationDuration=e.createHistogram("gen_ai.client.operation.duration",{description:"Duration of LIOP operations",unit:"s",advice:{explicitBucketBoundaries:Me}}),this.active=!0,a.debug("[LIOP-OTel] gen_ai.* metrics bridge initialized");}catch(e){a.debug(`[LIOP-OTel] Bridge disabled: ${e instanceof Error?e.message:String(e)}`);let t={record:()=>{}};this.tokenUsage=t,this.operationDuration=t;}}recordTokens(e,t,r,s){this.tokenUsage.record(e,{"gen_ai.system":"liop","gen_ai.operation.name":r,"gen_ai.token.type":t,"gen_ai.request.model":"liop-mesh",...s?{"liop.tool.name":s}:{}});}recordDuration(e,t,r){this.operationDuration.record(e/1e3,{"gen_ai.system":"liop","gen_ai.operation.name":t,...r?{"error.type":r}:{}});}isActive(){return this.active}};var Ce={tools_list:"chat",tool_call:"execute_tool",resource_read:"chat",resource_list:"chat",prompt_get:"chat",prompt_list:"chat",diagnostic:"chat"},P=class i{static instance=null;operations=[];sessionId;startedAt;estimator;otelBridge;constructor(){this.sessionId=crypto.randomUUID(),this.startedAt=Date.now(),this.estimator=le(),this.otelBridge=new G,this.initRealEstimator();}initRealEstimator(){ue().then(e=>{this.estimator=e;}).catch(()=>{});}static getInstance(){return i.instance||(i.instance=new i),i.instance}countTokens(e){try{return this.estimator.countTokens(e)}catch{return Math.ceil(e.length/4)}}record(e){let t={...e,timestamp:Date.now()};this.operations.push(t);try{let r=Ce[e.type]||"chat";e.estimatedInputTokens>0&&this.otelBridge.recordTokens(e.estimatedInputTokens,"input",r,e.toolName),e.estimatedOutputTokens>0&&this.otelBridge.recordTokens(e.estimatedOutputTokens,"output",r,e.toolName),e.durationMs!==void 0&&this.otelBridge.recordDuration(e.durationMs,r);}catch{}}estimateTokens(e){return this.countTokens(e)}getReport(){return {sessionId:this.sessionId,operations:[...this.operations],totalInputTokens:this.operations.reduce((e,t)=>e+t.estimatedInputTokens,0),totalOutputTokens:this.operations.reduce((e,t)=>e+t.estimatedOutputTokens,0),estimatorName:this.estimator.name,sessionUptimeMs:Date.now()-this.startedAt}}getPerToolReport(){let e=new Map;for(let t of this.operations){let r=t.toolName||t.method,s=e.get(r)||{input:0,output:0,calls:0,avgDurationMs:0},o=s.avgDurationMs*s.calls+(t.durationMs||0),n=s.calls+1;e.set(r,{input:s.input+t.estimatedInputTokens,output:s.output+t.estimatedOutputTokens,calls:n,avgDurationMs:n>0?o/n:0});}return e}formatStatusBlock(){let e=this.getReport();if(e.operations.length===0)return "";let t=this.formatUptime(e.sessionUptimeMs),r=e.totalInputTokens+e.totalOutputTokens,s=new Map;for(let d of e.operations){let g=d.type,h=s.get(g)||{count:0,input:0,output:0};s.set(g,{count:h.count+1,input:h.input+d.estimatedInputTokens,output:h.output+d.estimatedOutputTokens});}let o=Array.from(s.entries()),n=o.map(([d,g],h)=>{let k=h===o.length-1?"\u2502 \u2514\u2500":"\u2502 \u251C\u2500",S=g.output>0?` / ${g.output.toLocaleString()} out`:"";return `${k} ${d} \xD7${g.count} \u2192 ${g.input.toLocaleString()} in${S}`}),c=this.getPerToolReport(),a=Array.from(c.entries()).filter(([d])=>d!=="tools/list"&&d!=="LiopMeshStatus"),u=[];a.length>0&&(u.push("\u251C\u2500 By Tool:"),a.forEach(([d,g],h)=>{let k=h===a.length-1?"\u2502 \u2514\u2500":"\u2502 \u251C\u2500",S=g.output>0?` / ${g.output.toLocaleString()} out`:"",I=g.avgDurationMs>0?` ~${Math.round(g.avgDurationMs)}ms`:"";u.push(`${k} ${d}: ${g.input.toLocaleString()} in${S} (\xD7${g.calls})${I}`);}));let m=e.operations.filter(d=>d.durationMs!==void 0),f=m.length>0?Math.round(m.reduce((d,g)=>d+(g.durationMs||0),0)/m.length):0,l=this.otelBridge.isActive()?"gen_ai.client.token.usage \u2192 active":"disabled";return [`
2
2
  Token Economy:`,`\u251C\u2500 Session: ${e.sessionId.slice(0,8)} (${t})`,`\u251C\u2500 Estimator: ${e.estimatorName}`,`\u251C\u2500 Operations: ${e.operations.length}`,...n,`\u251C\u2500 Total: ${e.totalInputTokens.toLocaleString()} in / ${e.totalOutputTokens.toLocaleString()} out (${r.toLocaleString()} combined)`,...u,...f>0?[`\u251C\u2500 Avg Latency: ${f}ms`]:[],`\u2514\u2500 OTel: ${l}`].join(`
3
3
  `)}formatUptime(e){let t=Math.floor(e/1e3);if(t<60)return `${t}s`;let r=Math.floor(t/60),s=t%60;if(r<60)return `${r}m ${s}s`;let o=Math.floor(r/60),n=r%60;return `${o}h ${n}m`}reset(){this.operations=[];}static destroy(){i.instance=null;}};function C(){let i=process.env.LIOP_MCP_COMPACT_TOOL_DESCRIPTIONS?.toLowerCase().trim();return !(i==="0"||i==="false"||i==="no")}function re(i){let e=i,t=[`
4
4
 
@@ -29,5 +29,5 @@ ${d}
29
29
  Discovered Remote Tools (Zero-Trust Origins):
30
30
  ${S}`:`
31
31
  No remote tools discovered yet.`,P.getInstance().formatStatusBlock()].filter(O=>O!=="").join(`
32
- `),b=P.getInstance();return b.record({type:"diagnostic",method:"tools/call",toolName:"LiopMeshStatus",estimatedInputTokens:0,estimatedOutputTokens:b.countTokens(I)}),{jsonrpc:"2.0",id:e,result:{content:[{type:"text",text:I}]}}}let s=this.liopServer.listTools().some(o=>o.name===r);if(!s&&this.meshNode){let o=this.resolveManifestTarget(r);if(o||(await this.refreshManifestCache(),o=this.resolveManifestTarget(r)),o)return a.info(`[LIOP-Router] Resolved ${r} via manifest cache (Peer: ${o.peerId}, Original: ${o.originalToolName})`),this.routeToRemoteProvider(e,o.originalToolName,o.peerId,t);let n=[];for(let c=0;c<3&&(n=await this.meshNode.findProviders(r),!(n.length>0));c++)c<2&&await new Promise(a=>setTimeout(a,1e3));if(n.length>0)return this.routeToRemoteProvider(e,r,n[0],t)}if(s)try{let o=Date.now(),n=await this.liopServer.callTool({name:r,arguments:t.arguments||{}}),c=P.getInstance(),a=JSON.stringify(t.arguments||{}),u=JSON.stringify(n);return c.record({type:"tool_call",method:"tools/call",toolName:r,estimatedInputTokens:c.countTokens(a),estimatedOutputTokens:c.countTokens(u),durationMs:Date.now()-o}),{jsonrpc:"2.0",id:e,result:n}}catch(o){return {jsonrpc:"2.0",id:e,error:{code:-32e3,message:o instanceof Error?o.message:String(o)}}}return {jsonrpc:"2.0",id:e,error:{code:-32002,message:`No provider found for tool: ${r}. Ensure the provider node is active and connected to the mesh.`}}}async routeToRemoteProvider(e,t,r,s){if(!this.meshNode)return {jsonrpc:"2.0",id:e,error:{code:-32603,message:"Mesh Node inactive"}};let o=this.manifestCache.get(r),n=this.defaultRpcPort;if(o)n=o.manifest.grpcPort;else {let p=await this.meshNode.queryManifest(r);p&&(n=p.grpcPort,this.manifestCache.set(r,{manifest:p,cachedAt:Date.now()}),o=this.manifestCache.get(r));}if((process.env.LIOP_USE_PUBLISHED_GRPC_PORTS==="1"||process.env.LIOP_DOCKER_MAP==="true"||process.env.LIOP_DEV_MODE==="true"||process.env.NODE_ENV==="development"||process.env.NODE_ENV==="test")&&o){let p=o.manifest.serverInfo?.name?.toLowerCase()||"";p.includes("vault")?n=13011:p.includes("bank")?n=13021:p.includes("oracle")&&(n=13031);}let a$1=await this.meshNode.resolvePeer(r),u=null,m=await import('os'),f=Object.values(m.networkInterfaces()).flat().filter(p=>p?.family==="IPv4").map(p=>p?.address);for(let p of a$1){let d=p.split("/"),g=d.indexOf("ip4");if(g!==-1){let h=d[g+1];if(h==="127.0.0.1"||f.includes(h)){u=`127.0.0.1:${n}`;break}u||(u=`${h}:${n}`);}}u||(u=`127.0.0.1:${n}`),a.info(`[LIOP-Router] Dynamic route: ${t} -> ${u} (PeerID: ${r})`);let l=new a$2.LogicMesh(u,c());return this.performTranscoding(e,l,t,s,r)}async performTranscoding(e,t,r,s,o){let n=r,c=this.meshNode?await this.meshNode.sign(Buffer.from(n)):Buffer.from([]),a=Date.now();return new Promise(u=>{t.negotiateIntent({agent_did:`did:liop:${this.meshNode?.getPeerId()||"mcp-proxy"}`,capability_hash:n,proof_of_intent:c},async(m,f)=>{if(m||!f.accepted)return u({jsonrpc:"2.0",id:e,result:{content:[{type:"text",text:`PQC Handshake Failed: ${m?.message||"Rejected"}`}],isError:true}});let{ciphertext:l,sharedSecret:p}=await a$3.encapsulateAsymmetric(f.kyber_public_key),d=JSON.stringify(s.arguments||{}),g=`return { "__liop_proxy_tool": "${r}", "__liop_proxy_args": ${d} };`,h=z.randomBytes(12),k=this.encryptWithNonce(Buffer.from(g),p,h),S=t.executeLogic({session_token:f.session_token,wasm_binary:new Uint8Array(k),inputs:{},pqc_ciphertext:l,aes_nonce:h}),I="",b=null;S.on("data",O=>{I+=O.semantic_evidence,b=O;}),S.on("end",async()=>{try{if(b&&!b.is_error){let w=Buffer.from(b.cryptographic_proof).toString("hex");if(!await this.verifier.verifyZkReceipt(Buffer.from(g),w,Buffer.from(b.zk_receipt),Buffer.from(p)))return u({jsonrpc:"2.0",id:e,result:{content:[{type:"text",text:"SECURITY ALERT: Remote response failed cryptographic integrity audit."}],isError:!0}})}let O=JSON.parse(I),E=P.getInstance();E.record({type:"tool_call",method:"tools/call",toolName:r,peerId:o,estimatedInputTokens:E.countTokens(d),estimatedOutputTokens:E.countTokens(I),durationMs:Date.now()-a}),u({jsonrpc:"2.0",id:e,result:O});}catch{u({jsonrpc:"2.0",id:e,result:{content:[{type:"text",text:I}]}});}}),S.on("error",O=>u({jsonrpc:"2.0",id:e,result:{content:[{type:"text",text:`LIOP gRPC Error: ${O.message}`}],isError:true}}));});})}encryptWithNonce(e,t,r){let s=z.createCipheriv("aes-256-gcm",t,r),o=Buffer.concat([s.update(e),s.final()]);return Buffer.concat([o,s.getAuthTag()])}};export{H as a,B as b,ue as c,le as d,G as e,P as f,Te as g};//# sourceMappingURL=chunk-LJQF6ULT.js.map
33
- //# sourceMappingURL=chunk-LJQF6ULT.js.map
32
+ `),b=P.getInstance();return b.record({type:"diagnostic",method:"tools/call",toolName:"LiopMeshStatus",estimatedInputTokens:0,estimatedOutputTokens:b.countTokens(I)}),{jsonrpc:"2.0",id:e,result:{content:[{type:"text",text:I}]}}}let s=this.liopServer.listTools().some(o=>o.name===r);if(!s&&this.meshNode){let o=this.resolveManifestTarget(r);if(o||(await this.refreshManifestCache(),o=this.resolveManifestTarget(r)),o)return a.info(`[LIOP-Router] Resolved ${r} via manifest cache (Peer: ${o.peerId}, Original: ${o.originalToolName})`),this.routeToRemoteProvider(e,o.originalToolName,o.peerId,t);let n=[];for(let c=0;c<3&&(n=await this.meshNode.findProviders(r),!(n.length>0));c++)c<2&&await new Promise(a=>setTimeout(a,1e3));if(n.length>0)return this.routeToRemoteProvider(e,r,n[0],t)}if(s)try{let o=Date.now(),n=await this.liopServer.callTool({name:r,arguments:t.arguments||{}}),c=P.getInstance(),a=JSON.stringify(t.arguments||{}),u=JSON.stringify(n);return c.record({type:"tool_call",method:"tools/call",toolName:r,estimatedInputTokens:c.countTokens(a),estimatedOutputTokens:c.countTokens(u),durationMs:Date.now()-o}),{jsonrpc:"2.0",id:e,result:n}}catch(o){return {jsonrpc:"2.0",id:e,error:{code:-32e3,message:o instanceof Error?o.message:String(o)}}}return {jsonrpc:"2.0",id:e,error:{code:-32002,message:`No provider found for tool: ${r}. Ensure the provider node is active and connected to the mesh.`}}}async routeToRemoteProvider(e,t,r,s){if(!this.meshNode)return {jsonrpc:"2.0",id:e,error:{code:-32603,message:"Mesh Node inactive"}};let o=this.manifestCache.get(r),n=this.defaultRpcPort;if(o)n=o.manifest.grpcPort;else {let p=await this.meshNode.queryManifest(r);p&&(n=p.grpcPort,this.manifestCache.set(r,{manifest:p,cachedAt:Date.now()}),o=this.manifestCache.get(r));}if((process.env.LIOP_USE_PUBLISHED_GRPC_PORTS==="1"||process.env.LIOP_DOCKER_MAP==="true"||process.env.LIOP_DEV_MODE==="true"||process.env.NODE_ENV==="development"||process.env.NODE_ENV==="test")&&o){let p=o.manifest.serverInfo?.name?.toLowerCase()||"";p.includes("vault")?n=13011:p.includes("bank")?n=13021:p.includes("oracle")&&(n=13031);}let a$1=await this.meshNode.resolvePeer(r),u=null,m=await import('os'),f=Object.values(m.networkInterfaces()).flat().filter(p=>p?.family==="IPv4").map(p=>p?.address);for(let p of a$1){let d=p.split("/"),g=d.indexOf("ip4");if(g!==-1){let h=d[g+1];if(h==="127.0.0.1"||f.includes(h)){u=`127.0.0.1:${n}`;break}u||(u=`${h}:${n}`);}}u||(u=`127.0.0.1:${n}`),a.info(`[LIOP-Router] Dynamic route: ${t} -> ${u} (PeerID: ${r})`);let l=new a$2.LogicMesh(u,c());return this.performTranscoding(e,l,t,s,r)}async performTranscoding(e,t,r,s,o){let n=r,c=this.meshNode?await this.meshNode.sign(Buffer.from(n)):Buffer.from([]),a=Date.now();return new Promise(u=>{t.negotiateIntent({agent_did:`did:liop:${this.meshNode?.getPeerId()||"mcp-proxy"}`,capability_hash:n,proof_of_intent:c},async(m,f)=>{if(m||!f.accepted)return u({jsonrpc:"2.0",id:e,result:{content:[{type:"text",text:`PQC Handshake Failed: ${m?.message||"Rejected"}`}],isError:true}});let{ciphertext:l,sharedSecret:p}=await a$3.encapsulateAsymmetric(f.kyber_public_key),d=JSON.stringify(s.arguments||{}),g=`return { "__liop_proxy_tool": "${r}", "__liop_proxy_args": ${d} };`,h=z.randomBytes(12),k=this.encryptWithNonce(Buffer.from(g),p,h),S=t.executeLogic({session_token:f.session_token,wasm_binary:new Uint8Array(k),inputs:{},pqc_ciphertext:l,aes_nonce:h}),I="",b=null;S.on("data",O=>{I+=O.semantic_evidence,b=O;}),S.on("end",async()=>{try{if(b&&!b.is_error){let w=Buffer.from(b.cryptographic_proof).toString("hex");if(!await this.verifier.verifyZkReceipt(Buffer.from(g),w,Buffer.from(b.zk_receipt),Buffer.from(p)))return u({jsonrpc:"2.0",id:e,result:{content:[{type:"text",text:"SECURITY ALERT: Remote response failed cryptographic integrity audit."}],isError:!0}})}let O=JSON.parse(I),E=P.getInstance();E.record({type:"tool_call",method:"tools/call",toolName:r,peerId:o,estimatedInputTokens:E.countTokens(d),estimatedOutputTokens:E.countTokens(I),durationMs:Date.now()-a}),u({jsonrpc:"2.0",id:e,result:O});}catch{u({jsonrpc:"2.0",id:e,result:{content:[{type:"text",text:I}]}});}}),S.on("error",O=>u({jsonrpc:"2.0",id:e,result:{content:[{type:"text",text:`LIOP gRPC Error: ${O.message}`}],isError:true}}));});})}encryptWithNonce(e,t,r){let s=z.createCipheriv("aes-256-gcm",t,r),o=Buffer.concat([s.update(e),s.final()]);return Buffer.concat([o,s.getAuthTag()])}};export{H as a,B as b,ue as c,le as d,G as e,P as f,Te as g};//# sourceMappingURL=chunk-GFRRQ2EB.js.map
33
+ //# sourceMappingURL=chunk-GFRRQ2EB.js.map