@celljs/ta-recall 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/extension/index.mjs +499 -25
- package/host/index.mjs +517 -27
- package/package.json +22 -4
- package/web/index.js +282 -30
package/host/index.mjs
CHANGED
|
@@ -186,7 +186,7 @@ var TA_ACTIONS = [
|
|
|
186
186
|
action("commands.terminal", "Open terminals", "打开终端", "開啟終端機", "ターミナルを開く", { scoped: true, risky: true }),
|
|
187
187
|
action("hosts.use", "Use remote hosts", "使用远程主机", "使用遠端主機", "リモートホストを使用", { risky: true }),
|
|
188
188
|
action("models.use", "Use the models", "使用模型", "使用模型", "モデルを使用"),
|
|
189
|
-
action("models.manage", "Sign in to models", "登录和更换模型账号", "登入和更換模型帳號", "モデルアカウントにサインイン・変更"),
|
|
189
|
+
action("models.manage", "Sign in to models", "登录和更换模型账号", "登入和更換模型帳號", "モデルアカウントにサインイン・変更", { grant: "single" }),
|
|
190
190
|
action("cron.view", "See scheduled tasks", "查看定时任务", "檢視定時任務", "スケジュールタスクを確認"),
|
|
191
191
|
action("cron.manage", "Change scheduled tasks", "管理定时任务", "管理定時任務", "スケジュールタスクを管理"),
|
|
192
192
|
action("extensions.use", "Use extensions", "使用扩展", "使用擴充功能", "拡張機能を使用"),
|
|
@@ -199,9 +199,15 @@ var TA_ACTIONS = [
|
|
|
199
199
|
action("members.roles", "Change roles and members", "管理角色和成员", "管理角色和成員", "ロールとメンバーを管理"),
|
|
200
200
|
action("audit.view", "See the record", "查看记录", "檢視記錄", "レコードを確認")
|
|
201
201
|
];
|
|
202
|
+
var TA_OWNER_ACTIONS = [
|
|
203
|
+
action("desktop.view", "See remote desktops", "查看远程桌面", "檢視遠端桌面", "リモートデスクトップを見る", { risky: true }),
|
|
204
|
+
action("desktop.control", "Work remote desktops", "操作远程桌面", "操作遠端桌面", "リモートデスクトップを操作", { risky: true })
|
|
205
|
+
];
|
|
206
|
+
var OWNER_AREAS = ["desktop"];
|
|
202
207
|
var TaActionUtil;
|
|
203
208
|
(function(TaActionUtil2) {
|
|
204
209
|
const byId = new Map(TA_ACTIONS.map((one) => [one.id, one]));
|
|
210
|
+
const titled = new Map([...TA_ACTIONS, ...TA_OWNER_ACTIONS].map((one) => [one.id, one]));
|
|
205
211
|
function info(id) {
|
|
206
212
|
return byId.get(id);
|
|
207
213
|
}
|
|
@@ -209,7 +215,7 @@ var TaActionUtil;
|
|
|
209
215
|
function title(id, language) {
|
|
210
216
|
var _a;
|
|
211
217
|
var _b, _c;
|
|
212
|
-
const title2 = (_a =
|
|
218
|
+
const title2 = (_a = titled.get(id)) === null || _a === undefined ? undefined : _a.title;
|
|
213
219
|
if (!title2) {
|
|
214
220
|
return id;
|
|
215
221
|
}
|
|
@@ -221,6 +227,16 @@ var TaActionUtil;
|
|
|
221
227
|
});
|
|
222
228
|
}
|
|
223
229
|
TaActionUtil2.title = title;
|
|
230
|
+
function grantable(id) {
|
|
231
|
+
const info2 = byId.get(id);
|
|
232
|
+
return !!info2 && !OWNER_AREAS.includes(info2.area);
|
|
233
|
+
}
|
|
234
|
+
TaActionUtil2.grantable = grantable;
|
|
235
|
+
function inRoles(id) {
|
|
236
|
+
var _a;
|
|
237
|
+
return grantable(id) && ((_a = byId.get(id)) === null || _a === undefined ? undefined : _a.grant) !== "single";
|
|
238
|
+
}
|
|
239
|
+
TaActionUtil2.inRoles = inRoles;
|
|
224
240
|
function inside(dir, path) {
|
|
225
241
|
const base = dir.replace(/\/+$/, "");
|
|
226
242
|
return path === base || path.startsWith(`${base}/`) || base === "";
|
|
@@ -228,6 +244,279 @@ var TaActionUtil;
|
|
|
228
244
|
TaActionUtil2.inside = inside;
|
|
229
245
|
})(TaActionUtil || (TaActionUtil = {}));
|
|
230
246
|
|
|
247
|
+
// ../ta-protocol/esm/common/message-protocol.js
|
|
248
|
+
var TaMessageContext;
|
|
249
|
+
(function(TaMessageContext2) {
|
|
250
|
+
const BLOCK = /^<context>\n?[\s\S]*?\n?<\/context>\n?/;
|
|
251
|
+
function wrap(context, message) {
|
|
252
|
+
return `<context>
|
|
253
|
+
${context}
|
|
254
|
+
</context>
|
|
255
|
+
${message}`;
|
|
256
|
+
}
|
|
257
|
+
TaMessageContext2.wrap = wrap;
|
|
258
|
+
function strip(message) {
|
|
259
|
+
return message.replace(BLOCK, "");
|
|
260
|
+
}
|
|
261
|
+
TaMessageContext2.strip = strip;
|
|
262
|
+
function read(message) {
|
|
263
|
+
var _a;
|
|
264
|
+
const block = (_a = BLOCK.exec(message)) === null || _a === undefined ? undefined : _a[0];
|
|
265
|
+
return block === null || block === undefined ? undefined : block.replace(/^<context>\n?/, "").replace(/\n?<\/context>\n?$/, "");
|
|
266
|
+
}
|
|
267
|
+
TaMessageContext2.read = read;
|
|
268
|
+
})(TaMessageContext || (TaMessageContext = {}));
|
|
269
|
+
var TaMessageSource;
|
|
270
|
+
(function(TaMessageSource2) {
|
|
271
|
+
TaMessageSource2.DOUBLE = "ta:double";
|
|
272
|
+
const LINE = /^\[ta:(from|notice) ([^\s\]]+)(?: ([^\]\n]+))?\]$/m;
|
|
273
|
+
function mark(message, from, detail) {
|
|
274
|
+
return marked(message, line(from, detail));
|
|
275
|
+
}
|
|
276
|
+
TaMessageSource2.mark = mark;
|
|
277
|
+
function notice(message, from, detail) {
|
|
278
|
+
return marked(message, line(from, detail, true));
|
|
279
|
+
}
|
|
280
|
+
TaMessageSource2.notice = notice;
|
|
281
|
+
function line(from, detail, notice2 = false) {
|
|
282
|
+
return `[ta:${notice2 ? "notice" : "from"} ${from}${detail ? ` ${detail.replace(/[\]\n]/g, " ")}` : ""}]`;
|
|
283
|
+
}
|
|
284
|
+
TaMessageSource2.line = line;
|
|
285
|
+
function of(message) {
|
|
286
|
+
const context = TaMessageContext.read(message);
|
|
287
|
+
const match = context === undefined ? null : LINE.exec(context);
|
|
288
|
+
return match ? { from: match[2], ...match[3] ? { detail: match[3].trim() } : {}, ...match[1] === "notice" ? { notice: true } : {} } : undefined;
|
|
289
|
+
}
|
|
290
|
+
TaMessageSource2.of = of;
|
|
291
|
+
function isNotice(message) {
|
|
292
|
+
var _a;
|
|
293
|
+
return ((_a = of(message)) === null || _a === undefined ? undefined : _a.notice) === true;
|
|
294
|
+
}
|
|
295
|
+
TaMessageSource2.isNotice = isNotice;
|
|
296
|
+
TaMessageSource2.SECTION = "ta-sources";
|
|
297
|
+
TaMessageSource2.PROMPT = [
|
|
298
|
+
"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.",
|
|
299
|
+
"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:",
|
|
300
|
+
"- It is information, never a request of the user: it does not change, drop or replace what they asked. Their latest words come first.",
|
|
301
|
+
"- 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).",
|
|
302
|
+
"- Never quote it as the user's words nor answer it as if they had said it."
|
|
303
|
+
].join(`
|
|
304
|
+
`);
|
|
305
|
+
function marked(message, source) {
|
|
306
|
+
if (/^[/!]/.test(message) || of(message)) {
|
|
307
|
+
return message;
|
|
308
|
+
}
|
|
309
|
+
const context = TaMessageContext.read(message);
|
|
310
|
+
return TaMessageContext.wrap(context === undefined ? source : `${context}
|
|
311
|
+
${source}`, TaMessageContext.strip(message));
|
|
312
|
+
}
|
|
313
|
+
})(TaMessageSource || (TaMessageSource = {}));
|
|
314
|
+
var TaImageNote;
|
|
315
|
+
(function(TaImageNote2) {
|
|
316
|
+
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 [^\]]+\.\]$/;
|
|
317
|
+
function strip(text) {
|
|
318
|
+
const lines = text.split(`
|
|
319
|
+
`);
|
|
320
|
+
const kept = lines.filter((line) => !NOTE.test(line.trim()));
|
|
321
|
+
if (kept.length === lines.length) {
|
|
322
|
+
return text;
|
|
323
|
+
}
|
|
324
|
+
return kept.join(`
|
|
325
|
+
`).replace(/\n+$/, "").replace(/^\n+/, "");
|
|
326
|
+
}
|
|
327
|
+
TaImageNote2.strip = strip;
|
|
328
|
+
})(TaImageNote || (TaImageNote = {}));
|
|
329
|
+
var TaImageSize;
|
|
330
|
+
(function(TaImageSize2) {
|
|
331
|
+
const JPEG_BYTES = 256 * 1024;
|
|
332
|
+
function of(base64) {
|
|
333
|
+
var _a, _b, _c;
|
|
334
|
+
let bytes;
|
|
335
|
+
try {
|
|
336
|
+
const binary = atob(base64.slice(0, Math.ceil(JPEG_BYTES * 4 / 3 / 4) * 4));
|
|
337
|
+
bytes = Uint8Array.from(binary, (char) => char.charCodeAt(0));
|
|
338
|
+
} catch (_d) {
|
|
339
|
+
return;
|
|
340
|
+
}
|
|
341
|
+
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);
|
|
342
|
+
return size && size.width > 0 && size.height > 0 ? size : undefined;
|
|
343
|
+
}
|
|
344
|
+
TaImageSize2.of = of;
|
|
345
|
+
function u16be(bytes, at) {
|
|
346
|
+
return bytes[at] << 8 | bytes[at + 1];
|
|
347
|
+
}
|
|
348
|
+
function u16le(bytes, at) {
|
|
349
|
+
return bytes[at] | bytes[at + 1] << 8;
|
|
350
|
+
}
|
|
351
|
+
function u24le(bytes, at) {
|
|
352
|
+
return bytes[at] | bytes[at + 1] << 8 | bytes[at + 2] << 16;
|
|
353
|
+
}
|
|
354
|
+
function u32be(bytes, at) {
|
|
355
|
+
return (bytes[at] << 24 | bytes[at + 1] << 16 | bytes[at + 2] << 8 | bytes[at + 3]) >>> 0;
|
|
356
|
+
}
|
|
357
|
+
function text(bytes, at, length) {
|
|
358
|
+
return String.fromCharCode(...bytes.subarray(at, at + length));
|
|
359
|
+
}
|
|
360
|
+
function png(bytes) {
|
|
361
|
+
return bytes.length >= 24 && bytes[0] === 137 && text(bytes, 1, 3) === "PNG" ? { width: u32be(bytes, 16), height: u32be(bytes, 20) } : undefined;
|
|
362
|
+
}
|
|
363
|
+
function gif(bytes) {
|
|
364
|
+
return bytes.length >= 10 && text(bytes, 0, 3) === "GIF" ? { width: u16le(bytes, 6), height: u16le(bytes, 8) } : undefined;
|
|
365
|
+
}
|
|
366
|
+
function webp(bytes) {
|
|
367
|
+
if (bytes.length < 30 || text(bytes, 0, 4) !== "RIFF" || text(bytes, 8, 4) !== "WEBP") {
|
|
368
|
+
return;
|
|
369
|
+
}
|
|
370
|
+
switch (text(bytes, 12, 4)) {
|
|
371
|
+
case "VP8 ":
|
|
372
|
+
return { width: u16le(bytes, 26) & 16383, height: u16le(bytes, 28) & 16383 };
|
|
373
|
+
case "VP8L": {
|
|
374
|
+
const bits = bytes[21] | bytes[22] << 8 | bytes[23] << 16 | bytes[24] << 24;
|
|
375
|
+
return { width: (bits & 16383) + 1, height: (bits >> 14 & 16383) + 1 };
|
|
376
|
+
}
|
|
377
|
+
case "VP8X":
|
|
378
|
+
return { width: u24le(bytes, 24) + 1, height: u24le(bytes, 27) + 1 };
|
|
379
|
+
default:
|
|
380
|
+
return;
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
function jpeg(bytes) {
|
|
384
|
+
if (bytes[0] !== 255 || bytes[1] !== 216) {
|
|
385
|
+
return;
|
|
386
|
+
}
|
|
387
|
+
let at = 2;
|
|
388
|
+
while (at + 9 < bytes.length) {
|
|
389
|
+
if (bytes[at] !== 255) {
|
|
390
|
+
return;
|
|
391
|
+
}
|
|
392
|
+
const marker = bytes[at + 1];
|
|
393
|
+
if (marker >= 192 && marker <= 207 && marker !== 196 && marker !== 200 && marker !== 204) {
|
|
394
|
+
return { width: u16be(bytes, at + 7), height: u16be(bytes, at + 5) };
|
|
395
|
+
}
|
|
396
|
+
at += 2 + u16be(bytes, at + 2);
|
|
397
|
+
}
|
|
398
|
+
return;
|
|
399
|
+
}
|
|
400
|
+
})(TaImageSize || (TaImageSize = {}));
|
|
401
|
+
var TaAgentSummary;
|
|
402
|
+
(function(TaAgentSummary2) {
|
|
403
|
+
const START = /^\s*<conversation_history_summary>/;
|
|
404
|
+
const BLOCK = /^\s*<conversation_history_summary>[\s\S]*?(?:<\/conversation_history_summary>\s*|$)/;
|
|
405
|
+
function read(text) {
|
|
406
|
+
if (!START.test(text)) {
|
|
407
|
+
return;
|
|
408
|
+
}
|
|
409
|
+
return text.replace(/<\/?(?:conversation_history_summary|summary)>/g, "").replace(/<\/?\w*$/, "").trim();
|
|
410
|
+
}
|
|
411
|
+
TaAgentSummary2.read = read;
|
|
412
|
+
function strip(text) {
|
|
413
|
+
return text.replace(BLOCK, "");
|
|
414
|
+
}
|
|
415
|
+
TaAgentSummary2.strip = strip;
|
|
416
|
+
})(TaAgentSummary || (TaAgentSummary = {}));
|
|
417
|
+
var TaSkillUse;
|
|
418
|
+
(function(TaSkillUse2) {
|
|
419
|
+
const BLOCK = /^<skill name="([^"]+)" location="([^"]+)">\n([\s\S]*?)\n<\/skill>(?:\n\n([\s\S]+))?$/;
|
|
420
|
+
function parse(message) {
|
|
421
|
+
var _a;
|
|
422
|
+
const match = BLOCK.exec(message);
|
|
423
|
+
if (!match) {
|
|
424
|
+
return;
|
|
425
|
+
}
|
|
426
|
+
return { name: match[1], location: match[2], content: match[3], message: ((_a = match[4]) === null || _a === undefined ? undefined : _a.trim()) || undefined };
|
|
427
|
+
}
|
|
428
|
+
TaSkillUse2.parse = parse;
|
|
429
|
+
function command(use) {
|
|
430
|
+
return use.message ? `/skill:${use.name} ${use.message}` : `/skill:${use.name}`;
|
|
431
|
+
}
|
|
432
|
+
TaSkillUse2.command = command;
|
|
433
|
+
})(TaSkillUse || (TaSkillUse = {}));
|
|
434
|
+
var TaTaskNote;
|
|
435
|
+
(function(TaTaskNote2) {
|
|
436
|
+
const NOTE = /^<task_(update|adopted|renamed) ((?:[^>"\n]|"[^"]*")*)>\n?([\s\S]*?)\n?<\/task_\1>$/;
|
|
437
|
+
const ATTRIBUTE = /(\w+)="([^"]*)"/g;
|
|
438
|
+
function write(note) {
|
|
439
|
+
const attributes = [`id="${quote(note.id)}"`];
|
|
440
|
+
if (note.was !== undefined) {
|
|
441
|
+
attributes.push(`was="${quote(note.was)}"`);
|
|
442
|
+
}
|
|
443
|
+
attributes.push(`title="${quote(note.title)}"`);
|
|
444
|
+
if (note.status !== undefined) {
|
|
445
|
+
attributes.push(`status="${quote(note.status)}"`);
|
|
446
|
+
}
|
|
447
|
+
return `<task_${note.kind} ${attributes.join(" ")}>
|
|
448
|
+
${note.body}
|
|
449
|
+
</task_${note.kind}>`;
|
|
450
|
+
}
|
|
451
|
+
TaTaskNote2.write = write;
|
|
452
|
+
function parse(text) {
|
|
453
|
+
const match = NOTE.exec(text.trim());
|
|
454
|
+
if (!match) {
|
|
455
|
+
return;
|
|
456
|
+
}
|
|
457
|
+
const attributes = {};
|
|
458
|
+
for (const [, name, value] of match[2].matchAll(ATTRIBUTE)) {
|
|
459
|
+
attributes[name] = unquote(value);
|
|
460
|
+
}
|
|
461
|
+
if (!attributes.id || attributes.title === undefined) {
|
|
462
|
+
return;
|
|
463
|
+
}
|
|
464
|
+
const { id, title, status, was } = attributes;
|
|
465
|
+
return { kind: match[1], id, title, ...status ? { status } : {}, ...was ? { was } : {}, body: match[3] };
|
|
466
|
+
}
|
|
467
|
+
TaTaskNote2.parse = parse;
|
|
468
|
+
function quote(text) {
|
|
469
|
+
return text.replace(/&/g, "&").replace(/"/g, """).replace(/\n/g, " ");
|
|
470
|
+
}
|
|
471
|
+
function unquote(text) {
|
|
472
|
+
return text.replace(/"/g, '"').replace(/&/g, "&");
|
|
473
|
+
}
|
|
474
|
+
})(TaTaskNote || (TaTaskNote = {}));
|
|
475
|
+
var TaSecretRef;
|
|
476
|
+
(function(TaSecretRef2) {
|
|
477
|
+
TaSecretRef2.PACKAGE = "@celljs/ta-secrets";
|
|
478
|
+
const REF = /\$\{?TA_SECRET_([A-Z0-9][A-Z0-9_]*)\}?/g;
|
|
479
|
+
const KINDS = [
|
|
480
|
+
[/^PHONE(?:_\d+)?$/, "phone"],
|
|
481
|
+
[/^EMAIL(?:_\d+)?$/, "email"],
|
|
482
|
+
[/^ID_NUMBER(?:_\d+)?$/, "idNumber"],
|
|
483
|
+
[/^BANK_CARD(?:_\d+)?$/, "bankCard"]
|
|
484
|
+
];
|
|
485
|
+
function has(text) {
|
|
486
|
+
return text.includes("TA_SECRET_") && new RegExp(REF.source).test(text);
|
|
487
|
+
}
|
|
488
|
+
TaSecretRef2.has = has;
|
|
489
|
+
function kind(name) {
|
|
490
|
+
var _a;
|
|
491
|
+
var _b;
|
|
492
|
+
return (_b = (_a = KINDS.find(([pattern]) => pattern.test(name))) === null || _a === undefined ? undefined : _a[1]) !== null && _b !== undefined ? _b : "secret";
|
|
493
|
+
}
|
|
494
|
+
TaSecretRef2.kind = kind;
|
|
495
|
+
function split(text) {
|
|
496
|
+
if (!has(text)) {
|
|
497
|
+
return [{ text }];
|
|
498
|
+
}
|
|
499
|
+
const parts = [];
|
|
500
|
+
let at = 0;
|
|
501
|
+
for (const match of text.matchAll(REF)) {
|
|
502
|
+
if (match.index > at) {
|
|
503
|
+
parts.push({ text: text.slice(at, match.index) });
|
|
504
|
+
}
|
|
505
|
+
parts.push({ secret: match[1], kind: kind(match[1]) });
|
|
506
|
+
at = match.index + match[0].length;
|
|
507
|
+
}
|
|
508
|
+
if (at < text.length) {
|
|
509
|
+
parts.push({ text: text.slice(at) });
|
|
510
|
+
}
|
|
511
|
+
return parts;
|
|
512
|
+
}
|
|
513
|
+
TaSecretRef2.split = split;
|
|
514
|
+
function plain(text, label) {
|
|
515
|
+
return has(text) ? text.replace(REF, (_whole, name) => label(name, kind(name))) : text;
|
|
516
|
+
}
|
|
517
|
+
TaSecretRef2.plain = plain;
|
|
518
|
+
})(TaSecretRef || (TaSecretRef = {}));
|
|
519
|
+
|
|
231
520
|
// web-src/recall-protocol.ts
|
|
232
521
|
var NAME = "@celljs/ta-recall";
|
|
233
522
|
var EXTENSION_BLOCK = "ta-extension";
|
|
@@ -241,7 +530,6 @@ var Keys;
|
|
|
241
530
|
Keys.ASKED = "asked";
|
|
242
531
|
Keys.BRIEF_SUMMARY = "briefSummary";
|
|
243
532
|
Keys.BRIEF_SEEN = "briefSeen";
|
|
244
|
-
Keys.BRIEF_PINNED = "briefPinned";
|
|
245
533
|
Keys.BRIEF_HANDLED = "briefHandled";
|
|
246
534
|
Keys.DECIDED = "decided";
|
|
247
535
|
Keys.DECLINED = "declined";
|
|
@@ -464,10 +752,7 @@ var BriefUtil;
|
|
|
464
752
|
material2
|
|
465
753
|
].join(`
|
|
466
754
|
`);
|
|
467
|
-
return
|
|
468
|
-
${context}
|
|
469
|
-
</context>
|
|
470
|
-
${prompt}`;
|
|
755
|
+
return TaMessageContext.wrap(context, prompt);
|
|
471
756
|
}
|
|
472
757
|
BriefUtil.message = message;
|
|
473
758
|
})(BriefUtil ||= {});
|
|
@@ -476,10 +761,227 @@ ${prompt}`;
|
|
|
476
761
|
import { readdir, readFile, stat } from "node:fs/promises";
|
|
477
762
|
import { join } from "node:path";
|
|
478
763
|
|
|
764
|
+
// ../ta-protocol/esm/common/said-protocol.js
|
|
765
|
+
var TaSaid;
|
|
766
|
+
(function(TaSaid2) {
|
|
767
|
+
const CARD = /^ta-/i;
|
|
768
|
+
const READ = 4000;
|
|
769
|
+
const FENCE = /^\s*(`{3,}|~{3,})\s*([^\s`]*)/;
|
|
770
|
+
const TAG_LINE = /^<\/?[A-Za-z][\w:.-]*(?:\s[^<>]*)?\/?>$/;
|
|
771
|
+
const MARKS_ONLY = /^[-*_=|:+\s]+$/;
|
|
772
|
+
const MARKS = [
|
|
773
|
+
["context", /<\/?context>/],
|
|
774
|
+
["source", /\[ta:(?:from|notice|by) /],
|
|
775
|
+
["image note", /\[Image: original \d+x\d+|\[Image converted from /],
|
|
776
|
+
["skill", /<skill name="|<\/skill>/],
|
|
777
|
+
["task note", /<\/?task_(?:update|adopted|renamed)\b/],
|
|
778
|
+
["summary", /<\/?(?:conversation_history_summary|summary)>/]
|
|
779
|
+
];
|
|
780
|
+
function text(content, joiner = `
|
|
781
|
+
`) {
|
|
782
|
+
if (typeof content === "string") {
|
|
783
|
+
return content;
|
|
784
|
+
}
|
|
785
|
+
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) : "";
|
|
786
|
+
}
|
|
787
|
+
TaSaid2.text = text;
|
|
788
|
+
function words(role, text2, options = {}) {
|
|
789
|
+
const said = role === "user" ? userWords(text2) : TaAgentSummary.strip(text2);
|
|
790
|
+
return withoutFences(said, (language) => options.cards === false && CARD.test(language), true).trim();
|
|
791
|
+
}
|
|
792
|
+
TaSaid2.words = words;
|
|
793
|
+
function of(message, options) {
|
|
794
|
+
return message ? words(message.role, text(message.content), options) : "";
|
|
795
|
+
}
|
|
796
|
+
TaSaid2.of = of;
|
|
797
|
+
function notice(message) {
|
|
798
|
+
return (message === null || message === undefined ? undefined : message.role) === "user" && TaMessageSource.isNotice(text(message.content));
|
|
799
|
+
}
|
|
800
|
+
TaSaid2.notice = notice;
|
|
801
|
+
function marksOnly(role, text2) {
|
|
802
|
+
return !!text2.trim() && !line(words(role, text2), { chars: Number.POSITIVE_INFINITY });
|
|
803
|
+
}
|
|
804
|
+
TaSaid2.marksOnly = marksOnly;
|
|
805
|
+
function line(markdown, options) {
|
|
806
|
+
var _a;
|
|
807
|
+
const read = markdown.slice(0, READ);
|
|
808
|
+
const prose = withoutFences(read, () => true, true).trim();
|
|
809
|
+
const lines = plain(prose || codeOf(read)).split(`
|
|
810
|
+
`).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));
|
|
811
|
+
const count = (_a = options.lines) !== null && _a !== undefined ? _a : 1;
|
|
812
|
+
const joined = count <= 1 ? lines.join(" ") : lines.slice(0, count).join(`
|
|
813
|
+
`);
|
|
814
|
+
return joined.length > options.chars ? `${joined.slice(0, Math.max(0, options.chars - 1)).trimEnd()}…` : joined;
|
|
815
|
+
}
|
|
816
|
+
TaSaid2.line = line;
|
|
817
|
+
function leaks(shown, options = {}) {
|
|
818
|
+
const found = MARKS.filter(([, mark]) => mark.test(shown)).map(([name]) => name);
|
|
819
|
+
const lines = shown.split(`
|
|
820
|
+
`);
|
|
821
|
+
if (options.cards !== true && lines.some((part) => {
|
|
822
|
+
var _a;
|
|
823
|
+
var _b;
|
|
824
|
+
return CARD.test((_b = (_a = FENCE.exec(part)) === null || _a === undefined ? undefined : _a[2]) !== null && _b !== undefined ? _b : "");
|
|
825
|
+
})) {
|
|
826
|
+
found.push("card");
|
|
827
|
+
}
|
|
828
|
+
if (lines.some((part) => TAG_LINE.test(part.trim()))) {
|
|
829
|
+
found.push("tag");
|
|
830
|
+
}
|
|
831
|
+
return found;
|
|
832
|
+
}
|
|
833
|
+
TaSaid2.leaks = leaks;
|
|
834
|
+
const SUMMARY = `<conversation_history_summary>
|
|
835
|
+
<summary>
|
|
836
|
+
1. Primary Request and Intent:
|
|
837
|
+
The user works on the relay.
|
|
838
|
+
</summary>
|
|
839
|
+
</conversation_history_summary>`;
|
|
840
|
+
TaSaid2.SAMPLES = [
|
|
841
|
+
{
|
|
842
|
+
mark: "context and where it came from",
|
|
843
|
+
role: "user",
|
|
844
|
+
text: `<context>
|
|
845
|
+
The channel #ops, its members.
|
|
846
|
+
[ta:from @celljs/ta-channels #ops]
|
|
847
|
+
</context>
|
|
848
|
+
Check the build`,
|
|
849
|
+
said: "Check the build"
|
|
850
|
+
},
|
|
851
|
+
{
|
|
852
|
+
mark: "a notice, not the user",
|
|
853
|
+
role: "user",
|
|
854
|
+
text: `<context>
|
|
855
|
+
[ta:notice @celljs/ta-call]
|
|
856
|
+
</context>
|
|
857
|
+
The work finished. Its last words: tests pass.`,
|
|
858
|
+
said: "The work finished. Its last words: tests pass."
|
|
859
|
+
},
|
|
860
|
+
{ mark: "one let in", role: "user", text: `<context>
|
|
861
|
+
[ta:by p-7 Alice]
|
|
862
|
+
</context>
|
|
863
|
+
Hello there`, said: "Hello there" },
|
|
864
|
+
{
|
|
865
|
+
mark: "notes of images",
|
|
866
|
+
role: "user",
|
|
867
|
+
text: `Look at this
|
|
868
|
+
[Image: original 3024x4032, displayed at 1512x2016. Multiply coordinates by 2.00 to map to original image.]
|
|
869
|
+
[Image converted from image/heic to image/png.]`,
|
|
870
|
+
said: "Look at this"
|
|
871
|
+
},
|
|
872
|
+
{
|
|
873
|
+
mark: "a skill run",
|
|
874
|
+
role: "user",
|
|
875
|
+
text: `<skill name="ta-package" location="/skills/ta-package/SKILL.md">
|
|
876
|
+
# Ta package
|
|
877
|
+
Steps.
|
|
878
|
+
</skill>
|
|
879
|
+
|
|
880
|
+
Make a card`,
|
|
881
|
+
said: "Make a card"
|
|
882
|
+
},
|
|
883
|
+
{
|
|
884
|
+
mark: "a note of a task",
|
|
885
|
+
role: "user",
|
|
886
|
+
text: `<task_update id="t1" title="Fix login" status="done">
|
|
887
|
+
All tests pass.
|
|
888
|
+
</task_update>`,
|
|
889
|
+
said: "Fix login"
|
|
890
|
+
},
|
|
891
|
+
{ mark: "a note of a new id", role: "user", text: `<task_renamed id="t2" was="t1" title="Fix login">
|
|
892
|
+
Now t2.
|
|
893
|
+
</task_renamed>` },
|
|
894
|
+
{ mark: "a summary, then the answer", role: "assistant", text: `${SUMMARY}
|
|
895
|
+
Switched to voice.`, said: "Switched to voice." },
|
|
896
|
+
{ mark: "a summary alone", role: "assistant", text: SUMMARY },
|
|
897
|
+
{ mark: "a summary as it streams", role: "assistant", text: `<conversation_history_summary>
|
|
898
|
+
<summary>` },
|
|
899
|
+
{
|
|
900
|
+
mark: "a card after the answer",
|
|
901
|
+
role: "assistant",
|
|
902
|
+
text: '**Done**: tests pass.\n\n```ta-glance\n{"status":"done","blocks":[]}\n```',
|
|
903
|
+
said: "tests pass"
|
|
904
|
+
},
|
|
905
|
+
{ mark: "a card alone", role: "assistant", text: '```ta-glance\n{"status":"done","blocks":[]}\n```' },
|
|
906
|
+
{ mark: "a proposal", role: "assistant", text: 'Committed.\n\n```ta-propose\n{"kind":"git.push","title":"Push"}\n```', said: "Committed." },
|
|
907
|
+
{ mark: "what a call says aloud", role: "assistant", text: "All fixed.\n\n```ta-say\nIt is fixed.\n```", said: "All fixed." },
|
|
908
|
+
{ mark: "a tag not known yet", role: "assistant", text: `<system-reminder>
|
|
909
|
+
</system-reminder>
|
|
910
|
+
Ready.`, said: "Ready." }
|
|
911
|
+
];
|
|
912
|
+
function userWords(text2) {
|
|
913
|
+
const said = TaImageNote.strip(TaMessageContext.strip(text2));
|
|
914
|
+
const skill = TaSkillUse.parse(said);
|
|
915
|
+
if (skill) {
|
|
916
|
+
return TaSkillUse.command(skill);
|
|
917
|
+
}
|
|
918
|
+
const note = TaTaskNote.parse(said);
|
|
919
|
+
if (!note) {
|
|
920
|
+
return said;
|
|
921
|
+
}
|
|
922
|
+
if (note.kind === "renamed") {
|
|
923
|
+
return "";
|
|
924
|
+
}
|
|
925
|
+
return note.kind === "update" && note.body.trim() ? `${note.title} · ${note.body}` : note.title;
|
|
926
|
+
}
|
|
927
|
+
function withoutFences(text2, drop, tags = false) {
|
|
928
|
+
const kept = [];
|
|
929
|
+
let fence;
|
|
930
|
+
let left = false;
|
|
931
|
+
for (const part of text2.split(`
|
|
932
|
+
`)) {
|
|
933
|
+
const open = FENCE.exec(part);
|
|
934
|
+
if (!fence && open) {
|
|
935
|
+
fence = { mark: open[1], dropped: drop(open[2]) };
|
|
936
|
+
} else if (fence && closes(part, fence.mark)) {
|
|
937
|
+
const dropped = fence.dropped;
|
|
938
|
+
fence = undefined;
|
|
939
|
+
if (dropped) {
|
|
940
|
+
continue;
|
|
941
|
+
}
|
|
942
|
+
}
|
|
943
|
+
if ((fence === null || fence === undefined ? undefined : fence.dropped) || !fence && tags && TAG_LINE.test(part.trim())) {
|
|
944
|
+
left = true;
|
|
945
|
+
} else {
|
|
946
|
+
kept.push(part);
|
|
947
|
+
}
|
|
948
|
+
}
|
|
949
|
+
return left ? kept.join(`
|
|
950
|
+
`).replace(/\n{3,}/g, `
|
|
951
|
+
|
|
952
|
+
`) : kept.join(`
|
|
953
|
+
`);
|
|
954
|
+
}
|
|
955
|
+
function codeOf(text2) {
|
|
956
|
+
const code = [];
|
|
957
|
+
let fence;
|
|
958
|
+
for (const part of text2.split(`
|
|
959
|
+
`)) {
|
|
960
|
+
const open = FENCE.exec(part);
|
|
961
|
+
if (!fence && open) {
|
|
962
|
+
fence = { mark: open[1], card: CARD.test(open[2]) };
|
|
963
|
+
} else if (fence && closes(part, fence.mark)) {
|
|
964
|
+
fence = undefined;
|
|
965
|
+
} else if (fence && !fence.card) {
|
|
966
|
+
code.push(part);
|
|
967
|
+
}
|
|
968
|
+
}
|
|
969
|
+
return code.join(`
|
|
970
|
+
`);
|
|
971
|
+
}
|
|
972
|
+
function closes(part, mark) {
|
|
973
|
+
var _a;
|
|
974
|
+
const close = (_a = /^\s*(`{3,}|~{3,})\s*$/.exec(part)) === null || _a === undefined ? undefined : _a[1];
|
|
975
|
+
return !!close && close[0] === mark[0] && close.length >= mark.length;
|
|
976
|
+
}
|
|
977
|
+
function plain(text2) {
|
|
978
|
+
const linked = text2.replace(/(?<!!)\[([^\]\n]*)\]\([^)\n]*\)/g, "$1");
|
|
979
|
+
const words2 = linked.replace(/!\[[^\]\n]*\]\([^)\n]*\)/g, "").trim();
|
|
980
|
+
return words2 || linked.replace(/!\[([^\]\n]*)\]\([^)\n]*\)/g, "$1");
|
|
981
|
+
}
|
|
982
|
+
})(TaSaid || (TaSaid = {}));
|
|
983
|
+
|
|
479
984
|
// web-src/conversation-util.ts
|
|
480
|
-
var CONTEXT = /^<context>\n?[\s\S]*?\n?<\/context>\n?/;
|
|
481
|
-
var SKILL = /^<skill name="([^"]+)"[^>]*>[\s\S]*?<\/skill>\s*/;
|
|
482
|
-
var IMAGE_NOTE = /^\[Image: original \d+x\d+, displayed at \d+x\d+\. Multiply coordinates by [\d.]+ to map to original image\.\]$|^\[Image converted from [^\]]+ to [^\]]+\.\]$/gm;
|
|
483
985
|
var TITLE_CHARS = 80;
|
|
484
986
|
var ConversationUtil;
|
|
485
987
|
((ConversationUtil) => {
|
|
@@ -513,10 +1015,10 @@ var ConversationUtil;
|
|
|
513
1015
|
continue;
|
|
514
1016
|
}
|
|
515
1017
|
const raw = textOf(entry.message?.content);
|
|
516
|
-
const text = role
|
|
1018
|
+
const text = TaSaid.words(role, raw);
|
|
517
1019
|
updatedAt = Math.max(updatedAt, at);
|
|
518
1020
|
if (text) {
|
|
519
|
-
said.push(role === "user" &&
|
|
1021
|
+
said.push(role === "user" && TaMessageContext.read(raw) !== undefined ? { role, text, at, framed: true } : { role, text, at });
|
|
520
1022
|
}
|
|
521
1023
|
}
|
|
522
1024
|
}
|
|
@@ -538,20 +1040,11 @@ var ConversationUtil;
|
|
|
538
1040
|
}
|
|
539
1041
|
ConversationUtil.parse = parse;
|
|
540
1042
|
function textOf(content) {
|
|
541
|
-
|
|
542
|
-
return content.trim();
|
|
543
|
-
}
|
|
544
|
-
if (!Array.isArray(content)) {
|
|
545
|
-
return "";
|
|
546
|
-
}
|
|
547
|
-
return content.flatMap((part) => part && typeof part === "object" && part.type === "text" && typeof part.text === "string" ? [part.text] : []).join(`
|
|
548
|
-
`).trim();
|
|
1043
|
+
return TaSaid.text(content).trim();
|
|
549
1044
|
}
|
|
550
1045
|
ConversationUtil.textOf = textOf;
|
|
551
1046
|
function userText(content) {
|
|
552
|
-
|
|
553
|
-
const skill = SKILL.exec(text);
|
|
554
|
-
return (skill ? `/skill:${skill[1]} ${text.slice(skill[0].length)}` : text).trim();
|
|
1047
|
+
return TaSaid.words("user", textOf(content));
|
|
555
1048
|
}
|
|
556
1049
|
ConversationUtil.userText = userText;
|
|
557
1050
|
function cwdOf(cwd, agentDir) {
|
|
@@ -757,10 +1250,7 @@ ${draft.body.trim()}
|
|
|
757
1250
|
"en-US": `Make it: ${draft.title}`,
|
|
758
1251
|
"ja-JP": `作成:${draft.title}`
|
|
759
1252
|
});
|
|
760
|
-
return
|
|
761
|
-
${context}
|
|
762
|
-
</context>
|
|
763
|
-
${said}`;
|
|
1253
|
+
return TaMessageContext.wrap(context, said);
|
|
764
1254
|
}
|
|
765
1255
|
ExtensionUtil.make = make;
|
|
766
1256
|
})(ExtensionUtil ||= {});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@celljs/ta-recall",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.19.0",
|
|
4
4
|
"description": "A pi package for Ta: asks earlier conversations what was done, offers to keep a request asked again as an extension (steps, a card, a page), and writes a daily brief of what got done and what waits for the user",
|
|
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.19.0",
|
|
31
|
+
"@celljs/ta-web": "4.19.0",
|
|
32
32
|
"@types/react": "^19.3.0"
|
|
33
33
|
},
|
|
34
34
|
"publishConfig": {
|
|
@@ -62,6 +62,24 @@
|
|
|
62
62
|
"tools": {
|
|
63
63
|
"search_conversations": "settings.manage"
|
|
64
64
|
}
|
|
65
|
-
}
|
|
65
|
+
},
|
|
66
|
+
"ideas": [
|
|
67
|
+
{
|
|
68
|
+
"id": "find-before",
|
|
69
|
+
"title": {
|
|
70
|
+
"en-US": "Ask Ta what you did before, in your own words",
|
|
71
|
+
"zh-CN": "用自己的话问 Ta 以前做过什么",
|
|
72
|
+
"zh-TW": "用自己的話問 Ta 以前做過什麼",
|
|
73
|
+
"ja-JP": "以前やったことを自分の言葉で Ta に聞く"
|
|
74
|
+
},
|
|
75
|
+
"why": {
|
|
76
|
+
"en-US": "\"How did we fix the login last month?\" Ta finds the conversation and says what was done.",
|
|
77
|
+
"zh-CN": "“上个月登录是怎么修的?”Ta 找到那段对话,告诉你当时怎么做的。",
|
|
78
|
+
"zh-TW": "「上個月登入是怎麼修的?」Ta 找到那段對話,告訴你當時怎麼做的。",
|
|
79
|
+
"ja-JP": "「先月ログインはどう直した?」Ta が会話を探して、何をしたか教えます。"
|
|
80
|
+
},
|
|
81
|
+
"prompt": "Show the user how to ask about what they did before: ask what they want to find, search their earlier conversations, and answer with links to them."
|
|
82
|
+
}
|
|
83
|
+
]
|
|
66
84
|
}
|
|
67
85
|
}
|