feat: add Node.js MapLibre Strands TypeScript example#95
Merged
Conversation
Adds a Node/Express + Vite example that runs a Strands TypeScript agent on the server so model API keys, Codex OAuth, and AWS credentials stay off the browser, while exposing the same provider set as the GeoAgent and QGIS UIs (OpenAI, Anthropic, Gemini, Bedrock, LiteLLM, Ollama).
|
🚀 Deployed on https://6a00bc901aa4c8130dd53af6--opengeos.netlify.app |
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new runnable example (examples/node_maplibre_strands_typescript/) demonstrating a Node/Express + MapLibre app where Strands agent execution (and provider credentials) remain server-side, with small top-level docs updates to link to it.
Changes:
- Added a full Node.js TypeScript backend that streams Strands agent output over WebSockets and proxies MapLibre tool calls to the browser.
- Added a MapLibre browser client with map/tool execution, chat UI, and streaming rendering.
- Updated
README.mdandexamples/README.mdto document and link the new example.
Reviewed changes
Copilot reviewed 15 out of 16 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| README.md | Links to the new Node/MapLibre Strands TypeScript example. |
| examples/README.md | Adds the new example to the examples index. |
| examples/node_maplibre_strands_typescript/tsconfig.json | TypeScript config for building client/server code. |
| examples/node_maplibre_strands_typescript/src/server/types.ts | Shared server message/provider type definitions. |
| examples/node_maplibre_strands_typescript/src/server/tools.ts | Defines MapLibre tool schemas and session tool wiring. |
| examples/node_maplibre_strands_typescript/src/server/models.ts | Provider/model selection and provider-specific model creation. |
| examples/node_maplibre_strands_typescript/src/server/mapSession.ts | Browser session abstraction for map command RPC over WS. |
| examples/node_maplibre_strands_typescript/src/server/main.ts | Express + WS server, session lifecycle, agent streaming, and message routing. |
| examples/node_maplibre_strands_typescript/src/server/codexAuth.ts | Codex OAuth token loading/refresh logic for server-side auth. |
| examples/node_maplibre_strands_typescript/src/client/styles.css | UI styling for the example app and chat panel. |
| examples/node_maplibre_strands_typescript/src/client/main.ts | MapLibre UI, WS client, map command execution, and chat rendering. |
| examples/node_maplibre_strands_typescript/README.md | Setup/run instructions and provider configuration docs for the example. |
| examples/node_maplibre_strands_typescript/public/index.html | Static HTML shell that loads bundled client assets. |
| examples/node_maplibre_strands_typescript/package.json | Example app scripts and dependencies. |
| examples/node_maplibre_strands_typescript/.gitignore | Ignores build outputs, node_modules, and generated assets. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- server/main.ts: import the runtime WebSocket value from `ws` and compare readyState against WebSocket.OPEN so sendJson does not always early-return. - server/main.ts: reject non-object JSON payloads before treating them as ClientMessage so a `null` or scalar JSON body cannot crash the server. - server/mapSession.ts: same WebSocket.OPEN fix for the call() guard. - client/main.ts: capture allowBrowserCode/allowDestructive from the session message and reject remove_layer, clear_layers, and run_maplibre_script when the session disables them, mirroring the server-side safety flags.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
examples/node_maplibre_strands_typescript/, a Node/Express + Vite example that runs a Strands TypeScript agent on the server so model credentials never reach the browser.README.mdandexamples/README.mdto point to the new example.Test plan
npm installandnpm run devinsideexamples/node_maplibre_strands_typescript/