TW-5722: add JSON-RPC server over WebSocket exposing the CLI surface#114
Merged
Conversation
Add `nylas rpc serve` — a JSON-RPC 2.0 server over WebSocket exposing the CLI surface (email, calendar, contacts, threads, drafts, agent accounts, scheduler, notetaker, admin, auth grant ops) as a second inbound adapter over the existing ports.*Client interfaces. - Full CRUD parity for email, calendar/events, contacts, and API grant ops; folders, attachments, signatures, scheduled sends, free/busy, availability, recurring instances, room resources, and virtual-calendar grants - Attachment download capped at 30 MiB; per-grant resolution with default grant - Incremental pollers (messages, threads, events, contacts) with notifications - Integration suite launches the real binary over WebSocket (read-only smoke + protocol/notification/read/write coverage) - docs/RPC.md documents the method surface Also correct the agent rule `assign_to_folder` hint and docs: the value is now a folder name (UUID folder IDs no longer resolve), matching the API change in developer.nylas.com#630.
…Config Poll intervals were hardcoded (5s/30s focused/idle, 60s contacts). Make them configurable at startup via env vars and live over RPC: - NYLAS_WS_POLL_FAST / _IDLE / _CONTACTS seed the intervals (invalid or non-positive values fall back to the previous defaults). - New client.pollConfig request method updates the live intervals (optional Go-duration fields; omitted fields unchanged) and returns the effective values; takes effect on the next poll cycle, no restart. Contacts now run through RunAdaptive on their own controller, unifying all four pollers on one driver. That retired the dead MessagePoller.Run / ThreadPoller.Run / ContactPoller.Run / runTicker (only ContactPoller.Run was ever wired), along with their tests. Docs: documented the env vars and client.pollConfig in docs/RPC.md.
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
Adds
nylas rpc serve— a JSON-RPC 2.0 server over WebSocket that exposes the Nylas CLI surface to a thin client / future GUI. It is implemented as a second inbound adapter (alongside the Cobra CLI) over the existingports.*Clientinterfaces, so it reuses the same adapters, grant resolution, and validation rather than duplicating logic.Scope is data operations: email, calendar/events, contacts, threads, drafts, agent accounts, scheduler, notetaker, admin, and API auth-grant ops. Interactive login and local-session commands stay CLI-only.
What's included
-32xxxerror mapping (no internal detail leaked), per-grant resolution falling back to the default grant.nylas rpc servebinary over WebSocket: a read-only smoke test plus protocol/notification/read/write coverage.docs/RPC.mddocuments the method surface.Also corrects the agent rule
assign_to_folderhint and docs: the value is now a folder name (UUID folder IDs no longer resolve), matching the API change documented in nylas/developer.nylas.com#630.Testing
make ci— green (fmt, vet, lint, unit, race, security, vuln, build)internal/cli/agentbuild/vet/lint/tests green after theassign_to_folderchangeRelated docs
assign_to_folderaction now takes a folder name