@arcgis/ai-components 5.1.0-next.126 → 5.1.0-next.128

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.
@@ -7,10 +7,14 @@ import type { StructuredToolInterface } from "@langchain/core/tools";
7
7
  import type { AnnotationRoot, BaseChannel, StateGraph } from "@langchain/langgraph/web";
8
8
  import type { ChatOpenAI } from "@langchain/openai";
9
9
  import type { ZodType } from "zod";
10
+ import type { AgentRegistration as AgentRegistration2 } from "../orchestrator/registry/agentRegistry.js";
10
11
 
11
12
  export { type CustomConfigurableType } from "../orchestrator";
12
13
  export { Orchestrator } from "../orchestrator";
13
14
 
15
+ /** @internal */
16
+ export type ChatModelTier = "advanced" | "default" | "fast";
17
+
14
18
  /**
15
19
  * Represents the chat message history between the user and the assistant, including all messages sent and received during the conversation.
16
20
  * This structure is used to provide context for the assistant's responses and can be utilized when invoking prompts to ensure the model
@@ -309,10 +313,21 @@ export function sendTraceMessage(data: TraceEventData, config?: RunnableConfig):
309
313
  */
310
314
  export function getEmbeddings(inputs: string[]): Promise<number[][]>;
311
315
 
316
+ /**
317
+ * Calculates the cosine similarity between two numeric vectors. This is used to measure the similarity
318
+ * between two embedding vectors, where a score of 1 indicates identical vectors, 0 indicates orthogonal
319
+ * vectors, and -1 indicates opposite vectors.
320
+ *
321
+ * @param vectorA - The first vector array.
322
+ * @param vectorB - The second vector array.
323
+ * @returns A similarity score from -1 (opposite) to 1 (identical).
324
+ */
325
+ export function cosineSimilarity(vectorA: number[], vectorB: number[]): number;
326
+
312
327
  /**
313
328
  * The suggestions emitted by the agent to the user interface.
314
329
  *
315
- * @internal
330
+ * @since 5.1
316
331
  */
317
332
  export type UXSuggestion = {
318
333
  /** The type of suggestion being made. */
@@ -324,32 +339,41 @@ export type UXSuggestion = {
324
339
  /**
325
340
  * Execution status returned by an agent run.
326
341
  *
327
- * @internal
342
+ * @since 5.1
328
343
  */
329
344
  export type AgentStatus = "failed" | "success" | "unknown";
330
345
 
331
346
  /**
332
347
  * Summary of a previously executed agent step.
333
348
  *
334
- * @internal
349
+ * @since 5.1
335
350
  */
336
351
  export interface PriorStep {
352
+ /** The agent that handled the step. */
337
353
  agentId: string;
354
+ /** The task assigned to the agent for this step. */
338
355
  assignedTask: string;
356
+ /** A brief summary of the step's execution. */
339
357
  summary: string;
358
+ /** The execution status of the step. */
340
359
  status: AgentStatus;
341
360
  }
342
361
 
343
362
  /**
344
363
  * Runtime execution context available to agent graph nodes and tools.
345
364
  *
346
- * @internal
365
+ * @since 5.1
347
366
  */
348
367
  export interface AgentExecutionContext<TState extends Record<string, unknown> = Record<string, unknown>> {
368
+ /** The user's original request. */
349
369
  userRequest: string;
370
+ /** The task assigned to the agent. */
350
371
  assignedTask: string;
372
+ /** The message history for the run */
351
373
  messages: ChatHistory;
374
+ /** Previous steps */
352
375
  priorSteps: PriorStep[];
376
+ /** Shared state available to the agent. */
353
377
  sharedState: SharedState<TState>;
354
378
  }
355
379
 
@@ -381,7 +405,7 @@ export type DataExplorationContext = {
381
405
  export const HelpAgent: AgentRegistration;
382
406
 
383
407
  /** @internal */
384
- export const ArcgisKnowledgeAgent: AgentRegistration;
408
+ export const ArcgisKnowledgeAgent: AgentRegistration2;
385
409
 
386
410
  /** @internal */
387
411
  export type ArcgisKnowledgeContext = {
@@ -420,6 +444,9 @@ export const createWebmapEmbeddings: (mapView: MapView) => Promise<{
420
444
  }>;
421
445
  }>;
422
446
 
447
+ /** @internal */
448
+ export type GetContext<TContext extends Record<string, unknown>> = () => Promise<TContext> | TContext;
449
+
423
450
  /** @internal */
424
451
  export interface AgentWithContext<TContext extends Record<string, unknown> = Record<string, unknown>> {
425
452
  agent: AgentRegistration;
@@ -431,37 +458,9 @@ export interface AgentWithContext<TContext extends Record<string, unknown> = Rec
431
458
  }
432
459
 
433
460
  /** @internal */
434
- export function createAgentRuntimeState<TState extends Record<string, unknown> = Record<string, unknown>>(): StatelessAgentBaseState<TState>;
435
-
436
- /** @internal */
437
- export function createAgentRuntimeStateWithSharedState<TState extends Record<string, unknown> = Record<string, unknown>>(): StatefulAgentBaseState<TState>;
438
-
439
- /**
440
- * @param suggestion
441
- * @param config
442
- * @internal
443
- */
444
- export function sendUXSuggestion(suggestion: UXSuggestion, config?: RunnableConfig): Promise<void>;
461
+ export type AgentExecutionContextWithSharedState<TState extends Record<string, unknown> = Record<string, unknown>> = AgentExecutionContext<TState>;
445
462
 
446
463
  /** @internal */
447
- export type SharedStatePatch<T extends Record<string, unknown> = Record<string, unknown>> = {
448
- [K in keyof T]?: SharedStatePatchEntry<T[K]>;
449
- };
450
-
451
- /**
452
- * @param parameter0
453
- * @internal
454
- */
455
- export function createChatModel(parameter0?: {
456
- modelTier?: ChatModelTier;
457
- temperature?: number;
458
- abortSignal?: AbortSignal;
459
- }): Promise<ChatOpenAI>;
460
-
461
- export type ChatModelTier = "advanced" | "default" | "fast";
462
-
463
- export type GetContext<TContext extends Record<string, unknown>> = () => Promise<TContext> | TContext;
464
-
465
464
  export type StatelessAgentBaseState<TState extends Record<string, unknown> = Record<string, unknown>> = {
466
465
  agentExecutionContext: BaseChannel<AgentExecutionContextWithSharedState<TState>, unknown, unknown>;
467
466
  outputMessage: BaseChannel<string, unknown, unknown>;
@@ -469,27 +468,76 @@ export type StatelessAgentBaseState<TState extends Record<string, unknown> = Rec
469
468
  status: BaseChannel<AgentStatus | undefined, unknown, unknown>;
470
469
  };
471
470
 
471
+ /** @internal */
472
472
  export type StatefulAgentBaseState<TState extends Record<string, unknown> = Record<string, unknown>> = StatelessAgentBaseState<TState>
473
473
  & {
474
474
  sharedStatePatch: BaseChannel<SharedStatePatch<TState> | undefined, unknown, unknown>;
475
475
  };
476
476
 
477
- /** Patch shape returned by agents. `meta` is intentionally omitted. */
478
- export type SharedStatePatchEntry<T = unknown> = {
479
- value: T;
480
- };
477
+ /**
478
+ * Creates the standard runtime state for a custom agent graph.
479
+ * Includes common fields used by the assistant flow (request context, output message, summary, and status), so you only add your agent-specific state.
480
+ *
481
+ * @since 5.1
482
+ */
483
+ export function createAgentRuntimeState<TState extends Record<string, unknown> = Record<string, unknown>>(): StatelessAgentBaseState<TState>;
481
484
 
482
- export type SharedState<T extends Record<string, unknown> = Record<string, unknown>> = {
483
- [K in keyof T]?: SharedStateEntry<T[K]>;
484
- };
485
+ /**
486
+ * Creates the standard runtime state for a custom agent graph, plus support for shared state updates.
487
+ * Use this when your agent needs to write values that other agents can read later in the same orchestration flow.
488
+ *
489
+ * @since 5.1
490
+ */
491
+ export function createAgentRuntimeStateWithSharedState<TState extends Record<string, unknown> = Record<string, unknown>>(): StatefulAgentBaseState<TState>;
485
492
 
486
- export type AgentExecutionContextWithSharedState<TState extends Record<string, unknown> = Record<string, unknown>> = AgentExecutionContext<TState>;
493
+ /**
494
+ * Sends an optional UX suggestion from an agent run to the host application.
495
+ * Use this for non-blocking hints (for example, recommended next actions or UI prompts) that the app may choose to display.
496
+ *
497
+ * @param suggestion
498
+ * @param config
499
+ * @since 5.1
500
+ */
501
+ export function sendUXSuggestion(suggestion: UXSuggestion, config?: RunnableConfig): Promise<void>;
487
502
 
488
- /** Stored shared state entry. `meta` is added by the orchestrator. */
503
+ /** @internal */
489
504
  export type SharedStateEntry<T = unknown> = {
490
505
  value: T;
491
506
  meta: {
492
507
  updatedByAgentId: string;
493
508
  updatedAt: number;
494
509
  };
495
- };
510
+ };
511
+
512
+ /** @internal */
513
+ export type SharedStatePatchEntry<T = unknown> = {
514
+ value: T;
515
+ };
516
+
517
+ /**
518
+ * Shared state that can be read and updated during agent execution.
519
+ *
520
+ * @since 5.1
521
+ */
522
+ export type SharedState<T extends Record<string, unknown> = Record<string, unknown>> = {
523
+ [K in keyof T]?: SharedStateEntry<T[K]>;
524
+ };
525
+
526
+ /**
527
+ * Partial shared state returned by an agent for merging into the current run state.
528
+ *
529
+ * @since 5.1
530
+ */
531
+ export type SharedStatePatch<T extends Record<string, unknown> = Record<string, unknown>> = {
532
+ [K in keyof T]?: SharedStatePatchEntry<T[K]>;
533
+ };
534
+
535
+ /**
536
+ * @param parameter0
537
+ * @internal
538
+ */
539
+ export function createChatModel(parameter0?: {
540
+ modelTier?: ChatModelTier;
541
+ temperature?: number;
542
+ abortSignal?: AbortSignal;
543
+ }): Promise<ChatOpenAI>;
@@ -1,101 +1,115 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
2
  import { g as p } from "../chunks/orchestrator.js";
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";
3
+ import { O as ye } from "../chunks/orchestrator.js";
4
+ import { g as h, a as A, W as S, f, l as y, d as v, m as w, b as $, e as b, i as E, h as L, j as P, s as M, k as T, n as R, c as k, o as x } from "../chunks/generateLayerDescriptions.js";
5
+ import D from "@arcgis/core/layers/FeatureLayer.js";
6
+ import * as W from "@arcgis/core/core/reactiveUtils.js";
7
+ import { N as F } 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 (t) => {
13
- const e = t.allLayers.toArray(), s = [], o = /* @__PURE__ */ new Map();
14
- for (const a of e)
15
- if (a instanceof x) {
12
+ const I = async (e) => {
13
+ const t = e.allLayers.toArray(), s = [], n = /* @__PURE__ */ new Map();
14
+ for (const a of t)
15
+ if (a instanceof D) {
16
16
  const m = (async () => {
17
- const r = await A(a), c = await h(a, r);
18
- o.set(a.id, { layerItem: c, fieldRegistry: r });
17
+ const o = await h(a), r = await A(a, o);
18
+ n.set(a.id, { layerItem: r, fieldRegistry: o });
19
19
  })();
20
20
  s.push(m);
21
21
  }
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 = {
22
+ return await Promise.all(s), n;
23
+ }, O = async (e) => {
24
+ await W.whenOnce(() => e.ready);
25
+ const t = await I(e.map), { layers: s } = await U(t), n = {
26
26
  schemaVersion: b,
27
27
  modified: Date.now(),
28
28
  embeddings: {
29
29
  modelProvider: $,
30
30
  model: w,
31
- dimensions: S,
31
+ dimensions: v,
32
32
  templates: {
33
- layer: f,
34
- field: g
33
+ layer: y,
34
+ field: f
35
35
  }
36
36
  },
37
37
  layers: s
38
- }, a = v.safeParse(o);
38
+ }, a = S.safeParse(n);
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 (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
42
+ }, U = async (e) => {
43
+ const t = [], s = [];
44
+ for (const [o, { fieldRegistry: r, layerItem: i }] of e.entries()) {
45
+ const l = g(y, {
46
+ name: i.name,
47
+ title: i.title,
48
+ description: i.description
49
49
  });
50
- e.push(y);
50
+ t.push(l);
51
51
  const d = {
52
- id: r,
53
- name: n.name ?? "",
54
- title: n.title,
55
- description: n.description,
52
+ id: o,
53
+ name: i.name ?? "",
54
+ title: i.title,
55
+ description: i.description,
56
56
  vector: [],
57
57
  fields: []
58
58
  };
59
- for (const [, i] of c.entries()) {
60
- const u = l(g, {
61
- name: i.name,
62
- alias: i.alias,
63
- description: i.description
59
+ for (const [, c] of r.entries()) {
60
+ const u = g(f, {
61
+ name: c.name,
62
+ alias: c.alias,
63
+ description: c.description
64
64
  });
65
- e.push(u), d.fields.push({
66
- name: i.name,
67
- alias: i.alias,
68
- description: i.description,
65
+ t.push(u), d.fields.push({
66
+ name: c.name,
67
+ alias: c.alias,
68
+ description: c.description,
69
69
  vector: []
70
70
  });
71
71
  }
72
72
  s.push(d);
73
73
  }
74
- const o = await p(e);
74
+ const n = await p(t);
75
75
  let a = 0;
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,
76
+ return { layers: s.map((o) => (o.vector = n[a++], o.fields.forEach((r) => {
77
+ r.vector = n[a++];
78
+ }), o)) };
79
+ }, g = (e, t) => e.replace(/\{(\w+)\}/gu, (s, n) => t[n] ?? ""), V = (e, t) => {
80
+ if (e.length !== t.length)
81
+ throw new Error("Vectors must be the same length");
82
+ let s = 0, n = 0, a = 0;
83
+ for (let r = 0; r < e.length; ++r) {
84
+ const i = e[r], l = t[r];
85
+ s += i * l, n += i * i, a += l * l;
86
+ }
87
+ const m = Math.sqrt(n * a);
88
+ if (m === 0)
89
+ return 0;
90
+ const o = s / 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 ({
93
+ modelTier: e = "default",
94
+ temperature: t = 0,
82
95
  abortSignal: s
83
- } = {}) => await D({ modelTier: t, temperature: e, abortSignal: s });
96
+ } = {}) => await k({ modelTier: e, temperature: t, abortSignal: s });
84
97
  export {
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
98
+ ie as ArcgisKnowledgeAgent,
99
+ oe as DataExplorationAgent,
100
+ re as HelpAgent,
101
+ ne as LayerStylingAgent,
102
+ se as NavigationAgent,
103
+ ye as Orchestrator,
104
+ ae as cosineSimilarity,
105
+ me as createAgentRuntimeState,
106
+ le as createAgentRuntimeStateWithSharedState,
107
+ ge as createChatModel,
108
+ ce as createWebmapEmbeddings,
109
+ te as getEmbeddings,
110
+ Y as invokeStructuredPrompt,
111
+ Q as invokeTextPrompt,
112
+ Z as invokeToolPrompt,
113
+ ee as sendTraceMessage,
114
+ de as sendUXSuggestion
101
115
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcgis/ai-components",
3
- "version": "5.1.0-next.126",
3
+ "version": "5.1.0-next.128",
4
4
  "description": "ArcGIS AI Components",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -44,16 +44,16 @@
44
44
  "@langchain/openai": "^1.4.3",
45
45
  "langchain": "^1.3.1",
46
46
  "lit": "^3.3.0",
47
- "marked": "~18.0.4",
47
+ "marked": "~18.0.5",
48
48
  "tslib": "^2.8.1",
49
49
  "zod": "^4.3.6",
50
- "@arcgis/lumina": "5.1.0-next.126",
51
- "@arcgis/toolkit": "5.1.0-next.126"
50
+ "@arcgis/lumina": "5.1.0-next.128",
51
+ "@arcgis/toolkit": "5.1.0-next.128"
52
52
  },
53
53
  "peerDependencies": {
54
54
  "@arcgis/core": "^5.1.0-next",
55
55
  "@esri/calcite-components": "^5.1.1-next.3",
56
- "@arcgis/map-components": "~5.1.0-next.126"
56
+ "@arcgis/map-components": "~5.1.0-next.128"
57
57
  },
58
58
  "css.customData": [
59
59
  "dist/docs/vscode.css-custom-data.json"