@evandu/super-pi 0.1.182 → 0.1.183
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/.super-pi-client-sources.json +1 -1
- package/dist/server/application/run-service.d.ts +7 -0
- package/dist/server/application/run-service.js +24 -2
- package/dist/server/http-server.js +4 -1
- package/dist/shared/child-session-lock.d.ts +8 -0
- package/dist/shared/child-session-lock.js +8 -0
- package/package.json +2 -1
|
@@ -40,5 +40,5 @@
|
|
|
40
40
|
"src/client/types.ts": "a39f30eafc1afa7b40dac4d8fe1f639f36234782877036722f66978e9b69d8e6",
|
|
41
41
|
"src/client/vite-env.d.ts": "65996936fbb042915f7b74a200fcdde7e410f32a669b1ab9597cfaa4b0faddb5"
|
|
42
42
|
},
|
|
43
|
-
"recordedAt": "2026-11-
|
|
43
|
+
"recordedAt": "2026-11-10T16:30:38.561Z"
|
|
44
44
|
}
|
|
@@ -92,6 +92,13 @@ export declare class RunService {
|
|
|
92
92
|
holdHistoryCut(conversationId: string): void;
|
|
93
93
|
releaseHistoryCut(conversationId: string): void;
|
|
94
94
|
private assertHistoryAvailable;
|
|
95
|
+
/**
|
|
96
|
+
* Whether a conversation is a child session with an active (unarchived) parent.
|
|
97
|
+
*
|
|
98
|
+
* Reuses the canonical judgement in `src/shared/child-session-lock.ts`: child sessions
|
|
99
|
+
* must report upwards via `session_report` rather than asking the user directly.
|
|
100
|
+
*/
|
|
101
|
+
private isChildConversation;
|
|
95
102
|
/**
|
|
96
103
|
* The completion of the run currently holding a conversation's slot.
|
|
97
104
|
*
|
|
@@ -11,6 +11,7 @@ import { describeThrownWithStack } from "../failure-text.js";
|
|
|
11
11
|
import { toWorkspaceRelative } from "../files.js";
|
|
12
12
|
import { refreshWorkspaceIndex } from "../file-index.js";
|
|
13
13
|
import { resolveSessionCwd } from "../session-cwd.js";
|
|
14
|
+
import { CHILD_QUESTION_LOCK_REASON, isChildSession } from "../../shared/child-session-lock.js";
|
|
14
15
|
import { execFile } from "node:child_process";
|
|
15
16
|
import { promisify } from "node:util";
|
|
16
17
|
import { randomUUID } from "node:crypto";
|
|
@@ -166,6 +167,16 @@ export class RunService {
|
|
|
166
167
|
if (this.historyCutClaims.has(conversationId))
|
|
167
168
|
throw new Error("正在撤回上一条消息,Pi 的历史还没截断完成,请等撤回结束后再发送。");
|
|
168
169
|
}
|
|
170
|
+
/**
|
|
171
|
+
* Whether a conversation is a child session with an active (unarchived) parent.
|
|
172
|
+
*
|
|
173
|
+
* Reuses the canonical judgement in `src/shared/child-session-lock.ts`: child sessions
|
|
174
|
+
* must report upwards via `session_report` rather than asking the user directly.
|
|
175
|
+
*/
|
|
176
|
+
isChildConversation(conversationId) {
|
|
177
|
+
const facts = this.store.childSessionFacts(conversationId);
|
|
178
|
+
return isChildSession(facts.parentConversationId, facts.parent);
|
|
179
|
+
}
|
|
169
180
|
/**
|
|
170
181
|
* The completion of the run currently holding a conversation's slot.
|
|
171
182
|
*
|
|
@@ -621,6 +632,17 @@ export class RunService {
|
|
|
621
632
|
* backfilled with `options[0]`.
|
|
622
633
|
*/
|
|
623
634
|
async askQuestion(conversationId) {
|
|
635
|
+
if (this.isChildConversation(conversationId)) {
|
|
636
|
+
const pending = this.store.pendingQuestion(conversationId);
|
|
637
|
+
if (pending) {
|
|
638
|
+
void this.store.updateToolCall(conversationId, pending.messageId, pending.index, {
|
|
639
|
+
question: { items: pending.question.items, status: "cancelled" },
|
|
640
|
+
}).then(() => {
|
|
641
|
+
this.broadcaster.broadcastState();
|
|
642
|
+
}).catch(() => { });
|
|
643
|
+
}
|
|
644
|
+
throw new Error(CHILD_QUESTION_LOCK_REASON);
|
|
645
|
+
}
|
|
624
646
|
// The HTTP callback belongs to the run that admitted it. A stop followed by a new turn clears
|
|
625
647
|
// the conversation's cancellation marker, but must never let an old polling ask bind its row.
|
|
626
648
|
const owner = this.activeRuns.get(conversationId);
|
|
@@ -1423,7 +1445,7 @@ export class RunService {
|
|
|
1423
1445
|
preparing: false,
|
|
1424
1446
|
at: callAt,
|
|
1425
1447
|
thinkingBlock: callThinkingBlock,
|
|
1426
|
-
...(call.question ? { question: call.question } : {}),
|
|
1448
|
+
...(call.question && !this.isChildConversation(conversation.id) ? { question: call.question } : {}),
|
|
1427
1449
|
}));
|
|
1428
1450
|
return;
|
|
1429
1451
|
}
|
|
@@ -1446,7 +1468,7 @@ export class RunService {
|
|
|
1446
1468
|
// must NOT be called once the answer has started - that would file an after-answer call between
|
|
1447
1469
|
// two stretches of reasoning that were never separated by one.
|
|
1448
1470
|
const callThinkingBlock = answerAfterThinking ? null : currentThinkingBlock();
|
|
1449
|
-
enqueueTools("a tool call", () => this.store.appendToolCall(conversation.id, assistant.id, { label: call.name, detail: call.detail, args: call.args, at, thinkingAt, thinkingBlock: callThinkingBlock, ...(call.question ? { question: call.question } : {}) }));
|
|
1471
|
+
enqueueTools("a tool call", () => this.store.appendToolCall(conversation.id, assistant.id, { label: call.name, detail: call.detail, args: call.args, at, thinkingAt, thinkingBlock: callThinkingBlock, ...(call.question && !this.isChildConversation(conversation.id) ? { question: call.question } : {}) }));
|
|
1450
1472
|
};
|
|
1451
1473
|
const onToolUpdate = (call) => {
|
|
1452
1474
|
if (!acceptsEvent("tool.update"))
|
|
@@ -26,6 +26,7 @@ import { FileIndex } from "./file-index.js";
|
|
|
26
26
|
import { ensureNameIndex, recordWorkspacePath } from "./file-name-index.js";
|
|
27
27
|
import { resolveSessionCwd, sessionScopeKey, workspacePathFromSession } from "./session-cwd.js";
|
|
28
28
|
import { verifyDirectChildScope, verifyListParentScope, verifyReportTargetScope, verifySpawnParentScope } from "./session-tree-scope.js";
|
|
29
|
+
import { CHILD_SESSION_LOCK_REASON } from "../shared/child-session-lock.js";
|
|
29
30
|
import { MAX_CONTENT_DEPTH, MAX_CONTENT_FILE_BYTES, MAX_CONTENT_RESULTS, searchByContent } from "./content-search.js";
|
|
30
31
|
import { getAvailableSkills, readSkill } from "./skills.js";
|
|
31
32
|
/**
|
|
@@ -2201,7 +2202,9 @@ export function createHttpServer(options) {
|
|
|
2201
2202
|
response.writeHead(200, { "content-type": "application/json" }).end(JSON.stringify(result));
|
|
2202
2203
|
}
|
|
2203
2204
|
catch (error) {
|
|
2204
|
-
|
|
2205
|
+
const errorText = describeThrown(error) || "问答失败,没有拿到失败原因。";
|
|
2206
|
+
const status = errorText.includes(CHILD_SESSION_LOCK_REASON) ? 403 : 400;
|
|
2207
|
+
response.writeHead(status, { "content-type": "application/json" }).end(JSON.stringify({ error: errorText }));
|
|
2205
2208
|
}
|
|
2206
2209
|
return;
|
|
2207
2210
|
}
|
|
@@ -7,6 +7,14 @@
|
|
|
7
7
|
* server must not disagree about what the rule is.
|
|
8
8
|
*/
|
|
9
9
|
export declare const CHILD_SESSION_LOCK_REASON = "\u6C47\u62A5\u7EBF\u53EA\u5141\u8BB8\u9010\u7EA7\u4E0A\u5347\uFF0C\u5B50\u4F1A\u8BDD\u9ED8\u8BA4\u4E0D\u80FD\u76F4\u63A5\u5BF9\u8BDD\uFF1B\u786E\u6709\u7279\u6B8A\u60C5\u51B5\u53EF\u89E3\u9501\u3002";
|
|
10
|
+
/**
|
|
11
|
+
* THE QUESTION LOCK SENTENCE.
|
|
12
|
+
*
|
|
13
|
+
* Child sessions must not use the `question` tool to ask the reader directly.
|
|
14
|
+
* When they need a human decision, they must report to their direct supervisor
|
|
15
|
+
* using `session_report`, which escalates through the reporting line.
|
|
16
|
+
*/
|
|
17
|
+
export declare const CHILD_QUESTION_LOCK_REASON = "\u6C47\u62A5\u7EBF\u53EA\u5141\u8BB8\u9010\u7EA7\u4E0A\u5347\uFF0C\u5B50\u4F1A\u8BDD\u9ED8\u8BA4\u4E0D\u80FD\u76F4\u63A5\u5BF9\u8BDD\uFF1B\u786E\u6709\u7279\u6B8A\u60C5\u51B5\u53EF\u89E3\u9501\u3002\u5B50\u4F1A\u8BDD\u8981\u7528 session_report \u5411\u76F4\u63A5\u4E0A\u7EA7\uFF08\u7236\u4F1A\u8BDD\uFF09\u6C47\u62A5\uFF0C\u7531\u7236\u4F1A\u8BDD\u9010\u7EA7\u8F6C\u8FF0\u3002";
|
|
10
18
|
/** The minimum a parent row has to expose for the judgement to be made. */
|
|
11
19
|
export type ChildSessionRow = {
|
|
12
20
|
id: string;
|
|
@@ -30,6 +30,14 @@
|
|
|
30
30
|
* server must not disagree about what the rule is.
|
|
31
31
|
*/
|
|
32
32
|
export const CHILD_SESSION_LOCK_REASON = "汇报线只允许逐级上升,子会话默认不能直接对话;确有特殊情况可解锁。";
|
|
33
|
+
/**
|
|
34
|
+
* THE QUESTION LOCK SENTENCE.
|
|
35
|
+
*
|
|
36
|
+
* Child sessions must not use the `question` tool to ask the reader directly.
|
|
37
|
+
* When they need a human decision, they must report to their direct supervisor
|
|
38
|
+
* using `session_report`, which escalates through the reporting line.
|
|
39
|
+
*/
|
|
40
|
+
export const CHILD_QUESTION_LOCK_REASON = `${CHILD_SESSION_LOCK_REASON}子会话要用 session_report 向直接上级(父会话)汇报,由父会话逐级转述。`;
|
|
33
41
|
/**
|
|
34
42
|
* Whether a conversation is a CHILD SESSION: it hangs under a parent that is still ALIVE.
|
|
35
43
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@evandu/super-pi",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.183",
|
|
4
4
|
"description": "Web control plane and companion for Pi",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -258,6 +258,7 @@
|
|
|
258
258
|
"scripts/primary-employee-guard.test.mjs",
|
|
259
259
|
"scripts/interrupted-task-recovery.test.mjs",
|
|
260
260
|
"scripts/child-session-lock.test.mjs",
|
|
261
|
+
"scripts/child-question-lock.test.mjs",
|
|
261
262
|
"scripts/session-reporting.test.mjs",
|
|
262
263
|
"scripts/mutation-lock-coverage.test.mjs"
|
|
263
264
|
],
|