@evandu/super-pi 0.1.315 → 0.1.316
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/preload.cjs +4 -2
- package/dist/client/.super-pi-client-sources.json +30 -27
- package/dist/client/assets/{CodeMirrorEditor-CNkxpHoE.js → CodeMirrorEditor-NqtytHoW.js} +1 -1
- package/dist/client/assets/{GitDiffEditor-IgRl-QlD.js → GitDiffEditor-7sJVHsy2.js} +1 -1
- package/dist/client/assets/index-D9YZBpfH.css +1 -0
- package/dist/client/assets/index-GK8bikbc.js +363 -0
- package/dist/client/index.html +2 -2
- package/dist/server/application/rsi-repairs.d.ts +1 -1
- package/dist/server/application/rsi-repairs.js +14 -3
- package/dist/server/index.js +3 -3
- package/dist/server/types.d.ts +1 -0
- package/dist/server/ws-server.js +1 -0
- package/dist/shared/rsi.d.ts +2 -0
- package/package.json +1 -1
- package/dist/client/assets/index-BP3z0_br.css +0 -1
- package/dist/client/assets/index-COe1c4FI.js +0 -363
package/dist/client/index.html
CHANGED
|
@@ -8,9 +8,9 @@
|
|
|
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-GK8bikbc.js"></script>
|
|
12
12
|
<link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-XKyaHtl9.js">
|
|
13
|
-
<link rel="stylesheet" crossorigin href="/assets/index-
|
|
13
|
+
<link rel="stylesheet" crossorigin href="/assets/index-D9YZBpfH.css">
|
|
14
14
|
</head>
|
|
15
15
|
<body>
|
|
16
16
|
<div id="root"></div>
|
|
17
17
|
|
|
@@ -3,7 +3,7 @@ import type { GroupRsiReport } from "../../shared/group-chat.js";
|
|
|
3
3
|
import { type RsiRepairView, type RsiSource } from "../../shared/rsi.js";
|
|
4
4
|
export type RsiRepairHooks = {
|
|
5
5
|
discuss(source: RsiSource, title: string, prompt: string): Promise<string>;
|
|
6
|
-
send(conversationId: string, prompt: string): Promise<void>;
|
|
6
|
+
send(conversationId: string, prompt: string, requestId?: string): Promise<void>;
|
|
7
7
|
execute(conversationId: string, prompt: string): Promise<void>;
|
|
8
8
|
endExecution(conversationId: string): Promise<void>;
|
|
9
9
|
stop(conversationId: string): Promise<unknown>;
|
|
@@ -85,10 +85,13 @@ export class RsiRepairs {
|
|
|
85
85
|
return this.serial(async () => {
|
|
86
86
|
if (this.closed || !this.hooks)
|
|
87
87
|
throw new Error("当前服务不支持 RSI 讨论与修复。");
|
|
88
|
+
const requestId = typeof body.requestId === "string" && /^rsi_[0-9a-f-]{36}$/i.test(body.requestId) ? body.requestId : undefined;
|
|
88
89
|
const workspace = this.store.workspace(source.workspaceId);
|
|
89
90
|
if (!workspace || workspace.closedAt && body.action !== "rsi.repair.cancel")
|
|
90
91
|
throw new Error("请选择已打开的有效工作区。");
|
|
91
92
|
if (body.action === "rsi.repair.discuss") {
|
|
93
|
+
if (requestId && this.jobs.some(job => job.initialRequestId === requestId && rsiKey(job.source) === rsiKey(source)))
|
|
94
|
+
return;
|
|
92
95
|
const initialPrompt = typeof body.initialPrompt === "string" ? body.initialPrompt.trim() : "";
|
|
93
96
|
if (initialPrompt.length > 12000)
|
|
94
97
|
throw new Error("讨论开场内容不能超过 12000 字。");
|
|
@@ -106,7 +109,8 @@ export class RsiRepairs {
|
|
|
106
109
|
delete existing.error;
|
|
107
110
|
existing.updatedAt = new Date().toISOString();
|
|
108
111
|
await this.save();
|
|
109
|
-
await this.hooks.send(existing.conversationId, initialPrompt);
|
|
112
|
+
await this.hooks.send(existing.conversationId, initialPrompt, requestId);
|
|
113
|
+
existing.initialRequestId = requestId;
|
|
110
114
|
if (report) {
|
|
111
115
|
existing.observationSourceKey = report.sourceKey;
|
|
112
116
|
existing.reportId = report.id;
|
|
@@ -135,7 +139,7 @@ export class RsiRepairs {
|
|
|
135
139
|
const id = await this.hooks.discuss(source, title, prompt);
|
|
136
140
|
const now = new Date().toISOString();
|
|
137
141
|
this.jobs.push({ id: randomUUID(), source: { ...source }, reportId: report?.id, observationSourceKey: report?.sourceKey, title, conversationId: id, status: "discussing", createdAt: now, updatedAt: now,
|
|
138
|
-
initialMessageId: this.store.conversation(id)?.messages.find(message => message.role === "user")?.id, ...(initialPrompt ? { initialPrompt } : {}) });
|
|
142
|
+
initialMessageId: this.store.conversation(id)?.messages.find(message => message.role === "user")?.id, initialRequestId: requestId, ...(initialPrompt ? { initialPrompt } : {}) });
|
|
139
143
|
await this.save();
|
|
140
144
|
return;
|
|
141
145
|
}
|
|
@@ -145,6 +149,10 @@ export class RsiRepairs {
|
|
|
145
149
|
const conversation = this.store.conversation(job.conversationId);
|
|
146
150
|
if (!conversation || conversation.workspaceId !== source.workspaceId || conversation.archivedAt && body.action !== "rsi.repair.cancel")
|
|
147
151
|
throw new Error("修复会话不存在或已归档。");
|
|
152
|
+
if (requestId && body.action === "rsi.repair.approve" && job.approvedRequestId === requestId)
|
|
153
|
+
return;
|
|
154
|
+
if (requestId && body.action === "rsi.repair.send" && this.store.hasAcceptedSend(job.conversationId, `message_${requestId.slice(4)}`))
|
|
155
|
+
return;
|
|
148
156
|
if (body.action === "rsi.repair.cancel") {
|
|
149
157
|
if (["completed", "cancelled"].includes(job.status))
|
|
150
158
|
return;
|
|
@@ -163,6 +171,8 @@ export class RsiRepairs {
|
|
|
163
171
|
return;
|
|
164
172
|
}
|
|
165
173
|
if (body.action === "rsi.repair.accept") {
|
|
174
|
+
if (job.status === "completed")
|
|
175
|
+
return;
|
|
166
176
|
if (job.status !== "review")
|
|
167
177
|
throw new Error("修复尚未进入待验收状态。");
|
|
168
178
|
job.status = "completed";
|
|
@@ -182,7 +192,7 @@ export class RsiRepairs {
|
|
|
182
192
|
delete job.error;
|
|
183
193
|
job.updatedAt = new Date().toISOString();
|
|
184
194
|
await this.save();
|
|
185
|
-
await this.hooks.send(job.conversationId, message);
|
|
195
|
+
await this.hooks.send(job.conversationId, message, requestId);
|
|
186
196
|
return;
|
|
187
197
|
}
|
|
188
198
|
if (body.action !== "rsi.repair.approve")
|
|
@@ -208,6 +218,7 @@ export class RsiRepairs {
|
|
|
208
218
|
job.approvedPlan = plan;
|
|
209
219
|
job.updatedAt = job.approvedAt;
|
|
210
220
|
delete job.error;
|
|
221
|
+
job.approvedRequestId = requestId;
|
|
211
222
|
job.approvals = [...(job.approvals ?? []), { at: job.approvedAt, revision: view.revision, plan }];
|
|
212
223
|
try {
|
|
213
224
|
await this.save();
|
package/dist/server/index.js
CHANGED
|
@@ -367,12 +367,12 @@ const groupChatService = await GroupChatService.open(join(dataDir, "group-chats.
|
|
|
367
367
|
const { groupPrimaryExecutor, groupPrimaryLifecycle } = await import("./group-primary-executor.js");
|
|
368
368
|
runtime.setGroupMemberExecutor?.(groupPrimaryExecutor(store, runService, uploadsDir), groupPrimaryLifecycle(store, runService, id => runtime.disposeSessions?.(id) ?? Promise.resolve(), join(dataDir, "pi-sessions"), () => broadcaster.broadcastState()));
|
|
369
369
|
const userTools = await UserTools.open(join(dataDir, "user-capabilities"));
|
|
370
|
-
async function queueRsiConversation(id, prompt, authorized = false) {
|
|
370
|
+
async function queueRsiConversation(id, prompt, authorized = false, requestId) {
|
|
371
371
|
await new Promise((resolve, reject) => {
|
|
372
372
|
let accepted = false;
|
|
373
373
|
const acknowledge = () => { accepted = true; resolve(); };
|
|
374
374
|
const work = authorized ? runService.enqueueAuthorizedRsiRepair(id, prompt, acknowledge)
|
|
375
|
-
: runService.enqueueAndRun(id, prompt, undefined, undefined, crypto.randomUUID(), "queue", acknowledge);
|
|
375
|
+
: runService.enqueueAndRun(id, prompt, undefined, undefined, requestId ?? crypto.randomUUID(), "queue", acknowledge);
|
|
376
376
|
void work.catch(async (error) => {
|
|
377
377
|
if (!accepted)
|
|
378
378
|
reject(error);
|
|
@@ -408,7 +408,7 @@ const rsiService = await RsiService.open(join(dataDir, "rsi"), store, runtime, u
|
|
|
408
408
|
broadcaster.broadcastState();
|
|
409
409
|
return id;
|
|
410
410
|
},
|
|
411
|
-
async send(id, prompt) { await store.setConversationAgent(id, "rsi-discussion"); await queueRsiConversation(id, prompt); },
|
|
411
|
+
async send(id, prompt, requestId) { await store.setConversationAgent(id, "rsi-discussion"); await queueRsiConversation(id, prompt, false, requestId && `message_${requestId.slice(4)}`); },
|
|
412
412
|
async execute(id, prompt) { await queueRsiConversation(id, prompt, true); },
|
|
413
413
|
async endExecution(id) {
|
|
414
414
|
if (store.conversation(id)?.agentId === "rsi-repair")
|
package/dist/server/types.d.ts
CHANGED
package/dist/server/ws-server.js
CHANGED
|
@@ -621,6 +621,7 @@ export class WsServer {
|
|
|
621
621
|
safeSend(socket, JSON.stringify({
|
|
622
622
|
type: "error",
|
|
623
623
|
message: reason || "服务端没有说明这次失败的原因。",
|
|
624
|
+
...(command && "conversationId" in command && typeof command.conversationId === "string" ? { conversationId: command.conversationId } : {}),
|
|
624
625
|
...(isRecordedTurnFailure(error) ? { recordedTurnFailure: true } : {}),
|
|
625
626
|
}));
|
|
626
627
|
}
|
package/dist/shared/rsi.d.ts
CHANGED