@standardagents/code 0.9.10 → 0.9.11

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/dist/index.js CHANGED
@@ -3052,7 +3052,8 @@ function parseToolCalls(message) {
3052
3052
  return [{ id, name, arguments: parseObject(item?.function?.arguments ?? item?.arguments ?? item?.args) }];
3053
3053
  });
3054
3054
  }
3055
- function deriveSessionActivity(messages) {
3055
+ var EMPTY_BOUNDARY_STALE_MS = 15e4;
3056
+ function deriveSessionActivity(messages, nowMs = Date.now()) {
3056
3057
  const visible = messages.filter((message) => message.silent !== true && message.metadata?.silent !== true).sort((a, b) => createdAt(a) - createdAt(b));
3057
3058
  if (visible.some((message) => message.status === "pending")) return { busy: true, currentTool: unresolvedTool(visible) };
3058
3059
  const last = visible.at(-1);
@@ -3061,6 +3062,11 @@ function deriveSessionActivity(messages) {
3061
3062
  if (currentTool) return { busy: true, currentTool };
3062
3063
  if (last.role === "user" || last.role === "tool") return { busy: true, currentTool: null };
3063
3064
  if (last.role === "assistant" && last.status !== "failed" && !messageText(last.content).trim()) {
3065
+ const raw = createdAt(last);
3066
+ const lastMs = raw > 1e14 ? raw / 1e3 : raw < 1e12 ? raw * 1e3 : raw;
3067
+ if (lastMs > 0 && nowMs - lastMs > EMPTY_BOUNDARY_STALE_MS) {
3068
+ return { busy: false, currentTool: null };
3069
+ }
3064
3070
  return { busy: true, currentTool: null };
3065
3071
  }
3066
3072
  return { busy: false, currentTool: null };