@celljs/ta-channels 4.12.0 → 4.13.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.en.md +3 -1
- package/README.md +3 -1
- package/extension/index.mjs +78 -4
- package/host/index.mjs +289 -8
- package/package.json +29 -5
- package/web/index.js +137 -27
package/README.en.md
CHANGED
|
@@ -29,7 +29,9 @@ Data is stored on the server in `<agentDir>/extension-data/@celljs/ta-channels.j
|
|
|
29
29
|
| `working` | agents currently answering |
|
|
30
30
|
| `focus` | channels Ta has created tools for or posted messages to; pages use this to mark them in the sidebar |
|
|
31
31
|
|
|
32
|
-
The page learns of changes via `pi.storage.onChange` and rereads them. To change something (create agent, create channel, add channel member, set lead / mute / remove member, delete channel, restart agent session, modify or delete agent, post message as user, open agent session), a page calls `request` on the server side: this package's web extension with `pi.callHost('request', request)`, other extensions with `pi.packages.callPackageHost('@celljs/ta-channels', 'request', [request])
|
|
32
|
+
The page learns of changes via `pi.storage.onChange` and rereads them. To change something (create agent, create channel, add channel member, set lead / mute / remove member, delete channel, restart agent session, modify or delete agent, post message as user, open agent session), a page calls `request` on the server side: this package's web extension with `pi.callHost('request', request)`, other extensions with `pi.packages.callPackageHost('@celljs/ta-channels', 'request', [request])` (the host of another package with `host.callPackageHost`). `request` is a `TeamRequest` (`web-src/channels-model.ts`); the call returns the result, or throws the reason. Each answer is first recorded as a job in `queue` and removed only after the answer is posted to the channel. After ta serve restarts, it continues processing remaining jobs: jobs that already have an answer (the channel has this agent's reply to that message) are not asked again, and messages already forwarded are not forwarded again, so processed messages do not duplicate. On restart, the one message that was being answered and not yet posted is asked again.
|
|
33
|
+
|
|
34
|
+
Another package that needs the agents (ta-rooms, for those to invite to a room) calls `listAgents` of the server side (`callPackageHost('@celljs/ta-channels', 'listAgents')`) rather than reading `team`: it returns `TeamAgentInfo[]` (`web-src/channels-model.ts`), each agent's `id`, `name`, `role`, `mark`, `face` (the one given by its id to an agent made before faces) and `cwd`, `temporary` on those Ta made for a team of its own; it only reads, and holds no session files.
|
|
33
35
|
|
|
34
36
|
## Limitations
|
|
35
37
|
|
package/README.md
CHANGED
|
@@ -29,7 +29,9 @@ Ta 自带的 pi 包(默认开启,可在 Web 客户端的 设置 → 包 关
|
|
|
29
29
|
| `working` | 正在回答的智能体 |
|
|
30
30
|
| `focus` | Ta 用工具建过或发过消息的频道,页面据此在侧栏标出 |
|
|
31
31
|
|
|
32
|
-
页面通过 `pi.storage.onChange` 得知变化后重新读取。页面要改什么(新建智能体、新建频道、添加频道成员、设负责人 / 免打扰 / 移出成员、删除频道、重开智能体的会话、修改或删除智能体、以用户身份发消息、打开智能体的会话),调用服务端的 `request`:本包的 Web 扩展用 `pi.callHost('request', request)`,其他扩展用 `pi.packages.callPackageHost('@celljs/ta-channels', 'request', [request])
|
|
32
|
+
页面通过 `pi.storage.onChange` 得知变化后重新读取。页面要改什么(新建智能体、新建频道、添加频道成员、设负责人 / 免打扰 / 移出成员、删除频道、重开智能体的会话、修改或删除智能体、以用户身份发消息、打开智能体的会话),调用服务端的 `request`:本包的 Web 扩展用 `pi.callHost('request', request)`,其他扩展用 `pi.packages.callPackageHost('@celljs/ta-channels', 'request', [request])`(别的包的服务端用 `host.callPackageHost`);`request` 的类型是 `TeamRequest`(`web-src/channels-model.ts`),返回结果,出错时抛出原因。每个回答先作为 job 记进 `queue`,回答贴进频道后才移除。ta serve 重启后接着处理剩下的 job:已经有回答(频道里有该智能体对这条消息的回复)的 job 不会再问,已经交出去的消息也不会再交一次,所以已处理的消息不会重复转发。重启时正在回答、还没有贴出的那一条,会再问一次。
|
|
33
|
+
|
|
34
|
+
别的包要知道有哪些智能体(如 ta-rooms 列出可以邀请进房间的),调用服务端的 `listAgents`(`callPackageHost('@celljs/ta-channels', 'listAgents')`),不要读 `team`:它返回 `TeamAgentInfo[]`(`web-src/channels-model.ts`),每个智能体的 `id`、`name`、`role`、`mark`、`face`(早于头像的智能体按 id 分到的那个)、`cwd`,Ta 为自己的团队临时建的带 `temporary`;只读,不含会话文件。
|
|
33
35
|
|
|
34
36
|
## 限制
|
|
35
37
|
|
package/extension/index.mjs
CHANGED
|
@@ -5,19 +5,91 @@ var TaHostUtil;
|
|
|
5
5
|
TaHostUtil2.WAIT_MS = 1000;
|
|
6
6
|
function reach(events, name, waitMs = TaHostUtil2.WAIT_MS) {
|
|
7
7
|
return new Promise((resolve) => {
|
|
8
|
+
let heard = false;
|
|
9
|
+
let answered = false;
|
|
8
10
|
const timer = setTimeout(() => resolve(undefined), waitMs);
|
|
9
11
|
const request = {
|
|
10
12
|
name,
|
|
13
|
+
heard: () => {
|
|
14
|
+
heard = true;
|
|
15
|
+
},
|
|
11
16
|
resolve: (answer) => {
|
|
17
|
+
answered = true;
|
|
12
18
|
clearTimeout(timer);
|
|
13
19
|
resolve(answer);
|
|
14
20
|
}
|
|
15
21
|
};
|
|
16
22
|
events.emit(TA_HOST_EVENT, request);
|
|
23
|
+
if (!heard && !answered) {
|
|
24
|
+
clearTimeout(timer);
|
|
25
|
+
resolve(undefined);
|
|
26
|
+
}
|
|
17
27
|
});
|
|
18
28
|
}
|
|
19
29
|
TaHostUtil2.reach = reach;
|
|
30
|
+
function marked(systemPrompt, mark) {
|
|
31
|
+
return role(systemPrompt).includes(mark);
|
|
32
|
+
}
|
|
33
|
+
TaHostUtil2.marked = marked;
|
|
34
|
+
function role(systemPrompt) {
|
|
35
|
+
if (!systemPrompt) {
|
|
36
|
+
return "";
|
|
37
|
+
}
|
|
38
|
+
const open = `<addendum>
|
|
39
|
+
`;
|
|
40
|
+
const start = systemPrompt.indexOf(open);
|
|
41
|
+
const context = systemPrompt.indexOf(`<project_context>
|
|
42
|
+
`);
|
|
43
|
+
if (start < 0 || context >= 0 && context < start) {
|
|
44
|
+
return "";
|
|
45
|
+
}
|
|
46
|
+
const end = systemPrompt.indexOf(`
|
|
47
|
+
</addendum>`, start);
|
|
48
|
+
return systemPrompt.slice(start + open.length, end < 0 ? undefined : end);
|
|
49
|
+
}
|
|
50
|
+
TaHostUtil2.role = role;
|
|
20
51
|
})(TaHostUtil || (TaHostUtil = {}));
|
|
52
|
+
var TA_ASK_ENTRY = "ta-ask";
|
|
53
|
+
var TaAskUtil;
|
|
54
|
+
(function(TaAskUtil2) {
|
|
55
|
+
const LENGTH = 120;
|
|
56
|
+
function entry(question) {
|
|
57
|
+
const line = question.replace(/\s+/g, " ").trim();
|
|
58
|
+
return { question: line.length > LENGTH ? `${line.slice(0, LENGTH - 1)}…` : line };
|
|
59
|
+
}
|
|
60
|
+
TaAskUtil2.entry = entry;
|
|
61
|
+
function asking(entries) {
|
|
62
|
+
var _a;
|
|
63
|
+
for (let i = entries.length - 1;i >= 0; i--) {
|
|
64
|
+
const entry2 = entries[i];
|
|
65
|
+
if (entry2.type === "message" && ((_a = entry2.message) === null || _a === undefined ? undefined : _a.role) === "user") {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
if (entry2.type === "custom" && entry2.customType === TA_ASK_ENTRY) {
|
|
69
|
+
return read(entry2);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
TaAskUtil2.asking = asking;
|
|
75
|
+
function next(asked, entry2) {
|
|
76
|
+
var _a;
|
|
77
|
+
if (entry2.type === "message" && ((_a = entry2.message) === null || _a === undefined ? undefined : _a.role) === "user") {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
return entry2.type === "custom" && entry2.customType === TA_ASK_ENTRY ? read(entry2) : asked;
|
|
81
|
+
}
|
|
82
|
+
TaAskUtil2.next = next;
|
|
83
|
+
function read(found) {
|
|
84
|
+
var _a;
|
|
85
|
+
const question = (_a = found.data) === null || _a === undefined ? undefined : _a.question;
|
|
86
|
+
if (typeof question !== "string" || !question.trim()) {
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
const at = found.timestamp ? Date.parse(found.timestamp) : Number.NaN;
|
|
90
|
+
return { question: entry(question).question, at: Number.isNaN(at) ? 0 : at };
|
|
91
|
+
}
|
|
92
|
+
})(TaAskUtil || (TaAskUtil = {}));
|
|
21
93
|
|
|
22
94
|
// web-src/channels-model.ts
|
|
23
95
|
var NAME = "@celljs/ta-channels";
|
|
@@ -150,12 +222,12 @@ var ChannelsUtil;
|
|
|
150
222
|
ChannelsUtil.hash = hash;
|
|
151
223
|
function findAgent(team, ref) {
|
|
152
224
|
const key = ref.trim().replace(/^@/, "").toLowerCase();
|
|
153
|
-
return team.agents.find((agent) => agent.id === ref
|
|
225
|
+
return team.agents.find((agent) => agent.id === ref) ?? team.agents.find((agent) => agent.name.toLowerCase() === key);
|
|
154
226
|
}
|
|
155
227
|
ChannelsUtil.findAgent = findAgent;
|
|
156
228
|
function findChannel(team, ref) {
|
|
157
229
|
const key = ref.trim().replace(/^#/, "").toLowerCase();
|
|
158
|
-
return team.channels.find((channel) => channel.id === ref
|
|
230
|
+
return team.channels.find((channel) => channel.id === ref) ?? team.channels.find((channel) => channel.name.toLowerCase() === key);
|
|
159
231
|
}
|
|
160
232
|
ChannelsUtil.findChannel = findChannel;
|
|
161
233
|
function directory(value) {
|
|
@@ -504,6 +576,8 @@ var ChannelsUtil;
|
|
|
504
576
|
lines.push("", "Recent messages:", ...before.map((item) => `${authorName(team, item.author, labels)}: ${item.text}`));
|
|
505
577
|
}
|
|
506
578
|
lines.push("", `${authorName(team, message.author, labels)} to you:`);
|
|
579
|
+
const speaker = message.author === USER ? "" : ` · ${authorName(team, message.author, labels).replace(/[\]\n]/g, " ")}`;
|
|
580
|
+
lines.push(`[ta:from ${NAME} #${channel.name}${speaker}]`);
|
|
507
581
|
return `<context>
|
|
508
582
|
${lines.join(`
|
|
509
583
|
`)}
|
|
@@ -931,7 +1005,7 @@ var ASK_FIRST_MARK = "Ask the user before you hand out work";
|
|
|
931
1005
|
function activate(pi) {
|
|
932
1006
|
let reached;
|
|
933
1007
|
const reach = () => reached ??= TaHostUtil.reach(pi.events, NAME).then((answer) => ({ answered: !!answer, team: answer?.service }));
|
|
934
|
-
const isAgent = (ctx) => ctx.getSystemPrompt()
|
|
1008
|
+
const isAgent = (ctx) => TaHostUtil.marked(ctx.getSystemPrompt(), AGENT_MARK);
|
|
935
1009
|
const allowed = new Set;
|
|
936
1010
|
pi.on("session_start", () => {
|
|
937
1011
|
reach();
|
|
@@ -974,7 +1048,7 @@ function activate(pi) {
|
|
|
974
1048
|
throw new Error(answered ? NO_TEAM : NO_SERVER);
|
|
975
1049
|
}
|
|
976
1050
|
const input = params ?? {};
|
|
977
|
-
if (ctx.getSystemPrompt()
|
|
1051
|
+
if (TaHostUtil.marked(ctx.getSystemPrompt(), ASK_FIRST_MARK)) {
|
|
978
1052
|
const question = TeamAsk.question(tool.name, input, team2.state, allowed);
|
|
979
1053
|
if (question && !await ask(ctx, question)) {
|
|
980
1054
|
return { content: [{ type: "text", text: TeamAsk.REFUSED }], details: undefined };
|
package/host/index.mjs
CHANGED
|
@@ -230,19 +230,91 @@ var TaHostUtil;
|
|
|
230
230
|
TaHostUtil2.WAIT_MS = 1000;
|
|
231
231
|
function reach(events, name, waitMs = TaHostUtil2.WAIT_MS) {
|
|
232
232
|
return new Promise((resolve) => {
|
|
233
|
+
let heard = false;
|
|
234
|
+
let answered = false;
|
|
233
235
|
const timer = setTimeout(() => resolve(undefined), waitMs);
|
|
234
236
|
const request = {
|
|
235
237
|
name,
|
|
238
|
+
heard: () => {
|
|
239
|
+
heard = true;
|
|
240
|
+
},
|
|
236
241
|
resolve: (answer) => {
|
|
242
|
+
answered = true;
|
|
237
243
|
clearTimeout(timer);
|
|
238
244
|
resolve(answer);
|
|
239
245
|
}
|
|
240
246
|
};
|
|
241
247
|
events.emit(TA_HOST_EVENT, request);
|
|
248
|
+
if (!heard && !answered) {
|
|
249
|
+
clearTimeout(timer);
|
|
250
|
+
resolve(undefined);
|
|
251
|
+
}
|
|
242
252
|
});
|
|
243
253
|
}
|
|
244
254
|
TaHostUtil2.reach = reach;
|
|
255
|
+
function marked(systemPrompt, mark) {
|
|
256
|
+
return role(systemPrompt).includes(mark);
|
|
257
|
+
}
|
|
258
|
+
TaHostUtil2.marked = marked;
|
|
259
|
+
function role(systemPrompt) {
|
|
260
|
+
if (!systemPrompt) {
|
|
261
|
+
return "";
|
|
262
|
+
}
|
|
263
|
+
const open = `<addendum>
|
|
264
|
+
`;
|
|
265
|
+
const start = systemPrompt.indexOf(open);
|
|
266
|
+
const context = systemPrompt.indexOf(`<project_context>
|
|
267
|
+
`);
|
|
268
|
+
if (start < 0 || context >= 0 && context < start) {
|
|
269
|
+
return "";
|
|
270
|
+
}
|
|
271
|
+
const end = systemPrompt.indexOf(`
|
|
272
|
+
</addendum>`, start);
|
|
273
|
+
return systemPrompt.slice(start + open.length, end < 0 ? undefined : end);
|
|
274
|
+
}
|
|
275
|
+
TaHostUtil2.role = role;
|
|
245
276
|
})(TaHostUtil || (TaHostUtil = {}));
|
|
277
|
+
var TA_ASK_ENTRY = "ta-ask";
|
|
278
|
+
var TaAskUtil;
|
|
279
|
+
(function(TaAskUtil2) {
|
|
280
|
+
const LENGTH = 120;
|
|
281
|
+
function entry(question) {
|
|
282
|
+
const line = question.replace(/\s+/g, " ").trim();
|
|
283
|
+
return { question: line.length > LENGTH ? `${line.slice(0, LENGTH - 1)}…` : line };
|
|
284
|
+
}
|
|
285
|
+
TaAskUtil2.entry = entry;
|
|
286
|
+
function asking(entries) {
|
|
287
|
+
var _a;
|
|
288
|
+
for (let i = entries.length - 1;i >= 0; i--) {
|
|
289
|
+
const entry2 = entries[i];
|
|
290
|
+
if (entry2.type === "message" && ((_a = entry2.message) === null || _a === undefined ? undefined : _a.role) === "user") {
|
|
291
|
+
return;
|
|
292
|
+
}
|
|
293
|
+
if (entry2.type === "custom" && entry2.customType === TA_ASK_ENTRY) {
|
|
294
|
+
return read(entry2);
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
return;
|
|
298
|
+
}
|
|
299
|
+
TaAskUtil2.asking = asking;
|
|
300
|
+
function next(asked, entry2) {
|
|
301
|
+
var _a;
|
|
302
|
+
if (entry2.type === "message" && ((_a = entry2.message) === null || _a === undefined ? undefined : _a.role) === "user") {
|
|
303
|
+
return;
|
|
304
|
+
}
|
|
305
|
+
return entry2.type === "custom" && entry2.customType === TA_ASK_ENTRY ? read(entry2) : asked;
|
|
306
|
+
}
|
|
307
|
+
TaAskUtil2.next = next;
|
|
308
|
+
function read(found) {
|
|
309
|
+
var _a;
|
|
310
|
+
const question = (_a = found.data) === null || _a === undefined ? undefined : _a.question;
|
|
311
|
+
if (typeof question !== "string" || !question.trim()) {
|
|
312
|
+
return;
|
|
313
|
+
}
|
|
314
|
+
const at = found.timestamp ? Date.parse(found.timestamp) : Number.NaN;
|
|
315
|
+
return { question: entry(question).question, at: Number.isNaN(at) ? 0 : at };
|
|
316
|
+
}
|
|
317
|
+
})(TaAskUtil || (TaAskUtil = {}));
|
|
246
318
|
// ../ta-protocol/esm/common/ta-protocol.js
|
|
247
319
|
var TaServer = Symbol("TaServer");
|
|
248
320
|
var TaClient = Symbol("TaClient");
|
|
@@ -260,6 +332,8 @@ var TaErrorCode = {
|
|
|
260
332
|
CANCELLED: "CELL_TA_CANCELLED",
|
|
261
333
|
NOT_SIGNED_IN: "CELL_TA_NOT_SIGNED_IN",
|
|
262
334
|
ENVIRONMENT_FAILED: "CELL_TA_ENVIRONMENT_FAILED",
|
|
335
|
+
FORBIDDEN: "CELL_TA_FORBIDDEN",
|
|
336
|
+
LIMIT: "CELL_TA_LIMIT",
|
|
263
337
|
CONNECTION_LOST: "CELL_TA_CONNECTION_LOST"
|
|
264
338
|
};
|
|
265
339
|
var TaErrorUtil;
|
|
@@ -296,7 +370,34 @@ ${message}`;
|
|
|
296
370
|
return message.replace(BLOCK, "");
|
|
297
371
|
}
|
|
298
372
|
TaMessageContext2.strip = strip;
|
|
373
|
+
function read(message) {
|
|
374
|
+
var _a;
|
|
375
|
+
const block = (_a = BLOCK.exec(message)) === null || _a === undefined ? undefined : _a[0];
|
|
376
|
+
return block === null || block === undefined ? undefined : block.replace(/^<context>\n?/, "").replace(/\n?<\/context>\n?$/, "");
|
|
377
|
+
}
|
|
378
|
+
TaMessageContext2.read = read;
|
|
299
379
|
})(TaMessageContext || (TaMessageContext = {}));
|
|
380
|
+
var TaMessageSource;
|
|
381
|
+
(function(TaMessageSource2) {
|
|
382
|
+
TaMessageSource2.DOUBLE = "ta:double";
|
|
383
|
+
const LINE = /^\[ta:from ([^\s\]]+)(?: ([^\]\n]+))?\]$/m;
|
|
384
|
+
function mark(message, from, detail) {
|
|
385
|
+
if (/^[/!]/.test(message) || of(message)) {
|
|
386
|
+
return message;
|
|
387
|
+
}
|
|
388
|
+
const line = `[ta:from ${from}${detail ? ` ${detail.replace(/[\]\n]/g, " ")}` : ""}]`;
|
|
389
|
+
const context = TaMessageContext.read(message);
|
|
390
|
+
return TaMessageContext.wrap(context === undefined ? line : `${context}
|
|
391
|
+
${line}`, TaMessageContext.strip(message));
|
|
392
|
+
}
|
|
393
|
+
TaMessageSource2.mark = mark;
|
|
394
|
+
function of(message) {
|
|
395
|
+
const context = TaMessageContext.read(message);
|
|
396
|
+
const match = context === undefined ? null : LINE.exec(context);
|
|
397
|
+
return match ? { from: match[1], ...match[2] ? { detail: match[2].trim() } : {} } : undefined;
|
|
398
|
+
}
|
|
399
|
+
TaMessageSource2.of = of;
|
|
400
|
+
})(TaMessageSource || (TaMessageSource = {}));
|
|
300
401
|
var TaImageNote;
|
|
301
402
|
(function(TaImageNote2) {
|
|
302
403
|
const NOTE = /^\[Image: original \d+x\d+, displayed at \d+x\d+\. Multiply coordinates by [\d.]+ to map to original image\.\]$|^\[Image converted from [^\]]+ to [^\]]+\.\]$/;
|
|
@@ -417,6 +518,86 @@ var TaSkillUse;
|
|
|
417
518
|
}
|
|
418
519
|
TaSkillUse2.command = command;
|
|
419
520
|
})(TaSkillUse || (TaSkillUse = {}));
|
|
521
|
+
// ../ta-protocol/esm/common/team-protocol.js
|
|
522
|
+
var TA_OWNER = "owner";
|
|
523
|
+
var TA_UNDECLARED = "extensions.install";
|
|
524
|
+
var TaPermissionUtil;
|
|
525
|
+
(function(TaPermissionUtil2) {
|
|
526
|
+
function read(pi) {
|
|
527
|
+
const given = pi === null || pi === undefined ? undefined : pi.permissions;
|
|
528
|
+
const map = (value) => value && typeof value === "object" && !Array.isArray(value) ? Object.fromEntries(Object.entries(value).filter((entry) => typeof entry[1] === "string")) : undefined;
|
|
529
|
+
const host2 = map(given === null || given === undefined ? undefined : given.host);
|
|
530
|
+
const tools = map(given === null || given === undefined ? undefined : given.tools);
|
|
531
|
+
return { ...host2 ? { host: host2 } : {}, ...tools ? { tools } : {} };
|
|
532
|
+
}
|
|
533
|
+
TaPermissionUtil2.read = read;
|
|
534
|
+
function host(manifest, method, kind) {
|
|
535
|
+
var _a, _b, _c, _d;
|
|
536
|
+
const host2 = (_a = manifest === null || manifest === undefined ? undefined : manifest.host) !== null && _a !== undefined ? _a : {};
|
|
537
|
+
const own = (key) => Object.prototype.hasOwnProperty.call(host2, key) ? host2[key] : undefined;
|
|
538
|
+
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;
|
|
539
|
+
}
|
|
540
|
+
TaPermissionUtil2.host = host;
|
|
541
|
+
})(TaPermissionUtil || (TaPermissionUtil = {}));
|
|
542
|
+
var action = (id, en, zh, more = {}) => ({
|
|
543
|
+
id,
|
|
544
|
+
area: id.split(".")[0],
|
|
545
|
+
title: { en, "zh-CN": zh },
|
|
546
|
+
...more
|
|
547
|
+
});
|
|
548
|
+
var TA_ACTIONS = [
|
|
549
|
+
action("chat.view", "See conversations", "查看对话"),
|
|
550
|
+
action("chat.send", "Send in conversations", "在对话里发消息"),
|
|
551
|
+
action("chat.create", "Start conversations", "新建对话"),
|
|
552
|
+
action("chat.stop", "Stop a reply", "停止回复"),
|
|
553
|
+
action("chat.manage", "Rename, archive and close conversations", "改名、归档、关闭对话"),
|
|
554
|
+
action("chat.share", "Share by a link", "生成分享链接"),
|
|
555
|
+
action("agent.view", "See agents", "查看智能体"),
|
|
556
|
+
action("agent.use", "Talk with agents", "和智能体对话"),
|
|
557
|
+
action("agent.edit", "Create, change and remove agents", "新建、修改、删除智能体"),
|
|
558
|
+
action("channel.view", "See channels", "查看频道"),
|
|
559
|
+
action("channel.post", "Post in channels", "在频道里发言"),
|
|
560
|
+
action("channel.manage", "Create and change channels", "新建、管理频道"),
|
|
561
|
+
action("task.view", "See tasks", "查看任务"),
|
|
562
|
+
action("task.create", "Hand out tasks", "派任务"),
|
|
563
|
+
action("task.manage", "Take over and stop tasks", "接管、停止任务"),
|
|
564
|
+
action("files.read", "Read files", "读文件", { scoped: true }),
|
|
565
|
+
action("files.write", "Change files", "改文件", { scoped: true }),
|
|
566
|
+
action("commands.run", "Let Ta run commands", "让 Ta 运行命令", { scoped: true, risky: true }),
|
|
567
|
+
action("commands.terminal", "Open terminals", "打开终端", { scoped: true, risky: true }),
|
|
568
|
+
action("hosts.use", "Use remote hosts", "使用远程主机", { risky: true }),
|
|
569
|
+
action("models.use", "Use the models", "使用模型"),
|
|
570
|
+
action("models.manage", "Sign in to models", "登录和更换模型账号"),
|
|
571
|
+
action("cron.view", "See scheduled tasks", "查看定时任务"),
|
|
572
|
+
action("cron.manage", "Change scheduled tasks", "管理定时任务"),
|
|
573
|
+
action("extensions.use", "Use extensions", "使用扩展"),
|
|
574
|
+
action("extensions.install", "Install and turn off extensions", "安装、停用扩展"),
|
|
575
|
+
action("settings.view", "See settings", "查看设置"),
|
|
576
|
+
action("settings.manage", "Change settings", "修改设置"),
|
|
577
|
+
action("members.view", "See members", "查看成员"),
|
|
578
|
+
action("members.invite", "Invite people", "邀请别人"),
|
|
579
|
+
action("members.approve", "Answer requests", "处理申请"),
|
|
580
|
+
action("members.roles", "Change roles and members", "管理角色和成员"),
|
|
581
|
+
action("audit.view", "See the record", "查看记录")
|
|
582
|
+
];
|
|
583
|
+
var TaActionUtil;
|
|
584
|
+
(function(TaActionUtil2) {
|
|
585
|
+
const byId = new Map(TA_ACTIONS.map((one) => [one.id, one]));
|
|
586
|
+
function info(id) {
|
|
587
|
+
return byId.get(id);
|
|
588
|
+
}
|
|
589
|
+
TaActionUtil2.info = info;
|
|
590
|
+
function title(id, language) {
|
|
591
|
+
const found = byId.get(id);
|
|
592
|
+
return found ? language.startsWith("zh") ? found.title["zh-CN"] : found.title.en : id;
|
|
593
|
+
}
|
|
594
|
+
TaActionUtil2.title = title;
|
|
595
|
+
function inside(dir, path) {
|
|
596
|
+
const base = dir.replace(/\/+$/, "");
|
|
597
|
+
return path === base || path.startsWith(`${base}/`) || base === "";
|
|
598
|
+
}
|
|
599
|
+
TaActionUtil2.inside = inside;
|
|
600
|
+
})(TaActionUtil || (TaActionUtil = {}));
|
|
420
601
|
// ../ta-protocol/esm/common/workspace-protocol.js
|
|
421
602
|
var TaWorkspaceServer = Symbol("TaWorkspaceServer");
|
|
422
603
|
var TaTerminalServer = Symbol("TaTerminalServer");
|
|
@@ -651,12 +832,12 @@ var ChannelsUtil;
|
|
|
651
832
|
ChannelsUtil.hash = hash;
|
|
652
833
|
function findAgent(team, ref) {
|
|
653
834
|
const key = ref.trim().replace(/^@/, "").toLowerCase();
|
|
654
|
-
return team.agents.find((agent) => agent.id === ref
|
|
835
|
+
return team.agents.find((agent) => agent.id === ref) ?? team.agents.find((agent) => agent.name.toLowerCase() === key);
|
|
655
836
|
}
|
|
656
837
|
ChannelsUtil.findAgent = findAgent;
|
|
657
838
|
function findChannel(team, ref) {
|
|
658
839
|
const key = ref.trim().replace(/^#/, "").toLowerCase();
|
|
659
|
-
return team.channels.find((channel) => channel.id === ref
|
|
840
|
+
return team.channels.find((channel) => channel.id === ref) ?? team.channels.find((channel) => channel.name.toLowerCase() === key);
|
|
660
841
|
}
|
|
661
842
|
ChannelsUtil.findChannel = findChannel;
|
|
662
843
|
function directory(value) {
|
|
@@ -1005,6 +1186,8 @@ var ChannelsUtil;
|
|
|
1005
1186
|
lines.push("", "Recent messages:", ...before.map((item) => `${authorName(team, item.author, labels)}: ${item.text}`));
|
|
1006
1187
|
}
|
|
1007
1188
|
lines.push("", `${authorName(team, message.author, labels)} to you:`);
|
|
1189
|
+
const speaker = message.author === USER ? "" : ` · ${authorName(team, message.author, labels).replace(/[\]\n]/g, " ")}`;
|
|
1190
|
+
lines.push(`[ta:from ${NAME} #${channel.name}${speaker}]`);
|
|
1008
1191
|
return `<context>
|
|
1009
1192
|
${lines.join(`
|
|
1010
1193
|
`)}
|
|
@@ -1275,6 +1458,42 @@ ${brief.trim()}`;
|
|
|
1275
1458
|
HandOff.result = result;
|
|
1276
1459
|
})(HandOff ||= {});
|
|
1277
1460
|
|
|
1461
|
+
// web-src/team-view.ts
|
|
1462
|
+
var TeamViewUtil;
|
|
1463
|
+
((TeamViewUtil) => {
|
|
1464
|
+
function visible(team2, can) {
|
|
1465
|
+
const channels = new Set(team2.channels.filter((channel) => can("channel", channel.id)).map((channel) => channel.id));
|
|
1466
|
+
const agents = new Set(team2.agents.filter((agent) => can("agent", agent.id)).map((agent) => agent.id));
|
|
1467
|
+
for (const channel of team2.channels) {
|
|
1468
|
+
if (channels.has(channel.id)) {
|
|
1469
|
+
for (const member of channel.members) {
|
|
1470
|
+
agents.add(member);
|
|
1471
|
+
}
|
|
1472
|
+
}
|
|
1473
|
+
}
|
|
1474
|
+
return { agents, channels };
|
|
1475
|
+
}
|
|
1476
|
+
TeamViewUtil.visible = visible;
|
|
1477
|
+
function team(value, visible2) {
|
|
1478
|
+
if (!value) {
|
|
1479
|
+
return value;
|
|
1480
|
+
}
|
|
1481
|
+
return {
|
|
1482
|
+
...value,
|
|
1483
|
+
agents: value.agents.filter((agent) => visible2.agents.has(agent.id)),
|
|
1484
|
+
channels: value.channels.filter((channel) => visible2.channels.has(channel.id))
|
|
1485
|
+
};
|
|
1486
|
+
}
|
|
1487
|
+
TeamViewUtil.team = team;
|
|
1488
|
+
function byId(value, seen) {
|
|
1489
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
1490
|
+
return value;
|
|
1491
|
+
}
|
|
1492
|
+
return Object.fromEntries(Object.entries(value).filter(([id]) => seen.has(id)));
|
|
1493
|
+
}
|
|
1494
|
+
TeamViewUtil.byId = byId;
|
|
1495
|
+
})(TeamViewUtil ||= {});
|
|
1496
|
+
|
|
1278
1497
|
// web-src/team.ts
|
|
1279
1498
|
class TeamService {
|
|
1280
1499
|
host;
|
|
@@ -1300,6 +1519,7 @@ class TeamService {
|
|
|
1300
1519
|
}
|
|
1301
1520
|
async start() {
|
|
1302
1521
|
this.team = await this.get(Keys.TEAM) ?? ChannelsUtil.emptyTeam();
|
|
1522
|
+
this.shareWithMembers();
|
|
1303
1523
|
await this.pinDirectories();
|
|
1304
1524
|
this.queue = await this.get(Keys.QUEUE) ?? { jobs: [], rounds: {} };
|
|
1305
1525
|
await this.set(Keys.WORKING, null);
|
|
@@ -1476,7 +1696,14 @@ class TeamService {
|
|
|
1476
1696
|
async focus(channelId) {
|
|
1477
1697
|
await this.set(Keys.FOCUS, { channelId, at: Date.now() });
|
|
1478
1698
|
}
|
|
1479
|
-
|
|
1699
|
+
poster() {
|
|
1700
|
+
const principal = this.host.team?.current();
|
|
1701
|
+
if (!principal || principal === TA_OWNER) {
|
|
1702
|
+
return {};
|
|
1703
|
+
}
|
|
1704
|
+
return { by: principal, byName: this.host.team?.describe(principal)?.name ?? principal };
|
|
1705
|
+
}
|
|
1706
|
+
async post(channelRef, author, text, poster = {}) {
|
|
1480
1707
|
const channel = ChannelsUtil.findChannel(this.team, channelRef);
|
|
1481
1708
|
if (!channel) {
|
|
1482
1709
|
const known = this.team.channels.map((other) => `#${other.name}`).join(", ") || "none yet";
|
|
@@ -1485,7 +1712,7 @@ class TeamService {
|
|
|
1485
1712
|
if (!text.trim()) {
|
|
1486
1713
|
throw new Error("The message is empty.");
|
|
1487
1714
|
}
|
|
1488
|
-
const message = await this.append(channel.id, { id: ChannelsUtil.newId("message"), author, text: text.trim(), at: Date.now() });
|
|
1715
|
+
const message = await this.append(channel.id, { id: ChannelsUtil.newId("message"), author, text: text.trim(), at: Date.now(), ...poster });
|
|
1489
1716
|
const done = new Promise((resolve) => this.waitingFor(message.id).waiters.push(resolve));
|
|
1490
1717
|
await this.handOn(channel, message, 0, message.id);
|
|
1491
1718
|
await this.settle(message.id);
|
|
@@ -1517,6 +1744,18 @@ class TeamService {
|
|
|
1517
1744
|
await this.focus(channel.id);
|
|
1518
1745
|
return { kind: "channel", id: channel.id, name: channel.name };
|
|
1519
1746
|
}
|
|
1747
|
+
listAgents() {
|
|
1748
|
+
const faces = ChannelsUtil.faces(this.team.agents);
|
|
1749
|
+
return this.team.agents.map((agent) => ({
|
|
1750
|
+
id: agent.id,
|
|
1751
|
+
name: agent.name,
|
|
1752
|
+
role: agent.role,
|
|
1753
|
+
mark: agent.mark,
|
|
1754
|
+
face: faces.get(agent.id) ?? 0,
|
|
1755
|
+
...agent.cwd ? { cwd: agent.cwd } : {},
|
|
1756
|
+
...agent.temporary ? { temporary: true } : {}
|
|
1757
|
+
}));
|
|
1758
|
+
}
|
|
1520
1759
|
async request(request) {
|
|
1521
1760
|
if (this.disposed) {
|
|
1522
1761
|
throw new Error("The team has stopped; the extension may have been turned off.");
|
|
@@ -1541,7 +1780,7 @@ class TeamService {
|
|
|
1541
1780
|
case "deleteAgent":
|
|
1542
1781
|
return this.deleteAgent(request.agent);
|
|
1543
1782
|
case "post":
|
|
1544
|
-
return (await this.post(String(request.channel ?? ""), USER, String(request.text ?? ""))).message;
|
|
1783
|
+
return (await this.post(String(request.channel ?? ""), USER, String(request.text ?? ""), this.poster())).message;
|
|
1545
1784
|
case "setNotice":
|
|
1546
1785
|
return this.setNotice({ channel: request.channel, text: request.text, by: USER });
|
|
1547
1786
|
case "shareAgent":
|
|
@@ -1604,7 +1843,8 @@ class TeamService {
|
|
|
1604
1843
|
const message = messages.find((candidate) => candidate.id === job.messageId);
|
|
1605
1844
|
let reply = messages.find((candidate) => candidate.replyTo === job.messageId && candidate.author === job.agentId);
|
|
1606
1845
|
if (!reply && channel && message) {
|
|
1607
|
-
|
|
1846
|
+
const by = messages.find((candidate) => candidate.id === job.round)?.by;
|
|
1847
|
+
reply = await this.answer(channel, message, job.agentId, by);
|
|
1608
1848
|
}
|
|
1609
1849
|
if (this.disposed) {
|
|
1610
1850
|
return;
|
|
@@ -1659,12 +1899,13 @@ class TeamService {
|
|
|
1659
1899
|
}
|
|
1660
1900
|
return waiting;
|
|
1661
1901
|
}
|
|
1662
|
-
async answer(channel, message, agentId) {
|
|
1902
|
+
async answer(channel, message, agentId, by) {
|
|
1663
1903
|
await this.setWorking(channel.id, agentId, true);
|
|
1664
1904
|
let text;
|
|
1665
1905
|
let failed = false;
|
|
1666
1906
|
try {
|
|
1667
|
-
|
|
1907
|
+
const team = this.host.team;
|
|
1908
|
+
text = await (by && team ? team.actAs(by, () => this.ask(channel, message, agentId)) : this.ask(channel, message, agentId));
|
|
1668
1909
|
} catch (error) {
|
|
1669
1910
|
text = error instanceof Error ? error.message : String(error);
|
|
1670
1911
|
failed = true;
|
|
@@ -1785,8 +2026,48 @@ class TeamService {
|
|
|
1785
2026
|
}
|
|
1786
2027
|
async saveTeam(team) {
|
|
1787
2028
|
this.team = team;
|
|
2029
|
+
this.linkSessions();
|
|
1788
2030
|
await this.set(Keys.TEAM, team);
|
|
1789
2031
|
}
|
|
2032
|
+
shareWithMembers() {
|
|
2033
|
+
const team = this.host.team;
|
|
2034
|
+
if (!team) {
|
|
2035
|
+
return;
|
|
2036
|
+
}
|
|
2037
|
+
const can = (principal, kind, id) => team.can(principal, kind === "agent" ? "agent.view" : "channel.view", { kind, id });
|
|
2038
|
+
team.shareData(NAME, {
|
|
2039
|
+
keys: [Keys.TEAM, Keys.WORKING, Keys.ANSWERED, Keys.FOCUS, Keys.MESSAGES],
|
|
2040
|
+
view: (principal, key, value) => {
|
|
2041
|
+
const visible = TeamViewUtil.visible(this.team, (kind, id) => can(principal, kind, id));
|
|
2042
|
+
if (key === Keys.TEAM) {
|
|
2043
|
+
return TeamViewUtil.team(value, visible);
|
|
2044
|
+
}
|
|
2045
|
+
if (key.startsWith(Keys.MESSAGES)) {
|
|
2046
|
+
return visible.channels.has(key.slice(Keys.MESSAGES.length)) ? value : undefined;
|
|
2047
|
+
}
|
|
2048
|
+
if (key === Keys.FOCUS) {
|
|
2049
|
+
return visible.channels.has(value?.channelId ?? "") ? value : undefined;
|
|
2050
|
+
}
|
|
2051
|
+
return TeamViewUtil.byId(value, key === Keys.WORKING ? visible.channels : visible.agents);
|
|
2052
|
+
}
|
|
2053
|
+
});
|
|
2054
|
+
this.linkSessions();
|
|
2055
|
+
}
|
|
2056
|
+
linkSessions() {
|
|
2057
|
+
for (const agent of this.team.agents) {
|
|
2058
|
+
if (agent.sessionFile) {
|
|
2059
|
+
this.host.team?.link(agent.sessionFile, { kind: "agent", id: agent.id });
|
|
2060
|
+
}
|
|
2061
|
+
}
|
|
2062
|
+
}
|
|
2063
|
+
listChannels() {
|
|
2064
|
+
return this.team.channels.map((channel) => ({
|
|
2065
|
+
id: channel.id,
|
|
2066
|
+
name: channel.name,
|
|
2067
|
+
...channel.topic ? { topic: channel.topic } : {},
|
|
2068
|
+
members: channel.members
|
|
2069
|
+
}));
|
|
2070
|
+
}
|
|
1790
2071
|
async setWorking(channelId, agentId, on) {
|
|
1791
2072
|
const others = (this.working[channelId] ?? []).filter((id) => id !== agentId);
|
|
1792
2073
|
this.working = { ...this.working, [channelId]: on ? [...others, agentId] : others };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@celljs/ta-channels",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.13.1",
|
|
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.13.1",
|
|
31
|
+
"@celljs/ta-relay": "4.13.1",
|
|
32
|
+
"@celljs/ta-web": "4.13.1",
|
|
33
33
|
"@types/react": "^19.3.0"
|
|
34
34
|
},
|
|
35
35
|
"publishConfig": {
|
|
@@ -51,6 +51,30 @@
|
|
|
51
51
|
"host": "./host/index.mjs",
|
|
52
52
|
"extensions": [
|
|
53
53
|
"./extension/index.mjs"
|
|
54
|
-
]
|
|
54
|
+
],
|
|
55
|
+
"permissions": {
|
|
56
|
+
"host": {
|
|
57
|
+
"listAgents": "agent.view",
|
|
58
|
+
"listChannels": "channel.view",
|
|
59
|
+
"request:post": "channel.post",
|
|
60
|
+
"request:openAgent": "agent.use",
|
|
61
|
+
"request:setNotice": "channel.manage",
|
|
62
|
+
"request:updateChannel": "channel.manage",
|
|
63
|
+
"request:deleteChannel": "channel.manage",
|
|
64
|
+
"request:changeMember": "channel.manage",
|
|
65
|
+
"request:addMembers": "agent.edit",
|
|
66
|
+
"request:createChannel": "agent.edit",
|
|
67
|
+
"*": "agent.edit"
|
|
68
|
+
},
|
|
69
|
+
"tools": {
|
|
70
|
+
"list_channels": "channel.view",
|
|
71
|
+
"post_to_channel": "channel.post",
|
|
72
|
+
"hand_off": "agent.use",
|
|
73
|
+
"create_agent": "agent.edit",
|
|
74
|
+
"create_channel": "agent.edit",
|
|
75
|
+
"add_to_channel": "agent.edit",
|
|
76
|
+
"update_channel_notice": "channel.manage"
|
|
77
|
+
}
|
|
78
|
+
}
|
|
55
79
|
}
|
|
56
80
|
}
|
package/web/index.js
CHANGED
|
@@ -215,12 +215,12 @@ var ChannelsUtil;
|
|
|
215
215
|
ChannelsUtil.hash = hash;
|
|
216
216
|
function findAgent(team, ref) {
|
|
217
217
|
const key = ref.trim().replace(/^@/, "").toLowerCase();
|
|
218
|
-
return team.agents.find((agent) => agent.id === ref
|
|
218
|
+
return team.agents.find((agent) => agent.id === ref) ?? team.agents.find((agent) => agent.name.toLowerCase() === key);
|
|
219
219
|
}
|
|
220
220
|
ChannelsUtil.findAgent = findAgent;
|
|
221
221
|
function findChannel(team, ref) {
|
|
222
222
|
const key = ref.trim().replace(/^#/, "").toLowerCase();
|
|
223
|
-
return team.channels.find((channel) => channel.id === ref
|
|
223
|
+
return team.channels.find((channel) => channel.id === ref) ?? team.channels.find((channel) => channel.name.toLowerCase() === key);
|
|
224
224
|
}
|
|
225
225
|
ChannelsUtil.findChannel = findChannel;
|
|
226
226
|
function directory(value) {
|
|
@@ -569,6 +569,8 @@ var ChannelsUtil;
|
|
|
569
569
|
lines.push("", "Recent messages:", ...before.map((item) => `${authorName(team, item.author, labels)}: ${item.text}`));
|
|
570
570
|
}
|
|
571
571
|
lines.push("", `${authorName(team, message.author, labels)} to you:`);
|
|
572
|
+
const speaker = message.author === USER ? "" : ` · ${authorName(team, message.author, labels).replace(/[\]\n]/g, " ")}`;
|
|
573
|
+
lines.push(`[ta:from ${NAME} #${channel.name}${speaker}]`);
|
|
572
574
|
return `<context>
|
|
573
575
|
${lines.join(`
|
|
574
576
|
`)}
|
|
@@ -1154,6 +1156,7 @@ var EN = {
|
|
|
1154
1156
|
back: "Back",
|
|
1155
1157
|
send: "Send",
|
|
1156
1158
|
you: "You",
|
|
1159
|
+
owner: "Owner",
|
|
1157
1160
|
ta: "Ta",
|
|
1158
1161
|
lead: "Lead",
|
|
1159
1162
|
empty: "No channels yet",
|
|
@@ -1338,6 +1341,7 @@ var ZH = {
|
|
|
1338
1341
|
back: "返回",
|
|
1339
1342
|
send: "发送",
|
|
1340
1343
|
you: "你",
|
|
1344
|
+
owner: "所有者",
|
|
1341
1345
|
ta: "Ta",
|
|
1342
1346
|
lead: "负责人",
|
|
1343
1347
|
empty: "还没有频道",
|
|
@@ -2989,6 +2993,87 @@ function MemberPicker({ context, team, channel, faces }) {
|
|
|
2989
2993
|
}))));
|
|
2990
2994
|
}
|
|
2991
2995
|
|
|
2996
|
+
// ../ta-protocol/esm/common/team-protocol.js
|
|
2997
|
+
var TA_OWNER = "owner";
|
|
2998
|
+
var TA_UNDECLARED = "extensions.install";
|
|
2999
|
+
var TaPermissionUtil;
|
|
3000
|
+
(function(TaPermissionUtil2) {
|
|
3001
|
+
function read(pi) {
|
|
3002
|
+
const given = pi === null || pi === undefined ? undefined : pi.permissions;
|
|
3003
|
+
const map = (value) => value && typeof value === "object" && !Array.isArray(value) ? Object.fromEntries(Object.entries(value).filter((entry) => typeof entry[1] === "string")) : undefined;
|
|
3004
|
+
const host2 = map(given === null || given === undefined ? undefined : given.host);
|
|
3005
|
+
const tools = map(given === null || given === undefined ? undefined : given.tools);
|
|
3006
|
+
return { ...host2 ? { host: host2 } : {}, ...tools ? { tools } : {} };
|
|
3007
|
+
}
|
|
3008
|
+
TaPermissionUtil2.read = read;
|
|
3009
|
+
function host(manifest, method, kind) {
|
|
3010
|
+
var _a, _b, _c, _d;
|
|
3011
|
+
const host2 = (_a = manifest === null || manifest === undefined ? undefined : manifest.host) !== null && _a !== undefined ? _a : {};
|
|
3012
|
+
const own = (key) => Object.prototype.hasOwnProperty.call(host2, key) ? host2[key] : undefined;
|
|
3013
|
+
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;
|
|
3014
|
+
}
|
|
3015
|
+
TaPermissionUtil2.host = host;
|
|
3016
|
+
})(TaPermissionUtil || (TaPermissionUtil = {}));
|
|
3017
|
+
var action = (id, en, zh, more = {}) => ({
|
|
3018
|
+
id,
|
|
3019
|
+
area: id.split(".")[0],
|
|
3020
|
+
title: { en, "zh-CN": zh },
|
|
3021
|
+
...more
|
|
3022
|
+
});
|
|
3023
|
+
var TA_ACTIONS = [
|
|
3024
|
+
action("chat.view", "See conversations", "查看对话"),
|
|
3025
|
+
action("chat.send", "Send in conversations", "在对话里发消息"),
|
|
3026
|
+
action("chat.create", "Start conversations", "新建对话"),
|
|
3027
|
+
action("chat.stop", "Stop a reply", "停止回复"),
|
|
3028
|
+
action("chat.manage", "Rename, archive and close conversations", "改名、归档、关闭对话"),
|
|
3029
|
+
action("chat.share", "Share by a link", "生成分享链接"),
|
|
3030
|
+
action("agent.view", "See agents", "查看智能体"),
|
|
3031
|
+
action("agent.use", "Talk with agents", "和智能体对话"),
|
|
3032
|
+
action("agent.edit", "Create, change and remove agents", "新建、修改、删除智能体"),
|
|
3033
|
+
action("channel.view", "See channels", "查看频道"),
|
|
3034
|
+
action("channel.post", "Post in channels", "在频道里发言"),
|
|
3035
|
+
action("channel.manage", "Create and change channels", "新建、管理频道"),
|
|
3036
|
+
action("task.view", "See tasks", "查看任务"),
|
|
3037
|
+
action("task.create", "Hand out tasks", "派任务"),
|
|
3038
|
+
action("task.manage", "Take over and stop tasks", "接管、停止任务"),
|
|
3039
|
+
action("files.read", "Read files", "读文件", { scoped: true }),
|
|
3040
|
+
action("files.write", "Change files", "改文件", { scoped: true }),
|
|
3041
|
+
action("commands.run", "Let Ta run commands", "让 Ta 运行命令", { scoped: true, risky: true }),
|
|
3042
|
+
action("commands.terminal", "Open terminals", "打开终端", { scoped: true, risky: true }),
|
|
3043
|
+
action("hosts.use", "Use remote hosts", "使用远程主机", { risky: true }),
|
|
3044
|
+
action("models.use", "Use the models", "使用模型"),
|
|
3045
|
+
action("models.manage", "Sign in to models", "登录和更换模型账号"),
|
|
3046
|
+
action("cron.view", "See scheduled tasks", "查看定时任务"),
|
|
3047
|
+
action("cron.manage", "Change scheduled tasks", "管理定时任务"),
|
|
3048
|
+
action("extensions.use", "Use extensions", "使用扩展"),
|
|
3049
|
+
action("extensions.install", "Install and turn off extensions", "安装、停用扩展"),
|
|
3050
|
+
action("settings.view", "See settings", "查看设置"),
|
|
3051
|
+
action("settings.manage", "Change settings", "修改设置"),
|
|
3052
|
+
action("members.view", "See members", "查看成员"),
|
|
3053
|
+
action("members.invite", "Invite people", "邀请别人"),
|
|
3054
|
+
action("members.approve", "Answer requests", "处理申请"),
|
|
3055
|
+
action("members.roles", "Change roles and members", "管理角色和成员"),
|
|
3056
|
+
action("audit.view", "See the record", "查看记录")
|
|
3057
|
+
];
|
|
3058
|
+
var TaActionUtil;
|
|
3059
|
+
(function(TaActionUtil2) {
|
|
3060
|
+
const byId = new Map(TA_ACTIONS.map((one) => [one.id, one]));
|
|
3061
|
+
function info(id) {
|
|
3062
|
+
return byId.get(id);
|
|
3063
|
+
}
|
|
3064
|
+
TaActionUtil2.info = info;
|
|
3065
|
+
function title(id, language) {
|
|
3066
|
+
const found = byId.get(id);
|
|
3067
|
+
return found ? language.startsWith("zh") ? found.title["zh-CN"] : found.title.en : id;
|
|
3068
|
+
}
|
|
3069
|
+
TaActionUtil2.title = title;
|
|
3070
|
+
function inside(dir, path) {
|
|
3071
|
+
const base = dir.replace(/\/+$/, "");
|
|
3072
|
+
return path === base || path.startsWith(`${base}/`) || base === "";
|
|
3073
|
+
}
|
|
3074
|
+
TaActionUtil2.inside = inside;
|
|
3075
|
+
})(TaActionUtil || (TaActionUtil = {}));
|
|
3076
|
+
|
|
2992
3077
|
// web-src/notice.tsx
|
|
2993
3078
|
var NoticeView;
|
|
2994
3079
|
((NoticeView) => {
|
|
@@ -3117,7 +3202,7 @@ var RoomUtil;
|
|
|
3117
3202
|
return messages.map((message, index) => {
|
|
3118
3203
|
const before = messages[index - 1];
|
|
3119
3204
|
const separator = !before || message.at - before.at > PAUSE_MS;
|
|
3120
|
-
const first = separator || before.author !== message.author || before.author === SYSTEM || !!before.notice || message.at - before.at > RUN_MS;
|
|
3205
|
+
const first = separator || before.author !== message.author || before.by !== message.by || before.author === SYSTEM || !!before.notice || message.at - before.at > RUN_MS;
|
|
3121
3206
|
return { message, first, separator };
|
|
3122
3207
|
});
|
|
3123
3208
|
}
|
|
@@ -3201,8 +3286,22 @@ function ChannelSceneHead({ context, channelId }) {
|
|
|
3201
3286
|
size: 13
|
|
3202
3287
|
}), w.openInMain));
|
|
3203
3288
|
}
|
|
3289
|
+
var mePromise;
|
|
3290
|
+
function useMe(pi) {
|
|
3291
|
+
const [me, setMe] = React.useState(TA_OWNER);
|
|
3292
|
+
React.useEffect(() => {
|
|
3293
|
+
mePromise ??= pi.server.getServerInfo().then((info) => info.member?.id ?? TA_OWNER, () => TA_OWNER);
|
|
3294
|
+
let live = true;
|
|
3295
|
+
mePromise.then((id) => live && setMe(id));
|
|
3296
|
+
return () => {
|
|
3297
|
+
live = false;
|
|
3298
|
+
};
|
|
3299
|
+
}, [pi]);
|
|
3300
|
+
return me;
|
|
3301
|
+
}
|
|
3204
3302
|
function ChannelRoom({ context, channelId: fixed }) {
|
|
3205
3303
|
const { pi, service, ui } = context;
|
|
3304
|
+
const me = useMe(pi);
|
|
3206
3305
|
const state = useChannels(service);
|
|
3207
3306
|
const shown = useUi(ui).channelId;
|
|
3208
3307
|
const channelId = fixed ?? shown;
|
|
@@ -3278,7 +3377,24 @@ function ChannelRoom({ context, channelId: fixed }) {
|
|
|
3278
3377
|
className: "tac-notice tac-notice-line",
|
|
3279
3378
|
disabled: !channel.notice,
|
|
3280
3379
|
onClick: () => setNotice({ open: true, editing: false })
|
|
3281
|
-
}, ChannelWords.format(message.notice === "cleared" ? w.noticeCleared : w.noticeUpdated, { name: name(message.author) })) : message.author === USER ? /* @__PURE__ */ React.createElement("div", {
|
|
3380
|
+
}, 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", {
|
|
3381
|
+
className: `tac-msg${first ? " tac-first" : ""}`
|
|
3382
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
3383
|
+
className: "tac-msg-face"
|
|
3384
|
+
}, first && pi.ui.Face && /* @__PURE__ */ React.createElement(pi.ui.Face, {
|
|
3385
|
+
seed: message.by ?? TA_OWNER,
|
|
3386
|
+
size: 28
|
|
3387
|
+
})), /* @__PURE__ */ React.createElement("div", {
|
|
3388
|
+
className: "tac-msg-col"
|
|
3389
|
+
}, first && /* @__PURE__ */ React.createElement("div", {
|
|
3390
|
+
className: "tac-msg-name"
|
|
3391
|
+
}, message.byName ?? w.owner), /* @__PURE__ */ React.createElement("div", {
|
|
3392
|
+
className: "tac-msg-bubble",
|
|
3393
|
+
title: time(message.at)
|
|
3394
|
+
}, /* @__PURE__ */ React.createElement(Mentions, {
|
|
3395
|
+
text: message.text,
|
|
3396
|
+
agents: state.team.agents
|
|
3397
|
+
})))) : message.author === USER ? /* @__PURE__ */ React.createElement("div", {
|
|
3282
3398
|
className: "ta-message ta-user tac-mine"
|
|
3283
3399
|
}, /* @__PURE__ */ React.createElement("div", {
|
|
3284
3400
|
className: "ta-bubble"
|
|
@@ -3513,8 +3629,8 @@ function AgentMenu({ context, agent, cwd, working }) {
|
|
|
3513
3629
|
const [dialog, setDialog] = React.useState();
|
|
3514
3630
|
const icon = (name) => ChannelViews.maybeIcon(pi, name, null, 15);
|
|
3515
3631
|
const fail = (error) => pi.ui.notify(ChannelViews.message(error), "error");
|
|
3516
|
-
const act = (
|
|
3517
|
-
Promise.resolve().then(
|
|
3632
|
+
const act = (action2) => () => {
|
|
3633
|
+
Promise.resolve().then(action2).catch(fail);
|
|
3518
3634
|
};
|
|
3519
3635
|
const openSession = async () => {
|
|
3520
3636
|
if (!agent.sessionFile) {
|
|
@@ -3613,14 +3729,14 @@ function AgentMenu({ context, agent, cwd, working }) {
|
|
|
3613
3729
|
}
|
|
3614
3730
|
}));
|
|
3615
3731
|
}
|
|
3616
|
-
function useSave(
|
|
3732
|
+
function useSave(action2, onClose) {
|
|
3617
3733
|
const [busy, setBusy] = React.useState(false);
|
|
3618
3734
|
const [error, setError] = React.useState();
|
|
3619
3735
|
const submit = (event) => {
|
|
3620
3736
|
event.preventDefault();
|
|
3621
3737
|
setBusy(true);
|
|
3622
3738
|
setError(undefined);
|
|
3623
|
-
|
|
3739
|
+
action2().then(onClose, (failure) => {
|
|
3624
3740
|
setBusy(false);
|
|
3625
3741
|
setError(ChannelViews.message(failure));
|
|
3626
3742
|
});
|
|
@@ -3876,8 +3992,8 @@ function taskMenu(context, channel, working) {
|
|
|
3876
3992
|
const { pi, service } = context;
|
|
3877
3993
|
const w = ChannelViews.words(pi);
|
|
3878
3994
|
const icon = (name) => ChannelViews.icon(pi, name);
|
|
3879
|
-
const act = (
|
|
3880
|
-
Promise.resolve().then(
|
|
3995
|
+
const act = (action2) => () => {
|
|
3996
|
+
Promise.resolve().then(action2).catch((error) => pi.ui.notify(ChannelViews.message(error), "error"));
|
|
3881
3997
|
};
|
|
3882
3998
|
const temporary = membersOf(service.state.team, channel).filter((agent) => agent.temporary);
|
|
3883
3999
|
return [
|
|
@@ -3964,8 +4080,8 @@ function ChannelMenu({ context, channel, working }) {
|
|
|
3964
4080
|
const { fresh } = useUi(ui);
|
|
3965
4081
|
const w = ChannelViews.words(pi);
|
|
3966
4082
|
const icon = (name) => ChannelViews.maybeIcon(pi, name, null, 15);
|
|
3967
|
-
const act = (
|
|
3968
|
-
Promise.resolve().then(
|
|
4083
|
+
const act = (action2) => () => {
|
|
4084
|
+
Promise.resolve().then(action2).catch((error) => pi.ui.notify(ChannelViews.message(error), "error"));
|
|
3969
4085
|
};
|
|
3970
4086
|
const unread = fresh.includes(channel.id);
|
|
3971
4087
|
const pin = act(() => service.updateChannel(channel.id, { pinned: !channel.pinned }));
|
|
@@ -4230,7 +4346,7 @@ function Section({
|
|
|
4230
4346
|
count,
|
|
4231
4347
|
folded,
|
|
4232
4348
|
onFold,
|
|
4233
|
-
action,
|
|
4349
|
+
action: action2,
|
|
4234
4350
|
alert,
|
|
4235
4351
|
children
|
|
4236
4352
|
}) {
|
|
@@ -4254,7 +4370,7 @@ function Section({
|
|
|
4254
4370
|
}), /* @__PURE__ */ React.createElement("span", {
|
|
4255
4371
|
className: "tac-section-chevron",
|
|
4256
4372
|
"aria-hidden": "true"
|
|
4257
|
-
})), !closed &&
|
|
4373
|
+
})), !closed && action2), !closed && /* @__PURE__ */ React.createElement("div", {
|
|
4258
4374
|
className: "tac-section-body"
|
|
4259
4375
|
}, children));
|
|
4260
4376
|
}
|
|
@@ -4880,9 +4996,7 @@ button.tac-notice-line { border: 0; font: inherit; font-size: calc(12px * var(--
|
|
|
4880
4996
|
button.tac-notice-line:hover:not(:disabled) { color: var(--ta-text); }
|
|
4881
4997
|
button.tac-notice-line:disabled { cursor: default; }
|
|
4882
4998
|
@keyframes tac-notice-in { from { opacity: 0; transform: translateY(-4px); } }
|
|
4883
|
-
|
|
4884
|
-
.tac-notice-bar { padding: 6px 14px 0; }
|
|
4885
|
-
}
|
|
4999
|
+
[data-layout='compact'] .tac-notice-bar { padding: 6px 14px 0; }
|
|
4886
5000
|
|
|
4887
5001
|
/* An agent's card (card.tsx): shared from its menu, opened from its link */
|
|
4888
5002
|
.tac-card { display: flex; flex-direction: column; align-items: stretch; gap: 12px; }
|
|
@@ -4916,11 +5030,9 @@ button.tac-notice-line:disabled { cursor: default; }
|
|
|
4916
5030
|
/* Above the keyboard the home indicator is not there: no room for it, as under the box of a conversation. */
|
|
4917
5031
|
:root[data-keyboard] .tac-chat-bottom { padding-bottom: 8px; }
|
|
4918
5032
|
:root[data-keyboard-moving] .tac-chat-bottom { transition: padding-bottom 450ms cubic-bezier(0.15, 0.75, 0.2, 1); }
|
|
4919
|
-
|
|
4920
|
-
|
|
4921
|
-
|
|
4922
|
-
.tac-msg-col { max-width: calc(100% - 38px); }
|
|
4923
|
-
}
|
|
5033
|
+
[data-layout='compact'] .tac-head-topic, [data-layout='compact'] .tac-head-face:nth-child(n + 4), [data-layout='compact'] .tac-head-more { display: none; }
|
|
5034
|
+
[data-layout='compact'] .tac-chat-col, [data-layout='compact'] .tac-chat-bottom { padding-left: 14px; padding-right: 14px; }
|
|
5035
|
+
[data-layout='compact'] .tac-msg-col { max-width: calc(100% - 38px); }
|
|
4924
5036
|
.tac-new-head { position: relative; display: flex; align-items: center; justify-content: center; flex: 1; min-width: 0; height: 100%; }
|
|
4925
5037
|
.tac-new-title { position: relative; display: flex; justify-content: center; min-width: 0; }
|
|
4926
5038
|
.tac-new-head > .tac-button { position: absolute; right: 0; }
|
|
@@ -4964,11 +5076,9 @@ div.tac-dialog-label { flex-direction: row; justify-content: space-between; marg
|
|
|
4964
5076
|
.tac-dialog-note { color: var(--ta-muted); font-size: calc(12px * var(--ta-font-scale)); }
|
|
4965
5077
|
.tac-dialog-actions { display: flex; justify-content: flex-end; margin-top: 4px; }
|
|
4966
5078
|
.tac-dialog-actions .tac-button { height: 36px; padding: 0 18px; font-size: calc(13.5px * var(--ta-font-scale)); }
|
|
4967
|
-
|
|
4968
|
-
|
|
4969
|
-
|
|
4970
|
-
.tac-identity { position: fixed; top: calc(60px + env(safe-area-inset-top) + var(--ta-titlebar, 0px)); left: 12px; right: 12px; width: auto; max-width: none; transform: none; animation: none; }
|
|
4971
|
-
}
|
|
5079
|
+
[data-layout='compact'] .tac-new-head > .tac-button { position: static; margin-left: auto; }
|
|
5080
|
+
[data-layout='compact'] .tac-new-head { justify-content: flex-start; }
|
|
5081
|
+
[data-layout='compact'] .tac-identity { position: fixed; top: calc(60px + env(safe-area-inset-top) + var(--ta-titlebar, 0px)); left: 12px; right: 12px; width: auto; max-width: none; transform: none; animation: none; }
|
|
4972
5082
|
.tac-empty { padding: 8px 18px; }
|
|
4973
5083
|
.tac-item { position: relative; display: flex; align-items: center; gap: 12px; width: 100%; min-height: 60px; margin: 1px 0; padding: 9px 10px; border: 0; border-radius: 12px; background: none; color: var(--ta-text); font: inherit; text-align: left; cursor: pointer; transition: background 120ms; }
|
|
4974
5084
|
.tac-item:hover { background: var(--ta-hover); }
|