@evandu/super-pi 0.1.222 → 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/dist/client/.super-pi-client-sources.json +6 -5
- package/dist/client/assets/{CodeMirrorEditor-IWcAz6oz.js → CodeMirrorEditor-Due3YL4A.js} +2 -2
- package/dist/client/assets/{dist-Brmqe6G6.js → dist-1hXEE44f.js} +1 -1
- package/dist/client/assets/{dist-C-CsTWFq.js → dist-2kMlRtqo.js} +1 -1
- package/dist/client/assets/{dist-CLfjxR6r.js → dist-B2XX-bBx.js} +1 -1
- package/dist/client/assets/{dist-D73UQVEK.js → dist-B3qtMidG.js} +1 -1
- package/dist/client/assets/{dist-DftBUe3J.js → dist-BHlGN5Cp.js} +1 -1
- package/dist/client/assets/{dist-DgRXONWV.js → dist-BJ5mZEGq.js} +1 -1
- package/dist/client/assets/{dist-ChJliyoT.js → dist-BJ_pU8qp.js} +1 -1
- package/dist/client/assets/{dist-0tDquiIc.js → dist-BXTbngmK.js} +1 -1
- package/dist/client/assets/{dist-JFHBsRN8.js → dist-BZGq856v.js} +1 -1
- package/dist/client/assets/{dist-KddcFuL2.js → dist-BaUqm3zx.js} +1 -1
- package/dist/client/assets/{dist-ByhQMTZz.js → dist-BvUexO6W.js} +1 -1
- package/dist/client/assets/{dist-fzY9qpWd.js → dist-CA52X7jm.js} +1 -1
- package/dist/client/assets/{dist-B4YZqIKX.js → dist-CMws1R9h.js} +1 -1
- package/dist/client/assets/{dist-DglikBo1.js → dist-CQIMZ_7M.js} +1 -1
- package/dist/client/assets/{dist-B2WzMUqb.js → dist-CRrYz-2t.js} +1 -1
- package/dist/client/assets/{dist-DZFnjuKR.js → dist-Cw21UX77.js} +1 -1
- package/dist/client/assets/{dist-CRfBzL2s.js → dist-D2n9-vIx.js} +1 -1
- package/dist/client/assets/{dist-Cd2jBngi.js → dist-DCVXoyno.js} +1 -1
- package/dist/client/assets/{dist-BPhtg6ss.js → dist-DOJKt6Px.js} +1 -1
- package/dist/client/assets/{dist-B41_P-GB.js → dist-DSCSHwdP.js} +1 -1
- package/dist/client/assets/{dist-DR-NR2sl.js → dist-JSFnHR0P.js} +1 -1
- package/dist/client/assets/{dist-Bx-zvsek.js → dist-Po3GdueN.js} +1 -1
- package/dist/client/assets/{index-DbtNmSyS.js → index-DHdzZ1mf.js} +11 -11
- package/dist/client/index.html +1 -1
- 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/http-server.js +1 -1
- package/dist/server/store.js +7 -0
- 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/index.html
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
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-
|
|
11
|
+
<script type="module" crossorigin src="/assets/index-DHdzZ1mf.js"></script>
|
|
12
12
|
<link rel="stylesheet" crossorigin href="/assets/index-OmaD3l6r.css">
|
|
13
13
|
</head>
|
|
14
14
|
<body>
|
|
@@ -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);
|
|
@@ -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);
|
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
|
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
|
+
}
|
|
@@ -18,6 +18,11 @@ export type OverviewDecision = {
|
|
|
18
18
|
severity?: string;
|
|
19
19
|
requestedByConversationId?: string;
|
|
20
20
|
createdAt?: string;
|
|
21
|
+
/** What the case was answered with - the reader's own words, or the words the archive wrote on
|
|
22
|
+
* their behalf. Either way the record keeps it, because a decision nobody can read is a
|
|
23
|
+
* decision that never happened. */
|
|
24
|
+
decision?: string;
|
|
25
|
+
resolvedAt?: string;
|
|
21
26
|
};
|
|
22
27
|
export type OverviewProject = {
|
|
23
28
|
id: string;
|
|
@@ -37,6 +42,13 @@ export type OverviewProject = {
|
|
|
37
42
|
}[];
|
|
38
43
|
};
|
|
39
44
|
};
|
|
45
|
+
/**
|
|
46
|
+
* 一条例外是不是「用户还欠着一个决定」。
|
|
47
|
+
*
|
|
48
|
+
* 一条判据,全篇通用:`status` 是 open(还没结),受众是 boss(或者是没写 audience 的旧记录,
|
|
49
|
+
* 那是当年的默认受众)。supervisor 级的是团队内部的事,用户从来没被问过,所以不算。
|
|
50
|
+
*/
|
|
51
|
+
export declare function isOpenUserDecision(item: OverviewDecision): boolean;
|
|
40
52
|
/** Internal coordination is not a request for the user's attention. */
|
|
41
53
|
export declare function userProjectDecisions(project: OverviewProject): OverviewDecision[];
|
|
42
54
|
/**
|
|
@@ -51,6 +63,29 @@ export declare function projectsNeedingUserDecision(projects: OverviewProject[])
|
|
|
51
63
|
projects: number;
|
|
52
64
|
cases: number;
|
|
53
65
|
};
|
|
66
|
+
/**
|
|
67
|
+
* IS THIS PROJECT STILL THE READER'S BUSINESS?
|
|
68
|
+
*
|
|
69
|
+
* Two ways a project stops being the reader's business: it ENDED (cancelled or failed), or its
|
|
70
|
+
* OWNER SESSION WAS ARCHIVED - and a project whose owner sits in the archive has nobody left to
|
|
71
|
+
* run it. The second case is not a status: the record still says 「进行中」, but the session that
|
|
72
|
+
* was supposed to drive it is gone, so the panel cannot even offer 「让负责人继续」. A project
|
|
73
|
+
* like that is history with its records intact, not work in progress.
|
|
74
|
+
*
|
|
75
|
+
* A project that has NO owner yet is NOT over: it simply has not started, and the reader is the
|
|
76
|
+
* one who can start it. Only an owner that EXISTS and is archived makes a project unmanaged.
|
|
77
|
+
*/
|
|
78
|
+
export declare function projectIsOver(project: {
|
|
79
|
+
status?: string;
|
|
80
|
+
}, ownerArchived?: boolean): boolean;
|
|
81
|
+
/**
|
|
82
|
+
* WHICH VIEW A PROJECT BELONGS TO - the server decides, the client re-applies the same rule.
|
|
83
|
+
*
|
|
84
|
+
* The split is not 「ended / not ended」 - it is 「still owed something / nothing left to say」.
|
|
85
|
+
* A project that still owes the reader a decision stays in the current list, because hiding it
|
|
86
|
+
* would leave that decision with nobody. Everything else that is over goes to history.
|
|
87
|
+
*/
|
|
88
|
+
export declare function projectInView(project: OverviewProject, ownerArchived: boolean, view: "current" | "history"): boolean;
|
|
54
89
|
export declare function ownerProjectReports(project: OverviewProject): OverviewReport[];
|
|
55
90
|
export declare function latestProjectDelivery<T extends OverviewReport>(project: {
|
|
56
91
|
ownerConversationId?: string;
|
|
@@ -1,6 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 一条例外是不是「用户还欠着一个决定」。
|
|
3
|
+
*
|
|
4
|
+
* 一条判据,全篇通用:`status` 是 open(还没结),受众是 boss(或者是没写 audience 的旧记录,
|
|
5
|
+
* 那是当年的默认受众)。supervisor 级的是团队内部的事,用户从来没被问过,所以不算。
|
|
6
|
+
*/
|
|
7
|
+
export function isOpenUserDecision(item) {
|
|
8
|
+
return item.status === "open" && (item.audience === "boss" || item.audience === undefined);
|
|
9
|
+
}
|
|
1
10
|
/** Internal coordination is not a request for the user's attention. */
|
|
2
11
|
export function userProjectDecisions(project) {
|
|
3
|
-
return (project.escalations ?? []).filter(
|
|
12
|
+
return (project.escalations ?? []).filter(isOpenUserDecision);
|
|
4
13
|
}
|
|
5
14
|
/**
|
|
6
15
|
* HOW MANY PROJECTS NEED THE USER - counted by project, not by case.
|
|
@@ -17,6 +26,35 @@ export function projectsNeedingUserDecision(projects) {
|
|
|
17
26
|
cases: withCases.reduce((sum, project) => sum + userProjectDecisions(project).length, 0),
|
|
18
27
|
};
|
|
19
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
* IS THIS PROJECT STILL THE READER'S BUSINESS?
|
|
31
|
+
*
|
|
32
|
+
* Two ways a project stops being the reader's business: it ENDED (cancelled or failed), or its
|
|
33
|
+
* OWNER SESSION WAS ARCHIVED - and a project whose owner sits in the archive has nobody left to
|
|
34
|
+
* run it. The second case is not a status: the record still says 「进行中」, but the session that
|
|
35
|
+
* was supposed to drive it is gone, so the panel cannot even offer 「让负责人继续」. A project
|
|
36
|
+
* like that is history with its records intact, not work in progress.
|
|
37
|
+
*
|
|
38
|
+
* A project that has NO owner yet is NOT over: it simply has not started, and the reader is the
|
|
39
|
+
* one who can start it. Only an owner that EXISTS and is archived makes a project unmanaged.
|
|
40
|
+
*/
|
|
41
|
+
export function projectIsOver(project, ownerArchived = false) {
|
|
42
|
+
if (["cancelled", "failed"].includes(project.status ?? ""))
|
|
43
|
+
return true;
|
|
44
|
+
return ownerArchived;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* WHICH VIEW A PROJECT BELONGS TO - the server decides, the client re-applies the same rule.
|
|
48
|
+
*
|
|
49
|
+
* The split is not 「ended / not ended」 - it is 「still owed something / nothing left to say」.
|
|
50
|
+
* A project that still owes the reader a decision stays in the current list, because hiding it
|
|
51
|
+
* would leave that decision with nobody. Everything else that is over goes to history.
|
|
52
|
+
*/
|
|
53
|
+
export function projectInView(project, ownerArchived, view) {
|
|
54
|
+
const over = projectIsOver(project, ownerArchived);
|
|
55
|
+
const owesTheReader = userProjectDecisions(project).length > 0;
|
|
56
|
+
return view === "history" ? over && !owesTheReader : !over || owesTheReader;
|
|
57
|
+
}
|
|
20
58
|
export function ownerProjectReports(project) {
|
|
21
59
|
return (project.reports ?? []).filter(report => !report.taskId && ["progress", "delivery"].includes(report.kind ?? "")
|
|
22
60
|
&& (report.authorConversationId === project.ownerConversationId && Boolean(project.ownerConversationId)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@evandu/super-pi",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.223",
|
|
4
4
|
"description": "Web control plane and companion for Pi",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -46,6 +46,8 @@
|
|
|
46
46
|
"scripts/markdown-syntax.test.mjs",
|
|
47
47
|
"scripts/file-mentions.test.mjs",
|
|
48
48
|
"scripts/sidebar-refresh.test.mjs",
|
|
49
|
+
"scripts/sidebar-project-leak.test.mjs",
|
|
50
|
+
"scripts/archive-drops-decisions.test.mjs",
|
|
49
51
|
"scripts/provider-network.test.mjs",
|
|
50
52
|
"scripts/project-overview.test.mjs",
|
|
51
53
|
"scripts/team-handoff-view.test.mjs",
|