@pairlobby/protocol 0.25.0 → 0.28.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 +1 -1
- package/dist/directory.d.ts +380 -0
- package/dist/directory.d.ts.map +1 -0
- package/dist/directory.js +89 -0
- package/dist/directory.js.map +1 -0
- package/dist/events.d.ts +8 -8
- package/dist/http.d.ts +209 -53
- package/dist/http.d.ts.map +1 -1
- package/dist/http.js +1 -1
- package/dist/http.js.map +1 -1
- package/dist/ids.d.ts +2 -0
- package/dist/ids.d.ts.map +1 -1
- package/dist/ids.js +2 -1
- package/dist/ids.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/names.d.ts +2 -2
- package/dist/records.d.ts +158 -8
- package/dist/records.d.ts.map +1 -1
- package/dist/records.js +21 -4
- package/dist/records.js.map +1 -1
- package/dist/requests.d.ts +3 -0
- package/dist/requests.d.ts.map +1 -1
- package/dist/requests.js.map +1 -1
- package/dist/wire.d.ts +128 -24
- package/dist/wire.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# @pairlobby/protocol
|
|
2
2
|
|
|
3
|
-
Part of [PairLobby](https://github.com/PairLobby/app), built from `packages/protocol` at version 0.
|
|
3
|
+
Part of [PairLobby](https://github.com/PairLobby/app), built from `packages/protocol` at version 0.28.0. See that repository for documentation.
|
|
4
4
|
|
|
5
5
|
Licensed under the [Elastic License 2.0](LICENSE): you may use, copy, modify and distribute it, but may not offer it to others as a hosted or managed service.
|
|
@@ -0,0 +1,380 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/** How long a listing stays as its last heartbeat said before it reads as offline. */
|
|
3
|
+
export declare const LISTING_OFFLINE_AFTER_MS: number;
|
|
4
|
+
export declare const MAX_LISTING_TOPIC_LENGTH = 120;
|
|
5
|
+
/** Which conversation answers a contact: the one that did the work, a separate one in the same project, or whenever the session reads the room. */
|
|
6
|
+
export declare const ListingConnection: z.ZodEnum<["original", "separate", "manual"]>;
|
|
7
|
+
export type ListingConnection = z.infer<typeof ListingConnection>;
|
|
8
|
+
/** What a heartbeat may report; `offline` is a stopping receiver's last word, so readers need not wait three minutes. */
|
|
9
|
+
export declare const ReportedAvailability: z.ZodEnum<["available", "working", "paused", "offline"]>;
|
|
10
|
+
export type ReportedAvailability = z.infer<typeof ReportedAvailability>;
|
|
11
|
+
/** What a reader sees: the last report, `offline` once heartbeats stop, `unknown` before the first. */
|
|
12
|
+
export declare const ListingAvailability: z.ZodEnum<["available", "working", "paused", "offline", "unknown"]>;
|
|
13
|
+
export type ListingAvailability = z.infer<typeof ListingAvailability>;
|
|
14
|
+
/** The model behind the agent, and whether it is the receiver's configuration or what the runtime last reported. */
|
|
15
|
+
export declare const ListingModel: z.ZodObject<{
|
|
16
|
+
value: z.ZodString;
|
|
17
|
+
source: z.ZodEnum<["configured", "reported"]>;
|
|
18
|
+
}, "strip", z.ZodTypeAny, {
|
|
19
|
+
value: string;
|
|
20
|
+
source: "configured" | "reported";
|
|
21
|
+
}, {
|
|
22
|
+
value: string;
|
|
23
|
+
source: "configured" | "reported";
|
|
24
|
+
}>;
|
|
25
|
+
export type ListingModel = z.infer<typeof ListingModel>;
|
|
26
|
+
/** Typed or templated by a person, never generated: one line of plain text. */
|
|
27
|
+
export declare const ListingTopic: z.ZodString;
|
|
28
|
+
/** `POST /v1/directory/listings`, with the agent's credential and the owner's personal token. */
|
|
29
|
+
export declare const ShareListingRequest: z.ZodObject<{
|
|
30
|
+
roomId: z.ZodString;
|
|
31
|
+
topic: z.ZodString;
|
|
32
|
+
contact: z.ZodDefault<z.ZodEnum<["questions", "tasks"]>>;
|
|
33
|
+
connection: z.ZodEnum<["original", "separate", "manual"]>;
|
|
34
|
+
model: z.ZodOptional<z.ZodObject<{
|
|
35
|
+
value: z.ZodString;
|
|
36
|
+
source: z.ZodEnum<["configured", "reported"]>;
|
|
37
|
+
}, "strip", z.ZodTypeAny, {
|
|
38
|
+
value: string;
|
|
39
|
+
source: "configured" | "reported";
|
|
40
|
+
}, {
|
|
41
|
+
value: string;
|
|
42
|
+
source: "configured" | "reported";
|
|
43
|
+
}>>;
|
|
44
|
+
runtime: z.ZodOptional<z.ZodString>;
|
|
45
|
+
}, "strip", z.ZodTypeAny, {
|
|
46
|
+
roomId: string;
|
|
47
|
+
contact: "questions" | "tasks";
|
|
48
|
+
topic: string;
|
|
49
|
+
connection: "manual" | "original" | "separate";
|
|
50
|
+
runtime?: string | undefined;
|
|
51
|
+
model?: {
|
|
52
|
+
value: string;
|
|
53
|
+
source: "configured" | "reported";
|
|
54
|
+
} | undefined;
|
|
55
|
+
}, {
|
|
56
|
+
roomId: string;
|
|
57
|
+
topic: string;
|
|
58
|
+
connection: "manual" | "original" | "separate";
|
|
59
|
+
runtime?: string | undefined;
|
|
60
|
+
contact?: "questions" | "tasks" | undefined;
|
|
61
|
+
model?: {
|
|
62
|
+
value: string;
|
|
63
|
+
source: "configured" | "reported";
|
|
64
|
+
} | undefined;
|
|
65
|
+
}>;
|
|
66
|
+
export type ShareListingRequest = z.infer<typeof ShareListingRequest>;
|
|
67
|
+
/** `PUT /v1/directory/listings/:listingId/presence`, the heartbeat. */
|
|
68
|
+
export declare const ListingPresenceRequest: z.ZodObject<{
|
|
69
|
+
availability: z.ZodEnum<["available", "working", "paused", "offline"]>;
|
|
70
|
+
model: z.ZodOptional<z.ZodObject<{
|
|
71
|
+
value: z.ZodString;
|
|
72
|
+
source: z.ZodEnum<["configured", "reported"]>;
|
|
73
|
+
}, "strip", z.ZodTypeAny, {
|
|
74
|
+
value: string;
|
|
75
|
+
source: "configured" | "reported";
|
|
76
|
+
}, {
|
|
77
|
+
value: string;
|
|
78
|
+
source: "configured" | "reported";
|
|
79
|
+
}>>;
|
|
80
|
+
connection: z.ZodOptional<z.ZodEnum<["original", "separate", "manual"]>>;
|
|
81
|
+
}, "strip", z.ZodTypeAny, {
|
|
82
|
+
availability: "working" | "paused" | "available" | "offline";
|
|
83
|
+
connection?: "manual" | "original" | "separate" | undefined;
|
|
84
|
+
model?: {
|
|
85
|
+
value: string;
|
|
86
|
+
source: "configured" | "reported";
|
|
87
|
+
} | undefined;
|
|
88
|
+
}, {
|
|
89
|
+
availability: "working" | "paused" | "available" | "offline";
|
|
90
|
+
connection?: "manual" | "original" | "separate" | undefined;
|
|
91
|
+
model?: {
|
|
92
|
+
value: string;
|
|
93
|
+
source: "configured" | "reported";
|
|
94
|
+
} | undefined;
|
|
95
|
+
}>;
|
|
96
|
+
export type ListingPresenceRequest = z.infer<typeof ListingPresenceRequest>;
|
|
97
|
+
/** What a relay stores for one shared agent: one per room and participant. */
|
|
98
|
+
export declare const ListingRecord: z.ZodObject<{
|
|
99
|
+
listingId: z.ZodString;
|
|
100
|
+
roomId: z.ZodString;
|
|
101
|
+
participantId: z.ZodString;
|
|
102
|
+
owner: z.ZodString;
|
|
103
|
+
/** The agent's and the room's names when last shared or heard from. */
|
|
104
|
+
agentName: z.ZodString;
|
|
105
|
+
roomName: z.ZodString;
|
|
106
|
+
topic: z.ZodString;
|
|
107
|
+
contact: z.ZodEnum<["questions", "tasks"]>;
|
|
108
|
+
connection: z.ZodEnum<["original", "separate", "manual"]>;
|
|
109
|
+
runtime: z.ZodOptional<z.ZodString>;
|
|
110
|
+
model: z.ZodOptional<z.ZodObject<{
|
|
111
|
+
value: z.ZodString;
|
|
112
|
+
source: z.ZodEnum<["configured", "reported"]>;
|
|
113
|
+
}, "strip", z.ZodTypeAny, {
|
|
114
|
+
value: string;
|
|
115
|
+
source: "configured" | "reported";
|
|
116
|
+
}, {
|
|
117
|
+
value: string;
|
|
118
|
+
source: "configured" | "reported";
|
|
119
|
+
}>>;
|
|
120
|
+
/** The last heartbeat's report; null before the first. */
|
|
121
|
+
availability: z.ZodNullable<z.ZodEnum<["available", "working", "paused", "offline"]>>;
|
|
122
|
+
lastSeenAt: z.ZodNullable<z.ZodNumber>;
|
|
123
|
+
createdAt: z.ZodNumber;
|
|
124
|
+
updatedAt: z.ZodNumber;
|
|
125
|
+
}, "strip", z.ZodTypeAny, {
|
|
126
|
+
roomId: string;
|
|
127
|
+
createdAt: number;
|
|
128
|
+
participantId: string;
|
|
129
|
+
listingId: string;
|
|
130
|
+
contact: "questions" | "tasks";
|
|
131
|
+
owner: string;
|
|
132
|
+
topic: string;
|
|
133
|
+
connection: "manual" | "original" | "separate";
|
|
134
|
+
availability: "working" | "paused" | "available" | "offline" | null;
|
|
135
|
+
agentName: string;
|
|
136
|
+
roomName: string;
|
|
137
|
+
lastSeenAt: number | null;
|
|
138
|
+
updatedAt: number;
|
|
139
|
+
runtime?: string | undefined;
|
|
140
|
+
model?: {
|
|
141
|
+
value: string;
|
|
142
|
+
source: "configured" | "reported";
|
|
143
|
+
} | undefined;
|
|
144
|
+
}, {
|
|
145
|
+
roomId: string;
|
|
146
|
+
createdAt: number;
|
|
147
|
+
participantId: string;
|
|
148
|
+
listingId: string;
|
|
149
|
+
contact: "questions" | "tasks";
|
|
150
|
+
owner: string;
|
|
151
|
+
topic: string;
|
|
152
|
+
connection: "manual" | "original" | "separate";
|
|
153
|
+
availability: "working" | "paused" | "available" | "offline" | null;
|
|
154
|
+
agentName: string;
|
|
155
|
+
roomName: string;
|
|
156
|
+
lastSeenAt: number | null;
|
|
157
|
+
updatedAt: number;
|
|
158
|
+
runtime?: string | undefined;
|
|
159
|
+
model?: {
|
|
160
|
+
value: string;
|
|
161
|
+
source: "configured" | "reported";
|
|
162
|
+
} | undefined;
|
|
163
|
+
}>;
|
|
164
|
+
export type ListingRecord = z.infer<typeof ListingRecord>;
|
|
165
|
+
/** A listing as the relay shows it: no room id, participant id or credential. */
|
|
166
|
+
export declare const ListingView: z.ZodObject<{
|
|
167
|
+
listingId: z.ZodString;
|
|
168
|
+
owner: z.ZodObject<{
|
|
169
|
+
handle: z.ZodString;
|
|
170
|
+
name: z.ZodOptional<z.ZodString>;
|
|
171
|
+
}, "strip", z.ZodTypeAny, {
|
|
172
|
+
handle: string;
|
|
173
|
+
name?: string | undefined;
|
|
174
|
+
}, {
|
|
175
|
+
handle: string;
|
|
176
|
+
name?: string | undefined;
|
|
177
|
+
}>;
|
|
178
|
+
agentName: z.ZodString;
|
|
179
|
+
roomName: z.ZodString;
|
|
180
|
+
topic: z.ZodString;
|
|
181
|
+
contact: z.ZodEnum<["questions", "tasks"]>;
|
|
182
|
+
connection: z.ZodEnum<["original", "separate", "manual"]>;
|
|
183
|
+
runtime: z.ZodOptional<z.ZodString>;
|
|
184
|
+
model: z.ZodOptional<z.ZodObject<{
|
|
185
|
+
value: z.ZodString;
|
|
186
|
+
source: z.ZodEnum<["configured", "reported"]>;
|
|
187
|
+
}, "strip", z.ZodTypeAny, {
|
|
188
|
+
value: string;
|
|
189
|
+
source: "configured" | "reported";
|
|
190
|
+
}, {
|
|
191
|
+
value: string;
|
|
192
|
+
source: "configured" | "reported";
|
|
193
|
+
}>>;
|
|
194
|
+
availability: z.ZodEnum<["available", "working", "paused", "offline", "unknown"]>;
|
|
195
|
+
lastSeenAt: z.ZodNullable<z.ZodNumber>;
|
|
196
|
+
/** When the agent last sent a message in its room; null when it never has. */
|
|
197
|
+
lastMessageAt: z.ZodNullable<z.ZodNumber>;
|
|
198
|
+
createdAt: z.ZodNumber;
|
|
199
|
+
updatedAt: z.ZodNumber;
|
|
200
|
+
}, "strip", z.ZodTypeAny, {
|
|
201
|
+
createdAt: number;
|
|
202
|
+
listingId: string;
|
|
203
|
+
contact: "questions" | "tasks";
|
|
204
|
+
owner: {
|
|
205
|
+
handle: string;
|
|
206
|
+
name?: string | undefined;
|
|
207
|
+
};
|
|
208
|
+
lastMessageAt: number | null;
|
|
209
|
+
topic: string;
|
|
210
|
+
connection: "manual" | "original" | "separate";
|
|
211
|
+
availability: "unknown" | "working" | "paused" | "available" | "offline";
|
|
212
|
+
agentName: string;
|
|
213
|
+
roomName: string;
|
|
214
|
+
lastSeenAt: number | null;
|
|
215
|
+
updatedAt: number;
|
|
216
|
+
runtime?: string | undefined;
|
|
217
|
+
model?: {
|
|
218
|
+
value: string;
|
|
219
|
+
source: "configured" | "reported";
|
|
220
|
+
} | undefined;
|
|
221
|
+
}, {
|
|
222
|
+
createdAt: number;
|
|
223
|
+
listingId: string;
|
|
224
|
+
contact: "questions" | "tasks";
|
|
225
|
+
owner: {
|
|
226
|
+
handle: string;
|
|
227
|
+
name?: string | undefined;
|
|
228
|
+
};
|
|
229
|
+
lastMessageAt: number | null;
|
|
230
|
+
topic: string;
|
|
231
|
+
connection: "manual" | "original" | "separate";
|
|
232
|
+
availability: "unknown" | "working" | "paused" | "available" | "offline";
|
|
233
|
+
agentName: string;
|
|
234
|
+
roomName: string;
|
|
235
|
+
lastSeenAt: number | null;
|
|
236
|
+
updatedAt: number;
|
|
237
|
+
runtime?: string | undefined;
|
|
238
|
+
model?: {
|
|
239
|
+
value: string;
|
|
240
|
+
source: "configured" | "reported";
|
|
241
|
+
} | undefined;
|
|
242
|
+
}>;
|
|
243
|
+
export type ListingView = z.infer<typeof ListingView>;
|
|
244
|
+
export declare const ListingResponse: z.ZodObject<{
|
|
245
|
+
listing: z.ZodObject<{
|
|
246
|
+
listingId: z.ZodString;
|
|
247
|
+
owner: z.ZodObject<{
|
|
248
|
+
handle: z.ZodString;
|
|
249
|
+
name: z.ZodOptional<z.ZodString>;
|
|
250
|
+
}, "strip", z.ZodTypeAny, {
|
|
251
|
+
handle: string;
|
|
252
|
+
name?: string | undefined;
|
|
253
|
+
}, {
|
|
254
|
+
handle: string;
|
|
255
|
+
name?: string | undefined;
|
|
256
|
+
}>;
|
|
257
|
+
agentName: z.ZodString;
|
|
258
|
+
roomName: z.ZodString;
|
|
259
|
+
topic: z.ZodString;
|
|
260
|
+
contact: z.ZodEnum<["questions", "tasks"]>;
|
|
261
|
+
connection: z.ZodEnum<["original", "separate", "manual"]>;
|
|
262
|
+
runtime: z.ZodOptional<z.ZodString>;
|
|
263
|
+
model: z.ZodOptional<z.ZodObject<{
|
|
264
|
+
value: z.ZodString;
|
|
265
|
+
source: z.ZodEnum<["configured", "reported"]>;
|
|
266
|
+
}, "strip", z.ZodTypeAny, {
|
|
267
|
+
value: string;
|
|
268
|
+
source: "configured" | "reported";
|
|
269
|
+
}, {
|
|
270
|
+
value: string;
|
|
271
|
+
source: "configured" | "reported";
|
|
272
|
+
}>>;
|
|
273
|
+
availability: z.ZodEnum<["available", "working", "paused", "offline", "unknown"]>;
|
|
274
|
+
lastSeenAt: z.ZodNullable<z.ZodNumber>;
|
|
275
|
+
/** When the agent last sent a message in its room; null when it never has. */
|
|
276
|
+
lastMessageAt: z.ZodNullable<z.ZodNumber>;
|
|
277
|
+
createdAt: z.ZodNumber;
|
|
278
|
+
updatedAt: z.ZodNumber;
|
|
279
|
+
}, "strip", z.ZodTypeAny, {
|
|
280
|
+
createdAt: number;
|
|
281
|
+
listingId: string;
|
|
282
|
+
contact: "questions" | "tasks";
|
|
283
|
+
owner: {
|
|
284
|
+
handle: string;
|
|
285
|
+
name?: string | undefined;
|
|
286
|
+
};
|
|
287
|
+
lastMessageAt: number | null;
|
|
288
|
+
topic: string;
|
|
289
|
+
connection: "manual" | "original" | "separate";
|
|
290
|
+
availability: "unknown" | "working" | "paused" | "available" | "offline";
|
|
291
|
+
agentName: string;
|
|
292
|
+
roomName: string;
|
|
293
|
+
lastSeenAt: number | null;
|
|
294
|
+
updatedAt: number;
|
|
295
|
+
runtime?: string | undefined;
|
|
296
|
+
model?: {
|
|
297
|
+
value: string;
|
|
298
|
+
source: "configured" | "reported";
|
|
299
|
+
} | undefined;
|
|
300
|
+
}, {
|
|
301
|
+
createdAt: number;
|
|
302
|
+
listingId: string;
|
|
303
|
+
contact: "questions" | "tasks";
|
|
304
|
+
owner: {
|
|
305
|
+
handle: string;
|
|
306
|
+
name?: string | undefined;
|
|
307
|
+
};
|
|
308
|
+
lastMessageAt: number | null;
|
|
309
|
+
topic: string;
|
|
310
|
+
connection: "manual" | "original" | "separate";
|
|
311
|
+
availability: "unknown" | "working" | "paused" | "available" | "offline";
|
|
312
|
+
agentName: string;
|
|
313
|
+
roomName: string;
|
|
314
|
+
lastSeenAt: number | null;
|
|
315
|
+
updatedAt: number;
|
|
316
|
+
runtime?: string | undefined;
|
|
317
|
+
model?: {
|
|
318
|
+
value: string;
|
|
319
|
+
source: "configured" | "reported";
|
|
320
|
+
} | undefined;
|
|
321
|
+
}>;
|
|
322
|
+
}, "strip", z.ZodTypeAny, {
|
|
323
|
+
listing: {
|
|
324
|
+
createdAt: number;
|
|
325
|
+
listingId: string;
|
|
326
|
+
contact: "questions" | "tasks";
|
|
327
|
+
owner: {
|
|
328
|
+
handle: string;
|
|
329
|
+
name?: string | undefined;
|
|
330
|
+
};
|
|
331
|
+
lastMessageAt: number | null;
|
|
332
|
+
topic: string;
|
|
333
|
+
connection: "manual" | "original" | "separate";
|
|
334
|
+
availability: "unknown" | "working" | "paused" | "available" | "offline";
|
|
335
|
+
agentName: string;
|
|
336
|
+
roomName: string;
|
|
337
|
+
lastSeenAt: number | null;
|
|
338
|
+
updatedAt: number;
|
|
339
|
+
runtime?: string | undefined;
|
|
340
|
+
model?: {
|
|
341
|
+
value: string;
|
|
342
|
+
source: "configured" | "reported";
|
|
343
|
+
} | undefined;
|
|
344
|
+
};
|
|
345
|
+
}, {
|
|
346
|
+
listing: {
|
|
347
|
+
createdAt: number;
|
|
348
|
+
listingId: string;
|
|
349
|
+
contact: "questions" | "tasks";
|
|
350
|
+
owner: {
|
|
351
|
+
handle: string;
|
|
352
|
+
name?: string | undefined;
|
|
353
|
+
};
|
|
354
|
+
lastMessageAt: number | null;
|
|
355
|
+
topic: string;
|
|
356
|
+
connection: "manual" | "original" | "separate";
|
|
357
|
+
availability: "unknown" | "working" | "paused" | "available" | "offline";
|
|
358
|
+
agentName: string;
|
|
359
|
+
roomName: string;
|
|
360
|
+
lastSeenAt: number | null;
|
|
361
|
+
updatedAt: number;
|
|
362
|
+
runtime?: string | undefined;
|
|
363
|
+
model?: {
|
|
364
|
+
value: string;
|
|
365
|
+
source: "configured" | "reported";
|
|
366
|
+
} | undefined;
|
|
367
|
+
};
|
|
368
|
+
}>;
|
|
369
|
+
export type ListingResponse = z.infer<typeof ListingResponse>;
|
|
370
|
+
/** Availability as of `now`: no heartbeat yet is unknown, none for three minutes is offline. */
|
|
371
|
+
export declare function listingAvailability(listing: ListingRecord, now: number): ListingAvailability;
|
|
372
|
+
/** What a reader's view of a listing needs beyond the record: the time, the agent's last message and the owner's name. */
|
|
373
|
+
export type ListingViewContext = {
|
|
374
|
+
now: number;
|
|
375
|
+
lastMessageAt: number | null;
|
|
376
|
+
ownerName?: string | undefined;
|
|
377
|
+
};
|
|
378
|
+
/** The record as readers see it. */
|
|
379
|
+
export declare function toListingView(listing: ListingRecord, { now, lastMessageAt, ownerName }: ListingViewContext): ListingView;
|
|
380
|
+
//# sourceMappingURL=directory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"directory.d.ts","sourceRoot":"","sources":["../src/directory.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AAKtB,sFAAsF;AACtF,eAAO,MAAM,wBAAwB,QAAa,CAAC;AAEnD,eAAO,MAAM,wBAAwB,MAAM,CAAC;AAE5C,mJAAmJ;AACnJ,eAAO,MAAM,iBAAiB,+CAA6C,CAAC;AAC5E,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAElE,yHAAyH;AACzH,eAAO,MAAM,oBAAoB,0DAAwD,CAAC;AAC1F,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAExE,uGAAuG;AACvG,eAAO,MAAM,mBAAmB,qEAAmE,CAAC;AACpG,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KA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;;;EAOnB,CAAC;AAChE,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC;AAE9D,gGAAgG;AAChG,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,aAAa,EAAE,GAAG,EAAE,MAAM,GAAG,mBAAmB,CAK5F;AAED,0HAA0H;AAC1H,MAAM,MAAM,kBAAkB,GAAG;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAAC,CAAC;AAE7G,oCAAoC;AACpC,wBAAgB,aAAa,CAAC,OAAO,EAAE,aAAa,EAAE,EAAC,GAAG,EAAE,aAAa,EAAE,SAAS,EAAC,EAAE,kBAAkB,GAAG,WAAW,CAGtH"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
//! The agent directory: an agent a member shares from a room, so colleagues on the
|
|
2
|
+
//! same relay can find it. A listing names no room id, participant id or credential
|
|
3
|
+
//! to anyone reading it.
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
import { ListingId, ParticipantId, RoomId } from './ids.js';
|
|
6
|
+
import { ListingContact, MemberHandle } from './records.js';
|
|
7
|
+
/** How long a listing stays as its last heartbeat said before it reads as offline. */
|
|
8
|
+
export const LISTING_OFFLINE_AFTER_MS = 3 * 60_000;
|
|
9
|
+
export const MAX_LISTING_TOPIC_LENGTH = 120;
|
|
10
|
+
/** Which conversation answers a contact: the one that did the work, a separate one in the same project, or whenever the session reads the room. */
|
|
11
|
+
export const ListingConnection = z.enum(['original', 'separate', 'manual']);
|
|
12
|
+
/** What a heartbeat may report; `offline` is a stopping receiver's last word, so readers need not wait three minutes. */
|
|
13
|
+
export const ReportedAvailability = z.enum(['available', 'working', 'paused', 'offline']);
|
|
14
|
+
/** What a reader sees: the last report, `offline` once heartbeats stop, `unknown` before the first. */
|
|
15
|
+
export const ListingAvailability = z.enum(['available', 'working', 'paused', 'offline', 'unknown']);
|
|
16
|
+
/** The model behind the agent, and whether it is the receiver's configuration or what the runtime last reported. */
|
|
17
|
+
export const ListingModel = z.object({
|
|
18
|
+
value: z.string().trim().min(1).max(128),
|
|
19
|
+
source: z.enum(['configured', 'reported'])
|
|
20
|
+
});
|
|
21
|
+
/** Typed or templated by a person, never generated: one line of plain text. */
|
|
22
|
+
export const ListingTopic = z.string().trim().min(1).max(MAX_LISTING_TOPIC_LENGTH).regex(/^[^\p{Cc}]*$/u, 'a topic is one line of plain text');
|
|
23
|
+
/** `POST /v1/directory/listings`, with the agent's credential and the owner's personal token. */
|
|
24
|
+
export const ShareListingRequest = z.object({
|
|
25
|
+
roomId: RoomId,
|
|
26
|
+
topic: ListingTopic,
|
|
27
|
+
contact: ListingContact.default('questions'),
|
|
28
|
+
connection: ListingConnection,
|
|
29
|
+
model: ListingModel.optional(),
|
|
30
|
+
runtime: z.string().trim().min(1).max(32).optional()
|
|
31
|
+
});
|
|
32
|
+
/** `PUT /v1/directory/listings/:listingId/presence`, the heartbeat. */
|
|
33
|
+
export const ListingPresenceRequest = z.object({
|
|
34
|
+
availability: ReportedAvailability,
|
|
35
|
+
model: ListingModel.optional(),
|
|
36
|
+
connection: ListingConnection.optional()
|
|
37
|
+
});
|
|
38
|
+
/** What a relay stores for one shared agent: one per room and participant. */
|
|
39
|
+
export const ListingRecord = z.object({
|
|
40
|
+
listingId: ListingId,
|
|
41
|
+
roomId: RoomId,
|
|
42
|
+
participantId: ParticipantId,
|
|
43
|
+
owner: MemberHandle,
|
|
44
|
+
/** The agent's and the room's names when last shared or heard from. */
|
|
45
|
+
agentName: z.string(),
|
|
46
|
+
roomName: z.string(),
|
|
47
|
+
topic: ListingTopic,
|
|
48
|
+
contact: ListingContact,
|
|
49
|
+
connection: ListingConnection,
|
|
50
|
+
runtime: z.string().optional(),
|
|
51
|
+
model: ListingModel.optional(),
|
|
52
|
+
/** The last heartbeat's report; null before the first. */
|
|
53
|
+
availability: ReportedAvailability.nullable(),
|
|
54
|
+
lastSeenAt: z.number().int().nonnegative().nullable(),
|
|
55
|
+
createdAt: z.number().int().nonnegative(),
|
|
56
|
+
updatedAt: z.number().int().nonnegative()
|
|
57
|
+
});
|
|
58
|
+
/** A listing as the relay shows it: no room id, participant id or credential. */
|
|
59
|
+
export const ListingView = z.object({
|
|
60
|
+
listingId: ListingId,
|
|
61
|
+
owner: z.object({ handle: MemberHandle, name: z.string().optional() }),
|
|
62
|
+
agentName: z.string(),
|
|
63
|
+
roomName: z.string(),
|
|
64
|
+
topic: z.string(),
|
|
65
|
+
contact: ListingContact,
|
|
66
|
+
connection: ListingConnection,
|
|
67
|
+
runtime: z.string().optional(),
|
|
68
|
+
model: ListingModel.optional(),
|
|
69
|
+
availability: ListingAvailability,
|
|
70
|
+
lastSeenAt: z.number().int().nonnegative().nullable(),
|
|
71
|
+
/** When the agent last sent a message in its room; null when it never has. */
|
|
72
|
+
lastMessageAt: z.number().int().nonnegative().nullable(),
|
|
73
|
+
createdAt: z.number().int().nonnegative(),
|
|
74
|
+
updatedAt: z.number().int().nonnegative()
|
|
75
|
+
});
|
|
76
|
+
export const ListingResponse = z.object({ listing: ListingView });
|
|
77
|
+
/** Availability as of `now`: no heartbeat yet is unknown, none for three minutes is offline. */
|
|
78
|
+
export function listingAvailability(listing, now) {
|
|
79
|
+
if (listing.lastSeenAt === null || listing.availability === null) {
|
|
80
|
+
return 'unknown';
|
|
81
|
+
}
|
|
82
|
+
return now - listing.lastSeenAt >= LISTING_OFFLINE_AFTER_MS ? 'offline' : listing.availability;
|
|
83
|
+
}
|
|
84
|
+
/** The record as readers see it. */
|
|
85
|
+
export function toListingView(listing, { now, lastMessageAt, ownerName }) {
|
|
86
|
+
const { listingId, owner, agentName, roomName, topic, contact, connection, runtime, model, lastSeenAt, createdAt, updatedAt } = listing;
|
|
87
|
+
return { listingId, owner: { handle: owner, ...(ownerName ? { name: ownerName } : {}) }, agentName, roomName, topic, contact, connection, ...(runtime ? { runtime } : {}), ...(model ? { model } : {}), availability: listingAvailability(listing, now), lastSeenAt, lastMessageAt, createdAt, updatedAt };
|
|
88
|
+
}
|
|
89
|
+
//# sourceMappingURL=directory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"directory.js","sourceRoot":"","sources":["../src/directory.ts"],"names":[],"mappings":"AAAA,mFAAmF;AACnF,oFAAoF;AACpF,yBAAyB;AAEzB,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AAEtB,OAAO,EAAC,SAAS,EAAE,aAAa,EAAE,MAAM,EAAC,MAAM,UAAU,CAAC;AAC1D,OAAO,EAAC,cAAc,EAAE,YAAY,EAAC,MAAM,cAAc,CAAC;AAE1D,sFAAsF;AACtF,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,GAAG,MAAM,CAAC;AAEnD,MAAM,CAAC,MAAM,wBAAwB,GAAG,GAAG,CAAC;AAE5C,mJAAmJ;AACnJ,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE,UAAU,EAAE,QAAQ,CAAC,CAAC,CAAC;AAG5E,yHAAyH;AACzH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC,CAAC;AAG1F,uGAAuG;AACvG,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC;AAGpG,oHAAoH;AACpH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,CAAC,MAAM,CAAC;IACjC,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC;IACxC,MAAM,EAAE,CAA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K,CAAC,CAAC,CAAC,EAAC,KAAK,EAAC,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,YAAY,EAAE,mBAAmB,CAAC,OAAO,EAAE,GAAG,CAAC,EAAE,UAAU,EAAE,aAAa,EAAE,SAAS,EAAE,SAAS,EAAC,CAAC;AACrS,CAAC"}
|
package/dist/events.d.ts
CHANGED
|
@@ -1144,12 +1144,12 @@ export declare const EventBody: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
|
|
|
1144
1144
|
source: z.ZodEnum<["profile", "room"]>;
|
|
1145
1145
|
}, "strip", z.ZodTypeAny, {
|
|
1146
1146
|
name: string;
|
|
1147
|
-
source: "
|
|
1147
|
+
source: "room" | "profile";
|
|
1148
1148
|
participantId: string;
|
|
1149
1149
|
previousName: string;
|
|
1150
1150
|
}, {
|
|
1151
1151
|
name: string;
|
|
1152
|
-
source: "
|
|
1152
|
+
source: "room" | "profile";
|
|
1153
1153
|
participantId: string;
|
|
1154
1154
|
previousName: string;
|
|
1155
1155
|
}>;
|
|
@@ -1157,7 +1157,7 @@ export declare const EventBody: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
|
|
|
1157
1157
|
type: "participant.renamed";
|
|
1158
1158
|
payload: {
|
|
1159
1159
|
name: string;
|
|
1160
|
-
source: "
|
|
1160
|
+
source: "room" | "profile";
|
|
1161
1161
|
participantId: string;
|
|
1162
1162
|
previousName: string;
|
|
1163
1163
|
};
|
|
@@ -1165,7 +1165,7 @@ export declare const EventBody: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
|
|
|
1165
1165
|
type: "participant.renamed";
|
|
1166
1166
|
payload: {
|
|
1167
1167
|
name: string;
|
|
1168
|
-
source: "
|
|
1168
|
+
source: "room" | "profile";
|
|
1169
1169
|
participantId: string;
|
|
1170
1170
|
previousName: string;
|
|
1171
1171
|
};
|
|
@@ -2657,12 +2657,12 @@ export declare const RoomEvent: z.ZodIntersection<z.ZodObject<{
|
|
|
2657
2657
|
source: z.ZodEnum<["profile", "room"]>;
|
|
2658
2658
|
}, "strip", z.ZodTypeAny, {
|
|
2659
2659
|
name: string;
|
|
2660
|
-
source: "
|
|
2660
|
+
source: "room" | "profile";
|
|
2661
2661
|
participantId: string;
|
|
2662
2662
|
previousName: string;
|
|
2663
2663
|
}, {
|
|
2664
2664
|
name: string;
|
|
2665
|
-
source: "
|
|
2665
|
+
source: "room" | "profile";
|
|
2666
2666
|
participantId: string;
|
|
2667
2667
|
previousName: string;
|
|
2668
2668
|
}>;
|
|
@@ -2670,7 +2670,7 @@ export declare const RoomEvent: z.ZodIntersection<z.ZodObject<{
|
|
|
2670
2670
|
type: "participant.renamed";
|
|
2671
2671
|
payload: {
|
|
2672
2672
|
name: string;
|
|
2673
|
-
source: "
|
|
2673
|
+
source: "room" | "profile";
|
|
2674
2674
|
participantId: string;
|
|
2675
2675
|
previousName: string;
|
|
2676
2676
|
};
|
|
@@ -2678,7 +2678,7 @@ export declare const RoomEvent: z.ZodIntersection<z.ZodObject<{
|
|
|
2678
2678
|
type: "participant.renamed";
|
|
2679
2679
|
payload: {
|
|
2680
2680
|
name: string;
|
|
2681
|
-
source: "
|
|
2681
|
+
source: "room" | "profile";
|
|
2682
2682
|
participantId: string;
|
|
2683
2683
|
previousName: string;
|
|
2684
2684
|
};
|