@evandu/super-pi 0.1.293 → 0.1.294
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/.super-pi-check-inputs.json +4 -0
- package/dist/client/.super-pi-client-sources.json +14 -13
- package/dist/client/assets/CodeMirrorEditor-CJn8-fEi.js +2 -0
- package/dist/client/assets/CodeMirrorEditor-CxuPc1PQ.css +1 -0
- package/dist/client/assets/{GitDiffEditor-DP0DQ9Y5.css → GitDiffEditor-DUY8YwXS.css} +1 -1
- package/dist/client/assets/{GitDiffEditor-WONJq3t4.js → GitDiffEditor-cWxmXmgp.js} +3 -3
- package/dist/client/assets/index-B2EmFGB9.js +350 -0
- package/dist/client/assets/index-BJlhpC31.css +1 -0
- package/dist/client/index.html +2 -2
- package/dist/server/application/group-chat-service.d.ts +7 -0
- package/dist/server/application/group-chat-service.js +34 -2
- package/dist/server/application/run-service.d.ts +1 -0
- package/dist/server/application/run-service.js +3 -3
- package/dist/server/exec-service.js +27 -3
- package/dist/server/group-primary-executor.d.ts +1 -1
- package/dist/server/group-primary-executor.js +9 -2
- package/dist/server/http-server.js +9 -0
- package/dist/server/index.js +1 -1
- package/dist/server/runtime.d.ts +1 -0
- package/dist/server/runtime.js +1 -1
- package/dist/server/store.d.ts +4 -3
- package/dist/server/store.js +20 -4
- package/dist/shared/group-chat.d.ts +6 -0
- package/package.json +1 -1
- package/dist/client/assets/CodeMirrorEditor-7EW-C8kx.css +0 -1
- package/dist/client/assets/CodeMirrorEditor-CRYNvn14.js +0 -2
- package/dist/client/assets/index-B2HH9caF.css +0 -1
- package/dist/client/assets/index-MxsSEfDh.js +0 -350
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-B2EmFGB9.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-BJlhpC31.css">
|
|
14
14
|
</head>
|
|
15
15
|
<body>
|
|
16
16
|
<div id="root"></div>
|
|
@@ -97,12 +97,19 @@ export declare class GroupChatService {
|
|
|
97
97
|
memberModels?: unknown;
|
|
98
98
|
cloneLimit?: unknown;
|
|
99
99
|
}): Promise<GroupSnapshot>;
|
|
100
|
+
private requireImageModels;
|
|
101
|
+
uploadImage(workspaceId: string, id: string, input: {
|
|
102
|
+
name?: string;
|
|
103
|
+
mimeType?: string;
|
|
104
|
+
data?: string;
|
|
105
|
+
}): Promise<import("../upload.js").UploadRecord>;
|
|
100
106
|
send(workspaceId: string, id: string, input: {
|
|
101
107
|
content?: unknown;
|
|
102
108
|
clientId?: unknown;
|
|
103
109
|
memberIds?: unknown;
|
|
104
110
|
replyTo?: unknown;
|
|
105
111
|
filePaths?: unknown;
|
|
112
|
+
images?: unknown;
|
|
106
113
|
}): Promise<GroupSnapshot>;
|
|
107
114
|
stop(workspaceId: string, id: string, postId: string): Promise<GroupSnapshot>;
|
|
108
115
|
private kick;
|
|
@@ -6,6 +6,7 @@ import { DEFAULT_GROUP_MEMBER_IDS, groupTimeline } from "../../shared/group-chat
|
|
|
6
6
|
import { CODING_STANDARD_REQUEST } from "../active-memory.js";
|
|
7
7
|
import { applicableRules, assertModelAllowed } from "../model-filter.js";
|
|
8
8
|
import { replaceFile } from "../persistence/rename.js";
|
|
9
|
+
import { saveUpload, loadConversationImages, findUploadFile } from "../upload.js";
|
|
9
10
|
import { finishGroupExecution, GroupExecutionRecorder } from "./group-execution.js";
|
|
10
11
|
import { defaultGroupRsi, updateUnifiedObservation, parseRsiReport, rsiInput, rsiSourceKey, RSI_INSTRUCTIONS, rsiFailure } from "./group-rsi.js";
|
|
11
12
|
const MAX_AUTOMATIC_REPLIES = 10;
|
|
@@ -504,6 +505,23 @@ export class GroupChatService {
|
|
|
504
505
|
});
|
|
505
506
|
return this.get(workspaceId, id);
|
|
506
507
|
}
|
|
508
|
+
async requireImageModels(room) {
|
|
509
|
+
const catalog = await this.runtime.catalog();
|
|
510
|
+
const models = [room.moderator.model ?? this.workspace(room.workspaceId).defaultModel ?? catalog.defaultModel];
|
|
511
|
+
for (const member of room.members) {
|
|
512
|
+
const agent = await this.runtime.agentFor?.({ id: room.id, agentId: member.agentId ?? member.id });
|
|
513
|
+
models.push(member.model ?? agent?.model ?? this.workspace(room.workspaceId).defaultModel ?? catalog.defaultModel);
|
|
514
|
+
}
|
|
515
|
+
if (models.some(selection => !catalog.models.find(model => model.provider === selection?.provider && model.modelId === selection?.modelId)?.imageInput))
|
|
516
|
+
throw new Error("当前版本需要主持人及所有群成员的模型都支持图片输入,请先调整群聊模型。");
|
|
517
|
+
}
|
|
518
|
+
async uploadImage(workspaceId, id, input) {
|
|
519
|
+
const room = this.activeRoom(this.rooms, workspaceId, id);
|
|
520
|
+
await this.requireImageModels(room);
|
|
521
|
+
if (typeof input.mimeType !== "string" || typeof input.data !== "string")
|
|
522
|
+
throw new Error("缺少图片内容或格式");
|
|
523
|
+
return saveUpload(join(dirname(this.filePath), "uploads"), room.id, input.name, input.mimeType, input.data);
|
|
524
|
+
}
|
|
507
525
|
async send(workspaceId, id, input) {
|
|
508
526
|
if (this.closing)
|
|
509
527
|
throw new Error("服务正在关闭。");
|
|
@@ -512,6 +530,19 @@ export class GroupChatService {
|
|
|
512
530
|
if (!content || !clientId)
|
|
513
531
|
throw new Error("消息内容和发送标识不能为空。");
|
|
514
532
|
const current = this.activeRoom(this.rooms, workspaceId, id);
|
|
533
|
+
let images = Array.isArray(input.images) ? input.images : [];
|
|
534
|
+
if (images.length > 8 || images.some(image => !image || typeof image.id !== "string" || !/^[a-zA-Z0-9_-]+$/.test(image.id)))
|
|
535
|
+
throw new Error("群聊图片附件无效");
|
|
536
|
+
if (images.length) {
|
|
537
|
+
await this.requireImageModels(current);
|
|
538
|
+
images = await Promise.all(images.map(async (image) => {
|
|
539
|
+
const found = await findUploadFile(join(dirname(this.filePath), "uploads"), current.id, image.id);
|
|
540
|
+
if (!found)
|
|
541
|
+
throw new Error("群聊图片不存在,请重新上传");
|
|
542
|
+
return { id: image.id, mimeType: found.mimeType, bytes: found.size, name: typeof image.name === "string" ? image.name.slice(0, 120) : "群聊图片" };
|
|
543
|
+
}));
|
|
544
|
+
await loadConversationImages(join(dirname(this.filePath), "uploads"), current.id, images, { required: true });
|
|
545
|
+
}
|
|
515
546
|
if (current.messages.some(post => post.role === "user" && post.clientId === clientId))
|
|
516
547
|
return this.get(workspaceId, id);
|
|
517
548
|
const files = await readReferences(this.workspace(workspaceId).path, input.filePaths);
|
|
@@ -531,7 +562,7 @@ export class GroupChatService {
|
|
|
531
562
|
}
|
|
532
563
|
if (!memberIds.length && parent?.role === "assistant" && room.members.some(member => member.id === parent.memberId))
|
|
533
564
|
memberIds.push(parent.memberId);
|
|
534
|
-
room.messages.push({ id: randomUUID(), role: "user", clientId, content, files, memberIds, replyTo: parent?.id, createdAt: timestamp(), status: "queued" });
|
|
565
|
+
room.messages.push({ id: randomUUID(), role: "user", clientId, content, files, images, memberIds, replyTo: parent?.id, createdAt: timestamp(), status: "queued" });
|
|
535
566
|
room.updatedAt = timestamp();
|
|
536
567
|
room.revision += 1;
|
|
537
568
|
});
|
|
@@ -1001,7 +1032,7 @@ export class GroupChatService {
|
|
|
1001
1032
|
performed, handoffs, members: room.members, cloneRequests: room.cloneRequests, busyMembers: [...busy], workInProgress, remainingReplies, messages: context });
|
|
1002
1033
|
try {
|
|
1003
1034
|
const anchors = new Set([topic.id, ...context.map(post => post.id), ...replies.filter(post => post.status === "failed").map(post => post.id)]);
|
|
1004
|
-
const ask = async (instructions) => route(await this.complete(room, { prompt: [...instructions, payload].join("\n"), model: room.moderator.model, signal, timeoutMs: 35_000 }), candidates, anchors);
|
|
1035
|
+
const ask = async (instructions) => route(await this.complete(room, { images: topic.images?.length ? await loadConversationImages(join(dirname(this.filePath), "uploads"), room.id, topic.images, { required: true }) : undefined, prompt: [...instructions, payload].join("\n"), model: room.moderator.model, signal, timeoutMs: 35_000 }), candidates, anchors);
|
|
1005
1036
|
let decision = await ask(prompt);
|
|
1006
1037
|
if (decision.action === "finish" && !decision.reason && handoffs.length && !signal.aborted) {
|
|
1007
1038
|
decision = await ask([...prompt, "还有尚未接手的交接。检查它与用户目标的关系,安排接手或说明为什么结束。"]);
|
|
@@ -1133,6 +1164,7 @@ export class GroupChatService {
|
|
|
1133
1164
|
JSON.stringify({ request: topic.content, files: topic.files, replyTo: reply.replyTo, quote: started.messages.find(post => post.id === reply.replyTo)?.content.slice(0, 4_000), assignment: reply.assignment, members: started.members, notes }),
|
|
1134
1165
|
].join("\n");
|
|
1135
1166
|
const answer = await this.complete(started, {
|
|
1167
|
+
images: topic.images?.length ? await loadConversationImages(join(dirname(this.filePath), "uploads"), started.id, topic.images, { required: true }) : undefined,
|
|
1136
1168
|
onConversation: id => this.edit(rooms => { const post = this.find(rooms, started.workspaceId, roomId).messages.find(item => item.id === reply.id); if (post?.role === "assistant") {
|
|
1137
1169
|
post.executionConversationId = id;
|
|
1138
1170
|
this.find(rooms, started.workspaceId, roomId).revision++;
|
|
@@ -416,6 +416,7 @@ export declare class RunService {
|
|
|
416
416
|
enqueueAndRunAsAgent(conversationId: string, content: string, options?: {
|
|
417
417
|
mode?: MessageDeliveryMode;
|
|
418
418
|
onAccepted?: (messageId: string) => void;
|
|
419
|
+
images?: MessageImage[];
|
|
419
420
|
}): Promise<void>;
|
|
420
421
|
acknowledgeAcceptedSend(conversationId: string, clientId: string | undefined): Promise<boolean>;
|
|
421
422
|
enqueueAndRun(conversationId: string, content: string, images?: MessageImage[], attachments?: Message["attachments"], clientId?: string, mode?: MessageDeliveryMode, onAccepted?: () => void): Promise<void>;
|
|
@@ -1979,7 +1979,7 @@ export class RunService {
|
|
|
1979
1979
|
}
|
|
1980
1980
|
let message;
|
|
1981
1981
|
try {
|
|
1982
|
-
message = await this.store.addAgentMessage(conversationId, trimmed, { ...(queueOnly ? { delivery: "waiting" } : {}) });
|
|
1982
|
+
message = await this.store.addAgentMessage(conversationId, trimmed, { images: options?.images, ...(queueOnly ? { delivery: "waiting" } : {}) });
|
|
1983
1983
|
}
|
|
1984
1984
|
catch (error) {
|
|
1985
1985
|
if (reservedController)
|
|
@@ -2007,8 +2007,8 @@ export class RunService {
|
|
|
2007
2007
|
await this.store.setStatus(conversation.id, "stopped");
|
|
2008
2008
|
return;
|
|
2009
2009
|
}
|
|
2010
|
-
await this.assertModelSupportsImages(conversation,
|
|
2011
|
-
await this.runUntilDrained(conversation, workspace, composePrompt(message), controller, message.id);
|
|
2010
|
+
await this.assertModelSupportsImages(conversation, Boolean(message.images?.length), message.id);
|
|
2011
|
+
await this.runUntilDrained(conversation, workspace, composePrompt(message), controller, message.id, message.images);
|
|
2012
2012
|
// Turn completed cleanly without truncation; clear any stale warning and continuation tracking
|
|
2013
2013
|
this.lengthContinuations.delete(conversationId);
|
|
2014
2014
|
await this.store.setWarningReason(conversationId, undefined).catch(() => undefined);
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* bash commands without going through the subagent dispatch machinery.
|
|
7
7
|
*/
|
|
8
8
|
import { createRequire } from "node:module";
|
|
9
|
+
import { execFile } from "node:child_process";
|
|
9
10
|
import { BACKGROUND_LOG_LIMIT } from "../shared/background-task.js";
|
|
10
11
|
let ptyModule;
|
|
11
12
|
let ptyLoadFailure;
|
|
@@ -29,7 +30,7 @@ function ptyLoadError() {
|
|
|
29
30
|
return ptyLoadFailure;
|
|
30
31
|
}
|
|
31
32
|
const CHECKPOINT_INTERVAL_MS = 500;
|
|
32
|
-
const STOP_TIMEOUT_MS =
|
|
33
|
+
const STOP_TIMEOUT_MS = 5000;
|
|
33
34
|
export class ExecService {
|
|
34
35
|
onCheckpoint;
|
|
35
36
|
sessions = new Map();
|
|
@@ -124,9 +125,32 @@ export class ExecService {
|
|
|
124
125
|
if (!session)
|
|
125
126
|
return false;
|
|
126
127
|
this.kill(id, cancellation);
|
|
128
|
+
const escalation = setTimeout(() => {
|
|
129
|
+
if (this.sessions.get(id) !== session)
|
|
130
|
+
return;
|
|
131
|
+
if (!Number.isInteger(session.pty.pid) || session.pty.pid <= 1)
|
|
132
|
+
return;
|
|
133
|
+
if (process.platform === "win32")
|
|
134
|
+
execFile("taskkill.exe", ["/PID", String(session.pty.pid), "/T", "/F"], { windowsHide: true }, () => undefined);
|
|
135
|
+
else {
|
|
136
|
+
try {
|
|
137
|
+
process.kill(-session.pty.pid, "SIGKILL");
|
|
138
|
+
}
|
|
139
|
+
catch { /* The owned process group may already be gone. */ }
|
|
140
|
+
try {
|
|
141
|
+
session.pty.kill("SIGKILL");
|
|
142
|
+
}
|
|
143
|
+
catch { /* Already exited. */ }
|
|
144
|
+
}
|
|
145
|
+
}, 1500);
|
|
127
146
|
let timer;
|
|
128
|
-
|
|
129
|
-
|
|
147
|
+
try {
|
|
148
|
+
await Promise.race([session.ended, new Promise(resolve => { timer = setTimeout(resolve, STOP_TIMEOUT_MS); })]);
|
|
149
|
+
}
|
|
150
|
+
finally {
|
|
151
|
+
clearTimeout(timer);
|
|
152
|
+
clearTimeout(escalation);
|
|
153
|
+
}
|
|
130
154
|
if (this.sessions.get(id) === session)
|
|
131
155
|
throw new Error("后台命令尚未退出,可以重试终止。");
|
|
132
156
|
return true;
|
|
@@ -3,5 +3,5 @@ import type { RunService } from "./application/run-service.js";
|
|
|
3
3
|
import type { IsolatedCompletionInput } from "./runtime.js";
|
|
4
4
|
import type { GroupExecutionLifecycle } from "./runtime.js";
|
|
5
5
|
/** A group member is a normal primary execution, with a private durable conversation identity. */
|
|
6
|
-
export declare function groupPrimaryExecutor(store: Store, runs: RunService): (input: IsolatedCompletionInput, file: string) => Promise<string>;
|
|
6
|
+
export declare function groupPrimaryExecutor(store: Store, runs: RunService, uploadsDir?: string): (input: IsolatedCompletionInput, file: string) => Promise<string>;
|
|
7
7
|
export declare function groupPrimaryLifecycle(store: Store, runs: RunService, dispose: (id: string) => Promise<void>, sessionRoot: string, changed?: () => void): GroupExecutionLifecycle;
|
|
@@ -2,8 +2,9 @@ import { randomUUID } from "node:crypto";
|
|
|
2
2
|
import { isAbsolute, relative, resolve } from "node:path";
|
|
3
3
|
import { readTranscriptHeader } from "./pi-session.js";
|
|
4
4
|
import { rm } from "node:fs/promises";
|
|
5
|
+
import { saveUpload } from "./upload.js";
|
|
5
6
|
/** A group member is a normal primary execution, with a private durable conversation identity. */
|
|
6
|
-
export function groupPrimaryExecutor(store, runs) {
|
|
7
|
+
export function groupPrimaryExecutor(store, runs, uploadsDir) {
|
|
7
8
|
return async (input, file) => {
|
|
8
9
|
const scope = input.memberSession;
|
|
9
10
|
if (!scope || !input.agent)
|
|
@@ -62,7 +63,13 @@ export function groupPrimaryExecutor(store, runs) {
|
|
|
62
63
|
input.signal?.addEventListener("abort", abort, { once: true });
|
|
63
64
|
try {
|
|
64
65
|
input.signal?.throwIfAborted();
|
|
65
|
-
|
|
66
|
+
if (input.images?.length && !uploadsDir)
|
|
67
|
+
throw new Error("群聊图片存储尚未启用");
|
|
68
|
+
const images = await Promise.all((input.images ?? []).map(async (image) => {
|
|
69
|
+
const stored = await saveUpload(uploadsDir, id, "群聊图片", image.mimeType, image.data);
|
|
70
|
+
return { id: stored.id, name: stored.name, mimeType: stored.mimeType, bytes: stored.bytes };
|
|
71
|
+
}));
|
|
72
|
+
await runs.enqueueAndRunAsAgent(id, fresh ? `${input.prompt}\n群聊完整公开上下文:\n${JSON.stringify(scope.context)}` : input.prompt, { images });
|
|
66
73
|
observe();
|
|
67
74
|
input.signal?.throwIfAborted();
|
|
68
75
|
const current = store.conversation(id);
|
|
@@ -557,6 +557,15 @@ export function createHttpServer(options) {
|
|
|
557
557
|
return;
|
|
558
558
|
}
|
|
559
559
|
if (request.method === "POST") {
|
|
560
|
+
if (roomId && url.searchParams.get("upload") === "image") {
|
|
561
|
+
const input = await readRequestText(request, 8 * 1024 * 1024);
|
|
562
|
+
if (input.tooLarge) {
|
|
563
|
+
json(413, { error: "群聊图片过大" });
|
|
564
|
+
return;
|
|
565
|
+
}
|
|
566
|
+
json(200, await groups.uploadImage(workspaceId, roomId, JSON.parse(input.text)));
|
|
567
|
+
return;
|
|
568
|
+
}
|
|
560
569
|
const input = await readRequestText(request, 128_000);
|
|
561
570
|
if (input.tooLarge) {
|
|
562
571
|
json(413, { error: "群聊请求内容过大。" });
|
package/dist/server/index.js
CHANGED
|
@@ -363,7 +363,7 @@ void sessionOrchestratorService.restoreWatchdogs().catch((error) => {
|
|
|
363
363
|
});
|
|
364
364
|
const groupChatService = await GroupChatService.open(join(dataDir, "group-chats.json"), store, runtime, memory, update => broadcaster.broadcast({ type: "group.activity", ...update }));
|
|
365
365
|
const { groupPrimaryExecutor, groupPrimaryLifecycle } = await import("./group-primary-executor.js");
|
|
366
|
-
runtime.setGroupMemberExecutor?.(groupPrimaryExecutor(store, runService), groupPrimaryLifecycle(store, runService, id => runtime.disposeSessions?.(id) ?? Promise.resolve(), join(dataDir, "pi-sessions"), () => broadcaster.broadcastState()));
|
|
366
|
+
runtime.setGroupMemberExecutor?.(groupPrimaryExecutor(store, runService, uploadsDir), groupPrimaryLifecycle(store, runService, id => runtime.disposeSessions?.(id) ?? Promise.resolve(), join(dataDir, "pi-sessions"), () => broadcaster.broadcastState()));
|
|
367
367
|
const userTools = await UserTools.open(join(dataDir, "user-capabilities"));
|
|
368
368
|
async function queueRsiConversation(id, prompt) {
|
|
369
369
|
await new Promise((resolve, reject) => {
|
package/dist/server/runtime.d.ts
CHANGED
|
@@ -275,6 +275,7 @@ export type GroupExecutionLifecycle = {
|
|
|
275
275
|
forget(workspaceId: string, roomId: string): Promise<void>;
|
|
276
276
|
};
|
|
277
277
|
export type IsolatedCompletionInput = {
|
|
278
|
+
images?: import("./types.js").PiImageContent[];
|
|
278
279
|
onConversation?(conversationId: string): Promise<void> | void;
|
|
279
280
|
userToolContext?: {
|
|
280
281
|
id: string;
|
package/dist/server/runtime.js
CHANGED
|
@@ -2909,7 +2909,7 @@ export class PiRpcRuntime {
|
|
|
2909
2909
|
catch { /* Older worker protocols can retain their default; the wall-clock deadline still applies. */ }
|
|
2910
2910
|
}
|
|
2911
2911
|
input.signal?.throwIfAborted();
|
|
2912
|
-
channel.write({ id: "tool_llm", type: "prompt", message: input.prompt });
|
|
2912
|
+
channel.write({ id: "tool_llm", type: "prompt", message: input.prompt, ...(input.images?.length ? { images: input.images } : {}) });
|
|
2913
2913
|
awaitingCompletion = true;
|
|
2914
2914
|
let settled = false, text = "";
|
|
2915
2915
|
let failure, finalText;
|
package/dist/server/store.d.ts
CHANGED
|
@@ -499,7 +499,7 @@ export declare class Store {
|
|
|
499
499
|
* `composePrompt` in the run service). So the instruction reaches the model the same way, and the
|
|
500
500
|
* reader sees who spoke.
|
|
501
501
|
*/
|
|
502
|
-
addAgentMessage(conversationId: string, content: string, options?: Pick<Message, "delivery" | "source">): Promise<Message>;
|
|
502
|
+
addAgentMessage(conversationId: string, content: string, options?: Pick<Message, "delivery" | "source" | "images">): Promise<Message>;
|
|
503
503
|
addUserMessage(conversationId: string, content: string, images?: MessageImage[], attachments?: import("./types.js").MessageAttachments, options?: {
|
|
504
504
|
clientId?: string;
|
|
505
505
|
delivery?: Message["delivery"];
|
|
@@ -875,8 +875,9 @@ export declare class Store {
|
|
|
875
875
|
* THE INSERT POSITION IS THE WHOLE DESIGN. `push` was the old behaviour and it is only correct when the
|
|
876
876
|
* message being answered is the last thing in the conversation. With two messages waiting, answering
|
|
877
877
|
* the first by appending puts its reply BELOW the second one, so the reader sees the answer to a
|
|
878
|
-
* question that is still waiting - a transcript lying about its own order.
|
|
879
|
-
*
|
|
878
|
+
* question that is still waiting - a transcript lying about its own order.
|
|
879
|
+
* Moving the delivered message past completed turns and then inserting its answer keeps waiting
|
|
880
|
+
* rows below actual answers, even when a later-created interrupt was answered first.
|
|
880
881
|
*
|
|
881
882
|
* The side effects - title, `updatedAt`, `status: "waiting"`, clearing a stale failure - all describe a
|
|
882
883
|
* TURN rather than a message, which is why `addUserMessage` skips them for a message that is only
|
package/dist/server/store.js
CHANGED
|
@@ -1982,6 +1982,8 @@ export class Store {
|
|
|
1982
1982
|
const message = { id: id("message"), role: "tool", content, createdAt: now() };
|
|
1983
1983
|
if (options?.source)
|
|
1984
1984
|
message.source = options.source;
|
|
1985
|
+
if (options?.images?.length)
|
|
1986
|
+
message.images = structuredClone(options.images);
|
|
1985
1987
|
if (options?.delivery)
|
|
1986
1988
|
message.delivery = options.delivery;
|
|
1987
1989
|
conversation.messages.push(message);
|
|
@@ -2923,9 +2925,16 @@ export class Store {
|
|
|
2923
2925
|
const user = conversation.messages[index];
|
|
2924
2926
|
if ((user.role !== "user" && user.role !== "tool") || user.delivery !== "sending")
|
|
2925
2927
|
return undefined;
|
|
2928
|
+
// Delivery order owns transcript placement, regardless of when a waiting row was accepted.
|
|
2929
|
+
conversation.messages.splice(index, 1);
|
|
2930
|
+
let delivered = conversation.messages.length - 1;
|
|
2931
|
+
while (delivered >= 0 && conversation.messages[delivered].delivery)
|
|
2932
|
+
delivered--;
|
|
2933
|
+
const deliveryIndex = delivered + 1;
|
|
2934
|
+
conversation.messages.splice(deliveryIndex, 0, user);
|
|
2926
2935
|
delete user.delivery;
|
|
2927
2936
|
const assistant = { id: id("message"), role: "assistant", content: "", createdAt: now(), ...(agentIdentity ? { agentIdentity: structuredClone(agentIdentity) } : {}) };
|
|
2928
|
-
conversation.messages.splice(
|
|
2937
|
+
conversation.messages.splice(deliveryIndex + 1, 0, assistant);
|
|
2929
2938
|
await this.persistMessages(conversation);
|
|
2930
2939
|
return { user: structuredClone(user), assistant: structuredClone(assistant) };
|
|
2931
2940
|
}
|
|
@@ -2937,8 +2946,9 @@ export class Store {
|
|
|
2937
2946
|
* THE INSERT POSITION IS THE WHOLE DESIGN. `push` was the old behaviour and it is only correct when the
|
|
2938
2947
|
* message being answered is the last thing in the conversation. With two messages waiting, answering
|
|
2939
2948
|
* the first by appending puts its reply BELOW the second one, so the reader sees the answer to a
|
|
2940
|
-
* question that is still waiting - a transcript lying about its own order.
|
|
2941
|
-
*
|
|
2949
|
+
* question that is still waiting - a transcript lying about its own order.
|
|
2950
|
+
* Moving the delivered message past completed turns and then inserting its answer keeps waiting
|
|
2951
|
+
* rows below actual answers, even when a later-created interrupt was answered first.
|
|
2942
2952
|
*
|
|
2943
2953
|
* The side effects - title, `updatedAt`, `status: "waiting"`, clearing a stale failure - all describe a
|
|
2944
2954
|
* TURN rather than a message, which is why `addUserMessage` skips them for a message that is only
|
|
@@ -2951,9 +2961,15 @@ export class Store {
|
|
|
2951
2961
|
if (index < 0)
|
|
2952
2962
|
throw new Error(`消息不存在或已被撤回:${messageId}`);
|
|
2953
2963
|
const user = conversation.messages[index];
|
|
2964
|
+
conversation.messages.splice(index, 1);
|
|
2965
|
+
let delivered = conversation.messages.length - 1;
|
|
2966
|
+
while (delivered >= 0 && conversation.messages[delivered].delivery)
|
|
2967
|
+
delivered--;
|
|
2968
|
+
const deliveryIndex = delivered + 1;
|
|
2969
|
+
conversation.messages.splice(deliveryIndex, 0, user);
|
|
2954
2970
|
delete user.delivery;
|
|
2955
2971
|
const assistant = { id: id("message"), role: "assistant", content: "", createdAt: now(), ...(agentIdentity ? { agentIdentity: structuredClone(agentIdentity) } : {}) };
|
|
2956
|
-
conversation.messages.splice(
|
|
2972
|
+
conversation.messages.splice(deliveryIndex + 1, 0, assistant);
|
|
2957
2973
|
const firstUser = conversation.messages.find((item) => item.role === "user");
|
|
2958
2974
|
const autoTitle = firstUser?.content.trim()
|
|
2959
2975
|
? firstUser.content.slice(0, 42)
|
|
@@ -144,6 +144,12 @@ export type GroupUserPost = GroupPost & {
|
|
|
144
144
|
replyTo?: string;
|
|
145
145
|
clientId: string;
|
|
146
146
|
files?: GroupFileReference[];
|
|
147
|
+
images?: {
|
|
148
|
+
id: string;
|
|
149
|
+
name?: string;
|
|
150
|
+
mimeType: string;
|
|
151
|
+
bytes: number;
|
|
152
|
+
}[];
|
|
147
153
|
memoryNotice?: string;
|
|
148
154
|
};
|
|
149
155
|
export type GroupReply = GroupPost & {
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
.workbench-shell .cm-editor .cm-panels{background:var(--bg-panel);color:var(--text-primary)}.workbench-shell .cm-editor .cm-panels-top{border-bottom:1px solid var(--border-default)}.workbench-shell .cm-editor .cm-panel.cm-search{min-width:0;font-family:Manrope,system-ui,sans-serif;font-size:var(--type-control);line-height:var(--type-control-line);background:var(--bg-panel);color:var(--text-primary);flex-wrap:wrap;align-items:center;gap:6px 8px;padding:10px 46px 10px 12px;display:flex;position:relative}.workbench-shell .cm-editor .cm-search :is(input,button,label){font:inherit;margin:0}.workbench-shell .cm-editor .cm-search .cm-textfield{border:1px solid var(--border-default);width:220px;min-width:100px;max-width:340px;height:32px;color:var(--text-primary);background:var(--bg-input);box-shadow:none;border-radius:4px;flex:180px;padding:5px 8px}.workbench-shell .cm-editor .cm-search .cm-textfield::placeholder{color:var(--text-muted)}.workbench-shell .cm-editor .cm-search button{border:1px solid var(--border-default);min-height:32px;color:var(--text-primary);background:var(--bg-raised);box-shadow:none;cursor:pointer;background-image:none;border-radius:4px;flex:none;justify-content:center;align-items:center;padding:4px 8px;display:inline-flex}.workbench-shell .cm-editor .cm-search button:hover{background:var(--bg-hover)}.workbench-shell .cm-editor .cm-search label{white-space:nowrap;min-height:32px;color:var(--text-secondary);align-items:center;gap:5px;display:inline-flex}.workbench-shell .cm-editor .cm-search input[type=checkbox]{width:16px;height:16px;accent-color:var(--accent);cursor:pointer;margin:0}.workbench-shell .cm-editor .cm-search br{flex-basis:100%;height:0}.workbench-shell .cm-editor .cm-search button[name=close]{background:0 0;border-color:#0000;width:30px;height:32px;min-height:32px;padding:0;font-size:20px;line-height:1;position:absolute;top:10px;right:8px}.workbench-shell .cm-editor .cm-search button[name=close]:hover{background:var(--bg-hover)}.workbench-shell .cm-editor .cm-search :is(input,button):focus-visible{outline:2px solid var(--focus-ring);outline-offset:1px}.workbench-shell .cm-editor .cm-searchMatch{color:var(--editor-find-fg);background-color:var(--editor-find-bg);box-shadow:inset 0 0 0 1px var(--editor-find-border)}.workbench-shell .cm-editor .cm-searchMatch-selected{color:var(--editor-find-current-fg);background-color:var(--editor-find-current-bg);outline:1px solid var(--editor-find-current-border);box-shadow:inset 0 0 0 1px var(--editor-find-current-border)}.workbench-shell .cm-editor .cm-searchMatch span{color:inherit;background-color:#0000}@media (width<=700px){.workbench-shell .cm-editor .cm-panel.cm-search{padding-right:60px}.workbench-shell .cm-editor .cm-search :is(button,label){min-height:44px}.workbench-shell .cm-editor .cm-search .cm-textfield{height:44px}.workbench-shell .cm-editor .cm-search button[name=close]{width:44px;height:44px}}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/dist-D978o95T.js","assets/rolldown-runtime-XKyaHtl9.js","assets/dist-B3-a6uF0.js","assets/dist-CX_Hm4GS.js","assets/dist-Cus6_oaF.js","assets/dist-J6XWqRpB.js","assets/dist-scBkrwv-.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{d as t,f as n,i as r,l as i,p as a,r as o,u as s}from"./index-MxsSEfDh.js";var c=e(a(),1);function l(e,t){return[t.search({top:!0}),e.EditorState.phrases.of({Find:`查找`,Replace:`替换为`,next:`下一处`,previous:`上一处`,all:`全部选中`,"match case":`区分大小写`,regexp:`正则表达式`,"by word":`全词匹配`,replace:`替换`,"replace all":`全部替换`,close:`关闭查找`,"current match":`当前匹配`,"on line":`所在行`})]}var u=n(),d=262144,f=131072;function p(e){return e.split(`.`).pop()?.toLowerCase()??``}function m(e,t,n=!1){let r=e=>n?`var(--git-diff-${e.slice(5)}, var(${e}))`:`var(${e})`;return e.HighlightStyle.define([{tag:t.tags.keyword,color:r(`--cm-keyword`)},{tag:t.tags.string,color:r(`--cm-string`)},{tag:t.tags.number,color:r(`--cm-number`)},{tag:t.tags.comment,color:r(`--cm-comment`),fontStyle:`italic`},{tag:t.tags.function(t.tags.variableName),color:r(`--cm-function`)},{tag:t.tags.typeName,color:r(`--cm-type`)},{tag:t.tags.className,color:r(`--cm-type`)},{tag:t.tags.propertyName,color:r(`--cm-property`)},{tag:t.tags.operator,color:r(`--cm-operator`)},{tag:t.tags.variableName,color:r(`--cm-variable`)}])}function h({path:e,value:n,onChange:a,jumpToLine:h,onSave:g,workspaceId:_,blame:v,onPosition:y,readOnly:b=!1,languageOverride:x}){let S=(0,c.useRef)(null),C=(0,c.useRef)(null),w=(0,c.useRef)(null),T=(0,c.useRef)(void 0),E=(0,c.useRef)(null),D=(0,c.useRef)(null),O=(0,c.useRef)(null),k=(0,c.useRef)(null),A=(0,c.useRef)(null),j=(0,c.useRef)(null),M=(0,c.useRef)(a),N=(0,c.useRef)(g);M.current=a,N.current=g;let[P,F]=(0,c.useState)(!1),[I,L]=(0,c.useState)(!1),[R,z]=(0,c.useState)(`0,0`),[B,V]=(0,c.useState)(0);(0,c.useEffect)(()=>{let i=!1,a,o,c,u,f;return(async()=>{try{let h=x??p(e),g=s(h),[v,y,P,I,R,B,H,U]=await Promise.all([t(()=>import(`./dist-D978o95T.js`).then(e=>e.S),__vite__mapDeps([0,1])),t(()=>import(`./dist-B3-a6uF0.js`).then(e=>e.s),__vite__mapDeps([2,1,0])),t(()=>import(`./dist-CX_Hm4GS.js`),__vite__mapDeps([3,0,1,2,4,5])),t(()=>import(`./dist-scBkrwv-.js`),__vite__mapDeps([6,0,1,2])),t(()=>import(`./dist-J6XWqRpB.js`).then(e=>e.d),__vite__mapDeps([5,1,0,2,4])),t(()=>import(`./dist-Cus6_oaF.js`).then(e=>e.n),__vite__mapDeps([4,1])),g?g().catch(e=>(console.warn(`[CodeMirror] Failed to load language for .${h}:`,e),null)):Promise.resolve(null),r().catch(e=>(console.warn(`[CodeMirror] Failed to build the blame extension:`,e),null))]);if(i||!S.current)return;w.current=y.EditorView,u=R,f=B,D.current=v.Annotation.define(),O.current=v.Transaction.addToHistory;let W=n.length<=d&&H!==null;o=new v.Compartment;let G=[y.lineNumbers(),y.highlightActiveLine(),y.drawSelection(),P.history(),y.keymap.of([P.indentWithTab,...P.defaultKeymap,...P.historyKeymap,...I.searchKeymap,{key:`Mod-s`,run:()=>(N.current(),!0)}]),y.EditorView.updateListener.of(e=>{e.docChanged&&!(D.current&&e.transactions.some(e=>e.annotation(D.current)===!0))&&M.current(e.state.doc.toString()),e.selectionSet&&z(`${e.state.selection.main.from},${e.state.selection.main.to}`)}),y.EditorView.domEventHandlers({mousedown:(e,t)=>(t.focus(),!1)})];if(G.push(l(v,I)),b&&G.push(v.EditorState.readOnly.of(!0),y.EditorView.editable.of(!1),y.EditorView.contentAttributes.of({tabindex:`0`})),U&&!b&&(c=new v.Compartment,G.splice(1,0,c.of([])),G.push(U.base)),H)try{G.push(H)}catch(e){console.warn(`[CodeMirror] Failed to apply language extension for .${h}:`,e),W=!1}if(W&&o&&u&&f)try{G.push(o.of(u.syntaxHighlighting(m(u,f))))}catch(e){console.warn(`[CodeMirror] Failed to attach syntaxHighlighting for .${h}:`,e),W=!1}let K=T.current,q=K?.scope===JSON.stringify([_,e])&&K.state.doc.toString()===n,J=q?K.state.update({effects:v.StateEffect.reconfigure.of(G)}).state:v.EditorState.create({doc:n,extensions:G});if(a=new y.EditorView({state:J,parent:S.current}),q&&(a.scrollDOM.scrollTop=K.top,a.scrollDOM.scrollLeft=K.left),i){a.destroy();return}C.current=a,F(W),L(!0),k.current=U,A.current=c??null,j.current=null,V(e=>e+1);let Y=new MutationObserver(()=>{let e=C.current;if(e&&W&&o&&u&&f)try{e.dispatch({effects:o.reconfigure(u.syntaxHighlighting(m(u,f)))})}catch{}});E.current=Y,Y.observe(document.documentElement,{attributes:!0,attributeFilter:[`data-theme`]})}catch(e){console.error(`[CodeMirror] Fatal editor initialization error:`,e),i||L(!0)}})(),()=>{i=!0,E.current?.disconnect(),E.current=null,a&&(T.current={scope:JSON.stringify([_,e]),state:a.state,top:a.scrollDOM.scrollTop,left:a.scrollDOM.scrollLeft}),a?.destroy(),C.current=null,L(!1),S.current&&(S.current.textContent=``)}},[e,b,x]),(0,c.useEffect)(()=>{let e=C.current;if(!e)return;let t=e.state.doc.toString();t!==n&&e.dispatch({changes:{from:0,to:t.length,insert:n},annotations:D.current?D.current.of(!0):void 0})},[n]),(0,c.useEffect)(()=>{let e=C.current;if(!e||!h)return;let t=e.state.doc.line(Math.min(Math.max(1,h.line),e.state.doc.lines)),n=Math.min(t.to,t.from+(h.column??1)-1);e.dispatch({selection:{anchor:t.to,head:n},effects:w.current?.scrollIntoView(n,{y:`start`,yMargin:Math.round(e.scrollDOM.clientHeight/3)})}),e.focus()},[h,I]);let H=!!(v&&v.state===`ready`&&v.response&&v.path===e&&v.workspaceId===_);(0,c.useEffect)(()=>{let t=C.current,n=k.current,r=A.current;if(!t||!n||!r)return;let i=v&&v.state===`ready`&&v.response&&v.path===e&&v.workspaceId===_?v.response:null,a=i?o(i):null;j.current!==a&&(j.current=a,t.dispatch({effects:[n.setBlame.of(a),r.reconfigure(a?n.gutter:[])]}))},[v?.state,v?.response,v?.path,v?.workspaceId,e,_,B]);let U=C.current?.state.doc.toString()??n,W=U.length<=f?U:U.slice(0,f),G=x??p(e),K=i(G),q=C.current?.state,J=q?.selection.main.head,Y=J===void 0?void 0:q?.doc.lineAt(J),X=Y?.number,Z=J!==void 0&&Y?J-Y.from+1:void 0;return(0,c.useEffect)(()=>{I&&X!==void 0&&Z!==void 0&&y?.({line:X,column:Z,language:P&&K||`纯文本`,highlight:P?G:`plain`})},[I,X,Z,P,K,G,y]),(0,c.useEffect)(()=>()=>y?.(),[y]),(0,u.jsxs)(`div`,{className:`file-cm-wrap`,"data-file-text":e,"data-file-content":W,"data-file-content-truncated":U.length>f?`1`:`0`,"data-file-selection":R,"data-file-editor-ready":I?`1`:`0`,"data-file-blame-gutter":H?`1`:void 0,onMouseDown:()=>C.current?.focus(),children:[(0,u.jsx)(`div`,{className:`file-cm`,ref:S,"aria-label":`${b?`查看`:`编辑`} ${e}`}),(!I||!y)&&(0,u.jsxs)(`div`,{className:`file-editor-status`,children:[!I&&(0,u.jsx)(`span`,{"data-file-editor-loading":`1`,children:`正在加载编辑器…`}),I&&J!==void 0&&Y&&(0,u.jsxs)(`span`,{children:[`第 `,Y.number,` 行,第 `,J-Y.from+1,` 列`]}),I&&!P&&(0,u.jsx)(`span`,{"data-file-highlight-status":`plain`,children:`纯文本`}),I&&P&&K&&(0,u.jsx)(`span`,{"data-file-highlight-status":G,children:K})]})]})}export{h as CodeMirrorEditor,l as t,m as themeHighlightStyle};
|