Skip to content

accelerate-v0.6.367

@kanat kanat tagged this 20 Nov 16:05
## Why

`Backend.speakingFor` (added in #2110) is tagged `@internal`, but the
package has no `stripInternal`, so `dist/backend.d.ts` published it as a
method of the public `Backend`, beside the deprecated `actingFor` it
duplicates. AI-3411.

`stripInternal` was not used. It would hide the 15 `@internal` symbols
that the published 0.5.0 `.d.ts` already exposes (`onRetry`, `Tools.of`,
`Conversation.said`/`observe`, `Session.cameraFrames`,
`LiveUI.observeTurns`, ...), which breaks published types. `speakingFor`
itself is not in 0.5.0.

Checked: `npm pack @stream-io/stream-agents@0.5.0`, then `grep -rl
@internal dist --include=*.d.ts` finds 15 tags.

## How it works

```
before: Backend.speakingFor(userId)      -> on the type, autocompleted
after:  speakingFor(backend, userId)     -> module function in backend.ts, no entry point re-exports it
        Backend.actingFor(userId)        -> calls it, same copy, same request
```

- `speakingFor` is a module function in `sdks/js/src/backend.ts`. No
entry point re-exports it: the test covers the five entry points (`.`,
`./node`, `./chat`, `./video`, `./react`) and `Backend`'s statics.
- `package.json` `exports` has only those five paths, so a consumer
cannot import `dist/backend.js`. The copy is the same code; its private
fields are reached by name (`acting["fetched"]`).

## Changes

- `sdks/js/src/backend.ts`: `speakingFor` becomes a module function;
`actingFor` calls it. The actsFor and actingForValue docs name
`actingFor`.
- `sdks/js/src/connections.ts`, `dispatch.ts`: call the function.
- `sdks/js/tests/backend.test.ts`: `@ts-expect-error` on
`backend.speakingFor`; `actingFor` still works; `speakingFor` absent
from all five entry points and from `Backend`'s statics.
- `sdks/js/tests/token.test.ts`: a copy acting for another user carries
neither the original's fetched token nor its user.
- `.claude/skills/sdk/SKILL.md` line 789 (AI-3413): a user's team is no
longer said to be `for_user(team=)`. It names `create_user_token(...,
team=)` and `user_id=` on `Client.agent`/`Client.router` of a client
built with `team=`/`usage_categories=`; `for_user` is deprecated
(#2103). Line 936: `speakingFor` is named as a module function in
`backend.ts`.
- No CHANGELOG entry: `speakingFor` was never released, so nothing
user-visible changes.

## Review rounds

| Round | Verdict | Findings | Fixed in |
|---|---|---|---|
| R1 | NO-GO | R1.1 no test that keeps `speakingFor` off the exports;
R1.2 actsFor/actingForValue docs named `speakingFor`; R1.3 SKILL.md:936
still called it a `Backend` method | 5430d9909 |
| R2 | NO-GO | R2.1 test checked two of the five entry points; chat,
video and react re-exports survived | 788302d46 |
| R3 | GO | Orchestrator check: delta 5430d9909..788302d46 is test-only
(+6); chat, video and react re-export mutants each fail; head 50/50 |
(no change) |

Follow-ups: `Tools.failure`, `ToolCalls.observe`, `offerTool` are
unreleased and published the same way, ticketed as AI-3451.

## Validation

- `cd sdks/js && npm run types -- --check && npm test` on 788302d46: 794
pass, 0 fail.
- CI on 788302d46: `sdks` pass, plus CodeQL, Analyze
(actions/go/python), GitGuardian and labeler, all pass.
- Mutations, each killed by a test: re-adding the method (tsc: unused
`@ts-expect-error`); a re-export of `speakingFor` from `index`, `node`,
`chat`, `video` or `react`; a `static speakingFor` on `Backend`;
dropping the `userIdValue`, `user`, `fetched` or `fetching` reset; each
of the three call sites (`connections.ts` x2, `dispatch.ts`).

AI-3411, AI-3413.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
Assets 2
Loading