@11agents/cli 0.1.39 → 0.1.40

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@11agents/cli",
3
- "version": "0.1.39",
3
+ "version": "0.1.40",
4
4
  "description": "11agents local runtime and telemetry CLI",
5
5
  "type": "module",
6
6
  "bin": {
@@ -1653,12 +1653,31 @@ async function claimAndRunRuntimeTasks(registration, flags, deps, handlerModule,
1653
1653
  }
1654
1654
 
1655
1655
  async function drainRuntimeTasks(registration, flags, deps, handlerModule, retryState = createRetryState(), heartbeatIntervalMs = 15000, maxConcurrent = 1) {
1656
+ if (!handlerModule) return 0
1657
+ const runtimes = (registration?.runtimes || []).filter(r => r?.id)
1658
+ if (!runtimes.length) return 0
1659
+ const config = configFromFlags(flags)
1660
+ const machineKey = registration?.machine?.machine_key || machineOverride(flags) || ''
1661
+
1662
+ const perRuntime = Math.max(1, (deps.cpuCount ?? os.cpus().length) - 1)
1663
+ const effectiveConcurrent = Math.max(maxConcurrent, runtimes.length * perRuntime)
1664
+
1656
1665
  let completed = 0
1657
- while (true) {
1658
- const claimed = await claimAndRunRuntimeTasks(registration, flags, deps, handlerModule, retryState, heartbeatIntervalMs, maxConcurrent)
1659
- completed += claimed
1660
- if (claimed === 0) return completed
1661
- }
1666
+ // Worker pool: each worker loops claiming tasks until the queue is empty,
1667
+ // so a fast worker immediately picks up the next task without waiting for
1668
+ // slow workers to finish (unlike the old batched Promise.allSettled approach).
1669
+ const workers = Array.from({ length: effectiveConcurrent }, (_, i) => {
1670
+ const runtime = runtimes[i % runtimes.length]
1671
+ return (async () => {
1672
+ while (true) {
1673
+ const ran = await runOneRuntimeTaskSlot(runtime, config, machineKey, registration, flags, deps, handlerModule, retryState, heartbeatIntervalMs)
1674
+ if (!ran) break
1675
+ completed++
1676
+ }
1677
+ })()
1678
+ })
1679
+ await Promise.allSettled(workers)
1680
+ return completed
1662
1681
  }
1663
1682
 
1664
1683
  export async function startRuntimeDaemon(flags = {}, deps = {}) {