@arcgis/ai-components 5.2.0-next.1 → 5.2.0-next.100
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/LICENSE.md +4 -2
- package/README.md +2 -2
- package/dist/agent-utils/FunctionAgent.d.ts +2 -2
- package/dist/agent-utils/LLMAgent.d.ts +7 -4
- package/dist/agent-utils/LLMAgent.js +26 -24
- package/dist/agent-utils/WorkflowAgent.d.ts +2 -2
- package/dist/agent-utils/WorkflowAgent.js +14 -15
- package/dist/agent-utils/index.d.ts +177 -0
- package/dist/agent-utils/index.js +167 -0
- package/dist/agent-utils/middlewares/trace.d.ts +2 -0
- package/dist/agent-utils/middlewares/trace.js +25 -33
- package/dist/agent-utils/tools/FunctionTool.d.ts +2 -2
- package/dist/agent-utils/types.d.ts +37 -8
- package/dist/agent-utils/workflows/ConditionalWorkflow.d.ts +2 -2
- package/dist/agent-utils/workflows/LoopWorkflow.d.ts +2 -2
- package/dist/agent-utils/workflows/ParallelWorkflow.d.ts +2 -2
- package/dist/agent-utils/workflows/RouterWorkflow.d.ts +2 -2
- package/dist/agent-utils/workflows/SequentialWorkflow.d.ts +2 -2
- package/dist/agent-utils/workflows/SwitchWorkflow.d.ts +2 -2
- package/dist/agentic-workflow/AgenticWorkflowRuntime.d.ts +24 -0
- package/dist/agentic-workflow/Edge.d.ts +16 -0
- package/dist/agentic-workflow/WebAgent.d.ts +39 -0
- package/dist/agentic-workflow/jsonTypes.d.ts +189 -0
- package/dist/agentic-workflow/nodes/AgentNode.d.ts +28 -0
- package/dist/agentic-workflow/nodes/BaseNode.d.ts +35 -0
- package/dist/agentic-workflow/nodes/EndMessageNode.d.ts +25 -0
- package/dist/agentic-workflow/nodes/StartNode.d.ts +21 -0
- package/dist/agentic-workflow/nodes/tools/ArcgisTool.d.ts +21 -0
- package/dist/agentic-workflow/types.d.ts +29 -0
- package/dist/agents/tools/filter/clearFilters/adapter.d.ts +8 -0
- package/dist/agents/tools/filter/clearFilters/adapter.js +22 -0
- package/dist/agents/tools/filter/resetMap/adapter.d.ts +8 -0
- package/dist/agents/tools/filter/resetMap/adapter.js +22 -0
- package/dist/agents/tools/filter/setFeatureEffect/adapter.d.ts +8 -0
- package/dist/agents/tools/filter/setFeatureEffect/adapter.js +121 -0
- package/dist/agents/tools/help/listFields/adapter.d.ts +11 -0
- package/dist/agents/tools/help/listFields/adapter.js +30 -0
- package/dist/agents/tools/navigation/goToAddress/adapter.d.ts +10 -0
- package/dist/agents/tools/navigation/goToAddress/adapter.js +60 -0
- package/dist/agents/tools/navigation/goToBookmark/adapter.d.ts +8 -0
- package/dist/agents/tools/navigation/goToBookmark/adapter.js +30 -0
- package/dist/agents/tools/navigation/goToFeatures/adapter.d.ts +8 -0
- package/dist/agents/tools/navigation/goToFeatures/adapter.js +50 -0
- package/dist/agents/tools/navigation/goToFullExtent/adapter.d.ts +8 -0
- package/dist/agents/tools/navigation/goToFullExtent/adapter.js +27 -0
- package/dist/agents/tools/navigation/goToHomeExtent/adapter.d.ts +8 -0
- package/dist/agents/tools/navigation/goToHomeExtent/adapter.js +24 -0
- package/dist/agents/tools/navigation/goToLayer/adapter.d.ts +8 -0
- package/dist/agents/tools/navigation/goToLayer/adapter.js +26 -0
- package/dist/agents/tools/navigation/goToScale/adapter.d.ts +8 -0
- package/dist/agents/tools/navigation/goToScale/adapter.js +21 -0
- package/dist/agents/tools/navigation/goToViewpoint/adapter.d.ts +8 -0
- package/dist/agents/tools/navigation/goToViewpoint/adapter.js +42 -0
- package/dist/agents/tools/navigation/goToZoom/adapter.d.ts +8 -0
- package/dist/agents/tools/navigation/goToZoom/adapter.js +21 -0
- package/dist/agents/tools/query/getAttribute/adapter.d.ts +8 -0
- package/dist/agents/tools/query/getAttribute/adapter.js +40 -0
- package/dist/agents/tools/query/getStatistics/adapter.d.ts +8 -0
- package/dist/agents/tools/query/getStatistics/adapter.js +157 -0
- package/dist/agents/tools/query/getTopFeatures/adapter.d.ts +8 -0
- package/dist/agents/tools/query/getTopFeatures/adapter.js +144 -0
- package/dist/agents/tools/query/queryFeatures/adapter.d.ts +8 -0
- package/dist/agents/tools/query/queryFeatures/adapter.js +130 -0
- package/dist/agents/tools/search/findRelevantFields/adapter.d.ts +8 -0
- package/dist/agents/tools/search/findRelevantFields/adapter.js +57 -0
- package/dist/agents/tools/search/findRelevantLayers/adapter.d.ts +8 -0
- package/dist/agents/tools/search/findRelevantLayers/adapter.js +38 -0
- package/dist/cdn/22KHSDJI.js +2 -0
- package/dist/cdn/2EY3BQQX.js +2 -0
- package/dist/cdn/2O4DON37.js +2 -0
- package/dist/cdn/34O57OGV.js +2 -0
- package/dist/cdn/{AMP6IALT.js → 3UEKINYC.js} +1 -1
- package/dist/cdn/434TAA3J.js +2 -0
- package/dist/cdn/4OGR5QKS.js +2 -0
- package/dist/cdn/5FL5BTTX.js +66 -0
- package/dist/cdn/5HBAJ57P.js +2 -0
- package/dist/cdn/5K5ZY267.js +2 -0
- package/dist/cdn/5MK44FNO.js +2 -0
- package/dist/cdn/5WYRJMBW.js +2 -0
- package/dist/cdn/5X7EG7D2.js +2 -0
- package/dist/cdn/5XZLS7UO.js +2 -0
- package/dist/cdn/5ZFUGNRN.js +2 -0
- package/dist/cdn/655YIKL3.js +11 -0
- package/dist/cdn/6ECRQVHY.js +2 -0
- package/dist/cdn/6OOZSZRJ.js +2 -0
- package/dist/cdn/{3PKJWIC3.js → 6P44KOKX.js} +1 -1
- package/dist/cdn/6YYPVU7H.js +3 -0
- package/dist/cdn/7BCQMK6D.js +2 -0
- package/dist/cdn/7SRLZQVC.js +5 -0
- package/dist/cdn/7V6OSTFC.js +2 -0
- package/dist/cdn/7VAQUCBU.js +9 -0
- package/dist/cdn/7VUSIGEM.js +2 -0
- package/dist/cdn/ACJTJLZN.js +2 -0
- package/dist/cdn/AI6DYOKR.js +181 -0
- package/dist/cdn/AKD5UOVX.js +2 -0
- package/dist/cdn/ANRQWYU2.js +2 -0
- package/dist/cdn/{ZS2TZ6BF.js → AOVJ34QE.js} +1 -1
- package/dist/cdn/APFZY4PI.js +2 -0
- package/dist/cdn/B2JDVLA6.js +2 -0
- package/dist/cdn/BE7BRJZD.js +2 -0
- package/dist/cdn/{FL4W4VYN.js → BL273EGZ.js} +17 -1
- package/dist/cdn/C4FEETBZ.js +2 -0
- package/dist/cdn/C4JT4S5E.js +2 -0
- package/dist/cdn/CCC6LBMY.js +2 -0
- package/dist/cdn/{5ZZGKP7N.js → CEKOEHB3.js} +1 -1
- package/dist/cdn/CJMUJXPL.js +2 -0
- package/dist/cdn/COH3QXWG.js +4 -0
- package/dist/cdn/CP5BVGJU.js +2 -0
- package/dist/cdn/D5UFYQHN.js +44 -0
- package/dist/cdn/EWLXNGKH.js +208 -0
- package/dist/cdn/EYOWRGDP.js +2 -0
- package/dist/cdn/F5NIRETW.js +2 -0
- package/dist/cdn/FDOMMK2M.js +2 -0
- package/dist/cdn/FG647IP6.js +2 -0
- package/dist/cdn/FJO4KNOZ.js +2 -0
- package/dist/cdn/FUF3NAU7.js +2 -0
- package/dist/cdn/FXP5UIQU.js +156 -0
- package/dist/cdn/{ZLXN7NMF.js → FYZATVB3.js} +10 -8
- package/dist/cdn/G2EGT3CF.js +6 -0
- package/dist/cdn/G3SF6U2U.js +2 -0
- package/dist/cdn/G7OMHU2B.js +2 -0
- package/dist/cdn/HAEFC2SJ.js +2 -0
- package/dist/cdn/HDACNIZF.js +2 -0
- package/dist/cdn/HHFNQR6Z.js +2 -0
- package/dist/cdn/HHUQXL3R.js +2 -0
- package/dist/cdn/IBZ2NEAO.js +2 -0
- package/dist/cdn/{FX7UOGHP.js → ICBIUFK7.js} +1 -1
- package/dist/cdn/ICQCK5D3.js +2 -0
- package/dist/cdn/IHP25JWI.js +99 -0
- package/dist/cdn/IJVMUS2L.js +14 -0
- package/dist/cdn/J6A4AS7E.js +22 -0
- package/dist/cdn/J6SZIQJA.js +2 -0
- package/dist/cdn/JCOA24UH.js +3 -0
- package/dist/cdn/{NE7E52YR.js → JEBRN3EU.js} +9 -3
- package/dist/cdn/JO5ETMPS.js +2 -0
- package/dist/cdn/K2R6XVK3.js +2 -0
- package/dist/cdn/KITIP6J2.js +2 -0
- package/dist/cdn/KWD2ECTM.js +2 -0
- package/dist/cdn/{4HU7735A.js → LAYVGCPL.js} +6 -4
- package/dist/cdn/{7RCQFLPP.js → LK7ZIQW6.js} +1 -1
- package/dist/cdn/LLUGJKAQ.js +2 -0
- package/dist/cdn/MWYBF3F3.js +66 -0
- package/dist/cdn/{V2P4AIGG.js → MXTXJKFE.js} +1 -1
- package/dist/cdn/MY47B3CE.js +3 -0
- package/dist/cdn/NEV6OZN3.js +71 -0
- package/dist/cdn/NNXISHCA.js +14 -0
- package/dist/cdn/NZSOJ726.js +2 -0
- package/dist/cdn/O4NVW75A.js +2 -0
- package/dist/cdn/OE3GW5LE.js +2 -0
- package/dist/cdn/{23EQTPO3.js → OKVLGJAG.js} +1 -1
- package/dist/cdn/ONQ6JSBJ.js +2 -0
- package/dist/cdn/OX64WOEL.js +22 -0
- package/dist/cdn/{LQ6R5YRN.js → PQ2DPOFM.js} +1 -1
- package/dist/cdn/PUHRBGKB.js +2 -0
- package/dist/cdn/Q57QWN5W.js +2 -0
- package/dist/cdn/QUKNPVAF.js +2 -0
- package/dist/cdn/R2PQVY4O.js +2 -0
- package/dist/cdn/R74ZHFA6.js +2 -0
- package/dist/cdn/RBE55SWR.js +2 -0
- package/dist/cdn/RHYNE5OE.js +2 -0
- package/dist/cdn/RLEHNAIA.js +2 -0
- package/dist/cdn/RVSTAUQS.js +2 -0
- package/dist/cdn/{X2ZDYHCG.js → SDWWUWAF.js} +10 -5
- package/dist/cdn/SXM4NUT5.js +2 -0
- package/dist/cdn/SZ2QSSB3.js +2 -0
- package/dist/cdn/T4RIGOXB.js +2 -0
- package/dist/cdn/TCH5I5LS.js +2 -0
- package/dist/cdn/TEPP7YPR.js +2 -0
- package/dist/cdn/TMVF2W5N.js +36 -0
- package/dist/cdn/TPULIO6I.js +34 -0
- package/dist/cdn/UDRKUVZP.js +2 -0
- package/dist/cdn/{6YMR4QSD.js → UHEYPSOR.js} +1 -1
- package/dist/cdn/UHNVDALX.js +18 -0
- package/dist/cdn/UZLQALHY.js +2 -0
- package/dist/cdn/V6HOUZPZ.js +2 -0
- package/dist/cdn/VAXH6RUQ.js +134 -0
- package/dist/cdn/VLLZ2FFU.js +2 -0
- package/dist/cdn/VOKXKU7M.js +56 -0
- package/dist/cdn/VXFQANGJ.js +2 -0
- package/dist/cdn/WGO5SER7.js +6 -0
- package/dist/cdn/WJXXOKGA.js +9 -0
- package/dist/cdn/WKTQVBFJ.js +2 -0
- package/dist/cdn/{DHOVCT6R.js → WSWB3B7B.js} +1 -1
- package/dist/cdn/XX6GHMNR.js +2 -0
- package/dist/cdn/Y7XD7ZRD.js +2 -0
- package/dist/cdn/YEZ3AMNX.js +2 -0
- package/dist/cdn/YLVJA4ZE.js +2 -0
- package/dist/cdn/Z5HWPSZN.js +2 -0
- package/dist/cdn/Z5W4V7RC.js +2 -0
- package/dist/cdn/ZDV4K4WG.js +2 -0
- package/dist/cdn/ZOEMBHRF.js +2 -0
- package/dist/cdn/ZRVZMPFN.js +2 -0
- package/dist/cdn/{ZTBA5PM7.js → ZU2FHVNK.js} +1 -1
- package/dist/cdn/agent-utils/index.js +2 -0
- package/dist/cdn/agent-utils/middlewares/humanInTheLoop.js +3 -0
- package/dist/cdn/agent-utils/middlewares/middleware.js +2 -0
- package/dist/cdn/agent-utils/middlewares/trace.js +2 -0
- package/dist/cdn/assets/assistant/t9n/messages.en.json +1 -1
- package/dist/cdn/assets/assistant-interrupt/t9n/messages.en.json +1 -1
- package/dist/cdn/assets/assistant-interrupt-preview/t9n/messages.en.json +1 -0
- package/dist/cdn/assets/assistant-message/t9n/messages.en.json +1 -0
- package/dist/cdn/assets/assistant-message-loading/t9n/messages.en.json +1 -0
- package/dist/cdn/index.js +1 -1
- package/dist/cdn/main.css +1 -1
- package/dist/chunks/adapter.js +1299 -2113
- package/dist/chunks/arcgisKnowledgeGraph.js +128 -72
- package/dist/chunks/arcgis_knowledge_current_lc_context.js +19 -2
- package/dist/chunks/arcgis_knowledge_current_map_context.js +31 -2
- package/dist/chunks/arcgis_knowledge_cypher_query_prompt.js +102 -0
- package/dist/chunks/arcgis_knowledge_summarize_result_prompt.js +116 -27
- package/dist/chunks/baseAgentState.js +58 -0
- package/dist/chunks/converterUtils.js +66 -41
- package/dist/chunks/dataExplorationGraph.js +135 -179
- package/dist/chunks/data_explore_query_prompt.js +9 -4
- package/dist/chunks/fetchAgentContext.js +13 -0
- package/dist/chunks/fetchService.js +10 -0
- package/dist/chunks/fieldStatistics.js +79 -0
- package/dist/chunks/formatFeatureAttributes.js +132 -0
- package/dist/chunks/generateLayerDescriptions.js +250 -246
- package/dist/chunks/helpGraph.js +35 -25
- package/dist/chunks/help_prompt.js +34 -17
- package/dist/chunks/index.js +11 -0
- package/dist/chunks/intent_prompt.js +16 -0
- package/dist/chunks/layerStylingGraph.js +37 -31
- package/dist/chunks/mergeWhereClauses.js +15 -0
- package/dist/chunks/navigationGraph.js +135 -111
- package/dist/chunks/navigation_intent_prompt.js +8 -2
- package/dist/chunks/orchestrator.js +530 -280
- package/dist/chunks/resolvePointGeometryFilter.js +92 -0
- package/dist/chunks/slottableRequestUtils.js +3 -7
- package/dist/chunks/state.js +21 -27
- package/dist/chunks/summarize_query_response_prompt.js +9 -7
- package/dist/chunks/toolCallResponse.js +14 -10
- package/dist/chunks/utils2.js +11 -11
- package/dist/components/arcgis-assistant/customElement.d.ts +96 -0
- package/dist/components/arcgis-assistant/customElement.js +398 -149
- package/dist/components/arcgis-assistant/index.js +2 -3
- package/dist/components/arcgis-assistant/types.d.ts +14 -1
- package/dist/components/arcgis-assistant-agent/customElement.d.ts +13 -1
- package/dist/components/arcgis-assistant-agent/customElement.js +614 -10
- package/dist/components/arcgis-assistant-chat/customElement.d.ts +8 -2
- package/dist/components/arcgis-assistant-chat/customElement.js +23 -18
- package/dist/components/arcgis-assistant-chat-entry/customElement.d.ts +4 -1
- package/dist/components/arcgis-assistant-chat-entry/customElement.js +25 -18
- package/dist/components/arcgis-assistant-data-exploration-agent/customElement.js +20 -4
- package/dist/components/arcgis-assistant-help-agent/customElement.js +29 -7
- package/dist/components/arcgis-assistant-interrupt/customElement.d.ts +8 -1
- package/dist/components/arcgis-assistant-interrupt/customElement.js +17 -14
- package/dist/components/arcgis-assistant-interrupt-preview/customElement.js +24 -0
- package/dist/components/arcgis-assistant-interrupt-preview/index.js +2 -0
- package/dist/components/arcgis-assistant-knowledge-agent/customElement.d.ts +7 -7
- package/dist/components/arcgis-assistant-knowledge-agent/customElement.js +40 -16
- package/dist/components/arcgis-assistant-layer-styling-agent/customElement.js +30 -7
- package/dist/components/arcgis-assistant-message/customElement.d.ts +26 -0
- package/dist/components/arcgis-assistant-message/customElement.js +29 -26
- package/dist/components/arcgis-assistant-message/index.d.ts +1 -0
- package/dist/components/arcgis-assistant-message/index.js +2 -0
- package/dist/components/arcgis-assistant-message-block/customElement.d.ts +1 -1
- package/dist/components/arcgis-assistant-message-block/customElement.js +18 -11
- package/dist/components/arcgis-assistant-message-block/index.js +1 -0
- package/dist/components/arcgis-assistant-message-feedback/customElement.d.ts +4 -1
- package/dist/components/arcgis-assistant-message-footer/customElement.d.ts +4 -1
- package/dist/components/arcgis-assistant-message-loading/customElement.d.ts +11 -1
- package/dist/components/arcgis-assistant-message-loading/customElement.js +8 -7
- package/dist/components/arcgis-assistant-message-loading/index.js +1 -0
- package/dist/components/arcgis-assistant-message-log/customElement.d.ts +4 -1
- package/dist/components/arcgis-assistant-message-read-aloud/customElement.d.ts +4 -1
- package/dist/components/arcgis-assistant-message-text/customElement.d.ts +5 -1
- package/dist/components/arcgis-assistant-message-text/customElement.js +12 -12
- package/dist/components/arcgis-assistant-navigation-agent/customElement.js +18 -4
- package/dist/components/arcgis-assistant-speech-input/customElement.d.ts +6 -1
- package/dist/components/arcgis-assistant-speech-input/customElement.js +34 -52
- package/dist/components/arcgis-assistant-suggested-prompts/customElement.d.ts +4 -1
- package/dist/components/arcgis-assistant-suggested-prompts/customElement.js +8 -8
- package/dist/components/arcgis-assistant-user-message/customElement.d.ts +6 -1
- package/dist/components/arcgis-assistant-user-message/customElement.js +15 -10
- package/dist/docs/api.json +1 -1
- package/dist/docs/docs.json +1 -1
- package/dist/docs/vscode.html-custom-data.json +1 -1
- package/dist/docs/web-types.json +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/loader.js +9 -8
- package/dist/oauth-callback.html +1 -1
- package/dist/orchestrator/orchestrator/orchestratorEvents.d.ts +78 -0
- package/dist/types/lumina.d.ts +14 -7
- package/dist/types/preact.d.ts +15 -7
- package/dist/types/react.d.ts +16 -7
- package/dist/types/stencil.d.ts +16 -9
- package/dist/utils/index.d.ts +135 -65
- package/dist/utils/index.js +55 -50
- package/package.json +32 -12
- package/dist/cdn/2AXF774U.js +0 -2
- package/dist/cdn/462JBSEV.js +0 -422
- package/dist/cdn/5QAHYX7Y.js +0 -5
- package/dist/cdn/7BCR6TUO.js +0 -2
- package/dist/cdn/7GH7VSB2.js +0 -2
- package/dist/cdn/7PLV4QH6.js +0 -2
- package/dist/cdn/AO7BQHKC.js +0 -2
- package/dist/cdn/AXDZBBNL.js +0 -45
- package/dist/cdn/DDLZOMUY.js +0 -2
- package/dist/cdn/F2AHA4GB.js +0 -54
- package/dist/cdn/FHVXO2WG.js +0 -166
- package/dist/cdn/FX5JFRDL.js +0 -2
- package/dist/cdn/GSEPHN3A.js +0 -106
- package/dist/cdn/H7422XUG.js +0 -2
- package/dist/cdn/HB5A5R2E.js +0 -2
- package/dist/cdn/JY6LLOUJ.js +0 -22
- package/dist/cdn/KMQ3SP4I.js +0 -5
- package/dist/cdn/MDVYQQUG.js +0 -14
- package/dist/cdn/MH5RPXHM.js +0 -2
- package/dist/cdn/NAUXSHIE.js +0 -72
- package/dist/cdn/NVI3I46B.js +0 -2
- package/dist/cdn/OAVEHGB6.js +0 -2
- package/dist/cdn/OH64RMOR.js +0 -4
- package/dist/cdn/ON2V5XI2.js +0 -3
- package/dist/cdn/P6OPJQMC.js +0 -3
- package/dist/cdn/QR54T33D.js +0 -2
- package/dist/cdn/RVOAPUBN.js +0 -2
- package/dist/cdn/S6W6HV4T.js +0 -36
- package/dist/cdn/SXDLXCIM.js +0 -2
- package/dist/cdn/USMDJUFS.js +0 -2
- package/dist/cdn/V5YEZSRY.js +0 -16
- package/dist/cdn/Y333DGV6.js +0 -2
- package/dist/cdn/YIMNOUTF.js +0 -2
- package/dist/cdn/YY2SBO3V.js +0 -2
|
@@ -1,79 +1,127 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import { isGraphInterrupt as
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
|
|
11
|
-
|
|
2
|
+
import M from "@arcgis/core/identity/IdentityManager.js";
|
|
3
|
+
import _ from "@arcgis/core/portal/Portal.js";
|
|
4
|
+
import { j as $, k as b, D, n as F, o as L, W } from "./generateLayerDescriptions.js";
|
|
5
|
+
import { isGraphInterrupt as q, StateGraph as T, START as j, END as H, MemorySaver as P } from "@langchain/langgraph/web";
|
|
6
|
+
import { generateGuid as A } from "@arcgis/toolkit/string";
|
|
7
|
+
import { HumanMessage as U, AIMessage as O } from "@langchain/core/messages";
|
|
8
|
+
import { s as p } from "./index.js";
|
|
9
|
+
import { BaseCallbackHandler as G } from "@langchain/core/callbacks/base";
|
|
10
|
+
import * as N from "@arcgis/core/core/reactiveUtils.js";
|
|
11
|
+
import V from "@arcgis/core/layers/FeatureLayer.js";
|
|
12
|
+
import z from "@arcgis/core/request.js";
|
|
13
|
+
const B = async (n) => {
|
|
14
|
+
const e = await Q(), r = await $("default"), s = _.getDefault(), a = (await M.getCredential(`${s.url}/sharing`)).token, i = {
|
|
12
15
|
type: "generateEmbeddings",
|
|
13
|
-
webmapEmbeddings:
|
|
14
|
-
auth: { apiUrl:
|
|
16
|
+
webmapEmbeddings: n,
|
|
17
|
+
auth: { apiUrl: r, token: a }
|
|
15
18
|
};
|
|
16
|
-
return e.postMessage(
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
},
|
|
20
|
-
e.removeEventListener("message",
|
|
19
|
+
return e.postMessage(i), await new Promise((o, d) => {
|
|
20
|
+
const c = (g) => {
|
|
21
|
+
g.data === "completed" && (e.removeEventListener("message", c), o());
|
|
22
|
+
}, u = (g) => {
|
|
23
|
+
e.removeEventListener("message", c), d(g instanceof Error ? g : new Error("Embeddings worker error"));
|
|
21
24
|
};
|
|
22
|
-
e.addEventListener("message",
|
|
25
|
+
e.addEventListener("message", c), e.addEventListener("error", u, { once: !0 });
|
|
23
26
|
}), e;
|
|
24
|
-
},
|
|
27
|
+
}, Q = async () => {
|
|
25
28
|
{
|
|
26
|
-
const
|
|
27
|
-
return new
|
|
28
|
-
}
|
|
29
|
-
},
|
|
30
|
-
|
|
31
|
-
},
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
t
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
29
|
+
const n = (await import("./embeddings.worker.js")).default;
|
|
30
|
+
return new n();
|
|
31
|
+
}
|
|
32
|
+
}, K = (n) => {
|
|
33
|
+
n.currentIntent = "none";
|
|
34
|
+
}, J = async (n, e) => {
|
|
35
|
+
const r = b(e);
|
|
36
|
+
if (n.agentExecutionContext.userRequest) {
|
|
37
|
+
const t = new U(n.agentExecutionContext.userRequest.trim());
|
|
38
|
+
n.agentExecutionContext.messages = [...n.agentExecutionContext.messages, t], K(n);
|
|
39
|
+
}
|
|
40
|
+
const s = r?.services.agentRegistry.list().map((t) => t.agent.id) ?? [];
|
|
41
|
+
return await p({ text: `Available agents: ${[...s].join(", ")}` }, e), await p({ text: "Analyzing user input" }, e), n;
|
|
42
|
+
}, X = async (n, e) => (await p({ text: "Exiting..." }, e), n), E = (n) => typeof n == "object" && n !== null && !Array.isArray(n), Y = (n, e) => {
|
|
43
|
+
if (!E(n)) {
|
|
44
|
+
n !== void 0 && console.warn(`Agent "${e}" returned invalid sharedStatePatch. Ignoring it.`);
|
|
41
45
|
return;
|
|
42
46
|
}
|
|
43
|
-
const
|
|
44
|
-
for (const [
|
|
45
|
-
if (!
|
|
47
|
+
const r = {};
|
|
48
|
+
for (const [s, t] of Object.entries(n)) {
|
|
49
|
+
if (!E(t) || !("value" in t)) {
|
|
46
50
|
console.warn(
|
|
47
|
-
`Agent "${e}" returned invalid sharedStatePatch entry for key "${
|
|
51
|
+
`Agent "${e}" returned invalid sharedStatePatch entry for key "${s}". Ignoring that entry.`
|
|
48
52
|
);
|
|
49
53
|
continue;
|
|
50
54
|
}
|
|
51
|
-
s
|
|
55
|
+
r[s] = { value: t.value };
|
|
52
56
|
}
|
|
53
|
-
return
|
|
54
|
-
},
|
|
55
|
-
const { previousSharedState: e, patch:
|
|
56
|
-
if (!
|
|
57
|
+
return r;
|
|
58
|
+
}, Z = (n) => {
|
|
59
|
+
const { previousSharedState: e, patch: r, agentId: s } = n;
|
|
60
|
+
if (!r)
|
|
57
61
|
return e;
|
|
58
|
-
const
|
|
62
|
+
const t = Date.now(), a = {
|
|
59
63
|
...e
|
|
60
64
|
};
|
|
61
|
-
for (const [
|
|
62
|
-
|
|
63
|
-
value:
|
|
65
|
+
for (const [i, o] of Object.entries(r))
|
|
66
|
+
o?.value !== void 0 && (a[i] = {
|
|
67
|
+
value: o.value,
|
|
64
68
|
meta: {
|
|
65
|
-
updatedByAgentId:
|
|
66
|
-
updatedAt:
|
|
69
|
+
updatedByAgentId: s,
|
|
70
|
+
updatedAt: t
|
|
67
71
|
}
|
|
68
72
|
});
|
|
69
|
-
return
|
|
70
|
-
},
|
|
71
|
-
if (
|
|
73
|
+
return a;
|
|
74
|
+
}, ee = 256, te = /* @__PURE__ */ new Set(["point", "polyline", "polygon", "extent", "custom"]), ne = (n) => typeof n == "object" && n !== null && !Array.isArray(n), re = (n, e) => {
|
|
75
|
+
if (n === void 0)
|
|
76
|
+
return;
|
|
77
|
+
if (!Array.isArray(n)) {
|
|
78
|
+
console.warn(`Agent "${e}" returned invalid sharedResourceAdditions. Ignoring it.`);
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
const r = [];
|
|
82
|
+
for (const [s, t] of n.entries()) {
|
|
83
|
+
if (!ne(t) || typeof t.kind != "string" || !te.has(t.kind) || typeof t.description != "string" || !t.description.trim() || !("payload" in t) || t.payload === void 0) {
|
|
84
|
+
console.warn(
|
|
85
|
+
`Agent "${e}" returned invalid sharedResourceAdditions entry at index ${s}. Ignoring that entry.`
|
|
86
|
+
);
|
|
87
|
+
continue;
|
|
88
|
+
}
|
|
89
|
+
let a;
|
|
90
|
+
try {
|
|
91
|
+
a = structuredClone(t.payload);
|
|
92
|
+
} catch {
|
|
93
|
+
console.warn(
|
|
94
|
+
`Agent "${e}" returned invalid sharedResourceAdditions entry at index ${s}. Ignoring that entry.`
|
|
95
|
+
);
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
98
|
+
r.push({
|
|
99
|
+
kind: t.kind,
|
|
100
|
+
description: t.description.trim().slice(0, ee),
|
|
101
|
+
payload: a
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
return r.length ? r : void 0;
|
|
105
|
+
}, se = (n) => {
|
|
106
|
+
const { previousSharedResources: e, additions: r, agentId: s } = n;
|
|
107
|
+
if (!r?.length)
|
|
108
|
+
return e;
|
|
109
|
+
const t = Date.now(), a = r.map((i) => ({
|
|
110
|
+
...i,
|
|
111
|
+
id: A(),
|
|
112
|
+
meta: {
|
|
113
|
+
createdByAgentId: s,
|
|
114
|
+
createdAt: t
|
|
115
|
+
}
|
|
116
|
+
}));
|
|
117
|
+
return [...e, ...a].slice(-50);
|
|
118
|
+
}, R = (n) => {
|
|
119
|
+
if (typeof n != "string")
|
|
72
120
|
return;
|
|
73
|
-
const e =
|
|
121
|
+
const e = n.trim();
|
|
74
122
|
return e || void 0;
|
|
75
|
-
},
|
|
76
|
-
switch (
|
|
123
|
+
}, ae = (n) => {
|
|
124
|
+
switch (n) {
|
|
77
125
|
case "failed":
|
|
78
126
|
return "Agent failed without a summary.";
|
|
79
127
|
case "unknown":
|
|
@@ -83,99 +131,203 @@ const O = async (t) => {
|
|
|
83
131
|
default:
|
|
84
132
|
return "Agent completed without a summary.";
|
|
85
133
|
}
|
|
86
|
-
},
|
|
87
|
-
const
|
|
88
|
-
|
|
89
|
-
const
|
|
134
|
+
}, ie = (n, e) => {
|
|
135
|
+
const r = R(e?.outputMessage), s = R(e?.summary), t = e?.status, a = t === "success" || t === "failed" ? t : "unknown";
|
|
136
|
+
a === "unknown" && console.warn(`Agent "${n}" returned missing/invalid status. Defaulting to "unknown".`);
|
|
137
|
+
const i = Y(e?.sharedStatePatch, n), o = re(e?.sharedResourceAdditions, n);
|
|
90
138
|
return {
|
|
91
|
-
outputMessage:
|
|
92
|
-
summary:
|
|
93
|
-
status:
|
|
94
|
-
sharedStatePatch:
|
|
139
|
+
outputMessage: r,
|
|
140
|
+
summary: s ?? r ?? ae(a),
|
|
141
|
+
status: a,
|
|
142
|
+
sharedStatePatch: i,
|
|
143
|
+
sharedResourceAdditions: o
|
|
95
144
|
};
|
|
96
|
-
},
|
|
97
|
-
const
|
|
98
|
-
if (
|
|
99
|
-
return
|
|
100
|
-
|
|
101
|
-
|
|
145
|
+
}, x = 4e3, oe = async (n, e) => {
|
|
146
|
+
const r = b(e);
|
|
147
|
+
if (e?.signal?.aborted)
|
|
148
|
+
return await p({ text: "Run cancelled; skipping agent execution" }, e), {
|
|
149
|
+
...n,
|
|
150
|
+
currentIntent: "none",
|
|
151
|
+
requiresFollowUp: !1
|
|
152
|
+
};
|
|
153
|
+
const { agentRegistry: s } = r?.services ?? {}, t = s?.get(n.currentIntent);
|
|
154
|
+
if (!t)
|
|
155
|
+
return console.warn(`No agent found for intent: ${n.currentIntent}`), n;
|
|
156
|
+
await p({ text: `Executing registered agent: ${t.agent.name}` }, e);
|
|
157
|
+
const a = {
|
|
102
158
|
...e ?? {},
|
|
159
|
+
metadata: {
|
|
160
|
+
...e?.metadata,
|
|
161
|
+
agentId: t.agent.id
|
|
162
|
+
},
|
|
103
163
|
configurable: {
|
|
104
|
-
...
|
|
105
|
-
agentId:
|
|
106
|
-
context:
|
|
164
|
+
...r ?? {},
|
|
165
|
+
agentId: t.agent.id,
|
|
166
|
+
context: t.getContext ? await t.getContext() : void 0
|
|
107
167
|
}
|
|
108
168
|
};
|
|
109
|
-
let
|
|
169
|
+
let i;
|
|
110
170
|
try {
|
|
111
|
-
const
|
|
171
|
+
const c = await t.agent.createGraph().compile().invoke(
|
|
112
172
|
{
|
|
113
173
|
agentExecutionContext: {
|
|
114
|
-
...
|
|
174
|
+
...n.agentExecutionContext,
|
|
115
175
|
// deep clone on messages did not work in agents, so its a shallow clone here.
|
|
116
|
-
messages: [...
|
|
176
|
+
messages: [...n.agentExecutionContext.messages],
|
|
117
177
|
// deep clone to prevent accidental mutations by agents
|
|
118
|
-
priorSteps: structuredClone(
|
|
119
|
-
sharedState: structuredClone(
|
|
178
|
+
priorSteps: structuredClone(n.agentExecutionContext.priorSteps ?? []),
|
|
179
|
+
sharedState: structuredClone(n.agentExecutionContext.sharedState ?? {}),
|
|
180
|
+
sharedResources: structuredClone(n.agentExecutionContext.sharedResources ?? [])
|
|
120
181
|
}
|
|
121
182
|
},
|
|
122
|
-
|
|
183
|
+
a
|
|
123
184
|
);
|
|
124
|
-
|
|
125
|
-
} catch (
|
|
126
|
-
if (
|
|
127
|
-
throw
|
|
128
|
-
const
|
|
129
|
-
console.error(`Agent "${
|
|
185
|
+
i = ie(t.agent.name, c), await p({ text: `Finished executing registered agent: ${t.agent.name}` }, e);
|
|
186
|
+
} catch (c) {
|
|
187
|
+
if (q(c) || e?.signal?.aborted || c instanceof Error && c.name === "AbortError")
|
|
188
|
+
throw c;
|
|
189
|
+
const u = c instanceof Error ? c.message : String(c);
|
|
190
|
+
console.error(`Agent "${t.agent.name}" failed:`, c), await p({ text: `Registered agent failed: ${t.agent.name}. ${u}` }, e), i = {
|
|
130
191
|
status: "failed",
|
|
131
|
-
outputMessage: `Agent execution failed: ${
|
|
132
|
-
summary: `Agent execution failed: ${
|
|
192
|
+
outputMessage: `Agent execution failed: ${u}`,
|
|
193
|
+
summary: `Agent execution failed: ${u}`
|
|
133
194
|
};
|
|
134
195
|
}
|
|
135
|
-
const
|
|
136
|
-
if (
|
|
137
|
-
const
|
|
138
|
-
[truncated]` :
|
|
139
|
-
d.push(new
|
|
196
|
+
const o = i.outputMessage, d = [...n.agentExecutionContext.messages];
|
|
197
|
+
if (o) {
|
|
198
|
+
const c = o.length > x ? `${o.slice(0, x - 14)}
|
|
199
|
+
[truncated]` : o;
|
|
200
|
+
d.push(new O(c));
|
|
140
201
|
}
|
|
141
202
|
return {
|
|
142
|
-
...
|
|
143
|
-
stepCount:
|
|
144
|
-
lastExecutedAgent:
|
|
145
|
-
requiresFollowUp:
|
|
146
|
-
finalOutputMessage:
|
|
203
|
+
...n,
|
|
204
|
+
stepCount: n.stepCount + 1,
|
|
205
|
+
lastExecutedAgent: t.agent.id,
|
|
206
|
+
requiresFollowUp: i.status === "failed" ? !0 : n.requiresFollowUp,
|
|
207
|
+
finalOutputMessage: o ?? "",
|
|
147
208
|
agentExecutionContext: {
|
|
148
|
-
...
|
|
209
|
+
...n.agentExecutionContext,
|
|
149
210
|
messages: d,
|
|
150
211
|
priorSteps: [
|
|
151
|
-
...
|
|
212
|
+
...n.agentExecutionContext.priorSteps ?? [],
|
|
152
213
|
{
|
|
153
|
-
agentId:
|
|
154
|
-
assignedTask:
|
|
155
|
-
summary:
|
|
156
|
-
status:
|
|
214
|
+
agentId: t.agent.id,
|
|
215
|
+
assignedTask: n.agentExecutionContext.assignedTask,
|
|
216
|
+
summary: i?.summary || "No summary provided.",
|
|
217
|
+
status: i?.status || "unknown"
|
|
157
218
|
}
|
|
158
219
|
],
|
|
159
|
-
sharedState:
|
|
160
|
-
previousSharedState:
|
|
161
|
-
patch:
|
|
162
|
-
agentId:
|
|
220
|
+
sharedState: Z({
|
|
221
|
+
previousSharedState: n.agentExecutionContext.sharedState,
|
|
222
|
+
patch: i.sharedStatePatch,
|
|
223
|
+
agentId: t.agent.id
|
|
224
|
+
}),
|
|
225
|
+
sharedResources: se({
|
|
226
|
+
previousSharedResources: n.agentExecutionContext.sharedResources,
|
|
227
|
+
additions: i.sharedResourceAdditions,
|
|
228
|
+
agentId: t.agent.id
|
|
163
229
|
})
|
|
164
230
|
}
|
|
165
231
|
};
|
|
166
|
-
},
|
|
167
|
-
"
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
232
|
+
}, ce = async (n, e) => {
|
|
233
|
+
if (n.routing.mode !== "direct")
|
|
234
|
+
throw new Error("Direct agent assignment requires direct routing.");
|
|
235
|
+
return await p({ text: `Doing a direct route to agent: ${n.routing.agentId}` }, e), {
|
|
236
|
+
...n,
|
|
237
|
+
currentIntent: n.routing.agentId,
|
|
238
|
+
requiresFollowUp: !1,
|
|
239
|
+
agentExecutionContext: {
|
|
240
|
+
...n.agentExecutionContext,
|
|
241
|
+
assignedTask: n.agentExecutionContext.userRequest
|
|
242
|
+
}
|
|
243
|
+
};
|
|
244
|
+
}, de = 3, ue = (n) => n.routing.mode === "direct" ? "assignDirectAgent" : "intentLLM", ge = (n) => n.routing.mode === "direct" || n.stepCount >= de || !n.requiresFollowUp ? "exit" : "intentLLM", le = () => new T(D).addNode("ingestInput", J).addNode("assignDirectAgent", ce).addNode("intentLLM", F).addNode("executeRegisteredAgent", oe).addNode("exit", X).addEdge(j, "ingestInput").addConditionalEdges("ingestInput", ue).addEdge("assignDirectAgent", "executeRegisteredAgent").addConditionalEdges("intentLLM", (e) => e.currentIntent === "none" || e.currentIntent === e.lastExecutedAgent ? "exit" : "executeRegisteredAgent").addConditionalEdges("executeRegisteredAgent", ge).addEdge("exit", H), he = (n, e) => {
|
|
245
|
+
const r = n.output?.usage_metadata ?? e.usage_metadata, s = n.output?.llmOutput?.tokenUsage, t = r?.input_tokens ?? s?.promptTokens, a = r?.output_tokens ?? s?.completionTokens, i = r?.total_tokens ?? s?.totalTokens;
|
|
246
|
+
if (t === void 0 || a === void 0 || i === void 0)
|
|
247
|
+
return;
|
|
248
|
+
const o = r?.input_token_details?.cache_read, d = r?.output_token_details?.reasoning;
|
|
249
|
+
return {
|
|
250
|
+
input: t,
|
|
251
|
+
output: a,
|
|
252
|
+
total: i,
|
|
253
|
+
...o !== void 0 && { cacheRead: o },
|
|
254
|
+
...d !== void 0 && { reasoning: d }
|
|
255
|
+
};
|
|
256
|
+
}, pe = (n, e, r, s) => {
|
|
257
|
+
switch (n) {
|
|
258
|
+
case "chat_model":
|
|
259
|
+
case "llm":
|
|
260
|
+
return "model";
|
|
261
|
+
case "tool":
|
|
262
|
+
case "retriever":
|
|
263
|
+
return n;
|
|
264
|
+
case "chain":
|
|
265
|
+
return !s || e === "LangGraph" ? "workflow" : r === e ? "node" : "chain";
|
|
266
|
+
default:
|
|
267
|
+
return;
|
|
268
|
+
}
|
|
269
|
+
}, me = (n) => {
|
|
270
|
+
if (n instanceof Error)
|
|
271
|
+
return { message: n.message, name: n.name };
|
|
272
|
+
const e = n, r = typeof e?.message == "string" ? e.message : String(n ?? "Unknown runtime error"), s = typeof e?.name == "string" ? e.name : void 0;
|
|
273
|
+
return { message: r, ...s && { name: s } };
|
|
274
|
+
}, ye = ({
|
|
275
|
+
event: n,
|
|
276
|
+
runId: e,
|
|
277
|
+
parentSpanId: r,
|
|
278
|
+
timestamp: s
|
|
279
|
+
}) => {
|
|
280
|
+
const t = /^on_(.+)_(start|end|error)$/u.exec(n.event);
|
|
281
|
+
if (!t)
|
|
282
|
+
return;
|
|
283
|
+
const [, a, i] = t, o = n.metadata ?? {}, d = o.langgraph_node, c = pe(a, n.name, d, r);
|
|
284
|
+
if (!c)
|
|
285
|
+
return;
|
|
286
|
+
const u = o.agentId, g = o.model ?? o.ls_model_name, l = n.data, f = i === "end" && c === "model" ? he(l, o) : void 0, h = n.tags?.includes("langsmith:hidden") || d === "__start__", v = {
|
|
287
|
+
...g && { model: g },
|
|
288
|
+
...f && { tokenUsage: f },
|
|
289
|
+
...h && { internal: !0 }
|
|
290
|
+
}, w = {
|
|
291
|
+
id: n.run_id,
|
|
292
|
+
...r && { parentId: r },
|
|
293
|
+
label: n.name,
|
|
294
|
+
type: c,
|
|
295
|
+
...Object.keys(v).length && { metadata: v }
|
|
296
|
+
}, m = { runId: e, timestamp: s, type: "runtime", ...u && { agentId: u } };
|
|
297
|
+
switch (i) {
|
|
298
|
+
case "start":
|
|
299
|
+
return {
|
|
300
|
+
...m,
|
|
301
|
+
phase: "started",
|
|
302
|
+
span: {
|
|
303
|
+
...w,
|
|
304
|
+
...l?.input !== void 0 && { input: l.input }
|
|
305
|
+
}
|
|
306
|
+
};
|
|
307
|
+
case "end":
|
|
308
|
+
return {
|
|
309
|
+
...m,
|
|
310
|
+
phase: "completed",
|
|
311
|
+
span: {
|
|
312
|
+
...w,
|
|
313
|
+
...l?.output !== void 0 && { output: l.output }
|
|
314
|
+
}
|
|
315
|
+
};
|
|
316
|
+
case "error":
|
|
317
|
+
return { ...m, phase: "failed", span: { ...w, error: me(l?.error) } };
|
|
318
|
+
default:
|
|
319
|
+
return;
|
|
320
|
+
}
|
|
321
|
+
};
|
|
322
|
+
class S {
|
|
171
323
|
constructor() {
|
|
172
324
|
this.agentRegistry = /* @__PURE__ */ new Map();
|
|
173
325
|
}
|
|
174
326
|
register(e) {
|
|
175
|
-
const { agent:
|
|
176
|
-
if (this.agentRegistry.has(
|
|
177
|
-
throw new Error(`Duplicate agent id: ${
|
|
178
|
-
this.agentRegistry.set(
|
|
327
|
+
const { agent: r } = e;
|
|
328
|
+
if (this.agentRegistry.has(r.id))
|
|
329
|
+
throw new Error(`Duplicate agent id: ${r.id}`);
|
|
330
|
+
this.agentRegistry.set(r.id, e);
|
|
179
331
|
}
|
|
180
332
|
get(e) {
|
|
181
333
|
return this.agentRegistry.get(e);
|
|
@@ -184,42 +336,42 @@ class X {
|
|
|
184
336
|
return [...this.agentRegistry.values()];
|
|
185
337
|
}
|
|
186
338
|
}
|
|
187
|
-
class
|
|
339
|
+
class fe {
|
|
188
340
|
/**
|
|
189
341
|
* Create a new InterruptHandler tied to a specific compiled graph and config.
|
|
190
342
|
*/
|
|
191
|
-
constructor(e,
|
|
192
|
-
this.graph = e, this.config = { ...
|
|
343
|
+
constructor(e, r) {
|
|
344
|
+
this.graph = e, this.config = { ...r };
|
|
193
345
|
}
|
|
194
346
|
/**
|
|
195
347
|
* Returns a promise that resolves when the user provides a HITL response.
|
|
196
348
|
*/
|
|
197
349
|
async waitForUser() {
|
|
198
|
-
return await new Promise((e,
|
|
199
|
-
this.resolveWait = e, this.rejectWait =
|
|
350
|
+
return await new Promise((e, r) => {
|
|
351
|
+
this.resolveWait = e, this.rejectWait = r;
|
|
200
352
|
});
|
|
201
353
|
}
|
|
202
354
|
/**
|
|
203
355
|
* Resume graph execution after the UI responds to an interrupt.
|
|
204
356
|
*/
|
|
205
|
-
handle(e,
|
|
357
|
+
handle(e, r) {
|
|
206
358
|
try {
|
|
207
|
-
const
|
|
359
|
+
const s = {
|
|
208
360
|
agentId: e.agentId,
|
|
209
361
|
id: e.id,
|
|
210
|
-
payload:
|
|
211
|
-
},
|
|
362
|
+
payload: r
|
|
363
|
+
}, t = this.graph.streamEvents(null, {
|
|
212
364
|
...this.config,
|
|
213
365
|
configurable: {
|
|
214
366
|
...this.config.configurable,
|
|
215
|
-
hitlResponse:
|
|
367
|
+
hitlResponse: s
|
|
216
368
|
},
|
|
217
369
|
subgraphs: !0,
|
|
218
370
|
version: "v2"
|
|
219
371
|
});
|
|
220
|
-
this.resolveWait?.(
|
|
221
|
-
} catch (
|
|
222
|
-
this.rejectWait?.(
|
|
372
|
+
this.resolveWait?.(t);
|
|
373
|
+
} catch (s) {
|
|
374
|
+
this.rejectWait?.(s);
|
|
223
375
|
} finally {
|
|
224
376
|
this.resolveWait = void 0, this.rejectWait = void 0;
|
|
225
377
|
}
|
|
@@ -231,157 +383,157 @@ class Y {
|
|
|
231
383
|
this.rejectWait && (this.rejectWait(new Error("Request cancelled by user.")), this.resolveWait = void 0, this.rejectWait = void 0);
|
|
232
384
|
}
|
|
233
385
|
}
|
|
234
|
-
const
|
|
386
|
+
const we = async (n) => {
|
|
235
387
|
try {
|
|
236
|
-
return await (await
|
|
388
|
+
return await (await L()).embedDocuments(n);
|
|
237
389
|
} catch (e) {
|
|
238
390
|
throw console.error("Failed to generate embeddings:", e), e;
|
|
239
391
|
}
|
|
240
|
-
},
|
|
241
|
-
const
|
|
242
|
-
if (
|
|
243
|
-
return
|
|
244
|
-
const
|
|
245
|
-
return e.set(
|
|
392
|
+
}, C = async (n, e) => {
|
|
393
|
+
const r = e.get(n);
|
|
394
|
+
if (r)
|
|
395
|
+
return r;
|
|
396
|
+
const s = await we([n]);
|
|
397
|
+
return e.set(n, s[0]), s[0];
|
|
246
398
|
};
|
|
247
|
-
async function
|
|
248
|
-
const
|
|
399
|
+
async function ve(n, e, r, s) {
|
|
400
|
+
const t = `req-${Date.now()}`, i = {
|
|
249
401
|
type: "layerSearch",
|
|
250
|
-
precomputedEmbedding:
|
|
251
|
-
requestId:
|
|
252
|
-
minScore:
|
|
402
|
+
precomputedEmbedding: s ? await C(n, s) : void 0,
|
|
403
|
+
requestId: t,
|
|
404
|
+
minScore: r
|
|
253
405
|
};
|
|
254
|
-
return await new Promise((
|
|
255
|
-
const d = (
|
|
256
|
-
|
|
406
|
+
return await new Promise((o) => {
|
|
407
|
+
const d = (c) => {
|
|
408
|
+
c.data.requestId === t && o(c.data.results);
|
|
257
409
|
};
|
|
258
|
-
e.addEventListener("message", d, { once: !0 }), e.postMessage(
|
|
410
|
+
e.addEventListener("message", d, { once: !0 }), e.postMessage(i);
|
|
259
411
|
});
|
|
260
412
|
}
|
|
261
|
-
function
|
|
262
|
-
const { worker: e } =
|
|
413
|
+
function Ee(n) {
|
|
414
|
+
const { worker: e } = n;
|
|
263
415
|
return {
|
|
264
416
|
async searchLayers({
|
|
265
|
-
text:
|
|
266
|
-
minScore:
|
|
267
|
-
embeddingCache:
|
|
417
|
+
text: r,
|
|
418
|
+
minScore: s,
|
|
419
|
+
embeddingCache: t
|
|
268
420
|
}) {
|
|
269
|
-
return await
|
|
421
|
+
return await ve(r, e, s, t);
|
|
270
422
|
}
|
|
271
423
|
};
|
|
272
424
|
}
|
|
273
|
-
const
|
|
274
|
-
combinedQuery:
|
|
425
|
+
const Re = async ({
|
|
426
|
+
combinedQuery: n,
|
|
275
427
|
layerIds: e,
|
|
276
|
-
embeddingsWorker:
|
|
277
|
-
minScore:
|
|
278
|
-
topResults:
|
|
279
|
-
embeddingCache:
|
|
428
|
+
embeddingsWorker: r,
|
|
429
|
+
minScore: s,
|
|
430
|
+
topResults: t,
|
|
431
|
+
embeddingCache: a
|
|
280
432
|
}) => {
|
|
281
|
-
const
|
|
433
|
+
const i = `req-${Date.now()}`, o = a ? await C(n, a) : void 0, d = {
|
|
282
434
|
type: "fieldSearch",
|
|
283
435
|
layerIdForFieldsSearch: e,
|
|
284
|
-
precomputedEmbedding:
|
|
285
|
-
requestId:
|
|
286
|
-
minScore:
|
|
287
|
-
topResults:
|
|
436
|
+
precomputedEmbedding: o,
|
|
437
|
+
requestId: i,
|
|
438
|
+
minScore: s,
|
|
439
|
+
topResults: t
|
|
288
440
|
};
|
|
289
|
-
return await new Promise((
|
|
290
|
-
const
|
|
291
|
-
if (
|
|
441
|
+
return await new Promise((c) => {
|
|
442
|
+
const u = (g) => {
|
|
443
|
+
if (g.data.requestId !== i)
|
|
292
444
|
return;
|
|
293
|
-
const
|
|
294
|
-
layerId:
|
|
445
|
+
const l = g.data.results.map(({ layerId: f, results: h }) => ({
|
|
446
|
+
layerId: f,
|
|
295
447
|
results: h
|
|
296
448
|
}));
|
|
297
|
-
|
|
449
|
+
c(l);
|
|
298
450
|
};
|
|
299
|
-
|
|
451
|
+
r.addEventListener("message", u, { once: !0 }), r.postMessage(d);
|
|
300
452
|
});
|
|
301
453
|
};
|
|
302
|
-
function
|
|
303
|
-
const { worker: e } =
|
|
454
|
+
function xe(n) {
|
|
455
|
+
const { worker: e } = n;
|
|
304
456
|
return {
|
|
305
|
-
async searchFields({ text:
|
|
306
|
-
return await
|
|
307
|
-
combinedQuery:
|
|
308
|
-
layerIds:
|
|
457
|
+
async searchFields({ text: r, layerIds: s, minScore: t, topResults: a, embeddingCache: i }) {
|
|
458
|
+
return await Re({
|
|
459
|
+
combinedQuery: r,
|
|
460
|
+
layerIds: s,
|
|
309
461
|
embeddingsWorker: e,
|
|
310
|
-
minScore:
|
|
311
|
-
topResults:
|
|
312
|
-
embeddingCache:
|
|
462
|
+
minScore: t,
|
|
463
|
+
topResults: a,
|
|
464
|
+
embeddingCache: i
|
|
313
465
|
});
|
|
314
466
|
}
|
|
315
467
|
};
|
|
316
468
|
}
|
|
317
|
-
const
|
|
318
|
-
const e =
|
|
469
|
+
const Se = (n) => {
|
|
470
|
+
const e = W.safeParse(n);
|
|
319
471
|
if (!e.success)
|
|
320
472
|
throw new Error("Embeddings response validation failed. Regenerate embeddings.");
|
|
321
473
|
return e.data;
|
|
322
|
-
},
|
|
323
|
-
const
|
|
324
|
-
if (e.allLayers.forEach((
|
|
325
|
-
|
|
326
|
-
}),
|
|
474
|
+
}, be = (n, e) => {
|
|
475
|
+
const r = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map();
|
|
476
|
+
if (e.allLayers.forEach((t) => {
|
|
477
|
+
t instanceof V && s.set(t.id, t);
|
|
478
|
+
}), n.length !== s.size)
|
|
327
479
|
throw new Error("Layer count mismatch during registry restoration. Regenerate embeddings.");
|
|
328
|
-
for (const
|
|
329
|
-
const
|
|
330
|
-
if (!
|
|
480
|
+
for (const t of n) {
|
|
481
|
+
const a = s.get(t.id);
|
|
482
|
+
if (!a)
|
|
331
483
|
throw new Error(
|
|
332
|
-
`Layer with ID ${
|
|
484
|
+
`Layer with ID ${t.id} not found in the original map during registry restoration. Regenerate embeddings.`
|
|
333
485
|
);
|
|
334
|
-
if (
|
|
486
|
+
if (t.fields.length !== a.fields.length)
|
|
335
487
|
throw new Error(
|
|
336
|
-
`Field count mismatch for layer ID ${
|
|
488
|
+
`Field count mismatch for layer ID ${t.id} during registry restoration. Regenerate embeddings.`
|
|
337
489
|
);
|
|
338
|
-
const
|
|
339
|
-
name:
|
|
340
|
-
title:
|
|
341
|
-
description:
|
|
342
|
-
},
|
|
343
|
-
for (const d of
|
|
344
|
-
const
|
|
345
|
-
if (!
|
|
490
|
+
const i = {
|
|
491
|
+
name: t.name,
|
|
492
|
+
title: t.title,
|
|
493
|
+
description: t.description
|
|
494
|
+
}, o = /* @__PURE__ */ new Map();
|
|
495
|
+
for (const d of t.fields) {
|
|
496
|
+
const c = a.fieldsIndex.get(d.name);
|
|
497
|
+
if (!c)
|
|
346
498
|
throw new Error(
|
|
347
|
-
`Field with name ${d.name} not found in the original layer ${
|
|
499
|
+
`Field with name ${d.name} not found in the original layer ${t.id} during registry restoration. Regenerate embeddings.`
|
|
348
500
|
);
|
|
349
|
-
|
|
501
|
+
o.set(d.name, {
|
|
350
502
|
name: d.name,
|
|
351
|
-
alias:
|
|
503
|
+
alias: a.getFieldAlias(d.name) ?? d.alias,
|
|
352
504
|
description: d.description,
|
|
353
|
-
type:
|
|
354
|
-
valueType:
|
|
355
|
-
domain:
|
|
505
|
+
type: c.type || "unknown",
|
|
506
|
+
valueType: c.valueType || "unknown",
|
|
507
|
+
domain: a.getFieldDomain(d.name) ?? void 0
|
|
356
508
|
});
|
|
357
509
|
}
|
|
358
|
-
|
|
359
|
-
layerItem:
|
|
360
|
-
fieldRegistry:
|
|
510
|
+
r.set(t.id, {
|
|
511
|
+
layerItem: i,
|
|
512
|
+
fieldRegistry: o
|
|
361
513
|
});
|
|
362
514
|
}
|
|
363
|
-
return
|
|
364
|
-
},
|
|
515
|
+
return r;
|
|
516
|
+
}, Ae = async (n) => {
|
|
365
517
|
try {
|
|
366
|
-
return (await
|
|
518
|
+
return (await z(n, {
|
|
367
519
|
responseType: "json"
|
|
368
520
|
})).data;
|
|
369
521
|
} catch (e) {
|
|
370
|
-
throw new Error(`Failed to fetch data from ${
|
|
522
|
+
throw new Error(`Failed to fetch data from ${n}: ${String(e)}`);
|
|
371
523
|
}
|
|
372
|
-
},
|
|
373
|
-
const e =
|
|
524
|
+
}, Ce = async (n) => {
|
|
525
|
+
const e = n.map;
|
|
374
526
|
if (!e?.portalItem)
|
|
375
527
|
throw new Error("WebMap portal item is missing.");
|
|
376
|
-
const { resources:
|
|
377
|
-
if (!
|
|
528
|
+
const { resources: r } = await e.portalItem.fetchResources(), s = r.find((i) => i.resource.path === "embeddings-v01.json");
|
|
529
|
+
if (!s?.resource.url)
|
|
378
530
|
throw new Error("Embeddings resource 'embeddings-v01.json' not found in the webmap portal item.");
|
|
379
|
-
const
|
|
380
|
-
return
|
|
531
|
+
const t = await Ae(s.resource.url);
|
|
532
|
+
return Se(t);
|
|
381
533
|
};
|
|
382
|
-
class
|
|
534
|
+
class k {
|
|
383
535
|
constructor() {
|
|
384
|
-
this.orchestratorReady = !1, this.chatHistory = [], this.priorSteps = [], this.sharedState = {}, this.
|
|
536
|
+
this.orchestratorReady = !1, this.chatHistory = [], this.priorSteps = [], this.sharedState = {}, this.sharedResources = [], this.agentRegistry = new S(), this.activeRunId = "", this.cancelledRunIds = /* @__PURE__ */ new Set(), this.parentRunIds = /* @__PURE__ */ new Map(), this.activeRuntimeSpans = /* @__PURE__ */ new Map(), this.runtimeEventsEnabled = !1, this.streamEpoch = 0;
|
|
385
537
|
}
|
|
386
538
|
/**
|
|
387
539
|
* Creates and returns an AI-ready Orchestrator instance.
|
|
@@ -389,21 +541,22 @@ class v {
|
|
|
389
541
|
* @returns Ready Orchestrator.
|
|
390
542
|
*/
|
|
391
543
|
static async init(e) {
|
|
392
|
-
const
|
|
544
|
+
const r = new k();
|
|
545
|
+
r.runtimeEventsEnabled = e.runtimeEventsEnabled ?? !1;
|
|
393
546
|
try {
|
|
394
547
|
if (e.view?.map) {
|
|
395
|
-
await
|
|
396
|
-
const
|
|
397
|
-
|
|
548
|
+
await N.whenOnce(() => e.view.ready);
|
|
549
|
+
const s = await Ce(e.view), t = be(
|
|
550
|
+
s.layers,
|
|
398
551
|
e.view.map
|
|
399
552
|
);
|
|
400
|
-
|
|
553
|
+
r.layersAndFieldsRegistry = t, r.embeddingsWorker = await B(s);
|
|
401
554
|
}
|
|
402
|
-
return e.agents?.forEach((
|
|
403
|
-
|
|
404
|
-
}),
|
|
405
|
-
} catch (
|
|
406
|
-
throw console.error("Orchestrator initialization failed:",
|
|
555
|
+
return e.agents?.forEach((s) => {
|
|
556
|
+
r.agentRegistry.register(s);
|
|
557
|
+
}), r.orchestratorReady = !0, r;
|
|
558
|
+
} catch (s) {
|
|
559
|
+
throw console.error("Orchestrator initialization failed:", s), s;
|
|
407
560
|
}
|
|
408
561
|
}
|
|
409
562
|
/**
|
|
@@ -413,77 +566,105 @@ class v {
|
|
|
413
566
|
* - `interrupt`: HITL required, wait for `resumeInterrupt()`
|
|
414
567
|
* - `completed`: final result with chat history + layer styling
|
|
415
568
|
* - `cancelled`: user aborted the run
|
|
569
|
+
* @param userInput User request to process.
|
|
570
|
+
* @param options Agent selection and routing behavior for this run.
|
|
416
571
|
*/
|
|
417
|
-
async *ask(e) {
|
|
572
|
+
async *ask(e, r = {}) {
|
|
418
573
|
if (!this.orchestratorReady)
|
|
419
574
|
throw new Error("Orchestrator is not ready yet.");
|
|
420
575
|
if (!this.agentRegistry.list().length)
|
|
421
576
|
throw new Error("Orchestrator has no registered agents.");
|
|
577
|
+
const s = this.createRequestAgentRegistry(r);
|
|
578
|
+
if (!s.list().length)
|
|
579
|
+
throw new Error("Orchestrator has no agents selected for this request.");
|
|
422
580
|
if (++this.streamEpoch, !e.trim())
|
|
423
581
|
return;
|
|
424
|
-
|
|
425
|
-
|
|
582
|
+
const t = A();
|
|
583
|
+
this.parentRunIds.clear(), this.activeRuntimeSpans.clear(), this.activeRunId = t, this.activeAbortController = new AbortController(), this.graph || (this.graph = le().compile({ checkpointer: new P() }));
|
|
584
|
+
const a = this.embeddingsWorker ? Ee({ worker: this.embeddingsWorker }) : void 0, i = this.embeddingsWorker ? xe({ worker: this.embeddingsWorker }) : void 0, o = /* @__PURE__ */ new Map(), d = r.routing === "direct" ? { mode: "direct", agentId: r.agentId } : { mode: "auto" }, c = {
|
|
585
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
586
|
+
thread_id: t,
|
|
587
|
+
hitlResponse: null,
|
|
588
|
+
services: {
|
|
589
|
+
layerSearch: a,
|
|
590
|
+
fieldSearch: i,
|
|
591
|
+
layersAndFieldsRegistry: this.layersAndFieldsRegistry,
|
|
592
|
+
agentRegistry: s,
|
|
593
|
+
embeddingCache: o
|
|
594
|
+
}
|
|
595
|
+
}, u = {
|
|
426
596
|
version: "v2",
|
|
427
597
|
streamMode: "custom",
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
hitlResponse: null,
|
|
432
|
-
services: {
|
|
433
|
-
layerSearch: s,
|
|
434
|
-
fieldSearch: n,
|
|
435
|
-
layersAndFieldsRegistry: this.layersAndFieldsRegistry,
|
|
436
|
-
agentRegistry: this.agentRegistry,
|
|
437
|
-
embeddingCache: r
|
|
438
|
-
}
|
|
439
|
-
},
|
|
598
|
+
signal: this.activeAbortController.signal,
|
|
599
|
+
...this.runtimeEventsEnabled && { callbacks: [this.createHierarchyCallback()] },
|
|
600
|
+
configurable: c,
|
|
440
601
|
subgraphs: !0
|
|
441
|
-
},
|
|
602
|
+
}, g = this.graph?.streamEvents(
|
|
442
603
|
{
|
|
604
|
+
routing: d,
|
|
443
605
|
agentExecutionContext: {
|
|
444
606
|
userRequest: e,
|
|
445
607
|
messages: this.chatHistory,
|
|
446
608
|
priorSteps: this.priorSteps,
|
|
447
|
-
sharedState: this.sharedState
|
|
609
|
+
sharedState: this.sharedState,
|
|
610
|
+
sharedResources: this.sharedResources
|
|
448
611
|
}
|
|
449
612
|
},
|
|
450
|
-
|
|
451
|
-
),
|
|
452
|
-
|
|
453
|
-
|
|
613
|
+
u
|
|
614
|
+
), l = ++this.streamEpoch;
|
|
615
|
+
if (yield* this.pipeStream(g, l, t), this.isRunCancelled(t)) {
|
|
616
|
+
yield* this.createCancellationEvents(t);
|
|
617
|
+
return;
|
|
618
|
+
}
|
|
619
|
+
for (; ; ) {
|
|
620
|
+
if (this.isRunCancelled(t)) {
|
|
621
|
+
yield* this.createCancellationEvents(t);
|
|
622
|
+
return;
|
|
623
|
+
}
|
|
624
|
+
const m = (await this.graph.getState(u, { subgraphs: !0 })).tasks.find((y) => y.interrupts.length > 0)?.interrupts[0]?.value;
|
|
454
625
|
if (!m)
|
|
455
626
|
break;
|
|
456
|
-
this.currentInterrupt = m, this.interruptHandler = new
|
|
627
|
+
this.currentInterrupt = m, this.interruptHandler = new fe(this.graph, u), yield* this.closeActiveRuntimeSpans(t, "interrupted"), yield { runId: t, timestamp: Date.now(), type: "interrupt", interrupt: m };
|
|
457
628
|
try {
|
|
458
|
-
const
|
|
459
|
-
yield* this.pipeStream(
|
|
460
|
-
} catch (
|
|
461
|
-
if (
|
|
629
|
+
const y = await this.interruptHandler.waitForUser(), I = ++this.streamEpoch;
|
|
630
|
+
yield* this.pipeStream(y, I, t);
|
|
631
|
+
} catch (y) {
|
|
632
|
+
if (this.isRunCancelled(t)) {
|
|
633
|
+
yield* this.createCancellationEvents(t);
|
|
634
|
+
return;
|
|
635
|
+
}
|
|
636
|
+
if (y) {
|
|
462
637
|
yield {
|
|
463
|
-
runId:
|
|
638
|
+
runId: t,
|
|
464
639
|
timestamp: Date.now(),
|
|
465
640
|
type: "error",
|
|
466
|
-
error: { message:
|
|
641
|
+
error: { message: y?.message }
|
|
467
642
|
};
|
|
468
643
|
return;
|
|
469
644
|
}
|
|
470
|
-
yield { runId: this.threadId, timestamp: Date.now(), type: "cancelled" };
|
|
471
|
-
return;
|
|
472
645
|
}
|
|
473
646
|
}
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
647
|
+
if (this.isRunCancelled(t)) {
|
|
648
|
+
yield* this.createCancellationEvents(t);
|
|
649
|
+
return;
|
|
650
|
+
}
|
|
651
|
+
const h = (await this.graph.getState(u, { subgraphs: !0 })).values;
|
|
652
|
+
if (this.isRunCancelled(t)) {
|
|
653
|
+
yield* this.createCancellationEvents(t);
|
|
654
|
+
return;
|
|
655
|
+
}
|
|
656
|
+
this.chatHistory = h.agentExecutionContext.messages.length ? h.agentExecutionContext.messages : this.chatHistory, this.priorSteps = h.agentExecutionContext.priorSteps?.slice(-5) ?? [], this.sharedState = h.agentExecutionContext.sharedState ?? {}, this.sharedResources = h.agentExecutionContext.sharedResources ?? [], yield {
|
|
657
|
+
runId: t,
|
|
477
658
|
timestamp: Date.now(),
|
|
478
659
|
type: "completed",
|
|
479
|
-
result: { content:
|
|
660
|
+
result: { content: h.finalOutputMessage }
|
|
480
661
|
};
|
|
481
662
|
}
|
|
482
663
|
/**
|
|
483
664
|
* Start a new conversation by clearing chat history, prior steps, and shared state.
|
|
484
665
|
*/
|
|
485
666
|
newConversation() {
|
|
486
|
-
this.chatHistory = [], this.priorSteps = [], this.sharedState = {};
|
|
667
|
+
this.chatHistory = [], this.priorSteps = [], this.sharedState = {}, this.sharedResources = [];
|
|
487
668
|
}
|
|
488
669
|
/**
|
|
489
670
|
* Generic resume for any HITL interrupt.
|
|
@@ -500,29 +681,98 @@ class v {
|
|
|
500
681
|
cancelInterrupt() {
|
|
501
682
|
this.interruptHandler && this.interruptHandler.cancel();
|
|
502
683
|
}
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
684
|
+
/**
|
|
685
|
+
* Cancels the active run.
|
|
686
|
+
*
|
|
687
|
+
* - Aborts in-flight work for consumers that honor AbortSignal.
|
|
688
|
+
* - Invalidates active stream iterators via epoch bump.
|
|
689
|
+
* - Unblocks any pending HITL wait.
|
|
690
|
+
*/
|
|
691
|
+
cancel() {
|
|
692
|
+
this.activeRunId && (this.cancelledRunIds.add(this.activeRunId), this.activeAbortController?.abort(), ++this.streamEpoch, this.interruptHandler?.cancel());
|
|
693
|
+
}
|
|
694
|
+
async *pipeStream(e, r, s) {
|
|
695
|
+
try {
|
|
696
|
+
for await (const t of e) {
|
|
697
|
+
if (this.isRunCancelled(s) || r !== this.streamEpoch)
|
|
698
|
+
break;
|
|
699
|
+
if (this.runtimeEventsEnabled) {
|
|
700
|
+
const a = ye({
|
|
701
|
+
event: t,
|
|
702
|
+
runId: s,
|
|
703
|
+
parentSpanId: this.parentRunIds.get(t.run_id),
|
|
704
|
+
timestamp: Date.now()
|
|
705
|
+
});
|
|
706
|
+
a && (a.phase === "started" ? this.activeRuntimeSpans.set(a.span.id, a) : this.activeRuntimeSpans.delete(a.span.id), yield a);
|
|
707
|
+
}
|
|
708
|
+
t.event === "on_custom_event" && t.name === "trace_message" ? yield { runId: s, timestamp: Date.now(), type: "trace", data: t.data } : t.name === "graph_ux_suggestion" && (yield {
|
|
709
|
+
runId: s,
|
|
710
|
+
timestamp: Date.now(),
|
|
711
|
+
type: "ux-suggestion",
|
|
712
|
+
suggestion: t.data
|
|
713
|
+
});
|
|
508
714
|
}
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
type: "ux-suggestion",
|
|
513
|
-
suggestion: n.data
|
|
514
|
-
});
|
|
715
|
+
} catch (t) {
|
|
716
|
+
if (!this.isRunCancelled(s))
|
|
717
|
+
throw t;
|
|
515
718
|
}
|
|
516
719
|
}
|
|
720
|
+
*createCancellationEvents(e) {
|
|
721
|
+
yield* this.closeActiveRuntimeSpans(e, "cancelled"), yield { runId: e, timestamp: Date.now(), type: "cancelled", reason: "user" };
|
|
722
|
+
}
|
|
723
|
+
*closeActiveRuntimeSpans(e, r) {
|
|
724
|
+
const s = Date.now(), t = [...this.activeRuntimeSpans.values()].reverse();
|
|
725
|
+
this.activeRuntimeSpans.clear();
|
|
726
|
+
for (const a of t) {
|
|
727
|
+
const { input: i, ...o } = a.span;
|
|
728
|
+
yield {
|
|
729
|
+
type: "runtime",
|
|
730
|
+
phase: r,
|
|
731
|
+
runId: e,
|
|
732
|
+
timestamp: s,
|
|
733
|
+
...a.agentId && { agentId: a.agentId },
|
|
734
|
+
span: o
|
|
735
|
+
};
|
|
736
|
+
}
|
|
737
|
+
}
|
|
738
|
+
// v2 stream events omit parent run IDs, so capture them through callbacks to preserve the normalized span hierarchy.
|
|
739
|
+
createHierarchyCallback() {
|
|
740
|
+
const e = (r, s) => {
|
|
741
|
+
s && this.parentRunIds.set(r, s);
|
|
742
|
+
};
|
|
743
|
+
return G.fromMethods({
|
|
744
|
+
handleLLMStart: (r, s, t, a) => e(t, a),
|
|
745
|
+
handleChatModelStart: (r, s, t, a) => e(t, a),
|
|
746
|
+
handleChainStart: (r, s, t, a) => e(t, a),
|
|
747
|
+
handleToolStart: (r, s, t, a) => e(t, a),
|
|
748
|
+
handleRetrieverStart: (r, s, t, a) => e(t, a)
|
|
749
|
+
});
|
|
750
|
+
}
|
|
751
|
+
isRunCancelled(e) {
|
|
752
|
+
return this.cancelledRunIds.has(e);
|
|
753
|
+
}
|
|
754
|
+
/**
|
|
755
|
+
* Creates a request-scoped registry containing all agents by default,
|
|
756
|
+
* or only the explicitly selected agents when filtering is requested.
|
|
757
|
+
*/
|
|
758
|
+
createRequestAgentRegistry(e) {
|
|
759
|
+
const r = e.routing === "direct" ? [e.agentId] : e.agentIds, s = r ? r.map((a) => {
|
|
760
|
+
const i = this.agentRegistry.get(a);
|
|
761
|
+
if (!i)
|
|
762
|
+
throw new Error(`Agent is not registered: ${a}`);
|
|
763
|
+
return i;
|
|
764
|
+
}) : this.agentRegistry.list(), t = new S();
|
|
765
|
+
return s.forEach((a) => t.register(a)), t;
|
|
766
|
+
}
|
|
517
767
|
/**
|
|
518
768
|
* Disposes this instance by terminating the embeddings worker
|
|
519
769
|
* and cleaning up all related resources.
|
|
520
770
|
*/
|
|
521
771
|
dispose() {
|
|
522
|
-
this.embeddingsWorker && (this.embeddingsWorker.terminate(), this.embeddingsWorker = void 0), this.orchestratorReady = !1;
|
|
772
|
+
this.sharedResources = [], this.embeddingsWorker && (this.embeddingsWorker.terminate(), this.embeddingsWorker = void 0), this.orchestratorReady = !1;
|
|
523
773
|
}
|
|
524
774
|
}
|
|
525
775
|
export {
|
|
526
|
-
|
|
527
|
-
|
|
776
|
+
k as O,
|
|
777
|
+
we as g
|
|
528
778
|
};
|