@celljs/ta-channels 4.19.0 → 4.21.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 -2
- package/README.md +3 -2
- package/extension/index.mjs +131 -17
- package/host/index.mjs +573 -67
- package/package.json +7 -4
- package/web/index.js +2162 -1383
package/web/index.js
CHANGED
|
@@ -700,6 +700,12 @@ var FaceUtil;
|
|
|
700
700
|
})(FaceUtil || (FaceUtil = {}));
|
|
701
701
|
|
|
702
702
|
// web-src/channels-model.ts
|
|
703
|
+
var DEFAULT_LIMITS = { answer: 300000, channelDay: 5000000, allDay: 20000000 };
|
|
704
|
+
var LIMIT_CHOICES = {
|
|
705
|
+
answer: [1e5, 300000, 1e6],
|
|
706
|
+
channelDay: [2000000, 5000000, 20000000, 0],
|
|
707
|
+
allDay: [5000000, 20000000, 0]
|
|
708
|
+
};
|
|
703
709
|
var NAME = "@celljs/ta-channels";
|
|
704
710
|
var AGENT_MARK = "one of the agents of Ta";
|
|
705
711
|
var MEMBER_CHANGES = ["lead", "remove", "mute", "unmute"];
|
|
@@ -711,15 +717,22 @@ var Keys;
|
|
|
711
717
|
Keys.FOCUS = "focus";
|
|
712
718
|
Keys.ANSWERED = "answered";
|
|
713
719
|
Keys.CARDS = "cards";
|
|
720
|
+
Keys.LIMITS = "limits";
|
|
721
|
+
Keys.SPENT = "spent";
|
|
714
722
|
Keys.MESSAGES = "messages/";
|
|
715
723
|
Keys.messages = (channelId) => `${Keys.MESSAGES}${channelId}`;
|
|
716
724
|
})(Keys ||= {});
|
|
717
725
|
var USER = "user";
|
|
718
726
|
var TA = "ta";
|
|
719
727
|
var SYSTEM = "system";
|
|
720
|
-
var
|
|
721
|
-
|
|
722
|
-
|
|
728
|
+
var BUDGETS = {
|
|
729
|
+
short: { tokens: 200000, replies: 10 },
|
|
730
|
+
normal: { tokens: 800000, replies: 30 },
|
|
731
|
+
long: { tokens: 3000000, replies: 100 }
|
|
732
|
+
};
|
|
733
|
+
var DEFAULT_BUDGET = "normal";
|
|
734
|
+
var EXTEND_BY = 0.5;
|
|
735
|
+
var WATCH_MS = 30000;
|
|
723
736
|
var MAX_MESSAGES = 200;
|
|
724
737
|
var FACES = FACE_COUNT;
|
|
725
738
|
var MAX_MEMBERS = 12;
|
|
@@ -733,25 +746,58 @@ var NOTICE_HEADINGS = { zh: ["决定", "约定", "待办"], en: ["Decisions", "C
|
|
|
733
746
|
var ChannelsUtil;
|
|
734
747
|
((ChannelsUtil) => {
|
|
735
748
|
function newRound() {
|
|
736
|
-
return { total: 0,
|
|
749
|
+
return { total: 0, tokens: 0, stopped: false };
|
|
737
750
|
}
|
|
738
751
|
ChannelsUtil.newRound = newRound;
|
|
739
|
-
function
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
752
|
+
function budgetOf(channel) {
|
|
753
|
+
return channel?.budget && channel.budget in BUDGETS ? channel.budget : DEFAULT_BUDGET;
|
|
754
|
+
}
|
|
755
|
+
ChannelsUtil.budgetOf = budgetOf;
|
|
756
|
+
function limit(round, targets, budget, from, scale = 1) {
|
|
757
|
+
const fit = (extended2) => {
|
|
758
|
+
const { tokens, replies } = caps(budget, scale, extended2);
|
|
759
|
+
const open = (round.tokens ?? 0) < tokens;
|
|
760
|
+
const allowed2 = [];
|
|
761
|
+
let total2 = round.total;
|
|
762
|
+
for (const id of targets) {
|
|
763
|
+
if (open && total2 < replies) {
|
|
764
|
+
allowed2.push(id);
|
|
765
|
+
total2++;
|
|
766
|
+
}
|
|
748
767
|
}
|
|
768
|
+
return { allowed: allowed2, total: total2 };
|
|
769
|
+
};
|
|
770
|
+
let extended = !!round.extended;
|
|
771
|
+
let { allowed, total } = fit(extended);
|
|
772
|
+
if (allowed.length < targets.length && round.progress && !extended) {
|
|
773
|
+
extended = true;
|
|
774
|
+
({ allowed, total } = fit(true));
|
|
749
775
|
}
|
|
750
|
-
|
|
751
|
-
const
|
|
752
|
-
|
|
776
|
+
round = extended ? { ...round, extended } : round;
|
|
777
|
+
const cut = targets.filter((id) => !allowed.includes(id));
|
|
778
|
+
const pending = cut.length > 0 && from ? [...round.pending ?? [], { ...from, agentIds: cut }] : round.pending;
|
|
779
|
+
return { allowed, cut, round: { ...round, total, stopped: round.stopped || cut.length > 0, ...pending ? { pending } : {} } };
|
|
753
780
|
}
|
|
754
781
|
ChannelsUtil.limit = limit;
|
|
782
|
+
function used(round, budget, scale = 1) {
|
|
783
|
+
const limits = caps(budget, scale, !!round.extended);
|
|
784
|
+
return Math.max((round.tokens ?? 0) / limits.tokens, round.total / limits.replies);
|
|
785
|
+
}
|
|
786
|
+
ChannelsUtil.used = used;
|
|
787
|
+
function caps(budget, scale, extended) {
|
|
788
|
+
const { tokens, replies } = BUDGETS[budget];
|
|
789
|
+
const factor = scale * (extended ? 1 + EXTEND_BY : 1);
|
|
790
|
+
return { tokens: tokens * factor, replies: Math.max(1, Math.round(replies * factor)) };
|
|
791
|
+
}
|
|
792
|
+
ChannelsUtil.caps = caps;
|
|
793
|
+
function spent(before, after) {
|
|
794
|
+
if (!before || !after) {
|
|
795
|
+
return 0;
|
|
796
|
+
}
|
|
797
|
+
const delta = (key) => Math.max(0, (after[key] ?? 0) - (before[key] ?? 0));
|
|
798
|
+
return Math.round(delta("input") + delta("output") + delta("cacheWrite") + delta("cacheRead") / 10);
|
|
799
|
+
}
|
|
800
|
+
ChannelsUtil.spent = spent;
|
|
755
801
|
function emptyTeam() {
|
|
756
802
|
return { agents: [], channels: [] };
|
|
757
803
|
}
|
|
@@ -968,6 +1014,24 @@ var ChannelsUtil;
|
|
|
968
1014
|
delete channel.pinned;
|
|
969
1015
|
}
|
|
970
1016
|
}
|
|
1017
|
+
if (input.budget !== undefined) {
|
|
1018
|
+
if (typeof input.budget !== "string" || !(input.budget in BUDGETS)) {
|
|
1019
|
+
throw new Error(`The budget of a channel is one of ${Object.keys(BUDGETS).join(", ")}.`);
|
|
1020
|
+
}
|
|
1021
|
+
if (input.budget === DEFAULT_BUDGET) {
|
|
1022
|
+
delete channel.budget;
|
|
1023
|
+
} else {
|
|
1024
|
+
channel.budget = input.budget;
|
|
1025
|
+
}
|
|
1026
|
+
}
|
|
1027
|
+
if (input.dailyLimit === null) {
|
|
1028
|
+
delete channel.dailyLimit;
|
|
1029
|
+
} else if (input.dailyLimit !== undefined) {
|
|
1030
|
+
if (!LIMIT_CHOICES.channelDay.includes(input.dailyLimit)) {
|
|
1031
|
+
throw new Error(`The limit of a day of a channel is one of ${LIMIT_CHOICES.channelDay.join(", ")} tokens (0 for none), or null.`);
|
|
1032
|
+
}
|
|
1033
|
+
channel.dailyLimit = input.dailyLimit;
|
|
1034
|
+
}
|
|
971
1035
|
return { team: { ...team, channels: team.channels.map((other) => other.id === channel.id ? channel : other) }, channel, before };
|
|
972
1036
|
}
|
|
973
1037
|
ChannelsUtil.updateChannel = updateChannel;
|
|
@@ -1048,9 +1112,40 @@ var ChannelsUtil;
|
|
|
1048
1112
|
delete agent.cwd;
|
|
1049
1113
|
}
|
|
1050
1114
|
}
|
|
1115
|
+
if (input.model !== undefined) {
|
|
1116
|
+
const model = checkModel(input.model);
|
|
1117
|
+
if (model) {
|
|
1118
|
+
agent.model = model;
|
|
1119
|
+
} else {
|
|
1120
|
+
delete agent.model;
|
|
1121
|
+
}
|
|
1122
|
+
}
|
|
1051
1123
|
return { team: { ...team, agents: team.agents.map((other) => other.id === agent.id ? agent : other) }, agent, before };
|
|
1052
1124
|
}
|
|
1053
1125
|
ChannelsUtil.updateAgent = updateAgent;
|
|
1126
|
+
function checkModel(value) {
|
|
1127
|
+
if (value === "" || value === null) {
|
|
1128
|
+
return;
|
|
1129
|
+
}
|
|
1130
|
+
if (typeof value !== "string" || value.length > 200 || !/^[^/\s]+\/\S+$/.test(value)) {
|
|
1131
|
+
throw new Error("A model is named `<provider>/<model id>`.");
|
|
1132
|
+
}
|
|
1133
|
+
return value;
|
|
1134
|
+
}
|
|
1135
|
+
ChannelsUtil.checkModel = checkModel;
|
|
1136
|
+
function setChannelModel(team, input) {
|
|
1137
|
+
const channel = findChannel(team, typeof input.channel === "string" ? input.channel : "");
|
|
1138
|
+
if (!channel) {
|
|
1139
|
+
throw new Error(`No channel is ${String(input.channel)}.`);
|
|
1140
|
+
}
|
|
1141
|
+
let next = team;
|
|
1142
|
+
for (const id of channel.members) {
|
|
1143
|
+
next = updateAgent(next, { agent: id, model: input.model }).team;
|
|
1144
|
+
}
|
|
1145
|
+
const agents = next.agents.filter((agent) => channel.members.includes(agent.id));
|
|
1146
|
+
return { team: next, channel, agents };
|
|
1147
|
+
}
|
|
1148
|
+
ChannelsUtil.setChannelModel = setChannelModel;
|
|
1054
1149
|
function removeAgent(team, ref) {
|
|
1055
1150
|
const agent = findAgent(team, typeof ref === "string" ? ref : "");
|
|
1056
1151
|
if (!agent) {
|
|
@@ -1274,7 +1369,40 @@ var JA = {
|
|
|
1274
1369
|
answering: "{name} が回答中",
|
|
1275
1370
|
failed: "回答がありません",
|
|
1276
1371
|
mention: "@{name}",
|
|
1277
|
-
stopped: "
|
|
1372
|
+
stopped: "議論を一時停止しました。あなたの判断を待っています",
|
|
1373
|
+
stoppedStats: "返信 {replies} 件 · 約 {tokens} トークン",
|
|
1374
|
+
stoppedReplies: "返信 {replies} 件",
|
|
1375
|
+
keepGoing: "続ける",
|
|
1376
|
+
wrapUp: "{name} にまとめてもらう",
|
|
1377
|
+
wentOn: "続行済み",
|
|
1378
|
+
summedUp: "まとめ依頼済み",
|
|
1379
|
+
dailyChannel: "このグループの今日の上限に達しました。エージェントはあなたにだけ答えます",
|
|
1380
|
+
dailyAll: "すべてのグループの今日の上限に達し、一時停止しました",
|
|
1381
|
+
overBudget: "1回の回答の上限を超えたため停止",
|
|
1382
|
+
limitsTitle: "グループチャットの使用量",
|
|
1383
|
+
limitAnswer: "1回の回答",
|
|
1384
|
+
limitAnswerHint: "超えるとその場で回答を止めます",
|
|
1385
|
+
limitChannelDay: "1グループ1日あたり",
|
|
1386
|
+
limitChannelDayHint: "超えるとその日はあなたにだけ答えます",
|
|
1387
|
+
limitAllDay: "全グループ1日あたり",
|
|
1388
|
+
limitAllDayHint: "超えると全て一時停止して通知します",
|
|
1389
|
+
limitSpent: "今日の使用量",
|
|
1390
|
+
noLimit: "無制限",
|
|
1391
|
+
talkLength: "議論の長さ",
|
|
1392
|
+
budgetShortWord: "短い",
|
|
1393
|
+
budgetNormalWord: "標準",
|
|
1394
|
+
budgetLongWord: "長い",
|
|
1395
|
+
dailyLimit: "1日の上限",
|
|
1396
|
+
dailySpent: "今日 {spent}",
|
|
1397
|
+
dailySpentOf: "今日 {spent} / {limit}",
|
|
1398
|
+
limitDefault: "既定",
|
|
1399
|
+
idleRepeat: "同じ内容を繰り返していたため一時停止しました",
|
|
1400
|
+
idleAgree: "同意だけが続いたため一時停止しました",
|
|
1401
|
+
idlePingPong: "二人の往復に進展がないため一時停止しました",
|
|
1402
|
+
extendedOnce: "進展があったため一度延長済み",
|
|
1403
|
+
budgetShort: "短い議論 · 約 {n} 件",
|
|
1404
|
+
budgetNormal: "標準の議論 · 約 {n} 件",
|
|
1405
|
+
budgetLong: "長い議論 · 約 {n} 件",
|
|
1278
1406
|
search: "検索",
|
|
1279
1407
|
clear: "クリア",
|
|
1280
1408
|
new: "新規",
|
|
@@ -1285,8 +1413,9 @@ var JA = {
|
|
|
1285
1413
|
noAgentsYet: "まだエージェントがありません",
|
|
1286
1414
|
noAgentsYetHint: "+ で作成するか、Ta にチームを組ませて",
|
|
1287
1415
|
partners: "仲間",
|
|
1288
|
-
groupsSection: "
|
|
1416
|
+
groupsSection: "チャット",
|
|
1289
1417
|
agentsSection: "エージェント",
|
|
1418
|
+
agentTag: "エージェント",
|
|
1290
1419
|
noPartners: "まだ仲間がいません",
|
|
1291
1420
|
noPartnersHint: "+ でエージェントやグループチャットを作るか、友だちを追加して",
|
|
1292
1421
|
inviteFriends: "友だちを招待",
|
|
@@ -1310,7 +1439,17 @@ var JA = {
|
|
|
1310
1439
|
channelNamePlaceholder: "例:Project Falcon",
|
|
1311
1440
|
addAgents: "エージェントを追加",
|
|
1312
1441
|
searchAgents: "エージェントを検索、1 ~ {max} 件を選択",
|
|
1313
|
-
showMembers: "
|
|
1442
|
+
showMembers: "グループチャット情報",
|
|
1443
|
+
channelName: "グループ名",
|
|
1444
|
+
notSet: "未設定",
|
|
1445
|
+
pinChat: "チャットを固定",
|
|
1446
|
+
sameModel: "モデルを統一",
|
|
1447
|
+
sameModelHint: "ここのエージェントすべてが選んだモデルで答えます",
|
|
1448
|
+
mixedModels: "それぞれ",
|
|
1449
|
+
modelSwitched: "{count} 人のメンバーが選んだモデルに切り替わりました",
|
|
1450
|
+
agentSettings: "クイック設定",
|
|
1451
|
+
model: "モデル",
|
|
1452
|
+
agentSettingsHint: "モデルはすぐに、役割は次のセッションから反映されます。",
|
|
1314
1453
|
canAdd: "{count} 個のエージェントを追加できます",
|
|
1315
1454
|
findAgent: "エージェントを検索",
|
|
1316
1455
|
addCount: "{count} 人を追加",
|
|
@@ -1473,7 +1612,40 @@ var ZH = {
|
|
|
1473
1612
|
answering: "{name} 正在回答",
|
|
1474
1613
|
failed: "没有回答",
|
|
1475
1614
|
mention: "@{name}",
|
|
1476
|
-
stopped: "
|
|
1615
|
+
stopped: "讨论暂停,等你决定",
|
|
1616
|
+
stoppedStats: "{replies} 条回复 · 约 {tokens} tokens",
|
|
1617
|
+
stoppedReplies: "{replies} 条回复",
|
|
1618
|
+
keepGoing: "继续讨论",
|
|
1619
|
+
wrapUp: "请 {name} 总结",
|
|
1620
|
+
wentOn: "已继续",
|
|
1621
|
+
summedUp: "已请总结",
|
|
1622
|
+
dailyChannel: "这个群今天的用量到了上限,智能体只回答你",
|
|
1623
|
+
dailyAll: "所有群今天的用量到了上限,已全部暂停",
|
|
1624
|
+
overBudget: "超出单条回复上限,已停下",
|
|
1625
|
+
limitsTitle: "群聊用量",
|
|
1626
|
+
limitAnswer: "单条回复",
|
|
1627
|
+
limitAnswerHint: "超过就在原处停下这条回复",
|
|
1628
|
+
limitChannelDay: "每个群每天",
|
|
1629
|
+
limitChannelDayHint: "超过后当天这个群的智能体只回答你",
|
|
1630
|
+
limitAllDay: "所有群每天",
|
|
1631
|
+
limitAllDayHint: "超过后全部暂停并通知你",
|
|
1632
|
+
limitSpent: "今天已用",
|
|
1633
|
+
noLimit: "不限",
|
|
1634
|
+
talkLength: "讨论长度",
|
|
1635
|
+
budgetShortWord: "简短",
|
|
1636
|
+
budgetNormalWord: "标准",
|
|
1637
|
+
budgetLongWord: "深入",
|
|
1638
|
+
dailyLimit: "每天上限",
|
|
1639
|
+
dailySpent: "今天 {spent}",
|
|
1640
|
+
dailySpentOf: "今天 {spent} / {limit}",
|
|
1641
|
+
limitDefault: "默认",
|
|
1642
|
+
idleRepeat: "智能体在重复说过的话,先停下",
|
|
1643
|
+
idleAgree: "智能体只在附和,先停下",
|
|
1644
|
+
idlePingPong: "两人来回没有进展,先停下",
|
|
1645
|
+
extendedOnce: "有进展已自动续过一次",
|
|
1646
|
+
budgetShort: "简短讨论 · 约 {n} 条",
|
|
1647
|
+
budgetNormal: "标准讨论 · 约 {n} 条",
|
|
1648
|
+
budgetLong: "深入讨论 · 约 {n} 条",
|
|
1477
1649
|
search: "搜索",
|
|
1478
1650
|
clear: "清除",
|
|
1479
1651
|
new: "新建",
|
|
@@ -1484,8 +1656,9 @@ var ZH = {
|
|
|
1484
1656
|
noAgentsYet: "还没有智能体",
|
|
1485
1657
|
noAgentsYetHint: "点 + 新建,或让 Ta 组个团队",
|
|
1486
1658
|
partners: "伙伴",
|
|
1487
|
-
groupsSection: "
|
|
1659
|
+
groupsSection: "聊天",
|
|
1488
1660
|
agentsSection: "智能体",
|
|
1661
|
+
agentTag: "智能体",
|
|
1489
1662
|
noPartners: "还没有伙伴",
|
|
1490
1663
|
noPartnersHint: "点 + 新建智能体或群聊,或加个好友",
|
|
1491
1664
|
inviteFriends: "邀请好友",
|
|
@@ -1509,7 +1682,17 @@ var ZH = {
|
|
|
1509
1682
|
channelNamePlaceholder: "例如:官网改版",
|
|
1510
1683
|
addAgents: "添加智能体",
|
|
1511
1684
|
searchAgents: "搜索智能体,选择 1–{max} 个",
|
|
1512
|
-
showMembers: "
|
|
1685
|
+
showMembers: "群聊信息",
|
|
1686
|
+
channelName: "群聊名称",
|
|
1687
|
+
notSet: "未设置",
|
|
1688
|
+
pinChat: "置顶聊天",
|
|
1689
|
+
sameModel: "统一模型",
|
|
1690
|
+
sameModelHint: "群里的智能体都改用你选的模型",
|
|
1691
|
+
mixedModels: "各用各的",
|
|
1692
|
+
modelSwitched: "{count} 位成员已改用所选模型",
|
|
1693
|
+
agentSettings: "快捷设置",
|
|
1694
|
+
model: "模型",
|
|
1695
|
+
agentSettingsHint: "模型立即生效;职责从下一个会话起生效。",
|
|
1513
1696
|
canAdd: "还能添加 {count} 个智能体",
|
|
1514
1697
|
findAgent: "搜索智能体",
|
|
1515
1698
|
addCount: "添加 {count} 位",
|
|
@@ -1672,7 +1855,40 @@ var ZH_TW = {
|
|
|
1672
1855
|
answering: "{name} 正在回答",
|
|
1673
1856
|
failed: "沒有回答",
|
|
1674
1857
|
mention: "@{name}",
|
|
1675
|
-
stopped: "
|
|
1858
|
+
stopped: "討論暫停,等你決定",
|
|
1859
|
+
stoppedStats: "{replies} 則回覆 · 約 {tokens} tokens",
|
|
1860
|
+
stoppedReplies: "{replies} 則回覆",
|
|
1861
|
+
keepGoing: "繼續討論",
|
|
1862
|
+
wrapUp: "請 {name} 總結",
|
|
1863
|
+
wentOn: "已繼續",
|
|
1864
|
+
summedUp: "已請總結",
|
|
1865
|
+
dailyChannel: "這個群今天的用量到了上限,智能體只回答你",
|
|
1866
|
+
dailyAll: "所有群今天的用量到了上限,已全部暫停",
|
|
1867
|
+
overBudget: "超出單則回覆上限,已停下",
|
|
1868
|
+
limitsTitle: "群聊用量",
|
|
1869
|
+
limitAnswer: "單則回覆",
|
|
1870
|
+
limitAnswerHint: "超過就在原處停下這則回覆",
|
|
1871
|
+
limitChannelDay: "每個群每天",
|
|
1872
|
+
limitChannelDayHint: "超過後當天這個群的智能體只回答你",
|
|
1873
|
+
limitAllDay: "所有群每天",
|
|
1874
|
+
limitAllDayHint: "超過後全部暫停並通知你",
|
|
1875
|
+
limitSpent: "今天已用",
|
|
1876
|
+
noLimit: "不限",
|
|
1877
|
+
talkLength: "討論長度",
|
|
1878
|
+
budgetShortWord: "簡短",
|
|
1879
|
+
budgetNormalWord: "標準",
|
|
1880
|
+
budgetLongWord: "深入",
|
|
1881
|
+
dailyLimit: "每天上限",
|
|
1882
|
+
dailySpent: "今天 {spent}",
|
|
1883
|
+
dailySpentOf: "今天 {spent} / {limit}",
|
|
1884
|
+
limitDefault: "預設",
|
|
1885
|
+
idleRepeat: "智能體在重複說過的話,先停下",
|
|
1886
|
+
idleAgree: "智能體只在附和,先停下",
|
|
1887
|
+
idlePingPong: "兩人來回沒有進展,先停下",
|
|
1888
|
+
extendedOnce: "有進展已自動續過一次",
|
|
1889
|
+
budgetShort: "簡短討論 · 約 {n} 則",
|
|
1890
|
+
budgetNormal: "標準討論 · 約 {n} 則",
|
|
1891
|
+
budgetLong: "深入討論 · 約 {n} 則",
|
|
1676
1892
|
search: "搜尋",
|
|
1677
1893
|
clear: "清除",
|
|
1678
1894
|
new: "新建",
|
|
@@ -1683,8 +1899,9 @@ var ZH_TW = {
|
|
|
1683
1899
|
noAgentsYet: "還沒有智慧體",
|
|
1684
1900
|
noAgentsYetHint: "點 + 新建,或讓 Ta 組個團隊",
|
|
1685
1901
|
partners: "夥伴",
|
|
1686
|
-
groupsSection: "
|
|
1902
|
+
groupsSection: "聊天",
|
|
1687
1903
|
agentsSection: "智慧體",
|
|
1904
|
+
agentTag: "智慧體",
|
|
1688
1905
|
noPartners: "還沒有夥伴",
|
|
1689
1906
|
noPartnersHint: "點 + 新建智慧體或群聊,或加個好友",
|
|
1690
1907
|
inviteFriends: "邀請好友",
|
|
@@ -1708,7 +1925,17 @@ var ZH_TW = {
|
|
|
1708
1925
|
channelNamePlaceholder: "例如:官網改版",
|
|
1709
1926
|
addAgents: "新增智慧體",
|
|
1710
1927
|
searchAgents: "搜尋智慧體,選擇 1–{max} 個",
|
|
1711
|
-
showMembers: "
|
|
1928
|
+
showMembers: "群聊資訊",
|
|
1929
|
+
channelName: "群聊名稱",
|
|
1930
|
+
notSet: "未設定",
|
|
1931
|
+
pinChat: "置頂聊天",
|
|
1932
|
+
sameModel: "統一模型",
|
|
1933
|
+
sameModelHint: "群裡的智慧體都改用你選的模型",
|
|
1934
|
+
mixedModels: "各用各的",
|
|
1935
|
+
modelSwitched: "{count} 位成員已改用所選模型",
|
|
1936
|
+
agentSettings: "快捷設定",
|
|
1937
|
+
model: "模型",
|
|
1938
|
+
agentSettingsHint: "模型立即生效;職責從下一個會話起生效。",
|
|
1712
1939
|
canAdd: "還能新增 {count} 個智慧體",
|
|
1713
1940
|
findAgent: "搜尋智慧體",
|
|
1714
1941
|
addCount: "新增 {count} 位",
|
|
@@ -1871,7 +2098,40 @@ var EN = {
|
|
|
1871
2098
|
answering: "{name} is answering",
|
|
1872
2099
|
failed: "did not answer",
|
|
1873
2100
|
mention: "Mention {name}",
|
|
1874
|
-
stopped: "The agents
|
|
2101
|
+
stopped: "The agents paused to wait for you",
|
|
2102
|
+
stoppedStats: "{replies} replies · about {tokens} tokens",
|
|
2103
|
+
stoppedReplies: "{replies} replies",
|
|
2104
|
+
keepGoing: "Go on",
|
|
2105
|
+
wrapUp: "Have {name} sum up",
|
|
2106
|
+
wentOn: "went on",
|
|
2107
|
+
summedUp: "summed up",
|
|
2108
|
+
dailyChannel: "This group chat reached its limit of the day; the agents only answer you",
|
|
2109
|
+
dailyAll: "All group chats reached the limit of the day; paused",
|
|
2110
|
+
overBudget: "stopped past the limit of one answer",
|
|
2111
|
+
limitsTitle: "Group chats",
|
|
2112
|
+
limitAnswer: "One answer",
|
|
2113
|
+
limitAnswerHint: "An answer spending more is stopped where it is",
|
|
2114
|
+
limitChannelDay: "One group chat a day",
|
|
2115
|
+
limitChannelDayHint: "Past it, its agents only answer you that day",
|
|
2116
|
+
limitAllDay: "All group chats a day",
|
|
2117
|
+
limitAllDayHint: "Past it, all pause and you are told",
|
|
2118
|
+
limitSpent: "Spent today",
|
|
2119
|
+
noLimit: "No limit",
|
|
2120
|
+
talkLength: "Length of talks",
|
|
2121
|
+
budgetShortWord: "Short",
|
|
2122
|
+
budgetNormalWord: "Normal",
|
|
2123
|
+
budgetLongWord: "Long",
|
|
2124
|
+
dailyLimit: "A day",
|
|
2125
|
+
dailySpent: "today {spent}",
|
|
2126
|
+
dailySpentOf: "today {spent} / {limit}",
|
|
2127
|
+
limitDefault: "Default",
|
|
2128
|
+
idleRepeat: "The agents were saying the same again; paused",
|
|
2129
|
+
idleAgree: "The agents only agreed; paused",
|
|
2130
|
+
idlePingPong: "Two agents went back and forth with nothing done; paused",
|
|
2131
|
+
extendedOnce: "went on once for the work done",
|
|
2132
|
+
budgetShort: "Short talks · about {n} replies",
|
|
2133
|
+
budgetNormal: "Normal talks · about {n} replies",
|
|
2134
|
+
budgetLong: "Long talks · about {n} replies",
|
|
1875
2135
|
search: "Search",
|
|
1876
2136
|
clear: "Clear",
|
|
1877
2137
|
new: "New",
|
|
@@ -1882,8 +2142,9 @@ var EN = {
|
|
|
1882
2142
|
noAgentsYet: "No agents yet",
|
|
1883
2143
|
noAgentsYetHint: "Create one with +, or ask Ta for a team",
|
|
1884
2144
|
partners: "Partners",
|
|
1885
|
-
groupsSection: "
|
|
2145
|
+
groupsSection: "Chats",
|
|
1886
2146
|
agentsSection: "Agents",
|
|
2147
|
+
agentTag: "Agent",
|
|
1887
2148
|
noPartners: "No one to work with yet",
|
|
1888
2149
|
noPartnersHint: "Create an agent or a group chat with +, or add a friend",
|
|
1889
2150
|
inviteFriends: "Invite friends",
|
|
@@ -1907,7 +2168,17 @@ var EN = {
|
|
|
1907
2168
|
channelNamePlaceholder: "For example: Project Falcon",
|
|
1908
2169
|
addAgents: "Add agents",
|
|
1909
2170
|
searchAgents: "Search agents, pick 1 to {max}",
|
|
1910
|
-
showMembers: "
|
|
2171
|
+
showMembers: "About the group chat",
|
|
2172
|
+
channelName: "Group name",
|
|
2173
|
+
notSet: "Not set",
|
|
2174
|
+
pinChat: "Pin the chat",
|
|
2175
|
+
sameModel: "Model for all",
|
|
2176
|
+
sameModelHint: "Every agent here answers with the model you pick",
|
|
2177
|
+
mixedModels: "Each its own",
|
|
2178
|
+
modelSwitched: "The {count} members answer with the model picked now.",
|
|
2179
|
+
agentSettings: "Quick settings",
|
|
2180
|
+
model: "Model",
|
|
2181
|
+
agentSettingsHint: "The model takes effect at once; the role from its next session.",
|
|
1911
2182
|
canAdd: "{count} agents can join",
|
|
1912
2183
|
findAgent: "Search agents",
|
|
1913
2184
|
addCount: "Add {count}",
|
|
@@ -2047,6 +2318,7 @@ var ChannelWords;
|
|
|
2047
2318
|
var DOUBLE_PAGE = "assistant/assistant";
|
|
2048
2319
|
var CHANNEL_PAGE = `${NAME}/channel`;
|
|
2049
2320
|
var MEMBERS_VIEW = `${NAME}/members`;
|
|
2321
|
+
var ROOM_INFO_VIEW = "@celljs/ta-rooms/members";
|
|
2050
2322
|
var CHANNEL_KEY = "ta-channels.channel";
|
|
2051
2323
|
|
|
2052
2324
|
class ChannelsUiStore {
|
|
@@ -2643,6 +2915,11 @@ class ChannelsClient {
|
|
|
2643
2915
|
await this.load(true);
|
|
2644
2916
|
return agent;
|
|
2645
2917
|
}
|
|
2918
|
+
async setChannelModel(channelId, model) {
|
|
2919
|
+
const channel = await this.send({ kind: "setChannelModel", channel: channelId, model });
|
|
2920
|
+
await this.load(true);
|
|
2921
|
+
return channel;
|
|
2922
|
+
}
|
|
2646
2923
|
async deleteAgent(agentId) {
|
|
2647
2924
|
await this.deleting(agentId, async () => {
|
|
2648
2925
|
await this.send({ kind: "deleteAgent", agent: agentId });
|
|
@@ -2683,6 +2960,15 @@ class ChannelsClient {
|
|
|
2683
2960
|
async post(channelId, text) {
|
|
2684
2961
|
await this.send({ kind: "post", channel: channelId, text });
|
|
2685
2962
|
}
|
|
2963
|
+
async resumeRound(channelId, messageId, how) {
|
|
2964
|
+
await this.send({ kind: "resumeRound", channel: channelId, message: messageId, how });
|
|
2965
|
+
}
|
|
2966
|
+
async setLimits(limits) {
|
|
2967
|
+
await this.send({ kind: "setLimits", limits });
|
|
2968
|
+
}
|
|
2969
|
+
async watch(channelId) {
|
|
2970
|
+
await this.send({ kind: "watch", channel: channelId });
|
|
2971
|
+
}
|
|
2686
2972
|
async changed(keys) {
|
|
2687
2973
|
const reads = [];
|
|
2688
2974
|
for (const key of keys) {
|
|
@@ -3365,415 +3651,193 @@ var HandOffView;
|
|
|
3365
3651
|
HandOffView.composerAddon = composerAddon;
|
|
3366
3652
|
})(HandOffView ||= {});
|
|
3367
3653
|
|
|
3368
|
-
// web-src/
|
|
3369
|
-
|
|
3370
|
-
|
|
3371
|
-
const
|
|
3372
|
-
const
|
|
3373
|
-
const
|
|
3374
|
-
const
|
|
3375
|
-
const
|
|
3376
|
-
|
|
3377
|
-
|
|
3378
|
-
|
|
3379
|
-
|
|
3380
|
-
|
|
3381
|
-
|
|
3654
|
+
// web-src/round-rules.ts
|
|
3655
|
+
var ChannelRounds;
|
|
3656
|
+
((ChannelRounds) => {
|
|
3657
|
+
const SHORT = 20;
|
|
3658
|
+
const MIN_PAIRS = 8;
|
|
3659
|
+
const ALIKE = 0.8;
|
|
3660
|
+
const PING_PONG = 4;
|
|
3661
|
+
const NEW = 0.35;
|
|
3662
|
+
const CHANGES = new Set(["edit", "write", "delete", "move"]);
|
|
3663
|
+
function scale(watchedAt, pages, now) {
|
|
3664
|
+
if (watchedAt !== undefined && now - watchedAt < 2 * WATCH_MS) {
|
|
3665
|
+
return 2;
|
|
3666
|
+
}
|
|
3667
|
+
return pages === undefined || pages > 0 ? 1 : 0.5;
|
|
3668
|
+
}
|
|
3669
|
+
ChannelRounds.scale = scale;
|
|
3670
|
+
function idle(said, progress) {
|
|
3671
|
+
const last = said.at(-1);
|
|
3672
|
+
if (!last) {
|
|
3673
|
+
return;
|
|
3674
|
+
}
|
|
3675
|
+
const pairs = said.map((item) => pairsOf(item.text));
|
|
3676
|
+
const mine = pairs[pairs.length - 1];
|
|
3677
|
+
if (mine.length >= MIN_PAIRS && pairs.slice(0, -1).some((other) => alike(other, mine) >= ALIKE)) {
|
|
3678
|
+
return "repeat";
|
|
3679
|
+
}
|
|
3680
|
+
const recent = said.slice(-3);
|
|
3681
|
+
if (recent.length === 3 && recent.every((item) => units(item.text).join("").length < SHORT)) {
|
|
3682
|
+
return "agree";
|
|
3683
|
+
}
|
|
3684
|
+
const run = said.slice(-PING_PONG);
|
|
3685
|
+
const authors = new Set(run.map((item) => item.author));
|
|
3686
|
+
const alternate = run.every((item, i) => i === 0 || item.author !== run[i - 1].author);
|
|
3687
|
+
const start = said.length - PING_PONG;
|
|
3688
|
+
if (progress || start <= 0 || authors.size !== 2 || !alternate) {
|
|
3689
|
+
return;
|
|
3690
|
+
}
|
|
3691
|
+
const seen = new Set(pairs.slice(0, start).flat());
|
|
3692
|
+
for (const own of pairs.slice(start)) {
|
|
3693
|
+
const fresh = own.filter((pair) => !seen.has(pair)).length;
|
|
3694
|
+
if (own.length === 0 || fresh / own.length >= NEW) {
|
|
3695
|
+
return;
|
|
3696
|
+
}
|
|
3697
|
+
for (const pair of own) {
|
|
3698
|
+
seen.add(pair);
|
|
3699
|
+
}
|
|
3700
|
+
}
|
|
3701
|
+
return "pingPong";
|
|
3382
3702
|
}
|
|
3383
|
-
|
|
3384
|
-
|
|
3385
|
-
|
|
3386
|
-
|
|
3387
|
-
|
|
3388
|
-
|
|
3389
|
-
|
|
3390
|
-
|
|
3391
|
-
|
|
3392
|
-
|
|
3393
|
-
|
|
3394
|
-
|
|
3395
|
-
|
|
3396
|
-
|
|
3703
|
+
ChannelRounds.idle = idle;
|
|
3704
|
+
function day(now) {
|
|
3705
|
+
const date = new Date(now);
|
|
3706
|
+
return `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, "0")}-${String(date.getDate()).padStart(2, "0")}`;
|
|
3707
|
+
}
|
|
3708
|
+
ChannelRounds.day = day;
|
|
3709
|
+
function limits(stored) {
|
|
3710
|
+
const given = stored ?? {};
|
|
3711
|
+
const pick = (key) => LIMIT_CHOICES[key].includes(given[key]) ? given[key] : DEFAULT_LIMITS[key];
|
|
3712
|
+
return { answer: pick("answer"), channelDay: pick("channelDay"), allDay: pick("allDay") };
|
|
3713
|
+
}
|
|
3714
|
+
ChannelRounds.limits = limits;
|
|
3715
|
+
function today(stored, now) {
|
|
3716
|
+
const current = day(now);
|
|
3717
|
+
return stored?.day === current ? stored : { day: current, total: 0, channels: {} };
|
|
3718
|
+
}
|
|
3719
|
+
ChannelRounds.today = today;
|
|
3720
|
+
function spend(stored, channelId, tokens, now) {
|
|
3721
|
+
const current = today(stored, now);
|
|
3722
|
+
return { ...current, total: current.total + tokens, channels: { ...current.channels, [channelId]: (current.channels[channelId] ?? 0) + tokens } };
|
|
3723
|
+
}
|
|
3724
|
+
ChannelRounds.spend = spend;
|
|
3725
|
+
function held(spent, limits2, channelId, hops, granted = false) {
|
|
3726
|
+
if (granted) {
|
|
3727
|
+
return;
|
|
3728
|
+
}
|
|
3729
|
+
if (limits2.allDay > 0 && spent.total >= limits2.allDay) {
|
|
3730
|
+
return "all";
|
|
3731
|
+
}
|
|
3732
|
+
if (hops > 0 && limits2.channelDay > 0 && (spent.channels[channelId] ?? 0) >= limits2.channelDay) {
|
|
3733
|
+
return "channel";
|
|
3734
|
+
}
|
|
3735
|
+
return;
|
|
3736
|
+
}
|
|
3737
|
+
ChannelRounds.held = held;
|
|
3738
|
+
function changedFiles(entries) {
|
|
3739
|
+
for (const entry of entries) {
|
|
3740
|
+
const message = entry?.message;
|
|
3741
|
+
if (entry?.type !== "message" || message?.role !== "assistant" || !Array.isArray(message.content)) {
|
|
3742
|
+
continue;
|
|
3743
|
+
}
|
|
3744
|
+
for (const part of message.content) {
|
|
3745
|
+
if (part?.type !== "toolCall") {
|
|
3746
|
+
continue;
|
|
3747
|
+
}
|
|
3748
|
+
if (CHANGES.has(String(part.name)) || part.name === "agent_tool" && CHANGES.has(String(part.arguments?.kind))) {
|
|
3749
|
+
return true;
|
|
3750
|
+
}
|
|
3751
|
+
}
|
|
3752
|
+
}
|
|
3753
|
+
return false;
|
|
3754
|
+
}
|
|
3755
|
+
ChannelRounds.changedFiles = changedFiles;
|
|
3756
|
+
function units(text) {
|
|
3757
|
+
return text.replace(/@[^\s@#,,。::]+/g, " ").toLowerCase().match(/[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}]|[\p{L}\p{N}]+/gu) ?? [];
|
|
3758
|
+
}
|
|
3759
|
+
function pairsOf(text) {
|
|
3760
|
+
const words = units(text);
|
|
3761
|
+
return words.length === 1 ? words : words.slice(1).map((word, i) => `${words[i]} ${word}`);
|
|
3762
|
+
}
|
|
3763
|
+
function alike(a, b) {
|
|
3764
|
+
if (a.length === 0 || b.length === 0) {
|
|
3765
|
+
return 0;
|
|
3766
|
+
}
|
|
3767
|
+
const left = new Map;
|
|
3768
|
+
for (const pair of a) {
|
|
3769
|
+
left.set(pair, (left.get(pair) ?? 0) + 1);
|
|
3770
|
+
}
|
|
3771
|
+
let common = 0;
|
|
3772
|
+
for (const pair of b) {
|
|
3773
|
+
const n = left.get(pair) ?? 0;
|
|
3774
|
+
if (n > 0) {
|
|
3775
|
+
left.set(pair, n - 1);
|
|
3776
|
+
common++;
|
|
3777
|
+
}
|
|
3778
|
+
}
|
|
3779
|
+
return 2 * common / (a.length + b.length);
|
|
3780
|
+
}
|
|
3781
|
+
})(ChannelRounds ||= {});
|
|
3782
|
+
|
|
3783
|
+
// web-src/limit-settings.tsx
|
|
3784
|
+
function amount(pi, tokens) {
|
|
3785
|
+
return tokens > 0 ? new Intl.NumberFormat(pi.ui.language, { notation: "compact", maximumFractionDigits: 1 }).format(tokens) : ChannelWords.of(pi.ui.language).noLimit;
|
|
3397
3786
|
}
|
|
3398
|
-
function
|
|
3399
|
-
const
|
|
3400
|
-
|
|
3401
|
-
|
|
3402
|
-
|
|
3403
|
-
const
|
|
3404
|
-
|
|
3405
|
-
|
|
3406
|
-
|
|
3407
|
-
|
|
3408
|
-
|
|
3409
|
-
|
|
3410
|
-
|
|
3411
|
-
|
|
3412
|
-
|
|
3413
|
-
|
|
3414
|
-
|
|
3415
|
-
};
|
|
3416
|
-
|
|
3417
|
-
|
|
3418
|
-
|
|
3419
|
-
|
|
3420
|
-
|
|
3421
|
-
|
|
3422
|
-
|
|
3423
|
-
|
|
3424
|
-
|
|
3425
|
-
|
|
3426
|
-
|
|
3427
|
-
|
|
3428
|
-
className: "tac-members-top"
|
|
3429
|
-
}, /* @__PURE__ */ React.createElement(RoomFace, {
|
|
3430
|
-
members,
|
|
3431
|
-
faces,
|
|
3432
|
-
size: 44,
|
|
3433
|
-
working
|
|
3434
|
-
}), /* @__PURE__ */ React.createElement("span", {
|
|
3435
|
-
className: "tac-members-title"
|
|
3436
|
-
}, /* @__PURE__ */ React.createElement("strong", null, channel.name), /* @__PURE__ */ React.createElement("span", null, channel.topic ?? ChannelWords.format(w.memberCount, { count: String(members.length) })))), /* @__PURE__ */ React.createElement("div", {
|
|
3437
|
-
className: "tac-members-label"
|
|
3438
|
-
}, w.members, " · ", members.length), /* @__PURE__ */ React.createElement("button", {
|
|
3439
|
-
type: "button",
|
|
3440
|
-
className: "tac-member-main",
|
|
3441
|
-
onClick: () => ui.set({ adding: true })
|
|
3442
|
-
}, /* @__PURE__ */ React.createElement("span", {
|
|
3443
|
-
className: "tac-member-plus"
|
|
3444
|
-
}, /* @__PURE__ */ React.createElement(UserPlus, {
|
|
3445
|
-
size: 16
|
|
3446
|
-
})), /* @__PURE__ */ React.createElement("span", {
|
|
3447
|
-
className: "tac-member-text"
|
|
3448
|
-
}, /* @__PURE__ */ React.createElement("span", {
|
|
3449
|
-
className: "tac-member-name"
|
|
3450
|
-
}, w.addMembers))), pi.rooms && channel.by !== "ta" && /* @__PURE__ */ React.createElement("button", {
|
|
3451
|
-
type: "button",
|
|
3452
|
-
className: "tac-member-main",
|
|
3453
|
-
onClick: () => openShareGroup(context, channel)
|
|
3454
|
-
}, /* @__PURE__ */ React.createElement("span", {
|
|
3455
|
-
className: "tac-member-plus"
|
|
3456
|
-
}, /* @__PURE__ */ React.createElement(Contact, {
|
|
3457
|
-
size: 16
|
|
3458
|
-
})), /* @__PURE__ */ React.createElement("span", {
|
|
3459
|
-
className: "tac-member-text"
|
|
3460
|
-
}, /* @__PURE__ */ React.createElement("span", {
|
|
3461
|
-
className: "tac-member-name"
|
|
3462
|
-
}, w.inviteFriends))), members.map((agent, index) => {
|
|
3463
|
-
const lead = index === 0;
|
|
3464
|
-
const off = muted.includes(agent.id);
|
|
3465
|
-
const answering = working.includes(agent.id);
|
|
3466
|
-
const detail = answering ? w.replying : off ? w.muted : agent.role.split(`
|
|
3467
|
-
`)[0] ?? "";
|
|
3468
|
-
return /* @__PURE__ */ React.createElement("div", {
|
|
3469
|
-
key: agent.id,
|
|
3470
|
-
className: `tac-member${off ? " tac-muted" : ""}`
|
|
3471
|
-
}, /* @__PURE__ */ React.createElement("button", {
|
|
3472
|
-
type: "button",
|
|
3473
|
-
className: "tac-member-main",
|
|
3474
|
-
title: `${w.open}
|
|
3475
|
-
${agent.role}`,
|
|
3476
|
-
onClick: () => ChannelViews.openAgent(context, agent.id).catch((error) => pi.ui.notify(ChannelViews.message(error), "error"))
|
|
3477
|
-
}, /* @__PURE__ */ React.createElement(AgentAvatar, {
|
|
3478
|
-
agent,
|
|
3479
|
-
faces,
|
|
3480
|
-
size: 32,
|
|
3481
|
-
working: answering
|
|
3482
|
-
}), /* @__PURE__ */ React.createElement("span", {
|
|
3483
|
-
className: "tac-member-text"
|
|
3484
|
-
}, /* @__PURE__ */ React.createElement("span", {
|
|
3485
|
-
className: "tac-member-name"
|
|
3486
|
-
}, /* @__PURE__ */ React.createElement("span", {
|
|
3487
|
-
className: "tac-member-label"
|
|
3488
|
-
}, agent.name), lead && /* @__PURE__ */ React.createElement("span", {
|
|
3489
|
-
className: "tac-lead",
|
|
3490
|
-
title: w.leadHint
|
|
3491
|
-
}, /* @__PURE__ */ React.createElement(Crown, {
|
|
3492
|
-
size: 11
|
|
3493
|
-
}), /* @__PURE__ */ React.createElement("span", null, w.lead)), agent.temporary && /* @__PURE__ */ React.createElement("span", {
|
|
3494
|
-
className: "tac-temporary",
|
|
3495
|
-
title: w.temporary
|
|
3496
|
-
}, w.temporaryTag)), /* @__PURE__ */ React.createElement("span", {
|
|
3497
|
-
className: `tac-member-detail${answering ? " tac-live" : ""}`
|
|
3498
|
-
}, detail))), /* @__PURE__ */ React.createElement("span", {
|
|
3499
|
-
className: "tac-member-actions"
|
|
3500
|
-
}, agent.temporary && /* @__PURE__ */ React.createElement("button", {
|
|
3501
|
-
type: "button",
|
|
3502
|
-
className: "tac-action",
|
|
3503
|
-
title: w.keep,
|
|
3504
|
-
"aria-label": w.keep,
|
|
3505
|
-
disabled: !!busy,
|
|
3506
|
-
onClick: () => service.updateAgent(agent.id, { keep: true }).then(() => pi.ui.notify(ChannelWords.format(w.kept, { name: agent.name }), "info")).catch((error) => pi.ui.notify(ChannelViews.message(error), "error"))
|
|
3507
|
-
}, /* @__PURE__ */ React.createElement(UserPlus, {
|
|
3508
|
-
size: 15
|
|
3509
|
-
})), !lead && /* @__PURE__ */ React.createElement("button", {
|
|
3510
|
-
type: "button",
|
|
3511
|
-
className: "tac-action",
|
|
3512
|
-
title: w.makeLead,
|
|
3513
|
-
"aria-label": w.makeLead,
|
|
3514
|
-
disabled: !!busy,
|
|
3515
|
-
onClick: () => change(agent, "lead")
|
|
3516
|
-
}, /* @__PURE__ */ React.createElement(Crown, {
|
|
3517
|
-
size: 15
|
|
3518
|
-
})), /* @__PURE__ */ React.createElement("button", {
|
|
3519
|
-
type: "button",
|
|
3520
|
-
className: `tac-action${off ? " tac-on" : ""}`,
|
|
3521
|
-
title: off ? w.unmute : w.mute,
|
|
3522
|
-
"aria-label": off ? w.unmute : w.mute,
|
|
3523
|
-
"aria-pressed": off,
|
|
3524
|
-
disabled: !!busy,
|
|
3525
|
-
onClick: () => change(agent, off ? "unmute" : "mute")
|
|
3526
|
-
}, /* @__PURE__ */ React.createElement(BellOff, {
|
|
3527
|
-
size: 15
|
|
3528
|
-
})), /* @__PURE__ */ React.createElement("button", {
|
|
3529
|
-
type: "button",
|
|
3530
|
-
className: "tac-action",
|
|
3531
|
-
title: w.reset,
|
|
3532
|
-
"aria-label": w.reset,
|
|
3533
|
-
disabled: !!busy,
|
|
3534
|
-
onClick: () => reset(agent)
|
|
3535
|
-
}, /* @__PURE__ */ React.createElement(RotateCcw, {
|
|
3536
|
-
size: 15
|
|
3537
|
-
})), /* @__PURE__ */ React.createElement("button", {
|
|
3787
|
+
function useLimits(pi) {
|
|
3788
|
+
const read = React.useCallback(async () => ({
|
|
3789
|
+
limits: ChannelRounds.limits(await pi.storage.get(Keys.LIMITS)),
|
|
3790
|
+
...((today) => ({ spent: today.total, channels: today.channels }))(ChannelRounds.today(await pi.storage.get(Keys.SPENT), Date.now()))
|
|
3791
|
+
}), [pi]);
|
|
3792
|
+
const [value, setValue] = React.useState({ limits: ChannelRounds.limits(undefined), spent: 0, channels: {} });
|
|
3793
|
+
React.useEffect(() => {
|
|
3794
|
+
let live = true;
|
|
3795
|
+
const load = () => void read().then((next) => live && setValue(next), () => {
|
|
3796
|
+
return;
|
|
3797
|
+
});
|
|
3798
|
+
load();
|
|
3799
|
+
const stop = pi.storage.onChange((keys) => (keys.includes(Keys.LIMITS) || keys.includes(Keys.SPENT)) && load());
|
|
3800
|
+
return () => {
|
|
3801
|
+
live = false;
|
|
3802
|
+
stop();
|
|
3803
|
+
};
|
|
3804
|
+
}, [pi, read]);
|
|
3805
|
+
return value;
|
|
3806
|
+
}
|
|
3807
|
+
function limitSettings(pi, service) {
|
|
3808
|
+
const words = () => ChannelWords.of(pi.ui.language);
|
|
3809
|
+
const row = (key) => function Choices() {
|
|
3810
|
+
const { limits } = useLimits(pi);
|
|
3811
|
+
const pick = (value) => void service.setLimits({ [key]: value }).catch((error) => pi.ui.notify(String(error?.message ?? error), "error"));
|
|
3812
|
+
return /* @__PURE__ */ React.createElement("fieldset", {
|
|
3813
|
+
className: "ta-segmented",
|
|
3814
|
+
"aria-label": words()[key === "answer" ? "limitAnswer" : key === "channelDay" ? "limitChannelDay" : "limitAllDay"]
|
|
3815
|
+
}, LIMIT_CHOICES[key].map((value) => /* @__PURE__ */ React.createElement("button", {
|
|
3816
|
+
key: value,
|
|
3538
3817
|
type: "button",
|
|
3539
|
-
|
|
3540
|
-
|
|
3541
|
-
|
|
3542
|
-
|
|
3543
|
-
|
|
3544
|
-
|
|
3545
|
-
|
|
3546
|
-
|
|
3547
|
-
|
|
3548
|
-
|
|
3549
|
-
}, confirming ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("span", {
|
|
3550
|
-
className: "tac-members-ask"
|
|
3551
|
-
}, ChannelWords.format(w.confirmDelete, { channel: channel.name })), /* @__PURE__ */ React.createElement("button", {
|
|
3552
|
-
type: "button",
|
|
3553
|
-
className: "tac-button",
|
|
3554
|
-
onClick: () => setConfirming(false)
|
|
3555
|
-
}, w.cancel), /* @__PURE__ */ React.createElement("button", {
|
|
3556
|
-
type: "button",
|
|
3557
|
-
className: busy === "delete" ? "tac-button tac-danger ta-busy" : "tac-button tac-danger",
|
|
3558
|
-
disabled: !!busy,
|
|
3559
|
-
onClick: remove
|
|
3560
|
-
}, w.delete, busy === "delete" && /* @__PURE__ */ React.createElement("span", {
|
|
3561
|
-
className: "ta-spinner ta-busy-mark"
|
|
3562
|
-
}))) : /* @__PURE__ */ React.createElement("button", {
|
|
3563
|
-
type: "button",
|
|
3564
|
-
className: "tac-link tac-danger",
|
|
3565
|
-
onClick: () => setConfirming(true)
|
|
3566
|
-
}, /* @__PURE__ */ React.createElement(Trash, {
|
|
3567
|
-
size: 14
|
|
3568
|
-
}), w.deleteChannel)));
|
|
3569
|
-
}
|
|
3570
|
-
function MemberPicker({ context, team, channel, faces }) {
|
|
3571
|
-
const { pi, service, ui } = context;
|
|
3572
|
-
const w = ChannelViews.words(pi);
|
|
3573
|
-
const [query, setQuery] = React.useState("");
|
|
3574
|
-
const [picked, setPicked] = React.useState([]);
|
|
3575
|
-
const ArrowLeft = ChannelViews.icon(pi, "ArrowLeft");
|
|
3576
|
-
const Search = ChannelViews.icon(pi, "Search");
|
|
3577
|
-
const Check = ChannelViews.icon(pi, "Check");
|
|
3578
|
-
const UserPlus = ChannelViews.icon(pi, "UserPlus");
|
|
3579
|
-
const back = () => ui.set({ adding: false });
|
|
3580
|
-
const { busy, error, submit } = useSubmit(() => service.addMembers(channel.id, picked), back);
|
|
3581
|
-
const others = team.agents.filter((agent) => !channel.members.includes(agent.id));
|
|
3582
|
-
const shown = others.filter((agent) => SidebarUtil.matches(query, agent.name, agent.role));
|
|
3583
|
-
const toggle = (id) => setPicked(picked.includes(id) ? picked.filter((other) => other !== id) : [...picked, id]);
|
|
3584
|
-
return /* @__PURE__ */ React.createElement("div", {
|
|
3585
|
-
className: "tac-view tac-members"
|
|
3586
|
-
}, /* @__PURE__ */ React.createElement("div", {
|
|
3587
|
-
className: "tac-members-head"
|
|
3588
|
-
}, /* @__PURE__ */ React.createElement("button", {
|
|
3589
|
-
type: "button",
|
|
3590
|
-
className: "tac-action",
|
|
3591
|
-
title: w.back,
|
|
3592
|
-
"aria-label": w.back,
|
|
3593
|
-
onClick: back
|
|
3594
|
-
}, /* @__PURE__ */ React.createElement(ArrowLeft, {
|
|
3595
|
-
size: 16
|
|
3596
|
-
})), /* @__PURE__ */ React.createElement("strong", null, w.addMembers)), /* @__PURE__ */ React.createElement("label", {
|
|
3597
|
-
className: "tac-search tac-members-search"
|
|
3598
|
-
}, /* @__PURE__ */ React.createElement(Search, {
|
|
3599
|
-
size: 14
|
|
3600
|
-
}), /* @__PURE__ */ React.createElement("input", {
|
|
3601
|
-
value: query,
|
|
3602
|
-
placeholder: w.findAgent,
|
|
3603
|
-
"aria-label": w.findAgent,
|
|
3604
|
-
onChange: (event) => setQuery(event.target.value)
|
|
3605
|
-
})), /* @__PURE__ */ React.createElement("div", {
|
|
3606
|
-
className: "tac-members-scroll"
|
|
3607
|
-
}, /* @__PURE__ */ React.createElement("div", {
|
|
3608
|
-
className: "tac-members-label"
|
|
3609
|
-
}, ChannelWords.format(w.canAdd, { count: String(others.length) })), others.length === 0 && /* @__PURE__ */ React.createElement(pi.ui.Empty, {
|
|
3610
|
-
compact: true,
|
|
3611
|
-
title: w.allMembers
|
|
3612
|
-
}), others.length > 0 && shown.length === 0 && /* @__PURE__ */ React.createElement(pi.ui.Empty, {
|
|
3613
|
-
compact: true,
|
|
3614
|
-
title: w.noMatch
|
|
3615
|
-
}), shown.map((agent) => {
|
|
3616
|
-
const on = picked.includes(agent.id);
|
|
3617
|
-
return /* @__PURE__ */ React.createElement("button", {
|
|
3618
|
-
key: agent.id,
|
|
3619
|
-
type: "button",
|
|
3620
|
-
className: `tac-member-main tac-pick${on ? " tac-on" : ""}`,
|
|
3621
|
-
"aria-pressed": on,
|
|
3622
|
-
title: agent.role,
|
|
3623
|
-
onClick: () => toggle(agent.id)
|
|
3624
|
-
}, /* @__PURE__ */ React.createElement(AgentAvatar, {
|
|
3625
|
-
agent,
|
|
3626
|
-
faces,
|
|
3627
|
-
size: 32
|
|
3628
|
-
}), /* @__PURE__ */ React.createElement("span", {
|
|
3629
|
-
className: "tac-member-text"
|
|
3630
|
-
}, /* @__PURE__ */ React.createElement("span", {
|
|
3631
|
-
className: "tac-member-name"
|
|
3632
|
-
}, /* @__PURE__ */ React.createElement("span", {
|
|
3633
|
-
className: "tac-member-label"
|
|
3634
|
-
}, agent.name)), /* @__PURE__ */ React.createElement("span", {
|
|
3635
|
-
className: "tac-member-detail"
|
|
3636
|
-
}, agent.role.split(`
|
|
3637
|
-
`)[0])), /* @__PURE__ */ React.createElement("span", {
|
|
3638
|
-
className: "tac-check"
|
|
3639
|
-
}, on && /* @__PURE__ */ React.createElement(Check, {
|
|
3640
|
-
size: 12,
|
|
3641
|
-
strokeWidth: 3
|
|
3642
|
-
})));
|
|
3643
|
-
}), /* @__PURE__ */ React.createElement("div", {
|
|
3644
|
-
className: "tac-members-sep"
|
|
3645
|
-
}), /* @__PURE__ */ React.createElement("button", {
|
|
3646
|
-
type: "button",
|
|
3647
|
-
className: "tac-member-main",
|
|
3648
|
-
onClick: () => newAgent(context)
|
|
3649
|
-
}, /* @__PURE__ */ React.createElement("span", {
|
|
3650
|
-
className: "tac-member-plus"
|
|
3651
|
-
}, /* @__PURE__ */ React.createElement(UserPlus, {
|
|
3652
|
-
size: 16
|
|
3653
|
-
})), /* @__PURE__ */ React.createElement("span", {
|
|
3654
|
-
className: "tac-member-text"
|
|
3655
|
-
}, /* @__PURE__ */ React.createElement("span", {
|
|
3656
|
-
className: "tac-member-name"
|
|
3657
|
-
}, w.newAgent)))), error && /* @__PURE__ */ React.createElement("div", {
|
|
3658
|
-
className: "tac-empty tac-error"
|
|
3659
|
-
}, error), /* @__PURE__ */ React.createElement("div", {
|
|
3660
|
-
className: "tac-members-foot"
|
|
3661
|
-
}, /* @__PURE__ */ React.createElement("button", {
|
|
3662
|
-
type: "button",
|
|
3663
|
-
className: busy ? "tac-button tac-primary tac-wide ta-busy" : "tac-button tac-primary tac-wide",
|
|
3664
|
-
disabled: busy || picked.length === 0,
|
|
3665
|
-
onClick: submit
|
|
3666
|
-
}, picked.length > 0 ? ChannelWords.format(w.addCount, { count: String(picked.length) }) : w.add, busy && /* @__PURE__ */ React.createElement("span", {
|
|
3667
|
-
className: "ta-spinner ta-busy-mark ta-on-brand"
|
|
3668
|
-
}))));
|
|
3669
|
-
}
|
|
3670
|
-
|
|
3671
|
-
// ../ta-protocol/esm/common/team-protocol.js
|
|
3672
|
-
var TA_OWNER = "owner";
|
|
3673
|
-
var TA_UNDECLARED = "extensions.install";
|
|
3674
|
-
var TaPermissionUtil;
|
|
3675
|
-
(function(TaPermissionUtil2) {
|
|
3676
|
-
function read(pi) {
|
|
3677
|
-
const given = pi === null || pi === undefined ? undefined : pi.permissions;
|
|
3678
|
-
const map = (value) => value && typeof value === "object" && !Array.isArray(value) ? Object.fromEntries(Object.entries(value).filter((entry) => typeof entry[1] === "string")) : undefined;
|
|
3679
|
-
const host2 = map(given === null || given === undefined ? undefined : given.host);
|
|
3680
|
-
const tools = map(given === null || given === undefined ? undefined : given.tools);
|
|
3681
|
-
return { ...host2 ? { host: host2 } : {}, ...tools ? { tools } : {} };
|
|
3682
|
-
}
|
|
3683
|
-
TaPermissionUtil2.read = read;
|
|
3684
|
-
function host(manifest, method, kind) {
|
|
3685
|
-
var _a, _b, _c, _d;
|
|
3686
|
-
const host2 = (_a = manifest === null || manifest === undefined ? undefined : manifest.host) !== null && _a !== undefined ? _a : {};
|
|
3687
|
-
const own = (key) => Object.prototype.hasOwnProperty.call(host2, key) ? host2[key] : undefined;
|
|
3688
|
-
return (_d = (_c = (_b = kind ? own(`${method}:${kind}`) : undefined) !== null && _b !== undefined ? _b : own(method)) !== null && _c !== undefined ? _c : own("*")) !== null && _d !== undefined ? _d : TA_UNDECLARED;
|
|
3689
|
-
}
|
|
3690
|
-
TaPermissionUtil2.host = host;
|
|
3691
|
-
})(TaPermissionUtil || (TaPermissionUtil = {}));
|
|
3692
|
-
var action = (id, en, zh, tw, ja, more = {}) => ({
|
|
3693
|
-
id,
|
|
3694
|
-
area: id.split(".")[0],
|
|
3695
|
-
title: { en, "zh-CN": zh, ...tw ? { "zh-TW": tw } : {}, ...ja ? { "ja-JP": ja } : {} },
|
|
3696
|
-
...more
|
|
3697
|
-
});
|
|
3698
|
-
var TA_ACTIONS = [
|
|
3699
|
-
action("chat.view", "See conversations", "查看对话", "檢視對話", "会話を確認"),
|
|
3700
|
-
action("chat.send", "Send in conversations", "在对话里发消息", "在對話裡發訊息", "会話にメッセージを送信"),
|
|
3701
|
-
action("chat.create", "Start conversations", "新建对话", "新建對話", "新しい会話を開始"),
|
|
3702
|
-
action("chat.stop", "Stop a reply", "停止回复", "停止回覆", "返信を停止"),
|
|
3703
|
-
action("chat.manage", "Rename, archive and close conversations", "改名、归档、关闭对话", "改名、歸檔、關閉對話", "会話の名前変更、アーカイブ、クローズ"),
|
|
3704
|
-
action("chat.share", "Share by a link", "生成分享链接", "生成分享連結", "共有リンクで共有"),
|
|
3705
|
-
action("agent.view", "See agents", "查看智能体", "檢視智慧體", "エージェントを確認"),
|
|
3706
|
-
action("agent.use", "Talk with agents", "和智能体对话", "和智慧體對話", "エージェントと対話"),
|
|
3707
|
-
action("agent.edit", "Create, change and remove agents", "新建、修改、删除智能体", "新建、修改、刪除智慧體", "エージェントを作成・変更・削除"),
|
|
3708
|
-
action("channel.view", "See channels", "查看频道", "檢視頻道", "チャネルを確認"),
|
|
3709
|
-
action("channel.post", "Post in channels", "在频道里发言", "在頻道里發言", "チャネルに投稿"),
|
|
3710
|
-
action("channel.manage", "Create and change channels", "新建、管理频道", "新建、管理頻道", "チャネルを作成・管理"),
|
|
3711
|
-
action("task.view", "See tasks", "查看任务", "檢視任務", "タスクを確認"),
|
|
3712
|
-
action("task.create", "Hand out tasks", "派任务", "派任務", "タスクを割り当て"),
|
|
3713
|
-
action("task.manage", "Take over and stop tasks", "接管、停止任务", "接管、停止任務", "タスクを引き継ぎ・停止"),
|
|
3714
|
-
action("files.read", "Read files", "读文件", "讀檔案", "ファイルを読取", { scoped: true }),
|
|
3715
|
-
action("files.write", "Change files", "改文件", "改檔案", "ファイルを変更", { scoped: true }),
|
|
3716
|
-
action("commands.run", "Let Ta run commands", "让 Ta 运行命令", "讓 Ta 執行命令", "Ta にコマンド実行を許可", { scoped: true, risky: true }),
|
|
3717
|
-
action("commands.terminal", "Open terminals", "打开终端", "開啟終端機", "ターミナルを開く", { scoped: true, risky: true }),
|
|
3718
|
-
action("hosts.use", "Use remote hosts", "使用远程主机", "使用遠端主機", "リモートホストを使用", { risky: true }),
|
|
3719
|
-
action("models.use", "Use the models", "使用模型", "使用模型", "モデルを使用"),
|
|
3720
|
-
action("models.manage", "Sign in to models", "登录和更换模型账号", "登入和更換模型帳號", "モデルアカウントにサインイン・変更", { grant: "single" }),
|
|
3721
|
-
action("cron.view", "See scheduled tasks", "查看定时任务", "檢視定時任務", "スケジュールタスクを確認"),
|
|
3722
|
-
action("cron.manage", "Change scheduled tasks", "管理定时任务", "管理定時任務", "スケジュールタスクを管理"),
|
|
3723
|
-
action("extensions.use", "Use extensions", "使用扩展", "使用擴充功能", "拡張機能を使用"),
|
|
3724
|
-
action("extensions.install", "Install and turn off extensions", "安装、停用扩展", "安裝、停用擴充功能", "拡張機能をインストール・無効化"),
|
|
3725
|
-
action("settings.view", "See settings", "查看设置", "檢視設定", "設定を確認"),
|
|
3726
|
-
action("settings.manage", "Change settings", "修改设置", "修改設定", "設定を変更"),
|
|
3727
|
-
action("members.view", "See members", "查看成员", "檢視成員", "メンバーを確認"),
|
|
3728
|
-
action("members.invite", "Invite people", "邀请别人", "邀請別人", "メンバーを招待"),
|
|
3729
|
-
action("members.approve", "Answer requests", "处理申请", "處理申請", "リクエストに対応"),
|
|
3730
|
-
action("members.roles", "Change roles and members", "管理角色和成员", "管理角色和成員", "ロールとメンバーを管理"),
|
|
3731
|
-
action("audit.view", "See the record", "查看记录", "檢視記錄", "レコードを確認")
|
|
3732
|
-
];
|
|
3733
|
-
var TA_OWNER_ACTIONS = [
|
|
3734
|
-
action("desktop.view", "See remote desktops", "查看远程桌面", "檢視遠端桌面", "リモートデスクトップを見る", { risky: true }),
|
|
3735
|
-
action("desktop.control", "Work remote desktops", "操作远程桌面", "操作遠端桌面", "リモートデスクトップを操作", { risky: true })
|
|
3736
|
-
];
|
|
3737
|
-
var OWNER_AREAS = ["desktop"];
|
|
3738
|
-
var TaActionUtil;
|
|
3739
|
-
(function(TaActionUtil2) {
|
|
3740
|
-
const byId = new Map(TA_ACTIONS.map((one) => [one.id, one]));
|
|
3741
|
-
const titled = new Map([...TA_ACTIONS, ...TA_OWNER_ACTIONS].map((one) => [one.id, one]));
|
|
3742
|
-
function info(id) {
|
|
3743
|
-
return byId.get(id);
|
|
3744
|
-
}
|
|
3745
|
-
TaActionUtil2.info = info;
|
|
3746
|
-
function title(id, language) {
|
|
3747
|
-
var _a;
|
|
3748
|
-
var _b, _c;
|
|
3749
|
-
const title2 = (_a = titled.get(id)) === null || _a === undefined ? undefined : _a.title;
|
|
3750
|
-
if (!title2) {
|
|
3751
|
-
return id;
|
|
3752
|
-
}
|
|
3753
|
-
return TaLanguageUtil.pick(language, {
|
|
3754
|
-
"zh-CN": title2["zh-CN"],
|
|
3755
|
-
"zh-TW": (_b = title2["zh-TW"]) !== null && _b !== undefined ? _b : title2["zh-CN"],
|
|
3756
|
-
"en-US": title2.en,
|
|
3757
|
-
"ja-JP": (_c = title2["ja-JP"]) !== null && _c !== undefined ? _c : title2.en
|
|
3758
|
-
});
|
|
3759
|
-
}
|
|
3760
|
-
TaActionUtil2.title = title;
|
|
3761
|
-
function grantable(id) {
|
|
3762
|
-
const info2 = byId.get(id);
|
|
3763
|
-
return !!info2 && !OWNER_AREAS.includes(info2.area);
|
|
3764
|
-
}
|
|
3765
|
-
TaActionUtil2.grantable = grantable;
|
|
3766
|
-
function inRoles(id) {
|
|
3767
|
-
var _a;
|
|
3768
|
-
return grantable(id) && ((_a = byId.get(id)) === null || _a === undefined ? undefined : _a.grant) !== "single";
|
|
3769
|
-
}
|
|
3770
|
-
TaActionUtil2.inRoles = inRoles;
|
|
3771
|
-
function inside(dir, path) {
|
|
3772
|
-
const base = dir.replace(/\/+$/, "");
|
|
3773
|
-
return path === base || path.startsWith(`${base}/`) || base === "";
|
|
3818
|
+
"aria-pressed": limits[key] === value,
|
|
3819
|
+
className: limits[key] === value ? "ta-on" : "",
|
|
3820
|
+
onClick: () => pick(value)
|
|
3821
|
+
}, amount(pi, value))));
|
|
3822
|
+
};
|
|
3823
|
+
function Spent() {
|
|
3824
|
+
const { spent } = useLimits(pi);
|
|
3825
|
+
return /* @__PURE__ */ React.createElement("span", {
|
|
3826
|
+
className: "tac-limit-spent"
|
|
3827
|
+
}, spent > 0 ? amount(pi, spent) : "0");
|
|
3774
3828
|
}
|
|
3775
|
-
|
|
3776
|
-
|
|
3829
|
+
return {
|
|
3830
|
+
title: () => words().limitsTitle,
|
|
3831
|
+
icon: pi.ui.icons.Coins ?? pi.ui.icons.Gauge,
|
|
3832
|
+
group: "ta",
|
|
3833
|
+
rows: [
|
|
3834
|
+
{ key: "answer", label: () => words().limitAnswer, description: () => words().limitAnswerHint, render: row("answer") },
|
|
3835
|
+
{ key: "channelDay", label: () => words().limitChannelDay, description: () => words().limitChannelDayHint, render: row("channelDay") },
|
|
3836
|
+
{ key: "allDay", label: () => words().limitAllDay, description: () => words().limitAllDayHint, render: row("allDay") },
|
|
3837
|
+
{ key: "spent", label: () => words().limitSpent, render: Spent }
|
|
3838
|
+
]
|
|
3839
|
+
};
|
|
3840
|
+
}
|
|
3777
3841
|
|
|
3778
3842
|
// ../ta-protocol/esm/common/said-protocol.js
|
|
3779
3843
|
var TaSaid;
|
|
@@ -4055,12 +4119,13 @@ var ChannelsText;
|
|
|
4055
4119
|
"You work with the user, Ta and other agents in channels. A message for you starts with a <context> block: the channel, its members, the recent messages and who speaks to you; answer what follows the block.",
|
|
4056
4120
|
"Do the part of the work your role covers with your tools, then answer: your answer is posted to the channel as it is.",
|
|
4057
4121
|
"To hand work to another member, write @ and their name in your answer; name nobody when the work is done or you need the user.",
|
|
4122
|
+
"Name a member only when you need their part, not to thank them or agree: each answer spends what the user allows the channel before they look in. Once the members agree or the work is done, name nobody; the lead sums up for the user.",
|
|
4058
4123
|
NOTICE_RULE
|
|
4059
4124
|
].join(`
|
|
4060
4125
|
`);
|
|
4061
4126
|
}
|
|
4062
4127
|
ChannelsText.systemPrompt = systemPrompt;
|
|
4063
|
-
function prompt(team, channel, history, message, agent) {
|
|
4128
|
+
function prompt(team, channel, history, message, agent, options = {}) {
|
|
4064
4129
|
const labels = { user: "user", ta: "Ta" };
|
|
4065
4130
|
const members = channel.members.map((id) => team.agents.find((other) => other.id === id)).filter((other) => !!other).map((other) => `@${other.name}${other.id === agent.id ? " (you)" : ""}: ${firstLine(other.role)}`);
|
|
4066
4131
|
const before = history.filter((item) => item.id !== message.id && !item.failed && !item.notice).slice(-CONTEXT_MESSAGES);
|
|
@@ -4071,6 +4136,9 @@ var ChannelsText;
|
|
|
4071
4136
|
if (before.length > 0) {
|
|
4072
4137
|
lines.push("", "Recent messages:", ...before.map((item) => `${authorName(team, item.author, labels)}: ${item.text}`));
|
|
4073
4138
|
}
|
|
4139
|
+
if (options.closing) {
|
|
4140
|
+
lines.push("", CLOSING_NOTE);
|
|
4141
|
+
}
|
|
4074
4142
|
lines.push("", `${authorName(team, message.author, labels)} to you:`);
|
|
4075
4143
|
const speaker = message.author === USER ? "" : ` · ${authorName(team, message.author, labels)}`;
|
|
4076
4144
|
lines.push(TaMessageSource.line(NAME, `#${channel.name}${speaker}`));
|
|
@@ -4135,833 +4203,1071 @@ var ChannelsText;
|
|
|
4135
4203
|
`)[0];
|
|
4136
4204
|
}
|
|
4137
4205
|
})(ChannelsText ||= {});
|
|
4206
|
+
var CLOSING_NOTE = "This discussion has spent most of what the user allows it before they look in: conclude now. Hand on only if the work cannot go on without that member; the lead sums up what was concluded and what the user is to decide.";
|
|
4138
4207
|
var NOTICE_RULE = [
|
|
4139
4208
|
"A channel may have a notice, in the <context> block: what its members decided, agreed and are to do. Follow it.",
|
|
4140
4209
|
`When the talk settles a decision or a convention, or adds, assigns or finishes a to-do, update it with update_channel_notice: the whole notice, short, under the headings ### ${NOTICE_HEADINGS.zh.join(" / ")} (### ${NOTICE_HEADINGS.en.join(" / ")} in English), in the language of the channel, to-dos as - [ ] or - [x] with who does them. The lead keeps it most; leave it for small talk.`
|
|
4141
4210
|
].join(`
|
|
4142
4211
|
`);
|
|
4143
4212
|
|
|
4144
|
-
// web-src/
|
|
4145
|
-
var
|
|
4146
|
-
(
|
|
4147
|
-
const
|
|
4148
|
-
|
|
4149
|
-
|
|
4150
|
-
|
|
4151
|
-
|
|
4152
|
-
|
|
4153
|
-
|
|
4154
|
-
|
|
4155
|
-
|
|
4156
|
-
|
|
4157
|
-
|
|
4158
|
-
|
|
4159
|
-
|
|
4160
|
-
|
|
4161
|
-
|
|
4162
|
-
|
|
4163
|
-
|
|
4164
|
-
|
|
4165
|
-
|
|
4166
|
-
|
|
4167
|
-
|
|
4168
|
-
|
|
4169
|
-
|
|
4170
|
-
|
|
4171
|
-
|
|
4172
|
-
|
|
4173
|
-
|
|
4174
|
-
}
|
|
4213
|
+
// web-src/more-menu.tsx
|
|
4214
|
+
var MARGIN = 8;
|
|
4215
|
+
function MoreMenu({ pi, label, items }) {
|
|
4216
|
+
const w = ChannelViews.words(pi);
|
|
4217
|
+
const [open, setOpen] = React.useState(false);
|
|
4218
|
+
const anchor = React.useRef({
|
|
4219
|
+
right: 0,
|
|
4220
|
+
below: 0,
|
|
4221
|
+
above: 0,
|
|
4222
|
+
finger: undefined
|
|
4223
|
+
});
|
|
4224
|
+
const root = React.useRef(null);
|
|
4225
|
+
const menu = React.useRef(null);
|
|
4226
|
+
const Ellipsis = ChannelViews.icon(pi, "Ellipsis");
|
|
4227
|
+
const show = React.useCallback((button, at) => {
|
|
4228
|
+
const box = button.getBoundingClientRect();
|
|
4229
|
+
const touch = document.documentElement.hasAttribute("data-touch");
|
|
4230
|
+
const row = root.current?.parentElement?.getBoundingClientRect() ?? box;
|
|
4231
|
+
anchor.current = {
|
|
4232
|
+
right: box.right,
|
|
4233
|
+
below: at?.y ?? box.bottom,
|
|
4234
|
+
above: at?.y ?? box.top,
|
|
4235
|
+
finger: touch && at ? { ...at, around: { top: row.top, bottom: row.bottom } } : undefined
|
|
4236
|
+
};
|
|
4237
|
+
setOpen(true);
|
|
4238
|
+
}, []);
|
|
4239
|
+
React.useLayoutEffect(() => {
|
|
4240
|
+
const element = menu.current;
|
|
4241
|
+
if (!open || !element) {
|
|
4242
|
+
return;
|
|
4175
4243
|
}
|
|
4176
|
-
|
|
4177
|
-
|
|
4178
|
-
|
|
4179
|
-
function firstLine(text) {
|
|
4180
|
-
for (const line of text.split(/\r?\n/)) {
|
|
4181
|
-
const item = /^\s*(?:[-*+]|\d+[.)])\s+(?:\[[ xX]\]\s+)?(.+)$/.exec(line);
|
|
4182
|
-
if (item) {
|
|
4183
|
-
return item[1].replace(/[*_`~]+/g, "").trim();
|
|
4184
|
-
}
|
|
4244
|
+
const { right, below, above, finger } = anchor.current;
|
|
4245
|
+
if (finger) {
|
|
4246
|
+
return pi.ui.attachMenu(element, finger, () => setOpen(false));
|
|
4185
4247
|
}
|
|
4186
|
-
|
|
4187
|
-
|
|
4188
|
-
|
|
4189
|
-
|
|
4190
|
-
|
|
4191
|
-
|
|
4192
|
-
|
|
4193
|
-
|
|
4194
|
-
|
|
4195
|
-
|
|
4196
|
-
|
|
4197
|
-
NoticeView.display = display;
|
|
4198
|
-
function counts(text, language) {
|
|
4199
|
-
const w = ChannelWords.of(language);
|
|
4200
|
-
const counts2 = NoticeUtil.counts(text);
|
|
4201
|
-
if (counts2.decisions + counts2.conventions + counts2.todo === 0) {
|
|
4202
|
-
return NoticeUtil.firstLine(text);
|
|
4248
|
+
const width = element.offsetWidth;
|
|
4249
|
+
const height = element.offsetHeight;
|
|
4250
|
+
const top = below + 4 + height <= window.innerHeight - MARGIN ? below + 4 : Math.max(MARGIN, above - 4 - height);
|
|
4251
|
+
element.style.top = `${top}px`;
|
|
4252
|
+
element.style.left = `${Math.max(MARGIN, right - width)}px`;
|
|
4253
|
+
}, [open, pi]);
|
|
4254
|
+
React.useEffect(() => {
|
|
4255
|
+
const row = root.current?.parentElement;
|
|
4256
|
+
const button = root.current?.querySelector(".tac-action");
|
|
4257
|
+
if (!row || !button) {
|
|
4258
|
+
return;
|
|
4203
4259
|
}
|
|
4204
|
-
const
|
|
4205
|
-
|
|
4206
|
-
|
|
4207
|
-
|
|
4208
|
-
|
|
4209
|
-
|
|
4210
|
-
|
|
4211
|
-
channel,
|
|
4212
|
-
state,
|
|
4213
|
-
onState
|
|
4214
|
-
}) {
|
|
4215
|
-
const { pi, service } = context;
|
|
4216
|
-
const { team } = useChannels(service);
|
|
4217
|
-
const w = ChannelViews.words(pi);
|
|
4218
|
-
const notice = channel.notice;
|
|
4219
|
-
const [draft, setDraft] = React.useState("");
|
|
4220
|
-
const [busy, setBusy] = React.useState(false);
|
|
4221
|
-
const [error, setError] = React.useState();
|
|
4260
|
+
const onContextMenu = (event) => {
|
|
4261
|
+
event.preventDefault();
|
|
4262
|
+
show(button, event.clientX || event.clientY ? { x: event.clientX, y: event.clientY } : undefined);
|
|
4263
|
+
};
|
|
4264
|
+
row.addEventListener("contextmenu", onContextMenu);
|
|
4265
|
+
return () => row.removeEventListener("contextmenu", onContextMenu);
|
|
4266
|
+
}, [show]);
|
|
4222
4267
|
React.useEffect(() => {
|
|
4223
|
-
if (
|
|
4224
|
-
|
|
4225
|
-
setError(undefined);
|
|
4268
|
+
if (!open) {
|
|
4269
|
+
return;
|
|
4226
4270
|
}
|
|
4227
|
-
|
|
4228
|
-
|
|
4229
|
-
|
|
4230
|
-
|
|
4231
|
-
|
|
4232
|
-
|
|
4233
|
-
|
|
4234
|
-
|
|
4235
|
-
|
|
4236
|
-
|
|
4237
|
-
|
|
4238
|
-
|
|
4239
|
-
|
|
4240
|
-
|
|
4241
|
-
|
|
4242
|
-
|
|
4243
|
-
|
|
4244
|
-
});
|
|
4245
|
-
};
|
|
4246
|
-
const open = state.open || state.editing;
|
|
4271
|
+
const close = (event) => {
|
|
4272
|
+
if (!root.current?.contains(event.target)) {
|
|
4273
|
+
setOpen(false);
|
|
4274
|
+
}
|
|
4275
|
+
};
|
|
4276
|
+
const onKey = (event) => {
|
|
4277
|
+
if (event.key === "Escape") {
|
|
4278
|
+
setOpen(false);
|
|
4279
|
+
}
|
|
4280
|
+
};
|
|
4281
|
+
document.addEventListener("pointerdown", close);
|
|
4282
|
+
document.addEventListener("keydown", onKey);
|
|
4283
|
+
return () => {
|
|
4284
|
+
document.removeEventListener("pointerdown", close);
|
|
4285
|
+
document.removeEventListener("keydown", onKey);
|
|
4286
|
+
};
|
|
4287
|
+
}, [open]);
|
|
4247
4288
|
return /* @__PURE__ */ React.createElement("div", {
|
|
4248
|
-
className: "tac-
|
|
4249
|
-
|
|
4289
|
+
className: "tac-item-more",
|
|
4290
|
+
ref: root
|
|
4250
4291
|
}, /* @__PURE__ */ React.createElement("button", {
|
|
4251
4292
|
type: "button",
|
|
4252
|
-
className: "tac-
|
|
4293
|
+
className: `tac-action${open ? " tac-on" : ""}`,
|
|
4294
|
+
title: w.more,
|
|
4295
|
+
"aria-label": w.more,
|
|
4296
|
+
"aria-haspopup": "menu",
|
|
4253
4297
|
"aria-expanded": open,
|
|
4254
|
-
|
|
4255
|
-
|
|
4256
|
-
|
|
4257
|
-
|
|
4258
|
-
|
|
4259
|
-
|
|
4260
|
-
|
|
4261
|
-
|
|
4262
|
-
|
|
4263
|
-
}, notice ? NoticeView.counts(notice.text, pi.ui.language) : w.noticeEmpty), /* @__PURE__ */ React.createElement("span", {
|
|
4264
|
-
className: "tac-notice-chevron"
|
|
4265
|
-
}, /* @__PURE__ */ React.createElement(Chevron, {
|
|
4298
|
+
onClick: (event) => {
|
|
4299
|
+
event.stopPropagation();
|
|
4300
|
+
if (open) {
|
|
4301
|
+
setOpen(false);
|
|
4302
|
+
} else {
|
|
4303
|
+
show(event.currentTarget);
|
|
4304
|
+
}
|
|
4305
|
+
}
|
|
4306
|
+
}, /* @__PURE__ */ React.createElement(Ellipsis, {
|
|
4266
4307
|
size: 15
|
|
4267
|
-
}))
|
|
4268
|
-
|
|
4269
|
-
|
|
4270
|
-
|
|
4271
|
-
|
|
4272
|
-
|
|
4273
|
-
|
|
4274
|
-
|
|
4275
|
-
|
|
4276
|
-
|
|
4277
|
-
|
|
4278
|
-
})), /* @__PURE__ */ React.createElement("button", {
|
|
4279
|
-
type: "button",
|
|
4280
|
-
className: "tac-button tac-quiet",
|
|
4281
|
-
onClick: () => onState({ open: true, editing: true })
|
|
4282
|
-
}, w.noticeEdit))), state.editing && /* @__PURE__ */ React.createElement("form", {
|
|
4283
|
-
className: "tac-notice-body tac-notice-form",
|
|
4284
|
-
onSubmit: save
|
|
4285
|
-
}, /* @__PURE__ */ React.createElement("p", {
|
|
4286
|
-
className: "tac-dialog-note"
|
|
4287
|
-
}, w.noticeHint), /* @__PURE__ */ React.createElement("textarea", {
|
|
4288
|
-
className: "tac-input tac-notice-input",
|
|
4289
|
-
value: draft,
|
|
4290
|
-
"aria-label": w.noticeEdit,
|
|
4291
|
-
autoFocus: true,
|
|
4292
|
-
onChange: (event) => setDraft(event.target.value)
|
|
4293
|
-
}), error && /* @__PURE__ */ React.createElement("div", {
|
|
4294
|
-
className: "tac-error"
|
|
4295
|
-
}, error), /* @__PURE__ */ React.createElement("div", {
|
|
4296
|
-
className: "tac-notice-actions"
|
|
4297
|
-
}, /* @__PURE__ */ React.createElement("button", {
|
|
4308
|
+
})), open && /* @__PURE__ */ React.createElement("div", {
|
|
4309
|
+
ref: menu,
|
|
4310
|
+
className: "tac-menu tac-agent-menu",
|
|
4311
|
+
role: "menu",
|
|
4312
|
+
"aria-label": label
|
|
4313
|
+
}, items().filter((section) => section.length > 0).map((section, index) => /* @__PURE__ */ React.createElement(React.Fragment, {
|
|
4314
|
+
key: section[0]?.key ?? index
|
|
4315
|
+
}, index > 0 && /* @__PURE__ */ React.createElement("hr", {
|
|
4316
|
+
className: "tac-menu-line"
|
|
4317
|
+
}), section.map((item) => /* @__PURE__ */ React.createElement("button", {
|
|
4318
|
+
key: item.key,
|
|
4298
4319
|
type: "button",
|
|
4299
|
-
|
|
4300
|
-
|
|
4301
|
-
|
|
4302
|
-
|
|
4303
|
-
|
|
4304
|
-
|
|
4305
|
-
|
|
4306
|
-
|
|
4307
|
-
|
|
4320
|
+
role: "menuitem",
|
|
4321
|
+
className: item.danger ? "tac-danger" : undefined,
|
|
4322
|
+
disabled: item.disabled,
|
|
4323
|
+
onClick: () => {
|
|
4324
|
+
setOpen(false);
|
|
4325
|
+
item.run();
|
|
4326
|
+
}
|
|
4327
|
+
}, item.icon, /* @__PURE__ */ React.createElement("span", {
|
|
4328
|
+
className: "tac-menu-label"
|
|
4329
|
+
}, item.label)))))));
|
|
4308
4330
|
}
|
|
4309
4331
|
|
|
4310
|
-
// web-src/
|
|
4311
|
-
|
|
4312
|
-
|
|
4313
|
-
|
|
4314
|
-
|
|
4315
|
-
|
|
4316
|
-
return
|
|
4317
|
-
const before = messages[index - 1];
|
|
4318
|
-
const separator = !before || message.at - before.at > PAUSE_MS;
|
|
4319
|
-
const first = separator || before.author !== message.author || before.by !== message.by || before.author === SYSTEM || !!before.notice || message.at - before.at > RUN_MS;
|
|
4320
|
-
return { message, first, separator };
|
|
4321
|
-
});
|
|
4332
|
+
// web-src/agent-menu.tsx
|
|
4333
|
+
async function copy(text) {
|
|
4334
|
+
try {
|
|
4335
|
+
await navigator.clipboard.writeText(text);
|
|
4336
|
+
return true;
|
|
4337
|
+
} catch {
|
|
4338
|
+
return false;
|
|
4322
4339
|
}
|
|
4323
|
-
RoomUtil.rows = rows;
|
|
4324
|
-
})(RoomUtil ||= {});
|
|
4325
|
-
function Mentions({ text, agents }) {
|
|
4326
|
-
const names = new Set(agents.map((agent) => agent.name.toLowerCase()));
|
|
4327
|
-
const parts = text.split(/(@[^\s@#,,。::]+)/);
|
|
4328
|
-
return /* @__PURE__ */ React.createElement("span", null, parts.map((part, index) => part.startsWith("@") && names.has(part.slice(1).toLowerCase()) ? /* @__PURE__ */ React.createElement("span", {
|
|
4329
|
-
key: index,
|
|
4330
|
-
className: "tac-mention"
|
|
4331
|
-
}, part) : part));
|
|
4332
4340
|
}
|
|
4333
|
-
function
|
|
4334
|
-
const
|
|
4335
|
-
const
|
|
4336
|
-
|
|
4337
|
-
|
|
4338
|
-
|
|
4339
|
-
|
|
4340
|
-
const channel = state.team.channels.find((candidate) => candidate.id === channelId);
|
|
4341
|
-
if (!channel) {
|
|
4342
|
-
return null;
|
|
4343
|
-
}
|
|
4344
|
-
const members = membersOf(state.team, channel);
|
|
4345
|
-
const working = state.working[channel.id] ?? [];
|
|
4346
|
-
return /* @__PURE__ */ React.createElement("div", {
|
|
4347
|
-
className: "tac-head"
|
|
4348
|
-
}, /* @__PURE__ */ React.createElement("div", {
|
|
4349
|
-
className: "tac-head-title"
|
|
4350
|
-
}, /* @__PURE__ */ React.createElement("strong", null, channel.name), /* @__PURE__ */ React.createElement("span", {
|
|
4351
|
-
className: "tac-head-count"
|
|
4352
|
-
}, ChannelWords.format(w.memberCount, { count: String(members.length) })), channel.topic && /* @__PURE__ */ React.createElement("span", {
|
|
4353
|
-
className: "tac-head-topic"
|
|
4354
|
-
}, channel.topic)), /* @__PURE__ */ React.createElement("button", {
|
|
4355
|
-
type: "button",
|
|
4356
|
-
className: `tac-head-members${shown ? " tac-on" : ""}`,
|
|
4357
|
-
title: w.showMembers,
|
|
4358
|
-
"aria-label": w.showMembers,
|
|
4359
|
-
"aria-pressed": shown,
|
|
4360
|
-
onClick: () => context.showMembers()
|
|
4361
|
-
}, members.slice(0, 5).map((agent) => /* @__PURE__ */ React.createElement("span", {
|
|
4362
|
-
key: agent.id,
|
|
4363
|
-
className: "tac-head-face"
|
|
4364
|
-
}, /* @__PURE__ */ React.createElement(AgentAvatar, {
|
|
4365
|
-
agent,
|
|
4366
|
-
faces,
|
|
4367
|
-
size: 24,
|
|
4368
|
-
working: working.includes(agent.id)
|
|
4369
|
-
}))), members.length > 5 && /* @__PURE__ */ React.createElement("span", {
|
|
4370
|
-
className: "tac-head-more"
|
|
4371
|
-
}, "+", members.length - 5)));
|
|
4341
|
+
function download(name, text) {
|
|
4342
|
+
const url = URL.createObjectURL(new Blob([text], { type: "text/markdown;charset=utf-8" }));
|
|
4343
|
+
const link = document.createElement("a");
|
|
4344
|
+
link.href = url;
|
|
4345
|
+
link.download = name;
|
|
4346
|
+
link.click();
|
|
4347
|
+
setTimeout(() => URL.revokeObjectURL(url), 1000);
|
|
4372
4348
|
}
|
|
4373
|
-
function
|
|
4374
|
-
const
|
|
4375
|
-
const
|
|
4376
|
-
|
|
4377
|
-
|
|
4378
|
-
|
|
4379
|
-
if (
|
|
4380
|
-
|
|
4349
|
+
async function deleteAgent(context, agent) {
|
|
4350
|
+
const w = ChannelViews.words(context.pi);
|
|
4351
|
+
const sure = await context.pi.ui.confirm(ChannelWords.format(w.confirmDeleteAgent, { name: agent.name }), undefined, {
|
|
4352
|
+
confirmLabel: w.delete,
|
|
4353
|
+
danger: true
|
|
4354
|
+
});
|
|
4355
|
+
if (sure) {
|
|
4356
|
+
await context.service.deleteAgent(agent.id);
|
|
4357
|
+
context.sessions.delete(agent.id);
|
|
4381
4358
|
}
|
|
4382
|
-
const members = membersOf(state.team, channel);
|
|
4383
|
-
const working = state.working[channel.id] ?? [];
|
|
4384
|
-
const External = ChannelViews.icon(pi, "ExternalLink");
|
|
4385
|
-
return /* @__PURE__ */ React.createElement("div", {
|
|
4386
|
-
className: "tac-scene-head"
|
|
4387
|
-
}, /* @__PURE__ */ React.createElement(RoomFace, {
|
|
4388
|
-
members,
|
|
4389
|
-
faces,
|
|
4390
|
-
size: 26,
|
|
4391
|
-
working
|
|
4392
|
-
}), /* @__PURE__ */ React.createElement("div", {
|
|
4393
|
-
className: "tac-scene-title"
|
|
4394
|
-
}, /* @__PURE__ */ React.createElement("strong", null, channel.name), /* @__PURE__ */ React.createElement("span", null, channel.topic ?? ChannelWords.format(w.memberCount, { count: String(members.length) }))), /* @__PURE__ */ React.createElement("button", {
|
|
4395
|
-
type: "button",
|
|
4396
|
-
className: "tac-button tac-scene-main",
|
|
4397
|
-
title: w.openInMainHint,
|
|
4398
|
-
onClick: () => context.showChannel(channel.id)
|
|
4399
|
-
}, /* @__PURE__ */ React.createElement(External, {
|
|
4400
|
-
size: 13
|
|
4401
|
-
}), w.openInMain));
|
|
4402
|
-
}
|
|
4403
|
-
var mePromise;
|
|
4404
|
-
function useMe(pi) {
|
|
4405
|
-
const [me, setMe] = React.useState(TA_OWNER);
|
|
4406
|
-
React.useEffect(() => {
|
|
4407
|
-
mePromise ??= pi.server.getServerInfo().then((info) => info.member?.id ?? TA_OWNER, () => TA_OWNER);
|
|
4408
|
-
let live = true;
|
|
4409
|
-
mePromise.then((id) => live && setMe(id));
|
|
4410
|
-
return () => {
|
|
4411
|
-
live = false;
|
|
4412
|
-
};
|
|
4413
|
-
}, [pi]);
|
|
4414
|
-
return me;
|
|
4415
4359
|
}
|
|
4416
|
-
function
|
|
4417
|
-
const { pi, service
|
|
4418
|
-
const me = useMe(pi);
|
|
4419
|
-
const state = useChannels(service);
|
|
4420
|
-
const shown = useUi(ui).channelId;
|
|
4421
|
-
const channelId = fixed ?? shown;
|
|
4422
|
-
const faces = useFaces(state.team);
|
|
4360
|
+
function AgentMenu({ context, agent, cwd, working }) {
|
|
4361
|
+
const { pi, service } = context;
|
|
4423
4362
|
const w = ChannelViews.words(pi);
|
|
4424
|
-
const
|
|
4425
|
-
const
|
|
4426
|
-
const
|
|
4427
|
-
|
|
4428
|
-
|
|
4429
|
-
|
|
4363
|
+
const [dialog, setDialog] = React.useState();
|
|
4364
|
+
const icon = (name) => ChannelViews.maybeIcon(pi, name, null, 15);
|
|
4365
|
+
const fail = (error) => pi.ui.notify(ChannelViews.message(error), "error");
|
|
4366
|
+
const act = (action) => () => {
|
|
4367
|
+
Promise.resolve().then(action).catch(fail);
|
|
4368
|
+
};
|
|
4369
|
+
const openSession = async () => {
|
|
4370
|
+
if (!agent.sessionFile) {
|
|
4371
|
+
return;
|
|
4430
4372
|
}
|
|
4431
|
-
|
|
4432
|
-
|
|
4433
|
-
const
|
|
4434
|
-
|
|
4435
|
-
|
|
4436
|
-
|
|
4437
|
-
|
|
4438
|
-
|
|
4439
|
-
if (!channel) {
|
|
4440
|
-
return /* @__PURE__ */ React.createElement("div", {
|
|
4441
|
-
className: "tac-room-page"
|
|
4442
|
-
}, state.loaded && /* @__PURE__ */ React.createElement(pi.ui.Empty, {
|
|
4443
|
-
title: w.pick
|
|
4444
|
-
}));
|
|
4445
|
-
}
|
|
4446
|
-
const members = membersOf(state.team, channel);
|
|
4447
|
-
const agentOf = (id) => state.team.agents.find((agent) => agent.id === id);
|
|
4448
|
-
const name = (id) => ChannelsText.authorName(state.team, id, { user: w.you, ta: w.ta });
|
|
4449
|
-
const time = (at) => SidebarUtil.time(at, pi.ui.language);
|
|
4450
|
-
const mention = (agent) => ({
|
|
4451
|
-
key: agent.id,
|
|
4452
|
-
label: agent.name,
|
|
4453
|
-
icon: /* @__PURE__ */ React.createElement(AgentAvatar, {
|
|
4454
|
-
agent,
|
|
4455
|
-
faces,
|
|
4456
|
-
size: 20
|
|
4457
|
-
}),
|
|
4458
|
-
detail: agent.id === channel.members[0] ? w.lead : undefined,
|
|
4459
|
-
insert: `@${agent.name} `
|
|
4373
|
+
return (await pi.server.listSessions()).find((session) => session.sessionFile === agent.sessionFile);
|
|
4374
|
+
};
|
|
4375
|
+
const stop = act(async () => {
|
|
4376
|
+
const session = await openSession();
|
|
4377
|
+
if (session) {
|
|
4378
|
+
await pi.server.abort(session.sessionId);
|
|
4379
|
+
}
|
|
4380
|
+
pi.ui.notify(ChannelWords.format(w.stoppedAgent, { name: agent.name }), "info");
|
|
4460
4381
|
});
|
|
4461
|
-
|
|
4462
|
-
|
|
4463
|
-
|
|
4382
|
+
const restart = act(async () => {
|
|
4383
|
+
await service.resetAgent(agent.id);
|
|
4384
|
+
context.sessions.delete(agent.id);
|
|
4385
|
+
pi.ui.notify(ChannelWords.format(w.resetDone, { name: agent.name }), "info");
|
|
4386
|
+
});
|
|
4387
|
+
const copyCwd = act(async () => {
|
|
4388
|
+
if (await copy(cwd)) {
|
|
4389
|
+
pi.ui.notify(ChannelWords.format(w.copied, { path: cwd }), "info");
|
|
4390
|
+
}
|
|
4391
|
+
});
|
|
4392
|
+
const exportMarkdown = act(async () => {
|
|
4393
|
+
const session = await openSession();
|
|
4394
|
+
const sessionId = session?.sessionId ?? (agent.sessionFile ? await service.openAgent(agent.id) : undefined);
|
|
4395
|
+
const { messages } = sessionId ? await pi.server.getMessages(sessionId) : { messages: [] };
|
|
4396
|
+
if (!messages.some((message) => message.role === "assistant")) {
|
|
4397
|
+
pi.ui.notify(ChannelWords.format(w.nothingToExport, { name: agent.name }), "info");
|
|
4398
|
+
return;
|
|
4399
|
+
}
|
|
4400
|
+
download(`${agent.name}.md`, ChannelsText.markdown(agent, messages, { user: w.you }));
|
|
4401
|
+
});
|
|
4402
|
+
const remove = act(() => deleteAgent(context, agent));
|
|
4403
|
+
const pin = act(() => service.updateAgent(agent.id, { pinned: !agent.pinned }));
|
|
4404
|
+
const keep = act(async () => {
|
|
4405
|
+
await service.updateAgent(agent.id, { keep: true });
|
|
4406
|
+
pi.ui.notify(ChannelWords.format(w.kept, { name: agent.name }), "info");
|
|
4407
|
+
});
|
|
4408
|
+
const show = (next) => () => setDialog(next);
|
|
4409
|
+
const item = (key, label, glyph, run, options = {}) => ({
|
|
4410
|
+
key,
|
|
4411
|
+
label,
|
|
4412
|
+
icon: icon(glyph),
|
|
4413
|
+
run,
|
|
4414
|
+
...options
|
|
4415
|
+
});
|
|
4416
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(MoreMenu, {
|
|
4417
|
+
pi,
|
|
4418
|
+
label: agent.name,
|
|
4419
|
+
items: () => [
|
|
4420
|
+
[
|
|
4421
|
+
...agent.temporary ? [item("keep", w.keep, "UserPlus", keep)] : [],
|
|
4422
|
+
item("pin", agent.pinned ? w.unpin : w.pin, agent.pinned ? "PinOff" : "Pin", pin)
|
|
4423
|
+
],
|
|
4424
|
+
[item("stop", w.stop, "Square", stop, { disabled: !working && !agent.sessionFile }), item("restart", w.restart, "RotateCcw", restart)],
|
|
4425
|
+
[
|
|
4426
|
+
item("settings", w.agentSettings, "SlidersHorizontal", show("settings")),
|
|
4427
|
+
item("rename", w.rename, "Pencil", show("rename")),
|
|
4428
|
+
item("role", w.editRole, "ScrollText", show("role")),
|
|
4429
|
+
item("move", w.moveTo, "FolderInput", show("move")),
|
|
4430
|
+
item("copy", w.copyCwd, "Copy", copyCwd)
|
|
4431
|
+
],
|
|
4432
|
+
[
|
|
4433
|
+
item("card", w.shareCard, "Contact", show("card")),
|
|
4434
|
+
item("export", w.exportChat, "Download", exportMarkdown),
|
|
4435
|
+
item("join", w.joinChannel, "UserPlus", show("join"))
|
|
4436
|
+
],
|
|
4437
|
+
[item("delete", w.deleteAgent, "Trash2", remove, { danger: true })]
|
|
4438
|
+
]
|
|
4439
|
+
}), dialog === "settings" && /* @__PURE__ */ React.createElement(AgentSettingsDialog, {
|
|
4464
4440
|
context,
|
|
4465
|
-
|
|
4466
|
-
|
|
4467
|
-
|
|
4468
|
-
|
|
4469
|
-
|
|
4470
|
-
|
|
4471
|
-
}, /* @__PURE__ */ React.createElement(
|
|
4472
|
-
|
|
4473
|
-
|
|
4474
|
-
|
|
4475
|
-
}, /* @__PURE__ */ React.createElement(
|
|
4476
|
-
|
|
4477
|
-
|
|
4478
|
-
|
|
4479
|
-
|
|
4480
|
-
|
|
4481
|
-
|
|
4482
|
-
|
|
4483
|
-
|
|
4484
|
-
|
|
4485
|
-
|
|
4486
|
-
|
|
4487
|
-
|
|
4488
|
-
|
|
4489
|
-
|
|
4490
|
-
|
|
4491
|
-
|
|
4492
|
-
|
|
4493
|
-
|
|
4494
|
-
}, ChannelWords.format(message.notice === "cleared" ? w.noticeCleared : w.noticeUpdated, { name: name(message.author) })) : message.author === USER && (message.by ?? TA_OWNER) !== me ? /* @__PURE__ */ React.createElement("div", {
|
|
4495
|
-
className: `tac-msg${first ? " tac-first" : ""}`
|
|
4496
|
-
}, /* @__PURE__ */ React.createElement("div", {
|
|
4497
|
-
className: "tac-msg-face"
|
|
4498
|
-
}, first && pi.ui.Face && /* @__PURE__ */ React.createElement(pi.ui.Face, {
|
|
4499
|
-
seed: message.by ?? TA_OWNER,
|
|
4500
|
-
double: (message.by ?? TA_OWNER) === TA_OWNER,
|
|
4501
|
-
size: 28
|
|
4502
|
-
})), /* @__PURE__ */ React.createElement("div", {
|
|
4503
|
-
className: "tac-msg-col"
|
|
4504
|
-
}, first && /* @__PURE__ */ React.createElement("div", {
|
|
4505
|
-
className: "tac-msg-name"
|
|
4506
|
-
}, message.byName ?? w.owner), /* @__PURE__ */ React.createElement("div", {
|
|
4507
|
-
className: "tac-msg-bubble",
|
|
4508
|
-
title: time(message.at)
|
|
4509
|
-
}, /* @__PURE__ */ React.createElement(Mentions, {
|
|
4510
|
-
text: message.text,
|
|
4511
|
-
agents: state.team.agents
|
|
4512
|
-
})))) : message.author === USER ? /* @__PURE__ */ React.createElement("div", {
|
|
4513
|
-
className: "ta-message ta-user tac-mine"
|
|
4514
|
-
}, /* @__PURE__ */ React.createElement("div", {
|
|
4515
|
-
className: "ta-bubble"
|
|
4516
|
-
}, /* @__PURE__ */ React.createElement(Mentions, {
|
|
4517
|
-
text: message.text,
|
|
4518
|
-
agents: state.team.agents
|
|
4519
|
-
}))) : /* @__PURE__ */ React.createElement("div", {
|
|
4520
|
-
className: `tac-msg${first ? " tac-first" : ""}`
|
|
4521
|
-
}, /* @__PURE__ */ React.createElement("div", {
|
|
4522
|
-
className: "tac-msg-face"
|
|
4523
|
-
}, first && (message.author === TA ? /* @__PURE__ */ React.createElement(Avatar, {
|
|
4524
|
-
size: 28
|
|
4525
|
-
}) : /* @__PURE__ */ React.createElement(AgentAvatar, {
|
|
4526
|
-
agent: agentOf(message.author),
|
|
4527
|
-
faces,
|
|
4528
|
-
size: 28,
|
|
4529
|
-
working: working.includes(message.author)
|
|
4530
|
-
}))), /* @__PURE__ */ React.createElement("div", {
|
|
4531
|
-
className: "tac-msg-col"
|
|
4532
|
-
}, first && /* @__PURE__ */ React.createElement("div", {
|
|
4533
|
-
className: "tac-msg-name"
|
|
4534
|
-
}, name(message.author), message.author === channel.members[0] && /* @__PURE__ */ React.createElement("span", {
|
|
4535
|
-
className: "tac-msg-lead"
|
|
4536
|
-
}, w.lead)), /* @__PURE__ */ React.createElement("div", {
|
|
4537
|
-
className: `tac-msg-bubble${message.failed ? " tac-failed" : ""}`,
|
|
4538
|
-
title: time(message.at)
|
|
4539
|
-
}, message.failed && /* @__PURE__ */ React.createElement("div", {
|
|
4540
|
-
className: "tac-msg-failed"
|
|
4541
|
-
}, w.failed), /* @__PURE__ */ React.createElement(Markdown, {
|
|
4542
|
-
text: ChannelsText.markMentions(message.text, state.team.agents)
|
|
4543
|
-
})))))), working.length > 0 && /* @__PURE__ */ React.createElement("div", {
|
|
4544
|
-
className: "tac-live",
|
|
4545
|
-
role: "status"
|
|
4546
|
-
}, /* @__PURE__ */ React.createElement("span", {
|
|
4547
|
-
className: "tac-live-faces"
|
|
4548
|
-
}, working.map((id) => /* @__PURE__ */ React.createElement(Face, {
|
|
4549
|
-
key: id,
|
|
4550
|
-
face: faces.get(id) ?? 0,
|
|
4551
|
-
size: 18,
|
|
4552
|
-
working: true
|
|
4553
|
-
}))), ChannelWords.format(w.answeringNow, { name: working.map(name).join("、") })))), /* @__PURE__ */ React.createElement("div", {
|
|
4554
|
-
className: "tac-chat-bottom"
|
|
4555
|
-
}, /* @__PURE__ */ React.createElement(Composer, {
|
|
4556
|
-
placeholder: ChannelWords.format(w.placeholder, { channel: channel.name }),
|
|
4557
|
-
draft: channel.id,
|
|
4558
|
-
mentions: members.map((agent) => ({ name: agent.name, detail: agent.role.split(`
|
|
4559
|
-
`)[0] })),
|
|
4560
|
-
actions: [
|
|
4561
|
-
members.map(mention),
|
|
4562
|
-
[
|
|
4563
|
-
{
|
|
4564
|
-
key: "notice",
|
|
4565
|
-
label: w.noticeEdit,
|
|
4566
|
-
icon: ChannelViews.maybeIcon(pi, "Megaphone", null, 16),
|
|
4567
|
-
run: () => setNotice({ open: true, editing: true })
|
|
4568
|
-
},
|
|
4569
|
-
{
|
|
4570
|
-
key: "add",
|
|
4571
|
-
label: w.addMembers,
|
|
4572
|
-
icon: ChannelViews.maybeIcon(pi, "UserPlus", null, 16),
|
|
4573
|
-
run: () => {
|
|
4574
|
-
if (fixed) {
|
|
4575
|
-
ui.set({ channelId: fixed });
|
|
4576
|
-
}
|
|
4577
|
-
context.showMembers(true);
|
|
4578
|
-
}
|
|
4579
|
-
}
|
|
4580
|
-
],
|
|
4581
|
-
[
|
|
4582
|
-
{
|
|
4583
|
-
key: "make-extension",
|
|
4584
|
-
label: w.makeExtension,
|
|
4585
|
-
detail: w.makeExtensionDetail,
|
|
4586
|
-
icon: ChannelViews.maybeIcon(pi, "Sparkles", null, 16),
|
|
4587
|
-
run: () => void service.post(channel.id, w.makeExtensionAsk).catch((error) => pi.ui.notify(ChannelViews.message(error), "error"))
|
|
4588
|
-
}
|
|
4589
|
-
]
|
|
4590
|
-
],
|
|
4591
|
-
onSend: (text) => service.post(channel.id, text)
|
|
4592
|
-
})));
|
|
4441
|
+
agent,
|
|
4442
|
+
onClose: () => setDialog(undefined)
|
|
4443
|
+
}), dialog === "rename" && /* @__PURE__ */ React.createElement(RenameDialog, {
|
|
4444
|
+
context,
|
|
4445
|
+
agent,
|
|
4446
|
+
onClose: () => setDialog(undefined)
|
|
4447
|
+
}), dialog === "role" && /* @__PURE__ */ React.createElement(RoleDialog, {
|
|
4448
|
+
context,
|
|
4449
|
+
agent,
|
|
4450
|
+
onClose: () => setDialog(undefined)
|
|
4451
|
+
}), dialog === "join" && /* @__PURE__ */ React.createElement(JoinDialog, {
|
|
4452
|
+
context,
|
|
4453
|
+
agent,
|
|
4454
|
+
onClose: () => setDialog(undefined)
|
|
4455
|
+
}), dialog === "card" && /* @__PURE__ */ React.createElement(CardDialog, {
|
|
4456
|
+
context,
|
|
4457
|
+
agent,
|
|
4458
|
+
onClose: () => setDialog(undefined)
|
|
4459
|
+
}), dialog === "move" && /* @__PURE__ */ React.createElement(pi.ui.FolderPicker, {
|
|
4460
|
+
initial: cwd,
|
|
4461
|
+
onClose: () => setDialog(undefined),
|
|
4462
|
+
onPick: async (path) => {
|
|
4463
|
+
setDialog(undefined);
|
|
4464
|
+
if (path !== cwd) {
|
|
4465
|
+
await service.updateAgent(agent.id, { cwd: path }).catch(fail);
|
|
4466
|
+
context.sessions.delete(agent.id);
|
|
4467
|
+
}
|
|
4468
|
+
}
|
|
4469
|
+
}));
|
|
4593
4470
|
}
|
|
4594
|
-
|
|
4595
|
-
|
|
4596
|
-
|
|
4597
|
-
|
|
4471
|
+
function useSave(action, onClose) {
|
|
4472
|
+
const [busy, setBusy] = React.useState(false);
|
|
4473
|
+
const [error, setError] = React.useState();
|
|
4474
|
+
const submit = (event) => {
|
|
4475
|
+
event.preventDefault();
|
|
4476
|
+
setBusy(true);
|
|
4477
|
+
setError(undefined);
|
|
4478
|
+
action().then(onClose, (failure) => {
|
|
4479
|
+
setBusy(false);
|
|
4480
|
+
setError(ChannelViews.message(failure));
|
|
4481
|
+
});
|
|
4482
|
+
};
|
|
4483
|
+
return { busy, error, submit };
|
|
4484
|
+
}
|
|
4485
|
+
function AgentSettingsDialog({ context, agent, onClose }) {
|
|
4486
|
+
const { pi, service } = context;
|
|
4598
4487
|
const w = ChannelViews.words(pi);
|
|
4599
|
-
const [
|
|
4600
|
-
const
|
|
4601
|
-
|
|
4602
|
-
|
|
4603
|
-
|
|
4604
|
-
|
|
4605
|
-
|
|
4606
|
-
|
|
4607
|
-
const
|
|
4608
|
-
|
|
4609
|
-
|
|
4610
|
-
|
|
4611
|
-
|
|
4612
|
-
|
|
4613
|
-
|
|
4614
|
-
|
|
4615
|
-
|
|
4616
|
-
|
|
4617
|
-
|
|
4618
|
-
|
|
4619
|
-
|
|
4620
|
-
|
|
4621
|
-
React.
|
|
4622
|
-
|
|
4623
|
-
|
|
4624
|
-
|
|
4625
|
-
|
|
4626
|
-
|
|
4627
|
-
|
|
4628
|
-
|
|
4629
|
-
|
|
4630
|
-
|
|
4631
|
-
|
|
4632
|
-
|
|
4633
|
-
|
|
4634
|
-
|
|
4635
|
-
},
|
|
4636
|
-
|
|
4637
|
-
|
|
4638
|
-
|
|
4639
|
-
|
|
4640
|
-
|
|
4641
|
-
|
|
4642
|
-
|
|
4643
|
-
|
|
4644
|
-
|
|
4645
|
-
|
|
4646
|
-
|
|
4647
|
-
|
|
4648
|
-
|
|
4649
|
-
|
|
4650
|
-
|
|
4651
|
-
|
|
4488
|
+
const [name, setName] = React.useState(agent.name);
|
|
4489
|
+
const [model, setModel] = React.useState(agent.model ?? "");
|
|
4490
|
+
const [role, setRole] = React.useState(agent.role);
|
|
4491
|
+
const change = {
|
|
4492
|
+
...name.trim() !== agent.name ? { name } : {},
|
|
4493
|
+
...model !== (agent.model ?? "") ? { model } : {},
|
|
4494
|
+
...role.trim() !== agent.role ? { role } : {}
|
|
4495
|
+
};
|
|
4496
|
+
const { busy, error, submit } = useSave(() => service.updateAgent(agent.id, change), onClose);
|
|
4497
|
+
return /* @__PURE__ */ React.createElement(pi.ui.Dialog, {
|
|
4498
|
+
title: `${w.agentSettings} · ${agent.name}`,
|
|
4499
|
+
onClose
|
|
4500
|
+
}, /* @__PURE__ */ React.createElement("form", {
|
|
4501
|
+
className: "tac-dialog",
|
|
4502
|
+
onSubmit: submit
|
|
4503
|
+
}, /* @__PURE__ */ React.createElement("label", {
|
|
4504
|
+
className: "tac-dialog-label"
|
|
4505
|
+
}, w.name, /* @__PURE__ */ React.createElement("input", {
|
|
4506
|
+
className: "tac-input tac-dialog-input",
|
|
4507
|
+
value: name,
|
|
4508
|
+
maxLength: 32,
|
|
4509
|
+
onChange: (event) => setName(event.target.value)
|
|
4510
|
+
})), /* @__PURE__ */ React.createElement("div", {
|
|
4511
|
+
className: "tac-dialog-field"
|
|
4512
|
+
}, /* @__PURE__ */ React.createElement("span", null, w.model), /* @__PURE__ */ React.createElement(pi.ui.ModelPicker, {
|
|
4513
|
+
cwd: agent.cwd,
|
|
4514
|
+
value: model,
|
|
4515
|
+
label: w.model,
|
|
4516
|
+
onChange: setModel
|
|
4517
|
+
})), /* @__PURE__ */ React.createElement("label", {
|
|
4518
|
+
className: "tac-dialog-label"
|
|
4519
|
+
}, w.editRole, /* @__PURE__ */ React.createElement("textarea", {
|
|
4520
|
+
className: "tac-input tac-settings-role",
|
|
4521
|
+
value: role,
|
|
4522
|
+
placeholder: w.rolePlaceholder,
|
|
4523
|
+
onChange: (event) => setRole(event.target.value)
|
|
4524
|
+
})), /* @__PURE__ */ React.createElement("p", {
|
|
4525
|
+
className: "tac-dialog-note"
|
|
4526
|
+
}, w.agentSettingsHint), error && /* @__PURE__ */ React.createElement("div", {
|
|
4527
|
+
className: "tac-error"
|
|
4528
|
+
}, error), /* @__PURE__ */ React.createElement("div", {
|
|
4529
|
+
className: "tac-dialog-actions"
|
|
4530
|
+
}, /* @__PURE__ */ React.createElement("button", {
|
|
4531
|
+
type: "submit",
|
|
4532
|
+
className: busy ? "tac-button tac-primary ta-busy" : "tac-button tac-primary",
|
|
4533
|
+
disabled: busy || !name.trim() || !role.trim() || Object.keys(change).length === 0
|
|
4534
|
+
}, w.save, busy && /* @__PURE__ */ React.createElement("span", {
|
|
4535
|
+
className: "ta-spinner ta-busy-mark ta-on-brand"
|
|
4536
|
+
})))));
|
|
4537
|
+
}
|
|
4538
|
+
function RenameDialog({ context, agent, onClose }) {
|
|
4539
|
+
const { pi, service } = context;
|
|
4540
|
+
const w = ChannelViews.words(pi);
|
|
4541
|
+
const [name, setName] = React.useState(agent.name);
|
|
4542
|
+
const { busy, error, submit } = useSave(() => service.updateAgent(agent.id, { name }), onClose);
|
|
4543
|
+
return /* @__PURE__ */ React.createElement(pi.ui.Dialog, {
|
|
4544
|
+
title: w.rename,
|
|
4545
|
+
onClose
|
|
4546
|
+
}, /* @__PURE__ */ React.createElement("form", {
|
|
4547
|
+
className: "tac-dialog",
|
|
4548
|
+
onSubmit: submit
|
|
4549
|
+
}, /* @__PURE__ */ React.createElement("label", {
|
|
4550
|
+
className: "tac-dialog-label"
|
|
4551
|
+
}, w.name, /* @__PURE__ */ React.createElement("input", {
|
|
4552
|
+
className: "tac-input tac-dialog-input",
|
|
4553
|
+
value: name,
|
|
4554
|
+
maxLength: 32,
|
|
4555
|
+
autoFocus: true,
|
|
4556
|
+
onChange: (event) => setName(event.target.value)
|
|
4557
|
+
})), error && /* @__PURE__ */ React.createElement("div", {
|
|
4558
|
+
className: "tac-error"
|
|
4559
|
+
}, error), /* @__PURE__ */ React.createElement("div", {
|
|
4560
|
+
className: "tac-dialog-actions"
|
|
4561
|
+
}, /* @__PURE__ */ React.createElement("button", {
|
|
4562
|
+
type: "submit",
|
|
4563
|
+
className: busy ? "tac-button tac-primary ta-busy" : "tac-button tac-primary",
|
|
4564
|
+
disabled: busy || !name.trim() || name.trim() === agent.name
|
|
4565
|
+
}, w.save, busy && /* @__PURE__ */ React.createElement("span", {
|
|
4566
|
+
className: "ta-spinner ta-busy-mark ta-on-brand"
|
|
4567
|
+
})))));
|
|
4568
|
+
}
|
|
4569
|
+
function RoleDialog({ context, agent, onClose }) {
|
|
4570
|
+
const { pi, service } = context;
|
|
4571
|
+
const w = ChannelViews.words(pi);
|
|
4572
|
+
const [role, setRole] = React.useState(agent.role);
|
|
4573
|
+
const { busy, error, submit } = useSave(() => service.updateAgent(agent.id, { role }), onClose);
|
|
4574
|
+
return /* @__PURE__ */ React.createElement(pi.ui.Dialog, {
|
|
4575
|
+
title: `${w.editRole} · ${agent.name}`,
|
|
4576
|
+
onClose
|
|
4577
|
+
}, /* @__PURE__ */ React.createElement("form", {
|
|
4578
|
+
className: "tac-dialog",
|
|
4579
|
+
onSubmit: submit
|
|
4580
|
+
}, /* @__PURE__ */ React.createElement("p", {
|
|
4581
|
+
className: "tac-dialog-note"
|
|
4582
|
+
}, w.roleHint), /* @__PURE__ */ React.createElement("textarea", {
|
|
4583
|
+
className: "tac-input tac-role-input",
|
|
4584
|
+
value: role,
|
|
4585
|
+
placeholder: w.rolePlaceholder,
|
|
4586
|
+
"aria-label": w.editRole,
|
|
4587
|
+
autoFocus: true,
|
|
4588
|
+
onChange: (event) => setRole(event.target.value)
|
|
4589
|
+
}), error && /* @__PURE__ */ React.createElement("div", {
|
|
4590
|
+
className: "tac-error"
|
|
4591
|
+
}, error), /* @__PURE__ */ React.createElement("div", {
|
|
4592
|
+
className: "tac-dialog-actions"
|
|
4593
|
+
}, /* @__PURE__ */ React.createElement("button", {
|
|
4594
|
+
type: "submit",
|
|
4595
|
+
className: busy ? "tac-button tac-primary ta-busy" : "tac-button tac-primary",
|
|
4596
|
+
disabled: busy || !role.trim() || role.trim() === agent.role
|
|
4597
|
+
}, w.save, busy && /* @__PURE__ */ React.createElement("span", {
|
|
4598
|
+
className: "ta-spinner ta-busy-mark ta-on-brand"
|
|
4599
|
+
})))));
|
|
4600
|
+
}
|
|
4601
|
+
function JoinDialog({ context, agent, onClose }) {
|
|
4602
|
+
const { pi, service } = context;
|
|
4603
|
+
const { team } = useChannels(service);
|
|
4604
|
+
const w = ChannelViews.words(pi);
|
|
4605
|
+
const Hash = ChannelViews.icon(pi, "Hash");
|
|
4606
|
+
const [error, setError] = React.useState();
|
|
4607
|
+
const open = team.channels.filter((channel) => !channel.members.includes(agent.id));
|
|
4608
|
+
const join = (channelId, name) => {
|
|
4609
|
+
service.addMembers(channelId, [agent.id]).then(() => {
|
|
4610
|
+
onClose();
|
|
4611
|
+
pi.ui.notify(ChannelWords.format(w.joined, { name: agent.name, channel: name }), "info");
|
|
4612
|
+
}, (failure) => setError(ChannelViews.message(failure)));
|
|
4613
|
+
};
|
|
4614
|
+
return /* @__PURE__ */ React.createElement(pi.ui.Dialog, {
|
|
4615
|
+
title: `${w.joinChannel} · ${agent.name}`,
|
|
4616
|
+
onClose
|
|
4617
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
4618
|
+
className: "tac-dialog"
|
|
4619
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
4620
|
+
className: "tac-pick-list"
|
|
4621
|
+
}, open.length === 0 && /* @__PURE__ */ React.createElement(pi.ui.Empty, {
|
|
4622
|
+
compact: true,
|
|
4623
|
+
title: w.noChannelToJoin
|
|
4624
|
+
}), open.map((channel) => /* @__PURE__ */ React.createElement("button", {
|
|
4625
|
+
key: channel.id,
|
|
4626
|
+
type: "button",
|
|
4627
|
+
className: "tac-pick",
|
|
4628
|
+
disabled: channel.members.length >= MAX_MEMBERS,
|
|
4629
|
+
onClick: () => join(channel.id, channel.name)
|
|
4630
|
+
}, /* @__PURE__ */ React.createElement(Hash, {
|
|
4631
|
+
size: 16
|
|
4632
|
+
}), /* @__PURE__ */ React.createElement("span", {
|
|
4633
|
+
className: "tac-pick-text"
|
|
4634
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
4635
|
+
className: "tac-pick-name"
|
|
4636
|
+
}, channel.name), /* @__PURE__ */ React.createElement("span", {
|
|
4637
|
+
className: "tac-pick-role"
|
|
4638
|
+
}, channel.topic ?? ChannelWords.format(w.memberCount, { count: String(channel.members.length) })))))), error && /* @__PURE__ */ React.createElement("div", {
|
|
4639
|
+
className: "tac-error"
|
|
4640
|
+
}, error)));
|
|
4641
|
+
}
|
|
4642
|
+
|
|
4643
|
+
// ../ta-protocol/esm/common/team-protocol.js
|
|
4644
|
+
var TA_OWNER = "owner";
|
|
4645
|
+
var TA_UNDECLARED = "extensions.install";
|
|
4646
|
+
var TaPermissionUtil;
|
|
4647
|
+
(function(TaPermissionUtil2) {
|
|
4648
|
+
function read(pi) {
|
|
4649
|
+
const given = pi === null || pi === undefined ? undefined : pi.permissions;
|
|
4650
|
+
const map = (value) => value && typeof value === "object" && !Array.isArray(value) ? Object.fromEntries(Object.entries(value).filter((entry) => typeof entry[1] === "string")) : undefined;
|
|
4651
|
+
const host2 = map(given === null || given === undefined ? undefined : given.host);
|
|
4652
|
+
const tools = map(given === null || given === undefined ? undefined : given.tools);
|
|
4653
|
+
return { ...host2 ? { host: host2 } : {}, ...tools ? { tools } : {} };
|
|
4654
|
+
}
|
|
4655
|
+
TaPermissionUtil2.read = read;
|
|
4656
|
+
function host(manifest, method, kind) {
|
|
4657
|
+
var _a, _b, _c, _d;
|
|
4658
|
+
const host2 = (_a = manifest === null || manifest === undefined ? undefined : manifest.host) !== null && _a !== undefined ? _a : {};
|
|
4659
|
+
const own = (key) => Object.prototype.hasOwnProperty.call(host2, key) ? host2[key] : undefined;
|
|
4660
|
+
return (_d = (_c = (_b = kind ? own(`${method}:${kind}`) : undefined) !== null && _b !== undefined ? _b : own(method)) !== null && _c !== undefined ? _c : own("*")) !== null && _d !== undefined ? _d : TA_UNDECLARED;
|
|
4661
|
+
}
|
|
4662
|
+
TaPermissionUtil2.host = host;
|
|
4663
|
+
})(TaPermissionUtil || (TaPermissionUtil = {}));
|
|
4664
|
+
var action = (id, en, zh, tw, ja, more = {}) => ({
|
|
4665
|
+
id,
|
|
4666
|
+
area: id.split(".")[0],
|
|
4667
|
+
title: { en, "zh-CN": zh, ...tw ? { "zh-TW": tw } : {}, ...ja ? { "ja-JP": ja } : {} },
|
|
4668
|
+
...more
|
|
4669
|
+
});
|
|
4670
|
+
var TA_ACTIONS = [
|
|
4671
|
+
action("chat.view", "See conversations", "查看对话", "檢視對話", "会話を確認"),
|
|
4672
|
+
action("chat.send", "Send in conversations", "在对话里发消息", "在對話裡發訊息", "会話にメッセージを送信"),
|
|
4673
|
+
action("chat.create", "Start conversations", "新建对话", "新建對話", "新しい会話を開始"),
|
|
4674
|
+
action("chat.stop", "Stop a reply", "停止回复", "停止回覆", "返信を停止"),
|
|
4675
|
+
action("chat.manage", "Rename, archive and close conversations", "改名、归档、关闭对话", "改名、歸檔、關閉對話", "会話の名前変更、アーカイブ、クローズ"),
|
|
4676
|
+
action("chat.share", "Share by a link", "生成分享链接", "生成分享連結", "共有リンクで共有"),
|
|
4677
|
+
action("agent.view", "See agents", "查看智能体", "檢視智慧體", "エージェントを確認"),
|
|
4678
|
+
action("agent.use", "Talk with agents", "和智能体对话", "和智慧體對話", "エージェントと対話"),
|
|
4679
|
+
action("agent.edit", "Create, change and remove agents", "新建、修改、删除智能体", "新建、修改、刪除智慧體", "エージェントを作成・変更・削除"),
|
|
4680
|
+
action("channel.view", "See channels", "查看频道", "檢視頻道", "チャネルを確認"),
|
|
4681
|
+
action("channel.post", "Post in channels", "在频道里发言", "在頻道里發言", "チャネルに投稿"),
|
|
4682
|
+
action("channel.manage", "Create and change channels", "新建、管理频道", "新建、管理頻道", "チャネルを作成・管理"),
|
|
4683
|
+
action("task.view", "See tasks", "查看任务", "檢視任務", "タスクを確認"),
|
|
4684
|
+
action("task.create", "Hand out tasks", "派任务", "派任務", "タスクを割り当て"),
|
|
4685
|
+
action("task.manage", "Take over and stop tasks", "接管、停止任务", "接管、停止任務", "タスクを引き継ぎ・停止"),
|
|
4686
|
+
action("files.read", "Read files", "读文件", "讀檔案", "ファイルを読取", { scoped: true }),
|
|
4687
|
+
action("files.write", "Change files", "改文件", "改檔案", "ファイルを変更", { scoped: true }),
|
|
4688
|
+
action("commands.run", "Let Ta run commands", "让 Ta 运行命令", "讓 Ta 執行命令", "Ta にコマンド実行を許可", { scoped: true, risky: true }),
|
|
4689
|
+
action("commands.terminal", "Open terminals", "打开终端", "開啟終端機", "ターミナルを開く", { scoped: true, risky: true }),
|
|
4690
|
+
action("hosts.use", "Use remote hosts", "使用远程主机", "使用遠端主機", "リモートホストを使用", { risky: true }),
|
|
4691
|
+
action("models.use", "Use the models", "使用模型", "使用模型", "モデルを使用"),
|
|
4692
|
+
action("models.manage", "Sign in to models", "登录和更换模型账号", "登入和更換模型帳號", "モデルアカウントにサインイン・変更", { grant: "single" }),
|
|
4693
|
+
action("cron.view", "See scheduled tasks", "查看定时任务", "檢視定時任務", "スケジュールタスクを確認"),
|
|
4694
|
+
action("cron.manage", "Change scheduled tasks", "管理定时任务", "管理定時任務", "スケジュールタスクを管理"),
|
|
4695
|
+
action("extensions.use", "Use extensions", "使用扩展", "使用擴充功能", "拡張機能を使用"),
|
|
4696
|
+
action("extensions.install", "Install and turn off extensions", "安装、停用扩展", "安裝、停用擴充功能", "拡張機能をインストール・無効化"),
|
|
4697
|
+
action("settings.view", "See settings", "查看设置", "檢視設定", "設定を確認"),
|
|
4698
|
+
action("settings.manage", "Change settings", "修改设置", "修改設定", "設定を変更"),
|
|
4699
|
+
action("members.view", "See members", "查看成员", "檢視成員", "メンバーを確認"),
|
|
4700
|
+
action("members.invite", "Invite people", "邀请别人", "邀請別人", "メンバーを招待"),
|
|
4701
|
+
action("members.approve", "Answer requests", "处理申请", "處理申請", "リクエストに対応"),
|
|
4702
|
+
action("members.roles", "Change roles and members", "管理角色和成员", "管理角色和成員", "ロールとメンバーを管理"),
|
|
4703
|
+
action("audit.view", "See the record", "查看记录", "檢視記錄", "レコードを確認")
|
|
4704
|
+
];
|
|
4705
|
+
var TA_OWNER_ACTIONS = [
|
|
4706
|
+
action("desktop.view", "See remote desktops", "查看远程桌面", "檢視遠端桌面", "リモートデスクトップを見る", { risky: true }),
|
|
4707
|
+
action("desktop.control", "Work remote desktops", "操作远程桌面", "操作遠端桌面", "リモートデスクトップを操作", { risky: true })
|
|
4708
|
+
];
|
|
4709
|
+
var OWNER_AREAS = ["desktop"];
|
|
4710
|
+
var TaActionUtil;
|
|
4711
|
+
(function(TaActionUtil2) {
|
|
4712
|
+
const byId = new Map(TA_ACTIONS.map((one) => [one.id, one]));
|
|
4713
|
+
const titled = new Map([...TA_ACTIONS, ...TA_OWNER_ACTIONS].map((one) => [one.id, one]));
|
|
4714
|
+
function info(id) {
|
|
4715
|
+
return byId.get(id);
|
|
4716
|
+
}
|
|
4717
|
+
TaActionUtil2.info = info;
|
|
4718
|
+
function title(id, language) {
|
|
4719
|
+
var _a;
|
|
4720
|
+
var _b, _c;
|
|
4721
|
+
const title2 = (_a = titled.get(id)) === null || _a === undefined ? undefined : _a.title;
|
|
4722
|
+
if (!title2) {
|
|
4723
|
+
return id;
|
|
4652
4724
|
}
|
|
4653
|
-
|
|
4654
|
-
|
|
4655
|
-
|
|
4725
|
+
return TaLanguageUtil.pick(language, {
|
|
4726
|
+
"zh-CN": title2["zh-CN"],
|
|
4727
|
+
"zh-TW": (_b = title2["zh-TW"]) !== null && _b !== undefined ? _b : title2["zh-CN"],
|
|
4728
|
+
"en-US": title2.en,
|
|
4729
|
+
"ja-JP": (_c = title2["ja-JP"]) !== null && _c !== undefined ? _c : title2.en
|
|
4730
|
+
});
|
|
4731
|
+
}
|
|
4732
|
+
TaActionUtil2.title = title;
|
|
4733
|
+
function grantable(id) {
|
|
4734
|
+
const info2 = byId.get(id);
|
|
4735
|
+
return !!info2 && !OWNER_AREAS.includes(info2.area);
|
|
4736
|
+
}
|
|
4737
|
+
TaActionUtil2.grantable = grantable;
|
|
4738
|
+
function inRoles(id) {
|
|
4739
|
+
var _a;
|
|
4740
|
+
return grantable(id) && ((_a = byId.get(id)) === null || _a === undefined ? undefined : _a.grant) !== "single";
|
|
4741
|
+
}
|
|
4742
|
+
TaActionUtil2.inRoles = inRoles;
|
|
4743
|
+
function inside(dir, path) {
|
|
4744
|
+
const base = dir.replace(/\/+$/, "");
|
|
4745
|
+
return path === base || path.startsWith(`${base}/`) || base === "";
|
|
4746
|
+
}
|
|
4747
|
+
TaActionUtil2.inside = inside;
|
|
4748
|
+
})(TaActionUtil || (TaActionUtil = {}));
|
|
4749
|
+
|
|
4750
|
+
// web-src/notice-util.ts
|
|
4751
|
+
var NoticeUtil;
|
|
4752
|
+
((NoticeUtil) => {
|
|
4753
|
+
const PARTS = {
|
|
4754
|
+
决定: "decisions",
|
|
4755
|
+
decisions: "decisions",
|
|
4756
|
+
约定: "conventions",
|
|
4757
|
+
conventions: "conventions",
|
|
4758
|
+
待办: "todo",
|
|
4759
|
+
"to do": "todo",
|
|
4760
|
+
todo: "todo",
|
|
4761
|
+
"to-do": "todo"
|
|
4762
|
+
};
|
|
4763
|
+
function counts(text) {
|
|
4764
|
+
const counts2 = { decisions: 0, conventions: 0, todo: 0, done: 0 };
|
|
4765
|
+
let part;
|
|
4766
|
+
for (const line of text.split(/\r?\n/)) {
|
|
4767
|
+
const heading = /^\s*#{1,6}\s+(.+?)\s*#*\s*$/.exec(line) ?? /^\s*\*\*(.+?)\*\*\s*[::]?\s*$/.exec(line);
|
|
4768
|
+
if (heading) {
|
|
4769
|
+
part = PARTS[heading[1].replace(/[::]$/, "").trim().toLowerCase()];
|
|
4770
|
+
continue;
|
|
4656
4771
|
}
|
|
4657
|
-
|
|
4658
|
-
|
|
4659
|
-
|
|
4660
|
-
setOpen(false);
|
|
4772
|
+
const item = /^\s*(?:[-*+]|\d+[.)])\s+(\[( |x|X)\]\s+)?\S/.exec(line);
|
|
4773
|
+
if (!part || !item) {
|
|
4774
|
+
continue;
|
|
4661
4775
|
}
|
|
4662
|
-
|
|
4663
|
-
|
|
4664
|
-
document.addEventListener("keydown", onKey);
|
|
4665
|
-
return () => {
|
|
4666
|
-
document.removeEventListener("pointerdown", close);
|
|
4667
|
-
document.removeEventListener("keydown", onKey);
|
|
4668
|
-
};
|
|
4669
|
-
}, [open]);
|
|
4670
|
-
return /* @__PURE__ */ React.createElement("div", {
|
|
4671
|
-
className: "tac-item-more",
|
|
4672
|
-
ref: root
|
|
4673
|
-
}, /* @__PURE__ */ React.createElement("button", {
|
|
4674
|
-
type: "button",
|
|
4675
|
-
className: `tac-action${open ? " tac-on" : ""}`,
|
|
4676
|
-
title: w.more,
|
|
4677
|
-
"aria-label": w.more,
|
|
4678
|
-
"aria-haspopup": "menu",
|
|
4679
|
-
"aria-expanded": open,
|
|
4680
|
-
onClick: (event) => {
|
|
4681
|
-
event.stopPropagation();
|
|
4682
|
-
if (open) {
|
|
4683
|
-
setOpen(false);
|
|
4776
|
+
if (part === "todo" && item[2] && item[2] !== " ") {
|
|
4777
|
+
counts2.done++;
|
|
4684
4778
|
} else {
|
|
4685
|
-
|
|
4779
|
+
counts2[part]++;
|
|
4686
4780
|
}
|
|
4687
4781
|
}
|
|
4688
|
-
|
|
4689
|
-
|
|
4690
|
-
|
|
4691
|
-
|
|
4692
|
-
|
|
4693
|
-
|
|
4694
|
-
|
|
4695
|
-
|
|
4696
|
-
|
|
4697
|
-
}, index > 0 && /* @__PURE__ */ React.createElement("hr", {
|
|
4698
|
-
className: "tac-menu-line"
|
|
4699
|
-
}), section.map((item) => /* @__PURE__ */ React.createElement("button", {
|
|
4700
|
-
key: item.key,
|
|
4701
|
-
type: "button",
|
|
4702
|
-
role: "menuitem",
|
|
4703
|
-
className: item.danger ? "tac-danger" : undefined,
|
|
4704
|
-
disabled: item.disabled,
|
|
4705
|
-
onClick: () => {
|
|
4706
|
-
setOpen(false);
|
|
4707
|
-
item.run();
|
|
4782
|
+
return counts2;
|
|
4783
|
+
}
|
|
4784
|
+
NoticeUtil.counts = counts;
|
|
4785
|
+
function firstLine(text) {
|
|
4786
|
+
for (const line of text.split(/\r?\n/)) {
|
|
4787
|
+
const item = /^\s*(?:[-*+]|\d+[.)])\s+(?:\[[ xX]\]\s+)?(.+)$/.exec(line);
|
|
4788
|
+
if (item) {
|
|
4789
|
+
return item[1].replace(/[*_`~]+/g, "").trim();
|
|
4790
|
+
}
|
|
4708
4791
|
}
|
|
4709
|
-
|
|
4710
|
-
|
|
4711
|
-
|
|
4712
|
-
}
|
|
4792
|
+
return text.split(/\r?\n/).find((line) => line.trim() && !/^\s*#/.test(line))?.trim() ?? "";
|
|
4793
|
+
}
|
|
4794
|
+
NoticeUtil.firstLine = firstLine;
|
|
4795
|
+
})(NoticeUtil ||= {});
|
|
4713
4796
|
|
|
4714
|
-
// web-src/
|
|
4715
|
-
|
|
4716
|
-
|
|
4717
|
-
|
|
4718
|
-
return
|
|
4719
|
-
} catch {
|
|
4720
|
-
return false;
|
|
4797
|
+
// web-src/notice.tsx
|
|
4798
|
+
var NoticeView;
|
|
4799
|
+
((NoticeView) => {
|
|
4800
|
+
function display(text) {
|
|
4801
|
+
return text.replace(/^(\s*[-*+]\s+)\[ \]\s+/gm, "$1☐ ").replace(/^(\s*[-*+]\s+)\[[xX]\]\s+/gm, "$1☑ ");
|
|
4721
4802
|
}
|
|
4722
|
-
|
|
4723
|
-
function
|
|
4724
|
-
|
|
4725
|
-
|
|
4726
|
-
|
|
4727
|
-
|
|
4728
|
-
|
|
4729
|
-
|
|
4730
|
-
|
|
4731
|
-
async function deleteAgent(context, agent) {
|
|
4732
|
-
const w = ChannelViews.words(context.pi);
|
|
4733
|
-
const sure = await context.pi.ui.confirm(ChannelWords.format(w.confirmDeleteAgent, { name: agent.name }), undefined, {
|
|
4734
|
-
confirmLabel: w.delete,
|
|
4735
|
-
danger: true
|
|
4736
|
-
});
|
|
4737
|
-
if (sure) {
|
|
4738
|
-
await context.service.deleteAgent(agent.id);
|
|
4739
|
-
context.sessions.delete(agent.id);
|
|
4803
|
+
NoticeView.display = display;
|
|
4804
|
+
function counts(text, language) {
|
|
4805
|
+
const w = ChannelWords.of(language);
|
|
4806
|
+
const counts2 = NoticeUtil.counts(text);
|
|
4807
|
+
if (counts2.decisions + counts2.conventions + counts2.todo === 0) {
|
|
4808
|
+
return NoticeUtil.firstLine(text);
|
|
4809
|
+
}
|
|
4810
|
+
const values = { decisions: String(counts2.decisions), conventions: String(counts2.conventions), todo: String(counts2.todo) };
|
|
4811
|
+
return ChannelWords.format(w.noticeCounts, values).split(" · ").filter((_, at) => [counts2.decisions, counts2.conventions, counts2.todo][at] > 0).join(" · ");
|
|
4740
4812
|
}
|
|
4741
|
-
|
|
4742
|
-
|
|
4813
|
+
NoticeView.counts = counts;
|
|
4814
|
+
})(NoticeView ||= {});
|
|
4815
|
+
function NoticeBar({
|
|
4816
|
+
context,
|
|
4817
|
+
channel,
|
|
4818
|
+
state,
|
|
4819
|
+
onState
|
|
4820
|
+
}) {
|
|
4743
4821
|
const { pi, service } = context;
|
|
4822
|
+
const { team } = useChannels(service);
|
|
4744
4823
|
const w = ChannelViews.words(pi);
|
|
4745
|
-
const
|
|
4746
|
-
const
|
|
4747
|
-
const fail = (error) => pi.ui.notify(ChannelViews.message(error), "error");
|
|
4748
|
-
const act = (action2) => () => {
|
|
4749
|
-
Promise.resolve().then(action2).catch(fail);
|
|
4750
|
-
};
|
|
4751
|
-
const openSession = async () => {
|
|
4752
|
-
if (!agent.sessionFile) {
|
|
4753
|
-
return;
|
|
4754
|
-
}
|
|
4755
|
-
return (await pi.server.listSessions()).find((session) => session.sessionFile === agent.sessionFile);
|
|
4756
|
-
};
|
|
4757
|
-
const stop = act(async () => {
|
|
4758
|
-
const session = await openSession();
|
|
4759
|
-
if (session) {
|
|
4760
|
-
await pi.server.abort(session.sessionId);
|
|
4761
|
-
}
|
|
4762
|
-
pi.ui.notify(ChannelWords.format(w.stoppedAgent, { name: agent.name }), "info");
|
|
4763
|
-
});
|
|
4764
|
-
const restart = act(async () => {
|
|
4765
|
-
await service.resetAgent(agent.id);
|
|
4766
|
-
context.sessions.delete(agent.id);
|
|
4767
|
-
pi.ui.notify(ChannelWords.format(w.resetDone, { name: agent.name }), "info");
|
|
4768
|
-
});
|
|
4769
|
-
const copyCwd = act(async () => {
|
|
4770
|
-
if (await copy(cwd)) {
|
|
4771
|
-
pi.ui.notify(ChannelWords.format(w.copied, { path: cwd }), "info");
|
|
4772
|
-
}
|
|
4773
|
-
});
|
|
4774
|
-
const exportMarkdown = act(async () => {
|
|
4775
|
-
const session = await openSession();
|
|
4776
|
-
const sessionId = session?.sessionId ?? (agent.sessionFile ? await service.openAgent(agent.id) : undefined);
|
|
4777
|
-
const { messages } = sessionId ? await pi.server.getMessages(sessionId) : { messages: [] };
|
|
4778
|
-
if (!messages.some((message) => message.role === "assistant")) {
|
|
4779
|
-
pi.ui.notify(ChannelWords.format(w.nothingToExport, { name: agent.name }), "info");
|
|
4780
|
-
return;
|
|
4781
|
-
}
|
|
4782
|
-
download(`${agent.name}.md`, ChannelsText.markdown(agent, messages, { user: w.you }));
|
|
4783
|
-
});
|
|
4784
|
-
const remove = act(() => deleteAgent(context, agent));
|
|
4785
|
-
const pin = act(() => service.updateAgent(agent.id, { pinned: !agent.pinned }));
|
|
4786
|
-
const keep = act(async () => {
|
|
4787
|
-
await service.updateAgent(agent.id, { keep: true });
|
|
4788
|
-
pi.ui.notify(ChannelWords.format(w.kept, { name: agent.name }), "info");
|
|
4789
|
-
});
|
|
4790
|
-
const show = (next) => () => setDialog(next);
|
|
4791
|
-
const item = (key, label, glyph, run, options = {}) => ({
|
|
4792
|
-
key,
|
|
4793
|
-
label,
|
|
4794
|
-
icon: icon(glyph),
|
|
4795
|
-
run,
|
|
4796
|
-
...options
|
|
4797
|
-
});
|
|
4798
|
-
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(MoreMenu, {
|
|
4799
|
-
pi,
|
|
4800
|
-
label: agent.name,
|
|
4801
|
-
items: () => [
|
|
4802
|
-
[
|
|
4803
|
-
...agent.temporary ? [item("keep", w.keep, "UserPlus", keep)] : [],
|
|
4804
|
-
item("pin", agent.pinned ? w.unpin : w.pin, agent.pinned ? "PinOff" : "Pin", pin)
|
|
4805
|
-
],
|
|
4806
|
-
[item("stop", w.stop, "Square", stop, { disabled: !working && !agent.sessionFile }), item("restart", w.restart, "RotateCcw", restart)],
|
|
4807
|
-
[
|
|
4808
|
-
item("rename", w.rename, "Pencil", show("rename")),
|
|
4809
|
-
item("role", w.editRole, "ScrollText", show("role")),
|
|
4810
|
-
item("move", w.moveTo, "FolderInput", show("move")),
|
|
4811
|
-
item("copy", w.copyCwd, "Copy", copyCwd)
|
|
4812
|
-
],
|
|
4813
|
-
[
|
|
4814
|
-
item("card", w.shareCard, "Contact", show("card")),
|
|
4815
|
-
item("export", w.exportChat, "Download", exportMarkdown),
|
|
4816
|
-
item("join", w.joinChannel, "UserPlus", show("join"))
|
|
4817
|
-
],
|
|
4818
|
-
[item("delete", w.deleteAgent, "Trash2", remove, { danger: true })]
|
|
4819
|
-
]
|
|
4820
|
-
}), dialog === "rename" && /* @__PURE__ */ React.createElement(RenameDialog, {
|
|
4821
|
-
context,
|
|
4822
|
-
agent,
|
|
4823
|
-
onClose: () => setDialog(undefined)
|
|
4824
|
-
}), dialog === "role" && /* @__PURE__ */ React.createElement(RoleDialog, {
|
|
4825
|
-
context,
|
|
4826
|
-
agent,
|
|
4827
|
-
onClose: () => setDialog(undefined)
|
|
4828
|
-
}), dialog === "join" && /* @__PURE__ */ React.createElement(JoinDialog, {
|
|
4829
|
-
context,
|
|
4830
|
-
agent,
|
|
4831
|
-
onClose: () => setDialog(undefined)
|
|
4832
|
-
}), dialog === "card" && /* @__PURE__ */ React.createElement(CardDialog, {
|
|
4833
|
-
context,
|
|
4834
|
-
agent,
|
|
4835
|
-
onClose: () => setDialog(undefined)
|
|
4836
|
-
}), dialog === "move" && /* @__PURE__ */ React.createElement(pi.ui.FolderPicker, {
|
|
4837
|
-
initial: cwd,
|
|
4838
|
-
onClose: () => setDialog(undefined),
|
|
4839
|
-
onPick: async (path) => {
|
|
4840
|
-
setDialog(undefined);
|
|
4841
|
-
if (path !== cwd) {
|
|
4842
|
-
await service.updateAgent(agent.id, { cwd: path }).catch(fail);
|
|
4843
|
-
context.sessions.delete(agent.id);
|
|
4844
|
-
}
|
|
4845
|
-
}
|
|
4846
|
-
}));
|
|
4847
|
-
}
|
|
4848
|
-
function useSave(action2, onClose) {
|
|
4824
|
+
const notice = channel.notice;
|
|
4825
|
+
const [draft, setDraft] = React.useState("");
|
|
4849
4826
|
const [busy, setBusy] = React.useState(false);
|
|
4850
4827
|
const [error, setError] = React.useState();
|
|
4851
|
-
|
|
4828
|
+
React.useEffect(() => {
|
|
4829
|
+
if (state.editing) {
|
|
4830
|
+
setDraft(notice?.text ?? w.noticeTemplate);
|
|
4831
|
+
setError(undefined);
|
|
4832
|
+
}
|
|
4833
|
+
}, [state.editing]);
|
|
4834
|
+
if (!notice && !state.editing) {
|
|
4835
|
+
return null;
|
|
4836
|
+
}
|
|
4837
|
+
const Megaphone = ChannelViews.icon(pi, "Megaphone");
|
|
4838
|
+
const Chevron = ChannelViews.icon(pi, "ChevronDown");
|
|
4839
|
+
const Markdown = pi.ui.Markdown;
|
|
4840
|
+
const save = (event) => {
|
|
4852
4841
|
event.preventDefault();
|
|
4853
4842
|
setBusy(true);
|
|
4854
4843
|
setError(undefined);
|
|
4855
|
-
|
|
4844
|
+
service.setNotice(channel.id, draft).then(() => {
|
|
4845
|
+
setBusy(false);
|
|
4846
|
+
onState({ open: true, editing: false });
|
|
4847
|
+
}, (failure) => {
|
|
4856
4848
|
setBusy(false);
|
|
4857
4849
|
setError(ChannelViews.message(failure));
|
|
4858
4850
|
});
|
|
4859
4851
|
};
|
|
4860
|
-
|
|
4861
|
-
|
|
4862
|
-
|
|
4863
|
-
|
|
4864
|
-
const w = ChannelViews.words(pi);
|
|
4865
|
-
const [name, setName] = React.useState(agent.name);
|
|
4866
|
-
const { busy, error, submit } = useSave(() => service.updateAgent(agent.id, { name }), onClose);
|
|
4867
|
-
return /* @__PURE__ */ React.createElement(pi.ui.Dialog, {
|
|
4868
|
-
title: w.rename,
|
|
4869
|
-
onClose
|
|
4870
|
-
}, /* @__PURE__ */ React.createElement("form", {
|
|
4871
|
-
className: "tac-dialog",
|
|
4872
|
-
onSubmit: submit
|
|
4873
|
-
}, /* @__PURE__ */ React.createElement("label", {
|
|
4874
|
-
className: "tac-dialog-label"
|
|
4875
|
-
}, w.name, /* @__PURE__ */ React.createElement("input", {
|
|
4876
|
-
className: "tac-input tac-dialog-input",
|
|
4877
|
-
value: name,
|
|
4878
|
-
maxLength: 32,
|
|
4879
|
-
autoFocus: true,
|
|
4880
|
-
onChange: (event) => setName(event.target.value)
|
|
4881
|
-
})), error && /* @__PURE__ */ React.createElement("div", {
|
|
4882
|
-
className: "tac-error"
|
|
4883
|
-
}, error), /* @__PURE__ */ React.createElement("div", {
|
|
4884
|
-
className: "tac-dialog-actions"
|
|
4852
|
+
const open = state.open || state.editing;
|
|
4853
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
4854
|
+
className: "tac-notice-bar",
|
|
4855
|
+
"data-open": open ? "" : undefined
|
|
4885
4856
|
}, /* @__PURE__ */ React.createElement("button", {
|
|
4886
|
-
type: "
|
|
4887
|
-
className:
|
|
4888
|
-
|
|
4889
|
-
|
|
4890
|
-
|
|
4891
|
-
}
|
|
4892
|
-
|
|
4893
|
-
|
|
4894
|
-
|
|
4895
|
-
|
|
4896
|
-
|
|
4897
|
-
|
|
4898
|
-
|
|
4899
|
-
|
|
4900
|
-
|
|
4901
|
-
|
|
4902
|
-
|
|
4903
|
-
|
|
4857
|
+
type: "button",
|
|
4858
|
+
className: "tac-notice-head",
|
|
4859
|
+
"aria-expanded": open,
|
|
4860
|
+
title: open ? w.noticeHide : w.noticeShow,
|
|
4861
|
+
onClick: () => onState({ open: !open, editing: false })
|
|
4862
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
4863
|
+
className: "tac-notice-icon"
|
|
4864
|
+
}, /* @__PURE__ */ React.createElement(Megaphone, {
|
|
4865
|
+
size: 13,
|
|
4866
|
+
strokeWidth: 2
|
|
4867
|
+
})), /* @__PURE__ */ React.createElement("strong", null, w.notice), /* @__PURE__ */ React.createElement("span", {
|
|
4868
|
+
className: "tac-notice-sum"
|
|
4869
|
+
}, notice ? NoticeView.counts(notice.text, pi.ui.language) : w.noticeEmpty), /* @__PURE__ */ React.createElement("span", {
|
|
4870
|
+
className: "tac-notice-chevron"
|
|
4871
|
+
}, /* @__PURE__ */ React.createElement(Chevron, {
|
|
4872
|
+
size: 15
|
|
4873
|
+
}))), open && !state.editing && notice && /* @__PURE__ */ React.createElement("div", {
|
|
4874
|
+
className: "tac-notice-body"
|
|
4875
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
4876
|
+
className: "tac-notice-text"
|
|
4877
|
+
}, /* @__PURE__ */ React.createElement(Markdown, {
|
|
4878
|
+
text: NoticeView.display(notice.text)
|
|
4879
|
+
})), /* @__PURE__ */ React.createElement("div", {
|
|
4880
|
+
className: "tac-notice-foot"
|
|
4881
|
+
}, /* @__PURE__ */ React.createElement("span", null, ChannelWords.format(w.noticeBy, {
|
|
4882
|
+
name: ChannelsText.authorName(team, notice.by, { user: w.you, ta: w.ta }),
|
|
4883
|
+
time: SidebarUtil.time(notice.at, pi.ui.language)
|
|
4884
|
+
})), /* @__PURE__ */ React.createElement("button", {
|
|
4885
|
+
type: "button",
|
|
4886
|
+
className: "tac-button tac-quiet",
|
|
4887
|
+
onClick: () => onState({ open: true, editing: true })
|
|
4888
|
+
}, w.noticeEdit))), state.editing && /* @__PURE__ */ React.createElement("form", {
|
|
4889
|
+
className: "tac-notice-body tac-notice-form",
|
|
4890
|
+
onSubmit: save
|
|
4904
4891
|
}, /* @__PURE__ */ React.createElement("p", {
|
|
4905
4892
|
className: "tac-dialog-note"
|
|
4906
|
-
}, w.
|
|
4907
|
-
className: "tac-input tac-
|
|
4908
|
-
value:
|
|
4909
|
-
|
|
4910
|
-
"aria-label": w.editRole,
|
|
4893
|
+
}, w.noticeHint), /* @__PURE__ */ React.createElement("textarea", {
|
|
4894
|
+
className: "tac-input tac-notice-input",
|
|
4895
|
+
value: draft,
|
|
4896
|
+
"aria-label": w.noticeEdit,
|
|
4911
4897
|
autoFocus: true,
|
|
4912
|
-
onChange: (event) =>
|
|
4898
|
+
onChange: (event) => setDraft(event.target.value)
|
|
4913
4899
|
}), error && /* @__PURE__ */ React.createElement("div", {
|
|
4914
4900
|
className: "tac-error"
|
|
4915
4901
|
}, error), /* @__PURE__ */ React.createElement("div", {
|
|
4916
|
-
className: "tac-
|
|
4902
|
+
className: "tac-notice-actions"
|
|
4917
4903
|
}, /* @__PURE__ */ React.createElement("button", {
|
|
4904
|
+
type: "button",
|
|
4905
|
+
className: "tac-button tac-quiet",
|
|
4906
|
+
onClick: () => onState({ open: !!notice, editing: false })
|
|
4907
|
+
}, w.cancel), /* @__PURE__ */ React.createElement("button", {
|
|
4918
4908
|
type: "submit",
|
|
4919
4909
|
className: busy ? "tac-button tac-primary ta-busy" : "tac-button tac-primary",
|
|
4920
|
-
disabled: busy ||
|
|
4910
|
+
disabled: busy || draft.trim() === (notice?.text ?? "")
|
|
4921
4911
|
}, w.save, busy && /* @__PURE__ */ React.createElement("span", {
|
|
4922
4912
|
className: "ta-spinner ta-busy-mark ta-on-brand"
|
|
4923
4913
|
})))));
|
|
4924
4914
|
}
|
|
4925
|
-
|
|
4915
|
+
|
|
4916
|
+
// web-src/room.tsx
|
|
4917
|
+
var RUN_MS = 5 * 60 * 1000;
|
|
4918
|
+
var PAUSE_MS = 15 * 60 * 1000;
|
|
4919
|
+
var RoomUtil;
|
|
4920
|
+
((RoomUtil) => {
|
|
4921
|
+
function rows(messages) {
|
|
4922
|
+
return messages.map((message, index) => {
|
|
4923
|
+
const before = messages[index - 1];
|
|
4924
|
+
const separator = !before || message.at - before.at > PAUSE_MS;
|
|
4925
|
+
const first = separator || before.author !== message.author || before.by !== message.by || before.author === SYSTEM || !!before.notice || message.at - before.at > RUN_MS;
|
|
4926
|
+
return { message, first, separator };
|
|
4927
|
+
});
|
|
4928
|
+
}
|
|
4929
|
+
RoomUtil.rows = rows;
|
|
4930
|
+
})(RoomUtil ||= {});
|
|
4931
|
+
function Mentions({ text, agents }) {
|
|
4932
|
+
const names = new Set(agents.map((agent) => agent.name.toLowerCase()));
|
|
4933
|
+
const parts = text.split(/(@[^\s@#,,。::]+)/);
|
|
4934
|
+
return /* @__PURE__ */ React.createElement("span", null, parts.map((part, index) => part.startsWith("@") && names.has(part.slice(1).toLowerCase()) ? /* @__PURE__ */ React.createElement("span", {
|
|
4935
|
+
key: index,
|
|
4936
|
+
className: "tac-mention"
|
|
4937
|
+
}, part) : part));
|
|
4938
|
+
}
|
|
4939
|
+
function StopLine({
|
|
4940
|
+
context,
|
|
4941
|
+
channel,
|
|
4942
|
+
message,
|
|
4943
|
+
later,
|
|
4944
|
+
agents
|
|
4945
|
+
}) {
|
|
4926
4946
|
const { pi, service } = context;
|
|
4927
|
-
const { team } = useChannels(service);
|
|
4928
4947
|
const w = ChannelViews.words(pi);
|
|
4929
|
-
const
|
|
4930
|
-
const
|
|
4931
|
-
const
|
|
4932
|
-
const
|
|
4933
|
-
|
|
4934
|
-
|
|
4935
|
-
|
|
4936
|
-
|
|
4948
|
+
const [busy, setBusy] = React.useState(false);
|
|
4949
|
+
const stop = message.stop;
|
|
4950
|
+
const lead = agents.find((agent) => agent.id === channel.members.find((id) => !(channel.muted ?? []).includes(id)));
|
|
4951
|
+
const replies = String(stop?.replies ?? 0);
|
|
4952
|
+
const tokens = stop?.tokens ? new Intl.NumberFormat(pi.ui.language, { notation: "compact", maximumFractionDigits: 1 }).format(stop.tokens) : "";
|
|
4953
|
+
const stats = stop ? ChannelWords.format(tokens ? w.stoppedStats : w.stoppedReplies, { replies, tokens }) : "";
|
|
4954
|
+
const resumed = stop?.resumed === "continue" ? w.wentOn : stop?.resumed === "wrapUp" ? w.summedUp : "";
|
|
4955
|
+
const why = stop?.daily === "all" ? w.dailyAll : stop?.daily === "channel" ? w.dailyChannel : stop?.idle === "repeat" ? w.idleRepeat : stop?.idle === "agree" ? w.idleAgree : stop?.idle === "pingPong" ? w.idlePingPong : w.stopped;
|
|
4956
|
+
const extended = stop?.extended ? w.extendedOnce : "";
|
|
4957
|
+
const go = (how) => {
|
|
4958
|
+
setBusy(true);
|
|
4959
|
+
service.resumeRound(channel.id, message.id, how).catch((error) => pi.ui.notify(ChannelViews.message(error), "error")).finally(() => setBusy(false));
|
|
4937
4960
|
};
|
|
4938
|
-
|
|
4939
|
-
|
|
4940
|
-
|
|
4961
|
+
const open = !!stop?.pending.length && !stop.resumed && !later;
|
|
4962
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
4963
|
+
className: "tac-stop",
|
|
4964
|
+
role: "note"
|
|
4941
4965
|
}, /* @__PURE__ */ React.createElement("div", {
|
|
4942
|
-
className: "tac-
|
|
4966
|
+
className: "tac-notice"
|
|
4967
|
+
}, why), /* @__PURE__ */ React.createElement("div", {
|
|
4968
|
+
className: "tac-stop-meta"
|
|
4969
|
+
}, [stats, extended, resumed].filter(Boolean).join(" · ")), open && /* @__PURE__ */ React.createElement("div", {
|
|
4970
|
+
className: "tac-stop-actions"
|
|
4971
|
+
}, /* @__PURE__ */ React.createElement("button", {
|
|
4972
|
+
type: "button",
|
|
4973
|
+
className: "tac-stop-button",
|
|
4974
|
+
disabled: busy,
|
|
4975
|
+
onClick: () => go("continue")
|
|
4976
|
+
}, w.keepGoing), lead && /* @__PURE__ */ React.createElement("button", {
|
|
4977
|
+
type: "button",
|
|
4978
|
+
className: "tac-stop-button",
|
|
4979
|
+
disabled: busy,
|
|
4980
|
+
onClick: () => go("wrapUp")
|
|
4981
|
+
}, ChannelWords.format(w.wrapUp, { name: `@${lead.name}` }))));
|
|
4982
|
+
}
|
|
4983
|
+
function ChannelHead({ context }) {
|
|
4984
|
+
const { pi, service, ui } = context;
|
|
4985
|
+
const state = useChannels(service);
|
|
4986
|
+
const { channelId } = useUi(ui);
|
|
4987
|
+
const faces = useFaces(state.team);
|
|
4988
|
+
const w = ChannelViews.words(pi);
|
|
4989
|
+
const shown = !!pi.ui.useView(MEMBERS_VIEW)?.shown;
|
|
4990
|
+
const roomInfo = !!pi.ui.useView(ROOM_INFO_VIEW)?.shown;
|
|
4991
|
+
const follow = React.useRef(roomInfo);
|
|
4992
|
+
follow.current = roomInfo;
|
|
4993
|
+
React.useEffect(() => {
|
|
4994
|
+
if (channelId && follow.current) {
|
|
4995
|
+
context.showMembers();
|
|
4996
|
+
}
|
|
4997
|
+
}, [channelId, context]);
|
|
4998
|
+
const channel = state.team.channels.find((candidate) => candidate.id === channelId);
|
|
4999
|
+
if (!channel) {
|
|
5000
|
+
return null;
|
|
5001
|
+
}
|
|
5002
|
+
const members = membersOf(state.team, channel);
|
|
5003
|
+
const working = state.working[channel.id] ?? [];
|
|
5004
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
5005
|
+
className: "tac-head"
|
|
4943
5006
|
}, /* @__PURE__ */ React.createElement("div", {
|
|
4944
|
-
className: "tac-
|
|
4945
|
-
},
|
|
4946
|
-
|
|
4947
|
-
|
|
4948
|
-
|
|
4949
|
-
|
|
5007
|
+
className: "tac-head-title"
|
|
5008
|
+
}, /* @__PURE__ */ React.createElement("strong", null, channel.name), /* @__PURE__ */ React.createElement("span", {
|
|
5009
|
+
className: "tac-head-count"
|
|
5010
|
+
}, ChannelWords.format(w.memberCount, { count: String(members.length) })), channel.topic && /* @__PURE__ */ React.createElement("span", {
|
|
5011
|
+
className: "tac-head-topic"
|
|
5012
|
+
}, channel.topic)), /* @__PURE__ */ React.createElement("button", {
|
|
4950
5013
|
type: "button",
|
|
4951
|
-
className: "tac-
|
|
4952
|
-
|
|
4953
|
-
|
|
4954
|
-
|
|
4955
|
-
|
|
4956
|
-
}
|
|
4957
|
-
|
|
5014
|
+
className: `tac-head-members${shown ? " tac-on" : ""}`,
|
|
5015
|
+
title: w.showMembers,
|
|
5016
|
+
"aria-label": w.showMembers,
|
|
5017
|
+
"aria-pressed": shown,
|
|
5018
|
+
onClick: () => context.showMembers()
|
|
5019
|
+
}, members.slice(0, 5).map((agent) => /* @__PURE__ */ React.createElement("span", {
|
|
5020
|
+
key: agent.id,
|
|
5021
|
+
className: "tac-head-face"
|
|
5022
|
+
}, /* @__PURE__ */ React.createElement(AgentAvatar, {
|
|
5023
|
+
agent,
|
|
5024
|
+
faces,
|
|
5025
|
+
size: 24,
|
|
5026
|
+
working: working.includes(agent.id)
|
|
5027
|
+
}))), members.length > 5 && /* @__PURE__ */ React.createElement("span", {
|
|
5028
|
+
className: "tac-head-more"
|
|
5029
|
+
}, "+", members.length - 5)));
|
|
5030
|
+
}
|
|
5031
|
+
function ChannelSceneHead({ context, channelId }) {
|
|
5032
|
+
const { pi, service } = context;
|
|
5033
|
+
const state = useChannels(service);
|
|
5034
|
+
const faces = useFaces(state.team);
|
|
5035
|
+
const w = ChannelViews.words(pi);
|
|
5036
|
+
const channel = state.team.channels.find((candidate) => candidate.id === channelId);
|
|
5037
|
+
if (!channel) {
|
|
5038
|
+
return null;
|
|
5039
|
+
}
|
|
5040
|
+
const members = membersOf(state.team, channel);
|
|
5041
|
+
const working = state.working[channel.id] ?? [];
|
|
5042
|
+
const External = ChannelViews.icon(pi, "ExternalLink");
|
|
5043
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
5044
|
+
className: "tac-scene-head"
|
|
5045
|
+
}, /* @__PURE__ */ React.createElement(RoomFace, {
|
|
5046
|
+
members,
|
|
5047
|
+
faces,
|
|
5048
|
+
size: 26,
|
|
5049
|
+
working
|
|
5050
|
+
}), /* @__PURE__ */ React.createElement("div", {
|
|
5051
|
+
className: "tac-scene-title"
|
|
5052
|
+
}, /* @__PURE__ */ React.createElement("strong", null, channel.name), /* @__PURE__ */ React.createElement("span", null, channel.topic ?? ChannelWords.format(w.memberCount, { count: String(members.length) }))), /* @__PURE__ */ React.createElement("button", {
|
|
5053
|
+
type: "button",
|
|
5054
|
+
className: "tac-button tac-scene-main",
|
|
5055
|
+
title: w.openInMainHint,
|
|
5056
|
+
onClick: () => context.showChannel(channel.id)
|
|
5057
|
+
}, /* @__PURE__ */ React.createElement(External, {
|
|
5058
|
+
size: 13
|
|
5059
|
+
}), w.openInMain));
|
|
5060
|
+
}
|
|
5061
|
+
var mePromise;
|
|
5062
|
+
function useMe(pi) {
|
|
5063
|
+
const [me, setMe] = React.useState(TA_OWNER);
|
|
5064
|
+
React.useEffect(() => {
|
|
5065
|
+
mePromise ??= pi.server.getServerInfo().then((info) => info.member?.id ?? TA_OWNER, () => TA_OWNER);
|
|
5066
|
+
let live = true;
|
|
5067
|
+
mePromise.then((id) => live && setMe(id));
|
|
5068
|
+
return () => {
|
|
5069
|
+
live = false;
|
|
5070
|
+
};
|
|
5071
|
+
}, [pi]);
|
|
5072
|
+
return me;
|
|
5073
|
+
}
|
|
5074
|
+
function ChannelRoom({ context, channelId: fixed }) {
|
|
5075
|
+
const { pi, service, ui } = context;
|
|
5076
|
+
const me = useMe(pi);
|
|
5077
|
+
const state = useChannels(service);
|
|
5078
|
+
const shown = useUi(ui).channelId;
|
|
5079
|
+
const channelId = fixed ?? shown;
|
|
5080
|
+
const faces = useFaces(state.team);
|
|
5081
|
+
const w = ChannelViews.words(pi);
|
|
5082
|
+
const channel = state.team.channels.find((candidate) => candidate.id === channelId);
|
|
5083
|
+
const messages = channel ? state.messages[channel.id] : undefined;
|
|
5084
|
+
const working = channel ? state.working[channel.id] ?? [] : [];
|
|
5085
|
+
React.useEffect(() => {
|
|
5086
|
+
if (channelId) {
|
|
5087
|
+
service.messages(channelId);
|
|
5088
|
+
}
|
|
5089
|
+
}, [service, channelId]);
|
|
5090
|
+
React.useEffect(() => {
|
|
5091
|
+
if (!channelId) {
|
|
5092
|
+
return;
|
|
5093
|
+
}
|
|
5094
|
+
const watch = () => document.visibilityState === "visible" && void service.watch(channelId).catch(() => {
|
|
5095
|
+
return;
|
|
5096
|
+
});
|
|
5097
|
+
watch();
|
|
5098
|
+
const timer = setInterval(watch, WATCH_MS);
|
|
5099
|
+
document.addEventListener("visibilitychange", watch);
|
|
5100
|
+
return () => {
|
|
5101
|
+
clearInterval(timer);
|
|
5102
|
+
document.removeEventListener("visibilitychange", watch);
|
|
5103
|
+
};
|
|
5104
|
+
}, [service, channelId]);
|
|
5105
|
+
const sent = React.useMemo(() => messages?.filter((message) => message.author === USER).length ?? 0, [messages]);
|
|
5106
|
+
const list = pi.ui.useChatScroll(sent, channelId);
|
|
5107
|
+
const [notice, setNotice] = React.useState({ open: false, editing: false });
|
|
5108
|
+
React.useEffect(() => setNotice({ open: false, editing: false }), [channelId]);
|
|
5109
|
+
const Markdown = pi.ui.Markdown;
|
|
5110
|
+
const Composer = pi.ui.Composer;
|
|
5111
|
+
const Avatar = pi.ui.Avatar;
|
|
5112
|
+
if (!channel) {
|
|
5113
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
5114
|
+
className: "tac-room-page"
|
|
5115
|
+
}, state.loaded && /* @__PURE__ */ React.createElement(pi.ui.Empty, {
|
|
5116
|
+
title: w.pick
|
|
5117
|
+
}));
|
|
5118
|
+
}
|
|
5119
|
+
const members = membersOf(state.team, channel);
|
|
5120
|
+
const agentOf = (id) => state.team.agents.find((agent) => agent.id === id);
|
|
5121
|
+
const name = (id) => ChannelsText.authorName(state.team, id, { user: w.you, ta: w.ta });
|
|
5122
|
+
const time = (at) => SidebarUtil.time(at, pi.ui.language);
|
|
5123
|
+
const mention = (agent) => ({
|
|
5124
|
+
key: agent.id,
|
|
5125
|
+
label: agent.name,
|
|
5126
|
+
icon: /* @__PURE__ */ React.createElement(AgentAvatar, {
|
|
5127
|
+
agent,
|
|
5128
|
+
faces,
|
|
5129
|
+
size: 20
|
|
5130
|
+
}),
|
|
5131
|
+
detail: agent.id === channel.members[0] ? w.lead : undefined,
|
|
5132
|
+
insert: `@${agent.name} `
|
|
5133
|
+
});
|
|
5134
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
5135
|
+
className: "tac-room-page"
|
|
5136
|
+
}, /* @__PURE__ */ React.createElement(NoticeBar, {
|
|
5137
|
+
context,
|
|
5138
|
+
channel,
|
|
5139
|
+
state: notice,
|
|
5140
|
+
onState: setNotice
|
|
5141
|
+
}), /* @__PURE__ */ React.createElement("div", {
|
|
5142
|
+
className: "tac-chat ta-conversation",
|
|
5143
|
+
ref: list
|
|
5144
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
5145
|
+
className: "tac-chat-col"
|
|
5146
|
+
}, messages && messages.length === 0 && /* @__PURE__ */ React.createElement("div", {
|
|
5147
|
+
className: "tac-chat-empty"
|
|
5148
|
+
}, /* @__PURE__ */ React.createElement(RoomFace, {
|
|
5149
|
+
members,
|
|
5150
|
+
faces,
|
|
5151
|
+
size: 56,
|
|
5152
|
+
working
|
|
5153
|
+
}), /* @__PURE__ */ React.createElement("strong", null, channel.name), channel.topic && /* @__PURE__ */ React.createElement("span", null, channel.topic), /* @__PURE__ */ React.createElement("span", {
|
|
5154
|
+
className: "tac-chat-hint"
|
|
5155
|
+
}, w.quiet)), messages && RoomUtil.rows(messages).map(({ message, first, separator }) => /* @__PURE__ */ React.createElement(React.Fragment, {
|
|
5156
|
+
key: message.id
|
|
5157
|
+
}, separator && /* @__PURE__ */ React.createElement("div", {
|
|
5158
|
+
className: "tac-chat-time"
|
|
5159
|
+
}, time(message.at)), message.author === SYSTEM ? /* @__PURE__ */ React.createElement(StopLine, {
|
|
5160
|
+
context,
|
|
5161
|
+
channel,
|
|
5162
|
+
message,
|
|
5163
|
+
agents: state.team.agents,
|
|
5164
|
+
later: messages.some((other) => other.at > message.at && (other.author === USER || other.author === TA))
|
|
5165
|
+
}) : message.notice ? /* @__PURE__ */ React.createElement("button", {
|
|
5166
|
+
type: "button",
|
|
5167
|
+
className: "tac-notice tac-notice-line",
|
|
5168
|
+
disabled: !channel.notice,
|
|
5169
|
+
onClick: () => setNotice({ open: true, editing: false })
|
|
5170
|
+
}, ChannelWords.format(message.notice === "cleared" ? w.noticeCleared : w.noticeUpdated, { name: name(message.author) })) : message.author === USER && (message.by ?? TA_OWNER) !== me ? /* @__PURE__ */ React.createElement("div", {
|
|
5171
|
+
className: `tac-msg${first ? " tac-first" : ""}`
|
|
5172
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
5173
|
+
className: "tac-msg-face"
|
|
5174
|
+
}, first && pi.ui.Face && /* @__PURE__ */ React.createElement(pi.ui.Face, {
|
|
5175
|
+
seed: message.by ?? TA_OWNER,
|
|
5176
|
+
double: (message.by ?? TA_OWNER) === TA_OWNER,
|
|
5177
|
+
size: 28
|
|
5178
|
+
})), /* @__PURE__ */ React.createElement("div", {
|
|
5179
|
+
className: "tac-msg-col"
|
|
5180
|
+
}, first && /* @__PURE__ */ React.createElement("div", {
|
|
5181
|
+
className: "tac-msg-name"
|
|
5182
|
+
}, message.byName ?? w.owner), /* @__PURE__ */ React.createElement("div", {
|
|
5183
|
+
className: "tac-msg-bubble",
|
|
5184
|
+
title: time(message.at)
|
|
5185
|
+
}, /* @__PURE__ */ React.createElement(Mentions, {
|
|
5186
|
+
text: message.text,
|
|
5187
|
+
agents: state.team.agents
|
|
5188
|
+
})))) : message.author === USER ? /* @__PURE__ */ React.createElement("div", {
|
|
5189
|
+
className: "ta-message ta-user tac-mine"
|
|
5190
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
5191
|
+
className: "ta-bubble"
|
|
5192
|
+
}, /* @__PURE__ */ React.createElement(Mentions, {
|
|
5193
|
+
text: message.text,
|
|
5194
|
+
agents: state.team.agents
|
|
5195
|
+
}))) : /* @__PURE__ */ React.createElement("div", {
|
|
5196
|
+
className: `tac-msg${first ? " tac-first" : ""}`
|
|
5197
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
5198
|
+
className: "tac-msg-face"
|
|
5199
|
+
}, first && (message.author === TA ? /* @__PURE__ */ React.createElement(Avatar, {
|
|
5200
|
+
size: 28
|
|
5201
|
+
}) : /* @__PURE__ */ React.createElement(AgentAvatar, {
|
|
5202
|
+
agent: agentOf(message.author),
|
|
5203
|
+
faces,
|
|
5204
|
+
size: 28,
|
|
5205
|
+
working: working.includes(message.author)
|
|
5206
|
+
}))), /* @__PURE__ */ React.createElement("div", {
|
|
5207
|
+
className: "tac-msg-col"
|
|
5208
|
+
}, first && /* @__PURE__ */ React.createElement("div", {
|
|
5209
|
+
className: "tac-msg-name"
|
|
5210
|
+
}, name(message.author), message.author === channel.members[0] && /* @__PURE__ */ React.createElement("span", {
|
|
5211
|
+
className: "tac-msg-lead"
|
|
5212
|
+
}, w.lead)), /* @__PURE__ */ React.createElement("div", {
|
|
5213
|
+
className: `tac-msg-bubble${message.failed ? " tac-failed" : ""}`,
|
|
5214
|
+
title: time(message.at)
|
|
5215
|
+
}, message.failed && /* @__PURE__ */ React.createElement("div", {
|
|
5216
|
+
className: "tac-msg-failed"
|
|
5217
|
+
}, w.failed), message.overBudget && /* @__PURE__ */ React.createElement("div", {
|
|
5218
|
+
className: "tac-msg-over"
|
|
5219
|
+
}, w.overBudget), /* @__PURE__ */ React.createElement(Markdown, {
|
|
5220
|
+
text: ChannelsText.markMentions(message.text, state.team.agents)
|
|
5221
|
+
})))))), working.length > 0 && /* @__PURE__ */ React.createElement("div", {
|
|
5222
|
+
className: "tac-live",
|
|
5223
|
+
role: "status"
|
|
4958
5224
|
}, /* @__PURE__ */ React.createElement("span", {
|
|
4959
|
-
className: "tac-
|
|
4960
|
-
},
|
|
4961
|
-
|
|
4962
|
-
|
|
4963
|
-
|
|
4964
|
-
|
|
5225
|
+
className: "tac-live-faces"
|
|
5226
|
+
}, working.map((id) => /* @__PURE__ */ React.createElement(Face, {
|
|
5227
|
+
key: id,
|
|
5228
|
+
face: faces.get(id) ?? 0,
|
|
5229
|
+
size: 18,
|
|
5230
|
+
working: true
|
|
5231
|
+
}))), ChannelWords.format(w.answeringNow, { name: working.map(name).join("、") })))), /* @__PURE__ */ React.createElement("div", {
|
|
5232
|
+
className: "tac-chat-bottom"
|
|
5233
|
+
}, /* @__PURE__ */ React.createElement(Composer, {
|
|
5234
|
+
placeholder: ChannelWords.format(w.placeholder, { channel: channel.name }),
|
|
5235
|
+
draft: channel.id,
|
|
5236
|
+
mentions: members.map((agent) => ({ name: agent.name, detail: agent.role.split(`
|
|
5237
|
+
`)[0] })),
|
|
5238
|
+
actions: [
|
|
5239
|
+
members.map(mention),
|
|
5240
|
+
[
|
|
5241
|
+
{
|
|
5242
|
+
key: "notice",
|
|
5243
|
+
label: w.noticeEdit,
|
|
5244
|
+
icon: ChannelViews.maybeIcon(pi, "Megaphone", null, 16),
|
|
5245
|
+
run: () => setNotice({ open: true, editing: true })
|
|
5246
|
+
},
|
|
5247
|
+
{
|
|
5248
|
+
key: "add",
|
|
5249
|
+
label: w.addMembers,
|
|
5250
|
+
icon: ChannelViews.maybeIcon(pi, "UserPlus", null, 16),
|
|
5251
|
+
run: () => {
|
|
5252
|
+
if (fixed) {
|
|
5253
|
+
ui.set({ channelId: fixed });
|
|
5254
|
+
}
|
|
5255
|
+
context.showMembers(true);
|
|
5256
|
+
}
|
|
5257
|
+
}
|
|
5258
|
+
],
|
|
5259
|
+
[
|
|
5260
|
+
{
|
|
5261
|
+
key: "make-extension",
|
|
5262
|
+
label: w.makeExtension,
|
|
5263
|
+
detail: w.makeExtensionDetail,
|
|
5264
|
+
icon: ChannelViews.maybeIcon(pi, "Sparkles", null, 16),
|
|
5265
|
+
run: () => void service.post(channel.id, w.makeExtensionAsk).catch((error) => pi.ui.notify(ChannelViews.message(error), "error"))
|
|
5266
|
+
}
|
|
5267
|
+
]
|
|
5268
|
+
],
|
|
5269
|
+
onSend: (text) => service.post(channel.id, text)
|
|
5270
|
+
})));
|
|
4965
5271
|
}
|
|
4966
5272
|
|
|
4967
5273
|
// web-src/tasks.tsx
|
|
@@ -5105,153 +5411,577 @@ function openScene(context, channel) {
|
|
|
5105
5411
|
}))
|
|
5106
5412
|
});
|
|
5107
5413
|
}
|
|
5108
|
-
function taskMenu(context, channel, working) {
|
|
5109
|
-
const { pi, service } = context;
|
|
5414
|
+
function taskMenu(context, channel, working) {
|
|
5415
|
+
const { pi, service } = context;
|
|
5416
|
+
const w = ChannelViews.words(pi);
|
|
5417
|
+
const icon = (name) => ChannelViews.icon(pi, name);
|
|
5418
|
+
const act = (action2) => () => {
|
|
5419
|
+
Promise.resolve().then(action2).catch((error) => pi.ui.notify(ChannelViews.message(error), "error"));
|
|
5420
|
+
};
|
|
5421
|
+
const temporary = membersOf(service.state.team, channel).filter((agent) => agent.temporary);
|
|
5422
|
+
return [
|
|
5423
|
+
working.length > 0 ? [
|
|
5424
|
+
{
|
|
5425
|
+
key: "stop",
|
|
5426
|
+
label: w.stopAnswering,
|
|
5427
|
+
icon: icon("Square"),
|
|
5428
|
+
run: act(async () => {
|
|
5429
|
+
await TeamActions.stop(context, working);
|
|
5430
|
+
pi.ui.notify(ChannelWords.format(w.stoppedChannel, { channel: channel.name }), "info");
|
|
5431
|
+
})
|
|
5432
|
+
}
|
|
5433
|
+
] : [],
|
|
5434
|
+
[
|
|
5435
|
+
{ key: "main", label: w.openInMain, icon: icon("ExternalLink"), run: () => context.showChannel(channel.id) },
|
|
5436
|
+
...temporary.length > 0 ? [
|
|
5437
|
+
{
|
|
5438
|
+
key: "keep",
|
|
5439
|
+
label: w.keepMembers,
|
|
5440
|
+
icon: icon("UserPlus"),
|
|
5441
|
+
run: act(async () => {
|
|
5442
|
+
await TeamActions.keep(context, temporary);
|
|
5443
|
+
pi.ui.notify(ChannelWords.format(w.keptMembers, { names: temporary.map((agent) => `@${agent.name}`).join("、") }), "info");
|
|
5444
|
+
})
|
|
5445
|
+
}
|
|
5446
|
+
] : []
|
|
5447
|
+
],
|
|
5448
|
+
[
|
|
5449
|
+
{
|
|
5450
|
+
key: "delete",
|
|
5451
|
+
label: w.deleteTask,
|
|
5452
|
+
icon: icon("Trash2"),
|
|
5453
|
+
danger: true,
|
|
5454
|
+
run: act(() => pi.ui.removeTasks([
|
|
5455
|
+
{
|
|
5456
|
+
title: taskTitle(channel),
|
|
5457
|
+
removeHint: ChannelWords.format(w.deleteTaskHint, { channel: channel.name }),
|
|
5458
|
+
remove: () => deleteTeam(context, channel)
|
|
5459
|
+
}
|
|
5460
|
+
]))
|
|
5461
|
+
}
|
|
5462
|
+
]
|
|
5463
|
+
];
|
|
5464
|
+
}
|
|
5465
|
+
var TeamActions;
|
|
5466
|
+
((TeamActions) => {
|
|
5467
|
+
async function stop(context, agentIds) {
|
|
5468
|
+
const { pi, service } = context;
|
|
5469
|
+
const files = new Set(service.state.team.agents.filter((agent) => agentIds.includes(agent.id) && agent.sessionFile).map((agent) => agent.sessionFile));
|
|
5470
|
+
const sessions = (await pi.server.listSessions()).filter((session) => session.sessionFile && files.has(session.sessionFile));
|
|
5471
|
+
await Promise.all(sessions.map((session) => pi.server.abort(session.sessionId)));
|
|
5472
|
+
}
|
|
5473
|
+
TeamActions.stop = stop;
|
|
5474
|
+
async function keep(context, agents) {
|
|
5475
|
+
for (const agent of agents) {
|
|
5476
|
+
await context.service.updateAgent(agent.id, { keep: true });
|
|
5477
|
+
}
|
|
5478
|
+
}
|
|
5479
|
+
TeamActions.keep = keep;
|
|
5480
|
+
})(TeamActions ||= {});
|
|
5481
|
+
|
|
5482
|
+
// web-src/channel-menu.tsx
|
|
5483
|
+
function download2(name, text) {
|
|
5484
|
+
const url = URL.createObjectURL(new Blob([text], { type: "text/markdown;charset=utf-8" }));
|
|
5485
|
+
const link = document.createElement("a");
|
|
5486
|
+
link.href = url;
|
|
5487
|
+
link.download = name;
|
|
5488
|
+
link.click();
|
|
5489
|
+
setTimeout(() => URL.revokeObjectURL(url), 1000);
|
|
5490
|
+
}
|
|
5491
|
+
async function deleteChannel(context, channel) {
|
|
5492
|
+
const w = ChannelViews.words(context.pi);
|
|
5493
|
+
const sure = await context.pi.ui.confirm(ChannelWords.format(w.confirmDelete, { channel: channel.name }), undefined, {
|
|
5494
|
+
confirmLabel: w.delete,
|
|
5495
|
+
danger: true
|
|
5496
|
+
});
|
|
5497
|
+
if (sure) {
|
|
5498
|
+
await context.service.deleteChannel(channel.id);
|
|
5499
|
+
}
|
|
5500
|
+
}
|
|
5501
|
+
async function renameChannel(context, channel) {
|
|
5502
|
+
const w = ChannelViews.words(context.pi);
|
|
5503
|
+
const name = await context.pi.ui.input(ChannelWords.format(w.renameChannel, { channel: channel.name }), w.channelNamePlaceholder, { value: channel.name });
|
|
5504
|
+
if (name !== undefined && name.trim() !== channel.name) {
|
|
5505
|
+
await context.service.updateChannel(channel.id, { name });
|
|
5506
|
+
}
|
|
5507
|
+
}
|
|
5508
|
+
async function editChannelTopic(context, channel) {
|
|
5509
|
+
const w = ChannelViews.words(context.pi);
|
|
5510
|
+
const topic = await context.pi.ui.input(w.editTopic, w.topicPlaceholder, { value: channel.topic ?? "" });
|
|
5511
|
+
if (topic !== undefined && topic.trim() !== (channel.topic ?? "")) {
|
|
5512
|
+
await context.service.updateChannel(channel.id, { topic });
|
|
5513
|
+
}
|
|
5514
|
+
}
|
|
5515
|
+
function ChannelMenu({ context, channel, working }) {
|
|
5516
|
+
const { pi, service, ui } = context;
|
|
5517
|
+
const { fresh } = useUi(ui);
|
|
5518
|
+
const w = ChannelViews.words(pi);
|
|
5519
|
+
const icon = (name) => ChannelViews.maybeIcon(pi, name, null, 15);
|
|
5520
|
+
const act = (action2) => () => {
|
|
5521
|
+
Promise.resolve().then(action2).catch((error) => pi.ui.notify(ChannelViews.message(error), "error"));
|
|
5522
|
+
};
|
|
5523
|
+
const unread = fresh.includes(channel.id);
|
|
5524
|
+
const pin = act(() => service.updateChannel(channel.id, { pinned: !channel.pinned }));
|
|
5525
|
+
const markRead = act(() => ui.set({ fresh: unread ? fresh.filter((id) => id !== channel.id) : [...fresh, channel.id] }));
|
|
5526
|
+
const rename = act(() => renameChannel(context, channel));
|
|
5527
|
+
const editTopic = act(() => editChannelTopic(context, channel));
|
|
5528
|
+
const members = act(() => {
|
|
5529
|
+
context.showChannel(channel.id);
|
|
5530
|
+
context.showMembers();
|
|
5531
|
+
});
|
|
5532
|
+
const stop = act(async () => {
|
|
5533
|
+
await TeamActions.stop(context, working);
|
|
5534
|
+
pi.ui.notify(ChannelWords.format(w.stoppedChannel, { channel: channel.name }), "info");
|
|
5535
|
+
});
|
|
5536
|
+
const exportMarkdown = act(async () => {
|
|
5537
|
+
const messages = await service.messages(channel.id);
|
|
5538
|
+
if (!messages.some((message) => message.text.trim())) {
|
|
5539
|
+
pi.ui.notify(ChannelWords.format(w.noMessagesToExport, { channel: channel.name }), "info");
|
|
5540
|
+
return;
|
|
5541
|
+
}
|
|
5542
|
+
download2(`${channel.name}.md`, ChannelsText.channelMarkdown(service.state.team, channel, messages, { user: w.you, ta: w.ta }));
|
|
5543
|
+
});
|
|
5544
|
+
const remove = act(() => deleteChannel(context, channel));
|
|
5545
|
+
const budget = ChannelsUtil.budgetOf(channel);
|
|
5546
|
+
const budgets = [
|
|
5547
|
+
["short", w.budgetShort],
|
|
5548
|
+
["normal", w.budgetNormal],
|
|
5549
|
+
["long", w.budgetLong]
|
|
5550
|
+
];
|
|
5551
|
+
const budgetItem = ([key, label]) => ({
|
|
5552
|
+
key: `budget-${key}`,
|
|
5553
|
+
label: ChannelWords.format(label, { n: String(BUDGETS[key].replies) }),
|
|
5554
|
+
icon: key === budget ? icon("Check") : /* @__PURE__ */ React.createElement("span", {
|
|
5555
|
+
className: "tac-menu-blank"
|
|
5556
|
+
}),
|
|
5557
|
+
run: act(() => key !== budget && service.updateChannel(channel.id, { budget: key }))
|
|
5558
|
+
});
|
|
5559
|
+
const item = (key, label, glyph, run, options = {}) => ({
|
|
5560
|
+
key,
|
|
5561
|
+
label,
|
|
5562
|
+
icon: icon(glyph),
|
|
5563
|
+
run,
|
|
5564
|
+
...options
|
|
5565
|
+
});
|
|
5566
|
+
return /* @__PURE__ */ React.createElement(MoreMenu, {
|
|
5567
|
+
pi,
|
|
5568
|
+
label: channel.name,
|
|
5569
|
+
items: () => [
|
|
5570
|
+
[
|
|
5571
|
+
item("pin", channel.pinned ? w.unpin : w.pin, channel.pinned ? "PinOff" : "Pin", pin),
|
|
5572
|
+
item("read", unread ? w.markRead : w.markUnread, unread ? "MessageSquareText" : "MessageSquareDot", markRead)
|
|
5573
|
+
],
|
|
5574
|
+
[item("rename", w.rename, "Pencil", rename), item("topic", w.editTopic, "Text", editTopic), item("members", w.showMembers, "Users", members)],
|
|
5575
|
+
budgets.map(budgetItem),
|
|
5576
|
+
[item("stop", w.stopAnswering, "Square", stop, { disabled: working.length === 0 }), item("export", w.exportChat, "Download", exportMarkdown)],
|
|
5577
|
+
[item("delete", w.deleteChannel, "Trash2", remove, { danger: true })]
|
|
5578
|
+
]
|
|
5579
|
+
});
|
|
5580
|
+
}
|
|
5581
|
+
|
|
5582
|
+
// web-src/members.tsx
|
|
5583
|
+
function MembersView({ context }) {
|
|
5584
|
+
const { pi, service, ui } = context;
|
|
5585
|
+
const state = useChannels(service);
|
|
5586
|
+
const { channelId, adding } = useUi(ui);
|
|
5587
|
+
const faces = useFaces(state.team);
|
|
5588
|
+
const w = ChannelViews.words(pi);
|
|
5589
|
+
const channel = state.team.channels.find((candidate) => candidate.id === channelId);
|
|
5590
|
+
if (!channel) {
|
|
5591
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
5592
|
+
className: "tac-view tac-members"
|
|
5593
|
+
}, state.loaded && /* @__PURE__ */ React.createElement(pi.ui.Empty, {
|
|
5594
|
+
title: w.noChannel
|
|
5595
|
+
}));
|
|
5596
|
+
}
|
|
5597
|
+
return adding ? /* @__PURE__ */ React.createElement(MemberPicker, {
|
|
5598
|
+
key: channel.id,
|
|
5599
|
+
context,
|
|
5600
|
+
team: state.team,
|
|
5601
|
+
channel,
|
|
5602
|
+
faces
|
|
5603
|
+
}) : /* @__PURE__ */ React.createElement(MemberList, {
|
|
5604
|
+
key: channel.id,
|
|
5605
|
+
context,
|
|
5606
|
+
team: state.team,
|
|
5607
|
+
channel,
|
|
5608
|
+
faces,
|
|
5609
|
+
working: state.working[channel.id] ?? []
|
|
5610
|
+
});
|
|
5611
|
+
}
|
|
5612
|
+
function MemberList({ context, team, channel, faces, working }) {
|
|
5613
|
+
const { pi, service, ui } = context;
|
|
5110
5614
|
const w = ChannelViews.words(pi);
|
|
5111
|
-
const
|
|
5112
|
-
const
|
|
5113
|
-
|
|
5615
|
+
const [busy, setBusy] = React.useState();
|
|
5616
|
+
const [confirming, setConfirming] = React.useState(false);
|
|
5617
|
+
const [editing, setEditing] = React.useState();
|
|
5618
|
+
const UserPlus = ChannelViews.icon(pi, "UserPlus");
|
|
5619
|
+
const Contact = ChannelViews.icon(pi, "Contact");
|
|
5620
|
+
const Crown = ChannelViews.icon(pi, "Crown");
|
|
5621
|
+
const BellOff = ChannelViews.icon(pi, "BellOff");
|
|
5622
|
+
const RotateCcw = ChannelViews.icon(pi, "RotateCcw");
|
|
5623
|
+
const X = ChannelViews.icon(pi, "X");
|
|
5624
|
+
const Trash = ChannelViews.icon(pi, "Trash2");
|
|
5625
|
+
const Sliders = pi.ui.icons.SlidersHorizontal ?? ChannelViews.icon(pi, "Pencil");
|
|
5626
|
+
const members = membersOf(team, channel);
|
|
5627
|
+
const models = new Set(members.map((agent) => agent.model ?? ""));
|
|
5628
|
+
const shared = models.size === 1 ? [...models][0] : undefined;
|
|
5629
|
+
const muted = channel.muted ?? [];
|
|
5630
|
+
const run = (key, action2) => {
|
|
5631
|
+
setBusy(key);
|
|
5632
|
+
action2().catch((error) => pi.ui.notify(ChannelViews.message(error), "error")).finally(() => setBusy(undefined));
|
|
5114
5633
|
};
|
|
5115
|
-
const
|
|
5116
|
-
|
|
5117
|
-
|
|
5118
|
-
|
|
5119
|
-
|
|
5120
|
-
|
|
5121
|
-
|
|
5122
|
-
|
|
5123
|
-
|
|
5124
|
-
|
|
5125
|
-
|
|
5126
|
-
|
|
5127
|
-
|
|
5128
|
-
|
|
5129
|
-
|
|
5130
|
-
|
|
5131
|
-
|
|
5132
|
-
|
|
5133
|
-
|
|
5134
|
-
|
|
5135
|
-
|
|
5136
|
-
|
|
5137
|
-
|
|
5138
|
-
|
|
5139
|
-
|
|
5140
|
-
|
|
5141
|
-
|
|
5142
|
-
|
|
5143
|
-
|
|
5144
|
-
|
|
5145
|
-
|
|
5146
|
-
|
|
5147
|
-
|
|
5148
|
-
|
|
5149
|
-
|
|
5150
|
-
|
|
5151
|
-
|
|
5152
|
-
|
|
5153
|
-
|
|
5154
|
-
|
|
5155
|
-
|
|
5156
|
-
|
|
5157
|
-
|
|
5634
|
+
const change = (agent, kind) => run(`${kind}:${agent.id}`, () => service.changeMember(channel.id, agent.id, kind));
|
|
5635
|
+
const reset = (agent) => run(`reset:${agent.id}`, async () => {
|
|
5636
|
+
await service.resetAgent(agent.id);
|
|
5637
|
+
context.sessions.delete(agent.id);
|
|
5638
|
+
pi.ui.notify(ChannelWords.format(w.resetDone, { name: agent.name }), "info");
|
|
5639
|
+
});
|
|
5640
|
+
const remove = () => run("delete", () => service.deleteChannel(channel.id));
|
|
5641
|
+
const setModel = (model) => run("model", async () => {
|
|
5642
|
+
await service.setChannelModel(channel.id, model);
|
|
5643
|
+
pi.ui.notify(ChannelWords.format(w.modelSwitched, { count: String(members.length) }), "info");
|
|
5644
|
+
});
|
|
5645
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
5646
|
+
className: "tac-view tac-members"
|
|
5647
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
5648
|
+
className: "tac-members-scroll"
|
|
5649
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
5650
|
+
className: "tac-members-top"
|
|
5651
|
+
}, /* @__PURE__ */ React.createElement(RoomFace, {
|
|
5652
|
+
members,
|
|
5653
|
+
faces,
|
|
5654
|
+
size: 44,
|
|
5655
|
+
working
|
|
5656
|
+
}), /* @__PURE__ */ React.createElement("span", {
|
|
5657
|
+
className: "tac-members-title"
|
|
5658
|
+
}, /* @__PURE__ */ React.createElement("strong", null, channel.name), /* @__PURE__ */ React.createElement("span", null, channel.topic ?? ChannelWords.format(w.memberCount, { count: String(members.length) })))), /* @__PURE__ */ React.createElement("div", {
|
|
5659
|
+
className: "tac-members-label"
|
|
5660
|
+
}, /* @__PURE__ */ React.createElement("span", null, w.members, " · ", members.length), /* @__PURE__ */ React.createElement("span", {
|
|
5661
|
+
className: "tac-members-model",
|
|
5662
|
+
title: w.sameModelHint
|
|
5663
|
+
}, /* @__PURE__ */ React.createElement("span", null, w.sameModel), /* @__PURE__ */ React.createElement(pi.ui.ModelPicker, {
|
|
5664
|
+
value: shared ?? "",
|
|
5665
|
+
defaultLabel: shared === undefined ? w.mixedModels : undefined,
|
|
5666
|
+
label: w.sameModelHint,
|
|
5667
|
+
disabled: !!busy,
|
|
5668
|
+
onChange: setModel
|
|
5669
|
+
}))), /* @__PURE__ */ React.createElement("button", {
|
|
5670
|
+
type: "button",
|
|
5671
|
+
className: "tac-member-main",
|
|
5672
|
+
onClick: () => ui.set({ adding: true })
|
|
5673
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
5674
|
+
className: "tac-member-plus"
|
|
5675
|
+
}, /* @__PURE__ */ React.createElement(UserPlus, {
|
|
5676
|
+
size: 16
|
|
5677
|
+
})), /* @__PURE__ */ React.createElement("span", {
|
|
5678
|
+
className: "tac-member-text"
|
|
5679
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
5680
|
+
className: "tac-member-name"
|
|
5681
|
+
}, w.addMembers))), pi.rooms && channel.by !== "ta" && /* @__PURE__ */ React.createElement("button", {
|
|
5682
|
+
type: "button",
|
|
5683
|
+
className: "tac-member-main",
|
|
5684
|
+
onClick: () => openShareGroup(context, channel)
|
|
5685
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
5686
|
+
className: "tac-member-plus"
|
|
5687
|
+
}, /* @__PURE__ */ React.createElement(Contact, {
|
|
5688
|
+
size: 16
|
|
5689
|
+
})), /* @__PURE__ */ React.createElement("span", {
|
|
5690
|
+
className: "tac-member-text"
|
|
5691
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
5692
|
+
className: "tac-member-name"
|
|
5693
|
+
}, w.inviteFriends))), members.map((agent, index) => {
|
|
5694
|
+
const lead = index === 0;
|
|
5695
|
+
const off = muted.includes(agent.id);
|
|
5696
|
+
const answering = working.includes(agent.id);
|
|
5697
|
+
const detail = answering ? w.replying : off ? w.muted : agent.role.split(`
|
|
5698
|
+
`)[0] ?? "";
|
|
5699
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
5700
|
+
key: agent.id,
|
|
5701
|
+
className: `tac-member${off ? " tac-muted" : ""}`
|
|
5702
|
+
}, /* @__PURE__ */ React.createElement("button", {
|
|
5703
|
+
type: "button",
|
|
5704
|
+
className: "tac-member-main",
|
|
5705
|
+
title: `${w.open}
|
|
5706
|
+
${agent.role}`,
|
|
5707
|
+
onClick: () => ChannelViews.openAgent(context, agent.id).catch((error) => pi.ui.notify(ChannelViews.message(error), "error"))
|
|
5708
|
+
}, /* @__PURE__ */ React.createElement(AgentAvatar, {
|
|
5709
|
+
agent,
|
|
5710
|
+
faces,
|
|
5711
|
+
size: 32,
|
|
5712
|
+
working: answering
|
|
5713
|
+
}), /* @__PURE__ */ React.createElement("span", {
|
|
5714
|
+
className: "tac-member-text"
|
|
5715
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
5716
|
+
className: "tac-member-name"
|
|
5717
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
5718
|
+
className: "tac-member-label"
|
|
5719
|
+
}, agent.name), lead && /* @__PURE__ */ React.createElement("span", {
|
|
5720
|
+
className: "tac-lead",
|
|
5721
|
+
title: w.leadHint
|
|
5722
|
+
}, /* @__PURE__ */ React.createElement(Crown, {
|
|
5723
|
+
size: 11
|
|
5724
|
+
}), /* @__PURE__ */ React.createElement("span", null, w.lead)), agent.temporary && /* @__PURE__ */ React.createElement("span", {
|
|
5725
|
+
className: "tac-temporary",
|
|
5726
|
+
title: w.temporary
|
|
5727
|
+
}, w.temporaryTag)), /* @__PURE__ */ React.createElement("span", {
|
|
5728
|
+
className: `tac-member-detail${answering ? " tac-live" : ""}`
|
|
5729
|
+
}, detail))), /* @__PURE__ */ React.createElement("span", {
|
|
5730
|
+
className: "tac-member-actions"
|
|
5731
|
+
}, /* @__PURE__ */ React.createElement("button", {
|
|
5732
|
+
type: "button",
|
|
5733
|
+
className: "tac-action",
|
|
5734
|
+
title: w.agentSettings,
|
|
5735
|
+
"aria-label": `${w.agentSettings} · ${agent.name}`,
|
|
5736
|
+
disabled: !!busy,
|
|
5737
|
+
onClick: () => setEditing(agent)
|
|
5738
|
+
}, /* @__PURE__ */ React.createElement(Sliders, {
|
|
5739
|
+
size: 15
|
|
5740
|
+
})), agent.temporary && /* @__PURE__ */ React.createElement("button", {
|
|
5741
|
+
type: "button",
|
|
5742
|
+
className: "tac-action",
|
|
5743
|
+
title: w.keep,
|
|
5744
|
+
"aria-label": w.keep,
|
|
5745
|
+
disabled: !!busy,
|
|
5746
|
+
onClick: () => service.updateAgent(agent.id, { keep: true }).then(() => pi.ui.notify(ChannelWords.format(w.kept, { name: agent.name }), "info")).catch((error) => pi.ui.notify(ChannelViews.message(error), "error"))
|
|
5747
|
+
}, /* @__PURE__ */ React.createElement(UserPlus, {
|
|
5748
|
+
size: 15
|
|
5749
|
+
})), !lead && /* @__PURE__ */ React.createElement("button", {
|
|
5750
|
+
type: "button",
|
|
5751
|
+
className: "tac-action",
|
|
5752
|
+
title: w.makeLead,
|
|
5753
|
+
"aria-label": w.makeLead,
|
|
5754
|
+
disabled: !!busy,
|
|
5755
|
+
onClick: () => change(agent, "lead")
|
|
5756
|
+
}, /* @__PURE__ */ React.createElement(Crown, {
|
|
5757
|
+
size: 15
|
|
5758
|
+
})), /* @__PURE__ */ React.createElement("button", {
|
|
5759
|
+
type: "button",
|
|
5760
|
+
className: `tac-action${off ? " tac-on" : ""}`,
|
|
5761
|
+
title: off ? w.unmute : w.mute,
|
|
5762
|
+
"aria-label": off ? w.unmute : w.mute,
|
|
5763
|
+
"aria-pressed": off,
|
|
5764
|
+
disabled: !!busy,
|
|
5765
|
+
onClick: () => change(agent, off ? "unmute" : "mute")
|
|
5766
|
+
}, /* @__PURE__ */ React.createElement(BellOff, {
|
|
5767
|
+
size: 15
|
|
5768
|
+
})), /* @__PURE__ */ React.createElement("button", {
|
|
5769
|
+
type: "button",
|
|
5770
|
+
className: "tac-action",
|
|
5771
|
+
title: w.reset,
|
|
5772
|
+
"aria-label": w.reset,
|
|
5773
|
+
disabled: !!busy,
|
|
5774
|
+
onClick: () => reset(agent)
|
|
5775
|
+
}, /* @__PURE__ */ React.createElement(RotateCcw, {
|
|
5776
|
+
size: 15
|
|
5777
|
+
})), /* @__PURE__ */ React.createElement("button", {
|
|
5778
|
+
type: "button",
|
|
5779
|
+
className: "tac-action",
|
|
5780
|
+
title: members.length === 1 ? w.onlyMember : w.remove,
|
|
5781
|
+
"aria-label": w.remove,
|
|
5782
|
+
disabled: !!busy || members.length === 1,
|
|
5783
|
+
onClick: () => change(agent, "remove")
|
|
5784
|
+
}, /* @__PURE__ */ React.createElement(X, {
|
|
5785
|
+
size: 15
|
|
5786
|
+
}))));
|
|
5787
|
+
}), /* @__PURE__ */ React.createElement(ChannelSettings, {
|
|
5788
|
+
context,
|
|
5789
|
+
channel
|
|
5790
|
+
})), editing && /* @__PURE__ */ React.createElement(AgentSettingsDialog, {
|
|
5791
|
+
context,
|
|
5792
|
+
agent: editing,
|
|
5793
|
+
onClose: () => setEditing(undefined)
|
|
5794
|
+
}), /* @__PURE__ */ React.createElement("div", {
|
|
5795
|
+
className: "tac-members-foot"
|
|
5796
|
+
}, confirming ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("span", {
|
|
5797
|
+
className: "tac-members-ask"
|
|
5798
|
+
}, ChannelWords.format(w.confirmDelete, { channel: channel.name })), /* @__PURE__ */ React.createElement("button", {
|
|
5799
|
+
type: "button",
|
|
5800
|
+
className: "tac-button",
|
|
5801
|
+
onClick: () => setConfirming(false)
|
|
5802
|
+
}, w.cancel), /* @__PURE__ */ React.createElement("button", {
|
|
5803
|
+
type: "button",
|
|
5804
|
+
className: busy === "delete" ? "tac-button tac-danger ta-busy" : "tac-button tac-danger",
|
|
5805
|
+
disabled: !!busy,
|
|
5806
|
+
onClick: remove
|
|
5807
|
+
}, w.delete, busy === "delete" && /* @__PURE__ */ React.createElement("span", {
|
|
5808
|
+
className: "ta-spinner ta-busy-mark"
|
|
5809
|
+
}))) : /* @__PURE__ */ React.createElement("button", {
|
|
5810
|
+
type: "button",
|
|
5811
|
+
className: "tac-link tac-danger",
|
|
5812
|
+
onClick: () => setConfirming(true)
|
|
5813
|
+
}, /* @__PURE__ */ React.createElement(Trash, {
|
|
5814
|
+
size: 14
|
|
5815
|
+
}), w.deleteChannel)));
|
|
5158
5816
|
}
|
|
5159
|
-
|
|
5160
|
-
|
|
5161
|
-
|
|
5162
|
-
|
|
5163
|
-
|
|
5164
|
-
|
|
5165
|
-
|
|
5166
|
-
|
|
5167
|
-
|
|
5168
|
-
|
|
5169
|
-
|
|
5170
|
-
|
|
5171
|
-
|
|
5172
|
-
}
|
|
5173
|
-
|
|
5174
|
-
})
|
|
5175
|
-
|
|
5176
|
-
|
|
5177
|
-
|
|
5178
|
-
|
|
5179
|
-
|
|
5180
|
-
|
|
5181
|
-
|
|
5182
|
-
|
|
5183
|
-
|
|
5817
|
+
function ChannelSettings({ context, channel }) {
|
|
5818
|
+
const { pi, service } = context;
|
|
5819
|
+
const w = ChannelViews.words(pi);
|
|
5820
|
+
const Chevron = ChannelViews.icon(pi, "ChevronRight");
|
|
5821
|
+
const fail = (error) => pi.ui.notify(ChannelViews.message(error), "error");
|
|
5822
|
+
const row = (label, value, edit) => /* @__PURE__ */ React.createElement("button", {
|
|
5823
|
+
type: "button",
|
|
5824
|
+
className: "tac-setting",
|
|
5825
|
+
onClick: () => edit().catch(fail)
|
|
5826
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
5827
|
+
className: "tac-setting-label"
|
|
5828
|
+
}, label), /* @__PURE__ */ React.createElement("span", {
|
|
5829
|
+
className: "tac-setting-value"
|
|
5830
|
+
}, value), /* @__PURE__ */ React.createElement(Chevron, {
|
|
5831
|
+
size: 15
|
|
5832
|
+
}));
|
|
5833
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", {
|
|
5834
|
+
className: "tac-members-sep"
|
|
5835
|
+
}), row(w.channelName, channel.name, () => renameChannel(context, channel)), row(w.topic, channel.topic ?? w.notSet, () => editChannelTopic(context, channel)), /* @__PURE__ */ React.createElement("div", {
|
|
5836
|
+
className: "tac-setting"
|
|
5837
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
5838
|
+
className: "tac-setting-label"
|
|
5839
|
+
}, w.pinChat), /* @__PURE__ */ React.createElement(pi.ui.Switch, {
|
|
5840
|
+
checked: !!channel.pinned,
|
|
5841
|
+
label: w.pinChat,
|
|
5842
|
+
onChange: (pinned) => service.updateChannel(channel.id, { pinned }).catch(fail)
|
|
5843
|
+
})), /* @__PURE__ */ React.createElement(ChannelLimits, {
|
|
5844
|
+
context,
|
|
5845
|
+
channel
|
|
5846
|
+
}));
|
|
5184
5847
|
}
|
|
5185
|
-
|
|
5186
|
-
const
|
|
5187
|
-
const
|
|
5188
|
-
|
|
5189
|
-
|
|
5190
|
-
|
|
5191
|
-
|
|
5192
|
-
|
|
5193
|
-
|
|
5848
|
+
function ChannelLimits({ context, channel }) {
|
|
5849
|
+
const { pi, service } = context;
|
|
5850
|
+
const w = ChannelViews.words(pi);
|
|
5851
|
+
const { limits, channels } = useLimits(pi);
|
|
5852
|
+
const fail = (error) => pi.ui.notify(ChannelViews.message(error), "error");
|
|
5853
|
+
const budget = ChannelsUtil.budgetOf(channel);
|
|
5854
|
+
const budgets = [
|
|
5855
|
+
["short", w.budgetShortWord],
|
|
5856
|
+
["normal", w.budgetNormalWord],
|
|
5857
|
+
["long", w.budgetLongWord]
|
|
5858
|
+
];
|
|
5859
|
+
const daily = [null, ...LIMIT_CHOICES.channelDay];
|
|
5860
|
+
const own = channel.dailyLimit ?? null;
|
|
5861
|
+
const limit = channel.dailyLimit ?? limits.channelDay;
|
|
5862
|
+
const spent = channels[channel.id] ?? 0;
|
|
5863
|
+
const segment = (label, values, current, word, pick) => /* @__PURE__ */ React.createElement("fieldset", {
|
|
5864
|
+
className: "ta-segmented tac-limit-segments",
|
|
5865
|
+
"aria-label": label
|
|
5866
|
+
}, values.map((value) => /* @__PURE__ */ React.createElement("button", {
|
|
5867
|
+
key: String(value),
|
|
5868
|
+
type: "button",
|
|
5869
|
+
"aria-pressed": value === current,
|
|
5870
|
+
className: value === current ? "ta-on" : "",
|
|
5871
|
+
onClick: () => value !== current && pick(value)
|
|
5872
|
+
}, word(value))));
|
|
5873
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
5874
|
+
className: "tac-limits"
|
|
5875
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
5876
|
+
className: "tac-limit-head"
|
|
5877
|
+
}, /* @__PURE__ */ React.createElement("span", null, w.talkLength)), segment(w.talkLength, budgets.map(([key]) => key), budget, (key) => budgets.find(([other]) => other === key)?.[1] ?? key, (key) => service.updateChannel(channel.id, { budget: key }).catch(fail)), /* @__PURE__ */ React.createElement("div", {
|
|
5878
|
+
className: "tac-limit-head"
|
|
5879
|
+
}, /* @__PURE__ */ React.createElement("span", null, w.dailyLimit), /* @__PURE__ */ React.createElement("span", {
|
|
5880
|
+
className: "tac-limit-spent"
|
|
5881
|
+
}, ChannelWords.format(limit > 0 ? w.dailySpentOf : w.dailySpent, {
|
|
5882
|
+
spent: amount(pi, spent) === w.noLimit ? "0" : amount(pi, spent),
|
|
5883
|
+
limit: amount(pi, limit)
|
|
5884
|
+
}))), segment(w.dailyLimit, daily, own, (value) => value === null ? w.limitDefault : amount(pi, value), (value) => service.updateChannel(channel.id, { dailyLimit: value }).catch(fail)));
|
|
5194
5885
|
}
|
|
5195
|
-
function
|
|
5886
|
+
function MemberPicker({ context, team, channel, faces }) {
|
|
5196
5887
|
const { pi, service, ui } = context;
|
|
5197
|
-
const { fresh } = useUi(ui);
|
|
5198
5888
|
const w = ChannelViews.words(pi);
|
|
5199
|
-
const
|
|
5200
|
-
const
|
|
5201
|
-
|
|
5202
|
-
|
|
5203
|
-
const
|
|
5204
|
-
const
|
|
5205
|
-
const
|
|
5206
|
-
const
|
|
5207
|
-
|
|
5208
|
-
|
|
5209
|
-
|
|
5210
|
-
|
|
5211
|
-
|
|
5212
|
-
|
|
5213
|
-
|
|
5214
|
-
|
|
5215
|
-
|
|
5216
|
-
|
|
5217
|
-
|
|
5218
|
-
|
|
5219
|
-
|
|
5220
|
-
|
|
5221
|
-
|
|
5222
|
-
|
|
5223
|
-
|
|
5224
|
-
|
|
5225
|
-
|
|
5226
|
-
|
|
5227
|
-
|
|
5228
|
-
|
|
5229
|
-
|
|
5230
|
-
|
|
5231
|
-
|
|
5232
|
-
|
|
5233
|
-
}
|
|
5234
|
-
|
|
5235
|
-
|
|
5236
|
-
|
|
5237
|
-
|
|
5238
|
-
|
|
5239
|
-
|
|
5240
|
-
|
|
5241
|
-
})
|
|
5242
|
-
|
|
5243
|
-
|
|
5244
|
-
|
|
5245
|
-
|
|
5246
|
-
|
|
5247
|
-
|
|
5248
|
-
|
|
5249
|
-
|
|
5250
|
-
|
|
5251
|
-
|
|
5252
|
-
|
|
5253
|
-
|
|
5254
|
-
|
|
5889
|
+
const [query, setQuery] = React.useState("");
|
|
5890
|
+
const [picked, setPicked] = React.useState([]);
|
|
5891
|
+
const ArrowLeft = ChannelViews.icon(pi, "ArrowLeft");
|
|
5892
|
+
const Search = ChannelViews.icon(pi, "Search");
|
|
5893
|
+
const Check = ChannelViews.icon(pi, "Check");
|
|
5894
|
+
const UserPlus = ChannelViews.icon(pi, "UserPlus");
|
|
5895
|
+
const back = () => ui.set({ adding: false });
|
|
5896
|
+
const { busy, error, submit } = useSubmit(() => service.addMembers(channel.id, picked), back);
|
|
5897
|
+
const others = team.agents.filter((agent) => !channel.members.includes(agent.id));
|
|
5898
|
+
const shown = others.filter((agent) => SidebarUtil.matches(query, agent.name, agent.role));
|
|
5899
|
+
const toggle = (id) => setPicked(picked.includes(id) ? picked.filter((other) => other !== id) : [...picked, id]);
|
|
5900
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
5901
|
+
className: "tac-view tac-members"
|
|
5902
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
5903
|
+
className: "tac-members-head"
|
|
5904
|
+
}, /* @__PURE__ */ React.createElement("button", {
|
|
5905
|
+
type: "button",
|
|
5906
|
+
className: "tac-action",
|
|
5907
|
+
title: w.back,
|
|
5908
|
+
"aria-label": w.back,
|
|
5909
|
+
onClick: back
|
|
5910
|
+
}, /* @__PURE__ */ React.createElement(ArrowLeft, {
|
|
5911
|
+
size: 16
|
|
5912
|
+
})), /* @__PURE__ */ React.createElement("strong", null, w.addMembers)), /* @__PURE__ */ React.createElement("label", {
|
|
5913
|
+
className: "tac-search tac-members-search"
|
|
5914
|
+
}, /* @__PURE__ */ React.createElement(Search, {
|
|
5915
|
+
size: 14
|
|
5916
|
+
}), /* @__PURE__ */ React.createElement("input", {
|
|
5917
|
+
value: query,
|
|
5918
|
+
placeholder: w.findAgent,
|
|
5919
|
+
"aria-label": w.findAgent,
|
|
5920
|
+
onChange: (event) => setQuery(event.target.value)
|
|
5921
|
+
})), /* @__PURE__ */ React.createElement("div", {
|
|
5922
|
+
className: "tac-members-scroll"
|
|
5923
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
5924
|
+
className: "tac-members-label"
|
|
5925
|
+
}, ChannelWords.format(w.canAdd, { count: String(others.length) })), others.length === 0 && /* @__PURE__ */ React.createElement(pi.ui.Empty, {
|
|
5926
|
+
compact: true,
|
|
5927
|
+
title: w.allMembers
|
|
5928
|
+
}), others.length > 0 && shown.length === 0 && /* @__PURE__ */ React.createElement(pi.ui.Empty, {
|
|
5929
|
+
compact: true,
|
|
5930
|
+
title: w.noMatch
|
|
5931
|
+
}), shown.map((agent) => {
|
|
5932
|
+
const on = picked.includes(agent.id);
|
|
5933
|
+
return /* @__PURE__ */ React.createElement("button", {
|
|
5934
|
+
key: agent.id,
|
|
5935
|
+
type: "button",
|
|
5936
|
+
className: `tac-member-main tac-pick${on ? " tac-on" : ""}`,
|
|
5937
|
+
"aria-pressed": on,
|
|
5938
|
+
title: agent.role,
|
|
5939
|
+
onClick: () => toggle(agent.id)
|
|
5940
|
+
}, /* @__PURE__ */ React.createElement(AgentAvatar, {
|
|
5941
|
+
agent,
|
|
5942
|
+
faces,
|
|
5943
|
+
size: 32
|
|
5944
|
+
}), /* @__PURE__ */ React.createElement("span", {
|
|
5945
|
+
className: "tac-member-text"
|
|
5946
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
5947
|
+
className: "tac-member-name"
|
|
5948
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
5949
|
+
className: "tac-member-label"
|
|
5950
|
+
}, agent.name)), /* @__PURE__ */ React.createElement("span", {
|
|
5951
|
+
className: "tac-member-detail"
|
|
5952
|
+
}, agent.role.split(`
|
|
5953
|
+
`)[0])), /* @__PURE__ */ React.createElement("span", {
|
|
5954
|
+
className: "tac-check"
|
|
5955
|
+
}, on && /* @__PURE__ */ React.createElement(Check, {
|
|
5956
|
+
size: 12,
|
|
5957
|
+
strokeWidth: 3
|
|
5958
|
+
})));
|
|
5959
|
+
}), /* @__PURE__ */ React.createElement("div", {
|
|
5960
|
+
className: "tac-members-sep"
|
|
5961
|
+
}), /* @__PURE__ */ React.createElement("button", {
|
|
5962
|
+
type: "button",
|
|
5963
|
+
className: "tac-member-main",
|
|
5964
|
+
onClick: () => newAgent(context)
|
|
5965
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
5966
|
+
className: "tac-member-plus"
|
|
5967
|
+
}, /* @__PURE__ */ React.createElement(UserPlus, {
|
|
5968
|
+
size: 16
|
|
5969
|
+
})), /* @__PURE__ */ React.createElement("span", {
|
|
5970
|
+
className: "tac-member-text"
|
|
5971
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
5972
|
+
className: "tac-member-name"
|
|
5973
|
+
}, w.newAgent)))), error && /* @__PURE__ */ React.createElement("div", {
|
|
5974
|
+
className: "tac-empty tac-error"
|
|
5975
|
+
}, error), /* @__PURE__ */ React.createElement("div", {
|
|
5976
|
+
className: "tac-members-foot"
|
|
5977
|
+
}, /* @__PURE__ */ React.createElement("button", {
|
|
5978
|
+
type: "button",
|
|
5979
|
+
className: busy ? "tac-button tac-primary tac-wide ta-busy" : "tac-button tac-primary tac-wide",
|
|
5980
|
+
disabled: busy || picked.length === 0,
|
|
5981
|
+
onClick: submit
|
|
5982
|
+
}, picked.length > 0 ? ChannelWords.format(w.addCount, { count: String(picked.length) }) : w.add, busy && /* @__PURE__ */ React.createElement("span", {
|
|
5983
|
+
className: "ta-spinner ta-busy-mark ta-on-brand"
|
|
5984
|
+
}))));
|
|
5255
5985
|
}
|
|
5256
5986
|
|
|
5257
5987
|
// web-src/sidebar-hooks.ts
|
|
@@ -5617,13 +6347,13 @@ function TaskItem({ context, task, selection, seen }) {
|
|
|
5617
6347
|
})
|
|
5618
6348
|
});
|
|
5619
6349
|
}
|
|
5620
|
-
function HomeRow({ pi, item }) {
|
|
6350
|
+
function HomeRow({ pi, item, selected = false }) {
|
|
5621
6351
|
const [opening, setOpening] = React.useState(false);
|
|
5622
6352
|
const Glyph = item.icon;
|
|
5623
6353
|
const Own = item.face;
|
|
5624
6354
|
const open = () => {
|
|
5625
6355
|
setOpening(true);
|
|
5626
|
-
Promise.resolve().then(() => item.open()).catch((error) => pi.ui.notify(ChannelViews.message(error), "error")).finally(() => setOpening(false));
|
|
6356
|
+
Promise.resolve().then(() => pi.ui.openHome ? pi.ui.openHome(item) : item.open()).catch((error) => pi.ui.notify(ChannelViews.message(error), "error")).finally(() => setOpening(false));
|
|
5627
6357
|
};
|
|
5628
6358
|
return /* @__PURE__ */ React.createElement(Row, {
|
|
5629
6359
|
pi,
|
|
@@ -5643,7 +6373,7 @@ function HomeRow({ pi, item }) {
|
|
|
5643
6373
|
fresh: item.unseen,
|
|
5644
6374
|
dot: item.unseen ? "attention" : undefined,
|
|
5645
6375
|
time: item.at ? SidebarUtil.time(item.at, pi.ui.language) : "",
|
|
5646
|
-
selected
|
|
6376
|
+
selected,
|
|
5647
6377
|
onSelect: open
|
|
5648
6378
|
});
|
|
5649
6379
|
}
|
|
@@ -5663,6 +6393,7 @@ function AgentsSidebar({ context, partners = false }) {
|
|
|
5663
6393
|
const agentPage = pi.ui.useView(AGENT_PAGE);
|
|
5664
6394
|
const tasks = pi.ui.useTasks();
|
|
5665
6395
|
const homeItems = pi.ui.useHomeItems?.() ?? NO_HOME_ITEMS;
|
|
6396
|
+
const shownHome = pi.ui.useHomeShown?.();
|
|
5666
6397
|
const homeShown = homeItems.filter((item) => SidebarUtil.matches(query, item.title, item.detail));
|
|
5667
6398
|
const homeSections = SidebarUtil.homeSections(partners ? homeShown.filter((item) => SidebarUtil.place(item) === "partners") : homeShown);
|
|
5668
6399
|
const partnerTop = partners ? homeShown.filter((item) => SidebarUtil.place(item) === "partners" && !item.section) : [];
|
|
@@ -5690,7 +6421,7 @@ function AgentsSidebar({ context, partners = false }) {
|
|
|
5690
6421
|
const answering = React.useMemo(() => SidebarUtil.answering(team.agents, openSessions, context.sessions), [team.agents, openSessions, context.sessions]);
|
|
5691
6422
|
const asking = React.useMemo(() => SidebarUtil.waiting(team.agents, openSessions, context.sessions), [team.agents, openSessions, context.sessions]);
|
|
5692
6423
|
const doubleBusy = !!double?.busy;
|
|
5693
|
-
const pageShown = !!double?.shown || !!channelPage?.shown || !!agentPage?.shown;
|
|
6424
|
+
const pageShown = !!double?.shown || !!channelPage?.shown || !!agentPage?.shown || !!shownHome;
|
|
5694
6425
|
const shownFile = shownSession ? openSessions.find((session) => session.sessionId === shownSession)?.sessionFile : undefined;
|
|
5695
6426
|
const shownAgent = pageShown ? undefined : team.agents.find((agent) => !!shownSession && context.sessions.get(agent.id) === shownSession || !!shownFile && agent.sessionFile === shownFile)?.id;
|
|
5696
6427
|
const doubleAt = double?.preview?.at;
|
|
@@ -5753,6 +6484,53 @@ function AgentsSidebar({ context, partners = false }) {
|
|
|
5753
6484
|
fresh > 0 ? ChannelWords.format(w.freshCount, { count: String(fresh) }) : "",
|
|
5754
6485
|
running > 0 ? ChannelWords.format(w.runningCount, { count: String(running) }) : ""
|
|
5755
6486
|
].filter(Boolean).join(" · ");
|
|
6487
|
+
const agentRow = (agent, tag = false) => {
|
|
6488
|
+
const where = team.channels.find((channel) => working[channel.id]?.includes(agent.id));
|
|
6489
|
+
const cwd = agent.cwd ?? serverCwd;
|
|
6490
|
+
const last = lastLines?.get(agent.id);
|
|
6491
|
+
const line = lastLines ? last?.text ?? w.noMessages : "";
|
|
6492
|
+
const busy = !!where || answering.has(agent.id);
|
|
6493
|
+
const needsYou = asking.has(agent.id);
|
|
6494
|
+
const unseen = !busy && needsLook(agent.id);
|
|
6495
|
+
return /* @__PURE__ */ React.createElement(Row, {
|
|
6496
|
+
pi,
|
|
6497
|
+
key: agent.id,
|
|
6498
|
+
avatar: /* @__PURE__ */ React.createElement(AgentAvatar, {
|
|
6499
|
+
agent,
|
|
6500
|
+
faces,
|
|
6501
|
+
size: 40,
|
|
6502
|
+
working: busy
|
|
6503
|
+
}),
|
|
6504
|
+
title: agent.name,
|
|
6505
|
+
badge: /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(PinMark, {
|
|
6506
|
+
pi,
|
|
6507
|
+
pinned: agent.pinned
|
|
6508
|
+
}), tag && /* @__PURE__ */ React.createElement("span", {
|
|
6509
|
+
className: "tac-kind"
|
|
6510
|
+
}, w.agentTag)),
|
|
6511
|
+
place: /* @__PURE__ */ React.createElement(HostTag, {
|
|
6512
|
+
location: cwd
|
|
6513
|
+
}),
|
|
6514
|
+
preview: needsYou ? w.needsYou : where ? ChannelWords.format(w.answeringIn, { channel: where.name }) : line,
|
|
6515
|
+
live: busy && !needsYou,
|
|
6516
|
+
waiting: needsYou,
|
|
6517
|
+
fresh: unseen,
|
|
6518
|
+
dot: needsYou ? "ask" : busy ? "running" : unseen ? "attention" : undefined,
|
|
6519
|
+
time: lastLines ? SidebarUtil.time(last?.at ?? agent.createdAt, pi.ui.language) : "",
|
|
6520
|
+
hint: SidebarUtil.where(cwd),
|
|
6521
|
+
selected: agentSelected(agent),
|
|
6522
|
+
deleting: state.deleting.includes(agent.id),
|
|
6523
|
+
onSelect: () => openAgent(agent),
|
|
6524
|
+
more: /* @__PURE__ */ React.createElement(AgentMenu, {
|
|
6525
|
+
context,
|
|
6526
|
+
agent,
|
|
6527
|
+
cwd,
|
|
6528
|
+
working: !!where
|
|
6529
|
+
}),
|
|
6530
|
+
swipe: swipePinDelete(pi, !!agent.pinned, (pinned) => context.service.updateAgent(agent.id, { pinned }), () => deleteAgent(context, agent))
|
|
6531
|
+
});
|
|
6532
|
+
};
|
|
6533
|
+
const chatAgents = partners && lastLines ? agents.filter((agent) => lastLines.has(agent.id)) : [];
|
|
5756
6534
|
return /* @__PURE__ */ React.createElement("div", {
|
|
5757
6535
|
className: "tac-view"
|
|
5758
6536
|
}, /* @__PURE__ */ React.createElement("div", {
|
|
@@ -5793,7 +6571,8 @@ function AgentsSidebar({ context, partners = false }) {
|
|
|
5793
6571
|
})), (partners ? partnerTop : homeShown.filter((item) => !item.section)).map((item) => /* @__PURE__ */ React.createElement(HomeRow, {
|
|
5794
6572
|
key: item.key,
|
|
5795
6573
|
pi,
|
|
5796
|
-
item
|
|
6574
|
+
item,
|
|
6575
|
+
selected: item.key === shownHome
|
|
5797
6576
|
})), draft && /* @__PURE__ */ React.createElement(Row, {
|
|
5798
6577
|
pi,
|
|
5799
6578
|
avatar: /* @__PURE__ */ React.createElement(Face, {
|
|
@@ -5846,10 +6625,10 @@ function AgentsSidebar({ context, partners = false }) {
|
|
|
5846
6625
|
type: "button",
|
|
5847
6626
|
className: "tac-show-all",
|
|
5848
6627
|
onClick: () => setAllEnded(!allEnded)
|
|
5849
|
-
}, allEnded ? w.showFewer : ChannelWords.format(w.showAll, { count: String(groups.ended.length) }))), (channels.length > 0 || groupItems.length > 0) && /* @__PURE__ */ React.createElement(Section, {
|
|
6628
|
+
}, allEnded ? w.showFewer : ChannelWords.format(w.showAll, { count: String(groups.ended.length) }))), (channels.length > 0 || groupItems.length > 0 || chatAgents.length > 0) && /* @__PURE__ */ React.createElement(Section, {
|
|
5850
6629
|
id: "channels",
|
|
5851
6630
|
title: partners ? w.groupsSection : w.channelsSection,
|
|
5852
|
-
count: channels.length + groupItems.length,
|
|
6631
|
+
count: channels.length + groupItems.length + chatAgents.length,
|
|
5853
6632
|
folded,
|
|
5854
6633
|
onFold: fold,
|
|
5855
6634
|
alert: channels.some((channel) => unread.includes(channel.id)) || groupItems.some((item) => item.unseen)
|
|
@@ -5859,13 +6638,20 @@ function AgentsSidebar({ context, partners = false }) {
|
|
|
5859
6638
|
pinned: !!channel.pinned,
|
|
5860
6639
|
at: SidebarUtil.channelAt(channel, state.messages[channel.id])
|
|
5861
6640
|
})),
|
|
5862
|
-
...groupItems.map((item) => ({ item, pinned: false, at: item.at ?? 0 }))
|
|
6641
|
+
...groupItems.map((item) => ({ item, pinned: false, at: item.at ?? 0 })),
|
|
6642
|
+
...chatAgents.map((agent) => ({ agent, pinned: !!agent.pinned, at: latest.get(agent.id) ?? agent.createdAt }))
|
|
5863
6643
|
], partners).map((entry) => {
|
|
6644
|
+
if ("agent" in entry) {
|
|
6645
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, {
|
|
6646
|
+
key: `agent:${entry.agent.id}`
|
|
6647
|
+
}, agentRow(entry.agent, true));
|
|
6648
|
+
}
|
|
5864
6649
|
if (!("channel" in entry)) {
|
|
5865
6650
|
return /* @__PURE__ */ React.createElement(HomeRow, {
|
|
5866
6651
|
key: entry.item.key,
|
|
5867
6652
|
pi,
|
|
5868
|
-
item: entry.item
|
|
6653
|
+
item: entry.item,
|
|
6654
|
+
selected: entry.item.key === shownHome
|
|
5869
6655
|
});
|
|
5870
6656
|
}
|
|
5871
6657
|
const { channel } = entry;
|
|
@@ -5928,50 +6714,7 @@ function AgentsSidebar({ context, partners = false }) {
|
|
|
5928
6714
|
size: 12
|
|
5929
6715
|
}), /* @__PURE__ */ React.createElement("span", null, SidebarUtil.folder(group.cwd)), /* @__PURE__ */ React.createElement(HostTag, {
|
|
5930
6716
|
location: group.cwd
|
|
5931
|
-
})), group.agents.map((agent) => {
|
|
5932
|
-
const where = team.channels.find((channel) => working[channel.id]?.includes(agent.id));
|
|
5933
|
-
const cwd = agent.cwd ?? serverCwd;
|
|
5934
|
-
const last = lastLines?.get(agent.id);
|
|
5935
|
-
const line = lastLines ? last?.text ?? w.noMessages : "";
|
|
5936
|
-
const busy = !!where || answering.has(agent.id);
|
|
5937
|
-
const needsYou = asking.has(agent.id);
|
|
5938
|
-
const unseen = !busy && needsLook(agent.id);
|
|
5939
|
-
return /* @__PURE__ */ React.createElement(Row, {
|
|
5940
|
-
pi,
|
|
5941
|
-
key: agent.id,
|
|
5942
|
-
avatar: /* @__PURE__ */ React.createElement(AgentAvatar, {
|
|
5943
|
-
agent,
|
|
5944
|
-
faces,
|
|
5945
|
-
size: 40,
|
|
5946
|
-
working: busy
|
|
5947
|
-
}),
|
|
5948
|
-
title: agent.name,
|
|
5949
|
-
badge: /* @__PURE__ */ React.createElement(PinMark, {
|
|
5950
|
-
pi,
|
|
5951
|
-
pinned: agent.pinned
|
|
5952
|
-
}),
|
|
5953
|
-
place: /* @__PURE__ */ React.createElement(HostTag, {
|
|
5954
|
-
location: cwd
|
|
5955
|
-
}),
|
|
5956
|
-
preview: needsYou ? w.needsYou : where ? ChannelWords.format(w.answeringIn, { channel: where.name }) : line,
|
|
5957
|
-
live: busy && !needsYou,
|
|
5958
|
-
waiting: needsYou,
|
|
5959
|
-
fresh: unseen,
|
|
5960
|
-
dot: needsYou ? "ask" : busy ? "running" : unseen ? "attention" : undefined,
|
|
5961
|
-
time: lastLines ? SidebarUtil.time(last?.at ?? agent.createdAt, pi.ui.language) : "",
|
|
5962
|
-
hint: SidebarUtil.where(cwd),
|
|
5963
|
-
selected: agentSelected(agent),
|
|
5964
|
-
deleting: state.deleting.includes(agent.id),
|
|
5965
|
-
onSelect: () => openAgent(agent),
|
|
5966
|
-
more: /* @__PURE__ */ React.createElement(AgentMenu, {
|
|
5967
|
-
context,
|
|
5968
|
-
agent,
|
|
5969
|
-
cwd,
|
|
5970
|
-
working: !!where
|
|
5971
|
-
}),
|
|
5972
|
-
swipe: swipePinDelete(pi, !!agent.pinned, (pinned) => context.service.updateAgent(agent.id, { pinned }), () => deleteAgent(context, agent))
|
|
5973
|
-
});
|
|
5974
|
-
})))), homeSections.map((section) => /* @__PURE__ */ React.createElement(Section, {
|
|
6717
|
+
})), group.agents.map((agent) => agentRow(agent))))), homeSections.map((section) => /* @__PURE__ */ React.createElement(Section, {
|
|
5975
6718
|
key: section.id,
|
|
5976
6719
|
id: section.id,
|
|
5977
6720
|
title: section.title,
|
|
@@ -5982,7 +6725,8 @@ function AgentsSidebar({ context, partners = false }) {
|
|
|
5982
6725
|
}, section.items.map((item) => /* @__PURE__ */ React.createElement(HomeRow, {
|
|
5983
6726
|
key: item.key,
|
|
5984
6727
|
pi,
|
|
5985
|
-
item
|
|
6728
|
+
item,
|
|
6729
|
+
selected: item.key === shownHome
|
|
5986
6730
|
}))))), selection.selecting && SelectBar && /* @__PURE__ */ React.createElement(SelectBar, {
|
|
5987
6731
|
count: selection.selected.length,
|
|
5988
6732
|
total: selection.removable.length,
|
|
@@ -6101,6 +6845,7 @@ function SidebarHead({ context }) {
|
|
|
6101
6845
|
|
|
6102
6846
|
// web-src/style.ts
|
|
6103
6847
|
var STYLE = `
|
|
6848
|
+
.tac-kind { flex: none; margin-left: 6px; padding: 0 5px; border-radius: 4px; background: var(--ta-hover); color: var(--ta-muted); font-size: calc(10.5px * var(--ta-font-scale)); line-height: 16px; font-weight: 500; }
|
|
6104
6849
|
.tac-view { display: flex; flex-direction: column; height: 100%; min-height: 0; color: var(--ta-text); font-size: calc(13px * var(--ta-font-scale)); }
|
|
6105
6850
|
.tac-action { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; flex: none; padding: 0; border: 0; border-radius: 6px; background: none; color: var(--ta-muted); cursor: pointer; }
|
|
6106
6851
|
.tac-action:hover { background: var(--ta-hover); color: var(--ta-text); }
|
|
@@ -6164,6 +6909,23 @@ var STYLE = `
|
|
|
6164
6909
|
.tac-msg-failed { margin-bottom: 4px; color: var(--ta-red); font-size: calc(12px * var(--ta-font-scale)); }
|
|
6165
6910
|
.tac-msg-bubble pre { max-width: 100%; overflow-x: auto; }
|
|
6166
6911
|
.tac-mention { color: var(--ta-link); }
|
|
6912
|
+
.tac-menu-blank { display: inline-block; flex: none; width: 15px; height: 15px; }
|
|
6913
|
+
.tac-stop { align-self: center; display: flex; flex-direction: column; align-items: center; gap: 6px; margin: 10px 0; }
|
|
6914
|
+
.tac-stop .tac-notice { margin: 0; text-align: center; }
|
|
6915
|
+
.tac-stop-meta { max-width: 100%; padding: 0 12px; color: var(--ta-muted); font-size: calc(11.5px * var(--ta-font-scale)); text-align: center; }
|
|
6916
|
+
.tac-msg-over { margin-bottom: 4px; color: var(--ta-muted); font-size: calc(12px * var(--ta-font-scale)); }
|
|
6917
|
+
.tac-limits { display: flex; flex-direction: column; gap: 6px; padding: 6px 10px 4px; }
|
|
6918
|
+
.tac-limit-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-top: 4px; color: var(--ta-text); font-size: calc(13.5px * var(--ta-font-scale)); }
|
|
6919
|
+
.tac-limit-head .tac-limit-spent { color: var(--ta-muted); font-size: calc(12px * var(--ta-font-scale)); }
|
|
6920
|
+
.tac-limit-segments { width: 100%; }
|
|
6921
|
+
.tac-limit-segments > button { flex: 1; min-width: 0; padding-left: 4px; padding-right: 4px; white-space: nowrap; }
|
|
6922
|
+
.tac-limit-spent { color: var(--ta-secondary); font-variant-numeric: tabular-nums; }
|
|
6923
|
+
.tac-stop-meta:empty { display: none; }
|
|
6924
|
+
.tac-stop-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
|
|
6925
|
+
.tac-stop-button { padding: 4px 12px; border: 1px solid var(--ta-border-muted); border-radius: 999px; background: var(--ta-raised, var(--ta-main)); color: var(--ta-text); font: inherit; font-size: calc(12.5px * var(--ta-font-scale)); cursor: pointer; -webkit-tap-highlight-color: transparent; transition: background 120ms; }
|
|
6926
|
+
@media (hover: hover) { .tac-stop-button:hover:not(:disabled) { background: var(--ta-hover); } }
|
|
6927
|
+
.tac-stop-button:active:not(:disabled) { background: var(--ta-hover); }
|
|
6928
|
+
.tac-stop-button:disabled { opacity: 0.5; cursor: default; }
|
|
6167
6929
|
.tac-notice { align-self: center; margin: 10px 0; padding: 3px 10px; border-radius: 999px; background: var(--ta-hover); color: var(--ta-muted); font-size: calc(12px * var(--ta-font-scale)); }
|
|
6168
6930
|
/* The notice of a channel (notice.tsx): a line over the chat, open to read and to write */
|
|
6169
6931
|
.tac-notice-bar { flex: none; width: 100%; max-width: calc(var(--ta-col) + 48px); margin: 0 auto; padding: 8px 24px 0; box-sizing: border-box; }
|
|
@@ -6350,6 +7112,22 @@ textarea.tac-input { resize: vertical; min-height: 56px; line-height: 1.5; }
|
|
|
6350
7112
|
.tac-pick.tac-on .tac-check { border-color: var(--ta-green); background: var(--ta-green); }
|
|
6351
7113
|
.tac-members-foot { display: flex; align-items: center; justify-content: flex-end; gap: 6px; flex: none; padding: 10px 16px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--ta-border-muted); }
|
|
6352
7114
|
.tac-members-ask { flex: 1; min-width: 0; color: var(--ta-body); font-size: calc(12.5px * var(--ta-font-scale)); }
|
|
7115
|
+
.tac-members-label { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
|
|
7116
|
+
.tac-members-model { display: inline-flex; align-items: center; gap: 2px; min-width: 0; }
|
|
7117
|
+
.tac-members-model > span { flex: none; }
|
|
7118
|
+
.tac-members-model .ta-model-field { max-width: 150px; height: 24px; padding: 0 4px 0 6px; border: 0; border-radius: 6px; background: none; color: var(--ta-secondary); font-size: calc(12px * var(--ta-font-scale)); }
|
|
7119
|
+
.tac-members-model .ta-model-field:not(:disabled):hover { background: var(--ta-hover); color: var(--ta-text); }
|
|
7120
|
+
.tac-members-model .ta-model-field > svg { width: 13px; height: 13px; }
|
|
7121
|
+
.tac-setting { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 40px; padding: 0 10px; border: 0; border-radius: 10px; background: none; color: var(--ta-text); font: inherit; font-size: calc(13.5px * var(--ta-font-scale)); text-align: left; box-sizing: border-box; }
|
|
7122
|
+
button.tac-setting { cursor: pointer; }
|
|
7123
|
+
button.tac-setting:hover { background: var(--ta-hover); }
|
|
7124
|
+
button.tac-setting:focus-visible { outline: 1px solid var(--ta-border-focus); outline-offset: -1px; }
|
|
7125
|
+
.tac-setting > svg { flex: none; color: var(--ta-muted); }
|
|
7126
|
+
.tac-setting-label { flex: 1; min-width: 0; }
|
|
7127
|
+
.tac-setting-value { flex: none; max-width: 55%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: right; color: var(--ta-muted); }
|
|
7128
|
+
.tac-dialog-field { display: flex; flex-direction: column; gap: 8px; color: var(--ta-secondary); font-size: calc(13px * var(--ta-font-scale)); }
|
|
7129
|
+
.tac-dialog-field .ta-model-field { width: 100%; height: 40px; padding: 0 12px; border-radius: 8px; font-size: calc(14px * var(--ta-font-scale)); }
|
|
7130
|
+
textarea.tac-settings-role { min-height: 120px; max-height: 40vh; line-height: 1.6; }
|
|
6353
7131
|
.tac-button.tac-wide { flex: 1; height: 36px; border-radius: 10px; font-size: calc(13.5px * var(--ta-font-scale)); }
|
|
6354
7132
|
@media (hover: none) {
|
|
6355
7133
|
.tac-member-actions { opacity: 1; }
|
|
@@ -6631,6 +7409,7 @@ function activate(pi) {
|
|
|
6631
7409
|
}
|
|
6632
7410
|
};
|
|
6633
7411
|
pi.registerTasks(tasks);
|
|
7412
|
+
pi.registerSettings(limitSettings(pi, service));
|
|
6634
7413
|
new ChannelToolLines(context).register();
|
|
6635
7414
|
pi.registerMessageRenderer(HandOff.CARD, HandOffView.card(context));
|
|
6636
7415
|
pi.registerComposerAddon(HandOffView.composerAddon(context));
|