@arcgis/ai-components 5.2.0-next.4 → 5.2.0-next.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent-utils/LLMAgent.js +22 -22
- package/dist/cdn/{YY2SBO3V.js → 3NI46YCE.js} +1 -1
- package/dist/cdn/{V5YEZSRY.js → 47FWPQ2A.js} +1 -1
- package/dist/cdn/{FHVXO2WG.js → AEJHYRGT.js} +4 -4
- package/dist/cdn/{JY6LLOUJ.js → BFZJNJL6.js} +1 -1
- package/dist/cdn/{MDVYQQUG.js → GCQLVNNC.js} +1 -1
- package/dist/cdn/{GSEPHN3A.js → JV4SI65E.js} +31 -29
- package/dist/cdn/R6HV42YW.js +3 -0
- package/dist/cdn/{S6W6HV4T.js → V7OJRG26.js} +1 -1
- package/dist/cdn/{4HU7735A.js → VOQX4AVB.js} +1 -1
- package/dist/cdn/index.js +1 -1
- package/dist/cdn/main.css +1 -1
- package/dist/chunks/adapter.js +6 -6
- package/dist/chunks/generateLayerDescriptions.js +236 -208
- package/dist/chunks/orchestrator.js +240 -201
- package/dist/components/arcgis-assistant-chat/customElement.d.ts +6 -1
- package/dist/components/arcgis-assistant-chat-entry/customElement.d.ts +2 -1
- package/dist/components/arcgis-assistant-interrupt/customElement.d.ts +4 -1
- package/dist/components/arcgis-assistant-message/customElement.d.ts +21 -0
- package/dist/components/arcgis-assistant-message/index.d.ts +1 -0
- package/dist/components/arcgis-assistant-message-block/customElement.d.ts +1 -1
- package/dist/components/arcgis-assistant-message-feedback/customElement.d.ts +4 -1
- package/dist/components/arcgis-assistant-message-footer/customElement.d.ts +4 -1
- package/dist/components/arcgis-assistant-message-loading/customElement.d.ts +4 -1
- package/dist/components/arcgis-assistant-message-log/customElement.d.ts +4 -1
- package/dist/components/arcgis-assistant-message-read-aloud/customElement.d.ts +4 -1
- package/dist/components/arcgis-assistant-message-text/customElement.d.ts +4 -1
- package/dist/components/arcgis-assistant-speech-input/customElement.d.ts +6 -1
- package/dist/components/arcgis-assistant-suggested-prompts/customElement.d.ts +4 -1
- package/dist/components/arcgis-assistant-user-message/customElement.d.ts +4 -1
- package/dist/docs/api.json +1 -1
- package/dist/docs/docs.json +1 -1
- package/dist/docs/vscode.html-custom-data.json +1 -1
- package/dist/docs/web-types.json +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/types/lumina.d.ts +5 -0
- package/dist/types/preact.d.ts +6 -0
- package/dist/types/react.d.ts +7 -0
- package/dist/types/stencil.d.ts +5 -0
- package/dist/utils/index.d.ts +10 -14
- package/dist/utils/index.js +68 -78
- package/package.json +5 -5
- package/dist/cdn/ON2V5XI2.js +0 -3
package/dist/index.d.ts
CHANGED
|
@@ -34,6 +34,7 @@ import type { ArcgisAssistantNavigationAgent } from "./components/arcgis-assista
|
|
|
34
34
|
import type { ArcgisAssistantChat } from "./components/arcgis-assistant-chat/customElement.js";
|
|
35
35
|
import type { ArcgisAssistantChatEntry } from "./components/arcgis-assistant-chat-entry/customElement.js";
|
|
36
36
|
import type { ArcgisAssistantInterrupt } from "./components/arcgis-assistant-interrupt/customElement.js";
|
|
37
|
+
import type { ArcgisAssistantMessage } from "./components/arcgis-assistant-message/customElement.js";
|
|
37
38
|
import type { ArcgisAssistantMessageBlock } from "./components/arcgis-assistant-message-block/customElement.js";
|
|
38
39
|
import type { ArcgisAssistantMessageFeedback } from "./components/arcgis-assistant-message-feedback/customElement.js";
|
|
39
40
|
import type { ArcgisAssistantMessageFooter } from "./components/arcgis-assistant-message-footer/customElement.js";
|
|
@@ -91,6 +92,7 @@ declare global {
|
|
|
91
92
|
"arcgis-assistant-chat": ArcgisAssistantChat;
|
|
92
93
|
"arcgis-assistant-chat-entry": ArcgisAssistantChatEntry;
|
|
93
94
|
"arcgis-assistant-interrupt": ArcgisAssistantInterrupt;
|
|
95
|
+
"arcgis-assistant-message": ArcgisAssistantMessage;
|
|
94
96
|
"arcgis-assistant-message-block": ArcgisAssistantMessageBlock;
|
|
95
97
|
"arcgis-assistant-message-feedback": ArcgisAssistantMessageFeedback;
|
|
96
98
|
"arcgis-assistant-message-footer": ArcgisAssistantMessageFooter;
|
|
@@ -127,6 +129,8 @@ declare global {
|
|
|
127
129
|
type HTMLArcgisAssistantInterruptElementEventMap = ArcgisAssistantInterrupt["@eventTypes"];
|
|
128
130
|
type HTMLArcgisAssistantInterruptElement = ArcgisAssistantInterrupt;
|
|
129
131
|
|
|
132
|
+
type HTMLArcgisAssistantMessageElement = ArcgisAssistantMessage;
|
|
133
|
+
|
|
130
134
|
type HTMLArcgisAssistantMessageBlockElement = ArcgisAssistantMessageBlock;
|
|
131
135
|
|
|
132
136
|
type HTMLArcgisAssistantMessageFeedbackElementEventMap = ArcgisAssistantMessageFeedback["@eventTypes"];
|
package/dist/types/lumina.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ import type { ArcgisAssistantNavigationAgent } from "../components/arcgis-assist
|
|
|
9
9
|
import type { ArcgisAssistantChat } from "../components/arcgis-assistant-chat/customElement.js";
|
|
10
10
|
import type { ArcgisAssistantChatEntry } from "../components/arcgis-assistant-chat-entry/customElement.js";
|
|
11
11
|
import type { ArcgisAssistantInterrupt } from "../components/arcgis-assistant-interrupt/customElement.js";
|
|
12
|
+
import type { ArcgisAssistantMessage } from "../components/arcgis-assistant-message/customElement.js";
|
|
12
13
|
import type { ArcgisAssistantMessageBlock } from "../components/arcgis-assistant-message-block/customElement.js";
|
|
13
14
|
import type { ArcgisAssistantMessageFeedback } from "../components/arcgis-assistant-message-feedback/customElement.js";
|
|
14
15
|
import type { ArcgisAssistantMessageFooter } from "../components/arcgis-assistant-message-footer/customElement.js";
|
|
@@ -65,6 +66,9 @@ interface LuminaArcgisAssistantInterrupt extends Partial<Pick<ArcgisAssistantInt
|
|
|
65
66
|
onarcgisSubmit?: EventHandler<ArcgisAssistantInterrupt["arcgisSubmit"]>;
|
|
66
67
|
}
|
|
67
68
|
|
|
69
|
+
interface LuminaArcgisAssistantMessage extends Partial<Pick<ArcgisAssistantMessage, "copyEnabled" | "feedbackEnabled" | "footerDisabled" | "logEnabled" | "message" | "readAloudEnabled">>, h.JSX.HTMLAttributes<ArcgisAssistantMessage> {
|
|
70
|
+
}
|
|
71
|
+
|
|
68
72
|
interface LuminaArcgisAssistantMessageBlock extends Partial<Pick<ArcgisAssistantMessageBlock, "block">>, h.JSX.HTMLAttributes<ArcgisAssistantMessageBlock> {
|
|
69
73
|
}
|
|
70
74
|
|
|
@@ -117,6 +121,7 @@ declare module "@arcgis/lumina" {
|
|
|
117
121
|
"arcgis-assistant-chat": LuminaArcgisAssistantChat;
|
|
118
122
|
"arcgis-assistant-chat-entry": LuminaArcgisAssistantChatEntry;
|
|
119
123
|
"arcgis-assistant-interrupt": LuminaArcgisAssistantInterrupt;
|
|
124
|
+
"arcgis-assistant-message": LuminaArcgisAssistantMessage;
|
|
120
125
|
"arcgis-assistant-message-block": LuminaArcgisAssistantMessageBlock;
|
|
121
126
|
"arcgis-assistant-message-feedback": LuminaArcgisAssistantMessageFeedback;
|
|
122
127
|
"arcgis-assistant-message-footer": LuminaArcgisAssistantMessageFooter;
|
package/dist/types/preact.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ import type { ArcgisAssistantNavigationAgent } from "../components/arcgis-assist
|
|
|
9
9
|
import type { ArcgisAssistantChat } from "../components/arcgis-assistant-chat/customElement.js";
|
|
10
10
|
import type { ArcgisAssistantChatEntry } from "../components/arcgis-assistant-chat-entry/customElement.js";
|
|
11
11
|
import type { ArcgisAssistantInterrupt } from "../components/arcgis-assistant-interrupt/customElement.js";
|
|
12
|
+
import type { ArcgisAssistantMessage } from "../components/arcgis-assistant-message/customElement.js";
|
|
12
13
|
import type { ArcgisAssistantMessageBlock } from "../components/arcgis-assistant-message-block/customElement.js";
|
|
13
14
|
import type { ArcgisAssistantMessageFeedback } from "../components/arcgis-assistant-message-feedback/customElement.js";
|
|
14
15
|
import type { ArcgisAssistantMessageFooter } from "../components/arcgis-assistant-message-footer/customElement.js";
|
|
@@ -66,6 +67,9 @@ interface PreactArcgisAssistantInterrupt extends Partial<Pick<ArcgisAssistantInt
|
|
|
66
67
|
onarcgisSubmit?: EventHandler<ArcgisAssistantInterrupt["arcgisSubmit"]>;
|
|
67
68
|
}
|
|
68
69
|
|
|
70
|
+
interface PreactArcgisAssistantMessage extends Partial<Pick<ArcgisAssistantMessage, "copyEnabled" | "feedbackEnabled" | "footerDisabled" | "logEnabled" | "message" | "readAloudEnabled">>, HTMLAttributes<ArcgisAssistantMessage> {
|
|
71
|
+
}
|
|
72
|
+
|
|
69
73
|
interface PreactArcgisAssistantMessageBlock extends Partial<Pick<ArcgisAssistantMessageBlock, "block">>, HTMLAttributes<ArcgisAssistantMessageBlock> {
|
|
70
74
|
}
|
|
71
75
|
|
|
@@ -118,6 +122,7 @@ declare module 'preact' {
|
|
|
118
122
|
"arcgis-assistant-chat": PreactArcgisAssistantChat;
|
|
119
123
|
"arcgis-assistant-chat-entry": PreactArcgisAssistantChatEntry;
|
|
120
124
|
"arcgis-assistant-interrupt": PreactArcgisAssistantInterrupt;
|
|
125
|
+
"arcgis-assistant-message": PreactArcgisAssistantMessage;
|
|
121
126
|
"arcgis-assistant-message-block": PreactArcgisAssistantMessageBlock;
|
|
122
127
|
"arcgis-assistant-message-feedback": PreactArcgisAssistantMessageFeedback;
|
|
123
128
|
"arcgis-assistant-message-footer": PreactArcgisAssistantMessageFooter;
|
|
@@ -142,6 +147,7 @@ declare module 'preact' {
|
|
|
142
147
|
"arcgis-assistant-chat": PreactArcgisAssistantChat;
|
|
143
148
|
"arcgis-assistant-chat-entry": PreactArcgisAssistantChatEntry;
|
|
144
149
|
"arcgis-assistant-interrupt": PreactArcgisAssistantInterrupt;
|
|
150
|
+
"arcgis-assistant-message": PreactArcgisAssistantMessage;
|
|
145
151
|
"arcgis-assistant-message-block": PreactArcgisAssistantMessageBlock;
|
|
146
152
|
"arcgis-assistant-message-feedback": PreactArcgisAssistantMessageFeedback;
|
|
147
153
|
"arcgis-assistant-message-footer": PreactArcgisAssistantMessageFooter;
|
package/dist/types/react.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ import type { ArcgisAssistantNavigationAgent } from "../components/arcgis-assist
|
|
|
9
9
|
import type { ArcgisAssistantChat } from "../components/arcgis-assistant-chat/customElement.js";
|
|
10
10
|
import type { ArcgisAssistantChatEntry } from "../components/arcgis-assistant-chat-entry/customElement.js";
|
|
11
11
|
import type { ArcgisAssistantInterrupt } from "../components/arcgis-assistant-interrupt/customElement.js";
|
|
12
|
+
import type { ArcgisAssistantMessage } from "../components/arcgis-assistant-message/customElement.js";
|
|
12
13
|
import type { ArcgisAssistantMessageBlock } from "../components/arcgis-assistant-message-block/customElement.js";
|
|
13
14
|
import type { ArcgisAssistantMessageFeedback } from "../components/arcgis-assistant-message-feedback/customElement.js";
|
|
14
15
|
import type { ArcgisAssistantMessageFooter } from "../components/arcgis-assistant-message-footer/customElement.js";
|
|
@@ -66,6 +67,9 @@ interface ReactArcgisAssistantInterrupt extends Partial<Pick<ArcgisAssistantInte
|
|
|
66
67
|
onarcgisSubmit?: EventHandler<ArcgisAssistantInterrupt["arcgisSubmit"]>;
|
|
67
68
|
}
|
|
68
69
|
|
|
70
|
+
interface ReactArcgisAssistantMessage extends Partial<Pick<ArcgisAssistantMessage, "copyEnabled" | "feedbackEnabled" | "footerDisabled" | "logEnabled" | "message" | "readAloudEnabled">>, HTMLProps<ArcgisAssistantMessage> {
|
|
71
|
+
}
|
|
72
|
+
|
|
69
73
|
interface ReactArcgisAssistantMessageBlock extends Partial<Pick<ArcgisAssistantMessageBlock, "block">>, HTMLProps<ArcgisAssistantMessageBlock> {
|
|
70
74
|
}
|
|
71
75
|
|
|
@@ -118,6 +122,7 @@ declare module "react" {
|
|
|
118
122
|
"arcgis-assistant-chat": ReactArcgisAssistantChat;
|
|
119
123
|
"arcgis-assistant-chat-entry": ReactArcgisAssistantChatEntry;
|
|
120
124
|
"arcgis-assistant-interrupt": ReactArcgisAssistantInterrupt;
|
|
125
|
+
"arcgis-assistant-message": ReactArcgisAssistantMessage;
|
|
121
126
|
"arcgis-assistant-message-block": ReactArcgisAssistantMessageBlock;
|
|
122
127
|
"arcgis-assistant-message-feedback": ReactArcgisAssistantMessageFeedback;
|
|
123
128
|
"arcgis-assistant-message-footer": ReactArcgisAssistantMessageFooter;
|
|
@@ -144,6 +149,7 @@ declare module "react/jsx-runtime" {
|
|
|
144
149
|
"arcgis-assistant-chat": ReactArcgisAssistantChat;
|
|
145
150
|
"arcgis-assistant-chat-entry": ReactArcgisAssistantChatEntry;
|
|
146
151
|
"arcgis-assistant-interrupt": ReactArcgisAssistantInterrupt;
|
|
152
|
+
"arcgis-assistant-message": ReactArcgisAssistantMessage;
|
|
147
153
|
"arcgis-assistant-message-block": ReactArcgisAssistantMessageBlock;
|
|
148
154
|
"arcgis-assistant-message-feedback": ReactArcgisAssistantMessageFeedback;
|
|
149
155
|
"arcgis-assistant-message-footer": ReactArcgisAssistantMessageFooter;
|
|
@@ -170,6 +176,7 @@ declare module "react/jsx-dev-runtime" {
|
|
|
170
176
|
"arcgis-assistant-chat": ReactArcgisAssistantChat;
|
|
171
177
|
"arcgis-assistant-chat-entry": ReactArcgisAssistantChatEntry;
|
|
172
178
|
"arcgis-assistant-interrupt": ReactArcgisAssistantInterrupt;
|
|
179
|
+
"arcgis-assistant-message": ReactArcgisAssistantMessage;
|
|
173
180
|
"arcgis-assistant-message-block": ReactArcgisAssistantMessageBlock;
|
|
174
181
|
"arcgis-assistant-message-feedback": ReactArcgisAssistantMessageFeedback;
|
|
175
182
|
"arcgis-assistant-message-footer": ReactArcgisAssistantMessageFooter;
|
package/dist/types/stencil.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ import type { ArcgisAssistantNavigationAgent } from "../components/arcgis-assist
|
|
|
9
9
|
import type { ArcgisAssistantChat } from "../components/arcgis-assistant-chat/customElement.js";
|
|
10
10
|
import type { ArcgisAssistantChatEntry } from "../components/arcgis-assistant-chat-entry/customElement.js";
|
|
11
11
|
import type { ArcgisAssistantInterrupt } from "../components/arcgis-assistant-interrupt/customElement.js";
|
|
12
|
+
import type { ArcgisAssistantMessage } from "../components/arcgis-assistant-message/customElement.js";
|
|
12
13
|
import type { ArcgisAssistantMessageBlock } from "../components/arcgis-assistant-message-block/customElement.js";
|
|
13
14
|
import type { ArcgisAssistantMessageFeedback } from "../components/arcgis-assistant-message-feedback/customElement.js";
|
|
14
15
|
import type { ArcgisAssistantMessageFooter } from "../components/arcgis-assistant-message-footer/customElement.js";
|
|
@@ -66,6 +67,9 @@ interface StencilArcgisAssistantInterrupt extends Partial<Pick<ArcgisAssistantIn
|
|
|
66
67
|
onArcgisSubmit?: EventHandler<ArcgisAssistantInterrupt["arcgisSubmit"]>;
|
|
67
68
|
}
|
|
68
69
|
|
|
70
|
+
interface StencilArcgisAssistantMessage extends Partial<Pick<ArcgisAssistantMessage, "copyEnabled" | "feedbackEnabled" | "footerDisabled" | "logEnabled" | "message" | "readAloudEnabled">>, StencilJsx.HTMLAttributes<ArcgisAssistantMessage> {
|
|
71
|
+
}
|
|
72
|
+
|
|
69
73
|
interface StencilArcgisAssistantMessageBlock extends Partial<Pick<ArcgisAssistantMessageBlock, "block">>, StencilJsx.HTMLAttributes<ArcgisAssistantMessageBlock> {
|
|
70
74
|
}
|
|
71
75
|
|
|
@@ -116,6 +120,7 @@ interface ExposedElements {
|
|
|
116
120
|
"arcgis-assistant-chat": StencilArcgisAssistantChat;
|
|
117
121
|
"arcgis-assistant-chat-entry": StencilArcgisAssistantChatEntry;
|
|
118
122
|
"arcgis-assistant-interrupt": StencilArcgisAssistantInterrupt;
|
|
123
|
+
"arcgis-assistant-message": StencilArcgisAssistantMessage;
|
|
119
124
|
"arcgis-assistant-message-block": StencilArcgisAssistantMessageBlock;
|
|
120
125
|
"arcgis-assistant-message-feedback": StencilArcgisAssistantMessageFeedback;
|
|
121
126
|
"arcgis-assistant-message-footer": StencilArcgisAssistantMessageFooter;
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -146,6 +146,8 @@ export type ArcgisPromptOptions = {
|
|
|
146
146
|
* - `advanced` - An advanced model tier that may provide improved accuracy or capabilities compared to
|
|
147
147
|
* the default tier. However, it may also come with increased cost and slower performance. At
|
|
148
148
|
* JS SDK v5.0, this model tier corresponds to GPT-5.2 model.
|
|
149
|
+
* - `fast` - A lower cost model suitable for tasks like classification and summarization. This tier may have limitations in terms of response length and complexity.
|
|
150
|
+
* New at JS SDK v5.1, this model tier corresponds to GPT-5.4-nano model.
|
|
149
151
|
*
|
|
150
152
|
* The specific models available in each tier may evolve over time as new models are released and existing
|
|
151
153
|
* models are retired. The dates models are retired depends on the model provider and therefore may not
|
|
@@ -172,6 +174,8 @@ export type ArcgisPromptOptions = {
|
|
|
172
174
|
* and produce more accurate and relevant responses.
|
|
173
175
|
*/
|
|
174
176
|
messages?: ChatHistory;
|
|
177
|
+
/** Abort signal for cooperative run cancellation. */
|
|
178
|
+
abortSignal?: AbortSignal;
|
|
175
179
|
/**
|
|
176
180
|
* Input variables for the prompt. This can include any relevant variables related to the context
|
|
177
181
|
* provided to the agent. This may be necessary for determining tool parameters or for providing additional
|
|
@@ -305,17 +309,6 @@ export function sendTraceMessage(data: TraceEventData, config?: RunnableConfig):
|
|
|
305
309
|
*/
|
|
306
310
|
export function getEmbeddings(inputs: string[]): Promise<number[][]>;
|
|
307
311
|
|
|
308
|
-
/**
|
|
309
|
-
* Calculates the cosine similarity between two numeric vectors. This is used to measure the similarity
|
|
310
|
-
* between two embedding vectors, where a score of 1 indicates identical vectors, 0 indicates orthogonal
|
|
311
|
-
* vectors, and -1 indicates opposite vectors.
|
|
312
|
-
*
|
|
313
|
-
* @param vectorA - The first vector array.
|
|
314
|
-
* @param vectorB - The second vector array.
|
|
315
|
-
* @returns A similarity score from -1 (opposite) to 1 (identical).
|
|
316
|
-
*/
|
|
317
|
-
export function cosineSimilarity(vectorA: number[], vectorB: number[]): number;
|
|
318
|
-
|
|
319
312
|
/**
|
|
320
313
|
* The suggestions emitted by the agent to the user interface.
|
|
321
314
|
*
|
|
@@ -456,11 +449,14 @@ export type SharedStatePatch<T extends Record<string, unknown> = Record<string,
|
|
|
456
449
|
};
|
|
457
450
|
|
|
458
451
|
/**
|
|
459
|
-
* @param
|
|
460
|
-
* @param temperature
|
|
452
|
+
* @param parameter0
|
|
461
453
|
* @internal
|
|
462
454
|
*/
|
|
463
|
-
export function createChatModel(
|
|
455
|
+
export function createChatModel(parameter0?: {
|
|
456
|
+
modelTier?: ChatModelTier;
|
|
457
|
+
temperature?: number;
|
|
458
|
+
abortSignal?: AbortSignal;
|
|
459
|
+
}): Promise<ChatOpenAI>;
|
|
464
460
|
|
|
465
461
|
export type ChatModelTier = "advanced" | "default" | "fast";
|
|
466
462
|
|
package/dist/utils/index.js
CHANGED
|
@@ -1,111 +1,101 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
2
|
import { g as p } from "../chunks/orchestrator.js";
|
|
3
|
-
import { O as
|
|
4
|
-
import { g as
|
|
5
|
-
import
|
|
6
|
-
import * as
|
|
7
|
-
import { N as
|
|
3
|
+
import { O as ge } from "../chunks/orchestrator.js";
|
|
4
|
+
import { g as A, a as h, W as v, f as g, l as f, d as S, m as w, b as $, e as b, i as L, h as P, j as E, s as T, k as R, n as k, c as D, o as W } from "../chunks/generateLayerDescriptions.js";
|
|
5
|
+
import x from "@arcgis/core/layers/FeatureLayer.js";
|
|
6
|
+
import * as F from "@arcgis/core/core/reactiveUtils.js";
|
|
7
|
+
import { N as M } from "../chunks/navigationGraph.js";
|
|
8
8
|
import { L as C } from "../chunks/layerStylingGraph.js";
|
|
9
9
|
import { D as N } from "../chunks/dataExplorationGraph.js";
|
|
10
10
|
import { H as z } from "../chunks/helpGraph.js";
|
|
11
11
|
import { A as H } from "../chunks/arcgisKnowledgeGraph.js";
|
|
12
|
-
const I = async (
|
|
13
|
-
const
|
|
14
|
-
for (const a of
|
|
15
|
-
if (a instanceof
|
|
12
|
+
const I = async (t) => {
|
|
13
|
+
const e = t.allLayers.toArray(), s = [], o = /* @__PURE__ */ new Map();
|
|
14
|
+
for (const a of e)
|
|
15
|
+
if (a instanceof x) {
|
|
16
16
|
const m = (async () => {
|
|
17
|
-
const
|
|
18
|
-
|
|
17
|
+
const r = await A(a), c = await h(a, r);
|
|
18
|
+
o.set(a.id, { layerItem: c, fieldRegistry: r });
|
|
19
19
|
})();
|
|
20
|
-
|
|
20
|
+
s.push(m);
|
|
21
21
|
}
|
|
22
|
-
return await Promise.all(
|
|
23
|
-
}, O = async (
|
|
24
|
-
await
|
|
25
|
-
const
|
|
22
|
+
return await Promise.all(s), o;
|
|
23
|
+
}, O = async (t) => {
|
|
24
|
+
await F.whenOnce(() => t.ready);
|
|
25
|
+
const e = await I(t.map), { layers: s } = await U(e), o = {
|
|
26
26
|
schemaVersion: b,
|
|
27
27
|
modified: Date.now(),
|
|
28
28
|
embeddings: {
|
|
29
29
|
modelProvider: $,
|
|
30
30
|
model: w,
|
|
31
|
-
dimensions:
|
|
31
|
+
dimensions: S,
|
|
32
32
|
templates: {
|
|
33
|
-
layer:
|
|
34
|
-
field:
|
|
33
|
+
layer: f,
|
|
34
|
+
field: g
|
|
35
35
|
}
|
|
36
36
|
},
|
|
37
|
-
layers:
|
|
38
|
-
}, a =
|
|
37
|
+
layers: s
|
|
38
|
+
}, a = v.safeParse(o);
|
|
39
39
|
if (!a.success)
|
|
40
40
|
throw console.error("Schema Mismatch:", a.error.format()), new Error("Webmap embedding generation failed validation.");
|
|
41
41
|
return a.data;
|
|
42
|
-
}, U = async (
|
|
43
|
-
const
|
|
44
|
-
for (const [
|
|
45
|
-
const
|
|
46
|
-
name:
|
|
47
|
-
title:
|
|
48
|
-
description:
|
|
42
|
+
}, U = async (t) => {
|
|
43
|
+
const e = [], s = [];
|
|
44
|
+
for (const [r, { fieldRegistry: c, layerItem: n }] of t.entries()) {
|
|
45
|
+
const y = l(f, {
|
|
46
|
+
name: n.name,
|
|
47
|
+
title: n.title,
|
|
48
|
+
description: n.description
|
|
49
49
|
});
|
|
50
|
-
|
|
50
|
+
e.push(y);
|
|
51
51
|
const d = {
|
|
52
|
-
id:
|
|
53
|
-
name:
|
|
54
|
-
title:
|
|
55
|
-
description:
|
|
52
|
+
id: r,
|
|
53
|
+
name: n.name ?? "",
|
|
54
|
+
title: n.title,
|
|
55
|
+
description: n.description,
|
|
56
56
|
vector: [],
|
|
57
57
|
fields: []
|
|
58
58
|
};
|
|
59
|
-
for (const [,
|
|
60
|
-
const u = g
|
|
61
|
-
name:
|
|
62
|
-
alias:
|
|
63
|
-
description:
|
|
59
|
+
for (const [, i] of c.entries()) {
|
|
60
|
+
const u = l(g, {
|
|
61
|
+
name: i.name,
|
|
62
|
+
alias: i.alias,
|
|
63
|
+
description: i.description
|
|
64
64
|
});
|
|
65
|
-
|
|
66
|
-
name:
|
|
67
|
-
alias:
|
|
68
|
-
description:
|
|
65
|
+
e.push(u), d.fields.push({
|
|
66
|
+
name: i.name,
|
|
67
|
+
alias: i.alias,
|
|
68
|
+
description: i.description,
|
|
69
69
|
vector: []
|
|
70
70
|
});
|
|
71
71
|
}
|
|
72
|
-
|
|
72
|
+
s.push(d);
|
|
73
73
|
}
|
|
74
|
-
const
|
|
74
|
+
const o = await p(e);
|
|
75
75
|
let a = 0;
|
|
76
|
-
return { layers:
|
|
77
|
-
|
|
78
|
-
}),
|
|
79
|
-
},
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
const i = e[r], l = t[r];
|
|
85
|
-
n += i * l, s += i * i, a += l * l;
|
|
86
|
-
}
|
|
87
|
-
const m = Math.sqrt(s * a);
|
|
88
|
-
if (m === 0)
|
|
89
|
-
return 0;
|
|
90
|
-
const o = n / m;
|
|
91
|
-
return Math.max(-1, Math.min(1, o));
|
|
92
|
-
}, Q = L, Y = E, Z = P, ee = M, te = p, ae = V, se = F, ne = C, oe = N, re = z, ie = H, ce = O, me = () => T(), le = () => R(), de = async (e, t) => await x(e, t), ge = async (e = "default", t = 0) => await k(e, t);
|
|
76
|
+
return { layers: s.map((r) => (r.vector = o[a++], r.fields.forEach((c) => {
|
|
77
|
+
c.vector = o[a++];
|
|
78
|
+
}), r)) };
|
|
79
|
+
}, l = (t, e) => t.replace(/\{(\w+)\}/gu, (s, o) => e[o] ?? ""), J = P, Q = L, Y = E, Z = T, ee = p, te = M, ae = C, se = N, oe = z, re = H, ne = O, ie = () => R(), ce = () => k(), me = async (t, e) => await W(t, e), de = async ({
|
|
80
|
+
modelTier: t = "default",
|
|
81
|
+
temperature: e = 0,
|
|
82
|
+
abortSignal: s
|
|
83
|
+
} = {}) => await D({ modelTier: t, temperature: e, abortSignal: s });
|
|
93
84
|
export {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
Z as
|
|
109
|
-
|
|
110
|
-
de as sendUXSuggestion
|
|
85
|
+
re as ArcgisKnowledgeAgent,
|
|
86
|
+
se as DataExplorationAgent,
|
|
87
|
+
oe as HelpAgent,
|
|
88
|
+
ae as LayerStylingAgent,
|
|
89
|
+
te as NavigationAgent,
|
|
90
|
+
ge as Orchestrator,
|
|
91
|
+
ie as createAgentRuntimeState,
|
|
92
|
+
ce as createAgentRuntimeStateWithSharedState,
|
|
93
|
+
de as createChatModel,
|
|
94
|
+
ne as createWebmapEmbeddings,
|
|
95
|
+
ee as getEmbeddings,
|
|
96
|
+
Q as invokeStructuredPrompt,
|
|
97
|
+
J as invokeTextPrompt,
|
|
98
|
+
Y as invokeToolPrompt,
|
|
99
|
+
Z as sendTraceMessage,
|
|
100
|
+
me as sendUXSuggestion
|
|
111
101
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arcgis/ai-components",
|
|
3
|
-
"version": "5.2.0-next.
|
|
3
|
+
"version": "5.2.0-next.6",
|
|
4
4
|
"description": "ArcGIS AI Components",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -47,13 +47,13 @@
|
|
|
47
47
|
"marked": "~18.0.4",
|
|
48
48
|
"tslib": "^2.8.1",
|
|
49
49
|
"zod": "^4.3.6",
|
|
50
|
-
"@arcgis/
|
|
51
|
-
"@arcgis/
|
|
50
|
+
"@arcgis/toolkit": "5.2.0-next.6",
|
|
51
|
+
"@arcgis/lumina": "5.2.0-next.6"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
|
54
54
|
"@arcgis/core": "^5.1.0-next",
|
|
55
|
-
"@esri/calcite-components": "^5.1.
|
|
56
|
-
"@arcgis/map-components": "~5.2.0-next.
|
|
55
|
+
"@esri/calcite-components": "^5.1.1-next.3",
|
|
56
|
+
"@arcgis/map-components": "~5.2.0-next.6"
|
|
57
57
|
},
|
|
58
58
|
"css.customData": [
|
|
59
59
|
"dist/docs/vscode.css-custom-data.json"
|
package/dist/cdn/ON2V5XI2.js
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import{a as S,b as I}from"./7GH7VSB2.js";import{a as M}from"./H7422XUG.js";import"./MH5RPXHM.js";import a from"./GSEPHN3A.js";import{Fb as j,Q as q,W as F,a as P,b as D,eb as O,u as W}from"./462JBSEV.js";import{a as U}from"./AMP6IALT.js";import"./OAVEHGB6.js";import{g as C,h as g,l as R,n as h,t as b,u as v,v as L,w as f,y as A}from"./OH64RMOR.js";import"./YIMNOUTF.js";export default $arcgis.t(([Ie,{whenOnce:_e,watch:ke,when:$e},Ce,Y,ee,J,te,se,,,Re,{property:y,subclass:Le},{b:H,e:N,f:m,h:z,i:V,j:T}])=>{var re=async t=>{let e=await ie(),s=await H("default"),i=ee.getDefault(),r=(await Y.getCredential(`${i.url}/sharing`)).token,a={type:"generateEmbeddings",webmapEmbeddings:t,auth:{apiUrl:s,token:r}};return e.postMessage(a),await new Promise((n,c)=>{let o=l=>{l.data==="completed"&&(e.removeEventListener("message",o),n())},d=l=>{e.removeEventListener("message",o),c(l instanceof Error?l:new Error("Embeddings worker error"))};e.addEventListener("message",o),e.addEventListener("error",d,{once:!0})}),e},ie=async()=>{{let t=(await import("./23EQTPO3.js")).default;return new t}},ae=t=>{t.currentIntent="none"},ne=async(t,e)=>{if(t.agentExecutionContext.userRequest){let i=new F(t.agentExecutionContext.userRequest.trim());t.agentExecutionContext.messages=[...t.agentExecutionContext.messages,i],ae(t)}let s=e?.configurable?.services.agentRegistry.list().map(i=>i.agent.id)??[];return await m({text:`Available agents: ${[...s].join(", ")}`},e),await m({text:"Analyzing user input"},e),t},oe=async(t,e)=>(await m({text:"Exiting..."},e),t),B=t=>typeof t=="object"&&t!==null&&!Array.isArray(t),ce=(t,e)=>{if(!B(t)){t!==void 0&&console.warn(`Agent "${e}" returned invalid sharedStatePatch. Ignoring it.`);return}let s={};for(let[i,r]of Object.entries(t)){if(!B(r)||!("value"in r)){console.warn(`Agent "${e}" returned invalid sharedStatePatch entry for key "${i}". Ignoring that entry.`);continue}s[i]={value:r.value}}return s},de=t=>{let{previousSharedState:e,patch:s,agentId:i}=t;if(!s)return e;let r=Date.now(),a={...e};for(let[n,c]of Object.entries(s))c?.value!==void 0&&(a[n]={value:c.value,meta:{updatedByAgentId:i,updatedAt:r}});return a},G=t=>typeof t!="string"?void 0:t.trim()||void 0,le=t=>{switch(t){case"failed":return"Agent failed without a summary.";case"unknown":return"Agent returned with unknown status.";case"success":return"Agent completed without a summary.";default:return"Agent completed without a summary."}},ge=(t,e)=>{let s=G(e?.outputMessage),i=G(e?.summary),r=e?.status,a=r==="success"||r==="failed"?r:"unknown";a==="unknown"&&console.warn(`Agent "${t}" returned missing/invalid status. Defaulting to "unknown".`);let n=ce(e?.sharedStatePatch,t);return{outputMessage:s,summary:i??s??le(a),status:a,sharedStatePatch:n}},Q=4e3,he=async(t,e)=>{let s=e?.configurable,{agentRegistry:i}=s.services,r=i?.get(t.currentIntent);if(!r)return console.warn(`No agent found for intent: ${t.currentIntent}`),t;await m({text:`Executing registered agent: ${r.agent.name}`},e);let a={...e??{},configurable:{...s??{},agentId:r.agent.id,context:r.getContext?await r.getContext():void 0}},n;try{let d=await r.agent.createGraph().compile().invoke({agentExecutionContext:{...t.agentExecutionContext,messages:[...t.agentExecutionContext.messages],priorSteps:structuredClone(t.agentExecutionContext.priorSteps??[]),sharedState:structuredClone(t.agentExecutionContext.sharedState??{})}},a);n=ge(r.agent.name,d),await m({text:`Finished executing registered agent: ${r.agent.name}`},e)}catch(d){if(W(d))throw d;let l=d instanceof Error?d.message:String(d);console.error(`Agent "${r.agent.name}" failed:`,d),await m({text:`Registered agent failed: ${r.agent.name}. ${l}`},e),n={status:"failed",outputMessage:`Agent execution failed: ${l}`,summary:`Agent execution failed: ${l}`}}let c=n.outputMessage,o=[...t.agentExecutionContext.messages];if(c){let d=c.length>Q?`${c.slice(0,Q-14)}
|
|
3
|
-
[truncated]`:c;o.push(new q(d))}return{...t,stepCount:t.stepCount+1,lastExecutedAgent:r.agent.id,requiresFollowUp:n.status==="failed"?!0:t.requiresFollowUp,finalOutputMessage:c??"",agentExecutionContext:{...t.agentExecutionContext,messages:o,priorSteps:[...t.agentExecutionContext.priorSteps??[],{agentId:r.agent.id,assignedTask:t.agentExecutionContext.assignedTask,summary:n?.summary||"No summary provided.",status:n?.status||"unknown"}],sharedState:de({previousSharedState:t.agentExecutionContext.sharedState,patch:n.sharedStatePatch,agentId:r.agent.id})}}},ue=3,pe=()=>new j(N).addNode("ingestInput",ne).addNode("intentLLM",V).addNode("executeRegisteredAgent",he).addNode("exit",oe).addEdge(P,"ingestInput").addEdge("ingestInput","intentLLM").addConditionalEdges("intentLLM",t=>t.currentIntent==="none"||t.currentIntent===t.lastExecutedAgent?"exit":"executeRegisteredAgent").addConditionalEdges("executeRegisteredAgent",t=>t.stepCount>=ue||!t.requiresFollowUp?"exit":"intentLLM").addEdge("exit",D),_=class{constructor(){this.agentRegistry=new Map}register(e){let{agent:s}=e;if(this.agentRegistry.has(s.id))throw new Error(`Duplicate agent id: ${s.id}`);this.agentRegistry.set(s.id,e)}get(e){return this.agentRegistry.get(e)}list(){return[...this.agentRegistry.values()]}},k=class{constructor(e,s){this.graph=e,this.config={...s}}async waitForUser(){return await new Promise((e,s)=>{this.resolveWait=e,this.rejectWait=s})}handle(e,s){try{let i={agentId:e.agentId,id:e.id,payload:s},r=this.graph.streamEvents(null,{...this.config,configurable:{...this.config.configurable,hitlResponse:i},subgraphs:!0,version:"v2"});this.resolveWait?.(r)}catch(i){this.rejectWait?.(i)}finally{this.resolveWait=void 0,this.rejectWait=void 0}}cancel(){this.rejectWait&&(this.rejectWait(new Error("Request cancelled by user.")),this.resolveWait=void 0,this.rejectWait=void 0)}},me=async t=>{try{return await(await z()).embedDocuments(t)}catch(e){throw console.error("Failed to generate embeddings:",e),e}},K=async(t,e)=>{let s=e.get(t);if(s)return s;let i=await me([t]);return e.set(t,i[0]),i[0]};async function ye(t,e,s,i){let r=`req-${Date.now()}`,a={type:"layerSearch",precomputedEmbedding:i?await K(t,i):void 0,requestId:r,minScore:s};return await new Promise(n=>{let c=o=>{o.data.requestId===r&&n(o.data.results)};e.addEventListener("message",c,{once:!0}),e.postMessage(a)})}function we(t){let{worker:e}=t;return{async searchLayers({text:s,minScore:i,embeddingCache:r}){return await ye(s,e,i,r)}}}var fe=async({combinedQuery:t,layerIds:e,embeddingsWorker:s,minScore:i,topResults:r,embeddingCache:a})=>{let n=`req-${Date.now()}`,c=a?await K(t,a):void 0,o={type:"fieldSearch",layerIdForFieldsSearch:e,precomputedEmbedding:c,requestId:n,minScore:i,topResults:r};return await new Promise(d=>{let l=w=>{if(w.data.requestId!==n)return;let x=w.data.results.map(({layerId:Z,results:X})=>({layerId:Z,results:X}));d(x)};s.addEventListener("message",l,{once:!0}),s.postMessage(o)})};function be(t){let{worker:e}=t;return{async searchFields({text:s,layerIds:i,minScore:r,topResults:a,embeddingCache:n}){return await fe({combinedQuery:s,layerIds:i,embeddingsWorker:e,minScore:r,topResults:a,embeddingCache:n})}}}var ve=t=>{let e=T.safeParse(t);if(!e.success)throw new Error("Embeddings response validation failed. Regenerate embeddings.");return e.data},Ee=(t,e)=>{let s=new Map,i=new Map;if(e.allLayers.forEach(r=>{r instanceof te&&i.set(r.id,r)}),t.length!==i.size)throw new Error("Layer count mismatch during registry restoration. Regenerate embeddings.");for(let r of t){let a=i.get(r.id);if(!a)throw new Error(`Layer with ID ${r.id} not found in the original map during registry restoration. Regenerate embeddings.`);if(r.fields.length!==a.fields.length)throw new Error(`Field count mismatch for layer ID ${r.id} during registry restoration. Regenerate embeddings.`);let n={name:r.name,title:r.title,description:r.description},c=new Map;for(let o of r.fields){let d=a.fieldsIndex.get(o.name);if(!d)throw new Error(`Field with name ${o.name} not found in the original layer ${r.id} during registry restoration. Regenerate embeddings.`);c.set(o.name,{name:o.name,alias:a.getFieldAlias(o.name)??o.alias,description:o.description,type:d.type||"unknown",valueType:d.valueType||"unknown",domain:a.getFieldDomain(o.name)??void 0})}s.set(r.id,{layerItem:n,fieldRegistry:c})}return s},xe=async t=>{try{return(await se(t,{responseType:"json"})).data}catch(e){throw new Error(`Failed to fetch data from ${t}: ${String(e)}`)}},Se=async t=>{let e=t.map;if(!e?.portalItem)throw new Error("WebMap portal item is missing.");let{resources:s}=await e.portalItem.fetchResources(),i=s.find(a=>a.resource.path==="embeddings-v01.json");if(!i?.resource.url)throw new Error("Embeddings resource 'embeddings-v01.json' not found in the webmap portal item.");let r=await xe(i.resource.url);return ve(r)},E=class t{constructor(){this.orchestratorReady=!1,this.chatHistory=[],this.priorSteps=[],this.sharedState={},this.threadId="",this.agentRegistry=new _,this.streamEpoch=0}static async init(e){let s=new t;try{if(e.view?.map){await J.whenOnce(()=>e.view.ready);let i=await Se(e.view),r=Ee(i.layers,e.view.map);s.layersAndFieldsRegistry=r,s.embeddingsWorker=await re(i)}return e.agents?.forEach(i=>{s.agentRegistry.register(i)}),s.orchestratorReady=!0,s}catch(i){throw console.error("Orchestrator initialization failed:",i),i}}async*ask(e){if(!this.orchestratorReady)throw new Error("Orchestrator is not ready yet.");if(!this.agentRegistry.list().length)throw new Error("Orchestrator has no registered agents.");if(++this.streamEpoch,!e.trim())return;this.threadId=String(Date.now()),this.graph||(this.graph=pe().compile({checkpointer:new O}));let s=this.embeddingsWorker?we({worker:this.embeddingsWorker}):void 0,i=this.embeddingsWorker?be({worker:this.embeddingsWorker}):void 0,r=new Map,a={version:"v2",streamMode:"custom",configurable:{thread_id:this.threadId,hitlResponse:null,services:{layerSearch:s,fieldSearch:i,layersAndFieldsRegistry:this.layersAndFieldsRegistry,agentRegistry:this.agentRegistry,embeddingCache:r}},subgraphs:!0},n=this.graph?.streamEvents({agentExecutionContext:{userRequest:e,messages:this.chatHistory,priorSteps:this.priorSteps,sharedState:this.sharedState}},a),c=++this.streamEpoch;for(yield*this.pipeStream(n,c);;){let d=(await this.graph.getState(a,{subgraphs:!0})).tasks.find(l=>l.interrupts.length>0)?.interrupts[0]?.value;if(!d)break;this.currentInterrupt=d,this.interruptHandler=new k(this.graph,a),yield{runId:this.threadId,timestamp:Date.now(),type:"interrupt",interrupt:d};try{let l=await this.interruptHandler.waitForUser(),w=++this.streamEpoch;yield*this.pipeStream(l,w)}catch(l){if(l){yield{runId:this.threadId,timestamp:Date.now(),type:"error",error:{message:l?.message}};return}yield{runId:this.threadId,timestamp:Date.now(),type:"cancelled"};return}}let o=(await this.graph.getState(a,{subgraphs:!0})).values;this.chatHistory=o.agentExecutionContext.messages.length?o.agentExecutionContext.messages:this.chatHistory,this.priorSteps=o.agentExecutionContext.priorSteps?.slice(-5)??[],this.sharedState=o.agentExecutionContext.sharedState??{},yield{runId:this.threadId,timestamp:Date.now(),type:"completed",result:{content:o.finalOutputMessage}}}newConversation(){this.chatHistory=[],this.priorSteps=[],this.sharedState={}}resumeInterrupt(e){if(!this.currentInterrupt||!this.interruptHandler)throw new Error("No pending interrupt to resume.");this.interruptHandler.handle(this.currentInterrupt,e)}cancelInterrupt(){this.interruptHandler&&this.interruptHandler.cancel()}async*pipeStream(e,s){for await(let i of e){if(s!==this.streamEpoch){console.log("Stale stream detected, aborting.");break}i.event==="on_custom_event"&&i.name==="trace_message"?yield{runId:this.threadId,timestamp:Date.now(),type:"trace",data:i.data}:i.name==="graph_ux_suggestion"&&(yield{runId:this.threadId,timestamp:Date.now(),type:"ux-suggestion",suggestion:i.data})}}dispose(){this.embeddingsWorker&&(this.embeddingsWorker.terminate(),this.embeddingsWorker=void 0),this.orchestratorReady=!1}};var Ae=C`:host{display:block;width:var(--arcgis-internal-panel-width, 100%);height:var(--arcgis-internal-expand-max-height, 100%)}.footer-container{display:flex;flex-direction:column;flex:1 1 0;gap:var(--calcite-spacing-md)}.content-container{display:flex;flex-direction:column;flex:1 1 0;min-height:0;position:relative;overflow:auto}.suggested-prompts-container{display:flex;justify-content:center;width:100%}.suggested-prompts{display:block;padding:var(--calcite-spacing-md);max-width:100%;box-sizing:border-box}.error-notice{padding:var(--calcite-spacing-sm)}`,Me=Object.defineProperty,Pe=Object.getOwnPropertyDescriptor,p=(t,e,s,i)=>{for(var r=i>1?void 0:i?Pe(e,s):e,a=t.length-1,n;a>=0;a--)(n=t[a])&&(r=(i?n(e,s,r):n(r))||r);return i&&r&&Me(e,s,r),r},u=class extends Re{constructor(t){super(t),this.view=null,this.loading=!1,this.processing=!1,this.processingStep=""}async load(){this._set("loading",!0);try{await this._initialize()}finally{this._set("loading",!1)}}destroy(){this.orchestrator?.dispose(),super.destroy()}async _initialize(){this.removeHandles(),await Promise.all([this.portal.load(),this.view?.when()]),this.view&&await _e(()=>!this.view.updating),this._set("orchestrator",await E.init({agents:[...this.agents],view:this.view??void 0})),this.addHandles([ke(()=>[this.view,this.agents],()=>{this._initialize()})])}clearChatHistory(){this.orchestrator?.newConversation()}async*ask(t,e){if(!this.orchestrator)throw new Error("Orchestrator not initialized yet.");this._set("processing",!0),this._set("processingStep","");let s=[],i;try{let r=this.orchestrator.ask(t);for await(let a of r){let n=a.runId;if(e?.aborted){yield{type:"cancelled",runId:n};break}switch(a.type){case"trace":{this._set("processingStep",a.data.text),s.push(a.data.text);break}case"completed":{let c=a.result,o=!!c.content.length,d=!!i?.length;if(!o&&!d){yield{type:"completed",error:"Could not process the request.",log:s,runId:n};return}let l=c.content;this._set("processingStep",""),yield{type:"completed",response:l,blocks:i,log:s,runId:n};return}case"ux-suggestion":{let c=a.suggestion;i=i?[...i,c]:[c];break}case"interrupt":{let{kind:c,message:o,metadata:d}=a.interrupt,l=Array.isArray(d)?d.filter(x=>typeof x=="string"):[],w=(()=>{switch(c){case"booleanChoice":return{type:"boolean-choice",message:o,options:l};case"singleSelection":return{type:"single-select",message:o,options:l};case"multipleSelection":return{type:"multi-select",message:o,options:l};case"textInput":return{type:"text-input",message:o};default:return{type:c,message:o,options:l}}})();this._set("processingStep","Waiting for user input..."),yield{type:"interrupt",payload:w,runId:n};break}case"cancelled":{yield{type:"cancelled",runId:n};return}case"error":{yield{type:"completed",error:a.error.message,log:s,runId:n};return}default:{console.warn("Unknown event type:",a);break}}}}catch(r){console.warn("Error during message processing:",r),yield{type:"completed",error:"An error occurred during message processing.",log:s,runId:"error"};return}finally{this._set("processing",!1)}}};p([y({readOnly:!0})],u.prototype,"orchestrator",2);p([y()],u.prototype,"agents",2);p([y()],u.prototype,"portal",2);p([y()],u.prototype,"view",2);p([y({readOnly:!0})],u.prototype,"loading",2);p([y({readOnly:!0})],u.prototype,"processing",2);p([y({readOnly:!0})],u.prototype,"processingStep",2);u=p([Le("OrchestratorController")],u);var De="Embeddings resource 'embeddings-v01.json' not found in the webmap portal item.",We="Embeddings not found for this web map.",qe="https://developers.arcgis.com/javascript/latest/agentic-apps/ai-webmap-setup/#embeddings",$=class extends L{constructor(){super(...arguments),this._messages=M({blocking:!0}),this.#e=b(),this.#n=b(),this.#t=b(),this.#s=null,this.#o=new Map,this.#r=Ce.getDefault(),this.#i=e=>{e.stopPropagation(),this.cancelInterrupt()},this.#a=e=>{e.stopPropagation();let s=e.detail;this.submitInterrupt(s)},this.#c=e=>{e.stopPropagation(),this.keepSuggestedPrompts||(this.suggestedPrompts=[]);let s=e.detail;this._inputValue="",this.arcgisSubmit.emit(s),this.submitMessage(s)},this.#d=e=>{if(e.stopPropagation(),this.arcgisCancel.emit(),this._interrupt){this.orchestrator?.cancelInterrupt(),this._interrupt=null;return}this.#s?.abort()},this.#l=e=>{e.stopPropagation();let s=e.detail;this.arcgisFeedback.emit(s)},this.#g=e=>{e.stopPropagation();let s=e.detail;this._inputValue=s.prompt,this.arcgisPromptSelect.emit(s)},this.#h=e=>{this.arcgisSlottableRequest.emit(e.detail)},this._orchestratorController=null,this._interrupt=null,this._error=null,this._inputValue="",this.messages=new Ie([]),this.referenceElement=null,this.suggestedPrompts=[],this.feedbackEnabled=!1,this.keepSuggestedPrompts=!1,this.logEnabled=!1,this.copyEnabled=!1,this.voiceInputEnabled=!1,this.readAloudEnabled=!1,this.arcgisCancel=h(),this.arcgisError=h(),this.arcgisFeedback=h(),this.arcgisInterrupt=h(),this.arcgisInterruptCancel=h(),this.arcgisInterruptSubmit=h(),this.arcgisPromptSelect=h(),this.arcgisReady=h(),this.arcgisSubmit=h(),this.arcgisSlottableRequest=h({bubbles:!1,composed:!1})}static{this.properties={_orchestratorController:16,_interrupt:16,_error:16,_inputValue:16,_user:16,awaitingResponse:32,awaitingResponseStep:32,interrupt:32,messages:0,orchestrator:32,entryMessage:1,heading:1,description:1,referenceElement:1,suggestedPrompts:0,feedbackEnabled:5,keepSuggestedPrompts:5,logEnabled:5,copyEnabled:5,voiceInputEnabled:5,readAloudEnabled:5}}static{this.styles=Ae}#e;#n;#t;#s;#o;#r;#i;#a;#c;#d;#l;#g;#h;async#u(){try{let e=U(this.el,this.referenceElement);await e?.componentOnReady();let s=[...this.#o.values()];return s.length?(this._orchestratorController=new u({agents:s,portal:this.#r,view:e?.view}),await this._orchestratorController.load(),!0):(this._error="No agents found.",!1)}catch(e){return this._error=e?.message??"Error initializing orchestrator.",R(this)(e),!1}}get _user(){return this.#r?.user?.fullName||this.#r?.user?.username}get awaitingResponse(){return this._orchestratorController?.processing??!1}get awaitingResponseStep(){return this._orchestratorController?.processingStep??""}get interrupt(){return this._interrupt}get orchestrator(){return this._orchestratorController?.orchestrator}async clearChatHistory(){this._reset(),this._orchestratorController?.clearChatHistory()}cancelInterrupt(){this.arcgisInterruptCancel.emit(),this.orchestrator?.cancelInterrupt(),this._interrupt=null}register(e){this.#o.set(e.agent.id,e)}async submitMessage(e){let s=e.trim();if(!s||(this.messages.push({id:Date.now().toString(),role:"user",content:s}),!this._orchestratorController))return;let i=this._orchestratorController.ask(s,this.#s?.signal);for await(let r of i){let a=r.runId;switch(r.type){case"completed":this.messages.push({role:"assistant",content:r.response,blocks:r.blocks,log:r.log,error:r.error,id:a});break;case"interrupt":this._interrupt={...r.payload,id:a},this.arcgisInterrupt.emit(this._interrupt);break;case"cancelled":this.messages.push({role:"assistant",error:"Request cancelled.",id:a});break}}}submitInterrupt(e){this.arcgisInterruptSubmit.emit(e),this.orchestrator?.resumeInterrupt(e),this._interrupt=null}load(){this.manager.onLifecycle(this._reset.bind(this))}loaded(){this.manager.onLifecycle(()=>{this.#e.value?.addEventListener("arcgisPromptSelect",this.#g),this.#e.value?.addEventListener("arcgisSubmit",this.#c),this.#e.value?.addEventListener("arcgisCancel",this.#d),this.#e.value?.addEventListener("arcgisFeedback",this.#l);let e=$e(()=>!!this._interrupt&&!!this.#t.value,()=>{let s=this.#t.value;s.removeEventListener("arcgisSubmit",this.#a),s.removeEventListener("arcgisCancel",this.#i),s.addEventListener("arcgisSubmit",this.#a,{once:!0}),s.addEventListener("arcgisCancel",this.#i,{once:!0})});return queueMicrotask(()=>{this.#u().then(s=>{s?this.arcgisReady.emit():this._error&&this.arcgisError.emit(new Error(this._error))})}),()=>{e.remove(),this.#e.value?.removeEventListener("arcgisPromptSelect",this.#g),this.#t.value?.removeEventListener("arcgisSubmit",this.#a),this.#t.value?.removeEventListener("arcgisCancel",this.#i),this.#e.value?.removeEventListener("arcgisSubmit",this.#c),this.#e.value?.removeEventListener("arcgisCancel",this.#d),this.#e.value?.removeEventListener("arcgisFeedback",this.#l),this._orchestratorController?.destroy(),this._orchestratorController=null}})}_reset(){this.#s?.abort(),this._interrupt=null,this.messages.removeAll(),this._error=null,this._inputValue=""}_renderEntryMessage(){return this._interrupt?g`<slot name=interrupt><arcgis-assistant-interrupt .type=${this._interrupt.type} .message=${this._interrupt.message} .options=${this._interrupt.options} ${v(this.#t)}></arcgis-assistant-interrupt></slot>`:this._error?this._renderErrorNotice():this.entryMessage?this.messages.length>0?null:g`<calcite-notice open kind=info closable icon width=full><div slot=message>${this.entryMessage}</div></calcite-notice>`:g`<slot name=entry-message></slot>`}_renderErrorNotice(){return this._error?g`<calcite-notice closable slot=entry-message open kind=danger icon width=full>${this._error===De?g`<div slot=message>${We}</div><calcite-link slot=link .href=${qe} target=_blank title="Learn about web map embeddings">Read more</calcite-link>`:g`<div slot=message>${this._error}</div>`}</calcite-notice>`:null}_renderSuggestedPrompts(){return this.suggestedPrompts?.length?g`<div class="suggested-prompts-container"><arcgis-assistant-suggested-prompts class="suggested-prompts" .prompts=${this.suggestedPrompts}></arcgis-assistant-suggested-prompts></div>`:null}render(){return g`<calcite-panel .loading=${!this._orchestratorController&&!this._error||this._orchestratorController?.loading} .heading=${this.heading??this._messages.assistantLabel} .description=${this.description} ${v(this.#e)}><slot name=header-actions-start slot=header-actions-start></slot><slot name=header-actions-end slot=header-actions-end></slot><div class="content-container"><arcgis-assistant-chat .loading=${this.awaitingResponse} .messages=${this.messages}><slot name=message-starter slot=message-starter></slot><slot name=messages slot=messages>${this.messages.map(e=>e.role==="assistant"?g`<arcgis-assistant-message .message=${e} .feedbackEnabled=${this.feedbackEnabled} .logEnabled=${this.logEnabled} .copyEnabled=${this.copyEnabled} .readAloudEnabled=${this.readAloudEnabled} @arcgisSlottableRequest=${this.#h}><slot name=${S(e.id)??f} slot=${S(e.id)??f}>${e?.error?g`<calcite-notice class="error-notice" open icon kind=warning width=full><div slot=message>${e.error}</div></calcite-notice>`:g`<arcgis-assistant-message-text .content=${e?.content}></arcgis-assistant-message-text>`}</slot>${e.blocks?.map((s,i)=>g`<slot name=${I(e.id,i)??f} slot=${I(e.id,i)??f}><arcgis-assistant-message-block .block=${s}></arcgis-assistant-message-block></slot>`)}</arcgis-assistant-message>`:g`<arcgis-assistant-user-message .message=${e} .user=${this._user}></arcgis-assistant-user-message>`)}</slot><slot name=message-loading slot=message-loading><arcgis-assistant-message-loading .loading=${this.awaitingResponse} .loadingMessage=${this.awaitingResponseStep}></arcgis-assistant-message-loading></slot></arcgis-assistant-chat></div>${this._renderSuggestedPrompts()}<div class="footer-container" slot=footer>${this._renderEntryMessage()}<slot name=chat-entry><arcgis-assistant-chat-entry .awaitingResponse=${this.awaitingResponse} .inputValue=${this._inputValue} .messages=${this.messages} .voiceInputEnabled=${this.voiceInputEnabled} ${v(this.#n)}><slot name=entry-actions-start slot=entry-actions-start></slot><slot name=entry-actions-end slot=entry-actions-end><calcite-button .iconStart=${this.awaitingResponse?"circle-stop":"send"} @click=${()=>{this.#n.value?.submitMessage()}} round>${this.awaitingResponse?this._messages.stopButtonLabel:this._messages.askButtonLabel}</calcite-button></slot></arcgis-assistant-chat-entry></slot><slot name=footer-content></slot></div></calcite-panel>`}};A("arcgis-assistant",$);return $},"core/Collection","core/reactiveUtils","portal/Portal","identity/IdentityManager","portal/Portal","core/reactiveUtils","layers/FeatureLayer","request","identity/IdentityManager","layers/FeatureLayer","core/Accessor","core/accessorSupport/decorators",a)
|