@arcgis/ai-components 6.0.0-next.0 → 6.0.0-next.2
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/agent-utils/BaseAgent.js +1 -1
- package/dist/agent-utils/FunctionAgent.js +1 -1
- package/dist/agent-utils/LLMAgent.d.ts +9 -2
- package/dist/agent-utils/LLMAgent.js +46 -37
- package/dist/agent-utils/SkillAgent.js +1 -1
- package/dist/agent-utils/WorkflowAgent.js +1 -1
- package/dist/agent-utils/createSchema.js +1 -1
- package/dist/agent-utils/middlewares/humanInTheLoop.js +1 -1
- package/dist/agent-utils/middlewares/middleware.js +1 -1
- package/dist/agent-utils/middlewares/trace.js +1 -1
- package/dist/agent-utils/middlewares/types.js +1 -1
- package/dist/agent-utils/tools/FunctionTool.d.ts +12 -1
- package/dist/agent-utils/tools/FunctionTool.js +16 -15
- package/dist/agent-utils/tools/MCPToolProvider.d.ts +54 -0
- package/dist/agent-utils/tools/MCPToolProvider.js +120 -0
- package/dist/agent-utils/tools/ToolProvider.d.ts +13 -0
- package/dist/agent-utils/tools/WebMCPToolProvider.d.ts +37 -0
- package/dist/agent-utils/tools/WebMCPToolProvider.js +71 -0
- package/dist/agent-utils/workflows/ConditionalWorkflow.js +1 -1
- package/dist/agent-utils/workflows/LoopWorkflow.js +1 -1
- package/dist/agent-utils/workflows/ParallelWorkflow.js +1 -1
- package/dist/agent-utils/workflows/RouterWorkflow.js +1 -1
- package/dist/agent-utils/workflows/SequentialWorkflow.js +1 -1
- package/dist/agent-utils/workflows/SwitchWorkflow.js +1 -1
- package/dist/agents/agents/arcgisKnowledge/graph/arcgisKnowledgeGraph.js +1 -1
- package/dist/agents/agents/dataExploration/dataExplorationAgent.js +1 -1
- package/dist/agents/agents/dataExplorationGraph/graph/dataExplorationGraph.js +1 -1
- package/dist/agents/agents/help/helpAgent.js +1 -1
- package/dist/agents/agents/helpGraph/graph/helpGraph.js +1 -1
- package/dist/agents/agents/layerStyling/context/layerStylingContext.js +1 -1
- package/dist/agents/agents/layerStyling/graph/layerStylingGraph.js +1 -1
- package/dist/agents/agents/navigation/navigationAgent.js +1 -1
- package/dist/agents/agents/navigationGraph/graph/navigationGraph.js +1 -1
- package/dist/agents/tools/filter/clearFilters/adapter.js +1 -1
- package/dist/agents/tools/filter/resetMap/adapter.js +1 -1
- package/dist/agents/tools/filter/setFeatureEffect/adapter.js +1 -1
- package/dist/agents/tools/help/listFields/adapter.js +1 -1
- package/dist/agents/tools/navigation/goToAddress/adapter.js +1 -1
- package/dist/agents/tools/navigation/goToBookmark/adapter.js +1 -1
- package/dist/agents/tools/navigation/goToFeatures/adapter.js +1 -1
- package/dist/agents/tools/navigation/goToFullExtent/adapter.js +1 -1
- package/dist/agents/tools/navigation/goToHomeExtent/adapter.js +1 -1
- package/dist/agents/tools/navigation/goToLayer/adapter.js +1 -1
- package/dist/agents/tools/navigation/goToScale/adapter.js +1 -1
- package/dist/agents/tools/navigation/goToViewpoint/adapter.js +1 -1
- package/dist/agents/tools/navigation/goToZoom/adapter.js +1 -1
- package/dist/agents/tools/query/getAttribute/adapter.js +29 -25
- package/dist/agents/tools/query/getStatistics/adapter.js +71 -67
- package/dist/agents/tools/query/getTopFeatures/adapter.js +75 -71
- package/dist/agents/tools/query/queryFeatures/adapter.js +41 -37
- package/dist/agents/tools/search/findRelevantFields/adapter.js +1 -1
- package/dist/agents/tools/search/findRelevantLayers/adapter.js +1 -1
- package/dist/agents/tools/shared/resolveToolArtifact.js +1 -1
- package/dist/agents/tools/shared/types.js +1 -1
- package/dist/cdn/24KEZCPF.js +2 -0
- package/dist/cdn/{2UKFCF2J.js → 272R36XK.js} +2 -2
- package/dist/cdn/{FX4LV2S3.js → 2H32MDP2.js} +1 -1
- package/dist/cdn/{VAXH6RUQ.js → 2HNGMLFD.js} +2 -2
- package/dist/cdn/{3HV6OXCZ.js → 2JD3G7IW.js} +2 -2
- package/dist/cdn/2NOLMOEP.js +9 -0
- package/dist/cdn/{ZU2FHVNK.js → 2OW3DCUT.js} +2 -2
- package/dist/cdn/2PGZDONH.js +2 -0
- package/dist/cdn/2WY5MPMY.js +2 -0
- package/dist/cdn/{4OLV5LA7.js → 3COVQI26.js} +2 -2
- package/dist/cdn/{VIJVRJHL.js → 3UVQLYUK.js} +2 -2
- package/dist/cdn/{BIEX4MVV.js → 5HNKH5OK.js} +2 -2
- package/dist/cdn/{46DT6BIG.js → 5INBG23U.js} +1 -1
- package/dist/cdn/{MHUEU6MR.js → 5LBUP33F.js} +2 -2
- package/dist/cdn/{UZLQALHY.js → 5PV2GUZW.js} +1 -1
- package/dist/cdn/{UYEF3IKE.js → 5SRRG7WG.js} +2 -2
- package/dist/cdn/{AMFZY5QK.js → 5XZ5VL42.js} +2 -2
- package/dist/cdn/{IEAHAC6B.js → 63OF33IL.js} +2 -2
- package/dist/cdn/{7OQA4GCM.js → 6ELWX4W5.js} +2 -2
- package/dist/cdn/{OKVLGJAG.js → 6J3J7VLW.js} +2 -2
- package/dist/cdn/{AOVJ34QE.js → 6QOSUG64.js} +2 -2
- package/dist/cdn/{GVFJHADC.js → 6UGT2UG5.js} +2 -2
- package/dist/cdn/{VVWKEN53.js → 7APXFHDF.js} +3 -3
- package/dist/cdn/{QJOO6IIX.js → 7GDMXAF5.js} +2 -2
- package/dist/cdn/7JIXXYZR.js +2 -0
- package/dist/cdn/{2ZH5JNHL.js → 7OQK2F7O.js} +2 -2
- package/dist/cdn/{I7PHDOEQ.js → 7XVIZ7HK.js} +2 -2
- package/dist/cdn/{TRZJYWEB.js → A4ZVCRVF.js} +3 -3
- package/dist/cdn/{OVIQ5NSE.js → AGDGDULE.js} +2 -2
- package/dist/cdn/{TPULIO6I.js → AMA67DVI.js} +2 -2
- package/dist/cdn/AO42IPOX.js +2 -0
- package/dist/cdn/AOT3PM2Q.js +2 -0
- package/dist/cdn/{YO3L3XIH.js → AQ7KG25Q.js} +2 -2
- package/dist/cdn/{KKXOSV62.js → AWH4VDPD.js} +2 -2
- package/dist/cdn/AY2ZONWQ.js +2 -0
- package/dist/cdn/{B2JRBDJZ.js → BMVPOFHU.js} +2 -2
- package/dist/cdn/BWUQRZPK.js +2 -0
- package/dist/cdn/{EXIA3APU.js → C3VLDYS2.js} +2 -2
- package/dist/cdn/{PQ2DPOFM.js → C5Q6E7UC.js} +2 -2
- package/dist/cdn/{FDOMMK2M.js → CETIZ4IQ.js} +1 -1
- package/dist/cdn/{W3OJTTVX.js → COANVCKH.js} +2 -2
- package/dist/cdn/D7CRICBG.js +2 -0
- package/dist/cdn/D7FEOAW3.js +2 -0
- package/dist/cdn/{37EJSNE3.js → DY6MO2CA.js} +2 -2
- package/dist/cdn/EKMCGN6R.js +2 -0
- package/dist/cdn/EUIURCPS.js +2 -0
- package/dist/cdn/{NN6MELJ7.js → FGQH46Z2.js} +2 -2
- package/dist/cdn/FIZMK7GS.js +1 -0
- package/dist/cdn/FONIQ7VF.js +2 -0
- package/dist/cdn/G3KILEGJ.js +2 -0
- package/dist/cdn/{FYZATVB3.js → G7MCIFV2.js} +2 -2
- package/dist/cdn/{SDWWUWAF.js → GGAXXX5X.js} +2 -2
- package/dist/cdn/GS5JDPZH.js +2 -0
- package/dist/cdn/{KJZVYKWL.js → H4QWVTEZ.js} +2 -2
- package/dist/cdn/{HWNPZ4CF.js → H6J65TWL.js} +2 -2
- package/dist/cdn/{UHEYPSOR.js → HCPI2RJE.js} +2 -2
- package/dist/cdn/{TPMZRJEC.js → HJOWCZPL.js} +2 -2
- package/dist/cdn/HOMSK66Q.js +2 -0
- package/dist/cdn/{SBIYXWXZ.js → HTNKDDEV.js} +2 -2
- package/dist/cdn/{OFM2S6U7.js → HU527DML.js} +2 -2
- package/dist/cdn/I37ZJHTM.js +2 -0
- package/dist/cdn/{7DRHB24Z.js → I724KIFI.js} +2 -2
- package/dist/cdn/IH5P2PWJ.js +2 -0
- package/dist/cdn/{ZBRZU4XB.js → J3T5HB77.js} +2 -2
- package/dist/cdn/{ZMMUAYDN.js → JCWFLYB4.js} +2 -2
- package/dist/cdn/{IHP25JWI.js → JSRNLNOE.js} +2 -2
- package/dist/cdn/{MPWEXYYB.js → KDA5VPLO.js} +2 -2
- package/dist/cdn/KRPPMEOF.js +2 -0
- package/dist/cdn/{W6TS2TIE.js → KURNYULZ.js} +2 -2
- package/dist/cdn/{YOQCQAKT.js → L46O52F7.js} +2 -2
- package/dist/cdn/{W3ZLMBEE.js → L5OYOLWV.js} +3 -3
- package/dist/cdn/{M7TMD2HP.js → LDDP7NSY.js} +2 -2
- package/dist/cdn/{ZQTCPJUV.js → LGIXZLOP.js} +2 -2
- package/dist/cdn/{ENVTUTY6.js → LMAIOLS2.js} +2 -2
- package/dist/cdn/{CFAC4FN3.js → LWEKPFV6.js} +2 -2
- package/dist/cdn/M52LKZN7.js +2 -0
- package/dist/cdn/{6GQCLDLJ.js → M5UMOOL2.js} +2 -2
- package/dist/cdn/MHXM37QI.js +2 -0
- package/dist/cdn/{XI4BPYGB.js → MR3R5YHQ.js} +2 -2
- package/dist/cdn/{H7WJUUJT.js → MUSLUFKI.js} +2 -2
- package/dist/cdn/MYLY2ABI.js +2 -0
- package/dist/cdn/{2XXM52PS.js → N2GN5WOI.js} +3 -3
- package/dist/cdn/{2FUTKTNO.js → NAVK5JJ2.js} +3 -3
- package/dist/cdn/NDSYDURO.js +2 -0
- package/dist/cdn/{EU6YSCZL.js → NK2QRPS6.js} +2 -2
- package/dist/cdn/{GMZUN5SF.js → NYFL2F5L.js} +2 -2
- package/dist/cdn/{O62IJLTZ.js → OKDXM5D4.js} +2 -2
- package/dist/cdn/{I5OBL24F.js → OMUWBY75.js} +2 -2
- package/dist/cdn/{34O57OGV.js → OPQCY33W.js} +1 -1
- package/dist/cdn/{R74ZHFA6.js → OUMTV5H5.js} +1 -1
- package/dist/cdn/OZDRETY2.js +5 -0
- package/dist/cdn/{DYSPEU7W.js → PR4VMSKD.js} +1 -1
- package/dist/cdn/{V7ERVXIO.js → PXBS2FXE.js} +2 -2
- package/dist/cdn/{B4C7NIB5.js → Q7BJGEFH.js} +3 -3
- package/dist/cdn/QAVDW7A7.js +2 -0
- package/dist/cdn/{ONQ6JSBJ.js → QBZP6XOE.js} +1 -1
- package/dist/cdn/{OT5ECP4V.js → RFIN7KO6.js} +2 -2
- package/dist/cdn/RNJ7T5GF.js +2 -0
- package/dist/cdn/{Q6PCXSZT.js → S6OUM5X2.js} +2 -2
- package/dist/cdn/SG6PAUVR.js +2 -0
- package/dist/cdn/{U53SVXZK.js → SRXUC4QB.js} +2 -2
- package/dist/cdn/SUMXIUIS.js +2 -0
- package/dist/cdn/SW3D6QD4.js +2 -0
- package/dist/cdn/{GEFFWUB2.js → T2OYUOSO.js} +1 -1
- package/dist/cdn/T7LYQ56H.js +2 -0
- package/dist/cdn/{T2FKFOHE.js → TFXK2POV.js} +2 -2
- package/dist/cdn/{XQ3NBBQ3.js → TIQUULA4.js} +1 -1
- package/dist/cdn/{LCI5MEDN.js → TOUYGIGK.js} +2 -2
- package/dist/cdn/{DWMZ23QK.js → UJMM5QA4.js} +2 -2
- package/dist/cdn/UMTRLI63.js +2 -0
- package/dist/cdn/{MQSOVP27.js → UP7RW5K2.js} +2 -2
- package/dist/cdn/{J37GSI7C.js → UR2S7L6Z.js} +2 -2
- package/dist/cdn/{CEKOEHB3.js → UWHRBGWN.js} +2 -2
- package/dist/cdn/UXDRYDOD.js +11 -0
- package/dist/cdn/UZ7XFHYI.js +2 -0
- package/dist/cdn/V66TS2BB.js +2 -0
- package/dist/cdn/{AAUVOBPS.js → VINKTQFR.js} +1 -1
- package/dist/cdn/{U3ZTF2BC.js → VU7IOGNS.js} +2 -2
- package/dist/cdn/W2SIOY2B.js +3 -0
- package/dist/cdn/{WVMQ3I6F.js → W36IUEUB.js} +2 -2
- package/dist/cdn/{V6AQFRUC.js → WEBAQIUT.js} +2 -2
- package/dist/cdn/{WSIZ2OTL.js → WHIWOYHN.js} +1 -1
- package/dist/cdn/WOL5YMJ2.js +2 -0
- package/dist/cdn/{RBRHDEOB.js → X3YFCWQZ.js} +2 -2
- package/dist/cdn/{ICBIUFK7.js → X4EQEKM7.js} +2 -2
- package/dist/cdn/{UPSFL6U3.js → XBWGOD6I.js} +2 -2
- package/dist/cdn/XGDXTTYW.js +2 -0
- package/dist/cdn/{FFWPUYGD.js → XLHYQNAM.js} +2 -2
- package/dist/cdn/{NEV6OZN3.js → XMQJWPXI.js} +2 -2
- package/dist/cdn/{FXRZCD5Y.js → XQUKC4YK.js} +2 -2
- package/dist/cdn/{JEBRN3EU.js → XSH4B7FP.js} +2 -2
- package/dist/cdn/{LK7ZIQW6.js → XVWSIDZV.js} +2 -2
- package/dist/cdn/{J6A4AS7E.js → XYMIFFBW.js} +2 -2
- package/dist/cdn/{645SDZBB.js → Y3ZKMD47.js} +2 -2
- package/dist/cdn/{2GSHUAQ2.js → YAANCUW2.js} +2 -2
- package/dist/cdn/{XJUYG2M3.js → YD5LVM7V.js} +2 -2
- package/dist/cdn/{TTPTZBCM.js → YGI277SH.js} +2 -2
- package/dist/cdn/YGSDJ4V3.js +14 -0
- package/dist/cdn/YJEARDAZ.js +2 -0
- package/dist/cdn/{DXCDVRGL.js → YSEHJQ4L.js} +2 -2
- package/dist/cdn/Z44NI2YQ.js +2 -0
- package/dist/cdn/{74CVYM72.js → ZEDDYT24.js} +2 -2
- package/dist/cdn/{ZBBI5M2X.js → ZROI63CW.js} +2 -2
- package/dist/cdn/{ZKDCEL6K.js → ZUKM4DGB.js} +2 -2
- package/dist/cdn/ZVVNATCX.js +2 -0
- package/dist/cdn/agent-utils/BaseAgent.js +2 -2
- package/dist/cdn/agent-utils/FunctionAgent.js +2 -2
- package/dist/cdn/agent-utils/LLMAgent.js +2 -2
- package/dist/cdn/agent-utils/SkillAgent.js +2 -2
- package/dist/cdn/agent-utils/WorkflowAgent.js +2 -2
- package/dist/cdn/agent-utils/createSchema.js +2 -2
- package/dist/cdn/agent-utils/middlewares/humanInTheLoop.js +2 -2
- package/dist/cdn/agent-utils/middlewares/middleware.js +2 -2
- package/dist/cdn/agent-utils/middlewares/trace.js +2 -2
- package/dist/cdn/agent-utils/tools/FunctionTool.js +2 -2
- package/dist/cdn/agent-utils/tools/MCPToolProvider.js +15 -0
- package/dist/cdn/agent-utils/tools/WebMCPToolProvider.js +2 -0
- package/dist/cdn/agent-utils/workflows/ConditionalWorkflow.js +2 -2
- package/dist/cdn/agent-utils/workflows/LoopWorkflow.js +2 -2
- package/dist/cdn/agent-utils/workflows/ParallelWorkflow.js +2 -2
- package/dist/cdn/agent-utils/workflows/RouterWorkflow.js +2 -2
- package/dist/cdn/agent-utils/workflows/SequentialWorkflow.js +2 -2
- package/dist/cdn/agent-utils/workflows/SwitchWorkflow.js +2 -2
- package/dist/cdn/index.js +2 -2
- package/dist/cdn/orchestrator/embeddings/getEmbeddings.js +2 -2
- package/dist/cdn/orchestrator/models/chatModel.js +2 -2
- package/dist/cdn/orchestrator/models/prompts.js +2 -2
- package/dist/cdn/orchestrator/signals.js +2 -2
- package/dist/cdn/orchestrator/state/runtime.js +2 -2
- package/dist/chunks/BaseWorkflow.js +1 -1
- package/dist/chunks/SKILL.js +1 -1
- package/dist/chunks/SKILL2.js +1 -1
- package/dist/chunks/SKILL3.js +1 -1
- package/dist/chunks/SKILL4.js +1 -1
- package/dist/chunks/adapter.js +1 -1
- package/dist/chunks/adapter2.js +1 -1
- package/dist/chunks/aiFactory.js +1 -1
- package/dist/chunks/aiUtilityService.js +1 -1
- package/dist/chunks/arcgisToolRegistry.js +1 -1
- package/dist/chunks/arcgis_knowledge_current_lc_context.js +1 -1
- package/dist/chunks/arcgis_knowledge_current_map_context.js +1 -1
- package/dist/chunks/arcgis_knowledge_cypher_query_prompt.js +1 -1
- package/dist/chunks/arcgis_knowledge_lucene_generation_prompt.js +1 -1
- package/dist/chunks/arcgis_knowledge_summarize_result_prompt.js +1 -1
- package/dist/chunks/arcgis_knowledge_tool_prompt.js +1 -1
- package/dist/chunks/converterUtils.js +66 -110
- package/dist/chunks/createSkillAgent.js +1 -1
- package/dist/chunks/data_explore_filter_prompt.js +1 -1
- package/dist/chunks/data_explore_query_prompt.js +1 -1
- package/dist/chunks/embeddings.worker.js +1 -1
- package/dist/chunks/fetchAgentContext.js +1 -1
- package/dist/chunks/fetchService.js +1 -1
- package/dist/chunks/fetchUtils.js +1 -1
- package/dist/chunks/fieldStatistics.js +1 -1
- package/dist/chunks/field_descriptions_prompt.js +1 -1
- package/dist/chunks/formatFeatureAttributes.js +1 -1
- package/dist/chunks/getPrompt.js +1 -1
- package/dist/chunks/graph.js +1 -1
- package/dist/chunks/helpState.js +1 -1
- package/dist/chunks/help_prompt.js +1 -1
- package/dist/chunks/intent_prompt.js +1 -1
- package/dist/chunks/layerQueryToolCalling.js +1 -1
- package/dist/chunks/layerStylingState.js +1 -1
- package/dist/chunks/layer_descriptions_prompt.js +1 -1
- package/dist/chunks/layer_styling_prompt.js +1 -1
- package/dist/chunks/localization.js +1 -1
- package/dist/chunks/mergeWhereClauses.js +1 -1
- package/dist/chunks/modelConfig.js +1 -1
- package/dist/chunks/modelPricing.js +1 -1
- package/dist/chunks/navigationState.js +1 -1
- package/dist/chunks/navigation_intent_prompt.js +1 -1
- package/dist/chunks/navigation_tool_prompt.js +1 -1
- package/dist/chunks/observationSnapshot.js +1 -1
- package/dist/chunks/reducers.js +1 -1
- package/dist/chunks/requireAgentServices.js +1 -1
- package/dist/chunks/resolveFieldNames.js +9 -0
- package/dist/chunks/resolveGeometryFilter.js +1 -1
- package/dist/chunks/runtime.js +2 -2
- package/dist/chunks/runtime2.js +1 -1
- package/dist/chunks/runtimeSpans.js +1 -1
- package/dist/chunks/schema.js +1 -1
- package/dist/chunks/slottableRequestUtils.js +1 -1
- package/dist/chunks/state.js +1 -1
- package/dist/chunks/summarize_query_response_prompt.js +1 -1
- package/dist/chunks/textFormatters.js +1 -1
- package/dist/chunks/toolCallResponse.js +1 -1
- package/dist/chunks/useT9n.js +1 -1
- package/dist/chunks/utils.js +1 -1
- package/dist/chunks/utils2.js +1 -1
- package/dist/chunks/utils3.js +1 -1
- package/dist/chunks/webmapSchema.js +1 -1
- package/dist/components/arcgis-assistant/customElement.js +1 -1
- package/dist/components/arcgis-assistant-agent/customElement.js +1 -1
- package/dist/components/arcgis-assistant-chat/customElement.js +1 -1
- package/dist/components/arcgis-assistant-chat-entry/customElement.js +1 -1
- package/dist/components/arcgis-assistant-data-exploration-agent/customElement.js +1 -1
- package/dist/components/arcgis-assistant-help-agent/customElement.js +1 -1
- package/dist/components/arcgis-assistant-interrupt/customElement.js +1 -1
- package/dist/components/arcgis-assistant-interrupt-preview/customElement.js +1 -1
- package/dist/components/arcgis-assistant-knowledge-agent/customElement.js +1 -1
- package/dist/components/arcgis-assistant-layer-styling-agent/customElement.js +1 -1
- package/dist/components/arcgis-assistant-message/customElement.js +1 -1
- package/dist/components/arcgis-assistant-message-block/customElement.js +1 -1
- package/dist/components/arcgis-assistant-message-feedback/customElement.js +1 -1
- package/dist/components/arcgis-assistant-message-footer/customElement.js +1 -1
- package/dist/components/arcgis-assistant-message-loading/customElement.js +1 -1
- package/dist/components/arcgis-assistant-message-log/customElement.js +5 -6
- package/dist/components/arcgis-assistant-message-log/index.js +5 -0
- package/dist/components/arcgis-assistant-message-read-aloud/customElement.js +1 -1
- package/dist/components/arcgis-assistant-message-text/customElement.js +11 -12
- package/dist/components/arcgis-assistant-message-text/index.js +5 -0
- package/dist/components/arcgis-assistant-navigation-agent/customElement.js +1 -1
- package/dist/components/arcgis-assistant-observation-inspector/customElement.js +1 -1
- package/dist/components/arcgis-assistant-observation-latency/customElement.js +1 -1
- package/dist/components/arcgis-assistant-observation-panel/customElement.js +1 -1
- package/dist/components/arcgis-assistant-observation-run/customElement.js +1 -1
- package/dist/components/arcgis-assistant-observation-usage/customElement.js +1 -1
- package/dist/components/arcgis-assistant-speech-input/customElement.js +1 -1
- package/dist/components/arcgis-assistant-suggested-prompts/customElement.js +1 -1
- package/dist/components/arcgis-assistant-user-message/customElement.js +8 -9
- package/dist/components/arcgis-assistant-user-message/index.js +5 -0
- package/dist/docs/api.json +1 -1
- package/dist/docs/docs.json +1 -1
- package/dist/docs/web-types.json +1 -1
- package/dist/index.js +1 -1
- package/dist/loader.js +1 -1
- package/dist/orchestrator/embeddings/cosineSimilarity.js +1 -1
- package/dist/orchestrator/embeddings/getEmbeddings.js +1 -1
- package/dist/orchestrator/embeddings/webmapEmbeddings.js +1 -1
- package/dist/orchestrator/models/chatModel.js +1 -1
- package/dist/orchestrator/models/prompts.js +1 -1
- package/dist/orchestrator/orchestrator/orchestrator.js +1 -1
- package/dist/orchestrator/orchestrator/orchestratorEvents.js +1 -1
- package/dist/orchestrator/signals.js +1 -1
- package/dist/orchestrator/state/runtime.js +1 -1
- package/dist/orchestrator/state/types.js +1 -1
- package/dist/orchestrator/types.js +1 -1
- package/dist/utils/index.js +1 -1
- package/package.json +8 -5
- package/dist/cdn/25CQLMB4.js +0 -2
- package/dist/cdn/34HKOU3T.js +0 -2
- package/dist/cdn/3WS4DSWD.js +0 -2
- package/dist/cdn/434TAA3J.js +0 -2
- package/dist/cdn/43OJZMBB.js +0 -2
- package/dist/cdn/4BRIOLDJ.js +0 -2
- package/dist/cdn/4KFTUBFL.js +0 -2
- package/dist/cdn/4ZPGFIE2.js +0 -2
- package/dist/cdn/6JCDY4FL.js +0 -2
- package/dist/cdn/7GQCNR4P.js +0 -11
- package/dist/cdn/A3KIOUWB.js +0 -2
- package/dist/cdn/BKKLQUK2.js +0 -2
- package/dist/cdn/CADNOKIK.js +0 -2
- package/dist/cdn/DQRKGYR3.js +0 -2
- package/dist/cdn/EOSKJPQV.js +0 -2
- package/dist/cdn/F7VQ3WH2.js +0 -2
- package/dist/cdn/FBIPIDP7.js +0 -2
- package/dist/cdn/GOET2CH4.js +0 -2
- package/dist/cdn/ISDNOFHU.js +0 -3
- package/dist/cdn/JZS6ZSWH.js +0 -2
- package/dist/cdn/KEBMHD4R.js +0 -9
- package/dist/cdn/KPHHXMRK.js +0 -2
- package/dist/cdn/LVSIZRTB.js +0 -2
- package/dist/cdn/OJP56R5R.js +0 -2
- package/dist/cdn/OYHYHALE.js +0 -2
- package/dist/cdn/QQPVN5MG.js +0 -2
- package/dist/cdn/QUZTFUWM.js +0 -1
- package/dist/cdn/REE4K4J7.js +0 -2
- package/dist/cdn/RFKOCMMT.js +0 -2
- package/dist/cdn/RKHDRUX5.js +0 -2
- package/dist/cdn/TGI7QCB2.js +0 -2
- package/dist/cdn/UALF45Q2.js +0 -2
- package/dist/cdn/WB5AFS42.js +0 -2
- package/dist/cdn/WC6SHIEX.js +0 -2
- package/dist/cdn/XPSPAZUD.js +0 -2
- package/dist/cdn/YAUQJ6NV.js +0 -2
- package/dist/cdn/YD3DLETZ.js +0 -2
- package/dist/cdn/YKKIJTJY.js +0 -2
- package/dist/cdn/ZCNCYKXW.js +0 -14
- package/dist/cdn/ZESTW6HJ.js +0 -2
- package/dist/cdn/ZS5P7NRI.js +0 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* COPYRIGHT Esri - https://js.arcgis.com/
|
|
1
|
+
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
2
|
import { isGraphInterrupt as o } from "@langchain/langgraph/web";
|
|
3
3
|
import { BaseAgent as c } from "./BaseAgent.js";
|
|
4
4
|
import { c as u } from "../chunks/graph.js";
|
|
@@ -2,10 +2,11 @@ import type { StructuredToolInterface } from "@langchain/core/tools";
|
|
|
2
2
|
import type { BaseAgent } from "./BaseAgent.js";
|
|
3
3
|
import type { AgentMiddleware } from "./middlewares/types.js";
|
|
4
4
|
import type { FunctionToolLike } from "./tools/FunctionTool.js";
|
|
5
|
+
import type { ToolProvider } from "./tools/ToolProvider.js";
|
|
5
6
|
import type { AgentCustomState, AgentData, ZodObjectSchema } from "./types.js";
|
|
6
7
|
import type { ChatModelTier } from "../orchestrator/models/chatModel.js";
|
|
7
8
|
|
|
8
|
-
export type LLMAgentTool = FunctionToolLike | StructuredToolInterface;
|
|
9
|
+
export type LLMAgentTool = FunctionToolLike | StructuredToolInterface | ToolProvider;
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* LLMAgent uses a language model to generate its output based on a provided prompt template and optional tools.
|
|
@@ -45,8 +46,14 @@ export class LLMAgent<TInput extends AgentData = AgentData, TOutput extends Agen
|
|
|
45
46
|
* @required
|
|
46
47
|
*/
|
|
47
48
|
prompt: string;
|
|
48
|
-
/**
|
|
49
|
+
/**
|
|
50
|
+
* The tools property is an optional array of tools and tool providers that the agent can use during execution.
|
|
51
|
+
* Passing a provider transfers ownership to this agent. Providers must not be shared between agents.
|
|
52
|
+
* Providers are destroyed when this agent is destroyed. Ordinary tools remain caller-owned.
|
|
53
|
+
* Keep tools fixed for the agent's lifetime. To replace them, destroy this agent and create a new one.
|
|
54
|
+
*/
|
|
49
55
|
tools?: LLMAgentTool[];
|
|
56
|
+
destroy(): void;
|
|
50
57
|
/**
|
|
51
58
|
* Rebuilds internal workspace and createGraph wiring. Concrete agent constructors call this after assigning their
|
|
52
59
|
* configuration. Call it manually after changing graph-defining properties.
|
|
@@ -1,70 +1,77 @@
|
|
|
1
|
-
/* COPYRIGHT Esri - https://js.arcgis.com/
|
|
1
|
+
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
2
|
import { ChatPromptTemplate as c } from "@langchain/core/prompts";
|
|
3
3
|
import { ToolMessage as l } from "@langchain/core/messages";
|
|
4
4
|
import { isGraphInterrupt as g } from "@langchain/langgraph/web";
|
|
5
|
-
import { createAgent as
|
|
5
|
+
import { createAgent as d, providerStrategy as f } from "langchain";
|
|
6
6
|
import { BaseAgent as w } from "./BaseAgent.js";
|
|
7
|
-
import { convertToLangChainMiddlewares as
|
|
8
|
-
import { c as
|
|
9
|
-
import { c as
|
|
10
|
-
import { c as u, h as
|
|
7
|
+
import { convertToLangChainMiddlewares as m } from "./middlewares/middleware.js";
|
|
8
|
+
import { c as y } from "../chunks/graph.js";
|
|
9
|
+
import { c as T } from "../chunks/state.js";
|
|
10
|
+
import { c as u, h as A } from "../chunks/utils.js";
|
|
11
11
|
class L extends w {
|
|
12
12
|
//#region Lifecycle
|
|
13
13
|
constructor(t) {
|
|
14
|
-
super(), this.middlewares = [], this.modelTier = "default", Object.assign(this, t), this.generate();
|
|
14
|
+
super(), this.middlewares = [], this.modelTier = "default", this._destroyed = !1, Object.assign(this, t), this.generate();
|
|
15
|
+
}
|
|
16
|
+
destroy() {
|
|
17
|
+
if (!this._destroyed) {
|
|
18
|
+
this._destroyed = !0;
|
|
19
|
+
for (const t of new Set(this.tools))
|
|
20
|
+
"getTools" in t && t.destroy();
|
|
21
|
+
}
|
|
15
22
|
}
|
|
16
23
|
//#endregion
|
|
17
24
|
//#region Public Methods
|
|
18
25
|
generate() {
|
|
19
|
-
const t = this.prompt ? c.fromTemplate(this.prompt).inputVariables : [],
|
|
26
|
+
const t = this.prompt ? c.fromTemplate(this.prompt).inputVariables : [], e = T(
|
|
20
27
|
[this.inputSchema, this.outputSchema].filter(Boolean),
|
|
21
28
|
t
|
|
22
|
-
),
|
|
29
|
+
), s = this.id, o = { [s]: this._invoke.bind(this) }, r = [{ from: s, decide: () => {
|
|
23
30
|
} }];
|
|
24
|
-
this.workspace =
|
|
31
|
+
this.workspace = e, this.createGraph = () => y(o, r, e, {
|
|
25
32
|
agent: this,
|
|
26
|
-
entryNode:
|
|
33
|
+
entryNode: s,
|
|
27
34
|
middlewares: this.middlewares
|
|
28
35
|
});
|
|
29
36
|
}
|
|
30
37
|
//#endregion
|
|
31
38
|
//#region Private Methods
|
|
32
|
-
async _invoke(t,
|
|
39
|
+
async _invoke(t, e) {
|
|
33
40
|
try {
|
|
34
|
-
return this.outputSchema ? await this._invokeStructured(t,
|
|
35
|
-
} catch (
|
|
36
|
-
if (g(
|
|
37
|
-
throw
|
|
38
|
-
const o =
|
|
41
|
+
return this.outputSchema ? await this._invokeStructured(t, e) : await this._invokeUnstructured(t, e);
|
|
42
|
+
} catch (s) {
|
|
43
|
+
if (g(s) || e?.signal?.aborted || s instanceof Error && s.name === "AbortError")
|
|
44
|
+
throw s;
|
|
45
|
+
const o = s instanceof Error ? s.message : String(s);
|
|
39
46
|
return u({ outputMessage: o }, "failed", o);
|
|
40
47
|
}
|
|
41
48
|
}
|
|
42
|
-
async _invokeStructured(t,
|
|
49
|
+
async _invokeStructured(t, e) {
|
|
43
50
|
if (!this.outputSchema)
|
|
44
51
|
throw new Error("Output schema is required for structured invocation.");
|
|
45
|
-
const { createChatModel:
|
|
46
|
-
model: await
|
|
52
|
+
const { createChatModel: s } = await import("../orchestrator/models/chatModel.js"), r = await d({
|
|
53
|
+
model: await s({ modelTier: this.modelTier }),
|
|
47
54
|
systemPrompt: await this._getPromptWithInputVariables(t),
|
|
48
|
-
tools: this._getTools(),
|
|
55
|
+
tools: await this._getTools(),
|
|
49
56
|
checkpointer: !0,
|
|
50
|
-
middleware:
|
|
57
|
+
middleware: m(this.middlewares),
|
|
51
58
|
responseFormat: f(this.outputSchema)
|
|
52
|
-
}).invoke({ messages: t.agentExecutionContext.messages },
|
|
59
|
+
}).invoke({ messages: t.agentExecutionContext.messages }, e);
|
|
53
60
|
if (!("structuredResponse" in r) || r.structuredResponse === void 0)
|
|
54
61
|
throw new Error("LLMAgent did not receive structured output from createAgent.");
|
|
55
62
|
return {
|
|
56
|
-
...
|
|
63
|
+
...A(r.structuredResponse, this.outputSchema, r.messages),
|
|
57
64
|
sharedResourceAdditions: p(r.messages)
|
|
58
65
|
};
|
|
59
66
|
}
|
|
60
|
-
async _invokeUnstructured(t,
|
|
61
|
-
const { createChatModel:
|
|
62
|
-
model: await
|
|
67
|
+
async _invokeUnstructured(t, e) {
|
|
68
|
+
const { createChatModel: s } = await import("../orchestrator/models/chatModel.js"), a = (await d({
|
|
69
|
+
model: await s({ modelTier: this.modelTier }),
|
|
63
70
|
systemPrompt: await this._getPromptWithInputVariables(t),
|
|
64
|
-
tools: this._getTools(),
|
|
71
|
+
tools: await this._getTools(),
|
|
65
72
|
checkpointer: !0,
|
|
66
|
-
middleware:
|
|
67
|
-
}).invoke({ messages: t.agentExecutionContext.messages },
|
|
73
|
+
middleware: m(this.middlewares)
|
|
74
|
+
}).invoke({ messages: t.agentExecutionContext.messages }, e)).messages, n = a.at(-1)?.text ?? "", h = n.trim() || "LLMAgent completed.";
|
|
68
75
|
return u(
|
|
69
76
|
{
|
|
70
77
|
agentExecutionContext: { ...t.agentExecutionContext, messages: a },
|
|
@@ -78,18 +85,20 @@ class L extends w {
|
|
|
78
85
|
async _getPromptWithInputVariables(t) {
|
|
79
86
|
return await c.fromTemplate(this.prompt).format(t);
|
|
80
87
|
}
|
|
81
|
-
_getTools() {
|
|
82
|
-
return
|
|
88
|
+
async _getTools() {
|
|
89
|
+
return (await Promise.all(
|
|
90
|
+
(this.tools ?? []).map(async (e) => "getTools" in e ? await e.getTools() : ["getTool" in e ? e.getTool() : e])
|
|
91
|
+
)).flat();
|
|
83
92
|
}
|
|
84
93
|
//#endregion
|
|
85
94
|
}
|
|
86
95
|
function p(i) {
|
|
87
96
|
const t = [];
|
|
88
|
-
for (const
|
|
89
|
-
if (l.isInstance(
|
|
90
|
-
const
|
|
91
|
-
if (typeof
|
|
92
|
-
const o =
|
|
97
|
+
for (const e of i)
|
|
98
|
+
if (l.isInstance(e) && e.status !== "error") {
|
|
99
|
+
const s = e.artifact;
|
|
100
|
+
if (typeof s == "object" && s !== null && "sharedResourceAdditions" in s) {
|
|
101
|
+
const o = s.sharedResourceAdditions;
|
|
93
102
|
if (Array.isArray(o))
|
|
94
103
|
for (const r of o)
|
|
95
104
|
t.push({
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* COPYRIGHT Esri - https://js.arcgis.com/
|
|
1
|
+
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
2
|
import { NodeInterrupt as s } from "@langchain/langgraph/web";
|
|
3
3
|
import { createAgentMiddleware as f, createToolMiddleware as I } from "./middleware.js";
|
|
4
4
|
const m = "human-in-the-loop", w = "Agent execution requires approval", p = "Agent execution rejected by the user.", h = "human-in-the-loop-tool", y = "Tool execution requires approval";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* COPYRIGHT Esri - https://js.arcgis.com/
|
|
1
|
+
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
2
|
import { sendTraceMessage as n } from "../../orchestrator/signals.js";
|
|
3
3
|
import { AIMessage as i, ToolMessage as c } from "@langchain/core/messages";
|
|
4
4
|
import { createAgentMiddleware as s, createToolMiddleware as d } from "./middleware.js";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/* COPYRIGHT Esri - https://js.arcgis.com/
|
|
1
|
+
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
2
|
|
|
@@ -100,8 +100,19 @@ export class FunctionTool<TInput extends AgentData, TOutput = unknown> {
|
|
|
100
100
|
* The output schema defines the expected structure of the result returned by the tool.
|
|
101
101
|
* This should be a Zod schema object.
|
|
102
102
|
* The agent will validate the output against this schema after execution.
|
|
103
|
+
* With `content-and-artifact`, the schema validates the entire tuple, including the artifact.
|
|
103
104
|
*/
|
|
104
105
|
outputSchema?: z.ZodType<TOutput>;
|
|
106
|
+
/**
|
|
107
|
+
* The format of the tool's response. With `content`, the result is interpreted as message content.
|
|
108
|
+
* With `content-and-artifact`, execute must return a two-item tuple containing message content
|
|
109
|
+
* and an artifact. Only the content is sent to the model; the artifact is available to the application.
|
|
110
|
+
* String results from middleware are treated as content with no artifact.
|
|
111
|
+
*
|
|
112
|
+
* @default "content"
|
|
113
|
+
* @since 5.2
|
|
114
|
+
*/
|
|
115
|
+
responseFormat: "content-and-artifact" | "content";
|
|
105
116
|
/**
|
|
106
117
|
* The result mode determines how the agent should treat the output of this tool.
|
|
107
118
|
* If set to `terminal`, the agent will
|
|
@@ -122,5 +133,5 @@ export interface FunctionToolMiddlewareTool {
|
|
|
122
133
|
resultMode: ToolResultMode;
|
|
123
134
|
}
|
|
124
135
|
|
|
125
|
-
export type FunctionToolConstructProperties<TInput extends AgentData, TOutput> = Partial<Pick<FunctionTool<TInput, TOutput>, "inputSchema" | "middlewares" | "outputSchema" | "resultMode">>
|
|
136
|
+
export type FunctionToolConstructProperties<TInput extends AgentData, TOutput> = Partial<Pick<FunctionTool<TInput, TOutput>, "inputSchema" | "middlewares" | "outputSchema" | "responseFormat" | "resultMode">>
|
|
126
137
|
& Pick<FunctionTool<TInput, TOutput>, "description" | "execute" | "name">;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
/* COPYRIGHT Esri - https://js.arcgis.com/
|
|
2
|
-
import { tool as
|
|
3
|
-
class
|
|
1
|
+
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
+
import { tool as c } from "@langchain/core/tools";
|
|
3
|
+
class h {
|
|
4
4
|
//#region Lifecycle
|
|
5
5
|
constructor(t) {
|
|
6
|
-
this.resultMode = "continue", this.middlewares = [], Object.assign(this, t);
|
|
6
|
+
this.resultMode = "continue", this.responseFormat = "content", this.middlewares = [], Object.assign(this, t);
|
|
7
7
|
}
|
|
8
8
|
//#endregion
|
|
9
9
|
//#region Public Methods
|
|
@@ -11,24 +11,25 @@ class d {
|
|
|
11
11
|
* Builds the LangChain tool adapter used by LLM agents.
|
|
12
12
|
*/
|
|
13
13
|
getTool() {
|
|
14
|
-
return
|
|
14
|
+
return c(this._executeWithMiddlewares.bind(this), {
|
|
15
15
|
name: this.name,
|
|
16
16
|
description: this.description,
|
|
17
17
|
returnDirect: this.resultMode === "terminal",
|
|
18
|
-
schema: this.inputSchema
|
|
18
|
+
schema: this.inputSchema,
|
|
19
|
+
responseFormat: this.responseFormat === "content-and-artifact" ? "content_and_artifact" : "content"
|
|
19
20
|
});
|
|
20
21
|
}
|
|
21
22
|
//#endregion
|
|
22
23
|
//#region Private Methods
|
|
23
24
|
async _executeWithMiddlewares(t, e) {
|
|
24
|
-
const a = async (
|
|
25
|
-
const
|
|
26
|
-
return this._validateOutput(
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
(i, s) => async (r) => await s.handler(r, i),
|
|
25
|
+
const a = async (o) => {
|
|
26
|
+
const i = await this.execute(o.input, o.config);
|
|
27
|
+
return this._validateOutput(i);
|
|
28
|
+
}, s = await this.middlewares.reduceRight(
|
|
29
|
+
(o, i) => async (r) => await i.handler(r, o),
|
|
30
30
|
a
|
|
31
31
|
)({ config: e, input: t, tool: this, toolCallId: l(e) });
|
|
32
|
+
return this.responseFormat === "content-and-artifact" && typeof s == "string" ? [s, void 0] : s;
|
|
32
33
|
}
|
|
33
34
|
_validateOutput(t) {
|
|
34
35
|
if (!this.outputSchema)
|
|
@@ -40,10 +41,10 @@ class d {
|
|
|
40
41
|
}
|
|
41
42
|
//#endregion
|
|
42
43
|
}
|
|
43
|
-
function l(
|
|
44
|
-
const t =
|
|
44
|
+
function l(n) {
|
|
45
|
+
const t = n?.toolCall;
|
|
45
46
|
return typeof t?.id == "string" ? t.id : void 0;
|
|
46
47
|
}
|
|
47
48
|
export {
|
|
48
|
-
|
|
49
|
+
h as FunctionTool
|
|
49
50
|
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { StructuredToolInterface } from "@langchain/core/tools";
|
|
2
|
+
import type { ToolResultMode } from "./FunctionTool.js";
|
|
3
|
+
|
|
4
|
+
/** @internal */
|
|
5
|
+
export type MCPToolProviderConstructProperties = Partial<Pick<MCPToolProvider, "allowedTools" | "headers" | "resultModes">>
|
|
6
|
+
& Pick<MCPToolProvider, "serverUrl">;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Discovers tools hosted by a remote Streamable HTTP MCP server and adapts them for use by LLM agents.
|
|
10
|
+
*
|
|
11
|
+
* @internal
|
|
12
|
+
*/
|
|
13
|
+
export class MCPToolProvider {
|
|
14
|
+
constructor(properties?: MCPToolProviderConstructProperties);
|
|
15
|
+
/**
|
|
16
|
+
* Names of the advertised tools to expose. All advertised tools are exposed when this property is undefined.
|
|
17
|
+
*
|
|
18
|
+
* @internal
|
|
19
|
+
*/
|
|
20
|
+
allowedTools?: string[];
|
|
21
|
+
/**
|
|
22
|
+
* Request headers sent to the MCP server, for example an authorization header.
|
|
23
|
+
*
|
|
24
|
+
* @internal
|
|
25
|
+
*/
|
|
26
|
+
headers?: Record<string, string>;
|
|
27
|
+
/**
|
|
28
|
+
* Result modes keyed by tool name. Tools without an entry default to "continue".
|
|
29
|
+
* "continue" lets the agent process the result; "terminal" ends the run with the tool result.
|
|
30
|
+
*
|
|
31
|
+
* @internal
|
|
32
|
+
*/
|
|
33
|
+
resultModes?: Partial<Record<string, ToolResultMode>>;
|
|
34
|
+
/**
|
|
35
|
+
* Streamable HTTP endpoint for the MCP server.
|
|
36
|
+
*
|
|
37
|
+
* @required
|
|
38
|
+
* @internal
|
|
39
|
+
*/
|
|
40
|
+
serverUrl: string;
|
|
41
|
+
/**
|
|
42
|
+
* Closes the MCP connection when the provider is no longer needed.
|
|
43
|
+
*
|
|
44
|
+
* @internal
|
|
45
|
+
*/
|
|
46
|
+
close(): Promise<void>;
|
|
47
|
+
destroy(): void;
|
|
48
|
+
/**
|
|
49
|
+
* Discovers the tools advertised by the MCP server and builds their LangChain adapters.
|
|
50
|
+
*
|
|
51
|
+
* @internal
|
|
52
|
+
*/
|
|
53
|
+
getTools(): Promise<StructuredToolInterface[]>;
|
|
54
|
+
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
+
import { DynamicStructuredTool as a } from "@langchain/core/tools";
|
|
3
|
+
import { Client as c, StreamableHTTPClientTransport as l } from "@modelcontextprotocol/client";
|
|
4
|
+
class u {
|
|
5
|
+
//#region Lifecycle
|
|
6
|
+
constructor(t) {
|
|
7
|
+
Object.assign(this, t);
|
|
8
|
+
}
|
|
9
|
+
destroy() {
|
|
10
|
+
this.close();
|
|
11
|
+
}
|
|
12
|
+
//#endregion
|
|
13
|
+
//#region Public Methods
|
|
14
|
+
/**
|
|
15
|
+
* Discovers the tools advertised by the MCP server and builds their LangChain adapters.
|
|
16
|
+
*
|
|
17
|
+
* @internal
|
|
18
|
+
*/
|
|
19
|
+
async getTools() {
|
|
20
|
+
const t = await this._getClient();
|
|
21
|
+
try {
|
|
22
|
+
const e = await this._getToolDefinitions(t), o = this.allowedTools;
|
|
23
|
+
if (o) {
|
|
24
|
+
const n = new Set(e.map(({ name: i }) => i)), r = o.filter((i) => !n.has(i));
|
|
25
|
+
if (r.length > 0)
|
|
26
|
+
throw new Error(`MCP server did not advertise the following allowed tools: ${r.join(", ")}`);
|
|
27
|
+
}
|
|
28
|
+
const s = o ? new Set(o) : void 0;
|
|
29
|
+
return e.filter(({ name: n }) => !s || s.has(n)).map((n) => this._createTool(n));
|
|
30
|
+
} finally {
|
|
31
|
+
await this._closeConnection();
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Closes the MCP connection when the provider is no longer needed.
|
|
36
|
+
*
|
|
37
|
+
* @internal
|
|
38
|
+
*/
|
|
39
|
+
async close() {
|
|
40
|
+
this._toolDefinitions = void 0, await this._closeConnection();
|
|
41
|
+
}
|
|
42
|
+
//#endregion
|
|
43
|
+
//#region Private Methods
|
|
44
|
+
_createTool(t) {
|
|
45
|
+
return new a({
|
|
46
|
+
description: t.description ?? t.title ?? t.name,
|
|
47
|
+
func: async (e, o, s) => await this._invoke(t.name, e, s),
|
|
48
|
+
name: t.name,
|
|
49
|
+
returnDirect: this.resultModes?.[t.name] === "terminal",
|
|
50
|
+
schema: t.inputSchema
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
async _invoke(t, e, o) {
|
|
54
|
+
const s = await this._getClient();
|
|
55
|
+
try {
|
|
56
|
+
const n = await s.callTool(
|
|
57
|
+
{ arguments: e, name: t },
|
|
58
|
+
o?.signal ? { requestSignal: o.signal } : void 0
|
|
59
|
+
);
|
|
60
|
+
if ("toolResult" in n)
|
|
61
|
+
return JSON.stringify(n.toolResult);
|
|
62
|
+
const r = n.content.map((i) => i.type === "text" ? i.text : JSON.stringify(i)).join(`
|
|
63
|
+
`);
|
|
64
|
+
if (n.isError)
|
|
65
|
+
throw new Error(r);
|
|
66
|
+
return r;
|
|
67
|
+
} finally {
|
|
68
|
+
await this._closeConnection();
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
async _listTools(t) {
|
|
72
|
+
const e = [];
|
|
73
|
+
let o;
|
|
74
|
+
do {
|
|
75
|
+
const s = await t.listTools(o ? { cursor: o } : void 0);
|
|
76
|
+
e.push(...s.tools), o = s.nextCursor;
|
|
77
|
+
} while (o);
|
|
78
|
+
return e;
|
|
79
|
+
}
|
|
80
|
+
async _getToolDefinitions(t) {
|
|
81
|
+
return this._toolDefinitions ??= this._listTools(t).catch((e) => {
|
|
82
|
+
throw this._toolDefinitions = void 0, e;
|
|
83
|
+
}), await this._toolDefinitions;
|
|
84
|
+
}
|
|
85
|
+
async _getClient() {
|
|
86
|
+
if (this._client)
|
|
87
|
+
return this._client;
|
|
88
|
+
this._connection ??= this._connect();
|
|
89
|
+
try {
|
|
90
|
+
return await this._connection;
|
|
91
|
+
} catch (t) {
|
|
92
|
+
throw this._connection = void 0, t;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
async _closeConnection() {
|
|
96
|
+
const t = this._transport;
|
|
97
|
+
this._client = void 0, this._connection = void 0, this._transport = void 0, t && await t.close();
|
|
98
|
+
}
|
|
99
|
+
async _connect() {
|
|
100
|
+
const t = new c(
|
|
101
|
+
{ name: "@arcgis/ai-components", version: "5.2" },
|
|
102
|
+
{ versionNegotiation: { mode: "auto" } }
|
|
103
|
+
), e = new l(new URL(this.serverUrl), {
|
|
104
|
+
requestInit: { headers: this.headers }
|
|
105
|
+
});
|
|
106
|
+
this._transport = e;
|
|
107
|
+
try {
|
|
108
|
+
return await t.connect(e), this._client = t, t;
|
|
109
|
+
} catch (o) {
|
|
110
|
+
throw this._transport = void 0, await e.close(), o instanceof TypeError ? new Error(
|
|
111
|
+
"Could not connect to the MCP server. Check the URL, network connection, and server's CORS settings. See the browser console for details.",
|
|
112
|
+
{ cause: o }
|
|
113
|
+
) : o;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
//#endregion
|
|
117
|
+
}
|
|
118
|
+
export {
|
|
119
|
+
u as MCPToolProvider
|
|
120
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { StructuredToolInterface } from "@langchain/core/tools";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Supplies tools owned by an LLM agent. Provider instances must not be shared between agents.
|
|
5
|
+
*
|
|
6
|
+
* @since 5.2
|
|
7
|
+
*/
|
|
8
|
+
export interface ToolProvider {
|
|
9
|
+
/** Resolves the tools available for an agent invocation. */
|
|
10
|
+
getTools: () => Promise<StructuredToolInterface[]>;
|
|
11
|
+
/** Releases provider resources when the owning agent is destroyed. */
|
|
12
|
+
destroy: () => void;
|
|
13
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { StructuredToolInterface } from "@langchain/core/tools";
|
|
2
|
+
import type { ToolResultMode } from "./FunctionTool.js";
|
|
3
|
+
|
|
4
|
+
/** @internal */
|
|
5
|
+
export type WebMCPToolProviderConstructProperties = Partial<Pick<WebMCPToolProvider, "allowedTools" | "resultModes">>;
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Adapts tools exposed to the current document by the experimental WebMCP API for use by LLM agents.
|
|
9
|
+
* Requires the draft document.modelContext.getTools() and executeTool() APIs in a secure context.
|
|
10
|
+
* Discovery uses the browser's default same-origin scope; page-owned registrations are never removed.
|
|
11
|
+
*
|
|
12
|
+
* @see https://webmachinelearning.github.io/webmcp/#model-context-container
|
|
13
|
+
* @internal
|
|
14
|
+
*/
|
|
15
|
+
export class WebMCPToolProvider {
|
|
16
|
+
constructor(properties?: WebMCPToolProviderConstructProperties);
|
|
17
|
+
/**
|
|
18
|
+
* Names of tools to expose. All discovered tools are exposed when undefined.
|
|
19
|
+
*
|
|
20
|
+
* @internal
|
|
21
|
+
*/
|
|
22
|
+
allowedTools?: string[];
|
|
23
|
+
/**
|
|
24
|
+
* Result modes keyed by tool name. Tools without an entry default to "continue".
|
|
25
|
+
* "continue" lets the agent process the result; "terminal" ends the run with the tool result.
|
|
26
|
+
*
|
|
27
|
+
* @internal
|
|
28
|
+
*/
|
|
29
|
+
resultModes?: Partial<Record<string, ToolResultMode>>;
|
|
30
|
+
destroy(): void;
|
|
31
|
+
/**
|
|
32
|
+
* Discovers currently available WebMCP tools and builds their LangChain adapters.
|
|
33
|
+
*
|
|
34
|
+
* @internal
|
|
35
|
+
*/
|
|
36
|
+
getTools(): Promise<StructuredToolInterface[]>;
|
|
37
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
+
import { DynamicStructuredTool as c } from "@langchain/core/tools";
|
|
3
|
+
function u(n) {
|
|
4
|
+
return n instanceof Error && /^Failed to parse (?:input|arguments)/u.test(n.message);
|
|
5
|
+
}
|
|
6
|
+
class p {
|
|
7
|
+
//#region Lifecycle
|
|
8
|
+
constructor(e) {
|
|
9
|
+
this._abortController = new AbortController(), Object.assign(this, e);
|
|
10
|
+
}
|
|
11
|
+
destroy() {
|
|
12
|
+
this._abortController.abort();
|
|
13
|
+
}
|
|
14
|
+
//#endregion
|
|
15
|
+
//#region Public Methods
|
|
16
|
+
/**
|
|
17
|
+
* Discovers currently available WebMCP tools and builds their LangChain adapters.
|
|
18
|
+
*
|
|
19
|
+
* @internal
|
|
20
|
+
*/
|
|
21
|
+
async getTools() {
|
|
22
|
+
const e = this._abortController.signal;
|
|
23
|
+
e.throwIfAborted();
|
|
24
|
+
const t = typeof document > "u" ? void 0 : document.modelContext;
|
|
25
|
+
if (typeof t?.getTools != "function" || typeof t.executeTool != "function")
|
|
26
|
+
throw new Error("WebMCP tools are unavailable because WebMCP is unsupported or disabled on this page.");
|
|
27
|
+
const s = await t.getTools();
|
|
28
|
+
if (e.throwIfAborted(), this.allowedTools) {
|
|
29
|
+
const o = new Set(s.map(({ name: a }) => a)), r = this.allowedTools.filter((a) => !o.has(a));
|
|
30
|
+
if (r.length > 0)
|
|
31
|
+
throw new Error(`WebMCP did not expose the following allowed tools: ${r.join(", ")}`);
|
|
32
|
+
}
|
|
33
|
+
const l = this.allowedTools ? new Set(this.allowedTools) : void 0;
|
|
34
|
+
return s.filter(({ name: o }) => !l || l.has(o)).map((o) => this._createTool(o, t));
|
|
35
|
+
}
|
|
36
|
+
//#endregion
|
|
37
|
+
//#region Private Methods
|
|
38
|
+
_createTool(e, t) {
|
|
39
|
+
return new c({
|
|
40
|
+
name: e.name,
|
|
41
|
+
description: e.description,
|
|
42
|
+
func: async (s, l, i) => {
|
|
43
|
+
const o = i?.signal ? AbortSignal.any([this._abortController.signal, i.signal]) : this._abortController.signal;
|
|
44
|
+
o.throwIfAborted();
|
|
45
|
+
let r;
|
|
46
|
+
try {
|
|
47
|
+
r = await t.executeTool(e, JSON.stringify(s), { signal: o });
|
|
48
|
+
} catch (a) {
|
|
49
|
+
if (!u(a) || !s || typeof s != "object")
|
|
50
|
+
throw a;
|
|
51
|
+
r = await t.executeTool(e, s, { signal: o });
|
|
52
|
+
}
|
|
53
|
+
return typeof r == "string" ? r : JSON.stringify(r) ?? String(r);
|
|
54
|
+
},
|
|
55
|
+
returnDirect: this.resultModes?.[e.name] === "terminal",
|
|
56
|
+
schema: this._parseInputSchema(e)
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
_parseInputSchema(e) {
|
|
60
|
+
if (!e.inputSchema)
|
|
61
|
+
return { properties: {}, type: "object" };
|
|
62
|
+
let t = e.inputSchema;
|
|
63
|
+
if (typeof t == "string" && (t = JSON.parse(t)), typeof t != "object" || t === null || Array.isArray(t))
|
|
64
|
+
throw new TypeError(`WebMCP tool "${e.name}" has an invalid input schema.`);
|
|
65
|
+
return t;
|
|
66
|
+
}
|
|
67
|
+
//#endregion
|
|
68
|
+
}
|
|
69
|
+
export {
|
|
70
|
+
p as WebMCPToolProvider
|
|
71
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* COPYRIGHT Esri - https://js.arcgis.com/
|
|
1
|
+
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
2
|
import { c as M } from "../../chunks/graph.js";
|
|
3
3
|
import { a as R } from "../../chunks/state.js";
|
|
4
4
|
import { B as k, c as P, g as m, a as F } from "../../chunks/BaseWorkflow.js";
|