@evandu/super-pi 0.1.183 → 0.1.184

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.
Files changed (32) hide show
  1. package/dist/client/.super-pi-client-sources.json +6 -6
  2. package/dist/client/assets/{CodeMirrorEditor-DUyqaSOB.js → CodeMirrorEditor-v8j7qM-5.js} +2 -2
  3. package/dist/client/assets/{dist-nbHIDjzw.js → dist-1PSYOzSn.js} +1 -1
  4. package/dist/client/assets/{dist-Dnx8LlEL.js → dist-BKj3_VBI.js} +1 -1
  5. package/dist/client/assets/{dist-ka17rnWs.js → dist-BS72C5ep.js} +1 -1
  6. package/dist/client/assets/{dist-DLOUy-hB.js → dist-BUHFKfEO.js} +1 -1
  7. package/dist/client/assets/{dist-CeU4Svbh.js → dist-Bc6s4uHe.js} +1 -1
  8. package/dist/client/assets/{dist-NLNoAzKl.js → dist-Bcw21qWX.js} +1 -1
  9. package/dist/client/assets/{dist-DTd2PCza.js → dist-BoSFlin7.js} +1 -1
  10. package/dist/client/assets/{dist-C7PhA7pe.js → dist-Bpfwpwk8.js} +1 -1
  11. package/dist/client/assets/{dist-CU8JEI5K.js → dist-BtRpNdOI.js} +1 -1
  12. package/dist/client/assets/{dist-CkTZUfAR.js → dist-Bta_JEiJ.js} +1 -1
  13. package/dist/client/assets/{dist-D3HMZhM-.js → dist-Bvl-DsMt.js} +1 -1
  14. package/dist/client/assets/{dist-D4lWO1EF.js → dist-CIxW4sg_.js} +1 -1
  15. package/dist/client/assets/{dist-CvLzvDh7.js → dist-CJ4rSQ4N.js} +1 -1
  16. package/dist/client/assets/{dist-dnyR0Vf6.js → dist-CPEKtCMg.js} +1 -1
  17. package/dist/client/assets/{dist-Dlg4MpdE.js → dist-CvM_6f5G.js} +1 -1
  18. package/dist/client/assets/{dist-CNem2r_T.js → dist-D-MqsRQM.js} +1 -1
  19. package/dist/client/assets/{dist-TX6Uhfee.js → dist-D4SHQTo9.js} +1 -1
  20. package/dist/client/assets/{dist-Dkm31GRe.js → dist-DF3hHXYK.js} +1 -1
  21. package/dist/client/assets/{dist-CPmDYAQT.js → dist-DFpSLAtp.js} +1 -1
  22. package/dist/client/assets/{dist-Bj218gfa.js → dist-DsUX6SY5.js} +1 -1
  23. package/dist/client/assets/{dist-CB124C6Z.js → dist-XrYkL2Xu.js} +1 -1
  24. package/dist/client/assets/{dist-AQ8CYp6b.js → dist-cgEoGcO1.js} +1 -1
  25. package/dist/client/assets/{index-BplDWdZp.js → index-D_XU8eXm.js} +10 -10
  26. package/dist/client/assets/{index-Ui6aXMVV.css → index-DeTEc54b.css} +1 -1
  27. package/dist/client/index.html +2 -2
  28. package/dist/server/application/project-service.js +69 -13
  29. package/dist/server/types.d.ts +7 -0
  30. package/dist/shared/session-reporting.d.ts +11 -2
  31. package/dist/shared/session-reporting.js +60 -13
  32. package/package.json +2 -1
@@ -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-BplDWdZp.js"></script>
12
- <link rel="stylesheet" crossorigin href="/assets/index-Ui6aXMVV.css">
11
+ <script type="module" crossorigin src="/assets/index-D_XU8eXm.js"></script>
12
+ <link rel="stylesheet" crossorigin href="/assets/index-DeTEc54b.css">
13
13
  </head>
14
14
  <body>
15
15
  <div id="root"></div>
@@ -1,4 +1,5 @@
1
1
  import { randomUUID } from "node:crypto";
2
+ import { deriveReportingState, deriveSessionState, sessionStateWord, } from "../../shared/session-reporting.js";
2
3
  const stamp = () => new Date().toISOString();
3
4
  /**
4
5
  * WHAT THE PROJECT LEADER IS TOLD WHEN IT STARTS.
@@ -808,6 +809,20 @@ export class ProjectService {
808
809
  from the task row - the row says 「已中断」 and the card says 「执行中」, and the reader has
809
810
  no way to tell which one to believe. */
810
811
  const hasInterruptedTask = p.tasks.some((t) => t.status === "interrupted");
812
+ const openRequesters = new Set((p.escalations ?? [])
813
+ .filter((e) => e.status === "open" && e.requestedByConversationId)
814
+ .map((e) => e.requestedByConversationId));
815
+ const memberIds = new Set([
816
+ p.ownerConversationId,
817
+ ...p.tasks.flatMap((t) => [t.ownerConversationId, t.reviewerConversationId]),
818
+ ...(p.escalations ?? []).map((e) => e.requestedByConversationId),
819
+ ].filter(Boolean));
820
+ for (const memberId of memberIds) {
821
+ const conv = this.store.conversation(memberId);
822
+ if (conv) {
823
+ conv.hasOpenEscalation = openRequesters.has(memberId);
824
+ }
825
+ }
811
826
  /* A PROJECT THAT HAS WORK REGISTERED BUT NO LEADER SESSION YET IS NOT RUNNING.
812
827
  "active" used to mean "there is at least one task", so a project whose tasks were only
813
828
  REGISTERED - nobody had started it, nobody was working on it - claimed on its card to be
@@ -848,19 +863,60 @@ export class ProjectService {
848
863
  * "project" by the same rule as everybody else - there is no special case for it. */
849
864
  const projectTreeId = p.ownerConversationId ? this.store.conversation(p.ownerConversationId)?.treeId : undefined;
850
865
  const memberConversations = state.conversations.filter((c) => c.workspaceId === p.workspaceId && members.has(c.id));
851
- const sessions = memberConversations.map((c) => ({
852
- id: c.id, title: c.title, status: c.status, tokens: tokens(c.usage), contextPercent: c.contextUsage?.percent,
853
- // THE TREE SKELETON. The client draws the agents of a project as a tree, and the only
854
- // thing that knows who spawned whom is the conversation's own parent link. It is sent
855
- // verbatim (including the undefined case, which means "this session has no parent in
856
- // this collection" - i.e. it is a root of the tree).
857
- parentConversationId: c.parentConversationId,
858
- // WHOSE MEMORY THIS SESSION WORKS FROM. The project's own tree is the one the leader
859
- // opened; anything else is a session that still shares the initiator's chat memory.
860
- memoryTreeId: c.treeId,
861
- memoryScope: projectTreeId && c.treeId === projectTreeId ? "project" : "shared",
862
- role: c.id === p.ownerConversationId ? "项目负责人" : coordinatorIds.has(c.id) ? "分支 Leader" : p.tasks.some((t) => t.reviewerConversationId === c.id) ? "独立复核" : "执行者",
863
- }));
866
+ const openEscalationRequesters = new Set((p.escalations ?? [])
867
+ .filter((e) => e.status === "open" && e.requestedByConversationId)
868
+ .map((e) => e.requestedByConversationId));
869
+ const snapshotMap = new Map();
870
+ for (const c of memberConversations) {
871
+ snapshotMap.set(c.id, {
872
+ id: c.id,
873
+ parentConversationId: c.parentConversationId,
874
+ status: c.status,
875
+ reportedToParentAt: c.reportedToParentAt,
876
+ archivedAt: c.archivedAt,
877
+ hasOpenEscalation: openEscalationRequesters.has(c.id),
878
+ });
879
+ }
880
+ const sessions = memberConversations.map((c) => {
881
+ const parent = c.parentConversationId ? this.store.conversation(c.parentConversationId) : undefined;
882
+ const directChildren = memberConversations
883
+ .filter((child) => child.parentConversationId === c.id)
884
+ .map((child) => snapshotMap.get(child.id));
885
+ const snapshot = snapshotMap.get(c.id);
886
+ const reportingState = deriveReportingState({
887
+ conversation: snapshot,
888
+ parent,
889
+ directChildren,
890
+ isTopLevelUnread: false,
891
+ });
892
+ const displayStatus = deriveSessionState({
893
+ status: c.status,
894
+ reportingState,
895
+ });
896
+ const displayWord = sessionStateWord(displayStatus);
897
+ return {
898
+ id: c.id,
899
+ title: c.title,
900
+ status: c.status,
901
+ displayStatus,
902
+ displayWord,
903
+ reportingState,
904
+ hasOpenEscalation: snapshot.hasOpenEscalation,
905
+ reportedToParentAt: c.reportedToParentAt,
906
+ tokens: tokens(c.usage),
907
+ contextPercent: c.contextUsage?.percent,
908
+ // THE TREE SKELETON. The client draws the agents of a project as a tree, and the only
909
+ // thing that knows who spawned whom is the conversation's own parent link. It is sent
910
+ // verbatim (including the undefined case, which means "this session has no parent in
911
+ // this collection" - i.e. it is a root of the tree).
912
+ parentConversationId: c.parentConversationId,
913
+ // WHOSE MEMORY THIS SESSION WORKS FROM. The project's own tree is the one the leader
914
+ // opened; anything else is a session that still shares the initiator's chat memory.
915
+ memoryTreeId: c.treeId,
916
+ memoryScope: projectTreeId && c.treeId === projectTreeId ? "project" : "shared",
917
+ role: c.id === p.ownerConversationId ? "项目负责人" : coordinatorIds.has(c.id) ? "分支 Leader" : p.tasks.some((t) => t.reviewerConversationId === c.id) ? "独立复核" : "执行者",
918
+ };
919
+ });
864
920
  const runs = state.subagentRuns.filter((r) => members.has(r.conversationId));
865
921
  /* A COORDINATOR IS NOT A WORKER - EXCEPT IN A LIGHTWEIGHT PROJECT, WHERE THE LEADER IS THE
866
922
  WORKER. There the leader session does the work itself, so a project that is running must not
@@ -565,6 +565,8 @@ export type Conversation = {
565
565
  * 只要本字段存在,子会话就在汇报轴上算「已汇报」。
566
566
  */
567
567
  reportedToParentAt?: string;
568
+ /** 该会话是否存在未决的例外升级(等待上级处理)。 */
569
+ hasOpenEscalation?: boolean;
568
570
  /**
569
571
  * 用户上次点击阅读该会话的时间戳(ISO 字符串)。
570
572
  * 顶层会话退回到根据这个判断未读;子会话不看这个。
@@ -1141,6 +1143,11 @@ export type Project = {
1141
1143
  title: string;
1142
1144
  role: string;
1143
1145
  status: RunStatus;
1146
+ displayStatus?: string;
1147
+ displayWord?: string;
1148
+ reportingState?: string | null;
1149
+ hasOpenEscalation?: boolean;
1150
+ reportedToParentAt?: string;
1144
1151
  tokens: number;
1145
1152
  contextPercent?: number | null;
1146
1153
  parentConversationId?: string;
@@ -5,11 +5,20 @@ export type SessionReportingSnapshot = {
5
5
  status?: string;
6
6
  reportedToParentAt?: string;
7
7
  archivedAt?: string;
8
+ hasOpenEscalation?: boolean;
8
9
  };
9
- export type ReportingAxisState = "pending_report" | "awaiting_subordinates" | "unread";
10
+ export type ReportingAxisState = "pending_report" | "awaiting_subordinates" | "awaiting_decision" | "unread";
10
11
  export declare function deriveReportingState(params: {
11
12
  conversation: SessionReportingSnapshot;
12
13
  parent?: ChildSessionRow;
13
14
  directChildren: SessionReportingSnapshot[];
14
- isTopLevelUnread: boolean;
15
+ isTopLevelUnread?: boolean;
15
16
  }): ReportingAxisState | null;
17
+ export type SessionDisplayState = "waiting" | "running" | "failed" | "question" | "completed" | "unread" | "idle" | "awaiting_background" | "pending_report" | "awaiting_subordinates" | "awaiting_decision";
18
+ export declare const SESSION_STATE_WORD: Record<string, string>;
19
+ export declare function sessionStateWord(state: string | undefined): string;
20
+ export declare function deriveSessionState(params: {
21
+ status?: string;
22
+ reportingState?: ReportingAxisState | null;
23
+ awaitingQuestion?: boolean;
24
+ }): SessionDisplayState;
@@ -1,24 +1,20 @@
1
1
  // 会话状态模型:汇报线上的位置 —— 两边共用的推导逻辑与类型。
2
2
  //
3
3
  // 状态在回答什么问题:
4
- // - 子会话:有没有向上汇报?没有就是待汇报(pending_report),报过了就消停了(null)。
4
+ // - 自己有升级例外:等上面拍板(awaiting_decision)。
5
5
  // - 父会话:下级是不是都在消停状态?不是就是等待下级(awaiting_subordinates)。
6
+ // - 子会话:有没有向上汇报?没有就是待汇报(pending_report),报过了就消停了(null)。
6
7
  // - 顶层会话:自己有没有未读?有就是未读(unread)。
7
8
  //
8
9
  // 规则在 `docs/DESIGN-PRINCIPLES.md` 第二节「汇报线逐级转述:Boss 只有一个联络线」。
9
10
  import { isChildSession } from "./child-session-lock.js";
10
11
  export function deriveReportingState(params) {
11
- const { conversation, parent, directChildren, isTopLevelUnread } = params;
12
- // 1. 如果自己是子会话(按 isChildSession 判据,父会话存在且未归档)
13
- if (isChildSession(conversation.parentConversationId, parent)) {
14
- // 还没汇报过 -> 待汇报
15
- if (!conversation.reportedToParentAt) {
16
- return "pending_report";
17
- }
18
- // 已经汇报过 -> 在汇报轴上完成,不显示任何汇报标记
19
- return null;
12
+ const { conversation, parent, directChildren, isTopLevelUnread = false } = params;
13
+ // 1. 如果自己有未决的升级例外:等上面拍板
14
+ if (conversation.hasOpenEscalation) {
15
+ return "awaiting_decision";
20
16
  }
21
- // 2. 如果自己有未结束或未汇报的直接子会话
17
+ // 2. 如果自己有未结束、未汇报或未决升级的直接子会话:等待下级
22
18
  const hasPendingChild = directChildren.some((child) => {
23
19
  if (child.archivedAt)
24
20
  return false;
@@ -26,14 +22,65 @@ export function deriveReportingState(params) {
26
22
  child.status === "waiting" ||
27
23
  child.status === "awaiting_background";
28
24
  const hasNotReported = !child.reportedToParentAt;
29
- return isRunning || hasNotReported;
25
+ const hasEscalation = Boolean(child.hasOpenEscalation);
26
+ return isRunning || hasNotReported || hasEscalation;
30
27
  });
31
28
  if (hasPendingChild) {
32
29
  return "awaiting_subordinates";
33
30
  }
34
- // 3. 顶层会话退回到原有的「未读」逻辑
31
+ // 3. 如果自己是子会话(按 isChildSession 判据,父会话存在且未归档)
32
+ if (isChildSession(conversation.parentConversationId, parent)) {
33
+ // 还没汇报过 -> 待汇报
34
+ if (!conversation.reportedToParentAt) {
35
+ return "pending_report";
36
+ }
37
+ // 已经汇报过 -> 在汇报轴上完成,不显示任何汇报标记
38
+ return null;
39
+ }
40
+ // 4. 顶层会话退回到原有的「未读」逻辑
35
41
  if (isTopLevelUnread) {
36
42
  return "unread";
37
43
  }
38
44
  return null;
39
45
  }
46
+ export const SESSION_STATE_WORD = {
47
+ waiting: "等待 LLM",
48
+ running: "进行中",
49
+ failed: "出错",
50
+ question: "等你回答",
51
+ completed: "已完成",
52
+ unread: "有未读",
53
+ idle: "空闲",
54
+ awaiting_background: "等待后台任务",
55
+ pending_report: "待汇报",
56
+ awaiting_subordinates: "等待下级",
57
+ awaiting_decision: "等上面拍板",
58
+ };
59
+ export function sessionStateWord(state) {
60
+ return SESSION_STATE_WORD[state ?? ""] ?? state ?? "未知状态";
61
+ }
62
+ export function deriveSessionState(params) {
63
+ const { status, reportingState, awaitingQuestion } = params;
64
+ if (awaitingQuestion)
65
+ return "question";
66
+ if (status === "failed")
67
+ return "failed";
68
+ if (reportingState === "awaiting_decision")
69
+ return "awaiting_decision";
70
+ if (status === "waiting")
71
+ return "waiting";
72
+ if (status === "running")
73
+ return "running";
74
+ if (status === "awaiting_background")
75
+ return "awaiting_background";
76
+ if (reportingState === "pending_report")
77
+ return "pending_report";
78
+ if (reportingState === "awaiting_subordinates")
79
+ return "awaiting_subordinates";
80
+ if (reportingState === "unread") {
81
+ if (status === "completed")
82
+ return "completed";
83
+ return "unread";
84
+ }
85
+ return status === "completed" ? "completed" : "idle";
86
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@evandu/super-pi",
3
- "version": "0.1.183",
3
+ "version": "0.1.184",
4
4
  "description": "Web control plane and companion for Pi",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -260,6 +260,7 @@
260
260
  "scripts/child-session-lock.test.mjs",
261
261
  "scripts/child-question-lock.test.mjs",
262
262
  "scripts/session-reporting.test.mjs",
263
+ "scripts/project-panel-reporting.test.mjs",
263
264
  "scripts/mutation-lock-coverage.test.mjs"
264
265
  ],
265
266
  "check:browser": [