@celljs/ta-moments 4.16.0 → 4.17.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/extension/index.mjs +702 -191
- package/host/index.mjs +1361 -837
- package/package.json +4 -4
- package/web/index.js +648 -144
package/web/index.js
CHANGED
|
@@ -491,8 +491,464 @@ function icon(name, fallback = "Circle") {
|
|
|
491
491
|
|
|
492
492
|
// ../ta-protocol/esm/common/access-protocol.js
|
|
493
493
|
var TaAccessServer = Symbol("TaAccessServer");
|
|
494
|
+
// ../ta-protocol/esm/common/ta-extension-host.js
|
|
495
|
+
var TA_WEBHOOK_MAX_BYTES = 256 * 1024;
|
|
496
|
+
var TA_HOST_EVENT = "ta:host";
|
|
497
|
+
var TaHostUtil;
|
|
498
|
+
(function(TaHostUtil2) {
|
|
499
|
+
TaHostUtil2.WAIT_MS = 1000;
|
|
500
|
+
function reach(events, name, waitMs = TaHostUtil2.WAIT_MS) {
|
|
501
|
+
return new Promise((resolve) => {
|
|
502
|
+
let heard = false;
|
|
503
|
+
let answered = false;
|
|
504
|
+
const timer = setTimeout(() => resolve(undefined), waitMs);
|
|
505
|
+
const request = {
|
|
506
|
+
name,
|
|
507
|
+
heard: () => {
|
|
508
|
+
heard = true;
|
|
509
|
+
},
|
|
510
|
+
resolve: (answer) => {
|
|
511
|
+
answered = true;
|
|
512
|
+
clearTimeout(timer);
|
|
513
|
+
resolve(answer);
|
|
514
|
+
}
|
|
515
|
+
};
|
|
516
|
+
events.emit(TA_HOST_EVENT, request);
|
|
517
|
+
if (!heard && !answered) {
|
|
518
|
+
clearTimeout(timer);
|
|
519
|
+
resolve(undefined);
|
|
520
|
+
}
|
|
521
|
+
});
|
|
522
|
+
}
|
|
523
|
+
TaHostUtil2.reach = reach;
|
|
524
|
+
function marked(systemPrompt, mark) {
|
|
525
|
+
return role(systemPrompt).includes(mark);
|
|
526
|
+
}
|
|
527
|
+
TaHostUtil2.marked = marked;
|
|
528
|
+
function role(systemPrompt) {
|
|
529
|
+
if (!systemPrompt) {
|
|
530
|
+
return "";
|
|
531
|
+
}
|
|
532
|
+
const open = `<addendum>
|
|
533
|
+
`;
|
|
534
|
+
const start = systemPrompt.indexOf(open);
|
|
535
|
+
const context = systemPrompt.indexOf(`<project_context>
|
|
536
|
+
`);
|
|
537
|
+
if (start < 0 || context >= 0 && context < start) {
|
|
538
|
+
return "";
|
|
539
|
+
}
|
|
540
|
+
const end = systemPrompt.indexOf(`
|
|
541
|
+
</addendum>`, start);
|
|
542
|
+
return systemPrompt.slice(start + open.length, end < 0 ? undefined : end);
|
|
543
|
+
}
|
|
544
|
+
TaHostUtil2.role = role;
|
|
545
|
+
})(TaHostUtil || (TaHostUtil = {}));
|
|
546
|
+
var TA_ASK_ENTRY = "ta-ask";
|
|
547
|
+
var TaAskUtil;
|
|
548
|
+
(function(TaAskUtil2) {
|
|
549
|
+
const LENGTH = 120;
|
|
550
|
+
function entry(question) {
|
|
551
|
+
const line = question.replace(/\s+/g, " ").trim();
|
|
552
|
+
return { question: line.length > LENGTH ? `${line.slice(0, LENGTH - 1)}…` : line };
|
|
553
|
+
}
|
|
554
|
+
TaAskUtil2.entry = entry;
|
|
555
|
+
function asking(entries) {
|
|
556
|
+
var _a;
|
|
557
|
+
for (let i = entries.length - 1;i >= 0; i--) {
|
|
558
|
+
const entry2 = entries[i];
|
|
559
|
+
if (entry2.type === "message" && ((_a = entry2.message) === null || _a === undefined ? undefined : _a.role) === "user") {
|
|
560
|
+
return;
|
|
561
|
+
}
|
|
562
|
+
if (entry2.type === "custom" && entry2.customType === TA_ASK_ENTRY) {
|
|
563
|
+
return read(entry2);
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
return;
|
|
567
|
+
}
|
|
568
|
+
TaAskUtil2.asking = asking;
|
|
569
|
+
function next(asked, entry2) {
|
|
570
|
+
var _a;
|
|
571
|
+
if (entry2.type === "message" && ((_a = entry2.message) === null || _a === undefined ? undefined : _a.role) === "user") {
|
|
572
|
+
return;
|
|
573
|
+
}
|
|
574
|
+
return entry2.type === "custom" && entry2.customType === TA_ASK_ENTRY ? read(entry2) : asked;
|
|
575
|
+
}
|
|
576
|
+
TaAskUtil2.next = next;
|
|
577
|
+
function read(found) {
|
|
578
|
+
var _a;
|
|
579
|
+
const question = (_a = found.data) === null || _a === undefined ? undefined : _a.question;
|
|
580
|
+
if (typeof question !== "string" || !question.trim()) {
|
|
581
|
+
return;
|
|
582
|
+
}
|
|
583
|
+
const at = found.timestamp ? Date.parse(found.timestamp) : Number.NaN;
|
|
584
|
+
return { question: entry(question).question, at: Number.isNaN(at) ? 0 : at };
|
|
585
|
+
}
|
|
586
|
+
})(TaAskUtil || (TaAskUtil = {}));
|
|
587
|
+
|
|
588
|
+
// ../ta-protocol/esm/common/delegate-protocol.js
|
|
589
|
+
var TaDelegateUtil;
|
|
590
|
+
(function(TaDelegateUtil2) {
|
|
591
|
+
TaDelegateUtil2.LEVELS = ["less", "balanced", "more"];
|
|
592
|
+
TaDelegateUtil2.DEFAULT = "balanced";
|
|
593
|
+
TaDelegateUtil2.WORK_TOOLS = ["read", "bash", "powershell", "edit", "write", "grep", "find", "ls"];
|
|
594
|
+
TaDelegateUtil2.CHANGE_TOOLS = ["edit", "write"];
|
|
595
|
+
const LIMITS = {
|
|
596
|
+
less: { noChanges: false },
|
|
597
|
+
balanced: { noChanges: true, steps: 6 },
|
|
598
|
+
more: { noChanges: true, steps: 2 }
|
|
599
|
+
};
|
|
600
|
+
function parse(value) {
|
|
601
|
+
return TaDelegateUtil2.LEVELS.includes(value) ? value : TaDelegateUtil2.DEFAULT;
|
|
602
|
+
}
|
|
603
|
+
TaDelegateUtil2.parse = parse;
|
|
604
|
+
function mark(level) {
|
|
605
|
+
return `(delegate=${level})`;
|
|
606
|
+
}
|
|
607
|
+
TaDelegateUtil2.mark = mark;
|
|
608
|
+
function levelOf(systemPrompt) {
|
|
609
|
+
const role = TaHostUtil.role(systemPrompt);
|
|
610
|
+
return TaDelegateUtil2.LEVELS.find((level) => role.includes(mark(level)));
|
|
611
|
+
}
|
|
612
|
+
TaDelegateUtil2.levelOf = levelOf;
|
|
613
|
+
function limits(level) {
|
|
614
|
+
return LIMITS[level];
|
|
615
|
+
}
|
|
616
|
+
TaDelegateUtil2.limits = limits;
|
|
617
|
+
function refusal(level, tool, steps) {
|
|
618
|
+
if (!TaDelegateUtil2.WORK_TOOLS.includes(tool)) {
|
|
619
|
+
return;
|
|
620
|
+
}
|
|
621
|
+
const limit = LIMITS[level];
|
|
622
|
+
if (limit.noChanges && TaDelegateUtil2.CHANGE_TOOLS.includes(tool)) {
|
|
623
|
+
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.";
|
|
624
|
+
}
|
|
625
|
+
if (limit.steps !== undefined && steps >= limit.steps) {
|
|
626
|
+
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.";
|
|
627
|
+
}
|
|
628
|
+
return;
|
|
629
|
+
}
|
|
630
|
+
TaDelegateUtil2.refusal = refusal;
|
|
631
|
+
})(TaDelegateUtil || (TaDelegateUtil = {}));
|
|
632
|
+
|
|
633
|
+
// ../ta-protocol/esm/common/app-protocol.js
|
|
634
|
+
var FONT_SIZES = ["small", "standard", "large", "xlarge"];
|
|
635
|
+
var words = (en2, zh2, tw, ja2) => ({ "en-US": en2, "zh-CN": zh2, "zh-TW": tw, "ja-JP": ja2 });
|
|
636
|
+
var SYSTEM = words("as the system", "跟随系统", "跟隨系統", "システムに合わせる");
|
|
637
|
+
var FONT_SHOWN = {
|
|
638
|
+
small: words("small", "小", "小", "小"),
|
|
639
|
+
standard: words("standard", "标准", "標準", "標準"),
|
|
640
|
+
large: words("large", "大", "大", "大"),
|
|
641
|
+
xlarge: words("extra large", "特大", "特大", "特大")
|
|
642
|
+
};
|
|
643
|
+
var TA_WEB_SETTINGS = [
|
|
644
|
+
{
|
|
645
|
+
key: "theme",
|
|
646
|
+
type: "enum",
|
|
647
|
+
values: ["system", "light", "dark"],
|
|
648
|
+
default: "system",
|
|
649
|
+
what: "Light or dark look; system follows the device.",
|
|
650
|
+
title: words("Theme", "外观", "外觀", "外観"),
|
|
651
|
+
shown: { system: SYSTEM, light: words("light", "浅色", "淺色", "ライト"), dark: words("dark", "深色", "深色", "ダーク") }
|
|
652
|
+
},
|
|
653
|
+
{
|
|
654
|
+
key: "language",
|
|
655
|
+
type: "enum",
|
|
656
|
+
values: ["system", ...TaLanguageUtil.ALL],
|
|
657
|
+
default: "system",
|
|
658
|
+
what: "The language of Ta's pages and of what Ta says; system follows the device.",
|
|
659
|
+
title: words("Language", "语言", "語言", "言語"),
|
|
660
|
+
shown: {
|
|
661
|
+
system: SYSTEM,
|
|
662
|
+
...Object.fromEntries(TaLanguageUtil.ALL.map((language) => [
|
|
663
|
+
language,
|
|
664
|
+
words(TaLanguageUtil.NAMES[language], TaLanguageUtil.NAMES[language], TaLanguageUtil.NAMES[language], TaLanguageUtil.NAMES[language])
|
|
665
|
+
]))
|
|
666
|
+
}
|
|
667
|
+
},
|
|
668
|
+
{
|
|
669
|
+
key: "fontSize",
|
|
670
|
+
type: "enum",
|
|
671
|
+
values: FONT_SIZES,
|
|
672
|
+
default: "standard",
|
|
673
|
+
what: "The size of the text of the whole page.",
|
|
674
|
+
title: words("Text size", "字体大小", "字型大小", "文字サイズ"),
|
|
675
|
+
shown: FONT_SHOWN
|
|
676
|
+
},
|
|
677
|
+
{
|
|
678
|
+
key: "chatFontSize",
|
|
679
|
+
type: "enum",
|
|
680
|
+
values: FONT_SIZES,
|
|
681
|
+
default: "standard",
|
|
682
|
+
what: "The size of the text of conversations, on top of fontSize.",
|
|
683
|
+
title: words("Text size of conversations", "对话字体大小", "對話字型大小", "会話の文字サイズ"),
|
|
684
|
+
shown: FONT_SHOWN
|
|
685
|
+
},
|
|
686
|
+
{
|
|
687
|
+
key: "speak",
|
|
688
|
+
type: "boolean",
|
|
689
|
+
default: false,
|
|
690
|
+
what: "Read every reply aloud.",
|
|
691
|
+
title: words("Read replies aloud", "朗读回复", "朗讀回覆", "返信を読み上げ")
|
|
692
|
+
},
|
|
693
|
+
{
|
|
694
|
+
key: "speakTalk",
|
|
695
|
+
type: "boolean",
|
|
696
|
+
default: false,
|
|
697
|
+
what: "Read the reply aloud when the user spoke to the double by voice.",
|
|
698
|
+
title: words("Read aloud what was asked by voice", "语音提问时朗读回复", "語音提問時朗讀回覆", "音声で聞いたら読み上げ")
|
|
699
|
+
},
|
|
700
|
+
{
|
|
701
|
+
key: "callCaptions",
|
|
702
|
+
type: "boolean",
|
|
703
|
+
default: false,
|
|
704
|
+
what: "Show captions in a call: what the user says and what Ta reads.",
|
|
705
|
+
title: words("Call captions", "通话字幕", "通話字幕", "通話の字幕")
|
|
706
|
+
},
|
|
707
|
+
{
|
|
708
|
+
key: "voice",
|
|
709
|
+
type: "string",
|
|
710
|
+
default: "",
|
|
711
|
+
what: "The voice replies are read with (a voiceURI of the device's voices); empty for the most natural one.",
|
|
712
|
+
title: words("Voice", "朗读声音", "朗讀聲音", "読み上げの声")
|
|
713
|
+
},
|
|
714
|
+
{
|
|
715
|
+
key: "confirmTasks",
|
|
716
|
+
type: "boolean",
|
|
717
|
+
default: false,
|
|
718
|
+
what: "The double asks before it hands out work.",
|
|
719
|
+
title: words("Ask before handing out work", "派任务前先问我", "派任務前先問我", "作業を割り当てる前に確認")
|
|
720
|
+
},
|
|
721
|
+
{
|
|
722
|
+
key: "maxTasks",
|
|
723
|
+
type: "number",
|
|
724
|
+
values: [0, 2, 4, 8],
|
|
725
|
+
default: 0,
|
|
726
|
+
what: "How many of the double's tasks run at once; 0 for as many as it starts.",
|
|
727
|
+
title: words("Tasks at once", "同时运行的任务", "同時執行的任務", "同時に実行するタスク")
|
|
728
|
+
},
|
|
729
|
+
{
|
|
730
|
+
key: "delegate",
|
|
731
|
+
type: "enum",
|
|
732
|
+
values: TaDelegateUtil.LEVELS,
|
|
733
|
+
default: TaDelegateUtil.DEFAULT,
|
|
734
|
+
what: "How much of the work the double hands out to tasks rather than doing it itself.",
|
|
735
|
+
title: words("Hand out work", "派活多少", "派活多少", "作業の割り当て"),
|
|
736
|
+
shown: { less: words("less", "少", "少", "少なめ"), balanced: words("balanced", "适中", "適中", "ふつう"), more: words("more", "多", "多", "多め") }
|
|
737
|
+
},
|
|
738
|
+
{
|
|
739
|
+
key: "assistantModel",
|
|
740
|
+
type: "model",
|
|
741
|
+
default: "",
|
|
742
|
+
what: "The model of the double, <provider>/<model id>; empty for the default model.",
|
|
743
|
+
title: words("Model of the double", "分身的模型", "分身的模型", "分身のモデル")
|
|
744
|
+
},
|
|
745
|
+
{
|
|
746
|
+
key: "taskModel",
|
|
747
|
+
type: "model",
|
|
748
|
+
default: "",
|
|
749
|
+
what: "The model of the tasks the double starts; empty for the default model.",
|
|
750
|
+
title: words("Model of tasks", "任务的模型", "任務的模型", "タスクのモデル")
|
|
751
|
+
},
|
|
752
|
+
{ key: "reduceMotion", type: "boolean", default: false, what: "Fewer animations.", title: words("Reduce motion", "减少动画", "減少動畫", "動きを減らす") },
|
|
753
|
+
{
|
|
754
|
+
key: "keepAliveMinutes",
|
|
755
|
+
type: "number",
|
|
756
|
+
values: [1, 5, 15, 30],
|
|
757
|
+
default: 5,
|
|
758
|
+
what: "How long an extension started on open keeps running once left, in minutes.",
|
|
759
|
+
title: words("Keep extensions running", "扩展离开后保留", "擴充功能離開後保留", "拡張機能を保持")
|
|
760
|
+
},
|
|
761
|
+
{
|
|
762
|
+
key: "chatFoldDays",
|
|
763
|
+
type: "number",
|
|
764
|
+
values: [3, 7, 30, 0],
|
|
765
|
+
default: 7,
|
|
766
|
+
what: "Conversations not updated for these days fold at the end of the list; 0 for none.",
|
|
767
|
+
title: words("Fold old conversations", "折叠旧对话", "摺疊舊對話", "古い会話を折りたたむ")
|
|
768
|
+
},
|
|
769
|
+
{
|
|
770
|
+
key: "chatArchiveDays",
|
|
771
|
+
type: "number",
|
|
772
|
+
values: [30, 90, 365, 0],
|
|
773
|
+
default: 30,
|
|
774
|
+
what: "Conversations not updated for these days are archived (out of the list, found by search); 0 for none.",
|
|
775
|
+
title: words("Archive old conversations", "归档旧对话", "歸檔舊對話", "古い会話をアーカイブ")
|
|
776
|
+
},
|
|
777
|
+
{
|
|
778
|
+
key: "recentShots",
|
|
779
|
+
type: "boolean",
|
|
780
|
+
default: true,
|
|
781
|
+
what: "The screenshot just taken is offered above the message box, once.",
|
|
782
|
+
title: words("Offer recent screenshots", "提示刚截的图", "提示剛截的圖", "撮ったばかりのスクリーンショットを提案")
|
|
783
|
+
}
|
|
784
|
+
];
|
|
785
|
+
var TaAppUtil;
|
|
786
|
+
(function(TaAppUtil2) {
|
|
787
|
+
function check(spec, value) {
|
|
788
|
+
var _a, _b;
|
|
789
|
+
switch (spec.type) {
|
|
790
|
+
case "boolean":
|
|
791
|
+
return typeof value === "boolean" ? undefined : "true or false";
|
|
792
|
+
case "string":
|
|
793
|
+
return typeof value === "string" ? undefined : "a string";
|
|
794
|
+
case "model":
|
|
795
|
+
return value === "" || typeof value === "string" && /^[^/\s]+\/\S+$/.test(value) ? undefined : "<provider>/<model id>, or empty";
|
|
796
|
+
default:
|
|
797
|
+
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(", ")}`;
|
|
798
|
+
}
|
|
799
|
+
}
|
|
800
|
+
TaAppUtil2.check = check;
|
|
801
|
+
function shown(value, language, spec) {
|
|
802
|
+
var _a;
|
|
803
|
+
const named = (_a = spec === null || spec === undefined ? undefined : spec.shown) === null || _a === undefined ? undefined : _a[String(value)];
|
|
804
|
+
if (named) {
|
|
805
|
+
return TaLanguageUtil.pick(language, named);
|
|
806
|
+
}
|
|
807
|
+
if (typeof value === "boolean") {
|
|
808
|
+
return TaLanguageUtil.pick(language, value ? words("on", "开", "開", "オン") : words("off", "关", "關", "オフ"));
|
|
809
|
+
}
|
|
810
|
+
if (value === "" || value === undefined || value === null) {
|
|
811
|
+
return TaLanguageUtil.pick(language, words("default", "默认", "預設", "デフォルト"));
|
|
812
|
+
}
|
|
813
|
+
return String(value);
|
|
814
|
+
}
|
|
815
|
+
TaAppUtil2.shown = shown;
|
|
816
|
+
})(TaAppUtil || (TaAppUtil = {}));
|
|
494
817
|
// ../ta-protocol/esm/common/auth-protocol.js
|
|
495
818
|
var TaAuthServer = Symbol("TaAuthServer");
|
|
819
|
+
// ../ta-protocol/esm/common/deployment-protocol.js
|
|
820
|
+
var TA_WELL_KNOWN_PATH = "/.well-known/ta";
|
|
821
|
+
|
|
822
|
+
class TaDeploymentError extends Error {
|
|
823
|
+
}
|
|
824
|
+
var TaDeploymentUtil;
|
|
825
|
+
(function(TaDeploymentUtil2) {
|
|
826
|
+
TaDeploymentUtil2.DISTRIBUTION_FILE = "distribution.json";
|
|
827
|
+
function url(value) {
|
|
828
|
+
if (typeof value !== "string" || !value.trim()) {
|
|
829
|
+
return;
|
|
830
|
+
}
|
|
831
|
+
try {
|
|
832
|
+
const parsed = new URL(value.trim());
|
|
833
|
+
if (!/^https?:$/.test(parsed.protocol) || parsed.search || parsed.hash || parsed.username || parsed.password) {
|
|
834
|
+
return;
|
|
835
|
+
}
|
|
836
|
+
return `${parsed.origin}${parsed.pathname}`.replace(/\/+$/, "");
|
|
837
|
+
} catch (_a) {
|
|
838
|
+
return;
|
|
839
|
+
}
|
|
840
|
+
}
|
|
841
|
+
TaDeploymentUtil2.url = url;
|
|
842
|
+
function name(value) {
|
|
843
|
+
return typeof value === "string" && value.trim() ? value.trim().slice(0, 80) : undefined;
|
|
844
|
+
}
|
|
845
|
+
function describe(env, own, version) {
|
|
846
|
+
var _a, _b;
|
|
847
|
+
const gateway = (_a = url(own.gateway)) !== null && _a !== undefined ? _a : url(env.TA_GATEWAY_URL);
|
|
848
|
+
const relay = (_b = url(own.relay)) !== null && _b !== undefined ? _b : url(env.TA_RELAY_URL);
|
|
849
|
+
const called = name(env.TA_DEPLOYMENT_NAME);
|
|
850
|
+
return { v: 1, ...called ? { name: called } : {}, ...gateway ? { gateway } : {}, ...relay ? { relay } : {}, ...version ? { version } : {} };
|
|
851
|
+
}
|
|
852
|
+
TaDeploymentUtil2.describe = describe;
|
|
853
|
+
TaDeploymentUtil2.HEADERS = {
|
|
854
|
+
"content-type": "application/json",
|
|
855
|
+
"access-control-allow-origin": "*",
|
|
856
|
+
"cache-control": "no-store"
|
|
857
|
+
};
|
|
858
|
+
function parse(value) {
|
|
859
|
+
const given = value;
|
|
860
|
+
if (!given || typeof given !== "object" || given.v !== 1) {
|
|
861
|
+
return;
|
|
862
|
+
}
|
|
863
|
+
const deployment = describe({ TA_DEPLOYMENT_NAME: given.name, TA_GATEWAY_URL: given.gateway, TA_RELAY_URL: given.relay }, {});
|
|
864
|
+
const version = name(given.version);
|
|
865
|
+
return version ? { ...deployment, version } : deployment;
|
|
866
|
+
}
|
|
867
|
+
TaDeploymentUtil2.parse = parse;
|
|
868
|
+
async function discover(address, timeoutMs = 6000) {
|
|
869
|
+
const base = url(address);
|
|
870
|
+
if (!base) {
|
|
871
|
+
throw new TaDeploymentError(`${address} is not an address of http or https.`);
|
|
872
|
+
}
|
|
873
|
+
const controller = new AbortController;
|
|
874
|
+
const timer = setTimeout(() => controller.abort(), timeoutMs);
|
|
875
|
+
try {
|
|
876
|
+
const response = await fetch(`${base}${TA_WELL_KNOWN_PATH}`, { signal: controller.signal, redirect: "follow" });
|
|
877
|
+
if (!response.ok) {
|
|
878
|
+
throw new TaDeploymentError(`${base} is not a deployment of Ta (${response.status}).`);
|
|
879
|
+
}
|
|
880
|
+
const deployment = parse(await response.json().catch(() => {
|
|
881
|
+
return;
|
|
882
|
+
}));
|
|
883
|
+
if (!deployment || !deployment.gateway && !deployment.relay) {
|
|
884
|
+
throw new TaDeploymentError(`${base} is not a deployment of Ta.`);
|
|
885
|
+
}
|
|
886
|
+
return deployment;
|
|
887
|
+
} catch (error) {
|
|
888
|
+
if ((error === null || error === undefined ? undefined : error.name) === "AbortError") {
|
|
889
|
+
throw new TaDeploymentError(`${base} did not answer in time.`);
|
|
890
|
+
}
|
|
891
|
+
throw error;
|
|
892
|
+
} finally {
|
|
893
|
+
clearTimeout(timer);
|
|
894
|
+
}
|
|
895
|
+
}
|
|
896
|
+
TaDeploymentUtil2.discover = discover;
|
|
897
|
+
function distribution(value) {
|
|
898
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
899
|
+
throw new TaDeploymentError(`${TaDeploymentUtil2.DISTRIBUTION_FILE} holds a JSON object.`);
|
|
900
|
+
}
|
|
901
|
+
const given = value;
|
|
902
|
+
const result = {};
|
|
903
|
+
if (given.name !== undefined) {
|
|
904
|
+
result.name = name(given.name);
|
|
905
|
+
}
|
|
906
|
+
for (const key of ["relay", "gateway"]) {
|
|
907
|
+
if (given[key] !== undefined) {
|
|
908
|
+
const address = url(given[key]);
|
|
909
|
+
if (!address) {
|
|
910
|
+
throw new TaDeploymentError(`"${key}" of ${TaDeploymentUtil2.DISTRIBUTION_FILE} is not an address of http or https.`);
|
|
911
|
+
}
|
|
912
|
+
result[key] = address;
|
|
913
|
+
}
|
|
914
|
+
}
|
|
915
|
+
if (given.updates !== undefined) {
|
|
916
|
+
const updates = given.updates;
|
|
917
|
+
const base = url(updates === null || updates === undefined ? undefined : updates.base);
|
|
918
|
+
if (!base && (updates === null || updates === undefined ? undefined : updates.base) !== undefined) {
|
|
919
|
+
throw new TaDeploymentError(`"updates.base" of ${TaDeploymentUtil2.DISTRIBUTION_FILE} is not an address of http or https.`);
|
|
920
|
+
}
|
|
921
|
+
const key = typeof (updates === null || updates === undefined ? undefined : updates.key) === "string" && updates.key.includes("PUBLIC KEY") ? updates.key : undefined;
|
|
922
|
+
if ((updates === null || updates === undefined ? undefined : updates.key) !== undefined && !key) {
|
|
923
|
+
throw new TaDeploymentError(`"updates.key" of ${TaDeploymentUtil2.DISTRIBUTION_FILE} is a public key in PEM.`);
|
|
924
|
+
}
|
|
925
|
+
result.updates = { ...base ? { base } : {}, ...key ? { key } : {} };
|
|
926
|
+
}
|
|
927
|
+
return result;
|
|
928
|
+
}
|
|
929
|
+
TaDeploymentUtil2.distribution = distribution;
|
|
930
|
+
function apply(distribution2, env) {
|
|
931
|
+
const defaults = { TA_DEPLOYMENT_NAME: distribution2.name, TA_RELAY_URL: distribution2.relay, TA_GATEWAY_URL: distribution2.gateway };
|
|
932
|
+
for (const [key, value] of Object.entries(defaults)) {
|
|
933
|
+
if (value && !env[key]) {
|
|
934
|
+
env[key] = value;
|
|
935
|
+
}
|
|
936
|
+
}
|
|
937
|
+
}
|
|
938
|
+
TaDeploymentUtil2.apply = apply;
|
|
939
|
+
})(TaDeploymentUtil || (TaDeploymentUtil = {}));
|
|
940
|
+
// ../ta-protocol/esm/common/error-protocol.js
|
|
941
|
+
var TaErrorUtil;
|
|
942
|
+
(function(TaErrorUtil2) {
|
|
943
|
+
function code(error) {
|
|
944
|
+
var _a;
|
|
945
|
+
var _b;
|
|
946
|
+
const failure = error;
|
|
947
|
+
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;
|
|
948
|
+
return typeof code2 === "string" ? code2 : undefined;
|
|
949
|
+
}
|
|
950
|
+
TaErrorUtil2.code = code;
|
|
951
|
+
})(TaErrorUtil || (TaErrorUtil = {}));
|
|
496
952
|
// ../ta-protocol/esm/common/gateway-protocol.js
|
|
497
953
|
var TaGatewayServer = Symbol("TaGatewayServer");
|
|
498
954
|
// ../ta-protocol/esm/common/location.js
|
|
@@ -556,19 +1012,19 @@ var TaLocation;
|
|
|
556
1012
|
TaLocation2.isHost = isHost;
|
|
557
1013
|
const FLAGS = /^-[46AaCfGgKkMNnqsTtVvXxYy]+$/;
|
|
558
1014
|
function readHost(input) {
|
|
559
|
-
const
|
|
560
|
-
if (
|
|
561
|
-
|
|
1015
|
+
const words2 = input.trim().split(/\s+/).filter(Boolean);
|
|
1016
|
+
if (words2[0] === "ssh") {
|
|
1017
|
+
words2.shift();
|
|
562
1018
|
}
|
|
563
1019
|
let destination;
|
|
564
1020
|
let port;
|
|
565
1021
|
let user;
|
|
566
1022
|
const options = [];
|
|
567
|
-
for (let i = 0;i <
|
|
568
|
-
const word =
|
|
1023
|
+
for (let i = 0;i < words2.length; i++) {
|
|
1024
|
+
const word = words2[i];
|
|
569
1025
|
const glued = /^-([pl])(.+)$/.exec(word);
|
|
570
1026
|
if (word === "-p" || word === "-l" || glued) {
|
|
571
|
-
const value = glued ? glued[2] :
|
|
1027
|
+
const value = glued ? glued[2] : words2[++i];
|
|
572
1028
|
if (value === undefined) {
|
|
573
1029
|
return { error: "invalid" };
|
|
574
1030
|
}
|
|
@@ -578,7 +1034,7 @@ var TaLocation;
|
|
|
578
1034
|
user = value;
|
|
579
1035
|
}
|
|
580
1036
|
} else if (word === "-o" || word.startsWith("-o")) {
|
|
581
|
-
const value = word === "-o" ?
|
|
1037
|
+
const value = word === "-o" ? words2[++i] : word.slice(2);
|
|
582
1038
|
const option = /^(port|user)\s*=?\s*(.+)$/i.exec(value !== null && value !== undefined ? value : "");
|
|
583
1039
|
if (!option) {
|
|
584
1040
|
options.push(`-o ${value !== null && value !== undefined ? value : ""}`.trim());
|
|
@@ -588,7 +1044,7 @@ var TaLocation;
|
|
|
588
1044
|
user = option[2];
|
|
589
1045
|
}
|
|
590
1046
|
} else if (FLAGS.test(word)) {} else if (word.startsWith("-")) {
|
|
591
|
-
options.push(/^-[bBcDeEFiIJLmOQRSwW]$/.test(word) &&
|
|
1047
|
+
options.push(/^-[bBcDeEFiIJLmOQRSwW]$/.test(word) && words2[i + 1] !== undefined ? `${word} ${words2[++i]}` : word);
|
|
592
1048
|
} else if (destination === undefined) {
|
|
593
1049
|
destination = word;
|
|
594
1050
|
} else {
|
|
@@ -694,44 +1150,7 @@ var TaLocation;
|
|
|
694
1150
|
return squeezed.length > 1 ? squeezed.replace(/\/$/, "") : squeezed;
|
|
695
1151
|
}
|
|
696
1152
|
})(TaLocation || (TaLocation = {}));
|
|
697
|
-
// ../ta-protocol/esm/common/
|
|
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 = {}));
|
|
1153
|
+
// ../ta-protocol/esm/common/message-protocol.js
|
|
735
1154
|
var TaMessageContext;
|
|
736
1155
|
(function(TaMessageContext2) {
|
|
737
1156
|
const BLOCK = /^<context>\n?[\s\S]*?\n?<\/context>\n?/;
|
|
@@ -894,7 +1313,168 @@ var TaSkillUse;
|
|
|
894
1313
|
}
|
|
895
1314
|
TaSkillUse2.command = command;
|
|
896
1315
|
})(TaSkillUse || (TaSkillUse = {}));
|
|
897
|
-
|
|
1316
|
+
var TaTaskNote;
|
|
1317
|
+
(function(TaTaskNote2) {
|
|
1318
|
+
const NOTE = /^<task_(update|adopted|renamed) ((?:[^>"\n]|"[^"]*")*)>\n?([\s\S]*?)\n?<\/task_\1>$/;
|
|
1319
|
+
const ATTRIBUTE = /(\w+)="([^"]*)"/g;
|
|
1320
|
+
function write(note) {
|
|
1321
|
+
const attributes = [`id="${quote(note.id)}"`];
|
|
1322
|
+
if (note.was !== undefined) {
|
|
1323
|
+
attributes.push(`was="${quote(note.was)}"`);
|
|
1324
|
+
}
|
|
1325
|
+
attributes.push(`title="${quote(note.title)}"`);
|
|
1326
|
+
if (note.status !== undefined) {
|
|
1327
|
+
attributes.push(`status="${quote(note.status)}"`);
|
|
1328
|
+
}
|
|
1329
|
+
return `<task_${note.kind} ${attributes.join(" ")}>
|
|
1330
|
+
${note.body}
|
|
1331
|
+
</task_${note.kind}>`;
|
|
1332
|
+
}
|
|
1333
|
+
TaTaskNote2.write = write;
|
|
1334
|
+
function parse(text) {
|
|
1335
|
+
const match = NOTE.exec(text.trim());
|
|
1336
|
+
if (!match) {
|
|
1337
|
+
return;
|
|
1338
|
+
}
|
|
1339
|
+
const attributes = {};
|
|
1340
|
+
for (const [, name, value] of match[2].matchAll(ATTRIBUTE)) {
|
|
1341
|
+
attributes[name] = unquote(value);
|
|
1342
|
+
}
|
|
1343
|
+
if (!attributes.id || attributes.title === undefined) {
|
|
1344
|
+
return;
|
|
1345
|
+
}
|
|
1346
|
+
const { id, title, status, was } = attributes;
|
|
1347
|
+
return { kind: match[1], id, title, ...status ? { status } : {}, ...was ? { was } : {}, body: match[3] };
|
|
1348
|
+
}
|
|
1349
|
+
TaTaskNote2.parse = parse;
|
|
1350
|
+
function quote(text) {
|
|
1351
|
+
return text.replace(/&/g, "&").replace(/"/g, """).replace(/\n/g, " ");
|
|
1352
|
+
}
|
|
1353
|
+
function unquote(text) {
|
|
1354
|
+
return text.replace(/"/g, '"').replace(/&/g, "&");
|
|
1355
|
+
}
|
|
1356
|
+
})(TaTaskNote || (TaTaskNote = {}));
|
|
1357
|
+
// ../ta-protocol/esm/common/package-protocol.js
|
|
1358
|
+
var TaPackageServer = Symbol("TaPackageServer");
|
|
1359
|
+
var TaPackageTextUtil;
|
|
1360
|
+
(function(TaPackageTextUtil2) {
|
|
1361
|
+
function pick(text, language) {
|
|
1362
|
+
var _a, _b, _c, _d, _e;
|
|
1363
|
+
if (text === undefined || typeof text === "string") {
|
|
1364
|
+
return text;
|
|
1365
|
+
}
|
|
1366
|
+
const base = language.split("-")[0];
|
|
1367
|
+
const kin = Object.keys(text).find((key) => key.split("-")[0] === base);
|
|
1368
|
+
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];
|
|
1369
|
+
}
|
|
1370
|
+
TaPackageTextUtil2.pick = pick;
|
|
1371
|
+
})(TaPackageTextUtil || (TaPackageTextUtil = {}));
|
|
1372
|
+
// ../ta-protocol/esm/common/page-protocol.js
|
|
1373
|
+
var TaPageServer = Symbol("TaPageServer");
|
|
1374
|
+
// ../ta-protocol/esm/common/path-map.js
|
|
1375
|
+
var TaPathMap;
|
|
1376
|
+
(function(TaPathMap2) {
|
|
1377
|
+
function isWindows(path2) {
|
|
1378
|
+
return /^[a-zA-Z]:([\\/]|$)/.test(path2) || /^\\\\[^\\]/.test(path2);
|
|
1379
|
+
}
|
|
1380
|
+
TaPathMap2.isWindows = isWindows;
|
|
1381
|
+
function rest(path2, base) {
|
|
1382
|
+
const windows = isWindows(base);
|
|
1383
|
+
if (windows ? !isWindows(path2) : !base.startsWith("/") || !path2.startsWith("/")) {
|
|
1384
|
+
return;
|
|
1385
|
+
}
|
|
1386
|
+
const within = parts(base, windows);
|
|
1387
|
+
const all = parts(path2, windows);
|
|
1388
|
+
if (!within.length || all.length < within.length) {
|
|
1389
|
+
return;
|
|
1390
|
+
}
|
|
1391
|
+
const same = (a, b) => windows ? a.toLowerCase() === b.toLowerCase() : a === b;
|
|
1392
|
+
return within.every((part, i) => same(part, all[i])) ? all.slice(within.length) : undefined;
|
|
1393
|
+
}
|
|
1394
|
+
TaPathMap2.rest = rest;
|
|
1395
|
+
function under(path2, base) {
|
|
1396
|
+
return rest(path2, base) !== undefined;
|
|
1397
|
+
}
|
|
1398
|
+
TaPathMap2.under = under;
|
|
1399
|
+
function join(base, parts2) {
|
|
1400
|
+
if (!parts2.length) {
|
|
1401
|
+
return base;
|
|
1402
|
+
}
|
|
1403
|
+
const sep = isWindows(base) ? "\\" : "/";
|
|
1404
|
+
return `${base.replace(/[\\/]+$/, "")}${sep}${parts2.join(sep)}`;
|
|
1405
|
+
}
|
|
1406
|
+
TaPathMap2.join = join;
|
|
1407
|
+
function basename(path2) {
|
|
1408
|
+
var _a;
|
|
1409
|
+
return (_a = path2.split(/[\\/]+/).filter(Boolean).pop()) !== null && _a !== undefined ? _a : "";
|
|
1410
|
+
}
|
|
1411
|
+
TaPathMap2.basename = basename;
|
|
1412
|
+
function path(value, pairs) {
|
|
1413
|
+
for (const [from, to] of deepest(pairs)) {
|
|
1414
|
+
const found = rest(value, from);
|
|
1415
|
+
if (found) {
|
|
1416
|
+
return join(to, found);
|
|
1417
|
+
}
|
|
1418
|
+
}
|
|
1419
|
+
return value;
|
|
1420
|
+
}
|
|
1421
|
+
TaPathMap2.path = path;
|
|
1422
|
+
function text(value, pairs) {
|
|
1423
|
+
const order = deepest(pairs);
|
|
1424
|
+
if (!order.length) {
|
|
1425
|
+
return value;
|
|
1426
|
+
}
|
|
1427
|
+
const end = String.raw`\s"'<>|*?:;,`;
|
|
1428
|
+
const pattern = new RegExp(String.raw`(^|[^\w.~-])(?:${order.map(([from]) => `(${source(from)})`).join("|")})((?:[\\/][^\\/${end}]*)*)(?=$|[\\/${end})\]}])`, "g");
|
|
1429
|
+
return value.replace(pattern, (...match) => {
|
|
1430
|
+
var _a;
|
|
1431
|
+
const before = match[1];
|
|
1432
|
+
const found = order.findIndex((_, i) => match[i + 2] !== undefined);
|
|
1433
|
+
const tail = (_a = match[order.length + 2]) !== null && _a !== undefined ? _a : "";
|
|
1434
|
+
return `${before}${join(order[found][1], tail.split(/[\\/]+/).filter(Boolean))}`;
|
|
1435
|
+
});
|
|
1436
|
+
}
|
|
1437
|
+
TaPathMap2.text = text;
|
|
1438
|
+
function json(value, pairs) {
|
|
1439
|
+
const order = deepest(pairs);
|
|
1440
|
+
if (!order.length) {
|
|
1441
|
+
return value;
|
|
1442
|
+
}
|
|
1443
|
+
const one = (each) => {
|
|
1444
|
+
const whole = path(each, order);
|
|
1445
|
+
return whole !== each ? whole : text(each, order);
|
|
1446
|
+
};
|
|
1447
|
+
const walk = (each) => {
|
|
1448
|
+
if (typeof each === "string") {
|
|
1449
|
+
return one(each);
|
|
1450
|
+
}
|
|
1451
|
+
if (Array.isArray(each)) {
|
|
1452
|
+
return each.map(walk);
|
|
1453
|
+
}
|
|
1454
|
+
if (each && typeof each === "object") {
|
|
1455
|
+
return Object.fromEntries(Object.entries(each).map(([key, inner]) => [one(key), walk(inner)]));
|
|
1456
|
+
}
|
|
1457
|
+
return each;
|
|
1458
|
+
};
|
|
1459
|
+
return walk(value);
|
|
1460
|
+
}
|
|
1461
|
+
TaPathMap2.json = json;
|
|
1462
|
+
function parts(path2, windows) {
|
|
1463
|
+
return path2.split(windows ? /[\\/]+/ : /\/+/).filter(Boolean);
|
|
1464
|
+
}
|
|
1465
|
+
function deepest(pairs) {
|
|
1466
|
+
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);
|
|
1467
|
+
}
|
|
1468
|
+
function source(base) {
|
|
1469
|
+
const windows = isWindows(base);
|
|
1470
|
+
const quote = (part) => [...part].map((char) => windows && char.toLowerCase() !== char.toUpperCase() ? `[${char.toLowerCase()}${char.toUpperCase()}]` : char.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("");
|
|
1471
|
+
const each = parts(base, windows).map(quote);
|
|
1472
|
+
if (!windows) {
|
|
1473
|
+
return `/${each.join("/+")}`;
|
|
1474
|
+
}
|
|
1475
|
+
return `${base.startsWith("\\\\") ? String.raw`\\\\` : ""}${each.join(String.raw`[\\/]+`)}`;
|
|
1476
|
+
}
|
|
1477
|
+
})(TaPathMap || (TaPathMap = {}));
|
|
898
1478
|
// ../ta-protocol/esm/common/presence-protocol.js
|
|
899
1479
|
var TaPresenceServer = Symbol("TaPresenceServer");
|
|
900
1480
|
var TaMessageAuthor;
|
|
@@ -972,98 +1552,18 @@ var TaRoomWatchUtil;
|
|
|
972
1552
|
})(TaRoomWatchUtil || (TaRoomWatchUtil = {}));
|
|
973
1553
|
// ../ta-protocol/esm/common/settings-protocol.js
|
|
974
1554
|
var TaSettingsServer = Symbol("TaSettingsServer");
|
|
975
|
-
// ../ta-protocol/esm/common/ta-
|
|
976
|
-
var
|
|
977
|
-
var
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
function
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
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
|
-
});
|
|
1002
|
-
}
|
|
1003
|
-
TaHostUtil2.reach = reach;
|
|
1004
|
-
function marked(systemPrompt, mark) {
|
|
1005
|
-
return role(systemPrompt).includes(mark);
|
|
1006
|
-
}
|
|
1007
|
-
TaHostUtil2.marked = marked;
|
|
1008
|
-
function role(systemPrompt) {
|
|
1009
|
-
if (!systemPrompt) {
|
|
1010
|
-
return "";
|
|
1011
|
-
}
|
|
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 "";
|
|
1019
|
-
}
|
|
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 };
|
|
1033
|
-
}
|
|
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);
|
|
1044
|
-
}
|
|
1045
|
-
}
|
|
1046
|
-
return;
|
|
1047
|
-
}
|
|
1048
|
-
TaAskUtil2.asking = asking;
|
|
1049
|
-
function next(asked, entry2) {
|
|
1050
|
-
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;
|
|
1055
|
-
}
|
|
1056
|
-
TaAskUtil2.next = next;
|
|
1057
|
-
function read(found) {
|
|
1058
|
-
var _a;
|
|
1059
|
-
const question = (_a = found.data) === null || _a === undefined ? undefined : _a.question;
|
|
1060
|
-
if (typeof question !== "string" || !question.trim()) {
|
|
1061
|
-
return;
|
|
1062
|
-
}
|
|
1063
|
-
const at = found.timestamp ? Date.parse(found.timestamp) : Number.NaN;
|
|
1064
|
-
return { question: entry(question).question, at: Number.isNaN(at) ? 0 : at };
|
|
1555
|
+
// ../ta-protocol/esm/common/ta-protocol.js
|
|
1556
|
+
var TaServer = Symbol("TaServer");
|
|
1557
|
+
var TaClient = Symbol("TaClient");
|
|
1558
|
+
var TaSlashCommandUtil;
|
|
1559
|
+
(function(TaSlashCommandUtil2) {
|
|
1560
|
+
function description(command, language) {
|
|
1561
|
+
var _a, _b;
|
|
1562
|
+
const { descriptions } = command;
|
|
1563
|
+
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;
|
|
1065
1564
|
}
|
|
1066
|
-
|
|
1565
|
+
TaSlashCommandUtil2.description = description;
|
|
1566
|
+
})(TaSlashCommandUtil || (TaSlashCommandUtil = {}));
|
|
1067
1567
|
// ../ta-protocol/esm/common/team-protocol.js
|
|
1068
1568
|
var TA_UNDECLARED = "extensions.install";
|
|
1069
1569
|
var TaPermissionUtil;
|
|
@@ -1155,6 +1655,8 @@ var TaActionUtil;
|
|
|
1155
1655
|
})(TaActionUtil || (TaActionUtil = {}));
|
|
1156
1656
|
// ../ta-protocol/esm/common/usage-protocol.js
|
|
1157
1657
|
var TaUsageServer = Symbol("TaUsageServer");
|
|
1658
|
+
// ../ta-protocol/esm/common/voice-protocol.js
|
|
1659
|
+
var TaVoiceServer = Symbol("TaVoiceServer");
|
|
1158
1660
|
// ../ta-protocol/esm/common/workspace-protocol.js
|
|
1159
1661
|
var TaWorkspaceServer = Symbol("TaWorkspaceServer");
|
|
1160
1662
|
var TaTerminalServer = Symbol("TaTerminalServer");
|
|
@@ -1846,9 +2348,9 @@ function AttachCard({ post, attach }) {
|
|
|
1846
2348
|
}), /* @__PURE__ */ React.createElement("span", null, label)));
|
|
1847
2349
|
}
|
|
1848
2350
|
function names(people, me) {
|
|
1849
|
-
const
|
|
2351
|
+
const words2 = MomentsWords.of(pi.ui.language);
|
|
1850
2352
|
const separator = TaLanguageUtil.list(pi.ui.language, ["", ""]).slice(1, -1) || ", ";
|
|
1851
|
-
return people.map((person) => person.id === me ?
|
|
2353
|
+
return people.map((person) => person.id === me ? words2.me : person.name).join(separator);
|
|
1852
2354
|
}
|
|
1853
2355
|
function TalkLine({ post, entry, me, onReply }) {
|
|
1854
2356
|
const own = entry.by.id === me && !entry.double;
|
|
@@ -1897,6 +2399,7 @@ function TalkBox({ post, writing, close }) {
|
|
|
1897
2399
|
}, /* @__PURE__ */ React.createElement(Composer, {
|
|
1898
2400
|
key: `${writing.ask ? "ask" : "say"}:${writing.to?.id ?? ""}`,
|
|
1899
2401
|
placeholder,
|
|
2402
|
+
draft: `${post.id}:${writing.ask ? "ask" : "say"}:${writing.to?.id ?? ""}`,
|
|
1900
2403
|
onSend: async (text) => {
|
|
1901
2404
|
await pi.callHost("say", post.room, post.id, text, { ...writing.to ? { to: writing.to.id } : {}, ...writing.ask ? { ask: true } : {} });
|
|
1902
2405
|
close();
|
|
@@ -1915,7 +2418,7 @@ function PostView({ post, me, now }) {
|
|
|
1915
2418
|
const Heart = icon("Heart");
|
|
1916
2419
|
const Trash = icon("Trash2");
|
|
1917
2420
|
const Took = icon("PackageOpen");
|
|
1918
|
-
const
|
|
2421
|
+
const words2 = MomentsWords.of(pi.ui.language);
|
|
1919
2422
|
const left = post.until !== undefined ? Math.ceil((post.until - now) / 86400000) : undefined;
|
|
1920
2423
|
const Spark = icon("Sparkles");
|
|
1921
2424
|
const Comment = icon("MessageCircle");
|
|
@@ -1945,7 +2448,7 @@ function PostView({ post, me, now }) {
|
|
|
1945
2448
|
attach: post.attach
|
|
1946
2449
|
}), /* @__PURE__ */ React.createElement("div", {
|
|
1947
2450
|
className: "tmo-meta"
|
|
1948
|
-
}, /* @__PURE__ */ React.createElement("span", null, MomentsWords.ago(
|
|
2451
|
+
}, /* @__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
2452
|
type: "button",
|
|
1950
2453
|
className: "tmo-link",
|
|
1951
2454
|
disabled: removing,
|
|
@@ -2137,7 +2640,7 @@ var STYLE = `
|
|
|
2137
2640
|
.tmo-head-end { position: absolute; right: 0; top: 50%; transform: translateY(-50%); display: flex; gap: 2px; }
|
|
2138
2641
|
/* The page: one column, as WeChat's Moments */
|
|
2139
2642
|
.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:
|
|
2643
|
+
.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
2644
|
.tmo-card { margin: 4px 0 8px; padding: 2px 8px; border-radius: 14px; background: var(--ta-raised); }
|
|
2142
2645
|
.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
2646
|
.tmo-friends-row:hover, .tmo-friends-row:active { background: var(--ta-hover); }
|
|
@@ -2279,7 +2782,8 @@ function activate(pi2) {
|
|
|
2279
2782
|
head: MomentsHead,
|
|
2280
2783
|
mark: MomentsMark,
|
|
2281
2784
|
discover: true,
|
|
2282
|
-
|
|
2785
|
+
group: "people",
|
|
2786
|
+
order: 78
|
|
2283
2787
|
});
|
|
2284
2788
|
pi2.registerMessageRenderer(DRAFT_TYPE, DraftMessage);
|
|
2285
2789
|
pi2.registerOpener((link) => {
|