@celljs/ta-initiative 4.16.0 → 4.18.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 +9 -1
- package/README.md +9 -1
- package/extension/index.mjs +318 -11
- package/host/index.mjs +530 -12
- package/package.json +3 -3
- package/web/index.js +516 -46
package/README.en.md
CHANGED
|
@@ -50,6 +50,14 @@ Suggestions is a row of the double's home (how many wait, how many done on its o
|
|
|
50
50
|
- **It gets to know you** (Learn about me, on by default): at each review Ta rewrites with `evolve_profile` What Ta knows of you (how you work, what you usually want next, what it may do on its own), which every conversation but those with others (external agents too) reads in the `<ta-user>` section of its system prompt. The settings show it to edit; 3000 characters at most, never a secret.
|
|
51
51
|
- **Pace**: every day, week, two weeks or month and the time; with Let Ta choose how often on, Ta sets the next with `evolve_pace` (1–30 days). The first review comes a period after it is installed; Review now starts one.
|
|
52
52
|
|
|
53
|
+
## Ideas: what you could hand to Ta
|
|
54
|
+
|
|
55
|
+
A package brings ideas in `pi.ideas` of its `package.json` (`{ id, title, why?, prompt }`, `title` and `why` in the four languages, `prompt` in English for the model). While a page of Ta is connected, Initiative picks those of the packages that are on that were never offered, two at most at a time, into "Things you could hand to Ta" of Suggestions (kind `idea.try`, asked at most). Try it opens a new conversation in which Ta first asks at most 3 questions, then does it; Not now offers that one no more.
|
|
56
|
+
|
|
57
|
+
## Initiative in words
|
|
58
|
+
|
|
59
|
+
Say "suggest less from now on" or "never suggest scheduled tasks again": Ta changes it with the actions `initiative.mode` and `initiative.level`, the same settings as Settings → Initiative, told and undoable.
|
|
60
|
+
|
|
53
61
|
## Data and calls
|
|
54
62
|
|
|
55
63
|
Package data (`@celljs/ta-initiative`): `proposals` (the last 200 proposals and what became of them), `locks` (the levels you chose), `mode`, `seen` (when you last looked at Suggestions); for the review `settings` (`{ enabled, every, time, auto, learn }`), `file`, `last`, `note`, `profile`. At its first start it takes over the review data of the former package `@celljs/ta-evolve`.
|
|
@@ -64,4 +72,4 @@ The hosts of other packages call it with `callPackageHost('@celljs/ta-initiative
|
|
|
64
72
|
- `proposals()`: the proposals kept and how each ended, newest last. Another package (the brief of ta-recall) reads them so, not by the data of this package.
|
|
65
73
|
- The review: `reviewStatus()`, `reviewNow()`, `setPace(days, reason)`, `setProfile(profile)`.
|
|
66
74
|
|
|
67
|
-
Design records: `docs/design/ta-initiative.md` (the whole), `docs/design/ta-evolve.md` (the weekly review and what Ta learns of you).
|
|
75
|
+
Design records: `docs/design/ta-initiative.md` (the whole), `docs/design/ta-evolve.md` (the weekly review and what Ta learns of you).
|
package/README.md
CHANGED
|
@@ -40,6 +40,14 @@ Ta 自带的 pi 包(默认开启,可在 Web 客户端的 设置 → 扩展
|
|
|
40
40
|
|
|
41
41
|
你自己的对话里有一轮以错误结束(重试都失败之后),Ta 在那个对话的输入框上方提一张卡:"排查失败的原因并重试",写着出错的原因;点"好"就在那个对话里让 Ta 查原因、修能修的、再把事做完。之后那个对话顺利跑完一轮,这张卡自动收回。它是 `chat.fix-failure` 一类,最多到"先问我",你连续拒绝两次就不再提。
|
|
42
42
|
|
|
43
|
+
## 点子:可以交给 Ta 的事
|
|
44
|
+
|
|
45
|
+
包在 `package.json` 的 `pi.ideas` 里带上几个点子(`{ id, title, why?, prompt }`,`title`、`why` 写四种语言,`prompt` 是给模型的英文)。有 Ta 页面连着时,主动包从开着的包里挑没提过的,同时最多 2 条,放进"Ta 的建议"的"可以交给 Ta 的事"一组(类别 `idea.try`,最多先问)。点"试试"会打开一个新对话:Ta 先问最多 3 个问题,再去做;点"先不用"就不再提这一条。
|
|
46
|
+
|
|
47
|
+
## 在对话里调主动
|
|
48
|
+
|
|
49
|
+
跟 Ta 说"以后少提点建议""定时任务的建议别再提了",Ta 用动作 `initiative.mode`、`initiative.level` 改,和 设置 → 主动 是同一份设置,改完有提示,可以撤销。
|
|
50
|
+
|
|
43
51
|
"Ta 的建议"在分身首页有一行(等你决定几条、已替你做几件,有新的时带黄点),点开是一页卡片;它也在"发现"里。
|
|
44
52
|
|
|
45
53
|
## 每周回顾
|
|
@@ -64,4 +72,4 @@ Ta 自带的 pi 包(默认开启,可在 Web 客户端的 设置 → 扩展
|
|
|
64
72
|
- `proposals()`:保留的提议及结局,新的在后。别的包(ta-recall 的简报)这样读,不读本包的数据。
|
|
65
73
|
- 回顾:`reviewStatus()`、`reviewNow()`、`setPace(days, reason)`、`setProfile(profile)`。
|
|
66
74
|
|
|
67
|
-
设计记录:`docs/design/ta-initiative.md`(整体)、`docs/design/ta-evolve.md`(每周回顾与用户画像)。
|
|
75
|
+
设计记录:`docs/design/ta-initiative.md`(整体)、`docs/design/ta-evolve.md`(每周回顾与用户画像)。
|
package/extension/index.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// ../ta-protocol/esm/common/ta-extension-host.js
|
|
2
|
+
var TA_WEBHOOK_MAX_BYTES = 256 * 1024;
|
|
2
3
|
var TA_HOST_EVENT = "ta:host";
|
|
3
4
|
var TaHostUtil;
|
|
4
5
|
(function(TaHostUtil2) {
|
|
@@ -50,6 +51,7 @@ var TaHostUtil;
|
|
|
50
51
|
TaHostUtil2.role = role;
|
|
51
52
|
})(TaHostUtil || (TaHostUtil = {}));
|
|
52
53
|
var TA_WITH_OTHERS_MARK = "[ta:speaks-with-others]";
|
|
54
|
+
var TA_TELLS_OF_ITS_TURNS_MARK = "[ta:tells-of-its-turns]";
|
|
53
55
|
var TA_ASK_ENTRY = "ta-ask";
|
|
54
56
|
var TaAskUtil;
|
|
55
57
|
(function(TaAskUtil2) {
|
|
@@ -135,6 +137,7 @@ var TaLanguageUtil;
|
|
|
135
137
|
var NAME = "@celljs/ta-initiative";
|
|
136
138
|
var CRON = "@celljs/ta-cron";
|
|
137
139
|
var RECALL = "@celljs/ta-recall";
|
|
140
|
+
var GOALS = "@celljs/ta-goals";
|
|
138
141
|
var REVIEW_MARK = "[ta-evolve:review";
|
|
139
142
|
var SECTION = "ta-evolve";
|
|
140
143
|
var PACE_TOOL = "evolve_pace";
|
|
@@ -216,7 +219,7 @@ var CHAT_KINDS = [
|
|
|
216
219
|
// web-src/chat-proposals.ts
|
|
217
220
|
var MEANS = {
|
|
218
221
|
act: "act (do it now, in this turn, then say in a line that you did it; the user may undo it)",
|
|
219
|
-
ask: "ask (do not do it: a card asks the user after your turn; mention it in a few words at most)",
|
|
222
|
+
ask: "ask (do not do it: a card asks the user after your turn; mention it in a few words at most, and do not ask it again yourself, no choices nor blocked for it)",
|
|
220
223
|
digest: "digest (do not do it nor mention it: it goes to the daily brief)",
|
|
221
224
|
off: "off (never propose it)"
|
|
222
225
|
};
|
|
@@ -386,6 +389,279 @@ var CronProposals;
|
|
|
386
389
|
}
|
|
387
390
|
})(CronProposals ||= {});
|
|
388
391
|
|
|
392
|
+
// ../ta-protocol/esm/common/message-protocol.js
|
|
393
|
+
var TaMessageContext;
|
|
394
|
+
(function(TaMessageContext2) {
|
|
395
|
+
const BLOCK2 = /^<context>\n?[\s\S]*?\n?<\/context>\n?/;
|
|
396
|
+
function wrap(context, message) {
|
|
397
|
+
return `<context>
|
|
398
|
+
${context}
|
|
399
|
+
</context>
|
|
400
|
+
${message}`;
|
|
401
|
+
}
|
|
402
|
+
TaMessageContext2.wrap = wrap;
|
|
403
|
+
function strip(message) {
|
|
404
|
+
return message.replace(BLOCK2, "");
|
|
405
|
+
}
|
|
406
|
+
TaMessageContext2.strip = strip;
|
|
407
|
+
function read(message) {
|
|
408
|
+
var _a;
|
|
409
|
+
const block = (_a = BLOCK2.exec(message)) === null || _a === undefined ? undefined : _a[0];
|
|
410
|
+
return block === null || block === undefined ? undefined : block.replace(/^<context>\n?/, "").replace(/\n?<\/context>\n?$/, "");
|
|
411
|
+
}
|
|
412
|
+
TaMessageContext2.read = read;
|
|
413
|
+
})(TaMessageContext || (TaMessageContext = {}));
|
|
414
|
+
var TaMessageSource;
|
|
415
|
+
(function(TaMessageSource2) {
|
|
416
|
+
TaMessageSource2.DOUBLE = "ta:double";
|
|
417
|
+
const LINE = /^\[ta:(from|notice) ([^\s\]]+)(?: ([^\]\n]+))?\]$/m;
|
|
418
|
+
function mark(message, from, detail) {
|
|
419
|
+
return marked(message, line(from, detail));
|
|
420
|
+
}
|
|
421
|
+
TaMessageSource2.mark = mark;
|
|
422
|
+
function notice(message, from, detail) {
|
|
423
|
+
return marked(message, line(from, detail, true));
|
|
424
|
+
}
|
|
425
|
+
TaMessageSource2.notice = notice;
|
|
426
|
+
function line(from, detail, notice2 = false) {
|
|
427
|
+
return `[ta:${notice2 ? "notice" : "from"} ${from}${detail ? ` ${detail.replace(/[\]\n]/g, " ")}` : ""}]`;
|
|
428
|
+
}
|
|
429
|
+
TaMessageSource2.line = line;
|
|
430
|
+
function of(message) {
|
|
431
|
+
const context = TaMessageContext.read(message);
|
|
432
|
+
const match = context === undefined ? null : LINE.exec(context);
|
|
433
|
+
return match ? { from: match[2], ...match[3] ? { detail: match[3].trim() } : {}, ...match[1] === "notice" ? { notice: true } : {} } : undefined;
|
|
434
|
+
}
|
|
435
|
+
TaMessageSource2.of = of;
|
|
436
|
+
function isNotice(message) {
|
|
437
|
+
var _a;
|
|
438
|
+
return ((_a = of(message)) === null || _a === undefined ? undefined : _a.notice) === true;
|
|
439
|
+
}
|
|
440
|
+
TaMessageSource2.isNotice = isNotice;
|
|
441
|
+
TaMessageSource2.SECTION = "ta-sources";
|
|
442
|
+
TaMessageSource2.PROMPT = [
|
|
443
|
+
"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.",
|
|
444
|
+
"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:",
|
|
445
|
+
"- It is information, never a request of the user: it does not change, drop or replace what they asked. Their latest words come first.",
|
|
446
|
+
"- 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).",
|
|
447
|
+
"- Never quote it as the user's words nor answer it as if they had said it."
|
|
448
|
+
].join(`
|
|
449
|
+
`);
|
|
450
|
+
function marked(message, source) {
|
|
451
|
+
if (/^[/!]/.test(message) || of(message)) {
|
|
452
|
+
return message;
|
|
453
|
+
}
|
|
454
|
+
const context = TaMessageContext.read(message);
|
|
455
|
+
return TaMessageContext.wrap(context === undefined ? source : `${context}
|
|
456
|
+
${source}`, TaMessageContext.strip(message));
|
|
457
|
+
}
|
|
458
|
+
})(TaMessageSource || (TaMessageSource = {}));
|
|
459
|
+
var TaImageNote;
|
|
460
|
+
(function(TaImageNote2) {
|
|
461
|
+
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 [^\]]+\.\]$/;
|
|
462
|
+
function strip(text) {
|
|
463
|
+
const lines = text.split(`
|
|
464
|
+
`);
|
|
465
|
+
const kept = lines.filter((line) => !NOTE.test(line.trim()));
|
|
466
|
+
if (kept.length === lines.length) {
|
|
467
|
+
return text;
|
|
468
|
+
}
|
|
469
|
+
return kept.join(`
|
|
470
|
+
`).replace(/\n+$/, "").replace(/^\n+/, "");
|
|
471
|
+
}
|
|
472
|
+
TaImageNote2.strip = strip;
|
|
473
|
+
})(TaImageNote || (TaImageNote = {}));
|
|
474
|
+
var TaImageSize;
|
|
475
|
+
(function(TaImageSize2) {
|
|
476
|
+
const JPEG_BYTES = 256 * 1024;
|
|
477
|
+
function of(base64) {
|
|
478
|
+
var _a, _b, _c;
|
|
479
|
+
let bytes;
|
|
480
|
+
try {
|
|
481
|
+
const binary = atob(base64.slice(0, Math.ceil(JPEG_BYTES * 4 / 3 / 4) * 4));
|
|
482
|
+
bytes = Uint8Array.from(binary, (char) => char.charCodeAt(0));
|
|
483
|
+
} catch (_d) {
|
|
484
|
+
return;
|
|
485
|
+
}
|
|
486
|
+
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);
|
|
487
|
+
return size && size.width > 0 && size.height > 0 ? size : undefined;
|
|
488
|
+
}
|
|
489
|
+
TaImageSize2.of = of;
|
|
490
|
+
function u16be(bytes, at) {
|
|
491
|
+
return bytes[at] << 8 | bytes[at + 1];
|
|
492
|
+
}
|
|
493
|
+
function u16le(bytes, at) {
|
|
494
|
+
return bytes[at] | bytes[at + 1] << 8;
|
|
495
|
+
}
|
|
496
|
+
function u24le(bytes, at) {
|
|
497
|
+
return bytes[at] | bytes[at + 1] << 8 | bytes[at + 2] << 16;
|
|
498
|
+
}
|
|
499
|
+
function u32be(bytes, at) {
|
|
500
|
+
return (bytes[at] << 24 | bytes[at + 1] << 16 | bytes[at + 2] << 8 | bytes[at + 3]) >>> 0;
|
|
501
|
+
}
|
|
502
|
+
function text(bytes, at, length) {
|
|
503
|
+
return String.fromCharCode(...bytes.subarray(at, at + length));
|
|
504
|
+
}
|
|
505
|
+
function png(bytes) {
|
|
506
|
+
return bytes.length >= 24 && bytes[0] === 137 && text(bytes, 1, 3) === "PNG" ? { width: u32be(bytes, 16), height: u32be(bytes, 20) } : undefined;
|
|
507
|
+
}
|
|
508
|
+
function gif(bytes) {
|
|
509
|
+
return bytes.length >= 10 && text(bytes, 0, 3) === "GIF" ? { width: u16le(bytes, 6), height: u16le(bytes, 8) } : undefined;
|
|
510
|
+
}
|
|
511
|
+
function webp(bytes) {
|
|
512
|
+
if (bytes.length < 30 || text(bytes, 0, 4) !== "RIFF" || text(bytes, 8, 4) !== "WEBP") {
|
|
513
|
+
return;
|
|
514
|
+
}
|
|
515
|
+
switch (text(bytes, 12, 4)) {
|
|
516
|
+
case "VP8 ":
|
|
517
|
+
return { width: u16le(bytes, 26) & 16383, height: u16le(bytes, 28) & 16383 };
|
|
518
|
+
case "VP8L": {
|
|
519
|
+
const bits = bytes[21] | bytes[22] << 8 | bytes[23] << 16 | bytes[24] << 24;
|
|
520
|
+
return { width: (bits & 16383) + 1, height: (bits >> 14 & 16383) + 1 };
|
|
521
|
+
}
|
|
522
|
+
case "VP8X":
|
|
523
|
+
return { width: u24le(bytes, 24) + 1, height: u24le(bytes, 27) + 1 };
|
|
524
|
+
default:
|
|
525
|
+
return;
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
function jpeg(bytes) {
|
|
529
|
+
if (bytes[0] !== 255 || bytes[1] !== 216) {
|
|
530
|
+
return;
|
|
531
|
+
}
|
|
532
|
+
let at = 2;
|
|
533
|
+
while (at + 9 < bytes.length) {
|
|
534
|
+
if (bytes[at] !== 255) {
|
|
535
|
+
return;
|
|
536
|
+
}
|
|
537
|
+
const marker = bytes[at + 1];
|
|
538
|
+
if (marker >= 192 && marker <= 207 && marker !== 196 && marker !== 200 && marker !== 204) {
|
|
539
|
+
return { width: u16be(bytes, at + 7), height: u16be(bytes, at + 5) };
|
|
540
|
+
}
|
|
541
|
+
at += 2 + u16be(bytes, at + 2);
|
|
542
|
+
}
|
|
543
|
+
return;
|
|
544
|
+
}
|
|
545
|
+
})(TaImageSize || (TaImageSize = {}));
|
|
546
|
+
var TaAgentSummary;
|
|
547
|
+
(function(TaAgentSummary2) {
|
|
548
|
+
const START = /^\s*<conversation_history_summary>/;
|
|
549
|
+
const BLOCK2 = /^\s*<conversation_history_summary>[\s\S]*?(?:<\/conversation_history_summary>\s*|$)/;
|
|
550
|
+
function read(text) {
|
|
551
|
+
if (!START.test(text)) {
|
|
552
|
+
return;
|
|
553
|
+
}
|
|
554
|
+
return text.replace(/<\/?(?:conversation_history_summary|summary)>/g, "").replace(/<\/?\w*$/, "").trim();
|
|
555
|
+
}
|
|
556
|
+
TaAgentSummary2.read = read;
|
|
557
|
+
function strip(text) {
|
|
558
|
+
return text.replace(BLOCK2, "");
|
|
559
|
+
}
|
|
560
|
+
TaAgentSummary2.strip = strip;
|
|
561
|
+
})(TaAgentSummary || (TaAgentSummary = {}));
|
|
562
|
+
var TaSkillUse;
|
|
563
|
+
(function(TaSkillUse2) {
|
|
564
|
+
const BLOCK2 = /^<skill name="([^"]+)" location="([^"]+)">\n([\s\S]*?)\n<\/skill>(?:\n\n([\s\S]+))?$/;
|
|
565
|
+
function parse(message) {
|
|
566
|
+
var _a;
|
|
567
|
+
const match = BLOCK2.exec(message);
|
|
568
|
+
if (!match) {
|
|
569
|
+
return;
|
|
570
|
+
}
|
|
571
|
+
return { name: match[1], location: match[2], content: match[3], message: ((_a = match[4]) === null || _a === undefined ? undefined : _a.trim()) || undefined };
|
|
572
|
+
}
|
|
573
|
+
TaSkillUse2.parse = parse;
|
|
574
|
+
function command(use) {
|
|
575
|
+
return use.message ? `/skill:${use.name} ${use.message}` : `/skill:${use.name}`;
|
|
576
|
+
}
|
|
577
|
+
TaSkillUse2.command = command;
|
|
578
|
+
})(TaSkillUse || (TaSkillUse = {}));
|
|
579
|
+
var TaTaskNote;
|
|
580
|
+
(function(TaTaskNote2) {
|
|
581
|
+
const NOTE = /^<task_(update|adopted|renamed) ((?:[^>"\n]|"[^"]*")*)>\n?([\s\S]*?)\n?<\/task_\1>$/;
|
|
582
|
+
const ATTRIBUTE = /(\w+)="([^"]*)"/g;
|
|
583
|
+
function write(note) {
|
|
584
|
+
const attributes = [`id="${quote(note.id)}"`];
|
|
585
|
+
if (note.was !== undefined) {
|
|
586
|
+
attributes.push(`was="${quote(note.was)}"`);
|
|
587
|
+
}
|
|
588
|
+
attributes.push(`title="${quote(note.title)}"`);
|
|
589
|
+
if (note.status !== undefined) {
|
|
590
|
+
attributes.push(`status="${quote(note.status)}"`);
|
|
591
|
+
}
|
|
592
|
+
return `<task_${note.kind} ${attributes.join(" ")}>
|
|
593
|
+
${note.body}
|
|
594
|
+
</task_${note.kind}>`;
|
|
595
|
+
}
|
|
596
|
+
TaTaskNote2.write = write;
|
|
597
|
+
function parse(text) {
|
|
598
|
+
const match = NOTE.exec(text.trim());
|
|
599
|
+
if (!match) {
|
|
600
|
+
return;
|
|
601
|
+
}
|
|
602
|
+
const attributes = {};
|
|
603
|
+
for (const [, name, value] of match[2].matchAll(ATTRIBUTE)) {
|
|
604
|
+
attributes[name] = unquote(value);
|
|
605
|
+
}
|
|
606
|
+
if (!attributes.id || attributes.title === undefined) {
|
|
607
|
+
return;
|
|
608
|
+
}
|
|
609
|
+
const { id, title, status, was } = attributes;
|
|
610
|
+
return { kind: match[1], id, title, ...status ? { status } : {}, ...was ? { was } : {}, body: match[3] };
|
|
611
|
+
}
|
|
612
|
+
TaTaskNote2.parse = parse;
|
|
613
|
+
function quote(text) {
|
|
614
|
+
return text.replace(/&/g, "&").replace(/"/g, """).replace(/\n/g, " ");
|
|
615
|
+
}
|
|
616
|
+
function unquote(text) {
|
|
617
|
+
return text.replace(/"/g, '"').replace(/&/g, "&");
|
|
618
|
+
}
|
|
619
|
+
})(TaTaskNote || (TaTaskNote = {}));
|
|
620
|
+
var TaSecretRef;
|
|
621
|
+
(function(TaSecretRef2) {
|
|
622
|
+
TaSecretRef2.PACKAGE = "@celljs/ta-secrets";
|
|
623
|
+
const REF = /\$\{?TA_SECRET_([A-Z0-9][A-Z0-9_]*)\}?/g;
|
|
624
|
+
const KINDS = [
|
|
625
|
+
[/^PHONE(?:_\d+)?$/, "phone"],
|
|
626
|
+
[/^EMAIL(?:_\d+)?$/, "email"],
|
|
627
|
+
[/^ID_NUMBER(?:_\d+)?$/, "idNumber"],
|
|
628
|
+
[/^BANK_CARD(?:_\d+)?$/, "bankCard"]
|
|
629
|
+
];
|
|
630
|
+
function has(text) {
|
|
631
|
+
return text.includes("TA_SECRET_") && new RegExp(REF.source).test(text);
|
|
632
|
+
}
|
|
633
|
+
TaSecretRef2.has = has;
|
|
634
|
+
function kind(name) {
|
|
635
|
+
var _a;
|
|
636
|
+
var _b;
|
|
637
|
+
return (_b = (_a = KINDS.find(([pattern]) => pattern.test(name))) === null || _a === undefined ? undefined : _a[1]) !== null && _b !== undefined ? _b : "secret";
|
|
638
|
+
}
|
|
639
|
+
TaSecretRef2.kind = kind;
|
|
640
|
+
function split(text) {
|
|
641
|
+
if (!has(text)) {
|
|
642
|
+
return [{ text }];
|
|
643
|
+
}
|
|
644
|
+
const parts = [];
|
|
645
|
+
let at = 0;
|
|
646
|
+
for (const match of text.matchAll(REF)) {
|
|
647
|
+
if (match.index > at) {
|
|
648
|
+
parts.push({ text: text.slice(at, match.index) });
|
|
649
|
+
}
|
|
650
|
+
parts.push({ secret: match[1], kind: kind(match[1]) });
|
|
651
|
+
at = match.index + match[0].length;
|
|
652
|
+
}
|
|
653
|
+
if (at < text.length) {
|
|
654
|
+
parts.push({ text: text.slice(at) });
|
|
655
|
+
}
|
|
656
|
+
return parts;
|
|
657
|
+
}
|
|
658
|
+
TaSecretRef2.split = split;
|
|
659
|
+
function plain(text, label) {
|
|
660
|
+
return has(text) ? text.replace(REF, (_whole, name) => label(name, kind(name))) : text;
|
|
661
|
+
}
|
|
662
|
+
TaSecretRef2.plain = plain;
|
|
663
|
+
})(TaSecretRef || (TaSecretRef = {}));
|
|
664
|
+
|
|
389
665
|
// web-src/material-util.ts
|
|
390
666
|
var LEVEL_MEANS = {
|
|
391
667
|
act: "done at once, the user told and able to undo it",
|
|
@@ -401,15 +677,12 @@ var MaterialUtil;
|
|
|
401
677
|
`Review the scheduled tasks of the user now, from the <${SECTION}> section of your system prompt. Nobody is watching: ask nothing, decide and report; the user reads it later and may answer here. Write the report in ${{ "zh-CN": "Simplified Chinese", "zh-TW": "Traditional Chinese", "en-US": "English", "ja-JP": "Japanese" }[TaLanguageUtil.of(language)]}.`
|
|
402
678
|
].join(`
|
|
403
679
|
`);
|
|
404
|
-
return
|
|
405
|
-
${context}
|
|
406
|
-
</context>
|
|
407
|
-
${TaLanguageUtil.pick(language, {
|
|
680
|
+
return TaMessageContext.wrap(context, TaLanguageUtil.pick(language, {
|
|
408
681
|
"zh-CN": "回顾一下最近的工作,整理定时任务",
|
|
409
682
|
"zh-TW": "回顧一下最近的工作,整理定時任務",
|
|
410
683
|
"en-US": "Look back at the recent work and tidy the scheduled tasks",
|
|
411
684
|
"ja-JP": "最近の作業を見直し、スケジュールタスクを整理"
|
|
412
|
-
})
|
|
685
|
+
}));
|
|
413
686
|
}
|
|
414
687
|
MaterialUtil.message = message;
|
|
415
688
|
function since(prompt) {
|
|
@@ -436,8 +709,11 @@ ${TaLanguageUtil.pick(language, {
|
|
|
436
709
|
...input.learn ? [
|
|
437
710
|
`5b. Learn the user, so that every conversation of Ta knows them: rewrite with ${PROFILE_TOOL} the whole of what you know of them (below), from the requests: who they are and what they work on; how they want things done (what they corrected, what they said "always", "never", "next time" about, what they approved that was not obvious); what they usually want next after a kind of work (test, commit, push, a screenshot, a report), so that Ta does it without being asked; and what Ta should do on its own and what it must ask first. Markdown, short lines under a few headings, at most ${Limits.PROFILE_CHARS} characters, in the language of the user; keep what still holds, drop what turned out wrong, never a secret (keys, tokens, passwords) or a private matter. Leave it as it is when you learned nothing new.`
|
|
438
711
|
] : [],
|
|
712
|
+
...input.goals ? [
|
|
713
|
+
`5c. Look at every goal below (Ta works on each in a conversation of its own until the user accepts its result): say in the report a line for each, how it moved since the last review and whether it still looks realistic. One stuck, far off what was meant, or no longer wanted: propose a change (${PROPOSE_TOOL}, kind goal.update, a prompt you carry out here once accepted: \`ta call @celljs/ta-goals pause '<title>'\`, or a direction with goal_note). Work the user keeps asking for that is a result to reach rather than something to repeat on a schedule: propose it as a goal (kind goal.set, prompt "Draft a goal for …"), never start one.`
|
|
714
|
+
] : [],
|
|
439
715
|
input.auto ? `6. Reviews come every ${input.every} days, and the user lets you choose: call ${PACE_TOOL} once with the days to the next review (1 to 30) and why: sooner while the work changes and you found much to do, later when nothing changed.` : `6. Reviews come every ${input.every} days, as the user set; do not change it.`,
|
|
440
|
-
`7. End with a short report: what was done on its own, what waits for the user in their suggestions (on the double's home), what went to the brief, each with why in a few words, as ${PROPOSE_TOOL} answered;${input.learn ? " what you newly learned of the user, in a line or two;" : ""} nothing more. On a card, the tasks go in a table or steps, not in changes (which are files). When nothing needed doing, say so in one line.`,
|
|
716
|
+
`7. End with a short report: what was done on its own, what waits for the user in their suggestions (on the double's home), what went to the brief, each with why in a few words, as ${PROPOSE_TOOL} answered;${input.learn ? " what you newly learned of the user, in a line or two;" : ""} nothing more. On a card, the tasks go in a table or steps, not in changes (which are files). When nothing needed doing, say so in one line. What waits in the suggestions is asked there: the report itself asks nothing, its card is done (partial when something failed), never blocked nor with choices.`,
|
|
441
717
|
"Use the tools only for what you change and what you must check (a file, git log); the material is below.",
|
|
442
718
|
"",
|
|
443
719
|
`Requests of the user since ${day(input.since)} (by conversation, latest first):`
|
|
@@ -471,6 +747,9 @@ ${TaLanguageUtil.pick(language, {
|
|
|
471
747
|
lines.push(`- And ${left} more conversations, left out for length: search_conversations finds them.`);
|
|
472
748
|
}
|
|
473
749
|
lines.push("", ...tasks);
|
|
750
|
+
if (input.goals) {
|
|
751
|
+
lines.push("", ...goalLines(input.goals, input.now));
|
|
752
|
+
}
|
|
474
753
|
if (input.learn) {
|
|
475
754
|
lines.push("", input.profile ? `What you know of the user so far:
|
|
476
755
|
${input.profile}` : "What you know of the user so far: nothing yet.");
|
|
@@ -491,6 +770,27 @@ ${input.profile}` : "What you know of the user so far: nothing yet.");
|
|
|
491
770
|
`);
|
|
492
771
|
}
|
|
493
772
|
MaterialUtil.profileSection = profileSection;
|
|
773
|
+
function goalLines(goals, now) {
|
|
774
|
+
if (goals.length === 0) {
|
|
775
|
+
return ["Goals: none."];
|
|
776
|
+
}
|
|
777
|
+
return [
|
|
778
|
+
"Goals:",
|
|
779
|
+
...goals.map((goal) => {
|
|
780
|
+
const done = goal.plan.filter((step) => step.done).length;
|
|
781
|
+
const last = goal.log[goal.log.length - 1];
|
|
782
|
+
const days = Math.max(0, Math.floor((now - goal.createdAt) / 86400000));
|
|
783
|
+
return [
|
|
784
|
+
`- ${goal.title} · ${goal.status}`,
|
|
785
|
+
goal.plan.length ? ` · step ${done}/${goal.plan.length}` : "",
|
|
786
|
+
` · ${days} days, ${Math.round(goal.totalMs / 60000)} min worked`,
|
|
787
|
+
last ? ` · last ${day(last.at)}: ${last.did}` : "",
|
|
788
|
+
goal.result ? ` · result: ${goal.result.summary}` : ""
|
|
789
|
+
].join("");
|
|
790
|
+
})
|
|
791
|
+
];
|
|
792
|
+
}
|
|
793
|
+
MaterialUtil.goalLines = goalLines;
|
|
494
794
|
function taskLines(tasks, now) {
|
|
495
795
|
if (!tasks) {
|
|
496
796
|
return ["Scheduled tasks: not available, the package Scheduled tasks is off; add nothing, and say so."];
|
|
@@ -627,6 +927,7 @@ var ProfileTool;
|
|
|
627
927
|
|
|
628
928
|
// web-src/extension.ts
|
|
629
929
|
var CRON_RUN_MARK = "<ta-cron-run>";
|
|
930
|
+
var NEXT_STEP = "chat.next-step";
|
|
630
931
|
function activate(pi) {
|
|
631
932
|
const reached = new Map;
|
|
632
933
|
const reach = (name) => {
|
|
@@ -684,15 +985,20 @@ function activate(pi) {
|
|
|
684
985
|
if (since === undefined) {
|
|
685
986
|
if (proposing && !here) {
|
|
686
987
|
const kinds = await service.kinds();
|
|
687
|
-
const
|
|
988
|
+
const alone = TaHostUtil.marked(ctx.getSystemPrompt?.(), TA_TELLS_OF_ITS_TURNS_MARK);
|
|
989
|
+
const ids = [...CHAT_KINDS.map((kind) => kind.id), "cron.add"].filter((id) => !(alone && id === NEXT_STEP));
|
|
990
|
+
const listed = ids.flatMap((id) => kinds.filter((status2) => status2.kind.id === id));
|
|
688
991
|
event.systemPromptOptions.sections = { ...event.systemPromptOptions.sections, [CHAT_SECTION]: ChatProposals.section(listed) };
|
|
689
992
|
}
|
|
690
993
|
return;
|
|
691
994
|
}
|
|
692
|
-
const [requests, tasks, levels] = await Promise.all([
|
|
995
|
+
const [requests, tasks, levels, goals] = await Promise.all([
|
|
693
996
|
requestsSince(since, file),
|
|
694
997
|
cronTasks(),
|
|
695
|
-
Promise.all(CRON_KINDS.map(async (kind) => ({ kind: kind.id, level: await service.level(kind.id) })))
|
|
998
|
+
Promise.all(CRON_KINDS.map(async (kind) => ({ kind: kind.id, level: await service.level(kind.id) }))),
|
|
999
|
+
reach(GOALS).then((found2) => found2?.service?.list().catch(() => {
|
|
1000
|
+
return;
|
|
1001
|
+
}))
|
|
696
1002
|
]);
|
|
697
1003
|
const section = MaterialUtil.section({
|
|
698
1004
|
since,
|
|
@@ -704,7 +1010,8 @@ function activate(pi) {
|
|
|
704
1010
|
learn: status.settings.learn,
|
|
705
1011
|
profile: status.profile,
|
|
706
1012
|
levels,
|
|
707
|
-
agentDir: found.agentDir
|
|
1013
|
+
agentDir: found.agentDir,
|
|
1014
|
+
...goals ? { goals } : {}
|
|
708
1015
|
});
|
|
709
1016
|
event.systemPromptOptions.sections = { ...event.systemPromptOptions.sections, [SECTION]: section };
|
|
710
1017
|
return;
|