@neta-art/cohub 4.8.0 → 5.0.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/README.md +42 -1
- package/dist/chunks/http.d.ts +2 -2
- package/dist/chunks/http.js +2 -2
- package/dist/chunks/transport.js +7 -2
- package/dist/chunks/websocket.d.ts +192 -49
- package/dist/chunks/websocket.js +56 -4
- package/dist/http.d.ts +2 -2
- package/dist/index.d.ts +131 -7
- package/dist/index.js +837 -230
- package/docs/work-runtime-guide.md +123 -12
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -216,7 +216,7 @@ A **Work** is a published, shareable web page hosted by Cohub. When a viewer
|
|
|
216
216
|
opens a Work, it runs inside a Cohub-managed runtime that provides short-lived
|
|
217
217
|
access tokens — no API keys required.
|
|
218
218
|
|
|
219
|
-
|
|
219
|
+
Four runtime-only APIs are available **exclusively inside a published Work**:
|
|
220
220
|
|
|
221
221
|
- `client.context()` — returns Work identity, Space identity, and current
|
|
222
222
|
permission scopes. Returns `null` outside a Work runtime.
|
|
@@ -224,6 +224,8 @@ Three runtime-only APIs are available **exclusively inside a published Work**:
|
|
|
224
224
|
and caches a token with the approved scopes.
|
|
225
225
|
- `client.work.commerce.*` — entitlement checks, credit consumption,
|
|
226
226
|
purchases.
|
|
227
|
+
- `client.work.realtime.*` — temporary rooms, typed events, presence, and
|
|
228
|
+
membership.
|
|
227
229
|
|
|
228
230
|
### Quick start (inside a Work)
|
|
229
231
|
|
|
@@ -259,6 +261,45 @@ lets you send a prompt but does NOT let you read the reply — that needs
|
|
|
259
261
|
`session.view` (a work scope). Similarly, `generation.create` lets you create
|
|
260
262
|
a generation task, but polling its result needs `taskrun.view` (a work scope).
|
|
261
263
|
|
|
264
|
+
### Realtime rooms
|
|
265
|
+
|
|
266
|
+
Work runtime rooms are generic, temporary event channels. The SDK does not
|
|
267
|
+
know the Work's business events; define their names and payload types in the
|
|
268
|
+
Work itself.
|
|
269
|
+
|
|
270
|
+
```ts
|
|
271
|
+
type Events = {
|
|
272
|
+
"shared.state.updated": { value: number };
|
|
273
|
+
"activity.submitted": { itemId: string };
|
|
274
|
+
};
|
|
275
|
+
|
|
276
|
+
const room = await client.work.realtime.createRoom<Events>({
|
|
277
|
+
code: "TEAM-ALPHA", // optional; generated when omitted
|
|
278
|
+
maxParticipants: 64,
|
|
279
|
+
expiresInSeconds: 2 * 60 * 60,
|
|
280
|
+
});
|
|
281
|
+
|
|
282
|
+
const stop = room.subscribe("shared.state.updated", (event) => {
|
|
283
|
+
console.log(event.sequence, event.data.value, event.self);
|
|
284
|
+
});
|
|
285
|
+
|
|
286
|
+
await room.publish("shared.state.updated", { value: 42 });
|
|
287
|
+
await room.setPresence({ status: "active" });
|
|
288
|
+
await room.leave();
|
|
289
|
+
stop();
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
`expiresInSeconds` is an absolute lifetime from server-side room creation. It
|
|
293
|
+
never extends on publish, presence, or heartbeat. The maximum lifetime is
|
|
294
|
+
24 hours. Room events are live and ordered while connected, with publish ACKs
|
|
295
|
+
and sequence-gap detection; events missed during a disconnect are not replayed.
|
|
296
|
+
|
|
297
|
+
For high-frequency traffic such as input frames, `room.send(type, data)` skips
|
|
298
|
+
the per-event ACK that would otherwise cap throughput at one round trip per
|
|
299
|
+
event; failures surface through `room.onSendError`. Every connection is its own
|
|
300
|
+
participant by default; create the room with `seatPerUser: true` to give each
|
|
301
|
+
viewer a single seat instead.
|
|
302
|
+
|
|
262
303
|
For the complete API-to-scope mapping, initialization recipe, capability
|
|
263
304
|
recipes, a full working example, and a pitfalls checklist, see the
|
|
264
305
|
**[Work Runtime Guide](./docs/work-runtime-guide.md)**.
|
package/dist/chunks/http.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as CreateSpacePromptInput, $
|
|
1
|
+
import { $ as CreateSpacePromptInput, $n as SpaceFsTreeResponse, Ai as BoardCapabilities, Ar as SpaceUsageResponse, At as Permission, Br as ChannelHealth, Bt as ReferenceAggregateGroupBy, Ci as BoardAwarenessUpdate, Cn as SpaceCommerceBenefit, Ct as LabelResourceType, Di as WorkContentKind, Dn as SpaceCommerceOrder, Dt as ModelCatalogEntry, Er as SpaceTurnAuthorFilter, Et as MeResponse, Fn as SpaceCreateResponse, Fr as UserRulesResponse, Ft as PublicUserPageResponse, Gi as BoardPlaybackSnapshot, Gt as ReferenceQueryableType, Hi as BoardPlaybackCommand, Hn as SpaceFsCreateUploadResponse, Ht as ReferenceDirection, Ii as BoardInspectInput, In as SpaceDefaultResponse, J as ClaimReferralResponse, Jn as SpaceFsMoveInput, Jt as ReferralDashboard, K as CheckpointDiffSummary, Ln as SpaceEnvInput, Mi as BoardCreateInput, Mn as SpaceConfigInput, Mr as TaskRunDetailResponse, Nn as SpaceConfigResponse, Nr as TaskRunRecord, Nt as PromptTemplateCatalogResponse, On as SpaceCommerceProduct, Ot as PatchResourceLabelsInput, Pn as SpaceConfigUpdateResponse, Pr as UserProfile, Pt as PublicReferral, Qn as SpaceFsReadFilesResponse, R as Channel, Rn as SpaceFsCompleteUploadInput, Rr as UserSessionsResponse, Sa as RequestSource, Sn as SpaceCheckpointDetailResponse, Tr as SpaceSessionsResponse, Ut as ReferenceKind, V as CheckpointDiffFileResponse, Vn as SpaceFsCreateUploadInput, Vt as ReferenceAggregateResponse, Wt as ReferenceQueryResponse, X as CreateInvitationResponse, Xi as BoardValidationResult, Y as CreateInvitationInput, Yi as BoardTransaction, Yn as SpaceFsPreparingFile, Z as CreateSpaceInput, _a as BillingPayload, _r as SpacePresenceSnapshot, a as WebsocketClientOptions, aa as SessionTurnRecord, an as SessionRecord, at as CursorPageInfo, br as SpaceRecord, ci as BoardTransactionAppliedEvent$1, cn as SessionTurnSignedUrlsResponse, d as BatchUserProfilesResponse, di as RealtimePatchOperation, dn as SessionTurnsPaginatedResponse, dt as GlobalSearchType, ea as SpacePublicEndpoints, et as CreateSpacePromptResponse, fa as CreateSpaceCompletionInput, fr as SpaceMember, ft as InvitationDetail, ga as Usage, gn as SpaceAccessPolicy, gr as SpacePendingDiffSummary, ha as SpaceCompletionStreamEvent, hr as SpacePendingDiffFileResponse, ii as GenerationModelDeclaration, in as SessionMessagesResponse, it as CronJobUpdatePatch, ki as BoardBootstrap, kn as SpaceCommerceProductBenefitBinding, kt as PatchResourceLabelsResponse, l as AcceptInvitationResponse, ln as SessionTurnStreamSnapshotResponse, lr as SpaceInvitationListResponse, lt as GlobalSearchResponse, ma as SpaceCompletionResult, mr as SpaceModListItem, na as SessionForkRecord, nn as SessionMessageResponse, oa as SpaceTurnsResponse, oi as BoardAwarenessUpdatedEvent$1, on as SessionTurnIndexResponse, or as SpaceFsUploadResponse, pn as SkillCatalogResponse, q as CheckpointRecord, qn as SpaceFsFileResponse, r as WebsocketClient, ri as GenerationContentBlock, rn as SessionMessagesPaginatedResponse, rt as CronJobRecord, s as WebsocketEventPayload, si as BoardPlaybackChangedEvent$1, sn as SessionTurnResponse, sr as SpaceFsWriteFileInput, ta as MessageRecord, tt as CreateSpaceSessionInput, un as SessionTurnWindowResponse, va as ContentBlock, vi as SessionTurnPatchEvent, vt as LabelAssignmentRecord, wi as WorkArtifactDescriptor, wn as SpaceCommerceBuyerProfile, xr as SpaceRole, xt as LabelListItem, yr as SpacePublicProfile, yt as LabelItemsResponse, zn as SpaceFsCompleteUploadResponse, zr as ChannelConfig } from "./websocket.js";
|
|
2
2
|
import { n as CohubEnvironment } from "./environment.js";
|
|
3
3
|
import { a as VoiceInputCreateOptions } from "./voice-input.js";
|
|
4
4
|
//#region ../protocol/dist/model/status.d.ts
|
|
@@ -921,7 +921,7 @@ declare class SpacesApi {
|
|
|
921
921
|
getDefault(customFetch?: Fetch): Promise<SpaceDefaultResponse>;
|
|
922
922
|
get(spaceId: string, customFetch?: Fetch): Promise<SpaceRecord>;
|
|
923
923
|
getBySlug(username: string, slug: string, customFetch?: Fetch): Promise<SpaceRecord>;
|
|
924
|
-
create(input
|
|
924
|
+
create(input: CreateSpaceInput, headers?: Record<string, string>): Promise<SpaceCreateResponse>;
|
|
925
925
|
}
|
|
926
926
|
declare class SpaceFilesApi {
|
|
927
927
|
private readonly transport;
|
package/dist/chunks/http.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { C as getRealtimeBoardRoom, n as HttpTransport, t as HttpError, w as getRealtimeSpaceRoom } from "./transport.js";
|
|
2
2
|
import { a as resolveApiBaseUrl } from "./environment.js";
|
|
3
3
|
//#region src/apis/channels.ts
|
|
4
4
|
var ChannelsApi = class {
|
|
@@ -1546,7 +1546,7 @@ var SpacesApi = class {
|
|
|
1546
1546
|
...headers,
|
|
1547
1547
|
"Content-Type": "application/json"
|
|
1548
1548
|
},
|
|
1549
|
-
body: JSON.stringify(input
|
|
1549
|
+
body: JSON.stringify(input)
|
|
1550
1550
|
});
|
|
1551
1551
|
}
|
|
1552
1552
|
};
|
package/dist/chunks/transport.js
CHANGED
|
@@ -3,6 +3,11 @@ import { a as resolveApiBaseUrl } from "./environment.js";
|
|
|
3
3
|
const WS_COMPACT_STREAM_CAPABILITY = "session.compact_stream.v1";
|
|
4
4
|
const WS_ROOM_SUBSCRIPTION_CAPABILITY = "realtime.rooms.v1";
|
|
5
5
|
const WS_BOARD_AWARENESS_CAPABILITY = "board.awareness.v1";
|
|
6
|
+
const WS_REALTIME_ROOM_CAPABILITY = "realtime.room.v1";
|
|
7
|
+
/** Accepted room event names. Shared so a client can reject one before sending. */
|
|
8
|
+
const REALTIME_ROOM_EVENT_NAME_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._:-]{0,63}$/;
|
|
9
|
+
/** Maximum encoded size of a room event payload. */
|
|
10
|
+
const REALTIME_ROOM_MAX_PAYLOAD_BYTES = 16 * 1024;
|
|
6
11
|
const getRealtimeSpaceRoom = (spaceId) => `space:${spaceId}`;
|
|
7
12
|
const getRealtimeBoardRoom = (boardId) => `board:${boardId}`;
|
|
8
13
|
const parseRealtimeRoom = (room) => {
|
|
@@ -12,7 +17,7 @@ const parseRealtimeRoom = (room) => {
|
|
|
12
17
|
const kind = trimmed.slice(0, separatorIndex);
|
|
13
18
|
const id = trimmed.slice(separatorIndex + 1).trim();
|
|
14
19
|
if (!id) return null;
|
|
15
|
-
if (kind !== "space" && kind !== "user" && kind !== "board") return null;
|
|
20
|
+
if (kind !== "space" && kind !== "user" && kind !== "board" && kind !== "room") return null;
|
|
16
21
|
return {
|
|
17
22
|
kind,
|
|
18
23
|
id
|
|
@@ -304,4 +309,4 @@ var HttpTransport = class {
|
|
|
304
309
|
}
|
|
305
310
|
};
|
|
306
311
|
//#endregion
|
|
307
|
-
export {
|
|
312
|
+
export { getRealtimeBoardRoom as C, normalizeRealtimeRooms as E, WS_ROOM_SUBSCRIPTION_CAPABILITY as S, getSessionTurnPatchStreamKey as T, REALTIME_ROOM_EVENT_NAME_PATTERN as _, COHUB_SOURCE_HEADER as a, WS_COMPACT_STREAM_CAPABILITY as b, hasRequestSourceIdentity as c, mergeRequestSourceIntoMeta as d, normalizeRequestSource as f, resolveRequestSourceChannel as g, requestSourceToHeaders as h, sanitizeAccessToken as i, isRequestSourceEmpty as l, readRequestSourceFromEnv as m, HttpTransport as n, COHUB_SOURCE_HEADER_NAMES as o, parseRequestSourceFromHeaders as p, joinApiUrl as r, REQUEST_SOURCE_VIA_MAX_LENGTH as s, HttpError as t, isRequestSourceUuid as u, REALTIME_ROOM_MAX_PAYLOAD_BYTES as v, getRealtimeSpaceRoom as w, WS_REALTIME_ROOM_CAPABILITY as x, WS_BOARD_AWARENESS_CAPABILITY as y };
|
|
@@ -1277,19 +1277,156 @@ type BoardAwarenessGesture = z.infer<typeof BoardAwarenessGestureSchema>;
|
|
|
1277
1277
|
type BoardAwarenessUpdate = z.infer<typeof BoardAwarenessUpdateSchema>;
|
|
1278
1278
|
//#endregion
|
|
1279
1279
|
//#region ../protocol/dist/realtime/types.d.ts
|
|
1280
|
-
type RealtimeRoom = `space:${string}` | `user:${string}` | `board:${string}`;
|
|
1280
|
+
type RealtimeRoom = `space:${string}` | `user:${string}` | `board:${string}` | `room:${string}`;
|
|
1281
1281
|
type RealtimeEnvelope = {
|
|
1282
1282
|
id: string;
|
|
1283
1283
|
timestamp: number;
|
|
1284
|
-
domain: "system" | "session" | "space" | "label";
|
|
1284
|
+
domain: "system" | "session" | "space" | "label" | "room";
|
|
1285
1285
|
type: string;
|
|
1286
1286
|
requestId?: string | null;
|
|
1287
1287
|
spaceId?: string | null;
|
|
1288
1288
|
sessionId?: string | null;
|
|
1289
|
+
roomId?: string | null;
|
|
1289
1290
|
rooms?: RealtimeRoom[];
|
|
1290
1291
|
payload: Record<string, unknown>;
|
|
1291
1292
|
};
|
|
1292
1293
|
type ChannelEnvelope = RealtimeEnvelope;
|
|
1294
|
+
type RealtimeRoomDescriptor = {
|
|
1295
|
+
id: string;
|
|
1296
|
+
code: string;
|
|
1297
|
+
createdAt: string;
|
|
1298
|
+
expiresAt: string;
|
|
1299
|
+
maxParticipants: number;
|
|
1300
|
+
/**
|
|
1301
|
+
* When true a viewer holds at most one seat: rejoining from another tab, or
|
|
1302
|
+
* after an unclean disconnect, takes over the existing seat instead of
|
|
1303
|
+
* consuming a second one. Default false, which gives every connection its own
|
|
1304
|
+
* seat (two tabs are two participants).
|
|
1305
|
+
*/
|
|
1306
|
+
seatPerUser: boolean;
|
|
1307
|
+
};
|
|
1308
|
+
type RealtimeRoomMember = {
|
|
1309
|
+
participantId: string;
|
|
1310
|
+
joinedAt: string;
|
|
1311
|
+
presence: Record<string, unknown> | null;
|
|
1312
|
+
/**
|
|
1313
|
+
* Opaque, stable per room and viewer. Connections of the same viewer share it,
|
|
1314
|
+
* so an application can group or de-duplicate participants without seeing the
|
|
1315
|
+
* underlying account id.
|
|
1316
|
+
*/
|
|
1317
|
+
userKey?: string;
|
|
1318
|
+
};
|
|
1319
|
+
type RealtimeRoomEvent = {
|
|
1320
|
+
id: string;
|
|
1321
|
+
timestamp: number;
|
|
1322
|
+
domain: "room";
|
|
1323
|
+
type: "realtime.room.event";
|
|
1324
|
+
requestId?: string | null;
|
|
1325
|
+
spaceId?: null;
|
|
1326
|
+
sessionId?: null;
|
|
1327
|
+
rooms: RealtimeRoom[];
|
|
1328
|
+
payload: {
|
|
1329
|
+
roomId: string;
|
|
1330
|
+
sequence: number;
|
|
1331
|
+
event: string;
|
|
1332
|
+
data: unknown;
|
|
1333
|
+
clientEventId: string | null;
|
|
1334
|
+
sender: {
|
|
1335
|
+
participantId: string;
|
|
1336
|
+
};
|
|
1337
|
+
};
|
|
1338
|
+
};
|
|
1339
|
+
type RealtimeRoomJoinedEvent = {
|
|
1340
|
+
id: string;
|
|
1341
|
+
timestamp: number;
|
|
1342
|
+
domain: "room";
|
|
1343
|
+
type: "realtime.room.joined";
|
|
1344
|
+
requestId?: string | null;
|
|
1345
|
+
spaceId?: null;
|
|
1346
|
+
sessionId?: null;
|
|
1347
|
+
rooms: RealtimeRoom[];
|
|
1348
|
+
payload: {
|
|
1349
|
+
room: RealtimeRoomDescriptor;
|
|
1350
|
+
participantId: string;
|
|
1351
|
+
members: RealtimeRoomMember[];
|
|
1352
|
+
sequence: number;
|
|
1353
|
+
};
|
|
1354
|
+
};
|
|
1355
|
+
type RealtimeRoomMemberChangedEvent = {
|
|
1356
|
+
id: string;
|
|
1357
|
+
timestamp: number;
|
|
1358
|
+
domain: "room";
|
|
1359
|
+
type: "realtime.room.member.joined" | "realtime.room.member.left";
|
|
1360
|
+
requestId?: string | null;
|
|
1361
|
+
spaceId?: null;
|
|
1362
|
+
sessionId?: null;
|
|
1363
|
+
rooms: RealtimeRoom[];
|
|
1364
|
+
payload: {
|
|
1365
|
+
roomId: string;
|
|
1366
|
+
sequence: number;
|
|
1367
|
+
member: RealtimeRoomMember;
|
|
1368
|
+
};
|
|
1369
|
+
};
|
|
1370
|
+
type RealtimeRoomPresenceUpdatedEvent = {
|
|
1371
|
+
id: string;
|
|
1372
|
+
timestamp: number;
|
|
1373
|
+
domain: "room";
|
|
1374
|
+
type: "realtime.room.presence.updated";
|
|
1375
|
+
requestId?: string | null;
|
|
1376
|
+
spaceId?: null;
|
|
1377
|
+
sessionId?: null;
|
|
1378
|
+
rooms: RealtimeRoom[];
|
|
1379
|
+
payload: {
|
|
1380
|
+
roomId: string;
|
|
1381
|
+
sequence: number;
|
|
1382
|
+
member: RealtimeRoomMember;
|
|
1383
|
+
};
|
|
1384
|
+
};
|
|
1385
|
+
type RealtimeRoomRequestEvent = {
|
|
1386
|
+
id: string;
|
|
1387
|
+
timestamp: number;
|
|
1388
|
+
domain: "room";
|
|
1389
|
+
type: "realtime.room.request.ok";
|
|
1390
|
+
requestId?: string | null;
|
|
1391
|
+
spaceId?: null;
|
|
1392
|
+
sessionId?: null;
|
|
1393
|
+
roomId?: string | null;
|
|
1394
|
+
payload: {
|
|
1395
|
+
roomId: string;
|
|
1396
|
+
sequence?: number;
|
|
1397
|
+
eventId?: string | null;
|
|
1398
|
+
clientEventId?: string | null;
|
|
1399
|
+
};
|
|
1400
|
+
};
|
|
1401
|
+
type RealtimeRoomRequestErrorEvent = {
|
|
1402
|
+
id: string;
|
|
1403
|
+
timestamp: number;
|
|
1404
|
+
domain: "room";
|
|
1405
|
+
type: "realtime.room.request.error";
|
|
1406
|
+
requestId?: string | null;
|
|
1407
|
+
spaceId?: null;
|
|
1408
|
+
sessionId?: null;
|
|
1409
|
+
roomId?: string | null;
|
|
1410
|
+
payload: {
|
|
1411
|
+
roomId: string;
|
|
1412
|
+
code: string;
|
|
1413
|
+
message: string;
|
|
1414
|
+
};
|
|
1415
|
+
};
|
|
1416
|
+
type RealtimeRoomClosedEvent = {
|
|
1417
|
+
id: string;
|
|
1418
|
+
timestamp: number;
|
|
1419
|
+
domain: "room";
|
|
1420
|
+
type: "realtime.room.closed";
|
|
1421
|
+
requestId?: string | null;
|
|
1422
|
+
spaceId?: null;
|
|
1423
|
+
sessionId?: null;
|
|
1424
|
+
rooms: RealtimeRoom[];
|
|
1425
|
+
payload: {
|
|
1426
|
+
roomId: string;
|
|
1427
|
+
reason: "expired" | "left" | "revoked" | "superseded";
|
|
1428
|
+
};
|
|
1429
|
+
};
|
|
1293
1430
|
type SystemReadyEvent = {
|
|
1294
1431
|
id: string;
|
|
1295
1432
|
timestamp: number;
|
|
@@ -1313,6 +1450,7 @@ type SystemAuthOkEvent = {
|
|
|
1313
1450
|
payload: {
|
|
1314
1451
|
connectionId: string;
|
|
1315
1452
|
user: Record<string, unknown>;
|
|
1453
|
+
capabilities?: string[];
|
|
1316
1454
|
};
|
|
1317
1455
|
};
|
|
1318
1456
|
type SystemRequestErrorEvent = {
|
|
@@ -1791,7 +1929,7 @@ type LabelAssignmentsUpdatedEvent = {
|
|
|
1791
1929
|
affectedLabelIds: string[];
|
|
1792
1930
|
};
|
|
1793
1931
|
};
|
|
1794
|
-
type RealtimeServerEvent = SystemReadyEvent | SystemAuthOkEvent | SystemRequestErrorEvent | SystemPongEvent | SystemAckOkEvent | SystemSubscribeOkEvent | SystemSubscribeErrorEvent | SessionCreatedEvent | SessionUpdatedEvent | SessionRequestAcceptedEvent | SessionRequestErrorEvent | SessionTurnCreatedEvent | SessionTurnPatchEvent | SessionTurnErrorEvent | SessionTurnLifecycleEvent | SessionTurnUpdatedEvent | SessionTurnFinalizedEvent | SessionTurnNotifyEvent | SessionMessagePersistedEvent | SpaceFsChangedEvent | SpacePortsChangedEvent | SpacePresenceUpdatedEvent | BoardTransactionAppliedEvent | BoardAwarenessUpdatedEvent | BoardPlaybackChangedEvent | WorkVersionPublishedEvent | TaskCreatedEvent | TaskUpdatedEvent | LabelAssignmentsUpdatedEvent;
|
|
1932
|
+
type RealtimeServerEvent = SystemReadyEvent | SystemAuthOkEvent | SystemRequestErrorEvent | SystemPongEvent | SystemAckOkEvent | SystemSubscribeOkEvent | SystemSubscribeErrorEvent | SessionCreatedEvent | SessionUpdatedEvent | SessionRequestAcceptedEvent | SessionRequestErrorEvent | SessionTurnCreatedEvent | SessionTurnPatchEvent | SessionTurnErrorEvent | SessionTurnLifecycleEvent | SessionTurnUpdatedEvent | SessionTurnFinalizedEvent | SessionTurnNotifyEvent | SessionMessagePersistedEvent | SpaceFsChangedEvent | SpacePortsChangedEvent | SpacePresenceUpdatedEvent | BoardTransactionAppliedEvent | BoardAwarenessUpdatedEvent | BoardPlaybackChangedEvent | WorkVersionPublishedEvent | TaskCreatedEvent | TaskUpdatedEvent | LabelAssignmentsUpdatedEvent | RealtimeRoomEvent | RealtimeRoomJoinedEvent | RealtimeRoomMemberChangedEvent | RealtimeRoomPresenceUpdatedEvent | RealtimeRoomRequestEvent | RealtimeRoomRequestErrorEvent | RealtimeRoomClosedEvent;
|
|
1795
1933
|
//#endregion
|
|
1796
1934
|
//#region ../../node_modules/.pnpm/@neta-art+generation@0.1.18/node_modules/@neta-art/generation/dist/builtins-8R5iZQ10.d.ts
|
|
1797
1935
|
//#region src/types.d.ts
|
|
@@ -2618,12 +2756,37 @@ type SpaceSandboxConfig = {
|
|
|
2618
2756
|
type SpaceConfig = {
|
|
2619
2757
|
sandbox?: SpaceSandboxConfig;
|
|
2620
2758
|
};
|
|
2759
|
+
type SpaceBootstrapSource = {
|
|
2760
|
+
type: "blank";
|
|
2761
|
+
} | {
|
|
2762
|
+
type: "git_repo";
|
|
2763
|
+
repoUrl: string;
|
|
2764
|
+
ref?: string | null;
|
|
2765
|
+
} | {
|
|
2766
|
+
type: "checkpoint";
|
|
2767
|
+
checkpointId: string;
|
|
2768
|
+
};
|
|
2769
|
+
type SpaceBootstrapStatus = "pending" | "running" | "ready" | "failed";
|
|
2770
|
+
type SpaceBootstrapStage = "prepare" | "import" | "checkpoint_restore" | "finalize";
|
|
2771
|
+
type SpaceBootstrapMeta = {
|
|
2772
|
+
source: SpaceBootstrapSource;
|
|
2773
|
+
status: SpaceBootstrapStatus;
|
|
2774
|
+
stage: SpaceBootstrapStage | null;
|
|
2775
|
+
taskRunId: string | null;
|
|
2776
|
+
errorMessage: string | null;
|
|
2777
|
+
errorCode?: string | null;
|
|
2778
|
+
startedAt: string | null;
|
|
2779
|
+
finishedAt: string | null;
|
|
2780
|
+
stageTimings?: Record<string, number>;
|
|
2781
|
+
initialCheckpointTaskRunId?: string | null;
|
|
2782
|
+
};
|
|
2621
2783
|
type SpacePublicProfile = {
|
|
2622
2784
|
avatarUrl: string | null;
|
|
2623
2785
|
};
|
|
2624
2786
|
type SpaceMeta = JsonObject & {
|
|
2625
2787
|
config?: SpaceConfig;
|
|
2626
2788
|
extraEnv?: SpaceEnvInput[];
|
|
2789
|
+
bootstrap?: SpaceBootstrapMeta;
|
|
2627
2790
|
publicProfile?: Partial<SpacePublicProfile> | null;
|
|
2628
2791
|
};
|
|
2629
2792
|
type SpaceRecord = {
|
|
@@ -2654,16 +2817,6 @@ type SpaceRecord = {
|
|
|
2654
2817
|
/** Whether the viewer has pinned this space (only present in list responses). */
|
|
2655
2818
|
isPinned?: boolean;
|
|
2656
2819
|
};
|
|
2657
|
-
type SpaceBootstrapSource = {
|
|
2658
|
-
type: "blank";
|
|
2659
|
-
} | {
|
|
2660
|
-
type: "git_repo";
|
|
2661
|
-
repoUrl?: string;
|
|
2662
|
-
ref?: string | null;
|
|
2663
|
-
} | {
|
|
2664
|
-
type: "checkpoint";
|
|
2665
|
-
checkpointId: string;
|
|
2666
|
-
};
|
|
2667
2820
|
type SpaceConfigInput = {
|
|
2668
2821
|
sandbox?: {
|
|
2669
2822
|
provider?: SpaceSandboxProvider;
|
|
@@ -2678,7 +2831,7 @@ type CreateSpaceModInput = {
|
|
|
2678
2831
|
enabled?: boolean;
|
|
2679
2832
|
};
|
|
2680
2833
|
type CreateSpaceInput = {
|
|
2681
|
-
name
|
|
2834
|
+
name: string;
|
|
2682
2835
|
slug?: string | null;
|
|
2683
2836
|
description?: string | null;
|
|
2684
2837
|
source?: string;
|
|
@@ -3204,40 +3357,6 @@ type SpaceModListItem = {
|
|
|
3204
3357
|
modSpaceName: string | null;
|
|
3205
3358
|
modSpaceDescription: string | null;
|
|
3206
3359
|
};
|
|
3207
|
-
/**
|
|
3208
|
-
* Public-safe DTO for Explore spaces.
|
|
3209
|
-
* Only contains fields safe for unauthenticated product rendering.
|
|
3210
|
-
*/
|
|
3211
|
-
type ExploreSpaceItem = {
|
|
3212
|
-
id: string;
|
|
3213
|
-
slug: string | null;
|
|
3214
|
-
title: string;
|
|
3215
|
-
summary: string | null;
|
|
3216
|
-
spaceUrl: string;
|
|
3217
|
-
avatarUrl: string | null;
|
|
3218
|
-
avatarAlt: string | null;
|
|
3219
|
-
ownerDisplayName: string | null;
|
|
3220
|
-
ownerAvatarUrl: string | null;
|
|
3221
|
-
ownerUsername: string | null;
|
|
3222
|
-
category: string | null;
|
|
3223
|
-
tags: string[];
|
|
3224
|
-
saveCount: number;
|
|
3225
|
-
forkCount: number;
|
|
3226
|
-
updatedAt: string | null;
|
|
3227
|
-
accessLabel: "public" | "sign-in-required" | "unknown";
|
|
3228
|
-
latestSaveLabel: string | null;
|
|
3229
|
-
};
|
|
3230
|
-
type ExploreSection = {
|
|
3231
|
-
key: string;
|
|
3232
|
-
title: string | null;
|
|
3233
|
-
subtitle: string | null;
|
|
3234
|
-
description: string | null;
|
|
3235
|
-
spaces: ExploreSpaceItem[];
|
|
3236
|
-
};
|
|
3237
|
-
type ExploreSpacesResponse = {
|
|
3238
|
-
sections: ExploreSection[];
|
|
3239
|
-
spaces: ExploreSpaceItem[];
|
|
3240
|
-
};
|
|
3241
3360
|
type Permission = "space.view" | "space.edit" | "space.label.view" | "space.label.manage" | "space.label.assign" | "session.view" | "session.edit" | "session.prompt.readonly" | "session.prompt.fullaccess" | "generation.create" | "file.view" | "file.view.filtered" | "file.edit" | "checkpoint.view" | "checkpoint.edit" | "member.view" | "member.manage" | "references.view" | "channel.view" | "channel.manage" | "cronjob.view" | "cronjob.manage" | "taskrun.view" | "sandbox.view" | "sandbox.manage" | "mod.view" | "mod.manage" | "user.space.list" | "user.session.list" | "user.usage.read";
|
|
3242
3361
|
type SpaceAccess = {
|
|
3243
3362
|
role: SpaceRole | null;
|
|
@@ -3474,6 +3593,7 @@ type WebsocketClientEvents = {
|
|
|
3474
3593
|
auth: {
|
|
3475
3594
|
connectionId: string;
|
|
3476
3595
|
user: Record<string, unknown>;
|
|
3596
|
+
capabilities: string[];
|
|
3477
3597
|
};
|
|
3478
3598
|
messageAccepted: {
|
|
3479
3599
|
requestId?: string | null;
|
|
@@ -3537,8 +3657,10 @@ declare class WebsocketClient {
|
|
|
3537
3657
|
private readonly compactStreamContexts;
|
|
3538
3658
|
private readonly patchStreamBuffers;
|
|
3539
3659
|
private readonly roomSubscriptions;
|
|
3660
|
+
private readonly serverCapabilities;
|
|
3540
3661
|
state: WebsocketClientState;
|
|
3541
3662
|
connectionId: string | null;
|
|
3663
|
+
supportsCapability(capability: string): boolean;
|
|
3542
3664
|
private readonly listeners;
|
|
3543
3665
|
constructor(options?: WebsocketClientOptions);
|
|
3544
3666
|
on<K extends keyof WebsocketClientEvents>(type: K, handler: EventHandler<WebsocketClientEvents[K]>): () => void;
|
|
@@ -3559,6 +3681,27 @@ declare class WebsocketClient {
|
|
|
3559
3681
|
update: BoardAwarenessUpdate;
|
|
3560
3682
|
requestId?: string;
|
|
3561
3683
|
}): Promise<void>;
|
|
3684
|
+
joinRealtimeRoom(input: {
|
|
3685
|
+
roomId: string;
|
|
3686
|
+
ticket: string;
|
|
3687
|
+
requestId?: string;
|
|
3688
|
+
}): Promise<void>;
|
|
3689
|
+
publishRealtimeRoom(input: {
|
|
3690
|
+
roomId: string;
|
|
3691
|
+
event: string;
|
|
3692
|
+
data: unknown;
|
|
3693
|
+
clientEventId?: string;
|
|
3694
|
+
requestId?: string;
|
|
3695
|
+
}): Promise<void>;
|
|
3696
|
+
leaveRealtimeRoom(input: {
|
|
3697
|
+
roomId: string;
|
|
3698
|
+
requestId?: string;
|
|
3699
|
+
}): Promise<void>;
|
|
3700
|
+
updateRealtimeRoomPresence(input: {
|
|
3701
|
+
roomId: string;
|
|
3702
|
+
presence: Record<string, unknown> | null;
|
|
3703
|
+
requestId?: string;
|
|
3704
|
+
}): Promise<void>;
|
|
3562
3705
|
sendMessage(input: {
|
|
3563
3706
|
spaceId: string;
|
|
3564
3707
|
sessionId: string;
|
|
@@ -3596,4 +3739,4 @@ declare class WebsocketClient {
|
|
|
3596
3739
|
}
|
|
3597
3740
|
declare const createWebsocketClient: (options?: WebsocketClientOptions) => WebsocketClient;
|
|
3598
3741
|
//#endregion
|
|
3599
|
-
export { CreateSpacePromptInput as $,
|
|
3742
|
+
export { CreateSpacePromptInput as $, BoardRenderCost as $i, SpaceFsTreeResponse as $n, findGenerationModelPolicy as $r, SandboxSpecId as $t, BillingProductDisplay as A, readRequestSourceFromEnv as Aa, BoardCapabilities as Ai, SpaceCommerceProductCreditBenefit as An, SpaceUsageResponse as Ar, Permission as At, CheckpointDiffFile as B, BoardNodeRecord as Bi, SpaceFsCreateDirectoryInput as Bn, ChannelHealth as Br, ReferenceAggregateGroupBy as Bt, BillingCreditStatus as C, RequestSourceVia as Ca, BoardAwarenessUpdate as Ci, SpaceCommerceBenefit as Cn, SpaceSandboxConfig as Cr, LabelResourceType as Ct, BillingPluginStatus as D, mergeRequestSourceIntoMeta as Da, WorkContentKind as Di, SpaceCommerceOrder as Dn, SpaceTurnListItem as Dr, ModelCatalogEntry as Dt, BillingPaymentStatus as E, isRequestSourceUuid as Ea, WorkBoardAsset as Ei, SpaceCommerceFeatureBenefit as En, SpaceTurnAuthorFilter as Er, MeResponse as Et, BillingSubscriptionHistoryList as F, BoardEffect as Fi, SpaceCreateResponse as Fn, UserRulesResponse as Fr, PublicUserPageResponse as Ft, CheckpointDiffStatus as G, BoardPlaybackSnapshot as Gi, SpaceFsEntry as Gn, GenerationModelPolicy as Gr, ReferenceQueryableType as Gt, CheckpointDiffPatchKind as H, BoardPlaybackCommand as Hi, SpaceFsCreateUploadResponse as Hn, ChannelRuntimeState as Hr, ReferenceDirection as Ht, BillingSubscriptionHistoryStatus as I, BoardInspectInput as Ii, SpaceDefaultResponse as In, UserSessionListItem as Ir, PublicUserProfile as It, ClaimReferralResponse as J, BoardTarget as Ji, SpaceFsMoveInput as Jn, GenerationPolicyError as Jr, ReferralDashboard as Jt, CheckpointDiffSummary as K, BoardRecord as Ki, SpaceFsFileKind as Kn, GenerationParameterConstraint as Kr, ReferenceRecord as Kt, BillingSubscriptionSummary as L, BoardKeyframe as Li, SpaceEnvInput as Ln, UserSessionSpaceSummary as Lr, PublicUserSpaceItem as Lt, BillingProductPricing as M, resolveRequestSourceChannel as Ma, BoardCreateInput as Mi, SpaceConfigInput as Mn, TaskRunDetailResponse as Mr, PromptTemplateCatalogEntry as Mt, BillingRedemptionResult as N, BoardDeleteReason as Ni, SpaceConfigResponse as Nn, TaskRunRecord as Nr, PromptTemplateCatalogResponse as Nt, BillingProductBillingInterval as O, normalizeRequestSource as Oa, BoardAssetRef as Oi, SpaceCommerceProduct as On, SpaceTurnsResponse as Or, PatchResourceLabelsInput as Ot, BillingResponsePayload as P, BoardDiagnostic as Pi, SpaceConfigUpdateResponse as Pn, UserProfile as Pr, PublicReferral as Pt, CreateSpaceModInput as Q, BoardCapability as Qi, SpaceFsReadFilesResponse as Qn, filterGenerationDeclarationsByPolicy as Qr, ResourceLabelsResponse as Qt, Channel as R, BoardManifest as Ri, SpaceFsCompleteUploadInput as Rn, UserSessionsResponse as Rr, PublicUserWorkItem as Rt, BillingCreditGrantStatus as S, RequestSource as Sa, BoardAwarenessStateUpdate as Si, SpaceCheckpointDetailResponse as Sn, SpaceSandboxAutoDestroyPolicy as Sr, LabelRecord as St, BillingHistoryPagination as T, isRequestSourceEmpty as Ta, WorkBoardArtifactManifest as Ti, SpaceCommerceCreditsBenefit as Tn, SpaceSessionsResponse as Tr, LabelSource as Tt, CheckpointDiffPatchLine as U, BoardPlaybackPolicy as Ui, SpaceFsDeleteNodeInput as Un, DiscordChannelConfig as Ur, ReferenceKind as Ut, CheckpointDiffFileResponse as V, BoardOperation as Vi, SpaceFsCreateUploadInput as Vn, ChannelHealthReasonCode as Vr, ReferenceAggregateResponse as Vt, CheckpointDiffStats as W, BoardPlaybackPolicySchema as Wi, SpaceFsEncoding as Wn, FeishuChannelConfig as Wr, ReferenceQueryResponse as Wt, CreateInvitationResponse as X, BoardValidationResult as Xi, SpaceFsReadFilesError as Xn, decodeGenerationPolicy as Xr, ReferralReward as Xt, CreateInvitationInput as Y, BoardTransaction as Yi, SpaceFsPreparingFile as Yn, assertGenerationRequestAllowedByPolicy as Yr, ReferralListItem as Yt, CreateSpaceInput as Z, parseBoardPlaybackPolicy as Zi, SpaceFsReadFilesInput as Zn, encodeGenerationPolicy as Zr, ReferralStatus as Zt, BillingCatalogProduct as _, BillingPayload as _a, RealtimeWorkVersionRecord as _i, SpaceBootstrapMeta as _n, SpacePresenceSnapshot as _r, LabelAssignmentPageInfo as _t, WebsocketClientOptions as a, SessionTurnRecord as aa, GenerationResult as ai, SessionRecord as an, SpaceFsUploadProgress as ar, CursorPageInfo as at, BillingConversionIntent as b, COHUB_SOURCE_HEADER_NAMES as ba, BoardAwarenessGesture as bi, SpaceBootstrapStatus as bn, SpaceRecord as br, LabelItemsSessionFork as bt, createWebsocketClient as c, CompletionMessage as ca, BoardTransactionAppliedEvent as ci, SessionTurnSignedUrlsResponse as cn, SpaceInvitation as cr, GenerationUsageSummary as ct, BatchUserProfilesResponse as d, CompletionUsage as da, RealtimePatchOperation as di, SessionTurnsPaginatedResponse as dn, SpaceListItem as dr, GlobalSearchType as dt, SpacePublicEndpoints as ea, getAllowedGenerationModelIds as ei, SendMessageCronJobPayload as en, SpaceFsUploadDestination as er, CreateSpacePromptResponse as et, BillingBalanceActivity as f, CreateSpaceCompletionInput as fa, RealtimeRoomDescriptor as fi, SkillCatalogEntry as fn, SpaceMember as fr, InvitationDetail as ft, BillingCatalog as g, Usage as ga, RealtimeWorkRecord as gi, SpaceAccessPolicy as gn, SpacePendingDiffSummary as gr, LabelAssignmentListItem as gt, BillingBalanceActivityStatus as h, SpaceCompletionStreamEvent as ha, RealtimeServerEvent as hi, SpaceAccess as hn, SpacePendingDiffFileResponse as hr, JsonValue as ht, WebsocketClientEvents as i, SessionTurnIndexItem as ia, GenerationModelDeclaration as ii, SessionMessagesResponse as in, SpaceFsUploadPlanEntryInput as ir, CronJobUpdatePatch as it, BillingProductKind as j, requestSourceToHeaders as ja, BoardClip as ji, SpaceConfig as jn, SpaceUsageSummary as jr, PromptAccessMode as jt, BillingProductCreditBenefit as k, parseRequestSourceFromHeaders as ka, BoardBootstrap as ki, SpaceCommerceProductBenefitBinding as kn, SpaceUsageHourlyStat as kr, PatchResourceLabelsResponse as kt, AcceptInvitationResponse as l, CompletionMessageRole as la, ChannelEnvelope as li, SessionTurnStreamSnapshotResponse as ln, SpaceInvitationListResponse as lr, GlobalSearchResponse as lt, BillingBalanceActivityList as m, SpaceCompletionResult as ma, RealtimeRoomMember as mi, SkillCatalogSource as mn, SpaceModListItem as mr, JsonPrimitive as mt, WebSocketLike as n, SessionForkRecord as na, parseGenerationPolicyFromEnv as ni, SessionMessageResponse as nn, SpaceFsUploadError as nr, CronJobPayload as nt, WebsocketClientState as o, SpaceTurnsResponse$1 as oa, BoardAwarenessUpdatedEvent as oi, SessionTurnIndexResponse as on, SpaceFsUploadResponse as or, GenerationUsageBlock as ot, BillingBalanceActivityKind as p, ModelThinkingLevel as pa, RealtimeRoomEvent as pi, SkillCatalogResponse as pn, SpaceMeta as pr, JsonObject as pt, CheckpointRecord as q, BoardSequence as qi, SpaceFsFileResponse as qn, GenerationPolicy as qr, ReferenceResourceType as qt, WebsocketClient as r, SessionTurnSegmentRecord as ra, GenerationContentBlock as ri, SessionMessagesPaginatedResponse as rn, SpaceFsUploadPlanEntry as rr, CronJobRecord as rt, WebsocketEventPayload as s, CompletionAssistantMessage as sa, BoardPlaybackChangedEvent as si, SessionTurnResponse as sn, SpaceFsWriteFileInput as sr, GenerationUsageHourlyStat as st, WebSocketConstructor as t, MessageRecord as ta, normalizeGenerationPolicy as ti, SessionBindingRecord as tn, SpaceFsUploadEntry as tr, CreateSpaceSessionInput as tt, ApiError as u, CompletionThinkingLevel as ua, LabelAssignmentsUpdatedEvent as ui, SessionTurnWindowResponse as un, SpaceInvitationLocation as ur, GlobalSearchResult as ut, BillingCheckoutActionState as v, ContentBlock as va, SessionTurnPatchEvent as vi, SpaceBootstrapSource as vn, SpacePresenceUser as vr, LabelAssignmentRecord as vt, BillingCreditUnit as w, hasRequestSourceIdentity as wa, WorkArtifactDescriptor as wi, SpaceCommerceBuyerProfile as wn, SpaceSandboxProvider as wr, LabelScopeType as wt, BillingCreditExpiryGroup as x, REQUEST_SOURCE_VIA_MAX_LENGTH as xa, BoardAwarenessNodePreview as xi, SpaceChannelBindingInput as xn, SpaceRole as xr, LabelListItem as xt, BillingCheckoutResult as y, COHUB_SOURCE_HEADER as ya, WorkVersionPublishedEvent as yi, SpaceBootstrapStage as yn, SpacePublicProfile as yr, LabelItemsResponse as yt, CheckpointDiffDelivery as z, BoardNodeInput as zi, SpaceFsCompleteUploadResponse as zn, ChannelConfig as zr, ReferenceAggregateGroup as zt };
|
package/dist/chunks/websocket.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { E as normalizeRealtimeRooms, S as WS_ROOM_SUBSCRIPTION_CAPABILITY, T as getSessionTurnPatchStreamKey, b as WS_COMPACT_STREAM_CAPABILITY, t as HttpError, w as getRealtimeSpaceRoom, x as WS_REALTIME_ROOM_CAPABILITY, y as WS_BOARD_AWARENESS_CAPABILITY } from "./transport.js";
|
|
2
2
|
import { c as resolveWebsocketUrl } from "./environment.js";
|
|
3
3
|
//#region src/http-error.ts
|
|
4
4
|
/** Shared HTTP error code for every plan entitlement gate (402). */
|
|
@@ -88,7 +88,7 @@ const isRealtimeEnvelope = (value) => {
|
|
|
88
88
|
if (!isRecord(value)) return false;
|
|
89
89
|
if (typeof value.id !== "string") return false;
|
|
90
90
|
if (typeof value.timestamp !== "number") return false;
|
|
91
|
-
if (value.domain !== "system" && value.domain !== "session" && value.domain !== "space" && value.domain !== "label") return false;
|
|
91
|
+
if (value.domain !== "system" && value.domain !== "session" && value.domain !== "space" && value.domain !== "label" && value.domain !== "room") return false;
|
|
92
92
|
if (typeof value.type !== "string") return false;
|
|
93
93
|
if (!isRecord(value.payload)) return false;
|
|
94
94
|
return true;
|
|
@@ -157,8 +157,12 @@ var WebsocketClient = class {
|
|
|
157
157
|
compactStreamContexts = /* @__PURE__ */ new Map();
|
|
158
158
|
patchStreamBuffers = /* @__PURE__ */ new Map();
|
|
159
159
|
roomSubscriptions = /* @__PURE__ */ new Map();
|
|
160
|
+
serverCapabilities = /* @__PURE__ */ new Set();
|
|
160
161
|
state = "idle";
|
|
161
162
|
connectionId = null;
|
|
163
|
+
supportsCapability(capability) {
|
|
164
|
+
return this.serverCapabilities.has(capability);
|
|
165
|
+
}
|
|
162
166
|
listeners = createEventMap();
|
|
163
167
|
constructor(options = {}) {
|
|
164
168
|
const normalized = normalizeOptions(options);
|
|
@@ -322,6 +326,49 @@ var WebsocketClient = class {
|
|
|
322
326
|
}
|
|
323
327
|
});
|
|
324
328
|
}
|
|
329
|
+
async joinRealtimeRoom(input) {
|
|
330
|
+
await this.ensureOpen();
|
|
331
|
+
this.send({
|
|
332
|
+
type: "realtime.room.join",
|
|
333
|
+
requestId: input.requestId,
|
|
334
|
+
payload: {
|
|
335
|
+
roomId: input.roomId,
|
|
336
|
+
ticket: input.ticket
|
|
337
|
+
}
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
async publishRealtimeRoom(input) {
|
|
341
|
+
await this.ensureOpen();
|
|
342
|
+
this.send({
|
|
343
|
+
type: "realtime.room.publish",
|
|
344
|
+
requestId: input.requestId,
|
|
345
|
+
payload: {
|
|
346
|
+
roomId: input.roomId,
|
|
347
|
+
event: input.event,
|
|
348
|
+
data: input.data,
|
|
349
|
+
clientEventId: input.clientEventId
|
|
350
|
+
}
|
|
351
|
+
});
|
|
352
|
+
}
|
|
353
|
+
async leaveRealtimeRoom(input) {
|
|
354
|
+
await this.ensureOpen();
|
|
355
|
+
this.send({
|
|
356
|
+
type: "realtime.room.leave",
|
|
357
|
+
requestId: input.requestId,
|
|
358
|
+
payload: { roomId: input.roomId }
|
|
359
|
+
});
|
|
360
|
+
}
|
|
361
|
+
async updateRealtimeRoomPresence(input) {
|
|
362
|
+
await this.ensureOpen();
|
|
363
|
+
this.send({
|
|
364
|
+
type: "realtime.room.presence.update",
|
|
365
|
+
requestId: input.requestId,
|
|
366
|
+
payload: {
|
|
367
|
+
roomId: input.roomId,
|
|
368
|
+
presence: input.presence
|
|
369
|
+
}
|
|
370
|
+
});
|
|
371
|
+
}
|
|
325
372
|
async sendMessage(input) {
|
|
326
373
|
await this.ensureOpen();
|
|
327
374
|
this.send({
|
|
@@ -424,7 +471,8 @@ var WebsocketClient = class {
|
|
|
424
471
|
capabilities: [
|
|
425
472
|
WS_COMPACT_STREAM_CAPABILITY,
|
|
426
473
|
WS_ROOM_SUBSCRIPTION_CAPABILITY,
|
|
427
|
-
WS_BOARD_AWARENESS_CAPABILITY
|
|
474
|
+
WS_BOARD_AWARENESS_CAPABILITY,
|
|
475
|
+
WS_REALTIME_ROOM_CAPABILITY
|
|
428
476
|
]
|
|
429
477
|
}
|
|
430
478
|
});
|
|
@@ -515,11 +563,15 @@ var WebsocketClient = class {
|
|
|
515
563
|
case "system.auth.ok": {
|
|
516
564
|
const connectionId = typeof envelope.payload.connectionId === "string" ? envelope.payload.connectionId : this.connectionId;
|
|
517
565
|
const user = envelope.payload.user && typeof envelope.payload.user === "object" ? envelope.payload.user : {};
|
|
566
|
+
const capabilities = Array.isArray(envelope.payload.capabilities) ? envelope.payload.capabilities.filter((value) => typeof value === "string") : [];
|
|
567
|
+
this.serverCapabilities.clear();
|
|
568
|
+
for (const capability of capabilities) this.serverCapabilities.add(capability);
|
|
518
569
|
if (connectionId) {
|
|
519
570
|
this.connectionId = connectionId;
|
|
520
571
|
this.emit("auth", {
|
|
521
572
|
connectionId,
|
|
522
|
-
user
|
|
573
|
+
user,
|
|
574
|
+
capabilities
|
|
523
575
|
});
|
|
524
576
|
}
|
|
525
577
|
this.resolveAuthWaiter();
|