@evandu/super-pi 0.1.221 → 0.1.223
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/agents/super-pi-task/core.ts +15 -15
- package/agents/super-pi-task/index.ts +5 -2
- package/dist/client/.super-pi-client-sources.json +9 -8
- package/dist/client/assets/{CodeMirrorEditor-Cv1X2hmd.js → CodeMirrorEditor-Due3YL4A.js} +2 -2
- package/dist/client/assets/{dist-ClwDCrdU.js → dist-1hXEE44f.js} +1 -1
- package/dist/client/assets/{dist-C071I6sD.js → dist-2kMlRtqo.js} +1 -1
- package/dist/client/assets/{dist-BqNxkXgs.js → dist-B2XX-bBx.js} +1 -1
- package/dist/client/assets/{dist-CT23BwQB.js → dist-B3qtMidG.js} +1 -1
- package/dist/client/assets/{dist-B3GZVLeH.js → dist-BHlGN5Cp.js} +1 -1
- package/dist/client/assets/{dist-Bxyffyjn.js → dist-BJ5mZEGq.js} +1 -1
- package/dist/client/assets/{dist-IohJ9Qkl.js → dist-BJ_pU8qp.js} +1 -1
- package/dist/client/assets/{dist-CRfLPcZ8.js → dist-BXTbngmK.js} +1 -1
- package/dist/client/assets/{dist-DrNjVA0k.js → dist-BZGq856v.js} +1 -1
- package/dist/client/assets/{dist-CeHhOkTz.js → dist-BaUqm3zx.js} +1 -1
- package/dist/client/assets/{dist-DPYofnO9.js → dist-BvUexO6W.js} +1 -1
- package/dist/client/assets/{dist-xdw6XDXx.js → dist-CA52X7jm.js} +1 -1
- package/dist/client/assets/{dist-CVErcv3I.js → dist-CMws1R9h.js} +1 -1
- package/dist/client/assets/{dist-J-F3f1eU.js → dist-CQIMZ_7M.js} +1 -1
- package/dist/client/assets/{dist-DlBSkHdo.js → dist-CRrYz-2t.js} +1 -1
- package/dist/client/assets/{dist-Gvvox7eW.js → dist-Cw21UX77.js} +1 -1
- package/dist/client/assets/{dist-C-Kbr0WK.js → dist-D2n9-vIx.js} +1 -1
- package/dist/client/assets/{dist-w6rH3SJG.js → dist-DCVXoyno.js} +1 -1
- package/dist/client/assets/{dist-C729XRkf.js → dist-DOJKt6Px.js} +1 -1
- package/dist/client/assets/{dist-BT_Z_-2X.js → dist-DSCSHwdP.js} +1 -1
- package/dist/client/assets/{dist-BA1wBjGJ.js → dist-JSFnHR0P.js} +1 -1
- package/dist/client/assets/{dist-CsqiBKUZ.js → dist-Po3GdueN.js} +1 -1
- package/dist/client/assets/index-DHdzZ1mf.js +103 -0
- package/dist/client/assets/index-OmaD3l6r.css +1 -0
- package/dist/client/index.html +2 -2
- package/dist/server/application/conversation-service.d.ts +15 -0
- package/dist/server/application/conversation-service.js +28 -0
- package/dist/server/application/project-service.d.ts +7 -1
- package/dist/server/application/project-service.js +29 -9
- package/dist/server/application/session-reminder-service.d.ts +7 -3
- package/dist/server/application/session-reminder-service.js +40 -19
- package/dist/server/http-server.js +7 -7
- package/dist/server/store.js +7 -0
- package/dist/server/task-tool.d.ts +1 -1
- package/dist/server/task-tool.js +7 -7
- package/dist/server/types.d.ts +17 -0
- package/dist/shared/archive-decisions.d.ts +37 -0
- package/dist/shared/archive-decisions.js +86 -0
- package/dist/shared/project-overview.d.ts +35 -0
- package/dist/shared/project-overview.js +39 -1
- package/package.json +3 -1
- package/dist/client/assets/index-B-h_KnC5.css +0 -1
- package/dist/client/assets/index-CCF1Ymba.js +0 -103
package/dist/client/index.html
CHANGED
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
<link rel="alternate icon" href="/favicon.ico" />
|
|
9
9
|
<link rel="apple-touch-icon" href="/favicon.svg" />
|
|
10
10
|
<title>Super Pi</title>
|
|
11
|
-
<script type="module" crossorigin src="/assets/index-
|
|
12
|
-
<link rel="stylesheet" crossorigin href="/assets/index-
|
|
11
|
+
<script type="module" crossorigin src="/assets/index-DHdzZ1mf.js"></script>
|
|
12
|
+
<link rel="stylesheet" crossorigin href="/assets/index-OmaD3l6r.css">
|
|
13
13
|
</head>
|
|
14
14
|
<body>
|
|
15
15
|
<div id="root"></div>
|
|
@@ -117,8 +117,23 @@ export declare class ConversationService {
|
|
|
117
117
|
selectConversation(conversationId: string): Promise<void>;
|
|
118
118
|
/**
|
|
119
119
|
* Archives a conversation.
|
|
120
|
+
*
|
|
121
|
+
* 归档这件事带三件事:树被归档、**欠着用户的决策随之作废**、然后广播一次。
|
|
122
|
+
*
|
|
123
|
+
* 为什么作废:负责人会话被归档 ⇒ 那个项目从此没人管 ⇒ 它欠用户的决定没有人会再去问了。
|
|
124
|
+
* 用户自己说过:「一旦决定归档了,过往所有的待决策项都是垃圾」。所以那些决策作废。
|
|
125
|
+
*
|
|
126
|
+
* 作废是**定性**,不是删除:例外仍然留在 `p.escalations` 里,`status` 变成 `dismissed`,
|
|
127
|
+
* `decision` 写下为什么,`resolvedAt` 记下什么时候 —— 可查、可导出。supervisor 级的内部事
|
|
128
|
+
* 不作废,别的项目的例外也不动。
|
|
129
|
+
*
|
|
130
|
+
* 顺序有讲究:先归档再作废。归档失败(运行中的会话)时什么也不该发生。
|
|
120
131
|
*/
|
|
121
132
|
archiveConversation(conversationId: string): Promise<void>;
|
|
133
|
+
/**
|
|
134
|
+
* 把「负责人会话被归档」的那些项目的未决用户级例外作废。记录留下,状态改掉。
|
|
135
|
+
*/
|
|
136
|
+
private dismissDecisionsOfArchivedOwners;
|
|
122
137
|
/**
|
|
123
138
|
* Unarchives an archived tree root and every archived descendant. Descendants that are
|
|
124
139
|
* already active need no write; they are already in the live tree this restore rejoins.
|
|
@@ -2,6 +2,7 @@ import { assertModelAllowed } from "../model-filter.js";
|
|
|
2
2
|
import { newConversationId } from "../store.js";
|
|
3
3
|
import { normalizeSessionCwd, resolveSessionCwd } from "../session-cwd.js";
|
|
4
4
|
import { isChildSession } from "../../shared/child-session-lock.js";
|
|
5
|
+
import { dismissArchivedOwnerDecisions } from "../../shared/archive-decisions.js";
|
|
5
6
|
import { rm } from "node:fs/promises";
|
|
6
7
|
import { copyForkUploads, deleteConversationUploads } from "../upload.js";
|
|
7
8
|
function isMissingPrimaryAgent(error, agentId) {
|
|
@@ -237,12 +238,39 @@ export class ConversationService {
|
|
|
237
238
|
}
|
|
238
239
|
/**
|
|
239
240
|
* Archives a conversation.
|
|
241
|
+
*
|
|
242
|
+
* 归档这件事带三件事:树被归档、**欠着用户的决策随之作废**、然后广播一次。
|
|
243
|
+
*
|
|
244
|
+
* 为什么作废:负责人会话被归档 ⇒ 那个项目从此没人管 ⇒ 它欠用户的决定没有人会再去问了。
|
|
245
|
+
* 用户自己说过:「一旦决定归档了,过往所有的待决策项都是垃圾」。所以那些决策作废。
|
|
246
|
+
*
|
|
247
|
+
* 作废是**定性**,不是删除:例外仍然留在 `p.escalations` 里,`status` 变成 `dismissed`,
|
|
248
|
+
* `decision` 写下为什么,`resolvedAt` 记下什么时候 —— 可查、可导出。supervisor 级的内部事
|
|
249
|
+
* 不作废,别的项目的例外也不动。
|
|
250
|
+
*
|
|
251
|
+
* 顺序有讲究:先归档再作废。归档失败(运行中的会话)时什么也不该发生。
|
|
240
252
|
*/
|
|
241
253
|
async archiveConversation(conversationId) {
|
|
242
254
|
this.runService.reviewMemoryBoundary(conversationId);
|
|
255
|
+
const archivedIds = this.store.conversationSubtreeIds(conversationId);
|
|
243
256
|
await this.store.archiveConversationTree(conversationId);
|
|
257
|
+
await this.dismissDecisionsOfArchivedOwners(archivedIds);
|
|
244
258
|
this.broadcaster.broadcastState();
|
|
245
259
|
}
|
|
260
|
+
/**
|
|
261
|
+
* 把「负责人会话被归档」的那些项目的未决用户级例外作废。记录留下,状态改掉。
|
|
262
|
+
*/
|
|
263
|
+
async dismissDecisionsOfArchivedOwners(conversationIds) {
|
|
264
|
+
if (!conversationIds.length)
|
|
265
|
+
return;
|
|
266
|
+
const projects = this.store.projects();
|
|
267
|
+
const updated = dismissArchivedOwnerDecisions(projects, conversationIds, new Date().toISOString());
|
|
268
|
+
for (const [index, project] of updated.entries()) {
|
|
269
|
+
if (project === projects[index])
|
|
270
|
+
continue;
|
|
271
|
+
await this.store.setProject(project);
|
|
272
|
+
}
|
|
273
|
+
}
|
|
246
274
|
/**
|
|
247
275
|
* Unarchives an archived tree root and every archived descendant. Descendants that are
|
|
248
276
|
* already active need no write; they are already in the live tree this restore rejoins.
|
|
@@ -300,7 +300,13 @@ export declare class ProjectService {
|
|
|
300
300
|
};
|
|
301
301
|
private reconcile;
|
|
302
302
|
private resources;
|
|
303
|
-
list(workspaceId?: string): Project[];
|
|
303
|
+
list(workspaceId?: string, view?: "current" | "history"): Project[];
|
|
304
|
+
/**
|
|
305
|
+
* IS THE OWNER SESSION IN THE ARCHIVE? A project whose leader was archived has nobody left to
|
|
306
|
+
* run it. The server is the one that knows what is archived, so it computes the answer and
|
|
307
|
+
* hands the client the same fact in the project payload (`ownerArchived`).
|
|
308
|
+
*/
|
|
309
|
+
private ownerArchived;
|
|
304
310
|
headline(p: Project, actor?: string, resources?: Project["resources"]): string;
|
|
305
311
|
private activitySessions;
|
|
306
312
|
private isActorRelated;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { randomUUID } from "node:crypto";
|
|
2
2
|
import { deriveProjectActivity, deriveTaskActivity } from "../../shared/project-presentation.js";
|
|
3
|
-
import { deliveryCoversTasks, latestProjectDelivery } from "../../shared/project-overview.js";
|
|
3
|
+
import { deliveryCoversTasks, latestProjectDelivery, projectInView } from "../../shared/project-overview.js";
|
|
4
4
|
import { buildTeamHandoff, discoverTeamFiles, parseTeamContext, pathsOverlap, publishTeamContext, teamPaths } from "../team-context.js";
|
|
5
5
|
import { deriveReportingState, deriveSessionState, sessionStateWord, } from "../../shared/session-reporting.js";
|
|
6
6
|
const stamp = () => new Date().toISOString();
|
|
@@ -639,6 +639,10 @@ export class ProjectService {
|
|
|
639
639
|
return {
|
|
640
640
|
...p,
|
|
641
641
|
status: this.statusWithInterruptions(p),
|
|
642
|
+
/* THE CLIENT MIRRORS THE VIEW RULE, so it needs the same fact: is the owner session in the
|
|
643
|
+
archive? The server computes it (it is the one that knows), and the client re-applies the
|
|
644
|
+
rule rather than guessing. */
|
|
645
|
+
ownerArchived: this.ownerArchived(p),
|
|
642
646
|
resources,
|
|
643
647
|
activity: deriveProjectActivity({ ...p, status: this.statusWithInterruptions(p), resources }),
|
|
644
648
|
tasks: p.tasks.map((t) => ({ ...ProjectService.taskView(t, p), activity: deriveTaskActivity(t, resources.sessions, p.mode, p.tasks) })),
|
|
@@ -1038,11 +1042,13 @@ export class ProjectService {
|
|
|
1038
1042
|
* "project" by the same rule as everybody else - there is no special case for it. */
|
|
1039
1043
|
const projectTreeId = p.ownerConversationId ? this.store.conversation(p.ownerConversationId)?.treeId : undefined;
|
|
1040
1044
|
const memberConversations = state.conversations.filter((c) => c.workspaceId === p.workspaceId && members.has(c.id));
|
|
1045
|
+
// Match the sidebar's archive marker without removing historical usage.
|
|
1046
|
+
const visibleMemberConversations = memberConversations.filter((c) => !c.archivedAt);
|
|
1041
1047
|
const openEscalationRequesters = new Set((p.escalations ?? [])
|
|
1042
1048
|
.filter((e) => e.status === "open" && e.requestedByConversationId)
|
|
1043
1049
|
.map((e) => e.requestedByConversationId));
|
|
1044
1050
|
const snapshotMap = new Map();
|
|
1045
|
-
for (const c of
|
|
1051
|
+
for (const c of visibleMemberConversations) {
|
|
1046
1052
|
snapshotMap.set(c.id, {
|
|
1047
1053
|
id: c.id,
|
|
1048
1054
|
parentConversationId: c.parentConversationId,
|
|
@@ -1053,9 +1059,9 @@ export class ProjectService {
|
|
|
1053
1059
|
...(c.hasPendingResult ? { hasPendingResult: true } : {}),
|
|
1054
1060
|
});
|
|
1055
1061
|
}
|
|
1056
|
-
const sessions =
|
|
1062
|
+
const sessions = visibleMemberConversations.map((c) => {
|
|
1057
1063
|
const parent = c.parentConversationId ? this.store.conversation(c.parentConversationId) : undefined;
|
|
1058
|
-
const directChildren =
|
|
1064
|
+
const directChildren = visibleMemberConversations
|
|
1059
1065
|
.filter((child) => child.parentConversationId === c.id)
|
|
1060
1066
|
.map((child) => snapshotMap.get(child.id));
|
|
1061
1067
|
const snapshot = snapshotMap.get(c.id);
|
|
@@ -1128,17 +1134,31 @@ export class ProjectService {
|
|
|
1128
1134
|
return acc;
|
|
1129
1135
|
}, { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 });
|
|
1130
1136
|
return { tokens: tokens(usage),
|
|
1131
|
-
usageKnown:
|
|
1132
|
-
activeWorkers: sessions.filter((s) => (!coordinatorIds.has(s.id) || (leaderIsWorker && s.id === p.ownerConversationId)) && busy(s.status)).length + runs.filter((r) => r.status === "running").length,
|
|
1137
|
+
usageKnown: memberConversations.length > 0 && memberConversations.every((c) => Boolean(c.usage)) && runs.every((r) => Boolean(r.usage)),
|
|
1138
|
+
activeWorkers: sessions.filter((s) => (!coordinatorIds.has(s.id) || (leaderIsWorker && s.id === p.ownerConversationId)) && busy(s.status)).length + runs.filter((r) => r.status === "running" && visibleMemberConversations.some((c) => c.id === r.conversationId)).length,
|
|
1133
1139
|
// THE PROJECT'S OWN MEMORY TREE, named once so the client does not have to infer it from
|
|
1134
1140
|
// the sessions. Absent only when the project has no leader session yet.
|
|
1135
1141
|
memoryTreeId: projectTreeId, sessions,
|
|
1142
|
+
// Evidence keeps its original base directory even when the owner is archived.
|
|
1143
|
+
ownerCwd: memberConversations.find((c) => c.id === p.ownerConversationId)?.cwd,
|
|
1136
1144
|
// THE RAW 1:1 PICTURE OF THE SAME MONEY, next to the equivalent number it is spent in.
|
|
1137
1145
|
usage, rawTokens: usage.input + usage.output + usage.cacheRead + usage.cacheWrite };
|
|
1138
1146
|
}
|
|
1139
|
-
list(workspaceId) {
|
|
1147
|
+
list(workspaceId, view = "current") {
|
|
1140
1148
|
const scope = this.workspace(workspaceId);
|
|
1141
|
-
return this.store.projects()
|
|
1149
|
+
return this.store.projects()
|
|
1150
|
+
.filter((p) => p.workspaceId === scope && projectInView(p, this.ownerArchived(p), view))
|
|
1151
|
+
.map((p) => this.projectView(p));
|
|
1152
|
+
}
|
|
1153
|
+
/**
|
|
1154
|
+
* IS THE OWNER SESSION IN THE ARCHIVE? A project whose leader was archived has nobody left to
|
|
1155
|
+
* run it. The server is the one that knows what is archived, so it computes the answer and
|
|
1156
|
+
* hands the client the same fact in the project payload (`ownerArchived`).
|
|
1157
|
+
*/
|
|
1158
|
+
ownerArchived(p) {
|
|
1159
|
+
if (!p.ownerConversationId)
|
|
1160
|
+
return false;
|
|
1161
|
+
return Boolean(this.store.conversation(p.ownerConversationId)?.archivedAt);
|
|
1142
1162
|
}
|
|
1143
1163
|
headline(p, actor, resources) {
|
|
1144
1164
|
const total = p.tasks.length;
|
|
@@ -1180,7 +1200,7 @@ export class ProjectService {
|
|
|
1180
1200
|
}
|
|
1181
1201
|
activitySessions(p) {
|
|
1182
1202
|
const ids = new Set([p.ownerConversationId, ...p.tasks.flatMap(task => [task.ownerConversationId, task.reviewerConversationId])].filter(Boolean));
|
|
1183
|
-
return [...ids].flatMap(id => { const session = this.store.conversation(id); return session ? [{ id, status: session.status }] : []; });
|
|
1203
|
+
return [...ids].flatMap(id => { const session = this.store.conversation(id); return session && !session.archivedAt ? [{ id, status: session.status }] : []; });
|
|
1184
1204
|
}
|
|
1185
1205
|
isActorRelated(p, actor) {
|
|
1186
1206
|
return this.isMember(p, actor);
|
|
@@ -4,6 +4,7 @@ export interface SessionReminderItem {
|
|
|
4
4
|
reminderId: string;
|
|
5
5
|
conversationId: string;
|
|
6
6
|
note: string;
|
|
7
|
+
repeat: boolean;
|
|
7
8
|
delaySeconds: number;
|
|
8
9
|
fireAt: number;
|
|
9
10
|
createdAt: number;
|
|
@@ -14,19 +15,22 @@ export declare class SessionReminderService {
|
|
|
14
15
|
private reminders;
|
|
15
16
|
constructor(runService: RunService, store: Store);
|
|
16
17
|
/**
|
|
17
|
-
* Schedules a
|
|
18
|
+
* Schedules a wake-up for the same conversation after delaySeconds.
|
|
18
19
|
*/
|
|
19
20
|
createReminder(params: {
|
|
20
21
|
conversationId: string;
|
|
21
22
|
delaySeconds: number;
|
|
22
|
-
note
|
|
23
|
+
note?: string;
|
|
24
|
+
repeat?: boolean;
|
|
23
25
|
}): {
|
|
24
26
|
ok: true;
|
|
25
27
|
reminderId: string;
|
|
26
28
|
delaySeconds: number;
|
|
27
29
|
note: string;
|
|
30
|
+
repeat: boolean;
|
|
28
31
|
fireAt: string;
|
|
29
32
|
};
|
|
33
|
+
private arm;
|
|
30
34
|
/**
|
|
31
35
|
* Cancels a pending reminder by ID.
|
|
32
36
|
*
|
|
@@ -49,7 +53,7 @@ export declare class SessionReminderService {
|
|
|
49
53
|
*/
|
|
50
54
|
cancelAllForConversation(conversationId: string): void;
|
|
51
55
|
/**
|
|
52
|
-
* Timer callback:
|
|
56
|
+
* Timer callback: wakes the originating conversation.
|
|
53
57
|
*/
|
|
54
58
|
private triggerReminder;
|
|
55
59
|
}
|
|
@@ -8,10 +8,10 @@ export class SessionReminderService {
|
|
|
8
8
|
this.store = store;
|
|
9
9
|
}
|
|
10
10
|
/**
|
|
11
|
-
* Schedules a
|
|
11
|
+
* Schedules a wake-up for the same conversation after delaySeconds.
|
|
12
12
|
*/
|
|
13
13
|
createReminder(params) {
|
|
14
|
-
const { conversationId,
|
|
14
|
+
const { conversationId, repeat = false } = params;
|
|
15
15
|
const delaySeconds = Math.max(1, Math.round(params.delaySeconds));
|
|
16
16
|
// A REMINDER THAT FIRES IMMEDIATELY IS NOT A REMINDER. `Math.max(1, ...)` would quietly turn a
|
|
17
17
|
// zero or negative delay into "one second from now", so the bad number is refused in words
|
|
@@ -19,9 +19,6 @@ export class SessionReminderService {
|
|
|
19
19
|
if (!Number.isFinite(params.delaySeconds) || params.delaySeconds <= 0) {
|
|
20
20
|
throw new Error("提醒需要正的秒数:请传 delaySeconds(或 seconds)。");
|
|
21
21
|
}
|
|
22
|
-
if (!note || !note.trim()) {
|
|
23
|
-
throw new Error("提醒内容 (note) 不能为空");
|
|
24
|
-
}
|
|
25
22
|
const conversation = this.store.conversation(conversationId);
|
|
26
23
|
if (!conversation) {
|
|
27
24
|
throw new Error(`找不到会话:${conversationId}`);
|
|
@@ -29,30 +26,34 @@ export class SessionReminderService {
|
|
|
29
26
|
const reminderId = `rem_${randomUUID()}`;
|
|
30
27
|
const now = Date.now();
|
|
31
28
|
const fireAt = now + delaySeconds * 1000;
|
|
29
|
+
if (fireAt > 8.64e15)
|
|
30
|
+
throw new Error("提醒间隔超出日期范围。");
|
|
32
31
|
const item = {
|
|
33
32
|
reminderId,
|
|
34
33
|
conversationId,
|
|
35
|
-
note: note
|
|
34
|
+
note: repeat ? "" : (params.note?.trim() ?? ""),
|
|
35
|
+
repeat,
|
|
36
36
|
delaySeconds,
|
|
37
37
|
fireAt,
|
|
38
38
|
createdAt: now,
|
|
39
39
|
};
|
|
40
|
-
|
|
41
|
-
void this.triggerReminder(reminderId);
|
|
42
|
-
}, delaySeconds * 1000);
|
|
43
|
-
// Node process unref to avoid blocking process exit if idle
|
|
44
|
-
if (typeof timer.unref === "function") {
|
|
45
|
-
timer.unref();
|
|
46
|
-
}
|
|
47
|
-
this.reminders.set(reminderId, { item, timer });
|
|
40
|
+
this.reminders.set(reminderId, { item, timer: this.arm(item), lastFiredAt: now, delivering: false });
|
|
48
41
|
return {
|
|
49
42
|
ok: true,
|
|
50
43
|
reminderId,
|
|
51
44
|
delaySeconds,
|
|
52
45
|
note: item.note,
|
|
46
|
+
repeat,
|
|
53
47
|
fireAt: new Date(fireAt).toISOString(),
|
|
54
48
|
};
|
|
55
49
|
}
|
|
50
|
+
arm(item) {
|
|
51
|
+
// Node treats delays beyond the signed 32-bit limit as 1 ms. Re-arm long waits in chunks.
|
|
52
|
+
const delay = Math.min(item.fireAt - Date.now(), 2 ** 31 - 1);
|
|
53
|
+
const timer = setTimeout(() => void this.triggerReminder(item.reminderId), delay);
|
|
54
|
+
timer.unref();
|
|
55
|
+
return timer;
|
|
56
|
+
}
|
|
56
57
|
/**
|
|
57
58
|
* Cancels a pending reminder by ID.
|
|
58
59
|
*
|
|
@@ -78,7 +79,6 @@ export class SessionReminderService {
|
|
|
78
79
|
*/
|
|
79
80
|
listReminders(conversationId) {
|
|
80
81
|
const results = [];
|
|
81
|
-
const now = Date.now();
|
|
82
82
|
for (const { item } of this.reminders.values()) {
|
|
83
83
|
if (item.conversationId === conversationId) {
|
|
84
84
|
results.push({ ...item });
|
|
@@ -98,23 +98,44 @@ export class SessionReminderService {
|
|
|
98
98
|
}
|
|
99
99
|
}
|
|
100
100
|
/**
|
|
101
|
-
* Timer callback:
|
|
101
|
+
* Timer callback: wakes the originating conversation.
|
|
102
102
|
*/
|
|
103
103
|
async triggerReminder(reminderId) {
|
|
104
104
|
const entry = this.reminders.get(reminderId);
|
|
105
105
|
if (!entry)
|
|
106
106
|
return;
|
|
107
|
-
|
|
108
|
-
|
|
107
|
+
const now = Date.now();
|
|
108
|
+
if (now < entry.item.fireAt) {
|
|
109
|
+
entry.timer = this.arm(entry.item);
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
const { conversationId, note, repeat, delaySeconds } = entry.item;
|
|
109
113
|
const conversation = this.store.conversation(conversationId);
|
|
110
114
|
if (!conversation || conversation.archivedAt) {
|
|
115
|
+
this.reminders.delete(reminderId);
|
|
111
116
|
return;
|
|
112
117
|
}
|
|
118
|
+
if (repeat) {
|
|
119
|
+
entry.item.fireAt = now + delaySeconds * 1000;
|
|
120
|
+
entry.timer = this.arm(entry.item);
|
|
121
|
+
// One wake-up is enough while a previous reminder is running or still in the queue.
|
|
122
|
+
if (entry.delivering || this.store.listWaitingMessages(conversationId).some(message => message.source === "session-reminder"))
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
this.reminders.delete(reminderId);
|
|
127
|
+
}
|
|
128
|
+
const elapsed = Math.round((now - entry.lastFiredAt) / 1000);
|
|
129
|
+
entry.delivering = true;
|
|
113
130
|
try {
|
|
114
|
-
await this.runService.enqueueReminder(conversationId, note);
|
|
131
|
+
await this.runService.enqueueReminder(conversationId, note || `距上次计时已过 ${elapsed} 秒。`);
|
|
132
|
+
entry.lastFiredAt = now;
|
|
115
133
|
}
|
|
116
134
|
catch (error) {
|
|
117
135
|
console.warn(`Super Pi: delivering session reminder to ${conversationId} failed:`, error instanceof Error ? error.message : String(error));
|
|
118
136
|
}
|
|
137
|
+
finally {
|
|
138
|
+
entry.delivering = false;
|
|
139
|
+
}
|
|
119
140
|
}
|
|
120
141
|
}
|
|
@@ -1683,7 +1683,7 @@ export function createHttpServer(options) {
|
|
|
1683
1683
|
return;
|
|
1684
1684
|
}
|
|
1685
1685
|
if (!projectId) {
|
|
1686
|
-
json(200, { projects: service.list(requestedWorkspaceId) });
|
|
1686
|
+
json(200, { projects: service.list(requestedWorkspaceId, url.searchParams.get("view") === "history" ? "history" : "current") });
|
|
1687
1687
|
return;
|
|
1688
1688
|
}
|
|
1689
1689
|
const project = service.get(projectId, requestedWorkspaceId);
|
|
@@ -2102,13 +2102,13 @@ export function createHttpServer(options) {
|
|
|
2102
2102
|
json(400, { error: "提醒需要正的秒数:请传 delaySeconds(或 seconds)。" });
|
|
2103
2103
|
return;
|
|
2104
2104
|
}
|
|
2105
|
-
const note = typeof body.note === "string" ? body.note.trim() : "";
|
|
2106
|
-
if (!note) {
|
|
2107
|
-
json(400, { error: "提醒内容不能为空:note 要写清楚提醒什么。" });
|
|
2108
|
-
return;
|
|
2109
|
-
}
|
|
2110
2105
|
try {
|
|
2111
|
-
const created = reminders.createReminder({
|
|
2106
|
+
const created = reminders.createReminder({
|
|
2107
|
+
conversationId: callerConversationId,
|
|
2108
|
+
delaySeconds,
|
|
2109
|
+
note: typeof body.note === "string" ? body.note : undefined,
|
|
2110
|
+
repeat: body.repeat === true,
|
|
2111
|
+
});
|
|
2112
2112
|
json(200, { ...created, ok: true });
|
|
2113
2113
|
}
|
|
2114
2114
|
catch (error) {
|
package/dist/server/store.js
CHANGED
|
@@ -4,6 +4,7 @@ import { normalizeTodos } from "./task-tool.js";
|
|
|
4
4
|
import { initializeMemoryTrees, memoryTreeId } from "./session-memory-scope.js";
|
|
5
5
|
import { TOOL_ARG_CAP } from "./tool-calls.js";
|
|
6
6
|
import { serverTimeZone } from "./time-zone.js";
|
|
7
|
+
import { pendingUserDecisionsByOwner } from "../shared/archive-decisions.js";
|
|
7
8
|
function id(prefix) { return `${prefix}_${crypto.randomUUID()}`; }
|
|
8
9
|
/** Mints the id a forked conversation will have, BEFORE its Pi transcript exists.
|
|
9
10
|
*
|
|
@@ -1271,12 +1272,17 @@ export class Store {
|
|
|
1271
1272
|
const presets = warmSessions.length ? { warmSessions } : {};
|
|
1272
1273
|
const openEscalations = this.openEscalationAudiences();
|
|
1273
1274
|
const pendingResults = this.pendingResultConversationIds();
|
|
1275
|
+
/* 项目本身不上广播,但归档提醒要知道「归档这棵树会作废几条决策」。服务端算这个数,
|
|
1276
|
+
客户端只做加法 —— 判据在 `src/shared/archive-decisions.ts`,两边共用一份。 */
|
|
1277
|
+
const pendingDecisions = pendingUserDecisionsByOwner(this.state.projects ?? []);
|
|
1278
|
+
const pendingDecisionsField = Object.keys(pendingDecisions).length ? { pendingUserDecisionsByConversation: pendingDecisions } : {};
|
|
1274
1279
|
// Legacy sockets still receive complete visible transcripts. Project before cloning so a closed
|
|
1275
1280
|
// workspace's retained history is never copied just to discard it afterwards.
|
|
1276
1281
|
if (scope === undefined) {
|
|
1277
1282
|
return structuredClone({
|
|
1278
1283
|
...publicState,
|
|
1279
1284
|
...presets,
|
|
1285
|
+
...pendingDecisionsField,
|
|
1280
1286
|
workspaces,
|
|
1281
1287
|
conversations: visible.map((c) => {
|
|
1282
1288
|
const escalationAudience = openEscalations.get(c.id);
|
|
@@ -1308,6 +1314,7 @@ export class Store {
|
|
|
1308
1314
|
return structuredClone({
|
|
1309
1315
|
...publicState,
|
|
1310
1316
|
...presets,
|
|
1317
|
+
...pendingDecisionsField,
|
|
1311
1318
|
workspaces,
|
|
1312
1319
|
conversations,
|
|
1313
1320
|
// THE CLOCK THE SERVER SCHEDULES BY, NAMED. The scheduled-task panel renders 「每天 09:00」 and
|
|
@@ -264,7 +264,7 @@ export declare const SESSION_STOP_SUBTREE_TOOL_NAME = "session_stop_subtree";
|
|
|
264
264
|
export declare const SESSION_REMOVE_TOOL_NAME = "session_remove";
|
|
265
265
|
export declare const SESSION_REMINDER_TOOL_NAME = "session_reminder";
|
|
266
266
|
/** Model-facing description for session_reminder. */
|
|
267
|
-
export declare const SESSION_REMINDER_DESCRIPTION = "Set
|
|
267
|
+
export declare const SESSION_REMINDER_DESCRIPTION = "Set a timer that wakes THIS conversation. A timer without a note reports only the elapsed time. It does not introduce a new agenda or tell you how to act.\n\nFor a periodic project check-in, set delaySeconds and repeat: true once. On each wake-up, decide what to do based on the project\u2019s current state. Cancel the timer when it is no longer needed.\n\nActions:\n- \"create\" (default): Requires a positive delaySeconds (or seconds). Set repeat: true for recurring wake-ups that only report elapsed time. A one-off reminder can optionally include a short note. Returns reminderId.\n- \"cancel\": Cancel future wake-ups. Requires reminderId.\n- \"list\": List this conversation\u2019s active timers.\n\nUse scheduled_task for work that should run in a separate conversation.";
|
|
268
268
|
/** Model-facing description for session_spawn. */
|
|
269
269
|
export declare const SESSION_SPAWN_DESCRIPTION = "Create a child conversation in the current workspace and immediately dispatch its initial task. You can specify a primary agent as the child's role.\n\nDIFFERENCE FROM THE 'task' TOOL:\n- The 'task' tool delegates to a transient, one-shot subagent process (scout, critic, patcher) that runs once, returns its final text, and terminates. It has no conversation history and does not appear in the workspace sidebar.\n- 'session_spawn' creates a real, persistent child CONVERSATION in Super Pi. It appears in the sidebar, retains multi-turn message history, can receive follow-up messages via session_dispatch, can be inspected via session_status, and can be stopped via session_stop. The user can also switch to it in the Web UI.\n\nWHEN TO USE THIS:\n- Long-running, multi-phase tracks of work that require ongoing context, multiple turns of dialogue, or independent user visibility.\n- Multi-phase or complex work where the user needs each step to be visible and available for inspection or intervention: create a child session with session_spawn.\n- Parallel work streams (e.g., Track A: backend refactor, Track B: frontend component update) where both need full conversational capabilities.\n- When the user asks you to act as an orchestrator/manager who delegates to multiple sessions.\n\nWHEN NOT TO USE THIS:\n- For one-off, focused delegation with a single answer: use 'task' (with scout/critic/patcher). It is faster, cheaper, and returns directly to your transcript.\n- For running shell commands or build watchers: use 'run_async'.\n- For a single one-off delegation with a single answer: use 'task'.\n\nUsage notes:\n1. Spawning is ASYNCHRONOUS by default: it creates the conversation, enqueues the initial task, and returns the new conversationId immediately. The sibling session runs in the background.\n2. The initial task should provide clear context and goals since the new session starts with a fresh conversation history.\n3. Use session_status with the returned conversationId to check progress, or session_dispatch to send further messages.\n4. The new session reports completion to its DIRECT parent automatically, and that parent is always the calling session. 'parentConversationId' may only repeat the calling session's own id - the server refuses (403) any other session as the parent and creates nothing.\n5. The new session always belongs to the calling session's workspace. Pass 'cwd' as a workspace-relative subdirectory (for example, 'packages/a') when it should work below the workspace root; absolute paths and traversal are rejected.\n6. Optionally pass 'model' to choose which model the NEW session runs on: {\"provider\":\"...\",\"modelId\":\"...\"} - the same \"provider/modelId\" pair the model picker shows, and BOTH halves are required. Leave 'model' out and the new session starts on the workspace default model.\n7. Optionally pass 'watchdogTimeoutSeconds' to declare how long YOU are willing to wait for a report before you want to be reminded: a positive number of seconds. If the new session stays silent that long, you receive a '[Watchdog \u63D0\u9192]' message naming it. A report from the child (session_report) restarts the clock; the watchdog never stops the child. Leave it out to run without a watchdog.";
|
|
270
270
|
/** Model-facing description for session_status. */
|
package/dist/server/task-tool.js
CHANGED
|
@@ -369,16 +369,16 @@ export const SESSION_STOP_SUBTREE_TOOL_NAME = "session_stop_subtree";
|
|
|
369
369
|
export const SESSION_REMOVE_TOOL_NAME = "session_remove";
|
|
370
370
|
export const SESSION_REMINDER_TOOL_NAME = "session_reminder";
|
|
371
371
|
/** Model-facing description for session_reminder. */
|
|
372
|
-
export const SESSION_REMINDER_DESCRIPTION = `Set
|
|
372
|
+
export const SESSION_REMINDER_DESCRIPTION = `Set a timer that wakes THIS conversation. A timer without a note reports only the elapsed time. It does not introduce a new agenda or tell you how to act.
|
|
373
373
|
|
|
374
|
-
|
|
375
|
-
- Self-reminders and time-based checkpoints (e.g. "Check child session progress in 60 seconds", "Review test run in 120 seconds").
|
|
376
|
-
- Unlike scheduled_task which runs in a separate independent conversation, session_reminder sends the note back to THIS EXACT conversation as a new turn so you can follow up directly.
|
|
374
|
+
For a periodic project check-in, set delaySeconds and repeat: true once. On each wake-up, decide what to do based on the project’s current state. Cancel the timer when it is no longer needed.
|
|
377
375
|
|
|
378
376
|
Actions:
|
|
379
|
-
- "create" (default):
|
|
380
|
-
- "cancel": Cancel
|
|
381
|
-
- "list": List
|
|
377
|
+
- "create" (default): Requires a positive delaySeconds (or seconds). Set repeat: true for recurring wake-ups that only report elapsed time. A one-off reminder can optionally include a short note. Returns reminderId.
|
|
378
|
+
- "cancel": Cancel future wake-ups. Requires reminderId.
|
|
379
|
+
- "list": List this conversation’s active timers.
|
|
380
|
+
|
|
381
|
+
Use scheduled_task for work that should run in a separate conversation.`;
|
|
382
382
|
/** Model-facing description for session_spawn. */
|
|
383
383
|
export const SESSION_SPAWN_DESCRIPTION = `Create a child conversation in the current workspace and immediately dispatch its initial task. You can specify a primary agent as the child's role.
|
|
384
384
|
|
package/dist/server/types.d.ts
CHANGED
|
@@ -1139,6 +1139,11 @@ export type Project = {
|
|
|
1139
1139
|
risk: ProjectRisk;
|
|
1140
1140
|
status: ProjectStatus;
|
|
1141
1141
|
ownerConversationId?: string;
|
|
1142
|
+
/** IS THE OWNER SESSION IN THE ARCHIVE? A project whose leader was archived has nobody left to
|
|
1143
|
+
* run it, so it is history with its records intact - not work in progress. The server computes
|
|
1144
|
+
* it (it is the one that knows what is archived) and the client re-applies the same rule, so
|
|
1145
|
+
* both ends agree on which view a project belongs to. */
|
|
1146
|
+
ownerArchived?: boolean;
|
|
1142
1147
|
/** The session that created the project - the Boss's own conversation, which may register the
|
|
1143
1148
|
* top-level tasks and is the one the project answers to. */
|
|
1144
1149
|
initiatorConversationId?: string;
|
|
@@ -1172,6 +1177,7 @@ export type Project = {
|
|
|
1172
1177
|
tokens: number;
|
|
1173
1178
|
usageKnown: boolean;
|
|
1174
1179
|
activeWorkers: number;
|
|
1180
|
+
ownerCwd?: string;
|
|
1175
1181
|
memoryTreeId?: string;
|
|
1176
1182
|
usage?: {
|
|
1177
1183
|
input: number;
|
|
@@ -1264,6 +1270,17 @@ export type AppState = {
|
|
|
1264
1270
|
cwd?: string;
|
|
1265
1271
|
savedAt: string;
|
|
1266
1272
|
}>;
|
|
1273
|
+
/**
|
|
1274
|
+
* 每个会话背着几条「用户还没拍板的决策」,by conversation id.
|
|
1275
|
+
*
|
|
1276
|
+
* 项目本身不上广播(`clientState` 把 projects 摘掉了),但归档提醒需要知道:**归档这棵会话树
|
|
1277
|
+
* 会作废几条决策**。这个数由服务端算 —— 判据在 `src/shared/archive-decisions.ts`,两边共用 ——
|
|
1278
|
+
* 客户端只负责把树里的会话加起来,然后写进那一次确认框。
|
|
1279
|
+
*
|
|
1280
|
+
* 键是**负责人会话**:一个项目上的未决决策记在它的负责人名下,因为那个会话就是项目的领导。
|
|
1281
|
+
* 没有这个数,客户端就只能对用户说「可能会作废一些东西」,而不是「还有 3 个」。
|
|
1282
|
+
*/
|
|
1283
|
+
pendingUserDecisionsByConversation?: Record<string, number>;
|
|
1267
1284
|
/**
|
|
1268
1285
|
* THE CLOCK THIS SERVER SCHEDULES BY. A scheduled task's 「每天 09:00」 is the SERVER's wall clock,
|
|
1269
1286
|
* and the panel has to say so, because browser rendering 「下次」 may be on a different clock
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { type OverviewProject } from "./project-overview.js";
|
|
2
|
+
/**
|
|
3
|
+
* THE WORDS THE RECORD CARRIES WHEN AN ARCHIVE THROWS THE DECISION AWAY.
|
|
4
|
+
*
|
|
5
|
+
* 作废也是保留:例外**留在** `p.escalations` 里,原因、决定、决定时间都在,可查可导出;
|
|
6
|
+
* 改的只是**状态**。所以这句话要写得像人话,也要说清是谁干的 —— 是用户自己归档了会话,
|
|
7
|
+
* 决策才随之作废的。
|
|
8
|
+
*/
|
|
9
|
+
export declare const ARCHIVED_DECISION_REASON = "\u7528\u6237\u5F52\u6863\u4E86\u8D1F\u8D23\u4EBA\u4F1A\u8BDD\uFF0C\u672A\u62CD\u677F\u7684\u51B3\u7B56\u968F\u4E4B\u4F5C\u5E9F\u3002";
|
|
10
|
+
/**
|
|
11
|
+
* 每个会话背着几条未拍板的决策 —— 通过它负责的项目算。
|
|
12
|
+
*
|
|
13
|
+
* 一个项目可以有多条未决的用户级例外,它们都记在这个项目的**负责人会话**名下:那个会话是
|
|
14
|
+
* 项目的领导,决策是向它要来的,也是它这一摊的事。会话被归档,这个项目就没人管了。
|
|
15
|
+
*/
|
|
16
|
+
export declare function pendingUserDecisionsByOwner(projects: OverviewProject[]): Record<string, number>;
|
|
17
|
+
/**
|
|
18
|
+
* 这批会话被归档时,有几条未拍板的决策会跟着作废。
|
|
19
|
+
*
|
|
20
|
+
* 树里每一个会话都算:负责人会话在树里,它负责的项目上的未决决策就归零。
|
|
21
|
+
*/
|
|
22
|
+
export declare function pendingUserDecisionsForTree(counts: Record<string, number> | undefined, conversationIds: string[]): number;
|
|
23
|
+
/**
|
|
24
|
+
* THE DISMISSAL: archiving a leader session throws away the decisions that were waiting on it.
|
|
25
|
+
*
|
|
26
|
+
* 判据只有一条:**负责人会话在这次归档的会话树里** ⇒ 那个项目从此没人管 ⇒ 它欠用户的
|
|
27
|
+
* 未决决策作废。三件事不做:
|
|
28
|
+
*
|
|
29
|
+
* - **别的项目的例外不动。** 别人家的项目跟这次归档没关系。
|
|
30
|
+
* - **supervisor 级的不作废。** 那是团队内部的事,用户从来没被问过。
|
|
31
|
+
* - **记录不删。** 例外留在 `p.escalations` 里,`status` 变成 `dismissed`,`decision` 写下
|
|
32
|
+
* 为什么作废,`resolvedAt` 记下什么时候。作废是定性,不是消失。
|
|
33
|
+
*
|
|
34
|
+
* 返回的是同样长、同样的顺序的一份列表:**没被动过的项目是同一个对象**,动了的项目是新对象。
|
|
35
|
+
* 调用方靠这个比较就知道哪些要落盘。
|
|
36
|
+
*/
|
|
37
|
+
export declare function dismissArchivedOwnerDecisions<T extends OverviewProject>(projects: T[], archivedConversationIds: Iterable<string>, stamp: string, reason?: string): T[];
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
// 归档与未拍板的决策 —— 两边共用的判据。
|
|
2
|
+
//
|
|
3
|
+
// WHY THIS FILE EXISTS.
|
|
4
|
+
//
|
|
5
|
+
// 归档会牵动三件事,而它们数的是同一批例外:
|
|
6
|
+
//
|
|
7
|
+
// 1. 归档前告诉用户「还有 N 个未拍板的决策,归档后它们会作废」(客户端的确认框);
|
|
8
|
+
// 2. 归档后把那些决策作废(服务端;记录留下,状态改掉);
|
|
9
|
+
// 3. 决策作废之后,那个项目归到历史还是留在当前(服务端判视图,客户端照着判)。
|
|
10
|
+
//
|
|
11
|
+
// 三件事要是各写一遍判据,就会各写错一遍 —— 提醒说 3 条、作废掉 2 条、视图又按第 4 条算。
|
|
12
|
+
// 所以判据只写一次,两端都调它。
|
|
13
|
+
//
|
|
14
|
+
// 一条判据贯穿全篇:**未拍板的决策 = 用户的决定 = 项目上 status 为 open 的 boss 级例外**
|
|
15
|
+
// (没有 audience 的旧记录也算,那是当年的默认受众)。supervisor 级的是团队内部的事,不是
|
|
16
|
+
// 用户的待办,归档不碰它,视图也不为它留位置。
|
|
17
|
+
import { isOpenUserDecision, userProjectDecisions } from "./project-overview.js";
|
|
18
|
+
/**
|
|
19
|
+
* THE WORDS THE RECORD CARRIES WHEN AN ARCHIVE THROWS THE DECISION AWAY.
|
|
20
|
+
*
|
|
21
|
+
* 作废也是保留:例外**留在** `p.escalations` 里,原因、决定、决定时间都在,可查可导出;
|
|
22
|
+
* 改的只是**状态**。所以这句话要写得像人话,也要说清是谁干的 —— 是用户自己归档了会话,
|
|
23
|
+
* 决策才随之作废的。
|
|
24
|
+
*/
|
|
25
|
+
export const ARCHIVED_DECISION_REASON = "用户归档了负责人会话,未拍板的决策随之作废。";
|
|
26
|
+
/**
|
|
27
|
+
* 每个会话背着几条未拍板的决策 —— 通过它负责的项目算。
|
|
28
|
+
*
|
|
29
|
+
* 一个项目可以有多条未决的用户级例外,它们都记在这个项目的**负责人会话**名下:那个会话是
|
|
30
|
+
* 项目的领导,决策是向它要来的,也是它这一摊的事。会话被归档,这个项目就没人管了。
|
|
31
|
+
*/
|
|
32
|
+
export function pendingUserDecisionsByOwner(projects) {
|
|
33
|
+
const counts = {};
|
|
34
|
+
for (const project of projects) {
|
|
35
|
+
const owner = project.ownerConversationId;
|
|
36
|
+
if (!owner)
|
|
37
|
+
continue;
|
|
38
|
+
const open = userProjectDecisions(project).length;
|
|
39
|
+
if (!open)
|
|
40
|
+
continue;
|
|
41
|
+
counts[owner] = (counts[owner] ?? 0) + open;
|
|
42
|
+
}
|
|
43
|
+
return counts;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* 这批会话被归档时,有几条未拍板的决策会跟着作废。
|
|
47
|
+
*
|
|
48
|
+
* 树里每一个会话都算:负责人会话在树里,它负责的项目上的未决决策就归零。
|
|
49
|
+
*/
|
|
50
|
+
export function pendingUserDecisionsForTree(counts, conversationIds) {
|
|
51
|
+
if (!counts)
|
|
52
|
+
return 0;
|
|
53
|
+
let total = 0;
|
|
54
|
+
for (const id of conversationIds)
|
|
55
|
+
total += counts[id] ?? 0;
|
|
56
|
+
return total;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* THE DISMISSAL: archiving a leader session throws away the decisions that were waiting on it.
|
|
60
|
+
*
|
|
61
|
+
* 判据只有一条:**负责人会话在这次归档的会话树里** ⇒ 那个项目从此没人管 ⇒ 它欠用户的
|
|
62
|
+
* 未决决策作废。三件事不做:
|
|
63
|
+
*
|
|
64
|
+
* - **别的项目的例外不动。** 别人家的项目跟这次归档没关系。
|
|
65
|
+
* - **supervisor 级的不作废。** 那是团队内部的事,用户从来没被问过。
|
|
66
|
+
* - **记录不删。** 例外留在 `p.escalations` 里,`status` 变成 `dismissed`,`decision` 写下
|
|
67
|
+
* 为什么作废,`resolvedAt` 记下什么时候。作废是定性,不是消失。
|
|
68
|
+
*
|
|
69
|
+
* 返回的是同样长、同样的顺序的一份列表:**没被动过的项目是同一个对象**,动了的项目是新对象。
|
|
70
|
+
* 调用方靠这个比较就知道哪些要落盘。
|
|
71
|
+
*/
|
|
72
|
+
export function dismissArchivedOwnerDecisions(projects, archivedConversationIds, stamp, reason = ARCHIVED_DECISION_REASON) {
|
|
73
|
+
const archived = new Set(archivedConversationIds);
|
|
74
|
+
return projects.map(project => {
|
|
75
|
+
const owner = project.ownerConversationId;
|
|
76
|
+
if (!owner || !archived.has(owner))
|
|
77
|
+
return project;
|
|
78
|
+
const escalations = project.escalations ?? [];
|
|
79
|
+
if (!escalations.some(isOpenUserDecision))
|
|
80
|
+
return project;
|
|
81
|
+
const dismissed = escalations.map(item => isOpenUserDecision(item)
|
|
82
|
+
? { ...item, status: "dismissed", decision: reason, resolvedAt: stamp }
|
|
83
|
+
: item);
|
|
84
|
+
return { ...project, escalations: dismissed };
|
|
85
|
+
});
|
|
86
|
+
}
|