cortico-world-self-awareness 0.6.0 → 0.6.2

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 CHANGED
@@ -1,5 +1,29 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.6.2
4
+
5
+ **时间线换了一张脸,顺便补上一个漏掉的模式。**
6
+
7
+ - **页面重做**:从原来的一列灰字,改成「深空意识舱」——深空蓝黑底、紫色思绪、青色状态,左边是思绪流,右边是留给下一次的便笺和接口诊断。
8
+ 思绪按今天/昨天/日期分组,可筛选;正文放大到 15px、行高 1.9,长时间看不再费眼。
9
+ - **补 `synthesize`(综合)**:0.4.0 加了第五种模式,但页面上的模式表只认四个——综合模式会原样显示英文 `synthesize`,筛选栏里也没有它。
10
+ 现在有中文名、有颜色、能筛选。
11
+ - **五种模式有说明了**:筛选栏下面加一行图例,写明「回看/走神/打算/琢磨/综合」各自在做什么,不用再翻文档猜。
12
+ - 接口检测仍放在右侧「系统信号」卡片里;10 秒限流单独显示「等一下」,不冒充故障。
13
+ - 测试 54 项不变,全部通过。
14
+
15
+ ## 0.6.1
16
+
17
+ 把「测接口」做得能看见了。
18
+
19
+ - 从状态条下面的灰色小按钮,改成**状态条右侧的独立卡片**:脉冲图标 + 文字,高度和状态条齐平。
20
+ - 三种状态都有视觉反馈:测试中图标呼吸、通了整块变青、失败整块变红。
21
+ - 结果单独一行带淡入:`接口正常 · deepseek-flash · 往返 659ms`。
22
+ - **修一个误导**:10 秒限流时原来画成红色的「接口不通」,让人以为接口坏了。
23
+ 现在单独显示「等一下 · 刚才测过,隔十秒再点一次」,中性色,不冒充故障。
24
+ - 彩蛋:地址带 `#probe` 打开会自动测一次。
25
+
26
+ ## 0.6.0
3
27
  ## 0.6.0
4
28
 
5
29
  **能自己测接口了,状态灯也不再误导。**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cortico-world-self-awareness",
3
- "version": "0.6.0",
3
+ "version": "0.6.2",
4
4
  "type": "module",
5
5
  "description": "桌宠自己的内在时间线:没人说话的时候她也在想事情——想起旧事、走神、反复琢磨一件没想明白的。\n\n它只负责「想」:想到的写在本机一个文件里,不发消息,也不占对话的 token。配合「记忆核心」使用——你开口时,记忆核心会挑一条带进上下文,标明时间,并说清那不一定是你现在的想法。单独装也能跑,但那是一本她自己不会翻的日记。\n\n模型自选,OpenAI 兼容接口就行;默认一天最多 12 次,一次几分钱。\n\nQQ 交流群:745879632",
6
6
  "keywords": [
package/src/site.ts CHANGED
@@ -108,7 +108,8 @@ export class ThoughtSite {
108
108
  const now = Date.now();
109
109
  if (now - this.lastProbe < PROBE_GAP_MS) {
110
110
  rsp.writeHead(429, { 'content-type': 'application/json; charset=utf-8' });
111
- rsp.end(JSON.stringify({ ok: false, ms: 0, error: '刚测过,等几秒再来' }));
111
+ // 带 throttled 标记:限流不是「接口不通」,前端别把它画成红色失败
112
+ rsp.end(JSON.stringify({ ok: false, throttled: true, ms: 0, error: '刚测过,等几秒再来' }));
112
113
  return;
113
114
  }
114
115
  this.lastProbe = now;
package/webui/index.html CHANGED
@@ -5,217 +5,351 @@
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1">
6
6
  <title>她的时间线 · 自我意识</title>
7
7
  <style>
8
- :root {
9
- --bg: #060911;
10
- --panel: rgba(120, 220, 214, 0.045);
11
- --line: rgba(120, 220, 214, 0.14);
12
- --text: #d9e6f2;
13
- --dim: rgba(150, 172, 200, 0.55);
14
- --faint: rgba(150, 172, 200, 0.32);
15
- --accent: #7fe3d4;
16
- --reflect: #7fe3d4;
17
- --wonder: #b9a7ff;
18
- --plan: #8cc4ff;
19
- --doubt: #ffc27f;
20
- }
21
- * { box-sizing: border-box; }
22
- body {
23
- margin: 0; background: var(--bg); color: var(--text);
24
- font: 14px/1.65 -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
25
- padding: 28px 20px 64px;
26
- }
27
- .wrap { max-width: 760px; margin: 0 auto; }
28
- header { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; margin-bottom: 6px; }
29
- h1 { font-size: 17px; font-weight: 500; margin: 0; letter-spacing: .02em; }
30
- h1::before {
31
- content: ''; display: inline-block; width: 7px; height: 7px; border-radius: 50%;
32
- background: var(--accent); box-shadow: 0 0 12px var(--accent); margin-right: 9px; vertical-align: 3px;
33
- }
34
- .sub { color: var(--faint); font-size: 12px; letter-spacing: .04em; }
35
- .stats {
36
- display: flex; gap: 22px; flex-wrap: wrap; margin: 18px 0 26px;
37
- padding: 14px 16px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel);
38
- }
39
- .stat { min-width: 78px; }
40
- .stat b { display: block; font-size: 19px; font-weight: 500; font-variant-numeric: tabular-nums; }
41
- .stat span { color: var(--dim); font-size: 11.5px; }
42
- .warn { color: #ffb3a7; }
43
- .toolbar { display: flex; align-items: center; gap: 10px; margin: -8px 0 22px; flex-wrap: wrap; }
44
- .btn {
45
- background: transparent; border: 1px solid var(--line); color: var(--text);
46
- padding: 5px 13px; border-radius: 7px; font-size: 12px; cursor: pointer;
47
- font-family: inherit; transition: border-color .15s, color .15s;
48
- }
49
- .btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
50
- .btn:disabled { opacity: .45; cursor: default; }
51
- .probe { font-size: 12px; color: var(--dim); }
52
- .probe.ok { color: var(--accent); }
53
- .probe.bad { color: #ffb3a7; }
54
- .err {
55
- margin: 0 0 20px; padding: 10px 14px; border-radius: 8px;
56
- border: 1px solid rgba(255, 120, 100, 0.3); background: rgba(255, 90, 70, 0.07);
57
- color: #ffb3a7; font-size: 12.5px;
58
- }
59
- h2 {
60
- font-size: 12px; font-weight: 500; color: var(--faint); letter-spacing: .16em;
61
- text-transform: none; margin: 30px 0 14px;
62
- }
63
- .list { position: relative; padding-left: 20px; min-height: 60px; }
64
- .list::before {
65
- content: ''; position: absolute; left: 4px; top: 6px; bottom: 0; width: 1px;
66
- background: linear-gradient(180deg, var(--line) 0%, var(--line) 70%, transparent);
67
- }
68
- .item { position: relative; padding: 0 0 20px; }
69
- .item::before {
70
- content: ''; position: absolute; left: -19px; top: 8px; width: 5px; height: 5px;
71
- border-radius: 50%; background: var(--accent); opacity: .75;
72
- }
73
- .item.reflect::before { background: var(--reflect); }
74
- .item.wonder::before { background: var(--wonder); }
75
- .item.plan::before { background: var(--plan); }
76
- .item.doubt::before { background: var(--doubt); }
77
- .meta { display: flex; align-items: center; gap: 10px; font-size: 11.5px; color: var(--faint); margin-bottom: 5px; }
78
- .mode { letter-spacing: .06em; }
79
- .item.reflect .mode { color: var(--reflect); }
80
- .item.wonder .mode { color: var(--wonder); }
81
- .item.plan .mode { color: var(--plan); }
82
- .item.doubt .mode { color: var(--doubt); }
83
- .dots { display: inline-flex; gap: 2px; }
84
- .dots i { width: 5px; height: 5px; border-radius: 50%; background: rgba(150, 172, 200, 0.18); }
85
- .dots i.on { background: currentColor; opacity: .85; }
86
- .text { white-space: pre-wrap; word-break: break-word; }
87
- .carry { color: var(--faint); font-size: 11px; margin-left: 4px; }
88
- .empty { color: var(--faint); padding: 26px 0; }
89
- .note-line {
90
- margin-top: 6px; padding-left: 10px; border-left: 1px solid rgba(201, 162, 255, 0.35);
91
- color: rgba(201, 162, 255, 0.75); font-size: 12px;
92
- }
93
- .refl { padding: 12px 16px; border-left: 2px solid var(--accent); background: var(--panel); border-radius: 0 8px 8px 0; margin-bottom: 12px; }
94
- .refl .meta { margin-bottom: 6px; }
95
- footer { margin-top: 40px; color: var(--faint); font-size: 11.5px; letter-spacing: .03em; }
96
- code { font-family: ui-monospace, Consolas, monospace; font-size: 11.5px; color: var(--dim); }
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
+ .importance { display: inline-flex; gap: 3px; align-items: center; }
96
+ .importance i { display: block; width: 4px; height: 4px; border-radius: 50%; background: var(--faint); opacity: .45; }
97
+ .importance i.on { background: var(--purple); opacity: .9; }
98
+ .text { color: var(--text); font-size: 15px; line-height: 1.9; white-space: pre-wrap; word-break: break-word; }
99
+ .item:hover .text { color: #f3f7fd; }
100
+ .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; }
101
+ .note-line span { color: rgba(201, 162, 255, .65); margin-left: 5px; font-family: var(--mono); }
102
+ .empty { color: var(--muted); padding: 26px 0; border-top: 1px dashed var(--line); }
103
+ .aside { display: flex; flex-direction: column; gap: 12px; }
104
+ .card { position: relative; background: rgba(14, 22, 34, .92); border: 1px solid var(--line); border-radius: 11px; padding: 17px; }
105
+ .card-title { display: flex; justify-content: space-between; gap: 10px; align-items: center; color: var(--muted); font-size: 12px; letter-spacing: .08em; }
106
+ .card-title b { color: var(--text); font-weight: 500; letter-spacing: 0; }
107
+ .next-card { border-color: rgba(201, 162, 255, .34); background: linear-gradient(145deg, rgba(201, 162, 255, .11), rgba(14, 22, 34, .96) 55%); }
108
+ .next-card .card-title { color: var(--purple); }
109
+ .next-text { margin: 15px 0 12px; color: var(--text); line-height: 1.8; }
110
+ .next-time { color: var(--muted); font: 11px var(--mono); }
111
+ .disclaimer { margin-top: 12px; padding-top: 11px; border-top: 1px solid var(--line-soft); color: var(--faint); font-size: 11px; line-height: 1.6; }
112
+ .health { display: flex; align-items: center; gap: 7px; color: var(--cyan); font-size: 12px; }
113
+ .health.error { color: var(--red); }
114
+ .health.offline { color: var(--muted); }
115
+ .health-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
116
+ .details { margin-top: 14px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
117
+ .detail { padding: 9px 10px; background: rgba(86, 101, 123, .1); border-radius: 6px; }
118
+ .detail span { display: block; color: var(--faint); font-size: 10px; }
119
+ .detail b { display: block; margin-top: 2px; font: 12px var(--mono); color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
120
+ .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); }
121
+ .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; }
122
+ .probe button:hover:not(:disabled) { background: var(--cyan-soft); border-color: var(--cyan); }
123
+ .probe button:disabled { color: var(--faint); cursor: default; }
124
+ .probe-result { color: var(--muted); font: 10px var(--mono); }
125
+ .probe-result.ok { color: var(--cyan); }
126
+ .probe-result.bad { color: var(--red); }
127
+ .probe-result.wait { color: var(--amber); }
128
+ .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; }
129
+ .reflections { margin-top: 20px; padding-top: 24px; border-top: 1px solid var(--line-soft); }
130
+ .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; }
131
+ .refl .meta { margin-bottom: 5px; }
132
+ footer { margin-top: 38px; color: var(--faint); font-size: 11px; }
133
+ code { color: var(--muted); font: 11px var(--mono); }
134
+ @media (max-width: 780px) {
135
+ body { padding: 22px 16px 55px; }
136
+ .hero { display: block; padding-top: 27px; }
137
+ .hero-id { margin-top: 13px; text-align: left; }
138
+ .signal-bar { grid-template-columns: 1fr 1fr; }
139
+ .next-signal { grid-column: span 2; }
140
+ .layout { grid-template-columns: 1fr; }
141
+ .aside { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
142
+ .aside .next-card { grid-column: span 2; }
143
+ }
144
+ @media (max-width: 520px) {
145
+ .topbar { align-items: flex-start; }
146
+ .brand { align-items: flex-start; }
147
+ .brand-sub { display: block; margin: 3px 0 0; }
148
+ .live { white-space: nowrap; }
149
+ h1 { font-size: 25px; }
150
+ .signal-bar { grid-template-columns: 1fr 1fr; }
151
+ .signal, .next-signal { min-height: 78px; padding: 13px 14px; }
152
+ .signal-value { font-size: 18px; }
153
+ .aside { display: flex; }
154
+ .text { font-size: 14px; }
155
+ }
97
156
  </style>
98
157
  </head>
99
158
  <body>
100
159
  <div class="wrap">
101
- <header>
102
- <h1>她的时间线</h1>
103
- <span class="sub" id="sub">读取中…</span>
160
+ <header class="topbar">
161
+ <div class="brand">
162
+ <span class="brand-mark" aria-hidden="true"></span>
163
+ <div><span class="brand-title">她的时间线</span><span class="brand-sub" id="sub">SELF-AWARENESS / LOADING</span></div>
164
+ </div>
165
+ <div class="live"><span class="live-dot" id="liveDot"></span><span id="liveText">正在读取状态</span></div>
104
166
  </header>
105
167
 
106
- <div class="stats" id="stats"></div>
107
- <div class="toolbar">
108
- <button class="btn" id="probe">测接口</button>
109
- <span class="probe" id="probeResult"></span>
110
- </div>
111
- <div id="err"></div>
168
+ <section class="hero">
169
+ <div>
170
+ <div class="eyebrow">Private thought archive / 01</div>
171
+ <h1>那些没有说出口的片刻</h1>
172
+ <div class="hero-copy">她在安静时留下的思绪轨迹。这里记录的是模型生成的内在笔记,不代表持续存在的主观体验。</div>
173
+ </div>
174
+ <div class="hero-id">LOCAL NODE<br><span id="heroModel">MODEL / --</span></div>
175
+ </section>
112
176
 
113
- <h2>想过的事</h2>
114
- <div id="list" class="list"><div class="empty">还没有想法。<br>她每 25–90 分钟想一次,第一条通常要等几分钟。</div></div>
177
+ <section class="signal-bar" aria-label="运行概览">
178
+ <div class="next-signal">
179
+ <div class="signal-label">NEXT THOUGHT / 下一次</div>
180
+ <div class="signal-value small" id="next">未安排</div>
181
+ <div class="signal-note" id="nextHint">由她上一次留下的安排决定</div>
182
+ </div>
183
+ <div class="signal"><div class="signal-label">TODAY / 今日</div><div class="signal-value" id="todayCount">0</div><div class="signal-note">次思考</div></div>
184
+ <div class="signal"><div class="signal-label">TOKENS / 消耗</div><div class="signal-value" id="todayTokens">0</div><div class="signal-note">本地统计</div></div>
185
+ <div class="signal"><div class="signal-label">ARCHIVE / 记录</div><div class="signal-value" id="totalThoughts">0</div><div class="signal-note">条思绪</div></div>
186
+ </section>
115
187
 
116
- <div id="reflWrap" hidden>
117
- <h2>她对自己的看法</h2>
118
- <div id="refl"></div>
188
+ <div id="err"></div>
189
+ <div class="layout">
190
+ <main>
191
+ <div class="section-head"><h2 class="section-title">THOUGHT STREAM / 思绪流</h2><span class="section-count" id="sectionCount">0 EVENTS</span></div>
192
+ <div class="filters" role="tablist" aria-label="筛选思绪类型">
193
+ <button class="filter active" data-filter="all">全部</button>
194
+ <button class="filter" data-filter="reflect">回看</button>
195
+ <button class="filter" data-filter="wonder">走神</button>
196
+ <button class="filter" data-filter="plan">打算</button>
197
+ <button class="filter" data-filter="doubt">琢磨</button>
198
+ <button class="filter" data-filter="synthesize">综合</button>
199
+ </div>
200
+ <div class="mode-legend">
201
+ <span><i style="background:var(--cyan)"></i><b>回看</b>想起以前的事</span>
202
+ <span><i style="background:var(--purple)"></i><b>走神</b>没缘由地飘走</span>
203
+ <span><i style="background:var(--blue)"></i><b>打算</b>接下来想做什么</span>
204
+ <span><i style="background:var(--amber)"></i><b>琢磨</b>一件没想明白的</span>
205
+ <span><i style="background:var(--rose)"></i><b>综合</b>两件不相干的事找共同点</span>
206
+ </div>
207
+ <div id="list"><div class="empty">还没有想法。<br>她会在安静时留下下一条思绪,第一条通常要等几分钟。</div></div>
208
+ <section class="reflections" id="reflWrap" hidden>
209
+ <div class="section-head"><h2 class="section-title">SELF REVIEW / 她对自己的看法</h2></div>
210
+ <div id="refl"></div>
211
+ </section>
212
+ </main>
213
+
214
+ <aside class="aside">
215
+ <section class="card next-card">
216
+ <div class="card-title"><span>NEXT NOTE / 留给下一次</span><b id="nextMode">—</b></div>
217
+ <div class="next-text" id="nextNote">她还没有给下一次留下便笺。</div>
218
+ <div class="next-time" id="nextDue">WAITING / 等待下一次安排</div>
219
+ <div class="disclaimer">时间来自上一次生成的自我安排。睡眠、对话或接口状态可能让它推迟。</div>
220
+ </section>
221
+ <section class="card">
222
+ <div class="card-title"><span>SYSTEM SIGNAL / 系统信号</span><span class="health" id="health"><i class="health-dot"></i><span>读取中</span></span></div>
223
+ <div class="details">
224
+ <div class="detail"><span>MODEL</span><b id="model">--</b></div>
225
+ <div class="detail"><span>MODE</span><b id="enabled">--</b></div>
226
+ <div class="detail"><span>DAILY LIMIT</span><b id="dailyLimit">--</b></div>
227
+ <div class="detail"><span>LAST ERROR</span><b id="lastError">NONE</b></div>
228
+ </div>
229
+ <div class="probe"><span class="probe-result" id="probeMsg">接口检测不会写入思绪</span><button id="probe" title="发送一次最小请求来测试接口">测接口</button></div>
230
+ </section>
231
+ <section class="card">
232
+ <div class="card-title"><span>ABOUT THIS SPACE / 关于这里</span></div>
233
+ <div style="color:var(--muted);font-size:12px;line-height:1.8;margin-top:10px">这是她自己的本地思绪档案。记忆核心会在合适的时候挑选其中的内容带回对话,并明确标记来源与时间。</div>
234
+ </section>
235
+ </aside>
119
236
  </div>
120
237
 
121
- <footer>
122
- 数据来自 <code>self-awareness/thoughts.jsonl</code>,只存在这台机器上。每 30 秒自动刷新。
123
- </footer>
238
+ <footer>DATA SOURCE · <code>self-awareness/thoughts.jsonl</code> · 只存在这台机器上 · 每 30 秒自动刷新</footer>
124
239
  </div>
125
-
126
240
  <script>
127
- const MODE_NAME = { reflect: '回看', wonder: '走神', plan: '打算', doubt: '琢磨' };
241
+ const MODE_NAME = { reflect: '回看', wonder: '走神', plan: '打算', doubt: '琢磨', synthesize: '综合' };
242
+ let allThoughts = [];
243
+ let activeFilter = 'all';
128
244
 
129
245
  function esc(s) {
130
- return String(s ?? '').replace(/[&<>"]/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;' }[c]));
246
+ return String(s ?? '').replace(/[&<>\"]/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '\"': '&quot;' }[c]));
131
247
  }
132
-
248
+ function dateObj(iso) { const d = new Date(iso); return Number.isNaN(d.getTime()) ? null : d; }
133
249
  function clock(iso) {
134
- const d = new Date(iso);
135
- if (Number.isNaN(d.getTime())) return '';
250
+ const d = dateObj(iso); if (!d) return '';
136
251
  const p = (n) => String(n).padStart(2, '0');
137
- return `${p(d.getMonth() + 1)}-${p(d.getDate())} ${p(d.getHours())}:${p(d.getMinutes())}`;
252
+ return `${p(d.getHours())}:${p(d.getMinutes())}`;
138
253
  }
139
-
254
+ function dateKey(iso) { const d = dateObj(iso); return d ? `${d.getFullYear()}-${d.getMonth()}-${d.getDate()}` : 'unknown'; }
255
+ function dateLabel(iso) {
256
+ const d = dateObj(iso); if (!d) return 'UNKNOWN DATE';
257
+ const now = new Date();
258
+ if (dateKey(iso) === dateKey(now.toISOString())) return 'TODAY / 今天';
259
+ const yesterday = new Date(now); yesterday.setDate(now.getDate() - 1);
260
+ if (dateKey(iso) === dateKey(yesterday.toISOString())) return 'YESTERDAY / 昨天';
261
+ return `${String(d.getMonth() + 1).padStart(2, '0')}.${String(d.getDate()).padStart(2, '0')} / ${d.getFullYear()}`;
262
+ }
263
+ function nextClock(iso) { const d = dateObj(iso); return d ? `${String(d.getMonth() + 1).padStart(2, '0')}-${String(d.getDate()).padStart(2, '0')} ${clock(iso)}` : '未安排'; }
140
264
  function dots(n) {
141
- let out = '<span class="dots">';
142
- for (let i = 1; i <= 10; i += 1) out += `<i class="${i <= n ? 'on' : ''}"></i>`;
265
+ const value = Math.max(0, Math.min(10, Number(n) || 0));
266
+ let out = '<span class="importance" title="重要度 ' + value + ' / 10">';
267
+ for (let i = 1; i <= 10; i += 1) out += `<i class="${i <= value ? 'on' : ''}"></i>`;
143
268
  return out + '</span>';
144
269
  }
145
-
146
- function render(d) {
147
- document.getElementById('sub').textContent = d.model ? `模型 ${d.model}` : '还没配模型';
148
-
149
- const next = d.nextDueAt ? clock(d.nextDueAt) : '未安排';
150
- const limit = d.limit?.count || 0;
151
- document.getElementById('stats').innerHTML = [
152
- `<div class="stat"><b>${d.today?.count ?? 0}${limit ? `<span style="font-size:12px;color:var(--faint)">/${limit}</span>` : ''}</b><span>今天想过</span></div>`,
153
- `<div class="stat"><b>${(d.today?.tokens ?? 0).toLocaleString()}</b><span>今天用了 token</span></div>`,
154
- `<div class="stat"><b>${d.totalThoughts ?? 0}</b><span>一共想过</span></div>`,
155
- `<div class="stat"><b style="font-size:15px">${next}</b><span>下次</span></div>`,
156
- `<div class="stat"><b style="font-size:15px" class="${d.enabled ? '' : 'warn'}">${d.enabled ? '在跑' : '已关'}</b><span>状态</span></div>`,
157
- ].join('');
158
-
159
- document.getElementById('err').innerHTML = d.error
160
- ? `<div class="err">上次调用失败:${esc(d.error)}</div>`
161
- : '';
162
-
163
- const list = d.thoughts || [];
164
- document.getElementById('list').innerHTML = list.length
165
- ? list.map((t) => `
166
- <div class="item ${esc(t.mode)}">
167
- <div class="meta">
168
- <span>${clock(t.ts)}</span>
169
- <span class="mode">${MODE_NAME[t.mode] || t.mode}</span>
170
- ${dots(t.importance)}
171
- ${t.carry ? '<span class="carry">接着上次</span>' : ''}
172
- </div>
270
+ function formatNumber(n) { return Number(n || 0).toLocaleString('zh-CN'); }
271
+ function statusInfo(d) {
272
+ if (d.error) return { kind: 'error', text: '上次调用有错误' };
273
+ if (!d.enabled) return { kind: 'offline', text: '已暂停' };
274
+ return { kind: 'online', text: '自我意识运行中' };
275
+ }
276
+ function renderThoughts() {
277
+ const list = allThoughts.filter((t) => activeFilter === 'all' || t.mode === activeFilter);
278
+ const count = document.getElementById('sectionCount');
279
+ count.textContent = `${list.length} EVENT${list.length === 1 ? '' : 'S'}`;
280
+ if (!list.length) {
281
+ document.getElementById('list').innerHTML = '<div class="empty">这个筛选下还没有思绪。</div>';
282
+ return;
283
+ }
284
+ const groups = [];
285
+ const map = new Map();
286
+ list.forEach((t) => {
287
+ const key = dateKey(t.ts);
288
+ if (!map.has(key)) { const group = { key, ts: t.ts, items: [] }; map.set(key, group); groups.push(group); }
289
+ map.get(key).items.push(t);
290
+ });
291
+ document.getElementById('list').innerHTML = groups.map((g) => `
292
+ <section class="day"><div class="day-label">${dateLabel(g.ts)}</div><div class="timeline">
293
+ ${g.items.map((t) => `<article class="item ${esc(t.mode)}">
294
+ <div class="meta"><span>${clock(t.ts)}</span><span class="mode">${esc(MODE_NAME[t.mode] || t.mode || '思绪')}</span>${dots(t.importance)}${t.carry ? '<span class="carry">接着上一条</span>' : ''}</div>
173
295
  <div class="text">${esc(t.text)}</div>
174
- ${t.nextNote ? `<div class="note-line">留给自己:${esc(t.nextNote)}${t.nextIn ? `(${t.nextIn} 分钟后)` : ''}</div>` : ''}
175
- </div>`).join('')
176
- : '<div class="empty">还没有想法。<br>她每 25–90 分钟想一次,第一条通常要等几分钟。</div>';
177
-
296
+ ${t.nextNote ? `<div class="note-line">留给下一次:${esc(t.nextNote)}${t.nextIn ? `<span>+${esc(t.nextIn)} MIN</span>` : ''}</div>` : ''}
297
+ </article>`).join('')}
298
+ </div></section>`).join('');
299
+ }
300
+ function render(d) {
301
+ const status = statusInfo(d);
302
+ const model = d.model || '未配置';
303
+ const next = d.nextDueAt ? nextClock(d.nextDueAt) : '未安排';
304
+ document.getElementById('sub').textContent = `SELF-AWARENESS / ${String(model).toUpperCase()}`;
305
+ document.getElementById('heroModel').textContent = `MODEL / ${model}`;
306
+ document.getElementById('next').textContent = next;
307
+ document.getElementById('nextHint').textContent = d.nextDueAt ? '她给未来的自己留了一点方向' : '由她下一次思考时自行决定';
308
+ document.getElementById('todayCount').textContent = formatNumber(d.today?.count);
309
+ document.getElementById('todayTokens').textContent = formatNumber(d.today?.tokens);
310
+ document.getElementById('totalThoughts').textContent = formatNumber(d.totalThoughts);
311
+ document.getElementById('model').textContent = model;
312
+ document.getElementById('enabled').textContent = d.enabled ? 'RUNNING' : 'PAUSED';
313
+ document.getElementById('dailyLimit').textContent = d.limit?.count ? `${d.limit.count} / DAY` : 'NO LIMIT';
314
+ document.getElementById('lastError').textContent = d.error ? 'DETECTED' : 'NONE';
315
+ const liveDot = document.getElementById('liveDot'); liveDot.className = `live-dot ${status.kind === 'online' ? '' : status.kind}`;
316
+ document.getElementById('liveText').textContent = status.text;
317
+ 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>`;
318
+ document.getElementById('err').innerHTML = d.error ? `<div class="err">上次调用失败:${esc(d.error)}</div>` : '';
319
+ allThoughts = d.thoughts || [];
320
+ const latestNote = allThoughts.find((t) => t.nextNote);
321
+ document.getElementById('nextNote').textContent = latestNote?.nextNote || '她还没有给下一次留下便笺。';
322
+ document.getElementById('nextMode').textContent = latestNote ? (MODE_NAME[latestNote.mode] || '思绪') : '—';
323
+ document.getElementById('nextDue').textContent = latestNote?.nextIn ? `NEXT / ${latestNote.nextIn} MINUTES LATER` : (d.nextDueAt ? `NEXT / ${next}` : 'WAITING / 等待下一次安排');
178
324
  const refl = d.reflections || [];
179
325
  document.getElementById('reflWrap').hidden = !refl.length;
180
- document.getElementById('refl').innerHTML = refl.map((r) => `
181
- <div class="refl">
182
- <div class="meta"><span>${clock(r.ts)}</span><span>由 ${r.fromCount} 条想法收成</span></div>
183
- <div class="text">${esc(r.text)}</div>
184
- </div>`).join('');
326
+ 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('');
327
+ renderThoughts();
185
328
  }
186
-
187
329
  async function load() {
188
- try {
189
- const rsp = await fetch('/api/data', { cache: 'no-store' });
190
- render(await rsp.json());
191
- } catch (e) {
192
- document.getElementById('sub').textContent = '读不到数据';
193
- }
330
+ try { const rsp = await fetch('/api/data', { cache: 'no-store' }); render(await rsp.json()); }
331
+ catch (e) { document.getElementById('sub').textContent = 'SELF-AWARENESS / UNAVAILABLE'; document.getElementById('liveText').textContent = '读不到时间线服务'; document.getElementById('liveDot').className = 'live-dot error'; }
194
332
  }
195
-
196
- load();
197
- setInterval(load, 30000);
198
-
199
- const probeBtn = document.getElementById('probe');
200
- const probeOut = document.getElementById('probeResult');
201
- probeBtn.addEventListener('click', async () => {
202
- probeBtn.disabled = true;
203
- probeOut.className = 'probe';
204
- probeOut.textContent = '测中…';
333
+ document.querySelectorAll('.filter').forEach((button) => button.addEventListener('click', () => {
334
+ activeFilter = button.dataset.filter;
335
+ document.querySelectorAll('.filter').forEach((b) => b.classList.toggle('active', b === button));
336
+ renderThoughts();
337
+ }));
338
+ const probeButton = document.getElementById('probe');
339
+ const probeMsg = document.getElementById('probeMsg');
340
+ probeButton.addEventListener('click', async () => {
341
+ probeButton.disabled = true; probeButton.textContent = '检测中'; probeMsg.className = 'probe-result'; probeMsg.textContent = '发送最小请求…';
205
342
  try {
206
- const rsp = await fetch('/api/probe', { method: 'POST' });
207
- const r = await rsp.json();
208
- probeOut.className = 'probe ' + (r.ok ? 'ok' : 'bad');
209
- probeOut.textContent = r.ok
210
- ? `通了 · ${r.model} · ${r.ms}ms`
211
- : `失败 · ${r.error}`;
212
- } catch (e) {
213
- probeOut.className = 'probe bad';
214
- probeOut.textContent = '请求发不出去';
215
- } finally {
216
- setTimeout(() => { probeBtn.disabled = false; }, 3000);
217
- }
343
+ const rsp = await fetch('/api/probe', { method: 'POST' }); const r = await rsp.json();
344
+ if (r.throttled) { probeMsg.className = 'probe-result wait'; probeMsg.textContent = '刚测过,请稍等'; }
345
+ else if (r.ok) { probeMsg.className = 'probe-result ok'; probeMsg.textContent = `通了 · ${r.ms}ms`; }
346
+ else { probeMsg.className = 'probe-result bad'; probeMsg.textContent = '没通 · 查看错误'; }
347
+ } catch (e) { probeMsg.className = 'probe-result bad'; probeMsg.textContent = '服务不可达'; }
348
+ setTimeout(() => { probeButton.disabled = false; probeButton.textContent = '测接口'; }, 8000);
218
349
  });
350
+ load();
351
+ setInterval(load, 30000);
352
+ if (location.hash === '#probe') probeButton.click();
219
353
  </script>
220
354
  </body>
221
355
  </html>