@evandu/super-pi 0.1.283 → 0.1.285

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.
@@ -267,7 +267,13 @@ export type IsolatedExecutionEvent = {
267
267
  phase: "start" | "update" | "end";
268
268
  call: Pick<ToolCallNotice, "id" | "name" | "detail" | "status" | "durationMs" | "result">;
269
269
  };
270
+ export type GroupExecutionLifecycle = {
271
+ busy(workspaceId: string, roomId: string): boolean;
272
+ stop(workspaceId: string, roomId: string, memberIds: string[]): Promise<void>;
273
+ forget(workspaceId: string, roomId: string): Promise<void>;
274
+ };
270
275
  export type IsolatedCompletionInput = {
276
+ onConversation?(conversationId: string): Promise<void> | void;
271
277
  userToolContext?: {
272
278
  id: string;
273
279
  workspaceId: string;
@@ -288,6 +294,9 @@ export type IsolatedCompletionInput = {
288
294
  onModel?: (model: ModelSelection) => void | Promise<void>;
289
295
  };
290
296
  export interface AgentRuntime {
297
+ setGroupMemberExecutor?(execute: (input: IsolatedCompletionInput, file: string) => Promise<string>, lifecycle?: GroupExecutionLifecycle): void;
298
+ groupMembersBusy?(workspaceId: string, roomId: string): boolean;
299
+ stopGroupMembers?(workspaceId: string, roomId: string, memberIds: string[]): Promise<void>;
291
300
  compactContext?(input: Pick<AnswerInput, "conversation" | "cwd" | "signal" | "onCompaction" | "onUsage" | "onSessionFile">): Promise<void>;
292
301
  answer(input: AnswerInput): AsyncIterable<string>;
293
302
  cacheWarmingSettings?(): Promise<PiCacheWarmingSettings>;
@@ -1256,6 +1265,11 @@ export declare class PiRpcRuntime implements AgentRuntime {
1256
1265
  * calls supply the explicit durable identity, with their normal agent tool policy.
1257
1266
  */
1258
1267
  askOnce(input: IsolatedCompletionInput): Promise<string>;
1268
+ private groupMemberExecutor?;
1269
+ private groupLifecycle?;
1270
+ setGroupMemberExecutor(execute: (input: IsolatedCompletionInput, file: string) => Promise<string>, lifecycle?: GroupExecutionLifecycle): void;
1271
+ groupMembersBusy(workspaceId: string, roomId: string): boolean;
1272
+ stopGroupMembers(workspaceId: string, roomId: string, memberIds: string[]): Promise<void>;
1259
1273
  forgetGroupMemberSessions(workspaceId: string, roomId: string): Promise<void>;
1260
1274
  private completeOnce;
1261
1275
  /**
@@ -2818,21 +2818,32 @@ export class PiRpcRuntime {
2818
2818
  if (input.memberSession) {
2819
2819
  if (!input.agent || !input.onToolStart)
2820
2820
  throw new Error("持久成员会话必须属于可执行的群成员。");
2821
- return (this.memberSessions ??= new GroupMemberSessions(join(this.sessionDir, "group-members"))).run(input.memberSession, input.agent.id, input.cwd, input.prompt, input.signal, (file, prompt) => this.completeOnce({ ...input, prompt }, file));
2821
+ return (this.memberSessions ??= new GroupMemberSessions(join(this.sessionDir, "group-members"))).run(input.memberSession, input.agent.id, input.cwd, input.prompt, input.signal, (file, prompt) => this.groupMemberExecutor ? this.groupMemberExecutor({ ...input, prompt }, file) : this.completeOnce({ ...input, prompt }, file), Boolean(this.groupMemberExecutor));
2822
2822
  }
2823
2823
  return this.completeOnce(input);
2824
2824
  }
2825
+ groupMemberExecutor;
2826
+ groupLifecycle;
2827
+ setGroupMemberExecutor(execute, lifecycle) { this.groupMemberExecutor = execute; this.groupLifecycle = lifecycle; }
2828
+ groupMembersBusy(workspaceId, roomId) { return this.groupLifecycle?.busy(workspaceId, roomId) ?? false; }
2829
+ async stopGroupMembers(workspaceId, roomId, memberIds) { await this.groupLifecycle?.stop(workspaceId, roomId, memberIds); }
2825
2830
  async forgetGroupMemberSessions(workspaceId, roomId) {
2831
+ await this.groupLifecycle?.forget(workspaceId, roomId);
2826
2832
  await (this.memberSessions ??= new GroupMemberSessions(join(this.sessionDir, "group-members"))).removeRoom(workspaceId, roomId);
2827
2833
  }
2828
2834
  async completeOnce(input, sessionFile) {
2829
2835
  if (!this.pi.found)
2830
2836
  throw new Error(this.pi.reason);
2831
- const args = ["--mode", "rpc", ...(sessionFile ? ["--session", sessionFile] : ["--no-session"]), "--no-extensions", "--no-skills", "--no-prompt-templates", "--no-mcp", "--extension", modelPolicyExtensionPath()];
2837
+ const executable = Boolean(input.agent && input.onToolStart);
2838
+ const args = ["--mode", "rpc", ...(sessionFile ? ["--session", sessionFile] : ["--no-session"]), "--no-mcp"];
2839
+ if (executable)
2840
+ args.push(...superPiExtensionPaths(repositoryRootFrom()).flatMap(path => ["--extension", path]));
2841
+ else
2842
+ args.push("--no-extensions", "--no-skills", "--no-prompt-templates", "--extension", modelPolicyExtensionPath());
2832
2843
  let nativeEnv = {};
2833
2844
  if (input.agent && input.onToolStart) {
2834
- const selection = nativeToolPolicy(toolSelection(input.agent.tools), readNativeToolSettings(nativeToolSettingsPath(this.sessionDir)));
2835
- args.push("--extension", nativeToolExtensionPath(), ...nativeToolArgs(selection));
2845
+ const selection = nativeToolPolicy(toolSelection(input.agent.tools, { extraAllowedTools: this.extensionToolNames() }), readNativeToolSettings(nativeToolSettingsPath(this.sessionDir)));
2846
+ args.push(...nativeToolArgs(selection));
2836
2847
  nativeEnv = nativeToolEnv(this.sessionDir, selection);
2837
2848
  if (input.userToolContext)
2838
2849
  nativeEnv = { ...nativeEnv, SUPER_PI_USER_TOOLS_ID: input.userToolContext.id, SUPER_PI_USER_TOOLS_CAPABILITY: mintCapability(input.userToolContext.id) };
@@ -295,6 +295,12 @@ export declare class Store {
295
295
  conversationId?: string;
296
296
  }): AppState;
297
297
  createConversation(workspaceId: string, configuration?: {
298
+ groupExecution?: {
299
+ workspaceId?: string;
300
+ roomId: string;
301
+ memberId: string;
302
+ };
303
+ executionSessionId?: string;
298
304
  agentId?: string | null;
299
305
  model?: ModelSelection | null;
300
306
  thinkingLevel?: string | null;
@@ -430,7 +436,7 @@ export declare class Store {
430
436
  * workflows, todos, UI locks/collapse markers, and open escalations raised by the destroyed
431
437
  * sessions). Refuses top-level sessions and refuses if any session in the subtree is running.
432
438
  */
433
- deleteConversationSubtree(conversationId: string): Promise<{
439
+ deleteConversationSubtree(conversationId: string, groupExecution?: boolean): Promise<{
434
440
  destroyed: Array<{
435
441
  id: string;
436
442
  title: string;
@@ -1426,7 +1426,10 @@ export class Store {
1426
1426
  const workspace = this.state.workspaces.find((item) => item.id === workspaceId);
1427
1427
  if (!workspace)
1428
1428
  throw new Error("找不到这个工作区。");
1429
- const conversation = { id: id("conversation"), title: DEFAULT_CONVERSATION_TITLE, workspaceId, updatedAt: now(), status: "idle", messages: [] };
1429
+ const groupExecution = configuration?.groupExecution ?? this.state.conversations.find(item => item.id === configuration?.parentConversationId)?.groupExecution;
1430
+ const conversation = { ...(groupExecution ? { groupExecution } : {}), id: configuration?.executionSessionId ?? id("conversation"), title: DEFAULT_CONVERSATION_TITLE, workspaceId, updatedAt: now(), status: "idle", messages: [] };
1431
+ if (this.state.conversations.some(item => item.id === conversation.id))
1432
+ throw new Error("执行会话标识已经存在,拒绝复用其他会话身份。");
1430
1433
  // INHERITANCE, AS A COPY AT BIRTH. The workspace's defaults are stamped onto the new conversation
1431
1434
  // here and never consulted again: the session picker edits the conversation's own fields, so an
1432
1435
  // existing conversation is untouched by later workspace settings, and a workspace edit never
@@ -1757,11 +1760,11 @@ export class Store {
1757
1760
  * workflows, todos, UI locks/collapse markers, and open escalations raised by the destroyed
1758
1761
  * sessions). Refuses top-level sessions and refuses if any session in the subtree is running.
1759
1762
  */
1760
- async deleteConversationSubtree(conversationId) {
1763
+ async deleteConversationSubtree(conversationId, groupExecution = false) {
1761
1764
  const root = this.state.conversations.find((item) => item.id === conversationId);
1762
1765
  if (!root)
1763
1766
  return { destroyed: [] };
1764
- if (!root.parentConversationId && !root.warmSession) {
1767
+ if (!root.parentConversationId && !root.warmSession && !(groupExecution && root.groupExecution)) {
1765
1768
  throw new Error("顶层会话不能销毁,只能由用户归档。");
1766
1769
  }
1767
1770
  const subtree = this.conversationSubtree(root);
@@ -504,6 +504,11 @@ export type Conversation = {
504
504
  /** Private receipts retained even when a message is withdrawn or cut from history. */
505
505
  acceptedSendIds?: string[];
506
506
  warmSession?: true;
507
+ groupExecution?: {
508
+ workspaceId?: string;
509
+ roomId: string;
510
+ memberId: string;
511
+ };
507
512
  /**
508
513
  * Cumulative usage observed for this conversation: its OWN assistant messages AND the one-shot
509
514
  * (sub-agent) calls it dispatched.
@@ -57,6 +57,7 @@ export type GroupRsi = {
57
57
  startedAt?: string;
58
58
  sourceKey?: string;
59
59
  reports: GroupRsiReport[];
60
+ archivedReports?: GroupRsiReport[];
60
61
  pending?: boolean;
61
62
  notice?: string;
62
63
  requestedAt?: string;
@@ -145,6 +146,7 @@ export type GroupUserPost = GroupPost & {
145
146
  memoryNotice?: string;
146
147
  };
147
148
  export type GroupReply = GroupPost & {
149
+ executionConversationId?: string;
148
150
  role: "assistant";
149
151
  memberId: string;
150
152
  memberName?: string;
@@ -11,6 +11,7 @@ export type RsiRepair = {
11
11
  findingId?: string;
12
12
  title: string;
13
13
  conversationId: string;
14
+ observationSourceKey?: string;
14
15
  status: "discussing" | "implementing" | "review" | "completed" | "failed" | "interrupted" | "cancelled";
15
16
  createdAt: string;
16
17
  updatedAt: string;
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "superPi": {
4
4
  "managedDirectListener": true
5
5
  },
6
- "version": "0.1.283",
6
+ "version": "0.1.285",
7
7
  "description": "Web control plane and companion for Pi",
8
8
  "license": "MIT",
9
9
  "type": "module",
@@ -54,6 +54,7 @@
54
54
  "pack:server": "npm run build && node scripts/pack-server.mjs"
55
55
  },
56
56
  "check:logic": [
57
+ "scripts/group-capability-parity.test.mjs",
57
58
  "scripts/context-compaction.test.mjs",
58
59
  "scripts/minimax-output.test.mjs",
59
60
  "scripts/rsi-repairs.test.mjs",
@@ -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{c as t,d as n,f as r,l as i,n as a,r as o,u as s}from"./index-DGnOud6x.js";var c=e(r(),1),l=n(),u=262144,d=131072;function f(e){return e.split(`.`).pop()?.toLowerCase()??``}function p(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 m({path:e,value:n,onChange:r,jumpToLine:m,onSave:h,workspaceId:g,blame:_,onPosition:v,readOnly:y=!1,languageOverride:b}){let x=(0,c.useRef)(null),S=(0,c.useRef)(null),C=(0,c.useRef)(void 0),w=(0,c.useRef)(null),T=(0,c.useRef)(null),E=(0,c.useRef)(null),D=(0,c.useRef)(null),O=(0,c.useRef)(null),k=(0,c.useRef)(null),A=(0,c.useRef)(r),j=(0,c.useRef)(h);A.current=r,j.current=h;let[M,N]=(0,c.useState)(!1),[P,F]=(0,c.useState)(!1),[I,L]=(0,c.useState)(`0,0`),[R,z]=(0,c.useState)(0);(0,c.useEffect)(()=>{let t=!1,r,a,c,l,d;return(async()=>{try{let m=b??f(e),h=i(m),[_,v,M,P,I,R,B,V]=await Promise.all([s(()=>import(`./dist-D978o95T.js`).then(e=>e.S),__vite__mapDeps([0,1])),s(()=>import(`./dist-B3-a6uF0.js`).then(e=>e.s),__vite__mapDeps([2,1,0])),s(()=>import(`./dist-CX_Hm4GS.js`),__vite__mapDeps([3,0,1,2,4,5])),s(()=>import(`./dist-scBkrwv-.js`),__vite__mapDeps([6,0,1,2])),s(()=>import(`./dist-J6XWqRpB.js`).then(e=>e.d),__vite__mapDeps([5,1,0,2,4])),s(()=>import(`./dist-Cus6_oaF.js`).then(e=>e.n),__vite__mapDeps([4,1])),h?h().catch(e=>(console.warn(`[CodeMirror] Failed to load language for .${m}:`,e),null)):Promise.resolve(null),o().catch(e=>(console.warn(`[CodeMirror] Failed to build the blame extension:`,e),null))]);if(t||!x.current)return;l=I,d=R,T.current=_.Annotation.define(),E.current=_.Transaction.addToHistory;let H=n.length<=u&&B!==null;a=new _.Compartment;let U=[v.lineNumbers(),v.highlightActiveLine(),v.drawSelection(),M.history(),v.keymap.of([M.indentWithTab,...M.defaultKeymap,...M.historyKeymap,...P.searchKeymap,{key:`Mod-s`,run:()=>(j.current(),!0)}]),v.EditorView.updateListener.of(e=>{e.docChanged&&!(T.current&&e.transactions.some(e=>e.annotation(T.current)===!0))&&A.current(e.state.doc.toString()),e.selectionSet&&L(`${e.state.selection.main.from},${e.state.selection.main.to}`)}),v.EditorView.domEventHandlers({mousedown:(e,t)=>(t.focus(),!1)})];if(y&&U.push(_.EditorState.readOnly.of(!0),v.EditorView.editable.of(!1)),V&&!y&&(c=new _.Compartment,U.splice(1,0,c.of([])),U.push(V.base)),B)try{U.push(B)}catch(e){console.warn(`[CodeMirror] Failed to apply language extension for .${m}:`,e),H=!1}if(H&&a&&l&&d)try{U.push(a.of(l.syntaxHighlighting(p(l,d))))}catch(e){console.warn(`[CodeMirror] Failed to attach syntaxHighlighting for .${m}:`,e),H=!1}let W=C.current,G=W?.scope===JSON.stringify([g,e])&&W.state.doc.toString()===n,K=G?W.state.update({effects:_.StateEffect.reconfigure.of(U)}).state:_.EditorState.create({doc:n,extensions:U});if(r=new v.EditorView({state:K,parent:x.current}),G&&(r.scrollDOM.scrollTop=W.top,r.scrollDOM.scrollLeft=W.left),t){r.destroy();return}S.current=r,N(H),F(!0),D.current=V,O.current=c??null,k.current=null,z(e=>e+1);let q=new MutationObserver(()=>{let e=S.current;if(e&&H&&a&&l&&d)try{e.dispatch({effects:a.reconfigure(l.syntaxHighlighting(p(l,d)))})}catch{}});w.current=q,q.observe(document.documentElement,{attributes:!0,attributeFilter:[`data-theme`]})}catch(e){console.error(`[CodeMirror] Fatal editor initialization error:`,e),t||F(!0)}})(),()=>{t=!0,w.current?.disconnect(),w.current=null,r&&(C.current={scope:JSON.stringify([g,e]),state:r.state,top:r.scrollDOM.scrollTop,left:r.scrollDOM.scrollLeft}),r?.destroy(),S.current=null,F(!1),x.current&&(x.current.textContent=``)}},[e,y,b]),(0,c.useEffect)(()=>{let e=S.current;if(!e)return;let t=e.state.doc.toString();t!==n&&e.dispatch({changes:{from:0,to:t.length,insert:n},annotations:T.current?T.current.of(!0):void 0})},[n]),(0,c.useEffect)(()=>{let e=S.current;if(!e||!m)return;let t=e.state.doc.line(Math.min(Math.max(1,m.line),e.state.doc.lines)),n=Math.min(t.to,t.from+(m.column??1)-1);e.dispatch({selection:{anchor:t.to,head:n},scrollIntoView:!0}),e.focus()},[m,P]);let B=!!(_&&_.state===`ready`&&_.response&&_.path===e&&_.workspaceId===g);(0,c.useEffect)(()=>{let t=S.current,n=D.current,r=O.current;if(!t||!n||!r)return;let i=_&&_.state===`ready`&&_.response&&_.path===e&&_.workspaceId===g?_.response:null,o=i?a(i):null;k.current!==o&&(k.current=o,t.dispatch({effects:[n.setBlame.of(o),r.reconfigure(o?n.gutter:[])]}))},[_?.state,_?.response,_?.path,_?.workspaceId,e,g,R]);let V=S.current?.state.doc.toString()??n,H=V.length<=d?V:V.slice(0,d),U=b??f(e),W=t(U),G=S.current?.state,K=G?.selection.main.head,q=K===void 0?void 0:G?.doc.lineAt(K),J=q?.number,Y=K!==void 0&&q?K-q.from+1:void 0;return(0,c.useEffect)(()=>{P&&J!==void 0&&Y!==void 0&&v?.({line:J,column:Y,language:M&&W||`纯文本`,highlight:M?U:`plain`})},[P,J,Y,M,W,U,v]),(0,c.useEffect)(()=>()=>v?.(),[v]),(0,l.jsxs)(`div`,{className:`file-cm-wrap`,"data-file-text":e,"data-file-content":H,"data-file-content-truncated":V.length>d?`1`:`0`,"data-file-selection":I,"data-file-editor-ready":P?`1`:`0`,"data-file-blame-gutter":B?`1`:void 0,onMouseDown:()=>S.current?.focus(),children:[(0,l.jsx)(`div`,{className:`file-cm`,ref:x,"aria-label":`${y?`查看`:`编辑`} ${e}`}),(!P||!v)&&(0,l.jsxs)(`div`,{className:`file-editor-status`,children:[!P&&(0,l.jsx)(`span`,{"data-file-editor-loading":`1`,children:`正在加载编辑器…`}),P&&K!==void 0&&q&&(0,l.jsxs)(`span`,{children:[`第 `,q.number,` 行,第 `,K-q.from+1,` 列`]}),P&&!M&&(0,l.jsx)(`span`,{"data-file-highlight-status":`plain`,children:`纯文本`}),P&&M&&W&&(0,l.jsx)(`span`,{"data-file-highlight-status":U,children:W})]})]})}export{m as CodeMirrorEditor,p as themeHighlightStyle};