@jsm-mit/chat-motoko-package 0.5.0 → 0.6.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 CHANGED
@@ -23,6 +23,10 @@ const chat = await new ChatsActor(canisterId, identity).openChatAsyncUnsafe({ pr
23
23
 
24
24
  const messages = new MessagesActor(canisterId, identity);
25
25
  await messages.postAsyncUnsafe({ chatId: chat.id, text: "dodaj usługę strzyżenie" });
26
+
27
+ // The page carries the thread AND what the others are doing: `presence[].typing` while
28
+ // somebody is writing (a room's recipients report it with setTypingAsyncUnsafe, and their
29
+ // own post clears it), `presence[].lastReadSeq` for "read up to here".
26
30
  const page = await messages.getMessagesAsyncUnsafe({ chatId: chat.id, sinceSeq: 0 });
27
31
 
28
32
  // An agent host: every new message in every chat this identity is a recipient of, with
@@ -13,6 +13,7 @@ type UpdateProjectArgs =
13
13
  projectId: ProjectId;
14
14
  };
15
15
  type SystemEvent = variant {chatCreated;};
16
+ type SetTypingArgs = record {chatId: ChatId;};
16
17
  type SetQuotaLimitsArgs = record {limits: QuotaLimits;};
17
18
  type SetLoggingEnabledArgs = record {enabled: bool;};
18
19
  type RoomId = text;
@@ -65,12 +66,12 @@ type Result_4 =
65
66
  type Result_3 =
66
67
  variant {
67
68
  err: Error;
68
- ok: bool;
69
+ ok: QuotaLimits;
69
70
  };
70
71
  type Result_2 =
71
72
  variant {
72
73
  err: Error;
73
- ok: QuotaLimits;
74
+ ok: bool;
74
75
  };
75
76
  type Result_13 =
76
77
  variant {
@@ -129,6 +130,12 @@ type Project =
129
130
  createdBy: principal;
130
131
  id: ProjectId;
131
132
  };
133
+ type Presence =
134
+ record {
135
+ lastReadSeq: nat;
136
+ "principal": principal;
137
+ typingUntil: int;
138
+ };
132
139
  type PostKind =
133
140
  variant {
134
141
  "text";
@@ -170,6 +177,7 @@ type MessagesPage =
170
177
  record {
171
178
  lastSeq: nat;
172
179
  messages: vec Message;
180
+ presence: vec Presence;
173
181
  };
174
182
  type MessageKind =
175
183
  variant {
@@ -281,7 +289,7 @@ type Chat =
281
289
  };
282
290
  type AddAdminArgs = record {"principal": principal;};
283
291
  service : {
284
- addAdmin: (args: AddAdminArgs) -> (Result_3);
292
+ addAdmin: (args: AddAdminArgs) -> (Result_2);
285
293
  clearLogs: () -> ();
286
294
  createProject: (args: CreateProjectArgs) -> (Result_1);
287
295
  createRoom: (args: CreateRoomArgs) -> (Result);
@@ -291,20 +299,22 @@ service : {
291
299
  getMessages: (args: GetMessagesArgs) -> (Result_12) query;
292
300
  getMyChats: (args: GetMyChatsArgs) -> (Result_11) query;
293
301
  getProject: (args: GetProjectArgs) -> (Result_1) query;
294
- getQuotaLimits: () -> (Result_2) query;
302
+ getQuotaLimits: () -> (Result_3) query;
295
303
  getRoom: (args: GetRoomArgs) -> (Result) query;
296
304
  listProjectChats: (args: ListProjectChatsArgs) -> (Result_10) query;
297
305
  listProjects: (args: ListProjectsArgs) -> (Result_9) query;
298
306
  listRooms: (args: ListRoomsArgs) -> (Result_8) query;
299
- markRead: (args: MarkReadArgs) -> (Result_3);
307
+ markRead: (args: MarkReadArgs) -> (Result_2);
300
308
  openChat: (args: OpenChatArgs) -> (Result_7);
301
309
  pollNewMessages: (args: PollNewMessagesArgs) -> (Result_6) query;
302
310
  post: (args: PostArgs) -> (Result_5);
303
- purgeChat: (args: PurgeChatArgs) -> (Result_3);
311
+ purgeChat: (args: PurgeChatArgs) -> (Result_2);
304
312
  registerAsAdmin: () -> (Result_4);
305
- removeAdmin: (args: RemoveAdminArgs) -> (Result_3);
306
- setLoggingEnabled: (args: SetLoggingEnabledArgs) -> (Result_3);
307
- setQuotaLimits: (args: SetQuotaLimitsArgs) -> (Result_2);
313
+ removeAdmin: (args: RemoveAdminArgs) -> (Result_2);
314
+ setLoggingEnabled: (args: SetLoggingEnabledArgs) -> (Result_2);
315
+ setQuotaLimits: (args: SetQuotaLimitsArgs) -> (Result_3);
316
+ /// "I am writing" — a room's recipients only; it expires by itself and a post clears it.
317
+ setTyping: (args: SetTypingArgs) -> (Result_2);
308
318
  updateProject: (args: UpdateProjectArgs) -> (Result_1);
309
319
  updateRoom: (args: UpdateRoomArgs) -> (Result);
310
320
  whoAmI: () -> (principal) query;
@@ -86,6 +86,7 @@ export type MessageKind = { 'toolTrace' : null } |
86
86
  { 'event' : SystemEvent };
87
87
  export interface MessagesPage {
88
88
  'messages' : Array<Message>,
89
+ 'presence' : Array<Presence>,
89
90
  'lastSeq' : bigint,
90
91
  }
91
92
  export interface OpenChatArgs {
@@ -117,6 +118,11 @@ export interface PostArgs {
117
118
  }
118
119
  export type PostKind = { 'toolTrace' : null } |
119
120
  { 'text' : null };
121
+ export interface Presence {
122
+ 'principal' : Principal,
123
+ 'typingUntil' : bigint,
124
+ 'lastReadSeq' : bigint,
125
+ }
120
126
  export interface Project {
121
127
  'id' : ProjectId,
122
128
  'createdAt' : bigint,
@@ -147,9 +153,9 @@ export type Result_12 = { 'ok' : MessagesPage } |
147
153
  { 'err' : Error };
148
154
  export type Result_13 = { 'ok' : Array<Principal> } |
149
155
  { 'err' : Error };
150
- export type Result_2 = { 'ok' : QuotaLimits } |
156
+ export type Result_2 = { 'ok' : boolean } |
151
157
  { 'err' : Error };
152
- export type Result_3 = { 'ok' : boolean } |
158
+ export type Result_3 = { 'ok' : QuotaLimits } |
153
159
  { 'err' : Error };
154
160
  export type Result_4 = { 'ok' : Principal } |
155
161
  { 'err' : Error };
@@ -178,6 +184,7 @@ export interface Room {
178
184
  export type RoomId = string;
179
185
  export interface SetLoggingEnabledArgs { 'enabled' : boolean }
180
186
  export interface SetQuotaLimitsArgs { 'limits' : QuotaLimits }
187
+ export interface SetTypingArgs { 'chatId' : ChatId }
181
188
  export type SystemEvent = { 'chatCreated' : null };
182
189
  export interface UpdateProjectArgs {
183
190
  'accountsCanister' : [] | [Principal],
@@ -192,7 +199,7 @@ export interface UpdateRoomArgs {
192
199
  'allowedCustomers' : [] | [Array<Principal>],
193
200
  }
194
201
  export interface _SERVICE {
195
- 'addAdmin' : ActorMethod<[AddAdminArgs], Result_3>,
202
+ 'addAdmin' : ActorMethod<[AddAdminArgs], Result_2>,
196
203
  'clearLogs' : ActorMethod<[], undefined>,
197
204
  'createProject' : ActorMethod<[CreateProjectArgs], Result_1>,
198
205
  'createRoom' : ActorMethod<[CreateRoomArgs], Result>,
@@ -202,20 +209,24 @@ export interface _SERVICE {
202
209
  'getMessages' : ActorMethod<[GetMessagesArgs], Result_12>,
203
210
  'getMyChats' : ActorMethod<[GetMyChatsArgs], Result_11>,
204
211
  'getProject' : ActorMethod<[GetProjectArgs], Result_1>,
205
- 'getQuotaLimits' : ActorMethod<[], Result_2>,
212
+ 'getQuotaLimits' : ActorMethod<[], Result_3>,
206
213
  'getRoom' : ActorMethod<[GetRoomArgs], Result>,
207
214
  'listProjectChats' : ActorMethod<[ListProjectChatsArgs], Result_10>,
208
215
  'listProjects' : ActorMethod<[ListProjectsArgs], Result_9>,
209
216
  'listRooms' : ActorMethod<[ListRoomsArgs], Result_8>,
210
- 'markRead' : ActorMethod<[MarkReadArgs], Result_3>,
217
+ 'markRead' : ActorMethod<[MarkReadArgs], Result_2>,
211
218
  'openChat' : ActorMethod<[OpenChatArgs], Result_7>,
212
219
  'pollNewMessages' : ActorMethod<[PollNewMessagesArgs], Result_6>,
213
220
  'post' : ActorMethod<[PostArgs], Result_5>,
214
- 'purgeChat' : ActorMethod<[PurgeChatArgs], Result_3>,
221
+ 'purgeChat' : ActorMethod<[PurgeChatArgs], Result_2>,
215
222
  'registerAsAdmin' : ActorMethod<[], Result_4>,
216
- 'removeAdmin' : ActorMethod<[RemoveAdminArgs], Result_3>,
217
- 'setLoggingEnabled' : ActorMethod<[SetLoggingEnabledArgs], Result_3>,
218
- 'setQuotaLimits' : ActorMethod<[SetQuotaLimitsArgs], Result_2>,
223
+ 'removeAdmin' : ActorMethod<[RemoveAdminArgs], Result_2>,
224
+ 'setLoggingEnabled' : ActorMethod<[SetLoggingEnabledArgs], Result_2>,
225
+ 'setQuotaLimits' : ActorMethod<[SetQuotaLimitsArgs], Result_3>,
226
+ /**
227
+ * / "I am writing" — a room's recipients only; it expires by itself and a post clears it.
228
+ */
229
+ 'setTyping' : ActorMethod<[SetTypingArgs], Result_2>,
219
230
  'updateProject' : ActorMethod<[UpdateProjectArgs], Result_1>,
220
231
  'updateRoom' : ActorMethod<[UpdateRoomArgs], Result>,
221
232
  'whoAmI' : ActorMethod<[], Principal>,
@@ -10,7 +10,7 @@ export const idlFactory = ({ IDL }) => {
10
10
  'ReturnsNull' : IDL.Null,
11
11
  });
12
12
  const Error = IDL.Record({ 'details' : ErrorDetails, 'logsJson' : IDL.Text });
13
- const Result_3 = IDL.Variant({ 'ok' : IDL.Bool, 'err' : Error });
13
+ const Result_2 = IDL.Variant({ 'ok' : IDL.Bool, 'err' : Error });
14
14
  const ProjectId = IDL.Text;
15
15
  const CreateProjectArgs = IDL.Record({
16
16
  'id' : ProjectId,
@@ -105,8 +105,14 @@ export const idlFactory = ({ IDL }) => {
105
105
  'chatId' : ChatId,
106
106
  'roomId' : RoomId,
107
107
  });
108
+ const Presence = IDL.Record({
109
+ 'principal' : IDL.Principal,
110
+ 'typingUntil' : IDL.Int,
111
+ 'lastReadSeq' : IDL.Nat,
112
+ });
108
113
  const MessagesPage = IDL.Record({
109
114
  'messages' : IDL.Vec(Message),
115
+ 'presence' : IDL.Vec(Presence),
110
116
  'lastSeq' : IDL.Nat,
111
117
  });
112
118
  const Result_12 = IDL.Variant({ 'ok' : MessagesPage, 'err' : Error });
@@ -118,7 +124,7 @@ export const idlFactory = ({ IDL }) => {
118
124
  const Result_11 = IDL.Variant({ 'ok' : IDL.Vec(Chat), 'err' : Error });
119
125
  const GetProjectArgs = IDL.Record({ 'projectId' : ProjectId });
120
126
  const QuotaLimits = IDL.Record({ 'chats' : IDL.Nat, 'posts' : IDL.Nat });
121
- const Result_2 = IDL.Variant({ 'ok' : QuotaLimits, 'err' : Error });
127
+ const Result_3 = IDL.Variant({ 'ok' : QuotaLimits, 'err' : Error });
122
128
  const GetRoomArgs = IDL.Record({
123
129
  'projectId' : ProjectId,
124
130
  'roomId' : RoomId,
@@ -175,6 +181,7 @@ export const idlFactory = ({ IDL }) => {
175
181
  const RemoveAdminArgs = IDL.Record({ 'principal' : IDL.Principal });
176
182
  const SetLoggingEnabledArgs = IDL.Record({ 'enabled' : IDL.Bool });
177
183
  const SetQuotaLimitsArgs = IDL.Record({ 'limits' : QuotaLimits });
184
+ const SetTypingArgs = IDL.Record({ 'chatId' : ChatId });
178
185
  const UpdateProjectArgs = IDL.Record({
179
186
  'accountsCanister' : IDL.Opt(IDL.Principal),
180
187
  'projectId' : ProjectId,
@@ -188,7 +195,7 @@ export const idlFactory = ({ IDL }) => {
188
195
  'allowedCustomers' : IDL.Opt(IDL.Vec(IDL.Principal)),
189
196
  });
190
197
  return IDL.Service({
191
- 'addAdmin' : IDL.Func([AddAdminArgs], [Result_3], []),
198
+ 'addAdmin' : IDL.Func([AddAdminArgs], [Result_2], []),
192
199
  'clearLogs' : IDL.Func([], [], []),
193
200
  'createProject' : IDL.Func([CreateProjectArgs], [Result_1], []),
194
201
  'createRoom' : IDL.Func([CreateRoomArgs], [Result], []),
@@ -198,7 +205,7 @@ export const idlFactory = ({ IDL }) => {
198
205
  'getMessages' : IDL.Func([GetMessagesArgs], [Result_12], ['query']),
199
206
  'getMyChats' : IDL.Func([GetMyChatsArgs], [Result_11], ['query']),
200
207
  'getProject' : IDL.Func([GetProjectArgs], [Result_1], ['query']),
201
- 'getQuotaLimits' : IDL.Func([], [Result_2], ['query']),
208
+ 'getQuotaLimits' : IDL.Func([], [Result_3], ['query']),
202
209
  'getRoom' : IDL.Func([GetRoomArgs], [Result], ['query']),
203
210
  'listProjectChats' : IDL.Func(
204
211
  [ListProjectChatsArgs],
@@ -207,15 +214,16 @@ export const idlFactory = ({ IDL }) => {
207
214
  ),
208
215
  'listProjects' : IDL.Func([ListProjectsArgs], [Result_9], ['query']),
209
216
  'listRooms' : IDL.Func([ListRoomsArgs], [Result_8], ['query']),
210
- 'markRead' : IDL.Func([MarkReadArgs], [Result_3], []),
217
+ 'markRead' : IDL.Func([MarkReadArgs], [Result_2], []),
211
218
  'openChat' : IDL.Func([OpenChatArgs], [Result_7], []),
212
219
  'pollNewMessages' : IDL.Func([PollNewMessagesArgs], [Result_6], ['query']),
213
220
  'post' : IDL.Func([PostArgs], [Result_5], []),
214
- 'purgeChat' : IDL.Func([PurgeChatArgs], [Result_3], []),
221
+ 'purgeChat' : IDL.Func([PurgeChatArgs], [Result_2], []),
215
222
  'registerAsAdmin' : IDL.Func([], [Result_4], []),
216
- 'removeAdmin' : IDL.Func([RemoveAdminArgs], [Result_3], []),
217
- 'setLoggingEnabled' : IDL.Func([SetLoggingEnabledArgs], [Result_3], []),
218
- 'setQuotaLimits' : IDL.Func([SetQuotaLimitsArgs], [Result_2], []),
223
+ 'removeAdmin' : IDL.Func([RemoveAdminArgs], [Result_2], []),
224
+ 'setLoggingEnabled' : IDL.Func([SetLoggingEnabledArgs], [Result_2], []),
225
+ 'setQuotaLimits' : IDL.Func([SetQuotaLimitsArgs], [Result_3], []),
226
+ 'setTyping' : IDL.Func([SetTypingArgs], [Result_2], []),
219
227
  'updateProject' : IDL.Func([UpdateProjectArgs], [Result_1], []),
220
228
  'updateRoom' : IDL.Func([UpdateRoomArgs], [Result], []),
221
229
  'whoAmI' : IDL.Func([], [IDL.Principal], ['query']),
@@ -22,7 +22,18 @@ export declare class MessagesActor extends ActorBase {
22
22
  */
23
23
  markReadAsyncUnsafe(chatId: string, seq: number): Promise<boolean>;
24
24
  /**
25
- * A chat's messages with seq > sinceSeq, oldest first (max 200 per call).
25
+ * Reports that the caller is writing: true for 30 seconds, cleared by their own next
26
+ * post, and gone by itself afterwards — so a client that dies mid-turn leaves no
27
+ * indicator hanging. A ROOM'S RECIPIENTS ONLY (a person or an agent); a customer is
28
+ * refused. Send it once at the start of a turn, not per keystroke.
29
+ * @throws Error with message `CanisterError` when the canister returns a business error (`NotAuthorized` for a customer or a non-participant, `NotFound` for the chat). Examine "cause" for {errorKey, errorMessage, logs}.
30
+ * @throws Error with message `CriticalCanisterError` when there is no communication with the canister or the canister code traps during execution.
31
+ * @throws Error with message `CallRefusedAtInspectionStage` when the canister's `inspect` rejects the call before execution.
32
+ */
33
+ setTypingAsyncUnsafe(chatId: string): Promise<boolean>;
34
+ /**
35
+ * A chat's messages with seq > sinceSeq, oldest first (max 200 per call), together
36
+ * with `presence`: who is typing and how far each other participant has read.
26
37
  * Participants only.
27
38
  * @throws Error with message `CanisterError` when the canister returns a business error (not authorized, `NotFound`). Examine "cause" for {errorKey, errorMessage, logs}.
28
39
  * @throws Error with message `CriticalCanisterError` when there is no communication with the canister or the canister code traps during execution.
@@ -1 +1 @@
1
- {"version":3,"file":"messages-actor.d.ts","sourceRoot":"","sources":["../../src/actors/messages-actor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,KAAK,EAAE,gBAAgB,EAAE,WAAW,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAGzI,yDAAyD;AACzD,qBAAa,aAAc,SAAQ,SAAS;gBAE5B,UAAU,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,QAAQ;IAInD;;;;;;OAMG;IACU,eAAe,CAAC,KAAK,EAAE,SAAS,GAAG,OAAO,CAAC,WAAW,CAAC;IAWpE,2EAA2E;IAC9D,aAAa,CAAC,KAAK,EAAE,SAAS,GAAG,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC;IAQzE;;;;;OAKG;IACU,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAI/E;;;;;;OAMG;IACU,sBAAsB,CA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;IAU7F,sFAAsF;IACzE,wBAAwB,CAAC,KAAK,EAAE,oBAAoB,GAAG,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC;CAOrG"}
@@ -40,7 +40,20 @@ export class MessagesActor extends ActorBase {
40
40
  return this.executeFunctionAsyncUnsafe(() => this.actor.markRead({ chatId, seq: BigInt(seq) }));
41
41
  }
42
42
  /**
43
- * A chat's messages with seq > sinceSeq, oldest first (max 200 per call).
43
+ * Reports that the caller is writing: true for 30 seconds, cleared by their own next
44
+ * post, and gone by itself afterwards — so a client that dies mid-turn leaves no
45
+ * indicator hanging. A ROOM'S RECIPIENTS ONLY (a person or an agent); a customer is
46
+ * refused. Send it once at the start of a turn, not per keystroke.
47
+ * @throws Error with message `CanisterError` when the canister returns a business error (`NotAuthorized` for a customer or a non-participant, `NotFound` for the chat). Examine "cause" for {errorKey, errorMessage, logs}.
48
+ * @throws Error with message `CriticalCanisterError` when there is no communication with the canister or the canister code traps during execution.
49
+ * @throws Error with message `CallRefusedAtInspectionStage` when the canister's `inspect` rejects the call before execution.
50
+ */
51
+ async setTypingAsyncUnsafe(chatId) {
52
+ return this.executeFunctionAsyncUnsafe(() => this.actor.setTyping({ chatId }));
53
+ }
54
+ /**
55
+ * A chat's messages with seq > sinceSeq, oldest first (max 200 per call), together
56
+ * with `presence`: who is typing and how far each other participant has read.
44
57
  * Participants only.
45
58
  * @throws Error with message `CanisterError` when the canister returns a business error (not authorized, `NotFound`). Examine "cause" for {errorKey, errorMessage, logs}.
46
59
  * @throws Error with message `CriticalCanisterError` when there is no communication with the canister or the canister code traps during execution.
package/dist/index.d.ts CHANGED
@@ -5,7 +5,7 @@ export { RoomsActor } from "./actors/rooms-actor.js";
5
5
  export { ChatsActor } from "./actors/chats-actor.js";
6
6
  export { MessagesActor } from "./actors/messages-actor.js";
7
7
  export { ChatPoller, type ChatPollerOptions } from "./chat-poller.js";
8
- export type { RoleView, RecipientRoleView, ProjectView, RecipientView, RoomView, ParticipantView, ChatView, ChatSummaryView, SystemEventView, MessageKindView, MessageView, MessagesPageView, PollResultView, QuotaLimitsView, CreateProjectInput, UpdateProjectInput, CreateRoomInput, UpdateRoomInput, RoomRefInput, ListRoomsInput, OpenChatInput, GetMyChatsInput, ListProjectChatsInput, PostInput, GetMessagesInput, PollNewMessagesInput, } from "./interfaces.js";
8
+ export type { RoleView, RecipientRoleView, ProjectView, RecipientView, RoomView, ParticipantView, ChatView, ChatSummaryView, SystemEventView, MessageKindView, MessageView, MessagesPageView, PresenceView, PollResultView, QuotaLimitsView, CreateProjectInput, UpdateProjectInput, CreateRoomInput, UpdateRoomInput, RoomRefInput, ListRoomsInput, OpenChatInput, GetMyChatsInput, ListProjectChatsInput, PostInput, GetMessagesInput, PollNewMessagesInput, } from "./interfaces.js";
9
9
  export { mapProjectView, mapRoomView, mapRecipientView, mapChatView, mapChatSummaryView, mapParticipantView, mapMessageView, mapMessagesPageView, mapPollResultView, mapSystemEventView, mapQuotaLimitsView, mapRoleView, mapRecipientRoleView, toCandidRecipient, toCandidRecipientRole, } from "./mappers.js";
10
10
  export type { Chat, ChatId, ChatSummary, Message, MessageKind, MessagesPage, Participant, PollResult, Project, ProjectId, QuotaLimits, Recipient, RecipientRole, Role, Room, RoomId, SystemEvent, Error as CanisterErrorShape, ErrorDetails, } from "../declarations/chat-motoko-backend/chat-motoko-backend.did.js";
11
11
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,KAAK,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACtE,YAAY,EACR,QAAQ,EACR,iBAAiB,EACjB,WAAW,EACX,aAAa,EACb,QAAQ,EACR,eAAe,EACf,QAAQ,EACR,eAAe,EACf,eAAe,EACf,eAAe,EACf,WAAW,EACX,gBAAgB,EAChB,cAAc,EACd,eAAe,EACf,kBAAkB,EAClB,kBAAkB,EAClB,eAAe,EACf,eAAe,EACf,YAAY,EACZ,cAAc,EACd,aAAa,EACb,eAAe,EACf,qBAAqB,EACrB,SAAS,EACT,gBAAgB,EAChB,oBAAoB,GACvB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACH,cAAc,EACd,WAAW,EACX,gBAAgB,EAChB,WAAW,EACX,kBAAkB,EAClB,kBAAkB,EAClB,cAAc,EACd,mBAAmB,EACnB,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,EAClB,WAAW,EACX,oBAAoB,EACpB,iBAAiB,EACjB,qBAAqB,GACxB,MAAM,cAAc,CAAC;AACtB,YAAY,EACR,IAAI,EACJ,MAAM,EACN,WAAW,EACX,OAAO,EACP,WAAW,EACX,YAAY,EACZ,WAAW,EACX,UAAU,EACV,OAAO,EACP,SAAS,EACT,WAAW,EACX,SAAS,EACT,aAAa,EACb,IAAI,EACJ,IAAI,EACJ,MAAM,EACN,WAAW,EACX,KAAK,IAAI,kBAAkB,EAC3B,YAAY,GACf,MAAM,gEAAgE,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,KAAK,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACtE,YAAY,EACR,QAAQ,EACR,iBAAiB,EACjB,WAAW,EACX,aAAa,EACb,QAAQ,EACR,eAAe,EACf,QAAQ,EACR,eAAe,EACf,eAAe,EACf,eAAe,EACf,WAAW,EACX,gBAAgB,EAChB,YAAY,EACZ,cAAc,EACd,eAAe,EACf,kBAAkB,EAClB,kBAAkB,EAClB,eAAe,EACf,eAAe,EACf,YAAY,EACZ,cAAc,EACd,aAAa,EACb,eAAe,EACf,qBAAqB,EACrB,SAAS,EACT,gBAAgB,EAChB,oBAAoB,GACvB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACH,cAAc,EACd,WAAW,EACX,gBAAgB,EAChB,WAAW,EACX,kBAAkB,EAClB,kBAAkB,EAClB,cAAc,EACd,mBAAmB,EACnB,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,EAClB,WAAW,EACX,oBAAoB,EACpB,iBAAiB,EACjB,qBAAqB,GACxB,MAAM,cAAc,CAAC;AACtB,YAAY,EACR,IAAI,EACJ,MAAM,EACN,WAAW,EACX,OAAO,EACP,WAAW,EACX,YAAY,EACZ,WAAW,EACX,UAAU,EACV,OAAO,EACP,SAAS,EACT,WAAW,EACX,SAAS,EACT,aAAa,EACb,IAAI,EACJ,IAAI,EACJ,MAAM,EACN,WAAW,EACX,KAAK,IAAI,kBAAkB,EAC3B,YAAY,GACf,MAAM,gEAAgE,CAAC"}
@@ -86,6 +86,21 @@ export interface MessageView {
86
86
  export interface MessagesPageView {
87
87
  messages: MessageView[];
88
88
  lastSeq: number;
89
+ /** What every OTHER participant is doing right now — the caller's own row is left out. */
90
+ presence: PresenceView[];
91
+ }
92
+ /** Who is typing and how far they have read, as of the moment the page was read. */
93
+ export interface PresenceView {
94
+ principal: string;
95
+ /**
96
+ * `true` while this participant's typing signal is still valid. Derived from the
97
+ * canister's instant and the clock at read time, so it needs no timer of its own.
98
+ */
99
+ typing: boolean;
100
+ /** Nanoseconds; 0 when the participant is not typing. */
101
+ typingUntil: bigint;
102
+ /** Highest per-chat seq this participant has marked read (0 = nothing). */
103
+ lastReadSeq: number;
89
104
  }
90
105
  export interface PollResultView {
91
106
  messages: MessageView[];
@@ -1 +1 @@
1
- {"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,mGAAmG;AACnG,MAAM,MAAM,QAAQ,GAAG,UAAU,GAAG,QAAQ,GAAG,OAAO,CAAC;AACvD,iFAAiF;AACjF,MAAM,MAAM,iBAAiB,GAAG,QAAQ,GAAG,OAAO,CAAC;AAEnD,MAAM,WAAW,WAAW;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,6EAA6E;IAC7E,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,wFAAwF;IACxF,kBAAkB,EAAE,MAAM,CAAC;CAC9B;AAED,MAAM,WAAW,aAAa;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,iBAAiB,CAAC;IACxB,qDAAqD;IACrD,WAAW,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,QAAQ;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,aAAa,EAAE,CAAC;IAC5B,kFAAkF;IAClF,gBAAgB,EAAE,MAAM,EAAE,CAAC;CAC9B;AAED,MAAM,WAAW,eAAe;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,IAA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ED,wBAAgB,cAAc,CAAC,OAAO,EAAE,OAAO,GAAG,WAAW,CAQ5D;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,IAAI,GAAG,QAAQ,CAUhD;AAED,wBAAgB,kBAAkB,CAAC,WAAW,EAAE,WAAW,GAAG,eAAe,CAU5E;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,IAAI,GAAG,QAAQ,CAWhD;AAED,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,WAAW,GAAG,eAAe,CAWxE;AAED,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,WAAW,GAAG,eAAe,CAEvE;AAED,wBAAgB,cAAc,CAAC,OAAO,EAAE,OAAO,GAAG,WAAW,CAiB5D;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,YAAY,GAAG,gBAAgB,CAcxE;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,UAAU,GAAG,cAAc,CAMpE;AAED,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,WAAW,GAAG,eAAe,CAEvE;AAED,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,eAAe,GAAG,WAAW,CAExE"}
package/dist/mappers.js CHANGED
@@ -110,7 +110,19 @@ export function mapMessageView(message) {
110
110
  return { ...base, kind: "toolTrace" in message.kind ? "toolTrace" : "text" };
111
111
  }
112
112
  export function mapMessagesPageView(page) {
113
- return { messages: page.messages.map(mapMessageView), lastSeq: Number(page.lastSeq) };
113
+ // The canister answers with the instant a signal expires; whether it still holds is a
114
+ // question about now, and the caller should not have to ask it themselves.
115
+ const nowNs = BigInt(Date.now()) * 1000000n;
116
+ return {
117
+ messages: page.messages.map(mapMessageView),
118
+ lastSeq: Number(page.lastSeq),
119
+ presence: page.presence.map((entry) => ({
120
+ principal: entry.principal.toText(),
121
+ typing: entry.typingUntil > nowNs,
122
+ typingUntil: entry.typingUntil,
123
+ lastReadSeq: Number(entry.lastReadSeq),
124
+ })),
125
+ };
114
126
  }
115
127
  export function mapPollResultView(result) {
116
128
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsm-mit/chat-motoko-package",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
4
4
  "description": "Wrapper TypeScript package for the chat-motoko canister: projects, multi-party chats, messages and a poller for agent hosts.",
5
5
  "license": "ISC",
6
6
  "author": "",
@@ -58,6 +58,6 @@
58
58
  "chatMotoko": {
59
59
  "repo": "chat-motoko",
60
60
  "repoUrl": "https://github.com/JSM-Chat-Platform/chat-motoko",
61
- "commit": "1a505b79dfe4e90997143abe4d17607e9a5083f1"
61
+ "commit": "a5184ccd2c42aefd0b21dc0419cd24530e10de5b"
62
62
  }
63
63
  }