Commit a193401
feat: add deployment field to agent dispatch (#1111)
## Summary
- Add `deployment` field to `RoomAgentDispatch` for targeting specific
agent deployments
- Add `agentDeployment` to `TokenRequestOptions` to pass deployment
through token requests
- Update generated JSON serialization code
The `deployment` field allows targeting a specific agent deployment
(e.g., "staging"). Leave empty to target the production deployment.
Related PRs:
- node-sdks: livekit/node-sdks#675
- python-sdks: livekit/python-sdks#722
- rust-sdks: livekit/rust-sdks#1176
- client-sdk-swift:
livekit/client-sdk-swift#1043
- client-sdk-js: livekit/client-sdk-js#1971
## Usage
```dart
final options = TokenRequestOptions(
roomName: 'my-room',
agentName: 'my-agent',
agentDeployment: 'staging', // Optional: target specific deployment
);
```
Or directly via `RoomAgentDispatch`:
```dart
final dispatch = RoomAgentDispatch(
agentName: 'my-agent',
metadata: 'my-metadata',
deployment: 'staging',
);
```
## Test plan
### Unit Tests
```bash
flutter test
flutter test test/token/token_source_test.dart -v
```
### Manual Verification
**1. Verify JSON serialization includes deployment:**
```dart
final dispatch = RoomAgentDispatch(
agentName: 'my-agent',
deployment: 'staging',
);
final json = dispatch.toJson();
print(json); // Should include 'deployment': 'staging'
```
**2. Verify TokenRequestOptions converts to request correctly:**
```dart
final options = TokenRequestOptions(
roomName: 'test-room',
agentName: 'my-agent',
agentDeployment: 'staging',
);
final request = options.toRequest();
print(request.roomConfiguration?.agents?.first?.deployment); // Should print 'staging'
```
**3. Verify JSON round-trip:**
```dart
final original = RoomAgentDispatch(
agentName: 'my-agent',
deployment: 'staging',
);
final json = original.toJson();
final restored = RoomAgentDispatch.fromJson(json);
assert(restored.deployment == 'staging');
```
### End-to-End Verification
1. Use TokenSource to get credentials with agentDeployment set
2. Connect to room - agent with matching deployment should join
3. Verify only staging agent receives the dispatch
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>1 parent 1c03b55 commit a193401
4 files changed
Lines changed: 16 additions & 2 deletions
File tree
- lib/src/token_source
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
29 | 32 | | |
30 | 33 | | |
31 | 34 | | |
| 35 | + | |
32 | 36 | | |
33 | 37 | | |
34 | 38 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
46 | 49 | | |
47 | 50 | | |
48 | 51 | | |
| |||
51 | 54 | | |
52 | 55 | | |
53 | 56 | | |
| 57 | + | |
54 | 58 | | |
55 | 59 | | |
56 | 60 | | |
57 | 61 | | |
58 | 62 | | |
59 | 63 | | |
60 | 64 | | |
61 | | - | |
62 | | - | |
| 65 | + | |
| 66 | + | |
63 | 67 | | |
64 | 68 | | |
65 | 69 | | |
| |||
83 | 87 | | |
84 | 88 | | |
85 | 89 | | |
| 90 | + | |
86 | 91 | | |
87 | 92 | | |
88 | 93 | | |
| |||
95 | 100 | | |
96 | 101 | | |
97 | 102 | | |
| 103 | + | |
98 | 104 | | |
99 | 105 | | |
100 | 106 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
0 commit comments