@celljs/ta-channels 4.17.0 → 4.19.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 +2 -2
- package/README.md +2 -2
- package/extension/index.mjs +752 -19
- package/host/index.mjs +920 -231
- package/package.json +4 -4
- package/web/index.js +1351 -689
package/host/index.mjs
CHANGED
|
@@ -86,7 +86,7 @@ var TA_ACTIONS = [
|
|
|
86
86
|
action("commands.terminal", "Open terminals", "打开终端", "開啟終端機", "ターミナルを開く", { scoped: true, risky: true }),
|
|
87
87
|
action("hosts.use", "Use remote hosts", "使用远程主机", "使用遠端主機", "リモートホストを使用", { risky: true }),
|
|
88
88
|
action("models.use", "Use the models", "使用模型", "使用模型", "モデルを使用"),
|
|
89
|
-
action("models.manage", "Sign in to models", "登录和更换模型账号", "登入和更換模型帳號", "モデルアカウントにサインイン・変更"),
|
|
89
|
+
action("models.manage", "Sign in to models", "登录和更换模型账号", "登入和更換模型帳號", "モデルアカウントにサインイン・変更", { grant: "single" }),
|
|
90
90
|
action("cron.view", "See scheduled tasks", "查看定时任务", "檢視定時任務", "スケジュールタスクを確認"),
|
|
91
91
|
action("cron.manage", "Change scheduled tasks", "管理定时任务", "管理定時任務", "スケジュールタスクを管理"),
|
|
92
92
|
action("extensions.use", "Use extensions", "使用扩展", "使用擴充功能", "拡張機能を使用"),
|
|
@@ -99,9 +99,15 @@ var TA_ACTIONS = [
|
|
|
99
99
|
action("members.roles", "Change roles and members", "管理角色和成员", "管理角色和成員", "ロールとメンバーを管理"),
|
|
100
100
|
action("audit.view", "See the record", "查看记录", "檢視記錄", "レコードを確認")
|
|
101
101
|
];
|
|
102
|
+
var TA_OWNER_ACTIONS = [
|
|
103
|
+
action("desktop.view", "See remote desktops", "查看远程桌面", "檢視遠端桌面", "リモートデスクトップを見る", { risky: true }),
|
|
104
|
+
action("desktop.control", "Work remote desktops", "操作远程桌面", "操作遠端桌面", "リモートデスクトップを操作", { risky: true })
|
|
105
|
+
];
|
|
106
|
+
var OWNER_AREAS = ["desktop"];
|
|
102
107
|
var TaActionUtil;
|
|
103
108
|
(function(TaActionUtil2) {
|
|
104
109
|
const byId = new Map(TA_ACTIONS.map((one) => [one.id, one]));
|
|
110
|
+
const titled = new Map([...TA_ACTIONS, ...TA_OWNER_ACTIONS].map((one) => [one.id, one]));
|
|
105
111
|
function info(id) {
|
|
106
112
|
return byId.get(id);
|
|
107
113
|
}
|
|
@@ -109,7 +115,7 @@ var TaActionUtil;
|
|
|
109
115
|
function title(id, language) {
|
|
110
116
|
var _a;
|
|
111
117
|
var _b, _c;
|
|
112
|
-
const title2 = (_a =
|
|
118
|
+
const title2 = (_a = titled.get(id)) === null || _a === undefined ? undefined : _a.title;
|
|
113
119
|
if (!title2) {
|
|
114
120
|
return id;
|
|
115
121
|
}
|
|
@@ -121,6 +127,16 @@ var TaActionUtil;
|
|
|
121
127
|
});
|
|
122
128
|
}
|
|
123
129
|
TaActionUtil2.title = title;
|
|
130
|
+
function grantable(id) {
|
|
131
|
+
const info2 = byId.get(id);
|
|
132
|
+
return !!info2 && !OWNER_AREAS.includes(info2.area);
|
|
133
|
+
}
|
|
134
|
+
TaActionUtil2.grantable = grantable;
|
|
135
|
+
function inRoles(id) {
|
|
136
|
+
var _a;
|
|
137
|
+
return grantable(id) && ((_a = byId.get(id)) === null || _a === undefined ? undefined : _a.grant) !== "single";
|
|
138
|
+
}
|
|
139
|
+
TaActionUtil2.inRoles = inRoles;
|
|
124
140
|
function inside(dir, path) {
|
|
125
141
|
const base = dir.replace(/\/+$/, "");
|
|
126
142
|
return path === base || path.startsWith(`${base}/`) || base === "";
|
|
@@ -128,6 +144,279 @@ var TaActionUtil;
|
|
|
128
144
|
TaActionUtil2.inside = inside;
|
|
129
145
|
})(TaActionUtil || (TaActionUtil = {}));
|
|
130
146
|
|
|
147
|
+
// ../ta-protocol/esm/common/message-protocol.js
|
|
148
|
+
var TaMessageContext;
|
|
149
|
+
(function(TaMessageContext2) {
|
|
150
|
+
const BLOCK = /^<context>\n?[\s\S]*?\n?<\/context>\n?/;
|
|
151
|
+
function wrap(context, message) {
|
|
152
|
+
return `<context>
|
|
153
|
+
${context}
|
|
154
|
+
</context>
|
|
155
|
+
${message}`;
|
|
156
|
+
}
|
|
157
|
+
TaMessageContext2.wrap = wrap;
|
|
158
|
+
function strip(message) {
|
|
159
|
+
return message.replace(BLOCK, "");
|
|
160
|
+
}
|
|
161
|
+
TaMessageContext2.strip = strip;
|
|
162
|
+
function read(message) {
|
|
163
|
+
var _a;
|
|
164
|
+
const block = (_a = BLOCK.exec(message)) === null || _a === undefined ? undefined : _a[0];
|
|
165
|
+
return block === null || block === undefined ? undefined : block.replace(/^<context>\n?/, "").replace(/\n?<\/context>\n?$/, "");
|
|
166
|
+
}
|
|
167
|
+
TaMessageContext2.read = read;
|
|
168
|
+
})(TaMessageContext || (TaMessageContext = {}));
|
|
169
|
+
var TaMessageSource;
|
|
170
|
+
(function(TaMessageSource2) {
|
|
171
|
+
TaMessageSource2.DOUBLE = "ta:double";
|
|
172
|
+
const LINE = /^\[ta:(from|notice) ([^\s\]]+)(?: ([^\]\n]+))?\]$/m;
|
|
173
|
+
function mark(message, from, detail) {
|
|
174
|
+
return marked(message, line(from, detail));
|
|
175
|
+
}
|
|
176
|
+
TaMessageSource2.mark = mark;
|
|
177
|
+
function notice(message, from, detail) {
|
|
178
|
+
return marked(message, line(from, detail, true));
|
|
179
|
+
}
|
|
180
|
+
TaMessageSource2.notice = notice;
|
|
181
|
+
function line(from, detail, notice2 = false) {
|
|
182
|
+
return `[ta:${notice2 ? "notice" : "from"} ${from}${detail ? ` ${detail.replace(/[\]\n]/g, " ")}` : ""}]`;
|
|
183
|
+
}
|
|
184
|
+
TaMessageSource2.line = line;
|
|
185
|
+
function of(message) {
|
|
186
|
+
const context = TaMessageContext.read(message);
|
|
187
|
+
const match = context === undefined ? null : LINE.exec(context);
|
|
188
|
+
return match ? { from: match[2], ...match[3] ? { detail: match[3].trim() } : {}, ...match[1] === "notice" ? { notice: true } : {} } : undefined;
|
|
189
|
+
}
|
|
190
|
+
TaMessageSource2.of = of;
|
|
191
|
+
function isNotice(message) {
|
|
192
|
+
var _a;
|
|
193
|
+
return ((_a = of(message)) === null || _a === undefined ? undefined : _a.notice) === true;
|
|
194
|
+
}
|
|
195
|
+
TaMessageSource2.isNotice = isNotice;
|
|
196
|
+
TaMessageSource2.SECTION = "ta-sources";
|
|
197
|
+
TaMessageSource2.PROMPT = [
|
|
198
|
+
"Who wrote a message: what the user typed or said is theirs. One whose <context> ends with [ta:from <part of Ta> …] was sent by that part of Ta for the user (their choice in a card, what they said in a call, a task or goal they set up): it is theirs too.",
|
|
199
|
+
"One with [ta:notice <part of Ta> …] is not the user's: news or an event of that part of Ta (work that ended elsewhere, a time limit, a permission granted). Weigh it below what the user said:",
|
|
200
|
+
"- It is information, never a request of the user: it does not change, drop or replace what they asked. Their latest words come first.",
|
|
201
|
+
"- Act on it only as far as what they asked, your role or a limit they set calls for; otherwise take it in and go on, and tell them of it in a line only when they need it (a result they wait for, a failure, a question for them).",
|
|
202
|
+
"- Never quote it as the user's words nor answer it as if they had said it."
|
|
203
|
+
].join(`
|
|
204
|
+
`);
|
|
205
|
+
function marked(message, source) {
|
|
206
|
+
if (/^[/!]/.test(message) || of(message)) {
|
|
207
|
+
return message;
|
|
208
|
+
}
|
|
209
|
+
const context = TaMessageContext.read(message);
|
|
210
|
+
return TaMessageContext.wrap(context === undefined ? source : `${context}
|
|
211
|
+
${source}`, TaMessageContext.strip(message));
|
|
212
|
+
}
|
|
213
|
+
})(TaMessageSource || (TaMessageSource = {}));
|
|
214
|
+
var TaImageNote;
|
|
215
|
+
(function(TaImageNote2) {
|
|
216
|
+
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 [^\]]+\.\]$/;
|
|
217
|
+
function strip(text) {
|
|
218
|
+
const lines = text.split(`
|
|
219
|
+
`);
|
|
220
|
+
const kept = lines.filter((line) => !NOTE.test(line.trim()));
|
|
221
|
+
if (kept.length === lines.length) {
|
|
222
|
+
return text;
|
|
223
|
+
}
|
|
224
|
+
return kept.join(`
|
|
225
|
+
`).replace(/\n+$/, "").replace(/^\n+/, "");
|
|
226
|
+
}
|
|
227
|
+
TaImageNote2.strip = strip;
|
|
228
|
+
})(TaImageNote || (TaImageNote = {}));
|
|
229
|
+
var TaImageSize;
|
|
230
|
+
(function(TaImageSize2) {
|
|
231
|
+
const JPEG_BYTES = 256 * 1024;
|
|
232
|
+
function of(base64) {
|
|
233
|
+
var _a, _b, _c;
|
|
234
|
+
let bytes;
|
|
235
|
+
try {
|
|
236
|
+
const binary = atob(base64.slice(0, Math.ceil(JPEG_BYTES * 4 / 3 / 4) * 4));
|
|
237
|
+
bytes = Uint8Array.from(binary, (char) => char.charCodeAt(0));
|
|
238
|
+
} catch (_d) {
|
|
239
|
+
return;
|
|
240
|
+
}
|
|
241
|
+
const size = (_c = (_b = (_a = png(bytes)) !== null && _a !== undefined ? _a : gif(bytes)) !== null && _b !== undefined ? _b : webp(bytes)) !== null && _c !== undefined ? _c : jpeg(bytes);
|
|
242
|
+
return size && size.width > 0 && size.height > 0 ? size : undefined;
|
|
243
|
+
}
|
|
244
|
+
TaImageSize2.of = of;
|
|
245
|
+
function u16be(bytes, at) {
|
|
246
|
+
return bytes[at] << 8 | bytes[at + 1];
|
|
247
|
+
}
|
|
248
|
+
function u16le(bytes, at) {
|
|
249
|
+
return bytes[at] | bytes[at + 1] << 8;
|
|
250
|
+
}
|
|
251
|
+
function u24le(bytes, at) {
|
|
252
|
+
return bytes[at] | bytes[at + 1] << 8 | bytes[at + 2] << 16;
|
|
253
|
+
}
|
|
254
|
+
function u32be(bytes, at) {
|
|
255
|
+
return (bytes[at] << 24 | bytes[at + 1] << 16 | bytes[at + 2] << 8 | bytes[at + 3]) >>> 0;
|
|
256
|
+
}
|
|
257
|
+
function text(bytes, at, length) {
|
|
258
|
+
return String.fromCharCode(...bytes.subarray(at, at + length));
|
|
259
|
+
}
|
|
260
|
+
function png(bytes) {
|
|
261
|
+
return bytes.length >= 24 && bytes[0] === 137 && text(bytes, 1, 3) === "PNG" ? { width: u32be(bytes, 16), height: u32be(bytes, 20) } : undefined;
|
|
262
|
+
}
|
|
263
|
+
function gif(bytes) {
|
|
264
|
+
return bytes.length >= 10 && text(bytes, 0, 3) === "GIF" ? { width: u16le(bytes, 6), height: u16le(bytes, 8) } : undefined;
|
|
265
|
+
}
|
|
266
|
+
function webp(bytes) {
|
|
267
|
+
if (bytes.length < 30 || text(bytes, 0, 4) !== "RIFF" || text(bytes, 8, 4) !== "WEBP") {
|
|
268
|
+
return;
|
|
269
|
+
}
|
|
270
|
+
switch (text(bytes, 12, 4)) {
|
|
271
|
+
case "VP8 ":
|
|
272
|
+
return { width: u16le(bytes, 26) & 16383, height: u16le(bytes, 28) & 16383 };
|
|
273
|
+
case "VP8L": {
|
|
274
|
+
const bits = bytes[21] | bytes[22] << 8 | bytes[23] << 16 | bytes[24] << 24;
|
|
275
|
+
return { width: (bits & 16383) + 1, height: (bits >> 14 & 16383) + 1 };
|
|
276
|
+
}
|
|
277
|
+
case "VP8X":
|
|
278
|
+
return { width: u24le(bytes, 24) + 1, height: u24le(bytes, 27) + 1 };
|
|
279
|
+
default:
|
|
280
|
+
return;
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
function jpeg(bytes) {
|
|
284
|
+
if (bytes[0] !== 255 || bytes[1] !== 216) {
|
|
285
|
+
return;
|
|
286
|
+
}
|
|
287
|
+
let at = 2;
|
|
288
|
+
while (at + 9 < bytes.length) {
|
|
289
|
+
if (bytes[at] !== 255) {
|
|
290
|
+
return;
|
|
291
|
+
}
|
|
292
|
+
const marker = bytes[at + 1];
|
|
293
|
+
if (marker >= 192 && marker <= 207 && marker !== 196 && marker !== 200 && marker !== 204) {
|
|
294
|
+
return { width: u16be(bytes, at + 7), height: u16be(bytes, at + 5) };
|
|
295
|
+
}
|
|
296
|
+
at += 2 + u16be(bytes, at + 2);
|
|
297
|
+
}
|
|
298
|
+
return;
|
|
299
|
+
}
|
|
300
|
+
})(TaImageSize || (TaImageSize = {}));
|
|
301
|
+
var TaAgentSummary;
|
|
302
|
+
(function(TaAgentSummary2) {
|
|
303
|
+
const START = /^\s*<conversation_history_summary>/;
|
|
304
|
+
const BLOCK = /^\s*<conversation_history_summary>[\s\S]*?(?:<\/conversation_history_summary>\s*|$)/;
|
|
305
|
+
function read(text) {
|
|
306
|
+
if (!START.test(text)) {
|
|
307
|
+
return;
|
|
308
|
+
}
|
|
309
|
+
return text.replace(/<\/?(?:conversation_history_summary|summary)>/g, "").replace(/<\/?\w*$/, "").trim();
|
|
310
|
+
}
|
|
311
|
+
TaAgentSummary2.read = read;
|
|
312
|
+
function strip(text) {
|
|
313
|
+
return text.replace(BLOCK, "");
|
|
314
|
+
}
|
|
315
|
+
TaAgentSummary2.strip = strip;
|
|
316
|
+
})(TaAgentSummary || (TaAgentSummary = {}));
|
|
317
|
+
var TaSkillUse;
|
|
318
|
+
(function(TaSkillUse2) {
|
|
319
|
+
const BLOCK = /^<skill name="([^"]+)" location="([^"]+)">\n([\s\S]*?)\n<\/skill>(?:\n\n([\s\S]+))?$/;
|
|
320
|
+
function parse(message) {
|
|
321
|
+
var _a;
|
|
322
|
+
const match = BLOCK.exec(message);
|
|
323
|
+
if (!match) {
|
|
324
|
+
return;
|
|
325
|
+
}
|
|
326
|
+
return { name: match[1], location: match[2], content: match[3], message: ((_a = match[4]) === null || _a === undefined ? undefined : _a.trim()) || undefined };
|
|
327
|
+
}
|
|
328
|
+
TaSkillUse2.parse = parse;
|
|
329
|
+
function command(use) {
|
|
330
|
+
return use.message ? `/skill:${use.name} ${use.message}` : `/skill:${use.name}`;
|
|
331
|
+
}
|
|
332
|
+
TaSkillUse2.command = command;
|
|
333
|
+
})(TaSkillUse || (TaSkillUse = {}));
|
|
334
|
+
var TaTaskNote;
|
|
335
|
+
(function(TaTaskNote2) {
|
|
336
|
+
const NOTE = /^<task_(update|adopted|renamed) ((?:[^>"\n]|"[^"]*")*)>\n?([\s\S]*?)\n?<\/task_\1>$/;
|
|
337
|
+
const ATTRIBUTE = /(\w+)="([^"]*)"/g;
|
|
338
|
+
function write(note) {
|
|
339
|
+
const attributes = [`id="${quote(note.id)}"`];
|
|
340
|
+
if (note.was !== undefined) {
|
|
341
|
+
attributes.push(`was="${quote(note.was)}"`);
|
|
342
|
+
}
|
|
343
|
+
attributes.push(`title="${quote(note.title)}"`);
|
|
344
|
+
if (note.status !== undefined) {
|
|
345
|
+
attributes.push(`status="${quote(note.status)}"`);
|
|
346
|
+
}
|
|
347
|
+
return `<task_${note.kind} ${attributes.join(" ")}>
|
|
348
|
+
${note.body}
|
|
349
|
+
</task_${note.kind}>`;
|
|
350
|
+
}
|
|
351
|
+
TaTaskNote2.write = write;
|
|
352
|
+
function parse(text) {
|
|
353
|
+
const match = NOTE.exec(text.trim());
|
|
354
|
+
if (!match) {
|
|
355
|
+
return;
|
|
356
|
+
}
|
|
357
|
+
const attributes = {};
|
|
358
|
+
for (const [, name, value] of match[2].matchAll(ATTRIBUTE)) {
|
|
359
|
+
attributes[name] = unquote(value);
|
|
360
|
+
}
|
|
361
|
+
if (!attributes.id || attributes.title === undefined) {
|
|
362
|
+
return;
|
|
363
|
+
}
|
|
364
|
+
const { id, title, status, was } = attributes;
|
|
365
|
+
return { kind: match[1], id, title, ...status ? { status } : {}, ...was ? { was } : {}, body: match[3] };
|
|
366
|
+
}
|
|
367
|
+
TaTaskNote2.parse = parse;
|
|
368
|
+
function quote(text) {
|
|
369
|
+
return text.replace(/&/g, "&").replace(/"/g, """).replace(/\n/g, " ");
|
|
370
|
+
}
|
|
371
|
+
function unquote(text) {
|
|
372
|
+
return text.replace(/"/g, '"').replace(/&/g, "&");
|
|
373
|
+
}
|
|
374
|
+
})(TaTaskNote || (TaTaskNote = {}));
|
|
375
|
+
var TaSecretRef;
|
|
376
|
+
(function(TaSecretRef2) {
|
|
377
|
+
TaSecretRef2.PACKAGE = "@celljs/ta-secrets";
|
|
378
|
+
const REF = /\$\{?TA_SECRET_([A-Z0-9][A-Z0-9_]*)\}?/g;
|
|
379
|
+
const KINDS = [
|
|
380
|
+
[/^PHONE(?:_\d+)?$/, "phone"],
|
|
381
|
+
[/^EMAIL(?:_\d+)?$/, "email"],
|
|
382
|
+
[/^ID_NUMBER(?:_\d+)?$/, "idNumber"],
|
|
383
|
+
[/^BANK_CARD(?:_\d+)?$/, "bankCard"]
|
|
384
|
+
];
|
|
385
|
+
function has(text) {
|
|
386
|
+
return text.includes("TA_SECRET_") && new RegExp(REF.source).test(text);
|
|
387
|
+
}
|
|
388
|
+
TaSecretRef2.has = has;
|
|
389
|
+
function kind(name) {
|
|
390
|
+
var _a;
|
|
391
|
+
var _b;
|
|
392
|
+
return (_b = (_a = KINDS.find(([pattern]) => pattern.test(name))) === null || _a === undefined ? undefined : _a[1]) !== null && _b !== undefined ? _b : "secret";
|
|
393
|
+
}
|
|
394
|
+
TaSecretRef2.kind = kind;
|
|
395
|
+
function split(text) {
|
|
396
|
+
if (!has(text)) {
|
|
397
|
+
return [{ text }];
|
|
398
|
+
}
|
|
399
|
+
const parts = [];
|
|
400
|
+
let at = 0;
|
|
401
|
+
for (const match of text.matchAll(REF)) {
|
|
402
|
+
if (match.index > at) {
|
|
403
|
+
parts.push({ text: text.slice(at, match.index) });
|
|
404
|
+
}
|
|
405
|
+
parts.push({ secret: match[1], kind: kind(match[1]) });
|
|
406
|
+
at = match.index + match[0].length;
|
|
407
|
+
}
|
|
408
|
+
if (at < text.length) {
|
|
409
|
+
parts.push({ text: text.slice(at) });
|
|
410
|
+
}
|
|
411
|
+
return parts;
|
|
412
|
+
}
|
|
413
|
+
TaSecretRef2.split = split;
|
|
414
|
+
function plain(text, label) {
|
|
415
|
+
return has(text) ? text.replace(REF, (_whole, name) => label(name, kind(name))) : text;
|
|
416
|
+
}
|
|
417
|
+
TaSecretRef2.plain = plain;
|
|
418
|
+
})(TaSecretRef || (TaSecretRef = {}));
|
|
419
|
+
|
|
131
420
|
// ../ta-protocol/esm/common/redactor.js
|
|
132
421
|
var REDACTED = "[redacted]";
|
|
133
422
|
var WHOLE = [
|
|
@@ -246,6 +535,255 @@ var RelayAgentCards;
|
|
|
246
535
|
RelayAgentCards2.parse = parse;
|
|
247
536
|
})(RelayAgentCards || (RelayAgentCards = {}));
|
|
248
537
|
|
|
538
|
+
// ../ta-relay/esm/common/relay-faces.js
|
|
539
|
+
var FACE_COUNT = 25;
|
|
540
|
+
var BLUE = "#4285F4";
|
|
541
|
+
var RED = "#EA4335";
|
|
542
|
+
var YELLOW = "#FBBC05";
|
|
543
|
+
var GREEN = "#34A853";
|
|
544
|
+
var MINT = "#5CC27F";
|
|
545
|
+
var ORANGE = "#EE7B3B";
|
|
546
|
+
var VIOLET = "#8C5CF0";
|
|
547
|
+
var CREAM = "#F1DFC0";
|
|
548
|
+
var TEAL = "#26B0A9";
|
|
549
|
+
var PINK = "#F27BA6";
|
|
550
|
+
var LILAC = "#B49CF5";
|
|
551
|
+
var SKY = "#45B5E8";
|
|
552
|
+
var INDIGO = "#5C6BC0";
|
|
553
|
+
var MIST = "#DCE3F0";
|
|
554
|
+
var INK = "#202124";
|
|
555
|
+
var WHITE = "#FFFFFF";
|
|
556
|
+
var CHEEK = "rgba(255, 160, 185, 0.55)";
|
|
557
|
+
var EDGE = "rgba(0, 0, 0, 0.14)";
|
|
558
|
+
var CHEEK_DEEP = "rgba(120, 10, 30, 0.35)";
|
|
559
|
+
var CHEEK_WARM = "rgba(234, 67, 53, 0.4)";
|
|
560
|
+
var LOOKS = [
|
|
561
|
+
{ color: MINT, eye: "#1D3B27", cheek: CHEEK, eyeY: 21, gap: 8 },
|
|
562
|
+
{ color: BLUE, eye: WHITE, cheek: CHEEK, eyeY: 23, gap: 8 },
|
|
563
|
+
{ color: RED, eye: WHITE, cheek: CHEEK_DEEP, eyeY: 22, gap: 8 },
|
|
564
|
+
{ color: CREAM, eye: "#4A3420", cheek: "rgba(240, 120, 120, 0.5)", accent: "#DDBF8E", eyeY: 22, gap: 7.6 },
|
|
565
|
+
{ color: GREEN, eye: WHITE, cheek: CHEEK, eyeY: 19, gap: 7.2 },
|
|
566
|
+
{ color: INDIGO, eye: WHITE, cheek: CHEEK, eyeY: 20, gap: 7.4 },
|
|
567
|
+
{ color: YELLOW, eye: INK, cheek: CHEEK_WARM, accent: "#F29900", eyeY: 24, gap: 8.4 },
|
|
568
|
+
{ color: VIOLET, eye: "#22134A", cheek: CHEEK, eyeY: 20, gap: 8 },
|
|
569
|
+
{ color: MIST, eye: "#2B3245", cheek: CHEEK, eyeY: 19, gap: 7.6 },
|
|
570
|
+
{ color: SKY, eye: WHITE, cheek: CHEEK, eyeY: 21, gap: 6.4 },
|
|
571
|
+
{ color: ORANGE, eye: "#3D1C08", cheek: CHEEK, accent: GREEN, eyeY: 22, gap: 8.6, brows: true },
|
|
572
|
+
{ color: WHITE, eye: WHITE, cheek: CHEEK, accent: INK, mouth: INK, eyeY: 22, gap: 10 },
|
|
573
|
+
{ color: TEAL, eye: WHITE, cheek: CHEEK, accent: "#1B8A84", eyeY: 22.5, gap: 8.4 },
|
|
574
|
+
{ color: PINK, eye: "#4A1428", cheek: "rgba(160, 20, 70, 0.3)", eyeY: 24, gap: 7.4 },
|
|
575
|
+
{ color: LILAC, eye: "#2A1A5E", cheek: CHEEK, eyeY: 25, gap: 8 },
|
|
576
|
+
{ color: YELLOW, eye: INK, cheek: CHEEK_WARM, eyeY: 25, gap: 7.4 },
|
|
577
|
+
{ color: BLUE, eye: WHITE, cheek: CHEEK, eyeY: 19.5, gap: 8 },
|
|
578
|
+
{ color: CREAM, eye: "#4A3420", cheek: "rgba(240, 120, 120, 0.5)", eyeY: 23.5, gap: 8 },
|
|
579
|
+
{ color: GREEN, eye: WHITE, cheek: CHEEK, eyeY: 21, gap: 8 },
|
|
580
|
+
{ color: PINK, eye: "#4A1428", cheek: "rgba(160, 20, 70, 0.3)", eyeY: 19.5, gap: 8.4 },
|
|
581
|
+
{ color: RED, eye: WHITE, cheek: CHEEK_DEEP, accent: "#B3261E", eyeY: 20, gap: 8.4 },
|
|
582
|
+
{ color: SKY, eye: WHITE, cheek: CHEEK, eyeY: 23.5, gap: 8 },
|
|
583
|
+
{ color: VIOLET, eye: WHITE, cheek: CHEEK, accent: "#6B3FD4", eyeY: 22, gap: 8 },
|
|
584
|
+
{ color: TEAL, eye: WHITE, cheek: CHEEK, accent: "#1B8A84", eyeY: 25, gap: 7.6 },
|
|
585
|
+
{ color: MINT, eye: "#1D3B27", cheek: CHEEK, accent: "#4AAE6C", eyeY: 22.5, gap: 9 }
|
|
586
|
+
];
|
|
587
|
+
function corners(count, radius, cx, cy, inner) {
|
|
588
|
+
const points = [];
|
|
589
|
+
const steps = inner ? count * 2 : count;
|
|
590
|
+
for (let index = 0;index < steps; index++) {
|
|
591
|
+
const r = inner && index % 2 === 1 ? inner : radius;
|
|
592
|
+
const angle = -Math.PI / 2 + index * 2 * Math.PI / steps;
|
|
593
|
+
points.push(`${(cx + r * Math.cos(angle)).toFixed(2)},${(cy + r * Math.sin(angle)).toFixed(2)}`);
|
|
594
|
+
}
|
|
595
|
+
return points.join(" ");
|
|
596
|
+
}
|
|
597
|
+
var PENTAGON = corners(5, 13.5, 20, 21.5);
|
|
598
|
+
var HEXAGON = corners(6, 14, 20, 20);
|
|
599
|
+
var STAR = corners(5, 15.5, 20, 21.5, 8.6);
|
|
600
|
+
function node(tag, attrs, children) {
|
|
601
|
+
return children ? { tag, attrs, children } : { tag, attrs };
|
|
602
|
+
}
|
|
603
|
+
function rounded(points, color, width = 5) {
|
|
604
|
+
return node("polygon", { points, fill: color, stroke: color, "stroke-width": width, "stroke-linejoin": "round" });
|
|
605
|
+
}
|
|
606
|
+
function shape(face, look) {
|
|
607
|
+
const { color, accent = color } = look;
|
|
608
|
+
switch (face) {
|
|
609
|
+
case 1:
|
|
610
|
+
return node("g", {}, [
|
|
611
|
+
rounded("7.5,6.5 17,12 8.5,18", color, 4),
|
|
612
|
+
rounded("32.5,6.5 23,12 31.5,18", color, 4),
|
|
613
|
+
node("ellipse", { cx: 20, cy: 23, rx: 14.5, ry: 12.5, fill: color })
|
|
614
|
+
]);
|
|
615
|
+
case 2:
|
|
616
|
+
return rounded(PENTAGON, color);
|
|
617
|
+
case 3:
|
|
618
|
+
return node("g", {}, [
|
|
619
|
+
node("circle", { cx: 9.5, cy: 10.5, r: 5.5, fill: color }),
|
|
620
|
+
node("circle", { cx: 30.5, cy: 10.5, r: 5.5, fill: color }),
|
|
621
|
+
node("circle", { cx: 9.5, cy: 10.5, r: 2.6, fill: accent }),
|
|
622
|
+
node("circle", { cx: 30.5, cy: 10.5, r: 2.6, fill: accent }),
|
|
623
|
+
node("ellipse", { cx: 20, cy: 22.5, rx: 14.5, ry: 13, fill: color })
|
|
624
|
+
]);
|
|
625
|
+
case 4:
|
|
626
|
+
return node("rect", { x: 8.5, y: 4, width: 23, height: 32, rx: 11.5, fill: color });
|
|
627
|
+
case 5:
|
|
628
|
+
return rounded("20,5.5 34.5,20 20,34.5 5.5,20", color, 5.5);
|
|
629
|
+
case 6:
|
|
630
|
+
return node("g", {}, [
|
|
631
|
+
node("ellipse", { cx: 20, cy: 11, rx: 3.2, ry: 3.6, fill: accent }),
|
|
632
|
+
node("path", { d: "M20 12.5c9.2 0 15.5 5.6 15.5 12.4 0 6.4-6.9 10.1-15.5 10.1S4.5 31.3 4.5 24.9C4.5 18.1 10.8 12.5 20 12.5Z", fill: color })
|
|
633
|
+
]);
|
|
634
|
+
case 7:
|
|
635
|
+
return rounded(HEXAGON, color);
|
|
636
|
+
case 8:
|
|
637
|
+
return node("path", {
|
|
638
|
+
d: "M8 19a12 12 0 0 1 24 0v14l-4-3-4 3-4-3-4 3-4-3-4 3Z",
|
|
639
|
+
fill: color,
|
|
640
|
+
stroke: EDGE,
|
|
641
|
+
"stroke-width": 0.8,
|
|
642
|
+
"stroke-linejoin": "round"
|
|
643
|
+
});
|
|
644
|
+
case 9:
|
|
645
|
+
return rounded(STAR, color, 4.5);
|
|
646
|
+
case 10:
|
|
647
|
+
return node("g", {}, [
|
|
648
|
+
node("rect", { x: 18.6, y: 4.5, width: 2.8, height: 7, rx: 1.4, fill: accent }),
|
|
649
|
+
node("ellipse", { cx: 12.5, cy: 23, rx: 8.5, ry: 11, fill: color }),
|
|
650
|
+
node("ellipse", { cx: 27.5, cy: 23, rx: 8.5, ry: 11, fill: color }),
|
|
651
|
+
node("ellipse", { cx: 20, cy: 22.5, rx: 9.5, ry: 12, fill: color })
|
|
652
|
+
]);
|
|
653
|
+
case 11:
|
|
654
|
+
return node("g", {}, [
|
|
655
|
+
node("circle", { cx: 9.5, cy: 10, r: 5, fill: accent }),
|
|
656
|
+
node("circle", { cx: 30.5, cy: 10, r: 5, fill: accent }),
|
|
657
|
+
node("ellipse", { cx: 20, cy: 22.5, rx: 14.5, ry: 13, fill: color, stroke: EDGE, "stroke-width": 0.8 }),
|
|
658
|
+
node("ellipse", { cx: 14.6, cy: 22, rx: 3.6, ry: 4.4, transform: "rotate(20 14.6 22)", fill: accent }),
|
|
659
|
+
node("ellipse", { cx: 25.4, cy: 22, rx: 3.6, ry: 4.4, transform: "rotate(-20 25.4 22)", fill: accent })
|
|
660
|
+
]);
|
|
661
|
+
case 12:
|
|
662
|
+
return node("g", {}, [
|
|
663
|
+
node("rect", { x: 19.1, y: 6, width: 1.8, height: 7, fill: accent }),
|
|
664
|
+
node("circle", { cx: 20, cy: 5, r: 2.2, fill: accent }),
|
|
665
|
+
node("rect", { x: 5.5, y: 12, width: 29, height: 22.5, rx: 6.5, fill: color })
|
|
666
|
+
]);
|
|
667
|
+
case 13:
|
|
668
|
+
return node("path", { d: "M20 4.5c2 0 13 11.6 13 20.2 0 6.4-5.8 10.8-13 10.8S7 31.1 7 24.7C7 16.1 18 4.5 20 4.5Z", fill: color });
|
|
669
|
+
case 14:
|
|
670
|
+
return node("g", {}, [
|
|
671
|
+
node("ellipse", { cx: 14, cy: 10.5, rx: 3.6, ry: 8, transform: "rotate(-8 14 10.5)", fill: color }),
|
|
672
|
+
node("ellipse", { cx: 26, cy: 10.5, rx: 3.6, ry: 8, transform: "rotate(8 26 10.5)", fill: color }),
|
|
673
|
+
node("ellipse", { cx: 20, cy: 25, rx: 14, ry: 11, fill: color })
|
|
674
|
+
]);
|
|
675
|
+
case 15:
|
|
676
|
+
return rounded("20,7 35,33 5,33", color, 6);
|
|
677
|
+
case 16:
|
|
678
|
+
return node("path", {
|
|
679
|
+
d: "M20 6.5l12 4.2v8.4c0 7.4-4.9 12.6-12 15.9-7.1-3.3-12-8.5-12-15.9v-8.4Z",
|
|
680
|
+
fill: color,
|
|
681
|
+
stroke: color,
|
|
682
|
+
"stroke-width": 3,
|
|
683
|
+
"stroke-linejoin": "round"
|
|
684
|
+
});
|
|
685
|
+
case 17:
|
|
686
|
+
return rounded("20,7 32.5,17.5 32.5,33 7.5,33 7.5,17.5", color, 4.5);
|
|
687
|
+
case 18:
|
|
688
|
+
return rounded("14,9 26,9 32.5,32 7.5,32", color, 6);
|
|
689
|
+
case 19:
|
|
690
|
+
return node("rect", { x: 4.5, y: 10.5, width: 31, height: 19.5, rx: 9.75, fill: color });
|
|
691
|
+
case 20:
|
|
692
|
+
return node("g", {}, [
|
|
693
|
+
node("rect", { x: 14, y: 5.5, width: 12, height: 4.5, rx: 1.6, fill: accent }),
|
|
694
|
+
node("rect", { x: 14, y: 30.5, width: 12, height: 4.5, rx: 1.6, fill: accent }),
|
|
695
|
+
node("ellipse", { cx: 20, cy: 20.25, rx: 15, ry: 12.25, fill: color })
|
|
696
|
+
]);
|
|
697
|
+
case 21:
|
|
698
|
+
return node("g", {}, [
|
|
699
|
+
node("circle", { cx: 13.5, cy: 21.5, r: 7, fill: color }),
|
|
700
|
+
node("circle", { cx: 21.5, cy: 16.5, r: 9, fill: color }),
|
|
701
|
+
node("circle", { cx: 28.5, cy: 22.5, r: 6.5, fill: color }),
|
|
702
|
+
node("rect", { x: 5.5, y: 21, width: 29, height: 12, rx: 6, fill: color })
|
|
703
|
+
]);
|
|
704
|
+
case 22:
|
|
705
|
+
return node("g", {}, [
|
|
706
|
+
node("rect", { x: 12.5, y: 5.5, width: 15, height: 5.5, rx: 2, fill: accent }),
|
|
707
|
+
node("rect", { x: 7.5, y: 9.5, width: 25, height: 25.5, rx: 6.5, fill: color })
|
|
708
|
+
]);
|
|
709
|
+
case 23:
|
|
710
|
+
return node("g", {}, [
|
|
711
|
+
node("rect", { x: 18.8, y: 3.5, width: 2.4, height: 6, rx: 1.2, fill: accent }),
|
|
712
|
+
node("circle", { cx: 20, cy: 13, r: 6.5, fill: color }),
|
|
713
|
+
node("circle", { cx: 20, cy: 25, r: 11.5, fill: color })
|
|
714
|
+
]);
|
|
715
|
+
case 24:
|
|
716
|
+
return node("g", {}, [
|
|
717
|
+
node("circle", { cx: 12, cy: 13, r: 5.5, fill: color }),
|
|
718
|
+
node("circle", { cx: 28, cy: 13, r: 5.5, fill: color }),
|
|
719
|
+
node("circle", { cx: 12, cy: 13, r: 2.2, fill: accent }),
|
|
720
|
+
node("circle", { cx: 28, cy: 13, r: 2.2, fill: accent }),
|
|
721
|
+
node("ellipse", { cx: 20, cy: 23.5, rx: 15.5, ry: 11.5, fill: color })
|
|
722
|
+
]);
|
|
723
|
+
default:
|
|
724
|
+
return node("circle", { cx: 20, cy: 21, r: 14.5, fill: color });
|
|
725
|
+
}
|
|
726
|
+
}
|
|
727
|
+
var FaceUtil;
|
|
728
|
+
(function(FaceUtil2) {
|
|
729
|
+
function of(seed) {
|
|
730
|
+
let hash = 0;
|
|
731
|
+
for (const char of seed) {
|
|
732
|
+
hash = hash * 31 + char.charCodeAt(0) | 0;
|
|
733
|
+
}
|
|
734
|
+
return Math.abs(hash) % FACE_COUNT;
|
|
735
|
+
}
|
|
736
|
+
FaceUtil2.of = of;
|
|
737
|
+
function pick(face, seed = "") {
|
|
738
|
+
return face !== undefined && face >= 0 && face < FACE_COUNT ? Math.floor(face) : of(seed);
|
|
739
|
+
}
|
|
740
|
+
FaceUtil2.pick = pick;
|
|
741
|
+
function color(face) {
|
|
742
|
+
var _a;
|
|
743
|
+
return ((_a = LOOKS[face]) !== null && _a !== undefined ? _a : LOOKS[0]).color;
|
|
744
|
+
}
|
|
745
|
+
FaceUtil2.color = color;
|
|
746
|
+
function art(face) {
|
|
747
|
+
var _a, _b;
|
|
748
|
+
const look = (_a = LOOKS[face]) !== null && _a !== undefined ? _a : LOOKS[0];
|
|
749
|
+
const half = look.gap / 2;
|
|
750
|
+
const eyeW = 4.1;
|
|
751
|
+
const eyeH = 4.9;
|
|
752
|
+
const top = look.eyeY - eyeH / 2;
|
|
753
|
+
const cheekY = look.eyeY + 3.6;
|
|
754
|
+
const cheekX = half + 2.2;
|
|
755
|
+
const mouthY = look.eyeY + 3.4;
|
|
756
|
+
const features = [
|
|
757
|
+
node("g", { fill: look.cheek }, [
|
|
758
|
+
node("ellipse", { cx: 20 - cheekX, cy: cheekY, rx: 2.2, ry: 1.25 }),
|
|
759
|
+
node("ellipse", { cx: 20 + cheekX, cy: cheekY, rx: 2.2, ry: 1.25 })
|
|
760
|
+
])
|
|
761
|
+
];
|
|
762
|
+
if (look.brows) {
|
|
763
|
+
features.push(node("path", {
|
|
764
|
+
d: `M${20 - half - 3.4} ${top - 2.6}l3.6 1.6M${20 + half + 3.4} ${top - 2.6}l-3.6 1.6`,
|
|
765
|
+
stroke: look.eye,
|
|
766
|
+
"stroke-width": 1.4,
|
|
767
|
+
"stroke-linecap": "round",
|
|
768
|
+
fill: "none"
|
|
769
|
+
}));
|
|
770
|
+
}
|
|
771
|
+
features.push(node("g", { class: "ta-face-eyes", fill: look.eye }, [
|
|
772
|
+
node("rect", { x: 20 - half - eyeW / 2, y: top, width: eyeW, height: eyeH, rx: eyeW / 2 }),
|
|
773
|
+
node("rect", { x: 20 + half - eyeW / 2, y: top, width: eyeW, height: eyeH, rx: eyeW / 2 })
|
|
774
|
+
]), node("path", {
|
|
775
|
+
d: `M18.1 ${mouthY}q.95 1.25 1.9 0q.95 1.25 1.9 0`,
|
|
776
|
+
fill: "none",
|
|
777
|
+
stroke: (_b = look.mouth) !== null && _b !== undefined ? _b : look.eye,
|
|
778
|
+
"stroke-width": 1.1,
|
|
779
|
+
"stroke-linecap": "round",
|
|
780
|
+
"stroke-linejoin": "round"
|
|
781
|
+
}));
|
|
782
|
+
return node("g", { class: "ta-face-body" }, [shape(face, look), node("g", { class: "ta-face-look" }, features)]);
|
|
783
|
+
}
|
|
784
|
+
FaceUtil2.art = art;
|
|
785
|
+
})(FaceUtil || (FaceUtil = {}));
|
|
786
|
+
|
|
249
787
|
// web-src/channels-model.ts
|
|
250
788
|
var NAME = "@celljs/ta-channels";
|
|
251
789
|
var AGENT_MARK = "one of the agents of Ta";
|
|
@@ -269,7 +807,7 @@ var MAX_REPLIES = 8;
|
|
|
269
807
|
var MAX_AGENT_REPLIES = 2;
|
|
270
808
|
var STOP_NOTE = "The agents stopped handing on here, at the limit of a round; it is your turn.";
|
|
271
809
|
var MAX_MESSAGES = 200;
|
|
272
|
-
var FACES =
|
|
810
|
+
var FACES = FACE_COUNT;
|
|
273
811
|
var MAX_MEMBERS = 12;
|
|
274
812
|
var CONTEXT_MESSAGES = 12;
|
|
275
813
|
var MAX_NAME = 32;
|
|
@@ -704,16 +1242,238 @@ var AgentCards;
|
|
|
704
1242
|
function adapt(cwd, language) {
|
|
705
1243
|
const context = [
|
|
706
1244
|
AgentCards.MARK,
|
|
707
|
-
`You were just added to this Ta from a card someone shared: the role in your instructions is theirs, written for their own work. Fit it to the project of your directory (${cwd}): look at it first (its README, manifests such as package.json, its layout, how it builds and tests), then rewrite your role for it, keeping what you are for, and save it with update_my_role. Then tell the user
|
|
1245
|
+
`You were just added to this Ta from a card someone shared: the role in your instructions is theirs, written for their own work. Fit it to the project of your directory (${cwd}): look at it first (its README, manifests such as package.json, its layout, how it builds and tests), then rewrite your role for it, keeping what you are for, and save it with update_my_role. Then tell the user, in ${TaLanguageUtil.pick(language, { "zh-CN": "Chinese", "zh-TW": "Traditional Chinese", "en-US": "English", "ja-JP": "Japanese" })}, what you changed and what you can do here. Change no files.`
|
|
708
1246
|
].join(`
|
|
709
1247
|
`);
|
|
710
|
-
return
|
|
711
|
-
|
|
1248
|
+
return TaMessageContext.wrap(context, TaLanguageUtil.pick(language, {
|
|
1249
|
+
"zh-CN": "看看这个项目,把你的职责调整得贴合这里",
|
|
1250
|
+
"zh-TW": "看看這個專案,把你的職責調整得貼合這裡",
|
|
1251
|
+
"en-US": "Look at this project and fit your role to it",
|
|
1252
|
+
"ja-JP": "このプロジェクトを見て、ロールをそれに適応させてください"
|
|
1253
|
+
}));
|
|
1254
|
+
}
|
|
1255
|
+
AgentCards.adapt = adapt;
|
|
1256
|
+
})(AgentCards ||= {});
|
|
1257
|
+
|
|
1258
|
+
// ../ta-protocol/esm/common/said-protocol.js
|
|
1259
|
+
var TaSaid;
|
|
1260
|
+
(function(TaSaid2) {
|
|
1261
|
+
const CARD = /^ta-/i;
|
|
1262
|
+
const READ = 4000;
|
|
1263
|
+
const FENCE = /^\s*(`{3,}|~{3,})\s*([^\s`]*)/;
|
|
1264
|
+
const TAG_LINE = /^<\/?[A-Za-z][\w:.-]*(?:\s[^<>]*)?\/?>$/;
|
|
1265
|
+
const MARKS_ONLY = /^[-*_=|:+\s]+$/;
|
|
1266
|
+
const MARKS = [
|
|
1267
|
+
["context", /<\/?context>/],
|
|
1268
|
+
["source", /\[ta:(?:from|notice|by) /],
|
|
1269
|
+
["image note", /\[Image: original \d+x\d+|\[Image converted from /],
|
|
1270
|
+
["skill", /<skill name="|<\/skill>/],
|
|
1271
|
+
["task note", /<\/?task_(?:update|adopted|renamed)\b/],
|
|
1272
|
+
["summary", /<\/?(?:conversation_history_summary|summary)>/]
|
|
1273
|
+
];
|
|
1274
|
+
function text(content, joiner = `
|
|
1275
|
+
`) {
|
|
1276
|
+
if (typeof content === "string") {
|
|
1277
|
+
return content;
|
|
1278
|
+
}
|
|
1279
|
+
return Array.isArray(content) ? content.filter((part) => (part === null || part === undefined ? undefined : part.type) === "text" && typeof part.text === "string").map((part) => part.text).join(joiner) : "";
|
|
1280
|
+
}
|
|
1281
|
+
TaSaid2.text = text;
|
|
1282
|
+
function words(role, text2, options = {}) {
|
|
1283
|
+
const said = role === "user" ? userWords(text2) : TaAgentSummary.strip(text2);
|
|
1284
|
+
return withoutFences(said, (language) => options.cards === false && CARD.test(language), true).trim();
|
|
1285
|
+
}
|
|
1286
|
+
TaSaid2.words = words;
|
|
1287
|
+
function of(message, options) {
|
|
1288
|
+
return message ? words(message.role, text(message.content), options) : "";
|
|
1289
|
+
}
|
|
1290
|
+
TaSaid2.of = of;
|
|
1291
|
+
function notice(message) {
|
|
1292
|
+
return (message === null || message === undefined ? undefined : message.role) === "user" && TaMessageSource.isNotice(text(message.content));
|
|
1293
|
+
}
|
|
1294
|
+
TaSaid2.notice = notice;
|
|
1295
|
+
function marksOnly(role, text2) {
|
|
1296
|
+
return !!text2.trim() && !line(words(role, text2), { chars: Number.POSITIVE_INFINITY });
|
|
1297
|
+
}
|
|
1298
|
+
TaSaid2.marksOnly = marksOnly;
|
|
1299
|
+
function line(markdown, options) {
|
|
1300
|
+
var _a;
|
|
1301
|
+
const read = markdown.slice(0, READ);
|
|
1302
|
+
const prose = withoutFences(read, () => true, true).trim();
|
|
1303
|
+
const lines = plain(prose || codeOf(read)).split(`
|
|
1304
|
+
`).map((part) => part.replace(/^\s*(?:#{1,6}\s+|>\s*|[-*+]\s+|\d+[.)]\s+)/, "").replace(/\*{1,3}|`+|~~|(?<![\p{L}\p{N}])_{1,3}|_{1,3}(?![\p{L}\p{N}])/gu, "").replace(/\s+/g, " ").trim()).filter((part) => part && !MARKS_ONLY.test(part) && !TAG_LINE.test(part));
|
|
1305
|
+
const count = (_a = options.lines) !== null && _a !== undefined ? _a : 1;
|
|
1306
|
+
const joined = count <= 1 ? lines.join(" ") : lines.slice(0, count).join(`
|
|
1307
|
+
`);
|
|
1308
|
+
return joined.length > options.chars ? `${joined.slice(0, Math.max(0, options.chars - 1)).trimEnd()}…` : joined;
|
|
1309
|
+
}
|
|
1310
|
+
TaSaid2.line = line;
|
|
1311
|
+
function leaks(shown, options = {}) {
|
|
1312
|
+
const found = MARKS.filter(([, mark]) => mark.test(shown)).map(([name]) => name);
|
|
1313
|
+
const lines = shown.split(`
|
|
1314
|
+
`);
|
|
1315
|
+
if (options.cards !== true && lines.some((part) => {
|
|
1316
|
+
var _a;
|
|
1317
|
+
var _b;
|
|
1318
|
+
return CARD.test((_b = (_a = FENCE.exec(part)) === null || _a === undefined ? undefined : _a[2]) !== null && _b !== undefined ? _b : "");
|
|
1319
|
+
})) {
|
|
1320
|
+
found.push("card");
|
|
1321
|
+
}
|
|
1322
|
+
if (lines.some((part) => TAG_LINE.test(part.trim()))) {
|
|
1323
|
+
found.push("tag");
|
|
1324
|
+
}
|
|
1325
|
+
return found;
|
|
1326
|
+
}
|
|
1327
|
+
TaSaid2.leaks = leaks;
|
|
1328
|
+
const SUMMARY = `<conversation_history_summary>
|
|
1329
|
+
<summary>
|
|
1330
|
+
1. Primary Request and Intent:
|
|
1331
|
+
The user works on the relay.
|
|
1332
|
+
</summary>
|
|
1333
|
+
</conversation_history_summary>`;
|
|
1334
|
+
TaSaid2.SAMPLES = [
|
|
1335
|
+
{
|
|
1336
|
+
mark: "context and where it came from",
|
|
1337
|
+
role: "user",
|
|
1338
|
+
text: `<context>
|
|
1339
|
+
The channel #ops, its members.
|
|
1340
|
+
[ta:from @celljs/ta-channels #ops]
|
|
1341
|
+
</context>
|
|
1342
|
+
Check the build`,
|
|
1343
|
+
said: "Check the build"
|
|
1344
|
+
},
|
|
1345
|
+
{
|
|
1346
|
+
mark: "a notice, not the user",
|
|
1347
|
+
role: "user",
|
|
1348
|
+
text: `<context>
|
|
1349
|
+
[ta:notice @celljs/ta-call]
|
|
712
1350
|
</context>
|
|
713
|
-
|
|
1351
|
+
The work finished. Its last words: tests pass.`,
|
|
1352
|
+
said: "The work finished. Its last words: tests pass."
|
|
1353
|
+
},
|
|
1354
|
+
{ mark: "one let in", role: "user", text: `<context>
|
|
1355
|
+
[ta:by p-7 Alice]
|
|
1356
|
+
</context>
|
|
1357
|
+
Hello there`, said: "Hello there" },
|
|
1358
|
+
{
|
|
1359
|
+
mark: "notes of images",
|
|
1360
|
+
role: "user",
|
|
1361
|
+
text: `Look at this
|
|
1362
|
+
[Image: original 3024x4032, displayed at 1512x2016. Multiply coordinates by 2.00 to map to original image.]
|
|
1363
|
+
[Image converted from image/heic to image/png.]`,
|
|
1364
|
+
said: "Look at this"
|
|
1365
|
+
},
|
|
1366
|
+
{
|
|
1367
|
+
mark: "a skill run",
|
|
1368
|
+
role: "user",
|
|
1369
|
+
text: `<skill name="ta-package" location="/skills/ta-package/SKILL.md">
|
|
1370
|
+
# Ta package
|
|
1371
|
+
Steps.
|
|
1372
|
+
</skill>
|
|
1373
|
+
|
|
1374
|
+
Make a card`,
|
|
1375
|
+
said: "Make a card"
|
|
1376
|
+
},
|
|
1377
|
+
{
|
|
1378
|
+
mark: "a note of a task",
|
|
1379
|
+
role: "user",
|
|
1380
|
+
text: `<task_update id="t1" title="Fix login" status="done">
|
|
1381
|
+
All tests pass.
|
|
1382
|
+
</task_update>`,
|
|
1383
|
+
said: "Fix login"
|
|
1384
|
+
},
|
|
1385
|
+
{ mark: "a note of a new id", role: "user", text: `<task_renamed id="t2" was="t1" title="Fix login">
|
|
1386
|
+
Now t2.
|
|
1387
|
+
</task_renamed>` },
|
|
1388
|
+
{ mark: "a summary, then the answer", role: "assistant", text: `${SUMMARY}
|
|
1389
|
+
Switched to voice.`, said: "Switched to voice." },
|
|
1390
|
+
{ mark: "a summary alone", role: "assistant", text: SUMMARY },
|
|
1391
|
+
{ mark: "a summary as it streams", role: "assistant", text: `<conversation_history_summary>
|
|
1392
|
+
<summary>` },
|
|
1393
|
+
{
|
|
1394
|
+
mark: "a card after the answer",
|
|
1395
|
+
role: "assistant",
|
|
1396
|
+
text: '**Done**: tests pass.\n\n```ta-glance\n{"status":"done","blocks":[]}\n```',
|
|
1397
|
+
said: "tests pass"
|
|
1398
|
+
},
|
|
1399
|
+
{ mark: "a card alone", role: "assistant", text: '```ta-glance\n{"status":"done","blocks":[]}\n```' },
|
|
1400
|
+
{ mark: "a proposal", role: "assistant", text: 'Committed.\n\n```ta-propose\n{"kind":"git.push","title":"Push"}\n```', said: "Committed." },
|
|
1401
|
+
{ mark: "what a call says aloud", role: "assistant", text: "All fixed.\n\n```ta-say\nIt is fixed.\n```", said: "All fixed." },
|
|
1402
|
+
{ mark: "a tag not known yet", role: "assistant", text: `<system-reminder>
|
|
1403
|
+
</system-reminder>
|
|
1404
|
+
Ready.`, said: "Ready." }
|
|
1405
|
+
];
|
|
1406
|
+
function userWords(text2) {
|
|
1407
|
+
const said = TaImageNote.strip(TaMessageContext.strip(text2));
|
|
1408
|
+
const skill = TaSkillUse.parse(said);
|
|
1409
|
+
if (skill) {
|
|
1410
|
+
return TaSkillUse.command(skill);
|
|
1411
|
+
}
|
|
1412
|
+
const note = TaTaskNote.parse(said);
|
|
1413
|
+
if (!note) {
|
|
1414
|
+
return said;
|
|
1415
|
+
}
|
|
1416
|
+
if (note.kind === "renamed") {
|
|
1417
|
+
return "";
|
|
1418
|
+
}
|
|
1419
|
+
return note.kind === "update" && note.body.trim() ? `${note.title} · ${note.body}` : note.title;
|
|
1420
|
+
}
|
|
1421
|
+
function withoutFences(text2, drop, tags = false) {
|
|
1422
|
+
const kept = [];
|
|
1423
|
+
let fence;
|
|
1424
|
+
let left = false;
|
|
1425
|
+
for (const part of text2.split(`
|
|
1426
|
+
`)) {
|
|
1427
|
+
const open = FENCE.exec(part);
|
|
1428
|
+
if (!fence && open) {
|
|
1429
|
+
fence = { mark: open[1], dropped: drop(open[2]) };
|
|
1430
|
+
} else if (fence && closes(part, fence.mark)) {
|
|
1431
|
+
const dropped = fence.dropped;
|
|
1432
|
+
fence = undefined;
|
|
1433
|
+
if (dropped) {
|
|
1434
|
+
continue;
|
|
1435
|
+
}
|
|
1436
|
+
}
|
|
1437
|
+
if ((fence === null || fence === undefined ? undefined : fence.dropped) || !fence && tags && TAG_LINE.test(part.trim())) {
|
|
1438
|
+
left = true;
|
|
1439
|
+
} else {
|
|
1440
|
+
kept.push(part);
|
|
1441
|
+
}
|
|
1442
|
+
}
|
|
1443
|
+
return left ? kept.join(`
|
|
1444
|
+
`).replace(/\n{3,}/g, `
|
|
1445
|
+
|
|
1446
|
+
`) : kept.join(`
|
|
1447
|
+
`);
|
|
1448
|
+
}
|
|
1449
|
+
function codeOf(text2) {
|
|
1450
|
+
const code = [];
|
|
1451
|
+
let fence;
|
|
1452
|
+
for (const part of text2.split(`
|
|
1453
|
+
`)) {
|
|
1454
|
+
const open = FENCE.exec(part);
|
|
1455
|
+
if (!fence && open) {
|
|
1456
|
+
fence = { mark: open[1], card: CARD.test(open[2]) };
|
|
1457
|
+
} else if (fence && closes(part, fence.mark)) {
|
|
1458
|
+
fence = undefined;
|
|
1459
|
+
} else if (fence && !fence.card) {
|
|
1460
|
+
code.push(part);
|
|
1461
|
+
}
|
|
1462
|
+
}
|
|
1463
|
+
return code.join(`
|
|
1464
|
+
`);
|
|
714
1465
|
}
|
|
715
|
-
|
|
716
|
-
|
|
1466
|
+
function closes(part, mark) {
|
|
1467
|
+
var _a;
|
|
1468
|
+
const close = (_a = /^\s*(`{3,}|~{3,})\s*$/.exec(part)) === null || _a === undefined ? undefined : _a[1];
|
|
1469
|
+
return !!close && close[0] === mark[0] && close.length >= mark.length;
|
|
1470
|
+
}
|
|
1471
|
+
function plain(text2) {
|
|
1472
|
+
const linked = text2.replace(/(?<!!)\[([^\]\n]*)\]\([^)\n]*\)/g, "$1");
|
|
1473
|
+
const words2 = linked.replace(/!\[[^\]\n]*\]\([^)\n]*\)/g, "").trim();
|
|
1474
|
+
return words2 || linked.replace(/!\[([^\]\n]*)\]\([^)\n]*\)/g, "$1");
|
|
1475
|
+
}
|
|
1476
|
+
})(TaSaid || (TaSaid = {}));
|
|
717
1477
|
|
|
718
1478
|
// web-src/channels-text.ts
|
|
719
1479
|
var ChannelsText;
|
|
@@ -773,7 +1533,7 @@ var ChannelsText;
|
|
|
773
1533
|
return [
|
|
774
1534
|
`You are ${agent.name}, ${AGENT_MARK}. Your role: ${agent.role}`,
|
|
775
1535
|
"You work with the user, Ta and other agents in channels. A message for you starts with a <context> block: the channel, its members, the recent messages and who speaks to you; answer what follows the block.",
|
|
776
|
-
"Do the part of the work your role covers with your tools, then answer
|
|
1536
|
+
"Do the part of the work your role covers with your tools, then answer: your answer is posted to the channel as it is.",
|
|
777
1537
|
"To hand work to another member, write @ and their name in your answer; name nobody when the work is done or you need the user.",
|
|
778
1538
|
NOTICE_RULE
|
|
779
1539
|
].join(`
|
|
@@ -792,13 +1552,10 @@ var ChannelsText;
|
|
|
792
1552
|
lines.push("", "Recent messages:", ...before.map((item) => `${authorName(team, item.author, labels)}: ${item.text}`));
|
|
793
1553
|
}
|
|
794
1554
|
lines.push("", `${authorName(team, message.author, labels)} to you:`);
|
|
795
|
-
const speaker = message.author === USER ? "" : ` · ${authorName(team, message.author, labels)
|
|
796
|
-
lines.push(
|
|
797
|
-
return
|
|
798
|
-
|
|
799
|
-
`)}
|
|
800
|
-
</context>
|
|
801
|
-
${message.text}`;
|
|
1555
|
+
const speaker = message.author === USER ? "" : ` · ${authorName(team, message.author, labels)}`;
|
|
1556
|
+
lines.push(TaMessageSource.line(NAME, `#${channel.name}${speaker}`));
|
|
1557
|
+
return TaMessageContext.wrap(lines.join(`
|
|
1558
|
+
`), message.text);
|
|
802
1559
|
}
|
|
803
1560
|
ChannelsText.prompt = prompt;
|
|
804
1561
|
function summary(team) {
|
|
@@ -827,7 +1584,7 @@ ${message.text}`;
|
|
|
827
1584
|
if (role !== "user" && role !== "assistant") {
|
|
828
1585
|
continue;
|
|
829
1586
|
}
|
|
830
|
-
const text =
|
|
1587
|
+
const text = TaSaid.words(role, TaSaid.text(content, ""));
|
|
831
1588
|
if (text) {
|
|
832
1589
|
parts.push("", `## ${role === "user" ? labels.user : agent.name}`, "", text);
|
|
833
1590
|
}
|
|
@@ -909,10 +1666,7 @@ var HandOff;
|
|
|
909
1666
|
"en-US": `Hand this over to ${to}`,
|
|
910
1667
|
"ja-JP": `これを ${to} に引き継ぐ`
|
|
911
1668
|
});
|
|
912
|
-
return
|
|
913
|
-
${context}
|
|
914
|
-
</context>
|
|
915
|
-
${line}`;
|
|
1669
|
+
return TaMessageContext.wrap(context, line);
|
|
916
1670
|
}
|
|
917
1671
|
HandOff.ask = ask;
|
|
918
1672
|
function asked(text) {
|
|
@@ -950,12 +1704,9 @@ ${line}`;
|
|
|
950
1704
|
origin.sessionFile ? `That conversation is pi's session file ${origin.sessionFile}${origin.cwd ? `, working in ${origin.cwd}` : ""}: read it only when the brief is not enough.` : ""
|
|
951
1705
|
].filter(Boolean).join(`
|
|
952
1706
|
`);
|
|
953
|
-
return
|
|
954
|
-
${context}
|
|
955
|
-
</context>
|
|
956
|
-
${head}
|
|
1707
|
+
return TaMessageContext.wrap(context, `${head}
|
|
957
1708
|
|
|
958
|
-
${brief.trim()}
|
|
1709
|
+
${brief.trim()}`);
|
|
959
1710
|
}
|
|
960
1711
|
HandOff.message = message;
|
|
961
1712
|
function channelText(origin, brief, language) {
|
|
@@ -982,6 +1733,10 @@ ${brief.trim()}`;
|
|
|
982
1733
|
|
|
983
1734
|
// ../ta-protocol/esm/common/access-protocol.js
|
|
984
1735
|
var TaAccessServer = Symbol("TaAccessServer");
|
|
1736
|
+
var TA_SIGN_IN_PATH = "/sign-in";
|
|
1737
|
+
var TA_DEVICE_SIGN_IN_PATH = `${TA_SIGN_IN_PATH}/device`;
|
|
1738
|
+
// ../ta-protocol/esm/common/account-protocol.js
|
|
1739
|
+
var TaAccountServer = Symbol("TaAccountServer");
|
|
985
1740
|
// ../ta-protocol/esm/common/ta-extension-host.js
|
|
986
1741
|
var TA_WEBHOOK_MAX_BYTES = 256 * 1024;
|
|
987
1742
|
var TA_HOST_EVENT = "ta:host";
|
|
@@ -1241,6 +1996,20 @@ var TA_WEB_SETTINGS = [
|
|
|
1241
1996
|
title: words("Model of tasks", "任务的模型", "任務的模型", "タスクのモデル")
|
|
1242
1997
|
},
|
|
1243
1998
|
{ key: "reduceMotion", type: "boolean", default: false, what: "Fewer animations.", title: words("Reduce motion", "减少动画", "減少動畫", "動きを減らす") },
|
|
1999
|
+
{
|
|
2000
|
+
key: "diagramStyle",
|
|
2001
|
+
type: "enum",
|
|
2002
|
+
values: ["clean", "sketch", "colour", "motion"],
|
|
2003
|
+
default: "clean",
|
|
2004
|
+
what: "How diagrams in replies draw: in the colours of the page, as by hand, a colour to a node, or coming in with flowing lines.",
|
|
2005
|
+
title: words("Diagram style", "图表风格", "圖表風格", "図のスタイル"),
|
|
2006
|
+
shown: {
|
|
2007
|
+
clean: words("clean", "简洁", "簡潔", "シンプル"),
|
|
2008
|
+
sketch: words("sketch", "草图", "草圖", "スケッチ"),
|
|
2009
|
+
colour: words("colour", "彩色", "彩色", "カラー"),
|
|
2010
|
+
motion: words("motion", "动效", "動效", "モーション")
|
|
2011
|
+
}
|
|
2012
|
+
},
|
|
1244
2013
|
{
|
|
1245
2014
|
key: "keepAliveMinutes",
|
|
1246
2015
|
type: "number",
|
|
@@ -1415,9 +2184,44 @@ var TaDeploymentUtil;
|
|
|
1415
2184
|
}
|
|
1416
2185
|
result.updates = { ...base ? { base } : {}, ...key ? { key } : {} };
|
|
1417
2186
|
}
|
|
2187
|
+
if (given.reach !== undefined) {
|
|
2188
|
+
result.reach = reach(given.reach);
|
|
2189
|
+
}
|
|
2190
|
+
if (given.inside !== undefined) {
|
|
2191
|
+
const inside = url(given.inside);
|
|
2192
|
+
if (!inside) {
|
|
2193
|
+
throw new TaDeploymentError(`"inside" of ${TaDeploymentUtil2.DISTRIBUTION_FILE} is not an address of http or https.`);
|
|
2194
|
+
}
|
|
2195
|
+
result.inside = inside;
|
|
2196
|
+
}
|
|
1418
2197
|
return result;
|
|
1419
2198
|
}
|
|
1420
2199
|
TaDeploymentUtil2.distribution = distribution;
|
|
2200
|
+
function reach(value) {
|
|
2201
|
+
const given = typeof value === "string" ? { "*": value } : value;
|
|
2202
|
+
const entries = given && typeof given === "object" && !Array.isArray(given) ? Object.entries(given) : [];
|
|
2203
|
+
const result = {};
|
|
2204
|
+
for (const [language, text] of entries) {
|
|
2205
|
+
if (typeof text !== "string" || !text.trim()) {
|
|
2206
|
+
throw new TaDeploymentError(`"reach.${language}" of ${TaDeploymentUtil2.DISTRIBUTION_FILE} is not a sentence.`);
|
|
2207
|
+
}
|
|
2208
|
+
result[language] = text.trim().slice(0, 200);
|
|
2209
|
+
}
|
|
2210
|
+
if (Object.keys(result).length === 0) {
|
|
2211
|
+
throw new TaDeploymentError(`"reach" of ${TaDeploymentUtil2.DISTRIBUTION_FILE} is a sentence, or one by language.`);
|
|
2212
|
+
}
|
|
2213
|
+
return result;
|
|
2214
|
+
}
|
|
2215
|
+
function reachIn(reach2, language) {
|
|
2216
|
+
var _a, _b, _c, _d, _e;
|
|
2217
|
+
if (!reach2) {
|
|
2218
|
+
return;
|
|
2219
|
+
}
|
|
2220
|
+
const base = language.split("-")[0];
|
|
2221
|
+
const near = Object.keys(reach2).find((key) => key.split("-")[0] === base);
|
|
2222
|
+
return (_e = (_d = (_c = (_b = (_a = reach2[language]) !== null && _a !== undefined ? _a : reach2[base]) !== null && _b !== undefined ? _b : near && reach2[near]) !== null && _c !== undefined ? _c : reach2["*"]) !== null && _d !== undefined ? _d : reach2.en) !== null && _e !== undefined ? _e : Object.values(reach2)[0];
|
|
2223
|
+
}
|
|
2224
|
+
TaDeploymentUtil2.reachIn = reachIn;
|
|
1421
2225
|
function apply(distribution2, env) {
|
|
1422
2226
|
const defaults = { TA_DEPLOYMENT_NAME: distribution2.name, TA_RELAY_URL: distribution2.relay, TA_GATEWAY_URL: distribution2.gateway };
|
|
1423
2227
|
for (const [key, value] of Object.entries(defaults)) {
|
|
@@ -1660,210 +2464,6 @@ var TaLocation;
|
|
|
1660
2464
|
return squeezed.length > 1 ? squeezed.replace(/\/$/, "") : squeezed;
|
|
1661
2465
|
}
|
|
1662
2466
|
})(TaLocation || (TaLocation = {}));
|
|
1663
|
-
// ../ta-protocol/esm/common/message-protocol.js
|
|
1664
|
-
var TaMessageContext;
|
|
1665
|
-
(function(TaMessageContext2) {
|
|
1666
|
-
const BLOCK = /^<context>\n?[\s\S]*?\n?<\/context>\n?/;
|
|
1667
|
-
function wrap(context, message) {
|
|
1668
|
-
return `<context>
|
|
1669
|
-
${context}
|
|
1670
|
-
</context>
|
|
1671
|
-
${message}`;
|
|
1672
|
-
}
|
|
1673
|
-
TaMessageContext2.wrap = wrap;
|
|
1674
|
-
function strip(message) {
|
|
1675
|
-
return message.replace(BLOCK, "");
|
|
1676
|
-
}
|
|
1677
|
-
TaMessageContext2.strip = strip;
|
|
1678
|
-
function read(message) {
|
|
1679
|
-
var _a;
|
|
1680
|
-
const block = (_a = BLOCK.exec(message)) === null || _a === undefined ? undefined : _a[0];
|
|
1681
|
-
return block === null || block === undefined ? undefined : block.replace(/^<context>\n?/, "").replace(/\n?<\/context>\n?$/, "");
|
|
1682
|
-
}
|
|
1683
|
-
TaMessageContext2.read = read;
|
|
1684
|
-
})(TaMessageContext || (TaMessageContext = {}));
|
|
1685
|
-
var TaMessageSource;
|
|
1686
|
-
(function(TaMessageSource2) {
|
|
1687
|
-
TaMessageSource2.DOUBLE = "ta:double";
|
|
1688
|
-
const LINE = /^\[ta:from ([^\s\]]+)(?: ([^\]\n]+))?\]$/m;
|
|
1689
|
-
function mark(message, from, detail) {
|
|
1690
|
-
if (/^[/!]/.test(message) || of(message)) {
|
|
1691
|
-
return message;
|
|
1692
|
-
}
|
|
1693
|
-
const line = `[ta:from ${from}${detail ? ` ${detail.replace(/[\]\n]/g, " ")}` : ""}]`;
|
|
1694
|
-
const context = TaMessageContext.read(message);
|
|
1695
|
-
return TaMessageContext.wrap(context === undefined ? line : `${context}
|
|
1696
|
-
${line}`, TaMessageContext.strip(message));
|
|
1697
|
-
}
|
|
1698
|
-
TaMessageSource2.mark = mark;
|
|
1699
|
-
function of(message) {
|
|
1700
|
-
const context = TaMessageContext.read(message);
|
|
1701
|
-
const match = context === undefined ? null : LINE.exec(context);
|
|
1702
|
-
return match ? { from: match[1], ...match[2] ? { detail: match[2].trim() } : {} } : undefined;
|
|
1703
|
-
}
|
|
1704
|
-
TaMessageSource2.of = of;
|
|
1705
|
-
})(TaMessageSource || (TaMessageSource = {}));
|
|
1706
|
-
var TaImageNote;
|
|
1707
|
-
(function(TaImageNote2) {
|
|
1708
|
-
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 [^\]]+\.\]$/;
|
|
1709
|
-
function strip(text) {
|
|
1710
|
-
const lines = text.split(`
|
|
1711
|
-
`);
|
|
1712
|
-
const kept = lines.filter((line) => !NOTE.test(line.trim()));
|
|
1713
|
-
if (kept.length === lines.length) {
|
|
1714
|
-
return text;
|
|
1715
|
-
}
|
|
1716
|
-
return kept.join(`
|
|
1717
|
-
`).replace(/\n+$/, "").replace(/^\n+/, "");
|
|
1718
|
-
}
|
|
1719
|
-
TaImageNote2.strip = strip;
|
|
1720
|
-
})(TaImageNote || (TaImageNote = {}));
|
|
1721
|
-
var TaImageSize;
|
|
1722
|
-
(function(TaImageSize2) {
|
|
1723
|
-
const JPEG_BYTES = 256 * 1024;
|
|
1724
|
-
function of(base64) {
|
|
1725
|
-
var _a, _b, _c;
|
|
1726
|
-
let bytes;
|
|
1727
|
-
try {
|
|
1728
|
-
const binary = atob(base64.slice(0, Math.ceil(JPEG_BYTES * 4 / 3 / 4) * 4));
|
|
1729
|
-
bytes = Uint8Array.from(binary, (char) => char.charCodeAt(0));
|
|
1730
|
-
} catch (_d) {
|
|
1731
|
-
return;
|
|
1732
|
-
}
|
|
1733
|
-
const size = (_c = (_b = (_a = png(bytes)) !== null && _a !== undefined ? _a : gif(bytes)) !== null && _b !== undefined ? _b : webp(bytes)) !== null && _c !== undefined ? _c : jpeg(bytes);
|
|
1734
|
-
return size && size.width > 0 && size.height > 0 ? size : undefined;
|
|
1735
|
-
}
|
|
1736
|
-
TaImageSize2.of = of;
|
|
1737
|
-
function u16be(bytes, at) {
|
|
1738
|
-
return bytes[at] << 8 | bytes[at + 1];
|
|
1739
|
-
}
|
|
1740
|
-
function u16le(bytes, at) {
|
|
1741
|
-
return bytes[at] | bytes[at + 1] << 8;
|
|
1742
|
-
}
|
|
1743
|
-
function u24le(bytes, at) {
|
|
1744
|
-
return bytes[at] | bytes[at + 1] << 8 | bytes[at + 2] << 16;
|
|
1745
|
-
}
|
|
1746
|
-
function u32be(bytes, at) {
|
|
1747
|
-
return (bytes[at] << 24 | bytes[at + 1] << 16 | bytes[at + 2] << 8 | bytes[at + 3]) >>> 0;
|
|
1748
|
-
}
|
|
1749
|
-
function text(bytes, at, length) {
|
|
1750
|
-
return String.fromCharCode(...bytes.subarray(at, at + length));
|
|
1751
|
-
}
|
|
1752
|
-
function png(bytes) {
|
|
1753
|
-
return bytes.length >= 24 && bytes[0] === 137 && text(bytes, 1, 3) === "PNG" ? { width: u32be(bytes, 16), height: u32be(bytes, 20) } : undefined;
|
|
1754
|
-
}
|
|
1755
|
-
function gif(bytes) {
|
|
1756
|
-
return bytes.length >= 10 && text(bytes, 0, 3) === "GIF" ? { width: u16le(bytes, 6), height: u16le(bytes, 8) } : undefined;
|
|
1757
|
-
}
|
|
1758
|
-
function webp(bytes) {
|
|
1759
|
-
if (bytes.length < 30 || text(bytes, 0, 4) !== "RIFF" || text(bytes, 8, 4) !== "WEBP") {
|
|
1760
|
-
return;
|
|
1761
|
-
}
|
|
1762
|
-
switch (text(bytes, 12, 4)) {
|
|
1763
|
-
case "VP8 ":
|
|
1764
|
-
return { width: u16le(bytes, 26) & 16383, height: u16le(bytes, 28) & 16383 };
|
|
1765
|
-
case "VP8L": {
|
|
1766
|
-
const bits = bytes[21] | bytes[22] << 8 | bytes[23] << 16 | bytes[24] << 24;
|
|
1767
|
-
return { width: (bits & 16383) + 1, height: (bits >> 14 & 16383) + 1 };
|
|
1768
|
-
}
|
|
1769
|
-
case "VP8X":
|
|
1770
|
-
return { width: u24le(bytes, 24) + 1, height: u24le(bytes, 27) + 1 };
|
|
1771
|
-
default:
|
|
1772
|
-
return;
|
|
1773
|
-
}
|
|
1774
|
-
}
|
|
1775
|
-
function jpeg(bytes) {
|
|
1776
|
-
if (bytes[0] !== 255 || bytes[1] !== 216) {
|
|
1777
|
-
return;
|
|
1778
|
-
}
|
|
1779
|
-
let at = 2;
|
|
1780
|
-
while (at + 9 < bytes.length) {
|
|
1781
|
-
if (bytes[at] !== 255) {
|
|
1782
|
-
return;
|
|
1783
|
-
}
|
|
1784
|
-
const marker = bytes[at + 1];
|
|
1785
|
-
if (marker >= 192 && marker <= 207 && marker !== 196 && marker !== 200 && marker !== 204) {
|
|
1786
|
-
return { width: u16be(bytes, at + 7), height: u16be(bytes, at + 5) };
|
|
1787
|
-
}
|
|
1788
|
-
at += 2 + u16be(bytes, at + 2);
|
|
1789
|
-
}
|
|
1790
|
-
return;
|
|
1791
|
-
}
|
|
1792
|
-
})(TaImageSize || (TaImageSize = {}));
|
|
1793
|
-
var TaAgentSummary;
|
|
1794
|
-
(function(TaAgentSummary2) {
|
|
1795
|
-
const START = /^\s*<conversation_history_summary>/;
|
|
1796
|
-
const BLOCK = /^\s*<conversation_history_summary>[\s\S]*?(?:<\/conversation_history_summary>\s*|$)/;
|
|
1797
|
-
function read(text) {
|
|
1798
|
-
if (!START.test(text)) {
|
|
1799
|
-
return;
|
|
1800
|
-
}
|
|
1801
|
-
return text.replace(/<\/?(?:conversation_history_summary|summary)>/g, "").replace(/<\/?\w*$/, "").trim();
|
|
1802
|
-
}
|
|
1803
|
-
TaAgentSummary2.read = read;
|
|
1804
|
-
function strip(text) {
|
|
1805
|
-
return text.replace(BLOCK, "");
|
|
1806
|
-
}
|
|
1807
|
-
TaAgentSummary2.strip = strip;
|
|
1808
|
-
})(TaAgentSummary || (TaAgentSummary = {}));
|
|
1809
|
-
var TaSkillUse;
|
|
1810
|
-
(function(TaSkillUse2) {
|
|
1811
|
-
const BLOCK = /^<skill name="([^"]+)" location="([^"]+)">\n([\s\S]*?)\n<\/skill>(?:\n\n([\s\S]+))?$/;
|
|
1812
|
-
function parse(message) {
|
|
1813
|
-
var _a;
|
|
1814
|
-
const match = BLOCK.exec(message);
|
|
1815
|
-
if (!match) {
|
|
1816
|
-
return;
|
|
1817
|
-
}
|
|
1818
|
-
return { name: match[1], location: match[2], content: match[3], message: ((_a = match[4]) === null || _a === undefined ? undefined : _a.trim()) || undefined };
|
|
1819
|
-
}
|
|
1820
|
-
TaSkillUse2.parse = parse;
|
|
1821
|
-
function command(use) {
|
|
1822
|
-
return use.message ? `/skill:${use.name} ${use.message}` : `/skill:${use.name}`;
|
|
1823
|
-
}
|
|
1824
|
-
TaSkillUse2.command = command;
|
|
1825
|
-
})(TaSkillUse || (TaSkillUse = {}));
|
|
1826
|
-
var TaTaskNote;
|
|
1827
|
-
(function(TaTaskNote2) {
|
|
1828
|
-
const NOTE = /^<task_(update|adopted|renamed) ((?:[^>"\n]|"[^"]*")*)>\n?([\s\S]*?)\n?<\/task_\1>$/;
|
|
1829
|
-
const ATTRIBUTE = /(\w+)="([^"]*)"/g;
|
|
1830
|
-
function write(note) {
|
|
1831
|
-
const attributes = [`id="${quote(note.id)}"`];
|
|
1832
|
-
if (note.was !== undefined) {
|
|
1833
|
-
attributes.push(`was="${quote(note.was)}"`);
|
|
1834
|
-
}
|
|
1835
|
-
attributes.push(`title="${quote(note.title)}"`);
|
|
1836
|
-
if (note.status !== undefined) {
|
|
1837
|
-
attributes.push(`status="${quote(note.status)}"`);
|
|
1838
|
-
}
|
|
1839
|
-
return `<task_${note.kind} ${attributes.join(" ")}>
|
|
1840
|
-
${note.body}
|
|
1841
|
-
</task_${note.kind}>`;
|
|
1842
|
-
}
|
|
1843
|
-
TaTaskNote2.write = write;
|
|
1844
|
-
function parse(text) {
|
|
1845
|
-
const match = NOTE.exec(text.trim());
|
|
1846
|
-
if (!match) {
|
|
1847
|
-
return;
|
|
1848
|
-
}
|
|
1849
|
-
const attributes = {};
|
|
1850
|
-
for (const [, name, value] of match[2].matchAll(ATTRIBUTE)) {
|
|
1851
|
-
attributes[name] = unquote(value);
|
|
1852
|
-
}
|
|
1853
|
-
if (!attributes.id || attributes.title === undefined) {
|
|
1854
|
-
return;
|
|
1855
|
-
}
|
|
1856
|
-
const { id, title, status, was } = attributes;
|
|
1857
|
-
return { kind: match[1], id, title, ...status ? { status } : {}, ...was ? { was } : {}, body: match[3] };
|
|
1858
|
-
}
|
|
1859
|
-
TaTaskNote2.parse = parse;
|
|
1860
|
-
function quote(text) {
|
|
1861
|
-
return text.replace(/&/g, "&").replace(/"/g, """).replace(/\n/g, " ");
|
|
1862
|
-
}
|
|
1863
|
-
function unquote(text) {
|
|
1864
|
-
return text.replace(/"/g, '"').replace(/&/g, "&");
|
|
1865
|
-
}
|
|
1866
|
-
})(TaTaskNote || (TaTaskNote = {}));
|
|
1867
2467
|
// ../ta-protocol/esm/common/package-protocol.js
|
|
1868
2468
|
var TaPackageServer = Symbol("TaPackageServer");
|
|
1869
2469
|
var TaPackageTextUtil;
|
|
@@ -2060,6 +2660,48 @@ var TaRoomWatchUtil;
|
|
|
2060
2660
|
}
|
|
2061
2661
|
TaRoomWatchUtil2.hears = hears;
|
|
2062
2662
|
})(TaRoomWatchUtil || (TaRoomWatchUtil = {}));
|
|
2663
|
+
// ../ta-protocol/esm/common/screen-share-protocol.js
|
|
2664
|
+
var TaScreenShareServer = Symbol("TaScreenShareServer");
|
|
2665
|
+
var TaDesktopUtil;
|
|
2666
|
+
(function(TaDesktopUtil2) {
|
|
2667
|
+
TaDesktopUtil2.DEFAULT_PORT = 5900;
|
|
2668
|
+
function id(target) {
|
|
2669
|
+
var _a;
|
|
2670
|
+
return `${(_a = target.via) !== null && _a !== undefined ? _a : ""}|${host(target)}:${port(target)}`;
|
|
2671
|
+
}
|
|
2672
|
+
TaDesktopUtil2.id = id;
|
|
2673
|
+
function host(target) {
|
|
2674
|
+
var _a;
|
|
2675
|
+
return ((_a = target.host) !== null && _a !== undefined ? _a : "").trim() || "127.0.0.1";
|
|
2676
|
+
}
|
|
2677
|
+
TaDesktopUtil2.host = host;
|
|
2678
|
+
function port(target) {
|
|
2679
|
+
var _a;
|
|
2680
|
+
return (_a = target.port) !== null && _a !== undefined ? _a : TaDesktopUtil2.DEFAULT_PORT;
|
|
2681
|
+
}
|
|
2682
|
+
TaDesktopUtil2.port = port;
|
|
2683
|
+
function parse(id2) {
|
|
2684
|
+
const match = /^([^|]*)\|(.+):(\d+)$/.exec(String(id2 !== null && id2 !== undefined ? id2 : ""));
|
|
2685
|
+
if (!match) {
|
|
2686
|
+
return;
|
|
2687
|
+
}
|
|
2688
|
+
const port2 = Number(match[3]);
|
|
2689
|
+
return port2 > 0 && port2 < 65536 ? { via: match[1], host: match[2], port: port2 } : undefined;
|
|
2690
|
+
}
|
|
2691
|
+
TaDesktopUtil2.parse = parse;
|
|
2692
|
+
function validPort(port2) {
|
|
2693
|
+
return typeof port2 === "number" && Number.isInteger(port2) && port2 >= 1024 && port2 < 65536;
|
|
2694
|
+
}
|
|
2695
|
+
TaDesktopUtil2.validPort = validPort;
|
|
2696
|
+
function loopback(host2) {
|
|
2697
|
+
return /^(127\.\d+\.\d+\.\d+|localhost|::1|\[::1\])$/i.test(host2);
|
|
2698
|
+
}
|
|
2699
|
+
TaDesktopUtil2.loopback = loopback;
|
|
2700
|
+
function validHost(host2) {
|
|
2701
|
+
return typeof host2 === "string" && /^[A-Za-z0-9.:\-[\]]{1,253}$/.test(host2);
|
|
2702
|
+
}
|
|
2703
|
+
TaDesktopUtil2.validHost = validHost;
|
|
2704
|
+
})(TaDesktopUtil || (TaDesktopUtil = {}));
|
|
2063
2705
|
// ../ta-protocol/esm/common/settings-protocol.js
|
|
2064
2706
|
var TaSettingsServer = Symbol("TaSettingsServer");
|
|
2065
2707
|
// ../ta-protocol/esm/common/ta-protocol.js
|
|
@@ -2078,6 +2720,53 @@ var TaSlashCommandUtil;
|
|
|
2078
2720
|
var TaUsageServer = Symbol("TaUsageServer");
|
|
2079
2721
|
// ../ta-protocol/esm/common/voice-protocol.js
|
|
2080
2722
|
var TaVoiceServer = Symbol("TaVoiceServer");
|
|
2723
|
+
var TaBargeIn;
|
|
2724
|
+
(function(TaBargeIn2) {
|
|
2725
|
+
TaBargeIn2.DEFAULTS = { duck: 0.2, speechMs: 500, level: 0.02, words: 2, waitMs: 1500, echo: 0.3, joinMs: 300, tap: false };
|
|
2726
|
+
TaBargeIn2.SENSITIVITY = [
|
|
2727
|
+
{ speechMs: 1000, level: 0.05 },
|
|
2728
|
+
{ speechMs: 750, level: 0.035 },
|
|
2729
|
+
{ speechMs: TaBargeIn2.DEFAULTS.speechMs, level: TaBargeIn2.DEFAULTS.level },
|
|
2730
|
+
{ speechMs: 300, level: 0.012 },
|
|
2731
|
+
{ speechMs: 150, level: 0.006 }
|
|
2732
|
+
];
|
|
2733
|
+
function sensitivity(bargeIn) {
|
|
2734
|
+
let nearest = 0;
|
|
2735
|
+
TaBargeIn2.SENSITIVITY.forEach((step, index) => {
|
|
2736
|
+
if (Math.abs(step.speechMs - bargeIn.speechMs) < Math.abs(TaBargeIn2.SENSITIVITY[nearest].speechMs - bargeIn.speechMs)) {
|
|
2737
|
+
nearest = index;
|
|
2738
|
+
}
|
|
2739
|
+
});
|
|
2740
|
+
return nearest;
|
|
2741
|
+
}
|
|
2742
|
+
TaBargeIn2.sensitivity = sensitivity;
|
|
2743
|
+
function pick(value) {
|
|
2744
|
+
const given = value && typeof value === "object" ? value : {};
|
|
2745
|
+
const out = typeof given.tap === "boolean" ? { tap: given.tap } : {};
|
|
2746
|
+
for (const key of Object.keys(RANGES)) {
|
|
2747
|
+
const number = given[key];
|
|
2748
|
+
if (typeof number === "number" && Number.isFinite(number)) {
|
|
2749
|
+
const [min, max] = RANGES[key];
|
|
2750
|
+
out[key] = Math.min(max, Math.max(min, number));
|
|
2751
|
+
}
|
|
2752
|
+
}
|
|
2753
|
+
return out;
|
|
2754
|
+
}
|
|
2755
|
+
TaBargeIn2.pick = pick;
|
|
2756
|
+
const RANGES = {
|
|
2757
|
+
duck: [0, 1],
|
|
2758
|
+
speechMs: [0, 5000],
|
|
2759
|
+
level: [0, 1],
|
|
2760
|
+
words: [1, 50],
|
|
2761
|
+
waitMs: [100, 1e4],
|
|
2762
|
+
echo: [0, 4],
|
|
2763
|
+
joinMs: [0, 3000]
|
|
2764
|
+
};
|
|
2765
|
+
function resolve(value) {
|
|
2766
|
+
return { ...TaBargeIn2.DEFAULTS, ...pick(value) };
|
|
2767
|
+
}
|
|
2768
|
+
TaBargeIn2.resolve = resolve;
|
|
2769
|
+
})(TaBargeIn || (TaBargeIn = {}));
|
|
2081
2770
|
// ../ta-protocol/esm/common/workspace-protocol.js
|
|
2082
2771
|
var TaWorkspaceServer = Symbol("TaWorkspaceServer");
|
|
2083
2772
|
var TaTerminalServer = Symbol("TaTerminalServer");
|