anymap-ts 0.17.0 → 0.17.1
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.
|
@@ -6294,7 +6294,7 @@ Workflow guidance:
|
|
|
6294
6294
|
- Do not ask the user to paste JavaScript or run Python for actions that the browser map tools can perform.
|
|
6295
6295
|
- Keep responses concise and include layer names, locations, and tool results when useful.`,ERr=`Browser JavaScript code execution is enabled for this local session. This tool runs arbitrary JavaScript in the page context and is not a safety boundary; treat it as a trusted, local-only escape hatch.
|
|
6296
6296
|
|
|
6297
|
-
When no dedicated browser map tool can perform the requested MapLibre operation, write a short JavaScript snippet and run it with run_maplibre_script. The snippet executes in the browser with these names in scope: map, maplibregl, and helpers. Prefer MapLibre GL JS API calls, keep code focused on map operations, and avoid credential handling, storage access, unrelated DOM manipulation, or broad network operations.`;k3e=class{constructor(e={}){ii(this,"options"),ii(this,"map"),ii(this,"mapContainer"),ii(this,"container"),ii(this,"panel"),ii(this,"ui"),ii(this,"tools"),ii(this,"agent",null),ii(this,"agentSignature",""),ii(this,"streamingAssistantTextEl",null),ii(this,"streamingAssistantText",""),ii(this,"promptHistory",[]),ii(this,"promptHistoryIndex",-1),ii(this,"promptHistoryDraft",""),ii(this,"state"),ii(this,"eventHandlers",new globalThis.Map),ii(this,"resizeHandler",null),ii(this,"mapResizeHandler",null),ii(this,"clickOutsideHandler",null),ii(this,"panelResizeMoveHandler",null),ii(this,"panelResizeUpHandler",null),ii(this,"activeAbortController",null),ii(this,"cancelRequested",!1),this.options={collapsed:e.collapsed??!0,position:e.position??"top-right",title:e.title??"GeoAgent",panelWidth:e.panelWidth??390,panelMinWidth:e.panelMinWidth??320,panelMaxWidth:e.panelMaxWidth??720,className:e.className??"",defaultProvider:e.defaultProvider??IRr,storagePrefix:e.storagePrefix??yRr,allowCodeExecutionDefault:e.allowCodeExecutionDefault??!0,allowDestructiveToolsDefault:e.allowDestructiveToolsDefault??!0,showPermissionToggles:e.showPermissionToggles??!1,defaultModel:e.defaultModel,basemaps:e.basemaps,earthEngine:e.earthEngine};let t=this.initialProviderId();this.state={collapsed:this.options.collapsed,panelWidth:this.constrainPanelWidth(this.options.panelWidth),busy:!1,providerId:t,modelId:this.initialModelId(t),bedrockRegion:this.initialBedrockRegion(),allowCodeExecution:this.options.allowCodeExecutionDefault,allowDestructiveTools:this.options.allowDestructiveToolsDefault,data:{}}}onAdd(e){return this.map=e,this.mapContainer=e.getContainer(),this.container=this.createContainer(),this.panel=this.createPanel(),this.mapContainer.appendChild(this.panel),this.tools=new D9t(e,{basemaps:{...cmt,...this.options.basemaps},allowCodeExecution:()=>this.state.allowCodeExecution,allowDestructiveTools:()=>this.state.allowDestructiveTools,earthEngine:this.options.earthEngine,onStateDataChange:t=>{this.state.data={...this.state.data??{},...t},this.updateEarthEngineStatus(),this.emit("statechange")}}),this.setupEventListeners(),this.loadProviderSettings(),this.setStatus("Ready","connected"),this.appendLog("system","Browser-only Strands MapLibre agent ready."),this.updateControls(),this.state.collapsed||(this.panel.classList.add("expanded"),requestAnimationFrame(()=>this.updatePanelPosition())),this.container}onRemove(){var e,t,n,r,a,l,A;this.resizeHandler&&(window.removeEventListener("resize",this.resizeHandler),this.resizeHandler=null),this.mapResizeHandler&&this.map&&(this.map.off("resize",this.mapResizeHandler),this.mapResizeHandler=null),this.clickOutsideHandler&&(document.removeEventListener("click",this.clickOutsideHandler),this.clickOutsideHandler=null),this.stopPanelResize(),(e=this.activeAbortController)==null||e.abort(),(t=this.agent)==null||t.cancel(),this.activeAbortController=null,this.cancelRequested=!1,(n=this.tools)==null||n.destroy(),this.tools=void 0,(a=(r=this.panel)==null?void 0:r.parentNode)==null||a.removeChild(this.panel),(A=(l=this.container)==null?void 0:l.parentNode)==null||A.removeChild(this.container),this.map=void 0,this.mapContainer=void 0,this.container=void 0,this.panel=void 0,this.ui=void 0,this.agent=null,this.agentSignature="",this.streamingAssistantTextEl=null,this.streamingAssistantText="",this.promptHistory=[],this.promptHistoryIndex=-1,this.promptHistoryDraft="",this.eventHandlers.clear()}getState(){return{...this.state,data:{...this.state.data}}}setState(e){var t,n;let r=e.collapsed!==void 0&&e.collapsed!==this.state.collapsed,a=e.providerId!==void 0&&e.providerId!==this.state.providerId||e.modelId!==void 0&&e.modelId!==this.state.modelId||e.allowCodeExecution!==void 0&&e.allowCodeExecution!==this.state.allowCodeExecution;if(this.state={...this.state,...e},e.panelWidth!==void 0&&this.panel){let l=this.constrainPanelWidth(e.panelWidth);this.state.panelWidth=l,this.panel.style.width=`${l}px`}r&&(this.state.collapsed?((t=this.panel)==null||t.classList.remove("expanded"),this.emit("collapse")):((n=this.panel)==null||n.classList.add("expanded"),this.updatePanelPosition(),this.emit("expand"))),a&&this.invalidateAgent(),this.syncUiFromState(),this.emit("statechange")}toggle(){this.setState({collapsed:!this.state.collapsed})}expand(){this.state.collapsed&&this.toggle()}collapse(){this.state.collapsed||this.toggle()}on(e,t){this.eventHandlers.has(e)||this.eventHandlers.set(e,new Set),this.eventHandlers.get(e).add(t)}off(e,t){var n;(n=this.eventHandlers.get(e))==null||n.delete(t)}getMap(){return this.map}getContainer(){return this.container}getPanel(){return this.panel}emit(e){let t=this.eventHandlers.get(e);if(!t)return;let n={type:e,state:this.getState()};t.forEach(r=>r(n))}providerConfigs(){return{"openai-responses":this.providerConfig("openai-responses"),"openai-chat":this.providerConfig("openai-chat"),anthropic:this.providerConfig("anthropic"),google:this.providerConfig("google"),bedrock:this.providerConfig("bedrock")}}providerConfig(e){return{...e3e[e],storageKey:`${this.options.storagePrefix}.${e}.api_key`,defaultModel:Pbi(e,this.options.defaultModel)}}initialProviderId(){let e=cee(`${this.options.storagePrefix}.provider`);return e&&e in e3e?e:this.options.defaultProvider}initialModelId(e){return cee(this.modelStorageKey(e))||Pbi(e,this.options.defaultModel)}modelStorageKey(e){return`${this.options.storagePrefix}.model.${e}`}bedrockRegionStorageKey(){return`${this.options.storagePrefix}.bedrock.region`}earthEngineProjectIdStorageKey(){return`${this.options.storagePrefix}.earthEngine.projectId`}initialBedrockRegion(){return cee(this.bedrockRegionStorageKey())||e3e.bedrock.defaultRegion}createContainer(){let e=document.createElement("div");e.className=`maplibregl-ctrl maplibregl-ctrl-group geoagent-control${this.options.className?` ${this.options.className}`:""}`;let t=document.createElement("button");return t.className="geoagent-control-toggle",t.type="button",t.title=this.options.title,t.setAttribute("aria-label",this.options.title),t.setAttribute("aria-expanded",String(!this.state.collapsed)),t.innerHTML=`
|
|
6297
|
+
When no dedicated browser map tool can perform the requested MapLibre operation, write a short JavaScript snippet and run it with run_maplibre_script. The snippet executes in the browser with these names in scope: map, maplibregl, and helpers. Prefer MapLibre GL JS API calls, keep code focused on map operations, and avoid credential handling, storage access, unrelated DOM manipulation, or broad network operations.`;k3e=class{constructor(e={}){ii(this,"options"),ii(this,"map"),ii(this,"mapContainer"),ii(this,"container"),ii(this,"panel"),ii(this,"ui"),ii(this,"tools"),ii(this,"agent",null),ii(this,"agentSignature",""),ii(this,"streamingAssistantTextEl",null),ii(this,"streamingAssistantText",""),ii(this,"promptHistory",[]),ii(this,"promptHistoryIndex",-1),ii(this,"promptHistoryDraft",""),ii(this,"state"),ii(this,"eventHandlers",new globalThis.Map),ii(this,"resizeHandler",null),ii(this,"mapResizeHandler",null),ii(this,"clickOutsideHandler",null),ii(this,"panelResizeMoveHandler",null),ii(this,"panelResizeUpHandler",null),ii(this,"activeAbortController",null),ii(this,"cancelRequested",!1),this.options={collapsed:e.collapsed??!0,position:e.position??"top-right",title:e.title??"GeoAgent",panelWidth:e.panelWidth??390,panelMinWidth:e.panelMinWidth??320,panelMaxWidth:e.panelMaxWidth??720,className:e.className??"",defaultProvider:e.defaultProvider??IRr,storagePrefix:e.storagePrefix??yRr,allowCodeExecutionDefault:e.allowCodeExecutionDefault??!0,allowDestructiveToolsDefault:e.allowDestructiveToolsDefault??!0,showPermissionToggles:e.showPermissionToggles??!1,defaultModel:e.defaultModel,apiKeys:e.apiKeys,basemaps:e.basemaps,earthEngine:e.earthEngine};let t=this.initialProviderId();this.state={collapsed:this.options.collapsed,panelWidth:this.constrainPanelWidth(this.options.panelWidth),busy:!1,providerId:t,modelId:this.initialModelId(t),bedrockRegion:this.initialBedrockRegion(),allowCodeExecution:this.options.allowCodeExecutionDefault,allowDestructiveTools:this.options.allowDestructiveToolsDefault,data:{}}}onAdd(e){return this.map=e,this.mapContainer=e.getContainer(),this.container=this.createContainer(),this.panel=this.createPanel(),this.mapContainer.appendChild(this.panel),this.tools=new D9t(e,{basemaps:{...cmt,...this.options.basemaps},allowCodeExecution:()=>this.state.allowCodeExecution,allowDestructiveTools:()=>this.state.allowDestructiveTools,earthEngine:this.options.earthEngine,onStateDataChange:t=>{this.state.data={...this.state.data??{},...t},this.updateEarthEngineStatus(),this.emit("statechange")}}),this.setupEventListeners(),this.loadProviderSettings(),this.setStatus("Ready","connected"),this.appendLog("system","Browser-only Strands MapLibre agent ready."),this.updateControls(),this.state.collapsed||(this.panel.classList.add("expanded"),requestAnimationFrame(()=>this.updatePanelPosition())),this.container}onRemove(){var e,t,n,r,a,l,A;this.resizeHandler&&(window.removeEventListener("resize",this.resizeHandler),this.resizeHandler=null),this.mapResizeHandler&&this.map&&(this.map.off("resize",this.mapResizeHandler),this.mapResizeHandler=null),this.clickOutsideHandler&&(document.removeEventListener("click",this.clickOutsideHandler),this.clickOutsideHandler=null),this.stopPanelResize(),(e=this.activeAbortController)==null||e.abort(),(t=this.agent)==null||t.cancel(),this.activeAbortController=null,this.cancelRequested=!1,(n=this.tools)==null||n.destroy(),this.tools=void 0,(a=(r=this.panel)==null?void 0:r.parentNode)==null||a.removeChild(this.panel),(A=(l=this.container)==null?void 0:l.parentNode)==null||A.removeChild(this.container),this.map=void 0,this.mapContainer=void 0,this.container=void 0,this.panel=void 0,this.ui=void 0,this.agent=null,this.agentSignature="",this.streamingAssistantTextEl=null,this.streamingAssistantText="",this.promptHistory=[],this.promptHistoryIndex=-1,this.promptHistoryDraft="",this.eventHandlers.clear()}getState(){return{...this.state,data:{...this.state.data}}}setState(e){var t,n;let r=e.collapsed!==void 0&&e.collapsed!==this.state.collapsed,a=e.providerId!==void 0&&e.providerId!==this.state.providerId||e.modelId!==void 0&&e.modelId!==this.state.modelId||e.allowCodeExecution!==void 0&&e.allowCodeExecution!==this.state.allowCodeExecution;if(this.state={...this.state,...e},e.panelWidth!==void 0&&this.panel){let l=this.constrainPanelWidth(e.panelWidth);this.state.panelWidth=l,this.panel.style.width=`${l}px`}r&&(this.state.collapsed?((t=this.panel)==null||t.classList.remove("expanded"),this.emit("collapse")):((n=this.panel)==null||n.classList.add("expanded"),this.updatePanelPosition(),this.emit("expand"))),a&&this.invalidateAgent(),this.syncUiFromState(),this.emit("statechange")}toggle(){this.setState({collapsed:!this.state.collapsed})}expand(){this.state.collapsed&&this.toggle()}collapse(){this.state.collapsed||this.toggle()}on(e,t){this.eventHandlers.has(e)||this.eventHandlers.set(e,new Set),this.eventHandlers.get(e).add(t)}off(e,t){var n;(n=this.eventHandlers.get(e))==null||n.delete(t)}getMap(){return this.map}getContainer(){return this.container}getPanel(){return this.panel}emit(e){let t=this.eventHandlers.get(e);if(!t)return;let n={type:e,state:this.getState()};t.forEach(r=>r(n))}providerConfigs(){return{"openai-responses":this.providerConfig("openai-responses"),"openai-chat":this.providerConfig("openai-chat"),anthropic:this.providerConfig("anthropic"),google:this.providerConfig("google"),bedrock:this.providerConfig("bedrock")}}providerConfig(e){return{...e3e[e],storageKey:`${this.options.storagePrefix}.${e}.api_key`,defaultModel:Pbi(e,this.options.defaultModel)}}initialProviderId(){let e=cee(`${this.options.storagePrefix}.provider`);return e&&e in e3e?e:this.options.defaultProvider}initialModelId(e){return cee(this.modelStorageKey(e))||Pbi(e,this.options.defaultModel)}modelStorageKey(e){return`${this.options.storagePrefix}.model.${e}`}bedrockRegionStorageKey(){return`${this.options.storagePrefix}.bedrock.region`}earthEngineProjectIdStorageKey(){return`${this.options.storagePrefix}.earthEngine.projectId`}initialBedrockRegion(){return cee(this.bedrockRegionStorageKey())||e3e.bedrock.defaultRegion}createContainer(){let e=document.createElement("div");e.className=`maplibregl-ctrl maplibregl-ctrl-group geoagent-control${this.options.className?` ${this.options.className}`:""}`;let t=document.createElement("button");return t.className="geoagent-control-toggle",t.type="button",t.title=this.options.title,t.setAttribute("aria-label",this.options.title),t.setAttribute("aria-expanded",String(!this.state.collapsed)),t.innerHTML=`
|
|
6298
6298
|
<span class="geoagent-control-icon">
|
|
6299
6299
|
<svg viewBox="0 0 24 24" fill="none" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
|
|
6300
6300
|
<path d="M12 6V3"></path>
|
|
@@ -6370,7 +6370,7 @@ When no dedicated browser map tool can perform the requested MapLibre operation,
|
|
|
6370
6370
|
`;let c=document.createElement("div");return c.className="geoagent-panel-resize-handle",c.setAttribute("role","separator"),c.setAttribute("aria-orientation","vertical"),c.setAttribute("aria-label","Resize GeoAgent panel"),c.addEventListener("mousedown",u=>this.startPanelResize(u)),e.append(t,A,c),this.ui={status:a,providerSelect:this.requiredElement(A,".geoagent-provider"),apiKeyLabel:this.requiredElement(A,".geoagent-api-key-label"),apiKeyInput:this.requiredElement(A,".geoagent-api-key"),modelIdInput:this.requiredElement(A,".geoagent-model-id"),bedrockRegionLabel:this.requiredElement(A,".geoagent-bedrock-region-row"),bedrockRegionInput:this.requiredElement(A,".geoagent-bedrock-region"),earthEngineDetails:this.requiredElement(A,".geoagent-earth-engine"),earthEngineClientIdInput:this.requiredElement(A,".geoagent-ee-client-id"),earthEngineProjectIdInput:this.requiredElement(A,".geoagent-ee-project-id"),earthEngineStatus:this.requiredElement(A,".geoagent-earth-engine-status"),permissionRow:this.requiredElement(A,".geoagent-toggle-row"),allowCodeInput:this.requiredElement(A,".geoagent-allow-code"),allowDestructiveInput:this.requiredElement(A,".geoagent-allow-destructive"),log:this.requiredElement(A,".geoagent-log"),form:this.requiredElement(A,".geoagent-form"),prompt:this.requiredElement(A,".geoagent-prompt"),sendButton:this.requiredElement(A,".geoagent-send"),cancelButton:this.requiredElement(A,".geoagent-cancel"),clearButton:this.requiredElement(A,".geoagent-clear"),copyButton:this.requiredElement(A,".geoagent-copy"),resizeHandle:c,closeButton:l},this.ui.permissionRow.hidden=!this.options.showPermissionToggles,this.setupEarthEngineControls(),this.populateProviderOptions(),this.wireUiEvents(),this.syncUiFromState(),e}requiredElement(e,t){let n=e.querySelector(t);if(!n)throw new Error(`Missing required element: ${t}`);return n}populateProviderOptions(){if(this.ui){this.ui.providerSelect.replaceChildren();for(let e of Object.values(this.providerConfigs())){let t=document.createElement("option");t.value=e.id,t.textContent=e.label,this.ui.providerSelect.appendChild(t)}}}setupEarthEngineControls(){var e,t,n;if(!this.ui)return;let r=!!this.options.earthEngine&&this.options.earthEngine.enabled!==!1;if(this.ui.earthEngineDetails.hidden=!r,!r)return;let a=rft((e=this.options.earthEngine)==null?void 0:e.oauthClientId),l=rft((t=this.options.earthEngine)==null?void 0:t.accessToken),A=rft(cee(this.earthEngineProjectIdStorageKey()),(n=this.options.earthEngine)==null?void 0:n.projectId);this.ui.earthEngineClientIdInput.value=a,this.ui.earthEngineProjectIdInput.value=A,this.ui.earthEngineDetails.open=!a&&!l||!A,this.applyEarthEngineSettings()}applyEarthEngineSettings(){var e;if(!this.ui||!this.options.earthEngine)return;let t=this.ui.earthEngineClientIdInput.value.trim(),n=this.ui.earthEngineProjectIdInput.value.trim();n?Jfe(this.earthEngineProjectIdStorageKey(),n):YDe(this.earthEngineProjectIdStorageKey()),this.options.earthEngine={...this.options.earthEngine,oauthClientId:t,projectId:n},(e=this.tools)==null||e.updateEarthEngineOptions(this.options.earthEngine),this.updateEarthEngineStatus(),this.emit("statechange")}updateEarthEngineStatus(){var e,t,n;if(!this.ui||this.ui.earthEngineDetails.hidden)return;let r=this.ui.earthEngineClientIdInput.value.trim(),a=(t=(e=this.options.earthEngine)==null?void 0:e.accessToken)==null?void 0:t.trim(),l=this.ui.earthEngineProjectIdInput.value.trim(),A=(n=this.state.data)==null?void 0:n.earthEngine;if(!r&&!a){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.";return}if(!l){this.ui.earthEngineStatus.textContent="Enter an Earth Engine project ID before running Earth Engine tools.";return}this.ui.earthEngineStatus.textContent=A?`Initialized: ${A.initialized?"yes":"no"}; layers: ${A.layerCount??0}.`:"Earth Engine tools configured."}wireUiEvents(){let e=this.ui;e&&(e.form.addEventListener("submit",t=>{t.preventDefault(),this.sendPrompt()}),e.providerSelect.addEventListener("change",()=>{let t=this.currentProviderId();Jfe(`${this.options.storagePrefix}.provider`,t),this.state.providerId=t,this.state.modelId=this.initialModelId(t),this.loadProviderSettings(),this.invalidateAgent(),this.updateControls(),this.emit("statechange")}),e.apiKeyInput.addEventListener("input",()=>{let t=e.apiKeyInput.value.trim(),n=this.currentProviderConfig().storageKey;t?Jfe(n,t):YDe(n),this.invalidateAgent(),this.updateControls()}),e.modelIdInput.addEventListener("input",()=>{let t=e.modelIdInput.value.trim();this.state.modelId=t,t?Jfe(this.modelStorageKey(this.state.providerId),t):YDe(this.modelStorageKey(this.state.providerId)),this.invalidateAgent(),this.updateControls(),this.emit("statechange")}),e.bedrockRegionInput.addEventListener("input",()=>{let t=e.bedrockRegionInput.value.trim();this.state.bedrockRegion=t,t?Jfe(this.bedrockRegionStorageKey(),t):YDe(this.bedrockRegionStorageKey()),this.invalidateAgent(),this.updateControls(),this.emit("statechange")}),e.earthEngineProjectIdInput.addEventListener("input",()=>{this.applyEarthEngineSettings()}),e.allowCodeInput.addEventListener("change",()=>{this.state.allowCodeExecution=e.allowCodeInput.checked,this.invalidateAgent(),this.emit("statechange")}),e.allowDestructiveInput.addEventListener("change",()=>{this.state.allowDestructiveTools=e.allowDestructiveInput.checked,this.emit("statechange")}),e.prompt.addEventListener("input",()=>this.updateControls()),e.prompt.addEventListener("keydown",t=>{if(t.key==="Enter"&&t.ctrlKey&&!t.isComposing){t.preventDefault(),e.prompt.setRangeText(`
|
|
6371
6371
|
`,e.prompt.selectionStart,e.prompt.selectionEnd,"end"),e.prompt.dispatchEvent(new Event("input",{bubbles:!0}));return}if(t.key==="Enter"&&!t.ctrlKey&&!t.metaKey&&!t.shiftKey&&!t.altKey&&!t.isComposing){t.preventDefault(),this.sendPrompt();return}(t.key==="ArrowUp"||t.key==="ArrowDown")&&this.handlePromptHistoryKey(t)}),e.clearButton.addEventListener("click",()=>{this.state.busy||(e.log.replaceChildren(),this.streamingAssistantTextEl=null,this.streamingAssistantText="",this.invalidateAgent(),this.appendLog("system","Chat cleared."))}),e.copyButton.addEventListener("click",()=>{this.copyConversationAsMarkdown()}),e.cancelButton.addEventListener("click",()=>this.cancelActiveRun()))}setupEventListeners(){var e;this.clickOutsideHandler=t=>{let n=t.target;this.container&&this.panel&&!this.container.contains(n)&&!this.panel.contains(n)&&this.collapse()},document.addEventListener("click",this.clickOutsideHandler),this.resizeHandler=()=>{this.state.collapsed||this.updatePanelPosition()},window.addEventListener("resize",this.resizeHandler),this.mapResizeHandler=()=>{this.state.collapsed||this.updatePanelPosition()},(e=this.map)==null||e.on("resize",this.mapResizeHandler)}rememberPrompt(e){this.promptHistory[this.promptHistory.length-1]!==e&&this.promptHistory.push(e),this.promptHistoryIndex=-1,this.promptHistoryDraft=""}applyPromptHistoryValue(e){this.ui&&(this.ui.prompt.value=e,this.updateControls(),requestAnimationFrame(()=>{var t;(t=this.ui)==null||t.prompt.setSelectionRange(e.length,e.length)}))}handlePromptHistoryKey(e){if(!this.ui||this.promptHistory.length===0)return;let t=this.ui.prompt,n=t.value.slice(0,t.selectionStart),r=t.value.slice(t.selectionEnd),a=!n.includes(`
|
|
6372
6372
|
`),l=!r.includes(`
|
|
6373
|
-
`);if(!(e.key==="ArrowUp"&&!a)&&!(e.key==="ArrowDown"&&!l)){if(e.preventDefault(),this.promptHistoryIndex===-1&&(this.promptHistoryDraft=t.value),e.key==="ArrowUp"){this.promptHistoryIndex=this.promptHistoryIndex===-1?this.promptHistory.length-1:Math.max(0,this.promptHistoryIndex-1),this.applyPromptHistoryValue(this.promptHistory[this.promptHistoryIndex]);return}if(this.promptHistoryIndex!==-1){if(this.promptHistoryIndex+=1,this.promptHistoryIndex>=this.promptHistory.length){this.promptHistoryIndex=-1,this.applyPromptHistoryValue(this.promptHistoryDraft);return}this.applyPromptHistoryValue(this.promptHistory[this.promptHistoryIndex])}}}constrainPanelWidth(e){return Math.max(this.options.panelMinWidth,Math.min(this.options.panelMaxWidth,Math.round(e)))}startPanelResize(e){if(!this.panel)return;e.preventDefault(),e.stopPropagation();let t=this.getControlPosition(),n=t==="top-left"||t==="bottom-left"?1:-1,r=e.clientX,a=this.panel.getBoundingClientRect().width||this.state.panelWidth;this.stopPanelResize(),this.panel.classList.add("resizing"),document.body.classList.add("geoagent-panel-resizing"),this.panelResizeMoveHandler=l=>{l.preventDefault();let A=a+(l.clientX-r)*n;this.setState({panelWidth:A})},this.panelResizeUpHandler=()=>this.stopPanelResize(),document.addEventListener("mousemove",this.panelResizeMoveHandler),document.addEventListener("mouseup",this.panelResizeUpHandler)}stopPanelResize(){var e;this.panelResizeMoveHandler&&(document.removeEventListener("mousemove",this.panelResizeMoveHandler),this.panelResizeMoveHandler=null),this.panelResizeUpHandler&&(document.removeEventListener("mouseup",this.panelResizeUpHandler),this.panelResizeUpHandler=null),(e=this.panel)==null||e.classList.remove("resizing"),document.body.classList.remove("geoagent-panel-resizing")}syncUiFromState(){if(!this.ui||!this.container)return;let e=this.container.querySelector(".geoagent-control-toggle");e?.setAttribute("aria-expanded",String(!this.state.collapsed)),this.ui.providerSelect.value=this.state.providerId,this.ui.modelIdInput.value=this.state.modelId,this.ui.bedrockRegionInput.value=this.state.bedrockRegion,this.ui.bedrockRegionLabel.hidden=this.state.providerId!=="bedrock",this.ui.allowCodeInput.checked=this.state.allowCodeExecution,this.ui.allowDestructiveInput.checked=this.state.allowDestructiveTools,this.ui.closeButton.setAttribute("aria-expanded",String(!this.state.collapsed))}currentProviderId(){var e;let t=(e=this.ui)==null?void 0:e.providerSelect.value;return t&&t in e3e?t:this.state.providerId}currentProviderConfig(){return this.providerConfig(this.currentProviderId())}loadProviderSettings(){if(!this.ui)return;let
|
|
6373
|
+
`);if(!(e.key==="ArrowUp"&&!a)&&!(e.key==="ArrowDown"&&!l)){if(e.preventDefault(),this.promptHistoryIndex===-1&&(this.promptHistoryDraft=t.value),e.key==="ArrowUp"){this.promptHistoryIndex=this.promptHistoryIndex===-1?this.promptHistory.length-1:Math.max(0,this.promptHistoryIndex-1),this.applyPromptHistoryValue(this.promptHistory[this.promptHistoryIndex]);return}if(this.promptHistoryIndex!==-1){if(this.promptHistoryIndex+=1,this.promptHistoryIndex>=this.promptHistory.length){this.promptHistoryIndex=-1,this.applyPromptHistoryValue(this.promptHistoryDraft);return}this.applyPromptHistoryValue(this.promptHistory[this.promptHistoryIndex])}}}constrainPanelWidth(e){return Math.max(this.options.panelMinWidth,Math.min(this.options.panelMaxWidth,Math.round(e)))}startPanelResize(e){if(!this.panel)return;e.preventDefault(),e.stopPropagation();let t=this.getControlPosition(),n=t==="top-left"||t==="bottom-left"?1:-1,r=e.clientX,a=this.panel.getBoundingClientRect().width||this.state.panelWidth;this.stopPanelResize(),this.panel.classList.add("resizing"),document.body.classList.add("geoagent-panel-resizing"),this.panelResizeMoveHandler=l=>{l.preventDefault();let A=a+(l.clientX-r)*n;this.setState({panelWidth:A})},this.panelResizeUpHandler=()=>this.stopPanelResize(),document.addEventListener("mousemove",this.panelResizeMoveHandler),document.addEventListener("mouseup",this.panelResizeUpHandler)}stopPanelResize(){var e;this.panelResizeMoveHandler&&(document.removeEventListener("mousemove",this.panelResizeMoveHandler),this.panelResizeMoveHandler=null),this.panelResizeUpHandler&&(document.removeEventListener("mouseup",this.panelResizeUpHandler),this.panelResizeUpHandler=null),(e=this.panel)==null||e.classList.remove("resizing"),document.body.classList.remove("geoagent-panel-resizing")}syncUiFromState(){if(!this.ui||!this.container)return;let e=this.container.querySelector(".geoagent-control-toggle");e?.setAttribute("aria-expanded",String(!this.state.collapsed)),this.ui.providerSelect.value=this.state.providerId,this.ui.modelIdInput.value=this.state.modelId,this.ui.bedrockRegionInput.value=this.state.bedrockRegion,this.ui.bedrockRegionLabel.hidden=this.state.providerId!=="bedrock",this.ui.allowCodeInput.checked=this.state.allowCodeExecution,this.ui.allowDestructiveInput.checked=this.state.allowDestructiveTools,this.ui.closeButton.setAttribute("aria-expanded",String(!this.state.collapsed))}currentProviderId(){var e;let t=(e=this.ui)==null?void 0:e.providerSelect.value;return t&&t in e3e?t:this.state.providerId}currentProviderConfig(){return this.providerConfig(this.currentProviderId())}loadProviderSettings(){var e,t;if(!this.ui)return;let n=this.currentProviderConfig(),r=((t=(e=this.options.apiKeys)==null?void 0:e[n.id])==null?void 0:t.trim())??"";this.state.providerId=n.id,this.state.modelId=cee(this.modelStorageKey(n.id))||n.defaultModel,this.ui.providerSelect.value=n.id,this.ui.apiKeyLabel.textContent=n.keyLabel,this.ui.apiKeyInput.placeholder=n.keyPlaceholder,this.ui.apiKeyInput.value=cee(n.storageKey)||r,this.ui.modelIdInput.value=this.state.modelId,this.ui.modelIdInput.placeholder=n.defaultModel,this.state.bedrockRegion=this.initialBedrockRegion(),this.ui.bedrockRegionInput.value=this.state.bedrockRegion,this.ui.bedrockRegionInput.placeholder=n.defaultRegion||"us-west-2",this.ui.bedrockRegionLabel.hidden=n.id!=="bedrock",this.updateEarthEngineStatus()}setStatus(e,t=""){this.ui&&(this.ui.status.textContent=e,this.ui.status.className=`geoagent-status ${t}`.trim())}appendLog(e,t,n=t){if(!this.ui)throw new Error("GeoAgent control UI is not mounted.");let r=document.createElement("div");r.className="geoagent-entry",r.dataset.role=e,r.dataset.markdown=n;let a=document.createElement("div");a.className="geoagent-role",a.textContent=e;let l=document.createElement("div");return l.className="geoagent-text",l.textContent=t,r.append(a,l),this.ui.log.append(r),this.ui.log.scrollTop=this.ui.log.scrollHeight,this.updateControls(),l}renderAssistantMarkdown(e,t){let n=mg(t||"",{async:!1,breaks:!1,gfm:!0});e.innerHTML=oMr.sanitize(n,{USE_PROFILES:{html:!0}});for(let r of e.querySelectorAll("a"))r.target="_blank",r.rel="noopener noreferrer"}appendAssistantLog(e){let t=this.appendLog("assistant","",e);return t.classList.add("markdown"),this.renderAssistantMarkdown(t,e),t}conversationMarkdown(){return this.ui?Array.from(this.ui.log.querySelectorAll(".geoagent-entry")).map(e=>{var t,n;let r=e.dataset.role||((t=e.querySelector(".geoagent-role"))==null?void 0:t.textContent)||"message",a=e.dataset.markdown??((n=e.querySelector(".geoagent-text"))==null?void 0:n.textContent)??"";return`## ${CRr(r)}
|
|
6374
6374
|
|
|
6375
6375
|
${a.trim()}`}).filter(e=>e.trim().length>0).join(`
|
|
6376
6376
|
|
|
@@ -28141,14 +28141,14 @@ maplibre-gl/dist/maplibre-gl.js:
|
|
|
28141
28141
|
* @license 3-Clause BSD. Full text of license: https://github.com/maplibre/maplibre-gl-js/blob/v5.24.0/LICENSE.txt
|
|
28142
28142
|
*)
|
|
28143
28143
|
|
|
28144
|
-
maplibre-gl-geoagent/dist/index-
|
|
28144
|
+
maplibre-gl-geoagent/dist/index-nbt2E_lW.js:
|
|
28145
28145
|
(**
|
|
28146
28146
|
* @license
|
|
28147
28147
|
* Copyright 2025 Google LLC
|
|
28148
28148
|
* SPDX-License-Identifier: Apache-2.0
|
|
28149
28149
|
*)
|
|
28150
28150
|
|
|
28151
|
-
maplibre-gl-geoagent/dist/GeoAgentControl-
|
|
28151
|
+
maplibre-gl-geoagent/dist/GeoAgentControl-CM-lWHhd.js:
|
|
28152
28152
|
dompurify/dist/purify.es.mjs:
|
|
28153
28153
|
(*! @license DOMPurify 3.4.2 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.4.2/LICENSE *)
|
|
28154
28154
|
|
|
@@ -5129,7 +5129,7 @@ Workflow guidance:
|
|
|
5129
5129
|
- Do not ask the user to paste JavaScript or run Python for actions that the browser map tools can perform.
|
|
5130
5130
|
- Keep responses concise and include layer names, locations, and tool results when useful.`,Vdr=`Browser JavaScript code execution is enabled for this local session. This tool runs arbitrary JavaScript in the page context and is not a safety boundary; treat it as a trusted, local-only escape hatch.
|
|
5131
5131
|
|
|
5132
|
-
When no dedicated browser map tool can perform the requested MapLibre operation, write a short JavaScript snippet and run it with run_maplibre_script. The snippet executes in the browser with these names in scope: map, maplibregl, and helpers. Prefer MapLibre GL JS API calls, keep code focused on map operations, and avoid credential handling, storage access, unrelated DOM manipulation, or broad network operations.`;Qge=class{constructor(e={}){jt(this,"options"),jt(this,"map"),jt(this,"mapContainer"),jt(this,"container"),jt(this,"panel"),jt(this,"ui"),jt(this,"tools"),jt(this,"agent",null),jt(this,"agentSignature",""),jt(this,"streamingAssistantTextEl",null),jt(this,"streamingAssistantText",""),jt(this,"promptHistory",[]),jt(this,"promptHistoryIndex",-1),jt(this,"promptHistoryDraft",""),jt(this,"state"),jt(this,"eventHandlers",new globalThis.Map),jt(this,"resizeHandler",null),jt(this,"mapResizeHandler",null),jt(this,"clickOutsideHandler",null),jt(this,"panelResizeMoveHandler",null),jt(this,"panelResizeUpHandler",null),jt(this,"activeAbortController",null),jt(this,"cancelRequested",!1),this.options={collapsed:e.collapsed??!0,position:e.position??"top-right",title:e.title??"GeoAgent",panelWidth:e.panelWidth??390,panelMinWidth:e.panelMinWidth??320,panelMaxWidth:e.panelMaxWidth??720,className:e.className??"",defaultProvider:e.defaultProvider??Ydr,storagePrefix:e.storagePrefix??Jdr,allowCodeExecutionDefault:e.allowCodeExecutionDefault??!0,allowDestructiveToolsDefault:e.allowDestructiveToolsDefault??!0,showPermissionToggles:e.showPermissionToggles??!1,defaultModel:e.defaultModel,basemaps:e.basemaps,earthEngine:e.earthEngine};let i=this.initialProviderId();this.state={collapsed:this.options.collapsed,panelWidth:this.constrainPanelWidth(this.options.panelWidth),busy:!1,providerId:i,modelId:this.initialModelId(i),bedrockRegion:this.initialBedrockRegion(),allowCodeExecution:this.options.allowCodeExecutionDefault,allowDestructiveTools:this.options.allowDestructiveToolsDefault,data:{}}}onAdd(e){return this.map=e,this.mapContainer=e.getContainer(),this.container=this.createContainer(),this.panel=this.createPanel(),this.mapContainer.appendChild(this.panel),this.tools=new lct(e,{basemaps:{...Put,...this.options.basemaps},allowCodeExecution:()=>this.state.allowCodeExecution,allowDestructiveTools:()=>this.state.allowDestructiveTools,earthEngine:this.options.earthEngine,onStateDataChange:i=>{this.state.data={...this.state.data??{},...i},this.updateEarthEngineStatus(),this.emit("statechange")}}),this.setupEventListeners(),this.loadProviderSettings(),this.setStatus("Ready","connected"),this.appendLog("system","Browser-only Strands MapLibre agent ready."),this.updateControls(),this.state.collapsed||(this.panel.classList.add("expanded"),requestAnimationFrame(()=>this.updatePanelPosition())),this.container}onRemove(){var e,i,n,r,a,l,A;this.resizeHandler&&(window.removeEventListener("resize",this.resizeHandler),this.resizeHandler=null),this.mapResizeHandler&&this.map&&(this.map.off("resize",this.mapResizeHandler),this.mapResizeHandler=null),this.clickOutsideHandler&&(document.removeEventListener("click",this.clickOutsideHandler),this.clickOutsideHandler=null),this.stopPanelResize(),(e=this.activeAbortController)==null||e.abort(),(i=this.agent)==null||i.cancel(),this.activeAbortController=null,this.cancelRequested=!1,(n=this.tools)==null||n.destroy(),this.tools=void 0,(a=(r=this.panel)==null?void 0:r.parentNode)==null||a.removeChild(this.panel),(A=(l=this.container)==null?void 0:l.parentNode)==null||A.removeChild(this.container),this.map=void 0,this.mapContainer=void 0,this.container=void 0,this.panel=void 0,this.ui=void 0,this.agent=null,this.agentSignature="",this.streamingAssistantTextEl=null,this.streamingAssistantText="",this.promptHistory=[],this.promptHistoryIndex=-1,this.promptHistoryDraft="",this.eventHandlers.clear()}getState(){return{...this.state,data:{...this.state.data}}}setState(e){var i,n;let r=e.collapsed!==void 0&&e.collapsed!==this.state.collapsed,a=e.providerId!==void 0&&e.providerId!==this.state.providerId||e.modelId!==void 0&&e.modelId!==this.state.modelId||e.allowCodeExecution!==void 0&&e.allowCodeExecution!==this.state.allowCodeExecution;if(this.state={...this.state,...e},e.panelWidth!==void 0&&this.panel){let l=this.constrainPanelWidth(e.panelWidth);this.state.panelWidth=l,this.panel.style.width=`${l}px`}r&&(this.state.collapsed?((i=this.panel)==null||i.classList.remove("expanded"),this.emit("collapse")):((n=this.panel)==null||n.classList.add("expanded"),this.updatePanelPosition(),this.emit("expand"))),a&&this.invalidateAgent(),this.syncUiFromState(),this.emit("statechange")}toggle(){this.setState({collapsed:!this.state.collapsed})}expand(){this.state.collapsed&&this.toggle()}collapse(){this.state.collapsed||this.toggle()}on(e,i){this.eventHandlers.has(e)||this.eventHandlers.set(e,new Set),this.eventHandlers.get(e).add(i)}off(e,i){var n;(n=this.eventHandlers.get(e))==null||n.delete(i)}getMap(){return this.map}getContainer(){return this.container}getPanel(){return this.panel}emit(e){let i=this.eventHandlers.get(e);if(!i)return;let n={type:e,state:this.getState()};i.forEach(r=>r(n))}providerConfigs(){return{"openai-responses":this.providerConfig("openai-responses"),"openai-chat":this.providerConfig("openai-chat"),anthropic:this.providerConfig("anthropic"),google:this.providerConfig("google"),bedrock:this.providerConfig("bedrock")}}providerConfig(e){return{...Zhe[e],storageKey:`${this.options.storagePrefix}.${e}.api_key`,defaultModel:E3i(e,this.options.defaultModel)}}initialProviderId(){let e=uW(`${this.options.storagePrefix}.provider`);return e&&e in Zhe?e:this.options.defaultProvider}initialModelId(e){return uW(this.modelStorageKey(e))||E3i(e,this.options.defaultModel)}modelStorageKey(e){return`${this.options.storagePrefix}.model.${e}`}bedrockRegionStorageKey(){return`${this.options.storagePrefix}.bedrock.region`}earthEngineProjectIdStorageKey(){return`${this.options.storagePrefix}.earthEngine.projectId`}initialBedrockRegion(){return uW(this.bedrockRegionStorageKey())||Zhe.bedrock.defaultRegion}createContainer(){let e=document.createElement("div");e.className=`maplibregl-ctrl maplibregl-ctrl-group geoagent-control${this.options.className?` ${this.options.className}`:""}`;let i=document.createElement("button");return i.className="geoagent-control-toggle",i.type="button",i.title=this.options.title,i.setAttribute("aria-label",this.options.title),i.setAttribute("aria-expanded",String(!this.state.collapsed)),i.innerHTML=`
|
|
5132
|
+
When no dedicated browser map tool can perform the requested MapLibre operation, write a short JavaScript snippet and run it with run_maplibre_script. The snippet executes in the browser with these names in scope: map, maplibregl, and helpers. Prefer MapLibre GL JS API calls, keep code focused on map operations, and avoid credential handling, storage access, unrelated DOM manipulation, or broad network operations.`;Qge=class{constructor(e={}){jt(this,"options"),jt(this,"map"),jt(this,"mapContainer"),jt(this,"container"),jt(this,"panel"),jt(this,"ui"),jt(this,"tools"),jt(this,"agent",null),jt(this,"agentSignature",""),jt(this,"streamingAssistantTextEl",null),jt(this,"streamingAssistantText",""),jt(this,"promptHistory",[]),jt(this,"promptHistoryIndex",-1),jt(this,"promptHistoryDraft",""),jt(this,"state"),jt(this,"eventHandlers",new globalThis.Map),jt(this,"resizeHandler",null),jt(this,"mapResizeHandler",null),jt(this,"clickOutsideHandler",null),jt(this,"panelResizeMoveHandler",null),jt(this,"panelResizeUpHandler",null),jt(this,"activeAbortController",null),jt(this,"cancelRequested",!1),this.options={collapsed:e.collapsed??!0,position:e.position??"top-right",title:e.title??"GeoAgent",panelWidth:e.panelWidth??390,panelMinWidth:e.panelMinWidth??320,panelMaxWidth:e.panelMaxWidth??720,className:e.className??"",defaultProvider:e.defaultProvider??Ydr,storagePrefix:e.storagePrefix??Jdr,allowCodeExecutionDefault:e.allowCodeExecutionDefault??!0,allowDestructiveToolsDefault:e.allowDestructiveToolsDefault??!0,showPermissionToggles:e.showPermissionToggles??!1,defaultModel:e.defaultModel,apiKeys:e.apiKeys,basemaps:e.basemaps,earthEngine:e.earthEngine};let i=this.initialProviderId();this.state={collapsed:this.options.collapsed,panelWidth:this.constrainPanelWidth(this.options.panelWidth),busy:!1,providerId:i,modelId:this.initialModelId(i),bedrockRegion:this.initialBedrockRegion(),allowCodeExecution:this.options.allowCodeExecutionDefault,allowDestructiveTools:this.options.allowDestructiveToolsDefault,data:{}}}onAdd(e){return this.map=e,this.mapContainer=e.getContainer(),this.container=this.createContainer(),this.panel=this.createPanel(),this.mapContainer.appendChild(this.panel),this.tools=new lct(e,{basemaps:{...Put,...this.options.basemaps},allowCodeExecution:()=>this.state.allowCodeExecution,allowDestructiveTools:()=>this.state.allowDestructiveTools,earthEngine:this.options.earthEngine,onStateDataChange:i=>{this.state.data={...this.state.data??{},...i},this.updateEarthEngineStatus(),this.emit("statechange")}}),this.setupEventListeners(),this.loadProviderSettings(),this.setStatus("Ready","connected"),this.appendLog("system","Browser-only Strands MapLibre agent ready."),this.updateControls(),this.state.collapsed||(this.panel.classList.add("expanded"),requestAnimationFrame(()=>this.updatePanelPosition())),this.container}onRemove(){var e,i,n,r,a,l,A;this.resizeHandler&&(window.removeEventListener("resize",this.resizeHandler),this.resizeHandler=null),this.mapResizeHandler&&this.map&&(this.map.off("resize",this.mapResizeHandler),this.mapResizeHandler=null),this.clickOutsideHandler&&(document.removeEventListener("click",this.clickOutsideHandler),this.clickOutsideHandler=null),this.stopPanelResize(),(e=this.activeAbortController)==null||e.abort(),(i=this.agent)==null||i.cancel(),this.activeAbortController=null,this.cancelRequested=!1,(n=this.tools)==null||n.destroy(),this.tools=void 0,(a=(r=this.panel)==null?void 0:r.parentNode)==null||a.removeChild(this.panel),(A=(l=this.container)==null?void 0:l.parentNode)==null||A.removeChild(this.container),this.map=void 0,this.mapContainer=void 0,this.container=void 0,this.panel=void 0,this.ui=void 0,this.agent=null,this.agentSignature="",this.streamingAssistantTextEl=null,this.streamingAssistantText="",this.promptHistory=[],this.promptHistoryIndex=-1,this.promptHistoryDraft="",this.eventHandlers.clear()}getState(){return{...this.state,data:{...this.state.data}}}setState(e){var i,n;let r=e.collapsed!==void 0&&e.collapsed!==this.state.collapsed,a=e.providerId!==void 0&&e.providerId!==this.state.providerId||e.modelId!==void 0&&e.modelId!==this.state.modelId||e.allowCodeExecution!==void 0&&e.allowCodeExecution!==this.state.allowCodeExecution;if(this.state={...this.state,...e},e.panelWidth!==void 0&&this.panel){let l=this.constrainPanelWidth(e.panelWidth);this.state.panelWidth=l,this.panel.style.width=`${l}px`}r&&(this.state.collapsed?((i=this.panel)==null||i.classList.remove("expanded"),this.emit("collapse")):((n=this.panel)==null||n.classList.add("expanded"),this.updatePanelPosition(),this.emit("expand"))),a&&this.invalidateAgent(),this.syncUiFromState(),this.emit("statechange")}toggle(){this.setState({collapsed:!this.state.collapsed})}expand(){this.state.collapsed&&this.toggle()}collapse(){this.state.collapsed||this.toggle()}on(e,i){this.eventHandlers.has(e)||this.eventHandlers.set(e,new Set),this.eventHandlers.get(e).add(i)}off(e,i){var n;(n=this.eventHandlers.get(e))==null||n.delete(i)}getMap(){return this.map}getContainer(){return this.container}getPanel(){return this.panel}emit(e){let i=this.eventHandlers.get(e);if(!i)return;let n={type:e,state:this.getState()};i.forEach(r=>r(n))}providerConfigs(){return{"openai-responses":this.providerConfig("openai-responses"),"openai-chat":this.providerConfig("openai-chat"),anthropic:this.providerConfig("anthropic"),google:this.providerConfig("google"),bedrock:this.providerConfig("bedrock")}}providerConfig(e){return{...Zhe[e],storageKey:`${this.options.storagePrefix}.${e}.api_key`,defaultModel:E3i(e,this.options.defaultModel)}}initialProviderId(){let e=uW(`${this.options.storagePrefix}.provider`);return e&&e in Zhe?e:this.options.defaultProvider}initialModelId(e){return uW(this.modelStorageKey(e))||E3i(e,this.options.defaultModel)}modelStorageKey(e){return`${this.options.storagePrefix}.model.${e}`}bedrockRegionStorageKey(){return`${this.options.storagePrefix}.bedrock.region`}earthEngineProjectIdStorageKey(){return`${this.options.storagePrefix}.earthEngine.projectId`}initialBedrockRegion(){return uW(this.bedrockRegionStorageKey())||Zhe.bedrock.defaultRegion}createContainer(){let e=document.createElement("div");e.className=`maplibregl-ctrl maplibregl-ctrl-group geoagent-control${this.options.className?` ${this.options.className}`:""}`;let i=document.createElement("button");return i.className="geoagent-control-toggle",i.type="button",i.title=this.options.title,i.setAttribute("aria-label",this.options.title),i.setAttribute("aria-expanded",String(!this.state.collapsed)),i.innerHTML=`
|
|
5133
5133
|
<span class="geoagent-control-icon">
|
|
5134
5134
|
<svg viewBox="0 0 24 24" fill="none" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
|
|
5135
5135
|
<path d="M12 6V3"></path>
|
|
@@ -5205,7 +5205,7 @@ When no dedicated browser map tool can perform the requested MapLibre operation,
|
|
|
5205
5205
|
`;let c=document.createElement("div");return c.className="geoagent-panel-resize-handle",c.setAttribute("role","separator"),c.setAttribute("aria-orientation","vertical"),c.setAttribute("aria-label","Resize GeoAgent panel"),c.addEventListener("mousedown",u=>this.startPanelResize(u)),e.append(i,A,c),this.ui={status:a,providerSelect:this.requiredElement(A,".geoagent-provider"),apiKeyLabel:this.requiredElement(A,".geoagent-api-key-label"),apiKeyInput:this.requiredElement(A,".geoagent-api-key"),modelIdInput:this.requiredElement(A,".geoagent-model-id"),bedrockRegionLabel:this.requiredElement(A,".geoagent-bedrock-region-row"),bedrockRegionInput:this.requiredElement(A,".geoagent-bedrock-region"),earthEngineDetails:this.requiredElement(A,".geoagent-earth-engine"),earthEngineClientIdInput:this.requiredElement(A,".geoagent-ee-client-id"),earthEngineProjectIdInput:this.requiredElement(A,".geoagent-ee-project-id"),earthEngineStatus:this.requiredElement(A,".geoagent-earth-engine-status"),permissionRow:this.requiredElement(A,".geoagent-toggle-row"),allowCodeInput:this.requiredElement(A,".geoagent-allow-code"),allowDestructiveInput:this.requiredElement(A,".geoagent-allow-destructive"),log:this.requiredElement(A,".geoagent-log"),form:this.requiredElement(A,".geoagent-form"),prompt:this.requiredElement(A,".geoagent-prompt"),sendButton:this.requiredElement(A,".geoagent-send"),cancelButton:this.requiredElement(A,".geoagent-cancel"),clearButton:this.requiredElement(A,".geoagent-clear"),copyButton:this.requiredElement(A,".geoagent-copy"),resizeHandle:c,closeButton:l},this.ui.permissionRow.hidden=!this.options.showPermissionToggles,this.setupEarthEngineControls(),this.populateProviderOptions(),this.wireUiEvents(),this.syncUiFromState(),e}requiredElement(e,i){let n=e.querySelector(i);if(!n)throw new Error(`Missing required element: ${i}`);return n}populateProviderOptions(){if(this.ui){this.ui.providerSelect.replaceChildren();for(let e of Object.values(this.providerConfigs())){let i=document.createElement("option");i.value=e.id,i.textContent=e.label,this.ui.providerSelect.appendChild(i)}}}setupEarthEngineControls(){var e,i,n;if(!this.ui)return;let r=!!this.options.earthEngine&&this.options.earthEngine.enabled!==!1;if(this.ui.earthEngineDetails.hidden=!r,!r)return;let a=D0t((e=this.options.earthEngine)==null?void 0:e.oauthClientId),l=D0t((i=this.options.earthEngine)==null?void 0:i.accessToken),A=D0t(uW(this.earthEngineProjectIdStorageKey()),(n=this.options.earthEngine)==null?void 0:n.projectId);this.ui.earthEngineClientIdInput.value=a,this.ui.earthEngineProjectIdInput.value=A,this.ui.earthEngineDetails.open=!a&&!l||!A,this.applyEarthEngineSettings()}applyEarthEngineSettings(){var e;if(!this.ui||!this.options.earthEngine)return;let i=this.ui.earthEngineClientIdInput.value.trim(),n=this.ui.earthEngineProjectIdInput.value.trim();n?qhe(this.earthEngineProjectIdStorageKey(),n):fQe(this.earthEngineProjectIdStorageKey()),this.options.earthEngine={...this.options.earthEngine,oauthClientId:i,projectId:n},(e=this.tools)==null||e.updateEarthEngineOptions(this.options.earthEngine),this.updateEarthEngineStatus(),this.emit("statechange")}updateEarthEngineStatus(){var e,i,n;if(!this.ui||this.ui.earthEngineDetails.hidden)return;let r=this.ui.earthEngineClientIdInput.value.trim(),a=(i=(e=this.options.earthEngine)==null?void 0:e.accessToken)==null?void 0:i.trim(),l=this.ui.earthEngineProjectIdInput.value.trim(),A=(n=this.state.data)==null?void 0:n.earthEngine;if(!r&&!a){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.";return}if(!l){this.ui.earthEngineStatus.textContent="Enter an Earth Engine project ID before running Earth Engine tools.";return}this.ui.earthEngineStatus.textContent=A?`Initialized: ${A.initialized?"yes":"no"}; layers: ${A.layerCount??0}.`:"Earth Engine tools configured."}wireUiEvents(){let e=this.ui;e&&(e.form.addEventListener("submit",i=>{i.preventDefault(),this.sendPrompt()}),e.providerSelect.addEventListener("change",()=>{let i=this.currentProviderId();qhe(`${this.options.storagePrefix}.provider`,i),this.state.providerId=i,this.state.modelId=this.initialModelId(i),this.loadProviderSettings(),this.invalidateAgent(),this.updateControls(),this.emit("statechange")}),e.apiKeyInput.addEventListener("input",()=>{let i=e.apiKeyInput.value.trim(),n=this.currentProviderConfig().storageKey;i?qhe(n,i):fQe(n),this.invalidateAgent(),this.updateControls()}),e.modelIdInput.addEventListener("input",()=>{let i=e.modelIdInput.value.trim();this.state.modelId=i,i?qhe(this.modelStorageKey(this.state.providerId),i):fQe(this.modelStorageKey(this.state.providerId)),this.invalidateAgent(),this.updateControls(),this.emit("statechange")}),e.bedrockRegionInput.addEventListener("input",()=>{let i=e.bedrockRegionInput.value.trim();this.state.bedrockRegion=i,i?qhe(this.bedrockRegionStorageKey(),i):fQe(this.bedrockRegionStorageKey()),this.invalidateAgent(),this.updateControls(),this.emit("statechange")}),e.earthEngineProjectIdInput.addEventListener("input",()=>{this.applyEarthEngineSettings()}),e.allowCodeInput.addEventListener("change",()=>{this.state.allowCodeExecution=e.allowCodeInput.checked,this.invalidateAgent(),this.emit("statechange")}),e.allowDestructiveInput.addEventListener("change",()=>{this.state.allowDestructiveTools=e.allowDestructiveInput.checked,this.emit("statechange")}),e.prompt.addEventListener("input",()=>this.updateControls()),e.prompt.addEventListener("keydown",i=>{if(i.key==="Enter"&&i.ctrlKey&&!i.isComposing){i.preventDefault(),e.prompt.setRangeText(`
|
|
5206
5206
|
`,e.prompt.selectionStart,e.prompt.selectionEnd,"end"),e.prompt.dispatchEvent(new Event("input",{bubbles:!0}));return}if(i.key==="Enter"&&!i.ctrlKey&&!i.metaKey&&!i.shiftKey&&!i.altKey&&!i.isComposing){i.preventDefault(),this.sendPrompt();return}(i.key==="ArrowUp"||i.key==="ArrowDown")&&this.handlePromptHistoryKey(i)}),e.clearButton.addEventListener("click",()=>{this.state.busy||(e.log.replaceChildren(),this.streamingAssistantTextEl=null,this.streamingAssistantText="",this.invalidateAgent(),this.appendLog("system","Chat cleared."))}),e.copyButton.addEventListener("click",()=>{this.copyConversationAsMarkdown()}),e.cancelButton.addEventListener("click",()=>this.cancelActiveRun()))}setupEventListeners(){var e;this.clickOutsideHandler=i=>{let n=i.target;this.container&&this.panel&&!this.container.contains(n)&&!this.panel.contains(n)&&this.collapse()},document.addEventListener("click",this.clickOutsideHandler),this.resizeHandler=()=>{this.state.collapsed||this.updatePanelPosition()},window.addEventListener("resize",this.resizeHandler),this.mapResizeHandler=()=>{this.state.collapsed||this.updatePanelPosition()},(e=this.map)==null||e.on("resize",this.mapResizeHandler)}rememberPrompt(e){this.promptHistory[this.promptHistory.length-1]!==e&&this.promptHistory.push(e),this.promptHistoryIndex=-1,this.promptHistoryDraft=""}applyPromptHistoryValue(e){this.ui&&(this.ui.prompt.value=e,this.updateControls(),requestAnimationFrame(()=>{var i;(i=this.ui)==null||i.prompt.setSelectionRange(e.length,e.length)}))}handlePromptHistoryKey(e){if(!this.ui||this.promptHistory.length===0)return;let i=this.ui.prompt,n=i.value.slice(0,i.selectionStart),r=i.value.slice(i.selectionEnd),a=!n.includes(`
|
|
5207
5207
|
`),l=!r.includes(`
|
|
5208
|
-
`);if(!(e.key==="ArrowUp"&&!a)&&!(e.key==="ArrowDown"&&!l)){if(e.preventDefault(),this.promptHistoryIndex===-1&&(this.promptHistoryDraft=i.value),e.key==="ArrowUp"){this.promptHistoryIndex=this.promptHistoryIndex===-1?this.promptHistory.length-1:Math.max(0,this.promptHistoryIndex-1),this.applyPromptHistoryValue(this.promptHistory[this.promptHistoryIndex]);return}if(this.promptHistoryIndex!==-1){if(this.promptHistoryIndex+=1,this.promptHistoryIndex>=this.promptHistory.length){this.promptHistoryIndex=-1,this.applyPromptHistoryValue(this.promptHistoryDraft);return}this.applyPromptHistoryValue(this.promptHistory[this.promptHistoryIndex])}}}constrainPanelWidth(e){return Math.max(this.options.panelMinWidth,Math.min(this.options.panelMaxWidth,Math.round(e)))}startPanelResize(e){if(!this.panel)return;e.preventDefault(),e.stopPropagation();let i=this.getControlPosition(),n=i==="top-left"||i==="bottom-left"?1:-1,r=e.clientX,a=this.panel.getBoundingClientRect().width||this.state.panelWidth;this.stopPanelResize(),this.panel.classList.add("resizing"),document.body.classList.add("geoagent-panel-resizing"),this.panelResizeMoveHandler=l=>{l.preventDefault();let A=a+(l.clientX-r)*n;this.setState({panelWidth:A})},this.panelResizeUpHandler=()=>this.stopPanelResize(),document.addEventListener("mousemove",this.panelResizeMoveHandler),document.addEventListener("mouseup",this.panelResizeUpHandler)}stopPanelResize(){var e;this.panelResizeMoveHandler&&(document.removeEventListener("mousemove",this.panelResizeMoveHandler),this.panelResizeMoveHandler=null),this.panelResizeUpHandler&&(document.removeEventListener("mouseup",this.panelResizeUpHandler),this.panelResizeUpHandler=null),(e=this.panel)==null||e.classList.remove("resizing"),document.body.classList.remove("geoagent-panel-resizing")}syncUiFromState(){if(!this.ui||!this.container)return;let e=this.container.querySelector(".geoagent-control-toggle");e?.setAttribute("aria-expanded",String(!this.state.collapsed)),this.ui.providerSelect.value=this.state.providerId,this.ui.modelIdInput.value=this.state.modelId,this.ui.bedrockRegionInput.value=this.state.bedrockRegion,this.ui.bedrockRegionLabel.hidden=this.state.providerId!=="bedrock",this.ui.allowCodeInput.checked=this.state.allowCodeExecution,this.ui.allowDestructiveInput.checked=this.state.allowDestructiveTools,this.ui.closeButton.setAttribute("aria-expanded",String(!this.state.collapsed))}currentProviderId(){var e;let i=(e=this.ui)==null?void 0:e.providerSelect.value;return i&&i in Zhe?i:this.state.providerId}currentProviderConfig(){return this.providerConfig(this.currentProviderId())}loadProviderSettings(){if(!this.ui)return;let
|
|
5208
|
+
`);if(!(e.key==="ArrowUp"&&!a)&&!(e.key==="ArrowDown"&&!l)){if(e.preventDefault(),this.promptHistoryIndex===-1&&(this.promptHistoryDraft=i.value),e.key==="ArrowUp"){this.promptHistoryIndex=this.promptHistoryIndex===-1?this.promptHistory.length-1:Math.max(0,this.promptHistoryIndex-1),this.applyPromptHistoryValue(this.promptHistory[this.promptHistoryIndex]);return}if(this.promptHistoryIndex!==-1){if(this.promptHistoryIndex+=1,this.promptHistoryIndex>=this.promptHistory.length){this.promptHistoryIndex=-1,this.applyPromptHistoryValue(this.promptHistoryDraft);return}this.applyPromptHistoryValue(this.promptHistory[this.promptHistoryIndex])}}}constrainPanelWidth(e){return Math.max(this.options.panelMinWidth,Math.min(this.options.panelMaxWidth,Math.round(e)))}startPanelResize(e){if(!this.panel)return;e.preventDefault(),e.stopPropagation();let i=this.getControlPosition(),n=i==="top-left"||i==="bottom-left"?1:-1,r=e.clientX,a=this.panel.getBoundingClientRect().width||this.state.panelWidth;this.stopPanelResize(),this.panel.classList.add("resizing"),document.body.classList.add("geoagent-panel-resizing"),this.panelResizeMoveHandler=l=>{l.preventDefault();let A=a+(l.clientX-r)*n;this.setState({panelWidth:A})},this.panelResizeUpHandler=()=>this.stopPanelResize(),document.addEventListener("mousemove",this.panelResizeMoveHandler),document.addEventListener("mouseup",this.panelResizeUpHandler)}stopPanelResize(){var e;this.panelResizeMoveHandler&&(document.removeEventListener("mousemove",this.panelResizeMoveHandler),this.panelResizeMoveHandler=null),this.panelResizeUpHandler&&(document.removeEventListener("mouseup",this.panelResizeUpHandler),this.panelResizeUpHandler=null),(e=this.panel)==null||e.classList.remove("resizing"),document.body.classList.remove("geoagent-panel-resizing")}syncUiFromState(){if(!this.ui||!this.container)return;let e=this.container.querySelector(".geoagent-control-toggle");e?.setAttribute("aria-expanded",String(!this.state.collapsed)),this.ui.providerSelect.value=this.state.providerId,this.ui.modelIdInput.value=this.state.modelId,this.ui.bedrockRegionInput.value=this.state.bedrockRegion,this.ui.bedrockRegionLabel.hidden=this.state.providerId!=="bedrock",this.ui.allowCodeInput.checked=this.state.allowCodeExecution,this.ui.allowDestructiveInput.checked=this.state.allowDestructiveTools,this.ui.closeButton.setAttribute("aria-expanded",String(!this.state.collapsed))}currentProviderId(){var e;let i=(e=this.ui)==null?void 0:e.providerSelect.value;return i&&i in Zhe?i:this.state.providerId}currentProviderConfig(){return this.providerConfig(this.currentProviderId())}loadProviderSettings(){var e,i;if(!this.ui)return;let n=this.currentProviderConfig(),r=((i=(e=this.options.apiKeys)==null?void 0:e[n.id])==null?void 0:i.trim())??"";this.state.providerId=n.id,this.state.modelId=uW(this.modelStorageKey(n.id))||n.defaultModel,this.ui.providerSelect.value=n.id,this.ui.apiKeyLabel.textContent=n.keyLabel,this.ui.apiKeyInput.placeholder=n.keyPlaceholder,this.ui.apiKeyInput.value=uW(n.storageKey)||r,this.ui.modelIdInput.value=this.state.modelId,this.ui.modelIdInput.placeholder=n.defaultModel,this.state.bedrockRegion=this.initialBedrockRegion(),this.ui.bedrockRegionInput.value=this.state.bedrockRegion,this.ui.bedrockRegionInput.placeholder=n.defaultRegion||"us-west-2",this.ui.bedrockRegionLabel.hidden=n.id!=="bedrock",this.updateEarthEngineStatus()}setStatus(e,i=""){this.ui&&(this.ui.status.textContent=e,this.ui.status.className=`geoagent-status ${i}`.trim())}appendLog(e,i,n=i){if(!this.ui)throw new Error("GeoAgent control UI is not mounted.");let r=document.createElement("div");r.className="geoagent-entry",r.dataset.role=e,r.dataset.markdown=n;let a=document.createElement("div");a.className="geoagent-role",a.textContent=e;let l=document.createElement("div");return l.className="geoagent-text",l.textContent=i,r.append(a,l),this.ui.log.append(r),this.ui.log.scrollTop=this.ui.log.scrollHeight,this.updateControls(),l}renderAssistantMarkdown(e,i){let n=xh(i||"",{async:!1,breaks:!1,gfm:!0});e.innerHTML=Dpr.sanitize(n,{USE_PROFILES:{html:!0}});for(let r of e.querySelectorAll("a"))r.target="_blank",r.rel="noopener noreferrer"}appendAssistantLog(e){let i=this.appendLog("assistant","",e);return i.classList.add("markdown"),this.renderAssistantMarkdown(i,e),i}conversationMarkdown(){return this.ui?Array.from(this.ui.log.querySelectorAll(".geoagent-entry")).map(e=>{var i,n;let r=e.dataset.role||((i=e.querySelector(".geoagent-role"))==null?void 0:i.textContent)||"message",a=e.dataset.markdown??((n=e.querySelector(".geoagent-text"))==null?void 0:n.textContent)??"";return`## ${Kdr(r)}
|
|
5209
5209
|
|
|
5210
5210
|
${a.trim()}`}).filter(e=>e.trim().length>0).join(`
|
|
5211
5211
|
|
|
@@ -26941,14 +26941,14 @@ pako/dist/pako.esm.mjs:
|
|
|
26941
26941
|
lerc/LercDecode.js:
|
|
26942
26942
|
(* Copyright 2015-2021 Esri. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @preserve *)
|
|
26943
26943
|
|
|
26944
|
-
maplibre-gl-geoagent/dist/index-
|
|
26944
|
+
maplibre-gl-geoagent/dist/index-nbt2E_lW.js:
|
|
26945
26945
|
(**
|
|
26946
26946
|
* @license
|
|
26947
26947
|
* Copyright 2025 Google LLC
|
|
26948
26948
|
* SPDX-License-Identifier: Apache-2.0
|
|
26949
26949
|
*)
|
|
26950
26950
|
|
|
26951
|
-
maplibre-gl-geoagent/dist/GeoAgentControl-
|
|
26951
|
+
maplibre-gl-geoagent/dist/GeoAgentControl-CM-lWHhd.js:
|
|
26952
26952
|
dompurify/dist/purify.es.mjs:
|
|
26953
26953
|
(*! @license DOMPurify 3.4.2 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.4.2/LICENSE *)
|
|
26954
26954
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "anymap-ts",
|
|
3
|
-
"version": "0.17.
|
|
3
|
+
"version": "0.17.1",
|
|
4
4
|
"description": "TypeScript frontend for anymap-ts interactive maps",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.ts",
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"maplibre-gl": ">=5.14.0",
|
|
59
59
|
"maplibre-gl-components": "^0.16.3",
|
|
60
60
|
"maplibre-gl-geo-editor": "^0.7.3",
|
|
61
|
-
"maplibre-gl-geoagent": "^0.4.
|
|
61
|
+
"maplibre-gl-geoagent": "^0.4.2",
|
|
62
62
|
"maplibre-gl-geophoto": "^0.2.0",
|
|
63
63
|
"maplibre-gl-layer-control": "^0.14.1",
|
|
64
64
|
"maplibre-gl-lidar": "^0.11.1",
|