Skip to content

feat: add Node.js MapLibre Strands TypeScript example#95

Merged
giswqs merged 2 commits into
mainfrom
feat/node-maplibre-strands-typescript
May 10, 2026
Merged

feat: add Node.js MapLibre Strands TypeScript example#95
giswqs merged 2 commits into
mainfrom
feat/node-maplibre-strands-typescript

Conversation

@giswqs

@giswqs giswqs commented May 10, 2026

Copy link
Copy Markdown
Member

Summary

  • Adds 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.
  • Supports the same provider set as the GeoAgent and QGIS UIs, including ChatGPT/Codex OAuth, OpenAI, Anthropic, Gemini, Amazon Bedrock, LiteLLM, and Ollama.
  • Updates the top-level README.md and examples/README.md to point to the new example.

Test plan

  • npm install and npm run dev inside examples/node_maplibre_strands_typescript/
  • Load the app in a browser and confirm the MapLibre canvas renders
  • Send a prompt with each configured provider and confirm tool calls update the map

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).
Copilot AI review requested due to automatic review settings May 10, 2026 16:40
@github-actions

github-actions Bot commented May 10, 2026

Copy link
Copy Markdown

@github-actions github-actions Bot temporarily deployed to pull request May 10, 2026 16:41 Inactive

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.md and examples/README.md to 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.

Comment thread examples/node_maplibre_strands_typescript/src/server/main.ts
Comment thread examples/node_maplibre_strands_typescript/src/server/mapSession.ts
Comment thread examples/node_maplibre_strands_typescript/src/server/main.ts
Comment thread examples/node_maplibre_strands_typescript/src/client/main.ts
Comment thread examples/node_maplibre_strands_typescript/src/client/main.ts
Comment thread examples/node_maplibre_strands_typescript/package.json
- 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.
@github-actions github-actions Bot temporarily deployed to pull request May 10, 2026 17:12 Inactive
@giswqs giswqs merged commit 1a41c78 into main May 10, 2026
9 checks passed
@giswqs giswqs deleted the feat/node-maplibre-strands-typescript branch May 10, 2026 17:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants