@celljs/ta-moments 4.13.1 → 4.14.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.
@@ -340,49 +340,6 @@ var TaPackageTextUtil;
340
340
  }
341
341
  TaPackageTextUtil2.pick = pick;
342
342
  })(TaPackageTextUtil || (TaPackageTextUtil = {}));
343
- // ../ta-protocol/esm/common/relay-protocol.js
344
- var TaRelayServer = Symbol("TaRelayServer");
345
- // ../ta-protocol/esm/common/remote-protocol.js
346
- var TaRemoteServer = Symbol("TaRemoteServer");
347
- // ../ta-protocol/esm/common/room-protocol.js
348
- var TaRoomServer = Symbol("TaRoomServer");
349
- var TA_FRIENDS_KIND = "ta-friends";
350
- var TaRoomWatchUtil;
351
- (function(TaRoomWatchUtil2) {
352
- function of(messages, state) {
353
- const prefixes = Array.isArray(state) ? state.filter((prefix) => typeof prefix === "string" && prefix.length > 0) : [];
354
- return { messages: messages !== false, state: [...new Set(prefixes)].sort() };
355
- }
356
- TaRoomWatchUtil2.of = of;
357
- function union(watches) {
358
- let messages = false;
359
- const state = [];
360
- for (const watch of watches) {
361
- messages || (messages = watch.messages);
362
- state.push(...watch.state);
363
- }
364
- return of(messages, messages ? [] : state);
365
- }
366
- TaRoomWatchUtil2.union = union;
367
- function same(a, b) {
368
- return a === b || !!a && !!b && a.messages === b.messages && a.state.join(`
369
- `) === b.state.join(`
370
- `);
371
- }
372
- TaRoomWatchUtil2.same = same;
373
- function hears(watch, event) {
374
- if (event.type === "message") {
375
- return watch.messages;
376
- }
377
- if (event.type === "state") {
378
- return watch.messages || watch.state.some((prefix) => event.key.startsWith(prefix));
379
- }
380
- return true;
381
- }
382
- TaRoomWatchUtil2.hears = hears;
383
- })(TaRoomWatchUtil || (TaRoomWatchUtil = {}));
384
- // ../ta-protocol/esm/common/settings-protocol.js
385
- var TaSettingsServer = Symbol("TaSettingsServer");
386
343
  // ../ta-protocol/esm/common/ta-protocol.js
387
344
  var TaServer = Symbol("TaServer");
388
345
  var TaClient = Symbol("TaClient");
@@ -568,6 +525,85 @@ var TaSkillUse;
568
525
  }
569
526
  TaSkillUse2.command = command;
570
527
  })(TaSkillUse || (TaSkillUse = {}));
528
+
529
+ // ../ta-protocol/esm/common/presence-protocol.js
530
+ var TaPresenceServer = Symbol("TaPresenceServer");
531
+ var TaMessageAuthor;
532
+ (function(TaMessageAuthor2) {
533
+ const LINE = /^\[ta:by ([^\s\]]+)(?: ([^\]\n]+))?\]$/m;
534
+ const LINES = /^\[ta:by [^\]\n]*\]$\n?/gm;
535
+ function strip(message) {
536
+ const context = TaMessageContext.read(message);
537
+ if (context === undefined || !LINE.test(context)) {
538
+ return message;
539
+ }
540
+ const kept = context.replace(LINES, "").replace(/\n+$/, "");
541
+ const body = TaMessageContext.strip(message);
542
+ return kept.trim() ? TaMessageContext.wrap(kept, body) : body;
543
+ }
544
+ TaMessageAuthor2.strip = strip;
545
+ function mark(message, id, name) {
546
+ const plain = strip(message);
547
+ if (/^[/!]/.test(plain)) {
548
+ return plain;
549
+ }
550
+ const line = `[ta:by ${id.replace(/[\s\]]/g, "")} ${name.replace(/[\]\n]/g, " ").trim() || id}]`;
551
+ const context = TaMessageContext.read(plain);
552
+ return TaMessageContext.wrap(context === undefined ? line : `${context}
553
+ ${line}`, TaMessageContext.strip(plain));
554
+ }
555
+ TaMessageAuthor2.mark = mark;
556
+ function of(message) {
557
+ var _a;
558
+ const context = TaMessageContext.read(message);
559
+ const match = context === undefined ? null : LINE.exec(context);
560
+ return match ? { id: match[1], name: ((_a = match[2]) !== null && _a !== undefined ? _a : match[1]).trim() } : undefined;
561
+ }
562
+ TaMessageAuthor2.of = of;
563
+ })(TaMessageAuthor || (TaMessageAuthor = {}));
564
+ // ../ta-protocol/esm/common/relay-protocol.js
565
+ var TaRelayServer = Symbol("TaRelayServer");
566
+ // ../ta-protocol/esm/common/remote-protocol.js
567
+ var TaRemoteServer = Symbol("TaRemoteServer");
568
+ // ../ta-protocol/esm/common/room-protocol.js
569
+ var TaRoomServer = Symbol("TaRoomServer");
570
+ var TA_FRIENDS_KIND = "ta-friends";
571
+ var TaRoomWatchUtil;
572
+ (function(TaRoomWatchUtil2) {
573
+ function of(messages, state) {
574
+ const prefixes = Array.isArray(state) ? state.filter((prefix) => typeof prefix === "string" && prefix.length > 0) : [];
575
+ return { messages: messages !== false, state: [...new Set(prefixes)].sort() };
576
+ }
577
+ TaRoomWatchUtil2.of = of;
578
+ function union(watches) {
579
+ let messages = false;
580
+ const state = [];
581
+ for (const watch of watches) {
582
+ messages || (messages = watch.messages);
583
+ state.push(...watch.state);
584
+ }
585
+ return of(messages, messages ? [] : state);
586
+ }
587
+ TaRoomWatchUtil2.union = union;
588
+ function same(a, b) {
589
+ return a === b || !!a && !!b && a.messages === b.messages && a.state.join(`
590
+ `) === b.state.join(`
591
+ `);
592
+ }
593
+ TaRoomWatchUtil2.same = same;
594
+ function hears(watch, event) {
595
+ if (event.type === "message") {
596
+ return watch.messages;
597
+ }
598
+ if (event.type === "state") {
599
+ return watch.messages || watch.state.some((prefix) => event.key.startsWith(prefix));
600
+ }
601
+ return true;
602
+ }
603
+ TaRoomWatchUtil2.hears = hears;
604
+ })(TaRoomWatchUtil || (TaRoomWatchUtil = {}));
605
+ // ../ta-protocol/esm/common/settings-protocol.js
606
+ var TaSettingsServer = Symbol("TaSettingsServer");
571
607
  // ../ta-protocol/esm/common/team-protocol.js
572
608
  var TA_UNDECLARED = "extensions.install";
573
609
  var TaPermissionUtil;
@@ -832,7 +868,7 @@ var PostUtil;
832
868
  return [];
833
869
  }
834
870
  const online = owner.self || owner.online;
835
- const author = { id: owner.id, name: owner.name || room.ownerName };
871
+ const author = { id: owner.id, name: owner.name || room.ownerName, ...owner.look ? { look: owner.look } : {} };
836
872
  const byMember = new Map(room.members.map((member) => [member.member, member]));
837
873
  const self = room.members.find((member) => member.self);
838
874
  const marks = (prefix, id) => {
@@ -851,7 +887,7 @@ var PostUtil;
851
887
  mine = true;
852
888
  }
853
889
  if (who.id === me || who.id === owner.id || owner.id === me || friends.has(who.id)) {
854
- people.push({ id: who.id, name: who.name });
890
+ people.push({ id: who.id, name: who.name, ...who.look ? { look: who.look } : {} });
855
891
  }
856
892
  }
857
893
  return { people, mine };
package/host/index.mjs CHANGED
@@ -367,49 +367,6 @@ var TaLocation;
367
367
  return squeezed.length > 1 ? squeezed.replace(/\/$/, "") : squeezed;
368
368
  }
369
369
  })(TaLocation || (TaLocation = {}));
370
- // ../ta-protocol/esm/common/relay-protocol.js
371
- var TaRelayServer = Symbol("TaRelayServer");
372
- // ../ta-protocol/esm/common/remote-protocol.js
373
- var TaRemoteServer = Symbol("TaRemoteServer");
374
- // ../ta-protocol/esm/common/room-protocol.js
375
- var TaRoomServer = Symbol("TaRoomServer");
376
- var TA_FRIENDS_KIND = "ta-friends";
377
- var TaRoomWatchUtil;
378
- (function(TaRoomWatchUtil2) {
379
- function of(messages, state) {
380
- const prefixes = Array.isArray(state) ? state.filter((prefix) => typeof prefix === "string" && prefix.length > 0) : [];
381
- return { messages: messages !== false, state: [...new Set(prefixes)].sort() };
382
- }
383
- TaRoomWatchUtil2.of = of;
384
- function union(watches) {
385
- let messages = false;
386
- const state = [];
387
- for (const watch of watches) {
388
- messages || (messages = watch.messages);
389
- state.push(...watch.state);
390
- }
391
- return of(messages, messages ? [] : state);
392
- }
393
- TaRoomWatchUtil2.union = union;
394
- function same(a, b) {
395
- return a === b || !!a && !!b && a.messages === b.messages && a.state.join(`
396
- `) === b.state.join(`
397
- `);
398
- }
399
- TaRoomWatchUtil2.same = same;
400
- function hears(watch, event) {
401
- if (event.type === "message") {
402
- return watch.messages;
403
- }
404
- if (event.type === "state") {
405
- return watch.messages || watch.state.some((prefix) => event.key.startsWith(prefix));
406
- }
407
- return true;
408
- }
409
- TaRoomWatchUtil2.hears = hears;
410
- })(TaRoomWatchUtil || (TaRoomWatchUtil = {}));
411
- // ../ta-protocol/esm/common/settings-protocol.js
412
- var TaSettingsServer = Symbol("TaSettingsServer");
413
370
  // ../ta-protocol/esm/common/ta-protocol.js
414
371
  var TaServer = Symbol("TaServer");
415
372
  var TaClient = Symbol("TaClient");
@@ -595,6 +552,85 @@ var TaSkillUse;
595
552
  }
596
553
  TaSkillUse2.command = command;
597
554
  })(TaSkillUse || (TaSkillUse = {}));
555
+
556
+ // ../ta-protocol/esm/common/presence-protocol.js
557
+ var TaPresenceServer = Symbol("TaPresenceServer");
558
+ var TaMessageAuthor;
559
+ (function(TaMessageAuthor2) {
560
+ const LINE = /^\[ta:by ([^\s\]]+)(?: ([^\]\n]+))?\]$/m;
561
+ const LINES = /^\[ta:by [^\]\n]*\]$\n?/gm;
562
+ function strip(message) {
563
+ const context = TaMessageContext.read(message);
564
+ if (context === undefined || !LINE.test(context)) {
565
+ return message;
566
+ }
567
+ const kept = context.replace(LINES, "").replace(/\n+$/, "");
568
+ const body = TaMessageContext.strip(message);
569
+ return kept.trim() ? TaMessageContext.wrap(kept, body) : body;
570
+ }
571
+ TaMessageAuthor2.strip = strip;
572
+ function mark(message, id, name) {
573
+ const plain = strip(message);
574
+ if (/^[/!]/.test(plain)) {
575
+ return plain;
576
+ }
577
+ const line = `[ta:by ${id.replace(/[\s\]]/g, "")} ${name.replace(/[\]\n]/g, " ").trim() || id}]`;
578
+ const context = TaMessageContext.read(plain);
579
+ return TaMessageContext.wrap(context === undefined ? line : `${context}
580
+ ${line}`, TaMessageContext.strip(plain));
581
+ }
582
+ TaMessageAuthor2.mark = mark;
583
+ function of(message) {
584
+ var _a;
585
+ const context = TaMessageContext.read(message);
586
+ const match = context === undefined ? null : LINE.exec(context);
587
+ return match ? { id: match[1], name: ((_a = match[2]) !== null && _a !== undefined ? _a : match[1]).trim() } : undefined;
588
+ }
589
+ TaMessageAuthor2.of = of;
590
+ })(TaMessageAuthor || (TaMessageAuthor = {}));
591
+ // ../ta-protocol/esm/common/relay-protocol.js
592
+ var TaRelayServer = Symbol("TaRelayServer");
593
+ // ../ta-protocol/esm/common/remote-protocol.js
594
+ var TaRemoteServer = Symbol("TaRemoteServer");
595
+ // ../ta-protocol/esm/common/room-protocol.js
596
+ var TaRoomServer = Symbol("TaRoomServer");
597
+ var TA_FRIENDS_KIND = "ta-friends";
598
+ var TaRoomWatchUtil;
599
+ (function(TaRoomWatchUtil2) {
600
+ function of(messages, state) {
601
+ const prefixes = Array.isArray(state) ? state.filter((prefix) => typeof prefix === "string" && prefix.length > 0) : [];
602
+ return { messages: messages !== false, state: [...new Set(prefixes)].sort() };
603
+ }
604
+ TaRoomWatchUtil2.of = of;
605
+ function union(watches) {
606
+ let messages = false;
607
+ const state = [];
608
+ for (const watch of watches) {
609
+ messages || (messages = watch.messages);
610
+ state.push(...watch.state);
611
+ }
612
+ return of(messages, messages ? [] : state);
613
+ }
614
+ TaRoomWatchUtil2.union = union;
615
+ function same(a, b) {
616
+ return a === b || !!a && !!b && a.messages === b.messages && a.state.join(`
617
+ `) === b.state.join(`
618
+ `);
619
+ }
620
+ TaRoomWatchUtil2.same = same;
621
+ function hears(watch, event) {
622
+ if (event.type === "message") {
623
+ return watch.messages;
624
+ }
625
+ if (event.type === "state") {
626
+ return watch.messages || watch.state.some((prefix) => event.key.startsWith(prefix));
627
+ }
628
+ return true;
629
+ }
630
+ TaRoomWatchUtil2.hears = hears;
631
+ })(TaRoomWatchUtil || (TaRoomWatchUtil = {}));
632
+ // ../ta-protocol/esm/common/settings-protocol.js
633
+ var TaSettingsServer = Symbol("TaSettingsServer");
598
634
  // ../ta-protocol/esm/common/team-protocol.js
599
635
  var TA_UNDECLARED = "extensions.install";
600
636
  var TaPermissionUtil;
@@ -854,7 +890,7 @@ var PostUtil;
854
890
  return [];
855
891
  }
856
892
  const online = owner.self || owner.online;
857
- const author = { id: owner.id, name: owner.name || room.ownerName };
893
+ const author = { id: owner.id, name: owner.name || room.ownerName, ...owner.look ? { look: owner.look } : {} };
858
894
  const byMember = new Map(room.members.map((member) => [member.member, member]));
859
895
  const self = room.members.find((member) => member.self);
860
896
  const marks = (prefix, id) => {
@@ -873,7 +909,7 @@ var PostUtil;
873
909
  mine = true;
874
910
  }
875
911
  if (who.id === me || who.id === owner.id || owner.id === me || friends.has(who.id)) {
876
- people.push({ id: who.id, name: who.name });
912
+ people.push({ id: who.id, name: who.name, ...who.look ? { look: who.look } : {} });
877
913
  }
878
914
  }
879
915
  return { people, mine };
@@ -1768,7 +1804,7 @@ class MomentsHost {
1768
1804
  }
1769
1805
  return {
1770
1806
  me,
1771
- friends: friends.map(({ id, name }) => ({ id, name })),
1807
+ friends: friends.map(({ id, name, look }) => ({ id, name, ...look ? { look } : {} })),
1772
1808
  asking: requests.length,
1773
1809
  posts: posts.sort((a, b) => b.at - a.at)
1774
1810
  };
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@celljs/ta-moments",
3
- "version": "4.13.1",
3
+ "version": "4.14.0",
4
4
  "description": "A pi package for Ta: Moments, what friends made with Ta that one can take and use. Ta drafts a post of what you made and you post it; your Ta friends see it, like it and take it, their Ta reading the code first",
5
5
  "keywords": [
6
6
  "pi-package"
7
7
  ],
8
- "homepage": "https://github.com/cellbang/cell",
8
+ "homepage": "https://github.com/cellbang/ta",
9
9
  "bugs": {
10
- "url": "https://github.com/cellbang/cell/issues"
10
+ "url": "https://github.com/cellbang/ta/issues"
11
11
  },
12
12
  "repository": {
13
13
  "type": "git",
@@ -27,9 +27,9 @@
27
27
  "watch": "tsc -b -w --preserveWatchOutput"
28
28
  },
29
29
  "devDependencies": {
30
- "@celljs/ta-protocol": "4.13.1",
31
- "@celljs/ta-relay": "4.13.1",
32
- "@celljs/ta-web": "4.13.1",
30
+ "@celljs/ta-protocol": "4.14.0",
31
+ "@celljs/ta-relay": "4.14.0",
32
+ "@celljs/ta-web": "4.14.0",
33
33
  "@types/react": "^19.3.0"
34
34
  },
35
35
  "publishConfig": {
package/web/index.js CHANGED
@@ -468,140 +468,6 @@ var TaPackageTextUtil;
468
468
  }
469
469
  TaPackageTextUtil2.pick = pick;
470
470
  })(TaPackageTextUtil || (TaPackageTextUtil = {}));
471
- // ../ta-protocol/esm/common/relay-protocol.js
472
- var TaRelayServer = Symbol("TaRelayServer");
473
- // ../ta-protocol/esm/common/remote-protocol.js
474
- var TaRemoteServer = Symbol("TaRemoteServer");
475
- // ../ta-protocol/esm/common/room-protocol.js
476
- var TaRoomServer = Symbol("TaRoomServer");
477
- var TaRoomWatchUtil;
478
- (function(TaRoomWatchUtil2) {
479
- function of(messages, state) {
480
- const prefixes = Array.isArray(state) ? state.filter((prefix) => typeof prefix === "string" && prefix.length > 0) : [];
481
- return { messages: messages !== false, state: [...new Set(prefixes)].sort() };
482
- }
483
- TaRoomWatchUtil2.of = of;
484
- function union(watches) {
485
- let messages = false;
486
- const state = [];
487
- for (const watch of watches) {
488
- messages || (messages = watch.messages);
489
- state.push(...watch.state);
490
- }
491
- return of(messages, messages ? [] : state);
492
- }
493
- TaRoomWatchUtil2.union = union;
494
- function same(a, b) {
495
- return a === b || !!a && !!b && a.messages === b.messages && a.state.join(`
496
- `) === b.state.join(`
497
- `);
498
- }
499
- TaRoomWatchUtil2.same = same;
500
- function hears(watch, event) {
501
- if (event.type === "message") {
502
- return watch.messages;
503
- }
504
- if (event.type === "state") {
505
- return watch.messages || watch.state.some((prefix) => event.key.startsWith(prefix));
506
- }
507
- return true;
508
- }
509
- TaRoomWatchUtil2.hears = hears;
510
- })(TaRoomWatchUtil || (TaRoomWatchUtil = {}));
511
- // ../ta-protocol/esm/common/settings-protocol.js
512
- var TaSettingsServer = Symbol("TaSettingsServer");
513
- // ../ta-protocol/esm/common/ta-extension-host.js
514
- var TA_HOST_EVENT = "ta:host";
515
- var TaHostUtil;
516
- (function(TaHostUtil2) {
517
- TaHostUtil2.WAIT_MS = 1000;
518
- function reach(events, name, waitMs = TaHostUtil2.WAIT_MS) {
519
- return new Promise((resolve) => {
520
- let heard = false;
521
- let answered = false;
522
- const timer = setTimeout(() => resolve(undefined), waitMs);
523
- const request = {
524
- name,
525
- heard: () => {
526
- heard = true;
527
- },
528
- resolve: (answer) => {
529
- answered = true;
530
- clearTimeout(timer);
531
- resolve(answer);
532
- }
533
- };
534
- events.emit(TA_HOST_EVENT, request);
535
- if (!heard && !answered) {
536
- clearTimeout(timer);
537
- resolve(undefined);
538
- }
539
- });
540
- }
541
- TaHostUtil2.reach = reach;
542
- function marked(systemPrompt, mark) {
543
- return role(systemPrompt).includes(mark);
544
- }
545
- TaHostUtil2.marked = marked;
546
- function role(systemPrompt) {
547
- if (!systemPrompt) {
548
- return "";
549
- }
550
- const open = `<addendum>
551
- `;
552
- const start = systemPrompt.indexOf(open);
553
- const context = systemPrompt.indexOf(`<project_context>
554
- `);
555
- if (start < 0 || context >= 0 && context < start) {
556
- return "";
557
- }
558
- const end = systemPrompt.indexOf(`
559
- </addendum>`, start);
560
- return systemPrompt.slice(start + open.length, end < 0 ? undefined : end);
561
- }
562
- TaHostUtil2.role = role;
563
- })(TaHostUtil || (TaHostUtil = {}));
564
- var TA_ASK_ENTRY = "ta-ask";
565
- var TaAskUtil;
566
- (function(TaAskUtil2) {
567
- const LENGTH = 120;
568
- function entry(question) {
569
- const line = question.replace(/\s+/g, " ").trim();
570
- return { question: line.length > LENGTH ? `${line.slice(0, LENGTH - 1)}…` : line };
571
- }
572
- TaAskUtil2.entry = entry;
573
- function asking(entries) {
574
- var _a;
575
- for (let i = entries.length - 1;i >= 0; i--) {
576
- const entry2 = entries[i];
577
- if (entry2.type === "message" && ((_a = entry2.message) === null || _a === undefined ? undefined : _a.role) === "user") {
578
- return;
579
- }
580
- if (entry2.type === "custom" && entry2.customType === TA_ASK_ENTRY) {
581
- return read(entry2);
582
- }
583
- }
584
- return;
585
- }
586
- TaAskUtil2.asking = asking;
587
- function next(asked, entry2) {
588
- var _a;
589
- if (entry2.type === "message" && ((_a = entry2.message) === null || _a === undefined ? undefined : _a.role) === "user") {
590
- return;
591
- }
592
- return entry2.type === "custom" && entry2.customType === TA_ASK_ENTRY ? read(entry2) : asked;
593
- }
594
- TaAskUtil2.next = next;
595
- function read(found) {
596
- var _a;
597
- const question = (_a = found.data) === null || _a === undefined ? undefined : _a.question;
598
- if (typeof question !== "string" || !question.trim()) {
599
- return;
600
- }
601
- const at = found.timestamp ? Date.parse(found.timestamp) : Number.NaN;
602
- return { question: entry(question).question, at: Number.isNaN(at) ? 0 : at };
603
- }
604
- })(TaAskUtil || (TaAskUtil = {}));
605
471
  // ../ta-protocol/esm/common/ta-protocol.js
606
472
  var TaServer = Symbol("TaServer");
607
473
  var TaClient = Symbol("TaClient");
@@ -787,6 +653,176 @@ var TaSkillUse;
787
653
  }
788
654
  TaSkillUse2.command = command;
789
655
  })(TaSkillUse || (TaSkillUse = {}));
656
+
657
+ // ../ta-protocol/esm/common/presence-protocol.js
658
+ var TaPresenceServer = Symbol("TaPresenceServer");
659
+ var TaMessageAuthor;
660
+ (function(TaMessageAuthor2) {
661
+ const LINE = /^\[ta:by ([^\s\]]+)(?: ([^\]\n]+))?\]$/m;
662
+ const LINES = /^\[ta:by [^\]\n]*\]$\n?/gm;
663
+ function strip(message2) {
664
+ const context = TaMessageContext.read(message2);
665
+ if (context === undefined || !LINE.test(context)) {
666
+ return message2;
667
+ }
668
+ const kept = context.replace(LINES, "").replace(/\n+$/, "");
669
+ const body = TaMessageContext.strip(message2);
670
+ return kept.trim() ? TaMessageContext.wrap(kept, body) : body;
671
+ }
672
+ TaMessageAuthor2.strip = strip;
673
+ function mark(message2, id, name) {
674
+ const plain = strip(message2);
675
+ if (/^[/!]/.test(plain)) {
676
+ return plain;
677
+ }
678
+ const line = `[ta:by ${id.replace(/[\s\]]/g, "")} ${name.replace(/[\]\n]/g, " ").trim() || id}]`;
679
+ const context = TaMessageContext.read(plain);
680
+ return TaMessageContext.wrap(context === undefined ? line : `${context}
681
+ ${line}`, TaMessageContext.strip(plain));
682
+ }
683
+ TaMessageAuthor2.mark = mark;
684
+ function of(message2) {
685
+ var _a;
686
+ const context = TaMessageContext.read(message2);
687
+ const match = context === undefined ? null : LINE.exec(context);
688
+ return match ? { id: match[1], name: ((_a = match[2]) !== null && _a !== undefined ? _a : match[1]).trim() } : undefined;
689
+ }
690
+ TaMessageAuthor2.of = of;
691
+ })(TaMessageAuthor || (TaMessageAuthor = {}));
692
+ // ../ta-protocol/esm/common/relay-protocol.js
693
+ var TaRelayServer = Symbol("TaRelayServer");
694
+ // ../ta-protocol/esm/common/remote-protocol.js
695
+ var TaRemoteServer = Symbol("TaRemoteServer");
696
+ // ../ta-protocol/esm/common/room-protocol.js
697
+ var TaRoomServer = Symbol("TaRoomServer");
698
+ var TaRoomWatchUtil;
699
+ (function(TaRoomWatchUtil2) {
700
+ function of(messages, state) {
701
+ const prefixes = Array.isArray(state) ? state.filter((prefix) => typeof prefix === "string" && prefix.length > 0) : [];
702
+ return { messages: messages !== false, state: [...new Set(prefixes)].sort() };
703
+ }
704
+ TaRoomWatchUtil2.of = of;
705
+ function union(watches) {
706
+ let messages = false;
707
+ const state = [];
708
+ for (const watch of watches) {
709
+ messages || (messages = watch.messages);
710
+ state.push(...watch.state);
711
+ }
712
+ return of(messages, messages ? [] : state);
713
+ }
714
+ TaRoomWatchUtil2.union = union;
715
+ function same(a, b) {
716
+ return a === b || !!a && !!b && a.messages === b.messages && a.state.join(`
717
+ `) === b.state.join(`
718
+ `);
719
+ }
720
+ TaRoomWatchUtil2.same = same;
721
+ function hears(watch, event) {
722
+ if (event.type === "message") {
723
+ return watch.messages;
724
+ }
725
+ if (event.type === "state") {
726
+ return watch.messages || watch.state.some((prefix) => event.key.startsWith(prefix));
727
+ }
728
+ return true;
729
+ }
730
+ TaRoomWatchUtil2.hears = hears;
731
+ })(TaRoomWatchUtil || (TaRoomWatchUtil = {}));
732
+ // ../ta-protocol/esm/common/settings-protocol.js
733
+ var TaSettingsServer = Symbol("TaSettingsServer");
734
+ // ../ta-protocol/esm/common/ta-extension-host.js
735
+ var TA_HOST_EVENT = "ta:host";
736
+ var TaHostUtil;
737
+ (function(TaHostUtil2) {
738
+ TaHostUtil2.WAIT_MS = 1000;
739
+ function reach(events, name, waitMs = TaHostUtil2.WAIT_MS) {
740
+ return new Promise((resolve) => {
741
+ let heard = false;
742
+ let answered = false;
743
+ const timer = setTimeout(() => resolve(undefined), waitMs);
744
+ const request = {
745
+ name,
746
+ heard: () => {
747
+ heard = true;
748
+ },
749
+ resolve: (answer) => {
750
+ answered = true;
751
+ clearTimeout(timer);
752
+ resolve(answer);
753
+ }
754
+ };
755
+ events.emit(TA_HOST_EVENT, request);
756
+ if (!heard && !answered) {
757
+ clearTimeout(timer);
758
+ resolve(undefined);
759
+ }
760
+ });
761
+ }
762
+ TaHostUtil2.reach = reach;
763
+ function marked(systemPrompt, mark) {
764
+ return role(systemPrompt).includes(mark);
765
+ }
766
+ TaHostUtil2.marked = marked;
767
+ function role(systemPrompt) {
768
+ if (!systemPrompt) {
769
+ return "";
770
+ }
771
+ const open = `<addendum>
772
+ `;
773
+ const start = systemPrompt.indexOf(open);
774
+ const context = systemPrompt.indexOf(`<project_context>
775
+ `);
776
+ if (start < 0 || context >= 0 && context < start) {
777
+ return "";
778
+ }
779
+ const end = systemPrompt.indexOf(`
780
+ </addendum>`, start);
781
+ return systemPrompt.slice(start + open.length, end < 0 ? undefined : end);
782
+ }
783
+ TaHostUtil2.role = role;
784
+ })(TaHostUtil || (TaHostUtil = {}));
785
+ var TA_ASK_ENTRY = "ta-ask";
786
+ var TaAskUtil;
787
+ (function(TaAskUtil2) {
788
+ const LENGTH = 120;
789
+ function entry(question) {
790
+ const line = question.replace(/\s+/g, " ").trim();
791
+ return { question: line.length > LENGTH ? `${line.slice(0, LENGTH - 1)}…` : line };
792
+ }
793
+ TaAskUtil2.entry = entry;
794
+ function asking(entries) {
795
+ var _a;
796
+ for (let i = entries.length - 1;i >= 0; i--) {
797
+ const entry2 = entries[i];
798
+ if (entry2.type === "message" && ((_a = entry2.message) === null || _a === undefined ? undefined : _a.role) === "user") {
799
+ return;
800
+ }
801
+ if (entry2.type === "custom" && entry2.customType === TA_ASK_ENTRY) {
802
+ return read(entry2);
803
+ }
804
+ }
805
+ return;
806
+ }
807
+ TaAskUtil2.asking = asking;
808
+ function next(asked, entry2) {
809
+ var _a;
810
+ if (entry2.type === "message" && ((_a = entry2.message) === null || _a === undefined ? undefined : _a.role) === "user") {
811
+ return;
812
+ }
813
+ return entry2.type === "custom" && entry2.customType === TA_ASK_ENTRY ? read(entry2) : asked;
814
+ }
815
+ TaAskUtil2.next = next;
816
+ function read(found) {
817
+ var _a;
818
+ const question = (_a = found.data) === null || _a === undefined ? undefined : _a.question;
819
+ if (typeof question !== "string" || !question.trim()) {
820
+ return;
821
+ }
822
+ const at = found.timestamp ? Date.parse(found.timestamp) : Number.NaN;
823
+ return { question: entry(question).question, at: Number.isNaN(at) ? 0 : at };
824
+ }
825
+ })(TaAskUtil || (TaAskUtil = {}));
790
826
  // ../ta-protocol/esm/common/team-protocol.js
791
827
  var TA_UNDECLARED = "extensions.install";
792
828
  var TaPermissionUtil;
@@ -1149,12 +1185,12 @@ function PostEditor({ text: first, images, attach: firstAttach, pickPackage, onP
1149
1185
  }, /* @__PURE__ */ React.createElement("span", {
1150
1186
  className: "tmo-editor-label"
1151
1187
  }, t("keep")), /* @__PURE__ */ React.createElement("div", {
1152
- className: "tmo-segments"
1188
+ className: "ta-segmented tmo-segments"
1153
1189
  }, Limits.DAYS.map((value) => /* @__PURE__ */ React.createElement("button", {
1154
1190
  key: value,
1155
1191
  type: "button",
1156
1192
  "aria-pressed": days === value,
1157
- className: `tmo-segment${days === value ? " tmo-on" : ""}`,
1193
+ className: days === value ? "ta-on" : undefined,
1158
1194
  onClick: () => setDays(value)
1159
1195
  }, t(KEEP[value]))))), /* @__PURE__ */ React.createElement("label", {
1160
1196
  className: "tmo-editor-row tmo-editor-check"
@@ -1250,6 +1286,13 @@ class MomentsStore {
1250
1286
  if (latest > this.seen) {
1251
1287
  this.seen = latest;
1252
1288
  this.emit();
1289
+ const kept = await pi.storage.get(Keys.SEEN).catch(() => {
1290
+ return;
1291
+ });
1292
+ if (typeof kept === "number" && kept >= latest) {
1293
+ await this.readSeen();
1294
+ return;
1295
+ }
1253
1296
  await pi.storage.set(Keys.SEEN, latest);
1254
1297
  }
1255
1298
  }
@@ -1356,10 +1399,12 @@ function show(component) {
1356
1399
  }
1357
1400
  pi.ui.custom(component);
1358
1401
  }
1359
- function Face({ id, size = 40 }) {
1402
+ function Face({ id, look, mine, size = 40 }) {
1360
1403
  const Face2 = pi.ui.Face;
1361
1404
  return Face2 ? /* @__PURE__ */ React.createElement(Face2, {
1362
1405
  seed: id,
1406
+ look,
1407
+ double: mine || undefined,
1363
1408
  size
1364
1409
  }) : /* @__PURE__ */ React.createElement("span", {
1365
1410
  className: "tmo-face",
@@ -1625,6 +1670,8 @@ function PostView({ post, me, now }) {
1625
1670
  "data-post": `${post.room}:${post.id}`
1626
1671
  }, /* @__PURE__ */ React.createElement(Face, {
1627
1672
  id: post.author.id,
1673
+ look: post.author.look,
1674
+ mine: post.mine,
1628
1675
  size: 42
1629
1676
  }), /* @__PURE__ */ React.createElement("div", {
1630
1677
  className: "tmo-post-body"
@@ -1726,7 +1773,7 @@ function FriendsRow() {
1726
1773
  }) : null, /* @__PURE__ */ React.createElement("span", {
1727
1774
  className: "tmo-grow"
1728
1775
  }), friends.length > 0 && GroupFace && /* @__PURE__ */ React.createElement(GroupFace, {
1729
- members: friends.slice(0, 4).map((friend) => ({ seed: friend.id })),
1776
+ members: friends.slice(0, 4).map((friend) => ({ seed: friend.id, look: friend.look })),
1730
1777
  size: 24
1731
1778
  }), /* @__PURE__ */ React.createElement("span", {
1732
1779
  className: "tmo-quiet"
@@ -1788,13 +1835,10 @@ function MomentsPage() {
1788
1835
  })) : state.friends.length ? /* @__PURE__ */ React.createElement(pi.ui.Empty, {
1789
1836
  title: t("noPosts"),
1790
1837
  hint: t("noPostsHint")
1791
- }) : /* @__PURE__ */ React.createElement("div", {
1792
- className: "tmo-empty"
1793
- }, /* @__PURE__ */ React.createElement(pi.ui.Empty, {
1838
+ }) : /* @__PURE__ */ React.createElement(pi.ui.Empty, {
1794
1839
  title: t("emptyTitle"),
1795
- hint: t("emptyHint"),
1796
- compact: true
1797
- }), /* @__PURE__ */ React.createElement("button", {
1840
+ hint: t("emptyHint")
1841
+ }, /* @__PURE__ */ React.createElement("button", {
1798
1842
  type: "button",
1799
1843
  className: "ta-button ta-primary",
1800
1844
  onClick: openFriends
@@ -1813,6 +1857,7 @@ function MomentsMark() {
1813
1857
  className: "tmo-mark"
1814
1858
  }, /* @__PURE__ */ React.createElement(Face, {
1815
1859
  id: latest.author.id,
1860
+ look: latest.author.look,
1816
1861
  size: 26
1817
1862
  }), /* @__PURE__ */ React.createElement("i", {
1818
1863
  className: "tmo-mark-dot"
@@ -1838,14 +1883,13 @@ var STYLE = `
1838
1883
  .tmo-head-end { position: absolute; right: 0; top: 50%; transform: translateY(-50%); display: flex; gap: 2px; }
1839
1884
  /* The page: one column, as WeChat's Moments */
1840
1885
  .tmo-page { flex: 1; min-height: 0; height: 100%; overflow-y: auto; overscroll-behavior: none; background: var(--ta-main); color: var(--ta-text); }
1841
- .tmo-feed { display: flex; flex-direction: column; max-width: 640px; margin: 0 auto; padding: 6px 14px calc(28px + env(safe-area-inset-bottom)); box-sizing: border-box; }
1886
+ .tmo-feed { display: flex; flex-direction: column; min-height: 100%; max-width: 640px; margin: 0 auto; padding: 6px 14px calc(28px + env(safe-area-inset-bottom)); box-sizing: border-box; }
1842
1887
  .tmo-card { margin: 4px 0 8px; padding: 2px 8px; border-radius: 14px; background: var(--ta-raised); }
1843
1888
  .tmo-friends-row { display: flex; align-items: center; gap: 8px; min-height: 48px; margin: 2px 0 6px; padding: 0 12px; border: 0; border-radius: 12px; background: var(--ta-raised); color: var(--ta-text); font: inherit; font-size: calc(14px * var(--ta-font-scale)); text-align: left; cursor: pointer; -webkit-tap-highlight-color: transparent; }
1844
1889
  .tmo-friends-row:hover, .tmo-friends-row:active { background: var(--ta-hover); }
1845
1890
  .tmo-friends-label { font-weight: 500; }
1846
1891
  .tmo-friends-row .ta-face { --ta-face-ring: var(--ta-raised); }
1847
1892
  .tmo-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ta-yellow); }
1848
- .tmo-empty { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 48px 0 24px; text-align: center; }
1849
1893
  /* A post: the face, then the name, words, pictures, what to take, when and the heart */
1850
1894
  .tmo-post { display: flex; gap: 12px; padding: 16px 2px 14px; border-bottom: 1px solid var(--ta-border-muted); }
1851
1895
  .tmo-post .ta-face { --ta-face-ring: var(--ta-main); }
@@ -1941,9 +1985,9 @@ var STYLE = `
1941
1985
  .tmo-editor-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
1942
1986
  .tmo-editor-label { flex: none; min-width: 34px; color: var(--ta-muted); font-size: calc(12.5px * var(--ta-font-scale)); }
1943
1987
  .tmo-select { flex: 1; min-width: 0; max-width: 320px; height: 32px; padding: 0 8px; border: 1px solid var(--ta-border-field); border-radius: 8px; background: var(--ta-main); color: var(--ta-text); font: inherit; font-size: calc(13px * var(--ta-font-scale)); }
1944
- .tmo-segments { display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 2px; border-radius: 9px; background: var(--ta-raised); }
1945
- .tmo-segment { min-height: 28px; padding: 0 10px; border: 0; border-radius: 7px; background: none; color: var(--ta-secondary); font: inherit; font-size: calc(12.5px * var(--ta-font-scale)); cursor: pointer; }
1946
- .tmo-segment.tmo-on { background: var(--ta-segment, var(--ta-card)); color: var(--ta-text); box-shadow: 0 1px 2px rgba(0, 0, 0, .12); }
1988
+ /* How long a post stays: the page's segmented control (.ta-segmented), sized to its labels */
1989
+ .tmo-segments { max-width: 100%; }
1990
+ .tmo-segments button { padding: 0 10px; white-space: nowrap; cursor: pointer; }
1947
1991
  .tmo-chip { display: inline-flex; align-items: center; gap: 6px; align-self: flex-start; max-width: 100%; padding: 5px 6px 5px 10px; border-radius: 8px; background: var(--ta-raised); color: var(--ta-secondary); font-size: calc(12.5px * var(--ta-font-scale)); }
1948
1992
  .tmo-chip-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ta-text); }
1949
1993
  .tmo-chip-x { display: grid; place-items: center; width: 20px; height: 20px; padding: 0; border: 0; border-radius: 50%; background: none; color: var(--ta-muted); cursor: pointer; }