@evandu/super-pi 0.1.261 → 0.1.263
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 +14 -10
- package/dist/client/assets/{CodeMirrorEditor-DGK07ECt.js → CodeMirrorEditor-EhfQhlNI.js} +1 -1
- package/dist/client/assets/{GitDiffEditor-DCQ2HgfJ.js → GitDiffEditor-Fd--uK9q.js} +1 -1
- package/dist/client/assets/index-Cs_T0IFR.js +350 -0
- package/dist/client/assets/index-D6ei0DbU.css +1 -0
- package/dist/client/index.html +2 -2
- package/dist/server/application/group-chat-service.d.ts +3 -0
- package/dist/server/application/group-chat-service.js +34 -7
- package/dist/server/runtime.d.ts +1 -0
- package/dist/server/runtime.js +12 -0
- package/dist/shared/group-chat.d.ts +4 -0
- package/dist/shared/group-chat.js +7 -0
- package/package.json +3 -1
- package/dist/client/assets/index-BVn_-dwp.js +0 -350
- package/dist/client/assets/index-DhW875H-.css +0 -1
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-Cs_T0IFR.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-D6ei0DbU.css">
|
|
14
14
|
</head>
|
|
15
15
|
<body>
|
|
16
16
|
<div id="root"></div>
|
|
@@ -35,9 +35,11 @@ export declare class GroupChatService {
|
|
|
35
35
|
deleteArchived(workspaceId: string, id: string): Promise<void>;
|
|
36
36
|
private moderator;
|
|
37
37
|
private resolveMembers;
|
|
38
|
+
private memberModels;
|
|
38
39
|
create(workspaceId: string, input: {
|
|
39
40
|
title?: unknown;
|
|
40
41
|
memberIds?: unknown;
|
|
42
|
+
memberModels?: unknown;
|
|
41
43
|
moderator?: {
|
|
42
44
|
model?: unknown;
|
|
43
45
|
prompt?: unknown;
|
|
@@ -52,6 +54,7 @@ export declare class GroupChatService {
|
|
|
52
54
|
model?: unknown;
|
|
53
55
|
prompt?: unknown;
|
|
54
56
|
memberIds?: unknown;
|
|
57
|
+
memberModels?: unknown;
|
|
55
58
|
cloneLimit?: unknown;
|
|
56
59
|
}): Promise<GroupSnapshot>;
|
|
57
60
|
send(workspaceId: string, id: string, input: {
|
|
@@ -2,7 +2,7 @@ import { randomUUID } from "node:crypto";
|
|
|
2
2
|
import { open, readFile, realpath, writeFile } from "node:fs/promises";
|
|
3
3
|
import { dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
4
4
|
import { createGitWorktree } from "../git.js";
|
|
5
|
-
import { DEFAULT_GROUP_MEMBER_IDS } from "../../shared/group-chat.js";
|
|
5
|
+
import { DEFAULT_GROUP_MEMBER_IDS, groupTimeline } from "../../shared/group-chat.js";
|
|
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";
|
|
@@ -350,13 +350,29 @@ export class GroupChatService {
|
|
|
350
350
|
return { id: agent.id, name: agent.name, description: agent.description };
|
|
351
351
|
}));
|
|
352
352
|
}
|
|
353
|
+
async memberModels(workspaceId, members, input) {
|
|
354
|
+
if (input === undefined)
|
|
355
|
+
return members;
|
|
356
|
+
if (!input || typeof input !== "object" || Array.isArray(input))
|
|
357
|
+
throw new Error("成员模型设置无效。");
|
|
358
|
+
const entries = Object.entries(input);
|
|
359
|
+
if (entries.some(([id]) => !members.some(member => member.id === id)))
|
|
360
|
+
throw new Error("模型设置包含不在群内的成员。");
|
|
361
|
+
return Promise.all(members.map(async (member) => {
|
|
362
|
+
const entry = entries.find(([id]) => id === member.id);
|
|
363
|
+
if (!entry)
|
|
364
|
+
return member;
|
|
365
|
+
const model = entry[1] == null ? undefined : (await this.moderator(workspaceId, { model: entry[1] })).model;
|
|
366
|
+
return { ...member, model };
|
|
367
|
+
}));
|
|
368
|
+
}
|
|
353
369
|
async create(workspaceId, input) {
|
|
354
370
|
this.workspace(workspaceId);
|
|
355
371
|
const title = inputText(input.title, 100, "群名");
|
|
356
372
|
if (!title)
|
|
357
373
|
throw new Error("请输入群名。");
|
|
358
374
|
const id = randomUUID();
|
|
359
|
-
const members = await this.resolveMembers(id, input.memberIds ?? DEFAULT_GROUP_MEMBER_IDS);
|
|
375
|
+
const members = await this.memberModels(workspaceId, await this.resolveMembers(id, input.memberIds ?? DEFAULT_GROUP_MEMBER_IDS), input.memberModels);
|
|
360
376
|
const moderator = await this.moderator(workspaceId, input.moderator ?? {});
|
|
361
377
|
const room = { id, workspaceId, title, updatedAt: timestamp(), revision: 0, members, moderator, messages: [] };
|
|
362
378
|
await this.edit(rooms => { rooms.push(room); });
|
|
@@ -417,8 +433,10 @@ export class GroupChatService {
|
|
|
417
433
|
}
|
|
418
434
|
async configure(workspaceId, id, input) {
|
|
419
435
|
const current = this.activeRoom(this.rooms, workspaceId, id);
|
|
420
|
-
const moderator =
|
|
421
|
-
|
|
436
|
+
const moderator = ["model", "prompt", "cloneLimit"].some(key => Object.hasOwn(input, key))
|
|
437
|
+
? await this.moderator(workspaceId, { ...current.moderator, ...input }) : current.moderator;
|
|
438
|
+
const members = input.memberIds === undefined && input.memberModels === undefined ? undefined
|
|
439
|
+
: await this.memberModels(workspaceId, input.memberIds === undefined ? current.members : await this.resolveMembers(id, input.memberIds, current.members), input.memberModels);
|
|
422
440
|
await this.edit(rooms => {
|
|
423
441
|
const room = this.activeRoom(rooms, workspaceId, id);
|
|
424
442
|
if (members) {
|
|
@@ -723,8 +741,9 @@ export class GroupChatService {
|
|
|
723
741
|
const topicIndex = room.messages.findIndex(post => post.id === topic.id);
|
|
724
742
|
const previous = room.messages.slice(0, topicIndex).filter(post => post.role === "user" && post.status !== "cancelled");
|
|
725
743
|
const topicIds = new Set(previous.map(post => post.id));
|
|
726
|
-
const
|
|
727
|
-
const
|
|
744
|
+
const timeline = groupTimeline(room.messages);
|
|
745
|
+
const current = timeline.filter(post => post.role === "assistant" && post.topicId === topic.id && post.status === "completed").slice(-CONTEXT_MESSAGES);
|
|
746
|
+
const roomHistory = timeline.filter(post => post.role === "assistant" ? topicIds.has(post.topicId) && post.status === "completed" : topicIds.has(post.id));
|
|
728
747
|
const remaining = CONTEXT_MESSAGES - current.length;
|
|
729
748
|
return [...(remaining ? roomHistory.slice(-remaining) : []), ...current].map(post => ({
|
|
730
749
|
id: post.id, author: post.role === "user" ? "用户" : post.memberName ?? room.members.find(member => member.id === post.memberId)?.name,
|
|
@@ -893,7 +912,15 @@ export class GroupChatService {
|
|
|
893
912
|
].join("\n");
|
|
894
913
|
const answer = await this.complete(started, {
|
|
895
914
|
prompt: `群内身份:${member?.name ?? agent.name}。${member?.worktreePath ? "你在独立工作树工作;报告分支和产物供后续审查整合。" : ""}\n${prompt}`, cwd: member?.worktreePath,
|
|
896
|
-
agent, model: agent.model && { ...agent.model, label: agent.model.modelId }, signal: memberSignal, timeoutMs: 15 * 60_000,
|
|
915
|
+
agent, model: member?.model ?? (agent.model && { ...agent.model, label: agent.model.modelId }), signal: memberSignal, timeoutMs: 15 * 60_000,
|
|
916
|
+
onModel: model => this.edit(rooms => {
|
|
917
|
+
const room = rooms.find(item => item.id === roomId);
|
|
918
|
+
const post = room?.messages.find(item => item.id === reply.id);
|
|
919
|
+
if (!room || post?.role !== "assistant" || post.status !== "running")
|
|
920
|
+
return;
|
|
921
|
+
post.model = { provider: model.provider, modelId: model.modelId, label: model.label };
|
|
922
|
+
room.revision += 1;
|
|
923
|
+
}),
|
|
897
924
|
onToolStart: goBackground,
|
|
898
925
|
onExecution: event => {
|
|
899
926
|
if (memberSignal.aborted || !execution.record(event))
|
package/dist/server/runtime.d.ts
CHANGED
|
@@ -271,6 +271,7 @@ export type IsolatedCompletionInput = {
|
|
|
271
271
|
onText?: (text: string) => void;
|
|
272
272
|
onToolStart?: () => void;
|
|
273
273
|
onExecution?: (event: IsolatedExecutionEvent) => void;
|
|
274
|
+
onModel?: (model: ModelSelection) => void | Promise<void>;
|
|
274
275
|
};
|
|
275
276
|
export interface AgentRuntime {
|
|
276
277
|
answer(input: AnswerInput): AsyncIterable<string>;
|
package/dist/server/runtime.js
CHANGED
|
@@ -2681,6 +2681,18 @@ export class PiRpcRuntime {
|
|
|
2681
2681
|
if (response.success !== true)
|
|
2682
2682
|
throw new Error(response.error || "Pi 无法选择指定模型");
|
|
2683
2683
|
}
|
|
2684
|
+
if (input.onModel) {
|
|
2685
|
+
let selected = input.model;
|
|
2686
|
+
try {
|
|
2687
|
+
const state = await channel.request({ id: "isolated_state", type: "get_state" }, Math.min(input.timeoutMs, 2_000));
|
|
2688
|
+
const actual = state.success === true ? describeModel(state.data?.model) : undefined;
|
|
2689
|
+
if (actual)
|
|
2690
|
+
selected = { provider: actual.provider, modelId: actual.modelId, label: actual.label };
|
|
2691
|
+
}
|
|
2692
|
+
catch { /* An explicitly selected model is already confirmed by set_model. */ }
|
|
2693
|
+
if (selected)
|
|
2694
|
+
await input.onModel(selected);
|
|
2695
|
+
}
|
|
2684
2696
|
input.signal?.throwIfAborted();
|
|
2685
2697
|
channel.write({ id: "tool_llm", type: "prompt", message: input.prompt });
|
|
2686
2698
|
let settled = false, text = "";
|
|
@@ -16,6 +16,7 @@ export type GroupMember = {
|
|
|
16
16
|
description: string;
|
|
17
17
|
agentId?: string;
|
|
18
18
|
worktreePath?: string;
|
|
19
|
+
model?: GroupModel;
|
|
19
20
|
};
|
|
20
21
|
export type GroupCloneRequest = {
|
|
21
22
|
id: string;
|
|
@@ -82,6 +83,7 @@ export type GroupReply = GroupPost & {
|
|
|
82
83
|
role: "assistant";
|
|
83
84
|
memberId: string;
|
|
84
85
|
memberName?: string;
|
|
86
|
+
model?: GroupModel;
|
|
85
87
|
topicId: string;
|
|
86
88
|
replyTo: string;
|
|
87
89
|
assignment?: string;
|
|
@@ -95,6 +97,8 @@ export type GroupReply = GroupPost & {
|
|
|
95
97
|
};
|
|
96
98
|
};
|
|
97
99
|
export type GroupMessage = GroupUserPost | GroupReply;
|
|
100
|
+
export declare function groupMessageTime(post: GroupMessage): string;
|
|
101
|
+
export declare function groupTimeline(messages: readonly GroupMessage[]): GroupMessage[];
|
|
98
102
|
export type GroupActivity = {
|
|
99
103
|
status: "idle" | "running" | "awaiting_background" | "completed" | "failed";
|
|
100
104
|
revision: number;
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import { deriveSessionState } from "./session-reporting.js";
|
|
2
2
|
export const DEFAULT_GROUP_MEMBER_IDS = ["solution-designer", "code-designer", "code-auditor", "document-organizer"];
|
|
3
|
+
export function groupMessageTime(post) {
|
|
4
|
+
return post.role === "assistant" ? post.settledAt ?? post.createdAt : post.createdAt;
|
|
5
|
+
}
|
|
6
|
+
export function groupTimeline(messages) {
|
|
7
|
+
return messages.filter(post => post.role === "user" || !["queued", "running"].includes(post.status))
|
|
8
|
+
.slice().sort((a, b) => groupMessageTime(a).localeCompare(groupMessageTime(b)));
|
|
9
|
+
}
|
|
3
10
|
export function groupDisplayState(activity, readAt) {
|
|
4
11
|
return deriveSessionState({ status: activity.status, quietWhenRead: true,
|
|
5
12
|
reportingState: activity.lastReplyAt && activity.lastReplyAt > (readAt ?? "") ? "unread" : null });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@evandu/super-pi",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.263",
|
|
4
4
|
"description": "Web control plane and companion for Pi",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -348,6 +348,8 @@
|
|
|
348
348
|
"scripts/right-sidebar-browser.test.mjs",
|
|
349
349
|
"scripts/background-task-output-browser.test.mjs",
|
|
350
350
|
"scripts/group-chat-browser.test.mjs",
|
|
351
|
+
"scripts/group-model-switch-browser.test.mjs",
|
|
352
|
+
"scripts/workbench-search-panel-browser.test.mjs",
|
|
351
353
|
"scripts/rail-workspace-follows-session-browser.test.mjs",
|
|
352
354
|
"scripts/git-tab-browser.test.mjs",
|
|
353
355
|
"scripts/workspace-reopen-browser.test.mjs",
|