@arcgis/ai-components 5.1.0-next.137 → 5.1.0-next.139
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/index.d.ts +78 -0
- package/dist/agent-utils/index.js +116 -97
- package/dist/agent-utils/middlewares/trace.d.ts +2 -0
- package/dist/agent-utils/types.d.ts +12 -12
- package/dist/cdn/3J5RM5OR.js +36 -0
- package/dist/cdn/46U2PGRW.js +65 -0
- package/dist/cdn/4BA4OUWC.js +134 -0
- package/dist/cdn/5PCM536R.js +2 -0
- package/dist/cdn/{ZL2D2BJI.js → 7CCULIWM.js} +1 -1
- package/dist/cdn/7UZXJ2NV.js +2 -0
- package/dist/cdn/{WTEDVMFR.js → AJKWCXDA.js} +8 -2
- package/dist/cdn/{VWG4M6ZB.js → AXOPGQGZ.js} +1 -1
- package/dist/cdn/BP3VTREO.js +2 -0
- package/dist/cdn/BUTKUPXN.js +34 -0
- package/dist/cdn/CU2TRUZQ.js +99 -0
- package/dist/cdn/CY6TQNPZ.js +2 -0
- package/dist/cdn/DB2C7FK7.js +2 -0
- package/dist/cdn/DHGNGMNJ.js +2 -0
- package/dist/cdn/{RLWXD365.js → DKNDDDWM.js} +1 -1
- package/dist/cdn/ECRIHA3B.js +2 -0
- package/dist/cdn/{RHG5ENR3.js → ESRKMM6P.js} +1 -1
- package/dist/cdn/FDBWYCAB.js +22 -0
- package/dist/cdn/GREMH2RH.js +2 -0
- package/dist/cdn/J2C46PBG.js +9 -0
- package/dist/cdn/JBSIE542.js +2 -0
- package/dist/cdn/K7E3HQ3X.js +2 -0
- package/dist/cdn/{V746CPCO.js → LTPDBXQ7.js} +1 -1
- package/dist/cdn/{DAMZY3V4.js → LUY7QCZ3.js} +1 -1
- package/dist/cdn/MJM2MHJW.js +44 -0
- package/dist/cdn/N2SKXRLK.js +71 -0
- package/dist/cdn/NA33FY7K.js +3 -0
- package/dist/cdn/{O4SVTPFW.js → OBDCCGVH.js} +1 -1
- package/dist/cdn/OP6ENMCN.js +180 -0
- package/dist/cdn/{YI2KPJBP.js → PFW7KXCP.js} +19 -18
- package/dist/cdn/{EY5GGKO5.js → PKH5BECA.js} +1 -1
- package/dist/cdn/PZBN3ZC7.js +2 -0
- package/dist/cdn/QZAMDTLL.js +2 -0
- package/dist/cdn/{P3JUCFXI.js → TIXCHLEN.js} +2 -2
- package/dist/cdn/U7ANQZBC.js +2 -0
- package/dist/cdn/UDXMJNRF.js +3 -0
- package/dist/cdn/{LYJY5QUA.js → UE3CP46P.js} +1 -1
- package/dist/cdn/VDAF255D.js +22 -0
- package/dist/cdn/W2CWLWUT.js +14 -0
- package/dist/cdn/W6HO4D6J.js +18 -0
- package/dist/cdn/{PCZS64LS.js → WNJM5TET.js} +1 -1
- package/dist/cdn/{KJ5IHMRP.js → Y5GGIKKC.js} +1 -1
- package/dist/cdn/{UPSGN34Q.js → YURWID37.js} +1 -1
- package/dist/cdn/ZGQAMC2Z.js +3 -0
- package/dist/cdn/agent-utils/index.js +1 -1
- package/dist/cdn/index.js +1 -1
- package/dist/chunks/adapter.js +1464 -1376
- package/dist/chunks/arcgisKnowledgeGraph.js +91 -74
- package/dist/chunks/arcgis_knowledge_current_lc_context.js +19 -2
- package/dist/chunks/arcgis_knowledge_current_map_context.js +31 -2
- package/dist/chunks/arcgis_knowledge_cypher_query_prompt.js +102 -0
- package/dist/chunks/arcgis_knowledge_summarize_result_prompt.js +116 -27
- package/dist/chunks/converterUtils.js +39 -32
- package/dist/chunks/dataExplorationGraph.js +12 -10
- package/dist/chunks/helpGraph.js +8 -8
- package/dist/chunks/help_prompt.js +34 -17
- package/dist/chunks/intent_prompt.js +2 -2
- package/dist/chunks/navigationGraph.js +4 -4
- package/dist/chunks/navigation_intent_prompt.js +8 -2
- package/dist/chunks/state.js +1 -1
- package/dist/chunks/utils2.js +8 -8
- package/dist/components/arcgis-assistant/customElement.d.ts +7 -0
- package/dist/components/arcgis-assistant/customElement.js +301 -181
- package/dist/components/arcgis-assistant-agent/customElement.js +5 -1
- package/dist/components/arcgis-assistant-chat/customElement.js +22 -17
- package/dist/components/arcgis-assistant-data-exploration-agent/customElement.js +9 -5
- package/dist/components/arcgis-assistant-help-agent/customElement.js +6 -2
- package/dist/components/arcgis-assistant-interrupt/customElement.js +4 -4
- package/dist/components/arcgis-assistant-knowledge-agent/customElement.js +16 -12
- package/dist/components/arcgis-assistant-layer-styling-agent/customElement.js +8 -4
- package/dist/components/arcgis-assistant-message-block/customElement.js +1 -1
- package/dist/components/arcgis-assistant-message-text/customElement.d.ts +1 -0
- package/dist/components/arcgis-assistant-message-text/customElement.js +12 -12
- package/dist/components/arcgis-assistant-navigation-agent/customElement.js +9 -5
- package/dist/components/arcgis-assistant-user-message/customElement.js +10 -8
- package/dist/docs/api.json +1 -1
- package/dist/docs/docs.json +1 -1
- package/dist/docs/vscode.html-custom-data.json +1 -1
- package/dist/docs/web-types.json +1 -1
- package/dist/loader.js +2 -2
- package/dist/types/lumina.d.ts +2 -2
- package/dist/types/preact.d.ts +2 -2
- package/dist/types/react.d.ts +2 -2
- package/dist/types/stencil.d.ts +2 -2
- package/dist/utils/index.d.ts +1 -2
- package/package.json +4 -4
- package/dist/cdn/2DYXX3VX.js +0 -2
- package/dist/cdn/2K55LM7D.js +0 -44
- package/dist/cdn/4YMVC2WQ.js +0 -2
- package/dist/cdn/5TNWYXLO.js +0 -14
- package/dist/cdn/D2I7TZ3V.js +0 -3
- package/dist/cdn/DQML5GFC.js +0 -16
- package/dist/cdn/DZ5GEWTT.js +0 -2
- package/dist/cdn/E2FJS7ZW.js +0 -2
- package/dist/cdn/FWLEC33J.js +0 -3
- package/dist/cdn/GH7EROHP.js +0 -5
- package/dist/cdn/HQJUEXND.js +0 -22
- package/dist/cdn/KWORBODI.js +0 -5
- package/dist/cdn/MCQR5IEB.js +0 -36
- package/dist/cdn/MFEAOGTZ.js +0 -45
- package/dist/cdn/MXPGGYZ5.js +0 -2
- package/dist/cdn/ORRZDP5H.js +0 -54
- package/dist/cdn/PJFNIBRA.js +0 -161
- package/dist/cdn/RXUGYIPT.js +0 -2
- package/dist/cdn/WALWNGLA.js +0 -2
- package/dist/cdn/WAUIIVEJ.js +0 -72
- package/dist/orchestrator/registry/agentRegistry.d.ts +0 -33
|
@@ -9,15 +9,93 @@ import type { ParallelWorkflow, ParallelWorkflowConstructProperties } from "./wo
|
|
|
9
9
|
import type { RouterWorkflow, RouterWorkflowConstructProperties } from "./workflows/RouterWorkflow.js";
|
|
10
10
|
import type { SequentialWorkflow, SequentialWorkflowConstructProperties } from "./workflows/SequentialWorkflow.js";
|
|
11
11
|
import type { SwitchWorkflow, SwitchWorkflowConstructProperties } from "./workflows/SwitchWorkflow.js";
|
|
12
|
+
import type { RunnableConfig } from "@langchain/core/runnables";
|
|
12
13
|
|
|
13
14
|
/**
|
|
14
15
|
* Creates a Zod schema from a plain object schema definition.
|
|
15
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
|
+
*
|
|
16
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
|
+
* ```
|
|
17
73
|
* @since 5.1
|
|
18
74
|
*/
|
|
19
75
|
export function createSchema<const TDefinition extends SchemaDefinition>(definition: TDefinition): Promise<ZodObjectSchema<SchemaDefinitionData<TDefinition>>>;
|
|
20
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
|
+
|
|
21
99
|
/**
|
|
22
100
|
* Creates a FunctionAgent instance from the existing agent implementation.
|
|
23
101
|
*
|
|
@@ -1,148 +1,167 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
let
|
|
3
|
-
async function n(
|
|
4
|
-
if (
|
|
5
|
-
return
|
|
6
|
-
if ("default" in
|
|
7
|
-
const
|
|
8
|
-
return typeof
|
|
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
9
|
}
|
|
10
|
-
throw new Error(`Unable to resolve ${String(
|
|
10
|
+
throw new Error(`Unable to resolve ${String(t)} from module.`);
|
|
11
11
|
}
|
|
12
|
-
function
|
|
13
|
-
const
|
|
14
|
-
for (const [
|
|
15
|
-
|
|
16
|
-
return
|
|
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
17
|
}
|
|
18
|
-
function
|
|
19
|
-
return
|
|
18
|
+
function W(e, t) {
|
|
19
|
+
return e.object(y(e, t));
|
|
20
20
|
}
|
|
21
|
-
function
|
|
22
|
-
const
|
|
23
|
-
return
|
|
21
|
+
function S(e, t) {
|
|
22
|
+
const o = h(e, t);
|
|
23
|
+
return t.required === !0 ? o : o.optional();
|
|
24
24
|
}
|
|
25
|
-
function
|
|
26
|
-
let
|
|
27
|
-
return
|
|
25
|
+
function h(e, t) {
|
|
26
|
+
let o = P(e, t);
|
|
27
|
+
return t.description !== void 0 && (o = o.describe(t.description)), o;
|
|
28
28
|
}
|
|
29
|
-
function
|
|
30
|
-
switch (
|
|
29
|
+
function b(e, t) {
|
|
30
|
+
switch (t) {
|
|
31
31
|
case "string":
|
|
32
|
-
return
|
|
32
|
+
return e.string();
|
|
33
33
|
case "number":
|
|
34
|
-
return
|
|
34
|
+
return e.number();
|
|
35
35
|
case "boolean":
|
|
36
|
-
return
|
|
36
|
+
return e.boolean();
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
|
-
function
|
|
40
|
-
|
|
39
|
+
function M(e) {
|
|
40
|
+
return e === "string" || e === "number" || e === "boolean";
|
|
41
|
+
}
|
|
42
|
+
function P(e, t) {
|
|
43
|
+
switch (t.type) {
|
|
41
44
|
case "string": {
|
|
42
|
-
if (
|
|
43
|
-
if (
|
|
45
|
+
if (t.enum != null) {
|
|
46
|
+
if (t.enum.length === 0)
|
|
44
47
|
throw new Error("String schema field enum must include at least one value.");
|
|
45
|
-
return
|
|
48
|
+
return e.enum(t.enum);
|
|
46
49
|
}
|
|
47
|
-
return
|
|
50
|
+
return e.string();
|
|
48
51
|
}
|
|
49
52
|
case "number":
|
|
50
|
-
return
|
|
53
|
+
return e.number();
|
|
51
54
|
case "boolean":
|
|
52
|
-
return
|
|
55
|
+
return e.boolean();
|
|
53
56
|
case "array": {
|
|
54
|
-
if (
|
|
57
|
+
if (t.itemType == null)
|
|
55
58
|
throw new Error("Array schema field requires an itemType definition.");
|
|
56
|
-
return
|
|
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);
|
|
57
67
|
}
|
|
58
68
|
}
|
|
59
69
|
}
|
|
60
|
-
async function
|
|
61
|
-
|
|
62
|
-
const
|
|
63
|
-
return
|
|
64
|
-
}
|
|
65
|
-
async function
|
|
66
|
-
|
|
67
|
-
const
|
|
68
|
-
|
|
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,
|
|
69
87
|
"FunctionAgent"
|
|
70
88
|
);
|
|
71
|
-
return new
|
|
89
|
+
return new o(e);
|
|
72
90
|
}
|
|
73
|
-
async function
|
|
91
|
+
async function q(e) {
|
|
74
92
|
a ??= import("./tools/FunctionTool.js");
|
|
75
|
-
const
|
|
76
|
-
|
|
93
|
+
const t = await a, o = await n(
|
|
94
|
+
t,
|
|
77
95
|
"FunctionTool"
|
|
78
96
|
);
|
|
79
|
-
return new
|
|
97
|
+
return new o(e);
|
|
80
98
|
}
|
|
81
|
-
async function
|
|
82
|
-
|
|
83
|
-
const
|
|
84
|
-
return new
|
|
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);
|
|
85
103
|
}
|
|
86
|
-
async function
|
|
87
|
-
|
|
88
|
-
const
|
|
89
|
-
|
|
104
|
+
async function j(e) {
|
|
105
|
+
u ??= import("./WorkflowAgent.js");
|
|
106
|
+
const t = await u, o = await n(
|
|
107
|
+
t,
|
|
90
108
|
"WorkflowAgent"
|
|
91
109
|
);
|
|
92
|
-
return new
|
|
110
|
+
return new o(e);
|
|
93
111
|
}
|
|
94
|
-
async function
|
|
95
|
-
|
|
96
|
-
const
|
|
97
|
-
return new
|
|
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);
|
|
98
116
|
}
|
|
99
|
-
async function
|
|
100
|
-
|
|
101
|
-
const
|
|
102
|
-
|
|
117
|
+
async function v(e) {
|
|
118
|
+
s ??= import("./workflows/LoopWorkflow.js");
|
|
119
|
+
const t = await s, o = await n(
|
|
120
|
+
t,
|
|
103
121
|
"LoopWorkflow"
|
|
104
122
|
);
|
|
105
|
-
return new
|
|
123
|
+
return new o(e);
|
|
106
124
|
}
|
|
107
|
-
async function
|
|
108
|
-
|
|
109
|
-
const
|
|
110
|
-
|
|
125
|
+
async function U(e) {
|
|
126
|
+
w ??= import("./workflows/ParallelWorkflow.js");
|
|
127
|
+
const t = await w, o = await n(
|
|
128
|
+
t,
|
|
111
129
|
"ParallelWorkflow"
|
|
112
130
|
);
|
|
113
|
-
return new
|
|
131
|
+
return new o(e);
|
|
114
132
|
}
|
|
115
|
-
async function
|
|
116
|
-
|
|
117
|
-
const
|
|
118
|
-
|
|
133
|
+
async function R(e) {
|
|
134
|
+
m ??= import("./workflows/RouterWorkflow.js");
|
|
135
|
+
const t = await m, o = await n(
|
|
136
|
+
t,
|
|
119
137
|
"RouterWorkflow"
|
|
120
138
|
);
|
|
121
|
-
return new
|
|
139
|
+
return new o(e);
|
|
122
140
|
}
|
|
123
|
-
async function
|
|
141
|
+
async function X(e) {
|
|
124
142
|
f ??= import("./workflows/SequentialWorkflow.js");
|
|
125
|
-
const
|
|
126
|
-
return new
|
|
143
|
+
const t = await f, o = await n(t, "SequentialWorkflow");
|
|
144
|
+
return new o(e);
|
|
127
145
|
}
|
|
128
|
-
async function
|
|
129
|
-
|
|
130
|
-
const
|
|
131
|
-
|
|
146
|
+
async function x(e) {
|
|
147
|
+
p ??= import("./workflows/SwitchWorkflow.js");
|
|
148
|
+
const t = await p, o = await n(
|
|
149
|
+
t,
|
|
132
150
|
"SwitchWorkflow"
|
|
133
151
|
);
|
|
134
|
-
return new
|
|
152
|
+
return new o(e);
|
|
135
153
|
}
|
|
136
154
|
export {
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
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
|
|
148
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>;
|
|
@@ -3,10 +3,8 @@ import type { BaseChannel, BinaryOperatorAggregate } from "@langchain/langgraph/
|
|
|
3
3
|
import type { AnnotationRoot, StateDefinitionInit, StateGraph } from "@langchain/langgraph/web";
|
|
4
4
|
import type { AgentExecutionContext, AgentRegistration, AgentStatus } from "../utils/index.js";
|
|
5
5
|
|
|
6
|
-
/** @internal */
|
|
7
6
|
export type AgentData = Record<string, unknown>;
|
|
8
7
|
|
|
9
|
-
/** @internal */
|
|
10
8
|
export type EmptyAgentData = Record<never, never>;
|
|
11
9
|
|
|
12
10
|
/** @internal */
|
|
@@ -16,13 +14,18 @@ export type ZodModule = {
|
|
|
16
14
|
|
|
17
15
|
export type SchemaPrimitiveFieldType = "boolean" | "number" | "string";
|
|
18
16
|
|
|
17
|
+
export type SchemaArrayItemDefinition = SchemaFieldDefinition | SchemaPrimitiveFieldType;
|
|
18
|
+
|
|
19
19
|
export type SchemaFieldDefinition = ({
|
|
20
|
-
enum?: readonly string[];
|
|
21
|
-
type: "string";
|
|
22
|
-
} | {
|
|
23
|
-
itemType: SchemaPrimitiveFieldType;
|
|
24
20
|
type: "array";
|
|
25
|
-
|
|
21
|
+
itemType: SchemaArrayItemDefinition;
|
|
22
|
+
} | { type: "boolean" | "number"; } | {
|
|
23
|
+
type: "object";
|
|
24
|
+
fields: SchemaDefinition;
|
|
25
|
+
} | {
|
|
26
|
+
type: "string";
|
|
27
|
+
enum?: readonly string[];
|
|
28
|
+
}) & {
|
|
26
29
|
description?: string;
|
|
27
30
|
required?: boolean;
|
|
28
31
|
};
|
|
@@ -36,7 +39,7 @@ export type SchemaDefinitionData<TDefinition extends SchemaDefinition> = {
|
|
|
36
39
|
[K in keyof TDefinition as TDefinition[K] extends { required: true; } ? never : K]?: SchemaFieldData<TDefinition[K]>;
|
|
37
40
|
};
|
|
38
41
|
|
|
39
|
-
/** @privateRemark All
|
|
42
|
+
/** @privateRemark All agents are orchestrator-driven, so these channels exist for every agent graph. */
|
|
40
43
|
export type AgentRuntimeState = {
|
|
41
44
|
agentExecutionContext: AgentExecutionContext;
|
|
42
45
|
/** The outputMessage is a string representing the output of an agent execution. */
|
|
@@ -128,7 +131,6 @@ export type AgentNodeUpdate<TInput extends AgentData, TOutput extends AgentData>
|
|
|
128
131
|
* AgentStateAnnotation defines the shape of the agent state used in LangGraph nodes, including both the built-in runtime channels
|
|
129
132
|
* and any custom fields defined by the agent.
|
|
130
133
|
*
|
|
131
|
-
* @internal
|
|
132
134
|
* @since 5.1
|
|
133
135
|
*/
|
|
134
136
|
export type AgentStateAnnotation<TState extends AgentData> = AnnotationRoot<{
|
|
@@ -150,7 +152,6 @@ export type RunnableUpdate<TState extends AgentData> = Partial<TState> extends o
|
|
|
150
152
|
/**
|
|
151
153
|
* Internal type representing the compiled graph used for agent execution.
|
|
152
154
|
*
|
|
153
|
-
* @internal
|
|
154
155
|
* @since 5.1
|
|
155
156
|
*/
|
|
156
157
|
export type TypedStateGraph<TState extends AgentData> = StateGraph<StateDefinitionInit, AgentGraphState<TState>, RunnableUpdate<AgentGraphState<TState>>, string>;
|
|
@@ -159,7 +160,6 @@ export type TypedStateGraph<TState extends AgentData> = StateGraph<StateDefiniti
|
|
|
159
160
|
* The shape of the `createGraph` function used by agents to generate their internal graph representation.
|
|
160
161
|
* This function is responsible for defining the nodes and edges of the graph, as well as any associated state and middleware.
|
|
161
162
|
*
|
|
162
|
-
* @internal
|
|
163
163
|
* @since 5.1
|
|
164
164
|
*/
|
|
165
165
|
export type AgentCreateGraph<TState extends AgentData> = () => TypedStateGraph<TState>;
|
|
@@ -178,4 +178,4 @@ export type GraphEdge<S extends AgentData> = {
|
|
|
178
178
|
to: string;
|
|
179
179
|
};
|
|
180
180
|
|
|
181
|
-
export type SchemaFieldData<TField extends SchemaFieldDefinition> = TField extends { type: "string"; } ? TField["enum"] extends readonly (infer TValue extends string)[] ? TValue : string : TField extends { type: "array"; } ? (TField["itemType"] extends "string" ? string : TField["itemType"] extends "number" ? number : boolean)[] : TField extends { type: "number"; } ? number : boolean;
|
|
181
|
+
export type SchemaFieldData<TField extends SchemaFieldDefinition> = TField extends { type: "string"; } ? TField["enum"] extends readonly (infer TValue extends string)[] ? TValue : string : TField extends { type: "array"; } ? (TField["itemType"] extends "string" ? string : TField["itemType"] extends "number" ? number : TField["itemType"] extends "boolean" ? boolean : TField["itemType"] extends SchemaFieldDefinition ? SchemaFieldData<TField["itemType"]> : never)[] : TField extends { type: "object"; } ? SchemaDefinitionData<TField["fields"]> : TField extends { type: "number"; } ? number : boolean;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
+
import b from"./OP6ENMCN.js";import a from"./PFW7KXCP.js";import{a as m}from"./KGYSBUFO.js";import{a as k,b as E,ta as $}from"./H3EEFM4A.js";import{a as f}from"./QH6TSBNI.js";export default $arcgis.t(([,,,,,,{q:N,r:T},{a:b,b:v,c:x,d:C,e:F,f:R,g:L,h:_,i:I,j:M,k:Z,l:A,m:S,n:q,o:p,p:j}])=>{var w=[C,F,R,L,_,I,M,Z,A];async function G(e,t){let a=await S("navigation_tool_prompt"),{mapView:r}=x(t),c=r.map.bookmarks?.map(h=>h.name).filter(Boolean)??[],s=e.vectorSearchLayerResults?.length>0?e.vectorSearchLayerResults.map((h,z)=>`${z+1}. layerId=${h.id} | title=${h.title??""} | name=${h.name??""} | score=${h.score.toFixed(2)}`).join(`
|
|
3
|
+
`):"",l=e.vectorSearchFieldResults?.length>0?JSON.stringify(e.vectorSearchFieldResults,null,2):"",i=e.intent==="goToBookmark"&&c.length?`Available bookmarks:
|
|
4
|
+
${c.map(h=>`- ${h}`).join(`
|
|
5
|
+
`)}`:"",o=(e.intent==="goToLayer"||e.intent==="goToFeatures")&&e.vectorSearchLayerResults?.length?`Candidate layers:
|
|
6
|
+
${s}`:"",d=e.intent==="goToFeatures"&&e.vectorSearchFieldResults?.length?`Candidate fields:
|
|
7
|
+
${l}`:"",u={intent:e.intent,bookmarksSection:i,layersSection:o,fieldsSection:d,currentZoom:r.zoom,assignedTask:e.agentExecutionContext.assignedTask,userRequest:e.agentExecutionContext.userRequest,priorSteps:e.agentExecutionContext.priorSteps},n=await T({promptText:a,modelTier:"fast",config:t,inputVariables:u,tools:w}),g=(n.tool_calls?.length??0)>0,y=typeof n.text=="string"?n.text.trim():"",O=y.length>0;return{...e,navigationInternalState:{...e.navigationInternalState,toolCallMessage:g?n:void 0},outputMessage:g?e.outputMessage:y,status:g?e.status:O?"success":"failed"}}var B=e=>{let t=typeof e=="string"?e:String(e);try{let a=JSON.parse(t);if(a&&typeof a=="object"&&typeof a.text=="string")return a}catch{console.warn("Failed to parse tool response as JSON:",t)}return{text:t}};async function D(e,t){let a=new b(w,{handleToolErrors:!1});try{let r=e.navigationInternalState.toolCallMessage;if(!r)throw new Error("navigationToolCalling: missing navigationInternalState.toolCallMessage");let{messages:c}=await a.invoke({messages:[r]},t),s="",l;for(let i of c){let o=B(i.content);o.text&&(s+=`${o.text}
|
|
8
|
+
`),o.sharedStatePatch&&(l={...l,...o.sharedStatePatch})}return await m({text:`Finished executing navigation tool: ${s}`},t),{...e,outputMessage:s,sharedStatePatch:l,status:"success",summary:s?q(s):"Navigation executed.",navigationInternalState:{...e.navigationInternalState,toolCallMessage:void 0}}}catch(r){let c=r instanceof Error?r.message:String(r);return await m({text:`Navigation tool execution failed: ${c}`},t),{...e,outputMessage:`Navigation tool execution failed: ${c}`,status:"failed",summary:`Navigation tool execution failed: ${c}`,navigationInternalState:{...e.navigationInternalState,toolCallMessage:void 0}}}}async function J(e,t){let a=await S("navigation_intent_prompt"),{mapView:r}=x(t),c=w.map(n=>({name:n.name,description:n.description,schema:n.schema})),s=r.map.bookmarks?.map(n=>n.name).filter(Boolean)??[],l=s.length?`Available bookmarks:
|
|
9
|
+
${s.map(n=>`- ${n}`).join(`
|
|
10
|
+
`)}`:"No bookmarks are available in this map.",i={tools:c.map(({name:n,description:g,schema:y})=>`${n}: ${g}, ${JSON.stringify(y)}`).join(`
|
|
11
|
+
`),bookmarks:l,assignedTask:e.agentExecutionContext.assignedTask,userRequest:e.agentExecutionContext.userRequest,priorSteps:e.agentExecutionContext.priorSteps},o=f.object({intent:f.string()}),d=await N({promptText:a,config:t,inputVariables:i,schema:o,modelTier:"fast"}),u=typeof d.intent=="string"?d.intent.trim().replace(/^"|"$/gu,""):"";return{...e,intent:u||""}}var P=.7,W=async(e,t)=>{try{await m({text:`Similarity search to find layers: ${e.agentExecutionContext.assignedTask}`},t);let a=p(t,"layerSearch"),r=p(t,"layersAndFieldsRegistry"),c=p(t,"embeddingCache"),s=(await a.searchLayers({text:e.agentExecutionContext.assignedTask,minScore:P,embeddingCache:c})).map(({id:i,score:o})=>{let d=r.get(i)?.layerItem;return{id:i,title:d?.title,name:d?.name??void 0,score:o}}),l;return s.length>0?l=`Vector search completed. Matching layers:
|
|
12
|
+
${s.map(i=>`- layerId=${i.id} | title=${i.title??""} | name=${i.name??""} | score=${i.score.toFixed(2)}`).join(`
|
|
13
|
+
`)}`:l="Vector search completed. No matching layers found.",await m({text:l},t),{...e,vectorSearchLayerResults:s}}catch(a){throw await m({text:`Error during vector search layers: ${a instanceof Error?a.message:String(a)}`},t),a}},V=.7,H=10,K=async(e,t)=>{try{await m({text:`Similarity search to find fields: ${e.agentExecutionContext.assignedTask}`},t);let a=p(t,"fieldSearch"),r=p(t,"layersAndFieldsRegistry"),c=p(t,"embeddingCache"),s=e.vectorSearchLayerResults?.map(o=>o.id)??[];if(s.length===0)return await m({text:"No candidate layers for field search"},t),e;let l=(await a.searchFields({text:e.agentExecutionContext.assignedTask,layerIds:s,minScore:V,topResults:H,embeddingCache:c})).map(({layerId:o,results:d})=>{let u=r.get(o)?.fieldRegistry;return{layerId:o,layerName:r.get(o)?.layerItem.name,results:d.map(n=>{let g=u?.get(n.name);return{name:n.name,score:n.score,type:g?.type,alias:g?.alias,description:g?.description,statistics:g?.statistics}})}}),i;return l.length>0?i=`Vector search completed. Matching layers and fields:
|
|
14
|
+
${l.map(o=>`${o.layerName??o.layerId}:
|
|
15
|
+
${o.results.map(d=>` - ${d.name} (${d.score.toFixed(2)})`).join(`
|
|
16
|
+
`)}`).join(`
|
|
17
|
+
`)}`:i=`No vector search field results found for score over ${V}.`,await m({text:i},t),{...e,vectorSearchFieldResults:l}}catch(a){throw await m({text:`Error during vector search fields: ${a instanceof Error?a.message:String(a)}`},t),a}},Q=(e,t)=>j(["layerSearch","layersAndFieldsRegistry"],"Navigation Agent")(e,t),U=()=>new $(v).addNode("requireNavigationServices",Q).addNode("intentLLM",J).addNode("vectorSearchLayers",W).addNode("vectorSearchFields",K).addNode("agent",G).addNode("tools",D).addEdge(k,"requireNavigationServices").addEdge("requireNavigationServices","intentLLM").addConditionalEdges("intentLLM",e=>e.intent==="goToLayer"||e.intent==="goToFeatures"?"vectorSearchLayers":"agent",{vectorSearchLayers:"vectorSearchLayers",agent:"agent"}).addConditionalEdges("vectorSearchLayers",e=>e.intent==="goToFeatures"?"vectorSearchFields":"agent",{vectorSearchFields:"vectorSearchFields",agent:"agent"}).addEdge("vectorSearchFields","agent").addEdge("agent","tools").addEdge("tools",E),X=String.raw`- **navigation** — Enables users to interact with the map by navigating to specific locations, layers, features, or extents.
|
|
18
|
+
This includes zooming, panning, centering, or geocoding based on user input. The agent is designed to handle explicit map movement requests. NOTE: DO NOT call this agent if the user asks "show me...", that is meant to be handled by another agent. If the query is about where a certain address is, call this agent.
|
|
19
|
+
|
|
20
|
+
Supported actions:
|
|
21
|
+
- **Zooming**: Adjust the map's zoom level (e.g., "Zoom to level 10", "Zoom in").
|
|
22
|
+
- **Viewpoints**: Navigate to a specific center point with optional zoom or scale (e.g., "Center the map on San Francisco at zoom level 16").
|
|
23
|
+
- **Scales**: Set the map to a specific scale (e.g., "Set the map scale to 1:50,000").
|
|
24
|
+
- **Layers**: Zoom to the full extent of a specific layer (e.g., "Go to the water mains layer"). For the purposes of link charts, if the user requests to go to the extent of a link chart or the entities/nodes within it, that should be treated as a request to use the goToLayer tool on the link chart layer
|
|
25
|
+
- **Features**: Zoom to features in a layer that match a filter (e.g., "Zoom to all schools in the city").
|
|
26
|
+
- **Bookmarks**: Navigate to a predefined bookmark extent (e.g., "Go to the Downtown bookmark").
|
|
27
|
+
- **Extents**: Reset to the initial web map extent or zoom to the full world extent (e.g., "Reset the map", "Zoom to the full world extent").
|
|
28
|
+
- **Addresses**: Zoom to an address or place name (e.g., "Zoom to 1600 Pennsylvania Ave").
|
|
29
|
+
|
|
30
|
+
_Example: “Zoom to Texas”_
|
|
31
|
+
_Example: “Go to the water mains layer”_
|
|
32
|
+
_Example: “Zoom to to the extent of my link chart”_
|
|
33
|
+
_Example: “Center the map on San Francisco at scale 50000”_
|
|
34
|
+
_Example: “Zoom to the features in the schools layer where city = 'Austin'”_
|
|
35
|
+
_Example: “Go to the Downtown bookmark”_
|
|
36
|
+
_Example: “Where is Mount Rainier?”_`,ue={id:"navigation",name:"Navigation Agent",description:X,createGraph:U,workspace:v};return ue},"identity/IdentityManager","portal/Portal","config","core/reactiveUtils","layers/FeatureLayer","request",a,b)
|