@evandu/super-pi 0.1.218 → 0.1.220
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/project-leader.md +1 -1
- package/agents/super-pi-task/core.ts +1 -1
- package/agents/super-pi-task/index.ts +4 -2
- package/dist/client/.super-pi-client-sources.json +6 -6
- package/dist/client/assets/{CodeMirrorEditor-CyESWKhO.js → CodeMirrorEditor-DLESYIdU.js} +2 -2
- package/dist/client/assets/{dist-xAE0Sxu_.js → dist-2Gv721yB.js} +1 -1
- package/dist/client/assets/{dist-CWLwzCNI.js → dist-B-63MNT9.js} +1 -1
- package/dist/client/assets/{dist-BQ5yUYGI.js → dist-B-ydE4PJ.js} +1 -1
- package/dist/client/assets/{dist-BfAB10-T.js → dist-B6UYFWUo.js} +1 -1
- package/dist/client/assets/{dist-GMozZ-IZ.js → dist-BG1xVEUu.js} +1 -1
- package/dist/client/assets/{dist-C6tiomV0.js → dist-BTUuXAFG.js} +1 -1
- package/dist/client/assets/{dist-Zl8KoipB.js → dist-Bz37bm03.js} +1 -1
- package/dist/client/assets/{dist-BwQiVXeZ.js → dist-CQAWuaHA.js} +1 -1
- package/dist/client/assets/{dist-XNj0UVAT.js → dist-CYEoLBJJ.js} +1 -1
- package/dist/client/assets/{dist-CkjmcyTq.js → dist-CbixgvA8.js} +1 -1
- package/dist/client/assets/{dist-DHh4-Br1.js → dist-CoC8iHD1.js} +1 -1
- package/dist/client/assets/{dist-DtyV497P.js → dist-CrtcsyOg.js} +1 -1
- package/dist/client/assets/{dist-BlALlifb.js → dist-D0Mff5_O.js} +1 -1
- package/dist/client/assets/{dist-BXMYNRiG.js → dist-DKRxalqK.js} +1 -1
- package/dist/client/assets/{dist-Cgclz1Km.js → dist-DPvgTEV_.js} +1 -1
- package/dist/client/assets/{dist-C9qNY2Kp.js → dist-DhCNXN4F.js} +1 -1
- package/dist/client/assets/{dist-BXq9HMCd.js → dist-DmraLEb2.js} +1 -1
- package/dist/client/assets/{dist-B33BwR-8.js → dist-DvJTvgiN.js} +1 -1
- package/dist/client/assets/{dist-C7y8W3IU.js → dist-YSB8UKj7.js} +1 -1
- package/dist/client/assets/{dist-1djw1Aua.js → dist-aDKso4tk.js} +1 -1
- package/dist/client/assets/{dist-DH6F4kKv.js → dist-h8QFV1py.js} +1 -1
- package/dist/client/assets/{dist-DZGY_CNU.js → dist-hyn4QSU9.js} +1 -1
- package/dist/client/assets/index-B-h_KnC5.css +1 -0
- package/dist/client/assets/{index-2k9h0zMt.js → index-BMuvJCSx.js} +11 -11
- package/dist/client/index.html +2 -2
- package/dist/server/application/conversation-service.d.ts +7 -2
- package/dist/server/application/conversation-service.js +45 -5
- package/dist/server/application/project-service.d.ts +53 -5
- package/dist/server/application/project-service.js +167 -36
- package/dist/server/application/run-service.d.ts +3 -1
- package/dist/server/application/run-service.js +22 -5
- package/dist/server/application/session-orchestrator-service.d.ts +65 -0
- package/dist/server/application/session-orchestrator-service.js +175 -22
- package/dist/server/application/session-reminder-service.js +1 -2
- package/dist/server/command-handler.d.ts +3 -1
- package/dist/server/command-handler.js +21 -1
- package/dist/server/index.js +2 -2
- package/dist/server/runtime.js +2 -2
- package/dist/server/store.d.ts +17 -4
- package/dist/server/store.js +93 -28
- package/dist/server/types.d.ts +24 -1
- package/dist/server/upload.d.ts +2 -0
- package/dist/server/upload.js +19 -2
- package/dist/shared/project-overview.d.ts +21 -0
- package/dist/shared/project-overview.js +36 -7
- package/dist/shared/project-presentation.d.ts +3 -0
- package/dist/shared/project-presentation.js +13 -5
- package/dist/shared/session-reporting.d.ts +32 -0
- package/dist/shared/session-reporting.js +29 -0
- package/dist/shared/team-context.d.ts +1 -1
- package/package.json +5 -1
- package/dist/client/assets/index-CwfAN5Vw.css +0 -1
|
@@ -1,5 +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
4
|
import { buildTeamHandoff, discoverTeamFiles, parseTeamContext, pathsOverlap, publishTeamContext, teamPaths } from "../team-context.js";
|
|
4
5
|
import { deriveReportingState, deriveSessionState, sessionStateWord, } from "../../shared/session-reporting.js";
|
|
5
6
|
const stamp = () => new Date().toISOString();
|
|
@@ -21,8 +22,8 @@ const stamp = () => new Date().toISOString();
|
|
|
21
22
|
* leader has no subordinates at all, so it is told the second half only - it must not decide
|
|
22
23
|
* alone either - and is never told about subordinates it does not have.
|
|
23
24
|
*/
|
|
24
|
-
export const STANDARD_LEADER_PROMPT = "你是直接向 Boss 负责的项目 Leader,负责敏捷开发与小步交付。用户是顶层决策者,你自行处理内部协调,只向用户汇总进展、成果与必要决策。开篇上下文已给出项目目标、模式、分工与当前任务清单,不必先调用 project(action=get) 就能直接拆解、派活或推进。小项目只拆最少必要任务,大项目按交付边界分工。用 add_task 登记任务(明确目标、交付物、验收标准、依赖);add_task / update_task 时可以带 executorProfile 与 reviewerProfile(支持指定 agentId、cwd、model、thinkingLevel、watchdogTimeoutSeconds),按任务性质将执行与复核委派给最合适的员工,不指定则继承项目默认;需要继续拆解的工作设 role=leader,叶子执行任务设 role=executor,子 Leader 用 parentTaskId 登记自己的子任务,dispatch 立即启动执行子会话;不要用 session_spawn/session_dispatch 或 task/workflow 绕开项目分工与汇报线。收到交付后用 request_review 启动独立复核。派发后子会话会立即开始执行并在完成后自动回报给你,届时继续派发 ready 任务、复核待验收任务或按 review.summary 返工;不要轮询等待,不要反复无进展重试,等待回报时直接结束当前回复。用 report 登记关键进展。你的下属的升级先到你这里:你在自己这一层处理,能自己解决的自己解决;只有确实需要 Boss 决策的(重大偏差、权限或范围变更)才用 escalate 交给 Boss。你不能替 Boss 做决定,也不要把没处理的升级压下去不理。所有任务验收后,用
|
|
25
|
-
export const LIGHTWEIGHT_LEADER_PROMPT = "你是直接向 Boss 负责的项目 Leader,这是一个轻量项目:这个项目由你亲自完成,不要拆子任务、不要派发给别人、也没有独立复核。开篇上下文已给出项目目标、模式与当前任务清单,不必先调用 project(action=get) 就能直接动手。用 add_task 登记任务(明确目标、交付物、验收标准、依赖),任务一律登记为执行任务:role=leader 或带 parentTaskId 都会被拒绝。dispatch 会把任务交回给你自己,你亲自做完;做完后调用 project(action=submit, projectId, taskId, output, evidenceRefs) 提交交付,提交即完成,不会有人回来复核,证据必须附上。不要用 session_spawn/session_dispatch 或 task/workflow 绕开项目职责与汇报线。不要轮询等待,不要反复无进展重试。用 report 汇总关键进展。普通技术决策、阻塞与返工由你自行处理;只有确实需要用户决定的目标取舍、权限或外部资源才用 escalate 交给 Boss,不得替 Boss 决定这些事项。所有任务交付后,用
|
|
25
|
+
export const STANDARD_LEADER_PROMPT = "你是直接向 Boss 负责的项目 Leader,负责敏捷开发与小步交付。用户是顶层决策者,你自行处理内部协调,只向用户汇总进展、成果与必要决策。开篇上下文已给出项目目标、模式、分工与当前任务清单,不必先调用 project(action=get) 就能直接拆解、派活或推进。小项目只拆最少必要任务,大项目按交付边界分工。用 add_task 登记任务(明确目标、交付物、验收标准、依赖);add_task / update_task 时可以带 executorProfile 与 reviewerProfile(支持指定 agentId、cwd、model、thinkingLevel、watchdogTimeoutSeconds),按任务性质将执行与复核委派给最合适的员工,不指定则继承项目默认;需要继续拆解的工作设 role=leader,叶子执行任务设 role=executor,子 Leader 用 parentTaskId 登记自己的子任务,dispatch 立即启动执行子会话;不要用 session_spawn/session_dispatch 或 task/workflow 绕开项目分工与汇报线。收到交付后用 request_review 启动独立复核。派发后子会话会立即开始执行并在完成后自动回报给你,届时继续派发 ready 任务、复核待验收任务或按 review.summary 返工;不要轮询等待,不要反复无进展重试,等待回报时直接结束当前回复。用 report 登记关键进展。你的下属的升级先到你这里:你在自己这一层处理,能自己解决的自己解决;只有确实需要 Boss 决策的(重大偏差、权限或范围变更)才用 escalate 交给 Boss。你不能替 Boss 做决定,也不要把没处理的升级压下去不理。所有任务验收后,用 deliver 记录带证据的阶段交付,后续可继续派发。上下文有限,明确假设,主动寻找反证。只在本次触发范围内工作。";
|
|
26
|
+
export const LIGHTWEIGHT_LEADER_PROMPT = "你是直接向 Boss 负责的项目 Leader,这是一个轻量项目:这个项目由你亲自完成,不要拆子任务、不要派发给别人、也没有独立复核。开篇上下文已给出项目目标、模式与当前任务清单,不必先调用 project(action=get) 就能直接动手。用 add_task 登记任务(明确目标、交付物、验收标准、依赖),任务一律登记为执行任务:role=leader 或带 parentTaskId 都会被拒绝。dispatch 会把任务交回给你自己,你亲自做完;做完后调用 project(action=submit, projectId, taskId, output, evidenceRefs) 提交交付,提交即完成,不会有人回来复核,证据必须附上。不要用 session_spawn/session_dispatch 或 task/workflow 绕开项目职责与汇报线。不要轮询等待,不要反复无进展重试。用 report 汇总关键进展。普通技术决策、阻塞与返工由你自行处理;只有确实需要用户决定的目标取舍、权限或外部资源才用 escalate 交给 Boss,不得替 Boss 决定这些事项。所有任务交付后,用 deliver 记录带证据的阶段交付,后续可继续派发。上下文有限,明确假设,主动寻找反证。只在本次触发范围内工作。";
|
|
26
27
|
const text = (value, label) => {
|
|
27
28
|
if (typeof value !== "string" || !value.trim())
|
|
28
29
|
throw new Error(`${label} 不能为空`);
|
|
@@ -120,7 +121,7 @@ export const mergeProfile = (taskProfile, projectDefault) => {
|
|
|
120
121
|
}
|
|
121
122
|
return hasKey ? merged : undefined;
|
|
122
123
|
};
|
|
123
|
-
const closed = (p) => ["
|
|
124
|
+
const closed = (p) => ["cancelled", "failed"].includes(p.status);
|
|
124
125
|
const busy = (status) => ["running", "waiting", "awaiting_background"].includes(status ?? "");
|
|
125
126
|
const dependenciesComplete = (p, t) => t.dependencies.every((id) => p.tasks.find((candidate) => candidate.id === id)?.status === "completed");
|
|
126
127
|
// Usage accounting uses billing-equivalent tokens so the panel and report match provider bills,
|
|
@@ -162,7 +163,7 @@ const DECISION_CELL_LIMIT = 40;
|
|
|
162
163
|
// state and every role is written the way a person would say it out loud.
|
|
163
164
|
const PROJECT_STATUS_TEXT = {
|
|
164
165
|
planning: "草稿", awaiting_start: "待启动", active: "进行中", blocked: "已阻塞", awaiting_approval: "等待审批",
|
|
165
|
-
awaiting_review: "等待复核",
|
|
166
|
+
awaiting_review: "等待复核", cancelled: "已取消", failed: "失败",
|
|
166
167
|
};
|
|
167
168
|
const TASK_STATUS_TEXT = {
|
|
168
169
|
pending: "等待依赖", ready: "待派发", in_progress: "执行阶段", interrupted: "已中断", blocked: "已阻塞",
|
|
@@ -172,7 +173,7 @@ const EVENT_TEXT = {
|
|
|
172
173
|
created: "创建项目", started: "启动执行", task_created: "登记任务", dispatched: "派发执行",
|
|
173
174
|
submitted: "提交交付", reviewed: "复核", review_requested: "启动复核", task_updated: "任务更新", status: "状态变更",
|
|
174
175
|
budget: "预算变更", report: "进展汇报", escalated: "例外升级", decision: "决定",
|
|
175
|
-
completed: "
|
|
176
|
+
delivery: "阶段交付", completed: "历史交付", ready: "依赖就绪", unreachable: "转述对象不可达",
|
|
176
177
|
// THE REPORT IS READ BY PEOPLE. Every other line of the timeline is printed in Chinese, so the
|
|
177
178
|
// one warning that says "your leader landed on the workspace default agent" must not be the
|
|
178
179
|
// only line a reader meets as an English identifier.
|
|
@@ -365,29 +366,92 @@ export class ProjectService {
|
|
|
365
366
|
this.event(p, "context_published", `共享上下文更新到第 ${p.contextRevision} 版`, undefined, actor);
|
|
366
367
|
}
|
|
367
368
|
async shareContext(id, value, workspaceId, actor) {
|
|
368
|
-
return this.change(id, workspaceId, p => {
|
|
369
|
+
return this.change(id, workspaceId, p => {
|
|
370
|
+
this.live(p);
|
|
371
|
+
this.publishContext(p, value, actor);
|
|
372
|
+
return { revision: p.contextRevision ?? 0, entries: p.sharedContext ?? [] };
|
|
373
|
+
});
|
|
369
374
|
}
|
|
370
375
|
async messageTask(id, taskId, content, workspaceId, actor, targetConversationId, deliveryMode = "queue") {
|
|
371
376
|
return this.change(id, workspaceId, async (p) => {
|
|
372
377
|
this.live(p);
|
|
373
378
|
const task = this.task(p, taskId);
|
|
374
379
|
this.manager(p, task, actor);
|
|
375
|
-
if (!["in_progress", "awaiting_review", "blocked"].includes(task.status))
|
|
376
|
-
throw new Error("
|
|
380
|
+
if (!["in_progress", "awaiting_review", "blocked", "completed"].includes(task.status))
|
|
381
|
+
throw new Error("补充指令只能发送到已有执行或复核记录的任务;新的交付请登记任务");
|
|
377
382
|
if (!["queue", "steer"].includes(deliveryMode))
|
|
378
383
|
throw new Error("deliveryMode 只能是 queue 或 steer");
|
|
379
384
|
const target = targetConversationId ?? task.ownerConversationId;
|
|
380
385
|
if (!target || ![task.ownerConversationId, task.reviewerConversationId].includes(target))
|
|
381
386
|
throw new Error("补充指令只能发送给本任务已有的执行或复核会话");
|
|
387
|
+
const session = this.store.conversation(target);
|
|
388
|
+
if (!session || session.archivedAt || session.workspaceId !== workspaceId)
|
|
389
|
+
throw new Error("目标会话已归档或不存在");
|
|
382
390
|
if (target === task.ownerConversationId)
|
|
383
391
|
this.assertWriteScope(p, task);
|
|
384
|
-
if (!busy(
|
|
392
|
+
if (!busy(session.status))
|
|
385
393
|
this.admission(p);
|
|
386
394
|
const result = await this.dispatchContext(target, text(content, "补充指令"), { wait: false, mode: deliveryMode }, task.id);
|
|
387
395
|
this.event(p, "task_message", `向「${task.title}」发送补充指令(${deliveryMode === "steer" ? "下一工具边界" : "排队"}),附带当前共享上下文`, task.id, actor);
|
|
396
|
+
/* THE REPLY IS THE ANSWER. The case was raised against this supervisor, and the supervisor
|
|
397
|
+
has just written to the member - so the case is answered, and the member's session must
|
|
398
|
+
stop saying that it is waiting for a decision. */
|
|
399
|
+
this.settleEscalationsByMessage(p, actor, target, text(content, "补充指令"));
|
|
388
400
|
return result;
|
|
389
401
|
});
|
|
390
402
|
}
|
|
403
|
+
/**
|
|
404
|
+
* A SUPERVISOR'S MESSAGE IS THE ANSWER TO THE EXCEPTION - NOT A FORMAL RULING.
|
|
405
|
+
*
|
|
406
|
+
* The reader's complaint was that a session kept saying 「等上面拍板」 long after the question
|
|
407
|
+
* had been settled in a real conversation: the supervisor had talked it through with the member
|
|
408
|
+
* and sent the follow-up instruction, and the platform was still waiting for a ceremony nobody
|
|
409
|
+
* had asked for. Communication is higher than protocol - when the supervisor the case is
|
|
410
|
+
* addressed to writes back to the member who raised it, the case IS answered.
|
|
411
|
+
*
|
|
412
|
+
* TWO THINGS ARE KEPT APART ON PURPOSE.
|
|
413
|
+
* - THE RECORD STAYS. The exception keeps its place in `p.escalations` with the answer, who
|
|
414
|
+
* answered and when. A decision record must not disappear when the project is cancelled.
|
|
415
|
+
* - THE STATE CHANGES. The session no longer says 「等上面拍板」, because nobody is waiting for
|
|
416
|
+
* anything any more: the answer is already on the member's desk.
|
|
417
|
+
*
|
|
418
|
+
* WHAT IS NOT SETTLED HERE, AND WHY:
|
|
419
|
+
* - A BOSS-LEVEL EXCEPTION IS NEVER SETTLED BY A MESSAGE. That case asks the Boss himself, and
|
|
420
|
+
* no team member has the authority to answer it - `resolveEscalation` enforces the very same
|
|
421
|
+
* rule for the panel and the tool, and it must hold for a message too.
|
|
422
|
+
* - A RETURNED EXCEPTION IS NOT REVIVED BY A MESSAGE. A returned case means the member was
|
|
423
|
+
* asked for more material; that material comes back as a NEW exception, not as the old one
|
|
424
|
+
* coming back to life.
|
|
425
|
+
* - ONLY THE DESIGNATED DIRECT SUPERVISOR ANSWERS. `targetConversationId` is the supervisor
|
|
426
|
+
* the case is addressed to, so a message from anybody else is somebody else's business.
|
|
427
|
+
* - AND THE REPLY HAS TO REACH THE MEMBER WHO RAISED IT. A supervisor who writes to somebody
|
|
428
|
+
* else has not answered this case, and settling it would repeat the mistake this project
|
|
429
|
+
* already made once: one answer closing every case of that member at once.
|
|
430
|
+
*/
|
|
431
|
+
settleEscalationsByMessage(p, actor, target, content) {
|
|
432
|
+
if (!actor)
|
|
433
|
+
return;
|
|
434
|
+
const answer = truncate(oneLine(content), 200);
|
|
435
|
+
let settled = 0;
|
|
436
|
+
for (const e of p.escalations ?? []) {
|
|
437
|
+
if (e.status !== "open")
|
|
438
|
+
continue;
|
|
439
|
+
if ((e.audience ?? "boss") !== "supervisor")
|
|
440
|
+
continue;
|
|
441
|
+
if (e.targetConversationId !== actor)
|
|
442
|
+
continue;
|
|
443
|
+
if (e.requestedByConversationId && e.requestedByConversationId !== target)
|
|
444
|
+
continue;
|
|
445
|
+
e.status = "resolved";
|
|
446
|
+
e.decision = answer;
|
|
447
|
+
e.resolvedAt = stamp();
|
|
448
|
+
e.resolvedByConversationId = actor;
|
|
449
|
+
this.event(p, "decision", `直接上级已答复例外(ID:${e.id}):${e.decision}`, e.taskId, actor);
|
|
450
|
+
settled += 1;
|
|
451
|
+
}
|
|
452
|
+
if (settled)
|
|
453
|
+
this.reconcile(p);
|
|
454
|
+
}
|
|
391
455
|
getContext(id, workspaceId, actor, taskId, contextIds) {
|
|
392
456
|
const p = id ? this.raw(id, workspaceId) : actor ? this.projectForSession(actor) : undefined;
|
|
393
457
|
if (!p)
|
|
@@ -431,14 +495,17 @@ export class ProjectService {
|
|
|
431
495
|
hints.push({ action: "message", taskId: task.id, reason: task.status === "blocked" ? "先排查并协调阻塞,给原执行者明确下一步;仅确需用户提供取舍或权限时才上收" : "本轮已结束但尚未交付,继续原会话或要求提交,不等待用户安排" });
|
|
432
496
|
}
|
|
433
497
|
}
|
|
434
|
-
|
|
435
|
-
|
|
498
|
+
const required = this.deliveryTasks(p);
|
|
499
|
+
if (actor === p.ownerConversationId && required.length && required.every(task => this.taskAccepted(task))
|
|
500
|
+
&& !deliveryCoversTasks(latestProjectDelivery(p), required) && !p.escalations.some(item => item.status === "open")) {
|
|
501
|
+
hints.push({ action: "deliver", reason: "本阶段必需任务已验收,汇总成果与证据后继续安排工作" });
|
|
502
|
+
}
|
|
436
503
|
return hints;
|
|
437
504
|
}
|
|
438
505
|
assertWriteScope(p, task) {
|
|
439
506
|
if (task.readOnly || !task.ownedPaths?.length)
|
|
440
507
|
return;
|
|
441
|
-
const conflicts = p.tasks.filter(other => other.id !== task.id && !other.readOnly
|
|
508
|
+
const conflicts = p.tasks.filter(other => other.id !== task.id && !other.readOnly
|
|
442
509
|
&& other.ownerConversationId && busy(this.store.conversation(other.ownerConversationId)?.status)
|
|
443
510
|
&& other.ownedPaths?.some(path => task.ownedPaths.some(own => pathsOverlap(path, own))));
|
|
444
511
|
if (conflicts.length)
|
|
@@ -1069,9 +1136,6 @@ export class ProjectService {
|
|
|
1069
1136
|
headline(p, actor, resources) {
|
|
1070
1137
|
const total = p.tasks.length;
|
|
1071
1138
|
const completed = p.tasks.filter((t) => t.status === "completed").length;
|
|
1072
|
-
if (p.status === "completed") {
|
|
1073
|
-
return total > 0 ? `项目已完成(${completed}/${total} 任务已验收)` : "项目已完成";
|
|
1074
|
-
}
|
|
1075
1139
|
if (p.status === "cancelled")
|
|
1076
1140
|
return "项目已取消";
|
|
1077
1141
|
if (p.status === "failed")
|
|
@@ -1229,7 +1293,7 @@ export class ProjectService {
|
|
|
1229
1293
|
lines.push(`- 创建时间:${moment(p.createdAt)}`);
|
|
1230
1294
|
lines.push(`- 最后更新时间:${moment(p.updatedAt)}`);
|
|
1231
1295
|
if (p.closedAt)
|
|
1232
|
-
lines.push(`-
|
|
1296
|
+
lines.push(`- 停止时间:${moment(p.closedAt)}`);
|
|
1233
1297
|
const usage = this.resources(p);
|
|
1234
1298
|
lines.push(`- 已用等效 Token:${usage.tokens}(口径:输入 + 输出 + 缓存写入×${CACHE_WRITE_WEIGHT} + 缓存读取×${CACHE_READ_WEIGHT},取整;含项目内的一次性调用(subagent))`);
|
|
1235
1299
|
lines.push(`- 原始口径(1:1):${usage.rawTokens}(输入 ${usage.usage?.input ?? 0} + 输出 ${usage.usage?.output ?? 0} + 缓存写入 ${usage.usage?.cacheWrite ?? 0} + 缓存读取 ${usage.usage?.cacheRead ?? 0})`);
|
|
@@ -1527,7 +1591,7 @@ export class ProjectService {
|
|
|
1527
1591
|
return ProjectService.taskView(t, p);
|
|
1528
1592
|
});
|
|
1529
1593
|
}
|
|
1530
|
-
async dispatchTask(id, taskId, workspaceId, actor) {
|
|
1594
|
+
async dispatchTask(id, taskId, workspaceId, actor, sourceContext) {
|
|
1531
1595
|
return this.change(id, workspaceId, async (p) => {
|
|
1532
1596
|
const t = this.task(p, taskId);
|
|
1533
1597
|
const manager = this.manager(p, t, actor);
|
|
@@ -1555,6 +1619,22 @@ export class ProjectService {
|
|
|
1555
1619
|
if (t.parentTaskId && this.task(p, t.parentTaskId).status !== "in_progress")
|
|
1556
1620
|
throw new Error("父任务未处于执行中");
|
|
1557
1621
|
const effective = mergeProfile(t.executorProfile, p.defaultExecutorProfile);
|
|
1622
|
+
if (sourceContext) {
|
|
1623
|
+
if (lightweight(p) || t.ownerConversationId || wasInterrupted || !manager)
|
|
1624
|
+
throw new Error("分叉只用于标准项目中首次派发的任务");
|
|
1625
|
+
const source = this.store.conversation(sourceContext.id);
|
|
1626
|
+
if (sourceContext.warm) {
|
|
1627
|
+
if (!source?.warmSession || source.workspaceId !== workspaceId)
|
|
1628
|
+
throw new Error("预热会话不在此工作区或已移除");
|
|
1629
|
+
}
|
|
1630
|
+
else if (!source || source.warmSession || source.parentConversationId !== manager || source.workspaceId !== workspaceId
|
|
1631
|
+
|| !p.tasks.some((task) => task.ownerConversationId === source.id)) {
|
|
1632
|
+
throw new Error("分叉来源必须是本项目下由你管理的执行会话");
|
|
1633
|
+
}
|
|
1634
|
+
else if (source.archivedAt || busy(source.status)) {
|
|
1635
|
+
throw new Error("请等待来源会话结束当前一轮后再分叉");
|
|
1636
|
+
}
|
|
1637
|
+
}
|
|
1558
1638
|
if (!t.ownerConversationId) {
|
|
1559
1639
|
if (lightweight(p)) {
|
|
1560
1640
|
// THE LEADER IS THE WORKER. A lightweight project spawns no worker session, so the task's
|
|
@@ -1567,6 +1647,7 @@ export class ProjectService {
|
|
|
1567
1647
|
else {
|
|
1568
1648
|
t.ownerConversationId = (await this.orchestrator.spawn({
|
|
1569
1649
|
workspaceId, parentConversationId: manager, title: `${t.role === "leader" ? "Leader" : "执行"} · ${t.title}`, task: t.objective, initialPrompt: "",
|
|
1650
|
+
...(sourceContext ? { forkFromConversationId: sourceContext.id } : {}),
|
|
1570
1651
|
...(effective?.agentId ? { agentId: effective.agentId } : {}),
|
|
1571
1652
|
...(effective?.cwd !== undefined ? { cwd: effective.cwd } : {}),
|
|
1572
1653
|
...(effective?.model ? { model: effective.model } : {}),
|
|
@@ -1599,7 +1680,7 @@ export class ProjectService {
|
|
|
1599
1680
|
delete t.blockedReason;
|
|
1600
1681
|
delete t.blockedReportedByConversationId;
|
|
1601
1682
|
delete t.interruptedReason;
|
|
1602
|
-
this.captureHandoff(p, t, manager);
|
|
1683
|
+
this.captureHandoff(p, t, sourceContext?.id ?? manager);
|
|
1603
1684
|
this.event(p, "dispatched", `派发执行:${t.title};交接 ${t.handoff?.entries.length ?? 0} 条共享记录`, t.id, actor);
|
|
1604
1685
|
this.reconcile(p);
|
|
1605
1686
|
await this.store.setProject(p);
|
|
@@ -1607,7 +1688,8 @@ export class ProjectService {
|
|
|
1607
1688
|
/* THE LIGHTWEIGHT TASK SAYS WHAT IS DIFFERENT, because the difference is the point: there is
|
|
1608
1689
|
no reviewer coming back, so the evidence that the reviewer would have demanded is the only
|
|
1609
1690
|
thing that stands behind the delivery. */
|
|
1610
|
-
const modeNote = lightweight(p) ? "本项目是轻量项目:你就是唯一的执行会话,不会有独立复核人回来,完成后调用 project(action=submit, …) 提交即完成,交付证据必须附上。"
|
|
1691
|
+
const modeNote = lightweight(p) ? "本项目是轻量项目:你就是唯一的执行会话,不会有独立复核人回来,完成后调用 project(action=submit, …) 提交即完成,交付证据必须附上。"
|
|
1692
|
+
: sourceContext ? "\n复用已复制的历史背景,立即推进本条消息指定的新任务;历史里的任务、成员身份及验收均属于原会话。\n" : "";
|
|
1611
1693
|
/* THE TASK THAT WAS INTERRUPTED IS TOLD WHAT HAPPENED. A worker that comes back to a task
|
|
1612
1694
|
it was working on has no idea whether the work it half did is still wanted, and the
|
|
1613
1695
|
default - carry on as if nothing happened - is the wrong one after a crash. */
|
|
@@ -1636,7 +1718,8 @@ export class ProjectService {
|
|
|
1636
1718
|
});
|
|
1637
1719
|
}
|
|
1638
1720
|
async submit(id, taskId, input, workspaceId, actor) {
|
|
1639
|
-
|
|
1721
|
+
let completedOwner;
|
|
1722
|
+
const task = await this.change(id, workspaceId, (p) => {
|
|
1640
1723
|
this.live(p);
|
|
1641
1724
|
const t = this.task(p, taskId);
|
|
1642
1725
|
if (actor && actor !== t.ownerConversationId)
|
|
@@ -1661,6 +1744,7 @@ export class ProjectService {
|
|
|
1661
1744
|
claim that somebody else checked it. */
|
|
1662
1745
|
t.status = "completed";
|
|
1663
1746
|
t.updatedAt = stamp();
|
|
1747
|
+
completedOwner = t.ownerConversationId;
|
|
1664
1748
|
t.review = { verdict: "accepted", summary: "轻量项目:执行者自评交付,未做独立复核", evidenceRefs,
|
|
1665
1749
|
reviewerConversationId: t.ownerConversationId, createdAt: stamp(), lightweight: true };
|
|
1666
1750
|
this.syncDeliveryContext(p, t, actor);
|
|
@@ -1676,6 +1760,8 @@ export class ProjectService {
|
|
|
1676
1760
|
this.reconcile(p);
|
|
1677
1761
|
return ProjectService.taskView(t, p);
|
|
1678
1762
|
});
|
|
1763
|
+
await this.notifyTaskCompleted(completedOwner, taskId);
|
|
1764
|
+
return task;
|
|
1679
1765
|
}
|
|
1680
1766
|
async requestReview(id, taskId, workspaceId, actor) {
|
|
1681
1767
|
return this.change(id, workspaceId, async (p) => {
|
|
@@ -1710,7 +1796,8 @@ export class ProjectService {
|
|
|
1710
1796
|
});
|
|
1711
1797
|
}
|
|
1712
1798
|
async review(id, taskId, input, workspaceId, actor) {
|
|
1713
|
-
|
|
1799
|
+
let completedOwner;
|
|
1800
|
+
const task = await this.change(id, workspaceId, (p) => {
|
|
1714
1801
|
this.live(p);
|
|
1715
1802
|
const t = this.task(p, taskId);
|
|
1716
1803
|
if (!actor || actor !== t.reviewerConversationId || actor === t.ownerConversationId)
|
|
@@ -1725,11 +1812,39 @@ export class ProjectService {
|
|
|
1725
1812
|
t.review = { verdict: input.verdict, summary: text(input.summary, "复核意见"), evidenceRefs, reviewerConversationId: actor, createdAt: stamp() };
|
|
1726
1813
|
t.status = input.verdict === "accepted" ? "completed" : "ready";
|
|
1727
1814
|
t.updatedAt = stamp();
|
|
1815
|
+
if (t.status === "completed")
|
|
1816
|
+
completedOwner = t.ownerConversationId;
|
|
1728
1817
|
this.syncDeliveryContext(p, t, actor);
|
|
1729
1818
|
this.event(p, "reviewed", `${input.verdict === "accepted" ? "验收通过" : "退回返工"}:${t.title};${t.review.summary}`, t.id, actor);
|
|
1730
1819
|
this.reconcile(p);
|
|
1731
1820
|
return ProjectService.taskView(t, p);
|
|
1732
1821
|
});
|
|
1822
|
+
await this.notifyTaskCompleted(completedOwner, taskId);
|
|
1823
|
+
return task;
|
|
1824
|
+
}
|
|
1825
|
+
/**
|
|
1826
|
+
* THE TASK IS DONE, SO THE LEADER IS WOKEN - AND IT IS NOT TOLD WHAT WAS DONE.
|
|
1827
|
+
*
|
|
1828
|
+
* The member's work is finished, and the member's direct parent - the Leader - has to hear
|
|
1829
|
+
* about it: a Leader that is not told is a Leader that sits there with a finished employee.
|
|
1830
|
+
*
|
|
1831
|
+
* WHAT THE WAKE CARRIES IS THE TASK'S IDENTITY AND NOTHING ELSE. The delivery, the evidence and
|
|
1832
|
+
* the review verdict stay where they are: in the project record and in the member's own
|
|
1833
|
+
* session. A platform that wrote the summary here would be writing a report nobody checked, and
|
|
1834
|
+
* the Leader is the one who is supposed to look and judge.
|
|
1835
|
+
*
|
|
1836
|
+
* THE COMPLETION IS THE UNIT, SO THE KNOCK HAPPENS ONCE. A task that is marked complete twice -
|
|
1837
|
+
* a retried acceptance - is one piece of work, and the Leader is woken once for it.
|
|
1838
|
+
*/
|
|
1839
|
+
async notifyTaskCompleted(ownerConversationId, taskId) {
|
|
1840
|
+
if (!ownerConversationId || !this.orchestrator)
|
|
1841
|
+
return;
|
|
1842
|
+
try {
|
|
1843
|
+
await this.orchestrator.notifyChildCompleted(ownerConversationId, { unit: `task:${taskId}` });
|
|
1844
|
+
}
|
|
1845
|
+
catch (error) {
|
|
1846
|
+
console.warn(`Super Pi: 任务 ${taskId} 已完成,但叫不醒直属上级:${error instanceof Error ? error.message : String(error)}`);
|
|
1847
|
+
}
|
|
1733
1848
|
}
|
|
1734
1849
|
async updateTask(id, taskId, patch, actor) {
|
|
1735
1850
|
const result = await this.change(id, patch.workspaceId, async (p) => {
|
|
@@ -1849,7 +1964,7 @@ export class ProjectService {
|
|
|
1849
1964
|
const result = await this.change(id, workspaceId, (p) => {
|
|
1850
1965
|
this.live(p);
|
|
1851
1966
|
if (!["active", "cancelled", "failed"].includes(status))
|
|
1852
|
-
throw new Error("
|
|
1967
|
+
throw new Error("阶段交付请使用 deliver,项目状态由任务和例外推导");
|
|
1853
1968
|
if (status === "active" && p.escalations.some((e) => e.status === "open"))
|
|
1854
1969
|
throw new Error("请先处理未解决的例外");
|
|
1855
1970
|
/* A PROJECT WITH NO LEADER SESSION HAS NOTHING RUNNING IN IT. The status is derived from
|
|
@@ -2129,24 +2244,27 @@ export class ProjectService {
|
|
|
2129
2244
|
}
|
|
2130
2245
|
return result;
|
|
2131
2246
|
}
|
|
2132
|
-
|
|
2247
|
+
deliveryTasks(p) {
|
|
2248
|
+
return p.tasks.filter((task) => task.status !== "cancelled" || !task.blockedReason);
|
|
2249
|
+
}
|
|
2250
|
+
async deliver(id, summary, evidenceRefs, workspaceId, actor) {
|
|
2133
2251
|
return this.change(id, workspaceId, (p) => {
|
|
2134
2252
|
this.live(p);
|
|
2135
2253
|
this.leader(p, actor);
|
|
2136
|
-
const required =
|
|
2254
|
+
const required = this.deliveryTasks(p);
|
|
2137
2255
|
if (!required.length || required.some((t) => !this.taskAccepted(t))) {
|
|
2138
|
-
throw new Error(lightweight(p) ? "
|
|
2256
|
+
throw new Error(lightweight(p) ? "所有必需任务须先完成交付" : "所有必需任务须先经独立复核验收");
|
|
2139
2257
|
}
|
|
2140
2258
|
if (p.escalations.some((e) => e.status === "open"))
|
|
2141
2259
|
throw new Error("尚有未处理例外");
|
|
2142
|
-
const evidence = strings(evidenceRefs, "
|
|
2260
|
+
const evidence = strings(evidenceRefs, "阶段交付证据");
|
|
2143
2261
|
if (!evidence.length)
|
|
2144
|
-
throw new Error("
|
|
2145
|
-
const progress = text(summary, "
|
|
2146
|
-
p.reports.push({ id: randomUUID(), projectId: id, kind: "delivery", progress, evidenceRefs: evidence,
|
|
2147
|
-
|
|
2148
|
-
p
|
|
2149
|
-
this.
|
|
2262
|
+
throw new Error("阶段交付必须附证据");
|
|
2263
|
+
const progress = text(summary, "阶段交付总结");
|
|
2264
|
+
p.reports.push({ id: randomUUID(), projectId: id, kind: "delivery", progress, evidenceRefs: evidence,
|
|
2265
|
+
acceptedTaskIds: required.map(task => task.id), authorConversationId: actor ?? p.ownerConversationId, createdAt: stamp() });
|
|
2266
|
+
this.event(p, "delivery", progress, undefined, actor);
|
|
2267
|
+
this.reconcile(p);
|
|
2150
2268
|
return p;
|
|
2151
2269
|
});
|
|
2152
2270
|
}
|
|
@@ -2289,7 +2407,11 @@ export class ProjectService {
|
|
|
2289
2407
|
throw new Error("已经在项目里的会话不能另起项目:请专注当前项目分工。");
|
|
2290
2408
|
if (conversation.parentConversationId)
|
|
2291
2409
|
throw new Error("只有主对话可以创建项目:派发出来的会话不能另起项目。");
|
|
2292
|
-
const running = this.store.projects().filter((p) => p.initiatorConversationId === actor && !closed(p)
|
|
2410
|
+
const running = this.store.projects().filter((p) => p.initiatorConversationId === actor && !closed(p)
|
|
2411
|
+
&& (!deliveryCoversTasks(latestProjectDelivery(p), this.deliveryTasks(p))
|
|
2412
|
+
|| this.deliveryTasks(p).some(task => !this.taskAccepted(task))
|
|
2413
|
+
|| p.escalations.some(item => item.status === "open")
|
|
2414
|
+
|| this.activitySessions(p).some(session => busy(session.status))));
|
|
2293
2415
|
if (running.length >= 3)
|
|
2294
2416
|
throw new Error("你同时进行的项目超过上限(3 个),先完成或停止一个再新建。");
|
|
2295
2417
|
// ONLY TWO FIELDS ARE ASKED FOR, AND SAYING SO IS PART OF THE CONTRACT. The schema marks
|
|
@@ -2326,6 +2448,7 @@ export class ProjectService {
|
|
|
2326
2448
|
this.member(rawProject, actor);
|
|
2327
2449
|
switch (body.action) {
|
|
2328
2450
|
case "get": return this.get(id, workspaceId, actor);
|
|
2451
|
+
case "list_warm_sessions": return { sessions: this.store.listWarmSessions(workspaceId) };
|
|
2329
2452
|
case "export": return this.exportReport(id, workspaceId);
|
|
2330
2453
|
case "start": return this.start(id, workspaceId, actor);
|
|
2331
2454
|
case "add_task": return this.addTask(id, body, workspaceId, actor);
|
|
@@ -2337,20 +2460,27 @@ export class ProjectService {
|
|
|
2337
2460
|
return this.messageTask(id, text(body.taskId, "taskId"), text(body.content, "content"), workspaceId, actor, typeof body.targetConversationId === "string" ? body.targetConversationId : undefined, body.deliveryMode);
|
|
2338
2461
|
}
|
|
2339
2462
|
case "dispatch": {
|
|
2463
|
+
const forkFromConversationId = body.forkFromConversationId === undefined
|
|
2464
|
+
? undefined : text(body.forkFromConversationId, "forkFromConversationId");
|
|
2465
|
+
const warmSessionId = body.warmSessionId === undefined ? undefined : text(body.warmSessionId, "warmSessionId");
|
|
2466
|
+
if (forkFromConversationId && warmSessionId)
|
|
2467
|
+
throw new Error("请选择一个会话上下文来源");
|
|
2468
|
+
const sourceContext = warmSessionId ? { id: warmSessionId, warm: true }
|
|
2469
|
+
: forkFromConversationId ? { id: forkFromConversationId, warm: false } : undefined;
|
|
2340
2470
|
if (body.sharedContext !== undefined)
|
|
2341
2471
|
await this.shareContext(id, body.sharedContext, workspaceId, actor);
|
|
2342
2472
|
if (body.taskIds === undefined) {
|
|
2343
2473
|
const taskId = text(body.taskId, "taskId");
|
|
2344
2474
|
if (body.handoffNote !== undefined)
|
|
2345
2475
|
await this.updateTask(id, taskId, { workspaceId, handoffNote: body.handoffNote }, actor);
|
|
2346
|
-
return this.dispatchReceipt(await this.dispatchTask(id, taskId, workspaceId, actor));
|
|
2476
|
+
return this.dispatchReceipt(await this.dispatchTask(id, taskId, workspaceId, actor, sourceContext));
|
|
2347
2477
|
}
|
|
2348
2478
|
if (!Array.isArray(body.taskIds) || !body.taskIds.length || body.taskIds.length > 32 || body.taskIds.some(taskId => typeof taskId !== "string"))
|
|
2349
2479
|
throw new Error("taskIds 须为 1–32 项任务 id 数组");
|
|
2350
2480
|
const started = [], failed = [];
|
|
2351
2481
|
for (const taskId of [...new Set(body.taskIds)]) {
|
|
2352
2482
|
try {
|
|
2353
|
-
started.push(await this.dispatchTask(id, taskId, workspaceId, actor));
|
|
2483
|
+
started.push(await this.dispatchTask(id, taskId, workspaceId, actor, sourceContext));
|
|
2354
2484
|
}
|
|
2355
2485
|
catch (error) {
|
|
2356
2486
|
failed.push({ taskId, error: error instanceof Error ? error.message : String(error) });
|
|
@@ -2368,7 +2498,8 @@ export class ProjectService {
|
|
|
2368
2498
|
case "resolveEscalation":
|
|
2369
2499
|
return this.resolveEscalation(id, text(body.escalationId, "escalationId"), text(body.decision, "decision"), body.status ?? "resolved", workspaceId, actor);
|
|
2370
2500
|
case "correct": return this.correctMember(id, text(body.targetConversationId, "targetConversationId"), text(body.content, "content"), workspaceId, actor);
|
|
2371
|
-
case "
|
|
2501
|
+
case "deliver":
|
|
2502
|
+
case "complete": return this.deliver(id, body.summary, body.evidenceRefs, workspaceId, actor);
|
|
2372
2503
|
case "cancel": return this.cancel(id, body, workspaceId, actor);
|
|
2373
2504
|
default: throw new Error("未知的项目工具操作");
|
|
2374
2505
|
}
|
|
@@ -441,7 +441,9 @@ export declare class RunService {
|
|
|
441
441
|
mode?: MessageDeliveryMode;
|
|
442
442
|
onAccepted?: (messageId: string) => void;
|
|
443
443
|
}): Promise<void>;
|
|
444
|
-
enqueueAndRun(conversationId: string, content: string, images?: MessageImage[], attachments?:
|
|
444
|
+
enqueueAndRun(conversationId: string, content: string, images?: MessageImage[], attachments?: Message["attachments"], clientId?: string, mode?: MessageDeliveryMode): Promise<void>;
|
|
445
|
+
enqueueReminder(conversationId: string, note: string): Promise<void>;
|
|
446
|
+
private enqueueMessage;
|
|
445
447
|
/**
|
|
446
448
|
* Steers a queued message into the in-flight turn.
|
|
447
449
|
*/
|
|
@@ -40,7 +40,11 @@ async function expandAtReferences(store, workspace, content) {
|
|
|
40
40
|
const found = state.conversations.find(c => c.id === key || c.title.toLocaleLowerCase().includes(key.toLocaleLowerCase()));
|
|
41
41
|
if (!found)
|
|
42
42
|
continue;
|
|
43
|
-
const text = found.messages
|
|
43
|
+
const text = found.messages
|
|
44
|
+
.filter(message => message.role === "user" || message.role === "assistant" || message.source === "session-reminder")
|
|
45
|
+
.slice(-12)
|
|
46
|
+
.map(message => `${message.source === "session-reminder" ? "定时提醒" : message.role}: ${message.content}`)
|
|
47
|
+
.join("\n");
|
|
44
48
|
blocks.push(`\n[引用会话 ${found.title} (${found.id})]\n${text.slice(-12000)}\n[/引用会话]`);
|
|
45
49
|
continue;
|
|
46
50
|
}
|
|
@@ -88,6 +92,8 @@ async function expandAtReferences(store, workspace, content) {
|
|
|
88
92
|
* answers about THAT - which is what a primary agent should do with a child's result.
|
|
89
93
|
*/
|
|
90
94
|
function composePrompt(message) {
|
|
95
|
+
if (message.source === "session-reminder")
|
|
96
|
+
return `[定时提醒] ${message.content}`;
|
|
91
97
|
if (message.role !== "tool")
|
|
92
98
|
return message.content;
|
|
93
99
|
const content = message.content;
|
|
@@ -716,6 +722,8 @@ export class RunService {
|
|
|
716
722
|
throw new Error("会话不存在");
|
|
717
723
|
throw new Error(`会话所属的工作区 ${conversation.workspaceId} 已不存在,拒绝运行`);
|
|
718
724
|
}
|
|
725
|
+
if (context.conversation.warmSession)
|
|
726
|
+
throw new Error("预热快照只能通过项目派发使用");
|
|
719
727
|
return context;
|
|
720
728
|
}
|
|
721
729
|
/**
|
|
@@ -1953,7 +1961,13 @@ export class RunService {
|
|
|
1953
1961
|
this.broadcaster.broadcastState();
|
|
1954
1962
|
}
|
|
1955
1963
|
}
|
|
1956
|
-
|
|
1964
|
+
enqueueAndRun(conversationId, content, images, attachments, clientId, mode) {
|
|
1965
|
+
return this.enqueueMessage(conversationId, content, { images, attachments, clientId, mode });
|
|
1966
|
+
}
|
|
1967
|
+
enqueueReminder(conversationId, note) {
|
|
1968
|
+
return this.enqueueMessage(conversationId, note, { source: "session-reminder" });
|
|
1969
|
+
}
|
|
1970
|
+
async enqueueMessage(conversationId, content, { images, attachments, clientId, mode, source }) {
|
|
1957
1971
|
const deliveryMode = parseMessageDeliveryMode(mode);
|
|
1958
1972
|
this.assertHistoryAvailable(conversationId);
|
|
1959
1973
|
/**
|
|
@@ -1971,7 +1985,7 @@ export class RunService {
|
|
|
1971
1985
|
if (clientId && this.store.hasMessage(conversationId, clientId))
|
|
1972
1986
|
return;
|
|
1973
1987
|
this.memory?.cancel(conversationId);
|
|
1974
|
-
if (!isLengthContinuation(content)) {
|
|
1988
|
+
if (source || !isLengthContinuation(content)) {
|
|
1975
1989
|
this.lengthContinuations.delete(conversationId);
|
|
1976
1990
|
await this.store.setWarningReason(conversationId, undefined).catch(() => undefined);
|
|
1977
1991
|
}
|
|
@@ -2017,7 +2031,10 @@ export class RunService {
|
|
|
2017
2031
|
}
|
|
2018
2032
|
let message;
|
|
2019
2033
|
try {
|
|
2020
|
-
|
|
2034
|
+
const delivery = queueOnly ? "waiting" : undefined;
|
|
2035
|
+
message = source
|
|
2036
|
+
? await this.store.addAgentMessage(conversationId, trimmed, { source, delivery })
|
|
2037
|
+
: await this.store.addUserMessage(conversationId, trimmed, validImages, attachments, { clientId, delivery });
|
|
2021
2038
|
}
|
|
2022
2039
|
catch (error) {
|
|
2023
2040
|
if (reservedController)
|
|
@@ -2052,7 +2069,7 @@ export class RunService {
|
|
|
2052
2069
|
try {
|
|
2053
2070
|
const currentConv = this.turnContext(conversationId).conversation;
|
|
2054
2071
|
await this.assertModelSupportsImages(currentConv, Boolean(validImages?.length), message.id);
|
|
2055
|
-
expanded = await expandAtReferences(this.store, workspace,
|
|
2072
|
+
expanded = await expandAtReferences(this.store, workspace, composePrompt(message));
|
|
2056
2073
|
}
|
|
2057
2074
|
catch (error) {
|
|
2058
2075
|
// EVERY REFUSAL ABOVE HAPPENS BEFORE A TURN EXISTS. The words are on screen and no model has seen
|
|
@@ -56,6 +56,8 @@ export interface SpawnSessionOptions {
|
|
|
56
56
|
* edge and the memory tree are two different things, and this flag touches only the second.
|
|
57
57
|
*/
|
|
58
58
|
separateMemoryTree?: boolean;
|
|
59
|
+
/** Copy the settled history of another child of the same parent. */
|
|
60
|
+
forkFromConversationId?: string;
|
|
59
61
|
}
|
|
60
62
|
export interface ReportSessionOptions {
|
|
61
63
|
/** The report content (milestone, findings, roadblock, or final output). */
|
|
@@ -153,6 +155,19 @@ export declare class SessionOrchestratorService {
|
|
|
153
155
|
* result is still its own.
|
|
154
156
|
*/
|
|
155
157
|
private readonly reportedChildren;
|
|
158
|
+
/**
|
|
159
|
+
* THE COMPLETION NOTICES THAT HAVE ALREADY KNOCKED ON A PARENT'S DOOR.
|
|
160
|
+
*
|
|
161
|
+
* One entry per finished child per completion, and the completion is identified by the child's
|
|
162
|
+
* last answer - so a RETRY of the same finished turn knocks once, while the next turn the child
|
|
163
|
+
* runs is a different completion and knocks again.
|
|
164
|
+
*
|
|
165
|
+
* WHY THIS IS A SET AND NOT A FLAG. A flag would say "this child has been announced", and that
|
|
166
|
+
* is a different question from "THIS completion has been announced". A flag silences every
|
|
167
|
+
* later completion of the same child, and a child that works for three turns would be announced
|
|
168
|
+
* once - the parent would sit through two of the child's finishes without being told.
|
|
169
|
+
*/
|
|
170
|
+
private readonly completionNotices;
|
|
156
171
|
constructor(store: Store, conversationService: ConversationService, runService: RunService, ledger: SessionLedger, broadcaster?: EventBroadcaster | undefined, watchdog?: SessionWatchdog, uploadsDir?: string | undefined);
|
|
157
172
|
/**
|
|
158
173
|
* The watchdog timer fired: the child has been silent for longer than the parent declared.
|
|
@@ -168,15 +183,64 @@ export declare class SessionOrchestratorService {
|
|
|
168
183
|
/**
|
|
169
184
|
* Dispatches a message to an arbitrary session (server-to-server).
|
|
170
185
|
* By default dispatches asynchronously so the orchestrator caller is not blocked.
|
|
186
|
+
*
|
|
187
|
+
* `silent` is for the platform's own housekeeping - the completion knock. A knock wakes a
|
|
188
|
+
* session and carries no result, so the turn it starts must not produce a result report of its
|
|
189
|
+
* own: a knock that made the woken session report up would turn one child's finish into a
|
|
190
|
+
* chain of knocks all the way to the top.
|
|
171
191
|
*/
|
|
172
192
|
dispatch(conversationId: string, content: string, options?: {
|
|
173
193
|
wait?: boolean;
|
|
174
194
|
mode?: MessageDeliveryMode;
|
|
195
|
+
silent?: boolean;
|
|
175
196
|
}): Promise<{
|
|
176
197
|
conversationId: string;
|
|
177
198
|
messageId?: string;
|
|
178
199
|
mode: MessageDeliveryMode;
|
|
179
200
|
}>;
|
|
201
|
+
/**
|
|
202
|
+
* THE PLATFORM KNOCKS ON THE PARENT'S DOOR WHEN A CHILD SESSION ENDS.
|
|
203
|
+
*
|
|
204
|
+
* A child that finished its work is a child the parent has to hear about, and the PLATFORM is the
|
|
205
|
+
* one that knows the turn ended: the child may forget to say so, and a parent that was not
|
|
206
|
+
* present for the turn cannot see that it happened. This is the platform's own housekeeping -
|
|
207
|
+
* it is not something the child is asked to do and not something the model has to remember.
|
|
208
|
+
*
|
|
209
|
+
* THE KNOCK CARRIES NO WORK. It says WHICH child session finished and nothing else: no output,
|
|
210
|
+
* no summary, no last message, no result, no task result. The parent reads the child's session
|
|
211
|
+
* itself, so a platform that summarized here would be writing the report the parent is supposed
|
|
212
|
+
* to write - and a summary written by the platform is a summary nobody verified.
|
|
213
|
+
*
|
|
214
|
+
* ONLY THE DIRECT PARENT IS TOLD. The parent wakes up and looks at its own child; the
|
|
215
|
+
* grandparent is not told about a grandchild's finish, because the parent is the one who has to
|
|
216
|
+
* decide what that means.
|
|
217
|
+
*
|
|
218
|
+
* A TOP-LEVEL SESSION HAS NOBODY TO TELL, so a session without a parent produces nothing - and
|
|
219
|
+
* the user's own session is one of those.
|
|
220
|
+
*/
|
|
221
|
+
notifyChildCompleted(childConversationId: string, options?: {
|
|
222
|
+
unit?: string;
|
|
223
|
+
}): Promise<{
|
|
224
|
+
delivered: boolean;
|
|
225
|
+
parentConversationId?: string;
|
|
226
|
+
}>;
|
|
227
|
+
/**
|
|
228
|
+
* WHAT MAKES TWO COMPLETION REPORTS THE SAME COMPLETION.
|
|
229
|
+
*
|
|
230
|
+
* The child's last answer is the thing the completion is about, so two reports that arrive after
|
|
231
|
+
* the same answer are the same completion - a retry, a repeated settle, a second report about a
|
|
232
|
+
* turn that already ended. The next turn produces the next answer, and that is a new completion
|
|
233
|
+
* the parent has not been told about yet.
|
|
234
|
+
*/
|
|
235
|
+
private completionUnit;
|
|
236
|
+
/**
|
|
237
|
+
* IS THIS SESSION ONE OF A PROJECT'S EMPLOYEES?
|
|
238
|
+
*
|
|
239
|
+
* A project member's turn ending is NOT its work being done: the delivery still has to be
|
|
240
|
+
* reviewed. The moment that counts is the task being completed, and the project announces that
|
|
241
|
+
* one - announcing both would wake the Leader twice for one piece of work.
|
|
242
|
+
*/
|
|
243
|
+
private projectParticipant;
|
|
180
244
|
/**
|
|
181
245
|
* THE CHILD'S OUTPUT WAS CUT OFF. TELL IT TO CARRY ON, AND LET IT.
|
|
182
246
|
*
|
|
@@ -295,6 +359,7 @@ export declare class SessionOrchestratorService {
|
|
|
295
359
|
stoppedIds: string[];
|
|
296
360
|
descendantCount: number;
|
|
297
361
|
}>;
|
|
362
|
+
removeWarmSession(conversationId: string): Promise<void>;
|
|
298
363
|
/**
|
|
299
364
|
* Permanently destroys a direct child session and its entire descendant subtree (stopping any
|
|
300
365
|
* running/queued turns first) and removes all transcripts, outputs, runs, and auxiliary state.
|