@mcp-use/inspector 0.4.12 → 0.4.13-canary.0
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/client/assets/{chunk-VL2OQCWN-B6188h-8.js → chunk-VL2OQCWN-D5zTMCrV.js} +2 -2
- package/dist/client/assets/embeddings-T3ulhIAT.js +1 -0
- package/dist/client/assets/{index-x_xzGcAx.js → index-B1m6hcte.js} +1 -1
- package/dist/client/assets/index-BgTUJ2nU.js +81 -0
- package/dist/client/assets/{index-LZZ02vm2.js → index-D2syF8VP.js} +4 -4
- package/dist/client/assets/index-D8wSHXf0.js +70 -0
- package/dist/client/assets/index-DOTQn2XV.js +4 -0
- package/dist/client/assets/{index-azKdcp4V.js → index-X8eKTn1y.js} +4 -4
- package/dist/client/assets/{index-Dhd81mGH.js → index-jpgFjbgb.js} +3 -3
- package/dist/client/assets/{index-B2AaM8iX.js → index-q-FFFyxK.js} +6 -6
- package/dist/client/assets/{langfuse-C4HKZ3NL-DdY799py.js → langfuse-C4HKZ3NL-DxYt-pQv.js} +3 -3
- package/dist/client/assets/{winston-BxLvA24A.js → winston-PkVSuyBJ.js} +1 -1
- package/dist/client/index.html +2 -2
- package/package.json +10 -5
- package/dist/client/assets/embeddings-CmTKipI3.js +0 -1
- package/dist/client/assets/index-CvPVR03j.js +0 -4
- package/dist/client/assets/index-DI2GdDtn.js +0 -150
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-
|
|
2
|
-
var hy=Object.defineProperty;var py=(e,t,n)=>t in e?hy(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var su=(e,t,n)=>py(e,typeof t!="symbol"?t+"":t,n);import{_ as G,c as ji,u as en,a as ht,d as Rc,n as St,s as Oe,e as Pn,o as te,f as fy,Z as R,h as Ht,i as au,l as Io,j as my,k as Yd,p as Xd,m as Fr,r as $c,q as Qd,t as T,v as gy,w as $a,B as yy,x as _y,H as wy,L as vy,y as by,M as Sy,W as Ty,z as Ey}from"./index-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-DOTQn2XV.js","assets/index-B1m6hcte.js","assets/index-D2syF8VP.js","assets/index-BrUPorMz.css","assets/chunk-VL2OQCWN-D5zTMCrV.js","assets/index-DRz5BQNA.js","assets/__vite-browser-external-DFygW7-s.js","assets/path-C9FudP8b.js","assets/index-BgTUJ2nU.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
var hy=Object.defineProperty;var py=(e,t,n)=>t in e?hy(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var su=(e,t,n)=>py(e,typeof t!="symbol"?t+"":t,n);import{_ as G,c as ji,u as en,a as ht,d as Rc,n as St,s as Oe,e as Pn,o as te,f as fy,Z as R,h as Ht,i as au,l as Io,j as my,k as Yd,p as Xd,m as Fr,r as $c,q as Qd,t as T,v as gy,w as $a,B as yy,x as _y,H as wy,L as vy,y as by,M as Sy,W as Ty,z as Ey}from"./index-D2syF8VP.js";import{u as Cy,w as Lc,x as Ay,y as Be,z as ky,A as Oy,B as xy,C as Iy,D as Py,E as Ny,F as My,G as Ry,H as $y,I as Ly,f as An,J as jy,c as Re,K as Dy,L as eh,M as Uy,N as Fy,O as La,j as jc,Q as By,R as zy,S as Hy,U as Vy,W as Gy,X as Wy,Y as Jy,Z as Ky,a0 as Zy,a1 as qy,a2 as Yy,a3 as iu,a4 as Xy,a5 as Qy,a6 as e_,a7 as t_,s as n_,v as Ce,P as tn,p as ja,a as ws,b as th,e as nh,k as Dc,l as r_,i as s_,_ as a_,$ as i_,h as o_,m as c_,t as ou,d as rh,V as Uc,n as l_,o as br,g as u_,T as d_,q as h_,r as p_,a8 as f_}from"./chunk-VL2OQCWN-D5zTMCrV.js";import{o as Po}from"./__vite-browser-external-DFygW7-s.js";import{j as Da,d as cu,i as m_}from"./path-C9FudP8b.js";var Di,ra,Ui=0,Fi=0;function g_(e,t,n){var r=0,s=t||new Array(16);e=e||{};var a=e.node,i=e.clockseq;if(e._v6||(a||(a=Di),i==null&&(i=ra)),a==null||i==null){var o=e.random||(e.rng||Cy)();a==null&&(a=[o[0],o[1],o[2],o[3],o[4],o[5]],!Di&&!e._v6&&(a[0]|=1,Di=a)),i==null&&(i=(o[6]<<8|o[7])&16383,ra===void 0&&!e._v6&&(ra=i))}var c=e.msecs!==void 0?e.msecs:Date.now(),l=e.nsecs!==void 0?e.nsecs:Fi+1,u=c-Ui+(l-Fi)/1e4;if(u<0&&e.clockseq===void 0&&(i=i+1&16383),(u<0||c>Ui)&&e.nsecs===void 0&&(l=0),l>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");Ui=c,Fi=l,ra=i,c+=122192928e5;var d=((c&268435455)*1e4+l)%4294967296;s[r++]=d>>>24&255,s[r++]=d>>>16&255,s[r++]=d>>>8&255,s[r++]=d&255;var h=c/4294967296*1e4&268435455;s[r++]=h>>>8&255,s[r++]=h&255,s[r++]=h>>>24&15|16,s[r++]=h>>>16&255,s[r++]=i>>>8|128,s[r++]=i&255;for(var p=0;p<6;++p)s[r+p]=a[p];return t||Lc(s)}function y_(e){var t=typeof e=="string"?Ay(e):e,n=__(t);return typeof e=="string"?Lc(n):n}function __(e,t=!1){return Uint8Array.of((e[6]&15)<<4|e[7]>>4&15,(e[7]&15)<<4|(e[4]&240)>>4,(e[4]&15)<<4|(e[5]&240)>>4,(e[5]&15)<<4|(e[0]&240)>>4,(e[0]&15)<<4|(e[1]&240)>>4,(e[1]&15)<<4|(e[2]&240)>>4,96|e[2]&15,e[3],e[8],e[9],e[10],e[11],e[12],e[13],e[14],e[15])}function lu(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),n.push.apply(n,r)}return n}function uu(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?lu(Object(n),!0).forEach(function(r){w_(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):lu(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function w_(e,t,n){return(t=v_(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function v_(e){var t=b_(e,"string");return typeof t=="symbol"?t:t+""}function b_(e,t){if(typeof e!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function S_(e={},t,n=0){var r=g_(uu(uu({},e),{},{_v6:!0}),new Uint8Array(16));return r=y_(r),Lc(r)}const T_=(e,t)=>{ky.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:n=>xy(e,n)},flatten:{value:n=>Oy(e,n)},addIssue:{value:n=>e.issues.push(n)},addIssues:{value:n=>e.issues.push(...n)},isEmpty:{get(){return e.issues.length===0}}})},li=Be("ZodError",T_,{Parent:Error}),E_=Iy(li),C_=Ny(li),A_=Py(li),k_=My(li),ct=Be("ZodType",(e,t)=>(Ly.init(e,t),e.def=t,Object.defineProperty(e,"_def",{value:t}),e.check=(...n)=>e.clone({...t,checks:[...t.checks??[],...n.map(r=>typeof r=="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]}),e.clone=(n,r)=>An(e,n,r),e.brand=()=>e,e.register=((n,r)=>(n.add(e,r),e)),e.parse=(n,r)=>E_(e,n,r,{callee:e.parse}),e.safeParse=(n,r)=>A_(e,n,r),e.parseAsync=async(n,r)=>C_(e,n,r,{callee:e.parseAsync}),e.safeParseAsync=async(n,r)=>k_(e,n,r),e.spa=e.safeParseAsync,e.refine=(n,r)=>e.check(X_(n,r)),e.superRefine=n=>e.check(Q_(n)),e.overwrite=n=>e.check(jy(n)),e.optional=()=>du(e),e.nullable=()=>hu(e),e.nullish=()=>du(hu(e)),e.nonoptional=n=>V_(e,n),e.array=()=>I_(e),e.or=n=>N_([e,n]),e.and=n=>R_(e,n),e.transform=n=>pu(e,L_(n)),e.default=n=>F_(e,n),e.prefault=n=>z_(e,n),e.catch=n=>W_(e,n),e.pipe=n=>pu(e,n),e.readonly=()=>Z_(e),e.describe=n=>{const r=e.clone();return Re.add(r,{description:n}),r},Object.defineProperty(e,"description",{get(){return Re.get(e)?.description},configurable:!0}),e.meta=(...n)=>{if(n.length===0)return Re.get(e);const r=e.clone();return Re.add(r,n[0]),r},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e)),O_=Be("ZodAny",(e,t)=>{$y.init(e,t),ct.init(e,t)});function sa(){return Ry(O_)}const x_=Be("ZodArray",(e,t)=>{Yy.init(e,t),ct.init(e,t),e.element=t.element,e.min=(n,r)=>e.check(iu(n,r)),e.nonempty=n=>e.check(iu(1,n)),e.max=(n,r)=>e.check(Xy(n,r)),e.length=(n,r)=>e.check(Qy(n,r)),e.unwrap=()=>e.element});function I_(e,t){return Uy(x_,e,t)}const P_=Be("ZodUnion",(e,t)=>{Hy.init(e,t),ct.init(e,t),e.options=t.options});function N_(e,t){return new P_({type:"union",options:e,...eh(t)})}const M_=Be("ZodIntersection",(e,t)=>{Vy.init(e,t),ct.init(e,t)});function R_(e,t){return new M_({type:"intersection",left:e,right:t})}const $_=Be("ZodTransform",(e,t)=>{Wy.init(e,t),ct.init(e,t),e._zod.parse=(n,r)=>{n.addIssue=a=>{if(typeof a=="string")n.issues.push(La(a,n.value,t));else{const i=a;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=n.value),i.inst??(i.inst=e),i.continue??(i.continue=!0),n.issues.push(La(i))}};const s=t.transform(n.value,n);return s instanceof Promise?s.then(a=>(n.value=a,n)):(n.value=s,n)}});function L_(e){return new $_({type:"transform",transform:e})}const j_=Be("ZodOptional",(e,t)=>{jc.init(e,t),ct.init(e,t),e.unwrap=()=>e._zod.def.innerType});function du(e){return new j_({type:"optional",innerType:e})}const D_=Be("ZodNullable",(e,t)=>{By.init(e,t),ct.init(e,t),e.unwrap=()=>e._zod.def.innerType});function hu(e){return new D_({type:"nullable",innerType:e})}const U_=Be("ZodDefault",(e,t)=>{Jy.init(e,t),ct.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function F_(e,t){return new U_({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():t}})}const B_=Be("ZodPrefault",(e,t)=>{Ky.init(e,t),ct.init(e,t),e.unwrap=()=>e._zod.def.innerType});function z_(e,t){return new B_({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():t}})}const H_=Be("ZodNonOptional",(e,t)=>{zy.init(e,t),ct.init(e,t),e.unwrap=()=>e._zod.def.innerType});function V_(e,t){return new H_({type:"nonoptional",innerType:e,...eh(t)})}const G_=Be("ZodCatch",(e,t)=>{Zy.init(e,t),ct.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function W_(e,t){return new G_({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const J_=Be("ZodPipe",(e,t)=>{Gy.init(e,t),ct.init(e,t),e.in=t.in,e.out=t.out});function pu(e,t){return new J_({type:"pipe",in:e,out:t})}const K_=Be("ZodReadonly",(e,t)=>{qy.init(e,t),ct.init(e,t)});function Z_(e){return new K_({type:"readonly",innerType:e})}const q_=Be("ZodCustom",(e,t)=>{e_.init(e,t),ct.init(e,t)});function Y_(e){const t=new Fy({check:"custom"});return t._zod.check=e,t}function X_(e,t={}){return Dy(q_,e,t)}function Q_(e){const t=Y_(n=>(n.addIssue=r=>{if(typeof r=="string")n.issues.push(La(r,n.value,t._zod.def));else{const s=r;s.fatal&&(s.continue=!1),s.code??(s.code="custom"),s.input??(s.input=n.value),s.inst??(s.inst=t),s.continue??(s.continue=!t._zod.def.abort),n.issues.push(La(s))}},e(n.value,n)));return t}async function*sh(e){for await(const t of e)if(t.event==="on_chat_model_stream"&&t.data?.chunk?.text){const n=t.data.chunk.text;typeof n=="string"&&n.length>0&&(yield n)}}G(sh,"streamEventsToAISDK");function ah(e){return new ReadableStream({async start(t){try{for await(const n of e)t.enqueue(n);t.close()}catch(n){t.error(n)}}})}G(ah,"createReadableStreamFromGenerator");async function*ih(e){for await(const t of e)switch(t.event){case"on_chat_model_stream":if(t.data?.chunk?.text){const n=t.data.chunk.text;typeof n=="string"&&n.length>0&&(yield n)}break;case"on_tool_start":yield`
|
|
3
3
|
🔧 Using tool: ${t.name}
|
|
4
4
|
`;break;case"on_tool_end":yield`
|
|
5
5
|
✅ Tool completed: ${t.name}
|
|
@@ -567,4 +567,4 @@ ${f}`);const S=await s.stream(f);let b=null,v=0;for await(const E of S){if(v++,T
|
|
|
567
567
|
|
|
568
568
|
Make sure you gather ALL the required information during your task execution.
|
|
569
569
|
If any required information is missing, continue working to find it.
|
|
570
|
-
`}catch(r){return T.warn(`Could not extract schema details: ${r}`),t}}},G(Ur,"MCPAgent"),Ur),Me={},kP=Me.MCP_USE_LANGFUSE?.toLowerCase()==="false",Bs={handler:null,client:null,initPromise:null};async function Xl(e,t,n,r){try{const s=await $a(()=>import("./index-
|
|
570
|
+
`}catch(r){return T.warn(`Could not extract schema details: ${r}`),t}}},G(Ur,"MCPAgent"),Ur),Me={},kP=Me.MCP_USE_LANGFUSE?.toLowerCase()==="false",Bs={handler:null,client:null,initPromise:null};async function Xl(e,t,n,r){try{const s=await $a(()=>import("./index-DOTQn2XV.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8])).catch(()=>null);if(!s){T.debug("Langfuse package not installed - tracing disabled. Install with: npm install @langfuse/langchain");return}const{CallbackHandler:a}=s,u=class u extends a{agentId;metadata;metadataProvider;tagsProvider;verbose;constructor(h,p,f,y,S){super(h),this.agentId=p,this.metadata=f,this.metadataProvider=y,this.tagsProvider=S,this.verbose=h?.verbose??!1}async handleChainStart(h,p,f,y,S,b,v,w){T.debug("Langfuse: Chain start intercepted");const E=this.getCustomTags(),A=this.getMetadata(),I=[...S||[],...E],k={...b||{},...A};return this.verbose&&(T.debug(`Langfuse: Chain start with custom tags: ${JSON.stringify(I)}`),T.debug(`Langfuse: Chain start with metadata: ${JSON.stringify(k)}`)),super.handleChainStart(h,p,f,y,I,k,v,w)}getCustomTags(){const h=[],p=this.getEnvironmentTag();if(p&&h.push(`env:${p}`),this.agentId&&h.push(`agent_id:${this.agentId}`),this.tagsProvider){const f=this.tagsProvider();f&&f.length>0&&h.push(...f)}return h}getMetadata(){const h={},p=this.getEnvironmentTag();if(p&&(h.env=p),this.agentId&&(h.agent_id=this.agentId),this.metadata&&Object.assign(h,this.metadata),this.metadataProvider){const f=this.metadataProvider();f&&Object.assign(h,f)}return h}getEnvironmentTag(){const h=Me.MCP_USE_AGENT_ENV;if(!h)return"unknown";const p=h.toLowerCase();return p==="local"||p==="development"?"local":p==="production"||p==="prod"?"production":p==="staging"||p==="stage"?"staging":p==="hosted"||p==="cloud"?"hosted":p.replace(/[^a-z0-9_-]/g,"_")}async handleLLMStart(...h){return T.debug("Langfuse: LLM start intercepted"),this.verbose&&T.debug(`Langfuse: LLM start args: ${JSON.stringify(h)}`),super.handleLLMStart(...h)}async handleToolStart(...h){return T.debug("Langfuse: Tool start intercepted"),this.verbose&&T.debug(`Langfuse: Tool start args: ${JSON.stringify(h)}`),super.handleToolStart(...h)}async handleRetrieverStart(...h){return T.debug("Langfuse: Retriever start intercepted"),this.verbose&&T.debug(`Langfuse: Retriever start args: ${JSON.stringify(h)}`),super.handleRetrieverStart(...h)}async handleAgentAction(...h){return T.debug("Langfuse: Agent action intercepted"),this.verbose&&T.debug(`Langfuse: Agent action args: ${JSON.stringify(h)}`),super.handleAgentAction(...h)}async handleAgentEnd(...h){return T.debug("Langfuse: Agent end intercepted"),this.verbose&&T.debug(`Langfuse: Agent end args: ${JSON.stringify(h)}`),super.handleAgentEnd(...h)}};G(u,"LoggingCallbackHandler");let i=u;const o=t||(n?n():{}),c=r?r():[],l={publicKey:Me.LANGFUSE_PUBLIC_KEY,secretKey:Me.LANGFUSE_SECRET_KEY,baseUrl:Me.LANGFUSE_HOST||Me.LANGFUSE_BASEURL||"https://cloud.langfuse.com",flushAt:Number.parseInt(Me.LANGFUSE_FLUSH_AT||"15"),flushInterval:Number.parseInt(Me.LANGFUSE_FLUSH_INTERVAL||"10000"),release:Me.LANGFUSE_RELEASE,requestTimeout:Number.parseInt(Me.LANGFUSE_REQUEST_TIMEOUT||"10000"),enabled:Me.LANGFUSE_ENABLED!=="false",traceName:o.trace_name||Me.LANGFUSE_TRACE_NAME||"mcp-use-agent",sessionId:o.session_id||void 0,userId:o.user_id||void 0,tags:c.length>0?c:void 0,metadata:o||void 0};T.debug("Langfuse handler config:",JSON.stringify({traceName:l.traceName,sessionId:l.sessionId,userId:l.userId,tags:l.tags},null,2)),Bs.handler=new i(l,e,t,n,r),T.debug("Langfuse observability initialized successfully with logging enabled");try{const d=await $a(()=>import("./index-B1m6hcte.js"),__vite__mapDeps([1,2,3,4,5,6,7])).catch(()=>null);if(d){const{Langfuse:h}=d;Bs.client=new h({publicKey:Me.LANGFUSE_PUBLIC_KEY,secretKey:Me.LANGFUSE_SECRET_KEY,baseUrl:Me.LANGFUSE_HOST||"https://cloud.langfuse.com"}),T.debug("Langfuse client initialized")}}catch(d){T.debug(`Langfuse client initialization failed: ${d}`)}}catch(s){T.debug(`Langfuse initialization error: ${s}`)}}G(Xl,"initializeLangfuse");kP?T.debug("Langfuse tracing disabled via MCP_USE_LANGFUSE environment variable"):!Me.LANGFUSE_PUBLIC_KEY||!Me.LANGFUSE_SECRET_KEY?T.debug("Langfuse API keys not found - tracing disabled. Set LANGFUSE_PUBLIC_KEY and LANGFUSE_SECRET_KEY to enable"):Bs.initPromise=Xl();var OP=G(()=>Bs.handler,"langfuseHandler"),xP=G(()=>Bs.initPromise,"langfuseInitPromise");const BP=Object.freeze(Object.defineProperty({__proto__:null,AIMessage:j,BaseAdapter:ty,BaseConnector:yy,BaseMessage:Ke,BrowserOAuthClientProvider:_y,HttpConnector:wy,HumanMessage:ue,LangChainAdapter:Dn,Logger:vy,MCPAgent:AP,MCPClient:by,MCPSession:Sy,ObservabilityManager:Pc,RemoteAgent:iy,SystemMessage:fe,ToolMessage:X,WebSocketConnector:Ty,createReadableStreamFromGenerator:ah,logger:T,onMcpAuthorization:Ey,streamEventsToAISDK:sh,streamEventsToAISDKWithTools:ih},Symbol.toStringTag,{value:"Module"})),qd=Object.freeze(Object.defineProperty({__proto__:null,initializeLangfuse:Xl,langfuseHandler:OP,langfuseInitPromise:xP},Symbol.toStringTag,{value:"Module"}));export{BP as b,ot as m};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{b as St,g as Vo}from"./index-
|
|
1
|
+
import{b as St,g as Vo}from"./index-D2syF8VP.js";import{o as Ko}from"./__vite-browser-external-DFygW7-s.js";import{r as Jo}from"./index-DRz5BQNA.js";import{p as Zo}from"./path-C9FudP8b.js";function Qo(r,i){for(var v=0;v<i.length;v++){const E=i[v];if(typeof E!="string"&&!Array.isArray(E)){for(const d in E)if(d!=="default"&&!(d in r)){const l=Object.getOwnPropertyDescriptor(E,d);l&&Object.defineProperty(r,d,l.get?l:{enumerable:!0,get:()=>E[d]})}}}return Object.freeze(Object.defineProperty(r,Symbol.toStringTag,{value:"Module"}))}var Pt={},He={},Tt,rn;function ye(){if(rn)return Tt;rn=1;function r(m){"@babel/helpers - typeof";return r=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},r(m)}function i(m,s,c){return Object.defineProperty(m,"prototype",{writable:!1}),m}function v(m,s){if(!(m instanceof s))throw new TypeError("Cannot call a class as a function")}function E(m,s,c){return s=p(s),d(m,_()?Reflect.construct(s,c||[],p(m).constructor):s.apply(m,c))}function d(m,s){if(s&&(r(s)=="object"||typeof s=="function"))return s;if(s!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return l(m)}function l(m){if(m===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return m}function h(m,s){if(typeof s!="function"&&s!==null)throw new TypeError("Super expression must either be null or a function");m.prototype=Object.create(s&&s.prototype,{constructor:{value:m,writable:!0,configurable:!0}}),Object.defineProperty(m,"prototype",{writable:!1}),s&&x(m,s)}function t(m){var s=typeof Map=="function"?new Map:void 0;return t=function(a){if(a===null||!y(a))return a;if(typeof a!="function")throw new TypeError("Super expression must either be null or a function");if(s!==void 0){if(s.has(a))return s.get(a);s.set(a,o)}function o(){return u(a,arguments,p(this).constructor)}return o.prototype=Object.create(a.prototype,{constructor:{value:o,enumerable:!1,writable:!0,configurable:!0}}),x(o,a)},t(m)}function u(m,s,c){if(_())return Reflect.construct.apply(null,arguments);var a=[null];a.push.apply(a,s);var o=new(m.bind.apply(m,a));return c&&x(o,c.prototype),o}function _(){try{var m=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(_=function(){return!!m})()}function y(m){try{return Function.toString.call(m).indexOf("[native code]")!==-1}catch{return typeof m=="function"}}function x(m,s){return x=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(c,a){return c.__proto__=a,c},x(m,s)}function p(m){return p=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(s){return s.__proto__||Object.getPrototypeOf(s)},p(m)}var w=(function(m){function s(c){var a;return v(this,s),a=E(this,s,[`Format functions must be synchronous taking a two arguments: (info, opts)
|
|
2
2
|
Found: `.concat(c.toString().split(`
|
|
3
3
|
`)[0],`
|
|
4
4
|
`)]),Error.captureStackTrace(a,s),a}return h(s,m),i(s)})(t(Error));return Tt=function(m){if(m.length>2)throw new w(m);function s(){var a=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.options=a}s.prototype.transform=m;function c(a){return new s(a)}return c.Format=s,c},Tt}var Be={exports:{}},jt={exports:{}},Lt={exports:{}};function po(){return()=>{}}function yo(r){return JSON.stringify(r)}function mo(){}function go(){}const Xo={debuglog:po,inspect:yo,inherits:mo,format:go},ea=Object.freeze(Object.defineProperty({__proto__:null,debuglog:po,default:Xo,format:go,inherits:mo,inspect:yo},Symbol.toStringTag,{value:"Module"})),_e=St(ea);var Mt={exports:{}},nn;function ta(){return nn||(nn=1,(function(r){var i={};r.exports=i;var v={reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],inverse:[7,27],hidden:[8,28],strikethrough:[9,29],black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],gray:[90,39],grey:[90,39],brightRed:[91,39],brightGreen:[92,39],brightYellow:[93,39],brightBlue:[94,39],brightMagenta:[95,39],brightCyan:[96,39],brightWhite:[97,39],bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgGray:[100,49],bgGrey:[100,49],bgBrightRed:[101,49],bgBrightGreen:[102,49],bgBrightYellow:[103,49],bgBrightBlue:[104,49],bgBrightMagenta:[105,49],bgBrightCyan:[106,49],bgBrightWhite:[107,49],blackBG:[40,49],redBG:[41,49],greenBG:[42,49],yellowBG:[43,49],blueBG:[44,49],magentaBG:[45,49],cyanBG:[46,49],whiteBG:[47,49]};Object.keys(v).forEach(function(E){var d=v[E],l=i[E]=[];l.open="\x1B["+d[0]+"m",l.close="\x1B["+d[1]+"m"})})(Mt)),Mt.exports}const be=St(Ko);var At,on;function ra(){return on||(on=1,At=function(r,i){i=i||process.argv||[];var v=i.indexOf("--"),E=/^-{1,2}/.test(r)?"":"--",d=i.indexOf(E+r);return d!==-1&&(v===-1?!0:d<v)}),At}var Ct,an;function na(){if(an)return Ct;an=1;var r={},i=ra(),v=r,E=void 0;i("no-color")||i("no-colors")||i("color=false")?E=!1:(i("color")||i("colors")||i("color=true")||i("color=always"))&&(E=!0),"FORCE_COLOR"in v&&(E=v.FORCE_COLOR.length===0||parseInt(v.FORCE_COLOR,10)!==0);function d(t){return t===0?!1:{level:t,hasBasic:!0,has256:t>=2,has16m:t>=3}}function l(t){if(E===!1)return 0;if(i("color=16m")||i("color=full")||i("color=truecolor"))return 3;if(i("color=256"))return 2;if(t&&!t.isTTY&&E!==!0)return 0;var u=E?1:0;if("CI"in v)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI"].some(function(y){return y in v})||v.CI_NAME==="codeship"?1:u;if("TEAMCITY_VERSION"in v)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(v.TEAMCITY_VERSION)?1:0;if("TERM_PROGRAM"in v){var _=parseInt((v.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(v.TERM_PROGRAM){case"iTerm.app":return _>=3?3:2;case"Hyper":return 3;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(v.TERM)?2:/^screen|^xterm|^vt100|^rxvt|color|ansi|cygwin|linux/i.test(v.TERM)||"COLORTERM"in v?1:(v.TERM==="dumb",u)}function h(t){var u=l(t);return d(u)}return Ct={supportsColor:h,stdout:h(process.stdout),stderr:h(process.stderr)},Ct}var It={exports:{}},un;function ia(){return un||(un=1,(function(r){r.exports=function(v,E){var d="";v=v||"Run the trap, drop the bass",v=v.split("");var l={a:["@","Ą","Ⱥ","Ʌ","Δ","Λ","Д"],b:["ß","Ɓ","Ƀ","ɮ","β","฿"],c:["©","Ȼ","Ͼ"],d:["Ð","Ɗ","Ԁ","ԁ","Ԃ","ԃ"],e:["Ë","ĕ","Ǝ","ɘ","Σ","ξ","Ҽ","੬"],f:["Ӻ"],g:["ɢ"],h:["Ħ","ƕ","Ң","Һ","Ӈ","Ԋ"],i:["༏"],j:["Ĵ"],k:["ĸ","Ҡ","Ӄ","Ԟ"],l:["Ĺ"],m:["ʍ","Ӎ","ӎ","Ԡ","ԡ","൩"],n:["Ñ","ŋ","Ɲ","Ͷ","Π","Ҋ"],o:["Ø","õ","ø","Ǿ","ʘ","Ѻ","ם","","๏"],p:["Ƿ","Ҏ"],q:["্"],r:["®","Ʀ","Ȑ","Ɍ","ʀ","Я"],s:["§","Ϟ","ϟ","Ϩ"],t:["Ł","Ŧ","ͳ"],u:["Ʊ","Ս"],v:["ט"],w:["Ш","Ѡ","Ѽ","൰"],x:["Ҳ","Ӿ","Ӽ","ӽ"],y:["¥","Ұ","Ӌ"],z:["Ƶ","ɀ"]};return v.forEach(function(h){h=h.toLowerCase();var t=l[h]||[" "],u=Math.floor(Math.random()*t.length);typeof l[h]<"u"?d+=l[h][u]:d+=h}),d}})(It)),It.exports}var qt={exports:{}},sn;function oa(){return sn||(sn=1,(function(r){r.exports=function(v,E){v=v||" he is here ";var d={up:["̍","̎","̄","̅","̿","̑","̆","̐","͒","͗","͑","̇","̈","̊","͂","̓","̈","͊","͋","͌","̃","̂","̌","͐","̀","́","̋","̏","̒","̓","̔","̽","̉","ͣ","ͤ","ͥ","ͦ","ͧ","ͨ","ͩ","ͪ","ͫ","ͬ","ͭ","ͮ","ͯ","̾","͛","͆","̚"],down:["̖","̗","̘","̙","̜","̝","̞","̟","̠","̤","̥","̦","̩","̪","̫","̬","̭","̮","̯","̰","̱","̲","̳","̹","̺","̻","̼","ͅ","͇","͈","͉","͍","͎","͓","͔","͕","͖","͙","͚","̣"],mid:["̕","̛","̀","́","͘","̡","̢","̧","̨","̴","̵","̶","͜","͝","͞","͟","͠","͢","̸","̷","͡"," ҉"]},l=[].concat(d.up,d.down,d.mid);function h(_){var y=Math.floor(Math.random()*_);return y}function t(_){var y=!1;return l.filter(function(x){y=x===_}),y}function u(_,y){var x="",p,w;y=y||{},y.up=typeof y.up<"u"?y.up:!0,y.mid=typeof y.mid<"u"?y.mid:!0,y.down=typeof y.down<"u"?y.down:!0,y.size=typeof y.size<"u"?y.size:"maxi",_=_.split("");for(w in _)if(!t(w)){switch(x=x+_[w],p={up:0,down:0,mid:0},y.size){case"mini":p.up=h(8),p.mid=h(2),p.down=h(8);break;case"maxi":p.up=h(16)+3,p.mid=h(4)+1,p.down=h(64)+3;break;default:p.up=h(8)+1,p.mid=h(6)/2,p.down=h(8)+1;break}var m=["up","mid","down"];for(var s in m)for(var c=m[s],a=0;a<=p[c];a++)y[c]&&(x=x+d[c][h(d[c].length)])}return x}return u(v,E)}})(qt)),qt.exports}var Bt={exports:{}},fn;function aa(){return fn||(fn=1,(function(r){r.exports=function(i){return function(v,E,d){if(v===" ")return v;switch(E%3){case 0:return i.red(v);case 1:return i.white(v);case 2:return i.blue(v)}}}})(Bt)),Bt.exports}var Nt={exports:{}},ln;function ua(){return ln||(ln=1,(function(r){r.exports=function(i){return function(v,E,d){return E%2===0?v:i.inverse(v)}}})(Nt)),Nt.exports}var Ft={exports:{}},cn;function sa(){return cn||(cn=1,(function(r){r.exports=function(i){var v=["red","yellow","green","blue","magenta"];return function(E,d,l){return E===" "?E:i[v[d++%v.length]](E)}}})(Ft)),Ft.exports}var Dt={exports:{}},hn;function fa(){return hn||(hn=1,(function(r){r.exports=function(i){var v=["underline","inverse","grey","yellow","red","green","blue","white","cyan","magenta","brightYellow","brightRed","brightGreen","brightBlue","brightWhite","brightCyan","brightMagenta"];return function(E,d,l){return E===" "?E:i[v[Math.round(Math.random()*(v.length-2))]](E)}}})(Dt)),Dt.exports}var pn;function la(){return pn||(pn=1,(function(r){var i={};r.exports=i,i.themes={};var v=_e,E=i.styles=ta(),d=Object.defineProperties,l=new RegExp(/[\r\n]+/g);i.supportsColor=na().supportsColor,typeof i.enabled>"u"&&(i.enabled=i.supportsColor()!==!1),i.enable=function(){i.enabled=!0},i.disable=function(){i.enabled=!1},i.stripColors=i.strip=function(s){return(""+s).replace(/\x1B\[\d+m/g,"")},i.stylize=function(c,a){if(!i.enabled)return c+"";var o=E[a];return!o&&a in i?i[a](c):o.open+c+o.close};var h=/[|\\{}()[\]^$+*?.]/g,t=function(s){if(typeof s!="string")throw new TypeError("Expected a string");return s.replace(h,"\\$&")};function u(s){var c=function a(){return x.apply(a,arguments)};return c._styles=s,c.__proto__=y,c}var _=(function(){var s={};return E.grey=E.gray,Object.keys(E).forEach(function(c){E[c].closeRe=new RegExp(t(E[c].close),"g"),s[c]={get:function(){return u(this._styles.concat(c))}}}),s})(),y=d(function(){},_);function x(){var s=Array.prototype.slice.call(arguments),c=s.map(function(S){return S!=null&&S.constructor===String?S:v.inspect(S)}).join(" ");if(!i.enabled||!c)return c;for(var a=c.indexOf(`
|
package/dist/client/index.html
CHANGED
|
@@ -27,9 +27,9 @@
|
|
|
27
27
|
rel="stylesheet"
|
|
28
28
|
/>
|
|
29
29
|
<title>Inspector | mcp-use</title>
|
|
30
|
-
<script type="module" crossorigin src="/inspector/assets/index-
|
|
30
|
+
<script type="module" crossorigin src="/inspector/assets/index-D2syF8VP.js"></script>
|
|
31
31
|
<link rel="stylesheet" crossorigin href="/inspector/assets/index-BrUPorMz.css">
|
|
32
|
-
<script>window.__INSPECTOR_VERSION__ = "0.4.
|
|
32
|
+
<script>window.__INSPECTOR_VERSION__ = "0.4.13-canary.0";</script>
|
|
33
33
|
</head>
|
|
34
34
|
<body>
|
|
35
35
|
<script>
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mcp-use/inspector",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.4.
|
|
4
|
+
"version": "0.4.13-canary.0",
|
|
5
5
|
"description": "MCP Inspector - A tool for inspecting and debugging MCP servers",
|
|
6
6
|
"author": "",
|
|
7
7
|
"license": "MIT",
|
|
@@ -26,13 +26,18 @@
|
|
|
26
26
|
"dist"
|
|
27
27
|
],
|
|
28
28
|
"peerDependencies": {
|
|
29
|
+
"express": "^4.21.2"
|
|
30
|
+
},
|
|
31
|
+
"peerDependenciesMeta": {
|
|
32
|
+
"express": {
|
|
33
|
+
"optional": true
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
"dependencies": {
|
|
29
37
|
"@langchain/anthropic": "^1.0.0",
|
|
30
38
|
"@langchain/core": "^1.0.0",
|
|
31
39
|
"@langchain/google-genai": "^1.0.0",
|
|
32
40
|
"@langchain/openai": "^1.0.0",
|
|
33
|
-
"express": "^4.21.2"
|
|
34
|
-
},
|
|
35
|
-
"dependencies": {
|
|
36
41
|
"@ai-sdk/react": "^1.0.20",
|
|
37
42
|
"@hono/node-server": "^1.19.5",
|
|
38
43
|
"@mcp-ui/client": "^5.12.1",
|
|
@@ -68,7 +73,7 @@
|
|
|
68
73
|
"sonner": "^2.0.7",
|
|
69
74
|
"tailwind-merge": "^3.3.1",
|
|
70
75
|
"vite-express": "^0.21.1",
|
|
71
|
-
"mcp-use": "1.2.
|
|
76
|
+
"mcp-use": "1.2.4-canary.0"
|
|
72
77
|
},
|
|
73
78
|
"publishConfig": {
|
|
74
79
|
"access": "public"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{_ as e,A as d}from"./index-DI2GdDtn.js";var l={};e(l,{chunkArray:()=>u});const u=(r,n)=>r.reduce((a,o,s)=>{const c=Math.floor(s/n),t=a[c]||[];return a[c]=t.concat([o]),a},[]);var _={};e(_,{Embeddings:()=>h});var h=class{caller;constructor(r){this.caller=new d(r??{})}};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{Langfuse as T}from"./index-x_xzGcAx.js";import{B as I,a as v,A as g,b as y,H as M,C as S,S as w,F as D,T as b}from"./langfuse-C4HKZ3NL-DdY799py.js";import"./index-LZZ02vm2.js";import"./chunk-VL2OQCWN-B6188h-8.js";import"./index-DRz5BQNA.js";import"./__vite-browser-external-DFygW7-s.js";import"./path-C9FudP8b.js";const u="langsmith:hidden";class k extends I{constructor(t){super(),this.name="CallbackHandler",this.rootProvided=!1,this.updateRoot=!1,this.debugEnabled=!1,this.completionStartTimes={},t&&"root"in t?(this.langfuse=t.root.client,this.rootObservationId=t.root.observationId??void 0,this.traceId=t.root.traceId,this.rootProvided=!0,this.updateRoot=t.updateRoot??!1,this.metadata=t.metadata):(this.langfuse=new T({...t,persistence:"memory",sdkIntegration:t?.sdkIntegration??"LANGCHAIN"}),this.sessionId=t?.sessionId,this.userId=t?.userId,this.metadata=t?.metadata,this.tags=t?.tags),this.version=t?.version,this.promptToParentRunMap=new Map,this.traceUpdates=new Map}async flushAsync(){return this.langfuse.flushAsync()}async shutdownAsync(){return this.langfuse.shutdownAsync()}debug(t=!0){this.langfuse.debug(t),this.debugEnabled=t}_log(t){this.debugEnabled&&console.log(t)}async handleNewToken(t,e){return e&&!(e in this.completionStartTimes)&&(this._log(`LLM first streaming token: ${e}`),this.completionStartTimes[e]=new Date),Promise.resolve()}async handleLLMNewToken(t,e,s,i,n,a){return s&&!(s in this.completionStartTimes)&&(this._log(`LLM first streaming token: ${s}`),this.completionStartTimes[s]=new Date),Promise.resolve()}getTraceId(){return this.traceId}getTraceUrl(){return this.traceId?`${this.langfuse.baseUrl}/trace/${this.traceId}`:void 0}getLangchainRunId(){return this.topLevelObservationId}async handleRetrieverError(t,e,s){try{this._log(`Retriever error: ${t} with ID: ${e}`),this.langfuse._updateSpan({id:e,traceId:this.traceId,level:"ERROR",statusMessage:t.toString(),endTime:new Date,version:this.version}),this.updateTrace(e,s,t.toString())}catch(i){this._log(i)}}async handleChainStart(t,e,s,i,n,a,o,h){try{this._log(`Chain start with Id: ${s}`);const d=h??t.id.at(-1)?.toString()??"Langchain Run";this.registerLangfusePrompt(i,a);let r=e;typeof e=="object"&&"input"in e&&Array.isArray(e.input)&&e.input.every(l=>l instanceof v)?r=e.input.map(l=>this.extractChatMessageContent(l)):typeof e=="object"&&"content"in e&&typeof e.content=="string"&&(r=e.content),this.generateTrace(d,s,i,n,a,r),this.langfuse.span({id:s,traceId:this.traceId,parentObservationId:i??this.rootObservationId,name:d,metadata:this.joinTagsAndMetaData(n,a),input:r,version:this.version,level:n&&n.includes(u)?"DEBUG":void 0}),i||this.traceUpdates.set(s,{tags:n,userId:a&&"langfuseUserId"in a&&typeof a.langfuseUserId=="string"?a.langfuseUserId:void 0,sessionId:a&&"langfuseSessionId"in a&&typeof a.langfuseSessionId=="string"?a.langfuseSessionId:void 0})}catch(d){this._log(d)}}registerLangfusePrompt(t,e){e&&"langfusePrompt"in e&&t&&this.promptToParentRunMap.set(t,e.langfusePrompt)}deregisterLangfusePrompt(t){this.promptToParentRunMap.delete(t)}async handleAgentAction(t,e,s){try{this._log(`Agent action with ID: ${e}`),this.langfuse.span({id:e,parentObservationId:s,traceId:this.traceId,endTime:new Date,input:t,version:this.version})}catch(i){this._log(i)}}async handleAgentEnd(t,e,s){try{this._log(`Agent finish with ID: ${e}`),this.langfuse._updateSpan({id:e,traceId:this.traceId,endTime:new Date,output:t,version:this.version}),this.updateTrace(e,s,t)}catch(i){this._log(i)}}async handleChainError(t,e,s){try{this._log(`Chain error: ${t} with ID: ${e}`);const i=this.parseAzureRefusalError(t);this.langfuse._updateSpan({id:e,traceId:this.traceId,level:"ERROR",statusMessage:t.toString()+i,endTime:new Date,version:this.version}),this.updateTrace(e,s,t.toString()+i)}catch(i){this._log(i)}}generateTrace(t,e,s,i,n,a){this.traceId&&!s&&!this.rootProvided&&(this.traceId=void 0,this.topLevelObservationId=void 0);const o={name:t,metadata:this.joinTagsAndMetaData(i,n,this.metadata),userId:this.userId,version:this.version,sessionId:this.sessionId,input:a,tags:this.tags};this.traceId||(this.langfuse.trace({id:e,...o}),this.traceId=e),this.rootProvided&&this.updateRoot&&(this.rootObservationId?this.langfuse._updateSpan({id:this.rootObservationId,traceId:this.traceId,...o}):this.langfuse.trace({id:this.traceId,...o})),this.topLevelObservationId=s?this.topLevelObservationId:e}async handleGenerationStart(t,e,s,i,n,a,o,h){this._log(`Generation start with ID: ${s}`);const d=h??t.id.at(-1)?.toString()??"Langchain Generation";this.generateTrace(d,s,i,a,o,e);const r={},l=n?.invocation_params;for(const[f,c]of Object.entries({temperature:l?.temperature,max_tokens:l?.max_tokens,top_p:l?.top_p,frequency_penalty:l?.frequency_penalty,presence_penalty:l?.presence_penalty,request_timeout:l?.request_timeout}))c!=null&&(r[f]=c);let _;if(n){const f=n.invocation_params.model,c=o&&"ls_model_name"in o?o.ls_model_name:void 0;_=f??c}const m=this.promptToParentRunMap.get(i??"root");m&&i&&this.deregisterLangfusePrompt(i),this.langfuse.generation({id:s,traceId:this.traceId,name:h??t.id.at(-1)?.toString(),metadata:this.joinTagsAndMetaData(a,o),parentObservationId:i??this.rootObservationId,input:e,model:_,modelParameters:r,version:this.version,prompt:m,level:a&&a.includes(u)?"DEBUG":void 0})}async handleChatModelStart(t,e,s,i,n,a,o,h){try{this._log(`Chat model start with ID: ${s}`);const d=e.flatMap(r=>r.map(l=>this.extractChatMessageContent(l)));this.handleGenerationStart(t,d,s,i,n,a,o,h)}catch(d){this._log(d)}}async handleChainEnd(t,e,s){try{this._log(`Chain end with ID: ${e}`);let i=t;typeof t=="object"&&"output"in t&&typeof t.output=="string"&&(i=t.output),this.langfuse._updateSpan({id:e,traceId:this.traceId,output:i,endTime:new Date,version:this.version}),this.updateTrace(e,s,i),this.deregisterLangfusePrompt(e)}catch(i){this._log(i)}}async handleLLMStart(t,e,s,i,n,a,o,h){try{this._log(`LLM start with ID: ${s}`),this.handleGenerationStart(t,e,s,i,n,a,o,h)}catch(d){this._log(d)}}async handleToolStart(t,e,s,i,n,a,o){try{this._log(`Tool start with ID: ${s}`),this.langfuse.span({id:s,parentObservationId:i,traceId:this.traceId,name:o??t.id.at(-1)?.toString(),input:e,metadata:this.joinTagsAndMetaData(n,a),version:this.version,level:n&&n.includes(u)?"DEBUG":void 0})}catch(h){this._log(h)}}async handleRetrieverStart(t,e,s,i,n,a,o){try{this._log(`Retriever start with ID: ${s}`),this.langfuse.span({id:s,parentObservationId:i,traceId:this.traceId,name:o??t.id.at(-1)?.toString(),input:e,metadata:this.joinTagsAndMetaData(n,a),version:this.version,level:n&&n.includes(u)?"DEBUG":void 0})}catch(h){this._log(h)}}async handleRetrieverEnd(t,e,s){try{this._log(`Retriever end with ID: ${e}`),this.langfuse._updateSpan({id:e,traceId:this.traceId,output:t,endTime:new Date,version:this.version}),this.updateTrace(e,s,t)}catch(i){this._log(i)}}async handleToolEnd(t,e,s){try{this._log(`Tool end with ID: ${e}`),this.langfuse._updateSpan({id:e,traceId:this.traceId,output:t,endTime:new Date,version:this.version}),this.updateTrace(e,s,t)}catch(i){this._log(i)}}async handleToolError(t,e,s){try{this._log(`Tool error ${t} with ID: ${e}`),this.langfuse._updateSpan({id:e,traceId:this.traceId,level:"ERROR",statusMessage:t.toString(),endTime:new Date,version:this.version}),this.updateTrace(e,s,t.toString())}catch(i){this._log(i)}}async handleLLMEnd(t,e,s){try{this._log(`LLM end with ID: ${e}`);const i=t.generations[t.generations.length-1][t.generations[t.generations.length-1].length-1],n=this.extractUsageMetadata(i)??t.llmOutput?.tokenUsage,a=this.extractModelNameFromMetadata(i),o={input:n?.input_tokens??("promptTokens"in n?n?.promptTokens:void 0),output:n?.output_tokens??("completionTokens"in n?n?.completionTokens:void 0),total:n?.total_tokens??("totalTokens"in n?n?.totalTokens:void 0)};if(n&&"input_token_details"in n)for(const[d,r]of Object.entries(n.input_token_details??{}))o[`input_${d}`]=r,"input"in o&&typeof r=="number"&&(o.input=Math.max(0,o.input-r));if(n&&"output_token_details"in n)for(const[d,r]of Object.entries(n.output_token_details??{}))o[`output_${d}`]=r,"output"in o&&typeof r=="number"&&(o.output=Math.max(0,o.output-r));const h="message"in i&&i.message instanceof v?this.extractChatMessageContent(i.message):i.text;this.langfuse._updateGeneration({id:e,model:a,traceId:this.traceId,output:h,endTime:new Date,completionStartTime:e in this.completionStartTimes?this.completionStartTimes[e]:void 0,usage:o,usageDetails:o,version:this.version}),e in this.completionStartTimes&&delete this.completionStartTimes[e],this.updateTrace(e,s,h)}catch(i){this._log(i)}}extractUsageMetadata(t){try{return"message"in t&&(t.message instanceof g||t.message instanceof y)?t.message.usage_metadata:void 0}catch(e){this._log(`Error extracting usage metadata: ${e}`);return}}extractModelNameFromMetadata(t){try{return"message"in t&&(t.message instanceof g||t.message instanceof y)?t.message.response_metadata.model_name:void 0}catch{}}extractChatMessageContent(t){let e;return t instanceof M?e={content:t.content,role:"user"}:t instanceof S?e={content:t.content,role:t.role}:t instanceof g?e={content:t.content,role:"assistant"}:t instanceof w?e={content:t.content,role:"system"}:t instanceof D?e={content:t.content,additional_kwargs:t.additional_kwargs,role:t.name}:t instanceof b?e={content:t.content,additional_kwargs:t.additional_kwargs,role:t.name}:t.name?e={role:t.name,content:t.content}:e={content:t.content},t.additional_kwargs.function_call||t.additional_kwargs.tool_calls?{...e,additional_kwargs:t.additional_kwargs}:e}async handleLLMError(t,e,s){try{this._log(`LLM error ${t} with ID: ${e}`);const i=this.parseAzureRefusalError(t);this.langfuse._updateGeneration({id:e,traceId:this.traceId,level:"ERROR",statusMessage:t.toString()+i,endTime:new Date,version:this.version}),this.updateTrace(e,s,t.toString()+i)}catch(i){this._log(i)}}parseAzureRefusalError(t){let e="";if(typeof t=="object"&&"error"in t)try{e=`
|
|
2
|
-
|
|
3
|
-
Error details:
|
|
4
|
-
`+JSON.stringify(t.error,null,2)}catch{}return e}updateTrace(t,e,s){const i=this.traceUpdates.get(t);this.traceUpdates.delete(t),!e&&this.traceId&&this.traceId===t&&this.langfuse.trace({id:this.traceId,output:s,...i}),!e&&this.traceId&&this.rootProvided&&this.updateRoot&&(this.rootObservationId?this.langfuse._updateSpan({id:this.rootObservationId,traceId:this.traceId,output:s}):this.langfuse.trace({id:this.traceId,output:s,...i}))}joinTagsAndMetaData(t,e,s){const i={};return t&&t.length>0&&(i.tags=t),e&&Object.assign(i,e),s&&Object.assign(i,s),this.stripLangfuseKeysFromMetadata(i)}stripLangfuseKeysFromMetadata(t){if(!t)return;const e=["langfusePrompt","langfuseUserId","langfuseSessionId"];return Object.fromEntries(Object.entries(t).filter(([s,i])=>!e.includes(s)))}}const P=async p=>{const{runName:t,item:e,langfuseClient:s,options:i}=p,n={dataset_item_id:e.id,dataset_id:e.datasetId,dataset_run_name:t},a=s.trace();return await e.link(a,t,{description:i?.runDescription,metadata:i?.runMetadata}),{handler:new k({root:a,updateRoot:!0,metadata:n}),trace:a}};export{k as CallbackHandler,T as Langfuse,P as createDatasetItemHandler,k as default};
|