@evandu/super-pi 0.1.261 → 0.1.262

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.
@@ -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-BVn_-dwp.js"></script>
11
+ <script type="module" crossorigin src="/assets/index-BZd7RTFi.js"></script>
12
12
  <link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-XKyaHtl9.js">
13
- <link rel="stylesheet" crossorigin href="/assets/index-DhW875H-.css">
13
+ <link rel="stylesheet" crossorigin href="/assets/index-DHTKUM97.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); });
@@ -418,7 +434,8 @@ export class GroupChatService {
418
434
  async configure(workspaceId, id, input) {
419
435
  const current = this.activeRoom(this.rooms, workspaceId, id);
420
436
  const moderator = await this.moderator(workspaceId, input);
421
- const members = input.memberIds === undefined ? undefined : await this.resolveMembers(id, input.memberIds, current.members);
437
+ const members = input.memberIds === undefined && input.memberModels === undefined ? undefined
438
+ : await this.memberModels(workspaceId, input.memberIds === undefined ? current.members : await this.resolveMembers(id, input.memberIds, current.members), input.memberModels);
422
439
  await this.edit(rooms => {
423
440
  const room = this.activeRoom(rooms, workspaceId, id);
424
441
  if (members) {
@@ -723,8 +740,9 @@ export class GroupChatService {
723
740
  const topicIndex = room.messages.findIndex(post => post.id === topic.id);
724
741
  const previous = room.messages.slice(0, topicIndex).filter(post => post.role === "user" && post.status !== "cancelled");
725
742
  const topicIds = new Set(previous.map(post => post.id));
726
- const current = room.messages.filter(post => post.role === "assistant" && post.topicId === topic.id && post.status === "completed").slice(-CONTEXT_MESSAGES);
727
- const roomHistory = room.messages.filter(post => post.role === "assistant" ? topicIds.has(post.topicId) && post.status === "completed" : topicIds.has(post.id));
743
+ const timeline = groupTimeline(room.messages);
744
+ const current = timeline.filter(post => post.role === "assistant" && post.topicId === topic.id && post.status === "completed").slice(-CONTEXT_MESSAGES);
745
+ const roomHistory = timeline.filter(post => post.role === "assistant" ? topicIds.has(post.topicId) && post.status === "completed" : topicIds.has(post.id));
728
746
  const remaining = CONTEXT_MESSAGES - current.length;
729
747
  return [...(remaining ? roomHistory.slice(-remaining) : []), ...current].map(post => ({
730
748
  id: post.id, author: post.role === "user" ? "用户" : post.memberName ?? room.members.find(member => member.id === post.memberId)?.name,
@@ -893,7 +911,7 @@ export class GroupChatService {
893
911
  ].join("\n");
894
912
  const answer = await this.complete(started, {
895
913
  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,
914
+ agent, model: member?.model ?? (agent.model && { ...agent.model, label: agent.model.modelId }), signal: memberSignal, timeoutMs: 15 * 60_000,
897
915
  onToolStart: goBackground,
898
916
  onExecution: event => {
899
917
  if (memberSignal.aborted || !execution.record(event))
@@ -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;
@@ -95,6 +96,8 @@ export type GroupReply = GroupPost & {
95
96
  };
96
97
  };
97
98
  export type GroupMessage = GroupUserPost | GroupReply;
99
+ export declare function groupMessageTime(post: GroupMessage): string;
100
+ export declare function groupTimeline(messages: readonly GroupMessage[]): GroupMessage[];
98
101
  export type GroupActivity = {
99
102
  status: "idle" | "running" | "awaiting_background" | "completed" | "failed";
100
103
  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.261",
3
+ "version": "0.1.262",
4
4
  "description": "Web control plane and companion for Pi",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -348,6 +348,7 @@
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/workbench-search-panel-browser.test.mjs",
351
352
  "scripts/rail-workspace-follows-session-browser.test.mjs",
352
353
  "scripts/git-tab-browser.test.mjs",
353
354
  "scripts/workspace-reopen-browser.test.mjs",