cortico-world-self-awareness 0.7.0 → 0.8.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/CHANGELOG.md +15 -0
- package/README.md +4 -0
- package/package.json +1 -1
- package/src/pool.ts +16 -0
- package/src/think.ts +4 -1
- package/src/world.ts +47 -10
- package/webui/index.html +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.8.0
|
|
4
|
+
|
|
5
|
+
**隔夜的心事,第二天能接着想。**
|
|
6
|
+
|
|
7
|
+
以前只有 2 小时内的上一条才允许「接着往下想」。23:40 想到一半,早上醒来拿到的是一张便签转述——是「她昨天留的话」,不是「我昨晚想到哪儿了」。这两种体验差很远。
|
|
8
|
+
|
|
9
|
+
- **接续窗口 2 小时 → 20 小时**,但隔夜这一档多了条件:**必须她自己留过话,或说要歇着**。
|
|
10
|
+
没留就是真想完了,不该第二天又被翻出来。
|
|
11
|
+
- **同一条线最多接两跳**,第三跳强制换题。不设上限的话,一件不痛快的事会被每天醒来接着咀嚼——那比忘掉更糟。
|
|
12
|
+
- **提示词改成「你上次写到『…』(8 小时前),没写完」**,仍然说「写过」,不说「想过」。
|
|
13
|
+
把另一次调用的产物说成她的回忆,是 0.17 就定死的禁区。
|
|
14
|
+
- 想法多存两个字段:`carryGapMin`(隔了多久)、`carryDepth`(接了几跳)。
|
|
15
|
+
时间线上隔夜的标「跨夜接着想」,两小时内的还是「接着上一条」。
|
|
16
|
+
- 测试 68 → 75 项,覆盖四种闸门和措辞。
|
|
17
|
+
|
|
3
18
|
## 0.7.0
|
|
4
19
|
|
|
5
20
|
**这次把方向盘交出去了:怎么想、什么时候停,由她定。**
|
package/README.md
CHANGED
|
@@ -45,6 +45,10 @@
|
|
|
45
45
|
时间线上会标一句「她先搁着了」。这不是卡住,是她自己叫停。
|
|
46
46
|
留的那句话也不再硬性 12 小时过期:她留得越久,便签存得越久(最多 36 小时)。
|
|
47
47
|
|
|
48
|
+
**隔夜的事能接着想。** 两小时内的上一条,她有三成概率往下接;如果上一条她自己留了话(或说要歇着),
|
|
49
|
+
接续窗口放宽到 20 小时——第二天早上可以接着昨晚那句说第二层,而不是从头再讲一遍。
|
|
50
|
+
但同一条线最多接两跳,第三跳强制换题:**不设上限就会变成反刍**,一件不痛快的事每天醒来嚼一遍,比忘掉更糟。
|
|
51
|
+
|
|
48
52
|
于是会出现这种连续:
|
|
49
53
|
|
|
50
54
|
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cortico-world-self-awareness",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "桌宠自己的内在时间线:没人说话的时候她也在想事情——想起旧事、走神、反复琢磨一件没想明白的。\n\n它只负责「想」:想到的写在本机一个文件里,不发消息,也不占对话的 token。配合「记忆核心」使用——你开口时,记忆核心会挑一条带进上下文,标明时间,并说清那不一定是你现在的想法。单独装也能跑,但那是一本她自己不会翻的日记。\n\n模型自选,OpenAI 兼容接口就行;默认一天最多 12 次,一次几分钱。\n\nQQ 交流群:745879632",
|
|
6
6
|
"keywords": [
|
package/src/pool.ts
CHANGED
|
@@ -26,6 +26,10 @@ export interface Thought {
|
|
|
26
26
|
outputTokens?: number;
|
|
27
27
|
/** 这条是接着上一条想下去的,不是新起一件 */
|
|
28
28
|
carry?: boolean;
|
|
29
|
+
/** 接着想时,上一条是多久前写的(分钟)。隔着夜就是几百分钟。 */
|
|
30
|
+
carryGapMin?: number;
|
|
31
|
+
/** 同一条线已经接了几跳。到上限就强制换题,防止反茭。 */
|
|
32
|
+
carryDepth?: number;
|
|
29
33
|
/** 她自己定的下次间隔(分钟)。没写就按密度算。 */
|
|
30
34
|
nextIn?: number;
|
|
31
35
|
/** 她给自己留的话:「明早再看看那个帖子」。下次会原样递回去。 */
|
|
@@ -107,6 +111,8 @@ export class ThoughtPool {
|
|
|
107
111
|
...(t.promptTokens ? { promptTokens: t.promptTokens } : {}),
|
|
108
112
|
...(t.outputTokens ? { outputTokens: t.outputTokens } : {}),
|
|
109
113
|
...(t.carry ? { carry: true } : {}),
|
|
114
|
+
...(typeof t.carryGapMin === 'number' ? { carryGapMin: t.carryGapMin } : {}),
|
|
115
|
+
...(typeof t.carryDepth === 'number' ? { carryDepth: t.carryDepth } : {}),
|
|
110
116
|
...(t.nextIn ? { nextIn: t.nextIn } : {}),
|
|
111
117
|
...(t.nextNote ? { nextNote: t.nextNote } : {}),
|
|
112
118
|
...(t.rest ? { rest: true } : {}),
|
|
@@ -226,6 +232,16 @@ export function noteTtlMs(t: { nextIn?: number }): number {
|
|
|
226
232
|
return Math.min(NOTE_TTL_MAX_MS, Math.max(NOTE_TTL_MS, byHer));
|
|
227
233
|
}
|
|
228
234
|
|
|
235
|
+
/**
|
|
236
|
+
* 跨天接续的三道闸。
|
|
237
|
+
* 只在「同一天内」能接着想的旧限制,让隔夜的心事第二天只能从头再讲一遍;
|
|
238
|
+
* 放开到 20 小时就够覆盖一夜,再长就变成翻旧账。
|
|
239
|
+
* 同时必须是她自己留了话(或说要歇着)——没留就是真想完了。
|
|
240
|
+
*/
|
|
241
|
+
export const CARRY_FRESH_MIN = 120;
|
|
242
|
+
export const CARRY_MAX_AGE_MIN = 1200;
|
|
243
|
+
export const CARRY_MAX_DEPTH = 2;
|
|
244
|
+
|
|
229
245
|
/** 累计重要度到这条线就该往上抽象一层了(写一条 reflection)。 */
|
|
230
246
|
export const REFLECT_THRESHOLD = 24;
|
|
231
247
|
|
package/src/think.ts
CHANGED
|
@@ -27,6 +27,8 @@ export interface ThinkContext {
|
|
|
27
27
|
lastNote?: string;
|
|
28
28
|
/** 这次是接着上一条想下去,不是新起一件 */
|
|
29
29
|
carry?: boolean;
|
|
30
|
+
/** 上一条是多久前写的(「8 小时」「两天」)。跨夜时得让她知道隔了多久。 */
|
|
31
|
+
carryAgo?: string;
|
|
30
32
|
}
|
|
31
33
|
|
|
32
34
|
function systemPrompt(persona?: string): string {
|
|
@@ -107,7 +109,8 @@ export function buildMessages(mode: ThoughtMode, ctx: ThinkContext): { role: str
|
|
|
107
109
|
lines.push('');
|
|
108
110
|
if (ctx.carry && ctx.focus) {
|
|
109
111
|
// 接着上一条想:这时候别让她换题,除非她自己要换
|
|
110
|
-
|
|
112
|
+
const when = ctx.carryAgo ? `(${ctx.carryAgo}前)` : '';
|
|
113
|
+
lines.push(`你上次写到「${ctx.focus}」${when},没写完。接着往下想——说新的一层,别把上次那句重说一遍。`);
|
|
111
114
|
lines.push(`想换件事也行;换就换,mode 里写你这次想用的方式。`);
|
|
112
115
|
} else {
|
|
113
116
|
lines.push('这次没人跟你说话。想怎么想都行:');
|
package/src/world.ts
CHANGED
|
@@ -25,6 +25,9 @@ import {
|
|
|
25
25
|
loadBudget,
|
|
26
26
|
nextGapMinutes,
|
|
27
27
|
noteTtlMs,
|
|
28
|
+
CARRY_FRESH_MIN,
|
|
29
|
+
CARRY_MAX_AGE_MIN,
|
|
30
|
+
CARRY_MAX_DEPTH,
|
|
28
31
|
REST_DEFAULT_MINUTES,
|
|
29
32
|
rollDay,
|
|
30
33
|
saveBudget,
|
|
@@ -298,10 +301,17 @@ export class SelfAwarenessWorld implements World {
|
|
|
298
301
|
}
|
|
299
302
|
}
|
|
300
303
|
|
|
301
|
-
const { mode, carry } = this.nextMode();
|
|
304
|
+
const { mode, carry, carryAgeMin, carryDepth } = this.nextMode();
|
|
302
305
|
const seeds = this.pickSeeds(mode, now);
|
|
303
306
|
const note = this.latestNote(now);
|
|
304
|
-
const ctx = this.buildContext(
|
|
307
|
+
const ctx = this.buildContext(
|
|
308
|
+
core,
|
|
309
|
+
now,
|
|
310
|
+
seeds,
|
|
311
|
+
carry,
|
|
312
|
+
note?.text,
|
|
313
|
+
carryAgeMin ? humanSpan(carryAgeMin * 60_000) : undefined,
|
|
314
|
+
);
|
|
305
315
|
|
|
306
316
|
const started = Date.now();
|
|
307
317
|
const res = await thinkOnce(
|
|
@@ -329,10 +339,13 @@ export class SelfAwarenessWorld implements World {
|
|
|
329
339
|
|
|
330
340
|
this.fails = 0;
|
|
331
341
|
this.lastError = '';
|
|
342
|
+
const carried = Boolean(carry) && res.thought.mode === mode;
|
|
332
343
|
const thought = this.pool.add({
|
|
333
344
|
...res.thought,
|
|
334
345
|
// 她还按建议往下接,才算「接着上一条」;自己换了方式,多半是换了件事
|
|
335
|
-
carry:
|
|
346
|
+
carry: carried,
|
|
347
|
+
...(carried && carryAgeMin ? { carryGapMin: carryAgeMin } : {}),
|
|
348
|
+
...(carried && carryDepth ? { carryDepth } : {}),
|
|
336
349
|
// 把「她当时是什么样子」一起存下来:时间线以后能回看,不只是知道她想了什么
|
|
337
350
|
...(typeof core?.mood === 'number' ? { mood: Math.round(core.mood) } : {}),
|
|
338
351
|
...(typeof core?.energy === 'number' ? { energy: Math.round(core.energy) } : {}),
|
|
@@ -606,6 +619,7 @@ export class SelfAwarenessWorld implements World {
|
|
|
606
619
|
seeds: Seed[],
|
|
607
620
|
carry?: string,
|
|
608
621
|
lastNote?: string,
|
|
622
|
+
carryAgo?: string,
|
|
609
623
|
): ThinkContext {
|
|
610
624
|
const tz = this.tz();
|
|
611
625
|
// 「11-15 23:30(深夜)」——只说时间她不知道那是深夜,会想出「下午出去走走」
|
|
@@ -637,6 +651,7 @@ export class SelfAwarenessWorld implements World {
|
|
|
637
651
|
lastNote,
|
|
638
652
|
focus: carry ? clip(carry, 50) : seeds[0] ? clip(seeds[0].text, 50) : undefined,
|
|
639
653
|
carry: Boolean(carry),
|
|
654
|
+
carryAgo,
|
|
640
655
|
selfView: reflections.length ? clip(reflections.slice(-1)[0].text, 80) : undefined,
|
|
641
656
|
persona: String(this.cfg().personaNote ?? '').trim() || undefined,
|
|
642
657
|
};
|
|
@@ -644,16 +659,36 @@ export class SelfAwarenessWorld implements World {
|
|
|
644
659
|
|
|
645
660
|
/**
|
|
646
661
|
* 模式轮换:七成按顺序,三成随机跳,免得形成「每个模式轮流打卡」的机械感。
|
|
647
|
-
*
|
|
662
|
+
*
|
|
663
|
+
* 接着上一条想:两小时内跟以前一样(想到一半就该接);
|
|
664
|
+
* 隔夜的接续要严一点——必须是她自己留了话或说要歇着,才说明这件事还没完,
|
|
665
|
+
* 而且同一条线最多接两跳,第三跳强制换题(不然会反刍)。
|
|
648
666
|
*/
|
|
649
|
-
private nextMode(
|
|
667
|
+
private nextMode(rand: () => number = Math.random): {
|
|
668
|
+
mode: ThoughtMode;
|
|
669
|
+
carry?: string;
|
|
670
|
+
carryAgeMin?: number;
|
|
671
|
+
carryDepth?: number;
|
|
672
|
+
} {
|
|
650
673
|
const last = this.pool.recent(1)[0];
|
|
651
|
-
const
|
|
652
|
-
|
|
653
|
-
|
|
674
|
+
const ageMin = last ? (Date.now() - (Date.parse(last.ts) || 0)) / 60_000 : Infinity;
|
|
675
|
+
const depth = Number(last?.carryDepth) || 0;
|
|
676
|
+
const leftOpen = Boolean(last && (last.nextNote || last.rest));
|
|
677
|
+
const canCarry =
|
|
678
|
+
Boolean(last)
|
|
679
|
+
&& depth < CARRY_MAX_DEPTH
|
|
680
|
+
&& (ageMin <= CARRY_FRESH_MIN || (ageMin <= CARRY_MAX_AGE_MIN && leftOpen));
|
|
681
|
+
|
|
682
|
+
if (canCarry && rand() < (ageMin <= CARRY_FRESH_MIN ? 0.3 : 0.55)) {
|
|
683
|
+
return {
|
|
684
|
+
mode: 'reflect',
|
|
685
|
+
carry: last!.text,
|
|
686
|
+
carryAgeMin: Math.max(1, Math.round(ageMin)),
|
|
687
|
+
carryDepth: depth + 1,
|
|
688
|
+
};
|
|
654
689
|
}
|
|
655
|
-
if (
|
|
656
|
-
return { mode: THOUGHT_MODES[Math.floor(
|
|
690
|
+
if (rand() < 0.3) {
|
|
691
|
+
return { mode: THOUGHT_MODES[Math.floor(rand() * THOUGHT_MODES.length)] };
|
|
657
692
|
}
|
|
658
693
|
const m = THOUGHT_MODES[this.modeCursor % THOUGHT_MODES.length];
|
|
659
694
|
this.modeCursor += 1;
|
|
@@ -730,6 +765,8 @@ export class SelfAwarenessWorld implements World {
|
|
|
730
765
|
text: t.text,
|
|
731
766
|
importance: t.importance,
|
|
732
767
|
carry: Boolean(t.carry),
|
|
768
|
+
carryGapMin: typeof t.carryGapMin === 'number' ? t.carryGapMin : null,
|
|
769
|
+
carryDepth: typeof t.carryDepth === 'number' ? t.carryDepth : null,
|
|
733
770
|
nextNote: t.nextNote ?? null,
|
|
734
771
|
nextIn: t.nextIn ?? null,
|
|
735
772
|
rest: Boolean(t.rest),
|
package/webui/index.html
CHANGED
|
@@ -292,7 +292,7 @@ function renderThoughts() {
|
|
|
292
292
|
document.getElementById('list').innerHTML = groups.map((g) => `
|
|
293
293
|
<section class="day"><div class="day-label">${dateLabel(g.ts)}</div><div class="timeline">
|
|
294
294
|
${g.items.map((t) => `<article class="item ${esc(t.mode)}${t.rest ? ' rest' : ''}">
|
|
295
|
-
<div class="meta"><span>${clock(t.ts)}</span><span class="mode">${esc(MODE_NAME[t.mode] || t.mode || '思绪')}</span>${t.phase ? `<span>${esc(t.phase)}</span>` : ''}${t.energy != null ? `<span>精力 ${t.energy}</span>` : ''}${dots(t.importance)}${t.carry ?
|
|
295
|
+
<div class="meta"><span>${clock(t.ts)}</span><span class="mode">${esc(MODE_NAME[t.mode] || t.mode || '思绪')}</span>${t.phase ? `<span>${esc(t.phase)}</span>` : ''}${t.energy != null ? `<span>精力 ${t.energy}</span>` : ''}${dots(t.importance)}${t.carry ? `<span class="carry">${(t.carryGapMin ?? 0) >= 360 ? '跨夜接着想' : '接着上一条'}</span>` : ''}${t.rest ? '<span class="rest-tag">她先搁着了</span>' : ''}</div>
|
|
296
296
|
<div class="text">${esc(t.text)}</div>
|
|
297
297
|
${t.nextNote ? `<div class="note-line">留给下一次:${esc(t.nextNote)}${t.nextIn ? `<span>+${esc(t.nextIn)} MIN</span>` : ''}</div>` : ''}
|
|
298
298
|
</article>`).join('')}
|