@celljs/ta-moments 4.15.2 → 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 +740 -194
- package/host/index.mjs +1393 -834
- package/package.json +4 -4
- package/web/index.js +686 -147
package/web/index.js
CHANGED
|
@@ -491,23 +491,511 @@ 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
|
|
499
955
|
var TaLocation;
|
|
500
956
|
(function(TaLocation2) {
|
|
501
957
|
TaLocation2.SSH = "ssh://";
|
|
958
|
+
TaLocation2.CLOUD = "ta://";
|
|
959
|
+
const CLOUD_NAME = /^[a-z0-9][a-z0-9-]{0,39}$/;
|
|
502
960
|
const HOST = /^(?!-)[\w.@:%+[\]-]+$/;
|
|
503
961
|
function isRemote(location) {
|
|
504
|
-
return location.startsWith(TaLocation2.SSH);
|
|
962
|
+
return location.startsWith(TaLocation2.SSH) || location.startsWith(TaLocation2.CLOUD);
|
|
505
963
|
}
|
|
506
964
|
TaLocation2.isRemote = isRemote;
|
|
965
|
+
function isCloud(host2) {
|
|
966
|
+
return !!host2 && host2.startsWith(TaLocation2.CLOUD);
|
|
967
|
+
}
|
|
968
|
+
TaLocation2.isCloud = isCloud;
|
|
969
|
+
function isCloudName(name) {
|
|
970
|
+
return CLOUD_NAME.test(name);
|
|
971
|
+
}
|
|
972
|
+
TaLocation2.isCloudName = isCloudName;
|
|
973
|
+
function cloud(name, path2 = "") {
|
|
974
|
+
return `${TaLocation2.CLOUD}${name}${path2 ? normalize(path2) : ""}`;
|
|
975
|
+
}
|
|
976
|
+
TaLocation2.cloud = cloud;
|
|
977
|
+
function cloudName(hostOrLocation) {
|
|
978
|
+
if (!hostOrLocation.startsWith(TaLocation2.CLOUD)) {
|
|
979
|
+
return;
|
|
980
|
+
}
|
|
981
|
+
const rest = hostOrLocation.slice(TaLocation2.CLOUD.length);
|
|
982
|
+
const slash = rest.indexOf("/");
|
|
983
|
+
return slash < 0 ? rest : rest.slice(0, slash);
|
|
984
|
+
}
|
|
985
|
+
TaLocation2.cloudName = cloudName;
|
|
507
986
|
function parse(location) {
|
|
987
|
+
var _a;
|
|
508
988
|
if (!isRemote(location)) {
|
|
509
989
|
return;
|
|
510
990
|
}
|
|
991
|
+
if (location.startsWith(TaLocation2.CLOUD)) {
|
|
992
|
+
const name = (_a = cloudName(location)) !== null && _a !== undefined ? _a : "";
|
|
993
|
+
if (!isCloudName(name)) {
|
|
994
|
+
throw new Error(`${JSON.stringify(location)} names no cloud workspace: write ta://<name>/<path>.`);
|
|
995
|
+
}
|
|
996
|
+
const path3 = location.slice(TaLocation2.CLOUD.length + name.length);
|
|
997
|
+
return { host: `${TaLocation2.CLOUD}${name}`, path: path3 ? normalize(path3) : "" };
|
|
998
|
+
}
|
|
511
999
|
const rest = location.slice(TaLocation2.SSH.length);
|
|
512
1000
|
const slash = rest.indexOf("/");
|
|
513
1001
|
const host2 = slash < 0 ? rest : rest.slice(0, slash);
|
|
@@ -519,24 +1007,24 @@ var TaLocation;
|
|
|
519
1007
|
}
|
|
520
1008
|
TaLocation2.parse = parse;
|
|
521
1009
|
function isHost(host2) {
|
|
522
|
-
return HOST.test(host2);
|
|
1010
|
+
return isCloud(host2) ? isCloudName(host2.slice(TaLocation2.CLOUD.length)) : HOST.test(host2);
|
|
523
1011
|
}
|
|
524
1012
|
TaLocation2.isHost = isHost;
|
|
525
1013
|
const FLAGS = /^-[46AaCfGgKkMNnqsTtVvXxYy]+$/;
|
|
526
1014
|
function readHost(input) {
|
|
527
|
-
const
|
|
528
|
-
if (
|
|
529
|
-
|
|
1015
|
+
const words2 = input.trim().split(/\s+/).filter(Boolean);
|
|
1016
|
+
if (words2[0] === "ssh") {
|
|
1017
|
+
words2.shift();
|
|
530
1018
|
}
|
|
531
1019
|
let destination;
|
|
532
1020
|
let port;
|
|
533
1021
|
let user;
|
|
534
1022
|
const options = [];
|
|
535
|
-
for (let i = 0;i <
|
|
536
|
-
const word =
|
|
1023
|
+
for (let i = 0;i < words2.length; i++) {
|
|
1024
|
+
const word = words2[i];
|
|
537
1025
|
const glued = /^-([pl])(.+)$/.exec(word);
|
|
538
1026
|
if (word === "-p" || word === "-l" || glued) {
|
|
539
|
-
const value = glued ? glued[2] :
|
|
1027
|
+
const value = glued ? glued[2] : words2[++i];
|
|
540
1028
|
if (value === undefined) {
|
|
541
1029
|
return { error: "invalid" };
|
|
542
1030
|
}
|
|
@@ -546,7 +1034,7 @@ var TaLocation;
|
|
|
546
1034
|
user = value;
|
|
547
1035
|
}
|
|
548
1036
|
} else if (word === "-o" || word.startsWith("-o")) {
|
|
549
|
-
const value = word === "-o" ?
|
|
1037
|
+
const value = word === "-o" ? words2[++i] : word.slice(2);
|
|
550
1038
|
const option = /^(port|user)\s*=?\s*(.+)$/i.exec(value !== null && value !== undefined ? value : "");
|
|
551
1039
|
if (!option) {
|
|
552
1040
|
options.push(`-o ${value !== null && value !== undefined ? value : ""}`.trim());
|
|
@@ -556,7 +1044,7 @@ var TaLocation;
|
|
|
556
1044
|
user = option[2];
|
|
557
1045
|
}
|
|
558
1046
|
} else if (FLAGS.test(word)) {} else if (word.startsWith("-")) {
|
|
559
|
-
options.push(/^-[bBcDeEFiIJLmOQRSwW]$/.test(word) &&
|
|
1047
|
+
options.push(/^-[bBcDeEFiIJLmOQRSwW]$/.test(word) && words2[i + 1] !== undefined ? `${word} ${words2[++i]}` : word);
|
|
560
1048
|
} else if (destination === undefined) {
|
|
561
1049
|
destination = word;
|
|
562
1050
|
} else {
|
|
@@ -583,10 +1071,13 @@ var TaLocation;
|
|
|
583
1071
|
}
|
|
584
1072
|
TaLocation2.readHost = readHost;
|
|
585
1073
|
function ssh(host2, path2 = "") {
|
|
586
|
-
return `${TaLocation2.SSH}${host2}${path2 ? normalize(path2) : ""}`;
|
|
1074
|
+
return isCloud(host2) ? `${host2}${path2 ? normalize(path2) : ""}` : `${TaLocation2.SSH}${host2}${path2 ? normalize(path2) : ""}`;
|
|
587
1075
|
}
|
|
588
1076
|
TaLocation2.ssh = ssh;
|
|
589
1077
|
function hostLabel(host2) {
|
|
1078
|
+
if (isCloud(host2)) {
|
|
1079
|
+
return host2.slice(TaLocation2.CLOUD.length);
|
|
1080
|
+
}
|
|
590
1081
|
const name = host2.replace(/^[^@]*@/, "").replace(/^\[(.*)\](?::\d+)?$/, "$1").replace(/^([^:]*):\d+$/, "$1");
|
|
591
1082
|
return /^[\d.]+$/.test(name) || name.includes(":") ? name : name.split(".")[0] || name;
|
|
592
1083
|
}
|
|
@@ -659,44 +1150,7 @@ var TaLocation;
|
|
|
659
1150
|
return squeezed.length > 1 ? squeezed.replace(/\/$/, "") : squeezed;
|
|
660
1151
|
}
|
|
661
1152
|
})(TaLocation || (TaLocation = {}));
|
|
662
|
-
// ../ta-protocol/esm/common/
|
|
663
|
-
var TaPackageServer = Symbol("TaPackageServer");
|
|
664
|
-
var TaPackageTextUtil;
|
|
665
|
-
(function(TaPackageTextUtil2) {
|
|
666
|
-
function pick(text, language) {
|
|
667
|
-
var _a, _b, _c, _d, _e;
|
|
668
|
-
if (text === undefined || typeof text === "string") {
|
|
669
|
-
return text;
|
|
670
|
-
}
|
|
671
|
-
const base = language.split("-")[0];
|
|
672
|
-
const kin = Object.keys(text).find((key) => key.split("-")[0] === base);
|
|
673
|
-
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];
|
|
674
|
-
}
|
|
675
|
-
TaPackageTextUtil2.pick = pick;
|
|
676
|
-
})(TaPackageTextUtil || (TaPackageTextUtil = {}));
|
|
677
|
-
// ../ta-protocol/esm/common/ta-protocol.js
|
|
678
|
-
var TaServer = Symbol("TaServer");
|
|
679
|
-
var TaClient = Symbol("TaClient");
|
|
680
|
-
var TaErrorUtil;
|
|
681
|
-
(function(TaErrorUtil2) {
|
|
682
|
-
function code(error) {
|
|
683
|
-
var _a;
|
|
684
|
-
var _b;
|
|
685
|
-
const failure = error;
|
|
686
|
-
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;
|
|
687
|
-
return typeof code2 === "string" ? code2 : undefined;
|
|
688
|
-
}
|
|
689
|
-
TaErrorUtil2.code = code;
|
|
690
|
-
})(TaErrorUtil || (TaErrorUtil = {}));
|
|
691
|
-
var TaSlashCommandUtil;
|
|
692
|
-
(function(TaSlashCommandUtil2) {
|
|
693
|
-
function description(command, language) {
|
|
694
|
-
var _a, _b;
|
|
695
|
-
const { descriptions } = command;
|
|
696
|
-
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;
|
|
697
|
-
}
|
|
698
|
-
TaSlashCommandUtil2.description = description;
|
|
699
|
-
})(TaSlashCommandUtil || (TaSlashCommandUtil = {}));
|
|
1153
|
+
// ../ta-protocol/esm/common/message-protocol.js
|
|
700
1154
|
var TaMessageContext;
|
|
701
1155
|
(function(TaMessageContext2) {
|
|
702
1156
|
const BLOCK = /^<context>\n?[\s\S]*?\n?<\/context>\n?/;
|
|
@@ -859,7 +1313,168 @@ var TaSkillUse;
|
|
|
859
1313
|
}
|
|
860
1314
|
TaSkillUse2.command = command;
|
|
861
1315
|
})(TaSkillUse || (TaSkillUse = {}));
|
|
862
|
-
|
|
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 = {}));
|
|
863
1478
|
// ../ta-protocol/esm/common/presence-protocol.js
|
|
864
1479
|
var TaPresenceServer = Symbol("TaPresenceServer");
|
|
865
1480
|
var TaMessageAuthor;
|
|
@@ -937,98 +1552,18 @@ var TaRoomWatchUtil;
|
|
|
937
1552
|
})(TaRoomWatchUtil || (TaRoomWatchUtil = {}));
|
|
938
1553
|
// ../ta-protocol/esm/common/settings-protocol.js
|
|
939
1554
|
var TaSettingsServer = Symbol("TaSettingsServer");
|
|
940
|
-
// ../ta-protocol/esm/common/ta-
|
|
941
|
-
var
|
|
942
|
-
var
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
function
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
const timer = setTimeout(() => resolve(undefined), waitMs);
|
|
950
|
-
const request = {
|
|
951
|
-
name,
|
|
952
|
-
heard: () => {
|
|
953
|
-
heard = true;
|
|
954
|
-
},
|
|
955
|
-
resolve: (answer) => {
|
|
956
|
-
answered = true;
|
|
957
|
-
clearTimeout(timer);
|
|
958
|
-
resolve(answer);
|
|
959
|
-
}
|
|
960
|
-
};
|
|
961
|
-
events.emit(TA_HOST_EVENT, request);
|
|
962
|
-
if (!heard && !answered) {
|
|
963
|
-
clearTimeout(timer);
|
|
964
|
-
resolve(undefined);
|
|
965
|
-
}
|
|
966
|
-
});
|
|
967
|
-
}
|
|
968
|
-
TaHostUtil2.reach = reach;
|
|
969
|
-
function marked(systemPrompt, mark) {
|
|
970
|
-
return role(systemPrompt).includes(mark);
|
|
971
|
-
}
|
|
972
|
-
TaHostUtil2.marked = marked;
|
|
973
|
-
function role(systemPrompt) {
|
|
974
|
-
if (!systemPrompt) {
|
|
975
|
-
return "";
|
|
976
|
-
}
|
|
977
|
-
const open = `<addendum>
|
|
978
|
-
`;
|
|
979
|
-
const start = systemPrompt.indexOf(open);
|
|
980
|
-
const context = systemPrompt.indexOf(`<project_context>
|
|
981
|
-
`);
|
|
982
|
-
if (start < 0 || context >= 0 && context < start) {
|
|
983
|
-
return "";
|
|
984
|
-
}
|
|
985
|
-
const end = systemPrompt.indexOf(`
|
|
986
|
-
</addendum>`, start);
|
|
987
|
-
return systemPrompt.slice(start + open.length, end < 0 ? undefined : end);
|
|
988
|
-
}
|
|
989
|
-
TaHostUtil2.role = role;
|
|
990
|
-
})(TaHostUtil || (TaHostUtil = {}));
|
|
991
|
-
var TA_ASK_ENTRY = "ta-ask";
|
|
992
|
-
var TaAskUtil;
|
|
993
|
-
(function(TaAskUtil2) {
|
|
994
|
-
const LENGTH = 120;
|
|
995
|
-
function entry(question) {
|
|
996
|
-
const line = question.replace(/\s+/g, " ").trim();
|
|
997
|
-
return { question: line.length > LENGTH ? `${line.slice(0, LENGTH - 1)}…` : line };
|
|
998
|
-
}
|
|
999
|
-
TaAskUtil2.entry = entry;
|
|
1000
|
-
function asking(entries) {
|
|
1001
|
-
var _a;
|
|
1002
|
-
for (let i = entries.length - 1;i >= 0; i--) {
|
|
1003
|
-
const entry2 = entries[i];
|
|
1004
|
-
if (entry2.type === "message" && ((_a = entry2.message) === null || _a === undefined ? undefined : _a.role) === "user") {
|
|
1005
|
-
return;
|
|
1006
|
-
}
|
|
1007
|
-
if (entry2.type === "custom" && entry2.customType === TA_ASK_ENTRY) {
|
|
1008
|
-
return read(entry2);
|
|
1009
|
-
}
|
|
1010
|
-
}
|
|
1011
|
-
return;
|
|
1012
|
-
}
|
|
1013
|
-
TaAskUtil2.asking = asking;
|
|
1014
|
-
function next(asked, entry2) {
|
|
1015
|
-
var _a;
|
|
1016
|
-
if (entry2.type === "message" && ((_a = entry2.message) === null || _a === undefined ? undefined : _a.role) === "user") {
|
|
1017
|
-
return;
|
|
1018
|
-
}
|
|
1019
|
-
return entry2.type === "custom" && entry2.customType === TA_ASK_ENTRY ? read(entry2) : asked;
|
|
1020
|
-
}
|
|
1021
|
-
TaAskUtil2.next = next;
|
|
1022
|
-
function read(found) {
|
|
1023
|
-
var _a;
|
|
1024
|
-
const question = (_a = found.data) === null || _a === undefined ? undefined : _a.question;
|
|
1025
|
-
if (typeof question !== "string" || !question.trim()) {
|
|
1026
|
-
return;
|
|
1027
|
-
}
|
|
1028
|
-
const at = found.timestamp ? Date.parse(found.timestamp) : Number.NaN;
|
|
1029
|
-
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;
|
|
1030
1564
|
}
|
|
1031
|
-
|
|
1565
|
+
TaSlashCommandUtil2.description = description;
|
|
1566
|
+
})(TaSlashCommandUtil || (TaSlashCommandUtil = {}));
|
|
1032
1567
|
// ../ta-protocol/esm/common/team-protocol.js
|
|
1033
1568
|
var TA_UNDECLARED = "extensions.install";
|
|
1034
1569
|
var TaPermissionUtil;
|
|
@@ -1120,6 +1655,8 @@ var TaActionUtil;
|
|
|
1120
1655
|
})(TaActionUtil || (TaActionUtil = {}));
|
|
1121
1656
|
// ../ta-protocol/esm/common/usage-protocol.js
|
|
1122
1657
|
var TaUsageServer = Symbol("TaUsageServer");
|
|
1658
|
+
// ../ta-protocol/esm/common/voice-protocol.js
|
|
1659
|
+
var TaVoiceServer = Symbol("TaVoiceServer");
|
|
1123
1660
|
// ../ta-protocol/esm/common/workspace-protocol.js
|
|
1124
1661
|
var TaWorkspaceServer = Symbol("TaWorkspaceServer");
|
|
1125
1662
|
var TaTerminalServer = Symbol("TaTerminalServer");
|
|
@@ -1811,9 +2348,9 @@ function AttachCard({ post, attach }) {
|
|
|
1811
2348
|
}), /* @__PURE__ */ React.createElement("span", null, label)));
|
|
1812
2349
|
}
|
|
1813
2350
|
function names(people, me) {
|
|
1814
|
-
const
|
|
2351
|
+
const words2 = MomentsWords.of(pi.ui.language);
|
|
1815
2352
|
const separator = TaLanguageUtil.list(pi.ui.language, ["", ""]).slice(1, -1) || ", ";
|
|
1816
|
-
return people.map((person) => person.id === me ?
|
|
2353
|
+
return people.map((person) => person.id === me ? words2.me : person.name).join(separator);
|
|
1817
2354
|
}
|
|
1818
2355
|
function TalkLine({ post, entry, me, onReply }) {
|
|
1819
2356
|
const own = entry.by.id === me && !entry.double;
|
|
@@ -1862,6 +2399,7 @@ function TalkBox({ post, writing, close }) {
|
|
|
1862
2399
|
}, /* @__PURE__ */ React.createElement(Composer, {
|
|
1863
2400
|
key: `${writing.ask ? "ask" : "say"}:${writing.to?.id ?? ""}`,
|
|
1864
2401
|
placeholder,
|
|
2402
|
+
draft: `${post.id}:${writing.ask ? "ask" : "say"}:${writing.to?.id ?? ""}`,
|
|
1865
2403
|
onSend: async (text) => {
|
|
1866
2404
|
await pi.callHost("say", post.room, post.id, text, { ...writing.to ? { to: writing.to.id } : {}, ...writing.ask ? { ask: true } : {} });
|
|
1867
2405
|
close();
|
|
@@ -1880,7 +2418,7 @@ function PostView({ post, me, now }) {
|
|
|
1880
2418
|
const Heart = icon("Heart");
|
|
1881
2419
|
const Trash = icon("Trash2");
|
|
1882
2420
|
const Took = icon("PackageOpen");
|
|
1883
|
-
const
|
|
2421
|
+
const words2 = MomentsWords.of(pi.ui.language);
|
|
1884
2422
|
const left = post.until !== undefined ? Math.ceil((post.until - now) / 86400000) : undefined;
|
|
1885
2423
|
const Spark = icon("Sparkles");
|
|
1886
2424
|
const Comment = icon("MessageCircle");
|
|
@@ -1910,7 +2448,7 @@ function PostView({ post, me, now }) {
|
|
|
1910
2448
|
attach: post.attach
|
|
1911
2449
|
}), /* @__PURE__ */ React.createElement("div", {
|
|
1912
2450
|
className: "tmo-meta"
|
|
1913
|
-
}, /* @__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", {
|
|
1914
2452
|
type: "button",
|
|
1915
2453
|
className: "tmo-link",
|
|
1916
2454
|
disabled: removing,
|
|
@@ -2102,7 +2640,7 @@ var STYLE = `
|
|
|
2102
2640
|
.tmo-head-end { position: absolute; right: 0; top: 50%; transform: translateY(-50%); display: flex; gap: 2px; }
|
|
2103
2641
|
/* The page: one column, as WeChat's Moments */
|
|
2104
2642
|
.tmo-page { flex: 1; min-height: 0; height: 100%; overflow-y: auto; overscroll-behavior: none; background: var(--ta-main); color: var(--ta-text); }
|
|
2105
|
-
.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; }
|
|
2106
2644
|
.tmo-card { margin: 4px 0 8px; padding: 2px 8px; border-radius: 14px; background: var(--ta-raised); }
|
|
2107
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; }
|
|
2108
2646
|
.tmo-friends-row:hover, .tmo-friends-row:active { background: var(--ta-hover); }
|
|
@@ -2244,7 +2782,8 @@ function activate(pi2) {
|
|
|
2244
2782
|
head: MomentsHead,
|
|
2245
2783
|
mark: MomentsMark,
|
|
2246
2784
|
discover: true,
|
|
2247
|
-
|
|
2785
|
+
group: "people",
|
|
2786
|
+
order: 78
|
|
2248
2787
|
});
|
|
2249
2788
|
pi2.registerMessageRenderer(DRAFT_TYPE, DraftMessage);
|
|
2250
2789
|
pi2.registerOpener((link) => {
|