@evandu/super-pi 0.1.183 → 0.1.186
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/agents/coder.md +1 -1
- package/agents/planner.md +1 -1
- package/agents/project-leader.md +2 -2
- package/agents/reviewer.md +1 -1
- package/agents/super-pi-task/core.ts +164 -7
- package/agents/super-pi-task/index.ts +33 -1
- package/dist/client/.super-pi-client-sources.json +7 -7
- package/dist/client/assets/{CodeMirrorEditor-DUyqaSOB.js → CodeMirrorEditor-Cmx7-z0f.js} +2 -2
- package/dist/client/assets/{dist-CPmDYAQT.js → dist-B8CAEuXW.js} +1 -1
- package/dist/client/assets/{dist-nbHIDjzw.js → dist-BKx3CpQJ.js} +1 -1
- package/dist/client/assets/{dist-CB124C6Z.js → dist-BMSVWA_A.js} +1 -1
- package/dist/client/assets/{dist-CU8JEI5K.js → dist-BdiInYmk.js} +1 -1
- package/dist/client/assets/{dist-D3HMZhM-.js → dist-Bq7p17eF.js} +1 -1
- package/dist/client/assets/{dist-CvLzvDh7.js → dist-BzqUlzAf.js} +1 -1
- package/dist/client/assets/{dist-Dkm31GRe.js → dist-C0PMHwdm.js} +1 -1
- package/dist/client/assets/{dist-CeU4Svbh.js → dist-C2ltv_8u.js} +1 -1
- package/dist/client/assets/{dist-DTd2PCza.js → dist-CDSDxXju.js} +1 -1
- package/dist/client/assets/{dist-DLOUy-hB.js → dist-CKZOnuRU.js} +1 -1
- package/dist/client/assets/{dist-ka17rnWs.js → dist-CWlI6qO0.js} +1 -1
- package/dist/client/assets/{dist-AQ8CYp6b.js → dist-CXDhHY7N.js} +1 -1
- package/dist/client/assets/{dist-Dnx8LlEL.js → dist-Cblc22Ag.js} +1 -1
- package/dist/client/assets/{dist-Bj218gfa.js → dist-CcuBp_Kn.js} +1 -1
- package/dist/client/assets/{dist-CNem2r_T.js → dist-DHFt0Hvo.js} +1 -1
- package/dist/client/assets/{dist-NLNoAzKl.js → dist-D_7x3oZt.js} +1 -1
- package/dist/client/assets/{dist-D4lWO1EF.js → dist-RHYiODih.js} +1 -1
- package/dist/client/assets/{dist-CkTZUfAR.js → dist-V27Fcf8p.js} +1 -1
- package/dist/client/assets/{dist-Dlg4MpdE.js → dist-WfagMkC4.js} +1 -1
- package/dist/client/assets/{dist-dnyR0Vf6.js → dist-akJoBtjs.js} +1 -1
- package/dist/client/assets/{dist-C7PhA7pe.js → dist-frBiV55p.js} +1 -1
- package/dist/client/assets/{dist-TX6Uhfee.js → dist-ibsGPa_S.js} +1 -1
- package/dist/client/assets/{index-Ui6aXMVV.css → index-BXQjUHV_.css} +1 -1
- package/dist/client/assets/{index-BplDWdZp.js → index-Dx7HAZ5j.js} +14 -13
- package/dist/client/index.html +2 -2
- package/dist/server/agents.d.ts +1 -1
- package/dist/server/agents.js +1 -1
- package/dist/server/application/conversation-service.d.ts +13 -0
- package/dist/server/application/conversation-service.js +21 -0
- package/dist/server/application/project-service.d.ts +2 -70
- package/dist/server/application/project-service.js +102 -205
- package/dist/server/application/run-service.d.ts +39 -3
- package/dist/server/application/run-service.js +166 -18
- package/dist/server/application/session-orchestrator-service.d.ts +38 -5
- package/dist/server/application/session-orchestrator-service.js +167 -5
- package/dist/server/command-handler.js +5 -1
- package/dist/server/http-server.js +45 -18
- package/dist/server/index.js +1 -1
- package/dist/server/pi-session.d.ts +3 -2
- package/dist/server/runtime.js +9 -6
- package/dist/server/session-tree-scope.d.ts +1 -1
- package/dist/server/store.d.ts +24 -0
- package/dist/server/store.js +229 -4
- package/dist/server/task-tool.d.ts +5 -2
- package/dist/server/task-tool.js +25 -2
- package/dist/server/types.d.ts +43 -13
- package/dist/server/upload.d.ts +2 -6
- package/dist/server/upload.js +7 -5
- package/dist/shared/session-reporting.d.ts +13 -2
- package/dist/shared/session-reporting.js +62 -15
- package/package.json +8 -3
|
@@ -18,6 +18,7 @@ import { conversationWorkspace } from "./model-filter.js";
|
|
|
18
18
|
import { describeSchedule } from "./scheduled-tasks.js";
|
|
19
19
|
import { MAX_KNOWLEDGE_REQUEST_BYTES } from "./knowledge.js";
|
|
20
20
|
import { MAX_DOCUMENT_REQUEST_BYTES } from "./application/document-service.js";
|
|
21
|
+
import { parseMessageDeliveryMode } from "./application/run-service.js";
|
|
21
22
|
import { MAX_FEISHU_REQUEST_BYTES } from "./application/feishu-service.js";
|
|
22
23
|
import { MAX_WEB_REQUEST_BYTES } from "./web.js";
|
|
23
24
|
import { MAX_TOOL_BODY_BYTES } from "./tool-registry.js";
|
|
@@ -315,7 +316,7 @@ export function createHttpServer(options) {
|
|
|
315
316
|
// the endpoint that can spend it is exactly the one an agent's own turn can reach, and the
|
|
316
317
|
// management half (`/api/feishu/config`) stays behind the ordinary token AND the local-address
|
|
317
318
|
// predicate.
|
|
318
|
-
if (requestPath !== "/api/conversation/usage" && requestPath !== "/api/memory/tool" && requestPath !== "/api/knowledge/tool" && requestPath !== "/api/documents/tool" && requestPath !== "/api/web/tool" && requestPath !== "/api/feishu/tool" && requestPath !== "/api/todos" && requestPath !== "/api/scheduled-tasks" && requestPath !== "/api/projects/tool" && requestPath !== "/api/question" && (requestPath !== "/api/tools" || request.method !== "POST") && !requestPath.startsWith("/tools/") && !isAuthorized(request, accessToken)) {
|
|
319
|
+
if (requestPath !== "/api/conversations" && requestPath !== "/api/conversation/usage" && requestPath !== "/api/memory/tool" && requestPath !== "/api/knowledge/tool" && requestPath !== "/api/documents/tool" && requestPath !== "/api/web/tool" && requestPath !== "/api/feishu/tool" && requestPath !== "/api/todos" && requestPath !== "/api/scheduled-tasks" && requestPath !== "/api/projects/tool" && requestPath !== "/api/question" && (requestPath !== "/api/tools" || request.method !== "POST") && !requestPath.startsWith("/tools/") && !isAuthorized(request, accessToken)) {
|
|
319
320
|
response.writeHead(401, { "www-authenticate": "Bearer" }).end("Authentication required");
|
|
320
321
|
return;
|
|
321
322
|
}
|
|
@@ -1668,20 +1669,6 @@ export function createHttpServer(options) {
|
|
|
1668
1669
|
json(200, { project });
|
|
1669
1670
|
return;
|
|
1670
1671
|
}
|
|
1671
|
-
if (request.method === "PATCH" && subresource === "budget") {
|
|
1672
|
-
const project = await service.updateBudget(projectId, body, workspaceId);
|
|
1673
|
-
broadcaster.broadcastState();
|
|
1674
|
-
json(200, { project });
|
|
1675
|
-
return;
|
|
1676
|
-
}
|
|
1677
|
-
// ONE CLICK: RAISE THE BUDGET AND CONTINUE. The server computes the new cap, closes the
|
|
1678
|
-
// budget exception and wakes the leader - the client sends no number of its own.
|
|
1679
|
-
if (request.method === "POST" && subresource === "budget" && parts[2] === "continue") {
|
|
1680
|
-
const result = await service.raiseBudgetAndContinue(projectId, workspaceId, callerConversationId);
|
|
1681
|
-
broadcaster.broadcastState();
|
|
1682
|
-
json(200, result);
|
|
1683
|
-
return;
|
|
1684
|
-
}
|
|
1685
1672
|
if (request.method === "POST" && subresource === "tasks" && parts[2] && parts[3] === "dispatch") {
|
|
1686
1673
|
const task = await service.dispatchTask(projectId, parts[2], workspaceId);
|
|
1687
1674
|
broadcaster.broadcastState();
|
|
@@ -1856,12 +1843,13 @@ export function createHttpServer(options) {
|
|
|
1856
1843
|
throw new Error("dispatch requires conversationId");
|
|
1857
1844
|
if (!body.content)
|
|
1858
1845
|
throw new Error("dispatch requires content");
|
|
1846
|
+
const deliveryMode = parseMessageDeliveryMode(body.mode);
|
|
1859
1847
|
const scope = verifyTargetScope(body.conversationId, "调度");
|
|
1860
1848
|
if (!scope.ok) {
|
|
1861
1849
|
json(scope.status, { error: scope.error });
|
|
1862
1850
|
return;
|
|
1863
1851
|
}
|
|
1864
|
-
const result = await service.dispatch(body.conversationId, body.content, { wait: body.wait });
|
|
1852
|
+
const result = await service.dispatch(body.conversationId, body.content, { wait: body.wait, mode: deliveryMode });
|
|
1865
1853
|
json(200, { ok: true, ...result });
|
|
1866
1854
|
return;
|
|
1867
1855
|
}
|
|
@@ -1906,7 +1894,11 @@ export function createHttpServer(options) {
|
|
|
1906
1894
|
json(scope.status, { error: scope.error });
|
|
1907
1895
|
return;
|
|
1908
1896
|
}
|
|
1909
|
-
const result = await service.stop(body.conversationId, {
|
|
1897
|
+
const result = await service.stop(body.conversationId, {
|
|
1898
|
+
mode: body.mode,
|
|
1899
|
+
messageId: body.messageId,
|
|
1900
|
+
messageIds: body.messageIds,
|
|
1901
|
+
});
|
|
1910
1902
|
json(200, { ok: true, ...result });
|
|
1911
1903
|
return;
|
|
1912
1904
|
}
|
|
@@ -1925,6 +1917,24 @@ export function createHttpServer(options) {
|
|
|
1925
1917
|
json(200, { ok: true, ...result });
|
|
1926
1918
|
return;
|
|
1927
1919
|
}
|
|
1920
|
+
if (action === "remove") {
|
|
1921
|
+
if (!body.conversationId)
|
|
1922
|
+
throw new Error("remove requires conversationId");
|
|
1923
|
+
// Already-absent targets resolve idempotently via service.remove; existing targets must
|
|
1924
|
+
// still pass the direct-child scope check so top-level, self, or unrelated sessions fail.
|
|
1925
|
+
if (context.store.conversation(body.conversationId)) {
|
|
1926
|
+
const scope = verifyTargetScope(body.conversationId, "移出");
|
|
1927
|
+
if (!scope.ok) {
|
|
1928
|
+
json(scope.status, { error: scope.error });
|
|
1929
|
+
return;
|
|
1930
|
+
}
|
|
1931
|
+
}
|
|
1932
|
+
const result = await service.remove(body.conversationId, {
|
|
1933
|
+
reason: typeof body.reason === "string" ? body.reason : undefined,
|
|
1934
|
+
});
|
|
1935
|
+
json(200, { ok: true, ...result });
|
|
1936
|
+
return;
|
|
1937
|
+
}
|
|
1928
1938
|
if (action === "resume") {
|
|
1929
1939
|
if (!body.conversationId)
|
|
1930
1940
|
throw new Error("resume requires conversationId");
|
|
@@ -2040,11 +2050,15 @@ export function createHttpServer(options) {
|
|
|
2040
2050
|
json(400, { error: "缺少 conversationId" });
|
|
2041
2051
|
return;
|
|
2042
2052
|
}
|
|
2053
|
+
if (body.subtree && body.messageIds !== undefined) {
|
|
2054
|
+
json(400, { error: "stopSubtree 不支持按 messageIds 撤回单会话队列消息" });
|
|
2055
|
+
return;
|
|
2056
|
+
}
|
|
2043
2057
|
// THE TREE GOES WITH THE ROOT WHEN THE PERSON ASKS FOR THE TREE. Stopping one session and
|
|
2044
2058
|
// stopping its whole branch are two different intentions, and the person says which.
|
|
2045
2059
|
const result = body.subtree
|
|
2046
2060
|
? await service.stopSubtree(conversationId, { mode: body.mode, messageId: body.messageId })
|
|
2047
|
-
: await service.stop(conversationId, { mode: body.mode, messageId: body.messageId });
|
|
2061
|
+
: await service.stop(conversationId, { mode: body.mode, messageId: body.messageId, messageIds: body.messageIds });
|
|
2048
2062
|
json(200, { ok: true, ...result });
|
|
2049
2063
|
}
|
|
2050
2064
|
catch (error) {
|
|
@@ -2052,6 +2066,19 @@ export function createHttpServer(options) {
|
|
|
2052
2066
|
}
|
|
2053
2067
|
return;
|
|
2054
2068
|
}
|
|
2069
|
+
if (url.pathname === "/api/conversations") {
|
|
2070
|
+
const json = (status, payload) => {
|
|
2071
|
+
response.writeHead(status, { "content-type": "application/json; charset=utf-8", "cache-control": "no-store" }).end(JSON.stringify(payload));
|
|
2072
|
+
};
|
|
2073
|
+
if (request.method !== "GET") {
|
|
2074
|
+
json(405, { error: "仅支持 GET 请求。" });
|
|
2075
|
+
return;
|
|
2076
|
+
}
|
|
2077
|
+
const workspaceId = url.searchParams.get("workspaceId");
|
|
2078
|
+
const conversations = workspaceId ? store.conversationsForWorkspace(workspaceId) : store.clientState().conversations;
|
|
2079
|
+
json(200, { conversations });
|
|
2080
|
+
return;
|
|
2081
|
+
}
|
|
2055
2082
|
if (url.pathname === "/api/conversation/usage") {
|
|
2056
2083
|
const json = (status, payload) => {
|
|
2057
2084
|
response.writeHead(status, { "content-type": "application/json; charset=utf-8", "cache-control": "no-store" }).end(JSON.stringify(payload));
|
package/dist/server/index.js
CHANGED
|
@@ -309,7 +309,7 @@ runService.setExecService(execService);
|
|
|
309
309
|
*/
|
|
310
310
|
const scheduledTaskService = new ScheduledTaskService(store, runService, conversationService, broadcaster);
|
|
311
311
|
const sessionLedger = new SessionLedger();
|
|
312
|
-
const sessionOrchestratorService = new SessionOrchestratorService(store, conversationService, runService, sessionLedger, broadcaster);
|
|
312
|
+
const sessionOrchestratorService = new SessionOrchestratorService(store, conversationService, runService, sessionLedger, broadcaster, undefined, uploadsDir);
|
|
313
313
|
/**
|
|
314
314
|
* THE PROJECT SERVICE IS TOLD HOW TO ASK WHAT AN AGENT IS.
|
|
315
315
|
*
|
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
* the transcript on disk while the live session still holds the old context in memory, and nothing in Pi
|
|
24
24
|
* would notice the difference.
|
|
25
25
|
*/
|
|
26
|
+
import type { PiImageContent } from "./types.js";
|
|
26
27
|
/**
|
|
27
28
|
* The Pi SDK, imported lazily.
|
|
28
29
|
*
|
|
@@ -280,7 +281,7 @@ export declare function withIsolatedSessionEnv<T>(values: Record<string, string>
|
|
|
280
281
|
export interface PiSessionLike {
|
|
281
282
|
/** Runs one turn. Resolves when the agent settles. */
|
|
282
283
|
prompt(message: string, options?: {
|
|
283
|
-
images?:
|
|
284
|
+
images?: PiImageContent[];
|
|
284
285
|
streamingBehavior?: "steer" | "followUp";
|
|
285
286
|
preflightResult?: (success: boolean) => void;
|
|
286
287
|
}): Promise<void>;
|
|
@@ -298,7 +299,7 @@ export interface PiSessionLike {
|
|
|
298
299
|
* Optional because a test double has no queues; its absence means "this session cannot hold a
|
|
299
300
|
* message for later", and the caller falls back to answering it as a turn of its own.
|
|
300
301
|
*/
|
|
301
|
-
followUp?(message: string, images?:
|
|
302
|
+
followUp?(message: string, images?: PiImageContent[]): Promise<"queued" | "handled">;
|
|
302
303
|
sendCustomMessage?(message: {
|
|
303
304
|
customType: string;
|
|
304
305
|
content: unknown;
|
package/dist/server/runtime.js
CHANGED
|
@@ -24,7 +24,7 @@ import { LengthExceededError } from "./turn-failure.js";
|
|
|
24
24
|
// paths recognise a delivery identically. Re-exported because they were part of this module's surface.
|
|
25
25
|
export { describeDeliveredUserMessage, describePiQueue } from "./pi-session-events.js";
|
|
26
26
|
import { createPiSession, createSdkCatalog, piSdkAvailable, resolveTranscriptFile, superPiExtensionPaths } from "./pi-session.js";
|
|
27
|
-
import { TASK_CONVERSATION_ENV, PARENT_CONVERSATION_ENV, TASK_DEPTH_ENV, TASK_ENDPOINT_ENV, TASK_EXEC_ENDPOINT_ENV, TASK_ROSTER_ENV, TASK_TOOL_NAME, TODO_ENDPOINT_ENV, TODO_TOOL_NAME, PROJECT_TOOL_NAME, PROJECT_ENDPOINT_ENV, SCHEDULED_TASK_ENDPOINT_ENV, SCHEDULED_TASK_TOOL_NAME, WORKFLOW_ENDPOINT_ENV, WORKFLOW_TOOL_NAME, RUN_ASYNC_TOOL_NAME, ORCHESTRATOR_ENDPOINT_ENV, ORCHESTRATOR_WORKSPACE_ENV, SESSION_SPAWN_TOOL_NAME, SESSION_STATUS_TOOL_NAME, SESSION_DISPATCH_TOOL_NAME, SESSION_STOP_TOOL_NAME, SESSION_REPORT_TOOL_NAME, SESSION_STOP_SUBTREE_TOOL_NAME, rosterPayload, } from "./task-tool.js";
|
|
27
|
+
import { TASK_CONVERSATION_ENV, PARENT_CONVERSATION_ENV, TASK_DEPTH_ENV, TASK_ENDPOINT_ENV, TASK_EXEC_ENDPOINT_ENV, TASK_ROSTER_ENV, TASK_TOOL_NAME, TODO_ENDPOINT_ENV, TODO_TOOL_NAME, PROJECT_TOOL_NAME, PROJECT_ENDPOINT_ENV, SCHEDULED_TASK_ENDPOINT_ENV, SCHEDULED_TASK_TOOL_NAME, WORKFLOW_ENDPOINT_ENV, WORKFLOW_TOOL_NAME, RUN_ASYNC_TOOL_NAME, ORCHESTRATOR_ENDPOINT_ENV, ORCHESTRATOR_WORKSPACE_ENV, SESSION_SPAWN_TOOL_NAME, SESSION_STATUS_TOOL_NAME, SESSION_DISPATCH_TOOL_NAME, SESSION_STOP_TOOL_NAME, SESSION_REPORT_TOOL_NAME, SESSION_STOP_SUBTREE_TOOL_NAME, SESSION_REMOVE_TOOL_NAME, rosterPayload, } from "./task-tool.js";
|
|
28
28
|
import { BLOCKING_UI_METHODS, EXTENSION_UI_METHODS, } from "./types.js";
|
|
29
29
|
import { loadConversationImages } from "./upload.js";
|
|
30
30
|
import { describeToolCall, describeToolCallArgs, describeToolCallInProgress, extractPartialResultText, extractToolResultText, readQuestionCall } from "./tool-calls.js";
|
|
@@ -966,8 +966,11 @@ export class PiRpcRuntime {
|
|
|
966
966
|
const finished = (async () => {
|
|
967
967
|
try {
|
|
968
968
|
let promptAccepted = false;
|
|
969
|
+
const imagePayloads = this.options.uploadsDir && images?.length
|
|
970
|
+
? await loadConversationImages(this.options.uploadsDir, conversation.id, images)
|
|
971
|
+
: undefined;
|
|
969
972
|
const promptOptions = {
|
|
970
|
-
...(
|
|
973
|
+
...(imagePayloads?.length ? { images: imagePayloads } : {}),
|
|
971
974
|
preflightResult: (success) => {
|
|
972
975
|
if (!success)
|
|
973
976
|
return;
|
|
@@ -1263,7 +1266,7 @@ export class PiRpcRuntime {
|
|
|
1263
1266
|
if (this.options.orchestratorEndpoint)
|
|
1264
1267
|
names.push(PROJECT_TOOL_NAME);
|
|
1265
1268
|
if (this.options.orchestratorEndpoint)
|
|
1266
|
-
names.push(SESSION_SPAWN_TOOL_NAME, SESSION_STATUS_TOOL_NAME, SESSION_DISPATCH_TOOL_NAME, SESSION_STOP_TOOL_NAME, SESSION_REPORT_TOOL_NAME, SESSION_STOP_SUBTREE_TOOL_NAME);
|
|
1269
|
+
names.push(SESSION_SPAWN_TOOL_NAME, SESSION_STATUS_TOOL_NAME, SESSION_DISPATCH_TOOL_NAME, SESSION_STOP_TOOL_NAME, SESSION_REPORT_TOOL_NAME, SESSION_STOP_SUBTREE_TOOL_NAME, SESSION_REMOVE_TOOL_NAME);
|
|
1267
1270
|
return names;
|
|
1268
1271
|
}
|
|
1269
1272
|
/**
|
|
@@ -1482,7 +1485,7 @@ export class PiRpcRuntime {
|
|
|
1482
1485
|
// allowlist and naming a tool Pi has not registered would change the spawn line for every other
|
|
1483
1486
|
// mode. The prompt asks for a bare JSON array and nothing else; if the model spends a turn on a
|
|
1484
1487
|
// tool call anyway the reranker times out and falls back to the lexical order.
|
|
1485
|
-
const agentArgs = memoryReview ? ["--no-extensions", "--no-skills", "--no-mcp", "--no-context-files", "--no-prompt-templates", "--tools", "memory,skill_manage,session_search"] : knowledgeRerank ? ["--no-extensions", "--no-skills", "--no-mcp", "--no-context-files", "--no-prompt-templates"] : await agentSpawnArgs(this.agents.promptDir, agent, { extraAllowedTools: [...(extensionArgs.length ? [TASK_TOOL_NAME, TODO_TOOL_NAME, PROJECT_TOOL_NAME, WORKFLOW_TOOL_NAME, RUN_ASYNC_TOOL_NAME, SCHEDULED_TASK_TOOL_NAME, "question", "tool_register", ...(this.options.orchestratorEndpoint ? [SESSION_SPAWN_TOOL_NAME, SESSION_STATUS_TOOL_NAME, SESSION_DISPATCH_TOOL_NAME, SESSION_STOP_TOOL_NAME, SESSION_REPORT_TOOL_NAME, SESSION_STOP_SUBTREE_TOOL_NAME] : [])] : []), ...(memoryEnabled ? ["memory", "skill_manage", "session_search"] : []), ...(knowledgeEnabled ? [KNOWLEDGE_TOOL_NAME, KNOWLEDGE_IMPORT_TOOL_NAME] : []), ...(documentsEnabled ? [DOCUMENT_READ_TOOL_NAME, DOCUMENT_WRITE_TOOL_NAME] : []), ...(webEnabled ? [WEB_SEARCH_TOOL_NAME, WEB_FETCH_TOOL_NAME] : []), ...(feishuEnabled ? [FEISHU_READ_TOOL_NAME, FEISHU_WRITE_TOOL_NAME] : [])] });
|
|
1488
|
+
const agentArgs = memoryReview ? ["--no-extensions", "--no-skills", "--no-mcp", "--no-context-files", "--no-prompt-templates", "--tools", "memory,skill_manage,session_search"] : knowledgeRerank ? ["--no-extensions", "--no-skills", "--no-mcp", "--no-context-files", "--no-prompt-templates"] : await agentSpawnArgs(this.agents.promptDir, agent, { extraAllowedTools: [...(extensionArgs.length ? [TASK_TOOL_NAME, TODO_TOOL_NAME, PROJECT_TOOL_NAME, WORKFLOW_TOOL_NAME, RUN_ASYNC_TOOL_NAME, SCHEDULED_TASK_TOOL_NAME, "question", "tool_register", ...(this.options.orchestratorEndpoint ? [SESSION_SPAWN_TOOL_NAME, SESSION_STATUS_TOOL_NAME, SESSION_DISPATCH_TOOL_NAME, SESSION_STOP_TOOL_NAME, SESSION_REPORT_TOOL_NAME, SESSION_STOP_SUBTREE_TOOL_NAME, SESSION_REMOVE_TOOL_NAME] : [])] : []), ...(memoryEnabled ? ["memory", "skill_manage", "session_search"] : []), ...(knowledgeEnabled ? [KNOWLEDGE_TOOL_NAME, KNOWLEDGE_IMPORT_TOOL_NAME] : []), ...(documentsEnabled ? [DOCUMENT_READ_TOOL_NAME, DOCUMENT_WRITE_TOOL_NAME] : []), ...(webEnabled ? [WEB_SEARCH_TOOL_NAME, WEB_FETCH_TOOL_NAME] : []), ...(feishuEnabled ? [FEISHU_READ_TOOL_NAME, FEISHU_WRITE_TOOL_NAME] : [])] });
|
|
1486
1489
|
// Refused here, with the reason, rather than handed to the spawn: an ENOENT from `spawn` reads as
|
|
1487
1490
|
// "the app is broken" and hides the one fact that matters, which is where it looked for Pi.
|
|
1488
1491
|
if (!this.pi.found)
|
|
@@ -2569,7 +2572,7 @@ export class PiRpcRuntime {
|
|
|
2569
2572
|
: undefined;
|
|
2570
2573
|
if (!session.followUp)
|
|
2571
2574
|
throw new SteerUnavailableError(`会话 ${conversationId} 的 Pi 不支持排队消息`);
|
|
2572
|
-
const disposition = await session.followUp(message, imagePayloads);
|
|
2575
|
+
const disposition = await session.followUp(message, imagePayloads?.length ? imagePayloads : undefined);
|
|
2573
2576
|
return disposition === "handled" ? "handled" : "queued";
|
|
2574
2577
|
}
|
|
2575
2578
|
// NO TURN TO FOLLOW. A follow-up is only meaningful while something is running - with nothing
|
|
@@ -2639,7 +2642,7 @@ export class PiRpcRuntime {
|
|
|
2639
2642
|
? await loadConversationImages(this.options.uploadsDir, conversationId, images)
|
|
2640
2643
|
: undefined;
|
|
2641
2644
|
try {
|
|
2642
|
-
await session.prompt(message, { ...(imagePayloads ? { images: imagePayloads } : {}), streamingBehavior: "steer" });
|
|
2645
|
+
await session.prompt(message, { ...(imagePayloads?.length ? { images: imagePayloads } : {}), streamingBehavior: "steer" });
|
|
2643
2646
|
}
|
|
2644
2647
|
catch (error) {
|
|
2645
2648
|
throw error instanceof Error ? error : new Error(String(error));
|
|
@@ -33,7 +33,7 @@ export type ScopeVerdict = {
|
|
|
33
33
|
error: string;
|
|
34
34
|
};
|
|
35
35
|
/** The verb a refusal is about, so the message reads like the action that was refused. */
|
|
36
|
-
export type ScopeVerb = "调度" | "读取" | "停止" | "恢复" | "列出" | "看护";
|
|
36
|
+
export type ScopeVerb = "调度" | "读取" | "停止" | "恢复" | "列出" | "看护" | "移出";
|
|
37
37
|
/** What the caller was trying to reach: a session to manage, a session's children, or a parent to claim. */
|
|
38
38
|
export type ScopeSubject = "manage" | "list-children" | "declare-parent";
|
|
39
39
|
/** The narrow slice of the store this file needs. */
|
package/dist/server/store.d.ts
CHANGED
|
@@ -147,6 +147,10 @@ export declare class Store {
|
|
|
147
147
|
scheduledTasks(): ScheduledTask[];
|
|
148
148
|
projects(): Project[];
|
|
149
149
|
project(projectId: string): Project | undefined;
|
|
150
|
+
/** Conversation IDs that currently have an unresolved escalation requested. */
|
|
151
|
+
openEscalationConversationIds(): Set<string>;
|
|
152
|
+
/** Child conversation IDs whose enqueued session result is still waiting or sending on a non-archived parent. */
|
|
153
|
+
pendingResultConversationIds(): Set<string>;
|
|
150
154
|
setProject(project: Project): Promise<Project>;
|
|
151
155
|
removeProject(projectId: string): Promise<void>;
|
|
152
156
|
/** Small detached rows used when refreshing each conversation's scoped model catalog. */
|
|
@@ -390,6 +394,26 @@ export declare class Store {
|
|
|
390
394
|
archiveConversationTree(conversationId: string): Promise<void>;
|
|
391
395
|
/** Restores one archived tree in one write; active descendants are already restored by definition. */
|
|
392
396
|
unarchiveConversationTree(conversationId: string): Promise<void>;
|
|
397
|
+
/**
|
|
398
|
+
* Lists the conversation IDs in a session's subtree (root first, pre-order).
|
|
399
|
+
* Returns `[]` when the conversation does not exist.
|
|
400
|
+
*/
|
|
401
|
+
conversationSubtreeIds(conversationId: string): string[];
|
|
402
|
+
/**
|
|
403
|
+
* Permanently destroys a child conversation and its entire descendant subtree along with all
|
|
404
|
+
* conversation-scoped store records (messages, tool calls, sub-agent runs, background tasks,
|
|
405
|
+
* workflows, todos, UI locks/collapse markers, and open escalations raised by the destroyed
|
|
406
|
+
* sessions). Refuses top-level sessions and refuses if any session in the subtree is running.
|
|
407
|
+
*/
|
|
408
|
+
deleteConversationSubtree(conversationId: string): Promise<{
|
|
409
|
+
destroyed: Array<{
|
|
410
|
+
id: string;
|
|
411
|
+
title: string;
|
|
412
|
+
workspaceId: string;
|
|
413
|
+
piSessionFile?: string;
|
|
414
|
+
messageIds: string[];
|
|
415
|
+
}>;
|
|
416
|
+
}>;
|
|
393
417
|
/** Pre-order traversal with cycle protection; archived nodes are traversed, not treated as leaves. */
|
|
394
418
|
private conversationSubtree;
|
|
395
419
|
/**
|
package/dist/server/store.js
CHANGED
|
@@ -812,7 +812,16 @@ export class Store {
|
|
|
812
812
|
/** Read one detached conversation for lifecycle operations. */
|
|
813
813
|
conversation(conversationId) {
|
|
814
814
|
const conversation = this.state.conversations.find((item) => item.id === conversationId);
|
|
815
|
-
|
|
815
|
+
if (!conversation)
|
|
816
|
+
return undefined;
|
|
817
|
+
const clone = structuredClone(conversation);
|
|
818
|
+
if (this.openEscalationConversationIds().has(conversation.id)) {
|
|
819
|
+
clone.hasOpenEscalation = true;
|
|
820
|
+
}
|
|
821
|
+
if (this.pendingResultConversationIds().has(conversation.id)) {
|
|
822
|
+
clone.hasPendingResult = true;
|
|
823
|
+
}
|
|
824
|
+
return clone;
|
|
816
825
|
}
|
|
817
826
|
/** Return every pending question in one conversation without cloning unrelated history. */
|
|
818
827
|
pendingQuestions(conversationId) {
|
|
@@ -847,6 +856,41 @@ export class Store {
|
|
|
847
856
|
}
|
|
848
857
|
projects() { return structuredClone(this.state.projects ?? []); }
|
|
849
858
|
project(projectId) { const project = this.state.projects?.find((item) => item.id === projectId); return project ? structuredClone(project) : undefined; }
|
|
859
|
+
/** Conversation IDs that currently have an unresolved escalation requested. */
|
|
860
|
+
openEscalationConversationIds() {
|
|
861
|
+
const set = new Set();
|
|
862
|
+
for (const project of this.state.projects ?? []) {
|
|
863
|
+
for (const e of project.escalations ?? []) {
|
|
864
|
+
if ((e.status === "open" || e.status === "pending") && e.requestedByConversationId) {
|
|
865
|
+
set.add(e.requestedByConversationId);
|
|
866
|
+
}
|
|
867
|
+
}
|
|
868
|
+
}
|
|
869
|
+
return set;
|
|
870
|
+
}
|
|
871
|
+
/** Child conversation IDs whose enqueued session result is still waiting or sending on a non-archived parent. */
|
|
872
|
+
pendingResultConversationIds() {
|
|
873
|
+
const set = new Set();
|
|
874
|
+
for (const parent of this.state.conversations) {
|
|
875
|
+
if (parent.archivedAt)
|
|
876
|
+
continue;
|
|
877
|
+
for (const message of parent.messages) {
|
|
878
|
+
if (message.role !== "tool" || !message.delivery)
|
|
879
|
+
continue;
|
|
880
|
+
const tagMatch = /^<task\b([^>]*)>/.exec(message.content);
|
|
881
|
+
if (!tagMatch)
|
|
882
|
+
continue;
|
|
883
|
+
const attrs = tagMatch[1];
|
|
884
|
+
if (!/\bkind="session"/.test(attrs))
|
|
885
|
+
continue;
|
|
886
|
+
const idMatch = /\bid="([^"]+)"/.exec(attrs);
|
|
887
|
+
if (idMatch?.[1]) {
|
|
888
|
+
set.add(idMatch[1]);
|
|
889
|
+
}
|
|
890
|
+
}
|
|
891
|
+
}
|
|
892
|
+
return set;
|
|
893
|
+
}
|
|
850
894
|
async setProject(project) {
|
|
851
895
|
if (!this.state.projects)
|
|
852
896
|
this.state.projects = [];
|
|
@@ -877,7 +921,19 @@ export class Store {
|
|
|
877
921
|
}
|
|
878
922
|
/** Clone only one workspace's transcripts, never unrelated workspaces or app state. */
|
|
879
923
|
conversationsForWorkspace(workspaceId) {
|
|
880
|
-
|
|
924
|
+
const openEscalations = this.openEscalationConversationIds();
|
|
925
|
+
const pendingResults = this.pendingResultConversationIds();
|
|
926
|
+
return structuredClone(this.state.conversations.filter((item) => item.workspaceId === workspaceId)).map((c) => {
|
|
927
|
+
const hasOpenEscalation = openEscalations.has(c.id);
|
|
928
|
+
const hasPendingResult = pendingResults.has(c.id);
|
|
929
|
+
if (!hasOpenEscalation && !hasPendingResult)
|
|
930
|
+
return c;
|
|
931
|
+
return {
|
|
932
|
+
...c,
|
|
933
|
+
...(hasOpenEscalation ? { hasOpenEscalation: true } : {}),
|
|
934
|
+
...(hasPendingResult ? { hasPendingResult: true } : {}),
|
|
935
|
+
};
|
|
936
|
+
});
|
|
881
937
|
}
|
|
882
938
|
async setModelFilterRules(rules) {
|
|
883
939
|
if (!Array.isArray(rules) || rules.some(rule => !rule || typeof rule.id !== "string" || typeof rule.workspacePattern !== "string" || typeof rule.modelPattern !== "string" || (rule.label !== undefined && typeof rule.label !== "string")))
|
|
@@ -934,6 +990,16 @@ export class Store {
|
|
|
934
990
|
snapshot() {
|
|
935
991
|
const startedAt = process.env.SUPER_PI_TRACE_LATENCY === "1" ? performance.now() : 0;
|
|
936
992
|
const value = structuredClone(this.state);
|
|
993
|
+
const openEscalations = this.openEscalationConversationIds();
|
|
994
|
+
const pendingResults = this.pendingResultConversationIds();
|
|
995
|
+
for (const conv of value.conversations) {
|
|
996
|
+
if (openEscalations.has(conv.id)) {
|
|
997
|
+
conv.hasOpenEscalation = true;
|
|
998
|
+
}
|
|
999
|
+
if (pendingResults.has(conv.id)) {
|
|
1000
|
+
conv.hasPendingResult = true;
|
|
1001
|
+
}
|
|
1002
|
+
}
|
|
937
1003
|
// Do not stringify here just to count bytes: that makes tracing add a second full serialization
|
|
938
1004
|
// and mislabels that extra work as clone time. The broadcaster measures the actual JSON payload.
|
|
939
1005
|
if (startedAt)
|
|
@@ -1134,15 +1200,35 @@ export class Store {
|
|
|
1134
1200
|
const closed = new Set(this.state.workspaces.filter((item) => item.closedAt).map((item) => item.id));
|
|
1135
1201
|
const workspaces = this.state.workspaces.filter((item) => !closed.has(item.id));
|
|
1136
1202
|
const visible = this.state.conversations.filter((item) => !closed.has(item.workspaceId));
|
|
1203
|
+
const openEscalations = this.openEscalationConversationIds();
|
|
1204
|
+
const pendingResults = this.pendingResultConversationIds();
|
|
1137
1205
|
// Legacy sockets still receive complete visible transcripts. Project before cloning so a closed
|
|
1138
1206
|
// workspace's retained history is never copied just to discard it afterwards.
|
|
1139
|
-
if (scope === undefined)
|
|
1140
|
-
return structuredClone({
|
|
1207
|
+
if (scope === undefined) {
|
|
1208
|
+
return structuredClone({
|
|
1209
|
+
...publicState,
|
|
1210
|
+
workspaces,
|
|
1211
|
+
conversations: visible.map((c) => {
|
|
1212
|
+
const hasOpenEscalation = openEscalations.has(c.id);
|
|
1213
|
+
const hasPendingResult = pendingResults.has(c.id);
|
|
1214
|
+
if (!hasOpenEscalation && !hasPendingResult)
|
|
1215
|
+
return c;
|
|
1216
|
+
return {
|
|
1217
|
+
...c,
|
|
1218
|
+
...(hasOpenEscalation ? { hasOpenEscalation: true } : {}),
|
|
1219
|
+
...(hasPendingResult ? { hasPendingResult: true } : {}),
|
|
1220
|
+
};
|
|
1221
|
+
}),
|
|
1222
|
+
serverTimeZone: serverTimeZone(),
|
|
1223
|
+
});
|
|
1224
|
+
}
|
|
1141
1225
|
// A focused socket keeps every sidebar row, but owns only the selected transcript. An empty scope
|
|
1142
1226
|
// deliberately loads none; a missing/closed selection must not expose retained workspace history.
|
|
1143
1227
|
const selectedId = visible.find((item) => item.id === scope.conversationId)?.id;
|
|
1144
1228
|
const conversations = visible.map(({ messages, ...metadata }) => ({
|
|
1145
1229
|
...metadata,
|
|
1230
|
+
...(openEscalations.has(metadata.id) ? { hasOpenEscalation: true } : {}),
|
|
1231
|
+
...(pendingResults.has(metadata.id) ? { hasPendingResult: true } : {}),
|
|
1146
1232
|
messages: metadata.id === selectedId ? messages : [],
|
|
1147
1233
|
messagesLoaded: metadata.id === selectedId,
|
|
1148
1234
|
hasPendingQuestion: messages.some((message) => message.toolCalls?.some((call) => call.question?.status === "pending")),
|
|
@@ -1456,6 +1542,145 @@ export class Store {
|
|
|
1456
1542
|
delete conversation.archivedAt;
|
|
1457
1543
|
await this.persist();
|
|
1458
1544
|
}
|
|
1545
|
+
/**
|
|
1546
|
+
* Lists the conversation IDs in a session's subtree (root first, pre-order).
|
|
1547
|
+
* Returns `[]` when the conversation does not exist.
|
|
1548
|
+
*/
|
|
1549
|
+
conversationSubtreeIds(conversationId) {
|
|
1550
|
+
const root = this.state.conversations.find((item) => item.id === conversationId);
|
|
1551
|
+
if (!root)
|
|
1552
|
+
return [];
|
|
1553
|
+
return this.conversationSubtree(root).map((item) => item.id);
|
|
1554
|
+
}
|
|
1555
|
+
/**
|
|
1556
|
+
* Permanently destroys a child conversation and its entire descendant subtree along with all
|
|
1557
|
+
* conversation-scoped store records (messages, tool calls, sub-agent runs, background tasks,
|
|
1558
|
+
* workflows, todos, UI locks/collapse markers, and open escalations raised by the destroyed
|
|
1559
|
+
* sessions). Refuses top-level sessions and refuses if any session in the subtree is running.
|
|
1560
|
+
*/
|
|
1561
|
+
async deleteConversationSubtree(conversationId) {
|
|
1562
|
+
const root = this.state.conversations.find((item) => item.id === conversationId);
|
|
1563
|
+
if (!root)
|
|
1564
|
+
return { destroyed: [] };
|
|
1565
|
+
if (!root.parentConversationId) {
|
|
1566
|
+
throw new Error("顶层会话不能销毁,只能由用户归档。");
|
|
1567
|
+
}
|
|
1568
|
+
const subtree = this.conversationSubtree(root);
|
|
1569
|
+
const running = subtree.find((item) => item.status === "running" || item.status === "awaiting_background");
|
|
1570
|
+
if (running) {
|
|
1571
|
+
throw new Error(`会话「${running.title}」仍在运行,无法销毁,请先停止运行。`);
|
|
1572
|
+
}
|
|
1573
|
+
const destroyed = subtree.map((item) => ({
|
|
1574
|
+
id: item.id,
|
|
1575
|
+
title: item.title,
|
|
1576
|
+
workspaceId: item.workspaceId,
|
|
1577
|
+
...(item.piSessionFile ? { piSessionFile: item.piSessionFile } : {}),
|
|
1578
|
+
messageIds: item.messages.map((message) => message.id),
|
|
1579
|
+
}));
|
|
1580
|
+
const destroyedIds = new Set(destroyed.map((item) => item.id));
|
|
1581
|
+
const previousConversations = this.state.conversations;
|
|
1582
|
+
const previousSubagentRuns = this.state.subagentRuns;
|
|
1583
|
+
const previousBackgroundTasks = this.state.backgroundTasks;
|
|
1584
|
+
const previousTodos = this.state.todosByConversation;
|
|
1585
|
+
const previousWorkflows = this.state.workflows;
|
|
1586
|
+
const previousScheduledTasks = this.state.scheduledTasks;
|
|
1587
|
+
const previousCollapsed = this.state.collapsedConversationIds;
|
|
1588
|
+
const previousUnlocked = this.state.unlockedChildConversationIds;
|
|
1589
|
+
const previousProjects = this.state.projects;
|
|
1590
|
+
this.state.conversations = this.state.conversations.filter((item) => !destroyedIds.has(item.id));
|
|
1591
|
+
this.state.subagentRuns = this.state.subagentRuns.filter((run) => !destroyedIds.has(run.conversationId));
|
|
1592
|
+
this.state.backgroundTasks = this.state.backgroundTasks.filter((task) => !destroyedIds.has(task.conversationId));
|
|
1593
|
+
if (this.state.todosByConversation) {
|
|
1594
|
+
const nextTodos = { ...this.state.todosByConversation };
|
|
1595
|
+
for (const id of destroyedIds)
|
|
1596
|
+
delete nextTodos[id];
|
|
1597
|
+
if (Object.keys(nextTodos).length === 0)
|
|
1598
|
+
delete this.state.todosByConversation;
|
|
1599
|
+
else
|
|
1600
|
+
this.state.todosByConversation = nextTodos;
|
|
1601
|
+
}
|
|
1602
|
+
if (this.state.workflows) {
|
|
1603
|
+
const nextWorkflows = this.state.workflows.filter((workflow) => !workflow?.conversationId || !destroyedIds.has(workflow.conversationId));
|
|
1604
|
+
if (nextWorkflows.length === 0)
|
|
1605
|
+
delete this.state.workflows;
|
|
1606
|
+
else
|
|
1607
|
+
this.state.workflows = nextWorkflows;
|
|
1608
|
+
}
|
|
1609
|
+
if (this.state.scheduledTasks) {
|
|
1610
|
+
this.state.scheduledTasks = this.state.scheduledTasks.map((task) => {
|
|
1611
|
+
if (!task?.conversationId || !destroyedIds.has(task.conversationId))
|
|
1612
|
+
return task;
|
|
1613
|
+
const copy = { ...task };
|
|
1614
|
+
delete copy.conversationId;
|
|
1615
|
+
return copy;
|
|
1616
|
+
});
|
|
1617
|
+
}
|
|
1618
|
+
if (this.state.collapsedConversationIds) {
|
|
1619
|
+
const nextCollapsed = this.state.collapsedConversationIds.filter((id) => !destroyedIds.has(id));
|
|
1620
|
+
if (nextCollapsed.length === 0)
|
|
1621
|
+
delete this.state.collapsedConversationIds;
|
|
1622
|
+
else
|
|
1623
|
+
this.state.collapsedConversationIds = nextCollapsed;
|
|
1624
|
+
}
|
|
1625
|
+
if (this.state.unlockedChildConversationIds) {
|
|
1626
|
+
const nextUnlocked = this.state.unlockedChildConversationIds.filter((id) => !destroyedIds.has(id));
|
|
1627
|
+
if (nextUnlocked.length === 0)
|
|
1628
|
+
delete this.state.unlockedChildConversationIds;
|
|
1629
|
+
else
|
|
1630
|
+
this.state.unlockedChildConversationIds = nextUnlocked;
|
|
1631
|
+
}
|
|
1632
|
+
if (this.state.projects) {
|
|
1633
|
+
this.state.projects = this.state.projects.map((project) => {
|
|
1634
|
+
if (!project.escalations?.length)
|
|
1635
|
+
return project;
|
|
1636
|
+
const nextEscalations = project.escalations.filter((escalation) => {
|
|
1637
|
+
const isOpen = escalation.status === "open" || escalation.status === "pending";
|
|
1638
|
+
if (!isOpen)
|
|
1639
|
+
return true;
|
|
1640
|
+
const requestedByDestroyed = Boolean(escalation.requestedByConversationId && destroyedIds.has(escalation.requestedByConversationId));
|
|
1641
|
+
const targetsDestroyed = Boolean(escalation.targetConversationId && destroyedIds.has(escalation.targetConversationId));
|
|
1642
|
+
return !requestedByDestroyed && !targetsDestroyed;
|
|
1643
|
+
});
|
|
1644
|
+
if (nextEscalations.length === project.escalations.length)
|
|
1645
|
+
return project;
|
|
1646
|
+
return { ...project, escalations: nextEscalations };
|
|
1647
|
+
});
|
|
1648
|
+
}
|
|
1649
|
+
try {
|
|
1650
|
+
await this.persist();
|
|
1651
|
+
}
|
|
1652
|
+
catch (error) {
|
|
1653
|
+
this.state.conversations = previousConversations;
|
|
1654
|
+
this.state.subagentRuns = previousSubagentRuns;
|
|
1655
|
+
this.state.backgroundTasks = previousBackgroundTasks;
|
|
1656
|
+
if (previousTodos === undefined)
|
|
1657
|
+
delete this.state.todosByConversation;
|
|
1658
|
+
else
|
|
1659
|
+
this.state.todosByConversation = previousTodos;
|
|
1660
|
+
if (previousWorkflows === undefined)
|
|
1661
|
+
delete this.state.workflows;
|
|
1662
|
+
else
|
|
1663
|
+
this.state.workflows = previousWorkflows;
|
|
1664
|
+
if (previousScheduledTasks === undefined)
|
|
1665
|
+
delete this.state.scheduledTasks;
|
|
1666
|
+
else
|
|
1667
|
+
this.state.scheduledTasks = previousScheduledTasks;
|
|
1668
|
+
if (previousCollapsed === undefined)
|
|
1669
|
+
delete this.state.collapsedConversationIds;
|
|
1670
|
+
else
|
|
1671
|
+
this.state.collapsedConversationIds = previousCollapsed;
|
|
1672
|
+
if (previousUnlocked === undefined)
|
|
1673
|
+
delete this.state.unlockedChildConversationIds;
|
|
1674
|
+
else
|
|
1675
|
+
this.state.unlockedChildConversationIds = previousUnlocked;
|
|
1676
|
+
if (previousProjects === undefined)
|
|
1677
|
+
delete this.state.projects;
|
|
1678
|
+
else
|
|
1679
|
+
this.state.projects = previousProjects;
|
|
1680
|
+
throw error;
|
|
1681
|
+
}
|
|
1682
|
+
return { destroyed };
|
|
1683
|
+
}
|
|
1459
1684
|
/** Pre-order traversal with cycle protection; archived nodes are traversed, not treated as leaves. */
|
|
1460
1685
|
conversationSubtree(root) {
|
|
1461
1686
|
const byParent = new Map();
|
|
@@ -261,15 +261,18 @@ export declare const SESSION_DISPATCH_TOOL_NAME = "session_dispatch";
|
|
|
261
261
|
export declare const SESSION_STOP_TOOL_NAME = "session_stop";
|
|
262
262
|
export declare const SESSION_REPORT_TOOL_NAME = "session_report";
|
|
263
263
|
export declare const SESSION_STOP_SUBTREE_TOOL_NAME = "session_stop_subtree";
|
|
264
|
+
export declare const SESSION_REMOVE_TOOL_NAME = "session_remove";
|
|
264
265
|
/** Model-facing description for session_spawn. */
|
|
265
266
|
export declare const SESSION_SPAWN_DESCRIPTION = "Create a child conversation in the current workspace and immediately dispatch its initial task. You can specify a primary agent as the child's role.\n\nDIFFERENCE FROM THE 'task' TOOL:\n- The 'task' tool delegates to a transient, one-shot subagent process (scout, critic, patcher) that runs once, returns its final text, and terminates. It has no conversation history and does not appear in the workspace sidebar.\n- 'session_spawn' creates a real, persistent child CONVERSATION in Super Pi. It appears in the sidebar, retains multi-turn message history, can receive follow-up messages via session_dispatch, can be inspected via session_status, and can be stopped via session_stop. The user can also switch to it in the Web UI.\n\nWHEN TO USE THIS:\n- Long-running, multi-phase tracks of work that require ongoing context, multiple turns of dialogue, or independent user visibility.\n- Multi-phase or complex work where the user needs each step to be visible and available for inspection or intervention: create a child session with session_spawn.\n- Parallel work streams (e.g., Track A: backend refactor, Track B: frontend component update) where both need full conversational capabilities.\n- When the user asks you to act as an orchestrator/manager who delegates to multiple sessions.\n\nWHEN NOT TO USE THIS:\n- For one-off, focused delegation with a single answer: use 'task' (with scout/critic/patcher). It is faster, cheaper, and returns directly to your transcript.\n- For running shell commands or build watchers: use 'run_async'.\n- For a single one-off delegation with a single answer: use 'task'.\n\nUsage notes:\n1. Spawning is ASYNCHRONOUS by default: it creates the conversation, enqueues the initial task, and returns the new conversationId immediately. The sibling session runs in the background.\n2. The initial task should provide clear context and goals since the new session starts with a fresh conversation history.\n3. Use session_status with the returned conversationId to check progress, or session_dispatch to send further messages.\n4. The new session reports completion to its DIRECT parent automatically, and that parent is always the calling session. 'parentConversationId' may only repeat the calling session's own id - the server refuses (403) any other session as the parent and creates nothing.\n5. The new session always belongs to the calling session's workspace. Pass 'cwd' as a workspace-relative subdirectory (for example, 'packages/a') when it should work below the workspace root; absolute paths and traversal are rejected.\n6. Optionally pass 'model' to choose which model the NEW session runs on: {\"provider\":\"...\",\"modelId\":\"...\"} - the same \"provider/modelId\" pair the model picker shows, and BOTH halves are required. Leave 'model' out and the new session starts on the workspace default model.\n7. Optionally pass 'watchdogTimeoutSeconds' to declare how long YOU are willing to wait for a report before you want to be reminded: a positive number of seconds. If the new session stays silent that long, you receive a '[Watchdog \u63D0\u9192]' message naming it. A report from the child (session_report) restarts the clock; the watchdog never stops the child. Leave it out to run without a watchdog.";
|
|
266
267
|
/** Model-facing description for session_status. */
|
|
267
268
|
export declare const SESSION_STATUS_DESCRIPTION = "Inspect the progress, run state, and latest activity of sibling conversations created by the orchestrator.\n\nWHEN TO USE THIS:\n- To check whether a spawned sibling conversation is still running, has finished (idle), is stopped, or encountered an error.\n- To read the latest assistant progress snippet without bloating your context with the session's entire raw message transcript.\n- To list all sibling conversations under your coordination when conversationId is omitted.\n\nUsage notes:\n1. When 'conversationId' is provided: returns a compact summary for that specific session, including its run status ('idle', 'running', 'waiting', 'stopped', 'failed'), messageCount, turnCount, lastAssistantSnippet, lastUserSnippet, activeTool, and error (if any).\n2. When 'conversationId' is omitted: returns a summary list of sibling conversations whose direct parent is 'parentConversationId' (the calling session by default).\n3. By default it never returns full transcripts; concise summaries keep your context window lean. Set 'includeOutput' with a conversationId to read the final output from its result file, capped to the last 64Ki characters with an explicit truncation notice.";
|
|
268
269
|
/** Model-facing description for session_dispatch. */
|
|
269
|
-
export declare const SESSION_DISPATCH_DESCRIPTION = "Send a message, follow-up instructions, or steering guidance to an existing sibling conversation.\n\nWHEN TO USE THIS:\n- To follow up with a sibling session after reading its progress with session_status.\n- To give feedback, provide additional requirements, or answer a question from a sibling session.\n- To kick off a new turn on an idle or stopped sibling session.\n\nUsage notes:\n1. 'conversationId' is required and must identify an existing sibling conversation.\n2. 'content' is the text instruction sent to that session, just as if typed by a user in that session's chat.\n3. Dispatch is ASYNCHRONOUS by default: it enqueues the message into the session's queue and returns immediately.\n4. If the sibling session is currently busy running a turn, the dispatched message is placed in its waiting queue and processed when the active turn completes.";
|
|
270
|
+
export declare const SESSION_DISPATCH_DESCRIPTION = "Send a message, follow-up instructions, or steering guidance to an existing sibling conversation.\n\nWHEN TO USE THIS:\n- To follow up with a sibling session after reading its progress with session_status.\n- To give feedback, provide additional requirements, or answer a question from a sibling session.\n- To kick off a new turn on an idle or stopped sibling session.\n\nUsage notes:\n1. 'conversationId' is required and must identify an existing sibling conversation.\n2. 'content' is the text instruction sent to that session, just as if typed by a user in that session's chat.\n3. Dispatch is ASYNCHRONOUS by default: it enqueues the message into the session's queue and returns immediately.\n4. If the sibling session is currently busy running a turn, the dispatched message is placed in its waiting queue and processed when the active turn completes.\n5. 'mode' controls delivery when the target session is busy:\n - 'queue' (default): waits until the active turn and earlier queued messages finish (delivered via follow-up queue / subsequent turn; multiple queued messages wait in order).\n - 'steer': delivers at the NEXT turn boundary (after the current tool-call batch completes) ahead of queued follow-up messages. It does NOT kill or abort an in-flight tool call mid-execution. Multiple steered messages arriving before the next boundary may be delivered together at that boundary; when the session is idle, it starts a turn immediately.\n - Invalid 'mode' values are rejected with an error (never silently fall back to 'queue').";
|
|
270
271
|
/** Model-facing description for session_stop. */
|
|
271
|
-
export declare const SESSION_STOP_DESCRIPTION = "Stop execution in a sibling conversation.\n\nWHEN TO USE THIS:\n- When a sibling session has gone down the wrong path, is stuck in an unwanted loop, or when the overall goal has changed and remaining work should be aborted.\n- To clear pending queued messages before they start running.\n\nUsage notes:\n1. 'mode' controls what to stop:\n - 'all' (default): stops the currently running turn and cancels all pending queued messages in the session.\n - 'active': only interrupts the active running turn; leaves any pending queued messages untouched.\n - 'queued': only cancels pending queued messages; lets the currently running turn complete naturally.\n2. Use 'messageId' if you want to cancel or interrupt one specific queued message instead of all queued messages.";
|
|
272
|
+
export declare const SESSION_STOP_DESCRIPTION = "Stop execution in a sibling conversation.\n\nWHEN TO USE THIS:\n- When a sibling session has gone down the wrong path, is stuck in an unwanted loop, or when the overall goal has changed and remaining work should be aborted.\n- To clear pending queued messages before they start running.\n\nUsage notes:\n1. 'mode' controls what to stop:\n - 'all' (default): stops the currently running turn and cancels all pending queued messages in the session.\n - 'active': only interrupts the active running turn; leaves any pending queued messages untouched.\n - 'queued': only cancels pending queued messages; lets the currently running turn complete naturally.\n2. Use 'messageId' if you want to cancel or interrupt one specific queued message instead of all queued messages.\n3. Use 'messageIds' (an array of queued message IDs from session_status or session_dispatch) to selectively withdraw only those queued messages while keeping the running turn, other queued messages, and unrelated steered messages intact.";
|
|
272
273
|
/** Model-facing description for session_report. */
|
|
273
274
|
export declare const SESSION_REPORT_DESCRIPTION = "Report progress from THIS session to the parent session that spawned it.\n\nWHEN TO USE THIS:\n- You are a spawned sibling session, and the parent is waiting to hear from you: a milestone is done, a roadblock appeared, or the task is finished.\n- The parent set a watchdog (session_spawn's 'watchdogTimeoutSeconds'): a report is what restarts that clock, and silence is what triggers the reminder.\n- The task is over and the parent needs the outcome NOW rather than after the automatic end-of-turn result.\n\nWHEN NOT TO USE THIS:\n- This session has no parent (the user opened it directly): there is nobody to report to, and the server refuses the call.\n- You want to ASK the parent something or send it new instructions: that is session_dispatch, and only the parent can send it. A report is one-way - the parent receives it as a message.\n\nUsage notes:\n1. 'content' is required: it is the text the parent receives. Write it for the parent - what is done, what is left, what you need.\n2. 'status' says what the report MEANS:\n - 'in_progress' (default): an interim update. The task continues, and the parent's watchdog clock restarts.\n - 'completed': the task is finished and this is your final word.\n - 'failed': the task could not be finished, and this says why.\n3. A 'completed' or 'failed' report tells the server the work is over, so the parent is NOT also sent the automatic end-of-turn result. Send it once, at the end, with the final answer in 'content'.\n4. Reporting does NOT end your turn. If the task is not done, keep working afterwards - the parent is waiting on the work, not on the report.\n5. The report reaches your DIRECT parent only. A sibling, a cousin, and the user's own session are all out of reach, and the server refuses those.";
|
|
274
275
|
/** Model-facing description for session_stop_subtree. */
|
|
275
276
|
export declare const SESSION_STOP_SUBTREE_DESCRIPTION = "Stop a sibling session AND every session underneath it.\n\nWHEN TO USE THIS:\n- The session has children of its own and you are stopping it: those children would otherwise keep running with a dead parent - zombies that burn tokens, keep writing files, and report results nobody is left to read.\n- The whole branch should go: stopping only the top leaves the work underneath it alive.\n- A child went wrong and everything it started has to go down with it.\n\nWHEN NOT TO USE THIS:\n- The session has no children: session_stop does the same thing to one session and says less.\n- The session is only misbehaving at the top and its children are doing work you still want: stop it alone with session_stop.\n- You want to cancel one queued message: session_stop's 'messageId'.\n\nUsage notes:\n1. 'conversationId' must be your own DIRECT child, exactly as for session_stop. You are not reaching across levels to manage anybody.\n2. Everything under that session goes down with it - children, grandchildren, the whole tree - deepest first, so nothing is left running under a session that is already gone.\n3. The descendants are stopped AS A CONSEQUENCE of stopping the root. They cannot be spared, because a session cannot outlive the one that owns it.\n4. The answer says how many sessions were stopped in total, including the one you named.";
|
|
277
|
+
/** Model-facing description for session_remove. */
|
|
278
|
+
export declare const SESSION_REMOVE_DESCRIPTION = "Permanently destroy a direct child session (and any descendant sessions under it) from the current working group.\n\nWHEN TO USE THIS:\n- A child session's work is finished and you no longer need its session, transcript, or saved output.\n- A child session is stuck and no longer needed, or was spawned by mistake / as a duplicate.\n\nWHEN NOT TO USE THIS:\n- You still plan to send follow-up instructions to it later, or still need its transcript, messages, or saved result file.\n- You want to delete yourself, a top-level user session (top-level projects are archived by the user, not destroyed by agents), or any session that is not your direct child.\n\nUsage notes:\n1. Destroying is PERMANENT, NOT archiving: the child session and its entire descendant subtree are permanently deleted from the store along with their messages, tool calls, sub-agent runs, todos, and saved output artifacts.\n2. Once destroyed, the session and its branch disappear from your active child list, session_status queries, and reporting wait state.\n3. If the child session or any of its descendants is still running or has queued work, session_remove stops the subtree first; if stopping any session fails, the destruction is refused.\n4. Only your DIRECT child can be targeted (top-level user sessions and non-direct-child sessions are refused). Deleting a direct child that has subordinates destroys that whole branch together.\n5. Destroying a session that is already gone is idempotent and succeeds without error.";
|