@adminide-stack/clock-tik-browser 12.0.35 → 12.0.36
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/lib/pages/Home/__tests__/connectors.test.d.ts +2 -0
- package/lib/pages/Home/__tests__/connectors.test.d.ts.map +1 -0
- package/lib/pages/Home/__tests__/history.test.d.ts +2 -0
- package/lib/pages/Home/__tests__/history.test.d.ts.map +1 -0
- package/lib/pages/Home/chat/ChoresChat.d.ts.map +1 -1
- package/lib/pages/Home/chat/ChoresChat.js +163 -32
- package/lib/pages/Home/chat/ChoresChat.js.map +1 -1
- package/lib/pages/Home/chat/ChoresPanel.d.ts +10 -1
- package/lib/pages/Home/chat/ChoresPanel.d.ts.map +1 -1
- package/lib/pages/Home/chat/ChoresPanel.js +24 -17
- package/lib/pages/Home/chat/ChoresPanel.js.map +1 -1
- package/lib/pages/Home/chat/ConnectorsPanel.d.ts +23 -0
- package/lib/pages/Home/chat/ConnectorsPanel.d.ts.map +1 -0
- package/lib/pages/Home/chat/ConnectorsPanel.js +132 -0
- package/lib/pages/Home/chat/ConnectorsPanel.js.map +1 -0
- package/lib/pages/Home/chat/HistoryPanel.d.ts +27 -0
- package/lib/pages/Home/chat/HistoryPanel.d.ts.map +1 -0
- package/lib/pages/Home/chat/HistoryPanel.js +234 -0
- package/lib/pages/Home/chat/HistoryPanel.js.map +1 -0
- package/lib/pages/Home/chat/chatTheme.d.ts.map +1 -1
- package/lib/pages/Home/chat/chatTheme.js +249 -7
- package/lib/pages/Home/chat/chatTheme.js.map +1 -1
- package/lib/pages/Home/chat/connectors.d.ts +37 -0
- package/lib/pages/Home/chat/connectors.d.ts.map +1 -0
- package/lib/pages/Home/chat/connectors.js +73 -0
- package/lib/pages/Home/chat/connectors.js.map +1 -0
- package/lib/pages/Home/chat/history.d.ts +51 -0
- package/lib/pages/Home/chat/history.d.ts.map +1 -0
- package/lib/pages/Home/chat/history.js +186 -0
- package/lib/pages/Home/chat/history.js.map +1 -0
- package/lib/pages/Home/chat/lucy.d.ts.map +1 -1
- package/lib/pages/Home/chat/lucy.js +1 -1
- package/lib/pages/Home/chat/lucy.js.map +1 -1
- package/lib/pages/Home/chat/thread.d.ts +2 -0
- package/lib/pages/Home/chat/thread.d.ts.map +1 -1
- package/lib/pages/Home/chat/thread.js +4 -3
- package/lib/pages/Home/chat/thread.js.map +1 -1
- package/lib/pages/Home/chat/tour/tourSteps.d.ts +4 -3
- package/lib/pages/Home/chat/tour/tourSteps.d.ts.map +1 -1
- package/lib/pages/Home/chat/tour/tourSteps.js +23 -3
- package/lib/pages/Home/chat/tour/tourSteps.js.map +1 -1
- package/lib/pages/Home/chat/useChores.d.ts +5 -0
- package/lib/pages/Home/chat/useChores.d.ts.map +1 -1
- package/lib/pages/Home/chat/useChores.js +4 -1
- package/lib/pages/Home/chat/useChores.js.map +1 -1
- package/package.json +2 -2
|
@@ -203,6 +203,56 @@ import {jsx}from'react/jsx-runtime';const CHAT_CSS = `
|
|
|
203
203
|
font-weight: 500;
|
|
204
204
|
color: hsl(var(--muted-foreground));
|
|
205
205
|
}
|
|
206
|
+
/* Under the starters: the apps Lucy can use (ConnectorsPanel), and iMessage, side by side where they
|
|
207
|
+
fit. The apps pill wears the marks of what it connects. */
|
|
208
|
+
.cbh-chat .cbh-chat-ways {
|
|
209
|
+
display: flex;
|
|
210
|
+
flex-wrap: wrap;
|
|
211
|
+
justify-content: center;
|
|
212
|
+
gap: 8px 10px;
|
|
213
|
+
margin-top: 18px;
|
|
214
|
+
}
|
|
215
|
+
.cbh-chat .cbh-chat-ways .cbh-chat-imsg {
|
|
216
|
+
margin-top: 0;
|
|
217
|
+
}
|
|
218
|
+
.cbh-chat .cbh-chat-apps {
|
|
219
|
+
display: inline-flex;
|
|
220
|
+
align-items: center;
|
|
221
|
+
gap: 8px;
|
|
222
|
+
height: 40px;
|
|
223
|
+
padding: 0 14px 0 8px;
|
|
224
|
+
border: 0;
|
|
225
|
+
border-radius: 999px;
|
|
226
|
+
background: hsl(var(--card));
|
|
227
|
+
color: hsl(var(--foreground));
|
|
228
|
+
font: inherit;
|
|
229
|
+
font-size: 13.5px;
|
|
230
|
+
font-weight: 600;
|
|
231
|
+
white-space: nowrap;
|
|
232
|
+
cursor: pointer;
|
|
233
|
+
box-shadow: 0 0 0 1px hsl(var(--border)), 0 6px 18px -12px rgba(48, 28, 8, 0.35);
|
|
234
|
+
transition: transform 0.2s ease, box-shadow 0.25s ease;
|
|
235
|
+
}
|
|
236
|
+
.cbh-chat .cbh-chat-apps:hover {
|
|
237
|
+
transform: translateY(-1px);
|
|
238
|
+
box-shadow: 0 0 0 1px rgba(255, 90, 0, 0.35), 0 12px 24px -12px rgba(255, 90, 0, 0.55);
|
|
239
|
+
}
|
|
240
|
+
.cbh-chat .cbh-chat-apps:focus-visible {
|
|
241
|
+
outline: 2px solid hsl(var(--ring));
|
|
242
|
+
outline-offset: 2px;
|
|
243
|
+
}
|
|
244
|
+
.cbh-chat .cbh-chat-apps-logos {
|
|
245
|
+
display: inline-flex;
|
|
246
|
+
}
|
|
247
|
+
.cbh-chat .cbh-chat-apps-logos > span {
|
|
248
|
+
width: 24px;
|
|
249
|
+
height: 24px;
|
|
250
|
+
border-radius: 999px;
|
|
251
|
+
box-shadow: 0 0 0 2px hsl(var(--card)), inset 0 0 0 1px hsl(var(--border));
|
|
252
|
+
}
|
|
253
|
+
.cbh-chat .cbh-chat-apps-logos > span + span {
|
|
254
|
+
margin-left: -7px;
|
|
255
|
+
}
|
|
206
256
|
/* A phone: the welcome fits the chat without scrolling. The kit opens an empty chat scrolled to its
|
|
207
257
|
foot, so a welcome taller than the chat starts with Lucy's greeting cut off above the top. The
|
|
208
258
|
starters become one-line rows (their full wording is still read out) and the halo is smaller. */
|
|
@@ -262,17 +312,25 @@ import {jsx}from'react/jsx-runtime';const CHAT_CSS = `
|
|
|
262
312
|
clip: rect(0 0 0 0);
|
|
263
313
|
white-space: nowrap;
|
|
264
314
|
}
|
|
265
|
-
.cbh-chat .cbh-chat-imsg
|
|
315
|
+
.cbh-chat .cbh-chat-imsg,
|
|
316
|
+
.cbh-chat .cbh-chat-ways {
|
|
266
317
|
margin-top: 14px;
|
|
267
318
|
}
|
|
268
319
|
/* "Prefer texting?" does not fit beside it on one line. */
|
|
269
320
|
.cbh-chat .cbh-chat-imsg span {
|
|
270
321
|
display: none;
|
|
271
322
|
}
|
|
323
|
+
/* One pill fits beside nothing here, and a second row would scroll the welcome: iMessage keeps
|
|
324
|
+
the row, and the apps pill joins it only in a chat tall enough (below). The account menu
|
|
325
|
+
always has the apps. */
|
|
326
|
+
.cbh-chat .cbh-chat-apps {
|
|
327
|
+
display: none;
|
|
328
|
+
}
|
|
272
329
|
}
|
|
273
330
|
/* A short chat (a phone with the browser's bars showing, a small phone): what the welcome can do
|
|
274
331
|
without goes before it would scroll - the halo (the header carries Lucy's mark), then the line
|
|
275
|
-
under the question, then the greeting and the
|
|
332
|
+
under the question, then the greeting and the pills under the starters (the header has iMessage
|
|
333
|
+
too, and the account menu has the apps).
|
|
276
334
|
Measured on chat-pro's scroll area, so it is the room the welcome really has. */
|
|
277
335
|
.cbh-chat .ym-hide-scrollbar:has(.cbh-chat-welcome) {
|
|
278
336
|
container: cbh-chat-area / size;
|
|
@@ -289,10 +347,17 @@ import {jsx}from'react/jsx-runtime';const CHAT_CSS = `
|
|
|
289
347
|
}
|
|
290
348
|
@container cbh-chat-area (max-height: 430px) {
|
|
291
349
|
.cbh-chat .cbh-chat-hello,
|
|
292
|
-
.cbh-chat .cbh-chat-imsg
|
|
350
|
+
.cbh-chat .cbh-chat-imsg,
|
|
351
|
+
.cbh-chat .cbh-chat-ways {
|
|
293
352
|
display: none;
|
|
294
353
|
}
|
|
295
354
|
}
|
|
355
|
+
/* A phone's chat tall enough for the apps pill's own row (the welcome then measures about 640px). */
|
|
356
|
+
@container cbh-chat-area (min-height: 690px) {
|
|
357
|
+
.cbh-chat .cbh-chat-apps {
|
|
358
|
+
display: inline-flex;
|
|
359
|
+
}
|
|
360
|
+
}
|
|
296
361
|
/* what Lucy made: videos and sound clips under her reply (media.ts); images are the kit's own figures */
|
|
297
362
|
.cbh-chat .cbh-chat-media {
|
|
298
363
|
display: grid;
|
|
@@ -1079,9 +1144,9 @@ import {jsx}from'react/jsx-runtime';const CHAT_CSS = `
|
|
|
1079
1144
|
text-align: center;
|
|
1080
1145
|
font-variant-numeric: tabular-nums;
|
|
1081
1146
|
}
|
|
1082
|
-
/*
|
|
1083
|
-
still read it). */
|
|
1084
|
-
@media (max-width:
|
|
1147
|
+
/* Narrow phones: New chat keeps its icon and gives its word up to Lucy's name, which the header's
|
|
1148
|
+
History beside it would squeeze to a letter (screen readers still read it). */
|
|
1149
|
+
@media (max-width: 389px) {
|
|
1085
1150
|
.cbh-chat .cbh-chat-newchat {
|
|
1086
1151
|
position: absolute;
|
|
1087
1152
|
width: 1px;
|
|
@@ -1317,6 +1382,182 @@ import {jsx}from'react/jsx-runtime';const CHAT_CSS = `
|
|
|
1317
1382
|
.cbh-chat .cbh-chores-empty .cbh-chores-icon {
|
|
1318
1383
|
margin-bottom: 6px;
|
|
1319
1384
|
}
|
|
1385
|
+
/* The chat's history (HistoryPanel): the same sheet and card, holding past chats. A row keeps room
|
|
1386
|
+
at its end for its delete button, which a mouse finds on hover; a question about a row (delete it,
|
|
1387
|
+
or stop Lucy to open it) takes its place, or sits under it. */
|
|
1388
|
+
.cbh-chat .cbh-history-line {
|
|
1389
|
+
position: relative;
|
|
1390
|
+
}
|
|
1391
|
+
.cbh-chat .cbh-history-line .cbh-chores-row {
|
|
1392
|
+
padding-right: 48px;
|
|
1393
|
+
}
|
|
1394
|
+
.cbh-chat .cbh-history-delete {
|
|
1395
|
+
position: absolute;
|
|
1396
|
+
top: 50%;
|
|
1397
|
+
right: 8px;
|
|
1398
|
+
display: grid;
|
|
1399
|
+
place-items: center;
|
|
1400
|
+
width: 32px;
|
|
1401
|
+
height: 32px;
|
|
1402
|
+
border: 0;
|
|
1403
|
+
border-radius: 999px;
|
|
1404
|
+
background: transparent;
|
|
1405
|
+
color: hsl(var(--muted-foreground));
|
|
1406
|
+
cursor: pointer;
|
|
1407
|
+
transform: translateY(-50%);
|
|
1408
|
+
}
|
|
1409
|
+
.cbh-chat .cbh-history-delete:hover {
|
|
1410
|
+
background: hsl(var(--background));
|
|
1411
|
+
color: #b42318;
|
|
1412
|
+
}
|
|
1413
|
+
@media (hover: hover) {
|
|
1414
|
+
.cbh-chat .cbh-history-delete {
|
|
1415
|
+
opacity: 0;
|
|
1416
|
+
}
|
|
1417
|
+
.cbh-chat .cbh-history-line:hover .cbh-history-delete,
|
|
1418
|
+
.cbh-chat .cbh-history-line:focus-within .cbh-history-delete {
|
|
1419
|
+
opacity: 1;
|
|
1420
|
+
}
|
|
1421
|
+
}
|
|
1422
|
+
.cbh-chat .cbh-history-ask {
|
|
1423
|
+
margin: 2px 0 6px;
|
|
1424
|
+
padding: 12px;
|
|
1425
|
+
border: 1px solid hsl(var(--border));
|
|
1426
|
+
border-radius: 14px;
|
|
1427
|
+
background: hsl(var(--background));
|
|
1428
|
+
}
|
|
1429
|
+
.cbh-chat .cbh-history-ask p {
|
|
1430
|
+
margin: 0;
|
|
1431
|
+
font-size: 13px;
|
|
1432
|
+
color: hsl(var(--muted-foreground));
|
|
1433
|
+
}
|
|
1434
|
+
.cbh-chat .cbh-history-ask b {
|
|
1435
|
+
display: block;
|
|
1436
|
+
margin-bottom: 2px;
|
|
1437
|
+
overflow: hidden;
|
|
1438
|
+
white-space: nowrap;
|
|
1439
|
+
text-overflow: ellipsis;
|
|
1440
|
+
font-size: 14px;
|
|
1441
|
+
font-weight: 600;
|
|
1442
|
+
color: hsl(var(--foreground));
|
|
1443
|
+
}
|
|
1444
|
+
.cbh-chat .cbh-history-ask-actions {
|
|
1445
|
+
display: flex;
|
|
1446
|
+
justify-content: flex-end;
|
|
1447
|
+
gap: 6px;
|
|
1448
|
+
margin-top: 10px;
|
|
1449
|
+
}
|
|
1450
|
+
.cbh-chat .cbh-history-ask-actions button {
|
|
1451
|
+
padding: 8px 12px;
|
|
1452
|
+
border: 0;
|
|
1453
|
+
border-radius: 10px;
|
|
1454
|
+
background: transparent;
|
|
1455
|
+
color: hsl(var(--muted-foreground));
|
|
1456
|
+
font: inherit;
|
|
1457
|
+
font-size: 13.5px;
|
|
1458
|
+
font-weight: 500;
|
|
1459
|
+
cursor: pointer;
|
|
1460
|
+
}
|
|
1461
|
+
.cbh-chat .cbh-history-ask-actions button:hover {
|
|
1462
|
+
background: hsl(var(--muted));
|
|
1463
|
+
color: hsl(var(--foreground));
|
|
1464
|
+
}
|
|
1465
|
+
.cbh-chat .cbh-history-ask-actions .cbh-history-go,
|
|
1466
|
+
.cbh-chat .cbh-history-ask-actions .cbh-history-go:hover {
|
|
1467
|
+
background: hsl(var(--primary));
|
|
1468
|
+
color: hsl(var(--primary-foreground));
|
|
1469
|
+
}
|
|
1470
|
+
.cbh-chat .cbh-history-ask-actions .cbh-history-danger,
|
|
1471
|
+
.cbh-chat .cbh-history-ask-actions .cbh-history-danger:hover {
|
|
1472
|
+
background: #b42318;
|
|
1473
|
+
color: #fff;
|
|
1474
|
+
}
|
|
1475
|
+
.cbh-chat .cbh-history-ask-actions .cbh-history-go:hover,
|
|
1476
|
+
.cbh-chat .cbh-history-ask-actions .cbh-history-danger:hover {
|
|
1477
|
+
opacity: 0.9;
|
|
1478
|
+
}
|
|
1479
|
+
.cbh-chat .cbh-history-delete:focus-visible,
|
|
1480
|
+
.cbh-chat .cbh-history-ask-actions button:focus-visible {
|
|
1481
|
+
outline: 2px solid hsl(var(--ring));
|
|
1482
|
+
outline-offset: 2px;
|
|
1483
|
+
}
|
|
1484
|
+
/* Connect your apps (ConnectorsPanel): the same sheet and card. An app shows its own mark on a white
|
|
1485
|
+
tile; each row ends in the link that connects it on Yantra, and what Lucy does with it may take
|
|
1486
|
+
two lines. */
|
|
1487
|
+
.cbh-chat .cbh-apps-logo {
|
|
1488
|
+
flex: none;
|
|
1489
|
+
display: grid;
|
|
1490
|
+
place-items: center;
|
|
1491
|
+
width: 34px;
|
|
1492
|
+
height: 34px;
|
|
1493
|
+
border-radius: 11px;
|
|
1494
|
+
background: #fff;
|
|
1495
|
+
box-shadow: inset 0 0 0 1px hsl(var(--border));
|
|
1496
|
+
}
|
|
1497
|
+
.cbh-chat .cbh-apps-row {
|
|
1498
|
+
display: flex;
|
|
1499
|
+
align-items: center;
|
|
1500
|
+
gap: 12px;
|
|
1501
|
+
padding: 10px 8px;
|
|
1502
|
+
}
|
|
1503
|
+
.cbh-chat .cbh-apps .cbh-chores-row-text small {
|
|
1504
|
+
overflow: visible;
|
|
1505
|
+
white-space: normal;
|
|
1506
|
+
text-overflow: clip;
|
|
1507
|
+
}
|
|
1508
|
+
.cbh-chat .cbh-apps-connect {
|
|
1509
|
+
flex: none;
|
|
1510
|
+
min-width: 76px;
|
|
1511
|
+
padding: 7px 14px;
|
|
1512
|
+
border-radius: 999px;
|
|
1513
|
+
background: hsl(var(--primary));
|
|
1514
|
+
color: hsl(var(--primary-foreground));
|
|
1515
|
+
font-size: 13px;
|
|
1516
|
+
font-weight: 600;
|
|
1517
|
+
text-align: center;
|
|
1518
|
+
text-decoration: none;
|
|
1519
|
+
}
|
|
1520
|
+
.cbh-chat .cbh-apps-connect[data-group='saved'] {
|
|
1521
|
+
background: hsl(var(--card));
|
|
1522
|
+
color: hsl(var(--foreground));
|
|
1523
|
+
box-shadow: inset 0 0 0 1px hsl(var(--border));
|
|
1524
|
+
}
|
|
1525
|
+
.cbh-chat .cbh-apps-connect:hover {
|
|
1526
|
+
opacity: 0.9;
|
|
1527
|
+
}
|
|
1528
|
+
.cbh-chat .cbh-apps-connect[data-group='saved']:hover {
|
|
1529
|
+
opacity: 1;
|
|
1530
|
+
background: hsl(var(--muted));
|
|
1531
|
+
}
|
|
1532
|
+
.cbh-chat .cbh-apps-all {
|
|
1533
|
+
display: flex;
|
|
1534
|
+
align-items: center;
|
|
1535
|
+
gap: 10px;
|
|
1536
|
+
margin: 8px 8px 0;
|
|
1537
|
+
padding: 12px 14px;
|
|
1538
|
+
border: 1px dashed hsl(var(--border));
|
|
1539
|
+
border-radius: 14px;
|
|
1540
|
+
color: hsl(var(--foreground));
|
|
1541
|
+
font-size: 13.5px;
|
|
1542
|
+
font-weight: 600;
|
|
1543
|
+
text-decoration: none;
|
|
1544
|
+
}
|
|
1545
|
+
.cbh-chat .cbh-apps-all span {
|
|
1546
|
+
flex: 1;
|
|
1547
|
+
}
|
|
1548
|
+
.cbh-chat .cbh-apps-all:hover {
|
|
1549
|
+
background: hsl(var(--muted));
|
|
1550
|
+
}
|
|
1551
|
+
.cbh-chat .cbh-apps-note {
|
|
1552
|
+
margin: 10px 8px 2px;
|
|
1553
|
+
font-size: 12px;
|
|
1554
|
+
color: hsl(var(--muted-foreground));
|
|
1555
|
+
}
|
|
1556
|
+
.cbh-chat .cbh-apps-connect:focus-visible,
|
|
1557
|
+
.cbh-chat .cbh-apps-all:focus-visible {
|
|
1558
|
+
outline: 2px solid hsl(var(--ring));
|
|
1559
|
+
outline-offset: 2px;
|
|
1560
|
+
}
|
|
1320
1561
|
/* one chore, opened */
|
|
1321
1562
|
.cbh-chat .cbh-chores-detail {
|
|
1322
1563
|
padding: 0 8px 4px;
|
|
@@ -1529,7 +1770,8 @@ import {jsx}from'react/jsx-runtime';const CHAT_CSS = `
|
|
|
1529
1770
|
transition: none;
|
|
1530
1771
|
}
|
|
1531
1772
|
.cbh-chat .cbh-chat-starter,
|
|
1532
|
-
.cbh-chat .cbh-chat-imsg
|
|
1773
|
+
.cbh-chat .cbh-chat-imsg,
|
|
1774
|
+
.cbh-chat .cbh-chat-apps {
|
|
1533
1775
|
transition: none;
|
|
1534
1776
|
}
|
|
1535
1777
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chatTheme.js","sources":["../../../../src/pages/Home/chat/chatTheme.tsx"],"sourcesContent":[null],"names":["_jsx"],"mappings":"oCASA,MAAM,QA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), and where each one
|
|
3
|
+
* is connected.
|
|
4
|
+
*
|
|
5
|
+
* Clockbook connects nothing itself, for now. The connection is the person's Yantra account's
|
|
6
|
+
* (Clockbook runs on Yantra), so Connect sends them to the Yantra app: to the public
|
|
7
|
+
* `/connect/<connector>` page the messenger gateway sends iMessage and the kit's Connect card opens
|
|
8
|
+
* (yantra-app ConnectLinkPage). That page signs them in when they need it and opens the
|
|
9
|
+
* connector's form; once saved, Lucy can use it, here and everywhere else on Yantra.
|
|
10
|
+
*
|
|
11
|
+
* The ids are Yantra's own: catalog connectors by their template key (the ones Yantra's Meetings
|
|
12
|
+
* and Inbox connect), the rest by the kinds its vault form saves (yantra-app common
|
|
13
|
+
* CONNECTOR_CONNECT_PROTOCOL, `VAULT_FORM_KINDS`).
|
|
14
|
+
*/
|
|
15
|
+
/** An app Lucy works in, or something kept for her in Yantra's vault. */
|
|
16
|
+
export type ConnectorGroup = 'apps' | 'saved';
|
|
17
|
+
export interface LucyConnector {
|
|
18
|
+
/** Yantra's id for it: a catalog template key, or a vault form kind. */
|
|
19
|
+
id: string;
|
|
20
|
+
name: string;
|
|
21
|
+
/** What Lucy does with it, in a line. */
|
|
22
|
+
does: string;
|
|
23
|
+
group: ConnectorGroup;
|
|
24
|
+
}
|
|
25
|
+
/** The ones Clockbook's chores use, in the order the panel lists them. */
|
|
26
|
+
export declare const LUCY_CONNECTORS: readonly LucyConnector[];
|
|
27
|
+
/** The panel's sections, in order. */
|
|
28
|
+
export declare const CONNECTOR_GROUPS: ReadonlyArray<readonly [ConnectorGroup, string]>;
|
|
29
|
+
/** A button's word: an app is connected, the rest are added. */
|
|
30
|
+
export declare function connectVerb(connector: Pick<LucyConnector, 'group'>): string;
|
|
31
|
+
/** Yantra's page that connects `id`: `<app>/connect/<id>?via=surface`. '' without an app or an id. */
|
|
32
|
+
export declare function connectLink(appUrl: string, id: string): string;
|
|
33
|
+
/** Yantra's Connectors page: every connector there is, and what is connected already. */
|
|
34
|
+
export declare function allConnectorsLink(appUrl: string): string;
|
|
35
|
+
/** The app's host, for "opens yantra.app": '' when the address is not one. */
|
|
36
|
+
export declare function appHost(appUrl: string): string;
|
|
37
|
+
//# sourceMappingURL=connectors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connectors.d.ts","sourceRoot":"","sources":["../../../../src/pages/Home/chat/connectors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,yEAAyE;AACzE,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,OAAO,CAAC;AAE9C,MAAM,WAAW,aAAa;IAC1B,wEAAwE;IACxE,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,yCAAyC;IACzC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,cAAc,CAAC;CACzB;AAED,0EAA0E;AAC1E,eAAO,MAAM,eAAe,EAAE,SAAS,aAAa,EA+BnD,CAAC;AAEF,sCAAsC;AACtC,eAAO,MAAM,gBAAgB,EAAE,aAAa,CAAC,SAAS,CAAC,cAAc,EAAE,MAAM,CAAC,CAG7E,CAAC;AAEF,gEAAgE;AAChE,wBAAgB,WAAW,CAAC,SAAS,EAAE,IAAI,CAAC,aAAa,EAAE,OAAO,CAAC,GAAG,MAAM,CAE3E;AAUD,sGAAsG;AACtG,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CAK9D;AAED,yFAAyF;AACzF,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAGxD;AAED,8EAA8E;AAC9E,wBAAgB,OAAO,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAM9C"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What Lucy can use when it is connected, as the chat lists it (ConnectorsPanel), and where each one
|
|
3
|
+
* is connected.
|
|
4
|
+
*
|
|
5
|
+
* Clockbook connects nothing itself, for now. The connection is the person's Yantra account's
|
|
6
|
+
* (Clockbook runs on Yantra), so Connect sends them to the Yantra app: to the public
|
|
7
|
+
* `/connect/<connector>` page the messenger gateway sends iMessage and the kit's Connect card opens
|
|
8
|
+
* (yantra-app ConnectLinkPage). That page signs them in when they need it and opens the
|
|
9
|
+
* connector's form; once saved, Lucy can use it, here and everywhere else on Yantra.
|
|
10
|
+
*
|
|
11
|
+
* The ids are Yantra's own: catalog connectors by their template key (the ones Yantra's Meetings
|
|
12
|
+
* and Inbox connect), the rest by the kinds its vault form saves (yantra-app common
|
|
13
|
+
* CONNECTOR_CONNECT_PROTOCOL, `VAULT_FORM_KINDS`).
|
|
14
|
+
*/
|
|
15
|
+
/** The ones Clockbook's chores use, in the order the panel lists them. */
|
|
16
|
+
const LUCY_CONNECTORS = [{
|
|
17
|
+
id: 'google-calendar',
|
|
18
|
+
name: 'Google Calendar',
|
|
19
|
+
does: 'Books calls and appointments when you’re free.',
|
|
20
|
+
group: 'apps'
|
|
21
|
+
}, {
|
|
22
|
+
id: 'google-gmail',
|
|
23
|
+
name: 'Gmail',
|
|
24
|
+
does: 'Finds bills, receipts and confirmation numbers.',
|
|
25
|
+
group: 'apps'
|
|
26
|
+
}, {
|
|
27
|
+
id: 'site-login',
|
|
28
|
+
name: 'Website logins',
|
|
29
|
+
does: 'Signs in to your accounts to cancel or change a plan.',
|
|
30
|
+
group: 'saved'
|
|
31
|
+
}, {
|
|
32
|
+
id: 'autofill-address',
|
|
33
|
+
name: 'Your address',
|
|
34
|
+
does: 'Fills it in on forms, bookings and deliveries.',
|
|
35
|
+
group: 'saved'
|
|
36
|
+
}, {
|
|
37
|
+
id: 'autofill-payment-card',
|
|
38
|
+
name: 'Payment card',
|
|
39
|
+
does: 'Pays only after you say yes.',
|
|
40
|
+
group: 'saved'
|
|
41
|
+
}];
|
|
42
|
+
/** The panel's sections, in order. */
|
|
43
|
+
const CONNECTOR_GROUPS = [['apps', 'Your apps'], ['saved', 'Kept for Lucy']];
|
|
44
|
+
/** A button's word: an app is connected, the rest are added. */
|
|
45
|
+
function connectVerb(connector) {
|
|
46
|
+
return connector.group === 'apps' ? 'Connect' : 'Add';
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* The link's `via`: a page of its own rather than a chat the connect page could answer, so its done
|
|
50
|
+
* step has nothing to send (the kit's CONNECT_LINK_VIA, yantra-app SURFACE_CONNECT_VIA).
|
|
51
|
+
*/
|
|
52
|
+
const CONNECT_VIA = 'surface';
|
|
53
|
+
const appBase = appUrl => appUrl.trim().replace(/\/+$/, '');
|
|
54
|
+
/** Yantra's page that connects `id`: `<app>/connect/<id>?via=surface`. '' without an app or an id. */
|
|
55
|
+
function connectLink(appUrl, id) {
|
|
56
|
+
const base = appBase(appUrl);
|
|
57
|
+
const connector = id.trim();
|
|
58
|
+
if (!base || !connector) return '';
|
|
59
|
+
return `${base}/connect/${encodeURIComponent(connector)}?via=${CONNECT_VIA}`;
|
|
60
|
+
}
|
|
61
|
+
/** Yantra's Connectors page: every connector there is, and what is connected already. */
|
|
62
|
+
function allConnectorsLink(appUrl) {
|
|
63
|
+
const base = appBase(appUrl);
|
|
64
|
+
return base ? `${base}/account/connectors` : '';
|
|
65
|
+
}
|
|
66
|
+
/** The app's host, for "opens yantra.app": '' when the address is not one. */
|
|
67
|
+
function appHost(appUrl) {
|
|
68
|
+
try {
|
|
69
|
+
return new URL(appBase(appUrl)).host;
|
|
70
|
+
} catch {
|
|
71
|
+
return '';
|
|
72
|
+
}
|
|
73
|
+
}export{CONNECTOR_GROUPS,LUCY_CONNECTORS,allConnectorsLink,appHost,connectLink,connectVerb};//# sourceMappingURL=connectors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connectors.js","sources":["../../../../src/pages/Home/chat/connectors.ts"],"sourcesContent":[null],"names":[],"mappings":"AAAA;;;;;;;;;;;;;AAaG;AAcH;AACa,MAAA,eAAe,GAA6B,CAAA;AACrD,EAAA,EAAA,EAAA,iBA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,MAAA,CAAA;AACtG,EAAA,OAAgB,IAAA,GAAA,CAAA,EAAA,IAAA,CAAA,mBAAsC,CAAA,GAAA,EAAA;AAClD;AACA;AACA,SAAa,OAAU,CAAA,MAAA,EAAA;AAAE,EAAA,IAAA;IACzB,OAAO,IAAO,GAAA,CAAA,OAAA,CAAA,MAA8B,CAAA,CAAA,CAAA,IAAA;AAChD,GAAC,CAAA,MAAA;AAED,IAAyF,OAAA,EAAA;AACzF;AACI"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { type ChatThread, type ThreadMessage } from './thread';
|
|
2
|
+
export interface PastChat {
|
|
3
|
+
/** Its own id: its agent session's, else its first question's. */
|
|
4
|
+
id: string;
|
|
5
|
+
/** What it was about: the first thing the person asked, kept short. */
|
|
6
|
+
title: string;
|
|
7
|
+
/** When it was last written to (ms): its newest message, else when it was put away. */
|
|
8
|
+
at: number;
|
|
9
|
+
sessionId: string;
|
|
10
|
+
messages: ThreadMessage[];
|
|
11
|
+
}
|
|
12
|
+
/** The most past chats kept; the oldest go first. */
|
|
13
|
+
export declare const HISTORY_MAX_CHATS = 30;
|
|
14
|
+
/**
|
|
15
|
+
* The most room the history takes, in characters of its record. A browser gives a site a few
|
|
16
|
+
* million at most, and the thread, the chores and the sign-in need theirs.
|
|
17
|
+
*/
|
|
18
|
+
export declare const HISTORY_MAX_CHARS = 1000000;
|
|
19
|
+
/** What a reply Lucy was stopped in the middle of ends with (ChoresChat's Stop). */
|
|
20
|
+
export declare const STOPPED_MARK = "_Stopped._";
|
|
21
|
+
/** The thread as a past chat, kept the way the thread is (thread.ts). Null when nothing was asked. */
|
|
22
|
+
export declare function toPastChat(thread: ChatThread, now?: number): PastChat | null;
|
|
23
|
+
/**
|
|
24
|
+
* The thread with Lucy's replies to the `stopped` turns saying they were stopped, the way Stop
|
|
25
|
+
* leaves a reply it cuts short. A chat put away while she streams one is kept with it that way.
|
|
26
|
+
*/
|
|
27
|
+
export declare function markStopped(messages: readonly ThreadMessage[], stopped: ReadonlySet<string>): ThreadMessage[];
|
|
28
|
+
/** The past chats, newest first. Storage damaged is read as no history; a damaged chat, as none. */
|
|
29
|
+
export declare function listPastChats(account: string, storage?: Storage): PastChat[];
|
|
30
|
+
/**
|
|
31
|
+
* Put the thread away, in the history by when it was last written to. A copy of it already there
|
|
32
|
+
* (another tab of the page put it away first) gives way to this one. Nothing for a thread where
|
|
33
|
+
* nothing was asked.
|
|
34
|
+
*/
|
|
35
|
+
export declare function archiveChat(account: string, thread: ChatThread, storage?: Storage, now?: number): void;
|
|
36
|
+
/** A past chat, out of the history: it is about to be the thread. Null when it is gone. */
|
|
37
|
+
export declare function takePastChat(account: string, id: string, storage?: Storage): PastChat | null;
|
|
38
|
+
export declare function deletePastChat(account: string, id: string, storage?: Storage): void;
|
|
39
|
+
export declare function clearHistory(account: string, storage?: Storage): void;
|
|
40
|
+
/** The panel's sections, newest first. */
|
|
41
|
+
export type ChatAge = 'Today' | 'Yesterday' | 'Previous 7 days' | 'Older';
|
|
42
|
+
export declare const CHAT_AGES: readonly ChatAge[];
|
|
43
|
+
/**
|
|
44
|
+
* Where a past chat goes in the panel, and the time it shows: the hour for today and yesterday, the
|
|
45
|
+
* weekday within the week, the date before that (with the year, once it is not this one's).
|
|
46
|
+
*/
|
|
47
|
+
export declare function chatWhen(at: number, now?: number): {
|
|
48
|
+
age: ChatAge;
|
|
49
|
+
label: string;
|
|
50
|
+
};
|
|
51
|
+
//# sourceMappingURL=history.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"history.d.ts","sourceRoot":"","sources":["../../../../src/pages/Home/chat/history.ts"],"names":[],"mappings":"AAYA,OAAO,EAAwC,KAAK,UAAU,EAAE,KAAK,aAAa,EAAE,MAAM,UAAU,CAAC;AAErG,MAAM,WAAW,QAAQ;IACrB,kEAAkE;IAClE,EAAE,EAAE,MAAM,CAAC;IACX,uEAAuE;IACvE,KAAK,EAAE,MAAM,CAAC;IACd,uFAAuF;IAC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AAS,OAAO,EAAuD,CAAC;AAUhG;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,EAAE,EAAE,MAAM,EAAE,GAAG,SAAa,GAAG;IAAE,GAAG,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAgBtF"}
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import {choreTitle}from'./chores.js';import {taskOf}from'./placement.js';import {isThreadMessage}from'./thread.js';/**
|
|
2
|
+
* The chat's history: the conversations put away by New chat, kept so one can be opened again
|
|
3
|
+
* (HistoryPanel). In this browser only, per account, like the thread itself (thread.ts): another
|
|
4
|
+
* device keeps its own, and signing out leaves none behind.
|
|
5
|
+
*
|
|
6
|
+
* Opening a past chat takes it out of the history and makes it the thread; the one it replaces is
|
|
7
|
+
* put away in its place. Its agent session goes with it, so Lucy carries on where it left off.
|
|
8
|
+
*
|
|
9
|
+
* Every storage call is guarded: a private window or blocked storage just means nothing is kept.
|
|
10
|
+
*/
|
|
11
|
+
const HISTORY_PREFIX = 'cbh-history:v1:';
|
|
12
|
+
/** The most past chats kept; the oldest go first. */
|
|
13
|
+
const HISTORY_MAX_CHATS = 30;
|
|
14
|
+
/**
|
|
15
|
+
* The most room the history takes, in characters of its record. A browser gives a site a few
|
|
16
|
+
* million at most, and the thread, the chores and the sign-in need theirs.
|
|
17
|
+
*/
|
|
18
|
+
const HISTORY_MAX_CHARS = 1_000_000;
|
|
19
|
+
/** What a reply Lucy was stopped in the middle of ends with (ChoresChat's Stop). */
|
|
20
|
+
const STOPPED_MARK = '_Stopped._';
|
|
21
|
+
/** The first thing the person asked; a thread without one holds nothing worth keeping. */
|
|
22
|
+
function firstAsked(messages) {
|
|
23
|
+
return messages.find(m => m.role === 'user' && m.content.trim());
|
|
24
|
+
}
|
|
25
|
+
/** When a thread was last written to: its newest message that says when, else `now`. */
|
|
26
|
+
function lastWrittenAt(messages, now) {
|
|
27
|
+
for (let i = messages.length - 1; i >= 0; i--) {
|
|
28
|
+
const at = Date.parse(messages[i].createdAt ?? '');
|
|
29
|
+
if (Number.isFinite(at)) return at;
|
|
30
|
+
}
|
|
31
|
+
return now;
|
|
32
|
+
}
|
|
33
|
+
/** The thread as a past chat, kept the way the thread is (thread.ts). Null when nothing was asked. */
|
|
34
|
+
function toPastChat(thread, now = Date.now()) {
|
|
35
|
+
const messages = thread.messages.filter(m => m.content.trim()).slice(-200);
|
|
36
|
+
const first = firstAsked(messages);
|
|
37
|
+
if (!first) return null;
|
|
38
|
+
return {
|
|
39
|
+
id: thread.sessionId || first.id,
|
|
40
|
+
title: choreTitle(first.content),
|
|
41
|
+
at: lastWrittenAt(messages, now),
|
|
42
|
+
sessionId: thread.sessionId,
|
|
43
|
+
messages
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* The thread with Lucy's replies to the `stopped` turns saying they were stopped, the way Stop
|
|
48
|
+
* leaves a reply it cuts short. A chat put away while she streams one is kept with it that way.
|
|
49
|
+
*/
|
|
50
|
+
function markStopped(messages, stopped) {
|
|
51
|
+
return messages.map(m => m.role === 'assistant' && m.content.trim() && stopped.has(taskOf(m)) ? {
|
|
52
|
+
...m,
|
|
53
|
+
content: `${m.content}\n\n${STOPPED_MARK}`
|
|
54
|
+
} : m);
|
|
55
|
+
}
|
|
56
|
+
function isPastChat(value) {
|
|
57
|
+
if (!value || typeof value !== 'object') return false;
|
|
58
|
+
const c = value;
|
|
59
|
+
return typeof c.id === 'string' && Boolean(c.id) && typeof c.title === 'string' && typeof c.at === 'number' && Number.isFinite(c.at) && typeof c.sessionId === 'string' && Array.isArray(c.messages);
|
|
60
|
+
}
|
|
61
|
+
const isQuotaError = err => err instanceof DOMException && (err.name === 'QuotaExceededError' || err.name === 'NS_ERROR_DOM_QUOTA_REACHED');
|
|
62
|
+
/** The past chats, newest first. Storage damaged is read as no history; a damaged chat, as none. */
|
|
63
|
+
function listPastChats(account, storage = localStorage) {
|
|
64
|
+
if (!account) return [];
|
|
65
|
+
try {
|
|
66
|
+
const raw = storage.getItem(HISTORY_PREFIX + account);
|
|
67
|
+
if (!raw) return [];
|
|
68
|
+
const parsed = JSON.parse(raw);
|
|
69
|
+
if (!Array.isArray(parsed.chats)) return [];
|
|
70
|
+
return parsed.chats.filter(isPastChat).map(chat => ({
|
|
71
|
+
...chat,
|
|
72
|
+
messages: chat.messages.filter(isThreadMessage)
|
|
73
|
+
})).filter(chat => firstAsked(chat.messages)).sort((a, b) => b.at - a.at);
|
|
74
|
+
} catch {
|
|
75
|
+
return [];
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Keep `chats` (newest first): as many as there is room for, the oldest left out first. A chat too
|
|
80
|
+
* big for the room on its own is left out rather than crowding out every other one.
|
|
81
|
+
*/
|
|
82
|
+
function savePastChats(account, chats, storage) {
|
|
83
|
+
const key = HISTORY_PREFIX + account;
|
|
84
|
+
const kept = [];
|
|
85
|
+
let room = HISTORY_MAX_CHARS;
|
|
86
|
+
for (const chat of chats) {
|
|
87
|
+
if (kept.length === HISTORY_MAX_CHATS) break;
|
|
88
|
+
const size = JSON.stringify(chat).length + 1;
|
|
89
|
+
if (size > room) continue;
|
|
90
|
+
kept.push(chat);
|
|
91
|
+
room -= size;
|
|
92
|
+
}
|
|
93
|
+
// The browser's own room can run out first (the thread and the chores share it): the oldest go.
|
|
94
|
+
while (kept.length) {
|
|
95
|
+
try {
|
|
96
|
+
storage.setItem(key, JSON.stringify({
|
|
97
|
+
chats: kept
|
|
98
|
+
}));
|
|
99
|
+
return;
|
|
100
|
+
} catch (err) {
|
|
101
|
+
if (!isQuotaError(err)) return;
|
|
102
|
+
kept.pop();
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
try {
|
|
106
|
+
storage.removeItem(key);
|
|
107
|
+
} catch {
|
|
108
|
+
/* nothing kept to clear */
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Put the thread away, in the history by when it was last written to. A copy of it already there
|
|
113
|
+
* (another tab of the page put it away first) gives way to this one. Nothing for a thread where
|
|
114
|
+
* nothing was asked.
|
|
115
|
+
*/
|
|
116
|
+
function archiveChat(account, thread, storage = localStorage, now = Date.now()) {
|
|
117
|
+
if (!account) return;
|
|
118
|
+
const chat = toPastChat(thread, now);
|
|
119
|
+
if (!chat) return;
|
|
120
|
+
const rest = listPastChats(account, storage).filter(c => c.id !== chat.id);
|
|
121
|
+
savePastChats(account, [chat, ...rest].sort((a, b) => b.at - a.at), storage);
|
|
122
|
+
}
|
|
123
|
+
/** A past chat, out of the history: it is about to be the thread. Null when it is gone. */
|
|
124
|
+
function takePastChat(account, id, storage = localStorage) {
|
|
125
|
+
if (!account || !id) return null;
|
|
126
|
+
const chats = listPastChats(account, storage);
|
|
127
|
+
const chat = chats.find(c => c.id === id);
|
|
128
|
+
if (!chat) return null;
|
|
129
|
+
savePastChats(account, chats.filter(c => c !== chat), storage);
|
|
130
|
+
return chat;
|
|
131
|
+
}
|
|
132
|
+
function deletePastChat(account, id, storage = localStorage) {
|
|
133
|
+
takePastChat(account, id, storage);
|
|
134
|
+
}
|
|
135
|
+
function clearHistory(account, storage = localStorage) {
|
|
136
|
+
if (!account) return;
|
|
137
|
+
try {
|
|
138
|
+
storage.removeItem(HISTORY_PREFIX + account);
|
|
139
|
+
} catch {
|
|
140
|
+
/* nothing kept to clear */
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
const CHAT_AGES = ['Today', 'Yesterday', 'Previous 7 days', 'Older'];
|
|
144
|
+
const DAY_MS = 24 * 60 * 60 * 1000;
|
|
145
|
+
/** Midnight of `at`'s day, on the visitor's own clock. */
|
|
146
|
+
function dayStart(at) {
|
|
147
|
+
const d = new Date(at);
|
|
148
|
+
return new Date(d.getFullYear(), d.getMonth(), d.getDate()).getTime();
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Where a past chat goes in the panel, and the time it shows: the hour for today and yesterday, the
|
|
152
|
+
* weekday within the week, the date before that (with the year, once it is not this one's).
|
|
153
|
+
*/
|
|
154
|
+
function chatWhen(at, now = Date.now()) {
|
|
155
|
+
const days = Math.round((dayStart(now) - dayStart(at)) / DAY_MS);
|
|
156
|
+
const date = new Date(at);
|
|
157
|
+
const time = date.toLocaleTimeString('en-US', {
|
|
158
|
+
hour: 'numeric',
|
|
159
|
+
minute: '2-digit'
|
|
160
|
+
});
|
|
161
|
+
if (days <= 0) return {
|
|
162
|
+
age: 'Today',
|
|
163
|
+
label: time
|
|
164
|
+
};
|
|
165
|
+
if (days === 1) return {
|
|
166
|
+
age: 'Yesterday',
|
|
167
|
+
label: time
|
|
168
|
+
};
|
|
169
|
+
if (days < 7) return {
|
|
170
|
+
age: 'Previous 7 days',
|
|
171
|
+
label: date.toLocaleDateString('en-US', {
|
|
172
|
+
weekday: 'long'
|
|
173
|
+
})
|
|
174
|
+
};
|
|
175
|
+
const sameYear = date.getFullYear() === new Date(now).getFullYear();
|
|
176
|
+
return {
|
|
177
|
+
age: 'Older',
|
|
178
|
+
label: date.toLocaleDateString('en-US', {
|
|
179
|
+
month: 'short',
|
|
180
|
+
day: 'numeric',
|
|
181
|
+
...(sameYear ? {} : {
|
|
182
|
+
year: 'numeric'
|
|
183
|
+
})
|
|
184
|
+
})
|
|
185
|
+
};
|
|
186
|
+
}export{CHAT_AGES,HISTORY_MAX_CHARS,HISTORY_MAX_CHATS,STOPPED_MARK,archiveChat,chatWhen,clearHistory,deletePastChat,listPastChats,markStopped,takePastChat,toPastChat};//# sourceMappingURL=history.js.map
|