Skip to content

Install the latest Server SDK in guides instead of pinned versions - #908

Open
Devon-White wants to merge 3 commits into
mainfrom
devon/server-sdk-latest
Open

Devon-White wants to merge 3 commits into
mainfrom
devon/server-sdk-latest

Conversation

@Devon-White

@Devon-White Devon-White commented Nov 2, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Guides now install the latest Server SDK instead of a pinned version, so samples don't drift behind the features the pages describe.

  • Installs unpinned. signalwire-sdk==3.4.1 → signalwire-sdk, @signalwire/sdk@2.0.5 → @signalwire/sdk, and the signalwire-sdk>=1.0.15 floor in the serverless and dev-environment requirements.txt snippets → signalwire-sdk.
  • No version talk in guides. Removed the four "dial()/play() signature depends on the SDK version" notes, and reworded the code comments that named a version (the @ts-expect-error comment on the TTS pages and the enter_queue validation workaround on Call queues). Both workarounds are still needed on the latest releases (TypeScript 3.7.1, Python 3.7.5), so the code stays and only the comment changed.
  • TypeScript samples updated for the latest SDK. The latest TypeScript SDK (3.x) takes positional arguments for REST calling commands, so samples written for 2.0.5's single options object would send malformed requests. Updated: calling.dial (9 samples plus the TCPA example), calling.play, calling.stream/streamStop, calling.transfer, calling.refer, phoneNumbers.setRelayTopic, fabric.tokens.createSubscriberToken, and the sidecar server (serve() replaces run(), and the tool returns a FunctionResult). SWML Script uploads use .render(), which matches the SDK's contents type. A line highlight on Make and receive calls moved to match.
  • SMS guide gains TypeScript samples. "Send a message via REST" and "Track delivery via REST" now show messages.create() next to Python. The inbound reply server is no longer Python only: a TypeScript SWMLService adds reply with schemaValidation: false, the same approach as the Python sample, and serves the same document.
  • Serverless Lambda handler is typed. The TypeScript handler types event as ServerlessEvent, which runServerless expects, so the sample passes tsc --strict.
  • Authoring rule. .claude/rules/mdx-capability-guides.md: the install header comments are unpinned. The "Pinned versions" rule is replaced by two rules: Server SDK installs are unpinned and guides never state a minimum Server SDK version, while the Browser SDK pin @signalwire/js@4.0.0-rc.5 rxjs@7.8.2 stays literal and identical, because @signalwire/js@latest still installs 3.x. A missing SDK method is judged against the latest Server SDK release, and the validation step names the latest releases.

The @signalwire/js pins and all generated files are untouched. 27 pages changed, plus the rule file. No changelog entry, since this is documentation work.

Notes for reviewers

  • TypeScript typing gaps in the 3.7.1 SDK (no runtime effect). Under tsc --strict, these samples still report type errors that come from the SDK's own type definitions. The requests they send are correct.
    • SwmlBuilder.build() returns Record<string, unknown>, which isn't assignable to the SWMLObject that calling.dial({ swml }) and calling.transfer() expect. This affects 8 dial samples and the Forward calls transfer sample.
    • In Forward calls (Relay), call.device.params?.from_number fails to type-check because Device is a union.
    • The pages label these samples "also runs as JavaScript", so they're left as they are rather than adding casts. They're probably worth an issue against the TypeScript SDK.
  • TypeScript SDK REST reference pages still show 2.x call shapes. 91 of the 312 pages under /docs/server-sdks/reference/typescript/rest/... fail tsc --strict against 3.7.1: 42 pass a single options object where 3.x takes positional arguments, and 51 read response fields the 3.x types don't declare. Out of scope here because SDK reference pages are left alone; tracked in TypeScript Server SDK REST reference pages use 2.x call signatures #914.
  • Left as is (SDK reference): /docs/server-sdks/reference/python/agents/semantic-gate says "Requires SDK 3.7.1 or later". It documents a version on a reference page, which this change keeps.
  • Open PRs that add pinned installs (for example docs: AI agent webhooks are signed; add Server SDK signature validation #902) should follow the new rule: python -m pip install signalwire-sdk and npm install @signalwire/sdk, with no minimum-version wording.

Verification

  • Extracted every Python and TypeScript sample from the affected pages. Type-checked the TypeScript ones with tsc --strict against @signalwire/sdk 2.0.5 and 3.7.1, and ran pyright on the Python ones against signalwire-sdk 3.4.1 and 3.7.5. The Python samples show no new errors on the latest release. The TypeScript failures that appeared only on 3.7.1 are fixed here, except the typing items above.
  • Ran each changed TypeScript REST call against a stubbed fetch and compared the request body with the page's cURL example: dial, play, stream, stream.stop, transfer, refer, relay topic, subscriber token, messages.create, SWML Script create, and logs.messages.get.
  • SMS reply server: the TypeScript sample passes tsc --strict on 3.7.1 and runs unchanged as JavaScript. Served over HTTP, it returns a document identical to the Python sample's (signalwire-sdk 3.7.5), and returns 401 without credentials.
  • Serverless Lambda handler: passes tsc --strict on 3.7.1 (the previous event: unknown fails), and returns a response when invoked with a Lambda-style event.
  • yarn fern-md-check passes.

Preview

Drop signalwire-sdk==3.4.1, @signalwire/sdk@2.0.5 and the >=1.0.15
requirements floor from every guide, and update the capability-guide rule:
Server SDK installs are unpinned and guides never state a minimum Server SDK
version. The @signalwire/js v4 pin stays, since @signalwire/js@latest is
still the 3.x line.

The latest TypeScript SDK (3.x) takes positional arguments for REST calling
commands, so the TypeScript samples that relied on the 2.0.5 options-object
form are updated to match (dial, play, stream, streamStop, transfer, refer,
setRelayTopic, createSubscriberToken), the notes explaining the version
difference are removed, and the SMS guide gains the TypeScript REST
messages.create() sample that 2.0.5 couldn't provide.
@github-actions

github-actions Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

@Manny-r31

Copy link
Copy Markdown
Collaborator

@Devon-White This checks out. I pulled every TypeScript sample from the changed pages, ran tsc --strict against @signalwire/sdk@3.7.1, and checked the new call shapes against the 3.7.1 source. These all match: dial, play, stream/streamStop, transfer, refer, setRelayTopic, createSubscriberToken, messages.create (to, then from), serve(), FunctionResult, and .render() for contents: string. The only type errors left are the SWMLObject and Device ones you listed. The moved highlights are correct, and no pinned Server SDK installs are left in the guides. Both workarounds are still needed: the @ts-expect-error is still used on 3.7.1, and the 3.7.5 Python schema still requires transfer_after_bridge on enter_queue.

A few small things:

  1. SMS guide, "The TypeScript SDK can't build messaging documents yet" (send-and-receive-messages.mdx:274). This is out of date on 3.7.1. service.getBuilder().addVerb("reply", { body: "..." }, { skipValidation: true }) renders the same document as the Python sample. Could you add a TypeScript tab using that pattern, or at least drop the "Python only" sentence?
  2. serverless.mdx:118. handler = async (event: unknown, context: unknown) fails tsc --strict on 3.7.1, because runServerless takes a ServerlessEvent. Importing type ServerlessEvent from @signalwire/sdk and using it for event fixes it. This was already failing on main, but the page is in this PR.
  3. .claude/rules/mdx-capability-guides.md:103 still says "for the documented version". Now that installs are unpinned, "in the latest Server SDK release" would match the rest of the rule.
  4. Minor: the rule asks for ## Summary, ## Notes for reviewers, ## Verification, and preview URLs in the PR body.

Not for this PR: about 38 TypeScript reference pages under reference/typescript/rest/ fail type-check against 3.7.1, not just the four you named, so it may be worth one tracking issue.

- Send and receive messages: the TypeScript SDK serves the reply document
  with schemaValidation off, matching the Python sample's output, so the
  server step shows both languages.
- Serverless: the Lambda handler types its event as ServerlessEvent, which
  runServerless expects, so the sample passes tsc --strict.
- Capability guides rule: a missing SDK method is judged against the
  latest Server SDK release.
@Devon-White

Devon-White commented Nov 3, 2026 •

Copy link
Copy Markdown
Collaborator Author

@Manny-r31 Thanks for the thorough check. Changes are in ad015a6.

  1. SMS reply server: fixed. I added a "TypeScript — SWML service" tab next to the Python one and dropped the "Python only" sentence. I didn't use getBuilder().addVerb(..., { skipValidation: true }), because the SDK describes that option as an escape hatch for its own internal assembly. Instead the sample uses SWMLService's documented schemaValidation: false option with service.addVerb("reply", …), which is the same approach as the Python sample's schema_validation=False. On 3.7.1 it passes tsc --strict, runs as JavaScript, and serves a document identical to the Python sample's on 3.7.5.
  2. serverless.mdx: fixed. The handler now imports type ServerlessEvent and uses it for event. It passes tsc --strict on 3.7.1, and I confirmed that the old unknown version fails.
  3. Rule wording: fixed. It now says "in the latest Server SDK release".
  4. PR body: fixed. It now has ## Summary, ## Notes for reviewers, ## Verification, and preview URLs for every changed page.

Follow-up: #914. By my count, 91 of the 312 TypeScript REST reference pages fail tsc --strict against 3.7.1. In 42 of them, the sample passes a single options object where 3.x expects positional arguments, so the request it sends is malformed (checked with a stubbed fetch). 51 pages read response fields that the 3.x types don't declare, and two pages have both problems. #914 lists every affected page.

yarn fern-md-check 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.

3 participants