@evandu/super-pi 0.1.219 → 0.1.221
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 +3 -2
- package/agents/super-pi-task/core.ts +1 -1
- package/dist/client/.super-pi-client-sources.json +6 -6
- package/dist/client/assets/{CodeMirrorEditor-BoRBaVec.js → CodeMirrorEditor-Cv1X2hmd.js} +2 -2
- package/dist/client/assets/{dist-CYpk6fXT.js → dist-B3GZVLeH.js} +1 -1
- package/dist/client/assets/{dist-DQ_C0DEU.js → dist-BA1wBjGJ.js} +1 -1
- package/dist/client/assets/{dist-CPjKkcyd.js → dist-BT_Z_-2X.js} +1 -1
- package/dist/client/assets/{dist-Digy2Mj0.js → dist-BqNxkXgs.js} +1 -1
- package/dist/client/assets/{dist-CiRgPe6t.js → dist-Bxyffyjn.js} +1 -1
- package/dist/client/assets/{dist-D1hdxSH6.js → dist-C-Kbr0WK.js} +1 -1
- package/dist/client/assets/{dist-CIv6vCdn.js → dist-C071I6sD.js} +1 -1
- package/dist/client/assets/{dist-CMdO3YzL.js → dist-C729XRkf.js} +1 -1
- package/dist/client/assets/{dist-BOF4T7jI.js → dist-CRfLPcZ8.js} +1 -1
- package/dist/client/assets/{dist-Dwsqs8C-.js → dist-CT23BwQB.js} +1 -1
- package/dist/client/assets/{dist-mAA5Fw0-.js → dist-CVErcv3I.js} +1 -1
- package/dist/client/assets/{dist-Cp3XgqJR.js → dist-CeHhOkTz.js} +1 -1
- package/dist/client/assets/{dist-CjhpwEGf.js → dist-ClwDCrdU.js} +1 -1
- package/dist/client/assets/{dist-xb23AFcT.js → dist-CsqiBKUZ.js} +1 -1
- package/dist/client/assets/{dist-DvWgfLRt.js → dist-DPYofnO9.js} +1 -1
- package/dist/client/assets/{dist-DUbHNa35.js → dist-DlBSkHdo.js} +1 -1
- package/dist/client/assets/{dist-DLYLxwOe.js → dist-DrNjVA0k.js} +1 -1
- package/dist/client/assets/{dist-BVVJTFYw.js → dist-Gvvox7eW.js} +1 -1
- package/dist/client/assets/{dist-BXOV_xtI.js → dist-IohJ9Qkl.js} +1 -1
- package/dist/client/assets/{dist-BOC9yjsN.js → dist-J-F3f1eU.js} +1 -1
- package/dist/client/assets/{dist-Bh20DSAa.js → dist-w6rH3SJG.js} +1 -1
- package/dist/client/assets/{dist-gRtmlyhZ.js → dist-xdw6XDXx.js} +1 -1
- package/dist/client/assets/index-B-h_KnC5.css +1 -0
- package/dist/client/assets/{index-DmxXnVfN.js → index-CCF1Ymba.js} +11 -11
- package/dist/client/index.html +2 -2
- package/dist/server/application/extension-ui-service.d.ts +2 -1
- package/dist/server/application/extension-ui-service.js +25 -17
- package/dist/server/application/project-service.d.ts +48 -3
- package/dist/server/application/project-service.js +123 -38
- package/dist/server/application/run-service.d.ts +3 -1
- package/dist/server/application/run-service.js +20 -5
- package/dist/server/application/session-orchestrator-service.d.ts +62 -0
- package/dist/server/application/session-orchestrator-service.js +122 -1
- package/dist/server/application/session-reminder-service.js +1 -2
- package/dist/server/index.js +5 -1
- package/dist/server/runtime.js +2 -2
- package/dist/server/store.d.ts +10 -3
- package/dist/server/store.js +87 -20
- package/dist/server/types.d.ts +7 -0
- package/dist/shared/project-overview.d.ts +12 -0
- package/dist/shared/project-overview.js +15 -0
- package/dist/shared/session-reporting.d.ts +14 -0
- package/dist/shared/session-reporting.js +11 -0
- package/package.json +5 -1
- package/dist/client/assets/index-Nu--gcBs.css +0 -1
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-CCF1Ymba.js"></script>
|
|
12
|
+
<link rel="stylesheet" crossorigin href="/assets/index-B-h_KnC5.css">
|
|
13
13
|
</head>
|
|
14
14
|
<body>
|
|
15
15
|
<div id="root"></div>
|
|
@@ -14,8 +14,9 @@ import type { EventBroadcaster } from "../server-context.js";
|
|
|
14
14
|
*/
|
|
15
15
|
export declare class ExtensionUiService {
|
|
16
16
|
private readonly broadcaster;
|
|
17
|
+
private readonly canAddressUser;
|
|
17
18
|
private readonly pendingUi;
|
|
18
|
-
constructor(broadcaster: EventBroadcaster);
|
|
19
|
+
constructor(broadcaster: EventBroadcaster, canAddressUser?: (conversationId: string) => boolean);
|
|
19
20
|
private uiKey;
|
|
20
21
|
/**
|
|
21
22
|
* Settles a pending UI request by answering, timing out, or aborting.
|
|
@@ -11,9 +11,11 @@
|
|
|
11
11
|
*/
|
|
12
12
|
export class ExtensionUiService {
|
|
13
13
|
broadcaster;
|
|
14
|
+
canAddressUser;
|
|
14
15
|
pendingUi = new Map();
|
|
15
|
-
constructor(broadcaster) {
|
|
16
|
+
constructor(broadcaster, canAddressUser = () => true) {
|
|
16
17
|
this.broadcaster = broadcaster;
|
|
18
|
+
this.canAddressUser = canAddressUser;
|
|
17
19
|
}
|
|
18
20
|
uiKey(conversationId, requestId) {
|
|
19
21
|
return `${conversationId}\u0000${requestId}`;
|
|
@@ -62,24 +64,30 @@ export class ExtensionUiService {
|
|
|
62
64
|
const scoped = (request) => runId ? { ...request, requestId: `${runId}:${request.requestId}` } : request;
|
|
63
65
|
return {
|
|
64
66
|
notify: (request) => {
|
|
67
|
+
if (!this.canAddressUser(conversationId))
|
|
68
|
+
return;
|
|
65
69
|
this.broadcaster.broadcast({ type: "extension.ui", conversationId, request: scoped(request) });
|
|
66
70
|
},
|
|
67
|
-
ask: (request) =>
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
71
|
+
ask: async (request) => {
|
|
72
|
+
if (!this.canAddressUser(conversationId))
|
|
73
|
+
return { cancelled: true };
|
|
74
|
+
return new Promise((resolve) => {
|
|
75
|
+
const shown = scoped(request);
|
|
76
|
+
const key = this.uiKey(conversationId, shown.requestId);
|
|
77
|
+
// Only the Pi-declared `timeoutMs` is honoured. There is no safety net when Pi did not set
|
|
78
|
+
// one: a question Pi chose to leave open is a question the model is waiting on, and a
|
|
79
|
+
// fabricated cancel would be the model continuing on a false premise. The run-level
|
|
80
|
+
// teardown (stop / abort / shutdown) is the path that closes an unanswered ask.
|
|
81
|
+
const pending = { conversationId, request: shown, resolve };
|
|
82
|
+
if (shown.timeoutMs !== undefined) {
|
|
83
|
+
pending.timer = setTimeout(() => {
|
|
84
|
+
this.settleUi(key, { cancelled: true }, "timeout");
|
|
85
|
+
}, shown.timeoutMs);
|
|
86
|
+
}
|
|
87
|
+
this.pendingUi.set(key, pending);
|
|
88
|
+
this.broadcaster.broadcast({ type: "extension.ui", conversationId, request: shown });
|
|
89
|
+
});
|
|
90
|
+
},
|
|
83
91
|
};
|
|
84
92
|
}
|
|
85
93
|
}
|
|
@@ -19,8 +19,8 @@ import type { SessionOrchestratorService } from "./session-orchestrator-service.
|
|
|
19
19
|
* leader has no subordinates at all, so it is told the second half only - it must not decide
|
|
20
20
|
* alone either - and is never told about subordinates it does not have.
|
|
21
21
|
*/
|
|
22
|
-
export declare const STANDARD_LEADER_PROMPT = "\u4F60\u662F\
|
|
23
|
-
export declare const LIGHTWEIGHT_LEADER_PROMPT = "\u4F60\u662F\
|
|
22
|
+
export declare const STANDARD_LEADER_PROMPT = "\u4F60\u662F\u8D1F\u8D23\u9879\u76EE\u534F\u8C03\u7684 Leader\uFF0C\u8D1F\u8D23\u654F\u6377\u5F00\u53D1\u4E0E\u5C0F\u6B65\u4EA4\u4ED8\u3002\u7528\u6237\u662F\u9876\u5C42\u51B3\u7B56\u8005\uFF0C\u4F60\u81EA\u884C\u5904\u7406\u5185\u90E8\u534F\u8C03\uFF0C\u6CBF\u6C47\u62A5\u7EBF\u6C47\u603B\u8FDB\u5C55\u3001\u6210\u679C\u4E0E\u5FC5\u8981\u51B3\u7B56\u3002\u5F00\u7BC7\u4E0A\u4E0B\u6587\u5DF2\u7ED9\u51FA\u9879\u76EE\u76EE\u6807\u3001\u6A21\u5F0F\u3001\u5206\u5DE5\u4E0E\u5F53\u524D\u4EFB\u52A1\u6E05\u5355\uFF0C\u4E0D\u5FC5\u5148\u8C03\u7528 project(action=get) \u5C31\u80FD\u76F4\u63A5\u62C6\u89E3\u3001\u6D3E\u6D3B\u6216\u63A8\u8FDB\u3002\u5C0F\u9879\u76EE\u53EA\u62C6\u6700\u5C11\u5FC5\u8981\u4EFB\u52A1\uFF0C\u5927\u9879\u76EE\u6309\u4EA4\u4ED8\u8FB9\u754C\u5206\u5DE5\u3002\u7528 add_task \u767B\u8BB0\u4EFB\u52A1\uFF08\u660E\u786E\u76EE\u6807\u3001\u4EA4\u4ED8\u7269\u3001\u9A8C\u6536\u6807\u51C6\u3001\u4F9D\u8D56\uFF09\uFF1Badd_task / update_task \u65F6\u53EF\u4EE5\u5E26 executorProfile \u4E0E reviewerProfile\uFF08\u652F\u6301\u6307\u5B9A agentId\u3001cwd\u3001model\u3001thinkingLevel\u3001watchdogTimeoutSeconds\uFF09\uFF0C\u6309\u4EFB\u52A1\u6027\u8D28\u5C06\u6267\u884C\u4E0E\u590D\u6838\u59D4\u6D3E\u7ED9\u6700\u5408\u9002\u7684\u5458\u5DE5\uFF0C\u4E0D\u6307\u5B9A\u5219\u7EE7\u627F\u9879\u76EE\u9ED8\u8BA4\uFF1B\u9700\u8981\u7EE7\u7EED\u62C6\u89E3\u7684\u5DE5\u4F5C\u8BBE role=leader\uFF0C\u53F6\u5B50\u6267\u884C\u4EFB\u52A1\u8BBE role=executor\uFF0C\u5B50 Leader \u7528 parentTaskId \u767B\u8BB0\u81EA\u5DF1\u7684\u5B50\u4EFB\u52A1\uFF0Cdispatch \u7ACB\u5373\u542F\u52A8\u6267\u884C\u5B50\u4F1A\u8BDD\uFF1B\u4E0D\u8981\u7528 session_spawn/session_dispatch \u6216 task/workflow \u7ED5\u5F00\u9879\u76EE\u5206\u5DE5\u4E0E\u6C47\u62A5\u7EBF\u3002\u6536\u5230\u4EA4\u4ED8\u540E\u7528 request_review \u542F\u52A8\u72EC\u7ACB\u590D\u6838\u3002\u6D3E\u53D1\u540E\u5B50\u4F1A\u8BDD\u4F1A\u7ACB\u5373\u5F00\u59CB\u6267\u884C\u5E76\u5728\u5B8C\u6210\u540E\u81EA\u52A8\u56DE\u62A5\u7ED9\u4F60\uFF0C\u5C4A\u65F6\u7EE7\u7EED\u6D3E\u53D1 ready \u4EFB\u52A1\u3001\u590D\u6838\u5F85\u9A8C\u6536\u4EFB\u52A1\u6216\u6309 review.summary \u8FD4\u5DE5\uFF1B\u4E0D\u8981\u8F6E\u8BE2\u7B49\u5F85\uFF0C\u4E0D\u8981\u53CD\u590D\u65E0\u8FDB\u5C55\u91CD\u8BD5\uFF0C\u7B49\u5F85\u56DE\u62A5\u65F6\u76F4\u63A5\u7ED3\u675F\u5F53\u524D\u56DE\u590D\u3002\u7528 report \u767B\u8BB0\u5173\u952E\u8FDB\u5C55\u3002\u4F60\u7684\u4E0B\u5C5E\u7684\u5347\u7EA7\u5148\u5230\u4F60\u8FD9\u91CC\uFF1A\u4F60\u5728\u81EA\u5DF1\u8FD9\u4E00\u5C42\u5904\u7406\uFF0C\u80FD\u81EA\u5DF1\u89E3\u51B3\u7684\u81EA\u5DF1\u89E3\u51B3\uFF1B\u672C\u5C42\u89E3\u51B3\u4E0D\u4E86\u7684\u95EE\u9898\u624D\u7528 escalate\uFF1A\u6709\u7236\u4F1A\u8BDD\u5C31\u4EA4\u7ED9\u76F4\u5C5E\u7236\u4F1A\u8BDD\uFF0C\u7531\u5B83\u5224\u65AD\u548C\u8F6C\u8FF0\uFF1B\u53EA\u6709\u9876\u5C42\u4F1A\u8BDD\u624D\u628A\u786E\u9700\u7528\u6237\u51B3\u5B9A\u7684\u95EE\u9898\u4EA4\u7ED9\u7528\u6237\u3002\u4F60\u4E0D\u80FD\u66FF Boss \u505A\u51B3\u5B9A\uFF0C\u4E5F\u4E0D\u8981\u628A\u6CA1\u5904\u7406\u7684\u5347\u7EA7\u538B\u4E0B\u53BB\u4E0D\u7406\u3002\u6240\u6709\u4EFB\u52A1\u9A8C\u6536\u540E\uFF0C\u7528 deliver \u8BB0\u5F55\u5E26\u8BC1\u636E\u7684\u9636\u6BB5\u4EA4\u4ED8\uFF0C\u540E\u7EED\u53EF\u7EE7\u7EED\u6D3E\u53D1\u3002\u4E0A\u4E0B\u6587\u6709\u9650\uFF0C\u660E\u786E\u5047\u8BBE\uFF0C\u4E3B\u52A8\u5BFB\u627E\u53CD\u8BC1\u3002\u53EA\u5728\u672C\u6B21\u89E6\u53D1\u8303\u56F4\u5185\u5DE5\u4F5C\u3002";
|
|
23
|
+
export declare const LIGHTWEIGHT_LEADER_PROMPT = "\u4F60\u662F\u8D1F\u8D23\u9879\u76EE\u534F\u8C03\u7684 Leader\uFF0C\u8FD9\u662F\u4E00\u4E2A\u8F7B\u91CF\u9879\u76EE\uFF1A\u8FD9\u4E2A\u9879\u76EE\u7531\u4F60\u4EB2\u81EA\u5B8C\u6210\uFF0C\u4E0D\u8981\u62C6\u5B50\u4EFB\u52A1\u3001\u4E0D\u8981\u6D3E\u53D1\u7ED9\u522B\u4EBA\u3001\u4E5F\u6CA1\u6709\u72EC\u7ACB\u590D\u6838\u3002\u5F00\u7BC7\u4E0A\u4E0B\u6587\u5DF2\u7ED9\u51FA\u9879\u76EE\u76EE\u6807\u3001\u6A21\u5F0F\u4E0E\u5F53\u524D\u4EFB\u52A1\u6E05\u5355\uFF0C\u4E0D\u5FC5\u5148\u8C03\u7528 project(action=get) \u5C31\u80FD\u76F4\u63A5\u52A8\u624B\u3002\u7528 add_task \u767B\u8BB0\u4EFB\u52A1\uFF08\u660E\u786E\u76EE\u6807\u3001\u4EA4\u4ED8\u7269\u3001\u9A8C\u6536\u6807\u51C6\u3001\u4F9D\u8D56\uFF09\uFF0C\u4EFB\u52A1\u4E00\u5F8B\u767B\u8BB0\u4E3A\u6267\u884C\u4EFB\u52A1\uFF1Arole=leader \u6216\u5E26 parentTaskId \u90FD\u4F1A\u88AB\u62D2\u7EDD\u3002dispatch \u4F1A\u628A\u4EFB\u52A1\u4EA4\u56DE\u7ED9\u4F60\u81EA\u5DF1\uFF0C\u4F60\u4EB2\u81EA\u505A\u5B8C\uFF1B\u505A\u5B8C\u540E\u8C03\u7528 project(action=submit, projectId, taskId, output, evidenceRefs) \u63D0\u4EA4\u4EA4\u4ED8\uFF0C\u63D0\u4EA4\u5373\u5B8C\u6210\uFF0C\u4E0D\u4F1A\u6709\u4EBA\u56DE\u6765\u590D\u6838\uFF0C\u8BC1\u636E\u5FC5\u987B\u9644\u4E0A\u3002\u4E0D\u8981\u7528 session_spawn/session_dispatch \u6216 task/workflow \u7ED5\u5F00\u9879\u76EE\u804C\u8D23\u4E0E\u6C47\u62A5\u7EBF\u3002\u4E0D\u8981\u8F6E\u8BE2\u7B49\u5F85\uFF0C\u4E0D\u8981\u53CD\u590D\u65E0\u8FDB\u5C55\u91CD\u8BD5\u3002\u7528 report \u6C47\u603B\u5173\u952E\u8FDB\u5C55\u3002\u666E\u901A\u6280\u672F\u51B3\u7B56\u3001\u963B\u585E\u4E0E\u8FD4\u5DE5\u7531\u4F60\u81EA\u884C\u5904\u7406\uFF1B\u672C\u5C42\u89E3\u51B3\u4E0D\u4E86\u7684\u4E8B\u624D\u7528 escalate\uFF1A\u6709\u7236\u4F1A\u8BDD\u5C31\u4EA4\u7ED9\u76F4\u5C5E\u7236\u4F1A\u8BDD\uFF0C\u7531\u5B83\u5224\u65AD\u548C\u8F6C\u8FF0\uFF1B\u53EA\u6709\u9876\u5C42\u4F1A\u8BDD\u624D\u628A\u786E\u9700\u7528\u6237\u51B3\u5B9A\u7684\u95EE\u9898\u4EA4\u7ED9\u7528\u6237\uFF0C\u4E0D\u5F97\u66FF Boss \u51B3\u5B9A\u8FD9\u4E9B\u4E8B\u9879\u3002\u6240\u6709\u4EFB\u52A1\u4EA4\u4ED8\u540E\uFF0C\u7528 deliver \u8BB0\u5F55\u5E26\u8BC1\u636E\u7684\u9636\u6BB5\u4EA4\u4ED8\uFF0C\u540E\u7EED\u53EF\u7EE7\u7EED\u6D3E\u53D1\u3002\u4E0A\u4E0B\u6587\u6709\u9650\uFF0C\u660E\u786E\u5047\u8BBE\uFF0C\u4E3B\u52A8\u5BFB\u627E\u53CD\u8BC1\u3002\u53EA\u5728\u672C\u6B21\u89E6\u53D1\u8303\u56F4\u5185\u5DE5\u4F5C\u3002";
|
|
24
24
|
export declare const profile: (value: unknown, label: string) => SessionProfile | undefined;
|
|
25
25
|
export declare const mergeProfile: (taskProfile?: SessionProfile, projectDefault?: SessionProfile) => SessionProfile | undefined;
|
|
26
26
|
/**
|
|
@@ -97,7 +97,7 @@ export declare class ProjectService {
|
|
|
97
97
|
*/
|
|
98
98
|
private readonly agents?;
|
|
99
99
|
private readonly queues;
|
|
100
|
-
constructor(store: Store, orchestrator?: (Pick<SessionOrchestratorService, "spawn" | "dispatch"> & Partial<Pick<SessionOrchestratorService, "stopSubtree">>) | undefined,
|
|
100
|
+
constructor(store: Store, orchestrator?: (Pick<SessionOrchestratorService, "spawn" | "dispatch" | "notifyChildCompleted"> & Partial<Pick<SessionOrchestratorService, "stopSubtree">>) | undefined,
|
|
101
101
|
/**
|
|
102
102
|
* Optional on purpose: a service built without an agent directory cannot tell a subagent from a
|
|
103
103
|
* custom agent, and it then behaves exactly as it did before this check existed. The real
|
|
@@ -107,6 +107,35 @@ export declare class ProjectService {
|
|
|
107
107
|
private publishContext;
|
|
108
108
|
shareContext(id: string, value: unknown, workspaceId: string, actor?: string): Promise<unknown>;
|
|
109
109
|
messageTask(id: string, taskId: string, content: string, workspaceId: string, actor?: string, targetConversationId?: string, deliveryMode?: string): Promise<unknown>;
|
|
110
|
+
/**
|
|
111
|
+
* A SUPERVISOR'S MESSAGE IS THE ANSWER TO THE EXCEPTION - NOT A FORMAL RULING.
|
|
112
|
+
*
|
|
113
|
+
* The reader's complaint was that a session kept saying 「等上面拍板」 long after the question
|
|
114
|
+
* had been settled in a real conversation: the supervisor had talked it through with the member
|
|
115
|
+
* and sent the follow-up instruction, and the platform was still waiting for a ceremony nobody
|
|
116
|
+
* had asked for. Communication is higher than protocol - when the supervisor the case is
|
|
117
|
+
* addressed to writes back to the member who raised it, the case IS answered.
|
|
118
|
+
*
|
|
119
|
+
* TWO THINGS ARE KEPT APART ON PURPOSE.
|
|
120
|
+
* - THE RECORD STAYS. The exception keeps its place in `p.escalations` with the answer, who
|
|
121
|
+
* answered and when. A decision record must not disappear when the project is cancelled.
|
|
122
|
+
* - THE STATE CHANGES. The session no longer says 「等上面拍板」, because nobody is waiting for
|
|
123
|
+
* anything any more: the answer is already on the member's desk.
|
|
124
|
+
*
|
|
125
|
+
* WHAT IS NOT SETTLED HERE, AND WHY:
|
|
126
|
+
* - A BOSS-LEVEL EXCEPTION IS NEVER SETTLED BY A MESSAGE. That case asks the Boss himself, and
|
|
127
|
+
* no team member has the authority to answer it - `resolveEscalation` enforces the very same
|
|
128
|
+
* rule for the panel and the tool, and it must hold for a message too.
|
|
129
|
+
* - A RETURNED EXCEPTION IS NOT REVIVED BY A MESSAGE. A returned case means the member was
|
|
130
|
+
* asked for more material; that material comes back as a NEW exception, not as the old one
|
|
131
|
+
* coming back to life.
|
|
132
|
+
* - ONLY THE DESIGNATED DIRECT SUPERVISOR ANSWERS. `targetConversationId` is the supervisor
|
|
133
|
+
* the case is addressed to, so a message from anybody else is somebody else's business.
|
|
134
|
+
* - AND THE REPLY HAS TO REACH THE MEMBER WHO RAISED IT. A supervisor who writes to somebody
|
|
135
|
+
* else has not answered this case, and settling it would repeat the mistake this project
|
|
136
|
+
* already made once: one answer closing every case of that member at once.
|
|
137
|
+
*/
|
|
138
|
+
private settleEscalationsByMessage;
|
|
110
139
|
getContext(id: string | undefined, workspaceId: string, actor?: string, taskId?: string, contextIds?: unknown): unknown;
|
|
111
140
|
private coordinationHints;
|
|
112
141
|
private assertWriteScope;
|
|
@@ -243,6 +272,7 @@ export declare class ProjectService {
|
|
|
243
272
|
private requiredComplete;
|
|
244
273
|
private task;
|
|
245
274
|
private member;
|
|
275
|
+
private canAddressUser;
|
|
246
276
|
isMember(p: Project, actor?: string): boolean;
|
|
247
277
|
directSupervisor(p: Project, actor?: string, taskId?: string): string | undefined;
|
|
248
278
|
/**
|
|
@@ -327,6 +357,21 @@ export declare class ProjectService {
|
|
|
327
357
|
summary?: string;
|
|
328
358
|
evidenceRefs?: string[];
|
|
329
359
|
}, workspaceId: string, actor?: string): Promise<ProjectTask>;
|
|
360
|
+
/**
|
|
361
|
+
* THE TASK IS DONE, SO THE LEADER IS WOKEN - AND IT IS NOT TOLD WHAT WAS DONE.
|
|
362
|
+
*
|
|
363
|
+
* The member's work is finished, and the member's direct parent - the Leader - has to hear
|
|
364
|
+
* about it: a Leader that is not told is a Leader that sits there with a finished employee.
|
|
365
|
+
*
|
|
366
|
+
* WHAT THE WAKE CARRIES IS THE TASK'S IDENTITY AND NOTHING ELSE. The delivery, the evidence and
|
|
367
|
+
* the review verdict stay where they are: in the project record and in the member's own
|
|
368
|
+
* session. A platform that wrote the summary here would be writing a report nobody checked, and
|
|
369
|
+
* the Leader is the one who is supposed to look and judge.
|
|
370
|
+
*
|
|
371
|
+
* THE COMPLETION IS THE UNIT, SO THE KNOCK HAPPENS ONCE. A task that is marked complete twice -
|
|
372
|
+
* a retried acceptance - is one piece of work, and the Leader is woken once for it.
|
|
373
|
+
*/
|
|
374
|
+
private notifyTaskCompleted;
|
|
330
375
|
updateTask(id: string, taskId: string, patch: Record<string, unknown> & {
|
|
331
376
|
workspaceId?: string;
|
|
332
377
|
}, actor?: string): Promise<ProjectTask>;
|
|
@@ -22,8 +22,8 @@ const stamp = () => new Date().toISOString();
|
|
|
22
22
|
* leader has no subordinates at all, so it is told the second half only - it must not decide
|
|
23
23
|
* alone either - and is never told about subordinates it does not have.
|
|
24
24
|
*/
|
|
25
|
-
export const STANDARD_LEADER_PROMPT = "
|
|
26
|
-
export const LIGHTWEIGHT_LEADER_PROMPT = "
|
|
25
|
+
export const STANDARD_LEADER_PROMPT = "你是负责项目协调的 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 登记关键进展。你的下属的升级先到你这里:你在自己这一层处理,能自己解决的自己解决;本层解决不了的问题才用 escalate:有父会话就交给直属父会话,由它判断和转述;只有顶层会话才把确需用户决定的问题交给用户。你不能替 Boss 做决定,也不要把没处理的升级压下去不理。所有任务验收后,用 deliver 记录带证据的阶段交付,后续可继续派发。上下文有限,明确假设,主动寻找反证。只在本次触发范围内工作。";
|
|
26
|
+
export const LIGHTWEIGHT_LEADER_PROMPT = "你是负责项目协调的 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 决定这些事项。所有任务交付后,用 deliver 记录带证据的阶段交付,后续可继续派发。上下文有限,明确假设,主动寻找反证。只在本次触发范围内工作。";
|
|
27
27
|
const text = (value, label) => {
|
|
28
28
|
if (typeof value !== "string" || !value.trim())
|
|
29
29
|
throw new Error(`${label} 不能为空`);
|
|
@@ -393,9 +393,67 @@ export class ProjectService {
|
|
|
393
393
|
this.admission(p);
|
|
394
394
|
const result = await this.dispatchContext(target, text(content, "补充指令"), { wait: false, mode: deliveryMode }, task.id);
|
|
395
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, "补充指令"));
|
|
396
400
|
return result;
|
|
397
401
|
});
|
|
398
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, existingIds) {
|
|
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 (existingIds && !existingIds.has(e.id))
|
|
438
|
+
continue;
|
|
439
|
+
if (e.status !== "open")
|
|
440
|
+
continue;
|
|
441
|
+
if ((e.audience ?? "boss") !== "supervisor")
|
|
442
|
+
continue;
|
|
443
|
+
if (e.targetConversationId !== actor)
|
|
444
|
+
continue;
|
|
445
|
+
if (e.requestedByConversationId !== target)
|
|
446
|
+
continue;
|
|
447
|
+
e.status = "resolved";
|
|
448
|
+
e.decision = answer;
|
|
449
|
+
e.resolvedAt = stamp();
|
|
450
|
+
e.resolvedByConversationId = actor;
|
|
451
|
+
this.event(p, "decision", `直接上级已答复例外(ID:${e.id}):${e.decision}`, e.taskId, actor);
|
|
452
|
+
settled += 1;
|
|
453
|
+
}
|
|
454
|
+
if (settled)
|
|
455
|
+
this.reconcile(p);
|
|
456
|
+
}
|
|
399
457
|
getContext(id, workspaceId, actor, taskId, contextIds) {
|
|
400
458
|
const p = id ? this.raw(id, workspaceId) : actor ? this.projectForSession(actor) : undefined;
|
|
401
459
|
if (!p)
|
|
@@ -575,6 +633,8 @@ export class ProjectService {
|
|
|
575
633
|
and the exported report all read the same corrected project, and none of them has to know
|
|
576
634
|
that the correction happened at all. */
|
|
577
635
|
this.reconcileInterrupted(p);
|
|
636
|
+
if (p.status === "awaiting_approval" && !p.escalations.some(item => item.status === "open" && item.severity === "high" && item.audience !== "supervisor"))
|
|
637
|
+
this.reconcile(p);
|
|
578
638
|
const resources = this.resources(p);
|
|
579
639
|
return {
|
|
580
640
|
...p,
|
|
@@ -829,6 +889,10 @@ export class ProjectService {
|
|
|
829
889
|
if (actor && actor !== p.ownerConversationId && actor !== p.initiatorConversationId && !p.tasks.some((t) => t.ownerConversationId === actor || t.reviewerConversationId === actor))
|
|
830
890
|
throw new Error("调用会话不属于项目执行团队");
|
|
831
891
|
}
|
|
892
|
+
canAddressUser(p, actor) {
|
|
893
|
+
return !actor || ((actor === p.ownerConversationId || actor === p.initiatorConversationId)
|
|
894
|
+
&& !this.store.conversation(actor)?.parentConversationId);
|
|
895
|
+
}
|
|
832
896
|
isMember(p, actor) {
|
|
833
897
|
if (!actor)
|
|
834
898
|
return false;
|
|
@@ -843,15 +907,16 @@ export class ProjectService {
|
|
|
843
907
|
return false;
|
|
844
908
|
}
|
|
845
909
|
directSupervisor(p, actor, taskId) {
|
|
846
|
-
if (!actor
|
|
910
|
+
if (!actor)
|
|
847
911
|
return undefined;
|
|
848
912
|
const session = this.store.conversation(actor);
|
|
849
|
-
const
|
|
850
|
-
if (
|
|
851
|
-
return
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
913
|
+
const parent = session?.parentConversationId ? this.store.conversation(session.parentConversationId) : undefined;
|
|
914
|
+
if (parent && !parent.archivedAt && parent.workspaceId === p.workspaceId && this.isMember(p, parent.id))
|
|
915
|
+
return parent.id;
|
|
916
|
+
if (actor === p.ownerConversationId || actor === p.initiatorConversationId)
|
|
917
|
+
return undefined;
|
|
918
|
+
const assigned = p.tasks.filter(item => item.ownerConversationId === actor || item.reviewerConversationId === actor);
|
|
919
|
+
const t = assigned.find(item => item.id === taskId) ?? assigned[0];
|
|
855
920
|
const manager = t ? this.manager(p, t) : undefined;
|
|
856
921
|
if (manager && this.isMember(p, manager))
|
|
857
922
|
return manager;
|
|
@@ -893,9 +958,8 @@ export class ProjectService {
|
|
|
893
958
|
const project = this.liveProjectForSession(conversationId);
|
|
894
959
|
if (!project)
|
|
895
960
|
return { ok: true };
|
|
896
|
-
if (
|
|
961
|
+
if (this.canAddressUser(project, conversationId))
|
|
897
962
|
return { ok: true };
|
|
898
|
-
}
|
|
899
963
|
return {
|
|
900
964
|
ok: false,
|
|
901
965
|
reason: "项目成员不能直接向 Boss 提问:请通过直接上级上报,由负责人代为转述",
|
|
@@ -910,10 +974,9 @@ export class ProjectService {
|
|
|
910
974
|
t.updatedAt = stamp();
|
|
911
975
|
this.event(p, "ready", `前置交付已验收:${t.title}`, t.id);
|
|
912
976
|
}
|
|
913
|
-
const isLeader = (convId) => !convId || convId === p.ownerConversationId || convId === p.initiatorConversationId;
|
|
914
977
|
const openBoss = p.escalations.filter((e) => e.status === "open" && (e.audience === "boss" || !e.audience));
|
|
915
|
-
const hasLeaderBlockedTask = p.tasks.some((t) => t.status === "blocked" &&
|
|
916
|
-
const lastLeaderProjectReport = [...p.reports].reverse().find((r) => !r.taskId &&
|
|
978
|
+
const hasLeaderBlockedTask = p.tasks.some((t) => t.status === "blocked" && this.canAddressUser(p, t.blockedReportedByConversationId));
|
|
979
|
+
const lastLeaderProjectReport = [...p.reports].reverse().find((r) => !r.taskId && this.canAddressUser(p, r.authorConversationId));
|
|
917
980
|
const leaderProjectBlocked = lastLeaderProjectReport?.kind === "blocked";
|
|
918
981
|
/* AN INTERRUPTED TASK BLOCKS THE PROJECT. Its execution session is gone, so nobody is working
|
|
919
982
|
on it and nobody will report back on it: the project is not "running", it is waiting for a
|
|
@@ -1662,7 +1725,8 @@ export class ProjectService {
|
|
|
1662
1725
|
});
|
|
1663
1726
|
}
|
|
1664
1727
|
async submit(id, taskId, input, workspaceId, actor) {
|
|
1665
|
-
|
|
1728
|
+
let completedOwner;
|
|
1729
|
+
const task = await this.change(id, workspaceId, (p) => {
|
|
1666
1730
|
this.live(p);
|
|
1667
1731
|
const t = this.task(p, taskId);
|
|
1668
1732
|
if (actor && actor !== t.ownerConversationId)
|
|
@@ -1687,6 +1751,7 @@ export class ProjectService {
|
|
|
1687
1751
|
claim that somebody else checked it. */
|
|
1688
1752
|
t.status = "completed";
|
|
1689
1753
|
t.updatedAt = stamp();
|
|
1754
|
+
completedOwner = t.ownerConversationId;
|
|
1690
1755
|
t.review = { verdict: "accepted", summary: "轻量项目:执行者自评交付,未做独立复核", evidenceRefs,
|
|
1691
1756
|
reviewerConversationId: t.ownerConversationId, createdAt: stamp(), lightweight: true };
|
|
1692
1757
|
this.syncDeliveryContext(p, t, actor);
|
|
@@ -1702,6 +1767,8 @@ export class ProjectService {
|
|
|
1702
1767
|
this.reconcile(p);
|
|
1703
1768
|
return ProjectService.taskView(t, p);
|
|
1704
1769
|
});
|
|
1770
|
+
await this.notifyTaskCompleted(completedOwner, taskId);
|
|
1771
|
+
return task;
|
|
1705
1772
|
}
|
|
1706
1773
|
async requestReview(id, taskId, workspaceId, actor) {
|
|
1707
1774
|
return this.change(id, workspaceId, async (p) => {
|
|
@@ -1736,7 +1803,8 @@ export class ProjectService {
|
|
|
1736
1803
|
});
|
|
1737
1804
|
}
|
|
1738
1805
|
async review(id, taskId, input, workspaceId, actor) {
|
|
1739
|
-
|
|
1806
|
+
let completedOwner;
|
|
1807
|
+
const task = await this.change(id, workspaceId, (p) => {
|
|
1740
1808
|
this.live(p);
|
|
1741
1809
|
const t = this.task(p, taskId);
|
|
1742
1810
|
if (!actor || actor !== t.reviewerConversationId || actor === t.ownerConversationId)
|
|
@@ -1751,11 +1819,39 @@ export class ProjectService {
|
|
|
1751
1819
|
t.review = { verdict: input.verdict, summary: text(input.summary, "复核意见"), evidenceRefs, reviewerConversationId: actor, createdAt: stamp() };
|
|
1752
1820
|
t.status = input.verdict === "accepted" ? "completed" : "ready";
|
|
1753
1821
|
t.updatedAt = stamp();
|
|
1822
|
+
if (t.status === "completed")
|
|
1823
|
+
completedOwner = t.ownerConversationId;
|
|
1754
1824
|
this.syncDeliveryContext(p, t, actor);
|
|
1755
1825
|
this.event(p, "reviewed", `${input.verdict === "accepted" ? "验收通过" : "退回返工"}:${t.title};${t.review.summary}`, t.id, actor);
|
|
1756
1826
|
this.reconcile(p);
|
|
1757
1827
|
return ProjectService.taskView(t, p);
|
|
1758
1828
|
});
|
|
1829
|
+
await this.notifyTaskCompleted(completedOwner, taskId);
|
|
1830
|
+
return task;
|
|
1831
|
+
}
|
|
1832
|
+
/**
|
|
1833
|
+
* THE TASK IS DONE, SO THE LEADER IS WOKEN - AND IT IS NOT TOLD WHAT WAS DONE.
|
|
1834
|
+
*
|
|
1835
|
+
* The member's work is finished, and the member's direct parent - the Leader - has to hear
|
|
1836
|
+
* about it: a Leader that is not told is a Leader that sits there with a finished employee.
|
|
1837
|
+
*
|
|
1838
|
+
* WHAT THE WAKE CARRIES IS THE TASK'S IDENTITY AND NOTHING ELSE. The delivery, the evidence and
|
|
1839
|
+
* the review verdict stay where they are: in the project record and in the member's own
|
|
1840
|
+
* session. A platform that wrote the summary here would be writing a report nobody checked, and
|
|
1841
|
+
* the Leader is the one who is supposed to look and judge.
|
|
1842
|
+
*
|
|
1843
|
+
* THE COMPLETION IS THE UNIT, SO THE KNOCK HAPPENS ONCE. A task that is marked complete twice -
|
|
1844
|
+
* a retried acceptance - is one piece of work, and the Leader is woken once for it.
|
|
1845
|
+
*/
|
|
1846
|
+
async notifyTaskCompleted(ownerConversationId, taskId) {
|
|
1847
|
+
if (!ownerConversationId || !this.orchestrator)
|
|
1848
|
+
return;
|
|
1849
|
+
try {
|
|
1850
|
+
await this.orchestrator.notifyChildCompleted(ownerConversationId, { unit: `task:${taskId}` });
|
|
1851
|
+
}
|
|
1852
|
+
catch (error) {
|
|
1853
|
+
console.warn(`Super Pi: 任务 ${taskId} 已完成,但叫不醒直属上级:${error instanceof Error ? error.message : String(error)}`);
|
|
1854
|
+
}
|
|
1759
1855
|
}
|
|
1760
1856
|
async updateTask(id, taskId, patch, actor) {
|
|
1761
1857
|
const result = await this.change(id, patch.workspaceId, async (p) => {
|
|
@@ -1949,7 +2045,8 @@ export class ProjectService {
|
|
|
1949
2045
|
const t = input.taskId ? this.task(p, text(input.taskId, "任务 id")) : undefined;
|
|
1950
2046
|
if (t && ["completed", "cancelled"].includes(t.status) && input.kind === "blocked")
|
|
1951
2047
|
throw new Error("已结束的任务不能标记阻塞");
|
|
1952
|
-
|
|
2048
|
+
const projectContact = actor === p.ownerConversationId || (!t && actor === p.initiatorConversationId);
|
|
2049
|
+
if (actor && !projectContact && (!t || ![t.ownerConversationId, t.reviewerConversationId, this.manager(p, t)].includes(actor)))
|
|
1953
2050
|
throw new Error("仅可汇报本人负责的任务");
|
|
1954
2051
|
const report = { id: randomUUID(), projectId: id, taskId: t?.id, authorConversationId: actor, kind: input.kind,
|
|
1955
2052
|
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, "风险"),
|
|
@@ -1963,7 +2060,7 @@ export class ProjectService {
|
|
|
1963
2060
|
t.blockedReportedByConversationId = actor;
|
|
1964
2061
|
t.updatedAt = stamp();
|
|
1965
2062
|
}
|
|
1966
|
-
if (actor &&
|
|
2063
|
+
if (actor && !this.canAddressUser(p, actor)) {
|
|
1967
2064
|
memberBlockedReport = true;
|
|
1968
2065
|
supervisorToWake = this.directSupervisor(p, actor, t?.id);
|
|
1969
2066
|
taskForWake = t;
|
|
@@ -1975,7 +2072,7 @@ export class ProjectService {
|
|
|
1975
2072
|
}, actor);
|
|
1976
2073
|
if (supervisorToWake) {
|
|
1977
2074
|
const taskInfo = taskForWake ? `任务 ${taskForWake.id}(${taskForWake.title})` : "所属任务";
|
|
1978
|
-
await this.wake(supervisorToWake, `下级成员(会话:${actor})汇报阻塞:${taskInfo}\n原因:${report.progress}\n
|
|
2075
|
+
await this.wake(supervisorToWake, `下级成员(会话:${actor})汇报阻塞:${taskInfo}\n原因:${report.progress}\n请先在本层处理;仍需上级协助时,收敛后沿汇报线转述。`, "阻塞上报", id, workspaceId, actor);
|
|
1979
2076
|
}
|
|
1980
2077
|
else if (memberBlockedReport) {
|
|
1981
2078
|
/* A MEMBER REPORTED A BLOCK AND NO SUPERVISOR COULD BE FOUND. The report is saved either
|
|
@@ -1997,7 +2094,7 @@ export class ProjectService {
|
|
|
1997
2094
|
const t = input.taskId
|
|
1998
2095
|
? this.task(p, text(input.taskId, "任务 id"))
|
|
1999
2096
|
: p.tasks.find((task) => task.ownerConversationId === actor || task.reviewerConversationId === actor);
|
|
2000
|
-
const isBossAudience =
|
|
2097
|
+
const isBossAudience = this.canAddressUser(p, actor);
|
|
2001
2098
|
const audience = isBossAudience ? "boss" : "supervisor";
|
|
2002
2099
|
let targetConversationId;
|
|
2003
2100
|
if (!isBossAudience) {
|
|
@@ -2035,7 +2132,7 @@ export class ProjectService {
|
|
|
2035
2132
|
return e;
|
|
2036
2133
|
}, actor);
|
|
2037
2134
|
if (supervisorToWake) {
|
|
2038
|
-
await this.wake(supervisorToWake, `下级成员(会话:${actor},身份:${wakeMemberRole ?? "执行者"})发起例外升级(ID:${result.id}):\n${result.title ? `待决问题:${result.title}\n` : ""}原因:${result.reason}\n严重级别:${result.severity}\n
|
|
2135
|
+
await this.wake(supervisorToWake, `下级成员(会话:${actor},身份:${wakeMemberRole ?? "执行者"})发起例外升级(ID:${result.id}):\n${result.title ? `待决问题:${result.title}\n` : ""}原因:${result.reason}\n严重级别:${result.severity}\n请先在本层处理。若仍需上级或用户作决定,由你收敛问题并发起新的升级。`, `例外升级(ID:${result.id})`, id, workspaceId, actor);
|
|
2039
2136
|
}
|
|
2040
2137
|
return result;
|
|
2041
2138
|
}
|
|
@@ -2132,23 +2229,7 @@ export class ProjectService {
|
|
|
2132
2229
|
}
|
|
2133
2230
|
}
|
|
2134
2231
|
else {
|
|
2135
|
-
const
|
|
2136
|
-
? p.tasks.find((t) => t.id === result.taskId)
|
|
2137
|
-
: p.tasks.find((t) => t.ownerConversationId === result.requestedByConversationId || t.reviewerConversationId === result.requestedByConversationId);
|
|
2138
|
-
let directLeaderId;
|
|
2139
|
-
if (targetTask) {
|
|
2140
|
-
if (targetTask.role === "leader" && targetTask.ownerConversationId) {
|
|
2141
|
-
directLeaderId = targetTask.ownerConversationId;
|
|
2142
|
-
}
|
|
2143
|
-
else if (targetTask.parentTaskId) {
|
|
2144
|
-
const parent = p.tasks.find((t) => t.id === targetTask.parentTaskId);
|
|
2145
|
-
directLeaderId = parent?.ownerConversationId ?? targetTask.accountableConversationId;
|
|
2146
|
-
}
|
|
2147
|
-
else {
|
|
2148
|
-
directLeaderId = targetTask.accountableConversationId ?? p.ownerConversationId;
|
|
2149
|
-
}
|
|
2150
|
-
}
|
|
2151
|
-
const recipientId = directLeaderId || p.ownerConversationId;
|
|
2232
|
+
const recipientId = result.requestedByConversationId ?? p.initiatorConversationId ?? p.ownerConversationId;
|
|
2152
2233
|
if (recipientId) {
|
|
2153
2234
|
await this.wake(recipientId, `Boss 已处理项目 ${p.id} 的例外:${result.reason}\n决策:${result.decision}\n先读取 project 最新状态,按决策继续范围内的工作。`, `例外处理结果(ID:${result.id})`, id, workspaceId, actor);
|
|
2154
2235
|
}
|
|
@@ -2296,7 +2377,11 @@ export class ProjectService {
|
|
|
2296
2377
|
}
|
|
2297
2378
|
if (!this.orchestrator)
|
|
2298
2379
|
throw new Error("会话编排服务未就绪");
|
|
2380
|
+
const existingIds = new Set(p.escalations.filter(item => item.status === "open" && item.audience === "supervisor"
|
|
2381
|
+
&& item.targetConversationId === actor && item.requestedByConversationId === target).map(item => item.id));
|
|
2299
2382
|
await this.dispatchContext(target, message, { wait: false });
|
|
2383
|
+
if (existingIds.size)
|
|
2384
|
+
await this.change(id, workspaceId, current => this.settleEscalationsByMessage(current, actor, target, message, existingIds));
|
|
2300
2385
|
return { ok: true, conversationId: target, delivered: true };
|
|
2301
2386
|
}
|
|
2302
2387
|
async tool(body, workspaceId, actor) {
|
|
@@ -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;
|
|
@@ -1955,7 +1961,13 @@ export class RunService {
|
|
|
1955
1961
|
this.broadcaster.broadcastState();
|
|
1956
1962
|
}
|
|
1957
1963
|
}
|
|
1958
|
-
|
|
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 }) {
|
|
1959
1971
|
const deliveryMode = parseMessageDeliveryMode(mode);
|
|
1960
1972
|
this.assertHistoryAvailable(conversationId);
|
|
1961
1973
|
/**
|
|
@@ -1973,7 +1985,7 @@ export class RunService {
|
|
|
1973
1985
|
if (clientId && this.store.hasMessage(conversationId, clientId))
|
|
1974
1986
|
return;
|
|
1975
1987
|
this.memory?.cancel(conversationId);
|
|
1976
|
-
if (!isLengthContinuation(content)) {
|
|
1988
|
+
if (source || !isLengthContinuation(content)) {
|
|
1977
1989
|
this.lengthContinuations.delete(conversationId);
|
|
1978
1990
|
await this.store.setWarningReason(conversationId, undefined).catch(() => undefined);
|
|
1979
1991
|
}
|
|
@@ -2019,7 +2031,10 @@ export class RunService {
|
|
|
2019
2031
|
}
|
|
2020
2032
|
let message;
|
|
2021
2033
|
try {
|
|
2022
|
-
|
|
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 });
|
|
2023
2038
|
}
|
|
2024
2039
|
catch (error) {
|
|
2025
2040
|
if (reservedController)
|
|
@@ -2054,7 +2069,7 @@ export class RunService {
|
|
|
2054
2069
|
try {
|
|
2055
2070
|
const currentConv = this.turnContext(conversationId).conversation;
|
|
2056
2071
|
await this.assertModelSupportsImages(currentConv, Boolean(validImages?.length), message.id);
|
|
2057
|
-
expanded = await expandAtReferences(this.store, workspace,
|
|
2072
|
+
expanded = await expandAtReferences(this.store, workspace, composePrompt(message));
|
|
2058
2073
|
}
|
|
2059
2074
|
catch (error) {
|
|
2060
2075
|
// EVERY REFUSAL ABOVE HAPPENS BEFORE A TURN EXISTS. The words are on screen and no model has seen
|