@celljs/ta-channels 4.21.0 → 4.22.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.
@@ -687,6 +687,12 @@ var ChannelsUtil;
687
687
  }
688
688
  channel.dailyLimit = input.dailyLimit;
689
689
  }
690
+ if (input.shared !== undefined) {
691
+ if (typeof input.shared !== "string" || !input.shared) {
692
+ throw new Error("The group chat a channel became is the id of a room.");
693
+ }
694
+ channel.shared = input.shared;
695
+ }
690
696
  return { team: { ...team, channels: team.channels.map((other) => other.id === channel.id ? channel : other) }, channel, before };
691
697
  }
692
698
  ChannelsUtil.updateChannel = updateChannel;
@@ -699,6 +705,10 @@ var ChannelsUtil;
699
705
  return team.channels.filter((channel) => channel.by === "ta");
700
706
  }
701
707
  ChannelsUtil.taskChannels = taskChannels;
708
+ function liveChannels(team) {
709
+ return ownChannels(team).filter((channel) => !channel.shared);
710
+ }
711
+ ChannelsUtil.liveChannels = liveChannels;
702
712
  function ownChannels(team) {
703
713
  return team.channels.filter((channel) => channel.by !== "ta");
704
714
  }
@@ -1668,7 +1678,7 @@ var ChannelsText;
1668
1678
  if (message.author === SYSTEM) {
1669
1679
  return [];
1670
1680
  }
1671
- if (named.length > 0 || message.author !== USER && message.author !== TA) {
1681
+ if (named.length > 0 || message.author !== TA) {
1672
1682
  return named;
1673
1683
  }
1674
1684
  return members.length > 0 ? [members[0].id] : [];
package/host/index.mjs CHANGED
@@ -1120,6 +1120,12 @@ var ChannelsUtil;
1120
1120
  }
1121
1121
  channel.dailyLimit = input.dailyLimit;
1122
1122
  }
1123
+ if (input.shared !== undefined) {
1124
+ if (typeof input.shared !== "string" || !input.shared) {
1125
+ throw new Error("The group chat a channel became is the id of a room.");
1126
+ }
1127
+ channel.shared = input.shared;
1128
+ }
1123
1129
  return { team: { ...team, channels: team.channels.map((other) => other.id === channel.id ? channel : other) }, channel, before };
1124
1130
  }
1125
1131
  ChannelsUtil.updateChannel = updateChannel;
@@ -1132,6 +1138,10 @@ var ChannelsUtil;
1132
1138
  return team.channels.filter((channel) => channel.by === "ta");
1133
1139
  }
1134
1140
  ChannelsUtil.taskChannels = taskChannels;
1141
+ function liveChannels(team) {
1142
+ return ownChannels(team).filter((channel) => !channel.shared);
1143
+ }
1144
+ ChannelsUtil.liveChannels = liveChannels;
1135
1145
  function ownChannels(team) {
1136
1146
  return team.channels.filter((channel) => channel.by !== "ta");
1137
1147
  }
@@ -1607,7 +1617,7 @@ var ChannelsText;
1607
1617
  if (message.author === SYSTEM) {
1608
1618
  return [];
1609
1619
  }
1610
- if (named.length > 0 || message.author !== USER && message.author !== TA) {
1620
+ if (named.length > 0 || message.author !== TA) {
1611
1621
  return named;
1612
1622
  }
1613
1623
  return members.length > 0 ? [members[0].id] : [];
@@ -2323,6 +2333,53 @@ var TaAppUtil;
2323
2333
  })(TaAppUtil || (TaAppUtil = {}));
2324
2334
  // ../ta-protocol/esm/common/auth-protocol.js
2325
2335
  var TaAuthServer = Symbol("TaAuthServer");
2336
+ // ../ta-protocol/esm/common/confine-protocol.js
2337
+ var TA_CONFINED_MARK = "[ta:confined]";
2338
+ var AT = String.raw`(?:^|[;&|(\`]|\$\()\s*(?:sudo\s+|env\s+(?:\S+=\S*\s+)*|npx\s+|bunx\s+|pnpm\s+(?:exec|dlx)\s+|yarn\s+dlx\s+|exec\s+|xargs\s+(?:-\S+\s+)*)*`;
2339
+ var command = (names) => new RegExp(`${AT}(?:${names})(?=\\s|$|[;&|)])`, "m");
2340
+ var BLOCKED = [
2341
+ [/\bgit\b[^\n;&|]*\s(?:push|send-email|request-pull)\b/, "pushing: the user puts the work out once they looked at it"],
2342
+ [/\bgit\b[^\n;&|]*\sremote\s+(?:add|set-url|rename|remove|rm)\b/, "changing the remotes"],
2343
+ [/\bgit\b[^\n;&|]*\sconfig\b[^\n;&|]*(?:credential|url\.|core\.sshcommand|core\.hookspath)/i, "changing how git reaches others"],
2344
+ [/\b(?:publish|unpublish|deprecate)\b/, "publishing"],
2345
+ [
2346
+ command("wrangler|vercel|netlify|flyctl|fly|firebase|heroku|gh|aws|gcloud|az|kubectl|helm|terraform|pulumi|docker|podman|eas|fastlane|xcrun\\s+altool|twine"),
2347
+ "deploying, or the tools of a cloud"
2348
+ ],
2349
+ [command("ssh|scp|sftp|rsync|nc|ncat|netcat|telnet|ftp|socat"), "reaching other machines"],
2350
+ [
2351
+ /\b(?:curl|wget|http|https|Invoke-WebRequest|Invoke-RestMethod|iwr|irm)\b[^\n;&|]*(?:\s-[a-zA-Z]*[dFT]\b|\s--(?:data|upload|form|post|put|json)|\s-X\s*(?:POST|PUT|PATCH|DELETE)|\s-Method\s+(?:Post|Put|Patch|Delete)|\s-Body\b|\s-InFile\b)/i,
2352
+ "sending data out"
2353
+ ],
2354
+ [
2355
+ /(?:~|\$HOME|\$\{HOME\}|\$env:USERPROFILE|\/Users\/[^/\s]+|\/home\/[^/\s]+|\/root)[\\/]\.(?:ssh|aws|gnupg|netrc|npmrc|yarnrc|pypirc|zshenv|zshrc|zprofile|bashrc|bash_profile|profile|docker|kube|ta|codebuddy|claude|cursor|config[\\/](?:gh|gcloud|hub))\b/i,
2356
+ "the user's secrets and settings"
2357
+ ],
2358
+ [/\bsecurity\s+(?:find|dump|export)-/, "the keychain"],
2359
+ [command("printenv|env|set|export\\s+-p|declare\\s+-x|Get-ChildItem\\s+env:|gci\\s+env:|dir\\s+env:"), "printing the environment (it holds tokens)"],
2360
+ [command("sudo|su|doas|osascript|launchctl|crontab|defaults\\s+write|schtasks|reg"), "acting as the system"],
2361
+ [/\brm\s+-[a-zA-Z]*[rR][a-zA-Z]*\s+(?:-[a-zA-Z]+\s+)*(?:\/|~|\$HOME|\$\{HOME\})(?:\s|$|\/\s|\/\*)/, "deleting outside its directory"]
2362
+ ];
2363
+ var TaConfineUtil;
2364
+ (function(TaConfineUtil2) {
2365
+ TaConfineUtil2.FILE_TOOLS = ["read", "edit", "write", "grep", "find", "ls"];
2366
+ TaConfineUtil2.COMMAND_TOOLS = ["bash", "powershell"];
2367
+ function confine(role) {
2368
+ return role.includes(TA_CONFINED_MARK) ? role : `${TA_CONFINED_MARK}
2369
+ ${role}`;
2370
+ }
2371
+ TaConfineUtil2.confine = confine;
2372
+ function confined(systemPrompt) {
2373
+ return TaHostUtil.marked(systemPrompt, TA_CONFINED_MARK);
2374
+ }
2375
+ TaConfineUtil2.confined = confined;
2376
+ function blocked(commandText) {
2377
+ var _a;
2378
+ const text = String(commandText !== null && commandText !== undefined ? commandText : "");
2379
+ return (_a = BLOCKED.find(([pattern]) => pattern.test(text))) === null || _a === undefined ? undefined : _a[1];
2380
+ }
2381
+ TaConfineUtil2.blocked = blocked;
2382
+ })(TaConfineUtil || (TaConfineUtil = {}));
2326
2383
  // ../ta-protocol/esm/common/deployment-protocol.js
2327
2384
  var TA_WELL_KNOWN_PATH = "/.well-known/ta";
2328
2385
 
@@ -2957,10 +3014,10 @@ var TaServer = Symbol("TaServer");
2957
3014
  var TaClient = Symbol("TaClient");
2958
3015
  var TaSlashCommandUtil;
2959
3016
  (function(TaSlashCommandUtil2) {
2960
- function description(command, language) {
3017
+ function description(command2, language) {
2961
3018
  var _a, _b;
2962
- const { descriptions } = command;
2963
- return (_b = (_a = descriptions === null || descriptions === undefined ? undefined : descriptions[language]) !== null && _a !== undefined ? _a : descriptions === null || descriptions === undefined ? undefined : descriptions[language.split("-")[0]]) !== null && _b !== undefined ? _b : command.description;
3019
+ const { descriptions } = command2;
3020
+ return (_b = (_a = descriptions === null || descriptions === undefined ? undefined : descriptions[language]) !== null && _a !== undefined ? _a : descriptions === null || descriptions === undefined ? undefined : descriptions[language.split("-")[0]]) !== null && _b !== undefined ? _b : command2.description;
2964
3021
  }
2965
3022
  TaSlashCommandUtil2.description = description;
2966
3023
  })(TaSlashCommandUtil || (TaSlashCommandUtil = {}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@celljs/ta-channels",
3
- "version": "4.21.0",
3
+ "version": "4.22.0",
4
4
  "description": "A pi package for Ta: agents with roles of their own and channels where the user, Ta and the agents talk; Ta builds the team for what the user wants",
5
5
  "keywords": [
6
6
  "pi-package"
@@ -27,9 +27,9 @@
27
27
  "watch": "tsc -b -w --preserveWatchOutput"
28
28
  },
29
29
  "devDependencies": {
30
- "@celljs/ta-protocol": "4.21.0",
31
- "@celljs/ta-relay": "4.21.0",
32
- "@celljs/ta-web": "4.21.0",
30
+ "@celljs/ta-protocol": "4.22.0",
31
+ "@celljs/ta-relay": "4.22.0",
32
+ "@celljs/ta-web": "4.22.0",
33
33
  "@types/react": "^19.3.0"
34
34
  },
35
35
  "publishConfig": {
package/web/index.js CHANGED
@@ -1032,6 +1032,12 @@ var ChannelsUtil;
1032
1032
  }
1033
1033
  channel.dailyLimit = input.dailyLimit;
1034
1034
  }
1035
+ if (input.shared !== undefined) {
1036
+ if (typeof input.shared !== "string" || !input.shared) {
1037
+ throw new Error("The group chat a channel became is the id of a room.");
1038
+ }
1039
+ channel.shared = input.shared;
1040
+ }
1035
1041
  return { team: { ...team, channels: team.channels.map((other) => other.id === channel.id ? channel : other) }, channel, before };
1036
1042
  }
1037
1043
  ChannelsUtil.updateChannel = updateChannel;
@@ -1044,6 +1050,10 @@ var ChannelsUtil;
1044
1050
  return team.channels.filter((channel) => channel.by === "ta");
1045
1051
  }
1046
1052
  ChannelsUtil.taskChannels = taskChannels;
1053
+ function liveChannels(team) {
1054
+ return ownChannels(team).filter((channel) => !channel.shared);
1055
+ }
1056
+ ChannelsUtil.liveChannels = liveChannels;
1047
1057
  function ownChannels(team) {
1048
1058
  return team.channels.filter((channel) => channel.by !== "ta");
1049
1059
  }
@@ -1350,7 +1360,7 @@ var JA = {
1350
1360
  makeExtensionAsk: "このグループチャットで作成された事項を拡張機能にする(ta-package スキルで)、将来は 1 クリックで再利用可能",
1351
1361
  add: "追加",
1352
1362
  allMembers: "すべてのエージェントがこのグループチャットに既に含まれています",
1353
- membersHint: "最初に選択したメンバーがリーダー:誰も @ で指定されていないメッセージに答えます。",
1363
+ membersHint: "最初に選択したメンバーがリーダー:Ta がグループに任せた仕事を受けます。答えてほしいエージェントは @ で指定します。",
1354
1364
  create: "作成",
1355
1365
  cancel: "キャンセル",
1356
1366
  back: "戻る",
@@ -1364,7 +1374,7 @@ var JA = {
1364
1374
  noAgents: "まだエージェントがありません",
1365
1375
  noAgentsHint: "グループチャットはエージェントで構成されます:最初に 1 つ作成",
1366
1376
  pick: "グループチャットを選択",
1367
- quiet: "まだメッセージがありません。@ でメンバーを指定するか、リーダーが回答します。",
1377
+ quiet: "まだメッセージがありません。@ で指定したエージェントが答えます。",
1368
1378
  placeholder: "{channel} に送信;@ でメンバーを指定",
1369
1379
  answering: "{name} が回答中",
1370
1380
  failed: "回答がありません",
@@ -1418,10 +1428,9 @@ var JA = {
1418
1428
  agentTag: "エージェント",
1419
1429
  noPartners: "まだ仲間がいません",
1420
1430
  noPartnersHint: "+ でエージェントやグループチャットを作るか、友だちを追加して",
1421
- inviteFriends: "友だちを招待",
1422
- noFriends: "まだ友だちがいません",
1423
- shareGroup: "共有グループチャットにする",
1424
- shareGroupHint: "同じ名前のグループチャットを作り、選んだ友だちと中継で暗号化して共有します。エージェントも一緒に入ります。ここの履歴はこのコンピュータに残り、友だちには送られません。",
1431
+ shareGroupHint: "このグループチャットを選んだ友だちと中継で暗号化して共有します。エージェントもそのまま残ります。友だちには参加後のメッセージが見え、それ以前の履歴はこのコンピュータにあなただけのものとして残ります。",
1432
+ sharedBefore: "それ以前の履歴(あなただけに表示)",
1433
+ sharedBeforeTile: "以前の履歴",
1425
1434
  sharedMade: "「{name}」を友だちと共有しました。参加するとすぐ入れます。",
1426
1435
  addFriends: "友だちを追加",
1427
1436
  friend: "友だち",
@@ -1593,7 +1602,7 @@ var ZH = {
1593
1602
  makeExtensionAsk: "把这个群聊里商量和做成的事做成扩展(用 ta-package 技能),以后一键就能再用",
1594
1603
  add: "添加",
1595
1604
  allMembers: "所有智能体都已在这个群聊里",
1596
- membersHint: "先选的成员是负责人:没人被 @ 的消息由它回答。",
1605
+ membersHint: "先选的成员是负责人:Ta 派给群的事由它接。想让哪个智能体回答你,就 @ 它。",
1597
1606
  create: "创建",
1598
1607
  cancel: "取消",
1599
1608
  back: "返回",
@@ -1607,7 +1616,7 @@ var ZH = {
1607
1616
  noAgents: "还没有智能体",
1608
1617
  noAgentsHint: "群聊由智能体组成,先新建一个",
1609
1618
  pick: "选一个群聊",
1610
- quiet: "还没有消息。用 @ 点名成员,不点名就由负责人回答。",
1619
+ quiet: "还没有消息。@ 哪个智能体,它就会回答。",
1611
1620
  placeholder: "发到 {channel};@ 点名成员",
1612
1621
  answering: "{name} 正在回答",
1613
1622
  failed: "没有回答",
@@ -1661,10 +1670,9 @@ var ZH = {
1661
1670
  agentTag: "智能体",
1662
1671
  noPartners: "还没有伙伴",
1663
1672
  noPartnersHint: "点 + 新建智能体或群聊,或加个好友",
1664
- inviteFriends: "邀请好友",
1665
- noFriends: "还没有好友",
1666
- shareGroup: "建成共享群聊",
1667
- shareGroupHint: "会新建一个同名的群聊,经中继加密和你选的好友共享,群里的智能体一起进去;这里的聊天记录留在本机,不发给好友。",
1673
+ shareGroupHint: "这个群聊会经中继加密和你选的好友共享,群里的智能体都在。好友从加入起看到新消息,之前的记录只留在本机,只有你能看到。",
1674
+ sharedBefore: "之前的聊天记录,只有你能看到",
1675
+ sharedBeforeTile: "之前的记录",
1668
1676
  sharedMade: "已和好友共享「{name}」:好友点加入就进来。",
1669
1677
  addFriends: "添加好友",
1670
1678
  friend: "好友",
@@ -1836,7 +1844,7 @@ var ZH_TW = {
1836
1844
  makeExtensionAsk: "把這個群聊里商量和做成的事做成擴充功能(用 ta-package 技能),以後一鍵就能再用",
1837
1845
  add: "新增",
1838
1846
  allMembers: "所有智慧體都已在這個群聊里",
1839
- membersHint: "先選的成員是負責人:沒人被 @ 的訊息由它回答。",
1847
+ membersHint: "先選的成員是負責人:Ta 派給群的事由它接。想讓哪個智慧體回答你,就 @ 它。",
1840
1848
  create: "建立",
1841
1849
  cancel: "取消",
1842
1850
  back: "返回",
@@ -1850,7 +1858,7 @@ var ZH_TW = {
1850
1858
  noAgents: "還沒有智慧體",
1851
1859
  noAgentsHint: "群聊由智慧體組成,先新建一個",
1852
1860
  pick: "選一個群聊",
1853
- quiet: "還沒有訊息。用 @ 點名成員,不點名就由負責人回答。",
1861
+ quiet: "還沒有訊息。@ 哪個智慧體,它就會回答。",
1854
1862
  placeholder: "發到 {channel};@ 點名成員",
1855
1863
  answering: "{name} 正在回答",
1856
1864
  failed: "沒有回答",
@@ -1904,10 +1912,9 @@ var ZH_TW = {
1904
1912
  agentTag: "智慧體",
1905
1913
  noPartners: "還沒有夥伴",
1906
1914
  noPartnersHint: "點 + 新建智慧體或群聊,或加個好友",
1907
- inviteFriends: "邀請好友",
1908
- noFriends: "還沒有好友",
1909
- shareGroup: "建成共享群聊",
1910
- shareGroupHint: "會新建一個同名的群聊,經中繼加密和你選的好友共享,群裡的智慧體一起進去;這裡的聊天記錄留在本機,不發給好友。",
1915
+ shareGroupHint: "這個群聊會經中繼加密和你選的好友共享,群裡的智慧體都在。好友從加入起看到新訊息,之前的記錄只留在本機,只有你能看到。",
1916
+ sharedBefore: "之前的聊天記錄,只有你能看到",
1917
+ sharedBeforeTile: "之前的記錄",
1911
1918
  sharedMade: "已和好友共享「{name}」:好友點加入就進來。",
1912
1919
  addFriends: "新增好友",
1913
1920
  friend: "好友",
@@ -2079,7 +2086,7 @@ var EN = {
2079
2086
  makeExtensionAsk: "Make what this group chat worked out an extension, with the ta-package skill, to do it again in a click",
2080
2087
  add: "Add",
2081
2088
  allMembers: "Every agent is in this group chat already",
2082
- membersHint: "The first one you pick leads: it answers what names nobody.",
2089
+ membersHint: "The first one you pick leads: it answers what Ta hands the group chat. Mention an agent with @ to have it answer you.",
2083
2090
  create: "Create",
2084
2091
  cancel: "Cancel",
2085
2092
  back: "Back",
@@ -2093,7 +2100,7 @@ var EN = {
2093
2100
  noAgents: "No agents yet",
2094
2101
  noAgentsHint: "A group chat is made of agents: create one first",
2095
2102
  pick: "Pick a group chat",
2096
- quiet: "Nothing said yet. Mention a member with @, or the lead answers.",
2103
+ quiet: "Nothing said yet. Mention an agent with @ to have it answer.",
2097
2104
  placeholder: "Message {channel}; @ names a member",
2098
2105
  answering: "{name} is answering",
2099
2106
  failed: "did not answer",
@@ -2147,10 +2154,9 @@ var EN = {
2147
2154
  agentTag: "Agent",
2148
2155
  noPartners: "No one to work with yet",
2149
2156
  noPartnersHint: "Create an agent or a group chat with +, or add a friend",
2150
- inviteFriends: "Invite friends",
2151
- noFriends: "No friends yet",
2152
- shareGroup: "Make it shared",
2153
- shareGroupHint: "A group chat of the same name is made, shared with the friends you pick through the relay, sealed; its agents go in too. What was said here stays on this computer.",
2157
+ shareGroupHint: "This group chat is shared with the friends you pick through the relay, sealed, its agents in it too. They see what is said from when they join; what was said before stays on this computer, for you alone.",
2158
+ sharedBefore: "What was said before, for you alone",
2159
+ sharedBeforeTile: "Earlier",
2154
2160
  sharedMade: "“{name}” is shared with your friends now: they are in once they join.",
2155
2161
  addFriends: "Add friends",
2156
2162
  friend: "Friend",
@@ -3029,86 +3035,16 @@ async function createShared(context, title, friends, agents) {
3029
3035
  }
3030
3036
  const { link } = await rooms.invite(room.id);
3031
3037
  await pi.openLink?.(link);
3038
+ return room.id;
3032
3039
  }
3033
3040
  var ROOMS_PACKAGE = "@celljs/ta-rooms";
3034
3041
  var ROOMS_KIND = "ta-rooms";
3035
- function ShareDialog({ context, channel, onClose }) {
3042
+ async function becomeGroup(context, channel, friends, agents) {
3036
3043
  const { pi } = context;
3037
- const w = ChannelViews.words(pi);
3038
- const friends = useFriends(pi);
3039
- const Check = ChannelViews.icon(pi, "Check");
3040
- const [picked, setPicked] = React.useState([]);
3041
- const [busy, setBusy] = React.useState(false);
3042
- const [error, setError] = React.useState();
3043
- const toggle = (friend) => setPicked(picked.includes(friend.id) ? picked.filter((id) => id !== friend.id) : [...picked, friend.id]);
3044
- const share = () => {
3045
- setBusy(true);
3046
- setError(undefined);
3047
- createShared(context, channel.name, picked, channel.members).then(() => {
3048
- onClose();
3049
- pi.ui.notify(ChannelWords.format(w.sharedMade, { name: channel.name }), "info");
3050
- }, (failure) => {
3051
- setBusy(false);
3052
- setError(ChannelViews.message(failure));
3053
- });
3054
- };
3055
- return /* @__PURE__ */ React.createElement(pi.ui.Dialog, {
3056
- title: w.inviteFriends,
3057
- onClose
3058
- }, /* @__PURE__ */ React.createElement("div", {
3059
- className: "tac-dialog"
3060
- }, /* @__PURE__ */ React.createElement("div", {
3061
- className: "tac-dialog-note"
3062
- }, w.shareGroupHint), /* @__PURE__ */ React.createElement("div", {
3063
- className: "tac-pick-list"
3064
- }, friends.length === 0 && /* @__PURE__ */ React.createElement(pi.ui.Empty, {
3065
- compact: true,
3066
- title: w.noFriends
3067
- }), friends.map((friend) => {
3068
- const on = picked.includes(friend.id);
3069
- return /* @__PURE__ */ React.createElement("button", {
3070
- key: friend.id,
3071
- type: "button",
3072
- "aria-pressed": on,
3073
- className: `tac-pick${on ? " tac-on" : ""}`,
3074
- onClick: () => toggle(friend)
3075
- }, /* @__PURE__ */ React.createElement("span", {
3076
- className: "tac-check"
3077
- }, on && /* @__PURE__ */ React.createElement(Check, {
3078
- size: 13,
3079
- strokeWidth: 3
3080
- })), pi.ui.Face ? /* @__PURE__ */ React.createElement(pi.ui.Face, {
3081
- seed: friend.id,
3082
- size: 30,
3083
- look: friend.look
3084
- }) : /* @__PURE__ */ React.createElement("span", {
3085
- className: "tac-pick-face"
3086
- }), /* @__PURE__ */ React.createElement("span", {
3087
- className: "tac-pick-text"
3088
- }, /* @__PURE__ */ React.createElement("span", {
3089
- className: "tac-pick-name"
3090
- }, friend.name), /* @__PURE__ */ React.createElement("span", {
3091
- className: "tac-pick-role"
3092
- }, w.friend)));
3093
- })), error && /* @__PURE__ */ React.createElement("div", {
3094
- className: "tac-empty tac-error"
3095
- }, error), /* @__PURE__ */ React.createElement("div", {
3096
- className: "tac-dialog-actions"
3097
- }, /* @__PURE__ */ React.createElement("button", {
3098
- type: "button",
3099
- className: busy ? "tac-button tac-primary ta-busy" : "tac-button tac-primary",
3100
- disabled: busy || picked.length === 0,
3101
- onClick: share
3102
- }, w.shareGroup, busy && /* @__PURE__ */ React.createElement("span", {
3103
- className: "ta-spinner ta-busy-mark ta-on-brand"
3104
- })))));
3105
- }
3106
- function openShareGroup(context, channel) {
3107
- context.pi.ui.custom?.(({ close }) => /* @__PURE__ */ React.createElement(ShareDialog, {
3108
- context,
3109
- channel,
3110
- onClose: close
3111
- }));
3044
+ const members = [...channel.members, ...agents.filter((id) => !channel.members.includes(id))];
3045
+ const room = await createShared(context, channel.name, friends, members);
3046
+ await context.service.updateChannel(channel.id, { shared: room });
3047
+ pi.ui.notify(ChannelWords.format(ChannelViews.words(pi).sharedMade, { name: channel.name }), "info");
3112
3048
  }
3113
3049
 
3114
3050
  // web-src/create.tsx
@@ -4094,7 +4030,7 @@ var ChannelsText;
4094
4030
  if (message.author === SYSTEM) {
4095
4031
  return [];
4096
4032
  }
4097
- if (named.length > 0 || message.author !== USER && message.author !== TA) {
4033
+ if (named.length > 0 || message.author !== TA) {
4098
4034
  return named;
4099
4035
  }
4100
4036
  return members.length > 0 ? [members[0].id] : [];
@@ -5616,7 +5552,6 @@ function MemberList({ context, team, channel, faces, working }) {
5616
5552
  const [confirming, setConfirming] = React.useState(false);
5617
5553
  const [editing, setEditing] = React.useState();
5618
5554
  const UserPlus = ChannelViews.icon(pi, "UserPlus");
5619
- const Contact = ChannelViews.icon(pi, "Contact");
5620
5555
  const Crown = ChannelViews.icon(pi, "Crown");
5621
5556
  const BellOff = ChannelViews.icon(pi, "BellOff");
5622
5557
  const RotateCcw = ChannelViews.icon(pi, "RotateCcw");
@@ -5678,19 +5613,7 @@ function MemberList({ context, team, channel, faces, working }) {
5678
5613
  className: "tac-member-text"
5679
5614
  }, /* @__PURE__ */ React.createElement("span", {
5680
5615
  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) => {
5616
+ }, w.addMembers))), members.map((agent, index) => {
5694
5617
  const lead = index === 0;
5695
5618
  const off = muted.includes(agent.id);
5696
5619
  const answering = working.includes(agent.id);
@@ -5893,7 +5816,11 @@ function MemberPicker({ context, team, channel, faces }) {
5893
5816
  const Check = ChannelViews.icon(pi, "Check");
5894
5817
  const UserPlus = ChannelViews.icon(pi, "UserPlus");
5895
5818
  const back = () => ui.set({ adding: false });
5896
- const { busy, error, submit } = useSubmit(() => service.addMembers(channel.id, picked), back);
5819
+ const friends = useFriends(pi).filter(() => !!pi.rooms && channel.by !== "ta" && !channel.shared);
5820
+ const [pickedFriends, setPickedFriends] = React.useState([]);
5821
+ const toggleFriend = (id) => setPickedFriends(pickedFriends.includes(id) ? pickedFriends.filter((other) => other !== id) : [...pickedFriends, id]);
5822
+ const { busy, error, submit } = useSubmit(() => pickedFriends.length > 0 ? becomeGroup(context, channel, pickedFriends, picked) : service.addMembers(channel.id, picked), back);
5823
+ const count = picked.length + pickedFriends.length;
5897
5824
  const others = team.agents.filter((agent) => !channel.members.includes(agent.id));
5898
5825
  const shown = others.filter((agent) => SidebarUtil.matches(query, agent.name, agent.role));
5899
5826
  const toggle = (id) => setPicked(picked.includes(id) ? picked.filter((other) => other !== id) : [...picked, id]);
@@ -5956,7 +5883,39 @@ function MemberPicker({ context, team, channel, faces }) {
5956
5883
  size: 12,
5957
5884
  strokeWidth: 3
5958
5885
  })));
5959
- }), /* @__PURE__ */ React.createElement("div", {
5886
+ }), friends.length > 0 && /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", {
5887
+ className: "tac-members-label"
5888
+ }, w.addFriends), friends.filter((friend) => SidebarUtil.matches(query, friend.name)).map((friend) => {
5889
+ const on = pickedFriends.includes(friend.id);
5890
+ return /* @__PURE__ */ React.createElement("button", {
5891
+ key: friend.id,
5892
+ type: "button",
5893
+ className: `tac-member-main tac-pick${on ? " tac-on" : ""}`,
5894
+ "aria-pressed": on,
5895
+ onClick: () => toggleFriend(friend.id)
5896
+ }, pi.ui.Face ? /* @__PURE__ */ React.createElement(pi.ui.Face, {
5897
+ seed: friend.id,
5898
+ size: 32,
5899
+ look: friend.look
5900
+ }) : /* @__PURE__ */ React.createElement("span", {
5901
+ className: "tac-pick-face"
5902
+ }), /* @__PURE__ */ React.createElement("span", {
5903
+ className: "tac-member-text"
5904
+ }, /* @__PURE__ */ React.createElement("span", {
5905
+ className: "tac-member-name"
5906
+ }, /* @__PURE__ */ React.createElement("span", {
5907
+ className: "tac-member-label"
5908
+ }, friend.name)), /* @__PURE__ */ React.createElement("span", {
5909
+ className: "tac-member-detail"
5910
+ }, w.friend)), /* @__PURE__ */ React.createElement("span", {
5911
+ className: "tac-check"
5912
+ }, on && /* @__PURE__ */ React.createElement(Check, {
5913
+ size: 12,
5914
+ strokeWidth: 3
5915
+ })));
5916
+ }), pickedFriends.length > 0 && /* @__PURE__ */ React.createElement("div", {
5917
+ className: "tac-members-note"
5918
+ }, w.shareGroupHint)), /* @__PURE__ */ React.createElement("div", {
5960
5919
  className: "tac-members-sep"
5961
5920
  }), /* @__PURE__ */ React.createElement("button", {
5962
5921
  type: "button",
@@ -5977,13 +5936,186 @@ function MemberPicker({ context, team, channel, faces }) {
5977
5936
  }, /* @__PURE__ */ React.createElement("button", {
5978
5937
  type: "button",
5979
5938
  className: busy ? "tac-button tac-primary tac-wide ta-busy" : "tac-button tac-primary tac-wide",
5980
- disabled: busy || picked.length === 0,
5939
+ disabled: busy || count === 0,
5981
5940
  onClick: submit
5982
- }, picked.length > 0 ? ChannelWords.format(w.addCount, { count: String(picked.length) }) : w.add, busy && /* @__PURE__ */ React.createElement("span", {
5941
+ }, count > 0 ? ChannelWords.format(w.addCount, { count: String(count) }) : w.add, busy && /* @__PURE__ */ React.createElement("span", {
5983
5942
  className: "ta-spinner ta-busy-mark ta-on-brand"
5984
5943
  }))));
5985
5944
  }
5986
5945
 
5946
+ // web-src/partners.tsx
5947
+ class ChannelPartners {
5948
+ context;
5949
+ current = [];
5950
+ signature = "";
5951
+ listeners = new Set;
5952
+ faces = new Map;
5953
+ read = new Set;
5954
+ constructor(context) {
5955
+ this.context = context;
5956
+ }
5957
+ partners = () => this.current;
5958
+ subscribe = (listener) => {
5959
+ this.listeners.add(listener);
5960
+ return () => this.listeners.delete(listener);
5961
+ };
5962
+ start() {
5963
+ const stopService = this.context.service.subscribe(() => this.refresh());
5964
+ const stopUi = this.context.ui.subscribe(() => this.refresh());
5965
+ this.refresh();
5966
+ return () => {
5967
+ stopService();
5968
+ stopUi();
5969
+ };
5970
+ }
5971
+ add() {
5972
+ const { pi } = this.context;
5973
+ return [{ key: "agent", label: ChannelViews.words(pi).newAgent, icon: ChannelViews.icon(pi, "Bot"), run: () => newAgent(this.context) }];
5974
+ }
5975
+ async group(members) {
5976
+ if (!members.every((member) => member.extension === NAME && member.kind === "agent")) {
5977
+ return false;
5978
+ }
5979
+ const { service } = this.context;
5980
+ const names = members.map((member) => member.name.replace(/[@#,]/g, "")).join("、");
5981
+ const name = ChannelsUtil.freeName(service.state.team, names.length > MAX_NAME - 3 ? `${names.slice(0, MAX_NAME - 4)}…` : names);
5982
+ const channel = await service.createChannel({ name, members: members.map((member) => member.id) });
5983
+ this.context.showChannel(channel.id);
5984
+ return true;
5985
+ }
5986
+ addon() {
5987
+ const { pi, service } = this.context;
5988
+ const before = (roomId) => ChannelsUtil.ownChannels(service.state.team).find((channel) => channel.shared === roomId);
5989
+ return {
5990
+ tile: (room) => before(room.id) ? { label: ChannelViews.words(pi).sharedBeforeTile, icon: "Clock", status: ChannelViews.words(pi).sharedBefore } : undefined,
5991
+ open: (room) => {
5992
+ const channel = before(room.id);
5993
+ if (channel) {
5994
+ this.context.showChannel(channel.id);
5995
+ }
5996
+ },
5997
+ subscribe: (listener) => service.subscribe(listener)
5998
+ };
5999
+ }
6000
+ refresh() {
6001
+ const { pi, service, ui } = this.context;
6002
+ const { team, messages, working, loaded } = service.state;
6003
+ if (!loaded) {
6004
+ return;
6005
+ }
6006
+ const channels = ChannelsUtil.liveChannels(team);
6007
+ for (const channel of channels) {
6008
+ if (!this.read.has(channel.id)) {
6009
+ this.read.add(channel.id);
6010
+ service.messages(channel.id).catch(() => {
6011
+ return;
6012
+ });
6013
+ }
6014
+ }
6015
+ const agents = ChannelsUtil.standing(team);
6016
+ const { fresh } = ui.state;
6017
+ const language = pi.ui.language;
6018
+ const signature = [
6019
+ language,
6020
+ ...agents.map((agent) => [agent.id, agent.name, agent.role, agent.face, agent.sessionFile ?? "", agent.cwd ?? ""].join(":")),
6021
+ ...channels.map((channel) => [
6022
+ channel.id,
6023
+ channel.name,
6024
+ channel.topic ?? "",
6025
+ channel.members.join("/"),
6026
+ messages[channel.id]?.at(-1)?.id ?? "",
6027
+ (working[channel.id] ?? []).join("/"),
6028
+ fresh.includes(channel.id) ? 1 : 0
6029
+ ].join(":"))
6030
+ ].join("|");
6031
+ if (signature === this.signature) {
6032
+ return;
6033
+ }
6034
+ this.signature = signature;
6035
+ const w = ChannelWords.of(language);
6036
+ this.current = [...agents.map((agent) => this.agent(agent)), ...channels.map((channel) => this.channel(channel, w))];
6037
+ for (const listener of this.listeners) {
6038
+ listener();
6039
+ }
6040
+ }
6041
+ agent(agent) {
6042
+ const { pi } = this.context;
6043
+ const w = ChannelViews.words(pi);
6044
+ return {
6045
+ id: agent.id,
6046
+ kind: "agent",
6047
+ name: agent.name,
6048
+ face: this.agentFace(agent.id),
6049
+ icon: ChannelViews.icon(pi, "Bot"),
6050
+ about: agent.role,
6051
+ chat: agent.sessionFile ? { sessionFile: agent.sessionFile } : undefined,
6052
+ location: agent.cwd,
6053
+ open: () => ChannelViews.openAgent(this.context, agent.id),
6054
+ menu: () => [[{ key: "delete", label: w.deleteAgent, danger: true, run: () => void deleteAgent(this.context, agent) }]]
6055
+ };
6056
+ }
6057
+ channel(channel, w) {
6058
+ const { pi, service, ui } = this.context;
6059
+ const { team, messages, working } = service.state;
6060
+ const busy = working[channel.id] ?? [];
6061
+ const name = (id) => ChannelsText.authorName(team, id, { user: w.you, ta: w.ta });
6062
+ const last = messages[channel.id]?.filter((message) => message.author !== SYSTEM).at(-1);
6063
+ return {
6064
+ id: channel.id,
6065
+ kind: "group",
6066
+ name: channel.name,
6067
+ face: this.channelFace(channel.id),
6068
+ icon: ChannelViews.icon(pi, "Hash"),
6069
+ about: channel.topic ?? membersOf(team, channel).map((agent) => agent.name).join("、"),
6070
+ chat: {
6071
+ last: busy.length > 0 ? ChannelWords.format(w.answeringNow, { name: busy.map(name).join("、") }) : last ? `${name(last.author)}:${last.text.replace(/\s+/g, " ")}` : undefined,
6072
+ at: SidebarUtil.channelAt(channel, messages[channel.id]),
6073
+ unseen: ui.state.fresh.includes(channel.id),
6074
+ busy: busy.length > 0
6075
+ },
6076
+ open: () => this.context.showChannel(channel.id),
6077
+ menu: () => [[{ key: "delete", label: w.deleteChannel, danger: true, run: () => void deleteChannel(this.context, channel) }]]
6078
+ };
6079
+ }
6080
+ agentFace(id) {
6081
+ return this.face(`agent:${id}`, function AgentFace({ size, state: { team, working } }) {
6082
+ const faces = useFaces(team);
6083
+ return /* @__PURE__ */ React.createElement(Face, {
6084
+ face: faces.get(id) ?? 0,
6085
+ size,
6086
+ working: Object.values(working).some((ids) => ids.includes(id))
6087
+ });
6088
+ });
6089
+ }
6090
+ channelFace(id) {
6091
+ return this.face(`channel:${id}`, function ChannelFace({ size, state: { team, working } }) {
6092
+ const faces = useFaces(team);
6093
+ const channel = team.channels.find((each) => each.id === id);
6094
+ return /* @__PURE__ */ React.createElement(RoomFace, {
6095
+ members: channel ? membersOf(team, channel) : [],
6096
+ faces,
6097
+ size,
6098
+ working: working[id] ?? []
6099
+ });
6100
+ });
6101
+ }
6102
+ face(key, Draw) {
6103
+ let face = this.faces.get(key);
6104
+ if (!face) {
6105
+ const { service } = this.context;
6106
+ face = function PartnerFace({ size }) {
6107
+ const state = React.useSyncExternalStore((listener) => service.subscribe(listener), () => service.state);
6108
+ return /* @__PURE__ */ React.createElement(Draw, {
6109
+ size,
6110
+ state
6111
+ });
6112
+ };
6113
+ this.faces.set(key, face);
6114
+ }
6115
+ return face;
6116
+ }
6117
+ }
6118
+
5987
6119
  // web-src/sidebar-hooks.ts
5988
6120
  var FOLDED_KEY = "ta-channels.folded";
5989
6121
  var BY_DIRECTORY_KEY = "ui.membersByDirectory";
@@ -6412,7 +6544,7 @@ function AgentsSidebar({ context, partners = false }) {
6412
6544
  const Empty = pi.ui.Empty;
6413
6545
  const Loading = pi.ui.Loading ?? pi.ui.Skeleton;
6414
6546
  const { team, working } = state;
6415
- const own = React.useMemo(() => ChannelsUtil.ownChannels(team), [team]);
6547
+ const own = React.useMemo(() => ChannelsUtil.liveChannels(team), [team]);
6416
6548
  const seen = useSeenTasks(pi.storage, tasks);
6417
6549
  const said = Object.values(state.messages).reduce((count, list) => count + list.length, 0);
6418
6550
  const sessionLines = useSessionLines(context, `${said}:${Object.values(working).flat().join(",")}:${team.agents.length}`);
@@ -7087,6 +7219,7 @@ textarea.tac-input { resize: vertical; min-height: 56px; line-height: 1.5; }
7087
7219
  .tac-members-label { padding: 10px 10px 6px; color: var(--ta-muted); font-size: calc(12px * var(--ta-font-scale)); }
7088
7220
  .tac-members-head { display: flex; align-items: center; gap: 6px; flex: none; padding: 10px 12px 4px 8px; font-size: calc(13.5px * var(--ta-font-scale)); }
7089
7221
  .tac-members-search { flex: none; margin: 6px 16px 2px; }
7222
+ .tac-members-note { padding: 4px 10px 8px; color: var(--ta-muted); font-size: calc(12px * var(--ta-font-scale)); line-height: 1.5; }
7090
7223
  .tac-members-sep { height: 1px; margin: 6px 10px; background: var(--ta-border-muted); }
7091
7224
  .tac-member { position: relative; display: flex; align-items: center; border-radius: 12px; transition: background 120ms; }
7092
7225
  .tac-member:hover, .tac-member:focus-within { background: var(--ta-hover); }
@@ -7413,21 +7546,28 @@ function activate(pi) {
7413
7546
  new ChannelToolLines(context).register();
7414
7547
  pi.registerMessageRenderer(HandOff.CARD, HandOffView.card(context));
7415
7548
  pi.registerComposerAddon(HandOffView.composerAddon(context));
7416
- const partners = !!pi.ui.doubleInChats;
7417
- pi.registerView("channels", {
7418
- title: () => partners ? ChannelWords.of(pi.ui.language).partners : ChannelWords.of(pi.ui.language).title,
7419
- icon: ChannelViews.icon(pi, partners ? "Users" : "Bot"),
7420
- head: () => /* @__PURE__ */ React.createElement(SidebarHead, {
7421
- context
7422
- }),
7423
- render: () => /* @__PURE__ */ React.createElement(AgentsSidebar, {
7424
- context,
7425
- partners
7426
- }),
7427
- location: "sidebar",
7428
- pages: partners ? [CHANNEL_PAGE, AGENT_PAGE] : [DOUBLE_PAGE, CHANNEL_PAGE, AGENT_PAGE],
7429
- order: 80
7430
- });
7549
+ const shared = typeof pi.registerPartners === "function" ? new ChannelPartners(context) : undefined;
7550
+ const stopPartners = shared?.start();
7551
+ if (shared) {
7552
+ pi.registerPartners(shared);
7553
+ pi.registerRoomAddon?.(shared.addon());
7554
+ } else {
7555
+ const partners = !!pi.ui.doubleInChats;
7556
+ pi.registerView("channels", {
7557
+ title: () => partners ? ChannelWords.of(pi.ui.language).partners : ChannelWords.of(pi.ui.language).title,
7558
+ icon: ChannelViews.icon(pi, partners ? "Users" : "Bot"),
7559
+ head: () => /* @__PURE__ */ React.createElement(SidebarHead, {
7560
+ context
7561
+ }),
7562
+ render: () => /* @__PURE__ */ React.createElement(AgentsSidebar, {
7563
+ context,
7564
+ partners
7565
+ }),
7566
+ location: "sidebar",
7567
+ pages: partners ? [CHANNEL_PAGE, AGENT_PAGE] : [DOUBLE_PAGE, CHANNEL_PAGE, AGENT_PAGE],
7568
+ order: 80
7569
+ });
7570
+ }
7431
7571
  pi.registerView("channel", {
7432
7572
  title: () => {
7433
7573
  const channel = service.state.team.channels.find((candidate) => candidate.id === ui.state.channelId);
@@ -7473,6 +7613,7 @@ function activate(pi) {
7473
7613
  service.load();
7474
7614
  return () => {
7475
7615
  stopFocus();
7616
+ stopPartners?.();
7476
7617
  service.dispose();
7477
7618
  removeStyle();
7478
7619
  };