@celljs/ta-bots 4.15.2 → 4.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.en.md +1 -0
- package/README.md +1 -0
- package/extension/index.mjs +25 -22
- package/host/index.mjs +726 -151
- package/package.json +3 -3
- package/web/index.js +13 -2
package/README.en.md
CHANGED
|
@@ -13,6 +13,7 @@ A pi package that comes with Ta (on by default; turn it off in Settings → Exte
|
|
|
13
13
|
Rules:
|
|
14
14
|
|
|
15
15
|
- **A bot is connected to one place at most** (the double, an agent, or a conversation); one place can have several bots, of either kind.
|
|
16
|
+
- **Known in the list of conversations**: a plain conversation a bot is connected to has the icon of the bot's kind as its avatar (a bubble for WeChat, a building for WeCom), the first bot's when there are several; the double and agents keep their faces.
|
|
16
17
|
- **One bot per WeChat account**: scanning with the same WeChat again renews its bot (its name and where it is connected stay) rather than adding one. Different accounts each have their own. Robots of WeCom are told apart by Bot ID; the same Bot ID again updates its bot.
|
|
17
18
|
- A bot connected nowhere answers a message with how to connect it in Ta.
|
|
18
19
|
|
package/README.md
CHANGED
|
@@ -12,6 +12,7 @@ Ta 自带的 pi 包(默认开启,可在 Web 客户端的 设置 → 扩展
|
|
|
12
12
|
|
|
13
13
|
规则:
|
|
14
14
|
|
|
15
|
+
- **在对话列表里认得出**:连着机器人的普通对话,头像换成机器人种类的图标(微信是气泡,企业微信是大楼),连了几个时按第一个;分身和智能体仍是自己的脸。
|
|
15
16
|
- **一个机器人只连在一个地方**(分身、一个智能体,或一个对话);一个地方可以同时连多个、不同种类的机器人。
|
|
16
17
|
- **一个微信号对应一个机器人**:用同一个微信再次扫码,会更新原来的机器人(名字和连接位置保留),而不是多出一个。不同微信号可以各连一个。企业微信按 Bot ID 区分,重复填写同一个 Bot ID 会更新它。
|
|
17
18
|
- 没连到任何地方的机器人收到消息时,会回复一句如何在 Ta 里连接它。
|
package/extension/index.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// ../ta-protocol/esm/common/ta-extension-host.js
|
|
2
|
+
var TA_WEBHOOK_MAX_BYTES = 256 * 1024;
|
|
2
3
|
var TA_HOST_EVENT = "ta:host";
|
|
3
4
|
var TaHostUtil;
|
|
4
5
|
(function(TaHostUtil2) {
|
|
@@ -389,10 +390,8 @@ function botNote(details) {
|
|
|
389
390
|
function activate(pi) {
|
|
390
391
|
let reached;
|
|
391
392
|
let detach;
|
|
392
|
-
let
|
|
393
|
-
|
|
394
|
-
let failure;
|
|
395
|
-
let stopped = false;
|
|
393
|
+
let answers = [];
|
|
394
|
+
const origins = () => answers.flatMap((answer) => answer.origins);
|
|
396
395
|
let sessionFile = () => {
|
|
397
396
|
return;
|
|
398
397
|
};
|
|
@@ -427,31 +426,35 @@ function activate(pi) {
|
|
|
427
426
|
const message = event.message;
|
|
428
427
|
if (message.role === "custom" && message.customType === INBOUND_TYPE) {
|
|
429
428
|
const origin = message.details?.origin;
|
|
430
|
-
|
|
431
|
-
|
|
429
|
+
const last = answers.at(-1);
|
|
430
|
+
if (origin && last && !last.text && !last.failure && !last.stopped) {
|
|
431
|
+
last.origins.push(origin);
|
|
432
|
+
} else if (origin) {
|
|
433
|
+
answers.push({ origins: [origin], text: "", stopped: false });
|
|
432
434
|
}
|
|
433
|
-
} else if (message.role === "assistant" &&
|
|
434
|
-
const
|
|
435
|
-
|
|
436
|
-
failure = message.stopReason === "error" ? message.errorMessage || "error" : undefined;
|
|
437
|
-
stopped = message.stopReason === "aborted";
|
|
435
|
+
} else if (message.role === "assistant" && answers.length > 0 && message.stopReason !== "toolUse") {
|
|
436
|
+
const last = answers[answers.length - 1];
|
|
437
|
+
last.text = textOf(message.content) || last.text;
|
|
438
|
+
last.failure = message.stopReason === "error" ? message.errorMessage || "error" : undefined;
|
|
439
|
+
last.stopped = message.stopReason === "aborted";
|
|
438
440
|
}
|
|
439
441
|
});
|
|
440
442
|
pi.on("agent_settled", async () => {
|
|
441
|
-
if (
|
|
443
|
+
if (answers.length === 0) {
|
|
442
444
|
return;
|
|
443
445
|
}
|
|
444
|
-
const
|
|
445
|
-
|
|
446
|
-
origins = [];
|
|
447
|
-
answer = "";
|
|
448
|
-
failure = undefined;
|
|
449
|
-
stopped = false;
|
|
446
|
+
const given = answers;
|
|
447
|
+
answers = [];
|
|
450
448
|
const found = await reach();
|
|
451
|
-
if (found) {
|
|
452
|
-
|
|
453
|
-
|
|
449
|
+
if (!found) {
|
|
450
|
+
return;
|
|
451
|
+
}
|
|
452
|
+
const sent = [];
|
|
453
|
+
for (const answer of given) {
|
|
454
|
+
const text = answer.text || (answer.failure ? BotServerTexts.error(answer.failure) : answer.stopped ? BotServerTexts.stopped() : "");
|
|
455
|
+
sent.push(...await found.service.replied(answer.origins, text));
|
|
454
456
|
}
|
|
457
|
+
post({ sent });
|
|
455
458
|
});
|
|
456
459
|
pi.on("context", (event) => {
|
|
457
460
|
const messages = event.messages.filter((message) => !(message.role === "custom" && message.customType === SENT_TYPE));
|
|
@@ -473,7 +476,7 @@ function activate(pi) {
|
|
|
473
476
|
if (!found || !path) {
|
|
474
477
|
throw new Error(found ? "Give the path of the file." : "Bots need the Ta service.");
|
|
475
478
|
}
|
|
476
|
-
const to = origins.length > 0 ? origins : found.service.lastChats(await found.service.boundTo(sessionFile()));
|
|
479
|
+
const to = origins().length > 0 ? origins() : found.service.lastChats(await found.service.boundTo(sessionFile()));
|
|
477
480
|
if (to.length === 0) {
|
|
478
481
|
throw new Error("No chat of a bot is waiting for an answer in this conversation.");
|
|
479
482
|
}
|
package/host/index.mjs
CHANGED
|
@@ -279,23 +279,512 @@ var BotServerTexts;
|
|
|
279
279
|
|
|
280
280
|
// ../ta-protocol/esm/common/access-protocol.js
|
|
281
281
|
var TaAccessServer = Symbol("TaAccessServer");
|
|
282
|
+
// ../ta-protocol/esm/common/ta-extension-host.js
|
|
283
|
+
var TA_WEBHOOK_MAX_BYTES = 256 * 1024;
|
|
284
|
+
var TA_HOST_EVENT = "ta:host";
|
|
285
|
+
var TaHostUtil;
|
|
286
|
+
(function(TaHostUtil2) {
|
|
287
|
+
TaHostUtil2.WAIT_MS = 1000;
|
|
288
|
+
function reach(events, name, waitMs = TaHostUtil2.WAIT_MS) {
|
|
289
|
+
return new Promise((resolve) => {
|
|
290
|
+
let heard = false;
|
|
291
|
+
let answered = false;
|
|
292
|
+
const timer = setTimeout(() => resolve(undefined), waitMs);
|
|
293
|
+
const request = {
|
|
294
|
+
name,
|
|
295
|
+
heard: () => {
|
|
296
|
+
heard = true;
|
|
297
|
+
},
|
|
298
|
+
resolve: (answer) => {
|
|
299
|
+
answered = true;
|
|
300
|
+
clearTimeout(timer);
|
|
301
|
+
resolve(answer);
|
|
302
|
+
}
|
|
303
|
+
};
|
|
304
|
+
events.emit(TA_HOST_EVENT, request);
|
|
305
|
+
if (!heard && !answered) {
|
|
306
|
+
clearTimeout(timer);
|
|
307
|
+
resolve(undefined);
|
|
308
|
+
}
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
TaHostUtil2.reach = reach;
|
|
312
|
+
function marked(systemPrompt, mark) {
|
|
313
|
+
return role(systemPrompt).includes(mark);
|
|
314
|
+
}
|
|
315
|
+
TaHostUtil2.marked = marked;
|
|
316
|
+
function role(systemPrompt) {
|
|
317
|
+
if (!systemPrompt) {
|
|
318
|
+
return "";
|
|
319
|
+
}
|
|
320
|
+
const open = `<addendum>
|
|
321
|
+
`;
|
|
322
|
+
const start = systemPrompt.indexOf(open);
|
|
323
|
+
const context = systemPrompt.indexOf(`<project_context>
|
|
324
|
+
`);
|
|
325
|
+
if (start < 0 || context >= 0 && context < start) {
|
|
326
|
+
return "";
|
|
327
|
+
}
|
|
328
|
+
const end = systemPrompt.indexOf(`
|
|
329
|
+
</addendum>`, start);
|
|
330
|
+
return systemPrompt.slice(start + open.length, end < 0 ? undefined : end);
|
|
331
|
+
}
|
|
332
|
+
TaHostUtil2.role = role;
|
|
333
|
+
})(TaHostUtil || (TaHostUtil = {}));
|
|
334
|
+
var TA_DOUBLE_FILE = { name: "@celljs/ta-web", key: "assistant.file" };
|
|
335
|
+
var TA_ASK_ENTRY = "ta-ask";
|
|
336
|
+
var TaAskUtil;
|
|
337
|
+
(function(TaAskUtil2) {
|
|
338
|
+
const LENGTH = 120;
|
|
339
|
+
function entry(question) {
|
|
340
|
+
const line = question.replace(/\s+/g, " ").trim();
|
|
341
|
+
return { question: line.length > LENGTH ? `${line.slice(0, LENGTH - 1)}…` : line };
|
|
342
|
+
}
|
|
343
|
+
TaAskUtil2.entry = entry;
|
|
344
|
+
function asking(entries) {
|
|
345
|
+
var _a;
|
|
346
|
+
for (let i = entries.length - 1;i >= 0; i--) {
|
|
347
|
+
const entry2 = entries[i];
|
|
348
|
+
if (entry2.type === "message" && ((_a = entry2.message) === null || _a === undefined ? undefined : _a.role) === "user") {
|
|
349
|
+
return;
|
|
350
|
+
}
|
|
351
|
+
if (entry2.type === "custom" && entry2.customType === TA_ASK_ENTRY) {
|
|
352
|
+
return read(entry2);
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
return;
|
|
356
|
+
}
|
|
357
|
+
TaAskUtil2.asking = asking;
|
|
358
|
+
function next(asked, entry2) {
|
|
359
|
+
var _a;
|
|
360
|
+
if (entry2.type === "message" && ((_a = entry2.message) === null || _a === undefined ? undefined : _a.role) === "user") {
|
|
361
|
+
return;
|
|
362
|
+
}
|
|
363
|
+
return entry2.type === "custom" && entry2.customType === TA_ASK_ENTRY ? read(entry2) : asked;
|
|
364
|
+
}
|
|
365
|
+
TaAskUtil2.next = next;
|
|
366
|
+
function read(found) {
|
|
367
|
+
var _a;
|
|
368
|
+
const question = (_a = found.data) === null || _a === undefined ? undefined : _a.question;
|
|
369
|
+
if (typeof question !== "string" || !question.trim()) {
|
|
370
|
+
return;
|
|
371
|
+
}
|
|
372
|
+
const at = found.timestamp ? Date.parse(found.timestamp) : Number.NaN;
|
|
373
|
+
return { question: entry(question).question, at: Number.isNaN(at) ? 0 : at };
|
|
374
|
+
}
|
|
375
|
+
})(TaAskUtil || (TaAskUtil = {}));
|
|
376
|
+
|
|
377
|
+
// ../ta-protocol/esm/common/delegate-protocol.js
|
|
378
|
+
var TaDelegateUtil;
|
|
379
|
+
(function(TaDelegateUtil2) {
|
|
380
|
+
TaDelegateUtil2.LEVELS = ["less", "balanced", "more"];
|
|
381
|
+
TaDelegateUtil2.DEFAULT = "balanced";
|
|
382
|
+
TaDelegateUtil2.WORK_TOOLS = ["read", "bash", "powershell", "edit", "write", "grep", "find", "ls"];
|
|
383
|
+
TaDelegateUtil2.CHANGE_TOOLS = ["edit", "write"];
|
|
384
|
+
const LIMITS = {
|
|
385
|
+
less: { noChanges: false },
|
|
386
|
+
balanced: { noChanges: true, steps: 6 },
|
|
387
|
+
more: { noChanges: true, steps: 2 }
|
|
388
|
+
};
|
|
389
|
+
function parse(value) {
|
|
390
|
+
return TaDelegateUtil2.LEVELS.includes(value) ? value : TaDelegateUtil2.DEFAULT;
|
|
391
|
+
}
|
|
392
|
+
TaDelegateUtil2.parse = parse;
|
|
393
|
+
function mark(level) {
|
|
394
|
+
return `(delegate=${level})`;
|
|
395
|
+
}
|
|
396
|
+
TaDelegateUtil2.mark = mark;
|
|
397
|
+
function levelOf(systemPrompt) {
|
|
398
|
+
const role = TaHostUtil.role(systemPrompt);
|
|
399
|
+
return TaDelegateUtil2.LEVELS.find((level) => role.includes(mark(level)));
|
|
400
|
+
}
|
|
401
|
+
TaDelegateUtil2.levelOf = levelOf;
|
|
402
|
+
function limits(level) {
|
|
403
|
+
return LIMITS[level];
|
|
404
|
+
}
|
|
405
|
+
TaDelegateUtil2.limits = limits;
|
|
406
|
+
function refusal(level, tool, steps) {
|
|
407
|
+
if (!TaDelegateUtil2.WORK_TOOLS.includes(tool)) {
|
|
408
|
+
return;
|
|
409
|
+
}
|
|
410
|
+
const limit = LIMITS[level];
|
|
411
|
+
if (limit.noChanges && TaDelegateUtil2.CHANGE_TOOLS.includes(tool)) {
|
|
412
|
+
return "You do not change files yourself: hand this to a task with start_task, with instructions complete enough to do it. The user set how much you hand out in the settings of the double.";
|
|
413
|
+
}
|
|
414
|
+
if (limit.steps !== undefined && steps >= limit.steps) {
|
|
415
|
+
return "You have looked enough for this: hand the work to a task with start_task now, with what you found in its instructions, and tell the user what you started.";
|
|
416
|
+
}
|
|
417
|
+
return;
|
|
418
|
+
}
|
|
419
|
+
TaDelegateUtil2.refusal = refusal;
|
|
420
|
+
})(TaDelegateUtil || (TaDelegateUtil = {}));
|
|
421
|
+
|
|
422
|
+
// ../ta-protocol/esm/common/app-protocol.js
|
|
423
|
+
var FONT_SIZES = ["small", "standard", "large", "xlarge"];
|
|
424
|
+
var words = (en, zh, tw, ja) => ({ "en-US": en, "zh-CN": zh, "zh-TW": tw, "ja-JP": ja });
|
|
425
|
+
var SYSTEM = words("as the system", "跟随系统", "跟隨系統", "システムに合わせる");
|
|
426
|
+
var FONT_SHOWN = {
|
|
427
|
+
small: words("small", "小", "小", "小"),
|
|
428
|
+
standard: words("standard", "标准", "標準", "標準"),
|
|
429
|
+
large: words("large", "大", "大", "大"),
|
|
430
|
+
xlarge: words("extra large", "特大", "特大", "特大")
|
|
431
|
+
};
|
|
432
|
+
var TA_WEB_SETTINGS = [
|
|
433
|
+
{
|
|
434
|
+
key: "theme",
|
|
435
|
+
type: "enum",
|
|
436
|
+
values: ["system", "light", "dark"],
|
|
437
|
+
default: "system",
|
|
438
|
+
what: "Light or dark look; system follows the device.",
|
|
439
|
+
title: words("Theme", "外观", "外觀", "外観"),
|
|
440
|
+
shown: { system: SYSTEM, light: words("light", "浅色", "淺色", "ライト"), dark: words("dark", "深色", "深色", "ダーク") }
|
|
441
|
+
},
|
|
442
|
+
{
|
|
443
|
+
key: "language",
|
|
444
|
+
type: "enum",
|
|
445
|
+
values: ["system", ...TaLanguageUtil.ALL],
|
|
446
|
+
default: "system",
|
|
447
|
+
what: "The language of Ta's pages and of what Ta says; system follows the device.",
|
|
448
|
+
title: words("Language", "语言", "語言", "言語"),
|
|
449
|
+
shown: {
|
|
450
|
+
system: SYSTEM,
|
|
451
|
+
...Object.fromEntries(TaLanguageUtil.ALL.map((language) => [
|
|
452
|
+
language,
|
|
453
|
+
words(TaLanguageUtil.NAMES[language], TaLanguageUtil.NAMES[language], TaLanguageUtil.NAMES[language], TaLanguageUtil.NAMES[language])
|
|
454
|
+
]))
|
|
455
|
+
}
|
|
456
|
+
},
|
|
457
|
+
{
|
|
458
|
+
key: "fontSize",
|
|
459
|
+
type: "enum",
|
|
460
|
+
values: FONT_SIZES,
|
|
461
|
+
default: "standard",
|
|
462
|
+
what: "The size of the text of the whole page.",
|
|
463
|
+
title: words("Text size", "字体大小", "字型大小", "文字サイズ"),
|
|
464
|
+
shown: FONT_SHOWN
|
|
465
|
+
},
|
|
466
|
+
{
|
|
467
|
+
key: "chatFontSize",
|
|
468
|
+
type: "enum",
|
|
469
|
+
values: FONT_SIZES,
|
|
470
|
+
default: "standard",
|
|
471
|
+
what: "The size of the text of conversations, on top of fontSize.",
|
|
472
|
+
title: words("Text size of conversations", "对话字体大小", "對話字型大小", "会話の文字サイズ"),
|
|
473
|
+
shown: FONT_SHOWN
|
|
474
|
+
},
|
|
475
|
+
{
|
|
476
|
+
key: "speak",
|
|
477
|
+
type: "boolean",
|
|
478
|
+
default: false,
|
|
479
|
+
what: "Read every reply aloud.",
|
|
480
|
+
title: words("Read replies aloud", "朗读回复", "朗讀回覆", "返信を読み上げ")
|
|
481
|
+
},
|
|
482
|
+
{
|
|
483
|
+
key: "speakTalk",
|
|
484
|
+
type: "boolean",
|
|
485
|
+
default: false,
|
|
486
|
+
what: "Read the reply aloud when the user spoke to the double by voice.",
|
|
487
|
+
title: words("Read aloud what was asked by voice", "语音提问时朗读回复", "語音提問時朗讀回覆", "音声で聞いたら読み上げ")
|
|
488
|
+
},
|
|
489
|
+
{
|
|
490
|
+
key: "callCaptions",
|
|
491
|
+
type: "boolean",
|
|
492
|
+
default: false,
|
|
493
|
+
what: "Show captions in a call: what the user says and what Ta reads.",
|
|
494
|
+
title: words("Call captions", "通话字幕", "通話字幕", "通話の字幕")
|
|
495
|
+
},
|
|
496
|
+
{
|
|
497
|
+
key: "voice",
|
|
498
|
+
type: "string",
|
|
499
|
+
default: "",
|
|
500
|
+
what: "The voice replies are read with (a voiceURI of the device's voices); empty for the most natural one.",
|
|
501
|
+
title: words("Voice", "朗读声音", "朗讀聲音", "読み上げの声")
|
|
502
|
+
},
|
|
503
|
+
{
|
|
504
|
+
key: "confirmTasks",
|
|
505
|
+
type: "boolean",
|
|
506
|
+
default: false,
|
|
507
|
+
what: "The double asks before it hands out work.",
|
|
508
|
+
title: words("Ask before handing out work", "派任务前先问我", "派任務前先問我", "作業を割り当てる前に確認")
|
|
509
|
+
},
|
|
510
|
+
{
|
|
511
|
+
key: "maxTasks",
|
|
512
|
+
type: "number",
|
|
513
|
+
values: [0, 2, 4, 8],
|
|
514
|
+
default: 0,
|
|
515
|
+
what: "How many of the double's tasks run at once; 0 for as many as it starts.",
|
|
516
|
+
title: words("Tasks at once", "同时运行的任务", "同時執行的任務", "同時に実行するタスク")
|
|
517
|
+
},
|
|
518
|
+
{
|
|
519
|
+
key: "delegate",
|
|
520
|
+
type: "enum",
|
|
521
|
+
values: TaDelegateUtil.LEVELS,
|
|
522
|
+
default: TaDelegateUtil.DEFAULT,
|
|
523
|
+
what: "How much of the work the double hands out to tasks rather than doing it itself.",
|
|
524
|
+
title: words("Hand out work", "派活多少", "派活多少", "作業の割り当て"),
|
|
525
|
+
shown: { less: words("less", "少", "少", "少なめ"), balanced: words("balanced", "适中", "適中", "ふつう"), more: words("more", "多", "多", "多め") }
|
|
526
|
+
},
|
|
527
|
+
{
|
|
528
|
+
key: "assistantModel",
|
|
529
|
+
type: "model",
|
|
530
|
+
default: "",
|
|
531
|
+
what: "The model of the double, <provider>/<model id>; empty for the default model.",
|
|
532
|
+
title: words("Model of the double", "分身的模型", "分身的模型", "分身のモデル")
|
|
533
|
+
},
|
|
534
|
+
{
|
|
535
|
+
key: "taskModel",
|
|
536
|
+
type: "model",
|
|
537
|
+
default: "",
|
|
538
|
+
what: "The model of the tasks the double starts; empty for the default model.",
|
|
539
|
+
title: words("Model of tasks", "任务的模型", "任務的模型", "タスクのモデル")
|
|
540
|
+
},
|
|
541
|
+
{ key: "reduceMotion", type: "boolean", default: false, what: "Fewer animations.", title: words("Reduce motion", "减少动画", "減少動畫", "動きを減らす") },
|
|
542
|
+
{
|
|
543
|
+
key: "keepAliveMinutes",
|
|
544
|
+
type: "number",
|
|
545
|
+
values: [1, 5, 15, 30],
|
|
546
|
+
default: 5,
|
|
547
|
+
what: "How long an extension started on open keeps running once left, in minutes.",
|
|
548
|
+
title: words("Keep extensions running", "扩展离开后保留", "擴充功能離開後保留", "拡張機能を保持")
|
|
549
|
+
},
|
|
550
|
+
{
|
|
551
|
+
key: "chatFoldDays",
|
|
552
|
+
type: "number",
|
|
553
|
+
values: [3, 7, 30, 0],
|
|
554
|
+
default: 7,
|
|
555
|
+
what: "Conversations not updated for these days fold at the end of the list; 0 for none.",
|
|
556
|
+
title: words("Fold old conversations", "折叠旧对话", "摺疊舊對話", "古い会話を折りたたむ")
|
|
557
|
+
},
|
|
558
|
+
{
|
|
559
|
+
key: "chatArchiveDays",
|
|
560
|
+
type: "number",
|
|
561
|
+
values: [30, 90, 365, 0],
|
|
562
|
+
default: 30,
|
|
563
|
+
what: "Conversations not updated for these days are archived (out of the list, found by search); 0 for none.",
|
|
564
|
+
title: words("Archive old conversations", "归档旧对话", "歸檔舊對話", "古い会話をアーカイブ")
|
|
565
|
+
},
|
|
566
|
+
{
|
|
567
|
+
key: "recentShots",
|
|
568
|
+
type: "boolean",
|
|
569
|
+
default: true,
|
|
570
|
+
what: "The screenshot just taken is offered above the message box, once.",
|
|
571
|
+
title: words("Offer recent screenshots", "提示刚截的图", "提示剛截的圖", "撮ったばかりのスクリーンショットを提案")
|
|
572
|
+
}
|
|
573
|
+
];
|
|
574
|
+
var TaAppUtil;
|
|
575
|
+
(function(TaAppUtil2) {
|
|
576
|
+
function check(spec, value) {
|
|
577
|
+
var _a, _b;
|
|
578
|
+
switch (spec.type) {
|
|
579
|
+
case "boolean":
|
|
580
|
+
return typeof value === "boolean" ? undefined : "true or false";
|
|
581
|
+
case "string":
|
|
582
|
+
return typeof value === "string" ? undefined : "a string";
|
|
583
|
+
case "model":
|
|
584
|
+
return value === "" || typeof value === "string" && /^[^/\s]+\/\S+$/.test(value) ? undefined : "<provider>/<model id>, or empty";
|
|
585
|
+
default:
|
|
586
|
+
return ((_a = spec.values) === null || _a === undefined ? undefined : _a.includes(value)) ? undefined : `one of ${(_b = spec.values) === null || _b === undefined ? undefined : _b.map((one) => JSON.stringify(one)).join(", ")}`;
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
TaAppUtil2.check = check;
|
|
590
|
+
function shown(value, language, spec) {
|
|
591
|
+
var _a;
|
|
592
|
+
const named = (_a = spec === null || spec === undefined ? undefined : spec.shown) === null || _a === undefined ? undefined : _a[String(value)];
|
|
593
|
+
if (named) {
|
|
594
|
+
return TaLanguageUtil.pick(language, named);
|
|
595
|
+
}
|
|
596
|
+
if (typeof value === "boolean") {
|
|
597
|
+
return TaLanguageUtil.pick(language, value ? words("on", "开", "開", "オン") : words("off", "关", "關", "オフ"));
|
|
598
|
+
}
|
|
599
|
+
if (value === "" || value === undefined || value === null) {
|
|
600
|
+
return TaLanguageUtil.pick(language, words("default", "默认", "預設", "デフォルト"));
|
|
601
|
+
}
|
|
602
|
+
return String(value);
|
|
603
|
+
}
|
|
604
|
+
TaAppUtil2.shown = shown;
|
|
605
|
+
})(TaAppUtil || (TaAppUtil = {}));
|
|
282
606
|
// ../ta-protocol/esm/common/auth-protocol.js
|
|
283
607
|
var TaAuthServer = Symbol("TaAuthServer");
|
|
608
|
+
// ../ta-protocol/esm/common/deployment-protocol.js
|
|
609
|
+
var TA_WELL_KNOWN_PATH = "/.well-known/ta";
|
|
610
|
+
|
|
611
|
+
class TaDeploymentError extends Error {
|
|
612
|
+
}
|
|
613
|
+
var TaDeploymentUtil;
|
|
614
|
+
(function(TaDeploymentUtil2) {
|
|
615
|
+
TaDeploymentUtil2.DISTRIBUTION_FILE = "distribution.json";
|
|
616
|
+
function url(value) {
|
|
617
|
+
if (typeof value !== "string" || !value.trim()) {
|
|
618
|
+
return;
|
|
619
|
+
}
|
|
620
|
+
try {
|
|
621
|
+
const parsed = new URL(value.trim());
|
|
622
|
+
if (!/^https?:$/.test(parsed.protocol) || parsed.search || parsed.hash || parsed.username || parsed.password) {
|
|
623
|
+
return;
|
|
624
|
+
}
|
|
625
|
+
return `${parsed.origin}${parsed.pathname}`.replace(/\/+$/, "");
|
|
626
|
+
} catch (_a) {
|
|
627
|
+
return;
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
TaDeploymentUtil2.url = url;
|
|
631
|
+
function name(value) {
|
|
632
|
+
return typeof value === "string" && value.trim() ? value.trim().slice(0, 80) : undefined;
|
|
633
|
+
}
|
|
634
|
+
function describe(env, own, version) {
|
|
635
|
+
var _a, _b;
|
|
636
|
+
const gateway = (_a = url(own.gateway)) !== null && _a !== undefined ? _a : url(env.TA_GATEWAY_URL);
|
|
637
|
+
const relay = (_b = url(own.relay)) !== null && _b !== undefined ? _b : url(env.TA_RELAY_URL);
|
|
638
|
+
const called = name(env.TA_DEPLOYMENT_NAME);
|
|
639
|
+
return { v: 1, ...called ? { name: called } : {}, ...gateway ? { gateway } : {}, ...relay ? { relay } : {}, ...version ? { version } : {} };
|
|
640
|
+
}
|
|
641
|
+
TaDeploymentUtil2.describe = describe;
|
|
642
|
+
TaDeploymentUtil2.HEADERS = {
|
|
643
|
+
"content-type": "application/json",
|
|
644
|
+
"access-control-allow-origin": "*",
|
|
645
|
+
"cache-control": "no-store"
|
|
646
|
+
};
|
|
647
|
+
function parse(value) {
|
|
648
|
+
const given = value;
|
|
649
|
+
if (!given || typeof given !== "object" || given.v !== 1) {
|
|
650
|
+
return;
|
|
651
|
+
}
|
|
652
|
+
const deployment = describe({ TA_DEPLOYMENT_NAME: given.name, TA_GATEWAY_URL: given.gateway, TA_RELAY_URL: given.relay }, {});
|
|
653
|
+
const version = name(given.version);
|
|
654
|
+
return version ? { ...deployment, version } : deployment;
|
|
655
|
+
}
|
|
656
|
+
TaDeploymentUtil2.parse = parse;
|
|
657
|
+
async function discover(address, timeoutMs = 6000) {
|
|
658
|
+
const base = url(address);
|
|
659
|
+
if (!base) {
|
|
660
|
+
throw new TaDeploymentError(`${address} is not an address of http or https.`);
|
|
661
|
+
}
|
|
662
|
+
const controller = new AbortController;
|
|
663
|
+
const timer = setTimeout(() => controller.abort(), timeoutMs);
|
|
664
|
+
try {
|
|
665
|
+
const response = await fetch(`${base}${TA_WELL_KNOWN_PATH}`, { signal: controller.signal, redirect: "follow" });
|
|
666
|
+
if (!response.ok) {
|
|
667
|
+
throw new TaDeploymentError(`${base} is not a deployment of Ta (${response.status}).`);
|
|
668
|
+
}
|
|
669
|
+
const deployment = parse(await response.json().catch(() => {
|
|
670
|
+
return;
|
|
671
|
+
}));
|
|
672
|
+
if (!deployment || !deployment.gateway && !deployment.relay) {
|
|
673
|
+
throw new TaDeploymentError(`${base} is not a deployment of Ta.`);
|
|
674
|
+
}
|
|
675
|
+
return deployment;
|
|
676
|
+
} catch (error) {
|
|
677
|
+
if ((error === null || error === undefined ? undefined : error.name) === "AbortError") {
|
|
678
|
+
throw new TaDeploymentError(`${base} did not answer in time.`);
|
|
679
|
+
}
|
|
680
|
+
throw error;
|
|
681
|
+
} finally {
|
|
682
|
+
clearTimeout(timer);
|
|
683
|
+
}
|
|
684
|
+
}
|
|
685
|
+
TaDeploymentUtil2.discover = discover;
|
|
686
|
+
function distribution(value) {
|
|
687
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
688
|
+
throw new TaDeploymentError(`${TaDeploymentUtil2.DISTRIBUTION_FILE} holds a JSON object.`);
|
|
689
|
+
}
|
|
690
|
+
const given = value;
|
|
691
|
+
const result = {};
|
|
692
|
+
if (given.name !== undefined) {
|
|
693
|
+
result.name = name(given.name);
|
|
694
|
+
}
|
|
695
|
+
for (const key of ["relay", "gateway"]) {
|
|
696
|
+
if (given[key] !== undefined) {
|
|
697
|
+
const address = url(given[key]);
|
|
698
|
+
if (!address) {
|
|
699
|
+
throw new TaDeploymentError(`"${key}" of ${TaDeploymentUtil2.DISTRIBUTION_FILE} is not an address of http or https.`);
|
|
700
|
+
}
|
|
701
|
+
result[key] = address;
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
if (given.updates !== undefined) {
|
|
705
|
+
const updates = given.updates;
|
|
706
|
+
const base = url(updates === null || updates === undefined ? undefined : updates.base);
|
|
707
|
+
if (!base && (updates === null || updates === undefined ? undefined : updates.base) !== undefined) {
|
|
708
|
+
throw new TaDeploymentError(`"updates.base" of ${TaDeploymentUtil2.DISTRIBUTION_FILE} is not an address of http or https.`);
|
|
709
|
+
}
|
|
710
|
+
const key = typeof (updates === null || updates === undefined ? undefined : updates.key) === "string" && updates.key.includes("PUBLIC KEY") ? updates.key : undefined;
|
|
711
|
+
if ((updates === null || updates === undefined ? undefined : updates.key) !== undefined && !key) {
|
|
712
|
+
throw new TaDeploymentError(`"updates.key" of ${TaDeploymentUtil2.DISTRIBUTION_FILE} is a public key in PEM.`);
|
|
713
|
+
}
|
|
714
|
+
result.updates = { ...base ? { base } : {}, ...key ? { key } : {} };
|
|
715
|
+
}
|
|
716
|
+
return result;
|
|
717
|
+
}
|
|
718
|
+
TaDeploymentUtil2.distribution = distribution;
|
|
719
|
+
function apply(distribution2, env) {
|
|
720
|
+
const defaults = { TA_DEPLOYMENT_NAME: distribution2.name, TA_RELAY_URL: distribution2.relay, TA_GATEWAY_URL: distribution2.gateway };
|
|
721
|
+
for (const [key, value] of Object.entries(defaults)) {
|
|
722
|
+
if (value && !env[key]) {
|
|
723
|
+
env[key] = value;
|
|
724
|
+
}
|
|
725
|
+
}
|
|
726
|
+
}
|
|
727
|
+
TaDeploymentUtil2.apply = apply;
|
|
728
|
+
})(TaDeploymentUtil || (TaDeploymentUtil = {}));
|
|
729
|
+
// ../ta-protocol/esm/common/error-protocol.js
|
|
730
|
+
var TaErrorUtil;
|
|
731
|
+
(function(TaErrorUtil2) {
|
|
732
|
+
function code(error) {
|
|
733
|
+
var _a;
|
|
734
|
+
var _b;
|
|
735
|
+
const failure = error;
|
|
736
|
+
const code2 = (_b = failure === null || failure === undefined ? undefined : failure.code) !== null && _b !== undefined ? _b : (_a = failure === null || failure === undefined ? undefined : failure.data) === null || _a === undefined ? undefined : _a.code;
|
|
737
|
+
return typeof code2 === "string" ? code2 : undefined;
|
|
738
|
+
}
|
|
739
|
+
TaErrorUtil2.code = code;
|
|
740
|
+
})(TaErrorUtil || (TaErrorUtil = {}));
|
|
284
741
|
// ../ta-protocol/esm/common/gateway-protocol.js
|
|
285
742
|
var TaGatewayServer = Symbol("TaGatewayServer");
|
|
286
743
|
// ../ta-protocol/esm/common/location.js
|
|
287
744
|
var TaLocation;
|
|
288
745
|
(function(TaLocation2) {
|
|
289
746
|
TaLocation2.SSH = "ssh://";
|
|
747
|
+
TaLocation2.CLOUD = "ta://";
|
|
748
|
+
const CLOUD_NAME = /^[a-z0-9][a-z0-9-]{0,39}$/;
|
|
290
749
|
const HOST = /^(?!-)[\w.@:%+[\]-]+$/;
|
|
291
750
|
function isRemote(location) {
|
|
292
|
-
return location.startsWith(TaLocation2.SSH);
|
|
751
|
+
return location.startsWith(TaLocation2.SSH) || location.startsWith(TaLocation2.CLOUD);
|
|
293
752
|
}
|
|
294
753
|
TaLocation2.isRemote = isRemote;
|
|
754
|
+
function isCloud(host2) {
|
|
755
|
+
return !!host2 && host2.startsWith(TaLocation2.CLOUD);
|
|
756
|
+
}
|
|
757
|
+
TaLocation2.isCloud = isCloud;
|
|
758
|
+
function isCloudName(name) {
|
|
759
|
+
return CLOUD_NAME.test(name);
|
|
760
|
+
}
|
|
761
|
+
TaLocation2.isCloudName = isCloudName;
|
|
762
|
+
function cloud(name, path2 = "") {
|
|
763
|
+
return `${TaLocation2.CLOUD}${name}${path2 ? normalize(path2) : ""}`;
|
|
764
|
+
}
|
|
765
|
+
TaLocation2.cloud = cloud;
|
|
766
|
+
function cloudName(hostOrLocation) {
|
|
767
|
+
if (!hostOrLocation.startsWith(TaLocation2.CLOUD)) {
|
|
768
|
+
return;
|
|
769
|
+
}
|
|
770
|
+
const rest = hostOrLocation.slice(TaLocation2.CLOUD.length);
|
|
771
|
+
const slash = rest.indexOf("/");
|
|
772
|
+
return slash < 0 ? rest : rest.slice(0, slash);
|
|
773
|
+
}
|
|
774
|
+
TaLocation2.cloudName = cloudName;
|
|
295
775
|
function parse(location) {
|
|
776
|
+
var _a;
|
|
296
777
|
if (!isRemote(location)) {
|
|
297
778
|
return;
|
|
298
779
|
}
|
|
780
|
+
if (location.startsWith(TaLocation2.CLOUD)) {
|
|
781
|
+
const name = (_a = cloudName(location)) !== null && _a !== undefined ? _a : "";
|
|
782
|
+
if (!isCloudName(name)) {
|
|
783
|
+
throw new Error(`${JSON.stringify(location)} names no cloud workspace: write ta://<name>/<path>.`);
|
|
784
|
+
}
|
|
785
|
+
const path3 = location.slice(TaLocation2.CLOUD.length + name.length);
|
|
786
|
+
return { host: `${TaLocation2.CLOUD}${name}`, path: path3 ? normalize(path3) : "" };
|
|
787
|
+
}
|
|
299
788
|
const rest = location.slice(TaLocation2.SSH.length);
|
|
300
789
|
const slash = rest.indexOf("/");
|
|
301
790
|
const host2 = slash < 0 ? rest : rest.slice(0, slash);
|
|
@@ -307,24 +796,24 @@ var TaLocation;
|
|
|
307
796
|
}
|
|
308
797
|
TaLocation2.parse = parse;
|
|
309
798
|
function isHost(host2) {
|
|
310
|
-
return HOST.test(host2);
|
|
799
|
+
return isCloud(host2) ? isCloudName(host2.slice(TaLocation2.CLOUD.length)) : HOST.test(host2);
|
|
311
800
|
}
|
|
312
801
|
TaLocation2.isHost = isHost;
|
|
313
802
|
const FLAGS = /^-[46AaCfGgKkMNnqsTtVvXxYy]+$/;
|
|
314
803
|
function readHost(input) {
|
|
315
|
-
const
|
|
316
|
-
if (
|
|
317
|
-
|
|
804
|
+
const words2 = input.trim().split(/\s+/).filter(Boolean);
|
|
805
|
+
if (words2[0] === "ssh") {
|
|
806
|
+
words2.shift();
|
|
318
807
|
}
|
|
319
808
|
let destination;
|
|
320
809
|
let port;
|
|
321
810
|
let user;
|
|
322
811
|
const options = [];
|
|
323
|
-
for (let i = 0;i <
|
|
324
|
-
const word =
|
|
812
|
+
for (let i = 0;i < words2.length; i++) {
|
|
813
|
+
const word = words2[i];
|
|
325
814
|
const glued = /^-([pl])(.+)$/.exec(word);
|
|
326
815
|
if (word === "-p" || word === "-l" || glued) {
|
|
327
|
-
const value = glued ? glued[2] :
|
|
816
|
+
const value = glued ? glued[2] : words2[++i];
|
|
328
817
|
if (value === undefined) {
|
|
329
818
|
return { error: "invalid" };
|
|
330
819
|
}
|
|
@@ -334,7 +823,7 @@ var TaLocation;
|
|
|
334
823
|
user = value;
|
|
335
824
|
}
|
|
336
825
|
} else if (word === "-o" || word.startsWith("-o")) {
|
|
337
|
-
const value = word === "-o" ?
|
|
826
|
+
const value = word === "-o" ? words2[++i] : word.slice(2);
|
|
338
827
|
const option = /^(port|user)\s*=?\s*(.+)$/i.exec(value !== null && value !== undefined ? value : "");
|
|
339
828
|
if (!option) {
|
|
340
829
|
options.push(`-o ${value !== null && value !== undefined ? value : ""}`.trim());
|
|
@@ -344,7 +833,7 @@ var TaLocation;
|
|
|
344
833
|
user = option[2];
|
|
345
834
|
}
|
|
346
835
|
} else if (FLAGS.test(word)) {} else if (word.startsWith("-")) {
|
|
347
|
-
options.push(/^-[bBcDeEFiIJLmOQRSwW]$/.test(word) &&
|
|
836
|
+
options.push(/^-[bBcDeEFiIJLmOQRSwW]$/.test(word) && words2[i + 1] !== undefined ? `${word} ${words2[++i]}` : word);
|
|
348
837
|
} else if (destination === undefined) {
|
|
349
838
|
destination = word;
|
|
350
839
|
} else {
|
|
@@ -371,10 +860,13 @@ var TaLocation;
|
|
|
371
860
|
}
|
|
372
861
|
TaLocation2.readHost = readHost;
|
|
373
862
|
function ssh(host2, path2 = "") {
|
|
374
|
-
return `${TaLocation2.SSH}${host2}${path2 ? normalize(path2) : ""}`;
|
|
863
|
+
return isCloud(host2) ? `${host2}${path2 ? normalize(path2) : ""}` : `${TaLocation2.SSH}${host2}${path2 ? normalize(path2) : ""}`;
|
|
375
864
|
}
|
|
376
865
|
TaLocation2.ssh = ssh;
|
|
377
866
|
function hostLabel(host2) {
|
|
867
|
+
if (isCloud(host2)) {
|
|
868
|
+
return host2.slice(TaLocation2.CLOUD.length);
|
|
869
|
+
}
|
|
378
870
|
const name = host2.replace(/^[^@]*@/, "").replace(/^\[(.*)\](?::\d+)?$/, "$1").replace(/^([^:]*):\d+$/, "$1");
|
|
379
871
|
return /^[\d.]+$/.test(name) || name.includes(":") ? name : name.split(".")[0] || name;
|
|
380
872
|
}
|
|
@@ -447,44 +939,7 @@ var TaLocation;
|
|
|
447
939
|
return squeezed.length > 1 ? squeezed.replace(/\/$/, "") : squeezed;
|
|
448
940
|
}
|
|
449
941
|
})(TaLocation || (TaLocation = {}));
|
|
450
|
-
// ../ta-protocol/esm/common/
|
|
451
|
-
var TaPackageServer = Symbol("TaPackageServer");
|
|
452
|
-
var TaPackageTextUtil;
|
|
453
|
-
(function(TaPackageTextUtil2) {
|
|
454
|
-
function pick(text, language) {
|
|
455
|
-
var _a, _b, _c, _d, _e;
|
|
456
|
-
if (text === undefined || typeof text === "string") {
|
|
457
|
-
return text;
|
|
458
|
-
}
|
|
459
|
-
const base = language.split("-")[0];
|
|
460
|
-
const kin = Object.keys(text).find((key) => key.split("-")[0] === base);
|
|
461
|
-
return (_e = (_d = (_c = (_b = (_a = text[language]) !== null && _a !== undefined ? _a : text[base]) !== null && _b !== undefined ? _b : kin === undefined ? undefined : text[kin]) !== null && _c !== undefined ? _c : text.en) !== null && _d !== undefined ? _d : text["en-US"]) !== null && _e !== undefined ? _e : Object.values(text)[0];
|
|
462
|
-
}
|
|
463
|
-
TaPackageTextUtil2.pick = pick;
|
|
464
|
-
})(TaPackageTextUtil || (TaPackageTextUtil = {}));
|
|
465
|
-
// ../ta-protocol/esm/common/ta-protocol.js
|
|
466
|
-
var TaServer = Symbol("TaServer");
|
|
467
|
-
var TaClient = Symbol("TaClient");
|
|
468
|
-
var TaErrorUtil;
|
|
469
|
-
(function(TaErrorUtil2) {
|
|
470
|
-
function code(error) {
|
|
471
|
-
var _a;
|
|
472
|
-
var _b;
|
|
473
|
-
const failure = error;
|
|
474
|
-
const code2 = (_b = failure === null || failure === undefined ? undefined : failure.code) !== null && _b !== undefined ? _b : (_a = failure === null || failure === undefined ? undefined : failure.data) === null || _a === undefined ? undefined : _a.code;
|
|
475
|
-
return typeof code2 === "string" ? code2 : undefined;
|
|
476
|
-
}
|
|
477
|
-
TaErrorUtil2.code = code;
|
|
478
|
-
})(TaErrorUtil || (TaErrorUtil = {}));
|
|
479
|
-
var TaSlashCommandUtil;
|
|
480
|
-
(function(TaSlashCommandUtil2) {
|
|
481
|
-
function description(command, language) {
|
|
482
|
-
var _a, _b;
|
|
483
|
-
const { descriptions } = command;
|
|
484
|
-
return (_b = (_a = descriptions === null || descriptions === undefined ? undefined : descriptions[language]) !== null && _a !== undefined ? _a : descriptions === null || descriptions === undefined ? undefined : descriptions[language.split("-")[0]]) !== null && _b !== undefined ? _b : command.description;
|
|
485
|
-
}
|
|
486
|
-
TaSlashCommandUtil2.description = description;
|
|
487
|
-
})(TaSlashCommandUtil || (TaSlashCommandUtil = {}));
|
|
942
|
+
// ../ta-protocol/esm/common/message-protocol.js
|
|
488
943
|
var TaMessageContext;
|
|
489
944
|
(function(TaMessageContext2) {
|
|
490
945
|
const BLOCK = /^<context>\n?[\s\S]*?\n?<\/context>\n?/;
|
|
@@ -647,7 +1102,168 @@ var TaSkillUse;
|
|
|
647
1102
|
}
|
|
648
1103
|
TaSkillUse2.command = command;
|
|
649
1104
|
})(TaSkillUse || (TaSkillUse = {}));
|
|
650
|
-
|
|
1105
|
+
var TaTaskNote;
|
|
1106
|
+
(function(TaTaskNote2) {
|
|
1107
|
+
const NOTE = /^<task_(update|adopted|renamed) ((?:[^>"\n]|"[^"]*")*)>\n?([\s\S]*?)\n?<\/task_\1>$/;
|
|
1108
|
+
const ATTRIBUTE = /(\w+)="([^"]*)"/g;
|
|
1109
|
+
function write(note) {
|
|
1110
|
+
const attributes = [`id="${quote(note.id)}"`];
|
|
1111
|
+
if (note.was !== undefined) {
|
|
1112
|
+
attributes.push(`was="${quote(note.was)}"`);
|
|
1113
|
+
}
|
|
1114
|
+
attributes.push(`title="${quote(note.title)}"`);
|
|
1115
|
+
if (note.status !== undefined) {
|
|
1116
|
+
attributes.push(`status="${quote(note.status)}"`);
|
|
1117
|
+
}
|
|
1118
|
+
return `<task_${note.kind} ${attributes.join(" ")}>
|
|
1119
|
+
${note.body}
|
|
1120
|
+
</task_${note.kind}>`;
|
|
1121
|
+
}
|
|
1122
|
+
TaTaskNote2.write = write;
|
|
1123
|
+
function parse(text) {
|
|
1124
|
+
const match = NOTE.exec(text.trim());
|
|
1125
|
+
if (!match) {
|
|
1126
|
+
return;
|
|
1127
|
+
}
|
|
1128
|
+
const attributes = {};
|
|
1129
|
+
for (const [, name, value] of match[2].matchAll(ATTRIBUTE)) {
|
|
1130
|
+
attributes[name] = unquote(value);
|
|
1131
|
+
}
|
|
1132
|
+
if (!attributes.id || attributes.title === undefined) {
|
|
1133
|
+
return;
|
|
1134
|
+
}
|
|
1135
|
+
const { id, title, status, was } = attributes;
|
|
1136
|
+
return { kind: match[1], id, title, ...status ? { status } : {}, ...was ? { was } : {}, body: match[3] };
|
|
1137
|
+
}
|
|
1138
|
+
TaTaskNote2.parse = parse;
|
|
1139
|
+
function quote(text) {
|
|
1140
|
+
return text.replace(/&/g, "&").replace(/"/g, """).replace(/\n/g, " ");
|
|
1141
|
+
}
|
|
1142
|
+
function unquote(text) {
|
|
1143
|
+
return text.replace(/"/g, '"').replace(/&/g, "&");
|
|
1144
|
+
}
|
|
1145
|
+
})(TaTaskNote || (TaTaskNote = {}));
|
|
1146
|
+
// ../ta-protocol/esm/common/package-protocol.js
|
|
1147
|
+
var TaPackageServer = Symbol("TaPackageServer");
|
|
1148
|
+
var TaPackageTextUtil;
|
|
1149
|
+
(function(TaPackageTextUtil2) {
|
|
1150
|
+
function pick(text, language) {
|
|
1151
|
+
var _a, _b, _c, _d, _e;
|
|
1152
|
+
if (text === undefined || typeof text === "string") {
|
|
1153
|
+
return text;
|
|
1154
|
+
}
|
|
1155
|
+
const base = language.split("-")[0];
|
|
1156
|
+
const kin = Object.keys(text).find((key) => key.split("-")[0] === base);
|
|
1157
|
+
return (_e = (_d = (_c = (_b = (_a = text[language]) !== null && _a !== undefined ? _a : text[base]) !== null && _b !== undefined ? _b : kin === undefined ? undefined : text[kin]) !== null && _c !== undefined ? _c : text.en) !== null && _d !== undefined ? _d : text["en-US"]) !== null && _e !== undefined ? _e : Object.values(text)[0];
|
|
1158
|
+
}
|
|
1159
|
+
TaPackageTextUtil2.pick = pick;
|
|
1160
|
+
})(TaPackageTextUtil || (TaPackageTextUtil = {}));
|
|
1161
|
+
// ../ta-protocol/esm/common/page-protocol.js
|
|
1162
|
+
var TaPageServer = Symbol("TaPageServer");
|
|
1163
|
+
// ../ta-protocol/esm/common/path-map.js
|
|
1164
|
+
var TaPathMap;
|
|
1165
|
+
(function(TaPathMap2) {
|
|
1166
|
+
function isWindows(path2) {
|
|
1167
|
+
return /^[a-zA-Z]:([\\/]|$)/.test(path2) || /^\\\\[^\\]/.test(path2);
|
|
1168
|
+
}
|
|
1169
|
+
TaPathMap2.isWindows = isWindows;
|
|
1170
|
+
function rest(path2, base) {
|
|
1171
|
+
const windows = isWindows(base);
|
|
1172
|
+
if (windows ? !isWindows(path2) : !base.startsWith("/") || !path2.startsWith("/")) {
|
|
1173
|
+
return;
|
|
1174
|
+
}
|
|
1175
|
+
const within = parts(base, windows);
|
|
1176
|
+
const all = parts(path2, windows);
|
|
1177
|
+
if (!within.length || all.length < within.length) {
|
|
1178
|
+
return;
|
|
1179
|
+
}
|
|
1180
|
+
const same = (a, b) => windows ? a.toLowerCase() === b.toLowerCase() : a === b;
|
|
1181
|
+
return within.every((part, i) => same(part, all[i])) ? all.slice(within.length) : undefined;
|
|
1182
|
+
}
|
|
1183
|
+
TaPathMap2.rest = rest;
|
|
1184
|
+
function under(path2, base) {
|
|
1185
|
+
return rest(path2, base) !== undefined;
|
|
1186
|
+
}
|
|
1187
|
+
TaPathMap2.under = under;
|
|
1188
|
+
function join2(base, parts2) {
|
|
1189
|
+
if (!parts2.length) {
|
|
1190
|
+
return base;
|
|
1191
|
+
}
|
|
1192
|
+
const sep = isWindows(base) ? "\\" : "/";
|
|
1193
|
+
return `${base.replace(/[\\/]+$/, "")}${sep}${parts2.join(sep)}`;
|
|
1194
|
+
}
|
|
1195
|
+
TaPathMap2.join = join2;
|
|
1196
|
+
function basename(path2) {
|
|
1197
|
+
var _a;
|
|
1198
|
+
return (_a = path2.split(/[\\/]+/).filter(Boolean).pop()) !== null && _a !== undefined ? _a : "";
|
|
1199
|
+
}
|
|
1200
|
+
TaPathMap2.basename = basename;
|
|
1201
|
+
function path(value, pairs) {
|
|
1202
|
+
for (const [from, to] of deepest(pairs)) {
|
|
1203
|
+
const found = rest(value, from);
|
|
1204
|
+
if (found) {
|
|
1205
|
+
return join2(to, found);
|
|
1206
|
+
}
|
|
1207
|
+
}
|
|
1208
|
+
return value;
|
|
1209
|
+
}
|
|
1210
|
+
TaPathMap2.path = path;
|
|
1211
|
+
function text(value, pairs) {
|
|
1212
|
+
const order = deepest(pairs);
|
|
1213
|
+
if (!order.length) {
|
|
1214
|
+
return value;
|
|
1215
|
+
}
|
|
1216
|
+
const end = String.raw`\s"'<>|*?:;,`;
|
|
1217
|
+
const pattern = new RegExp(String.raw`(^|[^\w.~-])(?:${order.map(([from]) => `(${source(from)})`).join("|")})((?:[\\/][^\\/${end}]*)*)(?=$|[\\/${end})\]}])`, "g");
|
|
1218
|
+
return value.replace(pattern, (...match) => {
|
|
1219
|
+
var _a;
|
|
1220
|
+
const before = match[1];
|
|
1221
|
+
const found = order.findIndex((_, i) => match[i + 2] !== undefined);
|
|
1222
|
+
const tail = (_a = match[order.length + 2]) !== null && _a !== undefined ? _a : "";
|
|
1223
|
+
return `${before}${join2(order[found][1], tail.split(/[\\/]+/).filter(Boolean))}`;
|
|
1224
|
+
});
|
|
1225
|
+
}
|
|
1226
|
+
TaPathMap2.text = text;
|
|
1227
|
+
function json(value, pairs) {
|
|
1228
|
+
const order = deepest(pairs);
|
|
1229
|
+
if (!order.length) {
|
|
1230
|
+
return value;
|
|
1231
|
+
}
|
|
1232
|
+
const one = (each) => {
|
|
1233
|
+
const whole = path(each, order);
|
|
1234
|
+
return whole !== each ? whole : text(each, order);
|
|
1235
|
+
};
|
|
1236
|
+
const walk = (each) => {
|
|
1237
|
+
if (typeof each === "string") {
|
|
1238
|
+
return one(each);
|
|
1239
|
+
}
|
|
1240
|
+
if (Array.isArray(each)) {
|
|
1241
|
+
return each.map(walk);
|
|
1242
|
+
}
|
|
1243
|
+
if (each && typeof each === "object") {
|
|
1244
|
+
return Object.fromEntries(Object.entries(each).map(([key, inner]) => [one(key), walk(inner)]));
|
|
1245
|
+
}
|
|
1246
|
+
return each;
|
|
1247
|
+
};
|
|
1248
|
+
return walk(value);
|
|
1249
|
+
}
|
|
1250
|
+
TaPathMap2.json = json;
|
|
1251
|
+
function parts(path2, windows) {
|
|
1252
|
+
return path2.split(windows ? /[\\/]+/ : /\/+/).filter(Boolean);
|
|
1253
|
+
}
|
|
1254
|
+
function deepest(pairs) {
|
|
1255
|
+
return pairs.filter(([from, to]) => from && to && from !== to && parts(from, isWindows(from)).length > 0).sort(([a], [b]) => parts(b, isWindows(b)).length - parts(a, isWindows(a)).length);
|
|
1256
|
+
}
|
|
1257
|
+
function source(base) {
|
|
1258
|
+
const windows = isWindows(base);
|
|
1259
|
+
const quote = (part) => [...part].map((char) => windows && char.toLowerCase() !== char.toUpperCase() ? `[${char.toLowerCase()}${char.toUpperCase()}]` : char.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("");
|
|
1260
|
+
const each = parts(base, windows).map(quote);
|
|
1261
|
+
if (!windows) {
|
|
1262
|
+
return `/${each.join("/+")}`;
|
|
1263
|
+
}
|
|
1264
|
+
return `${base.startsWith("\\\\") ? String.raw`\\\\` : ""}${each.join(String.raw`[\\/]+`)}`;
|
|
1265
|
+
}
|
|
1266
|
+
})(TaPathMap || (TaPathMap = {}));
|
|
651
1267
|
// ../ta-protocol/esm/common/presence-protocol.js
|
|
652
1268
|
var TaPresenceServer = Symbol("TaPresenceServer");
|
|
653
1269
|
var TaMessageAuthor;
|
|
@@ -725,99 +1341,18 @@ var TaRoomWatchUtil;
|
|
|
725
1341
|
})(TaRoomWatchUtil || (TaRoomWatchUtil = {}));
|
|
726
1342
|
// ../ta-protocol/esm/common/settings-protocol.js
|
|
727
1343
|
var TaSettingsServer = Symbol("TaSettingsServer");
|
|
728
|
-
// ../ta-protocol/esm/common/ta-
|
|
729
|
-
var
|
|
730
|
-
var
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
function
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
const timer = setTimeout(() => resolve(undefined), waitMs);
|
|
738
|
-
const request = {
|
|
739
|
-
name,
|
|
740
|
-
heard: () => {
|
|
741
|
-
heard = true;
|
|
742
|
-
},
|
|
743
|
-
resolve: (answer) => {
|
|
744
|
-
answered = true;
|
|
745
|
-
clearTimeout(timer);
|
|
746
|
-
resolve(answer);
|
|
747
|
-
}
|
|
748
|
-
};
|
|
749
|
-
events.emit(TA_HOST_EVENT, request);
|
|
750
|
-
if (!heard && !answered) {
|
|
751
|
-
clearTimeout(timer);
|
|
752
|
-
resolve(undefined);
|
|
753
|
-
}
|
|
754
|
-
});
|
|
755
|
-
}
|
|
756
|
-
TaHostUtil2.reach = reach;
|
|
757
|
-
function marked(systemPrompt, mark) {
|
|
758
|
-
return role(systemPrompt).includes(mark);
|
|
759
|
-
}
|
|
760
|
-
TaHostUtil2.marked = marked;
|
|
761
|
-
function role(systemPrompt) {
|
|
762
|
-
if (!systemPrompt) {
|
|
763
|
-
return "";
|
|
764
|
-
}
|
|
765
|
-
const open = `<addendum>
|
|
766
|
-
`;
|
|
767
|
-
const start = systemPrompt.indexOf(open);
|
|
768
|
-
const context = systemPrompt.indexOf(`<project_context>
|
|
769
|
-
`);
|
|
770
|
-
if (start < 0 || context >= 0 && context < start) {
|
|
771
|
-
return "";
|
|
772
|
-
}
|
|
773
|
-
const end = systemPrompt.indexOf(`
|
|
774
|
-
</addendum>`, start);
|
|
775
|
-
return systemPrompt.slice(start + open.length, end < 0 ? undefined : end);
|
|
776
|
-
}
|
|
777
|
-
TaHostUtil2.role = role;
|
|
778
|
-
})(TaHostUtil || (TaHostUtil = {}));
|
|
779
|
-
var TA_DOUBLE_FILE = { name: "@celljs/ta-web", key: "assistant.file" };
|
|
780
|
-
var TA_ASK_ENTRY = "ta-ask";
|
|
781
|
-
var TaAskUtil;
|
|
782
|
-
(function(TaAskUtil2) {
|
|
783
|
-
const LENGTH = 120;
|
|
784
|
-
function entry(question) {
|
|
785
|
-
const line = question.replace(/\s+/g, " ").trim();
|
|
786
|
-
return { question: line.length > LENGTH ? `${line.slice(0, LENGTH - 1)}…` : line };
|
|
787
|
-
}
|
|
788
|
-
TaAskUtil2.entry = entry;
|
|
789
|
-
function asking(entries) {
|
|
790
|
-
var _a;
|
|
791
|
-
for (let i = entries.length - 1;i >= 0; i--) {
|
|
792
|
-
const entry2 = entries[i];
|
|
793
|
-
if (entry2.type === "message" && ((_a = entry2.message) === null || _a === undefined ? undefined : _a.role) === "user") {
|
|
794
|
-
return;
|
|
795
|
-
}
|
|
796
|
-
if (entry2.type === "custom" && entry2.customType === TA_ASK_ENTRY) {
|
|
797
|
-
return read(entry2);
|
|
798
|
-
}
|
|
799
|
-
}
|
|
800
|
-
return;
|
|
801
|
-
}
|
|
802
|
-
TaAskUtil2.asking = asking;
|
|
803
|
-
function next(asked, entry2) {
|
|
804
|
-
var _a;
|
|
805
|
-
if (entry2.type === "message" && ((_a = entry2.message) === null || _a === undefined ? undefined : _a.role) === "user") {
|
|
806
|
-
return;
|
|
807
|
-
}
|
|
808
|
-
return entry2.type === "custom" && entry2.customType === TA_ASK_ENTRY ? read(entry2) : asked;
|
|
809
|
-
}
|
|
810
|
-
TaAskUtil2.next = next;
|
|
811
|
-
function read(found) {
|
|
812
|
-
var _a;
|
|
813
|
-
const question = (_a = found.data) === null || _a === undefined ? undefined : _a.question;
|
|
814
|
-
if (typeof question !== "string" || !question.trim()) {
|
|
815
|
-
return;
|
|
816
|
-
}
|
|
817
|
-
const at = found.timestamp ? Date.parse(found.timestamp) : Number.NaN;
|
|
818
|
-
return { question: entry(question).question, at: Number.isNaN(at) ? 0 : at };
|
|
1344
|
+
// ../ta-protocol/esm/common/ta-protocol.js
|
|
1345
|
+
var TaServer = Symbol("TaServer");
|
|
1346
|
+
var TaClient = Symbol("TaClient");
|
|
1347
|
+
var TaSlashCommandUtil;
|
|
1348
|
+
(function(TaSlashCommandUtil2) {
|
|
1349
|
+
function description(command, language) {
|
|
1350
|
+
var _a, _b;
|
|
1351
|
+
const { descriptions } = command;
|
|
1352
|
+
return (_b = (_a = descriptions === null || descriptions === undefined ? undefined : descriptions[language]) !== null && _a !== undefined ? _a : descriptions === null || descriptions === undefined ? undefined : descriptions[language.split("-")[0]]) !== null && _b !== undefined ? _b : command.description;
|
|
819
1353
|
}
|
|
820
|
-
|
|
1354
|
+
TaSlashCommandUtil2.description = description;
|
|
1355
|
+
})(TaSlashCommandUtil || (TaSlashCommandUtil = {}));
|
|
821
1356
|
// ../ta-protocol/esm/common/team-protocol.js
|
|
822
1357
|
var TA_UNDECLARED = "extensions.install";
|
|
823
1358
|
var TaPermissionUtil;
|
|
@@ -909,6 +1444,8 @@ var TaActionUtil;
|
|
|
909
1444
|
})(TaActionUtil || (TaActionUtil = {}));
|
|
910
1445
|
// ../ta-protocol/esm/common/usage-protocol.js
|
|
911
1446
|
var TaUsageServer = Symbol("TaUsageServer");
|
|
1447
|
+
// ../ta-protocol/esm/common/voice-protocol.js
|
|
1448
|
+
var TaVoiceServer = Symbol("TaVoiceServer");
|
|
912
1449
|
// ../ta-protocol/esm/common/workspace-protocol.js
|
|
913
1450
|
var TaWorkspaceServer = Symbol("TaWorkspaceServer");
|
|
914
1451
|
var TaTerminalServer = Symbol("TaTerminalServer");
|
|
@@ -1796,7 +2333,7 @@ class WecomChannel {
|
|
|
1796
2333
|
if (!text && files.length === 0) {
|
|
1797
2334
|
return;
|
|
1798
2335
|
}
|
|
1799
|
-
this.messageHandler({ chat, from: { id: from }, group, text, files, handle: frame.headers?.req_id });
|
|
2336
|
+
this.messageHandler({ chat, from: { id: from }, group, text, files, handle: frame.headers?.req_id, ...body.msgid ? { id: body.msgid } : {} });
|
|
1800
2337
|
}
|
|
1801
2338
|
async download(kind, media) {
|
|
1802
2339
|
const response = await this.fetcher(media.url, { signal: AbortSignal.timeout(DOWNLOAD_MS) });
|
|
@@ -2291,8 +2828,9 @@ class WeixinChannel {
|
|
|
2291
2828
|
if (texts.length === 0 && files.length === 0) {
|
|
2292
2829
|
return;
|
|
2293
2830
|
}
|
|
2831
|
+
const id = message.message_id === undefined ? undefined : String(message.message_id);
|
|
2294
2832
|
this.messageHandler({ chat, from: { id: chat }, text: texts.join(`
|
|
2295
|
-
`), files });
|
|
2833
|
+
`), files, ...id ? { id } : {} });
|
|
2296
2834
|
}
|
|
2297
2835
|
async media(item) {
|
|
2298
2836
|
const of = (kind, media, aesKey) => media?.media && (media.media.encrypt_query_param || media.media.full_url) ? { kind, media: media.media, aesKey: aesKey ?? media.media.aes_key } : undefined;
|
|
@@ -2438,6 +2976,8 @@ class WeixinLogins extends LoginBook {
|
|
|
2438
2976
|
|
|
2439
2977
|
// web-src/bot-service.ts
|
|
2440
2978
|
var PENDING_MS = 30 * 60000;
|
|
2979
|
+
var HEARD_MS = 30 * 60000;
|
|
2980
|
+
var HEARD_MAX = 1000;
|
|
2441
2981
|
|
|
2442
2982
|
class BotService {
|
|
2443
2983
|
host;
|
|
@@ -2445,6 +2985,7 @@ class BotService {
|
|
|
2445
2985
|
status = {};
|
|
2446
2986
|
channels = new Map;
|
|
2447
2987
|
pending = new Map;
|
|
2988
|
+
heard = new Map;
|
|
2448
2989
|
lastChat = new Map;
|
|
2449
2990
|
store;
|
|
2450
2991
|
bridge;
|
|
@@ -2576,19 +3117,34 @@ class BotService {
|
|
|
2576
3117
|
}
|
|
2577
3118
|
async replied(origins, text) {
|
|
2578
3119
|
const sent = [];
|
|
3120
|
+
const chats = new Map;
|
|
2579
3121
|
for (const origin of BotService.unique(origins)) {
|
|
2580
|
-
const
|
|
2581
|
-
|
|
3122
|
+
const key = `${origin.botId}
|
|
3123
|
+
${origin.chat}`;
|
|
3124
|
+
chats.set(key, [...chats.get(key) ?? [], origin]);
|
|
3125
|
+
}
|
|
3126
|
+
for (const same of chats.values()) {
|
|
3127
|
+
const { botId, chat } = same[0];
|
|
3128
|
+
const bot = this.bots.find((other) => other.id === botId);
|
|
3129
|
+
const channel = this.channels.get(botId);
|
|
2582
3130
|
if (!bot || !channel) {
|
|
2583
3131
|
continue;
|
|
2584
3132
|
}
|
|
2585
|
-
const
|
|
2586
|
-
|
|
3133
|
+
const waiting = same.flatMap((origin) => {
|
|
3134
|
+
const pending = origin.reply ? this.pending.get(origin.reply) : undefined;
|
|
2587
3135
|
if (pending) {
|
|
2588
3136
|
this.done(origin.reply);
|
|
2589
|
-
|
|
3137
|
+
}
|
|
3138
|
+
return pending ? [pending] : [];
|
|
3139
|
+
});
|
|
3140
|
+
try {
|
|
3141
|
+
await Promise.all(waiting.slice(1).map((pending) => pending.reply.cancel().catch(() => {
|
|
3142
|
+
return;
|
|
3143
|
+
})));
|
|
3144
|
+
if (waiting[0]) {
|
|
3145
|
+
await (text ? waiting[0].reply.finish(text) : waiting[0].reply.cancel());
|
|
2590
3146
|
} else if (text) {
|
|
2591
|
-
await channel.sendText(
|
|
3147
|
+
await channel.sendText(chat, text);
|
|
2592
3148
|
}
|
|
2593
3149
|
sent.push({ botId: bot.id, kind: bot.kind, botName: bot.name, text });
|
|
2594
3150
|
} catch (error) {
|
|
@@ -2714,7 +3270,7 @@ class BotService {
|
|
|
2714
3270
|
}
|
|
2715
3271
|
async receive(botId, channel, message) {
|
|
2716
3272
|
const bot = this.bots.find((other) => other.id === botId);
|
|
2717
|
-
if (!bot) {
|
|
3273
|
+
if (!bot || this.heardBefore(bot.id, message.id)) {
|
|
2718
3274
|
return;
|
|
2719
3275
|
}
|
|
2720
3276
|
this.lastChat.set(bot.id, message.chat);
|
|
@@ -2757,6 +3313,25 @@ class BotService {
|
|
|
2757
3313
|
});
|
|
2758
3314
|
}
|
|
2759
3315
|
}
|
|
3316
|
+
heardBefore(botId, id) {
|
|
3317
|
+
if (!id) {
|
|
3318
|
+
return false;
|
|
3319
|
+
}
|
|
3320
|
+
const now = Date.now();
|
|
3321
|
+
const key = `${botId}
|
|
3322
|
+
${id}`;
|
|
3323
|
+
if (this.heard.has(key)) {
|
|
3324
|
+
return true;
|
|
3325
|
+
}
|
|
3326
|
+
for (const [other, at] of this.heard) {
|
|
3327
|
+
if (now - at < HEARD_MS && this.heard.size < HEARD_MAX) {
|
|
3328
|
+
break;
|
|
3329
|
+
}
|
|
3330
|
+
this.heard.delete(other);
|
|
3331
|
+
}
|
|
3332
|
+
this.heard.set(key, now);
|
|
3333
|
+
return false;
|
|
3334
|
+
}
|
|
2760
3335
|
done(id) {
|
|
2761
3336
|
const pending = this.pending.get(id);
|
|
2762
3337
|
if (pending) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@celljs/ta-bots",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.17.0",
|
|
4
4
|
"description": "A pi package for Ta: bots of WeChat (ClawBot) and WeCom connected to the double, an agent or a conversation, messages and files both ways",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pi-package"
|
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
"watch": "tsc -b -w --preserveWatchOutput"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@celljs/ta-protocol": "4.
|
|
31
|
-
"@celljs/ta-web": "4.
|
|
30
|
+
"@celljs/ta-protocol": "4.17.0",
|
|
31
|
+
"@celljs/ta-web": "4.17.0",
|
|
32
32
|
"@types/react": "^19.3.0"
|
|
33
33
|
},
|
|
34
34
|
"publishConfig": {
|
package/web/index.js
CHANGED
|
@@ -500,6 +500,15 @@ class BotsClient {
|
|
|
500
500
|
}
|
|
501
501
|
}
|
|
502
502
|
}
|
|
503
|
+
function chatIcons(client) {
|
|
504
|
+
return {
|
|
505
|
+
icon: (chat) => {
|
|
506
|
+
const bot = chat.sessionFile ? client.state.bots.find((candidate) => candidate.target?.kind === "session" && candidate.target.sessionFile === chat.sessionFile) : undefined;
|
|
507
|
+
return bot ? { icon: icon(KIND_ICON[bot.kind]), tint: bot.kind } : undefined;
|
|
508
|
+
},
|
|
509
|
+
subscribe: (listener) => client.subscribe(listener)
|
|
510
|
+
};
|
|
511
|
+
}
|
|
503
512
|
function useBots(client) {
|
|
504
513
|
return React.useSyncExternalStore((listener) => client.subscribe(listener), () => client.state);
|
|
505
514
|
}
|
|
@@ -1399,7 +1408,7 @@ var STYLE = `
|
|
|
1399
1408
|
.tbo-danger:hover { color: var(--ta-red); }
|
|
1400
1409
|
|
|
1401
1410
|
/* The page of the bots. */
|
|
1402
|
-
.tbo-page { box-sizing: border-box; display: flex; flex-direction: column; width: 100%; max-width:
|
|
1411
|
+
.tbo-page { box-sizing: border-box; display: flex; flex-direction: column; width: 100%; max-width: var(--ta-page-wide); min-height: 100%; margin: 0 auto; padding: 20px 24px 48px; }
|
|
1403
1412
|
.tbo-page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; font-size: calc(13px * var(--ta-font-scale)); }
|
|
1404
1413
|
.tbo-connect-buttons { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
|
|
1405
1414
|
.tbo-list { display: flex; flex-direction: column; gap: 8px; }
|
|
@@ -1451,6 +1460,7 @@ function activate(pi2) {
|
|
|
1451
1460
|
const dialogs = new DialogState;
|
|
1452
1461
|
client.start();
|
|
1453
1462
|
pi2.registerComposerAddon(composerAddon(client, dialogs));
|
|
1463
|
+
pi2.registerChatIcon?.(chatIcons(client));
|
|
1454
1464
|
pi2.registerMessageRenderer(INBOUND_TYPE, InboundMessage);
|
|
1455
1465
|
pi2.registerMessageRenderer(SENT_TYPE, SentMessageView);
|
|
1456
1466
|
BotToolLine.register(pi2, () => t("toolSendFile"));
|
|
@@ -1462,7 +1472,8 @@ function activate(pi2) {
|
|
|
1462
1472
|
dialogs
|
|
1463
1473
|
}),
|
|
1464
1474
|
order: 75,
|
|
1465
|
-
discover: true
|
|
1475
|
+
discover: true,
|
|
1476
|
+
group: "work"
|
|
1466
1477
|
});
|
|
1467
1478
|
return () => {
|
|
1468
1479
|
client.dispose();
|