@arcgis/ai-components 5.2.0-next.9 → 5.2.0-next.90
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 +183 -0
- package/dist/agentic-workflow/nodes/AgentNode.d.ts +27 -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 +109 -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 +52 -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 +154 -0
- package/dist/agents/tools/query/getTopFeatures/adapter.d.ts +8 -0
- package/dist/agents/tools/query/getTopFeatures/adapter.js +141 -0
- package/dist/agents/tools/query/queryFeatures/adapter.d.ts +8 -0
- package/dist/agents/tools/query/queryFeatures/adapter.js +127 -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/2EY3BQQX.js +2 -0
- package/dist/cdn/2PTPBAIN.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/4EBLRHYE.js +2 -0
- package/dist/cdn/4HDDRBIY.js +2 -0
- package/dist/cdn/4NJ2FF7H.js +2 -0
- package/dist/cdn/4OGR5QKS.js +2 -0
- package/dist/cdn/4WIDLQUH.js +2 -0
- package/dist/cdn/5WYRJMBW.js +2 -0
- package/dist/cdn/5X7EG7D2.js +2 -0
- package/dist/cdn/5ZFUGNRN.js +2 -0
- package/dist/cdn/6HF36IKA.js +2 -0
- package/dist/cdn/6KFMRBAA.js +2 -0
- package/dist/cdn/6U4GTCLJ.js +66 -0
- package/dist/cdn/6VJXUIXY.js +3 -0
- package/dist/cdn/7BCQMK6D.js +2 -0
- package/dist/cdn/7DFXYMEA.js +2 -0
- package/dist/cdn/7M6VKBTK.js +6 -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/7ZFAFKJT.js +2 -0
- package/dist/cdn/ACJTJLZN.js +2 -0
- package/dist/cdn/AI6DYOKR.js +181 -0
- package/dist/cdn/{ZS2TZ6BF.js → AOVJ34QE.js} +1 -1
- package/dist/cdn/APFZY4PI.js +2 -0
- package/dist/cdn/AT4XVTJR.js +44 -0
- package/dist/cdn/{FL4W4VYN.js → BL273EGZ.js} +17 -1
- package/dist/cdn/C5ZL5Z52.js +18 -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/COL6QYGQ.js +2 -0
- package/dist/cdn/CP5BVGJU.js +2 -0
- package/dist/cdn/CZM4URK7.js +2 -0
- package/dist/cdn/DP6O6PMH.js +2 -0
- package/dist/cdn/{V2P4AIGG.js → EKB7CAMM.js} +1 -1
- package/dist/cdn/EWLXNGKH.js +208 -0
- package/dist/cdn/EYNEYD34.js +2 -0
- package/dist/cdn/FDDQ67BG.js +2 -0
- package/dist/cdn/FDOMMK2M.js +2 -0
- package/dist/cdn/FQH3HOFH.js +2 -0
- package/dist/cdn/FULSCC5I.js +3 -0
- package/dist/cdn/{GGSZM7KV.js → FUZ77UGP.js} +6 -4
- package/dist/cdn/{ZLXN7NMF.js → FYZATVB3.js} +10 -8
- package/dist/cdn/GFEOVHJK.js +2 -0
- package/dist/cdn/HGDC6DEJ.js +9 -0
- package/dist/cdn/HHFNQR6Z.js +2 -0
- package/dist/cdn/HIPQ3VRW.js +2 -0
- package/dist/cdn/HKSFWTWK.js +14 -0
- package/dist/cdn/HMUWQCXU.js +2 -0
- package/dist/cdn/IBZ2NEAO.js +2 -0
- package/dist/cdn/{FX7UOGHP.js → ICBIUFK7.js} +1 -1
- package/dist/cdn/IHP25JWI.js +99 -0
- package/dist/cdn/J6A4AS7E.js +22 -0
- package/dist/cdn/J6SZIQJA.js +2 -0
- package/dist/cdn/{NE7E52YR.js → JEBRN3EU.js} +9 -3
- package/dist/cdn/JJJZ7FOM.js +2 -0
- package/dist/cdn/JKIESH74.js +2 -0
- package/dist/cdn/JO5ETMPS.js +2 -0
- package/dist/cdn/JQX7LNCN.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/{7RCQFLPP.js → LK7ZIQW6.js} +1 -1
- package/dist/cdn/LLUGJKAQ.js +2 -0
- package/dist/cdn/LPR72QZF.js +36 -0
- package/dist/cdn/{DHOVCT6R.js → MKOQJXQQ.js} +1 -1
- package/dist/cdn/MWYBF3F3.js +66 -0
- package/dist/cdn/NEV6OZN3.js +71 -0
- package/dist/cdn/OAKRPM7D.js +2 -0
- package/dist/cdn/{23EQTPO3.js → OKVLGJAG.js} +1 -1
- package/dist/cdn/OL5656NI.js +2 -0
- package/dist/cdn/ONQ6JSBJ.js +2 -0
- package/dist/cdn/OWTGH34K.js +2 -0
- package/dist/cdn/OYSPNIJI.js +156 -0
- package/dist/cdn/PEYYWXFE.js +2 -0
- package/dist/cdn/{LQ6R5YRN.js → PQ2DPOFM.js} +1 -1
- package/dist/cdn/PSYRZMX2.js +2 -0
- package/dist/cdn/PUHRBGKB.js +2 -0
- package/dist/cdn/Q57QWN5W.js +2 -0
- package/dist/cdn/QNNGPA3Q.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/RSNGZQCQ.js +2 -0
- package/dist/cdn/{X2ZDYHCG.js → SDWWUWAF.js} +10 -5
- package/dist/cdn/SHD6YFSR.js +2 -0
- package/dist/cdn/SUYWKYWI.js +22 -0
- package/dist/cdn/SZ2QSSB3.js +2 -0
- package/dist/cdn/T4RIGOXB.js +2 -0
- package/dist/cdn/{3PKJWIC3.js → TMZ6DF22.js} +1 -1
- package/dist/cdn/TPULIO6I.js +34 -0
- package/dist/cdn/U2D53TAX.js +14 -0
- package/dist/cdn/{6YMR4QSD.js → UHEYPSOR.js} +1 -1
- package/dist/cdn/UHZG7SKO.js +2 -0
- package/dist/cdn/UZLQALHY.js +2 -0
- package/dist/cdn/V52XWEGV.js +11 -0
- package/dist/cdn/V6F3HEK7.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/VNJMTA6O.js +2 -0
- package/dist/cdn/VOKXKU7M.js +56 -0
- package/dist/cdn/VXFQANGJ.js +2 -0
- package/dist/cdn/W5JPJWMM.js +2 -0
- package/dist/cdn/WKTQVBFJ.js +2 -0
- package/dist/cdn/WNNMKCKS.js +2 -0
- package/dist/cdn/WP7ORLSB.js +6 -0
- package/dist/cdn/X3COUAXY.js +4 -0
- package/dist/cdn/XCW5WVZZ.js +2 -0
- package/dist/cdn/Y4T4FQJC.js +2 -0
- package/dist/cdn/Y7XD7ZRD.js +2 -0
- package/dist/cdn/YB7AS6XQ.js +3 -0
- package/dist/cdn/YEZ3AMNX.js +2 -0
- package/dist/cdn/YLVJA4ZE.js +2 -0
- package/dist/cdn/YQSU6IUO.js +2 -0
- package/dist/cdn/Z5W4V7RC.js +2 -0
- package/dist/cdn/ZLWWWTH4.js +2 -0
- package/dist/cdn/ZOEMBHRF.js +2 -0
- package/dist/cdn/ZQMBJ6MI.js +2 -0
- package/dist/cdn/{ZTBA5PM7.js → ZU2FHVNK.js} +1 -1
- package/dist/cdn/ZVGUAOXE.js +2 -0
- 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 +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 +56 -0
- package/dist/chunks/converterUtils.js +66 -41
- package/dist/chunks/dataExplorationGraph.js +133 -177
- 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 +37 -31
- package/dist/chunks/mergeWhereClauses.js +15 -0
- package/dist/chunks/navigationGraph.js +124 -103
- package/dist/chunks/navigation_intent_prompt.js +8 -2
- package/dist/chunks/orchestrator.js +298 -139
- 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/types.js +59 -0
- package/dist/chunks/utils2.js +11 -11
- package/dist/components/arcgis-assistant/customElement.d.ts +72 -0
- package/dist/components/arcgis-assistant/customElement.js +412 -168
- 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 +609 -10
- package/dist/components/arcgis-assistant-chat/customElement.d.ts +2 -1
- package/dist/components/arcgis-assistant-chat/customElement.js +23 -18
- package/dist/components/arcgis-assistant-chat-entry/customElement.d.ts +2 -0
- 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 +4 -0
- 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 +5 -0
- package/dist/components/arcgis-assistant-message/customElement.js +29 -26
- package/dist/components/arcgis-assistant-message/index.js +2 -0
- 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-loading/customElement.d.ts +7 -0
- 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-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-suggested-prompts/customElement.js +8 -8
- 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 +9 -8
- package/dist/oauth-callback.html +1 -1
- package/dist/orchestrator/orchestrator/orchestratorEvents.d.ts +78 -0
- package/dist/types/lumina.d.ts +10 -8
- package/dist/types/preact.d.ts +10 -8
- package/dist/types/react.d.ts +10 -8
- package/dist/types/stencil.d.ts +12 -10
- package/dist/utils/index.d.ts +8 -8
- package/dist/utils/index.js +56 -55
- package/package.json +32 -12
- package/dist/cdn/2AXF774U.js +0 -2
- package/dist/cdn/462JBSEV.js +0 -422
- package/dist/cdn/53ZCUPKK.js +0 -22
- package/dist/cdn/5QAHYX7Y.js +0 -5
- package/dist/cdn/5XRDJL7R.js +0 -14
- package/dist/cdn/7BCR6TUO.js +0 -2
- package/dist/cdn/7GH7VSB2.js +0 -2
- package/dist/cdn/7PLV4QH6.js +0 -2
- package/dist/cdn/AXDZBBNL.js +0 -45
- package/dist/cdn/DDLZOMUY.js +0 -2
- package/dist/cdn/EECZLT6C.js +0 -166
- package/dist/cdn/ETRWZ3MS.js +0 -108
- package/dist/cdn/F2AHA4GB.js +0 -54
- package/dist/cdn/FX5JFRDL.js +0 -2
- package/dist/cdn/H7422XUG.js +0 -2
- package/dist/cdn/HB5A5R2E.js +0 -2
- package/dist/cdn/I6HNBTWY.js +0 -2
- package/dist/cdn/I7SRZPVS.js +0 -72
- package/dist/cdn/IG6YKZH3.js +0 -3
- package/dist/cdn/JVIKKZND.js +0 -3
- package/dist/cdn/KMQ3SP4I.js +0 -5
- package/dist/cdn/MH5RPXHM.js +0 -2
- package/dist/cdn/NVI3I46B.js +0 -2
- package/dist/cdn/OAVEHGB6.js +0 -2
- package/dist/cdn/OH64RMOR.js +0 -4
- package/dist/cdn/P26NON3Z.js +0 -16
- package/dist/cdn/QR54T33D.js +0 -2
- package/dist/cdn/RVOAPUBN.js +0 -2
- package/dist/cdn/S3VPZFWQ.js +0 -36
- package/dist/cdn/SXDLXCIM.js +0 -2
- package/dist/cdn/TR7RL3IK.js +0 -2
- package/dist/cdn/USMDJUFS.js +0 -2
- package/dist/cdn/Y333DGV6.js +0 -2
- package/dist/cdn/YIMNOUTF.js +0 -2
|
@@ -1,49 +1,52 @@
|
|
|
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 A from "@arcgis/core/identity/IdentityManager.js";
|
|
3
|
+
import M from "@arcgis/core/portal/Portal.js";
|
|
4
|
+
import { j as _, k as x, D, n as F, o as L, W as $ } from "./generateLayerDescriptions.js";
|
|
5
|
+
import { isGraphInterrupt as W, StateGraph as q, START as T, END as H, MemorySaver as j } from "@langchain/langgraph/web";
|
|
6
|
+
import { generateGuid as U } from "@arcgis/toolkit/string";
|
|
7
|
+
import { HumanMessage as P, AIMessage as O } from "@langchain/core/messages";
|
|
8
|
+
import { s as m } from "./index.js";
|
|
9
|
+
import { BaseCallbackHandler as N } from "@langchain/core/callbacks/base";
|
|
10
|
+
import * as G 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 (t) => {
|
|
14
|
+
const e = await Q(), r = await _("default"), s = M.getDefault(), a = (await A.getCredential(`${s.url}/sharing`)).token, i = {
|
|
12
15
|
type: "generateEmbeddings",
|
|
13
16
|
webmapEmbeddings: t,
|
|
14
17
|
auth: { apiUrl: r, token: a }
|
|
15
18
|
};
|
|
16
19
|
return e.postMessage(i), await new Promise((c, d) => {
|
|
17
|
-
const o = (
|
|
18
|
-
|
|
19
|
-
},
|
|
20
|
-
e.removeEventListener("message", o), d(
|
|
20
|
+
const o = (g) => {
|
|
21
|
+
g.data === "completed" && (e.removeEventListener("message", o), c());
|
|
22
|
+
}, u = (g) => {
|
|
23
|
+
e.removeEventListener("message", o), d(g instanceof Error ? g : new Error("Embeddings worker error"));
|
|
21
24
|
};
|
|
22
|
-
e.addEventListener("message", o), e.addEventListener("error",
|
|
25
|
+
e.addEventListener("message", o), e.addEventListener("error", u, { once: !0 });
|
|
23
26
|
}), e;
|
|
24
|
-
},
|
|
27
|
+
}, Q = async () => {
|
|
25
28
|
{
|
|
26
29
|
const t = (await import("./embeddings.worker.js")).default;
|
|
27
30
|
return new t();
|
|
28
31
|
}
|
|
29
|
-
},
|
|
32
|
+
}, J = (t) => {
|
|
30
33
|
t.currentIntent = "none";
|
|
31
|
-
},
|
|
32
|
-
const r =
|
|
34
|
+
}, K = async (t, e) => {
|
|
35
|
+
const r = x(e);
|
|
33
36
|
if (t.agentExecutionContext.userRequest) {
|
|
34
|
-
const n = new
|
|
35
|
-
t.agentExecutionContext.messages = [...t.agentExecutionContext.messages, n],
|
|
37
|
+
const n = new P(t.agentExecutionContext.userRequest.trim());
|
|
38
|
+
t.agentExecutionContext.messages = [...t.agentExecutionContext.messages, n], J(t);
|
|
36
39
|
}
|
|
37
40
|
const s = r?.services.agentRegistry.list().map((n) => n.agent.id) ?? [];
|
|
38
|
-
return await
|
|
39
|
-
},
|
|
40
|
-
if (!
|
|
41
|
+
return await m({ text: `Available agents: ${[...s].join(", ")}` }, e), await m({ text: "Analyzing user input" }, e), t;
|
|
42
|
+
}, X = async (t, e) => (await m({ text: "Exiting..." }, e), t), E = (t) => typeof t == "object" && t !== null && !Array.isArray(t), Y = (t, e) => {
|
|
43
|
+
if (!E(t)) {
|
|
41
44
|
t !== void 0 && console.warn(`Agent "${e}" returned invalid sharedStatePatch. Ignoring it.`);
|
|
42
45
|
return;
|
|
43
46
|
}
|
|
44
47
|
const r = {};
|
|
45
48
|
for (const [s, n] of Object.entries(t)) {
|
|
46
|
-
if (!
|
|
49
|
+
if (!E(n) || !("value" in n)) {
|
|
47
50
|
console.warn(
|
|
48
51
|
`Agent "${e}" returned invalid sharedStatePatch entry for key "${s}". Ignoring that entry.`
|
|
49
52
|
);
|
|
@@ -52,7 +55,7 @@ const U = async (t) => {
|
|
|
52
55
|
r[s] = { value: n.value };
|
|
53
56
|
}
|
|
54
57
|
return r;
|
|
55
|
-
},
|
|
58
|
+
}, Z = (t) => {
|
|
56
59
|
const { previousSharedState: e, patch: r, agentId: s } = t;
|
|
57
60
|
if (!r)
|
|
58
61
|
return e;
|
|
@@ -68,12 +71,12 @@ const U = async (t) => {
|
|
|
68
71
|
}
|
|
69
72
|
});
|
|
70
73
|
return a;
|
|
71
|
-
},
|
|
74
|
+
}, S = (t) => {
|
|
72
75
|
if (typeof t != "string")
|
|
73
76
|
return;
|
|
74
77
|
const e = t.trim();
|
|
75
78
|
return e || void 0;
|
|
76
|
-
},
|
|
79
|
+
}, ee = (t) => {
|
|
77
80
|
switch (t) {
|
|
78
81
|
case "failed":
|
|
79
82
|
return "Agent failed without a summary.";
|
|
@@ -84,20 +87,20 @@ const U = async (t) => {
|
|
|
84
87
|
default:
|
|
85
88
|
return "Agent completed without a summary.";
|
|
86
89
|
}
|
|
87
|
-
},
|
|
88
|
-
const r =
|
|
90
|
+
}, te = (t, e) => {
|
|
91
|
+
const r = S(e?.outputMessage), s = S(e?.summary), n = e?.status, a = n === "success" || n === "failed" ? n : "unknown";
|
|
89
92
|
a === "unknown" && console.warn(`Agent "${t}" returned missing/invalid status. Defaulting to "unknown".`);
|
|
90
|
-
const i =
|
|
93
|
+
const i = Y(e?.sharedStatePatch, t);
|
|
91
94
|
return {
|
|
92
95
|
outputMessage: r,
|
|
93
|
-
summary: s ?? r ??
|
|
96
|
+
summary: s ?? r ?? ee(a),
|
|
94
97
|
status: a,
|
|
95
98
|
sharedStatePatch: i
|
|
96
99
|
};
|
|
97
|
-
},
|
|
98
|
-
const r =
|
|
99
|
-
if (
|
|
100
|
-
return await
|
|
100
|
+
}, b = 4e3, ne = async (t, e) => {
|
|
101
|
+
const r = x(e);
|
|
102
|
+
if (e?.signal?.aborted)
|
|
103
|
+
return await m({ text: "Run cancelled; skipping agent execution" }, e), {
|
|
101
104
|
...t,
|
|
102
105
|
currentIntent: "none",
|
|
103
106
|
requiresFollowUp: !1
|
|
@@ -105,9 +108,13 @@ const U = async (t) => {
|
|
|
105
108
|
const { agentRegistry: s } = r?.services ?? {}, n = s?.get(t.currentIntent);
|
|
106
109
|
if (!n)
|
|
107
110
|
return console.warn(`No agent found for intent: ${t.currentIntent}`), t;
|
|
108
|
-
await
|
|
111
|
+
await m({ text: `Executing registered agent: ${n.agent.name}` }, e);
|
|
109
112
|
const a = {
|
|
110
113
|
...e ?? {},
|
|
114
|
+
metadata: {
|
|
115
|
+
...e?.metadata,
|
|
116
|
+
agentId: n.agent.id
|
|
117
|
+
},
|
|
111
118
|
configurable: {
|
|
112
119
|
...r ?? {},
|
|
113
120
|
agentId: n.agent.id,
|
|
@@ -129,22 +136,22 @@ const U = async (t) => {
|
|
|
129
136
|
},
|
|
130
137
|
a
|
|
131
138
|
);
|
|
132
|
-
i =
|
|
139
|
+
i = te(n.agent.name, o), await m({ text: `Finished executing registered agent: ${n.agent.name}` }, e);
|
|
133
140
|
} catch (o) {
|
|
134
|
-
if (
|
|
141
|
+
if (W(o) || e?.signal?.aborted || o instanceof Error && o.name === "AbortError")
|
|
135
142
|
throw o;
|
|
136
|
-
const
|
|
137
|
-
console.error(`Agent "${n.agent.name}" failed:`, o), await
|
|
143
|
+
const u = o instanceof Error ? o.message : String(o);
|
|
144
|
+
console.error(`Agent "${n.agent.name}" failed:`, o), await m({ text: `Registered agent failed: ${n.agent.name}. ${u}` }, e), i = {
|
|
138
145
|
status: "failed",
|
|
139
|
-
outputMessage: `Agent execution failed: ${
|
|
140
|
-
summary: `Agent execution failed: ${
|
|
146
|
+
outputMessage: `Agent execution failed: ${u}`,
|
|
147
|
+
summary: `Agent execution failed: ${u}`
|
|
141
148
|
};
|
|
142
149
|
}
|
|
143
150
|
const c = i.outputMessage, d = [...t.agentExecutionContext.messages];
|
|
144
151
|
if (c) {
|
|
145
|
-
const o = c.length >
|
|
152
|
+
const o = c.length > b ? `${c.slice(0, b - 14)}
|
|
146
153
|
[truncated]` : c;
|
|
147
|
-
d.push(new
|
|
154
|
+
d.push(new O(o));
|
|
148
155
|
}
|
|
149
156
|
return {
|
|
150
157
|
...t,
|
|
@@ -164,18 +171,104 @@ const U = async (t) => {
|
|
|
164
171
|
status: i?.status || "unknown"
|
|
165
172
|
}
|
|
166
173
|
],
|
|
167
|
-
sharedState:
|
|
174
|
+
sharedState: Z({
|
|
168
175
|
previousSharedState: t.agentExecutionContext.sharedState,
|
|
169
176
|
patch: i.sharedStatePatch,
|
|
170
177
|
agentId: n.agent.id
|
|
171
178
|
})
|
|
172
179
|
}
|
|
173
180
|
};
|
|
174
|
-
},
|
|
175
|
-
"
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
181
|
+
}, re = async (t, e) => {
|
|
182
|
+
if (t.routing.mode !== "direct")
|
|
183
|
+
throw new Error("Direct agent assignment requires direct routing.");
|
|
184
|
+
return await m({ text: `Doing a direct route to agent: ${t.routing.agentId}` }, e), {
|
|
185
|
+
...t,
|
|
186
|
+
currentIntent: t.routing.agentId,
|
|
187
|
+
requiresFollowUp: !1,
|
|
188
|
+
agentExecutionContext: {
|
|
189
|
+
...t.agentExecutionContext,
|
|
190
|
+
assignedTask: t.agentExecutionContext.userRequest
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
}, se = 3, ae = (t) => t.routing.mode === "direct" ? "assignDirectAgent" : "intentLLM", ie = (t) => t.routing.mode === "direct" || t.stepCount >= se || !t.requiresFollowUp ? "exit" : "intentLLM", oe = () => new q(D).addNode("ingestInput", K).addNode("assignDirectAgent", re).addNode("intentLLM", F).addNode("executeRegisteredAgent", ne).addNode("exit", X).addEdge(T, "ingestInput").addConditionalEdges("ingestInput", ae).addEdge("assignDirectAgent", "executeRegisteredAgent").addConditionalEdges("intentLLM", (e) => e.currentIntent === "none" || e.currentIntent === e.lastExecutedAgent ? "exit" : "executeRegisteredAgent").addConditionalEdges("executeRegisteredAgent", ie).addEdge("exit", H), ce = (t, e) => {
|
|
194
|
+
const r = t.output?.usage_metadata ?? e.usage_metadata, s = t.output?.llmOutput?.tokenUsage, n = r?.input_tokens ?? s?.promptTokens, a = r?.output_tokens ?? s?.completionTokens, i = r?.total_tokens ?? s?.totalTokens;
|
|
195
|
+
if (n === void 0 || a === void 0 || i === void 0)
|
|
196
|
+
return;
|
|
197
|
+
const c = r?.input_token_details?.cache_read, d = r?.output_token_details?.reasoning;
|
|
198
|
+
return {
|
|
199
|
+
input: n,
|
|
200
|
+
output: a,
|
|
201
|
+
total: i,
|
|
202
|
+
...c !== void 0 && { cacheRead: c },
|
|
203
|
+
...d !== void 0 && { reasoning: d }
|
|
204
|
+
};
|
|
205
|
+
}, de = (t, e, r, s) => {
|
|
206
|
+
switch (t) {
|
|
207
|
+
case "chat_model":
|
|
208
|
+
case "llm":
|
|
209
|
+
return "model";
|
|
210
|
+
case "tool":
|
|
211
|
+
case "retriever":
|
|
212
|
+
return t;
|
|
213
|
+
case "chain":
|
|
214
|
+
return !s || e === "LangGraph" ? "workflow" : r === e ? "node" : "chain";
|
|
215
|
+
default:
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
}, ue = (t) => {
|
|
219
|
+
if (t instanceof Error)
|
|
220
|
+
return { message: t.message, name: t.name };
|
|
221
|
+
const e = t, r = typeof e?.message == "string" ? e.message : String(t ?? "Unknown runtime error"), s = typeof e?.name == "string" ? e.name : void 0;
|
|
222
|
+
return { message: r, ...s && { name: s } };
|
|
223
|
+
}, ge = ({
|
|
224
|
+
event: t,
|
|
225
|
+
runId: e,
|
|
226
|
+
parentSpanId: r,
|
|
227
|
+
timestamp: s
|
|
228
|
+
}) => {
|
|
229
|
+
const n = /^on_(.+)_(start|end|error)$/u.exec(t.event);
|
|
230
|
+
if (!n)
|
|
231
|
+
return;
|
|
232
|
+
const [, a, i] = n, c = t.metadata ?? {}, d = c.langgraph_node, o = de(a, t.name, d, r);
|
|
233
|
+
if (!o)
|
|
234
|
+
return;
|
|
235
|
+
const u = c.agentId, g = c.model ?? c.ls_model_name, l = t.data, y = i === "end" && o === "model" ? ce(l, c) : void 0, h = t.tags?.includes("langsmith:hidden") || d === "__start__", v = {
|
|
236
|
+
...g && { model: g },
|
|
237
|
+
...y && { tokenUsage: y },
|
|
238
|
+
...h && { internal: !0 }
|
|
239
|
+
}, w = {
|
|
240
|
+
id: t.run_id,
|
|
241
|
+
...r && { parentId: r },
|
|
242
|
+
label: t.name,
|
|
243
|
+
type: o,
|
|
244
|
+
...Object.keys(v).length && { metadata: v }
|
|
245
|
+
}, p = { runId: e, timestamp: s, type: "runtime", ...u && { agentId: u } };
|
|
246
|
+
switch (i) {
|
|
247
|
+
case "start":
|
|
248
|
+
return {
|
|
249
|
+
...p,
|
|
250
|
+
phase: "started",
|
|
251
|
+
span: {
|
|
252
|
+
...w,
|
|
253
|
+
...l?.input !== void 0 && { input: l.input }
|
|
254
|
+
}
|
|
255
|
+
};
|
|
256
|
+
case "end":
|
|
257
|
+
return {
|
|
258
|
+
...p,
|
|
259
|
+
phase: "completed",
|
|
260
|
+
span: {
|
|
261
|
+
...w,
|
|
262
|
+
...l?.output !== void 0 && { output: l.output }
|
|
263
|
+
}
|
|
264
|
+
};
|
|
265
|
+
case "error":
|
|
266
|
+
return { ...p, phase: "failed", span: { ...w, error: ue(l?.error) } };
|
|
267
|
+
default:
|
|
268
|
+
return;
|
|
269
|
+
}
|
|
270
|
+
};
|
|
271
|
+
class R {
|
|
179
272
|
constructor() {
|
|
180
273
|
this.agentRegistry = /* @__PURE__ */ new Map();
|
|
181
274
|
}
|
|
@@ -192,7 +285,7 @@ class Z {
|
|
|
192
285
|
return [...this.agentRegistry.values()];
|
|
193
286
|
}
|
|
194
287
|
}
|
|
195
|
-
class
|
|
288
|
+
class le {
|
|
196
289
|
/**
|
|
197
290
|
* Create a new InterruptHandler tied to a specific compiled graph and config.
|
|
198
291
|
*/
|
|
@@ -239,23 +332,23 @@ class ee {
|
|
|
239
332
|
this.rejectWait && (this.rejectWait(new Error("Request cancelled by user.")), this.resolveWait = void 0, this.rejectWait = void 0);
|
|
240
333
|
}
|
|
241
334
|
}
|
|
242
|
-
const
|
|
335
|
+
const he = async (t) => {
|
|
243
336
|
try {
|
|
244
|
-
return await (await
|
|
337
|
+
return await (await L()).embedDocuments(t);
|
|
245
338
|
} catch (e) {
|
|
246
339
|
throw console.error("Failed to generate embeddings:", e), e;
|
|
247
340
|
}
|
|
248
|
-
},
|
|
341
|
+
}, C = async (t, e) => {
|
|
249
342
|
const r = e.get(t);
|
|
250
343
|
if (r)
|
|
251
344
|
return r;
|
|
252
|
-
const s = await
|
|
345
|
+
const s = await he([t]);
|
|
253
346
|
return e.set(t, s[0]), s[0];
|
|
254
347
|
};
|
|
255
|
-
async function
|
|
348
|
+
async function me(t, e, r, s) {
|
|
256
349
|
const n = `req-${Date.now()}`, i = {
|
|
257
350
|
type: "layerSearch",
|
|
258
|
-
precomputedEmbedding: s ? await
|
|
351
|
+
precomputedEmbedding: s ? await C(t, s) : void 0,
|
|
259
352
|
requestId: n,
|
|
260
353
|
minScore: r
|
|
261
354
|
};
|
|
@@ -266,7 +359,7 @@ async function re(t, e, r, s) {
|
|
|
266
359
|
e.addEventListener("message", d, { once: !0 }), e.postMessage(i);
|
|
267
360
|
});
|
|
268
361
|
}
|
|
269
|
-
function
|
|
362
|
+
function pe(t) {
|
|
270
363
|
const { worker: e } = t;
|
|
271
364
|
return {
|
|
272
365
|
async searchLayers({
|
|
@@ -274,11 +367,11 @@ function ne(t) {
|
|
|
274
367
|
minScore: s,
|
|
275
368
|
embeddingCache: n
|
|
276
369
|
}) {
|
|
277
|
-
return await
|
|
370
|
+
return await me(r, e, s, n);
|
|
278
371
|
}
|
|
279
372
|
};
|
|
280
373
|
}
|
|
281
|
-
const
|
|
374
|
+
const fe = async ({
|
|
282
375
|
combinedQuery: t,
|
|
283
376
|
layerIds: e,
|
|
284
377
|
embeddingsWorker: r,
|
|
@@ -286,7 +379,7 @@ const se = async ({
|
|
|
286
379
|
topResults: n,
|
|
287
380
|
embeddingCache: a
|
|
288
381
|
}) => {
|
|
289
|
-
const i = `req-${Date.now()}`, c = a ? await
|
|
382
|
+
const i = `req-${Date.now()}`, c = a ? await C(t, a) : void 0, d = {
|
|
290
383
|
type: "fieldSearch",
|
|
291
384
|
layerIdForFieldsSearch: e,
|
|
292
385
|
precomputedEmbedding: c,
|
|
@@ -295,23 +388,23 @@ const se = async ({
|
|
|
295
388
|
topResults: n
|
|
296
389
|
};
|
|
297
390
|
return await new Promise((o) => {
|
|
298
|
-
const
|
|
299
|
-
if (
|
|
391
|
+
const u = (g) => {
|
|
392
|
+
if (g.data.requestId !== i)
|
|
300
393
|
return;
|
|
301
|
-
const
|
|
394
|
+
const l = g.data.results.map(({ layerId: y, results: h }) => ({
|
|
302
395
|
layerId: y,
|
|
303
|
-
results:
|
|
396
|
+
results: h
|
|
304
397
|
}));
|
|
305
|
-
o(
|
|
398
|
+
o(l);
|
|
306
399
|
};
|
|
307
|
-
r.addEventListener("message",
|
|
400
|
+
r.addEventListener("message", u, { once: !0 }), r.postMessage(d);
|
|
308
401
|
});
|
|
309
402
|
};
|
|
310
|
-
function
|
|
403
|
+
function ye(t) {
|
|
311
404
|
const { worker: e } = t;
|
|
312
405
|
return {
|
|
313
406
|
async searchFields({ text: r, layerIds: s, minScore: n, topResults: a, embeddingCache: i }) {
|
|
314
|
-
return await
|
|
407
|
+
return await fe({
|
|
315
408
|
combinedQuery: r,
|
|
316
409
|
layerIds: s,
|
|
317
410
|
embeddingsWorker: e,
|
|
@@ -322,15 +415,15 @@ function ae(t) {
|
|
|
322
415
|
}
|
|
323
416
|
};
|
|
324
417
|
}
|
|
325
|
-
const
|
|
326
|
-
const e =
|
|
418
|
+
const we = (t) => {
|
|
419
|
+
const e = $.safeParse(t);
|
|
327
420
|
if (!e.success)
|
|
328
421
|
throw new Error("Embeddings response validation failed. Regenerate embeddings.");
|
|
329
422
|
return e.data;
|
|
330
|
-
},
|
|
423
|
+
}, ve = (t, e) => {
|
|
331
424
|
const r = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map();
|
|
332
425
|
if (e.allLayers.forEach((n) => {
|
|
333
|
-
n instanceof
|
|
426
|
+
n instanceof V && s.set(n.id, n);
|
|
334
427
|
}), t.length !== s.size)
|
|
335
428
|
throw new Error("Layer count mismatch during registry restoration. Regenerate embeddings.");
|
|
336
429
|
for (const n of t) {
|
|
@@ -369,27 +462,27 @@ const ie = (t) => {
|
|
|
369
462
|
});
|
|
370
463
|
}
|
|
371
464
|
return r;
|
|
372
|
-
},
|
|
465
|
+
}, Ee = async (t) => {
|
|
373
466
|
try {
|
|
374
|
-
return (await
|
|
467
|
+
return (await z(t, {
|
|
375
468
|
responseType: "json"
|
|
376
469
|
})).data;
|
|
377
470
|
} catch (e) {
|
|
378
471
|
throw new Error(`Failed to fetch data from ${t}: ${String(e)}`);
|
|
379
472
|
}
|
|
380
|
-
},
|
|
473
|
+
}, Se = async (t) => {
|
|
381
474
|
const e = t.map;
|
|
382
475
|
if (!e?.portalItem)
|
|
383
476
|
throw new Error("WebMap portal item is missing.");
|
|
384
477
|
const { resources: r } = await e.portalItem.fetchResources(), s = r.find((i) => i.resource.path === "embeddings-v01.json");
|
|
385
478
|
if (!s?.resource.url)
|
|
386
479
|
throw new Error("Embeddings resource 'embeddings-v01.json' not found in the webmap portal item.");
|
|
387
|
-
const n = await
|
|
388
|
-
return
|
|
480
|
+
const n = await Ee(s.resource.url);
|
|
481
|
+
return we(n);
|
|
389
482
|
};
|
|
390
|
-
class
|
|
483
|
+
class k {
|
|
391
484
|
constructor() {
|
|
392
|
-
this.orchestratorReady = !1, this.chatHistory = [], this.priorSteps = [], this.sharedState = {}, this.agentRegistry = new
|
|
485
|
+
this.orchestratorReady = !1, this.chatHistory = [], this.priorSteps = [], this.sharedState = {}, this.agentRegistry = new R(), this.activeRunId = "", this.cancelledRunIds = /* @__PURE__ */ new Set(), this.parentRunIds = /* @__PURE__ */ new Map(), this.activeRuntimeSpans = /* @__PURE__ */ new Map(), this.runtimeEventsEnabled = !1, this.streamEpoch = 0;
|
|
393
486
|
}
|
|
394
487
|
/**
|
|
395
488
|
* Creates and returns an AI-ready Orchestrator instance.
|
|
@@ -397,15 +490,16 @@ class x {
|
|
|
397
490
|
* @returns Ready Orchestrator.
|
|
398
491
|
*/
|
|
399
492
|
static async init(e) {
|
|
400
|
-
const r = new
|
|
493
|
+
const r = new k();
|
|
494
|
+
r.runtimeEventsEnabled = e.runtimeEventsEnabled ?? !1;
|
|
401
495
|
try {
|
|
402
496
|
if (e.view?.map) {
|
|
403
|
-
await
|
|
404
|
-
const s = await
|
|
497
|
+
await G.whenOnce(() => e.view.ready);
|
|
498
|
+
const s = await Se(e.view), n = ve(
|
|
405
499
|
s.layers,
|
|
406
500
|
e.view.map
|
|
407
501
|
);
|
|
408
|
-
r.layersAndFieldsRegistry = n, r.embeddingsWorker = await
|
|
502
|
+
r.layersAndFieldsRegistry = n, r.embeddingsWorker = await B(s);
|
|
409
503
|
}
|
|
410
504
|
return e.agents?.forEach((s) => {
|
|
411
505
|
r.agentRegistry.register(s);
|
|
@@ -421,35 +515,42 @@ class x {
|
|
|
421
515
|
* - `interrupt`: HITL required, wait for `resumeInterrupt()`
|
|
422
516
|
* - `completed`: final result with chat history + layer styling
|
|
423
517
|
* - `cancelled`: user aborted the run
|
|
518
|
+
* @param userInput User request to process.
|
|
519
|
+
* @param options Agent selection and routing behavior for this run.
|
|
424
520
|
*/
|
|
425
|
-
async *ask(e) {
|
|
521
|
+
async *ask(e, r = {}) {
|
|
426
522
|
if (!this.orchestratorReady)
|
|
427
523
|
throw new Error("Orchestrator is not ready yet.");
|
|
428
524
|
if (!this.agentRegistry.list().length)
|
|
429
525
|
throw new Error("Orchestrator has no registered agents.");
|
|
526
|
+
const s = this.createRequestAgentRegistry(r);
|
|
527
|
+
if (!s.list().length)
|
|
528
|
+
throw new Error("Orchestrator has no agents selected for this request.");
|
|
430
529
|
if (++this.streamEpoch, !e.trim())
|
|
431
530
|
return;
|
|
432
|
-
const
|
|
433
|
-
this.activeRunId =
|
|
434
|
-
const
|
|
531
|
+
const n = U();
|
|
532
|
+
this.parentRunIds.clear(), this.activeRuntimeSpans.clear(), this.activeRunId = n, this.activeAbortController = new AbortController(), this.graph || (this.graph = oe().compile({ checkpointer: new j() }));
|
|
533
|
+
const a = this.embeddingsWorker ? pe({ worker: this.embeddingsWorker }) : void 0, i = this.embeddingsWorker ? ye({ worker: this.embeddingsWorker }) : void 0, c = /* @__PURE__ */ new Map(), d = r.routing === "direct" ? { mode: "direct", agentId: r.agentId } : { mode: "auto" }, o = {
|
|
534
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
535
|
+
thread_id: n,
|
|
536
|
+
hitlResponse: null,
|
|
537
|
+
services: {
|
|
538
|
+
layerSearch: a,
|
|
539
|
+
fieldSearch: i,
|
|
540
|
+
layersAndFieldsRegistry: this.layersAndFieldsRegistry,
|
|
541
|
+
agentRegistry: s,
|
|
542
|
+
embeddingCache: c
|
|
543
|
+
}
|
|
544
|
+
}, u = {
|
|
435
545
|
version: "v2",
|
|
436
546
|
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
|
-
},
|
|
547
|
+
signal: this.activeAbortController.signal,
|
|
548
|
+
...this.runtimeEventsEnabled && { callbacks: [this.createHierarchyCallback()] },
|
|
549
|
+
configurable: o,
|
|
450
550
|
subgraphs: !0
|
|
451
|
-
},
|
|
551
|
+
}, g = this.graph?.streamEvents(
|
|
452
552
|
{
|
|
553
|
+
routing: d,
|
|
453
554
|
agentExecutionContext: {
|
|
454
555
|
userRequest: e,
|
|
455
556
|
messages: this.chatHistory,
|
|
@@ -457,54 +558,54 @@ class x {
|
|
|
457
558
|
sharedState: this.sharedState
|
|
458
559
|
}
|
|
459
560
|
},
|
|
460
|
-
|
|
461
|
-
),
|
|
462
|
-
if (yield* this.pipeStream(
|
|
463
|
-
yield
|
|
561
|
+
u
|
|
562
|
+
), l = ++this.streamEpoch;
|
|
563
|
+
if (yield* this.pipeStream(g, l, n), this.isRunCancelled(n)) {
|
|
564
|
+
yield* this.createCancellationEvents(n);
|
|
464
565
|
return;
|
|
465
566
|
}
|
|
466
567
|
for (; ; ) {
|
|
467
|
-
if (this.isRunCancelled(
|
|
468
|
-
yield
|
|
568
|
+
if (this.isRunCancelled(n)) {
|
|
569
|
+
yield* this.createCancellationEvents(n);
|
|
469
570
|
return;
|
|
470
571
|
}
|
|
471
|
-
const
|
|
472
|
-
if (!
|
|
572
|
+
const p = (await this.graph.getState(u, { subgraphs: !0 })).tasks.find((f) => f.interrupts.length > 0)?.interrupts[0]?.value;
|
|
573
|
+
if (!p)
|
|
473
574
|
break;
|
|
474
|
-
this.currentInterrupt =
|
|
575
|
+
this.currentInterrupt = p, this.interruptHandler = new le(this.graph, u), yield* this.closeActiveRuntimeSpans(n, "interrupted"), yield { runId: n, timestamp: Date.now(), type: "interrupt", interrupt: p };
|
|
475
576
|
try {
|
|
476
|
-
const
|
|
477
|
-
yield* this.pipeStream(
|
|
478
|
-
} catch (
|
|
479
|
-
if (this.isRunCancelled(
|
|
480
|
-
yield
|
|
577
|
+
const f = await this.interruptHandler.waitForUser(), I = ++this.streamEpoch;
|
|
578
|
+
yield* this.pipeStream(f, I, n);
|
|
579
|
+
} catch (f) {
|
|
580
|
+
if (this.isRunCancelled(n)) {
|
|
581
|
+
yield* this.createCancellationEvents(n);
|
|
481
582
|
return;
|
|
482
583
|
}
|
|
483
|
-
if (
|
|
584
|
+
if (f) {
|
|
484
585
|
yield {
|
|
485
|
-
runId:
|
|
586
|
+
runId: n,
|
|
486
587
|
timestamp: Date.now(),
|
|
487
588
|
type: "error",
|
|
488
|
-
error: { message:
|
|
589
|
+
error: { message: f?.message }
|
|
489
590
|
};
|
|
490
591
|
return;
|
|
491
592
|
}
|
|
492
593
|
}
|
|
493
594
|
}
|
|
494
|
-
if (this.isRunCancelled(
|
|
495
|
-
yield
|
|
595
|
+
if (this.isRunCancelled(n)) {
|
|
596
|
+
yield* this.createCancellationEvents(n);
|
|
496
597
|
return;
|
|
497
598
|
}
|
|
498
|
-
const
|
|
499
|
-
if (this.isRunCancelled(
|
|
500
|
-
yield
|
|
599
|
+
const h = (await this.graph.getState(u, { subgraphs: !0 })).values;
|
|
600
|
+
if (this.isRunCancelled(n)) {
|
|
601
|
+
yield* this.createCancellationEvents(n);
|
|
501
602
|
return;
|
|
502
603
|
}
|
|
503
|
-
this.chatHistory =
|
|
504
|
-
runId:
|
|
604
|
+
this.chatHistory = h.agentExecutionContext.messages.length ? h.agentExecutionContext.messages : this.chatHistory, this.priorSteps = h.agentExecutionContext.priorSteps?.slice(-5) ?? [], this.sharedState = h.agentExecutionContext.sharedState ?? {}, yield {
|
|
605
|
+
runId: n,
|
|
505
606
|
timestamp: Date.now(),
|
|
506
607
|
type: "completed",
|
|
507
|
-
result: { content:
|
|
608
|
+
result: { content: h.finalOutputMessage }
|
|
508
609
|
};
|
|
509
610
|
}
|
|
510
611
|
/**
|
|
@@ -539,20 +640,78 @@ class x {
|
|
|
539
640
|
this.activeRunId && (this.cancelledRunIds.add(this.activeRunId), this.activeAbortController?.abort(), ++this.streamEpoch, this.interruptHandler?.cancel());
|
|
540
641
|
}
|
|
541
642
|
async *pipeStream(e, r, s) {
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
643
|
+
try {
|
|
644
|
+
for await (const n of e) {
|
|
645
|
+
if (this.isRunCancelled(s) || r !== this.streamEpoch)
|
|
646
|
+
break;
|
|
647
|
+
if (this.runtimeEventsEnabled) {
|
|
648
|
+
const a = ge({
|
|
649
|
+
event: n,
|
|
650
|
+
runId: s,
|
|
651
|
+
parentSpanId: this.parentRunIds.get(n.run_id),
|
|
652
|
+
timestamp: Date.now()
|
|
653
|
+
});
|
|
654
|
+
a && (a.phase === "started" ? this.activeRuntimeSpans.set(a.span.id, a) : this.activeRuntimeSpans.delete(a.span.id), yield a);
|
|
655
|
+
}
|
|
656
|
+
n.event === "on_custom_event" && n.name === "trace_message" ? yield { runId: s, timestamp: Date.now(), type: "trace", data: n.data } : n.name === "graph_ux_suggestion" && (yield {
|
|
657
|
+
runId: s,
|
|
658
|
+
timestamp: Date.now(),
|
|
659
|
+
type: "ux-suggestion",
|
|
660
|
+
suggestion: n.data
|
|
661
|
+
});
|
|
662
|
+
}
|
|
663
|
+
} catch (n) {
|
|
664
|
+
if (!this.isRunCancelled(s))
|
|
665
|
+
throw n;
|
|
551
666
|
}
|
|
552
667
|
}
|
|
668
|
+
*createCancellationEvents(e) {
|
|
669
|
+
yield* this.closeActiveRuntimeSpans(e, "cancelled"), yield { runId: e, timestamp: Date.now(), type: "cancelled", reason: "user" };
|
|
670
|
+
}
|
|
671
|
+
*closeActiveRuntimeSpans(e, r) {
|
|
672
|
+
const s = Date.now(), n = [...this.activeRuntimeSpans.values()].reverse();
|
|
673
|
+
this.activeRuntimeSpans.clear();
|
|
674
|
+
for (const a of n) {
|
|
675
|
+
const { input: i, ...c } = a.span;
|
|
676
|
+
yield {
|
|
677
|
+
type: "runtime",
|
|
678
|
+
phase: r,
|
|
679
|
+
runId: e,
|
|
680
|
+
timestamp: s,
|
|
681
|
+
...a.agentId && { agentId: a.agentId },
|
|
682
|
+
span: c
|
|
683
|
+
};
|
|
684
|
+
}
|
|
685
|
+
}
|
|
686
|
+
// v2 stream events omit parent run IDs, so capture them through callbacks to preserve the normalized span hierarchy.
|
|
687
|
+
createHierarchyCallback() {
|
|
688
|
+
const e = (r, s) => {
|
|
689
|
+
s && this.parentRunIds.set(r, s);
|
|
690
|
+
};
|
|
691
|
+
return N.fromMethods({
|
|
692
|
+
handleLLMStart: (r, s, n, a) => e(n, a),
|
|
693
|
+
handleChatModelStart: (r, s, n, a) => e(n, a),
|
|
694
|
+
handleChainStart: (r, s, n, a) => e(n, a),
|
|
695
|
+
handleToolStart: (r, s, n, a) => e(n, a),
|
|
696
|
+
handleRetrieverStart: (r, s, n, a) => e(n, a)
|
|
697
|
+
});
|
|
698
|
+
}
|
|
553
699
|
isRunCancelled(e) {
|
|
554
700
|
return this.cancelledRunIds.has(e);
|
|
555
701
|
}
|
|
702
|
+
/**
|
|
703
|
+
* Creates a request-scoped registry containing all agents by default,
|
|
704
|
+
* or only the explicitly selected agents when filtering is requested.
|
|
705
|
+
*/
|
|
706
|
+
createRequestAgentRegistry(e) {
|
|
707
|
+
const r = e.routing === "direct" ? [e.agentId] : e.agentIds, s = r ? r.map((a) => {
|
|
708
|
+
const i = this.agentRegistry.get(a);
|
|
709
|
+
if (!i)
|
|
710
|
+
throw new Error(`Agent is not registered: ${a}`);
|
|
711
|
+
return i;
|
|
712
|
+
}) : this.agentRegistry.list(), n = new R();
|
|
713
|
+
return s.forEach((a) => n.register(a)), n;
|
|
714
|
+
}
|
|
556
715
|
/**
|
|
557
716
|
* Disposes this instance by terminating the embeddings worker
|
|
558
717
|
* and cleaning up all related resources.
|
|
@@ -562,6 +721,6 @@ class x {
|
|
|
562
721
|
}
|
|
563
722
|
}
|
|
564
723
|
export {
|
|
565
|
-
|
|
566
|
-
|
|
724
|
+
k as O,
|
|
725
|
+
he as g
|
|
567
726
|
};
|