@celljs/ta-channels 4.27.0 → 4.29.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/extension/index.mjs +48 -29
- package/host/index.mjs +487 -66
- package/package.json +4 -4
- package/web/index.js +87 -32
package/extension/index.mjs
CHANGED
|
@@ -830,33 +830,6 @@ var ChannelsUtil;
|
|
|
830
830
|
return { team: next, channel, agents };
|
|
831
831
|
}
|
|
832
832
|
ChannelsUtil.setChannelModel = setChannelModel;
|
|
833
|
-
function removeAgent(team, ref) {
|
|
834
|
-
const agent = findAgent(team, typeof ref === "string" ? ref : "");
|
|
835
|
-
if (!agent) {
|
|
836
|
-
throw new Error(`No agent is ${String(ref)}.`);
|
|
837
|
-
}
|
|
838
|
-
const gone = [];
|
|
839
|
-
const channels = [];
|
|
840
|
-
for (const channel of team.channels) {
|
|
841
|
-
if (!channel.members.includes(agent.id)) {
|
|
842
|
-
channels.push(channel);
|
|
843
|
-
continue;
|
|
844
|
-
}
|
|
845
|
-
const members = channel.members.filter((id) => id !== agent.id);
|
|
846
|
-
if (members.length === 0) {
|
|
847
|
-
gone.push(channel);
|
|
848
|
-
continue;
|
|
849
|
-
}
|
|
850
|
-
const muted = channel.muted?.filter((id) => id !== agent.id);
|
|
851
|
-
const next = { ...channel, members, muted };
|
|
852
|
-
if (!muted?.length) {
|
|
853
|
-
delete next.muted;
|
|
854
|
-
}
|
|
855
|
-
channels.push(next);
|
|
856
|
-
}
|
|
857
|
-
return { team: { agents: team.agents.filter((other) => other.id !== agent.id), channels }, agent, channels: gone };
|
|
858
|
-
}
|
|
859
|
-
ChannelsUtil.removeAgent = removeAgent;
|
|
860
833
|
function agentIds(team, refs) {
|
|
861
834
|
const ids = [];
|
|
862
835
|
for (const ref of Array.isArray(refs) ? refs.filter((item) => typeof item === "string") : []) {
|
|
@@ -1111,6 +1084,40 @@ var TaAgentSummary;
|
|
|
1111
1084
|
}
|
|
1112
1085
|
TaAgentSummary2.strip = strip;
|
|
1113
1086
|
})(TaAgentSummary || (TaAgentSummary = {}));
|
|
1087
|
+
var TaPictureNote;
|
|
1088
|
+
(function(TaPictureNote2) {
|
|
1089
|
+
TaPictureNote2.OPEN = "<pictures>";
|
|
1090
|
+
TaPictureNote2.CLOSE = "</pictures>";
|
|
1091
|
+
const BLOCK = /[ \t]*<pictures>([\s\S]*?)(?:<\/pictures>|$)|<p(?:i(?:c(?:t(?:u(?:r(?:es?)?)?)?)?)?)?$/gi;
|
|
1092
|
+
const ROW = /(?:^|\s)[-*]?\s*p(\d+)\s*[::]\s*/gi;
|
|
1093
|
+
function take(text) {
|
|
1094
|
+
const told = new Map;
|
|
1095
|
+
if (!/<p/i.test(text)) {
|
|
1096
|
+
return { said: text, told };
|
|
1097
|
+
}
|
|
1098
|
+
const said = text.replace(BLOCK, (_all, body) => {
|
|
1099
|
+
const rows = [...(body !== null && body !== undefined ? body : "").matchAll(ROW)];
|
|
1100
|
+
rows.forEach((row, index) => {
|
|
1101
|
+
var _a;
|
|
1102
|
+
var _b, _c;
|
|
1103
|
+
const end = (_b = (_a = rows[index + 1]) === null || _a === undefined ? undefined : _a.index) !== null && _b !== undefined ? _b : body === null || body === undefined ? undefined : body.length;
|
|
1104
|
+
const what = body === null || body === undefined ? undefined : body.slice(((_c = row.index) !== null && _c !== undefined ? _c : 0) + row[0].length, end).trim();
|
|
1105
|
+
if (what) {
|
|
1106
|
+
told.set(Number(row[1]), what);
|
|
1107
|
+
}
|
|
1108
|
+
});
|
|
1109
|
+
return "";
|
|
1110
|
+
});
|
|
1111
|
+
return { said: said === text ? text : said.replace(/\n{3,}/g, `
|
|
1112
|
+
|
|
1113
|
+
`).trim(), told };
|
|
1114
|
+
}
|
|
1115
|
+
TaPictureNote2.take = take;
|
|
1116
|
+
function strip(text) {
|
|
1117
|
+
return take(text).said;
|
|
1118
|
+
}
|
|
1119
|
+
TaPictureNote2.strip = strip;
|
|
1120
|
+
})(TaPictureNote || (TaPictureNote = {}));
|
|
1114
1121
|
var TaSkillUse;
|
|
1115
1122
|
(function(TaSkillUse2) {
|
|
1116
1123
|
const BLOCK = /^<skill name="([^"]+)" location="([^"]+)">\n([\s\S]*?)\n<\/skill>(?:\n\n([\s\S]+))?$/;
|
|
@@ -1461,7 +1468,8 @@ var TaSaid;
|
|
|
1461
1468
|
["image note", /\[Image: original \d+x\d+|\[Image converted from /],
|
|
1462
1469
|
["skill", /<skill name="|<\/skill>/],
|
|
1463
1470
|
["task note", /<\/?task_(?:update|adopted|renamed)\b/],
|
|
1464
|
-
["summary", /<\/?(?:conversation_history_summary|summary)>/]
|
|
1471
|
+
["summary", /<\/?(?:conversation_history_summary|summary)>/],
|
|
1472
|
+
["pictures described", /<\/?pictures>/]
|
|
1465
1473
|
];
|
|
1466
1474
|
function text(content, joiner = `
|
|
1467
1475
|
`) {
|
|
@@ -1472,7 +1480,7 @@ var TaSaid;
|
|
|
1472
1480
|
}
|
|
1473
1481
|
TaSaid2.text = text;
|
|
1474
1482
|
function words(role, text2, options = {}) {
|
|
1475
|
-
const said = role === "user" ? userWords(text2) : TaAgentSummary.strip(text2);
|
|
1483
|
+
const said = role === "user" ? userWords(text2) : TaPictureNote.strip(TaAgentSummary.strip(text2));
|
|
1476
1484
|
return withoutFences(said, (language) => options.cards === false && CARD.test(language), true).trim();
|
|
1477
1485
|
}
|
|
1478
1486
|
TaSaid2.words = words;
|
|
@@ -1591,6 +1599,17 @@ Switched to voice.`, said: "Switched to voice." },
|
|
|
1591
1599
|
{ mark: "a card alone", role: "assistant", text: '```ta-glance\n{"status":"done","blocks":[]}\n```' },
|
|
1592
1600
|
{ mark: "a proposal", role: "assistant", text: 'Committed.\n\n```ta-propose\n{"kind":"git.push","title":"Push"}\n```', said: "Committed." },
|
|
1593
1601
|
{ mark: "what a call says aloud", role: "assistant", text: "All fixed.\n\n```ta-say\nIt is fixed.\n```", said: "All fixed." },
|
|
1602
|
+
{
|
|
1603
|
+
mark: "pictures described after the answer",
|
|
1604
|
+
role: "assistant",
|
|
1605
|
+
text: `The left one.
|
|
1606
|
+
|
|
1607
|
+
<pictures> p1: two cats on a sofa. p2: a chart of sales, "Q4". </pictures>`,
|
|
1608
|
+
said: "The left one."
|
|
1609
|
+
},
|
|
1610
|
+
{ mark: "pictures described as it streams", role: "assistant", text: `The left one.
|
|
1611
|
+
<pictures>
|
|
1612
|
+
p1: two ca`, said: "The left one." },
|
|
1594
1613
|
{ mark: "a tag not known yet", role: "assistant", text: `<system-reminder>
|
|
1595
1614
|
</system-reminder>
|
|
1596
1615
|
Ready.`, said: "Ready." }
|
package/host/index.mjs
CHANGED
|
@@ -212,6 +212,40 @@ var TaAgentSummary;
|
|
|
212
212
|
}
|
|
213
213
|
TaAgentSummary2.strip = strip;
|
|
214
214
|
})(TaAgentSummary || (TaAgentSummary = {}));
|
|
215
|
+
var TaPictureNote;
|
|
216
|
+
(function(TaPictureNote2) {
|
|
217
|
+
TaPictureNote2.OPEN = "<pictures>";
|
|
218
|
+
TaPictureNote2.CLOSE = "</pictures>";
|
|
219
|
+
const BLOCK = /[ \t]*<pictures>([\s\S]*?)(?:<\/pictures>|$)|<p(?:i(?:c(?:t(?:u(?:r(?:es?)?)?)?)?)?)?$/gi;
|
|
220
|
+
const ROW = /(?:^|\s)[-*]?\s*p(\d+)\s*[::]\s*/gi;
|
|
221
|
+
function take(text) {
|
|
222
|
+
const told = new Map;
|
|
223
|
+
if (!/<p/i.test(text)) {
|
|
224
|
+
return { said: text, told };
|
|
225
|
+
}
|
|
226
|
+
const said = text.replace(BLOCK, (_all, body) => {
|
|
227
|
+
const rows = [...(body !== null && body !== undefined ? body : "").matchAll(ROW)];
|
|
228
|
+
rows.forEach((row, index) => {
|
|
229
|
+
var _a;
|
|
230
|
+
var _b, _c;
|
|
231
|
+
const end = (_b = (_a = rows[index + 1]) === null || _a === undefined ? undefined : _a.index) !== null && _b !== undefined ? _b : body === null || body === undefined ? undefined : body.length;
|
|
232
|
+
const what = body === null || body === undefined ? undefined : body.slice(((_c = row.index) !== null && _c !== undefined ? _c : 0) + row[0].length, end).trim();
|
|
233
|
+
if (what) {
|
|
234
|
+
told.set(Number(row[1]), what);
|
|
235
|
+
}
|
|
236
|
+
});
|
|
237
|
+
return "";
|
|
238
|
+
});
|
|
239
|
+
return { said: said === text ? text : said.replace(/\n{3,}/g, `
|
|
240
|
+
|
|
241
|
+
`).trim(), told };
|
|
242
|
+
}
|
|
243
|
+
TaPictureNote2.take = take;
|
|
244
|
+
function strip(text) {
|
|
245
|
+
return take(text).said;
|
|
246
|
+
}
|
|
247
|
+
TaPictureNote2.strip = strip;
|
|
248
|
+
})(TaPictureNote || (TaPictureNote = {}));
|
|
215
249
|
var TaSkillUse;
|
|
216
250
|
(function(TaSkillUse2) {
|
|
217
251
|
const BLOCK = /^<skill name="([^"]+)" location="([^"]+)">\n([\s\S]*?)\n<\/skill>(?:\n\n([\s\S]+))?$/;
|
|
@@ -689,6 +723,7 @@ var LIMIT_CHOICES = {
|
|
|
689
723
|
channelDay: [2000000, 5000000, 20000000, 0],
|
|
690
724
|
allDay: [5000000, 20000000, 0]
|
|
691
725
|
};
|
|
726
|
+
var REMOVED_DAYS = 30;
|
|
692
727
|
var NAME = "@celljs/ta-channels";
|
|
693
728
|
var AGENT_MARK = "one of the agents of Ta";
|
|
694
729
|
var MEMBER_CHANGES = ["lead", "remove", "mute", "unmute"];
|
|
@@ -1161,33 +1196,6 @@ var ChannelsUtil;
|
|
|
1161
1196
|
return { team: next, channel, agents };
|
|
1162
1197
|
}
|
|
1163
1198
|
ChannelsUtil.setChannelModel = setChannelModel;
|
|
1164
|
-
function removeAgent(team, ref) {
|
|
1165
|
-
const agent = findAgent(team, typeof ref === "string" ? ref : "");
|
|
1166
|
-
if (!agent) {
|
|
1167
|
-
throw new Error(`No agent is ${String(ref)}.`);
|
|
1168
|
-
}
|
|
1169
|
-
const gone = [];
|
|
1170
|
-
const channels = [];
|
|
1171
|
-
for (const channel of team.channels) {
|
|
1172
|
-
if (!channel.members.includes(agent.id)) {
|
|
1173
|
-
channels.push(channel);
|
|
1174
|
-
continue;
|
|
1175
|
-
}
|
|
1176
|
-
const members = channel.members.filter((id) => id !== agent.id);
|
|
1177
|
-
if (members.length === 0) {
|
|
1178
|
-
gone.push(channel);
|
|
1179
|
-
continue;
|
|
1180
|
-
}
|
|
1181
|
-
const muted = channel.muted?.filter((id) => id !== agent.id);
|
|
1182
|
-
const next = { ...channel, members, muted };
|
|
1183
|
-
if (!muted?.length) {
|
|
1184
|
-
delete next.muted;
|
|
1185
|
-
}
|
|
1186
|
-
channels.push(next);
|
|
1187
|
-
}
|
|
1188
|
-
return { team: { agents: team.agents.filter((other) => other.id !== agent.id), channels }, agent, channels: gone };
|
|
1189
|
-
}
|
|
1190
|
-
ChannelsUtil.removeAgent = removeAgent;
|
|
1191
1199
|
function agentIds(team, refs) {
|
|
1192
1200
|
const ids = [];
|
|
1193
1201
|
for (const ref of Array.isArray(refs) ? refs.filter((item) => typeof item === "string") : []) {
|
|
@@ -1293,7 +1301,8 @@ var TaSaid;
|
|
|
1293
1301
|
["image note", /\[Image: original \d+x\d+|\[Image converted from /],
|
|
1294
1302
|
["skill", /<skill name="|<\/skill>/],
|
|
1295
1303
|
["task note", /<\/?task_(?:update|adopted|renamed)\b/],
|
|
1296
|
-
["summary", /<\/?(?:conversation_history_summary|summary)>/]
|
|
1304
|
+
["summary", /<\/?(?:conversation_history_summary|summary)>/],
|
|
1305
|
+
["pictures described", /<\/?pictures>/]
|
|
1297
1306
|
];
|
|
1298
1307
|
function text(content, joiner = `
|
|
1299
1308
|
`) {
|
|
@@ -1304,7 +1313,7 @@ var TaSaid;
|
|
|
1304
1313
|
}
|
|
1305
1314
|
TaSaid2.text = text;
|
|
1306
1315
|
function words(role, text2, options = {}) {
|
|
1307
|
-
const said = role === "user" ? userWords(text2) : TaAgentSummary.strip(text2);
|
|
1316
|
+
const said = role === "user" ? userWords(text2) : TaPictureNote.strip(TaAgentSummary.strip(text2));
|
|
1308
1317
|
return withoutFences(said, (language) => options.cards === false && CARD.test(language), true).trim();
|
|
1309
1318
|
}
|
|
1310
1319
|
TaSaid2.words = words;
|
|
@@ -1423,6 +1432,17 @@ Switched to voice.`, said: "Switched to voice." },
|
|
|
1423
1432
|
{ mark: "a card alone", role: "assistant", text: '```ta-glance\n{"status":"done","blocks":[]}\n```' },
|
|
1424
1433
|
{ mark: "a proposal", role: "assistant", text: 'Committed.\n\n```ta-propose\n{"kind":"git.push","title":"Push"}\n```', said: "Committed." },
|
|
1425
1434
|
{ mark: "what a call says aloud", role: "assistant", text: "All fixed.\n\n```ta-say\nIt is fixed.\n```", said: "All fixed." },
|
|
1435
|
+
{
|
|
1436
|
+
mark: "pictures described after the answer",
|
|
1437
|
+
role: "assistant",
|
|
1438
|
+
text: `The left one.
|
|
1439
|
+
|
|
1440
|
+
<pictures> p1: two cats on a sofa. p2: a chart of sales, "Q4". </pictures>`,
|
|
1441
|
+
said: "The left one."
|
|
1442
|
+
},
|
|
1443
|
+
{ mark: "pictures described as it streams", role: "assistant", text: `The left one.
|
|
1444
|
+
<pictures>
|
|
1445
|
+
p1: two ca`, said: "The left one." },
|
|
1426
1446
|
{ mark: "a tag not known yet", role: "assistant", text: `<system-reminder>
|
|
1427
1447
|
</system-reminder>
|
|
1428
1448
|
Ready.`, said: "Ready." }
|
|
@@ -1792,6 +1812,85 @@ ${brief.trim()}`;
|
|
|
1792
1812
|
HandOff.result = result;
|
|
1793
1813
|
})(HandOff ||= {});
|
|
1794
1814
|
|
|
1815
|
+
// web-src/removed-agents.ts
|
|
1816
|
+
var RemovedAgentsUtil;
|
|
1817
|
+
((RemovedAgentsUtil) => {
|
|
1818
|
+
function remove(team, ref, at = Date.now()) {
|
|
1819
|
+
const agent = ChannelsUtil.findAgent(team, typeof ref === "string" ? ref : "");
|
|
1820
|
+
if (!agent) {
|
|
1821
|
+
throw new Error(`No agent is ${String(ref)}.`);
|
|
1822
|
+
}
|
|
1823
|
+
const gone = [];
|
|
1824
|
+
const channels = [];
|
|
1825
|
+
for (const channel of team.channels) {
|
|
1826
|
+
if (!channel.members.includes(agent.id)) {
|
|
1827
|
+
channels.push(channel);
|
|
1828
|
+
continue;
|
|
1829
|
+
}
|
|
1830
|
+
const members = channel.members.filter((id) => id !== agent.id);
|
|
1831
|
+
if (members.length === 0) {
|
|
1832
|
+
gone.push(channel);
|
|
1833
|
+
continue;
|
|
1834
|
+
}
|
|
1835
|
+
const muted = channel.muted?.filter((id) => id !== agent.id);
|
|
1836
|
+
const next = { ...channel, members, muted };
|
|
1837
|
+
if (!muted?.length) {
|
|
1838
|
+
delete next.muted;
|
|
1839
|
+
}
|
|
1840
|
+
channels.push(next);
|
|
1841
|
+
}
|
|
1842
|
+
const kept = {
|
|
1843
|
+
agent,
|
|
1844
|
+
at,
|
|
1845
|
+
channels: channels.filter((channel) => team.channels.some((before) => before.id === channel.id && before.members.includes(agent.id))).map((channel) => channel.id),
|
|
1846
|
+
gone
|
|
1847
|
+
};
|
|
1848
|
+
return {
|
|
1849
|
+
team: { ...team, agents: team.agents.filter((other) => other.id !== agent.id), channels, removed: [...team.removed ?? [], kept] },
|
|
1850
|
+
agent,
|
|
1851
|
+
channels: gone
|
|
1852
|
+
};
|
|
1853
|
+
}
|
|
1854
|
+
RemovedAgentsUtil.remove = remove;
|
|
1855
|
+
function restore(team, ref) {
|
|
1856
|
+
const kept = (team.removed ?? []).find((one) => one.agent.id === ref);
|
|
1857
|
+
if (!kept) {
|
|
1858
|
+
throw new Error(`No removed agent is ${String(ref)}.`);
|
|
1859
|
+
}
|
|
1860
|
+
const agent = { ...kept.agent, name: ChannelsUtil.freeName(team, kept.agent.name) };
|
|
1861
|
+
const channels = team.channels.map((channel) => kept.channels.includes(channel.id) && !channel.members.includes(agent.id) && channel.members.length < MAX_MEMBERS ? { ...channel, members: [...channel.members, agent.id] } : channel);
|
|
1862
|
+
const back = [];
|
|
1863
|
+
for (const channel of kept.gone) {
|
|
1864
|
+
let name = channel.name;
|
|
1865
|
+
for (let count = 2;ChannelsUtil.findChannel({ ...team, channels: [...channels, ...back] }, name); count++) {
|
|
1866
|
+
name = `${channel.name}-${count}`;
|
|
1867
|
+
}
|
|
1868
|
+
back.push({ ...channel, name });
|
|
1869
|
+
}
|
|
1870
|
+
const removed = (team.removed ?? []).filter((one) => one !== kept);
|
|
1871
|
+
const next = { ...team, agents: [...team.agents, agent], channels: [...channels, ...back], removed };
|
|
1872
|
+
if (!removed.length) {
|
|
1873
|
+
delete next.removed;
|
|
1874
|
+
}
|
|
1875
|
+
return { team: next, agent, channels: back };
|
|
1876
|
+
}
|
|
1877
|
+
RemovedAgentsUtil.restore = restore;
|
|
1878
|
+
function forget(team, now) {
|
|
1879
|
+
const since = now - REMOVED_DAYS * 24 * 60 * 60000;
|
|
1880
|
+
const old = (team.removed ?? []).filter((one) => one.at < since);
|
|
1881
|
+
if (!old.length) {
|
|
1882
|
+
return { team, channels: [] };
|
|
1883
|
+
}
|
|
1884
|
+
const removed = (team.removed ?? []).filter((one) => one.at >= since);
|
|
1885
|
+
const next = { ...team, removed };
|
|
1886
|
+
if (!removed.length) {
|
|
1887
|
+
delete next.removed;
|
|
1888
|
+
}
|
|
1889
|
+
return { team: next, channels: old.flatMap((one) => one.gone) };
|
|
1890
|
+
}
|
|
1891
|
+
RemovedAgentsUtil.forget = forget;
|
|
1892
|
+
})(RemovedAgentsUtil ||= {});
|
|
1893
|
+
|
|
1795
1894
|
// web-src/round-rules.ts
|
|
1796
1895
|
var ChannelRounds;
|
|
1797
1896
|
((ChannelRounds) => {
|
|
@@ -1927,6 +2026,28 @@ var TA_SIGN_IN_PATH = "/sign-in";
|
|
|
1927
2026
|
var TA_DEVICE_SIGN_IN_PATH = `${TA_SIGN_IN_PATH}/device`;
|
|
1928
2027
|
// ../ta-protocol/esm/common/account-protocol.js
|
|
1929
2028
|
var TaAccountServer = Symbol("TaAccountServer");
|
|
2029
|
+
// ../ta-protocol/esm/common/agent-tool-util.js
|
|
2030
|
+
var TaAgentToolUtil;
|
|
2031
|
+
(function(TaAgentToolUtil2) {
|
|
2032
|
+
TaAgentToolUtil2.NAME = "agent_tool";
|
|
2033
|
+
const UNSHOWN = new Set(["content", "new_string", "old_string", "edits"]);
|
|
2034
|
+
function shownInput(input) {
|
|
2035
|
+
if (!Object.keys(input).some((key) => UNSHOWN.has(key))) {
|
|
2036
|
+
return input;
|
|
2037
|
+
}
|
|
2038
|
+
return Object.fromEntries(Object.entries(input).filter(([key]) => !UNSHOWN.has(key)));
|
|
2039
|
+
}
|
|
2040
|
+
TaAgentToolUtil2.shownInput = shownInput;
|
|
2041
|
+
function shownDetails(details) {
|
|
2042
|
+
const input = details === null || details === undefined ? undefined : details.input;
|
|
2043
|
+
if (!input || typeof input !== "object") {
|
|
2044
|
+
return details;
|
|
2045
|
+
}
|
|
2046
|
+
const shown = shownInput(input);
|
|
2047
|
+
return shown === input ? details : { ...details, input: shown };
|
|
2048
|
+
}
|
|
2049
|
+
TaAgentToolUtil2.shownDetails = shownDetails;
|
|
2050
|
+
})(TaAgentToolUtil || (TaAgentToolUtil = {}));
|
|
1930
2051
|
// ../ta-protocol/esm/common/ta-extension-host.js
|
|
1931
2052
|
var TA_WEBHOOK_MAX_BYTES = 256 * 1024;
|
|
1932
2053
|
var TA_HOST_EVENT = "ta:host";
|
|
@@ -2282,6 +2403,149 @@ var TaAppUtil;
|
|
|
2282
2403
|
})(TaAppUtil || (TaAppUtil = {}));
|
|
2283
2404
|
// ../ta-protocol/esm/common/auth-protocol.js
|
|
2284
2405
|
var TaAuthServer = Symbol("TaAuthServer");
|
|
2406
|
+
// ../ta-protocol/esm/common/call-moves.js
|
|
2407
|
+
var TaCallMoves;
|
|
2408
|
+
(function(TaCallMoves2) {
|
|
2409
|
+
TaCallMoves2.TEXT = 'You can move as asked, as a person on a sofa does: wave, make a heart with your hands, clap, laugh behind your hand, stand up and dance (you turn around once as you dance: it is the move for turning around or spinning) or stand up and stretch. Asked for one of them or one close to it: say in a few words that you do it, naming the move as it is ("给你比个心", "挥挥手", "我站起来跳支舞,转个圈给你看"), one move a reply; they see it as you say it, a dance or a stretch once you finish. Asked for any other move (jumping, walking about, lying down, turning around twice): say plainly that you cannot do it on this call and offer one you can; never say you do a move you do not.';
|
|
2410
|
+
const MOVES = [
|
|
2411
|
+
[
|
|
2412
|
+
"dance",
|
|
2413
|
+
/跳舞|跳个舞|跳支舞|跳一支|跳一段|跳给你看|看我跳|转(?:个|一|两|几|三)?圈|转一转|转个身|转身|旋转|ダンス|踊|回って|\b(?:danc(?:e|ing)|spin(?:ning)?|twirl\w*|turn(?:ing)? around)\b/i
|
|
2414
|
+
],
|
|
2415
|
+
["stretch", /伸(?:个|一个|一下)?懒腰|伸展|活动一下|起来走走|ストレッチ|\bstretch\w*\b/i],
|
|
2416
|
+
["heart", /比(?:个|一个|颗)?(?:爱)?心|笔芯|ハート|\b(?:(?:make|making|made) (?:you )?a heart|heart (?:sign|hands?))\b/i],
|
|
2417
|
+
["wave", /挥(?:挥|一挥|一下|个)?手|招(?:招|个|一下)?手|摆摆手|手を振|\bwav(?:e|es|ing)\b/i],
|
|
2418
|
+
["clap", /鼓(?:个|鼓|一下)?掌|拍(?:拍|个|一下)?手|拍掌|拍手|\b(?:clap\w*|applau\w*)\b/i],
|
|
2419
|
+
["laugh", /笑一个|笑一下|笑一笑|笑给你看|大笑|\blaugh(?:s|ing)?\b/i]
|
|
2420
|
+
];
|
|
2421
|
+
const STAND = ["stretch", /站起来|站起身|起身|立ち上が|\b(?:stand(?:ing)? up|get(?:ting)? up)\b/i];
|
|
2422
|
+
const NOT = /不会|不能|没法|没办法|做不了|做不到|跳不了|不行|不太方便|不(?=跳|转|比|挥|鼓|拍|伸|站|笑)|できない|無理|\b(?:can'?t|cannot|unable|won'?t|not able|don'?t)\b/i;
|
|
2423
|
+
const CLAUSES = /[,,、;;::]|\bbut\b/i;
|
|
2424
|
+
const STANDING = new Set(["dance", "stretch"]);
|
|
2425
|
+
function named(sentence) {
|
|
2426
|
+
var _a;
|
|
2427
|
+
const clauses = (sentence !== null && sentence !== undefined ? sentence : "").split(CLAUSES).filter((clause) => !NOT.test(clause));
|
|
2428
|
+
return (_a = first(clauses, MOVES)) !== null && _a !== undefined ? _a : first(clauses, [STAND]);
|
|
2429
|
+
}
|
|
2430
|
+
TaCallMoves2.named = named;
|
|
2431
|
+
function first(clauses, moves) {
|
|
2432
|
+
for (const clause of clauses) {
|
|
2433
|
+
let best;
|
|
2434
|
+
for (const [move, test] of moves) {
|
|
2435
|
+
const at = clause.search(test);
|
|
2436
|
+
if (at >= 0 && (!best || at < best.at)) {
|
|
2437
|
+
best = { move, at };
|
|
2438
|
+
}
|
|
2439
|
+
}
|
|
2440
|
+
if (best) {
|
|
2441
|
+
return best.move;
|
|
2442
|
+
}
|
|
2443
|
+
}
|
|
2444
|
+
return;
|
|
2445
|
+
}
|
|
2446
|
+
function standing(move) {
|
|
2447
|
+
return !!move && STANDING.has(move);
|
|
2448
|
+
}
|
|
2449
|
+
TaCallMoves2.standing = standing;
|
|
2450
|
+
})(TaCallMoves || (TaCallMoves = {}));
|
|
2451
|
+
// ../ta-protocol/esm/common/call-scene.js
|
|
2452
|
+
var TaCallSceneUtil;
|
|
2453
|
+
(function(TaCallSceneUtil2) {
|
|
2454
|
+
const VIEWS = {
|
|
2455
|
+
full: "the call fills their screen",
|
|
2456
|
+
mini: "the call is a small floating window while they look at other pages",
|
|
2457
|
+
window: "the call is a window of its own on their computer",
|
|
2458
|
+
panel: "the call is a panel of the page"
|
|
2459
|
+
};
|
|
2460
|
+
function text(scene, sees) {
|
|
2461
|
+
const from = scene.device ? `, from the user's ${scene.device}` : "";
|
|
2462
|
+
if (!scene.video) {
|
|
2463
|
+
return `Voice call${from}: they only hear you.`;
|
|
2464
|
+
}
|
|
2465
|
+
const view = scene.view ? `, ${VIEWS[scene.view]}` : "";
|
|
2466
|
+
const you = "They see you as a lifelike person made by AI, who says your words with face and expressions: they watch you as you talk.";
|
|
2467
|
+
const them = !scene.camera ? "Their camera is off: you cannot see them; never act as if you could." : sees ? "Their camera is on: what they say may come with a picture of them now." : "Their camera is on, but no picture of it reaches you: you cannot see them.";
|
|
2468
|
+
return `Video call${from}${view}. ${you} ${TaCallMoves.TEXT}${moves(scene.moves)} ${them}`;
|
|
2469
|
+
}
|
|
2470
|
+
TaCallSceneUtil2.text = text;
|
|
2471
|
+
function moves(list) {
|
|
2472
|
+
if (!(list === null || list === undefined ? undefined : list.length)) {
|
|
2473
|
+
return "";
|
|
2474
|
+
}
|
|
2475
|
+
const said = (move2) => `${move2.name} (${move2.words.slice(0, 3).map((word) => `"${word}"`).join(", ")})`;
|
|
2476
|
+
const as = list.filter((move2) => !move2.after);
|
|
2477
|
+
const after = list.filter((move2) => move2.after);
|
|
2478
|
+
return [
|
|
2479
|
+
" The user gave you moves of your own too, which you make as you say their words, as below; they count among those you can do.",
|
|
2480
|
+
as.length ? ` As you say it: ${as.map(said).join("; ")}.` : "",
|
|
2481
|
+
after.length ? ` Once you said you will, as you listen: ${after.map(said).join("; ")}; you sit down again as they speak.` : ""
|
|
2482
|
+
].join("");
|
|
2483
|
+
}
|
|
2484
|
+
function minutes(scene, now) {
|
|
2485
|
+
return Math.max(0, Math.floor((now - scene.since) / 60000));
|
|
2486
|
+
}
|
|
2487
|
+
TaCallSceneUtil2.minutes = minutes;
|
|
2488
|
+
function length(scene, now) {
|
|
2489
|
+
const minutes2 = TaCallSceneUtil2.minutes(scene, now);
|
|
2490
|
+
return minutes2 < 1 ? "Begun just now" : minutes2 < 60 ? `${minutes2} min so far` : `${Math.floor(minutes2 / 60)} h ${minutes2 % 60} min so far`;
|
|
2491
|
+
}
|
|
2492
|
+
TaCallSceneUtil2.length = length;
|
|
2493
|
+
function next(scene, told, sees, now) {
|
|
2494
|
+
const key2 = TaCallSceneUtil2.key(scene);
|
|
2495
|
+
const minutes2 = TaCallSceneUtil2.minutes(scene, now);
|
|
2496
|
+
if (key2 !== told.key) {
|
|
2497
|
+
const first = told.key === undefined;
|
|
2498
|
+
told.key = key2;
|
|
2499
|
+
told.minutes = minutes2;
|
|
2500
|
+
return `${first ? "The call" : "The call changed"}: ${text(scene, sees)} ${length(scene, now)}.`;
|
|
2501
|
+
}
|
|
2502
|
+
if (minutes2 !== told.minutes) {
|
|
2503
|
+
told.minutes = minutes2;
|
|
2504
|
+
return `The call: ${length(scene, now)}.`;
|
|
2505
|
+
}
|
|
2506
|
+
return;
|
|
2507
|
+
}
|
|
2508
|
+
TaCallSceneUtil2.next = next;
|
|
2509
|
+
function key(scene) {
|
|
2510
|
+
var _a, _b, _c;
|
|
2511
|
+
return [
|
|
2512
|
+
scene.video ? "video" : "voice",
|
|
2513
|
+
scene.camera ? "camera" : "",
|
|
2514
|
+
(_a = scene.view) !== null && _a !== undefined ? _a : "",
|
|
2515
|
+
(_b = scene.device) !== null && _b !== undefined ? _b : "",
|
|
2516
|
+
((_c = scene.moves) !== null && _c !== undefined ? _c : []).map((move2) => move2.name).join(",")
|
|
2517
|
+
].join(":");
|
|
2518
|
+
}
|
|
2519
|
+
TaCallSceneUtil2.key = key;
|
|
2520
|
+
function of(value) {
|
|
2521
|
+
const scene = value;
|
|
2522
|
+
if (!scene || typeof scene !== "object" || typeof scene.video !== "boolean" || typeof scene.since !== "number" || !Number.isFinite(scene.since)) {
|
|
2523
|
+
return;
|
|
2524
|
+
}
|
|
2525
|
+
const view = typeof scene.view === "string" && Object.keys(VIEWS).includes(scene.view) ? scene.view : undefined;
|
|
2526
|
+
const device = scene.device === "phone" || scene.device === "tablet" || scene.device === "computer" ? scene.device : undefined;
|
|
2527
|
+
const moves2 = Array.isArray(scene.moves) ? scene.moves.flatMap((move2) => TaCallSceneUtil2.move(move2)).slice(0, MOVES) : [];
|
|
2528
|
+
return {
|
|
2529
|
+
video: scene.video,
|
|
2530
|
+
...scene.camera === true ? { camera: true } : {},
|
|
2531
|
+
...view ? { view } : {},
|
|
2532
|
+
...device ? { device } : {},
|
|
2533
|
+
since: scene.since,
|
|
2534
|
+
...scene.video && moves2.length ? { moves: moves2 } : {}
|
|
2535
|
+
};
|
|
2536
|
+
}
|
|
2537
|
+
TaCallSceneUtil2.of = of;
|
|
2538
|
+
function move(value) {
|
|
2539
|
+
const move2 = value;
|
|
2540
|
+
if (!move2 || typeof move2.name !== "string" || !move2.name.trim() || !Array.isArray(move2.words)) {
|
|
2541
|
+
return [];
|
|
2542
|
+
}
|
|
2543
|
+
const words2 = move2.words.filter((word) => typeof word === "string" && !!word.trim()).map((word) => word.slice(0, 24)).slice(0, 3);
|
|
2544
|
+
return words2.length ? [{ name: move2.name.slice(0, 32), ...move2.after === true ? { after: true } : {}, words: words2 }] : [];
|
|
2545
|
+
}
|
|
2546
|
+
TaCallSceneUtil2.move = move;
|
|
2547
|
+
})(TaCallSceneUtil || (TaCallSceneUtil = {}));
|
|
2548
|
+
var MOVES = 40;
|
|
2285
2549
|
// ../ta-protocol/esm/common/confine-protocol.js
|
|
2286
2550
|
var TA_CONFINED_MARK = "[ta:confined]";
|
|
2287
2551
|
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+)*)*`;
|
|
@@ -2529,6 +2793,27 @@ var TaErrorUtil;
|
|
|
2529
2793
|
}
|
|
2530
2794
|
TaErrorUtil2.code = code;
|
|
2531
2795
|
})(TaErrorUtil || (TaErrorUtil = {}));
|
|
2796
|
+
// ../ta-protocol/esm/common/figure-protocol.js
|
|
2797
|
+
var TaFigure;
|
|
2798
|
+
(function(TaFigure2) {
|
|
2799
|
+
TaFigure2.DEFAULT_LANGUAGE = "ta-plot";
|
|
2800
|
+
function markdown(value) {
|
|
2801
|
+
if (typeof value === "string") {
|
|
2802
|
+
return value.trim() || undefined;
|
|
2803
|
+
}
|
|
2804
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
2805
|
+
return;
|
|
2806
|
+
}
|
|
2807
|
+
const keys = Object.keys(value);
|
|
2808
|
+
const wrapped = keys.length === 1 && /^ta-[a-z0-9-]+$/.test(keys[0]);
|
|
2809
|
+
const language = wrapped ? keys[0] : TaFigure2.DEFAULT_LANGUAGE;
|
|
2810
|
+
const spec = wrapped ? value[language] : value;
|
|
2811
|
+
return spec && typeof spec === "object" && Object.keys(spec).length ? `\`\`\`${language}
|
|
2812
|
+
${JSON.stringify(spec)}
|
|
2813
|
+
\`\`\`` : undefined;
|
|
2814
|
+
}
|
|
2815
|
+
TaFigure2.markdown = markdown;
|
|
2816
|
+
})(TaFigure || (TaFigure = {}));
|
|
2532
2817
|
// ../ta-protocol/esm/common/gateway-protocol.js
|
|
2533
2818
|
var TaGatewayServer = Symbol("TaGatewayServer");
|
|
2534
2819
|
// ../ta-protocol/esm/common/location.js
|
|
@@ -3038,7 +3323,10 @@ var TaPermissionUtil;
|
|
|
3038
3323
|
function host(manifest, method, kind) {
|
|
3039
3324
|
var _a, _b, _c, _d;
|
|
3040
3325
|
const host2 = (_a = manifest === null || manifest === undefined ? undefined : manifest.host) !== null && _a !== undefined ? _a : {};
|
|
3041
|
-
const own = (key) =>
|
|
3326
|
+
const own = (key) => {
|
|
3327
|
+
var _a2;
|
|
3328
|
+
return (_a2 = Object.getOwnPropertyDescriptor(host2, key)) === null || _a2 === undefined ? undefined : _a2.value;
|
|
3329
|
+
};
|
|
3042
3330
|
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;
|
|
3043
3331
|
}
|
|
3044
3332
|
TaPermissionUtil2.host = host;
|
|
@@ -3134,7 +3422,7 @@ var TaUsageServer = Symbol("TaUsageServer");
|
|
|
3134
3422
|
var TaVoiceServer = Symbol("TaVoiceServer");
|
|
3135
3423
|
var TaBargeIn;
|
|
3136
3424
|
(function(TaBargeIn2) {
|
|
3137
|
-
TaBargeIn2.DEFAULTS = { duck: 0.
|
|
3425
|
+
TaBargeIn2.DEFAULTS = { duck: 0.35, speechMs: 500, level: 0.02, words: 2, waitMs: 1500, echo: 0.3, joinMs: 300, tap: false };
|
|
3138
3426
|
TaBargeIn2.SENSITIVITY = [
|
|
3139
3427
|
{ speechMs: 1000, level: 0.05 },
|
|
3140
3428
|
{ speechMs: 750, level: 0.035 },
|
|
@@ -3195,6 +3483,120 @@ var TaExcludedFiles;
|
|
|
3195
3483
|
TaExcludedFiles2.filter = filter;
|
|
3196
3484
|
})(TaExcludedFiles || (TaExcludedFiles = {}));
|
|
3197
3485
|
var TA_UPLOAD_PART_BYTES = 4 * 1024 * 1024;
|
|
3486
|
+
// web-src/agent-usage.ts
|
|
3487
|
+
import { open } from "node:fs/promises";
|
|
3488
|
+
var DAY_MS = 24 * 60 * 60000;
|
|
3489
|
+
var USAGE_DAYS = 30;
|
|
3490
|
+
var TAIL_BYTES = 256 * 1024;
|
|
3491
|
+
var AgentUsageUtil;
|
|
3492
|
+
((AgentUsageUtil) => {
|
|
3493
|
+
async function read(team, messagesOf, now) {
|
|
3494
|
+
const messages = new Map;
|
|
3495
|
+
for (const channel of team.channels) {
|
|
3496
|
+
messages.set(channel.id, await messagesOf(channel.id));
|
|
3497
|
+
}
|
|
3498
|
+
const sessionTimes = new Map;
|
|
3499
|
+
for (const agent of team.agents) {
|
|
3500
|
+
const at = agent.sessionFile ? await lastAskedIn(agent.sessionFile) : undefined;
|
|
3501
|
+
if (agent.sessionFile && at) {
|
|
3502
|
+
sessionTimes.set(agent.sessionFile, at);
|
|
3503
|
+
}
|
|
3504
|
+
}
|
|
3505
|
+
return usage(team, messages, sessionTimes, now);
|
|
3506
|
+
}
|
|
3507
|
+
AgentUsageUtil.read = read;
|
|
3508
|
+
async function lastAskedIn(file) {
|
|
3509
|
+
const handle = await open(file, "r").catch(() => {
|
|
3510
|
+
return;
|
|
3511
|
+
});
|
|
3512
|
+
if (!handle) {
|
|
3513
|
+
return;
|
|
3514
|
+
}
|
|
3515
|
+
try {
|
|
3516
|
+
const { size } = await handle.stat();
|
|
3517
|
+
const length = Math.min(size, TAIL_BYTES);
|
|
3518
|
+
const buffer = new Uint8Array(length);
|
|
3519
|
+
await handle.read(buffer, 0, length, size - length);
|
|
3520
|
+
return lastAskedAt(new TextDecoder().decode(buffer));
|
|
3521
|
+
} finally {
|
|
3522
|
+
await handle.close();
|
|
3523
|
+
}
|
|
3524
|
+
}
|
|
3525
|
+
function lastAskedAt(lines) {
|
|
3526
|
+
const all = lines.split(`
|
|
3527
|
+
`);
|
|
3528
|
+
for (let index = all.length - 1;index >= 0; index--) {
|
|
3529
|
+
const line = all[index];
|
|
3530
|
+
if (!line.includes('"user"')) {
|
|
3531
|
+
continue;
|
|
3532
|
+
}
|
|
3533
|
+
try {
|
|
3534
|
+
const entry = JSON.parse(line);
|
|
3535
|
+
if (entry.type === "message" && entry.message?.role === "user" && entry.timestamp) {
|
|
3536
|
+
const at = Date.parse(entry.timestamp);
|
|
3537
|
+
if (Number.isFinite(at)) {
|
|
3538
|
+
return at;
|
|
3539
|
+
}
|
|
3540
|
+
}
|
|
3541
|
+
} catch {}
|
|
3542
|
+
}
|
|
3543
|
+
return;
|
|
3544
|
+
}
|
|
3545
|
+
AgentUsageUtil.lastAskedAt = lastAskedAt;
|
|
3546
|
+
function usage(team, messages, sessionTimes, now) {
|
|
3547
|
+
const since = now - USAGE_DAYS * DAY_MS;
|
|
3548
|
+
const named = new Map;
|
|
3549
|
+
const answers = new Map;
|
|
3550
|
+
const answeredAt = new Map;
|
|
3551
|
+
for (const list of messages.values()) {
|
|
3552
|
+
for (const message of list) {
|
|
3553
|
+
if (message.at < since || message.notice) {
|
|
3554
|
+
continue;
|
|
3555
|
+
}
|
|
3556
|
+
for (const id of ChannelsText.mentions(message.text, team.agents)) {
|
|
3557
|
+
if (id !== message.author) {
|
|
3558
|
+
named.set(id, (named.get(id) ?? 0) + 1);
|
|
3559
|
+
}
|
|
3560
|
+
}
|
|
3561
|
+
if (!message.failed && team.agents.some((agent) => agent.id === message.author)) {
|
|
3562
|
+
answers.set(message.author, (answers.get(message.author) ?? 0) + 1);
|
|
3563
|
+
}
|
|
3564
|
+
}
|
|
3565
|
+
for (const message of list) {
|
|
3566
|
+
if (!message.failed && message.at > (answeredAt.get(message.author) ?? 0)) {
|
|
3567
|
+
answeredAt.set(message.author, message.at);
|
|
3568
|
+
}
|
|
3569
|
+
}
|
|
3570
|
+
}
|
|
3571
|
+
return team.agents.map((agent) => {
|
|
3572
|
+
const channels = team.channels.filter((channel) => channel.members.includes(agent.id)).map((channel) => {
|
|
3573
|
+
const list = messages.get(channel.id) ?? [];
|
|
3574
|
+
const last2 = list.reduce((at, message) => Math.max(at, message.at), 0);
|
|
3575
|
+
return {
|
|
3576
|
+
id: channel.id,
|
|
3577
|
+
name: channel.name,
|
|
3578
|
+
messages: list.filter((message) => message.at >= since).length,
|
|
3579
|
+
...last2 ? { lastAt: last2 } : {}
|
|
3580
|
+
};
|
|
3581
|
+
});
|
|
3582
|
+
const session = agent.sessionFile ? sessionTimes.get(agent.sessionFile) : undefined;
|
|
3583
|
+
const last = Math.max(session ?? 0, answeredAt.get(agent.id) ?? 0);
|
|
3584
|
+
return {
|
|
3585
|
+
id: agent.id,
|
|
3586
|
+
name: agent.name,
|
|
3587
|
+
role: agent.role,
|
|
3588
|
+
...agent.temporary ? { temporary: true } : {},
|
|
3589
|
+
createdAt: agent.createdAt,
|
|
3590
|
+
...last ? { lastUsedAt: last } : {},
|
|
3591
|
+
named: named.get(agent.id) ?? 0,
|
|
3592
|
+
answers: answers.get(agent.id) ?? 0,
|
|
3593
|
+
channels
|
|
3594
|
+
};
|
|
3595
|
+
});
|
|
3596
|
+
}
|
|
3597
|
+
AgentUsageUtil.usage = usage;
|
|
3598
|
+
})(AgentUsageUtil ||= {});
|
|
3599
|
+
|
|
3198
3600
|
// web-src/channel-pictures.ts
|
|
3199
3601
|
import { randomBytes } from "node:crypto";
|
|
3200
3602
|
import { mkdir, readdir, readFile, rm, writeFile } from "node:fs/promises";
|
|
@@ -3322,7 +3724,8 @@ var TeamViewUtil;
|
|
|
3322
3724
|
}
|
|
3323
3725
|
return manages ? channel : channelAs(channel);
|
|
3324
3726
|
});
|
|
3325
|
-
|
|
3727
|
+
const { removed: _removed, ...rest } = value;
|
|
3728
|
+
return { ...rest, agents, channels, may };
|
|
3326
3729
|
}
|
|
3327
3730
|
TeamViewUtil.team = team;
|
|
3328
3731
|
function agentAs(agent, edits, own) {
|
|
@@ -3460,9 +3863,9 @@ class TeamStore {
|
|
|
3460
3863
|
}
|
|
3461
3864
|
async openSession(agent) {
|
|
3462
3865
|
if (agent.sessionFile) {
|
|
3463
|
-
const
|
|
3464
|
-
if (
|
|
3465
|
-
return
|
|
3866
|
+
const open2 = (await this.host.listSessions()).find((session) => session.sessionFile === agent.sessionFile);
|
|
3867
|
+
if (open2) {
|
|
3868
|
+
return open2.sessionId;
|
|
3466
3869
|
}
|
|
3467
3870
|
}
|
|
3468
3871
|
const cwd = agent.cwd ?? (await this.host.getServerInfo()).cwd;
|
|
@@ -3485,10 +3888,10 @@ class TeamStore {
|
|
|
3485
3888
|
return sessionId;
|
|
3486
3889
|
}
|
|
3487
3890
|
async switchModel(agent) {
|
|
3488
|
-
const
|
|
3489
|
-
if (
|
|
3891
|
+
const open2 = agent.model && agent.sessionFile && (await this.host.listSessions()).find((session) => session.sessionFile === agent.sessionFile);
|
|
3892
|
+
if (open2 && agent.model && open2.model !== agent.model) {
|
|
3490
3893
|
const slash = agent.model.indexOf("/");
|
|
3491
|
-
await this.host.setModel(
|
|
3894
|
+
await this.host.setModel(open2.sessionId, agent.model.slice(0, slash), agent.model.slice(slash + 1));
|
|
3492
3895
|
}
|
|
3493
3896
|
}
|
|
3494
3897
|
async settled(sessionId, before, poll) {
|
|
@@ -3646,6 +4049,30 @@ class TeamStore {
|
|
|
3646
4049
|
set(key, value) {
|
|
3647
4050
|
return this.host.setExtensionData(NAME, key, value);
|
|
3648
4051
|
}
|
|
4052
|
+
listAgents() {
|
|
4053
|
+
const faces = ChannelsUtil.faces(this.team.agents);
|
|
4054
|
+
return this.team.agents.map((agent) => ({
|
|
4055
|
+
id: agent.id,
|
|
4056
|
+
name: agent.name,
|
|
4057
|
+
role: agent.role,
|
|
4058
|
+
mark: agent.mark,
|
|
4059
|
+
face: faces.get(agent.id) ?? 0,
|
|
4060
|
+
...agent.cwd ? { cwd: agent.cwd } : {},
|
|
4061
|
+
...agent.model ? { model: agent.model } : {},
|
|
4062
|
+
...agent.temporary ? { temporary: true } : {}
|
|
4063
|
+
}));
|
|
4064
|
+
}
|
|
4065
|
+
listChannels() {
|
|
4066
|
+
return this.team.channels.map((channel) => ({
|
|
4067
|
+
id: channel.id,
|
|
4068
|
+
name: channel.name,
|
|
4069
|
+
...channel.topic ? { topic: channel.topic } : {},
|
|
4070
|
+
members: channel.members
|
|
4071
|
+
}));
|
|
4072
|
+
}
|
|
4073
|
+
async agentUsage(now = Date.now()) {
|
|
4074
|
+
return AgentUsageUtil.read(this.team, (id) => this.messagesOf(id), now);
|
|
4075
|
+
}
|
|
3649
4076
|
}
|
|
3650
4077
|
|
|
3651
4078
|
// web-src/team-answers.ts
|
|
@@ -3855,9 +4282,9 @@ class TeamService extends TeamAnswers {
|
|
|
3855
4282
|
}
|
|
3856
4283
|
await this.saveTeam(team);
|
|
3857
4284
|
if (agent.name !== before.name && agent.sessionFile) {
|
|
3858
|
-
const
|
|
3859
|
-
if (
|
|
3860
|
-
await this.host.setSessionName(
|
|
4285
|
+
const open2 = (await this.host.listSessions()).find((session) => session.sessionFile === agent.sessionFile);
|
|
4286
|
+
if (open2) {
|
|
4287
|
+
await this.host.setSessionName(open2.sessionId, agent.name).catch(() => {
|
|
3861
4288
|
return;
|
|
3862
4289
|
});
|
|
3863
4290
|
}
|
|
@@ -3906,9 +4333,15 @@ class TeamService extends TeamAnswers {
|
|
|
3906
4333
|
return { agent, sessionId };
|
|
3907
4334
|
}
|
|
3908
4335
|
async deleteAgent(ref) {
|
|
3909
|
-
const
|
|
4336
|
+
const now = Date.now();
|
|
4337
|
+
const removed = RemovedAgentsUtil.remove(this.team, ref, now);
|
|
4338
|
+
const { team, channels: old } = RemovedAgentsUtil.forget(removed.team, now);
|
|
4339
|
+
const { agent, channels } = removed;
|
|
3910
4340
|
await this.saveTeam(team);
|
|
3911
4341
|
for (const channel of channels) {
|
|
4342
|
+
await this.forget(channel, true);
|
|
4343
|
+
}
|
|
4344
|
+
for (const channel of old) {
|
|
3912
4345
|
await this.forget(channel);
|
|
3913
4346
|
}
|
|
3914
4347
|
this.queue = { ...this.queue, jobs: this.queue.jobs.filter((job) => job.agentId !== agent.id) };
|
|
@@ -3918,11 +4351,18 @@ class TeamService extends TeamAnswers {
|
|
|
3918
4351
|
}
|
|
3919
4352
|
return agent;
|
|
3920
4353
|
}
|
|
3921
|
-
async
|
|
3922
|
-
|
|
4354
|
+
async restoreAgent(ref) {
|
|
4355
|
+
const { team, agent } = RemovedAgentsUtil.restore(this.team, ref);
|
|
4356
|
+
await this.saveTeam(team);
|
|
4357
|
+
return agent;
|
|
4358
|
+
}
|
|
4359
|
+
async forget(channel, keep = false) {
|
|
3923
4360
|
this.messages.delete(channel.id);
|
|
3924
4361
|
this.reading.delete(channel.id);
|
|
3925
|
-
|
|
4362
|
+
if (!keep) {
|
|
4363
|
+
await this.pictures.forget(channel.id);
|
|
4364
|
+
await this.set(Keys.messages(channel.id), null);
|
|
4365
|
+
}
|
|
3926
4366
|
const { [channel.id]: _gone, ...working } = this.working;
|
|
3927
4367
|
this.working = working;
|
|
3928
4368
|
await this.set(Keys.WORKING, working);
|
|
@@ -3983,19 +4423,6 @@ class TeamService extends TeamAnswers {
|
|
|
3983
4423
|
await this.focus(channel.id);
|
|
3984
4424
|
return { kind: "channel", id: channel.id, name: channel.name };
|
|
3985
4425
|
}
|
|
3986
|
-
listAgents() {
|
|
3987
|
-
const faces = ChannelsUtil.faces(this.team.agents);
|
|
3988
|
-
return this.team.agents.map((agent) => ({
|
|
3989
|
-
id: agent.id,
|
|
3990
|
-
name: agent.name,
|
|
3991
|
-
role: agent.role,
|
|
3992
|
-
mark: agent.mark,
|
|
3993
|
-
face: faces.get(agent.id) ?? 0,
|
|
3994
|
-
...agent.cwd ? { cwd: agent.cwd } : {},
|
|
3995
|
-
...agent.model ? { model: agent.model } : {},
|
|
3996
|
-
...agent.temporary ? { temporary: true } : {}
|
|
3997
|
-
}));
|
|
3998
|
-
}
|
|
3999
4426
|
async request(request) {
|
|
4000
4427
|
if (this.disposed) {
|
|
4001
4428
|
throw new Error("The team has stopped; the extension may have been turned off.");
|
|
@@ -4021,6 +4448,8 @@ class TeamService extends TeamAnswers {
|
|
|
4021
4448
|
return this.setChannelModel(request);
|
|
4022
4449
|
case "deleteAgent":
|
|
4023
4450
|
return this.deleteAgent(request.agent);
|
|
4451
|
+
case "restoreAgent":
|
|
4452
|
+
return this.restoreAgent(request.agent);
|
|
4024
4453
|
case "post":
|
|
4025
4454
|
return (await this.post(String(request.channel ?? ""), USER, String(request.text ?? ""), await this.posterOf(request))).message;
|
|
4026
4455
|
case "picture":
|
|
@@ -4213,14 +4642,6 @@ class TeamService extends TeamAnswers {
|
|
|
4213
4642
|
resolve(waiting.replies);
|
|
4214
4643
|
}
|
|
4215
4644
|
}
|
|
4216
|
-
listChannels() {
|
|
4217
|
-
return this.team.channels.map((channel) => ({
|
|
4218
|
-
id: channel.id,
|
|
4219
|
-
name: channel.name,
|
|
4220
|
-
...channel.topic ? { topic: channel.topic } : {},
|
|
4221
|
-
members: channel.members
|
|
4222
|
-
}));
|
|
4223
|
-
}
|
|
4224
4645
|
}
|
|
4225
4646
|
|
|
4226
4647
|
// web-src/host.ts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@celljs/ta-channels",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.29.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.
|
|
31
|
-
"@celljs/ta-relay": "4.
|
|
32
|
-
"@celljs/ta-web": "4.
|
|
30
|
+
"@celljs/ta-protocol": "4.29.0",
|
|
31
|
+
"@celljs/ta-relay": "4.29.0",
|
|
32
|
+
"@celljs/ta-web": "4.29.0",
|
|
33
33
|
"@types/react": "^19.3.0"
|
|
34
34
|
},
|
|
35
35
|
"publishConfig": {
|
package/web/index.js
CHANGED
|
@@ -234,6 +234,40 @@ var TaAgentSummary;
|
|
|
234
234
|
}
|
|
235
235
|
TaAgentSummary2.strip = strip;
|
|
236
236
|
})(TaAgentSummary || (TaAgentSummary = {}));
|
|
237
|
+
var TaPictureNote;
|
|
238
|
+
(function(TaPictureNote2) {
|
|
239
|
+
TaPictureNote2.OPEN = "<pictures>";
|
|
240
|
+
TaPictureNote2.CLOSE = "</pictures>";
|
|
241
|
+
const BLOCK = /[ \t]*<pictures>([\s\S]*?)(?:<\/pictures>|$)|<p(?:i(?:c(?:t(?:u(?:r(?:es?)?)?)?)?)?)?$/gi;
|
|
242
|
+
const ROW = /(?:^|\s)[-*]?\s*p(\d+)\s*[::]\s*/gi;
|
|
243
|
+
function take(text) {
|
|
244
|
+
const told = new Map;
|
|
245
|
+
if (!/<p/i.test(text)) {
|
|
246
|
+
return { said: text, told };
|
|
247
|
+
}
|
|
248
|
+
const said = text.replace(BLOCK, (_all, body) => {
|
|
249
|
+
const rows = [...(body !== null && body !== undefined ? body : "").matchAll(ROW)];
|
|
250
|
+
rows.forEach((row, index) => {
|
|
251
|
+
var _a;
|
|
252
|
+
var _b, _c;
|
|
253
|
+
const end = (_b = (_a = rows[index + 1]) === null || _a === undefined ? undefined : _a.index) !== null && _b !== undefined ? _b : body === null || body === undefined ? undefined : body.length;
|
|
254
|
+
const what = body === null || body === undefined ? undefined : body.slice(((_c = row.index) !== null && _c !== undefined ? _c : 0) + row[0].length, end).trim();
|
|
255
|
+
if (what) {
|
|
256
|
+
told.set(Number(row[1]), what);
|
|
257
|
+
}
|
|
258
|
+
});
|
|
259
|
+
return "";
|
|
260
|
+
});
|
|
261
|
+
return { said: said === text ? text : said.replace(/\n{3,}/g, `
|
|
262
|
+
|
|
263
|
+
`).trim(), told };
|
|
264
|
+
}
|
|
265
|
+
TaPictureNote2.take = take;
|
|
266
|
+
function strip(text) {
|
|
267
|
+
return take(text).said;
|
|
268
|
+
}
|
|
269
|
+
TaPictureNote2.strip = strip;
|
|
270
|
+
})(TaPictureNote || (TaPictureNote = {}));
|
|
237
271
|
var TaSkillUse;
|
|
238
272
|
(function(TaSkillUse2) {
|
|
239
273
|
const BLOCK = /^<skill name="([^"]+)" location="([^"]+)">\n([\s\S]*?)\n<\/skill>(?:\n\n([\s\S]+))?$/;
|
|
@@ -1180,33 +1214,6 @@ var ChannelsUtil;
|
|
|
1180
1214
|
return { team: next, channel, agents };
|
|
1181
1215
|
}
|
|
1182
1216
|
ChannelsUtil.setChannelModel = setChannelModel;
|
|
1183
|
-
function removeAgent(team, ref) {
|
|
1184
|
-
const agent = findAgent(team, typeof ref === "string" ? ref : "");
|
|
1185
|
-
if (!agent) {
|
|
1186
|
-
throw new Error(`No agent is ${String(ref)}.`);
|
|
1187
|
-
}
|
|
1188
|
-
const gone = [];
|
|
1189
|
-
const channels = [];
|
|
1190
|
-
for (const channel of team.channels) {
|
|
1191
|
-
if (!channel.members.includes(agent.id)) {
|
|
1192
|
-
channels.push(channel);
|
|
1193
|
-
continue;
|
|
1194
|
-
}
|
|
1195
|
-
const members = channel.members.filter((id) => id !== agent.id);
|
|
1196
|
-
if (members.length === 0) {
|
|
1197
|
-
gone.push(channel);
|
|
1198
|
-
continue;
|
|
1199
|
-
}
|
|
1200
|
-
const muted = channel.muted?.filter((id) => id !== agent.id);
|
|
1201
|
-
const next = { ...channel, members, muted };
|
|
1202
|
-
if (!muted?.length) {
|
|
1203
|
-
delete next.muted;
|
|
1204
|
-
}
|
|
1205
|
-
channels.push(next);
|
|
1206
|
-
}
|
|
1207
|
-
return { team: { agents: team.agents.filter((other) => other.id !== agent.id), channels }, agent, channels: gone };
|
|
1208
|
-
}
|
|
1209
|
-
ChannelsUtil.removeAgent = removeAgent;
|
|
1210
1217
|
function agentIds(team, refs) {
|
|
1211
1218
|
const ids = [];
|
|
1212
1219
|
for (const ref of Array.isArray(refs) ? refs.filter((item) => typeof item === "string") : []) {
|
|
@@ -2934,7 +2941,8 @@ var TaSaid;
|
|
|
2934
2941
|
["image note", /\[Image: original \d+x\d+|\[Image converted from /],
|
|
2935
2942
|
["skill", /<skill name="|<\/skill>/],
|
|
2936
2943
|
["task note", /<\/?task_(?:update|adopted|renamed)\b/],
|
|
2937
|
-
["summary", /<\/?(?:conversation_history_summary|summary)>/]
|
|
2944
|
+
["summary", /<\/?(?:conversation_history_summary|summary)>/],
|
|
2945
|
+
["pictures described", /<\/?pictures>/]
|
|
2938
2946
|
];
|
|
2939
2947
|
function text(content, joiner = `
|
|
2940
2948
|
`) {
|
|
@@ -2945,7 +2953,7 @@ var TaSaid;
|
|
|
2945
2953
|
}
|
|
2946
2954
|
TaSaid2.text = text;
|
|
2947
2955
|
function words(role, text2, options = {}) {
|
|
2948
|
-
const said = role === "user" ? userWords(text2) : TaAgentSummary.strip(text2);
|
|
2956
|
+
const said = role === "user" ? userWords(text2) : TaPictureNote.strip(TaAgentSummary.strip(text2));
|
|
2949
2957
|
return withoutFences(said, (language) => options.cards === false && CARD.test(language), true).trim();
|
|
2950
2958
|
}
|
|
2951
2959
|
TaSaid2.words = words;
|
|
@@ -3064,6 +3072,17 @@ Switched to voice.`, said: "Switched to voice." },
|
|
|
3064
3072
|
{ mark: "a card alone", role: "assistant", text: '```ta-glance\n{"status":"done","blocks":[]}\n```' },
|
|
3065
3073
|
{ mark: "a proposal", role: "assistant", text: 'Committed.\n\n```ta-propose\n{"kind":"git.push","title":"Push"}\n```', said: "Committed." },
|
|
3066
3074
|
{ mark: "what a call says aloud", role: "assistant", text: "All fixed.\n\n```ta-say\nIt is fixed.\n```", said: "All fixed." },
|
|
3075
|
+
{
|
|
3076
|
+
mark: "pictures described after the answer",
|
|
3077
|
+
role: "assistant",
|
|
3078
|
+
text: `The left one.
|
|
3079
|
+
|
|
3080
|
+
<pictures> p1: two cats on a sofa. p2: a chart of sales, "Q4". </pictures>`,
|
|
3081
|
+
said: "The left one."
|
|
3082
|
+
},
|
|
3083
|
+
{ mark: "pictures described as it streams", role: "assistant", text: `The left one.
|
|
3084
|
+
<pictures>
|
|
3085
|
+
p1: two ca`, said: "The left one." },
|
|
3067
3086
|
{ mark: "a tag not known yet", role: "assistant", text: `<system-reminder>
|
|
3068
3087
|
</system-reminder>
|
|
3069
3088
|
Ready.`, said: "Ready." }
|
|
@@ -3850,7 +3869,7 @@ function AgentInfoView({ context }) {
|
|
|
3850
3869
|
const act = (action2) => AgentActions.run(context, action2);
|
|
3851
3870
|
const rename = act(async () => {
|
|
3852
3871
|
const name = await pi.ui.input(w.rename, w.name, { value: agent.name });
|
|
3853
|
-
if (name
|
|
3872
|
+
if (name?.trim() && name.trim() !== agent.name) {
|
|
3854
3873
|
await service.updateAgent(agent.id, { name });
|
|
3855
3874
|
}
|
|
3856
3875
|
});
|
|
@@ -4175,6 +4194,11 @@ class ChannelsClient {
|
|
|
4175
4194
|
await this.load(true);
|
|
4176
4195
|
return channel;
|
|
4177
4196
|
}
|
|
4197
|
+
async restoreAgent(agentId) {
|
|
4198
|
+
const agent = await this.send({ kind: "restoreAgent", agent: agentId });
|
|
4199
|
+
await this.load(true);
|
|
4200
|
+
return agent;
|
|
4201
|
+
}
|
|
4178
4202
|
async deleteAgent(agentId) {
|
|
4179
4203
|
await this.deleting(agentId, async () => {
|
|
4180
4204
|
await this.send({ kind: "deleteAgent", agent: agentId });
|
|
@@ -5060,7 +5084,10 @@ var TaPermissionUtil;
|
|
|
5060
5084
|
function host(manifest, method, kind) {
|
|
5061
5085
|
var _a, _b, _c, _d;
|
|
5062
5086
|
const host2 = (_a = manifest === null || manifest === undefined ? undefined : manifest.host) !== null && _a !== undefined ? _a : {};
|
|
5063
|
-
const own = (key) =>
|
|
5087
|
+
const own = (key) => {
|
|
5088
|
+
var _a2;
|
|
5089
|
+
return (_a2 = Object.getOwnPropertyDescriptor(host2, key)) === null || _a2 === undefined ? undefined : _a2.value;
|
|
5090
|
+
};
|
|
5064
5091
|
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;
|
|
5065
5092
|
}
|
|
5066
5093
|
TaPermissionUtil2.host = host;
|
|
@@ -5331,7 +5358,29 @@ var RoomUtil;
|
|
|
5331
5358
|
});
|
|
5332
5359
|
}
|
|
5333
5360
|
RoomUtil.rows = rows;
|
|
5361
|
+
function choice(agent, text) {
|
|
5362
|
+
return `@${agent.name} ${text}`;
|
|
5363
|
+
}
|
|
5364
|
+
RoomUtil.choice = choice;
|
|
5365
|
+
function answer(messages, message, agent) {
|
|
5366
|
+
const said = messages.slice(messages.indexOf(message) + 1).find((later) => later.author === USER && !later.notice);
|
|
5367
|
+
if (!said) {
|
|
5368
|
+
return;
|
|
5369
|
+
}
|
|
5370
|
+
const named = `@${agent.name} `;
|
|
5371
|
+
return said.text.startsWith(named) ? said.text.slice(named.length) : said.text;
|
|
5372
|
+
}
|
|
5373
|
+
RoomUtil.answer = answer;
|
|
5334
5374
|
})(RoomUtil ||= {});
|
|
5375
|
+
function AgentText({ context, channelId, agent, text, answer }) {
|
|
5376
|
+
const { pi, service } = context;
|
|
5377
|
+
const send = React.useCallback((said) => service.post(channelId, RoomUtil.choice(agent, said)), [service, channelId, agent.name]);
|
|
5378
|
+
return /* @__PURE__ */ React.createElement(pi.ui.Markdown, {
|
|
5379
|
+
text,
|
|
5380
|
+
send,
|
|
5381
|
+
answer
|
|
5382
|
+
});
|
|
5383
|
+
}
|
|
5335
5384
|
function MessagePictures({ context, channelId, message, alt }) {
|
|
5336
5385
|
const { pi, service } = context;
|
|
5337
5386
|
const images = message.images ?? [];
|
|
@@ -5660,7 +5709,13 @@ function ChannelRoom({ context, channelId: fixed }) {
|
|
|
5660
5709
|
className: "tac-msg-failed"
|
|
5661
5710
|
}, w.failed), message.overBudget && /* @__PURE__ */ React.createElement("div", {
|
|
5662
5711
|
className: "tac-msg-over"
|
|
5663
|
-
}, w.overBudget), /* @__PURE__ */ React.createElement(
|
|
5712
|
+
}, w.overBudget), agentOf(message.author) ? /* @__PURE__ */ React.createElement(AgentText, {
|
|
5713
|
+
context,
|
|
5714
|
+
channelId: channel.id,
|
|
5715
|
+
agent: agentOf(message.author),
|
|
5716
|
+
text: ChannelsText.markMentions(message.text, state.team.agents),
|
|
5717
|
+
answer: RoomUtil.answer(messages, message, agentOf(message.author))
|
|
5718
|
+
}) : /* @__PURE__ */ React.createElement(Markdown, {
|
|
5664
5719
|
text: ChannelsText.markMentions(message.text, state.team.agents)
|
|
5665
5720
|
})))))), working.length > 0 && /* @__PURE__ */ React.createElement("div", {
|
|
5666
5721
|
className: "tac-live",
|