Skip to content

turf.js tools - #20

Draft
MKartaviciute wants to merge 4 commits into
mainfrom
maka/turf.js-tools
Draft

turf.js tools#20
MKartaviciute wants to merge 4 commits into
mainfrom
maka/turf.js-tools

Conversation

@MKartaviciute

@MKartaviciute MKartaviciute commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds a new @cesium-ai/turf-tools workspace package: server-only Turf.js spatial-analysis tools for the AI SDK agent loop, plus a geoJsonAdd/geoJsonRemove viewer tool pair (in @cesium-ai/tools-schemas / @cesium-ai/tools) so results can be rendered on the globe.

What's included

  • packages/turf-tools/ (new package) — session-scoped Turf.js tools with no Viewer dependency, run entirely in-process on the backend:
    • turf_register_dataset / turf_get_dataset — store/resolve a GeoJSON Feature or FeatureCollection by dataset_id, so large payloads aren't repeated through tool-call arguments/LLM context.
    • turf_buffer, turf_points_within_polygon, turf_intersect, turf_area, turf_hex_grid — wrap the corresponding Turf functions, chainable via dataset_id.
    • createTurfDatasetStore() — a sessionId -> datasetId -> GeoJSON store with idle-TTL eviction (default 30 min), fixing the reference implementation's unscoped global singleton store. Not yet suitable for multi-instance deployments (see package README for caveats/production notes).
  • geoJsonAdd / geoJsonRemove viewer tools (tools-schemas, tools) — render/remove GeoJSON on the live Cesium Viewer, used to visualize turf_get_dataset output.
  • Backend wiring: packages/server/src/agent.ts and chat-router.ts register the turf tools per-request (one dataset store per session), plus a new env var (see .env.example / backend/src/utils/env.ts).
  • Chat UI: MessageItem.tsx / chat-client.ts updates to support rendering these new tool calls.
  • Docs: new docs/packages/turf-tools/index.md, mkdocs.yml nav entry, updates to docs/packages/index.md and docs/packages/tools-schemas/tools.md.
  • Tests: unit tests for the new package (dataset-store.test.ts, index.test.ts, geojson.test.ts), a new e2e/turf-tools-live.spec.ts live e2e suite, plus additions to e2e/cesium-viewer-tools-live.spec.ts and backend/src/app.integration.test.ts.

Testing

  • npx vitest run — unit/integration suite passes.
  • npx playwright test e2e/turf-tools-live.spec.ts — live e2e suite passes.

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.

1 participant