@evandu/super-pi 0.1.186 → 0.1.188

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.
@@ -1138,7 +1138,7 @@ export async function executeScheduledTask(
1138
1138
  export const PROJECT_TOOL_NAME = "project";
1139
1139
  export const PROJECT_ENDPOINT_ENV = "SUPER_PI_PROJECT_ENDPOINT";
1140
1140
 
1141
- export const PROJECT_DESCRIPTION = `Manage an agile coding team project through clear delegation, evidence, independent review and level-by-level reporting. When the user describes a project in natural language, decompose it yourself into title, objective, deliverables, acceptanceCriteria and top-level tasks, then call action="create" with those fields to stand up the project in one call: create registers the project and its top-level tasks, spawns the leader session, and starts it immediately with the full task list in its context (no separate start call or initial project(action="get") is needed before dispatching work; action="start" remains available for a planning project created outside the tool). Create also accepts optional constraints, risk, default profiles defaultLeaderProfile/defaultExecutorProfile/defaultReviewerProfile, and mode: standard (the default) or lightweight. For a small self-contained project, create it with mode="lightweight": the project leader session does the work itself, the project has no separate worker or reviewer sessions, and a task is accepted on the worker's own evidence. Use the standard mode when the work needs an independent review. In a lightweight project the leader registers only executor tasks, never splits into child tasks and never asks for a review - a submitted task is a completed task. The conversation that created a project may cancel it with action="cancel" and a reason: the project is marked cancelled, its running sessions are stopped, and its record, tasks, events and evidence are kept. Only that initiating conversation may cancel it - a worker or reviewer cannot cancel the project it belongs to. The tasks array carries that decomposition: each entry needs a title and an objective, and its dependencies name the titles of sibling tasks in the same array. You are the initiator: you may create the project, register top-level tasks and cancel if needed; you may not register child tasks or interfere with member execution. Only a root conversation may create a project. Top-level tasks can also be registered later with add_task. When the user asks "我的项目现在怎么样", "我还有哪些项目在跑", "列出所有项目", or wants an overview of running projects, call action="list" first to retrieve up to 20 most recently updated projects with lightweight summaries (headline, task counts, active workers, tokens) without needing a projectId; the response returns projects, total, and returned counts, where total > returned indicates more historical projects exist in the workspace. Never guess a projectId to call get blindly; only call get when the user targets a specific project and you need deep task, escalation or event details. The project leader receives the current tasks in its startup context and does not need to call get before dispatching; it uses add_task (title, objective, deliverables, acceptanceCriteria, dependencies, role=leader/executor, optional executorProfile/reviewerProfile with agentId, cwd, model, thinkingLevel, watchdogTimeoutSeconds), dispatch and request_review. A branch leader creates children with parentTaskId set to its own task ID and manages only its direct tasks. Dependencies must be siblings. Leader aggregate submission requires independently accepted children. Keep at most 3 leader levels and 8 branch leaders; small projects need only one executor. Workers submit output plus evidenceRefs. Only the assigned independent reviewer can review with verdict accepted or changes_requested, summary and evidenceRefs. update_task marks blocked/failed with blockedReason, updates executorProfile/reviewerProfile before child sessions spawn, or the leader resets ready for retry. report records kind=progress/blocked, progress, summary, variance, nextStep, risks, decisionNeeded and evidenceRefs; blocked reports notify your direct supervisor rather than directly alerting Boss. escalate records an optional title, a reason and severity=low/medium/high. The title is ONE SENTENCE naming what the reader has to decide - the question - and the reason is the case for it: why it matters, what the evidence shows, what happens if nobody decides. Give a title whenever the question can be said in one line, because the reader decides on the title and reads the reason only when the question is not obvious; without a title the escalation falls back to its reason. member escalations route to your direct supervisor, and only project leader escalations reach Boss. resolve_escalation closes an escalation that was addressed to you: pass escalationId, decision and status (resolved, dismissed or returned, default resolved). Take escalationId from the escalations array that project(action=get) returns - it is the id of the one escalation you are answering, and the same array tells you whether it is still open. decision is your handling note: what you decided and why. status is optional and defaults to resolved; use dismissed when the question no longer stands. status="returned" means the material was not enough to decide on: the case goes back to whoever raised it, and that person is woken up to supply what is missing instead of the case hanging unanswered. It only accepts a supervisor escalation whose target session is your own - only the session an escalation names may answer it - and an escalation addressed to Boss is the Boss's to decide and is refused for you. Resolving it cascades: the member who raised the escalation is woken up with your decision. complete requires all tasks accepted - independently reviewed in the standard mode, self-accepted in the lightweight mode - and a final summary with evidenceRefs. action="export" returns the project as a Markdown report: the objective, every task with its delivery, evidence and review, the exceptions and how they were decided, and the full timeline. Use it when the user asks for a summary, a handover, or a status write-up of the project. Project and task IDs come from create/get/add_task. Reads never invoke models. Dispatch is asynchronous and starts the child session immediately; wait for child completion reports instead of polling. Do not use session_spawn, session_dispatch, task or workflow to bypass the project's delegation and reporting chain. Never claim success on an error.`;
1141
+ export const PROJECT_DESCRIPTION = `Manage an agile coding team project through clear delegation, evidence, independent review and level-by-level reporting. When the user describes a project in natural language, to create a project you ONLY need title and objective — all other fields (deliverables, acceptanceCriteria, constraints, risk, tasks, default profiles, mode) are optional; omit whatever you do not already have, leaving them out never blocks starting, and never pause to invent or fill optional parameters before calling action="create". Call action="create" with title and objective (plus any optional fields you already know) to stand up the project in one call: create registers the project (and any optional top-level tasks), spawns the leader session, and starts it immediately with the full context (no separate start call or initial project(action="get") is needed before work begins; action="start" remains available for a planning project created outside the tool). Optional fields include deliverables, acceptanceCriteria, constraints, risk (defaults to low; any value is accepted without error), defaultLeaderProfile/defaultExecutorProfile/defaultReviewerProfile, and mode: standard (the default) or lightweight. For a small self-contained project, create it with mode="lightweight": the project leader session does the work itself, the project has no separate worker or reviewer sessions, and a task is accepted on the worker's own evidence. Use the standard mode when the work needs an independent review. In a lightweight project the leader registers only executor tasks, never splits into child tasks and never asks for a review - a submitted task is a completed task. The conversation that created a project may cancel it with action="cancel" and a reason: the project is marked cancelled, its running sessions are stopped, and its record, tasks, events and evidence are kept. Only that initiating conversation may cancel it - a worker or reviewer cannot cancel the project it belongs to. If you choose to pass the optional tasks array, each entry only needs a title and an objective, and its dependencies name the titles of sibling tasks in the same array. You are the initiator: you may create the project, register top-level tasks and cancel if needed; you may not register child tasks or interfere with member execution. Only a root conversation may create a project. Top-level tasks can also be registered later with add_task. When the user asks "我的项目现在怎么样", "我还有哪些项目在跑", "列出所有项目", or wants an overview of running projects, call action="list" first to retrieve up to 20 most recently updated projects with lightweight summaries (headline, task counts, active workers, tokens) without needing a projectId; the response returns projects, total, and returned counts, where total > returned indicates more historical projects exist in the workspace. Never guess a projectId to call get blindly; only call get when the user targets a specific project and you need deep task, escalation or event details. The project leader receives the current tasks in its startup context and does not need to call get before dispatching; it uses add_task (only title and objective are required; deliverables, acceptanceCriteria, dependencies, role=leader/executor, and executorProfile/reviewerProfile with agentId, cwd, model, thinkingLevel, watchdogTimeoutSeconds are optional), dispatch and request_review. A branch leader creates children with parentTaskId set to its own task ID and manages only its direct tasks. Dependencies must be siblings. Leader aggregate submission requires independently accepted children. Keep at most 3 leader levels and 8 branch leaders; small projects need only one executor. Workers submit output plus evidenceRefs. Only the assigned independent reviewer can review with verdict accepted or changes_requested, summary and evidenceRefs. update_task marks blocked/failed with blockedReason, updates executorProfile/reviewerProfile before child sessions spawn, or the leader resets ready for retry. report records kind=progress/blocked, progress, summary, variance, nextStep, risks, decisionNeeded and evidenceRefs; blocked reports notify your direct supervisor rather than directly alerting Boss. escalate records an optional title, a reason and severity=low/medium/high. The title is ONE SENTENCE naming what the reader has to decide - the question - and the reason is the case for it: why it matters, what the evidence shows, what happens if nobody decides. Give a title whenever the question can be said in one line, because the reader decides on the title and reads the reason only when the question is not obvious; without a title the escalation falls back to its reason. member escalations route to your direct supervisor, and only project leader escalations reach Boss. resolve_escalation closes an escalation that was addressed to you: pass escalationId, decision and status (resolved, dismissed or returned, default resolved). Take escalationId from the escalations array that project(action=get) returns - it is the id of the one escalation you are answering, and the same array tells you whether it is still open. decision is your handling note: what you decided and why. status is optional and defaults to resolved; use dismissed when the question no longer stands. status="returned" means the material was not enough to decide on: the case goes back to whoever raised it, and that person is woken up to supply what is missing instead of the case hanging unanswered. It only accepts a supervisor escalation whose target session is your own - only the session an escalation names may answer it - and an escalation addressed to Boss is the Boss's to decide and is refused for you. Resolving it cascades: the member who raised the escalation is woken up with your decision. complete requires all tasks accepted - independently reviewed in the standard mode, self-accepted in the lightweight mode - and a final summary with evidenceRefs. action="export" returns the project as a Markdown report: the objective, every task with its delivery, evidence and review, the exceptions and how they were decided, and the full timeline. Use it when the user asks for a summary, a handover, or a status write-up of the project. Project and task IDs come from create/get/add_task. Reads never invoke models. Dispatch is asynchronous and starts the child session immediately; wait for child completion reports instead of polling. Do not use session_spawn, session_dispatch, task or workflow to bypass the project's delegation and reporting chain. Never claim success on an error.`;
1142
1142
 
1143
1143
  export function readProjectConfig(env: Record<string, string | undefined>) {
1144
1144
  return { endpoint: env[PROJECT_ENDPOINT_ENV] ?? "", conversationId: env[TASK_CONVERSATION_ENV] ?? "", workspaceId: env.SUPER_PI_ORCHESTRATOR_WORKSPACE ?? "", capability: env[TASK_CAPABILITY_ENV] };
@@ -1165,6 +1165,7 @@ export const SESSION_STOP_TOOL_NAME = "session_stop";
1165
1165
  export const SESSION_REPORT_TOOL_NAME = "session_report";
1166
1166
  export const SESSION_STOP_SUBTREE_TOOL_NAME = "session_stop_subtree";
1167
1167
  export const SESSION_REMOVE_TOOL_NAME = "session_remove";
1168
+ export const SESSION_REMINDER_TOOL_NAME = "session_reminder";
1168
1169
 
1169
1170
  /** Model-facing description for session_spawn. */
1170
1171
  export 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.
@@ -1298,6 +1299,134 @@ Usage notes:
1298
1299
  4. 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.
1299
1300
  5. Destroying a session that is already gone is idempotent and succeeds without error.`;
1300
1301
 
1302
+ /**
1303
+ * Model-facing description for session_reminder.
1304
+ *
1305
+ * THE COPY IN `src/server/task-tool.ts` MUST BE THE SAME STRING. The two files are loaded by two
1306
+ * different module systems, so the text is written out twice and `scripts/session-reminder-pmo-rights.test.mjs`
1307
+ * asserts the two copies agree - exactly the wire rule every other tool on this extension follows.
1308
+ */
1309
+ export const SESSION_REMINDER_DESCRIPTION = `Set an in-session timer that delivers a reminder note back to THIS conversation after a given number of seconds. Multiple reminders can run in parallel, and pending reminders can be cancelled or listed.
1310
+
1311
+ WHEN TO USE THIS:
1312
+ - Self-reminders and time-based checkpoints (e.g. "Check child session progress in 60 seconds", "Review test run in 120 seconds").
1313
+ - Unlike scheduled_task which runs in a separate independent conversation, session_reminder sends the note back to THIS EXACT conversation as a new turn so you can follow up directly.
1314
+
1315
+ Actions:
1316
+ - "create" (default): Schedule a reminder. Requires delaySeconds (or seconds) and note. Returns reminderId.
1317
+ - "cancel": Cancel a pending reminder. Requires reminderId.
1318
+ - "list": List all active pending reminders for this conversation.`;
1319
+
1320
+ /** The parameters `session_reminder` accepts. The action is optional and defaults to "create". */
1321
+ export type SessionReminderParams = {
1322
+ action?: "create" | "cancel" | "list";
1323
+ delaySeconds?: number;
1324
+ seconds?: number;
1325
+ note?: string;
1326
+ reminderId?: string;
1327
+ };
1328
+
1329
+ /**
1330
+ * Execute session_reminder: set, cancel or list this conversation's own reminders.
1331
+ *
1332
+ * THE REMINDER COMES BACK HERE, NOT SOMEWHERE ELSE. The note is delivered to the CALLING
1333
+ * conversation - the one whose capability this call carries - because a reminder that landed in
1334
+ * another session would be a message nobody is waiting for.
1335
+ */
1336
+ export async function executeSessionReminder(
1337
+ params: SessionReminderParams,
1338
+ config: OrchestratorToolConfig,
1339
+ deps: { signal?: AbortSignal; fetch?: TaskFetch } = {},
1340
+ ): Promise<TaskToolResult> {
1341
+ const text = (body: string, isError?: boolean): TaskToolResult => ({
1342
+ content: [{ type: "text", text: body }],
1343
+ details: undefined,
1344
+ ...(isError ? { isError: true } : {}),
1345
+ });
1346
+
1347
+ if (!config.endpoint) {
1348
+ return text("The session_reminder tool is not available in this session: SUPER_PI_ORCHESTRATOR_ENDPOINT is not set.", true);
1349
+ }
1350
+
1351
+ const action = (params.action ?? "create").trim();
1352
+ if (action !== "create" && action !== "cancel" && action !== "list") {
1353
+ return text(`Unknown session_reminder action "${action}". Use "create", "cancel" or "list".`, true);
1354
+ }
1355
+
1356
+ const body: Record<string, unknown> = {
1357
+ action: "reminder",
1358
+ subaction: action,
1359
+ callerConversationId: config.conversationId || undefined,
1360
+ capability: config.capability,
1361
+ };
1362
+
1363
+ if (action === "create") {
1364
+ const delaySeconds = Number(params.delaySeconds ?? params.seconds);
1365
+ if (!Number.isFinite(delaySeconds) || delaySeconds <= 0) {
1366
+ return text("A reminder needs a positive delay: pass delaySeconds (or seconds).", true);
1367
+ }
1368
+ const note = typeof params.note === "string" ? params.note.trim() : "";
1369
+ if (!note) {
1370
+ return text("A reminder needs a note: say what should be delivered back into this conversation.", true);
1371
+ }
1372
+ body.delaySeconds = delaySeconds;
1373
+ body.note = note;
1374
+ } else if (action === "cancel") {
1375
+ const reminderId = typeof params.reminderId === "string" ? params.reminderId.trim() : "";
1376
+ if (!reminderId) {
1377
+ return text("Cancelling a reminder needs its reminderId. Call session_reminder(action=list) to see the pending ones.", true);
1378
+ }
1379
+ body.reminderId = reminderId;
1380
+ }
1381
+
1382
+ const send = deps.fetch ?? (globalFetch as unknown as TaskFetch);
1383
+ try {
1384
+ const response = await send(config.endpoint, {
1385
+ method: "POST",
1386
+ headers: {
1387
+ "content-type": "application/json",
1388
+ ...(config.token ? { authorization: `Bearer ${config.token}` } : {}),
1389
+ },
1390
+ body: JSON.stringify(body),
1391
+ ...(deps.signal ? { signal: deps.signal } : {}),
1392
+ });
1393
+
1394
+ const bodyText = await response.text();
1395
+ let payload: {
1396
+ ok?: boolean;
1397
+ error?: string;
1398
+ reminderId?: string;
1399
+ delaySeconds?: number;
1400
+ note?: string;
1401
+ reminders?: { reminderId: string; note: string; delaySeconds: number }[];
1402
+ };
1403
+ try {
1404
+ payload = JSON.parse(bodyText);
1405
+ } catch {
1406
+ return text(`The orchestrator endpoint returned HTTP ${response.status}: ${bodyText}`, true);
1407
+ }
1408
+
1409
+ if (!response.ok || !payload.ok) {
1410
+ return text(`The reminder could not be handled: ${payload.error ?? `HTTP ${response.status}`}`, true);
1411
+ }
1412
+
1413
+ if (action === "create") {
1414
+ return text(`Reminder ${payload.reminderId} is set for ${payload.delaySeconds}s from now; it will be delivered back into THIS conversation.`);
1415
+ }
1416
+ if (action === "cancel") {
1417
+ return text(`Reminder ${String(params.reminderId).trim()} was cancelled; it will not fire.`);
1418
+ }
1419
+ const reminders = payload.reminders ?? [];
1420
+ if (!reminders.length) return text("This conversation has no pending reminders.");
1421
+ return text([
1422
+ `${reminders.length} pending reminder(s) in this conversation:`,
1423
+ ...reminders.map((reminder) => `- ${reminder.reminderId} in ${reminder.delaySeconds}s: ${reminder.note}`),
1424
+ ].join("\n"));
1425
+ } catch (error) {
1426
+ return text(`session_reminder network error: ${error instanceof Error ? error.message : String(error)}`, true);
1427
+ }
1428
+ }
1429
+
1301
1430
  /** Compact summary returned for an orchestrated session. */
1302
1431
  export type OrchestratorSessionSummary = {
1303
1432
  conversationId: string;
@@ -45,6 +45,7 @@ import {
45
45
  SESSION_REPORT_TOOL_NAME,
46
46
  SESSION_STOP_SUBTREE_TOOL_NAME,
47
47
  SESSION_REMOVE_TOOL_NAME,
48
+ SESSION_REMINDER_TOOL_NAME,
48
49
  SESSION_SPAWN_DESCRIPTION,
49
50
  SESSION_STATUS_DESCRIPTION,
50
51
  SESSION_DISPATCH_DESCRIPTION,
@@ -52,6 +53,7 @@ import {
52
53
  SESSION_REPORT_DESCRIPTION,
53
54
  SESSION_STOP_SUBTREE_DESCRIPTION,
54
55
  SESSION_REMOVE_DESCRIPTION,
56
+ SESSION_REMINDER_DESCRIPTION,
55
57
  executeSessionSpawn,
56
58
  executeSessionStatus,
57
59
  executeSessionDispatch,
@@ -59,6 +61,7 @@ import {
59
61
  executeSessionReport,
60
62
  executeSessionStopSubtree,
61
63
  executeSessionRemove,
64
+ executeSessionReminder,
62
65
  readOrchestratorConfig,
63
66
  type SessionSpawnParams,
64
67
  type SessionStatusParams,
@@ -67,6 +70,7 @@ import {
67
70
  type SessionReportParams,
68
71
  type SessionStopSubtreeParams,
69
72
  type SessionRemoveParams,
73
+ type SessionReminderParams,
70
74
  } from "./core.ts";
71
75
 
72
76
  /**
@@ -309,24 +313,30 @@ const extension = (pi: ExtensionApi): void => {
309
313
  pi.registerTool({
310
314
  name: PROJECT_TOOL_NAME, label: "Project", description: PROJECT_DESCRIPTION,
311
315
  parameters: Type.Object({
312
- action: Type.Union(["create", "start", "get", "list", "add_task", "dispatch", "submit", "request_review", "review", "update_task", "report", "escalate", "resolve_escalation", "complete", "cancel", "export"].map((value) => Type.Literal(value))),
316
+ action: Type.Union(["create", "start", "get", "list", "add_task", "dispatch", "submit", "request_review", "review", "update_task", "report", "escalate", "resolve_escalation", "correct", "complete", "cancel", "export"].map((value) => Type.Literal(value))),
313
317
  projectId: Type.Optional(Type.String()), taskId: Type.Optional(Type.String()),
314
318
  parentTaskId: Type.Optional(Type.String()), role: Type.Optional(Type.Union([Type.Literal("leader"), Type.Literal("executor")])),
315
- title: Type.Optional(Type.String()), objective: Type.Optional(Type.String()),
316
- deliverables: Type.Optional(Type.Array(Type.String())), acceptanceCriteria: Type.Optional(Type.Array(Type.String())), constraints: Type.Optional(Type.Array(Type.String())), dependencies: Type.Optional(Type.Array(Type.String())),
317
- risk: Type.Optional(Type.String()),
319
+ title: Type.Optional(Type.String({ description: "Required for action=\"create\" (and add_task): short project or task title." })),
320
+ objective: Type.Optional(Type.String({ description: "Required for action=\"create\" (and add_task): what the project or task should achieve." })),
321
+ deliverables: Type.Optional(Type.Array(Type.String(), { description: "Optional deliverables list. Omit if not needed; does not block starting." })),
322
+ acceptanceCriteria: Type.Optional(Type.Array(Type.String(), { description: "Optional acceptance criteria list. Omit if not needed; does not block starting." })),
323
+ constraints: Type.Optional(Type.Array(Type.String(), { description: "Optional constraints list. Omit if not needed; does not block starting." })),
324
+ dependencies: Type.Optional(Type.Array(Type.String())),
325
+ risk: Type.Optional(Type.String({ description: "Optional risk level (defaults to low; any value is accepted without error)." })),
318
326
  mode: Type.Optional(Type.Union([Type.Literal("standard"), Type.Literal("lightweight")])),
319
327
  priority: Type.Optional(Type.String()), status: Type.Optional(Type.String()), blockedReason: Type.Optional(Type.String()),
320
328
  tasks: Type.Optional(Type.Array(Type.Object({
321
329
  title: Type.String(), objective: Type.String(),
322
330
  deliverables: Type.Optional(Type.Array(Type.String())), acceptanceCriteria: Type.Optional(Type.Array(Type.String())),
323
331
  dependencies: Type.Optional(Type.Array(Type.String())), priority: Type.Optional(Type.String()),
324
- }))),
332
+ }), { description: "Optional initial top-level tasks. Omit to let the leader decompose and dispatch." })),
325
333
  output: Type.Optional(Type.String()), evidenceRefs: Type.Optional(Type.Array(Type.String())), verdict: Type.Optional(Type.String()), summary: Type.Optional(Type.String()),
326
334
  kind: Type.Optional(Type.String()), progress: Type.Optional(Type.String()), variance: Type.Optional(Type.String()), nextStep: Type.Optional(Type.String()),
327
335
  risks: Type.Optional(Type.Array(Type.String())), decisionNeeded: Type.Optional(Type.String()), reason: Type.Optional(Type.String()), severity: Type.Optional(Type.String()),
328
336
  escalationId: Type.Optional(Type.String({ description: "The id of the escalation to answer - take it from the escalations array that project(action=get) returns. Required for resolve_escalation" })),
329
337
  decision: Type.Optional(Type.String({ description: "Your handling note on that escalation: what you decided and why. Required for resolve_escalation" })),
338
+ targetConversationId: Type.Optional(Type.String({ description: "For action=\"correct\": the project member session that receives the message. It must be inside this project's tree - a session outside it is refused." })),
339
+ content: Type.Optional(Type.String({ description: "For action=\"correct\": the one message sent to that member session, in its own words. Required for correct." })),
330
340
  defaultLeaderProfile: Type.Optional(Type.Object({
331
341
  agentId: Type.Optional(Type.String()), cwd: Type.Optional(Type.String()),
332
342
  model: Type.Optional(Type.Object({ provider: Type.String(), modelId: Type.String() })),
@@ -643,6 +653,37 @@ const extension = (pi: ExtensionApi): void => {
643
653
  })),
644
654
  });
645
655
 
656
+ /**
657
+ * The `session_reminder` parameter schema.
658
+ *
659
+ * `action` is optional and defaults to "create", because setting a reminder is what the tool is
660
+ * for and a model that only means "remind me later" should not have to spell the action out.
661
+ * `delaySeconds` and `seconds` are the same field under two spellings, and BOTH are accepted:
662
+ * a model that reaches for `seconds` is not wrong, and refusing it would only teach it to
663
+ * retry with a different word.
664
+ */
665
+ const SessionReminderParameters = Type.Object({
666
+ action: Type.Optional(Type.Union([
667
+ Type.Literal("create", { description: "Set a new reminder for this conversation (default)" }),
668
+ Type.Literal("cancel", { description: "Cancel a pending reminder - needs its reminderId" }),
669
+ Type.Literal("list", { description: "List this conversation's pending reminders" }),
670
+ ], {
671
+ description: "What to do: 'create' (default), 'cancel' or 'list'.",
672
+ })),
673
+ delaySeconds: Type.Optional(Type.Number({
674
+ description: "How many seconds from now the reminder fires. Must be positive.",
675
+ })),
676
+ seconds: Type.Optional(Type.Number({
677
+ description: "The same as delaySeconds - accepted because models spell it both ways.",
678
+ })),
679
+ note: Type.Optional(Type.String({
680
+ description: "The reminder text, delivered back into THIS conversation when it fires. Required for create.",
681
+ })),
682
+ reminderId: Type.Optional(Type.String({
683
+ description: "The reminder's id, as returned by create or listed by list. Required for cancel.",
684
+ })),
685
+ });
686
+
646
687
  if (orchestratorConfig.endpoint) {
647
688
  pi.registerTool({
648
689
  name: SESSION_SPAWN_TOOL_NAME,
@@ -729,6 +770,24 @@ const extension = (pi: ExtensionApi): void => {
729
770
  execute: async (_toolCallId, params, signal) =>
730
771
  await executeSessionRemove(params as SessionRemoveParams, orchestratorConfig, { signal: signal ?? undefined }),
731
772
  });
773
+
774
+ /**
775
+ * `session_reminder`, registered AFTER the tools that act on OTHER SESSIONS.
776
+ *
777
+ * The order is the reading order, and this one is the odd one out: every tool above it reaches
778
+ * OUT to somebody else's session, while this one turns the clock on THIS conversation. A model
779
+ * reading the list top to bottom meets the manager's instruments first and its own timer last,
780
+ * which is the order the relationship actually has.
781
+ */
782
+ pi.registerTool({
783
+ name: SESSION_REMINDER_TOOL_NAME,
784
+ label: "Session Reminder",
785
+ description: SESSION_REMINDER_DESCRIPTION,
786
+ promptSnippet: "set a timer that delivers a note back into THIS conversation when it fires",
787
+ parameters: SessionReminderParameters,
788
+ execute: async (_toolCallId, params, signal) =>
789
+ await executeSessionReminder(params as SessionReminderParams, orchestratorConfig, { signal: signal ?? undefined }),
790
+ });
732
791
  }
733
792
  };
734
793
 
@@ -40,5 +40,5 @@
40
40
  "src/client/types.ts": "ef0586e206d0f229ed0e81e72397e1ddfd82c00ae7133d06d20892605e6f1ff4",
41
41
  "src/client/vite-env.d.ts": "65996936fbb042915f7b74a200fcdde7e410f32a669b1ab9597cfaa4b0faddb5"
42
42
  },
43
- "recordedAt": "2026-11-11T11:59:17.007Z"
43
+ "recordedAt": "2026-11-11T16:43:47.484Z"
44
44
  }
@@ -38,7 +38,7 @@ type Frontmatter = Record<string, unknown>;
38
38
  */
39
39
  export declare const PI_TOOL_NAMES: readonly ["read", "bash", "powershell", "edit", "write", "grep", "find", "ls", "codemode", "tool_search", "list_mcp_resources", "list_mcp_resource_templates", "read_mcp_resource"];
40
40
  /** Tools shipped by this package. Authors must be able to explicitly deny host extras. */
41
- export declare const SUPER_PI_TOOL_NAMES: readonly ["task", "todowrite", "workflow", "run_async", "scheduled_task", "project", "question", "tool_register", "memory", "skill_manage", "session_search", "session_spawn", "session_status", "session_dispatch", "session_stop", "session_report", "session_stop_subtree", "session_remove", "knowledge_search", "knowledge_import", "document_read", "document_write", "web_search", "web_fetch", "feishu_doc_read", "feishu_doc_write"];
41
+ export declare const SUPER_PI_TOOL_NAMES: readonly ["task", "todowrite", "workflow", "run_async", "scheduled_task", "project", "question", "tool_register", "memory", "skill_manage", "session_search", "session_spawn", "session_status", "session_dispatch", "session_stop", "session_report", "session_stop_subtree", "session_remove", "session_reminder", "knowledge_search", "knowledge_import", "document_read", "document_write", "web_search", "web_fetch", "feishu_doc_read", "feishu_doc_write"];
42
42
  /**
43
43
  * Whether a name can be a real Pi tool. A name is real if it is one of `PI_TOOL_NAMES`, an MCP
44
44
  * server tool, or a PATTERN.
@@ -41,7 +41,7 @@ export const PI_TOOL_NAMES = [
41
41
  export const SUPER_PI_TOOL_NAMES = [
42
42
  "task", "todowrite", "workflow", "run_async", "scheduled_task", "project", "question", "tool_register",
43
43
  "memory", "skill_manage", "session_search",
44
- "session_spawn", "session_status", "session_dispatch", "session_stop", "session_report", "session_stop_subtree", "session_remove",
44
+ "session_spawn", "session_status", "session_dispatch", "session_stop", "session_report", "session_stop_subtree", "session_remove", "session_reminder",
45
45
  "knowledge_search", "knowledge_import",
46
46
  "document_read", "document_write", "web_search", "web_fetch", "feishu_doc_read", "feishu_doc_write",
47
47
  ];
@@ -41,7 +41,7 @@ export type CreateProjectInput = {
41
41
  deliverables?: unknown;
42
42
  acceptanceCriteria?: unknown;
43
43
  constraints?: unknown;
44
- risk?: ProjectRisk;
44
+ risk?: ProjectRisk | (string & {});
45
45
  ownerConversationId?: string;
46
46
  defaultLeaderProfile?: unknown;
47
47
  defaultExecutorProfile?: unknown;
@@ -360,5 +360,30 @@ export declare class ProjectService {
360
360
  */
361
361
  private planTopLevelTasks;
362
362
  private registerTopLevelTasks;
363
+ /**
364
+ * THE INITIATOR'S LIMITED CORRECTION RIGHT.
365
+ *
366
+ * The person who opened the project gets exactly two things the Leader's chain does not give
367
+ * them: READ-ONLY SUPERVISION of the whole project (the project's own read surface already
368
+ * shows every member's status to every member), and ONE message to any session inside the
369
+ * project tree - a single correction, delivered to that session directly, without having to go
370
+ * through the Leader and wait for it to be relayed.
371
+ *
372
+ * WHY IT IS BOUNDED BY THREE RULES, AND NOT BY "THE INITIATOR CAN DO WHATEVER":
373
+ *
374
+ * 1. ONLY THE INITIATOR. Every other session in the project keeps the reporting line: a member
375
+ * still reaches its direct supervisor, and the Leader still answers to the initiator. If every
376
+ * member could correct every other member, the tree would stop being a tree.
377
+ * 2. ONLY INSIDE THE PROJECT TREE. The target must be one of this project's sessions - the
378
+ * Leader, a branch Leader, a worker, a reviewer. A session that is not in this project is
379
+ * somebody else's department, and this right says nothing about it.
380
+ * 3. ONE MESSAGE, NOT A CHANNEL. This sends a message; it does not open a line. The reporting
381
+ * line, the escalation path and the parent's dispatch rules are untouched by it.
382
+ */
383
+ correctMember(id: string, targetConversationId: string, content: string, workspaceId: string, actor?: string): Promise<{
384
+ ok: true;
385
+ conversationId: string;
386
+ delivered: true;
387
+ }>;
363
388
  tool(body: Record<string, any>, workspaceId: string, actor: string): Promise<unknown>;
364
389
  }
@@ -30,7 +30,7 @@ const text = (value, label) => {
30
30
  };
31
31
  const optional = (value, label) => value === undefined ? undefined : text(value, label);
32
32
  const strings = (value, label) => {
33
- if (value === undefined)
33
+ if (value === undefined || value === null)
34
34
  return [];
35
35
  if (!Array.isArray(value) || value.length > 100)
36
36
  throw new Error(`${label} 必须是最多 100 项的字符串数组`);
@@ -1158,8 +1158,8 @@ export class ProjectService {
1158
1158
  const workspaceId = this.workspace(input.workspaceId);
1159
1159
  if (input.ownerConversationId !== undefined)
1160
1160
  throw new Error("项目负责人由启动操作创建独立会话");
1161
- if (input.risk !== undefined && !["low", "medium", "high"].includes(input.risk))
1162
- throw new Error("项目风险等级不合法");
1161
+ const rawRisk = typeof input.risk === "string" ? input.risk.trim().toLowerCase() : "";
1162
+ const risk = rawRisk === "medium" || rawRisk === "high" ? rawRisk : "low";
1163
1163
  // THE MODE IS CHOSEN ONCE, AT BIRTH, AND IT IS A CLOSED SET. A typo must not silently buy a
1164
1164
  // project the standard shape, because the standard shape is the one with the reviewer.
1165
1165
  if (input.mode !== undefined && input.mode !== "standard" && input.mode !== "lightweight")
@@ -1177,7 +1177,7 @@ export class ProjectService {
1177
1177
  const now = stamp();
1178
1178
  const p = { id: `project_${randomUUID()}`, workspaceId, title: text(input.title, "项目标题"), objective: text(input.objective, "项目目标"),
1179
1179
  deliverables: strings(input.deliverables, "交付物"), acceptanceCriteria: strings(input.acceptanceCriteria, "验收标准"), constraints: strings(input.constraints, "约束"),
1180
- risk: input.risk ?? "low", status: "planning",
1180
+ risk, status: "planning",
1181
1181
  // A project without a mode is a standard project: the mode is written down only when it was
1182
1182
  // asked for, so every project that existed before the mode existed reads as standard.
1183
1183
  ...(input.mode ? { mode: input.mode } : {}),
@@ -2005,6 +2005,51 @@ export class ProjectService {
2005
2005
  ids.set(item.title, task.id);
2006
2006
  }
2007
2007
  }
2008
+ /**
2009
+ * THE INITIATOR'S LIMITED CORRECTION RIGHT.
2010
+ *
2011
+ * The person who opened the project gets exactly two things the Leader's chain does not give
2012
+ * them: READ-ONLY SUPERVISION of the whole project (the project's own read surface already
2013
+ * shows every member's status to every member), and ONE message to any session inside the
2014
+ * project tree - a single correction, delivered to that session directly, without having to go
2015
+ * through the Leader and wait for it to be relayed.
2016
+ *
2017
+ * WHY IT IS BOUNDED BY THREE RULES, AND NOT BY "THE INITIATOR CAN DO WHATEVER":
2018
+ *
2019
+ * 1. ONLY THE INITIATOR. Every other session in the project keeps the reporting line: a member
2020
+ * still reaches its direct supervisor, and the Leader still answers to the initiator. If every
2021
+ * member could correct every other member, the tree would stop being a tree.
2022
+ * 2. ONLY INSIDE THE PROJECT TREE. The target must be one of this project's sessions - the
2023
+ * Leader, a branch Leader, a worker, a reviewer. A session that is not in this project is
2024
+ * somebody else's department, and this right says nothing about it.
2025
+ * 3. ONE MESSAGE, NOT A CHANNEL. This sends a message; it does not open a line. The reporting
2026
+ * line, the escalation path and the parent's dispatch rules are untouched by it.
2027
+ */
2028
+ async correctMember(id, targetConversationId, content, workspaceId, actor) {
2029
+ const p = this.raw(id, workspaceId);
2030
+ if (!actor)
2031
+ throw new Error("纠偏需要发起会话的身份。");
2032
+ // THE INITIATOR, AND ONLY THE INITIATOR.
2033
+ if (actor !== p.initiatorConversationId) {
2034
+ throw new Error("只有项目发起会话可以直接纠偏:其它会话请通过直接上级转述,汇报线不变。");
2035
+ }
2036
+ const target = text(targetConversationId, "targetConversationId");
2037
+ if (target === actor)
2038
+ throw new Error("不能给自己的会话发纠偏消息。");
2039
+ const message = text(content, "content");
2040
+ // INSIDE THIS PROJECT'S TREE, AND ONLY INSIDE IT.
2041
+ const members = new Set([
2042
+ p.ownerConversationId,
2043
+ ...p.tasks.flatMap((t) => [t.ownerConversationId, t.reviewerConversationId]),
2044
+ ].filter(Boolean));
2045
+ if (!members.has(target)) {
2046
+ throw new Error(`会话 ${target} 不在这个项目的会话树里,纠偏只能发给项目树内的会话。`);
2047
+ }
2048
+ if (!this.orchestrator)
2049
+ throw new Error("会话编排服务未就绪");
2050
+ await this.orchestrator.dispatch(target, message, { wait: false });
2051
+ return { ok: true, conversationId: target, delivered: true };
2052
+ }
2008
2053
  async tool(body, workspaceId, actor) {
2009
2054
  if (body.action === "create") {
2010
2055
  // ONLY A ROOT CONVERSATION MAY OPEN A PROJECT. Every dispatched session - the leader, its
@@ -2059,6 +2104,7 @@ export class ProjectService {
2059
2104
  case "resolve_escalation":
2060
2105
  case "resolveEscalation":
2061
2106
  return this.resolveEscalation(id, text(body.escalationId, "escalationId"), text(body.decision, "decision"), body.status ?? "resolved", workspaceId, actor);
2107
+ case "correct": return this.correctMember(id, text(body.targetConversationId, "targetConversationId"), text(body.content, "content"), workspaceId, actor);
2062
2108
  case "complete": return this.complete(id, body.summary, body.evidenceRefs, workspaceId, actor);
2063
2109
  case "cancel": return this.cancel(id, body, workspaceId, actor);
2064
2110
  default: throw new Error("未知的项目工具操作");
@@ -196,6 +196,14 @@ export class SessionOrchestratorService {
196
196
  this.ledger.update(conversationId, {
197
197
  status: "running",
198
198
  });
199
+ // THE CONVERSATION'S OWN RECORD SAYS THE SAME THING. The ledger is metadata the orchestrator
200
+ // keeps for itself; the CONVERSATION's status is what the sidebar, the project panel and the
201
+ // status tool read, and it is the record a person believes. A session that has just been
202
+ // handed its work must not still read `idle` there: `idle` is a claim that nobody is working on
203
+ // it, and work has just been handed over. A Leader that was spawned with its opening prompt
204
+ // and then reads `idle` is a project that says it is running while its own session says it is
205
+ // not.
206
+ await this.store.setStatus(conversationId, "running");
199
207
  // THE ORDER IS THE SYSTEM'S, NOT THE READER'S. It used to go through `enqueueAndRun`, which
200
208
  // writes the words under the reader's own name - so the child's transcript showed an
201
209
  // instruction the reader never typed, wearing the reader's avatar, and a reader who looked at
@@ -0,0 +1,55 @@
1
+ import type { Store } from "../store.js";
2
+ import type { RunService } from "./run-service.js";
3
+ export interface SessionReminderItem {
4
+ reminderId: string;
5
+ conversationId: string;
6
+ note: string;
7
+ delaySeconds: number;
8
+ fireAt: number;
9
+ createdAt: number;
10
+ }
11
+ export declare class SessionReminderService {
12
+ private readonly runService;
13
+ private readonly store;
14
+ private reminders;
15
+ constructor(runService: RunService, store: Store);
16
+ /**
17
+ * Schedules a reminder note to be sent back to the same conversation after delaySeconds.
18
+ */
19
+ createReminder(params: {
20
+ conversationId: string;
21
+ delaySeconds: number;
22
+ note: string;
23
+ }): {
24
+ ok: true;
25
+ reminderId: string;
26
+ delaySeconds: number;
27
+ note: string;
28
+ fireAt: string;
29
+ };
30
+ /**
31
+ * Cancels a pending reminder by ID.
32
+ *
33
+ * A REMINDER BELONGS TO THE CONVERSATION THAT SET IT. `conversationId` is optional only so the
34
+ * service can be called without one; when it IS given, a reminder owned by another conversation
35
+ * is refused, because one session taking another session's timer away is exactly the kind of
36
+ * cross-session reach the tree rules exist to prevent.
37
+ */
38
+ cancelReminder(reminderId: string, conversationId?: string): {
39
+ ok: boolean;
40
+ cancelled?: boolean;
41
+ error?: string;
42
+ };
43
+ /**
44
+ * Lists active reminders for a conversation.
45
+ */
46
+ listReminders(conversationId: string): SessionReminderItem[];
47
+ /**
48
+ * Cancels all pending reminders for a given conversation.
49
+ */
50
+ cancelAllForConversation(conversationId: string): void;
51
+ /**
52
+ * Timer callback: delivers the note to the originating conversation.
53
+ */
54
+ private triggerReminder;
55
+ }