@evandu/super-pi 0.1.271 → 0.1.272
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 +5 -5
- package/dist/client/assets/{CodeMirrorEditor-Q77Plbqw.js → CodeMirrorEditor-BOfFOmcv.js} +1 -1
- package/dist/client/assets/{GitDiffEditor-C0XYcNpE.js → GitDiffEditor-DaN0Ye4q.js} +1 -1
- package/dist/client/assets/{index-CoLvWsuI.js → index-BsfNx6DV.js} +5 -5
- package/dist/client/index.html +1 -1
- package/dist/server/application/run-service.js +2 -2
- package/dist/server/managed-model-adapter.js +10 -2
- package/dist/server/managed-servers.d.ts +1 -0
- package/dist/server/managed-servers.js +16 -4
- package/dist/server/turn-failure.d.ts +2 -0
- package/dist/server/turn-failure.js +11 -0
- package/dist/server/types.d.ts +1 -0
- package/dist/server/ws-server.js +2 -0
- package/dist/shared/managed-servers.d.ts +1 -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-BsfNx6DV.js"></script>
|
|
12
12
|
<link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-XKyaHtl9.js">
|
|
13
13
|
<link rel="stylesheet" crossorigin href="/assets/index-DV3qc1Hh.css">
|
|
14
14
|
</head>
|
|
@@ -6,7 +6,7 @@ import { readAgents } from "../agents.js";
|
|
|
6
6
|
import { verifyCapability } from "../capability.js";
|
|
7
7
|
import { capText, validateWorkflowPlan, workflowSummary } from "../workflow.js";
|
|
8
8
|
import { ensureNameIndex, recordWorkspacePath } from "../file-name-index.js";
|
|
9
|
-
import { formatTurnFailure, isLengthExceededError } from "../turn-failure.js";
|
|
9
|
+
import { formatTurnFailure, isLengthExceededError, recordedTurnFailure } from "../turn-failure.js";
|
|
10
10
|
import { isLengthContinuation, lengthContinuationText, MAX_LENGTH_CONTINUATIONS, buildLengthContinuationPrompt } from "../length-continuation.js";
|
|
11
11
|
import { describeThrownWithStack } from "../failure-text.js";
|
|
12
12
|
import { toWorkspaceRelative } from "../files.js";
|
|
@@ -2134,7 +2134,7 @@ export class RunService {
|
|
|
2134
2134
|
// A turn that broke is the failure the reader will complain about, and the banner only carries
|
|
2135
2135
|
// the sentence. The stack goes to the server log, where it can still be found.
|
|
2136
2136
|
console.error("Super Pi turn failed:", describeThrownWithStack(error));
|
|
2137
|
-
throw error;
|
|
2137
|
+
throw recordedTurnFailure(error);
|
|
2138
2138
|
}
|
|
2139
2139
|
finally {
|
|
2140
2140
|
this.releaseRunSlot(conversation.id, controller);
|
|
@@ -19,13 +19,21 @@ export async function managedProviderDefinitions(config) {
|
|
|
19
19
|
const latest = await readManagedModelConfig() ?? config;
|
|
20
20
|
const { signal, ...rest } = options ?? {};
|
|
21
21
|
const safeOptions = Object.fromEntries(Object.entries(rest).filter(([key, value]) => ["maxTokens", "temperature", "reasoning", "cacheRetention", "sessionId", "samplingParams", "thinkingBudgets"].includes(key) && typeof value !== "function"));
|
|
22
|
-
const response = await fetch(latest.endpoint, { method: "POST", signal, headers: { authorization: `Bearer ${latest.token}`, "content-type": "application/json" }, body: JSON.stringify({ provider: model.provider, modelId: model.id, context, options: safeOptions }) })
|
|
22
|
+
const response = await fetch(latest.endpoint, { method: "POST", signal, headers: { authorization: `Bearer ${latest.token}`, "content-type": "application/json" }, body: JSON.stringify({ provider: model.provider, modelId: model.id, context, options: safeOptions }) }).catch(cause => {
|
|
23
|
+
if (signal?.aborted)
|
|
24
|
+
throw cause;
|
|
25
|
+
throw new Error("本地模型通道未连接。请在管理电脑的服务器连接中检查模型通道,必要时完成 SSH 验证后重试。", { cause });
|
|
26
|
+
});
|
|
23
27
|
if (!response.ok || !response.body)
|
|
24
28
|
throw new Error(`本地模型通道不可用(${response.status}),请检查管理电脑和 SSH 连接`);
|
|
25
29
|
const reader = response.body.getReader(), decoder = new TextDecoder();
|
|
26
30
|
let pending = "", settled = false;
|
|
27
31
|
for (;;) {
|
|
28
|
-
const { done, value } = await reader.read()
|
|
32
|
+
const { done, value } = await reader.read().catch(cause => {
|
|
33
|
+
if (signal?.aborted)
|
|
34
|
+
throw cause;
|
|
35
|
+
throw new Error("模型通道在回复完成前断开,请重连后重试", { cause });
|
|
36
|
+
});
|
|
29
37
|
pending += decoder.decode(value, { stream: !done });
|
|
30
38
|
let end;
|
|
31
39
|
while ((end = pending.indexOf("\n")) >= 0) {
|
|
@@ -56,6 +56,7 @@ export declare class ManagedServers {
|
|
|
56
56
|
ssh: "offline" | "connecting" | "online" | "needsTrust" | "awaitingVerification";
|
|
57
57
|
service: "unknown" | "offline" | "online";
|
|
58
58
|
modelChannel: "offline" | "online";
|
|
59
|
+
modelChannelPaused?: boolean;
|
|
59
60
|
phase: "idle" | "connecting" | "needsTrust" | "awaitingVerification" | "deploying" | "ready" | "failed";
|
|
60
61
|
existingService?: {
|
|
61
62
|
running: boolean;
|
|
@@ -287,7 +287,7 @@ export class ManagedServers {
|
|
|
287
287
|
return client;
|
|
288
288
|
}
|
|
289
289
|
catch (cause) {
|
|
290
|
-
if (requestedVerification || controller.signal.aborted)
|
|
290
|
+
if (requestedVerification || controller.signal.aborted || cause instanceof Error && cause.message.startsWith("SSH 认证失败"))
|
|
291
291
|
this.authBlocked.add(id);
|
|
292
292
|
this.verifications.get(id)?.reject(cause instanceof Error ? cause : new Error("SSH 验证已结束"));
|
|
293
293
|
this.verifications.delete(id);
|
|
@@ -323,6 +323,8 @@ export class ManagedServers {
|
|
|
323
323
|
entry.profile.modelChannel = "online";
|
|
324
324
|
}
|
|
325
325
|
async restoreModelChannel(entry, client) {
|
|
326
|
+
if (entry.profile.modelChannelPaused)
|
|
327
|
+
return;
|
|
326
328
|
try {
|
|
327
329
|
await this.reverseModelChannel(entry, client);
|
|
328
330
|
if (entry.profile.service === "online")
|
|
@@ -707,6 +709,8 @@ export class ManagedServers {
|
|
|
707
709
|
delete entry.profile.error;
|
|
708
710
|
}
|
|
709
711
|
else if (action === "disconnectSsh") {
|
|
712
|
+
if (entry.installation)
|
|
713
|
+
entry.profile.modelChannelPaused = true;
|
|
710
714
|
this.authBlocked.add(id);
|
|
711
715
|
await this.cancelConnection(id);
|
|
712
716
|
this.clients.get(id)?.end();
|
|
@@ -744,7 +748,11 @@ export class ManagedServers {
|
|
|
744
748
|
}
|
|
745
749
|
else if (action === "connectSsh") {
|
|
746
750
|
entry.profile.enabled = true;
|
|
747
|
-
|
|
751
|
+
delete entry.profile.modelChannelPaused;
|
|
752
|
+
if (entry.installation && this.clients.has(id))
|
|
753
|
+
await this.restoreModelChannel(entry, this.clients.get(id));
|
|
754
|
+
else
|
|
755
|
+
this.startConnection(id);
|
|
748
756
|
}
|
|
749
757
|
else if (action === "sync") {
|
|
750
758
|
try {
|
|
@@ -784,8 +792,12 @@ export class ManagedServers {
|
|
|
784
792
|
return;
|
|
785
793
|
const client = this.clients.get(entry.profile.id);
|
|
786
794
|
if (await this.checkDirect(entry.profile.id)) {
|
|
787
|
-
if (entry.installation &&
|
|
788
|
-
|
|
795
|
+
if (entry.installation && !entry.profile.modelChannelPaused) {
|
|
796
|
+
if (client)
|
|
797
|
+
await this.restoreModelChannel(entry, client);
|
|
798
|
+
else if (!this.connecting.has(entry.profile.id) && !this.authBlocked.has(entry.profile.id) && entry.profile.fingerprint && entry.profile.ssh !== "needsTrust")
|
|
799
|
+
this.startConnection(entry.profile.id);
|
|
800
|
+
}
|
|
789
801
|
return;
|
|
790
802
|
}
|
|
791
803
|
if (this.connecting.has(entry.profile.id) || this.authBlocked.has(entry.profile.id) || entry.profile.ssh === "needsTrust")
|
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
const recordedFailures = new WeakSet();
|
|
2
|
+
export function recordedTurnFailure(error) {
|
|
3
|
+
const failure = error instanceof Error ? error : new Error(String(error));
|
|
4
|
+
recordedFailures.add(failure);
|
|
5
|
+
return failure;
|
|
6
|
+
}
|
|
7
|
+
export function isRecordedTurnFailure(error) {
|
|
8
|
+
return error instanceof Error && recordedFailures.has(error);
|
|
9
|
+
}
|
|
1
10
|
/**
|
|
2
11
|
* Translates a thrown error from the turn loop into a sentence a person reads.
|
|
3
12
|
*
|
|
@@ -22,6 +31,8 @@ export function formatTurnFailure(error) {
|
|
|
22
31
|
if (controllerAborted(error))
|
|
23
32
|
return "本轮任务已停止。";
|
|
24
33
|
const raw = error instanceof Error ? error.message : typeof error === "string" ? error : "";
|
|
34
|
+
if (/^(本地模型通道|模型通道在回复完成前断开)/.test(raw))
|
|
35
|
+
return raw;
|
|
25
36
|
const lower = raw.toLowerCase();
|
|
26
37
|
// PROVIDER QUOTA / RATE LIMIT - the only reason the user is in this branch is because Pi was
|
|
27
38
|
// answering them a moment ago and now the model will not let it. The action is "wait or change
|
package/dist/server/types.d.ts
CHANGED
package/dist/server/ws-server.js
CHANGED
|
@@ -2,6 +2,7 @@ import { isBrowserAuthorized } from "./browser-access.js";
|
|
|
2
2
|
import { WebSocket, WebSocketServer } from "ws";
|
|
3
3
|
import { isAuthorized, isLoopbackAddress } from "./http-server.js";
|
|
4
4
|
import { describeThrown, describeThrownWithStack } from "./failure-text.js";
|
|
5
|
+
import { isRecordedTurnFailure } from "./turn-failure.js";
|
|
5
6
|
/**
|
|
6
7
|
* A WebSocket is a live transport, not an unbounded queue. `ws.send()` only
|
|
7
8
|
* copies bytes into the socket's userland buffer; a browser that is frozen or
|
|
@@ -607,6 +608,7 @@ export class WsServer {
|
|
|
607
608
|
safeSend(socket, JSON.stringify({
|
|
608
609
|
type: "error",
|
|
609
610
|
message: reason || "服务端没有说明这次失败的原因。",
|
|
611
|
+
...(isRecordedTurnFailure(error) ? { recordedTurnFailure: true } : {}),
|
|
610
612
|
}));
|
|
611
613
|
}
|
|
612
614
|
finally {
|
|
@@ -46,6 +46,7 @@ export interface ManagedServerProfile {
|
|
|
46
46
|
ssh: "offline" | "connecting" | "online" | "needsTrust" | "awaitingVerification";
|
|
47
47
|
service: "unknown" | "offline" | "online";
|
|
48
48
|
modelChannel: "offline" | "online";
|
|
49
|
+
modelChannelPaused?: boolean;
|
|
49
50
|
phase: "idle" | "connecting" | "needsTrust" | "awaitingVerification" | "deploying" | "ready" | "failed";
|
|
50
51
|
verification?: SshVerification;
|
|
51
52
|
existingService?: {
|