@evandu/super-pi 0.1.275 → 0.1.276
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/desktop/shell-entries.cjs +14 -2
- package/dist/.super-pi-check-inputs.json +4 -0
- package/dist/client/.super-pi-client-sources.json +5 -5
- package/dist/client/assets/{CodeMirrorEditor-DJgZdigq.js → CodeMirrorEditor-WFfkDO6N.js} +1 -1
- package/dist/client/assets/{GitDiffEditor-DIRyUxnb.css → GitDiffEditor-DOFVNrEW.css} +1 -1
- package/dist/client/assets/{GitDiffEditor-lOnvlR42.js → GitDiffEditor-PPULzRIU.js} +3 -3
- package/dist/client/assets/{index-BWm699nV.js → index-BjauxoWZ.js} +15 -15
- package/dist/client/index.html +1 -1
- package/dist/server/application/run-service.d.ts +1 -0
- package/dist/server/application/run-service.js +33 -7
- package/dist/server/length-continuation.d.ts +2 -9
- package/dist/server/length-continuation.js +10 -10
- package/dist/server/pi-session-events.js +3 -1
- package/dist/server/turn-failure.d.ts +2 -0
- package/dist/server/turn-failure.js +15 -1
- package/dist/shared/output-recovery.d.ts +4 -0
- package/dist/shared/output-recovery.js +6 -0
- package/package.json +1 -1
package/dist/client/index.html
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
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-
|
|
11
|
+
<script type="module" crossorigin src="/assets/index-BjauxoWZ.js"></script>
|
|
12
12
|
<link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-XKyaHtl9.js">
|
|
13
13
|
<link rel="stylesheet" crossorigin href="/assets/index-CnNljc5p.css">
|
|
14
14
|
</head>
|
|
@@ -409,6 +409,7 @@ export declare class RunService {
|
|
|
409
409
|
enqueueAndRun(conversationId: string, content: string, images?: MessageImage[], attachments?: Message["attachments"], clientId?: string, mode?: MessageDeliveryMode, onAccepted?: () => void): Promise<void>;
|
|
410
410
|
enqueueReminder(conversationId: string, note: string): Promise<void>;
|
|
411
411
|
private enqueueMessage;
|
|
412
|
+
private recoverOutputLimit;
|
|
412
413
|
/**
|
|
413
414
|
* Steers a queued message into the in-flight turn.
|
|
414
415
|
*/
|
|
@@ -2109,14 +2109,10 @@ export class RunService {
|
|
|
2109
2109
|
if (isLengthExceededError(error)) {
|
|
2110
2110
|
const used = this.lengthContinuations.get(conversation.id) ?? 0;
|
|
2111
2111
|
if (used < MAX_LENGTH_CONTINUATIONS && !controller.signal.aborted) {
|
|
2112
|
-
|
|
2113
|
-
console.warn(`Super Pi turn was truncated by output limit (${used + 1}/${MAX_LENGTH_CONTINUATIONS}); auto-continuing silently.`);
|
|
2114
|
-
const lastAssistant = conversation.messages.filter((m) => m.role === "assistant").pop();
|
|
2115
|
-
const continuationPrompt = buildLengthContinuationPrompt(lastAssistant);
|
|
2116
|
-
// Auto continue without exposing warning banner to user
|
|
2112
|
+
// Read the current persisted turn, not the detached snapshot from before streaming.
|
|
2117
2113
|
queueMicrotask(() => {
|
|
2118
|
-
void this.
|
|
2119
|
-
console.warn("Super Pi
|
|
2114
|
+
void this.recoverOutputLimit(conversation.id, controller).catch(recoveryError => {
|
|
2115
|
+
console.warn("Super Pi output recovery failed:", describeThrownWithStack(recoveryError));
|
|
2120
2116
|
});
|
|
2121
2117
|
});
|
|
2122
2118
|
return;
|
|
@@ -2145,6 +2141,36 @@ export class RunService {
|
|
|
2145
2141
|
this.broadcaster.broadcastState();
|
|
2146
2142
|
}
|
|
2147
2143
|
}
|
|
2144
|
+
async recoverOutputLimit(conversationId, controller) {
|
|
2145
|
+
while (!controller.signal.aborted) {
|
|
2146
|
+
const used = this.lengthContinuations.get(conversationId) ?? 0;
|
|
2147
|
+
const current = this.store.conversation(conversationId);
|
|
2148
|
+
if (!current || current.archivedAt)
|
|
2149
|
+
return;
|
|
2150
|
+
const assistant = current.messages.filter(message => message.role === "assistant").at(-1);
|
|
2151
|
+
if (used >= MAX_LENGTH_CONTINUATIONS) {
|
|
2152
|
+
this.lengthContinuations.delete(conversationId);
|
|
2153
|
+
const hasAnswer = typeof assistant?.content === "string" && assistant.content.trim();
|
|
2154
|
+
await this.store.setStatus(conversationId, "idle");
|
|
2155
|
+
await this.store.setWarningReason(conversationId, hasAnswer
|
|
2156
|
+
? "模型多次达到输出额度上限,自动恢复后仍未完成。可以继续任务,或降低思考等级后重试。"
|
|
2157
|
+
: "模型在产生可见回答前耗尽输出额度,自动恢复未成功。额度可能用于推理或未完成的工具参数;请重试、降低思考等级或更换模型。");
|
|
2158
|
+
this.broadcaster.broadcastState();
|
|
2159
|
+
return;
|
|
2160
|
+
}
|
|
2161
|
+
this.lengthContinuations.set(conversationId, used + 1);
|
|
2162
|
+
try {
|
|
2163
|
+
await this.enqueueAndRunAsAgent(conversationId, buildLengthContinuationPrompt(assistant));
|
|
2164
|
+
return;
|
|
2165
|
+
}
|
|
2166
|
+
catch (error) {
|
|
2167
|
+
if (!isLengthExceededError(error)) {
|
|
2168
|
+
console.warn("Super Pi auto-continuation dispatch error:", describeThrownWithStack(error));
|
|
2169
|
+
return;
|
|
2170
|
+
}
|
|
2171
|
+
}
|
|
2172
|
+
}
|
|
2173
|
+
}
|
|
2148
2174
|
/**
|
|
2149
2175
|
* Steers a queued message into the in-flight turn.
|
|
2150
2176
|
*/
|
|
@@ -15,15 +15,8 @@
|
|
|
15
15
|
* WHY IT IS AN ORDER AND NOT A USER MESSAGE. The person never typed it, and a row under their name
|
|
16
16
|
* saying words they never said is the exact bug this ordering was built to avoid.
|
|
17
17
|
*/
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
*
|
|
21
|
-
* The browser renders a `tool` row by looking at the content, and it tells a delivered result
|
|
22
|
-
* (`<task ...>`) from an order (no envelope) by the same inspection. A continuation is neither: it
|
|
23
|
-
* is the system telling the session to keep writing, and it needs a third label - 「续写」 - because
|
|
24
|
-
* calling it a 「智能体下发」 order would say the system sent a task, which is not what happened.
|
|
25
|
-
*/
|
|
26
|
-
export declare const LENGTH_CONTINUATION_ENVELOPE = "continue_output";
|
|
18
|
+
import { LENGTH_CONTINUATION_ENVELOPE } from "../shared/output-recovery.js";
|
|
19
|
+
export { LENGTH_CONTINUATION_ENVELOPE };
|
|
27
20
|
/**
|
|
28
21
|
* Maximum number of automatic continuations allowed per task/turn before requiring manual intervention.
|
|
29
22
|
*/
|
|
@@ -23,7 +23,9 @@
|
|
|
23
23
|
* is the system telling the session to keep writing, and it needs a third label - 「续写」 - because
|
|
24
24
|
* calling it a 「智能体下发」 order would say the system sent a task, which is not what happened.
|
|
25
25
|
*/
|
|
26
|
-
|
|
26
|
+
import { stripInlineThinking } from "./inline-thinking.js";
|
|
27
|
+
import { LENGTH_CONTINUATION_ENVELOPE } from "../shared/output-recovery.js";
|
|
28
|
+
export { LENGTH_CONTINUATION_ENVELOPE };
|
|
27
29
|
/**
|
|
28
30
|
* Maximum number of automatic continuations allowed per task/turn before requiring manual intervention.
|
|
29
31
|
*/
|
|
@@ -77,20 +79,18 @@ export function hasUnclosedThinking(text) {
|
|
|
77
79
|
* anchor and prevents it from freezing or emitting a single polite word.
|
|
78
80
|
*/
|
|
79
81
|
export function buildLengthContinuationText(assistant) {
|
|
80
|
-
|
|
81
|
-
return LENGTH_CONTINUATION_TEXT;
|
|
82
|
+
const content = stripInlineThinking(typeof assistant?.content === "string" ? assistant.content : "").replace(/[\u200B-\u200D\uFEFF]/g, "").trim();
|
|
82
83
|
// Case 1: truncation happened inside tool call arguments
|
|
83
|
-
if (Array.isArray(assistant
|
|
84
|
-
const
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
84
|
+
if (Array.isArray(assistant?.toolCalls) && assistant.toolCalls.some(call => {
|
|
85
|
+
const tool = call;
|
|
86
|
+
return tool && (tool.preparing === true || tool.status === undefined);
|
|
87
|
+
})) {
|
|
88
|
+
return "上一次工具调用因参数超出单次长度上限未完整执行。请检查已有工具结果,仅重新发起未完成的调用,将写入或修改操作拆分为更小的批次(如使用分块写入或局部编辑模式),不要重复执行已成功的写入。";
|
|
88
89
|
}
|
|
89
90
|
// Case 2: textual output
|
|
90
|
-
const content = typeof assistant.content === "string" ? assistant.content : "";
|
|
91
91
|
const anchor = extractContinuationAnchor(content);
|
|
92
92
|
if (!anchor)
|
|
93
|
-
return
|
|
93
|
+
return "上一轮在产生可见回答前耗尽了模型输出额度,没有可续写的正文。请基于原始用户请求和已完成的工具结果继续完成任务,避免重复长篇推理,优先执行必要的小步骤或给出简洁回答;不要虚构已输出的内容或断点,不要重复执行已经成功的写入。";
|
|
94
94
|
if (hasUnclosedCodeBlock(content)) {
|
|
95
95
|
return `上一条代码因为达到单次输出上限在以下断点处被截断:\n\`\`\`\n${anchor}\n\`\`\`\n请直接紧接上述断点继续写完后续代码并闭合代码块,严禁寒暄,不要重复断点之前已经写过的代码。`;
|
|
96
96
|
}
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
*/
|
|
19
19
|
import { describeToolCall, describeToolCallArgs, extractPartialResultText, readQuestionCall } from "./tool-calls.js";
|
|
20
20
|
import { toolTargetPath } from "./file-changes.js";
|
|
21
|
-
import { LengthExceededError } from "./turn-failure.js";
|
|
21
|
+
import { LengthExceededError, isProviderQuotaError } from "./turn-failure.js";
|
|
22
22
|
/** Keeps only real strings, so a malformed queue snapshot cannot put objects into a broadcast. */
|
|
23
23
|
const textList = (value) => Array.isArray(value) ? value.filter((item) => typeof item === "string") : undefined;
|
|
24
24
|
/**
|
|
@@ -78,6 +78,8 @@ export function describeMessageFailure(record) {
|
|
|
78
78
|
if (!message || typeof message !== "object" || message.role !== "assistant")
|
|
79
79
|
return undefined;
|
|
80
80
|
const text = typeof message.errorMessage === "string" ? message.errorMessage.trim() : "";
|
|
81
|
+
if (text && isProviderQuotaError(text))
|
|
82
|
+
return { message: text, stopReason: "error" };
|
|
81
83
|
if (message.stopReason === "error") {
|
|
82
84
|
return { message: text || "Pi 报告模型或服务提供方错误。", stopReason: "error" };
|
|
83
85
|
}
|
|
@@ -47,4 +47,6 @@ export declare class LengthExceededError extends Error {
|
|
|
47
47
|
* way up is exactly the case that used to kill a child session.
|
|
48
48
|
*/
|
|
49
49
|
export declare function isLengthExceededError(error: unknown): boolean;
|
|
50
|
+
/** An explicit provider limit overrides a contradictory output-length marker. */
|
|
51
|
+
export declare function isProviderQuotaError(error: unknown): boolean;
|
|
50
52
|
export declare function controllerAborted(error: unknown): boolean;
|
|
@@ -37,7 +37,9 @@ export function formatTurnFailure(error) {
|
|
|
37
37
|
// PROVIDER QUOTA / RATE LIMIT - the only reason the user is in this branch is because Pi was
|
|
38
38
|
// answering them a moment ago and now the model will not let it. The action is "wait or change
|
|
39
39
|
// model"; the wording has to make that obvious from the banner alone, without a tooltip.
|
|
40
|
-
if (
|
|
40
|
+
if (isProviderQuotaError(error)) {
|
|
41
|
+
if (/Token Plan.*用量上限|\(2056\)/i.test(raw))
|
|
42
|
+
return "模型额度已用完:供应商报告账户或套餐用量达到上限。请检查供应商控制台的用量,额度恢复后重试,或更换模型。";
|
|
41
43
|
return "模型额度已用完(5 小时限额或类似上限),Pi 已停止回答。可以等待重置后重试,或在会话里换一个模型再发。";
|
|
42
44
|
}
|
|
43
45
|
// RPC CHANNEL DEAD - Pi died without producing a `settled` event. Anything in the turn is now
|
|
@@ -142,6 +144,8 @@ export class LengthExceededError extends Error {
|
|
|
142
144
|
export function isLengthExceededError(error) {
|
|
143
145
|
if (!error)
|
|
144
146
|
return false;
|
|
147
|
+
if (isProviderQuotaError(error))
|
|
148
|
+
return false;
|
|
145
149
|
if (error instanceof LengthExceededError)
|
|
146
150
|
return true;
|
|
147
151
|
if (error?.stopReason === "length")
|
|
@@ -149,6 +153,16 @@ export function isLengthExceededError(error) {
|
|
|
149
153
|
const msg = error instanceof Error ? error.message : typeof error === "string" ? error : "";
|
|
150
154
|
return msg.includes("模型输出达到本轮长度上限") || msg.includes("达到本轮长度上限") || msg.includes("单次输出达到长度上限");
|
|
151
155
|
}
|
|
156
|
+
/** An explicit provider limit overrides a contradictory output-length marker. */
|
|
157
|
+
export function isProviderQuotaError(error) {
|
|
158
|
+
if (!error)
|
|
159
|
+
return false;
|
|
160
|
+
const record = error;
|
|
161
|
+
if (record.status === 429 || record.statusCode === 429)
|
|
162
|
+
return true;
|
|
163
|
+
const text = typeof error === "string" ? error : [record.message, record.errorMessage].filter(value => typeof value === "string").join("\n");
|
|
164
|
+
return /\b429\b|quota|rate[_ ]limit|usage limit|too many requests|5-hour|5h|resource_exhausted|resourc exhaust|hit your limit|usage cap|usage restrict|Token Plan.*(?:用量|上限)|用量上限|配额(?:耗尽|不足)|额度(?:已用完|耗尽|不足)|余额不足/i.test(text);
|
|
165
|
+
}
|
|
152
166
|
export function controllerAborted(error) {
|
|
153
167
|
if (!error)
|
|
154
168
|
return false;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const LENGTH_CONTINUATION_ENVELOPE = "continue_output";
|
|
2
|
+
export declare const MANUAL_OUTPUT_RECOVERY_TEXT = "\u8BF7\u57FA\u4E8E\u4E0A\u9762\u7684\u8BF7\u6C42\u3001\u5DF2\u8F93\u51FA\u7684\u5185\u5BB9\u548C\u5DF2\u5B8C\u6210\u7684\u64CD\u4F5C\u7EE7\u7EED\u5B8C\u6210\u4EFB\u52A1\u3002\u4F18\u5148\u7ED9\u51FA\u7B80\u6D01\u7ED3\u8BBA\u6216\u6267\u884C\u5FC5\u8981\u7684\u5C0F\u6B65\u9AA4\uFF0C\u4E0D\u8981\u91CD\u590D\u5DF2\u6709\u5185\u5BB9\u6216\u5DF2\u6210\u529F\u7684\u5199\u5165\u3002";
|
|
3
|
+
/** Decode a system recovery order without displaying its transport envelope. */
|
|
4
|
+
export declare function outputRecoveryText(content: string): string | undefined;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export const LENGTH_CONTINUATION_ENVELOPE = "continue_output";
|
|
2
|
+
export const MANUAL_OUTPUT_RECOVERY_TEXT = "请基于上面的请求、已输出的内容和已完成的操作继续完成任务。优先给出简洁结论或执行必要的小步骤,不要重复已有内容或已成功的写入。";
|
|
3
|
+
/** Decode a system recovery order without displaying its transport envelope. */
|
|
4
|
+
export function outputRecoveryText(content) {
|
|
5
|
+
return /^\s*<continue_output>([\s\S]*?)<\/continue_output>\s*$/.exec(content)?.[1].trim();
|
|
6
|
+
}
|