maplibre-gl-geoagent 0.4.0 → 0.4.2
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/README.md +40 -0
- package/dist/{GeoAgentControl-C0NqjEWe.js → GeoAgentControl-CM-lWHhd.js} +57 -15
- package/dist/{GeoAgentControl-C0NqjEWe.js.map → GeoAgentControl-CM-lWHhd.js.map} +1 -1
- package/dist/{GeoAgentControl-Dpr36122.cjs → GeoAgentControl-NjhimZRg.cjs} +57 -15
- package/dist/{GeoAgentControl-Dpr36122.cjs.map → GeoAgentControl-NjhimZRg.cjs.map} +1 -1
- package/dist/{anthropic-BkJWRsGY.cjs → anthropic-poATb89G.cjs} +2 -2
- package/dist/{anthropic-BkJWRsGY.cjs.map → anthropic-poATb89G.cjs.map} +1 -1
- package/dist/{anthropic-B3q8CswR.js → anthropic-qn30x05g.js} +2 -2
- package/dist/{anthropic-B3q8CswR.js.map → anthropic-qn30x05g.js.map} +1 -1
- package/dist/{browser-6nQo2Odo.js → browser-CRRVT6sN.js} +2 -2
- package/dist/{browser-6nQo2Odo.js.map → browser-CRRVT6sN.js.map} +1 -1
- package/dist/{browser-D6gmHQqD.cjs → browser-DfKdZvWC.cjs} +2 -2
- package/dist/{browser-D6gmHQqD.cjs.map → browser-DfKdZvWC.cjs.map} +1 -1
- package/dist/{index-CbFlyAAM.cjs → index-BHJHkcUd.cjs} +2 -2
- package/dist/{index-CbFlyAAM.cjs.map → index-BHJHkcUd.cjs.map} +1 -1
- package/dist/{index-DZcJF5D6.js → index-CCdoSNb8.js} +2 -2
- package/dist/{index-DZcJF5D6.js.map → index-CCdoSNb8.js.map} +1 -1
- package/dist/{index-CEnhCAzc.cjs → index-D8NXbhES.cjs} +2 -2
- package/dist/{index-CEnhCAzc.cjs.map → index-D8NXbhES.cjs.map} +1 -1
- package/dist/{index-Bi9NrqmL.js → index-DMcVy720.js} +2 -2
- package/dist/{index-Bi9NrqmL.js.map → index-DMcVy720.js.map} +1 -1
- package/dist/{index-B51VnjHA.cjs → index-DUXFjmo_.cjs} +2 -2
- package/dist/{index-B51VnjHA.cjs.map → index-DUXFjmo_.cjs.map} +1 -1
- package/dist/{index-CBRcDJl6.js → index-nbt2E_lW.js} +2 -2
- package/dist/{index-CBRcDJl6.js.map → index-nbt2E_lW.js.map} +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +1 -1
- package/dist/react.cjs +1 -1
- package/dist/react.mjs +1 -1
- package/dist/types/lib/core/GeoAgentControl.d.ts.map +1 -1
- package/dist/types/lib/core/earth-engine.d.ts +5 -0
- package/dist/types/lib/core/earth-engine.d.ts.map +1 -1
- package/dist/types/lib/core/types.d.ts +9 -2
- package/dist/types/lib/core/types.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -131,6 +131,7 @@ Converse model ID, and set the AWS region. The default Bedrock model is
|
|
|
131
131
|
| `defaultProvider` | `GeoAgentProviderId` | `'openai-responses'` |
|
|
132
132
|
| `defaultModel` | `string \| Partial<Record<GeoAgentProviderId, string>>` | provider default |
|
|
133
133
|
| `storagePrefix` | `string` | `'geoagent.maplibre'` |
|
|
134
|
+
| `apiKeys` | `Partial<Record<GeoAgentProviderId, string>>` | `undefined` |
|
|
134
135
|
| `allowCodeExecutionDefault` | `boolean` | `true` |
|
|
135
136
|
| `allowDestructiveToolsDefault` | `boolean` | `true` |
|
|
136
137
|
| `showPermissionToggles` | `boolean` | `false` |
|
|
@@ -154,6 +155,27 @@ The Earth Engine integration uses browser OAuth through the official
|
|
|
154
155
|
not supported in this browser-only package. Use a backend proxy if your
|
|
155
156
|
deployment needs service account access.
|
|
156
157
|
|
|
158
|
+
Host applications that already authenticate Earth Engine outside the browser
|
|
159
|
+
can provide a short-lived OAuth access token instead of launching browser
|
|
160
|
+
OAuth:
|
|
161
|
+
|
|
162
|
+
```typescript
|
|
163
|
+
new GeoAgentControl({
|
|
164
|
+
earthEngine: {
|
|
165
|
+
accessToken: "SHORT_LIVED_EARTH_ENGINE_ACCESS_TOKEN",
|
|
166
|
+
tokenType: "Bearer",
|
|
167
|
+
tokenExpiresIn: 3600,
|
|
168
|
+
projectId: "your-earth-engine-project",
|
|
169
|
+
includeCommunityCatalog: true,
|
|
170
|
+
},
|
|
171
|
+
});
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
Access tokens are passed to the browser JavaScript runtime and should be
|
|
175
|
+
short-lived. Do not persist them in page source, notebooks, local storage, or
|
|
176
|
+
session storage. For untrusted users or production deployments, prefer a
|
|
177
|
+
backend proxy.
|
|
178
|
+
|
|
157
179
|
## Browser Credentials
|
|
158
180
|
|
|
159
181
|
This package runs model SDKs directly in the browser. API keys entered in the
|
|
@@ -162,6 +184,24 @@ are sent directly from the page to the selected model provider. Use this for
|
|
|
162
184
|
local development, trusted internal apps, or apps that intentionally expose a
|
|
163
185
|
browser-compatible credential path.
|
|
164
186
|
|
|
187
|
+
Host applications can prefill the panel with initial API keys:
|
|
188
|
+
|
|
189
|
+
```typescript
|
|
190
|
+
new GeoAgentControl({
|
|
191
|
+
apiKeys: {
|
|
192
|
+
"openai-responses": "OPENAI_API_KEY_VALUE",
|
|
193
|
+
"openai-chat": "OPENAI_API_KEY_VALUE",
|
|
194
|
+
anthropic: "ANTHROPIC_API_KEY_VALUE",
|
|
195
|
+
google: "GOOGLE_API_KEY_VALUE",
|
|
196
|
+
bedrock: "AWS_BEARER_TOKEN_BEDROCK_VALUE",
|
|
197
|
+
},
|
|
198
|
+
});
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
Saved `sessionStorage` values take precedence over `apiKeys`. Initial keys are
|
|
202
|
+
kept in browser memory and are not written to storage unless the user edits the
|
|
203
|
+
API key field.
|
|
204
|
+
|
|
165
205
|
For Amazon Bedrock, this browser-only control uses Bedrock API-key bearer-token
|
|
166
206
|
authentication. Do not enter AWS access key IDs, secret access keys, or session
|
|
167
207
|
tokens in this UI. For production Bedrock deployments, prefer a backend proxy
|
|
@@ -3518,7 +3518,7 @@ class HttpProtocol extends SerdeContext {
|
|
|
3518
3518
|
});
|
|
3519
3519
|
}
|
|
3520
3520
|
async loadEventStreamCapability() {
|
|
3521
|
-
const { EventStreamSerde } = await import("./index-
|
|
3521
|
+
const { EventStreamSerde } = await import("./index-DMcVy720.js");
|
|
3522
3522
|
return new EventStreamSerde({
|
|
3523
3523
|
marshaller: this.getEventStreamMarshaller(),
|
|
3524
3524
|
serializer: this.serializer,
|
|
@@ -42584,6 +42584,10 @@ function normalizeOptionalString(value) {
|
|
|
42584
42584
|
const text2 = String(value ?? "").trim();
|
|
42585
42585
|
return text2 ? text2 : void 0;
|
|
42586
42586
|
}
|
|
42587
|
+
function normalizeTokenExpiresIn(value) {
|
|
42588
|
+
const seconds = Number(value);
|
|
42589
|
+
return Number.isFinite(seconds) && seconds > 0 ? seconds : 3600;
|
|
42590
|
+
}
|
|
42587
42591
|
class EarthEngineService {
|
|
42588
42592
|
constructor(options = {}) {
|
|
42589
42593
|
__publicField(this, "eePromise", null);
|
|
@@ -42598,10 +42602,12 @@ class EarthEngineService {
|
|
|
42598
42602
|
updateOptions(options) {
|
|
42599
42603
|
const previousOauthClientId = normalizeOptionalString(this.options.oauthClientId);
|
|
42600
42604
|
const previousProjectId = normalizeOptionalString(this.options.projectId);
|
|
42605
|
+
const previousAccessToken = normalizeOptionalString(this.options.accessToken);
|
|
42601
42606
|
const nextOauthClientId = normalizeOptionalString(options.oauthClientId);
|
|
42602
42607
|
const nextProjectId = normalizeOptionalString(options.projectId);
|
|
42608
|
+
const nextAccessToken = normalizeOptionalString(options.accessToken);
|
|
42603
42609
|
this.options = { ...this.options, ...options };
|
|
42604
|
-
if (previousOauthClientId !== nextOauthClientId || previousProjectId !== nextProjectId) {
|
|
42610
|
+
if (previousOauthClientId !== nextOauthClientId || previousProjectId !== nextProjectId || previousAccessToken !== nextAccessToken) {
|
|
42605
42611
|
this.initialized = false;
|
|
42606
42612
|
this.initializedProjectId = void 0;
|
|
42607
42613
|
this.tileUrlCache.clear();
|
|
@@ -42658,7 +42664,7 @@ class EarthEngineService {
|
|
|
42658
42664
|
}
|
|
42659
42665
|
async loadEe() {
|
|
42660
42666
|
if (!this.eePromise) {
|
|
42661
|
-
this.eePromise = import("./browser-
|
|
42667
|
+
this.eePromise = import("./browser-CRRVT6sN.js").then((n) => n.b).then((module) => {
|
|
42662
42668
|
const imported = "default" in module ? module.default : module;
|
|
42663
42669
|
const ee = imported;
|
|
42664
42670
|
const scope2 = globalThis;
|
|
@@ -42722,6 +42728,11 @@ class EarthEngineService {
|
|
|
42722
42728
|
}
|
|
42723
42729
|
async ensureAuthenticated(ee, oauthClientId) {
|
|
42724
42730
|
var _a3, _b3, _c3, _d2, _e2, _f2;
|
|
42731
|
+
const configuredAccessToken = normalizeOptionalString(this.options.accessToken);
|
|
42732
|
+
if (configuredAccessToken) {
|
|
42733
|
+
await this.applyAccessToken(ee, oauthClientId, configuredAccessToken);
|
|
42734
|
+
return;
|
|
42735
|
+
}
|
|
42725
42736
|
const token = (_b3 = (_a3 = ee.data) == null ? void 0 : _a3.getAuthToken) == null ? void 0 : _b3.call(_a3);
|
|
42726
42737
|
const currentAuthClientId = normalizeOptionalString((_d2 = (_c3 = ee.data) == null ? void 0 : _c3.getAuthClientId) == null ? void 0 : _d2.call(_c3));
|
|
42727
42738
|
if (token) {
|
|
@@ -42766,6 +42777,32 @@ class EarthEngineService {
|
|
|
42766
42777
|
});
|
|
42767
42778
|
return this.authPromise;
|
|
42768
42779
|
}
|
|
42780
|
+
async applyAccessToken(ee, oauthClientId, accessToken) {
|
|
42781
|
+
var _a3;
|
|
42782
|
+
if (!((_a3 = ee.data) == null ? void 0 : _a3.setAuthToken)) {
|
|
42783
|
+
throw new Error("Earth Engine token authentication is unavailable.");
|
|
42784
|
+
}
|
|
42785
|
+
const clientId = oauthClientId ?? "";
|
|
42786
|
+
const tokenType = normalizeOptionalString(this.options.tokenType) ?? "Bearer";
|
|
42787
|
+
const expiresIn = normalizeTokenExpiresIn(this.options.tokenExpiresIn);
|
|
42788
|
+
await new Promise((resolve2, reject) => {
|
|
42789
|
+
var _a4, _b3;
|
|
42790
|
+
try {
|
|
42791
|
+
(_b3 = (_a4 = ee.data) == null ? void 0 : _a4.setAuthToken) == null ? void 0 : _b3.call(
|
|
42792
|
+
_a4,
|
|
42793
|
+
clientId,
|
|
42794
|
+
tokenType,
|
|
42795
|
+
accessToken,
|
|
42796
|
+
expiresIn,
|
|
42797
|
+
[],
|
|
42798
|
+
resolve2,
|
|
42799
|
+
false
|
|
42800
|
+
);
|
|
42801
|
+
} catch (error) {
|
|
42802
|
+
reject(new Error(eeErrorMessage(error)));
|
|
42803
|
+
}
|
|
42804
|
+
});
|
|
42805
|
+
}
|
|
42769
42806
|
async catalog(includeCommunity = this.options.includeCommunityCatalog ?? true) {
|
|
42770
42807
|
const key = includeCommunity ? "all" : "official";
|
|
42771
42808
|
const ttl = this.options.catalogCacheTtlMs ?? DEFAULT_CATALOG_CACHE_TTL_MS;
|
|
@@ -46006,6 +46043,7 @@ class GeoAgentControl {
|
|
|
46006
46043
|
allowDestructiveToolsDefault: options.allowDestructiveToolsDefault ?? true,
|
|
46007
46044
|
showPermissionToggles: options.showPermissionToggles ?? false,
|
|
46008
46045
|
defaultModel: options.defaultModel,
|
|
46046
|
+
apiKeys: options.apiKeys,
|
|
46009
46047
|
basemaps: options.basemaps,
|
|
46010
46048
|
earthEngine: options.earthEngine
|
|
46011
46049
|
};
|
|
@@ -46370,7 +46408,7 @@ class GeoAgentControl {
|
|
|
46370
46408
|
}
|
|
46371
46409
|
}
|
|
46372
46410
|
setupEarthEngineControls() {
|
|
46373
|
-
var _a3, _b3;
|
|
46411
|
+
var _a3, _b3, _c3;
|
|
46374
46412
|
if (!this.ui) {
|
|
46375
46413
|
return;
|
|
46376
46414
|
}
|
|
@@ -46382,13 +46420,14 @@ class GeoAgentControl {
|
|
|
46382
46420
|
const oauthClientId = firstValue(
|
|
46383
46421
|
(_a3 = this.options.earthEngine) == null ? void 0 : _a3.oauthClientId
|
|
46384
46422
|
);
|
|
46423
|
+
const accessToken = firstValue((_b3 = this.options.earthEngine) == null ? void 0 : _b3.accessToken);
|
|
46385
46424
|
const projectId = firstValue(
|
|
46386
46425
|
storageGet(this.earthEngineProjectIdStorageKey()),
|
|
46387
|
-
(
|
|
46426
|
+
(_c3 = this.options.earthEngine) == null ? void 0 : _c3.projectId
|
|
46388
46427
|
);
|
|
46389
46428
|
this.ui.earthEngineClientIdInput.value = oauthClientId;
|
|
46390
46429
|
this.ui.earthEngineProjectIdInput.value = projectId;
|
|
46391
|
-
this.ui.earthEngineDetails.open = !oauthClientId || !projectId;
|
|
46430
|
+
this.ui.earthEngineDetails.open = !oauthClientId && !accessToken || !projectId;
|
|
46392
46431
|
this.applyEarthEngineSettings();
|
|
46393
46432
|
}
|
|
46394
46433
|
applyEarthEngineSettings() {
|
|
@@ -46413,15 +46452,16 @@ class GeoAgentControl {
|
|
|
46413
46452
|
this.emit("statechange");
|
|
46414
46453
|
}
|
|
46415
46454
|
updateEarthEngineStatus() {
|
|
46416
|
-
var _a3;
|
|
46455
|
+
var _a3, _b3, _c3;
|
|
46417
46456
|
if (!this.ui || this.ui.earthEngineDetails.hidden) {
|
|
46418
46457
|
return;
|
|
46419
46458
|
}
|
|
46420
46459
|
const oauthClientId = this.ui.earthEngineClientIdInput.value.trim();
|
|
46460
|
+
const accessToken = (_b3 = (_a3 = this.options.earthEngine) == null ? void 0 : _a3.accessToken) == null ? void 0 : _b3.trim();
|
|
46421
46461
|
const projectId = this.ui.earthEngineProjectIdInput.value.trim();
|
|
46422
|
-
const earthEngine = (
|
|
46423
|
-
if (!oauthClientId) {
|
|
46424
|
-
this.ui.earthEngineStatus.textContent = "OAuth Client ID is not configured by this app. Set VITE_GEE_OAUTH_CLIENT_ID before running Earth Engine tools.";
|
|
46462
|
+
const earthEngine = (_c3 = this.state.data) == null ? void 0 : _c3.earthEngine;
|
|
46463
|
+
if (!oauthClientId && !accessToken) {
|
|
46464
|
+
this.ui.earthEngineStatus.textContent = "OAuth Client ID or access token is not configured by this app. Set VITE_GEE_OAUTH_CLIENT_ID or provide earthEngine.accessToken before running Earth Engine tools.";
|
|
46425
46465
|
return;
|
|
46426
46466
|
}
|
|
46427
46467
|
if (!projectId) {
|
|
@@ -46672,16 +46712,18 @@ class GeoAgentControl {
|
|
|
46672
46712
|
return this.providerConfig(this.currentProviderId());
|
|
46673
46713
|
}
|
|
46674
46714
|
loadProviderSettings() {
|
|
46715
|
+
var _a3, _b3;
|
|
46675
46716
|
if (!this.ui) {
|
|
46676
46717
|
return;
|
|
46677
46718
|
}
|
|
46678
46719
|
const provider = this.currentProviderConfig();
|
|
46720
|
+
const initialApiKey = ((_b3 = (_a3 = this.options.apiKeys) == null ? void 0 : _a3[provider.id]) == null ? void 0 : _b3.trim()) ?? "";
|
|
46679
46721
|
this.state.providerId = provider.id;
|
|
46680
46722
|
this.state.modelId = storageGet(this.modelStorageKey(provider.id)) || provider.defaultModel;
|
|
46681
46723
|
this.ui.providerSelect.value = provider.id;
|
|
46682
46724
|
this.ui.apiKeyLabel.textContent = provider.keyLabel;
|
|
46683
46725
|
this.ui.apiKeyInput.placeholder = provider.keyPlaceholder;
|
|
46684
|
-
this.ui.apiKeyInput.value = storageGet(provider.storageKey) ||
|
|
46726
|
+
this.ui.apiKeyInput.value = storageGet(provider.storageKey) || initialApiKey;
|
|
46685
46727
|
this.ui.modelIdInput.value = this.state.modelId;
|
|
46686
46728
|
this.ui.modelIdInput.placeholder = provider.defaultModel;
|
|
46687
46729
|
this.state.bedrockRegion = this.initialBedrockRegion();
|
|
@@ -46802,7 +46844,7 @@ ${markdown.trim()}`;
|
|
|
46802
46844
|
}
|
|
46803
46845
|
async createProviderModel(providerId, modelId, apiKey, bedrockRegion) {
|
|
46804
46846
|
if (providerId === "openai-responses" || providerId === "openai-chat") {
|
|
46805
|
-
const { OpenAIModel } = await import("./index-
|
|
46847
|
+
const { OpenAIModel } = await import("./index-CCdoSNb8.js");
|
|
46806
46848
|
return new OpenAIModel({
|
|
46807
46849
|
api: providerId === "openai-responses" ? "responses" : "chat",
|
|
46808
46850
|
modelId,
|
|
@@ -46813,7 +46855,7 @@ ${markdown.trim()}`;
|
|
|
46813
46855
|
});
|
|
46814
46856
|
}
|
|
46815
46857
|
if (providerId === "anthropic") {
|
|
46816
|
-
const { AnthropicModel } = await import("./anthropic-
|
|
46858
|
+
const { AnthropicModel } = await import("./anthropic-qn30x05g.js");
|
|
46817
46859
|
return new AnthropicModel({
|
|
46818
46860
|
modelId,
|
|
46819
46861
|
apiKey,
|
|
@@ -46823,7 +46865,7 @@ ${markdown.trim()}`;
|
|
|
46823
46865
|
});
|
|
46824
46866
|
}
|
|
46825
46867
|
if (providerId === "google") {
|
|
46826
|
-
const { GoogleModel } = await import("./index-
|
|
46868
|
+
const { GoogleModel } = await import("./index-nbt2E_lW.js");
|
|
46827
46869
|
return new GoogleModel({
|
|
46828
46870
|
modelId,
|
|
46829
46871
|
apiKey
|
|
@@ -47048,4 +47090,4 @@ export {
|
|
|
47048
47090
|
toJsonValue as t,
|
|
47049
47091
|
warnOnce as w
|
|
47050
47092
|
};
|
|
47051
|
-
//# sourceMappingURL=GeoAgentControl-
|
|
47093
|
+
//# sourceMappingURL=GeoAgentControl-CM-lWHhd.js.map
|