@celljs/ta-moments 4.13.0 → 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.
@@ -27,6 +27,27 @@ var TaHostUtil;
27
27
  });
28
28
  }
29
29
  TaHostUtil2.reach = reach;
30
+ function marked(systemPrompt, mark) {
31
+ return role(systemPrompt).includes(mark);
32
+ }
33
+ TaHostUtil2.marked = marked;
34
+ function role(systemPrompt) {
35
+ if (!systemPrompt) {
36
+ return "";
37
+ }
38
+ const open = `<addendum>
39
+ `;
40
+ const start = systemPrompt.indexOf(open);
41
+ const context = systemPrompt.indexOf(`<project_context>
42
+ `);
43
+ if (start < 0 || context >= 0 && context < start) {
44
+ return "";
45
+ }
46
+ const end = systemPrompt.indexOf(`
47
+ </addendum>`, start);
48
+ return systemPrompt.slice(start + open.length, end < 0 ? undefined : end);
49
+ }
50
+ TaHostUtil2.role = role;
30
51
  })(TaHostUtil || (TaHostUtil = {}));
31
52
  var TA_WITH_OTHERS_MARK = "[ta:speaks-with-others]";
32
53
  var TA_ASK_ENTRY = "ta-ask";
@@ -319,49 +340,6 @@ var TaPackageTextUtil;
319
340
  }
320
341
  TaPackageTextUtil2.pick = pick;
321
342
  })(TaPackageTextUtil || (TaPackageTextUtil = {}));
322
- // ../ta-protocol/esm/common/relay-protocol.js
323
- var TaRelayServer = Symbol("TaRelayServer");
324
- // ../ta-protocol/esm/common/remote-protocol.js
325
- var TaRemoteServer = Symbol("TaRemoteServer");
326
- // ../ta-protocol/esm/common/room-protocol.js
327
- var TaRoomServer = Symbol("TaRoomServer");
328
- var TA_FRIENDS_KIND = "ta-friends";
329
- var TaRoomWatchUtil;
330
- (function(TaRoomWatchUtil2) {
331
- function of(messages, state) {
332
- const prefixes = Array.isArray(state) ? state.filter((prefix) => typeof prefix === "string" && prefix.length > 0) : [];
333
- return { messages: messages !== false, state: [...new Set(prefixes)].sort() };
334
- }
335
- TaRoomWatchUtil2.of = of;
336
- function union(watches) {
337
- let messages = false;
338
- const state = [];
339
- for (const watch of watches) {
340
- messages || (messages = watch.messages);
341
- state.push(...watch.state);
342
- }
343
- return of(messages, messages ? [] : state);
344
- }
345
- TaRoomWatchUtil2.union = union;
346
- function same(a, b) {
347
- return a === b || !!a && !!b && a.messages === b.messages && a.state.join(`
348
- `) === b.state.join(`
349
- `);
350
- }
351
- TaRoomWatchUtil2.same = same;
352
- function hears(watch, event) {
353
- if (event.type === "message") {
354
- return watch.messages;
355
- }
356
- if (event.type === "state") {
357
- return watch.messages || watch.state.some((prefix) => event.key.startsWith(prefix));
358
- }
359
- return true;
360
- }
361
- TaRoomWatchUtil2.hears = hears;
362
- })(TaRoomWatchUtil || (TaRoomWatchUtil = {}));
363
- // ../ta-protocol/esm/common/settings-protocol.js
364
- var TaSettingsServer = Symbol("TaSettingsServer");
365
343
  // ../ta-protocol/esm/common/ta-protocol.js
366
344
  var TaServer = Symbol("TaServer");
367
345
  var TaClient = Symbol("TaClient");
@@ -547,6 +525,85 @@ var TaSkillUse;
547
525
  }
548
526
  TaSkillUse2.command = command;
549
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");
550
607
  // ../ta-protocol/esm/common/team-protocol.js
551
608
  var TA_UNDECLARED = "extensions.install";
552
609
  var TaPermissionUtil;
@@ -811,7 +868,7 @@ var PostUtil;
811
868
  return [];
812
869
  }
813
870
  const online = owner.self || owner.online;
814
- 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 } : {} };
815
872
  const byMember = new Map(room.members.map((member) => [member.member, member]));
816
873
  const self = room.members.find((member) => member.self);
817
874
  const marks = (prefix, id) => {
@@ -830,7 +887,7 @@ var PostUtil;
830
887
  mine = true;
831
888
  }
832
889
  if (who.id === me || who.id === owner.id || owner.id === me || friends.has(who.id)) {
833
- people.push({ id: who.id, name: who.name });
890
+ people.push({ id: who.id, name: who.name, ...who.look ? { look: who.look } : {} });
834
891
  }
835
892
  }
836
893
  return { people, mine };
@@ -1672,7 +1729,7 @@ function activate(pi) {
1672
1729
  let briefing = false;
1673
1730
  let answering;
1674
1731
  const answers = async (ctx) => {
1675
- answering ??= !!ctx.getSystemPrompt?.().includes(ANSWER_MARK) || !!await (await reach())?.service?.answering(ctx.sessionManager?.getSessionFile())?.catch(() => false);
1732
+ answering ??= TaHostUtil.marked(ctx.getSystemPrompt?.(), ANSWER_MARK) || !!await (await reach())?.service?.answering(ctx.sessionManager?.getSessionFile())?.catch(() => false);
1676
1733
  return answering;
1677
1734
  };
1678
1735
  pi.on("session_start", () => {
@@ -1685,7 +1742,7 @@ function activate(pi) {
1685
1742
  pi.setActiveTools([]);
1686
1743
  return;
1687
1744
  }
1688
- if (event.messageType === "custom" || ctx.getSystemPrompt?.().includes(TA_WITH_OTHERS_MARK)) {
1745
+ if (event.messageType === "custom" || TaHostUtil.marked(ctx.getSystemPrompt?.(), TA_WITH_OTHERS_MARK)) {
1689
1746
  return;
1690
1747
  }
1691
1748
  const level = await (await reach())?.service?.level().catch(() => "ask");
package/host/index.mjs CHANGED
@@ -46,6 +46,27 @@ var TaHostUtil;
46
46
  });
47
47
  }
48
48
  TaHostUtil2.reach = reach;
49
+ function marked(systemPrompt, mark) {
50
+ return role(systemPrompt).includes(mark);
51
+ }
52
+ TaHostUtil2.marked = marked;
53
+ function role(systemPrompt) {
54
+ if (!systemPrompt) {
55
+ return "";
56
+ }
57
+ const open = `<addendum>
58
+ `;
59
+ const start = systemPrompt.indexOf(open);
60
+ const context = systemPrompt.indexOf(`<project_context>
61
+ `);
62
+ if (start < 0 || context >= 0 && context < start) {
63
+ return "";
64
+ }
65
+ const end = systemPrompt.indexOf(`
66
+ </addendum>`, start);
67
+ return systemPrompt.slice(start + open.length, end < 0 ? undefined : end);
68
+ }
69
+ TaHostUtil2.role = role;
49
70
  })(TaHostUtil || (TaHostUtil = {}));
50
71
  var TA_WITH_OTHERS_MARK = "[ta:speaks-with-others]";
51
72
  var TA_BRIEF_SOURCE = "brief";
@@ -346,49 +367,6 @@ var TaLocation;
346
367
  return squeezed.length > 1 ? squeezed.replace(/\/$/, "") : squeezed;
347
368
  }
348
369
  })(TaLocation || (TaLocation = {}));
349
- // ../ta-protocol/esm/common/relay-protocol.js
350
- var TaRelayServer = Symbol("TaRelayServer");
351
- // ../ta-protocol/esm/common/remote-protocol.js
352
- var TaRemoteServer = Symbol("TaRemoteServer");
353
- // ../ta-protocol/esm/common/room-protocol.js
354
- var TaRoomServer = Symbol("TaRoomServer");
355
- var TA_FRIENDS_KIND = "ta-friends";
356
- var TaRoomWatchUtil;
357
- (function(TaRoomWatchUtil2) {
358
- function of(messages, state) {
359
- const prefixes = Array.isArray(state) ? state.filter((prefix) => typeof prefix === "string" && prefix.length > 0) : [];
360
- return { messages: messages !== false, state: [...new Set(prefixes)].sort() };
361
- }
362
- TaRoomWatchUtil2.of = of;
363
- function union(watches) {
364
- let messages = false;
365
- const state = [];
366
- for (const watch of watches) {
367
- messages || (messages = watch.messages);
368
- state.push(...watch.state);
369
- }
370
- return of(messages, messages ? [] : state);
371
- }
372
- TaRoomWatchUtil2.union = union;
373
- function same(a, b) {
374
- return a === b || !!a && !!b && a.messages === b.messages && a.state.join(`
375
- `) === b.state.join(`
376
- `);
377
- }
378
- TaRoomWatchUtil2.same = same;
379
- function hears(watch, event) {
380
- if (event.type === "message") {
381
- return watch.messages;
382
- }
383
- if (event.type === "state") {
384
- return watch.messages || watch.state.some((prefix) => event.key.startsWith(prefix));
385
- }
386
- return true;
387
- }
388
- TaRoomWatchUtil2.hears = hears;
389
- })(TaRoomWatchUtil || (TaRoomWatchUtil = {}));
390
- // ../ta-protocol/esm/common/settings-protocol.js
391
- var TaSettingsServer = Symbol("TaSettingsServer");
392
370
  // ../ta-protocol/esm/common/ta-protocol.js
393
371
  var TaServer = Symbol("TaServer");
394
372
  var TaClient = Symbol("TaClient");
@@ -574,6 +552,85 @@ var TaSkillUse;
574
552
  }
575
553
  TaSkillUse2.command = command;
576
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");
577
634
  // ../ta-protocol/esm/common/team-protocol.js
578
635
  var TA_UNDECLARED = "extensions.install";
579
636
  var TaPermissionUtil;
@@ -833,7 +890,7 @@ var PostUtil;
833
890
  return [];
834
891
  }
835
892
  const online = owner.self || owner.online;
836
- 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 } : {} };
837
894
  const byMember = new Map(room.members.map((member) => [member.member, member]));
838
895
  const self = room.members.find((member) => member.self);
839
896
  const marks = (prefix, id) => {
@@ -852,7 +909,7 @@ var PostUtil;
852
909
  mine = true;
853
910
  }
854
911
  if (who.id === me || who.id === owner.id || owner.id === me || friends.has(who.id)) {
855
- people.push({ id: who.id, name: who.name });
912
+ people.push({ id: who.id, name: who.name, ...who.look ? { look: who.look } : {} });
856
913
  }
857
914
  }
858
915
  return { people, mine };
@@ -1747,7 +1804,7 @@ class MomentsHost {
1747
1804
  }
1748
1805
  return {
1749
1806
  me,
1750
- friends: friends.map(({ id, name }) => ({ id, name })),
1807
+ friends: friends.map(({ id, name, look }) => ({ id, name, ...look ? { look } : {} })),
1751
1808
  asking: requests.length,
1752
1809
  posts: posts.sort((a, b) => b.at - a.at)
1753
1810
  };
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@celljs/ta-moments",
3
- "version": "4.13.0",
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.0",
31
- "@celljs/ta-relay": "4.13.0",
32
- "@celljs/ta-web": "4.13.0",
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,119 +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
- })(TaHostUtil || (TaHostUtil = {}));
543
- var TA_ASK_ENTRY = "ta-ask";
544
- var TaAskUtil;
545
- (function(TaAskUtil2) {
546
- const LENGTH = 120;
547
- function entry(question) {
548
- const line = question.replace(/\s+/g, " ").trim();
549
- return { question: line.length > LENGTH ? `${line.slice(0, LENGTH - 1)}…` : line };
550
- }
551
- TaAskUtil2.entry = entry;
552
- function asking(entries) {
553
- var _a;
554
- for (let i = entries.length - 1;i >= 0; i--) {
555
- const entry2 = entries[i];
556
- if (entry2.type === "message" && ((_a = entry2.message) === null || _a === undefined ? undefined : _a.role) === "user") {
557
- return;
558
- }
559
- if (entry2.type === "custom" && entry2.customType === TA_ASK_ENTRY) {
560
- return read(entry2);
561
- }
562
- }
563
- return;
564
- }
565
- TaAskUtil2.asking = asking;
566
- function next(asked, entry2) {
567
- var _a;
568
- if (entry2.type === "message" && ((_a = entry2.message) === null || _a === undefined ? undefined : _a.role) === "user") {
569
- return;
570
- }
571
- return entry2.type === "custom" && entry2.customType === TA_ASK_ENTRY ? read(entry2) : asked;
572
- }
573
- TaAskUtil2.next = next;
574
- function read(found) {
575
- var _a;
576
- const question = (_a = found.data) === null || _a === undefined ? undefined : _a.question;
577
- if (typeof question !== "string" || !question.trim()) {
578
- return;
579
- }
580
- const at = found.timestamp ? Date.parse(found.timestamp) : Number.NaN;
581
- return { question: entry(question).question, at: Number.isNaN(at) ? 0 : at };
582
- }
583
- })(TaAskUtil || (TaAskUtil = {}));
584
471
  // ../ta-protocol/esm/common/ta-protocol.js
585
472
  var TaServer = Symbol("TaServer");
586
473
  var TaClient = Symbol("TaClient");
@@ -766,6 +653,176 @@ var TaSkillUse;
766
653
  }
767
654
  TaSkillUse2.command = command;
768
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 = {}));
769
826
  // ../ta-protocol/esm/common/team-protocol.js
770
827
  var TA_UNDECLARED = "extensions.install";
771
828
  var TaPermissionUtil;
@@ -1128,12 +1185,12 @@ function PostEditor({ text: first, images, attach: firstAttach, pickPackage, onP
1128
1185
  }, /* @__PURE__ */ React.createElement("span", {
1129
1186
  className: "tmo-editor-label"
1130
1187
  }, t("keep")), /* @__PURE__ */ React.createElement("div", {
1131
- className: "tmo-segments"
1188
+ className: "ta-segmented tmo-segments"
1132
1189
  }, Limits.DAYS.map((value) => /* @__PURE__ */ React.createElement("button", {
1133
1190
  key: value,
1134
1191
  type: "button",
1135
1192
  "aria-pressed": days === value,
1136
- className: `tmo-segment${days === value ? " tmo-on" : ""}`,
1193
+ className: days === value ? "ta-on" : undefined,
1137
1194
  onClick: () => setDays(value)
1138
1195
  }, t(KEEP[value]))))), /* @__PURE__ */ React.createElement("label", {
1139
1196
  className: "tmo-editor-row tmo-editor-check"
@@ -1229,6 +1286,13 @@ class MomentsStore {
1229
1286
  if (latest > this.seen) {
1230
1287
  this.seen = latest;
1231
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
+ }
1232
1296
  await pi.storage.set(Keys.SEEN, latest);
1233
1297
  }
1234
1298
  }
@@ -1335,10 +1399,12 @@ function show(component) {
1335
1399
  }
1336
1400
  pi.ui.custom(component);
1337
1401
  }
1338
- function Face({ id, size = 40 }) {
1402
+ function Face({ id, look, mine, size = 40 }) {
1339
1403
  const Face2 = pi.ui.Face;
1340
1404
  return Face2 ? /* @__PURE__ */ React.createElement(Face2, {
1341
1405
  seed: id,
1406
+ look,
1407
+ double: mine || undefined,
1342
1408
  size
1343
1409
  }) : /* @__PURE__ */ React.createElement("span", {
1344
1410
  className: "tmo-face",
@@ -1604,6 +1670,8 @@ function PostView({ post, me, now }) {
1604
1670
  "data-post": `${post.room}:${post.id}`
1605
1671
  }, /* @__PURE__ */ React.createElement(Face, {
1606
1672
  id: post.author.id,
1673
+ look: post.author.look,
1674
+ mine: post.mine,
1607
1675
  size: 42
1608
1676
  }), /* @__PURE__ */ React.createElement("div", {
1609
1677
  className: "tmo-post-body"
@@ -1705,7 +1773,7 @@ function FriendsRow() {
1705
1773
  }) : null, /* @__PURE__ */ React.createElement("span", {
1706
1774
  className: "tmo-grow"
1707
1775
  }), friends.length > 0 && GroupFace && /* @__PURE__ */ React.createElement(GroupFace, {
1708
- members: friends.slice(0, 4).map((friend) => ({ seed: friend.id })),
1776
+ members: friends.slice(0, 4).map((friend) => ({ seed: friend.id, look: friend.look })),
1709
1777
  size: 24
1710
1778
  }), /* @__PURE__ */ React.createElement("span", {
1711
1779
  className: "tmo-quiet"
@@ -1767,13 +1835,10 @@ function MomentsPage() {
1767
1835
  })) : state.friends.length ? /* @__PURE__ */ React.createElement(pi.ui.Empty, {
1768
1836
  title: t("noPosts"),
1769
1837
  hint: t("noPostsHint")
1770
- }) : /* @__PURE__ */ React.createElement("div", {
1771
- className: "tmo-empty"
1772
- }, /* @__PURE__ */ React.createElement(pi.ui.Empty, {
1838
+ }) : /* @__PURE__ */ React.createElement(pi.ui.Empty, {
1773
1839
  title: t("emptyTitle"),
1774
- hint: t("emptyHint"),
1775
- compact: true
1776
- }), /* @__PURE__ */ React.createElement("button", {
1840
+ hint: t("emptyHint")
1841
+ }, /* @__PURE__ */ React.createElement("button", {
1777
1842
  type: "button",
1778
1843
  className: "ta-button ta-primary",
1779
1844
  onClick: openFriends
@@ -1792,6 +1857,7 @@ function MomentsMark() {
1792
1857
  className: "tmo-mark"
1793
1858
  }, /* @__PURE__ */ React.createElement(Face, {
1794
1859
  id: latest.author.id,
1860
+ look: latest.author.look,
1795
1861
  size: 26
1796
1862
  }), /* @__PURE__ */ React.createElement("i", {
1797
1863
  className: "tmo-mark-dot"
@@ -1817,14 +1883,13 @@ var STYLE = `
1817
1883
  .tmo-head-end { position: absolute; right: 0; top: 50%; transform: translateY(-50%); display: flex; gap: 2px; }
1818
1884
  /* The page: one column, as WeChat's Moments */
1819
1885
  .tmo-page { flex: 1; min-height: 0; height: 100%; overflow-y: auto; overscroll-behavior: none; background: var(--ta-main); color: var(--ta-text); }
1820
- .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; }
1821
1887
  .tmo-card { margin: 4px 0 8px; padding: 2px 8px; border-radius: 14px; background: var(--ta-raised); }
1822
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; }
1823
1889
  .tmo-friends-row:hover, .tmo-friends-row:active { background: var(--ta-hover); }
1824
1890
  .tmo-friends-label { font-weight: 500; }
1825
1891
  .tmo-friends-row .ta-face { --ta-face-ring: var(--ta-raised); }
1826
1892
  .tmo-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ta-yellow); }
1827
- .tmo-empty { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 48px 0 24px; text-align: center; }
1828
1893
  /* A post: the face, then the name, words, pictures, what to take, when and the heart */
1829
1894
  .tmo-post { display: flex; gap: 12px; padding: 16px 2px 14px; border-bottom: 1px solid var(--ta-border-muted); }
1830
1895
  .tmo-post .ta-face { --ta-face-ring: var(--ta-main); }
@@ -1920,9 +1985,9 @@ var STYLE = `
1920
1985
  .tmo-editor-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
1921
1986
  .tmo-editor-label { flex: none; min-width: 34px; color: var(--ta-muted); font-size: calc(12.5px * var(--ta-font-scale)); }
1922
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)); }
1923
- .tmo-segments { display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 2px; border-radius: 9px; background: var(--ta-raised); }
1924
- .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; }
1925
- .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; }
1926
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)); }
1927
1992
  .tmo-chip-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ta-text); }
1928
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; }