@cydm/pie 2.6.2 → 2.6.3

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.
@@ -1,7 +1,7 @@
1
1
  import { createRequire as __createRequire } from "node:module"; const require = __createRequire(import.meta.url);
2
2
  import {
3
3
  createAskUserCapability
4
- } from "../../../chunks/chunk-HT3OYGS7.js";
4
+ } from "../../../chunks/chunk-WG6E54WK.js";
5
5
  import "../../../chunks/chunk-Y4CYXJR7.js";
6
6
  import "../../../chunks/chunk-O2DKMLNX.js";
7
7
  import "../../../chunks/chunk-XXGYUYXI.js";
@@ -7,7 +7,7 @@ import {
7
7
  isPlanModeSafeCommand,
8
8
  markCompletedPlanSteps,
9
9
  restoreExecutionState
10
- } from "../../../chunks/chunk-HT3OYGS7.js";
10
+ } from "../../../chunks/chunk-WG6E54WK.js";
11
11
  import "../../../chunks/chunk-Y4CYXJR7.js";
12
12
  import "../../../chunks/chunk-O2DKMLNX.js";
13
13
  import {
@@ -1,11 +1,11 @@
1
1
  import { createRequire as __createRequire } from "node:module"; const require = __createRequire(import.meta.url);
2
2
  import {
3
3
  createCliHostCapabilities
4
- } from "../../../chunks/chunk-INQMGIKU.js";
4
+ } from "../../../chunks/chunk-KTSUOXA7.js";
5
5
  import {
6
6
  createSharedFileSystemTools,
7
7
  createSubagentCapability
8
- } from "../../../chunks/chunk-HT3OYGS7.js";
8
+ } from "../../../chunks/chunk-WG6E54WK.js";
9
9
  import "../../../chunks/chunk-Y4CYXJR7.js";
10
10
  import "../../../chunks/chunk-O2DKMLNX.js";
11
11
  import "../../../chunks/chunk-5353DEEC.js";
@@ -8,7 +8,7 @@ import {
8
8
  executeManageTodoList,
9
9
  executionStateToTodos,
10
10
  restoreExecutionState
11
- } from "../../../chunks/chunk-HT3OYGS7.js";
11
+ } from "../../../chunks/chunk-WG6E54WK.js";
12
12
  import "../../../chunks/chunk-Y4CYXJR7.js";
13
13
  import "../../../chunks/chunk-O2DKMLNX.js";
14
14
  import "../../../chunks/chunk-XXGYUYXI.js";
@@ -8,7 +8,7 @@ import {
8
8
  createSharedWebSearchTool,
9
9
  interpretShellExit,
10
10
  requestInteraction
11
- } from "./chunk-HT3OYGS7.js";
11
+ } from "./chunk-WG6E54WK.js";
12
12
  import {
13
13
  getBuiltinDir,
14
14
  getConfigDir
@@ -1390,6 +1390,17 @@ function formatSkillSummariesForPrompt(skills) {
1390
1390
  var DEFAULT_SUBAGENT_TIMEOUT_SECONDS = 1200;
1391
1391
  var DEFAULT_SUBAGENT_THINKING_LEVEL = "medium";
1392
1392
  var SUBAGENT_THINKING_LEVELS = ["off", "minimal", "low", "medium", "high", "xhigh"];
1393
+ var DEFAULT_HEARTBEAT_INTERVAL_MS = 3e4;
1394
+ function formatHeartbeatElapsed(ms) {
1395
+ const totalSeconds = Math.floor(ms / 1e3);
1396
+ if (totalSeconds < 60) return `${totalSeconds}s`;
1397
+ const minutes = Math.floor(totalSeconds / 60);
1398
+ if (minutes < 60) return `${minutes}m${String(totalSeconds % 60).padStart(2, "0")}s`;
1399
+ return `${Math.floor(minutes / 60)}h${String(minutes % 60).padStart(2, "0")}m`;
1400
+ }
1401
+ function clipHeartbeatLabel(text, maxLength = 60) {
1402
+ return text.length > maxLength ? `${text.slice(0, maxLength - 1)}\u2026` : text;
1403
+ }
1393
1404
  function formatSkillsForPrompt(skills) {
1394
1405
  return formatSkillSummariesForPrompt(skills);
1395
1406
  }
@@ -1596,9 +1607,30 @@ async function runSubagentWithProgress(deps, task, reportProgress, signal) {
1596
1607
  const startTime = Date.now();
1597
1608
  task.status = "running";
1598
1609
  let timedOut = false;
1610
+ let lastProgressAt = Date.now();
1611
+ let lastActivity = "starting";
1612
+ const report = (update) => {
1613
+ lastProgressAt = Date.now();
1614
+ if (update.message) lastActivity = update.message;
1615
+ reportProgress(update);
1616
+ };
1617
+ const heartbeatIntervalMs = deps.heartbeatIntervalMs ?? DEFAULT_HEARTBEAT_INTERVAL_MS;
1599
1618
  deps.debugLog?.("run", "runSubagentWithProgress START", { taskName: task.name, yoloMode: deps.yoloMode });
1619
+ let heartbeat;
1620
+ if (heartbeatIntervalMs > 0) {
1621
+ heartbeat = setInterval(() => {
1622
+ try {
1623
+ if (Date.now() - lastProgressAt < heartbeatIntervalMs) return;
1624
+ lastProgressAt = Date.now();
1625
+ reportProgress({
1626
+ message: `[${task.name}] Still working (${formatHeartbeatElapsed(Date.now() - startTime)} elapsed; last: ${clipHeartbeatLabel(lastActivity)})`
1627
+ });
1628
+ } catch {
1629
+ }
1630
+ }, Math.max(50, Math.min(1e3, heartbeatIntervalMs / 2)));
1631
+ }
1600
1632
  try {
1601
- reportProgress({ message: `[${task.name}] Starting...`, increment: 5 });
1633
+ report({ message: `[${task.name}] Starting...`, increment: 5 });
1602
1634
  const { plan, tools, apiKey, model } = buildSubagentPlan(deps, task.task, task.name, task.priority, task.timeoutSeconds, task.modelOverride, task.thinkingLevel, task.mode);
1603
1635
  task.plan = plan;
1604
1636
  task.needsParentWrite = task.mode === "read" && needsParentWrite(task.task);
@@ -1678,7 +1710,7 @@ ${formatSkillsForPrompt(deps.skills ?? [])}`;
1678
1710
  type: event.toolName === "bash" ? "command_run" : event.toolName === "read_file" ? "file_read" : "tool_success",
1679
1711
  message: `${event.toolName} started`
1680
1712
  });
1681
- reportProgress({ message: `[${task.name}] Using ${event.toolName}...` });
1713
+ report({ message: `[${task.name}] Using ${event.toolName}...` });
1682
1714
  }
1683
1715
  if (event.type === "tool_execution_end" && event.isError) {
1684
1716
  task.confidenceSignals.push({ type: "tool_error", message: `${event.toolName} failed` });
@@ -1692,7 +1724,7 @@ ${formatSkillsForPrompt(deps.skills ?? [])}`;
1692
1724
  prompt += "\n\nThis delegation is read mode. Do not write files. If changes are needed, describe them for the parent.";
1693
1725
  }
1694
1726
  prompt += "\n\nReturn evidence for your conclusion and state uncertainty as low, medium, or high.";
1695
- reportProgress({ message: `[${task.name}] Running plan ${plan.complexity}/${plan.modelClass}...`, increment: 20 });
1727
+ report({ message: `[${task.name}] Running plan ${plan.complexity}/${plan.modelClass}...`, increment: 20 });
1696
1728
  try {
1697
1729
  await Promise.race([
1698
1730
  (async () => {
@@ -1743,7 +1775,7 @@ ${formatSkillsForPrompt(deps.skills ?? [])}`;
1743
1775
  };
1744
1776
  task.parentHandoffRequired = isParentHandoffRequired(task) || outputTruncated;
1745
1777
  task.completedAt = Date.now();
1746
- reportProgress({ message: `[${task.name}] Completed (${durationMs}ms, ${toolCalls} tools)`, increment: 100 });
1778
+ report({ message: `[${task.name}] Completed (${durationMs}ms, ${toolCalls} tools)`, increment: 100 });
1747
1779
  } catch (error) {
1748
1780
  const errorMessage = error instanceof Error ? error.message : String(error);
1749
1781
  const stackTrace = error instanceof Error ? error.stack : void 0;
@@ -1758,7 +1790,11 @@ ${formatSkillsForPrompt(deps.skills ?? [])}`;
1758
1790
  task.uncertainty = "high";
1759
1791
  task.parentHandoffRequired = isParentHandoffRequired(task);
1760
1792
  task.completedAt = Date.now();
1761
- reportProgress({ message: `[${task.name}] Failed: ${errorMessage.slice(0, 100)}`, increment: 100 });
1793
+ report({ message: `[${task.name}] Failed: ${errorMessage.slice(0, 100)}`, increment: 100 });
1794
+ } finally {
1795
+ if (heartbeat) {
1796
+ clearInterval(heartbeat);
1797
+ }
1762
1798
  }
1763
1799
  }
1764
1800
  function buildParallelResult(tasks, totalDuration) {