@mcp-use/inspector 0.9.2 → 0.10.0-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.
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-D-t8kYzy.js","assets/index-DZxMwvFi.js","assets/index-CHNXgq6o.css"])))=>i.map(i=>d[i]);
2
- import{_ as a,a as k}from"./index-DZxMwvFi.js";var y=null,L=null,O=null,J=!1,V=typeof process<"u"&&process.versions?.node;(async()=>{if(V)try{O=(await k(()=>import("./util-t-trnxQI.js").then(e=>e.u),[])).stripVTControlCharacters}catch{}try{y=(await k(()=>import("./index-JiKw9JSs.js"),[])).default}catch{}try{L=(await k(()=>import("./index-D-t8kYzy.js").then(e=>e.i),__vite__mapDeps([0,1,2]))).highlight}catch{}V&&(!y||!L)&&(J||(J=!0,console.warn(`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-C9QqRBsX.js","assets/index-BElrxX2D.js","assets/index-BlKiZ9Yy.css"])))=>i.map(i=>d[i]);
2
+ import{_ as a,a as k}from"./index-BElrxX2D.js";var y=null,L=null,O=null,J=!1,V=typeof process<"u"&&process.versions?.node;(async()=>{if(V)try{O=(await k(()=>import("./util-t-trnxQI.js").then(e=>e.u),[])).stripVTControlCharacters}catch{}try{y=(await k(()=>import("./index-JiKw9JSs.js"),[])).default}catch{}try{L=(await k(()=>import("./index-C9QqRBsX.js").then(e=>e.i),__vite__mapDeps([0,1,2]))).highlight}catch{}V&&(!y||!L)&&(J||(J=!0,console.warn(`
3
3
  ✨ For enhanced console output with colors and syntax highlighting, install:
4
4
 
5
5
  npm install chalk cli-highlight
@@ -1 +1 @@
1
- import{_ as c,A as d}from"./index-BxlzAdRz.js";var l={};c(l,{chunkArray:()=>u});const u=(r,s)=>r.reduce((a,n,o)=>{const e=Math.floor(o/s),t=a[e]||[];return a[e]=t.concat([n]),a},[]);var _={};c(_,{Embeddings:()=>h});var h=class{caller;constructor(r){this.caller=new d(r??{})}};export{h as E,l as c,_ as e};
1
+ import{_ as c,A as d}from"./index-8OwHMDVP.js";var l={};c(l,{chunkArray:()=>u});const u=(r,s)=>r.reduce((a,n,o)=>{const e=Math.floor(o/s),t=a[e]||[];return a[e]=t.concat([n]),a},[]);var _={};c(_,{Embeddings:()=>h});var h=class{caller;constructor(r){this.caller=new d(r??{})}};export{h as E,l as c,_ as e};
@@ -0,0 +1,8 @@
1
+ import{i as F,a as z,p as B,_ as k,C as w,G as j,c as K,b as U,R as L,d as P,e as V,m as H,f as S,g as Z,h as G,T as C,v as W,j as q,k as Y,l as O,o as Q,s as X,n as tt,q as et,r as I,t as N,u as E,w as at}from"./index-8OwHMDVP.js";import{O as M,B as st,a as nt,b as rt,i as ot,c as it,d as lt,e as ct}from"./index-BCqokRd8.js";import{p as ut}from"./index-BElrxX2D.js";function R(t,e){if(t.function===void 0)return;let a;if(e?.partial)try{a=B(t.function.arguments??"{}")}catch{return}else try{a=JSON.parse(t.function.arguments)}catch(r){throw new M([`Function "${t.function.name}" arguments:`,"",t.function.arguments,"","are not valid JSON.",`Error: ${r.message}`].join(`
2
+ `))}const s={name:t.function.name,args:a,type:"tool_call"};return e?.returnId&&(s.id=t.id),s}function ht(t){if(t.id===void 0)throw new Error('All OpenAI tool calls must have an "id" field.');return{id:t.id,type:"function",function:{name:t.name,arguments:JSON.stringify(t.args)}}}function mt(t,e){return{name:t.function?.name,args:t.function?.arguments,id:t.id,error:e,type:"invalid_tool_call"}}var x=class extends st{static lc_name(){return"JsonOutputToolsParser"}returnId=!1;lc_namespace=["langchain","output_parsers","openai_tools"];lc_serializable=!0;constructor(t){super(t),this.returnId=t?.returnId??this.returnId}_diff(){throw new Error("Not supported.")}async parse(){throw new Error("Not implemented.")}async parseResult(t){return await this.parsePartialResult(t,!1)}async parsePartialResult(t,e=!0){const a=t[0].message;let s;if(z(a)&&a.tool_calls?.length?s=a.tool_calls.map(n=>{const{id:h,...u}=n;return this.returnId?{id:h,...u}:u}):a.additional_kwargs.tool_calls!==void 0&&(s=JSON.parse(JSON.stringify(a.additional_kwargs.tool_calls)).map(h=>R(h,{returnId:this.returnId,partial:e}))),!s)return[];const r=[];for(const n of s)if(n!==void 0){const h={type:n.name,args:n.args,id:n.id};r.push(h)}return r}},dt=class extends x{static lc_name(){return"JsonOutputKeyToolsParser"}lc_namespace=["langchain","output_parsers","openai_tools"];lc_serializable=!0;returnId=!1;keyName;returnSingle=!1;zodSchema;constructor(t){super(t),this.keyName=t.keyName,this.returnSingle=t.returnSingle??this.returnSingle,this.zodSchema=t.zodSchema}async _validateResult(t){if(this.zodSchema===void 0)return t;const e=await F(this.zodSchema,t);if(e.success)return e.data;throw new M(`Failed to parse. Text: "${JSON.stringify(t,null,2)}". Error: ${JSON.stringify(e.error?.issues)}`,JSON.stringify(t,null,2))}async parsePartialResult(t){const a=(await super.parsePartialResult(t)).filter(r=>r.type===this.keyName);let s=a;if(a.length)return this.returnId||(s=a.map(r=>r.args)),this.returnSingle?s[0]:s}async parseResult(t){const a=(await super.parsePartialResult(t,!1)).filter(n=>n.type===this.keyName);let s=a;return a.length?(this.returnId||(s=a.map(n=>n.args)),this.returnSingle?this._validateResult(s[0]):await Promise.all(s.map(n=>this._validateResult(n)))):void 0}},gt={};k(gt,{JsonOutputKeyToolsParser:()=>dt,JsonOutputToolsParser:()=>x,convertLangChainToolCallToOpenAI:()=>ht,makeInvalidToolCall:()=>mt,parseToolCall:()=>R});var pt={};k(pt,{BaseLLM:()=>J,LLM:()=>ft});var J=class v extends nt{lc_namespace=["langchain","llms",this._llmType()];async invoke(e,a){const s=v._convertInputToPromptValue(e);return(await this.generatePrompt([s],a,a?.callbacks)).generations[0][0].text}async*_streamResponseChunks(e,a,s){throw new Error("Not implemented.")}_separateRunnableConfigFromCallOptionsCompat(e){const[a,s]=super._separateRunnableConfigFromCallOptions(e);return s.signal=a.signal,[a,s]}async*_streamIterator(e,a){if(this._streamResponseChunks===v.prototype._streamResponseChunks)yield this.invoke(e,a);else{const s=v._convertInputToPromptValue(e),[r,n]=this._separateRunnableConfigFromCallOptionsCompat(a),h=await w.configure(r.callbacks,this.callbacks,r.tags,this.tags,r.metadata,this.metadata,{verbose:this.verbose}),u={options:n,invocation_params:this?.invocationParams(n),batch_size:1},l=await h?.handleLLMStart(this.toJSON(),[s.toString()],r.runId,void 0,u,void 0,void 0,r.runName);let i=new j({text:""});try{for await(const o of this._streamResponseChunks(s.toString(),n,l?.[0]))i?i=i.concat(o):i=o,typeof o.text=="string"&&(yield o.text)}catch(o){throw await Promise.all((l??[]).map(c=>c?.handleLLMError(o))),o}await Promise.all((l??[]).map(o=>o?.handleLLMEnd({generations:[[i]]})))}}async generatePrompt(e,a,s){const r=e.map(n=>n.toString());return this.generate(r,a,s)}invocationParams(e){return{}}_flattenLLMResult(e){const a=[];for(let s=0;s<e.generations.length;s+=1){const r=e.generations[s];if(s===0)a.push({generations:[r],llmOutput:e.llmOutput});else{const n=e.llmOutput?{...e.llmOutput,tokenUsage:{}}:void 0;a.push({generations:[r],llmOutput:n})}}return a}async _generateUncached(e,a,s,r){let n;if(r!==void 0&&r.length===e.length)n=r;else{const i=await w.configure(s.callbacks,this.callbacks,s.tags,this.tags,s.metadata,this.metadata,{verbose:this.verbose}),o={options:a,invocation_params:this?.invocationParams(a),batch_size:e.length};n=await i?.handleLLMStart(this.toJSON(),e,s.runId,void 0,o,void 0,void 0,s?.runName)}const h=!!n?.[0].handlers.find(K);let u;if(h&&e.length===1&&this._streamResponseChunks!==v.prototype._streamResponseChunks)try{const i=await this._streamResponseChunks(e[0],a,n?.[0]);let o;for await(const c of i)o===void 0?o=c:o=U(o,c);if(o===void 0)throw new Error("Received empty response from chat model call.");u={generations:[[o]],llmOutput:{}},await n?.[0].handleLLMEnd(u)}catch(i){throw await n?.[0].handleLLMError(i),i}else{try{u=await this._generate(e,a,n?.[0])}catch(o){throw await Promise.all((n??[]).map(c=>c?.handleLLMError(o))),o}const i=this._flattenLLMResult(u);await Promise.all((n??[]).map((o,c)=>o?.handleLLMEnd(i[c])))}const l=n?.map(i=>i.runId)||void 0;return Object.defineProperty(u,L,{value:l?{runIds:l}:void 0,configurable:!0}),u}async _generateCached({prompts:e,cache:a,llmStringKey:s,parsedOptions:r,handledOptions:n,runId:h}){const u=await w.configure(n.callbacks,this.callbacks,n.tags,this.tags,n.metadata,this.metadata,{verbose:this.verbose}),l={options:r,invocation_params:this?.invocationParams(r),batch_size:e.length},i=await u?.handleLLMStart(this.toJSON(),e,h,void 0,l,void 0,void 0,n?.runName),o=[],p=(await Promise.allSettled(e.map(async(g,f)=>{const y=await a.lookup(g,s);return y==null&&o.push(f),y}))).map((g,f)=>({result:g,runManager:i?.[f]})).filter(({result:g})=>g.status==="fulfilled"&&g.value!=null||g.status==="rejected"),d=[];await Promise.all(p.map(async({result:g,runManager:f},y)=>{if(g.status==="fulfilled"){const _=g.value;return d[y]=_.map(b=>(b.generationInfo={...b.generationInfo,tokenUsage:{}},b)),_.length&&await f?.handleLLMNewToken(_[0].text),f?.handleLLMEnd({generations:[_]},void 0,void 0,void 0,{cached:!0})}else return await f?.handleLLMError(g.reason,void 0,void 0,void 0,{cached:!0}),Promise.reject(g.reason)}));const m={generations:d,missingPromptIndices:o,startedRunManagers:i};return Object.defineProperty(m,L,{value:i?{runIds:i?.map(g=>g.runId)}:void 0,configurable:!0}),m}async generate(e,a,s){if(!Array.isArray(e))throw new Error("Argument 'prompts' is expected to be a string[]");let r;Array.isArray(a)?r={stop:a}:r=a;const[n,h]=this._separateRunnableConfigFromCallOptionsCompat(r);if(n.callbacks=n.callbacks??s,!this.cache)return this._generateUncached(e,h,n);const{cache:u}=this,l=this._getSerializedCacheKeyParametersForCall(h),{generations:i,missingPromptIndices:o,startedRunManagers:c}=await this._generateCached({prompts:e,cache:u,llmStringKey:l,parsedOptions:h,handledOptions:n,runId:n.runId});let p={};if(o.length>0){const d=await this._generateUncached(o.map(m=>e[m]),h,n,c!==void 0?o.map(m=>c?.[m]):void 0);await Promise.all(d.generations.map(async(m,g)=>{const f=o[g];return i[f]=m,u.update(e[f],l,m)})),p=d.llmOutput??{}}return{generations:i,llmOutput:p}}_identifyingParams(){return{}}_modelType(){return"base_llm"}},ft=class extends J{async _generate(t,e,a){return{generations:await Promise.all(t.map((r,n)=>this._call(r,{...e,promptIndex:n},a).then(h=>[{text:h}])))}}},vt={};k(vt,{BaseToolkit:()=>yt,DynamicStructuredTool:()=>$,DynamicTool:()=>D,StructuredTool:()=>T,Tool:()=>A,ToolInputParsingException:()=>C,isLangChainTool:()=>ct,isRunnableToolLike:()=>lt,isStructuredTool:()=>it,isStructuredToolParams:()=>ot,tool:()=>_t});var T=class extends rt{returnDirect=!1;verboseParsingErrors=!1;get lc_namespace(){return["langchain","tools"]}responseFormat="content";defaultConfig;constructor(t){super(t??{}),this.verboseParsingErrors=t?.verboseParsingErrors??this.verboseParsingErrors,this.responseFormat=t?.responseFormat??this.responseFormat,this.defaultConfig=t?.defaultConfig??this.defaultConfig,this.metadata=t?.metadata??this.metadata}async invoke(t,e){let a,s=V(H(this.defaultConfig,e));return S(t)?(a=t.args,s={...s,toolCall:t}):a=t,this.call(a,s)}async call(t,e,a){const s=S(t)?t.args:t;let r;if(Z(this.schema))try{r=await G(this.schema,s)}catch(d){let m="Received tool input did not match expected schema";throw this.verboseParsingErrors&&(m=`${m}
3
+ Details: ${d.message}`),d instanceof Error&&d.constructor.name==="ZodError"&&(m=`${m}
4
+
5
+ ${ut(d)}`),new C(m,JSON.stringify(t))}else{const d=W(s,this.schema);if(!d.valid){let m="Received tool input did not match expected schema";throw this.verboseParsingErrors&&(m=`${m}
6
+ Details: ${d.errors.map(g=>`${g.keywordLocation}: ${g.error}`).join(`
7
+ `)}`),new C(m,JSON.stringify(t))}r=s}const n=P(e),u=await w.configure(n.callbacks,this.callbacks,n.tags||a,this.tags,n.metadata,this.metadata,{verbose:this.verbose})?.handleToolStart(this.toJSON(),typeof t=="string"?t:JSON.stringify(t),n.runId,void 0,void 0,void 0,n.runName);delete n.runId;let l;try{l=await this._call(r,u,n)}catch(d){throw await u?.handleToolError(d),d}let i,o;if(this.responseFormat==="content_and_artifact")if(Array.isArray(l)&&l.length===2)[i,o]=l;else throw new Error(`Tool response format is "content_and_artifact" but the output was not a two-tuple.
8
+ Result: ${JSON.stringify(l)}`);else i=l;let c;S(t)&&(c=t.id),!c&&q(n)&&(c=n.toolCall.id);const p=wt({content:i,artifact:o,toolCallId:c,name:this.name,metadata:this.metadata});return await u?.handleToolEnd(p),p}},A=class extends T{schema=Q({input:X().optional()}).transform(t=>t.input);constructor(t){super(t)}call(t,e){const a=typeof t=="string"||t==null?{input:t}:t;return super.call(a,e)}},D=class extends A{static lc_name(){return"DynamicTool"}name;description;func;constructor(t){super(t),this.name=t.name,this.description=t.description,this.func=t.func,this.returnDirect=t.returnDirect??this.returnDirect}async call(t,e){const a=P(e);return a.runName===void 0&&(a.runName=this.name),super.call(t,a)}async _call(t,e,a){return this.func(t,e,a)}},$=class extends T{static lc_name(){return"DynamicStructuredTool"}name;description;func;schema;constructor(t){super(t),this.name=t.name,this.description=t.description,this.func=t.func,this.returnDirect=t.returnDirect??this.returnDirect,this.schema=t.schema}async call(t,e,a){const s=P(e);return s.runName===void 0&&(s.runName=this.name),super.call(t,s,a)}_call(t,e,a){return this.func(t,e,a)}},yt=class{getTools(){return this.tools}};function _t(t,e){const a=tt(e.schema),s=et(e.schema);if(!e.schema||a||s)return new D({...e,description:e.description??e.schema?.description??`${e.name} tool`,func:async(h,u,l)=>new Promise((i,o)=>{const c=I(l,{callbacks:u?.getChild()});N.runWithConfig(E(c),async()=>{try{i(t(h,c))}catch(p){o(p)}})})});const r=e.schema,n=e.description??e.schema.description??`${e.name} tool`;return new $({...e,description:n,schema:r,func:async(h,u,l)=>new Promise((i,o)=>{let c;const p=()=>{l?.signal&&c&&l.signal.removeEventListener("abort",c)};l?.signal&&(c=()=>{p(),o(at(l.signal))},l.signal.addEventListener("abort",c));const d=I(l,{callbacks:u?.getChild()});N.runWithConfig(E(d),async()=>{try{const m=await t(h,d);if(l?.signal?.aborted){p();return}p(),i(m)}catch(m){p(),o(m)}})})})}function wt(t){const{content:e,artifact:a,toolCallId:s,metadata:r}=t;return s&&!Y(e)?typeof e=="string"||Array.isArray(e)&&e.every(n=>typeof n=="object")?new O({status:"success",content:e,artifact:a,tool_call_id:s,name:t.name,metadata:r}):new O({status:"success",content:bt(e),artifact:a,tool_call_id:s,name:t.name,metadata:r}):e}function bt(t){try{return JSON.stringify(t,null,2)??""}catch{return`${t}`}}export{D,dt as J,ft as L,T as S,A as T,_t as a,$ as b,ht as c,pt as l,mt as m,gt as o,R as p,vt as t};