@volter/twin-livekit 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/README.md +106 -0
- package/dist/src/cli.d.ts +2 -0
- package/dist/src/cli.js +23 -0
- package/dist/src/egress-service-cli.d.ts +2 -0
- package/dist/src/egress-service-cli.js +101 -0
- package/dist/src/index.d.ts +14 -0
- package/dist/src/index.js +53 -0
- package/dist/src/livekit-budget.d.ts +57 -0
- package/dist/src/livekit-budget.js +131 -0
- package/dist/src/livekit-capabilities.d.ts +3 -0
- package/dist/src/livekit-capabilities.js +728 -0
- package/dist/src/livekit-conformance.d.ts +8 -0
- package/dist/src/livekit-conformance.js +13 -0
- package/dist/src/livekit-connector.d.ts +130 -0
- package/dist/src/livekit-connector.js +382 -0
- package/dist/src/livekit-data.d.ts +86 -0
- package/dist/src/livekit-data.js +246 -0
- package/dist/src/livekit-perform-harness.d.ts +5 -0
- package/dist/src/livekit-perform-harness.js +17 -0
- package/dist/src/livekit-server.d.ts +23 -0
- package/dist/src/livekit-server.js +45 -0
- package/dist/src/livekit-service-cli.d.ts +2 -0
- package/dist/src/livekit-service-cli.js +88 -0
- package/dist/src/livekit-token.d.ts +68 -0
- package/dist/src/livekit-token.js +76 -0
- package/dist/src/livekit-twin.d.ts +4 -0
- package/dist/src/livekit-twin.js +1161 -0
- package/dist/src/livekit-types.d.ts +203 -0
- package/dist/src/livekit-types.js +1 -0
- package/dist/src/livekit-webhook.d.ts +26 -0
- package/dist/src/livekit-webhook.js +79 -0
- package/dist/src/redis-service-cli.d.ts +2 -0
- package/dist/src/redis-service-cli.js +35 -0
- package/dist/test-fixtures/livekit-openapi-operations.SOURCE.md +88 -0
- package/dist/test-fixtures/livekit-openapi-operations.json +442 -0
- package/dist/test-fixtures/protobufs/cloud_replay.proto +82 -0
- package/dist/test-fixtures/protobufs/livekit_agent.proto +185 -0
- package/dist/test-fixtures/protobufs/livekit_agent_dispatch.proto +103 -0
- package/dist/test-fixtures/protobufs/livekit_agent_simulation.proto +422 -0
- package/dist/test-fixtures/protobufs/livekit_agent_worker.proto +29 -0
- package/dist/test-fixtures/protobufs/livekit_agentdb.proto +226 -0
- package/dist/test-fixtures/protobufs/livekit_analytics.proto +312 -0
- package/dist/test-fixtures/protobufs/livekit_cloud_agent.proto +376 -0
- package/dist/test-fixtures/protobufs/livekit_connector.proto +41 -0
- package/dist/test-fixtures/protobufs/livekit_connector_twilio.proto +65 -0
- package/dist/test-fixtures/protobufs/livekit_connector_whatsapp.proto +171 -0
- package/dist/test-fixtures/protobufs/livekit_egress.proto +641 -0
- package/dist/test-fixtures/protobufs/livekit_ingress.proto +222 -0
- package/dist/test-fixtures/protobufs/livekit_internal.proto +228 -0
- package/dist/test-fixtures/protobufs/livekit_metrics.proto +103 -0
- package/dist/test-fixtures/protobufs/livekit_models.proto +992 -0
- package/dist/test-fixtures/protobufs/livekit_phone_number.proto +151 -0
- package/dist/test-fixtures/protobufs/livekit_room.proto +312 -0
- package/dist/test-fixtures/protobufs/livekit_rtc.proto +673 -0
- package/dist/test-fixtures/protobufs/livekit_sip.proto +1000 -0
- package/dist/test-fixtures/protobufs/livekit_token_source.proto +49 -0
- package/dist/test-fixtures/protobufs/livekit_webhook.proto +62 -0
- package/package.json +58 -0
- package/src/cli.ts +22 -0
- package/src/egress-service-cli.ts +111 -0
- package/src/index.ts +103 -0
- package/src/livekit-budget.ts +158 -0
- package/src/livekit-capabilities.ts +789 -0
- package/src/livekit-conformance.ts +15 -0
- package/src/livekit-connector.ts +406 -0
- package/src/livekit-data.ts +278 -0
- package/src/livekit-perform-harness.ts +17 -0
- package/src/livekit-server.ts +67 -0
- package/src/livekit-service-cli.ts +93 -0
- package/src/livekit-token.ts +133 -0
- package/src/livekit-twin.ts +1162 -0
- package/src/livekit-types.ts +211 -0
- package/src/livekit-webhook.ts +91 -0
- package/src/redis-service-cli.ts +39 -0
- package/test-fixtures/livekit-openapi-operations.SOURCE.md +88 -0
- package/test-fixtures/livekit-openapi-operations.json +442 -0
- package/test-fixtures/protobufs/cloud_replay.proto +82 -0
- package/test-fixtures/protobufs/livekit_agent.proto +185 -0
- package/test-fixtures/protobufs/livekit_agent_dispatch.proto +103 -0
- package/test-fixtures/protobufs/livekit_agent_simulation.proto +422 -0
- package/test-fixtures/protobufs/livekit_agent_worker.proto +29 -0
- package/test-fixtures/protobufs/livekit_agentdb.proto +226 -0
- package/test-fixtures/protobufs/livekit_analytics.proto +312 -0
- package/test-fixtures/protobufs/livekit_cloud_agent.proto +376 -0
- package/test-fixtures/protobufs/livekit_connector.proto +41 -0
- package/test-fixtures/protobufs/livekit_connector_twilio.proto +65 -0
- package/test-fixtures/protobufs/livekit_connector_whatsapp.proto +171 -0
- package/test-fixtures/protobufs/livekit_egress.proto +641 -0
- package/test-fixtures/protobufs/livekit_ingress.proto +222 -0
- package/test-fixtures/protobufs/livekit_internal.proto +228 -0
- package/test-fixtures/protobufs/livekit_metrics.proto +103 -0
- package/test-fixtures/protobufs/livekit_models.proto +992 -0
- package/test-fixtures/protobufs/livekit_phone_number.proto +151 -0
- package/test-fixtures/protobufs/livekit_room.proto +312 -0
- package/test-fixtures/protobufs/livekit_rtc.proto +673 -0
- package/test-fixtures/protobufs/livekit_sip.proto +1000 -0
- package/test-fixtures/protobufs/livekit_token_source.proto +49 -0
- package/test-fixtures/protobufs/livekit_webhook.proto +62 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
# @volter/twin-livekit
|
|
2
|
+
|
|
3
|
+
A local **LiveKit control-plane twin** for offline room and egress tests. It
|
|
4
|
+
models the Twirp JSON APIs used by `livekit-server-sdk` for room lifecycle,
|
|
5
|
+
participant inspection, metadata updates, and room-composite egress.
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
world-livekit serve [--port N] [--root DIR] [--read-only]
|
|
9
|
+
world-livekit conformance [--root DIR]
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## Coverage
|
|
13
|
+
|
|
14
|
+
The capability manifest (`src/livekit-capabilities.ts`) is an honest partial
|
|
15
|
+
denominator for LiveKit server APIs: RoomService, Egress, Ingress, SIP, agent
|
|
16
|
+
dispatch, webhooks, tokens, recording outputs, auth/error behavior, and media
|
|
17
|
+
plane behavior are enumerated.
|
|
18
|
+
|
|
19
|
+
**Modeled:**
|
|
20
|
+
|
|
21
|
+
- **RoomService**: `CreateRoom`, `ListRooms`, `DeleteRoom`,
|
|
22
|
+
`UpdateRoomMetadata`, `ListParticipants`, `GetParticipant`,
|
|
23
|
+
`RemoveParticipant`, `UpdateParticipant` (including atomic permission grant
|
|
24
|
+
replacement), `MutePublishedTrack`, `UpdateSubscriptions`, `SendData`,
|
|
25
|
+
`ForwardParticipant` (mirror into a destination room; mirror cannot publish)
|
|
26
|
+
and `MoveParticipant` (relocate; left source, present in destination).
|
|
27
|
+
- **Participants/tracks**: deterministic local participant rows with track
|
|
28
|
+
source and muted state, permission grants, and per-participant subscription
|
|
29
|
+
sets, including the `SCREEN_SHARE` checks Runhuman uses. Participant rows are
|
|
30
|
+
seeded through the local-only `livekit.Twin` test hook; the real WebRTC
|
|
31
|
+
join/media path is not claimed as vendor API coverage.
|
|
32
|
+
- **Egress**: all five start verbs — `StartRoomCompositeEgress`,
|
|
33
|
+
`StartWebEgress`, `StartParticipantEgress`, `StartTrackCompositeEgress`,
|
|
34
|
+
`StartTrackEgress` (each tagged with the correct protobuf `request` oneof
|
|
35
|
+
case) — plus `ListEgress`, `StopEgress`, `UpdateLayout`, `UpdateStream`
|
|
36
|
+
(add/remove stream URLs), segment outputs, image (thumbnail) outputs, the
|
|
37
|
+
per-egress `webhookUrl` config field, and terminal failure-state transitions
|
|
38
|
+
(`FAILED`/`ABORTED`/`LIMIT_REACHED`). Image/webhook config is persisted on the
|
|
39
|
+
request and round-trips via `ListEgress`; this twin records the control-plane
|
|
40
|
+
state rather than running egress workers that render bytes.
|
|
41
|
+
- **Ingress**: `CreateIngress`, `UpdateIngress`, `ListIngress`,
|
|
42
|
+
`DeleteIngress`; RTMP/WHIP/URL input types with stream-key/URL minting and
|
|
43
|
+
the RTMP-transcoding vs WHIP-bypass defaults.
|
|
44
|
+
- **SIP** (`SIPService`): `CreateSIPInboundTrunk` / `CreateSIPOutboundTrunk` +
|
|
45
|
+
`ListSIPInboundTrunk` / `ListSIPOutboundTrunk` (filter by id/number) +
|
|
46
|
+
`DeleteSIPTrunk`; `CreateSIPDispatchRule` (direct + individual `rule` oneof) +
|
|
47
|
+
`ListSIPDispatchRule` (filter by id/trunk, wildcard rules match) +
|
|
48
|
+
`DeleteSIPDispatchRule`; `CreateSIPParticipant` (dials over a known outbound
|
|
49
|
+
trunk and adds a `kind=SIP` room participant) + `TransferSIPParticipant`
|
|
50
|
+
(records the transfer destination on participant attributes). Trunk/rule
|
|
51
|
+
*update* verbs are still TODO. This twin models SIP control, not signalling/RTP.
|
|
52
|
+
- **Agent dispatch** (`AgentDispatchService`): `CreateDispatch`, `ListDispatch`
|
|
53
|
+
(filter by room + dispatch id), and `DeleteDispatch`. This twin models the
|
|
54
|
+
dispatch records, not an agent worker runtime.
|
|
55
|
+
- **Access tokens**: `mintAccessToken` / `verifyAccessToken` produce and check
|
|
56
|
+
HS256 grant JWTs that are byte-compatible with the SDK's `AccessToken` and
|
|
57
|
+
`TokenVerifier` (video + SIP grants, exp/nbf, forgery rejection).
|
|
58
|
+
- **Webhooks**: `buildWebhookBody` / `signWebhookHeader` / `verifyWebhook`
|
|
59
|
+
produce and verify signed webhook deliveries (HMAC auth header + body
|
|
60
|
+
`sha256`) that round-trip with the SDK's `WebhookReceiver`, covering room,
|
|
61
|
+
participant, egress, and ingress events.
|
|
62
|
+
- **Auth & errors**: opt-in access-token enforcement (`apiKeys` on the server /
|
|
63
|
+
handler) yields vendor-faithful `unauthenticated` (missing/invalid/expired
|
|
64
|
+
token) and `permission_denied` (missing grant) Twirp errors, plus an
|
|
65
|
+
`resource_exhausted` egress capacity quota.
|
|
66
|
+
- **SDK fidelity**: tests drive the unmodified `RoomServiceClient`,
|
|
67
|
+
`EgressClient`, `IngressClient`, `SipClient`, `AgentDispatchClient`,
|
|
68
|
+
`AccessToken`/`TokenVerifier`, and `WebhookReceiver` against the local twin.
|
|
69
|
+
- **Connector**: injected-client pull folds rooms/participants/egresses/ingresses
|
|
70
|
+
into local state (`pullLiveKitSnapshot`), plus SIP trunks/dispatch rules
|
|
71
|
+
(`pullLiveKitSIP`) and per-room agent dispatches (`pullLiveKitAgentDispatch`),
|
|
72
|
+
all idempotent; push confirms pending room metadata and egress stop actions.
|
|
73
|
+
|
|
74
|
+
**Planned (todo):**
|
|
75
|
+
|
|
76
|
+
- **Outbound webhook delivery** — POST the signed event bodies the twin already
|
|
77
|
+
builds to the configured `webhookUrl`, with the documented retry schedule.
|
|
78
|
+
- **Still TODO** (not faked): SIP trunk/dispatch-rule *update* verbs
|
|
79
|
+
(`UpdateSIPInboundTrunk` / `UpdateSIPOutboundTrunk` / `UpdateSIPDispatchRule`,
|
|
80
|
+
replace + field-merge). Unmodeled SIP/agent ops fail with a vendor-faithful
|
|
81
|
+
`not_found` Twirp error rather than being faked.
|
|
82
|
+
|
|
83
|
+
### No UI mirror
|
|
84
|
+
|
|
85
|
+
LiveKit is a vendor whose **product is the API**: the twin models the server-side SFU control plane
|
|
86
|
+
(RoomService, Egress, Ingress, SIP, agent dispatch, tokens, webhooks), which applications drive from
|
|
87
|
+
code. LiveKit Cloud's console is incidental project/key tooling, not where the work happens. Per
|
|
88
|
+
[../../../docs/contributing/adding-a-twin.md](../../../docs/contributing/adding-a-twin.md) ("Does this vendor get a mirror?") and
|
|
89
|
+
[../../../docs/contributing/architecture.md](../../../docs/contributing/architecture.md) C1b, this pack ships **no React mirror and no UI
|
|
90
|
+
capabilities** — omit rather than fabricate a dashboard. Coverage is API + connector + tokens.
|
|
91
|
+
|
|
92
|
+
## The store door
|
|
93
|
+
|
|
94
|
+
LiveKit's server API is Twirp: every operation, `ListRooms` included, is a POST to
|
|
95
|
+
`/twirp/livekit.<Service>/<Method>`. The vendor surface has no GET, so twin state had no
|
|
96
|
+
ordinary read. `GET /twin/store/{rooms,participants,egress,ingress}` is that read — the pack's
|
|
97
|
+
own named deterministic projections over stored state, served by the same fetch adapter the
|
|
98
|
+
Twirp paths come out of (the `mailgun` precedent). They are deliberately **out of the capability
|
|
99
|
+
manifest**: counting scaffolding the vendor does not have would pad the denominator. `GET /twin`
|
|
100
|
+
names them under `stores`.
|
|
101
|
+
|
|
102
|
+
## Architecture
|
|
103
|
+
|
|
104
|
+
State lives in the `@volter/world-core` event/action log. The serve path makes no real
|
|
105
|
+
LiveKit calls. Connector functions accept injected executors for real LiveKit
|
|
106
|
+
I/O and are not used by the local handler.
|
package/dist/src/cli.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { keepProcessAlive } from '@volter/world-core/lifecycle';
|
|
3
|
+
import { hasFlag, optionValue } from '@volter/world-core/args';
|
|
4
|
+
import { createLiveKitTwinServer } from "./livekit-server.js";
|
|
5
|
+
const [cmd, ...rest] = process.argv.slice(2);
|
|
6
|
+
const port = Number(optionValue(rest, '--port', '0')) || undefined;
|
|
7
|
+
const root = optionValue(rest, '--root') || undefined;
|
|
8
|
+
const readOnly = hasFlag(rest, '--read-only');
|
|
9
|
+
if (cmd === 'serve') {
|
|
10
|
+
const server = await createLiveKitTwinServer({ readOnly, ...(root ? { root } : {}), ...(port ? { port } : {}) });
|
|
11
|
+
process.stdout.write(`livekit twin${readOnly ? ' [read-only]' : ''} at http://127.0.0.1:${server.port}\n`);
|
|
12
|
+
await keepProcessAlive();
|
|
13
|
+
}
|
|
14
|
+
else if (cmd === 'conformance') {
|
|
15
|
+
const { checkLiveKitConformance } = await import("./livekit-conformance.js");
|
|
16
|
+
const report = await checkLiveKitConformance({ ...(root ? { root } : {}) });
|
|
17
|
+
process.stdout.write(`${JSON.stringify(report, null, 2)}\n`);
|
|
18
|
+
if (!report.ok)
|
|
19
|
+
process.exitCode = 1;
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
process.stdout.write('Usage: world-livekit serve|conformance [--port N] [--root DIR] [--read-only]\n');
|
|
23
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// @ts-nocheck
|
|
3
|
+
import { spawn, spawnSync } from 'node:child_process';
|
|
4
|
+
import { existsSync } from 'node:fs';
|
|
5
|
+
const PORT = process.env.PORT;
|
|
6
|
+
const LIVEKIT_URL = process.env.LIVEKIT_URL;
|
|
7
|
+
const REDIS_HOST = process.env.REDIS_HOST;
|
|
8
|
+
if (!PORT)
|
|
9
|
+
throw new Error('PORT is required');
|
|
10
|
+
if (!LIVEKIT_URL)
|
|
11
|
+
throw new Error('LIVEKIT_URL is required');
|
|
12
|
+
if (!REDIS_HOST)
|
|
13
|
+
throw new Error('REDIS_HOST is required');
|
|
14
|
+
// Loopback mode (EGRESS_LOOPBACK_PORTS, extra host ports such as an S3 twin's): a forwarding sidecar owns the
|
|
15
|
+
// egress's network namespace and carries 127.0.0.1:<port> to this host's loopback, so the egress reaches LiveKit,
|
|
16
|
+
// Redis and every named port at the same 127.0.0.1 address as everything else on this host. One storage endpoint
|
|
17
|
+
// URL then means the same place to the egress (which uploads to it) and to the host process that reads it back.
|
|
18
|
+
const loopbackPorts = (process.env.EGRESS_LOOPBACK_PORTS ?? '').split(',').map((p) => p.trim()).filter(Boolean);
|
|
19
|
+
const loopback = loopbackPorts.length > 0;
|
|
20
|
+
const portOf = (value) => /:(\d+)/.exec(value ?? '')?.[1];
|
|
21
|
+
const hostLiveKitUrl = loopback ? LIVEKIT_URL : LIVEKIT_URL.replace('127.0.0.1', 'host.docker.internal');
|
|
22
|
+
const hostRedis = loopback ? REDIS_HOST : REDIS_HOST.replace('127.0.0.1', 'host.docker.internal');
|
|
23
|
+
const dockerReachable = (value) => value?.replace('127.0.0.1', 'host.docker.internal').replace('localhost', 'host.docker.internal');
|
|
24
|
+
const proxyUrl = dockerReachable(process.env.HTTPS_PROXY || process.env.HTTP_PROXY || '');
|
|
25
|
+
const caBundle = process.env.AWS_CA_BUNDLE || process.env.SSL_CERT_FILE || '';
|
|
26
|
+
const containerCa = '/tmp/volter-world-ca.pem';
|
|
27
|
+
const configBody = [
|
|
28
|
+
// The keys of the LiveKit this egress serves (a World names its own); the dev pair is LiveKit's --dev default.
|
|
29
|
+
`api_key: ${process.env.LIVEKIT_API_KEY ?? 'devkey'}`,
|
|
30
|
+
`api_secret: ${process.env.LIVEKIT_API_SECRET ?? 'secret'}`,
|
|
31
|
+
`ws_url: ${hostLiveKitUrl}`,
|
|
32
|
+
'insecure: true',
|
|
33
|
+
`health_port: ${PORT}`,
|
|
34
|
+
'redis:',
|
|
35
|
+
` address: ${hostRedis}`,
|
|
36
|
+
'cpu_cost:',
|
|
37
|
+
' room_composite_cpu_cost: 1.0',
|
|
38
|
+
' web_cpu_cost: 1.0',
|
|
39
|
+
' track_composite_cpu_cost: 1.0',
|
|
40
|
+
' track_cpu_cost: 0.5',
|
|
41
|
+
'log_level: info',
|
|
42
|
+
'',
|
|
43
|
+
].join('\n');
|
|
44
|
+
const name = `volter-livekit-egress-${PORT}`;
|
|
45
|
+
const sidecar = `${name}-loopback`;
|
|
46
|
+
if (loopback) {
|
|
47
|
+
const forward = [...new Set([portOf(LIVEKIT_URL), portOf(REDIS_HOST), ...loopbackPorts].filter(Boolean))];
|
|
48
|
+
const script = forward.map((p) => `socat TCP-LISTEN:${p},fork,reuseaddr,bind=127.0.0.1 TCP:host.docker.internal:${p} &`).join(' ') + ' wait';
|
|
49
|
+
spawnSync('docker', ['rm', '-f', sidecar], { stdio: 'ignore' });
|
|
50
|
+
const started = spawnSync('docker', ['run', '-d', '--rm', '--name', sidecar, '-p', `127.0.0.1:${PORT}:${PORT}`, '--entrypoint', 'sh', 'alpine/socat', '-c', script], { stdio: 'inherit' });
|
|
51
|
+
if (started.status !== 0)
|
|
52
|
+
throw new Error('the egress loopback sidecar did not start');
|
|
53
|
+
}
|
|
54
|
+
const dockerArgs = [
|
|
55
|
+
'run',
|
|
56
|
+
'--rm',
|
|
57
|
+
'--name',
|
|
58
|
+
name,
|
|
59
|
+
'--cap-add=SYS_ADMIN',
|
|
60
|
+
...(loopback ? ['--network', `container:${sidecar}`] : ['-p', `127.0.0.1:${PORT}:${PORT}`]),
|
|
61
|
+
'-e',
|
|
62
|
+
`EGRESS_CONFIG_BODY=${configBody}`,
|
|
63
|
+
];
|
|
64
|
+
if (proxyUrl) {
|
|
65
|
+
const noProxy = '127.0.0.1,localhost,host.docker.internal';
|
|
66
|
+
dockerArgs.push('-e', `HTTPS_PROXY=${proxyUrl}`, '-e', `HTTP_PROXY=${proxyUrl}`, '-e', `https_proxy=${proxyUrl}`, '-e', `http_proxy=${proxyUrl}`, '-e', `NO_PROXY=${noProxy}`, '-e', `no_proxy=${noProxy}`);
|
|
67
|
+
}
|
|
68
|
+
if (caBundle) {
|
|
69
|
+
if (!existsSync(caBundle))
|
|
70
|
+
throw new Error(`world CA bundle does not exist: ${caBundle}`);
|
|
71
|
+
dockerArgs.push('-e', `AWS_CA_BUNDLE=${containerCa}`, '-e', `SSL_CERT_FILE=${containerCa}`);
|
|
72
|
+
}
|
|
73
|
+
dockerArgs.push('livekit/egress:latest');
|
|
74
|
+
const child = spawn('docker', dockerArgs, { stdio: 'inherit' });
|
|
75
|
+
function copyCaIntoContainer(attempt = 0) {
|
|
76
|
+
if (!caBundle)
|
|
77
|
+
return;
|
|
78
|
+
const result = spawnSync('docker', ['cp', caBundle, `${name}:${containerCa}`], { stdio: 'ignore' });
|
|
79
|
+
if (result.status === 0)
|
|
80
|
+
return;
|
|
81
|
+
if (attempt >= 50) {
|
|
82
|
+
process.stderr.write(`failed to copy world CA into ${name}; S3 egress TLS may fail\n`);
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
setTimeout(() => copyCaIntoContainer(attempt + 1), 100);
|
|
86
|
+
}
|
|
87
|
+
copyCaIntoContainer();
|
|
88
|
+
async function stop() {
|
|
89
|
+
try {
|
|
90
|
+
spawn('docker', ['rm', '-f', name], { stdio: 'ignore' });
|
|
91
|
+
if (loopback)
|
|
92
|
+
spawn('docker', ['rm', '-f', sidecar], { stdio: 'ignore' });
|
|
93
|
+
}
|
|
94
|
+
catch {
|
|
95
|
+
// best effort
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
process.on('SIGTERM', () => { stop(); process.exit(0); });
|
|
99
|
+
process.on('SIGINT', () => { stop(); process.exit(0); });
|
|
100
|
+
child.on('exit', (code) => { if (loopback)
|
|
101
|
+
spawnSync('docker', ['rm', '-f', sidecar], { stdio: 'ignore' }); process.exit(code ?? 0); });
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export { handleLiveKitTwinRequest } from './livekit-twin.js';
|
|
2
|
+
export { createLiveKitTwinFetch, createLiveKitTwinServer, type LiveKitTwinFetchOptions } from './livekit-server.js';
|
|
3
|
+
export { liveKitHttpOrigin, liveKitRequestForAction, liveKitTwirpPath, liveLiveKitExecute, pullLiveKitSnapshot, pullLiveKitSIP, pullLiveKitAgentDispatch, pushLiveKitAction, syncLiveKitFromReal, } from './livekit-connector.js';
|
|
4
|
+
export type { LiveKitExecute, LiveKitService } from './livekit-connector.js';
|
|
5
|
+
export { LIVEKIT_BUDGET_CEILING, LIVEKIT_BUDGET_MAX_RETRY_AFTER_S, LIVEKIT_BUDGET_WINDOW_MS, LIVEKIT_CALL_WEIGHTS, LIVEKIT_RATE_BUDGET, LiveKitBudget, LiveKitBudgetError, liveKitBudgetPath, liveKitCallWeight, } from './livekit-budget.js';
|
|
6
|
+
export type { LiveKitBudgetErrorKind, LiveKitBudgetOptions, LiveKitBudgetReservation, LiveKitBudgetSnapshot, } from './livekit-budget.js';
|
|
7
|
+
export { mintAccessToken, verifyAccessToken } from './livekit-token.js';
|
|
8
|
+
export type { LiveKitClaimGrants, LiveKitVideoGrant, LiveKitSIPGrant, MintTokenInput, VerifyResult } from './livekit-token.js';
|
|
9
|
+
export { buildWebhookBody, signWebhookHeader, verifyWebhook } from './livekit-webhook.js';
|
|
10
|
+
export type { WebhookEventInput, WebhookVerifyResult } from './livekit-webhook.js';
|
|
11
|
+
export type { EgressRequestCase, LiveKitEgress, LiveKitIngress, LiveKitParticipant, LiveKitParticipantPermission, LiveKitRequest, LiveKitResponse, LiveKitRoom, LiveKitTrack, LiveKitWebhookEvent, LiveKitSIPInboundTrunk, LiveKitSIPOutboundTrunk, LiveKitSIPDispatchRule, LiveKitSIPParticipant, LiveKitAgentDispatch, } from './livekit-types.js';
|
|
12
|
+
export { EGRESS_STATUS, INGRESS_INPUT, INGRESS_STATUS, PARTICIPANT_STATE, SIP_TRANSPORT, TRACK_SOURCE, TRACK_TYPE } from './livekit-data.js';
|
|
13
|
+
import { type TwinPack } from '@volter/world-core';
|
|
14
|
+
export declare const pack: TwinPack;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
export { handleLiveKitTwinRequest } from "./livekit-twin.js";
|
|
2
|
+
export { createLiveKitTwinFetch, createLiveKitTwinServer } from "./livekit-server.js";
|
|
3
|
+
export { liveKitHttpOrigin, liveKitRequestForAction, liveKitTwirpPath, liveLiveKitExecute, pullLiveKitSnapshot, pullLiveKitSIP, pullLiveKitAgentDispatch, pushLiveKitAction, syncLiveKitFromReal, } from "./livekit-connector.js";
|
|
4
|
+
// The client-side rate budget — the fail-closed backstop `liveLiveKitExecute` routes every live
|
|
5
|
+
// request through. The mechanism is the kernel's (`@volter/world-core` -> rateBudget.ts); these are this
|
|
6
|
+
// vendor's numbers and the typed bindings around them.
|
|
7
|
+
export { LIVEKIT_BUDGET_CEILING, LIVEKIT_BUDGET_MAX_RETRY_AFTER_S, LIVEKIT_BUDGET_WINDOW_MS, LIVEKIT_CALL_WEIGHTS, LIVEKIT_RATE_BUDGET, LiveKitBudget, LiveKitBudgetError, liveKitBudgetPath, liveKitCallWeight, } from "./livekit-budget.js";
|
|
8
|
+
export { mintAccessToken, verifyAccessToken } from "./livekit-token.js";
|
|
9
|
+
export { buildWebhookBody, signWebhookHeader, verifyWebhook } from "./livekit-webhook.js";
|
|
10
|
+
export { EGRESS_STATUS, INGRESS_INPUT, INGRESS_STATUS, PARTICIPANT_STATE, SIP_TRANSPORT, TRACK_SOURCE, TRACK_TYPE } from "./livekit-data.js";
|
|
11
|
+
import { registerPack } from '@volter/world-core';
|
|
12
|
+
import { LIVEKIT_RATE_BUDGET as RATE_BUDGET } from "./livekit-budget.js";
|
|
13
|
+
import { performLiveKitAction, syncLiveKitFromRemote } from "./livekit-connector.js";
|
|
14
|
+
export const pack = {
|
|
15
|
+
// PROTOCOL 2 (docs/contributing/architecture.md#protocol-2-the-pack-is-a-plugin): the pack is a plugin — its wire, its tree, and its half of the real
|
|
16
|
+
// state system: perform one entry against LiveKit's Twirp RPCs, refresh the root from them. Moved
|
|
17
|
+
// 2026-09-08.
|
|
18
|
+
protocol: '2',
|
|
19
|
+
refresh: { every: '1m', webhook: true, onDemand: { atMost: '10s' } }, // rooms and egresses move fast
|
|
20
|
+
stateSystem: { perform: performLiveKitAction, refresh: syncLiveKitFromRemote },
|
|
21
|
+
// the round trip: create a room — LiveKit's CreateRoom answers the existing room when it is already
|
|
22
|
+
// there, so it repeats cleanly on a branch
|
|
23
|
+
roundTrip: { method: 'POST', path: '/twirp/livekit.RoomService/CreateRoom', body: { name: 'round-trip' } },
|
|
24
|
+
parityOrigin: 'http://twin',
|
|
25
|
+
vendor: 'livekit',
|
|
26
|
+
// The SAME object livekit-budget.ts declares at module load — one source of truth, so registering
|
|
27
|
+
// the pack and importing the connector arm identical numbers.
|
|
28
|
+
rateBudget: RATE_BUDGET,
|
|
29
|
+
transport: 'rest',
|
|
30
|
+
archetype: 'crud',
|
|
31
|
+
bin: 'world-livekit',
|
|
32
|
+
resources: ['room', 'participant', 'egress', 'ingress', 'sip_inbound_trunk', 'sip_outbound_trunk', 'sip_dispatch_rule', 'sip_participant', 'agent_dispatch'],
|
|
33
|
+
specSource: 'LiveKit Server APIs: RoomService (incl. Forward/MoveParticipant), Egress, Ingress, SIP (SIPService), and AgentDispatchService Twirp JSON endpoints + AccessToken/WebhookReceiver schemes used by livekit-server-sdk 2.15.x; this pack models the control plane, not the media plane.',
|
|
34
|
+
description: 'LiveKit control-plane twin — local rooms, participants, egress/ingress lifecycle, access-token grants, and webhook signing for server SDK integrations.',
|
|
35
|
+
browserRouting: { apiPathPrefix: '/twirp/', loaderHost: 'https://livekit.cloud' },
|
|
36
|
+
// INTERCEPTION RULING — hostsNone, the pack's own home for it: real local media plane
|
|
37
|
+
// (livekit-server) exposed via app-read env (LIVEKIT_URL is ws:// — WebSocket media is
|
|
38
|
+
// outside the HTTP injector's reach).
|
|
39
|
+
hostsNone: "real local media plane (livekit-server) exposed via app-read env (LIVEKIT_URL is ws:// — WebSocket media is outside the HTTP injector's reach)",
|
|
40
|
+
// Adoption, moved off the central maps unchanged (descriptor-first back-migration, adding-a-twin.md §3,
|
|
41
|
+
// 2026-08-31).
|
|
42
|
+
adoption: {
|
|
43
|
+
// LiveKit's official Python distributions: the server API client (the counterpart of
|
|
44
|
+
// `livekit-server-sdk`), the realtime SDK (`@livekit/rtc-node`), and the agents framework whose
|
|
45
|
+
// core connects to a LiveKit server.
|
|
46
|
+
pypi: ['livekit-api', 'livekit', 'livekit-agents'],
|
|
47
|
+
sdks: ['livekit-server-sdk', '@livekit/rtc-node'],
|
|
48
|
+
scopes: ['@livekit/'],
|
|
49
|
+
envStems: ['LIVEKIT'],
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
// registered at import: the kernel learns the pack's state system (protocol 2)
|
|
53
|
+
registerPack(pack);
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { RateBudget, type RateBudgetDeclaration, type RateBudgetOptions, type RateBudgetReservation, type RateBudgetSnapshot } from '@volter/world-core';
|
|
2
|
+
/** Rolling window, in ms. Matches LiveKit's own per-MINUTE Server API limit. */
|
|
3
|
+
export declare const LIVEKIT_BUDGET_WINDOW_MS = 60000;
|
|
4
|
+
/** Weighted units allowed inside one window. 200 reads/60s = 20% of the documented 1,000/min. */
|
|
5
|
+
export declare const LIVEKIT_BUDGET_CEILING = 200;
|
|
6
|
+
/** Seconds. A `Retry-After` above this means the project is throttled hard — fail loudly. */
|
|
7
|
+
export declare const LIVEKIT_BUDGET_MAX_RETRY_AFTER_S = 300;
|
|
8
|
+
/**
|
|
9
|
+
* Per-call cost, keyed by the Twirp RPC id (`"<Service>/<Method>"`) this connector is about to invoke.
|
|
10
|
+
* A LiveKit call is not a REST path — it is an RPC — so the RPC id is the honest call key.
|
|
11
|
+
*/
|
|
12
|
+
export declare const LIVEKIT_CALL_WEIGHTS: {
|
|
13
|
+
/** The per-room inner loop: one `ListParticipants` / `ListDispatch` per room. Unbounded fan-out. */
|
|
14
|
+
readonly perRoomFanOut: 2;
|
|
15
|
+
/** A flat `List…` / `Get…` read: one call for a whole collection. */
|
|
16
|
+
readonly read: 1;
|
|
17
|
+
/** Anything else, including every mutating method. Priced above a read, never free. */
|
|
18
|
+
readonly other: 2;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* THE PACK'S DECLARATION — pure data, the only LiveKit-specific thing in the whole budget. Rules are
|
|
22
|
+
* ordered and first-match-wins, and they are keyed on the Twirp RPC id, so the per-room fan-out rules
|
|
23
|
+
* must come BEFORE the generic list/get rule.
|
|
24
|
+
*
|
|
25
|
+
* Also exported as `pack.rateBudget` (see index.ts), so `registerPack` arms it too.
|
|
26
|
+
*/
|
|
27
|
+
export declare const LIVEKIT_RATE_BUDGET: RateBudgetDeclaration;
|
|
28
|
+
/**
|
|
29
|
+
* Price one call. Keyed off the Twirp RPC the connector is ABOUT to invoke, so an unclassified method
|
|
30
|
+
* still costs `defaultWeight` — an unknown method must never be free.
|
|
31
|
+
*/
|
|
32
|
+
export declare function liveKitCallWeight(service: string, method: string): number;
|
|
33
|
+
/** Where LiveKit's ledger lives. API-key-keyed and cwd-independent by default (the limit is per
|
|
34
|
+
* PROJECT and the API key identifies the project, so a cwd-scoped ledger would hand the same project
|
|
35
|
+
* a fresh allowance in every checkout, worktree and CI matrix leg); pass `root` to opt into
|
|
36
|
+
* world-scoped accounting instead. */
|
|
37
|
+
export declare function liveKitBudgetPath(opts?: {
|
|
38
|
+
root?: string;
|
|
39
|
+
token?: string;
|
|
40
|
+
} | string): string;
|
|
41
|
+
/** Construction options for LiveKit's budget. The vendor is fixed; everything else may only TIGHTEN. */
|
|
42
|
+
export type LiveKitBudgetOptions = Omit<RateBudgetOptions, 'vendor'>;
|
|
43
|
+
/**
|
|
44
|
+
* LiveKit's budget — the shared kernel guard bound to this vendor's declaration. A real subclass, not
|
|
45
|
+
* an alias, so `budget instanceof LiveKitBudget` in `liveLiveKitExecute` still means "a budget that
|
|
46
|
+
* accounts against LIVEKIT's ledger under LIVEKIT's ceiling": another vendor's `RateBudget` (with its
|
|
47
|
+
* own, possibly larger, ceiling) is NOT assignable there.
|
|
48
|
+
*/
|
|
49
|
+
export declare class LiveKitBudget extends RateBudget {
|
|
50
|
+
constructor(opts?: LiveKitBudgetOptions);
|
|
51
|
+
}
|
|
52
|
+
/** The typed refusal. One error class shared with every other vendor's budget; `err.vendor` says
|
|
53
|
+
* which one refused, and `err.kind` says why. */
|
|
54
|
+
export { RateBudgetError as LiveKitBudgetError } from '@volter/world-core';
|
|
55
|
+
export type { RateBudgetErrorKind as LiveKitBudgetErrorKind } from '@volter/world-core';
|
|
56
|
+
export type LiveKitBudgetReservation = RateBudgetReservation;
|
|
57
|
+
export type LiveKitBudgetSnapshot = RateBudgetSnapshot;
|