cortico-world-self-awareness 0.6.1 → 0.7.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 +29 -0
- package/README.md +9 -3
- package/package.json +1 -1
- package/src/config.ts +1 -1
- package/src/pool.ts +37 -2
- package/src/think.ts +70 -15
- package/src/world.ts +39 -5
- package/webui/index.html +320 -231
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,34 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.7.0
|
|
4
|
+
|
|
5
|
+
**这次把方向盘交出去了:怎么想、什么时候停,由她定。**
|
|
6
|
+
|
|
7
|
+
- **方式她自己挑**:每次把五种方式(回看/走神/打算/琢磨/综合)摆出来,插件只给一个建议——「这会儿更像走神」。
|
|
8
|
+
她要在 `mode` 里写别的,就按她的来。接着上一条往下想时不摆菜单,只说「说新的一层」。
|
|
9
|
+
- **她可以叫停**:输出里写 `"rest": true`,就按她给的时长歇着——最短 2 小时、最长一天,没给时间默认 8 小时。
|
|
10
|
+
以前间隔被夹在 15–360 分钟,等于**永远会被叫醒**,没有「这件事我想完了」的出口。
|
|
11
|
+
- **便签不再硬性 12 小时过期**:她说「明早再看」,原来隔 13 小时那张便签就没了。现在过期时间跟着她自己的间隔走
|
|
12
|
+
(最少 12 小时,最多 36 小时)。
|
|
13
|
+
- **想法记下当时的状态**:`mood` / `energy` / `phase`(深夜、清晨…)一起写进 `thoughts.jsonl`。
|
|
14
|
+
以前心情和时段只喂给模型,回看时什么都看不到。时间线每条现在会标「深夜 · 精力 22」。
|
|
15
|
+
- **时间线**:叫停的那条标「她先搁着了」,右侧便笺显示「她说先搁着,X 再看」;
|
|
16
|
+
便签内容改由服务端算好(过期的直接不给),不会再挂着三天前的话。
|
|
17
|
+
- **小修**:`carry` 只在她沿用了建议时才标;自己换了方式多半是换了件事,不该再说「接着上一条」。
|
|
18
|
+
- 测试 54 → 68 项。
|
|
19
|
+
|
|
20
|
+
## 0.6.2
|
|
21
|
+
|
|
22
|
+
**时间线换了一张脸,顺便补上一个漏掉的模式。**
|
|
23
|
+
|
|
24
|
+
- **页面重做**:从原来的一列灰字,改成「深空意识舱」——深空蓝黑底、紫色思绪、青色状态,左边是思绪流,右边是留给下一次的便笺和接口诊断。
|
|
25
|
+
思绪按今天/昨天/日期分组,可筛选;正文放大到 15px、行高 1.9,长时间看不再费眼。
|
|
26
|
+
- **补 `synthesize`(综合)**:0.4.0 加了第五种模式,但页面上的模式表只认四个——综合模式会原样显示英文 `synthesize`,筛选栏里也没有它。
|
|
27
|
+
现在有中文名、有颜色、能筛选。
|
|
28
|
+
- **五种模式有说明了**:筛选栏下面加一行图例,写明「回看/走神/打算/琢磨/综合」各自在做什么,不用再翻文档猜。
|
|
29
|
+
- 接口检测仍放在右侧「系统信号」卡片里;10 秒限流单独显示「等一下」,不冒充故障。
|
|
30
|
+
- 测试 54 项不变,全部通过。
|
|
31
|
+
|
|
3
32
|
## 0.6.1
|
|
4
33
|
|
|
5
34
|
把「测接口」做得能看见了。
|
package/README.md
CHANGED
|
@@ -41,6 +41,10 @@
|
|
|
41
41
|
她每想完一件事,可以给自己留一句「下次从哪儿接着想」和一个大致间隔(15 分钟到 6 小时)。
|
|
42
42
|
下次思考时,那句话会原样递回到她眼前。她没留,才按上面的密度算。
|
|
43
43
|
|
|
44
|
+
**她也可以说不想了。** 写一个 `rest`,就按她给的时长歇着(最短 2 小时,最长一天;没给时间默认 8 小时),
|
|
45
|
+
时间线上会标一句「她先搁着了」。这不是卡住,是她自己叫停。
|
|
46
|
+
留的那句话也不再硬性 12 小时过期:她留得越久,便签存得越久(最多 36 小时)。
|
|
47
|
+
|
|
44
48
|
于是会出现这种连续:
|
|
45
49
|
|
|
46
50
|
```
|
|
@@ -55,7 +59,7 @@
|
|
|
55
59
|
|
|
56
60
|
---
|
|
57
61
|
|
|
58
|
-
##
|
|
62
|
+
## 五种方式,她自己挑
|
|
59
63
|
|
|
60
64
|
| 模式 | 她在干什么 |
|
|
61
65
|
|---|---|
|
|
@@ -63,8 +67,10 @@
|
|
|
63
67
|
| `wonder` | 手上没做事,脑子飘走了 |
|
|
64
68
|
| `plan` | 想接下来要做什么(不是任务清单) |
|
|
65
69
|
| `doubt` | 有件事一直没想明白,再想一次 |
|
|
70
|
+
| `synthesize` | 把两件看着不相干的事连起来看 |
|
|
66
71
|
|
|
67
|
-
|
|
72
|
+
**方式不是插件派的。** 每次会把五种摆出来,插件只给一个建议(「这会儿更像走神」),
|
|
73
|
+
她自己要换就在 `mode` 里写。她要接着上一条往下想时,才不摆菜单,直接让她说新的一层。
|
|
68
74
|
|
|
69
75
|
---
|
|
70
76
|
|
|
@@ -115,7 +121,7 @@
|
|
|
115
121
|
插件会开一个只在本机的小网页(默认 `http://127.0.0.1:7802`,被占用会自动往后找)。
|
|
116
122
|
在 World 页点「看她的时间线」就能打开。
|
|
117
123
|
|
|
118
|
-
-
|
|
124
|
+
- 按时间倒序,每条标:时间、方式(回看 / 走神 / 打算 / 琢磨 / 综合)、时段、当时的精力、重要度点
|
|
119
125
|
- 接着上次想下去的会单独标出来
|
|
120
126
|
- 底部是「她对自己的看法」——几条碎念攒够重要度后自动收成的一句
|
|
121
127
|
- 顶部:今天几次、花了多少 token、下次什么时候、现在是**在跑 / 睡着了 / 出错 / 已关闭**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cortico-world-self-awareness",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "桌宠自己的内在时间线:没人说话的时候她也在想事情——想起旧事、走神、反复琢磨一件没想明白的。\n\n它只负责「想」:想到的写在本机一个文件里,不发消息,也不占对话的 token。配合「记忆核心」使用——你开口时,记忆核心会挑一条带进上下文,标明时间,并说清那不一定是你现在的想法。单独装也能跑,但那是一本她自己不会翻的日记。\n\n模型自选,OpenAI 兼容接口就行;默认一天最多 12 次,一次几分钱。\n\nQQ 交流群:745879632",
|
|
6
6
|
"keywords": [
|
package/src/config.ts
CHANGED
|
@@ -130,7 +130,7 @@ const RAW_GROUP: ConfigGroup = {
|
|
|
130
130
|
'worlds.self-awareness.maxGapMin': {
|
|
131
131
|
type: 'integer',
|
|
132
132
|
title: '最长隔多久',
|
|
133
|
-
description: '
|
|
133
|
+
description: '想到的东西多,就自动往这个上限靠;想得敷衍,就往上面那个下限靠。她说「先搁着」时不受这里限制(可到一天)。',
|
|
134
134
|
minimum: 2,
|
|
135
135
|
maximum: 1440,
|
|
136
136
|
default: 90,
|
package/src/pool.ts
CHANGED
|
@@ -30,6 +30,12 @@ export interface Thought {
|
|
|
30
30
|
nextIn?: number;
|
|
31
31
|
/** 她给自己留的话:「明早再看看那个帖子」。下次会原样递回去。 */
|
|
32
32
|
nextNote?: string;
|
|
33
|
+
/** 她说「先搁着」——不是按密度排的下一跳,是她自己叫停的。 */
|
|
34
|
+
rest?: boolean;
|
|
35
|
+
/** 写下这条时的状态,用来在时间线上回看「她当时是什么样子」。 */
|
|
36
|
+
mood?: number;
|
|
37
|
+
energy?: number;
|
|
38
|
+
phase?: string;
|
|
33
39
|
}
|
|
34
40
|
|
|
35
41
|
export interface Reflection {
|
|
@@ -103,6 +109,10 @@ export class ThoughtPool {
|
|
|
103
109
|
...(t.carry ? { carry: true } : {}),
|
|
104
110
|
...(t.nextIn ? { nextIn: t.nextIn } : {}),
|
|
105
111
|
...(t.nextNote ? { nextNote: t.nextNote } : {}),
|
|
112
|
+
...(t.rest ? { rest: true } : {}),
|
|
113
|
+
...(typeof t.mood === 'number' ? { mood: t.mood } : {}),
|
|
114
|
+
...(typeof t.energy === 'number' ? { energy: t.energy } : {}),
|
|
115
|
+
...(t.phase ? { phase: t.phase } : {}),
|
|
106
116
|
};
|
|
107
117
|
ensureDir(this.dir);
|
|
108
118
|
// 先让 cache 落地再 append:否则 all() 会从文件里读回刚写的那条,push 之后就有了两份
|
|
@@ -183,12 +193,37 @@ export function clamp01(n: number): number {
|
|
|
183
193
|
/** 她自己说的「多久之后再想」的允许范围。上下都留边:说 1 分钟太密,说三天就断了。 */
|
|
184
194
|
export const NEXT_MIN_MINUTES = 15;
|
|
185
195
|
export const NEXT_MAX_MINUTES = 360;
|
|
196
|
+
/** 说「先搁着」时允许拉得更长:至少两小时,最多一天。 */
|
|
197
|
+
export const REST_MIN_MINUTES = 120;
|
|
198
|
+
export const REST_MAX_MINUTES = 1440;
|
|
199
|
+
/** 她说了 rest 却没给间隔时的默认值:睡一觉再说。 */
|
|
200
|
+
export const REST_DEFAULT_MINUTES = 480;
|
|
186
201
|
|
|
187
202
|
/** 把模型给的值收进合法范围;不是数字就当没写。 */
|
|
188
|
-
export function clampNextIn(value: unknown): number | undefined {
|
|
203
|
+
export function clampNextIn(value: unknown, max = NEXT_MAX_MINUTES): number | undefined {
|
|
189
204
|
const v = Number(value);
|
|
190
205
|
if (!Number.isFinite(v) || v <= 0) return undefined;
|
|
191
|
-
return Math.round(Math.max(NEXT_MIN_MINUTES, Math.min(
|
|
206
|
+
return Math.round(Math.max(NEXT_MIN_MINUTES, Math.min(max, v)));
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/** 「先搁着」用的间隔:范围比平时宽。 */
|
|
210
|
+
export function clampRestIn(value: unknown): number | undefined {
|
|
211
|
+
const v = Number(value);
|
|
212
|
+
if (!Number.isFinite(v) || v <= 0) return undefined;
|
|
213
|
+
return Math.round(Math.max(REST_MIN_MINUTES, Math.min(REST_MAX_MINUTES, v)));
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* 她留的那句话能存多久。
|
|
218
|
+
* 以前是硬 12 小时——她说「明早再看」,隔了 13 小时那张便签就直接没了。
|
|
219
|
+
* 现在跟着她自己的 next 走:留的间隔越长,便签留得越久;仍留上限,免得半年前的便签被翻出来。
|
|
220
|
+
*/
|
|
221
|
+
export const NOTE_TTL_MS = 12 * 3_600_000;
|
|
222
|
+
export const NOTE_TTL_MAX_MS = 36 * 3_600_000;
|
|
223
|
+
|
|
224
|
+
export function noteTtlMs(t: { nextIn?: number }): number {
|
|
225
|
+
const byHer = (Number(t.nextIn) || 0) * 60_000 + 3_600_000;
|
|
226
|
+
return Math.min(NOTE_TTL_MAX_MS, Math.max(NOTE_TTL_MS, byHer));
|
|
192
227
|
}
|
|
193
228
|
|
|
194
229
|
/** 累计重要度到这条线就该往上抽象一层了(写一条 reflection)。 */
|
package/src/think.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* 全部用「你就是她」的第二人称写提示词——用第三人称会写成分析报告。
|
|
6
6
|
*/
|
|
7
7
|
import type { Thought, ThoughtMode } from './pool.ts';
|
|
8
|
-
import { clampImportance, clampNextIn, density } from './pool.ts';
|
|
8
|
+
import { clampImportance, clampNextIn, clampRestIn, density } from './pool.ts';
|
|
9
9
|
import { clip } from './time.ts';
|
|
10
10
|
|
|
11
11
|
export interface ThinkContext {
|
|
@@ -39,21 +39,38 @@ ${persona ? `你是谁:${persona}\n` : ''}
|
|
|
39
39
|
- 别汇报工作,别复述别人交给你做的事。独处时想的不是待办。
|
|
40
40
|
- 想不通就想不通,可以停在半路。人独处时大部分念头都没有结论。
|
|
41
41
|
- 不要提「用户」「对话」「模型」「AI」「记忆」「记录」「卡片」这些词。
|
|
42
|
-
-
|
|
42
|
+
- 用什么方式想,你自己挑:回看 / 走神 / 打算 / 琢磨 / 综合。
|
|
43
|
+
- 想完之后,留一句「下次从哪儿接着想」和大致的间隔写进 next。
|
|
44
|
+
- 真的不想了、想搁着,就写 "rest":true,间隔可以长到一天。
|
|
43
45
|
|
|
44
46
|
只输出一行 JSON,不要别的:
|
|
45
|
-
{"thought":"你想到的那件事","importance":1,"next":{"in":60,"note":"留给自己的一句话"}}
|
|
47
|
+
{"thought":"你想到的那件事","importance":1,"mode":"wonder","next":{"in":60,"note":"留给自己的一句话"},"rest":false}
|
|
48
|
+
mode 只能填:reflect(回看以前的事)/ wonder(没缘由地走神)/ plan(打算接下来做什么)/ doubt(琢磨一件没想明白的)/ synthesize(把两件看着不相干的事连起来)。
|
|
46
49
|
importance 是 1-10:这件事对你有多重要。10 = 你会一直想它。
|
|
47
|
-
next 是你给自己留的:还会想,就定个时间(15–360
|
|
50
|
+
next 是你给自己留的:还会想,就定个时间(15–360 分钟;写了 rest 可以到 1440)和一句「下次从哪儿接着想」。
|
|
48
51
|
想完了、没什么可接的,就空着。`;
|
|
49
52
|
}
|
|
50
53
|
|
|
54
|
+
const MODE_LABEL: Record<ThoughtMode, string> = {
|
|
55
|
+
reflect: '回看',
|
|
56
|
+
wonder: '走神',
|
|
57
|
+
plan: '打算',
|
|
58
|
+
doubt: '琢磨',
|
|
59
|
+
synthesize: '综合',
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
/** 把五种方式摆给她选,不是替她定。 */
|
|
63
|
+
const MODE_MENU = [
|
|
64
|
+
'· 回看:想起以前的一件事,回头看它',
|
|
65
|
+
'· 走神:手上没在做什么,脑子飘走了',
|
|
66
|
+
'· 打算:想自己接下来要做什么(不是待办清单)',
|
|
67
|
+
'· 琢磨:一件一直没想明白的事,再想一次',
|
|
68
|
+
'· 综合:把两件看着没关系的事连起来看',
|
|
69
|
+
].join('\n');
|
|
70
|
+
|
|
51
71
|
const MODE_ASK: Record<ThoughtMode, (ctx: ThinkContext) => string> = {
|
|
52
72
|
reflect: (ctx) => {
|
|
53
73
|
if (!ctx.focus) return '你想起了以前的一件事。现在回头看它,感觉和当时一样吗?';
|
|
54
|
-
if (ctx.carry) {
|
|
55
|
-
return `你上次想到「${ctx.focus}」,没想完。接着往下想——说新的一层,别把上次那句重说一遍。`;
|
|
56
|
-
}
|
|
57
74
|
return `你想起了这件事:「${ctx.focus}」。现在回头看它,感觉和当时一样吗?`;
|
|
58
75
|
},
|
|
59
76
|
wonder: () => '你手上没在做什么,脑子飘走了。飘到哪算哪,不用有理由。',
|
|
@@ -88,7 +105,17 @@ export function buildMessages(mode: ThoughtMode, ctx: ThinkContext): { role: str
|
|
|
88
105
|
lines.push('(你最近没想过什么。)');
|
|
89
106
|
}
|
|
90
107
|
lines.push('');
|
|
91
|
-
|
|
108
|
+
if (ctx.carry && ctx.focus) {
|
|
109
|
+
// 接着上一条想:这时候别让她换题,除非她自己要换
|
|
110
|
+
lines.push(`上次你想到「${ctx.focus}」,没想完。接着往下想——说新的一层,别把上次那句重说一遍。`);
|
|
111
|
+
lines.push(`想换件事也行;换就换,mode 里写你这次想用的方式。`);
|
|
112
|
+
} else {
|
|
113
|
+
lines.push('这次没人跟你说话。想怎么想都行:');
|
|
114
|
+
lines.push(MODE_MENU);
|
|
115
|
+
if (ctx.focus) lines.push(`(手边现成的事:「${ctx.focus}」,想从这儿起头也行,不想用也行。)`);
|
|
116
|
+
lines.push(`这会儿更像「${MODE_LABEL[mode]}」:${MODE_ASK[mode](ctx)}`);
|
|
117
|
+
lines.push('你也可以换别的,mode 里写你选的。');
|
|
118
|
+
}
|
|
92
119
|
return [
|
|
93
120
|
{ role: 'system', content: systemPrompt(ctx.persona) },
|
|
94
121
|
{ role: 'user', content: lines.join('\n') },
|
|
@@ -188,11 +215,28 @@ export interface ParsedThought {
|
|
|
188
215
|
next?: { in?: number; note?: string };
|
|
189
216
|
}
|
|
190
217
|
|
|
191
|
-
|
|
192
|
-
|
|
218
|
+
export interface ParsedThought {
|
|
219
|
+
text: string;
|
|
220
|
+
importance: number;
|
|
221
|
+
next?: { in?: number; note?: string };
|
|
222
|
+
/** 她自己挑的方式。没填就用插件建议的那个。 */
|
|
223
|
+
mode?: ThoughtMode;
|
|
224
|
+
/** 她说「先搁着」。 */
|
|
225
|
+
rest?: boolean;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
const MODE_IDS: ThoughtMode[] = ['reflect', 'wonder', 'plan', 'doubt', 'synthesize'];
|
|
229
|
+
|
|
230
|
+
function asMode(value: unknown): ThoughtMode | undefined {
|
|
231
|
+
return typeof value === 'string' && (MODE_IDS as string[]).includes(value) ? (value as ThoughtMode) : undefined;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/** 她给自己留的那句:范围收进合法范围,note 超过 40 字截断。都不合法就当没留。 */
|
|
235
|
+
export function parseNext(value: unknown, rest = false): { in?: number; note?: string } | undefined {
|
|
193
236
|
if (!value || typeof value !== 'object') return undefined;
|
|
194
237
|
const o = value as { in?: unknown; note?: unknown };
|
|
195
|
-
|
|
238
|
+
// 说了 rest 就允许拉到一天,否则还是 15–360
|
|
239
|
+
const inMin = rest ? clampRestIn(o.in) : clampNextIn(o.in);
|
|
196
240
|
const note = typeof o.note === 'string' && o.note.trim() ? clip(o.note.trim(), 40) : undefined;
|
|
197
241
|
if (inMin === undefined && !note) return undefined;
|
|
198
242
|
return { ...(inMin !== undefined ? { in: inMin } : {}), ...(note ? { note } : {}) };
|
|
@@ -203,11 +247,19 @@ export function parseThought(raw: string): ParsedThought {
|
|
|
203
247
|
|
|
204
248
|
const tryJson = (s: string): ParsedThought | null => {
|
|
205
249
|
try {
|
|
206
|
-
const o = JSON.parse(s) as { thought?: unknown; text?: unknown; importance?: unknown; next?: unknown };
|
|
250
|
+
const o = JSON.parse(s) as { thought?: unknown; text?: unknown; importance?: unknown; next?: unknown; mode?: unknown; rest?: unknown };
|
|
207
251
|
const text = String(o.thought ?? o.text ?? '').trim();
|
|
208
252
|
if (!text) return null;
|
|
209
|
-
const
|
|
210
|
-
|
|
253
|
+
const rest = o.rest === true || o.rest === 'true';
|
|
254
|
+
const next = parseNext(o.next, rest);
|
|
255
|
+
const mode = asMode(o.mode);
|
|
256
|
+
return {
|
|
257
|
+
text,
|
|
258
|
+
importance: clampImportance(o.importance),
|
|
259
|
+
...(next ? { next } : {}),
|
|
260
|
+
...(mode ? { mode } : {}),
|
|
261
|
+
...(rest ? { rest: true } : {}),
|
|
262
|
+
};
|
|
211
263
|
} catch {
|
|
212
264
|
return null;
|
|
213
265
|
}
|
|
@@ -259,16 +311,19 @@ export async function thinkOnce(
|
|
|
259
311
|
if (!res.ok || !res.text) return { ok: false, reason: res.reason ?? '调用失败' };
|
|
260
312
|
const parsed = parseThought(res.text);
|
|
261
313
|
if (!parsed.text) return { ok: false, reason: '解析后没有内容' };
|
|
314
|
+
// 她自己挑了方式就用她的;没挑就沿用插件建议的
|
|
315
|
+
const finalMode = parsed.mode ?? mode;
|
|
262
316
|
return {
|
|
263
317
|
ok: true,
|
|
264
318
|
thought: {
|
|
265
|
-
mode,
|
|
319
|
+
mode: finalMode,
|
|
266
320
|
text: clip(parsed.text, 400),
|
|
267
321
|
importance: parsed.importance,
|
|
268
322
|
seeds,
|
|
269
323
|
// 她自己留的那句要带出去,不然解析了也白解析
|
|
270
324
|
...(parsed.next?.in ? { nextIn: parsed.next.in } : {}),
|
|
271
325
|
...(parsed.next?.note ? { nextNote: parsed.next.note } : {}),
|
|
326
|
+
...(parsed.rest ? { rest: true } : {}),
|
|
272
327
|
promptTokens: res.promptTokens,
|
|
273
328
|
outputTokens: res.outputTokens,
|
|
274
329
|
},
|
package/src/world.ts
CHANGED
|
@@ -24,6 +24,8 @@ import {
|
|
|
24
24
|
density,
|
|
25
25
|
loadBudget,
|
|
26
26
|
nextGapMinutes,
|
|
27
|
+
noteTtlMs,
|
|
28
|
+
REST_DEFAULT_MINUTES,
|
|
27
29
|
rollDay,
|
|
28
30
|
saveBudget,
|
|
29
31
|
type BudgetState,
|
|
@@ -327,7 +329,15 @@ export class SelfAwarenessWorld implements World {
|
|
|
327
329
|
|
|
328
330
|
this.fails = 0;
|
|
329
331
|
this.lastError = '';
|
|
330
|
-
const thought = this.pool.add({
|
|
332
|
+
const thought = this.pool.add({
|
|
333
|
+
...res.thought,
|
|
334
|
+
// 她还按建议往下接,才算「接着上一条」;自己换了方式,多半是换了件事
|
|
335
|
+
carry: Boolean(carry) && res.thought.mode === mode,
|
|
336
|
+
// 把「她当时是什么样子」一起存下来:时间线以后能回看,不只是知道她想了什么
|
|
337
|
+
...(typeof core?.mood === 'number' ? { mood: Math.round(core.mood) } : {}),
|
|
338
|
+
...(typeof core?.energy === 'number' ? { energy: Math.round(core.energy) } : {}),
|
|
339
|
+
phase: timeOfDay(now, this.tz()),
|
|
340
|
+
});
|
|
331
341
|
this.lastSnapshot = { ts: thought.ts, text: thought.text, mode: thought.mode };
|
|
332
342
|
|
|
333
343
|
this.budget.count += 1;
|
|
@@ -335,11 +345,13 @@ export class SelfAwarenessWorld implements World {
|
|
|
335
345
|
this.budget.pendingImportance += thought.importance;
|
|
336
346
|
this.budget.lastThoughtAt = thought.ts;
|
|
337
347
|
|
|
338
|
-
//
|
|
348
|
+
// 下次隔多久:她说「先搁着」就按她的长间隔,其余听她自己定的,没定才按密度算
|
|
339
349
|
const herNext = Number(res.thought.nextIn);
|
|
340
350
|
const gap = Number.isFinite(herNext) && herNext > 0
|
|
341
351
|
? herNext
|
|
342
|
-
:
|
|
352
|
+
: thought.rest
|
|
353
|
+
? REST_DEFAULT_MINUTES
|
|
354
|
+
: nextGapMinutes(density(thought), Number(cfg.minGapMin) || 25, Number(cfg.maxGapMin) || 90);
|
|
343
355
|
if (note) this.budget.lastNoteId = note.id;
|
|
344
356
|
this.budget.nextDueAt = new Date(Date.now() + Math.round(gap * 60_000)).toISOString();
|
|
345
357
|
saveBudget(this.dataDir, this.budget);
|
|
@@ -355,6 +367,7 @@ export class SelfAwarenessWorld implements World {
|
|
|
355
367
|
importance: thought.importance,
|
|
356
368
|
gapMin: Math.round(gap),
|
|
357
369
|
byHer: Number.isFinite(herNext) && herNext > 0,
|
|
370
|
+
rest: Boolean(thought.rest),
|
|
358
371
|
ms: Date.now() - started,
|
|
359
372
|
});
|
|
360
373
|
} catch {
|
|
@@ -435,12 +448,13 @@ export class SelfAwarenessWorld implements World {
|
|
|
435
448
|
* 现在都第二天晚上了,再提就是翻旧账。用过的记在 budget.lastNoteId,不重复递。
|
|
436
449
|
*/
|
|
437
450
|
private latestNote(now: number): { id: string; text: string } | null {
|
|
438
|
-
const recent = this.pool.recent(
|
|
451
|
+
const recent = this.pool.recent(12).reverse();
|
|
439
452
|
for (const t of recent) {
|
|
440
453
|
if (!t.nextNote) continue;
|
|
441
454
|
if (t.id === this.budget.lastNoteId) continue;
|
|
442
455
|
const at = Date.parse(t.ts) || 0;
|
|
443
|
-
|
|
456
|
+
// 便签能存多久,跟着她自己定的间隔走(以前硬 12 小时,"明早再看"会直接丢)
|
|
457
|
+
if (!at || now - at > noteTtlMs(t)) continue;
|
|
444
458
|
return { id: t.id, text: t.nextNote };
|
|
445
459
|
}
|
|
446
460
|
return null;
|
|
@@ -688,6 +702,22 @@ export class SelfAwarenessWorld implements World {
|
|
|
688
702
|
today: { count: this.budget.count, tokens: this.budget.tokens },
|
|
689
703
|
limit: { count: Number(cfg.dailyLimit) || 0, tokens: Number(cfg.dailyTokenBudget) || 0 },
|
|
690
704
|
nextDueAt: this.budget.nextDueAt ?? null,
|
|
705
|
+
// 她说「先搁着」的话,页面就别再写「等下一次思考」了——她是在歇,不是卡住了
|
|
706
|
+
resting: (() => {
|
|
707
|
+
const last = this.pool.recent(1)[0];
|
|
708
|
+
return last?.rest ? { at: last.ts, until: this.budget.nextDueAt ?? null } : null;
|
|
709
|
+
})(),
|
|
710
|
+
// 给页面用的「当前那张便签」:过期的不算,免得侧栏挂着三天前的话
|
|
711
|
+
note: (() => {
|
|
712
|
+
// 便签有效期现在能到 36 小时,往回多看几条,别因为条数少就漏了它
|
|
713
|
+
for (const t of this.pool.recent(12).reverse()) {
|
|
714
|
+
if (!t.nextNote) continue;
|
|
715
|
+
const at = Date.parse(t.ts) || 0;
|
|
716
|
+
if (!at || Date.now() - at > noteTtlMs(t)) continue;
|
|
717
|
+
return { text: t.nextNote, in: t.nextIn ?? null, at: t.ts, mode: t.mode };
|
|
718
|
+
}
|
|
719
|
+
return null;
|
|
720
|
+
})(),
|
|
691
721
|
totalThoughts: this.pool.all().length,
|
|
692
722
|
thoughts: this.pool
|
|
693
723
|
.all()
|
|
@@ -702,6 +732,10 @@ export class SelfAwarenessWorld implements World {
|
|
|
702
732
|
carry: Boolean(t.carry),
|
|
703
733
|
nextNote: t.nextNote ?? null,
|
|
704
734
|
nextIn: t.nextIn ?? null,
|
|
735
|
+
rest: Boolean(t.rest),
|
|
736
|
+
mood: typeof t.mood === 'number' ? t.mood : null,
|
|
737
|
+
energy: typeof t.energy === 'number' ? t.energy : null,
|
|
738
|
+
phase: t.phase ?? null,
|
|
705
739
|
promptTokens: t.promptTokens ?? 0,
|
|
706
740
|
outputTokens: t.outputTokens ?? 0,
|
|
707
741
|
})),
|
package/webui/index.html
CHANGED
|
@@ -5,267 +5,356 @@
|
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
6
6
|
<title>她的时间线 · 自我意识</title>
|
|
7
7
|
<style>
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
8
|
+
:root {
|
|
9
|
+
--bg: #080c14;
|
|
10
|
+
--bg-deep: #060910;
|
|
11
|
+
--surface: #0e1622;
|
|
12
|
+
--surface-2: #121d2c;
|
|
13
|
+
--surface-3: #172337;
|
|
14
|
+
--line: rgba(143, 183, 221, .18);
|
|
15
|
+
--line-soft: rgba(143, 183, 221, .1);
|
|
16
|
+
--text: #e7edf7;
|
|
17
|
+
--muted: #8b9ab0;
|
|
18
|
+
--faint: #56657b;
|
|
19
|
+
--cyan: #66e3d3;
|
|
20
|
+
--cyan-soft: rgba(102, 227, 211, .12);
|
|
21
|
+
--purple: #c9a2ff;
|
|
22
|
+
--purple-soft: rgba(201, 162, 255, .12);
|
|
23
|
+
--blue: #8cc4ff;
|
|
24
|
+
--amber: #f4c47c;
|
|
25
|
+
--rose: #f2a6c9;
|
|
26
|
+
--red: #ff9f9b;
|
|
27
|
+
--mono: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
|
|
28
|
+
}
|
|
29
|
+
* { box-sizing: border-box; }
|
|
30
|
+
html { background: var(--bg); }
|
|
31
|
+
body {
|
|
32
|
+
margin: 0; min-width: 320px; color: var(--text); background:
|
|
33
|
+
linear-gradient(rgba(102, 227, 211, .025) 1px, transparent 1px),
|
|
34
|
+
linear-gradient(90deg, rgba(102, 227, 211, .025) 1px, transparent 1px),
|
|
35
|
+
radial-gradient(circle at 75% 0%, rgba(108, 77, 170, .14), transparent 34rem),
|
|
36
|
+
var(--bg);
|
|
37
|
+
background-size: 48px 48px, 48px 48px, auto, auto;
|
|
38
|
+
font: 14px/1.7 -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
|
|
39
|
+
padding: 30px 24px 72px;
|
|
40
|
+
}
|
|
41
|
+
button { font: inherit; }
|
|
42
|
+
.wrap { max-width: 1120px; margin: 0 auto; }
|
|
43
|
+
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 18px; padding: 3px 0 22px; border-bottom: 1px solid var(--line-soft); }
|
|
44
|
+
.brand { display: flex; align-items: center; gap: 11px; }
|
|
45
|
+
.brand-mark { width: 10px; height: 10px; border: 1px solid var(--cyan); border-radius: 50%; box-shadow: 0 0 0 4px rgba(102, 227, 211, .08); }
|
|
46
|
+
.brand-title { font-size: 18px; font-weight: 500; letter-spacing: .03em; }
|
|
47
|
+
.brand-sub { margin-left: 10px; color: var(--faint); font: 11px var(--mono); letter-spacing: .03em; }
|
|
48
|
+
.live { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; }
|
|
49
|
+
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--cyan); box-shadow: 0 0 10px rgba(102, 227, 211, .75); }
|
|
50
|
+
.live-dot.offline { background: var(--faint); box-shadow: none; }
|
|
51
|
+
.live-dot.error { background: var(--red); box-shadow: 0 0 10px rgba(255, 159, 155, .55); }
|
|
52
|
+
.hero { display: flex; justify-content: space-between; align-items: flex-end; gap: 28px; padding: 34px 0 25px; }
|
|
53
|
+
.eyebrow { color: var(--cyan); font: 11px var(--mono); letter-spacing: .14em; text-transform: uppercase; }
|
|
54
|
+
h1 { margin: 8px 0 5px; font-size: 30px; line-height: 1.2; font-weight: 500; letter-spacing: .02em; }
|
|
55
|
+
.hero-copy { color: var(--muted); max-width: 630px; }
|
|
56
|
+
.hero-id { color: var(--faint); font: 11px var(--mono); text-align: right; line-height: 1.8; }
|
|
57
|
+
.signal-bar { display: grid; grid-template-columns: 1.35fr repeat(3, minmax(110px, .55fr)); gap: 1px; overflow: hidden; background: var(--line); border: 1px solid var(--line); border-radius: 12px; margin-bottom: 30px; }
|
|
58
|
+
.signal, .next-signal { background: rgba(14, 22, 34, .94); min-height: 92px; padding: 17px 19px; }
|
|
59
|
+
.signal-label { color: var(--faint); font-size: 11px; letter-spacing: .08em; }
|
|
60
|
+
.signal-value { margin-top: 5px; font-size: 22px; line-height: 1.25; font-weight: 500; font-variant-numeric: tabular-nums; }
|
|
61
|
+
.signal-value.small { font-size: 15px; }
|
|
62
|
+
.signal-note { color: var(--muted); font-size: 11px; margin-top: 4px; }
|
|
63
|
+
.next-signal { position: relative; background: linear-gradient(115deg, rgba(201, 162, 255, .13), rgba(14, 22, 34, .95) 60%); }
|
|
64
|
+
.next-signal::before { content: ''; position: absolute; left: 0; top: 18px; bottom: 18px; width: 2px; background: var(--purple); }
|
|
65
|
+
.next-signal .signal-label, .next-signal .signal-value { padding-left: 3px; }
|
|
66
|
+
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 30px; align-items: start; }
|
|
67
|
+
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 17px; }
|
|
68
|
+
.section-title { margin: 0; font-size: 13px; font-weight: 500; letter-spacing: .13em; color: var(--muted); }
|
|
69
|
+
.section-count { color: var(--faint); font: 11px var(--mono); }
|
|
70
|
+
.filters { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 23px; }
|
|
71
|
+
.filter { color: var(--muted); background: transparent; border: 1px solid var(--line); border-radius: 5px; padding: 5px 10px; cursor: pointer; font-size: 12px; transition: .18s ease; }
|
|
72
|
+
.filter:hover, .filter.active { color: var(--cyan); border-color: rgba(102, 227, 211, .55); background: var(--cyan-soft); }
|
|
73
|
+
.mode-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: -10px 0 22px; color: var(--faint); font-size: 11px; line-height: 1.7; }
|
|
74
|
+
.mode-legend span { display: inline-flex; align-items: center; gap: 6px; }
|
|
75
|
+
.mode-legend i { width: 5px; height: 5px; border-radius: 50%; flex: none; }
|
|
76
|
+
.mode-legend b { color: var(--muted); font-weight: 400; }
|
|
77
|
+
.day { margin: 0 0 26px; }
|
|
78
|
+
.day-label { display: flex; align-items: center; gap: 10px; margin: 0 0 15px 22px; color: var(--faint); font: 11px var(--mono); letter-spacing: .1em; }
|
|
79
|
+
.day-label::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: var(--cyan); }
|
|
80
|
+
.timeline { position: relative; padding-left: 23px; }
|
|
81
|
+
.timeline::before { content: ''; position: absolute; left: 4px; top: 8px; bottom: 13px; width: 1px; background: linear-gradient(var(--line), rgba(143, 183, 221, 0)); }
|
|
82
|
+
.item { position: relative; padding: 0 0 24px; }
|
|
83
|
+
.item::before { content: ''; position: absolute; left: -22px; top: 8px; width: 7px; height: 7px; border: 2px solid var(--bg); border-radius: 50%; background: var(--cyan); box-shadow: 0 0 0 1px rgba(102, 227, 211, .6); }
|
|
84
|
+
.item.wonder::before { background: var(--purple); box-shadow: 0 0 0 1px rgba(201, 162, 255, .55); }
|
|
85
|
+
.item.plan::before { background: var(--blue); box-shadow: 0 0 0 1px rgba(140, 196, 255, .55); }
|
|
86
|
+
.item.doubt::before { background: var(--amber); box-shadow: 0 0 0 1px rgba(244, 196, 124, .55); }
|
|
87
|
+
.item.synthesize::before { background: var(--rose); box-shadow: 0 0 0 1px rgba(242, 166, 201, .55); }
|
|
88
|
+
.meta { display: flex; align-items: center; flex-wrap: wrap; gap: 9px; color: var(--faint); font: 11px var(--mono); margin-bottom: 7px; }
|
|
89
|
+
.mode { color: var(--cyan); font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif; font-size: 12px; }
|
|
90
|
+
.item.wonder .mode { color: var(--purple); }
|
|
91
|
+
.item.plan .mode { color: var(--blue); }
|
|
92
|
+
.item.doubt .mode { color: var(--amber); }
|
|
93
|
+
.item.synthesize .mode { color: var(--rose); }
|
|
94
|
+
.carry { color: var(--purple); font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif; }
|
|
95
|
+
.rest-tag { color: var(--rose); font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif; }
|
|
96
|
+
.importance { display: inline-flex; gap: 3px; align-items: center; }
|
|
97
|
+
.importance i { display: block; width: 4px; height: 4px; border-radius: 50%; background: var(--faint); opacity: .45; }
|
|
98
|
+
.importance i.on { background: var(--purple); opacity: .9; }
|
|
99
|
+
.text { color: var(--text); font-size: 15px; line-height: 1.9; white-space: pre-wrap; word-break: break-word; }
|
|
100
|
+
.item:hover .text { color: #f3f7fd; }
|
|
101
|
+
.note-line { margin-top: 11px; padding: 8px 12px; color: var(--purple); background: var(--purple-soft); border-left: 2px solid var(--purple); border-radius: 0 6px 6px 0; font-size: 12px; }
|
|
102
|
+
.note-line span { color: rgba(201, 162, 255, .65); margin-left: 5px; font-family: var(--mono); }
|
|
103
|
+
.empty { color: var(--muted); padding: 26px 0; border-top: 1px dashed var(--line); }
|
|
104
|
+
.aside { display: flex; flex-direction: column; gap: 12px; }
|
|
105
|
+
.card { position: relative; background: rgba(14, 22, 34, .92); border: 1px solid var(--line); border-radius: 11px; padding: 17px; }
|
|
106
|
+
.card-title { display: flex; justify-content: space-between; gap: 10px; align-items: center; color: var(--muted); font-size: 12px; letter-spacing: .08em; }
|
|
107
|
+
.card-title b { color: var(--text); font-weight: 500; letter-spacing: 0; }
|
|
108
|
+
.next-card { border-color: rgba(201, 162, 255, .34); background: linear-gradient(145deg, rgba(201, 162, 255, .11), rgba(14, 22, 34, .96) 55%); }
|
|
109
|
+
.next-card .card-title { color: var(--purple); }
|
|
110
|
+
.next-text { margin: 15px 0 12px; color: var(--text); line-height: 1.8; }
|
|
111
|
+
.next-time { color: var(--muted); font: 11px var(--mono); }
|
|
112
|
+
.disclaimer { margin-top: 12px; padding-top: 11px; border-top: 1px solid var(--line-soft); color: var(--faint); font-size: 11px; line-height: 1.6; }
|
|
113
|
+
.health { display: flex; align-items: center; gap: 7px; color: var(--cyan); font-size: 12px; }
|
|
114
|
+
.health.error { color: var(--red); }
|
|
115
|
+
.health.offline { color: var(--muted); }
|
|
116
|
+
.health-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
|
|
117
|
+
.details { margin-top: 14px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
|
|
118
|
+
.detail { padding: 9px 10px; background: rgba(86, 101, 123, .1); border-radius: 6px; }
|
|
119
|
+
.detail span { display: block; color: var(--faint); font-size: 10px; }
|
|
120
|
+
.detail b { display: block; margin-top: 2px; font: 12px var(--mono); color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
121
|
+
.probe { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 14px; padding-top: 13px; border-top: 1px solid var(--line-soft); }
|
|
122
|
+
.probe button { color: var(--cyan); background: transparent; border: 1px solid rgba(102, 227, 211, .38); border-radius: 5px; padding: 5px 9px; cursor: pointer; font-size: 11px; transition: .18s ease; }
|
|
123
|
+
.probe button:hover:not(:disabled) { background: var(--cyan-soft); border-color: var(--cyan); }
|
|
124
|
+
.probe button:disabled { color: var(--faint); cursor: default; }
|
|
125
|
+
.probe-result { color: var(--muted); font: 10px var(--mono); }
|
|
126
|
+
.probe-result.ok { color: var(--cyan); }
|
|
127
|
+
.probe-result.bad { color: var(--red); }
|
|
128
|
+
.probe-result.wait { color: var(--amber); }
|
|
129
|
+
.err { color: var(--red); border: 1px solid rgba(255, 159, 155, .27); background: rgba(255, 159, 155, .07); border-radius: 7px; padding: 9px 12px; margin-bottom: 18px; font-size: 12px; }
|
|
130
|
+
.reflections { margin-top: 20px; padding-top: 24px; border-top: 1px solid var(--line-soft); }
|
|
131
|
+
.refl { margin-bottom: 10px; padding: 13px 15px; background: rgba(102, 227, 211, .06); border-left: 2px solid var(--cyan); border-radius: 0 7px 7px 0; }
|
|
132
|
+
.refl .meta { margin-bottom: 5px; }
|
|
133
|
+
footer { margin-top: 38px; color: var(--faint); font-size: 11px; }
|
|
134
|
+
code { color: var(--muted); font: 11px var(--mono); }
|
|
135
|
+
@media (max-width: 780px) {
|
|
136
|
+
body { padding: 22px 16px 55px; }
|
|
137
|
+
.hero { display: block; padding-top: 27px; }
|
|
138
|
+
.hero-id { margin-top: 13px; text-align: left; }
|
|
139
|
+
.signal-bar { grid-template-columns: 1fr 1fr; }
|
|
140
|
+
.next-signal { grid-column: span 2; }
|
|
141
|
+
.layout { grid-template-columns: 1fr; }
|
|
142
|
+
.aside { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
|
|
143
|
+
.aside .next-card { grid-column: span 2; }
|
|
144
|
+
}
|
|
145
|
+
@media (max-width: 520px) {
|
|
146
|
+
.topbar { align-items: flex-start; }
|
|
147
|
+
.brand { align-items: flex-start; }
|
|
148
|
+
.brand-sub { display: block; margin: 3px 0 0; }
|
|
149
|
+
.live { white-space: nowrap; }
|
|
150
|
+
h1 { font-size: 25px; }
|
|
151
|
+
.signal-bar { grid-template-columns: 1fr 1fr; }
|
|
152
|
+
.signal, .next-signal { min-height: 78px; padding: 13px 14px; }
|
|
153
|
+
.signal-value { font-size: 18px; }
|
|
154
|
+
.aside { display: flex; }
|
|
155
|
+
.text { font-size: 14px; }
|
|
156
|
+
}
|
|
113
157
|
</style>
|
|
114
158
|
</head>
|
|
115
159
|
<body>
|
|
116
160
|
<div class="wrap">
|
|
117
|
-
<header>
|
|
118
|
-
<
|
|
119
|
-
|
|
161
|
+
<header class="topbar">
|
|
162
|
+
<div class="brand">
|
|
163
|
+
<span class="brand-mark" aria-hidden="true"></span>
|
|
164
|
+
<div><span class="brand-title">她的时间线</span><span class="brand-sub" id="sub">SELF-AWARENESS / LOADING</span></div>
|
|
165
|
+
</div>
|
|
166
|
+
<div class="live"><span class="live-dot" id="liveDot"></span><span id="liveText">正在读取状态</span></div>
|
|
120
167
|
</header>
|
|
121
168
|
|
|
122
|
-
<
|
|
123
|
-
<div
|
|
124
|
-
|
|
125
|
-
<
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
<
|
|
132
|
-
|
|
169
|
+
<section class="hero">
|
|
170
|
+
<div>
|
|
171
|
+
<div class="eyebrow">Private thought archive / 01</div>
|
|
172
|
+
<h1>那些没有说出口的片刻</h1>
|
|
173
|
+
<div class="hero-copy">她在安静时留下的思绪轨迹。这里记录的是模型生成的内在笔记,不代表持续存在的主观体验。</div>
|
|
174
|
+
</div>
|
|
175
|
+
<div class="hero-id">LOCAL NODE<br><span id="heroModel">MODEL / --</span></div>
|
|
176
|
+
</section>
|
|
177
|
+
|
|
178
|
+
<section class="signal-bar" aria-label="运行概览">
|
|
179
|
+
<div class="next-signal">
|
|
180
|
+
<div class="signal-label">NEXT THOUGHT / 下一次</div>
|
|
181
|
+
<div class="signal-value small" id="next">未安排</div>
|
|
182
|
+
<div class="signal-note" id="nextHint">由她上一次留下的安排决定</div>
|
|
183
|
+
</div>
|
|
184
|
+
<div class="signal"><div class="signal-label">TODAY / 今日</div><div class="signal-value" id="todayCount">0</div><div class="signal-note">次思考</div></div>
|
|
185
|
+
<div class="signal"><div class="signal-label">TOKENS / 消耗</div><div class="signal-value" id="todayTokens">0</div><div class="signal-note">本地统计</div></div>
|
|
186
|
+
<div class="signal"><div class="signal-label">ARCHIVE / 记录</div><div class="signal-value" id="totalThoughts">0</div><div class="signal-note">条思绪</div></div>
|
|
187
|
+
</section>
|
|
133
188
|
|
|
134
|
-
<
|
|
135
|
-
<div
|
|
189
|
+
<div id="err"></div>
|
|
190
|
+
<div class="layout">
|
|
191
|
+
<main>
|
|
192
|
+
<div class="section-head"><h2 class="section-title">THOUGHT STREAM / 思绪流</h2><span class="section-count" id="sectionCount">0 EVENTS</span></div>
|
|
193
|
+
<div class="filters" role="tablist" aria-label="筛选思绪类型">
|
|
194
|
+
<button class="filter active" data-filter="all">全部</button>
|
|
195
|
+
<button class="filter" data-filter="reflect">回看</button>
|
|
196
|
+
<button class="filter" data-filter="wonder">走神</button>
|
|
197
|
+
<button class="filter" data-filter="plan">打算</button>
|
|
198
|
+
<button class="filter" data-filter="doubt">琢磨</button>
|
|
199
|
+
<button class="filter" data-filter="synthesize">综合</button>
|
|
200
|
+
</div>
|
|
201
|
+
<div class="mode-legend">
|
|
202
|
+
<span><i style="background:var(--cyan)"></i><b>回看</b>想起以前的事</span>
|
|
203
|
+
<span><i style="background:var(--purple)"></i><b>走神</b>没缘由地飘走</span>
|
|
204
|
+
<span><i style="background:var(--blue)"></i><b>打算</b>接下来想做什么</span>
|
|
205
|
+
<span><i style="background:var(--amber)"></i><b>琢磨</b>一件没想明白的</span>
|
|
206
|
+
<span><i style="background:var(--rose)"></i><b>综合</b>两件不相干的事找共同点</span>
|
|
207
|
+
</div>
|
|
208
|
+
<div id="list"><div class="empty">还没有想法。<br>她会在安静时留下下一条思绪,第一条通常要等几分钟。</div></div>
|
|
209
|
+
<section class="reflections" id="reflWrap" hidden>
|
|
210
|
+
<div class="section-head"><h2 class="section-title">SELF REVIEW / 她对自己的看法</h2></div>
|
|
211
|
+
<div id="refl"></div>
|
|
212
|
+
</section>
|
|
213
|
+
</main>
|
|
136
214
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
215
|
+
<aside class="aside">
|
|
216
|
+
<section class="card next-card">
|
|
217
|
+
<div class="card-title"><span>NEXT NOTE / 留给下一次</span><b id="nextMode">—</b></div>
|
|
218
|
+
<div class="next-text" id="nextNote">她还没有给下一次留下便笺。</div>
|
|
219
|
+
<div class="next-time" id="nextDue">WAITING / 等待下一次安排</div>
|
|
220
|
+
<div class="disclaimer">时间来自上一次生成的自我安排。睡眠、对话或接口状态可能让它推迟。</div>
|
|
221
|
+
</section>
|
|
222
|
+
<section class="card">
|
|
223
|
+
<div class="card-title"><span>SYSTEM SIGNAL / 系统信号</span><span class="health" id="health"><i class="health-dot"></i><span>读取中</span></span></div>
|
|
224
|
+
<div class="details">
|
|
225
|
+
<div class="detail"><span>MODEL</span><b id="model">--</b></div>
|
|
226
|
+
<div class="detail"><span>MODE</span><b id="enabled">--</b></div>
|
|
227
|
+
<div class="detail"><span>DAILY LIMIT</span><b id="dailyLimit">--</b></div>
|
|
228
|
+
<div class="detail"><span>LAST ERROR</span><b id="lastError">NONE</b></div>
|
|
229
|
+
</div>
|
|
230
|
+
<div class="probe"><span class="probe-result" id="probeMsg">接口检测不会写入思绪</span><button id="probe" title="发送一次最小请求来测试接口">测接口</button></div>
|
|
231
|
+
</section>
|
|
232
|
+
<section class="card">
|
|
233
|
+
<div class="card-title"><span>ABOUT THIS SPACE / 关于这里</span></div>
|
|
234
|
+
<div style="color:var(--muted);font-size:12px;line-height:1.8;margin-top:10px">这是她自己的本地思绪档案。记忆核心会在合适的时候挑选其中的内容带回对话,并明确标记来源与时间。</div>
|
|
235
|
+
</section>
|
|
236
|
+
</aside>
|
|
140
237
|
</div>
|
|
141
238
|
|
|
142
|
-
<footer>
|
|
143
|
-
数据来自 <code>self-awareness/thoughts.jsonl</code>,只存在这台机器上。每 30 秒自动刷新。
|
|
144
|
-
</footer>
|
|
239
|
+
<footer>DATA SOURCE · <code>self-awareness/thoughts.jsonl</code> · 只存在这台机器上 · 每 30 秒自动刷新</footer>
|
|
145
240
|
</div>
|
|
146
|
-
|
|
147
241
|
<script>
|
|
148
|
-
const MODE_NAME = { reflect: '回看', wonder: '走神', plan: '打算', doubt: '琢磨' };
|
|
242
|
+
const MODE_NAME = { reflect: '回看', wonder: '走神', plan: '打算', doubt: '琢磨', synthesize: '综合' };
|
|
243
|
+
let allThoughts = [];
|
|
244
|
+
let activeFilter = 'all';
|
|
149
245
|
|
|
150
246
|
function esc(s) {
|
|
151
|
-
return String(s ?? '').replace(/[
|
|
247
|
+
return String(s ?? '').replace(/[&<>\"]/g, (c) => ({ '&': '&', '<': '<', '>': '>', '\"': '"' }[c]));
|
|
152
248
|
}
|
|
153
|
-
|
|
249
|
+
function dateObj(iso) { const d = new Date(iso); return Number.isNaN(d.getTime()) ? null : d; }
|
|
154
250
|
function clock(iso) {
|
|
155
|
-
const d =
|
|
156
|
-
if (Number.isNaN(d.getTime())) return '';
|
|
251
|
+
const d = dateObj(iso); if (!d) return '';
|
|
157
252
|
const p = (n) => String(n).padStart(2, '0');
|
|
158
|
-
return `${p(d.
|
|
253
|
+
return `${p(d.getHours())}:${p(d.getMinutes())}`;
|
|
159
254
|
}
|
|
160
|
-
|
|
255
|
+
function dateKey(iso) { const d = dateObj(iso); return d ? `${d.getFullYear()}-${d.getMonth()}-${d.getDate()}` : 'unknown'; }
|
|
256
|
+
function dateLabel(iso) {
|
|
257
|
+
const d = dateObj(iso); if (!d) return 'UNKNOWN DATE';
|
|
258
|
+
const now = new Date();
|
|
259
|
+
if (dateKey(iso) === dateKey(now.toISOString())) return 'TODAY / 今天';
|
|
260
|
+
const yesterday = new Date(now); yesterday.setDate(now.getDate() - 1);
|
|
261
|
+
if (dateKey(iso) === dateKey(yesterday.toISOString())) return 'YESTERDAY / 昨天';
|
|
262
|
+
return `${String(d.getMonth() + 1).padStart(2, '0')}.${String(d.getDate()).padStart(2, '0')} / ${d.getFullYear()}`;
|
|
263
|
+
}
|
|
264
|
+
function nextClock(iso) { const d = dateObj(iso); return d ? `${String(d.getMonth() + 1).padStart(2, '0')}-${String(d.getDate()).padStart(2, '0')} ${clock(iso)}` : '未安排'; }
|
|
161
265
|
function dots(n) {
|
|
162
|
-
|
|
163
|
-
|
|
266
|
+
const value = Math.max(0, Math.min(10, Number(n) || 0));
|
|
267
|
+
let out = '<span class="importance" title="重要度 ' + value + ' / 10">';
|
|
268
|
+
for (let i = 1; i <= 10; i += 1) out += `<i class="${i <= value ? 'on' : ''}"></i>`;
|
|
164
269
|
return out + '</span>';
|
|
165
270
|
}
|
|
166
|
-
|
|
167
|
-
function
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
${dots(t.importance)}
|
|
192
|
-
${t.carry ? '<span class="carry">接着上次</span>' : ''}
|
|
193
|
-
</div>
|
|
271
|
+
function formatNumber(n) { return Number(n || 0).toLocaleString('zh-CN'); }
|
|
272
|
+
function statusInfo(d) {
|
|
273
|
+
if (d.error) return { kind: 'error', text: '上次调用有错误' };
|
|
274
|
+
if (!d.enabled) return { kind: 'offline', text: '已暂停' };
|
|
275
|
+
return { kind: 'online', text: '自我意识运行中' };
|
|
276
|
+
}
|
|
277
|
+
function renderThoughts() {
|
|
278
|
+
const list = allThoughts.filter((t) => activeFilter === 'all' || t.mode === activeFilter);
|
|
279
|
+
const count = document.getElementById('sectionCount');
|
|
280
|
+
count.textContent = `${list.length} EVENT${list.length === 1 ? '' : 'S'}`;
|
|
281
|
+
if (!list.length) {
|
|
282
|
+
document.getElementById('list').innerHTML = '<div class="empty">这个筛选下还没有思绪。</div>';
|
|
283
|
+
return;
|
|
284
|
+
}
|
|
285
|
+
const groups = [];
|
|
286
|
+
const map = new Map();
|
|
287
|
+
list.forEach((t) => {
|
|
288
|
+
const key = dateKey(t.ts);
|
|
289
|
+
if (!map.has(key)) { const group = { key, ts: t.ts, items: [] }; map.set(key, group); groups.push(group); }
|
|
290
|
+
map.get(key).items.push(t);
|
|
291
|
+
});
|
|
292
|
+
document.getElementById('list').innerHTML = groups.map((g) => `
|
|
293
|
+
<section class="day"><div class="day-label">${dateLabel(g.ts)}</div><div class="timeline">
|
|
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 ? '<span class="carry">接着上一条</span>' : ''}${t.rest ? '<span class="rest-tag">她先搁着了</span>' : ''}</div>
|
|
194
296
|
<div class="text">${esc(t.text)}</div>
|
|
195
|
-
${t.nextNote ? `<div class="note-line"
|
|
196
|
-
</
|
|
197
|
-
|
|
198
|
-
|
|
297
|
+
${t.nextNote ? `<div class="note-line">留给下一次:${esc(t.nextNote)}${t.nextIn ? `<span>+${esc(t.nextIn)} MIN</span>` : ''}</div>` : ''}
|
|
298
|
+
</article>`).join('')}
|
|
299
|
+
</div></section>`).join('');
|
|
300
|
+
}
|
|
301
|
+
function render(d) {
|
|
302
|
+
const status = statusInfo(d);
|
|
303
|
+
const model = d.model || '未配置';
|
|
304
|
+
const next = d.nextDueAt ? nextClock(d.nextDueAt) : '未安排';
|
|
305
|
+
document.getElementById('sub').textContent = `SELF-AWARENESS / ${String(model).toUpperCase()}`;
|
|
306
|
+
document.getElementById('heroModel').textContent = `MODEL / ${model}`;
|
|
307
|
+
document.getElementById('next').textContent = next;
|
|
308
|
+
document.getElementById('nextHint').textContent = d.resting
|
|
309
|
+
? '她自己叫停了,不是卡住'
|
|
310
|
+
: d.nextDueAt ? '她给未来的自己留了一点方向' : '由她下一次思考时自行决定';
|
|
311
|
+
document.getElementById('todayCount').textContent = formatNumber(d.today?.count);
|
|
312
|
+
document.getElementById('todayTokens').textContent = formatNumber(d.today?.tokens);
|
|
313
|
+
document.getElementById('totalThoughts').textContent = formatNumber(d.totalThoughts);
|
|
314
|
+
document.getElementById('model').textContent = model;
|
|
315
|
+
document.getElementById('enabled').textContent = d.enabled ? 'RUNNING' : 'PAUSED';
|
|
316
|
+
document.getElementById('dailyLimit').textContent = d.limit?.count ? `${d.limit.count} / DAY` : 'NO LIMIT';
|
|
317
|
+
document.getElementById('lastError').textContent = d.error ? 'DETECTED' : 'NONE';
|
|
318
|
+
const liveDot = document.getElementById('liveDot'); liveDot.className = `live-dot ${status.kind === 'online' ? '' : status.kind}`;
|
|
319
|
+
document.getElementById('liveText').textContent = status.text;
|
|
320
|
+
const health = document.getElementById('health'); health.className = `health ${status.kind === 'online' ? '' : status.kind}`; health.innerHTML = `<i class="health-dot"></i><span>${status.kind === 'online' ? 'ONLINE' : status.kind === 'error' ? 'ERROR' : 'OFFLINE'}</span>`;
|
|
321
|
+
document.getElementById('err').innerHTML = d.error ? `<div class="err">上次调用失败:${esc(d.error)}</div>` : '';
|
|
322
|
+
allThoughts = d.thoughts || [];
|
|
323
|
+
const note = d.note;
|
|
324
|
+
document.getElementById('nextNote').textContent = note?.text || '她还没有给下一次留下便笺。';
|
|
325
|
+
document.getElementById('nextMode').textContent = note ? (MODE_NAME[note.mode] || '思绪') : '—';
|
|
326
|
+
document.getElementById('nextDue').textContent = d.resting
|
|
327
|
+
? (d.nextDueAt ? `RESTING / 她说先搁着,${next} 再看` : 'RESTING / 她说到这儿了')
|
|
328
|
+
: note?.in ? `NEXT / ${note.in} MINUTES LATER` : (d.nextDueAt ? `NEXT / ${next}` : 'WAITING / 等待下一次安排');
|
|
199
329
|
const refl = d.reflections || [];
|
|
200
330
|
document.getElementById('reflWrap').hidden = !refl.length;
|
|
201
|
-
document.getElementById('refl').innerHTML = refl.map((r) =>
|
|
202
|
-
|
|
203
|
-
<div class="meta"><span>${clock(r.ts)}</span><span>由 ${r.fromCount} 条想法收成</span></div>
|
|
204
|
-
<div class="text">${esc(r.text)}</div>
|
|
205
|
-
</div>`).join('');
|
|
331
|
+
document.getElementById('refl').innerHTML = refl.map((r) => `<div class="refl"><div class="meta"><span>${clock(r.ts)}</span><span>由 ${r.fromCount} 条想法收成</span></div><div class="text">${esc(r.text)}</div></div>`).join('');
|
|
332
|
+
renderThoughts();
|
|
206
333
|
}
|
|
207
|
-
|
|
208
334
|
async function load() {
|
|
209
|
-
try {
|
|
210
|
-
|
|
211
|
-
render(await rsp.json());
|
|
212
|
-
} catch (e) {
|
|
213
|
-
document.getElementById('sub').textContent = '读不到数据';
|
|
214
|
-
}
|
|
335
|
+
try { const rsp = await fetch('/api/data', { cache: 'no-store' }); render(await rsp.json()); }
|
|
336
|
+
catch (e) { document.getElementById('sub').textContent = 'SELF-AWARENESS / UNAVAILABLE'; document.getElementById('liveText').textContent = '读不到时间线服务'; document.getElementById('liveDot').className = 'live-dot error'; }
|
|
215
337
|
}
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
const
|
|
338
|
+
document.querySelectorAll('.filter').forEach((button) => button.addEventListener('click', () => {
|
|
339
|
+
activeFilter = button.dataset.filter;
|
|
340
|
+
document.querySelectorAll('.filter').forEach((b) => b.classList.toggle('active', b === button));
|
|
341
|
+
renderThoughts();
|
|
342
|
+
}));
|
|
343
|
+
const probeButton = document.getElementById('probe');
|
|
222
344
|
const probeMsg = document.getElementById('probeMsg');
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
probeBtn.disabled = true;
|
|
226
|
-
probeBtn.className = 'probe-card testing';
|
|
227
|
-
probeLabel.textContent = '测中';
|
|
228
|
-
probeMsg.hidden = false;
|
|
229
|
-
probeMsg.className = 'probe-msg';
|
|
230
|
-
probeMsg.textContent = '正在发一句「在吗」…';
|
|
345
|
+
probeButton.addEventListener('click', async () => {
|
|
346
|
+
probeButton.disabled = true; probeButton.textContent = '检测中'; probeMsg.className = 'probe-result'; probeMsg.textContent = '发送最小请求…';
|
|
231
347
|
try {
|
|
232
|
-
const rsp = await fetch('/api/probe', { method: 'POST' });
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
probeLabel.textContent = '等一下';
|
|
239
|
-
probeMsg.className = 'probe-msg';
|
|
240
|
-
probeMsg.textContent = '刚才测过,隔十秒再点一次';
|
|
241
|
-
} else {
|
|
242
|
-
probeBtn.className = 'probe-card ' + (ok ? 'ok' : 'bad');
|
|
243
|
-
probeLabel.textContent = ok ? `通了 ${r.ms}ms` : '没通';
|
|
244
|
-
probeMsg.className = 'probe-msg ' + (ok ? 'ok' : 'bad');
|
|
245
|
-
probeMsg.textContent = ok
|
|
246
|
-
? `接口正常 · ${r.model} · 往返 ${r.ms}ms`
|
|
247
|
-
: `接口不通 · ${r.error}`;
|
|
248
|
-
}
|
|
249
|
-
} catch (e) {
|
|
250
|
-
probeBtn.className = 'probe-card bad';
|
|
251
|
-
probeLabel.textContent = '没通';
|
|
252
|
-
probeMsg.className = 'probe-msg bad';
|
|
253
|
-
probeMsg.textContent = '请求发不出去,时间线服务可能已经停了';
|
|
254
|
-
} finally {
|
|
255
|
-
setTimeout(() => {
|
|
256
|
-
probeBtn.disabled = false;
|
|
257
|
-
probeBtn.className = 'probe-card';
|
|
258
|
-
probeLabel.textContent = '测接口';
|
|
259
|
-
probeMsg.hidden = true;
|
|
260
|
-
}, 8000);
|
|
261
|
-
}
|
|
348
|
+
const rsp = await fetch('/api/probe', { method: 'POST' }); const r = await rsp.json();
|
|
349
|
+
if (r.throttled) { probeMsg.className = 'probe-result wait'; probeMsg.textContent = '刚测过,请稍等'; }
|
|
350
|
+
else if (r.ok) { probeMsg.className = 'probe-result ok'; probeMsg.textContent = `通了 · ${r.ms}ms`; }
|
|
351
|
+
else { probeMsg.className = 'probe-result bad'; probeMsg.textContent = '没通 · 查看错误'; }
|
|
352
|
+
} catch (e) { probeMsg.className = 'probe-result bad'; probeMsg.textContent = '服务不可达'; }
|
|
353
|
+
setTimeout(() => { probeButton.disabled = false; probeButton.textContent = '测接口'; }, 8000);
|
|
262
354
|
});
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
if (location.hash === '#probe')
|
|
266
|
-
|
|
267
|
-
// 带 #probe 打开就自动测一次:省得每次都要点(也方便截图看状态)
|
|
268
|
-
if (location.hash === '#probe') probeBtn.click();
|
|
355
|
+
load();
|
|
356
|
+
setInterval(load, 30000);
|
|
357
|
+
if (location.hash === '#probe') probeButton.click();
|
|
269
358
|
</script>
|
|
270
359
|
</body>
|
|
271
360
|
</html>
|