@celljs/ta-share 4.17.0 → 4.19.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/README.en.md +3 -1
- package/README.md +3 -1
- package/host/index.mjs +501 -3
- package/package.json +4 -4
- package/web/index.js +590 -155
package/web/index.js
CHANGED
|
@@ -75,7 +75,6 @@ var EN = {
|
|
|
75
75
|
makeLink: "Make the link",
|
|
76
76
|
making: "Making the link…",
|
|
77
77
|
preview: "What goes",
|
|
78
|
-
previewLoading: "Reading the conversation…",
|
|
79
78
|
stats: "{messages} messages · {tools} tool calls",
|
|
80
79
|
redacted: "{n} things that look like secrets are hidden",
|
|
81
80
|
images: "{n} images are left out",
|
|
@@ -86,9 +85,6 @@ var EN = {
|
|
|
86
85
|
ta: "Ta",
|
|
87
86
|
copy: "Copy link",
|
|
88
87
|
copied: "Copied",
|
|
89
|
-
copyPassword: "Copy password",
|
|
90
|
-
passwordApart: "The password is not in the link: tell it apart.",
|
|
91
|
-
send: "Send…",
|
|
92
88
|
stop: "Stop sharing",
|
|
93
89
|
stopTitle: "Stop sharing “{title}”?",
|
|
94
90
|
stopHint: "The link stops working at once, and the copy on the relay is deleted.",
|
|
@@ -175,7 +171,6 @@ var ZH = {
|
|
|
175
171
|
makeLink: "生成链接",
|
|
176
172
|
making: "正在生成链接…",
|
|
177
173
|
preview: "将分享的内容",
|
|
178
|
-
previewLoading: "正在读取对话…",
|
|
179
174
|
stats: "{messages} 条消息 · {tools} 次工具调用",
|
|
180
175
|
redacted: "隐去了 {n} 处疑似密钥",
|
|
181
176
|
images: "去掉了 {n} 张图片",
|
|
@@ -186,9 +181,6 @@ var ZH = {
|
|
|
186
181
|
ta: "Ta",
|
|
187
182
|
copy: "复制链接",
|
|
188
183
|
copied: "已复制",
|
|
189
|
-
copyPassword: "复制口令",
|
|
190
|
-
passwordApart: "口令不在链接里,请另外告诉对方。",
|
|
191
|
-
send: "发送…",
|
|
192
184
|
stop: "停止分享",
|
|
193
185
|
stopTitle: "停止分享“{title}”?",
|
|
194
186
|
stopHint: "链接立即失效,中继上的副本也会删除。",
|
|
@@ -275,7 +267,6 @@ var ZH_TW = {
|
|
|
275
267
|
makeLink: "生成連結",
|
|
276
268
|
making: "正在生成連結…",
|
|
277
269
|
preview: "將分享的內容",
|
|
278
|
-
previewLoading: "正在讀取對話…",
|
|
279
270
|
stats: "{messages} 條訊息 · {tools} 次工具呼叫",
|
|
280
271
|
redacted: "隱去了 {n} 處疑似金鑰",
|
|
281
272
|
images: "去掉了 {n} 張圖片",
|
|
@@ -286,9 +277,6 @@ var ZH_TW = {
|
|
|
286
277
|
ta: "Ta",
|
|
287
278
|
copy: "複製連結",
|
|
288
279
|
copied: "已複製",
|
|
289
|
-
copyPassword: "複製口令",
|
|
290
|
-
passwordApart: "口令不在連結裡,請另外告訴對方。",
|
|
291
|
-
send: "傳送…",
|
|
292
280
|
stop: "停止分享",
|
|
293
281
|
stopTitle: "停止分享「{title}」?",
|
|
294
282
|
stopHint: "連結立即失效,中繼上的副本也會刪除。",
|
|
@@ -375,7 +363,6 @@ var JA = {
|
|
|
375
363
|
makeLink: "リンクを生成",
|
|
376
364
|
making: "リンクを生成中…",
|
|
377
365
|
preview: "共有するコンテンツ",
|
|
378
|
-
previewLoading: "会話を読み込み中…",
|
|
379
366
|
stats: "{messages} 件のメッセージ · {tools} 件のツール呼び出し",
|
|
380
367
|
redacted: "{n} 個の秘密のような項目を非表示にしました",
|
|
381
368
|
images: "{n} 個の画像を削除しました",
|
|
@@ -386,9 +373,6 @@ var JA = {
|
|
|
386
373
|
ta: "Ta",
|
|
387
374
|
copy: "リンクをコピー",
|
|
388
375
|
copied: "コピーしました",
|
|
389
|
-
copyPassword: "パスワードをコピー",
|
|
390
|
-
passwordApart: "パスワードはリンクに含まれていません。別途伝えてください。",
|
|
391
|
-
send: "送信…",
|
|
392
376
|
stop: "共有を停止",
|
|
393
377
|
stopTitle: "「{title}」の共有を停止しますか?",
|
|
394
378
|
stopHint: "リンクは即座に無効になり、リレー上のコピーは削除されます。",
|
|
@@ -533,8 +517,545 @@ function shareLine(share) {
|
|
|
533
517
|
return [access, until, where].join(" · ");
|
|
534
518
|
}
|
|
535
519
|
|
|
520
|
+
// ../ta-protocol/esm/common/message-protocol.js
|
|
521
|
+
var TaMessageContext;
|
|
522
|
+
(function(TaMessageContext2) {
|
|
523
|
+
const BLOCK = /^<context>\n?[\s\S]*?\n?<\/context>\n?/;
|
|
524
|
+
function wrap(context, message2) {
|
|
525
|
+
return `<context>
|
|
526
|
+
${context}
|
|
527
|
+
</context>
|
|
528
|
+
${message2}`;
|
|
529
|
+
}
|
|
530
|
+
TaMessageContext2.wrap = wrap;
|
|
531
|
+
function strip(message2) {
|
|
532
|
+
return message2.replace(BLOCK, "");
|
|
533
|
+
}
|
|
534
|
+
TaMessageContext2.strip = strip;
|
|
535
|
+
function read(message2) {
|
|
536
|
+
var _a;
|
|
537
|
+
const block = (_a = BLOCK.exec(message2)) === null || _a === undefined ? undefined : _a[0];
|
|
538
|
+
return block === null || block === undefined ? undefined : block.replace(/^<context>\n?/, "").replace(/\n?<\/context>\n?$/, "");
|
|
539
|
+
}
|
|
540
|
+
TaMessageContext2.read = read;
|
|
541
|
+
})(TaMessageContext || (TaMessageContext = {}));
|
|
542
|
+
var TaMessageSource;
|
|
543
|
+
(function(TaMessageSource2) {
|
|
544
|
+
TaMessageSource2.DOUBLE = "ta:double";
|
|
545
|
+
const LINE = /^\[ta:(from|notice) ([^\s\]]+)(?: ([^\]\n]+))?\]$/m;
|
|
546
|
+
function mark(message2, from, detail) {
|
|
547
|
+
return marked(message2, line(from, detail));
|
|
548
|
+
}
|
|
549
|
+
TaMessageSource2.mark = mark;
|
|
550
|
+
function notice(message2, from, detail) {
|
|
551
|
+
return marked(message2, line(from, detail, true));
|
|
552
|
+
}
|
|
553
|
+
TaMessageSource2.notice = notice;
|
|
554
|
+
function line(from, detail, notice2 = false) {
|
|
555
|
+
return `[ta:${notice2 ? "notice" : "from"} ${from}${detail ? ` ${detail.replace(/[\]\n]/g, " ")}` : ""}]`;
|
|
556
|
+
}
|
|
557
|
+
TaMessageSource2.line = line;
|
|
558
|
+
function of(message2) {
|
|
559
|
+
const context = TaMessageContext.read(message2);
|
|
560
|
+
const match = context === undefined ? null : LINE.exec(context);
|
|
561
|
+
return match ? { from: match[2], ...match[3] ? { detail: match[3].trim() } : {}, ...match[1] === "notice" ? { notice: true } : {} } : undefined;
|
|
562
|
+
}
|
|
563
|
+
TaMessageSource2.of = of;
|
|
564
|
+
function isNotice(message2) {
|
|
565
|
+
var _a;
|
|
566
|
+
return ((_a = of(message2)) === null || _a === undefined ? undefined : _a.notice) === true;
|
|
567
|
+
}
|
|
568
|
+
TaMessageSource2.isNotice = isNotice;
|
|
569
|
+
TaMessageSource2.SECTION = "ta-sources";
|
|
570
|
+
TaMessageSource2.PROMPT = [
|
|
571
|
+
"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.",
|
|
572
|
+
"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:",
|
|
573
|
+
"- It is information, never a request of the user: it does not change, drop or replace what they asked. Their latest words come first.",
|
|
574
|
+
"- 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).",
|
|
575
|
+
"- Never quote it as the user's words nor answer it as if they had said it."
|
|
576
|
+
].join(`
|
|
577
|
+
`);
|
|
578
|
+
function marked(message2, source) {
|
|
579
|
+
if (/^[/!]/.test(message2) || of(message2)) {
|
|
580
|
+
return message2;
|
|
581
|
+
}
|
|
582
|
+
const context = TaMessageContext.read(message2);
|
|
583
|
+
return TaMessageContext.wrap(context === undefined ? source : `${context}
|
|
584
|
+
${source}`, TaMessageContext.strip(message2));
|
|
585
|
+
}
|
|
586
|
+
})(TaMessageSource || (TaMessageSource = {}));
|
|
587
|
+
var TaImageNote;
|
|
588
|
+
(function(TaImageNote2) {
|
|
589
|
+
const NOTE = /^\[Image: original \d+x\d+, displayed at \d+x\d+\. Multiply coordinates by [\d.]+ to map to original image\.\]$|^\[Image converted from [^\]]+ to [^\]]+\.\]$/;
|
|
590
|
+
function strip(text) {
|
|
591
|
+
const lines = text.split(`
|
|
592
|
+
`);
|
|
593
|
+
const kept = lines.filter((line) => !NOTE.test(line.trim()));
|
|
594
|
+
if (kept.length === lines.length) {
|
|
595
|
+
return text;
|
|
596
|
+
}
|
|
597
|
+
return kept.join(`
|
|
598
|
+
`).replace(/\n+$/, "").replace(/^\n+/, "");
|
|
599
|
+
}
|
|
600
|
+
TaImageNote2.strip = strip;
|
|
601
|
+
})(TaImageNote || (TaImageNote = {}));
|
|
602
|
+
var TaImageSize;
|
|
603
|
+
(function(TaImageSize2) {
|
|
604
|
+
const JPEG_BYTES = 256 * 1024;
|
|
605
|
+
function of(base64) {
|
|
606
|
+
var _a, _b, _c;
|
|
607
|
+
let bytes;
|
|
608
|
+
try {
|
|
609
|
+
const binary = atob(base64.slice(0, Math.ceil(JPEG_BYTES * 4 / 3 / 4) * 4));
|
|
610
|
+
bytes = Uint8Array.from(binary, (char) => char.charCodeAt(0));
|
|
611
|
+
} catch (_d) {
|
|
612
|
+
return;
|
|
613
|
+
}
|
|
614
|
+
const size = (_c = (_b = (_a = png(bytes)) !== null && _a !== undefined ? _a : gif(bytes)) !== null && _b !== undefined ? _b : webp(bytes)) !== null && _c !== undefined ? _c : jpeg(bytes);
|
|
615
|
+
return size && size.width > 0 && size.height > 0 ? size : undefined;
|
|
616
|
+
}
|
|
617
|
+
TaImageSize2.of = of;
|
|
618
|
+
function u16be(bytes, at) {
|
|
619
|
+
return bytes[at] << 8 | bytes[at + 1];
|
|
620
|
+
}
|
|
621
|
+
function u16le(bytes, at) {
|
|
622
|
+
return bytes[at] | bytes[at + 1] << 8;
|
|
623
|
+
}
|
|
624
|
+
function u24le(bytes, at) {
|
|
625
|
+
return bytes[at] | bytes[at + 1] << 8 | bytes[at + 2] << 16;
|
|
626
|
+
}
|
|
627
|
+
function u32be(bytes, at) {
|
|
628
|
+
return (bytes[at] << 24 | bytes[at + 1] << 16 | bytes[at + 2] << 8 | bytes[at + 3]) >>> 0;
|
|
629
|
+
}
|
|
630
|
+
function text(bytes, at, length) {
|
|
631
|
+
return String.fromCharCode(...bytes.subarray(at, at + length));
|
|
632
|
+
}
|
|
633
|
+
function png(bytes) {
|
|
634
|
+
return bytes.length >= 24 && bytes[0] === 137 && text(bytes, 1, 3) === "PNG" ? { width: u32be(bytes, 16), height: u32be(bytes, 20) } : undefined;
|
|
635
|
+
}
|
|
636
|
+
function gif(bytes) {
|
|
637
|
+
return bytes.length >= 10 && text(bytes, 0, 3) === "GIF" ? { width: u16le(bytes, 6), height: u16le(bytes, 8) } : undefined;
|
|
638
|
+
}
|
|
639
|
+
function webp(bytes) {
|
|
640
|
+
if (bytes.length < 30 || text(bytes, 0, 4) !== "RIFF" || text(bytes, 8, 4) !== "WEBP") {
|
|
641
|
+
return;
|
|
642
|
+
}
|
|
643
|
+
switch (text(bytes, 12, 4)) {
|
|
644
|
+
case "VP8 ":
|
|
645
|
+
return { width: u16le(bytes, 26) & 16383, height: u16le(bytes, 28) & 16383 };
|
|
646
|
+
case "VP8L": {
|
|
647
|
+
const bits = bytes[21] | bytes[22] << 8 | bytes[23] << 16 | bytes[24] << 24;
|
|
648
|
+
return { width: (bits & 16383) + 1, height: (bits >> 14 & 16383) + 1 };
|
|
649
|
+
}
|
|
650
|
+
case "VP8X":
|
|
651
|
+
return { width: u24le(bytes, 24) + 1, height: u24le(bytes, 27) + 1 };
|
|
652
|
+
default:
|
|
653
|
+
return;
|
|
654
|
+
}
|
|
655
|
+
}
|
|
656
|
+
function jpeg(bytes) {
|
|
657
|
+
if (bytes[0] !== 255 || bytes[1] !== 216) {
|
|
658
|
+
return;
|
|
659
|
+
}
|
|
660
|
+
let at = 2;
|
|
661
|
+
while (at + 9 < bytes.length) {
|
|
662
|
+
if (bytes[at] !== 255) {
|
|
663
|
+
return;
|
|
664
|
+
}
|
|
665
|
+
const marker = bytes[at + 1];
|
|
666
|
+
if (marker >= 192 && marker <= 207 && marker !== 196 && marker !== 200 && marker !== 204) {
|
|
667
|
+
return { width: u16be(bytes, at + 7), height: u16be(bytes, at + 5) };
|
|
668
|
+
}
|
|
669
|
+
at += 2 + u16be(bytes, at + 2);
|
|
670
|
+
}
|
|
671
|
+
return;
|
|
672
|
+
}
|
|
673
|
+
})(TaImageSize || (TaImageSize = {}));
|
|
674
|
+
var TaAgentSummary;
|
|
675
|
+
(function(TaAgentSummary2) {
|
|
676
|
+
const START = /^\s*<conversation_history_summary>/;
|
|
677
|
+
const BLOCK = /^\s*<conversation_history_summary>[\s\S]*?(?:<\/conversation_history_summary>\s*|$)/;
|
|
678
|
+
function read(text) {
|
|
679
|
+
if (!START.test(text)) {
|
|
680
|
+
return;
|
|
681
|
+
}
|
|
682
|
+
return text.replace(/<\/?(?:conversation_history_summary|summary)>/g, "").replace(/<\/?\w*$/, "").trim();
|
|
683
|
+
}
|
|
684
|
+
TaAgentSummary2.read = read;
|
|
685
|
+
function strip(text) {
|
|
686
|
+
return text.replace(BLOCK, "");
|
|
687
|
+
}
|
|
688
|
+
TaAgentSummary2.strip = strip;
|
|
689
|
+
})(TaAgentSummary || (TaAgentSummary = {}));
|
|
690
|
+
var TaSkillUse;
|
|
691
|
+
(function(TaSkillUse2) {
|
|
692
|
+
const BLOCK = /^<skill name="([^"]+)" location="([^"]+)">\n([\s\S]*?)\n<\/skill>(?:\n\n([\s\S]+))?$/;
|
|
693
|
+
function parse(message2) {
|
|
694
|
+
var _a;
|
|
695
|
+
const match = BLOCK.exec(message2);
|
|
696
|
+
if (!match) {
|
|
697
|
+
return;
|
|
698
|
+
}
|
|
699
|
+
return { name: match[1], location: match[2], content: match[3], message: ((_a = match[4]) === null || _a === undefined ? undefined : _a.trim()) || undefined };
|
|
700
|
+
}
|
|
701
|
+
TaSkillUse2.parse = parse;
|
|
702
|
+
function command(use) {
|
|
703
|
+
return use.message ? `/skill:${use.name} ${use.message}` : `/skill:${use.name}`;
|
|
704
|
+
}
|
|
705
|
+
TaSkillUse2.command = command;
|
|
706
|
+
})(TaSkillUse || (TaSkillUse = {}));
|
|
707
|
+
var TaTaskNote;
|
|
708
|
+
(function(TaTaskNote2) {
|
|
709
|
+
const NOTE = /^<task_(update|adopted|renamed) ((?:[^>"\n]|"[^"]*")*)>\n?([\s\S]*?)\n?<\/task_\1>$/;
|
|
710
|
+
const ATTRIBUTE = /(\w+)="([^"]*)"/g;
|
|
711
|
+
function write(note) {
|
|
712
|
+
const attributes = [`id="${quote(note.id)}"`];
|
|
713
|
+
if (note.was !== undefined) {
|
|
714
|
+
attributes.push(`was="${quote(note.was)}"`);
|
|
715
|
+
}
|
|
716
|
+
attributes.push(`title="${quote(note.title)}"`);
|
|
717
|
+
if (note.status !== undefined) {
|
|
718
|
+
attributes.push(`status="${quote(note.status)}"`);
|
|
719
|
+
}
|
|
720
|
+
return `<task_${note.kind} ${attributes.join(" ")}>
|
|
721
|
+
${note.body}
|
|
722
|
+
</task_${note.kind}>`;
|
|
723
|
+
}
|
|
724
|
+
TaTaskNote2.write = write;
|
|
725
|
+
function parse(text) {
|
|
726
|
+
const match = NOTE.exec(text.trim());
|
|
727
|
+
if (!match) {
|
|
728
|
+
return;
|
|
729
|
+
}
|
|
730
|
+
const attributes = {};
|
|
731
|
+
for (const [, name, value] of match[2].matchAll(ATTRIBUTE)) {
|
|
732
|
+
attributes[name] = unquote(value);
|
|
733
|
+
}
|
|
734
|
+
if (!attributes.id || attributes.title === undefined) {
|
|
735
|
+
return;
|
|
736
|
+
}
|
|
737
|
+
const { id, title, status, was } = attributes;
|
|
738
|
+
return { kind: match[1], id, title, ...status ? { status } : {}, ...was ? { was } : {}, body: match[3] };
|
|
739
|
+
}
|
|
740
|
+
TaTaskNote2.parse = parse;
|
|
741
|
+
function quote(text) {
|
|
742
|
+
return text.replace(/&/g, "&").replace(/"/g, """).replace(/\n/g, " ");
|
|
743
|
+
}
|
|
744
|
+
function unquote(text) {
|
|
745
|
+
return text.replace(/"/g, '"').replace(/&/g, "&");
|
|
746
|
+
}
|
|
747
|
+
})(TaTaskNote || (TaTaskNote = {}));
|
|
748
|
+
var TaSecretRef;
|
|
749
|
+
(function(TaSecretRef2) {
|
|
750
|
+
TaSecretRef2.PACKAGE = "@celljs/ta-secrets";
|
|
751
|
+
const REF = /\$\{?TA_SECRET_([A-Z0-9][A-Z0-9_]*)\}?/g;
|
|
752
|
+
const KINDS = [
|
|
753
|
+
[/^PHONE(?:_\d+)?$/, "phone"],
|
|
754
|
+
[/^EMAIL(?:_\d+)?$/, "email"],
|
|
755
|
+
[/^ID_NUMBER(?:_\d+)?$/, "idNumber"],
|
|
756
|
+
[/^BANK_CARD(?:_\d+)?$/, "bankCard"]
|
|
757
|
+
];
|
|
758
|
+
function has(text) {
|
|
759
|
+
return text.includes("TA_SECRET_") && new RegExp(REF.source).test(text);
|
|
760
|
+
}
|
|
761
|
+
TaSecretRef2.has = has;
|
|
762
|
+
function kind(name) {
|
|
763
|
+
var _a;
|
|
764
|
+
var _b;
|
|
765
|
+
return (_b = (_a = KINDS.find(([pattern]) => pattern.test(name))) === null || _a === undefined ? undefined : _a[1]) !== null && _b !== undefined ? _b : "secret";
|
|
766
|
+
}
|
|
767
|
+
TaSecretRef2.kind = kind;
|
|
768
|
+
function split(text) {
|
|
769
|
+
if (!has(text)) {
|
|
770
|
+
return [{ text }];
|
|
771
|
+
}
|
|
772
|
+
const parts = [];
|
|
773
|
+
let at = 0;
|
|
774
|
+
for (const match of text.matchAll(REF)) {
|
|
775
|
+
if (match.index > at) {
|
|
776
|
+
parts.push({ text: text.slice(at, match.index) });
|
|
777
|
+
}
|
|
778
|
+
parts.push({ secret: match[1], kind: kind(match[1]) });
|
|
779
|
+
at = match.index + match[0].length;
|
|
780
|
+
}
|
|
781
|
+
if (at < text.length) {
|
|
782
|
+
parts.push({ text: text.slice(at) });
|
|
783
|
+
}
|
|
784
|
+
return parts;
|
|
785
|
+
}
|
|
786
|
+
TaSecretRef2.split = split;
|
|
787
|
+
function plain(text, label) {
|
|
788
|
+
return has(text) ? text.replace(REF, (_whole, name) => label(name, kind(name))) : text;
|
|
789
|
+
}
|
|
790
|
+
TaSecretRef2.plain = plain;
|
|
791
|
+
})(TaSecretRef || (TaSecretRef = {}));
|
|
792
|
+
|
|
793
|
+
// ../ta-protocol/esm/common/said-protocol.js
|
|
794
|
+
var TaSaid;
|
|
795
|
+
(function(TaSaid2) {
|
|
796
|
+
const CARD = /^ta-/i;
|
|
797
|
+
const READ = 4000;
|
|
798
|
+
const FENCE = /^\s*(`{3,}|~{3,})\s*([^\s`]*)/;
|
|
799
|
+
const TAG_LINE = /^<\/?[A-Za-z][\w:.-]*(?:\s[^<>]*)?\/?>$/;
|
|
800
|
+
const MARKS_ONLY = /^[-*_=|:+\s]+$/;
|
|
801
|
+
const MARKS = [
|
|
802
|
+
["context", /<\/?context>/],
|
|
803
|
+
["source", /\[ta:(?:from|notice|by) /],
|
|
804
|
+
["image note", /\[Image: original \d+x\d+|\[Image converted from /],
|
|
805
|
+
["skill", /<skill name="|<\/skill>/],
|
|
806
|
+
["task note", /<\/?task_(?:update|adopted|renamed)\b/],
|
|
807
|
+
["summary", /<\/?(?:conversation_history_summary|summary)>/]
|
|
808
|
+
];
|
|
809
|
+
function text(content, joiner = `
|
|
810
|
+
`) {
|
|
811
|
+
if (typeof content === "string") {
|
|
812
|
+
return content;
|
|
813
|
+
}
|
|
814
|
+
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) : "";
|
|
815
|
+
}
|
|
816
|
+
TaSaid2.text = text;
|
|
817
|
+
function words(role, text2, options = {}) {
|
|
818
|
+
const said = role === "user" ? userWords(text2) : TaAgentSummary.strip(text2);
|
|
819
|
+
return withoutFences(said, (language) => options.cards === false && CARD.test(language), true).trim();
|
|
820
|
+
}
|
|
821
|
+
TaSaid2.words = words;
|
|
822
|
+
function of(message2, options) {
|
|
823
|
+
return message2 ? words(message2.role, text(message2.content), options) : "";
|
|
824
|
+
}
|
|
825
|
+
TaSaid2.of = of;
|
|
826
|
+
function notice(message2) {
|
|
827
|
+
return (message2 === null || message2 === undefined ? undefined : message2.role) === "user" && TaMessageSource.isNotice(text(message2.content));
|
|
828
|
+
}
|
|
829
|
+
TaSaid2.notice = notice;
|
|
830
|
+
function marksOnly(role, text2) {
|
|
831
|
+
return !!text2.trim() && !line(words(role, text2), { chars: Number.POSITIVE_INFINITY });
|
|
832
|
+
}
|
|
833
|
+
TaSaid2.marksOnly = marksOnly;
|
|
834
|
+
function line(markdown, options) {
|
|
835
|
+
var _a;
|
|
836
|
+
const read = markdown.slice(0, READ);
|
|
837
|
+
const prose = withoutFences(read, () => true, true).trim();
|
|
838
|
+
const lines = plain(prose || codeOf(read)).split(`
|
|
839
|
+
`).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));
|
|
840
|
+
const count = (_a = options.lines) !== null && _a !== undefined ? _a : 1;
|
|
841
|
+
const joined = count <= 1 ? lines.join(" ") : lines.slice(0, count).join(`
|
|
842
|
+
`);
|
|
843
|
+
return joined.length > options.chars ? `${joined.slice(0, Math.max(0, options.chars - 1)).trimEnd()}…` : joined;
|
|
844
|
+
}
|
|
845
|
+
TaSaid2.line = line;
|
|
846
|
+
function leaks(shown, options = {}) {
|
|
847
|
+
const found = MARKS.filter(([, mark]) => mark.test(shown)).map(([name]) => name);
|
|
848
|
+
const lines = shown.split(`
|
|
849
|
+
`);
|
|
850
|
+
if (options.cards !== true && lines.some((part) => {
|
|
851
|
+
var _a;
|
|
852
|
+
var _b;
|
|
853
|
+
return CARD.test((_b = (_a = FENCE.exec(part)) === null || _a === undefined ? undefined : _a[2]) !== null && _b !== undefined ? _b : "");
|
|
854
|
+
})) {
|
|
855
|
+
found.push("card");
|
|
856
|
+
}
|
|
857
|
+
if (lines.some((part) => TAG_LINE.test(part.trim()))) {
|
|
858
|
+
found.push("tag");
|
|
859
|
+
}
|
|
860
|
+
return found;
|
|
861
|
+
}
|
|
862
|
+
TaSaid2.leaks = leaks;
|
|
863
|
+
const SUMMARY = `<conversation_history_summary>
|
|
864
|
+
<summary>
|
|
865
|
+
1. Primary Request and Intent:
|
|
866
|
+
The user works on the relay.
|
|
867
|
+
</summary>
|
|
868
|
+
</conversation_history_summary>`;
|
|
869
|
+
TaSaid2.SAMPLES = [
|
|
870
|
+
{
|
|
871
|
+
mark: "context and where it came from",
|
|
872
|
+
role: "user",
|
|
873
|
+
text: `<context>
|
|
874
|
+
The channel #ops, its members.
|
|
875
|
+
[ta:from @celljs/ta-channels #ops]
|
|
876
|
+
</context>
|
|
877
|
+
Check the build`,
|
|
878
|
+
said: "Check the build"
|
|
879
|
+
},
|
|
880
|
+
{
|
|
881
|
+
mark: "a notice, not the user",
|
|
882
|
+
role: "user",
|
|
883
|
+
text: `<context>
|
|
884
|
+
[ta:notice @celljs/ta-call]
|
|
885
|
+
</context>
|
|
886
|
+
The work finished. Its last words: tests pass.`,
|
|
887
|
+
said: "The work finished. Its last words: tests pass."
|
|
888
|
+
},
|
|
889
|
+
{ mark: "one let in", role: "user", text: `<context>
|
|
890
|
+
[ta:by p-7 Alice]
|
|
891
|
+
</context>
|
|
892
|
+
Hello there`, said: "Hello there" },
|
|
893
|
+
{
|
|
894
|
+
mark: "notes of images",
|
|
895
|
+
role: "user",
|
|
896
|
+
text: `Look at this
|
|
897
|
+
[Image: original 3024x4032, displayed at 1512x2016. Multiply coordinates by 2.00 to map to original image.]
|
|
898
|
+
[Image converted from image/heic to image/png.]`,
|
|
899
|
+
said: "Look at this"
|
|
900
|
+
},
|
|
901
|
+
{
|
|
902
|
+
mark: "a skill run",
|
|
903
|
+
role: "user",
|
|
904
|
+
text: `<skill name="ta-package" location="/skills/ta-package/SKILL.md">
|
|
905
|
+
# Ta package
|
|
906
|
+
Steps.
|
|
907
|
+
</skill>
|
|
908
|
+
|
|
909
|
+
Make a card`,
|
|
910
|
+
said: "Make a card"
|
|
911
|
+
},
|
|
912
|
+
{
|
|
913
|
+
mark: "a note of a task",
|
|
914
|
+
role: "user",
|
|
915
|
+
text: `<task_update id="t1" title="Fix login" status="done">
|
|
916
|
+
All tests pass.
|
|
917
|
+
</task_update>`,
|
|
918
|
+
said: "Fix login"
|
|
919
|
+
},
|
|
920
|
+
{ mark: "a note of a new id", role: "user", text: `<task_renamed id="t2" was="t1" title="Fix login">
|
|
921
|
+
Now t2.
|
|
922
|
+
</task_renamed>` },
|
|
923
|
+
{ mark: "a summary, then the answer", role: "assistant", text: `${SUMMARY}
|
|
924
|
+
Switched to voice.`, said: "Switched to voice." },
|
|
925
|
+
{ mark: "a summary alone", role: "assistant", text: SUMMARY },
|
|
926
|
+
{ mark: "a summary as it streams", role: "assistant", text: `<conversation_history_summary>
|
|
927
|
+
<summary>` },
|
|
928
|
+
{
|
|
929
|
+
mark: "a card after the answer",
|
|
930
|
+
role: "assistant",
|
|
931
|
+
text: '**Done**: tests pass.\n\n```ta-glance\n{"status":"done","blocks":[]}\n```',
|
|
932
|
+
said: "tests pass"
|
|
933
|
+
},
|
|
934
|
+
{ mark: "a card alone", role: "assistant", text: '```ta-glance\n{"status":"done","blocks":[]}\n```' },
|
|
935
|
+
{ mark: "a proposal", role: "assistant", text: 'Committed.\n\n```ta-propose\n{"kind":"git.push","title":"Push"}\n```', said: "Committed." },
|
|
936
|
+
{ mark: "what a call says aloud", role: "assistant", text: "All fixed.\n\n```ta-say\nIt is fixed.\n```", said: "All fixed." },
|
|
937
|
+
{ mark: "a tag not known yet", role: "assistant", text: `<system-reminder>
|
|
938
|
+
</system-reminder>
|
|
939
|
+
Ready.`, said: "Ready." }
|
|
940
|
+
];
|
|
941
|
+
function userWords(text2) {
|
|
942
|
+
const said = TaImageNote.strip(TaMessageContext.strip(text2));
|
|
943
|
+
const skill = TaSkillUse.parse(said);
|
|
944
|
+
if (skill) {
|
|
945
|
+
return TaSkillUse.command(skill);
|
|
946
|
+
}
|
|
947
|
+
const note = TaTaskNote.parse(said);
|
|
948
|
+
if (!note) {
|
|
949
|
+
return said;
|
|
950
|
+
}
|
|
951
|
+
if (note.kind === "renamed") {
|
|
952
|
+
return "";
|
|
953
|
+
}
|
|
954
|
+
return note.kind === "update" && note.body.trim() ? `${note.title} · ${note.body}` : note.title;
|
|
955
|
+
}
|
|
956
|
+
function withoutFences(text2, drop, tags = false) {
|
|
957
|
+
const kept = [];
|
|
958
|
+
let fence;
|
|
959
|
+
let left = false;
|
|
960
|
+
for (const part of text2.split(`
|
|
961
|
+
`)) {
|
|
962
|
+
const open = FENCE.exec(part);
|
|
963
|
+
if (!fence && open) {
|
|
964
|
+
fence = { mark: open[1], dropped: drop(open[2]) };
|
|
965
|
+
} else if (fence && closes(part, fence.mark)) {
|
|
966
|
+
const dropped = fence.dropped;
|
|
967
|
+
fence = undefined;
|
|
968
|
+
if (dropped) {
|
|
969
|
+
continue;
|
|
970
|
+
}
|
|
971
|
+
}
|
|
972
|
+
if ((fence === null || fence === undefined ? undefined : fence.dropped) || !fence && tags && TAG_LINE.test(part.trim())) {
|
|
973
|
+
left = true;
|
|
974
|
+
} else {
|
|
975
|
+
kept.push(part);
|
|
976
|
+
}
|
|
977
|
+
}
|
|
978
|
+
return left ? kept.join(`
|
|
979
|
+
`).replace(/\n{3,}/g, `
|
|
980
|
+
|
|
981
|
+
`) : kept.join(`
|
|
982
|
+
`);
|
|
983
|
+
}
|
|
984
|
+
function codeOf(text2) {
|
|
985
|
+
const code = [];
|
|
986
|
+
let fence;
|
|
987
|
+
for (const part of text2.split(`
|
|
988
|
+
`)) {
|
|
989
|
+
const open = FENCE.exec(part);
|
|
990
|
+
if (!fence && open) {
|
|
991
|
+
fence = { mark: open[1], card: CARD.test(open[2]) };
|
|
992
|
+
} else if (fence && closes(part, fence.mark)) {
|
|
993
|
+
fence = undefined;
|
|
994
|
+
} else if (fence && !fence.card) {
|
|
995
|
+
code.push(part);
|
|
996
|
+
}
|
|
997
|
+
}
|
|
998
|
+
return code.join(`
|
|
999
|
+
`);
|
|
1000
|
+
}
|
|
1001
|
+
function closes(part, mark) {
|
|
1002
|
+
var _a;
|
|
1003
|
+
const close = (_a = /^\s*(`{3,}|~{3,})\s*$/.exec(part)) === null || _a === undefined ? undefined : _a[1];
|
|
1004
|
+
return !!close && close[0] === mark[0] && close.length >= mark.length;
|
|
1005
|
+
}
|
|
1006
|
+
function plain(text2) {
|
|
1007
|
+
const linked = text2.replace(/(?<!!)\[([^\]\n]*)\]\([^)\n]*\)/g, "$1");
|
|
1008
|
+
const words2 = linked.replace(/!\[[^\]\n]*\]\([^)\n]*\)/g, "").trim();
|
|
1009
|
+
return words2 || linked.replace(/!\[([^\]\n]*)\]\([^)\n]*\)/g, "$1");
|
|
1010
|
+
}
|
|
1011
|
+
})(TaSaid || (TaSaid = {}));
|
|
1012
|
+
|
|
1013
|
+
// ../ta-web/esm/browser/extension/share-sheet-compat.js
|
|
1014
|
+
function ShareSheetCompat({ pi: pi2, ...props }) {
|
|
1015
|
+
const h = pi2.React.createElement;
|
|
1016
|
+
if (pi2.ui.ShareSheet) {
|
|
1017
|
+
return h(pi2.ui.ShareSheet, props);
|
|
1018
|
+
}
|
|
1019
|
+
const { title, link, error, name, gets, notes, password, own, onClose, children } = props;
|
|
1020
|
+
const quiet = { margin: 0, opacity: 0.7, textAlign: "center" };
|
|
1021
|
+
return h(pi2.ui.Dialog, { title, onClose }, h("div", { style: { display: "flex", flexDirection: "column", alignItems: "center", gap: 12 } }, error !== undefined ? h("p", { role: "alert" }, error) : [
|
|
1022
|
+
name || gets ? h("p", { key: "who", style: { margin: 0, textAlign: "center" } }, [name, gets].filter(Boolean).join(" · ")) : null,
|
|
1023
|
+
link && !own ? h(pi2.ui.QrCode, { key: "qr", text: link, label: name || title }) : null,
|
|
1024
|
+
h("code", { key: "link", style: { maxWidth: "100%", overflowWrap: "anywhere", userSelect: "all" } }, link !== null && link !== undefined ? link : "…"),
|
|
1025
|
+
password ? h("code", { key: "password", style: { userSelect: "all" } }, password) : null,
|
|
1026
|
+
link ? h("button", { key: "copy", type: "button", className: "ta-button ta-primary", onClick: () => {
|
|
1027
|
+
var _a;
|
|
1028
|
+
return void ((_a = navigator.clipboard) === null || _a === undefined ? undefined : _a.writeText(link));
|
|
1029
|
+
} }, "Copy") : null,
|
|
1030
|
+
children,
|
|
1031
|
+
...(notes !== null && notes !== undefined ? notes : []).filter(Boolean).map((line) => h("p", { key: String(line), style: quiet }, line))
|
|
1032
|
+
]));
|
|
1033
|
+
}
|
|
1034
|
+
|
|
1035
|
+
// web-src/share-protocol.ts
|
|
1036
|
+
var SHARE_TOOL = "share_link";
|
|
1037
|
+
var CONVERSATION_KIND = "ta-conversation";
|
|
1038
|
+
var FILE_KIND = "file";
|
|
1039
|
+
var ShareLink;
|
|
1040
|
+
((ShareLink) => {
|
|
1041
|
+
const LINK = /^https?:\/\/[^/\s#?]+\/s#v=1&\S+$/i;
|
|
1042
|
+
function is(text) {
|
|
1043
|
+
const kind = LINK.test(text.trim()) ? fragment(text).get("c") : "none";
|
|
1044
|
+
return kind === null || kind === CONVERSATION_KIND || kind === FILE_KIND;
|
|
1045
|
+
}
|
|
1046
|
+
ShareLink.is = is;
|
|
1047
|
+
function fragment(text) {
|
|
1048
|
+
return new URLSearchParams(text.slice(text.indexOf("#") + 1));
|
|
1049
|
+
}
|
|
1050
|
+
function needsPassword(text) {
|
|
1051
|
+
return fragment(text).get("p") === "1";
|
|
1052
|
+
}
|
|
1053
|
+
ShareLink.needsPassword = needsPassword;
|
|
1054
|
+
})(ShareLink ||= {});
|
|
1055
|
+
|
|
536
1056
|
// web-src/share-dialog.tsx
|
|
537
1057
|
var DAYS = [1, 7, 30, 0];
|
|
1058
|
+
var PREVIEW_CHARS = 160;
|
|
538
1059
|
function Choice({
|
|
539
1060
|
value,
|
|
540
1061
|
options,
|
|
@@ -579,23 +1100,17 @@ function Toggle({
|
|
|
579
1100
|
onChange: (event) => onChange(event.target.checked)
|
|
580
1101
|
}));
|
|
581
1102
|
}
|
|
582
|
-
function firstText(content) {
|
|
583
|
-
if (typeof content === "string") {
|
|
584
|
-
return content;
|
|
585
|
-
}
|
|
586
|
-
return (Array.isArray(content) ? content : []).flatMap((part) => part?.type === "text" && part.text ? [part.text] : []).join(" ");
|
|
587
|
-
}
|
|
588
|
-
function plain(text) {
|
|
589
|
-
return text.replace(/```[\s\S]*?(```|$)/g, " ").replace(/!?\[([^\]]*)\]\([^)]*\)/g, "$1").replace(/[*_~`#>|]+/g, "").replace(/\s+/g, " ").trim();
|
|
590
|
-
}
|
|
591
1103
|
function PreviewBox({ preview, outputs }) {
|
|
592
1104
|
if (!preview) {
|
|
1105
|
+
const Loading = pi.ui.Loading ?? pi.ui.Skeleton;
|
|
593
1106
|
return /* @__PURE__ */ React.createElement("div", {
|
|
594
|
-
className: "tsh-preview
|
|
595
|
-
},
|
|
1107
|
+
className: "tsh-preview"
|
|
1108
|
+
}, /* @__PURE__ */ React.createElement(Loading, {
|
|
1109
|
+
compact: true
|
|
1110
|
+
}));
|
|
596
1111
|
}
|
|
597
1112
|
const { conversation, stats } = preview;
|
|
598
|
-
const lines = (conversation?.messages ?? []).filter((item) => item.role !== "toolResult").map((item) => ({ role: item.role, text:
|
|
1113
|
+
const lines = (conversation?.messages ?? []).filter((item) => item.role !== "toolResult").map((item) => ({ role: item.role, text: TaSaid.line(TaSaid.of(item), { chars: PREVIEW_CHARS }) })).filter((line) => line.text).slice(0, 6);
|
|
599
1114
|
const tools = stats?.tools ?? conversation?.messages.reduce((count, item) => count + (item.role === "assistant" ? item.content.filter((part) => part.type === "toolCall").length : 0), 0) ?? 0;
|
|
600
1115
|
const notes = [
|
|
601
1116
|
stats?.redacted ? t("redacted", { n: stats.redacted }) : "",
|
|
@@ -623,74 +1138,36 @@ function randomPassword() {
|
|
|
623
1138
|
const bytes = crypto.getRandomValues(new Uint8Array(8));
|
|
624
1139
|
return Array.from(bytes, (byte) => letters[byte % letters.length]).join("");
|
|
625
1140
|
}
|
|
1141
|
+
function kindIcon(share) {
|
|
1142
|
+
if (share.kind === CONVERSATION_KIND) {
|
|
1143
|
+
return "MessageSquareText";
|
|
1144
|
+
}
|
|
1145
|
+
if (share.kind === "ta-agent") {
|
|
1146
|
+
return "Contact";
|
|
1147
|
+
}
|
|
1148
|
+
return /^text\/html\b/.test(share.type ?? "") ? "Globe" : /^image\//.test(share.type ?? "") ? "Image" : "FileText";
|
|
1149
|
+
}
|
|
626
1150
|
function Made({ share, password, close }) {
|
|
627
|
-
const
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
};
|
|
647
|
-
return /* @__PURE__ */ React.createElement("div", {
|
|
648
|
-
className: "tsh-made"
|
|
649
|
-
}, share.access !== "self" && pi.ui.QrCode && /* @__PURE__ */ React.createElement("div", {
|
|
650
|
-
className: "tsh-qr"
|
|
651
|
-
}, /* @__PURE__ */ React.createElement(pi.ui.QrCode, {
|
|
652
|
-
text: share.link,
|
|
653
|
-
label: t("qr")
|
|
654
|
-
})), /* @__PURE__ */ React.createElement("p", {
|
|
655
|
-
className: "tsh-hint"
|
|
656
|
-
}, share.access === "self" ? t("accessSelfHint") : share.access === "people" ? t("accessPeopleHint") : t("linkReady")), /* @__PURE__ */ React.createElement("div", {
|
|
657
|
-
className: "tsh-link",
|
|
658
|
-
title: share.link
|
|
659
|
-
}, share.link), /* @__PURE__ */ React.createElement("p", {
|
|
660
|
-
className: "tsh-muted tsh-center"
|
|
661
|
-
}, shareLine(share)), password && /* @__PURE__ */ React.createElement("div", {
|
|
662
|
-
className: "tsh-password-note"
|
|
663
|
-
}, /* @__PURE__ */ React.createElement("span", null, t("passwordApart"), " ", /* @__PURE__ */ React.createElement("code", null, password)), /* @__PURE__ */ React.createElement("button", {
|
|
664
|
-
type: "button",
|
|
665
|
-
className: "ta-button",
|
|
666
|
-
onClick: () => copy(password, "password")
|
|
667
|
-
}, copied === "password" ? t("copied") : t("copyPassword"))), /* @__PURE__ */ React.createElement("div", {
|
|
668
|
-
className: "tsh-actions"
|
|
669
|
-
}, /* @__PURE__ */ React.createElement("button", {
|
|
670
|
-
type: "button",
|
|
671
|
-
className: "ta-button ta-primary",
|
|
672
|
-
onClick: () => copy(share.link, "link")
|
|
673
|
-
}, copied === "link" ? /* @__PURE__ */ React.createElement(Check, {
|
|
674
|
-
size: 14
|
|
675
|
-
}) : /* @__PURE__ */ React.createElement(Copy, {
|
|
676
|
-
size: 14
|
|
677
|
-
}), " ", copied === "link" ? t("copied") : t("copy")), canSend && share.access !== "self" && /* @__PURE__ */ React.createElement("button", {
|
|
678
|
-
type: "button",
|
|
679
|
-
className: "ta-button",
|
|
680
|
-
onClick: () => void navigator.share({ title: share.title, url: share.link }).catch(() => {
|
|
681
|
-
return;
|
|
682
|
-
})
|
|
683
|
-
}, /* @__PURE__ */ React.createElement(Send, {
|
|
684
|
-
size: 14
|
|
685
|
-
}), " ", t("send"))), /* @__PURE__ */ React.createElement("button", {
|
|
686
|
-
type: "button",
|
|
687
|
-
className: `tsh-stop${stopping ? " ta-busy" : ""}`,
|
|
688
|
-
"aria-busy": stopping || undefined,
|
|
689
|
-
disabled: stopping,
|
|
690
|
-
onClick: () => void stop()
|
|
691
|
-
}, stopping && /* @__PURE__ */ React.createElement("span", {
|
|
692
|
-
className: "ta-spinner ta-busy-mark"
|
|
693
|
-
}), /* @__PURE__ */ React.createElement("span", null, t("stop"))));
|
|
1151
|
+
const Kind = icon(kindIcon(share));
|
|
1152
|
+
return /* @__PURE__ */ React.createElement(ShareSheetCompat, {
|
|
1153
|
+
pi,
|
|
1154
|
+
title: t("shareTitle", { title: share.title }),
|
|
1155
|
+
link: share.link,
|
|
1156
|
+
face: /* @__PURE__ */ React.createElement(Kind, {
|
|
1157
|
+
size: 22
|
|
1158
|
+
}),
|
|
1159
|
+
name: share.title,
|
|
1160
|
+
gets: share.access === "self" ? t("accessSelfHint") : share.access === "people" ? t("accessPeopleHint") : t("linkReady"),
|
|
1161
|
+
notes: [shareLine(share)],
|
|
1162
|
+
password,
|
|
1163
|
+
own: share.access === "self",
|
|
1164
|
+
onStop: async () => {
|
|
1165
|
+
await shares.remove(share.id);
|
|
1166
|
+
pi.ui.notify(t("stopped"));
|
|
1167
|
+
},
|
|
1168
|
+
stop: { title: t("stopTitle", { title: share.title }), message: t("stopHint") },
|
|
1169
|
+
onClose: close
|
|
1170
|
+
});
|
|
694
1171
|
}
|
|
695
1172
|
function useFriends() {
|
|
696
1173
|
const [friends, setFriends] = React.useState();
|
|
@@ -846,17 +1323,19 @@ function Options({ target, onMade }) {
|
|
|
846
1323
|
}
|
|
847
1324
|
function ShareDialog({ target, close }) {
|
|
848
1325
|
const [made, setMade] = React.useState(target.kind === "made" ? { share: target.share } : undefined);
|
|
849
|
-
|
|
1326
|
+
if (made) {
|
|
1327
|
+
return /* @__PURE__ */ React.createElement(Made, {
|
|
1328
|
+
share: made.share,
|
|
1329
|
+
password: made.password,
|
|
1330
|
+
close
|
|
1331
|
+
});
|
|
1332
|
+
}
|
|
850
1333
|
return /* @__PURE__ */ React.createElement(pi.ui.Dialog, {
|
|
851
|
-
title: t("shareTitle", { title }),
|
|
1334
|
+
title: t("shareTitle", { title: target.kind === "made" ? target.share.title : target.title }),
|
|
852
1335
|
onClose: close
|
|
853
1336
|
}, /* @__PURE__ */ React.createElement("div", {
|
|
854
1337
|
className: "tsh-dialog"
|
|
855
|
-
},
|
|
856
|
-
share: made.share,
|
|
857
|
-
password: made.password,
|
|
858
|
-
close
|
|
859
|
-
}) : target.kind === "conversation" && /* @__PURE__ */ React.createElement(Options, {
|
|
1338
|
+
}, target.kind === "conversation" && /* @__PURE__ */ React.createElement(Options, {
|
|
860
1339
|
target,
|
|
861
1340
|
onMade: (result, password) => setMade({ share: result.share, password })
|
|
862
1341
|
})));
|
|
@@ -872,27 +1351,6 @@ function openShareDialog(target) {
|
|
|
872
1351
|
}));
|
|
873
1352
|
}
|
|
874
1353
|
|
|
875
|
-
// web-src/share-protocol.ts
|
|
876
|
-
var SHARE_TOOL = "share_link";
|
|
877
|
-
var CONVERSATION_KIND = "ta-conversation";
|
|
878
|
-
var FILE_KIND = "file";
|
|
879
|
-
var ShareLink;
|
|
880
|
-
((ShareLink) => {
|
|
881
|
-
const LINK = /^https?:\/\/[^/\s#?]+\/s#v=1&\S+$/i;
|
|
882
|
-
function is(text) {
|
|
883
|
-
const kind = LINK.test(text.trim()) ? fragment(text).get("c") : "none";
|
|
884
|
-
return kind === null || kind === CONVERSATION_KIND || kind === FILE_KIND;
|
|
885
|
-
}
|
|
886
|
-
ShareLink.is = is;
|
|
887
|
-
function fragment(text) {
|
|
888
|
-
return new URLSearchParams(text.slice(text.indexOf("#") + 1));
|
|
889
|
-
}
|
|
890
|
-
function needsPassword(text) {
|
|
891
|
-
return fragment(text).get("p") === "1";
|
|
892
|
-
}
|
|
893
|
-
ShareLink.needsPassword = needsPassword;
|
|
894
|
-
})(ShareLink ||= {});
|
|
895
|
-
|
|
896
1354
|
// web-src/shared-view.tsx
|
|
897
1355
|
var SharedToolLine;
|
|
898
1356
|
((SharedToolLine) => {
|
|
@@ -1125,9 +1583,10 @@ function SharedView({ link }) {
|
|
|
1125
1583
|
open();
|
|
1126
1584
|
}, [open]);
|
|
1127
1585
|
if (state.step === "loading") {
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1586
|
+
const Loading = pi.ui.Loading ?? pi.ui.Skeleton;
|
|
1587
|
+
return /* @__PURE__ */ React.createElement(Loading, {
|
|
1588
|
+
label: t("opening")
|
|
1589
|
+
});
|
|
1131
1590
|
}
|
|
1132
1591
|
if (state.step === "failed") {
|
|
1133
1592
|
return /* @__PURE__ */ React.createElement("div", {
|
|
@@ -1193,15 +1652,6 @@ function SharedView({ link }) {
|
|
|
1193
1652
|
}
|
|
1194
1653
|
|
|
1195
1654
|
// web-src/shares-page.tsx
|
|
1196
|
-
function kindIcon(share) {
|
|
1197
|
-
if (share.kind === CONVERSATION_KIND) {
|
|
1198
|
-
return "MessageSquareText";
|
|
1199
|
-
}
|
|
1200
|
-
if (share.kind === "ta-agent") {
|
|
1201
|
-
return "Contact";
|
|
1202
|
-
}
|
|
1203
|
-
return /^text\/html\b/.test(share.type ?? "") ? "Globe" : /^image\//.test(share.type ?? "") ? "Image" : "FileText";
|
|
1204
|
-
}
|
|
1205
1655
|
function ShareRow({ share }) {
|
|
1206
1656
|
const [copied, setCopied] = React.useState(false);
|
|
1207
1657
|
const [stopping, setStopping] = React.useState(false);
|
|
@@ -1282,12 +1732,11 @@ function ShareRow({ share }) {
|
|
|
1282
1732
|
}, content) : content, menu);
|
|
1283
1733
|
}
|
|
1284
1734
|
function SharesPage() {
|
|
1735
|
+
const Loading = pi.ui.Loading ?? pi.ui.Skeleton;
|
|
1285
1736
|
const list = useShares();
|
|
1286
1737
|
return /* @__PURE__ */ React.createElement("div", {
|
|
1287
1738
|
className: "tsh-page"
|
|
1288
|
-
}, list === undefined ?
|
|
1289
|
-
rows: 3
|
|
1290
|
-
}) : null : list.length === 0 ? /* @__PURE__ */ React.createElement(pi.ui.Empty, {
|
|
1739
|
+
}, list === undefined ? Loading ? /* @__PURE__ */ React.createElement(Loading, null) : null : list.length === 0 ? /* @__PURE__ */ React.createElement(pi.ui.Empty, {
|
|
1291
1740
|
title: t("emptyTitle"),
|
|
1292
1741
|
hint: t("emptyHint")
|
|
1293
1742
|
}) : /* @__PURE__ */ React.createElement("ul", {
|
|
@@ -1301,7 +1750,6 @@ function SharesPage() {
|
|
|
1301
1750
|
// web-src/style.ts
|
|
1302
1751
|
var STYLE = `
|
|
1303
1752
|
.tsh-muted { color: var(--ta-muted); font-size: calc(12.5px * var(--ta-font-scale)); }
|
|
1304
|
-
.tsh-center { text-align: center; }
|
|
1305
1753
|
.tsh-error { margin: 0; color: var(--ta-red); font-size: calc(12.5px * var(--ta-font-scale)); }
|
|
1306
1754
|
.tsh-input { flex: 1; min-width: 0; height: 32px; padding: 0 10px; border: 1px solid var(--ta-border-field); border-radius: 8px; background: var(--ta-input); color: var(--ta-text); font: inherit; font-size: calc(13px * var(--ta-font-scale)); outline: none; }
|
|
1307
1755
|
.tsh-input:focus { border-color: var(--ta-border-focus); }
|
|
@@ -1310,7 +1758,6 @@ var STYLE = `
|
|
|
1310
1758
|
.tsh-dialog { display: flex; flex-direction: column; gap: 14px; width: min(440px, calc(100vw - 48px)); }
|
|
1311
1759
|
.tsh-options { display: flex; flex-direction: column; gap: 14px; }
|
|
1312
1760
|
.tsh-preview { border: 1px solid var(--ta-border-muted); border-radius: 12px; background: var(--ta-raised); padding: 10px 12px; }
|
|
1313
|
-
.tsh-preview-wait { color: var(--ta-muted); font-size: calc(12.5px * var(--ta-font-scale)); }
|
|
1314
1761
|
.tsh-preview-head { display: flex; justify-content: space-between; gap: 8px; font-size: calc(12.5px * var(--ta-font-scale)); font-weight: 500; }
|
|
1315
1762
|
.tsh-lines { margin: 8px 0 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 4px; max-height: 132px; overflow: hidden; -webkit-mask-image: linear-gradient(#000 70%, transparent); mask-image: linear-gradient(#000 70%, transparent); }
|
|
1316
1763
|
.tsh-lines li { display: flex; gap: 8px; min-width: 0; font-size: calc(12.5px * var(--ta-font-scale)); color: var(--ta-secondary); }
|
|
@@ -1334,21 +1781,11 @@ var STYLE = `
|
|
|
1334
1781
|
.tsh-toggle-text small { color: var(--ta-muted); font-size: calc(12px * var(--ta-font-scale)); line-height: 1.4; }
|
|
1335
1782
|
.tsh-disabled { opacity: .5; }
|
|
1336
1783
|
.tsh-actions { display: flex; justify-content: flex-end; gap: 8px; }
|
|
1337
|
-
.tsh-made { display: flex; flex-direction: column; align-items: stretch; gap: 10px; }
|
|
1338
|
-
.tsh-made .tsh-actions { justify-content: center; }
|
|
1339
|
-
.tsh-qr { align-self: center; width: 188px; padding: 10px; border-radius: 14px; background: #fff; border: 1px solid var(--ta-border-muted); }
|
|
1340
|
-
.tsh-qr svg { display: block; width: 100%; height: auto; }
|
|
1341
|
-
.tsh-hint { margin: 0; text-align: center; color: var(--ta-secondary); font-size: calc(12.5px * var(--ta-font-scale)); line-height: 1.5; }
|
|
1342
|
-
.tsh-link { padding: 8px 10px; border-radius: 8px; background: var(--ta-code); font-family: var(--ta-mono); font-size: calc(11.5px * var(--ta-font-scale)); color: var(--ta-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
1343
|
-
.tsh-password-note { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 10px; border-radius: 8px; background: var(--ta-raised); font-size: calc(12.5px * var(--ta-font-scale)); }
|
|
1344
|
-
.tsh-password-note code { font-family: var(--ta-mono); color: var(--ta-text); }
|
|
1345
|
-
.tsh-stop { align-self: center; border: 0; background: none; color: var(--ta-muted); font: inherit; font-size: calc(12.5px * var(--ta-font-scale)); cursor: pointer; padding: 4px 8px; border-radius: 6px; }
|
|
1346
|
-
.tsh-stop:hover { color: var(--ta-red); background: var(--ta-hover); }
|
|
1347
|
-
.tsh-stop.ta-busy { position: relative; }
|
|
1348
1784
|
|
|
1349
1785
|
/* My shares: the page fills its place and scrolls, its rows never wider than it. */
|
|
1350
1786
|
.tsh-page { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; width: 100%; height: 100%; overflow-y: auto; box-sizing: border-box; padding: 12px 16px 32px; }
|
|
1351
|
-
|
|
1787
|
+
/* As wide as the page (up to its width), not as its longest title: a flex item with auto margins would shrink to its content and go past a phone. */
|
|
1788
|
+
.tsh-rows { width: 100%; max-width: var(--ta-page-width); margin: 0 auto; padding: 0; list-style: none; display: flex; flex-direction: column; }
|
|
1352
1789
|
.tsh-item { --ta-swipe-bg: var(--ta-main); min-width: 0; border-radius: 10px; overflow: hidden; }
|
|
1353
1790
|
.tsh-row { display: flex; align-items: center; gap: 4px; min-width: 0; padding-right: 6px; border-radius: 10px; transition: background 120ms, opacity 200ms; }
|
|
1354
1791
|
.tsh-row:hover { background: var(--ta-hover); }
|
|
@@ -1372,12 +1809,10 @@ var STYLE = `
|
|
|
1372
1809
|
/* What a link shares, in the workbench. */
|
|
1373
1810
|
.tsh-view { height: 100%; overflow: auto; padding: 18px 20px 32px; box-sizing: border-box; }
|
|
1374
1811
|
.tsh-view-page { padding: 0; overflow: hidden; }
|
|
1375
|
-
.tsh-view.tsh-center { padding-top: 22vh; }
|
|
1376
1812
|
.tsh-head { margin: 0 auto 18px; max-width: 760px; }
|
|
1377
1813
|
.tsh-head h2 { margin: 0 0 4px; font-size: calc(18px * var(--ta-font-scale)); line-height: 1.35; word-break: break-word; }
|
|
1378
1814
|
.tsh-head p { margin: 0 0 12px; }
|
|
1379
1815
|
.tsh-import { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 10px; }
|
|
1380
|
-
.tsh-link-button { border: 0; background: none; padding: 2px 4px; color: var(--ta-link); font: inherit; font-size: calc(12.5px * var(--ta-font-scale)); cursor: pointer; }
|
|
1381
1816
|
.tsh-conversation { max-width: 760px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px; }
|
|
1382
1817
|
.tsh-user { display: flex; justify-content: flex-end; }
|
|
1383
1818
|
.tsh-bubble { max-width: 85%; padding: 8px 13px; border-radius: 14px 14px 4px 14px; background: var(--ta-user); white-space: pre-wrap; word-break: break-word; }
|
|
@@ -1453,7 +1888,7 @@ function activate(pi2) {
|
|
|
1453
1888
|
openLink(pi2, link.url);
|
|
1454
1889
|
return true;
|
|
1455
1890
|
}, { specific: true });
|
|
1456
|
-
pi2.registerView("shares", { title: () => t("sharesTitle"), icon: Share, render: SharesPage,
|
|
1891
|
+
pi2.registerView("shares", { title: () => t("sharesTitle"), icon: Share, render: SharesPage, group: "share", order: 80 });
|
|
1457
1892
|
pi2.registerToolRenderer((name, next) => name === SHARE_TOOL ? next() ?? {
|
|
1458
1893
|
renderCall: (args) => ({
|
|
1459
1894
|
verb: t("toolShare"),
|