maplibre-gl-geoagent 0.5.2 → 0.5.3

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 (33) hide show
  1. package/README.md +15 -27
  2. package/dist/{GeoAgentControl-DdRAg6Nf.cjs → GeoAgentControl-BrqW0nW3.cjs} +43 -243
  3. package/dist/{GeoAgentControl-DdRAg6Nf.cjs.map → GeoAgentControl-BrqW0nW3.cjs.map} +1 -1
  4. package/dist/{GeoAgentControl-ixWp8KFN.js → GeoAgentControl-DJ8Yw4b1.js} +43 -243
  5. package/dist/{GeoAgentControl-ixWp8KFN.js.map → GeoAgentControl-DJ8Yw4b1.js.map} +1 -1
  6. package/dist/{anthropic-DN5bZZYl.cjs → anthropic-Det8kcL4.cjs} +2 -2
  7. package/dist/{anthropic-DN5bZZYl.cjs.map → anthropic-Det8kcL4.cjs.map} +1 -1
  8. package/dist/{anthropic-fbFV8vsy.js → anthropic-oFfmzzbq.js} +2 -2
  9. package/dist/{anthropic-fbFV8vsy.js.map → anthropic-oFfmzzbq.js.map} +1 -1
  10. package/dist/{browser-BdcLoQF1.js → browser-DKxcoOn_.js} +2 -2
  11. package/dist/{browser-BdcLoQF1.js.map → browser-DKxcoOn_.js.map} +1 -1
  12. package/dist/{browser-tB9M0iL7.cjs → browser-VzygwWeK.cjs} +2 -2
  13. package/dist/{browser-tB9M0iL7.cjs.map → browser-VzygwWeK.cjs.map} +1 -1
  14. package/dist/{index-GeIdoDMK.cjs → index-BDAtf431.cjs} +2 -2
  15. package/dist/{index-GeIdoDMK.cjs.map → index-BDAtf431.cjs.map} +1 -1
  16. package/dist/{index-CAfXh7NK.js → index-B_sFbHLH.js} +2 -2
  17. package/dist/{index-CAfXh7NK.js.map → index-B_sFbHLH.js.map} +1 -1
  18. package/dist/{index-CXoyZ3E-.js → index-CPBFxRBO.js} +2 -2
  19. package/dist/{index-CXoyZ3E-.js.map → index-CPBFxRBO.js.map} +1 -1
  20. package/dist/{index-TSQ43SxX.cjs → index-D2I5L_28.cjs} +2 -2
  21. package/dist/{index-TSQ43SxX.cjs.map → index-D2I5L_28.cjs.map} +1 -1
  22. package/dist/{index-BHlW-XGv.js → index-D5LWkU_h.js} +2 -2
  23. package/dist/{index-BHlW-XGv.js.map → index-D5LWkU_h.js.map} +1 -1
  24. package/dist/{index-CMusYhSC.cjs → index-V9Dk3O4j.cjs} +2 -2
  25. package/dist/{index-CMusYhSC.cjs.map → index-V9Dk3O4j.cjs.map} +1 -1
  26. package/dist/index.cjs +1 -1
  27. package/dist/index.mjs +1 -1
  28. package/dist/maplibre-gl-geoagent.css +1 -1
  29. package/dist/react.cjs +1 -1
  30. package/dist/react.mjs +1 -1
  31. package/dist/types/lib/core/GeoAgentControl.d.ts +5 -38
  32. package/dist/types/lib/core/GeoAgentControl.d.ts.map +1 -1
  33. package/package.json +1 -1
package/README.md CHANGED
@@ -13,8 +13,8 @@ inspect and operate on the live map through dedicated browser tools.
13
13
 
14
14
  - Collapsible MapLibre control with a floating chat panel
15
15
  - Browser provider UI for OpenAI Responses, OpenAI Chat, Anthropic, Google Gemini, Amazon Bedrock, and any OpenAI-compatible/custom endpoint
16
- - API keys are saved on commit (Enter or blur) with an inline confirmation, then checked against the provider: an invalid key keeps the chat locked, while a verified key (or one that could not be reached for verification) unlocks it
17
- - Provider, key, and model settings live in one collapsible section that folds away once configured; the model field is a combobox that accepts a typed value or a one-click "Load models" list of the provider's available models
16
+ - API keys are saved on commit (Enter or blur) with an inline confirmation; provider errors are shown when a prompt is sent
17
+ - Provider, key, and model settings live in one collapsible section that folds away once configured; built-in providers default to their latest configured model, and the model can still be edited manually
18
18
  - Map tools for camera movement, projection, basemaps, markers, GeoJSON, XYZ tiles, layer visibility, opacity, feature queries, screenshots, and layer cleanup
19
19
  - Optional Google Earth Engine tools for catalog search, OAuth initialization, dataset tile layers, normalized difference indexes, visualization updates, snippets, and bounded statistics
20
20
  - Optional MapLibre JavaScript execution tool, disabled by default
@@ -118,38 +118,26 @@ Supported providers:
118
118
 
119
119
  For Bedrock, select `Amazon Bedrock`, enter a Bedrock API key, choose a Bedrock
120
120
  Converse model ID, and set the AWS region. The default Bedrock model is
121
- `global.anthropic.claude-sonnet-4-6`, and the default region is `us-west-2`.
121
+ `anthropic.claude-opus-4-8`, and the default region is `us-west-2`.
122
122
 
123
123
  For a custom or self-hosted model, select `OpenAI-Compatible (Custom)`, enter the
124
124
  API base URL of an OpenAI-compatible endpoint (for example a local LLM server or
125
- a private deployment), supply the API key, and enter or load a model ID. The
126
- endpoint is called with the OpenAI Chat Completions API shape.
125
+ a private deployment), supply the API key, and enter a model ID. The endpoint is
126
+ called with the OpenAI Chat Completions API shape.
127
127
 
128
- ### Saving and verifying keys
128
+ ### Saving keys and models
129
129
 
130
130
  The API key is written to `sessionStorage` only when you commit it (press Enter
131
131
  or move focus out of the field), so a half-typed key never flips the status
132
- badge to "Ready". After a key is committed the control calls the provider's
133
- model-list endpoint to verify it: a success marks the connection ready and
134
- fills the model field's suggestion list, an authentication error marks the key
135
- invalid and keeps the prompt locked, and a network/CORS failure leaves the key
136
- usable but
137
- unverified so a provider that does not allow browser model listing never blocks
138
- you. Use the "Load models" button to re-run this check at any time.
139
-
140
- Auto-verification on commit only runs once the control has everything it needs
141
- to call the endpoint. For `OpenAI-Compatible (Custom)` that means the API base
142
- URL must already be a valid `http(s)` URL when you commit the key; otherwise
143
- finish entering the base URL first, then press "Load models" to verify and load
144
- the model list.
145
-
146
- The loaded list is filtered to text chat models: embeddings, speech/audio,
147
- image, moderation, and (for first-party OpenAI) legacy completion models such as
148
- `davinci` and `*-instruct` are removed. These `/models` endpoints expose no
149
- "deprecated" flag, so deprecated chat snapshots cannot be detected and are left
150
- in. Aggregator endpoints such as OpenRouter legitimately list hundreds of chat
151
- models from many providers; the model field is a combobox, so type to narrow the
152
- suggestions.
132
+ badge to "Ready" or get written to storage.
133
+
134
+ Built-in providers use the latest model configured by the package:
135
+ `gpt-5.5` for OpenAI Responses and OpenAI Chat, `claude-opus-4-8` for Anthropic,
136
+ `gemini-3.5-flash` for Google Gemini, and `anthropic.claude-opus-4-8` for Amazon
137
+ Bedrock. The "Use latest" button resets the model field to that configured
138
+ default without calling a provider model-list endpoint. For
139
+ `OpenAI-Compatible (Custom)`, there is no universal latest model, so enter the
140
+ model ID exposed by that endpoint.
153
141
 
154
142
  ## Options
155
143
 
@@ -3519,7 +3519,7 @@ class HttpProtocol extends SerdeContext {
3519
3519
  });
3520
3520
  }
3521
3521
  async loadEventStreamCapability() {
3522
- const { EventStreamSerde } = await Promise.resolve().then(() => require("./index-TSQ43SxX.cjs"));
3522
+ const { EventStreamSerde } = await Promise.resolve().then(() => require("./index-D2I5L_28.cjs"));
3523
3523
  return new EventStreamSerde({
3524
3524
  marshaller: this.getEventStreamMarshaller(),
3525
3525
  serializer: this.serializer,
@@ -42665,7 +42665,7 @@ class EarthEngineService {
42665
42665
  }
42666
42666
  async loadEe() {
42667
42667
  if (!this.eePromise) {
42668
- this.eePromise = Promise.resolve().then(() => require("./browser-tB9M0iL7.cjs")).then((n) => n.browser).then((module2) => {
42668
+ this.eePromise = Promise.resolve().then(() => require("./browser-VzygwWeK.cjs")).then((n) => n.browser).then((module2) => {
42669
42669
  const imported = "default" in module2 ? module2.default : module2;
42670
42670
  const ee = imported;
42671
42671
  const scope2 = globalThis;
@@ -45920,28 +45920,9 @@ ${code2}
45920
45920
  const DEFAULT_PROVIDER = "openai-responses";
45921
45921
  const DEFAULT_STORAGE_PREFIX = "geoagent.maplibre";
45922
45922
  const DEFAULT_PROMPT_PLACEHOLDER = "Add a red marker for San Francisco and zoom to it.";
45923
- const VERIFY_TIMEOUT_MS = 15e3;
45924
45923
  const STATUS_READY = "Ready";
45925
45924
  const STATUS_SETUP = "Setup required";
45926
- const STATUS_VERIFYING = "Verifying…";
45927
- const STATUS_INVALID = "Invalid API key";
45928
45925
  const IDLE_STATUS_LABELS = /* @__PURE__ */ new Set([STATUS_READY, STATUS_SETUP]);
45929
- class ProviderAuthError extends Error {
45930
- }
45931
- const NON_CHAT_MODEL_MARKERS = [
45932
- "embed",
45933
- "whisper",
45934
- "tts",
45935
- "text-to-speech",
45936
- "transcribe",
45937
- "realtime",
45938
- "moderation",
45939
- "dall-e",
45940
- "gpt-image",
45941
- "rerank",
45942
- "guard"
45943
- ];
45944
- const OPENAI_LEGACY_MODEL_MARKERS = ["davinci", "babbage", "curie"];
45945
45926
  const BASE_PROVIDER_CONFIGS = {
45946
45927
  "openai-responses": {
45947
45928
  id: "openai-responses",
@@ -45962,21 +45943,21 @@ const BASE_PROVIDER_CONFIGS = {
45962
45943
  label: "Anthropic",
45963
45944
  keyLabel: "Anthropic API Key",
45964
45945
  keyPlaceholder: "sk-ant-...",
45965
- defaultModel: "claude-sonnet-4-6"
45946
+ defaultModel: "claude-opus-4-8"
45966
45947
  },
45967
45948
  google: {
45968
45949
  id: "google",
45969
45950
  label: "Google Gemini",
45970
45951
  keyLabel: "Gemini API Key",
45971
45952
  keyPlaceholder: "AIza...",
45972
- defaultModel: "gemini-3.1-pro-preview"
45953
+ defaultModel: "gemini-3.5-flash"
45973
45954
  },
45974
45955
  bedrock: {
45975
45956
  id: "bedrock",
45976
45957
  label: "Amazon Bedrock",
45977
45958
  keyLabel: "Bedrock API Key",
45978
45959
  keyPlaceholder: "bedrock-api-key...",
45979
- defaultModel: "global.anthropic.claude-sonnet-4-6",
45960
+ defaultModel: "anthropic.claude-opus-4-8",
45980
45961
  defaultRegion: "us-west-2"
45981
45962
  },
45982
45963
  "openai-compatible": {
@@ -46067,10 +46048,6 @@ const _GeoAgentControl = class _GeoAgentControl {
46067
46048
  // key field (Enter or blur), never on every keystroke, so a half-typed key
46068
46049
  // does not flip the badge to "Ready" or get written to storage.
46069
46050
  __publicField(this, "committedApiKey", "");
46070
- __publicField(this, "verifyState", "idle");
46071
- // Incremented on every verification so a slow earlier request cannot apply its
46072
- // result over a newer key/provider.
46073
- __publicField(this, "verifyToken", 0);
46074
46051
  __publicField(this, "configNoteTimer", null);
46075
46052
  __publicField(this, "modelListId", `geoagent-model-list-${_GeoAgentControl.instanceCount += 1}`);
46076
46053
  // Loaded model names backing the custom suggestion dropdown. A native
@@ -46172,7 +46149,6 @@ const _GeoAgentControl = class _GeoAgentControl {
46172
46149
  clearTimeout(this.suggestionBlurTimer);
46173
46150
  this.suggestionBlurTimer = null;
46174
46151
  }
46175
- this.verifyToken++;
46176
46152
  (_a3 = this.activeAbortController) == null ? void 0 : _a3.abort();
46177
46153
  (_b3 = this.agent) == null ? void 0 : _b3.cancel();
46178
46154
  this.activeAbortController = null;
@@ -46401,7 +46377,7 @@ const _GeoAgentControl = class _GeoAgentControl {
46401
46377
  Model
46402
46378
  <div class="geoagent-model-row">
46403
46379
  <input class="geoagent-model-id" autocomplete="off" role="combobox" aria-autocomplete="list" aria-expanded="false" aria-controls="${this.modelListId}" />
46404
- <button class="geoagent-load-models secondary" type="button">Load models</button>
46380
+ <button class="geoagent-load-models secondary" type="button">Use latest</button>
46405
46381
  </div>
46406
46382
  <ul class="geoagent-model-suggestions" id="${this.modelListId}" role="listbox" hidden></ul>
46407
46383
  </label>
@@ -46587,7 +46563,7 @@ const _GeoAgentControl = class _GeoAgentControl {
46587
46563
  this.state.modelId = this.initialModelId(providerId);
46588
46564
  this.loadProviderSettings();
46589
46565
  this.invalidateAgent();
46590
- this.resetVerification();
46566
+ this.resetModelOptions();
46591
46567
  this.hideConfigNote();
46592
46568
  this.applyIdleStatus(true);
46593
46569
  this.updateControls();
@@ -46610,12 +46586,11 @@ const _GeoAgentControl = class _GeoAgentControl {
46610
46586
  storageRemove(this.baseUrlStorageKey(this.state.providerId));
46611
46587
  }
46612
46588
  this.invalidateAgent();
46613
- this.resetVerification();
46614
46589
  this.updateControls();
46615
46590
  this.emit("statechange");
46616
46591
  });
46617
46592
  ui.loadModelsButton.addEventListener("click", () => {
46618
- void this.verifyAndLoadModels();
46593
+ this.useLatestModel();
46619
46594
  });
46620
46595
  ui.modelIdInput.addEventListener("input", () => {
46621
46596
  const modelId = ui.modelIdInput.value.trim();
@@ -47073,21 +47048,17 @@ ${markdown.trim()}`;
47073
47048
  return;
47074
47049
  }
47075
47050
  const configured = this.isConfigured();
47076
- const blocked = !configured || this.verifyState === "invalid" || this.verifyState === "verifying";
47051
+ const blocked = !configured;
47077
47052
  this.ui.prompt.disabled = this.state.busy || blocked;
47078
47053
  this.ui.prompt.placeholder = blocked ? this.blockedPromptHint(configured) : DEFAULT_PROMPT_PLACEHOLDER;
47079
47054
  this.ui.sendButton.disabled = this.state.busy || !this.ui.prompt.value.trim() || blocked;
47080
47055
  if (!blocked) {
47081
47056
  this.ui.sendButton.removeAttribute("title");
47082
- } else if (this.verifyState === "invalid") {
47083
- this.ui.sendButton.title = "Fix the API key to send a prompt.";
47084
- } else if (this.verifyState === "verifying") {
47085
- this.ui.sendButton.title = "Verifying the connection…";
47086
47057
  } else {
47087
47058
  const missing = this.missingConfigSummary();
47088
47059
  this.ui.sendButton.title = missing ? `Add your ${missing} to send a prompt.` : "Configuration required to send a prompt.";
47089
47060
  }
47090
- this.ui.loadModelsButton.disabled = this.state.busy || this.verifyState === "verifying" || !this.canVerify();
47061
+ this.ui.loadModelsButton.disabled = this.state.busy || !this.currentProviderConfig().defaultModel;
47091
47062
  this.ui.cancelButton.disabled = !this.state.busy || this.cancelRequested;
47092
47063
  this.ui.clearButton.disabled = this.state.busy;
47093
47064
  this.ui.copyButton.disabled = this.ui.log.childElementCount === 0;
@@ -47099,28 +47070,9 @@ ${markdown.trim()}`;
47099
47070
  }
47100
47071
  /** Placeholder hint shown in the prompt field while it is locked. */
47101
47072
  blockedPromptHint(configured) {
47102
- if (this.verifyState === "verifying") {
47103
- return "Verifying the connection…";
47104
- }
47105
- if (this.verifyState === "invalid") {
47106
- return "The API key was rejected. Fix it to start.";
47107
- }
47108
47073
  const missing = configured ? "" : this.missingConfigSummary();
47109
47074
  return missing ? `Add your ${missing} to start.` : "Configure a provider to start.";
47110
47075
  }
47111
- /**
47112
- * Whether there is enough committed configuration to attempt a live
47113
- * verification / model-list request for the current provider.
47114
- */
47115
- canVerify() {
47116
- if (!this.ui || !this.committedApiKey.trim()) {
47117
- return false;
47118
- }
47119
- if (this.currentProviderConfig().requiresBaseUrl && !this.isValidBaseUrl(this.ui.baseUrlInput.value)) {
47120
- return false;
47121
- }
47122
- return true;
47123
- }
47124
47076
  /** React to an in-progress edit of the API key without committing it. */
47125
47077
  handleApiKeyEdited() {
47126
47078
  if (!this.ui) {
@@ -47134,16 +47086,12 @@ ${markdown.trim()}`;
47134
47086
  }
47135
47087
  this.updateControls();
47136
47088
  }
47137
- /**
47138
- * Persist the typed API key, refresh the connection state, and (when a usable
47139
- * key was entered) verify it against the provider in the background.
47140
- */
47089
+ /** Persist the typed API key and refresh the local connection state. */
47141
47090
  commitApiKey() {
47142
47091
  if (!this.ui) {
47143
47092
  return;
47144
47093
  }
47145
47094
  const apiKey = this.ui.apiKeyInput.value.trim();
47146
- const changed = apiKey !== this.committedApiKey;
47147
47095
  this.committedApiKey = apiKey;
47148
47096
  const storageKey = this.currentProviderConfig().storageKey;
47149
47097
  if (apiKey) {
@@ -47152,7 +47100,6 @@ ${markdown.trim()}`;
47152
47100
  storageRemove(storageKey);
47153
47101
  }
47154
47102
  this.invalidateAgent();
47155
- this.resetVerification();
47156
47103
  if (apiKey) {
47157
47104
  this.showConfigNote("API key saved.", "success", true);
47158
47105
  } else {
@@ -47160,31 +47107,10 @@ ${markdown.trim()}`;
47160
47107
  }
47161
47108
  this.applyIdleStatus(true);
47162
47109
  this.updateControls();
47163
- if (apiKey && changed && this.canVerify()) {
47164
- void this.verifyAndLoadModels();
47165
- }
47166
47110
  }
47167
- /** Clear any verification result so the connection state is re-evaluated. */
47168
- resetVerification() {
47169
- this.verifyToken++;
47170
- this.verifyState = "idle";
47111
+ resetModelOptions() {
47171
47112
  this.populateModelOptions([]);
47172
47113
  }
47173
- setVerifyState(state) {
47174
- this.verifyState = state;
47175
- if (!this.ui || this.state.busy) {
47176
- this.updateControls();
47177
- return;
47178
- }
47179
- if (state === "verifying") {
47180
- this.setStatus(STATUS_VERIFYING, "connecting");
47181
- } else if (state === "invalid") {
47182
- this.setStatus(STATUS_INVALID, "error");
47183
- } else {
47184
- this.applyIdleStatus(true);
47185
- }
47186
- this.updateControls();
47187
- }
47188
47114
  showConfigNote(text2, kind, autoHide) {
47189
47115
  if (!this.ui) {
47190
47116
  return;
@@ -47210,64 +47136,38 @@ ${markdown.trim()}`;
47210
47136
  this.ui.configNote.textContent = "";
47211
47137
  }
47212
47138
  }
47213
- /**
47214
- * Ask the current provider for its model list. A success both verifies the
47215
- * key and populates the model dropdown; an authentication failure marks the
47216
- * key invalid; any other failure (network/CORS/unsupported) leaves the key
47217
- * usable but unverified so the user is never blocked by a provider that does
47218
- * not allow browser model listing.
47219
- */
47220
- async verifyAndLoadModels() {
47221
- if (!this.ui || !this.canVerify()) {
47139
+ useLatestModel() {
47140
+ if (!this.ui) {
47222
47141
  return;
47223
47142
  }
47224
- const provider = this.currentProviderConfig();
47225
- const apiKey = this.committedApiKey.trim();
47226
- const baseUrl = this.ui.baseUrlInput.value.trim();
47227
- const region = this.ui.bedrockRegionInput.value.trim();
47228
- const token = ++this.verifyToken;
47229
- this.setVerifyState("verifying");
47230
- this.showConfigNote("Verifying connection…", "info", false);
47231
- try {
47232
- const models = await this.fetchProviderModels(
47233
- provider,
47234
- apiKey,
47235
- baseUrl,
47236
- region
47237
- );
47238
- if (token !== this.verifyToken) {
47239
- return;
47240
- }
47241
- this.populateModelOptions(models);
47242
- this.setVerifyState("ok");
47143
+ const latestModel = this.currentProviderConfig().defaultModel;
47144
+ if (!latestModel) {
47243
47145
  this.showConfigNote(
47244
- models.length ? `Connection verified. ${models.length} models available.` : "Connection verified.",
47245
- "success",
47146
+ "Enter the model ID for this custom endpoint.",
47147
+ "info",
47246
47148
  true
47247
47149
  );
47248
- } catch (error) {
47249
- if (token !== this.verifyToken) {
47250
- return;
47251
- }
47252
- if (error instanceof ProviderAuthError) {
47253
- this.setVerifyState("invalid");
47254
- this.showConfigNote(
47255
- error.message || "The provider rejected this API key.",
47256
- "error",
47257
- false
47258
- );
47259
- } else {
47260
- this.setVerifyState("unverified");
47261
- this.showConfigNote(
47262
- "Could not verify automatically. You can still enter a model and send prompts.",
47263
- "info",
47264
- true
47265
- );
47266
- }
47150
+ return;
47267
47151
  }
47152
+ this.ui.modelIdInput.value = latestModel;
47153
+ this.ui.modelIdInput.dispatchEvent(new Event("input", { bubbles: true }));
47154
+ this.closeModelSuggestions();
47155
+ this.showConfigNote(`Using latest model: ${latestModel}.`, "success", true);
47268
47156
  }
47269
47157
  populateModelOptions(models) {
47270
- this.modelOptions = models;
47158
+ const seen = /* @__PURE__ */ new Set();
47159
+ const options = [];
47160
+ for (const rawModel of models) {
47161
+ const model = rawModel.trim();
47162
+ if (!model || seen.has(model)) {
47163
+ continue;
47164
+ }
47165
+ seen.add(model);
47166
+ if (options.length < _GeoAgentControl.MAX_SUGGESTIONS) {
47167
+ options.push(model);
47168
+ }
47169
+ }
47170
+ this.modelOptions = options;
47271
47171
  if (this.ui && !this.ui.modelSuggestions.hidden) {
47272
47172
  this.openModelSuggestions(false);
47273
47173
  }
@@ -47282,8 +47182,8 @@ ${markdown.trim()}`;
47282
47182
  /**
47283
47183
  * Open (or refresh) the custom model suggestion dropdown. With `useFilter`
47284
47184
  * (typing) the list narrows to the current input value; without it (focus,
47285
- * arrow keys) the full loaded list is shown so the user can browse even when
47286
- * the field already holds the default model.
47185
+ * arrow keys) the full local suggestion list is shown so the user can browse
47186
+ * even when the field already holds the default model.
47287
47187
  */
47288
47188
  openModelSuggestions(useFilter = true) {
47289
47189
  if (!this.ui) {
@@ -47407,103 +47307,6 @@ ${markdown.trim()}`;
47407
47307
  return false;
47408
47308
  }
47409
47309
  }
47410
- async fetchProviderModels(provider, apiKey, baseUrl, region) {
47411
- switch (provider.id) {
47412
- case "openai-responses":
47413
- case "openai-chat":
47414
- return this.fetchOpenAiModels("https://api.openai.com/v1", apiKey, true);
47415
- case "openai-compatible":
47416
- return this.fetchOpenAiModels(
47417
- this.normalizeBaseUrl(baseUrl),
47418
- apiKey,
47419
- false
47420
- );
47421
- case "anthropic":
47422
- return this.fetchAnthropicModels(apiKey);
47423
- case "google":
47424
- return this.fetchGoogleModels(apiKey);
47425
- case "bedrock":
47426
- return this.fetchBedrockModels(apiKey, region);
47427
- default:
47428
- return [];
47429
- }
47430
- }
47431
- async fetchModelJson(url, init) {
47432
- const controller = new AbortController();
47433
- const timer = setTimeout(() => controller.abort(), VERIFY_TIMEOUT_MS);
47434
- try {
47435
- const response = await fetch(url, { ...init, signal: controller.signal });
47436
- if (response.status === 401 || response.status === 403) {
47437
- throw new ProviderAuthError("The provider rejected this API key.");
47438
- }
47439
- if (!response.ok) {
47440
- throw new Error(`Model list request failed (HTTP ${response.status}).`);
47441
- }
47442
- return await response.json();
47443
- } finally {
47444
- clearTimeout(timer);
47445
- }
47446
- }
47447
- async fetchOpenAiModels(baseUrl, apiKey, firstPartyOpenAi) {
47448
- const json = await this.fetchModelJson(`${baseUrl}/models`, {
47449
- headers: { Authorization: `Bearer ${apiKey}` }
47450
- });
47451
- const ids = (json.data ?? []).map((entry) => entry.id).filter((id2) => typeof id2 === "string" && id2.length > 0);
47452
- return this.filterChatModels(ids, firstPartyOpenAi).sort();
47453
- }
47454
- /**
47455
- * Drop entries that are clearly not text chat models (embeddings, audio,
47456
- * image, moderation) so the picker only offers models the agent can run. For
47457
- * first-party OpenAI, also drop legacy completion families the chat/responses
47458
- * API cannot drive. Custom endpoints keep their own naming, so the legacy
47459
- * filter is not applied to them.
47460
- */
47461
- filterChatModels(ids, firstPartyOpenAi) {
47462
- return ids.filter((id2) => {
47463
- const lower = id2.toLowerCase();
47464
- if (NON_CHAT_MODEL_MARKERS.some((marker) => lower.includes(marker))) {
47465
- return false;
47466
- }
47467
- if (firstPartyOpenAi) {
47468
- if (lower.endsWith("-instruct")) {
47469
- return false;
47470
- }
47471
- if (OPENAI_LEGACY_MODEL_MARKERS.some((marker) => lower.includes(marker))) {
47472
- return false;
47473
- }
47474
- }
47475
- return true;
47476
- });
47477
- }
47478
- async fetchAnthropicModels(apiKey) {
47479
- const json = await this.fetchModelJson(
47480
- "https://api.anthropic.com/v1/models?limit=1000",
47481
- {
47482
- headers: {
47483
- "x-api-key": apiKey,
47484
- "anthropic-version": "2023-06-01",
47485
- "anthropic-dangerous-direct-browser-access": "true"
47486
- }
47487
- }
47488
- );
47489
- return (json.data ?? []).map((entry) => entry.id).filter((id2) => typeof id2 === "string" && id2.length > 0);
47490
- }
47491
- async fetchGoogleModels(apiKey) {
47492
- const url = `https://generativelanguage.googleapis.com/v1beta/models?pageSize=1000&key=${encodeURIComponent(
47493
- apiKey
47494
- )}`;
47495
- const json = await this.fetchModelJson(url, {});
47496
- return (json.models ?? []).filter(
47497
- (entry) => (entry.supportedGenerationMethods ?? []).includes("generateContent")
47498
- ).map((entry) => (entry.name ?? "").replace(/^models\//, "")).filter((id2) => id2.length > 0).sort();
47499
- }
47500
- async fetchBedrockModels(apiKey, region) {
47501
- const host = `https://bedrock.${region || "us-west-2"}.amazonaws.com`;
47502
- const json = await this.fetchModelJson(`${host}/foundation-models`, {
47503
- headers: { Authorization: `Bearer ${apiKey}` }
47504
- });
47505
- return (json.modelSummaries ?? []).map((entry) => entry.modelId).filter((id2) => typeof id2 === "string" && id2.length > 0).sort();
47506
- }
47507
47310
  invalidateAgent() {
47508
47311
  this.agent = null;
47509
47312
  this.agentSignature = "";
@@ -47522,7 +47325,7 @@ ${markdown.trim()}`;
47522
47325
  }
47523
47326
  async createProviderModel(providerId, modelId, apiKey, bedrockRegion, baseUrl) {
47524
47327
  if (providerId === "openai-responses" || providerId === "openai-chat") {
47525
- const { OpenAIModel } = await Promise.resolve().then(() => require("./index-GeIdoDMK.cjs"));
47328
+ const { OpenAIModel } = await Promise.resolve().then(() => require("./index-BDAtf431.cjs"));
47526
47329
  return new OpenAIModel({
47527
47330
  api: providerId === "openai-responses" ? "responses" : "chat",
47528
47331
  modelId,
@@ -47533,7 +47336,7 @@ ${markdown.trim()}`;
47533
47336
  });
47534
47337
  }
47535
47338
  if (providerId === "openai-compatible") {
47536
- const { OpenAIModel } = await Promise.resolve().then(() => require("./index-GeIdoDMK.cjs"));
47339
+ const { OpenAIModel } = await Promise.resolve().then(() => require("./index-BDAtf431.cjs"));
47537
47340
  return new OpenAIModel({
47538
47341
  api: "chat",
47539
47342
  modelId,
@@ -47545,7 +47348,7 @@ ${markdown.trim()}`;
47545
47348
  });
47546
47349
  }
47547
47350
  if (providerId === "anthropic") {
47548
- const { AnthropicModel } = await Promise.resolve().then(() => require("./anthropic-DN5bZZYl.cjs"));
47351
+ const { AnthropicModel } = await Promise.resolve().then(() => require("./anthropic-Det8kcL4.cjs"));
47549
47352
  return new AnthropicModel({
47550
47353
  modelId,
47551
47354
  apiKey,
@@ -47555,7 +47358,7 @@ ${markdown.trim()}`;
47555
47358
  });
47556
47359
  }
47557
47360
  if (providerId === "google") {
47558
- const { GoogleModel } = await Promise.resolve().then(() => require("./index-CMusYhSC.cjs"));
47361
+ const { GoogleModel } = await Promise.resolve().then(() => require("./index-V9Dk3O4j.cjs"));
47559
47362
  return new GoogleModel({
47560
47363
  modelId,
47561
47364
  apiKey
@@ -47767,9 +47570,6 @@ ${BROWSER_MAPLIBRE_CODE_SYSTEM_PROMPT}` : BROWSER_MAPLIBRE_SYSTEM_PROMPT;
47767
47570
  // Unique per control instance so the model input's aria-controls points at its
47768
47571
  // own suggestion list even when several controls share a page.
47769
47572
  __publicField(_GeoAgentControl, "instanceCount", 0);
47770
- // Cap on rendered suggestion rows. The dropdown filters as the user types, so
47771
- // this only bounds the initial/unfiltered view and keeps a pathological model
47772
- // list (thousands of fine-tunes) from building a huge DOM list.
47773
47573
  __publicField(_GeoAgentControl, "MAX_SUGGESTIONS", 100);
47774
47574
  let GeoAgentControl = _GeoAgentControl;
47775
47575
  exports.ContextWindowOverflowError = ContextWindowOverflowError;
@@ -47798,4 +47598,4 @@ exports.toJsonValue = toJsonValue;
47798
47598
  exports.toMimeType = toMimeType;
47799
47599
  exports.toUtf8 = toUtf8;
47800
47600
  exports.warnOnce = warnOnce;
47801
- //# sourceMappingURL=GeoAgentControl-DdRAg6Nf.cjs.map
47601
+ //# sourceMappingURL=GeoAgentControl-BrqW0nW3.cjs.map