@openmarket/rooms-client 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 +201 -0
- package/README.md +25 -0
- package/dist/agent/armed-mode.d.ts +187 -0
- package/dist/agent/armed-mode.js +306 -0
- package/dist/agent/clients/common.d.ts +70 -0
- package/dist/agent/clients/common.js +46 -0
- package/dist/agent/lane-draft.d.ts +15 -0
- package/dist/agent/lane-draft.js +43 -0
- package/dist/agent/lane-prompts.d.ts +102 -0
- package/dist/agent/lane-prompts.js +120 -0
- package/dist/agent/library-context.d.ts +38 -0
- package/dist/agent/library-context.js +57 -0
- package/dist/agent/library-model.d.ts +41 -0
- package/dist/agent/library-model.js +173 -0
- package/dist/agent/room-context.d.ts +151 -0
- package/dist/agent/room-context.js +251 -0
- package/dist/agent/sidebar-model.d.ts +86 -0
- package/dist/agent/sidebar-model.js +162 -0
- package/dist/agent/topic-inbox.d.ts +119 -0
- package/dist/agent/topic-inbox.js +266 -0
- package/dist/agent/topic-view-batcher.d.ts +54 -0
- package/dist/agent/topic-view-batcher.js +115 -0
- package/dist/client.d.ts +421 -0
- package/dist/client.js +1428 -0
- package/dist/doc-reconcile.d.ts +100 -0
- package/dist/doc-reconcile.js +110 -0
- package/dist/doc-uri.d.ts +29 -0
- package/dist/doc-uri.js +55 -0
- package/dist/endpoints.d.ts +9 -0
- package/dist/endpoints.js +13 -0
- package/dist/jwt.d.ts +10 -0
- package/dist/jwt.js +51 -0
- package/dist/library-publisher.d.ts +52 -0
- package/dist/library-publisher.js +49 -0
- package/dist/merge3.d.ts +50 -0
- package/dist/merge3.js +280 -0
- package/dist/names.d.ts +6 -0
- package/dist/names.js +35 -0
- package/dist/shared/emoji-data.d.ts +22 -0
- package/dist/shared/emoji-data.js +8834 -0
- package/dist/shared/mentions.d.ts +6 -0
- package/dist/shared/mentions.js +32 -0
- package/dist/shared/rooms-protocol.d.ts +1183 -0
- package/dist/shared/rooms-protocol.js +160 -0
- package/dist/social-client.d.ts +361 -0
- package/dist/social-client.js +686 -0
- package/dist/social-types.d.ts +338 -0
- package/dist/social-types.js +1 -0
- package/dist/suggestion-attribution.d.ts +10 -0
- package/dist/suggestion-attribution.js +56 -0
- package/dist/topic-uri.d.ts +26 -0
- package/dist/topic-uri.js +40 -0
- package/dist/types.d.ts +2 -0
- package/dist/types.js +1 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.js +2 -0
- package/dist/ws-client.d.ts +115 -0
- package/dist/ws-client.js +491 -0
- package/package.json +180 -0
- package/src/agent/armed-mode.ts +368 -0
- package/src/agent/clients/common.ts +91 -0
- package/src/agent/lane-draft.ts +47 -0
- package/src/agent/lane-prompts.ts +267 -0
- package/src/agent/library-context.ts +97 -0
- package/src/agent/library-model.ts +210 -0
- package/src/agent/room-context.ts +351 -0
- package/src/agent/sidebar-model.ts +235 -0
- package/src/agent/topic-inbox.ts +297 -0
- package/src/agent/topic-view-batcher.ts +134 -0
- package/src/client.ts +2331 -0
- package/src/doc-reconcile.ts +160 -0
- package/src/doc-uri.ts +83 -0
- package/src/endpoints.ts +14 -0
- package/src/jwt.ts +59 -0
- package/src/library-publisher.ts +93 -0
- package/src/merge3.ts +326 -0
- package/src/names.ts +44 -0
- package/src/shared/emoji-data.ts +8868 -0
- package/src/shared/mentions.ts +32 -0
- package/src/shared/rooms-protocol.ts +1339 -0
- package/src/social-client.ts +1287 -0
- package/src/social-types.ts +376 -0
- package/src/suggestion-attribution.ts +83 -0
- package/src/topic-uri.ts +64 -0
- package/src/types.ts +83 -0
- package/src/version.ts +2 -0
- package/src/ws-client.ts +611 -0
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
export const RoomClientMessageType = {
|
|
2
|
+
AUTHENTICATE: "AUTHENTICATE",
|
|
3
|
+
CREATE_ROOM: "CREATE_ROOM",
|
|
4
|
+
INVITE: "INVITE",
|
|
5
|
+
REMOVE_MEMBER: "REMOVE_MEMBER",
|
|
6
|
+
SEARCH: "SEARCH",
|
|
7
|
+
JOIN: "JOIN",
|
|
8
|
+
HISTORY: "HISTORY",
|
|
9
|
+
PEEK: "PEEK",
|
|
10
|
+
LEAVE: "LEAVE",
|
|
11
|
+
POST: "POST",
|
|
12
|
+
REACT: "REACT",
|
|
13
|
+
EDIT: "EDIT",
|
|
14
|
+
DELETE: "DELETE",
|
|
15
|
+
THREAD: "THREAD",
|
|
16
|
+
PIN: "PIN",
|
|
17
|
+
UNPIN: "UNPIN",
|
|
18
|
+
PINS: "PINS",
|
|
19
|
+
REACTORS: "REACTORS",
|
|
20
|
+
REPORT: "REPORT",
|
|
21
|
+
MUTE: "MUTE",
|
|
22
|
+
KICK: "KICK",
|
|
23
|
+
BAN: "BAN",
|
|
24
|
+
ROLE_CHANGE: "ROLE_CHANGE",
|
|
25
|
+
SET_READ_ONLY: "SET_READ_ONLY",
|
|
26
|
+
AUDIT_LOG: "AUDIT_LOG",
|
|
27
|
+
SPACES: "SPACES",
|
|
28
|
+
JOIN_SPACE: "JOIN_SPACE",
|
|
29
|
+
READ_STATE: "READ_STATE",
|
|
30
|
+
SEARCH_ENTRIES: "SEARCH_ENTRIES",
|
|
31
|
+
WHO: "WHO",
|
|
32
|
+
TYPING: "TYPING",
|
|
33
|
+
STATUS: "STATUS",
|
|
34
|
+
ACK: "ACK",
|
|
35
|
+
PING: "PING",
|
|
36
|
+
FRIENDS: "FRIENDS",
|
|
37
|
+
DM_OPEN: "DM_OPEN",
|
|
38
|
+
DM_HISTORY: "DM_HISTORY",
|
|
39
|
+
DM_SEND: "DM_SEND",
|
|
40
|
+
DM_READ: "DM_READ",
|
|
41
|
+
TOPIC_CREATE: "TOPIC_CREATE",
|
|
42
|
+
TOPIC_RENAME: "TOPIC_RENAME",
|
|
43
|
+
TOPIC_MOVE: "TOPIC_MOVE",
|
|
44
|
+
TOPIC_MERGE: "TOPIC_MERGE",
|
|
45
|
+
TOPIC_RESOLVE: "TOPIC_RESOLVE",
|
|
46
|
+
TOPIC_SET_ATTENTION: "TOPIC_SET_ATTENTION",
|
|
47
|
+
TOPIC_LIST: "TOPIC_LIST",
|
|
48
|
+
};
|
|
49
|
+
export const RoomServerMessageType = {
|
|
50
|
+
AUTH_SUCCESS: "AUTH_SUCCESS",
|
|
51
|
+
ROOM_CREATED: "ROOM_CREATED",
|
|
52
|
+
ROOM_INVITED: "ROOM_INVITED",
|
|
53
|
+
ROOM_MEMBER_REMOVED: "ROOM_MEMBER_REMOVED",
|
|
54
|
+
ROOMS: "ROOMS",
|
|
55
|
+
BACKFILL: "BACKFILL",
|
|
56
|
+
HISTORY: "HISTORY",
|
|
57
|
+
PEEK_RESULT: "PEEK_RESULT",
|
|
58
|
+
MESSAGE: "MESSAGE",
|
|
59
|
+
ENTRY_UPDATED: "ENTRY_UPDATED",
|
|
60
|
+
THREAD: "THREAD",
|
|
61
|
+
PINS: "PINS",
|
|
62
|
+
REACTORS: "REACTORS",
|
|
63
|
+
ROOM_REPORTED: "ROOM_REPORTED",
|
|
64
|
+
ROOM_MUTED: "ROOM_MUTED",
|
|
65
|
+
ROOM_BANNED: "ROOM_BANNED",
|
|
66
|
+
ROOM_MEMBER_ROLE_CHANGED: "ROOM_MEMBER_ROLE_CHANGED",
|
|
67
|
+
ROOM_READ_ONLY_SET: "ROOM_READ_ONLY_SET",
|
|
68
|
+
ROOM_AUDIT_LOG: "ROOM_AUDIT_LOG",
|
|
69
|
+
SPACES: "SPACES",
|
|
70
|
+
SPACE_JOINED: "SPACE_JOINED",
|
|
71
|
+
SPACE_MEMBER_ADDED: "SPACE_MEMBER_ADDED",
|
|
72
|
+
SPACE_INVITE: "SPACE_INVITE",
|
|
73
|
+
ROOM_UPDATED: "ROOM_UPDATED",
|
|
74
|
+
SPACE_UPDATED: "SPACE_UPDATED",
|
|
75
|
+
READ_STATE: "READ_STATE",
|
|
76
|
+
SEARCH_RESULTS: "SEARCH_RESULTS",
|
|
77
|
+
PRESENCE: "PRESENCE",
|
|
78
|
+
RESYNC: "RESYNC",
|
|
79
|
+
PRESENCE_DELTA: "PRESENCE_DELTA",
|
|
80
|
+
WHO: "WHO",
|
|
81
|
+
TYPING: "TYPING",
|
|
82
|
+
ERROR: "ERROR",
|
|
83
|
+
PONG: "PONG",
|
|
84
|
+
FRIENDS: "FRIENDS",
|
|
85
|
+
DM_OPENED: "DM_OPENED",
|
|
86
|
+
DM_HISTORY: "DM_HISTORY",
|
|
87
|
+
DM_MESSAGE: "DM_MESSAGE",
|
|
88
|
+
DM_INBOX_UPDATED: "DM_INBOX_UPDATED",
|
|
89
|
+
TOPIC: "TOPIC",
|
|
90
|
+
TOPICS: "TOPICS",
|
|
91
|
+
TOPIC_UPDATED: "TOPIC_UPDATED",
|
|
92
|
+
};
|
|
93
|
+
export function addBounded(set, value, max) {
|
|
94
|
+
set.add(value);
|
|
95
|
+
while (set.size > max) {
|
|
96
|
+
const oldest = set.values().next().value;
|
|
97
|
+
if (oldest === undefined)
|
|
98
|
+
return;
|
|
99
|
+
set.delete(oldest);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
export const SUPPORTED_ROOM_PROTOCOL_VERSION = 2;
|
|
103
|
+
export const RoomLedgerEntryType = {
|
|
104
|
+
POST: "post",
|
|
105
|
+
SYSTEM: "system",
|
|
106
|
+
SYSTEM_MARKET: "system_market",
|
|
107
|
+
MODERATION: "moderation",
|
|
108
|
+
SECRET: "secret",
|
|
109
|
+
};
|
|
110
|
+
export function isSystemRoomLedgerEntryType(type) {
|
|
111
|
+
return (type === RoomLedgerEntryType.SYSTEM ||
|
|
112
|
+
type === RoomLedgerEntryType.SYSTEM_MARKET ||
|
|
113
|
+
type === RoomLedgerEntryType.MODERATION);
|
|
114
|
+
}
|
|
115
|
+
export const ROOM_PRESENCE_SAMPLE_LIMIT = 50;
|
|
116
|
+
/**
|
|
117
|
+
* Relay typing contract (kiyotaka `room.constants.ts`). Two facts every
|
|
118
|
+
* client-side typing feature must design against:
|
|
119
|
+
*
|
|
120
|
+
* - A typer's roster entry expires ROOM_TYPING_RELAY_ENTRY_TTL_MS after
|
|
121
|
+
* their last start frame, and the expiry is pruned lazily on the next
|
|
122
|
+
* roster read; it is NEVER broadcast. A client that wants the entry to
|
|
123
|
+
* survive a long message must re-send start inside this window, and a
|
|
124
|
+
* client rendering the roster must self-expire it locally.
|
|
125
|
+
* - Roster broadcasts are throttled to one per room per
|
|
126
|
+
* ROOM_TYPING_RELAY_BROADCAST_THROTTLE_MS (a trailing broadcast covers
|
|
127
|
+
* frames coalesced inside the window), so any roster a client displays
|
|
128
|
+
* can be that stale before the next one arrives.
|
|
129
|
+
*/
|
|
130
|
+
export const ROOM_TYPING_RELAY_ENTRY_TTL_MS = 5_000;
|
|
131
|
+
export const ROOM_TYPING_RELAY_BROADCAST_THROTTLE_MS = 2_000;
|
|
132
|
+
export function applyRoomPresenceDelta(current, delta) {
|
|
133
|
+
let sample = [...(current?.sample ?? current?.members ?? [])];
|
|
134
|
+
if (delta.left) {
|
|
135
|
+
const left = delta.left.toLowerCase();
|
|
136
|
+
sample = sample.filter((member) => member.userId.toLowerCase() !== left);
|
|
137
|
+
}
|
|
138
|
+
if (delta.joined) {
|
|
139
|
+
const joined = delta.joined.userId.toLowerCase();
|
|
140
|
+
sample = sample.filter((member) => member.userId.toLowerCase() !== joined);
|
|
141
|
+
if (sample.length < ROOM_PRESENCE_SAMPLE_LIMIT)
|
|
142
|
+
sample.push(delta.joined);
|
|
143
|
+
}
|
|
144
|
+
if (delta.updated) {
|
|
145
|
+
const updated = delta.updated.userId.toLowerCase();
|
|
146
|
+
// In-place identity refresh: replace only if already sampled (an update
|
|
147
|
+
// must not grow the sample past what joins admitted).
|
|
148
|
+
sample = sample.map((member) => member.userId.toLowerCase() === updated ? { ...member, ...delta.updated } : member);
|
|
149
|
+
}
|
|
150
|
+
return {
|
|
151
|
+
...(current ?? {}),
|
|
152
|
+
room: delta.room,
|
|
153
|
+
humans: delta.humans,
|
|
154
|
+
agents: delta.agents,
|
|
155
|
+
total: delta.humans + delta.agents,
|
|
156
|
+
...(delta.guestCount !== undefined ? { guestCount: delta.guestCount } : {}),
|
|
157
|
+
sample,
|
|
158
|
+
members: sample,
|
|
159
|
+
};
|
|
160
|
+
}
|
|
@@ -0,0 +1,361 @@
|
|
|
1
|
+
import type { RoomDmConversation, RoomDmHistory, RoomDmSendResult, RoomDmUnreadConversation, RoomDoc, RoomDocAttribution, RoomDocChanges, RoomDocConflictHead, RoomDocEditingLease, RoomDocProvenance, RoomDocRevision, RoomDocRunRevertResult, RoomDocWriteResult, RoomFollow, RoomFollowResult, RoomFriend, RoomFriendRequests, RoomPublicProfile, RoomRepliesReadResult, RoomRepliesResult, RoomSocialConfig, RoomSpaceRestorePlan, RoomSpaceRestoreReceipt, RoomSuggestion, RoomSuggestionRequest } from "./social-types.js";
|
|
2
|
+
export type { RoomAttachment, RoomDmConversation, RoomDmHistory, RoomDmMessage, RoomDmParticipant, RoomDmSendResult, RoomDmUnreadConversation, RoomDocAttribution, RoomDocEditingLease, RoomDocMergeRegion, RoomDocRevisionSource, RoomDocRunRevertResult, RoomFollow, RoomFollowResult, RoomFriend, RoomFriendRequest, RoomFriendRequests, RoomPublicProfile, RoomRepliesReadResult, RoomRepliesResult, RoomReplyInboxItem, RoomSocialConfig, RoomSpaceRestoreAction, RoomSpaceRestoreActionKind, RoomSpaceRestorePlan, RoomSpaceRestoreReceipt, RoomSpaceRestoreSummary, RoomSuggestion, RoomSuggestionIntent, RoomSuggestionRequest, RoomSuggestionSource, } from "./social-types.js";
|
|
3
|
+
export declare const ROOM_ATTACHMENT_MAX_BYTES: number;
|
|
4
|
+
export declare class RoomSocialError extends Error {
|
|
5
|
+
readonly name = "RoomSocialError";
|
|
6
|
+
readonly status: number;
|
|
7
|
+
readonly details?: unknown;
|
|
8
|
+
constructor(message: string, status: number, details?: unknown);
|
|
9
|
+
}
|
|
10
|
+
export declare function resolveRoomChatApiUrl(): string;
|
|
11
|
+
export declare function deriveRoomChatApiUrlFromRoomsUrl(wsUrl: string): string | undefined;
|
|
12
|
+
export declare function listRoomFriends(config: RoomSocialConfig): Promise<RoomFriend[]>;
|
|
13
|
+
export declare function sendRoomFriendRequest(config: RoomSocialConfig, username: string): Promise<{
|
|
14
|
+
friendshipId?: string;
|
|
15
|
+
systemMessage?: unknown;
|
|
16
|
+
}>;
|
|
17
|
+
export declare function listRoomFriendRequests(config: RoomSocialConfig): Promise<RoomFriendRequests>;
|
|
18
|
+
export declare function acceptRoomFriendRequest(config: RoomSocialConfig, friendshipId: string): Promise<{
|
|
19
|
+
friendshipId?: string;
|
|
20
|
+
systemMessage?: unknown;
|
|
21
|
+
}>;
|
|
22
|
+
export declare function rejectRoomFriendRequest(config: RoomSocialConfig, friendshipId: string): Promise<{
|
|
23
|
+
success: boolean;
|
|
24
|
+
}>;
|
|
25
|
+
export declare function removeRoomFriend(config: RoomSocialConfig, friendshipId: string): Promise<{
|
|
26
|
+
success: boolean;
|
|
27
|
+
systemMessage?: unknown;
|
|
28
|
+
}>;
|
|
29
|
+
export declare function listRoomFollowing(config: RoomSocialConfig): Promise<RoomFollow[]>;
|
|
30
|
+
export declare function followRoomUser(config: RoomSocialConfig, username: string): Promise<RoomFollowResult>;
|
|
31
|
+
export declare function unfollowRoomUser(config: RoomSocialConfig, username: string): Promise<{
|
|
32
|
+
target?: RoomFollowResult["target"];
|
|
33
|
+
}>;
|
|
34
|
+
export declare function listRoomDmInbox(config: RoomSocialConfig, options?: {
|
|
35
|
+
unreadOnly?: boolean;
|
|
36
|
+
limit?: number;
|
|
37
|
+
}): Promise<RoomDmConversation[]>;
|
|
38
|
+
export declare function listUnreadRoomDms(config: RoomSocialConfig, options?: {
|
|
39
|
+
username?: string;
|
|
40
|
+
limitPerConversation?: number;
|
|
41
|
+
markRead?: boolean;
|
|
42
|
+
signal?: AbortSignal;
|
|
43
|
+
}): Promise<RoomDmUnreadConversation[]>;
|
|
44
|
+
export declare function getRoomDmHistory(config: RoomSocialConfig, username: string, options?: {
|
|
45
|
+
limit?: number;
|
|
46
|
+
before?: number;
|
|
47
|
+
markRead?: boolean;
|
|
48
|
+
}): Promise<RoomDmHistory>;
|
|
49
|
+
export declare function sendRoomDm(config: RoomSocialConfig, username: string, content: string): Promise<RoomDmSendResult>;
|
|
50
|
+
/** Send a sealed DM: the opaque envelope rides in place of content (the door
|
|
51
|
+
* accepts exactly one of the two). Callers seal first; nothing here can. */
|
|
52
|
+
export declare function sendRoomDmSecret(config: RoomSocialConfig, username: string, secret: {
|
|
53
|
+
armored: string;
|
|
54
|
+
recipients: string[];
|
|
55
|
+
kind: "text";
|
|
56
|
+
}): Promise<RoomDmSendResult>;
|
|
57
|
+
/**
|
|
58
|
+
* CAS write conflict: the doc's head moved past the caller's baseRev. Carries
|
|
59
|
+
* the current head (fetched on demand when the transport dropped it) so the
|
|
60
|
+
* caller can rebase — typically an agent merge — and retry.
|
|
61
|
+
*/
|
|
62
|
+
export declare class RoomDocConflictError extends RoomSocialError {
|
|
63
|
+
readonly head: RoomDocConflictHead | null;
|
|
64
|
+
constructor(message: string, head: RoomDocConflictHead | null);
|
|
65
|
+
}
|
|
66
|
+
export declare function listRoomDocs(config: RoomSocialConfig, options: {
|
|
67
|
+
spaceId: string;
|
|
68
|
+
prefix?: string;
|
|
69
|
+
includeArchived?: boolean;
|
|
70
|
+
limit?: number;
|
|
71
|
+
}): Promise<RoomDoc[]>;
|
|
72
|
+
export declare function getRoomDocChanges(config: RoomSocialConfig, options: {
|
|
73
|
+
spaceId: string;
|
|
74
|
+
since?: number;
|
|
75
|
+
limit?: number;
|
|
76
|
+
signal?: AbortSignal;
|
|
77
|
+
}): Promise<RoomDocChanges>;
|
|
78
|
+
export declare function searchRoomDocs(config: RoomSocialConfig, options: {
|
|
79
|
+
spaceId: string;
|
|
80
|
+
q: string;
|
|
81
|
+
limit?: number;
|
|
82
|
+
}): Promise<RoomDoc[]>;
|
|
83
|
+
export declare function resolveRoomDoc(config: RoomSocialConfig, spaceId: string, path: string): Promise<RoomDoc>;
|
|
84
|
+
export declare function getRoomDoc(config: RoomSocialConfig, docId: string): Promise<RoomDoc>;
|
|
85
|
+
export declare function createRoomDoc(config: RoomSocialConfig, input: {
|
|
86
|
+
spaceId: string;
|
|
87
|
+
path: string;
|
|
88
|
+
content: string;
|
|
89
|
+
note?: string;
|
|
90
|
+
provenance?: RoomDocProvenance;
|
|
91
|
+
aclMode?: "space" | "owner";
|
|
92
|
+
asAgent?: boolean;
|
|
93
|
+
} & RoomDocAttribution): Promise<RoomDoc>;
|
|
94
|
+
export declare function updateRoomDoc(config: RoomSocialConfig, docId: string, input: {
|
|
95
|
+
baseRev: number;
|
|
96
|
+
content: string;
|
|
97
|
+
note?: string;
|
|
98
|
+
provenance?: RoomDocProvenance;
|
|
99
|
+
asAgent?: boolean;
|
|
100
|
+
} & RoomDocAttribution): Promise<RoomDocWriteResult>;
|
|
101
|
+
export declare function updateRoomDocMeta(config: RoomSocialConfig, docId: string, input: {
|
|
102
|
+
path?: string;
|
|
103
|
+
aclMode?: "space" | "owner";
|
|
104
|
+
restrictedToRoomId?: string | null;
|
|
105
|
+
note?: string;
|
|
106
|
+
asAgent?: boolean;
|
|
107
|
+
}): Promise<RoomDoc>;
|
|
108
|
+
export declare function listRoomDocRevisions(config: RoomSocialConfig, docId: string, options?: {
|
|
109
|
+
beforeRev?: number;
|
|
110
|
+
limit?: number;
|
|
111
|
+
}): Promise<RoomDocRevision[]>;
|
|
112
|
+
export declare function getRoomDocRevision(config: RoomSocialConfig, docId: string, rev: number): Promise<RoomDocRevision>;
|
|
113
|
+
export declare function revertRoomDoc(config: RoomSocialConfig, docId: string, input: {
|
|
114
|
+
toRev: number;
|
|
115
|
+
note?: string;
|
|
116
|
+
asAgent?: boolean;
|
|
117
|
+
} & RoomDocAttribution): Promise<RoomDocWriteResult>;
|
|
118
|
+
/**
|
|
119
|
+
* Selective run revert: undo every revision one agent run produced, as ONE
|
|
120
|
+
* new attributed revision computed server-side (inverse three-way merge
|
|
121
|
+
* against the current head; later edits survive). A diverging merge comes
|
|
122
|
+
* back as {status:"conflict"} OUTCOME data carrying the three contents and
|
|
123
|
+
* regions for the reconcile surface; nothing was written. A mid-commit CAS
|
|
124
|
+
* race still throws RoomDocConflictError like every other doc write.
|
|
125
|
+
*/
|
|
126
|
+
export declare function revertRoomDocRun(config: RoomSocialConfig, docId: string, input: {
|
|
127
|
+
runId: string;
|
|
128
|
+
note?: string;
|
|
129
|
+
asAgent?: boolean;
|
|
130
|
+
} & RoomDocAttribution): Promise<RoomDocRunRevertResult>;
|
|
131
|
+
export declare function createSpaceRestorePlan(config: RoomSocialConfig, input: {
|
|
132
|
+
spaceId: string;
|
|
133
|
+
restoreAt: string;
|
|
134
|
+
reason: string;
|
|
135
|
+
}): Promise<RoomSpaceRestorePlan>;
|
|
136
|
+
export declare function getSpaceRestorePlan(config: RoomSocialConfig, planId: string): Promise<RoomSpaceRestorePlan>;
|
|
137
|
+
export declare function applySpaceRestorePlan(config: RoomSocialConfig, planId: string, confirmSpaceId: string): Promise<RoomSpaceRestoreReceipt>;
|
|
138
|
+
/** Recover the durable receipt shape from an authoritative applied plan.
|
|
139
|
+
* Useful when the apply response was lost after the server committed. */
|
|
140
|
+
export declare function spaceRestoreReceiptFromPlan(plan: RoomSpaceRestorePlan): RoomSpaceRestoreReceipt | null;
|
|
141
|
+
export declare function archiveRoomDoc(config: RoomSocialConfig, docId: string, input?: {
|
|
142
|
+
note?: string;
|
|
143
|
+
asAgent?: boolean;
|
|
144
|
+
}): Promise<RoomDoc>;
|
|
145
|
+
/** Renew (or create) the caller's "editing" lease on a doc: I hold a dirty
|
|
146
|
+
* working copy. Heartbeat well inside the server TTL; content never rides. */
|
|
147
|
+
export declare function heartbeatDocEditing(config: RoomSocialConfig, docId: string, options?: {
|
|
148
|
+
asAgent?: boolean;
|
|
149
|
+
}): Promise<RoomDocEditingLease | null>;
|
|
150
|
+
/** Drop the caller's own editing lease (publish or discard). */
|
|
151
|
+
export declare function clearDocEditing(config: RoomSocialConfig, docId: string): Promise<{
|
|
152
|
+
cleared: boolean;
|
|
153
|
+
}>;
|
|
154
|
+
/** Active editing leases across a space (rides the existing library poll). */
|
|
155
|
+
export declare function listDocEditing(config: RoomSocialConfig, spaceId: string): Promise<RoomDocEditingLease[]>;
|
|
156
|
+
export interface RoomSpaceSummary {
|
|
157
|
+
spaceId: string;
|
|
158
|
+
name: string;
|
|
159
|
+
access?: "open" | "invite";
|
|
160
|
+
joined?: boolean;
|
|
161
|
+
role?: string | null;
|
|
162
|
+
/** The #general a new server is born with (present on create). */
|
|
163
|
+
defaultRoom?: {
|
|
164
|
+
roomId: string;
|
|
165
|
+
name?: string;
|
|
166
|
+
} | undefined;
|
|
167
|
+
iconUrl?: string | null;
|
|
168
|
+
/** Creation time — the stable server-rail sort key. */
|
|
169
|
+
createdAt?: string | number | null;
|
|
170
|
+
}
|
|
171
|
+
export declare function listRoomSpacesViaChat(config: RoomSocialConfig): Promise<RoomSpaceSummary[]>;
|
|
172
|
+
export interface RoomSpaceMember {
|
|
173
|
+
userId: string;
|
|
174
|
+
role: "owner" | "admin" | "member";
|
|
175
|
+
/** Named identity roles (RoomSpaceRole.roleId). */
|
|
176
|
+
roleIds?: string[];
|
|
177
|
+
joinedAt?: string;
|
|
178
|
+
}
|
|
179
|
+
export declare function getUserPrefs(config: RoomSocialConfig): Promise<Record<string, unknown>>;
|
|
180
|
+
/** Whole-blob replace (16KB cap server-side; last writer wins). */
|
|
181
|
+
export declare function setUserPrefs(config: RoomSocialConfig, prefs: Record<string, unknown>): Promise<void>;
|
|
182
|
+
export interface RoomSpaceRole {
|
|
183
|
+
roleId: string;
|
|
184
|
+
name: string;
|
|
185
|
+
/** #rrggbb, or null for the default (uncolored) name. */
|
|
186
|
+
color: string | null;
|
|
187
|
+
hoist: boolean;
|
|
188
|
+
position: number;
|
|
189
|
+
}
|
|
190
|
+
export declare function listSpaceRoles(config: RoomSocialConfig, spaceId: string): Promise<RoomSpaceRole[]>;
|
|
191
|
+
export declare function createSpaceRole(config: RoomSocialConfig, spaceId: string, input: {
|
|
192
|
+
name: string;
|
|
193
|
+
color?: string | null;
|
|
194
|
+
hoist?: boolean;
|
|
195
|
+
}): Promise<RoomSpaceRole>;
|
|
196
|
+
export declare function updateSpaceRole(config: RoomSocialConfig, spaceId: string, roleId: string, patch: {
|
|
197
|
+
name?: string;
|
|
198
|
+
color?: string | null;
|
|
199
|
+
hoist?: boolean;
|
|
200
|
+
position?: number;
|
|
201
|
+
}): Promise<RoomSpaceRole>;
|
|
202
|
+
export declare function deleteSpaceRole(config: RoomSocialConfig, spaceId: string, roleId: string): Promise<void>;
|
|
203
|
+
export declare function setSpaceMemberRoles(config: RoomSocialConfig, spaceId: string, targetUserId: string, roleIds: string[]): Promise<{
|
|
204
|
+
spaceId: string;
|
|
205
|
+
userId: string;
|
|
206
|
+
roleIds: string[];
|
|
207
|
+
}>;
|
|
208
|
+
export declare function listSpaceMembers(config: RoomSocialConfig, spaceId: string): Promise<RoomSpaceMember[]>;
|
|
209
|
+
export declare function addSpaceMember(config: RoomSocialConfig, spaceId: string, input: {
|
|
210
|
+
targetUserId?: string;
|
|
211
|
+
targetUsername?: string;
|
|
212
|
+
role?: "admin" | "member";
|
|
213
|
+
}): Promise<RoomSpaceMember>;
|
|
214
|
+
export interface RoomSpaceInvite {
|
|
215
|
+
inviteId: string;
|
|
216
|
+
spaceId: string;
|
|
217
|
+
spaceName?: string;
|
|
218
|
+
invitedUserId?: string;
|
|
219
|
+
invitedBy?: string;
|
|
220
|
+
role: "admin" | "member";
|
|
221
|
+
createdAt?: string;
|
|
222
|
+
}
|
|
223
|
+
/** Create (or refresh) a pending invitation. Membership needs their accept. */
|
|
224
|
+
export declare function createSpaceInvite(config: RoomSocialConfig, spaceId: string, input: {
|
|
225
|
+
targetUserId?: string;
|
|
226
|
+
targetUsername?: string;
|
|
227
|
+
role?: "admin" | "member";
|
|
228
|
+
}): Promise<RoomSpaceInvite>;
|
|
229
|
+
/** The caller's own pending invitations. */
|
|
230
|
+
export declare function listMySpaceInvites(config: RoomSocialConfig): Promise<RoomSpaceInvite[]>;
|
|
231
|
+
/** Pending invitations for a space (managers only). */
|
|
232
|
+
export declare function listSpaceInvites(config: RoomSocialConfig, spaceId: string): Promise<RoomSpaceInvite[]>;
|
|
233
|
+
export declare function acceptSpaceInvite(config: RoomSocialConfig, inviteId: string): Promise<{
|
|
234
|
+
spaceId: string;
|
|
235
|
+
spaceName?: string;
|
|
236
|
+
role?: string;
|
|
237
|
+
joined?: boolean;
|
|
238
|
+
}>;
|
|
239
|
+
export declare function declineSpaceInvite(config: RoomSocialConfig, inviteId: string): Promise<{
|
|
240
|
+
declined?: boolean;
|
|
241
|
+
}>;
|
|
242
|
+
/** Mint (or rotate) the shareable join code; plaintext comes back once. */
|
|
243
|
+
export declare function setSpaceJoinCode(config: RoomSocialConfig, spaceId: string): Promise<{
|
|
244
|
+
spaceId: string;
|
|
245
|
+
code: string;
|
|
246
|
+
}>;
|
|
247
|
+
export declare function clearSpaceJoinCode(config: RoomSocialConfig, spaceId: string): Promise<{
|
|
248
|
+
cleared?: boolean;
|
|
249
|
+
}>;
|
|
250
|
+
/** Redeem a shareable `<spaceId>:<code>` invite. */
|
|
251
|
+
export declare function joinSpaceByCode(config: RoomSocialConfig, spaceId: string, code: string): Promise<{
|
|
252
|
+
spaceId: string;
|
|
253
|
+
spaceName?: string;
|
|
254
|
+
joined?: boolean;
|
|
255
|
+
}>;
|
|
256
|
+
export interface RoomChatProfile {
|
|
257
|
+
userId: string;
|
|
258
|
+
status: "online" | "idle" | "dnd" | null;
|
|
259
|
+
statusText: string | null;
|
|
260
|
+
avatarUrl: string | null;
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* Bulk identity read (avatar/status/custom text) for tapes and rosters: ONE
|
|
264
|
+
* request, cap 100 ids. Identity lives on the platform user record
|
|
265
|
+
* (user_settings.profileUrl / presenceStatus / statusText) — the wire names
|
|
266
|
+
* map onto the chat-facing shape here. Status WRITES ride the ws STATUS
|
|
267
|
+
* frame (the relay persists them), avatar writes go through uploadAvatar.
|
|
268
|
+
*/
|
|
269
|
+
export declare function getBulkProfiles(config: RoomSocialConfig, userIds: string[]): Promise<RoomChatProfile[]>;
|
|
270
|
+
/** Rename / re-describe / re-order a channel (owner/admin). */
|
|
271
|
+
export declare function updateRoomChannel(config: RoomSocialConfig, room: string, input: {
|
|
272
|
+
title?: string;
|
|
273
|
+
description?: string;
|
|
274
|
+
category?: string | null;
|
|
275
|
+
sortOrder?: number;
|
|
276
|
+
/** The per-channel topics dial (off / allowed / required), owner-set. */
|
|
277
|
+
topicsPolicy?: "off" | "allowed" | "required";
|
|
278
|
+
}): Promise<Record<string, unknown>>;
|
|
279
|
+
/** Authoritative single-room meta: the store's resolve route through the
|
|
280
|
+
* relay BFF (existence-hiding 404 preserved). The task engine's policy
|
|
281
|
+
* read rides this, never the ranked room search, because a fresh
|
|
282
|
+
* zero-heat room can be crowded out of a search page and an enforcement
|
|
283
|
+
* read must be deterministic. */
|
|
284
|
+
export declare function resolveRoomChannel(config: RoomSocialConfig, room: string): Promise<Record<string, unknown> & {
|
|
285
|
+
topicsPolicy?: "off" | "allowed" | "required";
|
|
286
|
+
}>;
|
|
287
|
+
/** Archive a channel (owner/admin): drops from listings, refuses posts. */
|
|
288
|
+
export declare function archiveRoomChannel(config: RoomSocialConfig, room: string): Promise<{
|
|
289
|
+
roomId?: string;
|
|
290
|
+
archived?: boolean;
|
|
291
|
+
}>;
|
|
292
|
+
/** Rename / re-access / re-icon a server (managers). */
|
|
293
|
+
export declare function updateRoomSpace(config: RoomSocialConfig, spaceId: string, input: {
|
|
294
|
+
name?: string;
|
|
295
|
+
access?: "open" | "invite";
|
|
296
|
+
iconUrl?: string | null;
|
|
297
|
+
}): Promise<RoomSpaceSummary>;
|
|
298
|
+
/** Archive a server (owner only). */
|
|
299
|
+
export declare function archiveRoomSpace(config: RoomSocialConfig, spaceId: string): Promise<{
|
|
300
|
+
archived?: boolean;
|
|
301
|
+
}>;
|
|
302
|
+
/** Full channel roster (paged): role + lastSeen for every membership row. */
|
|
303
|
+
export declare function listRoomChannelMembers(config: RoomSocialConfig, roomId: string, options?: {
|
|
304
|
+
offset?: number;
|
|
305
|
+
limit?: number;
|
|
306
|
+
}): Promise<{
|
|
307
|
+
total: number;
|
|
308
|
+
offset: number;
|
|
309
|
+
members: Array<{
|
|
310
|
+
userId: string;
|
|
311
|
+
handle: string;
|
|
312
|
+
role: string;
|
|
313
|
+
joinedAt?: string;
|
|
314
|
+
lastSeenAt?: string;
|
|
315
|
+
avatarUrl?: string | null;
|
|
316
|
+
status?: string | null;
|
|
317
|
+
statusText?: string | null;
|
|
318
|
+
}>;
|
|
319
|
+
}>;
|
|
320
|
+
export declare function removeSpaceMember(config: RoomSocialConfig, spaceId: string, targetUserId: string): Promise<{
|
|
321
|
+
removed?: boolean;
|
|
322
|
+
}>;
|
|
323
|
+
export declare function changeSpaceMemberRole(config: RoomSocialConfig, spaceId: string, targetUserId: string, role: "admin" | "member"): Promise<RoomSpaceMember>;
|
|
324
|
+
export declare function createRoomSpace(config: RoomSocialConfig, input: {
|
|
325
|
+
name: string;
|
|
326
|
+
access?: "open" | "invite";
|
|
327
|
+
}): Promise<Partial<RoomSpaceSummary>>;
|
|
328
|
+
export declare function restoreRoomDoc(config: RoomSocialConfig, docId: string, input?: {
|
|
329
|
+
note?: string;
|
|
330
|
+
asAgent?: boolean;
|
|
331
|
+
}): Promise<RoomDoc>;
|
|
332
|
+
export declare function getRoomAttachmentUrl(config: RoomSocialConfig, room: string, key: string): Promise<{
|
|
333
|
+
url: string;
|
|
334
|
+
expiresAt: string | null;
|
|
335
|
+
}>;
|
|
336
|
+
export declare function getRoomPublicProfile(config: RoomSocialConfig, userId: string, hints?: {
|
|
337
|
+
handle?: string;
|
|
338
|
+
username?: string;
|
|
339
|
+
displayName?: string;
|
|
340
|
+
}): Promise<RoomPublicProfile>;
|
|
341
|
+
export declare function listRoomReplies(config: RoomSocialConfig, options?: {
|
|
342
|
+
unreadOnly?: boolean;
|
|
343
|
+
limit?: number;
|
|
344
|
+
signal?: AbortSignal;
|
|
345
|
+
}): Promise<RoomRepliesResult>;
|
|
346
|
+
export declare function markRoomRepliesRead(config: RoomSocialConfig, options?: {
|
|
347
|
+
room?: string;
|
|
348
|
+
before?: string | Date;
|
|
349
|
+
}): Promise<RoomRepliesReadResult>;
|
|
350
|
+
export declare function suggestRooms(config: RoomSocialConfig, request: RoomSuggestionRequest, options?: {
|
|
351
|
+
signal?: AbortSignal;
|
|
352
|
+
}): Promise<RoomSuggestion[]>;
|
|
353
|
+
export declare function socialRequest<T>(config: RoomSocialConfig, path: string, init?: {
|
|
354
|
+
method?: string;
|
|
355
|
+
body?: unknown;
|
|
356
|
+
signal?: AbortSignal;
|
|
357
|
+
formData?: FormData;
|
|
358
|
+
}): Promise<T>;
|
|
359
|
+
export declare function cleanUsername(username: string): string;
|
|
360
|
+
export declare function cleanRoomId(room: string): string;
|
|
361
|
+
export declare function mimeFromFilename(filename: string): string;
|