@arcgis/ai-components 5.2.0-next.37 → 5.2.0-next.39
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/cdn/{YRBANNQ5.js → 37Q23IS4.js} +1 -1
- package/dist/cdn/{WAVKMZA6.js → 3OH4DXSY.js} +1 -1
- package/dist/cdn/{5W7S2RS4.js → 3UEKINYC.js} +1 -1
- package/dist/cdn/{IGZWQJW7.js → 3Y5INO72.js} +1 -1
- package/dist/cdn/{DEAYZ3MK.js → 4G5XCUE5.js} +1 -1
- package/dist/cdn/{E7TMP4YV.js → 5SW5CPQT.js} +1 -1
- package/dist/cdn/{AMVOJNWN.js → 5VTVHDQ5.js} +1 -1
- package/dist/cdn/{YJ3QQXF6.js → 6G5DYYYU.js} +1 -1
- package/dist/cdn/{Q73PK7Q7.js → 6JX2ACRF.js} +1 -1
- package/dist/cdn/{5SBLS4NW.js → 7YIRK2E3.js} +1 -1
- package/dist/cdn/{CAECQD75.js → A4JLOAOH.js} +1 -1
- package/dist/cdn/{IXAKT6L3.js → AFKLWPPM.js} +1 -1
- package/dist/cdn/{ZS2TZ6BF.js → AOVJ34QE.js} +1 -1
- package/dist/cdn/{Q7TL5Q5N.js → APFZY4PI.js} +1 -1
- package/dist/cdn/{NOJYPREL.js → B7YAMTIH.js} +1 -1
- package/dist/cdn/{7IFCBXV7.js → BF2IYMM6.js} +1 -1
- package/dist/cdn/{X7GE26KU.js → BL273EGZ.js} +1 -1
- package/dist/cdn/{RMLXVQZ5.js → BMGQJYTE.js} +1 -1
- package/dist/cdn/{C7E7MJSR.js → BNJFXDJV.js} +1 -1
- package/dist/cdn/{IC5P5NYY.js → BST5ZU46.js} +1 -1
- package/dist/cdn/{O7TGCM5P.js → C7DSVDSP.js} +1 -1
- package/dist/cdn/{5ZZGKP7N.js → CEKOEHB3.js} +1 -1
- package/dist/cdn/{CIW3QMKV.js → D664PQPF.js} +1 -1
- package/dist/cdn/{JN744CAW.js → DMLRWHBA.js} +1 -1
- package/dist/cdn/{WDE3HN7K.js → E54QF5FR.js} +1 -1
- package/dist/cdn/{AFLQZIKS.js → EIPHHMWX.js} +31 -31
- package/dist/cdn/{KRE4U7V7.js → F3VYFN2Q.js} +1 -1
- package/dist/cdn/F5SUU35Z.js +2 -0
- package/dist/cdn/{YYY7HKYX.js → FNBXR5WD.js} +1 -1
- package/dist/cdn/{XVQJBUMY.js → FQ5XLE4I.js} +1 -1
- package/dist/cdn/{SMADRJ67.js → FY7YTXS4.js} +1 -1
- package/dist/cdn/{T537PKP4.js → FYZATVB3.js} +1 -1
- package/dist/cdn/{S27EJSLC.js → GPVY5GM6.js} +1 -1
- package/dist/cdn/{E2HENO3T.js → GYVSHAUI.js} +1 -1
- package/dist/cdn/{TSEQVE2H.js → HBUW4KGU.js} +1 -1
- package/dist/cdn/{4RZPOYZ7.js → HJG7QM2R.js} +1 -1
- package/dist/cdn/{FX7UOGHP.js → ICBIUFK7.js} +1 -1
- package/dist/cdn/{ZMSJQB65.js → IHP25JWI.js} +1 -1
- package/dist/cdn/{LEPJUN3X.js → J6A4AS7E.js} +1 -1
- package/dist/cdn/{KTK4HNL2.js → JEBRN3EU.js} +1 -1
- package/dist/cdn/{FWU6DFIB.js → JEL5M7FA.js} +1 -1
- package/dist/cdn/JMODFBN6.js +48 -0
- package/dist/cdn/{ZOSUDIJH.js → JVYPIWEU.js} +1 -1
- package/dist/cdn/{7RCQFLPP.js → LK7ZIQW6.js} +1 -1
- package/dist/cdn/LUY6V4TP.js +181 -0
- package/dist/cdn/{IB4WTK74.js → M2DEBF5S.js} +1 -1
- package/dist/cdn/M3MRIGDZ.js +2 -0
- package/dist/cdn/{O3F47IO5.js → MHMBHWYX.js} +1 -1
- package/dist/cdn/{L77BTGXY.js → MMRRNKWJ.js} +1 -1
- package/dist/cdn/{27NEUQN3.js → MS5EA2KY.js} +1 -1
- package/dist/cdn/{ZEYIBYSF.js → MWYBF3F3.js} +1 -1
- package/dist/cdn/{MAV3DW27.js → NAKAZDJ7.js} +1 -1
- package/dist/cdn/{4I4MCV7V.js → NEV6OZN3.js} +1 -1
- package/dist/cdn/{WH6QQK6N.js → OGMMYFHR.js} +1 -1
- package/dist/cdn/{23EQTPO3.js → OKVLGJAG.js} +1 -1
- package/dist/cdn/{JEIMRNYM.js → OYNIFMCJ.js} +1 -1
- package/dist/cdn/{LQ6R5YRN.js → PQ2DPOFM.js} +1 -1
- package/dist/cdn/PRN4OPLW.js +2 -0
- package/dist/cdn/RLEHNAIA.js +2 -0
- package/dist/cdn/SBP6WNDY.js +2 -0
- package/dist/cdn/{TNMXWUXU.js → SDWWUWAF.js} +1 -1
- package/dist/cdn/{M3SWPT3M.js → SJR4IR57.js} +1 -1
- package/dist/cdn/{HBYZSLEZ.js → SKXDXIQO.js} +1 -1
- package/dist/cdn/{PSWI3MFB.js → SPVOBZAL.js} +1 -1
- package/dist/cdn/SYEI4BB2.js +56 -0
- package/dist/cdn/TI7K3I3K.js +18 -0
- package/dist/cdn/{W2IHPJ54.js → TPULIO6I.js} +1 -1
- package/dist/cdn/{6YMR4QSD.js → UHEYPSOR.js} +1 -1
- package/dist/cdn/{HOCTVCHH.js → UK7PR2FE.js} +1 -1
- package/dist/cdn/UZLQALHY.js +2 -0
- package/dist/cdn/{W2JAKE2M.js → V6HOUZPZ.js} +1 -1
- package/dist/cdn/{3AXQTBIA.js → VAXH6RUQ.js} +1 -1
- package/dist/cdn/{WNS5ZUF5.js → VXFQANGJ.js} +1 -1
- package/dist/cdn/{RX45PCYB.js → WSGWTIAV.js} +1 -1
- package/dist/cdn/{HXOSLGWU.js → XFL2VQFM.js} +1 -1
- package/dist/cdn/{2NMR43NW.js → XNWCRFTJ.js} +1 -1
- package/dist/cdn/{ZPLFFLPF.js → YYSMCB4A.js} +1 -1
- package/dist/cdn/{I64KIZG3.js → ZB57WYHC.js} +1 -1
- package/dist/cdn/ZQ7PGNWB.js +208 -0
- package/dist/cdn/{ZTBA5PM7.js → ZU2FHVNK.js} +1 -1
- package/dist/cdn/agent-utils/index.js +1 -1
- package/dist/cdn/agent-utils/middlewares/humanInTheLoop.js +1 -1
- package/dist/cdn/agent-utils/middlewares/middleware.js +1 -1
- package/dist/cdn/agent-utils/middlewares/trace.js +1 -1
- package/dist/cdn/index.js +1 -1
- package/dist/docs/api.json +1 -1
- package/dist/docs/docs.json +1 -1
- package/dist/docs/web-types.json +1 -1
- package/package.json +9 -9
- package/dist/cdn/6LZ6GOHF.js +0 -56
- package/dist/cdn/CJIV4KJZ.js +0 -179
- package/dist/cdn/CVHJMR5X.js +0 -2
- package/dist/cdn/EBRNMPPO.js +0 -48
- package/dist/cdn/IKEF7ZHH.js +0 -181
- package/dist/cdn/LODKJRS4.js +0 -2
- package/dist/cdn/NXKKG5TK.js +0 -2
- package/dist/cdn/PKHQW7QU.js +0 -18
- package/dist/cdn/QSA4T3BU.js +0 -2
- package/dist/cdn/VKU4WAQV.js +0 -2
- package/dist/cdn/YIMNOUTF.js +0 -2
- /package/dist/cdn/{ADYIXCSG.js → R74ZHFA6.js} +0 -0
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
+
import{J as qe,Ka as te,La as nt,Na as W,Oa as Et,Ra as Ie,S as xt,Ta as ge,U as tt,Ua as Oe,Va as At,Z as St,a as ut,b as A,f as $,j as L,k as H,qa as Ae,ta as kt,x as mt,y as ft}from"./ZQ7PGNWB.js";import{$a as gt,$b as he,Ab as bt,I as Ge,Ib as F,Jb as le,Lb as vt,Ob as Se,Qb as Ct,Tb as a,U as T,Ua as Ke,Vb as Qe,Xa as z,Xb as ke,Ya as ie,Z as pt,_a as Ye,ac as K,bb as Xe,c as Je,ca as M,db as wt,dc as ce,fa as Ve,fc as Ee,oa as Q,ob as pe,pb as _e,sa as Ze,sb as xe,sc as et,ta as U,uc as _t,wb as Mt,yb as Tt,yc as ot,za as ht,zb as ee}from"./LUY6V4TP.js";import{Dd as B,s as yt}from"./MWYBF3F3.js";var rt=Symbol.for("AgentMiddleware");function O(e){return{[rt]:!0,name:e.name,stateSchema:e.stateSchema,contextSchema:e.contextSchema,wrapToolCall:e.wrapToolCall,wrapModelCall:e.wrapModelCall,beforeAgent:e.beforeAgent,beforeModel:e.beforeModel,afterModel:e.afterModel,afterAgent:e.afterAgent,tools:e.tools,streamTransformers:e.streamTransformers}}var Re=class extends Error{constructor(){super("The provided LLM already has bound tools. Please provide an LLM without bound tools to createAgent. The agent will bind the tools provided in the 'tools' parameter.")}},Pe=class extends Error{toolNames;constructor(e){super(`The model has called multiple tools: ${e.join(", ")} to return a structured output. This is not supported. Please provide a single structured output.`),this.toolNames=e}},we=class extends Error{toolName;errors;constructor(e,t){super(`Failed to parse structured output for tool '${e}':${t.map(o=>`
|
|
3
|
+
- ${o}`).join("")}.`),this.toolName=e,this.errors=t}},je=class extends Error{toolCall;toolError;constructor(e,t){let o=e instanceof Error?e:new Error(String(e)),n=JSON.stringify(t.args);super(`Error invoking tool '${t.name}' with kwargs ${n} with error: ${o.stack}
|
|
4
|
+
Please fix the error and try again.`),this.toolCall=t,this.toolError=o}},ye=class It extends Error{static"~brand"="MiddlewareError";constructor(t,o){let n=t instanceof Error?t.message:String(t);super(n),this.name=t instanceof Error?t.name:`${o[0].toUpperCase()+o.slice(1)}Error`,t instanceof Error&&(this.cause=t)}static wrap(t,o){return mt(t)?t:new It(t,o)}static isInstance(t){return t instanceof Error&&"~brand"in t&&t["~brand"]==="MiddlewareError"}};function Me(e){return"invoke"in e&&typeof e.invoke=="function"&&"_streamResponseChunks"in e}function de(e){return typeof e=="object"&&e!=null&&"_queuedMethodOperations"in e&&"_getModelInstance"in e&&typeof e._getModelInstance=="function"}var Ot=!0,ho=0,G=class st{constructor(t,o,n){this.schema=t,this.tool=o,this.options=n}get name(){return this.tool.function.name}static fromSchema(t,o){function n(s){return s??`extract-${++ho}`}if(pe(t)||xe(t)){let s=ke(t);return new st(s,{type:"function",function:{name:n(s.title),strict:!1,description:s.description??"Tool for extracting structured output from the model's response.",parameters:s}},o)}let r;return typeof t.name=="string"&&typeof t.parameters=="object"&&t.parameters!=null?r=t:r={name:n(t.title),description:t.description??"",parameters:t.schema||t},new st(ke(t),{type:"function",function:r},o)}parse(t){let o=new Qe(this.schema).validate(t);if(!o.valid)throw new we(this.name,o.errors.map(n=>n.error));return t}},oe=class Rt{_schemaType;schema;strict;constructor(t,o){if("schema"in t&&typeof t.schema=="object"&&t.schema!==null&&!("type"in t)){let n=t;this.schema=n.schema,this.strict=n.strict??Ot}else this.schema=t,this.strict=o??Ot}static fromSchema(t,o){return new Rt(ke(t),o)}parse(t){let o;if(typeof t.content=="string")o=t.content;else if(Array.isArray(t.content)){for(let n of t.content)if(typeof n=="object"&&n!==null&&"type"in n&&n.type==="text"&&"text"in n&&typeof n.text=="string"){o=n.text;break}}if(!(!o||o===""))try{let n=JSON.parse(o);return new Qe(this.schema).validate(n).valid?n:void 0}catch{}}};function Pt(e,t,o){if(!e)return[];if(typeof e=="object"&&e!==null&&"__responseFormatUndefined"in e)return[];if(Array.isArray(e)){if(e.every(r=>r instanceof G||r instanceof oe))return e;if(e.every(r=>pe(r)))return e.map(r=>G.fromSchema(r,t));if(e.every(r=>F(r)))return e.map(r=>G.fromSchema(r,t));if(e.every(r=>typeof r=="object"&&r!==null&&!F(r)&&!pe(r)))return e.map(r=>G.fromSchema(r,t));throw new Error(`Invalid response format: list contains mixed types.
|
|
5
|
+
All items must be either InteropZodObject, Standard Schema, or plain JSON schema objects.`)}if(e instanceof G||e instanceof oe)return[e];let n=go(o);if(pe(e))return n?[oe.fromSchema(e)]:[G.fromSchema(e,t)];if(F(e))return n?[oe.fromSchema(e)]:[G.fromSchema(e,t)];if(typeof e=="object"&&e!==null&&"properties"in e)return n?[oe.fromSchema(e)]:[G.fromSchema(e,t)];throw new Error(`Invalid response format: ${String(e)}`)}function go(e){return!e||!Me(e)||!("profile"in e)||typeof e.profile!="object"||!e.profile?!1:"structuredOutput"in e.profile&&e.profile.structuredOutput===!0}function wo(e,t){if(e.length<t.length||e.length>t.length+1)return!1;for(let o=0;o<t.length;o+=1)if(e[o]!==t[o])return!1;return!0}function yo(e){let t;try{t=JSON.parse(e)}catch{return!1}return!Array.isArray(t)||t.length===0?!1:t.every(o=>{if(o==null||typeof o!="object")return!1;let n=o;return typeof n.id=="string"&&"value"in n})}function Mo(e){if(e==null||typeof e!="object")return!1;let t=e;return t.type!=="constructor"||!Array.isArray(t.id)?!1:t.id[t.id.length-1]==="ToolMessage"}function To(e){return T.isInstance(e)?e.content:Mo(e)?e.kwargs?.content:e}function Te(e){return()=>{let t=Ae.local(),o=new Map;function n(r,s,i){if(o.has(r))return;let l=typeof i=="string"?JSON.parse(i):i,m,c,u,g,d=new Promise((x,y)=>{m=x,c=y}),f=new Promise(x=>{u=x}),h=new Promise(x=>{g=x});o.set(r,{resolveOutput:m,rejectOutput:c,resolveStatus:u,resolveError:g}),t.push({name:s,callId:r,input:l,output:d,status:f,error:h})}return{__native:!0,init:()=>({toolCalls:t}),process(r){if(!wo(r.params.namespace,e))return!0;if(r.method==="messages"){let s=r.params.data;if(s.event==="content-block-finish"){let i=s.contentBlock??s.content_block;i?.type==="tool_call"&&n(String(i.id??""),String(i.name??""),i.args??i.input)}}if(r.method==="tools"){let s=r.params.data,i=s.tool_call_id;s.event==="tool-started"&&n(i,s.tool_name??"unknown",s.input);let l=i?o.get(i):void 0;if(l){if(s.event==="tool-finished")l.resolveOutput(To(s.output)),l.resolveStatus("finished"),l.resolveError(void 0),o.delete(i);else if(s.event==="tool-error"){let m=s.message??"unknown error";if(yo(m))return!0;l.rejectOutput(new Error(m)),l.resolveStatus("error"),l.resolveError(m),o.delete(i)}}}return!0},finalize(){for(let r of o.values())r.resolveStatus("finished"),r.resolveError(void 0),r.resolveOutput(void 0);o.clear(),t.close()},fail(r){for(let s of o.values())s.resolveStatus("error"),s.resolveError(r instanceof Error?r.message:String(r)),s.rejectOutput(r);o.clear(),t.fail(r)}}}}function Y(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function be(e){return e.join("\0")}function jt(e,t){if(t.length>e.length)return!1;for(let o=0;o<t.length;o+=1)if(e[o]!==t[o])return!1;return!0}function Ne(e=[]){return()=>{let t=Ae.local(),o=new Map,n=new Map,r=new Map,s=new Map,i=e.length;function l(d,f){let h=be(d);if(o.has(h))return;let x=(Y(f)&&Y(f.metadata)?f.metadata:void 0)?.lc_agent_name;o.set(h,typeof x=="string"?x:void 0)}function m(d){if(!Y(d))return;let f=d.id;if(typeof f!="string")return;let h=d.input,x;if(Y(h)&&Y(h.tool_call)){let y=h.tool_call.id;typeof y=="string"&&(x=y)}else if(Array.isArray(h)){for(let y of h)if(Y(y)&&typeof y.id=="string"){x=y.id;break}}x!=null&&n.set(f,x)}function c(d){let f=r.get(be(d));if(typeof f=="string"&&f.length>0)return{type:"toolCall",tool_call_id:f};let h=d[d.length-1],x=h.indexOf(":");if(x===-1)return;let y=h.slice(x+1);if(y.length===0)return;let w=n.get(y);if(!(typeof w!="string"||w.length===0))return{type:"toolCall",tool_call_id:w}}function u(d){if(d.length!==i+1||!jt(d,e))return;let f=be(d);if(s.has(f))return;let h=o.get(f);if(typeof h!="string"||h.length===0)return;let x=kt(d),y=x.init(),w=Te(d)(),P=w.init(),I=Ne(d)(),j=I.init(),Z,N,b=new Promise((J,ae)=>{Z=J,N=ae});s.set(f,{key:f,path:d,name:h,messages:x,toolCall:w,nested:I,resolveOutput:Z,rejectOutput:N,latestValues:void 0,done:!1}),t.push({name:h,cause:c(d),output:b,messages:y.messages,toolCalls:P.toolCalls,subagents:j.subagents})}function g(d,f){d.done||(d.done=!0,f.type==="resolve"?d.resolveOutput(d.latestValues):d.rejectOutput(f.error),d.messages.finalize?.(),d.toolCall.finalize?.(),d.nested.finalize?.())}return{__native:!0,init:()=>({subagents:t}),process(d){let f=d.params.namespace,h=d.params.data,x=d.method==="tasks"&&Y(h)&&"result"in h;d.method==="tools"&&Y(h)&&h.event==="tool-started"&&typeof h.tool_call_id=="string"&&h.tool_call_id.length>0&&r.set(be(f),h.tool_call_id),d.method==="tasks"&&!x&&(l(f,h),m(h),u(f));for(let y of s.values())if(!y.done&&jt(f,y.path)&&(y.messages.process(d),y.toolCall.process(d),y.nested.process(d),be(f)===y.key)){if(d.method==="values"&&Y(h))y.latestValues=h;else if(d.method==="lifecycle"&&Y(h)){let w=h.event;w==="completed"||w==="interrupted"?g(y,{type:"resolve"}):w==="failed"&&g(y,{type:"reject",error:new Error(`Subagent ${y.name} failed`)})}}return!0},finalize(){for(let d of s.values())g(d,{type:"resolve"});t.close()},fail(d){for(let f of s.values())g(f,{type:"reject",error:d});t.fail(d)}}}}var at=Symbol.for("langgraph-zod");at in globalThis||(globalThis[at]=new WeakSet);function Nt(e){let t=globalThis[at];t.has(e)||(Object.defineProperty(e,"langgraph",{get(){let o=this;return{metadata(n){return Oe(o,{jsonSchemaExtra:n})},reducer(n,r){return Oe(o,{default:Se(o),reducer:{schema:r,fn:n}})}}}}),t.add(e))}try{Nt(a.ZodType.prototype),Nt(B.ZodType.prototype)}catch(e){throw new Error("Failed to extend Zod with LangGraph-related methods. This is most likely a bug, consider opening an issue and/or using `withLangGraph` to augment your Zod schema.",{cause:e})}var Lt=class extends yt{constructor(e){super(),this.parent=e,this._map=this.parent._map}add(e,...t){let o=t[0];if(o&&!o?.default){let n=Se(e);n!=null&&(o.default=n)}return super.add(e,...t)}},bo=new Lt(ge);function Dt(e=!0,t,o=[]){let n={jumpTo:new nt},r={},s={},i=l=>{if(W.isInstance(l)){for(let[c,u]of Object.entries(l.fields))if(!(c in n)){if(n[c]=u,c.startsWith("_"))continue;te.isInstance(u)?(r[c]=u.inputSchema||u.valueSchema,s[c]=u.valueSchema):(r[c]=u,s[c]=u)}return}let m=le(l);for(let[c,u]of Object.entries(m)){let g=c.startsWith("_");if(!(c in n)){if(_e(u)){let d=ge.get(u);if(d?.reducer){d.reducer.schema?(n[c]=new te(u,{inputSchema:d.reducer.schema,reducer:d.reducer.fn}),g||(r[c]=d.reducer.schema,s[c]=u)):(n[c]=new te(u,{reducer:d.reducer.fn}),g||(r[c]=u,s[c]=u));continue}}n[c]=u,g||(r[c]=u,s[c]=u)}}};t&&(W.isInstance(t)||F(t))&&i(t);for(let l of o)l.stateSchema&&(W.isInstance(l.stateSchema)||F(l.stateSchema))&&i(l.stateSchema);return e&&(s.structuredResponse=new nt),{state:new W({messages:Ie,...n}),input:new W({messages:Ie,...r}),output:new W({messages:Ie,...s})}}var it=/<name>(.*?)<\/name>/s,lt=/<content>(.*?)<\/content>/s;function vo(e,t){if(W.isInstance(e)){let o={};for(let n of Object.keys(e.fields))n in t&&(o[n]=t[n]);return o}if(xe(e))return ee(e,t);throw new Error(`Invalid state schema type: ${typeof e}`)}function Bt(e){if(!M.isInstance(e)||Ve.isInstance(e)||!e.name)return e;let{name:t}=e;if(typeof e.content=="string")return new M({...e.lc_kwargs,content:`<name>${t}</name><content>${e.content}</content>`,name:void 0});let o=[],n=0;for(let r of e.content)typeof r=="string"?(n+=1,o.push(`<name>${t}</name><content>${r}</content>`)):typeof r=="object"&&"type"in r&&r.type==="text"?(n+=1,o.push({...r,text:`<name>${t}</name><content>${r.text}</content>`})):o.push(r);return n||o.unshift({type:"text",text:`<name>${t}</name><content></content>`}),new M({...e.lc_kwargs,content:o,name:void 0})}function Ut(e){if(!M.isInstance(e)||!e.content)return e;let t=[],o;if(Array.isArray(e.content))t=e.content.filter(n=>{if(n.type==="text"&&typeof n.text=="string"){let r=n.text.match(it),s=n.text.match(lt);return r&&(!s||s[1]==="")?(o=r[1],!1):!0}return!0}).map(n=>{if(n.type==="text"&&typeof n.text=="string"){let r=n.text.match(it),s=n.text.match(lt);return!r||!s?n:(o=r[1],{...n,text:s[1]})}return n});else{let n=e.content,r=n.match(it),s=n.match(lt);if(!r||!s)return e;o=r[1],t=s[1]}return new M({...Object.keys(e.lc_kwargs??{}).length>0?e.lc_kwargs:e,content:t,name:o})}function se(e){return he.isRunnable(e)}function $t(e){return Me(e)?"bindTools"in e&&typeof e.bindTools=="function":!1}var ct=(e,t,o={})=>{if($t(e))return e.bindTools(t,o);if(K.isRunnableBinding(e)&&$t(e.bound)){let n=e.bound.bindTools(t,o);return K.isRunnableBinding(n)?new K({bound:n.bound,config:{...e.config,...n.config},kwargs:{...e.kwargs,...n.kwargs},configFactories:n.configFactories??e.configFactories}):new K({bound:n,config:e.config,kwargs:e.kwargs,configFactories:e.configFactories})}return null};function Le(e){if(typeof e=="function")return;let t=e;if(ce.isRunnableSequence(t)&&(t=t.steps.find(o=>K.isRunnableBinding(o))||t),!de(t)){if(K.isRunnableBinding(t)){let o=t.kwargs!=null&&typeof t.kwargs=="object"&&"tools"in t.kwargs&&Array.isArray(t.kwargs.tools)&&t.kwargs.tools.length>0,n=t.config!=null&&typeof t.config=="object"&&"tools"in t.config&&Array.isArray(t.config.tools)&&t.config.tools.length>0;if(o||n)throw new Re}if("tools"in t&&t.tools!==void 0&&Array.isArray(t.tools)&&t.tools.length>0)throw new Re}}function ue(e){return!!(M.isInstance(e)&&e.tool_calls&&e.tool_calls.length>0)}function zt(e){if(e==null)return new U("");if(U.isInstance(e))return e;if(typeof e=="string")return new U({content:[{type:"text",text:e}]});throw new Error(`Invalid systemPrompt type: expected string or SystemMessage, got ${typeof e}`)}async function Ft(e,t,o={}){let n=ct(e,t,o);if(n)return n;if(de(e)){let r=ct(await e._getModelInstance(),t,o);if(r)return r}if(ce.isRunnableSequence(e)){let r=e.steps.findIndex(s=>K.isRunnableBinding(s)||Me(s)||de(s));if(r>=0){let s=ct(e.steps[r],t,o);if(s){let i=e.steps.slice();return i.splice(r,1,s),ce.from(i)}}}throw new Error(`llm ${e} must define bindTools method.`)}function Co(e){if(e.length===0)return;if(e.length===1)return e[0];function t(n,r){return async(s,i)=>n(s,async m=>r(m,i))}let o=e[e.length-1];for(let n=e.length-2;n>=0;n--)o=t(e[n],o);return o}function Wt(e){let t=e.filter(o=>o.wrapToolCall);if(t.length!==0)return Co(t.map(o=>{let n=o.wrapToolCall;return async(s,i)=>{let l=s.state,m=async c=>{let u={...l,...c.state};return i({...c,state:u})};try{let c=await n({...s,state:{messages:l.messages,...o.stateSchema?vo(o.stateSchema,{...l}):{}}},m);if(!T.isInstance(c)&&!H(c))throw new Error(`Invalid response from "wrapToolCall" in middleware "${o.name}": expected ToolMessage or Command, got ${typeof c}`);return c}catch(c){throw ye.wrap(c,o.name)}}}))}var _o=["tags","metadata","runName","maxConcurrency","recursionLimit","configurable"];function Ht(e){let t={};for(let o of _o){let n=e[o];n!==void 0&&(t[o]=n)}return t}async function Jt(e,t){let o={};for(let n of e){if(!n.stateSchema)continue;let r;if(W.isInstance(n.stateSchema)){let l={};for(let[m,c]of Object.entries(n.stateSchema.fields))te.isInstance(c)?l[m]=c.inputSchema||c.valueSchema:l[m]=c;r=B.object(l)}else if(F(n.stateSchema))r=n.stateSchema;else continue;let s=await Mt(Ct(r,l=>l.startsWith("_")),t);if(s.success){Object.assign(o,s.data);continue}let i=s.error.issues.filter(l=>l.code==="invalid_type").map(l=>` - ${l.path.join(".")}: Required`).join(`
|
|
6
|
+
`);throw new Error(`Middleware "${n.name}" has required state fields that must be initialized:
|
|
7
|
+
${i}
|
|
8
|
+
|
|
9
|
+
To fix this, either:
|
|
10
|
+
1. Provide default values in your middleware's state schema using .default():
|
|
11
|
+
stateSchema: z.object({
|
|
12
|
+
myField: z.string().default("default value")
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
2. Or make the fields optional using .optional():
|
|
16
|
+
stateSchema: z.object({
|
|
17
|
+
myField: z.string().optional()
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
3. Or ensure you pass these values when invoking the agent:
|
|
21
|
+
agent.invoke({
|
|
22
|
+
messages: [...],
|
|
23
|
+
${s.error.issues[0]?.path.join(".")}: "value"
|
|
24
|
+
})`)}return o}function Gt(e){let t={messages:B.custom(()=>[]),structuredResponse:B.any().optional()};if(!e)return B.object(t);let o;if(W.isInstance(e)){o={};for(let[r,s]of Object.entries(e.fields))te.isInstance(s)?o[r]=s.inputSchema||s.valueSchema:o[r]=s}else if(F(e))o=le(e);else return B.object(t);let n={...t};for(let[r,s]of Object.entries(o))r.startsWith("_")?n[r]=s.optional():n[r]=s;return B.object(n)}function Vt(e){if(F(e))return vt(e);if(W.isInstance(e)){let t={};for(let[o,n]of Object.entries(e.fields)){let r;te.isInstance(n)?r=n.inputSchema||n.valueSchema:r=n,t[o]=_e(r)?r.optional():B.any().optional()}return B.object(t)}return B.object({})}function V(e){if(e){if(["model_request","tools",A].includes(e))return e;if(e==="model")return"model_request";if(e==="tools")return"tools";if(e==="end")return A;throw new Error(`Invalid jump target: ${e}, must be "model", "tools" or "end".`)}}function De(...e){return AbortSignal.any(e.filter(t=>t!=null&&typeof t=="object"&&"aborted"in t&&typeof t.aborted=="boolean"))}var Be={openai:{package:"@langchain/openai",className:"ChatOpenAI"},anthropic:{package:"@langchain/anthropic",className:"ChatAnthropic"},azure_openai:{package:"@langchain/openai",className:"AzureChatOpenAI"},cohere:{package:"@langchain/cohere",className:"ChatCohere"},google:{package:"@langchain/google",className:"ChatGoogle"},"google-vertexai":{package:"@langchain/google-vertexai",className:"ChatVertexAI"},"google-vertexai-web":{package:"@langchain/google-vertexai-web",className:"ChatVertexAI"},"google-genai":{package:"@langchain/google-genai",className:"ChatGoogleGenerativeAI"},ollama:{package:"@langchain/ollama",className:"ChatOllama"},mistralai:{package:"@langchain/mistralai",className:"ChatMistralAI"},mistral:{package:"@langchain/mistralai",className:"ChatMistralAI"},groq:{package:"@langchain/groq",className:"ChatGroq"},bedrock:{package:"@langchain/aws",className:"ChatBedrockConverse"},aws:{package:"@langchain/aws",className:"ChatBedrockConverse"},deepseek:{package:"@langchain/deepseek",className:"ChatDeepSeek"},xai:{package:"@langchain/xai",className:"ChatXAI"},cerebras:{package:"@langchain/cerebras",className:"ChatCerebras"},fireworks:{package:"@langchain/fireworks",className:"ChatFireworks"},together:{package:"@langchain/together-ai",className:"ChatTogetherAI",hasCircularDependency:!0},perplexity:{package:"@langchain/perplexity",className:"ChatPerplexity"}},Kt=Object.keys(Be);async function So(e,t){let o;if(t)o=Be[t];else{let n=Object.entries(Be).find(([,r])=>r.className===e);o=n?n[1]:void 0}if(o)try{return(await import(o.package))[o.className]}catch(n){let r=n;if("code"in r&&r.code?.toString().includes("ERR_MODULE_NOT_FOUND")&&"message"in r&&typeof r.message=="string"){let s=(r.message.startsWith("Error: ")?r.message.slice(7):r.message).split("Cannot find package '")[1].split("'")[0];throw new Error(`Unable to import ${s}. Please install with \`npm install ${s}\` or \`pnpm install ${s}\``)}throw n}}async function ko(e,t,o={}){let n=t||Eo(e);if(!n)throw new Error(`Unable to infer model provider for { model: ${e} }, please specify modelProvider directly.`);let r=Be[n];if(!r){let l=Kt.join(", ");throw new Error(`Unsupported { modelProvider: ${n} }.
|
|
25
|
+
|
|
26
|
+
Supported model providers are: ${l}`)}let{modelProvider:s,...i}=o;return new(await So(r.className,n))({model:e,...i})}function Eo(e){return e.startsWith("gpt-3")||e.startsWith("gpt-4")||e.startsWith("gpt-5")||e.startsWith("o1")||e.startsWith("o3")||e.startsWith("o4")?"openai":e.startsWith("claude")?"anthropic":e.startsWith("command")?"cohere":e.startsWith("accounts/fireworks")?"fireworks":e.startsWith("gemini")?"google-vertexai":e.startsWith("amazon.")?"bedrock":e.startsWith("mistral")?"mistralai":e.startsWith("sonar")||e.startsWith("pplx")?"perplexity":void 0}var Zt=class $e extends tt{_llmType(){return"chat_model"}lc_namespace=["langchain","chat_models"];_defaultConfig={};_configurableFields="any";_configPrefix;_queuedMethodOperations={};_modelInstanceCache=new Map;_profile;constructor(t){super(t),this._defaultConfig=t.defaultConfig??{},t.configurableFields==="any"?this._configurableFields="any":this._configurableFields=t.configurableFields??["model","modelProvider"],t.configPrefix?this._configPrefix=t.configPrefix.endsWith("_")?t.configPrefix:`${t.configPrefix}_`:this._configPrefix="",this._queuedMethodOperations=t.queuedMethodOperations??this._queuedMethodOperations,this._profile=t.profile??void 0,this.metadata={...this.metadata,ls_integration:"langchain_init_chat_model"}}async _getModelInstance(t){let o=this._getCacheKey(t),n=this._modelInstanceCache.get(o);if(n)return n;let r={...this._defaultConfig,...this._modelParams(t)},s=await ko(r.model,r.modelProvider,r);for(let[i,l]of Object.entries(this._queuedMethodOperations))i in s&&typeof s[i]=="function"&&(s=await s[i](...l));return this._modelInstanceCache.set(o,s),s}async _generate(t,o,n){return(await this._getModelInstance(o))._generate(t,o??{},n)}bindTools(t,o){let n={...this._queuedMethodOperations};return n.bindTools=[t,o],new $e({defaultConfig:this._defaultConfig,configurableFields:this._configurableFields,configPrefix:this._configPrefix,queuedMethodOperations:n})}withStructuredOutput=(t,...o)=>{let n={...this._queuedMethodOperations};return n.withStructuredOutput=[t,...o],new $e({defaultConfig:this._defaultConfig,configurableFields:this._configurableFields,configPrefix:this._configPrefix,queuedMethodOperations:n})};_modelParams(t){let o=t?.configurable??{},n={};for(let[r,s]of Object.entries(o))if(r.startsWith(this._configPrefix)){let i=this._removePrefix(r,this._configPrefix);n[i]=s}return this._configurableFields!=="any"&&(n=Object.fromEntries(Object.entries(n).filter(([r])=>this._configurableFields.includes(r)))),n}_removePrefix(t,o){return t.startsWith(o)?t.slice(o.length):t}withConfig(t){let o={...t||{}},n=this._modelParams(o),r=Object.fromEntries(Object.entries(o).filter(([s])=>s!=="configurable"));return r.configurable=Object.fromEntries(Object.entries(o.configurable||{}).filter(([s])=>this._configPrefix&&!Object.keys(n).includes(this._removePrefix(s,this._configPrefix)))),new K({config:o,bound:new $e({defaultConfig:{...this._defaultConfig,...n},configurableFields:Array.isArray(this._configurableFields)?[...this._configurableFields]:this._configurableFields,configPrefix:this._configPrefix,queuedMethodOperations:this._queuedMethodOperations})})}async invoke(t,o){let n=await this._getModelInstance(o),r=ie(o);return n.invoke(t,r)}async stream(t,o){let n=new wt({generator:await(await this._getModelInstance(o)).stream(t,o),config:o});return await n.setup,Xe.fromAsyncGenerator(n)}async batch(t,o,n){return super.batch(t,o,n)}async*transform(t,o){let n=await this._getModelInstance(o),r=ie(o);yield*n.transform(t,r)}async*streamLog(t,o,n){let r=await this._getModelInstance(o),s=ie(o);yield*r.streamLog(t,s,{...n,_schemaFormat:"original",includeNames:n?.includeNames,includeTypes:n?.includeTypes,includeTags:n?.includeTags,excludeNames:n?.excludeNames,excludeTypes:n?.excludeTypes,excludeTags:n?.excludeTags})}streamEvents(t,o,n){if(o?.version==="v1"||o?.version==="v2"){let i=this,l=o;async function*m(){let c=await i._getModelInstance(l),u={...ie(l),version:l.version,...l.encoding!==void 0?{encoding:l.encoding}:{}},g;l.version==="v1"&&l.encoding==="text/event-stream"||l.version==="v1"||l.version==="v2"&&l.encoding,g=c.streamEvents(t,u,n);for await(let d of g)yield d}return Xe.fromAsyncGenerator(m())}let r=this;async function*s(){let i=await r._getModelInstance(o),l=ie(o);yield*i.streamEvents(t,l)}return new xt(s())}get profile(){if(this._profile)return this._profile;let t=this._getCacheKey({});return this._modelInstanceCache.get(t)?.profile??{}}_getCacheKey(t){let o=t??{};if(o.configurable){let{configurable:n}=o,r={};for(let[s,i]of Object.entries(n))s.startsWith("__pregel_")||(r[s]=i);o={...o,configurable:r}}return JSON.stringify(o)}};async function q(e,t){let{configurableFields:o,configPrefix:n,modelProvider:r,profile:s,...i}={configPrefix:"",...t??{}};if(r===void 0&&e?.includes(":")){let[u,...g]=e.split(":"),d=g.length===0?[u]:[u,g.join(":")];Kt.includes(d[0])&&([r,e]=d)}let l=Array.isArray(o)?[...o]:o;!e&&l===void 0&&(l=["model","modelProvider"]),n&&l===void 0&&console.warn(`{ configPrefix: ${n} } has been set but no fields are configurable. Set { configurableFields: [...] } to specify the model params that are configurable.`);let m={...i},c;return l===void 0?c=new Zt({defaultConfig:{...m,model:e,modelProvider:r},configPrefix:n,profile:s}):(e&&(m.model=e),r&&(m.modelProvider=r),c=new Zt({defaultConfig:m,configPrefix:n,configurableFields:l,profile:s})),await c._getModelInstance(),c}var me=class extends he{lc_namespace=["langgraph"];func;tags;config;trace=!0;recurse=!0;#e;constructor(e){super(),this.name=e.name??e.func.name,this.func=e.func,this.config=e.tags?{tags:e.tags}:void 0,this.recurse=e.recurse??this.recurse}getState(){return this.#e}setState(e){this.#e={...this.#e,...e}}async invoke(e,t){let o=z(this.config,t),n=await Ke.runWithConfig(o,async()=>this.func(e,o));return he.isRunnable(n)&&this.recurse?await Ke.runWithConfig(o,async()=>n.invoke(e,o)):(this.#e=n,n)}};function Yt(e,t){let o,n;if(t==="inline")o=Bt,n=Ut;else throw new Error(`Invalid agent name mode: ${t}. Needs to be one of: "inline"`);function r(s){return s.map(o)}return ce.from([Ee.from(r),e,Ee.from(n)])}function Ao(e){return M.isInstance(e)||H(e)||typeof e=="object"&&e!==null&&"structuredResponse"in e&&"messages"in e}var R="model_request",Xt=class extends me{#e;#o;constructor(e){super({name:e.name??"model",func:(t,o)=>this.#t(t,o)}),this.#e=e,this.#o=e.systemMessage}async#r(e,t=this.#e.responseFormat){if(!t)return;let o;de(e)?o=await e._getModelInstance():typeof e!="string"&&(o=e);let n=Pt(t,void 0,o);if(n.length!==0)return n.every(r=>r instanceof oe)?{type:"native",strategy:n[0]}:{type:"tool",tools:n.filter(r=>r instanceof G).reduce((r,s)=>(r[s.name]=s,r),{})}}async#t(e,t){let o=e.messages.at(-1);if(o&&T.isInstance(o)&&o.name&&this.#e.shouldReturnDirect.has(o.name))return[new L({update:{messages:[]}})];let{response:n,lastAiMessage:r,collectedCommands:s}=await this.#a(e,t);if(typeof n=="object"&&n!==null&&"structuredResponse"in n&&"messages"in n){let{structuredResponse:m,messages:c}=n;return{messages:[...e.messages,...c],structuredResponse:m}}let i=[],l=M.isInstance(n)?n:r;return l&&(l.name=this.name,l.lc_kwargs.name=this.name,this.#c(e,l)?i.push(new L({update:{messages:[new M({content:"Sorry, need more steps to process this request.",name:this.name,id:l.id})]}})):i.push(new L({update:{messages:[l]}}))),H(n)&&!s.includes(n)&&i.push(n),i.push(...s),i}#s(){if(typeof this.#e.model=="string")return q(this.#e.model);if(this.#e.model)return this.#e.model;throw new Error("No model option was provided, either via `model` option.")}async#a(e,t,o={}){let n=await this.#s(),r=t,s=this.#o,i=null,l=[],m=async d=>{Le(d.model);let f=await this.#r(d.model,d.responseFormat),h=await this.#d(d.model,d,f),x=[...s.text===""?[]:[s],...d.messages],y=De(this.#e.signal,t.signal),w=await gt(h.invoke(x,{...t,signal:y}),y);if(i=w,f?.type==="native"){let j=f.strategy.parse(w);if(j)return{structuredResponse:j,messages:[w]};if(!w.tool_calls||w.tool_calls.length===0)throw new we(typeof f.strategy.schema?.title=="string"?f.strategy.schema.title:"providerStrategy",["Model output did not satisfy the provided response schema."]);return w}if(!f||!w.tool_calls)return w;let P=w.tool_calls.filter(j=>j.name in f.tools);if(P.length===0)return w;if(P.length>1)return this.#i(w,P,f);let I=f.tools[P[0].name]?.options?.toolMessageContent;return this.#l(w,P[0],f,I??o.lastMessage)},c=this.#e.wrapModelCallHookMiddleware??[],u=m;for(let d=c.length-1;d>=0;d--){let f=c[d],h=Array.isArray(f)?f[0]:f;if(h.wrapModelCall){let x=u,y=h;u=async w=>{let P=s,I=y.contextSchema?ee(y.contextSchema,r?.context||{}):r?.context,j=Object.freeze({context:I,store:r.store,configurable:r.configurable,writer:r.writer,interrupt:r.interrupt,signal:r.signal}),Z={...w,state:{...h.stateSchema?ee(Vt(h.stateSchema),e):{},messages:e.messages},runtime:j},N=async b=>{s=P;let J=b.tools??[],ae=new Map(this.#e.toolClasses.filter(se).map(_=>[_.name,_])),Ce=J.filter(_=>se(_)&&!ae.has(_.name)),fe=J.filter(_=>{if(!se(_))return!1;let v=ae.get(_.name);return v!=null&&v!==_});if(Ce.length>0&&!this.#e.middleware?.some(_=>_.wrapToolCall!=null))throw new Error(`You have added a new tool in "wrapModelCall" hook of middleware "${y.name}": ${Ce.map(_=>_.name).join(", ")}. This is not supported unless a middleware provides a "wrapToolCall" handler to execute it.`);if(fe.length>0)throw new Error(`You have modified a tool in "wrapModelCall" hook of middleware "${y.name}": ${fe.map(_=>_.name).join(", ")}. This is not supported.`);let p=b,C=b.systemPrompt!==s.text,E=b.systemMessage!==s;if(C&&E)throw new Error("Cannot change both systemPrompt and systemMessage in the same request.");C&&(s=new U({content:[{type:"text",text:b.systemPrompt}]}),p={...b,systemPrompt:s.text,systemMessage:s}),E&&(s=new U({...b.systemMessage}),p={...b,systemPrompt:s.text,systemMessage:s});let k=await x(p);return H(k)&&i?(l.includes(k)||l.push(k),i):k};if(!y.wrapModelCall)return N(Z);try{let b=await y.wrapModelCall(Z,N);if(!Ao(b))throw new Error(`Invalid response from "wrapModelCall" in middleware "${y.name}": expected AIMessage or Command, got ${typeof b}`);return M.isInstance(b)?i=b:H(b)&&l.push(b),b}catch(b){throw ye.wrap(b,y.name)}}}}s=this.#o;let g={model:n,responseFormat:this.#e.responseFormat,systemPrompt:s?.text,systemMessage:s,messages:e.messages,tools:this.#e.toolClasses,state:e,runtime:Object.freeze({context:r?.context,store:r.store,configurable:r.configurable,writer:r.writer,interrupt:r.interrupt,signal:r.signal})};return{response:await u(g),lastAiMessage:i,collectedCommands:l}}#i(e,t,o){let n=new Pe(t.map(r=>r.name));return this.#n(n,e,t[0],o)}#l(e,t,o,n){let r=o.tools[t.name];try{let s=r.parse(t.args);return{structuredResponse:s,messages:[e,new T({tool_call_id:t.id??"",content:JSON.stringify(s),name:t.name}),new M(n??`Returning structured response: ${JSON.stringify(s)}`)]}}catch(s){return this.#n(s,e,t,o)}}async#n(e,t,o,n){let r=Object.values(n.tools).at(0)?.options?.handleError,s=o.id;if(!s)throw new Error("Tool call ID is required to handle tool output errors. Please provide a tool call ID.");if(r===!1)throw e;if(r===void 0||typeof r=="boolean"&&r||Array.isArray(r)&&r.some(i=>i instanceof Pe))return new L({update:{messages:[t,new T({content:e.message,tool_call_id:s})]},goto:R});if(typeof r=="string")return new L({update:{messages:[t,new T({content:r,tool_call_id:s})]},goto:R});if(typeof r=="function"){let i=await r(e);if(typeof i!="string")throw new Error("Error handler must return a string.");return new L({update:{messages:[t,new T({content:i,tool_call_id:s})]},goto:R})}return new L({update:{messages:[t,new T({content:e.message,tool_call_id:s})]},goto:R})}#c(e,t){let o=M.isInstance(t)&&t.tool_calls?.every(r=>this.#e.shouldReturnDirect.has(r.name)),n="remainingSteps"in e?e.remainingSteps:void 0;return!!(n&&(n<1&&o||n<2&&ue(e.messages.at(-1))))}async#d(e,t,o){let n={},r=Object.values(o&&"tools"in o?o.tools:{}),s=[...t?.tools??this.#e.toolClasses,...r.map(m=>m.tool)],i=t?.toolChoice||(r.length>0?"any":void 0);if(o?.type==="native"){let m=t?.modelSettings?.strict??o?.strategy?.strict??!0,c={name:o.strategy.schema?.name??"extract",description:bt(o.strategy.schema),schema:o.strategy.schema,strict:m};Object.assign(n,{response_format:{type:"json_schema",json_schema:c},outputConfig:{format:{type:"json_schema",schema:o.strategy.schema}},responseSchema:o.strategy.schema,ls_structured_output_format:{kwargs:{method:"json_schema"},schema:o.strategy.schema},strict:t?.modelSettings?.strict})}let l=await Ft(e,s,{...n,...t?.modelSettings,tool_choice:i});return this.#e.includeAgentName==="inline"?Yt(l,this.#e.includeAgentName):l}getState(){let e=super.getState();return{messages:[],...e&&!H(e)?e:{}}}};var Qt=(e,t)=>`Error: ${e} is not a valid tool, try one of [${t.join(", ")}].`,D="tools",qt=e=>Array.isArray(e)&&e.every(Ge.isInstance),Io=e=>typeof e=="object"&&e!=null&&"messages"in e&&qt(e.messages),Oo=e=>typeof e=="object"&&e!=null&&"lg_tool_call"in e;function Ro(e,t){return e instanceof je?new T({content:e.message,tool_call_id:t.id,name:t.name}):new T({content:`${e}
|
|
27
|
+
Please fix your mistakes.`,tool_call_id:t.id,name:t.name})}var eo=class extends me{tools;trace=!1;signal;handleToolErrors=Ro;wrapToolCall;constructor(e,t){let{name:o,tags:n,handleToolErrors:r,signal:s,wrapToolCall:i}=t??{};super({name:o,tags:n,func:(l,m)=>this.run(l,m)}),this.options=t,this.tools=e,this.handleToolErrors=r??this.handleToolErrors,this.signal=s,this.wrapToolCall=i}#e(e,t,o){if(ft(e)||this.signal?.aborted||o&&this.handleToolErrors!==!0||!this.handleToolErrors)throw e;if(typeof this.handleToolErrors=="function"){let n=this.handleToolErrors(e,t);if(n&&T.isInstance(n))return n;throw e}else if(this.handleToolErrors)return new T({name:t.name,content:`${e}
|
|
28
|
+
Please fix your mistakes.`,tool_call_id:t.id});throw e}async runTool(e,t,o){let n=t,r={context:n?.context,store:n?.store,configurable:n?.configurable,writer:n?.writer,interrupt:n?.interrupt,signal:n?.signal},s=this.tools.find(m=>m.name===e.name),i=async m=>{let{toolCall:c,tool:u}=m,g=u??this.tools.find(f=>f.name===c.name);if(g===void 0){let f=this.tools.map(h=>h.name);return new T({content:Qt(c.name,f),tool_call_id:c.id,name:c.name,status:"error"})}let d=g;try{let f=await d.invoke({...c,type:"tool_call"},{...t,config:t,toolCallId:c.id,state:t.configurable?.__pregel_scratchpad?.currentTaskInput,signal:De(this.signal,t.signal)});return T.isInstance(f)||H(f)?f:new T({name:d.name,content:typeof f=="string"?f:JSON.stringify(f),tool_call_id:c.id})}catch(f){throw f instanceof pt?new je(f,c):f}},l={toolCall:e,tool:s,state:o,runtime:r};if(this.wrapToolCall)try{return await this.wrapToolCall(l,i)}catch(m){return this.#e(m,e,!0)}if(!s){let m=this.tools.map(c=>c.name);return new T({content:Qt(e.name,m),tool_call_id:e.id,name:e.name,status:"error"})}try{return await i(l)}catch(m){return this.#e(m,e,!1)}}async run(e,t){let o;if(Oo(e)){let{lg_tool_call:s,jumpTo:i,...l}=e;o=[await this.runTool(e.lg_tool_call,t,l)]}else{let s;if(qt(e))s=e;else if(Io(e))s=e.messages;else throw new Error("ToolNode only accepts BaseMessage[] or { messages: BaseMessage[] } as input.");let i=new Set(s.filter(m=>m.getType()==="tool").map(m=>m.tool_call_id)),l;for(let m=s.length-1;m>=0;m-=1){let c=s[m];if(M.isInstance(c)){l=c;break}}if(!M.isInstance(l))throw new Error("ToolNode only accepts AIMessages as input.");o=await Promise.all(l.tool_calls?.filter(m=>m.id==null||!i.has(m.id)).map(m=>this.runTool(m,t,e))??[])}if(!o.some(H))return Array.isArray(e)?o:{messages:o};let n=[],r=null;for(let s of o)H(s)?s.graph===L.PARENT&&Array.isArray(s.goto)&&s.goto.every(i=>Po(i))?r?r.goto.push(...s.goto):r=new L({graph:L.PARENT,goto:s.goto}):n.push(s):n.push(Array.isArray(e)?[s]:{messages:[s]});return r&&n.push(r),n}};function Po(e){return e instanceof $}function Ue(e,t){let n=0;if(t&&t.length>0){let r=0;for(let s of t){let i=ot(s)?St(s):s;r+=JSON.stringify(i).length}n+=r}for(let r of e){let s;typeof r.content=="string"?s=r.content:Array.isArray(r.content)?s=r.content.map(i=>typeof i=="string"?i:i.type==="text"&&"text"in i?i.text:"").join(""):s="",M.isInstance(r)&&Array.isArray(r.tool_calls)&&r.tool_calls.length>0&&(s+=JSON.stringify(r.tool_calls)),T.isInstance(r)&&(s+=r.tool_call_id??""),n+=s.length}return Math.ceil(n/4)}function X(e){if(!(!e||typeof e=="function"))return e.canJumpTo}function ne(e){return typeof e=="function"?e:e.hook}var jo=class{},No=class{},re=class extends me{constructor(e){super(e)}async invokeMiddleware(e,t){let o={};if(this.middleware.contextSchema&&F(this.middleware.contextSchema)){let m=le(this.middleware.contextSchema);if(m){let c={},u=t?.context||{};for(let g of Object.keys(m))g in u&&(c[g]=u[g]);o=ee(this.middleware.contextSchema,c)}}let n={...e,messages:e.messages},r={context:o,store:t?.store,configurable:t?.configurable,writer:t?.writer,interrupt:t?.interrupt,signal:t?.signal},s=await this.runHook(n,Object.freeze(Object.assign(new No,{...r,context:Object.freeze(Object.assign(new jo,o))})));if(!s)return{jumpTo:void 0};let i,l;if(this.name?.startsWith("BeforeAgentNode_")?(i=X(this.middleware.beforeAgent),l="beforeAgent.canJumpTo"):this.name?.startsWith("BeforeModelNode_")?(i=X(this.middleware.beforeModel),l="beforeModel.canJumpTo"):this.name?.startsWith("AfterAgentNode_")?(i=X(this.middleware.afterAgent),l="afterAgent.canJumpTo"):this.name?.startsWith("AfterModelNode_")&&(i=X(this.middleware.afterModel),l="afterModel.canJumpTo"),typeof s.jumpTo=="string"&&!i?.includes(s.jumpTo)){let m=i&&i.length>0?`must be one of: ${i?.join(", ")}.`:l?`no ${l} defined in middleware ${this.middleware.name}`:"";throw new Error(`Invalid jump target: ${s.jumpTo}, ${m}.`)}if(typeof s=="object"&&"type"in s){if(s.type==="terminate"){if(s.error)throw s.error;return{...n,...s.result||{},jumpTo:s.jumpTo}}throw new Error(`Invalid control action: ${JSON.stringify(s)}`)}return{...n,...s,jumpTo:s.jumpTo}}get nodeOptions(){return{input:Gt(this.middleware.stateSchema)}}};var to=class extends re{lc_namespace=["langchain","agents","beforeAgentNodes"];constructor(e){super({name:`BeforeAgentNode_${e.name}`,func:async(t,o)=>this.invokeMiddleware(t,o)}),this.middleware=e}runHook(e,t){return ne(this.middleware.beforeAgent)(e,t)}};var oo=class extends re{lc_namespace=["langchain","agents","beforeModelNodes"];constructor(e){super({name:`BeforeModelNode_${e.name}`,func:async(t,o)=>this.invokeMiddleware(t,o)}),this.middleware=e}runHook(e,t){return ne(this.middleware.beforeModel)(e,t)}};var no=class extends re{lc_namespace=["langchain","agents","afterModelNodes"];constructor(e){super({name:`AfterModelNode_${e.name}`,func:async(t,o)=>this.invokeMiddleware(t,o)}),this.middleware=e}runHook(e,t){return ne(this.middleware.afterModel)(e,t)}};var ro=class extends re{lc_namespace=["langchain","agents","afterAgentNodes"];constructor(e){super({name:`AfterAgentNode_${e.name}`,func:async(t,o)=>this.invokeMiddleware(t,o)}),this.middleware=e}runHook(e,t){return ne(this.middleware.afterAgent)(e,t)}};var so=class ao{#e;#o="v2";#r;#t;constructor(t,o){if(this.options=t,this.#t=z(o??{},{metadata:{ls_integration:"langchain_create_agent"},configurable:{ls_agent_type:"root"}}),t.name&&(this.#t=z(this.#t,{metadata:{lc_agent_name:t.name}})),this.#o=t.version??this.#o,!t.model)throw new Error("`model` option is required to create an agent.");typeof t.model!="string"&&Le(t.model);let n=this.options.middleware?.filter(p=>p.tools).flatMap(p=>p.tools)??[],r=[...t.tools??[],...n],s=new Set(r.filter(se).filter(p=>"returnDirect"in p&&p.returnDirect).map(p=>p.name)),i=!!this.options.middleware?.some(p=>p.wrapModelCall),{state:l,input:m,output:c}=Dt(this.options.responseFormat!==void 0||i,this.options.stateSchema,this.options.middleware),u=new At(l,{input:m,output:c,context:this.options.contextSchema}),g=[],d=[],f=[],h=[],x=[];this.#r=new Xt({model:this.options.model,systemMessage:zt(this.options.systemPrompt),includeAgentName:this.options.includeAgentName,name:this.options.name,responseFormat:this.options.responseFormat,middleware:this.options.middleware,toolClasses:r,shouldReturnDirect:s,signal:this.options.signal,wrapModelCallHookMiddleware:x});let y=new Set,w=this.options.middleware??[];for(let p=0;p<w.length;p++){let C,E,k,_,v=w[p];if(y.has(v.name))throw new Error(`Middleware ${v.name} is defined multiple times`);if(y.add(v.name),v.beforeAgent){C=new to(v);let S=`${v.name}.before_agent`;g.push({index:p,name:S,allowed:X(v.beforeAgent)}),u.addNode(S,C,C.nodeOptions)}if(v.beforeModel){E=new oo(v);let S=`${v.name}.before_model`;d.push({index:p,name:S,allowed:X(v.beforeModel)}),u.addNode(S,E,E.nodeOptions)}if(v.afterModel){k=new no(v);let S=`${v.name}.after_model`;f.push({index:p,name:S,allowed:X(v.afterModel)}),u.addNode(S,k,k.nodeOptions)}if(v.afterAgent){_=new ro(v);let S=`${v.name}.after_agent`;h.push({index:p,name:S,allowed:X(v.afterAgent)}),u.addNode(S,_,_.nodeOptions)}v.wrapModelCall&&x.push(v)}u.addNode(R,this.#r);let P=w.some(p=>p.wrapToolCall),I=r.filter(se);if(I.length>0||P){let p=new eo(I,{signal:this.options.signal,wrapToolCall:Wt(w)});u.addNode(D,p)}let j;g.length>0?j=g[0].name:d.length>0?j=d[0].name:j=R;let Z=d.length>0?d[0].name:R,N=h.length>0?h[h.length-1].name:A;u.addEdge(ut,j);let b=I.length>0||P;for(let p=0;p<g.length;p++){let C=g[p],E=C.name,k=p===g.length-1?Z:g[p+1].name;if(C.allowed&&C.allowed.length>0){let _=C.allowed.map(S=>V(S)).filter(S=>S!=="tools"||b),v=Array.from(new Set([k,..._.map(S=>S===A?N:S)]));u.addConditionalEdges(E,this.#c(I,k,N,b),v)}else u.addEdge(E,k)}for(let p=0;p<d.length;p++){let C=d[p],E=C.name,k=p===d.length-1?R:d[p+1].name;if(C.allowed&&C.allowed.length>0){let _=C.allowed.map(S=>V(S)).filter(S=>S!=="tools"||b),v=Array.from(new Set([k,..._]));u.addConditionalEdges(E,this.#d(I,k,b),v)}else u.addEdge(E,k)}let J=f.at(-1);if(f.length>0&&J)u.addEdge(R,J.name);else{let p=this.#s(I,!1,b).map(C=>C===A?N:C);p.length===1?u.addEdge(R,p[0]):u.addConditionalEdges(R,this.#i(N),p)}for(let p=f.length-1;p>0;p--){let C=f[p],E=C.name,k=f[p-1].name;if(C.allowed&&C.allowed.length>0){let _=C.allowed.map(S=>V(S)).filter(S=>S!=="tools"||b),v=Array.from(new Set([k,..._]));u.addConditionalEdges(E,this.#n(I,C.allowed,k,b),v)}else u.addEdge(E,k)}if(f.length>0){let p=f[0],C=p.name,E=this.#s(I,!0,b).filter(v=>v!=="tools"||b),k=!!(p.allowed&&p.allowed.length>0),_=E.map(v=>v===A?N:v);u.addConditionalEdges(C,this.#l(I,k,N,b),_)}for(let p=h.length-1;p>0;p--){let C=h[p],E=C.name,k=h[p-1].name;if(C.allowed&&C.allowed.length>0){let _=C.allowed.map(S=>V(S)).filter(S=>S!=="tools"||b),v=Array.from(new Set([k,..._]));u.addConditionalEdges(E,this.#n(I,C.allowed,k,b),v)}else u.addEdge(E,k)}if(h.length>0){let p=h[0],C=p.name;if(p.allowed&&p.allowed.length>0){let E=p.allowed.map(_=>V(_)).filter(_=>_!=="tools"||b),k=Array.from(new Set([A,...E]));u.addConditionalEdges(C,this.#n(I,p.allowed,A,b),k)}else u.addEdge(C,A)}if(b){let p=Z;s.size>0?u.addConditionalEdges(D,this.#a(s,N,p),[p,N]):u.addEdge(D,p)}let ae=(this.options.middleware??[]).flatMap(p=>p.streamTransformers??[]),Ce=[Te([]),Ne([]),...ae,...this.options.streamTransformers??[]];this.#e=u.compile({checkpointer:this.options.checkpointer,store:this.options.store,name:this.options.name,description:this.options.description,transformers:Ce});let fe=Ht(this.#t);Object.keys(fe).length>0&&(this.#e=this.#e.withConfig(fe))}get graph(){return this.#e}get checkpointer(){return this.#e.checkpointer}set checkpointer(t){this.#e.checkpointer=t}get store(){return this.#e.store}set store(t){this.#e.store=t}withConfig(t){return new ao(this.options,z(this.#t,t))}#s(t,o=!1,n=t.length>0){let r=[];return n&&r.push(D),o&&r.push(R),r.push(A),r}#a(t,o,n){return r=>{let s=r.messages,i=s[s.length-1];return T.isInstance(i)&&i.name&&t.has(i.name)?this.options.responseFormat?n:o:n}}#i(t=A){return o=>{let n=o.messages.at(-1);if(!M.isInstance(n)||!n.tool_calls||n.tool_calls.length===0||n.tool_calls.every(s=>s.name.startsWith("extract-")))return t;if(this.#o==="v1")return D;let r=n.tool_calls.filter(s=>!s.name.startsWith("extract-"));return r.length===0?t:r.map(s=>new $(D,{...o,lg_tool_call:s}))}}#l(t,o,n,r=t.length>0){let s=!!this.options.responseFormat;return i=>{let l=i,m=l.messages,c=m.at(-1);if(M.isInstance(c)&&(!c.tool_calls||c.tool_calls.length===0))return n;if(o&&l.jumpTo){let w=V(l.jumpTo);return w===A?n:w==="tools"?r?new $(D,{...i,jumpTo:void 0}):n:new $(R,{...i,jumpTo:void 0})}let u=m.filter(T.isInstance),g=m.filter(M.isInstance).at(-1),d=g?.tool_calls?.filter(w=>!u.some(P=>P.tool_call_id===w.id));if(d&&d.length>0)return this.#o==="v1"?D:d.map(w=>new $(D,{...i,lg_tool_call:w}));let f=g?.tool_calls?.some(w=>w.name.startsWith("extract-"));if(d&&d.length===0&&!f&&s)return R;if(!M.isInstance(c)||!c.tool_calls||c.tool_calls.length===0)return n;let h=c.tool_calls.every(w=>w.name.startsWith("extract-")),x=c.tool_calls.some(w=>!w.name.startsWith("extract-"));if(h||!x)return n;if(this.#o==="v1")return D;let y=c.tool_calls.filter(w=>!w.name.startsWith("extract-"));return y.length===0?n:y.map(w=>new $(D,{...i,lg_tool_call:w}))}}#n(t,o,n,r=t.length>0){let s=new Set(o.map(i=>V(i)));return i=>{let l=i;if(l.jumpTo){let m=V(l.jumpTo);if(m===A&&s.has(A))return A;if(m==="tools"&&s.has("tools"))return r?new $(D,{...i,jumpTo:void 0}):A;if(m==="model_request"&&s.has("model_request"))return new $(R,{...i,jumpTo:void 0})}return n}}#c(t,o,n,r=t.length>0){return s=>{let i=s;if(!i.jumpTo)return o;let l=V(i.jumpTo);return l===A?n:l==="tools"?r?new $(D,{...s,jumpTo:void 0}):n:new $(R,{...s,jumpTo:void 0})}}#d(t,o,n=t.length>0){return r=>{let s=r;if(!s.jumpTo)return o;let i=V(s.jumpTo);return i===A?A:i==="tools"?n?new $(D,{...r,jumpTo:void 0}):A:new $(R,{...r,jumpTo:void 0})}}async#u(t,o){if(!this.options.middleware||this.options.middleware.length===0||t instanceof L||!t)return t;let n=await Jt(this.options.middleware,t),r={...(await this.#e.getState(o).catch(()=>({values:{}}))).values,...t};if(!r)return r;for(let[s,i]of Object.entries(n))s in r||(r[s]=i);return r}async invoke(t,o){let n=z(this.#t,o),r=await this.#u(t,n);return this.#e.invoke(r,n)}async stream(t,o){let n=z(this.#t,o),r=await this.#u(t,n);return this.#e.stream(r,n)}streamEvents(t,o,n){if(o?.version!=="v3"||n!=null){let r=z(this.#t,o),s=o?.version==="v1"||o?.version==="v2"?o.version:"v2";return this.#e.streamEvents(t,{...r,version:s},n)}return(async()=>{let{transformers:r,version:s,...i}=o??{},l=z(this.#t,i),m=await this.#u(t,l);return await this.#e.streamEvents(m,{...l,version:"v3",transformers:r})})()}async drawMermaidPng(t){let o=await(await(await this.#e.getGraphAsync()).drawMermaidPng(t)).arrayBuffer();return new Uint8Array(o)}async drawMermaid(t){return(await this.#e.getGraphAsync()).drawMermaid(t)}getGraphAsync(t){return this.#e.getGraphAsync(t)}getState(t,o){return this.#e.getState(t,o)}getStateHistory(t,o){return this.#e.getStateHistory(t,o)}getSubgraphs(t,o){return this.#e.getSubgraphs(t,o)}getSubgraphsAsync(t,o){return this.#e.getSubgraphsAsync(t,o)}updateState(t,o,n){return this.#e.updateState(t,o,n)}get builder(){return this.#e.builder}};function Lo(e){return new so(e)}var $o=a.function().args(a.custom()).returns(a.union([a.boolean(),a.promise(a.boolean())])),Bo=a.function().args(a.custom(),a.custom(),a.custom()).returns(a.union([a.string(),a.promise(a.string())])),Uo=["approve","edit","reject"],zo=a.enum(Uo),Fo=a.object({allowedDecisions:a.array(zo),description:a.union([a.string(),Bo]).optional(),argsSchema:a.record(a.any()).optional(),when:$o.optional()}),fa=a.object({interruptOn:a.record(a.union([a.boolean(),Fo])).optional(),descriptionPrefix:a.string().default("Tool execution requires approval")});var ze=`<role>
|
|
29
|
+
Context Extraction Assistant
|
|
30
|
+
</role>
|
|
31
|
+
|
|
32
|
+
<primary_objective>
|
|
33
|
+
Your sole objective in this task is to extract the highest quality/most relevant context from the conversation history below.
|
|
34
|
+
</primary_objective>
|
|
35
|
+
|
|
36
|
+
<objective_information>
|
|
37
|
+
You're nearing the total number of input tokens you can accept, so you must extract the highest quality/most relevant pieces of information from your conversation history.
|
|
38
|
+
This context will then overwrite the conversation history presented below. Because of this, ensure the context you extract is only the most important information to your overall goal.
|
|
39
|
+
</objective_information>
|
|
40
|
+
|
|
41
|
+
<instructions>
|
|
42
|
+
The conversation history below will be replaced with the context you extract in this step. Because of this, you must do your very best to extract and record all of the most important context from the conversation history.
|
|
43
|
+
You want to ensure that you don't repeat any actions you've already completed, so the context you extract from the conversation history should be focused on the most important information to your overall goal.
|
|
44
|
+
</instructions>
|
|
45
|
+
|
|
46
|
+
The user will message you with the full message history you'll be extracting context from, to then replace. Carefully read over it all, and think deeply about what information is most important to your overall goal that should be saved:
|
|
47
|
+
|
|
48
|
+
With all of this in mind, please carefully read over the entire conversation history, and extract the most important and relevant context to replace it so that you can free up space in the conversation history.
|
|
49
|
+
Respond ONLY with the extracted context. Do not include any additional information, or text before or after the extracted context.
|
|
50
|
+
|
|
51
|
+
<messages>
|
|
52
|
+
Messages to summarize:
|
|
53
|
+
{messages}
|
|
54
|
+
</messages>`,Wo="Here is a summary of the conversation to date:",Fe=20,Ho=4e3,Jo=15,io=5,Go=a.function().args(a.array(a.custom())).returns(a.union([a.number(),a.promise(a.number())])),ve=a.object({fraction:a.number().gt(0,"Fraction must be greater than 0").max(1,"Fraction must be less than or equal to 1").optional(),tokens:a.number().positive("Tokens must be greater than 0").optional(),messages:a.number().int("Messages must be an integer").positive("Messages must be greater than 0").optional()}).refine(e=>[e.fraction,e.tokens,e.messages].filter(t=>t!==void 0).length>=1,{message:"At least one of fraction, tokens, or messages must be provided"}),dt=a.object({fraction:a.number().min(0,"Messages must be non-negative").max(1,"Fraction must be less than or equal to 1").optional(),tokens:a.number().min(0,"Tokens must be greater than or equal to 0").optional(),messages:a.number().int("Messages must be an integer").min(0,"Messages must be non-negative").optional()}).refine(e=>[e.fraction,e.tokens,e.messages].filter(t=>t!==void 0).length===1,{message:"Exactly one of fraction, tokens, or messages must be provided"}),lo=a.object({model:a.custom(),trigger:a.union([ve,a.array(ve)]).optional(),keep:dt.optional(),tokenCounter:Go.optional(),summaryPrompt:a.string().default(ze),trimTokensToSummarize:a.number().optional(),summaryPrefix:a.string().optional(),maxTokensBeforeSummary:a.number().optional(),messagesToKeep:a.number().optional()});function We(e){if("profile"in e&&typeof e.profile=="object"&&e.profile&&"maxInputTokens"in e.profile&&(typeof e.profile.maxInputTokens=="number"||e.profile.maxInputTokens==null))return e.profile.maxInputTokens??void 0;if("model"in e&&typeof e.model=="string")return et(e.model);if("modelName"in e&&typeof e.modelName=="string")return et(e.modelName)}function Vo(e){let{data:t,error:o}=Tt(lo,e);if(o)throw new Error(`Invalid summarization middleware options: ${B.prettifyError(o)}`);return O({name:"SummarizationMiddleware",contextSchema:lo.extend({model:a.custom().optional()}),beforeModel:async(n,r)=>{let s=t.trigger,i=t.keep;t.maxTokensBeforeSummary!==void 0&&(console.warn("maxTokensBeforeSummary is deprecated. Use `trigger: { tokens: value }` instead."),s===void 0&&(s={tokens:t.maxTokensBeforeSummary})),t.messagesToKeep!==void 0&&(console.warn("messagesToKeep is deprecated. Use `keep: { messages: value }` instead."),(!i||i&&"messages"in i&&i.messages===Fe)&&(i={messages:t.messagesToKeep}));let l=r.context?.trigger!==void 0?r.context.trigger:s,m=r.context?.keep!==void 0?r.context.keep:i??{messages:Fe},c=dt.parse(m),u=[];l===void 0?u=[]:Array.isArray(l)?u=l.map(J=>ve.parse(J)):u=[ve.parse(l)];let g=u.some(J=>"fraction"in J)||"fraction"in c,d=typeof t.model=="string"?await q(t.model):t.model;if(g&&!We(d))throw new Error("Model profile information is required to use fractional token limits. Use absolute token counts instead.");let f=r.context?.summaryPrompt===ze?t.summaryPrompt??ze:r.context?.summaryPrompt??t.summaryPrompt??ze,h=r.context.summaryPrefix??t.summaryPrefix??Wo,x=r.context?.trimTokensToSummarize!==void 0?r.context.trimTokensToSummarize:t.trimTokensToSummarize??Ho;Zo(n.messages);let y=r.context?.tokenCounter!==void 0?r.context.tokenCounter:t.tokenCounter??Ue,w=await y(n.messages);if(!await Xo(n.messages,w,u,d))return;let{systemPrompt:P,conversationMessages:I}=Ko(n.messages),j=await Qo(I,c,y,d);if(j<=0)return;let{messagesToSummarize:Z,preservedMessages:N}=Yo(P,I,j),b=new Q({content:`${h}
|
|
55
|
+
|
|
56
|
+
${await tn(Z,d,f,y,x,r)}`,id:Je(),additional_kwargs:{lc_source:"summarization"}});return{messages:[new Ze({id:Et}),b,...N]}}})}function Zo(e){for(let t of e)t.id||(t.id=Je())}function Ko(e){return e.length>0&&U.isInstance(e[0])?{systemPrompt:e[0],conversationMessages:e.slice(1)}:{conversationMessages:e}}function Yo(e,t,o){let n=t.slice(0,o),r=t.slice(o);return e&&n.unshift(e),{messagesToSummarize:n,preservedMessages:r}}async function Xo(e,t,o,n){if(o.length===0)return!1;for(let r of o){let s=!0,i=!1;if(r.messages!==void 0&&(i=!0,e.length<r.messages&&(s=!1)),r.tokens!==void 0&&(i=!0,t<r.tokens&&(s=!1)),r.fraction!==void 0){i=!0;let l=We(n);typeof l=="number"?t<Math.floor(l*r.fraction)&&(s=!1):s=!1}if(i&&s)return!0}return!1}async function Qo(e,t,o,n){if("tokens"in t||"fraction"in t){let r=await qo(e,t,o,n);return typeof r=="number"?r:co(e,Fe)}return co(e,t.messages??Fe)}async function qo(e,t,o,n){if(e.length===0)return 0;let r;if("fraction"in t&&t.fraction!==void 0){let u=We(n);if(typeof u!="number")return;r=Math.floor(u*t.fraction)}else if("tokens"in t&&t.tokens!==void 0)r=Math.floor(t.tokens);else return;if(r<=0&&(r=1),await o(e)<=r)return 0;let s=0,i=e.length,l=e.length,m=Math.floor(Math.log2(e.length))+1;for(let u=0;u<m&&!(s>=i);u++){let g=Math.floor((s+i)/2);await o(e.slice(g))<=r?(l=g,i=g):s=g+1}if(l===e.length&&(l=s),l>=e.length){if(e.length===1)return 0;l=e.length-1}let c=fo(e,l);if(c<=l)return c;for(let u=l;u>=0;u--)if(uo(e,u))return u;return 0}function co(e,t){if(e.length<=t)return 0;let o=e.length-t,n=fo(e,o);if(n<=o)return n;for(let r=o;r>=0;r--)if(uo(e,r))return r;return 0}function uo(e,t){if(t>=e.length)return!0;if(t<e.length&&M.isInstance(e[t])&&ue(e[t]))return!1;let o=Math.max(0,t-io),n=Math.min(e.length,t+io);for(let r=o;r<n;r++){if(!ue(e[r]))continue;let s=mo(e[r]);if(en(e,r,t,s))return!1}return!0}function mo(e){let t=new Set;if(e.tool_calls)for(let o of e.tool_calls){let n=typeof o=="object"&&"id"in o?o.id:null;n&&t.add(n)}return t}function fo(e,t){if(t>=e.length||!T.isInstance(e[t]))return t;let o=new Set,n=t;for(;n<e.length&&T.isInstance(e[n]);){let r=e[n];r.tool_call_id&&o.add(r.tool_call_id),n++}for(let r=t-1;r>=0;r--){let s=e[r];if(M.isInstance(s)&&ue(s)){let i=mo(s);for(let l of o)if(i.has(l))return r}}return n}function en(e,t,o,n){for(let r=t+1;r<e.length;r++){let s=e[r];if(T.isInstance(s)&&n.has(s.tool_call_id)&&t<o!=r<o)return!0}return!1}async function tn(e,t,o,n,r,s){if(!e.length)return"No previous conversation history.";let i=await on(e,n,r);if(!i.length)return"Previous conversation was too long to summarize.";let l=ht(i);try{let m=o.replace("{messages}",l),c=z(Ye(s)??{},{metadata:{lc_source:"summarization"}}),u=(await t.invoke(m,c)).content;return typeof u=="string"?u.trim():Array.isArray(u)?u.map(g=>typeof g=="string"?g:typeof g=="object"&&g!==null&&"text"in g?g.text:"").join("").trim():"Error generating summary: Invalid response format"}catch(m){return`Error generating summary: ${m}`}}async function on(e,t,o){if(o===void 0)return e;try{return await qe(e,{maxTokens:o,tokenCounter:async n=>t(n),strategy:"last",allowPartial:!0,includeSystem:!0})}catch{return e.slice(-Jo)}}var Da=a.object({model:a.string().or(a.instanceof(_t)).optional(),systemPrompt:a.string().optional(),maxTools:a.number().optional(),alwaysInclude:a.array(a.string()).optional()});var Ha=a.object({applyToInput:a.boolean().optional(),applyToOutput:a.boolean().optional(),applyToToolResults:a.boolean().optional()});var Ka=a.object({rules:a.record(a.string(),a.instanceof(RegExp).describe("Regular expression pattern to match PII")).optional()});var nn=["continue","error","end"],rn="continue";var sn=a.enum(nn).default(rn);a.object({toolName:a.string().optional(),threadLimit:a.number().optional(),runLimit:a.number().optional(),exitBehavior:sn});var si=a.object({threadToolCallCount:a.record(a.string(),a.number()).default({}),runToolCallCount:a.record(a.string(),a.number()).default({})});var an=a.enum(["pending","in_progress","completed"]).describe("Status of the todo"),ln=a.object({content:a.string().describe("Content of the todo item"),status:an}),fi=a.object({todos:a.array(ln).default([])});var cn="end",dn=a.object({threadLimit:a.number().optional(),runLimit:a.number().optional(),exitBehavior:a.enum(["error","end"]).optional()}),un=a.object({threadModelCallCount:a.number().default(0),runModelCallCount:a.number().default(0)}),po=class extends Error{constructor({threadLimit:e,runLimit:t,threadCount:o,runCount:n}){let r=[];typeof e=="number"&&typeof o=="number"&&r.push(`thread level call limit reached with ${o} model calls`),typeof t=="number"&&typeof n=="number"&&r.push(`run level call limit reached with ${n} model calls`),super(`Model call limits exceeded${r.length>0?`: ${r.join(", ")}`:""}`),this.name="ModelCallLimitMiddlewareError"}};function mn(e){return O({name:"ModelCallLimitMiddleware",contextSchema:dn,stateSchema:un,beforeModel:{canJumpTo:["end"],hook:(t,o)=>{let n=o.context.exitBehavior??e?.exitBehavior??cn;n==="throw"&&(console.warn("The 'throw' exit behavior is deprecated. Please use 'error' instead."),n="error");let r=o.context.threadLimit??e?.threadLimit,s=o.context.runLimit??e?.runLimit,i=t.threadModelCallCount,l=t.runModelCallCount;if(typeof r=="number"&&r<=i){let m=new po({threadLimit:r,threadCount:i});if(n==="end")return{jumpTo:"end",messages:[new M(m.message)]};throw m}if(typeof s=="number"&&s<=l){let m=new po({runLimit:s,runCount:l});if(n==="end")return{jumpTo:"end",messages:[new M(m.message)]};throw m}return t}},afterModel:t=>({runModelCallCount:t.runModelCallCount+1,threadModelCallCount:t.threadModelCallCount+1}),afterAgent:()=>({runModelCallCount:0})})}var He=a.object({maxRetries:a.number().min(0).default(2),retryOn:a.union([a.function().args(a.instanceof(Error)).returns(a.boolean()),a.array(a.custom())]).default(()=>()=>!0),backoffFactor:a.number().min(0).default(2),initialDelayMs:a.number().min(0).default(1e3),maxDelayMs:a.number().min(0).default(6e4),jitter:a.boolean().default(!0)});var Ri=a.object({onFailure:a.union([a.literal("error"),a.literal("continue"),a.function().args(a.instanceof(Error)).returns(a.string())]).default("continue")}).merge(He);var Ui=a.object({tools:a.array(a.union([a.custom(),a.custom(),a.string()])).optional(),onFailure:a.union([a.literal("error"),a.literal("continue"),a.literal("raise"),a.literal("return_message"),a.function().args(a.instanceof(Error)).returns(a.string())]).default("continue")}).merge(He);var tl=a.object({enableCaching:a.boolean().optional(),ttl:a.enum(["5m","1h"]).optional(),minMessagesToCache:a.number().optional(),unsupportedModelBehavior:a.enum(["ignore","warn","raise"]).optional()});var sl=a.object({enableCaching:a.boolean().optional(),ttl:a.enum(["5m","1h"]).optional(),minMessagesToCache:a.number().optional(),unsupportedModelBehavior:a.enum(["ignore","warn","raise"]).optional()});export{O as a,Lo as b,Vo as c,mn as d};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
+
import c from"./UK7PR2FE.js";import b from"./EIPHHMWX.js";import a from"./JMODFBN6.js";import{a as n}from"./HJG7QM2R.js";import{Va as N,a as I,b as S}from"./ZQ7PGNWB.js";import{ca as $}from"./LUY6V4TP.js";export default $arcgis.t(([,,,,,,P,U,{p:k,r:T},{C:M,D:z,E:L,F:D,G:F,H:O,a:A,m:w,n:R,o:y,p:V},b])=>{var W=async(e,t)=>(await n({text:"Exiting Data Exploration agent"},t),e),B=async(e,t)=>{await n({text:"Requesting LLM for layer filter results"},t);let a=await w("data_explore_filter_prompt");if(!t?.configurable)throw new Error("config.configurable is required for layer filter tools");let{userTimezone:d,userTimezoneOffset:o}=L(),s={layerFieldInfo:e.layerFieldInfo,userTimezone:d,userTimezoneOffset:o,queryResponse:e.queryResponse,assignedTask:e.agentExecutionContext.assignedTask,userRequest:e.agentExecutionContext.userRequest,priorSteps:e.agentExecutionContext.priorSteps},i=await T({promptText:a,modelTier:"advanced",config:t,messages:e.dataExplorationMessages,inputVariables:s,tools:F}),r=[...e.dataExplorationMessages,i];if(!((i.tool_calls?.length??0)>0))return await n({text:"LLM determined no filter changes needed"},t),{...e,dataExplorationMessages:r};let c=r,l=i.content.toString();return await b(i,t),{...e,dataExplorationMessages:c,outputMessage:l}},H=async(e,t)=>{await n({text:"Requesting LLM for layer query results"},t);let a=await w("data_explore_query_prompt");if(!t?.configurable)throw new Error("config.configurable is required for layer query tools");let{userTimezone:d,userTimezoneOffset:o}=L(),s=e.agentExecutionContext.sharedState,i=s.lastNavigatedFeatures?.value,r=s.lastResolvedLocation?.value,c="none";if(i!=null)try{c=JSON.stringify(i)}catch{c="none"}let l="none";if(r!=null)try{l=JSON.stringify({address:r.address,location:r.location})}catch{l="none"}let g={layerFieldInfo:e.layerFieldInfo,userTimezone:d,userTimezoneOffset:o,assignedTask:e.agentExecutionContext.assignedTask,userRequest:e.agentExecutionContext.userRequest,priorSteps:e.agentExecutionContext.priorSteps,lastNavigatedFeatures:c,lastResolvedLocation:l},m=await T({promptText:a,modelTier:"advanced",config:t,messages:e.dataExplorationMessages,inputVariables:g,tools:D}),h=(m.tool_calls?.length??0)>0,f=m.content.toString();return await b(m,t),{...e,dataExplorationMessages:[...e.dataExplorationMessages,m],...h?{}:{outputMessage:f},status:"success",summary:f&&!h?R(f):"Query planning completed."}},J=async(e,t)=>{try{await n({text:"Requesting LLM for summary on query results"},t);let a=await w("summarize_query_response_prompt"),d={queryResponse:e.queryResponse,assignedTask:e.agentExecutionContext.assignedTask,userRequest:e.agentExecutionContext.userRequest,priorSteps:e.agentExecutionContext.priorSteps},o=await k({promptText:a,modelTier:"fast",config:t,messages:e.dataExplorationMessages,inputVariables:d}),s=typeof o=="string"?o:o.content,i=new $(s);await n({text:`Received response from LLM: ${s}`},t);let r=s;return{...e,outputMessage:r,status:"success",summary:r?R(r):"Summary generated.",dataExplorationMessages:[...e.dataExplorationMessages,i]}}catch(a){throw await n({text:"Error during filter LLM request"},t),new Error(`Error during filter LLM request: ${a instanceof Error?a.message:String(a)}`)}};async function K(e,t){if((e.queryResponse??[]).some(d=>{let o=d.details;return typeof o=="object"&&o!==null&&"error"in o}))return await n({text:"Skipping layer filter tool because query response contains an error."},t),{...e};let a=await new A(F,{handleToolErrors:!1}).invoke({messages:e.dataExplorationMessages},t);return await n({text:`Finished executing layer filter tool: ${a.messages.map(d=>d.content).join(", ")}`},t),{...e}}var X=10,Y=["string","small-integer","integer"],Z=async(e,t,{includeSummaryStatistics:a=!0,includeUniqueValues:d=!0}={})=>{let o=null,s=null;try{if(t.type!=="geometry"&&t.type!=="oid"&&t.type!=="global-id"){a&&(o=await P({layer:e,field:t.name}));let i=t.domain?.type==="coded-value"?t.domain:null;d&&(Y.includes(t.type)||i)&&(s=(await U({layer:e,field:t.name})).uniqueValueInfos.sort((r,c)=>c.count-r.count).slice(0,X),i&&(s=s.map(r=>({...r,value:i.getName(r.value)??r.value}))))}}catch(i){console.error(`Error fetching statistics for field ${t.name}:`,i)}return{summaryStatistics:o,uniqueValues:s}};function ee(e,t){return["string","small-integer","integer"].includes(e)||t==="coded-value"}async function te(e,t,a,d=!0){let o=[],s=[],i=[];for(let r of e){let c=function(p){let u=t.get(p)?.layerItem;return u?[u.name&&`Name: ${u.name}`,u.title&&`Title: ${u.title}`,u.description&&`Description: ${u.description}`].filter(Boolean).join(" | "):p},{layerId:l,results:g}=r,m=a.map?.allLayers.find(p=>p.id===l),h=t.get(l)?.fieldRegistry;if(!h)continue;let f=o.find(p=>p.layerId===l);f||(f={layerId:l,layerSummary:c(l),fieldInfos:[]},o.push(f));for(let p of g){let u=h.get(p.name);if(!u)continue;let x=u.statistics,v=d&&!x?.summaryStatistics,q=ee(u.type,u.domain?.type)&&!x?.uniqueValues,_=v||q;if(i.push({layerId:l,fieldName:u.name,didFetchStatistics:_}),_){let G=Z(m,u,{includeSummaryStatistics:v,includeUniqueValues:q}).then(C=>{let E={summaryStatistics:x?.summaryStatistics??null,uniqueValues:x?.uniqueValues??null};v&&(E.summaryStatistics=C.summaryStatistics),q&&(E.uniqueValues=C.uniqueValues),h.set(u.name,{...u,statistics:E}),u.statistics=E});s.push(G)}f.fieldInfos.push(u)}}return await Promise.all(s),{layerFieldInfo:o,didFetchStatistics:s.length>0,fieldStatisticsFetchStatus:i}}var j=/\b(average|avg|mean|median|max(?:imum)?|min(?:imum)?|sum|total|count|std(?:dev|\s*deviation)|variance|null\s*count|missing\s*values?|range)\b/iu;function ae(e,t){return j.test(e)||j.test(t)}var se=async(e,t)=>{try{await n({text:"Preparing field information for vector search results"},t);let a=y(t,"layersAndFieldsRegistry"),{mapView:d}=z(t),{assignedTask:o,userRequest:s}=e.agentExecutionContext,i=ae(o,s),{layerFieldInfo:r,didFetchStatistics:c,fieldStatisticsFetchStatus:l}=await te(e.vectorSearchFieldResults,a,d,i);c?await n({text:"Statistics fetched"},t):await n({text:"Statistics skipped"},t);for(let g of l)await n({text:` - ${g.fieldName} - stats ${g.didFetchStatistics?"fetched":"skipped"}`},t);return await n({text:"Field information prepared"},t),{...e,layerFieldInfo:r}}catch(a){throw await n({text:"Error during fetching statistics"},t),new Error(`Error during fetching statistics: ${a instanceof Error?a.message:String(a)}`)}},Q=.7,re=10,ie=async(e,t)=>{try{await n({text:"Similarity search to find fields"},t);let a=y(t,"fieldSearch"),d=y(t,"layersAndFieldsRegistry"),o=y(t,"embeddingCache"),s=await a.searchFields({text:e.agentExecutionContext.assignedTask,layerIds:e.vectorSearchLayerIds,minScore:Q,topResults:re,embeddingCache:o}),i=s.map(({layerId:c,results:l})=>{let g=l.map(m=>` - ${m.name} (${m.score.toFixed(2)})`).join(`
|
|
3
|
+
`);return`${d.get(c)?.layerItem.name??c}:
|
|
4
|
+
${g}`}).join(`
|
|
5
|
+
`),r;return s.length>0?r=`Vector search completed. Matching layers and fields with scores:
|
|
6
|
+
${i}`:r=`No vector search results found for score over ${Q}.`,await n({text:r},t),{...e,vectorSearchFieldResults:s}}catch(a){throw await n({text:`Error during vector search: ${a instanceof Error?a.message:String(a)}`},t),new Error(`Vector search failed: ${a instanceof Error?a.message:String(a)}`)}},oe=.7,ne=async(e,t)=>{try{await n({text:`Similarity search to find layers: ${e.agentExecutionContext.assignedTask}`},t);let a=y(t,"layerSearch"),d=y(t,"layersAndFieldsRegistry"),o=y(t,"embeddingCache"),s=await a.searchLayers({text:e.agentExecutionContext.assignedTask,minScore:oe,embeddingCache:o}),i=s.map(l=>l.id),r=s.map(({id:l,score:g})=>`${d.get(l)?.layerItem.name??l} (${g.toFixed(2)})`).join(`
|
|
7
|
+
`),c;return i.length>0?c=`Vector search completed. Matching layers with scores:
|
|
8
|
+
${r}`:c="Vector search completed. No matching layers found.",await n({text:c},t),{...e,vectorSearchLayerIds:i}}catch(a){throw await n({text:`Error during vector search: ${a instanceof Error?a.message:String(a)}`},t),new Error(`Vector search failed: ${a instanceof Error?a.message:String(a)}`)}},le=(e,t)=>V(["layerSearch","fieldSearch","layersAndFieldsRegistry"],"Data Exploration Agent")(e,t),de=()=>new N(M).addNode("requireDataExplorationServices",le).addNode("vectorSearchLayers",ne).addNode("vectorSearchFields",ie).addNode("fieldStatistics",se).addNode("queryAgent",H).addNode("queryTools",O).addNode("summarizeQueryResponseLLM",J).addNode("filterAgent",B).addNode("filterTools",K).addNode("earlyExit",W).addEdge(I,"requireDataExplorationServices").addEdge("requireDataExplorationServices","vectorSearchLayers").addConditionalEdges("vectorSearchLayers",e=>e.vectorSearchLayerIds.length?"vectorSearchFields":"earlyExit").addConditionalEdges("vectorSearchFields",e=>e.vectorSearchFieldResults.length?"fieldStatistics":"earlyExit").addEdge("fieldStatistics","queryAgent").addConditionalEdges("queryAgent",e=>(e.dataExplorationMessages[e.dataExplorationMessages.length-1]?.tool_calls?.length??0)>0?"queryTools":"filterAgent").addConditionalEdges("queryTools",e=>e.queryResponse.length?"summarizeQueryResponseLLM":"filterAgent").addEdge("summarizeQueryResponseLLM","filterAgent").addConditionalEdges("filterAgent",e=>(e.dataExplorationMessages[e.dataExplorationMessages.length-1]?.tool_calls?.length??0)>0?"filterTools":S).addEdge("filterTools",S).addEdge("earlyExit",S),ce=String.raw`- **data exploration** — User is asking about the feature layer’s data (e.g. counts, summaries, statistics, field values), either for all features, a subset based on a condition, or for a subset based on the current view. And/Or user wants to include or exclude features based on field values, or visually style features differently (e.g., highlight or deemphasize them).
|
|
9
|
+
The Data Exploration Agent will automatically zoom to the affected features for action taken by this agent. In this case, no need to call navigation tool separately.
|
|
10
|
+
_Example: “Only show stations where Brand is Shell”_
|
|
11
|
+
_Example: “Make Shell stations stand out on the map”_
|
|
12
|
+
_Example: “Gray out all stations that aren’t Shell”_
|
|
13
|
+
This also includes questions that ask which feature meets a given condition or where a particular feature in the data is located (e.g., “Where is the spring with the highest elevation?”). However, this agent does not handle addresses.
|
|
14
|
+
_Example: “How many features are there?”_
|
|
15
|
+
_Example: “What’s the average population?”_
|
|
16
|
+
_Example: “Which values are in the status field?”_
|
|
17
|
+
|
|
18
|
+
This agent does NOT handle help/metadata requests such as listing available layers, listing field names/columns/attributes for a layer, or capability guidance.`,Fe={id:"dataExploration",name:"Data Exploration Agent",description:ce,createGraph:de,workspace:M};return Fe},"identity/IdentityManager","portal/Portal","config","core/reactiveUtils","layers/FeatureLayer","request","smartMapping/statistics/summaryStatistics","smartMapping/statistics/uniqueValues",a,b,c)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import"./
|
|
2
|
+
import"./UZLQALHY.js";var e=`## Membership Bind Parameters
|
|
3
3
|
|
|
4
4
|
The current map contains a subset of entities and relationships from the database. Their membership is available to Cypher queries as lists of string identifiers through these bind parameters:
|
|
5
5
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import"./
|
|
2
|
+
import"./UZLQALHY.js";var e=`# Navigation Tool Instructions
|
|
3
3
|
|
|
4
4
|
CRITICAL: You are FORBIDDEN from making multiple tool calls. You MUST make exactly ONE tool call.
|
|
5
5
|
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import{a as t}from"./
|
|
2
|
+
import{a as t}from"./HJG7QM2R.js";export default $arcgis.t(([])=>{var d=async(o,i)=>{let r=o.tool_calls??[];if(r.length===0){await t({text:`LLM did not request any tool calls: ${String(o?.content)}`},i);return}await Promise.all(r.map(async a=>await t({text:`LLM invoked ${a.name} tool with arguments: ${JSON.stringify(a.args,null,2)}`},i)))};return d},"identity/IdentityManager","portal/Portal","config","core/reactiveUtils","layers/FeatureLayer","request")
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
+
var g=Object.create;var e=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var i=Object.getOwnPropertyNames;var j=Object.getPrototypeOf,k=Object.prototype.hasOwnProperty;var m=(b,a)=>()=>{try{return a||b((a={exports:{}}).exports,a),a.exports}catch(c){throw a=0,c}},n=(b,a)=>{for(var c in a)e(b,c,{get:a[c],enumerable:!0})},l=(b,a,c,f)=>{if(a&&typeof a=="object"||typeof a=="function")for(let d of i(a))!k.call(b,d)&&d!==c&&e(b,d,{get:()=>a[d],enumerable:!(f=h(a,d))||f.enumerable});return b};var o=(b,a,c)=>(c=b!=null?g(j(b)):{},l(a||!b||!b.__esModule?e(c,"default",{value:b,enumerable:!0}):c,b));export{m as a,n as b,o as c};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import{a as s,b as i}from"./
|
|
2
|
+
import{a as s,b as i}from"./3UEKINYC.js";import{c as r}from"./RLEHNAIA.js";function c(e,n){let t=s(e.el,e.referenceElement);if(t)return t;let o=r(e.el,"arcgis-assistant"),a=s(e.el,o?.referenceElement);if(a)return a;throw new Error(`${n}: Reference element not found`)}function g(e,n){let t=c(e,n).view;if(!t)throw new Error(`${n}: Reference element does not have a view`);return t}function m(e){return typeof e=="function"}function w(e){let n=r(e.el,"arcgis-assistant");if(n===void 0)throw new Error("arcgis-assistant-agent must be used within an arcgis-assistant element");return n.register({agent:e.agent,getContext:async()=>await e.getContext?.()??e.context??{}}),n}function f(e){let n=i(e.el,e.referenceElement);if(n)return n;let t=r(e.el,"arcgis-assistant");return s(e.el,t?.referenceElement)||null}function E(e){let n=f(e);return n?n.view:null}export{g as a,m as b,w as c,E as d};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import"./
|
|
2
|
+
import"./UZLQALHY.js";var e=`# ArcGIS Knowledge Agent \u2014 Action Summary
|
|
3
3
|
|
|
4
4
|
You are a Knowledge Graph assistant that has executed tool calls to answer a user request.
|
|
5
5
|
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import{Dd as o}from"./
|
|
2
|
+
import{Dd as o}from"./MWYBF3F3.js";var r=o;export{r as a};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import{a as W}from"./PBTINZTK.js";import{i as M,j as z,q as j,r as B,s as Q}from"./
|
|
2
|
+
import{a as W}from"./PBTINZTK.js";import{i as M,j as z,q as j,r as B,s as Q}from"./NAKAZDJ7.js";var L=class extends Q{constructor(r){if(super(r),this.it=z,r.type!==j.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(r){if(r===z||r==null)return this._t=void 0,this.it=r;if(r===M)return r;if(typeof r!="string")throw Error(this.constructor.directiveName+"() called with a non-string value");if(r===this.it)return this._t;this.it=r;let t=[r];return t.raw=t,this._t={_$litType$:this.constructor.resultType,strings:t,values:[]}}};L.directiveName="unsafeHTML",L.resultType=1;var mt=B(L);var V=function(){return V=Object.assign||function(r){for(var t,a=1,i=arguments.length;a<i;a++){t=arguments[a];for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&(r[s]=t[s])}return r},V.apply(this,arguments)},D={exports:{}},p={},q={exports:{}},w={};function ee(){var e={};return e["align-content"]=!1,e["align-items"]=!1,e["align-self"]=!1,e["alignment-adjust"]=!1,e["alignment-baseline"]=!1,e.all=!1,e["anchor-point"]=!1,e.animation=!1,e["animation-delay"]=!1,e["animation-direction"]=!1,e["animation-duration"]=!1,e["animation-fill-mode"]=!1,e["animation-iteration-count"]=!1,e["animation-name"]=!1,e["animation-play-state"]=!1,e["animation-timing-function"]=!1,e.azimuth=!1,e["backface-visibility"]=!1,e.background=!0,e["background-attachment"]=!0,e["background-clip"]=!0,e["background-color"]=!0,e["background-image"]=!0,e["background-origin"]=!0,e["background-position"]=!0,e["background-repeat"]=!0,e["background-size"]=!0,e["baseline-shift"]=!1,e.binding=!1,e.bleed=!1,e["bookmark-label"]=!1,e["bookmark-level"]=!1,e["bookmark-state"]=!1,e.border=!0,e["border-bottom"]=!0,e["border-bottom-color"]=!0,e["border-bottom-left-radius"]=!0,e["border-bottom-right-radius"]=!0,e["border-bottom-style"]=!0,e["border-bottom-width"]=!0,e["border-collapse"]=!0,e["border-color"]=!0,e["border-image"]=!0,e["border-image-outset"]=!0,e["border-image-repeat"]=!0,e["border-image-slice"]=!0,e["border-image-source"]=!0,e["border-image-width"]=!0,e["border-left"]=!0,e["border-left-color"]=!0,e["border-left-style"]=!0,e["border-left-width"]=!0,e["border-radius"]=!0,e["border-right"]=!0,e["border-right-color"]=!0,e["border-right-style"]=!0,e["border-right-width"]=!0,e["border-spacing"]=!0,e["border-style"]=!0,e["border-top"]=!0,e["border-top-color"]=!0,e["border-top-left-radius"]=!0,e["border-top-right-radius"]=!0,e["border-top-style"]=!0,e["border-top-width"]=!0,e["border-width"]=!0,e.bottom=!1,e["box-decoration-break"]=!0,e["box-shadow"]=!0,e["box-sizing"]=!0,e["box-snap"]=!0,e["box-suppress"]=!0,e["break-after"]=!0,e["break-before"]=!0,e["break-inside"]=!0,e["caption-side"]=!1,e.chains=!1,e.clear=!0,e.clip=!1,e["clip-path"]=!1,e["clip-rule"]=!1,e.color=!0,e["color-interpolation-filters"]=!0,e["column-count"]=!1,e["column-fill"]=!1,e["column-gap"]=!1,e["column-rule"]=!1,e["column-rule-color"]=!1,e["column-rule-style"]=!1,e["column-rule-width"]=!1,e["column-span"]=!1,e["column-width"]=!1,e.columns=!1,e.contain=!1,e.content=!1,e["counter-increment"]=!1,e["counter-reset"]=!1,e["counter-set"]=!1,e.crop=!1,e.cue=!1,e["cue-after"]=!1,e["cue-before"]=!1,e.cursor=!1,e.direction=!1,e.display=!0,e["display-inside"]=!0,e["display-list"]=!0,e["display-outside"]=!0,e["dominant-baseline"]=!1,e.elevation=!1,e["empty-cells"]=!1,e.filter=!1,e.flex=!1,e["flex-basis"]=!1,e["flex-direction"]=!1,e["flex-flow"]=!1,e["flex-grow"]=!1,e["flex-shrink"]=!1,e["flex-wrap"]=!1,e.float=!1,e["float-offset"]=!1,e["flood-color"]=!1,e["flood-opacity"]=!1,e["flow-from"]=!1,e["flow-into"]=!1,e.font=!0,e["font-family"]=!0,e["font-feature-settings"]=!0,e["font-kerning"]=!0,e["font-language-override"]=!0,e["font-size"]=!0,e["font-size-adjust"]=!0,e["font-stretch"]=!0,e["font-style"]=!0,e["font-synthesis"]=!0,e["font-variant"]=!0,e["font-variant-alternates"]=!0,e["font-variant-caps"]=!0,e["font-variant-east-asian"]=!0,e["font-variant-ligatures"]=!0,e["font-variant-numeric"]=!0,e["font-variant-position"]=!0,e["font-weight"]=!0,e.grid=!1,e["grid-area"]=!1,e["grid-auto-columns"]=!1,e["grid-auto-flow"]=!1,e["grid-auto-rows"]=!1,e["grid-column"]=!1,e["grid-column-end"]=!1,e["grid-column-start"]=!1,e["grid-row"]=!1,e["grid-row-end"]=!1,e["grid-row-start"]=!1,e["grid-template"]=!1,e["grid-template-areas"]=!1,e["grid-template-columns"]=!1,e["grid-template-rows"]=!1,e["hanging-punctuation"]=!1,e.height=!0,e.hyphens=!1,e.icon=!1,e["image-orientation"]=!1,e["image-resolution"]=!1,e["ime-mode"]=!1,e["initial-letters"]=!1,e["inline-box-align"]=!1,e["justify-content"]=!1,e["justify-items"]=!1,e["justify-self"]=!1,e.left=!1,e["letter-spacing"]=!0,e["lighting-color"]=!0,e["line-box-contain"]=!1,e["line-break"]=!1,e["line-grid"]=!1,e["line-height"]=!1,e["line-snap"]=!1,e["line-stacking"]=!1,e["line-stacking-ruby"]=!1,e["line-stacking-shift"]=!1,e["line-stacking-strategy"]=!1,e["list-style"]=!0,e["list-style-image"]=!0,e["list-style-position"]=!0,e["list-style-type"]=!0,e.margin=!0,e["margin-bottom"]=!0,e["margin-left"]=!0,e["margin-right"]=!0,e["margin-top"]=!0,e["marker-offset"]=!1,e["marker-side"]=!1,e.marks=!1,e.mask=!1,e["mask-box"]=!1,e["mask-box-outset"]=!1,e["mask-box-repeat"]=!1,e["mask-box-slice"]=!1,e["mask-box-source"]=!1,e["mask-box-width"]=!1,e["mask-clip"]=!1,e["mask-image"]=!1,e["mask-origin"]=!1,e["mask-position"]=!1,e["mask-repeat"]=!1,e["mask-size"]=!1,e["mask-source-type"]=!1,e["mask-type"]=!1,e["max-height"]=!0,e["max-lines"]=!1,e["max-width"]=!0,e["min-height"]=!0,e["min-width"]=!0,e["move-to"]=!1,e["nav-down"]=!1,e["nav-index"]=!1,e["nav-left"]=!1,e["nav-right"]=!1,e["nav-up"]=!1,e["object-fit"]=!1,e["object-position"]=!1,e.opacity=!1,e.order=!1,e.orphans=!1,e.outline=!1,e["outline-color"]=!1,e["outline-offset"]=!1,e["outline-style"]=!1,e["outline-width"]=!1,e.overflow=!1,e["overflow-wrap"]=!1,e["overflow-x"]=!1,e["overflow-y"]=!1,e.padding=!0,e["padding-bottom"]=!0,e["padding-left"]=!0,e["padding-right"]=!0,e["padding-top"]=!0,e.page=!1,e["page-break-after"]=!1,e["page-break-before"]=!1,e["page-break-inside"]=!1,e["page-policy"]=!1,e.pause=!1,e["pause-after"]=!1,e["pause-before"]=!1,e.perspective=!1,e["perspective-origin"]=!1,e.pitch=!1,e["pitch-range"]=!1,e["play-during"]=!1,e.position=!1,e["presentation-level"]=!1,e.quotes=!1,e["region-fragment"]=!1,e.resize=!1,e.rest=!1,e["rest-after"]=!1,e["rest-before"]=!1,e.richness=!1,e.right=!1,e.rotation=!1,e["rotation-point"]=!1,e["ruby-align"]=!1,e["ruby-merge"]=!1,e["ruby-position"]=!1,e["shape-image-threshold"]=!1,e["shape-outside"]=!1,e["shape-margin"]=!1,e.size=!1,e.speak=!1,e["speak-as"]=!1,e["speak-header"]=!1,e["speak-numeral"]=!1,e["speak-punctuation"]=!1,e["speech-rate"]=!1,e.stress=!1,e["string-set"]=!1,e["tab-size"]=!1,e["table-layout"]=!1,e["text-align"]=!0,e["text-align-last"]=!0,e["text-combine-upright"]=!0,e["text-decoration"]=!0,e["text-decoration-color"]=!0,e["text-decoration-line"]=!0,e["text-decoration-skip"]=!0,e["text-decoration-style"]=!0,e["text-emphasis"]=!0,e["text-emphasis-color"]=!0,e["text-emphasis-position"]=!0,e["text-emphasis-style"]=!0,e["text-height"]=!0,e["text-indent"]=!0,e["text-justify"]=!0,e["text-orientation"]=!0,e["text-overflow"]=!0,e["text-shadow"]=!0,e["text-space-collapse"]=!0,e["text-transform"]=!0,e["text-underline-position"]=!0,e["text-wrap"]=!0,e.top=!1,e.transform=!1,e["transform-origin"]=!1,e["transform-style"]=!1,e.transition=!1,e["transition-delay"]=!1,e["transition-duration"]=!1,e["transition-property"]=!1,e["transition-timing-function"]=!1,e["unicode-bidi"]=!1,e["vertical-align"]=!1,e.visibility=!1,e["voice-balance"]=!1,e["voice-duration"]=!1,e["voice-family"]=!1,e["voice-pitch"]=!1,e["voice-range"]=!1,e["voice-rate"]=!1,e["voice-stress"]=!1,e["voice-volume"]=!1,e.volume=!1,e["white-space"]=!1,e.widows=!1,e.width=!0,e["will-change"]=!1,e["word-break"]=!0,e["word-spacing"]=!0,e["word-wrap"]=!0,e["wrap-flow"]=!1,e["wrap-through"]=!1,e["writing-mode"]=!1,e["z-index"]=!1,e}function be(e,r,t){}function ve(e,r,t){}var ye=/javascript\s*\:/img;function we(e,r){return ye.test(r)?"":r}w.whiteList=ee();w.getDefaultWhiteList=ee;w.onAttr=be;w.onIgnoreAttr=ve;w.safeAttrValue=we;var Ae={indexOf:function(e,r){var t,a;if(Array.prototype.indexOf)return e.indexOf(r);for(t=0,a=e.length;t<a;t++)if(e[t]===r)return t;return-1},forEach:function(e,r,t){var a,i;if(Array.prototype.forEach)return e.forEach(r,t);for(a=0,i=e.length;a<i;a++)r.call(t,e[a],a,e)},trim:function(e){return String.prototype.trim?e.trim():e.replace(/(^\s*)|(\s*$)/g,"")},trimRight:function(e){return String.prototype.trimRight?e.trimRight():e.replace(/(\s*$)/g,"")}},E=Ae;function xe(e,r){e=E.trimRight(e),e[e.length-1]!==";"&&(e+=";");var t=e.length,a=!1,i=0,s=0,l="";function n(){if(!a){var c=E.trim(e.slice(i,s)),f=c.indexOf(":");if(f!==-1){var g=E.trim(c.slice(0,f)),d=E.trim(c.slice(f+1));if(g){var h=r(i,l.length,g,d,c);h&&(l+=h+"; ")}}}i=s+1}for(;s<t;s++){var o=e[s];if(o==="/"&&e[s+1]==="*"){var u=e.indexOf("*/",s+2);if(u===-1)break;s=u+1,i=s+1,a=!1}else o==="("?a=!0:o===")"?a=!1:o===";"?a||n():o===`
|
|
3
3
|
`&&n()}return E.trim(l)}var Te=xe,_=w,Se=Te;function J(e){return e==null}function ke(e){var r={};for(var t in e)r[t]=e[t];return r}function te(e){e=ke(e||{}),e.whiteList=e.whiteList||_.whiteList,e.onAttr=e.onAttr||_.onAttr,e.onIgnoreAttr=e.onIgnoreAttr||_.onIgnoreAttr,e.safeAttrValue=e.safeAttrValue||_.safeAttrValue,this.options=e}te.prototype.process=function(e){if(e=e||"",e=e.toString(),!e)return"";var r=this,t=r.options,a=t.whiteList,i=t.onAttr,s=t.onIgnoreAttr,l=t.safeAttrValue,n=Se(e,function(o,u,c,f,g){var d=a[c],h=!1;if(d===!0?h=d:typeof d=="function"?h=d(f):d instanceof RegExp&&(h=d.test(f)),h!==!0&&(h=!1),f=l(c,f),!!f){var b={position:u,sourcePosition:o,source:g,isWhite:h};if(h){var m=i(c,f,b);return J(m)?c+":"+f:m}else{var m=s(c,f,b);if(!J(m))return m}}});return n};var Le=te;(function(e,r){var t=w,a=Le;function i(l,n){var o=new a(n);return o.process(l)}r=e.exports=i,r.FilterCSS=a;for(var s in t)r[s]=t[s]})(q,q.exports);var U=q.exports,H={indexOf:function(e,r){var t,a;if(Array.prototype.indexOf)return e.indexOf(r);for(t=0,a=e.length;t<a;t++)if(e[t]===r)return t;return-1},forEach:function(e,r,t){var a,i;if(Array.prototype.forEach)return e.forEach(r,t);for(a=0,i=e.length;a<i;a++)r.call(t,e[a],a,e)},trim:function(e){return String.prototype.trim?e.trim():e.replace(/(^\s*)|(\s*$)/g,"")},spaceIndex:function(e){var r=/\s|\n|\t/,t=r.exec(e);return t?t.index:-1}},Ee=U.FilterCSS,Oe=U.getDefaultWhiteList,R=H;function re(){return{a:["target","href","title"],abbr:["title"],address:[],area:["shape","coords","href","alt"],article:[],aside:[],audio:["autoplay","controls","crossorigin","loop","muted","preload","src"],b:[],bdi:["dir"],bdo:["dir"],big:[],blockquote:["cite"],br:[],caption:[],center:[],cite:[],code:[],col:["align","valign","span","width"],colgroup:["align","valign","span","width"],dd:[],del:["datetime"],details:["open"],div:[],dl:[],dt:[],em:[],figcaption:[],figure:[],font:["color","size","face"],footer:[],h1:[],h2:[],h3:[],h4:[],h5:[],h6:[],header:[],hr:[],i:[],img:["src","alt","title","width","height"],ins:["datetime"],li:[],mark:[],nav:[],ol:[],p:[],pre:[],s:[],section:[],small:[],span:[],sub:[],summary:[],sup:[],strong:[],strike:[],table:["width","border","align","valign"],tbody:["align","valign"],td:["width","rowspan","colspan","align","valign"],tfoot:["align","valign"],th:["width","rowspan","colspan","align","valign"],thead:["align","valign"],tr:["rowspan","align","valign"],tt:[],u:[],ul:[],video:["autoplay","controls","crossorigin","loop","muted","playsinline","poster","preload","src","height","width"]}}var ae=new Ee;function Ce(e,r,t){}function _e(e,r,t){}function Ie(e,r,t){}function Pe(e,r,t){}function ie(e){return e.replace(Ve,"<").replace(Re,">")}function Fe(e,r,t,a){if(t=ue(t),r==="href"||r==="src"){if(t=R.trim(t),t==="#")return"#";if(!(t.substr(0,7)==="http://"||t.substr(0,8)==="https://"||t.substr(0,7)==="mailto:"||t.substr(0,4)==="tel:"||t.substr(0,11)==="data:image/"||t.substr(0,6)==="ftp://"||t.substr(0,2)==="./"||t.substr(0,3)==="../"||t[0]==="#"||t[0]==="/"))return""}else if(r==="background"){if(I.lastIndex=0,I.test(t))return""}else if(r==="style"){if(Z.lastIndex=0,Z.test(t)||(K.lastIndex=0,K.test(t)&&(I.lastIndex=0,I.test(t))))return"";a!==!1&&(a=a||ae,t=a.process(t))}return t=ce(t),t}var Ve=/</g,Re=/>/g,Ne=/"/g,$e=/"/g,ze=/&#([a-zA-Z0-9]*);?/gim,We=/:?/gim,De=/&newline;?/gim,I=/((j\s*a\s*v\s*a|v\s*b|l\s*i\s*v\s*e)\s*s\s*c\s*r\s*i\s*p\s*t\s*|m\s*o\s*c\s*h\s*a):/gi,Z=/e\s*x\s*p\s*r\s*e\s*s\s*s\s*i\s*o\s*n\s*\(.*/gi,K=/u\s*r\s*l\s*\(.*/gi;function se(e){return e.replace(Ne,""")}function ne(e){return e.replace($e,'"')}function oe(e){return e.replace(ze,function(t,a){return a[0]==="x"||a[0]==="X"?String.fromCharCode(parseInt(a.substr(1),16)):String.fromCharCode(parseInt(a,10))})}function le(e){return e.replace(We,":").replace(De," ")}function fe(e){for(var r="",t=0,a=e.length;t<a;t++)r+=e.charCodeAt(t)<32?" ":e.charAt(t);return R.trim(r)}function ue(e){return e=ne(e),e=oe(e),e=le(e),e=fe(e),e}function ce(e){return e=se(e),e=ie(e),e}function qe(){return""}function Ue(e,r){typeof r!="function"&&(r=function(){});var t=!Array.isArray(e);function a(l){return t?!0:R.indexOf(e,l)!==-1}var i=[],s=!1;return{onIgnoreTag:function(l,n,o){if(a(l))if(o.isClosing){var u="[/removed]",c=o.position+u.length;return i.push([s!==!1?s:o.position,c]),s=!1,u}else return s||(s=o.position),"[removed]";else return r(l,n,o)},remove:function(l){var n="",o=0;return R.forEach(i,function(u){n+=l.slice(o,u[0]),o=u[1]}),n+=l.slice(o),n}}}function He(e){for(var r="",t=0;t<e.length;){var a=e.indexOf("<!--",t);if(a===-1){r+=e.slice(t);break}r+=e.slice(t,a);var i=e.indexOf("-->",a);if(i===-1)break;t=i+3}return r}function Xe(e){var r=e.split("");return r=r.filter(function(t){var a=t.charCodeAt(0);return a===127?!1:a<=31?a===10||a===13:!0}),r.join("")}p.whiteList=re();p.getDefaultWhiteList=re;p.onTag=Ce;p.onIgnoreTag=_e;p.onTagAttr=Ie;p.onIgnoreTagAttr=Pe;p.safeAttrValue=Fe;p.escapeHtml=ie;p.escapeQuote=se;p.unescapeQuote=ne;p.escapeHtmlEntities=oe;p.escapeDangerHtml5Entities=le;p.clearNonPrintableCharacter=fe;p.friendlyAttrValue=ue;p.escapeAttrValue=ce;p.onIgnoreTagStripAll=qe;p.StripTagBody=Ue;p.stripCommentTag=He;p.stripBlankChar=Xe;p.cssFilter=ae;p.getDefaultCSSWhiteList=Oe;var N={},y=H;function Ge(e){var r=y.spaceIndex(e),t;return r===-1?t=e.slice(1,-1):t=e.slice(1,r+1),t=y.trim(t).toLowerCase(),t.slice(0,1)==="/"&&(t=t.slice(1)),t.slice(-1)==="/"&&(t=t.slice(0,-1)),t}function Me(e){return e.slice(0,2)==="</"}function je(e,r,t){var a="",i=0,s=!1,l=!1,n=0,o=e.length,u="",c="";e:for(n=0;n<o;n++){var f=e.charAt(n);if(s===!1){if(f==="<"){s=n;continue}}else if(l===!1){if(f==="<"){a+=t(e.slice(i,n)),s=n,i=n;continue}if(f===">"){a+=t(e.slice(i,s)),c=e.slice(s,n+1),u=Ge(c),a+=r(s,a.length,u,c,Me(c)),i=n+1,s=!1;continue}if(f==='"'||f==="'")for(var g=1,d=e.charAt(n-g);d.trim()===""||d==="=";){if(d==="="){l=f;continue e}d=e.charAt(n-++g)}}else if(f===l){l=!1;continue}}return i<e.length&&(a+=t(e.substr(i))),a}var Be=/[^a-zA-Z0-9\\_:.-]/gim;function Qe(e,r){var t=0,a=0,i=[],s=!1,l=e.length;function n(g,d){if(g=y.trim(g),g=g.replace(Be,"").toLowerCase(),!(g.length<1)){var h=r(g,d||"");h&&i.push(h)}}for(var o=0;o<l;o++){var u=e.charAt(o),c,f;if(s===!1&&u==="="){s=e.slice(t,o),t=o+1,a=e.charAt(t)==='"'||e.charAt(t)==="'"?t:Ze(e,o+1);continue}if(s!==!1&&o===a){if(f=e.indexOf(u,o+1),f===-1)break;c=y.trim(e.slice(a+1,f)),n(s,c),s=!1,o=f,t=o+1;continue}if(/\s|\n|\t/.test(u))if(e=e.replace(/\s|\n|\t/g," "),s===!1)if(f=Je(e,o),f===-1){c=y.trim(e.slice(t,o)),n(c),s=!1,t=o+1;continue}else{o=f-1;continue}else if(f=Ke(e,o-1),f===-1){c=y.trim(e.slice(t,o)),c=Y(c),n(s,c),s=!1,t=o+1;continue}else continue}return t<e.length&&(s===!1?n(e.slice(t)):n(s,Y(y.trim(e.slice(t))))),y.trim(i.join(" "))}function Je(e,r){for(;r<e.length;r++){var t=e[r];if(t!==" ")return t==="="?r:-1}}function Ze(e,r){for(;r<e.length;r++){var t=e[r];if(t!==" ")return t==="'"||t==='"'?r:-1}}function Ke(e,r){for(;r>0;r--){var t=e[r];if(t!==" ")return t==="="?r:-1}}function Ye(e){return e[0]==='"'&&e[e.length-1]==='"'||e[0]==="'"&&e[e.length-1]==="'"}function Y(e){return Ye(e)?e.substr(1,e.length-2):e}N.parseTag=je;N.parseAttr=Qe;var et=U.FilterCSS,v=p,ge=N,tt=ge.parseTag,rt=ge.parseAttr,F=H;function P(e){return e==null}function at(e){var r=F.spaceIndex(e);if(r===-1)return{html:"",closing:e[e.length-2]==="/"};e=F.trim(e.slice(r+1,-1));var t=e[e.length-1]==="/";return t&&(e=F.trim(e.slice(0,-1))),{html:e,closing:t}}function it(e){var r={};for(var t in e)r[t]=e[t];return r}function st(e){var r={};for(var t in e)Array.isArray(e[t])?r[t.toLowerCase()]=e[t].map(function(a){return a.toLowerCase()}):r[t.toLowerCase()]=e[t];return r}function de(e){e=it(e||{}),e.stripIgnoreTag&&(e.onIgnoreTag&&console.error('Notes: cannot use these two options "stripIgnoreTag" and "onIgnoreTag" at the same time'),e.onIgnoreTag=v.onIgnoreTagStripAll),e.whiteList||e.allowList?e.whiteList=st(e.whiteList||e.allowList):e.whiteList=v.whiteList,e.onTag=e.onTag||v.onTag,e.onTagAttr=e.onTagAttr||v.onTagAttr,e.onIgnoreTag=e.onIgnoreTag||v.onIgnoreTag,e.onIgnoreTagAttr=e.onIgnoreTagAttr||v.onIgnoreTagAttr,e.safeAttrValue=e.safeAttrValue||v.safeAttrValue,e.escapeHtml=e.escapeHtml||v.escapeHtml,this.options=e,e.css===!1?this.cssFilter=!1:(e.css=e.css||{},this.cssFilter=new et(e.css))}de.prototype.process=function(e){if(e=e||"",e=e.toString(),!e)return"";var r=this,t=r.options,a=t.whiteList,i=t.onTag,s=t.onIgnoreTag,l=t.onTagAttr,n=t.onIgnoreTagAttr,o=t.safeAttrValue,u=t.escapeHtml,c=r.cssFilter;t.stripBlankChar&&(e=v.stripBlankChar(e)),t.allowCommentTag||(e=v.stripCommentTag(e));var f=!1;t.stripIgnoreTagBody&&(f=v.StripTagBody(t.stripIgnoreTagBody,s),s=f.onIgnoreTag);var g=tt(e,function(d,h,b,m,O){var C={sourcePosition:d,position:h,isClosing:O,isWhite:Object.prototype.hasOwnProperty.call(a,b)},S=i(b,m,C);if(!P(S))return S;if(C.isWhite){if(C.isClosing)return"</"+b+">";var X=at(m),me=a[b],G=rt(X.html,function(A,x){var $=F.indexOf(me,A)!==-1,k=l(b,A,x,$);return P(k)?$?(x=o(b,A,x,c),x?A+'="'+x+'"':A):(k=n(b,A,x,$),P(k)?void 0:k):k});return m="<"+b,G&&(m+=" "+G),X.closing&&(m+=" /"),m+=">",m}else return S=s(b,m,C),P(S)?u(m):S},u);return f&&(g=f.remove(g)),g};var nt=de;(function(e,r){var t=p,a=N,i=nt;function s(n,o){var u=new i(o);return u.process(n)}r=e.exports=s,r.filterXSS=s,r.FilterXSS=i,(function(){for(var n in t)r[n]=t[n];for(var o in a)r[o]=a[o]})();function l(){return typeof self<"u"&&typeof DedicatedWorkerGlobalScope<"u"&&self instanceof DedicatedWorkerGlobalScope}l()&&(self.filterXSS=e.exports)})(D,D.exports);var T=D.exports,ot=function(e){if(typeof e!="object"||e===null||Object.prototype.toString.call(e)!=="[object Object]")return!1;var r=Object.getPrototypeOf(e);if(r===null)return!0;for(;Object.getPrototypeOf(r)!==null;)r=Object.getPrototypeOf(r);return Object.getPrototypeOf(e)===r},pe=(function(){function e(r,t){var a=this;this.arcgisWhiteList={a:["href","style","target"],abbr:["title"],article:["style"],aside:["style"],audio:["autoplay","controls","loop","muted","preload"],b:[],blockquote:["style"],br:[],code:["style"],dd:["style"],del:["style"],details:["open","style"],div:["align","aria-hidden","aria-label","style"],dl:["style"],dt:["style"],em:[],figcaption:["style"],figure:["style"],font:["color","face","size","style"],footer:["style"],h1:["style"],h2:["style"],h3:["style"],h4:["style"],h5:["style"],h6:["style"],header:["style"],hr:[],i:[],img:["alt","border","height","src","style","width"],li:[],main:["style"],mark:["style"],nav:["style"],ol:[],p:["style"],pre:["style"],section:["style"],source:["media","src","type"],span:["aria-hidden","aria-label","style"],strong:[],sub:["style"],summary:["style"],sup:["style"],table:["border","cellpadding","cellspacing","height","style","width"],tbody:[],tr:["align","height","style","valign"],td:["align","colspan","height","nowrap","rowspan","style","valign","width"],th:["align","colspan","height","nowrap","rowspan","style","valign","width"],time:["style"],u:[],ul:[],video:["autoplay","controls","height","loop","muted","poster","preload","width"]},this.arcgisCSSWhiteList=V(V({},T.getDefaultCSSWhiteList()),{"align-items":!0,"align-self":!0,flex:!0,"flex-basis":!0,"flex-direction":!0,"flex-flow":!0,"flex-grow":!0,"flex-shrink":!0,"flex-wrap":!0,float:!0,gap:!0,grid:!0,"grid-area":!0,"grid-auto-columns":!0,"grid-auto-flow":!0,"grid-auto-rows":!0,"grid-column":!0,"grid-column-end":!0,"grid-column-start":!0,"grid-row":!0,"grid-row-end":!0,"grid-row-start":!0,"grid-template":!0,"grid-template-areas":!0,"grid-template-columns":!0,"grid-template-rows":!0,"justify-content":!0,"justify-items":!0,"justify-self":!0,"line-height":!0,overflow:!0}),this.allowedProtocols=["http","https","mailto","iform","tel","flow","lfmobile","arcgis-navigator","arcgis-appstudio-player","arcgis-survey123","arcgis-collector","arcgis-workforce","arcgis-explorer","arcgis-trek2there","arcgis-quickcapture","mspbi","comgooglemaps","pdfefile","pdfehttp","pdfehttps","boxapp","boxemm","awb","awbs","gropen","radarscope"],this.arcgisFilterOptions={allowCommentTag:!0,safeAttrValue:function(s,l,n,o){return s==="a"&&l==="href"||(s==="img"||s==="source")&&l==="src"?a.sanitizeUrl(n):T.safeAttrValue(s,l,n,o)}},this._entityMap={"&":"8","<":"<",">":">",'"':""","'":"'","/":"/"};var i;r&&!t?i=r:r&&t?(i=Object.create(this.arcgisFilterOptions),i.css={whiteList:this.arcgisCSSWhiteList},Object.keys(r).forEach(function(s){if(s==="whiteList")i.whiteList=a._extendObjectOfArrays([a.arcgisWhiteList,r.whiteList||{}]);else if(s==="css"){var l=r.css.whiteList;l!=null&&r.css instanceof Object&&Object.keys(l).forEach(function(n){return i.css.whiteList[n]=l[n]})}else i[s]=r[s]})):(i=Object.create(this.arcgisFilterOptions),i.whiteList=this.arcgisWhiteList,i.css={whiteList:this.arcgisCSSWhiteList}),this.xssFilterOptions=i,this._xssFilter=new T.FilterXSS(i)}return e.prototype.sanitize=function(r,t){switch(t===void 0&&(t={}),typeof r){case"number":return isNaN(r)||!isFinite(r)?null:r;case"boolean":return r;case"string":return this._xssFilter.process(r);case"object":return this._iterateOverObject(r,t);default:return t.allowUndefined&&typeof r>"u"?void 0:null}},e.prototype.sanitizeUrl=function(r,t){var a=(t??{}).isProtocolRequired,i=a===void 0?!0:a,s=this._trim(r.substring(0,r.indexOf(":"))),l=r==="/",n=/^#/.test(r),o=s&&this.allowedProtocols.indexOf(s.toLowerCase())>-1;return l||n||o?T.escapeAttrValue(r):!s&&!i?T.escapeAttrValue("https://".concat(r)):""},e.prototype.sanitizeHTMLAttribute=function(r,t,a,i){return typeof this.xssFilterOptions.safeAttrValue=="function"?this.xssFilterOptions.safeAttrValue(r,t,a,i):T.safeAttrValue(r,t,a,i)},e.prototype.validate=function(r,t){t===void 0&&(t={});var a=this.sanitize(r,t);return{isValid:r===a,sanitized:a}},e.prototype.encodeHTML=function(r){var t=this;return String(r).replace(/[&<>"'\/]/g,function(a){return t._entityMap[a]})},e.prototype.encodeAttrValue=function(r){var t=/^[a-zA-Z0-9]$/;return String(r).replace(/[\x00-\xFF]/g,function(a,i){return t.test(a)?a:"&#x".concat(Number(r.charCodeAt(i)).toString(16),";")})},e.prototype._extendObjectOfArrays=function(r){var t={};return r.forEach(function(a){Object.keys(a).forEach(function(i){Array.isArray(a[i])&&Array.isArray(t[i])?t[i]=t[i].concat(a[i]):t[i]=a[i]})}),t},e.prototype._iterateOverObject=function(r,t){var a=this;t===void 0&&(t={});try{var i=!1,s=void 0;if(Array.isArray(r))s=r.reduce(function(n,o){var u=a.validate(o,t);return u.isValid?n.concat([o]):(i=!0,n.concat([u.sanitized]))},[]);else if(ot(r)){var l=Object.keys(r);s=l.reduce(function(n,o){var u=r[o],c=a.validate(u,t);return c.isValid?n[o]=u:(i=!0,n[o]=c.sanitized),n},{})}else return t.allowUndefined&&typeof r>"u"?void 0:null;return i?s:r}catch{return null}},e.prototype._trim=function(r){return String.prototype.trim?r.trim():r.replace(/(^\s*)|(\s*$)/g,"")},e})();W.use({gfm:!0,breaks:!0,async:!1});var lt=new pe({whiteList:{ol:["start"],li:["value"],"calcite-table":["caption","bordered","striped","layout","scale","class"],"calcite-table-row":["slot","class"],"calcite-table-header":["heading","alignment","description","class"],"calcite-table-cell":["alignment","colspan","rowspan","class"],pre:["class"],code:["class"]}},!0);function ft(e){return lt.sanitize(e)}function he(e,r){let t=e.indexOf("{",r),a=e.indexOf("[",r);return t===-1?a:a===-1?t:Math.min(t,a)}function ut(e){if(e.trimStart().startsWith("```"))return null;for(let r=he(e,0);r!==-1;r=he(e,r+1)){let t=0,a=0;for(let i=r;i<e.length;i++){let s=e[i];if(s==="{"?t++:s==="}"?t--:s==="["?a++:s==="]"&&a--,t<0||a<0)break;if(t===0&&a===0&&i>r)return e.slice(r,i+1)}}return null}function Tt(e){if(!e)return"";let r=e,t=ut(e);if(t)try{let i=JSON.parse(t),s=`
|
|
4
4
|
|
|
5
5
|
\`\`\`json
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import b from"./
|
|
2
|
+
import b from"./EIPHHMWX.js";import a from"./JMODFBN6.js";import{a as c,b as k}from"./HJG7QM2R.js";import{Va as x,a as w,b as d,j as f}from"./ZQ7PGNWB.js";import{ca as u}from"./LUY6V4TP.js";export default $arcgis.t(([,,,,,,{p:_,r:b},{K:y,L:K,M:q,N:S,O:M,P:T,Q:E,R:C,S:G,T:N,U:R,a:v,m:m,n:h,p:A}])=>{var z=[T,E,N,C,M,R,G];async function $(e,a){let o=await m("arcgis_knowledge_tool_prompt"),s=K(a),n={assignedTask:e.agentExecutionContext.assignedTask,userRequest:e.agentExecutionContext.userRequest,priorSteps:e.agentExecutionContext.priorSteps,contextType:s},r=await b({promptText:o,messages:e.arcgisKnowledgeMessages,inputVariables:n,tools:z,config:a}),i=(r.tool_calls?.length??0)>0,t=typeof r.text=="string"?r.text.trim():"",l=t.length>0,p=r.content.toString();return!i&&(s==="map"||s==="knowledgeGraph")?{...e,arcgisKnowledgeMessages:[...e.arcgisKnowledgeMessages,r],outputMessage:s==="map"?"No tools were found for the current view and prompt. Maps do not support changing nonspatial visibility, layout changes, or generation from queries.":"No tools were found for the current prompt and knowledge graph service. A knowledge graph service only supports search and query.",status:"success"}:{...e,arcgisKnowledgeMessages:[...e.arcgisKnowledgeMessages,r],outputMessage:i?p:t,status:i?e.status:l?"success":"failed",summary:p?h(p):"ArcGIS Knowledge Agent tool executed."}}var L={generateCypher:"generated-cypher-query",queryGraphData:"graph-query-result",searchGraphData:"graph-search-result",addRecords:"added-records",applyLayout:"applied-layout",changeNonspatialVisibility:"changed-nonspatial-visibility",createLinkChart:"created-link-chart"};function I(e){return!!e&&e.status==="success"&&!!L[e.toolName]}function D(e){return{type:L[e.toolName],data:e.details}}async function F(e,a){let o=new v(z,{handleToolErrors:!1});try{let s=await o.invoke({messages:e.arcgisKnowledgeMessages},a),n=[];for(let t of s.messages){let l;if(typeof t.content!="string")throw new Error(`Unexpected tool message content type: ${typeof t.content}. Expected string.`);try{l=JSON.parse(t.content)}catch{throw new Error(`Failed to parse tool message content as JSON. Tool: ${t.name??"unknown"}.
|
|
3
3
|
|
|
4
4
|
Original Content: ${t.content}`)}if(!l||typeof l!="object"||!("toolName"in l))throw new Error(`Parsed tool message content does not have expected structure. Parsed content: ${JSON.stringify(l)}`);n.push(l)}await c({text:`Finished executing ArcGIS Knowledge Agent tools: ${s.messages.filter(t=>t.name).map(t=>t.name).join(", ")}`},a);let r=n.filter(t=>typeof t!="string").map(t=>`- Called Tool: ${t.toolName}, Status: ${t.status}`),i=n[0];return i&&I(i)&&await k(D(i),a),{...e,outputMessage:r.join(`
|
|
5
5
|
`),summary:r.length?h(r.join(`
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import{a as u,b as g,c as S}from"./
|
|
2
|
+
import{a as u,b as g,c as S}from"./M3MRIGDZ.js";import a from"./MMRRNKWJ.js";import{b as m,c as f}from"./SBP6WNDY.js";import{y as p}from"./ZQ7PGNWB.js";import"./LUY6V4TP.js";import"./MWYBF3F3.js";import"./UZLQALHY.js";export default $arcgis.t(([{property:h,subclass:l},{watch:w},d])=>{var v=Object.defineProperty,y=Object.getOwnPropertyDescriptor,o=(t,e,s,r)=>{for(var i=r>1?void 0:r?y(e,s):e,a=t.length-1,c;a>=0;a--)(c=t[a])&&(i=(r?c(e,s,i):c(i))||i);return r&&i&&v(e,s,i),i},n=class extends d{constructor(t){super(t)}initialize(){this.addHandles(w(()=>[this.name,this.description,this.inputSchema,this.outputSchema,this.execute],()=>{this.generate()},{initial:!0,sync:!0}))}getSchemas(){return[this.inputSchema,this.outputSchema].filter(Boolean)}generate(){let t=m(this.getSchemas());this._set("workspace",t);let e=`${this.id}-execute`,s={[e]:this._invokeExecuteNode.bind(this)},r=[{from:e,decide:()=>{}}];this._set("createGraph",()=>f(s,r,t,{agent:this,entryNode:e,middlewares:this.middlewares}))}async _invokeExecuteNode(t,e){try{return this.outputSchema?await this._invokeStructured(t,e):await this._invokeUnstructured(t,e)}catch(s){if(p(s))throw s;let r=s instanceof Error?s.message:String(s);return u({outputMessage:r},"failed",r)}}async _invokeStructured(t,e){if(!this.outputSchema)throw new Error("Output schema is required for structured invocation.");let s=this._validateInputState(t),r=await this.execute(s,e);if(typeof r=="string")throw new Error("Expected execute function to return an object matching the output schema, but received a string.");return g(r,this.outputSchema,t.agentExecutionContext.messages)}async _invokeUnstructured(t,e){let s=this._validateInputState(t),r=await this.execute(s,e),i=typeof r=="string"?r:JSON.stringify(r),a=i.trim()||"FunctionAgent completed.";return u({outputMessage:i},"success",a)}_validateInputState(t){if(!this.inputSchema)return t;let e=this.inputSchema.safeParse(S(t,this.inputSchema));if(!e.success)throw new Error(`FunctionAgent input schema validation failed: ${e.error.message}`);return{...t,...e.data}}};o([h()],n.prototype,"inputSchema",2);o([h()],n.prototype,"outputSchema",2);o([h()],n.prototype,"execute",2);n=o([l("FunctionAgent")],n);return n},"core/accessorSupport/decorators","core/reactiveUtils",a)
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import{g as i,h as a,v as e,z as t}from"./
|
|
2
|
+
import{g as i,h as a,v as e,z as t}from"./NAKAZDJ7.js";import"./R74ZHFA6.js";import"./UZLQALHY.js";var n=i`:host{display:contents}.icon{padding:var(--calcite-spacing-sm);border-radius:var(--calcite-spacing-xl);background:var(--calcite-color-brand);color:var(--calcite-color-foreground-1)}.loading-container{display:flex;flex-direction:column;gap:var(--calcite-spacing-sm);padding:0 var(--calcite-spacing-sm)}.loading{display:flex;align-items:center;gap:var(--calcite-spacing-sm)}.text{font-style:italic;word-wrap:break-word;word-break:break-all;overflow:hidden;text-overflow:ellipsis;display:-webkit-box;-webkit-line-clamp:1;line-clamp:1;-webkit-box-orient:vertical}.skeleton-block{display:flex;flex-direction:column;gap:var(--calcite-spacing-sm);width:100%}.skeleton-text{display:block;height:.95em;border-radius:var(--calcite-border-radius);background:linear-gradient(90deg,color-mix(in srgb,var(--calcite-color-foreground-2) 65%,transparent),color-mix(in srgb,var(--calcite-color-foreground-3) 85%,transparent),color-mix(in srgb,var(--calcite-color-foreground-2) 65%,transparent));background-size:200% 100%;animation:assistant-message-loading-shimmer 1.2s ease-in-out infinite;width:85%}.skeleton-text:last-child{width:70%}@keyframes assistant-message-loading-shimmer{0%{background-position:-150% 0}to{background-position:150% 0}}@media(prefers-reduced-motion){.skeleton-text{animation:none}}`,s=class extends e{constructor(){super(...arguments),this.loading=!1,this.loadingMessage="",this.assistantAvatarEnabled=!1}static{this.properties={loading:5,loadingMessage:1,assistantAvatarEnabled:5,interrupts:0}}static{this.styles=n}render(){return this.loading?a`<arcgis-assistant-message footer-disabled>${this.assistantAvatarEnabled?a`<slot name=icon slot=icon><calcite-icon class="icon" icon=effects scale=s></calcite-icon></slot>`:null}<slot name=content slot=content><arcgis-assistant-interrupt-preview .interrupts=${this.interrupts}></arcgis-assistant-interrupt-preview><div class="loading-container"><div class="loading"><calcite-loader label=loading inline></calcite-loader><div class="text">${this.loadingMessage}</div></div><div class="skeleton-block"><span class="skeleton-text"></span><span class="skeleton-text"></span></div></div></slot></arcgis-assistant-message>`:null}};t("arcgis-assistant-message-loading",s);export{s as ArcgisAssistantMessageLoading};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import{g as i,h as s,v as n,z as o}from"./
|
|
2
|
+
import{g as i,h as s,v as n,z as o}from"./NAKAZDJ7.js";import"./R74ZHFA6.js";import"./UZLQALHY.js";var c=i`:host{display:block}`,e=class extends n{static{this.properties={block:0}}static{this.styles=c}_renderSuggestedPrompts(t){if(t.type!=="suggested-prompts")return null;let r=t.data?.prompts,a=Array.isArray(r)?r.filter(p=>typeof p=="string"):[];return a.length?s`<arcgis-assistant-suggested-prompts .prompts=${a}></arcgis-assistant-suggested-prompts>`:null}_renderBlock(t){switch(t.type){case"suggested-prompts":return this._renderSuggestedPrompts(t);case"text":return s`<arcgis-assistant-message-text .content=${t.data?.content} .parts=${t.data?.parts}></arcgis-assistant-message-text>`;default:return null}}render(){return this.block?this._renderBlock(this.block):null}};o("arcgis-assistant-message-block",e);export{e as ArcgisAssistantMessageBlock};
|