@mcp-use/inspector 0.14.0-canary.0 → 0.14.0-canary.10
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/cli.js +10 -54
- package/dist/client/assets/browser-INsCMNyc.js +410 -0
- package/dist/client/assets/client-BLKbZjby.js +92 -0
- package/dist/client/assets/{display-A5IEINAP-D2Zkswj8.js → display-A5IEINAP-QwkwrW1D.js} +2 -2
- package/dist/client/assets/{embeddings-SLmbAVWP.js → embeddings-Dt8zD86W.js} +1 -1
- package/dist/client/assets/{index-CTUcNdQF.js → index-7zlfUUVg.js} +2 -2
- package/dist/client/assets/{index-DF_VhD4l.js → index-BIwswAy1.js} +2 -2
- package/dist/client/assets/{index-DDOzs1PG.js → index-BTYob6lV.js} +1 -1
- package/dist/client/assets/{index-pqhVKjyB.js → index-C9DK5WY4.js} +1 -1
- package/dist/client/assets/{index-ZoGs-72y.js → index-Cu6BBsRe.js} +1 -1
- package/dist/client/assets/{index-DvTyGyQK.js → index-HrVSgYfQ.js} +10 -10
- package/dist/client/assets/{index-DorqJhTq.js → index-Sz6vqd-H.js} +1 -1
- package/dist/client/assets/index-T9QtDRcf.css +1 -0
- package/dist/client/assets/index-c4KcZ9vr.js +1753 -0
- package/dist/client/assets/index-jYSn9Ie7.js +71 -0
- package/dist/client/assets/{llms-Og3hdOaD.js → llms-CJxJGKtJ.js} +1 -1
- package/dist/client/assets/util-QmrWvrtn.js +1 -0
- package/dist/client/index.html +3 -3
- package/dist/server/{chunk-JEKCWLHD.js → chunk-4OEEUHLZ.js} +2 -2
- package/dist/server/{chunk-YLX7JQDX.js → chunk-BC23UV5D.js} +3 -1
- package/dist/server/{chunk-XGILHZOF.js → chunk-E4Y73JSU.js} +5 -49
- package/dist/server/{chunk-JCLAFMDT.js → chunk-PUX4EJWH.js} +11 -0
- package/dist/server/{chunk-MCMZDGO6.js → chunk-Z5QIR3IS.js} +2 -2
- package/dist/server/cli.js +4 -4
- package/dist/server/index.js +5 -5
- package/dist/server/middleware.js +5 -5
- package/dist/server/server.d.ts +11 -0
- package/dist/server/server.d.ts.map +1 -1
- package/dist/server/server.js +16 -11
- package/dist/server/shared-routes.d.ts.map +1 -1
- package/dist/server/shared-routes.js +3 -3
- package/dist/server/shared-static.d.ts +5 -1
- package/dist/server/shared-static.d.ts.map +1 -1
- package/dist/server/shared-static.js +1 -1
- package/dist/server/shared-utils-browser.d.ts +9 -1
- package/dist/server/shared-utils-browser.d.ts.map +1 -1
- package/dist/server/shared-utils-browser.js +1 -1
- package/dist/server/utils.d.ts +14 -0
- package/dist/server/utils.d.ts.map +1 -1
- package/dist/server/utils.js +5 -3
- package/package.json +3 -3
- package/dist/client/assets/browser-2Ez00ml2.js +0 -501
- package/dist/client/assets/fs-u42MReIY.js +0 -1
- package/dist/client/assets/index-BFXh5irY.js +0 -1701
- package/dist/client/assets/index-DRz5BQNA.js +0 -1
- package/dist/client/assets/index-cMXsdFDY.css +0 -1
- package/dist/client/assets/index-jWGWxByD.js +0 -71
- package/dist/client/assets/path-BX1ROoWV.js +0 -1
- package/dist/client/assets/path-MNZaYwxc.js +0 -1
- package/dist/client/assets/posthog-node-CuYhrq1Q.js +0 -1
- package/dist/client/assets/transport-wrapper-browser-BI4dDu3b.js +0 -1
- package/dist/client/assets/util-t-trnxQI.js +0 -1
- package/dist/client/assets/winston-CYVymxcI.js +0 -37
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import{N as Ue,O as je,P as J,Q as ae,i as Ae,S as H,y as le,g as U,U as Nt,V as kt,W as xt,X as Pt,Y as Mt,Z as Rt,$ as Ft,a0 as Lt,a1 as Dt,a2 as Bt,h as Ut,a3 as jt,a4 as Vt,a5 as zt,b as Gt,a6 as Zt,a7 as $t,a8 as Ht,a9 as Wt,aa as Jt,r as Xt,ab as Yt,a as $e,ac as Kt,ad as He,ae as qt,af as Qt,ag as ea,ah as Se,ai as ta,aj as aa,ak as sa,q as We,al as re,e as oe,am as Je,an as Xe,x as ce,L as na,C as ye,ao as Ve,w as ra,R as ze,z as X,t as ia,ap as Ie,E as oa,M as Ye,aq as ca,ar as ua,as as la,B as Ke,at as ie,k as G,au as qe,av as ha,aw as Qe,ax as pa,l as ga,m as ma,ay as fa,az as da,aA as ba,aB as ya,aC as _a,aD as Ta,aE as va,aF as Ea,D as Ge,aG as wa,G as Ca,aH as Aa,aI as Sa,aJ as ve,o as et,s as tt,u as Ia}from"./index-C9DK5WY4.js";import{c as Oa}from"./index-c4KcZ9vr.js";function at(e,a,n,r,i){if(a!==e){typeof a.toJSON=="function"&&(a=a.toJSON());for(var c=Ue(a),h=Ue(e),l=!1,b=h.length-1;b>=0;b--){var f=h[b],T=e[f];if(je(a,f)&&!(a[f]===void 0&&T!==void 0&&Array.isArray(a)===!1)){var _=a[f];typeof T=="object"&&T!=null&&typeof _=="object"&&_!=null&&Array.isArray(T)===Array.isArray(_)?at(T,_,n,r+"/"+J(f),i):T!==_&&(i&&n.push({op:"test",path:r+"/"+J(f),value:ae(T)}),n.push({op:"replace",path:r+"/"+J(f),value:ae(_)}))}else Array.isArray(e)===Array.isArray(a)?(i&&n.push({op:"test",path:r+"/"+J(f),value:ae(T)}),n.push({op:"remove",path:r+"/"+J(f)}),l=!0):(i&&n.push({op:"test",path:r,value:e}),n.push({op:"replace",path:r,value:a}))}if(!(!l&&c.length==h.length))for(var b=0;b<c.length;b++){var f=c[b];!je(e,f)&&a[f]!==void 0&&n.push({op:"add",path:r+"/"+J(f),value:ae(a[f])})}}}function Oe(e,a,n=!1){var r=[];return at(e,a,r,"",n),r}function st(e){return e!==void 0&&Array.isArray(e.lc_namespace)}function nt(e){return e!==void 0&&H.isRunnable(e)&&"lc_name"in e.constructor&&typeof e.constructor.lc_name=="function"&&e.constructor.lc_name()==="RunnableToolLike"}function rt(e){return!!e&&typeof e=="object"&&"name"in e&&"schema"in e&&(Ae(e.schema)||e.schema!=null&&typeof e.schema=="object"&&"type"in e.schema&&typeof e.schema.type=="string"&&["null","boolean","object","array","number","string"].includes(e.schema.type))}function it(e){return rt(e)||nt(e)||st(e)}var Na={};U(Na,{convertToOpenAIFunction:()=>ot,convertToOpenAITool:()=>ka,isLangChainTool:()=>it,isRunnableToolLike:()=>nt,isStructuredTool:()=>st,isStructuredToolParams:()=>rt});function ot(e,a){const n=typeof a=="number"?void 0:a;return{name:e.name,description:e.description,parameters:le(e.schema),...n?.strict!==void 0?{strict:n.strict}:{}}}function ka(e,a){const n=typeof a=="number"?void 0:a;let r;return it(e)?r={type:"function",function:ot(e)}:r=e,n?.strict!==void 0&&(r.function.strict=n.strict),r}var xa={};U(xa,{extendInteropZodObject:()=>ea,getInteropZodDefaultGetter:()=>Qt,getInteropZodObjectShape:()=>qt,getSchemaDescription:()=>He,interopParse:()=>Kt,interopParseAsync:()=>$e,interopSafeParse:()=>Yt,interopSafeParseAsync:()=>Xt,interopZodObjectMakeFieldsOptional:()=>Jt,interopZodObjectPartial:()=>Wt,interopZodObjectPassthrough:()=>Ht,interopZodObjectStrict:()=>$t,interopZodTransformInputSchema:()=>Zt,isInteropZodError:()=>Gt,isInteropZodLiteral:()=>zt,isInteropZodObject:()=>Vt,isInteropZodSchema:()=>Ae,isShapelessZodSchema:()=>jt,isSimpleStringZodSchema:()=>Ut,isZodArrayV4:()=>Bt,isZodLiteralV3:()=>Dt,isZodLiteralV4:()=>Lt,isZodNullableV4:()=>Ft,isZodObjectV3:()=>Rt,isZodObjectV4:()=>Mt,isZodOptionalV4:()=>Pt,isZodSchema:()=>xt,isZodSchemaV3:()=>kt,isZodSchemaV4:()=>Nt});var Pa={};U(Pa,{BasePromptValue:()=>he,ChatPromptValue:()=>ut,ImagePromptValue:()=>Ma,StringPromptValue:()=>ct});var he=class extends aa{},ct=class extends he{static lc_name(){return"StringPromptValue"}lc_namespace=["langchain_core","prompt_values"];lc_serializable=!0;value;constructor(e){super({value:e}),this.value=e}toString(){return this.value}toChatMessages(){return[new Se(this.value)]}},ut=class extends he{lc_namespace=["langchain_core","prompt_values"];lc_serializable=!0;static lc_name(){return"ChatPromptValue"}messages;constructor(e){Array.isArray(e)&&(e={messages:e}),super(e),this.messages=e.messages}toString(){return ta(this.messages)}toChatMessages(){return this.messages}},Ma=class extends he{lc_namespace=["langchain_core","prompt_values"];lc_serializable=!0;static lc_name(){return"ImagePromptValue"}imageUrl;value;constructor(e){"imageUrl"in e||(e={imageUrl:e}),super(e),this.imageUrl=e.imageUrl}toString(){return this.imageUrl.url}toChatMessages(){return[new Se({content:[{type:"image_url",image_url:{detail:this.imageUrl.detail,url:this.imageUrl.url}}]})]}},y="0123456789abcdef".split(""),Ra=[-2147483648,8388608,32768,128],D=[24,16,8,0],se=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],M=[];function B(e,a){a?(M[0]=M[16]=M[1]=M[2]=M[3]=M[4]=M[5]=M[6]=M[7]=M[8]=M[9]=M[10]=M[11]=M[12]=M[13]=M[14]=M[15]=0,this.blocks=M):this.blocks=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],e?(this.h0=3238371032,this.h1=914150663,this.h2=812702999,this.h3=4144912697,this.h4=4290775857,this.h5=1750603025,this.h6=1694076839,this.h7=3204075428):(this.h0=1779033703,this.h1=3144134277,this.h2=1013904242,this.h3=2773480762,this.h4=1359893119,this.h5=2600822924,this.h6=528734635,this.h7=1541459225),this.block=this.start=this.bytes=this.hBytes=0,this.finalized=this.hashed=!1,this.first=!0,this.is224=e}B.prototype.update=function(e){if(!this.finalized){var a,n=typeof e;if(n!=="string"){if(n==="object"){if(e===null)throw new Error(ERROR);if(ARRAY_BUFFER&&e.constructor===ArrayBuffer)e=new Uint8Array(e);else if(!Array.isArray(e)&&(!ARRAY_BUFFER||!ArrayBuffer.isView(e)))throw new Error(ERROR)}else throw new Error(ERROR);a=!0}for(var r,i=0,c,h=e.length,l=this.blocks;i<h;){if(this.hashed&&(this.hashed=!1,l[0]=this.block,this.block=l[16]=l[1]=l[2]=l[3]=l[4]=l[5]=l[6]=l[7]=l[8]=l[9]=l[10]=l[11]=l[12]=l[13]=l[14]=l[15]=0),a)for(c=this.start;i<h&&c<64;++i)l[c>>>2]|=e[i]<<D[c++&3];else for(c=this.start;i<h&&c<64;++i)r=e.charCodeAt(i),r<128?l[c>>>2]|=r<<D[c++&3]:r<2048?(l[c>>>2]|=(192|r>>>6)<<D[c++&3],l[c>>>2]|=(128|r&63)<<D[c++&3]):r<55296||r>=57344?(l[c>>>2]|=(224|r>>>12)<<D[c++&3],l[c>>>2]|=(128|r>>>6&63)<<D[c++&3],l[c>>>2]|=(128|r&63)<<D[c++&3]):(r=65536+((r&1023)<<10|e.charCodeAt(++i)&1023),l[c>>>2]|=(240|r>>>18)<<D[c++&3],l[c>>>2]|=(128|r>>>12&63)<<D[c++&3],l[c>>>2]|=(128|r>>>6&63)<<D[c++&3],l[c>>>2]|=(128|r&63)<<D[c++&3]);this.lastByteIndex=c,this.bytes+=c-this.start,c>=64?(this.block=l[16],this.start=c-64,this.hash(),this.hashed=!0):this.start=c}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296<<0,this.bytes=this.bytes%4294967296),this}};B.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var e=this.blocks,a=this.lastByteIndex;e[16]=this.block,e[a>>>2]|=Ra[a&3],this.block=e[16],a>=56&&(this.hashed||this.hash(),e[0]=this.block,e[16]=e[1]=e[2]=e[3]=e[4]=e[5]=e[6]=e[7]=e[8]=e[9]=e[10]=e[11]=e[12]=e[13]=e[14]=e[15]=0),e[14]=this.hBytes<<3|this.bytes>>>29,e[15]=this.bytes<<3,this.hash()}};B.prototype.hash=function(){var e=this.h0,a=this.h1,n=this.h2,r=this.h3,i=this.h4,c=this.h5,h=this.h6,l=this.h7,b=this.blocks,f,T,_,E,g,d,m,v,w,A,C;for(f=16;f<64;++f)g=b[f-15],T=(g>>>7|g<<25)^(g>>>18|g<<14)^g>>>3,g=b[f-2],_=(g>>>17|g<<15)^(g>>>19|g<<13)^g>>>10,b[f]=b[f-16]+T+b[f-7]+_<<0;for(C=a&n,f=0;f<64;f+=4)this.first?(this.is224?(v=300032,g=b[0]-1413257819,l=g-150054599<<0,r=g+24177077<<0):(v=704751109,g=b[0]-210244248,l=g-1521486534<<0,r=g+143694565<<0),this.first=!1):(T=(e>>>2|e<<30)^(e>>>13|e<<19)^(e>>>22|e<<10),_=(i>>>6|i<<26)^(i>>>11|i<<21)^(i>>>25|i<<7),v=e&a,E=v^e&n^C,m=i&c^~i&h,g=l+_+m+se[f]+b[f],d=T+E,l=r+g<<0,r=g+d<<0),T=(r>>>2|r<<30)^(r>>>13|r<<19)^(r>>>22|r<<10),_=(l>>>6|l<<26)^(l>>>11|l<<21)^(l>>>25|l<<7),w=r&e,E=w^r&a^v,m=h&l^~h&i,g=c+_+m+se[f+1]+b[f+1],d=T+E,h=n+g<<0,n=g+d<<0,T=(n>>>2|n<<30)^(n>>>13|n<<19)^(n>>>22|n<<10),_=(h>>>6|h<<26)^(h>>>11|h<<21)^(h>>>25|h<<7),A=n&r,E=A^n&e^w,m=c&h^~c&l,g=i+_+m+se[f+2]+b[f+2],d=T+E,c=a+g<<0,a=g+d<<0,T=(a>>>2|a<<30)^(a>>>13|a<<19)^(a>>>22|a<<10),_=(c>>>6|c<<26)^(c>>>11|c<<21)^(c>>>25|c<<7),C=a&n,E=C^a&r^A,m=c&h^~c&l,g=i+_+m+se[f+3]+b[f+3],d=T+E,i=e+g<<0,e=g+d<<0,this.chromeBugWorkAround=!0;this.h0=this.h0+e<<0,this.h1=this.h1+a<<0,this.h2=this.h2+n<<0,this.h3=this.h3+r<<0,this.h4=this.h4+i<<0,this.h5=this.h5+c<<0,this.h6=this.h6+h<<0,this.h7=this.h7+l<<0};B.prototype.hex=function(){this.finalize();var e=this.h0,a=this.h1,n=this.h2,r=this.h3,i=this.h4,c=this.h5,h=this.h6,l=this.h7,b=y[e>>>28&15]+y[e>>>24&15]+y[e>>>20&15]+y[e>>>16&15]+y[e>>>12&15]+y[e>>>8&15]+y[e>>>4&15]+y[e&15]+y[a>>>28&15]+y[a>>>24&15]+y[a>>>20&15]+y[a>>>16&15]+y[a>>>12&15]+y[a>>>8&15]+y[a>>>4&15]+y[a&15]+y[n>>>28&15]+y[n>>>24&15]+y[n>>>20&15]+y[n>>>16&15]+y[n>>>12&15]+y[n>>>8&15]+y[n>>>4&15]+y[n&15]+y[r>>>28&15]+y[r>>>24&15]+y[r>>>20&15]+y[r>>>16&15]+y[r>>>12&15]+y[r>>>8&15]+y[r>>>4&15]+y[r&15]+y[i>>>28&15]+y[i>>>24&15]+y[i>>>20&15]+y[i>>>16&15]+y[i>>>12&15]+y[i>>>8&15]+y[i>>>4&15]+y[i&15]+y[c>>>28&15]+y[c>>>24&15]+y[c>>>20&15]+y[c>>>16&15]+y[c>>>12&15]+y[c>>>8&15]+y[c>>>4&15]+y[c&15]+y[h>>>28&15]+y[h>>>24&15]+y[h>>>20&15]+y[h>>>16&15]+y[h>>>12&15]+y[h>>>8&15]+y[h>>>4&15]+y[h&15];return this.is224||(b+=y[l>>>28&15]+y[l>>>24&15]+y[l>>>20&15]+y[l>>>16&15]+y[l>>>12&15]+y[l>>>8&15]+y[l>>>4&15]+y[l&15]),b};B.prototype.toString=B.prototype.hex;B.prototype.digest=function(){this.finalize();var e=this.h0,a=this.h1,n=this.h2,r=this.h3,i=this.h4,c=this.h5,h=this.h6,l=this.h7,b=[e>>>24&255,e>>>16&255,e>>>8&255,e&255,a>>>24&255,a>>>16&255,a>>>8&255,a&255,n>>>24&255,n>>>16&255,n>>>8&255,n&255,r>>>24&255,r>>>16&255,r>>>8&255,r&255,i>>>24&255,i>>>16&255,i>>>8&255,i&255,c>>>24&255,c>>>16&255,c>>>8&255,c&255,h>>>24&255,h>>>16&255,h>>>8&255,h&255];return this.is224||b.push(l>>>24&255,l>>>16&255,l>>>8&255,l&255),b};B.prototype.array=B.prototype.digest;B.prototype.arrayBuffer=function(){this.finalize();var e=new ArrayBuffer(this.is224?28:32),a=new DataView(e);return a.setUint32(0,this.h0),a.setUint32(4,this.h1),a.setUint32(8,this.h2),a.setUint32(12,this.h3),a.setUint32(16,this.h4),a.setUint32(20,this.h5),a.setUint32(24,this.h6),this.is224||a.setUint32(28,this.h7),e};const lt=(...e)=>new B(!1,!0).update(e.join("")).hex();var Fa={};U(Fa,{sha256:()=>lt});var La={};U(La,{BaseCache:()=>pt,InMemoryCache:()=>gt,defaultHashKeyEncoder:()=>ht,deserializeStoredGeneration:()=>Da,serializeGeneration:()=>Ba});const ht=(...e)=>lt(e.join("_"));function Da(e){return e.message!==void 0?{text:e.text,message:sa(e.message)}:{text:e.text}}function Ba(e){const a={text:e.text};return e.message!==void 0&&(a.message=e.message.toDict()),a}var pt=class{keyEncoder=ht;makeDefaultKeyEncoder(e){this.keyEncoder=e}};const Ua=new Map;var gt=class mt extends pt{cache;constructor(a){super(),this.cache=a??new Map}lookup(a,n){return Promise.resolve(this.cache.get(this.keyEncoder(a,n))??null)}async update(a,n,r){this.cache.set(this.keyEncoder(a,n),r)}static global(){return new mt(Ua)}},q={},Ze;function ja(){if(Ze)return q;Ze=1,q.byteLength=l,q.toByteArray=f,q.fromByteArray=E;for(var e=[],a=[],n=typeof Uint8Array<"u"?Uint8Array:Array,r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",i=0,c=r.length;i<c;++i)e[i]=r[i],a[r.charCodeAt(i)]=i;a[45]=62,a[95]=63;function h(g){var d=g.length;if(d%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var m=g.indexOf("=");m===-1&&(m=d);var v=m===d?0:4-m%4;return[m,v]}function l(g){var d=h(g),m=d[0],v=d[1];return(m+v)*3/4-v}function b(g,d,m){return(d+m)*3/4-m}function f(g){var d,m=h(g),v=m[0],w=m[1],A=new n(b(g,v,w)),C=0,P=w>0?v-4:v,O;for(O=0;O<P;O+=4)d=a[g.charCodeAt(O)]<<18|a[g.charCodeAt(O+1)]<<12|a[g.charCodeAt(O+2)]<<6|a[g.charCodeAt(O+3)],A[C++]=d>>16&255,A[C++]=d>>8&255,A[C++]=d&255;return w===2&&(d=a[g.charCodeAt(O)]<<2|a[g.charCodeAt(O+1)]>>4,A[C++]=d&255),w===1&&(d=a[g.charCodeAt(O)]<<10|a[g.charCodeAt(O+1)]<<4|a[g.charCodeAt(O+2)]>>2,A[C++]=d>>8&255,A[C++]=d&255),A}function T(g){return e[g>>18&63]+e[g>>12&63]+e[g>>6&63]+e[g&63]}function _(g,d,m){for(var v,w=[],A=d;A<m;A+=3)v=(g[A]<<16&16711680)+(g[A+1]<<8&65280)+(g[A+2]&255),w.push(T(v));return w.join("")}function E(g){for(var d,m=g.length,v=m%3,w=[],A=16383,C=0,P=m-v;C<P;C+=A)w.push(_(g,C,C+A>P?P:C+A));return v===1?(d=g[m-1],w.push(e[d>>2]+e[d<<4&63]+"==")):v===2&&(d=(g[m-2]<<8)+g[m-1],w.push(e[d>>10]+e[d>>4&63]+e[d<<2&63]+"=")),w.join("")}return q}var Va=ja();const za=Oa(Va);var Ga=Object.defineProperty,Za=(e,a,n)=>a in e?Ga(e,a,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[a]=n,$a=(e,a,n)=>(Za(e,a+"",n),n);function Ha(e,a){let n=Array.from({length:e.length},(r,i)=>({start:i,end:i+1}));for(;n.length>1;){let r=null;for(let i=0;i<n.length-1;i++){const c=e.slice(n[i].start,n[i+1].end),h=a.get(c.join(","));h!=null&&(r==null||h<r[0])&&(r=[h,i])}if(r!=null){const i=r[1];n[i]={start:n[i].start,end:n[i+1].end},n.splice(i+1,1)}else break}return n}function Wa(e,a){return e.length===1?[a.get(e.join(","))]:Ha(e,a).map(n=>a.get(e.slice(n.start,n.end).join(","))).filter(n=>n!=null)}function Ja(e){return e.replace(/[\\^$*+?.()|[\]{}]/g,"\\$&")}var Ee=class{specialTokens;inverseSpecialTokens;patStr;textEncoder=new TextEncoder;textDecoder=new TextDecoder("utf-8");rankMap=new Map;textMap=new Map;constructor(e,a){this.patStr=e.pat_str;const n=e.bpe_ranks.split(`
|
|
2
|
+
`).filter(Boolean).reduce((r,i)=>{const[c,h,...l]=i.split(" "),b=Number.parseInt(h,10);return l.forEach((f,T)=>r[f]=b+T),r},{});for(const[r,i]of Object.entries(n)){const c=za.toByteArray(r);this.rankMap.set(c.join(","),i),this.textMap.set(i,c)}this.specialTokens={...e.special_tokens,...a},this.inverseSpecialTokens=Object.entries(this.specialTokens).reduce((r,[i,c])=>(r[c]=this.textEncoder.encode(i),r),{})}encode(e,a=[],n="all"){const r=new RegExp(this.patStr,"ug"),i=Ee.specialTokenRegex(Object.keys(this.specialTokens)),c=[],h=new Set(a==="all"?Object.keys(this.specialTokens):a),l=new Set(n==="all"?Object.keys(this.specialTokens).filter(f=>!h.has(f)):n);if(l.size>0){const f=Ee.specialTokenRegex([...l]),T=e.match(f);if(T!=null)throw new Error(`The text contains a special token that is not allowed: ${T[0]}`)}let b=0;for(;;){let f=null,T=b;for(;i.lastIndex=T,f=i.exec(e),!(f==null||h.has(f[0]));)T=f.index+1;const _=f?.index??e.length;for(const g of e.substring(b,_).matchAll(r)){const d=this.textEncoder.encode(g[0]),m=this.rankMap.get(d.join(","));if(m!=null){c.push(m);continue}c.push(...Wa(d,this.rankMap))}if(f==null)break;let E=this.specialTokens[f[0]];c.push(E),b=f.index+f[0].length}return c}decode(e){const a=[];let n=0;for(let c=0;c<e.length;++c){const h=e[c],l=this.textMap.get(h)??this.inverseSpecialTokens[h];l!=null&&(a.push(l),n+=l.length)}const r=new Uint8Array(n);let i=0;for(const c of a)r.set(c,i),i+=c.length;return this.textDecoder.decode(r)}},ft=Ee;$a(ft,"specialTokenRegex",e=>new RegExp(e.map(a=>Ja(a)).join("|"),"g"));function Xa(e){switch(e){case"gpt2":return"gpt2";case"code-cushman-001":case"code-cushman-002":case"code-davinci-001":case"code-davinci-002":case"cushman-codex":case"davinci-codex":case"davinci-002":case"text-davinci-002":case"text-davinci-003":return"p50k_base";case"code-davinci-edit-001":case"text-davinci-edit-001":return"p50k_edit";case"ada":case"babbage":case"babbage-002":case"code-search-ada-code-001":case"code-search-babbage-code-001":case"curie":case"davinci":case"text-ada-001":case"text-babbage-001":case"text-curie-001":case"text-davinci-001":case"text-search-ada-doc-001":case"text-search-babbage-doc-001":case"text-search-curie-doc-001":case"text-search-davinci-doc-001":case"text-similarity-ada-001":case"text-similarity-babbage-001":case"text-similarity-curie-001":case"text-similarity-davinci-001":return"r50k_base";case"gpt-3.5-turbo-instruct-0914":case"gpt-3.5-turbo-instruct":case"gpt-3.5-turbo-16k-0613":case"gpt-3.5-turbo-16k":case"gpt-3.5-turbo-0613":case"gpt-3.5-turbo-0301":case"gpt-3.5-turbo":case"gpt-4-32k-0613":case"gpt-4-32k-0314":case"gpt-4-32k":case"gpt-4-0613":case"gpt-4-0314":case"gpt-4":case"gpt-3.5-turbo-1106":case"gpt-35-turbo":case"gpt-4-1106-preview":case"gpt-4-vision-preview":case"gpt-3.5-turbo-0125":case"gpt-4-turbo":case"gpt-4-turbo-2024-04-09":case"gpt-4-turbo-preview":case"gpt-4-0125-preview":case"text-embedding-ada-002":case"text-embedding-3-small":case"text-embedding-3-large":return"cl100k_base";case"gpt-4o":case"gpt-4o-2024-05-13":case"gpt-4o-2024-08-06":case"gpt-4o-2024-11-20":case"gpt-4o-mini-2024-07-18":case"gpt-4o-mini":case"gpt-4o-search-preview":case"gpt-4o-search-preview-2025-03-11":case"gpt-4o-mini-search-preview":case"gpt-4o-mini-search-preview-2025-03-11":case"gpt-4o-audio-preview":case"gpt-4o-audio-preview-2024-12-17":case"gpt-4o-audio-preview-2024-10-01":case"gpt-4o-mini-audio-preview":case"gpt-4o-mini-audio-preview-2024-12-17":case"o1":case"o1-2024-12-17":case"o1-mini":case"o1-mini-2024-09-12":case"o1-preview":case"o1-preview-2024-09-12":case"o1-pro":case"o1-pro-2025-03-19":case"o3":case"o3-2025-04-16":case"o3-mini":case"o3-mini-2025-01-31":case"o4-mini":case"o4-mini-2025-04-16":case"chatgpt-4o-latest":case"gpt-4o-realtime":case"gpt-4o-realtime-preview-2024-10-01":case"gpt-4o-realtime-preview-2024-12-17":case"gpt-4o-mini-realtime-preview":case"gpt-4o-mini-realtime-preview-2024-12-17":case"gpt-4.1":case"gpt-4.1-2025-04-14":case"gpt-4.1-mini":case"gpt-4.1-mini-2025-04-14":case"gpt-4.1-nano":case"gpt-4.1-nano-2025-04-14":case"gpt-4.5-preview":case"gpt-4.5-preview-2025-02-27":case"gpt-5":case"gpt-5-2025-08-07":case"gpt-5-nano":case"gpt-5-nano-2025-08-07":case"gpt-5-mini":case"gpt-5-mini-2025-08-07":case"gpt-5-chat-latest":return"o200k_base";default:throw new Error("Unknown model")}}var Ya={};U(Ya,{encodingForModel:()=>Ne,getEncoding:()=>dt});const ne={},Ka=new We({});async function dt(e){return e in ne||(ne[e]=Ka.fetch(`https://tiktoken.pages.dev/js/${e}.json`).then(a=>a.json()).then(a=>new ft(a)).catch(a=>{throw delete ne[e],a})),await ne[e]}async function Ne(e){return dt(Xa(e))}var qa={};U(qa,{BaseLangChain:()=>yt,BaseLanguageModel:()=>_t,calculateMaxTokens:()=>ts,getEmbeddingContextSize:()=>Qa,getModelContextSize:()=>bt,getModelNameForTiktoken:()=>pe,isOpenAITool:()=>es});const pe=e=>e.startsWith("gpt-5")?"gpt-5":e.startsWith("gpt-3.5-turbo-16k")?"gpt-3.5-turbo-16k":e.startsWith("gpt-3.5-turbo-")?"gpt-3.5-turbo":e.startsWith("gpt-4-32k")?"gpt-4-32k":e.startsWith("gpt-4-")?"gpt-4":e.startsWith("gpt-4o")?"gpt-4o":e,Qa=e=>{switch(e){case"text-embedding-ada-002":return 8191;default:return 2046}},bt=e=>{switch(pe(e)){case"gpt-5":case"gpt-5-turbo":case"gpt-5-turbo-preview":return 4e5;case"gpt-4o":case"gpt-4o-mini":case"gpt-4o-2024-05-13":case"gpt-4o-2024-08-06":return 128e3;case"gpt-4-turbo":case"gpt-4-turbo-preview":case"gpt-4-turbo-2024-04-09":case"gpt-4-0125-preview":case"gpt-4-1106-preview":return 128e3;case"gpt-4-32k":case"gpt-4-32k-0314":case"gpt-4-32k-0613":return 32768;case"gpt-4":case"gpt-4-0314":case"gpt-4-0613":return 8192;case"gpt-3.5-turbo-16k":case"gpt-3.5-turbo-16k-0613":return 16384;case"gpt-3.5-turbo":case"gpt-3.5-turbo-0301":case"gpt-3.5-turbo-0613":case"gpt-3.5-turbo-1106":case"gpt-3.5-turbo-0125":return 4096;case"text-davinci-003":case"text-davinci-002":return 4097;case"text-davinci-001":return 2049;case"text-curie-001":case"text-babbage-001":case"text-ada-001":return 2048;case"code-davinci-002":case"code-davinci-001":return 8e3;case"code-cushman-001":return 2048;case"claude-3-5-sonnet-20241022":case"claude-3-5-sonnet-20240620":case"claude-3-opus-20240229":case"claude-3-sonnet-20240229":case"claude-3-haiku-20240307":case"claude-2.1":return 2e5;case"claude-2.0":case"claude-instant-1.2":return 1e5;case"gemini-1.5-pro":case"gemini-1.5-pro-latest":case"gemini-1.5-flash":case"gemini-1.5-flash-latest":return 1e6;case"gemini-pro":case"gemini-pro-vision":return 32768;default:return 4097}};function es(e){return typeof e!="object"||!e?!1:!!("type"in e&&e.type==="function"&&"function"in e&&typeof e.function=="object"&&e.function&&"name"in e.function&&"parameters"in e.function)}const ts=async({prompt:e,modelName:a})=>{let n;try{n=(await Ne(pe(a))).encode(e).length}catch{console.warn("Failed to calculate number of tokens, falling back to approximate count"),n=Math.ceil(e.length/4)}return bt(a)-n},as=()=>!1;var yt=class extends H{verbose;callbacks;tags;metadata;get lc_attributes(){return{callbacks:void 0,verbose:void 0}}constructor(e){super(e),this.verbose=e.verbose??as(),this.callbacks=e.callbacks,this.tags=e.tags??[],this.metadata=e.metadata??{}}},_t=class extends yt{get callKeys(){return["stop","timeout","signal","tags","metadata","callbacks"]}caller;cache;constructor({callbacks:e,callbackManager:a,...n}){const{cache:r,...i}=n;super({callbacks:e??a,...i}),typeof r=="object"?this.cache=r:r?this.cache=gt.global():this.cache=void 0,this.caller=new We(n??{})}_encoding;async getNumTokens(e){let a;typeof e=="string"?a=e:a=e.map(r=>typeof r=="string"?r:r.type==="text"&&"text"in r?r.text:"").join("");let n=Math.ceil(a.length/4);if(!this._encoding)try{this._encoding=await Ne("modelName"in this?pe(this.modelName):"gpt2")}catch(r){console.warn("Failed to calculate number of tokens, falling back to approximate count",r)}if(this._encoding)try{n=this._encoding.encode(a).length}catch(r){console.warn("Failed to calculate number of tokens, falling back to approximate count",r)}return n}static _convertInputToPromptValue(e){return typeof e=="string"?new ct(e):Array.isArray(e)?new ut(e.map(re)):e}_identifyingParams(){return{}}_getSerializedCacheKeyParametersForCall({config:e,...a}){const n={...this._identifyingParams(),...a,_type:this._llmType(),_model:this._modelType()};return Object.entries(n).filter(([c,h])=>h!==void 0).map(([c,h])=>`${c}:${JSON.stringify(h)}`).sort().join(",")}serialize(){return{...this._identifyingParams(),_type:this._llmType(),_model:this._modelType()}}static async deserialize(e){throw new Error("Use .toJSON() instead")}get profile(){return{}}},ue=class extends H{static lc_name(){return"RunnablePassthrough"}lc_namespace=["langchain_core","runnables"];lc_serializable=!0;func;constructor(e){super(e),e&&(this.func=e.func)}async invoke(e,a){const n=oe(a);return this.func&&await this.func(e,n),this._callWithConfig(r=>Promise.resolve(r),e,n)}async*transform(e,a){const n=oe(a);let r,i=!0;for await(const c of this._transformStreamWithConfig(e,h=>h,n))if(yield c,i)if(r===void 0)r=c;else try{r=ce(r,c)}catch{r=void 0,i=!1}this.func&&r!==void 0&&await this.func(r,n)}static assign(e){return new Je(new Xe({steps:e}))}};const ss=e=>e();function _e(e){const a=e.constructor;return new a({...e,content:e.contentBlocks,response_metadata:{...e.response_metadata,output_version:"v1"}})}var ns={};U(ns,{BaseChatModel:()=>Tt,SimpleChatModel:()=>rs});function Te(e){const a=[];for(const n of e){let r=n;if(Array.isArray(n.content))for(let i=0;i<n.content.length;i++){const c=n.content[i];(ca(c)||ua(c))&&r===n&&(r=new n.constructor({...r,content:[...n.content.slice(0,i),la(c),...n.content.slice(i+1)]}))}a.push(r)}return a}var Tt=class Z extends _t{lc_namespace=["langchain","chat_models",this._llmType()];disableStreaming=!1;outputVersion;get callKeys(){return[...super.callKeys,"outputVersion"]}constructor(a){super(a),this.outputVersion=ss(()=>{const n=a.outputVersion??na("LC_OUTPUT_VERSION");return n&&["v0","v1"].includes(n)?n:"v0"})}_separateRunnableConfigFromCallOptionsCompat(a){const[n,r]=super._separateRunnableConfigFromCallOptions(a);return r.signal=n.signal,[n,r]}async invoke(a,n){const r=Z._convertInputToPromptValue(a);return(await this.generatePrompt([r],n,n?.callbacks)).generations[0][0].message}async*_streamResponseChunks(a,n,r){throw new Error("Not implemented.")}async*_streamIterator(a,n){if(this._streamResponseChunks===Z.prototype._streamResponseChunks||this.disableStreaming)yield this.invoke(a,n);else{const i=Z._convertInputToPromptValue(a).toChatMessages(),[c,h]=this._separateRunnableConfigFromCallOptionsCompat(n),l={...c.metadata,...this.getLsParams(h)},b=await ye.configure(c.callbacks,this.callbacks,c.tags,this.tags,l,this.metadata,{verbose:this.verbose}),f={options:h,invocation_params:this?.invocationParams(h),batch_size:1},T=h.outputVersion??this.outputVersion,_=await b?.handleChatModelStart(this.toJSON(),[Te(i)],c.runId,void 0,f,void 0,void 0,c.runName);let E,g;try{for await(const d of this._streamResponseChunks(i,h,_?.[0])){if(d.message.id==null){const m=_?.at(0)?.runId;m!=null&&d.message._updateId(`run-${m}`)}d.message.response_metadata={...d.generationInfo,...d.message.response_metadata},T==="v1"?yield _e(d.message):yield d.message,E?E=E.concat(d):E=d,Ve(d.message)&&d.message.usage_metadata!==void 0&&(g={tokenUsage:{promptTokens:d.message.usage_metadata.input_tokens,completionTokens:d.message.usage_metadata.output_tokens,totalTokens:d.message.usage_metadata.total_tokens}})}}catch(d){throw await Promise.all((_??[]).map(m=>m?.handleLLMError(d))),d}await Promise.all((_??[]).map(d=>d?.handleLLMEnd({generations:[[E]],llmOutput:g})))}}getLsParams(a){const n=this.getName().startsWith("Chat")?this.getName().replace("Chat",""):this.getName();return{ls_model_type:"chat",ls_stop:a.stop,ls_provider:n}}async _generateUncached(a,n,r,i){const c=a.map(E=>E.map(re));let h;if(i!==void 0&&i.length===c.length)h=i;else{const E={...r.metadata,...this.getLsParams(n)},g=await ye.configure(r.callbacks,this.callbacks,r.tags,this.tags,E,this.metadata,{verbose:this.verbose}),d={options:n,invocation_params:this?.invocationParams(n),batch_size:1};h=await g?.handleChatModelStart(this.toJSON(),c.map(Te),r.runId,void 0,d,void 0,void 0,r.runName)}const l=n.outputVersion??this.outputVersion,b=[],f=[];if(!!h?.[0].handlers.find(ra)&&!this.disableStreaming&&c.length===1&&this._streamResponseChunks!==Z.prototype._streamResponseChunks)try{const E=await this._streamResponseChunks(c[0],n,h?.[0]);let g,d;for await(const m of E){if(m.message.id==null){const v=h?.at(0)?.runId;v!=null&&m.message._updateId(`run-${v}`)}g===void 0?g=m:g=ce(g,m),Ve(m.message)&&m.message.usage_metadata!==void 0&&(d={tokenUsage:{promptTokens:m.message.usage_metadata.input_tokens,completionTokens:m.message.usage_metadata.output_tokens,totalTokens:m.message.usage_metadata.total_tokens}})}if(g===void 0)throw new Error("Received empty response from chat model call.");b.push([g]),await h?.[0].handleLLMEnd({generations:b,llmOutput:d})}catch(E){throw await h?.[0].handleLLMError(E),E}else{const E=await Promise.allSettled(c.map(async(g,d)=>{const m=await this._generate(g,{...n,promptIndex:d},h?.[d]);if(l==="v1")for(const v of m.generations)v.message=_e(v.message);return m}));await Promise.all(E.map(async(g,d)=>{if(g.status==="fulfilled"){const m=g.value;for(const v of m.generations){if(v.message.id==null){const w=h?.at(0)?.runId;w!=null&&v.message._updateId(`run-${w}`)}v.message.response_metadata={...v.generationInfo,...v.message.response_metadata}}return m.generations.length===1&&(m.generations[0].message.response_metadata={...m.llmOutput,...m.generations[0].message.response_metadata}),b[d]=m.generations,f[d]=m.llmOutput,h?.[d]?.handleLLMEnd({generations:[m.generations],llmOutput:m.llmOutput})}else return await h?.[d]?.handleLLMError(g.reason),Promise.reject(g.reason)}))}const _={generations:b,llmOutput:f.length?this._combineLLMOutput?.(...f):void 0};return Object.defineProperty(_,ze,{value:h?{runIds:h?.map(E=>E.runId)}:void 0,configurable:!0}),_}async _generateCached({messages:a,cache:n,llmStringKey:r,parsedOptions:i,handledOptions:c}){const h=a.map(w=>w.map(re)),l={...c.metadata,...this.getLsParams(i)},b=await ye.configure(c.callbacks,this.callbacks,c.tags,this.tags,l,this.metadata,{verbose:this.verbose}),f={options:i,invocation_params:this?.invocationParams(i),batch_size:1},T=await b?.handleChatModelStart(this.toJSON(),h.map(Te),c.runId,void 0,f,void 0,void 0,c.runName),_=[],g=(await Promise.allSettled(h.map(async(w,A)=>{const C=Z._convertInputToPromptValue(w).toString(),P=await n.lookup(C,r);return P==null&&_.push(A),P}))).map((w,A)=>({result:w,runManager:T?.[A]})).filter(({result:w})=>w.status==="fulfilled"&&w.value!=null||w.status==="rejected"),d=i.outputVersion??this.outputVersion,m=[];await Promise.all(g.map(async({result:w,runManager:A},C)=>{if(w.status==="fulfilled"){const P=w.value;return m[C]=P.map(O=>("message"in O&&X(O.message)&&ia(O.message)&&(O.message.usage_metadata={input_tokens:0,output_tokens:0,total_tokens:0},d==="v1"&&(O.message=_e(O.message))),O.generationInfo={...O.generationInfo,tokenUsage:{}},O)),P.length&&await A?.handleLLMNewToken(P[0].text),A?.handleLLMEnd({generations:[P]},void 0,void 0,void 0,{cached:!0})}else return await A?.handleLLMError(w.reason,void 0,void 0,void 0,{cached:!0}),Promise.reject(w.reason)}));const v={generations:m,missingPromptIndices:_,startedRunManagers:T};return Object.defineProperty(v,ze,{value:T?{runIds:T?.map(w=>w.runId)}:void 0,configurable:!0}),v}async generate(a,n,r){let i;Array.isArray(n)?i={stop:n}:i=n;const c=a.map(d=>d.map(re)),[h,l]=this._separateRunnableConfigFromCallOptionsCompat(i);if(h.callbacks=h.callbacks??r,!this.cache)return this._generateUncached(c,l,h);const{cache:b}=this,f=this._getSerializedCacheKeyParametersForCall(l),{generations:T,missingPromptIndices:_,startedRunManagers:E}=await this._generateCached({messages:c,cache:b,llmStringKey:f,parsedOptions:l,handledOptions:h});let g={};if(_.length>0){const d=await this._generateUncached(_.map(m=>c[m]),l,h,E!==void 0?_.map(m=>E?.[m]):void 0);await Promise.all(d.generations.map(async(m,v)=>{const w=_[v];T[w]=m;const A=Z._convertInputToPromptValue(c[w]).toString();return b.update(A,f,m)})),g=d.llmOutput??{}}return{generations:T,llmOutput:g}}invocationParams(a){return{}}_modelType(){return"base_chat_model"}async generatePrompt(a,n,r){const i=a.map(c=>c.toChatMessages());return this.generate(i,n,r)}withStructuredOutput(a,n){if(typeof this.bindTools!="function")throw new Error('Chat model must implement ".bindTools()" to use withStructuredOutput.');if(n?.strict)throw new Error('"strict" mode is not supported for this model by default.');const r=a,i=n?.name,c=He(r)??"A function available to call.",h=n?.method,l=n?.includeRaw;if(h==="jsonMode")throw new Error('Base withStructuredOutput implementation only supports "functionCalling" as a method.');let b=i??"extract",f;Ae(r)?f=[{type:"function",function:{name:b,description:c,parameters:le(r)}}]:("name"in r&&(b=r.name),f=[{type:"function",function:{name:b,description:c,parameters:r}}]);const T=this.bindTools(f),_=Ie.from(m=>{if(!oa.isInstance(m))throw new Error("Input is not an AIMessageChunk.");if(!m.tool_calls||m.tool_calls.length===0)throw new Error("No tool calls found in the response.");const v=m.tool_calls.find(w=>w.name===b);if(!v)throw new Error(`No tool call found with name ${b}.`);return v.args});if(!l)return T.pipe(_).withConfig({runName:"StructuredOutput"});const E=ue.assign({parsed:(m,v)=>_.invoke(m.raw,v)}),g=ue.assign({parsed:()=>null}),d=E.withFallbacks({fallbacks:[g]});return Ye.from([{raw:T},d]).withConfig({runName:"StructuredOutputRunnable"})}},rs=class extends Tt{async _generate(e,a,n){const r=await this._call(e,a,n),i=new Ke(r);if(typeof i.content!="string")throw new Error("Cannot generate with a simple chat model when output is not a string.");return{generations:[{text:i.content,message:i}]}}},is=class extends H{static lc_name(){return"RouterRunnable"}lc_namespace=["langchain_core","runnables"];lc_serializable=!0;runnables;constructor(e){super(e),this.runnables=e.runnables}async invoke(e,a){const{key:n,input:r}=e,i=this.runnables[n];if(i===void 0)throw new Error(`No runnable associated with key "${n}".`);return i.invoke(r,oe(a))}async batch(e,a,n){const r=e.map(_=>_.key),i=e.map(_=>_.input);if(r.find(_=>this.runnables[_]===void 0)!==void 0)throw new Error("One or more keys do not have a corresponding runnable.");const h=r.map(_=>this.runnables[_]),l=this._getOptionsList(a??{},e.length),b=l[0]?.maxConcurrency??n?.maxConcurrency,f=b&&b>0?b:e.length,T=[];for(let _=0;_<i.length;_+=f){const E=i.slice(_,_+f).map((d,m)=>h[m].invoke(d,l[m])),g=await Promise.all(E);T.push(g)}return T.flat()}async stream(e,a){const{key:n,input:r}=e,i=this.runnables[n];if(i===void 0)throw new Error(`No runnable associated with key "${n}".`);return i.stream(r,a)}},os=class extends H{static lc_name(){return"RunnableBranch"}lc_namespace=["langchain_core","runnables"];lc_serializable=!0;default;branches;constructor(e){super(e),this.branches=e.branches,this.default=e.default}static from(e){if(e.length<1)throw new Error("RunnableBranch requires at least one branch");const n=e.slice(0,-1).map(([i,c])=>[ie(i),ie(c)]),r=ie(e[e.length-1]);return new this({branches:n,default:r})}async _invoke(e,a,n){let r;for(let i=0;i<this.branches.length;i+=1){const[c,h]=this.branches[i];if(await c.invoke(e,G(a,{callbacks:n?.getChild(`condition:${i+1}`)}))){r=await h.invoke(e,G(a,{callbacks:n?.getChild(`branch:${i+1}`)}));break}}return r||(r=await this.default.invoke(e,G(a,{callbacks:n?.getChild("branch:default")}))),r}async invoke(e,a={}){return this._callWithConfig(this._invoke,e,a)}async*_streamIterator(e,a){const r=await(await qe(a))?.handleChainStart(this.toJSON(),ha(e,"input"),a?.runId,void 0,void 0,void 0,a?.runName);let i,c=!0,h;try{for(let l=0;l<this.branches.length;l+=1){const[b,f]=this.branches[l];if(await b.invoke(e,G(a,{callbacks:r?.getChild(`condition:${l+1}`)}))){h=await f.stream(e,G(a,{callbacks:r?.getChild(`branch:${l+1}`)}));for await(const _ of h)if(yield _,c)if(i===void 0)i=_;else try{i=ce(i,_)}catch{i=void 0,c=!1}break}}if(h===void 0){h=await this.default.stream(e,G(a,{callbacks:r?.getChild("branch:default")}));for await(const l of h)if(yield l,c)if(i===void 0)i=l;else try{i=ce(i,l)}catch{i=void 0,c=!1}}}catch(l){throw await r?.handleChainError(l),l}await r?.handleChainEnd(i??{})}},cs=class extends Qe{runnable;inputMessagesKey;outputMessagesKey;historyMessagesKey;getMessageHistory;constructor(e){let a=Ie.from((c,h)=>this._enterHistory(c,h??{})).withConfig({runName:"loadHistory"});const n=e.historyMessagesKey??e.inputMessagesKey;n&&(a=ue.assign({[n]:a}).withConfig({runName:"insertHistory"}));const r=a.pipe(e.runnable.withListeners({onEnd:(c,h)=>this._exitHistory(c,h??{})})).withConfig({runName:"RunnableWithMessageHistory"}),i=e.config??{};super({...e,config:i,bound:r}),this.runnable=e.runnable,this.getMessageHistory=e.getMessageHistory,this.inputMessagesKey=e.inputMessagesKey,this.outputMessagesKey=e.outputMessagesKey,this.historyMessagesKey=e.historyMessagesKey}_getInputMessages(e){let a;if(typeof e=="object"&&!Array.isArray(e)&&!X(e)){let n;this.inputMessagesKey?n=this.inputMessagesKey:Object.keys(e).length===1?n=Object.keys(e)[0]:n="input",Array.isArray(e[n])&&Array.isArray(e[n][0])?a=e[n][0]:a=e[n]}else a=e;if(typeof a=="string")return[new Se(a)];if(Array.isArray(a))return a;if(X(a))return[a];throw new Error(`Expected a string, BaseMessage, or array of BaseMessages.
|
|
3
|
+
Got ${JSON.stringify(a,null,2)}`)}_getOutputMessages(e){let a;if(!Array.isArray(e)&&!X(e)&&typeof e!="string"){let n;this.outputMessagesKey!==void 0?n=this.outputMessagesKey:Object.keys(e).length===1?n=Object.keys(e)[0]:n="output",e.generations!==void 0?a=e.generations[0][0].message:a=e[n]}else a=e;if(typeof a=="string")return[new Ke(a)];if(Array.isArray(a))return a;if(X(a))return[a];throw new Error(`Expected a string, BaseMessage, or array of BaseMessages. Received: ${JSON.stringify(a,null,2)}`)}async _enterHistory(e,a){const r=await(a?.configurable?.messageHistory).getMessages();return this.historyMessagesKey===void 0?r.concat(this._getInputMessages(e)):r}async _exitHistory(e,a){const n=a.configurable?.messageHistory;let r;Array.isArray(e.inputs)&&Array.isArray(e.inputs[0])?r=e.inputs[0]:r=e.inputs;let i=this._getInputMessages(r);if(this.historyMessagesKey===void 0){const l=await n.getMessages();i=i.slice(l.length)}const c=e.outputs;if(!c)throw new Error(`Output values from 'Run' undefined. Run: ${JSON.stringify(e,null,2)}`);const h=this._getOutputMessages(c);await n.addMessages([...i,...h])}async _mergeConfig(...e){const a=await super._mergeConfig(...e);if(!a.configurable||!a.configurable.sessionId){const r={[this.inputMessagesKey??"input"]:"foo"},i={configurable:{sessionId:"123"}};throw new Error(`sessionId is required. Pass it in as part of the config argument to .invoke() or .stream()
|
|
4
|
+
eg. chain.invoke(${JSON.stringify(r)}, ${JSON.stringify(i)})`)}const{sessionId:n}=a.configurable;return a.configurable.messageHistory=await this.getMessageHistory(n),a}},us={};U(us,{RouterRunnable:()=>is,Runnable:()=>H,RunnableAssign:()=>Je,RunnableBinding:()=>Qe,RunnableBranch:()=>os,RunnableEach:()=>Ta,RunnableLambda:()=>Ie,RunnableMap:()=>Xe,RunnableParallel:()=>_a,RunnablePassthrough:()=>ue,RunnablePick:()=>ya,RunnableRetry:()=>ba,RunnableSequence:()=>Ye,RunnableToolLike:()=>da,RunnableWithFallbacks:()=>fa,RunnableWithMessageHistory:()=>cs,_coerceToRunnable:()=>ie,ensureConfig:()=>oe,getCallbackManagerForConfig:()=>qe,mergeConfigs:()=>ma,patchConfig:()=>G,pickRunnableConfigKeys:()=>ga,raceWithSignal:()=>pa});var vt=class extends H{parseResultWithPrompt(e,a,n){return this.parseResult(e,n)}_baseMessageToString(e){return typeof e.content=="string"?e.content:this._baseMessageContentToString(e.content)}_baseMessageContentToString(e){return JSON.stringify(e)}async invoke(e,a){return typeof e=="string"?this._callWithConfig(async(n,r)=>this.parseResult([{text:n}],r?.callbacks),e,{...a,runType:"parser"}):this._callWithConfig(async(n,r)=>this.parseResult([{message:n,text:this._baseMessageToString(n)}],r?.callbacks),e,{...a,runType:"parser"})}},ge=class extends vt{parseResult(e,a){return this.parse(e[0].text,a)}async parseWithPrompt(e,a,n){return this.parse(e,n)}_type(){throw new Error("_type not implemented")}},$=class extends Error{llmOutput;observation;sendToLLM;constructor(e,a,n,r=!1){if(super(e),this.llmOutput=a,this.observation=n,this.sendToLLM=r,r&&(n===void 0||a===void 0))throw new Error("Arguments 'observation' & 'llmOutput' are required if 'sendToLlm' is true");va(this,"OUTPUT_PARSING_FAILURE")}},Q=class extends ge{async*_transform(e){for await(const a of e)typeof a=="string"?yield this.parseResult([{text:a}]):yield this.parseResult([{message:a,text:this._baseMessageToString(a)}])}async*transform(e,a){yield*this._transformStreamWithConfig(e,this._transform.bind(this),{...a,runType:"parser"})}},ke=class extends Q{diff=!1;constructor(e){super(e),this.diff=e?.diff??this.diff}async*_transform(e){let a,n;for await(const r of e){if(typeof r!="string"&&typeof r.content!="string")throw new Error("Cannot handle non-string output.");let i;if(Ea(r)){if(typeof r.content!="string")throw new Error("Cannot handle non-string message output.");i=new Ge({message:r,text:r.content})}else if(X(r)){if(typeof r.content!="string")throw new Error("Cannot handle non-string message output.");i=new Ge({message:wa(r),text:r.content})}else i=new Ca({text:r});n===void 0?n=i:n=n.concat(i);const c=await this.parsePartialResult([n]);c!=null&&!Aa(c,a)&&(this.diff?yield this._diff(a,c):yield c,a=c)}}getFormatInstructions(){return""}},ls={};U(ls,{applyPatch:()=>Sa,compare:()=>Oe});var hs=class extends ke{static lc_name(){return"JsonOutputParser"}lc_namespace=["langchain_core","output_parsers"];lc_serializable=!0;_concatOutputChunks(e,a){return this.diff?super._concatOutputChunks(e,a):a}_diff(e,a){if(a)return e?Oe(e,a):[{op:"replace",path:"",value:a}]}async parsePartialResult(e){return ve(e[0].text)}async parse(e){return ve(e,JSON.parse)}getFormatInstructions(){return""}},ps=class extends Q{static lc_name(){return"BytesOutputParser"}lc_namespace=["langchain_core","output_parsers","bytes"];lc_serializable=!0;textEncoder=new TextEncoder;parse(e){return Promise.resolve(this.textEncoder.encode(e))}getFormatInstructions(){return""}},ee=class extends Q{re;async*_transform(e){let a="";for await(const n of e)if(typeof n=="string"?a+=n:a+=n.content,this.re){const r=[...a.matchAll(this.re)];if(r.length>1){let i=0;for(const c of r.slice(0,-1))yield[c[1]],i+=(c.index??0)+c[0].length;a=a.slice(i)}}else{const r=await this.parse(a);if(r.length>1){for(const i of r.slice(0,-1))yield[i];a=r[r.length-1]}}for(const n of await this.parse(a))yield[n]}},gs=class extends ee{static lc_name(){return"CommaSeparatedListOutputParser"}lc_namespace=["langchain_core","output_parsers","list"];lc_serializable=!0;async parse(e){try{return e.trim().split(",").map(a=>a.trim())}catch{throw new $(`Could not parse output: ${e}`,e)}}getFormatInstructions(){return"Your response should be a list of comma separated values, eg: `foo, bar, baz`"}},ms=class extends ee{lc_namespace=["langchain_core","output_parsers","list"];length;separator;constructor({length:e,separator:a}){super(...arguments),this.length=e,this.separator=a||","}async parse(e){try{const a=e.trim().split(this.separator).map(n=>n.trim());if(this.length!==void 0&&a.length!==this.length)throw new $(`Incorrect number of items. Expected ${this.length}, got ${a.length}.`);return a}catch(a){throw Object.getPrototypeOf(a)===$.prototype?a:new $(`Could not parse output: ${e}`)}}getFormatInstructions(){return`Your response should be a list of ${this.length===void 0?"":`${this.length} `}items separated by "${this.separator}" (eg: \`foo${this.separator} bar${this.separator} baz\`)`}},fs=class extends ee{static lc_name(){return"NumberedListOutputParser"}lc_namespace=["langchain_core","output_parsers","list"];lc_serializable=!0;getFormatInstructions(){return`Your response should be a numbered list with each item on a new line. For example:
|
|
5
|
+
|
|
6
|
+
1. foo
|
|
7
|
+
|
|
8
|
+
2. bar
|
|
9
|
+
|
|
10
|
+
3. baz`}re=/\d+\.\s([^\n]+)/g;async parse(e){return[...e.matchAll(this.re)??[]].map(a=>a[1])}},ds=class extends ee{static lc_name(){return"NumberedListOutputParser"}lc_namespace=["langchain_core","output_parsers","list"];lc_serializable=!0;getFormatInstructions(){return`Your response should be a numbered list with each item on a new line. For example:
|
|
11
|
+
|
|
12
|
+
1. foo
|
|
13
|
+
|
|
14
|
+
2. bar
|
|
15
|
+
|
|
16
|
+
3. baz`}re=/^\s*[-*]\s([^\n]+)$/gm;async parse(e){return[...e.matchAll(this.re)??[]].map(a=>a[1])}},bs=class extends Q{static lc_name(){return"StrOutputParser"}lc_namespace=["langchain_core","output_parsers","string"];lc_serializable=!0;parse(e){return Promise.resolve(e)}getFormatInstructions(){return""}_textContentToString(e){return e.text}_imageUrlContentToString(e){throw new Error('Cannot coerce a multimodal "image_url" message part into a string.')}_messageContentToString(e){switch(e.type){case"text":case"text_delta":if("text"in e)return this._textContentToString(e);break;case"image_url":if("image_url"in e)return this._imageUrlContentToString(e);break;default:throw new Error(`Cannot coerce "${e.type}" message part into a string.`)}throw new Error(`Invalid content type: ${e.type}`)}_baseMessageContentToString(e){return e.reduce((a,n)=>a+this._messageContentToString(n),"")}},Et=class extends ge{static lc_name(){return"StructuredOutputParser"}lc_namespace=["langchain","output_parsers","structured"];toJSON(){return this.toJSONNotImplemented()}constructor(e){super(e),this.schema=e}static fromZodSchema(e){return new this(e)}static fromNamesAndDescriptions(e){const a=et(Object.fromEntries(Object.entries(e).map(([n,r])=>[n,tt().describe(r)])));return new this(a)}getFormatInstructions(){return`You must format your output as a JSON value that adheres to a given "JSON Schema" instance.
|
|
17
|
+
|
|
18
|
+
"JSON Schema" is a declarative language that allows you to annotate and validate JSON documents.
|
|
19
|
+
|
|
20
|
+
For example, the example "JSON Schema" instance {{"properties": {{"foo": {{"description": "a list of test words", "type": "array", "items": {{"type": "string"}}}}}}, "required": ["foo"]}}
|
|
21
|
+
would match an object with one required property, "foo". The "type" property specifies "foo" must be an "array", and the "description" property semantically describes it as "a list of test words". The items within "foo" must be strings.
|
|
22
|
+
Thus, the object {{"foo": ["bar", "baz"]}} is a well-formatted instance of this example "JSON Schema". The object {{"properties": {{"foo": ["bar", "baz"]}}}} is not well-formatted.
|
|
23
|
+
|
|
24
|
+
Your output will be parsed and type-checked according to the provided schema instance, so make sure all fields in your output match the schema exactly and there are no trailing commas!
|
|
25
|
+
|
|
26
|
+
Here is the JSON Schema instance your output must adhere to. Include the enclosing markdown codeblock:
|
|
27
|
+
\`\`\`json
|
|
28
|
+
${JSON.stringify(le(this.schema))}
|
|
29
|
+
\`\`\`
|
|
30
|
+
`}async parse(e){try{const a=e.trim(),r=(a.match(/^```(?:json)?\s*([\s\S]*?)```/)?.[1]||a.match(/```json\s*([\s\S]*?)```/)?.[1]||a).replace(/"([^"\\]*(\\.[^"\\]*)*)"/g,(i,c)=>`"${c.replace(/\n/g,"\\n")}"`).replace(/\n/g,"");return await $e(this.schema,JSON.parse(r))}catch(a){throw new $(`Failed to parse. Text: "${e}". Error: ${a}`,e)}}},wt=class extends Et{static lc_name(){return"JsonMarkdownStructuredOutputParser"}getFormatInstructions(e){const a=e?.interpolationDepth??1;if(a<1)throw new Error("f string interpolation depth must be at least 1");return`Return a markdown code snippet with a JSON object formatted to look like:
|
|
31
|
+
\`\`\`json
|
|
32
|
+
${this._schemaToInstruction(le(this.schema)).replaceAll("{","{".repeat(a)).replaceAll("}","}".repeat(a))}
|
|
33
|
+
\`\`\``}_schemaToInstruction(e,a=2){const n=e;if("type"in n){let r=!1,i;if(Array.isArray(n.type)){const l=n.type.findIndex(b=>b==="null");l!==-1&&(r=!0,n.type.splice(l,1)),i=n.type.join(" | ")}else i=n.type;if(n.type==="object"&&n.properties){const l=n.description?` // ${n.description}`:"";return`{
|
|
34
|
+
${Object.entries(n.properties).map(([f,T])=>{const _=n.required?.includes(f)?"":" (optional)";return`${" ".repeat(a)}"${f}": ${this._schemaToInstruction(T,a+2)}${_}`}).join(`
|
|
35
|
+
`)}
|
|
36
|
+
${" ".repeat(a-2)}}${l}`}if(n.type==="array"&&n.items){const l=n.description?` // ${n.description}`:"";return`array[
|
|
37
|
+
${" ".repeat(a)}${this._schemaToInstruction(n.items,a+2)}
|
|
38
|
+
${" ".repeat(a-2)}] ${l}`}const c=r?" (nullable)":"",h=n.description?` // ${n.description}`:"";return`${i}${h}${c}`}if("anyOf"in n)return n.anyOf.map(r=>this._schemaToInstruction(r,a)).join(`
|
|
39
|
+
${" ".repeat(a-2)}`);throw new Error("unsupported schema type")}static fromZodSchema(e){return new this(e)}static fromNamesAndDescriptions(e){const a=et(Object.fromEntries(Object.entries(e).map(([n,r])=>[n,tt().describe(r)])));return new this(a)}},ys=class extends ge{structuredInputParser;constructor({inputSchema:e}){super(...arguments),this.structuredInputParser=new wt(e)}async parse(e){let a;try{a=await this.structuredInputParser.parse(e)}catch(n){throw new $(`Failed to parse. Text: "${e}". Error: ${n}`,e)}return this.outputProcessor(a)}getFormatInstructions(){return this.structuredInputParser.getFormatInstructions()}};const _s=function(){const e={};e.parser=function(s,t){return new n(s,t)},e.SAXParser=n,e.SAXStream=f,e.createStream=b,e.MAX_BUFFER_LENGTH=64*1024;const a=["comment","sgmlDecl","textNode","tagName","doctype","procInstName","procInstBody","entity","attribName","attribValue","cdata","script"];e.EVENTS=["text","processinginstruction","sgmldeclaration","doctype","comment","opentagstart","attribute","opentag","closetag","opencdata","cdata","closecdata","error","end","ready","script","opennamespace","closenamespace"];function n(s,t){if(!(this instanceof n))return new n(s,t);var p=this;i(p),p.q=p.c="",p.bufferCheckPosition=e.MAX_BUFFER_LENGTH,p.opt=t||{},p.opt.lowercase=p.opt.lowercase||p.opt.lowercasetags,p.looseCase=p.opt.lowercase?"toLowerCase":"toUpperCase",p.tags=[],p.closed=p.closedRoot=p.sawRoot=!1,p.tag=p.error=null,p.strict=!!s,p.noscript=!!(s||p.opt.noscript),p.state=u.BEGIN,p.strictEntities=p.opt.strictEntities,p.ENTITIES=p.strictEntities?Object.create(e.XML_ENTITIES):Object.create(e.ENTITIES),p.attribList=[],p.opt.xmlns&&(p.ns=Object.create(d)),p.trackPosition=p.opt.position!==!1,p.trackPosition&&(p.position=p.line=p.column=0),Y(p,"onready")}Object.create||(Object.create=function(s){function t(){}t.prototype=s;var p=new t;return p}),Object.keys||(Object.keys=function(s){var t=[];for(var p in s)s.hasOwnProperty(p)&&t.push(p);return t});function r(s){for(var t=Math.max(e.MAX_BUFFER_LENGTH,10),p=0,o=0,S=a.length;o<S;o++){var k=s[a[o]].length;if(k>t)switch(a[o]){case"textNode":K(s);break;case"cdata":N(s,"oncdata",s.cdata),s.cdata="";break;case"script":N(s,"onscript",s.script),s.script="";break;default:te(s,"Max buffer length exceeded: "+a[o])}p=Math.max(p,k)}var x=e.MAX_BUFFER_LENGTH-p;s.bufferCheckPosition=x+s.position}function i(s){for(var t=0,p=a.length;t<p;t++)s[a[t]]=""}function c(s){K(s),s.cdata!==""&&(N(s,"oncdata",s.cdata),s.cdata=""),s.script!==""&&(N(s,"onscript",s.script),s.script="")}n.prototype={end:function(){Me(this)},write:It,resume:function(){return this.error=null,this},close:function(){return this.write(null)},flush:function(){c(this)}};var h=ReadableStream;h||(h=function(){});var l=e.EVENTS.filter(function(s){return s!=="error"&&s!=="end"});function b(s,t){return new f(s,t)}function f(s,t){if(!(this instanceof f))return new f(s,t);h.apply(this),this._parser=new n(s,t),this.writable=!0,this.readable=!0;var p=this;this._parser.onend=function(){p.emit("end")},this._parser.onerror=function(o){p.emit("error",o),p._parser.error=null},this._decoder=null,l.forEach(function(o){Object.defineProperty(p,"on"+o,{get:function(){return p._parser["on"+o]},set:function(S){if(!S)return p.removeAllListeners(o),p._parser["on"+o]=S,S;p.on(o,S)},enumerable:!0,configurable:!1})})}f.prototype=Object.create(h.prototype,{constructor:{value:f}}),f.prototype.write=function(s){return this._parser.write(s.toString()),this.emit("data",s),!0},f.prototype.end=function(s){return s&&s.length&&this.write(s),this._parser.end(),!0},f.prototype.on=function(s,t){var p=this;return!p._parser["on"+s]&&l.indexOf(s)!==-1&&(p._parser["on"+s]=function(){var o=arguments.length===1?[arguments[0]]:Array.apply(null,arguments);o.splice(0,0,s),p.emit.apply(p,o)}),h.prototype.on.call(p,s,t)};var T="[CDATA[",_="DOCTYPE",E="http://www.w3.org/XML/1998/namespace",g="http://www.w3.org/2000/xmlns/",d={xml:E,xmlns:g},m=/[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/,v=/[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/,w=/[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/,A=/[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/;function C(s){return s===" "||s===`
|
|
40
|
+
`||s==="\r"||s===" "}function P(s){return s==='"'||s==="'"}function O(s){return s===">"||C(s)}function j(s,t){return s.test(t)}function At(s,t){return!j(s,t)}var u=0;e.STATE={BEGIN:u++,BEGIN_WHITESPACE:u++,TEXT:u++,TEXT_ENTITY:u++,OPEN_WAKA:u++,SGML_DECL:u++,SGML_DECL_QUOTED:u++,DOCTYPE:u++,DOCTYPE_QUOTED:u++,DOCTYPE_DTD:u++,DOCTYPE_DTD_QUOTED:u++,COMMENT_STARTING:u++,COMMENT:u++,COMMENT_ENDING:u++,COMMENT_ENDED:u++,CDATA:u++,CDATA_ENDING:u++,CDATA_ENDING_2:u++,PROC_INST:u++,PROC_INST_BODY:u++,PROC_INST_ENDING:u++,OPEN_TAG:u++,OPEN_TAG_SLASH:u++,ATTRIB:u++,ATTRIB_NAME:u++,ATTRIB_NAME_SAW_WHITE:u++,ATTRIB_VALUE:u++,ATTRIB_VALUE_QUOTED:u++,ATTRIB_VALUE_CLOSED:u++,ATTRIB_VALUE_UNQUOTED:u++,ATTRIB_VALUE_ENTITY_Q:u++,ATTRIB_VALUE_ENTITY_U:u++,CLOSE_TAG:u++,CLOSE_TAG_SAW_WHITE:u++,SCRIPT:u++,SCRIPT_ENDING:u++},e.XML_ENTITIES={amp:"&",gt:">",lt:"<",quot:'"',apos:"'"},e.ENTITIES={amp:"&",gt:">",lt:"<",quot:'"',apos:"'",AElig:198,Aacute:193,Acirc:194,Agrave:192,Aring:197,Atilde:195,Auml:196,Ccedil:199,ETH:208,Eacute:201,Ecirc:202,Egrave:200,Euml:203,Iacute:205,Icirc:206,Igrave:204,Iuml:207,Ntilde:209,Oacute:211,Ocirc:212,Ograve:210,Oslash:216,Otilde:213,Ouml:214,THORN:222,Uacute:218,Ucirc:219,Ugrave:217,Uuml:220,Yacute:221,aacute:225,acirc:226,aelig:230,agrave:224,aring:229,atilde:227,auml:228,ccedil:231,eacute:233,ecirc:234,egrave:232,eth:240,euml:235,iacute:237,icirc:238,igrave:236,iuml:239,ntilde:241,oacute:243,ocirc:244,ograve:242,oslash:248,otilde:245,ouml:246,szlig:223,thorn:254,uacute:250,ucirc:251,ugrave:249,uuml:252,yacute:253,yuml:255,copy:169,reg:174,nbsp:160,iexcl:161,cent:162,pound:163,curren:164,yen:165,brvbar:166,sect:167,uml:168,ordf:170,laquo:171,not:172,shy:173,macr:175,deg:176,plusmn:177,sup1:185,sup2:178,sup3:179,acute:180,micro:181,para:182,middot:183,cedil:184,ordm:186,raquo:187,frac14:188,frac12:189,frac34:190,iquest:191,times:215,divide:247,OElig:338,oelig:339,Scaron:352,scaron:353,Yuml:376,fnof:402,circ:710,tilde:732,Alpha:913,Beta:914,Gamma:915,Delta:916,Epsilon:917,Zeta:918,Eta:919,Theta:920,Iota:921,Kappa:922,Lambda:923,Mu:924,Nu:925,Xi:926,Omicron:927,Pi:928,Rho:929,Sigma:931,Tau:932,Upsilon:933,Phi:934,Chi:935,Psi:936,Omega:937,alpha:945,beta:946,gamma:947,delta:948,epsilon:949,zeta:950,eta:951,theta:952,iota:953,kappa:954,lambda:955,mu:956,nu:957,xi:958,omicron:959,pi:960,rho:961,sigmaf:962,sigma:963,tau:964,upsilon:965,phi:966,chi:967,psi:968,omega:969,thetasym:977,upsih:978,piv:982,ensp:8194,emsp:8195,thinsp:8201,zwnj:8204,zwj:8205,lrm:8206,rlm:8207,ndash:8211,mdash:8212,lsquo:8216,rsquo:8217,sbquo:8218,ldquo:8220,rdquo:8221,bdquo:8222,dagger:8224,Dagger:8225,bull:8226,hellip:8230,permil:8240,prime:8242,Prime:8243,lsaquo:8249,rsaquo:8250,oline:8254,frasl:8260,euro:8364,image:8465,weierp:8472,real:8476,trade:8482,alefsym:8501,larr:8592,uarr:8593,rarr:8594,darr:8595,harr:8596,crarr:8629,lArr:8656,uArr:8657,rArr:8658,dArr:8659,hArr:8660,forall:8704,part:8706,exist:8707,empty:8709,nabla:8711,isin:8712,notin:8713,ni:8715,prod:8719,sum:8721,minus:8722,lowast:8727,radic:8730,prop:8733,infin:8734,ang:8736,and:8743,or:8744,cap:8745,cup:8746,int:8747,there4:8756,sim:8764,cong:8773,asymp:8776,ne:8800,equiv:8801,le:8804,ge:8805,sub:8834,sup:8835,nsub:8836,sube:8838,supe:8839,oplus:8853,otimes:8855,perp:8869,sdot:8901,lceil:8968,rceil:8969,lfloor:8970,rfloor:8971,lang:9001,rang:9002,loz:9674,spades:9824,clubs:9827,hearts:9829,diams:9830},Object.keys(e.ENTITIES).forEach(function(s){var t=e.ENTITIES[s],p=typeof t=="number"?String.fromCharCode(t):t;e.ENTITIES[s]=p});for(var xe in e.STATE)e.STATE[e.STATE[xe]]=xe;u=e.STATE;function Y(s,t,p){s[t]&&s[t](p)}function N(s,t,p){s.textNode&&K(s),Y(s,t,p)}function K(s){s.textNode=Pe(s.opt,s.textNode),s.textNode&&Y(s,"ontext",s.textNode),s.textNode=""}function Pe(s,t){return s.trim&&(t=t.trim()),s.normalize&&(t=t.replace(/\s+/g," ")),t}function te(s,t){return K(s),s.trackPosition&&(t+=`
|
|
41
|
+
Line: `+s.line+`
|
|
42
|
+
Column: `+s.column+`
|
|
43
|
+
Char: `+s.c),t=new Error(t),s.error=t,Y(s,"onerror",t),s}function Me(s){return s.sawRoot&&!s.closedRoot&&I(s,"Unclosed root tag"),s.state!==u.BEGIN&&s.state!==u.BEGIN_WHITESPACE&&s.state!==u.TEXT&&te(s,"Unexpected end"),K(s),s.c="",s.closed=!0,Y(s,"onend"),n.call(s,s.strict,s.opt),s}function I(s,t){if(typeof s!="object"||!(s instanceof n))throw new Error("bad call to strictFail");s.strict&&te(s,t)}function St(s){s.strict||(s.tagName=s.tagName[s.looseCase]());var t=s.tags[s.tags.length-1]||s,p=s.tag={name:s.tagName,attributes:{}};s.opt.xmlns&&(p.ns=t.ns),s.attribList.length=0,N(s,"onopentagstart",p)}function me(s,t){var p=s.indexOf(":"),o=p<0?["",s]:s.split(":"),S=o[0],k=o[1];return t&&s==="xmlns"&&(S="xmlns",k=""),{prefix:S,local:k}}function fe(s){if(s.strict||(s.attribName=s.attribName[s.looseCase]()),s.attribList.indexOf(s.attribName)!==-1||s.tag.attributes.hasOwnProperty(s.attribName)){s.attribName=s.attribValue="";return}if(s.opt.xmlns){var t=me(s.attribName,!0),p=t.prefix,o=t.local;if(p==="xmlns")if(o==="xml"&&s.attribValue!==E)I(s,"xml: prefix must be bound to "+E+`
|
|
44
|
+
Actual: `+s.attribValue);else if(o==="xmlns"&&s.attribValue!==g)I(s,"xmlns: prefix must be bound to "+g+`
|
|
45
|
+
Actual: `+s.attribValue);else{var S=s.tag,k=s.tags[s.tags.length-1]||s;S.ns===k.ns&&(S.ns=Object.create(k.ns)),S.ns[o]=s.attribValue}s.attribList.push([s.attribName,s.attribValue])}else s.tag.attributes[s.attribName]=s.attribValue,N(s,"onattribute",{name:s.attribName,value:s.attribValue});s.attribName=s.attribValue=""}function z(s,t){if(s.opt.xmlns){var p=s.tag,o=me(s.tagName);p.prefix=o.prefix,p.local=o.local,p.uri=p.ns[o.prefix]||"",p.prefix&&!p.uri&&(I(s,"Unbound namespace prefix: "+JSON.stringify(s.tagName)),p.uri=o.prefix);var S=s.tags[s.tags.length-1]||s;p.ns&&S.ns!==p.ns&&Object.keys(p.ns).forEach(function(Be){N(s,"onopennamespace",{prefix:Be,uri:p.ns[Be]})});for(var k=0,x=s.attribList.length;k<x;k++){var F=s.attribList[k],L=F[0],W=F[1],R=me(L,!0),V=R.prefix,Ot=R.local,De=V===""?"":p.ns[V]||"",be={name:L,value:W,prefix:V,local:Ot,uri:De};V&&V!=="xmlns"&&!De&&(I(s,"Unbound namespace prefix: "+JSON.stringify(V)),be.uri=V),s.tag.attributes[L]=be,N(s,"onattribute",be)}s.attribList.length=0}s.tag.isSelfClosing=!!t,s.sawRoot=!0,s.tags.push(s.tag),N(s,"onopentag",s.tag),t||(!s.noscript&&s.tagName.toLowerCase()==="script"?s.state=u.SCRIPT:s.state=u.TEXT,s.tag=null,s.tagName=""),s.attribName=s.attribValue="",s.attribList.length=0}function de(s){if(!s.tagName){I(s,"Weird empty close tag."),s.textNode+="</>",s.state=u.TEXT;return}if(s.script){if(s.tagName!=="script"){s.script+="</"+s.tagName+">",s.tagName="",s.state=u.SCRIPT;return}N(s,"onscript",s.script),s.script=""}var t=s.tags.length,p=s.tagName;s.strict||(p=p[s.looseCase]());for(var o=p;t--;){var S=s.tags[t];if(S.name!==o)I(s,"Unexpected close tag");else break}if(t<0){I(s,"Unmatched closing tag: "+s.tagName),s.textNode+="</"+s.tagName+">",s.state=u.TEXT;return}s.tagName=p;for(var k=s.tags.length;k-- >t;){var x=s.tag=s.tags.pop();s.tagName=s.tag.name,N(s,"onclosetag",s.tagName);var F={};for(var L in x.ns)F[L]=x.ns[L];var W=s.tags[s.tags.length-1]||s;s.opt.xmlns&&x.ns!==W.ns&&Object.keys(x.ns).forEach(function(R){var V=x.ns[R];N(s,"onclosenamespace",{prefix:R,uri:V})})}t===0&&(s.closedRoot=!0),s.tagName=s.attribValue=s.attribName="",s.attribList.length=0,s.state=u.TEXT}function Re(s){var t=s.entity,p=t.toLowerCase(),o,S="";return s.ENTITIES[t]?s.ENTITIES[t]:s.ENTITIES[p]?s.ENTITIES[p]:(t=p,t.charAt(0)==="#"&&(t.charAt(1)==="x"?(t=t.slice(2),o=parseInt(t,16),S=o.toString(16)):(t=t.slice(1),o=parseInt(t,10),S=o.toString(10))),t=t.replace(/^0+/,""),isNaN(o)||S.toLowerCase()!==t?(I(s,"Invalid character entity"),"&"+s.entity+";"):String.fromCodePoint(o))}function Fe(s,t){t==="<"?(s.state=u.OPEN_WAKA,s.startTagPosition=s.position):C(t)||(I(s,"Non-whitespace before first tag."),s.textNode=t,s.state=u.TEXT)}function Le(s,t){var p="";return t<s.length&&(p=s.charAt(t)),p}function It(s){var t=this;if(this.error)throw this.error;if(t.closed)return te(t,"Cannot write after close. Assign an onready handler.");if(s===null)return Me(t);typeof s=="object"&&(s=s.toString());for(var p=0,o="";o=Le(s,p++),t.c=o,!!o;)switch(t.trackPosition&&(t.position++,o===`
|
|
46
|
+
`?(t.line++,t.column=0):t.column++),t.state){case u.BEGIN:if(t.state=u.BEGIN_WHITESPACE,o==="\uFEFF")continue;Fe(t,o);continue;case u.BEGIN_WHITESPACE:Fe(t,o);continue;case u.TEXT:if(t.sawRoot&&!t.closedRoot){for(var S=p-1;o&&o!=="<"&&o!=="&";)o=Le(s,p++),o&&t.trackPosition&&(t.position++,o===`
|
|
47
|
+
`?(t.line++,t.column=0):t.column++);t.textNode+=s.substring(S,p-1)}o==="<"&&!(t.sawRoot&&t.closedRoot&&!t.strict)?(t.state=u.OPEN_WAKA,t.startTagPosition=t.position):(!C(o)&&(!t.sawRoot||t.closedRoot)&&I(t,"Text data outside of root node."),o==="&"?t.state=u.TEXT_ENTITY:t.textNode+=o);continue;case u.SCRIPT:o==="<"?t.state=u.SCRIPT_ENDING:t.script+=o;continue;case u.SCRIPT_ENDING:o==="/"?t.state=u.CLOSE_TAG:(t.script+="<"+o,t.state=u.SCRIPT);continue;case u.OPEN_WAKA:if(o==="!")t.state=u.SGML_DECL,t.sgmlDecl="";else if(!C(o))if(j(m,o))t.state=u.OPEN_TAG,t.tagName=o;else if(o==="/")t.state=u.CLOSE_TAG,t.tagName="";else if(o==="?")t.state=u.PROC_INST,t.procInstName=t.procInstBody="";else{if(I(t,"Unencoded <"),t.startTagPosition+1<t.position){var k=t.position-t.startTagPosition;o=new Array(k).join(" ")+o}t.textNode+="<"+o,t.state=u.TEXT}continue;case u.SGML_DECL:(t.sgmlDecl+o).toUpperCase()===T?(N(t,"onopencdata"),t.state=u.CDATA,t.sgmlDecl="",t.cdata=""):t.sgmlDecl+o==="--"?(t.state=u.COMMENT,t.comment="",t.sgmlDecl=""):(t.sgmlDecl+o).toUpperCase()===_?(t.state=u.DOCTYPE,(t.doctype||t.sawRoot)&&I(t,"Inappropriately located doctype declaration"),t.doctype="",t.sgmlDecl=""):o===">"?(N(t,"onsgmldeclaration",t.sgmlDecl),t.sgmlDecl="",t.state=u.TEXT):(P(o)&&(t.state=u.SGML_DECL_QUOTED),t.sgmlDecl+=o);continue;case u.SGML_DECL_QUOTED:o===t.q&&(t.state=u.SGML_DECL,t.q=""),t.sgmlDecl+=o;continue;case u.DOCTYPE:o===">"?(t.state=u.TEXT,N(t,"ondoctype",t.doctype),t.doctype=!0):(t.doctype+=o,o==="["?t.state=u.DOCTYPE_DTD:P(o)&&(t.state=u.DOCTYPE_QUOTED,t.q=o));continue;case u.DOCTYPE_QUOTED:t.doctype+=o,o===t.q&&(t.q="",t.state=u.DOCTYPE);continue;case u.DOCTYPE_DTD:t.doctype+=o,o==="]"?t.state=u.DOCTYPE:P(o)&&(t.state=u.DOCTYPE_DTD_QUOTED,t.q=o);continue;case u.DOCTYPE_DTD_QUOTED:t.doctype+=o,o===t.q&&(t.state=u.DOCTYPE_DTD,t.q="");continue;case u.COMMENT:o==="-"?t.state=u.COMMENT_ENDING:t.comment+=o;continue;case u.COMMENT_ENDING:o==="-"?(t.state=u.COMMENT_ENDED,t.comment=Pe(t.opt,t.comment),t.comment&&N(t,"oncomment",t.comment),t.comment=""):(t.comment+="-"+o,t.state=u.COMMENT);continue;case u.COMMENT_ENDED:o!==">"?(I(t,"Malformed comment"),t.comment+="--"+o,t.state=u.COMMENT):t.state=u.TEXT;continue;case u.CDATA:o==="]"?t.state=u.CDATA_ENDING:t.cdata+=o;continue;case u.CDATA_ENDING:o==="]"?t.state=u.CDATA_ENDING_2:(t.cdata+="]"+o,t.state=u.CDATA);continue;case u.CDATA_ENDING_2:o===">"?(t.cdata&&N(t,"oncdata",t.cdata),N(t,"onclosecdata"),t.cdata="",t.state=u.TEXT):o==="]"?t.cdata+="]":(t.cdata+="]]"+o,t.state=u.CDATA);continue;case u.PROC_INST:o==="?"?t.state=u.PROC_INST_ENDING:C(o)?t.state=u.PROC_INST_BODY:t.procInstName+=o;continue;case u.PROC_INST_BODY:if(!t.procInstBody&&C(o))continue;o==="?"?t.state=u.PROC_INST_ENDING:t.procInstBody+=o;continue;case u.PROC_INST_ENDING:o===">"?(N(t,"onprocessinginstruction",{name:t.procInstName,body:t.procInstBody}),t.procInstName=t.procInstBody="",t.state=u.TEXT):(t.procInstBody+="?"+o,t.state=u.PROC_INST_BODY);continue;case u.OPEN_TAG:j(v,o)?t.tagName+=o:(St(t),o===">"?z(t):o==="/"?t.state=u.OPEN_TAG_SLASH:(C(o)||I(t,"Invalid character in tag name"),t.state=u.ATTRIB));continue;case u.OPEN_TAG_SLASH:o===">"?(z(t,!0),de(t)):(I(t,"Forward-slash in opening tag not followed by >"),t.state=u.ATTRIB);continue;case u.ATTRIB:if(C(o))continue;o===">"?z(t):o==="/"?t.state=u.OPEN_TAG_SLASH:j(m,o)?(t.attribName=o,t.attribValue="",t.state=u.ATTRIB_NAME):I(t,"Invalid attribute name");continue;case u.ATTRIB_NAME:o==="="?t.state=u.ATTRIB_VALUE:o===">"?(I(t,"Attribute without value"),t.attribValue=t.attribName,fe(t),z(t)):C(o)?t.state=u.ATTRIB_NAME_SAW_WHITE:j(v,o)?t.attribName+=o:I(t,"Invalid attribute name");continue;case u.ATTRIB_NAME_SAW_WHITE:if(o==="=")t.state=u.ATTRIB_VALUE;else{if(C(o))continue;I(t,"Attribute without value"),t.tag.attributes[t.attribName]="",t.attribValue="",N(t,"onattribute",{name:t.attribName,value:""}),t.attribName="",o===">"?z(t):j(m,o)?(t.attribName=o,t.state=u.ATTRIB_NAME):(I(t,"Invalid attribute name"),t.state=u.ATTRIB)}continue;case u.ATTRIB_VALUE:if(C(o))continue;P(o)?(t.q=o,t.state=u.ATTRIB_VALUE_QUOTED):(I(t,"Unquoted attribute value"),t.state=u.ATTRIB_VALUE_UNQUOTED,t.attribValue=o);continue;case u.ATTRIB_VALUE_QUOTED:if(o!==t.q){o==="&"?t.state=u.ATTRIB_VALUE_ENTITY_Q:t.attribValue+=o;continue}fe(t),t.q="",t.state=u.ATTRIB_VALUE_CLOSED;continue;case u.ATTRIB_VALUE_CLOSED:C(o)?t.state=u.ATTRIB:o===">"?z(t):o==="/"?t.state=u.OPEN_TAG_SLASH:j(m,o)?(I(t,"No whitespace between attributes"),t.attribName=o,t.attribValue="",t.state=u.ATTRIB_NAME):I(t,"Invalid attribute name");continue;case u.ATTRIB_VALUE_UNQUOTED:if(!O(o)){o==="&"?t.state=u.ATTRIB_VALUE_ENTITY_U:t.attribValue+=o;continue}fe(t),o===">"?z(t):t.state=u.ATTRIB;continue;case u.CLOSE_TAG:if(t.tagName)o===">"?de(t):j(v,o)?t.tagName+=o:t.script?(t.script+="</"+t.tagName,t.tagName="",t.state=u.SCRIPT):(C(o)||I(t,"Invalid tagname in closing tag"),t.state=u.CLOSE_TAG_SAW_WHITE);else{if(C(o))continue;At(m,o)?t.script?(t.script+="</"+o,t.state=u.SCRIPT):I(t,"Invalid tagname in closing tag."):t.tagName=o}continue;case u.CLOSE_TAG_SAW_WHITE:if(C(o))continue;o===">"?de(t):I(t,"Invalid characters in closing tag");continue;case u.TEXT_ENTITY:case u.ATTRIB_VALUE_ENTITY_Q:case u.ATTRIB_VALUE_ENTITY_U:var x,F;switch(t.state){case u.TEXT_ENTITY:x=u.TEXT,F="textNode";break;case u.ATTRIB_VALUE_ENTITY_Q:x=u.ATTRIB_VALUE_QUOTED,F="attribValue";break;case u.ATTRIB_VALUE_ENTITY_U:x=u.ATTRIB_VALUE_UNQUOTED,F="attribValue";break}if(o===";")if(t.opt.unparsedEntities){var L=Re(t);t.entity="",t.state=x,t.write(L)}else t[F]+=Re(t),t.entity="",t.state=x;else j(t.entity.length?A:w,o)?t.entity+=o:(I(t,"Invalid character in entity name"),t[F]+="&"+t.entity+o,t.entity="",t.state=x);continue;default:throw new Error(t,"Unknown state: "+t.state)}return t.position>=t.bufferCheckPosition&&r(t),t}return String.fromCodePoint||(function(){var s=String.fromCharCode,t=Math.floor,p=function(){var o=16384,S=[],k,x,F=-1,L=arguments.length;if(!L)return"";for(var W="";++F<L;){var R=Number(arguments[F]);if(!isFinite(R)||R<0||R>1114111||t(R)!==R)throw RangeError("Invalid code point: "+R);R<=65535?S.push(R):(R-=65536,k=(R>>10)+55296,x=R%1024+56320,S.push(k,x)),(F+1===L||S.length>o)&&(W+=s.apply(null,S),S.length=0)}return W};Object.defineProperty?Object.defineProperty(String,"fromCodePoint",{value:p,configurable:!0,writable:!0}):String.fromCodePoint=p})(),e},Ts=_s(),we=`The output should be formatted as a XML file.
|
|
48
|
+
1. Output should conform to the tags below.
|
|
49
|
+
2. If tags are not given, make them on your own.
|
|
50
|
+
3. Remember to always open and close all the tags.
|
|
51
|
+
|
|
52
|
+
As an example, for the tags ["foo", "bar", "baz"]:
|
|
53
|
+
1. String "<foo>
|
|
54
|
+
<bar>
|
|
55
|
+
<baz></baz>
|
|
56
|
+
</bar>
|
|
57
|
+
</foo>" is a well-formatted instance of the schema.
|
|
58
|
+
2. String "<foo>
|
|
59
|
+
<bar>
|
|
60
|
+
</foo>" is a badly-formatted instance.
|
|
61
|
+
3. String "<foo>
|
|
62
|
+
<tag>
|
|
63
|
+
</tag>
|
|
64
|
+
</foo>" is a badly-formatted instance.
|
|
65
|
+
|
|
66
|
+
Here are the output tags:
|
|
67
|
+
\`\`\`
|
|
68
|
+
{tags}
|
|
69
|
+
\`\`\``;var vs=class extends ke{tags;constructor(e){super(e),this.tags=e?.tags}static lc_name(){return"XMLOutputParser"}lc_namespace=["langchain_core","output_parsers"];lc_serializable=!0;_diff(e,a){if(a)return e?Oe(e,a):[{op:"replace",path:"",value:a}]}async parsePartialResult(e){return Ce(e[0].text)}async parse(e){return Ce(e)}getFormatInstructions(){return!!(this.tags&&this.tags.length>0)?we.replace("{tags}",this.tags?.join(", ")??""):we}};const Es=e=>e.split(`
|
|
70
|
+
`).map(a=>a.replace(/^\s+/,"")).join(`
|
|
71
|
+
`).trim(),Ct=e=>{if(Object.keys(e).length===0)return{};const a={};return e.children.length>0?(a[e.name]=e.children.map(Ct),a):(a[e.name]=e.text??void 0,a)};function Ce(e){const a=Es(e),n=Ts.parser(!0);let r={};const i=[];n.onopentag=l=>{const b={name:l.name,attributes:l.attributes,children:[],text:"",isSelfClosing:l.isSelfClosing};i.length>0?i[i.length-1].children.push(b):r=b,l.isSelfClosing||i.push(b)},n.onclosetag=()=>{if(i.length>0){const l=i.pop();i.length===0&&l&&(r=l)}},n.ontext=l=>{if(i.length>0){const b=i[i.length-1];b.text+=l}},n.onattribute=l=>{if(i.length>0){const b=i[i.length-1];b.attributes[l.name]=l.value}};const c=/```(xml)?(.*)```/s.exec(a),h=c?c[2]:a;return n.write(h).close(),r&&r.name==="?xml"&&(r=r.children[0]),Ct(r)}var ws={};U(ws,{AsymmetricStructuredOutputParser:()=>ys,BaseCumulativeTransformOutputParser:()=>ke,BaseLLMOutputParser:()=>vt,BaseOutputParser:()=>ge,BaseTransformOutputParser:()=>Q,BytesOutputParser:()=>ps,CommaSeparatedListOutputParser:()=>gs,CustomListOutputParser:()=>ms,JsonMarkdownStructuredOutputParser:()=>wt,JsonOutputParser:()=>hs,ListOutputParser:()=>ee,MarkdownListOutputParser:()=>ds,NumberedListOutputParser:()=>fs,OutputParserException:()=>$,StringOutputParser:()=>bs,StructuredOutputParser:()=>Et,XMLOutputParser:()=>vs,XML_FORMAT_INSTRUCTIONS:()=>we,parseJsonMarkdown:()=>ve,parsePartialJson:()=>Ia,parseXMLMarkdown:()=>Ce});export{yt as B,ut as C,Ma as I,hs as J,$ as O,ue as R,Et as S,st as a,nt as b,it as c,ke as d,_t as e,es as f,vt as g,Tt as h,rt as i,ka as j,ct as k,Oe as l,ge as m,Ya as n,ls as o,Fa as p,Na as q,us as r,lt as s,xa as t,Pa as u,ws as v,ns as w,qa as x,La as y,bt as z};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{r as O,t as M,u as R,g as b,C as L,G as N,w as x,x as J,R as P}from"./index-
|
|
1
|
+
import{r as O,t as M,u as R,g as b,C as L,G as N,w as x,x as J,R as P}from"./index-C9DK5WY4.js";import{O as k,d as E,e as T}from"./index-jYSn9Ie7.js";function C(n,e){if(n.function===void 0)return;let t;if(e?.partial)try{t=R(n.function.arguments??"{}")}catch{return}else try{t=JSON.parse(n.function.arguments)}catch(r){throw new k([`Function "${n.function.name}" arguments:`,"",n.function.arguments,"","are not valid JSON.",`Error: ${r.message}`].join(`
|
|
2
2
|
`))}const s={name:n.function.name,args:t,type:"tool_call"};return e?.returnId&&(s.id=n.id),s}function z(n){if(n.id===void 0)throw new Error('All OpenAI tool calls must have an "id" field.');return{id:n.id,type:"function",function:{name:n.name,arguments:JSON.stringify(n.args)}}}function A(n,e){return{name:n.function?.name,args:n.function?.arguments,id:n.id,error:e,type:"invalid_tool_call"}}var S=class extends E{static lc_name(){return"JsonOutputToolsParser"}returnId=!1;lc_namespace=["langchain","output_parsers","openai_tools"];lc_serializable=!0;constructor(n){super(n),this.returnId=n?.returnId??this.returnId}_diff(){throw new Error("Not supported.")}async parse(){throw new Error("Not implemented.")}async parseResult(n){return await this.parsePartialResult(n,!1)}async parsePartialResult(n,e=!0){const t=n[0].message;let s;if(M(t)&&t.tool_calls?.length?s=t.tool_calls.map(a=>{const{id:l,...u}=a;return this.returnId?{id:l,...u}:u}):t.additional_kwargs.tool_calls!==void 0&&(s=JSON.parse(JSON.stringify(t.additional_kwargs.tool_calls)).map(l=>C(l,{returnId:this.returnId,partial:e}))),!s)return[];const r=[];for(const a of s)if(a!==void 0){const l={type:a.name,args:a.args,id:a.id};r.push(l)}return r}},F=class extends S{static lc_name(){return"JsonOutputKeyToolsParser"}lc_namespace=["langchain","output_parsers","openai_tools"];lc_serializable=!0;returnId=!1;keyName;returnSingle=!1;zodSchema;constructor(n){super(n),this.keyName=n.keyName,this.returnSingle=n.returnSingle??this.returnSingle,this.zodSchema=n.zodSchema}async _validateResult(n){if(this.zodSchema===void 0)return n;const e=await O(this.zodSchema,n);if(e.success)return e.data;throw new k(`Failed to parse. Text: "${JSON.stringify(n,null,2)}". Error: ${JSON.stringify(e.error?.issues)}`,JSON.stringify(n,null,2))}async parsePartialResult(n){const t=(await super.parsePartialResult(n)).filter(r=>r.type===this.keyName);let s=t;if(t.length)return this.returnId||(s=t.map(r=>r.args)),this.returnSingle?s[0]:s}async parseResult(n){const t=(await super.parsePartialResult(n,!1)).filter(a=>a.type===this.keyName);let s=t;return t.length?(this.returnId||(s=t.map(a=>a.args)),this.returnSingle?this._validateResult(s[0]):await Promise.all(s.map(a=>this._validateResult(a)))):void 0}},K={};b(K,{JsonOutputKeyToolsParser:()=>F,JsonOutputToolsParser:()=>S,convertLangChainToolCallToOpenAI:()=>z,makeInvalidToolCall:()=>A,parseToolCall:()=>C});var U={};b(U,{BaseLLM:()=>I,LLM:()=>j});var I=class f extends T{lc_namespace=["langchain","llms",this._llmType()];async invoke(e,t){const s=f._convertInputToPromptValue(e);return(await this.generatePrompt([s],t,t?.callbacks)).generations[0][0].text}async*_streamResponseChunks(e,t,s){throw new Error("Not implemented.")}_separateRunnableConfigFromCallOptionsCompat(e){const[t,s]=super._separateRunnableConfigFromCallOptions(e);return s.signal=t.signal,[t,s]}async*_streamIterator(e,t){if(this._streamResponseChunks===f.prototype._streamResponseChunks)yield this.invoke(e,t);else{const s=f._convertInputToPromptValue(e),[r,a]=this._separateRunnableConfigFromCallOptionsCompat(t),l=await L.configure(r.callbacks,this.callbacks,r.tags,this.tags,r.metadata,this.metadata,{verbose:this.verbose}),u={options:a,invocation_params:this?.invocationParams(a),batch_size:1},h=await l?.handleLLMStart(this.toJSON(),[s.toString()],r.runId,void 0,u,void 0,void 0,r.runName);let o=new N({text:""});try{for await(const i of this._streamResponseChunks(s.toString(),a,h?.[0]))o?o=o.concat(i):o=i,typeof i.text=="string"&&(yield i.text)}catch(i){throw await Promise.all((h??[]).map(d=>d?.handleLLMError(i))),i}await Promise.all((h??[]).map(i=>i?.handleLLMEnd({generations:[[o]]})))}}async generatePrompt(e,t,s){const r=e.map(a=>a.toString());return this.generate(r,t,s)}invocationParams(e){return{}}_flattenLLMResult(e){const t=[];for(let s=0;s<e.generations.length;s+=1){const r=e.generations[s];if(s===0)t.push({generations:[r],llmOutput:e.llmOutput});else{const a=e.llmOutput?{...e.llmOutput,tokenUsage:{}}:void 0;t.push({generations:[r],llmOutput:a})}}return t}async _generateUncached(e,t,s,r){let a;if(r!==void 0&&r.length===e.length)a=r;else{const o=await L.configure(s.callbacks,this.callbacks,s.tags,this.tags,s.metadata,this.metadata,{verbose:this.verbose}),i={options:t,invocation_params:this?.invocationParams(t),batch_size:e.length};a=await o?.handleLLMStart(this.toJSON(),e,s.runId,void 0,i,void 0,void 0,s?.runName)}const l=!!a?.[0].handlers.find(x);let u;if(l&&e.length===1&&this._streamResponseChunks!==f.prototype._streamResponseChunks)try{const o=await this._streamResponseChunks(e[0],t,a?.[0]);let i;for await(const d of o)i===void 0?i=d:i=J(i,d);if(i===void 0)throw new Error("Received empty response from chat model call.");u={generations:[[i]],llmOutput:{}},await a?.[0].handleLLMEnd(u)}catch(o){throw await a?.[0].handleLLMError(o),o}else{try{u=await this._generate(e,t,a?.[0])}catch(i){throw await Promise.all((a??[]).map(d=>d?.handleLLMError(i))),i}const o=this._flattenLLMResult(u);await Promise.all((a??[]).map((i,d)=>i?.handleLLMEnd(o[d])))}const h=a?.map(o=>o.runId)||void 0;return Object.defineProperty(u,P,{value:h?{runIds:h}:void 0,configurable:!0}),u}async _generateCached({prompts:e,cache:t,llmStringKey:s,parsedOptions:r,handledOptions:a,runId:l}){const u=await L.configure(a.callbacks,this.callbacks,a.tags,this.tags,a.metadata,this.metadata,{verbose:this.verbose}),h={options:r,invocation_params:this?.invocationParams(r),batch_size:e.length},o=await u?.handleLLMStart(this.toJSON(),e,l,void 0,h,void 0,void 0,a?.runName),i=[],v=(await Promise.allSettled(e.map(async(c,m)=>{const _=await t.lookup(c,s);return _==null&&i.push(m),_}))).map((c,m)=>({result:c,runManager:o?.[m]})).filter(({result:c})=>c.status==="fulfilled"&&c.value!=null||c.status==="rejected"),p=[];await Promise.all(v.map(async({result:c,runManager:m},_)=>{if(c.status==="fulfilled"){const y=c.value;return p[_]=y.map(w=>(w.generationInfo={...w.generationInfo,tokenUsage:{}},w)),y.length&&await m?.handleLLMNewToken(y[0].text),m?.handleLLMEnd({generations:[y]},void 0,void 0,void 0,{cached:!0})}else return await m?.handleLLMError(c.reason,void 0,void 0,void 0,{cached:!0}),Promise.reject(c.reason)}));const g={generations:p,missingPromptIndices:i,startedRunManagers:o};return Object.defineProperty(g,P,{value:o?{runIds:o?.map(c=>c.runId)}:void 0,configurable:!0}),g}async generate(e,t,s){if(!Array.isArray(e))throw new Error("Argument 'prompts' is expected to be a string[]");let r;Array.isArray(t)?r={stop:t}:r=t;const[a,l]=this._separateRunnableConfigFromCallOptionsCompat(r);if(a.callbacks=a.callbacks??s,!this.cache)return this._generateUncached(e,l,a);const{cache:u}=this,h=this._getSerializedCacheKeyParametersForCall(l),{generations:o,missingPromptIndices:i,startedRunManagers:d}=await this._generateCached({prompts:e,cache:u,llmStringKey:h,parsedOptions:l,handledOptions:a,runId:a.runId});let v={};if(i.length>0){const p=await this._generateUncached(i.map(g=>e[g]),l,a,d!==void 0?i.map(g=>d?.[g]):void 0);await Promise.all(p.generations.map(async(g,c)=>{const m=i[c];return o[m]=g,u.update(e[m],h,g)})),v=p.llmOutput??{}}return{generations:o,llmOutput:v}}_identifyingParams(){return{}}_modelType(){return"base_llm"}},j=class extends I{async _generate(n,e,t){return{generations:await Promise.all(n.map((r,a)=>this._call(r,{...e,promptIndex:a},t).then(l=>[{text:l}])))}}};export{F as J,j as L,z as c,U as l,A as m,K as o,C as p};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function t(){return()=>{}}function i(n){return JSON.stringify(n)}function u(){}function o(){}const r={debuglog:t,inspect:i,inherits:u,format:o};export{t as debuglog,r as default,o as format,u as inherits,i as inspect};
|
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-
|
|
31
|
-
<link rel="stylesheet" crossorigin href="/inspector/assets/index-
|
|
32
|
-
<script>window.__INSPECTOR_VERSION__ = "0.14.0-canary.
|
|
30
|
+
<script type="module" crossorigin src="/inspector/assets/index-c4KcZ9vr.js"></script>
|
|
31
|
+
<link rel="stylesheet" crossorigin href="/inspector/assets/index-T9QtDRcf.css">
|
|
32
|
+
<script>window.__INSPECTOR_VERSION__ = "0.14.0-canary.10";</script>
|
|
33
33
|
</head>
|
|
34
34
|
<body>
|
|
35
35
|
<script>
|
|
@@ -42,7 +42,9 @@ function registerStaticRoutes(app, clientDistPath) {
|
|
|
42
42
|
return c.notFound();
|
|
43
43
|
});
|
|
44
44
|
app.get("/", (c) => {
|
|
45
|
-
|
|
45
|
+
const url = new URL(c.req.url);
|
|
46
|
+
const queryString = url.search;
|
|
47
|
+
return c.redirect(`/inspector${queryString}`);
|
|
46
48
|
});
|
|
47
49
|
app.get("/inspector", (c) => {
|
|
48
50
|
const indexPath = join(distPath, "index.html");
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
formatErrorResponse
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-PUX4EJWH.js";
|
|
4
4
|
import {
|
|
5
5
|
rpcLogBus
|
|
6
6
|
} from "./chunk-CVECQ7BJ.js";
|
|
@@ -12,60 +12,16 @@ import {
|
|
|
12
12
|
handleChatRequest,
|
|
13
13
|
handleChatRequestStream,
|
|
14
14
|
storeWidgetData
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-Z5QIR3IS.js";
|
|
16
16
|
|
|
17
17
|
// src/server/shared-routes.ts
|
|
18
|
-
import {
|
|
18
|
+
import { mountMcpProxy } from "mcp-use/server";
|
|
19
19
|
function registerInspectorRoutes(app, config) {
|
|
20
20
|
app.get("/inspector/health", (c) => {
|
|
21
21
|
return c.json({ status: "ok", timestamp: (/* @__PURE__ */ new Date()).toISOString() });
|
|
22
22
|
});
|
|
23
|
-
app
|
|
24
|
-
|
|
25
|
-
try {
|
|
26
|
-
const targetUrl = c.req.header("X-Target-URL");
|
|
27
|
-
if (!targetUrl) {
|
|
28
|
-
return c.json({ error: "X-Target-URL header is required" }, 400);
|
|
29
|
-
}
|
|
30
|
-
const method = c.req.method;
|
|
31
|
-
const headers = {};
|
|
32
|
-
const requestHeaders = c.req.header();
|
|
33
|
-
for (const [key, value] of Object.entries(requestHeaders)) {
|
|
34
|
-
const lowerKey = key.toLowerCase();
|
|
35
|
-
if (!lowerKey.startsWith("x-proxy-") && !lowerKey.startsWith("x-target-") && lowerKey !== "host" && lowerKey !== "accept-encoding") {
|
|
36
|
-
headers[key] = value;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
headers["Accept-Encoding"] = "identity";
|
|
40
|
-
try {
|
|
41
|
-
const targetUrlObj = new URL(targetUrl);
|
|
42
|
-
headers.Host = targetUrlObj.host;
|
|
43
|
-
} catch {
|
|
44
|
-
return c.json({ error: "Invalid target URL" }, 400);
|
|
45
|
-
}
|
|
46
|
-
const body = method !== "GET" && method !== "HEAD" ? await c.req.arrayBuffer() : void 0;
|
|
47
|
-
const response = await fetch(targetUrl, {
|
|
48
|
-
method,
|
|
49
|
-
headers,
|
|
50
|
-
body: body ? new Uint8Array(body) : void 0
|
|
51
|
-
});
|
|
52
|
-
const responseHeaders = {};
|
|
53
|
-
response.headers.forEach((value, key) => {
|
|
54
|
-
const lowerKey = key.toLowerCase();
|
|
55
|
-
if (lowerKey !== "content-encoding" && lowerKey !== "transfer-encoding" && lowerKey !== "content-length") {
|
|
56
|
-
responseHeaders[key] = value;
|
|
57
|
-
}
|
|
58
|
-
});
|
|
59
|
-
return new Response(response.body, {
|
|
60
|
-
status: response.status,
|
|
61
|
-
statusText: response.statusText,
|
|
62
|
-
headers: responseHeaders
|
|
63
|
-
});
|
|
64
|
-
} catch (error) {
|
|
65
|
-
const message = error instanceof Error ? error.message : "Unknown error";
|
|
66
|
-
console.error("Proxy request failed:", message, error);
|
|
67
|
-
return c.json({ error: "Proxy request failed", details: message }, 500);
|
|
68
|
-
}
|
|
23
|
+
mountMcpProxy(app, {
|
|
24
|
+
path: "/inspector/api/proxy"
|
|
69
25
|
});
|
|
70
26
|
app.post("/inspector/api/chat/stream", async (c) => {
|
|
71
27
|
try {
|
|
@@ -37,6 +37,16 @@ async function isPortAvailable(port) {
|
|
|
37
37
|
server.on("error", () => resolve(false));
|
|
38
38
|
});
|
|
39
39
|
}
|
|
40
|
+
function parsePortFromArgs() {
|
|
41
|
+
const portArgIndex = process.argv.indexOf("--port");
|
|
42
|
+
if (portArgIndex !== -1 && portArgIndex + 1 < process.argv.length) {
|
|
43
|
+
const portValue = Number.parseInt(process.argv[portArgIndex + 1], 10);
|
|
44
|
+
if (!Number.isNaN(portValue) && portValue >= 1 && portValue <= 65535) {
|
|
45
|
+
return portValue;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
40
50
|
function formatErrorResponse(error, context) {
|
|
41
51
|
const timestamp = (/* @__PURE__ */ new Date()).toISOString();
|
|
42
52
|
const errorMessage = error instanceof Error ? error.message : "Unknown error";
|
|
@@ -58,5 +68,6 @@ export {
|
|
|
58
68
|
isValidUrl,
|
|
59
69
|
findAvailablePort,
|
|
60
70
|
isPortAvailable,
|
|
71
|
+
parsePortFromArgs,
|
|
61
72
|
formatErrorResponse
|
|
62
73
|
};
|
|
@@ -15,7 +15,7 @@ async function* handleChatRequestStream(requestBody) {
|
|
|
15
15
|
"Missing required fields: mcpServerUrl, llmConfig, messages"
|
|
16
16
|
);
|
|
17
17
|
}
|
|
18
|
-
const { MCPAgent, MCPClient } = await import("mcp-use
|
|
18
|
+
const { MCPAgent, MCPClient } = await import("mcp-use");
|
|
19
19
|
let llm;
|
|
20
20
|
if (llmConfig.provider === "openai") {
|
|
21
21
|
const { ChatOpenAI } = await import("@langchain/openai");
|
|
@@ -129,7 +129,7 @@ async function handleChatRequest(requestBody) {
|
|
|
129
129
|
"Missing required fields: mcpServerUrl, llmConfig, messages"
|
|
130
130
|
);
|
|
131
131
|
}
|
|
132
|
-
const { MCPAgent, MCPClient } = await import("mcp-use
|
|
132
|
+
const { MCPAgent, MCPClient } = await import("mcp-use");
|
|
133
133
|
let llm;
|
|
134
134
|
if (llmConfig.provider === "openai") {
|
|
135
135
|
const { ChatOpenAI } = await import("@langchain/openai");
|
package/dist/server/cli.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
registerInspectorRoutes
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-E4Y73JSU.js";
|
|
5
5
|
import {
|
|
6
6
|
findAvailablePort,
|
|
7
7
|
isValidUrl
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-PUX4EJWH.js";
|
|
9
9
|
import "./chunk-CVECQ7BJ.js";
|
|
10
10
|
import {
|
|
11
11
|
registerStaticRoutes
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-BC23UV5D.js";
|
|
13
13
|
import "./chunk-67ROKQZG.js";
|
|
14
|
-
import "./chunk-
|
|
14
|
+
import "./chunk-Z5QIR3IS.js";
|
|
15
15
|
import "./chunk-PKBMQBKP.js";
|
|
16
16
|
|
|
17
17
|
// src/server/cli.ts
|
package/dist/server/index.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
2
|
mountInspector
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import "./chunk-
|
|
5
|
-
import "./chunk-
|
|
3
|
+
} from "./chunk-4OEEUHLZ.js";
|
|
4
|
+
import "./chunk-E4Y73JSU.js";
|
|
5
|
+
import "./chunk-PUX4EJWH.js";
|
|
6
6
|
import "./chunk-CVECQ7BJ.js";
|
|
7
|
-
import "./chunk-
|
|
7
|
+
import "./chunk-BC23UV5D.js";
|
|
8
8
|
import "./chunk-67ROKQZG.js";
|
|
9
9
|
import {
|
|
10
10
|
handleChatRequest,
|
|
11
11
|
handleChatRequestStream
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-Z5QIR3IS.js";
|
|
13
13
|
import "./chunk-PKBMQBKP.js";
|
|
14
14
|
export {
|
|
15
15
|
handleChatRequest,
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
mountInspector
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import "./chunk-
|
|
5
|
-
import "./chunk-
|
|
3
|
+
} from "./chunk-4OEEUHLZ.js";
|
|
4
|
+
import "./chunk-E4Y73JSU.js";
|
|
5
|
+
import "./chunk-PUX4EJWH.js";
|
|
6
6
|
import "./chunk-CVECQ7BJ.js";
|
|
7
|
-
import "./chunk-
|
|
7
|
+
import "./chunk-BC23UV5D.js";
|
|
8
8
|
import "./chunk-67ROKQZG.js";
|
|
9
|
-
import "./chunk-
|
|
9
|
+
import "./chunk-Z5QIR3IS.js";
|
|
10
10
|
import "./chunk-PKBMQBKP.js";
|
|
11
11
|
export {
|
|
12
12
|
mountInspector
|
package/dist/server/server.d.ts
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Start the MCP Inspector HTTP server and return its listening port and fetch handler.
|
|
3
|
+
*
|
|
4
|
+
* Starts the Hono app on an available port (prefers a CLI-specified port, otherwise 3001;
|
|
5
|
+
* in standalone/production mode it will fall back to 3002 if 3001 is unavailable),
|
|
6
|
+
* logs server status, and attempts to open the browser when not running in production.
|
|
7
|
+
* On unrecoverable startup failures (for example, requested ports unavailable), the process
|
|
8
|
+
* will exit with code 1.
|
|
9
|
+
*
|
|
10
|
+
* @returns An object containing the resolved `port` number and the application's `fetch` handler.
|
|
11
|
+
*/
|
|
1
12
|
declare function startServer(): Promise<{
|
|
2
13
|
port: number;
|
|
3
14
|
fetch: (request: Request, Env?: unknown, executionCtx?: import("hono").ExecutionContext) => Response | Promise<Response>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/server/server.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/server/server.ts"],"names":[],"mappings":"AAmBA;;;;;;;;;;GAUG;AACH,iBAAe,WAAW;;;GAkFzB;;;;AAOD,wBAA+B"}
|
package/dist/server/server.js
CHANGED
|
@@ -1,24 +1,23 @@
|
|
|
1
1
|
import {
|
|
2
2
|
registerInspectorRoutes
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-E4Y73JSU.js";
|
|
4
4
|
import {
|
|
5
|
-
isPortAvailable
|
|
6
|
-
|
|
5
|
+
isPortAvailable,
|
|
6
|
+
parsePortFromArgs
|
|
7
|
+
} from "./chunk-PUX4EJWH.js";
|
|
7
8
|
import "./chunk-CVECQ7BJ.js";
|
|
8
9
|
import {
|
|
9
10
|
registerStaticRoutesWithDevProxy
|
|
10
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-BC23UV5D.js";
|
|
11
12
|
import "./chunk-67ROKQZG.js";
|
|
12
|
-
import "./chunk-
|
|
13
|
+
import "./chunk-Z5QIR3IS.js";
|
|
13
14
|
import "./chunk-PKBMQBKP.js";
|
|
14
15
|
|
|
15
16
|
// src/server/server.ts
|
|
16
|
-
import { exec } from "child_process";
|
|
17
|
-
import { promisify } from "util";
|
|
18
17
|
import { serve } from "@hono/node-server";
|
|
19
18
|
import { Hono } from "hono";
|
|
20
19
|
import { cors } from "hono/cors";
|
|
21
|
-
|
|
20
|
+
import open from "open";
|
|
22
21
|
var app = new Hono();
|
|
23
22
|
app.use("*", cors());
|
|
24
23
|
registerInspectorRoutes(app);
|
|
@@ -26,9 +25,16 @@ registerStaticRoutesWithDevProxy(app);
|
|
|
26
25
|
async function startServer() {
|
|
27
26
|
try {
|
|
28
27
|
const isDev = process.env.NODE_ENV === "development" || process.env.VITE_DEV === "true";
|
|
29
|
-
|
|
28
|
+
const cliPort = parsePortFromArgs();
|
|
29
|
+
let port = cliPort ?? 3001;
|
|
30
30
|
const available = await isPortAvailable(port);
|
|
31
31
|
if (!available) {
|
|
32
|
+
if (cliPort !== null) {
|
|
33
|
+
console.error(
|
|
34
|
+
`\u274C Port ${port} is not available. Please stop the process using this port and try again.`
|
|
35
|
+
);
|
|
36
|
+
process.exit(1);
|
|
37
|
+
}
|
|
32
38
|
if (isDev) {
|
|
33
39
|
console.error(
|
|
34
40
|
`\u274C\u274C\u274C Port ${port} is not available (probably used by Vite dev server as fallback so you should stop port 3000). Please stop the process using this port and try again.`
|
|
@@ -65,9 +71,8 @@ async function startServer() {
|
|
|
65
71
|
}
|
|
66
72
|
if (process.env.NODE_ENV !== "production") {
|
|
67
73
|
try {
|
|
68
|
-
const command = process.platform === "win32" ? "start" : process.platform === "darwin" ? "open" : "xdg-open";
|
|
69
74
|
const url = isDev ? "http://localhost:3000" : `http://localhost:${port}`;
|
|
70
|
-
await
|
|
75
|
+
await open(url);
|
|
71
76
|
console.warn(`\u{1F310} Browser opened automatically`);
|
|
72
77
|
} catch {
|
|
73
78
|
const url = isDev ? "http://localhost:3000" : `http://localhost:${port}`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared-routes.d.ts","sourceRoot":"","sources":["../../src/server/shared-routes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAiBjC;;GAEG;AACH,wBAAgB,uBAAuB,CACrC,GAAG,EAAE,IAAI,EACT,MAAM,CAAC,EAAE;IAAE,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,
|
|
1
|
+
{"version":3,"file":"shared-routes.d.ts","sourceRoot":"","sources":["../../src/server/shared-routes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAiBjC;;GAEG;AACH,wBAAgB,uBAAuB,CACrC,GAAG,EAAE,IAAI,EACT,MAAM,CAAC,EAAE;IAAE,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,QAgiB5C"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
registerInspectorRoutes
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import "./chunk-
|
|
3
|
+
} from "./chunk-E4Y73JSU.js";
|
|
4
|
+
import "./chunk-PUX4EJWH.js";
|
|
5
5
|
import "./chunk-CVECQ7BJ.js";
|
|
6
|
-
import "./chunk-
|
|
6
|
+
import "./chunk-Z5QIR3IS.js";
|
|
7
7
|
import "./chunk-PKBMQBKP.js";
|
|
8
8
|
export {
|
|
9
9
|
registerInspectorRoutes
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import type { Hono } from "hono";
|
|
2
2
|
/**
|
|
3
|
-
* Register
|
|
3
|
+
* Register routes that serve the built inspector client, handle SPA entry routing, and provide a fallback when client files are missing.
|
|
4
|
+
*
|
|
5
|
+
* This registers asset serving under the inspector path, redirects the root path to `/inspector` while preserving query parameters, serves the SPA entry (`index.html`) for inspector routes, and installs a final catch-all that serves the SPA or a build-missing fallback page. If `clientDistPath` is not provided, the built client path is resolved automatically.
|
|
6
|
+
*
|
|
7
|
+
* @param clientDistPath - Optional path to the built inspector client directory; when omitted, the implementation resolves the default distribution path
|
|
4
8
|
*/
|
|
5
9
|
export declare function registerStaticRoutes(app: Hono, clientDistPath?: string): void;
|
|
6
10
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared-static.d.ts","sourceRoot":"","sources":["../../src/server/shared-static.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AASjC
|
|
1
|
+
{"version":3,"file":"shared-static.d.ts","sourceRoot":"","sources":["../../src/server/shared-static.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AASjC;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,IAAI,EAAE,cAAc,CAAC,EAAE,MAAM,QAwGtE;AAED;;GAEG;AACH,wBAAgB,gCAAgC,CAC9C,GAAG,EAAE,IAAI,EACT,cAAc,CAAC,EAAE,MAAM,QA+DxB"}
|