@arcgis/ai-orchestrator 5.1.0-next.9 → 5.1.0-next.91
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/assets/embeddings.worker-k9_Ou679.js +1 -0
- package/dist/dispatcherAgent/reducers/commonReducers.d.ts +1 -0
- package/dist/dispatcherAgent/state/dispatcherGraphState.d.ts +5 -5
- package/dist/dispatcherAgent/utils/agentResultUtils.d.ts +7 -0
- package/dist/dispatcherAgent/utils/sharedStateUtils.d.ts +7 -0
- package/dist/embeddings/cosineSimilarity.d.ts +12 -0
- package/dist/embeddings/embeddings-parser.d.ts +1 -1
- package/dist/embeddings/fetchWebMapEmbeddings.d.ts +1 -1
- package/dist/embeddings/mmr.d.ts +16 -0
- package/dist/embeddings/webmapEmbeddings.d.ts +1 -2
- package/dist/embeddings/webmapSchema.d.ts +8 -114
- package/dist/embeddings.worker-GH7zdYqF.js +24 -0
- package/dist/index.d.ts +5 -1
- package/dist/index.js +634 -457
- package/dist/intent_prompt-D6yvMy34.js +122 -0
- package/dist/llm/generateFieldDescriptions.d.ts +1 -1
- package/dist/llm/generateLayerAndFieldDescription.d.ts +1 -1
- package/dist/llm/generateLayerDescriptions.d.ts +2 -10
- package/dist/models/types.d.ts +1 -1
- package/dist/orchestrator/orchestrator.d.ts +4 -2
- package/dist/orchestrator/orchestratorEvents.d.ts +5 -6
- package/dist/registry/agentRegistry.d.ts +2 -1
- package/dist/types/types.d.ts +37 -2
- package/dist/utils/contextSelectors.d.ts +2 -0
- package/dist/utils/invokeAgent.d.ts +21 -0
- package/package.json +7 -6
- package/dist/assets/embeddings.worker-23-pYuaK.js +0 -1
- package/dist/dispatcherAgent/nodes/intentDispatcher.d.ts +0 -2
- package/dist/embeddings.worker-Do8Eo8LT.js +0 -24
- package/dist/intent_prompt-CRmsldou.js +0 -22
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(){"use strict";const h=(a,r)=>{if(a.length!==r.length)throw new Error("Vectors must be the same length");let c=0,t=0,e=0;for(let n=0;n<a.length;++n){const s=a[n],l=r[n];c+=s*l,t+=s*s,e+=l*l}const i=Math.sqrt(t*e);if(i===0)return 0;const m=c/i;return Math.max(-1,Math.min(1,m))},f=(a,r,c=.6)=>{const t=[],e=[...a];for(;t.length<r&&e.length>0;){let i=-1,m=-1/0;for(let n=0;n<e.length;n++){const s=e[n].score,l=t.length===0?0:Math.max(...t.map(o=>h(e[n].vector,o.vector))),d=c*s-(1-c)*l;d>m&&(m=d,i=n)}t.push(e[i]),e.splice(i,1)}return t.map(({name:i,score:m})=>({name:i,score:m}))};let p=[];const u=new Map,v=12,y=10,M=a=>{p=a.layers.map(r=>({id:r.id,vector:r.vector}))},E=a=>{u.clear();for(const r of a.layers){const c=r.fields.map(t=>({name:t.name,vector:t.vector}));u.set(r.id,c)}};globalThis.addEventListener("message",a=>{(async()=>{const{type:r,webmapEmbeddings:c,layerIdForFieldsSearch:t=[],requestId:e,precomputedEmbedding:i,minScore:m=0,topResults:n=v}=a.data;switch(r){case"generateEmbeddings":{c&&(M(c),E(c)),globalThis.postMessage("completed");break}case"layerSearch":{if(p.length>0)try{const s=p.map(o=>({id:o.id,vector:o.vector,score:h(i,o.vector)})),d=f(s.map(o=>({name:o.id,vector:o.vector,score:o.score})),y).map(({name:o,score:b})=>({id:o,score:b}));globalThis.postMessage({requestId:e,results:d})}catch(s){globalThis.postMessage({requestId:e,results:[],error:s instanceof Error?s.message:"Calculation error"})}else globalThis.postMessage({requestId:e,results:[],error:"Layer embeddings not initialized"});break}case"fieldSearch":{if(t.length>0)try{const s=t.map(l=>{const d=u.get(l);if(!d)return{layerId:l,results:[]};const o=d.map(g=>({name:g.name,vector:g.vector,score:h(i,g.vector)})).filter(({score:g})=>g>=m),b=f(o,n);return{layerId:l,results:b}});globalThis.postMessage({requestId:e,results:s})}catch(s){globalThis.postMessage({requestId:e,results:[],error:s instanceof Error?s.message:"Field search calculation error"})}break}default:console.warn("Unknown message type:",r)}})()})})();
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AgentExecutionContext } from '../../types/types';
|
|
2
2
|
export declare const DispatcherGraphState: import('@langchain/langgraph').AnnotationRoot<{
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
agentExecutionContext: import('@langchain/langgraph').BaseChannel<AgentExecutionContext, AgentExecutionContext | import('@langchain/langgraph').OverwriteValue<AgentExecutionContext>, unknown>;
|
|
4
|
+
currentIntent: import('@langchain/langgraph').BaseChannel<string, string | import('@langchain/langgraph').OverwriteValue<string>, unknown>;
|
|
5
|
+
requiresFollowUp: import('@langchain/langgraph').BaseChannel<boolean, boolean | import('@langchain/langgraph').OverwriteValue<boolean>, unknown>;
|
|
6
|
+
stepCount: import('@langchain/langgraph').BaseChannel<number, number | import('@langchain/langgraph').OverwriteValue<number>, unknown>;
|
|
7
7
|
}>;
|
|
8
8
|
export type DispatcherGraphStateType = typeof DispatcherGraphState.State;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { SharedStatePatch, SharedState } from '../../types/types';
|
|
2
|
+
export declare const toSharedStatePatch: (value: unknown, agentName: string) => SharedStatePatch | undefined;
|
|
3
|
+
export declare const applySharedStatePatch: (params: {
|
|
4
|
+
previousSharedState: SharedState;
|
|
5
|
+
patch?: SharedStatePatch;
|
|
6
|
+
agentId: string;
|
|
7
|
+
}) => SharedState;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Calculates the cosine similarity between two numeric vectors.
|
|
3
|
+
* * This implementation is safeguarded against zero-magnitudes (returns 0)
|
|
4
|
+
* and ensures the result is clamped between -1 and 1 to account for
|
|
5
|
+
* floating-point precision errors.
|
|
6
|
+
*
|
|
7
|
+
* @param a - The first vector array.
|
|
8
|
+
* @param b - The second vector array.
|
|
9
|
+
* @returns A similarity score from -1 (opposite) to 1 (identical).
|
|
10
|
+
* @throws {Error} If the vectors have different lengths.
|
|
11
|
+
*/
|
|
12
|
+
export declare const cosineSimilarity: (a: number[], b: number[]) => number;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { LayersAndFieldsRegistry } from '../types/types';
|
|
2
2
|
import { VectorizedLayer } from './webmapEmbeddings';
|
|
3
3
|
import { WebmapEmbedding } from './webmapSchema';
|
|
4
|
-
import { default as ArcGISMap } from '@arcgis/core/Map';
|
|
4
|
+
import { default as ArcGISMap } from '@arcgis/core/Map.js';
|
|
5
5
|
export declare const validateEmbeddingsResponse: (data: unknown) => WebmapEmbedding;
|
|
6
6
|
export declare const restoreRegistryFromVectorsAndValidation: (vectorizedLayers: VectorizedLayer[], arcgisMap: ArcGISMap) => LayersAndFieldsRegistry;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Maximal Marginal Relevance selection.
|
|
3
|
+
* Balances relevance to the query against redundancy with already-selected items.
|
|
4
|
+
*
|
|
5
|
+
* @param candidates - Scored candidates with their vectors retained
|
|
6
|
+
* @param topK - How many results to return
|
|
7
|
+
* @param lambda - 0 = max diversity, 1 = max relevance
|
|
8
|
+
*/
|
|
9
|
+
export declare const maximalMarginalRelevance: (candidates: {
|
|
10
|
+
name: string;
|
|
11
|
+
vector: number[];
|
|
12
|
+
score: number;
|
|
13
|
+
}[], topK: number, lambda?: number) => {
|
|
14
|
+
name: string;
|
|
15
|
+
score: number;
|
|
16
|
+
}[];
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { WebmapEmbedding } from './webmapSchema';
|
|
2
|
-
import { default as MapView } from '@arcgis/core/views/MapView';
|
|
2
|
+
import { default as MapView } from '@arcgis/core/views/MapView.js';
|
|
3
3
|
export type VectorizedLayer = WebmapEmbedding["layers"][number];
|
|
4
|
-
export type VectorizedField = VectorizedLayer["fields"][number];
|
|
5
4
|
/**
|
|
6
5
|
* Generates a structured, vectorized representation of a Webmap's layers and fields.
|
|
7
6
|
* * Extracts metadata from the MapView, generates embeddings using a batched
|
|
@@ -15,126 +15,20 @@ export declare const WebmapEmbeddingSchema: z.ZodObject<{
|
|
|
15
15
|
templates: z.ZodObject<{
|
|
16
16
|
layer: z.ZodDefault<z.ZodString>;
|
|
17
17
|
field: z.ZodDefault<z.ZodString>;
|
|
18
|
-
},
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}, {
|
|
22
|
-
layer?: string | undefined;
|
|
23
|
-
field?: string | undefined;
|
|
24
|
-
}>;
|
|
25
|
-
}, "strip", z.ZodTypeAny, {
|
|
26
|
-
modelProvider: "openai";
|
|
27
|
-
model: string;
|
|
28
|
-
dimensions: 1536;
|
|
29
|
-
templates: {
|
|
30
|
-
layer: string;
|
|
31
|
-
field: string;
|
|
32
|
-
};
|
|
33
|
-
}, {
|
|
34
|
-
modelProvider: "openai";
|
|
35
|
-
model: string;
|
|
36
|
-
dimensions: 1536;
|
|
37
|
-
templates: {
|
|
38
|
-
layer?: string | undefined;
|
|
39
|
-
field?: string | undefined;
|
|
40
|
-
};
|
|
41
|
-
}>;
|
|
42
|
-
layers: z.ZodArray<z.ZodObject<{
|
|
18
|
+
}, z.core.$strip>;
|
|
19
|
+
}, z.core.$strip>;
|
|
20
|
+
layers: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
43
21
|
id: z.ZodString;
|
|
44
22
|
name: z.ZodString;
|
|
45
23
|
title: z.ZodCatch<z.ZodString>;
|
|
46
24
|
description: z.ZodCatch<z.ZodString>;
|
|
47
|
-
vector: z.ZodArray<z.ZodNumber
|
|
25
|
+
vector: z.ZodArray<z.ZodNumber>;
|
|
48
26
|
fields: z.ZodArray<z.ZodObject<{
|
|
49
27
|
name: z.ZodString;
|
|
50
28
|
alias: z.ZodCatch<z.ZodString>;
|
|
51
29
|
description: z.ZodCatch<z.ZodString>;
|
|
52
|
-
vector: z.ZodArray<z.ZodNumber
|
|
53
|
-
},
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
vector: number[];
|
|
57
|
-
alias: string;
|
|
58
|
-
}, {
|
|
59
|
-
name: string;
|
|
60
|
-
vector: number[];
|
|
61
|
-
description?: unknown;
|
|
62
|
-
alias?: unknown;
|
|
63
|
-
}>, "many">;
|
|
64
|
-
}, "strip", z.ZodTypeAny, {
|
|
65
|
-
id: string;
|
|
66
|
-
name: string;
|
|
67
|
-
title: string;
|
|
68
|
-
description: string;
|
|
69
|
-
vector: number[];
|
|
70
|
-
fields: {
|
|
71
|
-
name: string;
|
|
72
|
-
description: string;
|
|
73
|
-
vector: number[];
|
|
74
|
-
alias: string;
|
|
75
|
-
}[];
|
|
76
|
-
}, {
|
|
77
|
-
id: string;
|
|
78
|
-
name: string;
|
|
79
|
-
vector: number[];
|
|
80
|
-
fields: {
|
|
81
|
-
name: string;
|
|
82
|
-
vector: number[];
|
|
83
|
-
description?: unknown;
|
|
84
|
-
alias?: unknown;
|
|
85
|
-
}[];
|
|
86
|
-
title?: unknown;
|
|
87
|
-
description?: unknown;
|
|
88
|
-
}>, "many">;
|
|
89
|
-
}, "strip", z.ZodTypeAny, {
|
|
90
|
-
schemaVersion: "0.1";
|
|
91
|
-
modified: number;
|
|
92
|
-
embeddings: {
|
|
93
|
-
modelProvider: "openai";
|
|
94
|
-
model: string;
|
|
95
|
-
dimensions: 1536;
|
|
96
|
-
templates: {
|
|
97
|
-
layer: string;
|
|
98
|
-
field: string;
|
|
99
|
-
};
|
|
100
|
-
};
|
|
101
|
-
layers: {
|
|
102
|
-
id: string;
|
|
103
|
-
name: string;
|
|
104
|
-
title: string;
|
|
105
|
-
description: string;
|
|
106
|
-
vector: number[];
|
|
107
|
-
fields: {
|
|
108
|
-
name: string;
|
|
109
|
-
description: string;
|
|
110
|
-
vector: number[];
|
|
111
|
-
alias: string;
|
|
112
|
-
}[];
|
|
113
|
-
}[];
|
|
114
|
-
}, {
|
|
115
|
-
schemaVersion: "0.1";
|
|
116
|
-
modified: number;
|
|
117
|
-
embeddings: {
|
|
118
|
-
modelProvider: "openai";
|
|
119
|
-
model: string;
|
|
120
|
-
dimensions: 1536;
|
|
121
|
-
templates: {
|
|
122
|
-
layer?: string | undefined;
|
|
123
|
-
field?: string | undefined;
|
|
124
|
-
};
|
|
125
|
-
};
|
|
126
|
-
layers: {
|
|
127
|
-
id: string;
|
|
128
|
-
name: string;
|
|
129
|
-
vector: number[];
|
|
130
|
-
fields: {
|
|
131
|
-
name: string;
|
|
132
|
-
vector: number[];
|
|
133
|
-
description?: unknown;
|
|
134
|
-
alias?: unknown;
|
|
135
|
-
}[];
|
|
136
|
-
title?: unknown;
|
|
137
|
-
description?: unknown;
|
|
138
|
-
}[];
|
|
139
|
-
}>;
|
|
30
|
+
vector: z.ZodArray<z.ZodNumber>;
|
|
31
|
+
}, z.core.$strip>>;
|
|
32
|
+
}, z.core.$strip>>>;
|
|
33
|
+
}, z.core.$strip>;
|
|
140
34
|
export type WebmapEmbedding = z.infer<typeof WebmapEmbeddingSchema>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
const o = `(function(){"use strict";const h=(a,r)=>{if(a.length!==r.length)throw new Error("Vectors must be the same length");let c=0,t=0,e=0;for(let n=0;n<a.length;++n){const s=a[n],l=r[n];c+=s*l,t+=s*s,e+=l*l}const i=Math.sqrt(t*e);if(i===0)return 0;const m=c/i;return Math.max(-1,Math.min(1,m))},f=(a,r,c=.6)=>{const t=[],e=[...a];for(;t.length<r&&e.length>0;){let i=-1,m=-1/0;for(let n=0;n<e.length;n++){const s=e[n].score,l=t.length===0?0:Math.max(...t.map(o=>h(e[n].vector,o.vector))),d=c*s-(1-c)*l;d>m&&(m=d,i=n)}t.push(e[i]),e.splice(i,1)}return t.map(({name:i,score:m})=>({name:i,score:m}))};let p=[];const u=new Map,v=12,y=10,M=a=>{p=a.layers.map(r=>({id:r.id,vector:r.vector}))},E=a=>{u.clear();for(const r of a.layers){const c=r.fields.map(t=>({name:t.name,vector:t.vector}));u.set(r.id,c)}};globalThis.addEventListener("message",a=>{(async()=>{const{type:r,webmapEmbeddings:c,layerIdForFieldsSearch:t=[],requestId:e,precomputedEmbedding:i,minScore:m=0,topResults:n=v}=a.data;switch(r){case"generateEmbeddings":{c&&(M(c),E(c)),globalThis.postMessage("completed");break}case"layerSearch":{if(p.length>0)try{const s=p.map(o=>({id:o.id,vector:o.vector,score:h(i,o.vector)})),d=f(s.map(o=>({name:o.id,vector:o.vector,score:o.score})),y).map(({name:o,score:b})=>({id:o,score:b}));globalThis.postMessage({requestId:e,results:d})}catch(s){globalThis.postMessage({requestId:e,results:[],error:s instanceof Error?s.message:"Calculation error"})}else globalThis.postMessage({requestId:e,results:[],error:"Layer embeddings not initialized"});break}case"fieldSearch":{if(t.length>0)try{const s=t.map(l=>{const d=u.get(l);if(!d)return{layerId:l,results:[]};const o=d.map(g=>({name:g.name,vector:g.vector,score:h(i,g.vector)})).filter(({score:g})=>g>=m),b=f(o,n);return{layerId:l,results:b}});globalThis.postMessage({requestId:e,results:s})}catch(s){globalThis.postMessage({requestId:e,results:[],error:s instanceof Error?s.message:"Field search calculation error"})}break}default:console.warn("Unknown message type:",r)}})()})})();
|
|
2
|
+
`, s = typeof self < "u" && self.Blob && new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);", o], { type: "text/javascript;charset=utf-8" });
|
|
3
|
+
function a(r) {
|
|
4
|
+
let e;
|
|
5
|
+
try {
|
|
6
|
+
if (e = s && (self.URL || self.webkitURL).createObjectURL(s), !e) throw "";
|
|
7
|
+
const t = new Worker(e, {
|
|
8
|
+
name: r?.name
|
|
9
|
+
});
|
|
10
|
+
return t.addEventListener("error", () => {
|
|
11
|
+
(self.URL || self.webkitURL).revokeObjectURL(e);
|
|
12
|
+
}), t;
|
|
13
|
+
} catch {
|
|
14
|
+
return new Worker(
|
|
15
|
+
"data:text/javascript;charset=utf-8," + encodeURIComponent(o),
|
|
16
|
+
{
|
|
17
|
+
name: r?.name
|
|
18
|
+
}
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
export {
|
|
23
|
+
a as default
|
|
24
|
+
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
export { Orchestrator } from './orchestrator/orchestrator';
|
|
2
2
|
export { sendTraceMessage, sendUXSuggestion } from './signals';
|
|
3
3
|
export { invokeTextPrompt, invokeStructuredPrompt, invokeToolPrompt } from './providers/arcgis/promptChain';
|
|
4
|
+
export { createChatModel } from './providers/arcgis/aiFactory';
|
|
4
5
|
export { createWebmapEmbeddings } from './embeddings/webmapEmbeddings';
|
|
5
|
-
export
|
|
6
|
+
export { getEmbeddings } from './embeddings/embeddingsUtil';
|
|
7
|
+
export { cosineSimilarity } from './embeddings/cosineSimilarity';
|
|
8
|
+
export type { CustomConfigurableType, VectorSearchFieldResults, LayersAndFieldsRegistry, Services, FieldInfo, FieldStatistics, ChatHistory, AgentExecutionContext, AgentStatus, PriorStep, SharedState, SharedStatePatch, } from './types/types';
|
|
9
|
+
export type { UXSuggestion } from './orchestrator/orchestratorEvents';
|
|
6
10
|
export type { UiInterrupt } from './hitl/types';
|
|
7
11
|
export type { AgentRegistration, AgentWithContext } from './registry/agentRegistry';
|