luckytri 1.0.6 → 1.0.7
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/LICENSE +21 -21
- package/docs/en/CHANGELOG.md +25 -16
- package/docs/en/chat-style.md +28 -9
- package/docs/en/guide.md +5 -5
- package/docs/en/her-life.md +2 -2
- package/docs/en/webui.md +1 -1
- package/docs/zh/CHANGELOG.md +25 -16
- package/docs/zh/chat-style.md +30 -9
- package/docs/zh/guide.md +5 -5
- package/docs/zh/her-life.md +2 -2
- package/docs/zh/webui.md +1 -1
- package/package.json +1 -1
- package/public/app/assets/{ChatsPage-DCYMkJ91.js → ChatsPage-CshdtTzV.js} +2 -2
- package/public/app/assets/ChatsPage-DfyPCS9N.css +1 -0
- package/public/app/assets/{Empty-CLyZkxR5.js → Empty-C7yzOBzy.js} +1 -1
- package/public/app/assets/{Empty-DIobYG3x.css → Empty-DmUB2-Bk.css} +1 -1
- package/public/app/assets/{Field-BpaRwLI_.js → Field-BjFv4Rfn.js} +1 -1
- package/public/app/assets/HeartPage-Bft9wZp5.css +1 -0
- package/public/app/assets/{HeartPage-BIOMTiwr.js → HeartPage-eqo6ru16.js} +1 -1
- package/public/app/assets/LifePage-BUi5euBF.css +1 -0
- package/public/app/assets/{LifePage-BCgM4JkR.js → LifePage-CN8GE5NK.js} +1 -1
- package/public/app/assets/{MemoryPage-vShvRqMt.js → MemoryPage-CCpMN4Wg.js} +1 -1
- package/public/app/assets/MemoryPage-cZvXfkXb.css +1 -0
- package/public/app/assets/{NaturePage-Cy9ptr4G.js → NaturePage-C0JqdBTR.js} +2 -2
- package/public/app/assets/NaturePage-CHkpb5NK.css +1 -0
- package/public/app/assets/PeoplePage-BTU0H1pM.css +1 -0
- package/public/app/assets/{PeoplePage-CUZekB2E.js → PeoplePage-BXGBbO4u.js} +1 -1
- package/public/app/assets/{PluginsPage-1RM4rmJP.js → PluginsPage-Dksp5AV5.js} +1 -1
- package/public/app/assets/{SystemPage-BI2CB5Ig.css → SystemPage-BenIyTvk.css} +1 -1
- package/public/app/assets/{SystemPage-BeT5TmIV.js → SystemPage-Cd7aa8eE.js} +1 -1
- package/public/app/assets/TimePage-BOms_n4I.css +1 -0
- package/public/app/assets/{TimePage-taTmPMM8.js → TimePage-Bs_zImb4.js} +2 -2
- package/public/app/assets/{index-DY5AM0Hz.css → index-BHZcHUMh.css} +1 -1
- package/public/app/assets/{index-DdYwC5ZU.js → index-CyRtYxP3.js} +3 -3
- package/public/app/assets/{knowledge-DJmfu2KN.js → knowledge-BJOIyuJo.js} +1 -1
- package/public/app/assets/{media-BEtnE0Gv.js → media-Bwtx8blz.js} +1 -1
- package/public/app/assets/{mind-Dtiw0-QK.js → mind-DtTVrW6Z.js} +1 -1
- package/public/app/index.html +5 -6
- package/public/guide.en.html +3 -3
- package/public/guide.html +3 -3
- package/scripts/import-data.js +128 -128
- package/scripts/proxy-config.js +167 -167
- package/scripts/update-instance.js +201 -201
- package/server/channels/adapters.js +27 -27
- package/server/channels/onebot/adapter.js +288 -288
- package/server/channels/qqbot/adapter.js +253 -253
- package/server/channels/qqbot/api.js +199 -199
- package/server/channels/qqbot/credentials.js +11 -11
- package/server/channels/qqbot/gateway.js +274 -274
- package/server/channels/qqbot/index.js +389 -389
- package/server/channels/segments.js +40 -40
- package/server/channels/session-key.js +153 -153
- package/server/channels/state.js +42 -42
- package/server/core/api.js +564 -564
- package/server/core/context-builder.js +288 -288
- package/server/core/context-compactor.js +454 -454
- package/server/core/conversation-cues.js +365 -325
- package/server/core/conversation-grounding.js +178 -0
- package/server/core/conversation-manager.js +87 -87
- package/server/core/dialogue-context.js +52 -0
- package/server/core/feedback.js +8 -8
- package/server/core/group-style.js +72 -72
- package/server/core/initiative-context.js +66 -66
- package/server/core/input-budget.js +32 -32
- package/server/core/local-demo.js +98 -98
- package/server/core/message-manager.js +118 -118
- package/server/core/message-scheduler.js +78 -78
- package/server/core/model-json.js +190 -190
- package/server/core/model-presets.js +900 -900
- package/server/core/name-call.js +29 -29
- package/server/core/network.js +157 -157
- package/server/core/person-name.js +22 -22
- package/server/core/persona-manager.js +324 -269
- package/server/core/reply-delivery.js +472 -404
- package/server/core/reply-target-resolver.js +50 -50
- package/server/core/response-generator.js +58 -50
- package/server/core/response-validator.js +30 -27
- package/server/core/retired-prompts.js +51 -51
- package/server/core/sessions.js +109 -109
- package/server/core/speaker-names.js +92 -92
- package/server/core/topic-tracker.js +65 -65
- package/server/core/turn.js +42 -8
- package/server/http.js +18 -18
- package/server/i18n/decisions.js +209 -209
- package/server/i18n/index.js +144 -144
- package/server/i18n/labels.js +0 -5
- package/server/i18n/models.js +111 -111
- package/server/knowledge/api.js +342 -342
- package/server/knowledge/embedding-profile.js +114 -114
- package/server/knowledge/index.js +13 -13
- package/server/knowledge/retrieval.js +93 -93
- package/server/knowledge/schema.js +158 -158
- package/server/knowledge/vector-index.js +90 -90
- package/server/mind/affect.js +265 -265
- package/server/mind/attention.js +200 -200
- package/server/mind/bonds.js +565 -565
- package/server/mind/clock.js +83 -83
- package/server/mind/context-selection.js +16 -4
- package/server/mind/continuity.js +562 -562
- package/server/mind/conversation-origin.js +175 -175
- package/server/mind/days.js +210 -210
- package/server/mind/evidence-read.js +45 -45
- package/server/mind/faces.js +373 -373
- package/server/mind/guard.js +68 -60
- package/server/mind/initiative.js +338 -338
- package/server/mind/life/activities.js +21 -21
- package/server/mind/life/context.js +330 -330
- package/server/mind/life/growth.js +261 -261
- package/server/mind/life/presence.js +305 -305
- package/server/mind/meetings.js +1069 -1069
- package/server/mind/memory-policy.js +48 -48
- package/server/mind/memory.js +888 -888
- package/server/mind/nature.js +358 -358
- package/server/mind/novelty.js +19 -19
- package/server/mind/periods.js +118 -118
- package/server/mind/reading.js +120 -120
- package/server/mind/relationship-context.js +71 -71
- package/server/mind/relationships.js +390 -390
- package/server/mind/salience.js +201 -201
- package/server/mind/schema.js +567 -567
- package/server/mind/self.js +496 -484
- package/server/mind/thoughts.js +274 -274
- package/server/mind/time/agenda.js +242 -242
- package/server/mind/time/api.js +200 -200
- package/server/mind/time/attention.js +34 -34
- package/server/mind/time/delivery-links.js +130 -130
- package/server/mind/time/games.js +7 -3
- package/server/mind/time/index.js +3 -0
- package/server/mind/time/model-material.js +77 -77
- package/server/mind/time/presentation.js +35 -51
- package/server/mind/time/schedule.js +83 -83
- package/server/mind/time/schema.js +84 -84
- package/server/mind/time/search.js +383 -383
- package/server/mind/time/sharing.js +472 -472
- package/server/mind/time/task-links.js +311 -311
- package/server/mind/time/works.js +438 -432
- package/server/mind/traits.js +191 -191
- package/server/mind/view.js +43 -6
- package/server/runtime/installation.js +116 -116
- package/server/runtime/update-manager.js +140 -140
- package/server/storage/data-package.js +298 -298
- package/server/storage/data-transfer-api.js +50 -50
- package/server/storage/data-transfer-worker.js +18 -18
- package/server/storage/data-transfer.js +416 -416
- package/server/studio/display-names.js +139 -139
- package/server/studio/management.js +102 -102
- package/server/studio/updates.js +144 -144
- package/server/version.js +10 -10
- package/public/app/assets/ChatsPage-CFMVozoG.css +0 -1
- package/public/app/assets/HeartPage-C-2jvgzF.css +0 -1
- package/public/app/assets/LifePage-CG1OHbRK.css +0 -1
- package/public/app/assets/MemoryPage-C_Bu4rfb.css +0 -1
- package/public/app/assets/NaturePage-CPZlImT0.css +0 -1
- package/public/app/assets/PeoplePage-3RRUITDz.css +0 -1
- package/public/app/assets/TimePage-C-guwPk2.css +0 -1
|
@@ -1,242 +1,242 @@
|
|
|
1
|
-
import { dayKey, zonedTime, parse } from "../util.js";
|
|
2
|
-
import { activityPresentation } from "./presentation.js";
|
|
3
|
-
import { executionBlock } from "./availability.js";
|
|
4
|
-
|
|
5
|
-
// A view of saved choices and actual spans. Reading it never makes a plan.
|
|
6
|
-
export class Agenda {
|
|
7
|
-
constructor(time) {
|
|
8
|
-
this.time = time;
|
|
9
|
-
this.db = time.db;
|
|
10
|
-
}
|
|
11
|
-
blocked(task, now) {
|
|
12
|
-
if (task.state === "paused" && task.next_step >= Number.MAX_SAFE_INTEGER)
|
|
13
|
-
return task.wait_reason || "自己选择暂停,等待重新安排";
|
|
14
|
-
return executionBlock(this.time, task, now);
|
|
15
|
-
}
|
|
16
|
-
view(now = this.time.now()) {
|
|
17
|
-
const time = this.time,
|
|
18
|
-
zone = time.mind.timeZone(),
|
|
19
|
-
date = dayKey(now, zone);
|
|
20
|
-
const nextDate = new Date(Date.parse(date + "T12:00:00Z") + 86400000)
|
|
21
|
-
.toISOString()
|
|
22
|
-
.slice(0, 10);
|
|
23
|
-
const start = zonedTime(date, zone),
|
|
24
|
-
end = zonedTime(nextDate, zone),
|
|
25
|
-
today = time.today(now),
|
|
26
|
-
primary = time.primary();
|
|
27
|
-
const actual = today.spans
|
|
28
|
-
.map((s) => {
|
|
29
|
-
const rename = this.db
|
|
30
|
-
.prepare(
|
|
31
|
-
"SELECT data FROM mind_time_events WHERE task_id=? AND kind='self-scheduled' AND created>=? ORDER BY created,id LIMIT 1",
|
|
32
|
-
)
|
|
33
|
-
.get(s.task_id, s.started);
|
|
34
|
-
const title = parse(rename?.data, {}).previousTitle || s.title;
|
|
35
|
-
return {
|
|
36
|
-
id: s.id,
|
|
37
|
-
taskId: s.task_id,
|
|
38
|
-
title,
|
|
39
|
-
activity: s.activity,
|
|
40
|
-
start: Math.max(start, s.started),
|
|
41
|
-
end: Math.min(now, s.ended ?? s.updated),
|
|
42
|
-
engagedMs: s.clocked || time.fixtureImmediate ? s.todayMs : null,
|
|
43
|
-
ongoing: !s.ended && primary?.id === s.task_id,
|
|
44
|
-
kind: "actual",
|
|
45
|
-
label:
|
|
46
|
-
!s.ended && primary?.id === s.task_id
|
|
47
|
-
? primary.checkpoint.activityClock?.phase === "preparing"
|
|
48
|
-
? "准备中"
|
|
49
|
-
: "正在做"
|
|
50
|
-
: s.clocked && !s.todayMs
|
|
51
|
-
? "准备时段"
|
|
52
|
-
: "已发生",
|
|
53
|
-
};
|
|
54
|
-
})
|
|
55
|
-
.filter((s) => s.end > s.start);
|
|
56
|
-
const planned = [],
|
|
57
|
-
waiting = [],
|
|
58
|
-
unarranged = [],
|
|
59
|
-
paused = [];
|
|
60
|
-
const rows = this.db
|
|
61
|
-
.prepare(
|
|
62
|
-
"SELECT id FROM mind_time_tasks WHERE created<=? AND state IN ('todo','scheduled','doing','paused','waiting') AND json_extract(checkpoint,'$.mergedInto') IS NULL ORDER BY priority DESC,created LIMIT 100",
|
|
63
|
-
)
|
|
64
|
-
.all(now);
|
|
65
|
-
for (const row of rows) {
|
|
66
|
-
const task = time.tasks.get(row.id),
|
|
67
|
-
view = activityPresentation(task),
|
|
68
|
-
slot = task.checkpoint.schedule;
|
|
69
|
-
const why = this.blocked(task, now);
|
|
70
|
-
if (task.state === "paused") {
|
|
71
|
-
if (paused.length < 12)
|
|
72
|
-
paused.push({
|
|
73
|
-
id: task.id,
|
|
74
|
-
title: view.title,
|
|
75
|
-
reason: task.wait_reason || "暂时停下来,进度已保存",
|
|
76
|
-
});
|
|
77
|
-
continue;
|
|
78
|
-
}
|
|
79
|
-
if (why || task.state === "waiting") {
|
|
80
|
-
if (waiting.length < 12)
|
|
81
|
-
waiting.push({
|
|
82
|
-
id: task.id,
|
|
83
|
-
title: view.title,
|
|
84
|
-
reason: why || task.wait_reason,
|
|
85
|
-
retryAt:
|
|
86
|
-
task.next_step < Number.MAX_SAFE_INTEGER ? task.next_step : null,
|
|
87
|
-
});
|
|
88
|
-
continue;
|
|
89
|
-
}
|
|
90
|
-
if (
|
|
91
|
-
!slot?.chosenAt ||
|
|
92
|
-
task.checkpoint.reschedule ||
|
|
93
|
-
(slot.endedAt <= now && task.state !== "doing")
|
|
94
|
-
) {
|
|
95
|
-
if (unarranged.length < 12)
|
|
96
|
-
unarranged.push({
|
|
97
|
-
id: task.id,
|
|
98
|
-
title: view.title,
|
|
99
|
-
reason: slot?.chosenAt
|
|
100
|
-
? "原安排已过去,等她重新选时间"
|
|
101
|
-
: "事情已经记下,等她选择几点做、做多久",
|
|
102
|
-
});
|
|
103
|
-
continue;
|
|
104
|
-
}
|
|
105
|
-
if (slot.proposedAt >= end || slot.endedAt <= start) {
|
|
106
|
-
if (unarranged.length < 12)
|
|
107
|
-
unarranged.push({
|
|
108
|
-
id: task.id,
|
|
109
|
-
title: view.title,
|
|
110
|
-
reason: "安排在今天之外",
|
|
111
|
-
startAt: slot.proposedAt,
|
|
112
|
-
});
|
|
113
|
-
continue;
|
|
114
|
-
}
|
|
115
|
-
planned.push({
|
|
116
|
-
id: "slot:" + task.id,
|
|
117
|
-
kind: "activity",
|
|
118
|
-
taskId: task.id,
|
|
119
|
-
title: view.title,
|
|
120
|
-
activity: task.activity,
|
|
121
|
-
kindOfTask: task.kind,
|
|
122
|
-
priority: task.priority,
|
|
123
|
-
start: Math.max(start, slot.proposedAt),
|
|
124
|
-
end: Math.min(end, slot.endedAt),
|
|
125
|
-
chosenStart: slot.proposedAt,
|
|
126
|
-
chosenEnd: slot.endedAt,
|
|
127
|
-
durationMinutes: slot.durationMinutes,
|
|
128
|
-
why: slot.reason || view.why,
|
|
129
|
-
label:
|
|
130
|
-
task.state === "doing"
|
|
131
|
-
? "正在执行这份安排"
|
|
132
|
-
: slot.chosenBy === "admin"
|
|
133
|
-
? "管理台安排"
|
|
134
|
-
: "她选定的安排",
|
|
135
|
-
estimated: false,
|
|
136
|
-
scope: "这次投入",
|
|
137
|
-
state: task.state,
|
|
138
|
-
});
|
|
139
|
-
}
|
|
140
|
-
const rhythm = time.mind.nature.current(now).rhythm;
|
|
141
|
-
if (rhythm?.enabled) {
|
|
142
|
-
const bed = zonedTime(date + " " + rhythm.sleep, zone),
|
|
143
|
-
wake = zonedTime(date + " " + rhythm.wake, zone);
|
|
144
|
-
for (const [a, b] of bed < wake
|
|
145
|
-
? [[bed, wake]]
|
|
146
|
-
: [
|
|
147
|
-
[start, wake],
|
|
148
|
-
[bed, end],
|
|
149
|
-
])
|
|
150
|
-
if (b > now)
|
|
151
|
-
planned.push({
|
|
152
|
-
id: "sleep:" + a,
|
|
153
|
-
kind: "sleep",
|
|
154
|
-
title: "作息中的睡眠时间",
|
|
155
|
-
start: Math.max(now, a),
|
|
156
|
-
end: b,
|
|
157
|
-
});
|
|
158
|
-
}
|
|
159
|
-
for (const block of planned.filter((b) => b.taskId)) {
|
|
160
|
-
const urgent = planned
|
|
161
|
-
.filter(
|
|
162
|
-
(b) =>
|
|
163
|
-
b.taskId &&
|
|
164
|
-
b.taskId !== block.taskId &&
|
|
165
|
-
b.priority > block.priority &&
|
|
166
|
-
b.start < block.end &&
|
|
167
|
-
b.end > block.start,
|
|
168
|
-
)
|
|
169
|
-
.sort((a, b) => a.start - b.start)[0];
|
|
170
|
-
const bedtime = planned
|
|
171
|
-
.filter(
|
|
172
|
-
(b) =>
|
|
173
|
-
b.kind === "sleep" && b.start < block.end && b.end > block.start,
|
|
174
|
-
)
|
|
175
|
-
.sort((a, b) => a.start - b.start)[0];
|
|
176
|
-
const stop = Math.min(
|
|
177
|
-
urgent ? Math.max(block.start, urgent.start) : block.end,
|
|
178
|
-
bedtime ? Math.max(block.start, bedtime.start) : block.end,
|
|
179
|
-
);
|
|
180
|
-
block.chartEnd = stop;
|
|
181
|
-
if (stop < block.end) {
|
|
182
|
-
block.interruptedAt = stop;
|
|
183
|
-
block.interruption =
|
|
184
|
-
bedtime && stop === bedtime.start ? "sleep" : "priority";
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
planned.sort(
|
|
188
|
-
(a, b) => a.start - b.start || (b.priority || 0) - (a.priority || 0),
|
|
189
|
-
);
|
|
190
|
-
const next =
|
|
191
|
-
planned
|
|
192
|
-
.filter((b) => b.taskId && b.state !== "doing" && b.chosenStart > now)
|
|
193
|
-
.sort((a, b) => a.chosenStart - b.chosenStart)[0] || null;
|
|
194
|
-
const life = time.search.life,
|
|
195
|
-
planning = life?.planner?.working || life?.ownDay?.working,
|
|
196
|
-
phase = life?.phase(now);
|
|
197
|
-
const idle = {
|
|
198
|
-
title: primary
|
|
199
|
-
? "有主活动在继续"
|
|
200
|
-
: planning
|
|
201
|
-
? "正在想自己的安排"
|
|
202
|
-
: phase?.key === "asleep"
|
|
203
|
-
? "在睡觉"
|
|
204
|
-
: next
|
|
205
|
-
? "这会儿还没有主活动"
|
|
206
|
-
: "这会儿没有正在推进的主活动",
|
|
207
|
-
reason: primary
|
|
208
|
-
? "普通交流可以伴随进行"
|
|
209
|
-
: planning
|
|
210
|
-
? "把想做的事、开始时间和投入时长想清楚"
|
|
211
|
-
: phase?.key === "asleep"
|
|
212
|
-
? "醒来后再接着自己的安排"
|
|
213
|
-
: next
|
|
214
|
-
? "下一项已经选好时间,之前可以聊天、歇着或随手折腾"
|
|
215
|
-
: paused.length
|
|
216
|
-
? "有活动保留了续接位置,之后由她重新安排"
|
|
217
|
-
: unarranged.length
|
|
218
|
-
? "待办已经记下,等她选择具体时间"
|
|
219
|
-
: "可以自己找件小事做,也可以选择歇着",
|
|
220
|
-
next,
|
|
221
|
-
};
|
|
222
|
-
return {
|
|
223
|
-
date,
|
|
224
|
-
zone,
|
|
225
|
-
start,
|
|
226
|
-
end,
|
|
227
|
-
now,
|
|
228
|
-
actual,
|
|
229
|
-
planned,
|
|
230
|
-
waiting,
|
|
231
|
-
unarranged,
|
|
232
|
-
paused,
|
|
233
|
-
idle,
|
|
234
|
-
interactions: today.interactions.map((p) => ({
|
|
235
|
-
id: p.id,
|
|
236
|
-
at: p.created,
|
|
237
|
-
taskId: p.task_id,
|
|
238
|
-
})),
|
|
239
|
-
note: "下方是她已选定的开始时间和这次想投入的时长。实际经过单独记录;提前完成、暂停或优先级切换后会保留原安排并重新选择。空白不代表已经在做什么。",
|
|
240
|
-
};
|
|
241
|
-
}
|
|
242
|
-
}
|
|
1
|
+
import { dayKey, zonedTime, parse } from "../util.js";
|
|
2
|
+
import { activityPresentation } from "./presentation.js";
|
|
3
|
+
import { executionBlock } from "./availability.js";
|
|
4
|
+
|
|
5
|
+
// A view of saved choices and actual spans. Reading it never makes a plan.
|
|
6
|
+
export class Agenda {
|
|
7
|
+
constructor(time) {
|
|
8
|
+
this.time = time;
|
|
9
|
+
this.db = time.db;
|
|
10
|
+
}
|
|
11
|
+
blocked(task, now) {
|
|
12
|
+
if (task.state === "paused" && task.next_step >= Number.MAX_SAFE_INTEGER)
|
|
13
|
+
return task.wait_reason || "自己选择暂停,等待重新安排";
|
|
14
|
+
return executionBlock(this.time, task, now);
|
|
15
|
+
}
|
|
16
|
+
view(now = this.time.now()) {
|
|
17
|
+
const time = this.time,
|
|
18
|
+
zone = time.mind.timeZone(),
|
|
19
|
+
date = dayKey(now, zone);
|
|
20
|
+
const nextDate = new Date(Date.parse(date + "T12:00:00Z") + 86400000)
|
|
21
|
+
.toISOString()
|
|
22
|
+
.slice(0, 10);
|
|
23
|
+
const start = zonedTime(date, zone),
|
|
24
|
+
end = zonedTime(nextDate, zone),
|
|
25
|
+
today = time.today(now),
|
|
26
|
+
primary = time.primary();
|
|
27
|
+
const actual = today.spans
|
|
28
|
+
.map((s) => {
|
|
29
|
+
const rename = this.db
|
|
30
|
+
.prepare(
|
|
31
|
+
"SELECT data FROM mind_time_events WHERE task_id=? AND kind='self-scheduled' AND created>=? ORDER BY created,id LIMIT 1",
|
|
32
|
+
)
|
|
33
|
+
.get(s.task_id, s.started);
|
|
34
|
+
const title = parse(rename?.data, {}).previousTitle || s.title;
|
|
35
|
+
return {
|
|
36
|
+
id: s.id,
|
|
37
|
+
taskId: s.task_id,
|
|
38
|
+
title,
|
|
39
|
+
activity: s.activity,
|
|
40
|
+
start: Math.max(start, s.started),
|
|
41
|
+
end: Math.min(now, s.ended ?? s.updated),
|
|
42
|
+
engagedMs: s.clocked || time.fixtureImmediate ? s.todayMs : null,
|
|
43
|
+
ongoing: !s.ended && primary?.id === s.task_id,
|
|
44
|
+
kind: "actual",
|
|
45
|
+
label:
|
|
46
|
+
!s.ended && primary?.id === s.task_id
|
|
47
|
+
? primary.checkpoint.activityClock?.phase === "preparing"
|
|
48
|
+
? "准备中"
|
|
49
|
+
: "正在做"
|
|
50
|
+
: s.clocked && !s.todayMs
|
|
51
|
+
? "准备时段"
|
|
52
|
+
: "已发生",
|
|
53
|
+
};
|
|
54
|
+
})
|
|
55
|
+
.filter((s) => s.end > s.start);
|
|
56
|
+
const planned = [],
|
|
57
|
+
waiting = [],
|
|
58
|
+
unarranged = [],
|
|
59
|
+
paused = [];
|
|
60
|
+
const rows = this.db
|
|
61
|
+
.prepare(
|
|
62
|
+
"SELECT id FROM mind_time_tasks WHERE created<=? AND state IN ('todo','scheduled','doing','paused','waiting') AND json_extract(checkpoint,'$.mergedInto') IS NULL ORDER BY priority DESC,created LIMIT 100",
|
|
63
|
+
)
|
|
64
|
+
.all(now);
|
|
65
|
+
for (const row of rows) {
|
|
66
|
+
const task = time.tasks.get(row.id),
|
|
67
|
+
view = activityPresentation(task),
|
|
68
|
+
slot = task.checkpoint.schedule;
|
|
69
|
+
const why = this.blocked(task, now);
|
|
70
|
+
if (task.state === "paused") {
|
|
71
|
+
if (paused.length < 12)
|
|
72
|
+
paused.push({
|
|
73
|
+
id: task.id,
|
|
74
|
+
title: view.title,
|
|
75
|
+
reason: task.wait_reason || "暂时停下来,进度已保存",
|
|
76
|
+
});
|
|
77
|
+
continue;
|
|
78
|
+
}
|
|
79
|
+
if (why || task.state === "waiting") {
|
|
80
|
+
if (waiting.length < 12)
|
|
81
|
+
waiting.push({
|
|
82
|
+
id: task.id,
|
|
83
|
+
title: view.title,
|
|
84
|
+
reason: why || task.wait_reason,
|
|
85
|
+
retryAt:
|
|
86
|
+
task.next_step < Number.MAX_SAFE_INTEGER ? task.next_step : null,
|
|
87
|
+
});
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
if (
|
|
91
|
+
!slot?.chosenAt ||
|
|
92
|
+
task.checkpoint.reschedule ||
|
|
93
|
+
(slot.endedAt <= now && task.state !== "doing")
|
|
94
|
+
) {
|
|
95
|
+
if (unarranged.length < 12)
|
|
96
|
+
unarranged.push({
|
|
97
|
+
id: task.id,
|
|
98
|
+
title: view.title,
|
|
99
|
+
reason: slot?.chosenAt
|
|
100
|
+
? "原安排已过去,等她重新选时间"
|
|
101
|
+
: "事情已经记下,等她选择几点做、做多久",
|
|
102
|
+
});
|
|
103
|
+
continue;
|
|
104
|
+
}
|
|
105
|
+
if (slot.proposedAt >= end || slot.endedAt <= start) {
|
|
106
|
+
if (unarranged.length < 12)
|
|
107
|
+
unarranged.push({
|
|
108
|
+
id: task.id,
|
|
109
|
+
title: view.title,
|
|
110
|
+
reason: "安排在今天之外",
|
|
111
|
+
startAt: slot.proposedAt,
|
|
112
|
+
});
|
|
113
|
+
continue;
|
|
114
|
+
}
|
|
115
|
+
planned.push({
|
|
116
|
+
id: "slot:" + task.id,
|
|
117
|
+
kind: "activity",
|
|
118
|
+
taskId: task.id,
|
|
119
|
+
title: view.title,
|
|
120
|
+
activity: task.activity,
|
|
121
|
+
kindOfTask: task.kind,
|
|
122
|
+
priority: task.priority,
|
|
123
|
+
start: Math.max(start, slot.proposedAt),
|
|
124
|
+
end: Math.min(end, slot.endedAt),
|
|
125
|
+
chosenStart: slot.proposedAt,
|
|
126
|
+
chosenEnd: slot.endedAt,
|
|
127
|
+
durationMinutes: slot.durationMinutes,
|
|
128
|
+
why: slot.reason || view.why,
|
|
129
|
+
label:
|
|
130
|
+
task.state === "doing"
|
|
131
|
+
? "正在执行这份安排"
|
|
132
|
+
: slot.chosenBy === "admin"
|
|
133
|
+
? "管理台安排"
|
|
134
|
+
: "她选定的安排",
|
|
135
|
+
estimated: false,
|
|
136
|
+
scope: "这次投入",
|
|
137
|
+
state: task.state,
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
const rhythm = time.mind.nature.current(now).rhythm;
|
|
141
|
+
if (rhythm?.enabled) {
|
|
142
|
+
const bed = zonedTime(date + " " + rhythm.sleep, zone),
|
|
143
|
+
wake = zonedTime(date + " " + rhythm.wake, zone);
|
|
144
|
+
for (const [a, b] of bed < wake
|
|
145
|
+
? [[bed, wake]]
|
|
146
|
+
: [
|
|
147
|
+
[start, wake],
|
|
148
|
+
[bed, end],
|
|
149
|
+
])
|
|
150
|
+
if (b > now)
|
|
151
|
+
planned.push({
|
|
152
|
+
id: "sleep:" + a,
|
|
153
|
+
kind: "sleep",
|
|
154
|
+
title: "作息中的睡眠时间",
|
|
155
|
+
start: Math.max(now, a),
|
|
156
|
+
end: b,
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
for (const block of planned.filter((b) => b.taskId)) {
|
|
160
|
+
const urgent = planned
|
|
161
|
+
.filter(
|
|
162
|
+
(b) =>
|
|
163
|
+
b.taskId &&
|
|
164
|
+
b.taskId !== block.taskId &&
|
|
165
|
+
b.priority > block.priority &&
|
|
166
|
+
b.start < block.end &&
|
|
167
|
+
b.end > block.start,
|
|
168
|
+
)
|
|
169
|
+
.sort((a, b) => a.start - b.start)[0];
|
|
170
|
+
const bedtime = planned
|
|
171
|
+
.filter(
|
|
172
|
+
(b) =>
|
|
173
|
+
b.kind === "sleep" && b.start < block.end && b.end > block.start,
|
|
174
|
+
)
|
|
175
|
+
.sort((a, b) => a.start - b.start)[0];
|
|
176
|
+
const stop = Math.min(
|
|
177
|
+
urgent ? Math.max(block.start, urgent.start) : block.end,
|
|
178
|
+
bedtime ? Math.max(block.start, bedtime.start) : block.end,
|
|
179
|
+
);
|
|
180
|
+
block.chartEnd = stop;
|
|
181
|
+
if (stop < block.end) {
|
|
182
|
+
block.interruptedAt = stop;
|
|
183
|
+
block.interruption =
|
|
184
|
+
bedtime && stop === bedtime.start ? "sleep" : "priority";
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
planned.sort(
|
|
188
|
+
(a, b) => a.start - b.start || (b.priority || 0) - (a.priority || 0),
|
|
189
|
+
);
|
|
190
|
+
const next =
|
|
191
|
+
planned
|
|
192
|
+
.filter((b) => b.taskId && b.state !== "doing" && b.chosenStart > now)
|
|
193
|
+
.sort((a, b) => a.chosenStart - b.chosenStart)[0] || null;
|
|
194
|
+
const life = time.search.life,
|
|
195
|
+
planning = life?.planner?.working || life?.ownDay?.working,
|
|
196
|
+
phase = life?.phase(now);
|
|
197
|
+
const idle = {
|
|
198
|
+
title: primary
|
|
199
|
+
? "有主活动在继续"
|
|
200
|
+
: planning
|
|
201
|
+
? "正在想自己的安排"
|
|
202
|
+
: phase?.key === "asleep"
|
|
203
|
+
? "在睡觉"
|
|
204
|
+
: next
|
|
205
|
+
? "这会儿还没有主活动"
|
|
206
|
+
: "这会儿没有正在推进的主活动",
|
|
207
|
+
reason: primary
|
|
208
|
+
? "普通交流可以伴随进行"
|
|
209
|
+
: planning
|
|
210
|
+
? "把想做的事、开始时间和投入时长想清楚"
|
|
211
|
+
: phase?.key === "asleep"
|
|
212
|
+
? "醒来后再接着自己的安排"
|
|
213
|
+
: next
|
|
214
|
+
? "下一项已经选好时间,之前可以聊天、歇着或随手折腾"
|
|
215
|
+
: paused.length
|
|
216
|
+
? "有活动保留了续接位置,之后由她重新安排"
|
|
217
|
+
: unarranged.length
|
|
218
|
+
? "待办已经记下,等她选择具体时间"
|
|
219
|
+
: "可以自己找件小事做,也可以选择歇着",
|
|
220
|
+
next,
|
|
221
|
+
};
|
|
222
|
+
return {
|
|
223
|
+
date,
|
|
224
|
+
zone,
|
|
225
|
+
start,
|
|
226
|
+
end,
|
|
227
|
+
now,
|
|
228
|
+
actual,
|
|
229
|
+
planned,
|
|
230
|
+
waiting,
|
|
231
|
+
unarranged,
|
|
232
|
+
paused,
|
|
233
|
+
idle,
|
|
234
|
+
interactions: today.interactions.map((p) => ({
|
|
235
|
+
id: p.id,
|
|
236
|
+
at: p.created,
|
|
237
|
+
taskId: p.task_id,
|
|
238
|
+
})),
|
|
239
|
+
note: "下方是她已选定的开始时间和这次想投入的时长。实际经过单独记录;提前完成、暂停或优先级切换后会保留原安排并重新选择。空白不代表已经在做什么。",
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
}
|