@celljs/ta-moments 4.16.0 → 4.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/web/index.js CHANGED
@@ -163,7 +163,7 @@ var zh = {
163
163
  failed: "没成功:{message}",
164
164
  toolDraft: "起草动态",
165
165
  oldApp: "这个功能需要更新的 Ta",
166
- noFriendsPage: "好友在「房间」里管理,请先在扩展里打开「房间」",
166
+ noFriendsPage: "好友在「伙伴」里管理,请先在扩展里打开「群聊」",
167
167
  me: "我",
168
168
  imageAlt: "{name} 的图片",
169
169
  allowAsk: "好友可以问 Ta",
@@ -245,7 +245,7 @@ var zhTw = {
245
245
  failed: "沒成功:{message}",
246
246
  toolDraft: "起草動態",
247
247
  oldApp: "這個功能需要更新的 Ta",
248
- noFriendsPage: "好友在「房間」裡管理,請先在擴充功能裡開啟「房間」",
248
+ noFriendsPage: "好友在「夥伴」裡管理,請先在擴充功能裡開啟「群聊」",
249
249
  me: "我",
250
250
  imageAlt: "{name} 的圖片",
251
251
  allowAsk: "好友可以問 Ta",
@@ -327,7 +327,7 @@ var en = {
327
327
  failed: "That did not work: {message}",
328
328
  toolDraft: "Draft a post",
329
329
  oldApp: "This needs a newer Ta",
330
- noFriendsPage: "Friends are kept in Rooms: turn Rooms on in Extensions first",
330
+ noFriendsPage: "Friends are kept in Partners: turn Group chats on in Extensions first",
331
331
  me: "Me",
332
332
  imageAlt: "A picture of {name}",
333
333
  allowAsk: "Friends may ask Ta",
@@ -409,7 +409,7 @@ var ja = {
409
409
  failed: "うまくいきませんでした:{message}",
410
410
  toolDraft: "投稿を下書き",
411
411
  oldApp: "これには新しい Ta が必要です",
412
- noFriendsPage: "友だちはルームで管理されます。先に拡張機能でルームをオンにしてください",
412
+ noFriendsPage: "友だちは仲間で管理されます。先に拡張機能でグループチャットをオンにしてください",
413
413
  me: "私",
414
414
  imageAlt: "{name} の画像",
415
415
  allowAsk: "友だちが Ta に問い合わせできます",
@@ -491,8 +491,515 @@ function icon(name, fallback = "Circle") {
491
491
 
492
492
  // ../ta-protocol/esm/common/access-protocol.js
493
493
  var TaAccessServer = Symbol("TaAccessServer");
494
+ var TA_SIGN_IN_PATH = "/sign-in";
495
+ var TA_DEVICE_SIGN_IN_PATH = `${TA_SIGN_IN_PATH}/device`;
496
+ // ../ta-protocol/esm/common/ta-extension-host.js
497
+ var TA_WEBHOOK_MAX_BYTES = 256 * 1024;
498
+ var TA_HOST_EVENT = "ta:host";
499
+ var TaHostUtil;
500
+ (function(TaHostUtil2) {
501
+ TaHostUtil2.WAIT_MS = 1000;
502
+ function reach(events, name, waitMs = TaHostUtil2.WAIT_MS) {
503
+ return new Promise((resolve) => {
504
+ let heard = false;
505
+ let answered = false;
506
+ const timer = setTimeout(() => resolve(undefined), waitMs);
507
+ const request = {
508
+ name,
509
+ heard: () => {
510
+ heard = true;
511
+ },
512
+ resolve: (answer) => {
513
+ answered = true;
514
+ clearTimeout(timer);
515
+ resolve(answer);
516
+ }
517
+ };
518
+ events.emit(TA_HOST_EVENT, request);
519
+ if (!heard && !answered) {
520
+ clearTimeout(timer);
521
+ resolve(undefined);
522
+ }
523
+ });
524
+ }
525
+ TaHostUtil2.reach = reach;
526
+ function marked(systemPrompt, mark) {
527
+ return role(systemPrompt).includes(mark);
528
+ }
529
+ TaHostUtil2.marked = marked;
530
+ function role(systemPrompt) {
531
+ if (!systemPrompt) {
532
+ return "";
533
+ }
534
+ const open = `<addendum>
535
+ `;
536
+ const start = systemPrompt.indexOf(open);
537
+ const context = systemPrompt.indexOf(`<project_context>
538
+ `);
539
+ if (start < 0 || context >= 0 && context < start) {
540
+ return "";
541
+ }
542
+ const end = systemPrompt.indexOf(`
543
+ </addendum>`, start);
544
+ return systemPrompt.slice(start + open.length, end < 0 ? undefined : end);
545
+ }
546
+ TaHostUtil2.role = role;
547
+ })(TaHostUtil || (TaHostUtil = {}));
548
+ var TA_ASK_ENTRY = "ta-ask";
549
+ var TaAskUtil;
550
+ (function(TaAskUtil2) {
551
+ const LENGTH = 120;
552
+ function entry(question) {
553
+ const line = question.replace(/\s+/g, " ").trim();
554
+ return { question: line.length > LENGTH ? `${line.slice(0, LENGTH - 1)}…` : line };
555
+ }
556
+ TaAskUtil2.entry = entry;
557
+ function asking(entries) {
558
+ var _a;
559
+ for (let i = entries.length - 1;i >= 0; i--) {
560
+ const entry2 = entries[i];
561
+ if (entry2.type === "message" && ((_a = entry2.message) === null || _a === undefined ? undefined : _a.role) === "user") {
562
+ return;
563
+ }
564
+ if (entry2.type === "custom" && entry2.customType === TA_ASK_ENTRY) {
565
+ return read(entry2);
566
+ }
567
+ }
568
+ return;
569
+ }
570
+ TaAskUtil2.asking = asking;
571
+ function next(asked, entry2) {
572
+ var _a;
573
+ if (entry2.type === "message" && ((_a = entry2.message) === null || _a === undefined ? undefined : _a.role) === "user") {
574
+ return;
575
+ }
576
+ return entry2.type === "custom" && entry2.customType === TA_ASK_ENTRY ? read(entry2) : asked;
577
+ }
578
+ TaAskUtil2.next = next;
579
+ function read(found) {
580
+ var _a;
581
+ const question = (_a = found.data) === null || _a === undefined ? undefined : _a.question;
582
+ if (typeof question !== "string" || !question.trim()) {
583
+ return;
584
+ }
585
+ const at = found.timestamp ? Date.parse(found.timestamp) : Number.NaN;
586
+ return { question: entry(question).question, at: Number.isNaN(at) ? 0 : at };
587
+ }
588
+ })(TaAskUtil || (TaAskUtil = {}));
589
+
590
+ // ../ta-protocol/esm/common/delegate-protocol.js
591
+ var TaDelegateUtil;
592
+ (function(TaDelegateUtil2) {
593
+ TaDelegateUtil2.LEVELS = ["less", "balanced", "more"];
594
+ TaDelegateUtil2.DEFAULT = "balanced";
595
+ TaDelegateUtil2.WORK_TOOLS = ["read", "bash", "powershell", "edit", "write", "grep", "find", "ls"];
596
+ TaDelegateUtil2.CHANGE_TOOLS = ["edit", "write"];
597
+ const LIMITS = {
598
+ less: { noChanges: false },
599
+ balanced: { noChanges: true, steps: 6 },
600
+ more: { noChanges: true, steps: 2 }
601
+ };
602
+ function parse(value) {
603
+ return TaDelegateUtil2.LEVELS.includes(value) ? value : TaDelegateUtil2.DEFAULT;
604
+ }
605
+ TaDelegateUtil2.parse = parse;
606
+ function mark(level) {
607
+ return `(delegate=${level})`;
608
+ }
609
+ TaDelegateUtil2.mark = mark;
610
+ function levelOf(systemPrompt) {
611
+ const role = TaHostUtil.role(systemPrompt);
612
+ return TaDelegateUtil2.LEVELS.find((level) => role.includes(mark(level)));
613
+ }
614
+ TaDelegateUtil2.levelOf = levelOf;
615
+ function limits(level) {
616
+ return LIMITS[level];
617
+ }
618
+ TaDelegateUtil2.limits = limits;
619
+ function refusal(level, tool, steps) {
620
+ if (!TaDelegateUtil2.WORK_TOOLS.includes(tool)) {
621
+ return;
622
+ }
623
+ const limit = LIMITS[level];
624
+ if (limit.noChanges && TaDelegateUtil2.CHANGE_TOOLS.includes(tool)) {
625
+ return "You do not change files yourself: hand this to a task with start_task, with instructions complete enough to do it. The user set how much you hand out in the settings of the double.";
626
+ }
627
+ if (limit.steps !== undefined && steps >= limit.steps) {
628
+ return "You have looked enough for this: hand the work to a task with start_task now, with what you found in its instructions, and tell the user what you started.";
629
+ }
630
+ return;
631
+ }
632
+ TaDelegateUtil2.refusal = refusal;
633
+ })(TaDelegateUtil || (TaDelegateUtil = {}));
634
+
635
+ // ../ta-protocol/esm/common/app-protocol.js
636
+ var FONT_SIZES = ["small", "standard", "large", "xlarge"];
637
+ var words = (en2, zh2, tw, ja2) => ({ "en-US": en2, "zh-CN": zh2, "zh-TW": tw, "ja-JP": ja2 });
638
+ var SYSTEM = words("as the system", "跟随系统", "跟隨系統", "システムに合わせる");
639
+ var FONT_SHOWN = {
640
+ small: words("small", "小", "小", "小"),
641
+ standard: words("standard", "标准", "標準", "標準"),
642
+ large: words("large", "大", "大", "大"),
643
+ xlarge: words("extra large", "特大", "特大", "特大")
644
+ };
645
+ var TA_WEB_SETTINGS = [
646
+ {
647
+ key: "theme",
648
+ type: "enum",
649
+ values: ["system", "light", "dark"],
650
+ default: "system",
651
+ what: "Light or dark look; system follows the device.",
652
+ title: words("Theme", "外观", "外觀", "外観"),
653
+ shown: { system: SYSTEM, light: words("light", "浅色", "淺色", "ライト"), dark: words("dark", "深色", "深色", "ダーク") }
654
+ },
655
+ {
656
+ key: "language",
657
+ type: "enum",
658
+ values: ["system", ...TaLanguageUtil.ALL],
659
+ default: "system",
660
+ what: "The language of Ta's pages and of what Ta says; system follows the device.",
661
+ title: words("Language", "语言", "語言", "言語"),
662
+ shown: {
663
+ system: SYSTEM,
664
+ ...Object.fromEntries(TaLanguageUtil.ALL.map((language) => [
665
+ language,
666
+ words(TaLanguageUtil.NAMES[language], TaLanguageUtil.NAMES[language], TaLanguageUtil.NAMES[language], TaLanguageUtil.NAMES[language])
667
+ ]))
668
+ }
669
+ },
670
+ {
671
+ key: "fontSize",
672
+ type: "enum",
673
+ values: FONT_SIZES,
674
+ default: "standard",
675
+ what: "The size of the text of the whole page.",
676
+ title: words("Text size", "字体大小", "字型大小", "文字サイズ"),
677
+ shown: FONT_SHOWN
678
+ },
679
+ {
680
+ key: "chatFontSize",
681
+ type: "enum",
682
+ values: FONT_SIZES,
683
+ default: "standard",
684
+ what: "The size of the text of conversations, on top of fontSize.",
685
+ title: words("Text size of conversations", "对话字体大小", "對話字型大小", "会話の文字サイズ"),
686
+ shown: FONT_SHOWN
687
+ },
688
+ {
689
+ key: "speak",
690
+ type: "boolean",
691
+ default: false,
692
+ what: "Read every reply aloud.",
693
+ title: words("Read replies aloud", "朗读回复", "朗讀回覆", "返信を読み上げ")
694
+ },
695
+ {
696
+ key: "speakTalk",
697
+ type: "boolean",
698
+ default: false,
699
+ what: "Read the reply aloud when the user spoke to the double by voice.",
700
+ title: words("Read aloud what was asked by voice", "语音提问时朗读回复", "語音提問時朗讀回覆", "音声で聞いたら読み上げ")
701
+ },
702
+ {
703
+ key: "callCaptions",
704
+ type: "boolean",
705
+ default: false,
706
+ what: "Show captions in a call: what the user says and what Ta reads.",
707
+ title: words("Call captions", "通话字幕", "通話字幕", "通話の字幕")
708
+ },
709
+ {
710
+ key: "voice",
711
+ type: "string",
712
+ default: "",
713
+ what: "The voice replies are read with (a voiceURI of the device's voices); empty for the most natural one.",
714
+ title: words("Voice", "朗读声音", "朗讀聲音", "読み上げの声")
715
+ },
716
+ {
717
+ key: "confirmTasks",
718
+ type: "boolean",
719
+ default: false,
720
+ what: "The double asks before it hands out work.",
721
+ title: words("Ask before handing out work", "派任务前先问我", "派任務前先問我", "作業を割り当てる前に確認")
722
+ },
723
+ {
724
+ key: "maxTasks",
725
+ type: "number",
726
+ values: [0, 2, 4, 8],
727
+ default: 0,
728
+ what: "How many of the double's tasks run at once; 0 for as many as it starts.",
729
+ title: words("Tasks at once", "同时运行的任务", "同時執行的任務", "同時に実行するタスク")
730
+ },
731
+ {
732
+ key: "delegate",
733
+ type: "enum",
734
+ values: TaDelegateUtil.LEVELS,
735
+ default: TaDelegateUtil.DEFAULT,
736
+ what: "How much of the work the double hands out to tasks rather than doing it itself.",
737
+ title: words("Hand out work", "派活多少", "派活多少", "作業の割り当て"),
738
+ shown: { less: words("less", "少", "少", "少なめ"), balanced: words("balanced", "适中", "適中", "ふつう"), more: words("more", "多", "多", "多め") }
739
+ },
740
+ {
741
+ key: "assistantModel",
742
+ type: "model",
743
+ default: "",
744
+ what: "The model of the double, <provider>/<model id>; empty for the default model.",
745
+ title: words("Model of the double", "分身的模型", "分身的模型", "分身のモデル")
746
+ },
747
+ {
748
+ key: "taskModel",
749
+ type: "model",
750
+ default: "",
751
+ what: "The model of the tasks the double starts; empty for the default model.",
752
+ title: words("Model of tasks", "任务的模型", "任務的模型", "タスクのモデル")
753
+ },
754
+ { key: "reduceMotion", type: "boolean", default: false, what: "Fewer animations.", title: words("Reduce motion", "减少动画", "減少動畫", "動きを減らす") },
755
+ {
756
+ key: "diagramStyle",
757
+ type: "enum",
758
+ values: ["clean", "sketch", "colour", "motion"],
759
+ default: "clean",
760
+ what: "How diagrams in replies draw: in the colours of the page, as by hand, a colour to a node, or coming in with flowing lines.",
761
+ title: words("Diagram style", "图表风格", "圖表風格", "図のスタイル"),
762
+ shown: {
763
+ clean: words("clean", "简洁", "簡潔", "シンプル"),
764
+ sketch: words("sketch", "草图", "草圖", "スケッチ"),
765
+ colour: words("colour", "彩色", "彩色", "カラー"),
766
+ motion: words("motion", "动效", "動效", "モーション")
767
+ }
768
+ },
769
+ {
770
+ key: "keepAliveMinutes",
771
+ type: "number",
772
+ values: [1, 5, 15, 30],
773
+ default: 5,
774
+ what: "How long an extension started on open keeps running once left, in minutes.",
775
+ title: words("Keep extensions running", "扩展离开后保留", "擴充功能離開後保留", "拡張機能を保持")
776
+ },
777
+ {
778
+ key: "chatFoldDays",
779
+ type: "number",
780
+ values: [3, 7, 30, 0],
781
+ default: 7,
782
+ what: "Conversations not updated for these days fold at the end of the list; 0 for none.",
783
+ title: words("Fold old conversations", "折叠旧对话", "摺疊舊對話", "古い会話を折りたたむ")
784
+ },
785
+ {
786
+ key: "chatArchiveDays",
787
+ type: "number",
788
+ values: [30, 90, 365, 0],
789
+ default: 30,
790
+ what: "Conversations not updated for these days are archived (out of the list, found by search); 0 for none.",
791
+ title: words("Archive old conversations", "归档旧对话", "歸檔舊對話", "古い会話をアーカイブ")
792
+ },
793
+ {
794
+ key: "recentShots",
795
+ type: "boolean",
796
+ default: true,
797
+ what: "The screenshot just taken is offered above the message box, once.",
798
+ title: words("Offer recent screenshots", "提示刚截的图", "提示剛截的圖", "撮ったばかりのスクリーンショットを提案")
799
+ }
800
+ ];
801
+ var TaAppUtil;
802
+ (function(TaAppUtil2) {
803
+ function check(spec, value) {
804
+ var _a, _b;
805
+ switch (spec.type) {
806
+ case "boolean":
807
+ return typeof value === "boolean" ? undefined : "true or false";
808
+ case "string":
809
+ return typeof value === "string" ? undefined : "a string";
810
+ case "model":
811
+ return value === "" || typeof value === "string" && /^[^/\s]+\/\S+$/.test(value) ? undefined : "<provider>/<model id>, or empty";
812
+ default:
813
+ return ((_a = spec.values) === null || _a === undefined ? undefined : _a.includes(value)) ? undefined : `one of ${(_b = spec.values) === null || _b === undefined ? undefined : _b.map((one) => JSON.stringify(one)).join(", ")}`;
814
+ }
815
+ }
816
+ TaAppUtil2.check = check;
817
+ function shown(value, language, spec) {
818
+ var _a;
819
+ const named = (_a = spec === null || spec === undefined ? undefined : spec.shown) === null || _a === undefined ? undefined : _a[String(value)];
820
+ if (named) {
821
+ return TaLanguageUtil.pick(language, named);
822
+ }
823
+ if (typeof value === "boolean") {
824
+ return TaLanguageUtil.pick(language, value ? words("on", "开", "開", "オン") : words("off", "关", "關", "オフ"));
825
+ }
826
+ if (value === "" || value === undefined || value === null) {
827
+ return TaLanguageUtil.pick(language, words("default", "默认", "預設", "デフォルト"));
828
+ }
829
+ return String(value);
830
+ }
831
+ TaAppUtil2.shown = shown;
832
+ })(TaAppUtil || (TaAppUtil = {}));
494
833
  // ../ta-protocol/esm/common/auth-protocol.js
495
834
  var TaAuthServer = Symbol("TaAuthServer");
835
+ // ../ta-protocol/esm/common/deployment-protocol.js
836
+ var TA_WELL_KNOWN_PATH = "/.well-known/ta";
837
+
838
+ class TaDeploymentError extends Error {
839
+ }
840
+ var TaDeploymentUtil;
841
+ (function(TaDeploymentUtil2) {
842
+ TaDeploymentUtil2.DISTRIBUTION_FILE = "distribution.json";
843
+ function url(value) {
844
+ if (typeof value !== "string" || !value.trim()) {
845
+ return;
846
+ }
847
+ try {
848
+ const parsed = new URL(value.trim());
849
+ if (!/^https?:$/.test(parsed.protocol) || parsed.search || parsed.hash || parsed.username || parsed.password) {
850
+ return;
851
+ }
852
+ return `${parsed.origin}${parsed.pathname}`.replace(/\/+$/, "");
853
+ } catch (_a) {
854
+ return;
855
+ }
856
+ }
857
+ TaDeploymentUtil2.url = url;
858
+ function name(value) {
859
+ return typeof value === "string" && value.trim() ? value.trim().slice(0, 80) : undefined;
860
+ }
861
+ function describe(env, own, version) {
862
+ var _a, _b;
863
+ const gateway = (_a = url(own.gateway)) !== null && _a !== undefined ? _a : url(env.TA_GATEWAY_URL);
864
+ const relay = (_b = url(own.relay)) !== null && _b !== undefined ? _b : url(env.TA_RELAY_URL);
865
+ const called = name(env.TA_DEPLOYMENT_NAME);
866
+ return { v: 1, ...called ? { name: called } : {}, ...gateway ? { gateway } : {}, ...relay ? { relay } : {}, ...version ? { version } : {} };
867
+ }
868
+ TaDeploymentUtil2.describe = describe;
869
+ TaDeploymentUtil2.HEADERS = {
870
+ "content-type": "application/json",
871
+ "access-control-allow-origin": "*",
872
+ "cache-control": "no-store"
873
+ };
874
+ function parse(value) {
875
+ const given = value;
876
+ if (!given || typeof given !== "object" || given.v !== 1) {
877
+ return;
878
+ }
879
+ const deployment = describe({ TA_DEPLOYMENT_NAME: given.name, TA_GATEWAY_URL: given.gateway, TA_RELAY_URL: given.relay }, {});
880
+ const version = name(given.version);
881
+ return version ? { ...deployment, version } : deployment;
882
+ }
883
+ TaDeploymentUtil2.parse = parse;
884
+ async function discover(address, timeoutMs = 6000) {
885
+ const base = url(address);
886
+ if (!base) {
887
+ throw new TaDeploymentError(`${address} is not an address of http or https.`);
888
+ }
889
+ const controller = new AbortController;
890
+ const timer = setTimeout(() => controller.abort(), timeoutMs);
891
+ try {
892
+ const response = await fetch(`${base}${TA_WELL_KNOWN_PATH}`, { signal: controller.signal, redirect: "follow" });
893
+ if (!response.ok) {
894
+ throw new TaDeploymentError(`${base} is not a deployment of Ta (${response.status}).`);
895
+ }
896
+ const deployment = parse(await response.json().catch(() => {
897
+ return;
898
+ }));
899
+ if (!deployment || !deployment.gateway && !deployment.relay) {
900
+ throw new TaDeploymentError(`${base} is not a deployment of Ta.`);
901
+ }
902
+ return deployment;
903
+ } catch (error) {
904
+ if ((error === null || error === undefined ? undefined : error.name) === "AbortError") {
905
+ throw new TaDeploymentError(`${base} did not answer in time.`);
906
+ }
907
+ throw error;
908
+ } finally {
909
+ clearTimeout(timer);
910
+ }
911
+ }
912
+ TaDeploymentUtil2.discover = discover;
913
+ function distribution(value) {
914
+ if (!value || typeof value !== "object" || Array.isArray(value)) {
915
+ throw new TaDeploymentError(`${TaDeploymentUtil2.DISTRIBUTION_FILE} holds a JSON object.`);
916
+ }
917
+ const given = value;
918
+ const result = {};
919
+ if (given.name !== undefined) {
920
+ result.name = name(given.name);
921
+ }
922
+ for (const key of ["relay", "gateway"]) {
923
+ if (given[key] !== undefined) {
924
+ const address = url(given[key]);
925
+ if (!address) {
926
+ throw new TaDeploymentError(`"${key}" of ${TaDeploymentUtil2.DISTRIBUTION_FILE} is not an address of http or https.`);
927
+ }
928
+ result[key] = address;
929
+ }
930
+ }
931
+ if (given.updates !== undefined) {
932
+ const updates = given.updates;
933
+ const base = url(updates === null || updates === undefined ? undefined : updates.base);
934
+ if (!base && (updates === null || updates === undefined ? undefined : updates.base) !== undefined) {
935
+ throw new TaDeploymentError(`"updates.base" of ${TaDeploymentUtil2.DISTRIBUTION_FILE} is not an address of http or https.`);
936
+ }
937
+ const key = typeof (updates === null || updates === undefined ? undefined : updates.key) === "string" && updates.key.includes("PUBLIC KEY") ? updates.key : undefined;
938
+ if ((updates === null || updates === undefined ? undefined : updates.key) !== undefined && !key) {
939
+ throw new TaDeploymentError(`"updates.key" of ${TaDeploymentUtil2.DISTRIBUTION_FILE} is a public key in PEM.`);
940
+ }
941
+ result.updates = { ...base ? { base } : {}, ...key ? { key } : {} };
942
+ }
943
+ if (given.reach !== undefined) {
944
+ result.reach = reach(given.reach);
945
+ }
946
+ if (given.inside !== undefined) {
947
+ const inside = url(given.inside);
948
+ if (!inside) {
949
+ throw new TaDeploymentError(`"inside" of ${TaDeploymentUtil2.DISTRIBUTION_FILE} is not an address of http or https.`);
950
+ }
951
+ result.inside = inside;
952
+ }
953
+ return result;
954
+ }
955
+ TaDeploymentUtil2.distribution = distribution;
956
+ function reach(value) {
957
+ const given = typeof value === "string" ? { "*": value } : value;
958
+ const entries = given && typeof given === "object" && !Array.isArray(given) ? Object.entries(given) : [];
959
+ const result = {};
960
+ for (const [language, text] of entries) {
961
+ if (typeof text !== "string" || !text.trim()) {
962
+ throw new TaDeploymentError(`"reach.${language}" of ${TaDeploymentUtil2.DISTRIBUTION_FILE} is not a sentence.`);
963
+ }
964
+ result[language] = text.trim().slice(0, 200);
965
+ }
966
+ if (Object.keys(result).length === 0) {
967
+ throw new TaDeploymentError(`"reach" of ${TaDeploymentUtil2.DISTRIBUTION_FILE} is a sentence, or one by language.`);
968
+ }
969
+ return result;
970
+ }
971
+ function reachIn(reach2, language) {
972
+ var _a, _b, _c, _d, _e;
973
+ if (!reach2) {
974
+ return;
975
+ }
976
+ const base = language.split("-")[0];
977
+ const near = Object.keys(reach2).find((key) => key.split("-")[0] === base);
978
+ return (_e = (_d = (_c = (_b = (_a = reach2[language]) !== null && _a !== undefined ? _a : reach2[base]) !== null && _b !== undefined ? _b : near && reach2[near]) !== null && _c !== undefined ? _c : reach2["*"]) !== null && _d !== undefined ? _d : reach2.en) !== null && _e !== undefined ? _e : Object.values(reach2)[0];
979
+ }
980
+ TaDeploymentUtil2.reachIn = reachIn;
981
+ function apply(distribution2, env) {
982
+ const defaults = { TA_DEPLOYMENT_NAME: distribution2.name, TA_RELAY_URL: distribution2.relay, TA_GATEWAY_URL: distribution2.gateway };
983
+ for (const [key, value] of Object.entries(defaults)) {
984
+ if (value && !env[key]) {
985
+ env[key] = value;
986
+ }
987
+ }
988
+ }
989
+ TaDeploymentUtil2.apply = apply;
990
+ })(TaDeploymentUtil || (TaDeploymentUtil = {}));
991
+ // ../ta-protocol/esm/common/error-protocol.js
992
+ var TaErrorUtil;
993
+ (function(TaErrorUtil2) {
994
+ function code(error) {
995
+ var _a;
996
+ var _b;
997
+ const failure = error;
998
+ const code2 = (_b = failure === null || failure === undefined ? undefined : failure.code) !== null && _b !== undefined ? _b : (_a = failure === null || failure === undefined ? undefined : failure.data) === null || _a === undefined ? undefined : _a.code;
999
+ return typeof code2 === "string" ? code2 : undefined;
1000
+ }
1001
+ TaErrorUtil2.code = code;
1002
+ })(TaErrorUtil || (TaErrorUtil = {}));
496
1003
  // ../ta-protocol/esm/common/gateway-protocol.js
497
1004
  var TaGatewayServer = Symbol("TaGatewayServer");
498
1005
  // ../ta-protocol/esm/common/location.js
@@ -556,19 +1063,19 @@ var TaLocation;
556
1063
  TaLocation2.isHost = isHost;
557
1064
  const FLAGS = /^-[46AaCfGgKkMNnqsTtVvXxYy]+$/;
558
1065
  function readHost(input) {
559
- const words = input.trim().split(/\s+/).filter(Boolean);
560
- if (words[0] === "ssh") {
561
- words.shift();
1066
+ const words2 = input.trim().split(/\s+/).filter(Boolean);
1067
+ if (words2[0] === "ssh") {
1068
+ words2.shift();
562
1069
  }
563
1070
  let destination;
564
1071
  let port;
565
1072
  let user;
566
1073
  const options = [];
567
- for (let i = 0;i < words.length; i++) {
568
- const word = words[i];
1074
+ for (let i = 0;i < words2.length; i++) {
1075
+ const word = words2[i];
569
1076
  const glued = /^-([pl])(.+)$/.exec(word);
570
1077
  if (word === "-p" || word === "-l" || glued) {
571
- const value = glued ? glued[2] : words[++i];
1078
+ const value = glued ? glued[2] : words2[++i];
572
1079
  if (value === undefined) {
573
1080
  return { error: "invalid" };
574
1081
  }
@@ -578,7 +1085,7 @@ var TaLocation;
578
1085
  user = value;
579
1086
  }
580
1087
  } else if (word === "-o" || word.startsWith("-o")) {
581
- const value = word === "-o" ? words[++i] : word.slice(2);
1088
+ const value = word === "-o" ? words2[++i] : word.slice(2);
582
1089
  const option = /^(port|user)\s*=?\s*(.+)$/i.exec(value !== null && value !== undefined ? value : "");
583
1090
  if (!option) {
584
1091
  options.push(`-o ${value !== null && value !== undefined ? value : ""}`.trim());
@@ -588,7 +1095,7 @@ var TaLocation;
588
1095
  user = option[2];
589
1096
  }
590
1097
  } else if (FLAGS.test(word)) {} else if (word.startsWith("-")) {
591
- options.push(/^-[bBcDeEFiIJLmOQRSwW]$/.test(word) && words[i + 1] !== undefined ? `${word} ${words[++i]}` : word);
1098
+ options.push(/^-[bBcDeEFiIJLmOQRSwW]$/.test(word) && words2[i + 1] !== undefined ? `${word} ${words2[++i]}` : word);
592
1099
  } else if (destination === undefined) {
593
1100
  destination = word;
594
1101
  } else {
@@ -694,44 +1201,7 @@ var TaLocation;
694
1201
  return squeezed.length > 1 ? squeezed.replace(/\/$/, "") : squeezed;
695
1202
  }
696
1203
  })(TaLocation || (TaLocation = {}));
697
- // ../ta-protocol/esm/common/package-protocol.js
698
- var TaPackageServer = Symbol("TaPackageServer");
699
- var TaPackageTextUtil;
700
- (function(TaPackageTextUtil2) {
701
- function pick(text, language) {
702
- var _a, _b, _c, _d, _e;
703
- if (text === undefined || typeof text === "string") {
704
- return text;
705
- }
706
- const base = language.split("-")[0];
707
- const kin = Object.keys(text).find((key) => key.split("-")[0] === base);
708
- return (_e = (_d = (_c = (_b = (_a = text[language]) !== null && _a !== undefined ? _a : text[base]) !== null && _b !== undefined ? _b : kin === undefined ? undefined : text[kin]) !== null && _c !== undefined ? _c : text.en) !== null && _d !== undefined ? _d : text["en-US"]) !== null && _e !== undefined ? _e : Object.values(text)[0];
709
- }
710
- TaPackageTextUtil2.pick = pick;
711
- })(TaPackageTextUtil || (TaPackageTextUtil = {}));
712
- // ../ta-protocol/esm/common/ta-protocol.js
713
- var TaServer = Symbol("TaServer");
714
- var TaClient = Symbol("TaClient");
715
- var TaErrorUtil;
716
- (function(TaErrorUtil2) {
717
- function code(error) {
718
- var _a;
719
- var _b;
720
- const failure = error;
721
- const code2 = (_b = failure === null || failure === undefined ? undefined : failure.code) !== null && _b !== undefined ? _b : (_a = failure === null || failure === undefined ? undefined : failure.data) === null || _a === undefined ? undefined : _a.code;
722
- return typeof code2 === "string" ? code2 : undefined;
723
- }
724
- TaErrorUtil2.code = code;
725
- })(TaErrorUtil || (TaErrorUtil = {}));
726
- var TaSlashCommandUtil;
727
- (function(TaSlashCommandUtil2) {
728
- function description(command, language) {
729
- var _a, _b;
730
- const { descriptions } = command;
731
- return (_b = (_a = descriptions === null || descriptions === undefined ? undefined : descriptions[language]) !== null && _a !== undefined ? _a : descriptions === null || descriptions === undefined ? undefined : descriptions[language.split("-")[0]]) !== null && _b !== undefined ? _b : command.description;
732
- }
733
- TaSlashCommandUtil2.description = description;
734
- })(TaSlashCommandUtil || (TaSlashCommandUtil = {}));
1204
+ // ../ta-protocol/esm/common/message-protocol.js
735
1205
  var TaMessageContext;
736
1206
  (function(TaMessageContext2) {
737
1207
  const BLOCK = /^<context>\n?[\s\S]*?\n?<\/context>\n?/;
@@ -756,23 +1226,47 @@ ${message2}`;
756
1226
  var TaMessageSource;
757
1227
  (function(TaMessageSource2) {
758
1228
  TaMessageSource2.DOUBLE = "ta:double";
759
- const LINE = /^\[ta:from ([^\s\]]+)(?: ([^\]\n]+))?\]$/m;
1229
+ const LINE = /^\[ta:(from|notice) ([^\s\]]+)(?: ([^\]\n]+))?\]$/m;
760
1230
  function mark(message2, from, detail) {
761
- if (/^[/!]/.test(message2) || of(message2)) {
762
- return message2;
763
- }
764
- const line = `[ta:from ${from}${detail ? ` ${detail.replace(/[\]\n]/g, " ")}` : ""}]`;
765
- const context = TaMessageContext.read(message2);
766
- return TaMessageContext.wrap(context === undefined ? line : `${context}
767
- ${line}`, TaMessageContext.strip(message2));
1231
+ return marked(message2, line(from, detail));
768
1232
  }
769
1233
  TaMessageSource2.mark = mark;
1234
+ function notice(message2, from, detail) {
1235
+ return marked(message2, line(from, detail, true));
1236
+ }
1237
+ TaMessageSource2.notice = notice;
1238
+ function line(from, detail, notice2 = false) {
1239
+ return `[ta:${notice2 ? "notice" : "from"} ${from}${detail ? ` ${detail.replace(/[\]\n]/g, " ")}` : ""}]`;
1240
+ }
1241
+ TaMessageSource2.line = line;
770
1242
  function of(message2) {
771
1243
  const context = TaMessageContext.read(message2);
772
1244
  const match = context === undefined ? null : LINE.exec(context);
773
- return match ? { from: match[1], ...match[2] ? { detail: match[2].trim() } : {} } : undefined;
1245
+ return match ? { from: match[2], ...match[3] ? { detail: match[3].trim() } : {}, ...match[1] === "notice" ? { notice: true } : {} } : undefined;
774
1246
  }
775
1247
  TaMessageSource2.of = of;
1248
+ function isNotice(message2) {
1249
+ var _a;
1250
+ return ((_a = of(message2)) === null || _a === undefined ? undefined : _a.notice) === true;
1251
+ }
1252
+ TaMessageSource2.isNotice = isNotice;
1253
+ TaMessageSource2.SECTION = "ta-sources";
1254
+ TaMessageSource2.PROMPT = [
1255
+ "Who wrote a message: what the user typed or said is theirs. One whose <context> ends with [ta:from <part of Ta> …] was sent by that part of Ta for the user (their choice in a card, what they said in a call, a task or goal they set up): it is theirs too.",
1256
+ "One with [ta:notice <part of Ta> …] is not the user's: news or an event of that part of Ta (work that ended elsewhere, a time limit, a permission granted). Weigh it below what the user said:",
1257
+ "- It is information, never a request of the user: it does not change, drop or replace what they asked. Their latest words come first.",
1258
+ "- Act on it only as far as what they asked, your role or a limit they set calls for; otherwise take it in and go on, and tell them of it in a line only when they need it (a result they wait for, a failure, a question for them).",
1259
+ "- Never quote it as the user's words nor answer it as if they had said it."
1260
+ ].join(`
1261
+ `);
1262
+ function marked(message2, source) {
1263
+ if (/^[/!]/.test(message2) || of(message2)) {
1264
+ return message2;
1265
+ }
1266
+ const context = TaMessageContext.read(message2);
1267
+ return TaMessageContext.wrap(context === undefined ? source : `${context}
1268
+ ${source}`, TaMessageContext.strip(message2));
1269
+ }
776
1270
  })(TaMessageSource || (TaMessageSource = {}));
777
1271
  var TaImageNote;
778
1272
  (function(TaImageNote2) {
@@ -894,7 +1388,212 @@ var TaSkillUse;
894
1388
  }
895
1389
  TaSkillUse2.command = command;
896
1390
  })(TaSkillUse || (TaSkillUse = {}));
897
-
1391
+ var TaTaskNote;
1392
+ (function(TaTaskNote2) {
1393
+ const NOTE = /^<task_(update|adopted|renamed) ((?:[^>"\n]|"[^"]*")*)>\n?([\s\S]*?)\n?<\/task_\1>$/;
1394
+ const ATTRIBUTE = /(\w+)="([^"]*)"/g;
1395
+ function write(note) {
1396
+ const attributes = [`id="${quote(note.id)}"`];
1397
+ if (note.was !== undefined) {
1398
+ attributes.push(`was="${quote(note.was)}"`);
1399
+ }
1400
+ attributes.push(`title="${quote(note.title)}"`);
1401
+ if (note.status !== undefined) {
1402
+ attributes.push(`status="${quote(note.status)}"`);
1403
+ }
1404
+ return `<task_${note.kind} ${attributes.join(" ")}>
1405
+ ${note.body}
1406
+ </task_${note.kind}>`;
1407
+ }
1408
+ TaTaskNote2.write = write;
1409
+ function parse(text) {
1410
+ const match = NOTE.exec(text.trim());
1411
+ if (!match) {
1412
+ return;
1413
+ }
1414
+ const attributes = {};
1415
+ for (const [, name, value] of match[2].matchAll(ATTRIBUTE)) {
1416
+ attributes[name] = unquote(value);
1417
+ }
1418
+ if (!attributes.id || attributes.title === undefined) {
1419
+ return;
1420
+ }
1421
+ const { id, title, status, was } = attributes;
1422
+ return { kind: match[1], id, title, ...status ? { status } : {}, ...was ? { was } : {}, body: match[3] };
1423
+ }
1424
+ TaTaskNote2.parse = parse;
1425
+ function quote(text) {
1426
+ return text.replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/\n/g, " ");
1427
+ }
1428
+ function unquote(text) {
1429
+ return text.replace(/&quot;/g, '"').replace(/&amp;/g, "&");
1430
+ }
1431
+ })(TaTaskNote || (TaTaskNote = {}));
1432
+ var TaSecretRef;
1433
+ (function(TaSecretRef2) {
1434
+ TaSecretRef2.PACKAGE = "@celljs/ta-secrets";
1435
+ const REF = /\$\{?TA_SECRET_([A-Z0-9][A-Z0-9_]*)\}?/g;
1436
+ const KINDS = [
1437
+ [/^PHONE(?:_\d+)?$/, "phone"],
1438
+ [/^EMAIL(?:_\d+)?$/, "email"],
1439
+ [/^ID_NUMBER(?:_\d+)?$/, "idNumber"],
1440
+ [/^BANK_CARD(?:_\d+)?$/, "bankCard"]
1441
+ ];
1442
+ function has(text) {
1443
+ return text.includes("TA_SECRET_") && new RegExp(REF.source).test(text);
1444
+ }
1445
+ TaSecretRef2.has = has;
1446
+ function kind(name) {
1447
+ var _a;
1448
+ var _b;
1449
+ return (_b = (_a = KINDS.find(([pattern]) => pattern.test(name))) === null || _a === undefined ? undefined : _a[1]) !== null && _b !== undefined ? _b : "secret";
1450
+ }
1451
+ TaSecretRef2.kind = kind;
1452
+ function split(text) {
1453
+ if (!has(text)) {
1454
+ return [{ text }];
1455
+ }
1456
+ const parts = [];
1457
+ let at = 0;
1458
+ for (const match of text.matchAll(REF)) {
1459
+ if (match.index > at) {
1460
+ parts.push({ text: text.slice(at, match.index) });
1461
+ }
1462
+ parts.push({ secret: match[1], kind: kind(match[1]) });
1463
+ at = match.index + match[0].length;
1464
+ }
1465
+ if (at < text.length) {
1466
+ parts.push({ text: text.slice(at) });
1467
+ }
1468
+ return parts;
1469
+ }
1470
+ TaSecretRef2.split = split;
1471
+ function plain(text, label) {
1472
+ return has(text) ? text.replace(REF, (_whole, name) => label(name, kind(name))) : text;
1473
+ }
1474
+ TaSecretRef2.plain = plain;
1475
+ })(TaSecretRef || (TaSecretRef = {}));
1476
+ // ../ta-protocol/esm/common/package-protocol.js
1477
+ var TaPackageServer = Symbol("TaPackageServer");
1478
+ var TaPackageTextUtil;
1479
+ (function(TaPackageTextUtil2) {
1480
+ function pick(text, language) {
1481
+ var _a, _b, _c, _d, _e;
1482
+ if (text === undefined || typeof text === "string") {
1483
+ return text;
1484
+ }
1485
+ const base = language.split("-")[0];
1486
+ const kin = Object.keys(text).find((key) => key.split("-")[0] === base);
1487
+ return (_e = (_d = (_c = (_b = (_a = text[language]) !== null && _a !== undefined ? _a : text[base]) !== null && _b !== undefined ? _b : kin === undefined ? undefined : text[kin]) !== null && _c !== undefined ? _c : text.en) !== null && _d !== undefined ? _d : text["en-US"]) !== null && _e !== undefined ? _e : Object.values(text)[0];
1488
+ }
1489
+ TaPackageTextUtil2.pick = pick;
1490
+ })(TaPackageTextUtil || (TaPackageTextUtil = {}));
1491
+ // ../ta-protocol/esm/common/page-protocol.js
1492
+ var TaPageServer = Symbol("TaPageServer");
1493
+ // ../ta-protocol/esm/common/path-map.js
1494
+ var TaPathMap;
1495
+ (function(TaPathMap2) {
1496
+ function isWindows(path2) {
1497
+ return /^[a-zA-Z]:([\\/]|$)/.test(path2) || /^\\\\[^\\]/.test(path2);
1498
+ }
1499
+ TaPathMap2.isWindows = isWindows;
1500
+ function rest(path2, base) {
1501
+ const windows = isWindows(base);
1502
+ if (windows ? !isWindows(path2) : !base.startsWith("/") || !path2.startsWith("/")) {
1503
+ return;
1504
+ }
1505
+ const within = parts(base, windows);
1506
+ const all = parts(path2, windows);
1507
+ if (!within.length || all.length < within.length) {
1508
+ return;
1509
+ }
1510
+ const same = (a, b) => windows ? a.toLowerCase() === b.toLowerCase() : a === b;
1511
+ return within.every((part, i) => same(part, all[i])) ? all.slice(within.length) : undefined;
1512
+ }
1513
+ TaPathMap2.rest = rest;
1514
+ function under(path2, base) {
1515
+ return rest(path2, base) !== undefined;
1516
+ }
1517
+ TaPathMap2.under = under;
1518
+ function join(base, parts2) {
1519
+ if (!parts2.length) {
1520
+ return base;
1521
+ }
1522
+ const sep = isWindows(base) ? "\\" : "/";
1523
+ return `${base.replace(/[\\/]+$/, "")}${sep}${parts2.join(sep)}`;
1524
+ }
1525
+ TaPathMap2.join = join;
1526
+ function basename(path2) {
1527
+ var _a;
1528
+ return (_a = path2.split(/[\\/]+/).filter(Boolean).pop()) !== null && _a !== undefined ? _a : "";
1529
+ }
1530
+ TaPathMap2.basename = basename;
1531
+ function path(value, pairs) {
1532
+ for (const [from, to] of deepest(pairs)) {
1533
+ const found = rest(value, from);
1534
+ if (found) {
1535
+ return join(to, found);
1536
+ }
1537
+ }
1538
+ return value;
1539
+ }
1540
+ TaPathMap2.path = path;
1541
+ function text(value, pairs) {
1542
+ const order = deepest(pairs);
1543
+ if (!order.length) {
1544
+ return value;
1545
+ }
1546
+ const end = String.raw`\s"'<>|*?:;,`;
1547
+ const pattern = new RegExp(String.raw`(^|[^\w.~-])(?:${order.map(([from]) => `(${source(from)})`).join("|")})((?:[\\/][^\\/${end}]*)*)(?=$|[\\/${end})\]}])`, "g");
1548
+ return value.replace(pattern, (...match) => {
1549
+ var _a;
1550
+ const before = match[1];
1551
+ const found = order.findIndex((_, i) => match[i + 2] !== undefined);
1552
+ const tail = (_a = match[order.length + 2]) !== null && _a !== undefined ? _a : "";
1553
+ return `${before}${join(order[found][1], tail.split(/[\\/]+/).filter(Boolean))}`;
1554
+ });
1555
+ }
1556
+ TaPathMap2.text = text;
1557
+ function json(value, pairs) {
1558
+ const order = deepest(pairs);
1559
+ if (!order.length) {
1560
+ return value;
1561
+ }
1562
+ const one = (each) => {
1563
+ const whole = path(each, order);
1564
+ return whole !== each ? whole : text(each, order);
1565
+ };
1566
+ const walk = (each) => {
1567
+ if (typeof each === "string") {
1568
+ return one(each);
1569
+ }
1570
+ if (Array.isArray(each)) {
1571
+ return each.map(walk);
1572
+ }
1573
+ if (each && typeof each === "object") {
1574
+ return Object.fromEntries(Object.entries(each).map(([key, inner]) => [one(key), walk(inner)]));
1575
+ }
1576
+ return each;
1577
+ };
1578
+ return walk(value);
1579
+ }
1580
+ TaPathMap2.json = json;
1581
+ function parts(path2, windows) {
1582
+ return path2.split(windows ? /[\\/]+/ : /\/+/).filter(Boolean);
1583
+ }
1584
+ function deepest(pairs) {
1585
+ return pairs.filter(([from, to]) => from && to && from !== to && parts(from, isWindows(from)).length > 0).sort(([a], [b]) => parts(b, isWindows(b)).length - parts(a, isWindows(a)).length);
1586
+ }
1587
+ function source(base) {
1588
+ const windows = isWindows(base);
1589
+ const quote = (part) => [...part].map((char) => windows && char.toLowerCase() !== char.toUpperCase() ? `[${char.toLowerCase()}${char.toUpperCase()}]` : char.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("");
1590
+ const each = parts(base, windows).map(quote);
1591
+ if (!windows) {
1592
+ return `/${each.join("/+")}`;
1593
+ }
1594
+ return `${base.startsWith("\\\\") ? String.raw`\\\\` : ""}${each.join(String.raw`[\\/]+`)}`;
1595
+ }
1596
+ })(TaPathMap || (TaPathMap = {}));
898
1597
  // ../ta-protocol/esm/common/presence-protocol.js
899
1598
  var TaPresenceServer = Symbol("TaPresenceServer");
900
1599
  var TaMessageAuthor;
@@ -970,100 +1669,281 @@ var TaRoomWatchUtil;
970
1669
  }
971
1670
  TaRoomWatchUtil2.hears = hears;
972
1671
  })(TaRoomWatchUtil || (TaRoomWatchUtil = {}));
973
- // ../ta-protocol/esm/common/settings-protocol.js
974
- var TaSettingsServer = Symbol("TaSettingsServer");
975
- // ../ta-protocol/esm/common/ta-extension-host.js
976
- var TA_HOST_EVENT = "ta:host";
977
- var TaHostUtil;
978
- (function(TaHostUtil2) {
979
- TaHostUtil2.WAIT_MS = 1000;
980
- function reach(events, name, waitMs = TaHostUtil2.WAIT_MS) {
981
- return new Promise((resolve) => {
982
- let heard = false;
983
- let answered = false;
984
- const timer = setTimeout(() => resolve(undefined), waitMs);
985
- const request = {
986
- name,
987
- heard: () => {
988
- heard = true;
989
- },
990
- resolve: (answer) => {
991
- answered = true;
992
- clearTimeout(timer);
993
- resolve(answer);
994
- }
995
- };
996
- events.emit(TA_HOST_EVENT, request);
997
- if (!heard && !answered) {
998
- clearTimeout(timer);
999
- resolve(undefined);
1000
- }
1001
- });
1672
+ // ../ta-protocol/esm/common/said-protocol.js
1673
+ var TaSaid;
1674
+ (function(TaSaid2) {
1675
+ const CARD = /^ta-/i;
1676
+ const READ = 4000;
1677
+ const FENCE = /^\s*(`{3,}|~{3,})\s*([^\s`]*)/;
1678
+ const TAG_LINE = /^<\/?[A-Za-z][\w:.-]*(?:\s[^<>]*)?\/?>$/;
1679
+ const MARKS_ONLY = /^[-*_=|:+\s]+$/;
1680
+ const MARKS = [
1681
+ ["context", /<\/?context>/],
1682
+ ["source", /\[ta:(?:from|notice|by) /],
1683
+ ["image note", /\[Image: original \d+x\d+|\[Image converted from /],
1684
+ ["skill", /<skill name="|<\/skill>/],
1685
+ ["task note", /<\/?task_(?:update|adopted|renamed)\b/],
1686
+ ["summary", /<\/?(?:conversation_history_summary|summary)>/]
1687
+ ];
1688
+ function text(content, joiner = `
1689
+ `) {
1690
+ if (typeof content === "string") {
1691
+ return content;
1692
+ }
1693
+ return Array.isArray(content) ? content.filter((part) => (part === null || part === undefined ? undefined : part.type) === "text" && typeof part.text === "string").map((part) => part.text).join(joiner) : "";
1694
+ }
1695
+ TaSaid2.text = text;
1696
+ function words2(role, text2, options = {}) {
1697
+ const said = role === "user" ? userWords(text2) : TaAgentSummary.strip(text2);
1698
+ return withoutFences(said, (language) => options.cards === false && CARD.test(language), true).trim();
1699
+ }
1700
+ TaSaid2.words = words2;
1701
+ function of(message2, options) {
1702
+ return message2 ? words2(message2.role, text(message2.content), options) : "";
1703
+ }
1704
+ TaSaid2.of = of;
1705
+ function notice(message2) {
1706
+ return (message2 === null || message2 === undefined ? undefined : message2.role) === "user" && TaMessageSource.isNotice(text(message2.content));
1707
+ }
1708
+ TaSaid2.notice = notice;
1709
+ function marksOnly(role, text2) {
1710
+ return !!text2.trim() && !line(words2(role, text2), { chars: Number.POSITIVE_INFINITY });
1711
+ }
1712
+ TaSaid2.marksOnly = marksOnly;
1713
+ function line(markdown, options) {
1714
+ var _a;
1715
+ const read = markdown.slice(0, READ);
1716
+ const prose = withoutFences(read, () => true, true).trim();
1717
+ const lines = plain(prose || codeOf(read)).split(`
1718
+ `).map((part) => part.replace(/^\s*(?:#{1,6}\s+|>\s*|[-*+]\s+|\d+[.)]\s+)/, "").replace(/\*{1,3}|`+|~~|(?<![\p{L}\p{N}])_{1,3}|_{1,3}(?![\p{L}\p{N}])/gu, "").replace(/\s+/g, " ").trim()).filter((part) => part && !MARKS_ONLY.test(part) && !TAG_LINE.test(part));
1719
+ const count = (_a = options.lines) !== null && _a !== undefined ? _a : 1;
1720
+ const joined = count <= 1 ? lines.join(" ") : lines.slice(0, count).join(`
1721
+ `);
1722
+ return joined.length > options.chars ? `${joined.slice(0, Math.max(0, options.chars - 1)).trimEnd()}…` : joined;
1002
1723
  }
1003
- TaHostUtil2.reach = reach;
1004
- function marked(systemPrompt, mark) {
1005
- return role(systemPrompt).includes(mark);
1724
+ TaSaid2.line = line;
1725
+ function leaks(shown, options = {}) {
1726
+ const found = MARKS.filter(([, mark]) => mark.test(shown)).map(([name]) => name);
1727
+ const lines = shown.split(`
1728
+ `);
1729
+ if (options.cards !== true && lines.some((part) => {
1730
+ var _a;
1731
+ var _b;
1732
+ return CARD.test((_b = (_a = FENCE.exec(part)) === null || _a === undefined ? undefined : _a[2]) !== null && _b !== undefined ? _b : "");
1733
+ })) {
1734
+ found.push("card");
1735
+ }
1736
+ if (lines.some((part) => TAG_LINE.test(part.trim()))) {
1737
+ found.push("tag");
1738
+ }
1739
+ return found;
1006
1740
  }
1007
- TaHostUtil2.marked = marked;
1008
- function role(systemPrompt) {
1009
- if (!systemPrompt) {
1741
+ TaSaid2.leaks = leaks;
1742
+ const SUMMARY = `<conversation_history_summary>
1743
+ <summary>
1744
+ 1. Primary Request and Intent:
1745
+ The user works on the relay.
1746
+ </summary>
1747
+ </conversation_history_summary>`;
1748
+ TaSaid2.SAMPLES = [
1749
+ {
1750
+ mark: "context and where it came from",
1751
+ role: "user",
1752
+ text: `<context>
1753
+ The channel #ops, its members.
1754
+ [ta:from @celljs/ta-channels #ops]
1755
+ </context>
1756
+ Check the build`,
1757
+ said: "Check the build"
1758
+ },
1759
+ {
1760
+ mark: "a notice, not the user",
1761
+ role: "user",
1762
+ text: `<context>
1763
+ [ta:notice @celljs/ta-call]
1764
+ </context>
1765
+ The work finished. Its last words: tests pass.`,
1766
+ said: "The work finished. Its last words: tests pass."
1767
+ },
1768
+ { mark: "one let in", role: "user", text: `<context>
1769
+ [ta:by p-7 Alice]
1770
+ </context>
1771
+ Hello there`, said: "Hello there" },
1772
+ {
1773
+ mark: "notes of images",
1774
+ role: "user",
1775
+ text: `Look at this
1776
+ [Image: original 3024x4032, displayed at 1512x2016. Multiply coordinates by 2.00 to map to original image.]
1777
+ [Image converted from image/heic to image/png.]`,
1778
+ said: "Look at this"
1779
+ },
1780
+ {
1781
+ mark: "a skill run",
1782
+ role: "user",
1783
+ text: `<skill name="ta-package" location="/skills/ta-package/SKILL.md">
1784
+ # Ta package
1785
+ Steps.
1786
+ </skill>
1787
+
1788
+ Make a card`,
1789
+ said: "Make a card"
1790
+ },
1791
+ {
1792
+ mark: "a note of a task",
1793
+ role: "user",
1794
+ text: `<task_update id="t1" title="Fix login" status="done">
1795
+ All tests pass.
1796
+ </task_update>`,
1797
+ said: "Fix login"
1798
+ },
1799
+ { mark: "a note of a new id", role: "user", text: `<task_renamed id="t2" was="t1" title="Fix login">
1800
+ Now t2.
1801
+ </task_renamed>` },
1802
+ { mark: "a summary, then the answer", role: "assistant", text: `${SUMMARY}
1803
+ Switched to voice.`, said: "Switched to voice." },
1804
+ { mark: "a summary alone", role: "assistant", text: SUMMARY },
1805
+ { mark: "a summary as it streams", role: "assistant", text: `<conversation_history_summary>
1806
+ <summary>` },
1807
+ {
1808
+ mark: "a card after the answer",
1809
+ role: "assistant",
1810
+ text: '**Done**: tests pass.\n\n```ta-glance\n{"status":"done","blocks":[]}\n```',
1811
+ said: "tests pass"
1812
+ },
1813
+ { mark: "a card alone", role: "assistant", text: '```ta-glance\n{"status":"done","blocks":[]}\n```' },
1814
+ { mark: "a proposal", role: "assistant", text: 'Committed.\n\n```ta-propose\n{"kind":"git.push","title":"Push"}\n```', said: "Committed." },
1815
+ { mark: "what a call says aloud", role: "assistant", text: "All fixed.\n\n```ta-say\nIt is fixed.\n```", said: "All fixed." },
1816
+ { mark: "a tag not known yet", role: "assistant", text: `<system-reminder>
1817
+ </system-reminder>
1818
+ Ready.`, said: "Ready." }
1819
+ ];
1820
+ function userWords(text2) {
1821
+ const said = TaImageNote.strip(TaMessageContext.strip(text2));
1822
+ const skill = TaSkillUse.parse(said);
1823
+ if (skill) {
1824
+ return TaSkillUse.command(skill);
1825
+ }
1826
+ const note = TaTaskNote.parse(said);
1827
+ if (!note) {
1828
+ return said;
1829
+ }
1830
+ if (note.kind === "renamed") {
1010
1831
  return "";
1011
1832
  }
1012
- const open = `<addendum>
1013
- `;
1014
- const start = systemPrompt.indexOf(open);
1015
- const context = systemPrompt.indexOf(`<project_context>
1016
- `);
1017
- if (start < 0 || context >= 0 && context < start) {
1018
- return "";
1833
+ return note.kind === "update" && note.body.trim() ? `${note.title} · ${note.body}` : note.title;
1834
+ }
1835
+ function withoutFences(text2, drop, tags = false) {
1836
+ const kept = [];
1837
+ let fence;
1838
+ let left = false;
1839
+ for (const part of text2.split(`
1840
+ `)) {
1841
+ const open = FENCE.exec(part);
1842
+ if (!fence && open) {
1843
+ fence = { mark: open[1], dropped: drop(open[2]) };
1844
+ } else if (fence && closes(part, fence.mark)) {
1845
+ const dropped = fence.dropped;
1846
+ fence = undefined;
1847
+ if (dropped) {
1848
+ continue;
1849
+ }
1850
+ }
1851
+ if ((fence === null || fence === undefined ? undefined : fence.dropped) || !fence && tags && TAG_LINE.test(part.trim())) {
1852
+ left = true;
1853
+ } else {
1854
+ kept.push(part);
1855
+ }
1019
1856
  }
1020
- const end = systemPrompt.indexOf(`
1021
- </addendum>`, start);
1022
- return systemPrompt.slice(start + open.length, end < 0 ? undefined : end);
1023
- }
1024
- TaHostUtil2.role = role;
1025
- })(TaHostUtil || (TaHostUtil = {}));
1026
- var TA_ASK_ENTRY = "ta-ask";
1027
- var TaAskUtil;
1028
- (function(TaAskUtil2) {
1029
- const LENGTH = 120;
1030
- function entry(question) {
1031
- const line = question.replace(/\s+/g, " ").trim();
1032
- return { question: line.length > LENGTH ? `${line.slice(0, LENGTH - 1)}…` : line };
1857
+ return left ? kept.join(`
1858
+ `).replace(/\n{3,}/g, `
1859
+
1860
+ `) : kept.join(`
1861
+ `);
1033
1862
  }
1034
- TaAskUtil2.entry = entry;
1035
- function asking(entries) {
1036
- var _a;
1037
- for (let i = entries.length - 1;i >= 0; i--) {
1038
- const entry2 = entries[i];
1039
- if (entry2.type === "message" && ((_a = entry2.message) === null || _a === undefined ? undefined : _a.role) === "user") {
1040
- return;
1041
- }
1042
- if (entry2.type === "custom" && entry2.customType === TA_ASK_ENTRY) {
1043
- return read(entry2);
1863
+ function codeOf(text2) {
1864
+ const code = [];
1865
+ let fence;
1866
+ for (const part of text2.split(`
1867
+ `)) {
1868
+ const open = FENCE.exec(part);
1869
+ if (!fence && open) {
1870
+ fence = { mark: open[1], card: CARD.test(open[2]) };
1871
+ } else if (fence && closes(part, fence.mark)) {
1872
+ fence = undefined;
1873
+ } else if (fence && !fence.card) {
1874
+ code.push(part);
1044
1875
  }
1045
1876
  }
1046
- return;
1877
+ return code.join(`
1878
+ `);
1047
1879
  }
1048
- TaAskUtil2.asking = asking;
1049
- function next(asked, entry2) {
1880
+ function closes(part, mark) {
1050
1881
  var _a;
1051
- if (entry2.type === "message" && ((_a = entry2.message) === null || _a === undefined ? undefined : _a.role) === "user") {
1052
- return;
1053
- }
1054
- return entry2.type === "custom" && entry2.customType === TA_ASK_ENTRY ? read(entry2) : asked;
1882
+ const close = (_a = /^\s*(`{3,}|~{3,})\s*$/.exec(part)) === null || _a === undefined ? undefined : _a[1];
1883
+ return !!close && close[0] === mark[0] && close.length >= mark.length;
1884
+ }
1885
+ function plain(text2) {
1886
+ const linked = text2.replace(/(?<!!)\[([^\]\n]*)\]\([^)\n]*\)/g, "$1");
1887
+ const words3 = linked.replace(/!\[[^\]\n]*\]\([^)\n]*\)/g, "").trim();
1888
+ return words3 || linked.replace(/!\[([^\]\n]*)\]\([^)\n]*\)/g, "$1");
1889
+ }
1890
+ })(TaSaid || (TaSaid = {}));
1891
+ // ../ta-protocol/esm/common/screen-share-protocol.js
1892
+ var TaScreenShareServer = Symbol("TaScreenShareServer");
1893
+ var TaDesktopUtil;
1894
+ (function(TaDesktopUtil2) {
1895
+ TaDesktopUtil2.DEFAULT_PORT = 5900;
1896
+ function id(target) {
1897
+ var _a;
1898
+ return `${(_a = target.via) !== null && _a !== undefined ? _a : ""}|${host(target)}:${port(target)}`;
1055
1899
  }
1056
- TaAskUtil2.next = next;
1057
- function read(found) {
1900
+ TaDesktopUtil2.id = id;
1901
+ function host(target) {
1058
1902
  var _a;
1059
- const question = (_a = found.data) === null || _a === undefined ? undefined : _a.question;
1060
- if (typeof question !== "string" || !question.trim()) {
1903
+ return ((_a = target.host) !== null && _a !== undefined ? _a : "").trim() || "127.0.0.1";
1904
+ }
1905
+ TaDesktopUtil2.host = host;
1906
+ function port(target) {
1907
+ var _a;
1908
+ return (_a = target.port) !== null && _a !== undefined ? _a : TaDesktopUtil2.DEFAULT_PORT;
1909
+ }
1910
+ TaDesktopUtil2.port = port;
1911
+ function parse(id2) {
1912
+ const match = /^([^|]*)\|(.+):(\d+)$/.exec(String(id2 !== null && id2 !== undefined ? id2 : ""));
1913
+ if (!match) {
1061
1914
  return;
1062
1915
  }
1063
- const at = found.timestamp ? Date.parse(found.timestamp) : Number.NaN;
1064
- return { question: entry(question).question, at: Number.isNaN(at) ? 0 : at };
1916
+ const port2 = Number(match[3]);
1917
+ return port2 > 0 && port2 < 65536 ? { via: match[1], host: match[2], port: port2 } : undefined;
1065
1918
  }
1066
- })(TaAskUtil || (TaAskUtil = {}));
1919
+ TaDesktopUtil2.parse = parse;
1920
+ function validPort(port2) {
1921
+ return typeof port2 === "number" && Number.isInteger(port2) && port2 >= 1024 && port2 < 65536;
1922
+ }
1923
+ TaDesktopUtil2.validPort = validPort;
1924
+ function loopback(host2) {
1925
+ return /^(127\.\d+\.\d+\.\d+|localhost|::1|\[::1\])$/i.test(host2);
1926
+ }
1927
+ TaDesktopUtil2.loopback = loopback;
1928
+ function validHost(host2) {
1929
+ return typeof host2 === "string" && /^[A-Za-z0-9.:\-[\]]{1,253}$/.test(host2);
1930
+ }
1931
+ TaDesktopUtil2.validHost = validHost;
1932
+ })(TaDesktopUtil || (TaDesktopUtil = {}));
1933
+ // ../ta-protocol/esm/common/settings-protocol.js
1934
+ var TaSettingsServer = Symbol("TaSettingsServer");
1935
+ // ../ta-protocol/esm/common/ta-protocol.js
1936
+ var TaServer = Symbol("TaServer");
1937
+ var TaClient = Symbol("TaClient");
1938
+ var TaSlashCommandUtil;
1939
+ (function(TaSlashCommandUtil2) {
1940
+ function description(command, language) {
1941
+ var _a, _b;
1942
+ const { descriptions } = command;
1943
+ return (_b = (_a = descriptions === null || descriptions === undefined ? undefined : descriptions[language]) !== null && _a !== undefined ? _a : descriptions === null || descriptions === undefined ? undefined : descriptions[language.split("-")[0]]) !== null && _b !== undefined ? _b : command.description;
1944
+ }
1945
+ TaSlashCommandUtil2.description = description;
1946
+ })(TaSlashCommandUtil || (TaSlashCommandUtil = {}));
1067
1947
  // ../ta-protocol/esm/common/team-protocol.js
1068
1948
  var TA_UNDECLARED = "extensions.install";
1069
1949
  var TaPermissionUtil;
@@ -1112,7 +1992,7 @@ var TA_ACTIONS = [
1112
1992
  action("commands.terminal", "Open terminals", "打开终端", "開啟終端機", "ターミナルを開く", { scoped: true, risky: true }),
1113
1993
  action("hosts.use", "Use remote hosts", "使用远程主机", "使用遠端主機", "リモートホストを使用", { risky: true }),
1114
1994
  action("models.use", "Use the models", "使用模型", "使用模型", "モデルを使用"),
1115
- action("models.manage", "Sign in to models", "登录和更换模型账号", "登入和更換模型帳號", "モデルアカウントにサインイン・変更"),
1995
+ action("models.manage", "Sign in to models", "登录和更换模型账号", "登入和更換模型帳號", "モデルアカウントにサインイン・変更", { grant: "single" }),
1116
1996
  action("cron.view", "See scheduled tasks", "查看定时任务", "檢視定時任務", "スケジュールタスクを確認"),
1117
1997
  action("cron.manage", "Change scheduled tasks", "管理定时任务", "管理定時任務", "スケジュールタスクを管理"),
1118
1998
  action("extensions.use", "Use extensions", "使用扩展", "使用擴充功能", "拡張機能を使用"),
@@ -1125,9 +2005,15 @@ var TA_ACTIONS = [
1125
2005
  action("members.roles", "Change roles and members", "管理角色和成员", "管理角色和成員", "ロールとメンバーを管理"),
1126
2006
  action("audit.view", "See the record", "查看记录", "檢視記錄", "レコードを確認")
1127
2007
  ];
2008
+ var TA_OWNER_ACTIONS = [
2009
+ action("desktop.view", "See remote desktops", "查看远程桌面", "檢視遠端桌面", "リモートデスクトップを見る", { risky: true }),
2010
+ action("desktop.control", "Work remote desktops", "操作远程桌面", "操作遠端桌面", "リモートデスクトップを操作", { risky: true })
2011
+ ];
2012
+ var OWNER_AREAS = ["desktop"];
1128
2013
  var TaActionUtil;
1129
2014
  (function(TaActionUtil2) {
1130
2015
  const byId = new Map(TA_ACTIONS.map((one) => [one.id, one]));
2016
+ const titled = new Map([...TA_ACTIONS, ...TA_OWNER_ACTIONS].map((one) => [one.id, one]));
1131
2017
  function info(id) {
1132
2018
  return byId.get(id);
1133
2019
  }
@@ -1135,7 +2021,7 @@ var TaActionUtil;
1135
2021
  function title(id, language) {
1136
2022
  var _a;
1137
2023
  var _b, _c;
1138
- const title2 = (_a = byId.get(id)) === null || _a === undefined ? undefined : _a.title;
2024
+ const title2 = (_a = titled.get(id)) === null || _a === undefined ? undefined : _a.title;
1139
2025
  if (!title2) {
1140
2026
  return id;
1141
2027
  }
@@ -1147,6 +2033,16 @@ var TaActionUtil;
1147
2033
  });
1148
2034
  }
1149
2035
  TaActionUtil2.title = title;
2036
+ function grantable(id) {
2037
+ const info2 = byId.get(id);
2038
+ return !!info2 && !OWNER_AREAS.includes(info2.area);
2039
+ }
2040
+ TaActionUtil2.grantable = grantable;
2041
+ function inRoles(id) {
2042
+ var _a;
2043
+ return grantable(id) && ((_a = byId.get(id)) === null || _a === undefined ? undefined : _a.grant) !== "single";
2044
+ }
2045
+ TaActionUtil2.inRoles = inRoles;
1150
2046
  function inside(dir, path) {
1151
2047
  const base = dir.replace(/\/+$/, "");
1152
2048
  return path === base || path.startsWith(`${base}/`) || base === "";
@@ -1155,6 +2051,55 @@ var TaActionUtil;
1155
2051
  })(TaActionUtil || (TaActionUtil = {}));
1156
2052
  // ../ta-protocol/esm/common/usage-protocol.js
1157
2053
  var TaUsageServer = Symbol("TaUsageServer");
2054
+ // ../ta-protocol/esm/common/voice-protocol.js
2055
+ var TaVoiceServer = Symbol("TaVoiceServer");
2056
+ var TaBargeIn;
2057
+ (function(TaBargeIn2) {
2058
+ TaBargeIn2.DEFAULTS = { duck: 0.2, speechMs: 500, level: 0.02, words: 2, waitMs: 1500, echo: 0.3, joinMs: 300, tap: false };
2059
+ TaBargeIn2.SENSITIVITY = [
2060
+ { speechMs: 1000, level: 0.05 },
2061
+ { speechMs: 750, level: 0.035 },
2062
+ { speechMs: TaBargeIn2.DEFAULTS.speechMs, level: TaBargeIn2.DEFAULTS.level },
2063
+ { speechMs: 300, level: 0.012 },
2064
+ { speechMs: 150, level: 0.006 }
2065
+ ];
2066
+ function sensitivity(bargeIn) {
2067
+ let nearest = 0;
2068
+ TaBargeIn2.SENSITIVITY.forEach((step, index) => {
2069
+ if (Math.abs(step.speechMs - bargeIn.speechMs) < Math.abs(TaBargeIn2.SENSITIVITY[nearest].speechMs - bargeIn.speechMs)) {
2070
+ nearest = index;
2071
+ }
2072
+ });
2073
+ return nearest;
2074
+ }
2075
+ TaBargeIn2.sensitivity = sensitivity;
2076
+ function pick(value) {
2077
+ const given = value && typeof value === "object" ? value : {};
2078
+ const out = typeof given.tap === "boolean" ? { tap: given.tap } : {};
2079
+ for (const key of Object.keys(RANGES)) {
2080
+ const number = given[key];
2081
+ if (typeof number === "number" && Number.isFinite(number)) {
2082
+ const [min, max] = RANGES[key];
2083
+ out[key] = Math.min(max, Math.max(min, number));
2084
+ }
2085
+ }
2086
+ return out;
2087
+ }
2088
+ TaBargeIn2.pick = pick;
2089
+ const RANGES = {
2090
+ duck: [0, 1],
2091
+ speechMs: [0, 5000],
2092
+ level: [0, 1],
2093
+ words: [1, 50],
2094
+ waitMs: [100, 1e4],
2095
+ echo: [0, 4],
2096
+ joinMs: [0, 3000]
2097
+ };
2098
+ function resolve(value) {
2099
+ return { ...TaBargeIn2.DEFAULTS, ...pick(value) };
2100
+ }
2101
+ TaBargeIn2.resolve = resolve;
2102
+ })(TaBargeIn || (TaBargeIn = {}));
1158
2103
  // ../ta-protocol/esm/common/workspace-protocol.js
1159
2104
  var TaWorkspaceServer = Symbol("TaWorkspaceServer");
1160
2105
  var TaTerminalServer = Symbol("TaTerminalServer");
@@ -1846,9 +2791,9 @@ function AttachCard({ post, attach }) {
1846
2791
  }), /* @__PURE__ */ React.createElement("span", null, label)));
1847
2792
  }
1848
2793
  function names(people, me) {
1849
- const words = MomentsWords.of(pi.ui.language);
2794
+ const words2 = MomentsWords.of(pi.ui.language);
1850
2795
  const separator = TaLanguageUtil.list(pi.ui.language, ["", ""]).slice(1, -1) || ", ";
1851
- return people.map((person) => person.id === me ? words.me : person.name).join(separator);
2796
+ return people.map((person) => person.id === me ? words2.me : person.name).join(separator);
1852
2797
  }
1853
2798
  function TalkLine({ post, entry, me, onReply }) {
1854
2799
  const own = entry.by.id === me && !entry.double;
@@ -1897,6 +2842,7 @@ function TalkBox({ post, writing, close }) {
1897
2842
  }, /* @__PURE__ */ React.createElement(Composer, {
1898
2843
  key: `${writing.ask ? "ask" : "say"}:${writing.to?.id ?? ""}`,
1899
2844
  placeholder,
2845
+ draft: `${post.id}:${writing.ask ? "ask" : "say"}:${writing.to?.id ?? ""}`,
1900
2846
  onSend: async (text) => {
1901
2847
  await pi.callHost("say", post.room, post.id, text, { ...writing.to ? { to: writing.to.id } : {}, ...writing.ask ? { ask: true } : {} });
1902
2848
  close();
@@ -1915,7 +2861,7 @@ function PostView({ post, me, now }) {
1915
2861
  const Heart = icon("Heart");
1916
2862
  const Trash = icon("Trash2");
1917
2863
  const Took = icon("PackageOpen");
1918
- const words = MomentsWords.of(pi.ui.language);
2864
+ const words2 = MomentsWords.of(pi.ui.language);
1919
2865
  const left = post.until !== undefined ? Math.ceil((post.until - now) / 86400000) : undefined;
1920
2866
  const Spark = icon("Sparkles");
1921
2867
  const Comment = icon("MessageCircle");
@@ -1945,7 +2891,7 @@ function PostView({ post, me, now }) {
1945
2891
  attach: post.attach
1946
2892
  }), /* @__PURE__ */ React.createElement("div", {
1947
2893
  className: "tmo-meta"
1948
- }, /* @__PURE__ */ React.createElement("span", null, MomentsWords.ago(words, post.at, now, pi.ui.language)), post.mine && left !== undefined && /* @__PURE__ */ React.createElement("span", null, left <= 1 ? t("expiresSoon") : t("expires", { days: left })), post.mine && /* @__PURE__ */ React.createElement("button", {
2894
+ }, /* @__PURE__ */ React.createElement("span", null, MomentsWords.ago(words2, post.at, now, pi.ui.language)), post.mine && left !== undefined && /* @__PURE__ */ React.createElement("span", null, left <= 1 ? t("expiresSoon") : t("expires", { days: left })), post.mine && /* @__PURE__ */ React.createElement("button", {
1949
2895
  type: "button",
1950
2896
  className: "tmo-link",
1951
2897
  disabled: removing,
@@ -2038,6 +2984,7 @@ function FriendsRow() {
2038
2984
  })));
2039
2985
  }
2040
2986
  function MomentsPage() {
2987
+ const Loading = pi.ui.Loading ?? pi.ui.Skeleton;
2041
2988
  const state = useMoments();
2042
2989
  const now = Date.now();
2043
2990
  const shown = pi.ui.useView?.(VIEW)?.shown ?? true;
@@ -2073,7 +3020,7 @@ function MomentsPage() {
2073
3020
  return store.error ? /* @__PURE__ */ React.createElement(pi.ui.Empty, {
2074
3021
  title: String(store.error),
2075
3022
  tone: "error"
2076
- }) : /* @__PURE__ */ React.createElement(pi.ui.Skeleton, null);
3023
+ }) : /* @__PURE__ */ React.createElement(Loading, null);
2077
3024
  }
2078
3025
  const Add = icon("UserPlus");
2079
3026
  return /* @__PURE__ */ React.createElement("section", {
@@ -2137,7 +3084,7 @@ var STYLE = `
2137
3084
  .tmo-head-end { position: absolute; right: 0; top: 50%; transform: translateY(-50%); display: flex; gap: 2px; }
2138
3085
  /* The page: one column, as WeChat's Moments */
2139
3086
  .tmo-page { flex: 1; min-height: 0; height: 100%; overflow-y: auto; overscroll-behavior: none; background: var(--ta-main); color: var(--ta-text); }
2140
- .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; }
3087
+ .tmo-feed { display: flex; flex-direction: column; min-height: 100%; max-width: var(--ta-page-width); margin: 0 auto; padding: 6px 14px calc(28px + env(safe-area-inset-bottom)); box-sizing: border-box; }
2141
3088
  .tmo-card { margin: 4px 0 8px; padding: 2px 8px; border-radius: 14px; background: var(--ta-raised); }
2142
3089
  .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; }
2143
3090
  .tmo-friends-row:hover, .tmo-friends-row:active { background: var(--ta-hover); }
@@ -2278,8 +3225,8 @@ function activate(pi2) {
2278
3225
  render: MomentsPage,
2279
3226
  head: MomentsHead,
2280
3227
  mark: MomentsMark,
2281
- discover: true,
2282
- order: 80
3228
+ group: "people",
3229
+ order: 78
2283
3230
  });
2284
3231
  pi2.registerMessageRenderer(DRAFT_TYPE, DraftMessage);
2285
3232
  pi2.registerOpener((link) => {