Skip to content

fix(typescript): pipeline built-in tools + docs events parity for #114/#115 + CHANGELOG backfill#118

Merged
nicolotognoni merged 1 commit into
mainfrom
worktree-changelog-backfill-fixes
May 27, 2026
Merged

fix(typescript): pipeline built-in tools + docs events parity for #114/#115 + CHANGELOG backfill#118
nicolotognoni merged 1 commit into
mainfrom
worktree-changelog-backfill-fixes

Conversation

@nicolotognoni
Copy link
Copy Markdown
Collaborator

Summary

Implementation

  • libraries/typescript/src/server.ts — exported TRANSFER_CALL_TOOL / END_CALL_TOOL constants so the pipeline helper can re-use the canonical schema instead of redefining it.
  • libraries/typescript/src/stream-handler.ts — added augmentWithBuiltinHandoffTools(userTools, { transferCall, endCall }) that mirrors the Python helper shipped in fix(pipeline): inject built-in transfer_call / end_call tools into LLMLoop #115. Built-ins are appended (user tools keep their order) with handler closures that validate E.164 / default reason and dispatch to the existing telephony bridge methods. Both pipeline-mode new LLMLoop(...) call sites now pass the augmented list.
  • docs/typescript-sdk/events.mdx — replaced the broken ## EventBus section with documentation of the real TypeScript API: Speech-edge events (attribute setters on Patter proxied to speechEvents) and Tool events via onTranscript (filtered on role === "tool").
  • libraries/typescript/tests/pipeline-builtin-tools.test.ts — 8 new unit tests cover empty-user-tools, non-empty user tools order, missing-callback skip, partial-callback skip, transfer dispatch, E.164 rejection without dispatch, end_call default reason, end_call user-supplied reason.
  • CHANGELOG.md — 5 new ### Fixed entries under ## Unreleased: three for the upstream Python PRs (fix(websockets): use is_ws_alive across modern websockets>=12 API #113, docs(events): remove non-existent phone.events; document real API #114, fix(pipeline): inject built-in transfer_call / end_call tools into LLMLoop #115 — credited to @knowsuchagency) and two for the TypeScript parity fixes shipped here. Each entry leads with the user-visible effect and links file:line.

Files touched:

  • CHANGELOG.md (+91 / −0)
  • docs/typescript-sdk/events.mdx (+58 / −17)
  • libraries/typescript/src/server.ts (+2 / −2)
  • libraries/typescript/src/stream-handler.ts (+72 / −3)
  • libraries/typescript/tests/pipeline-builtin-tools.test.ts (+128 new file)
  • libraries/typescript/package-lock.json (version literal sync 0.6.1 → 0.6.2)

No new runtime dependencies.

Breaking change?

No. augmentWithBuiltinHandoffTools is purely additive on a previously broken code path (no app code relied on the missing built-ins), and the docs page replacement removes an API that crashed AttributeError immediately on import.

Test plan

Docs updates

…115)

- Pipeline mode in `libraries/typescript/src/stream-handler.ts` did not
  inject the built-in `transfer_call` / `end_call` tools into the
  `LLMLoop` (both `new LLMLoop(...)` call sites at lines 1891 and 1906
  passed `agent.tools` through unchanged). The Realtime path injects
  them at `server.ts:374`; pipeline was missing the parity. Added
  `augmentWithBuiltinHandoffTools` helper mirroring the Python helper
  shipped in #115; it builds handler closures that validate E.164 /
  default `reason` and dispatch to the existing telephony bridge
  methods (`bridge.transferCall` / `bridge.endCall`). Built-ins are
  skipped when the corresponding callback is missing, keeping
  non-telephony test harnesses clean. Exported
  `TRANSFER_CALL_TOOL` / `END_CALL_TOOL` from `server.ts` so the
  helper can re-use the canonical schema.
- Docs: `docs/typescript-sdk/events.mdx` advertised the same
  non-existent `phone.events.on(PatterEventType.X, handler)` API as
  the Python events page (closed by #114). Replaced the broken
  `EventBus` section with documentation of the APIs that actually
  exist on the TypeScript `Patter` class: speech-edge attribute
  setters (`onUserSpeechStarted` / `onAgentSpeechEnded` /
  `onLlmToken` / `onAudioOut` etc.) and tool events via
  `onTranscript` with `role === "tool"`.
- CHANGELOG: backfilled `## Unreleased` `### Fixed` entries for
  upstream PRs #113, #114, #115 (Python fixes by @knowsuchagency that
  landed without the corresponding TypeScript / changelog updates),
  plus entries for the two TypeScript parity fixes shipped here.

Test plan:
- Python: covered by tests added in the upstream PRs (#113, #115).
- TypeScript: 8 new unit tests in
  `libraries/typescript/tests/pipeline-builtin-tools.test.ts` cover
  empty-user-tools, non-empty user tools order, missing-callback
  skip, transfer dispatch + E.164 rejection, end_call default and
  user-supplied `reason`. Full suite: 1521 passed / 8 skipped, lint
  clean, build green.
@mintlify
Copy link
Copy Markdown

mintlify Bot commented May 27, 2026

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated (UTC)
patter-06b046ce 🟢 Ready View Preview May 27, 2026, 5:12 PM

💡 Tip: Enable Workflows to automatically generate PRs for you.

@nicolotognoni nicolotognoni merged commit d253ec8 into main May 27, 2026
14 checks passed
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