@evandu/super-pi 0.1.221 → 0.1.222

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.
Files changed (37) hide show
  1. package/agents/super-pi-task/core.ts +15 -15
  2. package/agents/super-pi-task/index.ts +5 -2
  3. package/dist/client/.super-pi-client-sources.json +6 -6
  4. package/dist/client/assets/{CodeMirrorEditor-Cv1X2hmd.js → CodeMirrorEditor-IWcAz6oz.js} +2 -2
  5. package/dist/client/assets/{dist-CRfLPcZ8.js → dist-0tDquiIc.js} +1 -1
  6. package/dist/client/assets/{dist-DlBSkHdo.js → dist-B2WzMUqb.js} +1 -1
  7. package/dist/client/assets/{dist-BT_Z_-2X.js → dist-B41_P-GB.js} +1 -1
  8. package/dist/client/assets/{dist-CVErcv3I.js → dist-B4YZqIKX.js} +1 -1
  9. package/dist/client/assets/{dist-C729XRkf.js → dist-BPhtg6ss.js} +1 -1
  10. package/dist/client/assets/{dist-ClwDCrdU.js → dist-Brmqe6G6.js} +1 -1
  11. package/dist/client/assets/{dist-CsqiBKUZ.js → dist-Bx-zvsek.js} +1 -1
  12. package/dist/client/assets/{dist-DPYofnO9.js → dist-ByhQMTZz.js} +1 -1
  13. package/dist/client/assets/{dist-C071I6sD.js → dist-C-CsTWFq.js} +1 -1
  14. package/dist/client/assets/{dist-BqNxkXgs.js → dist-CLfjxR6r.js} +1 -1
  15. package/dist/client/assets/{dist-C-Kbr0WK.js → dist-CRfBzL2s.js} +1 -1
  16. package/dist/client/assets/{dist-w6rH3SJG.js → dist-Cd2jBngi.js} +1 -1
  17. package/dist/client/assets/{dist-IohJ9Qkl.js → dist-ChJliyoT.js} +1 -1
  18. package/dist/client/assets/{dist-CT23BwQB.js → dist-D73UQVEK.js} +1 -1
  19. package/dist/client/assets/{dist-BA1wBjGJ.js → dist-DR-NR2sl.js} +1 -1
  20. package/dist/client/assets/{dist-Gvvox7eW.js → dist-DZFnjuKR.js} +1 -1
  21. package/dist/client/assets/{dist-B3GZVLeH.js → dist-DftBUe3J.js} +1 -1
  22. package/dist/client/assets/{dist-Bxyffyjn.js → dist-DgRXONWV.js} +1 -1
  23. package/dist/client/assets/{dist-J-F3f1eU.js → dist-DglikBo1.js} +1 -1
  24. package/dist/client/assets/{dist-DrNjVA0k.js → dist-JFHBsRN8.js} +1 -1
  25. package/dist/client/assets/{dist-CeHhOkTz.js → dist-KddcFuL2.js} +1 -1
  26. package/dist/client/assets/{dist-xdw6XDXx.js → dist-fzY9qpWd.js} +1 -1
  27. package/dist/client/assets/index-DbtNmSyS.js +103 -0
  28. package/dist/client/assets/index-OmaD3l6r.css +1 -0
  29. package/dist/client/index.html +2 -2
  30. package/dist/server/application/session-reminder-service.d.ts +7 -3
  31. package/dist/server/application/session-reminder-service.js +40 -19
  32. package/dist/server/http-server.js +6 -6
  33. package/dist/server/task-tool.d.ts +1 -1
  34. package/dist/server/task-tool.js +7 -7
  35. package/package.json +1 -1
  36. package/dist/client/assets/index-B-h_KnC5.css +0 -1
  37. package/dist/client/assets/index-CCF1Ymba.js +0 -103
@@ -8,8 +8,8 @@
8
8
  <link rel="alternate icon" href="/favicon.ico" />
9
9
  <link rel="apple-touch-icon" href="/favicon.svg" />
10
10
  <title>Super Pi</title>
11
- <script type="module" crossorigin src="/assets/index-CCF1Ymba.js"></script>
12
- <link rel="stylesheet" crossorigin href="/assets/index-B-h_KnC5.css">
11
+ <script type="module" crossorigin src="/assets/index-DbtNmSyS.js"></script>
12
+ <link rel="stylesheet" crossorigin href="/assets/index-OmaD3l6r.css">
13
13
  </head>
14
14
  <body>
15
15
  <div id="root"></div>
@@ -4,6 +4,7 @@ export interface SessionReminderItem {
4
4
  reminderId: string;
5
5
  conversationId: string;
6
6
  note: string;
7
+ repeat: boolean;
7
8
  delaySeconds: number;
8
9
  fireAt: number;
9
10
  createdAt: number;
@@ -14,19 +15,22 @@ export declare class SessionReminderService {
14
15
  private reminders;
15
16
  constructor(runService: RunService, store: Store);
16
17
  /**
17
- * Schedules a reminder note to be sent back to the same conversation after delaySeconds.
18
+ * Schedules a wake-up for the same conversation after delaySeconds.
18
19
  */
19
20
  createReminder(params: {
20
21
  conversationId: string;
21
22
  delaySeconds: number;
22
- note: string;
23
+ note?: string;
24
+ repeat?: boolean;
23
25
  }): {
24
26
  ok: true;
25
27
  reminderId: string;
26
28
  delaySeconds: number;
27
29
  note: string;
30
+ repeat: boolean;
28
31
  fireAt: string;
29
32
  };
33
+ private arm;
30
34
  /**
31
35
  * Cancels a pending reminder by ID.
32
36
  *
@@ -49,7 +53,7 @@ export declare class SessionReminderService {
49
53
  */
50
54
  cancelAllForConversation(conversationId: string): void;
51
55
  /**
52
- * Timer callback: delivers the note to the originating conversation.
56
+ * Timer callback: wakes the originating conversation.
53
57
  */
54
58
  private triggerReminder;
55
59
  }
@@ -8,10 +8,10 @@ export class SessionReminderService {
8
8
  this.store = store;
9
9
  }
10
10
  /**
11
- * Schedules a reminder note to be sent back to the same conversation after delaySeconds.
11
+ * Schedules a wake-up for the same conversation after delaySeconds.
12
12
  */
13
13
  createReminder(params) {
14
- const { conversationId, note } = params;
14
+ const { conversationId, repeat = false } = params;
15
15
  const delaySeconds = Math.max(1, Math.round(params.delaySeconds));
16
16
  // A REMINDER THAT FIRES IMMEDIATELY IS NOT A REMINDER. `Math.max(1, ...)` would quietly turn a
17
17
  // zero or negative delay into "one second from now", so the bad number is refused in words
@@ -19,9 +19,6 @@ export class SessionReminderService {
19
19
  if (!Number.isFinite(params.delaySeconds) || params.delaySeconds <= 0) {
20
20
  throw new Error("提醒需要正的秒数:请传 delaySeconds(或 seconds)。");
21
21
  }
22
- if (!note || !note.trim()) {
23
- throw new Error("提醒内容 (note) 不能为空");
24
- }
25
22
  const conversation = this.store.conversation(conversationId);
26
23
  if (!conversation) {
27
24
  throw new Error(`找不到会话:${conversationId}`);
@@ -29,30 +26,34 @@ export class SessionReminderService {
29
26
  const reminderId = `rem_${randomUUID()}`;
30
27
  const now = Date.now();
31
28
  const fireAt = now + delaySeconds * 1000;
29
+ if (fireAt > 8.64e15)
30
+ throw new Error("提醒间隔超出日期范围。");
32
31
  const item = {
33
32
  reminderId,
34
33
  conversationId,
35
- note: note.trim(),
34
+ note: repeat ? "" : (params.note?.trim() ?? ""),
35
+ repeat,
36
36
  delaySeconds,
37
37
  fireAt,
38
38
  createdAt: now,
39
39
  };
40
- const timer = setTimeout(() => {
41
- void this.triggerReminder(reminderId);
42
- }, delaySeconds * 1000);
43
- // Node process unref to avoid blocking process exit if idle
44
- if (typeof timer.unref === "function") {
45
- timer.unref();
46
- }
47
- this.reminders.set(reminderId, { item, timer });
40
+ this.reminders.set(reminderId, { item, timer: this.arm(item), lastFiredAt: now, delivering: false });
48
41
  return {
49
42
  ok: true,
50
43
  reminderId,
51
44
  delaySeconds,
52
45
  note: item.note,
46
+ repeat,
53
47
  fireAt: new Date(fireAt).toISOString(),
54
48
  };
55
49
  }
50
+ arm(item) {
51
+ // Node treats delays beyond the signed 32-bit limit as 1 ms. Re-arm long waits in chunks.
52
+ const delay = Math.min(item.fireAt - Date.now(), 2 ** 31 - 1);
53
+ const timer = setTimeout(() => void this.triggerReminder(item.reminderId), delay);
54
+ timer.unref();
55
+ return timer;
56
+ }
56
57
  /**
57
58
  * Cancels a pending reminder by ID.
58
59
  *
@@ -78,7 +79,6 @@ export class SessionReminderService {
78
79
  */
79
80
  listReminders(conversationId) {
80
81
  const results = [];
81
- const now = Date.now();
82
82
  for (const { item } of this.reminders.values()) {
83
83
  if (item.conversationId === conversationId) {
84
84
  results.push({ ...item });
@@ -98,23 +98,44 @@ export class SessionReminderService {
98
98
  }
99
99
  }
100
100
  /**
101
- * Timer callback: delivers the note to the originating conversation.
101
+ * Timer callback: wakes the originating conversation.
102
102
  */
103
103
  async triggerReminder(reminderId) {
104
104
  const entry = this.reminders.get(reminderId);
105
105
  if (!entry)
106
106
  return;
107
- this.reminders.delete(reminderId);
108
- const { conversationId, note } = entry.item;
107
+ const now = Date.now();
108
+ if (now < entry.item.fireAt) {
109
+ entry.timer = this.arm(entry.item);
110
+ return;
111
+ }
112
+ const { conversationId, note, repeat, delaySeconds } = entry.item;
109
113
  const conversation = this.store.conversation(conversationId);
110
114
  if (!conversation || conversation.archivedAt) {
115
+ this.reminders.delete(reminderId);
111
116
  return;
112
117
  }
118
+ if (repeat) {
119
+ entry.item.fireAt = now + delaySeconds * 1000;
120
+ entry.timer = this.arm(entry.item);
121
+ // One wake-up is enough while a previous reminder is running or still in the queue.
122
+ if (entry.delivering || this.store.listWaitingMessages(conversationId).some(message => message.source === "session-reminder"))
123
+ return;
124
+ }
125
+ else {
126
+ this.reminders.delete(reminderId);
127
+ }
128
+ const elapsed = Math.round((now - entry.lastFiredAt) / 1000);
129
+ entry.delivering = true;
113
130
  try {
114
- await this.runService.enqueueReminder(conversationId, note);
131
+ await this.runService.enqueueReminder(conversationId, note || `距上次计时已过 ${elapsed} 秒。`);
132
+ entry.lastFiredAt = now;
115
133
  }
116
134
  catch (error) {
117
135
  console.warn(`Super Pi: delivering session reminder to ${conversationId} failed:`, error instanceof Error ? error.message : String(error));
118
136
  }
137
+ finally {
138
+ entry.delivering = false;
139
+ }
119
140
  }
120
141
  }
@@ -2102,13 +2102,13 @@ export function createHttpServer(options) {
2102
2102
  json(400, { error: "提醒需要正的秒数:请传 delaySeconds(或 seconds)。" });
2103
2103
  return;
2104
2104
  }
2105
- const note = typeof body.note === "string" ? body.note.trim() : "";
2106
- if (!note) {
2107
- json(400, { error: "提醒内容不能为空:note 要写清楚提醒什么。" });
2108
- return;
2109
- }
2110
2105
  try {
2111
- const created = reminders.createReminder({ conversationId: callerConversationId, delaySeconds, note });
2106
+ const created = reminders.createReminder({
2107
+ conversationId: callerConversationId,
2108
+ delaySeconds,
2109
+ note: typeof body.note === "string" ? body.note : undefined,
2110
+ repeat: body.repeat === true,
2111
+ });
2112
2112
  json(200, { ...created, ok: true });
2113
2113
  }
2114
2114
  catch (error) {
@@ -264,7 +264,7 @@ export declare const SESSION_STOP_SUBTREE_TOOL_NAME = "session_stop_subtree";
264
264
  export declare const SESSION_REMOVE_TOOL_NAME = "session_remove";
265
265
  export declare const SESSION_REMINDER_TOOL_NAME = "session_reminder";
266
266
  /** Model-facing description for session_reminder. */
267
- export declare 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.\n\nWHEN TO USE THIS:\n- Self-reminders and time-based checkpoints (e.g. \"Check child session progress in 60 seconds\", \"Review test run in 120 seconds\").\n- 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.\n\nActions:\n- \"create\" (default): Schedule a reminder. Requires delaySeconds (or seconds) and note. Returns reminderId.\n- \"cancel\": Cancel a pending reminder. Requires reminderId.\n- \"list\": List all active pending reminders for this conversation.";
267
+ export declare const SESSION_REMINDER_DESCRIPTION = "Set a timer that wakes THIS conversation. A timer without a note reports only the elapsed time. It does not introduce a new agenda or tell you how to act.\n\nFor a periodic project check-in, set delaySeconds and repeat: true once. On each wake-up, decide what to do based on the project\u2019s current state. Cancel the timer when it is no longer needed.\n\nActions:\n- \"create\" (default): Requires a positive delaySeconds (or seconds). Set repeat: true for recurring wake-ups that only report elapsed time. A one-off reminder can optionally include a short note. Returns reminderId.\n- \"cancel\": Cancel future wake-ups. Requires reminderId.\n- \"list\": List this conversation\u2019s active timers.\n\nUse scheduled_task for work that should run in a separate conversation.";
268
268
  /** Model-facing description for session_spawn. */
269
269
  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.";
270
270
  /** Model-facing description for session_status. */
@@ -369,16 +369,16 @@ export const SESSION_STOP_SUBTREE_TOOL_NAME = "session_stop_subtree";
369
369
  export const SESSION_REMOVE_TOOL_NAME = "session_remove";
370
370
  export const SESSION_REMINDER_TOOL_NAME = "session_reminder";
371
371
  /** Model-facing description for session_reminder. */
372
- 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.
372
+ export const SESSION_REMINDER_DESCRIPTION = `Set a timer that wakes THIS conversation. A timer without a note reports only the elapsed time. It does not introduce a new agenda or tell you how to act.
373
373
 
374
- WHEN TO USE THIS:
375
- - Self-reminders and time-based checkpoints (e.g. "Check child session progress in 60 seconds", "Review test run in 120 seconds").
376
- - 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.
374
+ For a periodic project check-in, set delaySeconds and repeat: true once. On each wake-up, decide what to do based on the project’s current state. Cancel the timer when it is no longer needed.
377
375
 
378
376
  Actions:
379
- - "create" (default): Schedule a reminder. Requires delaySeconds (or seconds) and note. Returns reminderId.
380
- - "cancel": Cancel a pending reminder. Requires reminderId.
381
- - "list": List all active pending reminders for this conversation.`;
377
+ - "create" (default): Requires a positive delaySeconds (or seconds). Set repeat: true for recurring wake-ups that only report elapsed time. A one-off reminder can optionally include a short note. Returns reminderId.
378
+ - "cancel": Cancel future wake-ups. Requires reminderId.
379
+ - "list": List this conversation’s active timers.
380
+
381
+ Use scheduled_task for work that should run in a separate conversation.`;
382
382
  /** Model-facing description for session_spawn. */
383
383
  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.
384
384
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@evandu/super-pi",
3
- "version": "0.1.221",
3
+ "version": "0.1.222",
4
4
  "description": "Web control plane and companion for Pi",
5
5
  "license": "MIT",
6
6
  "type": "module",