@celljs/ta-share 4.28.0 → 4.30.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/host/index.mjs +551 -10
- package/package.json +4 -4
- package/web/index.js +216 -13
package/host/index.mjs
CHANGED
|
@@ -460,7 +460,7 @@ var DAY_MS4 = 24 * 60 * 60 * 1000;
|
|
|
460
460
|
var HOUR_MS3 = 60 * 60 * 1000;
|
|
461
461
|
|
|
462
462
|
// ../ta-relay/esm/common/relay-moderation-policy.js
|
|
463
|
-
var RELAY_OUTWARD_FEATURES = ["share", "rooms", "moments", "nearby"];
|
|
463
|
+
var RELAY_OUTWARD_FEATURES = ["share", "rooms", "moments", "nearby", "places"];
|
|
464
464
|
var RELAY_MODERATION_POLICY = {
|
|
465
465
|
auto: false,
|
|
466
466
|
people: 3,
|
|
@@ -468,7 +468,7 @@ var RELAY_MODERATION_POLICY = {
|
|
|
468
468
|
hostAfter: 3,
|
|
469
469
|
limitDays: 7,
|
|
470
470
|
needsAccount: [],
|
|
471
|
-
banCovers: ["share", "rooms", "moments", "nearby"],
|
|
471
|
+
banCovers: ["share", "rooms", "moments", "nearby", "places"],
|
|
472
472
|
newDays: 7,
|
|
473
473
|
newDaily: 5
|
|
474
474
|
};
|
|
@@ -561,10 +561,14 @@ var RELAY_PING = "ping";
|
|
|
561
561
|
var RELAY_PONG = "pong";
|
|
562
562
|
var RELAY_WAIT = '{"t":"wait"}';
|
|
563
563
|
var RELAY_PROOF = "ta-relay ready";
|
|
564
|
+
var RELAY_ROOM_PATH = "/r";
|
|
565
|
+
var RELAY_PLAY_PATH = "/p/";
|
|
566
|
+
var RELAY_HUB_MAX_MEMBERS = 101;
|
|
564
567
|
var RELAY_HUB_MAX_VALUE = 96 * 1024;
|
|
565
568
|
var RELAY_HUB_MAX_STATE = 3 * 1024 * 1024;
|
|
566
569
|
var RELAY_PICTURE_MAX_CHARS = 16 * 1024;
|
|
567
570
|
var RELAY_HUB_LOG_CHARS = 4 * 1024 * 1024;
|
|
571
|
+
var RELAY_HUB_HISTORY_MAX = 500;
|
|
568
572
|
|
|
569
573
|
// ../ta-relay/esm/common/relay-identity.js
|
|
570
574
|
var encoder2 = new TextEncoder;
|
|
@@ -691,6 +695,461 @@ var RelayIdentityUtil;
|
|
|
691
695
|
}
|
|
692
696
|
})(RelayIdentityUtil || (RelayIdentityUtil = {}));
|
|
693
697
|
|
|
698
|
+
// ../ta-relay/esm/common/relay-hub-charter.js
|
|
699
|
+
var RELAY_HUB_MAX_ADMINS = 8;
|
|
700
|
+
var MAX_RULES = 16;
|
|
701
|
+
var RelayHubCharterUtil;
|
|
702
|
+
(function(RelayHubCharterUtil2) {
|
|
703
|
+
function rules(input) {
|
|
704
|
+
if (!input || typeof input !== "object") {
|
|
705
|
+
return {};
|
|
706
|
+
}
|
|
707
|
+
return Object.fromEntries(Object.entries(input).filter(([name, value]) => /^[a-z][a-zA-Z]{0,30}$/.test(name) && typeof value === "boolean").slice(0, MAX_RULES));
|
|
708
|
+
}
|
|
709
|
+
RelayHubCharterUtil2.rules = rules;
|
|
710
|
+
async function seal(owner, body) {
|
|
711
|
+
const p = JSON.stringify(body);
|
|
712
|
+
return { p, s: await RelayIdentityUtil.sign(owner, p) };
|
|
713
|
+
}
|
|
714
|
+
RelayHubCharterUtil2.seal = seal;
|
|
715
|
+
async function open(ownerSign, room, charter) {
|
|
716
|
+
try {
|
|
717
|
+
const { p, s } = charter;
|
|
718
|
+
if (typeof p !== "string" || typeof s !== "string" || !await RelayIdentityUtil.verify(ownerSign, p, s)) {
|
|
719
|
+
return;
|
|
720
|
+
}
|
|
721
|
+
const body = JSON.parse(p);
|
|
722
|
+
if (body.room !== room || !(Number(body.v) > 0) || !Array.isArray(body.admins)) {
|
|
723
|
+
return;
|
|
724
|
+
}
|
|
725
|
+
const capacity = Math.round(Number(body.capacity));
|
|
726
|
+
const history = Math.min(Math.round(Number(body.history) || 0), RELAY_HUB_HISTORY_MAX);
|
|
727
|
+
return {
|
|
728
|
+
room,
|
|
729
|
+
v: Number(body.v),
|
|
730
|
+
admins: body.admins.filter((admin) => admin && typeof admin.member === "string" && typeof admin.id === "string").slice(0, RELAY_HUB_MAX_ADMINS).map((admin) => ({ member: admin.member, id: admin.id })),
|
|
731
|
+
rules: rules(body.rules),
|
|
732
|
+
...capacity >= 2 ? { capacity } : {},
|
|
733
|
+
...history > 0 ? { history } : {}
|
|
734
|
+
};
|
|
735
|
+
} catch (_a) {
|
|
736
|
+
return;
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
RelayHubCharterUtil2.open = open;
|
|
740
|
+
async function openRoster(keys, sealed, owner, room) {
|
|
741
|
+
try {
|
|
742
|
+
const found = RelayHubUtil.keyFor(keys, sealed);
|
|
743
|
+
if (!found) {
|
|
744
|
+
return;
|
|
745
|
+
}
|
|
746
|
+
const envelope = JSON.parse(await RelayKeys.open(found.key, found.sealed));
|
|
747
|
+
const signed = JSON.parse(envelope.p);
|
|
748
|
+
if (!(signed === null || signed === undefined ? undefined : signed.b) || !Array.isArray(signed.b.members) || typeof signed.m !== "string") {
|
|
749
|
+
return;
|
|
750
|
+
}
|
|
751
|
+
const members = signed.b.members.filter((member) => !!member && typeof member.member === "string");
|
|
752
|
+
const head = members.find((member) => member.owner && member.id === owner.id);
|
|
753
|
+
if (!head) {
|
|
754
|
+
return;
|
|
755
|
+
}
|
|
756
|
+
const charter = signed.b.charter ? await open(owner.sign, room, signed.b.charter) : undefined;
|
|
757
|
+
let key;
|
|
758
|
+
let byAdmin = false;
|
|
759
|
+
if (signed.m === head.member) {
|
|
760
|
+
key = owner.sign;
|
|
761
|
+
} else {
|
|
762
|
+
const named = charter === null || charter === undefined ? undefined : charter.admins.find((admin) => admin.member === signed.m);
|
|
763
|
+
const entry = named && members.find((member) => member.member === named.member && member.id === named.id && !member.owner && !member.guest);
|
|
764
|
+
if (entry && await RelayIdentityUtil.check(entry)) {
|
|
765
|
+
key = entry.sign;
|
|
766
|
+
byAdmin = true;
|
|
767
|
+
}
|
|
768
|
+
}
|
|
769
|
+
if (!key || !await RelayIdentityUtil.verify(key, envelope.p, envelope.s)) {
|
|
770
|
+
return;
|
|
771
|
+
}
|
|
772
|
+
return {
|
|
773
|
+
signer: signed.m,
|
|
774
|
+
byAdmin,
|
|
775
|
+
body: { v: Number(signed.b.v), members, ...signed.b.charter ? { charter: signed.b.charter } : {} },
|
|
776
|
+
...charter ? { charter } : {}
|
|
777
|
+
};
|
|
778
|
+
} catch (_a) {
|
|
779
|
+
return;
|
|
780
|
+
}
|
|
781
|
+
}
|
|
782
|
+
RelayHubCharterUtil2.openRoster = openRoster;
|
|
783
|
+
function adminMay(next, before) {
|
|
784
|
+
const charter = next.charter;
|
|
785
|
+
if (!charter || (before === null || before === undefined ? undefined : before.charter) && charter.v < before.charter.v) {
|
|
786
|
+
return false;
|
|
787
|
+
}
|
|
788
|
+
const has = (member) => next.body.members.some((each) => each.member === member);
|
|
789
|
+
if (!charter.admins.every((admin) => has(admin.member))) {
|
|
790
|
+
return false;
|
|
791
|
+
}
|
|
792
|
+
const head = before === null || before === undefined ? undefined : before.members.find((member) => member.owner);
|
|
793
|
+
if (head && !next.body.members.some((member) => member.member === head.member && member.owner && member.id === head.id)) {
|
|
794
|
+
return false;
|
|
795
|
+
}
|
|
796
|
+
return next.body.members.every((member) => {
|
|
797
|
+
const was = before === null || before === undefined ? undefined : before.members.find((each) => each.member === member.member);
|
|
798
|
+
return !was || was.id === member.id && !!was.owner === !!member.owner;
|
|
799
|
+
});
|
|
800
|
+
}
|
|
801
|
+
RelayHubCharterUtil2.adminMay = adminMay;
|
|
802
|
+
function answerProof(head, charter) {
|
|
803
|
+
return { head: RelayIdentityUtil.publicOf(head), charter };
|
|
804
|
+
}
|
|
805
|
+
RelayHubCharterUtil2.answerProof = answerProof;
|
|
806
|
+
async function answeredBy(signer, ownerId, room, proof) {
|
|
807
|
+
if (signer.id === ownerId) {
|
|
808
|
+
return await RelayIdentityUtil.check(signer) ? signer : undefined;
|
|
809
|
+
}
|
|
810
|
+
const head = proof.head;
|
|
811
|
+
if (!head || head.id !== ownerId || !await RelayIdentityUtil.check(head) || !await RelayIdentityUtil.check(signer)) {
|
|
812
|
+
return;
|
|
813
|
+
}
|
|
814
|
+
const charter = await open(head.sign, room, proof.charter);
|
|
815
|
+
return (charter === null || charter === undefined ? undefined : charter.admins.some((admin) => admin.id === signer.id)) ? head : undefined;
|
|
816
|
+
}
|
|
817
|
+
RelayHubCharterUtil2.answeredBy = answeredBy;
|
|
818
|
+
})(RelayHubCharterUtil || (RelayHubCharterUtil = {}));
|
|
819
|
+
|
|
820
|
+
// ../ta-relay/esm/common/relay-hub-util.js
|
|
821
|
+
var RelayHubUtil;
|
|
822
|
+
(function(RelayHubUtil2) {
|
|
823
|
+
function epochKeys(k) {
|
|
824
|
+
if (k === undefined) {
|
|
825
|
+
return;
|
|
826
|
+
}
|
|
827
|
+
if (!k || typeof k !== "object" || Array.isArray(k)) {
|
|
828
|
+
return null;
|
|
829
|
+
}
|
|
830
|
+
const entries = Object.entries(k);
|
|
831
|
+
const ok = entries.length <= RELAY_HUB_MAX_MEMBERS && entries.every(([member, value]) => RELAY_ID.test(member) && typeof value === "string" && value.length < 4096);
|
|
832
|
+
return ok ? Object.fromEntries(entries) : null;
|
|
833
|
+
}
|
|
834
|
+
RelayHubUtil2.epochKeys = epochKeys;
|
|
835
|
+
function link(link2) {
|
|
836
|
+
const fragment = new URLSearchParams({ v: "1", r: link2.room, i: link2.invite, o: link2.owner, n: link2.title, by: link2.by });
|
|
837
|
+
if (link2.kind) {
|
|
838
|
+
fragment.set("c", link2.kind);
|
|
839
|
+
}
|
|
840
|
+
return `${link2.relay}${RELAY_ROOM_PATH}#${fragment}`;
|
|
841
|
+
}
|
|
842
|
+
RelayHubUtil2.link = link;
|
|
843
|
+
function withKind(text, kind) {
|
|
844
|
+
return link({ ...parse(text), kind });
|
|
845
|
+
}
|
|
846
|
+
RelayHubUtil2.withKind = withKind;
|
|
847
|
+
function playLink(text, kind) {
|
|
848
|
+
const url = new URL(withKind(text, kind));
|
|
849
|
+
return `${url.origin}${RELAY_PLAY_PATH}${kind}${url.hash}`;
|
|
850
|
+
}
|
|
851
|
+
RelayHubUtil2.playLink = playLink;
|
|
852
|
+
function playKind(text) {
|
|
853
|
+
try {
|
|
854
|
+
const path = new URL(text.trim()).pathname;
|
|
855
|
+
const kind = path.startsWith(RELAY_PLAY_PATH) ? path.slice(RELAY_PLAY_PATH.length) : "";
|
|
856
|
+
return /^[a-z0-9-]{1,40}$/.test(kind) ? kind : undefined;
|
|
857
|
+
} catch (_a) {
|
|
858
|
+
return;
|
|
859
|
+
}
|
|
860
|
+
}
|
|
861
|
+
RelayHubUtil2.playKind = playKind;
|
|
862
|
+
function is(text) {
|
|
863
|
+
try {
|
|
864
|
+
parse(text);
|
|
865
|
+
return true;
|
|
866
|
+
} catch (_a) {
|
|
867
|
+
return false;
|
|
868
|
+
}
|
|
869
|
+
}
|
|
870
|
+
RelayHubUtil2.is = is;
|
|
871
|
+
function parse(text) {
|
|
872
|
+
var _a, _b, _c;
|
|
873
|
+
const url = new URL(text.trim());
|
|
874
|
+
const fragment = new URLSearchParams(url.hash.slice(1));
|
|
875
|
+
const [room, invite, owner] = ["r", "i", "o"].map((name) => {
|
|
876
|
+
var _a2;
|
|
877
|
+
return (_a2 = fragment.get(name)) !== null && _a2 !== undefined ? _a2 : "";
|
|
878
|
+
});
|
|
879
|
+
const play = playKind(text);
|
|
880
|
+
if (!/^https?:$/.test(url.protocol) || url.pathname !== RELAY_ROOM_PATH && (!play || play !== fragment.get("c")) || fragment.get("v") !== "1" || !RELAY_ID.test(room) || !/^[A-Za-z0-9_-]{43}$/.test(invite) || !/^[A-Za-z0-9_-]{22}$/.test(owner)) {
|
|
881
|
+
throw new Error("Not a link inviting into a group chat of Ta.");
|
|
882
|
+
}
|
|
883
|
+
const kind = (_a = fragment.get("c")) !== null && _a !== undefined ? _a : "";
|
|
884
|
+
return {
|
|
885
|
+
relay: url.origin,
|
|
886
|
+
room,
|
|
887
|
+
invite,
|
|
888
|
+
owner,
|
|
889
|
+
title: ((_b = fragment.get("n")) !== null && _b !== undefined ? _b : "").slice(0, 200),
|
|
890
|
+
by: ((_c = fragment.get("by")) !== null && _c !== undefined ? _c : "").slice(0, 100),
|
|
891
|
+
.../^[a-z0-9-]{1,40}$/.test(kind) ? { kind } : {}
|
|
892
|
+
};
|
|
893
|
+
}
|
|
894
|
+
RelayHubUtil2.parse = parse;
|
|
895
|
+
function randomId() {
|
|
896
|
+
return RelayBytes.toBase64(RelayBytes.random(16));
|
|
897
|
+
}
|
|
898
|
+
RelayHubUtil2.randomId = randomId;
|
|
899
|
+
function randomKey() {
|
|
900
|
+
return RelayBytes.toBase64(RelayBytes.random(32));
|
|
901
|
+
}
|
|
902
|
+
RelayHubUtil2.randomKey = randomKey;
|
|
903
|
+
async function keys(roomKey, epochs = {}) {
|
|
904
|
+
const key = RelayBytes.fromBase64(roomKey);
|
|
905
|
+
const none = new Uint8Array(0);
|
|
906
|
+
const sealOf = async (value) => RelayKeys.aesKey(await RelayKeys.hkdf(value, none, "ta-room/1 seal"));
|
|
907
|
+
const ring = new Map([[0, await sealOf(key)]]);
|
|
908
|
+
for (const [epoch2, value] of Object.entries(epochs)) {
|
|
909
|
+
const n = Number(epoch2);
|
|
910
|
+
if (Number.isInteger(n) && n > 0) {
|
|
911
|
+
ring.set(n, await sealOf(RelayBytes.fromBase64(value)));
|
|
912
|
+
}
|
|
913
|
+
}
|
|
914
|
+
const epoch = Math.max(...ring.keys());
|
|
915
|
+
return { seal: ring.get(epoch), names: await RelayKeys.hkdf(key, none, "ta-room/1 key"), epoch, ring };
|
|
916
|
+
}
|
|
917
|
+
RelayHubUtil2.keys = keys;
|
|
918
|
+
async function sealIn(keys2, identity, member, body, at = Date.now()) {
|
|
919
|
+
const sealed = await seal(keys2.seal, identity, member, body, at);
|
|
920
|
+
return keys2.epoch ? `${keys2.epoch}.${sealed}` : sealed;
|
|
921
|
+
}
|
|
922
|
+
RelayHubUtil2.sealIn = sealIn;
|
|
923
|
+
function keyFor(keys2, sealed) {
|
|
924
|
+
const dot = sealed.indexOf(".");
|
|
925
|
+
const epoch = dot > 0 ? Number(sealed.slice(0, dot)) : 0;
|
|
926
|
+
const key = Number.isInteger(epoch) ? keys2.ring.get(epoch) : undefined;
|
|
927
|
+
return key && { key, sealed: dot > 0 ? sealed.slice(dot + 1) : sealed, epoch };
|
|
928
|
+
}
|
|
929
|
+
RelayHubUtil2.keyFor = keyFor;
|
|
930
|
+
async function openIn(keys2, sealed, signOf, options = {}) {
|
|
931
|
+
const found = keyFor(keys2, String(sealed));
|
|
932
|
+
return found ? open(found.key, found.sealed, signOf, options) : undefined;
|
|
933
|
+
}
|
|
934
|
+
RelayHubUtil2.openIn = openIn;
|
|
935
|
+
async function keyId(keys2, name) {
|
|
936
|
+
return (await RelayKeys.hmac(keys2.names, name)).slice(0, 22);
|
|
937
|
+
}
|
|
938
|
+
RelayHubUtil2.keyId = keyId;
|
|
939
|
+
async function inviteProof(invite) {
|
|
940
|
+
return RelayBytes.toBase64(await RelayKeys.hkdf(RelayBytes.fromBase64(invite), new Uint8Array(0), "ta-room/1 ask auth"));
|
|
941
|
+
}
|
|
942
|
+
RelayHubUtil2.inviteProof = inviteProof;
|
|
943
|
+
async function inviteKey(invite) {
|
|
944
|
+
return RelayKeys.aesKey(await RelayKeys.hkdf(RelayBytes.fromBase64(invite), new Uint8Array(0), "ta-room/1 ask seal"));
|
|
945
|
+
}
|
|
946
|
+
RelayHubUtil2.inviteKey = inviteKey;
|
|
947
|
+
async function seal(key, identity, member, body, at = Date.now()) {
|
|
948
|
+
const p = JSON.stringify({ m: member, at, b: body });
|
|
949
|
+
return RelayKeys.seal(key, JSON.stringify({ p, s: await RelayIdentityUtil.sign(identity, p) }));
|
|
950
|
+
}
|
|
951
|
+
RelayHubUtil2.seal = seal;
|
|
952
|
+
async function open(key, sealed, signOf, options = {}) {
|
|
953
|
+
var _a;
|
|
954
|
+
try {
|
|
955
|
+
const envelope = JSON.parse(await RelayKeys.open(key, sealed));
|
|
956
|
+
const signed = JSON.parse(envelope.p);
|
|
957
|
+
const sign = typeof signed.m === "string" ? signOf(signed.m) : undefined;
|
|
958
|
+
if (!sign || !await RelayIdentityUtil.verify(sign, envelope.p, envelope.s)) {
|
|
959
|
+
return;
|
|
960
|
+
}
|
|
961
|
+
if (options.skewMs !== undefined && Math.abs(((_a = options.now) !== null && _a !== undefined ? _a : Date.now()) - Number(signed.at)) > options.skewMs) {
|
|
962
|
+
return;
|
|
963
|
+
}
|
|
964
|
+
return signed;
|
|
965
|
+
} catch (_b) {
|
|
966
|
+
return;
|
|
967
|
+
}
|
|
968
|
+
}
|
|
969
|
+
RelayHubUtil2.open = open;
|
|
970
|
+
async function sealAsk(invite, identity, member, at = Date.now(), guest = false) {
|
|
971
|
+
const body = { ...RelayIdentityUtil.publicOf(identity), member, at, ...guest ? { guest: true } : {} };
|
|
972
|
+
return seal(await inviteKey(invite), identity, member, body, at);
|
|
973
|
+
}
|
|
974
|
+
RelayHubUtil2.sealAsk = sealAsk;
|
|
975
|
+
async function openAsk(invite, sealed) {
|
|
976
|
+
try {
|
|
977
|
+
const envelope = JSON.parse(await RelayKeys.open(await inviteKey(invite), sealed));
|
|
978
|
+
const signed = JSON.parse(envelope.p);
|
|
979
|
+
const body = signed.b;
|
|
980
|
+
if (!body || signed.m !== body.member || !RELAY_ID.test(String(body.member)) || !await RelayIdentityUtil.check(body) || !await RelayIdentityUtil.verify(body.sign, envelope.p, envelope.s)) {
|
|
981
|
+
return;
|
|
982
|
+
}
|
|
983
|
+
return {
|
|
984
|
+
...RelayIdentityUtil.publicOf(body),
|
|
985
|
+
name: String(body.name).slice(0, 100),
|
|
986
|
+
member: body.member,
|
|
987
|
+
at: Number(body.at),
|
|
988
|
+
...body.guest === true ? { guest: true } : {}
|
|
989
|
+
};
|
|
990
|
+
} catch (_a) {
|
|
991
|
+
return;
|
|
992
|
+
}
|
|
993
|
+
}
|
|
994
|
+
RelayHubUtil2.openAsk = openAsk;
|
|
995
|
+
async function sealAnswer(owner, room, ask, body, invite, proof) {
|
|
996
|
+
const key = await RelayKeys.aesKey(await RelayIdentityUtil.agree(owner, ask.box, room, "ta-room/1 answer"));
|
|
997
|
+
const d = await RelayKeys.seal(key, JSON.stringify(body));
|
|
998
|
+
const signed = `${room}
|
|
999
|
+
${ask.member}
|
|
1000
|
+
${d}`;
|
|
1001
|
+
const answer = JSON.stringify({ owner: RelayIdentityUtil.publicOf(owner), d, s: await RelayIdentityUtil.sign(owner, signed), ...proof !== null && proof !== undefined ? proof : {} });
|
|
1002
|
+
return RelayKeys.seal(await inviteKey(invite), answer);
|
|
1003
|
+
}
|
|
1004
|
+
RelayHubUtil2.sealAnswer = sealAnswer;
|
|
1005
|
+
async function openAnswer(identity, room, member, ownerId, answer, invite) {
|
|
1006
|
+
try {
|
|
1007
|
+
const { owner, d, s, head, charter } = JSON.parse(await RelayKeys.open(await inviteKey(invite), answer));
|
|
1008
|
+
const named = await RelayHubCharterUtil.answeredBy(owner, ownerId, room, { head, charter });
|
|
1009
|
+
if (!named || !await RelayIdentityUtil.verify(owner.sign, `${room}
|
|
1010
|
+
${member}
|
|
1011
|
+
${d}`, s)) {
|
|
1012
|
+
return;
|
|
1013
|
+
}
|
|
1014
|
+
const key = await RelayKeys.aesKey(await RelayIdentityUtil.agree(identity, owner.box, room, "ta-room/1 answer"));
|
|
1015
|
+
const body = JSON.parse(await RelayKeys.open(key, d));
|
|
1016
|
+
RelayBytes.fromBase64(body.key);
|
|
1017
|
+
return { owner: { ...RelayIdentityUtil.publicOf(named), name: String(named.name).slice(0, 100) }, body };
|
|
1018
|
+
} catch (_a) {
|
|
1019
|
+
return;
|
|
1020
|
+
}
|
|
1021
|
+
}
|
|
1022
|
+
RelayHubUtil2.openAnswer = openAnswer;
|
|
1023
|
+
async function sealMoved(owner, room, ask, link2, invite) {
|
|
1024
|
+
const key = await RelayKeys.aesKey(await RelayIdentityUtil.agree(owner, ask.box, room, "ta-room/1 moved"));
|
|
1025
|
+
const d = await RelayKeys.seal(key, link2);
|
|
1026
|
+
const moved = JSON.stringify({
|
|
1027
|
+
owner: RelayIdentityUtil.publicOf(owner),
|
|
1028
|
+
d,
|
|
1029
|
+
s: await RelayIdentityUtil.sign(owner, `${room}
|
|
1030
|
+
${ask.member}
|
|
1031
|
+
moved
|
|
1032
|
+
${d}`)
|
|
1033
|
+
});
|
|
1034
|
+
return RelayKeys.seal(await inviteKey(invite), moved);
|
|
1035
|
+
}
|
|
1036
|
+
RelayHubUtil2.sealMoved = sealMoved;
|
|
1037
|
+
async function openMoved(identity, room, member, ownerId, moved, invite) {
|
|
1038
|
+
try {
|
|
1039
|
+
const { owner, d, s } = JSON.parse(await RelayKeys.open(await inviteKey(invite), moved));
|
|
1040
|
+
if (!await RelayIdentityUtil.check(owner) || owner.id !== ownerId || !await RelayIdentityUtil.verify(owner.sign, `${room}
|
|
1041
|
+
${member}
|
|
1042
|
+
moved
|
|
1043
|
+
${d}`, s)) {
|
|
1044
|
+
return;
|
|
1045
|
+
}
|
|
1046
|
+
const key = await RelayKeys.aesKey(await RelayIdentityUtil.agree(identity, owner.box, room, "ta-room/1 moved"));
|
|
1047
|
+
const link2 = parse(await RelayKeys.open(key, d));
|
|
1048
|
+
return link2.owner === ownerId && link2.room !== room ? link2 : undefined;
|
|
1049
|
+
} catch (_a) {
|
|
1050
|
+
return;
|
|
1051
|
+
}
|
|
1052
|
+
}
|
|
1053
|
+
RelayHubUtil2.openMoved = openMoved;
|
|
1054
|
+
})(RelayHubUtil || (RelayHubUtil = {}));
|
|
1055
|
+
|
|
1056
|
+
// ../ta-relay/esm/common/relay-places-protocol.js
|
|
1057
|
+
var RELAY_PLACE_KIND = /^[a-z0-9-]{1,40}$/;
|
|
1058
|
+
var KIND = RELAY_PLACE_KIND;
|
|
1059
|
+
var RELAY_PLACES_SHOT_PATH = "/v1/places/shot";
|
|
1060
|
+
var RELAY_PLACE_ZOOM = 12;
|
|
1061
|
+
var RELAY_PLACE_CELL_ZOOM = 6;
|
|
1062
|
+
var RELAY_PLACE_CELLS = 24;
|
|
1063
|
+
var RELAY_PLACE_ENTRIES = ["ask", "visit"];
|
|
1064
|
+
var RELAY_PLACE_SHOT_CHARS = 280 * 1024;
|
|
1065
|
+
var RelayPlacesUtil;
|
|
1066
|
+
(function(RelayPlacesUtil2) {
|
|
1067
|
+
function cellOf(x, y) {
|
|
1068
|
+
const per = 2 ** (RELAY_PLACE_ZOOM - RELAY_PLACE_CELL_ZOOM);
|
|
1069
|
+
return `${Math.floor(x / per)},${Math.floor(y / per)}`;
|
|
1070
|
+
}
|
|
1071
|
+
RelayPlacesUtil2.cellOf = cellOf;
|
|
1072
|
+
function tileOf(lon, lat) {
|
|
1073
|
+
const n = 2 ** RELAY_PLACE_ZOOM;
|
|
1074
|
+
const sin = Math.sin(Math.max(-85, Math.min(85, lat)) * Math.PI / 180);
|
|
1075
|
+
const x = Math.floor((lon + 180) / 360 * n);
|
|
1076
|
+
const y = Math.floor((0.5 - Math.log((1 + sin) / (1 - sin)) / (4 * Math.PI)) * n);
|
|
1077
|
+
return { x: Math.max(0, Math.min(n - 1, x)), y: Math.max(0, Math.min(n - 1, y)) };
|
|
1078
|
+
}
|
|
1079
|
+
RelayPlacesUtil2.tileOf = tileOf;
|
|
1080
|
+
function centreOf(x, y) {
|
|
1081
|
+
const n = 2 ** RELAY_PLACE_ZOOM;
|
|
1082
|
+
const lon = (x + 0.5) / n * 360 - 180;
|
|
1083
|
+
const lat = Math.atan(Math.sinh(Math.PI * (1 - 2 * (y + 0.5) / n))) * 180 / Math.PI;
|
|
1084
|
+
return { lon, lat };
|
|
1085
|
+
}
|
|
1086
|
+
RelayPlacesUtil2.centreOf = centreOf;
|
|
1087
|
+
function cells(text) {
|
|
1088
|
+
const n = 2 ** RELAY_PLACE_CELL_ZOOM;
|
|
1089
|
+
return [
|
|
1090
|
+
...new Set((text !== null && text !== undefined ? text : "").split(";").map((each) => /^(\d{1,3}),(\d{1,3})$/.exec(each.trim())).filter((match) => !!match && Number(match[1]) < n && Number(match[2]) < n).map((match) => `${Number(match[1])},${Number(match[2])}`))
|
|
1091
|
+
].slice(0, RELAY_PLACE_CELLS);
|
|
1092
|
+
}
|
|
1093
|
+
RelayPlacesUtil2.cells = cells;
|
|
1094
|
+
function place(value) {
|
|
1095
|
+
var _a, _b;
|
|
1096
|
+
const given = value;
|
|
1097
|
+
const n = 2 ** RELAY_PLACE_ZOOM;
|
|
1098
|
+
if (!given || typeof given.room !== "string" || !RELAY_ID.test(given.room) || typeof given.kind !== "string" || !KIND.test(given.kind) || !Number.isInteger(given.x) || !Number.isInteger(given.y) || given.x < 0 || given.y < 0 || given.x >= n || given.y >= n || !RELAY_PLACE_ENTRIES.includes(given.entry) || typeof given.link !== "string" || given.link.length > 2048 || !Number.isFinite(given.at)) {
|
|
1099
|
+
return;
|
|
1100
|
+
}
|
|
1101
|
+
const title = String((_a = given.title) !== null && _a !== undefined ? _a : "").trim().slice(0, 80);
|
|
1102
|
+
const purpose = typeof given.purpose === "string" && KIND.test(given.purpose) ? given.purpose : undefined;
|
|
1103
|
+
if (!title) {
|
|
1104
|
+
return;
|
|
1105
|
+
}
|
|
1106
|
+
return {
|
|
1107
|
+
room: given.room,
|
|
1108
|
+
kind: given.kind,
|
|
1109
|
+
title,
|
|
1110
|
+
by: String((_b = given.by) !== null && _b !== undefined ? _b : "").trim().slice(0, 60),
|
|
1111
|
+
x: given.x,
|
|
1112
|
+
y: given.y,
|
|
1113
|
+
entry: given.entry,
|
|
1114
|
+
...purpose ? { purpose } : {},
|
|
1115
|
+
people: Math.max(0, Math.min(1e4, Math.round(Number(given.people) || 0))),
|
|
1116
|
+
link: given.link,
|
|
1117
|
+
at: Number(given.at)
|
|
1118
|
+
};
|
|
1119
|
+
}
|
|
1120
|
+
RelayPlacesUtil2.place = place;
|
|
1121
|
+
function report(value) {
|
|
1122
|
+
var _a;
|
|
1123
|
+
const given = value;
|
|
1124
|
+
if (!given || typeof given.room !== "string" || !RELAY_ID.test(given.room) || typeof given.owner !== "string" || !/^[A-Za-z0-9_-]{22}$/.test(given.owner) || !RELAY_REPORT_REASONS.includes(given.reason)) {
|
|
1125
|
+
return;
|
|
1126
|
+
}
|
|
1127
|
+
const kind = typeof given.kind === "string" && KIND.test(given.kind) ? given.kind : undefined;
|
|
1128
|
+
const note = typeof given.note === "string" ? given.note.trim().slice(0, 500) : "";
|
|
1129
|
+
const shot = typeof given.shot === "string" && given.shot.length <= RELAY_PLACE_SHOT_CHARS && /^data:image\/(jpeg|png|webp);base64,[A-Za-z0-9+/]+={0,2}$/.test(given.shot) ? given.shot : undefined;
|
|
1130
|
+
return {
|
|
1131
|
+
room: given.room,
|
|
1132
|
+
owner: given.owner,
|
|
1133
|
+
title: String((_a = given.title) !== null && _a !== undefined ? _a : "").trim().slice(0, 80),
|
|
1134
|
+
...kind ? { kind } : {},
|
|
1135
|
+
reason: given.reason,
|
|
1136
|
+
...note ? { note } : {},
|
|
1137
|
+
...shot ? { shot } : {}
|
|
1138
|
+
};
|
|
1139
|
+
}
|
|
1140
|
+
RelayPlacesUtil2.report = report;
|
|
1141
|
+
async function digest(text) {
|
|
1142
|
+
const bytes = new Uint8Array(await globalThis.crypto.subtle.digest("SHA-256", new TextEncoder().encode(text)));
|
|
1143
|
+
return [...bytes.subarray(0, 8)].map((byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
1144
|
+
}
|
|
1145
|
+
RelayPlacesUtil2.digest = digest;
|
|
1146
|
+
})(RelayPlacesUtil || (RelayPlacesUtil = {}));
|
|
1147
|
+
|
|
1148
|
+
// ../ta-relay/esm/common/relay-places.js
|
|
1149
|
+
var DAY_MS6 = 24 * 60 * 60 * 1000;
|
|
1150
|
+
var HOUR_MS4 = 60 * 60 * 1000;
|
|
1151
|
+
var SKEW_MS = 10 * 60 * 1000;
|
|
1152
|
+
|
|
694
1153
|
// ../ta-relay/esm/common/relay-cipher.js
|
|
695
1154
|
var encoder3 = new TextEncoder;
|
|
696
1155
|
var decoder2 = new TextDecoder;
|
|
@@ -1256,7 +1715,7 @@ class RelayContentError extends Error {
|
|
|
1256
1715
|
var PBKDF2_ITERATIONS = 600000;
|
|
1257
1716
|
var BLOCKED_MESSAGE = "The operator of the relay blocked this link after a report.";
|
|
1258
1717
|
var PLAIN_KINDS = new Set(["ta-conversation", "file"]);
|
|
1259
|
-
var
|
|
1718
|
+
var KIND2 = /^[a-z0-9][a-z0-9-]{0,31}$/;
|
|
1260
1719
|
var RelayContentUtil;
|
|
1261
1720
|
(function(RelayContentUtil2) {
|
|
1262
1721
|
function link(content) {
|
|
@@ -1276,7 +1735,7 @@ var RelayContentUtil;
|
|
|
1276
1735
|
if (content.offline && content.access !== "self" && content.access !== "people") {
|
|
1277
1736
|
fragment.set("o", "1");
|
|
1278
1737
|
}
|
|
1279
|
-
if (content.kind && !PLAIN_KINDS.has(content.kind) &&
|
|
1738
|
+
if (content.kind && !PLAIN_KINDS.has(content.kind) && KIND2.test(content.kind)) {
|
|
1280
1739
|
fragment.set("c", content.kind);
|
|
1281
1740
|
}
|
|
1282
1741
|
return `${(_b = content.page) !== null && _b !== undefined ? _b : content.relay}${RELAY_CONTENT_PATH}#${fragment}`;
|
|
@@ -1307,7 +1766,7 @@ var RelayContentUtil;
|
|
|
1307
1766
|
}
|
|
1308
1767
|
const kind = (_b = fragment.get("c")) !== null && _b !== undefined ? _b : "";
|
|
1309
1768
|
if (people) {
|
|
1310
|
-
return { relay: url.origin, host, share, access: "people", owner, offline: false, ...
|
|
1769
|
+
return { relay: url.origin, host, share, access: "people", owner, offline: false, ...KIND2.test(kind) ? { kind } : {} };
|
|
1311
1770
|
}
|
|
1312
1771
|
return {
|
|
1313
1772
|
relay: url.origin,
|
|
@@ -1316,7 +1775,7 @@ var RelayContentUtil;
|
|
|
1316
1775
|
key: self ? undefined : key,
|
|
1317
1776
|
access: self ? "self" : fragment.get("p") === "1" ? "password" : "link",
|
|
1318
1777
|
offline: !self && fragment.get("o") === "1",
|
|
1319
|
-
...
|
|
1778
|
+
...KIND2.test(kind) ? { kind } : {}
|
|
1320
1779
|
};
|
|
1321
1780
|
}
|
|
1322
1781
|
RelayContentUtil2.parse = parse;
|
|
@@ -1583,8 +2042,8 @@ var RelayReportUtil;
|
|
|
1583
2042
|
})(RelayReportUtil || (RelayReportUtil = {}));
|
|
1584
2043
|
|
|
1585
2044
|
// ../ta-relay/esm/common/relay-moderation.js
|
|
1586
|
-
var
|
|
1587
|
-
var
|
|
2045
|
+
var HOUR_MS5 = 60 * 60 * 1000;
|
|
2046
|
+
var DAY_MS7 = 24 * HOUR_MS5;
|
|
1588
2047
|
|
|
1589
2048
|
// ../ta-relay/esm/common/relay-moderation-client.js
|
|
1590
2049
|
async function call(url, token, init) {
|
|
@@ -1621,6 +2080,10 @@ var RelayModerationClient;
|
|
|
1621
2080
|
return call(`${base(relay)}${RELAY_MODERATION_PATH}`, token, { method: "POST", body: JSON.stringify(action) });
|
|
1622
2081
|
}
|
|
1623
2082
|
RelayModerationClient2.apply = apply;
|
|
2083
|
+
async function shots(relay, token, room) {
|
|
2084
|
+
return (await call(`${base(relay)}${RELAY_PLACES_SHOT_PATH}?room=${encodeURIComponent(room)}`, token)).shots;
|
|
2085
|
+
}
|
|
2086
|
+
RelayModerationClient2.shots = shots;
|
|
1624
2087
|
})(RelayModerationClient || (RelayModerationClient = {}));
|
|
1625
2088
|
var RelayStandingClient;
|
|
1626
2089
|
(function(RelayStandingClient2) {
|
|
@@ -1877,6 +2340,7 @@ var ShareLink;
|
|
|
1877
2340
|
var OPERATOR_LOOK_MS = 15 * 60 * 1000;
|
|
1878
2341
|
var TOLD_KEY = "operator.told";
|
|
1879
2342
|
var TOLD_LOG_KEY = "operator.toldLog";
|
|
2343
|
+
var TOLD_PLACES_KEY = "operator.toldPlaces";
|
|
1880
2344
|
|
|
1881
2345
|
class ShareModeration {
|
|
1882
2346
|
host;
|
|
@@ -1952,6 +2416,14 @@ class ShareModeration {
|
|
|
1952
2416
|
}
|
|
1953
2417
|
return { relay, operator: true, ...await RelayModerationClient.apply(relay, token, action) };
|
|
1954
2418
|
}
|
|
2419
|
+
async shots(room) {
|
|
2420
|
+
const relay = await this.relay();
|
|
2421
|
+
const token = await this.token(relay);
|
|
2422
|
+
if (!token) {
|
|
2423
|
+
throw new Error("This Ta keeps no token of the operator of the relay.");
|
|
2424
|
+
}
|
|
2425
|
+
return RelayModerationClient.shots(relay, token, room);
|
|
2426
|
+
}
|
|
1955
2427
|
async look() {
|
|
1956
2428
|
const relay = await this.relay();
|
|
1957
2429
|
const token = await this.token(relay);
|
|
@@ -1978,6 +2450,26 @@ class ShareModeration {
|
|
|
1978
2450
|
if (fresh.length) {
|
|
1979
2451
|
await this.host.setExtensionData(NAME, TOLD_KEY, ShareModeration.toldOf(state.reports));
|
|
1980
2452
|
}
|
|
2453
|
+
const toldPlaces = await this.host.getExtensionData(NAME, TOLD_PLACES_KEY) ?? {};
|
|
2454
|
+
const blocked = state.places?.blocks.places ?? [];
|
|
2455
|
+
const places = (state.places?.reports ?? []).filter((report) => report.last > (toldPlaces[report.room] ?? 0) && !blocked.includes(report.room));
|
|
2456
|
+
for (const report of places) {
|
|
2457
|
+
await this.host.callPackageHost("@celljs/ta-notify", "notify", [
|
|
2458
|
+
{
|
|
2459
|
+
from: NAME,
|
|
2460
|
+
id: `place:${report.room}:${report.last}`,
|
|
2461
|
+
level: "ask",
|
|
2462
|
+
title: ShareServerTexts.reportsTitle(),
|
|
2463
|
+
text: ShareServerTexts.reported(report.reason, report.count, [`「${report.title}」`, report.note].filter(Boolean).join(" ")),
|
|
2464
|
+
view: REPORTS_VIEW
|
|
2465
|
+
}
|
|
2466
|
+
]).catch(() => {
|
|
2467
|
+
return;
|
|
2468
|
+
});
|
|
2469
|
+
}
|
|
2470
|
+
if (places.length) {
|
|
2471
|
+
await this.host.setExtensionData(NAME, TOLD_PLACES_KEY, Object.fromEntries((state.places?.reports ?? []).map((report) => [report.room, report.last])));
|
|
2472
|
+
}
|
|
1981
2473
|
const toldLog = Number(await this.host.getExtensionData(NAME, TOLD_LOG_KEY)) || 0;
|
|
1982
2474
|
for (const entry of ShareModeration.news(state.log, toldLog)) {
|
|
1983
2475
|
await this.host.callPackageHost("@celljs/ta-notify", "notify", [
|
|
@@ -2484,6 +2976,40 @@ var TaAgentSummary;
|
|
|
2484
2976
|
}
|
|
2485
2977
|
TaAgentSummary2.strip = strip;
|
|
2486
2978
|
})(TaAgentSummary || (TaAgentSummary = {}));
|
|
2979
|
+
var TaPictureNote;
|
|
2980
|
+
(function(TaPictureNote2) {
|
|
2981
|
+
TaPictureNote2.OPEN = "<pictures>";
|
|
2982
|
+
TaPictureNote2.CLOSE = "</pictures>";
|
|
2983
|
+
const BLOCK = /[ \t]*<pictures>([\s\S]*?)(?:<\/pictures>|$)|<p(?:i(?:c(?:t(?:u(?:r(?:es?)?)?)?)?)?)?$/gi;
|
|
2984
|
+
const ROW = /(?:^|\s)[-*]?\s*p(\d+)\s*[::]\s*/gi;
|
|
2985
|
+
function take(text) {
|
|
2986
|
+
const told = new Map;
|
|
2987
|
+
if (!/<p/i.test(text)) {
|
|
2988
|
+
return { said: text, told };
|
|
2989
|
+
}
|
|
2990
|
+
const said = text.replace(BLOCK, (_all, body) => {
|
|
2991
|
+
const rows = [...(body !== null && body !== undefined ? body : "").matchAll(ROW)];
|
|
2992
|
+
rows.forEach((row, index) => {
|
|
2993
|
+
var _a;
|
|
2994
|
+
var _b, _c;
|
|
2995
|
+
const end = (_b = (_a = rows[index + 1]) === null || _a === undefined ? undefined : _a.index) !== null && _b !== undefined ? _b : body === null || body === undefined ? undefined : body.length;
|
|
2996
|
+
const what = body === null || body === undefined ? undefined : body.slice(((_c = row.index) !== null && _c !== undefined ? _c : 0) + row[0].length, end).trim();
|
|
2997
|
+
if (what) {
|
|
2998
|
+
told.set(Number(row[1]), what);
|
|
2999
|
+
}
|
|
3000
|
+
});
|
|
3001
|
+
return "";
|
|
3002
|
+
});
|
|
3003
|
+
return { said: said === text ? text : said.replace(/\n{3,}/g, `
|
|
3004
|
+
|
|
3005
|
+
`).trim(), told };
|
|
3006
|
+
}
|
|
3007
|
+
TaPictureNote2.take = take;
|
|
3008
|
+
function strip(text) {
|
|
3009
|
+
return take(text).said;
|
|
3010
|
+
}
|
|
3011
|
+
TaPictureNote2.strip = strip;
|
|
3012
|
+
})(TaPictureNote || (TaPictureNote = {}));
|
|
2487
3013
|
var TaSkillUse;
|
|
2488
3014
|
(function(TaSkillUse2) {
|
|
2489
3015
|
const BLOCK = /^<skill name="([^"]+)" location="([^"]+)">\n([\s\S]*?)\n<\/skill>(?:\n\n([\s\S]+))?$/;
|
|
@@ -2601,7 +3127,8 @@ var TaSaid;
|
|
|
2601
3127
|
["image note", /\[Image: original \d+x\d+|\[Image converted from /],
|
|
2602
3128
|
["skill", /<skill name="|<\/skill>/],
|
|
2603
3129
|
["task note", /<\/?task_(?:update|adopted|renamed)\b/],
|
|
2604
|
-
["summary", /<\/?(?:conversation_history_summary|summary)>/]
|
|
3130
|
+
["summary", /<\/?(?:conversation_history_summary|summary)>/],
|
|
3131
|
+
["pictures described", /<\/?pictures>/]
|
|
2605
3132
|
];
|
|
2606
3133
|
function text(content, joiner = `
|
|
2607
3134
|
`) {
|
|
@@ -2612,7 +3139,7 @@ var TaSaid;
|
|
|
2612
3139
|
}
|
|
2613
3140
|
TaSaid2.text = text;
|
|
2614
3141
|
function words(role, text2, options = {}) {
|
|
2615
|
-
const said = role === "user" ? userWords(text2) : TaAgentSummary.strip(text2);
|
|
3142
|
+
const said = role === "user" ? userWords(text2) : TaPictureNote.strip(TaAgentSummary.strip(text2));
|
|
2616
3143
|
return withoutFences(said, (language) => options.cards === false && CARD.test(language), true).trim();
|
|
2617
3144
|
}
|
|
2618
3145
|
TaSaid2.words = words;
|
|
@@ -2731,6 +3258,17 @@ Switched to voice.`, said: "Switched to voice." },
|
|
|
2731
3258
|
{ mark: "a card alone", role: "assistant", text: '```ta-glance\n{"status":"done","blocks":[]}\n```' },
|
|
2732
3259
|
{ mark: "a proposal", role: "assistant", text: 'Committed.\n\n```ta-propose\n{"kind":"git.push","title":"Push"}\n```', said: "Committed." },
|
|
2733
3260
|
{ mark: "what a call says aloud", role: "assistant", text: "All fixed.\n\n```ta-say\nIt is fixed.\n```", said: "All fixed." },
|
|
3261
|
+
{
|
|
3262
|
+
mark: "pictures described after the answer",
|
|
3263
|
+
role: "assistant",
|
|
3264
|
+
text: `The left one.
|
|
3265
|
+
|
|
3266
|
+
<pictures> p1: two cats on a sofa. p2: a chart of sales, "Q4". </pictures>`,
|
|
3267
|
+
said: "The left one."
|
|
3268
|
+
},
|
|
3269
|
+
{ mark: "pictures described as it streams", role: "assistant", text: `The left one.
|
|
3270
|
+
<pictures>
|
|
3271
|
+
p1: two ca`, said: "The left one." },
|
|
2734
3272
|
{ mark: "a tag not known yet", role: "assistant", text: `<system-reminder>
|
|
2735
3273
|
</system-reminder>
|
|
2736
3274
|
Ready.`, said: "Ready." }
|
|
@@ -3084,6 +3622,9 @@ class ShareService {
|
|
|
3084
3622
|
moderate(action) {
|
|
3085
3623
|
return this.moderation.act(action);
|
|
3086
3624
|
}
|
|
3625
|
+
placeShots(room) {
|
|
3626
|
+
return this.moderation.shots(String(room));
|
|
3627
|
+
}
|
|
3087
3628
|
async standing() {
|
|
3088
3629
|
return await this.host.shares.standing?.().catch(() => {
|
|
3089
3630
|
return;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@celljs/ta-share",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.30.0",
|
|
4
4
|
"description": "A pi package for Ta: share a conversation, a page or a file by a link, public, with a password or for yourself, end to end through the relay; open and import what others share",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pi-package"
|
|
@@ -27,9 +27,9 @@
|
|
|
27
27
|
"watch": "tsc -b -w --preserveWatchOutput"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@celljs/ta-protocol": "4.
|
|
31
|
-
"@celljs/ta-relay": "4.
|
|
32
|
-
"@celljs/ta-web": "4.
|
|
30
|
+
"@celljs/ta-protocol": "4.30.0",
|
|
31
|
+
"@celljs/ta-relay": "4.30.0",
|
|
32
|
+
"@celljs/ta-web": "4.30.0",
|
|
33
33
|
"@types/react": "^19.3.0"
|
|
34
34
|
},
|
|
35
35
|
"publishConfig": {
|
package/web/index.js
CHANGED
|
@@ -178,6 +178,20 @@ var EN = {
|
|
|
178
178
|
featureRooms: "Group chats",
|
|
179
179
|
featureMoments: "Friends and Moments",
|
|
180
180
|
featureNearby: "Nearby",
|
|
181
|
+
featurePlaces: "Public worlds",
|
|
182
|
+
placeReport: "{title} · {reason}",
|
|
183
|
+
placeLine: "Reported {count} times by {people} · {time} · world of {name}",
|
|
184
|
+
placeUnlisted: "off the map",
|
|
185
|
+
placeShots: "Pictures ({n})",
|
|
186
|
+
placeNoShots: "No pictures",
|
|
187
|
+
blockPlace: "Take off the map",
|
|
188
|
+
blockPlaceTitle: "Take this world off the map?",
|
|
189
|
+
blockPlaceHint: "It leaves the world map at once and is not listed again until you put it back. Those in it stay.",
|
|
190
|
+
blockOwner: "Bar its owner",
|
|
191
|
+
blockOwnerTitle: "Bar {name} from public worlds?",
|
|
192
|
+
blockOwnerHint: "All their public worlds leave the map, and they make none public until you lift it.",
|
|
193
|
+
blockedPlace: "World {name} off the map",
|
|
194
|
+
blockedOwner: "{name} barred from public worlds",
|
|
181
195
|
needsFor: "Needs an account",
|
|
182
196
|
needsForHint: "Without it, those not signed in can still use it, and a ban does not reach them there.",
|
|
183
197
|
logTitle: "Record",
|
|
@@ -370,6 +384,20 @@ var ZH = {
|
|
|
370
384
|
featureRooms: "群聊",
|
|
371
385
|
featureMoments: "加好友与动态",
|
|
372
386
|
featureNearby: "附近",
|
|
387
|
+
featurePlaces: "公开世界",
|
|
388
|
+
placeReport: "{title} · {reason}",
|
|
389
|
+
placeLine: "{people} 人举报 {count} 次 · {time} · {name} 的世界",
|
|
390
|
+
placeUnlisted: "已不在地图上",
|
|
391
|
+
placeShots: "看截图({n})",
|
|
392
|
+
placeNoShots: "没有截图",
|
|
393
|
+
blockPlace: "下架这个世界",
|
|
394
|
+
blockPlaceTitle: "下架这个世界?",
|
|
395
|
+
blockPlaceHint: "立即从世界地图下架,你恢复之前不能再公开。已经在里面的人不受影响。",
|
|
396
|
+
blockOwner: "封禁主人的公开权限",
|
|
397
|
+
blockOwnerTitle: "封禁 {name} 的公开权限?",
|
|
398
|
+
blockOwnerHint: "他的公开世界全部下架,你解封之前不能再公开世界。",
|
|
399
|
+
blockedPlace: "世界「{name}」已下架",
|
|
400
|
+
blockedOwner: "{name} 不能公开世界",
|
|
373
401
|
needsFor: "须登录账号",
|
|
374
402
|
needsForHint: "不要求登录时,没登录的人仍能使用,封号也拦不住他们。",
|
|
375
403
|
logTitle: "记录",
|
|
@@ -562,6 +590,20 @@ var ZH_TW = {
|
|
|
562
590
|
featureRooms: "群聊",
|
|
563
591
|
featureMoments: "加好友與動態",
|
|
564
592
|
featureNearby: "附近",
|
|
593
|
+
featurePlaces: "公開世界",
|
|
594
|
+
placeReport: "{title} · {reason}",
|
|
595
|
+
placeLine: "{people} 人檢舉 {count} 次 · {time} · {name} 的世界",
|
|
596
|
+
placeUnlisted: "已不在地圖上",
|
|
597
|
+
placeShots: "看截圖({n})",
|
|
598
|
+
placeNoShots: "沒有截圖",
|
|
599
|
+
blockPlace: "下架這個世界",
|
|
600
|
+
blockPlaceTitle: "下架這個世界?",
|
|
601
|
+
blockPlaceHint: "立即從世界地圖下架,你恢復之前不能再公開。已經在裡面的人不受影響。",
|
|
602
|
+
blockOwner: "停權主人的公開權限",
|
|
603
|
+
blockOwnerTitle: "停權 {name} 的公開權限?",
|
|
604
|
+
blockOwnerHint: "他的公開世界全部下架,你解除之前不能再公開世界。",
|
|
605
|
+
blockedPlace: "世界「{name}」已下架",
|
|
606
|
+
blockedOwner: "{name} 不能公開世界",
|
|
565
607
|
needsFor: "須登入帳號",
|
|
566
608
|
needsForHint: "不要求登入時,沒登入的人仍能使用,封號也攔不住他們。",
|
|
567
609
|
logTitle: "記錄",
|
|
@@ -754,6 +796,20 @@ var JA = {
|
|
|
754
796
|
featureRooms: "グループチャット",
|
|
755
797
|
featureMoments: "友だちとモーメンツ",
|
|
756
798
|
featureNearby: "近く",
|
|
799
|
+
featurePlaces: "公開ワールド",
|
|
800
|
+
placeReport: "{title} · {reason}",
|
|
801
|
+
placeLine: "{people} 人が {count} 回通報 · {time} · {name} のワールド",
|
|
802
|
+
placeUnlisted: "地図から外れています",
|
|
803
|
+
placeShots: "スクリーンショット({n})",
|
|
804
|
+
placeNoShots: "スクリーンショットなし",
|
|
805
|
+
blockPlace: "地図から外す",
|
|
806
|
+
blockPlaceTitle: "このワールドを地図から外しますか?",
|
|
807
|
+
blockPlaceHint: "すぐに世界地図から外れ、戻すまで公開できません。中にいる人はそのままです。",
|
|
808
|
+
blockOwner: "持ち主の公開を止める",
|
|
809
|
+
blockOwnerTitle: "{name} の公開を止めますか?",
|
|
810
|
+
blockOwnerHint: "公開ワールドはすべて地図から外れ、解除するまで公開できません。",
|
|
811
|
+
blockedPlace: "ワールド「{name}」は地図から外れています",
|
|
812
|
+
blockedOwner: "{name} は公開できません",
|
|
757
813
|
needsFor: "アカウント必須",
|
|
758
814
|
needsForHint: "必須にしないと、サインインしていない人は使い続けられ、停止も届きません。",
|
|
759
815
|
logTitle: "記録",
|
|
@@ -857,6 +913,7 @@ var Host = {
|
|
|
857
913
|
operatorState: () => pi.callHost("operatorState"),
|
|
858
914
|
setOperatorToken: (token) => pi.callHost("setOperatorToken", token),
|
|
859
915
|
moderate: (action) => pi.callHost("moderate", action),
|
|
916
|
+
placeShots: (room) => pi.callHost("placeShots", room),
|
|
860
917
|
standing: () => pi.callHost("standing"),
|
|
861
918
|
appeal: (text) => pi.callHost("appeal", text),
|
|
862
919
|
open: (link, password) => pi.callHost("open", link, password),
|
|
@@ -910,7 +967,7 @@ function shareLine(share) {
|
|
|
910
967
|
}
|
|
911
968
|
|
|
912
969
|
// ../ta-relay/esm/common/relay-moderation-policy.js
|
|
913
|
-
var RELAY_OUTWARD_FEATURES = ["share", "rooms", "moments", "nearby"];
|
|
970
|
+
var RELAY_OUTWARD_FEATURES = ["share", "rooms", "moments", "nearby", "places"];
|
|
914
971
|
var RELAY_MODERATION_POLICY = {
|
|
915
972
|
auto: false,
|
|
916
973
|
people: 3,
|
|
@@ -918,7 +975,7 @@ var RELAY_MODERATION_POLICY = {
|
|
|
918
975
|
hostAfter: 3,
|
|
919
976
|
limitDays: 7,
|
|
920
977
|
needsAccount: [],
|
|
921
|
-
banCovers: ["share", "rooms", "moments", "nearby"],
|
|
978
|
+
banCovers: ["share", "rooms", "moments", "nearby", "places"],
|
|
922
979
|
newDays: 7,
|
|
923
980
|
newDaily: 5
|
|
924
981
|
};
|
|
@@ -961,7 +1018,13 @@ var RelayModerationPolicyUtil;
|
|
|
961
1018
|
})(RelayModerationPolicyUtil || (RelayModerationPolicyUtil = {}));
|
|
962
1019
|
|
|
963
1020
|
// web-src/moderation-rules.tsx
|
|
964
|
-
var FEATURES = {
|
|
1021
|
+
var FEATURES = {
|
|
1022
|
+
share: "featureShare",
|
|
1023
|
+
rooms: "featureRooms",
|
|
1024
|
+
moments: "featureMoments",
|
|
1025
|
+
nearby: "featureNearby",
|
|
1026
|
+
places: "featurePlaces"
|
|
1027
|
+
};
|
|
965
1028
|
function Stepper({ label, value, min, max, onChange }) {
|
|
966
1029
|
return /* @__PURE__ */ React.createElement("div", {
|
|
967
1030
|
className: "tsh-rule"
|
|
@@ -1074,7 +1137,7 @@ function ModerationRules({ policy, change }) {
|
|
|
1074
1137
|
})));
|
|
1075
1138
|
}
|
|
1076
1139
|
|
|
1077
|
-
// web-src/reports
|
|
1140
|
+
// web-src/place-reports.tsx
|
|
1078
1141
|
var REASONS = {
|
|
1079
1142
|
phishing: "reasonPhishing",
|
|
1080
1143
|
malware: "reasonMalware",
|
|
@@ -1083,6 +1146,92 @@ var REASONS = {
|
|
|
1083
1146
|
harassment: "reasonHarassment",
|
|
1084
1147
|
other: "reasonOther"
|
|
1085
1148
|
};
|
|
1149
|
+
function waitingPlaces(state) {
|
|
1150
|
+
const blocks = state?.places?.blocks ?? { places: [], owners: [] };
|
|
1151
|
+
return (state?.places?.reports ?? []).filter((report) => !blocks.places.includes(report.room) && !blocks.owners.includes(report.owner));
|
|
1152
|
+
}
|
|
1153
|
+
function PlaceReportRow({ report, act }) {
|
|
1154
|
+
const Mark = icon("Globe");
|
|
1155
|
+
const [shots, setShots] = React.useState();
|
|
1156
|
+
const time = new Date(report.last).toLocaleString(pi.ui.language, { month: "short", day: "numeric", hour: "2-digit", minute: "2-digit" });
|
|
1157
|
+
const reason = t(REASONS[report.reason] ?? "reasonOther");
|
|
1158
|
+
const show = () => void Host.placeShots(report.room).then(setShots, (error) => pi.ui.notify(error instanceof Error ? error.message : String(error), "error"));
|
|
1159
|
+
return /* @__PURE__ */ React.createElement("li", {
|
|
1160
|
+
className: "tsh-report"
|
|
1161
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
1162
|
+
className: "tsh-report-head"
|
|
1163
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
1164
|
+
className: "tsh-tile tsh-tile-report",
|
|
1165
|
+
"aria-hidden": "true"
|
|
1166
|
+
}, /* @__PURE__ */ React.createElement(Mark, {
|
|
1167
|
+
size: 18
|
|
1168
|
+
})), /* @__PURE__ */ React.createElement("span", {
|
|
1169
|
+
className: "tsh-row-text"
|
|
1170
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
1171
|
+
className: "tsh-row-title"
|
|
1172
|
+
}, t("placeReport", { title: report.title, reason })), /* @__PURE__ */ React.createElement("span", {
|
|
1173
|
+
className: "tsh-row-line"
|
|
1174
|
+
}, t("placeLine", { count: report.count, people: report.people, time, name: report.by || report.owner.slice(0, 6) }), report.listed ? "" : ` · ${t("placeUnlisted")}`))), report.note && /* @__PURE__ */ React.createElement("p", {
|
|
1175
|
+
className: "tsh-report-note"
|
|
1176
|
+
}, report.note), shots && /* @__PURE__ */ React.createElement("div", {
|
|
1177
|
+
className: "tsh-shots"
|
|
1178
|
+
}, shots.length === 0 ? /* @__PURE__ */ React.createElement("span", {
|
|
1179
|
+
className: "tsh-row-line"
|
|
1180
|
+
}, t("placeNoShots")) : shots.map((shot) => /* @__PURE__ */ React.createElement("img", {
|
|
1181
|
+
key: shot.slice(-24),
|
|
1182
|
+
src: shot,
|
|
1183
|
+
alt: report.title
|
|
1184
|
+
}))), /* @__PURE__ */ React.createElement("div", {
|
|
1185
|
+
className: "tsh-report-actions"
|
|
1186
|
+
}, report.shots > 0 && !shots && /* @__PURE__ */ React.createElement("button", {
|
|
1187
|
+
type: "button",
|
|
1188
|
+
className: "ta-button",
|
|
1189
|
+
onClick: show
|
|
1190
|
+
}, t("placeShots", { n: report.shots })), /* @__PURE__ */ React.createElement("span", {
|
|
1191
|
+
className: "tsh-grow"
|
|
1192
|
+
}), /* @__PURE__ */ React.createElement("button", {
|
|
1193
|
+
type: "button",
|
|
1194
|
+
className: "ta-button",
|
|
1195
|
+
onClick: () => act(() => Host.moderate({ action: "dismiss", place: report.room }))
|
|
1196
|
+
}, t("dismiss")), /* @__PURE__ */ React.createElement("button", {
|
|
1197
|
+
type: "button",
|
|
1198
|
+
className: "ta-button tsh-danger",
|
|
1199
|
+
onClick: () => act(() => Host.moderate({ action: "block", place: report.room }), [t("blockPlaceTitle"), t("blockPlaceHint")])
|
|
1200
|
+
}, t("blockPlace")), /* @__PURE__ */ React.createElement("button", {
|
|
1201
|
+
type: "button",
|
|
1202
|
+
className: "ta-button tsh-danger",
|
|
1203
|
+
onClick: () => act(() => Host.moderate({ action: "block", owner: report.owner }), [t("blockOwnerTitle", { name: report.by }), t("blockOwnerHint")])
|
|
1204
|
+
}, t("blockOwner"))));
|
|
1205
|
+
}
|
|
1206
|
+
function placeItems(state) {
|
|
1207
|
+
const blocks = state.places?.blocks ?? { places: [], owners: [] };
|
|
1208
|
+
const named = new Map((state.places?.reports ?? []).flatMap((report) => [[report.room, report.title], [report.owner, report.by]]));
|
|
1209
|
+
const auto = new Set((state.log ?? []).filter((entry) => entry.by === "rule" && entry.action === "block").map((entry) => entry.target));
|
|
1210
|
+
return [
|
|
1211
|
+
...blocks.places.map((id) => ({
|
|
1212
|
+
key: `place:${id}`,
|
|
1213
|
+
line: t("blockedPlace", { name: named.get(id) || id.slice(0, 6) }),
|
|
1214
|
+
auto: auto.has(`place:${id}`),
|
|
1215
|
+
lift: () => Host.moderate({ action: "unblock", place: id })
|
|
1216
|
+
})),
|
|
1217
|
+
...blocks.owners.map((id) => ({
|
|
1218
|
+
key: `owner:${id}`,
|
|
1219
|
+
line: t("blockedOwner", { name: named.get(id) || id.slice(0, 6) }),
|
|
1220
|
+
auto: false,
|
|
1221
|
+
lift: () => Host.moderate({ action: "unblock", owner: id })
|
|
1222
|
+
}))
|
|
1223
|
+
];
|
|
1224
|
+
}
|
|
1225
|
+
|
|
1226
|
+
// web-src/reports-page.tsx
|
|
1227
|
+
var REASONS2 = {
|
|
1228
|
+
phishing: "reasonPhishing",
|
|
1229
|
+
malware: "reasonMalware",
|
|
1230
|
+
sexual: "reasonSexual",
|
|
1231
|
+
illegal: "reasonIllegal",
|
|
1232
|
+
harassment: "reasonHarassment",
|
|
1233
|
+
other: "reasonOther"
|
|
1234
|
+
};
|
|
1086
1235
|
function useOperator() {
|
|
1087
1236
|
const [state, setState] = React.useState();
|
|
1088
1237
|
React.useEffect(() => {
|
|
@@ -1124,7 +1273,7 @@ function ReportRow({ report, state, act }) {
|
|
|
1124
1273
|
className: "tsh-row-text"
|
|
1125
1274
|
}, /* @__PURE__ */ React.createElement("span", {
|
|
1126
1275
|
className: "tsh-row-title"
|
|
1127
|
-
}, t(
|
|
1276
|
+
}, t(REASONS2[report.reason] ?? "reasonOther")), /* @__PURE__ */ React.createElement("span", {
|
|
1128
1277
|
className: "tsh-row-line"
|
|
1129
1278
|
}, t("reportLine", { count: report.count, time }), " · ", owner ? t("fromAccount", { name }) : t("fromComputer"), report.doubtful ? ` · ${t("doubtful", { n: report.doubtful })}` : ""))), report.note && /* @__PURE__ */ React.createElement("p", {
|
|
1130
1279
|
className: "tsh-report-note"
|
|
@@ -1149,11 +1298,11 @@ function ReportRow({ report, state, act }) {
|
|
|
1149
1298
|
}, t("blockShare")), owner ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("button", {
|
|
1150
1299
|
type: "button",
|
|
1151
1300
|
className: "ta-button tsh-danger",
|
|
1152
|
-
onClick: () => act(() => Host.moderate({ action: "limit", account: owner.account, days, reason: t(
|
|
1301
|
+
onClick: () => act(() => Host.moderate({ action: "limit", account: owner.account, days, reason: t(REASONS2[report.reason] ?? "reasonOther") }), [t("limitTitle", { name, days }), t("limitHint")])
|
|
1153
1302
|
}, t("limitAccount", { days })), /* @__PURE__ */ React.createElement("button", {
|
|
1154
1303
|
type: "button",
|
|
1155
1304
|
className: "ta-button tsh-danger",
|
|
1156
|
-
onClick: () => act(() => Host.moderate({ action: "ban", account: owner.account, reason: t(
|
|
1305
|
+
onClick: () => act(() => Host.moderate({ action: "ban", account: owner.account, reason: t(REASONS2[report.reason] ?? "reasonOther") }), [t("banTitle", { name }), t("banHint")])
|
|
1157
1306
|
}, t("banAccount"))) : /* @__PURE__ */ React.createElement("button", {
|
|
1158
1307
|
type: "button",
|
|
1159
1308
|
className: "ta-button tsh-danger",
|
|
@@ -1202,7 +1351,8 @@ function InForce({ state, act }) {
|
|
|
1202
1351
|
line: t("blockedShare", { id: short(id) }),
|
|
1203
1352
|
auto: !!blocks.auto?.[`share:${id}`],
|
|
1204
1353
|
lift: () => Host.moderate({ action: "unblock", share: id })
|
|
1205
|
-
}))
|
|
1354
|
+
})),
|
|
1355
|
+
...placeItems(state)
|
|
1206
1356
|
];
|
|
1207
1357
|
if (items.length === 0) {
|
|
1208
1358
|
return null;
|
|
@@ -1286,13 +1436,14 @@ function ReportsPage() {
|
|
|
1286
1436
|
}, t("operatorSet"))));
|
|
1287
1437
|
}
|
|
1288
1438
|
const list = waiting(state);
|
|
1439
|
+
const places = waitingPlaces(state);
|
|
1289
1440
|
const appeals = state.appeals ?? [];
|
|
1290
1441
|
return /* @__PURE__ */ React.createElement("div", {
|
|
1291
1442
|
className: `tsh-page${busy ? " ta-pending" : ""}`,
|
|
1292
1443
|
"aria-busy": busy || undefined
|
|
1293
1444
|
}, state.error && /* @__PURE__ */ React.createElement("p", {
|
|
1294
1445
|
className: "tsh-error"
|
|
1295
|
-
}, t("operatorError", { error: state.error })), list.length + appeals.length === 0 && !state.error ? /* @__PURE__ */ React.createElement(pi.ui.Empty, {
|
|
1446
|
+
}, t("operatorError", { error: state.error })), list.length + places.length + appeals.length === 0 && !state.error ? /* @__PURE__ */ React.createElement(pi.ui.Empty, {
|
|
1296
1447
|
title: t("reportsNone")
|
|
1297
1448
|
}) : /* @__PURE__ */ React.createElement("ul", {
|
|
1298
1449
|
className: "tsh-rows"
|
|
@@ -1305,6 +1456,10 @@ function ReportsPage() {
|
|
|
1305
1456
|
report,
|
|
1306
1457
|
state,
|
|
1307
1458
|
act
|
|
1459
|
+
})), places.map((report) => /* @__PURE__ */ React.createElement(PlaceReportRow, {
|
|
1460
|
+
key: report.room,
|
|
1461
|
+
report,
|
|
1462
|
+
act
|
|
1308
1463
|
}))), /* @__PURE__ */ React.createElement(InForce, {
|
|
1309
1464
|
state,
|
|
1310
1465
|
act
|
|
@@ -1327,7 +1482,7 @@ function ReportsRow() {
|
|
|
1327
1482
|
return null;
|
|
1328
1483
|
}
|
|
1329
1484
|
const Mark = icon("Shield");
|
|
1330
|
-
const count = waiting(state).length + (state.appeals?.length ?? 0);
|
|
1485
|
+
const count = waiting(state).length + waitingPlaces(state).length + (state.appeals?.length ?? 0);
|
|
1331
1486
|
const More = icon("ChevronRight");
|
|
1332
1487
|
return /* @__PURE__ */ React.createElement("ul", {
|
|
1333
1488
|
className: "tsh-rows tsh-group"
|
|
@@ -1535,6 +1690,40 @@ var TaAgentSummary;
|
|
|
1535
1690
|
}
|
|
1536
1691
|
TaAgentSummary2.strip = strip;
|
|
1537
1692
|
})(TaAgentSummary || (TaAgentSummary = {}));
|
|
1693
|
+
var TaPictureNote;
|
|
1694
|
+
(function(TaPictureNote2) {
|
|
1695
|
+
TaPictureNote2.OPEN = "<pictures>";
|
|
1696
|
+
TaPictureNote2.CLOSE = "</pictures>";
|
|
1697
|
+
const BLOCK = /[ \t]*<pictures>([\s\S]*?)(?:<\/pictures>|$)|<p(?:i(?:c(?:t(?:u(?:r(?:es?)?)?)?)?)?)?$/gi;
|
|
1698
|
+
const ROW = /(?:^|\s)[-*]?\s*p(\d+)\s*[::]\s*/gi;
|
|
1699
|
+
function take(text) {
|
|
1700
|
+
const told = new Map;
|
|
1701
|
+
if (!/<p/i.test(text)) {
|
|
1702
|
+
return { said: text, told };
|
|
1703
|
+
}
|
|
1704
|
+
const said = text.replace(BLOCK, (_all, body) => {
|
|
1705
|
+
const rows = [...(body !== null && body !== undefined ? body : "").matchAll(ROW)];
|
|
1706
|
+
rows.forEach((row, index) => {
|
|
1707
|
+
var _a;
|
|
1708
|
+
var _b, _c;
|
|
1709
|
+
const end = (_b = (_a = rows[index + 1]) === null || _a === undefined ? undefined : _a.index) !== null && _b !== undefined ? _b : body === null || body === undefined ? undefined : body.length;
|
|
1710
|
+
const what = body === null || body === undefined ? undefined : body.slice(((_c = row.index) !== null && _c !== undefined ? _c : 0) + row[0].length, end).trim();
|
|
1711
|
+
if (what) {
|
|
1712
|
+
told.set(Number(row[1]), what);
|
|
1713
|
+
}
|
|
1714
|
+
});
|
|
1715
|
+
return "";
|
|
1716
|
+
});
|
|
1717
|
+
return { said: said === text ? text : said.replace(/\n{3,}/g, `
|
|
1718
|
+
|
|
1719
|
+
`).trim(), told };
|
|
1720
|
+
}
|
|
1721
|
+
TaPictureNote2.take = take;
|
|
1722
|
+
function strip(text) {
|
|
1723
|
+
return take(text).said;
|
|
1724
|
+
}
|
|
1725
|
+
TaPictureNote2.strip = strip;
|
|
1726
|
+
})(TaPictureNote || (TaPictureNote = {}));
|
|
1538
1727
|
var TaSkillUse;
|
|
1539
1728
|
(function(TaSkillUse2) {
|
|
1540
1729
|
const BLOCK = /^<skill name="([^"]+)" location="([^"]+)">\n([\s\S]*?)\n<\/skill>(?:\n\n([\s\S]+))?$/;
|
|
@@ -1652,7 +1841,8 @@ var TaSaid;
|
|
|
1652
1841
|
["image note", /\[Image: original \d+x\d+|\[Image converted from /],
|
|
1653
1842
|
["skill", /<skill name="|<\/skill>/],
|
|
1654
1843
|
["task note", /<\/?task_(?:update|adopted|renamed)\b/],
|
|
1655
|
-
["summary", /<\/?(?:conversation_history_summary|summary)>/]
|
|
1844
|
+
["summary", /<\/?(?:conversation_history_summary|summary)>/],
|
|
1845
|
+
["pictures described", /<\/?pictures>/]
|
|
1656
1846
|
];
|
|
1657
1847
|
function text(content, joiner = `
|
|
1658
1848
|
`) {
|
|
@@ -1663,7 +1853,7 @@ var TaSaid;
|
|
|
1663
1853
|
}
|
|
1664
1854
|
TaSaid2.text = text;
|
|
1665
1855
|
function words(role, text2, options = {}) {
|
|
1666
|
-
const said = role === "user" ? userWords(text2) : TaAgentSummary.strip(text2);
|
|
1856
|
+
const said = role === "user" ? userWords(text2) : TaPictureNote.strip(TaAgentSummary.strip(text2));
|
|
1667
1857
|
return withoutFences(said, (language) => options.cards === false && CARD.test(language), true).trim();
|
|
1668
1858
|
}
|
|
1669
1859
|
TaSaid2.words = words;
|
|
@@ -1782,6 +1972,17 @@ Switched to voice.`, said: "Switched to voice." },
|
|
|
1782
1972
|
{ mark: "a card alone", role: "assistant", text: '```ta-glance\n{"status":"done","blocks":[]}\n```' },
|
|
1783
1973
|
{ mark: "a proposal", role: "assistant", text: 'Committed.\n\n```ta-propose\n{"kind":"git.push","title":"Push"}\n```', said: "Committed." },
|
|
1784
1974
|
{ mark: "what a call says aloud", role: "assistant", text: "All fixed.\n\n```ta-say\nIt is fixed.\n```", said: "All fixed." },
|
|
1975
|
+
{
|
|
1976
|
+
mark: "pictures described after the answer",
|
|
1977
|
+
role: "assistant",
|
|
1978
|
+
text: `The left one.
|
|
1979
|
+
|
|
1980
|
+
<pictures> p1: two cats on a sofa. p2: a chart of sales, "Q4". </pictures>`,
|
|
1981
|
+
said: "The left one."
|
|
1982
|
+
},
|
|
1983
|
+
{ mark: "pictures described as it streams", role: "assistant", text: `The left one.
|
|
1984
|
+
<pictures>
|
|
1985
|
+
p1: two ca`, said: "The left one." },
|
|
1785
1986
|
{ mark: "a tag not known yet", role: "assistant", text: `<system-reminder>
|
|
1786
1987
|
</system-reminder>
|
|
1787
1988
|
Ready.`, said: "Ready." }
|
|
@@ -2833,6 +3034,8 @@ var STYLE = `
|
|
|
2833
3034
|
.tsh-report-head { display: flex; align-items: center; gap: 12px; min-width: 0; }
|
|
2834
3035
|
.tsh-report-note { margin: 0 0 0 50px; font-size: calc(13px * var(--ta-font-scale)); line-height: 1.5; color: var(--ta-secondary); white-space: pre-wrap; overflow-wrap: anywhere; }
|
|
2835
3036
|
.tsh-report-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-left: 50px; }
|
|
3037
|
+
.tsh-shots { display: flex; flex-wrap: wrap; gap: 6px; margin-left: 50px; }
|
|
3038
|
+
.tsh-shots img { width: 160px; max-width: 100%; border-radius: 8px; border: 1px solid var(--ta-border-muted); }
|
|
2836
3039
|
.tsh-report-actions .tsh-danger, .tsh-blocked .tsh-danger { color: var(--ta-red); }
|
|
2837
3040
|
.ta-button.tsh-danger { color: var(--ta-red); }
|
|
2838
3041
|
.tsh-grow { flex: 1; }
|
|
@@ -2855,7 +3058,7 @@ var STYLE = `
|
|
|
2855
3058
|
.tsh-log summary { cursor: pointer; }
|
|
2856
3059
|
.tsh-log-line { list-style: none; padding: 3px 8px; white-space: normal; }
|
|
2857
3060
|
.tsh-standing { width: 100%; max-width: var(--ta-page-width); margin: 0 auto 12px; box-sizing: border-box; display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 10px; background: color-mix(in srgb, var(--ta-red) 10%, transparent); }
|
|
2858
|
-
:root[data-handheld] .tsh-report-note, :root[data-handheld] .tsh-report-actions { margin-left: 0; }
|
|
3061
|
+
:root[data-handheld] .tsh-report-note, :root[data-handheld] .tsh-report-actions, :root[data-handheld] .tsh-shots { margin-left: 0; }
|
|
2859
3062
|
/* The rows above the links (Reports, Services of this computer): each a group of its own, as the list rows are. */
|
|
2860
3063
|
.tsh-group { margin-bottom: 4px; }
|
|
2861
3064
|
.tsh-static, .tsh-static:hover { background: none; padding-right: 12px; }
|