@arcgis/ai-components 5.2.0-next.3 → 5.2.0-next.30

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.
Files changed (207) hide show
  1. package/dist/agent-utils/FunctionAgent.d.ts +2 -2
  2. package/dist/agent-utils/LLMAgent.d.ts +2 -2
  3. package/dist/agent-utils/LLMAgent.js +23 -22
  4. package/dist/agent-utils/WorkflowAgent.d.ts +2 -2
  5. package/dist/agent-utils/index.d.ts +177 -0
  6. package/dist/agent-utils/index.js +167 -0
  7. package/dist/agent-utils/middlewares/trace.d.ts +2 -0
  8. package/dist/agent-utils/middlewares/trace.js +25 -33
  9. package/dist/agent-utils/tools/FunctionTool.d.ts +2 -2
  10. package/dist/agent-utils/types.d.ts +36 -7
  11. package/dist/agent-utils/workflows/ConditionalWorkflow.d.ts +2 -2
  12. package/dist/agent-utils/workflows/LoopWorkflow.d.ts +2 -2
  13. package/dist/agent-utils/workflows/ParallelWorkflow.d.ts +2 -2
  14. package/dist/agent-utils/workflows/RouterWorkflow.d.ts +2 -2
  15. package/dist/agent-utils/workflows/SequentialWorkflow.d.ts +2 -2
  16. package/dist/agent-utils/workflows/SwitchWorkflow.d.ts +2 -2
  17. package/dist/cdn/27NEUQN3.js +2 -0
  18. package/dist/cdn/2NMR43NW.js +2 -0
  19. package/dist/cdn/3AXQTBIA.js +134 -0
  20. package/dist/cdn/434TAA3J.js +2 -0
  21. package/dist/cdn/4I4MCV7V.js +71 -0
  22. package/dist/cdn/4RZPOYZ7.js +9 -0
  23. package/dist/cdn/5SBLS4NW.js +2 -0
  24. package/dist/cdn/{AMP6IALT.js → 5W7S2RS4.js} +1 -1
  25. package/dist/cdn/6LZ6GOHF.js +56 -0
  26. package/dist/cdn/7IFCBXV7.js +2 -0
  27. package/dist/cdn/ADYIXCSG.js +2 -0
  28. package/dist/cdn/AFLQZIKS.js +180 -0
  29. package/dist/cdn/AMVOJNWN.js +2 -0
  30. package/dist/cdn/C7E7MJSR.js +2 -0
  31. package/dist/cdn/CAECQD75.js +2 -0
  32. package/dist/cdn/CIW3QMKV.js +2 -0
  33. package/dist/cdn/CJIV4KJZ.js +179 -0
  34. package/dist/cdn/CVHJMR5X.js +2 -0
  35. package/dist/cdn/DEAYZ3MK.js +2 -0
  36. package/dist/cdn/{H7422XUG.js → E2HENO3T.js} +1 -1
  37. package/dist/cdn/E7TMP4YV.js +3 -0
  38. package/dist/cdn/EBRNMPPO.js +48 -0
  39. package/dist/cdn/FWU6DFIB.js +2 -0
  40. package/dist/cdn/HBYZSLEZ.js +22 -0
  41. package/dist/cdn/HOCTVCHH.js +2 -0
  42. package/dist/cdn/{4HU7735A.js → HXOSLGWU.js} +6 -4
  43. package/dist/cdn/I64KIZG3.js +2 -0
  44. package/dist/cdn/IB4WTK74.js +2 -0
  45. package/dist/cdn/IC5P5NYY.js +2 -0
  46. package/dist/cdn/IGZWQJW7.js +3 -0
  47. package/dist/cdn/IKEF7ZHH.js +181 -0
  48. package/dist/cdn/IXAKT6L3.js +2 -0
  49. package/dist/cdn/JEIMRNYM.js +2 -0
  50. package/dist/cdn/JN744CAW.js +2 -0
  51. package/dist/cdn/KRE4U7V7.js +2 -0
  52. package/dist/cdn/{NE7E52YR.js → KTK4HNL2.js} +8 -2
  53. package/dist/cdn/L77BTGXY.js +2 -0
  54. package/dist/cdn/LEPJUN3X.js +22 -0
  55. package/dist/cdn/LODKJRS4.js +2 -0
  56. package/dist/cdn/M3SWPT3M.js +2 -0
  57. package/dist/cdn/MAV3DW27.js +4 -0
  58. package/dist/cdn/NOJYPREL.js +3 -0
  59. package/dist/cdn/NXKKG5TK.js +2 -0
  60. package/dist/cdn/O3F47IO5.js +2 -0
  61. package/dist/cdn/O7TGCM5P.js +6 -0
  62. package/dist/cdn/PBTINZTK.js +65 -0
  63. package/dist/cdn/PKHQW7QU.js +18 -0
  64. package/dist/cdn/PSWI3MFB.js +2 -0
  65. package/dist/cdn/Q73PK7Q7.js +2 -0
  66. package/dist/cdn/Q7TL5Q5N.js +2 -0
  67. package/dist/cdn/QSA4T3BU.js +2 -0
  68. package/dist/cdn/RMLXVQZ5.js +2 -0
  69. package/dist/cdn/RX45PCYB.js +9 -0
  70. package/dist/cdn/S27EJSLC.js +14 -0
  71. package/dist/cdn/SMADRJ67.js +2 -0
  72. package/dist/cdn/{ZLXN7NMF.js → T537PKP4.js} +9 -7
  73. package/dist/cdn/{X2ZDYHCG.js → TNMXWUXU.js} +9 -4
  74. package/dist/cdn/TSEQVE2H.js +36 -0
  75. package/dist/cdn/VKU4WAQV.js +2 -0
  76. package/dist/cdn/W2IHPJ54.js +34 -0
  77. package/dist/cdn/W2JAKE2M.js +2 -0
  78. package/dist/cdn/WAVKMZA6.js +2 -0
  79. package/dist/cdn/WDE3HN7K.js +2 -0
  80. package/dist/cdn/WH6QQK6N.js +2 -0
  81. package/dist/cdn/WNS5ZUF5.js +2 -0
  82. package/dist/cdn/{FL4W4VYN.js → X7GE26KU.js} +16 -0
  83. package/dist/cdn/XVQJBUMY.js +2 -0
  84. package/dist/cdn/YJ3QQXF6.js +2 -0
  85. package/dist/cdn/YRBANNQ5.js +2 -0
  86. package/dist/cdn/YYY7HKYX.js +2 -0
  87. package/dist/cdn/ZEYIBYSF.js +66 -0
  88. package/dist/cdn/ZMSJQB65.js +99 -0
  89. package/dist/cdn/ZOSUDIJH.js +2 -0
  90. package/dist/cdn/ZPLFFLPF.js +2 -0
  91. package/dist/cdn/agent-utils/index.js +2 -0
  92. package/dist/cdn/agent-utils/middlewares/humanInTheLoop.js +3 -0
  93. package/dist/cdn/agent-utils/middlewares/middleware.js +2 -0
  94. package/dist/cdn/agent-utils/middlewares/trace.js +2 -0
  95. package/dist/cdn/index.js +1 -1
  96. package/dist/cdn/main.css +1 -1
  97. package/dist/chunks/adapter.js +1794 -1597
  98. package/dist/chunks/arcgisKnowledgeGraph.js +126 -71
  99. package/dist/chunks/arcgis_knowledge_current_lc_context.js +19 -2
  100. package/dist/chunks/arcgis_knowledge_current_map_context.js +31 -2
  101. package/dist/chunks/arcgis_knowledge_cypher_query_prompt.js +102 -0
  102. package/dist/chunks/arcgis_knowledge_summarize_result_prompt.js +116 -27
  103. package/dist/chunks/converterUtils.js +39 -32
  104. package/dist/chunks/dataExplorationGraph.js +139 -113
  105. package/dist/chunks/data_explore_query_prompt.js +9 -4
  106. package/dist/chunks/generateLayerDescriptions.js +231 -191
  107. package/dist/chunks/helpGraph.js +17 -13
  108. package/dist/chunks/help_prompt.js +34 -17
  109. package/dist/chunks/index.js +11 -0
  110. package/dist/chunks/intent_prompt.js +16 -0
  111. package/dist/chunks/layerStylingGraph.js +24 -20
  112. package/dist/chunks/navigationGraph.js +33 -28
  113. package/dist/chunks/navigation_intent_prompt.js +8 -2
  114. package/dist/chunks/orchestrator.js +267 -226
  115. package/dist/chunks/slottableRequestUtils.js +3 -7
  116. package/dist/chunks/state.js +1 -1
  117. package/dist/chunks/summarize_query_response_prompt.js +9 -7
  118. package/dist/chunks/toolCallResponse.js +12 -9
  119. package/dist/chunks/utils2.js +8 -8
  120. package/dist/components/arcgis-assistant/customElement.d.ts +27 -0
  121. package/dist/components/arcgis-assistant/customElement.js +385 -152
  122. package/dist/components/arcgis-assistant/index.js +2 -3
  123. package/dist/components/arcgis-assistant/types.d.ts +14 -1
  124. package/dist/components/arcgis-assistant-agent/customElement.js +5 -1
  125. package/dist/components/arcgis-assistant-chat/customElement.d.ts +8 -2
  126. package/dist/components/arcgis-assistant-chat/customElement.js +23 -18
  127. package/dist/components/arcgis-assistant-chat-entry/customElement.d.ts +4 -1
  128. package/dist/components/arcgis-assistant-chat-entry/customElement.js +25 -18
  129. package/dist/components/arcgis-assistant-data-exploration-agent/customElement.js +11 -5
  130. package/dist/components/arcgis-assistant-help-agent/customElement.js +8 -2
  131. package/dist/components/arcgis-assistant-interrupt/customElement.d.ts +4 -1
  132. package/dist/components/arcgis-assistant-interrupt/customElement.js +12 -8
  133. package/dist/components/arcgis-assistant-interrupt-preview/customElement.js +20 -0
  134. package/dist/components/arcgis-assistant-interrupt-preview/index.js +2 -0
  135. package/dist/components/arcgis-assistant-knowledge-agent/customElement.d.ts +7 -7
  136. package/dist/components/arcgis-assistant-knowledge-agent/customElement.js +17 -11
  137. package/dist/components/arcgis-assistant-layer-styling-agent/customElement.js +10 -4
  138. package/dist/components/arcgis-assistant-message/customElement.d.ts +23 -0
  139. package/dist/components/arcgis-assistant-message/customElement.js +28 -26
  140. package/dist/components/arcgis-assistant-message/index.d.ts +1 -0
  141. package/dist/components/arcgis-assistant-message/index.js +2 -0
  142. package/dist/components/arcgis-assistant-message-block/customElement.d.ts +1 -1
  143. package/dist/components/arcgis-assistant-message-block/customElement.js +18 -11
  144. package/dist/components/arcgis-assistant-message-block/index.js +1 -0
  145. package/dist/components/arcgis-assistant-message-feedback/customElement.d.ts +4 -1
  146. package/dist/components/arcgis-assistant-message-footer/customElement.d.ts +4 -1
  147. package/dist/components/arcgis-assistant-message-loading/customElement.d.ts +8 -1
  148. package/dist/components/arcgis-assistant-message-loading/customElement.js +8 -8
  149. package/dist/components/arcgis-assistant-message-loading/index.js +1 -0
  150. package/dist/components/arcgis-assistant-message-log/customElement.d.ts +4 -1
  151. package/dist/components/arcgis-assistant-message-read-aloud/customElement.d.ts +4 -1
  152. package/dist/components/arcgis-assistant-message-text/customElement.d.ts +5 -1
  153. package/dist/components/arcgis-assistant-message-text/customElement.js +12 -12
  154. package/dist/components/arcgis-assistant-navigation-agent/customElement.js +11 -5
  155. package/dist/components/arcgis-assistant-speech-input/customElement.d.ts +6 -1
  156. package/dist/components/arcgis-assistant-suggested-prompts/customElement.d.ts +4 -1
  157. package/dist/components/arcgis-assistant-suggested-prompts/customElement.js +8 -8
  158. package/dist/components/arcgis-assistant-user-message/customElement.d.ts +4 -1
  159. package/dist/components/arcgis-assistant-user-message/customElement.js +10 -8
  160. package/dist/docs/api.json +1 -1
  161. package/dist/docs/docs.json +1 -1
  162. package/dist/docs/vscode.html-custom-data.json +1 -1
  163. package/dist/docs/web-types.json +1 -1
  164. package/dist/index.d.ts +4 -0
  165. package/dist/loader.js +7 -6
  166. package/dist/types/lumina.d.ts +11 -5
  167. package/dist/types/preact.d.ts +12 -5
  168. package/dist/types/react.d.ts +13 -5
  169. package/dist/types/stencil.d.ts +11 -5
  170. package/dist/utils/index.d.ts +85 -42
  171. package/dist/utils/index.js +54 -49
  172. package/package.json +8 -7
  173. package/dist/cdn/2AXF774U.js +0 -2
  174. package/dist/cdn/3PKJWIC3.js +0 -2
  175. package/dist/cdn/462JBSEV.js +0 -422
  176. package/dist/cdn/5QAHYX7Y.js +0 -5
  177. package/dist/cdn/7BCR6TUO.js +0 -2
  178. package/dist/cdn/7GH7VSB2.js +0 -2
  179. package/dist/cdn/7PLV4QH6.js +0 -2
  180. package/dist/cdn/AO7BQHKC.js +0 -2
  181. package/dist/cdn/AXDZBBNL.js +0 -45
  182. package/dist/cdn/DDLZOMUY.js +0 -2
  183. package/dist/cdn/DHOVCT6R.js +0 -2
  184. package/dist/cdn/F2AHA4GB.js +0 -54
  185. package/dist/cdn/FHVXO2WG.js +0 -166
  186. package/dist/cdn/FX5JFRDL.js +0 -2
  187. package/dist/cdn/GSEPHN3A.js +0 -106
  188. package/dist/cdn/HB5A5R2E.js +0 -2
  189. package/dist/cdn/JY6LLOUJ.js +0 -22
  190. package/dist/cdn/KMQ3SP4I.js +0 -5
  191. package/dist/cdn/MDVYQQUG.js +0 -14
  192. package/dist/cdn/MH5RPXHM.js +0 -2
  193. package/dist/cdn/NAUXSHIE.js +0 -72
  194. package/dist/cdn/NVI3I46B.js +0 -2
  195. package/dist/cdn/OAVEHGB6.js +0 -2
  196. package/dist/cdn/OH64RMOR.js +0 -4
  197. package/dist/cdn/ON2V5XI2.js +0 -3
  198. package/dist/cdn/P6OPJQMC.js +0 -3
  199. package/dist/cdn/QR54T33D.js +0 -2
  200. package/dist/cdn/RVOAPUBN.js +0 -2
  201. package/dist/cdn/S6W6HV4T.js +0 -36
  202. package/dist/cdn/SXDLXCIM.js +0 -2
  203. package/dist/cdn/USMDJUFS.js +0 -2
  204. package/dist/cdn/V2P4AIGG.js +0 -2
  205. package/dist/cdn/V5YEZSRY.js +0 -16
  206. package/dist/cdn/Y333DGV6.js +0 -2
  207. package/dist/cdn/YY2SBO3V.js +0 -2
@@ -18,7 +18,7 @@ export type FunctionAgentExecute<TInput extends AgentData, TOutput extends Agent
18
18
  * @since 5.1
19
19
  */
20
20
  export class FunctionAgent<TInput extends AgentData = AgentData, TOutput extends AgentData = AgentData> extends BaseAgent<AgentCustomState<TInput, TOutput>> {
21
- constructor(properties?: ConstructProperties<TInput, TOutput>);
21
+ constructor(properties?: FunctionAgentConstructProperties<TInput, TOutput>);
22
22
  /**
23
23
  * The execute function contains the core logic of the FunctionAgent.
24
24
  * It receives the current agent state and an optional execution configuration,
@@ -60,5 +60,5 @@ export class FunctionAgent<TInput extends AgentData = AgentData, TOutput extends
60
60
  initialize(): void;
61
61
  }
62
62
 
63
- export type ConstructProperties<TInput extends AgentData, TOutput extends AgentData> = Partial<Pick<FunctionAgent<TInput, TOutput>, "description" | "inputSchema" | "middlewares" | "outputSchema">>
63
+ export type FunctionAgentConstructProperties<TInput extends AgentData, TOutput extends AgentData> = Partial<Pick<FunctionAgent<TInput, TOutput>, "description" | "inputSchema" | "middlewares" | "outputSchema">>
64
64
  & Pick<FunctionAgent<TInput, TOutput>, "execute" | "name">;
@@ -9,7 +9,7 @@ import type { AgentCustomState, AgentData, ZodObjectSchema } from "./types.js";
9
9
  * @since 5.1
10
10
  */
11
11
  export class LLMAgent<TInput extends AgentData = AgentData, TOutput extends AgentData = AgentData> extends BaseAgent<AgentCustomState<TInput, TOutput>> {
12
- constructor(properties?: ConstructProperties<TInput, TOutput>);
12
+ constructor(properties?: LLMAgentConstructProperties<TInput, TOutput>);
13
13
  /**
14
14
  * The inputSchema property is an optional Zod schema describing the expected structured input for the agent.
15
15
  * This can be used for validation of the input state before execution and also to extract variables from the input
@@ -61,5 +61,5 @@ export class LLMAgent<TInput extends AgentData = AgentData, TOutput extends Agen
61
61
  initialize(): void;
62
62
  }
63
63
 
64
- export type ConstructProperties<TInput extends AgentData, TOutput extends AgentData> = Partial<Pick<LLMAgent<TInput, TOutput>, "description" | "inputSchema" | "middlewares" | "modelTier" | "outputSchema" | "tools">>
64
+ export type LLMAgentConstructProperties<TInput extends AgentData, TOutput extends AgentData> = Partial<Pick<LLMAgent<TInput, TOutput>, "description" | "inputSchema" | "middlewares" | "modelTier" | "outputSchema" | "tools">>
65
65
  & Pick<LLMAgent<TInput, TOutput>, "name" | "prompt">;
@@ -2,6 +2,7 @@
2
2
  import "@arcgis/core/identity/IdentityManager.js";
3
3
  import "@arcgis/core/portal/Portal.js";
4
4
  import { isGraphInterrupt as f } from "@langchain/langgraph/web";
5
+ import "@arcgis/toolkit/string";
5
6
  import { c as u } from "../chunks/generateLayerDescriptions.js";
6
7
  import "@langchain/core/messages";
7
8
  import "@langchain/core/callbacks/dispatch/web";
@@ -16,10 +17,10 @@ import { convertToLangChainMiddlewares as l } from "./middlewares/middleware.js"
16
17
  import { c as y } from "../chunks/graph.js";
17
18
  import { c as T } from "../chunks/state.js";
18
19
  import { c as d, h as M, g as x } from "../chunks/utils.js";
19
- var P = Object.defineProperty, b = Object.getOwnPropertyDescriptor, n = (t, s, r, e) => {
20
- for (var o = e > 1 ? void 0 : e ? b(s, r) : s, p = t.length - 1, i; p >= 0; p--)
21
- (i = t[p]) && (o = (e ? i(s, r, o) : i(o)) || o);
22
- return e && o && P(s, r, o), o;
20
+ var P = Object.defineProperty, b = Object.getOwnPropertyDescriptor, n = (t, r, s, e) => {
21
+ for (var o = e > 1 ? void 0 : e ? b(r, s) : r, p = t.length - 1, i; p >= 0; p--)
22
+ (i = t[p]) && (o = (e ? i(r, s, o) : i(o)) || o);
23
+ return e && o && P(r, s, o), o;
23
24
  };
24
25
  let a = class extends v {
25
26
  //#region Lifecycle
@@ -53,52 +54,52 @@ let a = class extends v {
53
54
  generate() {
54
55
  const t = T(this.getSchemas());
55
56
  this._set("workspace", t);
56
- const s = this.id, r = { [s]: this._invoke.bind(this) }, e = [{ from: s, decide: () => {
57
+ const r = this.id, s = { [r]: this._invoke.bind(this) }, e = [{ from: r, decide: () => {
57
58
  } }];
58
59
  this._set(
59
60
  "createGraph",
60
- () => y(r, e, t, {
61
+ () => y(s, e, t, {
61
62
  agent: this,
62
- entryNode: s,
63
+ entryNode: r,
63
64
  middlewares: this.middlewares
64
65
  })
65
66
  );
66
67
  }
67
68
  //#endregion
68
69
  //#region Private Methods
69
- async _invoke(t, s) {
70
+ async _invoke(t, r) {
70
71
  try {
71
- return this.outputSchema ? await this._invokeStructured(t, s) : await this._invokeUnstructured(t, s);
72
- } catch (r) {
73
- if (f(r))
74
- throw r;
75
- const e = r instanceof Error ? r.message : String(r);
72
+ return this.outputSchema ? await this._invokeStructured(t, r) : await this._invokeUnstructured(t, r);
73
+ } catch (s) {
74
+ if (f(s))
75
+ throw s;
76
+ const e = s instanceof Error ? s.message : String(s);
76
77
  return d({ outputMessage: e }, "failed", e);
77
78
  }
78
79
  }
79
- async _invokeStructured(t, s) {
80
+ async _invokeStructured(t, r) {
80
81
  if (!this.outputSchema)
81
82
  throw new Error("Output schema is required for structured invocation.");
82
83
  const e = await h({
83
- model: await u(this.modelTier),
84
+ model: await u({ modelTier: this.modelTier }),
84
85
  systemPrompt: await this._getPromptWithInputVariables(t),
85
86
  tools: this._getTools(),
86
87
  checkpointer: !0,
87
88
  middleware: l(this.middlewares),
88
89
  responseFormat: this.outputSchema
89
- }).invoke({ messages: t.agentExecutionContext.messages }, s);
90
+ }).invoke({ messages: t.agentExecutionContext.messages }, r);
90
91
  if (!("structuredResponse" in e) || e.structuredResponse === void 0)
91
92
  throw new Error("LLMAgent did not receive structured output from createAgent.");
92
93
  return M(e.structuredResponse, this.outputSchema, e.messages);
93
94
  }
94
- async _invokeUnstructured(t, s) {
95
+ async _invokeUnstructured(t, r) {
95
96
  const o = (await h({
96
- model: await u(this.modelTier),
97
+ model: await u({ modelTier: this.modelTier }),
97
98
  systemPrompt: await this._getPromptWithInputVariables(t),
98
99
  tools: this._getTools(),
99
100
  checkpointer: !0,
100
101
  middleware: l(this.middlewares)
101
- }).invoke({ messages: t.agentExecutionContext.messages }, s)).messages, i = o.at(-1)?.content ?? "", c = typeof i == "string" ? i : JSON.stringify(i), g = c.trim() || "LLMAgent completed.";
102
+ }).invoke({ messages: t.agentExecutionContext.messages }, r)).messages, i = o.at(-1)?.content ?? "", c = typeof i == "string" ? i : JSON.stringify(i), g = c.trim() || "LLMAgent completed.";
102
103
  return d(
103
104
  { agentExecutionContext: { ...t.agentExecutionContext, messages: o }, outputMessage: c },
104
105
  "success",
@@ -106,10 +107,10 @@ let a = class extends v {
106
107
  );
107
108
  }
108
109
  async _getPromptWithInputVariables(t) {
109
- const s = x(t, this.inputSchema);
110
+ const r = x(t, this.inputSchema);
110
111
  for (const { outputKey: e } of this.middlewares)
111
- e && (s[String(e)] = t[e]);
112
- return await S.fromTemplate(this.prompt).format(s);
112
+ e && (r[String(e)] = t[e]);
113
+ return await S.fromTemplate(this.prompt).format(r);
113
114
  }
114
115
  _getTools() {
115
116
  return this.tools?.map((t) => t.getTool()) ?? [];
@@ -9,7 +9,7 @@ import type { AgentData, ZodObjectSchema } from "./types.js";
9
9
  * @since 5.1
10
10
  */
11
11
  export class WorkflowAgent<TState extends AgentData = AgentData> extends BaseAgent<TState> {
12
- constructor(properties: ConstructProperties<TState>);
12
+ constructor(properties: WorkflowAgentConstructProperties<TState>);
13
13
  /** Optional structured input schema for the workflow wrapper. */
14
14
  accessor inputSchema: ZodObjectSchema<object> | undefined;
15
15
  /** Optional structured output schema for the workflow wrapper. */
@@ -40,5 +40,5 @@ export class WorkflowAgent<TState extends AgentData = AgentData> extends BaseAge
40
40
  initialize(): void;
41
41
  }
42
42
 
43
- export type ConstructProperties<TState extends AgentData = AgentData> = Partial<Pick<WorkflowAgent<TState>, "description" | "inputSchema" | "middlewares" | "outputSchema">>
43
+ export type WorkflowAgentConstructProperties<TState extends AgentData = AgentData> = Partial<Pick<WorkflowAgent<TState>, "description" | "inputSchema" | "middlewares" | "outputSchema">>
44
44
  & Pick<WorkflowAgent<TState>, "name" | "workflow">;
@@ -0,0 +1,177 @@
1
+ import type { FunctionAgent, FunctionAgentConstructProperties } from "./FunctionAgent.js";
2
+ import type { LLMAgent, LLMAgentConstructProperties } from "./LLMAgent.js";
3
+ import type { WorkflowAgent, WorkflowAgentConstructProperties } from "./WorkflowAgent.js";
4
+ import type { AgentData, SchemaDefinition, SchemaDefinitionData, ZodObjectSchema } from "./types.js";
5
+ import type { FunctionTool, FunctionToolConstructProperties } from "./tools/FunctionTool.js";
6
+ import type { ConditionalWorkflow, ConditionalWorkflowConstructProperties } from "./workflows/ConditionalWorkflow.js";
7
+ import type { LoopWorkflow, LoopWorkflowConstructProperties } from "./workflows/LoopWorkflow.js";
8
+ import type { ParallelWorkflow, ParallelWorkflowConstructProperties } from "./workflows/ParallelWorkflow.js";
9
+ import type { RouterWorkflow, RouterWorkflowConstructProperties } from "./workflows/RouterWorkflow.js";
10
+ import type { SequentialWorkflow, SequentialWorkflowConstructProperties } from "./workflows/SequentialWorkflow.js";
11
+ import type { SwitchWorkflow, SwitchWorkflowConstructProperties } from "./workflows/SwitchWorkflow.js";
12
+ import type { RunnableConfig } from "@langchain/core/runnables";
13
+
14
+ /**
15
+ * Creates a Zod schema from a plain object schema definition.
16
+ *
17
+ * Supports all schema field variants:
18
+ * - `string` (with optional `enum`)
19
+ * - `number`
20
+ * - `boolean`
21
+ * - `array` with primitive or nested item definitions
22
+ * - `object` with nested `fields`
23
+ *
24
+ * @param definition
25
+ * @example
26
+ * ```ts
27
+ * const primitiveSchema = await createSchema({
28
+ * name: { type: "string", description: "Search location name", required: true },
29
+ * radius: { type: "number", description: "Search radius in miles" },
30
+ * active: { type: "boolean", description: "Whether the search is enabled" },
31
+ * });
32
+ * ```
33
+ * @example
34
+ * ```ts
35
+ * const nestedObjectSchema = await createSchema({
36
+ * query: { type: "string", description: "User search text", required: true },
37
+ * options: {
38
+ * type: "object",
39
+ * description: "Search options",
40
+ * required: true,
41
+ * fields: {
42
+ * center: {
43
+ * type: "object",
44
+ * description: "Map center point",
45
+ * fields: {
46
+ * latitude: { type: "number", description: "Center latitude", required: true },
47
+ * longitude: { type: "number", description: "Center longitude", required: true },
48
+ * },
49
+ * },
50
+ * categories: { type: "array", description: "Selected categories", itemType: "string" },
51
+ * },
52
+ * },
53
+ * });
54
+ * ```
55
+ * @example
56
+ * ```ts
57
+ * const arrayOfObjectsSchema = await createSchema({
58
+ * constraints: {
59
+ * type: "array",
60
+ * description: "Constraint rules",
61
+ * itemType: {
62
+ * type: "object",
63
+ * description: "Single constraint rule",
64
+ * fields: {
65
+ * key: { type: "string", description: "Constraint key", required: true },
66
+ * enabled: { type: "boolean", description: "Whether this rule is active" },
67
+ * values: { type: "array", description: "Rule values", itemType: "string" },
68
+ * },
69
+ * },
70
+ * },
71
+ * });
72
+ * ```
73
+ * @since 5.1
74
+ */
75
+ export function createSchema<const TDefinition extends SchemaDefinition>(definition: TDefinition): Promise<ZodObjectSchema<SchemaDefinitionData<TDefinition>>>;
76
+
77
+ /**
78
+ * The suggestions emitted by the agent to the user interface.
79
+ *
80
+ * @since 5.1
81
+ */
82
+ export type UXSuggestion = {
83
+ /** The type of suggestion being made. */
84
+ type: string;
85
+ /** Optional additional data associated with the suggestion. */
86
+ data?: Record<string, unknown>;
87
+ };
88
+
89
+ /**
90
+ * Sends an optional UX suggestion from an agent run to the host application.
91
+ * Use this for non-blocking hints (for example, recommended next actions or UI prompts) that the app may choose to display.
92
+ *
93
+ * @param suggestion
94
+ * @param config
95
+ * @since 5.1
96
+ */
97
+ export function sendUXSuggestion(suggestion: UXSuggestion, config?: RunnableConfig): Promise<void>;
98
+
99
+ /**
100
+ * Creates a FunctionAgent instance from the existing agent implementation.
101
+ *
102
+ * @param properties
103
+ * @since 5.1
104
+ */
105
+ export function createFunctionAgent<TInput extends AgentData = AgentData, TOutput extends AgentData = AgentData>(properties: FunctionAgentConstructProperties<TInput, TOutput>): Promise<FunctionAgent<TInput, TOutput>>;
106
+
107
+ /**
108
+ * Creates a FunctionTool instance from the existing tool implementation.
109
+ *
110
+ * @param properties
111
+ * @since 5.1
112
+ */
113
+ export function createFunctionTool<TInput extends AgentData, TOutput = unknown>(properties: FunctionToolConstructProperties<TInput, TOutput>): Promise<FunctionTool<TInput, TOutput>>;
114
+
115
+ /**
116
+ * Creates an LLMAgent instance from the existing agent implementation.
117
+ *
118
+ * @param properties
119
+ * @since 5.1
120
+ */
121
+ export function createLLMAgent<TInput extends AgentData = AgentData, TOutput extends AgentData = AgentData>(properties: LLMAgentConstructProperties<TInput, TOutput>): Promise<LLMAgent<TInput, TOutput>>;
122
+
123
+ /**
124
+ * Creates a WorkflowAgent instance from the existing workflow agent implementation.
125
+ *
126
+ * @param properties
127
+ * @since 5.1
128
+ */
129
+ export function createWorkflowAgent<TState extends AgentData = AgentData>(properties: WorkflowAgentConstructProperties<TState>): Promise<WorkflowAgent<TState>>;
130
+
131
+ /**
132
+ * Creates a ConditionalWorkflow instance from the existing workflow implementation.
133
+ *
134
+ * @param properties
135
+ * @since 5.1
136
+ */
137
+ export function createConditionalWorkflow<TState extends AgentData = AgentData>(properties: ConditionalWorkflowConstructProperties<TState>): Promise<ConditionalWorkflow<TState>>;
138
+
139
+ /**
140
+ * Creates a LoopWorkflow instance from the existing workflow implementation.
141
+ *
142
+ * @param properties
143
+ * @since 5.1
144
+ */
145
+ export function createLoopWorkflow<TState extends AgentData = AgentData>(properties: LoopWorkflowConstructProperties<TState>): Promise<LoopWorkflow<TState>>;
146
+
147
+ /**
148
+ * Creates a ParallelWorkflow instance from the existing workflow implementation.
149
+ *
150
+ * @param properties
151
+ * @since 5.1
152
+ */
153
+ export function createParallelWorkflow<TState extends AgentData = AgentData>(properties: ParallelWorkflowConstructProperties<TState>): Promise<ParallelWorkflow<TState>>;
154
+
155
+ /**
156
+ * Creates a RouterWorkflow instance from the existing workflow implementation.
157
+ *
158
+ * @param properties
159
+ * @since 5.1
160
+ */
161
+ export function createRouterWorkflow<TState extends AgentData = AgentData>(properties: RouterWorkflowConstructProperties<TState>): Promise<RouterWorkflow<TState>>;
162
+
163
+ /**
164
+ * Creates a SequentialWorkflow instance from the existing workflow implementation.
165
+ *
166
+ * @param properties
167
+ * @since 5.1
168
+ */
169
+ export function createSequentialWorkflow<TState extends AgentData = AgentData>(properties: SequentialWorkflowConstructProperties<TState>): Promise<SequentialWorkflow<TState>>;
170
+
171
+ /**
172
+ * Creates a SwitchWorkflow instance from the existing workflow implementation.
173
+ *
174
+ * @param properties
175
+ * @since 5.1
176
+ */
177
+ export function createSwitchWorkflow<TState extends AgentData = AgentData>(properties: SwitchWorkflowConstructProperties<TState>): Promise<SwitchWorkflow<TState>>;
@@ -0,0 +1,167 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
+ let i, a, c, u, l, s, w, m, f, p, d, g;
3
+ async function n(e, t) {
4
+ if (t in e)
5
+ return e[t];
6
+ if ("default" in e) {
7
+ const o = await e.default;
8
+ return typeof o == "object" && o !== null && t in o ? o[t] : o;
9
+ }
10
+ throw new Error(`Unable to resolve ${String(t)} from module.`);
11
+ }
12
+ function y(e, t) {
13
+ const o = {};
14
+ for (const [r, k] of Object.entries(t))
15
+ o[r] = S(e, k);
16
+ return o;
17
+ }
18
+ function W(e, t) {
19
+ return e.object(y(e, t));
20
+ }
21
+ function S(e, t) {
22
+ const o = h(e, t);
23
+ return t.required === !0 ? o : o.optional();
24
+ }
25
+ function h(e, t) {
26
+ let o = P(e, t);
27
+ return t.description !== void 0 && (o = o.describe(t.description)), o;
28
+ }
29
+ function b(e, t) {
30
+ switch (t) {
31
+ case "string":
32
+ return e.string();
33
+ case "number":
34
+ return e.number();
35
+ case "boolean":
36
+ return e.boolean();
37
+ }
38
+ }
39
+ function M(e) {
40
+ return e === "string" || e === "number" || e === "boolean";
41
+ }
42
+ function P(e, t) {
43
+ switch (t.type) {
44
+ case "string": {
45
+ if (t.enum != null) {
46
+ if (t.enum.length === 0)
47
+ throw new Error("String schema field enum must include at least one value.");
48
+ return e.enum(t.enum);
49
+ }
50
+ return e.string();
51
+ }
52
+ case "number":
53
+ return e.number();
54
+ case "boolean":
55
+ return e.boolean();
56
+ case "array": {
57
+ if (t.itemType == null)
58
+ throw new Error("Array schema field requires an itemType definition.");
59
+ return e.array(
60
+ M(t.itemType) ? b(e, t.itemType) : h(e, t.itemType)
61
+ );
62
+ }
63
+ case "object": {
64
+ if (t.fields == null)
65
+ throw new Error("Object schema field requires a fields definition.");
66
+ return W(e, t.fields);
67
+ }
68
+ }
69
+ }
70
+ async function A(e) {
71
+ d ??= import("zod");
72
+ const t = await d;
73
+ return W(t.z, e);
74
+ }
75
+ async function T(e, t) {
76
+ g ??= import("../utils/index.js");
77
+ const o = await g;
78
+ return await (await n(
79
+ o,
80
+ "sendUXSuggestion"
81
+ ))(e, t);
82
+ }
83
+ async function L(e) {
84
+ i ??= import("./FunctionAgent.js");
85
+ const t = await i, o = await n(
86
+ t,
87
+ "FunctionAgent"
88
+ );
89
+ return new o(e);
90
+ }
91
+ async function q(e) {
92
+ a ??= import("./tools/FunctionTool.js");
93
+ const t = await a, o = await n(
94
+ t,
95
+ "FunctionTool"
96
+ );
97
+ return new o(e);
98
+ }
99
+ async function F(e) {
100
+ c ??= import("./LLMAgent.js");
101
+ const t = await c, o = await n(t, "LLMAgent");
102
+ return new o(e);
103
+ }
104
+ async function j(e) {
105
+ u ??= import("./WorkflowAgent.js");
106
+ const t = await u, o = await n(
107
+ t,
108
+ "WorkflowAgent"
109
+ );
110
+ return new o(e);
111
+ }
112
+ async function E(e) {
113
+ l ??= import("./workflows/ConditionalWorkflow.js");
114
+ const t = await l, o = await n(t, "ConditionalWorkflow");
115
+ return new o(e);
116
+ }
117
+ async function v(e) {
118
+ s ??= import("./workflows/LoopWorkflow.js");
119
+ const t = await s, o = await n(
120
+ t,
121
+ "LoopWorkflow"
122
+ );
123
+ return new o(e);
124
+ }
125
+ async function U(e) {
126
+ w ??= import("./workflows/ParallelWorkflow.js");
127
+ const t = await w, o = await n(
128
+ t,
129
+ "ParallelWorkflow"
130
+ );
131
+ return new o(e);
132
+ }
133
+ async function R(e) {
134
+ m ??= import("./workflows/RouterWorkflow.js");
135
+ const t = await m, o = await n(
136
+ t,
137
+ "RouterWorkflow"
138
+ );
139
+ return new o(e);
140
+ }
141
+ async function X(e) {
142
+ f ??= import("./workflows/SequentialWorkflow.js");
143
+ const t = await f, o = await n(t, "SequentialWorkflow");
144
+ return new o(e);
145
+ }
146
+ async function x(e) {
147
+ p ??= import("./workflows/SwitchWorkflow.js");
148
+ const t = await p, o = await n(
149
+ t,
150
+ "SwitchWorkflow"
151
+ );
152
+ return new o(e);
153
+ }
154
+ export {
155
+ E as createConditionalWorkflow,
156
+ L as createFunctionAgent,
157
+ q as createFunctionTool,
158
+ F as createLLMAgent,
159
+ v as createLoopWorkflow,
160
+ U as createParallelWorkflow,
161
+ R as createRouterWorkflow,
162
+ A as createSchema,
163
+ X as createSequentialWorkflow,
164
+ x as createSwitchWorkflow,
165
+ j as createWorkflowAgent,
166
+ T as sendUXSuggestion
167
+ };
@@ -10,6 +10,7 @@ import type { AgentData } from "../types.js";
10
10
  * executions, which can be useful for debugging and monitoring the agent's behavior.
11
11
  *
12
12
  * @returns An agent middleware that wraps model calls and sends trace messages.
13
+ * @internal
13
14
  * @since 5.1
14
15
  */
15
16
  export function createAgentTraceMiddleware(): AgentMiddleware;
@@ -20,6 +21,7 @@ export function createAgentTraceMiddleware(): AgentMiddleware;
20
21
  * debugging and monitoring the behavior of tools within the agent's execution.
21
22
  *
22
23
  * @returns A function tool middleware that wraps tool calls and sends trace messages.
24
+ * @internal
23
25
  * @since 5.1
24
26
  */
25
27
  export function createToolTraceMiddleware<TInput extends AgentData = AgentData, TOutput = unknown>(): FunctionToolMiddleware<TInput, TOutput>;
@@ -1,50 +1,42 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import "@arcgis/core/identity/IdentityManager.js";
3
- import "@arcgis/core/portal/Portal.js";
4
- import "@langchain/langgraph/web";
5
- import { s as n } from "../../chunks/generateLayerDescriptions.js";
6
- import { AIMessage as l, ToolMessage as s } from "@langchain/core/messages";
7
- import "@langchain/openai";
8
- import "@arcgis/core/core/reactiveUtils.js";
9
- import "@arcgis/core/layers/FeatureLayer.js";
10
- import "@arcgis/core/request.js";
11
- import "@langchain/core/prompts";
12
- import { createAgentMiddleware as c, createToolMiddleware as m } from "./middleware.js";
13
- const d = "agent-trace", g = "tool-trace";
14
- function $() {
15
- return c(d, {
16
- wrapModelCall: async (t, o) => {
17
- const e = await o(t), a = t.runtime, i = p(e);
2
+ import { s as r } from "../../chunks/index.js";
3
+ import { AIMessage as i, ToolMessage as s } from "@langchain/core/messages";
4
+ import { createAgentMiddleware as c, createToolMiddleware as d } from "./middleware.js";
5
+ const g = "agent-trace", f = "tool-trace";
6
+ function p() {
7
+ return c(g, {
8
+ wrapModelCall: async (e, a) => {
9
+ const t = await a(e), o = e.runtime, l = m(t);
18
10
  return await Promise.all(
19
- i.map(
20
- async (r) => await n(
11
+ l.map(
12
+ async (n) => await r(
21
13
  {
22
- text: `LLM requested tool call "${r.name}" with arguments: ${JSON.stringify(r.args, null, 2)}`
14
+ text: `LLM requested tool call "${n.name}" with arguments: ${JSON.stringify(n.args, null, 2)}`
23
15
  },
24
- a
16
+ o
25
17
  )
26
18
  )
27
- ), e;
19
+ ), t;
28
20
  }
29
21
  });
30
22
  }
31
- function h() {
32
- return m(g, {
33
- wrapToolCall: async (t, o) => {
34
- const e = await o(t), a = t.config;
35
- return await n(
23
+ function T() {
24
+ return d(f, {
25
+ wrapToolCall: async (e, a) => {
26
+ const t = await a(e), o = e.config;
27
+ return await r(
36
28
  {
37
- text: `Finished executing tool: ${s.isInstance(e) ? e.content.toString() : typeof e == "string" ? e : t.tool.name}`
29
+ text: `Finished executing tool: ${s.isInstance(t) ? t.content.toString() : typeof t == "string" ? t : e.tool.name}`
38
30
  },
39
- a
40
- ), e;
31
+ o
32
+ ), t;
41
33
  }
42
34
  });
43
35
  }
44
- function p(t) {
45
- return !l.isInstance(t) || !Array.isArray(t.tool_calls) ? [] : t.tool_calls.filter((o) => typeof o?.name == "string");
36
+ function m(e) {
37
+ return !i.isInstance(e) || !Array.isArray(e.tool_calls) ? [] : e.tool_calls.filter((a) => typeof a?.name == "string");
46
38
  }
47
39
  export {
48
- $ as createAgentTraceMiddleware,
49
- h as createToolTraceMiddleware
40
+ p as createAgentTraceMiddleware,
41
+ T as createToolTraceMiddleware
50
42
  };
@@ -59,7 +59,7 @@ export interface FunctionToolLike {
59
59
  * @since 5.1
60
60
  */
61
61
  export class FunctionTool<TInput extends AgentData, TOutput = unknown> extends Accessor {
62
- constructor(properties?: ConstructProperties<TInput, TOutput>);
62
+ constructor(properties?: FunctionToolConstructProperties<TInput, TOutput>);
63
63
  /**
64
64
  * A concise, but clear description of the tool's functionality.
65
65
  * This should provide enough information for the agent to understand when and why to use the tool.
@@ -123,5 +123,5 @@ export interface FunctionToolMiddlewareTool {
123
123
  resultMode: ToolResultMode;
124
124
  }
125
125
 
126
- export type ConstructProperties<TInput extends AgentData, TOutput> = Partial<Pick<FunctionTool<TInput, TOutput>, "inputSchema" | "middlewares" | "outputSchema" | "resultMode">>
126
+ export type FunctionToolConstructProperties<TInput extends AgentData, TOutput> = Partial<Pick<FunctionTool<TInput, TOutput>, "inputSchema" | "middlewares" | "outputSchema" | "resultMode">>
127
127
  & Pick<FunctionTool<TInput, TOutput>, "description" | "execute" | "name">;