@evandu/super-pi 0.1.240 → 0.1.241

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-DxjIxdVK.js"></script>
11
+ <script type="module" crossorigin src="/assets/index-oUDSLOqG.js"></script>
12
12
  <link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-XKyaHtl9.js">
13
- <link rel="stylesheet" crossorigin href="/assets/index-BGbZwftQ.css">
13
+ <link rel="stylesheet" crossorigin href="/assets/index-CwH7sttH.css">
14
14
  </head>
15
15
  <body>
16
16
  <div id="root"></div>
@@ -34,7 +34,9 @@ export declare class ExtensionUiService {
34
34
  /**
35
35
  * Cancels any pending UI requests for a given conversation.
36
36
  */
37
- cancelPendingUi(conversationId: string, reason: ExtensionUiCloseReason): void;
37
+ cancelPendingUi(conversationId: string, reason: ExtensionUiCloseReason, owner?: {
38
+ runId?: string;
39
+ }): void;
38
40
  /**
39
41
  * Creates an ExtensionUiHost interface for a conversation or subagent run.
40
42
  */
@@ -19,7 +19,7 @@ export class ExtensionUiService {
19
19
  .map(({ conversationId, request }) => ({ conversationId, request }));
20
20
  for (const [conversationId, requests] of this.view) {
21
21
  if (visible.has(conversationId))
22
- for (const request of requests.values())
22
+ for (const { request } of requests.values())
23
23
  pending.push({ conversationId, request });
24
24
  }
25
25
  return pending;
@@ -61,10 +61,23 @@ export class ExtensionUiService {
61
61
  /**
62
62
  * Cancels any pending UI requests for a given conversation.
63
63
  */
64
- cancelPendingUi(conversationId, reason) {
65
- const cleared = reason !== "expired" && this.view.delete(conversationId);
64
+ cancelPendingUi(conversationId, reason, owner) {
65
+ let cleared = false;
66
+ if (reason !== "expired") {
67
+ const view = this.view.get(conversationId);
68
+ if (!owner)
69
+ cleared = this.view.delete(conversationId);
70
+ else if (view) {
71
+ for (const [key, item] of view) {
72
+ if (item.runId === owner.runId)
73
+ cleared = view.delete(key) || cleared;
74
+ }
75
+ if (!view.size)
76
+ this.view.delete(conversationId);
77
+ }
78
+ }
66
79
  for (const [key, pending] of [...this.pendingUi]) {
67
- if (pending.conversationId === conversationId) {
80
+ if (pending.conversationId === conversationId && (!owner || pending.runId === owner.runId)) {
68
81
  this.settleUi(key, { cancelled: true }, reason);
69
82
  }
70
83
  }
@@ -82,14 +95,14 @@ export class ExtensionUiService {
82
95
  return;
83
96
  const shown = scoped(request);
84
97
  if (request.method === "setStatus" || request.method === "setWidget" || request.method === "setTitle") {
85
- const key = JSON.stringify([request.method, request.statusKey ?? request.widgetKey ?? ""]);
98
+ const key = JSON.stringify([runId ?? null, request.method, request.statusKey ?? request.widgetKey ?? ""]);
86
99
  const view = this.view.get(conversationId) ?? new Map();
87
100
  if ((request.method === "setStatus" && request.statusText === undefined)
88
101
  || (request.method === "setWidget" && request.widgetLines === undefined)
89
102
  || (request.method === "setTitle" && !request.title))
90
103
  view.delete(key);
91
104
  else
92
- view.set(key, shown);
105
+ view.set(key, { request: shown, runId });
93
106
  if (view.size)
94
107
  this.view.set(conversationId, view);
95
108
  else
@@ -107,7 +120,7 @@ export class ExtensionUiService {
107
120
  // one: a question Pi chose to leave open is a question the model is waiting on, and a
108
121
  // fabricated cancel would be the model continuing on a false premise. The run-level
109
122
  // teardown (stop / abort / shutdown) is the path that closes an unanswered ask.
110
- const pending = { conversationId, request: shown, resolve };
123
+ const pending = { conversationId, runId, request: shown, resolve };
111
124
  if (shown.timeoutMs !== undefined) {
112
125
  pending.timer = setTimeout(() => {
113
126
  this.settleUi(key, { cancelled: true }, "timeout");
@@ -6,6 +6,7 @@ import type { EventBroadcaster } from "../server-context.js";
6
6
  import type { ExtensionUiService } from "./extension-ui-service.js";
7
7
  import type { WorkflowEngine } from "../workflow-engine.js";
8
8
  import { FileChangeTracker } from "../file-changes.js";
9
+ import type { ExecCompletion } from "../exec-service.js";
9
10
  /**
10
11
  * Validates a caller-supplied delivery mode without silently falling back on bogus values.
11
12
  * Undefined defaults to `"queue"`; any other value is rejected explicitly.
@@ -117,6 +118,7 @@ export declare class RunService {
117
118
  private readonly runCompletions;
118
119
  /** A selected interrupt owns the next free run slot, even while the old child exits. */
119
120
  private readonly interruptTargets;
121
+ private readonly pendingBackgroundWakeups;
120
122
  private shuttingDown;
121
123
  /** Preserve incoming background results as waiting messages while the server drains its producers. */
122
124
  beginShutdown(): void;
@@ -155,7 +157,9 @@ export declare class RunService {
155
157
  } | undefined;
156
158
  waitForToolCall(conversationId: string, toolCallId: string | undefined): Promise<ReturnType<RunService["originForToolCall"]>>;
157
159
  private execService;
158
- setExecService(execService: import("../exec-service.js").ExecService): void;
160
+ private backgroundLogDirectory?;
161
+ private readonly execSettlements;
162
+ setExecService(execService: import("../exec-service.js").ExecService, logDirectory?: string): void;
159
163
  /**
160
164
  * Called by the exec completion handler in index.ts when a background exec session ends.
161
165
  * Injects the result into the conversation and cleans up the background task record.
@@ -166,7 +170,10 @@ export declare class RunService {
166
170
  * when nothing else is busy. The render stays as a 后台回传 block throughout - in dock and in
167
171
  * transcript - so a `role: "user"` is never impersonated.
168
172
  */
169
- enqueueExecResult(sessionId: string, exitCode: number, stdout: string, stderr: string): void;
173
+ enqueueExecResult(sessionId: string, exitCode: number, stdout: string, stderr: string, completion?: ExecCompletion): void;
174
+ failBackgroundTaskStart(taskId: string, reason: string, cancelled?: boolean): Promise<void>;
175
+ private finishBackgroundResult;
176
+ private startBackgroundResult;
170
177
  /**
171
178
  * Delivers an orchestrated child session's final output to its direct parent. This intentionally uses
172
179
  * the same waiting-queue contract as background sub-agent results: one result per turn, ahead of
@@ -180,15 +187,7 @@ export declare class RunService {
180
187
  error?: string;
181
188
  }): Promise<void>;
182
189
  private dispatchBackgroundResult;
183
- /**
184
- * Stops an active background task (spawned process or detached subagent) on user request.
185
- *
186
- * 1. Kills the underlying PTY child process if one exists in `execService`.
187
- * 2. If the task originated from a tool call in a conversation transcript, marks the tool
188
- * call as failed with a clear message and broadcasts `message.tools`.
189
- * 3. Removes the task from `state.backgroundTasks` and broadcasts `state` so the sidebar
190
- * updates immediately.
191
- */
190
+ private wakeWaitingBackgroundResult;
192
191
  stopBackgroundTask(taskId: string): Promise<void>;
193
192
  hasActiveBackgroundTasks(conversationId: string): boolean;
194
193
  settleBackgroundStatus(conversationId: string): Promise<void>;
@@ -278,6 +277,8 @@ export declare class RunService {
278
277
  * left HTTP-only paths with no owner at all.
279
278
  */
280
279
  verifyPrimaryCapability(conversationId: string, capability: unknown): import("../capability.js").CapabilityVerdict;
280
+ foregroundSignal(conversationId: string): AbortSignal | undefined;
281
+ canAdmitBackgroundTask(signal?: AbortSignal): boolean;
281
282
  /**
282
283
  * Aborts all active conversation runs and sub-agents.
283
284
  */
@@ -295,7 +296,9 @@ export declare class RunService {
295
296
  /**
296
297
  * Stops an active turn run for a conversation.
297
298
  */
298
- stopRun(conversationId: string): Promise<void>;
299
+ stopRun(conversationId: string, options?: {
300
+ foregroundOnly?: boolean;
301
+ }): Promise<void>;
299
302
  /** Releases waits that can prevent Pi's abort from reaching its idle state. Idempotent by design. */
300
303
  private cancelPendingRunInteractions;
301
304
  private stopRunUnsafe;