@evandu/super-pi 0.1.167 → 0.1.169
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 +1 -1
- package/dist/client/.super-pi-client-sources.json +4 -4
- package/dist/client/assets/{CodeMirrorEditor-CVWde5kc.js → CodeMirrorEditor-DArgTlD3.js} +2 -2
- package/dist/client/assets/{dist-BmMZE70t.js → dist-B-z8liQC.js} +1 -1
- package/dist/client/assets/{dist-BmTCWOAf.js → dist-BFaPEuXW.js} +1 -1
- package/dist/client/assets/{dist-DInnP2s9.js → dist-BrRu0IXM.js} +1 -1
- package/dist/client/assets/{dist-Dn-GoU5Q.js → dist-C898Y-mu.js} +1 -1
- package/dist/client/assets/{dist-CH83_wek.js → dist-CUbflO-e.js} +1 -1
- package/dist/client/assets/{dist-C5vtfmg_.js → dist-ChtaZGr2.js} +1 -1
- package/dist/client/assets/{dist-D7VBYFBQ.js → dist-CvSvjAn3.js} +1 -1
- package/dist/client/assets/{dist-DUgYAI4d.js → dist-D3E66dY7.js} +1 -1
- package/dist/client/assets/{dist-RLM_LWKf.js → dist-DKB8S6yA.js} +1 -1
- package/dist/client/assets/{dist-DOYAWZox.js → dist-DN-9z_cD.js} +1 -1
- package/dist/client/assets/{dist-BNHp4wy-.js → dist-DN_OOAtP.js} +1 -1
- package/dist/client/assets/{dist-DaEO5rUQ.js → dist-DUQ9n5h9.js} +1 -1
- package/dist/client/assets/{dist-DTOebxDL.js → dist-D_aMYdFI.js} +1 -1
- package/dist/client/assets/{dist-CC90sIpG.js → dist-DhpsFeLh.js} +1 -1
- package/dist/client/assets/{dist-C44HyASP.js → dist-DvtXvGUC.js} +1 -1
- package/dist/client/assets/{dist-FPYonm2j.js → dist-DyVwIwcR.js} +1 -1
- package/dist/client/assets/{dist-4fGafgy-.js → dist-EyFCbD4n.js} +1 -1
- package/dist/client/assets/{dist-DQ97Hq65.js → dist-HsjzJlZ8.js} +1 -1
- package/dist/client/assets/{dist-CYucB1mz.js → dist-J2qLs06H.js} +1 -1
- package/dist/client/assets/{dist-GZFbu49l.js → dist-NDu6lgDA.js} +1 -1
- package/dist/client/assets/{dist-BHFNgK-o.js → dist-maPYW6Rs.js} +1 -1
- package/dist/client/assets/{dist-BCl45PhR.js → dist-t2Ar76ug.js} +1 -1
- package/dist/client/assets/{index-DWjVnvsQ.css → index-bxZsZR4M.css} +1 -1
- package/dist/client/assets/{index-BptmWfVR.js → index-mr3cD5bb.js} +10 -10
- package/dist/client/index.html +2 -2
- package/dist/server/agents.d.ts +18 -0
- package/dist/server/agents.js +29 -0
- package/dist/server/application/project-service.d.ts +47 -3
- package/dist/server/application/project-service.js +119 -10
- package/dist/server/index.js +13 -2
- package/dist/server/types.d.ts +6 -2
- package/package.json +8 -2
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-mr3cD5bb.js"></script>
|
|
12
|
+
<link rel="stylesheet" crossorigin href="/assets/index-bxZsZR4M.css">
|
|
13
13
|
</head>
|
|
14
14
|
<body>
|
|
15
15
|
<div id="root"></div>
|
package/dist/server/agents.d.ts
CHANGED
|
@@ -199,6 +199,24 @@ export declare function readAgents(directory: string | readonly string[], option
|
|
|
199
199
|
mode?: AgentModeFilter;
|
|
200
200
|
builtinDir?: string;
|
|
201
201
|
}): Promise<AgentScan>;
|
|
202
|
+
/**
|
|
203
|
+
* WHAT KIND OF AGENT IS THIS ID?
|
|
204
|
+
*
|
|
205
|
+
* The catalogue is read in halves - the primaries and the subagents - and a question about ONE id
|
|
206
|
+
* has to be asked of both halves. The answer is the `mode:` frontmatter of the definition that
|
|
207
|
+
* WINS, which is the same override rule `readAgents` already applies: the first directory to offer
|
|
208
|
+
* an id owns it.
|
|
209
|
+
*
|
|
210
|
+
* `undefined` MEANS "NO SUCH AGENT IN THESE DIRECTORIES", and that is NOT the same as "not
|
|
211
|
+
* primary". An id nobody has heard of is a CUSTOM agent, and custom agents are legal - §3 keeps
|
|
212
|
+
* them legal on purpose, so that a project can name an agent the catalogue does not carry yet.
|
|
213
|
+
* Only an agent that EXISTS and is a subagent is a subagent.
|
|
214
|
+
*
|
|
215
|
+
* THE HIDDEN ONES COUNT. `hidden` decides whether a person is SHOWN an agent in a picker, not
|
|
216
|
+
* whether the agent exists, so a hidden subagent is still a subagent here. A guard that could be
|
|
217
|
+
* walked around by ticking one box in a frontmatter would not be a guard.
|
|
218
|
+
*/
|
|
219
|
+
export declare function agentModeOf(directories: string | readonly string[], agentId: string): Promise<"primary" | "subagent" | undefined>;
|
|
202
220
|
/** Parses one definition file, or returns the reason it is not a usable agent. */
|
|
203
221
|
export declare function parseDefinition(file: string, source: string): AgentDefinition | AgentProblem;
|
|
204
222
|
/**
|
package/dist/server/agents.js
CHANGED
|
@@ -545,6 +545,35 @@ export async function readAgents(directory, options = {}) {
|
|
|
545
545
|
problems,
|
|
546
546
|
};
|
|
547
547
|
}
|
|
548
|
+
/**
|
|
549
|
+
* WHAT KIND OF AGENT IS THIS ID?
|
|
550
|
+
*
|
|
551
|
+
* The catalogue is read in halves - the primaries and the subagents - and a question about ONE id
|
|
552
|
+
* has to be asked of both halves. The answer is the `mode:` frontmatter of the definition that
|
|
553
|
+
* WINS, which is the same override rule `readAgents` already applies: the first directory to offer
|
|
554
|
+
* an id owns it.
|
|
555
|
+
*
|
|
556
|
+
* `undefined` MEANS "NO SUCH AGENT IN THESE DIRECTORIES", and that is NOT the same as "not
|
|
557
|
+
* primary". An id nobody has heard of is a CUSTOM agent, and custom agents are legal - §3 keeps
|
|
558
|
+
* them legal on purpose, so that a project can name an agent the catalogue does not carry yet.
|
|
559
|
+
* Only an agent that EXISTS and is a subagent is a subagent.
|
|
560
|
+
*
|
|
561
|
+
* THE HIDDEN ONES COUNT. `hidden` decides whether a person is SHOWN an agent in a picker, not
|
|
562
|
+
* whether the agent exists, so a hidden subagent is still a subagent here. A guard that could be
|
|
563
|
+
* walked around by ticking one box in a frontmatter would not be a guard.
|
|
564
|
+
*/
|
|
565
|
+
export async function agentModeOf(directories, agentId) {
|
|
566
|
+
const id = agentId.trim();
|
|
567
|
+
if (!id)
|
|
568
|
+
return undefined;
|
|
569
|
+
const dirs = Array.isArray(directories) ? [...directories] : [directories];
|
|
570
|
+
for (const mode of ["subagent", "primary"]) {
|
|
571
|
+
const scan = await readAgents(dirs, { mode });
|
|
572
|
+
if (scan.agents.some((agent) => agent.id === id))
|
|
573
|
+
return mode;
|
|
574
|
+
}
|
|
575
|
+
return undefined;
|
|
576
|
+
}
|
|
548
577
|
/** Only `#rgb` and `#rrggbb`. A `color:` frontmatter value is rendered as a CSS background, so it has to
|
|
549
578
|
* be a colour and nothing else - accepting an arbitrary string would put author-controlled text into a
|
|
550
579
|
* style declaration. Anything else is dropped rather than sanitised into something misleading. */
|
|
@@ -80,12 +80,56 @@ export type BudgetRaiseResult = {
|
|
|
80
80
|
/** How many budget exceptions were closed by the raise. */
|
|
81
81
|
resolvedEscalations: number;
|
|
82
82
|
};
|
|
83
|
+
/**
|
|
84
|
+
* HOW THE SERVICE ASKS WHAT AN AGENT ID IS.
|
|
85
|
+
*
|
|
86
|
+
* The employee rule is a fact about the agent DIRECTORY, so the directory is read through the one
|
|
87
|
+
* reader the server already has (`readAgents`, through `agentModeOf`), and the question is asked of
|
|
88
|
+
* whoever owns those directories. The service deliberately does not know where the definitions
|
|
89
|
+
* live: the directories change when the user adds one, and a service that kept its own copy of the
|
|
90
|
+
* path would answer about a directory that is no longer there.
|
|
91
|
+
*
|
|
92
|
+
* `undefined` means "no such agent" - NOT "not primary". An id that is in no directory is a custom
|
|
93
|
+
* agent, and §3 keeps custom agents legal.
|
|
94
|
+
*/
|
|
95
|
+
export type AgentModeLookup = {
|
|
96
|
+
agentModeOf(agentId: string): Promise<"primary" | "subagent" | undefined>;
|
|
97
|
+
};
|
|
83
98
|
/** Persist explicit domain fields only; transport credentials never enter project records. */
|
|
84
99
|
export declare class ProjectService {
|
|
85
100
|
private readonly store;
|
|
86
101
|
private readonly orchestrator?;
|
|
102
|
+
/**
|
|
103
|
+
* Optional on purpose: a service built without an agent directory cannot tell a subagent from a
|
|
104
|
+
* custom agent, and it then behaves exactly as it did before this check existed. The real
|
|
105
|
+
* server always passes one.
|
|
106
|
+
*/
|
|
107
|
+
private readonly agents?;
|
|
87
108
|
private readonly queues;
|
|
88
|
-
constructor(store: Store, orchestrator?: (Pick<SessionOrchestratorService, "spawn" | "dispatch"> & Partial<Pick<SessionOrchestratorService, "stopSubtree">>) | undefined
|
|
109
|
+
constructor(store: Store, orchestrator?: (Pick<SessionOrchestratorService, "spawn" | "dispatch"> & Partial<Pick<SessionOrchestratorService, "stopSubtree">>) | undefined,
|
|
110
|
+
/**
|
|
111
|
+
* Optional on purpose: a service built without an agent directory cannot tell a subagent from a
|
|
112
|
+
* custom agent, and it then behaves exactly as it did before this check existed. The real
|
|
113
|
+
* server always passes one.
|
|
114
|
+
*/
|
|
115
|
+
agents?: AgentModeLookup | undefined);
|
|
116
|
+
/**
|
|
117
|
+
* A PROJECT EMPLOYEE MUST BE A PRIMARY AGENT.
|
|
118
|
+
*
|
|
119
|
+
* §1 says a subagent cannot be a project employee: a subagent is a tool-level, one-shot,
|
|
120
|
+
* invisible call, and a project that leans on one leans on a role the user can never see and
|
|
121
|
+
* never interrupt. The client only offers primary agents in the candidate list, but a candidate
|
|
122
|
+
* list is a SUGGESTION - the server is the constraint, and the refusal belongs at the moment the
|
|
123
|
+
* profile is written, while the reader is still looking at the form. Refusing later (when the
|
|
124
|
+
* task is dispatched) teaches the reader that the panel accepted something the project cannot
|
|
125
|
+
* use.
|
|
126
|
+
*
|
|
127
|
+
* WHAT IS REFUSED, AND WHAT IS NOT. An agent that EXISTS and is a subagent is refused, and the
|
|
128
|
+
* message names the slot and the agent, so the reader knows WHICH employee to change. An id that
|
|
129
|
+
* is in NO directory is a custom agent, and §3 keeps custom agents legal - so it is accepted here,
|
|
130
|
+
* exactly as it was before this check existed.
|
|
131
|
+
*/
|
|
132
|
+
private assertEmployee;
|
|
89
133
|
static taskView(task: ProjectTask, project: Pick<Project, "defaultExecutorProfile" | "defaultReviewerProfile">): ProjectTask;
|
|
90
134
|
private filterEscalations;
|
|
91
135
|
private projectView;
|
|
@@ -265,8 +309,8 @@ export declare class ProjectService {
|
|
|
265
309
|
*/
|
|
266
310
|
raiseBudgetAndContinue(id: string, workspaceId: string, callerConversationId?: string): Promise<BudgetRaiseResult>;
|
|
267
311
|
addReport(id: string, input: Omit<ProjectReport, "id" | "projectId" | "createdAt">, workspaceId?: string, actor?: string): Promise<ProjectReport>;
|
|
268
|
-
addEscalation(id: string, input: Pick<ProjectEscalation, "reason" | "severity" | "taskId">, workspaceId?: string, actor?: string): Promise<ProjectEscalation>;
|
|
269
|
-
resolveEscalation(id: string, escalationId: string, decision: string, status: "resolved" | "dismissed", workspaceId?: string, actor?: string): Promise<ProjectEscalation>;
|
|
312
|
+
addEscalation(id: string, input: Pick<ProjectEscalation, "reason" | "severity" | "taskId" | "title">, workspaceId?: string, actor?: string): Promise<ProjectEscalation>;
|
|
313
|
+
resolveEscalation(id: string, escalationId: string, decision: string, status: "resolved" | "dismissed" | "returned", workspaceId?: string, actor?: string): Promise<ProjectEscalation>;
|
|
270
314
|
complete(id: string, summary: string, evidenceRefs: unknown, workspaceId: string, actor?: string): Promise<Project>;
|
|
271
315
|
/**
|
|
272
316
|
* The tasks an initiator hands over with create. A dependency names the TITLE of another task in
|
|
@@ -171,7 +171,7 @@ const EVENT_TEXT = {
|
|
|
171
171
|
budget: "预算变更", report: "进展汇报", escalated: "例外升级", decision: "决定",
|
|
172
172
|
completed: "项目完成", ready: "依赖就绪", unreachable: "转述对象不可达",
|
|
173
173
|
};
|
|
174
|
-
const ESCALATION_STATUS_TEXT = { open: "未决", resolved: "已解决", dismissed: "已忽略" };
|
|
174
|
+
const ESCALATION_STATUS_TEXT = { open: "未决", resolved: "已解决", dismissed: "已忽略", returned: "已退回补充材料" };
|
|
175
175
|
const SEVERITY_TEXT = { low: "低", medium: "中", high: "高" };
|
|
176
176
|
const REPORT_KIND_TEXT = {
|
|
177
177
|
progress: "进展", blocked: "阻塞", delivery: "交付", decision_request: "决策请求", review: "复核",
|
|
@@ -184,6 +184,33 @@ const cell = (value) => oneLine(value).replace(/\|/g, "\\|");
|
|
|
184
184
|
const truncate = (value, limit) => value.length > limit ? `${value.slice(0, limit)}…(已截断)` : value;
|
|
185
185
|
/** A timestamp a person can read at a glance, and a missing one that says so. */
|
|
186
186
|
const moment = (value) => value ? value.replace("T", " ").replace(/\.\d+Z$/, "") : "无";
|
|
187
|
+
/**
|
|
188
|
+
* THE FIRST SENTENCE OF A PROSE.
|
|
189
|
+
*
|
|
190
|
+
* The sentence boundary is where a Chinese reader's eye stops, so the first sentence is the part
|
|
191
|
+
* that can stand alone in a table cell. A case with no sentence mark at all is returned whole -
|
|
192
|
+
* there is nothing to cut it at, and cutting it anywhere else would be guessing.
|
|
193
|
+
*/
|
|
194
|
+
const firstSentence = (value) => {
|
|
195
|
+
const text = oneLine(value).trim();
|
|
196
|
+
const index = text.search(/[。!?!?]/);
|
|
197
|
+
if (index < 0)
|
|
198
|
+
return text;
|
|
199
|
+
return text.slice(0, index + 1).trim();
|
|
200
|
+
};
|
|
201
|
+
/**
|
|
202
|
+
* THE QUESTION AN EXCEPTION ASKS, in one line.
|
|
203
|
+
*
|
|
204
|
+
* The reader decides on the question, and the case for it is a paragraph - so the table carries
|
|
205
|
+
* the question and the paragraph goes below the table. An exception raised before the title
|
|
206
|
+
* existed falls back to the first sentence of its case, which is the closest thing it has.
|
|
207
|
+
*/
|
|
208
|
+
const exceptionTitle = (exception) => {
|
|
209
|
+
const title = exception.title?.trim();
|
|
210
|
+
if (title)
|
|
211
|
+
return oneLine(title);
|
|
212
|
+
return firstSentence(exception.reason ?? "") || "(未命名)";
|
|
213
|
+
};
|
|
187
214
|
/**
|
|
188
215
|
* THE TWO SHAPES A PROJECT CAN HAVE.
|
|
189
216
|
*
|
|
@@ -202,10 +229,43 @@ const lightweight = (p) => p.mode === "lightweight";
|
|
|
202
229
|
export class ProjectService {
|
|
203
230
|
store;
|
|
204
231
|
orchestrator;
|
|
232
|
+
agents;
|
|
205
233
|
queues = new Map();
|
|
206
|
-
constructor(store, orchestrator
|
|
234
|
+
constructor(store, orchestrator,
|
|
235
|
+
/**
|
|
236
|
+
* Optional on purpose: a service built without an agent directory cannot tell a subagent from a
|
|
237
|
+
* custom agent, and it then behaves exactly as it did before this check existed. The real
|
|
238
|
+
* server always passes one.
|
|
239
|
+
*/
|
|
240
|
+
agents) {
|
|
207
241
|
this.store = store;
|
|
208
242
|
this.orchestrator = orchestrator;
|
|
243
|
+
this.agents = agents;
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* A PROJECT EMPLOYEE MUST BE A PRIMARY AGENT.
|
|
247
|
+
*
|
|
248
|
+
* §1 says a subagent cannot be a project employee: a subagent is a tool-level, one-shot,
|
|
249
|
+
* invisible call, and a project that leans on one leans on a role the user can never see and
|
|
250
|
+
* never interrupt. The client only offers primary agents in the candidate list, but a candidate
|
|
251
|
+
* list is a SUGGESTION - the server is the constraint, and the refusal belongs at the moment the
|
|
252
|
+
* profile is written, while the reader is still looking at the form. Refusing later (when the
|
|
253
|
+
* task is dispatched) teaches the reader that the panel accepted something the project cannot
|
|
254
|
+
* use.
|
|
255
|
+
*
|
|
256
|
+
* WHAT IS REFUSED, AND WHAT IS NOT. An agent that EXISTS and is a subagent is refused, and the
|
|
257
|
+
* message names the slot and the agent, so the reader knows WHICH employee to change. An id that
|
|
258
|
+
* is in NO directory is a custom agent, and §3 keeps custom agents legal - so it is accepted here,
|
|
259
|
+
* exactly as it was before this check existed.
|
|
260
|
+
*/
|
|
261
|
+
async assertEmployee(profile, label) {
|
|
262
|
+
const agentId = profile?.agentId;
|
|
263
|
+
if (!agentId || !this.agents)
|
|
264
|
+
return;
|
|
265
|
+
const mode = await this.agents.agentModeOf(agentId);
|
|
266
|
+
if (mode === "subagent") {
|
|
267
|
+
throw new Error(`${label}.agentId 指向的是 subagent(${agentId}),项目员工必须是 primary:subagent 是一次性的工具级调用,用户在侧栏看不到它的中间步骤,也插不上话。`);
|
|
268
|
+
}
|
|
209
269
|
}
|
|
210
270
|
static taskView(task, project) {
|
|
211
271
|
const t = { ...task };
|
|
@@ -759,9 +819,25 @@ export class ProjectService {
|
|
|
759
819
|
if (!p.escalations.length)
|
|
760
820
|
lines.push("无");
|
|
761
821
|
else {
|
|
822
|
+
/* THE TABLE IS FOR COMPARING, so the cell is a TITLE - the question the reader decides on -
|
|
823
|
+
and the case goes under the table. A whole paragraph in one cell makes the table
|
|
824
|
+
unreadable, and a table that cannot be scanned is not a table any more. */
|
|
762
825
|
lines.push("| 例外 | 严重程度 | 状态 | 决定 | 解决时间 |", "| --- | --- | --- | --- | --- |");
|
|
763
826
|
for (const e of p.escalations) {
|
|
764
|
-
lines.push(`| ${cell(e
|
|
827
|
+
lines.push(`| ${cell(exceptionTitle(e))} | ${SEVERITY_TEXT[e.severity] ?? e.severity} | ${ESCALATION_STATUS_TEXT[e.status] ?? e.status} | ${cell(e.decision ?? "无")} | ${e.resolvedAt ? moment(e.resolvedAt) : "无"} |`);
|
|
828
|
+
}
|
|
829
|
+
/* AND THE CASE IS NOT LOST. The title is what the reader compares; the reason is WHY, and it
|
|
830
|
+
is a paragraph - so it is printed in full below the table, where a paragraph belongs. */
|
|
831
|
+
const cases = p.escalations.filter((e) => (e.reason ?? "").trim());
|
|
832
|
+
if (cases.length) {
|
|
833
|
+
lines.push("", "例外详情:", "");
|
|
834
|
+
for (const e of cases) {
|
|
835
|
+
/* AN EXCEPTION WITH A TITLE is named by it; one without has only its case, and the case
|
|
836
|
+
is already the whole line - repeating its first sentence in front of it would say the
|
|
837
|
+
same thing twice. */
|
|
838
|
+
const title = e.title?.trim();
|
|
839
|
+
lines.push(title ? `- ${oneLine(title)}:${oneLine(e.reason)}` : `- ${oneLine(e.reason)}`);
|
|
840
|
+
}
|
|
765
841
|
}
|
|
766
842
|
}
|
|
767
843
|
lines.push("", "## 时间线", "");
|
|
@@ -820,6 +896,12 @@ export class ProjectService {
|
|
|
820
896
|
const defaultLeaderProfile = profile(input.defaultLeaderProfile, "默认 Leader 配置");
|
|
821
897
|
const defaultExecutorProfile = profile(input.defaultExecutorProfile, "默认执行配置");
|
|
822
898
|
const defaultReviewerProfile = profile(input.defaultReviewerProfile, "默认复核配置");
|
|
899
|
+
// THE PROJECT'S OWN EMPLOYEE DEFAULTS ARE EMPLOYEES TOO. They are the profiles every task
|
|
900
|
+
// inherits when it names no one, so a subagent written here would become the employee of the
|
|
901
|
+
// whole project - and it would be refused at every task that inherited it, one by one, long
|
|
902
|
+
// after the person who wrote it had walked away.
|
|
903
|
+
await this.assertEmployee(defaultExecutorProfile, "defaultExecutorProfile");
|
|
904
|
+
await this.assertEmployee(defaultReviewerProfile, "defaultReviewerProfile");
|
|
823
905
|
const initiator = (initiatorConversationId ?? (typeof input.initiatorConversationId === "string" ? input.initiatorConversationId : undefined))?.trim() || undefined;
|
|
824
906
|
const now = stamp();
|
|
825
907
|
const p = { id: `project_${randomUUID()}`, workspaceId, title: text(input.title, "项目标题"), objective: text(input.objective, "项目目标"),
|
|
@@ -909,7 +991,7 @@ export class ProjectService {
|
|
|
909
991
|
});
|
|
910
992
|
}
|
|
911
993
|
async addTask(id, input, workspaceId, actor) {
|
|
912
|
-
return this.change(id, workspaceId, (p) => {
|
|
994
|
+
return this.change(id, workspaceId, async (p) => {
|
|
913
995
|
this.live(p);
|
|
914
996
|
const parentTaskId = optional(input.parentTaskId, "父任务 id");
|
|
915
997
|
// A LIGHTWEIGHT PROJECT HAS ONE SESSION, SO IT HAS NO TREE OF TASKS. Decomposing the work
|
|
@@ -961,6 +1043,11 @@ export class ProjectService {
|
|
|
961
1043
|
throw new Error("项目最多 100 个任务,请收敛分工范围");
|
|
962
1044
|
const executorProfile = profile(input.executorProfile, "执行配置");
|
|
963
1045
|
const reviewerProfile = profile(input.reviewerProfile, "复核配置");
|
|
1046
|
+
// THE EMPLOYEE IS CHECKED BEFORE THE TASK EXISTS. The refusal happens in the write itself,
|
|
1047
|
+
// so a project never carries a task whose employee is a subagent - not even for the moment
|
|
1048
|
+
// between the write and the next read.
|
|
1049
|
+
await this.assertEmployee(executorProfile, "executorProfile");
|
|
1050
|
+
await this.assertEmployee(reviewerProfile, "reviewerProfile");
|
|
964
1051
|
const now = stamp();
|
|
965
1052
|
const t = { id: `task_${randomUUID()}`, projectId: id, title: text(input.title, "任务标题"), objective: text(input.objective, "任务目标"),
|
|
966
1053
|
status: dependencies.length ? "pending" : "ready", accountableConversationId: manager, parentTaskId, role: input.role ?? "executor", dependencies,
|
|
@@ -1126,7 +1213,7 @@ export class ProjectService {
|
|
|
1126
1213
|
});
|
|
1127
1214
|
}
|
|
1128
1215
|
async updateTask(id, taskId, patch, actor) {
|
|
1129
|
-
const result = await this.change(id, patch.workspaceId, (p) => {
|
|
1216
|
+
const result = await this.change(id, patch.workspaceId, async (p) => {
|
|
1130
1217
|
this.live(p);
|
|
1131
1218
|
const t = this.task(p, taskId);
|
|
1132
1219
|
this.member(p, actor);
|
|
@@ -1160,6 +1247,9 @@ export class ProjectService {
|
|
|
1160
1247
|
if (t.ownerConversationId)
|
|
1161
1248
|
throw new Error("执行会话已创建,禁止修改执行配置");
|
|
1162
1249
|
const ep = profile(patch.executorProfile, "执行配置");
|
|
1250
|
+
// THE CHECK COMES BEFORE THE ASSIGNMENT. The task keeps the employee it had; what it must
|
|
1251
|
+
// not do is end up holding an employee the project is not allowed to have.
|
|
1252
|
+
await this.assertEmployee(ep, "executorProfile");
|
|
1163
1253
|
if (ep)
|
|
1164
1254
|
t.executorProfile = ep;
|
|
1165
1255
|
else
|
|
@@ -1169,6 +1259,7 @@ export class ProjectService {
|
|
|
1169
1259
|
if (t.reviewerConversationId)
|
|
1170
1260
|
throw new Error("复核会话已创建,禁止修改复核配置");
|
|
1171
1261
|
const rp = profile(patch.reviewerProfile, "复核配置");
|
|
1262
|
+
await this.assertEmployee(rp, "reviewerProfile");
|
|
1172
1263
|
if (rp)
|
|
1173
1264
|
t.reviewerProfile = rp;
|
|
1174
1265
|
else
|
|
@@ -1374,7 +1465,7 @@ export class ProjectService {
|
|
|
1374
1465
|
if (actor && actor !== p.ownerConversationId && (!t || ![t.ownerConversationId, t.reviewerConversationId, this.manager(p, t)].includes(actor)))
|
|
1375
1466
|
throw new Error("仅可汇报本人负责的任务");
|
|
1376
1467
|
const report = { id: randomUUID(), projectId: id, taskId: t?.id, authorConversationId: actor, kind: input.kind,
|
|
1377
|
-
progress: text(input.progress, "汇报进展"), variance: optional(input.variance, "偏差"), nextStep: optional(input.nextStep, "下一步"), risks: strings(input.risks, "风险"),
|
|
1468
|
+
progress: text(input.progress, "汇报进展"), summary: typeof input.summary === "string" && input.summary.trim() ? text(input.summary, "汇报标题") : undefined, variance: optional(input.variance, "偏差"), nextStep: optional(input.nextStep, "下一步"), risks: strings(input.risks, "风险"),
|
|
1378
1469
|
decisionNeeded: optional(input.decisionNeeded, "所需决策"), evidenceRefs: strings(input.evidenceRefs, "证据"), createdAt: stamp() };
|
|
1379
1470
|
p.reports.push(report);
|
|
1380
1471
|
if (report.kind === "blocked") {
|
|
@@ -1438,6 +1529,10 @@ export class ProjectService {
|
|
|
1438
1529
|
projectId: id,
|
|
1439
1530
|
taskId: t?.id,
|
|
1440
1531
|
reason: text(input.reason, "升级原因"),
|
|
1532
|
+
/* THE QUESTION IS KEPT BESIDE THE CASE. The title is what the reader decides ON - one
|
|
1533
|
+
sentence, in the reader's terms - and the reason is the case for it. An escalation
|
|
1534
|
+
* without a title is still a valid escalation; it simply has to be read in full. */
|
|
1535
|
+
...(typeof input.title === "string" && input.title.trim() ? { title: text(input.title, "升级标题") } : {}),
|
|
1441
1536
|
severity: input.severity,
|
|
1442
1537
|
status: "open",
|
|
1443
1538
|
requestedByConversationId: actor,
|
|
@@ -1446,19 +1541,19 @@ export class ProjectService {
|
|
|
1446
1541
|
createdAt: stamp(),
|
|
1447
1542
|
};
|
|
1448
1543
|
p.escalations.push(e);
|
|
1449
|
-
this.event(p, "escalated", e.reason, t?.id, actor);
|
|
1544
|
+
this.event(p, "escalated", e.title ? `${e.title}:${e.reason}` : e.reason, t?.id, actor);
|
|
1450
1545
|
this.reconcile(p);
|
|
1451
1546
|
return e;
|
|
1452
1547
|
}, actor);
|
|
1453
1548
|
if (supervisorToWake) {
|
|
1454
|
-
await this.wake(supervisorToWake, `下级成员(会话:${actor},身份:${wakeMemberRole ?? "执行者"})发起例外升级(ID:${result.id}):\n原因:${result.reason}\n严重级别:${result.severity}\n请及时处理该例外(调用 project action="resolve_escalation" 记录处理意见),或按需向上级转述升级。`, `例外升级(ID:${result.id})`, id, workspaceId, actor);
|
|
1549
|
+
await this.wake(supervisorToWake, `下级成员(会话:${actor},身份:${wakeMemberRole ?? "执行者"})发起例外升级(ID:${result.id}):\n${result.title ? `待决问题:${result.title}\n` : ""}原因:${result.reason}\n严重级别:${result.severity}\n请及时处理该例外(调用 project action="resolve_escalation" 记录处理意见),或按需向上级转述升级。`, `例外升级(ID:${result.id})`, id, workspaceId, actor);
|
|
1455
1550
|
}
|
|
1456
1551
|
return result;
|
|
1457
1552
|
}
|
|
1458
1553
|
async resolveEscalation(id, escalationId, decision, status, workspaceId, actor) {
|
|
1459
1554
|
const result = await this.change(id, workspaceId, (p) => {
|
|
1460
1555
|
this.live(p);
|
|
1461
|
-
if (status !== "resolved" && status !== "dismissed")
|
|
1556
|
+
if (status !== "resolved" && status !== "dismissed" && status !== "returned")
|
|
1462
1557
|
throw new Error("升级处理状态不合法");
|
|
1463
1558
|
const e = p.escalations.find((e) => e.id === escalationId);
|
|
1464
1559
|
if (!e)
|
|
@@ -1481,10 +1576,24 @@ export class ProjectService {
|
|
|
1481
1576
|
e.decision = text(decision, "处理意见");
|
|
1482
1577
|
e.resolvedAt = stamp();
|
|
1483
1578
|
const decider = audience === "boss" ? "Boss" : "直接上级";
|
|
1484
|
-
|
|
1579
|
+
/* A RETURN IS NOT A DECISION. It says the case was not ready - the reader is being asked
|
|
1580
|
+
* for more material, not for a ruling - so the timeline says so in those words. */
|
|
1581
|
+
this.event(p, "decision", status === "returned"
|
|
1582
|
+
? `${decider}退回例外,等待补充材料:${e.decision}`
|
|
1583
|
+
: `${decider}决策:${e.decision}`, e.taskId, actor);
|
|
1485
1584
|
this.reconcile(p);
|
|
1486
1585
|
return e;
|
|
1487
1586
|
}, actor);
|
|
1587
|
+
/* THE CASE GOES BACK TO WHO RAISED IT. A returned escalation leaves the inbox without being
|
|
1588
|
+
* answered, so nobody would ever know it was still open - unless the person who raised it is
|
|
1589
|
+
* woken up and told to bring the missing material. This is the one wake that is NOT about a
|
|
1590
|
+
* decision: it is about work coming back. */
|
|
1591
|
+
if (status === "returned") {
|
|
1592
|
+
if (result.requestedByConversationId) {
|
|
1593
|
+
await this.wake(result.requestedByConversationId, `例外已退回,等待对方补充材料(ID:${result.id}):${result.title ?? result.reason}\n退回意见:${result.decision}\n请补充材料后重新发起升级。`, `例外已退回(ID:${result.id})`, id, workspaceId, actor);
|
|
1594
|
+
}
|
|
1595
|
+
return result;
|
|
1596
|
+
}
|
|
1488
1597
|
const p = this.raw(id, workspaceId);
|
|
1489
1598
|
if (result.audience === "supervisor") {
|
|
1490
1599
|
if (result.requestedByConversationId) {
|
package/dist/server/index.js
CHANGED
|
@@ -9,7 +9,7 @@ import { join, resolve } from "node:path";
|
|
|
9
9
|
import { pathToFileURL } from "node:url";
|
|
10
10
|
import { openStateStore } from "./persistence/open-state-store.js";
|
|
11
11
|
import { PiRpcRuntime, WelcomeRuntime } from "./runtime.js";
|
|
12
|
-
import { resolveAgentDirectories } from "./agents.js";
|
|
12
|
+
import { agentModeOf, resolveAgentDirectories } from "./agents.js";
|
|
13
13
|
import { releaseAllCapabilities } from "./capability.js";
|
|
14
14
|
import { SubagentSupervisor } from "./subagents.js";
|
|
15
15
|
import { SubagentRunRecorder } from "./subagent-runs.js";
|
|
@@ -297,7 +297,18 @@ runService.setExecService(execService);
|
|
|
297
297
|
const scheduledTaskService = new ScheduledTaskService(store, runService, conversationService, broadcaster);
|
|
298
298
|
const sessionLedger = new SessionLedger();
|
|
299
299
|
const sessionOrchestratorService = new SessionOrchestratorService(store, conversationService, runService, sessionLedger, broadcaster);
|
|
300
|
-
|
|
300
|
+
/**
|
|
301
|
+
* THE PROJECT SERVICE IS TOLD HOW TO ASK WHAT AN AGENT IS.
|
|
302
|
+
*
|
|
303
|
+
* The employee rule of §1 - "a subagent cannot be a project employee" - is a fact about the agent
|
|
304
|
+
* DIRECTORY, and the directory is read through the same reader the picker and the runtime use
|
|
305
|
+
* (`readAgents`, through `agentModeOf`). The directories are asked of the catalogue service
|
|
306
|
+
* because THEY are the live ones: the user can add an agents directory at any time, and a guard
|
|
307
|
+
* that read a path captured at startup would answer about a directory that is no longer there.
|
|
308
|
+
*/
|
|
309
|
+
const projectService = new ProjectService(store, sessionOrchestratorService, {
|
|
310
|
+
agentModeOf: (agentId) => agentModeOf(catalogService.getAgentDirs(), agentId),
|
|
311
|
+
});
|
|
301
312
|
void sessionOrchestratorService.restoreWatchdogs().catch((error) => {
|
|
302
313
|
console.warn("Super Pi: restoring watchdogs failed:", error instanceof Error ? error.message : String(error));
|
|
303
314
|
});
|
package/dist/server/types.d.ts
CHANGED
|
@@ -1011,6 +1011,7 @@ export type ProjectReport = {
|
|
|
1011
1011
|
authorConversationId?: string;
|
|
1012
1012
|
kind: "progress" | "blocked" | "delivery" | "decision_request" | "review";
|
|
1013
1013
|
progress: string;
|
|
1014
|
+
summary?: string;
|
|
1014
1015
|
variance?: string;
|
|
1015
1016
|
nextStep?: string;
|
|
1016
1017
|
risks?: string[];
|
|
@@ -1022,9 +1023,12 @@ export type ProjectEscalation = {
|
|
|
1022
1023
|
id: string;
|
|
1023
1024
|
projectId: string;
|
|
1024
1025
|
taskId?: string;
|
|
1025
|
-
reason: string;
|
|
1026
|
+
reason: string; /** THE QUESTION, IN ONE SENTENCE. What the Boss has to decide - as opposed to `reason`,
|
|
1027
|
+
* which is the case for it. The reader decides in a glance, and reads the case only if the
|
|
1028
|
+
* question is not obvious; an escalation without a title falls back to the reason. */
|
|
1029
|
+
title?: string;
|
|
1026
1030
|
severity: ProjectRisk;
|
|
1027
|
-
status: "open" | "resolved" | "dismissed";
|
|
1031
|
+
status: "open" | "resolved" | "dismissed" | "returned";
|
|
1028
1032
|
requestedByConversationId?: string;
|
|
1029
1033
|
decision?: string;
|
|
1030
1034
|
createdAt: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@evandu/super-pi",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.169",
|
|
4
4
|
"description": "Web control plane and companion for Pi",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -87,6 +87,7 @@
|
|
|
87
87
|
"scripts/session-result-callback-e2e.test.mjs",
|
|
88
88
|
"scripts/session-orchestrator-tools.test.mjs",
|
|
89
89
|
"scripts/project-service.test.mjs",
|
|
90
|
+
"scripts/project-report-exception-title.test.mjs",
|
|
90
91
|
"scripts/project-api-scope.test.mjs",
|
|
91
92
|
"scripts/project-report-chain.test.mjs",
|
|
92
93
|
"scripts/session-tree-collapse.test.mjs",
|
|
@@ -196,6 +197,7 @@
|
|
|
196
197
|
"scripts/session-state-icon.test.mjs",
|
|
197
198
|
"scripts/provider-fetch-models.test.mjs",
|
|
198
199
|
"scripts/shared-chrome.test.mjs",
|
|
200
|
+
"scripts/shared-chrome-recovery.test.mjs",
|
|
199
201
|
"scripts/prompt-templates.test.mjs",
|
|
200
202
|
"scripts/documents.test.mjs",
|
|
201
203
|
"scripts/web-tools.test.mjs",
|
|
@@ -232,7 +234,8 @@
|
|
|
232
234
|
"scripts/awaiting-background-status.test.mjs",
|
|
233
235
|
"scripts/project-lifecycle-e2e.test.mjs",
|
|
234
236
|
"scripts/agent-tiers.test.mjs",
|
|
235
|
-
"scripts/design-principles.test.mjs"
|
|
237
|
+
"scripts/design-principles.test.mjs",
|
|
238
|
+
"scripts/primary-employee-guard.test.mjs"
|
|
236
239
|
],
|
|
237
240
|
"check:browser": [
|
|
238
241
|
"scripts/interrupt-browser.test.mjs",
|
|
@@ -266,8 +269,11 @@
|
|
|
266
269
|
"scripts/workspace-identity-browser.test.mjs",
|
|
267
270
|
"scripts/sidebar-tools-browser.test.mjs",
|
|
268
271
|
"scripts/project-employee-panel-browser.test.mjs",
|
|
272
|
+
"scripts/primary-employee-guard-browser.test.mjs",
|
|
269
273
|
"scripts/project-evidence-panel-browser.test.mjs",
|
|
270
274
|
"scripts/project-panel-fixes-browser.test.mjs",
|
|
275
|
+
"scripts/boss-approval-readability-browser.test.mjs",
|
|
276
|
+
"scripts/prose-tidying-browser.test.mjs",
|
|
271
277
|
"scripts/builtin-agents-project-browser.test.mjs",
|
|
272
278
|
"scripts/tool-runtime-browser.test.mjs",
|
|
273
279
|
"scripts/session-context-menu-browser.test.mjs",
|