better-opencode-async-agents 0.4.0 → 0.5.0

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 +1 @@
1
- {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAMpE;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAC3B,IAAI,EAAE,cAAc,EACpB,MAAM,EAAE,oBAAoB,EAC5B,OAAO,CAAC,EAAE;IACR,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,cAAc,KAAK,IAAI,CAAC;IAC3C,MAAM,CAAC,EAAE,CACP,SAAS,EAAE,gBAAgB,GAAG,YAAY,GAAG,gBAAgB,EAC7D,IAAI,EAAE,cAAc,KACjB,IAAI,CAAC;CACX,GACA,IAAI,CA2BN;AAED;;;;;;GAMG;AACH,wBAAgB,OAAO,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,SAAI,GAAG,MAAM,CAO7D;AAED;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,EAAE,MAAM,SAAI,GAAG,MAAM,CAkBzF;AAED,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAexE;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAGpE;AAED,wBAAgB,aAAa,CAAC,MAAM,EAAE,oBAAoB,GAAG,MAAM,CAalE;AAED,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,cAAc,GAAG,MAAM,CA8B7D;AAGD,UAAU,WAAW;IACnB,IAAI,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM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B,aAAa,CAAC,MAAM,EAAE,oBAAoB,GAAG,MAAM,CAalE;AAED,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,cAAc,GAAG,MAAM,CA8B7D;AAGD,UAAU,WAAW;IACnB,IAAI,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACzB,KAAK,CAAC,EAAE,KAAK,CAAC;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACjD;AAED,wBAAsB,gBAAgB,CACpC,IAAI,EAAE,cAAc,EACpB,WAAW,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,OAAO,CAAC,WAAW,EAAE,CAAC,GACzD,OAAO,CAAC,MAAM,CAAC,CA8CjB"}
package/dist/index.js CHANGED
@@ -909,23 +909,28 @@ function setTaskStatus(task, status, options) {
909
909
  }
910
910
  function shortId(sessionId, minLen = 8) {
911
911
  if (!sessionId.startsWith("ses_")) {
912
- return sessionId.slice(0, minLen + 4);
912
+ return sessionId.slice(0, minLen);
913
913
  }
914
914
  const suffix = sessionId.slice(4);
915
- return `ses_${suffix.slice(0, minLen)}`;
915
+ return suffix.slice(0, minLen);
916
916
  }
917
917
  function uniqueShortId(sessionId, siblingIds, minLen = 8) {
918
918
  if (!sessionId.startsWith("ses_")) {
919
- return sessionId.slice(0, minLen + 4);
919
+ return sessionId.slice(0, minLen);
920
920
  }
921
921
  const suffix = sessionId.slice(4);
922
922
  for (let len = minLen;len <= suffix.length; len++) {
923
- const candidate = `ses_${suffix.slice(0, len)}`;
924
- const hasClash = siblingIds.some((otherId) => otherId !== sessionId && otherId.startsWith(candidate));
923
+ const candidate = suffix.slice(0, len);
924
+ const hasClash = siblingIds.some((otherId) => {
925
+ if (otherId === sessionId)
926
+ return false;
927
+ const otherSuffix = otherId.startsWith("ses_") ? otherId.slice(4) : otherId;
928
+ return otherSuffix.startsWith(candidate);
929
+ });
925
930
  if (!hasClash)
926
931
  return candidate;
927
932
  }
928
- return sessionId;
933
+ return suffix;
929
934
  }
930
935
  function formatDuration(startStr, endStr) {
931
936
  const start = new Date(startStr);
@@ -1116,7 +1121,9 @@ function showProgressToast(allTasks, animationFrame, client, getTasksArray) {
1116
1121
  const prevTools = tools.slice(0, -1);
1117
1122
  toolsStr = prevTools.length > 0 ? ` - ${prevTools.join(" > ")} > 「${lastTool}」` : ` - 「${lastTool}」`;
1118
1123
  }
1119
- taskLines.push(`${spinner} [${shortId(task.sessionID)}] ${task.agent}: ${task.description} (${duration})${toolsStr}`);
1124
+ const callCount = task.progress?.toolCalls ?? 0;
1125
+ const callsStr = callCount > 0 ? ` [${callCount} calls]` : "";
1126
+ taskLines.push(`${spinner} [${shortId(task.sessionID)}] ${task.agent}: ${task.description} (${duration})${toolsStr}${callsStr}`);
1120
1127
  }
1121
1128
  const batchCompleted = batchTasks.filter((t) => t.status === "completed" || t.status === "error" || t.status === "cancelled").sort((a, b) => {
1122
1129
  const aTime = a.completedAt ? new Date(a.completedAt).getTime() : 0;
@@ -1128,7 +1135,9 @@ function showProgressToast(allTasks, animationFrame, client, getTasksArray) {
1128
1135
  for (const task of visibleCompleted) {
1129
1136
  const duration = formatDuration2(new Date(task.startedAt), task.completedAt ? new Date(task.completedAt) : undefined);
1130
1137
  const icon = task.status === "completed" ? "✓" : task.status === "error" ? "✗" : "⊘";
1131
- taskLines.push(`${icon} [${shortId(task.sessionID)}] ${task.agent}: ${task.description} (${duration})`);
1138
+ const callCount = task.progress?.toolCalls ?? 0;
1139
+ const callsStr = callCount > 0 ? ` [${callCount} calls]` : "";
1140
+ taskLines.push(`${icon} [${shortId(task.sessionID)}] ${task.agent}: ${task.description} (${duration})${callsStr}`);
1132
1141
  }
1133
1142
  const hiddenCount = batchCompleted.length - visibleCompleted.length;
1134
1143
  if (hiddenCount > 0) {
@@ -1827,9 +1836,10 @@ class BackgroundManager {
1827
1836
  return this.tasks.get(id);
1828
1837
  }
1829
1838
  findTasksByPrefix(prefix) {
1839
+ const normalizedPrefix = prefix.startsWith("ses_") ? prefix : `ses_${prefix}`;
1830
1840
  const matching = [];
1831
1841
  for (const [id] of this.tasks) {
1832
- if (id.startsWith(prefix)) {
1842
+ if (id.startsWith(normalizedPrefix)) {
1833
1843
  const task = this.tasks.get(id);
1834
1844
  if (task) {
1835
1845
  matching.push(task);
@@ -1842,6 +1852,10 @@ class BackgroundManager {
1842
1852
  if (this.tasks.has(idOrPrefix)) {
1843
1853
  return idOrPrefix;
1844
1854
  }
1855
+ const withPrefix = idOrPrefix.startsWith("ses_") ? idOrPrefix : `ses_${idOrPrefix}`;
1856
+ if (withPrefix !== idOrPrefix && this.tasks.has(withPrefix)) {
1857
+ return withPrefix;
1858
+ }
1845
1859
  const matching = this.findTasksByPrefix(idOrPrefix);
1846
1860
  if (matching.length === 0) {
1847
1861
  return null;
@@ -1860,7 +1874,12 @@ class BackgroundManager {
1860
1874
  if (persistedIds.includes(idOrPrefix)) {
1861
1875
  return idOrPrefix;
1862
1876
  }
1863
- const matching = persistedIds.filter((id) => id.startsWith(idOrPrefix)).map((id) => ({ id, task: persisted[id] })).filter((item) => item.task !== undefined).sort((a, b) => new Date(b.task.createdAt).getTime() - new Date(a.task.createdAt).getTime());
1877
+ const withPrefix = idOrPrefix.startsWith("ses_") ? idOrPrefix : `ses_${idOrPrefix}`;
1878
+ if (withPrefix !== idOrPrefix && persistedIds.includes(withPrefix)) {
1879
+ return withPrefix;
1880
+ }
1881
+ const normalizedPrefix = idOrPrefix.startsWith("ses_") ? idOrPrefix : `ses_${idOrPrefix}`;
1882
+ const matching = persistedIds.filter((id) => id.startsWith(normalizedPrefix)).map((id) => ({ id, task: persisted[id] })).filter((item) => item.task !== undefined).sort((a, b) => new Date(b.task.createdAt).getTime() - new Date(a.task.createdAt).getTime());
1864
1883
  if (matching.length > 0 && matching[0]) {
1865
1884
  return matching[0].id;
1866
1885
  }
@@ -2128,6 +2147,7 @@ function handleStats(_req, manager) {
2128
2147
  const byStatus = {};
2129
2148
  const byAgent = {};
2130
2149
  const toolCallsByName = {};
2150
+ const toolCallsByAgent = {};
2131
2151
  const durations = [];
2132
2152
  let activeTasks = 0;
2133
2153
  for (const task of tasks) {
@@ -2138,6 +2158,10 @@ function handleStats(_req, manager) {
2138
2158
  toolCallsByName[toolName] = (toolCallsByName[toolName] ?? 0) + count;
2139
2159
  }
2140
2160
  }
2161
+ const agentToolCalls = task.progress?.toolCalls ?? 0;
2162
+ if (agentToolCalls > 0) {
2163
+ toolCallsByAgent[task.agent] = (toolCallsByAgent[task.agent] ?? 0) + agentToolCalls;
2164
+ }
2141
2165
  if (task.status === "running" || task.status === "resumed") {
2142
2166
  activeTasks++;
2143
2167
  }
@@ -2151,6 +2175,7 @@ function handleStats(_req, manager) {
2151
2175
  byStatus,
2152
2176
  byAgent,
2153
2177
  toolCallsByName,
2178
+ toolCallsByAgent,
2154
2179
  duration: {
2155
2180
  avg: durations.length > 0 ? durations.reduce((a, b) => a + b, 0) / durations.length : 0,
2156
2181
  max: durations.length > 0 ? Math.max(...durations) : 0,
@@ -2235,6 +2260,7 @@ function handleTaskGroup(req, manager, groupId) {
2235
2260
  let cancelled = 0;
2236
2261
  let totalToolCalls = 0;
2237
2262
  const toolCallsByName = {};
2263
+ const toolCallsByAgent = {};
2238
2264
  let minStart = Number.POSITIVE_INFINITY;
2239
2265
  let maxEnd = 0;
2240
2266
  for (const t of groupTasks) {
@@ -2252,6 +2278,10 @@ function handleTaskGroup(req, manager, groupId) {
2252
2278
  toolCallsByName[toolName] = (toolCallsByName[toolName] ?? 0) + count;
2253
2279
  }
2254
2280
  }
2281
+ const agentToolCalls = t.progress?.toolCalls ?? 0;
2282
+ if (agentToolCalls > 0) {
2283
+ toolCallsByAgent[t.agent] = (toolCallsByAgent[t.agent] ?? 0) + agentToolCalls;
2284
+ }
2255
2285
  if (t.startedAt) {
2256
2286
  const s = new Date(t.startedAt).getTime();
2257
2287
  if (s < minStart)
@@ -2277,6 +2307,7 @@ function handleTaskGroup(req, manager, groupId) {
2277
2307
  completionRate: total > 0 ? completed / total : 0,
2278
2308
  totalToolCalls,
2279
2309
  toolCallsByName,
2310
+ toolCallsByAgent,
2280
2311
  duration
2281
2312
  }
2282
2313
  };
@@ -2470,6 +2501,7 @@ class StatusApiServer {
2470
2501
  const byStatus = {};
2471
2502
  const byAgent = {};
2472
2503
  const toolCallsByName = {};
2504
+ const toolCallsByAgent = {};
2473
2505
  const durations = [];
2474
2506
  let activeTasks = 0;
2475
2507
  for (const task of tasks) {
@@ -2480,6 +2512,10 @@ class StatusApiServer {
2480
2512
  toolCallsByName[toolName] = (toolCallsByName[toolName] ?? 0) + count;
2481
2513
  }
2482
2514
  }
2515
+ const agentToolCalls = task.progress?.toolCalls ?? 0;
2516
+ if (agentToolCalls > 0) {
2517
+ toolCallsByAgent[task.agent] = (toolCallsByAgent[task.agent] ?? 0) + agentToolCalls;
2518
+ }
2483
2519
  if (task.status === "running" || task.status === "resumed")
2484
2520
  activeTasks++;
2485
2521
  if (task.startedAt && task.completedAt) {
@@ -2492,6 +2528,7 @@ class StatusApiServer {
2492
2528
  byStatus,
2493
2529
  byAgent,
2494
2530
  toolCallsByName,
2531
+ toolCallsByAgent,
2495
2532
  duration: {
2496
2533
  avg: durations.length ? durations.reduce((a, b) => a + b, 0) / durations.length : 0,
2497
2534
  max: durations.length ? Math.max(...durations) : 0,
@@ -15154,5 +15191,5 @@ export {
15154
15191
  plugin as default
15155
15192
  };
15156
15193
 
15157
- //# debugId=C3296E4B18C7938B64756E2164756E21
15194
+ //# debugId=27FA094E382366FA64756E2164756E21
15158
15195
  //# sourceMappingURL=index.js.map