@arcgis/ai-components 5.2.0-next.10 → 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 +4 -2
- 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/{SWOXSJ62.js → 2O4DON37.js} +1 -1
- package/dist/cdn/34O57OGV.js +2 -0
- package/dist/cdn/{5W7S2RS4.js → 3UEKINYC.js} +1 -1
- 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/{D3TNNRP4.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/{T537PKP4.js → FYZATVB3.js} +1 -1
- 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/{MODWHY3R.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/{VMXLYWUK.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/{GTLS44GI.js → SXM4NUT5.js} +1 -1
- 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/{2SJAOYZT.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/chunks/adapter.js +1295 -2104
- 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 +131 -182
- 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 +259 -282
- 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 +39 -33
- package/dist/chunks/mergeWhereClauses.js +15 -0
- package/dist/chunks/navigationGraph.js +140 -116
- package/dist/chunks/navigation_intent_prompt.js +8 -2
- package/dist/chunks/orchestrator.js +444 -233
- package/dist/chunks/resolvePointGeometryFilter.js +92 -0
- package/dist/chunks/state.js +21 -27
- package/dist/chunks/toolCallResponse.js +14 -10
- package/dist/chunks/utils2.js +11 -11
- package/dist/components/arcgis-assistant/customElement.d.ts +82 -1
- package/dist/components/arcgis-assistant/customElement.js +332 -183
- 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.js +22 -17
- 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 +4 -0
- package/dist/components/arcgis-assistant-interrupt/customElement.js +11 -12
- package/dist/components/arcgis-assistant-interrupt-preview/customElement.js +12 -8
- 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 +3 -0
- package/dist/components/arcgis-assistant-message/customElement.js +9 -8
- package/dist/components/arcgis-assistant-message-block/customElement.js +1 -1
- package/dist/components/arcgis-assistant-message-loading/customElement.d.ts +3 -0
- package/dist/components/arcgis-assistant-message-loading/customElement.js +11 -10
- package/dist/components/arcgis-assistant-message-text/customElement.d.ts +1 -0
- 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.js +34 -52
- package/dist/components/arcgis-assistant-user-message/customElement.d.ts +2 -0
- 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/loader.js +6 -6
- package/dist/oauth-callback.html +1 -1
- package/dist/orchestrator/orchestrator/orchestratorEvents.d.ts +78 -0
- package/dist/types/lumina.d.ts +5 -4
- package/dist/types/preact.d.ts +5 -4
- package/dist/types/react.d.ts +5 -4
- package/dist/types/stencil.d.ts +7 -6
- package/dist/utils/index.d.ts +65 -38
- package/dist/utils/index.js +56 -55
- package/package.json +32 -12
- package/dist/cdn/462JBSEV.js +0 -422
- package/dist/cdn/5QAHYX7Y.js +0 -5
- package/dist/cdn/64PJB5NU.js +0 -2
- package/dist/cdn/6AWNQHCO.js +0 -4
- package/dist/cdn/AXDZBBNL.js +0 -45
- package/dist/cdn/BIV2IPHH.js +0 -2
- package/dist/cdn/CCY4TSBO.js +0 -2
- package/dist/cdn/CTSALWEP.js +0 -2
- package/dist/cdn/D2N2NSRQ.js +0 -72
- package/dist/cdn/DOV5ZJ7M.js +0 -2
- package/dist/cdn/EEUCKMU7.js +0 -2
- package/dist/cdn/EGHBXLNG.js +0 -2
- package/dist/cdn/ETRWZ3MS.js +0 -108
- package/dist/cdn/EWI4V3GQ.js +0 -36
- package/dist/cdn/F2AHA4GB.js +0 -54
- package/dist/cdn/I6HNBTWY.js +0 -2
- package/dist/cdn/JBHNHHWO.js +0 -3
- package/dist/cdn/JOFUPKIB.js +0 -2
- package/dist/cdn/KMQ3SP4I.js +0 -5
- package/dist/cdn/KUEOKIQR.js +0 -2
- package/dist/cdn/LKRAPK4A.js +0 -165
- package/dist/cdn/NXKKG5TK.js +0 -2
- package/dist/cdn/OBUZ7HBN.js +0 -2
- package/dist/cdn/OIVRK7HT.js +0 -2
- package/dist/cdn/RUURNLTP.js +0 -2
- package/dist/cdn/RVOAPUBN.js +0 -2
- package/dist/cdn/TSZPHE7L.js +0 -22
- package/dist/cdn/VAZNJSKA.js +0 -16
- package/dist/cdn/VNQN5ZQO.js +0 -14
- package/dist/cdn/WIDTPVSU.js +0 -2
- package/dist/cdn/XER22VYQ.js +0 -3
- package/dist/cdn/YIMNOUTF.js +0 -2
|
@@ -1,80 +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:
|
|
16
|
+
webmapEmbeddings: n,
|
|
14
17
|
auth: { apiUrl: r, token: a }
|
|
15
18
|
};
|
|
16
|
-
return e.postMessage(i), await new Promise((
|
|
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
|
-
const r =
|
|
33
|
-
if (
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
const s = r?.services.agentRegistry.list().map((
|
|
38
|
-
return await
|
|
39
|
-
},
|
|
40
|
-
if (!
|
|
41
|
-
|
|
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.`);
|
|
42
45
|
return;
|
|
43
46
|
}
|
|
44
47
|
const r = {};
|
|
45
|
-
for (const [s,
|
|
46
|
-
if (!
|
|
48
|
+
for (const [s, t] of Object.entries(n)) {
|
|
49
|
+
if (!E(t) || !("value" in t)) {
|
|
47
50
|
console.warn(
|
|
48
51
|
`Agent "${e}" returned invalid sharedStatePatch entry for key "${s}". Ignoring that entry.`
|
|
49
52
|
);
|
|
50
53
|
continue;
|
|
51
54
|
}
|
|
52
|
-
r[s] = { value:
|
|
55
|
+
r[s] = { value: t.value };
|
|
53
56
|
}
|
|
54
57
|
return r;
|
|
55
|
-
},
|
|
56
|
-
const { previousSharedState: e, patch: r, agentId: s } =
|
|
58
|
+
}, Z = (n) => {
|
|
59
|
+
const { previousSharedState: e, patch: r, agentId: s } = n;
|
|
57
60
|
if (!r)
|
|
58
61
|
return e;
|
|
59
|
-
const
|
|
62
|
+
const t = Date.now(), a = {
|
|
60
63
|
...e
|
|
61
64
|
};
|
|
62
|
-
for (const [i,
|
|
63
|
-
|
|
64
|
-
value:
|
|
65
|
+
for (const [i, o] of Object.entries(r))
|
|
66
|
+
o?.value !== void 0 && (a[i] = {
|
|
67
|
+
value: o.value,
|
|
65
68
|
meta: {
|
|
66
69
|
updatedByAgentId: s,
|
|
67
|
-
updatedAt:
|
|
70
|
+
updatedAt: t
|
|
68
71
|
}
|
|
69
72
|
});
|
|
70
73
|
return a;
|
|
71
|
-
},
|
|
72
|
-
if (
|
|
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)
|
|
73
76
|
return;
|
|
74
|
-
|
|
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")
|
|
120
|
+
return;
|
|
121
|
+
const e = n.trim();
|
|
75
122
|
return e || void 0;
|
|
76
|
-
},
|
|
77
|
-
switch (
|
|
123
|
+
}, ae = (n) => {
|
|
124
|
+
switch (n) {
|
|
78
125
|
case "failed":
|
|
79
126
|
return "Agent failed without a summary.";
|
|
80
127
|
case "unknown":
|
|
@@ -84,98 +131,195 @@ const U = async (t) => {
|
|
|
84
131
|
default:
|
|
85
132
|
return "Agent completed without a summary.";
|
|
86
133
|
}
|
|
87
|
-
},
|
|
88
|
-
const r =
|
|
89
|
-
a === "unknown" && console.warn(`Agent "${
|
|
90
|
-
const i =
|
|
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);
|
|
91
138
|
return {
|
|
92
139
|
outputMessage: r,
|
|
93
|
-
summary: s ?? r ??
|
|
140
|
+
summary: s ?? r ?? ae(a),
|
|
94
141
|
status: a,
|
|
95
|
-
sharedStatePatch: i
|
|
142
|
+
sharedStatePatch: i,
|
|
143
|
+
sharedResourceAdditions: o
|
|
96
144
|
};
|
|
97
|
-
},
|
|
98
|
-
const r =
|
|
99
|
-
if (
|
|
100
|
-
return await
|
|
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,
|
|
102
150
|
currentIntent: "none",
|
|
103
151
|
requiresFollowUp: !1
|
|
104
152
|
};
|
|
105
|
-
const { agentRegistry: s } = r?.services ?? {},
|
|
106
|
-
if (!
|
|
107
|
-
return console.warn(`No agent found for intent: ${
|
|
108
|
-
await
|
|
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);
|
|
109
157
|
const a = {
|
|
110
158
|
...e ?? {},
|
|
159
|
+
metadata: {
|
|
160
|
+
...e?.metadata,
|
|
161
|
+
agentId: t.agent.id
|
|
162
|
+
},
|
|
111
163
|
configurable: {
|
|
112
164
|
...r ?? {},
|
|
113
|
-
agentId:
|
|
114
|
-
context:
|
|
165
|
+
agentId: t.agent.id,
|
|
166
|
+
context: t.getContext ? await t.getContext() : void 0
|
|
115
167
|
}
|
|
116
168
|
};
|
|
117
169
|
let i;
|
|
118
170
|
try {
|
|
119
|
-
const
|
|
171
|
+
const c = await t.agent.createGraph().compile().invoke(
|
|
120
172
|
{
|
|
121
173
|
agentExecutionContext: {
|
|
122
|
-
...
|
|
174
|
+
...n.agentExecutionContext,
|
|
123
175
|
// deep clone on messages did not work in agents, so its a shallow clone here.
|
|
124
|
-
messages: [...
|
|
176
|
+
messages: [...n.agentExecutionContext.messages],
|
|
125
177
|
// deep clone to prevent accidental mutations by agents
|
|
126
|
-
priorSteps: structuredClone(
|
|
127
|
-
sharedState: structuredClone(
|
|
178
|
+
priorSteps: structuredClone(n.agentExecutionContext.priorSteps ?? []),
|
|
179
|
+
sharedState: structuredClone(n.agentExecutionContext.sharedState ?? {}),
|
|
180
|
+
sharedResources: structuredClone(n.agentExecutionContext.sharedResources ?? [])
|
|
128
181
|
}
|
|
129
182
|
},
|
|
130
183
|
a
|
|
131
184
|
);
|
|
132
|
-
i =
|
|
133
|
-
} catch (
|
|
134
|
-
if (
|
|
135
|
-
throw
|
|
136
|
-
const
|
|
137
|
-
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 = {
|
|
138
191
|
status: "failed",
|
|
139
|
-
outputMessage: `Agent execution failed: ${
|
|
140
|
-
summary: `Agent execution failed: ${
|
|
192
|
+
outputMessage: `Agent execution failed: ${u}`,
|
|
193
|
+
summary: `Agent execution failed: ${u}`
|
|
141
194
|
};
|
|
142
195
|
}
|
|
143
|
-
const
|
|
144
|
-
if (
|
|
145
|
-
const
|
|
146
|
-
[truncated]` :
|
|
147
|
-
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));
|
|
148
201
|
}
|
|
149
202
|
return {
|
|
150
|
-
...
|
|
151
|
-
stepCount:
|
|
152
|
-
lastExecutedAgent:
|
|
153
|
-
requiresFollowUp: i.status === "failed" ? !0 :
|
|
154
|
-
finalOutputMessage:
|
|
203
|
+
...n,
|
|
204
|
+
stepCount: n.stepCount + 1,
|
|
205
|
+
lastExecutedAgent: t.agent.id,
|
|
206
|
+
requiresFollowUp: i.status === "failed" ? !0 : n.requiresFollowUp,
|
|
207
|
+
finalOutputMessage: o ?? "",
|
|
155
208
|
agentExecutionContext: {
|
|
156
|
-
...
|
|
209
|
+
...n.agentExecutionContext,
|
|
157
210
|
messages: d,
|
|
158
211
|
priorSteps: [
|
|
159
|
-
...
|
|
212
|
+
...n.agentExecutionContext.priorSteps ?? [],
|
|
160
213
|
{
|
|
161
|
-
agentId:
|
|
162
|
-
assignedTask:
|
|
214
|
+
agentId: t.agent.id,
|
|
215
|
+
assignedTask: n.agentExecutionContext.assignedTask,
|
|
163
216
|
summary: i?.summary || "No summary provided.",
|
|
164
217
|
status: i?.status || "unknown"
|
|
165
218
|
}
|
|
166
219
|
],
|
|
167
|
-
sharedState:
|
|
168
|
-
previousSharedState:
|
|
220
|
+
sharedState: Z({
|
|
221
|
+
previousSharedState: n.agentExecutionContext.sharedState,
|
|
169
222
|
patch: i.sharedStatePatch,
|
|
170
|
-
agentId:
|
|
223
|
+
agentId: t.agent.id
|
|
224
|
+
}),
|
|
225
|
+
sharedResources: se({
|
|
226
|
+
previousSharedResources: n.agentExecutionContext.sharedResources,
|
|
227
|
+
additions: i.sharedResourceAdditions,
|
|
228
|
+
agentId: t.agent.id
|
|
171
229
|
})
|
|
172
230
|
}
|
|
173
231
|
};
|
|
174
|
-
},
|
|
175
|
-
"
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
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 {
|
|
179
323
|
constructor() {
|
|
180
324
|
this.agentRegistry = /* @__PURE__ */ new Map();
|
|
181
325
|
}
|
|
@@ -192,7 +336,7 @@ class Z {
|
|
|
192
336
|
return [...this.agentRegistry.values()];
|
|
193
337
|
}
|
|
194
338
|
}
|
|
195
|
-
class
|
|
339
|
+
class fe {
|
|
196
340
|
/**
|
|
197
341
|
* Create a new InterruptHandler tied to a specific compiled graph and config.
|
|
198
342
|
*/
|
|
@@ -216,7 +360,7 @@ class ee {
|
|
|
216
360
|
agentId: e.agentId,
|
|
217
361
|
id: e.id,
|
|
218
362
|
payload: r
|
|
219
|
-
},
|
|
363
|
+
}, t = this.graph.streamEvents(null, {
|
|
220
364
|
...this.config,
|
|
221
365
|
configurable: {
|
|
222
366
|
...this.config.configurable,
|
|
@@ -225,7 +369,7 @@ class ee {
|
|
|
225
369
|
subgraphs: !0,
|
|
226
370
|
version: "v2"
|
|
227
371
|
});
|
|
228
|
-
this.resolveWait?.(
|
|
372
|
+
this.resolveWait?.(t);
|
|
229
373
|
} catch (s) {
|
|
230
374
|
this.rejectWait?.(s);
|
|
231
375
|
} finally {
|
|
@@ -239,157 +383,157 @@ class ee {
|
|
|
239
383
|
this.rejectWait && (this.rejectWait(new Error("Request cancelled by user.")), this.resolveWait = void 0, this.rejectWait = void 0);
|
|
240
384
|
}
|
|
241
385
|
}
|
|
242
|
-
const
|
|
386
|
+
const we = async (n) => {
|
|
243
387
|
try {
|
|
244
|
-
return await (await
|
|
388
|
+
return await (await L()).embedDocuments(n);
|
|
245
389
|
} catch (e) {
|
|
246
390
|
throw console.error("Failed to generate embeddings:", e), e;
|
|
247
391
|
}
|
|
248
|
-
},
|
|
249
|
-
const r = e.get(
|
|
392
|
+
}, C = async (n, e) => {
|
|
393
|
+
const r = e.get(n);
|
|
250
394
|
if (r)
|
|
251
395
|
return r;
|
|
252
|
-
const s = await
|
|
253
|
-
return e.set(
|
|
396
|
+
const s = await we([n]);
|
|
397
|
+
return e.set(n, s[0]), s[0];
|
|
254
398
|
};
|
|
255
|
-
async function
|
|
256
|
-
const
|
|
399
|
+
async function ve(n, e, r, s) {
|
|
400
|
+
const t = `req-${Date.now()}`, i = {
|
|
257
401
|
type: "layerSearch",
|
|
258
|
-
precomputedEmbedding: s ? await
|
|
259
|
-
requestId:
|
|
402
|
+
precomputedEmbedding: s ? await C(n, s) : void 0,
|
|
403
|
+
requestId: t,
|
|
260
404
|
minScore: r
|
|
261
405
|
};
|
|
262
|
-
return await new Promise((
|
|
263
|
-
const d = (
|
|
264
|
-
|
|
406
|
+
return await new Promise((o) => {
|
|
407
|
+
const d = (c) => {
|
|
408
|
+
c.data.requestId === t && o(c.data.results);
|
|
265
409
|
};
|
|
266
410
|
e.addEventListener("message", d, { once: !0 }), e.postMessage(i);
|
|
267
411
|
});
|
|
268
412
|
}
|
|
269
|
-
function
|
|
270
|
-
const { worker: e } =
|
|
413
|
+
function Ee(n) {
|
|
414
|
+
const { worker: e } = n;
|
|
271
415
|
return {
|
|
272
416
|
async searchLayers({
|
|
273
417
|
text: r,
|
|
274
418
|
minScore: s,
|
|
275
|
-
embeddingCache:
|
|
419
|
+
embeddingCache: t
|
|
276
420
|
}) {
|
|
277
|
-
return await
|
|
421
|
+
return await ve(r, e, s, t);
|
|
278
422
|
}
|
|
279
423
|
};
|
|
280
424
|
}
|
|
281
|
-
const
|
|
282
|
-
combinedQuery:
|
|
425
|
+
const Re = async ({
|
|
426
|
+
combinedQuery: n,
|
|
283
427
|
layerIds: e,
|
|
284
428
|
embeddingsWorker: r,
|
|
285
429
|
minScore: s,
|
|
286
|
-
topResults:
|
|
430
|
+
topResults: t,
|
|
287
431
|
embeddingCache: a
|
|
288
432
|
}) => {
|
|
289
|
-
const i = `req-${Date.now()}`,
|
|
433
|
+
const i = `req-${Date.now()}`, o = a ? await C(n, a) : void 0, d = {
|
|
290
434
|
type: "fieldSearch",
|
|
291
435
|
layerIdForFieldsSearch: e,
|
|
292
|
-
precomputedEmbedding:
|
|
436
|
+
precomputedEmbedding: o,
|
|
293
437
|
requestId: i,
|
|
294
438
|
minScore: s,
|
|
295
|
-
topResults:
|
|
439
|
+
topResults: t
|
|
296
440
|
};
|
|
297
|
-
return await new Promise((
|
|
298
|
-
const
|
|
299
|
-
if (
|
|
441
|
+
return await new Promise((c) => {
|
|
442
|
+
const u = (g) => {
|
|
443
|
+
if (g.data.requestId !== i)
|
|
300
444
|
return;
|
|
301
|
-
const
|
|
302
|
-
layerId:
|
|
303
|
-
results:
|
|
445
|
+
const l = g.data.results.map(({ layerId: f, results: h }) => ({
|
|
446
|
+
layerId: f,
|
|
447
|
+
results: h
|
|
304
448
|
}));
|
|
305
|
-
|
|
449
|
+
c(l);
|
|
306
450
|
};
|
|
307
|
-
r.addEventListener("message",
|
|
451
|
+
r.addEventListener("message", u, { once: !0 }), r.postMessage(d);
|
|
308
452
|
});
|
|
309
453
|
};
|
|
310
|
-
function
|
|
311
|
-
const { worker: e } =
|
|
454
|
+
function xe(n) {
|
|
455
|
+
const { worker: e } = n;
|
|
312
456
|
return {
|
|
313
|
-
async searchFields({ text: r, layerIds: s, minScore:
|
|
314
|
-
return await
|
|
457
|
+
async searchFields({ text: r, layerIds: s, minScore: t, topResults: a, embeddingCache: i }) {
|
|
458
|
+
return await Re({
|
|
315
459
|
combinedQuery: r,
|
|
316
460
|
layerIds: s,
|
|
317
461
|
embeddingsWorker: e,
|
|
318
|
-
minScore:
|
|
462
|
+
minScore: t,
|
|
319
463
|
topResults: a,
|
|
320
464
|
embeddingCache: i
|
|
321
465
|
});
|
|
322
466
|
}
|
|
323
467
|
};
|
|
324
468
|
}
|
|
325
|
-
const
|
|
326
|
-
const e =
|
|
469
|
+
const Se = (n) => {
|
|
470
|
+
const e = W.safeParse(n);
|
|
327
471
|
if (!e.success)
|
|
328
472
|
throw new Error("Embeddings response validation failed. Regenerate embeddings.");
|
|
329
473
|
return e.data;
|
|
330
|
-
},
|
|
474
|
+
}, be = (n, e) => {
|
|
331
475
|
const r = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map();
|
|
332
|
-
if (e.allLayers.forEach((
|
|
333
|
-
|
|
334
|
-
}),
|
|
476
|
+
if (e.allLayers.forEach((t) => {
|
|
477
|
+
t instanceof V && s.set(t.id, t);
|
|
478
|
+
}), n.length !== s.size)
|
|
335
479
|
throw new Error("Layer count mismatch during registry restoration. Regenerate embeddings.");
|
|
336
|
-
for (const
|
|
337
|
-
const a = s.get(
|
|
480
|
+
for (const t of n) {
|
|
481
|
+
const a = s.get(t.id);
|
|
338
482
|
if (!a)
|
|
339
483
|
throw new Error(
|
|
340
|
-
`Layer with ID ${
|
|
484
|
+
`Layer with ID ${t.id} not found in the original map during registry restoration. Regenerate embeddings.`
|
|
341
485
|
);
|
|
342
|
-
if (
|
|
486
|
+
if (t.fields.length !== a.fields.length)
|
|
343
487
|
throw new Error(
|
|
344
|
-
`Field count mismatch for layer ID ${
|
|
488
|
+
`Field count mismatch for layer ID ${t.id} during registry restoration. Regenerate embeddings.`
|
|
345
489
|
);
|
|
346
490
|
const i = {
|
|
347
|
-
name:
|
|
348
|
-
title:
|
|
349
|
-
description:
|
|
350
|
-
},
|
|
351
|
-
for (const d of
|
|
352
|
-
const
|
|
353
|
-
if (!
|
|
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)
|
|
354
498
|
throw new Error(
|
|
355
|
-
`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.`
|
|
356
500
|
);
|
|
357
|
-
|
|
501
|
+
o.set(d.name, {
|
|
358
502
|
name: d.name,
|
|
359
503
|
alias: a.getFieldAlias(d.name) ?? d.alias,
|
|
360
504
|
description: d.description,
|
|
361
|
-
type:
|
|
362
|
-
valueType:
|
|
505
|
+
type: c.type || "unknown",
|
|
506
|
+
valueType: c.valueType || "unknown",
|
|
363
507
|
domain: a.getFieldDomain(d.name) ?? void 0
|
|
364
508
|
});
|
|
365
509
|
}
|
|
366
|
-
r.set(
|
|
510
|
+
r.set(t.id, {
|
|
367
511
|
layerItem: i,
|
|
368
|
-
fieldRegistry:
|
|
512
|
+
fieldRegistry: o
|
|
369
513
|
});
|
|
370
514
|
}
|
|
371
515
|
return r;
|
|
372
|
-
},
|
|
516
|
+
}, Ae = async (n) => {
|
|
373
517
|
try {
|
|
374
|
-
return (await
|
|
518
|
+
return (await z(n, {
|
|
375
519
|
responseType: "json"
|
|
376
520
|
})).data;
|
|
377
521
|
} catch (e) {
|
|
378
|
-
throw new Error(`Failed to fetch data from ${
|
|
522
|
+
throw new Error(`Failed to fetch data from ${n}: ${String(e)}`);
|
|
379
523
|
}
|
|
380
|
-
},
|
|
381
|
-
const e =
|
|
524
|
+
}, Ce = async (n) => {
|
|
525
|
+
const e = n.map;
|
|
382
526
|
if (!e?.portalItem)
|
|
383
527
|
throw new Error("WebMap portal item is missing.");
|
|
384
528
|
const { resources: r } = await e.portalItem.fetchResources(), s = r.find((i) => i.resource.path === "embeddings-v01.json");
|
|
385
529
|
if (!s?.resource.url)
|
|
386
530
|
throw new Error("Embeddings resource 'embeddings-v01.json' not found in the webmap portal item.");
|
|
387
|
-
const
|
|
388
|
-
return
|
|
531
|
+
const t = await Ae(s.resource.url);
|
|
532
|
+
return Se(t);
|
|
389
533
|
};
|
|
390
|
-
class
|
|
534
|
+
class k {
|
|
391
535
|
constructor() {
|
|
392
|
-
this.orchestratorReady = !1, this.chatHistory = [], this.priorSteps = [], this.sharedState = {}, this.agentRegistry = new
|
|
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;
|
|
393
537
|
}
|
|
394
538
|
/**
|
|
395
539
|
* Creates and returns an AI-ready Orchestrator instance.
|
|
@@ -397,15 +541,16 @@ class x {
|
|
|
397
541
|
* @returns Ready Orchestrator.
|
|
398
542
|
*/
|
|
399
543
|
static async init(e) {
|
|
400
|
-
const r = new
|
|
544
|
+
const r = new k();
|
|
545
|
+
r.runtimeEventsEnabled = e.runtimeEventsEnabled ?? !1;
|
|
401
546
|
try {
|
|
402
547
|
if (e.view?.map) {
|
|
403
|
-
await
|
|
404
|
-
const s = await
|
|
548
|
+
await N.whenOnce(() => e.view.ready);
|
|
549
|
+
const s = await Ce(e.view), t = be(
|
|
405
550
|
s.layers,
|
|
406
551
|
e.view.map
|
|
407
552
|
);
|
|
408
|
-
r.layersAndFieldsRegistry =
|
|
553
|
+
r.layersAndFieldsRegistry = t, r.embeddingsWorker = await B(s);
|
|
409
554
|
}
|
|
410
555
|
return e.agents?.forEach((s) => {
|
|
411
556
|
r.agentRegistry.register(s);
|
|
@@ -421,97 +566,105 @@ class x {
|
|
|
421
566
|
* - `interrupt`: HITL required, wait for `resumeInterrupt()`
|
|
422
567
|
* - `completed`: final result with chat history + layer styling
|
|
423
568
|
* - `cancelled`: user aborted the run
|
|
569
|
+
* @param userInput User request to process.
|
|
570
|
+
* @param options Agent selection and routing behavior for this run.
|
|
424
571
|
*/
|
|
425
|
-
async *ask(e) {
|
|
572
|
+
async *ask(e, r = {}) {
|
|
426
573
|
if (!this.orchestratorReady)
|
|
427
574
|
throw new Error("Orchestrator is not ready yet.");
|
|
428
575
|
if (!this.agentRegistry.list().length)
|
|
429
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.");
|
|
430
580
|
if (++this.streamEpoch, !e.trim())
|
|
431
581
|
return;
|
|
432
|
-
const
|
|
433
|
-
this.activeRunId =
|
|
434
|
-
const
|
|
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 = {
|
|
435
596
|
version: "v2",
|
|
436
597
|
streamMode: "custom",
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
abortSignal: this.activeAbortController.signal,
|
|
441
|
-
hitlResponse: null,
|
|
442
|
-
services: {
|
|
443
|
-
layerSearch: s,
|
|
444
|
-
fieldSearch: n,
|
|
445
|
-
layersAndFieldsRegistry: this.layersAndFieldsRegistry,
|
|
446
|
-
agentRegistry: this.agentRegistry,
|
|
447
|
-
embeddingCache: a
|
|
448
|
-
}
|
|
449
|
-
},
|
|
598
|
+
signal: this.activeAbortController.signal,
|
|
599
|
+
...this.runtimeEventsEnabled && { callbacks: [this.createHierarchyCallback()] },
|
|
600
|
+
configurable: c,
|
|
450
601
|
subgraphs: !0
|
|
451
|
-
},
|
|
602
|
+
}, g = this.graph?.streamEvents(
|
|
452
603
|
{
|
|
604
|
+
routing: d,
|
|
453
605
|
agentExecutionContext: {
|
|
454
606
|
userRequest: e,
|
|
455
607
|
messages: this.chatHistory,
|
|
456
608
|
priorSteps: this.priorSteps,
|
|
457
|
-
sharedState: this.sharedState
|
|
609
|
+
sharedState: this.sharedState,
|
|
610
|
+
sharedResources: this.sharedResources
|
|
458
611
|
}
|
|
459
612
|
},
|
|
460
|
-
|
|
461
|
-
),
|
|
462
|
-
if (yield* this.pipeStream(
|
|
463
|
-
yield
|
|
613
|
+
u
|
|
614
|
+
), l = ++this.streamEpoch;
|
|
615
|
+
if (yield* this.pipeStream(g, l, t), this.isRunCancelled(t)) {
|
|
616
|
+
yield* this.createCancellationEvents(t);
|
|
464
617
|
return;
|
|
465
618
|
}
|
|
466
619
|
for (; ; ) {
|
|
467
|
-
if (this.isRunCancelled(
|
|
468
|
-
yield
|
|
620
|
+
if (this.isRunCancelled(t)) {
|
|
621
|
+
yield* this.createCancellationEvents(t);
|
|
469
622
|
return;
|
|
470
623
|
}
|
|
471
|
-
const m = (await this.graph.getState(
|
|
624
|
+
const m = (await this.graph.getState(u, { subgraphs: !0 })).tasks.find((y) => y.interrupts.length > 0)?.interrupts[0]?.value;
|
|
472
625
|
if (!m)
|
|
473
626
|
break;
|
|
474
|
-
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 };
|
|
475
628
|
try {
|
|
476
|
-
const
|
|
477
|
-
yield* this.pipeStream(
|
|
478
|
-
} catch (
|
|
479
|
-
if (this.isRunCancelled(
|
|
480
|
-
yield
|
|
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);
|
|
481
634
|
return;
|
|
482
635
|
}
|
|
483
|
-
if (
|
|
636
|
+
if (y) {
|
|
484
637
|
yield {
|
|
485
|
-
runId:
|
|
638
|
+
runId: t,
|
|
486
639
|
timestamp: Date.now(),
|
|
487
640
|
type: "error",
|
|
488
|
-
error: { message:
|
|
641
|
+
error: { message: y?.message }
|
|
489
642
|
};
|
|
490
643
|
return;
|
|
491
644
|
}
|
|
492
645
|
}
|
|
493
646
|
}
|
|
494
|
-
if (this.isRunCancelled(
|
|
495
|
-
yield
|
|
647
|
+
if (this.isRunCancelled(t)) {
|
|
648
|
+
yield* this.createCancellationEvents(t);
|
|
496
649
|
return;
|
|
497
650
|
}
|
|
498
|
-
const
|
|
499
|
-
if (this.isRunCancelled(
|
|
500
|
-
yield
|
|
651
|
+
const h = (await this.graph.getState(u, { subgraphs: !0 })).values;
|
|
652
|
+
if (this.isRunCancelled(t)) {
|
|
653
|
+
yield* this.createCancellationEvents(t);
|
|
501
654
|
return;
|
|
502
655
|
}
|
|
503
|
-
this.chatHistory =
|
|
504
|
-
runId:
|
|
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,
|
|
505
658
|
timestamp: Date.now(),
|
|
506
659
|
type: "completed",
|
|
507
|
-
result: { content:
|
|
660
|
+
result: { content: h.finalOutputMessage }
|
|
508
661
|
};
|
|
509
662
|
}
|
|
510
663
|
/**
|
|
511
664
|
* Start a new conversation by clearing chat history, prior steps, and shared state.
|
|
512
665
|
*/
|
|
513
666
|
newConversation() {
|
|
514
|
-
this.chatHistory = [], this.priorSteps = [], this.sharedState = {};
|
|
667
|
+
this.chatHistory = [], this.priorSteps = [], this.sharedState = {}, this.sharedResources = [];
|
|
515
668
|
}
|
|
516
669
|
/**
|
|
517
670
|
* Generic resume for any HITL interrupt.
|
|
@@ -539,29 +692,87 @@ class x {
|
|
|
539
692
|
this.activeRunId && (this.cancelledRunIds.add(this.activeRunId), this.activeAbortController?.abort(), ++this.streamEpoch, this.interruptHandler?.cancel());
|
|
540
693
|
}
|
|
541
694
|
async *pipeStream(e, r, s) {
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
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
|
+
});
|
|
714
|
+
}
|
|
715
|
+
} catch (t) {
|
|
716
|
+
if (!this.isRunCancelled(s))
|
|
717
|
+
throw t;
|
|
718
|
+
}
|
|
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
|
+
};
|
|
551
736
|
}
|
|
552
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
|
+
}
|
|
553
751
|
isRunCancelled(e) {
|
|
554
752
|
return this.cancelledRunIds.has(e);
|
|
555
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
|
+
}
|
|
556
767
|
/**
|
|
557
768
|
* Disposes this instance by terminating the embeddings worker
|
|
558
769
|
* and cleaning up all related resources.
|
|
559
770
|
*/
|
|
560
771
|
dispose() {
|
|
561
|
-
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;
|
|
562
773
|
}
|
|
563
774
|
}
|
|
564
775
|
export {
|
|
565
|
-
|
|
566
|
-
|
|
776
|
+
k as O,
|
|
777
|
+
we as g
|
|
567
778
|
};
|